diff -Nrc3pad gcc-3.2.3/gcc/ada/1aexcept.adb gcc-3.3/gcc/ada/1aexcept.adb *** gcc-3.2.3/gcc/ada/1aexcept.adb 2002-05-04 03:27:12.000000000 +0000 --- gcc-3.3/gcc/ada/1aexcept.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/1aexcept.ads gcc-3.3/gcc/ada/1aexcept.ads *** gcc-3.2.3/gcc/ada/1aexcept.ads 2002-05-04 03:27:12.000000000 +0000 --- gcc-3.3/gcc/ada/1aexcept.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,13 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/1ic.ads gcc-3.3/gcc/ada/1ic.ads *** gcc-3.2.3/gcc/ada/1ic.ads 2001-10-02 13:35:47.000000000 +0000 --- gcc-3.3/gcc/ada/1ic.ads 2002-03-14 10:58:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT Hi Integrity Edition. In accordance with the copyright of that -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/1ssecsta.adb gcc-3.3/gcc/ada/1ssecsta.adb *** gcc-3.2.3/gcc/ada/1ssecsta.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/1ssecsta.adb 2002-10-23 08:04:16.000000000 +0000 *************** *** 0 **** --- 1,144 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S Y S T E M . S E C O N D A R Y _ S T A C K -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 1992-2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This is the HI-E version of this package. + + with Unchecked_Conversion; + + package body System.Secondary_Stack is + + use type SSE.Storage_Offset; + + type Memory is array (Mark_Id range <>) of SSE.Storage_Element; + + type Stack_Id is record + Top : Mark_Id; + Last : Mark_Id; + Mem : Memory (1 .. Mark_Id'Last); + end record; + pragma Suppress_Initialization (Stack_Id); + + type Stack_Ptr is access Stack_Id; + + function From_Addr is new Unchecked_Conversion (Address, Stack_Ptr); + + function Get_Sec_Stack return Stack_Ptr; + pragma Import (C, Get_Sec_Stack, "__gnat_get_secondary_stack"); + -- Return the address of the secondary stack. + -- In a multi-threaded environment, Sec_Stack should be a thread-local + -- variable. + + -- Possible implementation of Get_Sec_Stack in a single-threaded + -- environment: + -- + -- Chunk : aliased Memory (1 .. Default_Secondary_Stack_Size); + -- for Chunk'Alignment use Standard'Maximum_Alignment; + -- -- The secondary stack. + -- + -- function Get_Sec_Stack return Stack_Ptr is + -- begin + -- return From_Addr (Chunk'Address); + -- end Get_Sec_Stack; + -- + -- begin + -- SS_Init (Chunk'Address, Default_Secondary_Stack_Size); + -- end System.Secondary_Stack; + + ----------------- + -- SS_Allocate -- + ----------------- + + procedure SS_Allocate + (Address : out System.Address; + Storage_Size : SSE.Storage_Count) + is + Max_Align : constant Mark_Id := Mark_Id (Standard'Maximum_Alignment); + Max_Size : constant Mark_Id := + ((Mark_Id (Storage_Size) + Max_Align - 1) / Max_Align) + * Max_Align; + Sec_Stack : constant Stack_Ptr := Get_Sec_Stack; + + begin + if Sec_Stack.Top + Max_Size > Sec_Stack.Last then + raise Storage_Error; + end if; + + Address := Sec_Stack.Mem (Sec_Stack.Top)'Address; + Sec_Stack.Top := Sec_Stack.Top + Mark_Id (Max_Size); + end SS_Allocate; + + ------------- + -- SS_Free -- + ------------- + + procedure SS_Free (Stk : in out System.Address) is + begin + Stk := Null_Address; + end SS_Free; + + ------------- + -- SS_Init -- + ------------- + + procedure SS_Init + (Stk : System.Address; + Size : Natural := Default_Secondary_Stack_Size) + is + Stack : Stack_Ptr := From_Addr (Stk); + begin + pragma Assert (Size >= 2 * Mark_Id'Max_Size_In_Storage_Elements); + + Stack.Top := Stack.Mem'First; + Stack.Last := Mark_Id (Size) - 2 * Mark_Id'Max_Size_In_Storage_Elements; + end SS_Init; + + ------------- + -- SS_Mark -- + ------------- + + function SS_Mark return Mark_Id is + begin + return Get_Sec_Stack.Top; + end SS_Mark; + + ---------------- + -- SS_Release -- + ---------------- + + procedure SS_Release (M : Mark_Id) is + begin + Get_Sec_Stack.Top := M; + end SS_Release; + + end System.Secondary_Stack; diff -Nrc3pad gcc-3.2.3/gcc/ada/1ssecsta.ads gcc-3.3/gcc/ada/1ssecsta.ads *** gcc-3.2.3/gcc/ada/1ssecsta.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/1ssecsta.ads 2002-10-23 08:04:16.000000000 +0000 *************** *** 0 **** --- 1,84 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S Y S T E M . S E C O N D A R Y _ S T A C K -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 1992-2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with System.Storage_Elements; + + package System.Secondary_Stack is + + package SSE renames System.Storage_Elements; + + Default_Secondary_Stack_Size : constant := 10 * 1024; + -- Default size of a secondary stack + + procedure SS_Init + (Stk : System.Address; + Size : Natural := Default_Secondary_Stack_Size); + -- Initialize the secondary stack with a main stack of the given Size. + -- + -- Stk is an "in" parameter that is already pointing to a memory area of + -- size Size. + -- + -- The secondary stack is fixed, and any attempt to allocate more than the + -- initial size will result in a Storage_Error being raised. + + procedure SS_Allocate + (Address : out System.Address; + Storage_Size : SSE.Storage_Count); + -- Allocate enough space for a 'Storage_Size' bytes object with Maximum + -- alignment. The address of the allocated space is returned in 'Address' + + procedure SS_Free (Stk : in out System.Address); + -- Release the memory allocated for the Secondary Stack. That is to say, + -- all the allocated chuncks. + -- Upon return, Stk will be set to System.Null_Address + + type Mark_Id is private; + -- Type used to mark the stack. + + function SS_Mark return Mark_Id; + -- Return the Mark corresponding to the current state of the stack + + procedure SS_Release (M : Mark_Id); + -- Restore the state of the stack corresponding to the mark M. If an + -- additional chunk have been allocated, it will never be freed during a + + private + + SS_Pool : Integer; + -- Unused entity that is just present to ease the sharing of the pool + -- mechanism for specific allocation/deallocation in the compiler + + type Mark_Id is new SSE.Integer_Address; + + end System.Secondary_Stack; diff -Nrc3pad gcc-3.2.3/gcc/ada/31soccon.ads gcc-3.3/gcc/ada/31soccon.ads *** gcc-3.2.3/gcc/ada/31soccon.ads 2001-10-02 13:35:47.000000000 +0000 --- gcc-3.3/gcc/ada/31soccon.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/31soliop.ads gcc-3.3/gcc/ada/31soliop.ads *** gcc-3.2.3/gcc/ada/31soliop.ads 2001-10-02 13:35:47.000000000 +0000 --- gcc-3.3/gcc/ada/31soliop.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3asoccon.ads gcc-3.3/gcc/ada/3asoccon.ads *** gcc-3.2.3/gcc/ada/3asoccon.ads 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3asoccon.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3bsoccon.ads gcc-3.3/gcc/ada/3bsoccon.ads *** gcc-3.2.3/gcc/ada/3bsoccon.ads 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3bsoccon.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3gsoccon.ads gcc-3.3/gcc/ada/3gsoccon.ads *** gcc-3.2.3/gcc/ada/3gsoccon.ads 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3gsoccon.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3hsoccon.ads gcc-3.3/gcc/ada/3hsoccon.ads *** gcc-3.2.3/gcc/ada/3hsoccon.ads 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3hsoccon.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3lsoccon.ads gcc-3.3/gcc/ada/3lsoccon.ads *** gcc-3.2.3/gcc/ada/3lsoccon.ads 2001-10-04 17:50:42.000000000 +0000 --- gcc-3.3/gcc/ada/3lsoccon.ads 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,115 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- G N A T . S O C K E T S . C O N S T A N T S -- - -- -- - -- S p e c -- - -- -- - -- $Revision: 1.1 $ - -- -- - -- Copyright (C) 2001 Ada Core Technologies, 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- 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. -- - -- -- - -- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). -- - -- -- - ------------------------------------------------------------------------------ - - -- This is the version for GNU/Linux - - package GNAT.Sockets.Constants is - - -- Families - - AF_INET : constant := 2; - AF_INET6 : constant := 10; - - -- Modes - - SOCK_STREAM : constant := 1; - SOCK_DGRAM : constant := 2; - - -- Socket Errors - - EBADF : constant := 9; - ENOTSOCK : constant := 88; - ENOTCONN : constant := 107; - ENOBUFS : constant := 105; - EOPNOTSUPP : constant := 95; - EFAULT : constant := 14; - EWOULDBLOCK : constant := 11; - EADDRNOTAVAIL : constant := 99; - EMSGSIZE : constant := 90; - EADDRINUSE : constant := 98; - EINVAL : constant := 22; - EACCES : constant := 13; - EAFNOSUPPORT : constant := 97; - EISCONN : constant := 106; - ETIMEDOUT : constant := 110; - ECONNREFUSED : constant := 111; - ENETUNREACH : constant := 101; - EALREADY : constant := 114; - EINPROGRESS : constant := 115; - ENOPROTOOPT : constant := 92; - EPROTONOSUPPORT : constant := 93; - EINTR : constant := 4; - EIO : constant := 5; - ESOCKTNOSUPPORT : constant := 94; - - -- Host Errors - - HOST_NOT_FOUND : constant := 1; - TRY_AGAIN : constant := 2; - NO_ADDRESS : constant := 4; - NO_RECOVERY : constant := 3; - - -- Control Flags - - FIONBIO : constant := 21537; - FIONREAD : constant := 21531; - - -- Shutdown Modes - - SHUT_RD : constant := 0; - SHUT_WR : constant := 1; - SHUT_RDWR : constant := 2; - - -- Protocol Levels - - SOL_SOCKET : constant := 1; - IPPROTO_IP : constant := 0; - IPPROTO_UDP : constant := 17; - IPPROTO_TCP : constant := 6; - - -- Socket Options - - TCP_NODELAY : constant := 1; - SO_SNDBUF : constant := 7; - SO_RCVBUF : constant := 8; - SO_REUSEADDR : constant := 2; - SO_KEEPALIVE : constant := 9; - SO_LINGER : constant := 13; - SO_ERROR : constant := 4; - SO_BROADCAST : constant := 6; - IP_ADD_MEMBERSHIP : constant := 35; - IP_DROP_MEMBERSHIP : constant := 36; - IP_MULTICAST_TTL : constant := 33; - IP_MULTICAST_LOOP : constant := 34; - end GNAT.Sockets.Constants; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3ssoccon.ads gcc-3.3/gcc/ada/3ssoccon.ads *** gcc-3.2.3/gcc/ada/3ssoccon.ads 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3ssoccon.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3ssoliop.ads gcc-3.3/gcc/ada/3ssoliop.ads *** gcc-3.2.3/gcc/ada/3ssoliop.ads 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3ssoliop.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3wsoccon.ads gcc-3.3/gcc/ada/3wsoccon.ads *** gcc-3.2.3/gcc/ada/3wsoccon.ads 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3wsoccon.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3wsocthi.adb gcc-3.3/gcc/ada/3wsocthi.adb *** gcc-3.2.3/gcc/ada/3wsocthi.adb 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3wsocthi.adb 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3wsocthi.ads gcc-3.3/gcc/ada/3wsocthi.ads *** gcc-3.2.3/gcc/ada/3wsocthi.ads 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3wsocthi.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/3wsoliop.ads gcc-3.3/gcc/ada/3wsoliop.ads *** gcc-3.2.3/gcc/ada/3wsoliop.ads 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/3wsoliop.ads 2002-03-14 10:58:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/41intnam.ads gcc-3.3/gcc/ada/41intnam.ads *** gcc-3.2.3/gcc/ada/41intnam.ads 2002-05-04 03:27:12.000000000 +0000 --- gcc-3.3/gcc/ada/41intnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 43,49 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handler - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping with System.OS_Interface; -- used for names of interrupts --- 42,47 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/42intnam.ads gcc-3.3/gcc/ada/42intnam.ads *** gcc-3.2.3/gcc/ada/42intnam.ads 2002-05-04 03:27:12.000000000 +0000 --- gcc-3.3/gcc/ada/42intnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 43,49 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handler - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping with System.OS_Interface; -- used for names of interrupts --- 42,47 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4aintnam.ads gcc-3.3/gcc/ada/4aintnam.ads *** gcc-3.2.3/gcc/ada/4aintnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4aintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 43,49 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handler - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping with System.OS_Interface; -- used for names of interrupts --- 42,47 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4cintnam.ads gcc-3.3/gcc/ada/4cintnam.ads *** gcc-3.2.3/gcc/ada/4cintnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4cintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 48,54 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handler - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping -- This target-dependent package spec contains names of interrupts -- supported by the local system. --- 47,52 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4dintnam.ads gcc-3.3/gcc/ada/4dintnam.ads *** gcc-3.2.3/gcc/ada/4dintnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4dintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 43,49 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: Made available for Ada handler - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping -- This target-dependent package spec contains names of interrupts -- supported by the local system. --- 42,47 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4gintnam.ads gcc-3.3/gcc/ada/4gintnam.ads *** gcc-3.2.3/gcc/ada/4gintnam.ads 2001-10-26 00:50:40.000000000 +0000 --- gcc-3.3/gcc/ada/4gintnam.ads 2002-03-14 10:58:23.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3 $ -- -- ! -- Copyright (C) 1997-2001, Florida State University -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU Library General Public License as published by the -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1997-2002, Florida State University -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU Library General Public License as published by the -- *************** *** 50,56 **** -- (Pthread library): -- -- SIGINT: made available for Ada handler - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping -- This target-dependent package spec contains names of interrupts -- supported by the local system. --- 49,54 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4hexcpol.adb gcc-3.3/gcc/ada/4hexcpol.adb *** gcc-3.2.3/gcc/ada/4hexcpol.adb 2002-05-04 03:27:12.000000000 +0000 --- gcc-3.3/gcc/ada/4hexcpol.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,13 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4hintnam.ads gcc-3.3/gcc/ada/4hintnam.ads *** gcc-3.2.3/gcc/ada/4hintnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4hintnam.ads 2002-03-14 10:58:23.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002, Florida State University -- -- -- -- GNARL 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- -- *************** *** 44,50 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handler - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping -- This target-dependent package spec contains names of interrupts -- supported by the local system. --- 43,48 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4lintnam.ads gcc-3.3/gcc/ada/4lintnam.ads *** gcc-3.2.3/gcc/ada/4lintnam.ads 2002-05-04 03:27:12.000000000 +0000 --- gcc-3.3/gcc/ada/4lintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 48,54 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handler - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping -- This target-dependent package spec contains names of interrupts -- supported by the local system. --- 47,52 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4mintnam.ads gcc-3.3/gcc/ada/4mintnam.ads *** gcc-3.2.3/gcc/ada/4mintnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4mintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1996-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 43,49 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handlers - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping -- This target-dependent package spec contains names of interrupts -- supported by the local system. --- 42,47 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4nintnam.ads gcc-3.3/gcc/ada/4nintnam.ads *** gcc-3.2.3/gcc/ada/4nintnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4nintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (No Tasking Version) -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1991,92,93,94,95,1996 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4ointnam.ads gcc-3.3/gcc/ada/4ointnam.ads *** gcc-3.2.3/gcc/ada/4ointnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4ointnam.ads 2002-03-14 10:58:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-1997 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4onumaux.ads gcc-3.3/gcc/ada/4onumaux.ads *** gcc-3.2.3/gcc/ada/4onumaux.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4onumaux.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (C Library Version for x86) -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4pintnam.ads gcc-3.3/gcc/ada/4pintnam.ads *** gcc-3.2.3/gcc/ada/4pintnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4pintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 43,49 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handlers - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping -- This target-dependent package spec contains names of interrupts -- supported by the local system. --- 42,47 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4rintnam.ads gcc-3.3/gcc/ada/4rintnam.ads *** gcc-3.2.3/gcc/ada/4rintnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4rintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 47,53 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handlers - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping -- This target-dependent package spec contains names of interrupts -- supported by the local system. --- 46,51 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4sintnam.ads gcc-3.3/gcc/ada/4sintnam.ads *** gcc-3.2.3/gcc/ada/4sintnam.ads 2002-05-07 08:22:01.000000000 +0000 --- gcc-3.3/gcc/ada/4sintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 48,54 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handlers - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping with System.OS_Interface; -- used for names of interrupts --- 47,52 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4uintnam.ads gcc-3.3/gcc/ada/4uintnam.ads *** gcc-3.2.3/gcc/ada/4uintnam.ads 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/4uintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 43,49 **** -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- -- SIGINT: made available for Ada handlers - -- SIGILL, SIGBUS, SIGSEGV: disconnected from runtime exception mapping with System.OS_Interface; -- used for names of interrupts --- 42,47 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4vcaldel.adb gcc-3.3/gcc/ada/4vcaldel.adb *** gcc-3.2.3/gcc/ada/4vcaldel.adb 2001-10-02 13:35:48.000000000 +0000 --- gcc-3.3/gcc/ada/4vcaldel.adb 2002-03-14 10:58:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2000 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4vcalend.adb gcc-3.3/gcc/ada/4vcalend.adb *** gcc-3.2.3/gcc/ada/4vcalend.adb 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/4vcalend.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Ada.Calendar is *** 60,68 **** -- Some basic constants used throughout - Days_In_Month : constant array (Month_Number) of Day_Number := - (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); - function To_Relative_Time (D : Duration) return Time; function To_Relative_Time (D : Duration) return Time is --- 59,64 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4vcalend.ads gcc-3.3/gcc/ada/4vcalend.ads *** gcc-3.2.3/gcc/ada/4vcalend.ads 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/4vcalend.ads 2002-03-14 10:58:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4vintnam.ads gcc-3.3/gcc/ada/4vintnam.ads *** gcc-3.2.3/gcc/ada/4vintnam.ads 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/4vintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1991-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4wcalend.adb gcc-3.3/gcc/ada/4wcalend.adb *** gcc-3.2.3/gcc/ada/4wcalend.adb 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/4wcalend.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4wexcpol.adb gcc-3.3/gcc/ada/4wexcpol.adb *** gcc-3.2.3/gcc/ada/4wexcpol.adb 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/4wexcpol.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,13 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4wintnam.ads gcc-3.3/gcc/ada/4wintnam.ads *** gcc-3.2.3/gcc/ada/4wintnam.ads 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/4wintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1997-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4zintnam.ads gcc-3.3/gcc/ada/4zintnam.ads *** gcc-3.2.3/gcc/ada/4zintnam.ads 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/4zintnam.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 34,53 **** ------------------------------------------------------------------------------ -- This is the VxWorks version of this package. - -- - -- The following signals are reserved by the run time: - -- - -- SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGABRT - -- - -- The pragma Unreserve_All_Interrupts affects the following signal(s): - -- - -- none - - -- This target-dependent package spec contains names of interrupts - -- supported by the local system. with System.OS_Interface; - with System.VxWorks; package Ada.Interrupts.Names is --- 33,40 ---- *************** package Ada.Interrupts.Names is *** 55,190 **** range Interrupt_ID'First .. System.OS_Interface.Max_HW_Interrupt; -- Range of values that can be used for hardware interrupts. - -- The following constants can be used for software interrupts mapped to - -- user-level signals: - - SIGHUP : constant Interrupt_ID; - -- hangup - - SIGINT : constant Interrupt_ID; - -- interrupt - - SIGQUIT : constant Interrupt_ID; - -- quit - - SIGILL : constant Interrupt_ID; - -- illegal instruction (not reset) - - SIGTRAP : constant Interrupt_ID; - -- trace trap (not reset) - - SIGIOT : constant Interrupt_ID; - -- IOT instruction - - SIGABRT : constant Interrupt_ID; - -- used by abort, replace SIGIOT - - SIGEMT : constant Interrupt_ID; - -- EMT instruction - - SIGFPE : constant Interrupt_ID; - -- floating point exception - - SIGKILL : constant Interrupt_ID; - -- kill (cannot be caught or ignored) - - SIGBUS : constant Interrupt_ID; - -- bus error - - SIGSEGV : constant Interrupt_ID; - -- segmentation violation - - SIGSYS : constant Interrupt_ID; - -- bad argument to system call - - SIGPIPE : constant Interrupt_ID; - -- no one to read it - - SIGALRM : constant Interrupt_ID; - -- alarm clock - - SIGTERM : constant Interrupt_ID; - -- software termination signal from kill - - SIGURG : constant Interrupt_ID; - -- urgent condition on IO channel - - SIGSTOP : constant Interrupt_ID; - -- stop (cannot be caught or ignored) - - SIGTSTP : constant Interrupt_ID; - -- user stop requested from tty - - SIGCONT : constant Interrupt_ID; - -- stopped process has been continued - - SIGCHLD : constant Interrupt_ID; - -- child status change - - SIGTTIN : constant Interrupt_ID; - -- background tty read attempted - - SIGTTOU : constant Interrupt_ID; - -- background tty write attempted - - SIGIO : constant Interrupt_ID; - -- input/output possible, - - SIGXCPU : constant Interrupt_ID; - -- CPU time limit exceeded - - SIGXFSZ : constant Interrupt_ID; - -- filesize limit exceeded - - SIGVTALRM : constant Interrupt_ID; - -- virtual timer expired - - SIGPROF : constant Interrupt_ID; - -- profiling timer expired - - SIGWINCH : constant Interrupt_ID; - -- window size change - - SIGUSR1 : constant Interrupt_ID; - -- user defined signal 1 - - SIGUSR2 : constant Interrupt_ID; - -- user defined signal 2 - - private - - Signal_Base : constant := System.VxWorks.Num_HW_Interrupts; - - SIGHUP : constant Interrupt_ID := 1 + Signal_Base; - SIGINT : constant Interrupt_ID := 2 + Signal_Base; - SIGQUIT : constant Interrupt_ID := 3 + Signal_Base; - SIGILL : constant Interrupt_ID := 4 + Signal_Base; - SIGTRAP : constant Interrupt_ID := 5 + Signal_Base; - SIGIOT : constant Interrupt_ID := 6 + Signal_Base; - SIGABRT : constant Interrupt_ID := 6 + Signal_Base; - SIGEMT : constant Interrupt_ID := 7 + Signal_Base; - SIGFPE : constant Interrupt_ID := 8 + Signal_Base; - SIGKILL : constant Interrupt_ID := 9 + Signal_Base; - SIGBUS : constant Interrupt_ID := 10 + Signal_Base; - SIGSEGV : constant Interrupt_ID := 11 + Signal_Base; - SIGSYS : constant Interrupt_ID := 12 + Signal_Base; - SIGPIPE : constant Interrupt_ID := 13 + Signal_Base; - SIGALRM : constant Interrupt_ID := 14 + Signal_Base; - SIGTERM : constant Interrupt_ID := 15 + Signal_Base; - SIGURG : constant Interrupt_ID := 16 + Signal_Base; - SIGSTOP : constant Interrupt_ID := 17 + Signal_Base; - SIGTSTP : constant Interrupt_ID := 18 + Signal_Base; - SIGCONT : constant Interrupt_ID := 19 + Signal_Base; - SIGCHLD : constant Interrupt_ID := 20 + Signal_Base; - SIGTTIN : constant Interrupt_ID := 21 + Signal_Base; - SIGTTOU : constant Interrupt_ID := 22 + Signal_Base; - SIGIO : constant Interrupt_ID := 23 + Signal_Base; - SIGXCPU : constant Interrupt_ID := 24 + Signal_Base; - SIGXFSZ : constant Interrupt_ID := 25 + Signal_Base; - SIGVTALRM : constant Interrupt_ID := 26 + Signal_Base; - SIGPROF : constant Interrupt_ID := 27 + Signal_Base; - SIGWINCH : constant Interrupt_ID := 28 + Signal_Base; - SIGUSR1 : constant Interrupt_ID := 30 + Signal_Base; - SIGUSR2 : constant Interrupt_ID := 31 + Signal_Base; - end Ada.Interrupts.Names; --- 42,45 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4znumaux.ads gcc-3.3/gcc/ada/4znumaux.ads *** gcc-3.2.3/gcc/ada/4znumaux.ads 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/4znumaux.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (C Library Version, VxWorks) -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4zsytaco.adb gcc-3.3/gcc/ada/4zsytaco.adb *** gcc-3.2.3/gcc/ada/4zsytaco.adb 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/4zsytaco.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/4zsytaco.ads gcc-3.3/gcc/ada/4zsytaco.ads *** gcc-3.2.3/gcc/ada/4zsytaco.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/4zsytaco.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/51osinte.adb gcc-3.3/gcc/ada/51osinte.adb *** gcc-3.2.3/gcc/ada/51osinte.adb 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/51osinte.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/51osinte.ads gcc-3.3/gcc/ada/51osinte.ads *** gcc-3.2.3/gcc/ada/51osinte.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/51osinte.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/52osinte.adb gcc-3.3/gcc/ada/52osinte.adb *** gcc-3.2.3/gcc/ada/52osinte.adb 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/52osinte.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/52osinte.ads gcc-3.3/gcc/ada/52osinte.ads *** gcc-3.2.3/gcc/ada/52osinte.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/52osinte.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/52system.ads gcc-3.3/gcc/ada/52system.ads *** gcc-3.2.3/gcc/ada/52system.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/52system.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (LynxOS PPC/x86 Version) -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (LynxOS PPC/x86 Version) -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 88,119 **** -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := ! Bit_Order'Val (Standard'Default_Bit_Order); -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 87,104 ---- -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := High_Order_First; -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 131,138 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; diff -Nrc3pad gcc-3.2.3/gcc/ada/53osinte.ads gcc-3.3/gcc/ada/53osinte.ads *** gcc-3.2.3/gcc/ada/53osinte.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/53osinte.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/54osinte.ads gcc-3.3/gcc/ada/54osinte.ads *** gcc-3.2.3/gcc/ada/54osinte.ads 2001-10-02 13:42:24.000000000 +0000 --- gcc-3.3/gcc/ada/54osinte.ads 2002-03-14 10:58:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5amastop.adb gcc-3.3/gcc/ada/5amastop.adb *** gcc-3.2.3/gcc/ada/5amastop.adb 2001-10-02 13:42:24.000000000 +0000 --- gcc-3.3/gcc/ada/5amastop.adb 2002-03-14 10:58:27.000000000 +0000 *************** *** 7,13 **** -- B o d y -- -- (Version for Alpha/Dec Unix) -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1999-2001 Ada Core Technologies, Inc. -- -- -- --- 7,12 ---- *************** package body System.Machine_State_Operat *** 87,97 **** ------------------------ procedure Free_Machine_State (M : in out Machine_State) is - procedure Gnat_Free (M : in Machine_State); - pragma Import (C, Gnat_Free, "__gnat_free"); - begin ! Gnat_Free (M); M := Machine_State (Null_Address); end Free_Machine_State; --- 86,93 ---- ------------------------ procedure Free_Machine_State (M : in out Machine_State) is begin ! Memory.Free (Address (M)); M := Machine_State (Null_Address); end Free_Machine_State; diff -Nrc3pad gcc-3.2.3/gcc/ada/5aosinte.adb gcc-3.3/gcc/ada/5aosinte.adb *** gcc-3.2.3/gcc/ada/5aosinte.adb 2001-10-02 13:42:24.000000000 +0000 --- gcc-3.3/gcc/ada/5aosinte.adb 2002-03-14 10:58:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5aosinte.ads gcc-3.3/gcc/ada/5aosinte.ads *** gcc-3.2.3/gcc/ada/5aosinte.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/5aosinte.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5asystem.ads gcc-3.3/gcc/ada/5asystem.ads *** gcc-3.2.3/gcc/ada/5asystem.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/5asystem.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (DEC Unix Version) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (DEC Unix Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 64; ! Memory_Size : constant := 2 ** 64; -- Address comparison *************** pragma Pure (System); *** 92,118 **** -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! ! Max_Interrupt_Priority : constant Positive := 31; ! ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 91,104 ---- -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 60; ! Max_Interrupt_Priority : constant Positive := 63; ! subtype Any_Priority is Integer range 0 .. 63; ! subtype Priority is Any_Priority range 0 .. 60; ! subtype Interrupt_Priority is Any_Priority range 61 .. 63; ! Default_Priority : constant Priority := 30; private *************** private *** 130,139 **** -- of the individual switch values. AAMP : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := False; Frontend_Layout : constant Boolean := False; ! Functions_Return_By_DSP : constant Boolean := True; Long_Shifts_Inlined : constant Boolean := True; High_Integrity_Mode : constant Boolean := False; Machine_Overflows : constant Boolean := False; --- 116,128 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := False; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; ! Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; High_Integrity_Mode : constant Boolean := False; Machine_Overflows : constant Boolean := False; *************** private *** 143,151 **** Stack_Check_Default : constant Boolean := True; Stack_Check_Probes : constant Boolean := True; Use_Ada_Main_Program_Name : constant Boolean := False; ! ZCX_By_Default : constant Boolean := True; GCC_ZCX_Support : constant Boolean := False; ! Front_End_ZCX_Support : constant Boolean := True; -- Note: Denorm is False because denormals are only handled properly -- if the -mieee switch is set, and we do not require this usage. --- 132,140 ---- Stack_Check_Default : constant Boolean := True; Stack_Check_Probes : constant Boolean := True; Use_Ada_Main_Program_Name : constant Boolean := False; ! ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; ! Front_End_ZCX_Support : constant Boolean := False; -- Note: Denorm is False because denormals are only handled properly -- if the -mieee switch is set, and we do not require this usage. *************** private *** 193,229 **** -- Suppress initialization in case gnat.adc specifies Normalize_Scalars Underlying_Priorities : constant Priorities_Mapping := ! (Priority'First => 16, ! 1 => 17, ! 2 => 18, ! 3 => 18, ! 4 => 18, ! 5 => 18, ! 6 => 19, ! 7 => 19, ! 8 => 19, ! 9 => 20, ! 10 => 20, ! 11 => 21, ! 12 => 21, ! 13 => 22, ! 14 => 23, ! Default_Priority => 24, ! 16 => 25, ! 17 => 25, ! 18 => 25, ! 19 => 26, ! 20 => 26, ! 21 => 26, ! 22 => 27, ! 23 => 27, ! 24 => 27, ! 25 => 28, ! 26 => 28, ! 27 => 29, ! 28 => 29, ! 29 => 30, ! Priority'Last => 30, ! Interrupt_Priority => 31); end System; --- 182,210 ---- -- Suppress initialization in case gnat.adc specifies Normalize_Scalars Underlying_Priorities : constant Priorities_Mapping := ! ! (Priority'First => 0, ! ! 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, ! 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, ! 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, ! 16 => 16, 17 => 17, 18 => 18, 19 => 19, 20 => 20, ! 21 => 21, 22 => 22, 23 => 23, 24 => 24, 25 => 25, ! 26 => 26, 27 => 27, 28 => 28, 29 => 29, ! ! Default_Priority => 30, ! ! 31 => 31, 32 => 32, 33 => 33, 34 => 34, 35 => 35, ! 36 => 36, 37 => 37, 38 => 38, 39 => 39, 40 => 40, ! 41 => 41, 42 => 42, 43 => 43, 44 => 44, 45 => 45, ! 46 => 46, 47 => 47, 48 => 48, 49 => 49, 50 => 50, ! 51 => 51, 52 => 52, 53 => 53, 54 => 54, 55 => 55, ! 56 => 56, 57 => 57, 58 => 58, 59 => 59, ! ! Priority'Last => 60, ! ! 61 => 61, 62 => 62, ! ! Interrupt_Priority'Last => 63); end System; diff -Nrc3pad gcc-3.2.3/gcc/ada/5ataprop.adb gcc-3.3/gcc/ada/5ataprop.adb *** gcc-3.2.3/gcc/ada/5ataprop.adb 2001-12-16 01:13:27.000000000 +0000 --- gcc-3.3/gcc/ada/5ataprop.adb 2002-10-23 08:27:54.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ *************** package body System.Task_Primitives.Oper *** 99,113 **** package SSL renames System.Soft_Links; ! ----------------- ! -- Local Data -- ! ----------------- -- The followings are logically constants, but need to be initialized -- at run time. ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. --- 97,113 ---- package SSL renames System.Soft_Links; ! ---------------- ! -- Local Data -- ! ---------------- -- The followings are logically constants, but need to be initialized -- at run time. ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. *************** package body System.Task_Primitives.Oper *** 221,227 **** -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as All_Tasks_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. --- 221,227 ---- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. *************** package body System.Task_Primitives.Oper *** 317,349 **** All_Tasks_Link := Self_ID.Common.All_Tasks_Link; Current_Prio := Get_Priority (Self_ID); ! -- if there is no other task, no need to check priorities ! if All_Tasks_Link /= Null_Task and then ! L.Ceiling < Interfaces.C.int (Current_Prio) then Ceiling_Violation := True; return; end if; end if; Result := pthread_mutex_lock (L.L'Access); - pragma Assert (Result = 0); Ceiling_Violation := False; end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; begin ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; begin ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Write_Lock; --------------- --- 317,356 ---- All_Tasks_Link := Self_ID.Common.All_Tasks_Link; Current_Prio := Get_Priority (Self_ID); ! -- If there is no other task, no need to check priorities ! ! if All_Tasks_Link /= Null_Task ! and then L.Ceiling < Interfaces.C.int (Current_Prio) ! then Ceiling_Violation := True; return; end if; end if; Result := pthread_mutex_lock (L.L'Access); pragma Assert (Result = 0); Ceiling_Violation := False; end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 366,383 **** pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock) is Result : Interfaces.C.int; begin ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; begin ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Unlock; ----------- --- 373,394 ---- pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); ! end if; end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Unlock; ----------- *************** package body System.Task_Primitives.Oper *** 390,398 **** is Result : Interfaces.C.int; begin ! pragma Assert (Self_ID = Self); ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); -- EINTR is not considered a failure. --- 401,413 ---- is Result : Interfaces.C.int; begin ! if Single_Lock then ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! else ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; -- EINTR is not considered a failure. *************** package body System.Task_Primitives.Oper *** 437,444 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 452,467 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! if Single_Lock then ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access, ! Request'Access); ! ! else ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, ! Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 477,482 **** --- 500,510 ---- -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); if Mode = Relative then *************** package body System.Task_Primitives.Oper *** 498,505 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 526,538 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! if Single_Lock then ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Single_RTS_Lock'Access, Request'Access); ! else ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 512,517 **** --- 545,555 ---- end if; Unlock (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + Yield; SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 612,618 **** Self_ID.Common.LL.Thread := pthread_self; Specific.Set (Self_ID); ! Lock_All_Tasks_List; for J in Known_Tasks'Range loop if Known_Tasks (J) = null then --- 650,656 ---- Self_ID.Common.LL.Thread := pthread_self; Specific.Set (Self_ID); ! Lock_RTS; for J in Known_Tasks'Range loop if Known_Tasks (J) = null then *************** package body System.Task_Primitives.Oper *** 622,628 **** end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 660,666 ---- end if; end loop; ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 644,688 **** Cond_Attr : aliased pthread_condattr_t; begin ! Result := pthread_mutexattr_init (Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Succeeded := False; ! return; end if; - Result := pthread_mutexattr_destroy (Mutex_Attr'Access); - pragma Assert (Result = 0); - Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! Succeeded := False; ! return; end if; - Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, - Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - if Result = 0 then Succeeded := True; else ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); Succeeded := False; end if; --- 682,723 ---- Cond_Attr : aliased pthread_condattr_t; begin ! if not Single_Lock then ! Result := pthread_mutexattr_init (Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! end if; ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! Result := pthread_mutexattr_destroy (Mutex_Attr'Access); ! pragma Assert (Result = 0); end if; Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, ! Cond_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); end if; if Result = 0 then Succeeded := True; else ! if not Single_Lock then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Succeeded := False; end if; *************** package body System.Task_Primitives.Oper *** 829,841 **** Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; Free (Tmp); end Finalize_TCB; --- 864,881 ---- Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! if not Single_Lock then ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); + if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; + Free (Tmp); end Finalize_TCB; *************** package body System.Task_Primitives.Oper *** 891,913 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 931,953 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 944,950 **** begin Environment_Task_ID := Environment_Task; ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); -- Initialize the lock used to synchronize chain of all ATCBs. Specific.Initialize (Environment_Task); --- 984,990 ---- begin Environment_Task_ID := Environment_Task; ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); -- Initialize the lock used to synchronize chain of all ATCBs. Specific.Initialize (Environment_Task); *************** package body System.Task_Primitives.Oper *** 971,977 **** begin declare Result : Interfaces.C.int; - begin -- Mask Environment task for all signals. The original mask of the -- Environment task will be recovered by Interrupt_Server task --- 1011,1016 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5atasinf.ads gcc-3.3/gcc/ada/5atasinf.ads *** gcc-3.2.3/gcc/ada/5atasinf.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/5atasinf.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (Compiler Interface) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2000 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5ataspri.ads gcc-3.3/gcc/ada/5ataspri.ads *** gcc-3.2.3/gcc/ada/5ataspri.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/5ataspri.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5atpopsp.adb gcc-3.3/gcc/ada/5atpopsp.adb *** gcc-3.2.3/gcc/ada/5atpopsp.adb 2001-12-16 01:13:27.000000000 +0000 --- gcc-3.3/gcc/ada/5atpopsp.adb 2002-10-23 08:27:54.000000000 +0000 *************** *** 7,15 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 7,14 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,44 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- This is a POSIX version of this package where foreign threads are -- recognized. ! -- Currently, DEC Unix, SCO UnixWare, Solaris pthread, HPUX pthread and RTEMS ! -- use this version. with System.Soft_Links; -- used to initialize TSD for a C thread, in function Self --- 28,45 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a POSIX version of this package where foreign threads are -- recognized. ! -- Currently, DEC Unix, SCO UnixWare, Solaris pthread, HPUX pthread, ! -- GNU/Linux threads and RTEMS use this version. ! ! with System.Task_Info; ! -- Use for Unspecified_Task_Info with System.Soft_Links; -- used to initialize TSD for a C thread, in function Self *************** package body Specific is *** 71,77 **** Fake_ATCB_List : Fake_ATCB_Ptr; -- A linear linked list. ! -- The list is protected by All_Tasks_L; -- Nodes are added to this list from the front. -- Once a node is added to this list, it is never removed. --- 72,78 ---- Fake_ATCB_List : Fake_ATCB_Ptr; -- A linear linked list. ! -- The list is protected by Single_RTS_Lock; -- Nodes are added to this list from the front. -- Once a node is added to this list, it is never removed. *************** package body Specific is *** 109,115 **** -- We dare not call anything that might require an ATCB, until -- we have the new ATCB in place. ! Write_Lock (All_Tasks_L'Access); Q := null; P := Fake_ATCB_List; --- 110,116 ---- -- We dare not call anything that might require an ATCB, until -- we have the new ATCB in place. ! Lock_RTS; Q := null; P := Fake_ATCB_List; *************** package body Specific is *** 195,201 **** -- Must not unlock until Next_ATCB is again allocated. ! Unlock (All_Tasks_L'Access); return Self_ID; end New_Fake_ATCB; --- 196,202 ---- -- Must not unlock until Next_ATCB is again allocated. ! Unlock_RTS; return Self_ID; end New_Fake_ATCB; *************** package body Specific is *** 205,211 **** procedure Initialize (Environment_Task : Task_ID) is Result : Interfaces.C.int; - begin Result := pthread_key_create (ATCB_Key'Access, null); pragma Assert (Result = 0); --- 206,211 ---- *************** package body Specific is *** 223,229 **** procedure Set (Self_Id : Task_ID) is Result : Interfaces.C.int; - begin Result := pthread_setspecific (ATCB_Key, To_Address (Self_Id)); pragma Assert (Result = 0); --- 223,228 ---- *************** package body Specific is *** 233,269 **** -- Self -- ---------- ! -- To make Ada tasks and C threads interoperate better, we have ! -- added some functionality to Self. Suppose a C main program ! -- (with threads) calls an Ada procedure and the Ada procedure ! -- calls the tasking runtime system. Eventually, a call will be ! -- made to self. Since the call is not coming from an Ada task, ! -- there will be no corresponding ATCB. ! ! -- (The entire Ada run-time system may not have been elaborated, ! -- either, but that is a different problem, that we will need to ! -- solve another way.) ! ! -- What we do in Self is to catch references that do not come ! -- from recognized Ada tasks, and create an ATCB for the calling ! -- thread. ! ! -- The new ATCB will be "detached" from the normal Ada task ! -- master hierarchy, much like the existing implicitly created ! -- signal-server tasks. ! -- We will also use such points to poll for disappearance of the ! -- threads associated with any implicit ATCBs that we created ! -- earlier, and take the opportunity to recover them. ! -- A nasty problem here is the limitations of the compilation ! -- order dependency, and in particular the GNARL/GNULLI layering. ! -- To initialize an ATCB we need to assume System.Tasking has ! -- been elaborated. function Self return Task_ID is Result : System.Address; - begin Result := pthread_getspecific (ATCB_Key); --- 232,252 ---- -- Self -- ---------- ! -- To make Ada tasks and C threads interoperate better, we have added some ! -- functionality to Self. Suppose a C main program (with threads) calls an ! -- Ada procedure and the Ada procedure calls the tasking runtime system. ! -- Eventually, a call will be made to self. Since the call is not coming ! -- from an Ada task, there will be no corresponding ATCB. ! -- What we do in Self is to catch references that do not come from ! -- recognized Ada tasks, and create an ATCB for the calling thread. ! -- The new ATCB will be "detached" from the normal Ada task master ! -- hierarchy, much like the existing implicitly created signal-server ! -- tasks. function Self return Task_ID is Result : System.Address; begin Result := pthread_getspecific (ATCB_Key); diff -Nrc3pad gcc-3.2.3/gcc/ada/5avxwork.ads gcc-3.3/gcc/ada/5avxwork.ads *** gcc-3.2.3/gcc/ada/5avxwork.ads 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/5avxwork.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** package System.VxWorks is *** 42,109 **** package IC renames Interfaces.C; ! -- Define enough of a Wind Task Control Block in order to ! -- obtain the inherited priority. When porting this to ! -- different versions of VxWorks (this is based on 5.3[.1]), ! -- be sure to look at the definition for WIND_TCB located ! -- in $WIND_BASE/target/h/taskLib.h ! ! type Wind_Fill_1 is array (0 .. 16#77#) of IC.unsigned_char; ! type Wind_Fill_2 is array (16#80# .. 16#1c7#) of IC.unsigned_char; ! type Wind_Fill_3 is array (16#1d8# .. 16#777#) of IC.unsigned_char; ! ! type Wind_TCB is record ! Fill_1 : Wind_Fill_1; -- 0x00 - 0x77 ! Priority : IC.int; -- 0x78 - 0x7b, current (inherited) priority ! Normal_Priority : IC.int; -- 0x7c - 0x7f, base priority ! Fill_2 : Wind_Fill_2; -- 0x80 - 0x1c7 ! spare1 : Address; -- 0x1c8 - 0x1cb ! spare2 : Address; -- 0x1cc - 0x1cf ! spare3 : Address; -- 0x1d0 - 0x1d3 ! spare4 : Address; -- 0x1d4 - 0x1d7 ! ! -- Fill_3 is much smaller on the board runtime, but the larger size ! -- below keeps this record compatible with vxsim. ! ! Fill_3 : Wind_Fill_3; -- 0x1d8 - 0x777 ! end record; ! type Wind_TCB_Ptr is access Wind_TCB; ! ! ! -- Floating point context record. Alpha version FP_NUM_DREGS : constant := 32; type Fpx_Array is array (1 .. FP_NUM_DREGS) of IC.double; type FP_CONTEXT is record ! fpx : Fpx_Array; fpcsr : IC.long; end record; pragma Convention (C, FP_CONTEXT); ! -- Number of entries in hardware interrupt vector table. Value of ! -- 0 disables hardware interrupt handling until it can be tested ! Num_HW_Interrupts : constant := 0; ! ! -- VxWorks 5.3 and 5.4 version ! type TASK_DESC is record ! td_id : IC.int; -- task id ! td_name : Address; -- name of task ! td_priority : IC.int; -- task priority ! td_status : IC.int; -- task status ! td_options : IC.int; -- task option bits (see below) ! td_entry : Address; -- original entry point of task ! td_sp : Address; -- saved stack pointer ! td_pStackBase : Address; -- the bottom of the stack ! td_pStackLimit : Address; -- the effective end of the stack ! td_pStackEnd : Address; -- the actual end of the stack ! td_stackSize : IC.int; -- size of stack in bytes ! td_stackCurrent : IC.int; -- current stack usage in bytes ! td_stackHigh : IC.int; -- maximum stack usage in bytes ! td_stackMargin : IC.int; -- current stack margin in bytes ! td_errorStatus : IC.int; -- most recent task error status ! td_delay : IC.int; -- delay/timeout ticks ! end record; ! pragma Convention (C, TASK_DESC); end System.VxWorks; --- 41,58 ---- package IC renames Interfaces.C; ! -- Floating point context record. Alpha version FP_NUM_DREGS : constant := 32; type Fpx_Array is array (1 .. FP_NUM_DREGS) of IC.double; type FP_CONTEXT is record ! fpx : Fpx_Array; fpcsr : IC.long; end record; pragma Convention (C, FP_CONTEXT); ! Num_HW_Interrupts : constant := 256; ! -- Number of entries in hardware interrupt vector table. end System.VxWorks; diff -Nrc3pad gcc-3.2.3/gcc/ada/5bosinte.adb gcc-3.3/gcc/ada/5bosinte.adb *** gcc-3.2.3/gcc/ada/5bosinte.adb 2001-10-02 13:42:25.000000000 +0000 --- gcc-3.3/gcc/ada/5bosinte.adb 2002-10-23 08:27:54.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1997-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2001, Free Software Fundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ *************** package body System.OS_Interface is *** 140,146 **** function sched_yield return int is procedure pthread_yield; ! pragma Import (C, pthread_yield, "pthread_yield"); begin pthread_yield; --- 138,144 ---- function sched_yield return int is procedure pthread_yield; ! pragma Import (C, pthread_yield, "sched_yield"); begin pthread_yield; diff -Nrc3pad gcc-3.2.3/gcc/ada/5bosinte.ads gcc-3.3/gcc/ada/5bosinte.ads *** gcc-3.2.3/gcc/ada/5bosinte.ads 2002-05-04 03:27:13.000000000 +0000 --- gcc-3.3/gcc/ada/5bosinte.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5bsystem.ads gcc-3.3/gcc/ada/5bsystem.ads *** gcc-3.2.3/gcc/ada/5bsystem.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5bsystem.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 5,15 **** -- S Y S T E M -- -- -- -- S p e c -- ! -- (AIX/PPC Version) -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 5,14 ---- -- S Y S T E M -- -- -- -- S p e c -- ! -- (AIX/PPC Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 88,119 **** -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := ! Bit_Order'Val (Standard'Default_Bit_Order); -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 87,104 ---- -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := High_Order_First; -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 131,138 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; diff -Nrc3pad gcc-3.2.3/gcc/ada/5cosinte.ads gcc-3.3/gcc/ada/5cosinte.ads *** gcc-3.2.3/gcc/ada/5cosinte.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5cosinte.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5dosinte.ads gcc-3.3/gcc/ada/5dosinte.ads *** gcc-3.2.3/gcc/ada/5dosinte.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5dosinte.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5esystem.ads gcc-3.3/gcc/ada/5esystem.ads *** gcc-3.2.3/gcc/ada/5esystem.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5esystem.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (X86 Solaris Version) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (X86 Solaris Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 92,118 **** -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 91,104 ---- -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 130,137 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; *************** private *** 145,150 **** Use_Ada_Main_Program_Name : constant Boolean := False; ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; ! Front_End_ZCX_Support : constant Boolean := False; end System; --- 134,139 ---- Use_Ada_Main_Program_Name : constant Boolean := False; ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; ! Front_End_ZCX_Support : constant Boolean := True; end System; diff -Nrc3pad gcc-3.2.3/gcc/ada/5etpopse.adb gcc-3.3/gcc/ada/5etpopse.adb *** gcc-3.2.3/gcc/ada/5etpopse.adb 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/5etpopse.adb 2002-03-14 10:58:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-1998, Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5fintman.adb gcc-3.3/gcc/ada/5fintman.adb *** gcc-3.2.3/gcc/ada/5fintman.adb 2001-10-02 13:42:25.000000000 +0000 --- gcc-3.3/gcc/ada/5fintman.adb 2002-03-14 10:58:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2001, Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5fosinte.ads gcc-3.3/gcc/ada/5fosinte.ads *** gcc-3.2.3/gcc/ada/5fosinte.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5fosinte.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5fsystem.ads gcc-3.3/gcc/ada/5fsystem.ads *** gcc-3.2.3/gcc/ada/5fsystem.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5fsystem.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (SGI Irix, o32 ABI) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (SGI Irix, o32 ABI) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 92,118 **** -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 91,104 ---- -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 130,137 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := False; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := True; Long_Shifts_Inlined : constant Boolean := True; diff -Nrc3pad gcc-3.2.3/gcc/ada/5ftaprop.adb gcc-3.3/gcc/ada/5ftaprop.adb *** gcc-3.2.3/gcc/ada/5ftaprop.adb 2001-12-16 01:13:27.000000000 +0000 --- gcc-3.3/gcc/ada/5ftaprop.adb 2002-10-23 08:27:54.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ *************** package body System.Task_Primitives.Oper *** 117,124 **** ATCB_Key : aliased pthread_key_t; -- Key used to find the Ada Task_ID associated with a thread ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Locking_Rules (spec). Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. --- 115,124 ---- ATCB_Key : aliased pthread_key_t; -- Key used to find the Ada Task_ID associated with a thread ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. *************** package body System.Task_Primitives.Oper *** 206,212 **** -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as All_Tasks_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. --- 206,212 ---- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. *************** package body System.Task_Primitives.Oper *** 308,314 **** procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is Result : Interfaces.C.int; - begin Result := pthread_mutex_lock (L); Ceiling_Violation := Result = EINVAL; --- 308,313 ---- *************** package body System.Task_Primitives.Oper *** 318,337 **** pragma Assert (Result = 0 or else Result = EINVAL); end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Write_Lock; --------------- --- 317,340 ---- pragma Assert (Result = 0 or else Result = EINVAL); end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 349,374 **** procedure Unlock (L : access Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_unlock (L); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Unlock; ----------- --- 352,378 ---- procedure Unlock (L : access Lock) is Result : Interfaces.C.int; begin Result := pthread_mutex_unlock (L); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); ! end if; end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Unlock; ----------- *************** package body System.Task_Primitives.Oper *** 381,389 **** is Result : Interfaces.C.int; begin ! pragma Assert (Self_ID = Self); ! Result := pthread_cond_wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access); -- EINTR is not considered a failure. --- 385,397 ---- is Result : Interfaces.C.int; begin ! if Single_Lock then ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! else ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; -- EINTR is not considered a failure. *************** package body System.Task_Primitives.Oper *** 424,431 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 432,447 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! if Single_Lock then ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access, ! Request'Access); ! ! else ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, ! Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 461,466 **** --- 477,487 ---- -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); if Mode = Relative then *************** package body System.Task_Primitives.Oper *** 495,500 **** --- 516,526 ---- end if; Unlock (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + Yield; SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 621,627 **** pragma Assert (Result = 0); end if; ! Lock_All_Tasks_List; for J in Known_Tasks'Range loop if Known_Tasks (J) = null then --- 647,653 ---- pragma Assert (Result = 0); end if; ! Lock_RTS; for J in Known_Tasks'Range loop if Known_Tasks (J) = null then *************** package body System.Task_Primitives.Oper *** 631,637 **** end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 657,663 ---- end if; end loop; ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 652,679 **** Cond_Attr : aliased pthread_condattr_t; begin ! Initialize_Lock (Self_ID.Common.LL.L'Access, All_Tasks_Level); Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! ! Succeeded := False; ! return; end if; - Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, - Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - if Result = 0 then Succeeded := True; else ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); Succeeded := False; end if; --- 678,704 ---- Cond_Attr : aliased pthread_condattr_t; begin ! if not Single_Lock then ! Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level); ! end if; Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, ! Cond_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); end if; if Result = 0 then Succeeded := True; else ! if not Single_Lock then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Succeeded := False; end if; *************** package body System.Task_Primitives.Oper *** 821,828 **** Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); --- 846,855 ---- Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! if not Single_Lock then ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); *************** package body System.Task_Primitives.Oper *** 885,907 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 912,934 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 939,945 **** Environment_Task_ID := Environment_Task; -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); Enter_Task (Environment_Task); --- 966,972 ---- Environment_Task_ID := Environment_Task; -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Enter_Task (Environment_Task); diff -Nrc3pad gcc-3.2.3/gcc/ada/5ftasinf.ads gcc-3.3/gcc/ada/5ftasinf.ads *** gcc-3.2.3/gcc/ada/5ftasinf.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5ftasinf.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (Compiler Interface) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5ginterr.adb gcc-3.3/gcc/ada/5ginterr.adb *** gcc-3.2.3/gcc/ada/5ginterr.adb 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5ginterr.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1998-1999 Free Software Fundation -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Fundation -- -- -- -- GNARL 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- -- *************** with System.Tasking.Initialization; *** 67,72 **** --- 66,74 ---- with System.Interrupt_Management; + with System.Parameters; + -- used for Single_Lock + with Interfaces.C; -- used for int *************** with Unchecked_Conversion; *** 74,79 **** --- 76,82 ---- package body System.Interrupts is + use Parameters; use Tasking; use Ada.Exceptions; use System.OS_Interface; *************** package body System.Interrupts is *** 649,659 **** --- 652,672 ---- end loop; Initialization.Defer_Abort (Self_Id); + + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Self_Id); Self_Id.Common.State := Interrupt_Server_Idle_Sleep; STPO.Sleep (Self_Id, Interrupt_Server_Idle_Sleep); Self_Id.Common.State := Runnable; STPO.Unlock (Self_Id); + + if Single_Lock then + STPO.Unlock_RTS; + end if; + Initialization.Undefer_Abort (Self_Id); -- Undefer abort here to allow a window for this task diff -Nrc3pad gcc-3.2.3/gcc/ada/5gintman.adb gcc-3.3/gcc/ada/5gintman.adb *** gcc-3.2.3/gcc/ada/5gintman.adb 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/5gintman.adb 2002-03-14 10:58:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1998, Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5gmastop.adb gcc-3.3/gcc/ada/5gmastop.adb *** gcc-3.2.3/gcc/ada/5gmastop.adb 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5gmastop.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,13 **** -- B o d y -- -- (Version for IRIX/MIPS) -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- *************** package body System.Machine_State_Operat *** 66,92 **** type Reg_Array is array (0 .. 31) of Uns64; ! type Sigcontext is ! record ! SC_Regmask : Uns32; -- 0 ! SC_Status : Uns32; -- 4 ! SC_PC : Uns64; -- 8 ! SC_Regs : Reg_Array; -- 16 ! SC_Fpregs : Reg_Array; -- 272 ! SC_Ownedfp : Uns32; -- 528 ! SC_Fpc_Csr : Uns32; -- 532 ! SC_Fpc_Eir : Uns32; -- 536 ! SC_Ssflags : Uns32; -- 540 ! SC_Mdhi : Uns64; -- 544 ! SC_Mdlo : Uns64; -- 552 ! SC_Cause : Uns64; -- 560 ! SC_Badvaddr : Uns64; -- 568 ! SC_Triggersave : Uns64; -- 576 ! SC_Sigset : Uns64; -- 584 ! SC_Fp_Rounded_Result : Uns64; -- 592 ! SC_Pancake : Uns64_Array (0 .. 5); ! SC_Pad : Uns64_Array (0 .. 26); ! end record; type Sigcontext_Ptr is access all Sigcontext; --- 65,90 ---- type Reg_Array is array (0 .. 31) of Uns64; ! type Sigcontext is record ! SC_Regmask : Uns32; -- 0 ! SC_Status : Uns32; -- 4 ! SC_PC : Uns64; -- 8 ! SC_Regs : Reg_Array; -- 16 ! SC_Fpregs : Reg_Array; -- 272 ! SC_Ownedfp : Uns32; -- 528 ! SC_Fpc_Csr : Uns32; -- 532 ! SC_Fpc_Eir : Uns32; -- 536 ! SC_Ssflags : Uns32; -- 540 ! SC_Mdhi : Uns64; -- 544 ! SC_Mdlo : Uns64; -- 552 ! SC_Cause : Uns64; -- 560 ! SC_Badvaddr : Uns64; -- 568 ! SC_Triggersave : Uns64; -- 576 ! SC_Sigset : Uns64; -- 584 ! SC_Fp_Rounded_Result : Uns64; -- 592 ! SC_Pancake : Uns64_Array (0 .. 5); ! SC_Pad : Uns64_Array (0 .. 26); ! end record; type Sigcontext_Ptr is access all Sigcontext; *************** package body System.Machine_State_Operat *** 253,263 **** ------------------------ procedure Free_Machine_State (M : in out Machine_State) is - procedure Gnat_Free (M : in Machine_State); - pragma Import (C, Gnat_Free, "__gnat_free"); - begin ! Gnat_Free (M); M := Machine_State (Null_Address); end Free_Machine_State; --- 251,258 ---- ------------------------ procedure Free_Machine_State (M : in out Machine_State) is begin ! Memory.Free (Address (M)); M := Machine_State (Null_Address); end Free_Machine_State; diff -Nrc3pad gcc-3.2.3/gcc/ada/5gosinte.ads gcc-3.3/gcc/ada/5gosinte.ads *** gcc-3.2.3/gcc/ada/5gosinte.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5gosinte.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5gproinf.adb gcc-3.3/gcc/ada/5gproinf.adb *** gcc-3.2.3/gcc/ada/5gproinf.adb 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5gproinf.adb 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5gproinf.ads gcc-3.3/gcc/ada/5gproinf.ads *** gcc-3.2.3/gcc/ada/5gproinf.ads 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/5gproinf.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5gsystem.ads gcc-3.3/gcc/ada/5gsystem.ads *** gcc-3.2.3/gcc/ada/5gsystem.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5gsystem.ads 2002-10-23 07:33:19.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (SGI Irix, n32 ABI) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (SGI Irix, n32 ABI) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 64; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 92,118 **** -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 91,104 ---- -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 130,137 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := False; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := True; Long_Shifts_Inlined : constant Boolean := True; diff -Nrc3pad gcc-3.2.3/gcc/ada/5gtaprop.adb gcc-3.3/gcc/ada/5gtaprop.adb *** gcc-3.2.3/gcc/ada/5gtaprop.adb 2001-12-16 01:13:27.000000000 +0000 --- gcc-3.3/gcc/ada/5gtaprop.adb 2002-10-23 08:27:54.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ *************** package body System.Task_Primitives.Oper *** 106,120 **** -- The followings are logically constants, but need to be initialized -- at run time. ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. Locking_Policy : Character; ! pragma Import (C, Locking_Policy, "__gl_locking_policy", ! "__gl_locking_policy"); Clock_Address : constant System.Address := System.Storage_Elements.To_Address (16#200F90#); --- 104,119 ---- -- The followings are logically constants, but need to be initialized -- at run time. ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. Locking_Policy : Character; ! pragma Import (C, Locking_Policy, "__gl_locking_policy"); Clock_Address : constant System.Address := System.Storage_Elements.To_Address (16#200F90#); *************** package body System.Task_Primitives.Oper *** 169,175 **** -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as All_Tasks_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. --- 168,174 ---- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. *************** package body System.Task_Primitives.Oper *** 267,273 **** procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is Result : Interfaces.C.int; - begin Result := pthread_mutex_lock (L); --- 266,271 ---- *************** package body System.Task_Primitives.Oper *** 275,294 **** pragma Assert (Result /= FUNC_ERR); end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Write_Lock; --------------- --- 273,296 ---- pragma Assert (Result /= FUNC_ERR); end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 306,437 **** procedure Unlock (L : access Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_unlock (L); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Unlock; ! ------------- ! -- Sleep -- ! ------------- procedure Sleep (Self_ID : ST.Task_ID; ! Reason : System.Tasking.Task_States) is ! Result : Interfaces.C.int; - begin ! pragma Assert (Self_ID = Self); ! Result := pthread_cond_wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access); -- EINTR is not considered a failure. pragma Assert (Result = 0 or else Result = EINTR); end Sleep; - -- Note that we are relying heaviliy here on the GNAT feature - -- that Calendar.Time, System.Real_Time.Time, Duration, and - -- System.Real_Time.Time_Span are all represented in the same - -- way, i.e., as a 64-bit count of nanoseconds. - -- This allows us to always pass the timeout value as a Duration. - - -- ????? ......... - -- We are taking liberties here with the semantics of the delays. - -- That is, we make no distinction between delays on the Calendar clock - -- and delays on the Real_Time clock. That is technically incorrect, if - -- the Calendar clock happens to be reset or adjusted. - -- To solve this defect will require modification to the compiler - -- interface, so that it can pass through more information, to tell - -- us here which clock to use! - - -- cond_timedwait will return if any of the following happens: - -- 1) some other task did cond_signal on this condition variable - -- In this case, the return value is 0 - -- 2) the call just returned, for no good reason - -- This is called a "spurious wakeup". - -- In this case, the return value may also be 0. - -- 3) the time delay expires - -- In this case, the return value is ETIME - -- 4) this task received a signal, which was handled by some - -- handler procedure, and now the thread is resuming execution - -- UNIX calls this an "interrupted" system call. - -- In this case, the return value is EINTR - - -- If the cond_timedwait returns 0 or EINTR, it is still - -- possible that the time has actually expired, and by chance - -- a signal or cond_signal occurred at around the same time. - - -- We have also observed that on some OS's the value ETIME - -- will be returned, but the clock will show that the full delay - -- has not yet expired. - - -- For these reasons, we need to check the clock after return - -- from cond_timedwait. If the time has expired, we will set - -- Timedout = True. - - -- This check might be omitted for systems on which the - -- cond_timedwait() never returns early or wakes up spuriously. - - -- Annex D requires that completion of a delay cause the task - -- to go to the end of its priority queue, regardless of whether - -- the task actually was suspended by the delay. Since - -- cond_timedwait does not do this on Solaris, we add a call - -- to thr_yield at the end. We might do this at the beginning, - -- instead, but then the round-robin effect would not be the - -- same; the delayed task would be ahead of other tasks of the - -- same priority that awoke while it was sleeping. - - -- For Timed_Sleep, we are expecting possible cond_signals - -- to indicate other events (e.g., completion of a RV or - -- completion of the abortable part of an async. select), - -- we want to always return if interrupted. The caller will - -- be responsible for checking the task state to see whether - -- the wakeup was spurious, and to go back to sleep again - -- in that case. We don't need to check for pending abort - -- or priority change on the way in our out; that is the - -- caller's responsibility. - - -- For Timed_Delay, we are not expecting any cond_signals or - -- other interruptions, except for priority changes and aborts. - -- Therefore, we don't want to return unless the delay has - -- actually expired, or the call has been aborted. In this - -- case, since we want to implement the entire delay statement - -- semantics, we do need to check for pending abort and priority - -- changes. We can quietly handle priority changes inside the - -- procedure, since there is no entry-queue reordering involved. - ----------------- -- Timed_Sleep -- ----------------- - -- This is for use within the run-time system, so abort is - -- assumed to be already deferred, and the caller should be - -- holding its own ATCB lock. - -- Yielded should be False unles we know for certain that the - -- operation resulted in the calling task going to the end of - -- the dispatching queue for its priority. - -- ????? - -- This version presumes the worst, so Yielded is always False. - -- On some targets, if cond_timedwait always yields, we could - -- set Yielded to True just before the cond_timedwait call. - procedure Timed_Sleep (Self_ID : Task_ID; Time : Duration; --- 308,362 ---- procedure Unlock (L : access Lock) is Result : Interfaces.C.int; begin Result := pthread_mutex_unlock (L); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); ! end if; end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Unlock; ! ----------- ! -- Sleep -- ! ----------- procedure Sleep (Self_ID : ST.Task_ID; ! Reason : System.Tasking.Task_States) ! is Result : Interfaces.C.int; begin ! if Single_Lock then ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! else ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; ! -- EINTR is not considered a failure. pragma Assert (Result = 0 or else Result = EINTR); end Sleep; ----------------- -- Timed_Sleep -- ----------------- procedure Timed_Sleep (Self_ID : Task_ID; Time : Duration; *************** package body System.Task_Primitives.Oper *** 461,468 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 386,401 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! if Single_Lock then ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access, ! Request'Access); ! ! else ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, ! Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 482,491 **** -- Timed_Delay -- ----------------- - -- This is for use in implementing delay statements, so - -- we assume the caller is abort-deferred but is holding - -- no locks. - procedure Timed_Delay (Self_ID : Task_ID; Time : Duration; --- 415,420 ---- *************** package body System.Task_Primitives.Oper *** 495,507 **** Abs_Time : Duration; Request : aliased struct_timeval; Result : Interfaces.C.int; - begin -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; Write_Lock (Self_ID); if Mode = Relative then --- 424,441 ---- Abs_Time : Duration; Request : aliased struct_timeval; Result : Interfaces.C.int; + begin -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); if Mode = Relative then *************** package body System.Task_Primitives.Oper *** 523,530 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 457,469 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! if Single_Lock then ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Single_RTS_Lock'Access, Request'Access); ! else ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 538,543 **** --- 477,487 ---- end if; Unlock (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + pthread_yield; SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 578,587 **** procedure Wakeup (T : ST.Task_ID; ! Reason : System.Tasking.Task_States) is ! Result : Interfaces.C.int; - begin Result := pthread_cond_signal (T.Common.LL.CV'Access); pragma Assert (Result = 0); --- 522,530 ---- procedure Wakeup (T : ST.Task_ID; ! Reason : System.Tasking.Task_States) ! is Result : Interfaces.C.int; begin Result := pthread_cond_signal (T.Common.LL.CV'Access); pragma Assert (Result = 0); *************** package body System.Task_Primitives.Oper *** 608,614 **** Loss_Of_Inheritance : Boolean := False) is Result : Interfaces.C.int; - begin T.Common.Current_Priority := Prio; Result := pthread_setprio (T.Common.LL.Thread, Interfaces.C.int (Prio)); --- 551,556 ---- *************** package body System.Task_Primitives.Oper *** 631,639 **** procedure Enter_Task (Self_ID : Task_ID) is Result : Interfaces.C.int; - begin - Self_ID.Common.LL.Thread := pthread_self; Self_ID.Common.LL.LWP := sproc_self; --- 573,579 ---- *************** package body System.Task_Primitives.Oper *** 642,658 **** pragma Assert (Result = 0); ! Lock_All_Tasks_List; ! for I in Known_Tasks'Range loop ! if Known_Tasks (I) = null then ! Known_Tasks (I) := Self_ID; ! Self_ID.Known_Tasks_Index := I; exit; end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 582,598 ---- pragma Assert (Result = 0); ! Lock_RTS; ! for J in Known_Tasks'Range loop ! if Known_Tasks (J) = null then ! Known_Tasks (J) := Self_ID; ! Self_ID.Known_Tasks_Index := J; exit; end if; end loop; ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 669,699 **** ---------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is ! Result : Interfaces.C.int; Cond_Attr : aliased pthread_condattr_t; begin ! Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level); Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! Succeeded := False; ! return; end if; - Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, - Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - if Result = 0 then Succeeded := True; else ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); Succeeded := False; end if; --- 609,639 ---- ---------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is ! Result : Interfaces.C.int; Cond_Attr : aliased pthread_condattr_t; begin ! if not Single_Lock then ! Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level); ! end if; Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, ! Cond_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); end if; if Result = 0 then Succeeded := True; else ! if not Single_Lock then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Succeeded := False; end if; *************** package body System.Task_Primitives.Oper *** 723,728 **** --- 663,669 ---- (System.Task_Info.Resource_Vector_T, System.OS_Interface.resource_t); use System.Task_Info; + begin if Stack_Size = Unspecified_Size then Adjusted_Stack_Size := *************** package body System.Task_Primitives.Oper *** 809,816 **** Tmp : Task_ID := T; begin ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); --- 750,760 ---- Tmp : Task_ID := T; begin ! if not Single_Lock then ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); *************** package body System.Task_Primitives.Oper *** 836,842 **** procedure Abort_Task (T : Task_ID) is Result : Interfaces.C.int; - begin Result := pthread_kill (T.Common.LL.Thread, Interfaces.C.int (System.Interrupt_Management.Abort_Task_Interrupt)); --- 780,785 ---- *************** package body System.Task_Primitives.Oper *** 873,895 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 816,838 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 929,935 **** begin Environment_Task_ID := Environment_Task; ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); -- Initialize the lock used to synchronize chain of all ATCBs. Enter_Task (Environment_Task); --- 872,878 ---- begin Environment_Task_ID := Environment_Task; ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); -- Initialize the lock used to synchronize chain of all ATCBs. Enter_Task (Environment_Task); diff -Nrc3pad gcc-3.2.3/gcc/ada/5gtasinf.adb gcc-3.3/gcc/ada/5gtasinf.adb *** gcc-3.2.3/gcc/ada/5gtasinf.adb 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/5gtasinf.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1998 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** with Interfaces.C; *** 42,47 **** --- 41,47 ---- with System.OS_Interface; with System; with Unchecked_Conversion; + package body System.Task_Info is use System.OS_Interface; *************** package body System.Task_Info is *** 67,118 **** TXTLOCK => 2, DATLOCK => 4); package body Resource_Vector_Functions is ! function "+" (R : Resource_T) ! return Resource_Vector_T is Result : Resource_Vector_T := NO_RESOURCES; begin Result (Resource_T'Pos (R)) := True; return Result; end "+"; ! function "+" (R1, R2 : Resource_T) ! return Resource_Vector_T is Result : Resource_Vector_T := NO_RESOURCES; begin Result (Resource_T'Pos (R1)) := True; Result (Resource_T'Pos (R2)) := True; return Result; end "+"; ! function "+" (R : Resource_T; S : Resource_Vector_T) ! return Resource_Vector_T is Result : Resource_Vector_T := S; begin Result (Resource_T'Pos (R)) := True; return Result; end "+"; ! function "+" (S : Resource_Vector_T; R : Resource_T) ! return Resource_Vector_T is Result : Resource_Vector_T := S; begin Result (Resource_T'Pos (R)) := True; return Result; end "+"; ! function "+" (S1, S2 : Resource_Vector_T) ! return Resource_Vector_T is Result : Resource_Vector_T; begin Result := S1 or S2; return Result; end "+"; ! function "-" (S : Resource_Vector_T; R : Resource_T) ! return Resource_Vector_T is Result : Resource_Vector_T := S; begin Result (Resource_T'Pos (R)) := False; return Result; --- 67,138 ---- TXTLOCK => 2, DATLOCK => 4); + ------------------------------- + -- Resource_Vector_Functions -- + ------------------------------- + package body Resource_Vector_Functions is ! --------- ! -- "+" -- ! --------- ! ! function "+" (R : Resource_T) return Resource_Vector_T is Result : Resource_Vector_T := NO_RESOURCES; + begin Result (Resource_T'Pos (R)) := True; return Result; end "+"; ! function "+" (R1, R2 : Resource_T) return Resource_Vector_T is Result : Resource_Vector_T := NO_RESOURCES; + begin Result (Resource_T'Pos (R1)) := True; Result (Resource_T'Pos (R2)) := True; return Result; end "+"; ! function "+" ! (R : Resource_T; ! S : Resource_Vector_T) ! return Resource_Vector_T ! is Result : Resource_Vector_T := S; + begin Result (Resource_T'Pos (R)) := True; return Result; end "+"; ! function "+" ! (S : Resource_Vector_T; ! R : Resource_T) ! return Resource_Vector_T ! is Result : Resource_Vector_T := S; + begin Result (Resource_T'Pos (R)) := True; return Result; end "+"; ! function "+" (S1, S2 : Resource_Vector_T) return Resource_Vector_T is Result : Resource_Vector_T; + begin Result := S1 or S2; return Result; end "+"; ! function "-" ! (S : Resource_Vector_T; ! R : Resource_T) ! return Resource_Vector_T ! is Result : Resource_Vector_T := S; + begin Result (Resource_T'Pos (R)) := False; return Result; *************** package body System.Task_Info is *** 120,133 **** end Resource_Vector_Functions; function New_Sproc (Attr : Sproc_Attributes) return sproc_t is Sproc_Attr : aliased sproc_attr_t; Sproc : aliased sproc_t; Status : int; begin Status := sproc_attr_init (Sproc_Attr'Unrestricted_Access); - if Status = 0 then Status := sproc_attr_setresources (Sproc_Attr'Unrestricted_Access, To_Resource_T (Attr.Sproc_Resources)); --- 140,158 ---- end Resource_Vector_Functions; + --------------- + -- New_Sproc -- + --------------- + function New_Sproc (Attr : Sproc_Attributes) return sproc_t is Sproc_Attr : aliased sproc_attr_t; Sproc : aliased sproc_t; Status : int; + begin Status := sproc_attr_init (Sproc_Attr'Unrestricted_Access); + if Status = 0 then Status := sproc_attr_setresources (Sproc_Attr'Unrestricted_Access, To_Resource_T (Attr.Sproc_Resources)); *************** package body System.Task_Info is *** 136,148 **** if Attr.CPU > Num_Processors then raise Invalid_CPU_Number; end if; Status := sproc_attr_setcpu (Sproc_Attr'Unrestricted_Access, int (Attr.CPU)); end if; if Attr.Resident /= NOLOCK then - if Geteuid /= 0 then raise Permission_Error; end if; --- 161,173 ---- if Attr.CPU > Num_Processors then raise Invalid_CPU_Number; end if; + Status := sproc_attr_setcpu (Sproc_Attr'Unrestricted_Access, int (Attr.CPU)); end if; if Attr.Resident /= NOLOCK then if Geteuid /= 0 then raise Permission_Error; end if; *************** package body System.Task_Info is *** 153,158 **** --- 178,184 ---- end if; if Attr.NDPRI /= NDP_NONE then + -- ??? why is that comment out, should it be removed ? -- if Geteuid /= 0 then -- raise Permission_Error; -- end if; *************** package body System.Task_Info is *** 184,196 **** return Sproc; end New_Sproc; function New_Sproc (Sproc_Resources : Resource_Vector_T := NO_RESOURCES; CPU : CPU_Number := ANY_CPU; Resident : Page_Locking := NOLOCK; NDPRI : Non_Degrading_Priority := NDP_NONE) ! return sproc_t is ! Attr : Sproc_Attributes := (Sproc_Resources, CPU, Resident, NDPRI); --- 210,226 ---- return Sproc; end New_Sproc; + --------------- + -- New_Sproc -- + --------------- + function New_Sproc (Sproc_Resources : Resource_Vector_T := NO_RESOURCES; CPU : CPU_Number := ANY_CPU; Resident : Page_Locking := NOLOCK; NDPRI : Non_Degrading_Priority := NDP_NONE) ! return sproc_t ! is Attr : Sproc_Attributes := (Sproc_Resources, CPU, Resident, NDPRI); *************** package body System.Task_Info is *** 198,220 **** return New_Sproc (Attr); end New_Sproc; function Unbound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0) ! return Thread_Attributes is begin return (False, Thread_Resources, Thread_Timeslice); end Unbound_Thread_Attributes; function Bound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0; Sproc : sproc_t) ! return Thread_Attributes is begin return (True, Thread_Resources, Thread_Timeslice, Sproc); end Bound_Thread_Attributes; function Bound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0; --- 228,264 ---- return New_Sproc (Attr); end New_Sproc; + ------------------------------- + -- Unbound_Thread_Attributes -- + ------------------------------- + function Unbound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0) ! return Thread_Attributes ! is begin return (False, Thread_Resources, Thread_Timeslice); end Unbound_Thread_Attributes; + ----------------------------- + -- Bound_Thread_Attributes -- + ----------------------------- + function Bound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0; Sproc : sproc_t) ! return Thread_Attributes ! is begin return (True, Thread_Resources, Thread_Timeslice, Sproc); end Bound_Thread_Attributes; + ----------------------------- + -- Bound_Thread_Attributes -- + ----------------------------- + function Bound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0; *************** package body System.Task_Info is *** 222,229 **** CPU : CPU_Number := ANY_CPU; Resident : Page_Locking := NOLOCK; NDPRI : Non_Degrading_Priority := NDP_NONE) ! return Thread_Attributes is ! Sproc : sproc_t := New_Sproc (Sproc_Resources, CPU, Resident, NDPRI); --- 266,273 ---- CPU : CPU_Number := ANY_CPU; Resident : Page_Locking := NOLOCK; NDPRI : Non_Degrading_Priority := NDP_NONE) ! return Thread_Attributes ! is Sproc : sproc_t := New_Sproc (Sproc_Resources, CPU, Resident, NDPRI); *************** package body System.Task_Info is *** 231,255 **** return (True, Thread_Resources, Thread_Timeslice, Sproc); end Bound_Thread_Attributes; function New_Unbound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0) ! return Task_Info_Type is begin return new Thread_Attributes' (False, Thread_Resources, Thread_Timeslice); end New_Unbound_Thread_Attributes; function New_Bound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0; Sproc : sproc_t) ! return Task_Info_Type is begin return new Thread_Attributes' (True, Thread_Resources, Thread_Timeslice, Sproc); end New_Bound_Thread_Attributes; function New_Bound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0; --- 275,313 ---- return (True, Thread_Resources, Thread_Timeslice, Sproc); end Bound_Thread_Attributes; + ----------------------------------- + -- New_Unbound_Thread_Attributes -- + ----------------------------------- + function New_Unbound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0) ! return Task_Info_Type ! is begin return new Thread_Attributes' (False, Thread_Resources, Thread_Timeslice); end New_Unbound_Thread_Attributes; + --------------------------------- + -- New_Bound_Thread_Attributes -- + --------------------------------- + function New_Bound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0; Sproc : sproc_t) ! return Task_Info_Type ! is begin return new Thread_Attributes' (True, Thread_Resources, Thread_Timeslice, Sproc); end New_Bound_Thread_Attributes; + --------------------------------- + -- New_Bound_Thread_Attributes -- + --------------------------------- + function New_Bound_Thread_Attributes (Thread_Resources : Resource_Vector_T := NO_RESOURCES; Thread_Timeslice : Duration := 0.0; *************** package body System.Task_Info is *** 257,264 **** CPU : CPU_Number := ANY_CPU; Resident : Page_Locking := NOLOCK; NDPRI : Non_Degrading_Priority := NDP_NONE) ! return Task_Info_Type is ! Sproc : sproc_t := New_Sproc (Sproc_Resources, CPU, Resident, NDPRI); --- 315,322 ---- CPU : CPU_Number := ANY_CPU; Resident : Page_Locking := NOLOCK; NDPRI : Non_Degrading_Priority := NDP_NONE) ! return Task_Info_Type ! is Sproc : sproc_t := New_Sproc (Sproc_Resources, CPU, Resident, NDPRI); diff -Nrc3pad gcc-3.2.3/gcc/ada/5gtasinf.ads gcc-3.3/gcc/ada/5gtasinf.ads *** gcc-3.2.3/gcc/ada/5gtasinf.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5gtasinf.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** *** 40,45 **** --- 39,45 ---- with System.OS_Interface; with Unchecked_Deallocation; + package System.Task_Info is pragma Elaborate_Body; -- To ensure that a body is allowed *************** pragma Elaborate_Body; *** 49,58 **** --------------------------------------------------------- -- The SGI implementation of the GNU Low-Level Interface (GNULLI) ! -- implements each Ada task as a Posix thread (Pthread). The SGI -- Pthread library distributes threads across one or more processes ! -- that are members of a common share group. Irix distributes ! -- processes across the available CPUs on a given machine. The -- pragma Task_Info provides the mechanism to control the distribution -- of tasks to sprocs, and sprocs to processors. --- 49,58 ---- --------------------------------------------------------- -- The SGI implementation of the GNU Low-Level Interface (GNULLI) ! -- implements each Ada task as a Posix thread (Pthread). The SGI -- Pthread library distributes threads across one or more processes ! -- that are members of a common share group. Irix distributes ! -- processes across the available CPUs on a given machine. The -- pragma Task_Info provides the mechanism to control the distribution -- of tasks to sprocs, and sprocs to processors. *************** pragma Elaborate_Body; *** 103,121 **** NO_RESOURCES : constant Resource_Vector_T := (others => False); generic ! type Resource_T is (<>); -- Discrete type up to 32 entries package Resource_Vector_Functions is ! function "+"(R : Resource_T) return Resource_Vector_T; ! function "+"(R1, R2 : Resource_T) return Resource_Vector_T; ! function "+"(R : Resource_T; S : Resource_Vector_T) return Resource_Vector_T; ! function "+"(S : Resource_Vector_T; R : Resource_T) return Resource_Vector_T; ! function "+"(S1, S2 : Resource_Vector_T) return Resource_Vector_T; ! function "-"(S : Resource_Vector_T; R : Resource_T) return Resource_Vector_T; end Resource_Vector_Functions; --- 103,139 ---- NO_RESOURCES : constant Resource_Vector_T := (others => False); generic ! type Resource_T is (<>); ! -- Discrete type up to 32 entries ! package Resource_Vector_Functions is ! function "+" ! (R : Resource_T) return Resource_Vector_T; ! ! function "+" ! (R1 : Resource_T; ! R2 : Resource_T) return Resource_Vector_T; ! ! function "+" ! (R : Resource_T; ! S : Resource_Vector_T) return Resource_Vector_T; ! ! function "+" ! (S : Resource_Vector_T; ! R : Resource_T) return Resource_Vector_T; ! ! function "+" ! (S1 : Resource_Vector_T; ! S2 : Resource_Vector_T) return Resource_Vector_T; ! ! function "-" ! (S : Resource_Vector_T; ! R : Resource_T) return Resource_Vector_T; end Resource_Vector_Functions; *************** pragma Elaborate_Body; *** 129,135 **** ANY_CPU : constant CPU_Number := CPU_Number'First; ! -- -- Specification of IRIX Non Degrading Priorities. -- -- WARNING: IRIX priorities have the reverse meaning of Ada priorities. --- 147,153 ---- ANY_CPU : constant CPU_Number := CPU_Number'First; ! type Non_Degrading_Priority is range 0 .. 255; -- Specification of IRIX Non Degrading Priorities. -- -- WARNING: IRIX priorities have the reverse meaning of Ada priorities. *************** pragma Elaborate_Body; *** 138,161 **** -- -- See the schedctl(2) man page for a complete discussion of non-degrading -- priorities. - -- - type Non_Degrading_Priority is range 0 .. 255; ! -- these priorities are higher than ALL normal user process priorities ! NDPHIMAX : constant Non_Degrading_Priority := 30; ! NDPHIMIN : constant Non_Degrading_Priority := 39; subtype NDP_High is Non_Degrading_Priority range NDPHIMAX .. NDPHIMIN; - -- these priorities overlap normal user process priorities NDPNORMMAX : constant Non_Degrading_Priority := 40; NDPNORMMIN : constant Non_Degrading_Priority := 127; subtype NDP_Norm is Non_Degrading_Priority range NDPNORMMAX .. NDPNORMMIN; ! -- these priorities are below ALL normal user process priorities ! NDPLOMAX : constant Non_Degrading_Priority := 128; ! NDPLOMIN : constant Non_Degrading_Priority := 254; NDP_NONE : constant Non_Degrading_Priority := 255; --- 156,177 ---- -- -- See the schedctl(2) man page for a complete discussion of non-degrading -- priorities. ! NDPHIMAX : constant Non_Degrading_Priority := 30; ! NDPHIMIN : constant Non_Degrading_Priority := 39; ! -- These priorities are higher than ALL normal user process priorities subtype NDP_High is Non_Degrading_Priority range NDPHIMAX .. NDPHIMIN; NDPNORMMAX : constant Non_Degrading_Priority := 40; NDPNORMMIN : constant Non_Degrading_Priority := 127; + -- These priorities overlap normal user process priorities subtype NDP_Norm is Non_Degrading_Priority range NDPNORMMAX .. NDPNORMMIN; ! NDPLOMAX : constant Non_Degrading_Priority := 128; ! NDPLOMIN : constant Non_Degrading_Priority := 254; ! -- These priorities are below ALL normal user process priorities NDP_NONE : constant Non_Degrading_Priority := 255; *************** pragma Elaborate_Body; *** 168,184 **** DATLOCK -- Lock data segment into memory (data lock) ); ! type Sproc_Attributes is ! record ! Sproc_Resources : Resource_Vector_T := NO_RESOURCES; ! CPU : CPU_Number := ANY_CPU; ! Resident : Page_Locking := NOLOCK; ! NDPRI : Non_Degrading_Priority := NDP_NONE; -- Sproc_Slice : Duration := 0.0; -- Deadline_Period : Duration := 0.0; -- Deadline_Alloc : Duration := 0.0; ! ! end record; Default_Sproc_Attributes : constant Sproc_Attributes := (NO_RESOURCES, ANY_CPU, NOLOCK, NDP_NONE); --- 184,199 ---- DATLOCK -- Lock data segment into memory (data lock) ); ! type Sproc_Attributes is record ! Sproc_Resources : Resource_Vector_T := NO_RESOURCES; ! CPU : CPU_Number := ANY_CPU; ! Resident : Page_Locking := NOLOCK; ! NDPRI : Non_Degrading_Priority := NDP_NONE; ! -- ??? why is that commented out, should it be removed ? -- Sproc_Slice : Duration := 0.0; -- Deadline_Period : Duration := 0.0; -- Deadline_Alloc : Duration := 0.0; ! end record; Default_Sproc_Attributes : constant Sproc_Attributes := (NO_RESOURCES, ANY_CPU, NOLOCK, NDP_NONE); *************** pragma Elaborate_Body; *** 190,199 **** Resident : Page_Locking := NOLOCK; NDPRI : Non_Degrading_Priority := NDP_NONE) return sproc_t; ! -- ! -- Allocates a sproc_t controll structure and creates the -- corresponding sproc. - -- Invalid_CPU_Number : exception; Permission_Error : exception; --- 205,212 ---- Resident : Page_Locking := NOLOCK; NDPRI : Non_Degrading_Priority := NDP_NONE) return sproc_t; ! -- Allocates a sproc_t control structure and creates the -- corresponding sproc. Invalid_CPU_Number : exception; Permission_Error : exception; *************** pragma Elaborate_Body; *** 203,219 **** -- Thread Attributes -- ----------------------- ! type Thread_Attributes (Bound_To_Sproc : Boolean) is ! record ! Thread_Resources : Resource_Vector_T := NO_RESOURCES; ! Thread_Timeslice : Duration := 0.0; ! case Bound_To_Sproc is ! when False => ! null; ! when True => ! Sproc : sproc_t; ! end case; ! end record; Default_Thread_Attributes : constant Thread_Attributes := (False, NO_RESOURCES, 0.0); --- 216,233 ---- -- Thread Attributes -- ----------------------- ! type Thread_Attributes (Bound_To_Sproc : Boolean) is record ! Thread_Resources : Resource_Vector_T := NO_RESOURCES; ! ! Thread_Timeslice : Duration := 0.0; ! ! case Bound_To_Sproc is ! when False => ! null; ! when True => ! Sproc : sproc_t; ! end case; ! end record; Default_Thread_Attributes : constant Thread_Attributes := (False, NO_RESOURCES, 0.0); diff -Nrc3pad gcc-3.2.3/gcc/ada/5gtpgetc.adb gcc-3.3/gcc/ada/5gtpgetc.adb *** gcc-3.2.3/gcc/ada/5gtpgetc.adb 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5gtpgetc.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2000 Free Software Fundation -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5hosinte.adb gcc-3.3/gcc/ada/5hosinte.adb *** gcc-3.2.3/gcc/ada/5hosinte.adb 2001-10-02 13:42:26.000000000 +0000 --- gcc-3.3/gcc/ada/5hosinte.adb 2002-03-14 10:58:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2001, Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5hosinte.ads gcc-3.3/gcc/ada/5hosinte.ads *** gcc-3.2.3/gcc/ada/5hosinte.ads 2001-10-02 13:42:26.000000000 +0000 --- gcc-3.3/gcc/ada/5hosinte.ads 2002-03-14 10:58:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1997-2001, Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5hparame.ads gcc-3.3/gcc/ada/5hparame.ads *** gcc-3.2.3/gcc/ada/5hparame.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5hparame.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** *** 34,39 **** --- 33,39 ---- ------------------------------------------------------------------------------ -- This is the HP version of this package + -- Blank line intentional so that it lines up exactly with default. -- This package defines some system dependent parameters for GNAT. These -- are values that are referenced by the runtime library and are therefore *************** pragma Pure (Parameters); *** 101,107 **** -- proper implementation of the stack overflow check. ---------------------------------------------- ! -- Characteristics of types in Interfaces.C -- ---------------------------------------------- long_bits : constant := Long_Integer'Size; --- 101,107 ---- -- proper implementation of the stack overflow check. ---------------------------------------------- ! -- Characteristics of Types in Interfaces.C -- ---------------------------------------------- long_bits : constant := Long_Integer'Size; *************** pragma Pure (Parameters); *** 132,135 **** --- 132,190 ---- Garbage_Collected : constant Boolean := False; -- The storage mode for this system (release on program exit) + --------------------- + -- Tasking Profile -- + --------------------- + + -- In the following sections, constant parameters are defined to + -- allow some optimizations within the tasking run time based on + -- restrictions on the tasking features. + + ---------------------- + -- Locking Strategy -- + ---------------------- + + Single_Lock : constant Boolean := False; + -- Indicates whether a single lock should be used within the tasking + -- run-time to protect internal structures. If True, a single lock + -- will be used, meaning less locking/unlocking operations, but also + -- more global contention. In general, Single_Lock should be set to + -- True on single processor machines, and to False to multi-processor + -- systems, but this can vary from application to application and also + -- depends on the scheduling policy. + + ------------------- + -- Task Abortion -- + ------------------- + + No_Abort : constant Boolean := False; + -- This constant indicates whether abort statements and asynchronous + -- transfer of control (ATC) are disallowed. If set to True, it is + -- assumed that neither construct is used, and the run time does not + -- need to defer/undefer abort and check for pending actions at + -- completion points. A value of True for No_Abort corresponds to: + -- pragma Restrictions (No_Abort_Statements); + -- pragma Restrictions (Max_Asynchronous_Select_Nesting => 0); + + ---------------------- + -- Dynamic Priority -- + ---------------------- + + Dynamic_Priority_Support : constant Boolean := True; + -- This constant indicates whether dynamic changes of task priorities + -- are allowed (True means normal RM mode in which such changes are + -- allowed). In particular, if this is False, then we do not need to + -- poll for pending base priority changes at every abort completion + -- point. A value of False for Dynamic_Priority_Support corresponds + -- to pragma Restrictions (No_Dynamic_Priorities); + + -------------------- + -- Runtime Traces -- + -------------------- + + Runtime_Traces : constant Boolean := False; + -- This constant indicates whether the runtime outputs traces to a + -- predefined output or not (True means that traces are output). + -- See System.Traces for more details. + end System.Parameters; diff -Nrc3pad gcc-3.2.3/gcc/ada/5hsystem.ads gcc-3.3/gcc/ada/5hsystem.ads *** gcc-3.2.3/gcc/ada/5hsystem.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5hsystem.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (HP-UX Version) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (HP-UX Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 92,118 **** -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 91,104 ---- -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 130,137 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := False; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := False; diff -Nrc3pad gcc-3.2.3/gcc/ada/5htaprop.adb gcc-3.3/gcc/ada/5htaprop.adb *** gcc-3.2.3/gcc/ada/5htaprop.adb 2001-12-16 01:13:27.000000000 +0000 --- gcc-3.3/gcc/ada/5htaprop.adb 2002-10-23 08:27:54.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,40 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ ! -- This is a HP-UX version of this package -- This package contains all the GNULL primitives that interface directly -- with the underlying OS. --- 27,38 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ ! -- This is a HP-UX DCE threads version of this package -- This package contains all the GNULL primitives that interface directly -- with the underlying OS. *************** package body System.Task_Primitives.Oper *** 106,113 **** ATCB_Key : aliased pthread_key_t; -- Key used to find the Ada Task_ID associated with a thread ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. --- 104,113 ---- ATCB_Key : aliased pthread_key_t; -- Key used to find the Ada Task_ID associated with a thread ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. *************** package body System.Task_Primitives.Oper *** 143,195 **** -- Abort_Handler -- ------------------- - -- Target-dependent binding of inter-thread Abort signal to - -- the raising of the Abort_Signal exception. - - -- The technical issues and alternatives here are essentially - -- the same as for raising exceptions in response to other - -- signals (e.g. Storage_Error). See code and comments in - -- the package body System.Interrupt_Management. - - -- Some implementations may not allow an exception to be propagated - -- out of a handler, and others might leave the signal or - -- interrupt that invoked this handler masked after the exceptional - -- return to the application code. - - -- GNAT exceptions are originally implemented using setjmp()/longjmp(). - -- On most UNIX systems, this will allow transfer out of a signal handler, - -- which is usually the only mechanism available for implementing - -- asynchronous handlers of this kind. However, some - -- systems do not restore the signal mask on longjmp(), leaving the - -- abort signal masked. - - -- Alternative solutions include: - - -- 1. Change the PC saved in the system-dependent Context - -- parameter to point to code that raises the exception. - -- Normal return from this handler will then raise - -- the exception after the mask and other system state has - -- been restored (see example below). - -- 2. Use siglongjmp()/sigsetjmp() to implement exceptions. - -- 3. Unmask the signal in the Abortion_Signal exception handler - -- (in the RTS). - - -- The following procedure would be needed if we can't lonjmp out of - -- a signal handler. (See below.) - -- procedure Raise_Abort_Signal is - -- begin - -- raise Standard'Abort_Signal; - -- end if; - procedure Abort_Handler (Sig : Signal) is Self_Id : constant Task_ID := Self; Result : Interfaces.C.int; Old_Set : aliased sigset_t; begin - -- Assuming it is safe to longjmp out of a signal handler, the - -- following code can be used: - if Self_Id.Deferral_Level = 0 and then Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level and then not Self_Id.Aborting --- 143,154 ---- *************** package body System.Task_Primitives.Oper *** 204,218 **** raise Standard'Abort_Signal; end if; - - -- Otherwise, something like this is required: - -- if not Abort_Is_Deferred.all then - -- -- Overwrite the return PC address with the address of the - -- -- special raise routine, and "return" to that routine's - -- -- starting address. - -- Context.PC := Raise_Abort_Signal'Address; - -- return; - -- end if; end Abort_Handler; ----------------- --- 163,168 ---- *************** package body System.Task_Primitives.Oper *** 243,249 **** function Self return Task_ID is Result : System.Address; - begin Result := pthread_getspecific (ATCB_Key); pragma Assert (Result /= System.Null_Address); --- 193,198 ---- *************** package body System.Task_Primitives.Oper *** 256,262 **** -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as All_Tasks_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. --- 205,211 ---- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. *************** package body System.Task_Primitives.Oper *** 266,272 **** L : access Lock) is Attributes : aliased pthread_mutexattr_t; ! Result : Interfaces.C.int; begin Result := pthread_mutexattr_init (Attributes'Access); pragma Assert (Result = 0 or else Result = ENOMEM); --- 215,222 ---- L : access Lock) is Attributes : aliased pthread_mutexattr_t; ! Result : Interfaces.C.int; ! begin Result := pthread_mutexattr_init (Attributes'Access); pragma Assert (Result = 0 or else Result = ENOMEM); *************** package body System.Task_Primitives.Oper *** 290,296 **** procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is Attributes : aliased pthread_mutexattr_t; ! Result : Interfaces.C.int; begin Result := pthread_mutexattr_init (Attributes'Access); --- 240,246 ---- procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is Attributes : aliased pthread_mutexattr_t; ! Result : Interfaces.C.int; begin Result := pthread_mutexattr_init (Attributes'Access); *************** package body System.Task_Primitives.Oper *** 318,324 **** procedure Finalize_Lock (L : access Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_destroy (L.L'Access); pragma Assert (Result = 0); --- 268,273 ---- *************** package body System.Task_Primitives.Oper *** 326,332 **** procedure Finalize_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_destroy (L); pragma Assert (Result = 0); --- 275,280 ---- *************** package body System.Task_Primitives.Oper *** 337,344 **** ---------------- procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is ! Result : Interfaces.C.int; ! begin L.Owner_Priority := Get_Priority (Self); --- 285,291 ---- ---------------- procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is ! Result : Interfaces.C.int; begin L.Owner_Priority := Get_Priority (Self); *************** package body System.Task_Primitives.Oper *** 352,371 **** Ceiling_Violation := False; end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Write_Lock; --------------- --- 299,322 ---- Ceiling_Violation := False; end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 382,422 **** ------------ procedure Unlock (L : access Lock) is ! Result : Interfaces.C.int; ! begin Result := pthread_mutex_unlock (L.L'Access); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Unlock; ! ------------- ! -- Sleep -- ! ------------- ! procedure Sleep (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) is Result : Interfaces.C.int; - begin ! pragma Assert (Self_ID = Self); ! Result := pthread_cond_wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access); -- EINTR is not considered a failure. pragma Assert (Result = 0 or else Result = EINTR); end Sleep; --- 333,380 ---- ------------ procedure Unlock (L : access Lock) is ! Result : Interfaces.C.int; begin Result := pthread_mutex_unlock (L.L'Access); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); ! end if; end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Unlock; ! ----------- ! -- Sleep -- ! ----------- ! procedure Sleep ! (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) ! is Result : Interfaces.C.int; begin ! if Single_Lock then ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! else ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; ! -- EINTR is not considered a failure. pragma Assert (Result = 0 or else Result = EINTR); end Sleep; *************** package body System.Task_Primitives.Oper *** 425,434 **** -- Timed_Sleep -- ----------------- - -- This is for use within the run-time system, so abort is - -- assumed to be already deferred, and the caller should be - -- holding its own ATCB lock. - procedure Timed_Sleep (Self_ID : Task_ID; Time : Duration; --- 383,388 ---- *************** package body System.Task_Primitives.Oper *** 441,446 **** --- 395,401 ---- Abs_Time : Duration; Request : aliased timespec; Result : Interfaces.C.int; + begin Timedout := True; Yielded := False; *************** package body System.Task_Primitives.Oper *** 458,466 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, ! Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 413,428 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! if Single_Lock then ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access, ! Request'Access); ! ! else ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, ! Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 479,488 **** -- Timed_Delay -- ----------------- - -- This is for use in implementing delay statements, so - -- we assume the caller is abort-deferred but is holding - -- no locks. - procedure Timed_Delay (Self_ID : Task_ID; Time : Duration; --- 441,446 ---- *************** package body System.Task_Primitives.Oper *** 492,504 **** Abs_Time : Duration; Request : aliased timespec; Result : Interfaces.C.int; - begin -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; Write_Lock (Self_ID); if Mode = Relative then --- 450,467 ---- Abs_Time : Duration; Request : aliased timespec; Result : Interfaces.C.int; + begin -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); if Mode = Relative then *************** package body System.Task_Primitives.Oper *** 520,527 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 483,495 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! if Single_Lock then ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Single_RTS_Lock'Access, Request'Access); ! else ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 534,539 **** --- 502,512 ---- end if; Unlock (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + Result := sched_yield; SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 567,573 **** procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is Result : Interfaces.C.int; - begin Result := pthread_cond_signal (T.Common.LL.CV'Access); pragma Assert (Result = 0); --- 540,545 ---- *************** package body System.Task_Primitives.Oper *** 579,585 **** procedure Yield (Do_Yield : Boolean := True) is Result : Interfaces.C.int; - begin if Do_Yield then Result := sched_yield; --- 551,556 ---- *************** package body System.Task_Primitives.Oper *** 681,695 **** Result := pthread_setspecific (ATCB_Key, To_Address (Self_ID)); pragma Assert (Result = 0); ! Lock_All_Tasks_List; ! for I in Known_Tasks'Range loop ! if Known_Tasks (I) = null then ! Known_Tasks (I) := Self_ID; ! Self_ID.Known_Tasks_Index := I; exit; end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 652,668 ---- Result := pthread_setspecific (ATCB_Key, To_Address (Self_ID)); pragma Assert (Result = 0); ! Lock_RTS; ! ! for J in Known_Tasks'Range loop ! if Known_Tasks (J) = null then ! Known_Tasks (J) := Self_ID; ! Self_ID.Known_Tasks_Index := J; exit; end if; end loop; ! ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 701,755 **** return new Ada_Task_Control_Block (Entry_Num); end New_ATCB; ! ---------------------- ! -- Initialize_TCB -- ! ---------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is Mutex_Attr : aliased pthread_mutexattr_t; ! Result : Interfaces.C.int; ! Cond_Attr : aliased pthread_condattr_t; begin ! Result := pthread_mutexattr_init (Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Succeeded := False; ! return; end if; - Result := pthread_mutexattr_destroy (Mutex_Attr'Access); - pragma Assert (Result = 0); - Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! Succeeded := False; ! return; end if; - Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, - Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - if Result = 0 then Succeeded := True; else ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); Succeeded := False; end if; --- 674,725 ---- return new Ada_Task_Control_Block (Entry_Num); end New_ATCB; ! -------------------- ! -- Initialize_TCB -- ! -------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is Mutex_Attr : aliased pthread_mutexattr_t; ! Result : Interfaces.C.int; ! Cond_Attr : aliased pthread_condattr_t; begin ! if not Single_Lock then ! Result := pthread_mutexattr_init (Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! end if; ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! Result := pthread_mutexattr_destroy (Mutex_Attr'Access); ! pragma Assert (Result = 0); end if; Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, ! Cond_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); end if; if Result = 0 then Succeeded := True; else ! if not Single_Lock then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Succeeded := False; end if; *************** package body System.Task_Primitives.Oper *** 834,841 **** Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); --- 804,814 ---- Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! if not Single_Lock then ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); *************** package body System.Task_Primitives.Oper *** 901,923 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 874,896 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 955,961 **** Environment_Task_ID := Environment_Task; ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); -- Initialize the lock used to synchronize chain of all ATCBs. Enter_Task (Environment_Task); --- 928,934 ---- Environment_Task_ID := Environment_Task; ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); -- Initialize the lock used to synchronize chain of all ATCBs. Enter_Task (Environment_Task); *************** package body System.Task_Primitives.Oper *** 985,991 **** end do_nothing; begin - declare Result : Interfaces.C.int; begin --- 958,963 ---- *************** begin *** 998,1002 **** Result := pthread_key_create (ATCB_Key'Access, do_nothing'Access); pragma Assert (Result = 0); end; - end System.Task_Primitives.Operations; --- 970,973 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5htaspri.ads gcc-3.3/gcc/ada/5htaspri.ads *** gcc-3.2.3/gcc/ada/5htaspri.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5htaspri.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5htraceb.adb gcc-3.3/gcc/ada/5htraceb.adb *** gcc-3.2.3/gcc/ada/5htraceb.adb 2001-10-02 13:42:26.000000000 +0000 --- gcc-3.3/gcc/ada/5htraceb.adb 2002-03-14 10:58:32.000000000 +0000 *************** *** 7,15 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 7,14 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1999-2002 Ada Core Technologies, 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- -- *************** package body System.Traceback is *** 200,208 **** -- Descriptors. subtype UWT is Unwind_Table_Region; - type UWT_Ptr is access all UWT; - - function To_UWT_Address is new Ada.Unchecked_Conversion (UWT_Ptr, Address); -- The subprograms imported below are provided by the HP library --- 199,204 ---- *************** package body System.Traceback is *** 598,601 **** end Call_Chain; end System.Traceback; - --- 594,596 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5iosinte.adb gcc-3.3/gcc/ada/5iosinte.adb *** gcc-3.2.3/gcc/ada/5iosinte.adb 2001-10-04 17:50:42.000000000 +0000 --- gcc-3.3/gcc/ada/5iosinte.adb 2002-03-14 10:58:32.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5iosinte.ads gcc-3.3/gcc/ada/5iosinte.ads *** gcc-3.2.3/gcc/ada/5iosinte.ads 2002-05-04 03:27:14.000000000 +0000 --- gcc-3.3/gcc/ada/5iosinte.ads 2003-05-02 17:22:50.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package System.OS_Interface is *** 445,455 **** private ! type sigset_t is array (0 .. 31) of unsigned_long; pragma Convention (C, sigset_t); - for sigset_t'Size use 1024; - -- This is for GNU libc version 2 but should be backward compatible with - -- other libc where sigset_t is smaller. type pid_t is new int; --- 444,451 ---- private ! type sigset_t is array (0 .. 127) of unsigned_char; pragma Convention (C, sigset_t); type pid_t is new int; *************** private *** 478,484 **** stackaddr : System.Address; stacksize : size_t; end record; ! pragma Convention (C_Pass_By_Copy, pthread_attr_t); type pthread_condattr_t is record dummy : int; --- 474,480 ---- stackaddr : System.Address; stacksize : size_t; end record; ! pragma Convention (C, pthread_attr_t); type pthread_condattr_t is record dummy : int; *************** private *** 492,515 **** type pthread_t is new unsigned_long; ! type struct_pthread_queue is record ! head : System.Address; ! tail : System.Address; end record; ! pragma Convention (C, struct_pthread_queue); type pthread_mutex_t is record ! m_spinlock : int; m_count : int; m_owner : System.Address; m_kind : int; ! m_waiting : struct_pthread_queue; end record; pragma Convention (C, pthread_mutex_t); type pthread_cond_t is record ! c_spinlock : int; ! c_waiting : struct_pthread_queue; end record; pragma Convention (C, pthread_cond_t); --- 488,515 ---- type pthread_t is new unsigned_long; ! type struct_pthread_fast_lock is record ! status : long; ! spinlock : int; end record; ! pragma Convention (C, struct_pthread_fast_lock); type pthread_mutex_t is record ! m_reserved : int; m_count : int; m_owner : System.Address; m_kind : int; ! m_lock : struct_pthread_fast_lock; end record; pragma Convention (C, pthread_mutex_t); + type pthread_cond_padding_t is array (0 .. 35) of unsigned_char; + pragma Convention (C, pthread_cond_padding_t); + type pthread_cond_t is record ! c_lock : struct_pthread_fast_lock; ! c_waiting : System.Address; ! c_padding : pthread_cond_padding_t; end record; pragma Convention (C, pthread_cond_t); diff -Nrc3pad gcc-3.2.3/gcc/ada/5itaprop.adb gcc-3.3/gcc/ada/5itaprop.adb *** gcc-3.2.3/gcc/ada/5itaprop.adb 2001-12-16 01:13:28.000000000 +0000 --- gcc-3.3/gcc/ada/5itaprop.adb 2002-03-14 10:58:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** package body System.Task_Primitives.Oper *** 112,122 **** -- The followings are logically constants, but need to be initialized -- at run time. ! ATCB_Key : aliased pthread_key_t; ! -- Key used to find the Ada Task_ID associated with a thread ! ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. --- 110,119 ---- -- The followings are logically constants, but need to be initialized -- at run time. ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. *************** package body System.Task_Primitives.Oper *** 186,191 **** --- 183,211 ---- function To_pthread_t is new Unchecked_Conversion (Integer, System.OS_Interface.pthread_t); + -------------------- + -- Local Packages -- + -------------------- + + package Specific is + + procedure Initialize (Environment_Task : Task_ID); + pragma Inline (Initialize); + -- Initialize various data needed by this package. + + procedure Set (Self_Id : Task_ID); + pragma Inline (Set); + -- Set the self id for the current task. + + function Self return Task_ID; + pragma Inline (Self); + -- Return a pointer to the Ada Task Control Block of the calling task. + + end Specific; + + package body Specific is separate; + -- The body of this package is target specific. + ------------------- -- Abort_Handler -- ------------------- *************** package body System.Task_Primitives.Oper *** 297,305 **** end if; end Abort_Handler; ! ------------------- ! -- Stack_Guard -- ! ------------------- -- The underlying thread system extends the memory (up to 2MB) when -- needed. --- 317,343 ---- end if; end Abort_Handler; ! -------------- ! -- Lock_RTS -- ! -------------- ! ! procedure Lock_RTS is ! begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! ! procedure Unlock_RTS is ! begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ! ! ----------------- ! -- Stack_Guard -- ! ----------------- -- The underlying thread system extends the memory (up to 2MB) when -- needed. *************** package body System.Task_Primitives.Oper *** 322,335 **** -- Self -- ---------- ! function Self return Task_ID is ! Result : System.Address; ! ! begin ! Result := pthread_getspecific (ATCB_Key); ! pragma Assert (Result /= System.Null_Address); ! return To_Task_ID (Result); ! end Self; --------------------- -- Initialize_Lock -- --- 360,366 ---- -- Self -- ---------- ! function Self return Task_ID renames Specific.Self; --------------------- -- Initialize_Lock -- *************** package body System.Task_Primitives.Oper *** 337,343 **** -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as All_Tasks_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. --- 368,374 ---- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. *************** package body System.Task_Primitives.Oper *** 401,407 **** procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is Result : Interfaces.C.int; - begin if Priority_Ceiling_Emulation then declare --- 432,437 ---- *************** package body System.Task_Primitives.Oper *** 427,446 **** end if; end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Write_Lock; --------------- --- 457,480 ---- end if; end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 458,464 **** procedure Unlock (L : access Lock) is Result : Interfaces.C.int; - begin if Priority_Ceiling_Emulation then declare --- 492,497 ---- *************** package body System.Task_Primitives.Oper *** 476,514 **** end if; end Unlock; ! procedure Unlock (L : access RTS_Lock) is Result : Interfaces.C.int; - -- Beware of any changes to this that might - -- require access to the ATCB after the mutex is unlocked. - -- This is the last operation performed by a task - -- before it allows its ATCB to be deallocated, so it - -- MUST NOT refer to the ATCB. - begin ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Unlock; ! ------------- ! -- Sleep -- ! ------------- ! procedure Sleep (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) is Result : Interfaces.C.int; - begin pragma Assert (Self_ID = Self); ! Result := pthread_cond_wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access); -- EINTR is not considered a failure. pragma Assert (Result = 0 or else Result = EINTR); end Sleep; --- 509,552 ---- end if; end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); ! end if; end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Unlock; ! ----------- ! -- Sleep -- ! ----------- ! procedure Sleep ! (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) ! is Result : Interfaces.C.int; begin pragma Assert (Self_ID = Self); ! ! if Single_Lock then ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! else ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; ! -- EINTR is not considered a failure. pragma Assert (Result = 0 or else Result = EINTR); end Sleep; *************** package body System.Task_Primitives.Oper *** 550,558 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, ! Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 588,603 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! if Single_Lock then ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access, ! Request'Access); ! ! else ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, ! Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 591,596 **** --- 636,646 ---- -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); if Mode = Relative then *************** package body System.Task_Primitives.Oper *** 612,619 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 662,674 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! if Single_Lock then ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Single_RTS_Lock'Access, Request'Access); ! else ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 626,631 **** --- 681,691 ---- end if; Unlock (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + Result := sched_yield; SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 734,756 **** ---------------- procedure Enter_Task (Self_ID : Task_ID) is - Result : Interfaces.C.int; - begin Self_ID.Common.LL.Thread := pthread_self; ! Result := pthread_setspecific (ATCB_Key, To_Address (Self_ID)); ! pragma Assert (Result = 0); ! Lock_All_Tasks_List; ! for I in Known_Tasks'Range loop ! if Known_Tasks (I) = null then ! Known_Tasks (I) := Self_ID; ! Self_ID.Known_Tasks_Index := I; exit; end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 794,815 ---- ---------------- procedure Enter_Task (Self_ID : Task_ID) is begin Self_ID.Common.LL.Thread := pthread_self; ! Specific.Set (Self_ID); ! Lock_RTS; ! ! for J in Known_Tasks'Range loop ! if Known_Tasks (J) = null then ! Known_Tasks (J) := Self_ID; ! Self_ID.Known_Tasks_Index := J; exit; end if; end loop; ! ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 778,790 **** Self_ID.Common.LL.Thread := To_pthread_t (-1); ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Succeeded := False; ! return; end if; Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, --- 837,851 ---- Self_ID.Common.LL.Thread := To_pthread_t (-1); ! if not Single_Lock then ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; end if; Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, *************** package body System.Task_Primitives.Oper *** 794,806 **** if Result = 0 then Succeeded := True; else ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); Succeeded := False; end if; - - Result := pthread_condattr_destroy (Cond_Attr'Access); - pragma Assert (Result = 0); end Initialize_TCB; ----------------- --- 855,867 ---- if Result = 0 then Succeeded := True; else ! if not Single_Lock then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Succeeded := False; end if; end Initialize_TCB; ----------------- *************** package body System.Task_Primitives.Oper *** 865,877 **** Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; Free (Tmp); end Finalize_TCB; --- 926,943 ---- Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! if not Single_Lock then ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); + if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; + Free (Tmp); end Finalize_TCB; *************** package body System.Task_Primitives.Oper *** 927,950 **** return Environment_Task_ID; end Environment_Task; - ------------------------- - -- Lock_All_Tasks_List -- - ------------------------- - - procedure Lock_All_Tasks_List is - begin - Write_Lock (All_Tasks_L'Access); - end Lock_All_Tasks_List; - - --------------------------- - -- Unlock_All_Tasks_List -- - --------------------------- - - procedure Unlock_All_Tasks_List is - begin - Unlock (All_Tasks_L'Access); - end Unlock_All_Tasks_List; - ------------------ -- Suspend_Task -- ------------------ --- 993,998 ---- *************** package body System.Task_Primitives.Oper *** 994,1001 **** Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); ! -- Initialize the lock used to synchronize chain of all ATCBs. Enter_Task (Environment_Task); --- 1042,1051 ---- Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); ! -- Initialize the global RTS lock ! ! Specific.Initialize (Environment_Task); Enter_Task (Environment_Task); *************** begin *** 1038,1046 **** pragma Assert (Result = 0); end if; end loop; - - Result := pthread_key_create (ATCB_Key'Access, null); - pragma Assert (Result = 0); end; - end System.Task_Primitives.Operations; --- 1088,1092 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5itaspri.ads gcc-3.3/gcc/ada/5itaspri.ads *** gcc-3.2.3/gcc/ada/5itaspri.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5itaspri.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5ksystem.ads gcc-3.3/gcc/ada/5ksystem.ads *** gcc-3.2.3/gcc/ada/5ksystem.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5ksystem.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (VxWorks version M68K) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (VxWorks version M68K) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 88,127 **** -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := ! Bit_Order'Val (Standard'Default_Bit_Order); -- Priority-related Declarations (RM D.1) ! -- 256 is reserved for the VxWorks kernel ! -- 248 - 255 correspond to hardware interrupt levels 0 .. 7 ! -- 247 is a catchall default "interrupt" priority for signals, allowing ! -- higher priority than normal tasks, but lower than hardware ! -- priority levels. Protected Object ceilings can override ! -- these values ! -- 246 is used by the Interrupt_Manager task ! ! Max_Priority : constant Positive := 245; Max_Interrupt_Priority : constant Positive := 255; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 87,112 ---- -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := High_Order_First; -- Priority-related Declarations (RM D.1) ! -- 256 is reserved for the VxWorks kernel ! -- 248 - 255 correspond to hardware interrupt levels 0 .. 7 ! -- 247 is a catchall default "interrupt" priority for signals, ! -- allowing higher priority than normal tasks, but lower than ! -- hardware priority levels. Protected Object ceilings can ! -- override these values. ! -- 246 is used by the Interrupt_Manager task + Max_Priority : constant Positive := 245; Max_Interrupt_Priority : constant Positive := 255; ! subtype Any_Priority is Integer range 0 .. 255; ! subtype Priority is Any_Priority range 0 .. 245; ! subtype Interrupt_Priority is Any_Priority range 246 .. 255; ! Default_Priority : constant Priority := 122; private *************** private *** 139,146 **** --- 124,134 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := False; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := False; diff -Nrc3pad gcc-3.2.3/gcc/ada/5kvxwork.ads gcc-3.3/gcc/ada/5kvxwork.ads *** gcc-3.2.3/gcc/ada/5kvxwork.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5kvxwork.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** package System.VxWorks is *** 42,71 **** package IC renames Interfaces.C; ! -- Define enough of a Wind Task Control Block in order to ! -- obtain the inherited priority. When porting this to ! -- different versions of VxWorks (this is based on 5.3[.1]), ! -- be sure to look at the definition for WIND_TCB located ! -- in $WIND_BASE/target/h/taskLib.h ! ! type Wind_Fill_1 is array (0 .. 16#3F#) of IC.unsigned_char; ! type Wind_Fill_2 is array (16#48# .. 16#107#) of IC.unsigned_char; ! ! type Wind_TCB is record ! Fill_1 : Wind_Fill_1; -- 0x00 - 0x3f ! Priority : IC.int; -- 0x40 - 0x43, current (inherited) priority ! Normal_Priority : IC.int; -- 0x44 - 0x47, base priority ! Fill_2 : Wind_Fill_2; -- 0x48 - 0x107 ! spare1 : Address; -- 0x108 - 0x10b ! spare2 : Address; -- 0x10c - 0x10f ! spare3 : Address; -- 0x110 - 0x113 ! spare4 : Address; -- 0x114 - 0x117 ! end record; ! type Wind_TCB_Ptr is access Wind_TCB; ! ! -- Floating point context record. 68K version ! FP_NUM_DREGS : constant := 8; FP_STATE_FRAME_SIZE : constant := 216; type DOUBLEX is array (1 .. 12) of Interfaces.Unsigned_8; --- 41,49 ---- package IC renames Interfaces.C; ! -- Floating point context record. 68K version ! FP_NUM_DREGS : constant := 8; FP_STATE_FRAME_SIZE : constant := 216; type DOUBLEX is array (1 .. 12) of Interfaces.Unsigned_8; *************** package System.VxWorks is *** 96,120 **** Num_HW_Interrupts : constant := 256; -- Number of entries in the hardware interrupt vector table - -- VxWorks 5.3 and 5.4 version - type TASK_DESC is record - td_id : IC.int; -- task id - td_name : Address; -- name of task - td_priority : IC.int; -- task priority - td_status : IC.int; -- task status - td_options : IC.int; -- task option bits (see below) - td_entry : Address; -- original entry point of task - td_sp : Address; -- saved stack pointer - td_pStackBase : Address; -- the bottom of the stack - td_pStackLimit : Address; -- the effective end of the stack - td_pStackEnd : Address; -- the actual end of the stack - td_stackSize : IC.int; -- size of stack in bytes - td_stackCurrent : IC.int; -- current stack usage in bytes - td_stackHigh : IC.int; -- maximum stack usage in bytes - td_stackMargin : IC.int; -- current stack margin in bytes - td_errorStatus : IC.int; -- most recent task error status - td_delay : IC.int; -- delay/timeout ticks - end record; - pragma Convention (C, TASK_DESC); - end System.VxWorks; --- 74,77 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5lintman.adb gcc-3.3/gcc/ada/5lintman.adb *** gcc-3.2.3/gcc/ada/5lintman.adb 2001-12-16 01:13:28.000000000 +0000 --- gcc-3.3/gcc/ada/5lintman.adb 2002-03-14 10:58:34.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3 $ -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2002 Florida State University -- -- -- -- GNARL 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- -- *************** begin *** 304,336 **** act.sa_mask := Signal_Mask; ! Result := ! sigaction ! (Signal (SIGFPE), act'Unchecked_Access, ! old_act'Unchecked_Access); ! pragma Assert (Result = 0); ! ! for J in Exception_Interrupts'First + 1 .. Exception_Interrupts'Last loop Keep_Unmasked (Exception_Interrupts (J)) := True; ! if Unreserve_All_Interrupts = 0 then ! Result := ! sigaction ! (Signal (Exception_Interrupts (J)), ! act'Unchecked_Access, ! old_act'Unchecked_Access); ! pragma Assert (Result = 0); ! end if; end loop; Keep_Unmasked (Abort_Task_Interrupt) := True; - Keep_Unmasked (SIGXCPU) := True; - Keep_Unmasked (SIGBUS) := True; - Keep_Unmasked (SIGFPE) := True; -- By keeping SIGINT unmasked, allow the user to do a Ctrl-C, but in the -- same time, disable the ability of handling this signal -- via Ada.Interrupts. ! -- The pragma Unreserve_All_Interrupts let the user the ability to -- change this behavior. if Unreserve_All_Interrupts = 0 then --- 303,324 ---- act.sa_mask := Signal_Mask; ! for J in Exception_Interrupts'Range loop Keep_Unmasked (Exception_Interrupts (J)) := True; ! Result := ! sigaction ! (Signal (Exception_Interrupts (J)), ! act'Unchecked_Access, ! old_act'Unchecked_Access); ! pragma Assert (Result = 0); end loop; Keep_Unmasked (Abort_Task_Interrupt) := True; -- By keeping SIGINT unmasked, allow the user to do a Ctrl-C, but in the -- same time, disable the ability of handling this signal -- via Ada.Interrupts. ! -- The pragma Unreserve_All_Interrupts allows the user to -- change this behavior. if Unreserve_All_Interrupts = 0 then diff -Nrc3pad gcc-3.2.3/gcc/ada/5lml-tgt.adb gcc-3.3/gcc/ada/5lml-tgt.adb *** gcc-3.2.3/gcc/ada/5lml-tgt.adb 2001-10-04 17:50:42.000000000 +0000 --- gcc-3.3/gcc/ada/5lml-tgt.adb 2002-03-14 10:58:34.000000000 +0000 *************** *** 7,13 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 2001, Ada Core Technologies, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5losinte.ads gcc-3.3/gcc/ada/5losinte.ads *** gcc-3.2.3/gcc/ada/5losinte.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5losinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5lsystem.ads gcc-3.3/gcc/ada/5lsystem.ads *** gcc-3.2.3/gcc/ada/5lsystem.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5lsystem.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 5,15 **** -- S Y S T E M -- -- -- -- S p e c -- ! -- (GNU/Linux/x86 Version) -- -- -- - -- $Revision: 1.2.12.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 5,14 ---- -- S Y S T E M -- -- -- -- S p e c -- ! -- (GNU-Linux/x86 Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 88,119 **** -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := ! Bit_Order'Val (Standard'Default_Bit_Order); -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 87,104 ---- -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := Low_Order_First; -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 131,138 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; *************** private *** 146,150 **** Use_Ada_Main_Program_Name : constant Boolean := False; ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; ! Front_End_ZCX_Support : constant Boolean := True; end System; --- 134,138 ---- Use_Ada_Main_Program_Name : constant Boolean := False; ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; ! Front_End_ZCX_Support : constant Boolean := False; end System; diff -Nrc3pad gcc-3.2.3/gcc/ada/5mosinte.ads gcc-3.3/gcc/ada/5mosinte.ads *** gcc-3.2.3/gcc/ada/5mosinte.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5mosinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5mvxwork.ads gcc-3.3/gcc/ada/5mvxwork.ads *** gcc-3.2.3/gcc/ada/5mvxwork.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5mvxwork.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** package System.VxWorks is *** 42,102 **** package IC renames Interfaces.C; ! -- Define enough of a Wind Task Control Block in order to ! -- obtain the inherited priority. When porting this to ! -- different versions of VxWorks (this is based on 5.3[.1]), ! -- be sure to look at the definition for WIND_TCB located ! -- in $WIND_BASE/target/h/taskLib.h ! ! type Wind_Fill_1 is array (0 .. 16#3F#) of IC.unsigned_char; ! type Wind_Fill_2 is array (16#48# .. 16#107#) of IC.unsigned_char; ! ! type Wind_TCB is record ! Fill_1 : Wind_Fill_1; -- 0x00 - 0x3f ! Priority : IC.int; -- 0x40 - 0x43, current (inherited) priority ! Normal_Priority : IC.int; -- 0x44 - 0x47, base priority ! Fill_2 : Wind_Fill_2; -- 0x48 - 0x107 ! spare1 : Address; -- 0x108 - 0x10b ! spare2 : Address; -- 0x10c - 0x10f ! spare3 : Address; -- 0x110 - 0x113 ! spare4 : Address; -- 0x114 - 0x117 ! end record; ! type Wind_TCB_Ptr is access Wind_TCB; ! ! -- Floating point context record. MIPS version FP_NUM_DREGS : constant := 16; type Fpx_Array is array (1 .. FP_NUM_DREGS) of IC.double; type FP_CONTEXT is record ! fpx : Fpx_Array; fpcsr : IC.int; end record; pragma Convention (C, FP_CONTEXT); ! -- Number of entries in hardware interrupt vector table. Value of ! -- 0 disables hardware interrupt handling until it can be tested ! Num_HW_Interrupts : constant := 0; ! ! -- VxWorks 5.3 and 5.4 version ! type TASK_DESC is record ! td_id : IC.int; -- task id ! td_name : Address; -- name of task ! td_priority : IC.int; -- task priority ! td_status : IC.int; -- task status ! td_options : IC.int; -- task option bits (see below) ! td_entry : Address; -- original entry point of task ! td_sp : Address; -- saved stack pointer ! td_pStackBase : Address; -- the bottom of the stack ! td_pStackLimit : Address; -- the effective end of the stack ! td_pStackEnd : Address; -- the actual end of the stack ! td_stackSize : IC.int; -- size of stack in bytes ! td_stackCurrent : IC.int; -- current stack usage in bytes ! td_stackHigh : IC.int; -- maximum stack usage in bytes ! td_stackMargin : IC.int; -- current stack margin in bytes ! td_errorStatus : IC.int; -- most recent task error status ! td_delay : IC.int; -- delay/timeout ticks ! end record; ! pragma Convention (C, TASK_DESC); end System.VxWorks; --- 41,58 ---- package IC renames Interfaces.C; ! -- Floating point context record. MIPS version FP_NUM_DREGS : constant := 16; type Fpx_Array is array (1 .. FP_NUM_DREGS) of IC.double; type FP_CONTEXT is record ! fpx : Fpx_Array; fpcsr : IC.int; end record; pragma Convention (C, FP_CONTEXT); ! Num_HW_Interrupts : constant := 256; ! -- Number of entries in hardware interrupt vector table. end System.VxWorks; diff -Nrc3pad gcc-3.2.3/gcc/ada/5ninmaop.adb gcc-3.3/gcc/ada/5ninmaop.adb *** gcc-3.2.3/gcc/ada/5ninmaop.adb 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/5ninmaop.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 2,15 **** -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . I N T E R R U P T _ M A N A G E M E N T . -- ! -- O P E R A T I O N S -- -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 2,13 ---- -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.INTERRUPT_MANAGEMENT.OPERATIONS -- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 38,43 **** --- 36,45 ---- package body System.Interrupt_Management.Operations is + -- Turn off warnings since many unused formals + + pragma Warnings (Off); + ---------------------------- -- Thread_Block_Interrupt -- ---------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/5nintman.adb gcc-3.3/gcc/ada/5nintman.adb *** gcc-3.2.3/gcc/ada/5nintman.adb 2002-05-07 08:22:02.000000000 +0000 --- gcc-3.3/gcc/ada/5nintman.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1991-1996, 1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5nosinte.ads gcc-3.3/gcc/ada/5nosinte.ads *** gcc-3.2.3/gcc/ada/5nosinte.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5nosinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.8.1 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 35,52 **** -- This is the no tasking version - with Interfaces.C; package System.OS_Interface is pragma Preelaborate; - subtype int is Interfaces.C.int; - ------------- -- Signals -- ------------- Max_Interrupt : constant := 2; ! type Signal is new int range 0 .. Max_Interrupt; type sigset_t is new Integer; type Thread_Id is new Integer; --- 34,48 ---- -- This is the no tasking version package System.OS_Interface is pragma Preelaborate; ------------- -- Signals -- ------------- Max_Interrupt : constant := 2; ! type Signal is new Integer range 0 .. Max_Interrupt; type sigset_t is new Integer; type Thread_Id is new Integer; diff -Nrc3pad gcc-3.2.3/gcc/ada/5ntaprop.adb gcc-3.3/gcc/ada/5ntaprop.adb *** gcc-3.2.3/gcc/ada/5ntaprop.adb 2001-10-02 13:42:26.000000000 +0000 --- gcc-3.3/gcc/ada/5ntaprop.adb 2002-05-31 19:27:59.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** with System.Tasking; *** 47,55 **** -- used for Ada_Task_Control_Block -- Task_ID - with System.OS_Primitives; - -- used for Delay_Modes - with System.Error_Reporting; -- used for Shutdown --- 45,50 ---- *************** package body System.Task_Primitives.Oper *** 57,67 **** use System.Tasking; use System.Parameters; - use System.OS_Primitives; ! ------------------- ! -- Stack_Guard -- ! ------------------- procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is begin --- 52,61 ---- use System.Tasking; use System.Parameters; ! ----------------- ! -- Stack_Guard -- ! ----------------- procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is begin *************** package body System.Task_Primitives.Oper *** 92,99 **** procedure Initialize_Lock (Prio : System.Any_Priority; ! L : access Lock) ! is begin null; end Initialize_Lock; --- 86,92 ---- procedure Initialize_Lock (Prio : System.Any_Priority; ! L : access Lock) is begin null; end Initialize_Lock; *************** package body System.Task_Primitives.Oper *** 126,132 **** Ceiling_Violation := False; end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is begin null; end Write_Lock; --- 119,127 ---- Ceiling_Violation := False; end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is begin null; end Write_Lock; *************** package body System.Task_Primitives.Oper *** 154,160 **** null; end Unlock; ! procedure Unlock (L : access RTS_Lock) is begin null; end Unlock; --- 149,155 ---- null; end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is begin null; end Unlock; *************** package body System.Task_Primitives.Oper *** 164,175 **** null; end Unlock; ! ------------- ! -- Sleep -- ! ------------- ! procedure Sleep (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) is begin null; end Sleep; --- 159,169 ---- null; end Unlock; ! ----------- ! -- Sleep -- ! ----------- ! procedure Sleep (Self_ID : Task_ID; Reason : System.Tasking.Task_States) is begin null; end Sleep; *************** package body System.Task_Primitives.Oper *** 195,219 **** ----------------- procedure Timed_Delay ! (Self_ID : Task_ID; ! Time : Duration; ! Mode : ST.Delay_Modes) ! is ! Rel_Time : Duration; ! ! procedure sleep (How_Long : Natural); ! pragma Import (C, sleep, "sleep"); ! begin ! if Mode = Relative then ! Rel_Time := Time; ! else ! Rel_Time := Time - Monotonic_Clock; ! end if; ! ! if Rel_Time > 0.0 then ! sleep (Natural (Rel_Time)); ! end if; end Timed_Delay; --------------------- --- 189,199 ---- ----------------- procedure Timed_Delay ! (Self_ID : Task_ID; ! Time : Duration; ! Mode : ST.Delay_Modes) is begin ! null; end Timed_Delay; --------------------- *************** package body System.Task_Primitives.Oper *** 248,255 **** ------------------ procedure Set_Priority ! (T : Task_ID; ! Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is begin null; --- 228,235 ---- ------------------ procedure Set_Priority ! (T : Task_ID; ! Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is begin null; *************** package body System.Task_Primitives.Oper *** 300,307 **** Wrapper : System.Address; Stack_Size : System.Parameters.Size_Type; Priority : System.Any_Priority; ! Succeeded : out Boolean) ! is begin Succeeded := False; end Create_Task; --- 280,286 ---- Wrapper : System.Address; Stack_Size : System.Parameters.Size_Type; Priority : System.Any_Priority; ! Succeeded : out Boolean) is begin Succeeded := False; end Create_Task; *************** package body System.Task_Primitives.Oper *** 372,394 **** return null; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin null; ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin null; ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 351,373 ---- return null; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin null; ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin null; ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 424,430 **** No_Tasking : Boolean; begin - -- Can't raise an exception because target independent packages try to -- do an Abort_Defer, which gets a memory fault. --- 403,408 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5ntaspri.ads gcc-3.3/gcc/ada/5ntaspri.ads *** gcc-3.2.3/gcc/ada/5ntaspri.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5ntaspri.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5ointerr.adb gcc-3.3/gcc/ada/5ointerr.adb *** gcc-3.2.3/gcc/ada/5ointerr.adb 2001-10-02 13:42:26.000000000 +0000 --- gcc-3.3/gcc/ada/5ointerr.adb 2002-03-14 10:58:35.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2000 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- *************** with Ada.Exceptions; *** 43,48 **** --- 42,49 ---- package body System.Interrupts is + pragma Warnings (Off); -- kill warnings on unreferenced formals + use System.Tasking; ----------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/5omastop.adb gcc-3.3/gcc/ada/5omastop.adb *** gcc-3.2.3/gcc/ada/5omastop.adb 2001-12-16 01:13:28.000000000 +0000 --- gcc-3.3/gcc/ada/5omastop.adb 2002-03-14 10:58:35.000000000 +0000 *************** *** 7,15 **** -- B o d y -- -- (Version for x86) -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 7,14 ---- -- B o d y -- -- (Version for x86) -- -- -- -- -- ! -- Copyright (C) 1999-2002 Ada Core Technologies, 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- -- *************** *** 41,46 **** --- 40,46 ---- with Unchecked_Conversion; with System.Storage_Elements; with System.Machine_Code; use System.Machine_Code; + with System.Memory; package body System.Machine_State_Operations is *************** package body System.Machine_State_Operat *** 54,64 **** function To_Address is new Unchecked_Conversion (Uns32, Address); - function To_Uns32 is new Unchecked_Conversion (Integer, Uns32); - function To_Uns32 is new Unchecked_Conversion (Address, Uns32); - type Uns32_Ptr is access all Uns32; - function To_Uns32_Ptr is new Unchecked_Conversion (Address, Uns32_Ptr); function To_Uns32_Ptr is new Unchecked_Conversion (Uns32, Uns32_Ptr); -- Note: the type Uns32 has an alignment of 4. However, in some cases --- 54,60 ---- *************** package body System.Machine_State_Operat *** 178,186 **** --- 174,185 ---- Op_Immed : constant Bits6 := 2#100000#; Op2_addl_Immed : constant Bits5 := 2#11100#; + pragma Unreferenced (Op2_addl_Immed); + Op2_subl_Immed : constant Bits5 := 2#11101#; type Word_Byte is (Word, Byte); + pragma Unreferenced (Byte); type Ins_addl_subl_byte is record Op : Bits6; -- Set to Op_Immed *************** package body System.Machine_State_Operat *** 329,342 **** ---------------------------- function Allocate_Machine_State return Machine_State is - use System.Storage_Elements; - function Gnat_Malloc (Size : Storage_Offset) return Machine_State; - pragma Import (C, Gnat_Malloc, "__gnat_malloc"); - begin ! return Gnat_Malloc (MState'Max_Size_In_Storage_Elements); end Allocate_Machine_State; -------------------- --- 328,338 ---- ---------------------------- function Allocate_Machine_State return Machine_State is use System.Storage_Elements; begin ! return Machine_State ! (Memory.Alloc (MState'Max_Size_In_Storage_Elements)); end Allocate_Machine_State; -------------------- *************** package body System.Machine_State_Operat *** 445,455 **** ------------------------ procedure Free_Machine_State (M : in out Machine_State) is - procedure Gnat_Free (M : in Machine_State); - pragma Import (C, Gnat_Free, "__gnat_free"); - begin ! Gnat_Free (M); M := Machine_State (Null_Address); end Free_Machine_State; --- 441,448 ---- ------------------------ procedure Free_Machine_State (M : in out Machine_State) is begin ! Memory.Free (Address (M)); M := Machine_State (Null_Address); end Free_Machine_State; *************** package body System.Machine_State_Operat *** 584,590 **** procedure Set_Signal_Machine_State (M : Machine_State; ! Context : System.Address) is begin null; end Set_Signal_Machine_State; --- 577,587 ---- procedure Set_Signal_Machine_State (M : Machine_State; ! Context : System.Address) ! is ! pragma Warnings (Off, M); ! pragma Warnings (Off, Context); ! begin null; end Set_Signal_Machine_State; diff -Nrc3pad gcc-3.2.3/gcc/ada/5oosinte.adb gcc-3.3/gcc/ada/5oosinte.adb *** gcc-3.2.3/gcc/ada/5oosinte.adb 2001-12-16 01:13:28.000000000 +0000 --- gcc-3.3/gcc/ada/5oosinte.adb 2002-03-14 10:58:35.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4 $ -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2002 Florida State University -- -- -- -- GNARL 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- -- *************** pragma Polling (Off); *** 40,46 **** -- Turn off polling, we do not want ATC polling to take place during -- tasking operations. It causes infinite loops and other problems. - with Interfaces.C.Strings; with Interfaces.OS2Lib.Errors; with Interfaces.OS2Lib.Synchronization; --- 39,44 ---- *************** package body System.OS_Interface is *** 51,83 **** use Interfaces.OS2Lib.Synchronization; use Interfaces.OS2Lib.Errors; - ------------------ - -- Timer (spec) -- - ------------------ - - -- Although the OS uses a 32-bit integer representing milliseconds - -- as timer value that doesn't work for us since 32 bits are not - -- enough for absolute timing. Also it is useful to use better - -- intermediate precision when adding/subtracting timing intervals. - -- So we use the standard Ada Duration type which is implemented using - -- microseconds. - - -- Shouldn't the timer be moved to a separate package ??? - - type Timer is record - Handle : aliased HTIMER := NULLHANDLE; - Event : aliased HEV := NULLHANDLE; - end record; - - procedure Initialize (T : out Timer); - procedure Finalize (T : in out Timer); - procedure Wait (T : in out Timer); - procedure Reset (T : in out Timer); - - procedure Set_Timer_For (T : in out Timer; Period : in Duration); - procedure Set_Timer_At (T : in out Timer; Time : in Duration); - -- Add a hook to locate the Epoch, for use with Calendar???? - ----------- -- Yield -- ----------- --- 49,54 ---- *************** package body System.OS_Interface is *** 147,256 **** return Tick_Count * Tick_Duration; end Clock; - ---------------------- - -- Initialize Timer -- - ---------------------- - - procedure Initialize (T : out Timer) is - begin - pragma Assert - (T.Handle = NULLHANDLE, "GNULLI---Timer already initialized"); - - Must_Not_Fail (DosCreateEventSem - (pszName => Interfaces.C.Strings.Null_Ptr, - f_phev => T.Event'Unchecked_Access, - flAttr => DC_SEM_SHARED, - fState => False32)); - end Initialize; - - ------------------- - -- Set_Timer_For -- - ------------------- - - procedure Set_Timer_For - (T : in out Timer; - Period : in Duration) - is - Rel_Time : Duration_In_Millisec := - Duration_In_Millisec (Period * 1_000.0); - - begin - pragma Assert - (T.Event /= NULLHANDLE, "GNULLI---Timer not initialized"); - pragma Assert - (T.Handle = NULLHANDLE, "GNULLI---Timer already in use"); - - Must_Not_Fail (DosAsyncTimer - (msec => ULONG (Rel_Time), - F_hsem => HSEM (T.Event), - F_phtimer => T.Handle'Unchecked_Access)); - end Set_Timer_For; - - ------------------ - -- Set_Timer_At -- - ------------------ - - -- Note that the timer is started in a critical section to prevent the - -- race condition when absolute time is converted to time relative to - -- current time. T.Event will be posted when the Time has passed - - procedure Set_Timer_At - (T : in out Timer; - Time : in Duration) - is - Relative_Time : Duration; - - begin - Must_Not_Fail (DosEnterCritSec); - - begin - Relative_Time := Time - Clock; - if Relative_Time > 0.0 then - Set_Timer_For (T, Period => Time - Clock); - else - Sem_Must_Not_Fail (DosPostEventSem (T.Event)); - end if; - end; - - Must_Not_Fail (DosExitCritSec); - end Set_Timer_At; - - ---------- - -- Wait -- - ---------- - - procedure Wait (T : in out Timer) is - begin - Sem_Must_Not_Fail (DosWaitEventSem (T.Event, SEM_INDEFINITE_WAIT)); - T.Handle := NULLHANDLE; - end Wait; - - ----------- - -- Reset -- - ----------- - - procedure Reset (T : in out Timer) is - Dummy_Count : aliased ULONG; - - begin - if T.Handle /= NULLHANDLE then - Must_Not_Fail (DosStopTimer (T.Handle)); - T.Handle := NULLHANDLE; - end if; - - Sem_Must_Not_Fail - (DosResetEventSem (T.Event, Dummy_Count'Unchecked_Access)); - end Reset; - - -------------- - -- Finalize -- - -------------- - - procedure Finalize (T : in out Timer) is - begin - Reset (T); - Must_Not_Fail (DosCloseEventSem (T.Event)); - T.Event := NULLHANDLE; - end Finalize; - end System.OS_Interface; --- 118,121 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5oosinte.ads gcc-3.3/gcc/ada/5oosinte.ads *** gcc-3.2.3/gcc/ada/5oosinte.ads 2001-10-02 13:42:27.000000000 +0000 --- gcc-3.3/gcc/ada/5oosinte.ads 2002-03-14 10:58:35.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5oosprim.adb gcc-3.3/gcc/ada/5oosprim.adb *** gcc-3.2.3/gcc/ada/5oosprim.adb 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5oosprim.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5oparame.adb gcc-3.3/gcc/ada/5oparame.adb *** gcc-3.2.3/gcc/ada/5oparame.adb 2002-05-07 08:22:03.000000000 +0000 --- gcc-3.3/gcc/ada/5oparame.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1997-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5osystem.ads gcc-3.3/gcc/ada/5osystem.ads *** gcc-3.2.3/gcc/ada/5osystem.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5osystem.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (OS/2 Version) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (OS/2 Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 88,119 **** -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := ! Bit_Order'Val (Standard'Default_Bit_Order); -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 87,104 ---- -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := Low_Order_First; -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 131,138 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; *************** private *** 146,151 **** Use_Ada_Main_Program_Name : constant Boolean := False; ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; ! Front_End_ZCX_Support : constant Boolean := False; end System; --- 134,139 ---- Use_Ada_Main_Program_Name : constant Boolean := False; ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; ! Front_End_ZCX_Support : constant Boolean := True; end System; diff -Nrc3pad gcc-3.2.3/gcc/ada/5otaprop.adb gcc-3.3/gcc/ada/5otaprop.adb *** gcc-3.2.3/gcc/ada/5otaprop.adb 2001-12-16 01:13:28.000000000 +0000 --- gcc-3.3/gcc/ada/5otaprop.adb 2002-03-14 10:58:36.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** package body System.Task_Primitives.Oper *** 91,119 **** use Interfaces.OS2Lib.Errors; use Interfaces.OS2Lib.Threads; use Interfaces.OS2Lib.Synchronization; use System.Tasking.Debug; use System.Tasking; use System.OS_Interface; use Interfaces.C; use System.OS_Primitives; ! ---------------------- ! -- Local Constants -- ! ---------------------- Max_Locks_Per_Task : constant := 100; Suppress_Owner_Check : constant Boolean := False; ! ------------------ ! -- Local Types -- ! ------------------ - type Microseconds is new IC.long; subtype Lock_Range is Integer range 0 .. Max_Locks_Per_Task; ! ------------------ ! -- Local Data -- ! ------------------ -- The OS/2 DosAllocThreadLocalMemory API is used to allocate our TCB_Ptr. --- 89,117 ---- use Interfaces.OS2Lib.Errors; use Interfaces.OS2Lib.Threads; use Interfaces.OS2Lib.Synchronization; + use System.Parameters; use System.Tasking.Debug; use System.Tasking; use System.OS_Interface; use Interfaces.C; use System.OS_Primitives; ! --------------------- ! -- Local Constants -- ! --------------------- Max_Locks_Per_Task : constant := 100; Suppress_Owner_Check : constant Boolean := False; ! ----------------- ! -- Local Types -- ! ----------------- subtype Lock_Range is Integer range 0 .. Max_Locks_Per_Task; ! ----------------- ! -- Local Data -- ! ----------------- -- The OS/2 DosAllocThreadLocalMemory API is used to allocate our TCB_Ptr. *************** package body System.Task_Primitives.Oper *** 138,145 **** type PPTLD is access all Access_Thread_Local_Data; ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. --- 136,145 ---- type PPTLD is access all Access_Thread_Local_Data; ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. *************** package body System.Task_Primitives.Oper *** 192,206 **** -- handler or to change the execution context of the thread. -- So asynchonous transfer of control is not supported. ! ------------------- ! -- Stack_Guard -- ! ------------------- -- The underlying thread system sets a guard page at the -- bottom of a thread stack, so nothing is needed. -- ??? Check the comment above procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is begin null; end Stack_Guard; --- 192,209 ---- -- handler or to change the execution context of the thread. -- So asynchonous transfer of control is not supported. ! ----------------- ! -- Stack_Guard -- ! ----------------- -- The underlying thread system sets a guard page at the -- bottom of a thread stack, so nothing is needed. -- ??? Check the comment above procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is + pragma Warnings (Off, T); + pragma Warnings (Off, On); + begin null; end Stack_Guard; *************** package body System.Task_Primitives.Oper *** 220,226 **** function Self return Task_ID is Self_ID : Task_ID renames Thread_Local_Data_Ptr.Self_ID; - begin -- Check that the thread local data has been initialized. --- 223,228 ---- *************** package body System.Task_Primitives.Oper *** 252,257 **** --- 254,261 ---- end Initialize_Lock; procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is + pragma Warnings (Off, Level); + begin if DosCreateMutexSem (ICS.Null_Ptr, L.Mutex'Unchecked_Access, 0, False32) /= NO_ERROR *************** package body System.Task_Primitives.Oper *** 312,355 **** L.Owner_ID := Self_ID.all'Address; end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is ! Self_ID : constant Task_ID := Thread_Local_Data_Ptr.Self_ID; ! Old_Priority : constant Any_Priority := ! Self_ID.Common.LL.Current_Priority; begin ! -- Increase priority before getting the lock ! -- to prevent priority inversion ! Thread_Local_Data_Ptr.Lock_Prio_Level := ! Thread_Local_Data_Ptr.Lock_Prio_Level + 1; ! if L.Priority > Old_Priority then ! Set_Temporary_Priority (Self_ID, L.Priority); ! end if; ! -- Request the lock and then update the lock owner data ! Must_Not_Fail (DosRequestMutexSem (L.Mutex, SEM_INDEFINITE_WAIT)); ! L.Owner_Priority := Old_Priority; ! L.Owner_ID := Self_ID.all'Address; end Write_Lock; procedure Write_Lock (T : Task_ID) is begin ! -- Request the lock and then update the lock owner data ! Must_Not_Fail ! (DosRequestMutexSem (T.Common.LL.L.Mutex, SEM_INDEFINITE_WAIT)); ! T.Common.LL.L.Owner_ID := Null_Address; end Write_Lock; --------------- -- Read_Lock -- --------------- ! procedure Read_Lock (L : access Lock; Ceiling_Violation : out Boolean) ! renames Write_Lock; ------------ -- Unlock -- --- 316,367 ---- L.Owner_ID := Self_ID.all'Address; end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is ! Self_ID : Task_ID; ! Old_Priority : Any_Priority; begin ! if not Single_Lock or else Global_Lock then ! Self_ID := Thread_Local_Data_Ptr.Self_ID; ! Old_Priority := Self_ID.Common.LL.Current_Priority; ! -- Increase priority before getting the lock ! -- to prevent priority inversion ! Thread_Local_Data_Ptr.Lock_Prio_Level := ! Thread_Local_Data_Ptr.Lock_Prio_Level + 1; ! if L.Priority > Old_Priority then ! Set_Temporary_Priority (Self_ID, L.Priority); ! end if; ! -- Request the lock and then update the lock owner data ! ! Must_Not_Fail (DosRequestMutexSem (L.Mutex, SEM_INDEFINITE_WAIT)); ! L.Owner_Priority := Old_Priority; ! L.Owner_ID := Self_ID.all'Address; ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is begin ! if not Single_Lock then ! -- Request the lock and then update the lock owner data ! Must_Not_Fail ! (DosRequestMutexSem (T.Common.LL.L.Mutex, SEM_INDEFINITE_WAIT)); ! T.Common.LL.L.Owner_ID := Null_Address; ! end if; end Write_Lock; --------------- -- Read_Lock -- --------------- ! procedure Read_Lock ! (L : access Lock; Ceiling_Violation : out Boolean) renames Write_Lock; ------------ -- Unlock -- *************** package body System.Task_Primitives.Oper *** 383,435 **** end if; end Unlock; ! procedure Unlock (L : access RTS_Lock) is ! Self_ID : constant Task_ID := Thread_Local_Data_Ptr.Self_ID; ! Old_Priority : constant Any_Priority := L.Owner_Priority; begin ! -- Check that this task holds the lock ! pragma Assert (Suppress_Owner_Check ! or else L.Owner_ID = Self_ID.all'Address); ! -- Upate the owner data ! L.Owner_ID := Null_Address; ! -- Do the actual unlocking. No more references ! -- to owner data of L after this point. ! Must_Not_Fail (DosReleaseMutexSem (L.Mutex)); ! -- Reset priority after unlocking to avoid priority inversion ! Thread_Local_Data_Ptr.Lock_Prio_Level := ! Thread_Local_Data_Ptr.Lock_Prio_Level - 1; ! if L.Priority /= Old_Priority then ! Set_Temporary_Priority (Self_ID, Old_Priority); end if; end Unlock; procedure Unlock (T : Task_ID) is begin ! -- Check the owner data ! pragma Assert (Suppress_Owner_Check ! or else T.Common.LL.L.Owner_ID = Null_Address); ! -- Do the actual unlocking. No more references ! -- to owner data of T.Common.LL.L after this point. ! Must_Not_Fail (DosReleaseMutexSem (T.Common.LL.L.Mutex)); end Unlock; ----------- -- Sleep -- ----------- ! procedure Sleep (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) is Count : aliased ULONG; -- Used to store dummy result begin --- 395,457 ---- end if; end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is ! Self_ID : Task_ID; ! Old_Priority : Any_Priority; begin ! if not Single_Lock or else Global_Lock then ! Self_ID := Thread_Local_Data_Ptr.Self_ID; ! Old_Priority := L.Owner_Priority; ! -- Check that this task holds the lock ! pragma Assert (Suppress_Owner_Check ! or else L.Owner_ID = Self_ID.all'Address); ! -- Upate the owner data ! L.Owner_ID := Null_Address; ! -- Do the actual unlocking. No more references ! -- to owner data of L after this point. ! Must_Not_Fail (DosReleaseMutexSem (L.Mutex)); ! -- Reset priority after unlocking to avoid priority inversion ! Thread_Local_Data_Ptr.Lock_Prio_Level := ! Thread_Local_Data_Ptr.Lock_Prio_Level - 1; ! if L.Priority /= Old_Priority then ! Set_Temporary_Priority (Self_ID, Old_Priority); ! end if; end if; end Unlock; procedure Unlock (T : Task_ID) is begin ! if not Single_Lock then ! -- Check the owner data ! pragma Assert (Suppress_Owner_Check ! or else T.Common.LL.L.Owner_ID = Null_Address); ! -- Do the actual unlocking. No more references ! -- to owner data of T.Common.LL.L after this point. ! Must_Not_Fail (DosReleaseMutexSem (T.Common.LL.L.Mutex)); ! end if; end Unlock; ----------- -- Sleep -- ----------- ! procedure Sleep ! (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) ! is ! pragma Warnings (Off, Reason); ! Count : aliased ULONG; -- Used to store dummy result begin *************** package body System.Task_Primitives.Oper *** 437,443 **** Sem_Must_Not_Fail (DosResetEventSem (Self_ID.Common.LL.CV, Count'Unchecked_Access)); ! Unlock (Self_ID); -- No problem if we are interrupted here. -- If the condition is signaled, DosWaitEventSem will simply not block. --- 459,470 ---- Sem_Must_Not_Fail (DosResetEventSem (Self_ID.Common.LL.CV, Count'Unchecked_Access)); ! ! if Single_Lock then ! Unlock_RTS; ! else ! Unlock (Self_ID); ! end if; -- No problem if we are interrupted here. -- If the condition is signaled, DosWaitEventSem will simply not block. *************** package body System.Task_Primitives.Oper *** 447,453 **** -- Since L was previously accquired, lock operation should not fail. ! Write_Lock (Self_ID); end Sleep; ----------------- --- 474,484 ---- -- Since L was previously accquired, lock operation should not fail. ! if Single_Lock then ! Lock_RTS; ! else ! Write_Lock (Self_ID); ! end if; end Sleep; ----------------- *************** package body System.Task_Primitives.Oper *** 472,477 **** --- 503,510 ---- Timedout : out Boolean; Yielded : out Boolean) is + pragma Warnings (Off, Reason); + Check_Time : constant Duration := OSP.Monotonic_Clock; Rel_Time : Duration; Abs_Time : Duration; *************** package body System.Task_Primitives.Oper *** 485,491 **** Sem_Must_Not_Fail (DosResetEventSem (Self_ID.Common.LL.CV, Count'Unchecked_Access)); ! Unlock (Self_ID); Timedout := True; Yielded := False; --- 518,529 ---- Sem_Must_Not_Fail (DosResetEventSem (Self_ID.Common.LL.CV, Count'Unchecked_Access)); ! ! if Single_Lock then ! Unlock_RTS; ! else ! Unlock (Self_ID); ! end if; Timedout := True; Yielded := False; *************** package body System.Task_Primitives.Oper *** 529,535 **** -- Ensure post-condition ! Write_Lock (Self_ID); if Timedout then Sem_Must_Not_Fail (DosPostEventSem (Self_ID.Common.LL.CV)); --- 567,577 ---- -- Ensure post-condition ! if Single_Lock then ! Lock_RTS; ! else ! Write_Lock (Self_ID); ! end if; if Timedout then Sem_Must_Not_Fail (DosPostEventSem (Self_ID.Common.LL.CV)); *************** package body System.Task_Primitives.Oper *** 550,556 **** Abs_Time : Duration; Timedout : Boolean := True; Time_Out : ULONG; ! Result : APIRET; Count : aliased ULONG; -- Used to store dummy result begin --- 592,598 ---- Abs_Time : Duration; Timedout : Boolean := True; Time_Out : ULONG; ! Result : APIRET; Count : aliased ULONG; -- Used to store dummy result begin *************** package body System.Task_Primitives.Oper *** 559,572 **** -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; ! Write_Lock (Self_ID); -- Must reset Cond BEFORE Self_ID is unlocked. Sem_Must_Not_Fail (DosResetEventSem (Self_ID.Common.LL.CV, Count'Unchecked_Access)); ! Unlock (Self_ID); if Mode = Relative then Rel_Time := Time; --- 601,624 ---- -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; ! ! if Single_Lock then ! Lock_RTS; ! else ! Write_Lock (Self_ID); ! end if; -- Must reset Cond BEFORE Self_ID is unlocked. Sem_Must_Not_Fail (DosResetEventSem (Self_ID.Common.LL.CV, Count'Unchecked_Access)); ! ! if Single_Lock then ! Unlock_RTS; ! else ! Unlock (Self_ID); ! end if; if Mode = Relative then Rel_Time := Time; *************** package body System.Task_Primitives.Oper *** 578,583 **** --- 630,636 ---- if Rel_Time > 0.0 then Self_ID.Common.State := Delay_Sleep; + loop if Self_ID.Pending_Priority_Change then Self_ID.Pending_Priority_Change := False; *************** package body System.Task_Primitives.Oper *** 599,613 **** Timedout := Result = ERROR_TIMEOUT; end if; ! -- Ensure post-condition ! ! Write_Lock (Self_ID); if Timedout then Sem_Must_Not_Fail (DosPostEventSem (Self_ID.Common.LL.CV)); end if; ! Unlock (Self_ID); System.OS_Interface.Yield; SSL.Abort_Undefer.all; end Timed_Delay; --- 652,673 ---- Timedout := Result = ERROR_TIMEOUT; end if; ! if Single_Lock then ! Lock_RTS; ! else ! Write_Lock (Self_ID); ! end if; if Timedout then Sem_Must_Not_Fail (DosPostEventSem (Self_ID.Common.LL.CV)); end if; ! if Single_Lock then ! Unlock_RTS; ! else ! Unlock (Self_ID); ! end if; ! System.OS_Interface.Yield; SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 617,622 **** --- 677,683 ---- ------------ procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is + pragma Warnings (Off, Reason); begin Sem_Must_Not_Fail (DosPostEventSem (T.Common.LL.CV)); end Wakeup; *************** package body System.Task_Primitives.Oper *** 659,665 **** end if; if Delta_Priority /= 0 then - -- ??? There is a race-condition here -- The TCB is updated before the system call to make -- pre-emption in the critical section less likely. --- 720,725 ---- *************** package body System.Task_Primitives.Oper *** 679,687 **** ------------------ procedure Set_Priority ! (T : Task_ID; ! Prio : System.Any_Priority; ! Loss_Of_Inheritance : Boolean := False) is begin T.Common.Current_Priority := Prio; Set_Temporary_Priority (T, Prio); --- 739,750 ---- ------------------ procedure Set_Priority ! (T : Task_ID; ! Prio : System.Any_Priority; ! Loss_Of_Inheritance : Boolean := False) ! is ! pragma Warnings (Off, Loss_Of_Inheritance); ! begin T.Common.Current_Priority := Prio; Set_Temporary_Priority (T, Prio); *************** package body System.Task_Primitives.Oper *** 702,722 **** procedure Enter_Task (Self_ID : Task_ID) is begin - -- Initialize thread local data. Must be done first. Thread_Local_Data_Ptr.Self_ID := Self_ID; Thread_Local_Data_Ptr.Lock_Prio_Level := 0; ! Lock_All_Tasks_List; ! for I in Known_Tasks'Range loop ! if Known_Tasks (I) = null then ! Known_Tasks (I) := Self_ID; ! Self_ID.Known_Tasks_Index := I; exit; end if; end loop; ! Unlock_All_Tasks_List; -- For OS/2, we can set Self_ID.Common.LL.Thread in -- Create_Task, since the thread is created suspended. --- 765,786 ---- procedure Enter_Task (Self_ID : Task_ID) is begin -- Initialize thread local data. Must be done first. Thread_Local_Data_Ptr.Self_ID := Self_ID; Thread_Local_Data_Ptr.Lock_Prio_Level := 0; ! Lock_RTS; ! ! for J in Known_Tasks'Range loop ! if Known_Tasks (J) = null then ! Known_Tasks (J) := Self_ID; ! Self_ID.Known_Tasks_Index := J; exit; end if; end loop; ! ! Unlock_RTS; -- For OS/2, we can set Self_ID.Common.LL.Thread in -- Create_Task, since the thread is created suspended. *************** package body System.Task_Primitives.Oper *** 725,731 **** -- has been initialized. -- .... Do we need to do anything with signals for OS/2 ??? - null; end Enter_Task; -------------- --- 789,794 ---- *************** package body System.Task_Primitives.Oper *** 746,753 **** if DosCreateEventSem (ICS.Null_Ptr, Self_ID.Common.LL.CV'Unchecked_Access, 0, True32) = NO_ERROR then ! if DosCreateMutexSem (ICS.Null_Ptr, ! Self_ID.Common.LL.L.Mutex'Unchecked_Access, 0, False32) /= NO_ERROR then Succeeded := False; Must_Not_Fail (DosCloseEventSem (Self_ID.Common.LL.CV)); --- 809,820 ---- if DosCreateEventSem (ICS.Null_Ptr, Self_ID.Common.LL.CV'Unchecked_Access, 0, True32) = NO_ERROR then ! if not Single_Lock ! and then DosCreateMutexSem ! (ICS.Null_Ptr, ! Self_ID.Common.LL.L.Mutex'Unchecked_Access, ! 0, ! False32) /= NO_ERROR then Succeeded := False; Must_Not_Fail (DosCloseEventSem (Self_ID.Common.LL.CV)); *************** package body System.Task_Primitives.Oper *** 755,762 **** Succeeded := True; end if; - pragma Assert (Self_ID.Common.LL.L.Mutex /= 0); - -- We now want to do the equivalent of: -- Initialize_Lock --- 822,827 ---- *************** package body System.Task_Primitives.Oper *** 774,780 **** Succeeded := False; end if; ! -- Note: at one time we had anb exception handler here, whose code -- was as follows: -- exception --- 839,845 ---- Succeeded := False; end if; ! -- Note: at one time we had an exception handler here, whose code -- was as follows: -- exception *************** package body System.Task_Primitives.Oper *** 789,795 **** -- result in messing with Jmpbuf values too early. If and when we get -- switched entirely to the new zero-cost exception scheme, we could -- put this handler back in! - end Initialize_TCB; ----------------- --- 854,859 ---- *************** package body System.Task_Primitives.Oper *** 889,900 **** procedure Free is new Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin Must_Not_Fail (DosCloseEventSem (T.Common.LL.CV)); ! Finalize_Lock (T.Common.LL.L'Unchecked_Access); if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; Free (Tmp); end Finalize_TCB; --- 953,970 ---- procedure Free is new Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); + begin Must_Not_Fail (DosCloseEventSem (T.Common.LL.CV)); ! ! if not Single_Lock then ! Finalize_Lock (T.Common.LL.L'Unchecked_Access); ! end if; ! if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; + Free (Tmp); end Finalize_TCB; *************** package body System.Task_Primitives.Oper *** 916,921 **** --- 986,993 ---- ---------------- procedure Abort_Task (T : Task_ID) is + pragma Warnings (Off, T); + begin null; *************** package body System.Task_Primitives.Oper *** 956,978 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 1028,1050 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 1010,1020 **** procedure Initialize (Environment_Task : Task_ID) is Succeeded : Boolean; - begin Environment_Task_ID := Environment_Task; ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); -- Initialize the lock used to synchronize chain of all ATCBs. -- Set ID of environment task. --- 1082,1091 ---- procedure Initialize (Environment_Task : Task_ID) is Succeeded : Boolean; begin Environment_Task_ID := Environment_Task; ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); -- Initialize the lock used to synchronize chain of all ATCBs. -- Set ID of environment task. *************** package body System.Task_Primitives.Oper *** 1047,1053 **** -- Insert here any other special -- initialization needed for the environment task. - end Initialize; begin --- 1118,1123 ---- *************** begin *** 1062,1066 **** Thread_Local_Data_Ptr.Self_ID := null; Thread_Local_Data_Ptr.Lock_Prio_Level := 0; - end System.Task_Primitives.Operations; --- 1132,1135 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5otaspri.ads gcc-3.3/gcc/ada/5otaspri.ads *** gcc-3.2.3/gcc/ada/5otaspri.ads 2001-10-02 13:42:27.000000000 +0000 --- gcc-3.3/gcc/ada/5otaspri.ads 2002-03-14 10:58:36.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-1999 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- *************** package System.Task_Primitives is *** 69,81 **** -- private ! type Lock is ! record ! Mutex : aliased Interfaces.OS2Lib.Synchronization.HMTX; ! Priority : Integer; ! Owner_Priority : Integer; ! Owner_ID : Address; ! end record; type RTS_Lock is new Lock; --- 68,79 ---- -- private ! type Lock is record ! Mutex : aliased Interfaces.OS2Lib.Synchronization.HMTX; ! Priority : Integer; ! Owner_Priority : Integer; ! Owner_ID : Address; ! end record; type RTS_Lock is new Lock; diff -Nrc3pad gcc-3.2.3/gcc/ada/5posinte.ads gcc-3.3/gcc/ada/5posinte.ads *** gcc-3.2.3/gcc/ada/5posinte.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5posinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5posprim.adb gcc-3.3/gcc/ada/5posprim.adb *** gcc-3.2.3/gcc/ada/5posprim.adb 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5posprim.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5pvxwork.ads gcc-3.3/gcc/ada/5pvxwork.ads *** gcc-3.2.3/gcc/ada/5pvxwork.ads 2002-05-07 08:22:03.000000000 +0000 --- gcc-3.3/gcc/ada/5pvxwork.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1998 - 2001 Free Software Foundation -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 33,40 **** -- -- ------------------------------------------------------------------------------ ! -- This is the PPC VxWorks 5.x version of this package. A different version ! -- is used for VxWorks 6.0 with Interfaces.C; --- 32,38 ---- -- -- ------------------------------------------------------------------------------ ! -- This is the PPC VxWorks version of this package. with Interfaces.C; *************** package System.VxWorks is *** 43,102 **** package IC renames Interfaces.C; ! -- Define enough of a Wind Task Control Block in order to ! -- obtain the inherited priority. When porting this to ! -- different versions of VxWorks (this is based on 5.3[.1]), ! -- be sure to look at the definition for WIND_TCB located ! -- in $WIND_BASE/target/h/taskLib.h ! ! type Wind_Fill_1 is array (0 .. 16#3F#) of IC.unsigned_char; ! type Wind_Fill_2 is array (16#48# .. 16#107#) of IC.unsigned_char; ! ! type Wind_TCB is record ! Fill_1 : Wind_Fill_1; -- 0x00 - 0x3f ! Priority : IC.int; -- 0x40 - 0x43, current (inherited) priority ! Normal_Priority : IC.int; -- 0x44 - 0x47, base priority ! Fill_2 : Wind_Fill_2; -- 0x48 - 0x107 ! spare1 : Address; -- 0x108 - 0x10b ! spare2 : Address; -- 0x10c - 0x10f ! spare3 : Address; -- 0x110 - 0x113 ! spare4 : Address; -- 0x114 - 0x117 ! end record; ! type Wind_TCB_Ptr is access Wind_TCB; ! ! -- Floating point context record. PPC version FP_NUM_DREGS : constant := 32; type Fpr_Array is array (1 .. FP_NUM_DREGS) of IC.double; type FP_CONTEXT is record ! fpr : Fpr_Array; fpcsr : IC.int; ! pad : IC.int; end record; pragma Convention (C, FP_CONTEXT); Num_HW_Interrupts : constant := 256; - -- VxWorks 5.3 and 5.4 version - type TASK_DESC is record - td_id : IC.int; -- task id - td_name : Address; -- name of task - td_priority : IC.int; -- task priority - td_status : IC.int; -- task status - td_options : IC.int; -- task option bits (see below) - td_entry : Address; -- original entry point of task - td_sp : Address; -- saved stack pointer - td_pStackBase : Address; -- the bottom of the stack - td_pStackLimit : Address; -- the effective end of the stack - td_pStackEnd : Address; -- the actual end of the stack - td_stackSize : IC.int; -- size of stack in bytes - td_stackCurrent : IC.int; -- current stack usage in bytes - td_stackHigh : IC.int; -- maximum stack usage in bytes - td_stackMargin : IC.int; -- current stack margin in bytes - td_errorStatus : IC.int; -- most recent task error status - td_delay : IC.int; -- delay/timeout ticks - end record; - pragma Convention (C, TASK_DESC); - end System.VxWorks; --- 41,58 ---- package IC renames Interfaces.C; ! -- Floating point context record. PPC version FP_NUM_DREGS : constant := 32; type Fpr_Array is array (1 .. FP_NUM_DREGS) of IC.double; type FP_CONTEXT is record ! fpr : Fpr_Array; fpcsr : IC.int; ! pad : IC.int; end record; pragma Convention (C, FP_CONTEXT); Num_HW_Interrupts : constant := 256; end System.VxWorks; diff -Nrc3pad gcc-3.2.3/gcc/ada/5qosinte.adb gcc-3.3/gcc/ada/5qosinte.adb *** gcc-3.2.3/gcc/ada/5qosinte.adb 2001-10-04 17:50:42.000000000 +0000 --- gcc-3.3/gcc/ada/5qosinte.adb 2002-03-14 10:58:37.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5qosinte.ads gcc-3.3/gcc/ada/5qosinte.ads *** gcc-3.2.3/gcc/ada/5qosinte.ads 2001-10-04 17:50:42.000000000 +0000 --- gcc-3.3/gcc/ada/5qosinte.ads 2002-03-14 10:58:37.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5qparame.ads gcc-3.3/gcc/ada/5qparame.ads *** gcc-3.2.3/gcc/ada/5qparame.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5qparame.ads 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,136 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- S Y S T E M . P A R A M E T E R S -- - -- -- - -- S p e c -- - -- -- - -- $Revision: 1.2.12.1 $ - -- -- - -- Copyright (C) 1992-2001 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- 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. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - -- This is the RT-GNU/Linux version. - -- Blank line intentional so that it lines up exactly with default. - - -- This package defines some system dependent parameters for GNAT. These - -- are values that are referenced by the runtime library and are therefore - -- relevant to the target machine. - - -- The parameters whose value is defined in the spec are not generally - -- expected to be changed. If they are changed, it will be necessary to - -- recompile the run-time library. - - -- The parameters which are defined by functions can be changed by modifying - -- the body of System.Parameters in file s-parame.adb. A change to this body - -- requires only rebinding and relinking of the application. - - -- Note: do not introduce any pragma Inline statements into this unit, since - -- otherwise the relinking and rebinding capability would be deactivated. - - package System.Parameters is - pragma Pure (Parameters); - - --------------------------------------- - -- Task And Stack Allocation Control -- - --------------------------------------- - - type Task_Storage_Size is new Integer; - -- Type used in tasking units for task storage size - - type Size_Type is new Task_Storage_Size; - -- Type used to provide task storage size to runtime - - Unspecified_Size : constant Size_Type := Size_Type'First; - -- Value used to indicate that no size type is set - - subtype Ratio is Size_Type range -1 .. 100; - Dynamic : constant Size_Type := 10; - -- The secondary stack ratio is a constant between 0 and 100 which - -- determines the percentage of the allocated task stack that is - -- used by the secondary stack (the rest being the primary stack). - -- The special value of minus one indicates that the secondary - -- stack is to be allocated from the heap instead. - - Sec_Stack_Ratio : constant Ratio := Dynamic; - -- This constant defines the handling of the secondary stack - - Sec_Stack_Dynamic : constant Boolean := Sec_Stack_Ratio = Dynamic; - -- Convenient Boolean for testing for dynamic secondary stack - - function Default_Stack_Size return Size_Type; - -- Default task stack size used if none is specified - - function Minimum_Stack_Size return Size_Type; - -- Minimum task stack size permitted - - function Adjust_Storage_Size (Size : Size_Type) return Size_Type; - -- Given the storage size stored in the TCB, return the Storage_Size - -- value required by the RM for the Storage_Size attribute. The - -- required adjustment is as follows: - -- - -- when Size = Unspecified_Size, return Default_Stack_Size - -- when Size < Minimum_Stack_Size, return Minimum_Stack_Size - -- otherwise return given Size - - Stack_Grows_Down : constant Boolean := True; - -- This constant indicates whether the stack grows up (False) or - -- down (True) in memory as functions are called. It is used for - -- proper implementation of the stack overflow check. - - ---------------------------------------------- - -- Characteristics of types in Interfaces.C -- - ---------------------------------------------- - - long_bits : constant := Long_Integer'Size; - -- Number of bits in type long and unsigned_long. The normal convention - -- is that this is the same as type Long_Integer, but this is not true - -- of all targets. For example, in OpenVMS long /= Long_Integer. - - ---------------------------------------------- - -- Behavior of Pragma Finalize_Storage_Only -- - ---------------------------------------------- - - -- Garbage_Collected is a Boolean constant whose value indicates the - -- effect of the pragma Finalize_Storage_Entry on a controlled type. - - -- Garbage_Collected = False - - -- The system releases all storage on program termination only, - -- but not other garbage collection occurs, so finalization calls - -- are ommitted only for outer level onjects can be omitted if - -- pragma Finalize_Storage_Only is used. - - -- Garbage_Collected = True - - -- The system provides full garbage collection, so it is never - -- necessary to release storage for controlled objects for which - -- a pragma Finalize_Storage_Only is used. - - Garbage_Collected : constant Boolean := False; - -- The storage mode for this system (release on program exit) - - end System.Parameters; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5qstache.adb gcc-3.3/gcc/ada/5qstache.adb *** gcc-3.2.3/gcc/ada/5qstache.adb 2001-10-02 13:42:27.000000000 +0000 --- gcc-3.3/gcc/ada/5qstache.adb 2002-03-14 10:58:37.000000000 +0000 *************** *** 7,13 **** -- B o d y -- -- (Dummy version) -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000 Ada Core Technologies, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5qtaprop.adb gcc-3.3/gcc/ada/5qtaprop.adb *** gcc-3.2.3/gcc/ada/5qtaprop.adb 2001-10-04 17:50:42.000000000 +0000 --- gcc-3.3/gcc/ada/5qtaprop.adb 2002-03-14 10:58:37.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** package body System.Task_Primitives.Oper *** 185,192 **** -- In the current implementation, this is the task assigned permanently -- as the regular GNU/Linux kernel. ! All_Tasks_L : aliased RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). -- The followings are internal configuration constants needed. Next_Serial_Number : Task_Serial_Number := 100; --- 183,192 ---- -- In the current implementation, this is the task assigned permanently -- as the regular GNU/Linux kernel. ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List -- The followings are internal configuration constants needed. Next_Serial_Number : Task_Serial_Number := 100; *************** package body System.Task_Primitives.Oper *** 722,733 **** -- Write_Lock -- ---------------- ! procedure Write_Lock ! (L : access Lock; ! Ceiling_Violation : out Boolean) ! is Prio : constant System.Any_Priority := Current_Task.Common.LL.Active_Priority; begin pragma Debug (Printk ("procedure Write_Lock called" & LF)); --- 722,731 ---- -- Write_Lock -- ---------------- ! procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is Prio : constant System.Any_Priority := Current_Task.Common.LL.Active_Priority; + begin pragma Debug (Printk ("procedure Write_Lock called" & LF)); *************** package body System.Task_Primitives.Oper *** 756,762 **** end if; end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is Prio : constant System.Any_Priority := Current_Task.Common.LL.Active_Priority; --- 754,762 ---- end if; end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is Prio : constant System.Any_Priority := Current_Task.Common.LL.Active_Priority; *************** package body System.Task_Primitives.Oper *** 872,878 **** end if; end Unlock; ! procedure Unlock (L : access RTS_Lock) is Flags : Integer; begin pragma Debug (Printk ("procedure Unlock (RTS_Lock) called" & LF)); --- 872,878 ---- end if; end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is Flags : Integer; begin pragma Debug (Printk ("procedure Unlock (RTS_Lock) called" & LF)); *************** package body System.Task_Primitives.Oper *** 1607,1633 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! pragma Debug (Printk ("procedure Lock_All_Tasks_List called" & LF)); ! ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! pragma Debug (Printk ("procedure Unlock_All_Tasks_List called" & LF)); ! ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ----------------- -- Stack_Guard -- --- 1607,1629 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ----------------- -- Stack_Guard -- *************** package body System.Task_Primitives.Oper *** 1770,1776 **** -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); Enter_Task (Environment_Task); end Initialize; --- 1766,1775 ---- -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); ! ! -- Single_Lock isn't supported in this configuration ! pragma Assert (not Single_Lock); Enter_Task (Environment_Task); end Initialize; diff -Nrc3pad gcc-3.2.3/gcc/ada/5qtaspri.ads gcc-3.3/gcc/ada/5qtaspri.ads *** gcc-3.2.3/gcc/ada/5qtaspri.ads 2001-10-04 17:50:42.000000000 +0000 --- gcc-3.3/gcc/ada/5qtaspri.ads 2002-03-14 10:58:37.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 1991-2001, Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5qvxwork.ads gcc-3.3/gcc/ada/5qvxwork.ads *** gcc-3.2.3/gcc/ada/5qvxwork.ads 2002-05-07 08:22:03.000000000 +0000 --- gcc-3.3/gcc/ada/5qvxwork.ads 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,111 **** - ------------------------------------------------------------------------------ - -- -- - -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- - -- -- - -- S Y S T E M . V X W O R K S -- - -- -- - -- S p e c -- - -- -- - -- $Revision: 1.1.16.2 $ - -- -- - -- Copyright (C) 1998 - 2001 Free Software Foundation -- - -- -- - -- GNARL 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- -- - -- sion. GNARL 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 GNARL; see file COPYING. If not, write -- - -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- 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. -- - -- -- - -- GNARL was developed by the GNARL team at Florida State University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - -- This is the PPC VxWorks 6.0 version of this package. A different version - -- is used for VxWorks 5.x - - with Interfaces.C; - - package System.VxWorks is - pragma Preelaborate (System.VxWorks); - - package IC renames Interfaces.C; - - -- Define enough of a Wind Task Control Block in order to - -- obtain the inherited priority. When porting this to - -- different versions of VxWorks (this is based on 6.0), - -- be sure to look at the definition for WIND_TCB located - -- in $WIND_BASE/target/h/taskLib.h - - type Wind_Fill_1 is array (0 .. 16#6B#) of IC.unsigned_char; - type Wind_Fill_2 is array (16#74# .. 16#10F#) of IC.unsigned_char; - - type Wind_TCB is record - Fill_1 : Wind_Fill_1; -- 0x00 - 0x6b - Priority : IC.int; -- 0x6c - 0x6f, current (inherited) priority - Normal_Priority : IC.int; -- 0x70 - 0x73, base priority - Fill_2 : Wind_Fill_2; -- 0x74 - 0x10f - spare1 : Address; -- 0x110 - 0x113 - spare2 : Address; -- 0x114 - 0x117 - spare3 : Address; -- 0x118 - 0x11b - spare4 : Address; -- 0x11c - 0x11f - end record; - type Wind_TCB_Ptr is access Wind_TCB; - - -- Floating point context record. PPC version - - FP_NUM_DREGS : constant := 32; - type Fpr_Array is array (1 .. FP_NUM_DREGS) of IC.double; - - type FP_CONTEXT is record - fpr : Fpr_Array; - fpcsr : IC.int; - pad : IC.int; - end record; - pragma Convention (C, FP_CONTEXT); - - Num_HW_Interrupts : constant := 256; - - -- For VxWorks 6.0 - type TASK_DESC is record - td_id : IC.int; -- task id - td_priority : IC.int; -- task priority - td_status : IC.int; -- task status - td_options : IC.int; -- task option bits (see below) - td_entry : Address; -- original entry point of task - td_sp : Address; -- saved stack pointer - td_pStackBase : Address; -- the bottom of the stack - td_pStackLimit : Address; -- the effective end of the stack - td_pStackEnd : Address; -- the actual end of the stack - td_stackSize : IC.int; -- size of stack in bytes - td_stackCurrent : IC.int; -- current stack usage in bytes - td_stackHigh : IC.int; -- maximum stack usage in bytes - td_stackMargin : IC.int; -- current stack margin in bytes - - td_PExcStkBase : Address; -- exception stack base - td_PExcStkPtr : Address; -- exception stack pointer - td_ExcStkHigh : IC.int; -- exception stack max usage - td_ExcStkMgn : IC.int; -- exception stack margin - - td_errorStatus : IC.int; -- most recent task error status - td_delay : IC.int; -- delay/timeout ticks - - td_PdId : Address; -- task's home protection domain - td_name : Address; -- name of task - end record; - - pragma Convention (C, TASK_DESC); - - end System.VxWorks; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5rosinte.adb gcc-3.3/gcc/ada/5rosinte.adb *** gcc-3.2.3/gcc/ada/5rosinte.adb 2001-10-02 13:42:27.000000000 +0000 --- gcc-3.3/gcc/ada/5rosinte.adb 2002-03-14 10:58:37.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2000 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5rosinte.ads gcc-3.3/gcc/ada/5rosinte.ads *** gcc-3.2.3/gcc/ada/5rosinte.ads 2003-01-29 17:34:08.000000000 +0000 --- gcc-3.3/gcc/ada/5rosinte.ads 2003-01-29 17:40:47.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1.4.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5rparame.adb gcc-3.3/gcc/ada/5rparame.adb *** gcc-3.2.3/gcc/ada/5rparame.adb 2002-05-07 08:22:03.000000000 +0000 --- gcc-3.3/gcc/ada/5rparame.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1997-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5rtpopsp.adb gcc-3.3/gcc/ada/5rtpopsp.adb *** gcc-3.2.3/gcc/ada/5rtpopsp.adb 2003-01-29 17:34:08.000000000 +0000 --- gcc-3.3/gcc/ada/5rtpopsp.adb 2003-01-29 17:40:47.000000000 +0000 *************** *** 7,13 **** -- -- -- B o d y -- -- -- ! -- $Revision: 1.1.2.1 $ -- -- -- Copyright (C) 1991-1999, Florida State University -- -- -- --- 7,13 ---- -- -- -- B o d y -- -- -- ! -- $Revision: 1.1.4.1 $ -- -- -- Copyright (C) 1991-1999, Florida State University -- -- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/5sintman.adb gcc-3.3/gcc/ada/5sintman.adb *** gcc-3.2.3/gcc/ada/5sintman.adb 2002-05-07 08:22:03.000000000 +0000 --- gcc-3.3/gcc/ada/5sintman.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** begin *** 172,184 **** act.sa_mask := mask; Keep_Unmasked (Abort_Task_Interrupt) := True; - Keep_Unmasked (SIGXCPU) := True; - Keep_Unmasked (SIGFPE) := True; - Result := - sigaction - (Signal (SIGFPE), act'Unchecked_Access, - old_act'Unchecked_Access); - pragma Assert (Result = 0); -- By keeping SIGINT unmasked, allow the user to do a Ctrl-C, but in the -- same time, disable the ability of handling this signal --- 171,176 ---- *************** begin *** 190,206 **** Keep_Unmasked (SIGINT) := True; end if; ! for J in ! Exception_Interrupts'First + 1 .. Exception_Interrupts'Last loop Keep_Unmasked (Exception_Interrupts (J)) := True; ! ! if Unreserve_All_Interrupts = 0 then ! Result := ! sigaction ! (Signal (Exception_Interrupts (J)), act'Unchecked_Access, ! old_act'Unchecked_Access); ! pragma Assert (Result = 0); ! end if; end loop; for J in Unmasked'Range loop --- 182,194 ---- Keep_Unmasked (SIGINT) := True; end if; ! for J in Exception_Interrupts'Range loop Keep_Unmasked (Exception_Interrupts (J)) := True; ! Result := ! sigaction ! (Signal (Exception_Interrupts (J)), act'Unchecked_Access, ! old_act'Unchecked_Access); ! pragma Assert (Result = 0); end loop; for J in Unmasked'Range loop diff -Nrc3pad gcc-3.2.3/gcc/ada/5smastop.adb gcc-3.3/gcc/ada/5smastop.adb *** gcc-3.2.3/gcc/ada/5smastop.adb 2001-10-02 13:42:27.000000000 +0000 --- gcc-3.3/gcc/ada/5smastop.adb 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,159 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- SYSTEM.MACHINE_STATE_OPERATIONS -- - -- -- - -- B o d y -- - -- (Version using the GCC stack unwinding mechanism) -- - -- -- - -- $Revision: 1.1 $ - -- -- - -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- 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. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- - -- -- - ------------------------------------------------------------------------------ - - -- This version of System.Machine_State_Operations is for use on - -- systems where the GCC stack unwinding mechanism is supported. - -- It is currently only used on Solaris - - package body System.Machine_State_Operations is - - use System.Storage_Elements; - use System.Exceptions; - - ---------------------------- - -- Allocate_Machine_State -- - ---------------------------- - - function Allocate_Machine_State return Machine_State is - function Machine_State_Length return Storage_Offset; - pragma Import (C, Machine_State_Length, "__gnat_machine_state_length"); - - function Gnat_Malloc (Size : Storage_Offset) return Machine_State; - pragma Import (C, Gnat_Malloc, "__gnat_malloc"); - - begin - return Gnat_Malloc (Machine_State_Length); - end Allocate_Machine_State; - - ------------------- - -- Enter_Handler -- - ------------------- - - procedure Enter_Handler (M : Machine_State; Handler : Handler_Loc) is - procedure c_enter_handler (m : Machine_State; handler : Handler_Loc); - pragma Import (C, c_enter_handler, "__gnat_enter_handler"); - - begin - c_enter_handler (M, Handler); - end Enter_Handler; - - ---------------- - -- Fetch_Code -- - ---------------- - - function Fetch_Code (Loc : Code_Loc) return Code_Loc is - begin - return Loc; - end Fetch_Code; - - ------------------------ - -- Free_Machine_State -- - ------------------------ - - procedure Free_Machine_State (M : in out Machine_State) is - procedure Gnat_Free (M : in Machine_State); - pragma Import (C, Gnat_Free, "__gnat_free"); - - begin - Gnat_Free (M); - M := Machine_State (Null_Address); - end Free_Machine_State; - - ------------------ - -- Get_Code_Loc -- - ------------------ - - function Get_Code_Loc (M : Machine_State) return Code_Loc is - function c_get_code_loc (m : Machine_State) return Code_Loc; - pragma Import (C, c_get_code_loc, "__gnat_get_code_loc"); - - begin - return c_get_code_loc (M); - end Get_Code_Loc; - - -------------------------- - -- Machine_State_Length -- - -------------------------- - - function Machine_State_Length return Storage_Offset is - - function c_machine_state_length return Storage_Offset; - pragma Import (C, c_machine_state_length, "__gnat_machine_state_length"); - - begin - return c_machine_state_length; - end Machine_State_Length; - - --------------- - -- Pop_Frame -- - --------------- - - procedure Pop_Frame - (M : Machine_State; - Info : Subprogram_Info_Type) - is - procedure c_pop_frame (m : Machine_State); - pragma Import (C, c_pop_frame, "__gnat_pop_frame"); - - begin - c_pop_frame (M); - end Pop_Frame; - - ----------------------- - -- Set_Machine_State -- - ----------------------- - - procedure Set_Machine_State (M : Machine_State) is - procedure c_set_machine_state (m : Machine_State); - pragma Import (C, c_set_machine_state, "__gnat_set_machine_state"); - - begin - c_set_machine_state (M); - Pop_Frame (M, System.Null_Address); - end Set_Machine_State; - - ------------------------------ - -- Set_Signal_Machine_State -- - ------------------------------ - - procedure Set_Signal_Machine_State - (M : Machine_State; - Context : System.Address) is - begin - null; - end Set_Signal_Machine_State; - - end System.Machine_State_Operations; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5sosinte.adb gcc-3.3/gcc/ada/5sosinte.adb *** gcc-3.2.3/gcc/ada/5sosinte.adb 2001-10-02 13:42:27.000000000 +0000 --- gcc-3.3/gcc/ada/5sosinte.adb 2002-03-14 10:58:37.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5sosinte.ads gcc-3.3/gcc/ada/5sosinte.ads *** gcc-3.2.3/gcc/ada/5sosinte.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5sosinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5sparame.adb gcc-3.3/gcc/ada/5sparame.adb *** gcc-3.2.3/gcc/ada/5sparame.adb 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5sparame.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5ssystem.ads gcc-3.3/gcc/ada/5ssystem.ads *** gcc-3.2.3/gcc/ada/5ssystem.ads 2002-05-04 03:27:15.000000000 +0000 --- gcc-3.3/gcc/ada/5ssystem.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (SUN Solaris Version) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (SUN Solaris Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 92,118 **** -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 91,104 ---- -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 130,137 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; diff -Nrc3pad gcc-3.2.3/gcc/ada/5staprop.adb gcc-3.3/gcc/ada/5staprop.adb *** gcc-3.2.3/gcc/ada/5staprop.adb 2001-12-16 01:13:28.000000000 +0000 --- gcc-3.3/gcc/ada/5staprop.adb 2002-10-23 08:27:55.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ *************** package body System.Task_Primitives.Oper *** 108,118 **** -- Local Data -- ------------------ - ATCB_Magic_Code : constant := 16#ADAADAAD#; - -- This is used to allow us to catch attempts to call Self - -- from outside an Ada task, with high probability. - -- For an Ada task, Task_Wrapper.Magic_Number = ATCB_Magic_Code. - -- The following are logically constants, but need to be initialized -- at run time. --- 106,111 ---- *************** package body System.Task_Primitives.Oper *** 128,135 **** -- Key used to find the Ada Task_ID associated with a thread, -- at least for C threads unknown to the Ada run-time system. ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Next_Serial_Number : Task_Serial_Number := 100; -- We start at 100, to reserve some special values for --- 121,130 ---- -- Key used to find the Ada Task_ID associated with a thread, -- at least for C threads unknown to the Ada run-time system. ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Next_Serial_Number : Task_Serial_Number := 100; -- We start at 100, to reserve some special values for *************** package body System.Task_Primitives.Oper *** 140,148 **** -- Priority Support -- ------------------------ - Dynamic_Priority_Support : constant Boolean := True; - -- controls whether we poll for pending priority changes during sleeps - Priority_Ceiling_Emulation : constant Boolean := True; -- controls whether we emulate priority ceiling locking --- 135,140 ---- *************** package body System.Task_Primitives.Oper *** 194,200 **** Fake_ATCB_List : Fake_ATCB_Ptr; -- A linear linked list. ! -- The list is protected by All_Tasks_L; -- Nodes are added to this list from the front. -- Once a node is added to this list, it is never removed. --- 186,192 ---- Fake_ATCB_List : Fake_ATCB_Ptr; -- A linear linked list. ! -- The list is protected by Single_RTS_Lock; -- Nodes are added to this list from the front. -- Once a node is added to this list, it is never removed. *************** package body System.Task_Primitives.Oper *** 245,257 **** function To_Address is new Unchecked_Conversion (Task_ID, System.Address); - type Ptr is access Task_ID; - function To_Ptr is new Unchecked_Conversion (Interfaces.C.unsigned, Ptr); - function To_Ptr is new Unchecked_Conversion (System.Address, Ptr); - - type Iptr is access Interfaces.C.unsigned; - function To_Iptr is new Unchecked_Conversion (Interfaces.C.unsigned, Iptr); - function Thread_Body_Access is new Unchecked_Conversion (System.Address, Thread_Body); --- 237,242 ---- *************** package body System.Task_Primitives.Oper *** 259,264 **** --- 244,252 ---- -- Allocate and Initialize a new ATCB. This code can safely be called from -- a foreign thread, as it doesn't access implicitly or explicitly -- "self" before having initialized the new ATCB. + pragma Warnings (Off, New_Fake_ATCB); + -- Disable warning on this function, since the Solaris x86 version does + -- not use it. ------------ -- Checks -- *************** package body System.Task_Primitives.Oper *** 309,318 **** -- This section is ticklish. -- We dare not call anything that might require an ATCB, until -- we have the new ATCB in place. ! -- Note: we don't use "Write_Lock (All_Tasks_L'Access);" because ! -- we don't yet have an ATCB, and so can't pass the safety check. ! Result := mutex_lock (All_Tasks_L.L'Access); Q := null; P := Fake_ATCB_List; --- 297,306 ---- -- This section is ticklish. -- We dare not call anything that might require an ATCB, until -- we have the new ATCB in place. ! -- Note: we don't use Lock_RTS because we don't yet have an ATCB, and ! -- so can't pass the safety check. ! Result := mutex_lock (Single_RTS_Lock.L'Access); Q := null; P := Fake_ATCB_List; *************** package body System.Task_Primitives.Oper *** 415,424 **** end if; end loop; ! Result := mutex_unlock (All_Tasks_L.L'Access); ! -- We cannot use "Unlock (All_Tasks_L'Access);" because ! -- we did not use Write_Lock, and so would not pass the checks. return Self_ID; end New_Fake_ATCB; --- 403,412 ---- end if; end loop; ! Result := mutex_unlock (Single_RTS_Lock.L'Access); ! -- We cannot use Unlock_RTS because we did not use Write_Lock, and so ! -- would not pass the checks. return Self_ID; end New_Fake_ATCB; *************** package body System.Task_Primitives.Oper *** 550,556 **** -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as All_Tasks_L, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. --- 538,544 ---- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. *************** package body System.Task_Primitives.Oper *** 658,681 **** pragma Assert (Record_Lock (Lock_Ptr (L))); end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! pragma Assert (Check_Lock (To_Lock_Ptr (RTS_Lock_Ptr (L)))); ! Result := mutex_lock (L.L'Access); ! pragma Assert (Result = 0); ! pragma Assert (Record_Lock (To_Lock_Ptr (RTS_Lock_Ptr (L)))); end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; - begin ! pragma Assert (Check_Lock (To_Lock_Ptr (T.Common.LL.L'Access))); ! Result := mutex_lock (T.Common.LL.L.L'Access); ! pragma Assert (Result = 0); ! pragma Assert (Record_Lock (To_Lock_Ptr (T.Common.LL.L'Access))); end Write_Lock; --------------- --- 646,673 ---- pragma Assert (Record_Lock (Lock_Ptr (L))); end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! pragma Assert (Check_Lock (To_Lock_Ptr (RTS_Lock_Ptr (L)))); ! Result := mutex_lock (L.L'Access); ! pragma Assert (Result = 0); ! pragma Assert (Record_Lock (To_Lock_Ptr (RTS_Lock_Ptr (L)))); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! pragma Assert (Check_Lock (To_Lock_Ptr (T.Common.LL.L'Access))); ! Result := mutex_lock (T.Common.LL.L.L'Access); ! pragma Assert (Result = 0); ! pragma Assert (Record_Lock (To_Lock_Ptr (T.Common.LL.L'Access))); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 693,699 **** procedure Unlock (L : access Lock) is Result : Interfaces.C.int; - begin pragma Assert (Check_Unlock (Lock_Ptr (L))); --- 685,690 ---- *************** package body System.Task_Primitives.Oper *** 715,736 **** end if; end Unlock; ! procedure Unlock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! pragma Assert (Check_Unlock (To_Lock_Ptr (RTS_Lock_Ptr (L)))); ! Result := mutex_unlock (L.L'Access); ! pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; - begin ! pragma Assert (Check_Unlock (To_Lock_Ptr (T.Common.LL.L'Access))); ! Result := mutex_unlock (T.Common.LL.L.L'Access); ! pragma Assert (Result = 0); end Unlock; -- For the time delay implementation, we need to make sure we --- 706,729 ---- end if; end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! pragma Assert (Check_Unlock (To_Lock_Ptr (RTS_Lock_Ptr (L)))); ! Result := mutex_unlock (L.L'Access); ! pragma Assert (Result = 0); ! end if; end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! pragma Assert (Check_Unlock (To_Lock_Ptr (T.Common.LL.L'Access))); ! Result := mutex_unlock (T.Common.LL.L.L'Access); ! pragma Assert (Result = 0); ! end if; end Unlock; -- For the time delay implementation, we need to make sure we *************** package body System.Task_Primitives.Oper *** 899,914 **** -- We need the above code even if we do direct fetch of Task_ID in Self -- for the main task on Sun, x86 Solaris and for gcc 2.7.2. ! Lock_All_Tasks_List; ! for I in Known_Tasks'Range loop ! if Known_Tasks (I) = null then ! Known_Tasks (I) := Self_ID; ! Self_ID.Known_Tasks_Index := I; exit; end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 892,908 ---- -- We need the above code even if we do direct fetch of Task_ID in Self -- for the main task on Sun, x86 Solaris and for gcc 2.7.2. ! Lock_RTS; ! for J in Known_Tasks'Range loop ! if Known_Tasks (J) = null then ! Known_Tasks (J) := Self_ID; ! Self_ID.Known_Tasks_Index := J; exit; end if; end loop; ! ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 920,932 **** return new Ada_Task_Control_Block (Entry_Num); end New_ATCB; ! ---------------------- ! -- Initialize_TCB -- ! ---------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is ! Result : Interfaces.C.int; ! begin -- Give the task a unique serial number. --- 914,925 ---- return new Ada_Task_Control_Block (Entry_Num); end New_ATCB; ! -------------------- ! -- Initialize_TCB -- ! -------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is ! Result : Interfaces.C.int := 0; begin -- Give the task a unique serial number. *************** package body System.Task_Primitives.Oper *** 935,959 **** pragma Assert (Next_Serial_Number /= 0); Self_ID.Common.LL.Thread := To_thread_t (-1); ! Result := mutex_init ! (Self_ID.Common.LL.L.L'Access, USYNC_THREAD, System.Null_Address); ! Self_ID.Common.LL.L.Level := ! Private_Task_Serial_Number (Self_ID.Serial_Number); ! pragma Assert (Result = 0 or else Result = ENOMEM); if Result = 0 then Result := cond_init (Self_ID.Common.LL.CV'Access, USYNC_THREAD, 0); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then Result := mutex_destroy (Self_ID.Common.LL.L.L'Access); pragma Assert (Result = 0); - Succeeded := False; - else - Succeeded := True; end if; - else Succeeded := False; end if; end Initialize_TCB; --- 928,955 ---- pragma Assert (Next_Serial_Number /= 0); Self_ID.Common.LL.Thread := To_thread_t (-1); ! ! if not Single_Lock then ! Result := mutex_init ! (Self_ID.Common.LL.L.L'Access, USYNC_THREAD, System.Null_Address); ! Self_ID.Common.LL.L.Level := ! Private_Task_Serial_Number (Self_ID.Serial_Number); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! end if; if Result = 0 then Result := cond_init (Self_ID.Common.LL.CV'Access, USYNC_THREAD, 0); pragma Assert (Result = 0 or else Result = ENOMEM); + end if; ! if Result = 0 then ! Succeeded := True; ! else ! if not Single_Lock then Result := mutex_destroy (Self_ID.Common.LL.L.L'Access); pragma Assert (Result = 0); end if; Succeeded := False; end if; end Initialize_TCB; *************** package body System.Task_Primitives.Oper *** 1042,1049 **** begin T.Common.LL.Thread := To_thread_t (0); ! Result := mutex_destroy (T.Common.LL.L.L'Access); ! pragma Assert (Result = 0); Result := cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); --- 1038,1049 ---- begin T.Common.LL.Thread := To_thread_t (0); ! ! if not Single_Lock then ! Result := mutex_destroy (T.Common.LL.L.L'Access); ! pragma Assert (Result = 0); ! end if; ! Result := cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); *************** package body System.Task_Primitives.Oper *** 1083,1098 **** pragma Assert (Result = 0); end Abort_Task; ! ------------- ! -- Sleep -- ! ------------- procedure Sleep (Self_ID : Task_ID; Reason : Task_States) is Result : Interfaces.C.int; - begin pragma Assert (Check_Sleep (Reason)); --- 1083,1097 ---- pragma Assert (Result = 0); end Abort_Task; ! ----------- ! -- Sleep -- ! ----------- procedure Sleep (Self_ID : Task_ID; Reason : Task_States) is Result : Interfaces.C.int; begin pragma Assert (Check_Sleep (Reason)); *************** package body System.Task_Primitives.Oper *** 1104,1114 **** Set_Priority (Self_ID, Self_ID.Common.Base_Priority); end if; ! Result := cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L.L'Access); ! pragma Assert (Result = 0 or else Result = EINTR); pragma Assert (Record_Wakeup (To_Lock_Ptr (Self_ID.Common.LL.L'Access), Reason)); end Sleep; -- Note that we are relying heaviliy here on the GNAT feature --- 1103,1119 ---- Set_Priority (Self_ID, Self_ID.Common.Base_Priority); end if; ! if Single_Lock then ! Result := cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock.L'Access); ! else ! Result := cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L.L'Access); ! end if; ! pragma Assert (Record_Wakeup (To_Lock_Ptr (Self_ID.Common.LL.L'Access), Reason)); + pragma Assert (Result = 0 or else Result = EINTR); end Sleep; -- Note that we are relying heaviliy here on the GNAT feature *************** package body System.Task_Primitives.Oper *** 1121,1127 **** -- ??? -- We are taking liberties here with the semantics of the delays. -- That is, we make no distinction between delays on the Calendar clock ! -- and delays on the Real_Time clock. That is technically incorrect, if -- the Calendar clock happens to be reset or adjusted. -- To solve this defect will require modification to the compiler -- interface, so that it can pass through more information, to tell --- 1126,1132 ---- -- ??? -- We are taking liberties here with the semantics of the delays. -- That is, we make no distinction between delays on the Calendar clock ! -- and delays on the Real_Time clock. That is technically incorrect, if -- the Calendar clock happens to be reset or adjusted. -- To solve this defect will require modification to the compiler -- interface, so that it can pass through more information, to tell *************** package body System.Task_Primitives.Oper *** 1157,1165 **** -- Annex D requires that completion of a delay cause the task -- to go to the end of its priority queue, regardless of whether ! -- the task actually was suspended by the delay. Since -- cond_timedwait does not do this on Solaris, we add a call ! -- to thr_yield at the end. We might do this at the beginning, -- instead, but then the round-robin effect would not be the -- same; the delayed task would be ahead of other tasks of the -- same priority that awoke while it was sleeping. --- 1162,1170 ---- -- Annex D requires that completion of a delay cause the task -- to go to the end of its priority queue, regardless of whether ! -- the task actually was suspended by the delay. Since -- cond_timedwait does not do this on Solaris, we add a call ! -- to thr_yield at the end. We might do this at the beginning, -- instead, but then the round-robin effect would not be the -- same; the delayed task would be ahead of other tasks of the -- same priority that awoke while it was sleeping. *************** package body System.Task_Primitives.Oper *** 1177,1205 **** -- For Timed_Delay, we are not expecting any cond_signals or -- other interruptions, except for priority changes and aborts. -- Therefore, we don't want to return unless the delay has ! -- actually expired, or the call has been aborted. In this -- case, since we want to implement the entire delay statement -- semantics, we do need to check for pending abort and priority ! -- changes. We can quietly handle priority changes inside the -- procedure, since there is no entry-queue reordering involved. ----------------- -- Timed_Sleep -- ----------------- - -- This is for use within the run-time system, so abort is - -- assumed to be already deferred, and the caller should be - -- holding its own ATCB lock. - - -- Yielded should be False unles we know for certain that the - -- operation resulted in the calling task going to the end of - -- the dispatching queue for its priority. - - -- ??? - -- This version presumes the worst, so Yielded is always False. - -- On some targets, if cond_timedwait always yields, we could - -- set Yielded to True just before the cond_timedwait call. - procedure Timed_Sleep (Self_ID : Task_ID; Time : Duration; --- 1182,1197 ---- -- For Timed_Delay, we are not expecting any cond_signals or -- other interruptions, except for priority changes and aborts. -- Therefore, we don't want to return unless the delay has ! -- actually expired, or the call has been aborted. In this -- case, since we want to implement the entire delay statement -- semantics, we do need to check for pending abort and priority ! -- changes. We can quietly handle priority changes inside the -- procedure, since there is no entry-queue reordering involved. ----------------- -- Timed_Sleep -- ----------------- procedure Timed_Sleep (Self_ID : Task_ID; Time : Duration; *************** package body System.Task_Primitives.Oper *** 1232,1239 **** or else (Dynamic_Priority_Support and then Self_ID.Pending_Priority_Change); ! Result := cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 1224,1238 ---- or else (Dynamic_Priority_Support and then Self_ID.Pending_Priority_Change); ! if Single_Lock then ! Result := cond_timedwait (Self_ID.Common.LL.CV'Access, ! Single_RTS_Lock.L'Access, Request'Access); ! else ! Result := cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L.L'Access, Request'Access); ! end if; ! ! Yielded := True; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 1255,1264 **** -- Timed_Delay -- ----------------- - -- This is for use in implementing delay statements, so - -- we assume the caller is abort-deferred but is holding - -- no locks. - procedure Timed_Delay (Self_ID : Task_ID; Time : Duration; --- 1254,1259 ---- *************** package body System.Task_Primitives.Oper *** 1268,1273 **** --- 1263,1269 ---- Abs_Time : Duration; Request : aliased timespec; Result : Interfaces.C.int; + Yielded : Boolean := False; begin -- Only the little window between deferring abort and *************** package body System.Task_Primitives.Oper *** 1275,1280 **** --- 1271,1281 ---- -- check for pending abort and priority change below! SSL.Abort_Defer.all; + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); if Mode = Relative then *************** package body System.Task_Primitives.Oper *** 1299,1306 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! Result := cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 1300,1314 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! if Single_Lock then ! Result := cond_timedwait (Self_ID.Common.LL.CV'Access, ! Single_RTS_Lock.L'Access, Request'Access); ! else ! Result := cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L.L'Access, Request'Access); ! end if; ! ! Yielded := True; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 1316,1322 **** end if; Unlock (Self_ID); ! thr_yield; SSL.Abort_Undefer.all; end Timed_Delay; --- 1324,1338 ---- end if; Unlock (Self_ID); ! ! if Single_Lock then ! Unlock_RTS; ! end if; ! ! if not Yielded then ! thr_yield; ! end if; ! SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 1329,1335 **** Reason : Task_States) is Result : Interfaces.C.int; - begin pragma Assert (Check_Wakeup (T, Reason)); Result := cond_signal (T.Common.LL.CV'Access); --- 1345,1350 ---- *************** package body System.Task_Primitives.Oper *** 1400,1405 **** --- 1415,1424 ---- return False; end if; + if Single_Lock then + return True; + end if; + -- Check that TCB lock order rules are satisfied P := Self_ID.Common.LL.Locks; *************** package body System.Task_Primitives.Oper *** 1435,1440 **** --- 1454,1463 ---- L.Owner := To_Owner_ID (Self_ID); + if Single_Lock then + return True; + end if; + -- Check that TCB lock order rules are satisfied P := Self_ID.Common.LL.Locks; *************** package body System.Task_Primitives.Oper *** 1463,1468 **** --- 1486,1495 ---- return False; end if; + if Single_Lock then + return True; + end if; + -- Check that caller is holding own lock, on top of list if Self_ID.Common.LL.Locks /= *************** package body System.Task_Primitives.Oper *** 1501,1506 **** --- 1528,1537 ---- L.Owner := To_Owner_ID (Self_ID); + if Single_Lock then + return True; + end if; + -- Check that TCB lock order rules are satisfied P := Self_ID.Common.LL.Locks; *************** package body System.Task_Primitives.Oper *** 1566,1572 **** if Unlock_Count - Check_Count > 1000 then Check_Count := Unlock_Count; ! Old_Owner := To_Task_ID (All_Tasks_L.Owner); end if; -- Check that caller is abort-deferred --- 1597,1603 ---- if Unlock_Count - Check_Count > 1000 then Check_Count := Unlock_Count; ! Old_Owner := To_Task_ID (Single_RTS_Lock.Owner); end if; -- Check that caller is abort-deferred *************** package body System.Task_Primitives.Oper *** 1596,1602 **** function Check_Finalize_Lock (L : Lock_Ptr) return Boolean is Self_ID : Task_ID := Self; - begin -- Check that caller is abort-deferred --- 1627,1632 ---- *************** package body System.Task_Primitives.Oper *** 1664,1686 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 1694,1716 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 1717,1726 **** ---------------- procedure Initialize (Environment_Task : ST.Task_ID) is ! act : aliased struct_sigaction; ! old_act : aliased struct_sigaction; ! Tmp_Set : aliased sigset_t; ! Result : Interfaces.C.int; procedure Configure_Processors; -- Processors configuration --- 1747,1756 ---- ---------------- procedure Initialize (Environment_Task : ST.Task_ID) is ! act : aliased struct_sigaction; ! old_act : aliased struct_sigaction; ! Tmp_Set : aliased sigset_t; ! Result : Interfaces.C.int; procedure Configure_Processors; -- Processors configuration *************** package body System.Task_Primitives.Oper *** 1740,1810 **** -- _SC_NPROCESSORS_CONF, minus one. procedure Configure_Processors is - Proc_Acc : constant GNAT.OS_Lib.String_Access := - GNAT.OS_Lib.Getenv ("GNAT_PROCESSOR"); begin if Proc_Acc.all'Length /= 0 then - -- Environment variable is defined ! declare ! Proc : aliased processorid_t; -- User processor # ! Last_Proc : processorid_t; -- Last processor # ! ! begin ! Last_Proc := Num_Procs - 1; ! ! if Last_Proc = -1 then ! -- Unable to read system variable _SC_NPROCESSORS_CONF ! -- Ignore environment variable GNAT_PROCESSOR null; ! else ! Proc := processorid_t'Value (Proc_Acc.all); ! ! if Proc < -2 or Proc > Last_Proc then ! raise Constraint_Error; ! ! elsif Proc = -2 then ! ! -- Use the default configuration ! ! null; ! ! elsif Proc = -1 then ! ! -- Choose a processor ! Result := 0; ! while Proc < Last_Proc loop ! Proc := Proc + 1; ! Result := p_online (Proc, PR_STATUS); ! exit when Result = PR_ONLINE; ! end loop; ! pragma Assert (Result = PR_ONLINE); ! Result := processor_bind (P_PID, P_MYID, Proc, null); ! pragma Assert (Result = 0); ! else ! -- Use user processor ! Result := processor_bind (P_PID, P_MYID, Proc, null); ! pragma Assert (Result = 0); ! end if; end if; ! ! exception ! when Constraint_Error => ! ! -- Illegal environment variable GNAT_PROCESSOR - ignored ! ! null; ! end; end if; end Configure_Processors; -- Start of processing for Initialize --- 1770,1820 ---- -- _SC_NPROCESSORS_CONF, minus one. procedure Configure_Processors is + Proc_Acc : constant GNAT.OS_Lib.String_Access := + GNAT.OS_Lib.Getenv ("GNAT_PROCESSOR"); + Proc : aliased processorid_t; -- User processor # + Last_Proc : processorid_t; -- Last processor # begin if Proc_Acc.all'Length /= 0 then -- Environment variable is defined ! Last_Proc := Num_Procs - 1; ! if Last_Proc /= -1 then ! Proc := processorid_t'Value (Proc_Acc.all); + if Proc <= -2 or else Proc > Last_Proc then + -- Use the default configuration null; + elsif Proc = -1 then + -- Choose a processor ! Result := 0; ! while Proc < Last_Proc loop ! Proc := Proc + 1; ! Result := p_online (Proc, PR_STATUS); ! exit when Result = PR_ONLINE; ! end loop; ! pragma Assert (Result = PR_ONLINE); ! Result := processor_bind (P_PID, P_MYID, Proc, null); ! pragma Assert (Result = 0); ! else ! -- Use user processor ! Result := processor_bind (P_PID, P_MYID, Proc, null); ! pragma Assert (Result = 0); end if; ! end if; end if; + + exception + when Constraint_Error => + -- Illegal environment variable GNAT_PROCESSOR - ignored + null; end Configure_Processors; -- Start of processing for Initialize *************** package body System.Task_Primitives.Oper *** 1821,1827 **** -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); Enter_Task (Environment_Task); --- 1831,1837 ---- -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Enter_Task (Environment_Task); *************** package body System.Task_Primitives.Oper *** 1861,1867 **** begin declare Result : Interfaces.C.int; - begin -- Mask Environment task for all signals. The original mask of the -- Environment task will be recovered by Interrupt_Server task --- 1871,1876 ---- *************** begin *** 1892,1903 **** if Dispatching_Policy = 'F' then declare ! Result : Interfaces.C.long; Class_Info : aliased struct_pcinfo; Secs, Nsecs : Interfaces.C.long; begin - -- If a pragma Time_Slice is specified, takes the value in account. if Time_Slice_Val > 0 then --- 1901,1911 ---- if Dispatching_Policy = 'F' then declare ! Result : Interfaces.C.long; Class_Info : aliased struct_pcinfo; Secs, Nsecs : Interfaces.C.long; begin -- If a pragma Time_Slice is specified, takes the value in account. if Time_Slice_Val > 0 then *************** begin *** 1918,1924 **** Class_Info.pc_clname (1) := 'R'; Class_Info.pc_clname (2) := 'T'; ! Class_Info.pc_clname (3) := ASCII.Nul; Result := priocntl (PC_VERSION, P_LWPID, P_MYID, PC_GETCID, Class_Info'Address); --- 1926,1932 ---- Class_Info.pc_clname (1) := 'R'; Class_Info.pc_clname (2) := 'T'; ! Class_Info.pc_clname (3) := ASCII.NUL; Result := priocntl (PC_VERSION, P_LWPID, P_MYID, PC_GETCID, Class_Info'Address); diff -Nrc3pad gcc-3.2.3/gcc/ada/5stasinf.adb gcc-3.3/gcc/ada/5stasinf.adb *** gcc-3.2.3/gcc/ada/5stasinf.adb 2002-05-07 08:22:03.000000000 +0000 --- gcc-3.3/gcc/ada/5stasinf.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5stasinf.ads gcc-3.3/gcc/ada/5stasinf.ads *** gcc-3.2.3/gcc/ada/5stasinf.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5stasinf.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5staspri.ads gcc-3.3/gcc/ada/5staspri.ads *** gcc-3.2.3/gcc/ada/5staspri.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5staspri.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5stpopse.adb gcc-3.3/gcc/ada/5stpopse.adb *** gcc-3.2.3/gcc/ada/5stpopse.adb 2002-05-07 08:22:03.000000000 +0000 --- gcc-3.3/gcc/ada/5stpopse.adb 2002-10-23 08:27:55.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-1998, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ *************** separate (System.Task_Primitives.Operati *** 139,144 **** --- 137,153 ---- -- been elaborated. function Self return Task_ID is + ATCB_Magic_Code : constant := 16#ADAADAAD#; + -- This is used to allow us to catch attempts to call Self + -- from outside an Ada task, with high probability. + -- For an Ada task, Task_Wrapper.Magic_Number = ATCB_Magic_Code. + + type Iptr is access Interfaces.C.unsigned; + function To_Iptr is new Unchecked_Conversion (Interfaces.C.unsigned, Iptr); + + type Ptr is access Task_ID; + function To_Ptr is new Unchecked_Conversion (Interfaces.C.unsigned, Ptr); + X : Ptr; Result : Interfaces.C.int; diff -Nrc3pad gcc-3.2.3/gcc/ada/5svxwork.ads gcc-3.3/gcc/ada/5svxwork.ads *** gcc-3.2.3/gcc/ada/5svxwork.ads 2002-05-07 08:22:03.000000000 +0000 --- gcc-3.3/gcc/ada/5svxwork.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 33,69 **** -- -- ------------------------------------------------------------------------------ ! -- This is the SPARC64 VxWorks version of this package. ! with Interfaces.C; package System.VxWorks is pragma Preelaborate (System.VxWorks); ! package IC renames Interfaces.C; ! ! -- Define enough of a Wind Task Control Block in order to ! -- obtain the inherited priority. When porting this to ! -- different versions of VxWorks (this is based on 5.3[.1]), ! -- be sure to look at the definition for WIND_TCB located ! -- in $WIND_BASE/target/h/taskLib.h ! ! type Wind_Fill_1 is array (0 .. 16#3F#) of IC.unsigned_char; ! type Wind_Fill_2 is array (16#48# .. 16#107#) of IC.unsigned_char; ! ! type Wind_TCB is record ! Fill_1 : Wind_Fill_1; -- 0x00 - 0x3f ! Priority : IC.int; -- 0x40 - 0x43, current (inherited) priority ! Normal_Priority : IC.int; -- 0x44 - 0x47, base priority ! Fill_2 : Wind_Fill_2; -- 0x48 - 0x107 ! spare1 : Address; -- 0x108 - 0x10b ! spare2 : Address; -- 0x10c - 0x10f ! spare3 : Address; -- 0x110 - 0x113 ! spare4 : Address; -- 0x114 - 0x117 ! end record; ! type Wind_TCB_Ptr is access Wind_TCB; ! ! -- Floating point context record. SPARCV9 version FP_NUM_DREGS : constant := 32; --- 32,45 ---- -- -- ------------------------------------------------------------------------------ ! -- This is the Sparc64 VxWorks version of this package. ! with Interfaces; package System.VxWorks is pragma Preelaborate (System.VxWorks); ! -- Floating point context record. SPARCV9 version FP_NUM_DREGS : constant := 32; *************** package System.VxWorks is *** 74,110 **** for Fpd_Array'Alignment use 8; type FP_CONTEXT is record ! fpd : Fpd_Array; ! fsr : RType; end record; for FP_CONTEXT'Alignment use 8; pragma Convention (C, FP_CONTEXT); ! -- Number of entries in hardware interrupt vector table. Value of ! -- 0 disables hardware interrupt handling until we have time to test it ! -- on this target. ! Num_HW_Interrupts : constant := 0; ! ! -- VxWorks 5.3 and 5.4 version ! type TASK_DESC is record ! td_id : IC.int; -- task id ! td_name : Address; -- name of task ! td_priority : IC.int; -- task priority ! td_status : IC.int; -- task status ! td_options : IC.int; -- task option bits (see below) ! td_entry : Address; -- original entry point of task ! td_sp : Address; -- saved stack pointer ! td_pStackBase : Address; -- the bottom of the stack ! td_pStackLimit : Address; -- the effective end of the stack ! td_pStackEnd : Address; -- the actual end of the stack ! td_stackSize : IC.int; -- size of stack in bytes ! td_stackCurrent : IC.int; -- current stack usage in bytes ! td_stackHigh : IC.int; -- maximum stack usage in bytes ! td_stackMargin : IC.int; -- current stack margin in bytes ! td_errorStatus : IC.int; -- most recent task error status ! td_delay : IC.int; -- delay/timeout ticks ! end record; ! pragma Convention (C, TASK_DESC); end System.VxWorks; --- 50,63 ---- for Fpd_Array'Alignment use 8; type FP_CONTEXT is record ! fpd : Fpd_Array; ! fsr : RType; end record; for FP_CONTEXT'Alignment use 8; pragma Convention (C, FP_CONTEXT); ! Num_HW_Interrupts : constant := 256; ! -- Number of entries in hardware interrupt vector table. end System.VxWorks; diff -Nrc3pad gcc-3.2.3/gcc/ada/5tosinte.ads gcc-3.3/gcc/ada/5tosinte.ads *** gcc-3.2.3/gcc/ada/5tosinte.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5tosinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1997-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1997-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** package System.OS_Interface is *** 119,124 **** --- 118,125 ---- SIGFREEZE : constant := 34; -- used by CPR (Solaris) SIGTHAW : constant := 35; -- used by CPR (Solaris) SIGCANCEL : constant := 36; -- used for thread cancel (Solaris) + SIGRTMIN : constant := 38; -- first (highest-priority) realtime signal + SIGRTMAX : constant := 45; -- last (lowest-priority) realtime signal type Signal_Set is array (Natural range <>) of Signal; *************** package System.OS_Interface is *** 126,132 **** (SIGTRAP, SIGLWP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF); Reserved : constant Signal_Set := ! (SIGKILL, SIGSTOP, SIGALRM, SIGVTALRM, SIGWAITING); type sigset_t is private; --- 127,133 ---- (SIGTRAP, SIGLWP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF); Reserved : constant Signal_Set := ! (SIGKILL, SIGSTOP, SIGALRM, SIGVTALRM, SIGWAITING, SIGRTMAX); type sigset_t is private; diff -Nrc3pad gcc-3.2.3/gcc/ada/5uintman.adb gcc-3.3/gcc/ada/5uintman.adb *** gcc-3.2.3/gcc/ada/5uintman.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/5uintman.adb 2002-03-14 10:58:38.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2002 Florida State University -- -- -- -- GNARL 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- -- *************** begin *** 208,235 **** for J in Exception_Interrupts'Range loop Keep_Unmasked (Exception_Interrupts (J)) := True; ! if Unreserve_All_Interrupts = 0 then ! Result := ! sigaction ! (Signal (Exception_Interrupts (J)), ! act'Unchecked_Access, ! old_act'Unchecked_Access); ! pragma Assert (Result = 0); ! end if; end loop; Keep_Unmasked (Abort_Task_Interrupt) := True; - Keep_Unmasked (SIGBUS) := True; - Keep_Unmasked (SIGFPE) := True; - Result := - sigaction - (Signal (SIGFPE), act'Unchecked_Access, - old_act'Unchecked_Access); - Keep_Unmasked (SIGALRM) := True; Keep_Unmasked (SIGSTOP) := True; Keep_Unmasked (SIGKILL) := True; - Keep_Unmasked (SIGXCPU) := True; -- By keeping SIGINT unmasked, allow the user to do a Ctrl-C, but at -- the same time, disable the ability of handling this signal using --- 207,224 ---- for J in Exception_Interrupts'Range loop Keep_Unmasked (Exception_Interrupts (J)) := True; ! Result := ! sigaction ! (Signal (Exception_Interrupts (J)), ! act'Unchecked_Access, ! old_act'Unchecked_Access); ! pragma Assert (Result = 0); end loop; Keep_Unmasked (Abort_Task_Interrupt) := True; Keep_Unmasked (SIGALRM) := True; Keep_Unmasked (SIGSTOP) := True; Keep_Unmasked (SIGKILL) := True; -- By keeping SIGINT unmasked, allow the user to do a Ctrl-C, but at -- the same time, disable the ability of handling this signal using diff -Nrc3pad gcc-3.2.3/gcc/ada/5uosinte.ads gcc-3.3/gcc/ada/5uosinte.ads *** gcc-3.2.3/gcc/ada/5uosinte.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5uosinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vasthan.adb gcc-3.3/gcc/ada/5vasthan.adb *** gcc-3.2.3/gcc/ada/5vasthan.adb 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5vasthan.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1996-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1996-2002 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- -- *************** with Ada.Task_Identification; *** 60,66 **** with Ada.Exceptions; use Ada.Exceptions; with Ada.Unchecked_Conversion; - with Ada.Unchecked_Deallocation; package body System.AST_Handling is --- 59,64 ---- *************** package body System.AST_Handling is *** 162,173 **** function To_AST_Handler is new Ada.Unchecked_Conversion (AST_Handler_Data_Ref, System.Aux_DEC.AST_Handler); - function To_AST_Data_Handler_Ref is new Ada.Unchecked_Conversion - (System.Aux_DEC.AST_Handler, AST_Handler_Data_Ref); - - function To_AST_Data_Handler_Ref is new Ada.Unchecked_Conversion - (AST_Handler, AST_Handler_Data_Ref); - -- Each time Create_AST_Handler is called, a new value of this record -- type is created, containing a copy of the procedure descriptor for -- the routine used to handle all AST's (Process_AST), and the Task_Id --- 160,165 ---- *************** package body System.AST_Handling is *** 198,206 **** type AST_Handler_Vector is array (Natural range <>) of AST_Handler_Data; type AST_Handler_Vector_Ref is access all AST_Handler_Vector; - procedure Free is new Ada.Unchecked_Deallocation - (Object => AST_Handler_Vector, - Name => AST_Handler_Vector_Ref); -- type AST_Vector_Ptr is new Ada.Finalization.Controlled with record -- removed due to problem with controlled attribute, consequence is that --- 190,195 ---- *************** package body System.AST_Handling is *** 211,219 **** Vector : AST_Handler_Vector_Ref; end record; - procedure Finalize (Object : in out AST_Vector_Ptr); - -- Used to get rid of allocated AST_Vector's - AST_Vector_Init : AST_Vector_Ptr; -- Initial value, treated as constant, Vector will be null. --- 200,205 ---- *************** package body System.AST_Handling is *** 308,316 **** type AST_Server_Task_Ptr is access all AST_Server_Task; -- Type used to allocate server tasks - function To_Integer is new Ada.Unchecked_Conversion - (ATID.Task_Id, Integer); - ----------------------- -- Local Subprograms -- ----------------------- --- 294,299 ---- *************** package body System.AST_Handling is *** 532,546 **** Total_Number := AST_Service_Queue_Size; end Expand_AST_Packet_Pool; - -------------- - -- Finalize -- - -------------- - - procedure Finalize (Object : in out AST_Vector_Ptr) is - begin - Free (Object.Vector); - end Finalize; - ----------------- -- Process_AST -- ----------------- --- 515,520 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vinmaop.adb gcc-3.3/gcc/ada/5vinmaop.adb *** gcc-3.2.3/gcc/ada/5vinmaop.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/5vinmaop.adb 2002-03-14 10:58:40.000000000 +0000 *************** *** 7,15 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-2000 Florida State University -- -- -- -- GNARL 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- -- --- 7,14 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- *************** package body System.Interrupt_Management *** 57,63 **** use type unsigned_short; function To_Address is new Unchecked_Conversion (Task_ID, System.Address); - function To_Task_ID is new Unchecked_Conversion (System.Address, Task_ID); package POP renames System.Task_Primitives.Operations; ---------------------------- --- 56,61 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vinterr.adb gcc-3.3/gcc/ada/5vinterr.adb *** gcc-3.2.3/gcc/ada/5vinterr.adb 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5vinterr.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1991-2000 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** with System.Interrupt_Management.Operati *** 83,95 **** -- Set_Interrupt_Mask -- IS_Member -- Environment_Mask - -- All_Tasks_Mask pragma Elaborate_All (System.Interrupt_Management.Operations); - with System.Error_Reporting; - pragma Warnings (Off, System.Error_Reporting); - -- used for Shutdown - with System.Task_Primitives.Operations; -- used for Write_Lock -- Unlock --- 82,89 ---- *************** with System.Tasking.Initialization; *** 124,135 **** -- used for Defer_Abort -- Undefer_Abort with Unchecked_Conversion; package body System.Interrupts is use Tasking; ! use System.Error_Reporting; use Ada.Exceptions; package PRI renames System.Task_Primitives; --- 118,132 ---- -- used for Defer_Abort -- Undefer_Abort + with System.Parameters; + -- used for Single_Lock + with Unchecked_Conversion; package body System.Interrupts is use Tasking; ! use System.Parameters; use Ada.Exceptions; package PRI renames System.Task_Primitives; *************** package body System.Interrupts is *** 145,155 **** -- Local Tasks -- ----------------- ! -- WARNING: System.Tasking.Utilities performs calls to this task -- with low-level constructs. Do not change this spec without synchro- -- nizing it. task Interrupt_Manager is entry Initialize (Mask : IMNG.Interrupt_Mask); entry Attach_Handler --- 142,154 ---- -- Local Tasks -- ----------------- ! -- WARNING: System.Tasking.Stages performs calls to this task -- with low-level constructs. Do not change this spec without synchro- -- nizing it. task Interrupt_Manager is + entry Detach_Interrupt_Entries (T : Task_ID); + entry Initialize (Mask : IMNG.Interrupt_Mask); entry Attach_Handler *************** package body System.Interrupts is *** 173,180 **** E : Task_Entry_Index; Interrupt : Interrupt_ID); - entry Detach_Interrupt_Entries (T : Task_ID); - entry Block_Interrupt (Interrupt : Interrupt_ID); entry Unblock_Interrupt (Interrupt : Interrupt_ID); --- 172,177 ---- *************** package body System.Interrupts is *** 259,367 **** Access_Hold : Server_Task_Access; -- variable used to allocate Server_Task using "new". - L : aliased PRI.RTS_Lock; - -- L protects contents in tables above corresponding to interrupts - -- for which Server_ID (T) = null. - -- - -- If Server_ID (T) /= null then protection is via - -- per-task (TCB) lock of Server_ID (T). - -- - -- For deadlock prevention, L should not be locked after - -- any other lock is held. - - Task_Lock : array (Interrupt_ID'Range) of Boolean := (others => False); - -- Boolean flags to give matching Locking and Unlocking. See the comments - -- in Lock_Interrupt. - ----------------------- -- Local Subprograms -- ----------------------- - procedure Lock_Interrupt - (Self_ID : Task_ID; - Interrupt : Interrupt_ID); - -- protect the tables using L or per-task lock. Set the Boolean - -- value Task_Lock if the lock is made using per-task lock. - -- This information is needed so that Unlock_Interrupt - -- performs unlocking on the same lock. The situation we are preventing - -- is, for example, when Attach_Handler is called for the first time - -- we lock L and create an Server_Task. For a matching unlocking, if we - -- rely on the fact that there is a Server_Task, we will unlock the - -- per-task lock. - - procedure Unlock_Interrupt - (Self_ID : Task_ID; - Interrupt : Interrupt_ID); - function Is_Registered (Handler : Parameterless_Handler) return Boolean; ! -------------------- ! -- Lock_Interrupt -- ! -------------------- ! ! -- ????? ! -- This package has been modified several times. ! -- Do we still need this fancy locking scheme, now that more operations ! -- are entries of the interrupt manager task? ! -- ????? ! -- More likely, we will need to convert one or more entry calls to ! -- protected operations, because presently we are violating locking order ! -- rules by calling a task entry from within the runtime system. ! ! procedure Lock_Interrupt ! (Self_ID : Task_ID; ! Interrupt : Interrupt_ID) ! is ! begin ! Initialization.Defer_Abort (Self_ID); ! ! POP.Write_Lock (L'Access); ! ! if Task_Lock (Interrupt) then ! ! -- We need to use per-task lock. ! ! POP.Unlock (L'Access); ! POP.Write_Lock (Server_ID (Interrupt)); ! ! -- Rely on the fact that once Server_ID is set to a non-null ! -- value it will never be set back to null. ! ! elsif Server_ID (Interrupt) /= Null_Task then ! ! -- We need to use per-task lock. ! ! Task_Lock (Interrupt) := True; ! POP.Unlock (L'Access); ! POP.Write_Lock (Server_ID (Interrupt)); ! end if; ! end Lock_Interrupt; ! ! ---------------------- ! -- Unlock_Interrupt -- ! ---------------------- ! ! procedure Unlock_Interrupt ! (Self_ID : Task_ID; ! Interrupt : Interrupt_ID) ! is ! begin ! if Task_Lock (Interrupt) then ! POP.Unlock (Server_ID (Interrupt)); ! else ! POP.Unlock (L'Access); ! end if; ! ! Initialization.Undefer_Abort (Self_ID); ! end Unlock_Interrupt; ! ! ---------------------------------- ! -- Register_Interrupt_Handler -- ! ---------------------------------- procedure Register_Interrupt_Handler (Handler_Addr : System.Address) is New_Node_Ptr : R_Link; - begin -- This routine registers the Handler as usable for Dynamic -- Interrupt Handler. Routines attaching and detaching Handler --- 256,275 ---- Access_Hold : Server_Task_Access; -- variable used to allocate Server_Task using "new". ----------------------- -- Local Subprograms -- ----------------------- function Is_Registered (Handler : Parameterless_Handler) return Boolean; + -- See if the Handler has been "pragma"ed using Interrupt_Handler. + -- Always consider a null handler as registered. ! -------------------------------- ! -- Register_Interrupt_Handler -- ! -------------------------------- procedure Register_Interrupt_Handler (Handler_Addr : System.Address) is New_Node_Ptr : R_Link; begin -- This routine registers the Handler as usable for Dynamic -- Interrupt Handler. Routines attaching and detaching Handler *************** package body System.Interrupts is *** 392,402 **** -- Is_Registered -- ------------------- - -- See if the Handler has been "pragma"ed using Interrupt_Handler. - -- Always consider a null handler as registered. - function Is_Registered (Handler : Parameterless_Handler) return Boolean is - type Fat_Ptr is record Object_Addr : System.Address; Handler_Addr : System.Address; --- 300,306 ---- *************** package body System.Interrupts is *** 528,535 **** procedure Attach_Handler (New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID; ! Static : in Boolean := False) ! is begin if Is_Reserved (Interrupt) then Raise_Exception (Program_Error'Identity, "Interrupt" & --- 432,438 ---- procedure Attach_Handler (New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID; ! Static : in Boolean := False) is begin if Is_Reserved (Interrupt) then Raise_Exception (Program_Error'Identity, "Interrupt" & *************** package body System.Interrupts is *** 556,563 **** (Old_Handler : out Parameterless_Handler; New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID; ! Static : in Boolean := False) ! is begin if Is_Reserved (Interrupt) then Raise_Exception (Program_Error'Identity, "Interrupt" & --- 459,465 ---- (Old_Handler : out Parameterless_Handler; New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID; ! Static : in Boolean := False) is begin if Is_Reserved (Interrupt) then Raise_Exception (Program_Error'Identity, "Interrupt" & *************** package body System.Interrupts is *** 582,589 **** procedure Detach_Handler (Interrupt : in Interrupt_ID; ! Static : in Boolean := False) ! is begin if Is_Reserved (Interrupt) then Raise_Exception (Program_Error'Identity, "Interrupt" & --- 484,490 ---- procedure Detach_Handler (Interrupt : in Interrupt_ID; ! Static : in Boolean := False) is begin if Is_Reserved (Interrupt) then Raise_Exception (Program_Error'Identity, "Interrupt" & *************** package body System.Interrupts is *** 591,597 **** end if; Interrupt_Manager.Detach_Handler (Interrupt, Static); - end Detach_Handler; --------------- --- 492,497 ---- *************** package body System.Interrupts is *** 622,628 **** E : Task_Entry_Index; Int_Ref : System.Address) is ! Interrupt : constant Interrupt_ID := Interrupt_ID (Storage_Elements.To_Integer (Int_Ref)); begin --- 522,528 ---- E : Task_Entry_Index; Int_Ref : System.Address) is ! Interrupt : constant Interrupt_ID := Interrupt_ID (Storage_Elements.To_Integer (Int_Ref)); begin *************** package body System.Interrupts is *** 677,685 **** ------------------ function Unblocked_By ! (Interrupt : Interrupt_ID) ! return System.Tasking.Task_ID ! is begin if Is_Reserved (Interrupt) then Raise_Exception (Program_Error'Identity, "Interrupt" & --- 577,583 ---- ------------------ function Unblocked_By ! (Interrupt : Interrupt_ID) return System.Tasking.Task_ID is begin if Is_Reserved (Interrupt) then Raise_Exception (Program_Error'Identity, "Interrupt" & *************** package body System.Interrupts is *** 723,731 **** task body Interrupt_Manager is ! ---------------------- ! -- Local Variables -- ! ---------------------- Intwait_Mask : aliased IMNG.Interrupt_Mask; Ret_Interrupt : Interrupt_ID; --- 621,629 ---- task body Interrupt_Manager is ! --------------------- ! -- Local Variables -- ! --------------------- Intwait_Mask : aliased IMNG.Interrupt_Mask; Ret_Interrupt : Interrupt_ID; *************** package body System.Interrupts is *** 756,770 **** New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID; Static : in Boolean; ! Restoration : in Boolean := False) ! is begin if User_Entry (Interrupt).T /= Null_Task then - -- In case we have an Interrupt Entry already installed. -- raise a program error. (propagate it to the caller). - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "An interrupt is already installed"); end if; --- 654,665 ---- New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID; Static : in Boolean; ! Restoration : in Boolean := False) is begin if User_Entry (Interrupt).T /= Null_Task then -- In case we have an Interrupt Entry already installed. -- raise a program error. (propagate it to the caller). Raise_Exception (Program_Error'Identity, "An interrupt is already installed"); end if; *************** package body System.Interrupts is *** 777,783 **** -- may be detaching a static handler to restore a dynamic one. if not Restoration and then not Static - -- Tries to overwrite a static Interrupt Handler with a -- dynamic Handler --- 672,677 ---- *************** package body System.Interrupts is *** 788,794 **** or else not Is_Registered (New_Handler)) then - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "Trying to overwrite a static Interrupt Handler with a " & "dynamic Handler"); --- 682,687 ---- *************** package body System.Interrupts is *** 841,851 **** begin if User_Entry (Interrupt).T /= Null_Task then - -- In case we have an Interrupt Entry installed. -- raise a program error. (propagate it to the caller). - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "An interrupt entry is already installed"); end if; --- 734,742 ---- *************** package body System.Interrupts is *** 855,865 **** -- status of the current_Handler. if not Static and then User_Handler (Interrupt).Static then - -- Tries to detach a static Interrupt Handler. -- raise a program error. - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "Trying to detach a static Interrupt Handler"); end if; --- 746,754 ---- *************** package body System.Interrupts is *** 932,938 **** declare Old_Handler : Parameterless_Handler; - begin select --- 821,826 ---- *************** package body System.Interrupts is *** 942,951 **** Static : in Boolean; Restoration : in Boolean := False) do - Lock_Interrupt (Self_ID, Interrupt); Unprotected_Exchange_Handler (Old_Handler, New_Handler, Interrupt, Static, Restoration); - Unlock_Interrupt (Self_ID, Interrupt); end Attach_Handler; or accept Exchange_Handler --- 830,837 ---- *************** package body System.Interrupts is *** 954,972 **** Interrupt : in Interrupt_ID; Static : in Boolean) do - Lock_Interrupt (Self_ID, Interrupt); Unprotected_Exchange_Handler (Old_Handler, New_Handler, Interrupt, Static); - Unlock_Interrupt (Self_ID, Interrupt); end Exchange_Handler; or accept Detach_Handler (Interrupt : in Interrupt_ID; Static : in Boolean) do - Lock_Interrupt (Self_ID, Interrupt); Unprotected_Detach_Handler (Interrupt, Static); - Unlock_Interrupt (Self_ID, Interrupt); end Detach_Handler; or accept Bind_Interrupt_To_Entry --- 840,854 ---- *************** package body System.Interrupts is *** 974,988 **** E : Task_Entry_Index; Interrupt : Interrupt_ID) do - Lock_Interrupt (Self_ID, Interrupt); - -- if there is a binding already (either a procedure or an -- entry), raise Program_Error (propagate it to the caller). if User_Handler (Interrupt).H /= null or else User_Entry (Interrupt).T /= Null_Task then - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "A binding for this interrupt is already present"); end if; --- 856,867 ---- *************** package body System.Interrupts is *** 1013,1028 **** POP.Wakeup (Server_ID (Interrupt), Interrupt_Server_Idle_Sleep); end if; - - Unlock_Interrupt (Self_ID, Interrupt); end Bind_Interrupt_To_Entry; or accept Detach_Interrupt_Entries (T : Task_ID) do for I in Interrupt_ID'Range loop if not Is_Reserved (I) then - Lock_Interrupt (Self_ID, I); - if User_Entry (I).T = T then -- The interrupt should no longer be ignored if --- 892,903 ---- *************** package body System.Interrupts is *** 1033,1040 **** (T => Null_Task, E => Null_Task_Entry); IMOP.Interrupt_Self_Process (IMNG.Interrupt_ID (I)); end if; - - Unlock_Interrupt (Self_ID, I); end if; end loop; --- 908,913 ---- *************** package body System.Interrupts is *** 1062,1068 **** end select; exception - -- If there is a program error we just want to propagate it -- to the caller and do not want to stop this task. --- 935,940 ---- *************** package body System.Interrupts is *** 1070,1084 **** null; when others => ! pragma Assert ! (Shutdown ("Interrupt_Manager---exception not expected")); null; end; - end loop; - - pragma Assert (Shutdown ("Interrupt_Manager---should not get here")); - end Interrupt_Manager; ----------------- --- 942,951 ---- null; when others => ! pragma Assert (False); null; end; end loop; end Interrupt_Manager; ----------------- *************** package body System.Interrupts is *** 1130,1135 **** --- 997,1006 ---- -- from status change (Unblocked -> Blocked). If that is not -- the case, we should exceute the attached Procedure or Entry. + if Single_Lock then + POP.Lock_RTS; + end if; + POP.Write_Lock (Self_ID); if User_Handler (Interrupt).H = null *************** package body System.Interrupts is *** 1143,1149 **** Self_ID.Common.State := Runnable; else - Self_ID.Common.State := Interrupt_Server_Blocked_On_Event_Flag; Ret_Interrupt := IMOP.Interrupt_Wait (Intwait_Mask'Access); Self_ID.Common.State := Runnable; --- 1014,1019 ---- *************** package body System.Interrupts is *** 1159,1167 **** --- 1029,1045 ---- POP.Unlock (Self_ID); + if Single_Lock then + POP.Unlock_RTS; + end if; + Tmp_Handler.all; POP.Write_Lock (Self_ID); + if Single_Lock then + POP.Lock_RTS; + end if; + elsif User_Entry (Interrupt).T /= Null_Task then Tmp_ID := User_Entry (Interrupt).T; Tmp_Entry_Index := User_Entry (Interrupt).E; *************** package body System.Interrupts is *** 1170,1191 **** POP.Unlock (Self_ID); System.Tasking.Rendezvous.Call_Simple (Tmp_ID, Tmp_Entry_Index, System.Null_Address); POP.Write_Lock (Self_ID); end if; end if; end if; POP.Unlock (Self_ID); System.Tasking.Initialization.Undefer_Abort (Self_ID); -- Undefer abort here to allow a window for this task -- to be aborted at the time of system shutdown. end loop; - - pragma Assert (Shutdown ("Server_Task---should not get here")); end Server_Task; ------------------------------------- --- 1048,1080 ---- POP.Unlock (Self_ID); + if Single_Lock then + POP.Unlock_RTS; + end if; + System.Tasking.Rendezvous.Call_Simple (Tmp_ID, Tmp_Entry_Index, System.Null_Address); POP.Write_Lock (Self_ID); + + if Single_Lock then + POP.Lock_RTS; + end if; end if; end if; end if; POP.Unlock (Self_ID); + + if Single_Lock then + POP.Unlock_RTS; + end if; + System.Tasking.Initialization.Undefer_Abort (Self_ID); -- Undefer abort here to allow a window for this task -- to be aborted at the time of system shutdown. end loop; end Server_Task; ------------------------------------- *************** package body System.Interrupts is *** 1238,1245 **** procedure Install_Handlers (Object : access Static_Interrupt_Protection; ! New_Handlers : in New_Handler_Array) ! is begin for N in New_Handlers'Range loop --- 1127,1133 ---- procedure Install_Handlers (Object : access Static_Interrupt_Protection; ! New_Handlers : in New_Handler_Array) is begin for N in New_Handlers'Range loop *************** begin *** 1267,1278 **** Interrupt_Manager_ID := To_System (Interrupt_Manager'Identity); - -- Initialize the lock L. - - Initialization.Defer_Abort (Self); - POP.Initialize_Lock (L'Access, POP.ATCB_Level); - Initialization.Undefer_Abort (Self); - -- During the elaboration of this package body we want RTS to -- inherit the interrupt mask from the Environment Task. --- 1155,1160 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vintman.adb gcc-3.3/gcc/ada/5vintman.adb *** gcc-3.2.3/gcc/ada/5vintman.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/5vintman.adb 2002-03-14 10:58:40.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-2000, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- *************** package body System.Interrupt_Management *** 50,57 **** use System.OS_Interface; use type unsigned_long; - type Interrupt_List is array (Interrupt_ID range <>) of Interrupt_ID; - --------------------------- -- Initialize_Interrupts -- --------------------------- --- 49,54 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vintman.ads gcc-3.3/gcc/ada/5vintman.ads *** gcc-3.2.3/gcc/ada/5vintman.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5vintman.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vmastop.adb gcc-3.3/gcc/ada/5vmastop.adb *** gcc-3.2.3/gcc/ada/5vmastop.adb 2001-10-02 13:42:28.000000000 +0000 --- gcc-3.3/gcc/ada/5vmastop.adb 2002-03-14 10:58:40.000000000 +0000 *************** *** 7,15 **** -- B o d y -- -- (Version for Alpha/VMS) -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 2001 Ada Core Technologies, 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- -- --- 7,14 ---- -- B o d y -- -- (Version for Alpha/VMS) -- -- -- -- -- ! -- Copyright (C) 2001-2002 Ada Core Technologies, 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- -- *************** package body System.Machine_State_Operat *** 65,77 **** end record; for ICB_Fflags_Bits_Type'Size use 24; - ICB_Fflags_Bits_Type_Init : constant ICB_Fflags_Bits_Type := - (ExceptIon_Frame => False, - Ast_Frame => False, - Bottom_Of_STACK => False, - Base_Frame => False, - Filler_1 => 0); - type ICB_Hdr_Quad_Type is record Context_Length : Unsigned_Longword; Fflags_Bits : ICB_Fflags_Bits_Type; --- 64,69 ---- *************** package body System.Machine_State_Operat *** 85,95 **** end record; for ICB_Hdr_Quad_Type'Size use 64; - ICB_Hdr_Quad_Type_Init : constant ICB_Hdr_Quad_Type := - (Context_Length => 0, - Fflags_Bits => ICB_Fflags_Bits_Type_Init, - Block_Version => 0); - type Invo_Context_Blk_Type is record -- -- The first quadword contains: --- 77,82 ---- *************** package body System.Machine_State_Operat *** 150,165 **** end record; for Invo_Context_Blk_Type'Size use 4352; - Invo_Context_Blk_Type_Init : constant Invo_Context_Blk_Type := - (Hdr_Quad => ICB_Hdr_Quad_Type_Init, - Procedure_Descriptor => (0, 0), - Program_Counter => 0, - Processor_Status => 0, - Ireg => (others => (0, 0)), - Freg => (others => (0, 0)), - System_Defined => (others => (0, 0)), - Filler_1 => (others => ASCII.NUL)); - subtype Invo_Handle_Type is Unsigned_Longword; type Invo_Handle_Access_Type is access all Invo_Handle_Type; --- 137,142 ---- *************** package body System.Machine_State_Operat *** 172,180 **** function To_Machine_State is new Unchecked_Conversion (System.Address, Machine_State); - function To_Code_Loc is new Unchecked_Conversion - (Unsigned_Longword, Code_Loc); - ---------------------------- -- Allocate_Machine_State -- ---------------------------- --- 149,154 ---- *************** package body System.Machine_State_Operat *** 244,254 **** ------------------------ procedure Free_Machine_State (M : in out Machine_State) is - procedure Gnat_Free (M : in Invo_Handle_Access_Type); - pragma Import (C, Gnat_Free, "__gnat_free"); - begin ! Gnat_Free (To_Invo_Handle_Access (M)); M := Machine_State (Null_Address); end Free_Machine_State; --- 218,225 ---- ------------------------ procedure Free_Machine_State (M : in out Machine_State) is begin ! Memory.Free (Address (M)); M := Machine_State (Null_Address); end Free_Machine_State; diff -Nrc3pad gcc-3.2.3/gcc/ada/5vosinte.adb gcc-3.3/gcc/ada/5vosinte.adb *** gcc-3.2.3/gcc/ada/5vosinte.adb 2001-10-02 13:42:28.000000000 +0000 --- gcc-3.3/gcc/ada/5vosinte.adb 2002-03-14 10:58:40.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2000 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vosinte.ads gcc-3.3/gcc/ada/5vosinte.ads *** gcc-3.2.3/gcc/ada/5vosinte.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5vosinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vosprim.adb gcc-3.3/gcc/ada/5vosprim.adb *** gcc-3.2.3/gcc/ada/5vosprim.adb 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5vosprim.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vosprim.ads gcc-3.3/gcc/ada/5vosprim.ads *** gcc-3.2.3/gcc/ada/5vosprim.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5vosprim.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vparame.ads gcc-3.3/gcc/ada/5vparame.ads *** gcc-3.2.3/gcc/ada/5vparame.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5vparame.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** pragma Pure (Parameters); *** 133,136 **** --- 132,190 ---- Garbage_Collected : constant Boolean := False; -- The storage mode for this system (release on program exit) + --------------------- + -- Tasking Profile -- + --------------------- + + -- In the following sections, constant parameters are defined to + -- allow some optimizations within the tasking run time based on + -- restrictions on the tasking features. + + ---------------------- + -- Locking Strategy -- + ---------------------- + + Single_Lock : constant Boolean := True; + -- Indicates whether a single lock should be used within the tasking + -- run-time to protect internal structures. If True, a single lock + -- will be used, meaning less locking/unlocking operations, but also + -- more global contention. In general, Single_Lock should be set to + -- True on single processor machines, and to False to multi-processor + -- systems, but this can vary from application to application and also + -- depends on the scheduling policy. + + ------------------- + -- Task Abortion -- + ------------------- + + No_Abort : constant Boolean := False; + -- This constant indicates whether abort statements and asynchronous + -- transfer of control (ATC) are disallowed. If set to True, it is + -- assumed that neither construct is used, and the run time does not + -- need to defer/undefer abort and check for pending actions at + -- completion points. A value of True for No_Abort corresponds to: + -- pragma Restrictions (No_Abort_Statements); + -- pragma Restrictions (Max_Asynchronous_Select_Nesting => 0); + + ---------------------- + -- Dynamic Priority -- + ---------------------- + + Dynamic_Priority_Support : constant Boolean := True; + -- This constant indicates whether dynamic changes of task priorities + -- are allowed (True means normal RM mode in which such changes are + -- allowed). In particular, if this is False, then we do not need to + -- poll for pending base priority changes at every abort completion + -- point. A value of False for Dynamic_Priority_Support corresponds + -- to pragma Restrictions (No_Dynamic_Priorities); + + -------------------- + -- Runtime Traces -- + -------------------- + + Runtime_Traces : constant Boolean := False; + -- This constant indicates whether the runtime outputs traces to a + -- predefined output or not (True means that traces are output). + -- See System.Traces for more details. + end System.Parameters; diff -Nrc3pad gcc-3.2.3/gcc/ada/5vsystem.ads gcc-3.3/gcc/ada/5vsystem.ads *** gcc-3.2.3/gcc/ada/5vsystem.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5vsystem.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (OpenVMS DEC Threads Version) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (OpenVMS DEC Threads Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 92,118 **** -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 91,104 ---- -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 130,137 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := False; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; diff -Nrc3pad gcc-3.2.3/gcc/ada/5vtaprop.adb gcc-3.3/gcc/ada/5vtaprop.adb *** gcc-3.2.3/gcc/ada/5vtaprop.adb 2001-12-16 01:13:29.000000000 +0000 --- gcc-3.3/gcc/ada/5vtaprop.adb 2002-03-14 10:58:41.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** package body System.Task_Primitives.Oper *** 94,101 **** ATCB_Key : aliased pthread_key_t; -- Key used to find the Ada Task_ID associated with a thread ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. --- 92,101 ---- ATCB_Key : aliased pthread_key_t; -- Key used to find the Ada Task_ID associated with a thread ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. *************** package body System.Task_Primitives.Oper *** 170,176 **** -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as All_Tasks_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. --- 170,176 ---- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. *************** package body System.Task_Primitives.Oper *** 244,250 **** procedure Finalize_Lock (L : access Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_destroy (L.L'Access); pragma Assert (Result = 0); --- 244,249 ---- *************** package body System.Task_Primitives.Oper *** 252,258 **** procedure Finalize_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_destroy (L); pragma Assert (Result = 0); --- 251,256 ---- *************** package body System.Task_Primitives.Oper *** 289,308 **** -- Set_Priority (Self_ID, System.Any_Priority (L.Prio)); end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Write_Lock; --------------- --- 287,310 ---- -- Set_Priority (Self_ID, System.Any_Priority (L.Prio)); end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 320,359 **** procedure Unlock (L : access Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_unlock (L.L'Access); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Unlock; ! ------------- ! -- Sleep -- ! ------------- ! procedure Sleep (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) is Result : Interfaces.C.int; - begin ! pragma Assert (Self_ID = Self); ! Result := pthread_cond_wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access); -- EINTR is not considered a failure. pragma Assert (Result = 0 or else Result = EINTR); --- 322,368 ---- procedure Unlock (L : access Lock) is Result : Interfaces.C.int; begin Result := pthread_mutex_unlock (L.L'Access); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); ! end if; end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Unlock; ! ----------- ! -- Sleep -- ! ----------- ! procedure Sleep ! (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) ! is Result : Interfaces.C.int; begin ! if Single_Lock then ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! else ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; ! -- EINTR is not considered a failure. pragma Assert (Result = 0 or else Result = EINTR); *************** package body System.Task_Primitives.Oper *** 369,378 **** -- Timed_Sleep -- ----------------- - -- This is for use within the run-time system, so abort is - -- assumed to be already deferred, and the caller should be - -- holding its own ATCB lock. - procedure Timed_Sleep (Self_ID : Task_ID; Time : Duration; --- 378,383 ---- *************** package body System.Task_Primitives.Oper *** 392,398 **** Sleep_Time := To_OS_Time (Time, Mode); if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level ! or else Self_ID.Pending_Priority_Change then return; end if; --- 397,403 ---- Sleep_Time := To_OS_Time (Time, Mode); if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level ! or else Self_ID.Pending_Priority_Change then return; end if; *************** package body System.Task_Primitives.Oper *** 407,414 **** raise Storage_Error; end if; ! Result := pthread_cond_wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access); if not Self_ID.Common.LL.AST_Pending then Timedout := True; --- 412,427 ---- raise Storage_Error; end if; ! if Single_Lock then ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! ! else ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; ! ! Yielded := True; if not Self_ID.Common.LL.AST_Pending then Timedout := True; *************** package body System.Task_Primitives.Oper *** 416,456 **** Sys_Cantim (Status, To_Address (Self_ID), 0); pragma Assert ((Status and 1) = 1); end if; - end Timed_Sleep; ----------------- -- Timed_Delay -- ----------------- - -- This is for use in implementing delay statements, so - -- we assume the caller is abort-deferred but is holding - -- no locks. - procedure Timed_Delay ! (Self_ID : Task_ID; ! Time : Duration; ! Mode : ST.Delay_Modes) is Sleep_Time : OS_Time; Result : Interfaces.C.int; Status : Cond_Value_Type; begin - -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to ! -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; Write_Lock (Self_ID); ! if not (Time = 0.0 and then Mode = Relative) then ! Sleep_Time := To_OS_Time (Time, Mode); if Mode = Relative or else OS_Clock < Sleep_Time then - Self_ID.Common.State := Delay_Sleep; Self_ID.Common.LL.AST_Pending := True; --- 429,466 ---- Sys_Cantim (Status, To_Address (Self_ID), 0); pragma Assert ((Status and 1) = 1); end if; end Timed_Sleep; ----------------- -- Timed_Delay -- ----------------- procedure Timed_Delay ! (Self_ID : Task_ID; ! Time : Duration; ! Mode : ST.Delay_Modes) is Sleep_Time : OS_Time; Result : Interfaces.C.int; Status : Cond_Value_Type; + Yielded : Boolean := False; begin -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to ! -- check for pending abort and priority change below! ! ! if Single_Lock then ! Lock_RTS; ! end if; SSL.Abort_Defer.all; Write_Lock (Self_ID); ! if Time /= 0.0 or else Mode /= Relative then Sleep_Time := To_OS_Time (Time, Mode); if Mode = Relative or else OS_Clock < Sleep_Time then Self_ID.Common.State := Delay_Sleep; Self_ID.Common.LL.AST_Pending := True; *************** package body System.Task_Primitives.Oper *** 475,494 **** exit; end if; ! Result := pthread_cond_wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access); ! exit when not Self_ID.Common.LL.AST_Pending; end loop; Self_ID.Common.State := Runnable; - end if; end if; Unlock (Self_ID); ! Result := sched_yield; SSL.Abort_Undefer.all; end Timed_Delay; --- 485,517 ---- exit; end if; ! if Single_Lock then ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! else ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; ! Yielded := True; + exit when not Self_ID.Common.LL.AST_Pending; end loop; Self_ID.Common.State := Runnable; end if; end if; Unlock (Self_ID); ! ! if Single_Lock then ! Unlock_RTS; ! end if; ! ! if not Yielded then ! Result := sched_yield; ! end if; ! SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 514,520 **** procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is Result : Interfaces.C.int; - begin Result := pthread_cond_signal (T.Common.LL.CV'Access); pragma Assert (Result = 0); --- 537,542 ---- *************** package body System.Task_Primitives.Oper *** 526,532 **** procedure Yield (Do_Yield : Boolean := True) is Result : Interfaces.C.int; - begin if Do_Yield then Result := sched_yield; --- 548,553 ---- *************** package body System.Task_Primitives.Oper *** 538,552 **** ------------------ procedure Set_Priority ! (T : Task_ID; ! Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is ! Result : Interfaces.C.int; ! Param : aliased struct_sched_param; begin T.Common.Current_Priority := Prio; ! Param.sched_priority := Interfaces.C.int (Underlying_Priorities (Prio)); if Time_Slice_Val > 0 then Result := pthread_setschedparam --- 559,573 ---- ------------------ procedure Set_Priority ! (T : Task_ID; ! Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is ! Result : Interfaces.C.int; ! Param : aliased struct_sched_param; begin T.Common.Current_Priority := Prio; ! Param.sched_priority := Interfaces.C.int (Underlying_Priorities (Prio)); if Time_Slice_Val > 0 then Result := pthread_setschedparam *************** package body System.Task_Primitives.Oper *** 579,585 **** procedure Enter_Task (Self_ID : Task_ID) is Result : Interfaces.C.int; - begin Self_ID.Common.LL.Thread := pthread_self; --- 600,605 ---- *************** package body System.Task_Primitives.Oper *** 591,605 **** Result := pthread_setspecific (ATCB_Key, To_Address (Self_ID)); pragma Assert (Result = 0); ! Lock_All_Tasks_List; ! for I in Known_Tasks'Range loop ! if Known_Tasks (I) = null then ! Known_Tasks (I) := Self_ID; ! Self_ID.Known_Tasks_Index := I; exit; end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 611,627 ---- Result := pthread_setspecific (ATCB_Key, To_Address (Self_ID)); pragma Assert (Result = 0); ! Lock_RTS; ! ! for J in Known_Tasks'Range loop ! if Known_Tasks (J) = null then ! Known_Tasks (J) := Self_ID; ! Self_ID.Known_Tasks_Index := J; exit; end if; end loop; ! ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 621,673 **** Cond_Attr : aliased pthread_condattr_t; begin ! Result := pthread_mutexattr_init (Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! ! -- Don't use, see comment in s-osinte.ads about ERRORCHECK mutexes. ! -- Result := pthread_mutexattr_settype_np ! -- (Mutex_Attr'Access, PTHREAD_MUTEX_ERRORCHECK_NP); ! -- pragma Assert (Result = 0); ! ! -- Result := pthread_mutexattr_setprotocol ! -- (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT); ! -- pragma Assert (Result = 0); ! -- Result := pthread_mutexattr_setprioceiling ! -- (Mutex_Attr'Access, Interfaces.C.int (System.Any_Priority'Last)); ! -- pragma Assert (Result = 0); ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Succeeded := False; ! return; end if; - Result := pthread_mutexattr_destroy (Mutex_Attr'Access); - pragma Assert (Result = 0); - Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! Succeeded := False; ! return; end if; - Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, - Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - if Result = 0 then Succeeded := True; Self_ID.Common.LL.Exc_Stack_Ptr := new Exc_Stack_T; --- 643,676 ---- Cond_Attr : aliased pthread_condattr_t; begin ! if not Single_Lock then ! Result := pthread_mutexattr_init (Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! end if; ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! Result := pthread_mutexattr_destroy (Mutex_Attr'Access); ! pragma Assert (Result = 0); end if; Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, ! Cond_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); end if; if Result = 0 then Succeeded := True; Self_ID.Common.LL.Exc_Stack_Ptr := new Exc_Stack_T; *************** package body System.Task_Primitives.Oper *** 676,683 **** Self_ID.Common.LL.Exc_Stack_Ptr (Exc_Stack_T'Last)'Address); else ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); Succeeded := False; end if; --- 679,689 ---- Self_ID.Common.LL.Exc_Stack_Ptr (Exc_Stack_T'Last)'Address); else ! if not Single_Lock then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Succeeded := False; end if; *************** package body System.Task_Primitives.Oper *** 777,789 **** (Exc_Stack_T, Exc_Stack_Ptr_T); begin ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; Free (T.Common.LL.Exc_Stack_Ptr); Free (Tmp); end Finalize_TCB; --- 783,800 ---- (Exc_Stack_T, Exc_Stack_Ptr_T); begin ! if not Single_Lock then ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); + if T.Known_Tasks_Index /= -1 then Known_Tasks (T.Known_Tasks_Index) := null; end if; + Free (T.Common.LL.Exc_Stack_Ptr); Free (Tmp); end Finalize_TCB; *************** package body System.Task_Primitives.Oper *** 851,873 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 862,884 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 899,905 **** begin Environment_Task_ID := Environment_Task; ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); -- Initialize the lock used to synchronize chain of all ATCBs. Enter_Task (Environment_Task); --- 910,916 ---- begin Environment_Task_ID := Environment_Task; ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); -- Initialize the lock used to synchronize chain of all ATCBs. Enter_Task (Environment_Task); diff -Nrc3pad gcc-3.2.3/gcc/ada/5vtaspri.ads gcc-3.3/gcc/ada/5vtaspri.ads *** gcc-3.2.3/gcc/ada/5vtaspri.ads 2002-05-04 03:27:16.000000000 +0000 --- gcc-3.3/gcc/ada/5vtaspri.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vtpopde.adb gcc-3.3/gcc/ada/5vtpopde.adb *** gcc-3.2.3/gcc/ada/5vtpopde.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/5vtpopde.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 2,15 **** -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S -- ! -- . D E C -- -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.2 $ -- -- ! -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 2,13 ---- -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASK_PRIMITIVES.OPERATIONS.DEC -- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2000-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 33,43 **** -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package is for OpenVMS/Alpha ! -- with System.OS_Interface; with System.Tasking; with Unchecked_Conversion; package body System.Task_Primitives.Operations.DEC is use System.OS_Interface; --- 31,43 ---- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ + -- This package is for OpenVMS/Alpha ! with System.OS_Interface; with System.Tasking; with Unchecked_Conversion; + package body System.Task_Primitives.Operations.DEC is use System.OS_Interface; *************** package body System.Task_Primitives.Oper *** 45,60 **** use System.Aux_DEC; use type Interfaces.C.int; ! -- The FAB_RAB_Type specifieds where the context field (the calling -- task) is stored. Other fields defined for FAB_RAB aren't need and -- so are ignored. ! type FAB_RAB_Type is ! record CTX : Unsigned_Longword; end record; ! for FAB_RAB_Type use ! record CTX at 24 range 0 .. 31; end record; --- 45,59 ---- use System.Aux_DEC; use type Interfaces.C.int; ! -- The FAB_RAB_Type specifies where the context field (the calling -- task) is stored. Other fields defined for FAB_RAB aren't need and -- so are ignored. ! ! type FAB_RAB_Type is record CTX : Unsigned_Longword; end record; ! for FAB_RAB_Type use record CTX at 24 range 0 .. 31; end record; *************** package body System.Task_Primitives.Oper *** 80,87 **** --------------------------- procedure Interrupt_AST_Handler (ID : Address) is ! Result : Interfaces.C.int; ! AST_Self_ID : Task_ID := To_Task_Id (ID); begin Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access); pragma Assert (Result = 0); --- 79,87 ---- --------------------------- procedure Interrupt_AST_Handler (ID : Address) is ! Result : Interfaces.C.int; ! AST_Self_ID : Task_ID := To_Task_Id (ID); ! begin Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access); pragma Assert (Result = 0); *************** package body System.Task_Primitives.Oper *** 92,99 **** --------------------- procedure RMS_AST_Handler (ID : Address) is ! AST_Self_ID : Task_ID := To_Task_Id (To_FAB_RAB (ID).CTX); ! Result : Interfaces.C.int; begin AST_Self_ID.Common.LL.AST_Pending := False; Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access); --- 92,100 ---- --------------------- procedure RMS_AST_Handler (ID : Address) is ! AST_Self_ID : Task_ID := To_Task_Id (To_FAB_RAB (ID).CTX); ! Result : Interfaces.C.int; ! begin AST_Self_ID.Common.LL.AST_Pending := False; Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access); *************** package body System.Task_Primitives.Oper *** 106,111 **** --- 107,113 ---- function Self return Unsigned_Longword is Self_ID : Task_ID := Self; + begin Self_ID.Common.LL.AST_Pending := True; return To_Unsigned_Longword (Self); *************** package body System.Task_Primitives.Oper *** 116,123 **** ------------------------- procedure Starlet_AST_Handler (ID : Address) is ! Result : Interfaces.C.int; ! AST_Self_ID : Task_ID := To_Task_Id (ID); begin AST_Self_ID.Common.LL.AST_Pending := False; Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access); --- 118,126 ---- ------------------------- procedure Starlet_AST_Handler (ID : Address) is ! Result : Interfaces.C.int; ! AST_Self_ID : Task_ID := To_Task_Id (ID); ! begin AST_Self_ID.Common.LL.AST_Pending := False; Result := pthread_cond_signal_int_np (AST_Self_ID.Common.LL.CV'Access); *************** package body System.Task_Primitives.Oper *** 130,141 **** --- 133,147 ---- procedure Task_Synch is Synch_Self_ID : Task_ID := Self; + begin Write_Lock (Synch_Self_ID); Synch_Self_ID.Common.State := AST_Server_Sleep; + while Synch_Self_ID.Common.LL.AST_Pending loop Sleep (Synch_Self_ID, AST_Server_Sleep); end loop; + Synch_Self_ID.Common.State := Runnable; Unlock (Synch_Self_ID); end Task_Synch; diff -Nrc3pad gcc-3.2.3/gcc/ada/5vtpopde.ads gcc-3.3/gcc/ada/5vtpopde.ads *** gcc-3.2.3/gcc/ada/5vtpopde.ads 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/5vtpopde.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,13 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5vvaflop.adb gcc-3.3/gcc/ada/5vvaflop.adb *** gcc-3.2.3/gcc/ada/5vvaflop.adb 2002-05-04 03:27:17.000000000 +0000 --- gcc-3.3/gcc/ada/5vvaflop.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2000 Free Software Foundation, Inc. -- -- (Version for Alpha OpenVMS) -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5wgloloc.adb gcc-3.3/gcc/ada/5wgloloc.adb *** gcc-3.2.3/gcc/ada/5wgloloc.adb 2001-10-02 13:42:28.000000000 +0000 --- gcc-3.3/gcc/ada/5wgloloc.adb 2002-03-14 10:58:41.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1999-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5wintman.adb gcc-3.3/gcc/ada/5wintman.adb *** gcc-3.2.3/gcc/ada/5wintman.adb 2002-05-04 03:27:17.000000000 +0000 --- gcc-3.3/gcc/ada/5wintman.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1991-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5wmemory.adb gcc-3.3/gcc/ada/5wmemory.adb *** gcc-3.2.3/gcc/ada/5wmemory.adb 2002-05-04 03:27:17.000000000 +0000 --- gcc-3.3/gcc/ada/5wmemory.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body System.Memory is *** 214,220 **** Result := c_realloc (Ptr, Actual_Size); if Result /= System.Null_Address then ! Available_Memory := Available_Memory + Old_Size - msize (Ptr); end if; Unlock_Task.all; --- 213,219 ---- Result := c_realloc (Ptr, Actual_Size); if Result /= System.Null_Address then ! Available_Memory := Available_Memory + Old_Size - msize (Result); end if; Unlock_Task.all; diff -Nrc3pad gcc-3.2.3/gcc/ada/5wosinte.ads gcc-3.3/gcc/ada/5wosinte.ads *** gcc-3.2.3/gcc/ada/5wosinte.ads 2002-05-04 03:27:17.000000000 +0000 --- gcc-3.3/gcc/ada/5wosinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5wosprim.adb gcc-3.3/gcc/ada/5wosprim.adb *** gcc-3.2.3/gcc/ada/5wosprim.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/5wosprim.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5wsystem.ads gcc-3.3/gcc/ada/5wsystem.ads *** gcc-3.2.3/gcc/ada/5wsystem.ads 2002-05-04 03:27:17.000000000 +0000 --- gcc-3.3/gcc/ada/5wsystem.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (NT Version) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (NT Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 92,118 **** -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 91,104 ---- -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 130,137 **** --- 116,126 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; *************** private *** 198,201 **** --- 187,197 ---- Interrupt_Priority => 15); + pragma Linker_Options ("-Wl,--stack=0x2000000"); + -- This is used to change the default stack (32 MB) size for non tasking + -- programs. We change this value for GNAT on Windows here because the + -- binutils on this platform have switched to a too low value for Ada + -- programs. Note that we also set the stack size for tasking programs in + -- System.Task_Primitives.Operations. + end System; diff -Nrc3pad gcc-3.2.3/gcc/ada/5wtaprop.adb gcc-3.3/gcc/ada/5wtaprop.adb *** gcc-3.2.3/gcc/ada/5wtaprop.adb 2002-05-04 03:27:17.000000000 +0000 --- gcc-3.3/gcc/ada/5wtaprop.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** package body System.Task_Primitives.Oper *** 90,96 **** use System.Parameters; use System.OS_Primitives; ! pragma Linker_Options ("-Xlinker --stack=0x800000,0x1000"); package SSL renames System.Soft_Links; --- 89,98 ---- use System.Parameters; use System.OS_Primitives; ! pragma Link_With ("-Xlinker --stack=0x800000,0x1000"); ! -- Change the stack size (8 MB) for tasking programs on Windows. This ! -- permit to have more than 30 tasks running at the same time. Note that ! -- we set the stack size for non tasking programs on System unit. package SSL renames System.Soft_Links; *************** package body System.Task_Primitives.Oper *** 101,108 **** Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Time_Slice_Val : Integer; pragma Import (C, Time_Slice_Val, "__gl_time_slice_val"); --- 103,112 ---- Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Time_Slice_Val : Integer; pragma Import (C, Time_Slice_Val, "__gl_time_slice_val"); *************** package body System.Task_Primitives.Oper *** 132,138 **** Fake_ATCB_List : Fake_ATCB_Ptr; -- A linear linked list. ! -- The list is protected by All_Tasks_L; -- Nodes are added to this list from the front. -- Once a node is added to this list, it is never removed. --- 136,142 ---- Fake_ATCB_List : Fake_ATCB_Ptr; -- A linear linked list. ! -- The list is protected by Single_RTS_Lock; -- Nodes are added to this list from the front. -- Once a node is added to this list, it is never removed. *************** package body System.Task_Primitives.Oper *** 183,189 **** -- We dare not call anything that might require an ATCB, until -- we have the new ATCB in place. ! Write_Lock (All_Tasks_L'Access); Q := null; P := Fake_ATCB_List; --- 187,193 ---- -- We dare not call anything that might require an ATCB, until -- we have the new ATCB in place. ! Lock_RTS; Q := null; P := Fake_ATCB_List; *************** package body System.Task_Primitives.Oper *** 262,268 **** -- Must not unlock until Next_ATCB is again allocated. ! Unlock (All_Tasks_L'Access); return Self_ID; end New_Fake_ATCB; --- 266,272 ---- -- Must not unlock until Next_ATCB is again allocated. ! Unlock_RTS; return Self_ID; end New_Fake_ATCB; *************** package body System.Task_Primitives.Oper *** 474,480 **** -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is handled. ! -- Other mutexes (such as All_Tasks_Lock, Memory_Lock...) used in -- the RTS is initialized before any status change of RTS. -- Therefore raising Storage_Error in the following routines -- should be able to be handled safely. --- 478,484 ---- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is handled. ! -- Other mutexes (such as RTS_Lock, Memory_Lock...) used in -- the RTS is initialized before any status change of RTS. -- Therefore raising Storage_Error in the following routines -- should be able to be handled safely. *************** package body System.Task_Primitives.Oper *** 525,539 **** Ceiling_Violation := False; end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is begin ! EnterCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access); end Write_Lock; procedure Write_Lock (T : Task_ID) is begin ! EnterCriticalSection ! (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access); end Write_Lock; --------------- --- 529,548 ---- Ceiling_Violation := False; end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) is begin ! if not Single_Lock or else Global_Lock then ! EnterCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is begin ! if not Single_Lock then ! EnterCriticalSection ! (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 554,568 **** LeaveCriticalSection (L.Mutex'Access); end Unlock; ! procedure Unlock (L : access RTS_Lock) is begin ! LeaveCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access); end Unlock; procedure Unlock (T : Task_ID) is begin ! LeaveCriticalSection ! (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access); end Unlock; ----------- --- 563,581 ---- LeaveCriticalSection (L.Mutex'Access); end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is begin ! if not Single_Lock or else Global_Lock then ! LeaveCriticalSection (CRITICAL_SECTION (L.all)'Unrestricted_Access); ! end if; end Unlock; procedure Unlock (T : Task_ID) is begin ! if not Single_Lock then ! LeaveCriticalSection ! (CRITICAL_SECTION (T.Common.LL.L)'Unrestricted_Access); ! end if; end Unlock; ----------- *************** package body System.Task_Primitives.Oper *** 575,581 **** begin pragma Assert (Self_ID = Self); ! Cond_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); if Self_ID.Deferral_Level = 0 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level --- 588,598 ---- begin pragma Assert (Self_ID = Self); ! if Single_Lock then ! Cond_Wait (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! else ! Cond_Wait (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; if Self_ID.Deferral_Level = 0 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level *************** package body System.Task_Primitives.Oper *** 610,616 **** begin Timedout := True; ! Yielded := False; if Mode = Relative then Rel_Time := Time; --- 627,633 ---- begin Timedout := True; ! Yielded := False; if Mode = Relative then Rel_Time := Time; *************** package body System.Task_Primitives.Oper *** 625,632 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Rel_Time, Local_Timedout, Result); exit when Abs_Time <= Monotonic_Clock; --- 642,654 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! if Single_Lock then ! Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, ! Single_RTS_Lock'Access, Rel_Time, Local_Timedout, Result); ! else ! Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Rel_Time, Local_Timedout, Result); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 659,667 **** begin -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to ! -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; Write_Lock (Self_ID); if Mode = Relative then --- 681,694 ---- begin -- Only the little window between deferring abort and -- locking Self_ID is the reason we need to ! -- check for pending abort and priority change below! SSL.Abort_Defer.all; + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); if Mode = Relative then *************** package body System.Task_Primitives.Oper *** 684,691 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Rel_Time, Timedout, Result); exit when Abs_Time <= Monotonic_Clock; --- 711,723 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! if Single_Lock then ! Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, ! Single_RTS_Lock'Access, Rel_Time, Timedout, Result); ! else ! Cond_Timed_Wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Rel_Time, Timedout, Result); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 696,701 **** --- 728,738 ---- end if; Unlock (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + Yield; SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 833,839 **** Self_ID.Common.LL.Thread_Id := GetCurrentThreadId; ! Lock_All_Tasks_List; for J in Known_Tasks'Range loop if Known_Tasks (J) = null then --- 870,876 ---- Self_ID.Common.LL.Thread_Id := GetCurrentThreadId; ! Lock_RTS; for J in Known_Tasks'Range loop if Known_Tasks (J) = null then *************** package body System.Task_Primitives.Oper *** 843,849 **** end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 880,886 ---- end if; end loop; ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 855,868 **** return new Ada_Task_Control_Block (Entry_Num); end New_ATCB; ! ---------------------- ! -- Initialize_TCB -- ! ---------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is begin Initialize_Cond (Self_ID.Common.LL.CV'Access); ! Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level); Succeeded := True; end Initialize_TCB; --- 892,909 ---- return new Ada_Task_Control_Block (Entry_Num); end New_ATCB; ! -------------------- ! -- Initialize_TCB -- ! -------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is begin Initialize_Cond (Self_ID.Common.LL.CV'Access); ! ! if not Single_Lock then ! Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level); ! end if; ! Succeeded := True; end Initialize_TCB; *************** package body System.Task_Primitives.Oper *** 879,890 **** is hTask : HANDLE; TaskId : aliased DWORD; - - -- ??? The fact that we can't use PVOID because the compiler - -- gives a "PVOID is not visible" error is a GNAT bug. - -- The strange thing is that the file compiles fine during a regular - -- build. - pTaskParameter : System.OS_Interface.PVOID; dwStackSize : DWORD; Result : DWORD; --- 920,925 ---- *************** package body System.Task_Primitives.Oper *** 951,957 **** Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! Finalize_Lock (T.Common.LL.L'Access); Finalize_Cond (T.Common.LL.CV'Access); if T.Known_Tasks_Index /= -1 then --- 986,995 ---- Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! if not Single_Lock then ! Finalize_Lock (T.Common.LL.L'Access); ! end if; ! Finalize_Cond (T.Common.LL.CV'Access); if T.Known_Tasks_Index /= -1 then *************** package body System.Task_Primitives.Oper *** 996,1018 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ---------------- -- Initialize -- --- 1034,1056 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ---------------- -- Initialize -- *************** package body System.Task_Primitives.Oper *** 1032,1038 **** -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); Environment_Task.Common.LL.Thread := GetCurrentThread; Enter_Task (Environment_Task); --- 1070,1076 ---- -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Environment_Task.Common.LL.Thread := GetCurrentThread; Enter_Task (Environment_Task); diff -Nrc3pad gcc-3.2.3/gcc/ada/5wtaspri.ads gcc-3.3/gcc/ada/5wtaspri.ads *** gcc-3.2.3/gcc/ada/5wtaspri.ads 2002-05-04 03:27:17.000000000 +0000 --- gcc-3.3/gcc/ada/5wtaspri.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5ysystem.ads gcc-3.3/gcc/ada/5ysystem.ads *** gcc-3.2.3/gcc/ada/5ysystem.ads 2002-05-04 03:27:17.000000000 +0000 --- gcc-3.3/gcc/ada/5ysystem.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 5,15 **** -- S Y S T E M -- -- -- -- S p e c -- ! -- (VXWORKS Version PPC, Sparc64) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 5,14 ---- -- S Y S T E M -- -- -- -- S p e c -- ! -- (VXWORKS Version PPC) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 32; ! Memory_Size : constant := 2 ** 32; -- Address comparison *************** pragma Pure (System); *** 88,127 **** -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := ! Bit_Order'Val (Standard'Default_Bit_Order); -- Priority-related Declarations (RM D.1) ! -- 256 is reserved for the VxWorks kernel ! -- 248 - 255 correspond to hardware interrupt levels 0 .. 7 ! -- 247 is a catchall default "interrupt" priority for signals, allowing ! -- higher priority than normal tasks, but lower than hardware ! -- priority levels. Protected Object ceilings can override ! -- these values ! -- 246 is used by the Interrupt_Manager task Max_Interrupt_Priority : constant Positive := 255; ! Max_Priority : constant Positive := 245; ! ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 87,112 ---- -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := High_Order_First; -- Priority-related Declarations (RM D.1) ! -- 256 is reserved for the VxWorks kernel ! -- 248 - 255 correspond to hardware interrupt levels 0 .. 7 ! -- 247 is a catchall default "interrupt" priority for signals, ! -- allowing higher priority than normal tasks, but lower than ! -- hardware priority levels. Protected Object ceilings can ! -- override these values. ! -- 246 is used by the Interrupt_Manager task + Max_Priority : constant Positive := 245; Max_Interrupt_Priority : constant Positive := 255; ! subtype Any_Priority is Integer range 0 .. 255; ! subtype Priority is Any_Priority range 0 .. 245; ! subtype Interrupt_Priority is Any_Priority range 246 .. 255; ! Default_Priority : constant Priority := 122; private *************** private *** 139,146 **** --- 124,134 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := False; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := False; diff -Nrc3pad gcc-3.2.3/gcc/ada/5zinterr.adb gcc-3.3/gcc/ada/5zinterr.adb *** gcc-3.2.3/gcc/ada/5zinterr.adb 2002-05-04 03:27:18.000000000 +0000 --- gcc-3.3/gcc/ada/5zinterr.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 45,57 **** -- hardware interrupts, which may be masked or unmasked using routined -- interfaced to the relevant VxWorks system calls. - -- Note : Direct calls to sigaction, sigprocmask, pthread_sigsetmask or any - -- other low-level interface that changes the signal action or - -- signal mask needs careful consideration. - -- One may achieve the effect of system calls first masking RTS blocked - -- (by calling Block_Interrupt) for the signal under consideration. - -- This will make all the tasks in RTS blocked for the signal. - -- Once we associate a Signal_Server_Task with an signal, the task never -- goes away, and we never remove the association. On the other hand, it -- is more convenient to terminate an associated Interrupt_Server_Task --- 44,49 ---- *************** *** 71,85 **** -- service requests are ensured via user calls to the Interrupt_Manager -- entries. ! -- This is the VxWorks version of this package, supporting both signals ! -- and vectored hardware interrupts. with Unchecked_Conversion; with System.OS_Interface; use System.OS_Interface; - with System.VxWorks; - with Interfaces.VxWorks; with Ada.Task_Identification; --- 63,75 ---- -- service requests are ensured via user calls to the Interrupt_Manager -- entries. ! -- This is the VxWorks version of this package, supporting vectored hardware ! -- interrupts. with Unchecked_Conversion; with System.OS_Interface; use System.OS_Interface; with Interfaces.VxWorks; with Ada.Task_Identification; *************** with Ada.Task_Identification; *** 88,126 **** with Ada.Exceptions; -- used for Raise_Exception - with System.Task_Primitives; - -- used for RTS_Lock - -- Self - - with System.Interrupt_Management; - -- used for Reserve - -- Interrupt_ID - -- Interrupt_Mask - -- Abort_Task_Interrupt - - with System.Interrupt_Management.Operations; - -- used for Thread_Block_Interrupt - -- Thread_Unblock_Interrupt - -- Install_Default_Action - -- Install_Ignore_Action - -- Copy_Interrupt_Mask - -- Set_Interrupt_Mask - -- Empty_Interrupt_Mask - -- Fill_Interrupt_Mask - -- Add_To_Interrupt_Mask - -- Delete_From_Interrupt_Mask - -- Interrupt_Wait - -- Interrupt_Self_Process - -- Get_Interrupt_Mask - -- Set_Interrupt_Mask - -- IS_Member - -- Environment_Mask - -- All_Tasks_Mask - pragma Elaborate_All (System.Interrupt_Management.Operations); - - with System.Error_Reporting; - -- used for Shutdown - with System.Task_Primitives.Operations; -- used for Write_Lock -- Unlock --- 78,83 ---- *************** with System.Task_Primitives.Operations; *** 129,137 **** -- Sleep -- Initialize_Lock - with System.Task_Primitives.Interrupt_Operations; - -- used for Set_Interrupt_ID - with System.Storage_Elements; -- used for To_Address -- To_Integer --- 86,91 ---- *************** with System.Tasking.Rendezvous; *** 151,171 **** -- used for Call_Simple pragma Elaborate_All (System.Tasking.Rendezvous); - with System.Tasking.Initialization; - -- used for Defer_Abort - -- Undefer_Abort - package body System.Interrupts is use Tasking; - use System.Error_Reporting; use Ada.Exceptions; package PRI renames System.Task_Primitives; package POP renames System.Task_Primitives.Operations; - package PIO renames System.Task_Primitives.Interrupt_Operations; - package IMNG renames System.Interrupt_Management; - package IMOP renames System.Interrupt_Management.Operations; function To_Ada is new Unchecked_Conversion (System.Tasking.Task_ID, Ada.Task_Identification.Task_Id); --- 105,117 ---- *************** package body System.Interrupts is *** 177,188 **** -- Local Tasks -- ----------------- ! -- WARNING: System.Tasking.Utilities performs calls to this task -- with low-level constructs. Do not change this spec without synchro- -- nizing it. task Interrupt_Manager is ! entry Initialize (Mask : IMNG.Interrupt_Mask); entry Attach_Handler (New_Handler : Parameterless_Handler; --- 123,134 ---- -- Local Tasks -- ----------------- ! -- WARNING: System.Tasking.Stages performs calls to this task -- with low-level constructs. Do not change this spec without synchro- -- nizing it. task Interrupt_Manager is ! entry Detach_Interrupt_Entries (T : Task_ID); entry Attach_Handler (New_Handler : Parameterless_Handler; *************** package body System.Interrupts is *** 205,222 **** E : Task_Entry_Index; Interrupt : Interrupt_ID); - entry Detach_Interrupt_Entries (T : Task_ID); - pragma Interrupt_Priority (System.Interrupt_Priority'First); end Interrupt_Manager; - task type Signal_Server_Task (Interrupt : Interrupt_ID) is - pragma Interrupt_Priority (System.Interrupt_Priority'First + 1); - end Signal_Server_Task; - -- Server task for signal handling - - type Signal_Task_Access is access Signal_Server_Task; - task type Interrupt_Server_Task (Interrupt : Interrupt_ID; Int_Sema : SEM_ID) is -- Server task for vectored hardware interrupt handling --- 151,159 ---- *************** package body System.Interrupts is *** 274,306 **** -- is needed to determine whether to create a new Server_Task. Semaphore_ID_Map : array ! (Interrupt_ID range 0 .. System.VxWorks.Num_HW_Interrupts) of SEM_ID := ! (others => 0); -- Array of binary semaphores associated with vectored interrupts -- Note that the last bound should be Max_HW_Interrupt, but this will raise -- Storage_Error if Num_HW_Interrupts is null, so use an extra 4 bytes -- instead. - Signal_Access_Hold : Signal_Task_Access; - -- Variable for allocating a Signal_Server_Task - Interrupt_Access_Hold : Interrupt_Task_Access; -- Variable for allocating an Interrupt_Server_Task - L : aliased PRI.RTS_Lock; - -- L protects the contents of the above tables for interrupts / signals - -- for which Server_ID (I) = Null_Task. - -- - -- If Server_ID (I) /= Null_Task then protection is via the - -- per-task (TCB) lock of Server_ID (I). - -- - -- For deadlock prevention, L should not be locked after - -- any other lock is held, hence we use PO_Level which is the highest - -- lock level for error checking. - - Task_Lock : array (Interrupt_ID) of Boolean := (others => False); - -- Booleans indicating whether the per task lock is used - Default_Handler : array (HW_Interrupt) of Interfaces.VxWorks.VOIDFUNCPTR; -- Vectored interrupt handlers installed prior to program startup. -- These are saved only when the umbrella handler is installed for --- 211,226 ---- -- is needed to determine whether to create a new Server_Task. Semaphore_ID_Map : array ! (Interrupt_ID range 0 .. System.OS_Interface.Max_HW_Interrupt) ! of SEM_ID := (others => 0); -- Array of binary semaphores associated with vectored interrupts -- Note that the last bound should be Max_HW_Interrupt, but this will raise -- Storage_Error if Num_HW_Interrupts is null, so use an extra 4 bytes -- instead. Interrupt_Access_Hold : Interrupt_Task_Access; -- Variable for allocating an Interrupt_Server_Task Default_Handler : array (HW_Interrupt) of Interfaces.VxWorks.VOIDFUNCPTR; -- Vectored interrupt handlers installed prior to program startup. -- These are saved only when the umbrella handler is installed for *************** package body System.Interrupts is *** 318,342 **** -- Unbind the handlers for hardware interrupt server tasks at program -- termination. - procedure Lock_Interrupt - (Self_ID : Task_ID; - Interrupt : Interrupt_ID); - -- Protect the tables using L or the per-task lock. Set the Boolean - -- value Task_Lock if the lock is made using per-task lock. - -- This information is needed so that Unlock_Interrupt - -- performs unlocking on the same lock. The situation we are preventing - -- is, for example, when Attach_Handler is called for the first time - -- we lock L and create an Server_Task. For a matching unlocking, if we - -- rely on the fact that there is a Server_Task, we will unlock the - -- per-task lock. - - procedure Unlock_Interrupt - (Self_ID : Task_ID; - Interrupt : Interrupt_ID); - -- Unlock interrupt previously locked by Lock_Interrupt - function Is_Registered (Handler : Parameterless_Handler) return Boolean; ! -- Needs comment ??? procedure Notify_Interrupt (Param : System.Address); -- Umbrella handler for vectored interrupts (not signals) --- 238,246 ---- -- Unbind the handlers for hardware interrupt server tasks at program -- termination. function Is_Registered (Handler : Parameterless_Handler) return Boolean; ! -- See if Handler has been "pragma"ed using Interrupt_Handler. ! -- Always consider a null handler as registered. procedure Notify_Interrupt (Param : System.Address); -- Umbrella handler for vectored interrupts (not signals) *************** package body System.Interrupts is *** 350,358 **** -- Install the runtime umbrella handler for a vectored hardware -- interrupt - function To_Signal (S : Interrupt_ID) return IMNG.Interrupt_ID; - -- Convert interrupt ID to signal number. - procedure Unimplemented (Feature : String); pragma No_Return (Unimplemented); -- Used to mark a call to an unimplemented function. Raises Program_Error --- 254,259 ---- *************** package body System.Interrupts is *** 373,380 **** procedure Attach_Handler (New_Handler : Parameterless_Handler; Interrupt : Interrupt_ID; ! Static : Boolean := False) ! is begin Check_Reserved_Interrupt (Interrupt); Interrupt_Manager.Attach_Handler (New_Handler, Interrupt, Static); --- 274,280 ---- procedure Attach_Handler (New_Handler : Parameterless_Handler; Interrupt : Interrupt_ID; ! Static : Boolean := False) is begin Check_Reserved_Interrupt (Interrupt); Interrupt_Manager.Attach_Handler (New_Handler, Interrupt, Static); *************** package body System.Interrupts is *** 394,400 **** Int_Ref : System.Address) is Interrupt : constant Interrupt_ID := ! Interrupt_ID (Storage_Elements.To_Integer (Int_Ref)); begin Check_Reserved_Interrupt (Interrupt); --- 294,300 ---- Int_Ref : System.Address) is Interrupt : constant Interrupt_ID := ! Interrupt_ID (Storage_Elements.To_Integer (Int_Ref)); begin Check_Reserved_Interrupt (Interrupt); *************** package body System.Interrupts is *** 430,438 **** --------------------- function Current_Handler ! (Interrupt : Interrupt_ID) ! return Parameterless_Handler ! is begin Check_Reserved_Interrupt (Interrupt); --- 330,336 ---- --------------------- function Current_Handler ! (Interrupt : Interrupt_ID) return Parameterless_Handler is begin Check_Reserved_Interrupt (Interrupt); *************** package body System.Interrupts is *** 456,463 **** procedure Detach_Handler (Interrupt : Interrupt_ID; ! Static : Boolean := False) ! is begin Check_Reserved_Interrupt (Interrupt); Interrupt_Manager.Detach_Handler (Interrupt, Static); --- 354,360 ---- procedure Detach_Handler (Interrupt : Interrupt_ID; ! Static : Boolean := False) is begin Check_Reserved_Interrupt (Interrupt); Interrupt_Manager.Detach_Handler (Interrupt, Static); *************** package body System.Interrupts is *** 488,495 **** (Old_Handler : out Parameterless_Handler; New_Handler : Parameterless_Handler; Interrupt : Interrupt_ID; ! Static : Boolean := False) ! is begin Check_Reserved_Interrupt (Interrupt); Interrupt_Manager.Exchange_Handler --- 385,391 ---- (Old_Handler : out Parameterless_Handler; New_Handler : Parameterless_Handler; Interrupt : Interrupt_ID; ! Static : Boolean := False) is begin Check_Reserved_Interrupt (Interrupt); Interrupt_Manager.Exchange_Handler *************** package body System.Interrupts is *** 524,533 **** -- Finalize_Interrupt_Servers -- -------------------------------- ! -- Restore default handlers for interrupt servers. Signal servers ! -- restore the default handlers when they're aborted. This is called ! -- by the Interrupt_Manager task when it receives the abort signal ! -- during program finalization. procedure Finalize_Interrupt_Servers is begin --- 420,428 ---- -- Finalize_Interrupt_Servers -- -------------------------------- ! -- Restore default handlers for interrupt servers. ! -- This is called by the Interrupt_Manager task when it receives the abort ! -- signal during program finalization. procedure Finalize_Interrupt_Servers is begin *************** package body System.Interrupts is *** 553,569 **** ------------------------------------- function Has_Interrupt_Or_Attach_Handler ! (Object : access Dynamic_Interrupt_Protection) ! return Boolean ! is begin return True; end Has_Interrupt_Or_Attach_Handler; function Has_Interrupt_Or_Attach_Handler ! (Object : access Static_Interrupt_Protection) ! return Boolean ! is begin return True; end Has_Interrupt_Or_Attach_Handler; --- 448,460 ---- ------------------------------------- function Has_Interrupt_Or_Attach_Handler ! (Object : access Dynamic_Interrupt_Protection) return Boolean is begin return True; end Has_Interrupt_Or_Attach_Handler; function Has_Interrupt_Or_Attach_Handler ! (Object : access Static_Interrupt_Protection) return Boolean is begin return True; end Has_Interrupt_Or_Attach_Handler; *************** package body System.Interrupts is *** 627,638 **** is use Interfaces.VxWorks; ! Vec : constant Interrupt_Vector := ! INUM_TO_IVEC (Interfaces.VxWorks.int (Interrupt)); Old_Handler : constant VOIDFUNCPTR := ! intVecGet ! (INUM_TO_IVEC (Interfaces.VxWorks.int (Interrupt))); ! Stat : Interfaces.VxWorks.STATUS; begin -- Only install umbrella handler when no Ada handler has already been --- 518,528 ---- is use Interfaces.VxWorks; ! Vec : constant Interrupt_Vector := ! INUM_TO_IVEC (Interfaces.VxWorks.int (Interrupt)); Old_Handler : constant VOIDFUNCPTR := ! intVecGet (INUM_TO_IVEC (Interfaces.VxWorks.int (Interrupt))); ! Stat : Interfaces.VxWorks.STATUS; begin -- Only install umbrella handler when no Ada handler has already been *************** package body System.Interrupts is *** 691,699 **** -- Is_Registered -- ------------------- - -- See if Handler has been "pragma"ed using Interrupt_Handler. - -- Always consider a null handler as registered. - function Is_Registered (Handler : Parameterless_Handler) return Boolean is type Fat_Ptr is record Object_Addr : System.Address; --- 581,586 ---- *************** package body System.Interrupts is *** 724,730 **** end loop; return False; - end Is_Registered; ----------------- --- 611,616 ---- *************** package body System.Interrupts is *** 733,795 **** function Is_Reserved (Interrupt : Interrupt_ID) return Boolean is begin ! if Interrupt < System.VxWorks.Num_HW_Interrupts then ! return False; ! else ! return IMNG.Reserve (To_Signal (Interrupt)); ! end if; end Is_Reserved; ! -------------------- ! -- Lock_Interrupt -- ! -------------------- ! ! -- ????? ! -- This package has been modified several times. ! -- Do we still need this fancy locking scheme, now that more operations ! -- are entries of the interrupt manager task? ! -- ????? ! -- More likely, we will need to convert one or more entry calls to ! -- protected operations, because presently we are violating locking order ! -- rules by calling a task entry from within the runtime system. ! ! procedure Lock_Interrupt ! (Self_ID : Task_ID; ! Interrupt : Interrupt_ID) is ! begin ! Initialization.Defer_Abort (Self_ID); ! ! POP.Write_Lock (L'Access); ! ! if Task_Lock (Interrupt) then ! pragma Assert (Server_ID (Interrupt) /= null, ! "Task_Lock is true for null server task"); ! pragma Assert ! (not Ada.Task_Identification.Is_Terminated ! (To_Ada (Server_ID (Interrupt))), ! "Attempt to lock per task lock of terminated server: " & ! "Task_Lock => True"); ! ! POP.Unlock (L'Access); ! POP.Write_Lock (Server_ID (Interrupt)); ! ! elsif Server_ID (Interrupt) /= Null_Task then ! pragma Assert ! (not Ada.Task_Identification.Is_Terminated ! (To_Ada (Server_ID (Interrupt))), ! "Attempt to lock per task lock of terminated server: " & ! "Task_Lock => False"); ! ! Task_Lock (Interrupt) := True; ! POP.Unlock (L'Access); ! POP.Write_Lock (Server_ID (Interrupt)); ! end if; ! ! end Lock_Interrupt; ! ! ------------------------ ! -- Notify_Interrupt -- ! ------------------------ -- Umbrella handler for vectored hardware interrupts (as opposed to -- signals and exceptions). As opposed to the signal implementation, --- 619,630 ---- function Is_Reserved (Interrupt : Interrupt_ID) return Boolean is begin ! return False; end Is_Reserved; ! ---------------------- ! -- Notify_Interrupt -- ! ---------------------- -- Umbrella handler for vectored hardware interrupts (as opposed to -- signals and exceptions). As opposed to the signal implementation, *************** package body System.Interrupts is *** 858,872 **** end if; end Register_Interrupt_Handler; - --------------- - -- To_Signal -- - --------------- - - function To_Signal (S : Interrupt_ID) return IMNG.Interrupt_ID is - begin - return IMNG.Interrupt_ID (S - System.VxWorks.Num_HW_Interrupts); - end To_Signal; - ----------------------- -- Unblock_Interrupt -- ----------------------- --- 693,698 ---- *************** package body System.Interrupts is *** 907,934 **** Feature & " not implemented on VxWorks"); end Unimplemented; - ---------------------- - -- Unlock_Interrupt -- - ---------------------- - - procedure Unlock_Interrupt - (Self_ID : Task_ID; - Interrupt : Interrupt_ID) is - begin - if Task_Lock (Interrupt) then - pragma Assert - (not Ada.Task_Identification.Is_Terminated - (To_Ada (Server_ID (Interrupt))), - "Attempt to unlock per task lock of terminated server"); - - POP.Unlock (Server_ID (Interrupt)); - else - POP.Unlock (L'Access); - end if; - - Initialization.Undefer_Abort (Self_ID); - end Unlock_Interrupt; - ----------------------- -- Interrupt_Manager -- ----------------------- --- 733,738 ---- *************** package body System.Interrupts is *** 938,946 **** -- Local Variables -- --------------------- ! Intwait_Mask : aliased IMNG.Interrupt_Mask; ! Old_Mask : aliased IMNG.Interrupt_Mask; ! Self_ID : Task_ID := POP.Self; -------------------- -- Local Routines -- --- 742,748 ---- -- Local Variables -- --------------------- ! Self_Id : constant Task_ID := POP.Self; -------------------- -- Local Routines -- *************** package body System.Interrupts is *** 956,965 **** -- Otherwise, we have to interrupt Server_Task for status change -- through an abort signal. - -- The following two procedures are labelled Unprotected... in order to - -- indicate that Lock/Unlock_Interrupt operations are needed around - -- around calls to them. - procedure Unprotected_Exchange_Handler (Old_Handler : out Parameterless_Handler; New_Handler : Parameterless_Handler; --- 758,763 ---- *************** package body System.Interrupts is *** 977,1000 **** procedure Bind_Handler (Interrupt : Interrupt_ID) is begin ! if Interrupt < System.VxWorks.Num_HW_Interrupts then ! Install_Umbrella_Handler ! (HW_Interrupt (Interrupt), Notify_Interrupt'Access); ! ! else ! -- Mask this task for the given signal so that all tasks ! -- are masked for the signal and the actual delivery of the ! -- signal will be caught using "sigwait" by the ! -- corresponding Server_Task. ! ! IMOP.Thread_Block_Interrupt (To_Signal (Interrupt)); ! -- We have installed a handler or an entry before we called ! -- this procedure. If the handler task is waiting to be ! -- awakened, do it here. Otherwise, the signal will be ! -- discarded. ! ! POP.Wakeup (Server_ID (Interrupt), Interrupt_Server_Idle_Sleep); ! end if; end Bind_Handler; -------------------- --- 775,782 ---- procedure Bind_Handler (Interrupt : Interrupt_ID) is begin ! Install_Umbrella_Handler ! (HW_Interrupt (Interrupt), Notify_Interrupt'Access); end Bind_Handler; -------------------- *************** package body System.Interrupts is *** 1003,1046 **** procedure Unbind_Handler (Interrupt : Interrupt_ID) is S : STATUS; - Ret_Interrupt : IMNG.Interrupt_ID; - - use type IMNG.Interrupt_ID; use type STATUS; begin ! if Interrupt < System.VxWorks.Num_HW_Interrupts then ! ! -- Hardware interrupt ! ! Install_Default_Action (HW_Interrupt (Interrupt)); ! ! -- Flush server task off semaphore, allowing it to terminate ! ! S := semFlush (Semaphore_ID_Map (Interrupt)); ! pragma Assert (S = 0); ! ! else ! -- Currently, there is a handler or an entry attached and ! -- the corresponding Server_Task is waiting on "sigwait." ! -- We have to wake up the Server_Task and make it ! -- wait on a condition variable by sending an ! -- Abort_Task_Interrupt ! ! -- Make sure corresponding Server_Task is out of its own ! -- sigwait state. ! ! POP.Abort_Task (Server_ID (Interrupt)); ! Ret_Interrupt := IMOP.Interrupt_Wait (Intwait_Mask'Access); ! pragma Assert (Ret_Interrupt = IMNG.Abort_Task_Interrupt); ! IMOP.Install_Default_Action (To_Signal (Interrupt)); ! -- Unmake the Interrupt for this task in order to allow default ! -- action again. ! IMOP.Thread_Unblock_Interrupt (To_Signal (Interrupt)); ! end if; end Unbind_Handler; -------------------------------- --- 785,801 ---- procedure Unbind_Handler (Interrupt : Interrupt_ID) is S : STATUS; use type STATUS; begin ! -- Hardware interrupt ! Install_Default_Action (HW_Interrupt (Interrupt)); ! -- Flush server task off semaphore, allowing it to terminate ! S := semFlush (Semaphore_ID_Map (Interrupt)); ! pragma Assert (S = 0); end Unbind_Handler; -------------------------------- *************** package body System.Interrupts is *** 1054,1064 **** Old_Handler : Parameterless_Handler; begin if User_Entry (Interrupt).T /= Null_Task then - -- If an interrupt entry is installed raise -- Program_Error. (propagate it to the caller). - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "An interrupt entry is already installed"); end if; --- 809,817 ---- *************** package body System.Interrupts is *** 1068,1078 **** -- status of the Current_Handler. if not Static and then User_Handler (Interrupt).Static then - -- Trying to detach a static Interrupt Handler. -- raise Program_Error. - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "Trying to detach a static Interrupt Handler"); end if; --- 821,829 ---- *************** package body System.Interrupts is *** 1087,1093 **** if Old_Handler /= null then Unbind_Handler (Interrupt); end if; - end Unprotected_Detach_Handler; ---------------------------------- --- 838,843 ---- *************** package body System.Interrupts is *** 1102,1114 **** Restoration : Boolean := False) is begin if User_Entry (Interrupt).T /= Null_Task then - -- If an interrupt entry is already installed, raise -- Program_Error. (propagate it to the caller). ! Unlock_Interrupt (Self_ID, Interrupt); ! Raise_Exception (Program_Error'Identity, ! "An interrupt is already installed"); end if; -- Note : A null handler with Static = True will --- 852,863 ---- Restoration : Boolean := False) is begin if User_Entry (Interrupt).T /= Null_Task then -- If an interrupt entry is already installed, raise -- Program_Error. (propagate it to the caller). ! Raise_Exception ! (Program_Error'Identity, ! "An interrupt is already installed"); end if; -- Note : A null handler with Static = True will *************** package body System.Interrupts is *** 1121,1135 **** if not Restoration and then not Static and then (User_Handler (Interrupt).Static ! -- Trying to overwrite a static Interrupt Handler with a ! -- dynamic Handler ! -- The new handler is not specified as an ! -- Interrupt Handler by a pragma. ! or else not Is_Registered (New_Handler)) then - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "Trying to overwrite a static Interrupt Handler with a " & --- 870,883 ---- if not Restoration and then not Static and then (User_Handler (Interrupt).Static ! -- Trying to overwrite a static Interrupt Handler with a ! -- dynamic Handler ! -- The new handler is not specified as an ! -- Interrupt Handler by a pragma. ! or else not Is_Registered (New_Handler)) then Raise_Exception (Program_Error'Identity, "Trying to overwrite a static Interrupt Handler with a " & *************** package body System.Interrupts is *** 1164,1209 **** Ada.Task_Identification.Is_Terminated (To_Ada (Server_ID (Interrupt)))) then ! -- When a new Server_Task is created, it should have its ! -- signal mask set to the All_Tasks_Mask. ! ! IMOP.Set_Interrupt_Mask ! (IMOP.All_Tasks_Mask'Access, Old_Mask'Access); ! ! if Interrupt < System.VxWorks.Num_HW_Interrupts then ! ! -- Vectored hardware interrupt ! ! Interrupt_Access_Hold := ! new Interrupt_Server_Task ! (Interrupt, semBCreate (SEM_Q_FIFO, SEM_EMPTY)); ! Server_ID (Interrupt) := ! To_System (Interrupt_Access_Hold.all'Identity); ! ! else ! -- Signal ! ! Signal_Access_Hold := new Signal_Server_Task (Interrupt); ! Server_ID (Interrupt) := ! To_System (Signal_Access_Hold.all'Identity); ! end if; ! ! IMOP.Set_Interrupt_Mask (Old_Mask'Access); end if; if (New_Handler = null) and then Old_Handler /= null then - -- Restore default handler Unbind_Handler (Interrupt); elsif Old_Handler = null then - -- Save default handler Bind_Handler (Interrupt); end if; - end Unprotected_Exchange_Handler; -- Start of processing for Interrupt_Manager --- 912,934 ---- Ada.Task_Identification.Is_Terminated (To_Ada (Server_ID (Interrupt)))) then ! Interrupt_Access_Hold := ! new Interrupt_Server_Task ! (Interrupt, semBCreate (SEM_Q_FIFO, SEM_EMPTY)); ! Server_ID (Interrupt) := ! To_System (Interrupt_Access_Hold.all'Identity); end if; if (New_Handler = null) and then Old_Handler /= null then -- Restore default handler Unbind_Handler (Interrupt); elsif Old_Handler = null then -- Save default handler Bind_Handler (Interrupt); end if; end Unprotected_Exchange_Handler; -- Start of processing for Interrupt_Manager *************** package body System.Interrupts is *** 1214,1269 **** System.Tasking.Utilities.Make_Independent; - -- Environment task gets its own interrupt mask, saves it, - -- and then masks all signals except the Keep_Unmasked set. - - -- During rendezvous, the Interrupt_Manager receives the old - -- signal mask of the environment task, and sets its own - -- signal mask to that value. - - -- The environment task will call this entry of Interrupt_Manager - -- during elaboration of the body of this package. - - accept Initialize (Mask : IMNG.Interrupt_Mask) do - declare - The_Mask : aliased IMNG.Interrupt_Mask; - - begin - IMOP.Copy_Interrupt_Mask (The_Mask, Mask); - IMOP.Set_Interrupt_Mask (The_Mask'Access); - end; - end Initialize; - - -- Note: All tasks in RTS will have all reserved signals - -- being masked (except the Interrupt_Manager) and Keep_Unmasked - -- signals unmasked when created. - - -- Abort_Task_Interrupt is one of the signals unmasked - -- in all tasks. We mask the signal in this particular task - -- so that "sigwait" is can catch an explicit - -- Abort_Task_Interrupt from a Server_Task. - - -- This sigwaiting is needed to ensure that a Signal_Server_Task is - -- out of its own sigwait state. This extra synchronization is - -- necessary to prevent following scenarios: - - -- 1) Interrupt_Manager sends an Abort_Task_Interrupt to a - -- Signal_Server_Task then changes its own signal mask (OS level). - -- If a signal (corresponding to the Signal_Server_Task) arrives - -- in the meantime, we have the Interrupt_Manager umnasked and - -- the Signal_Server_Task waiting on sigwait. - - -- 2) For unbinding a handler, we install a default action in the - -- Interrupt_Manager. POSIX.1c states that the result of using - -- "sigwait" and "sigaction" simultaneously on the same signal - -- is undefined. Therefore, we need to be informed from the - -- Signal_Server_Task that it is out of its sigwait stage. - - IMOP.Empty_Interrupt_Mask (Intwait_Mask'Access); - IMOP.Add_To_Interrupt_Mask - (Intwait_Mask'Access, IMNG.Abort_Task_Interrupt); - IMOP.Thread_Block_Interrupt (IMNG.Abort_Task_Interrupt); - loop -- A block is needed to absorb Program_Error exception --- 939,944 ---- *************** package body System.Interrupts is *** 1272,1413 **** begin select - accept Attach_Handler (New_Handler : Parameterless_Handler; Interrupt : Interrupt_ID; Static : Boolean; Restoration : Boolean := False) do - Lock_Interrupt (Self_ID, Interrupt); Unprotected_Exchange_Handler (Old_Handler, New_Handler, Interrupt, Static, Restoration); - Unlock_Interrupt (Self_ID, Interrupt); end Attach_Handler; ! or accept Exchange_Handler ! (Old_Handler : out Parameterless_Handler; ! New_Handler : Parameterless_Handler; ! Interrupt : Interrupt_ID; ! Static : Boolean) ! do ! Lock_Interrupt (Self_ID, Interrupt); ! Unprotected_Exchange_Handler ! (Old_Handler, New_Handler, Interrupt, Static); ! Unlock_Interrupt (Self_ID, Interrupt); ! end Exchange_Handler; ! ! or accept Detach_Handler ! (Interrupt : Interrupt_ID; ! Static : Boolean) ! do ! Lock_Interrupt (Self_ID, Interrupt); ! Unprotected_Detach_Handler (Interrupt, Static); ! Unlock_Interrupt (Self_ID, Interrupt); ! end Detach_Handler; ! ! or accept Bind_Interrupt_To_Entry ! (T : Task_ID; ! E : Task_Entry_Index; ! Interrupt : Interrupt_ID) ! do ! Lock_Interrupt (Self_ID, Interrupt); ! ! -- If there is a binding already (either a procedure or an ! -- entry), raise Program_Error (propagate it to the caller). ! ! if User_Handler (Interrupt).H /= null ! or else User_Entry (Interrupt).T /= Null_Task ! then ! Unlock_Interrupt (Self_ID, Interrupt); ! Raise_Exception ! (Program_Error'Identity, ! "A binding for this interrupt is already present"); ! end if; ! ! User_Entry (Interrupt) := Entry_Assoc' (T => T, E => E); ! -- Indicate the attachment of interrupt entry in the ATCB. ! -- This is needed so when an interrupt entry task terminates ! -- the binding can be cleaned. The call to unbinding must be ! -- make by the task before it terminates. ! T.Interrupt_Entry := True; ! -- Invoke a corresponding Server_Task if not yet created. ! -- Place Task_ID info in Server_ID array. ! if Server_ID (Interrupt) = Null_Task or else ! Ada.Task_Identification.Is_Terminated ! (To_Ada (Server_ID (Interrupt))) then ! -- When a new Server_Task is created, it should have its ! -- signal mask set to the All_Tasks_Mask. ! IMOP.Set_Interrupt_Mask ! (IMOP.All_Tasks_Mask'Access, Old_Mask'Access); ! if Interrupt < System.VxWorks.Num_HW_Interrupts then Interrupt_Access_Hold := new Interrupt_Server_Task (Interrupt, semBCreate (SEM_Q_FIFO, SEM_EMPTY)); Server_ID (Interrupt) := To_System (Interrupt_Access_Hold.all'Identity); - - else - Signal_Access_Hold := new Signal_Server_Task (Interrupt); - Server_ID (Interrupt) := - To_System (Signal_Access_Hold.all'Identity); end if; ! IMOP.Set_Interrupt_Mask (Old_Mask'Access); ! end if; ! ! Bind_Handler (Interrupt); ! Unlock_Interrupt (Self_ID, Interrupt); ! end Bind_Interrupt_To_Entry; ! ! or accept Detach_Interrupt_Entries (T : Task_ID) ! do ! for Int in Interrupt_ID'Range loop ! if not Is_Reserved (Int) then ! Lock_Interrupt (Self_ID, Int); ! ! if User_Entry (Int).T = T then ! User_Entry (Int) := Entry_Assoc' ! (T => Null_Task, E => Null_Task_Entry); ! Unbind_Handler (Int); end if; ! Unlock_Interrupt (Self_ID, Int); ! end if; ! end loop; ! ! -- Indicate in ATCB that no interrupt entries are attached. ! ! T.Interrupt_Entry := False; ! end Detach_Interrupt_Entries; end select; exception - -- If there is a Program_Error we just want to propagate it to -- the caller and do not want to stop this task. when Program_Error => null; ! when E : others => ! pragma Assert ! (Shutdown ("Interrupt_Manager---exception not expected" & ! ASCII.LF & ! Exception_Information (E))); null; end; end loop; - pragma Assert (Shutdown ("Interrupt_Manager---should not get here")); exception when Standard'Abort_Signal => -- Flush interrupt server semaphores, so they can terminate --- 947,1054 ---- begin select accept Attach_Handler (New_Handler : Parameterless_Handler; Interrupt : Interrupt_ID; Static : Boolean; Restoration : Boolean := False) do Unprotected_Exchange_Handler (Old_Handler, New_Handler, Interrupt, Static, Restoration); end Attach_Handler; ! or ! accept Exchange_Handler ! (Old_Handler : out Parameterless_Handler; ! New_Handler : Parameterless_Handler; ! Interrupt : Interrupt_ID; ! Static : Boolean) ! do ! Unprotected_Exchange_Handler ! (Old_Handler, New_Handler, Interrupt, Static); ! end Exchange_Handler; ! or ! accept Detach_Handler ! (Interrupt : Interrupt_ID; ! Static : Boolean) ! do ! Unprotected_Detach_Handler (Interrupt, Static); ! end Detach_Handler; ! or ! accept Bind_Interrupt_To_Entry ! (T : Task_ID; ! E : Task_Entry_Index; ! Interrupt : Interrupt_ID) ! do ! -- If there is a binding already (either a procedure or an ! -- entry), raise Program_Error (propagate it to the caller). ! if User_Handler (Interrupt).H /= null ! or else User_Entry (Interrupt).T /= Null_Task ! then ! Raise_Exception ! (Program_Error'Identity, ! "A binding for this interrupt is already present"); ! end if; ! User_Entry (Interrupt) := Entry_Assoc' (T => T, E => E); ! -- Indicate the attachment of interrupt entry in the ATCB. ! -- This is needed so when an interrupt entry task terminates ! -- the binding can be cleaned. The call to unbinding must be ! -- make by the task before it terminates. ! T.Interrupt_Entry := True; ! -- Invoke a corresponding Server_Task if not yet created. ! -- Place Task_ID info in Server_ID array. ! if Server_ID (Interrupt) = Null_Task ! or else ! Ada.Task_Identification.Is_Terminated ! (To_Ada (Server_ID (Interrupt))) ! then Interrupt_Access_Hold := new Interrupt_Server_Task (Interrupt, semBCreate (SEM_Q_FIFO, SEM_EMPTY)); Server_ID (Interrupt) := To_System (Interrupt_Access_Hold.all'Identity); end if; ! Bind_Handler (Interrupt); ! end Bind_Interrupt_To_Entry; ! or ! accept Detach_Interrupt_Entries (T : Task_ID) do ! for Int in Interrupt_ID'Range loop ! if not Is_Reserved (Int) then ! if User_Entry (Int).T = T then ! User_Entry (Int) := Entry_Assoc' ! (T => Null_Task, E => Null_Task_Entry); ! Unbind_Handler (Int); ! end if; end if; + end loop; ! -- Indicate in ATCB that no interrupt entries are attached. + T.Interrupt_Entry := False; + end Detach_Interrupt_Entries; end select; exception -- If there is a Program_Error we just want to propagate it to -- the caller and do not want to stop this task. when Program_Error => null; ! when others => ! pragma Assert (False); null; end; end loop; exception when Standard'Abort_Signal => -- Flush interrupt server semaphores, so they can terminate *************** package body System.Interrupts is *** 1415,1563 **** raise; end Interrupt_Manager; - ------------------------ - -- Signal_Server_Task -- - ------------------------ - - task body Signal_Server_Task is - Intwait_Mask : aliased IMNG.Interrupt_Mask; - Ret_Interrupt : IMNG.Interrupt_ID; - Self_ID : Task_ID := Self; - Tmp_Handler : Parameterless_Handler; - Tmp_ID : Task_ID; - Tmp_Entry_Index : Task_Entry_Index; - - use type IMNG.Interrupt_ID; - - begin - -- By making this task independent of master, when the process - -- goes away, the Server_Task will terminate gracefully. - - System.Tasking.Utilities.Make_Independent; - - -- Install default action in system level. - - IMOP.Install_Default_Action (To_Signal (Interrupt)); - - -- Note: All tasks in RTS will have all reserved signals - -- masked (except the Interrupt_Manager) and Keep_Unmasked - -- unmasked when created. - - -- Abort_Task_Interrupt is one of the signals unmasked - -- in all tasks. We mask it in this particular task - -- so that "sigwait" can catch an explicit - -- Abort_Task_Interrupt from the Interrupt_Manager. - - -- There are two signals that this task catches through - -- "sigwait." One is the signal it is designated to catch - -- in order to execute an user handler or entry. The other is - -- Abort_Task_Interrupt. This signal is sent from the - -- Interrupt_Manager to inform of status changes (e.g: become Blocked, - -- or a handler or entry is to be detached). - - -- Prepare the mask to be used for sigwait. - - IMOP.Empty_Interrupt_Mask (Intwait_Mask'Access); - - IMOP.Add_To_Interrupt_Mask - (Intwait_Mask'Access, To_Signal (Interrupt)); - - IMOP.Add_To_Interrupt_Mask - (Intwait_Mask'Access, IMNG.Abort_Task_Interrupt); - - IMOP.Thread_Block_Interrupt (IMNG.Abort_Task_Interrupt); - - PIO.Set_Interrupt_ID (To_Signal (Interrupt), Self_ID); - - loop - System.Tasking.Initialization.Defer_Abort (Self_ID); - POP.Write_Lock (Self_ID); - - if User_Handler (Interrupt).H = null - and then User_Entry (Interrupt).T = Null_Task - then - - -- No signal binding. If a signal is received, - -- Interrupt_Manager will take the default action. - - Self_ID.Common.State := Interrupt_Server_Blocked_Interrupt_Sleep; - POP.Sleep (Self_ID, Interrupt_Server_Idle_Sleep); - Self_ID.Common.State := Runnable; - - else - -- A handler or an entry is installed. At this point all tasks - -- mask for the signal is masked. Catch it using - -- sigwait. - - -- This task may wake up from sigwait by receiving a signal - -- (Abort_Task_Interrupt) from the Interrupt_Manager for unbinding - -- a procedure handler or an entry. Or it could be a wake up - -- from status change (Unblocked -> Blocked). If that is not - -- the case, we should execute the attached procedure or entry. - - POP.Unlock (Self_ID); - - Ret_Interrupt := IMOP.Interrupt_Wait (Intwait_Mask'Access); - - if Ret_Interrupt = IMNG.Abort_Task_Interrupt then - -- Inform the Interrupt_Manager of wakeup from above sigwait. - - POP.Abort_Task (Interrupt_Manager_ID); - POP.Write_Lock (Self_ID); - - else - POP.Write_Lock (Self_ID); - - -- Even though we have received a signal, the status may - -- have changed before we got the Self_ID lock above. - -- Therefore we make sure a handler or an entry is still - -- bound and make appropriate call. - -- If there is no call to make we need to regenerate the - -- signal in order not to lose it. - - if User_Handler (Interrupt).H /= null then - - Tmp_Handler := User_Handler (Interrupt).H; - - -- RTS calls should not be made with self being locked. - - POP.Unlock (Self_ID); - - Tmp_Handler.all; - POP.Write_Lock (Self_ID); - - elsif User_Entry (Interrupt).T /= Null_Task then - - Tmp_ID := User_Entry (Interrupt).T; - Tmp_Entry_Index := User_Entry (Interrupt).E; - - -- RTS calls should not be made with self being locked. - - POP.Unlock (Self_ID); - - System.Tasking.Rendezvous.Call_Simple - (Tmp_ID, Tmp_Entry_Index, System.Null_Address); - - POP.Write_Lock (Self_ID); - else - -- This is a situation where this task woke up receiving a - -- signal and before it got the lock the signal was blocked. - -- We do not want to lose the signal so we regenerate it at - -- the process level. - - IMOP.Interrupt_Self_Process (Ret_Interrupt); - end if; - end if; - end if; - - POP.Unlock (Self_ID); - System.Tasking.Initialization.Undefer_Abort (Self_ID); - - -- Undefer abort here to allow a window for this task - -- to be aborted at the time of system shutdown. - end loop; - end Signal_Server_Task; - --------------------------- -- Interrupt_Server_Task -- --------------------------- --- 1056,1061 ---- *************** package body System.Interrupts is *** 1565,1571 **** -- Server task for vectored hardware interrupt handling task body Interrupt_Server_Task is ! Self_ID : Task_ID := Self; Tmp_Handler : Parameterless_Handler; Tmp_ID : Task_ID; Tmp_Entry_Index : Task_Entry_Index; --- 1063,1069 ---- -- Server task for vectored hardware interrupt handling task body Interrupt_Server_Task is ! Self_Id : constant Task_ID := Self; Tmp_Handler : Parameterless_Handler; Tmp_ID : Task_ID; Tmp_Entry_Index : Task_Entry_Index; *************** package body System.Interrupts is *** 1606,1612 **** -- Wait for the Interrupt_Manager to complete its work ! POP.Write_Lock (Self_ID); -- Delete the associated semaphore --- 1104,1110 ---- -- Wait for the Interrupt_Manager to complete its work ! POP.Write_Lock (Self_Id); -- Delete the associated semaphore *************** package body System.Interrupts is *** 1617,1625 **** -- Set status for the Interrupt_Manager Semaphore_ID_Map (Interrupt) := 0; - Task_Lock (Interrupt) := False; Server_ID (Interrupt) := Null_Task; ! POP.Unlock (Self_ID); exit; end if; --- 1115,1122 ---- -- Set status for the Interrupt_Manager Semaphore_ID_Map (Interrupt) := 0; Server_ID (Interrupt) := Null_Task; ! POP.Unlock (Self_Id); exit; end if; *************** package body System.Interrupts is *** 1627,1657 **** end Interrupt_Server_Task; begin - -- Elaboration code for package System.Interrupts - -- Get Interrupt_Manager's ID so that Abort_Interrupt can be sent. Interrupt_Manager_ID := To_System (Interrupt_Manager'Identity); - - -- Initialize the lock L. - - Initialization.Defer_Abort (Self); - POP.Initialize_Lock (L'Access, POP.PO_Level); - Initialization.Undefer_Abort (Self); - - -- During the elaboration of this package body we want the RTS to - -- inherit its signal mask from the Environment Task. - - -- The Environment Task should have gotten its mask from - -- the enclosing process during the RTS start up. (See - -- in s-inmaop.adb). Pass the Interrupt_Mask of the Environment - -- task to the Interrupt_Manager. - - -- Note : At this point we know that all tasks (including - -- RTS internal servers) are masked for non-reserved signals - -- (see s-taprop.adb). Only the Interrupt_Manager will have - -- masks set up differently, inheriting the original Environment - -- Task's mask. - - Interrupt_Manager.Initialize (IMOP.Environment_Mask); end System.Interrupts; --- 1124,1130 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5zintman.adb gcc-3.3/gcc/ada/5zintman.adb *** gcc-3.2.3/gcc/ada/5zintman.adb 2001-10-02 13:42:29.000000000 +0000 --- gcc-3.3/gcc/ada/5zintman.adb 2002-10-23 08:27:55.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ *************** *** 52,93 **** -- may be used by the thread library. with Interfaces.C; - -- used for int and other types - - with System.Error_Reporting; - pragma Warnings (Off, System.Error_Reporting); - -- used for Shutdown with System.OS_Interface; -- used for various Constants, Signal and types - with Unchecked_Conversion; - package body System.Interrupt_Management is - use Interfaces.C; - use System.Error_Reporting; use System.OS_Interface; ! ! function To_Isr is new Unchecked_Conversion (Long_Integer, isr_address); type Interrupt_List is array (Interrupt_ID range <>) of Interrupt_ID; ! Exception_Interrupts : constant Interrupt_List := (SIGFPE, SIGILL, SIGSEGV, SIGBUS); -- Keep these variables global so that they are initialized only once. Exception_Action : aliased struct_sigaction; - Default_Action : aliased struct_sigaction; - - -- ????? Use these horrible imports here to solve elaboration order - -- problems. - - type Task_Id is access all Integer; - - Interrupt_ID_Map : array (Interrupt_ID) of Task_Id; - pragma Import (Ada, Interrupt_ID_Map, - "system__task_primitives__interrupt_operations__interrupt_id_map"); ---------------------- -- Notify_Exception -- --- 50,71 ---- -- may be used by the thread library. with Interfaces.C; with System.OS_Interface; -- used for various Constants, Signal and types package body System.Interrupt_Management is use System.OS_Interface; ! use type Interfaces.C.int; type Interrupt_List is array (Interrupt_ID range <>) of Interrupt_ID; ! Exception_Interrupts : constant Interrupt_List (1 .. 4) := (SIGFPE, SIGILL, SIGSEGV, SIGBUS); -- Keep these variables global so that they are initialized only once. Exception_Action : aliased struct_sigaction; ---------------------- -- Notify_Exception -- *************** package body System.Interrupt_Management *** 99,111 **** procedure Notify_Exception (signo : Signal) is Mask : aliased sigset_t; ! Result : Interfaces.C.int; ! My_Id : pthread_t; begin - -- VxWorks will always mask out the signal during the signal - -- handler and will reenable it on a longjmp. GNAT does - -- not generate a longjmp to return from a signal handler - -- so the signal will still be masked unless we unmask it. Result := pthread_sigmask (SIG_SETMASK, null, Mask'Unchecked_Access); Result := sigdelset (Mask'Access, signo); Result := pthread_sigmask (SIG_SETMASK, Mask'Unchecked_Access, null); --- 77,86 ---- procedure Notify_Exception (signo : Signal) is Mask : aliased sigset_t; ! Result : int; ! My_Id : t_id; ! begin Result := pthread_sigmask (SIG_SETMASK, null, Mask'Unchecked_Access); Result := sigdelset (Mask'Access, signo); Result := pthread_sigmask (SIG_SETMASK, Mask'Unchecked_Access, null); *************** package body System.Interrupt_Management *** 114,139 **** -- exception. We take the liberty of resuming the task -- for the application. My_Id := taskIdSelf; if taskIsSuspended (My_Id) /= 0 then Result := taskResume (My_Id); end if; - -- As long as we are using a longjmp to return control to the - -- exception handler on the runtime stack, we are safe. The original - -- signal mask (the one we had before coming into this signal catching - -- function) will be restored by the longjmp. Therefore, raising - -- an exception in this handler should be a safe operation. - - -- Check that treatment of exception propagation here - -- is consistent with treatment of the abort signal in - -- System.Task_Primitives.Operations. - - -- How can SIGSEGV be split into constraint and storage errors? - -- What should SIGILL really raise ? Some implementations have - -- codes for different types of SIGILL and some raise Storage_Error. - -- What causes SIGBUS and should it be caught? - -- Peter Burwood - case signo is when SIGFPE => raise Constraint_Error; --- 89,99 ---- -- exception. We take the liberty of resuming the task -- for the application. My_Id := taskIdSelf; + if taskIsSuspended (My_Id) /= 0 then Result := taskResume (My_Id); end if; case signo is when SIGFPE => raise Constraint_Error; *************** package body System.Interrupt_Management *** 144,206 **** when SIGBUS => raise Program_Error; when others => ! pragma Assert (Shutdown ("Unexpected signal")); ! null; end case; end Notify_Exception; - ------------------- - -- Notify_Signal -- - ------------------- - - -- VxWorks needs a special casing here. Each VxWorks task has a completely - -- separate signal handling, so the usual signal masking can't work. - -- This idea is to handle all the signals in all the tasks, and when - -- such a signal occurs, redirect it to the dedicated task (if any) or - -- reraise it. - - procedure Notify_Signal (signo : Signal); - - procedure Notify_Signal (signo : Signal) is - Mask : aliased sigset_t; - Result : Interfaces.C.int; - My_Id : pthread_t; - old_isr : isr_address; - - function Get_Thread_Id (T : Task_Id) return pthread_t; - pragma Import (Ada, Get_Thread_Id, - "system__task_primitives__operations__get_thread_id"); - - begin - -- VxWorks will always mask out the signal during the signal - -- handler and will reenable it on a longjmp. GNAT does - -- not generate a longjmp to return from a signal handler - -- so the signal will still be masked unless we unmask it. - Result := pthread_sigmask (SIG_SETMASK, null, Mask'Unchecked_Access); - Result := sigdelset (Mask'Access, signo); - Result := pthread_sigmask (SIG_SETMASK, Mask'Unchecked_Access, null); - - -- VxWorks will suspend the task when it gets a hardware - -- exception. We take the liberty of resuming the task - -- for the application. - My_Id := taskIdSelf; - if taskIsSuspended (My_Id) /= 0 then - Result := taskResume (My_Id); - end if; - - -- ??? Need a lock around this, in case the handler is detached - -- between the two following statements. - - if Interrupt_ID_Map (Interrupt_ID (signo)) /= null then - Result := - kill (Get_Thread_Id (Interrupt_ID_Map (Interrupt_ID (signo))), - Signal (signo)); - else - old_isr := c_signal (signo, To_Isr (SIG_DFL)); - Result := kill (My_Id, Signal (signo)); - end if; - end Notify_Signal; - --------------------------- -- Initialize_Interrupts -- --------------------------- --- 104,114 ---- when SIGBUS => raise Program_Error; when others => ! -- Unexpected signal ! raise Program_Error; end case; end Notify_Exception; --------------------------- -- Initialize_Interrupts -- --------------------------- *************** package body System.Interrupt_Management *** 209,228 **** -- to initialize signal handling in each task. procedure Initialize_Interrupts is old_act : aliased struct_sigaction; - Result : Interfaces.C.int; begin - for J in Interrupt_ID'First + 1 .. Interrupt_ID'Last loop - if J /= Abort_Task_Interrupt then - Result := sigaction (Signal (J), Default_Action'Access, - old_act'Unchecked_Access); - pragma Assert (Result = 0); - end if; - end loop; - for J in Exception_Interrupts'Range loop - Keep_Unmasked (Exception_Interrupts (J)) := True; Result := sigaction (Signal (Exception_Interrupts (J)), Exception_Action'Access, --- 117,127 ---- -- to initialize signal handling in each task. procedure Initialize_Interrupts is + Result : int; old_act : aliased struct_sigaction; begin for J in Exception_Interrupts'Range loop Result := sigaction (Signal (Exception_Interrupts (J)), Exception_Action'Access, *************** package body System.Interrupt_Management *** 233,295 **** begin declare ! mask : aliased sigset_t; ! default_mask : aliased sigset_t; ! Result : Interfaces.C.int; ! begin - -- The VxWorks POSIX threads library currently needs initialization. - -- We wish it could be in System.OS_Interface, but that would - -- cause an elaboration problem. - - pthread_init; - Abort_Task_Interrupt := SIGABRT; -- Change this if you want to use another signal for task abort. -- SIGTERM might be a good one. Exception_Action.sa_handler := Notify_Exception'Address; ! Default_Action.sa_handler := Notify_Signal'Address; ! ! Exception_Action.sa_flags := SA_SIGINFO + SA_ONSTACK; ! Default_Action.sa_flags := SA_SIGINFO + SA_ONSTACK; ! -- Send us extra signal information (SA_SIGINFO) on the ! -- stack (SA_ONSTACK). ! -- There is no SA_NODEFER in VxWorks. The signal mask is ! -- restored after a longjmp so the SA_NODEFER option is ! -- not needed. - Dan Eischen ! Result := sigemptyset (mask'Access); pragma Assert (Result = 0); - Result := sigemptyset (default_mask'Access); - pragma Assert (Result = 0); - - for J in Interrupt_ID'First + 1 .. Interrupt_ID'Last loop - Result := sigaddset (default_mask'Access, Signal (J)); - pragma Assert (Result = 0); - end loop; for J in Exception_Interrupts'Range loop Result := sigaddset (mask'Access, Signal (Exception_Interrupts (J))); pragma Assert (Result = 0); - Result := - sigdelset (default_mask'Access, Signal (Exception_Interrupts (J))); - pragma Assert (Result = 0); end loop; Exception_Action.sa_mask := mask; - Default_Action.sa_mask := default_mask; - - -- Initialize_Interrupts is called for each task in Enter_Task - - Keep_Unmasked (Abort_Task_Interrupt) := True; - - Reserve := Reserve or Keep_Unmasked or Keep_Masked; - - Reserve (0) := True; - -- We do not have Signal 0 in reality. We just use this value - -- to identify non-existent signals (see s-intnam.ads). Therefore, - -- Signal 0 should not be used in all signal related operations hence - -- mark it as reserved. end; end System.Interrupt_Management; --- 132,154 ---- begin declare ! mask : aliased sigset_t; ! Result : int; begin Abort_Task_Interrupt := SIGABRT; -- Change this if you want to use another signal for task abort. -- SIGTERM might be a good one. Exception_Action.sa_handler := Notify_Exception'Address; ! Exception_Action.sa_flags := SA_ONSTACK; Result := sigemptyset (mask'Access); pragma Assert (Result = 0); for J in Exception_Interrupts'Range loop Result := sigaddset (mask'Access, Signal (Exception_Interrupts (J))); pragma Assert (Result = 0); end loop; Exception_Action.sa_mask := mask; end; end System.Interrupt_Management; diff -Nrc3pad gcc-3.2.3/gcc/ada/5zosinte.adb gcc-3.3/gcc/ada/5zosinte.adb *** gcc-3.2.3/gcc/ada/5zosinte.adb 2002-05-04 03:27:18.000000000 +0000 --- gcc-3.3/gcc/ada/5zosinte.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1997-2001 Free Software Foundation -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2002 Free Software Foundation -- -- -- -- GNARL 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- -- *************** pragma Polling (Off); *** 42,212 **** -- Turn off polling, we do not want ATC polling to take place during -- tasking operations. It causes infinite loops and other problems. - with Interfaces.C; use Interfaces.C; - - with System.VxWorks; - -- used for Wind_TCB_Ptr - - with Unchecked_Conversion; - package body System.OS_Interface is ! use System.VxWorks; ! ! -- Option flags for taskSpawn ! ! VX_UNBREAKABLE : constant := 16#0002#; ! VX_FP_TASK : constant := 16#0008#; ! VX_FP_PRIVATE_ENV : constant := 16#0080#; ! VX_NO_STACK_FILL : constant := 16#0100#; ! ! function taskSpawn ! (name : System.Address; -- Pointer to task name ! priority : int; ! options : int; ! stacksize : size_t; ! start_routine : Thread_Body; ! arg1 : System.Address; ! arg2 : int := 0; ! arg3 : int := 0; ! arg4 : int := 0; ! arg5 : int := 0; ! arg6 : int := 0; ! arg7 : int := 0; ! arg8 : int := 0; ! arg9 : int := 0; ! arg10 : int := 0) return pthread_t; ! pragma Import (C, taskSpawn, "taskSpawn"); ! ! procedure taskDelete (tid : pthread_t); ! pragma Import (C, taskDelete, "taskDelete"); ! ! -- These are the POSIX scheduling priorities. These are enabled ! -- when the global variable posixPriorityNumbering is 1. ! ! POSIX_SCHED_FIFO_LOW_PRI : constant := 0; ! POSIX_SCHED_FIFO_HIGH_PRI : constant := 255; ! POSIX_SCHED_RR_LOW_PRI : constant := 0; ! POSIX_SCHED_RR_HIGH_PRI : constant := 255; ! ! -- These are the VxWorks native (default) scheduling priorities. ! -- These are used when the global variable posixPriorityNumbering ! -- is 0. ! ! SCHED_FIFO_LOW_PRI : constant := 255; ! SCHED_FIFO_HIGH_PRI : constant := 0; ! SCHED_RR_LOW_PRI : constant := 255; ! SCHED_RR_HIGH_PRI : constant := 0; ! ! -- Global variable to enable POSIX priority numbering. ! -- By default, it is 0 and VxWorks native priority numbering ! -- is used. ! ! posixPriorityNumbering : int; ! pragma Import (C, posixPriorityNumbering, "posixPriorityNumbering"); ! ! -- VxWorks will let you set round-robin scheduling globally ! -- for all tasks, but not for individual tasks. Attempting ! -- to set the scheduling policy for a specific task (using ! -- sched_setscheduler) to something other than what the system ! -- is currently using will fail. If you wish to change the ! -- scheduling policy, then use the following function to set ! -- it globally for all tasks. When ticks is 0, time slicing ! -- (round-robin scheduling) is disabled. ! ! function kernelTimeSlice (ticks : int) return int; ! pragma Import (C, kernelTimeSlice, "kernelTimeSlice"); ! ! function taskPriorityGet ! (tid : pthread_t; ! pPriority : access int) ! return int; ! pragma Import (C, taskPriorityGet, "taskPriorityGet"); ! ! function taskPrioritySet ! (tid : pthread_t; ! newPriority : int) ! return int; ! pragma Import (C, taskPrioritySet, "taskPrioritySet"); ! ! function To_Wind_TCB_Ptr is ! new Unchecked_Conversion (pthread_t, Wind_TCB_Ptr); ! ! ! -- Error codes (errno). The lower level 16 bits are the ! -- error code, with the upper 16 bits representing the ! -- module number in which the error occurred. By convention, ! -- the module number is 0 for UNIX errors. VxWorks reserves ! -- module numbers 1-500, with the remaining module numbers ! -- being available for user applications. ! ! M_objLib : constant := 61 * 2**16; ! -- semTake() failure with ticks = NO_WAIT ! S_objLib_OBJ_UNAVAILABLE : constant := M_objLib + 2; ! -- semTake() timeout with ticks > NO_WAIT ! S_objLib_OBJ_TIMEOUT : constant := M_objLib + 4; ! ! -- We use two different kinds of VxWorks semaphores: mutex ! -- and binary semaphores. A null (0) ID is returned when ! -- a semaphore cannot be created. Binary semaphores and common ! -- operations are declared in the spec of this package, ! -- as they are used to implement hardware interrupt handling ! ! function semMCreate ! (options : int) return SEM_ID; ! pragma Import (C, semMCreate, "semMCreate"); ! ! ! function taskLock return int; ! pragma Import (C, taskLock, "taskLock"); ! ! function taskUnlock return int; ! pragma Import (C, taskUnlock, "taskUnlock"); ! ! ------------------------------------------------------- ! -- Convenience routines to convert between VxWorks -- ! -- priority and POSIX priority. -- ! ------------------------------------------------------- ! ! function To_Vxworks_Priority (Priority : in int) return int; ! pragma Inline (To_Vxworks_Priority); ! ! function To_Posix_Priority (Priority : in int) return int; ! pragma Inline (To_Posix_Priority); ! ! function To_Vxworks_Priority (Priority : in int) return int is ! begin ! return SCHED_FIFO_LOW_PRI - Priority; ! end To_Vxworks_Priority; ! ! function To_Posix_Priority (Priority : in int) return int is ! begin ! return SCHED_FIFO_LOW_PRI - Priority; ! end To_Posix_Priority; ! ! ---------------------------------------- ! -- Implementation of POSIX routines -- ! ---------------------------------------- ! ! ----------------------------------------- ! -- Nonstandard Thread Initialization -- ! ----------------------------------------- ! procedure pthread_init is ! begin ! Keys_Created := 0; ! Time_Slice := -1; ! end pthread_init; ! --------------------------- ! -- POSIX.1c Section 3 -- ! --------------------------- function sigwait (set : access sigset_t; sig : access Signal) return int is ! Result : Interfaces.C.int; function sigwaitinfo (set : access sigset_t; sigvalue : System.Address) return int; --- 41,62 ---- -- Turn off polling, we do not want ATC polling to take place during -- tasking operations. It causes infinite loops and other problems. package body System.OS_Interface is ! use type Interfaces.C.int; ! Low_Priority : constant := 255; ! -- VxWorks native (default) lowest scheduling priority. ! ------------- ! -- sigwait -- ! ------------- function sigwait (set : access sigset_t; sig : access Signal) return int is ! Result : int; function sigwaitinfo (set : access sigset_t; sigvalue : System.Address) return int; *************** package body System.OS_Interface is *** 224,755 **** end if; end sigwait; - ---------------------------- - -- POSIX.1c Section 11 -- - ---------------------------- - - function pthread_mutexattr_init - (attr : access pthread_mutexattr_t) return int is - begin - -- Let's take advantage of VxWorks priority inversion - -- protection. - -- - -- ??? - Do we want to also specify SEM_DELETE_SAFE??? - - attr.Flags := int (SEM_Q_PRIORITY + SEM_INVERSION_SAFE); - - -- Initialize the ceiling priority to the maximim priority. - -- We will use POSIX priorities since these routines are - -- emulating POSIX routines. - - attr.Prio_Ceiling := POSIX_SCHED_FIFO_HIGH_PRI; - attr.Protocol := PTHREAD_PRIO_INHERIT; - return 0; - end pthread_mutexattr_init; - - function pthread_mutexattr_destroy - (attr : access pthread_mutexattr_t) return int is - begin - attr.Flags := 0; - attr.Prio_Ceiling := POSIX_SCHED_FIFO_HIGH_PRI; - attr.Protocol := PTHREAD_PRIO_INHERIT; - return 0; - end pthread_mutexattr_destroy; - - function pthread_mutex_init - (mutex : access pthread_mutex_t; - attr : access pthread_mutexattr_t) return int - is - Result : int := 0; - - begin - -- A mutex should initially be created full and the task - -- protected from deletion while holding the semaphore. - - mutex.Mutex := semMCreate (attr.Flags); - mutex.Prio_Ceiling := attr.Prio_Ceiling; - mutex.Protocol := attr.Protocol; - - if mutex.Mutex = 0 then - Result := errno; - end if; - - return Result; - end pthread_mutex_init; - - function pthread_mutex_destroy - (mutex : access pthread_mutex_t) return int - is - Result : STATUS; - begin - Result := semDelete (mutex.Mutex); - - if Result /= 0 then - Result := errno; - end if; - - mutex.Mutex := 0; -- Ensure the mutex is properly cleaned. - mutex.Prio_Ceiling := POSIX_SCHED_FIFO_HIGH_PRI; - mutex.Protocol := PTHREAD_PRIO_INHERIT; - return Result; - end pthread_mutex_destroy; - - function pthread_mutex_lock - (mutex : access pthread_mutex_t) return int - is - Result : int; - WTCB_Ptr : Wind_TCB_Ptr; - begin - WTCB_Ptr := To_Wind_TCB_Ptr (taskIdSelf); - - if WTCB_Ptr = null then - return errno; - end if; - - -- Check the current inherited priority in the WIND_TCB - -- against the mutex ceiling priority and return EINVAL - -- upon a ceiling violation. - -- - -- We always convert the VxWorks priority to POSIX priority - -- in case the current priority ordering has changed (see - -- posixPriorityNumbering). The mutex ceiling priority is - -- maintained as POSIX compatible. - - if mutex.Protocol = PTHREAD_PRIO_PROTECT and then - To_Posix_Priority (WTCB_Ptr.Priority) > mutex.Prio_Ceiling - then - return EINVAL; - end if; - - Result := semTake (mutex.Mutex, WAIT_FOREVER); - - if Result /= 0 then - Result := errno; - end if; - - return Result; - end pthread_mutex_lock; - - function pthread_mutex_unlock - (mutex : access pthread_mutex_t) return int - is - Result : int; - begin - Result := semGive (mutex.Mutex); - - if Result /= 0 then - Result := errno; - end if; - - return Result; - end pthread_mutex_unlock; - - function pthread_condattr_init - (attr : access pthread_condattr_t) return int is - begin - attr.Flags := SEM_Q_PRIORITY; - return 0; - end pthread_condattr_init; - - function pthread_condattr_destroy - (attr : access pthread_condattr_t) return int is - begin - attr.Flags := 0; - return 0; - end pthread_condattr_destroy; - - function pthread_cond_init - (cond : access pthread_cond_t; - attr : access pthread_condattr_t) return int - is - Result : int := 0; - - begin - -- Condition variables should be initially created - -- empty. - - cond.Sem := semBCreate (attr.Flags, SEM_EMPTY); - cond.Waiting := 0; - - if cond.Sem = 0 then - Result := errno; - end if; - - return Result; - end pthread_cond_init; - - function pthread_cond_destroy (cond : access pthread_cond_t) return int is - Result : int; - - begin - Result := semDelete (cond.Sem); - - if Result /= 0 then - Result := errno; - end if; - - return Result; - end pthread_cond_destroy; - - function pthread_cond_signal - (cond : access pthread_cond_t) return int - is - Result : int := 0; - Status : int; - - begin - -- Disable task scheduling. - - Status := taskLock; - - -- Iff someone is currently waiting on the condition variable - -- then release the semaphore; we don't want to leave the - -- semaphore in the full state because the next guy to do - -- a condition wait operation would not block. - - if cond.Waiting > 0 then - Result := semGive (cond.Sem); - - -- One less thread waiting on the CV. - - cond.Waiting := cond.Waiting - 1; - - if Result /= 0 then - Result := errno; - end if; - end if; - - -- Reenable task scheduling. - - Status := taskUnlock; - - return Result; - end pthread_cond_signal; - - function pthread_cond_wait - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t) return int - is - Result : int; - Status : int; - begin - -- Disable task scheduling. - - Status := taskLock; - - -- Release the mutex as required by POSIX. - - Result := semGive (mutex.Mutex); - - -- Indicate that there is another thread waiting on the CV. - - cond.Waiting := cond.Waiting + 1; - - -- Perform a blocking operation to take the CV semaphore. - -- Note that a blocking operation in VxWorks will reenable - -- task scheduling. When we are no longer blocked and control - -- is returned, task scheduling will again be disabled. - - Result := semTake (cond.Sem, WAIT_FOREVER); - - if Result /= 0 then - cond.Waiting := cond.Waiting - 1; - Result := EINVAL; - end if; - - -- Take the mutex as required by POSIX. - - Status := semTake (mutex.Mutex, WAIT_FOREVER); - - if Status /= 0 then - Result := EINVAL; - end if; - - -- Reenable task scheduling. - - Status := taskUnlock; - - return Result; - end pthread_cond_wait; - - function pthread_cond_timedwait - (cond : access pthread_cond_t; - mutex : access pthread_mutex_t; - abstime : access timespec) return int - is - Result : int; - Status : int; - Ticks : int; - TS : aliased timespec; - begin - Status := clock_gettime (CLOCK_REALTIME, TS'Unchecked_Access); - - -- Calculate the number of clock ticks for the timeout. - - Ticks := To_Clock_Ticks (To_Duration (abstime.all) - To_Duration (TS)); - - if Ticks <= 0 then - -- It is not worth the time to try to perform a semTake, - -- because we know it will always fail. A semTake with - -- ticks = 0 (NO_WAIT) will not block and therefore not - -- allow another task to give the semaphore. And if we've - -- designed pthread_cond_signal correctly, the semaphore - -- should never be left in a full state. - -- - -- Make sure we give up the CPU. - - Status := taskDelay (0); - return ETIMEDOUT; - end if; - - -- Disable task scheduling. - - Status := taskLock; - - -- Release the mutex as required by POSIX. - - Result := semGive (mutex.Mutex); - - -- Indicate that there is another thread waiting on the CV. - - cond.Waiting := cond.Waiting + 1; - - -- Perform a blocking operation to take the CV semaphore. - -- Note that a blocking operation in VxWorks will reenable - -- task scheduling. When we are no longer blocked and control - -- is returned, task scheduling will again be disabled. - - Result := semTake (cond.Sem, Ticks); - - if Result /= 0 then - if errno = S_objLib_OBJ_TIMEOUT then - Result := ETIMEDOUT; - else - Result := EINVAL; - end if; - cond.Waiting := cond.Waiting - 1; - end if; - - -- Take the mutex as required by POSIX. - - Status := semTake (mutex.Mutex, WAIT_FOREVER); - - if Status /= 0 then - Result := EINVAL; - end if; - - -- Reenable task scheduling. - - Status := taskUnlock; - - return Result; - end pthread_cond_timedwait; - - ---------------------------- - -- POSIX.1c Section 13 -- - ---------------------------- - - function pthread_mutexattr_setprotocol - (attr : access pthread_mutexattr_t; - protocol : int) return int is - begin - if protocol < PTHREAD_PRIO_NONE - or protocol > PTHREAD_PRIO_PROTECT - then - return EINVAL; - end if; - - attr.Protocol := protocol; - return 0; - end pthread_mutexattr_setprotocol; - - function pthread_mutexattr_setprioceiling - (attr : access pthread_mutexattr_t; - prioceiling : int) return int is - begin - -- Our interface to the rest of the world is meant - -- to be POSIX compliant; keep the priority in POSIX - -- format. - - attr.Prio_Ceiling := prioceiling; - return 0; - end pthread_mutexattr_setprioceiling; - - function pthread_setschedparam - (thread : pthread_t; - policy : int; - param : access struct_sched_param) return int - is - Result : int; - begin - -- Convert the POSIX priority to VxWorks native - -- priority. - - Result := taskPrioritySet (thread, - To_Vxworks_Priority (param.sched_priority)); - return 0; - end pthread_setschedparam; - - function sched_yield return int is - begin - return taskDelay (0); - end sched_yield; - - function pthread_sched_rr_set_interval (usecs : int) return int is - Result : int := 0; - D_Slice : Duration; - begin - -- Check to see if round-robin scheduling (time slicing) - -- is enabled. If the time slice is the default value (-1) - -- or any negative number, we will leave the kernel time - -- slice unchanged. If the time slice is 0, we disable - -- kernel time slicing by setting it to 0. Otherwise, we - -- set the kernel time slice to the specified value converted - -- to clock ticks. - - Time_Slice := usecs; - - if Time_Slice > 0 then - D_Slice := Duration (Time_Slice) / Duration (1_000_000.0); - Result := kernelTimeSlice (To_Clock_Ticks (D_Slice)); - - else - if Time_Slice = 0 then - Result := kernelTimeSlice (0); - end if; - end if; - - return Result; - end pthread_sched_rr_set_interval; - - function pthread_attr_init (attr : access pthread_attr_t) return int is - begin - attr.Stacksize := 100000; -- What else can I do? - attr.Detachstate := PTHREAD_CREATE_DETACHED; - attr.Priority := POSIX_SCHED_FIFO_LOW_PRI; - attr.Taskname := System.Null_Address; - return 0; - end pthread_attr_init; - - function pthread_attr_destroy (attr : access pthread_attr_t) return int is - begin - attr.Stacksize := 0; - attr.Detachstate := 0; - attr.Priority := POSIX_SCHED_FIFO_LOW_PRI; - attr.Taskname := System.Null_Address; - return 0; - end pthread_attr_destroy; - - function pthread_attr_setdetachstate - (attr : access pthread_attr_t; - detachstate : int) return int is - begin - attr.Detachstate := detachstate; - return 0; - end pthread_attr_setdetachstate; - - function pthread_attr_setstacksize - (attr : access pthread_attr_t; - stacksize : size_t) return int is - begin - attr.Stacksize := stacksize; - return 0; - end pthread_attr_setstacksize; - - -- In VxWorks tasks, we can set the task name. This - -- makes it really convenient for debugging. - - function pthread_attr_setname_np - (attr : access pthread_attr_t; - name : System.Address) return int is - begin - attr.Taskname := name; - return 0; - end pthread_attr_setname_np; - - function pthread_create - (thread : access pthread_t; - attr : access pthread_attr_t; - start_routine : Thread_Body; - arg : System.Address) return int is - begin - thread.all := taskSpawn (attr.Taskname, - To_Vxworks_Priority (attr.Priority), VX_FP_TASK, attr.Stacksize, - start_routine, arg); - - if thread.all = -1 then - return -1; - else - return 0; - end if; - end pthread_create; - - function pthread_detach (thread : pthread_t) return int is - begin - return 0; - end pthread_detach; - - procedure pthread_exit (status : System.Address) is - begin - taskDelete (0); - end pthread_exit; - - function pthread_self return pthread_t is - begin - return taskIdSelf; - end pthread_self; - - function pthread_equal (t1 : pthread_t; t2 : pthread_t) return int is - begin - if t1 = t2 then - return 1; - else - return 0; - end if; - end pthread_equal; - - function pthread_setspecific - (key : pthread_key_t; - value : System.Address) return int - is - Result : int; - begin - if Integer (key) not in Key_Storage'Range then - return EINVAL; - end if; - - Key_Storage (Integer (key)) := value; - Result := taskVarAdd (taskIdSelf, Key_Storage (Integer (key))'Access); - - -- We should be able to directly set the key with the following: - -- Key_Storage (key) := value; - -- but we'll be safe and use taskVarSet. - -- ??? Come back and revisit this. - - Result := taskVarSet (taskIdSelf, - Key_Storage (Integer (key))'Access, value); - return Result; - end pthread_setspecific; - - function pthread_getspecific (key : pthread_key_t) return System.Address is - begin - return Key_Storage (Integer (key)); - end pthread_getspecific; - - function pthread_key_create - (key : access pthread_key_t; - destructor : destructor_pointer) return int is - begin - Keys_Created := Keys_Created + 1; - - if Keys_Created not in Key_Storage'Range then - return ENOMEM; - end if; - - key.all := pthread_key_t (Keys_Created); - return 0; - end pthread_key_create; - ----------------- -- To_Duration -- ----------------- --- 74,79 ---- *************** package body System.OS_Interface is *** 776,796 **** S := S - 1; F := F + 1.0; end if; return timespec' (ts_sec => S, ts_nsec => long (Long_Long_Integer (F * 10#1#E9))); end To_Timespec; -------------------- -- To_Clock_Ticks -- -------------------- -- ??? - For now, we'll always get the system clock rate -- since it is allowed to be changed during run-time in ! -- VxWorks. A better method would be to provide an operation -- to set it that so we can always know its value. -- -- Another thing we should probably allow for is a resultant ! -- tick count greater than int'Last. This should probably -- be a procedure with two output parameters, one in the -- range 0 .. int'Last, and another representing the overflow -- count. --- 100,130 ---- S := S - 1; F := F + 1.0; end if; + return timespec' (ts_sec => S, ts_nsec => long (Long_Long_Integer (F * 10#1#E9))); end To_Timespec; + ------------------------- + -- To_VxWorks_Priority -- + ------------------------- + + function To_VxWorks_Priority (Priority : in int) return int is + begin + return Low_Priority - Priority; + end To_VxWorks_Priority; + -------------------- -- To_Clock_Ticks -- -------------------- -- ??? - For now, we'll always get the system clock rate -- since it is allowed to be changed during run-time in ! -- VxWorks. A better method would be to provide an operation -- to set it that so we can always know its value. -- -- Another thing we should probably allow for is a resultant ! -- tick count greater than int'Last. This should probably -- be a procedure with two output parameters, one in the -- range 0 .. int'Last, and another representing the overflow -- count. *************** package body System.OS_Interface is *** 799,805 **** --- 133,143 ---- Ticks : Long_Long_Integer; Rate_Duration : Duration; Ticks_Duration : Duration; + begin + if D < 0.0 then + return -1; + end if; -- Ensure that the duration can be converted to ticks -- at the current clock tick rate without overflowing. *************** package body System.OS_Interface is *** 808,817 **** if D > (Duration'Last / Rate_Duration) then Ticks := Long_Long_Integer (int'Last); - else - -- We always want to round up to the nearest clock tick. - Ticks_Duration := D * Rate_Duration; Ticks := Long_Long_Integer (Ticks_Duration); --- 146,152 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5zosinte.ads gcc-3.3/gcc/ada/5zosinte.ads *** gcc-3.2.3/gcc/ada/5zosinte.ads 2002-05-04 03:27:18.000000000 +0000 --- gcc-3.3/gcc/ada/5zosinte.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 49,67 **** with Interfaces.C; with System.VxWorks; package System.OS_Interface is pragma Preelaborate; ! subtype int is Interfaces.C.int; ! subtype short is Interfaces.C.short; ! subtype long is Interfaces.C.long; ! subtype unsigned is Interfaces.C.unsigned; ! subtype unsigned_short is Interfaces.C.unsigned_short; ! subtype unsigned_long is Interfaces.C.unsigned_long; ! subtype unsigned_char is Interfaces.C.unsigned_char; ! subtype plain_char is Interfaces.C.plain_char; ! subtype size_t is Interfaces.C.size_t; ! subtype char is Interfaces.C.char; ----------- -- Errno -- --- 48,62 ---- with Interfaces.C; with System.VxWorks; + package System.OS_Interface is pragma Preelaborate; ! subtype int is Interfaces.C.int; ! subtype short is Short_Integer; ! type long is new Long_Integer; ! type unsigned_long is mod 2 ** long'Size; ! type size_t is mod 2 ** Standard'Address_Size; ----------- -- Errno -- *************** package System.OS_Interface is *** 82,95 **** -- Signals and Interrupts -- ---------------------------- - -- In order to support both signal and hardware interrupt handling, - -- the ranges of "interrupt IDs" for the vectored hardware interrupts - -- and the signals are catenated. In other words, the external IDs - -- used to designate signals are relocated beyond the range of the - -- vectored interrupts. The IDs given in Ada.Interrupts.Names should - -- be used to designate signals; vectored interrupts are designated - -- by their interrupt number. - NSIG : constant := 32; -- Number of signals on the target OS type Signal is new int range 0 .. Interfaces.C."-" (NSIG, 1); --- 77,82 ---- *************** package System.OS_Interface is *** 97,103 **** Max_HW_Interrupt : constant := System.VxWorks.Num_HW_Interrupts - 1; type HW_Interrupt is new int range 0 .. Max_HW_Interrupt; ! Max_Interrupt : constant := Max_HW_Interrupt + NSIG; SIGILL : constant := 4; -- illegal instruction (not reset) SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future --- 84,90 ---- Max_HW_Interrupt : constant := System.VxWorks.Num_HW_Interrupts - 1; type HW_Interrupt is new int range 0 .. Max_HW_Interrupt; ! Max_Interrupt : constant := Max_HW_Interrupt; SIGILL : constant := 4; -- illegal instruction (not reset) SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future *************** package System.OS_Interface is *** 115,124 **** SIG_SETMASK : constant := 3; -- The sa_flags in struct sigaction. ! SA_SIGINFO : constant := 16#0002#; ! SA_ONSTACK : constant := 16#0004#; - -- ANSI args and returns from signal(). SIG_DFL : constant := 0; SIG_IGN : constant := 1; --- 102,110 ---- SIG_SETMASK : constant := 3; -- The sa_flags in struct sigaction. ! SA_SIGINFO : constant := 16#0002#; ! SA_ONSTACK : constant := 16#0004#; SIG_DFL : constant := 0; SIG_IGN : constant := 1; *************** package System.OS_Interface is *** 169,174 **** --- 155,171 ---- oset : sigset_t_ptr) return int; pragma Import (C, pthread_sigmask, "sigprocmask"); + type t_id is new long; + subtype Thread_Id is t_id; + + function kill (pid : t_id; sig : Signal) return int; + pragma Import (C, kill, "kill"); + + -- VxWorks doesn't have getpid; taskIdSelf is the equivalent + -- routine. + function getpid return t_id; + pragma Import (C, getpid, "taskIdSelf"); + ---------- -- Time -- ---------- *************** package System.OS_Interface is *** 198,458 **** (clock_id : clockid_t; tp : access timespec) return int; pragma Import (C, clock_gettime, "clock_gettime"); ! ------------------------- ! -- Priority Scheduling -- ! ------------------------- ! ! -- Scheduling policies. ! SCHED_FIFO : constant := 1; ! SCHED_RR : constant := 2; ! SCHED_OTHER : constant := 4; ! ! ------------- ! -- Threads -- ! ------------- ! ! type Thread_Body is access ! function (arg : System.Address) return System.Address; ! ! type pthread_t is private; ! subtype Thread_Id is pthread_t; ! ! null_pthread : constant pthread_t; ! ! type pthread_mutex_t is limited private; ! type pthread_cond_t is limited private; ! type pthread_attr_t is limited private; ! type pthread_mutexattr_t is limited private; ! type pthread_condattr_t is limited private; ! type pthread_key_t is private; ! PTHREAD_CREATE_DETACHED : constant := 0; ! PTHREAD_CREATE_JOINABLE : constant := 1; ! function kill (pid : pthread_t; sig : Signal) return int; ! pragma Import (C, kill, "kill"); ! -- VxWorks doesn't have getpid; taskIdSelf is the equivalent ! -- routine. ! function getpid return pthread_t; ! pragma Import (C, getpid, "taskIdSelf"); ! --------------------------------- ! -- Nonstandard Thread Routines -- ! --------------------------------- ! procedure pthread_init; ! pragma Inline (pthread_init); ! -- Vxworks requires this for the moment. ! function taskIdSelf return pthread_t; pragma Import (C, taskIdSelf, "taskIdSelf"); ! function taskSuspend (tid : pthread_t) return int; pragma Import (C, taskSuspend, "taskSuspend"); ! function taskResume (tid : pthread_t) return int; pragma Import (C, taskResume, "taskResume"); ! function taskIsSuspended (tid : pthread_t) return int; pragma Import (C, taskIsSuspended, "taskIsSuspended"); function taskVarAdd ! (tid : pthread_t; ! pVar : access System.Address) return int; pragma Import (C, taskVarAdd, "taskVarAdd"); function taskVarDelete ! (tid : pthread_t; ! pVar : access System.Address) return int; pragma Import (C, taskVarDelete, "taskVarDelete"); function taskVarSet ! (tid : pthread_t; pVar : access System.Address; value : System.Address) return int; pragma Import (C, taskVarSet, "taskVarSet"); function taskVarGet ! (tid : pthread_t; ! pVar : access System.Address) return int; pragma Import (C, taskVarGet, "taskVarGet"); - function taskInfoGet - (tid : pthread_t; - pTaskDesc : access System.VxWorks.TASK_DESC) return int; - pragma Import (C, taskInfoGet, "taskInfoGet"); - function taskDelay (ticks : int) return int; pragma Import (C, taskDelay, "taskDelay"); function sysClkRateGet return int; pragma Import (C, sysClkRateGet, "sysClkRateGet"); ! -------------------------- ! -- POSIX.1c Section 11 -- ! -------------------------- ! ! function pthread_mutexattr_init ! (attr : access pthread_mutexattr_t) return int; ! pragma Inline (pthread_mutexattr_init); ! ! function pthread_mutexattr_destroy ! (attr : access pthread_mutexattr_t) return int; ! pragma Inline (pthread_mutexattr_destroy); ! ! function pthread_mutex_init ! (mutex : access pthread_mutex_t; ! attr : access pthread_mutexattr_t) return int; ! pragma Inline (pthread_mutex_init); ! ! function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int; ! pragma Inline (pthread_mutex_destroy); ! ! function pthread_mutex_lock (mutex : access pthread_mutex_t) return int; ! pragma Inline (pthread_mutex_lock); ! ! function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int; ! pragma Inline (pthread_mutex_unlock); ! ! function pthread_condattr_init ! (attr : access pthread_condattr_t) return int; ! pragma Inline (pthread_condattr_init); ! ! function pthread_condattr_destroy ! (attr : access pthread_condattr_t) return int; ! pragma Inline (pthread_condattr_destroy); ! ! function pthread_cond_init ! (cond : access pthread_cond_t; ! attr : access pthread_condattr_t) return int; ! pragma Inline (pthread_cond_init); ! ! function pthread_cond_destroy (cond : access pthread_cond_t) return int; ! pragma Inline (pthread_cond_destroy); ! ! function pthread_cond_signal (cond : access pthread_cond_t) return int; ! pragma Inline (pthread_cond_signal); ! ! function pthread_cond_wait ! (cond : access pthread_cond_t; ! mutex : access pthread_mutex_t) return int; ! pragma Inline (pthread_cond_wait); ! ! function pthread_cond_timedwait ! (cond : access pthread_cond_t; ! mutex : access pthread_mutex_t; ! abstime : access timespec) return int; ! pragma Inline (pthread_cond_timedwait); ! ! -------------------------- ! -- POSIX.1c Section 13 -- ! -------------------------- ! ! PTHREAD_PRIO_NONE : constant := 0; ! PTHREAD_PRIO_PROTECT : constant := 2; ! PTHREAD_PRIO_INHERIT : constant := 1; ! ! function pthread_mutexattr_setprotocol ! (attr : access pthread_mutexattr_t; ! protocol : int) return int; ! pragma Inline (pthread_mutexattr_setprotocol); ! ! function pthread_mutexattr_setprioceiling ! (attr : access pthread_mutexattr_t; ! prioceiling : int) return int; ! pragma Inline (pthread_mutexattr_setprioceiling); ! ! type struct_sched_param is record ! sched_priority : int; ! end record; ! ! function pthread_setschedparam ! (thread : pthread_t; ! policy : int; ! param : access struct_sched_param) return int; ! pragma Inline (pthread_setschedparam); ! ! function sched_yield return int; ! pragma Inline (sched_yield); ! ! function pthread_sched_rr_set_interval (usecs : int) return int; ! pragma Inline (pthread_sched_rr_set_interval); ! ! --------------------------- ! -- P1003.1c - Section 16 -- ! --------------------------- ! ! function pthread_attr_init (attr : access pthread_attr_t) return int; ! pragma Inline (pthread_attr_init); ! ! function pthread_attr_destroy (attr : access pthread_attr_t) return int; ! pragma Inline (pthread_attr_destroy); ! ! function pthread_attr_setdetachstate ! (attr : access pthread_attr_t; ! detachstate : int) return int; ! pragma Inline (pthread_attr_setdetachstate); ! ! function pthread_attr_setstacksize ! (attr : access pthread_attr_t; ! stacksize : size_t) return int; ! pragma Inline (pthread_attr_setstacksize); ! ! function pthread_attr_setname_np ! (attr : access pthread_attr_t; ! name : System.Address) return int; ! -- In VxWorks tasks, we have a non-portable routine to set the ! -- task name. This makes it really convenient for debugging. ! pragma Inline (pthread_attr_setname_np); ! ! function pthread_create ! (thread : access pthread_t; ! attr : access pthread_attr_t; ! start_routine : Thread_Body; ! arg : System.Address) return int; ! pragma Inline (pthread_create); ! ! function pthread_detach (thread : pthread_t) return int; ! pragma Inline (pthread_detach); ! ! procedure pthread_exit (status : System.Address); ! pragma Inline (pthread_exit); ! ! function pthread_self return pthread_t; ! pragma Inline (pthread_self); ! ! function pthread_equal (t1 : pthread_t; t2 : pthread_t) return int; ! pragma Inline (pthread_equal); ! -- be careful not to use "=" on thread_t! ! ! -------------------------- ! -- POSIX.1c Section 17 -- ! -------------------------- ! function pthread_setspecific ! (key : pthread_key_t; ! value : System.Address) return int; ! pragma Inline (pthread_setspecific); ! function pthread_getspecific (key : pthread_key_t) return System.Address; ! pragma Inline (pthread_getspecific); ! type destructor_pointer is access procedure (arg : System.Address); ! function pthread_key_create ! (key : access pthread_key_t; ! destructor : destructor_pointer) return int; ! pragma Inline (pthread_key_create); ! -- VxWorks binary semaphores. These are exported for use by the ! -- implementation of hardware interrupt handling. subtype STATUS is int; -- Equivalent of the C type STATUS OK : constant STATUS := 0; ! ERROR : constant STATUS := Interfaces.C."-" (1); -- Semaphore creation flags. --- 195,298 ---- (clock_id : clockid_t; tp : access timespec) return int; pragma Import (C, clock_gettime, "clock_gettime"); ! type ULONG is new unsigned_long; ! procedure tickSet (ticks : ULONG); ! pragma Import (C, tickSet, "tickSet"); ! function tickGet return ULONG; ! pragma Import (C, tickGet, "tickGet"); ! ----------------------------------------------------- ! -- Convenience routine to convert between VxWorks -- ! -- priority and Ada priority. -- ! ----------------------------------------------------- ! function To_VxWorks_Priority (Priority : in int) return int; ! pragma Inline (To_VxWorks_Priority); ! -------------------------- ! -- VxWorks specific API -- ! -------------------------- ! function taskIdSelf return t_id; pragma Import (C, taskIdSelf, "taskIdSelf"); ! function taskSuspend (tid : t_id) return int; pragma Import (C, taskSuspend, "taskSuspend"); ! function taskResume (tid : t_id) return int; pragma Import (C, taskResume, "taskResume"); ! function taskIsSuspended (tid : t_id) return int; pragma Import (C, taskIsSuspended, "taskIsSuspended"); function taskVarAdd ! (tid : t_id; pVar : System.Address) return int; pragma Import (C, taskVarAdd, "taskVarAdd"); function taskVarDelete ! (tid : t_id; pVar : access System.Address) return int; pragma Import (C, taskVarDelete, "taskVarDelete"); function taskVarSet ! (tid : t_id; pVar : access System.Address; value : System.Address) return int; pragma Import (C, taskVarSet, "taskVarSet"); function taskVarGet ! (tid : t_id; ! pVar : access System.Address) return int; pragma Import (C, taskVarGet, "taskVarGet"); function taskDelay (ticks : int) return int; + procedure taskDelay (ticks : int); pragma Import (C, taskDelay, "taskDelay"); function sysClkRateGet return int; pragma Import (C, sysClkRateGet, "sysClkRateGet"); ! -- Option flags for taskSpawn ! VX_UNBREAKABLE : constant := 16#0002#; ! VX_FP_TASK : constant := 16#0008#; ! VX_FP_PRIVATE_ENV : constant := 16#0080#; ! VX_NO_STACK_FILL : constant := 16#0100#; ! function taskSpawn ! (name : System.Address; -- Pointer to task name ! priority : int; ! options : int; ! stacksize : size_t; ! start_routine : System.Address; ! arg1 : System.Address; ! arg2 : int := 0; ! arg3 : int := 0; ! arg4 : int := 0; ! arg5 : int := 0; ! arg6 : int := 0; ! arg7 : int := 0; ! arg8 : int := 0; ! arg9 : int := 0; ! arg10 : int := 0) return t_id; ! pragma Import (C, taskSpawn, "taskSpawn"); ! procedure taskDelete (tid : t_id); ! pragma Import (C, taskDelete, "taskDelete"); ! function kernelTimeSlice (ticks : int) return int; ! pragma Import (C, kernelTimeSlice, "kernelTimeSlice"); ! function taskPrioritySet ! (tid : t_id; newPriority : int) return int; ! pragma Import (C, taskPrioritySet, "taskPrioritySet"); subtype STATUS is int; -- Equivalent of the C type STATUS OK : constant STATUS := 0; ! ERROR : constant STATUS := Interfaces.C.int (-1); -- Semaphore creation flags. *************** package System.OS_Interface is *** 461,467 **** SEM_DELETE_SAFE : constant := 4; -- only valid for binary semaphore SEM_INVERSION_SAFE : constant := 8; -- only valid for binary semaphore ! -- Semaphore initial state flags; SEM_EMPTY : constant := 0; SEM_FULL : constant := 1; --- 301,307 ---- SEM_DELETE_SAFE : constant := 4; -- only valid for binary semaphore SEM_INVERSION_SAFE : constant := 8; -- only valid for binary semaphore ! -- Semaphore initial state flags SEM_EMPTY : constant := 0; SEM_FULL : constant := 1; *************** package System.OS_Interface is *** 471,506 **** WAIT_FOREVER : constant := -1; NO_WAIT : constant := 0; ! type SEM_ID is new long; ! -- The VxWorks semaphore ID is an integer which is really just ! -- a pointer to a semaphore structure. ! function semBCreate (Options : int; Initial_State : int) return SEM_ID; ! -- Create a binary semaphore. Returns ID, or 0 if memory could not ! -- be allocated pragma Import (C, semBCreate, "semBCreate"); ! function semTake (SemID : SEM_ID; Timeout : int) return STATUS; -- Attempt to take binary semaphore. Error is returned if operation -- times out pragma Import (C, semTake, "semTake"); - function semGive (SemID : SEM_ID) return STATUS; - -- Release one thread blocked on the semaphore - pragma Import (C, semGive, "semGive"); - function semFlush (SemID : SEM_ID) return STATUS; -- Release all threads blocked on the semaphore pragma Import (C, semFlush, "semFlush"); ! function semDelete (SemID : SEM_ID) return STATUS; ! -- Delete a semaphore ! pragma Import (C, semDelete, "semDelete"); private - -- This interface assumes that "unsigned" and "int" are 32-bit entities. - type sigset_t is new long; type pid_t is new int; --- 311,367 ---- WAIT_FOREVER : constant := -1; NO_WAIT : constant := 0; ! -- Error codes (errno). The lower level 16 bits are the ! -- error code, with the upper 16 bits representing the ! -- module number in which the error occurred. By convention, ! -- the module number is 0 for UNIX errors. VxWorks reserves ! -- module numbers 1-500, with the remaining module numbers ! -- being available for user applications. ! M_objLib : constant := 61 * 2**16; ! -- semTake() failure with ticks = NO_WAIT ! S_objLib_OBJ_UNAVAILABLE : constant := M_objLib + 2; ! -- semTake() timeout with ticks > NO_WAIT ! S_objLib_OBJ_TIMEOUT : constant := M_objLib + 4; ! ! type SEM_ID is new System.Address; ! -- typedef struct semaphore *SEM_ID; ! ! -- We use two different kinds of VxWorks semaphores: mutex ! -- and binary semaphores. A null ID is returned when ! -- a semaphore cannot be created. ! ! function semBCreate (options : int; initial_state : int) return SEM_ID; ! -- Create a binary semaphore. Return ID, or 0 if memory could not ! -- be allocated. pragma Import (C, semBCreate, "semBCreate"); ! function semMCreate (options : int) return SEM_ID; ! pragma Import (C, semMCreate, "semMCreate"); ! ! function semDelete (Sem : SEM_ID) return int; ! -- Delete a semaphore ! pragma Import (C, semDelete, "semDelete"); ! ! function semGive (Sem : SEM_ID) return int; ! pragma Import (C, semGive, "semGive"); ! ! function semTake (Sem : SEM_ID; timeout : int) return int; -- Attempt to take binary semaphore. Error is returned if operation -- times out pragma Import (C, semTake, "semTake"); function semFlush (SemID : SEM_ID) return STATUS; -- Release all threads blocked on the semaphore pragma Import (C, semFlush, "semFlush"); ! function taskLock return int; ! pragma Import (C, taskLock, "taskLock"); + function taskUnlock return int; + pragma Import (C, taskUnlock, "taskUnlock"); private type sigset_t is new long; type pid_t is new int; *************** private *** 510,558 **** type clockid_t is new int; CLOCK_REALTIME : constant clockid_t := 0; - -- Priority ceilings are now implemented in the body of - -- this package. - - type pthread_mutexattr_t is record - Flags : int; -- mutex semaphore creation flags - Prio_Ceiling : int; -- priority ceiling - Protocol : int; - end record; - - type pthread_mutex_t is record - Mutex : SEM_ID; - Protocol : int; - Prio_Ceiling : int; -- priority ceiling of lock - end record; - - type pthread_condattr_t is record - Flags : int; - end record; - - type pthread_cond_t is record - Sem : SEM_ID; -- VxWorks semaphore ID - Waiting : Integer; -- Number of queued tasks waiting - end record; - - type pthread_attr_t is record - Stacksize : size_t; - Detachstate : int; - Priority : int; - Taskname : System.Address; - end record; - - type pthread_t is new long; - - null_pthread : constant pthread_t := 0; - - type pthread_key_t is new int; - - -- These are to store the pthread_keys that are created with - -- pthread_key_create. Currently, we only need one key. - - Key_Storage : array (1 .. 10) of aliased System.Address; - Keys_Created : Integer; - - Time_Slice : int; - end System.OS_Interface; --- 371,374 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5zosprim.adb gcc-3.3/gcc/ada/5zosprim.adb *** gcc-3.2.3/gcc/ada/5zosprim.adb 2002-05-04 03:27:18.000000000 +0000 --- gcc-3.3/gcc/ada/5zosprim.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5zparame.ads gcc-3.3/gcc/ada/5zparame.ads *** gcc-3.2.3/gcc/ada/5zparame.ads 2002-05-04 03:27:18.000000000 +0000 --- gcc-3.3/gcc/ada/5zparame.ads 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,135 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- S Y S T E M . P A R A M E T E R S -- - -- -- - -- S p e c -- - -- -- - -- $Revision: 1.1.16.1 $ - -- -- - -- Copyright (C) 1992-2000 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- 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. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - -- This is the VxWorks/68k version of this package - - -- This package defines some system dependent parameters for GNAT. These - -- are values that are referenced by the runtime library and are therefore - -- relevant to the target machine. - - -- The parameters whose value is defined in the spec are not generally - -- expected to be changed. If they are changed, it will be necessary to - -- recompile the run-time library. - - -- The parameters which are defined by functions can be changed by modifying - -- the body of System.Parameters in file s-parame.adb. A change to this body - -- requires only rebinding and relinking of the application. - - -- Note: do not introduce any pragma Inline statements into this unit, since - -- otherwise the relinking and rebinding capability would be deactivated. - - package System.Parameters is - pragma Pure (Parameters); - - --------------------------------------- - -- Task And Stack Allocation Control -- - --------------------------------------- - - type Task_Storage_Size is new Integer; - -- Type used in tasking units for task storage size - - type Size_Type is new Task_Storage_Size; - -- Type used to provide task storage size to runtime - - Unspecified_Size : constant Size_Type := Size_Type'First; - -- Value used to indicate that no size type is set - - subtype Ratio is Size_Type range -1 .. 100; - Dynamic : constant Size_Type := -1; - -- Secondary_Stack_Ratio is a constant between 0 and 100 wich - -- determines the percentage of the allocate task stack that is - -- used by the secondary stack (the rest being the primary stack). - -- The special value of minus one indicates that the secondary - -- stack is to be allocated from the heap instead. - - Sec_Stack_Ratio : constant Ratio := -1; - -- This constant defines the handling of the secondary stack - - Sec_Stack_Dynamic : constant Boolean := Sec_Stack_Ratio = Dynamic; - -- Convenient Boolean for testing for dynmaic secondary stack - - function Default_Stack_Size return Size_Type; - -- Default task stack size used if none is specified - - function Minimum_Stack_Size return Size_Type; - -- Minimum task stack size permitted - - function Adjust_Storage_Size (Size : Size_Type) return Size_Type; - -- Given the storage size stored in the TCB, return the Storage_Size - -- value required by the RM for the Storage_Size attribute. The - -- required adjustment is as follows: - -- - -- when Size = Unspecified_Size, return Default_Stack_Size - -- when Size < Minimum_Stack_Size, return Minimum_Stack_Size - -- otherwise return given Size - - Stack_Grows_Down : constant Boolean := True; - -- This constant indicates whether the stack grows up (False) or - -- down (True) in memory as functions are called. It is used for - -- proper implementation of the stack overflow check. - - ---------------------------------------------- - -- Characteristics of types in Interfaces.C -- - ---------------------------------------------- - - long_bits : constant := Long_Integer'Size; - -- Number of bits in type long and unsigned_long. The normal convention - -- is that this is the same as type Long_Integer, but this is not true - -- of all targets. For example, in OpenVMS long /= Long_Integer. - - ---------------------------------------------- - -- Behavior of Pragma Finalize_Storage_Only -- - ---------------------------------------------- - - -- Garbage_Collected is a Boolean constant whose value indicates the - -- effect of the pragma Finalize_Storage_Entry on a controlled type. - - -- Garbage_Collected = False - - -- The system releases all storage on program termination only, - -- but not other garbage collection occurs, so finalization calls - -- are ommitted only for outer level onjects can be omitted if - -- pragma Finalize_Storage_Only is used. - - -- Garbage_Collected = True - - -- The system provides full garbage collection, so it is never - -- necessary to release storage for controlled objects for which - -- a pragma Finalize_Storage_Only is used. - - Garbage_Collected : constant Boolean := False; - -- The storage mode for this system (release on program exit) - - end System.Parameters; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/5zsystem.ads gcc-3.3/gcc/ada/5zsystem.ads *** gcc-3.2.3/gcc/ada/5zsystem.ads 2002-05-04 03:27:18.000000000 +0000 --- gcc-3.3/gcc/ada/5zsystem.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 5,15 **** -- S Y S T E M -- -- -- -- S p e c -- ! -- (VXWORKS Version Alpha, Mips) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 5,14 ---- -- S Y S T E M -- -- -- -- S p e c -- ! -- (VXWORKS Version Alpha) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (System); *** 60,75 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := Standard'Storage_Unit; ! Word_Size : constant := Standard'Word_Size; ! Memory_Size : constant := 2 ** Standard'Address_Size; -- Address comparison --- 59,74 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations type Address is private; Null_Address : constant Address; ! Storage_Unit : constant := 8; ! Word_Size : constant := 64; ! Memory_Size : constant := 2 ** 64; -- Address comparison *************** pragma Pure (System); *** 88,127 **** -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := ! Bit_Order'Val (Standard'Default_Bit_Order); -- Priority-related Declarations (RM D.1) ! -- 256 is reserved for the VxWorks kernel ! -- 248 - 255 correspond to hardware interrupt levels 0 .. 7 ! -- 247 is a catchall default "interrupt" priority for signals, allowing ! -- higher priority than normal tasks, but lower than hardware ! -- priority levels. Protected Object ceilings can override ! -- these values ! -- 246 is used by the Interrupt_Manager task ! ! Max_Priority : constant Positive := 245; Max_Interrupt_Priority : constant Positive := 255; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 87,112 ---- -- Other System-Dependent Declarations type Bit_Order is (High_Order_First, Low_Order_First); ! Default_Bit_Order : constant Bit_Order := Low_Order_First; -- Priority-related Declarations (RM D.1) ! -- 256 is reserved for the VxWorks kernel ! -- 248 - 255 correspond to hardware interrupt levels 0 .. 7 ! -- 247 is a catchall default "interrupt" priority for signals, ! -- allowing higher priority than normal tasks, but lower than ! -- hardware priority levels. Protected Object ceilings can ! -- override these values. ! -- 246 is used by the Interrupt_Manager task + Max_Priority : constant Positive := 245; Max_Interrupt_Priority : constant Positive := 255; ! subtype Any_Priority is Integer range 0 .. 255; ! subtype Priority is Any_Priority range 0 .. 245; ! subtype Interrupt_Priority is Any_Priority range 246 .. 255; ! Default_Priority : constant Priority := 122; private *************** private *** 139,157 **** -- of the individual switch values. AAMP : constant Boolean := False; Command_Line_Args : constant Boolean := False; - Frontend_Layout : constant Boolean := False; - Use_Ada_Main_Program_Name : constant Boolean := True; - Stack_Check_Probes : constant Boolean := False; - Stack_Check_Default : constant Boolean := False; Denorm : constant Boolean := False; ! Machine_Rounds : constant Boolean := True; Machine_Overflows : constant Boolean := False; OpenVMS : constant Boolean := False; Signed_Zeros : constant Boolean := True; ! Long_Shifts_Inlined : constant Boolean := False; ! High_Integrity_Mode : constant Boolean := False; ! Functions_Return_By_DSP : constant Boolean := False; ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; Front_End_ZCX_Support : constant Boolean := False; --- 124,145 ---- -- of the individual switch values. AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := False; Denorm : constant Boolean := False; ! Fractional_Fixed_Ops : constant Boolean := False; ! Frontend_Layout : constant Boolean := False; ! Functions_Return_By_DSP : constant Boolean := False; ! Long_Shifts_Inlined : constant Boolean := False; ! High_Integrity_Mode : constant Boolean := False; Machine_Overflows : constant Boolean := False; + Machine_Rounds : constant Boolean := True; OpenVMS : constant Boolean := False; Signed_Zeros : constant Boolean := True; ! Stack_Check_Default : constant Boolean := False; ! Stack_Check_Probes : constant Boolean := False; ! Use_Ada_Main_Program_Name : constant Boolean := True; ZCX_By_Default : constant Boolean := False; GCC_ZCX_Support : constant Boolean := False; Front_End_ZCX_Support : constant Boolean := False; diff -Nrc3pad gcc-3.2.3/gcc/ada/5ztaprop.adb gcc-3.3/gcc/ada/5ztaprop.adb *** gcc-3.2.3/gcc/ada/5ztaprop.adb 2001-12-16 01:13:30.000000000 +0000 --- gcc-3.3/gcc/ada/5ztaprop.adb 2002-10-23 08:27:55.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3 $ -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ *************** pragma Polling (Off); *** 46,55 **** with System.Tasking.Debug; -- used for Known_Tasks - with Interfaces.C; - -- used for int - -- size_t - with System.Interrupt_Management; -- used for Keep_Unmasked -- Abort_Task_Interrupt --- 44,49 ---- *************** with System.Tasking; *** 78,88 **** with System.Task_Info; -- used for Task_Image ! with System.OS_Primitives; ! -- used for Delay_Modes ! ! with System.VxWorks; ! -- used for TASK_DESC with Unchecked_Conversion; with Unchecked_Deallocation; --- 72,78 ---- with System.Task_Info; -- used for Task_Image ! with Interfaces.C; with Unchecked_Conversion; with Unchecked_Deallocation; *************** package body System.Task_Primitives.Oper *** 92,116 **** use System.Tasking.Debug; use System.Tasking; use System.Task_Info; - use Interfaces.C; use System.OS_Interface; use System.Parameters; ! use System.OS_Primitives; package SSL renames System.Soft_Links; ! ------------------ ! -- Local Data -- ! ------------------ -- The followings are logically constants, but need to be initialized -- at run time. ! ATCB_Key : aliased pthread_key_t; ! -- Key used to find the Ada Task_ID associated with a VxWorks task. ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. --- 82,112 ---- use System.Tasking.Debug; use System.Tasking; use System.Task_Info; use System.OS_Interface; use System.Parameters; ! use type Interfaces.C.int; package SSL renames System.Soft_Links; ! subtype int is System.OS_Interface.int; ! ! Relative : constant := 0; ! ! ---------------- ! -- Local Data -- ! ---------------- -- The followings are logically constants, but need to be initialized -- at run time. ! Current_Task : aliased Task_ID; ! pragma Export (Ada, Current_Task); ! -- Task specific value used to store the Ada Task_ID. ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. *************** package body System.Task_Primitives.Oper *** 132,141 **** FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F'; -- Indicates whether FIFO_Within_Priorities is set. ! Mutex_Protocol : Interfaces.C.int; ! ! Stack_Limit : aliased System.Address; ! pragma Import (C, Stack_Limit, "__gnat_stack_limit"); ----------------------- -- Local Subprograms -- --- 128,134 ---- FIFO_Within_Priorities : constant Boolean := Dispatching_Policy = 'F'; -- Indicates whether FIFO_Within_Priorities is set. ! Mutex_Protocol : Priority_Type; ----------------------- -- Local Subprograms -- *************** package body System.Task_Primitives.Oper *** 143,150 **** procedure Abort_Handler (signo : Signal); - function To_Task_ID is new Unchecked_Conversion (System.Address, Task_ID); - function To_Address is new Unchecked_Conversion (Task_ID, System.Address); ------------------- --- 136,141 ---- *************** package body System.Task_Primitives.Oper *** 153,165 **** procedure Abort_Handler (signo : Signal) is Self_ID : constant Task_ID := Self; ! Result : Interfaces.C.int; Old_Set : aliased sigset_t; begin if Self_ID.Deferral_Level = 0 ! and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level and then ! not Self_ID.Aborting then Self_ID.Aborting := True; --- 144,156 ---- procedure Abort_Handler (signo : Signal) is Self_ID : constant Task_ID := Self; ! Result : int; Old_Set : aliased sigset_t; begin if Self_ID.Deferral_Level = 0 ! and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level ! and then not Self_ID.Aborting then Self_ID.Aborting := True; *************** package body System.Task_Primitives.Oper *** 178,194 **** ----------------- procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is - Task_Descriptor : aliased System.VxWorks.TASK_DESC; - Result : Interfaces.C.int; - begin ! if On then ! Result := taskInfoGet (T.Common.LL.Thread, ! Task_Descriptor'Unchecked_Access); ! pragma Assert (Result = 0); ! ! Stack_Limit := Task_Descriptor.td_pStackLimit; ! end if; end Stack_Guard; ------------------- --- 169,177 ---- ----------------- procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is begin ! -- Nothing needed. ! null; end Stack_Guard; ------------------- *************** package body System.Task_Primitives.Oper *** 205,216 **** ---------- function Self return Task_ID is - Result : System.Address; - begin ! Result := pthread_getspecific (ATCB_Key); ! pragma Assert (Result /= System.Null_Address); ! return To_Task_ID (Result); end Self; ----------------------------- --- 188,196 ---- ---------- function Self return Task_ID is begin ! pragma Assert (Current_Task /= null); ! return Current_Task; end Self; ----------------------------- *************** package body System.Task_Primitives.Oper *** 218,230 **** ----------------------------- procedure Install_Signal_Handlers; ! pragma Inline (Install_Signal_Handlers); procedure Install_Signal_Handlers is act : aliased struct_sigaction; old_act : aliased struct_sigaction; Tmp_Set : aliased sigset_t; ! Result : Interfaces.C.int; begin act.sa_flags := 0; --- 198,210 ---- ----------------------------- procedure Install_Signal_Handlers; ! -- Install the default signal handlers for the current task. procedure Install_Signal_Handlers is act : aliased struct_sigaction; old_act : aliased struct_sigaction; Tmp_Set : aliased sigset_t; ! Result : int; begin act.sa_flags := 0; *************** package body System.Task_Primitives.Oper *** 248,323 **** -- Initialize_Lock -- --------------------- ! -- Note: mutexes and cond_variables needed per-task basis are ! -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as All_Tasks_Lock, Memory_Lock...) ! -- used in RTS is initialized before any status change of RTS. ! -- Therefore rasing Storage_Error in the following routines ! -- should be able to be handled safely. ! ! procedure Initialize_Lock ! (Prio : System.Any_Priority; ! L : access Lock) ! is ! Attributes : aliased pthread_mutexattr_t; ! Result : Interfaces.C.int; begin ! Result := pthread_mutexattr_init (Attributes'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! ! if Result = ENOMEM then ! raise Storage_Error; ! end if; ! ! Result := pthread_mutexattr_setprotocol ! (Attributes'Access, Mutex_Protocol); ! pragma Assert (Result = 0); ! ! Result := pthread_mutexattr_setprioceiling ! (Attributes'Access, Interfaces.C.int (Prio)); ! pragma Assert (Result = 0); ! ! Result := pthread_mutex_init (L, Attributes'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! ! if Result = ENOMEM then ! raise Storage_Error; ! end if; ! ! Result := pthread_mutexattr_destroy (Attributes'Access); ! pragma Assert (Result = 0); end Initialize_Lock; procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is - Attributes : aliased pthread_mutexattr_t; - Result : Interfaces.C.int; - begin ! Result := pthread_mutexattr_init (Attributes'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! ! if Result = ENOMEM then ! raise Storage_Error; ! end if; ! ! Result := pthread_mutexattr_setprotocol ! (Attributes'Access, Mutex_Protocol); ! pragma Assert (Result = 0); ! ! Result := pthread_mutexattr_setprioceiling ! (Attributes'Access, ! Interfaces.C.int (System.Any_Priority'Last)); ! pragma Assert (Result = 0); ! ! Result := pthread_mutex_init (L, Attributes'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! ! if Result = ENOMEM then ! raise Storage_Error; ! end if; ! ! Result := pthread_mutexattr_destroy (Attributes'Access); ! pragma Assert (Result = 0); end Initialize_Lock; ------------------- --- 228,247 ---- -- Initialize_Lock -- --------------------- ! procedure Initialize_Lock (Prio : System.Any_Priority; L : access Lock) is begin ! L.Mutex := semMCreate (SEM_Q_PRIORITY + SEM_INVERSION_SAFE); ! L.Prio_Ceiling := int (Prio); ! L.Protocol := Mutex_Protocol; ! pragma Assert (L.Mutex /= 0); end Initialize_Lock; procedure Initialize_Lock (L : access RTS_Lock; Level : Lock_Level) is begin ! L.Mutex := semMCreate (SEM_Q_PRIORITY + SEM_INVERSION_SAFE); ! L.Prio_Ceiling := int (System.Any_Priority'Last); ! L.Protocol := Mutex_Protocol; ! pragma Assert (L.Mutex /= 0); end Initialize_Lock; ------------------- *************** package body System.Task_Primitives.Oper *** 325,342 **** ------------------- procedure Finalize_Lock (L : access Lock) is ! Result : Interfaces.C.int; ! begin ! Result := pthread_mutex_destroy (L); pragma Assert (Result = 0); end Finalize_Lock; procedure Finalize_Lock (L : access RTS_Lock) is ! Result : Interfaces.C.int; ! begin ! Result := pthread_mutex_destroy (L); pragma Assert (Result = 0); end Finalize_Lock; --- 249,264 ---- ------------------- procedure Finalize_Lock (L : access Lock) is ! Result : int; begin ! Result := semDelete (L.Mutex); pragma Assert (Result = 0); end Finalize_Lock; procedure Finalize_Lock (L : access RTS_Lock) is ! Result : int; begin ! Result := semDelete (L.Mutex); pragma Assert (Result = 0); end Finalize_Lock; *************** package body System.Task_Primitives.Oper *** 345,375 **** ---------------- procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is ! Result : Interfaces.C.int; ! begin ! Result := pthread_mutex_lock (L); ! ! -- Assume that the cause of EINVAL is a priority ceiling violation ! Ceiling_Violation := (Result = EINVAL); ! pragma Assert (Result = 0 or else Result = EINVAL); end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is ! Result : Interfaces.C.int; ! begin ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); end Write_Lock; procedure Write_Lock (T : Task_ID) is ! Result : Interfaces.C.int; ! begin ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Write_Lock; --------------- --- 267,305 ---- ---------------- procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is ! Result : int; begin ! if L.Protocol = Prio_Protect ! and then int (Self.Common.Current_Priority) > L.Prio_Ceiling ! then ! Ceiling_Violation := True; ! return; ! else ! Ceiling_Violation := False; ! end if; ! Result := semTake (L.Mutex, WAIT_FOREVER); ! pragma Assert (Result = 0); end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is ! Result : int; begin ! if not Single_Lock or else Global_Lock then ! Result := semTake (L.Mutex, WAIT_FOREVER); ! pragma Assert (Result = 0); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is ! Result : int; begin ! if not Single_Lock then ! Result := semTake (T.Common.LL.L.Mutex, WAIT_FOREVER); ! pragma Assert (Result = 0); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 386,430 **** ------------ procedure Unlock (L : access Lock) is ! Result : Interfaces.C.int; ! begin ! Result := pthread_mutex_unlock (L); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock) is ! Result : Interfaces.C.int; ! begin ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_ID) is ! Result : Interfaces.C.int; ! begin ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Unlock; ! ------------- ! -- Sleep -- ! ------------- ! ! procedure Sleep (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) is ! Result : Interfaces.C.int; begin pragma Assert (Self_ID = Self); - Result := pthread_cond_wait (Self_ID.Common.LL.CV'Access, - Self_ID.Common.LL.L'Access); ! -- EINTR is not considered a failure. ! pragma Assert (Result = 0 or else Result = EINTR); end Sleep; ----------------- --- 316,397 ---- ------------ procedure Unlock (L : access Lock) is ! Result : int; begin ! Result := semGive (L.Mutex); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is ! Result : int; begin ! if not Single_Lock or else Global_Lock then ! Result := semGive (L.Mutex); ! pragma Assert (Result = 0); ! end if; end Unlock; procedure Unlock (T : Task_ID) is ! Result : int; begin ! if not Single_Lock then ! Result := semGive (T.Common.LL.L.Mutex); ! pragma Assert (Result = 0); ! end if; end Unlock; ! ----------- ! -- Sleep -- ! ----------- + procedure Sleep (Self_ID : Task_ID; Reason : System.Tasking.Task_States) is + Result : int; begin pragma Assert (Self_ID = Self); ! -- Disable task scheduling. ! Result := taskLock; ! ! -- Release the mutex before sleeping. ! ! if Single_Lock then ! Result := semGive (Single_RTS_Lock.Mutex); ! else ! Result := semGive (Self_ID.Common.LL.L.Mutex); ! end if; ! ! pragma Assert (Result = 0); ! ! -- Indicate that there is another thread waiting on the CV. ! ! Self_ID.Common.LL.CV.Waiting := Self_ID.Common.LL.CV.Waiting + 1; ! ! -- Perform a blocking operation to take the CV semaphore. ! -- Note that a blocking operation in VxWorks will reenable ! -- task scheduling. When we are no longer blocked and control ! -- is returned, task scheduling will again be disabled. ! ! Result := semTake (Self_ID.Common.LL.CV.Sem, WAIT_FOREVER); ! ! if Result /= 0 then ! Self_ID.Common.LL.CV.Waiting := Self_ID.Common.LL.CV.Waiting - 1; ! pragma Assert (False); ! end if; ! ! -- Take the mutex back. ! ! if Single_Lock then ! Result := semTake (Single_RTS_Lock.Mutex, WAIT_FOREVER); ! else ! Result := semTake (Self_ID.Common.LL.L.Mutex, WAIT_FOREVER); ! end if; ! ! pragma Assert (Result = 0); ! ! -- Reenable task scheduling. ! ! Result := taskUnlock; end Sleep; ----------------- *************** package body System.Task_Primitives.Oper *** 443,484 **** Timedout : out Boolean; Yielded : out Boolean) is ! Check_Time : constant Duration := Monotonic_Clock; ! Abs_Time : Duration; ! Request : aliased timespec; ! Result : Interfaces.C.int; begin Timedout := True; ! Yielded := False; if Mode = Relative then ! Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time; else ! Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time); end if; ! if Abs_Time > Check_Time then ! Request := To_Timespec (Abs_Time); ! loop ! exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level ! or else Self_ID.Pending_Priority_Change; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); ! Yielded := True; ! exit when Abs_Time <= Monotonic_Clock; ! if Result = 0 or Result = EINTR then ! -- Somebody may have called Wakeup for us Timedout := False; - exit; end if; ! pragma Assert (Result = ETIMEDOUT); ! end loop; end if; end Timed_Sleep; --- 410,487 ---- Timedout : out Boolean; Yielded : out Boolean) is ! Ticks : int; ! Result : int; begin Timedout := True; ! Yielded := True; if Mode = Relative then ! -- Systematically add one since the first tick will delay ! -- *at most* 1 / Rate_Duration seconds, so we need to add one to ! -- be on the safe side. ! ! Ticks := To_Clock_Ticks (Time) + 1; else ! Ticks := To_Clock_Ticks (Time - Monotonic_Clock); end if; ! if Ticks > 0 then ! -- Disable task scheduling. ! Result := taskLock; ! -- Release the mutex before sleeping. ! if Single_Lock then ! Result := semGive (Single_RTS_Lock.Mutex); ! else ! Result := semGive (Self_ID.Common.LL.L.Mutex); ! end if; ! ! pragma Assert (Result = 0); ! ! -- Indicate that there is another thread waiting on the CV. ! ! Self_ID.Common.LL.CV.Waiting := Self_ID.Common.LL.CV.Waiting + 1; ! ! -- Perform a blocking operation to take the CV semaphore. ! -- Note that a blocking operation in VxWorks will reenable ! -- task scheduling. When we are no longer blocked and control ! -- is returned, task scheduling will again be disabled. ! ! Result := semTake (Self_ID.Common.LL.CV.Sem, Ticks); ! ! if Result = 0 then ! -- Somebody may have called Wakeup for us ! ! Timedout := False; ! ! else ! Self_ID.Common.LL.CV.Waiting := Self_ID.Common.LL.CV.Waiting - 1; + if errno /= S_objLib_OBJ_TIMEOUT then Timedout := False; end if; + end if; ! -- Take the mutex back. ! ! if Single_Lock then ! Result := semTake (Single_RTS_Lock.Mutex, WAIT_FOREVER); ! else ! Result := semTake (Self_ID.Common.LL.L.Mutex, WAIT_FOREVER); ! end if; ! ! pragma Assert (Result = 0); ! ! -- Reenable task scheduling. ! ! Result := taskUnlock; ! ! else ! taskDelay (0); end if; end Timed_Sleep; *************** package body System.Task_Primitives.Oper *** 487,522 **** ----------------- -- This is for use in implementing delay statements, so ! -- we assume the caller is abort-deferred but is holding ! -- no locks. procedure Timed_Delay (Self_ID : Task_ID; Time : Duration; Mode : ST.Delay_Modes) is ! Check_Time : constant Duration := Monotonic_Clock; ! Abs_Time : Duration; ! Request : aliased timespec; ! Result : Interfaces.C.int; ! Yielded : Boolean := False; begin ! -- Only the little window between deferring abort and ! -- locking Self_ID is the reason we need to ! -- check for pending abort and priority change below! :( ! SSL.Abort_Defer.all; ! Write_Lock (Self_ID); if Mode = Relative then ! Abs_Time := Time + Check_Time; else ! Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time); end if; ! if Abs_Time > Check_Time then ! Request := To_Timespec (Abs_Time); Self_ID.Common.State := Delay_Sleep; loop --- 490,537 ---- ----------------- -- This is for use in implementing delay statements, so ! -- we assume the caller is holding no locks. procedure Timed_Delay (Self_ID : Task_ID; Time : Duration; Mode : ST.Delay_Modes) is ! Orig : constant Duration := Monotonic_Clock; ! Absolute : Duration; ! Ticks : int; ! Timedout : Boolean; ! Result : int; ! begin + SSL.Abort_Defer.all; ! if Single_Lock then ! Result := semTake (Single_RTS_Lock.Mutex, WAIT_FOREVER); ! else ! Result := semTake (Self_ID.Common.LL.L.Mutex, WAIT_FOREVER); ! end if; ! pragma Assert (Result = 0); if Mode = Relative then ! Absolute := Orig + Time; ! ! Ticks := To_Clock_Ticks (Time); ! ! if Ticks > 0 then ! -- The first tick will delay anytime between 0 and ! -- 1 / sysClkRateGet seconds, so we need to add one to ! -- be on the safe side. ! ! Ticks := Ticks + 1; ! end if; else ! Absolute := Time; ! Ticks := To_Clock_Ticks (Time - Orig); end if; ! if Ticks > 0 then Self_ID.Common.State := Delay_Sleep; loop *************** package body System.Task_Primitives.Oper *** 528,551 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); ! Yielded := True; ! exit when Abs_Time <= Monotonic_Clock; ! pragma Assert (Result = 0 ! or else Result = ETIMEDOUT ! or else Result = EINTR); end loop; Self_ID.Common.State := Runnable; end if; ! Unlock (Self_ID); ! ! if not Yielded then ! Result := sched_yield; end if; SSL.Abort_Undefer.all; end Timed_Delay; --- 543,603 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! Timedout := False; ! Result := taskLock; ! if Single_Lock then ! Result := semGive (Single_RTS_Lock.Mutex); ! else ! Result := semGive (Self_ID.Common.LL.L.Mutex); ! end if; ! ! pragma Assert (Result = 0); ! ! -- Indicate that there is another thread waiting on the CV. ! ! Self_ID.Common.LL.CV.Waiting := Self_ID.Common.LL.CV.Waiting + 1; ! ! Result := semTake (Self_ID.Common.LL.CV.Sem, Ticks); ! ! if Result /= 0 then ! Self_ID.Common.LL.CV.Waiting := ! Self_ID.Common.LL.CV.Waiting - 1; ! ! if errno = S_objLib_OBJ_TIMEOUT then ! Timedout := True; ! else ! Ticks := To_Clock_Ticks (Absolute - Monotonic_Clock); ! end if; ! end if; ! ! if Single_Lock then ! Result := semTake (Single_RTS_Lock.Mutex, WAIT_FOREVER); ! else ! Result := semTake (Self_ID.Common.LL.L.Mutex, WAIT_FOREVER); ! end if; ! ! pragma Assert (Result = 0); ! ! -- Reenable task scheduling. ! ! Result := taskUnlock; ! ! exit when Timedout; end loop; Self_ID.Common.State := Runnable; + else + taskDelay (0); end if; ! if Single_Lock then ! Result := semGive (Single_RTS_Lock.Mutex); ! else ! Result := semGive (Self_ID.Common.LL.L.Mutex); end if; + + pragma Assert (Result = 0); SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 555,561 **** function Monotonic_Clock return Duration is TS : aliased timespec; ! Result : Interfaces.C.int; begin Result := clock_gettime (CLOCK_REALTIME, TS'Unchecked_Access); pragma Assert (Result = 0); --- 607,614 ---- function Monotonic_Clock return Duration is TS : aliased timespec; ! Result : int; ! begin Result := clock_gettime (CLOCK_REALTIME, TS'Unchecked_Access); pragma Assert (Result = 0); *************** package body System.Task_Primitives.Oper *** 576,586 **** ------------ procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is ! Result : Interfaces.C.int; ! begin ! Result := pthread_cond_signal (T.Common.LL.CV'Access); ! pragma Assert (Result = 0); end Wakeup; ----------- --- 629,658 ---- ------------ procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is ! Result : int; begin ! -- Disable task scheduling. ! ! Result := taskLock; ! ! -- Iff someone is currently waiting on the condition variable ! -- then release the semaphore; we don't want to leave the ! -- semaphore in the full state because the next guy to do ! -- a condition wait operation would not block. ! ! if T.Common.LL.CV.Waiting > 0 then ! Result := semGive (T.Common.LL.CV.Sem); ! ! -- One less thread waiting on the CV. ! ! T.Common.LL.CV.Waiting := T.Common.LL.CV.Waiting - 1; ! ! pragma Assert (Result = 0); ! end if; ! ! -- Reenable task scheduling. ! ! Result := taskUnlock; end Wakeup; ----------- *************** package body System.Task_Primitives.Oper *** 588,597 **** ----------- procedure Yield (Do_Yield : Boolean := True) is ! Result : Interfaces.C.int; ! begin ! Result := sched_yield; end Yield; ------------------ --- 660,668 ---- ----------- procedure Yield (Do_Yield : Boolean := True) is ! Result : int; begin ! Result := taskDelay (0); end Yield; ------------------ *************** package body System.Task_Primitives.Oper *** 613,637 **** Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is - Param : aliased struct_sched_param; Array_Item : Integer; ! Result : Interfaces.C.int; begin ! Param.sched_priority := Interfaces.C.int (Prio); ! ! if Time_Slice_Val <= 0 then ! Result := pthread_setschedparam ! (T.Common.LL.Thread, SCHED_FIFO, Param'Access); ! else ! Result := pthread_setschedparam ! (T.Common.LL.Thread, SCHED_RR, Param'Access); ! end if; ! pragma Assert (Result = 0); if FIFO_Within_Priorities then - -- Annex D requirement [RM D.2.2 par. 9]: -- If the task drops its priority due to the loss of inherited -- priority, it is added at the head of the ready queue for its --- 684,698 ---- Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is Array_Item : Integer; ! Result : int; begin ! Result := taskPrioritySet ! (T.Common.LL.Thread, To_VxWorks_Priority (int (Prio))); pragma Assert (Result = 0); if FIFO_Within_Priorities then -- Annex D requirement [RM D.2.2 par. 9]: -- If the task drops its priority due to the loss of inherited -- priority, it is added at the head of the ready queue for its *************** package body System.Task_Primitives.Oper *** 676,693 **** ---------------- procedure Enter_Task (Self_ID : Task_ID) is ! Result : Interfaces.C.int; procedure Init_Float; pragma Import (C, Init_Float, "__gnat_init_float"); -- Properly initializes the FPU for PPC/MIPS systems. begin ! Self_ID.Common.LL.Thread := pthread_self; ! ! Result := pthread_setspecific (ATCB_Key, To_Address (Self_ID)); ! pragma Assert (Result = 0); ! Init_Float; -- Install the signal handlers. --- 737,752 ---- ---------------- procedure Enter_Task (Self_ID : Task_ID) is ! Result : int; procedure Init_Float; pragma Import (C, Init_Float, "__gnat_init_float"); -- Properly initializes the FPU for PPC/MIPS systems. begin ! Self_ID.Common.LL.Thread := taskIdSelf; ! Result := taskVarAdd (0, Current_Task'Address); ! Current_Task := Self_ID; Init_Float; -- Install the signal handlers. *************** package body System.Task_Primitives.Oper *** 696,712 **** Install_Signal_Handlers; ! Lock_All_Tasks_List; ! for T in Known_Tasks'Range loop ! if Known_Tasks (T) = null then ! Known_Tasks (T) := Self_ID; ! Self_ID.Known_Tasks_Index := T; exit; end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 755,771 ---- Install_Signal_Handlers; ! Lock_RTS; ! for J in Known_Tasks'Range loop ! if Known_Tasks (J) = null then ! Known_Tasks (J) := Self_ID; ! Self_ID.Known_Tasks_Index := J; exit; end if; end loop; ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 718,787 **** return new Ada_Task_Control_Block (Entry_Num); end New_ATCB; ! ---------------------- ! -- Initialize_TCB -- ! ---------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is - Mutex_Attr : aliased pthread_mutexattr_t; - Result : Interfaces.C.int; - Cond_Attr : aliased pthread_condattr_t; - begin ! Self_ID.Common.LL.Thread := null_pthread; ! ! Result := pthread_mutexattr_init (Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! ! Result := pthread_mutexattr_setprotocol ! (Mutex_Attr'Access, Mutex_Protocol); ! pragma Assert (Result = 0); ! ! Result := pthread_mutexattr_setprioceiling ! (Mutex_Attr'Access, Interfaces.C.int (System.Any_Priority'Last)); ! pragma Assert (Result = 0); ! ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! ! Result := pthread_mutexattr_destroy (Mutex_Attr'Access); ! pragma Assert (Result = 0); ! ! Result := pthread_condattr_init (Cond_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); Succeeded := False; - return; - end if; - - Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, - Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - - if Result = 0 then - Succeeded := True; else ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! Succeeded := False; ! end if; ! Result := pthread_condattr_destroy (Cond_Attr'Access); ! pragma Assert (Result = 0); end Initialize_TCB; ----------------- --- 777,801 ---- return new Ada_Task_Control_Block (Entry_Num); end New_ATCB; ! -------------------- ! -- Initialize_TCB -- ! -------------------- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is begin ! Self_ID.Common.LL.CV.Sem := semBCreate (SEM_Q_PRIORITY, SEM_EMPTY); ! Self_ID.Common.LL.CV.Waiting := 0; ! Self_ID.Common.LL.Thread := 0; ! if Self_ID.Common.LL.CV.Sem = 0 then Succeeded := False; else ! Succeeded := True; ! if not Single_Lock then ! Initialize_Lock (Self_ID.Common.LL.L'Access, ATCB_Level); ! end if; ! end if; end Initialize_TCB; ----------------- *************** package body System.Task_Primitives.Oper *** 797,818 **** is use type System.Task_Info.Task_Image_Type; ! Adjusted_Stack_Size : Interfaces.C.size_t; ! Attributes : aliased pthread_attr_t; ! Result : Interfaces.C.int; ! ! function Thread_Body_Access is new ! Unchecked_Conversion (System.Address, Thread_Body); begin if Stack_Size = Unspecified_Size then ! Adjusted_Stack_Size := Interfaces.C.size_t (Default_Stack_Size); elsif Stack_Size < Minimum_Stack_Size then ! Adjusted_Stack_Size := Interfaces.C.size_t (Minimum_Stack_Size); else ! Adjusted_Stack_Size := Interfaces.C.size_t (Stack_Size); end if; -- Ask for 4 extra bytes of stack space so that the ATCB --- 811,827 ---- is use type System.Task_Info.Task_Image_Type; ! Adjusted_Stack_Size : size_t; begin if Stack_Size = Unspecified_Size then ! Adjusted_Stack_Size := size_t (Default_Stack_Size); elsif Stack_Size < Minimum_Stack_Size then ! Adjusted_Stack_Size := size_t (Minimum_Stack_Size); else ! Adjusted_Stack_Size := size_t (Stack_Size); end if; -- Ask for 4 extra bytes of stack space so that the ATCB *************** package body System.Task_Primitives.Oper *** 821,827 **** -- gets the amount of stack requested exclusive of the needs -- of the runtime. -- ! -- We also have to allocate 10 more bytes for the task name -- storage and enough space for the Wind Task Control Block -- which is around 0x778 bytes. VxWorks also seems to carve out -- additional space, so use 2048 as a nice round number. --- 830,836 ---- -- gets the amount of stack requested exclusive of the needs -- of the runtime. -- ! -- We also have to allocate n more bytes for the task name -- storage and enough space for the Wind Task Control Block -- which is around 0x778 bytes. VxWorks also seems to carve out -- additional space, so use 2048 as a nice round number. *************** package body System.Task_Primitives.Oper *** 832,890 **** -- set the task name to something appropriate. Adjusted_Stack_Size := Adjusted_Stack_Size + 2048; ! Result := pthread_attr_init (Attributes'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! ! Result := pthread_attr_setdetachstate ! (Attributes'Access, PTHREAD_CREATE_DETACHED); ! pragma Assert (Result = 0); ! ! Result := pthread_attr_setstacksize ! (Attributes'Access, Adjusted_Stack_Size); ! pragma Assert (Result = 0); ! -- Let's check to see if the task has an image string and ! -- use that as the VxWorks task name. ! if T.Common.Task_Image /= null then declare ! Task_Name : aliased constant String := ! T.Common.Task_Image.all & ASCII.NUL; begin ! Result := pthread_attr_setname_np ! (Attributes'Access, Task_Name'Address); ! -- Since the initial signal mask of a thread is inherited from the ! -- creator, and the Environment task has all its signals masked, ! -- we do not need to manipulate caller's signal mask at this ! -- point. All tasks in RTS will have All_Tasks_Mask initially. ! Result := pthread_create ! (T.Common.LL.Thread'Access, ! Attributes'Access, ! Thread_Body_Access (Wrapper), To_Address (T)); end; - else - -- No specified task name - Result := pthread_create - (T.Common.LL.Thread'Access, - Attributes'Access, - Thread_Body_Access (Wrapper), - To_Address (T)); end if; - pragma Assert (Result = 0); - - Succeeded := Result = 0; ! Result := pthread_attr_destroy (Attributes'Access); ! pragma Assert (Result = 0); Task_Creation_Hook (T.Common.LL.Thread); - Set_Priority (T, Priority); end Create_Task; --- 841,883 ---- -- set the task name to something appropriate. Adjusted_Stack_Size := Adjusted_Stack_Size + 2048; ! -- Since the initial signal mask of a thread is inherited from the ! -- creator, and the Environment task has all its signals masked, we ! -- do not need to manipulate caller's signal mask at this point. ! -- All tasks in RTS will have All_Tasks_Mask initially. ! if T.Common.Task_Image = null then ! T.Common.LL.Thread := taskSpawn ! (System.Null_Address, ! To_VxWorks_Priority (int (Priority)), ! VX_FP_TASK, ! Adjusted_Stack_Size, ! Wrapper, ! To_Address (T)); ! else declare ! Name : aliased String (1 .. T.Common.Task_Image'Length + 1); begin ! Name (1 .. Name'Last - 1) := T.Common.Task_Image.all; ! Name (Name'Last) := ASCII.NUL; ! T.Common.LL.Thread := taskSpawn ! (Name'Address, ! To_VxWorks_Priority (int (Priority)), ! VX_FP_TASK, ! Adjusted_Stack_Size, ! Wrapper, To_Address (T)); end; end if; ! if T.Common.LL.Thread = -1 then ! Succeeded := False; ! else ! Succeeded := True; ! end if; Task_Creation_Hook (T.Common.LL.Thread); Set_Priority (T, Priority); end Create_Task; *************** package body System.Task_Primitives.Oper *** 893,911 **** ------------------ procedure Finalize_TCB (T : Task_ID) is ! Result : Interfaces.C.int; Tmp : Task_ID := T; procedure Free is new Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! T.Common.LL.Thread := null_pthread; ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); if T.Known_Tasks_Index /= -1 then --- 886,906 ---- ------------------ procedure Finalize_TCB (T : Task_ID) is ! Result : int; Tmp : Task_ID := T; procedure Free is new Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! if Single_Lock then ! Result := semDelete (T.Common.LL.L.Mutex); ! pragma Assert (Result = 0); ! end if; ! T.Common.LL.Thread := 0; ! Result := semDelete (T.Common.LL.CV.Sem); pragma Assert (Result = 0); if T.Known_Tasks_Index /= -1 then *************** package body System.Task_Primitives.Oper *** 922,928 **** procedure Exit_Task is begin Task_Termination_Hook; ! pthread_exit (System.Null_Address); end Exit_Task; ---------------- --- 917,923 ---- procedure Exit_Task is begin Task_Termination_Hook; ! taskDelete (0); end Exit_Task; ---------------- *************** package body System.Task_Primitives.Oper *** 930,936 **** ---------------- procedure Abort_Task (T : Task_ID) is ! Result : Interfaces.C.int; begin Result := kill (T.Common.LL.Thread, Signal (Interrupt_Management.Abort_Task_Interrupt)); --- 925,931 ---- ---------------- procedure Abort_Task (T : Task_ID) is ! Result : int; begin Result := kill (T.Common.LL.Thread, Signal (Interrupt_Management.Abort_Task_Interrupt)); *************** package body System.Task_Primitives.Oper *** 941,947 **** -- Check_Exit -- ---------------- ! -- Dummy versions. The only currently working versions is for solaris -- (native). function Check_Exit (Self_ID : ST.Task_ID) return Boolean is --- 936,942 ---- -- Check_Exit -- ---------------- ! -- Dummy versions. The only currently working version is for solaris -- (native). function Check_Exit (Self_ID : ST.Task_ID) return Boolean is *************** package body System.Task_Primitives.Oper *** 967,989 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 962,984 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 993,999 **** (T : ST.Task_ID; Thread_Self : Thread_Id) return Boolean is begin ! if T.Common.LL.Thread /= null_pthread and then T.Common.LL.Thread /= Thread_Self then return taskSuspend (T.Common.LL.Thread) = 0; --- 988,994 ---- (T : ST.Task_ID; Thread_Self : Thread_Id) return Boolean is begin ! if T.Common.LL.Thread /= 0 and then T.Common.LL.Thread /= Thread_Self then return taskSuspend (T.Common.LL.Thread) = 0; *************** package body System.Task_Primitives.Oper *** 1010,1016 **** (T : ST.Task_ID; Thread_Self : Thread_Id) return Boolean is begin ! if T.Common.LL.Thread /= null_pthread and then T.Common.LL.Thread /= Thread_Self then return taskResume (T.Common.LL.Thread) = 0; --- 1005,1011 ---- (T : ST.Task_ID; Thread_Self : Thread_Id) return Boolean is begin ! if T.Common.LL.Thread /= 0 and then T.Common.LL.Thread /= Thread_Self then return taskResume (T.Common.LL.Thread) = 0; *************** package body System.Task_Primitives.Oper *** 1029,1073 **** -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); Enter_Task (Environment_Task); end Initialize; begin declare ! Result : Interfaces.C.int; ! begin if Locking_Policy = 'C' then ! Mutex_Protocol := PTHREAD_PRIO_PROTECT; else ! -- We default to VxWorks native priority inheritence ! -- and inversion safe mutexes with no ceiling checks. ! Mutex_Protocol := PTHREAD_PRIO_INHERIT; end if; if Time_Slice_Val > 0 then ! Result := pthread_sched_rr_set_interval ! (Interfaces.C.int (Time_Slice_Val)); end if; - -- Prepare the set of signals that should unblocked in all tasks - Result := sigemptyset (Unblocked_Signal_Mask'Access); pragma Assert (Result = 0); - - for J in Interrupt_Management.Interrupt_ID loop - if Interrupt_Management.Keep_Unmasked (J) then - Result := sigaddset (Unblocked_Signal_Mask'Access, Signal (J)); - pragma Assert (Result = 0); - end if; - end loop; - - Result := pthread_key_create (ATCB_Key'Access, null); - pragma Assert (Result = 0); - - Result := taskVarAdd (getpid, Stack_Limit'Access); - pragma Assert (Result = 0); end; end System.Task_Primitives.Operations; --- 1024,1053 ---- -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Enter_Task (Environment_Task); end Initialize; begin declare ! Result : int; begin if Locking_Policy = 'C' then ! Mutex_Protocol := Prio_Protect; ! elsif Locking_Policy = 'I' then ! Mutex_Protocol := Prio_Inherit; else ! Mutex_Protocol := Prio_None; end if; if Time_Slice_Val > 0 then ! Result := kernelTimeSlice ! (To_Clock_Ticks ! (Duration (Time_Slice_Val) / Duration (1_000_000.0))); end if; Result := sigemptyset (Unblocked_Signal_Mask'Access); pragma Assert (Result = 0); end; end System.Task_Primitives.Operations; diff -Nrc3pad gcc-3.2.3/gcc/ada/6vcpp.adb gcc-3.3/gcc/ada/6vcpp.adb *** gcc-3.2.3/gcc/ada/6vcpp.adb 2002-05-04 03:27:19.000000000 +0000 --- gcc-3.3/gcc/ada/6vcpp.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 2000, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2000-2002, 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- -- *************** package body Interfaces.CPP is *** 76,88 **** function To_Type_Specific_Data_Ptr is new Unchecked_Conversion (Address, Type_Specific_Data_Ptr); - function To_Address is new Unchecked_Conversion (Vtable_Ptr, Address); function To_Address is new Unchecked_Conversion (Type_Specific_Data_Ptr, Address); - function To_Vtable_Ptr is new Unchecked_Conversion (Tag, Vtable_Ptr); - function To_Tag is new Unchecked_Conversion (Vtable_Ptr, Tag); - --------------------------------------------- -- Unchecked Conversions for String Fields -- --------------------------------------------- --- 75,83 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/6vcstrea.adb gcc-3.3/gcc/ada/6vcstrea.adb *** gcc-3.2.3/gcc/ada/6vcstrea.adb 2002-05-04 03:27:19.000000000 +0000 --- gcc-3.3/gcc/ada/6vcstrea.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1996-1999 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1996-2002 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- -- *************** *** 35,40 **** --- 34,40 ---- -- This is the Alpha/VMS version. + with Unchecked_Conversion; package body Interfaces.C_Streams is ------------ diff -Nrc3pad gcc-3.2.3/gcc/ada/6vinterf.ads gcc-3.3/gcc/ada/6vinterf.ads *** gcc-3.2.3/gcc/ada/6vinterf.ads 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/6vinterf.ads 2002-03-14 10:58:43.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/7sinmaop.adb gcc-3.3/gcc/ada/7sinmaop.adb *** gcc-3.2.3/gcc/ada/7sinmaop.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/7sinmaop.adb 2002-03-14 10:58:43.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1998, Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/7sintman.adb gcc-3.3/gcc/ada/7sintman.adb *** gcc-3.2.3/gcc/ada/7sintman.adb 2001-12-16 01:13:30.000000000 +0000 --- gcc-3.3/gcc/ada/7sintman.adb 2002-03-14 10:58:43.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2002, Florida State University -- -- -- -- GNARL 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- -- *************** begin *** 189,201 **** act.sa_mask := Signal_Mask; Keep_Unmasked (Abort_Task_Interrupt) := True; - Keep_Unmasked (SIGXCPU) := True; - Keep_Unmasked (SIGFPE) := True; - Result := - sigaction - (Signal (SIGFPE), act'Unchecked_Access, - old_act'Unchecked_Access); - pragma Assert (Result = 0); -- By keeping SIGINT unmasked, allow the user to do a Ctrl-C, but at -- the same time, disable the ability of handling this signal via --- 188,193 ---- *************** begin *** 208,225 **** Keep_Unmasked (SIGINT) := True; end if; ! for J in ! Exception_Interrupts'First + 1 .. Exception_Interrupts'Last ! loop Keep_Unmasked (Exception_Interrupts (J)) := True; ! if Unreserve_All_Interrupts = 0 then ! Result := ! sigaction ! (Signal (Exception_Interrupts (J)), act'Unchecked_Access, ! old_act'Unchecked_Access); ! pragma Assert (Result = 0); ! end if; end loop; for J in Unmasked'Range loop --- 200,213 ---- Keep_Unmasked (SIGINT) := True; end if; ! for J in Exception_Interrupts'Range loop Keep_Unmasked (Exception_Interrupts (J)) := True; ! Result := ! sigaction ! (Signal (Exception_Interrupts (J)), act'Unchecked_Access, ! old_act'Unchecked_Access); ! pragma Assert (Result = 0); end loop; for J in Unmasked'Range loop diff -Nrc3pad gcc-3.2.3/gcc/ada/7sosinte.adb gcc-3.3/gcc/ada/7sosinte.adb *** gcc-3.2.3/gcc/ada/7sosinte.adb 2001-10-02 13:42:29.000000000 +0000 --- gcc-3.3/gcc/ada/7sosinte.adb 2002-03-14 10:58:44.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1997-2001 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/7sosprim.adb gcc-3.3/gcc/ada/7sosprim.adb *** gcc-3.2.3/gcc/ada/7sosprim.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/7sosprim.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/7staprop.adb gcc-3.3/gcc/ada/7staprop.adb *** gcc-3.2.3/gcc/ada/7staprop.adb 2001-12-16 01:13:30.000000000 +0000 --- gcc-3.3/gcc/ada/7staprop.adb 2002-10-23 08:27:55.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ *************** package body System.Task_Primitives.Oper *** 101,115 **** package SSL renames System.Soft_Links; ! ------------------ ! -- Local Data -- ! ------------------ -- The followings are logically constants, but need to be initialized -- at run time. ! All_Tasks_L : aliased System.Task_Primitives.RTS_Lock; ! -- See comments on locking rules in System.Tasking (spec). Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. --- 99,115 ---- package SSL renames System.Soft_Links; ! ---------------- ! -- Local Data -- ! ---------------- -- The followings are logically constants, but need to be initialized -- at run time. ! Single_RTS_Lock : aliased RTS_Lock; ! -- This is a lock to allow only one thread of control in the RTS at ! -- a time; it is used to execute in mutual exclusion from all other tasks. ! -- Used mainly in Single_Lock mode, but also to protect All_Tasks_List Environment_Task_ID : Task_ID; -- A variable to hold Task_ID for the environment task. *************** package body System.Task_Primitives.Oper *** 143,150 **** -- Local Subprograms -- ----------------------- ! procedure Abort_Handler ! (Sig : Signal); function To_Task_ID is new Unchecked_Conversion (System.Address, Task_ID); --- 143,149 ---- -- Local Subprograms -- ----------------------- ! procedure Abort_Handler (Sig : Signal); function To_Task_ID is new Unchecked_Conversion (System.Address, Task_ID); *************** package body System.Task_Primitives.Oper *** 252,266 **** -- Context.PC := Raise_Abort_Signal'Address; -- return; -- end if; - end Abort_Handler; ! ------------------- ! -- Stack_Guard -- ! ------------------- procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is - Stack_Base : constant Address := Get_Stack_Base (T.Common.LL.Thread); Guard_Page_Address : Address; --- 251,263 ---- -- Context.PC := Raise_Abort_Signal'Address; -- return; -- end if; end Abort_Handler; ! ----------------- ! -- Stack_Guard -- ! ----------------- procedure Stack_Guard (T : ST.Task_ID; On : Boolean) is Stack_Base : constant Address := Get_Stack_Base (T.Common.LL.Thread); Guard_Page_Address : Address; *************** package body System.Task_Primitives.Oper *** 304,310 **** -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as All_Tasks_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. --- 301,307 ---- -- Note: mutexes and cond_variables needed per-task basis are -- initialized in Initialize_TCB and the Storage_Error is ! -- handled. Other mutexes (such as RTS_Lock, Memory_Lock...) -- used in RTS is initialized before any status change of RTS. -- Therefore rasing Storage_Error in the following routines -- should be able to be handled safely. *************** package body System.Task_Primitives.Oper *** 395,401 **** procedure Finalize_Lock (L : access Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_destroy (L); pragma Assert (Result = 0); --- 392,397 ---- *************** package body System.Task_Primitives.Oper *** 403,409 **** procedure Finalize_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_destroy (L); pragma Assert (Result = 0); --- 399,404 ---- *************** package body System.Task_Primitives.Oper *** 415,421 **** procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean) is Result : Interfaces.C.int; - begin Result := pthread_mutex_lock (L); --- 410,415 ---- *************** package body System.Task_Primitives.Oper *** 425,444 **** pragma Assert (Result = 0 or else Result = EINVAL); end Write_Lock; ! procedure Write_Lock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Write_Lock; --------------- --- 419,442 ---- pragma Assert (Result = 0 or else Result = EINVAL); end Write_Lock; ! procedure Write_Lock ! (L : access RTS_Lock; Global_Lock : Boolean := False) ! is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_lock (L); ! pragma Assert (Result = 0); ! end if; end Write_Lock; procedure Write_Lock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_lock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Write_Lock; --------------- *************** package body System.Task_Primitives.Oper *** 456,495 **** procedure Unlock (L : access Lock) is Result : Interfaces.C.int; - begin Result := pthread_mutex_unlock (L); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; - begin ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); end Unlock; ! ------------- ! -- Sleep -- ! ------------- ! procedure Sleep (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) is Result : Interfaces.C.int; - begin ! pragma Assert (Self_ID = Self); ! Result := pthread_cond_wait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access); -- EINTR is not considered a failure. --- 454,499 ---- procedure Unlock (L : access Lock) is Result : Interfaces.C.int; begin Result := pthread_mutex_unlock (L); pragma Assert (Result = 0); end Unlock; ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False) is Result : Interfaces.C.int; begin ! if not Single_Lock or else Global_Lock then ! Result := pthread_mutex_unlock (L); ! pragma Assert (Result = 0); ! end if; end Unlock; procedure Unlock (T : Task_ID) is Result : Interfaces.C.int; begin ! if not Single_Lock then ! Result := pthread_mutex_unlock (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; end Unlock; ! ----------- ! -- Sleep -- ! ----------- ! procedure Sleep ! (Self_ID : Task_ID; ! Reason : System.Tasking.Task_States) ! is Result : Interfaces.C.int; begin ! if Single_Lock then ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access); ! else ! Result := pthread_cond_wait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access); ! end if; -- EINTR is not considered a failure. *************** package body System.Task_Primitives.Oper *** 548,555 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; --- 552,567 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level or else Self_ID.Pending_Priority_Change; ! if Single_Lock then ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Single_RTS_Lock'Access, ! Request'Access); ! ! else ! Result := pthread_cond_timedwait ! (Self_ID.Common.LL.CV'Access, Self_ID.Common.LL.L'Access, ! Request'Access); ! end if; exit when Abs_Time <= Monotonic_Clock; *************** package body System.Task_Primitives.Oper *** 591,596 **** --- 603,613 ---- -- check for pending abort and priority change below! :( SSL.Abort_Defer.all; + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); if Mode = Relative then *************** package body System.Task_Primitives.Oper *** 626,633 **** exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); exit when Abs_Time <= Monotonic_Clock; pragma Assert (Result = 0 --- 643,656 ---- exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; ! if Single_Lock then ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Single_RTS_Lock'Access, Request'Access); ! else ! Result := pthread_cond_timedwait (Self_ID.Common.LL.CV'Access, ! Self_ID.Common.LL.L'Access, Request'Access); ! end if; ! exit when Abs_Time <= Monotonic_Clock; pragma Assert (Result = 0 *************** package body System.Task_Primitives.Oper *** 639,644 **** --- 662,672 ---- end if; Unlock (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + Result := sched_yield; SSL.Abort_Undefer.all; end Timed_Delay; *************** package body System.Task_Primitives.Oper *** 673,679 **** procedure Wakeup (T : Task_ID; Reason : System.Tasking.Task_States) is Result : Interfaces.C.int; - begin Result := pthread_cond_signal (T.Common.LL.CV'Access); pragma Assert (Result = 0); --- 701,706 ---- *************** package body System.Task_Primitives.Oper *** 685,691 **** procedure Yield (Do_Yield : Boolean := True) is Result : Interfaces.C.int; - begin if Do_Yield then Result := sched_yield; --- 712,717 ---- *************** package body System.Task_Primitives.Oper *** 697,704 **** ------------------ procedure Set_Priority ! (T : Task_ID; ! Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is Result : Interfaces.C.int; --- 723,730 ---- ------------------ procedure Set_Priority ! (T : Task_ID; ! Prio : System.Any_Priority; Loss_Of_Inheritance : Boolean := False) is Result : Interfaces.C.int; *************** package body System.Task_Primitives.Oper *** 744,760 **** Specific.Set (Self_ID); ! Lock_All_Tasks_List; ! for I in Known_Tasks'Range loop ! if Known_Tasks (I) = null then ! Known_Tasks (I) := Self_ID; ! Self_ID.Known_Tasks_Index := I; exit; end if; end loop; ! Unlock_All_Tasks_List; end Enter_Task; -------------- --- 770,786 ---- Specific.Set (Self_ID); ! Lock_RTS; ! for J in Known_Tasks'Range loop ! if Known_Tasks (J) = null then ! Known_Tasks (J) := Self_ID; ! Self_ID.Known_Tasks_Index := J; exit; end if; end loop; ! Unlock_RTS; end Enter_Task; -------------- *************** package body System.Task_Primitives.Oper *** 772,779 **** procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is Mutex_Attr : aliased pthread_mutexattr_t; ! Result : Interfaces.C.int; ! Cond_Attr : aliased pthread_condattr_t; begin -- Give the task a unique serial number. --- 798,805 ---- procedure Initialize_TCB (Self_ID : Task_ID; Succeeded : out Boolean) is Mutex_Attr : aliased pthread_mutexattr_t; ! Result : Interfaces.C.int; ! Cond_Attr : aliased pthread_condattr_t; begin -- Give the task a unique serial number. *************** package body System.Task_Primitives.Oper *** 782,834 **** Next_Serial_Number := Next_Serial_Number + 1; pragma Assert (Next_Serial_Number /= 0); ! Result := pthread_mutexattr_init (Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! Result := pthread_mutexattr_setprotocol ! (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT); ! pragma Assert (Result = 0); ! Result := pthread_mutexattr_setprioceiling ! (Mutex_Attr'Access, Interfaces.C.int (System.Any_Priority'Last)); ! pragma Assert (Result = 0); ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Succeeded := False; ! return; end if; - Result := pthread_mutexattr_destroy (Mutex_Attr'Access); - pragma Assert (Result = 0); - Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result /= 0 then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! Succeeded := False; ! return; end if; - Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, - Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); - if Result = 0 then Succeeded := True; else ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); Succeeded := False; end if; --- 808,857 ---- Next_Serial_Number := Next_Serial_Number + 1; pragma Assert (Next_Serial_Number /= 0); ! if not Single_Lock then ! Result := pthread_mutexattr_init (Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_mutexattr_setprotocol ! (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT); ! pragma Assert (Result = 0); ! Result := pthread_mutexattr_setprioceiling ! (Mutex_Attr'Access, Interfaces.C.int (System.Any_Priority'Last)); ! pragma Assert (Result = 0); ! Result := pthread_mutex_init (Self_ID.Common.LL.L'Access, ! Mutex_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); ! end if; ! if Result /= 0 then ! Succeeded := False; ! return; ! end if; ! Result := pthread_mutexattr_destroy (Mutex_Attr'Access); ! pragma Assert (Result = 0); end if; Result := pthread_condattr_init (Cond_Attr'Access); pragma Assert (Result = 0 or else Result = ENOMEM); ! if Result = 0 then ! Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, ! Cond_Attr'Access); ! pragma Assert (Result = 0 or else Result = ENOMEM); end if; if Result = 0 then Succeeded := True; else ! if not Single_Lock then ! Result := pthread_mutex_destroy (Self_ID.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; ! Succeeded := False; end if; *************** package body System.Task_Primitives.Oper *** 936,943 **** Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); --- 959,968 ---- Unchecked_Deallocation (Ada_Task_Control_Block, Task_ID); begin ! if not Single_Lock then ! Result := pthread_mutex_destroy (T.Common.LL.L'Access); ! pragma Assert (Result = 0); ! end if; Result := pthread_cond_destroy (T.Common.LL.CV'Access); pragma Assert (Result = 0); *************** package body System.Task_Primitives.Oper *** 1001,1023 **** return Environment_Task_ID; end Environment_Task; ! ------------------------- ! -- Lock_All_Tasks_List -- ! ------------------------- ! procedure Lock_All_Tasks_List is begin ! Write_Lock (All_Tasks_L'Access); ! end Lock_All_Tasks_List; ! --------------------------- ! -- Unlock_All_Tasks_List -- ! --------------------------- ! procedure Unlock_All_Tasks_List is begin ! Unlock (All_Tasks_L'Access); ! end Unlock_All_Tasks_List; ------------------ -- Suspend_Task -- --- 1026,1048 ---- return Environment_Task_ID; end Environment_Task; ! -------------- ! -- Lock_RTS -- ! -------------- ! procedure Lock_RTS is begin ! Write_Lock (Single_RTS_Lock'Access, Global_Lock => True); ! end Lock_RTS; ! ---------------- ! -- Unlock_RTS -- ! ---------------- ! procedure Unlock_RTS is begin ! Unlock (Single_RTS_Lock'Access, Global_Lock => True); ! end Unlock_RTS; ------------------ -- Suspend_Task -- *************** package body System.Task_Primitives.Oper *** 1056,1062 **** -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (All_Tasks_L'Access, All_Tasks_Level); Specific.Initialize (Environment_Task); --- 1081,1087 ---- -- Initialize the lock used to synchronize chain of all ATCBs. ! Initialize_Lock (Single_RTS_Lock'Access, RTS_Lock_Level); Specific.Initialize (Environment_Task); *************** package body System.Task_Primitives.Oper *** 1083,1089 **** begin declare Result : Interfaces.C.int; - begin -- Mask Environment task for all signals. The original mask of the -- Environment task will be recovered by Interrupt_Server task --- 1108,1113 ---- *************** begin *** 1104,1108 **** end if; end loop; end; - end System.Task_Primitives.Operations; --- 1128,1131 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/7staspri.ads gcc-3.3/gcc/ada/7staspri.ads *** gcc-3.2.3/gcc/ada/7staspri.ads 2001-10-02 13:42:29.000000000 +0000 --- gcc-3.3/gcc/ada/7staspri.ads 2002-03-14 10:58:44.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2000, Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/7stpopsp.adb gcc-3.3/gcc/ada/7stpopsp.adb *** gcc-3.2.3/gcc/ada/7stpopsp.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/7stpopsp.adb 2002-03-14 10:58:44.000000000 +0000 *************** *** 2,15 **** -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K _ P R I M I T I V E S . O P E R A T I O N S . -- ! -- S P E C I F I C -- -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-1998, Florida State University -- -- -- -- GNARL 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- -- --- 2,13 ---- -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASK_PRIMITIVES.OPERATIONS.SPECIFIC -- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- *************** package body Specific is *** 68,74 **** --------- procedure Set (Self_Id : Task_ID) is ! Result : Interfaces.C.int; begin Result := pthread_setspecific (ATCB_Key, To_Address (Self_Id)); --- 66,72 ---- --------- procedure Set (Self_Id : Task_ID) is ! Result : Interfaces.C.int; begin Result := pthread_setspecific (ATCB_Key, To_Address (Self_Id)); diff -Nrc3pad gcc-3.2.3/gcc/ada/7straceb.adb gcc-3.3/gcc/ada/7straceb.adb *** gcc-3.2.3/gcc/ada/7straceb.adb 2001-10-02 13:42:29.000000000 +0000 --- gcc-3.3/gcc/ada/7straceb.adb 2002-03-14 10:58:44.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1999-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/86numaux.adb gcc-3.3/gcc/ada/86numaux.adb *** gcc-3.2.3/gcc/ada/86numaux.adb 2002-05-04 03:27:19.000000000 +0000 --- gcc-3.3/gcc/ada/86numaux.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,13 **** -- B o d y -- -- (Machine Version for x86) -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/86numaux.ads gcc-3.3/gcc/ada/86numaux.ads *** gcc-3.2.3/gcc/ada/86numaux.ads 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/86numaux.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (Machine Version for x86) -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/9drpc.adb gcc-3.3/gcc/ada/9drpc.adb *** gcc-3.2.3/gcc/ada/9drpc.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/9drpc.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.2 $ -- -- ! -- Copyright (C) 1992,1993,1994,1995 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** *** 33,38 **** --- 32,39 ---- -- -- ------------------------------------------------------------------------------ + -- Version for ??? + with Unchecked_Deallocation; with Ada.Streams; *************** pragma Elaborate (System.RPC.Garlic); *** 43,48 **** --- 44,53 ---- package body System.RPC is + -- ??? general note: the debugging calls are very heavy, especially + -- those that create exception handlers in every procedure. Do we + -- really still need all this stuff? + use type Ada.Streams.Stream_Element_Count; use type Ada.Streams.Stream_Element_Offset; *************** package body System.RPC is *** 52,58 **** Max_Of_Message_Id : constant := 127; subtype Message_Id_Type is ! Integer range -Max_Of_Message_Id .. Max_Of_Message_Id; -- A message id is either a request id or reply id. A message id is -- provided with a message to a receiving stub which uses the opposite -- as a reply id. A message id helps to retrieve to which task is --- 57,63 ---- Max_Of_Message_Id : constant := 127; subtype Message_Id_Type is ! Integer range -Max_Of_Message_Id .. Max_Of_Message_Id; -- A message id is either a request id or reply id. A message id is -- provided with a message to a receiving stub which uses the opposite -- as a reply id. A message id helps to retrieve to which task is *************** package body System.RPC is *** 67,75 **** type Message_Length_Per_Request is array (Request_Id_Type) of Ada.Streams.Stream_Element_Count; ! Header_Size : Ada.Streams.Stream_Element_Count ! := Streams.Get_Integer_Initial_Size + ! Streams.Get_SEC_Initial_Size; -- Initial size needed for frequently used header streams Stream_Error : exception; --- 72,80 ---- type Message_Length_Per_Request is array (Request_Id_Type) of Ada.Streams.Stream_Element_Count; ! Header_Size : Ada.Streams.Stream_Element_Count := ! Streams.Get_Integer_Initial_Size + ! Streams.Get_SEC_Initial_Size; -- Initial size needed for frequently used header streams Stream_Error : exception; *************** package body System.RPC is *** 94,126 **** Params_Size : in Ada.Streams.Stream_Element_Count; Result_Size : in Ada.Streams.Stream_Element_Count; Protocol : in Garlic.Protocol_Access); ! -- This entry provides an anonymous task a remote call to perform ! -- This task calls for a ! -- Request id is provided to construct the reply id by using ! -- -Request. Partition is used to send the reply message. Params_Size ! -- is the size of the calling stub Params stream. Then, Protocol ! -- (used by the environment task previously) allows to extract the ! -- message following the header (The header is extracted by the ! -- environment task) end Anonymous_Task_Type; type Anonymous_Task_Access is access Anonymous_Task_Type; ! type Anonymous_Task_List is ! record ! Head : Anonymous_Task_Node_Access; ! Tail : Anonymous_Task_Node_Access; ! end record; ! type Anonymous_Task_Node is ! record ! Element : Anonymous_Task_Access; ! Next : Anonymous_Task_Node_Access; ! end record; ! -- Types we need to construct a singly linked list of anonymous tasks ! -- This pool is maintained to avoid a task creation each time a RPC ! -- occurs protected Garbage_Collector is --- 99,128 ---- Params_Size : in Ada.Streams.Stream_Element_Count; Result_Size : in Ada.Streams.Stream_Element_Count; Protocol : in Garlic.Protocol_Access); ! -- This entry provides an anonymous task a remote call to perform. ! -- This task calls for a Request id is provided to construct the ! -- reply id by using -Request. Partition is used to send the reply ! -- message. Params_Size is the size of the calling stub Params stream. ! -- Then Protocol (used by the environment task previously) allows ! -- extraction of the message following the header (The header is ! -- extracted by the environment task) ! -- Note: grammar in above is obscure??? needs cleanup end Anonymous_Task_Type; type Anonymous_Task_Access is access Anonymous_Task_Type; ! type Anonymous_Task_List is record ! Head : Anonymous_Task_Node_Access; ! Tail : Anonymous_Task_Node_Access; ! end record; ! type Anonymous_Task_Node is record ! Element : Anonymous_Task_Access; ! Next : Anonymous_Task_Node_Access; ! end record; ! -- Types we need to construct a singly linked list of anonymous tasks. ! -- This pool is maintained to avoid a task creation each time a RPC occurs. protected Garbage_Collector is *************** package body System.RPC is *** 133,138 **** --- 135,141 ---- (Item : in out Anonymous_Task_Node_Access); -- Anonymous task pool management : queue this task in the pool -- of inactive anonymous tasks. + private Anonymous_List : Anonymous_Task_Node_Access; *************** package body System.RPC is *** 230,242 **** --------------- procedure Head_Node ! (Index : out Packet_Node_Access; ! Stream : in Params_Stream_Type) is begin Index := Stream.Extra.Head; ! exception when others => ! D (D_Exception, "exception in Head_Node"); ! raise; end Head_Node; --------------- --- 233,248 ---- --------------- procedure Head_Node ! (Index : out Packet_Node_Access; ! Stream : Params_Stream_Type) ! is begin Index := Stream.Extra.Head; ! ! exception ! when others => ! D (D_Exception, "exception in Head_Node"); ! raise; end Head_Node; --------------- *************** package body System.RPC is *** 244,277 **** --------------- procedure Tail_Node ! (Index : out Packet_Node_Access; ! Stream : in Params_Stream_Type) is begin Index := Stream.Extra.Tail; ! exception when others => ! D (D_Exception, "exception in Tail_Node"); ! raise; end Tail_Node; --------------- -- Null_Node -- --------------- ! function Null_Node ! (Index : in Packet_Node_Access) return Boolean is begin return Index = null; ! exception when others => ! D (D_Exception, "exception in Null_Node"); ! raise; end Null_Node; ---------------------- -- Delete_Head_Node -- ---------------------- ! procedure Delete_Head_Node ! (Stream : in out Params_Stream_Type) is procedure Free is new Unchecked_Deallocation --- 250,286 ---- --------------- procedure Tail_Node ! (Index : out Packet_Node_Access; ! Stream : Params_Stream_Type) ! is begin Index := Stream.Extra.Tail; ! ! exception ! when others => ! D (D_Exception, "exception in Tail_Node"); ! raise; end Tail_Node; --------------- -- Null_Node -- --------------- ! function Null_Node (Index : in Packet_Node_Access) return Boolean is begin return Index = null; ! ! exception ! when others => ! D (D_Exception, "exception in Null_Node"); ! raise; end Null_Node; ---------------------- -- Delete_Head_Node -- ---------------------- ! procedure Delete_Head_Node (Stream : in out Params_Stream_Type) is procedure Free is new Unchecked_Deallocation *************** package body System.RPC is *** 280,286 **** Next_Node : Packet_Node_Access := Stream.Extra.Head.Next; begin - -- Delete head node and free memory usage Free (Stream.Extra.Head); --- 289,294 ---- *************** package body System.RPC is *** 292,310 **** Stream.Extra.Tail := null; end if; ! exception when others => ! D (D_Exception, "exception in Delete_Head_Node"); ! raise; end Delete_Head_Node; --------------- -- Next_Node -- --------------- ! procedure Next_Node ! (Node : in out Packet_Node_Access) is begin - -- Node is set to the next node -- If not possible, Stream_Error is raised --- 300,317 ---- Stream.Extra.Tail := null; end if; ! exception ! when others => ! D (D_Exception, "exception in Delete_Head_Node"); ! raise; end Delete_Head_Node; --------------- -- Next_Node -- --------------- ! procedure Next_Node (Node : in out Packet_Node_Access) is begin -- Node is set to the next node -- If not possible, Stream_Error is raised *************** package body System.RPC is *** 314,333 **** Node := Node.Next; end if; ! exception when others => ! D (D_Exception, "exception in Next_Node"); ! raise; end Next_Node; --------------------- -- Append_New_Node -- --------------------- ! procedure Append_New_Node ! (Stream : in out Params_Stream_Type) is Index : Packet_Node_Access; - begin -- Set Index to the end of the linked list Tail_Node (Index, Stream); --- 321,340 ---- Node := Node.Next; end if; ! exception ! when others => ! D (D_Exception, "exception in Next_Node"); ! raise; end Next_Node; --------------------- -- Append_New_Node -- --------------------- ! procedure Append_New_Node (Stream : in out Params_Stream_Type) is Index : Packet_Node_Access; + begin -- Set Index to the end of the linked list Tail_Node (Index, Stream); *************** package body System.RPC is *** 340,346 **** Stream.Extra.Tail := Stream.Extra.Head; else - -- The list is not empty : link new node with tail Stream.Extra.Tail.Next := new Packet_Node; --- 347,352 ---- *************** package body System.RPC is *** 348,356 **** end if; ! exception when others => ! D (D_Exception, "exception in Append_New_Node"); ! raise; end Append_New_Node; ---------- --- 354,363 ---- end if; ! exception ! when others => ! D (D_Exception, "exception in Append_New_Node"); ! raise; end Append_New_Node; ---------- *************** package body System.RPC is *** 360,367 **** procedure Read (Stream : in out Params_Stream_Type; Item : out Ada.Streams.Stream_Element_Array; ! Last : out Ada.Streams.Stream_Element_Offset) renames ! System.RPC.Streams.Read; ----------- -- Write -- --- 367,374 ---- procedure Read (Stream : in out Params_Stream_Type; Item : out Ada.Streams.Stream_Element_Array; ! Last : out Ada.Streams.Stream_Element_Offset) ! renames System.RPC.Streams.Read; ----------- -- Write -- *************** package body System.RPC is *** 369,376 **** procedure Write (Stream : in out Params_Stream_Type; ! Item : in Ada.Streams.Stream_Element_Array) renames ! System.RPC.Streams.Write; ----------------------- -- Garbage_Collector -- --- 376,383 ---- procedure Write (Stream : in out Params_Stream_Type; ! Item : in Ada.Streams.Stream_Element_Array) ! renames System.RPC.Streams.Write; ----------------------- -- Garbage_Collector -- *************** package body System.RPC is *** 382,393 **** -- Garbage_Collector.Allocate -- -------------------------------- ! procedure Allocate ! (Item : out Anonymous_Task_Node_Access) is New_Anonymous_Task_Node : Anonymous_Task_Node_Access; Anonymous_Task : Anonymous_Task_Access; - begin -- If the list is empty, allocate a new anonymous task -- Otherwise, reuse the first queued anonymous task --- 389,399 ---- -- Garbage_Collector.Allocate -- -------------------------------- ! procedure Allocate (Item : out Anonymous_Task_Node_Access) is New_Anonymous_Task_Node : Anonymous_Task_Node_Access; Anonymous_Task : Anonymous_Task_Access; + begin -- If the list is empty, allocate a new anonymous task -- Otherwise, reuse the first queued anonymous task *************** package body System.RPC is *** 404,410 **** New_Anonymous_Task_Node.all := (Anonymous_Task, null); else - -- Extract one task from the list -- Set the Next field to null to avoid possible bugs --- 410,415 ---- *************** package body System.RPC is *** 418,444 **** Item := New_Anonymous_Task_Node; ! exception when others => ! D (D_Exception, "exception in Allocate (Anonymous Task)"); ! raise; end Allocate; ---------------------------------- -- Garbage_Collector.Deallocate -- ---------------------------------- ! procedure Deallocate ! (Item : in out Anonymous_Task_Node_Access) is begin - -- Enqueue the task in the free list Item.Next := Anonymous_List; Anonymous_List := Item; ! exception when others => ! D (D_Exception, "exception in Deallocate (Anonymous Task)"); ! raise; end Deallocate; end Garbage_Collector; --- 423,449 ---- Item := New_Anonymous_Task_Node; ! exception ! when others => ! D (D_Exception, "exception in Allocate (Anonymous Task)"); ! raise; end Allocate; ---------------------------------- -- Garbage_Collector.Deallocate -- ---------------------------------- ! procedure Deallocate (Item : in out Anonymous_Task_Node_Access) is begin -- Enqueue the task in the free list Item.Next := Anonymous_List; Anonymous_List := Item; ! exception ! when others => ! D (D_Exception, "exception in Deallocate (Anonymous Task)"); ! raise; end Deallocate; end Garbage_Collector; *************** package body System.RPC is *** 448,462 **** ------------ procedure Do_RPC ! (Partition : in Partition_ID; Params : access Params_Stream_Type; ! Result : access Params_Stream_Type) is Protocol : Protocol_Access; Request : Request_Id_Type; Header : aliased Params_Stream_Type (Header_Size); R_Length : Ada.Streams.Stream_Element_Count; - begin -- Parameters order : -- Opcode (provided and used by garlic) -- (1) Size (provided by s-rpc and used by garlic) --- 453,468 ---- ------------ procedure Do_RPC ! (Partition : Partition_ID; Params : access Params_Stream_Type; ! Result : access Params_Stream_Type) ! is Protocol : Protocol_Access; Request : Request_Id_Type; Header : aliased Params_Stream_Type (Header_Size); R_Length : Ada.Streams.Stream_Element_Count; + begin -- Parameters order : -- Opcode (provided and used by garlic) -- (1) Size (provided by s-rpc and used by garlic) *************** package body System.RPC is *** 538,544 **** declare New_Result : aliased Params_Stream_Type (R_Length); begin - -- Adjust the Result stream size right now to be able to load -- the stream in one receive call. Create a temporary resutl -- that will be substituted to Do_RPC one --- 544,549 ---- *************** package body System.RPC is *** 570,576 **** end; else - -- Do RPC locally and first wait for Partition_RPC_Receiver to be -- set --- 575,580 ---- *************** package body System.RPC is *** 580,588 **** end if; ! exception when others => ! D (D_Exception, "exception in Do_RPC"); ! raise; end Do_RPC; ------------ --- 584,593 ---- end if; ! exception ! when others => ! D (D_Exception, "exception in Do_RPC"); ! raise; end Do_RPC; ------------ *************** package body System.RPC is *** 590,602 **** ------------ procedure Do_APC ! (Partition : in Partition_ID; ! Params : access Params_Stream_Type) is Message_Id : Message_Id_Type := 0; Protocol : Protocol_Access; Header : aliased Params_Stream_Type (Header_Size); - begin -- For more informations, see above -- Request = 0 as we are not waiting for a reply message -- Result length = 0 as we don't expect a result at all --- 595,608 ---- ------------ procedure Do_APC ! (Partition : Partition_ID; ! Params : access Params_Stream_Type) ! is Message_Id : Message_Id_Type := 0; Protocol : Protocol_Access; Header : aliased Params_Stream_Type (Header_Size); + begin -- For more informations, see above -- Request = 0 as we are not waiting for a reply message -- Result length = 0 as we don't expect a result at all *************** package body System.RPC is *** 660,666 **** declare Result : aliased Params_Stream_Type (0); begin - -- Result is here a dummy parameter -- No reason to deallocate as it is not allocated at all --- 666,671 ---- *************** package body System.RPC is *** 672,700 **** end if; ! exception when others => ! D (D_Exception, "exception in Do_APC"); ! raise; end Do_APC; ---------------------------- -- Establish_RPC_Receiver -- ---------------------------- ! procedure Establish_RPC_Receiver ( ! Partition : in Partition_ID; ! Receiver : in RPC_Receiver) is begin - -- Set Partition_RPC_Receiver and allow RPC mechanism Partition_RPC_Receiver := Receiver; Partition_Receiver.Set; D (D_Elaborate, "Partition_Receiver is set"); ! exception when others => ! D (D_Exception, "exception in Establish_RPC_Receiver"); ! raise; end Establish_RPC_Receiver; ---------------- --- 677,707 ---- end if; ! exception ! when others => ! D (D_Exception, "exception in Do_APC"); ! raise; end Do_APC; ---------------------------- -- Establish_RPC_Receiver -- ---------------------------- ! procedure Establish_RPC_Receiver ! (Partition : in Partition_ID; ! Receiver : in RPC_Receiver) ! is begin -- Set Partition_RPC_Receiver and allow RPC mechanism Partition_RPC_Receiver := Receiver; Partition_Receiver.Set; D (D_Elaborate, "Partition_Receiver is set"); ! exception ! when others => ! D (D_Exception, "exception in Establish_RPC_Receiver"); ! raise; end Establish_RPC_Receiver; ---------------- *************** package body System.RPC is *** 705,728 **** Last_Request : Request_Id_Type := Request_Id_Type'First; Current_Rqst : Request_Id_Type := Request_Id_Type'First; Current_Size : Ada.Streams.Stream_Element_Count; - begin loop ! -- Three services : ! -- New_Request to get an entry in Dispatcher table ! -- Wait_On for Do_RPC calls ! -- Wake_Up called by environment task when a Do_RPC receives ! -- the result of its remote call ! select ! accept New_Request ! (Request : out Request_Id_Type) do Request := Last_Request; -- << TODO >> ! -- Avaibility check if Last_Request = Request_Id_Type'Last then Last_Request := Request_Id_Type'First; --- 712,735 ---- Last_Request : Request_Id_Type := Request_Id_Type'First; Current_Rqst : Request_Id_Type := Request_Id_Type'First; Current_Size : Ada.Streams.Stream_Element_Count; + begin loop + -- Three services: ! -- New_Request to get an entry in Dispatcher table ! -- Wait_On for Do_RPC calls ! -- Wake_Up called by environment task when a Do_RPC receives ! -- the result of its remote call ! ! select ! accept New_Request (Request : out Request_Id_Type) do Request := Last_Request; -- << TODO >> ! -- ??? Avaibility check if Last_Request = Request_Id_Type'Last then Last_Request := Request_Id_Type'First; *************** package body System.RPC is *** 733,743 **** end New_Request; or - accept Wake_Up ! (Request : in Request_Id_Type; ! Length : in Ada.Streams.Stream_Element_Count) do ! -- The environment reads the header and has been notified -- of the reply id and the size of the result message --- 740,749 ---- end New_Request; or accept Wake_Up ! (Request : Request_Id_Type; ! Length : Ada.Streams.Stream_Element_Count) ! do -- The environment reads the header and has been notified -- of the reply id and the size of the result message *************** package body System.RPC is *** 747,763 **** end Wake_Up; -- << TODO >> ! -- Must be select with delay for aborted tasks select accept Wait_On (Current_Rqst) ! (Length : out Ada.Streams.Stream_Element_Count) do Length := Current_Size; end Wait_On; or - -- To free the Dispatcher when a task is aborted delay 1.0; --- 753,769 ---- end Wake_Up; -- << TODO >> ! -- ??? Must be select with delay for aborted tasks select accept Wait_On (Current_Rqst) ! (Length : out Ada.Streams.Stream_Element_Count) ! do Length := Current_Size; end Wait_On; or -- To free the Dispatcher when a task is aborted delay 1.0; *************** package body System.RPC is *** 765,780 **** end select; or - terminate; - end select; end loop; ! exception when others => ! D (D_Exception, "exception in Dispatcher body"); ! raise; end Dispatcher; ------------------------- --- 771,785 ---- end select; or terminate; end select; end loop; ! exception ! when others => ! D (D_Exception, "exception in Dispatcher body"); ! raise; end Dispatcher; ------------------------- *************** package body System.RPC is *** 788,797 **** Params_S : Ada.Streams.Stream_Element_Count; -- Params message size Result_S : Ada.Streams.Stream_Element_Count; -- Result message size C_Protocol : Protocol_Access; -- Current Protocol - begin loop - -- Get a new RPC to execute select --- 793,801 ---- Params_S : Ada.Streams.Stream_Element_Count; -- Params message size Result_S : Ada.Streams.Stream_Element_Count; -- Result message size C_Protocol : Protocol_Access; -- Current Protocol + begin loop -- Get a new RPC to execute select *************** package body System.RPC is *** 800,806 **** Partition : in Partition_ID; Params_Size : in Ada.Streams.Stream_Element_Count; Result_Size : in Ada.Streams.Stream_Element_Count; ! Protocol : in Protocol_Access) do C_Message_Id := Message_Id; C_Partition := Partition; Params_S := Params_Size; --- 804,811 ---- Partition : in Partition_ID; Params_Size : in Ada.Streams.Stream_Element_Count; Result_Size : in Ada.Streams.Stream_Element_Count; ! Protocol : in Protocol_Access) ! do C_Message_Id := Message_Id; C_Partition := Partition; Params_S := Params_Size; *************** package body System.RPC is *** 812,822 **** end select; declare ! Params : aliased Params_Stream_Type (Params_S); ! Result : aliased Params_Stream_Type (Result_S); ! Header : aliased Params_Stream_Type (Header_Size); ! begin -- We reconstruct all the client context : Params and Result -- with the SAME size, then we receive Params from calling stub --- 817,827 ---- end select; declare ! Params : aliased Params_Stream_Type (Params_S); ! Result : aliased Params_Stream_Type (Result_S); ! Header : aliased Params_Stream_Type (Header_Size); + begin -- We reconstruct all the client context : Params and Result -- with the SAME size, then we receive Params from calling stub *************** package body System.RPC is *** 863,869 **** (Header'Access, Streams.Get_Stream_Size (Result'Access)); - -- Get a protocol method to comunicate with the remote -- partition and give the message size --- 868,873 ---- *************** package body System.RPC is *** 903,914 **** (C_Protocol.all, C_Partition); Streams.Deallocate (Header); - end if; Streams.Deallocate (Params); Streams.Deallocate (Result); - end; -- Enqueue into the anonymous task free list : become inactive --- 907,916 ---- *************** package body System.RPC is *** 917,925 **** end loop; ! exception when others => ! D (D_Exception, "exception in Anonymous_Task_Type body"); ! raise; end Anonymous_Task_Type; ----------------- --- 919,928 ---- end loop; ! exception ! when others => ! D (D_Exception, "exception in Anonymous_Task_Type body"); ! raise; end Anonymous_Task_Type; ----------------- *************** package body System.RPC is *** 934,948 **** Header : aliased Params_Stream_Type (Header_Size); Protocol : Protocol_Access; Anonymous : Anonymous_Task_Node_Access; - begin -- Wait the Partition_RPC_Receiver to be set accept Start; D (D_Elaborate, "Environment task elaborated"); loop - -- We receive first a fixed size message : the header -- Header = Message Id + Message Size --- 937,950 ---- Header : aliased Params_Stream_Type (Header_Size); Protocol : Protocol_Access; Anonymous : Anonymous_Task_Node_Access; + begin -- Wait the Partition_RPC_Receiver to be set accept Start; D (D_Elaborate, "Environment task elaborated"); loop -- We receive first a fixed size message : the header -- Header = Message Id + Message Size *************** package body System.RPC is *** 952,961 **** -- protocol to use to communicate with the calling partition Garlic.Initiate_Receive ! (Partition, ! Message_Size, ! Protocol, ! Garlic.Remote_Call); D (D_Communication, "Environment task - Receive protocol to talk to active partition" & Partition_ID'Image (Partition)); --- 954,963 ---- -- protocol to use to communicate with the calling partition Garlic.Initiate_Receive ! (Partition, ! Message_Size, ! Protocol, ! Garlic.Remote_Call); D (D_Communication, "Environment task - Receive protocol to talk to active partition" & Partition_ID'Image (Partition)); *************** package body System.RPC is *** 968,976 **** "Environment task - Receive Header from partition" & Partition_ID'Image (Partition)); Garlic.Receive ! (Protocol.all, ! Partition, ! Header'Access); -- Evaluate the remaining size of the message --- 970,978 ---- "Environment task - Receive Header from partition" & Partition_ID'Image (Partition)); Garlic.Receive ! (Protocol.all, ! Partition, ! Header'Access); -- Evaluate the remaining size of the message *************** package body System.RPC is *** 1001,1007 **** Dispatcher.Wake_Up (-Message_Id, Result_Size); else - -- The message was send by a calling stub : get an anonymous -- task to perform the job --- 1003,1008 ---- *************** package body System.RPC is *** 1027,1039 **** end loop; ! exception when others => ! D (D_Exception, "exception in Environment"); ! raise; end Environnement; begin - -- Set debugging information Debugging.Set_Environment_Variable ("RPC"); --- 1028,1040 ---- end loop; ! exception ! when others => ! D (D_Exception, "exception in Environment"); ! raise; end Environnement; begin -- Set debugging information Debugging.Set_Environment_Variable ("RPC"); diff -Nrc3pad gcc-3.2.3/gcc/ada/a-astaco.adb gcc-3.3/gcc/ada/a-astaco.adb *** gcc-3.2.3/gcc/ada/a-astaco.adb 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/a-astaco.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-astaco.ads gcc-3.3/gcc/ada/a-astaco.ads *** gcc-3.2.3/gcc/ada/a-astaco.ads 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/a-astaco.ads 2002-03-14 10:58:45.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-caldel.adb gcc-3.3/gcc/ada/a-caldel.adb *** gcc-3.2.3/gcc/ada/a-caldel.adb 2001-10-02 13:51:51.000000000 +0000 --- gcc-3.3/gcc/ada/a-caldel.adb 2002-03-14 10:58:45.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- *************** with System.OS_Primitives; *** 41,46 **** --- 40,51 ---- with System.Soft_Links; -- Used for Timed_Delay + with System.Traces; + -- Used for Send_Trace_Info + + with System.Parameters; + -- used for Runtime_Traces + package body Ada.Calendar.Delays is package OSP renames System.OS_Primitives; *************** package body Ada.Calendar.Delays is *** 48,53 **** --- 53,60 ---- use type SSL.Timed_Delay_Call; + use System.Traces; + -- Earlier, the following operations were implemented using -- System.Time_Operations. The idea was to avoid sucking in the tasking -- packages. This did not work. Logically, we can't have it both ways. *************** package body Ada.Calendar.Delays is *** 68,75 **** procedure Delay_For (D : Duration) is begin SSL.Timed_Delay.all (Duration'Min (D, OSP.Max_Sensible_Delay), ! OSP.Relative); end Delay_For; ----------------- --- 75,90 ---- procedure Delay_For (D : Duration) is begin + if System.Parameters.Runtime_Traces then + Send_Trace_Info (W_Delay, D); + end if; + SSL.Timed_Delay.all (Duration'Min (D, OSP.Max_Sensible_Delay), ! OSP.Relative); ! ! if System.Parameters.Runtime_Traces then ! Send_Trace_Info (M_Delay, D); ! end if; end Delay_For; ----------------- *************** package body Ada.Calendar.Delays is *** 77,84 **** ----------------- procedure Delay_Until (T : Time) is begin ! SSL.Timed_Delay.all (To_Duration (T), OSP.Absolute_Calendar); end Delay_Until; -------------------- --- 92,109 ---- ----------------- procedure Delay_Until (T : Time) is + D : constant Duration := To_Duration (T); + begin ! if System.Parameters.Runtime_Traces then ! Send_Trace_Info (WU_Delay, D); ! end if; ! ! SSL.Timed_Delay.all (D, OSP.Absolute_Calendar); ! ! if System.Parameters.Runtime_Traces then ! Send_Trace_Info (M_Delay, D); ! end if; end Delay_Until; -------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-caldel.ads gcc-3.3/gcc/ada/a-caldel.ads *** gcc-3.2.3/gcc/ada/a-caldel.ads 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/a-caldel.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-calend.adb gcc-3.3/gcc/ada/a-calend.adb *** gcc-3.2.3/gcc/ada/a-calend.adb 2002-05-04 03:27:19.000000000 +0000 --- gcc-3.3/gcc/ada/a-calend.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-calend.ads gcc-3.3/gcc/ada/a-calend.ads *** gcc-3.2.3/gcc/ada/a-calend.ads 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/a-calend.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-chahan.adb gcc-3.3/gcc/ada/a-chahan.adb *** gcc-3.2.3/gcc/ada/a-chahan.adb 2002-05-04 03:27:19.000000000 +0000 --- gcc-3.3/gcc/ada/a-chahan.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-chahan.ads gcc-3.3/gcc/ada/a-chahan.ads *** gcc-3.2.3/gcc/ada/a-chahan.ads 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/a-chahan.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-charac.ads gcc-3.3/gcc/ada/a-charac.ads *** gcc-3.2.3/gcc/ada/a-charac.ads 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/a-charac.ads 2002-03-14 10:58:46.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-chlat1.ads gcc-3.3/gcc/ada/a-chlat1.ads *** gcc-3.2.3/gcc/ada/a-chlat1.ads 2002-05-07 08:22:04.000000000 +0000 --- gcc-3.3/gcc/ada/a-chlat1.ads 2002-03-14 10:58:46.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-chlat9.ads gcc-3.3/gcc/ada/a-chlat9.ads *** gcc-3.2.3/gcc/ada/a-chlat9.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/a-chlat9.ads 2002-10-28 16:19:22.000000000 +0000 *************** *** 0 **** --- 1,335 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT RUNTIME COMPONENTS -- + -- -- + -- A D A . C H A R A C T E R S . L A T I N _ 9 -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2002 Free Software Foundation, Inc. -- + -- -- + -- This specification is derived from the Ada Reference Manual for use with -- + -- GNAT. The copyright notice above, and the license provisions that follow -- + -- apply solely to the modifications made to Ada.Characters.Latin_1, noted -- + -- in the text, to derive the equivalent Latin-9 package. -- + -- -- + -- 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package provides definitions for Latin-9 (ISO-8859-9) analogous to + -- those defined in the standard package Ada.Characters.Latin_1 for Latin-1. + + package Ada.Characters.Latin_9 is + pragma Pure (Latin_9); + + ------------------------ + -- Control Characters -- + ------------------------ + + NUL : constant Character := Character'Val (0); + SOH : constant Character := Character'Val (1); + STX : constant Character := Character'Val (2); + ETX : constant Character := Character'Val (3); + EOT : constant Character := Character'Val (4); + ENQ : constant Character := Character'Val (5); + ACK : constant Character := Character'Val (6); + BEL : constant Character := Character'Val (7); + BS : constant Character := Character'Val (8); + HT : constant Character := Character'Val (9); + LF : constant Character := Character'Val (10); + VT : constant Character := Character'Val (11); + FF : constant Character := Character'Val (12); + CR : constant Character := Character'Val (13); + SO : constant Character := Character'Val (14); + SI : constant Character := Character'Val (15); + + DLE : constant Character := Character'Val (16); + DC1 : constant Character := Character'Val (17); + DC2 : constant Character := Character'Val (18); + DC3 : constant Character := Character'Val (19); + DC4 : constant Character := Character'Val (20); + NAK : constant Character := Character'Val (21); + SYN : constant Character := Character'Val (22); + ETB : constant Character := Character'Val (23); + CAN : constant Character := Character'Val (24); + EM : constant Character := Character'Val (25); + SUB : constant Character := Character'Val (26); + ESC : constant Character := Character'Val (27); + FS : constant Character := Character'Val (28); + GS : constant Character := Character'Val (29); + RS : constant Character := Character'Val (30); + US : constant Character := Character'Val (31); + + -------------------------------- + -- ISO 646 Graphic Characters -- + -------------------------------- + + Space : constant Character := ' '; -- Character'Val(32) + Exclamation : constant Character := '!'; -- Character'Val(33) + Quotation : constant Character := '"'; -- Character'Val(34) + Number_Sign : constant Character := '#'; -- Character'Val(35) + Dollar_Sign : constant Character := '$'; -- Character'Val(36) + Percent_Sign : constant Character := '%'; -- Character'Val(37) + Ampersand : constant Character := '&'; -- Character'Val(38) + Apostrophe : constant Character := '''; -- Character'Val(39) + Left_Parenthesis : constant Character := '('; -- Character'Val(40) + Right_Parenthesis : constant Character := ')'; -- Character'Val(41) + Asterisk : constant Character := '*'; -- Character'Val(42) + Plus_Sign : constant Character := '+'; -- Character'Val(43) + Comma : constant Character := ','; -- Character'Val(44) + Hyphen : constant Character := '-'; -- Character'Val(45) + Minus_Sign : Character renames Hyphen; + Full_Stop : constant Character := '.'; -- Character'Val(46) + Solidus : constant Character := '/'; -- Character'Val(47) + + -- Decimal digits '0' though '9' are at positions 48 through 57 + + Colon : constant Character := ':'; -- Character'Val(58) + Semicolon : constant Character := ';'; -- Character'Val(59) + Less_Than_Sign : constant Character := '<'; -- Character'Val(60) + Equals_Sign : constant Character := '='; -- Character'Val(61) + Greater_Than_Sign : constant Character := '>'; -- Character'Val(62) + Question : constant Character := '?'; -- Character'Val(63) + + Commercial_At : constant Character := '@'; -- Character'Val(64) + + -- Letters 'A' through 'Z' are at positions 65 through 90 + + Left_Square_Bracket : constant Character := '['; -- Character'Val (91) + Reverse_Solidus : constant Character := '\'; -- Character'Val (92) + Right_Square_Bracket : constant Character := ']'; -- Character'Val (93) + Circumflex : constant Character := '^'; -- Character'Val (94) + Low_Line : constant Character := '_'; -- Character'Val (95) + + Grave : constant Character := '`'; -- Character'Val (96) + LC_A : constant Character := 'a'; -- Character'Val (97) + LC_B : constant Character := 'b'; -- Character'Val (98) + LC_C : constant Character := 'c'; -- Character'Val (99) + LC_D : constant Character := 'd'; -- Character'Val (100) + LC_E : constant Character := 'e'; -- Character'Val (101) + LC_F : constant Character := 'f'; -- Character'Val (102) + LC_G : constant Character := 'g'; -- Character'Val (103) + LC_H : constant Character := 'h'; -- Character'Val (104) + LC_I : constant Character := 'i'; -- Character'Val (105) + LC_J : constant Character := 'j'; -- Character'Val (106) + LC_K : constant Character := 'k'; -- Character'Val (107) + LC_L : constant Character := 'l'; -- Character'Val (108) + LC_M : constant Character := 'm'; -- Character'Val (109) + LC_N : constant Character := 'n'; -- Character'Val (110) + LC_O : constant Character := 'o'; -- Character'Val (111) + LC_P : constant Character := 'p'; -- Character'Val (112) + LC_Q : constant Character := 'q'; -- Character'Val (113) + LC_R : constant Character := 'r'; -- Character'Val (114) + LC_S : constant Character := 's'; -- Character'Val (115) + LC_T : constant Character := 't'; -- Character'Val (116) + LC_U : constant Character := 'u'; -- Character'Val (117) + LC_V : constant Character := 'v'; -- Character'Val (118) + LC_W : constant Character := 'w'; -- Character'Val (119) + LC_X : constant Character := 'x'; -- Character'Val (120) + LC_Y : constant Character := 'y'; -- Character'Val (121) + LC_Z : constant Character := 'z'; -- Character'Val (122) + Left_Curly_Bracket : constant Character := '{'; -- Character'Val (123) + Vertical_Line : constant Character := '|'; -- Character'Val (124) + Right_Curly_Bracket : constant Character := '}'; -- Character'Val (125) + Tilde : constant Character := '~'; -- Character'Val (126) + DEL : constant Character := Character'Val (127); + + --------------------------------- + -- ISO 6429 Control Characters -- + --------------------------------- + + IS4 : Character renames FS; + IS3 : Character renames GS; + IS2 : Character renames RS; + IS1 : Character renames US; + + Reserved_128 : constant Character := Character'Val (128); + Reserved_129 : constant Character := Character'Val (129); + BPH : constant Character := Character'Val (130); + NBH : constant Character := Character'Val (131); + Reserved_132 : constant Character := Character'Val (132); + NEL : constant Character := Character'Val (133); + SSA : constant Character := Character'Val (134); + ESA : constant Character := Character'Val (135); + HTS : constant Character := Character'Val (136); + HTJ : constant Character := Character'Val (137); + VTS : constant Character := Character'Val (138); + PLD : constant Character := Character'Val (139); + PLU : constant Character := Character'Val (140); + RI : constant Character := Character'Val (141); + SS2 : constant Character := Character'Val (142); + SS3 : constant Character := Character'Val (143); + + DCS : constant Character := Character'Val (144); + PU1 : constant Character := Character'Val (145); + PU2 : constant Character := Character'Val (146); + STS : constant Character := Character'Val (147); + CCH : constant Character := Character'Val (148); + MW : constant Character := Character'Val (149); + SPA : constant Character := Character'Val (150); + EPA : constant Character := Character'Val (151); + + SOS : constant Character := Character'Val (152); + Reserved_153 : constant Character := Character'Val (153); + SCI : constant Character := Character'Val (154); + CSI : constant Character := Character'Val (155); + ST : constant Character := Character'Val (156); + OSC : constant Character := Character'Val (157); + PM : constant Character := Character'Val (158); + APC : constant Character := Character'Val (159); + + ------------------------------ + -- Other Graphic Characters -- + ------------------------------ + + -- Character positions 160 (16#A0#) .. 175 (16#AF#) + + No_Break_Space : constant Character := Character'Val (160); + NBSP : Character renames No_Break_Space; + Inverted_Exclamation : constant Character := Character'Val (161); + Cent_Sign : constant Character := Character'Val (162); + Pound_Sign : constant Character := Character'Val (163); + Euro_Sign : constant Character := Character'Val (164); + Yen_Sign : constant Character := Character'Val (165); + UC_S_Caron : constant Character := Character'Val (166); + Section_Sign : constant Character := Character'Val (167); + LC_S_Caron : constant Character := Character'Val (168); + Copyright_Sign : constant Character := Character'Val (169); + Feminine_Ordinal_Indicator : constant Character := Character'Val (170); + Left_Angle_Quotation : constant Character := Character'Val (171); + Not_Sign : constant Character := Character'Val (172); + Soft_Hyphen : constant Character := Character'Val (173); + Registered_Trade_Mark_Sign : constant Character := Character'Val (174); + Macron : constant Character := Character'Val (175); + + -- Character positions 176 (16#B0#) .. 191 (16#BF#) + + Degree_Sign : constant Character := Character'Val (176); + Ring_Above : Character renames Degree_Sign; + Plus_Minus_Sign : constant Character := Character'Val (177); + Superscript_Two : constant Character := Character'Val (178); + Superscript_Three : constant Character := Character'Val (179); + UC_Z_Caron : constant Character := Character'Val (180); + Micro_Sign : constant Character := Character'Val (181); + Pilcrow_Sign : constant Character := Character'Val (182); + Paragraph_Sign : Character renames Pilcrow_Sign; + Middle_Dot : constant Character := Character'Val (183); + LC_Z_Caron : constant Character := Character'Val (184); + Superscript_One : constant Character := Character'Val (185); + Masculine_Ordinal_Indicator : constant Character := Character'Val (186); + Right_Angle_Quotation : constant Character := Character'Val (187); + UC_Ligature_OE : constant Character := Character'Val (188); + LC_Ligature_OE : constant Character := Character'Val (189); + UC_Y_Diaeresis : constant Character := Character'Val (190); + Inverted_Question : constant Character := Character'Val (191); + + -- Character positions 192 (16#C0#) .. 207 (16#CF#) + + UC_A_Grave : constant Character := Character'Val (192); + UC_A_Acute : constant Character := Character'Val (193); + UC_A_Circumflex : constant Character := Character'Val (194); + UC_A_Tilde : constant Character := Character'Val (195); + UC_A_Diaeresis : constant Character := Character'Val (196); + UC_A_Ring : constant Character := Character'Val (197); + UC_AE_Diphthong : constant Character := Character'Val (198); + UC_C_Cedilla : constant Character := Character'Val (199); + UC_E_Grave : constant Character := Character'Val (200); + UC_E_Acute : constant Character := Character'Val (201); + UC_E_Circumflex : constant Character := Character'Val (202); + UC_E_Diaeresis : constant Character := Character'Val (203); + UC_I_Grave : constant Character := Character'Val (204); + UC_I_Acute : constant Character := Character'Val (205); + UC_I_Circumflex : constant Character := Character'Val (206); + UC_I_Diaeresis : constant Character := Character'Val (207); + + -- Character positions 208 (16#D0#) .. 223 (16#DF#) + + UC_Icelandic_Eth : constant Character := Character'Val (208); + UC_N_Tilde : constant Character := Character'Val (209); + UC_O_Grave : constant Character := Character'Val (210); + UC_O_Acute : constant Character := Character'Val (211); + UC_O_Circumflex : constant Character := Character'Val (212); + UC_O_Tilde : constant Character := Character'Val (213); + UC_O_Diaeresis : constant Character := Character'Val (214); + Multiplication_Sign : constant Character := Character'Val (215); + UC_O_Oblique_Stroke : constant Character := Character'Val (216); + UC_U_Grave : constant Character := Character'Val (217); + UC_U_Acute : constant Character := Character'Val (218); + UC_U_Circumflex : constant Character := Character'Val (219); + UC_U_Diaeresis : constant Character := Character'Val (220); + UC_Y_Acute : constant Character := Character'Val (221); + UC_Icelandic_Thorn : constant Character := Character'Val (222); + LC_German_Sharp_S : constant Character := Character'Val (223); + + -- Character positions 224 (16#E0#) .. 239 (16#EF#) + + LC_A_Grave : constant Character := Character'Val (224); + LC_A_Acute : constant Character := Character'Val (225); + LC_A_Circumflex : constant Character := Character'Val (226); + LC_A_Tilde : constant Character := Character'Val (227); + LC_A_Diaeresis : constant Character := Character'Val (228); + LC_A_Ring : constant Character := Character'Val (229); + LC_AE_Diphthong : constant Character := Character'Val (230); + LC_C_Cedilla : constant Character := Character'Val (231); + LC_E_Grave : constant Character := Character'Val (232); + LC_E_Acute : constant Character := Character'Val (233); + LC_E_Circumflex : constant Character := Character'Val (234); + LC_E_Diaeresis : constant Character := Character'Val (235); + LC_I_Grave : constant Character := Character'Val (236); + LC_I_Acute : constant Character := Character'Val (237); + LC_I_Circumflex : constant Character := Character'Val (238); + LC_I_Diaeresis : constant Character := Character'Val (239); + + -- Character positions 240 (16#F0#) .. 255 (16#FF) + LC_Icelandic_Eth : constant Character := Character'Val (240); + LC_N_Tilde : constant Character := Character'Val (241); + LC_O_Grave : constant Character := Character'Val (242); + LC_O_Acute : constant Character := Character'Val (243); + LC_O_Circumflex : constant Character := Character'Val (244); + LC_O_Tilde : constant Character := Character'Val (245); + LC_O_Diaeresis : constant Character := Character'Val (246); + Division_Sign : constant Character := Character'Val (247); + LC_O_Oblique_Stroke : constant Character := Character'Val (248); + LC_U_Grave : constant Character := Character'Val (249); + LC_U_Acute : constant Character := Character'Val (250); + LC_U_Circumflex : constant Character := Character'Val (251); + LC_U_Diaeresis : constant Character := Character'Val (252); + LC_Y_Acute : constant Character := Character'Val (253); + LC_Icelandic_Thorn : constant Character := Character'Val (254); + LC_Y_Diaeresis : constant Character := Character'Val (255); + + ------------------------------------------------ + -- Summary of Changes from Latin-1 => Latin-9 -- + ------------------------------------------------ + + -- 164 Currency => Euro_Sign + -- 166 Broken_Bar => UC_S_Caron + -- 168 Diaeresis => LC_S_Caron + -- 180 Acute => UC_Z_Caron + -- 184 Cedilla => LC_Z_Caron + -- 188 Fraction_One_Quarter => UC_Ligature_OE + -- 189 Fraction_One_Half => LC_Ligature_OE + -- 190 Fraction_Three_Quarters => UC_Y_Diaeresis + + end Ada.Characters.Latin_9; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-colien.adb gcc-3.3/gcc/ada/a-colien.adb *** gcc-3.2.3/gcc/ada/a-colien.adb 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-colien.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-colien.ads gcc-3.3/gcc/ada/a-colien.ads *** gcc-3.2.3/gcc/ada/a-colien.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-colien.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-colire.adb gcc-3.3/gcc/ada/a-colire.adb *** gcc-3.2.3/gcc/ada/a-colire.adb 2002-05-04 03:27:20.000000000 +0000 --- gcc-3.3/gcc/ada/a-colire.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-colire.ads gcc-3.3/gcc/ada/a-colire.ads *** gcc-3.2.3/gcc/ada/a-colire.ads 2002-05-04 03:27:20.000000000 +0000 --- gcc-3.3/gcc/ada/a-colire.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-comlin.adb gcc-3.3/gcc/ada/a-comlin.adb *** gcc-3.2.3/gcc/ada/a-comlin.adb 2002-05-04 03:27:20.000000000 +0000 --- gcc-3.3/gcc/ada/a-comlin.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-comlin.ads gcc-3.3/gcc/ada/a-comlin.ads *** gcc-3.2.3/gcc/ada/a-comlin.ads 2002-05-04 03:27:20.000000000 +0000 --- gcc-3.3/gcc/ada/a-comlin.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Preelaborate (Command_Line); *** 71,83 **** procedure Set_Exit_Status (Code : Exit_Status); ! private Success : constant Exit_Status := 0; Failure : constant Exit_Status := 1; -- The following locations support the operation of the package ! -- Ada.Command_Line_Remove, whih provides facilities for logically -- removing arguments from the command line. If one of the remove -- procedures is called in this unit, then Remove_Args/Remove_Count -- are set to indicate which arguments are removed. If no such calls --- 70,117 ---- procedure Set_Exit_Status (Code : Exit_Status); ! ------------------------------------ ! -- Note on Interface Requirements -- ! ------------------------------------ ! ! -- If the main program is in Ada, this package works as specified without ! -- any other work than the normal steps of WITH'ing the package and then ! -- calling the desired routines. ! ! -- If the main program is not in Ada, then the information must be made ! -- available for this package to work correctly. In particular, it is ! -- required that the global variable "gnat_argc" contain the number of ! -- arguments, and that the global variable "gnat_argv" points to an ! -- array of null-terminated strings, the first entry being the command ! -- name, and the remaining entries being the command arguments. ! ! -- These correspond to the normal argc/argv variables passed to a C ! -- main program, and the following is an example of a complete C main ! -- program that stores the required information: + -- main(int argc, char **argv, char **envp) + -- { + -- extern int gnat_argc; + -- extern char **gnat_argv; + -- extern char **gnat_envp; + -- gnat_argc = argc; + -- gnat_argv = argv; + -- gnat_envp = envp; + + -- adainit(); + -- adamain(); + -- adafinal(); + -- } + + -- The assignment statements ensure that the necessary information is + -- available for finding the command name and command line arguments. + + private Success : constant Exit_Status := 0; Failure : constant Exit_Status := 1; -- The following locations support the operation of the package ! -- Ada.Command_Line.Remove, whih provides facilities for logically -- removing arguments from the command line. If one of the remove -- procedures is called in this unit, then Remove_Args/Remove_Count -- are set to indicate which arguments are removed. If no such calls diff -Nrc3pad gcc-3.2.3/gcc/ada/a-cwila1.ads gcc-3.3/gcc/ada/a-cwila1.ads *** gcc-3.2.3/gcc/ada/a-cwila1.ads 2002-05-04 03:27:20.000000000 +0000 --- gcc-3.3/gcc/ada/a-cwila1.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-cwila9.ads gcc-3.3/gcc/ada/a-cwila9.ads *** gcc-3.2.3/gcc/ada/a-cwila9.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/a-cwila9.ads 2002-10-28 16:19:22.000000000 +0000 *************** *** 0 **** --- 1,337 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT RUNTIME COMPONENTS -- + -- -- + -- A D A . C H A R A C T E R S . W I D E _ L A T I N _ 9 -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 1992-2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package provides definitions analogous to those in the GNAT + -- package Ada.Characters.Latin_9 except that the type of the constants + -- is Wide_Character instead of Character. The provision of this package + -- is in accordance with the implementation permission in RM (A.3.3(27)). + + package Ada.Characters.Wide_Latin_9 is + pragma Pure (Wide_Latin_9); + + ------------------------ + -- Control Characters -- + ------------------------ + + NUL : constant Wide_Character := Wide_Character'Val (0); + SOH : constant Wide_Character := Wide_Character'Val (1); + STX : constant Wide_Character := Wide_Character'Val (2); + ETX : constant Wide_Character := Wide_Character'Val (3); + EOT : constant Wide_Character := Wide_Character'Val (4); + ENQ : constant Wide_Character := Wide_Character'Val (5); + ACK : constant Wide_Character := Wide_Character'Val (6); + BEL : constant Wide_Character := Wide_Character'Val (7); + BS : constant Wide_Character := Wide_Character'Val (8); + HT : constant Wide_Character := Wide_Character'Val (9); + LF : constant Wide_Character := Wide_Character'Val (10); + VT : constant Wide_Character := Wide_Character'Val (11); + FF : constant Wide_Character := Wide_Character'Val (12); + CR : constant Wide_Character := Wide_Character'Val (13); + SO : constant Wide_Character := Wide_Character'Val (14); + SI : constant Wide_Character := Wide_Character'Val (15); + + DLE : constant Wide_Character := Wide_Character'Val (16); + DC1 : constant Wide_Character := Wide_Character'Val (17); + DC2 : constant Wide_Character := Wide_Character'Val (18); + DC3 : constant Wide_Character := Wide_Character'Val (19); + DC4 : constant Wide_Character := Wide_Character'Val (20); + NAK : constant Wide_Character := Wide_Character'Val (21); + SYN : constant Wide_Character := Wide_Character'Val (22); + ETB : constant Wide_Character := Wide_Character'Val (23); + CAN : constant Wide_Character := Wide_Character'Val (24); + EM : constant Wide_Character := Wide_Character'Val (25); + SUB : constant Wide_Character := Wide_Character'Val (26); + ESC : constant Wide_Character := Wide_Character'Val (27); + FS : constant Wide_Character := Wide_Character'Val (28); + GS : constant Wide_Character := Wide_Character'Val (29); + RS : constant Wide_Character := Wide_Character'Val (30); + US : constant Wide_Character := Wide_Character'Val (31); + + ------------------------------------- + -- ISO 646 Graphic Wide_Characters -- + ------------------------------------- + + Space : constant Wide_Character := ' '; -- WC'Val(32) + Exclamation : constant Wide_Character := '!'; -- WC'Val(33) + Quotation : constant Wide_Character := '"'; -- WC'Val(34) + Number_Sign : constant Wide_Character := '#'; -- WC'Val(35) + Dollar_Sign : constant Wide_Character := '$'; -- WC'Val(36) + Percent_Sign : constant Wide_Character := '%'; -- WC'Val(37) + Ampersand : constant Wide_Character := '&'; -- WC'Val(38) + Apostrophe : constant Wide_Character := '''; -- WC'Val(39) + Left_Parenthesis : constant Wide_Character := '('; -- WC'Val(40) + Right_Parenthesis : constant Wide_Character := ')'; -- WC'Val(41) + Asterisk : constant Wide_Character := '*'; -- WC'Val(42) + Plus_Sign : constant Wide_Character := '+'; -- WC'Val(43) + Comma : constant Wide_Character := ','; -- WC'Val(44) + Hyphen : constant Wide_Character := '-'; -- WC'Val(45) + Minus_Sign : Wide_Character renames Hyphen; + Full_Stop : constant Wide_Character := '.'; -- WC'Val(46) + Solidus : constant Wide_Character := '/'; -- WC'Val(47) + + -- Decimal digits '0' though '9' are at positions 48 through 57 + + Colon : constant Wide_Character := ':'; -- WC'Val(58) + Semicolon : constant Wide_Character := ';'; -- WC'Val(59) + Less_Than_Sign : constant Wide_Character := '<'; -- WC'Val(60) + Equals_Sign : constant Wide_Character := '='; -- WC'Val(61) + Greater_Than_Sign : constant Wide_Character := '>'; -- WC'Val(62) + Question : constant Wide_Character := '?'; -- WC'Val(63) + + Commercial_At : constant Wide_Character := '@'; -- WC'Val(64) + + -- Letters 'A' through 'Z' are at positions 65 through 90 + + Left_Square_Bracket : constant Wide_Character := '['; -- WC'Val (91) + Reverse_Solidus : constant Wide_Character := '\'; -- WC'Val (92) + Right_Square_Bracket : constant Wide_Character := ']'; -- WC'Val (93) + Circumflex : constant Wide_Character := '^'; -- WC'Val (94) + Low_Line : constant Wide_Character := '_'; -- WC'Val (95) + + Grave : constant Wide_Character := '`'; -- WC'Val (96) + LC_A : constant Wide_Character := 'a'; -- WC'Val (97) + LC_B : constant Wide_Character := 'b'; -- WC'Val (98) + LC_C : constant Wide_Character := 'c'; -- WC'Val (99) + LC_D : constant Wide_Character := 'd'; -- WC'Val (100) + LC_E : constant Wide_Character := 'e'; -- WC'Val (101) + LC_F : constant Wide_Character := 'f'; -- WC'Val (102) + LC_G : constant Wide_Character := 'g'; -- WC'Val (103) + LC_H : constant Wide_Character := 'h'; -- WC'Val (104) + LC_I : constant Wide_Character := 'i'; -- WC'Val (105) + LC_J : constant Wide_Character := 'j'; -- WC'Val (106) + LC_K : constant Wide_Character := 'k'; -- WC'Val (107) + LC_L : constant Wide_Character := 'l'; -- WC'Val (108) + LC_M : constant Wide_Character := 'm'; -- WC'Val (109) + LC_N : constant Wide_Character := 'n'; -- WC'Val (110) + LC_O : constant Wide_Character := 'o'; -- WC'Val (111) + LC_P : constant Wide_Character := 'p'; -- WC'Val (112) + LC_Q : constant Wide_Character := 'q'; -- WC'Val (113) + LC_R : constant Wide_Character := 'r'; -- WC'Val (114) + LC_S : constant Wide_Character := 's'; -- WC'Val (115) + LC_T : constant Wide_Character := 't'; -- WC'Val (116) + LC_U : constant Wide_Character := 'u'; -- WC'Val (117) + LC_V : constant Wide_Character := 'v'; -- WC'Val (118) + LC_W : constant Wide_Character := 'w'; -- WC'Val (119) + LC_X : constant Wide_Character := 'x'; -- WC'Val (120) + LC_Y : constant Wide_Character := 'y'; -- WC'Val (121) + LC_Z : constant Wide_Character := 'z'; -- WC'Val (122) + Left_Curly_Bracket : constant Wide_Character := '{'; -- WC'Val (123) + Vertical_Line : constant Wide_Character := '|'; -- WC'Val (124) + Right_Curly_Bracket : constant Wide_Character := '}'; -- WC'Val (125) + Tilde : constant Wide_Character := '~'; -- WC'Val (126) + DEL : constant Wide_Character := Wide_Character'Val (127); + + -------------------------------------- + -- ISO 6429 Control Wide_Characters -- + -------------------------------------- + + IS4 : Wide_Character renames FS; + IS3 : Wide_Character renames GS; + IS2 : Wide_Character renames RS; + IS1 : Wide_Character renames US; + + Reserved_128 : constant Wide_Character := Wide_Character'Val (128); + Reserved_129 : constant Wide_Character := Wide_Character'Val (129); + BPH : constant Wide_Character := Wide_Character'Val (130); + NBH : constant Wide_Character := Wide_Character'Val (131); + Reserved_132 : constant Wide_Character := Wide_Character'Val (132); + NEL : constant Wide_Character := Wide_Character'Val (133); + SSA : constant Wide_Character := Wide_Character'Val (134); + ESA : constant Wide_Character := Wide_Character'Val (135); + HTS : constant Wide_Character := Wide_Character'Val (136); + HTJ : constant Wide_Character := Wide_Character'Val (137); + VTS : constant Wide_Character := Wide_Character'Val (138); + PLD : constant Wide_Character := Wide_Character'Val (139); + PLU : constant Wide_Character := Wide_Character'Val (140); + RI : constant Wide_Character := Wide_Character'Val (141); + SS2 : constant Wide_Character := Wide_Character'Val (142); + SS3 : constant Wide_Character := Wide_Character'Val (143); + + DCS : constant Wide_Character := Wide_Character'Val (144); + PU1 : constant Wide_Character := Wide_Character'Val (145); + PU2 : constant Wide_Character := Wide_Character'Val (146); + STS : constant Wide_Character := Wide_Character'Val (147); + CCH : constant Wide_Character := Wide_Character'Val (148); + MW : constant Wide_Character := Wide_Character'Val (149); + SPA : constant Wide_Character := Wide_Character'Val (150); + EPA : constant Wide_Character := Wide_Character'Val (151); + + SOS : constant Wide_Character := Wide_Character'Val (152); + Reserved_153 : constant Wide_Character := Wide_Character'Val (153); + SCI : constant Wide_Character := Wide_Character'Val (154); + CSI : constant Wide_Character := Wide_Character'Val (155); + ST : constant Wide_Character := Wide_Character'Val (156); + OSC : constant Wide_Character := Wide_Character'Val (157); + PM : constant Wide_Character := Wide_Character'Val (158); + APC : constant Wide_Character := Wide_Character'Val (159); + + ----------------------------------- + -- Other Graphic Wide_Characters -- + ----------------------------------- + + -- Wide_Character positions 160 (16#A0#) .. 175 (16#AF#) + + No_Break_Space : constant Wide_Character := Wide_Character'Val (160); + NBSP : Wide_Character renames No_Break_Space; + Inverted_Exclamation : constant Wide_Character := Wide_Character'Val (161); + Cent_Sign : constant Wide_Character := Wide_Character'Val (162); + Pound_Sign : constant Wide_Character := Wide_Character'Val (163); + Euro_Sign : constant Wide_Character := Wide_Character'Val (164); + Yen_Sign : constant Wide_Character := Wide_Character'Val (165); + UC_S_Caron : constant Wide_Character := Wide_Character'Val (166); + Section_Sign : constant Wide_Character := Wide_Character'Val (167); + LC_S_Caron : constant Wide_Character := Wide_Character'Val (168); + Copyright_Sign : constant Wide_Character := Wide_Character'Val (169); + Feminine_Ordinal_Indicator + : constant Wide_Character := Wide_Character'Val (170); + Left_Angle_Quotation : constant Wide_Character := Wide_Character'Val (171); + Not_Sign : constant Wide_Character := Wide_Character'Val (172); + Soft_Hyphen : constant Wide_Character := Wide_Character'Val (173); + Registered_Trade_Mark_Sign + : constant Wide_Character := Wide_Character'Val (174); + Macron : constant Wide_Character := Wide_Character'Val (175); + + -- Wide_Character positions 176 (16#B0#) .. 191 (16#BF#) + + Degree_Sign : constant Wide_Character := Wide_Character'Val (176); + Ring_Above : Wide_Character renames Degree_Sign; + Plus_Minus_Sign : constant Wide_Character := Wide_Character'Val (177); + Superscript_Two : constant Wide_Character := Wide_Character'Val (178); + Superscript_Three : constant Wide_Character := Wide_Character'Val (179); + UC_Z_Caron : constant Wide_Character := Wide_Character'Val (180); + Micro_Sign : constant Wide_Character := Wide_Character'Val (181); + Pilcrow_Sign : constant Wide_Character := Wide_Character'Val (182); + Paragraph_Sign : Wide_Character renames Pilcrow_Sign; + Middle_Dot : constant Wide_Character := Wide_Character'Val (183); + LC_Z_Caron : constant Wide_Character := Wide_Character'Val (184); + Superscript_One : constant Wide_Character := Wide_Character'Val (185); + Masculine_Ordinal_Indicator + : constant Wide_Character := Wide_Character'Val (186); + Right_Angle_Quotation + : constant Wide_Character := Wide_Character'Val (187); + UC_Ligature_OE : constant Wide_Character := Wide_Character'Val (188); + LC_Ligature_OE : constant Wide_Character := Wide_Character'Val (189); + UC_Y_Diaeresis : constant Wide_Character := Wide_Character'Val (190); + Inverted_Question : constant Wide_Character := Wide_Character'Val (191); + + -- Wide_Character positions 192 (16#C0#) .. 207 (16#CF#) + + UC_A_Grave : constant Wide_Character := Wide_Character'Val (192); + UC_A_Acute : constant Wide_Character := Wide_Character'Val (193); + UC_A_Circumflex : constant Wide_Character := Wide_Character'Val (194); + UC_A_Tilde : constant Wide_Character := Wide_Character'Val (195); + UC_A_Diaeresis : constant Wide_Character := Wide_Character'Val (196); + UC_A_Ring : constant Wide_Character := Wide_Character'Val (197); + UC_AE_Diphthong : constant Wide_Character := Wide_Character'Val (198); + UC_C_Cedilla : constant Wide_Character := Wide_Character'Val (199); + UC_E_Grave : constant Wide_Character := Wide_Character'Val (200); + UC_E_Acute : constant Wide_Character := Wide_Character'Val (201); + UC_E_Circumflex : constant Wide_Character := Wide_Character'Val (202); + UC_E_Diaeresis : constant Wide_Character := Wide_Character'Val (203); + UC_I_Grave : constant Wide_Character := Wide_Character'Val (204); + UC_I_Acute : constant Wide_Character := Wide_Character'Val (205); + UC_I_Circumflex : constant Wide_Character := Wide_Character'Val (206); + UC_I_Diaeresis : constant Wide_Character := Wide_Character'Val (207); + + -- Wide_Character positions 208 (16#D0#) .. 223 (16#DF#) + + UC_Icelandic_Eth : constant Wide_Character := Wide_Character'Val (208); + UC_N_Tilde : constant Wide_Character := Wide_Character'Val (209); + UC_O_Grave : constant Wide_Character := Wide_Character'Val (210); + UC_O_Acute : constant Wide_Character := Wide_Character'Val (211); + UC_O_Circumflex : constant Wide_Character := Wide_Character'Val (212); + UC_O_Tilde : constant Wide_Character := Wide_Character'Val (213); + UC_O_Diaeresis : constant Wide_Character := Wide_Character'Val (214); + Multiplication_Sign : constant Wide_Character := Wide_Character'Val (215); + UC_O_Oblique_Stroke : constant Wide_Character := Wide_Character'Val (216); + UC_U_Grave : constant Wide_Character := Wide_Character'Val (217); + UC_U_Acute : constant Wide_Character := Wide_Character'Val (218); + UC_U_Circumflex : constant Wide_Character := Wide_Character'Val (219); + UC_U_Diaeresis : constant Wide_Character := Wide_Character'Val (220); + UC_Y_Acute : constant Wide_Character := Wide_Character'Val (221); + UC_Icelandic_Thorn : constant Wide_Character := Wide_Character'Val (222); + LC_German_Sharp_S : constant Wide_Character := Wide_Character'Val (223); + + -- Wide_Character positions 224 (16#E0#) .. 239 (16#EF#) + + LC_A_Grave : constant Wide_Character := Wide_Character'Val (224); + LC_A_Acute : constant Wide_Character := Wide_Character'Val (225); + LC_A_Circumflex : constant Wide_Character := Wide_Character'Val (226); + LC_A_Tilde : constant Wide_Character := Wide_Character'Val (227); + LC_A_Diaeresis : constant Wide_Character := Wide_Character'Val (228); + LC_A_Ring : constant Wide_Character := Wide_Character'Val (229); + LC_AE_Diphthong : constant Wide_Character := Wide_Character'Val (230); + LC_C_Cedilla : constant Wide_Character := Wide_Character'Val (231); + LC_E_Grave : constant Wide_Character := Wide_Character'Val (232); + LC_E_Acute : constant Wide_Character := Wide_Character'Val (233); + LC_E_Circumflex : constant Wide_Character := Wide_Character'Val (234); + LC_E_Diaeresis : constant Wide_Character := Wide_Character'Val (235); + LC_I_Grave : constant Wide_Character := Wide_Character'Val (236); + LC_I_Acute : constant Wide_Character := Wide_Character'Val (237); + LC_I_Circumflex : constant Wide_Character := Wide_Character'Val (238); + LC_I_Diaeresis : constant Wide_Character := Wide_Character'Val (239); + + -- Wide_Character positions 240 (16#F0#) .. 255 (16#FF) + + LC_Icelandic_Eth : constant Wide_Character := Wide_Character'Val (240); + LC_N_Tilde : constant Wide_Character := Wide_Character'Val (241); + LC_O_Grave : constant Wide_Character := Wide_Character'Val (242); + LC_O_Acute : constant Wide_Character := Wide_Character'Val (243); + LC_O_Circumflex : constant Wide_Character := Wide_Character'Val (244); + LC_O_Tilde : constant Wide_Character := Wide_Character'Val (245); + LC_O_Diaeresis : constant Wide_Character := Wide_Character'Val (246); + Division_Sign : constant Wide_Character := Wide_Character'Val (247); + LC_O_Oblique_Stroke : constant Wide_Character := Wide_Character'Val (248); + LC_U_Grave : constant Wide_Character := Wide_Character'Val (249); + LC_U_Acute : constant Wide_Character := Wide_Character'Val (250); + LC_U_Circumflex : constant Wide_Character := Wide_Character'Val (251); + LC_U_Diaeresis : constant Wide_Character := Wide_Character'Val (252); + LC_Y_Acute : constant Wide_Character := Wide_Character'Val (253); + LC_Icelandic_Thorn : constant Wide_Character := Wide_Character'Val (254); + LC_Y_Diaeresis : constant Wide_Character := Wide_Character'Val (255); + + ------------------------------------------------ + -- Summary of Changes from Latin-1 => Latin-9 -- + ------------------------------------------------ + + -- 164 Currency => Euro_Sign + -- 166 Broken_Bar => UC_S_Caron + -- 168 Diaeresis => LC_S_Caron + -- 180 Acute => UC_Z_Caron + -- 184 Cedilla => LC_Z_Caron + -- 188 Fraction_One_Quarter => UC_Ligature_OE + -- 189 Fraction_One_Half => LC_Ligature_OE + -- 190 Fraction_Three_Quarters => UC_Y_Diaeresis + + end Ada.Characters.Wide_Latin_9; diff -Nrc3pad gcc-3.2.3/gcc/ada/ada.ads gcc-3.3/gcc/ada/ada.ads *** gcc-3.2.3/gcc/ada/ada.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/ada.ads 2002-03-14 10:59:01.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/adadecode.c gcc-3.3/gcc/ada/adadecode.c *** gcc-3.2.3/gcc/ada/adadecode.c 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/adadecode.c 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,319 ---- + /**************************************************************************** + * * + * GNAT COMPILER COMPONENTS * + * * + * G N A T D E C O * + * * + * * + * C Implementation File * + * * + * Copyright (C) 2001-2002, 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- * + * 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, 59 Temple Place - Suite 330, Boston, * + * MA 02111-1307, USA. * + * * + * As a special exception, if you link this file with other files to * + * produce an executable, this file does not by itself cause the resulting * + * executable to be covered by the GNU General Public License. This except- * + * ion does not however invalidate any other reasons why the executable * + * file might be covered by the GNU Public License. * + * * + * GNAT was originally developed by the GNAT team at New York University. * + * Extensive contributions were provided by Ada Core Technologies Inc. * + * * + ****************************************************************************/ + + #ifdef IN_GCC + #include "config.h" + #include "system.h" + #else + #include + #define PARMS(ARGS) ARGS + #endif + + #include "ctype.h" + #include "adadecode.h" + + static void add_verbose PARAMS ((const char *, char *)); + static int has_prefix PARAMS ((char *, const char *)); + static int has_suffix PARAMS ((char *, const char *)); + + /* Set to nonzero if we have written any verbose info. */ + static int verbose_info; + + /* Add TEXT to end of ADA_NAME, putting a leading " (" or ", ", depending + on VERBOSE_INFO. */ + + static void add_verbose (text, ada_name) + const char *text; + char *ada_name; + { + strcat (ada_name, verbose_info ? ", " : " ("); + strcat (ada_name, text); + + verbose_info = 1; + } + + /* Returns 1 if NAME starts with PREFIX. */ + + static int + has_prefix (name, prefix) + char *name; + const char *prefix; + { + return strncmp (name, prefix, strlen (prefix)) == 0; + } + + /* Returns 1 if NAME ends with SUFFIX. */ + + static int + has_suffix (name, suffix) + char *name; + const char *suffix; + { + int nlen = strlen (name); + int slen = strlen (suffix); + + return nlen > slen && strncmp (name + nlen - slen, suffix, slen) == 0; + } + + /* This function will return the Ada name from the encoded form. + The Ada coding is done in exp_dbug.ads and this is the inverse function. + see exp_dbug.ads for full encoding rules, a short description is added + below. Right now only objects and routines are handled. There is no support + for Ada types. + + CODED_NAME is the encoded entity name. + + ADA_NAME is a pointer to a buffer, it will receive the Ada name. A safe + size for this buffer is: strlen (coded_name) * 2 + 60. (60 is for the + verbose information). + + VERBOSE is nonzero if more information about the entity is to be + added at the end of the Ada name and surrounded by ( and ). + + Coded name Ada name verbose info + --------------------------------------------------------------------- + _ada_xyz xyz library level + x__y__z x.y.z + x__yTKB x.y task body + x__yB x.y task body + x__yX x.y body nested + x__yXb x.y body nested + xTK__y x.y in task + x__y$2 x.y overloaded + x__y__3 x.y overloaded + x__Oabs "abs" + x__Oand "and" + x__Omod "mod" + x__Onot "not" + x__Oor "or" + x__Orem "rem" + x__Oxor "xor" + x__Oeq "=" + x__One "/=" + x__Olt "<" + x__Ole "<=" + x__Ogt ">" + x__Oge ">=" + x__Oadd "+" + x__Osubtract "-" + x__Oconcat "&" + x__Omultiply "*" + x__Odivide "/" + x__Oexpon "**" */ + + void + __gnat_decode (coded_name, ada_name, verbose) + const char *coded_name; + char *ada_name; + int verbose; + { + int lib_subprog = 0; + int overloaded = 0; + int task_body = 0; + int in_task = 0; + int body_nested = 0; + + /* Copy the coded name into the ada name string, the rest of the code will + just replace or add characters into the ada_name. */ + strcpy (ada_name, coded_name); + + /* Check for library level subprogram. */ + if (has_prefix (ada_name, "_ada_")) + { + strcpy (ada_name, ada_name + 5); + lib_subprog = 1; + } + + /* Check for task body. */ + if (has_suffix (ada_name, "TKB")) + { + ada_name[strlen (ada_name) - 3] = '\0'; + task_body = 1; + } + + if (has_suffix (ada_name, "B")) + { + ada_name[strlen (ada_name) - 1] = '\0'; + task_body = 1; + } + + /* Check for body-nested entity: X[bn] */ + if (has_suffix (ada_name, "X")) + { + ada_name[strlen (ada_name) - 1] = '\0'; + body_nested = 1; + } + + if (has_suffix (ada_name, "Xb")) + { + ada_name[strlen (ada_name) - 2] = '\0'; + body_nested = 1; + } + + if (has_suffix (ada_name, "Xn")) + { + ada_name[strlen (ada_name) - 2] = '\0'; + body_nested = 1; + } + + /* Change instance of TK__ (object declared inside a task) to __. */ + { + char *tktoken; + + while ((tktoken = (char *) strstr (ada_name, "TK__")) != NULL) + { + strcpy (tktoken, tktoken + 2); + in_task = 1; + } + } + + /* Check for overloading: name terminated by $nn or __nn. */ + { + int len = strlen (ada_name); + int n_digits = 0; + + if (len > 1) + while (isdigit ((int) ada_name[(int) len - 1 - n_digits])) + n_digits++; + + /* Check if we have $ or __ before digits. */ + if (ada_name[len - 1 - n_digits] == '$') + { + ada_name[len - 1 - n_digits] = '\0'; + overloaded = 1; + } + else if (ada_name[len - 1 - n_digits] == '_' + && ada_name[len - 1 - n_digits - 1] == '_') + { + ada_name[len - 1 - n_digits - 1] = '\0'; + overloaded = 1; + } + } + + /* Change all "__" to ".". */ + { + int len = strlen (ada_name); + int k = 0; + + while (k < len) + { + if (ada_name[k] == '_' && ada_name[k+1] == '_') + { + ada_name[k] = '.'; + strcpy (ada_name + k + 1, ada_name + k + 2); + len = len - 1; + } + k++; + } + } + + /* Checks for operator name. */ + { + const char *trans_table[][2] + = {{"Oabs", "\"abs\""}, {"Oand", "\"and\""}, {"Omod", "\"mod\""}, + {"Onot", "\"not\""}, {"Oor", "\"or\""}, {"Orem", "\"rem\""}, + {"Oxor", "\"xor\""}, {"Oeq", "\"=\""}, {"One", "\"/=\""}, + {"Olt", "\"<\""}, {"Ole", "\"<=\""}, {"Ogt", "\">\""}, + {"Oge", "\">=\""}, {"Oadd", "\"+\""}, {"Osubtract", "\"-\""}, + {"Oconcat", "\"&\""}, {"Omultiply", "\"*\""}, {"Odivide", "\"/\""}, + {"Oexpon", "\"**\""}, {NULL, NULL} }; + int k = 0; + + while (1) + { + char *optoken; + + if ((optoken = (char *) strstr (ada_name, trans_table[k][0])) != NULL) + { + int codedlen = strlen (trans_table[k][0]); + int oplen = strlen (trans_table[k][1]); + + if (codedlen > oplen) + /* We shrink the space. */ + strcpy (optoken, optoken + codedlen - oplen); + else if (oplen > codedlen) + { + /* We need more space. */ + int len = strlen (ada_name); + int space = oplen - codedlen; + int num_to_move = &ada_name[len] - optoken; + int t; + + for (t = 0; t < num_to_move; t++) + ada_name[len + space - t - 1] = ada_name[len - t - 1]; + } + + /* Write symbol in the space. */ + strncpy (optoken, trans_table[k][1], oplen); + } + else + k++; + + /* Check for table's ending. */ + if (trans_table[k][0] == NULL) + break; + } + } + + /* If verbose mode is on, we add some information to the Ada name. */ + if (verbose) + { + if (overloaded) + add_verbose ("overloaded", ada_name); + + if (lib_subprog) + add_verbose ("library level", ada_name); + + if (body_nested) + add_verbose ("body nested", ada_name); + + if (in_task) + add_verbose ("in task", ada_name); + + if (task_body) + add_verbose ("task body", ada_name); + + if (verbose_info == 1) + strcat (ada_name, ")"); + } + } + + char * + ada_demangle (coded_name) + const char *coded_name; + { + char ada_name[2048]; + + __gnat_decode (coded_name, ada_name, 0); + return xstrdup (ada_name); + } diff -Nrc3pad gcc-3.2.3/gcc/ada/adadecode.h gcc-3.3/gcc/ada/adadecode.h *** gcc-3.2.3/gcc/ada/adadecode.h 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/adadecode.h 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,51 ---- + /**************************************************************************** + * * + * GNAT COMPILER COMPONENTS * + * * + * G N A T D E C O * + * * + * * + * C Header File * + * * + * Copyright (C) 2001-2002, 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- * + * 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, 59 Temple Place - Suite 330, Boston, * + * MA 02111-1307, USA. * + * * + * As a special exception, if you link this file with other files to * + * produce an executable, this file does not by itself cause the resulting * + * executable to be covered by the GNU General Public License. This except- * + * ion does not however invalidate any other reasons why the executable * + * file might be covered by the GNU Public License. * + * * + * GNAT was originally developed by the GNAT team at New York University. * + * Extensive contributions were provided by Ada Core Technologies Inc. * + * * + ****************************************************************************/ + + /* This function will return the Ada name from the encoded form. + The Ada coding is done in exp_dbug.ads and this is the inverse function. + see exp_dbug.ads for full encoding rules, a short description is added + below. Right now only objects and routines are handled. There is no support + for Ada types. + + CODED_NAME is the encoded entity name. + ADA_NAME is a pointer to a buffer, it will receive the Ada name. A safe + size for this buffer is: strlen (coded_name) * 2 + 60. (60 is for the + verbose information). + VERBOSE is nonzero if more information about the entity is to be + added at the end of the Ada name and surrounded by ( and ). */ + extern void __gnat_decode PARAMS ((const char *, char *, int)); + + /* ada_demangle is added for COMPATIBILITY ONLY. It has the name of the + function used in the binutils and GDB. Always consider using __gnat_decode + instead of ada_demangle. Caller must free the pointer returned. */ + extern char *ada_demangle PARAMS ((const char *)); diff -Nrc3pad gcc-3.2.3/gcc/ada/adafinal.c gcc-3.3/gcc/ada/adafinal.c *** gcc-3.2.3/gcc/ada/adafinal.c 2003-01-28 22:28:24.000000000 +0000 --- gcc-3.3/gcc/ada/adafinal.c 2003-01-29 22:37:55.000000000 +0000 *************** *** 4,10 **** * * * A D A F I N A L * * * - * $Revision: 1.1.2.1 $ * * * C Implementation File * * * --- 4,9 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/ada.h gcc-3.3/gcc/ada/ada.h *** gcc-3.2.3/gcc/ada/ada.h 2002-05-04 03:27:31.000000000 +0000 --- gcc-3.3/gcc/ada/ada.h 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * ! * Copyright (C) 1992-2001 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- * --- 6,13 ---- * * * C Header File * * * * * ! * Copyright (C) 1992-2002 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- * *************** *** 35,40 **** --- 34,42 ---- /* This file contains some standard macros for performing Ada-like operations. These are used to aid in the translation of other headers. */ + #ifndef GCC_ADA_H + #define GCC_ADA_H + /* Inlined functions in header are preceded by INLINE, which is normally set to extern inline for GCC, but may be set to static for use in standard ANSI-C. */ *************** *** 63,76 **** effect is to compile a typedef defining the subtype as a synonym for the type, together with two constants defining the end points. */ ! #define SUBTYPE(SUBTYPE,TYPE,FIRST,LAST) \ ! typedef TYPE SUBTYPE; \ ! static const SUBTYPE CAT (SUBTYPE,__First) = FIRST; \ ! static const SUBTYPE CAT (SUBTYPE,__Last) = LAST; /* The following definitions provide the equivalent of the Ada IN and NOT IN operators, assuming that the subtype involved has been defined using the SUBTYPE macro defined above. */ #define IN(VALUE,SUBTYPE) \ ! (((VALUE) >= CAT (SUBTYPE,__First)) && ((VALUE) <= CAT (SUBTYPE,__Last))) --- 65,81 ---- effect is to compile a typedef defining the subtype as a synonym for the type, together with two constants defining the end points. */ ! #define SUBTYPE(SUBTYPE,TYPE,FIRST,LAST) \ ! typedef TYPE SUBTYPE; \ ! enum { CAT (SUBTYPE,__First) = FIRST, \ ! CAT (SUBTYPE,__Last) = LAST }; /* The following definitions provide the equivalent of the Ada IN and NOT IN operators, assuming that the subtype involved has been defined using the SUBTYPE macro defined above. */ #define IN(VALUE,SUBTYPE) \ ! (((VALUE) >= (SUBTYPE) CAT (SUBTYPE,__First)) && \ ! ((VALUE) <= (SUBTYPE) CAT (SUBTYPE,__Last))) ! ! #endif diff -Nrc3pad gcc-3.2.3/gcc/ada/adaint.c gcc-3.3/gcc/ada/adaint.c *** gcc-3.2.3/gcc/ada/adaint.c 2002-05-04 03:27:31.000000000 +0000 --- gcc-3.3/gcc/ada/adaint.c 2002-11-18 14:39:46.000000000 +0000 *************** *** 4,14 **** * * * A D A I N T * * * - * $Revision: 1.7.2.2 $ * * * C Implementation File * * * ! * Copyright (C) 1992-2001, 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- * --- 4,13 ---- * * * A D A I N T * * * * * * C Implementation File * * * ! * Copyright (C) 1992-2002, 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- * *************** *** 32,47 **** * * ****************************************************************************/ ! /* This file contains those routines named by Import pragmas in packages */ ! /* in the GNAT hierarchy (especially GNAT.OS_Lib) and in package Osint. */ ! /* Many of the subprograms in OS_Lib import standard library calls */ ! /* directly. This file contains all other routines. */ #ifdef __vxworks ! /* No need to redefine exit here */ ! #ifdef exit #undef exit ! #endif /* We want to use the POSIX variants of include files. */ #define POSIX #include "vxWorks.h" --- 31,46 ---- * * ****************************************************************************/ ! /* This file contains those routines named by Import pragmas in ! packages in the GNAT hierarchy (especially GNAT.OS_Lib) and in ! package Osint. Many of the subprograms in OS_Lib import standard ! library calls directly. This file contains all other routines. */ #ifdef __vxworks ! ! /* No need to redefine exit here. */ #undef exit ! /* We want to use the POSIX variants of include files. */ #define POSIX #include "vxWorks.h" *************** *** 59,66 **** #include #include ! /* We don't have libiberty, so us malloc. */ #define xmalloc(S) malloc (S) #else #include "config.h" #include "system.h" --- 58,66 ---- #include #include ! /* We don't have libiberty, so use malloc. */ #define xmalloc(S) malloc (S) + #define xrealloc(V,S) realloc (V,S) #else #include "config.h" #include "system.h" *************** *** 70,76 **** #if defined (__EMX__) || defined (MSDOS) || defined (_WIN32) #elif defined (VMS) ! /* Header files and definitions for __gnat_set_file_time_name. */ #include #include --- 70,76 ---- #if defined (__EMX__) || defined (MSDOS) || defined (_WIN32) #elif defined (VMS) ! /* Header files and definitions for __gnat_set_file_time_name. */ #include #include *************** *** 82,88 **** #include #include ! /* use native 64-bit arithmetic */ #define unix_time_to_vms(X,Y) \ { unsigned long long reftime, tmptime = (X); \ $DESCRIPTOR (unixtime,"1-JAN-1970 0:00:00.00"); \ --- 82,88 ---- #include #include ! /* Use native 64-bit arithmetic. */ #define unix_time_to_vms(X,Y) \ { unsigned long long reftime, tmptime = (X); \ $DESCRIPTOR (unixtime,"1-JAN-1970 0:00:00.00"); \ *************** static char *tryfile; *** 109,118 **** struct vstring { short length; ! char string [NAM$C_MAXRSS+1]; }; - #else #include #endif --- 109,117 ---- struct vstring { short length; ! char string[NAM$C_MAXRSS+1]; }; #else #include #endif *************** char __gnat_path_separator = PATH_SEPARA *** 192,203 **** ??? This should be part of a GNAT host-specific compiler file instead of being included in all user applications ! as well. This is only a temporary work-around for 3.11b. */ #ifndef GNAT_LIBRARY_TEMPLATE ! #if defined(__EMX__) #define GNAT_LIBRARY_TEMPLATE "*.a" ! #elif defined(VMS) #define GNAT_LIBRARY_TEMPLATE "*.olb" #else #define GNAT_LIBRARY_TEMPLATE "lib*.a" --- 191,202 ---- ??? This should be part of a GNAT host-specific compiler file instead of being included in all user applications ! as well. This is only a temporary work-around for 3.11b. */ #ifndef GNAT_LIBRARY_TEMPLATE ! #if defined (__EMX__) #define GNAT_LIBRARY_TEMPLATE "*.a" ! #elif defined (VMS) #define GNAT_LIBRARY_TEMPLATE "*.olb" #else #define GNAT_LIBRARY_TEMPLATE "lib*.a" *************** char __gnat_path_separator = PATH_SEPARA *** 206,213 **** const char *__gnat_library_template = GNAT_LIBRARY_TEMPLATE; /* The following macro HAVE_READDIR_R should be defined if the ! system provides the routine readdir_r */ #undef HAVE_READDIR_R void --- 205,238 ---- const char *__gnat_library_template = GNAT_LIBRARY_TEMPLATE; + /* This variable is used in hostparm.ads to say whether the host is a VMS + system. */ + #ifdef VMS + const int __gnat_vmsp = 1; + #else + const int __gnat_vmsp = 0; + #endif + + /* This variable is used to export the maximum length of a path name to + Ada code. */ + + #ifdef __EMX__ + int __gnat_max_path_len = _MAX_PATH; + + #elif defined (VMS) + int __gnat_max_path_len = 4096; /* PATH_MAX */ + + #elif defined (__vxworks) || defined (__OPENNT) + int __gnat_max_path_len = PATH_MAX; + + #else + #include + int __gnat_max_path_len = MAXPATHLEN; + + #endif + /* The following macro HAVE_READDIR_R should be defined if the ! system provides the routine readdir_r. */ #undef HAVE_READDIR_R void *************** __gnat_to_gm_time (p_time, p_year, p_mon *** 234,240 **** *p_hours = res->tm_hour; *p_mins = res->tm_min; *p_secs = res->tm_sec; ! } else *p_year = *p_month = *p_day = *p_hours = *p_mins = *p_secs = 0; } --- 259,265 ---- *p_hours = res->tm_hour; *p_mins = res->tm_min; *p_secs = res->tm_sec; ! } else *p_year = *p_month = *p_day = *p_hours = *p_mins = *p_secs = 0; } *************** __gnat_readlink (path, buf, bufsiz) *** 261,270 **** #endif } ! /* Creates a symbolic link named newpath ! which contains the string oldpath. ! If newpath exists it will NOT be overwritten. ! For Windows, OS/2, vxworks, Interix and VMS, always retur -1. */ int __gnat_symlink (oldpath, newpath) --- 286,294 ---- #endif } ! /* Creates a symbolic link named NEWPATH which contains the string OLDPATH. If ! NEWPATH exists it will NOT be overwritten. For Windows, OS/2, VxWorks, ! Interix and VMS, always return -1. */ int __gnat_symlink (oldpath, newpath) *************** __gnat_symlink (oldpath, newpath) *** 282,288 **** #endif } ! /* Try to lock a file, return 1 if success */ #if defined (__vxworks) || defined (MSDOS) || defined (_WIN32) --- 306,312 ---- #endif } ! /* Try to lock a file, return 1 if success. */ #if defined (__vxworks) || defined (MSDOS) || defined (_WIN32) *************** __gnat_try_lock (dir, file) *** 293,306 **** char *dir; char *file; { ! char full_path [256]; int fd; sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file); fd = open (full_path, O_CREAT | O_EXCL, 0600); ! if (fd < 0) { return 0; ! } close (fd); return 1; } --- 317,330 ---- char *dir; char *file; { ! char full_path[256]; int fd; sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file); fd = open (full_path, O_CREAT | O_EXCL, 0600); ! if (fd < 0) return 0; ! close (fd); return 1; } *************** __gnat_try_lock (dir, file) *** 315,321 **** char *dir; char *file; { ! char full_path [256]; int fd; sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file); --- 339,345 ---- char *dir; char *file; { ! char full_path[256]; int fd; sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file); *************** __gnat_try_lock (dir, file) *** 328,333 **** --- 352,358 ---- } #else + /* Version using link(), more secure over NFS. */ int *************** __gnat_try_lock (dir, file) *** 335,360 **** char *dir; char *file; { ! char full_path [256]; ! char temp_file [256]; struct stat stat_result; int fd; sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file); sprintf (temp_file, "%s-%d-%d", dir, getpid(), getppid ()); ! /* Create the temporary file and write the process number */ fd = open (temp_file, O_CREAT | O_WRONLY, 0600); if (fd < 0) return 0; close (fd); ! /* Link it with the new file */ link (temp_file, full_path); /* Count the references on the old one. If we have a count of two, then ! the link did succeed. Remove the temporary file before returning. */ __gnat_stat (temp_file, &stat_result); unlink (temp_file); return stat_result.st_nlink == 2; --- 360,385 ---- char *dir; char *file; { ! char full_path[256]; ! char temp_file[256]; struct stat stat_result; int fd; sprintf (full_path, "%s%c%s", dir, DIR_SEPARATOR, file); sprintf (temp_file, "%s-%d-%d", dir, getpid(), getppid ()); ! /* Create the temporary file and write the process number. */ fd = open (temp_file, O_CREAT | O_WRONLY, 0600); if (fd < 0) return 0; close (fd); ! /* Link it with the new file. */ link (temp_file, full_path); /* Count the references on the old one. If we have a count of two, then ! the link did succeed. Remove the temporary file before returning. */ __gnat_stat (temp_file, &stat_result); unlink (temp_file); return stat_result.st_nlink == 2; *************** __gnat_try_lock (dir, file) *** 366,372 **** int __gnat_get_maximum_file_name_length () { ! #if defined(MSDOS) return 8; #elif defined (VMS) if (getenv ("GNAT$EXTENDED_FILE_SPECIFICATIONS")) --- 391,397 ---- int __gnat_get_maximum_file_name_length () { ! #if defined (MSDOS) return 8; #elif defined (VMS) if (getenv ("GNAT$EXTENDED_FILE_SPECIFICATIONS")) *************** __gnat_get_maximum_file_name_length () *** 378,401 **** #endif } - /* Return the default switch character. */ - - char - __gnat_get_switch_character () - { - /* Under MSDOS, the switch character is not normally a hyphen, but this is - the convention DJGPP uses. Similarly under OS2, the switch character is - not normally a hypen, but this is the convention EMX uses. */ - - return '-'; - } - /* Return nonzero if file names are case sensitive. */ int __gnat_get_file_names_case_sensitive () { ! #if defined (__EMX__) || defined (MSDOS) || defined (VMS) || defined(WINNT) return 0; #else return 1; --- 403,414 ---- #endif } /* Return nonzero if file names are case sensitive. */ int __gnat_get_file_names_case_sensitive () { ! #if defined (__EMX__) || defined (MSDOS) || defined (VMS) || defined (WINNT) return 0; #else return 1; *************** __gnat_get_default_identifier_character_ *** 412,418 **** #endif } ! /* Return the current working directory */ void __gnat_get_current_dir (dir, length) --- 425,431 ---- #endif } ! /* Return the current working directory. */ void __gnat_get_current_dir (dir, length) *************** __gnat_get_current_dir (dir, length) *** 428,439 **** *length = strlen (dir); ! dir [*length] = DIR_SEPARATOR; ! ++(*length); ! dir [*length] = '\0'; } ! /* Return the suffix for object files. */ void __gnat_get_object_suffix_ptr (len, value) --- 441,452 ---- *length = strlen (dir); ! dir[*length] = DIR_SEPARATOR; ! ++*length; ! dir[*length] = '\0'; } ! /* Return the suffix for object files. */ void __gnat_get_object_suffix_ptr (len, value) *************** __gnat_get_object_suffix_ptr (len, value *** 450,456 **** return; } ! /* Return the suffix for executable files */ void __gnat_get_executable_suffix_ptr (len, value) --- 463,469 ---- return; } ! /* Return the suffix for executable files. */ void __gnat_get_executable_suffix_ptr (len, value) *************** __gnat_get_executable_suffix_ptr (len, v *** 467,473 **** } /* Return the suffix for debuggable files. Usually this is the same as the ! executable extension. */ void __gnat_get_debuggable_suffix_ptr (len, value) --- 480,486 ---- } /* Return the suffix for debuggable files. Usually this is the same as the ! executable extension. */ void __gnat_get_debuggable_suffix_ptr (len, value) *************** __gnat_get_debuggable_suffix_ptr (len, v *** 477,483 **** #ifndef MSDOS *value = HOST_EXECUTABLE_SUFFIX; #else ! /* On DOS, the extensionless COFF file is what gdb likes. */ *value = ""; #endif --- 490,496 ---- #ifndef MSDOS *value = HOST_EXECUTABLE_SUFFIX; #else ! /* On DOS, the extensionless COFF file is what gdb likes. */ *value = ""; #endif *************** __gnat_open_read (path, fmode) *** 500,514 **** if (fmode) o_fmode = O_TEXT; ! #if defined(VMS) ! /* Optional arguments mbc,deq,fop increase read performance */ fd = open (path, O_RDONLY | o_fmode, 0444, "mbc=16", "deq=64", "fop=tef"); ! #elif defined(__vxworks) fd = open (path, O_RDONLY | o_fmode, 0444); #else fd = open (path, O_RDONLY | o_fmode); #endif return fd < 0 ? -1 : fd; } --- 513,528 ---- if (fmode) o_fmode = O_TEXT; ! #if defined (VMS) ! /* Optional arguments mbc,deq,fop increase read performance. */ fd = open (path, O_RDONLY | o_fmode, 0444, "mbc=16", "deq=64", "fop=tef"); ! #elif defined (__vxworks) fd = open (path, O_RDONLY | o_fmode, 0444); #else fd = open (path, O_RDONLY | o_fmode); #endif + return fd < 0 ? -1 : fd; } *************** __gnat_open_rw (path, fmode) *** 529,535 **** if (fmode) o_fmode = O_TEXT; ! #if defined(VMS) fd = open (path, O_RDWR | o_fmode, PERM, "mbc=16", "deq=64", "fop=tef"); #else --- 543,549 ---- if (fmode) o_fmode = O_TEXT; ! #if defined (VMS) fd = open (path, O_RDWR | o_fmode, PERM, "mbc=16", "deq=64", "fop=tef"); #else *************** __gnat_open_create (path, fmode) *** 550,556 **** if (fmode) o_fmode = O_TEXT; ! #if defined(VMS) fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | o_fmode, PERM, "mbc=16", "deq=64", "fop=tef"); #else --- 564,570 ---- if (fmode) o_fmode = O_TEXT; ! #if defined (VMS) fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | o_fmode, PERM, "mbc=16", "deq=64", "fop=tef"); #else *************** __gnat_open_append (path, fmode) *** 571,577 **** if (fmode) o_fmode = O_TEXT; ! #if defined(VMS) fd = open (path, O_WRONLY | O_CREAT | O_APPEND | o_fmode, PERM, "mbc=16", "deq=64", "fop=tef"); #else --- 585,591 ---- if (fmode) o_fmode = O_TEXT; ! #if defined (VMS) fd = open (path, O_WRONLY | O_CREAT | O_APPEND | o_fmode, PERM, "mbc=16", "deq=64", "fop=tef"); #else *************** __gnat_open_append (path, fmode) *** 581,587 **** return fd < 0 ? -1 : fd; } ! /* Open a new file. Return error (-1) if the file already exists. */ int __gnat_open_new (path, fmode) --- 595,601 ---- return fd < 0 ? -1 : fd; } ! /* Open a new file. Return error (-1) if the file already exists. */ int __gnat_open_new (path, fmode) *************** __gnat_open_new (path, fmode) *** 594,600 **** if (fmode) o_fmode = O_TEXT; ! #if defined(VMS) fd = open (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM, "mbc=16", "deq=64", "fop=tef"); #else --- 608,614 ---- if (fmode) o_fmode = O_TEXT; ! #if defined (VMS) fd = open (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM, "mbc=16", "deq=64", "fop=tef"); #else *************** __gnat_open_new (path, fmode) *** 605,613 **** } /* Open a new temp file. Return error (-1) if the file already exists. ! Special options for VMS allow the file to be shared between parent and ! child processes, however they really slow down output. Used in ! gnatchop. */ int __gnat_open_new_temp (path, fmode) --- 619,626 ---- } /* Open a new temp file. Return error (-1) if the file already exists. ! Special options for VMS allow the file to be shared between parent and child ! processes, however they really slow down output. Used in gnatchop. */ int __gnat_open_new_temp (path, fmode) *************** __gnat_open_new_temp (path, fmode) *** 631,637 **** if (fmode) o_fmode = O_TEXT; ! #if defined(VMS) fd = open (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM, "rfm=stmlf", "ctx=rec", "rat=none", "shr=del,get,put,upd", "mbc=16", "deq=64", "fop=tef"); --- 644,650 ---- if (fmode) o_fmode = O_TEXT; ! #if defined (VMS) fd = open (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM, "rfm=stmlf", "ctx=rec", "rat=none", "shr=del,get,put,upd", "mbc=16", "deq=64", "fop=tef"); *************** __gnat_open_new_temp (path, fmode) *** 642,666 **** return fd < 0 ? -1 : fd; } ! int ! __gnat_mkdir (dir_name) ! char *dir_name; ! { ! /* On some systems, mkdir has two args and on some it has one. If we ! are being built as part of the compiler, autoconf has figured that out ! for us. Otherwise, we have to do it ourselves. */ ! #ifndef IN_RTS ! return mkdir (dir_name, S_IRWXU | S_IRWXG | S_IRWXO); ! #else ! #if defined (_WIN32) || defined (__vxworks) ! return mkdir (dir_name); ! #else ! return mkdir (dir_name, S_IRWXU | S_IRWXG | S_IRWXO); ! #endif ! #endif ! } ! ! /* Return the number of bytes in the specified file. */ long __gnat_file_length (fd) --- 655,661 ---- return fd < 0 ? -1 : fd; } ! /* Return the number of bytes in the specified file. */ long __gnat_file_length (fd) *************** __gnat_file_length (fd) *** 677,683 **** } /* Create a temporary filename and put it in string pointed to by ! tmp_filename */ void __gnat_tmp_name (tmp_filename) --- 672,678 ---- } /* Create a temporary filename and put it in string pointed to by ! TMP_FILENAME. */ void __gnat_tmp_name (tmp_filename) *************** __gnat_tmp_name (tmp_filename) *** 694,701 **** pname = (char *) tempnam ("c:\\temp", "gnat-"); ! /* if pname start with a back slash and not path information it means that ! the filename is valid for the current working directory */ if (pname[0] == '\\') { --- 689,696 ---- pname = (char *) tempnam ("c:\\temp", "gnat-"); ! /* If pname start with a back slash and not path information it means that ! the filename is valid for the current working directory. */ if (pname[0] == '\\') { *************** __gnat_tmp_name (tmp_filename) *** 707,719 **** free (pname); } #elif defined (linux) char *tmpdir = getenv ("TMPDIR"); if (tmpdir == NULL) strcpy (tmp_filename, "/tmp/gnat-XXXXXX"); else ! sprintf (tmp_filename, "%200s/gnat-XXXXXX", tmpdir); close (mkstemp(tmp_filename)); #else --- 702,715 ---- free (pname); } + #elif defined (linux) char *tmpdir = getenv ("TMPDIR"); if (tmpdir == NULL) strcpy (tmp_filename, "/tmp/gnat-XXXXXX"); else ! sprintf (tmp_filename, "%.200s/gnat-XXXXXX", tmpdir); close (mkstemp(tmp_filename)); #else *************** win32_filetime (h) *** 779,785 **** FILETIME t_write; unsigned long long timestamp; ! /* Number of seconds between and */ unsigned long long offset = 11644473600; /* GetFileTime returns FILETIME data which are the number of 100 nanosecs --- 775,781 ---- FILETIME t_write; unsigned long long timestamp; ! /* Number of seconds between and . */ unsigned long long offset = 11644473600; /* GetFileTime returns FILETIME data which are the number of 100 nanosecs *************** __gnat_file_time_name (name) *** 821,827 **** (void) __gnat_stat (name, &statbuf); #ifdef VMS ! /* VMS has file versioning */ return statbuf.st_ctime; #else return statbuf.st_mtime; --- 817,823 ---- (void) __gnat_stat (name, &statbuf); #ifdef VMS ! /* VMS has file versioning. */ return statbuf.st_ctime; #else return statbuf.st_mtime; *************** __gnat_file_time_fd (fd) *** 839,845 **** DJGPP fstat attempts to convert time values to GMT rather than keep the actual OS timestamp of the file. By using the OS2/DOS functions directly the GNAT timestamp are independent of this behavior, which is desired to ! facilitate the distribution of GNAT compiled libraries. */ #if defined (__EMX__) || defined (MSDOS) #ifdef __EMX__ --- 835,841 ---- DJGPP fstat attempts to convert time values to GMT rather than keep the actual OS timestamp of the file. By using the OS2/DOS functions directly the GNAT timestamp are independent of this behavior, which is desired to ! facilitate the distribution of GNAT compiled libraries. */ #if defined (__EMX__) || defined (MSDOS) #ifdef __EMX__ *************** __gnat_file_time_fd (fd) *** 871,880 **** the whole days passed. The value for years returned by the DOS and OS2 functions count years from 1980, so to compensate for the UNIX epoch which begins in 1970 start with 10 years worth of days and add days for each ! four year period since then. */ time_t tot_secs; ! int cum_days [12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; int days_passed = 3652 + (file_year / 4) * 1461; int years_since_leap = file_year % 4; --- 867,876 ---- the whole days passed. The value for years returned by the DOS and OS2 functions count years from 1980, so to compensate for the UNIX epoch which begins in 1970 start with 10 years worth of days and add days for each ! four year period since then. */ time_t tot_secs; ! int cum_days[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; int days_passed = 3652 + (file_year / 4) * 1461; int years_since_leap = file_year % 4; *************** __gnat_file_time_fd (fd) *** 888,900 **** if (file_year > 20) days_passed -= 1; ! days_passed += cum_days [file_month - 1]; if (years_since_leap == 0 && file_year != 20 && file_month > 2) days_passed++; days_passed += file_day - 1; ! /* OK - have whole days. Multiply -- then add in other parts. */ tot_secs = days_passed * 86400; tot_secs += file_hour * 3600; --- 884,896 ---- if (file_year > 20) days_passed -= 1; ! days_passed += cum_days[file_month - 1]; if (years_since_leap == 0 && file_year != 20 && file_month > 2) days_passed++; days_passed += file_day - 1; ! /* OK - have whole days. Multiply -- then add in other parts. */ tot_secs = days_passed * 86400; tot_secs += file_hour * 3600; *************** __gnat_file_time_fd (fd) *** 905,911 **** #elif defined (_WIN32) HANDLE h = (HANDLE) _get_osfhandle (fd); time_t ret = win32_filetime (h); - CloseHandle (h); return ret; #else --- 901,906 ---- *************** __gnat_file_time_fd (fd) *** 914,920 **** (void) fstat (fd, &statbuf); #ifdef VMS ! /* VMS has file versioning */ return statbuf.st_ctime; #else return statbuf.st_mtime; --- 909,915 ---- (void) fstat (fd, &statbuf); #ifdef VMS ! /* VMS has file versioning. */ return statbuf.st_ctime; #else return statbuf.st_mtime; *************** __gnat_file_time_fd (fd) *** 922,928 **** #endif } ! /* Set the file time stamp */ void __gnat_set_file_time_name (name, time_stamp) --- 917,923 ---- #endif } ! /* Set the file time stamp. */ void __gnat_set_file_time_name (name, time_stamp) *************** __gnat_set_file_time_name (name, time_st *** 932,938 **** #if defined (__EMX__) || defined (MSDOS) || defined (_WIN32) \ || defined (__vxworks) ! /* Code to implement __gnat_set_file_time_name for these systems. */ #elif defined (VMS) struct FAB fab; --- 927,933 ---- #if defined (__EMX__) || defined (MSDOS) || defined (_WIN32) \ || defined (__vxworks) ! /* Code to implement __gnat_set_file_time_name for these systems. */ #elif defined (VMS) struct FAB fab; *************** __gnat_set_file_time_name (name, time_st *** 953,967 **** unsigned world : 4; } bits; } prot; ! } Fat = { 0 }; ! ATRDEF atrlst [] = { { ATR$S_CREDATE, ATR$C_CREDATE, &Fat.create }, { ATR$S_REVDATE, ATR$C_REVDATE, &Fat.revise }, { ATR$S_EXPDATE, ATR$C_EXPDATE, &Fat.expire }, { ATR$S_BAKDATE, ATR$C_BAKDATE, &Fat.backup }, ! n{ ATR$S_FPRO, ATR$C_FPRO, &Fat.prot }, { ATR$S_UIC, ATR$C_UIC, &Fat.uic }, { 0, 0, 0} }; --- 948,962 ---- unsigned world : 4; } bits; } prot; ! } Fat = { 0, 0, 0, 0, 0, { 0 }}; ! ATRDEF atrlst[] = { { ATR$S_CREDATE, ATR$C_CREDATE, &Fat.create }, { ATR$S_REVDATE, ATR$C_REVDATE, &Fat.revise }, { ATR$S_EXPDATE, ATR$C_EXPDATE, &Fat.expire }, { ATR$S_BAKDATE, ATR$C_BAKDATE, &Fat.backup }, ! { ATR$S_FPRO, ATR$C_FPRO, &Fat.prot }, { ATR$S_UIC, ATR$C_UIC, &Fat.uic }, { 0, 0, 0} }; *************** __gnat_set_file_time_name (name, time_st *** 991,997 **** tryfile = (char *) __gnat_to_host_dir_spec (name, 0); ! /* Allocate and initialize a fab and nam structures. */ fab = cc$rms_fab; nam = cc$rms_nam; --- 986,992 ---- tryfile = (char *) __gnat_to_host_dir_spec (name, 0); ! /* Allocate and initialize a FAB and NAM structures. */ fab = cc$rms_fab; nam = cc$rms_nam; *************** __gnat_set_file_time_name (name, time_st *** 1003,1024 **** fab.fab$b_fns = strlen (tryfile); fab.fab$l_nam = &nam; ! /*Validate filespec syntax and device existence. */ status = SYS$PARSE (&fab, 0, 0); if ((status & 1) != 1) LIB$SIGNAL (status); ! file.string [nam.nam$b_esl] = 0; ! /* Find matching filespec. */ status = SYS$SEARCH (&fab, 0, 0); if ((status & 1) != 1) LIB$SIGNAL (status); ! file.string [nam.nam$b_esl] = 0; ! result.string [result.length=nam.nam$b_rsl] = 0; ! /* Get the device name and assign an IO channel. */ strncpy (device.string, nam.nam$l_dev, nam.nam$b_dev); devicedsc.dsc$w_length = nam.nam$b_dev; chan = 0; --- 998,1019 ---- fab.fab$b_fns = strlen (tryfile); fab.fab$l_nam = &nam; ! /* Validate filespec syntax and device existence. */ status = SYS$PARSE (&fab, 0, 0); if ((status & 1) != 1) LIB$SIGNAL (status); ! file.string[nam.nam$b_esl] = 0; ! /* Find matching filespec. */ status = SYS$SEARCH (&fab, 0, 0); if ((status & 1) != 1) LIB$SIGNAL (status); ! file.string[nam.nam$b_esl] = 0; ! result.string[result.length=nam.nam$b_rsl] = 0; ! /* Get the device name and assign an IO channel. */ strncpy (device.string, nam.nam$l_dev, nam.nam$b_dev); devicedsc.dsc$w_length = nam.nam$b_dev; chan = 0; *************** __gnat_set_file_time_name (name, time_st *** 1026,1041 **** if ((status & 1) != 1) LIB$SIGNAL (status); ! /* Initialize the FIB and fill in the directory id field. */ ! bzero (&fib, sizeof (fib)); ! fib.fib$w_did [0] = nam.nam$w_did [0]; ! fib.fib$w_did [1] = nam.nam$w_did [1]; ! fib.fib$w_did [2] = nam.nam$w_did [2]; fib.fib$l_acctl = 0; fib.fib$l_wcc = 0; strcpy (file.string, (strrchr (result.string, ']') + 1)); filedsc.dsc$w_length = strlen (file.string); ! result.string [result.length = 0] = 0; /* Open and close the file to fill in the attributes. */ status --- 1021,1036 ---- if ((status & 1) != 1) LIB$SIGNAL (status); ! /* Initialize the FIB and fill in the directory id field. */ ! memset (&fib, 0, sizeof (fib)); ! fib.fib$w_did[0] = nam.nam$w_did[0]; ! fib.fib$w_did[1] = nam.nam$w_did[1]; ! fib.fib$w_did[2] = nam.nam$w_did[2]; fib.fib$l_acctl = 0; fib.fib$l_wcc = 0; strcpy (file.string, (strrchr (result.string, ']') + 1)); filedsc.dsc$w_length = strlen (file.string); ! result.string[result.length = 0] = 0; /* Open and close the file to fill in the attributes. */ status *************** __gnat_set_file_time_name (name, time_st *** 1046,1074 **** if ((iosb.status & 1) != 1) LIB$SIGNAL (iosb.status); ! result.string [result.length] = 0; ! status = SYS$QIOW (0, chan, IO$_DEACCESS, &iosb, 0, 0, ! &fibdsc, 0, 0, 0, &atrlst, 0); if ((status & 1) != 1) LIB$SIGNAL (status); if ((iosb.status & 1) != 1) LIB$SIGNAL (iosb.status); - /* Set creation time to requested time */ - unix_time_to_vms (time_stamp, newtime); - { time_t t; struct tm *ts; t = time ((time_t) 0); ts = localtime (&t); ! /* Set revision time to now in local time. */ unix_time_to_vms (t + ts->tm_gmtoff, revtime); } ! /* Reopen the file, modify the times and then close. */ fib.fib$l_acctl = FIB$M_WRITE; status = SYS$QIOW (0, chan, IO$_ACCESS|IO$M_ACCESS, &iosb, 0, 0, --- 1041,1071 ---- if ((iosb.status & 1) != 1) LIB$SIGNAL (iosb.status); ! result.string[result.length] = 0; ! status = SYS$QIOW (0, chan, IO$_DEACCESS, &iosb, 0, 0, &fibdsc, 0, 0, 0, ! &atrlst, 0); if ((status & 1) != 1) LIB$SIGNAL (status); if ((iosb.status & 1) != 1) LIB$SIGNAL (iosb.status); { time_t t; struct tm *ts; + ts = localtime (&time_stamp); + + /* Set creation time to requested time. */ + unix_time_to_vms (time_stamp + ts->tm_gmtoff, newtime); + t = time ((time_t) 0); ts = localtime (&t); ! /* Set revision time to now in local time. */ unix_time_to_vms (t + ts->tm_gmtoff, revtime); } ! /* Reopen the file, modify the times and then close. */ fib.fib$l_acctl = FIB$M_WRITE; status = SYS$QIOW (0, chan, IO$_ACCESS|IO$M_ACCESS, &iosb, 0, 0, *************** __gnat_set_file_time_name (name, time_st *** 1088,1094 **** if ((iosb.status & 1) != 1) LIB$SIGNAL (iosb.status); ! /* Deassign the channel and exit. */ status = SYS$DASSGN (chan); if ((status & 1) != 1) LIB$SIGNAL (status); --- 1085,1091 ---- if ((iosb.status & 1) != 1) LIB$SIGNAL (iosb.status); ! /* Deassign the channel and exit. */ status = SYS$DASSGN (chan); if ((status & 1) != 1) LIB$SIGNAL (status); *************** __gnat_set_file_time_name (name, time_st *** 1096,1105 **** struct utimbuf utimbuf; time_t t; ! /* Set modification time to requested time */ utimbuf.modtime = time_stamp; ! /* Set access time to now in local time */ t = time ((time_t) 0); utimbuf.actime = mktime (localtime (&t)); --- 1093,1102 ---- struct utimbuf utimbuf; time_t t; ! /* Set modification time to requested time. */ utimbuf.modtime = time_stamp; ! /* Set access time to now in local time. */ t = time ((time_t) 0); utimbuf.actime = mktime (localtime (&t)); *************** __gnat_get_env_value_ptr (name, len, val *** 1126,1132 **** #ifdef VMS ! static char *to_host_path_spec PROTO ((char *)); struct descriptor_s { --- 1123,1129 ---- #ifdef VMS ! static char *to_host_path_spec PARAMS ((char *)); struct descriptor_s { *************** __gnat_set_env_value (name, value) *** 1152,1158 **** #elif defined (VMS) struct descriptor_s name_desc; ! /* Put in JOB table for now, so that the project stuff at least works */ struct descriptor_s table_desc = {7, 0, "LNM$JOB"}; char *host_pathspec = to_host_path_spec (value); char *copy_pathspec; --- 1149,1155 ---- #elif defined (VMS) struct descriptor_s name_desc; ! /* Put in JOB table for now, so that the project stuff at least works. */ struct descriptor_s table_desc = {7, 0, "LNM$JOB"}; char *host_pathspec = to_host_path_spec (value); char *copy_pathspec; *************** __gnat_set_env_value (name, value) *** 1186,1207 **** next = strchr (curr, 0); *next = 0; ! ile_array [i].len = strlen (curr); ! /* Code 2 from lnmdef.h means its a string */ ! ile_array [i].code = 2; ! ile_array [i].adr = curr; ! /* retlen_adr is ignored */ ! ile_array [i].retlen_adr = 0; curr = next + 1; } ! /* Terminating item must be zero */ ! ile_array [i].len = 0; ! ile_array [i].code = 0; ! ile_array [i].adr = 0; ! ile_array [i].retlen_adr = 0; status = LIB$SET_LOGICAL (&name_desc, 0, &table_desc, 0, ile_array); if ((status & 1) != 1) --- 1183,1204 ---- next = strchr (curr, 0); *next = 0; ! ile_array[i].len = strlen (curr); ! /* Code 2 from lnmdef.h means its a string. */ ! ile_array[i].code = 2; ! ile_array[i].adr = curr; ! /* retlen_adr is ignored. */ ! ile_array[i].retlen_adr = 0; curr = next + 1; } ! /* Terminating item must be zero. */ ! ile_array[i].len = 0; ! ile_array[i].code = 0; ! ile_array[i].adr = 0; ! ile_array[i].retlen_adr = 0; status = LIB$SET_LOGICAL (&name_desc, 0, &table_desc, 0, ile_array); if ((status & 1) != 1) *************** __gnat_stat (name, statbuf) *** 1291,1309 **** /* Under Windows the directory name for the stat function must not be terminated by a directory separator except if just after a drive name. */ int name_len = strlen (name); ! char last_char = name [name_len - 1]; ! char win32_name [4096]; strcpy (win32_name, name); while (name_len > 1 && (last_char == '\\' || last_char == '/')) { ! win32_name [name_len - 1] = '\0'; name_len--; last_char = win32_name[name_len - 1]; } ! if (name_len == 2 && win32_name [1] == ':') strcat (win32_name, "\\"); return stat (win32_name, statbuf); --- 1288,1306 ---- /* Under Windows the directory name for the stat function must not be terminated by a directory separator except if just after a drive name. */ int name_len = strlen (name); ! char last_char = name[name_len - 1]; ! char win32_name[4096]; strcpy (win32_name, name); while (name_len > 1 && (last_char == '\\' || last_char == '/')) { ! win32_name[name_len - 1] = '\0'; name_len--; last_char = win32_name[name_len - 1]; } ! if (name_len == 2 && win32_name[1] == ':') strcat (win32_name, "\\"); return stat (win32_name, statbuf); *************** __gnat_is_absolute_path (name) *** 1327,1334 **** char *name; { return (*name == '/' || *name == DIR_SEPARATOR ! #if defined(__EMX__) || defined(MSDOS) || defined(WINNT) ! || strlen (name) > 1 && isalpha (name [0]) && name [1] == ':' #endif ); } --- 1324,1331 ---- char *name; { return (*name == '/' || *name == DIR_SEPARATOR ! #if defined (__EMX__) || defined (MSDOS) || defined (WINNT) ! || strlen (name) > 1 && isalpha (name[0]) && name[1] == ':' #endif ); } *************** __gnat_is_writable_file (name) *** 1369,1375 **** } #ifdef VMS ! /* Defined in VMS header files */ #define fork() (decc$$alloc_vfork_blocks() >= 0 ? \ LIB$GET_CURRENT_INVO_CONTEXT (decc$$get_vfork_jmpbuf()) : -1) #endif --- 1366,1372 ---- } #ifdef VMS ! /* Defined in VMS header files. */ #define fork() (decc$$alloc_vfork_blocks() >= 0 ? \ LIB$GET_CURRENT_INVO_CONTEXT (decc$$get_vfork_jmpbuf()) : -1) #endif *************** __gnat_portable_spawn (args) *** 1390,1436 **** int pid; #if defined (MSDOS) || defined (_WIN32) ! status = spawnvp (P_WAIT, args [0], args); if (status < 0) ! return 4; else return status; ! #elif defined(__vxworks) /* Mods for VxWorks */ ! pid = sp (args[0], args); /* Spawn process and save pid */ ! if (pid == -1) ! return (4); ! ! while (taskIdVerify(pid) >= 0) ! /* Wait until spawned task is complete then continue. */ ! ; #else #ifdef __EMX__ ! pid = spawnvp (P_NOWAIT, args [0], args); if (pid == -1) ! return (4); #else pid = fork (); ! if (pid == -1) ! return (4); ! if (pid == 0 && execv (args [0], args) != 0) ! _exit (1); #endif ! /* The parent */ finished = waitpid (pid, &status, 0); if (finished != pid || WIFEXITED (status) == 0) ! return 4; return WEXITSTATUS (status); #endif return 0; } ! /* WIN32 code to implement a wait call that wait for any child process */ #ifdef _WIN32 /* Synchronization code, to be thread safe. */ --- 1387,1438 ---- int pid; #if defined (MSDOS) || defined (_WIN32) ! status = spawnvp (P_WAIT, args[0], args); if (status < 0) ! return -1; else return status; ! #elif defined (__vxworks) ! return -1; #else #ifdef __EMX__ ! pid = spawnvp (P_NOWAIT, args[0], args); if (pid == -1) ! return -1; ! #else pid = fork (); ! if (pid < 0) ! return -1; ! if (pid == 0) ! { ! /* The child. */ ! if (execv (args[0], args) != 0) ! #if defined (VMS) ! return -1; /* execv is in parent context on VMS. */ ! #else ! _exit (1); ! #endif ! } #endif ! /* The parent. */ finished = waitpid (pid, &status, 0); if (finished != pid || WIFEXITED (status) == 0) ! return -1; return WEXITSTATUS (status); #endif + return 0; } ! /* WIN32 code to implement a wait call that wait for any child process. */ ! #ifdef _WIN32 /* Synchronization code, to be thread safe. */ *************** plist_enter () *** 1449,1455 **** EnterCriticalSection (&plist_cs); } ! void plist_leave () { LeaveCriticalSection (&plist_cs); --- 1451,1457 ---- EnterCriticalSection (&plist_cs); } ! static void plist_leave () { LeaveCriticalSection (&plist_cs); *************** win32_no_block_spawn (command, args) *** 1527,1536 **** STARTUPINFO SI; PROCESS_INFORMATION PI; SECURITY_ATTRIBUTES SA; ! ! char full_command [2000]; int k; /* Startup info. */ SI.cb = sizeof (STARTUPINFO); SI.lpReserved = NULL; --- 1529,1548 ---- STARTUPINFO SI; PROCESS_INFORMATION PI; SECURITY_ATTRIBUTES SA; ! int csize = 1; ! char *full_command; int k; + /* compute the total command line length */ + k = 0; + while (args[k]) + { + csize += strlen (args[k]) + 1; + k++; + } + + full_command = (char *) xmalloc (csize); + /* Startup info. */ SI.cb = sizeof (STARTUPINFO); SI.lpReserved = NULL; *************** win32_no_block_spawn (command, args) *** 1561,1566 **** --- 1573,1580 ---- result = CreateProcess (NULL, (char *) full_command, &SA, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &SI, &PI); + free (full_command); + if (result == TRUE) { add_handle (PI.hProcess); *************** win32_wait (status) *** 1605,1611 **** plist_leave(); res = WaitForMultipleObjects (plist_length, hl, FALSE, INFINITE); ! h = hl [res - WAIT_OBJECT_0]; free (hl); remove_handle (h); --- 1619,1625 ---- plist_leave(); res = WaitForMultipleObjects (plist_length, hl, FALSE, INFINITE); ! h = hl[res - WAIT_OBJECT_0]; free (hl); remove_handle (h); *************** __gnat_portable_no_block_spawn (args) *** 1635,1641 **** portable_wait below systematically returns a pid of 0 and reports that the subprocess terminated successfully. */ ! if (spawnvp (P_WAIT, args [0], args) != 0) return -1; #elif defined (_WIN32) --- 1649,1655 ---- portable_wait below systematically returns a pid of 0 and reports that the subprocess terminated successfully. */ ! if (spawnvp (P_WAIT, args[0], args) != 0) return -1; #elif defined (_WIN32) *************** __gnat_portable_no_block_spawn (args) *** 1643,1660 **** pid = win32_no_block_spawn (args[0], args); return pid; ! #elif defined (__vxworks) /* Mods for VxWorks */ ! pid = sp (args[0], args); /* Spawn task and then return (no waiting) */ ! if (pid == -1) ! return (4); ! ! return pid; #else pid = fork (); ! if (pid == 0 && execv (args [0], args) != 0) ! _exit (1); #endif return pid; --- 1657,1679 ---- pid = win32_no_block_spawn (args[0], args); return pid; ! #elif defined (__vxworks) ! return -1; #else pid = fork (); ! if (pid == 0) ! { ! /* The child. */ ! if (execv (args[0], args) != 0) ! #if defined (VMS) ! return -1; /* execv is in parent context on VMS. */ ! #else ! _exit (1); ! #endif ! } ! #endif return pid; *************** __gnat_portable_wait (process_status) *** 1672,1690 **** pid = win32_wait (&status); #elif defined (__EMX__) || defined (MSDOS) ! /* ??? See corresponding comment in portable_no_block_spawn. */ #elif defined (__vxworks) /* Not sure what to do here, so do same as __EMX__ case, i.e., nothing but ! return zero. */ #else - #ifdef VMS - /* Wait doesn't do the right thing on VMS */ pid = waitpid (-1, &status, 0); - #else - pid = wait (&status); - #endif status = status & 0xffff; #endif --- 1691,1704 ---- pid = win32_wait (&status); #elif defined (__EMX__) || defined (MSDOS) ! /* ??? See corresponding comment in portable_no_block_spawn. */ #elif defined (__vxworks) /* Not sure what to do here, so do same as __EMX__ case, i.e., nothing but ! return zero. */ #else pid = waitpid (-1, &status, 0); status = status & 0xffff; #endif *************** __gnat_portable_wait (process_status) *** 1692,1710 **** return pid; } void __gnat_os_exit (status) int status; { #ifdef VMS ! /* Exit without changing 0 to 1 */ __posix_exit (status); #else exit (status); #endif } ! /* Locate a regular file, give a Path value */ char * __gnat_locate_regular_file (file_name, path_val) --- 1706,1742 ---- return pid; } + int + __gnat_waitpid (pid) + int pid; + { + int status = 0; + + #if defined (_WIN32) + cwait (&status, pid, _WAIT_CHILD); + #elif defined (__EMX__) || defined (MSDOS) || defined (__vxworks) + /* Status is already zero, so nothing to do. */ + #else + waitpid (pid, &status, 0); + status = WEXITSTATUS (status); + #endif + + return status; + } + void __gnat_os_exit (status) int status; { #ifdef VMS ! /* Exit without changing 0 to 1. */ __posix_exit (status); #else exit (status); #endif } ! /* Locate a regular file, give a Path value. */ char * __gnat_locate_regular_file (file_name, path_val) *************** __gnat_locate_regular_file (file_name, p *** 1713,1725 **** { char *ptr; ! /* Handle absolute pathnames. */ for (ptr = file_name; *ptr && *ptr != '/' && *ptr != DIR_SEPARATOR; ptr++) ; if (*ptr != 0 ! #if defined(__EMX__) || defined(MSDOS) || defined(WINNT) ! || isalpha (file_name [0]) && file_name [1] == ':' #endif ) { --- 1745,1757 ---- { char *ptr; ! /* Handle absolute pathnames. */ for (ptr = file_name; *ptr && *ptr != '/' && *ptr != DIR_SEPARATOR; ptr++) ; if (*ptr != 0 ! #if defined (__EMX__) || defined (MSDOS) || defined (WINNT) ! || isalpha (file_name[0]) && file_name[1] == ':' #endif ) { *************** __gnat_locate_regular_file (file_name, p *** 1761,1770 **** return 0; } - /* Locate an executable given a Path argument. This routine is only used by gnatbl and should not be used otherwise. Use locate_exec_on_path ! instead. */ char * __gnat_locate_exec (exec_name, path_val) --- 1793,1801 ---- return 0; } /* Locate an executable given a Path argument. This routine is only used by gnatbl and should not be used otherwise. Use locate_exec_on_path ! instead. */ char * __gnat_locate_exec (exec_name, path_val) *************** __gnat_locate_exec (exec_name, path_val) *** 1784,1790 **** return __gnat_locate_regular_file (exec_name, path_val); } ! /* Locate an executable using the Systems default PATH */ char * __gnat_locate_exec_on_path (exec_name) --- 1815,1821 ---- return __gnat_locate_regular_file (exec_name, path_val); } ! /* Locate an executable using the Systems default PATH. */ char * __gnat_locate_exec_on_path (exec_name) *************** __gnat_locate_exec_on_path (exec_name) *** 1804,1848 **** #ifdef VMS /* These functions are used to translate to and from VMS and Unix syntax ! file, directory and path specifications. */ #define MAXNAMES 256 #define NEW_CANONICAL_FILELIST_INCREMENT 64 ! static char new_canonical_dirspec [255]; ! static char new_canonical_filespec [255]; ! static char new_canonical_pathspec [MAXNAMES*255]; static unsigned new_canonical_filelist_index; static unsigned new_canonical_filelist_in_use; static unsigned new_canonical_filelist_allocated; static char **new_canonical_filelist; ! static char new_host_pathspec [MAXNAMES*255]; ! static char new_host_dirspec [255]; ! static char new_host_filespec [255]; /* Routine is called repeatedly by decc$from_vms via ! __gnat_to_canonical_file_list_init until it returns 0 or the expansion ! runs out. */ static int wildcard_translate_unix (name) char *name; { char *ver; ! char buff [256]; strcpy (buff, name); ver = strrchr (buff, '.'); ! /* Chop off the version */ if (ver) *ver = 0; ! /* Dynamically extend the allocation by the increment */ if (new_canonical_filelist_in_use == new_canonical_filelist_allocated) { new_canonical_filelist_allocated += NEW_CANONICAL_FILELIST_INCREMENT; ! new_canonical_filelist = (char **) realloc (new_canonical_filelist, new_canonical_filelist_allocated * sizeof (char *)); } --- 1835,1879 ---- #ifdef VMS /* These functions are used to translate to and from VMS and Unix syntax ! file, directory and path specifications. */ #define MAXNAMES 256 #define NEW_CANONICAL_FILELIST_INCREMENT 64 ! static char new_canonical_dirspec[255]; ! static char new_canonical_filespec[255]; ! static char new_canonical_pathspec[MAXNAMES*255]; static unsigned new_canonical_filelist_index; static unsigned new_canonical_filelist_in_use; static unsigned new_canonical_filelist_allocated; static char **new_canonical_filelist; ! static char new_host_pathspec[MAXNAMES*255]; ! static char new_host_dirspec[255]; ! static char new_host_filespec[255]; /* Routine is called repeatedly by decc$from_vms via ! __gnat_to_canonical_file_list_init until it returns 0 or the expansion runs ! out. */ static int wildcard_translate_unix (name) char *name; { char *ver; ! char buff[256]; strcpy (buff, name); ver = strrchr (buff, '.'); ! /* Chop off the version. */ if (ver) *ver = 0; ! /* Dynamically extend the allocation by the increment. */ if (new_canonical_filelist_in_use == new_canonical_filelist_allocated) { new_canonical_filelist_allocated += NEW_CANONICAL_FILELIST_INCREMENT; ! new_canonical_filelist = (char **) xrealloc (new_canonical_filelist, new_canonical_filelist_allocated * sizeof (char *)); } *************** wildcard_translate_unix (name) *** 1852,1861 **** return 1; } ! /* Translate a wildcard VMS file spec into a list of Unix file ! specs. First do full translation and copy the results into a list (_init), ! then return them one at a time (_next). If onlydirs set, only expand ! directory files. */ int __gnat_to_canonical_file_list_init (filespec, onlydirs) --- 1883,1891 ---- return 1; } ! /* Translate a wildcard VMS file spec into a list of Unix file specs. First do ! full translation and copy the results into a list (_init), then return them ! one at a time (_next). If onlydirs set, only expand directory files. */ int __gnat_to_canonical_file_list_init (filespec, onlydirs) *************** __gnat_to_canonical_file_list_init (file *** 1863,1880 **** int onlydirs; { int len; ! char buff [256]; len = strlen (filespec); strcpy (buff, filespec); ! /* Only look for directories */ ! if (onlydirs && !strstr (&buff [len-5], "*.dir")) strcat (buff, "*.dir"); decc$from_vms (buff, wildcard_translate_unix, 1); ! /* Remove the .dir extension */ if (onlydirs) { int i; --- 1893,1910 ---- int onlydirs; { int len; ! char buff[256]; len = strlen (filespec); strcpy (buff, filespec); ! /* Only look for directories. */ ! if (onlydirs && !strstr (&buff[len - 5], "*.dir")) strcat (buff, "*.dir"); decc$from_vms (buff, wildcard_translate_unix, 1); ! /* Remove the .dir extension. */ if (onlydirs) { int i; *************** __gnat_to_canonical_file_list_init (file *** 1882,1888 **** for (i = 0; i < new_canonical_filelist_in_use; i++) { ! ext = strstr (new_canonical_filelist [i], ".dir"); if (ext) *ext = 0; } --- 1912,1918 ---- for (i = 0; i < new_canonical_filelist_in_use; i++) { ! ext = strstr (new_canonical_filelist[i], ".dir"); if (ext) *ext = 0; } *************** __gnat_to_canonical_file_list_init (file *** 1891,1905 **** return new_canonical_filelist_in_use; } ! /* Return the next filespec in the list */ char * __gnat_to_canonical_file_list_next () { ! return new_canonical_filelist [new_canonical_filelist_index++]; } ! /* Free up storage used in the wildcard expansion */ void __gnat_to_canonical_file_list_free () --- 1921,1935 ---- return new_canonical_filelist_in_use; } ! /* Return the next filespec in the list. */ char * __gnat_to_canonical_file_list_next () { ! return new_canonical_filelist[new_canonical_filelist_index++]; } ! /* Free storage used in the wildcard expansion. */ void __gnat_to_canonical_file_list_free () *************** __gnat_to_canonical_file_list_free () *** 1907,1913 **** int i; for (i = 0; i < new_canonical_filelist_in_use; i++) ! free (new_canonical_filelist [i]); free (new_canonical_filelist); --- 1937,1943 ---- int i; for (i = 0; i < new_canonical_filelist_in_use; i++) ! free (new_canonical_filelist[i]); free (new_canonical_filelist); *************** __gnat_to_canonical_file_list_free () *** 1917,1929 **** new_canonical_filelist = 0; } ! /* Translate a VMS syntax directory specification in to Unix syntax. ! If prefixflag is set, append an underscore "/". If no indicators ! of VMS syntax found, return input string. Also translate a dirname ! that contains no slashes, in case it's a logical name. */ char * ! __gnat_to_canonical_dir_spec (dirspec,prefixflag) char *dirspec; int prefixflag; { --- 1947,1959 ---- new_canonical_filelist = 0; } ! /* Translate a VMS syntax directory specification in to Unix syntax. If ! PREFIXFLAG is set, append an underscore "/". If no indicators of VMS syntax ! found, return input string. Also translate a dirname that contains no ! slashes, in case it's a logical name. */ char * ! __gnat_to_canonical_dir_spec (dirspec, prefixflag) char *dirspec; int prefixflag; { *************** __gnat_to_canonical_dir_spec (dirspec,pr *** 1943,1949 **** } len = strlen (new_canonical_dirspec); ! if (prefixflag && new_canonical_dirspec [len-1] != '/') strcat (new_canonical_dirspec, "/"); return new_canonical_dirspec; --- 1973,1979 ---- } len = strlen (new_canonical_dirspec); ! if (prefixflag && new_canonical_dirspec[len - 1] != '/') strcat (new_canonical_dirspec, "/"); return new_canonical_dirspec; *************** __gnat_to_canonical_dir_spec (dirspec,pr *** 1951,1957 **** } /* Translate a VMS syntax file specification into Unix syntax. ! If no indicators of VMS syntax found, return input string. */ char * __gnat_to_canonical_file_spec (filespec) --- 1981,1987 ---- } /* Translate a VMS syntax file specification into Unix syntax. ! If no indicators of VMS syntax found, return input string. */ char * __gnat_to_canonical_file_spec (filespec) *************** __gnat_to_canonical_file_spec (filespec) *** 1967,1988 **** } /* Translate a VMS syntax path specification into Unix syntax. ! If no indicators of VMS syntax found, return input string. */ char * __gnat_to_canonical_path_spec (pathspec) char *pathspec; { ! char *curr, *next, buff [256]; if (pathspec == 0) return pathspec; ! /* If there are /'s, assume it's a Unix path spec and return */ if (strchr (pathspec, '/')) return pathspec; ! new_canonical_pathspec [0] = 0; curr = pathspec; for (;;) --- 1997,2018 ---- } /* Translate a VMS syntax path specification into Unix syntax. ! If no indicators of VMS syntax found, return input string. */ char * __gnat_to_canonical_path_spec (pathspec) char *pathspec; { ! char *curr, *next, buff[256]; if (pathspec == 0) return pathspec; ! /* If there are /'s, assume it's a Unix path spec and return. */ if (strchr (pathspec, '/')) return pathspec; ! new_canonical_pathspec[0] = 0; curr = pathspec; for (;;) *************** __gnat_to_canonical_path_spec (pathspec) *** 1992,2000 **** next = strchr (curr, 0); strncpy (buff, curr, next - curr); ! buff [next - curr] = 0; ! /* Check for wildcards and expand if present */ if (strchr (buff, '*') || strchr (buff, '%') || strstr (buff, "...")) { int i, dirs; --- 2022,2030 ---- next = strchr (curr, 0); strncpy (buff, curr, next - curr); ! buff[next - curr] = 0; ! /* Check for wildcards and expand if present. */ if (strchr (buff, '*') || strchr (buff, '%') || strstr (buff, "...")) { int i, dirs; *************** __gnat_to_canonical_path_spec (pathspec) *** 2007,2013 **** next_dir = __gnat_to_canonical_file_list_next (); strcat (new_canonical_pathspec, next_dir); ! /* Don't append the separator after the last expansion */ if (i+1 < dirs) strcat (new_canonical_pathspec, ":"); } --- 2037,2043 ---- next_dir = __gnat_to_canonical_file_list_next (); strcat (new_canonical_pathspec, next_dir); ! /* Don't append the separator after the last expansion. */ if (i+1 < dirs) strcat (new_canonical_pathspec, ":"); } *************** __gnat_to_canonical_path_spec (pathspec) *** 2028,2034 **** return new_canonical_pathspec; } ! static char filename_buff [256]; static int translate_unix (name, type) --- 2058,2064 ---- return new_canonical_pathspec; } ! static char filename_buff[256]; static int translate_unix (name, type) *************** translate_unix (name, type) *** 2039,2061 **** return 0; } ! /* Translate a Unix syntax path spec into a VMS style (comma separated ! list of directories. Only used in this file so make it static */ static char * to_host_path_spec (pathspec) char *pathspec; { ! char *curr, *next, buff [256]; if (pathspec == 0) return pathspec; ! /* Can't very well test for colons, since that's the Unix separator! */ if (strchr (pathspec, ']') || strchr (pathspec, ',')) return pathspec; ! new_host_pathspec [0] = 0; curr = pathspec; for (;;) --- 2069,2091 ---- return 0; } ! /* Translate a Unix syntax path spec into a VMS style (comma separated list of ! directories. */ static char * to_host_path_spec (pathspec) char *pathspec; { ! char *curr, *next, buff[256]; if (pathspec == 0) return pathspec; ! /* Can't very well test for colons, since that's the Unix separator! */ if (strchr (pathspec, ']') || strchr (pathspec, ',')) return pathspec; ! new_host_pathspec[0] = 0; curr = pathspec; for (;;) *************** to_host_path_spec (pathspec) *** 2065,2071 **** next = strchr (curr, 0); strncpy (buff, curr, next - curr); ! buff [next - curr] = 0; strcat (new_host_pathspec, __gnat_to_host_dir_spec (buff, 0)); if (*next == 0) --- 2095,2101 ---- next = strchr (curr, 0); strncpy (buff, curr, next - curr); ! buff[next - curr] = 0; strcat (new_host_pathspec, __gnat_to_host_dir_spec (buff, 0)); if (*next == 0) *************** to_host_path_spec (pathspec) *** 2077,2091 **** return new_host_pathspec; } ! /* Translate a Unix syntax directory specification into VMS syntax. ! The prefixflag has no effect, but is kept for symmetry with ! to_canonical_dir_spec. ! If indicators of VMS syntax found, return input string. */ char * __gnat_to_host_dir_spec (dirspec, prefixflag) char *dirspec; ! int prefixflag; { int len = strlen (dirspec); --- 2107,2121 ---- return new_host_pathspec; } ! /* Translate a Unix syntax directory specification into VMS syntax. The ! PREFIXFLAG has no effect, but is kept for symmetry with ! to_canonical_dir_spec. If indicators of VMS syntax found, return input ! string. */ char * __gnat_to_host_dir_spec (dirspec, prefixflag) char *dirspec; ! int prefixflag ATTRIBUTE_UNUSED; { int len = strlen (dirspec); *************** __gnat_to_host_dir_spec (dirspec, prefix *** 2094,2102 **** if (strchr (new_host_dirspec, ']') || strchr (new_host_dirspec, ':')) return new_host_dirspec; ! while (len > 1 && new_host_dirspec [len-1] == '/') { ! new_host_dirspec [len-1] = 0; len--; } --- 2124,2132 ---- if (strchr (new_host_dirspec, ']') || strchr (new_host_dirspec, ':')) return new_host_dirspec; ! while (len > 1 && new_host_dirspec[len - 1] == '/') { ! new_host_dirspec[len - 1] = 0; len--; } *************** __gnat_to_host_dir_spec (dirspec, prefix *** 2108,2114 **** } /* Translate a Unix syntax file specification into VMS syntax. ! If indicators of VMS syntax found, return input string. */ char * __gnat_to_host_file_spec (filespec) --- 2138,2144 ---- } /* Translate a Unix syntax file specification into VMS syntax. ! If indicators of VMS syntax found, return input string. */ char * __gnat_to_host_file_spec (filespec) *************** __gnat_adjust_os_resource_limits () *** 2134,2140 **** #else ! /* Dummy functions for Osint import for non-VMS systems */ int __gnat_to_canonical_file_list_init (dirspec, onlydirs) --- 2164,2170 ---- #else ! /* Dummy functions for Osint import for non-VMS systems. */ int __gnat_to_canonical_file_list_init (dirspec, onlydirs) *************** __gnat_adjust_os_resource_limits () *** 2199,2207 **** #endif ! /* for EMX, we cannot include dummy in libgcc, since it is too difficult to coordinate this with the EMX distribution. Consequently, we put the ! definition of dummy() which is used for exception handling, here */ #if defined (__EMX__) void __dummy () {} --- 2229,2237 ---- #endif ! /* For EMX, we cannot include dummy in libgcc, since it is too difficult to coordinate this with the EMX distribution. Consequently, we put the ! definition of dummy which is used for exception handling, here. */ #if defined (__EMX__) void __dummy () {} *************** int _flush_cache() *** 2217,2229 **** #if defined (CROSS_COMPILE) \ || (! (defined (sparc) && defined (sun) && defined (__SVR4)) \ && ! defined (linux) \ - && ! defined (sgi) \ && ! defined (hpux) \ && ! (defined (__alpha__) && defined (__osf__)) \ && ! defined (__MINGW32__)) ! /* Dummy function to satisfy g-trasym.o. ! Currently Solaris sparc, HP/UX, IRIX, GNU/Linux, Tru64 & Windows provide a ! non-dummy version of this procedure in libaddr2line.a */ void convert_addresses (addrs, n_addr, buf, len) --- 2247,2259 ---- #if defined (CROSS_COMPILE) \ || (! (defined (sparc) && defined (sun) && defined (__SVR4)) \ && ! defined (linux) \ && ! defined (hpux) \ && ! (defined (__alpha__) && defined (__osf__)) \ && ! defined (__MINGW32__)) ! ! /* Dummy function to satisfy g-trasym.o. Currently Solaris sparc, HP/UX, ! GNU/Linux, Tru64 & Windows provide a non-dummy version of this procedure in ! libaddr2line.a. */ void convert_addresses (addrs, n_addr, buf, len) *************** convert_addresses (addrs, n_addr, buf, l *** 2235,2237 **** --- 2265,2273 ---- *len = 0; } #endif + + #if defined (_WIN32) + int __gnat_argument_needs_quote = 1; + #else + int __gnat_argument_needs_quote = 0; + #endif diff -Nrc3pad gcc-3.2.3/gcc/ada/adaint.h gcc-3.3/gcc/ada/adaint.h *** gcc-3.2.3/gcc/ada/adaint.h 2003-01-29 17:34:09.000000000 +0000 --- gcc-3.3/gcc/ada/adaint.h 2003-01-29 17:40:47.000000000 +0000 *************** *** 4,14 **** * * * A D A I N T * * * - * $Revision: 1.5.2.1.4.1 $ * * * C Header File * * * ! * Copyright (C) 1992-2001 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- * --- 4,13 ---- * * * A D A I N T * * * * * * C Header File * * * ! * Copyright (C) 1992-2002 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- * *************** *** 38,49 **** #include extern void __gnat_to_gm_time PARAMS ((int *, int *, int *, int *, int *, int *, int *)); extern int __gnat_get_maximum_file_name_length PARAMS ((void)); - extern char __gnat_get_switch_character PARAMS ((void)); extern int __gnat_get_switches_case_sensitive PARAMS ((void)); extern int __gnat_get_file_names_case_sensitive PARAMS ((void)); extern char __gnat_get_default_identifier_character_set PARAMS ((void)); --- 37,48 ---- #include + extern int __gnat_max_path_len; extern void __gnat_to_gm_time PARAMS ((int *, int *, int *, int *, int *, int *, int *)); extern int __gnat_get_maximum_file_name_length PARAMS ((void)); extern int __gnat_get_switches_case_sensitive PARAMS ((void)); extern int __gnat_get_file_names_case_sensitive PARAMS ((void)); extern char __gnat_get_default_identifier_character_set PARAMS ((void)); *************** extern int __gnat_is_writable_file *** 84,89 **** --- 83,89 ---- extern int __gnat_portable_spawn PARAMS ((char *[])); extern int __gnat_portable_no_block_spawn PARAMS ((char *[])); extern int __gnat_portable_wait PARAMS ((int *)); + extern int __gnat_waitpid PARAMS ((int)); extern char *__gnat_locate_exec PARAMS ((char *, char *)); extern char *__gnat_locate_exec_on_path PARAMS ((char *)); extern char *__gnat_locate_regular_file PARAMS ((char *, char *)); diff -Nrc3pad gcc-3.2.3/gcc/ada/ada-tree.def gcc-3.3/gcc/ada/ada-tree.def *** gcc-3.2.3/gcc/ada/ada-tree.def 2002-05-04 03:27:31.000000000 +0000 --- gcc-3.3/gcc/ada/ada-tree.def 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * Specification * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- *************** *** 35,52 **** DEFTREECODE (TRANSFORM_EXPR, "transform_expr", 'e', 0) - /* Perform an unchecked conversion between the input and the output. - if TREE_ADDRESSABLE is set, it means this is in an LHS; in that case, - we can only use techniques, such as pointer punning, that leave the - expression a "name". */ - - DEFTREECODE (UNCHECKED_CONVERT_EXPR, "unchecked_convert_expr", '1', 1) - /* Dynamically allocate on the stack a number of bytes of memory given by operand 0 at the alignment given by operand 1 and return the address of the resulting memory. */ ! DEFTREECODE (ALLOCATE_EXPR, "allocate_expr", '2', 2) /* A type that is an unconstrained array itself. This node is never passed to GCC. TREE_TYPE is the type of the fat pointer and TYPE_OBJECT_RECORD_TYPE --- 34,44 ---- DEFTREECODE (TRANSFORM_EXPR, "transform_expr", 'e', 0) /* Dynamically allocate on the stack a number of bytes of memory given by operand 0 at the alignment given by operand 1 and return the address of the resulting memory. */ ! DEFTREECODE (ALLOCATE_EXPR, "allocate_expr", 's', 2) /* A type that is an unconstrained array itself. This node is never passed to GCC. TREE_TYPE is the type of the fat pointer and TYPE_OBJECT_RECORD_TYPE diff -Nrc3pad gcc-3.2.3/gcc/ada/ada-tree.h gcc-3.3/gcc/ada/ada-tree.h *** gcc-3.2.3/gcc/ada/ada-tree.h 2002-05-04 03:27:31.000000000 +0000 --- gcc-3.3/gcc/ada/ada-tree.h 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- *************** enum gnat_tree_code { *** 35,40 **** --- 34,68 ---- }; #undef DEFTREECODE + /* A tree to hold a loop ID. */ + struct tree_loop_id GTY(()) + { + struct tree_common common; + struct nesting *loop_id; + }; + + /* The language-specific tree. */ + union lang_tree_node + GTY((desc ("TREE_CODE (&%h.generic) == GNAT_LOOP_ID"))) + { + union tree_node GTY ((tag ("0"), + desc ("tree_node_structure (&%h)"))) + generic; + struct tree_loop_id GTY ((tag ("1"))) loop_id; + }; + + /* Ada uses the lang_decl and lang_type fields to hold more trees. */ + struct lang_decl GTY(()) + { + union lang_tree_node + GTY((desc ("TREE_CODE (&%h.generic) == GNAT_LOOP_ID"))) t; + }; + struct lang_type GTY(()) + { + union lang_tree_node + GTY((desc ("TREE_CODE (&%h.generic) == GNAT_LOOP_ID"))) t; + }; + /* Flags added to GCC type nodes. */ /* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this is a *************** enum gnat_tree_code { *** 115,131 **** || TREE_CODE (NODE) == UNION_TYPE || TREE_CODE (NODE) == ENUMERAL_TYPE) \ && TYPE_DUMMY_P (NODE)) - /* Nonzero if this corresponds to a type where alignment is guaranteed - by other mechanisms (a tagged or packed type). */ - #define TYPE_ALIGN_OK_P(NODE) TYPE_LANG_FLAG_5 (NODE) - /* For an INTEGER_TYPE, nonzero if TYPE_ACTUAL_BOUNDS is present. */ #define TYPE_HAS_ACTUAL_BOUNDS_P(NODE) \ ! TYPE_LANG_FLAG_6 (INTEGER_TYPE_CHECK (NODE)) /* For a RECORD_TYPE, nonzero if this was made just to supply needed padding or alignment. */ ! #define TYPE_IS_PADDING_P(NODE) TYPE_LANG_FLAG_6 (RECORD_TYPE_CHECK (NODE)) /* This field is only defined for FUNCTION_TYPE nodes. If the Ada subprogram contains no parameters passed by copy in/copy out then this --- 143,155 ---- || TREE_CODE (NODE) == UNION_TYPE || TREE_CODE (NODE) == ENUMERAL_TYPE) \ && TYPE_DUMMY_P (NODE)) /* For an INTEGER_TYPE, nonzero if TYPE_ACTUAL_BOUNDS is present. */ #define TYPE_HAS_ACTUAL_BOUNDS_P(NODE) \ ! TYPE_LANG_FLAG_5 (INTEGER_TYPE_CHECK (NODE)) /* For a RECORD_TYPE, nonzero if this was made just to supply needed padding or alignment. */ ! #define TYPE_IS_PADDING_P(NODE) TYPE_LANG_FLAG_5 (RECORD_TYPE_CHECK (NODE)) /* This field is only defined for FUNCTION_TYPE nodes. If the Ada subprogram contains no parameters passed by copy in/copy out then this *************** enum gnat_tree_code { *** 134,162 **** by copy in copy out. It is a CONSTRUCTOR. For a full description of the cico parameter passing mechanism refer to the routine gnat_to_gnu_entity. */ #define TYPE_CI_CO_LIST(NODE) \ ! (tree) TYPE_LANG_SPECIFIC (FUNCTION_TYPE_CHECK (NODE)) /* For an INTEGER_TYPE with TYPE_MODULAR_P, this is the value of the modulus. */ #define TYPE_MODULUS(NODE) \ ! (tree) TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) /* For an INTEGER_TYPE that is the TYPE_DOMAIN of some ARRAY_TYPE, points to the type corresponding to the Ada index type. */ #define TYPE_INDEX_TYPE(NODE) \ ! (tree) TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) /* For an INTEGER_TYPE with TYPE_VAX_FLOATING_POINT_P, stores the Digits_Value. */ #define TYPE_DIGITS_VALUE(NODE) \ ! (long) TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) /* For INTEGER_TYPE, stores the RM_Size of the type. */ #define TYPE_RM_SIZE_INT(NODE) TYPE_VALUES (INTEGER_TYPE_CHECK (NODE)) /* Likewise for ENUMERAL_TYPE. */ #define TYPE_RM_SIZE_ENUM(NODE) \ ! (tree) TYPE_LANG_SPECIFIC (ENUMERAL_TYPE_CHECK (NODE)) #define TYPE_RM_SIZE(NODE) \ (TREE_CODE (NODE) == ENUMERAL_TYPE ? TYPE_RM_SIZE_ENUM (NODE) \ --- 158,196 ---- by copy in copy out. It is a CONSTRUCTOR. For a full description of the cico parameter passing mechanism refer to the routine gnat_to_gnu_entity. */ #define TYPE_CI_CO_LIST(NODE) \ ! (&TYPE_LANG_SPECIFIC (FUNCTION_TYPE_CHECK (NODE))->t.generic) ! #define SET_TYPE_CI_CO_LIST(NODE, X) \ ! (TYPE_LANG_SPECIFIC (FUNCTION_TYPE_CHECK (NODE)) = (struct lang_type *)(X)) /* For an INTEGER_TYPE with TYPE_MODULAR_P, this is the value of the modulus. */ #define TYPE_MODULUS(NODE) \ ! (&TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE))->t.generic) ! #define SET_TYPE_MODULUS(NODE, X) \ ! (TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) = (struct lang_type *)(X)) /* For an INTEGER_TYPE that is the TYPE_DOMAIN of some ARRAY_TYPE, points to the type corresponding to the Ada index type. */ #define TYPE_INDEX_TYPE(NODE) \ ! (&TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE))->t.generic) ! #define SET_TYPE_INDEX_TYPE(NODE, X) \ ! (TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) = (struct lang_type *)(X)) /* For an INTEGER_TYPE with TYPE_VAX_FLOATING_POINT_P, stores the Digits_Value. */ #define TYPE_DIGITS_VALUE(NODE) \ ! ((long) TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE))) ! #define SET_TYPE_DIGITS_VALUE(NODE, X) \ ! (TYPE_LANG_SPECIFIC (INTEGER_TYPE_CHECK (NODE)) = (struct lang_type *)(X)) /* For INTEGER_TYPE, stores the RM_Size of the type. */ #define TYPE_RM_SIZE_INT(NODE) TYPE_VALUES (INTEGER_TYPE_CHECK (NODE)) /* Likewise for ENUMERAL_TYPE. */ #define TYPE_RM_SIZE_ENUM(NODE) \ ! (&TYPE_LANG_SPECIFIC (ENUMERAL_TYPE_CHECK (NODE))->t.generic) ! #define SET_TYPE_RM_SIZE_ENUM(NODE, X) \ ! (TYPE_LANG_SPECIFIC (ENUMERAL_TYPE_CHECK (NODE)) = (struct lang_type *)(X)) #define TYPE_RM_SIZE(NODE) \ (TREE_CODE (NODE) == ENUMERAL_TYPE ? TYPE_RM_SIZE_ENUM (NODE) \ *************** enum gnat_tree_code { *** 167,183 **** unconstrained object. Likewise for a RECORD_TYPE that is pointed to by a thin pointer. */ #define TYPE_UNCONSTRAINED_ARRAY(NODE) \ ! (tree) TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE)) /* For other RECORD_TYPEs and all UNION_TYPEs and QUAL_UNION_TYPEs, the Ada size of the object. This differs from the GCC size in that it does not include any rounding up to the alignment of the type. */ ! #define TYPE_ADA_SIZE(NODE) (tree) TYPE_LANG_SPECIFIC (NODE) /* For an INTEGER_TYPE with TYPE_HAS_ACTUAL_BOUNDS_P or an ARRAY_TYPE, this is the index type that should be used when the actual bounds are required for a template. This is used in the case of packed arrays. */ ! #define TYPE_ACTUAL_BOUNDS(NODE) (tree) TYPE_LANG_SPECIFIC (NODE) /* In an UNCONSTRAINED_ARRAY_TYPE, points to the record containing both the template and object. */ --- 201,223 ---- unconstrained object. Likewise for a RECORD_TYPE that is pointed to by a thin pointer. */ #define TYPE_UNCONSTRAINED_ARRAY(NODE) \ ! (&TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE))->t.generic) ! #define SET_TYPE_UNCONSTRAINED_ARRAY(NODE, X) \ ! (TYPE_LANG_SPECIFIC (RECORD_TYPE_CHECK (NODE)) = (struct lang_type *)(X)) /* For other RECORD_TYPEs and all UNION_TYPEs and QUAL_UNION_TYPEs, the Ada size of the object. This differs from the GCC size in that it does not include any rounding up to the alignment of the type. */ ! #define TYPE_ADA_SIZE(NODE) (&TYPE_LANG_SPECIFIC (NODE)->t.generic) ! #define SET_TYPE_ADA_SIZE(NODE, X) \ ! (TYPE_LANG_SPECIFIC (NODE) = (struct lang_type *)(X)) /* For an INTEGER_TYPE with TYPE_HAS_ACTUAL_BOUNDS_P or an ARRAY_TYPE, this is the index type that should be used when the actual bounds are required for a template. This is used in the case of packed arrays. */ ! #define TYPE_ACTUAL_BOUNDS(NODE) (&TYPE_LANG_SPECIFIC (NODE)->t.generic) ! #define SET_TYPE_ACTUAL_BOUNDS(NODE, X) \ ! (TYPE_LANG_SPECIFIC (NODE) = (struct lang_type *)(X)) /* In an UNCONSTRAINED_ARRAY_TYPE, points to the record containing both the template and object. */ *************** enum gnat_tree_code { *** 216,227 **** memory. Used when a scalar constant is aliased or has its address taken. */ #define DECL_CONST_CORRESPONDING_VAR(NODE) \ ! (tree) DECL_LANG_SPECIFIC (CONST_DECL_CHECK (NODE)) /* In a FIELD_DECL, points to the FIELD_DECL that was the ultimate source of the decl. */ #define DECL_ORIGINAL_FIELD(NODE) \ ! (tree) DECL_LANG_SPECIFIC (FIELD_DECL_CHECK (NODE)) /* In a FIELD_DECL corresponding to a discriminant, contains the discriminant number. */ --- 256,271 ---- memory. Used when a scalar constant is aliased or has its address taken. */ #define DECL_CONST_CORRESPONDING_VAR(NODE) \ ! (&DECL_LANG_SPECIFIC (CONST_DECL_CHECK (NODE))->t.generic) ! #define SET_DECL_CONST_CORRESPONDING_VAR(NODE, X) \ ! (DECL_LANG_SPECIFIC (CONST_DECL_CHECK (NODE)) = (struct lang_decl *)(X)) /* In a FIELD_DECL, points to the FIELD_DECL that was the ultimate source of the decl. */ #define DECL_ORIGINAL_FIELD(NODE) \ ! (&DECL_LANG_SPECIFIC (FIELD_DECL_CHECK (NODE))->t.generic) ! #define SET_DECL_ORIGINAL_FIELD(NODE, X) \ ! (DECL_LANG_SPECIFIC (FIELD_DECL_CHECK (NODE)) = (struct lang_decl *)(X)) /* In a FIELD_DECL corresponding to a discriminant, contains the discriminant number. */ *************** enum gnat_tree_code { *** 229,232 **** /* This is a horrible kludge to store the loop_id of a loop into a tree node. We need to find some other place to store it! */ ! #define TREE_LOOP_ID(NODE) (TREE_CHECK (NODE, GNAT_LOOP_ID)->real_cst.rtl) --- 273,277 ---- /* This is a horrible kludge to store the loop_id of a loop into a tree node. We need to find some other place to store it! */ ! #define TREE_LOOP_ID(NODE) \ ! (((union lang_tree_node *)TREE_CHECK (NODE, GNAT_LOOP_ID))->loop_id.loop_id) diff -Nrc3pad gcc-3.2.3/gcc/ada/a-decima.adb gcc-3.3/gcc/ada/a-decima.adb *** gcc-3.2.3/gcc/ada/a-decima.adb 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-decima.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-decima.ads gcc-3.3/gcc/ada/a-decima.ads *** gcc-3.2.3/gcc/ada/a-decima.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-decima.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-diocst.adb gcc-3.3/gcc/ada/a-diocst.adb *** gcc-3.2.3/gcc/ada/a-diocst.adb 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-diocst.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-diocst.ads gcc-3.3/gcc/ada/a-diocst.ads *** gcc-3.2.3/gcc/ada/a-diocst.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-diocst.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-direio.adb gcc-3.3/gcc/ada/a-direio.adb *** gcc-3.2.3/gcc/ada/a-direio.adb 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-direio.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-direio.ads gcc-3.3/gcc/ada/a-direio.ads *** gcc-3.2.3/gcc/ada/a-direio.ads 2002-05-04 03:27:20.000000000 +0000 --- gcc-3.3/gcc/ada/a-direio.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-dynpri.adb gcc-3.3/gcc/ada/a-dynpri.adb *** gcc-3.2.3/gcc/ada/a-dynpri.adb 2001-10-02 13:51:51.000000000 +0000 --- gcc-3.3/gcc/ada/a-dynpri.adb 2002-10-28 16:19:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,36 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 27,34 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ *************** with Ada.Exceptions; *** 56,65 **** --- 54,69 ---- with System.Tasking.Initialization; -- used for Defer/Undefer_Abort + with System.Parameters; + -- used for Single_Lock + with Unchecked_Conversion; package body Ada.Dynamic_Priorities is + package STPO renames System.Task_Primitives.Operations; + + use System.Parameters; use System.Tasking; use Ada.Exceptions; *************** package body Ada.Dynamic_Priorities is *** 107,113 **** Ada.Task_Identification.Current_Task) is Target : constant Task_ID := Convert_Ids (T); ! Self_ID : constant Task_ID := System.Task_Primitives.Operations.Self; Error_Message : constant String := "Trying to set the priority of a "; begin --- 111,117 ---- Ada.Task_Identification.Current_Task) is Target : constant Task_ID := Convert_Ids (T); ! Self_ID : constant Task_ID := STPO.Self; Error_Message : constant String := "Trying to set the priority of a "; begin *************** package body Ada.Dynamic_Priorities is *** 121,154 **** Error_Message & "terminated task"); end if; ! System.Tasking.Initialization.Defer_Abort (Self_ID); ! System.Task_Primitives.Operations.Write_Lock (Target); if Self_ID = Target then Target.Common.Base_Priority := Priority; ! System.Task_Primitives.Operations.Set_Priority (Target, Priority); ! System.Task_Primitives.Operations.Unlock (Target); ! System.Task_Primitives.Operations.Yield; -- Yield is needed to enforce FIFO task dispatching. -- LL Set_Priority is made while holding the RTS lock so that -- it is inheriting high priority until it release all the RTS -- locks. -- If this is used in a system where Ceiling Locking is -- not enforced we may end up getting two Yield effects. else Target.New_Base_Priority := Priority; Target.Pending_Priority_Change := True; Target.Pending_Action := True; ! System.Task_Primitives.Operations.Wakeup ! (Target, Target.Common.State); -- If the task is suspended, wake it up to perform the change. -- check for ceiling violations ??? - System.Task_Primitives.Operations.Unlock (Target); end if; - System.Tasking.Initialization.Undefer_Abort (Self_ID); end Set_Priority; end Ada.Dynamic_Priorities; --- 125,173 ---- Error_Message & "terminated task"); end if; ! Initialization.Defer_Abort (Self_ID); ! ! if Single_Lock then ! STPO.Lock_RTS; ! end if; ! ! STPO.Write_Lock (Target); if Self_ID = Target then Target.Common.Base_Priority := Priority; ! STPO.Set_Priority (Target, Priority); ! ! STPO.Unlock (Target); ! ! if Single_Lock then ! STPO.Unlock_RTS; ! end if; ! ! STPO.Yield; -- Yield is needed to enforce FIFO task dispatching. -- LL Set_Priority is made while holding the RTS lock so that -- it is inheriting high priority until it release all the RTS -- locks. -- If this is used in a system where Ceiling Locking is -- not enforced we may end up getting two Yield effects. + else Target.New_Base_Priority := Priority; Target.Pending_Priority_Change := True; Target.Pending_Action := True; ! STPO.Wakeup (Target, Target.Common.State); -- If the task is suspended, wake it up to perform the change. -- check for ceiling violations ??? + STPO.Unlock (Target); + + if Single_Lock then + STPO.Unlock_RTS; + end if; end if; + Initialization.Undefer_Abort (Self_ID); end Set_Priority; end Ada.Dynamic_Priorities; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-dynpri.ads gcc-3.3/gcc/ada/a-dynpri.ads *** gcc-3.2.3/gcc/ada/a-dynpri.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-dynpri.ads 2002-03-14 10:58:48.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-einuoc.adb gcc-3.3/gcc/ada/a-einuoc.adb *** gcc-3.2.3/gcc/ada/a-einuoc.adb 2002-05-04 03:27:21.000000000 +0000 --- gcc-3.3/gcc/ada/a-einuoc.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-einuoc.ads gcc-3.3/gcc/ada/a-einuoc.ads *** gcc-3.2.3/gcc/ada/a-einuoc.ads 2002-05-04 03:27:21.000000000 +0000 --- gcc-3.3/gcc/ada/a-einuoc.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-except.adb gcc-3.3/gcc/ada/a-except.adb *** gcc-3.2.3/gcc/ada/a-except.adb 2002-05-04 03:27:21.000000000 +0000 --- gcc-3.3/gcc/ada/a-except.adb 2003-03-04 20:11:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Ada.Exceptions is *** 89,97 **** --- 88,206 ---- -- Boolean indicating whether tracebacks should be stored in exception -- occurrences. + Zero_Cost_Exceptions : Integer; + pragma Import (C, Zero_Cost_Exceptions, "__gl_zero_cost_exceptions"); + -- Boolean indicating if we are handling exceptions using a zero cost + -- mechanism. + -- + -- ??? We currently have two alternatives for this scheme : one using + -- front-end tables and one using back-end tables. The former is known to + -- only work for GNAT3 and the latter is known to only work for GNAT5. + -- Both are present in this implementation and it would be good to have + -- separate bodies at some point. + -- + -- Note that although we currently do not support it, the GCC3 back-end + -- tables are also potentially useable for setjmp/longjmp processing. + Nline : constant String := String' (1 => ASCII.LF); -- Convenient shortcut + ------------------------------------------------ + -- Entities to interface with the GCC runtime -- + ------------------------------------------------ + + -- These come from "C++ ABI for Itanium : Exception handling", which is + -- the reference for GCC. They are used only when we are relying on + -- back-end tables for exception propagation, which in turn is currenly + -- only the case for Zero_Cost_Exceptions in GNAT5. + + -- Return codes from the GCC runtime functions used to propagate + -- an exception. + + type Unwind_Reason_Code is + (URC_NO_REASON, + URC_FOREIGN_EXCEPTION_CAUGHT, + URC_PHASE2_ERROR, + URC_PHASE1_ERROR, + URC_NORMAL_STOP, + URC_END_OF_STACK, + URC_HANDLER_FOUND, + URC_INSTALL_CONTEXT, + URC_CONTINUE_UNWIND); + + -- ??? pragma Unreferenced is unknown until 3.15, so we need to disable + -- warnings around it to fix the bootstrap path. + + pragma Warnings (Off); + pragma Unreferenced + (URC_NO_REASON, + URC_FOREIGN_EXCEPTION_CAUGHT, + URC_PHASE2_ERROR, + URC_PHASE1_ERROR, + URC_NORMAL_STOP, + URC_END_OF_STACK, + URC_HANDLER_FOUND, + URC_INSTALL_CONTEXT, + URC_CONTINUE_UNWIND); + pragma Warnings (On); + + pragma Convention (C, Unwind_Reason_Code); + + -- Mandatory common header for any exception object handled by the + -- GCC unwinding runtime. + + subtype Exception_Class is String (1 .. 8); + + GNAT_Exception_Class : constant Exception_Class + := "GNU" & ASCII.NUL & "Ada" & ASCII.NUL; + + type Unwind_Exception is record + Class : Exception_Class := GNAT_Exception_Class; + Cleanup : System.Address := System.Null_Address; + Private1 : Integer; + Private2 : Integer; + end record; + + pragma Convention (C, Unwind_Exception); + + for Unwind_Exception'Alignment use Standard'Maximum_Alignment; + + -- A GNAT exception object to be dealt with by the personality routine + -- called by the GCC unwinding runtime. This structure shall match the + -- one in raise.c and is currently experimental as it might be merged + -- with the GNAT runtime definition some day. + + type GNAT_GCC_Exception is record + Header : Unwind_Exception; + -- Exception header first, as required by the ABI. + + Id : Exception_Id; + -- Usual Exception identifier + + Handled_By_Others : Boolean; + -- Is this exception handled by "when others" ? + + Has_Cleanup : Boolean; + -- Did we see any at-end handler while walking up the stack + -- searching for a handler ? This is used to determine if we + -- start the propagation again after having tried once without + -- finding a true handler for the exception. + + Select_Cleanups : Boolean; + -- Do we consider at-end handlers as legitimate handlers for the + -- exception ? This is used to control the propagation process + -- as described in Raise_Current_Excep. + end record; + + pragma Convention (C, GNAT_GCC_Exception); + + -- GCC runtime functions used + + function Unwind_RaiseException + (E : access GNAT_GCC_Exception) + return Unwind_Reason_Code; + pragma Import (C, Unwind_RaiseException, "__gnat_Unwind_RaiseException"); + ----------------------- -- Local Subprograms -- ----------------------- *************** package body Ada.Exceptions is *** 106,135 **** procedure ZZZ; -- Mark end of procedures in this package - Address_Image_Length : constant := - 13 + 10 * Boolean'Pos (Standard'Address_Size > 32); - -- Length of string returned by Address_Image function - function Address_Image (A : System.Address) return String; -- Returns at string of the form 0xhhhhhhhhh for 32-bit addresses -- or 0xhhhhhhhhhhhhhhhh for 64-bit addresses. Hex characters are -- in lower case. procedure Free is new Ada.Unchecked_Deallocation (Subprogram_Descriptor_List, Subprogram_Descriptor_List_Ptr); procedure Raise_Current_Excep (E : Exception_Id); pragma No_Return (Raise_Current_Excep); pragma Export (C, Raise_Current_Excep, "__gnat_raise_nodefer_with_msg"); ! -- This is the lowest level raise routine. It raises the exception ! -- referenced by Current_Excep.all in the TSD, without deferring ! -- abort (the caller must ensure that abort is deferred on entry). ! -- The parameter E is ignored. -- -- This external name for Raise_Current_Excep is historical, and probably ! -- should be changed but for now we keep it, because gdb knows about it. ! -- The parameter is also present for historical compatibility. ??? procedure Raise_Exception_No_Defer (E : Exception_Id; Message : String := ""); --- 215,283 ---- procedure ZZZ; -- Mark end of procedures in this package function Address_Image (A : System.Address) return String; -- Returns at string of the form 0xhhhhhhhhh for 32-bit addresses -- or 0xhhhhhhhhhhhhhhhh for 64-bit addresses. Hex characters are -- in lower case. + procedure Call_Chain (Excep : EOA); + -- Store up to Max_Tracebacks in Excep, corresponding to the current + -- call chain. + procedure Free is new Ada.Unchecked_Deallocation (Subprogram_Descriptor_List, Subprogram_Descriptor_List_Ptr); + procedure Process_Raise_Exception + (E : Exception_Id; + From_Signal_Handler : Boolean); + pragma Inline (Process_Raise_Exception); + pragma No_Return (Process_Raise_Exception); + -- This is the lowest level raise routine. It raises the exception + -- referenced by Current_Excep.all in the TSD, without deferring abort + -- (the caller must ensure that abort is deferred on entry). + -- + -- This is actually the common implementation for Raise_Current_Excep and + -- Raise_From_Signal_Handler, with a couple of operations inhibited when + -- called from the latter. The origin of the call is indicated by the + -- From_Signal_Handler argument. + -- + -- The Inline pragma is there for efficiency reasons. + + procedure Propagate_Exception_With_FE_Support (Mstate : Machine_State); + pragma No_Return (Propagate_Exception_With_FE_Support); + -- This procedure propagates the exception represented by the occurrence + -- referenced by Current_Excep in the TSD for the current task. M is the + -- initial machine state, representing the site of the exception raise + -- operation. + -- + -- The procedure searches the front end exception tables for an applicable + -- handler, calling Pop_Frame as needed. If and when it locates an + -- applicable handler, Enter_Handler is called to actually enter this + -- handler. If the search is unable to locate an applicable handler, + -- execution is terminated by calling Unhandled_Exception_Terminate. + + procedure Propagate_Exception_With_GCC_Support (Mstate : Machine_State); + pragma No_Return (Propagate_Exception_With_GCC_Support); + -- This procedure propagates the exception represented by the occurrence + -- referenced by Current_Excep in the TSD for the current task. M is the + -- initial machine state, representing the site of the exception raise + -- operation. It is currently not used and is there for the purpose of + -- interface consistency against Propagate_Exception_With_FE_Support. + -- + -- The procedure builds an object suitable for the libgcc processing and + -- calls Unwind_RaiseException to actually throw, taking care of handling + -- the two phase scheme it implements. + procedure Raise_Current_Excep (E : Exception_Id); pragma No_Return (Raise_Current_Excep); pragma Export (C, Raise_Current_Excep, "__gnat_raise_nodefer_with_msg"); ! -- This is a simple wrapper to Process_Raise_Exception setting the ! -- From_Signal_Handler argument to False. -- -- This external name for Raise_Current_Excep is historical, and probably ! -- should be changed but for now we keep it, because gdb and gigi know ! -- about it. procedure Raise_Exception_No_Defer (E : Exception_Id; Message : String := ""); *************** package body Ada.Exceptions is *** 148,178 **** procedure Raise_With_Location (E : Exception_Id; ! F : SSL.Big_String_Ptr; L : Integer); pragma No_Return (Raise_With_Location); -- Raise an exception with given exception id value. A filename and line -- number is associated with the raise and is stored in the exception -- occurrence. procedure Raise_Constraint_Error ! (File : SSL.Big_String_Ptr; Line : Integer); pragma No_Return (Raise_Constraint_Error); ! pragma Export (C, Raise_Constraint_Error, "__gnat_raise_constraint_error"); -- Raise constraint error with file:line information procedure Raise_Program_Error ! (File : SSL.Big_String_Ptr; Line : Integer); pragma No_Return (Raise_Program_Error); ! pragma Export (C, Raise_Program_Error, "__gnat_raise_program_error"); -- Raise program error with file:line information procedure Raise_Storage_Error ! (File : SSL.Big_String_Ptr; Line : Integer); pragma No_Return (Raise_Storage_Error); ! pragma Export (C, Raise_Storage_Error, "__gnat_raise_storage_error"); -- Raise storage error with file:line information -- The exception raising process and the automatic tracing mechanism rely -- on some careful use of flags attached to the exception occurrence. The -- graph below illustrates the relations between the Raise_ subprograms --- 296,369 ---- procedure Raise_With_Location (E : Exception_Id; ! F : Big_String_Ptr; L : Integer); pragma No_Return (Raise_With_Location); -- Raise an exception with given exception id value. A filename and line -- number is associated with the raise and is stored in the exception -- occurrence. + procedure Raise_With_Location_And_Msg + (E : Exception_Id; + F : Big_String_Ptr; + L : Integer; + M : Big_String_Ptr); + pragma No_Return (Raise_With_Location_And_Msg); + -- Raise an exception with given exception id value. A filename and line + -- number is associated with the raise and is stored in the exception + -- occurrence and in addition a string message M is appended to this. + procedure Raise_Constraint_Error ! (File : Big_String_Ptr; ! Line : Integer); pragma No_Return (Raise_Constraint_Error); ! pragma Export ! (C, Raise_Constraint_Error, "__gnat_raise_constraint_error"); -- Raise constraint error with file:line information + procedure Raise_Constraint_Error_Msg + (File : Big_String_Ptr; + Line : Integer; + Msg : Big_String_Ptr); + pragma No_Return (Raise_Constraint_Error_Msg); + pragma Export + (C, Raise_Constraint_Error_Msg, "__gnat_raise_constraint_error_msg"); + -- Raise constraint error with file:line + msg information + procedure Raise_Program_Error ! (File : Big_String_Ptr; ! Line : Integer); pragma No_Return (Raise_Program_Error); ! pragma Export ! (C, Raise_Program_Error, "__gnat_raise_program_error"); -- Raise program error with file:line information + procedure Raise_Program_Error_Msg + (File : Big_String_Ptr; + Line : Integer; + Msg : Big_String_Ptr); + pragma No_Return (Raise_Program_Error_Msg); + pragma Export + (C, Raise_Program_Error_Msg, "__gnat_raise_program_error_msg"); + -- Raise program error with file:line + msg information + procedure Raise_Storage_Error ! (File : Big_String_Ptr; ! Line : Integer); pragma No_Return (Raise_Storage_Error); ! pragma Export ! (C, Raise_Storage_Error, "__gnat_raise_storage_error"); -- Raise storage error with file:line information + procedure Raise_Storage_Error_Msg + (File : Big_String_Ptr; + Line : Integer; + Msg : Big_String_Ptr); + pragma No_Return (Raise_Storage_Error_Msg); + pragma Export + (C, Raise_Storage_Error_Msg, "__gnat_raise_storage_error_msg"); + -- Raise storage error with file:line + reason msg information + -- The exception raising process and the automatic tracing mechanism rely -- on some careful use of flags attached to the exception occurrence. The -- graph below illustrates the relations between the Raise_ subprograms *************** package body Ada.Exceptions is *** 211,222 **** procedure Set_Exception_C_Msg (Id : Exception_Id; ! Msg : SSL.Big_String_Ptr; ! Line : Integer := 0); -- This routine is called to setup the exception referenced by the -- Current_Excep field in the TSD to contain the indicated Id value ! -- and message. Msg is a null terminated string. when Line > 0, ! -- Msg is the filename and line the line number of the exception location. procedure To_Stderr (S : String); pragma Export (Ada, To_Stderr, "__gnat_to_stderr"); --- 402,417 ---- procedure Set_Exception_C_Msg (Id : Exception_Id; ! Msg1 : Big_String_Ptr; ! Line : Integer := 0; ! Msg2 : Big_String_Ptr := null); -- This routine is called to setup the exception referenced by the -- Current_Excep field in the TSD to contain the indicated Id value ! -- and message. Msg1 is a null terminated string which is generated ! -- as the exception message. If line is non-zero, then a colon and ! -- the decimal representation of this integer is appended to the ! -- message. When Msg2 is non-null, a space and this additional null ! -- terminated string is added to the message. procedure To_Stderr (S : String); pragma Export (Ada, To_Stderr, "__gnat_to_stderr"); *************** package body Ada.Exceptions is *** 261,266 **** --- 456,719 ---- -- which are somewhat redundant is historical. Notify_Exception -- certainly is complete enough, but GDB still uses this routine. + ----------------------------- + -- Run-Time Check Routines -- + ----------------------------- + + -- These routines are called from the runtime to raise a specific + -- exception with a reason message attached. The parameters are + -- the file name and line number in each case. The names are keyed + -- to the codes defined in Types.ads and a-types.h (for example, + -- the name Rcheck_05 refers to the Reason whose Pos code is 5). + + procedure Rcheck_00 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_01 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_02 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_03 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_04 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_05 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_06 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_07 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_08 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_09 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_10 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_11 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_12 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_13 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_14 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_15 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_16 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_17 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_18 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_19 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_20 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_21 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_22 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_23 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_24 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_25 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_26 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_27 (File : Big_String_Ptr; Line : Integer); + procedure Rcheck_28 (File : Big_String_Ptr; Line : Integer); + + pragma Export (C, Rcheck_00, "__gnat_rcheck_00"); + pragma Export (C, Rcheck_01, "__gnat_rcheck_01"); + pragma Export (C, Rcheck_02, "__gnat_rcheck_02"); + pragma Export (C, Rcheck_03, "__gnat_rcheck_03"); + pragma Export (C, Rcheck_04, "__gnat_rcheck_04"); + pragma Export (C, Rcheck_05, "__gnat_rcheck_05"); + pragma Export (C, Rcheck_06, "__gnat_rcheck_06"); + pragma Export (C, Rcheck_07, "__gnat_rcheck_07"); + pragma Export (C, Rcheck_08, "__gnat_rcheck_08"); + pragma Export (C, Rcheck_09, "__gnat_rcheck_09"); + pragma Export (C, Rcheck_10, "__gnat_rcheck_10"); + pragma Export (C, Rcheck_11, "__gnat_rcheck_11"); + pragma Export (C, Rcheck_12, "__gnat_rcheck_12"); + pragma Export (C, Rcheck_13, "__gnat_rcheck_13"); + pragma Export (C, Rcheck_14, "__gnat_rcheck_14"); + pragma Export (C, Rcheck_15, "__gnat_rcheck_15"); + pragma Export (C, Rcheck_16, "__gnat_rcheck_16"); + pragma Export (C, Rcheck_17, "__gnat_rcheck_17"); + pragma Export (C, Rcheck_18, "__gnat_rcheck_18"); + pragma Export (C, Rcheck_19, "__gnat_rcheck_19"); + pragma Export (C, Rcheck_20, "__gnat_rcheck_20"); + pragma Export (C, Rcheck_21, "__gnat_rcheck_21"); + pragma Export (C, Rcheck_22, "__gnat_rcheck_22"); + pragma Export (C, Rcheck_23, "__gnat_rcheck_23"); + pragma Export (C, Rcheck_24, "__gnat_rcheck_24"); + pragma Export (C, Rcheck_25, "__gnat_rcheck_25"); + pragma Export (C, Rcheck_26, "__gnat_rcheck_26"); + pragma Export (C, Rcheck_27, "__gnat_rcheck_27"); + pragma Export (C, Rcheck_28, "__gnat_rcheck_28"); + + --------------------------------------------- + -- Reason Strings for Run-Time Check Calls -- + --------------------------------------------- + + -- These strings are null-terminated and are used by Rcheck_nn. The + -- strings correspond to the definitions for Types.RT_Exception_Code. + + use ASCII; + + Rmsg_00 : constant String := "access check failed" & NUL; + Rmsg_01 : constant String := "access parameter is null" & NUL; + Rmsg_02 : constant String := "discriminant check failed" & NUL; + Rmsg_03 : constant String := "divide by zero" & NUL; + Rmsg_04 : constant String := "explicit raise" & NUL; + Rmsg_05 : constant String := "index check failed" & NUL; + Rmsg_06 : constant String := "invalid data" & NUL; + Rmsg_07 : constant String := "length check failed" & NUL; + Rmsg_08 : constant String := "overflow check failed" & NUL; + Rmsg_09 : constant String := "partition check failed" & NUL; + Rmsg_10 : constant String := "range check failed" & NUL; + Rmsg_11 : constant String := "tag check failed" & NUL; + Rmsg_12 : constant String := "access before elaboration" & NUL; + Rmsg_13 : constant String := "accessibility check failed" & NUL; + Rmsg_14 : constant String := "all guards closed" & NUL; + Rmsg_15 : constant String := "duplicated entry address" & NUL; + Rmsg_16 : constant String := "explicit raise" & NUL; + Rmsg_17 : constant String := "finalize raised exception" & NUL; + Rmsg_18 : constant String := "invalid data" & NUL; + Rmsg_19 : constant String := "misaligned address value" & NUL; + Rmsg_20 : constant String := "missing return" & NUL; + Rmsg_21 : constant String := "potentially blocking operation" & NUL; + Rmsg_22 : constant String := "stubbed subprogram called" & NUL; + Rmsg_23 : constant String := "unchecked union restriction" & NUL; + Rmsg_24 : constant String := "empty storage pool" & NUL; + Rmsg_25 : constant String := "explicit raise" & NUL; + Rmsg_26 : constant String := "infinite recursion" & NUL; + Rmsg_27 : constant String := "object too large" & NUL; + Rmsg_28 : constant String := "restriction violation" & NUL; + + -------------------------------------- + -- Calls to Run-Time Check Routines -- + -------------------------------------- + + procedure Rcheck_00 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_00'Address)); + end Rcheck_00; + + procedure Rcheck_01 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_01'Address)); + end Rcheck_01; + + procedure Rcheck_02 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_02'Address)); + end Rcheck_02; + + procedure Rcheck_03 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_03'Address)); + end Rcheck_03; + + procedure Rcheck_04 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_04'Address)); + end Rcheck_04; + + procedure Rcheck_05 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_05'Address)); + end Rcheck_05; + + procedure Rcheck_06 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_06'Address)); + end Rcheck_06; + + procedure Rcheck_07 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_07'Address)); + end Rcheck_07; + + procedure Rcheck_08 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_08'Address)); + end Rcheck_08; + + procedure Rcheck_09 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_09'Address)); + end Rcheck_09; + + procedure Rcheck_10 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_10'Address)); + end Rcheck_10; + + procedure Rcheck_11 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Constraint_Error_Msg (File, Line, To_Ptr (Rmsg_11'Address)); + end Rcheck_11; + + procedure Rcheck_12 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_12'Address)); + end Rcheck_12; + + procedure Rcheck_13 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_13'Address)); + end Rcheck_13; + + procedure Rcheck_14 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_14'Address)); + end Rcheck_14; + + procedure Rcheck_15 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_15'Address)); + end Rcheck_15; + + procedure Rcheck_16 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_16'Address)); + end Rcheck_16; + + procedure Rcheck_17 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_17'Address)); + end Rcheck_17; + + procedure Rcheck_18 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_18'Address)); + end Rcheck_18; + + procedure Rcheck_19 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_19'Address)); + end Rcheck_19; + + procedure Rcheck_20 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_20'Address)); + end Rcheck_20; + + procedure Rcheck_21 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_21'Address)); + end Rcheck_21; + + procedure Rcheck_22 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Program_Error_Msg (File, Line, To_Ptr (Rmsg_22'Address)); + end Rcheck_22; + + procedure Rcheck_23 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Storage_Error_Msg (File, Line, To_Ptr (Rmsg_23'Address)); + end Rcheck_23; + + procedure Rcheck_24 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Storage_Error_Msg (File, Line, To_Ptr (Rmsg_24'Address)); + end Rcheck_24; + + procedure Rcheck_25 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Storage_Error_Msg (File, Line, To_Ptr (Rmsg_25'Address)); + end Rcheck_25; + + procedure Rcheck_26 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Storage_Error_Msg (File, Line, To_Ptr (Rmsg_26'Address)); + end Rcheck_26; + + procedure Rcheck_27 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Storage_Error_Msg (File, Line, To_Ptr (Rmsg_27'Address)); + end Rcheck_27; + + procedure Rcheck_28 (File : Big_String_Ptr; Line : Integer) is + begin + Raise_Storage_Error_Msg (File, Line, To_Ptr (Rmsg_28'Address)); + end Rcheck_28; + --------------------------------------- -- Exception backtracing subprograms -- --------------------------------------- *************** package body Ada.Exceptions is *** 307,324 **** (N : Natural; Info : in out String; Ptr : in out Natural); ! -- Append the image of N at the end of the provided information string. procedure Append_Info_NL (Info : in out String; Ptr : in out Natural); ! -- Append a CR/LF couple at the end of the provided information string. procedure Append_Info_String (S : String; Info : in out String; Ptr : in out Natural); ! -- Append a string at the end of the provided information string. -- To build Exception_Information and Tailored_Exception_Information, -- we then use three intermediate functions : --- 760,777 ---- (N : Natural; Info : in out String; Ptr : in out Natural); ! -- Append the image of N at the end of the provided information string procedure Append_Info_NL (Info : in out String; Ptr : in out Natural); ! -- Append a LF at the end of the provided information string procedure Append_Info_String (S : String; Info : in out String; Ptr : in out Natural); ! -- Append a string at the end of the provided information string -- To build Exception_Information and Tailored_Exception_Information, -- we then use three intermediate functions : *************** package body Ada.Exceptions is *** 408,429 **** procedure Unhandled_Terminate; pragma Import (C, Unhandled_Terminate, "__gnat_unhandled_terminate"); - procedure Propagate_Exception (Mstate : Machine_State); - pragma No_Return (Propagate_Exception); - -- This procedure propagates the exception represented by the occurrence - -- referenced by Current_Excep in the TSD for the current task. M is - -- the initial machine state, representing the site of the exception - -- raise operation. Propagate_Exception searches the exception tables - -- for an applicable handler, calling Pop_Frame as needed. If and when - -- it locates an applicable handler Propagate_Exception makes a call - -- to Enter_Handler to actually enter the handler. If the search is - -- unable to locate an applicable handler, execution is terminated by - -- calling Unhandled_Exception_Terminate. - - procedure Call_Chain (Excep : EOA); - -- Store up to Max_Tracebacks in Excep, corresponding to the current - -- call chain. - ----------------------- -- Polling Interface -- ----------------------- --- 861,866 ---- *************** package body Ada.Exceptions is *** 504,511 **** is begin Ptr := Ptr + 1; - Info (Ptr) := ASCII.CR; - Ptr := Ptr + 1; Info (Ptr) := ASCII.LF; end Append_Info_NL; --- 941,946 ---- *************** package body Ada.Exceptions is *** 823,833 **** return Name (P .. Name'Length); end Exception_Name_Simple; ! ------------------------- ! -- Propagate_Exception -- ! ------------------------- ! procedure Propagate_Exception (Mstate : Machine_State) is Excep : constant EOA := Get_Current_Excep.all; Loc : Code_Loc; Lo, Hi : Natural; --- 1258,1355 ---- return Name (P .. Name'Length); end Exception_Name_Simple; ! ----------------------------- ! -- Process_Raise_Exception -- ! ----------------------------- ! procedure Process_Raise_Exception ! (E : Exception_Id; ! From_Signal_Handler : Boolean) ! is ! pragma Inspection_Point (E); ! -- This is so the debugger can reliably inspect the parameter ! ! Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all; ! Mstate_Ptr : constant Machine_State := ! Machine_State (Get_Machine_State_Addr.all); ! Excep : EOA := Get_Current_Excep.all; ! ! begin ! -- WARNING : There should be no exception handler for this body ! -- because this would cause gigi to prepend a setup for a new ! -- jmpbuf to the sequence of statements. We would then always get ! -- this new buf in Jumpbuf_Ptr instead of the one for the exception ! -- we are handling, which would completely break the whole design ! -- of this procedure. ! ! -- Processing varies between zero cost and setjmp/lonjmp processing. ! ! if Zero_Cost_Exceptions /= 0 then ! ! -- Use the front-end tables to propagate if we have them, otherwise ! -- resort to the GCC back-end alternative. The backtrace for the ! -- occurrence is stored while walking up the stack, and thus stops ! -- in the handler's frame if there is one. Notifications are also ! -- not performed here since it is not yet known if the exception is ! -- handled. ! ! -- Set the machine state unless we are raising from a signal handler ! -- since it has already been set properly in that case. ! ! if not From_Signal_Handler then ! Set_Machine_State (Mstate_Ptr); ! end if; ! ! if Subprogram_Descriptors /= null then ! Propagate_Exception_With_FE_Support (Mstate_Ptr); ! else ! Propagate_Exception_With_GCC_Support (Mstate_Ptr); ! end if; ! ! else ! ! -- Compute the backtrace for this occurrence if the corresponding ! -- binder option has been set and we are not raising from a signal ! -- handler. Call_Chain takes care of the reraise case. ! ! if not From_Signal_Handler ! and then Exception_Tracebacks /= 0 ! then ! Call_Chain (Excep); ! end if; ! ! -- If the jump buffer pointer is non-null, transfer control using ! -- it. Otherwise announce an unhandled exception (note that this ! -- means that we have no finalizations to do other than at the outer ! -- level). Perform the necessary notification tasks in both cases. ! ! if Jumpbuf_Ptr /= Null_Address then ! ! if not Excep.Exception_Raised then ! Excep.Exception_Raised := True; ! Notify_Handled_Exception (Null_Loc, False, False); ! ! -- The low level debugger notification is skipped from the ! -- call above because we do not have the necessary information ! -- to "feed" it properly. ! ! end if; ! ! builtin_longjmp (Jumpbuf_Ptr, 1); ! ! else ! Notify_Unhandled_Exception (E); ! Unhandled_Exception_Terminate; ! end if; ! end if; ! ! end Process_Raise_Exception; ! ! ----------------------------------------- ! -- Propagate_Exception_With_FE_Support -- ! ----------------------------------------- ! ! procedure Propagate_Exception_With_FE_Support (Mstate : Machine_State) is Excep : constant EOA := Get_Current_Excep.all; Loc : Code_Loc; Lo, Hi : Natural; *************** package body Ada.Exceptions is *** 872,881 **** FH_Mstate : aliased Machine_State_Record; -- Records the machine state for the finalization handler ! FH_Handler : Code_Loc; -- Record handler address for finalization handler ! FH_Num_Trb : Natural; -- Save number of tracebacks for finalization handler begin --- 1394,1403 ---- FH_Mstate : aliased Machine_State_Record; -- Records the machine state for the finalization handler ! FH_Handler : Code_Loc := Null_Address; -- Record handler address for finalization handler ! FH_Num_Trb : Natural := 0; -- Save number of tracebacks for finalization handler begin *************** package body Ada.Exceptions is *** 1034,1108 **** Unhandled_Exception_Terminate; ! end Propagate_Exception; ! ! ------------------------- ! -- Raise_Current_Excep -- ! ------------------------- ! ! procedure Raise_Current_Excep (E : Exception_Id) is ! pragma Inspection_Point (E); ! -- This is so the debugger can reliably inspect the parameter ! Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all; ! Mstate_Ptr : constant Machine_State := ! Machine_State (Get_Machine_State_Addr.all); ! Excep : EOA; begin ! -- WARNING : There should be no exception handler for this body ! -- because this would cause gigi to prepend a setup for a new ! -- jmpbuf to the sequence of statements. We would then always get ! -- this new buf in Jumpbuf_Ptr instead of the one for the exception ! -- we are handling, which would completely break the whole design ! -- of this procedure. ! -- If the jump buffer pointer is non-null, it means that a jump ! -- buffer was allocated (obviously that happens only in the case ! -- of zero cost exceptions not implemented, or if a jump buffer ! -- was manually set up by C code). ! if Jumpbuf_Ptr /= Null_Address then ! Excep := Get_Current_Excep.all; ! if Exception_Tracebacks /= 0 then ! Call_Chain (Excep); ! end if; ! -- Perform the necessary notification tasks if this is not a ! -- reraise. Actually ask to skip the low level debugger notification ! -- call since we do not have the necessary information to "feed" ! -- it properly. ! if not Excep.Exception_Raised then ! Excep.Exception_Raised := True; ! Notify_Handled_Exception (Null_Loc, False, False); ! end if; ! builtin_longjmp (Jumpbuf_Ptr, 1); ! -- If we have no jump buffer, then either zero cost exception ! -- handling is in place, or we have no handlers anyway. In ! -- either case we have an unhandled exception. If zero cost ! -- exception handling is in place, propagate the exception ! elsif Subprogram_Descriptors /= null then ! Set_Machine_State (Mstate_Ptr); ! Propagate_Exception (Mstate_Ptr); ! -- Otherwise, we know the exception is unhandled by the absence ! -- of an allocated jump buffer. Note that this means that we also ! -- have no finalizations to do other than at the outer level. ! else ! if Exception_Tracebacks /= 0 then ! Call_Chain (Get_Current_Excep.all); ! end if; ! Notify_Unhandled_Exception (E); ! Unhandled_Exception_Terminate; end if; end Raise_Current_Excep; --------------------- --- 1556,1666 ---- Unhandled_Exception_Terminate; ! end Propagate_Exception_With_FE_Support; ! ------------------------------------------ ! -- Propagate_Exception_With_GCC_Support -- ! ------------------------------------------ ! procedure Propagate_Exception_With_GCC_Support (Mstate : Machine_State) is ! Excep : EOA := Get_Current_Excep.all; ! This_Exception : aliased GNAT_GCC_Exception; ! Status : Unwind_Reason_Code; begin ! -- ??? Nothing is currently done for backtracing purposes. We could ! -- have used the personality routine to record the addresses while ! -- walking up the stack, but this method has two drawbacks : 1/ the ! -- trace is incomplete if the exception is handled since we don't walk ! -- up the frame with the handler, and 2/ we will miss frames if the ! -- exception propagates through frames for which our personality ! -- routine is not called (e.g. if C or C++ frames are on the way). ! -- Fill in the useful flags for the personality routine called for each ! -- frame via the call to Unwind_RaiseException below. ! This_Exception.Id := Excep.Id; ! This_Exception.Handled_By_Others := not Excep.Id.Not_Handled_By_Others; ! This_Exception.Has_Cleanup := False; ! -- We are looking for a regular handler first. If there is one, either ! -- it or the first at-end handler before it will be entered. If there ! -- is none, control will normally get back to after the call, with ! -- Has_Cleanup set to true if at least one at-end handler has been ! -- found while walking up the stack. ! This_Exception.Select_Cleanups := False; ! Status := Unwind_RaiseException (This_Exception'Access); ! -- If we get here we know the exception is not handled, as otherwise ! -- Unwind_RaiseException arranges for a handler to be entered. We might ! -- have met cleanups handlers, though, requiring to start again with ! -- the Select_Cleanups flag set to True. ! -- Before restarting for cleanups, take the necessary steps to enable ! -- the debugger to gain control while the stack is still intact. Flag ! -- the occurrence as raised to avoid notifying again in case cleanup ! -- handlers are entered later. ! if not Excep.Exception_Raised then ! Excep.Exception_Raised := True; ! Notify_Unhandled_Exception (Excep.Id); ! end if; ! -- Now raise again selecting cleanups as true handlers. Only do this if ! -- we know at least one such handler exists since otherwise we would ! -- perform a complete stack upwalk for nothing. ! if This_Exception.Has_Cleanup then ! This_Exception.Select_Cleanups := True; ! Status := Unwind_RaiseException (This_Exception'Access); ! -- The first cleanup found is entered. It performs its job, raises ! -- the initial exception again, and the flow goes back to the first ! -- step above with the stack in a different state. end if; + + -- We get here when there is no handler to be run at all. The debugger + -- has been notified before the second step above. + + Unhandled_Exception_Terminate; + + end Propagate_Exception_With_GCC_Support; + + ---------------------------- + -- Raise_Constraint_Error -- + ---------------------------- + + procedure Raise_Constraint_Error + (File : Big_String_Ptr; + Line : Integer) + is + begin + Raise_With_Location (Constraint_Error_Def'Access, File, Line); + end Raise_Constraint_Error; + + -------------------------------- + -- Raise_Constraint_Error_Msg -- + -------------------------------- + + procedure Raise_Constraint_Error_Msg + (File : Big_String_Ptr; + Line : Integer; + Msg : Big_String_Ptr) + is + begin + Raise_With_Location_And_Msg + (Constraint_Error_Def'Access, File, Line, Msg); + end Raise_Constraint_Error_Msg; + + ------------------------- + -- Raise_Current_Excep -- + ------------------------- + + procedure Raise_Current_Excep (E : Exception_Id) is + begin + Process_Raise_Exception (E => E, From_Signal_Handler => False); end Raise_Current_Excep; --------------------- *************** package body Ada.Exceptions is *** 1150,1200 **** procedure Raise_From_Signal_Handler (E : Exception_Id; ! M : SSL.Big_String_Ptr) is - Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all; - Mstate_Ptr : constant Machine_State := - Machine_State (Get_Machine_State_Addr.all); - begin Set_Exception_C_Msg (E, M); Abort_Defer.all; ! ! -- Now we raise the exception. The following code is essentially ! -- identical to the Raise_Current_Excep routine, except that in the ! -- zero cost exception case, we do not call Set_Machine_State, since ! -- the signal handler that passed control here has already set the ! -- machine state directly. ! -- ! -- We also do not compute the backtrace for the occurrence since going ! -- through the signal handler is far from trivial and it is not a ! -- problem to fail providing a backtrace in the "raised from signal ! -- handler" case. ! ! -- If the jump buffer pointer is non-null, it means that a jump ! -- buffer was allocated (obviously that happens only in the case ! -- of zero cost exceptions not implemented, or if a jump buffer ! -- was manually set up by C code). ! ! if Jumpbuf_Ptr /= Null_Address then ! builtin_longjmp (Jumpbuf_Ptr, 1); ! ! -- If we have no jump buffer, then either zero cost exception ! -- handling is in place, or we have no handlers anyway. In ! -- either case we have an unhandled exception. If zero cost ! -- exception handling is in place, propagate the exception ! ! elsif Subprogram_Descriptors /= null then ! Propagate_Exception (Mstate_Ptr); ! ! -- Otherwise, we know the exception is unhandled by the absence ! -- of an allocated jump buffer. Note that this means that we also ! -- have no finalizations to do other than at the outer level. ! ! else ! Notify_Unhandled_Exception (E); ! Unhandled_Exception_Terminate; ! end if; end Raise_From_Signal_Handler; ------------------ --- 1708,1719 ---- procedure Raise_From_Signal_Handler (E : Exception_Id; ! M : Big_String_Ptr) is begin Set_Exception_C_Msg (E, M); Abort_Defer.all; ! Process_Raise_Exception (E => E, From_Signal_Handler => True); end Raise_From_Signal_Handler; ------------------ *************** package body Ada.Exceptions is *** 1210,1271 **** end Raise_No_Msg; ------------------------- - -- Raise_With_Location -- - ------------------------- - - procedure Raise_With_Location - (E : Exception_Id; - F : SSL.Big_String_Ptr; - L : Integer) is - begin - Set_Exception_C_Msg (E, F, L); - Abort_Defer.all; - Raise_Current_Excep (E); - end Raise_With_Location; - - ---------------------------- - -- Raise_Constraint_Error -- - ---------------------------- - - procedure Raise_Constraint_Error - (File : SSL.Big_String_Ptr; Line : Integer) is - begin - Raise_With_Location (Constraint_Error_Def'Access, File, Line); - end Raise_Constraint_Error; - - ------------------------- -- Raise_Program_Error -- ------------------------- procedure Raise_Program_Error ! (File : SSL.Big_String_Ptr; Line : Integer) is begin Raise_With_Location (Program_Error_Def'Access, File, Line); end Raise_Program_Error; ------------------------- -- Raise_Storage_Error -- ------------------------- procedure Raise_Storage_Error ! (File : SSL.Big_String_Ptr; Line : Integer) is begin Raise_With_Location (Storage_Error_Def'Access, File, Line); end Raise_Storage_Error; ---------------------- -- Raise_With_C_Msg -- ---------------------- procedure Raise_With_C_Msg ! (E : Exception_Id; ! M : SSL.Big_String_Ptr) is begin Set_Exception_C_Msg (E, M); Abort_Defer.all; Raise_Current_Excep (E); end Raise_With_C_Msg; -------------------- -- Raise_With_Msg -- -------------------- --- 1729,1830 ---- end Raise_No_Msg; ------------------------- -- Raise_Program_Error -- ------------------------- procedure Raise_Program_Error ! (File : Big_String_Ptr; ! Line : Integer) ! is begin Raise_With_Location (Program_Error_Def'Access, File, Line); end Raise_Program_Error; + ----------------------------- + -- Raise_Program_Error_Msg -- + ----------------------------- + + procedure Raise_Program_Error_Msg + (File : Big_String_Ptr; + Line : Integer; + Msg : Big_String_Ptr) + is + begin + Raise_With_Location_And_Msg + (Program_Error_Def'Access, File, Line, Msg); + end Raise_Program_Error_Msg; + ------------------------- -- Raise_Storage_Error -- ------------------------- procedure Raise_Storage_Error ! (File : Big_String_Ptr; ! Line : Integer) ! is begin Raise_With_Location (Storage_Error_Def'Access, File, Line); end Raise_Storage_Error; + ----------------------------- + -- Raise_Storage_Error_Msg -- + ----------------------------- + + procedure Raise_Storage_Error_Msg + (File : Big_String_Ptr; + Line : Integer; + Msg : Big_String_Ptr) + is + begin + Raise_With_Location_And_Msg + (Storage_Error_Def'Access, File, Line, Msg); + end Raise_Storage_Error_Msg; + ---------------------- -- Raise_With_C_Msg -- ---------------------- procedure Raise_With_C_Msg ! (E : Exception_Id; ! M : Big_String_Ptr) ! is begin Set_Exception_C_Msg (E, M); Abort_Defer.all; Raise_Current_Excep (E); end Raise_With_C_Msg; + ------------------------- + -- Raise_With_Location -- + ------------------------- + + procedure Raise_With_Location + (E : Exception_Id; + F : Big_String_Ptr; + L : Integer) + is + begin + Set_Exception_C_Msg (E, F, L); + Abort_Defer.all; + Raise_Current_Excep (E); + end Raise_With_Location; + + --------------------------------- + -- Raise_With_Location_And_Msg -- + --------------------------------- + + procedure Raise_With_Location_And_Msg + (E : Exception_Id; + F : Big_String_Ptr; + L : Integer; + M : Big_String_Ptr) + is + begin + Set_Exception_C_Msg (E, F, L, M); + Abort_Defer.all; + Raise_Current_Excep (E); + end Raise_With_Location_And_Msg; + -------------------- -- Raise_With_Msg -- -------------------- *************** package body Ada.Exceptions is *** 1513,1525 **** procedure Set_Exception_C_Msg (Id : Exception_Id; ! Msg : Big_String_Ptr; ! Line : Integer := 0) is Excep : constant EOA := Get_Current_Excep.all; Val : Integer := Line; Remind : Integer; Size : Integer := 1; begin Excep.Exception_Raised := False; --- 2072,2086 ---- procedure Set_Exception_C_Msg (Id : Exception_Id; ! Msg1 : Big_String_Ptr; ! Line : Integer := 0; ! Msg2 : Big_String_Ptr := null) is Excep : constant EOA := Get_Current_Excep.all; Val : Integer := Line; Remind : Integer; Size : Integer := 1; + Ptr : Natural; begin Excep.Exception_Raised := False; *************** package body Ada.Exceptions is *** 1529,1542 **** Excep.Msg_Length := 0; Excep.Cleanup_Flag := False; ! while Msg (Excep.Msg_Length + 1) /= ASCII.NUL and then Excep.Msg_Length < Exception_Msg_Max_Length loop Excep.Msg_Length := Excep.Msg_Length + 1; ! Excep.Msg (Excep.Msg_Length) := Msg (Excep.Msg_Length); end loop; if Line > 0 then -- Compute the number of needed characters while Val > 0 loop --- 2090,2106 ---- Excep.Msg_Length := 0; Excep.Cleanup_Flag := False; ! while Msg1 (Excep.Msg_Length + 1) /= ASCII.NUL and then Excep.Msg_Length < Exception_Msg_Max_Length loop Excep.Msg_Length := Excep.Msg_Length + 1; ! Excep.Msg (Excep.Msg_Length) := Msg1 (Excep.Msg_Length); end loop; + -- Append line number if present + if Line > 0 then + -- Compute the number of needed characters while Val > 0 loop *************** package body Ada.Exceptions is *** 1561,1566 **** --- 2125,2148 ---- end loop; end if; end if; + + -- Append second message if present + + if Msg2 /= null + and then Excep.Msg_Length + 1 < Exception_Msg_Max_Length + then + Excep.Msg_Length := Excep.Msg_Length + 1; + Excep.Msg (Excep.Msg_Length) := ' '; + + Ptr := 1; + while Msg2 (Ptr) /= ASCII.NUL + and then Excep.Msg_Length < Exception_Msg_Max_Length + loop + Excep.Msg_Length := Excep.Msg_Length + 1; + Excep.Msg (Excep.Msg_Length) := Msg2 (Ptr); + Ptr := Ptr + 1; + end loop; + end if; end Set_Exception_C_Msg; ------------------- *************** package body Ada.Exceptions is *** 1593,1599 **** procedure Next_String; -- On entry, To points to last character of previous line of the ! -- message, terminated by CR/LF. On return, From .. To are set to -- specify the next string, or From > To if there are no more lines. procedure Bad_EO is --- 2175,2181 ---- procedure Next_String; -- On entry, To points to last character of previous line of the ! -- message, terminated by LF. On return, From .. To are set to -- specify the next string, or From > To if there are no more lines. procedure Bad_EO is *************** package body Ada.Exceptions is *** 1605,1619 **** procedure Next_String is begin ! From := To + 3; if From < S'Last then To := From + 1; ! while To < S'Last - 2 loop if To >= S'Last then Bad_EO; ! elsif S (To + 1) = ASCII.CR then exit; else To := To + 1; --- 2187,2201 ---- procedure Next_String is begin ! From := To + 2; if From < S'Last then To := From + 1; ! while To < S'Last - 1 loop if To >= S'Last then Bad_EO; ! elsif S (To + 1) = ASCII.LF then exit; else To := To + 1; *************** package body Ada.Exceptions is *** 1631,1637 **** else X.Cleanup_Flag := False; ! To := S'First - 3; Next_String; if S (From .. From + 15) /= "Exception name: " then --- 2213,2219 ---- else X.Cleanup_Flag := False; ! To := S'First - 2; Next_String; if S (From .. From + 15) /= "Exception name: " then *************** package body Ada.Exceptions is *** 1885,1892 **** type int is new Integer; procedure Unhandled_Exception_Terminate is ! Excep : constant EOA := Get_Current_Excep.all; ! Msg : constant String := Exception_Message (Excep.all); -- Start of processing for Unhandled_Exception_Terminate --- 2467,2480 ---- type int is new Integer; procedure Unhandled_Exception_Terminate is ! ! Excep : constant EOA := Save_Occurrence (Get_Current_Excep.all.all); ! -- This occurrence will be used to display a message after finalization. ! -- It is necessary to save a copy here, or else the designated value ! -- could be overwritten if an exception is raised during finalization ! -- (even if that exception is caught). ! ! Msg : constant String := Exception_Message (Excep.all); -- Start of processing for Unhandled_Exception_Terminate diff -Nrc3pad gcc-3.2.3/gcc/ada/a-except.ads gcc-3.3/gcc/ada/a-except.ads *** gcc-3.2.3/gcc/ada/a-except.ads 2002-05-04 03:27:21.000000000 +0000 --- gcc-3.3/gcc/ada/a-except.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** package Ada.Exceptions is *** 85,91 **** -- PID=nnnn -- 0xyyyyyyyy 0xyyyyyyyy ... -- ! -- The lines are separated by an ASCII.CR/ASCII.LF sequence. -- The nnnn is the partition Id given as decimal digits. -- The 0x... line represents traceback program counter locations, -- in order with the first one being the exception location. --- 84,90 ---- -- PID=nnnn -- 0xyyyyyyyy 0xyyyyyyyy ... -- ! -- The lines are separated by a ASCII.LF character -- The nnnn is the partition Id given as decimal digits. -- The 0x... line represents traceback program counter locations, -- in order with the first one being the exception location. *************** package Ada.Exceptions is *** 100,106 **** function Save_Occurrence (Source : Exception_Occurrence) ! return Exception_Occurrence_Access; private package SSL renames System.Standard_Library; --- 99,105 ---- function Save_Occurrence (Source : Exception_Occurrence) ! return Exception_Occurrence_Access; private package SSL renames System.Standard_Library; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-excpol.adb gcc-3.3/gcc/ada/a-excpol.adb *** gcc-3.2.3/gcc/ada/a-excpol.adb 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-excpol.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 7,13 **** -- B o d y -- -- (dummy version where polling is not used) -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-exctra.adb gcc-3.3/gcc/ada/a-exctra.adb *** gcc-3.2.3/gcc/ada/a-exctra.adb 2002-05-04 03:27:21.000000000 +0000 --- gcc-3.3/gcc/ada/a-exctra.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-exctra.ads gcc-3.3/gcc/ada/a-exctra.ads *** gcc-3.2.3/gcc/ada/a-exctra.ads 2002-05-04 03:27:21.000000000 +0000 --- gcc-3.3/gcc/ada/a-exctra.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-filico.adb gcc-3.3/gcc/ada/a-filico.adb *** gcc-3.2.3/gcc/ada/a-filico.adb 2002-05-04 03:27:21.000000000 +0000 --- gcc-3.3/gcc/ada/a-filico.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-filico.ads gcc-3.3/gcc/ada/a-filico.ads *** gcc-3.2.3/gcc/ada/a-filico.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-filico.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-finali.adb gcc-3.3/gcc/ada/a-finali.adb *** gcc-3.2.3/gcc/ada/a-finali.adb 2002-05-04 03:27:21.000000000 +0000 --- gcc-3.3/gcc/ada/a-finali.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Ada.Finalization is *** 51,56 **** --- 50,57 ---- ------------ procedure Adjust (Object : in out Controlled) is + pragma Warnings (Off, Object); + begin null; end Adjust; *************** package body Ada.Finalization is *** 60,70 **** --- 61,75 ---- -------------- procedure Finalize (Object : in out Controlled) is + pragma Warnings (Off, Object); + begin null; end Finalize; procedure Finalize (Object : in out Limited_Controlled) is + pragma Warnings (Off, Object); + begin null; end Finalize; *************** package body Ada.Finalization is *** 74,84 **** --- 79,93 ---- ---------------- procedure Initialize (Object : in out Controlled) is + pragma Warnings (Off, Object); + begin null; end Initialize; procedure Initialize (Object : in out Limited_Controlled) is + pragma Warnings (Off, Object); + begin null; end Initialize; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-finali.ads gcc-3.3/gcc/ada/a-finali.ads *** gcc-3.2.3/gcc/ada/a-finali.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-finali.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-flteio.ads gcc-3.3/gcc/ada/a-flteio.ads *** gcc-3.2.3/gcc/ada/a-flteio.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-flteio.ads 2002-03-14 10:58:48.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-fwteio.ads gcc-3.3/gcc/ada/a-fwteio.ads *** gcc-3.2.3/gcc/ada/a-fwteio.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-fwteio.ads 2002-03-14 10:58:48.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-inteio.ads gcc-3.3/gcc/ada/a-inteio.ads *** gcc-3.2.3/gcc/ada/a-inteio.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-inteio.ads 2002-03-14 10:58:48.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-interr.adb gcc-3.3/gcc/ada/a-interr.adb *** gcc-3.2.3/gcc/ada/a-interr.adb 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-interr.adb 2002-03-14 10:58:48.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-interr.ads gcc-3.3/gcc/ada/a-interr.ads *** gcc-3.2.3/gcc/ada/a-interr.ads 2002-05-04 03:27:21.000000000 +0000 --- gcc-3.3/gcc/ada/a-interr.ads 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-intnam.ads gcc-3.3/gcc/ada/a-intnam.ads *** gcc-3.2.3/gcc/ada/a-intnam.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-intnam.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-intsig.adb gcc-3.3/gcc/ada/a-intsig.adb *** gcc-3.2.3/gcc/ada/a-intsig.adb 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-intsig.adb 2002-10-23 07:33:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-intsig.ads gcc-3.3/gcc/ada/a-intsig.ads *** gcc-3.2.3/gcc/ada/a-intsig.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-intsig.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ioexce.ads gcc-3.3/gcc/ada/a-ioexce.ads *** gcc-3.2.3/gcc/ada/a-ioexce.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-ioexce.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-iwteio.ads gcc-3.3/gcc/ada/a-iwteio.ads *** gcc-3.2.3/gcc/ada/a-iwteio.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-iwteio.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-lfteio.ads gcc-3.3/gcc/ada/a-lfteio.ads *** gcc-3.2.3/gcc/ada/a-lfteio.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-lfteio.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-lfwtio.ads gcc-3.3/gcc/ada/a-lfwtio.ads *** gcc-3.2.3/gcc/ada/a-lfwtio.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-lfwtio.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/ali.adb gcc-3.3/gcc/ada/ali.adb *** gcc-3.2.3/gcc/ada/ali.adb 2002-05-04 03:27:31.000000000 +0000 --- gcc-3.3/gcc/ada/ali.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.6.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body ALI is *** 127,140 **** function Get_Name (Lower : Boolean := False) return Name_Id; -- Skip blanks, then scan out a name (name is left in Name_Buffer with ! -- length in Name_Len, as well as being returned in Name_Id form). The ! -- name is adjusted appropriately if it refers to a file that is to be ! -- substituted by another name as a result of a configuration pragma. ! -- If Lower is set to true then the Name_Buffer will be converted to ! -- all lower case. This only happends for systems where file names are ! -- not case sensitive, and ensures that gnatbind works correctly on ! -- such systems, regardless of the case of the file name. Note that ! -- a name can be terminated by a right typeref bracket or '='. function Get_Nat return Nat; -- Skip blanks, then scan out an unsigned integer value in Nat range --- 126,139 ---- function Get_Name (Lower : Boolean := False) return Name_Id; -- Skip blanks, then scan out a name (name is left in Name_Buffer with ! -- length in Name_Len, as well as being returned in Name_Id form). ! -- If Lower is set to True then the Name_Buffer will be converted to ! -- all lower case, for systems where file names are not case sensitive. ! -- This ensures that gnatbind works correctly regardless of the case ! -- of the file name on all systems. The name is terminated by a either ! -- white space or a typeref bracket or an equal sign except for the ! -- special case of an operator name starting with a double quite which ! -- is terminated by another double quote. function Get_Nat return Nat; -- Skip blanks, then scan out an unsigned integer value in Nat range *************** package body ALI is *** 305,315 **** loop Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := Getc; ! exit when At_End_Of_Field ! or else Nextc = ')' ! or else Nextc = '}' ! or else Nextc = '>' ! or else Nextc = '='; end loop; -- Convert file name to all lower case if file names are not case --- 304,322 ---- loop Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := Getc; ! ! exit when At_End_Of_Field; ! ! if Name_Buffer (1) = '"' then ! exit when Name_Len > 1 and then Name_Buffer (Name_Len) = '"'; ! ! else ! exit when At_End_Of_Field ! or else Nextc = '(' or else Nextc = ')' ! or else Nextc = '{' or else Nextc = '}' ! or else Nextc = '<' or else Nextc = '>' ! or else Nextc = '='; ! end if; end loop; -- Convert file name to all lower case if file names are not case *************** package body ALI is *** 639,652 **** Checkc (' '); Skip_Space; ! for J in Partition_Restrictions loop C := Getc; ! if C = 'v' or else C = 'r' or else C = 'n' then ! ALIs.Table (Id).Restrictions (J) := C; ! else ! Fatal_Error; ! end if; end loop; if At_Eol then --- 646,670 ---- Checkc (' '); Skip_Space; ! for J in All_Restrictions loop C := Getc; + ALIs.Table (Id).Restrictions (J) := C; ! case C is ! when 'v' => ! Restrictions (J) := 'v'; ! ! when 'r' => ! if Restrictions (J) = 'n' then ! Restrictions (J) := 'r'; ! end if; ! ! when 'n' => ! null; ! ! when others => ! Fatal_Error; ! end case; end loop; if At_Eol then *************** package body ALI is *** 694,699 **** --- 712,719 ---- if Debug_Flag_U then Write_Str (" ----> reading unit "); + Write_Int (Int (Units.Last)); + Write_Str (" "); Write_Unit_Name (Units.Table (Units.Last).Uname); Write_Str (" from file "); Write_Name (Units.Table (Units.Last).Sfile); *************** package body ALI is *** 710,724 **** and then Units.Table (Units.Last).Sfile /= Units.Table (Unit_Id (Info)).Sfile then ! -- If Err is set then treat duplicate unit name as an instance ! -- of a bad ALI format. This is the case of being called from ! -- gnatmake, and the point is that if anything is wrong with ! -- the ALI file, then gnatmake should just recompile. if Err then ! raise Bad_ALI_Format; ! -- If Err is not set, then this is a fatal error else Set_Standard_Error; --- 730,751 ---- and then Units.Table (Units.Last).Sfile /= Units.Table (Unit_Id (Info)).Sfile then ! -- If Err is set then ignore duplicate unit name. This is the ! -- case of a call from gnatmake, where the situation can arise ! -- from substitution of source files. In such situations, the ! -- processing in gnatmake will always result in any required ! -- recompilations in any case, and if we consider this to be ! -- an error we get strange cases (for example when a generic ! -- instantiation is replaced by a normal package) where we ! -- read the old ali file, decide to recompile, and then decide ! -- that the old and new ali files are incompatible. if Err then ! null; ! -- If Err is not set, then this is a fatal error. This is ! -- the case of being called from the binder, where we must ! -- definitely diagnose this as an error. else Set_Standard_Error; *************** package body ALI is *** 991,1098 **** Units.Table (Units.Last).Last_With := Withs.Last; Units.Table (Units.Last).Last_Arg := Args.Last; ! end loop Unit_Loop; ! ! -- End loop through units for one ALI file ! ALIs.Table (Id).Last_Unit := Units.Last; ! ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile; ! -- Set types of the units (there can be at most 2 of them) ! if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then ! Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body; ! Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec; ! else ! -- Deal with body only and spec only cases, note that the reason we ! -- do our own checking of the name (rather than using Is_Body_Name) ! -- is that Uname drags in far too much compiler junk! ! Get_Name_String (Units.Table (Units.Last).Uname); ! if Name_Buffer (Name_Len) = 'b' then ! Units.Table (Units.Last).Utype := Is_Body_Only; ! else ! Units.Table (Units.Last).Utype := Is_Spec_Only; ! end if; ! end if; ! -- If there are linker options lines present, scan them ! while C = 'L' loop ! Checkc (' '); ! Skip_Space; ! Checkc ('"'); ! Name_Len := 0; ! loop ! C := Getc; ! if C < Character'Val (16#20#) ! or else C > Character'Val (16#7E#) ! then ! Fatal_Error; ! elsif C = '{' then ! C := Character'Val (0); ! declare ! V : Natural; ! begin ! V := 0; ! for J in 1 .. 2 loop C := Getc; ! if C in '0' .. '9' then ! V := V * 16 + ! Character'Pos (C) - Character'Pos ('0'); ! elsif C in 'A' .. 'F' then ! V := V * 16 + ! Character'Pos (C) - Character'Pos ('A') + 10; ! else ! Fatal_Error; ! end if; ! end loop; ! Checkc ('}'); ! Add_Char_To_Name_Buffer (Character'Val (V)); ! end; ! else ! if C = '"' then ! exit when Nextc /= '"'; ! C := Getc; ! end if; ! Add_Char_To_Name_Buffer (C); ! end if; ! end loop; ! Add_Char_To_Name_Buffer (nul); ! Skip_Eol; ! C := Getc; ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last).Name ! := Name_Enter; ! Linker_Options.Table (Linker_Options.Last).Unit ! := ALIs.Table (Id).First_Unit; ! Linker_Options.Table (Linker_Options.Last).Internal_File ! := Is_Internal_File_Name (F); ! Linker_Options.Table (Linker_Options.Last).Original_Pos ! := Linker_Options.Last; ! end loop; -- Scan out external version references and put in hash table --- 1018,1128 ---- Units.Table (Units.Last).Last_With := Withs.Last; Units.Table (Units.Last).Last_Arg := Args.Last; ! -- If there are linker options lines present, scan them ! Name_Len := 0; ! Linker_Options_Loop : while C = 'L' loop ! Checkc (' '); ! Skip_Space; ! Checkc ('"'); ! loop ! C := Getc; ! if C < Character'Val (16#20#) ! or else C > Character'Val (16#7E#) ! then ! Fatal_Error; ! elsif C = '{' then ! C := Character'Val (0); ! declare ! V : Natural; ! begin ! V := 0; ! for J in 1 .. 2 loop ! C := Getc; ! if C in '0' .. '9' then ! V := V * 16 + ! Character'Pos (C) - Character'Pos ('0'); ! elsif C in 'A' .. 'F' then ! V := V * 16 + ! Character'Pos (C) - Character'Pos ('A') + 10; ! else ! Fatal_Error; ! end if; ! end loop; ! Checkc ('}'); ! Add_Char_To_Name_Buffer (Character'Val (V)); ! end; ! else ! if C = '"' then ! exit when Nextc /= '"'; C := Getc; + end if; ! Add_Char_To_Name_Buffer (C); ! end if; ! end loop; ! Add_Char_To_Name_Buffer (nul); ! Skip_Eol; ! C := Getc; ! end loop Linker_Options_Loop; ! -- Store the linker options entry ! if Name_Len /= 0 then ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last).Name := ! Name_Enter; ! Linker_Options.Table (Linker_Options.Last).Unit := ! Units.Last; ! Linker_Options.Table (Linker_Options.Last).Internal_File := ! Is_Internal_File_Name (F); ! Linker_Options.Table (Linker_Options.Last).Original_Pos := ! Linker_Options.Last; ! end if; ! end loop Unit_Loop; ! -- End loop through units for one ALI file ! ALIs.Table (Id).Last_Unit := Units.Last; ! ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile; ! -- Set types of the units (there can be at most 2 of them) ! if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then ! Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body; ! Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec; ! else ! -- Deal with body only and spec only cases, note that the reason we ! -- do our own checking of the name (rather than using Is_Body_Name) ! -- is that Uname drags in far too much compiler junk! ! Get_Name_String (Units.Table (Units.Last).Uname); ! ! if Name_Buffer (Name_Len) = 'b' then ! Units.Table (Units.Last).Utype := Is_Body_Only; ! else ! Units.Table (Units.Last).Utype := Is_Spec_Only; ! end if; ! end if; -- Scan out external version references and put in hash table diff -Nrc3pad gcc-3.2.3/gcc/ada/ali.ads gcc-3.3/gcc/ada/ali.ads *** gcc-3.2.3/gcc/ada/ali.ads 2002-05-04 03:27:31.000000000 +0000 --- gcc-3.3/gcc/ada/ali.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.6.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package ALI is *** 81,87 **** type Main_Program_Type is (None, Proc, Func); -- Indicator of whether unit can be used as main program ! type Restrictions_String is array (Partition_Restrictions) of Character; -- Type used to hold string from R line type ALIs_Record is record --- 80,86 ---- type Main_Program_Type is (None, Proc, Func); -- Indicator of whether unit can be used as main program ! type Restrictions_String is array (All_Restrictions) of Character; -- Type used to hold string from R line type ALIs_Record is record *************** package ALI is *** 363,368 **** --- 362,373 ---- -- Set to blank by Initialize_ALI. Set to the appropriate queuing policy -- character if an ali file contains a P line setting the queuing policy. + Restrictions : Restrictions_String := (others => 'n'); + -- This array records the cumulative contributions of R lines in all + -- ali files. An entry is changed will be set to v if any ali file + -- indicates that the restriction is violated, and otherwise will be + -- set to r if the restriction is specified by some unit. + Static_Elaboration_Model_Used : Boolean := False; -- Set to False by Initialize_ALI. Set to True if any ALI file for a -- non-internal unit compiled with the static elaboration model is *************** package ALI is *** 447,463 **** -- Linker_Options Table -- -------------------------- ! -- Each unique linker option (L line) in an ALI file generates ! -- an entry in the Linker_Options table. Note that only unique ! -- entries are stored, i.e. if the same entry appears twice, the ! -- second entry is suppressed. Each entry is a character sequence ! -- terminated by a NUL character. type Linker_Option_Record is record ! Name : Name_Id; ! Unit : Unit_Id; Internal_File : Boolean; ! Original_Pos : Positive; end record; -- Declare the Linker_Options Table --- 452,480 ---- -- Linker_Options Table -- -------------------------- ! -- If an ALI file has one of more Linker_Options lines, then a single ! -- entry is made in this table. If more than one Linker_Options lines ! -- appears in a given ALI file, then the arguments are concatenated ! -- to form the entry in this table, using a NUL character as the ! -- separator, and a final NUL character is appended to the end. type Linker_Option_Record is record ! Name : Name_Id; ! -- Name entry containing concatenated list of Linker_Options ! -- arguments separated by NUL and ended by NUL as described above. ! ! Unit : Unit_Id; ! -- Unit_Id for the entry ! Internal_File : Boolean; ! -- Set True if the linker options are from an internal file. This is ! -- used to insert certain standard entries after all the user entries ! -- but before the entries from the run-time. ! ! Original_Pos : Positive; ! -- Keep track of original position in the linker options table. This ! -- is used to implement a stable sort when we sort the linker options ! -- table. end record; -- Declare the Linker_Options Table diff -Nrc3pad gcc-3.2.3/gcc/ada/a-liteio.ads gcc-3.3/gcc/ada/a-liteio.ads *** gcc-3.2.3/gcc/ada/a-liteio.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-liteio.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/ali-util.adb gcc-3.3/gcc/ada/ali-util.adb *** gcc-3.2.3/gcc/ada/ali-util.adb 2002-05-04 03:27:31.000000000 +0000 --- gcc-3.3/gcc/ada/ali-util.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Opt; use Opt; *** 32,37 **** --- 31,38 ---- with Osint; use Osint; with System.CRC32; + with System.Memory; + with System.Address_To_Access_Conversions; package body ALI.Util is *************** package body ALI.Util is *** 91,101 **** -- Free source file buffer procedure Free_Source is ! procedure free (Arg : Source_Buffer_Ptr); ! pragma Import (C, free, "free"); begin ! free (Src); end Free_Source; -- Start of processing for Get_File_Checksum --- 92,103 ---- -- Free source file buffer procedure Free_Source is ! ! package SB is ! new System.Address_To_Access_Conversions (Big_Source_Buffer); begin ! System.Memory.Free (SB.To_Address (SB.Object_Pointer (Src))); end Free_Source; -- Start of processing for Get_File_Checksum diff -Nrc3pad gcc-3.2.3/gcc/ada/ali-util.ads gcc-3.3/gcc/ada/ali-util.ads *** gcc-3.2.3/gcc/ada/ali-util.ads 2002-05-04 03:27:31.000000000 +0000 --- gcc-3.3/gcc/ada/ali-util.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-liwtio.ads gcc-3.3/gcc/ada/a-liwtio.ads *** gcc-3.2.3/gcc/ada/a-liwtio.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-liwtio.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-llftio.ads gcc-3.3/gcc/ada/a-llftio.ads *** gcc-3.2.3/gcc/ada/a-llftio.ads 2002-05-07 08:22:05.000000000 +0000 --- gcc-3.3/gcc/ada/a-llftio.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-llfwti.ads gcc-3.3/gcc/ada/a-llfwti.ads *** gcc-3.2.3/gcc/ada/a-llfwti.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-llfwti.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-llitio.ads gcc-3.3/gcc/ada/a-llitio.ads *** gcc-3.2.3/gcc/ada/a-llitio.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-llitio.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-lliwti.ads gcc-3.3/gcc/ada/a-lliwti.ads *** gcc-3.2.3/gcc/ada/a-lliwti.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-lliwti.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/alloc.ads gcc-3.3/gcc/ada/alloc.ads *** gcc-3.2.3/gcc/ada/alloc.ads 2002-05-04 03:27:32.000000000 +0000 --- gcc-3.3/gcc/ada/alloc.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ncelfu.ads gcc-3.3/gcc/ada/a-ncelfu.ads *** gcc-3.2.3/gcc/ada/a-ncelfu.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-ncelfu.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- *************** with Ada.Numerics.Generic_Complex_Elemen *** 21,23 **** --- 20,24 ---- package Ada.Numerics.Complex_Elementary_Functions is new Ada.Numerics.Generic_Complex_Elementary_Functions (Ada.Numerics.Complex_Types); + + pragma Pure (Ada.Numerics.Complex_Elementary_Functions); diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ngcefu.adb gcc-3.3/gcc/ada/a-ngcefu.adb *** gcc-3.2.3/gcc/ada/a-ngcefu.adb 2002-05-04 03:27:22.000000000 +0000 --- gcc-3.3/gcc/ada/a-ngcefu.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ngcefu.ads gcc-3.3/gcc/ada/a-ngcefu.ads *** gcc-3.2.3/gcc/ada/a-ngcefu.ads 2001-10-02 13:51:52.000000000 +0000 --- gcc-3.3/gcc/ada/a-ngcefu.ads 2002-03-14 10:58:49.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ngcoty.adb gcc-3.3/gcc/ada/a-ngcoty.adb *** gcc-3.2.3/gcc/ada/a-ngcoty.adb 2002-05-04 03:27:22.000000000 +0000 --- gcc-3.3/gcc/ada/a-ngcoty.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ngcoty.ads gcc-3.3/gcc/ada/a-ngcoty.ads *** gcc-3.2.3/gcc/ada/a-ngcoty.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-ngcoty.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ngelfu.adb gcc-3.3/gcc/ada/a-ngelfu.adb *** gcc-3.2.3/gcc/ada/a-ngelfu.adb 2002-05-04 03:27:22.000000000 +0000 --- gcc-3.3/gcc/ada/a-ngelfu.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ngelfu.ads gcc-3.3/gcc/ada/a-ngelfu.ads *** gcc-3.2.3/gcc/ada/a-ngelfu.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-ngelfu.ads 2002-03-14 10:58:50.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nlcefu.ads gcc-3.3/gcc/ada/a-nlcefu.ads *** gcc-3.2.3/gcc/ada/a-nlcefu.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nlcefu.ads 2002-03-14 10:58:50.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nlcoty.ads gcc-3.3/gcc/ada/a-nlcoty.ads *** gcc-3.2.3/gcc/ada/a-nlcoty.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nlcoty.ads 2002-03-14 10:58:50.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nlelfu.ads gcc-3.3/gcc/ada/a-nlelfu.ads *** gcc-3.2.3/gcc/ada/a-nlelfu.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nlelfu.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nllcef.ads gcc-3.3/gcc/ada/a-nllcef.ads *** gcc-3.2.3/gcc/ada/a-nllcef.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nllcef.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nllcty.ads gcc-3.3/gcc/ada/a-nllcty.ads *** gcc-3.2.3/gcc/ada/a-nllcty.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nllcty.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nllefu.ads gcc-3.3/gcc/ada/a-nllefu.ads *** gcc-3.2.3/gcc/ada/a-nllefu.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nllefu.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nscefu.ads gcc-3.3/gcc/ada/a-nscefu.ads *** gcc-3.2.3/gcc/ada/a-nscefu.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nscefu.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nscoty.ads gcc-3.3/gcc/ada/a-nscoty.ads *** gcc-3.2.3/gcc/ada/a-nscoty.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nscoty.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nselfu.ads gcc-3.3/gcc/ada/a-nselfu.ads *** gcc-3.2.3/gcc/ada/a-nselfu.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nselfu.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nucoty.ads gcc-3.3/gcc/ada/a-nucoty.ads *** gcc-3.2.3/gcc/ada/a-nucoty.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nucoty.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nudira.adb gcc-3.3/gcc/ada/a-nudira.adb *** gcc-3.2.3/gcc/ada/a-nudira.adb 2002-05-04 03:27:22.000000000 +0000 --- gcc-3.3/gcc/ada/a-nudira.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nudira.ads gcc-3.3/gcc/ada/a-nudira.ads *** gcc-3.2.3/gcc/ada/a-nudira.ads 2002-05-04 03:27:22.000000000 +0000 --- gcc-3.3/gcc/ada/a-nudira.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nuelfu.ads gcc-3.3/gcc/ada/a-nuelfu.ads *** gcc-3.2.3/gcc/ada/a-nuelfu.ads 2001-10-02 13:51:52.000000000 +0000 --- gcc-3.3/gcc/ada/a-nuelfu.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nuflra.adb gcc-3.3/gcc/ada/a-nuflra.adb *** gcc-3.2.3/gcc/ada/a-nuflra.adb 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nuflra.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-nuflra.ads gcc-3.3/gcc/ada/a-nuflra.ads *** gcc-3.2.3/gcc/ada/a-nuflra.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-nuflra.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-numaux.ads gcc-3.3/gcc/ada/a-numaux.ads *** gcc-3.2.3/gcc/ada/a-numaux.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-numaux.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (C Library Version, non-x86) -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-numeri.ads gcc-3.3/gcc/ada/a-numeri.ads *** gcc-3.2.3/gcc/ada/a-numeri.ads 2002-05-07 08:22:06.000000000 +0000 --- gcc-3.3/gcc/ada/a-numeri.ads 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-reatim.adb gcc-3.3/gcc/ada/a-reatim.adb *** gcc-3.2.3/gcc/ada/a-reatim.adb 2001-12-18 00:03:37.000000000 +0000 --- gcc-3.3/gcc/ada/a-reatim.adb 2002-03-14 10:58:51.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2002, Florida State University -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** package body Ada.Real_Time is *** 46,56 **** --- 44,56 ---- -- Note that Constraint_Error may be propagated function "*" (Left : Time_Span; Right : Integer) return Time_Span is + pragma Unsuppress (Overflow_Check); begin return Time_Span (Duration (Left) * Right); end "*"; function "*" (Left : Integer; Right : Time_Span) return Time_Span is + pragma Unsuppress (Overflow_Check); begin return Time_Span (Left * Duration (Right)); end "*"; *************** package body Ada.Real_Time is *** 62,77 **** --- 62,80 ---- -- Note that Constraint_Error may be propagated function "+" (Left : Time; Right : Time_Span) return Time is + pragma Unsuppress (Overflow_Check); begin return Time (Duration (Left) + Duration (Right)); end "+"; function "+" (Left : Time_Span; Right : Time) return Time is + pragma Unsuppress (Overflow_Check); begin return Time (Duration (Left) + Duration (Right)); end "+"; function "+" (Left, Right : Time_Span) return Time_Span is + pragma Unsuppress (Overflow_Check); begin return Time_Span (Duration (Left) + Duration (Right)); end "+"; *************** package body Ada.Real_Time is *** 83,103 **** --- 86,110 ---- -- Note that Constraint_Error may be propagated function "-" (Left : Time; Right : Time_Span) return Time is + pragma Unsuppress (Overflow_Check); begin return Time (Duration (Left) - Duration (Right)); end "-"; function "-" (Left, Right : Time) return Time_Span is + pragma Unsuppress (Overflow_Check); begin return Time_Span (Duration (Left) - Duration (Right)); end "-"; function "-" (Left, Right : Time_Span) return Time_Span is + pragma Unsuppress (Overflow_Check); begin return Time_Span (Duration (Left) - Duration (Right)); end "-"; function "-" (Right : Time_Span) return Time_Span is + pragma Unsuppress (Overflow_Check); begin return Time_Span_Zero - Right; end "-"; *************** package body Ada.Real_Time is *** 109,119 **** --- 116,128 ---- -- Note that Constraint_Error may be propagated function "/" (Left, Right : Time_Span) return Integer is + pragma Unsuppress (Overflow_Check); begin return Integer (Duration (Left) / Duration (Right)); end "/"; function "/" (Left : Time_Span; Right : Integer) return Time_Span is + pragma Unsuppress (Overflow_Check); begin return Time_Span (Duration (Left) / Right); end "/"; *************** package body Ada.Real_Time is *** 190,196 **** SC := SC - 1; end if; ! TS := T - Time (SC); end Split; ------------- --- 199,205 ---- SC := SC - 1; end if; ! TS := Time_Span (Duration (T) - Duration (SC)); end Split; ------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-reatim.ads gcc-3.3/gcc/ada/a-reatim.ads *** gcc-3.2.3/gcc/ada/a-reatim.ads 2002-05-04 03:27:23.000000000 +0000 --- gcc-3.3/gcc/ada/a-reatim.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-retide.adb gcc-3.3/gcc/ada/a-retide.adb *** gcc-3.2.3/gcc/ada/a-retide.adb 2001-10-02 13:51:52.000000000 +0000 --- gcc-3.3/gcc/ada/a-retide.adb 2002-10-28 16:19:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-1999 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 28,49 **** -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ with System.Task_Primitives.Operations; -- Used for Timed_Delay - with System.OS_Primitives; - -- Used for Delay_Modes - package body Ada.Real_Time.Delays is package STPO renames System.Task_Primitives.Operations; ! package OSP renames System.OS_Primitives; ----------------- -- Delay_Until -- --- 27,45 ---- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- ! -- GNARL was developed by the GNARL team at Florida State University. -- ! -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ with System.Task_Primitives.Operations; -- Used for Timed_Delay package body Ada.Real_Time.Delays is package STPO renames System.Task_Primitives.Operations; ! ! Absolute_RT : constant := 2; ----------------- -- Delay_Until -- *************** package body Ada.Real_Time.Delays is *** 51,57 **** procedure Delay_Until (T : Time) is begin ! STPO.Timed_Delay (STPO.Self, To_Duration (T), OSP.Absolute_RT); end Delay_Until; ----------------- --- 47,53 ---- procedure Delay_Until (T : Time) is begin ! STPO.Timed_Delay (STPO.Self, To_Duration (T), Absolute_RT); end Delay_Until; ----------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-retide.ads gcc-3.3/gcc/ada/a-retide.ads *** gcc-3.2.3/gcc/ada/a-retide.ads 2002-05-04 03:27:23.000000000 +0000 --- gcc-3.3/gcc/ada/a-retide.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/argv.c gcc-3.3/gcc/ada/argv.c *** gcc-3.2.3/gcc/ada/argv.c 2002-05-04 03:27:32.000000000 +0000 --- gcc-3.3/gcc/ada/argv.c 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * C Implementation File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-sequio.adb gcc-3.3/gcc/ada/a-sequio.adb *** gcc-3.2.3/gcc/ada/a-sequio.adb 2002-05-04 03:27:23.000000000 +0000 --- gcc-3.3/gcc/ada/a-sequio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-sequio.ads gcc-3.3/gcc/ada/a-sequio.ads *** gcc-3.2.3/gcc/ada/a-sequio.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-sequio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-sfteio.ads gcc-3.3/gcc/ada/a-sfteio.ads *** gcc-3.2.3/gcc/ada/a-sfteio.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-sfteio.ads 2002-03-14 10:58:52.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-sfwtio.ads gcc-3.3/gcc/ada/a-sfwtio.ads *** gcc-3.2.3/gcc/ada/a-sfwtio.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-sfwtio.ads 2002-03-14 10:58:52.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-siocst.adb gcc-3.3/gcc/ada/a-siocst.adb *** gcc-3.2.3/gcc/ada/a-siocst.adb 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-siocst.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-siocst.ads gcc-3.3/gcc/ada/a-siocst.ads *** gcc-3.2.3/gcc/ada/a-siocst.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-siocst.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-siteio.ads gcc-3.3/gcc/ada/a-siteio.ads *** gcc-3.2.3/gcc/ada/a-siteio.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-siteio.ads 2002-03-14 10:58:52.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-siwtio.ads gcc-3.3/gcc/ada/a-siwtio.ads *** gcc-3.2.3/gcc/ada/a-siwtio.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-siwtio.ads 2002-03-14 10:58:52.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ssicst.adb gcc-3.3/gcc/ada/a-ssicst.adb *** gcc-3.2.3/gcc/ada/a-ssicst.adb 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-ssicst.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ssicst.ads gcc-3.3/gcc/ada/a-ssicst.ads *** gcc-3.2.3/gcc/ada/a-ssicst.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-ssicst.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ssitio.ads gcc-3.3/gcc/ada/a-ssitio.ads *** gcc-3.2.3/gcc/ada/a-ssitio.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-ssitio.ads 2002-03-14 10:58:52.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ssiwti.ads gcc-3.3/gcc/ada/a-ssiwti.ads *** gcc-3.2.3/gcc/ada/a-ssiwti.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-ssiwti.ads 2002-03-14 10:58:52.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stmaco.ads gcc-3.3/gcc/ada/a-stmaco.ads *** gcc-3.2.3/gcc/ada/a-stmaco.ads 2002-05-04 03:27:23.000000000 +0000 --- gcc-3.3/gcc/ada/a-stmaco.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-storio.adb gcc-3.3/gcc/ada/a-storio.adb *** gcc-3.2.3/gcc/ada/a-storio.adb 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-storio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-storio.ads gcc-3.3/gcc/ada/a-storio.ads *** gcc-3.2.3/gcc/ada/a-storio.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-storio.ads 2002-03-14 10:58:52.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strbou.adb gcc-3.3/gcc/ada/a-strbou.adb *** gcc-3.2.3/gcc/ada/a-strbou.adb 2002-05-04 03:27:23.000000000 +0000 --- gcc-3.3/gcc/ada/a-strbou.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strbou.ads gcc-3.3/gcc/ada/a-strbou.ads *** gcc-3.2.3/gcc/ada/a-strbou.ads 2002-05-04 03:27:23.000000000 +0000 --- gcc-3.3/gcc/ada/a-strbou.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stream.ads gcc-3.3/gcc/ada/a-stream.ads *** gcc-3.2.3/gcc/ada/a-stream.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-stream.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** pragma Pure (Streams); *** 53,59 **** Stream_Element_Offset range 0 .. Stream_Element_Offset'Last; type Stream_Element_Array is ! array (Stream_Element_Offset range <>) of Stream_Element; procedure Read (Stream : in out Root_Stream_Type; --- 52,58 ---- Stream_Element_Offset range 0 .. Stream_Element_Offset'Last; type Stream_Element_Array is ! array (Stream_Element_Offset range <>) of aliased Stream_Element; procedure Read (Stream : in out Root_Stream_Type; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strfix.adb gcc-3.3/gcc/ada/a-strfix.adb *** gcc-3.2.3/gcc/ada/a-strfix.adb 2002-05-04 03:27:23.000000000 +0000 --- gcc-3.3/gcc/ada/a-strfix.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strfix.ads gcc-3.3/gcc/ada/a-strfix.ads *** gcc-3.2.3/gcc/ada/a-strfix.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-strfix.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-string.ads gcc-3.3/gcc/ada/a-string.ads *** gcc-3.2.3/gcc/ada/a-string.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-string.ads 2002-03-14 10:58:53.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strmap.adb gcc-3.3/gcc/ada/a-strmap.adb *** gcc-3.2.3/gcc/ada/a-strmap.adb 2002-05-04 03:27:24.000000000 +0000 --- gcc-3.3/gcc/ada/a-strmap.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strmap.ads gcc-3.3/gcc/ada/a-strmap.ads *** gcc-3.2.3/gcc/ada/a-strmap.ads 2002-05-04 03:27:24.000000000 +0000 --- gcc-3.3/gcc/ada/a-strmap.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strsea.adb gcc-3.3/gcc/ada/a-strsea.adb *** gcc-3.2.3/gcc/ada/a-strsea.adb 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-strsea.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strsea.ads gcc-3.3/gcc/ada/a-strsea.ads *** gcc-3.2.3/gcc/ada/a-strsea.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-strsea.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strunb.adb gcc-3.3/gcc/ada/a-strunb.adb *** gcc-3.2.3/gcc/ada/a-strunb.adb 2002-05-04 03:27:24.000000000 +0000 --- gcc-3.3/gcc/ada/a-strunb.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-strunb.ads gcc-3.3/gcc/ada/a-strunb.ads *** gcc-3.2.3/gcc/ada/a-strunb.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-strunb.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ststio.adb gcc-3.3/gcc/ada/a-ststio.adb *** gcc-3.2.3/gcc/ada/a-ststio.adb 2002-05-04 03:27:24.000000000 +0000 --- gcc-3.3/gcc/ada/a-ststio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, 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- -- *************** package body Ada.Streams.Stream_IO is *** 64,69 **** --- 63,70 ---- ------------------- function AFCB_Allocate (Control_Block : Stream_AFCB) return FCB.AFCB_Ptr is + pragma Warnings (Off, Control_Block); + begin return new Stream_AFCB; end AFCB_Allocate; *************** package body Ada.Streams.Stream_IO is *** 75,80 **** --- 76,83 ---- -- No special processing required for closing Stream_IO file procedure AFCB_Close (File : access Stream_AFCB) is + pragma Warnings (Off, File); + begin null; end AFCB_Close; *************** package body Ada.Streams.Stream_IO is *** 149,155 **** -- Flush -- ----------- ! procedure Flush (File : in out File_Type) is begin FIO.Flush (AP (File)); end Flush; --- 152,158 ---- -- Flush -- ----------- ! procedure Flush (File : File_Type) is begin FIO.Flush (AP (File)); end Flush; *************** package body Ada.Streams.Stream_IO is *** 261,270 **** if File.Last_Op /= Op_Read or else File.Shared_Status = FCB.Yes then - if End_Of_File (File) then - raise End_Error; - end if; - Locked_Processing : begin SSL.Lock_Task.all; Set_Position (File); --- 264,269 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ststio.ads gcc-3.3/gcc/ada/a-ststio.ads *** gcc-3.2.3/gcc/ada/a-ststio.ads 2002-05-07 08:22:07.000000000 +0000 --- gcc-3.3/gcc/ada/a-ststio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** package Ada.Streams.Stream_IO is *** 128,134 **** procedure Set_Mode (File : in out File_Type; Mode : in File_Mode); ! procedure Flush (File : in out File_Type); ---------------- -- Exceptions -- --- 127,136 ---- procedure Set_Mode (File : in out File_Type; Mode : in File_Mode); ! -- Note: The parameter file is IN OUT in the RM, but this is clearly ! -- an oversight, and was intended to be IN, see AI95-00057. ! ! procedure Flush (File : File_Type); ---------------- -- Exceptions -- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stunau.adb gcc-3.3/gcc/ada/a-stunau.adb *** gcc-3.2.3/gcc/ada/a-stunau.adb 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-stunau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stunau.ads gcc-3.3/gcc/ada/a-stunau.ads *** gcc-3.2.3/gcc/ada/a-stunau.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-stunau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwibo.adb gcc-3.3/gcc/ada/a-stwibo.adb *** gcc-3.2.3/gcc/ada/a-stwibo.adb 2002-05-04 03:27:24.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwibo.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwibo.ads gcc-3.3/gcc/ada/a-stwibo.ads *** gcc-3.2.3/gcc/ada/a-stwibo.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwibo.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwifi.adb gcc-3.3/gcc/ada/a-stwifi.adb *** gcc-3.2.3/gcc/ada/a-stwifi.adb 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwifi.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1997 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** *** 33,39 **** -- -- ------------------------------------------------------------------------------ - with Ada.Strings.Wide_Maps; use Ada.Strings.Wide_Maps; with Ada.Strings.Wide_Search; --- 32,37 ---- *************** package body Ada.Strings.Wide_Fixed is *** 158,166 **** else declare ! Result : constant Wide_String := ! Source (Source'First .. From - 1) & ! Source (Through + 1 .. Source'Last); begin return Result; end; --- 156,166 ---- else declare ! Len : constant Integer := Source'Length - (Through - From + 1); ! Result : constant ! Wide_String (Source'First .. Source'First + Len - 1) := ! Source (Source'First .. From - 1) & ! Source (Through + 1 .. Source'Last); begin return Result; end; *************** package body Ada.Strings.Wide_Fixed is *** 381,393 **** else declare Result_Length : Natural := ! Natural'Max (Source'Length, ! Position - Source'First + New_Item'Length); Result : Wide_String (1 .. Result_Length); begin Result := Source (Source'First .. Position - 1) & New_Item & ! Source (Position + New_Item'Length .. Source'Last); return Result; end; end if; --- 381,395 ---- else declare Result_Length : Natural := ! Natural'Max ! (Source'Length, ! Position - Source'First + New_Item'Length); ! Result : Wide_String (1 .. Result_Length); begin Result := Source (Source'First .. Position - 1) & New_Item & ! Source (Position + New_Item'Length .. Source'Last); return Result; end; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwifi.ads gcc-3.3/gcc/ada/a-stwifi.ads *** gcc-3.2.3/gcc/ada/a-stwifi.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwifi.ads 2002-03-14 10:58:54.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwima.adb gcc-3.3/gcc/ada/a-stwima.adb *** gcc-3.2.3/gcc/ada/a-stwima.adb 2002-05-04 03:27:24.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwima.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwima.ads gcc-3.3/gcc/ada/a-stwima.ads *** gcc-3.2.3/gcc/ada/a-stwima.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwima.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwise.adb gcc-3.3/gcc/ada/a-stwise.adb *** gcc-3.2.3/gcc/ada/a-stwise.adb 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwise.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwise.ads gcc-3.3/gcc/ada/a-stwise.ads *** gcc-3.2.3/gcc/ada/a-stwise.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwise.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwiun.adb gcc-3.3/gcc/ada/a-stwiun.adb *** gcc-3.2.3/gcc/ada/a-stwiun.adb 2002-05-04 03:27:25.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwiun.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-stwiun.ads gcc-3.3/gcc/ada/a-stwiun.ads *** gcc-3.2.3/gcc/ada/a-stwiun.ads 2002-05-04 03:27:25.000000000 +0000 --- gcc-3.3/gcc/ada/a-stwiun.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-suteio.adb gcc-3.3/gcc/ada/a-suteio.adb *** gcc-3.2.3/gcc/ada/a-suteio.adb 2002-05-04 03:27:25.000000000 +0000 --- gcc-3.3/gcc/ada/a-suteio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-suteio.ads gcc-3.3/gcc/ada/a-suteio.ads *** gcc-3.2.3/gcc/ada/a-suteio.ads 2002-05-04 03:27:25.000000000 +0000 --- gcc-3.3/gcc/ada/a-suteio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-swmwco.ads gcc-3.3/gcc/ada/a-swmwco.ads *** gcc-3.2.3/gcc/ada/a-swmwco.ads 2002-05-04 03:27:25.000000000 +0000 --- gcc-3.3/gcc/ada/a-swmwco.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-swuwti.adb gcc-3.3/gcc/ada/a-swuwti.adb *** gcc-3.2.3/gcc/ada/a-swuwti.adb 2002-05-04 03:27:25.000000000 +0000 --- gcc-3.3/gcc/ada/a-swuwti.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-swuwti.ads gcc-3.3/gcc/ada/a-swuwti.ads *** gcc-3.2.3/gcc/ada/a-swuwti.ads 2002-05-04 03:27:25.000000000 +0000 --- gcc-3.3/gcc/ada/a-swuwti.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-sytaco.adb gcc-3.3/gcc/ada/a-sytaco.adb *** gcc-3.2.3/gcc/ada/a-sytaco.adb 2002-05-04 03:27:25.000000000 +0000 --- gcc-3.3/gcc/ada/a-sytaco.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-sytaco.ads gcc-3.3/gcc/ada/a-sytaco.ads *** gcc-3.2.3/gcc/ada/a-sytaco.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-sytaco.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tags.adb gcc-3.3/gcc/ada/a-tags.adb *** gcc-3.2.3/gcc/ada/a-tags.adb 2002-05-04 03:27:26.000000000 +0000 --- gcc-3.3/gcc/ada/a-tags.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Ada.Tags is *** 63,70 **** -- | tags | -- +-------------------+ - use System; - subtype Cstring is String (Positive); type Cstring_Ptr is access all Cstring; type Tag_Table is array (Natural range <>) of Tag; --- 62,67 ---- *************** package body Ada.Tags is *** 93,113 **** ------------------------------------------- function To_Type_Specific_Data_Ptr is ! new Unchecked_Conversion (Address, Type_Specific_Data_Ptr); - function To_Address is new Unchecked_Conversion (Tag, Address); function To_Address is ! new Unchecked_Conversion (Type_Specific_Data_Ptr, Address); --------------------------------------------- -- Unchecked Conversions for String Fields -- --------------------------------------------- function To_Cstring_Ptr is ! new Unchecked_Conversion (Address, Cstring_Ptr); function To_Address is ! new Unchecked_Conversion (Cstring_Ptr, Address); ----------------------- -- Local Subprograms -- --- 90,109 ---- ------------------------------------------- function To_Type_Specific_Data_Ptr is ! new Unchecked_Conversion (S.Address, Type_Specific_Data_Ptr); function To_Address is ! new Unchecked_Conversion (Type_Specific_Data_Ptr, S.Address); --------------------------------------------- -- Unchecked Conversions for String Fields -- --------------------------------------------- function To_Cstring_Ptr is ! new Unchecked_Conversion (S.Address, Cstring_Ptr); function To_Address is ! new Unchecked_Conversion (Cstring_Ptr, S.Address); ----------------------- -- Local Subprograms -- *************** package body Ada.Tags is *** 130,137 **** package HTable_Subprograms is procedure Set_HT_Link (T : Tag; Next : Tag); function Get_HT_Link (T : Tag) return Tag; ! function Hash (F : Address) return HTable_Headers; ! function Equal (A, B : Address) return Boolean; end HTable_Subprograms; package External_Tag_HTable is new GNAT.HTable.Static_HTable ( --- 126,133 ---- package HTable_Subprograms is procedure Set_HT_Link (T : Tag; Next : Tag); function Get_HT_Link (T : Tag) return Tag; ! function Hash (F : S.Address) return HTable_Headers; ! function Equal (A, B : S.Address) return Boolean; end HTable_Subprograms; package External_Tag_HTable is new GNAT.HTable.Static_HTable ( *************** package body Ada.Tags is *** 141,147 **** Null_Ptr => null, Set_Next => HTable_Subprograms.Set_HT_Link, Next => HTable_Subprograms.Get_HT_Link, ! Key => Address, Get_Key => Get_External_Tag, Hash => HTable_Subprograms.Hash, Equal => HTable_Subprograms.Equal); --- 137,143 ---- Null_Ptr => null, Set_Next => HTable_Subprograms.Set_HT_Link, Next => HTable_Subprograms.Get_HT_Link, ! Key => S.Address, Get_Key => Get_External_Tag, Hash => HTable_Subprograms.Hash, Equal => HTable_Subprograms.Equal); *************** package body Ada.Tags is *** 158,164 **** -- Equal -- ----------- ! function Equal (A, B : Address) return Boolean is Str1 : Cstring_Ptr := To_Cstring_Ptr (A); Str2 : Cstring_Ptr := To_Cstring_Ptr (B); J : Integer := 1; --- 154,160 ---- -- Equal -- ----------- ! function Equal (A, B : S.Address) return Boolean is Str1 : Cstring_Ptr := To_Cstring_Ptr (A); Str2 : Cstring_Ptr := To_Cstring_Ptr (B); J : Integer := 1; *************** package body Ada.Tags is *** 190,196 **** -- Hash -- ---------- ! function Hash (F : Address) return HTable_Headers is function H is new GNAT.HTable.Hash (HTable_Headers); Str : Cstring_Ptr := To_Cstring_Ptr (F); Res : constant HTable_Headers := H (Str (1 .. Length (Str))); --- 186,192 ---- -- Hash -- ---------- ! function Hash (F : S.Address) return HTable_Headers is function H is new GNAT.HTable.Hash (HTable_Headers); Str : Cstring_Ptr := To_Cstring_Ptr (F); Res : constant HTable_Headers := H (Str (1 .. Length (Str))); *************** package body Ada.Tags is *** 262,268 **** -- Get_Expanded_Name -- ----------------------- ! function Get_Expanded_Name (T : Tag) return Address is begin return To_Address (T.TSD.Expanded_Name); end Get_Expanded_Name; --- 258,264 ---- -- Get_Expanded_Name -- ----------------------- ! function Get_Expanded_Name (T : Tag) return S.Address is begin return To_Address (T.TSD.Expanded_Name); end Get_Expanded_Name; *************** package body Ada.Tags is *** 271,277 **** -- Get_External_Tag -- ---------------------- ! function Get_External_Tag (T : Tag) return Address is begin return To_Address (T.TSD.External_Tag); end Get_External_Tag; --- 267,273 ---- -- Get_External_Tag -- ---------------------- ! function Get_External_Tag (T : Tag) return S.Address is begin return To_Address (T.TSD.External_Tag); end Get_External_Tag; *************** package body Ada.Tags is *** 292,298 **** function Get_Prim_Op_Address (T : Tag; Position : Positive) ! return Address is begin return T.Prims_Ptr (Position); --- 288,294 ---- function Get_Prim_Op_Address (T : Tag; Position : Positive) ! return S.Address is begin return T.Prims_Ptr (Position); *************** package body Ada.Tags is *** 320,326 **** -- Get_TSD -- ------------- ! function Get_TSD (T : Tag) return Address is begin return To_Address (T.TSD); end Get_TSD; --- 316,322 ---- -- Get_TSD -- ------------- ! function Get_TSD (T : Tag) return S.Address is begin return To_Address (T.TSD); end Get_TSD; *************** package body Ada.Tags is *** 345,351 **** -- Inherit_TSD -- ----------------- ! procedure Inherit_TSD (Old_TSD : Address; New_Tag : Tag) is TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (Old_TSD); New_TSD : Type_Specific_Data renames New_Tag.TSD.all; --- 341,347 ---- -- Inherit_TSD -- ----------------- ! procedure Inherit_TSD (Old_TSD : S.Address; New_Tag : Tag) is TSD : constant Type_Specific_Data_Ptr := To_Type_Specific_Data_Ptr (Old_TSD); New_TSD : Type_Specific_Data renames New_Tag.TSD.all; *************** package body Ada.Tags is *** 422,435 **** type T_Ptr is access all T; ! function To_T_Ptr is new Unchecked_Conversion (Address, T_Ptr); -- The profile of the implicitly defined _size primitive ! type Acc_Size is access function (A : Address) return Long_Long_Integer; ! function To_Acc_Size is new Unchecked_Conversion (Address, Acc_Size); ! function Parent_Size (Obj : Address) return SSE.Storage_Count is -- Get the tag of the object --- 418,431 ---- type T_Ptr is access all T; ! function To_T_Ptr is new Unchecked_Conversion (S.Address, T_Ptr); -- The profile of the implicitly defined _size primitive ! type Acc_Size is access function (A : S.Address) return Long_Long_Integer; ! function To_Acc_Size is new Unchecked_Conversion (S.Address, Acc_Size); ! function Parent_Size (Obj : S.Address) return SSE.Storage_Count is -- Get the tag of the object *************** package body Ada.Tags is *** 463,469 **** -- Set_Expanded_Name -- ----------------------- ! procedure Set_Expanded_Name (T : Tag; Value : Address) is begin T.TSD.Expanded_Name := To_Cstring_Ptr (Value); end Set_Expanded_Name; --- 459,465 ---- -- Set_Expanded_Name -- ----------------------- ! procedure Set_Expanded_Name (T : Tag; Value : S.Address) is begin T.TSD.Expanded_Name := To_Cstring_Ptr (Value); end Set_Expanded_Name; *************** package body Ada.Tags is *** 472,478 **** -- Set_External_Tag -- ---------------------- ! procedure Set_External_Tag (T : Tag; Value : Address) is begin T.TSD.External_Tag := To_Cstring_Ptr (Value); end Set_External_Tag; --- 468,474 ---- -- Set_External_Tag -- ---------------------- ! procedure Set_External_Tag (T : Tag; Value : S.Address) is begin T.TSD.External_Tag := To_Cstring_Ptr (Value); end Set_External_Tag; *************** package body Ada.Tags is *** 496,502 **** procedure Set_Prim_Op_Address (T : Tag; Position : Positive; ! Value : Address) is begin T.Prims_Ptr (Position) := Value; --- 492,498 ---- procedure Set_Prim_Op_Address (T : Tag; Position : Positive; ! Value : S.Address) is begin T.Prims_Ptr (Position) := Value; *************** package body Ada.Tags is *** 528,534 **** -- Set_TSD -- ------------- ! procedure Set_TSD (T : Tag; Value : Address) is begin T.TSD := To_Type_Specific_Data_Ptr (Value); end Set_TSD; --- 524,530 ---- -- Set_TSD -- ------------- ! procedure Set_TSD (T : Tag; Value : S.Address) is begin T.TSD := To_Type_Specific_Data_Ptr (Value); end Set_TSD; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tags.ads gcc-3.3/gcc/ada/a-tags.ads *** gcc-3.2.3/gcc/ada/a-tags.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-tags.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tasatt.adb gcc-3.3/gcc/ada/a-tasatt.adb *** gcc-3.2.3/gcc/ada/a-tasatt.adb 2001-12-16 01:13:32.000000000 +0000 --- gcc-3.3/gcc/ada/a-tasatt.adb 2002-03-14 10:58:55.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2000 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1991-2002 Florida State University -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** *** 182,189 **** -- The latter initialization requires a list of all the instantiation -- descriptors. Updates to this list, as well as the bit-vector that -- is used to reserve slots for attributes in the TCB, require mutual ! -- exclusion. That is provided by the lock ! -- System.Tasking.Task_Attributes.All_Attrs_L. -- One special problem that added complexity to the design is that -- the per-task list of indirect attributes contains objects of --- 180,186 ---- -- The latter initialization requires a list of all the instantiation -- descriptors. Updates to this list, as well as the bit-vector that -- is used to reserve slots for attributes in the TCB, require mutual ! -- exclusion. That is provided by the Lock/Unlock_RTS. -- One special problem that added complexity to the design is that -- the per-task list of indirect attributes contains objects of *************** with System.Storage_Elements; *** 243,249 **** with System.Task_Primitives.Operations; -- used for Write_Lock -- Unlock ! -- Lock/Unlock_All_Tasks_List with System.Tasking; -- used for Access_Address --- 240,246 ---- with System.Task_Primitives.Operations; -- used for Write_Lock -- Unlock ! -- Lock/Unlock_RTS with System.Tasking; -- used for Access_Address *************** package body Ada.Task_Attributes is *** 301,306 **** --- 298,311 ---- type Wrapper; type Access_Wrapper is access all Wrapper; + pragma Warnings (Off); + -- We turn warnings off for the following declarations of the + -- To_Attribute_Handle conversions, since these are used only + -- for small attributes where we know that there are no problems + -- with alignment, but the compiler will generate warnings for + -- the occurrences in the large attribute case, even though + -- they will not actually be used. + function To_Attribute_Handle is new Unchecked_Conversion (Access_Address, Attribute_Handle); -- For reference to directly addressed task attributes *************** package body Ada.Task_Attributes is *** 312,317 **** --- 317,326 ---- (Access_Integer_Address, Attribute_Handle); -- For reference to directly addressed task attributes + pragma Warnings (On); + -- End of warnings off region for directly addressed + -- attribute conversion functions. + function To_Access_Address is new Unchecked_Conversion (Access_Node, Access_Address); -- To store pointer to list of indirect attributes *************** package body Ada.Task_Attributes is *** 320,328 **** (Access_Address, Access_Node); -- To fetch pointer to list of indirect attributes function To_Access_Wrapper is new Unchecked_Conversion (Access_Dummy_Wrapper, Access_Wrapper); ! -- To fetch pointer to actual wrapper of attribute node function To_Access_Dummy_Wrapper is new Unchecked_Conversion (Access_Wrapper, Access_Dummy_Wrapper); --- 329,343 ---- (Access_Address, Access_Node); -- To fetch pointer to list of indirect attributes + pragma Warnings (Off); function To_Access_Wrapper is new Unchecked_Conversion (Access_Dummy_Wrapper, Access_Wrapper); ! pragma Warnings (On); ! -- To fetch pointer to actual wrapper of attribute node. We turn off ! -- warnings since this may generate an alignment warning. The warning ! -- can be ignored since Dummy_Wrapper is only a non-generic standin ! -- for the real wrapper type (we never actually allocate objects of ! -- type Dummy_Wrapper). function To_Access_Dummy_Wrapper is new Unchecked_Conversion (Access_Wrapper, Access_Dummy_Wrapper); *************** package body Ada.Task_Attributes is *** 388,394 **** (T : Task_Identification.Task_Id := Task_Identification.Current_Task) return Attribute_Handle is ! TT : Task_ID := To_Task_ID (T); Error_Message : constant String := "Trying to get the reference of a"; begin --- 403,409 ---- (T : Task_Identification.Task_Id := Task_Identification.Current_Task) return Attribute_Handle is ! TT : Task_ID := To_Task_ID (T); Error_Message : constant String := "Trying to get the reference of a"; begin *************** package body Ada.Task_Attributes is *** 404,416 **** begin Defer_Abortion; ! POP.Write_Lock (All_Attrs_L'Access); if Local.Index /= 0 then ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; return To_Attribute_Handle (TT.Direct_Attributes (Local.Index)'Access); else declare --- 419,442 ---- begin Defer_Abortion; ! POP.Lock_RTS; ! ! -- Directly addressed case if Local.Index /= 0 then ! POP.Unlock_RTS; Undefer_Abortion; + + -- Return the attribute handle. Warnings off because this return + -- statement generates alignment warnings for large attributes + -- (but will never be executed in this case anyway). + + pragma Warnings (Off); return To_Attribute_Handle (TT.Direct_Attributes (Local.Index)'Access); + pragma Warnings (On); + + -- Not directly addressed else declare *************** package body Ada.Task_Attributes is *** 420,426 **** begin while P /= null loop if P.Instance = Access_Instance'(Local'Unchecked_Access) then ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; return To_Access_Wrapper (P.Wrapper).Value'Access; end if; --- 446,452 ---- begin while P /= null loop if P.Instance = Access_Instance'(Local'Unchecked_Access) then ! POP.Unlock_RTS; Undefer_Abortion; return To_Access_Wrapper (P.Wrapper).Value'Access; end if; *************** package body Ada.Task_Attributes is *** 428,447 **** P := P.Next; end loop; ! -- Unlock All_Attrs_L here to follow the lock ordering rule -- that prevent us from using new (i.e the Global_Lock) while -- holding any other lock. ! POP.Unlock (All_Attrs_L'Access); W := new Wrapper' ((null, Local'Unchecked_Access, null), Initial_Value); ! POP.Write_Lock (All_Attrs_L'Access); P := W.Noed'Unchecked_Access; P.Wrapper := To_Access_Dummy_Wrapper (W); P.Next := To_Access_Node (TT.Indirect_Attributes); TT.Indirect_Attributes := To_Access_Address (P); ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; return W.Value'Access; end; --- 454,473 ---- P := P.Next; end loop; ! -- Unlock the RTS here to follow the lock ordering rule -- that prevent us from using new (i.e the Global_Lock) while -- holding any other lock. ! POP.Unlock_RTS; W := new Wrapper' ((null, Local'Unchecked_Access, null), Initial_Value); ! POP.Lock_RTS; P := W.Noed'Unchecked_Access; P.Wrapper := To_Access_Dummy_Wrapper (W); P.Next := To_Access_Node (TT.Indirect_Attributes); TT.Indirect_Attributes := To_Access_Address (P); ! POP.Unlock_RTS; Undefer_Abortion; return W.Value'Access; end; *************** package body Ada.Task_Attributes is *** 452,458 **** exception when others => ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; raise; end; --- 478,484 ---- exception when others => ! POP.Unlock_RTS; Undefer_Abortion; raise; end; *************** package body Ada.Task_Attributes is *** 493,501 **** begin Defer_Abortion; ! POP.Write_Lock (All_Attrs_L'Access); ! Q := To_Access_Node (TT.Indirect_Attributes); while Q /= null loop if Q.Instance = Access_Instance'(Local'Unchecked_Access) then if P = null then --- 519,527 ---- begin Defer_Abortion; ! POP.Lock_RTS; Q := To_Access_Node (TT.Indirect_Attributes); + while Q /= null loop if Q.Instance = Access_Instance'(Local'Unchecked_Access) then if P = null then *************** package body Ada.Task_Attributes is *** 506,512 **** W := To_Access_Wrapper (Q.Wrapper); Free (W); ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; return; end if; --- 532,538 ---- W := To_Access_Wrapper (Q.Wrapper); Free (W); ! POP.Unlock_RTS; Undefer_Abortion; return; end if; *************** package body Ada.Task_Attributes is *** 515,526 **** Q := Q.Next; end loop; ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; exception when others => ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; end; --- 541,552 ---- Q := Q.Next; end loop; ! POP.Unlock_RTS; Undefer_Abortion; exception when others => ! POP.Unlock_RTS; Undefer_Abortion; end; *************** package body Ada.Task_Attributes is *** 560,574 **** begin Defer_Abortion; ! POP.Write_Lock (All_Attrs_L'Access); if Local.Index /= 0 then To_Attribute_Handle (TT.Direct_Attributes (Local.Index)'Access).all := Val; ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; return; else declare P : Access_Node := To_Access_Node (TT.Indirect_Attributes); --- 586,612 ---- begin Defer_Abortion; ! POP.Lock_RTS; ! ! -- Directly addressed case if Local.Index /= 0 then + + -- Set attribute handle, warnings off, because this code can + -- generate alignment warnings with large attributes (but of + -- course wil not be executed in this case, since we never + -- have direct addressing in such cases). + + pragma Warnings (Off); To_Attribute_Handle (TT.Direct_Attributes (Local.Index)'Access).all := Val; ! pragma Warnings (On); ! POP.Unlock_RTS; Undefer_Abortion; return; + -- Not directly addressed + else declare P : Access_Node := To_Access_Node (TT.Indirect_Attributes); *************** package body Ada.Task_Attributes is *** 579,585 **** if P.Instance = Access_Instance'(Local'Unchecked_Access) then To_Access_Wrapper (P.Wrapper).Value := Val; ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; return; end if; --- 617,623 ---- if P.Instance = Access_Instance'(Local'Unchecked_Access) then To_Access_Wrapper (P.Wrapper).Value := Val; ! POP.Unlock_RTS; Undefer_Abortion; return; end if; *************** package body Ada.Task_Attributes is *** 587,601 **** P := P.Next; end loop; ! -- Unlock TT here to follow the lock ordering rule that -- prevent us from using new (i.e the Global_Lock) while -- holding any other lock. ! POP.Unlock (All_Attrs_L'Access); W := new Wrapper' ((null, Local'Unchecked_Access, null), Val); ! POP.Write_Lock (All_Attrs_L'Access); ! P := W.Noed'Unchecked_Access; P.Wrapper := To_Access_Dummy_Wrapper (W); P.Next := To_Access_Node (TT.Indirect_Attributes); --- 625,638 ---- P := P.Next; end loop; ! -- Unlock RTS here to follow the lock ordering rule that -- prevent us from using new (i.e the Global_Lock) while -- holding any other lock. ! POP.Unlock_RTS; W := new Wrapper' ((null, Local'Unchecked_Access, null), Val); ! POP.Lock_RTS; P := W.Noed'Unchecked_Access; P.Wrapper := To_Access_Dummy_Wrapper (W); P.Next := To_Access_Node (TT.Indirect_Attributes); *************** package body Ada.Task_Attributes is *** 603,614 **** end; end if; ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; exception when others => ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; raise; end; --- 640,651 ---- end; end if; ! POP.Unlock_RTS; Undefer_Abortion; exception when others => ! POP.Unlock_RTS; Undefer_Abortion; raise; end; *************** package body Ada.Task_Attributes is *** 648,657 **** --- 685,706 ---- end if; begin + -- Directly addressed case + if Local.Index /= 0 then + + -- Get value of attribute. Warnings off, because for large + -- attributes, this code can generate alignment warnings. + -- But of course large attributes are never directly addressed + -- so in fact we will never execute the code in this case. + + pragma Warnings (Off); Result := To_Attribute_Handle (TT.Direct_Attributes (Local.Index)'Access).all; + pragma Warnings (On); + + -- Not directly addressed else declare *************** package body Ada.Task_Attributes is *** 659,670 **** begin Defer_Abortion; ! POP.Write_Lock (All_Attrs_L'Access); ! P := To_Access_Node (TT.Indirect_Attributes); while P /= null loop if P.Instance = Access_Instance'(Local'Unchecked_Access) then ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; return To_Access_Wrapper (P.Wrapper).Value; end if; --- 708,719 ---- begin Defer_Abortion; ! POP.Lock_RTS; P := To_Access_Node (TT.Indirect_Attributes); + while P /= null loop if P.Instance = Access_Instance'(Local'Unchecked_Access) then ! POP.Unlock_RTS; Undefer_Abortion; return To_Access_Wrapper (P.Wrapper).Value; end if; *************** package body Ada.Task_Attributes is *** 673,684 **** end loop; Result := Initial_Value; ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; exception when others => ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; raise; end; --- 722,733 ---- end loop; Result := Initial_Value; ! POP.Unlock_RTS; Undefer_Abortion; exception when others => ! POP.Unlock_RTS; Undefer_Abortion; raise; end; *************** begin *** 707,717 **** pragma Warnings (On); declare ! Two_To_J : Direct_Index_Vector; ! begin Defer_Abortion; ! POP.Write_Lock (All_Attrs_L'Access); -- Add this instantiation to the list of all instantiations. --- 756,770 ---- pragma Warnings (On); declare ! Two_To_J : Direct_Index_Vector; begin Defer_Abortion; ! ! -- Need protection for updating links to per-task initialization and ! -- finalization routines, in case some task is being created or ! -- terminated concurrently. ! ! POP.Lock_RTS; -- Add this instantiation to the list of all instantiations. *************** begin *** 749,760 **** end loop; end if; - -- Need protection of All_Tasks_L for updating links to - -- per-task initialization and finalization routines, - -- in case some task is being created or terminated concurrently. - - POP.Lock_All_Tasks_List; - -- Attribute goes directly in the TCB if Local.Index /= 0 then --- 802,807 ---- *************** begin *** 791,798 **** end if; ! POP.Unlock_All_Tasks_List; ! POP.Unlock (All_Attrs_L'Access); Undefer_Abortion; exception --- 838,844 ---- end if; ! POP.Unlock_RTS; Undefer_Abortion; exception *************** begin *** 804,808 **** -- any initializations that succeeded up to this point, or we will -- risk a dangling reference when the task terminates. end; - end Ada.Task_Attributes; --- 850,853 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tasatt.ads gcc-3.3/gcc/ada/a-tasatt.ads *** gcc-3.2.3/gcc/ada/a-tasatt.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-tasatt.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-taside.adb gcc-3.3/gcc/ada/a-taside.adb *** gcc-3.2.3/gcc/ada/a-taside.adb 2002-05-04 03:27:26.000000000 +0000 --- gcc-3.3/gcc/ada/a-taside.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-taside.ads gcc-3.3/gcc/ada/a-taside.ads *** gcc-3.2.3/gcc/ada/a-taside.ads 2002-05-04 03:27:26.000000000 +0000 --- gcc-3.3/gcc/ada/a-taside.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-teioed.adb gcc-3.3/gcc/ada/a-teioed.adb *** gcc-3.2.3/gcc/ada/a-teioed.adb 2002-05-04 03:27:26.000000000 +0000 --- gcc-3.3/gcc/ada/a-teioed.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-teioed.ads gcc-3.3/gcc/ada/a-teioed.ads *** gcc-3.2.3/gcc/ada/a-teioed.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-teioed.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-textio.adb gcc-3.3/gcc/ada/a-textio.adb *** gcc-3.2.3/gcc/ada/a-textio.adb 2002-05-04 03:27:26.000000000 +0000 --- gcc-3.3/gcc/ada/a-textio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Ada.Text_IO is *** 58,63 **** --- 57,64 ---- ------------------- function AFCB_Allocate (Control_Block : Text_AFCB) return FCB.AFCB_Ptr is + pragma Warnings (Off, Control_Block); + begin return new Text_AFCB; end AFCB_Allocate; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-textio.ads gcc-3.3/gcc/ada/a-textio.ads *** gcc-3.2.3/gcc/ada/a-textio.ads 2002-05-04 03:27:27.000000000 +0000 --- gcc-3.3/gcc/ada/a-textio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ticoau.adb gcc-3.3/gcc/ada/a-ticoau.adb *** gcc-3.2.3/gcc/ada/a-ticoau.adb 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-ticoau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ticoau.ads gcc-3.3/gcc/ada/a-ticoau.ads *** gcc-3.2.3/gcc/ada/a-ticoau.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-ticoau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ticoio.adb gcc-3.3/gcc/ada/a-ticoio.adb *** gcc-3.2.3/gcc/ada/a-ticoio.adb 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-ticoio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-ticoio.ads gcc-3.3/gcc/ada/a-ticoio.ads *** gcc-3.2.3/gcc/ada/a-ticoio.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-ticoio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tideau.adb gcc-3.3/gcc/ada/a-tideau.adb *** gcc-3.2.3/gcc/ada/a-tideau.adb 2002-05-04 03:27:28.000000000 +0000 --- gcc-3.3/gcc/ada/a-tideau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Ada.Text_IO.Decimal_Aux is *** 68,74 **** end if; Item := Scan_Decimal (Buf, Ptr'Access, Stop, Scale); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); return Item; end Get_Dec; --- 67,73 ---- end if; Item := Scan_Decimal (Buf, Ptr'Access, Stop, Scale); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); return Item; end Get_Dec; *************** package body Ada.Text_IO.Decimal_Aux is *** 97,103 **** end if; Item := Scan_Long_Long_Decimal (Buf, Ptr'Access, Stop, Scale); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); return Item; end Get_LLD; --- 96,102 ---- end if; Item := Scan_Long_Long_Decimal (Buf, Ptr'Access, Stop, Scale); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); return Item; end Get_LLD; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tideau.ads gcc-3.3/gcc/ada/a-tideau.ads *** gcc-3.2.3/gcc/ada/a-tideau.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-tideau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tideio.adb gcc-3.3/gcc/ada/a-tideio.adb *** gcc-3.2.3/gcc/ada/a-tideio.adb 2002-05-04 03:27:28.000000000 +0000 --- gcc-3.3/gcc/ada/a-tideio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tideio.ads gcc-3.3/gcc/ada/a-tideio.ads *** gcc-3.2.3/gcc/ada/a-tideio.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-tideio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tienau.adb gcc-3.3/gcc/ada/a-tienau.adb *** gcc-3.2.3/gcc/ada/a-tienau.adb 2002-05-04 03:27:28.000000000 +0000 --- gcc-3.3/gcc/ada/a-tienau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tienau.ads gcc-3.3/gcc/ada/a-tienau.ads *** gcc-3.2.3/gcc/ada/a-tienau.ads 2002-05-07 08:22:08.000000000 +0000 --- gcc-3.3/gcc/ada/a-tienau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tienio.adb gcc-3.3/gcc/ada/a-tienio.adb *** gcc-3.2.3/gcc/ada/a-tienio.adb 2002-05-04 03:27:28.000000000 +0000 --- gcc-3.3/gcc/ada/a-tienio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tienio.ads gcc-3.3/gcc/ada/a-tienio.ads *** gcc-3.2.3/gcc/ada/a-tienio.ads 2002-05-04 03:27:28.000000000 +0000 --- gcc-3.3/gcc/ada/a-tienio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tifiio.adb gcc-3.3/gcc/ada/a-tifiio.adb *** gcc-3.2.3/gcc/ada/a-tifiio.adb 2002-05-04 03:27:28.000000000 +0000 --- gcc-3.3/gcc/ada/a-tifiio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tifiio.ads gcc-3.3/gcc/ada/a-tifiio.ads *** gcc-3.2.3/gcc/ada/a-tifiio.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-tifiio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiflau.adb gcc-3.3/gcc/ada/a-tiflau.adb *** gcc-3.2.3/gcc/ada/a-tiflau.adb 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiflau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1998 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body Ada.Text_IO.Float_Aux is *** 63,69 **** Item := Scan_Real (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get; ---------- --- 62,68 ---- Item := Scan_Real (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get; ---------- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiflau.ads gcc-3.3/gcc/ada/a-tiflau.ads *** gcc-3.2.3/gcc/ada/a-tiflau.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiflau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiflio.adb gcc-3.3/gcc/ada/a-tiflio.adb *** gcc-3.2.3/gcc/ada/a-tiflio.adb 2002-05-04 03:27:28.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiflio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiflio.ads gcc-3.3/gcc/ada/a-tiflio.ads *** gcc-3.2.3/gcc/ada/a-tiflio.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiflio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tigeau.adb gcc-3.3/gcc/ada/a-tigeau.adb *** gcc-3.2.3/gcc/ada/a-tigeau.adb 2002-05-04 03:27:28.000000000 +0000 --- gcc-3.3/gcc/ada/a-tigeau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body Ada.Text_IO.Generic_Aux is *** 48,55 **** ------------------------ procedure Check_End_Of_Field ! (File : File_Type; ! Buf : String; Stop : Integer; Ptr : Integer; Width : Field) --- 47,53 ---- ------------------------ procedure Check_End_Of_Field ! (Buf : String; Stop : Integer; Ptr : Integer; Width : Field) diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tigeau.ads gcc-3.3/gcc/ada/a-tigeau.ads *** gcc-3.2.3/gcc/ada/a-tigeau.ads 2002-05-04 03:27:29.000000000 +0000 --- gcc-3.3/gcc/ada/a-tigeau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** private package Ada.Text_IO.Generic_Aux *** 46,53 **** -- so one of these two routines must be called first. procedure Check_End_Of_Field ! (File : File_Type; ! Buf : String; Stop : Integer; Ptr : Integer; Width : Field); --- 45,51 ---- -- so one of these two routines must be called first. procedure Check_End_Of_Field ! (Buf : String; Stop : Integer; Ptr : Integer; Width : Field); diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiinau.adb gcc-3.3/gcc/ada/a-tiinau.adb *** gcc-3.2.3/gcc/ada/a-tiinau.adb 2002-05-04 03:27:29.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiinau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-1999 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body Ada.Text_IO.Integer_Aux is *** 80,86 **** end if; Item := Scan_Integer (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get_Int; ------------- --- 79,85 ---- end if; Item := Scan_Integer (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get_Int; ------------- *************** package body Ada.Text_IO.Integer_Aux is *** 105,111 **** end if; Item := Scan_Long_Long_Integer (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get_LLI; -------------- --- 104,110 ---- end if; Item := Scan_Long_Long_Integer (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get_LLI; -------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiinau.ads gcc-3.3/gcc/ada/a-tiinau.ads *** gcc-3.2.3/gcc/ada/a-tiinau.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiinau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiinio.adb gcc-3.3/gcc/ada/a-tiinio.adb *** gcc-3.2.3/gcc/ada/a-tiinio.adb 2002-05-04 03:27:29.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiinio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiinio.ads gcc-3.3/gcc/ada/a-tiinio.ads *** gcc-3.2.3/gcc/ada/a-tiinio.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiinio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-timoau.adb gcc-3.3/gcc/ada/a-timoau.adb *** gcc-3.2.3/gcc/ada/a-timoau.adb 2002-05-04 03:27:29.000000000 +0000 --- gcc-3.3/gcc/ada/a-timoau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Ada.Text_IO.Modular_Aux is *** 82,88 **** end if; Item := Scan_Long_Long_Unsigned (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get_LLU; ------------- --- 81,87 ---- end if; Item := Scan_Long_Long_Unsigned (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get_LLU; ------------- *************** package body Ada.Text_IO.Modular_Aux is *** 107,113 **** end if; Item := Scan_Unsigned (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get_Uns; -------------- --- 106,112 ---- end if; Item := Scan_Unsigned (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get_Uns; -------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-timoau.ads gcc-3.3/gcc/ada/a-timoau.ads *** gcc-3.2.3/gcc/ada/a-timoau.ads 2002-05-04 03:27:29.000000000 +0000 --- gcc-3.3/gcc/ada/a-timoau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-timoio.adb gcc-3.3/gcc/ada/a-timoio.adb *** gcc-3.2.3/gcc/ada/a-timoio.adb 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-timoio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-timoio.ads gcc-3.3/gcc/ada/a-timoio.ads *** gcc-3.2.3/gcc/ada/a-timoio.ads 2002-05-04 03:27:29.000000000 +0000 --- gcc-3.3/gcc/ada/a-timoio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1993-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiocst.adb gcc-3.3/gcc/ada/a-tiocst.adb *** gcc-3.2.3/gcc/ada/a-tiocst.adb 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiocst.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-tiocst.ads gcc-3.3/gcc/ada/a-tiocst.ads *** gcc-3.2.3/gcc/ada/a-tiocst.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-tiocst.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-titest.adb gcc-3.3/gcc/ada/a-titest.adb *** gcc-3.2.3/gcc/ada/a-titest.adb 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-titest.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-titest.ads gcc-3.3/gcc/ada/a-titest.ads *** gcc-3.2.3/gcc/ada/a-titest.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-titest.ads 2002-03-14 10:58:59.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/atree.adb gcc-3.3/gcc/ada/atree.adb *** gcc-3.2.3/gcc/ada/atree.adb 2002-05-04 03:27:32.000000000 +0000 --- gcc-3.3/gcc/ada/atree.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Atree is *** 2354,2359 **** --- 2353,2379 ---- return OK; end if; + when OK_Orig => + declare + Onode : constant Node_Id := Original_Node (Node); + + begin + if Traverse_Field (Union_Id (Field1 (Onode))) = Abandon + or else + Traverse_Field (Union_Id (Field2 (Onode))) = Abandon + or else + Traverse_Field (Union_Id (Field3 (Onode))) = Abandon + or else + Traverse_Field (Union_Id (Field4 (Onode))) = Abandon + or else + Traverse_Field (Union_Id (Field5 (Onode))) = Abandon + then + return Abandon; + + else + return OK_Orig; + end if; + end; end case; end Traverse_Func; diff -Nrc3pad gcc-3.2.3/gcc/ada/atree.ads gcc-3.3/gcc/ada/atree.ads *** gcc-3.2.3/gcc/ada/atree.ads 2002-05-04 03:27:32.000000000 +0000 --- gcc-3.3/gcc/ada/atree.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Atree is *** 495,501 **** -- function is used only by Sinfo.CN to change nodes into their -- corresponding entities. ! type Traverse_Result is (OK, Skip, Abandon); -- This is the type of the result returned by the Process function passed -- to Traverse_Func and Traverse_Proc and also the type of the result of -- Traverse_Func itself. See descriptions below for details. --- 494,500 ---- -- function is used only by Sinfo.CN to change nodes into their -- corresponding entities. ! type Traverse_Result is (OK, OK_Orig, Skip, Abandon); -- This is the type of the result returned by the Process function passed -- to Traverse_Func and Traverse_Proc and also the type of the result of -- Traverse_Func itself. See descriptions below for details. *************** package Atree is *** 508,515 **** -- Process on each one. The traversal is controlled as follows by the -- result returned by Process: ! -- OK The traversal continues normally with the children of ! -- the node just processed. -- Skip The children of the node just processed are skipped and -- excluded from the traversal, but otherwise processing --- 507,517 ---- -- Process on each one. The traversal is controlled as follows by the -- result returned by Process: ! -- OK The traversal continues normally with the syntactic ! -- children of the node just processed. ! ! -- OK_Orig The traversal continues normally with the syntactic ! -- children of the original node of the node just processed. -- Skip The children of the node just processed are skipped and -- excluded from the traversal, but otherwise processing diff -Nrc3pad gcc-3.2.3/gcc/ada/atree.h gcc-3.3/gcc/ada/atree.h *** gcc-3.2.3/gcc/ada/atree.h 2002-05-04 03:27:32.000000000 +0000 --- gcc-3.3/gcc/ada/atree.h 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001, Free Software Foundation, Inc. * * * --- 6,11 ---- *************** struct NFK *** 46,52 **** Boolean rewrite_sub : 1; Boolean rewrite_ins : 1; Boolean analyzed : 1; ! Boolean comes_from_source : 1; Boolean error_posted : 1; Boolean flag4 : 1; --- 45,51 ---- Boolean rewrite_sub : 1; Boolean rewrite_ins : 1; Boolean analyzed : 1; ! Boolean c_f_s : 1; Boolean error_posted : 1; Boolean flag4 : 1; *************** struct NFNK *** 81,87 **** Boolean rewrite_sub : 1; Boolean rewrite_ins : 1; Boolean analyzed : 1; ! Boolean comes_from_source : 1; Boolean error_posted : 1; Boolean flag4 : 1; --- 80,86 ---- Boolean rewrite_sub : 1; Boolean rewrite_ins : 1; Boolean analyzed : 1; ! Boolean c_f_s : 1; Boolean error_posted : 1; Boolean flag4 : 1; *************** struct NFNK *** 101,114 **** Boolean flag17 : 1; Boolean flag18 : 1; ! Boolean flag65 : 1; ! Boolean flag66 : 1; ! Boolean flag67 : 1; ! Boolean flag68 : 1; ! Boolean flag69 : 1; ! Boolean flag70 : 1; ! Boolean flag71 : 1; ! Boolean flag72 : 1; }; /* Structure used for extra flags in third component overlaying Field12 */ --- 100,113 ---- Boolean flag17 : 1; Boolean flag18 : 1; ! Boolean flag65 : 1; ! Boolean flag66 : 1; ! Boolean flag67 : 1; ! Boolean flag68 : 1; ! Boolean flag69 : 1; ! Boolean flag70 : 1; ! Boolean flag71 : 1; ! Boolean flag72 : 1; }; /* Structure used for extra flags in third component overlaying Field12 */ *************** extern Node_Id Current_Error_Node; *** 313,347 **** /* Node Access Functions: */ ! #define Nkind(N) ((Node_Kind)(Nodes_Ptr [N].U.K.kind)) ! #define Ekind(N) ((Entity_Kind)(Nodes_Ptr [N + 1].U.K.kind)) ! #define Sloc(N) (Nodes_Ptr [N].V.NX.sloc) ! #define Paren_Count(N) (Nodes_Ptr [N].U.K.pflag1 \ ! + 2 * Nodes_Ptr [N].U.K.pflag2) ! #define Field1(N) (Nodes_Ptr [N].V.NX.field1) ! #define Field2(N) (Nodes_Ptr [N].V.NX.field2) ! #define Field3(N) (Nodes_Ptr [N].V.NX.field3) ! #define Field4(N) (Nodes_Ptr [N].V.NX.field4) ! #define Field5(N) (Nodes_Ptr [N].V.NX.field5) ! #define Field6(N) (Nodes_Ptr [(N)+1].V.EX.field6) ! #define Field7(N) (Nodes_Ptr [(N)+1].V.EX.field7) ! #define Field8(N) (Nodes_Ptr [(N)+1].V.EX.field8) ! #define Field9(N) (Nodes_Ptr [(N)+1].V.EX.field9) ! #define Field10(N) (Nodes_Ptr [(N)+1].V.EX.field10) ! #define Field11(N) (Nodes_Ptr [(N)+1].V.EX.X.field11) ! #define Field12(N) (Nodes_Ptr [(N)+1].V.EX.U.field12) ! #define Field13(N) (Nodes_Ptr [(N)+2].V.EX.field6) ! #define Field14(N) (Nodes_Ptr [(N)+2].V.EX.field7) ! #define Field15(N) (Nodes_Ptr [(N)+2].V.EX.field8) ! #define Field16(N) (Nodes_Ptr [(N)+2].V.EX.field9) ! #define Field17(N) (Nodes_Ptr [(N)+2].V.EX.field10) ! #define Field18(N) (Nodes_Ptr [(N)+2].V.EX.X.field11) ! #define Field19(N) (Nodes_Ptr [(N)+3].V.EX.field6) ! #define Field20(N) (Nodes_Ptr [(N)+3].V.EX.field7) ! #define Field21(N) (Nodes_Ptr [(N)+3].V.EX.field8) ! #define Field22(N) (Nodes_Ptr [(N)+3].V.EX.field9) ! #define Field23(N) (Nodes_Ptr [(N)+3].V.EX.field10) #define Node1(N) Field1 (N) #define Node2(N) Field2 (N) --- 312,346 ---- /* Node Access Functions: */ ! #define Nkind(N) ((Node_Kind) (Nodes_Ptr[(N) - First_Node_Id].U.K.kind)) ! #define Ekind(N) ((Entity_Kind) (Nodes_Ptr[N + 1].U.K.kind)) ! #define Sloc(N) (Nodes_Ptr[(N) - First_Node_Id].V.NX.sloc) ! #define Paren_Count(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.pflag1 \ ! + 2 * Nodes_Ptr[(N) - First_Node_Id].U.K.pflag2) ! #define Field1(N) (Nodes_Ptr[(N) - First_Node_Id].V.NX.field1) ! #define Field2(N) (Nodes_Ptr[(N) - First_Node_Id].V.NX.field2) ! #define Field3(N) (Nodes_Ptr[(N) - First_Node_Id].V.NX.field3) ! #define Field4(N) (Nodes_Ptr[(N) - First_Node_Id].V.NX.field4) ! #define Field5(N) (Nodes_Ptr[(N) - First_Node_Id].V.NX.field5) ! #define Field6(N) (Nodes_Ptr[(N) - First_Node_Id + 1].V.EX.field6) ! #define Field7(N) (Nodes_Ptr[(N) - First_Node_Id + 1].V.EX.field7) ! #define Field8(N) (Nodes_Ptr[(N) - First_Node_Id + 1].V.EX.field8) ! #define Field9(N) (Nodes_Ptr[(N) - First_Node_Id + 1].V.EX.field9) ! #define Field10(N) (Nodes_Ptr[(N) - First_Node_Id + 1].V.EX.field10) ! #define Field11(N) (Nodes_Ptr[(N) - First_Node_Id + 1].V.EX.X.field11) ! #define Field12(N) (Nodes_Ptr[(N) - First_Node_Id + 1].V.EX.U.field12) ! #define Field13(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.field6) ! #define Field14(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.field7) ! #define Field15(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.field8) ! #define Field16(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.field9) ! #define Field17(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.field10) ! #define Field18(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.X.field11) ! #define Field19(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.field6) ! #define Field20(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.field7) ! #define Field21(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.field8) ! #define Field22(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.field9) ! #define Field23(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.field10) #define Node1(N) Field1 (N) #define Node2(N) Field2 (N) *************** extern Node_Id Current_Error_Node; *** 392,606 **** #define Str3(N) Field3 (N) ! #define Uint3(N) ((Field3 (N)==0) ? Uint_0 : Field3 (N)) ! #define Uint4(N) ((Field4 (N)==0) ? Uint_0 : Field4 (N)) ! #define Uint5(N) ((Field5 (N)==0) ? Uint_0 : Field5 (N)) ! #define Uint8(N) ((Field8 (N)==0) ? Uint_0 : Field8 (N)) ! #define Uint9(N) ((Field9 (N)==0) ? Uint_0 : Field9 (N)) ! #define Uint10(N) ((Field10 (N)==0) ? Uint_0 : Field10 (N)) ! #define Uint11(N) ((Field11 (N)==0) ? Uint_0 : Field11 (N)) ! #define Uint12(N) ((Field12 (N)==0) ? Uint_0 : Field12 (N)) ! #define Uint13(N) ((Field13 (N)==0) ? Uint_0 : Field13 (N)) ! #define Uint14(N) ((Field14 (N)==0) ? Uint_0 : Field14 (N)) ! #define Uint15(N) ((Field15 (N)==0) ? Uint_0 : Field15 (N)) ! #define Uint16(N) ((Field16 (N)==0) ? Uint_0 : Field16 (N)) ! #define Uint17(N) ((Field17 (N)==0) ? Uint_0 : Field17 (N)) ! #define Uint22(N) ((Field22 (N)==0) ? Uint_0 : Field22 (N)) #define Ureal3(N) Field3 (N) #define Ureal18(N) Field18 (N) #define Ureal21(N) Field21 (N) ! #define Analyzed(N) (Nodes_Ptr [N].U.K.analyzed) ! #define Comes_From_Source(N) (Nodes_Ptr [N].U.K.comes_from_source) ! #define Error_Posted(N) (Nodes_Ptr [N].U.K.error_posted) ! ! #define Flag4(N) (Nodes_Ptr [N].U.K.flag4) ! #define Flag5(N) (Nodes_Ptr [N].U.K.flag5) ! #define Flag6(N) (Nodes_Ptr [N].U.K.flag6) ! #define Flag7(N) (Nodes_Ptr [N].U.K.flag7) ! #define Flag8(N) (Nodes_Ptr [N].U.K.flag8) ! #define Flag9(N) (Nodes_Ptr [N].U.K.flag9) ! #define Flag10(N) (Nodes_Ptr [N].U.K.flag10) ! #define Flag11(N) (Nodes_Ptr [N].U.K.flag11) ! #define Flag12(N) (Nodes_Ptr [N].U.K.flag12) ! #define Flag13(N) (Nodes_Ptr [N].U.K.flag13) ! #define Flag14(N) (Nodes_Ptr [N].U.K.flag14) ! #define Flag15(N) (Nodes_Ptr [N].U.K.flag15) ! #define Flag16(N) (Nodes_Ptr [N].U.K.flag16) ! #define Flag17(N) (Nodes_Ptr [N].U.K.flag17) ! #define Flag18(N) (Nodes_Ptr [N].U.K.flag18) ! ! #define Flag19(N) (Nodes_Ptr [(N)+1].U.K.in_list) ! #define Flag20(N) (Nodes_Ptr [(N)+1].U.K.rewrite_sub) ! #define Flag21(N) (Nodes_Ptr [(N)+1].U.K.rewrite_ins) ! #define Flag22(N) (Nodes_Ptr [(N)+1].U.K.analyzed) ! #define Flag23(N) (Nodes_Ptr [(N)+1].U.K.comes_from_source) ! #define Flag24(N) (Nodes_Ptr [(N)+1].U.K.error_posted) ! #define Flag25(N) (Nodes_Ptr [(N)+1].U.K.flag4) ! #define Flag26(N) (Nodes_Ptr [(N)+1].U.K.flag5) ! #define Flag27(N) (Nodes_Ptr [(N)+1].U.K.flag6) ! #define Flag28(N) (Nodes_Ptr [(N)+1].U.K.flag7) ! #define Flag29(N) (Nodes_Ptr [(N)+1].U.K.flag8) ! #define Flag30(N) (Nodes_Ptr [(N)+1].U.K.flag9) ! #define Flag31(N) (Nodes_Ptr [(N)+1].U.K.flag10) ! #define Flag32(N) (Nodes_Ptr [(N)+1].U.K.flag11) ! #define Flag33(N) (Nodes_Ptr [(N)+1].U.K.flag12) ! #define Flag34(N) (Nodes_Ptr [(N)+1].U.K.flag13) ! #define Flag35(N) (Nodes_Ptr [(N)+1].U.K.flag14) ! #define Flag36(N) (Nodes_Ptr [(N)+1].U.K.flag15) ! #define Flag37(N) (Nodes_Ptr [(N)+1].U.K.flag16) ! #define Flag38(N) (Nodes_Ptr [(N)+1].U.K.flag17) ! #define Flag39(N) (Nodes_Ptr [(N)+1].U.K.flag18) ! #define Flag40(N) (Nodes_Ptr [(N)+2].U.K.in_list) ! #define Flag41(N) (Nodes_Ptr [(N)+2].U.K.rewrite_sub) ! #define Flag42(N) (Nodes_Ptr [(N)+2].U.K.rewrite_ins) ! #define Flag43(N) (Nodes_Ptr [(N)+2].U.K.analyzed) ! #define Flag44(N) (Nodes_Ptr [(N)+2].U.K.comes_from_source) ! #define Flag45(N) (Nodes_Ptr [(N)+2].U.K.error_posted) ! #define Flag46(N) (Nodes_Ptr [(N)+2].U.K.flag4) ! #define Flag47(N) (Nodes_Ptr [(N)+2].U.K.flag5) ! #define Flag48(N) (Nodes_Ptr [(N)+2].U.K.flag6) ! #define Flag49(N) (Nodes_Ptr [(N)+2].U.K.flag7) ! #define Flag50(N) (Nodes_Ptr [(N)+2].U.K.flag8) ! #define Flag51(N) (Nodes_Ptr [(N)+2].U.K.flag9) ! #define Flag52(N) (Nodes_Ptr [(N)+2].U.K.flag10) ! #define Flag53(N) (Nodes_Ptr [(N)+2].U.K.flag11) ! #define Flag54(N) (Nodes_Ptr [(N)+2].U.K.flag12) ! #define Flag55(N) (Nodes_Ptr [(N)+2].U.K.flag13) ! #define Flag56(N) (Nodes_Ptr [(N)+2].U.K.flag14) ! #define Flag57(N) (Nodes_Ptr [(N)+2].U.K.flag15) ! #define Flag58(N) (Nodes_Ptr [(N)+2].U.K.flag16) ! #define Flag59(N) (Nodes_Ptr [(N)+2].U.K.flag17) ! #define Flag60(N) (Nodes_Ptr [(N)+2].U.K.flag18) ! #define Flag61(N) (Nodes_Ptr [(N)+1].U.K.pflag1) ! #define Flag62(N) (Nodes_Ptr [(N)+1].U.K.pflag2) ! #define Flag63(N) (Nodes_Ptr [(N)+2].U.K.pflag1) ! #define Flag64(N) (Nodes_Ptr [(N)+2].U.K.pflag2) ! #define Flag65(N) (Nodes_Ptr [(N)+2].U.NK.flag65) ! #define Flag66(N) (Nodes_Ptr [(N)+2].U.NK.flag66) ! #define Flag67(N) (Nodes_Ptr [(N)+2].U.NK.flag67) ! #define Flag68(N) (Nodes_Ptr [(N)+2].U.NK.flag68) ! #define Flag69(N) (Nodes_Ptr [(N)+2].U.NK.flag69) ! #define Flag70(N) (Nodes_Ptr [(N)+2].U.NK.flag70) ! #define Flag71(N) (Nodes_Ptr [(N)+2].U.NK.flag71) ! #define Flag72(N) (Nodes_Ptr [(N)+2].U.NK.flag72) ! #define Flag73(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag73) ! #define Flag74(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag74) ! #define Flag75(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag75) ! #define Flag76(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag76) ! #define Flag77(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag77) ! #define Flag78(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag78) ! #define Flag79(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag79) ! #define Flag80(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag80) ! #define Flag81(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag81) ! #define Flag82(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag82) ! #define Flag83(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag83) ! #define Flag84(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag84) ! #define Flag85(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag85) ! #define Flag86(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag86) ! #define Flag87(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag87) ! #define Flag88(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag88) ! #define Flag89(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag89) ! #define Flag90(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag90) ! #define Flag91(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag91) ! #define Flag92(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag92) ! #define Flag93(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag93) ! #define Flag94(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag94) ! #define Flag95(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag95) ! #define Flag96(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.flag96) ! #define Convention(N) (Nodes_Ptr [(N)+2].V.EX.U.fw.convention) ! #define Flag97(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag97) ! #define Flag98(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag98) ! #define Flag99(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag99) ! #define Flag100(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag100) ! #define Flag101(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag101) ! #define Flag102(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag102) ! #define Flag103(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag103) ! #define Flag104(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag104) ! #define Flag105(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag105) ! #define Flag106(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag106) ! #define Flag107(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag107) ! #define Flag108(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag108) ! #define Flag109(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag109) ! #define Flag110(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag110) ! #define Flag111(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag111) ! #define Flag112(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag112) ! #define Flag113(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag113) ! #define Flag114(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag114) ! #define Flag115(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag115) ! #define Flag116(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag116) ! #define Flag117(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag117) ! #define Flag118(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag118) ! #define Flag119(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag119) ! #define Flag120(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag120) ! #define Flag121(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag121) ! #define Flag122(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag122) ! #define Flag123(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag123) ! #define Flag124(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag124) ! #define Flag125(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag125) ! #define Flag126(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag126) ! #define Flag127(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag127) ! #define Flag128(N) (Nodes_Ptr [(N)+3].V.EX.U.fw2.flag128) ! #define Flag129(N) (Nodes_Ptr [(N)+3].U.K.in_list) ! #define Flag130(N) (Nodes_Ptr [(N)+3].U.K.rewrite_sub) ! #define Flag131(N) (Nodes_Ptr [(N)+3].U.K.rewrite_ins) ! #define Flag132(N) (Nodes_Ptr [(N)+3].U.K.analyzed) ! #define Flag133(N) (Nodes_Ptr [(N)+3].U.K.comes_from_source) ! #define Flag134(N) (Nodes_Ptr [(N)+3].U.K.error_posted) ! #define Flag135(N) (Nodes_Ptr [(N)+3].U.K.flag4) ! #define Flag136(N) (Nodes_Ptr [(N)+3].U.K.flag5) ! #define Flag137(N) (Nodes_Ptr [(N)+3].U.K.flag6) ! #define Flag138(N) (Nodes_Ptr [(N)+3].U.K.flag7) ! #define Flag139(N) (Nodes_Ptr [(N)+3].U.K.flag8) ! #define Flag140(N) (Nodes_Ptr [(N)+3].U.K.flag9) ! #define Flag141(N) (Nodes_Ptr [(N)+3].U.K.flag10) ! #define Flag142(N) (Nodes_Ptr [(N)+3].U.K.flag11) ! #define Flag143(N) (Nodes_Ptr [(N)+3].U.K.flag12) ! #define Flag144(N) (Nodes_Ptr [(N)+3].U.K.flag13) ! #define Flag145(N) (Nodes_Ptr [(N)+3].U.K.flag14) ! #define Flag146(N) (Nodes_Ptr [(N)+3].U.K.flag15) ! #define Flag147(N) (Nodes_Ptr [(N)+3].U.K.flag16) ! #define Flag148(N) (Nodes_Ptr [(N)+3].U.K.flag17) ! #define Flag149(N) (Nodes_Ptr [(N)+3].U.K.flag18) ! #define Flag150(N) (Nodes_Ptr [(N)+3].U.K.pflag1) ! #define Flag151(N) (Nodes_Ptr [(N)+3].U.K.pflag2) ! #define Flag152(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag152) ! #define Flag153(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag153) ! #define Flag154(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag154) ! #define Flag155(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag155) ! #define Flag156(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag156) ! #define Flag157(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag157) ! #define Flag158(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag158) ! #define Flag159(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag159) ! #define Flag160(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag160) ! #define Flag161(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag161) ! #define Flag162(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag162) ! #define Flag163(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag163) ! #define Flag164(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag164) ! #define Flag165(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag165) ! #define Flag166(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag166) ! #define Flag167(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag167) ! #define Flag168(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag168) ! #define Flag169(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag169) ! #define Flag170(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag170) ! #define Flag171(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag171) ! #define Flag172(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag172) ! #define Flag173(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag173) ! #define Flag174(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag174) ! #define Flag175(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag175) ! #define Flag176(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag176) ! #define Flag177(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag177) ! #define Flag178(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag178) ! #define Flag179(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag179) ! #define Flag180(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag180) ! #define Flag181(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag181) ! #define Flag182(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag182) ! #define Flag183(N) (Nodes_Ptr [(N)+3].V.EX.X.fw3.flag183) --- 391,604 ---- #define Str3(N) Field3 (N) ! #define Uint3(N) ((Field3 (N) == 0) ? Uint_0 : Field3 (N)) ! #define Uint4(N) ((Field4 (N) == 0) ? Uint_0 : Field4 (N)) ! #define Uint5(N) ((Field5 (N) == 0) ? Uint_0 : Field5 (N)) ! #define Uint8(N) ((Field8 (N) == 0) ? Uint_0 : Field8 (N)) ! #define Uint9(N) ((Field9 (N) == 0) ? Uint_0 : Field9 (N)) ! #define Uint10(N) ((Field10 (N) == 0) ? Uint_0 : Field10 (N)) ! #define Uint11(N) ((Field11 (N) == 0) ? Uint_0 : Field11 (N)) ! #define Uint12(N) ((Field12 (N) == 0) ? Uint_0 : Field12 (N)) ! #define Uint13(N) ((Field13 (N) == 0) ? Uint_0 : Field13 (N)) ! #define Uint14(N) ((Field14 (N) == 0) ? Uint_0 : Field14 (N)) ! #define Uint15(N) ((Field15 (N) == 0) ? Uint_0 : Field15 (N)) ! #define Uint16(N) ((Field16 (N) == 0) ? Uint_0 : Field16 (N)) ! #define Uint17(N) ((Field17 (N) == 0) ? Uint_0 : Field17 (N)) ! #define Uint22(N) ((Field22 (N) == 0) ? Uint_0 : Field22 (N)) #define Ureal3(N) Field3 (N) #define Ureal18(N) Field18 (N) #define Ureal21(N) Field21 (N) ! #define Analyzed(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.analyzed) ! #define Comes_From_Source(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.c_f_s) ! #define Error_Posted(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.error_posted) ! #define Convention(N) \ ! (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.convention) ! #define Flag4(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag4) ! #define Flag5(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag5) ! #define Flag6(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag6) ! #define Flag7(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag7) ! #define Flag8(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag8) ! #define Flag9(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag9) ! #define Flag10(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag10) ! #define Flag11(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag11) ! #define Flag12(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag12) ! #define Flag13(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag13) ! #define Flag14(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag14) ! #define Flag15(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag15) ! #define Flag16(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag16) ! #define Flag17(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag17) ! #define Flag18(N) (Nodes_Ptr[(N) - First_Node_Id].U.K.flag18) ! #define Flag19(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.in_list) ! #define Flag20(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.rewrite_sub) ! #define Flag21(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.rewrite_ins) ! #define Flag22(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.analyzed) ! #define Flag23(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.c_f_s) ! #define Flag24(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.error_posted) ! #define Flag25(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag4) ! #define Flag26(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag5) ! #define Flag27(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag6) ! #define Flag28(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag7) ! #define Flag29(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag8) ! #define Flag30(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag9) ! #define Flag31(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag10) ! #define Flag32(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag11) ! #define Flag33(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag12) ! #define Flag34(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag13) ! #define Flag35(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag14) ! #define Flag36(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag15) ! #define Flag37(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag16) ! #define Flag38(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag17) ! #define Flag39(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.flag18) ! #define Flag40(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.in_list) ! #define Flag41(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.rewrite_sub) ! #define Flag42(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.rewrite_ins) ! #define Flag43(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.analyzed) ! #define Flag44(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.c_f_s) ! #define Flag45(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.error_posted) ! #define Flag46(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag4) ! #define Flag47(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag5) ! #define Flag48(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag6) ! #define Flag49(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag7) ! #define Flag50(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag8) ! #define Flag51(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag9) ! #define Flag52(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag10) ! #define Flag53(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag11) ! #define Flag54(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag12) ! #define Flag55(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag13) ! #define Flag56(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag14) ! #define Flag57(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag15) ! #define Flag58(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag16) ! #define Flag59(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag17) ! #define Flag60(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.flag18) ! #define Flag61(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.pflag1) ! #define Flag62(N) (Nodes_Ptr[(N) - First_Node_Id + 1].U.K.pflag2) ! #define Flag63(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.pflag1) ! #define Flag64(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.K.pflag2) ! #define Flag65(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.NK.flag65) ! #define Flag66(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.NK.flag66) ! #define Flag67(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.NK.flag67) ! #define Flag68(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.NK.flag68) ! #define Flag69(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.NK.flag69) ! #define Flag70(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.NK.flag70) ! #define Flag71(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.NK.flag71) ! #define Flag72(N) (Nodes_Ptr[(N) - First_Node_Id + 2].U.NK.flag72) ! #define Flag73(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag73) ! #define Flag74(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag74) ! #define Flag75(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag75) ! #define Flag76(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag76) ! #define Flag77(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag77) ! #define Flag78(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag78) ! #define Flag79(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag79) ! #define Flag80(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag80) ! #define Flag81(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag81) ! #define Flag82(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag82) ! #define Flag83(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag83) ! #define Flag84(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag84) ! #define Flag85(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag85) ! #define Flag86(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag86) ! #define Flag87(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag87) ! #define Flag88(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag88) ! #define Flag89(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag89) ! #define Flag90(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag90) ! #define Flag91(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag91) ! #define Flag92(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag92) ! #define Flag93(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag93) ! #define Flag94(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag94) ! #define Flag95(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag95) ! #define Flag96(N) (Nodes_Ptr[(N) - First_Node_Id + 2].V.EX.U.fw.flag96) ! #define Flag97(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag97) ! #define Flag98(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag98) ! #define Flag99(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag99) ! #define Flag100(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag100) ! #define Flag101(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag101) ! #define Flag102(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag102) ! #define Flag103(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag103) ! #define Flag104(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag104) ! #define Flag105(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag105) ! #define Flag106(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag106) ! #define Flag107(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag107) ! #define Flag108(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag108) ! #define Flag109(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag109) ! #define Flag110(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag110) ! #define Flag111(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag111) ! #define Flag112(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag112) ! #define Flag113(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag113) ! #define Flag114(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag114) ! #define Flag115(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag115) ! #define Flag116(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag116) ! #define Flag117(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag117) ! #define Flag118(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag118) ! #define Flag119(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag119) ! #define Flag120(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag120) ! #define Flag121(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag121) ! #define Flag122(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag122) ! #define Flag123(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag123) ! #define Flag124(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag124) ! #define Flag125(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag125) ! #define Flag126(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag126) ! #define Flag127(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag127) ! #define Flag128(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.U.fw2.flag128) ! #define Flag129(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.in_list) ! #define Flag130(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.rewrite_sub) ! #define Flag131(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.rewrite_ins) ! #define Flag132(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.analyzed) ! #define Flag133(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.c_f_s) ! #define Flag134(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.error_posted) ! #define Flag135(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag4) ! #define Flag136(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag5) ! #define Flag137(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag6) ! #define Flag138(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag7) ! #define Flag139(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag8) ! #define Flag140(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag9) ! #define Flag141(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag10) ! #define Flag142(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag11) ! #define Flag143(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag12) ! #define Flag144(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag13) ! #define Flag145(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag14) ! #define Flag146(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag15) ! #define Flag147(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag16) ! #define Flag148(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag17) ! #define Flag149(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.flag18) ! #define Flag150(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.pflag1) ! #define Flag151(N) (Nodes_Ptr[(N) - First_Node_Id + 3].U.K.pflag2) ! #define Flag152(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag152) ! #define Flag153(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag153) ! #define Flag154(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag154) ! #define Flag155(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag155) ! #define Flag156(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag156) ! #define Flag157(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag157) ! #define Flag158(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag158) ! #define Flag159(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag159) ! #define Flag160(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag160) ! #define Flag161(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag161) ! #define Flag162(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag162) ! #define Flag163(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag163) ! #define Flag164(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag164) ! #define Flag165(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag165) ! #define Flag166(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag166) ! #define Flag167(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag167) ! #define Flag168(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag168) ! #define Flag169(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag169) ! #define Flag170(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag170) ! #define Flag171(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag171) ! #define Flag172(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag172) ! #define Flag173(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag173) ! #define Flag174(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag174) ! #define Flag175(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag175) ! #define Flag176(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag176) ! #define Flag177(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag177) ! #define Flag178(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag178) ! #define Flag179(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag179) ! #define Flag180(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag180) ! #define Flag181(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag181) ! #define Flag182(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag182) ! #define Flag183(N) (Nodes_Ptr[(N) - First_Node_Id + 3].V.EX.X.fw3.flag183) diff -Nrc3pad gcc-3.2.3/gcc/ada/a-unccon.ads gcc-3.3/gcc/ada/a-unccon.ads *** gcc-3.2.3/gcc/ada/a-unccon.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-unccon.ads 2002-03-14 10:58:59.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-uncdea.ads gcc-3.3/gcc/ada/a-uncdea.ads *** gcc-3.2.3/gcc/ada/a-uncdea.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-uncdea.ads 2002-03-14 10:58:59.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/aux-io.c gcc-3.3/gcc/ada/aux-io.c *** gcc-3.2.3/gcc/ada/aux-io.c 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/aux-io.c 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,101 ---- + /**************************************************************************** + * * + * GNAT RUN-TIME COMPONENTS * + * * + * A - T R A N S * + * * + * C Implementation File * + * * + * * + * Copyright (C) 1992-2001 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- * + * 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, 59 Temple Place - Suite 330, Boston, * + * MA 02111-1307, USA. * + * * + * As a special exception, if you link this file with other files to * + * produce an executable, this file does not by itself cause the resulting * + * executable to be covered by the GNU General Public License. This except- * + * ion does not however invalidate any other reasons why the executable * + * file might be covered by the GNU Public License. * + * * + * GNAT was originally developed by the GNAT team at New York University. * + * Extensive contributions were provided by Ada Core Technologies Inc. * + * * + ****************************************************************************/ + + #include + + #ifdef IN_RTS + #include "tconfig.h" + #include "tsystem.h" + #else + #include "config.h" + #include "system.h" + #endif + + /* Function wrappers are needed to access the values from Ada which are + defined as C macros. */ + + FILE *c_stdin PARAMS ((void)); + FILE *c_stdout PARAMS ((void)); + FILE *c_stderr PARAMS ((void)); + int seek_set_function PARAMS ((void)); + int seek_end_function PARAMS ((void)); + void *null_function PARAMS ((void)); + int c_fileno PARAMS ((FILE *)); + + FILE * + c_stdin () + { + return stdin; + } + + FILE * + c_stdout () + { + return stdout; + } + + FILE * + c_stderr () + { + return stderr; + } + + #ifndef SEEK_SET /* Symbolic constants for the "fseek" function: */ + #define SEEK_SET 0 /* Set file pointer to offset */ + #define SEEK_CUR 1 /* Set file pointer to its current value plus offset */ + #define SEEK_END 2 /* Set file pointer to the size of the file plus offset */ + #endif + + int + seek_set_function () + { + return SEEK_SET; + } + + int + seek_end_function () + { + return SEEK_END; + } + + void *null_function () + { + return NULL; + } + + int + c_fileno (s) + FILE *s; + { + return fileno (s); + } diff -Nrc3pad gcc-3.2.3/gcc/ada/a-witeio.adb gcc-3.3/gcc/ada/a-witeio.adb *** gcc-3.2.3/gcc/ada/a-witeio.adb 2002-05-04 03:27:29.000000000 +0000 --- gcc-3.3/gcc/ada/a-witeio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Ada.Wide_Text_IO is *** 88,93 **** --- 87,94 ---- (Control_Block : Wide_Text_AFCB) return FCB.AFCB_Ptr is + pragma Warnings (Off, Control_Block); + begin return new Wide_Text_AFCB; end AFCB_Allocate; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-witeio.ads gcc-3.3/gcc/ada/a-witeio.ads *** gcc-3.2.3/gcc/ada/a-witeio.ads 2002-05-04 03:27:29.000000000 +0000 --- gcc-3.3/gcc/ada/a-witeio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtcoau.adb gcc-3.3/gcc/ada/a-wtcoau.adb *** gcc-3.2.3/gcc/ada/a-wtcoau.adb 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtcoau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtcoau.ads gcc-3.3/gcc/ada/a-wtcoau.ads *** gcc-3.2.3/gcc/ada/a-wtcoau.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtcoau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtcoio.adb gcc-3.3/gcc/ada/a-wtcoio.adb *** gcc-3.2.3/gcc/ada/a-wtcoio.adb 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtcoio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtcoio.ads gcc-3.3/gcc/ada/a-wtcoio.ads *** gcc-3.2.3/gcc/ada/a-wtcoio.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtcoio.ads 2002-03-14 10:58:59.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtcstr.adb gcc-3.3/gcc/ada/a-wtcstr.adb *** gcc-3.2.3/gcc/ada/a-wtcstr.adb 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtcstr.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtcstr.ads gcc-3.3/gcc/ada/a-wtcstr.ads *** gcc-3.2.3/gcc/ada/a-wtcstr.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtcstr.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtdeau.adb gcc-3.3/gcc/ada/a-wtdeau.adb *** gcc-3.2.3/gcc/ada/a-wtdeau.adb 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtdeau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Ada.Wide_Text_IO.Decimal_Au *** 68,74 **** end if; Item := Scan_Decimal (Buf, Ptr'Access, Stop, Scale); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); return Item; end Get_Dec; --- 67,73 ---- end if; Item := Scan_Decimal (Buf, Ptr'Access, Stop, Scale); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); return Item; end Get_Dec; *************** package body Ada.Wide_Text_IO.Decimal_Au *** 97,103 **** end if; Item := Scan_Long_Long_Decimal (Buf, Ptr'Access, Stop, Scale); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); return Item; end Get_LLD; --- 96,102 ---- end if; Item := Scan_Long_Long_Decimal (Buf, Ptr'Access, Stop, Scale); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); return Item; end Get_LLD; diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtdeau.ads gcc-3.3/gcc/ada/a-wtdeau.ads *** gcc-3.2.3/gcc/ada/a-wtdeau.ads 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtdeau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtdeio.adb gcc-3.3/gcc/ada/a-wtdeio.adb *** gcc-3.2.3/gcc/ada/a-wtdeio.adb 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtdeio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtdeio.ads gcc-3.3/gcc/ada/a-wtdeio.ads *** gcc-3.2.3/gcc/ada/a-wtdeio.ads 2002-05-07 08:22:09.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtdeio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtedit.adb gcc-3.3/gcc/ada/a-wtedit.adb *** gcc-3.2.3/gcc/ada/a-wtedit.adb 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtedit.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtedit.ads gcc-3.3/gcc/ada/a-wtedit.ads *** gcc-3.2.3/gcc/ada/a-wtedit.ads 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtedit.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtenau.adb gcc-3.3/gcc/ada/a-wtenau.adb *** gcc-3.2.3/gcc/ada/a-wtenau.adb 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtenau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Ada.Wide_Text_IO.Enumeratio *** 48,55 **** ----------------------- procedure Store_Char ! (File : File_Type; ! WC : Wide_Character; Buf : out Wide_String; Ptr : in out Integer); -- Store a single character in buffer, checking for overflow. --- 47,53 ---- ----------------------- procedure Store_Char ! (WC : Wide_Character; Buf : out Wide_String; Ptr : in out Integer); -- Store a single character in buffer, checking for overflow. *************** package body Ada.Wide_Text_IO.Enumeratio *** 59,65 **** -- least in the OS/2 version. function To_Lower (C : Character) return Character; - function To_Upper (C : Character) return Character; ------------------ -- Get_Enum_Lit -- --- 57,62 ---- *************** package body Ada.Wide_Text_IO.Enumeratio *** 83,89 **** if ch = Character'Pos (''') then Get (File, WC); ! Store_Char (File, WC, Buf, Buflen); ch := Nextc (TFT (File)); --- 80,86 ---- if ch = Character'Pos (''') then Get (File, WC); ! Store_Char (WC, Buf, Buflen); ch := Nextc (TFT (File)); *************** package body Ada.Wide_Text_IO.Enumeratio *** 92,98 **** end if; Get (File, WC); ! Store_Char (File, WC, Buf, Buflen); ch := Nextc (TFT (File)); --- 89,95 ---- end if; Get (File, WC); ! Store_Char (WC, Buf, Buflen); ch := Nextc (TFT (File)); *************** package body Ada.Wide_Text_IO.Enumeratio *** 101,107 **** end if; Get (File, WC); ! Store_Char (File, WC, Buf, Buflen); -- Similarly for identifiers, read as far as we can, in particular, -- do read a trailing underscore (again see ACVC test CE3905L to --- 98,104 ---- end if; Get (File, WC); ! Store_Char (WC, Buf, Buflen); -- Similarly for identifiers, read as far as we can, in particular, -- do read a trailing underscore (again see ACVC test CE3905L to *************** package body Ada.Wide_Text_IO.Enumeratio *** 121,127 **** loop Get (File, WC); ! Store_Char (File, WC, Buf, Buflen); ch := Nextc (TFT (File)); --- 118,124 ---- loop Get (File, WC); ! Store_Char (WC, Buf, Buflen); ch := Nextc (TFT (File)); *************** package body Ada.Wide_Text_IO.Enumeratio *** 328,335 **** ---------------- procedure Store_Char ! (File : File_Type; ! WC : Wide_Character; Buf : out Wide_String; Ptr : in out Integer) is --- 325,331 ---- ---------------- procedure Store_Char ! (WC : Wide_Character; Buf : out Wide_String; Ptr : in out Integer) is *************** package body Ada.Wide_Text_IO.Enumeratio *** 355,371 **** end if; end To_Lower; - -------------- - -- To_Upper -- - -------------- - - function To_Upper (C : Character) return Character is - begin - if C in 'a' .. 'z' then - return Character'Val (Character'Pos (C) - 32); - else - return C; - end if; - end To_Upper; - end Ada.Wide_Text_IO.Enumeration_Aux; --- 351,354 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtenau.ads gcc-3.3/gcc/ada/a-wtenau.ads *** gcc-3.2.3/gcc/ada/a-wtenau.ads 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtenau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtenio.adb gcc-3.3/gcc/ada/a-wtenio.adb *** gcc-3.2.3/gcc/ada/a-wtenio.adb 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtenio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtenio.ads gcc-3.3/gcc/ada/a-wtenio.ads *** gcc-3.2.3/gcc/ada/a-wtenio.ads 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtenio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtfiio.adb gcc-3.3/gcc/ada/a-wtfiio.adb *** gcc-3.2.3/gcc/ada/a-wtfiio.adb 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtfiio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtfiio.ads gcc-3.3/gcc/ada/a-wtfiio.ads *** gcc-3.2.3/gcc/ada/a-wtfiio.ads 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtfiio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtflau.adb gcc-3.3/gcc/ada/a-wtflau.adb *** gcc-3.2.3/gcc/ada/a-wtflau.adb 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtflau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1998 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body Ada.Wide_Text_IO.Float_Aux *** 63,69 **** Item := Scan_Real (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get; ---------- --- 62,68 ---- Item := Scan_Real (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get; ---------- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtflau.ads gcc-3.3/gcc/ada/a-wtflau.ads *** gcc-3.2.3/gcc/ada/a-wtflau.ads 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtflau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtflio.adb gcc-3.3/gcc/ada/a-wtflio.adb *** gcc-3.2.3/gcc/ada/a-wtflio.adb 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtflio.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtflio.ads gcc-3.3/gcc/ada/a-wtflio.ads *** gcc-3.2.3/gcc/ada/a-wtflio.ads 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtflio.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtgeau.adb gcc-3.3/gcc/ada/a-wtgeau.adb *** gcc-3.2.3/gcc/ada/a-wtgeau.adb 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtgeau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body Ada.Wide_Text_IO.Generic_Au *** 48,55 **** ------------------------ procedure Check_End_Of_Field ! (File : File_Type; ! Buf : String; Stop : Integer; Ptr : Integer; Width : Field) --- 47,53 ---- ------------------------ procedure Check_End_Of_Field ! (Buf : String; Stop : Integer; Ptr : Integer; Width : Field) diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtgeau.ads gcc-3.3/gcc/ada/a-wtgeau.ads *** gcc-3.2.3/gcc/ada/a-wtgeau.ads 2002-05-04 03:27:30.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtgeau.ads 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Ada.Wide_Text_IO.Generic_Aux is *** 52,59 **** -- so one of these two routines must be called first. procedure Check_End_Of_Field ! (File : File_Type; ! Buf : String; Stop : Integer; Ptr : Integer; Width : Field); --- 51,57 ---- -- so one of these two routines must be called first. procedure Check_End_Of_Field ! (Buf : String; Stop : Integer; Ptr : Integer; Width : Field); diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtinau.adb gcc-3.3/gcc/ada/a-wtinau.adb *** gcc-3.2.3/gcc/ada/a-wtinau.adb 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtinau.adb 2002-10-23 07:33:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992,1993,1994,1995,1996 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body Ada.Wide_Text_IO.Integer_Au *** 80,86 **** end if; Item := Scan_Integer (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get_Int; ------------- --- 79,85 ---- end if; Item := Scan_Integer (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get_Int; ------------- *************** package body Ada.Wide_Text_IO.Integer_Au *** 105,111 **** end if; Item := Scan_Long_Long_Integer (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get_LLI; -------------- --- 104,110 ---- end if; Item := Scan_Long_Long_Integer (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get_LLI; -------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtinau.ads gcc-3.3/gcc/ada/a-wtinau.ads *** gcc-3.2.3/gcc/ada/a-wtinau.ads 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtinau.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtinio.adb gcc-3.3/gcc/ada/a-wtinio.adb *** gcc-3.2.3/gcc/ada/a-wtinio.adb 2002-05-04 03:27:31.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtinio.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtinio.ads gcc-3.3/gcc/ada/a-wtinio.ads *** gcc-3.2.3/gcc/ada/a-wtinio.ads 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtinio.ads 2002-03-14 10:59:00.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtmoau.adb gcc-3.3/gcc/ada/a-wtmoau.adb *** gcc-3.2.3/gcc/ada/a-wtmoau.adb 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtmoau.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Ada.Wide_Text_IO.Modular_Au *** 82,88 **** end if; Item := Scan_Long_Long_Unsigned (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get_LLU; ------------- --- 81,87 ---- end if; Item := Scan_Long_Long_Unsigned (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get_LLU; ------------- *************** package body Ada.Wide_Text_IO.Modular_Au *** 107,113 **** end if; Item := Scan_Unsigned (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (File, Buf, Stop, Ptr, Width); end Get_Uns; -------------- --- 106,112 ---- end if; Item := Scan_Unsigned (Buf, Ptr'Access, Stop); ! Check_End_Of_Field (Buf, Stop, Ptr, Width); end Get_Uns; -------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtmoau.ads gcc-3.3/gcc/ada/a-wtmoau.ads *** gcc-3.2.3/gcc/ada/a-wtmoau.ads 2002-05-07 08:22:10.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtmoau.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtmoio.adb gcc-3.3/gcc/ada/a-wtmoio.adb *** gcc-3.2.3/gcc/ada/a-wtmoio.adb 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtmoio.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wtmoio.ads gcc-3.3/gcc/ada/a-wtmoio.ads *** gcc-3.2.3/gcc/ada/a-wtmoio.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/a-wtmoio.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wttest.adb gcc-3.3/gcc/ada/a-wttest.adb *** gcc-3.2.3/gcc/ada/a-wttest.adb 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/a-wttest.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/a-wttest.ads gcc-3.3/gcc/ada/a-wttest.ads *** gcc-3.2.3/gcc/ada/a-wttest.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/a-wttest.ads 2002-03-14 10:59:01.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/back_end.adb gcc-3.3/gcc/ada/back_end.adb *** gcc-3.2.3/gcc/ada/back_end.adb 2002-05-04 03:27:33.000000000 +0000 --- gcc-3.3/gcc/ada/back_end.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 26,51 **** -- -- ------------------------------------------------------------------------------ ! with Atree; use Atree; ! with Debug; use Debug; ! with Elists; use Elists; ! with Lib; use Lib; ! with Osint; use Osint; ! with Opt; use Opt; ! with Osint; use Osint; ! with Namet; use Namet; ! with Nlists; use Nlists; ! with Stand; use Stand; ! with Sinput; use Sinput; ! with Stringt; use Stringt; ! with Switch; use Switch; ! with System; use System; ! with Types; use Types; package body Back_End is - -- Local subprograms - ------------------- -- Call_Back_End -- ------------------- --- 25,50 ---- -- -- ------------------------------------------------------------------------------ ! with Atree; use Atree; ! with Debug; use Debug; ! with Elists; use Elists; ! with Lib; use Lib; ! with Osint; use Osint; ! with Opt; use Opt; ! with Osint; use Osint; ! with Osint.C; use Osint.C; ! with Namet; use Namet; ! with Nlists; use Nlists; ! with Stand; use Stand; ! with Sinput; use Sinput; ! with Stringt; use Stringt; ! with Switch; use Switch; ! with Switch.C; use Switch.C; ! with System; use System; ! with Types; use Types; package body Back_End is ------------------- -- Call_Back_End -- ------------------- *************** package body Back_End is *** 209,225 **** Last := Last - 1; end if; if Switch_Chars (First .. Last) = "o" or else Switch_Chars (First .. Last) = "dumpbase" then Next_Arg := Next_Arg + 1; elsif Switch_Chars (First .. Last) = "quiet" then ! null; -- do not record this switch else -- Store any other GCC switches Store_Compilation_Switch (Switch_Chars); end if; end Scan_Back_End_Switches; --- 208,230 ---- Last := Last - 1; end if; + -- For dumpbase and o, skip following argument and do not + -- store either the switch or the following argument + if Switch_Chars (First .. Last) = "o" or else Switch_Chars (First .. Last) = "dumpbase" then Next_Arg := Next_Arg + 1; + -- Do not record -quiet switch + elsif Switch_Chars (First .. Last) = "quiet" then ! null; else -- Store any other GCC switches + Store_Compilation_Switch (Switch_Chars); end if; end Scan_Back_End_Switches; *************** package body Back_End is *** 259,273 **** elsif not Is_Switch (Argv) then -- must be a file name Add_File (Argv); ! elsif Is_Front_End_Switch (Argv) then ! Scan_Front_End_Switches (Argv); ! -- ??? Should be done in Scan_Front_End_Switches, after ! -- Switch is splitted in compiler/make/bind units ! if Argv (2) /= 'I' then ! Store_Compilation_Switch (Argv); ! end if; -- All non-front-end switches are back-end switches --- 264,278 ---- elsif not Is_Switch (Argv) then -- must be a file name Add_File (Argv); ! -- We must recognize -nostdinc to suppress visibility on the ! -- standard GNAT RTL sources. This is also a gcc switch. ! elsif Argv (Argv'First + 1 .. Argv'Last) = "nostdinc" then ! Opt.No_Stdinc := True; ! Scan_Back_End_Switches (Argv); ! elsif Is_Front_End_Switch (Argv) then ! Scan_Front_End_Switches (Argv); -- All non-front-end switches are back-end switches diff -Nrc3pad gcc-3.2.3/gcc/ada/back_end.ads gcc-3.3/gcc/ada/back_end.ads *** gcc-3.2.3/gcc/ada/back_end.ads 2002-05-04 03:27:33.000000000 +0000 --- gcc-3.3/gcc/ada/back_end.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/bcheck.adb gcc-3.3/gcc/ada/bcheck.adb *** gcc-3.2.3/gcc/ada/bcheck.adb 2002-05-04 03:27:33.000000000 +0000 --- gcc-3.3/gcc/ada/bcheck.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with ALI.Util; use ALI.Util; *** 31,37 **** with Binderr; use Binderr; with Butil; use Butil; with Casing; use Casing; - with Debug; use Debug; with Fname; use Fname; with Namet; use Namet; with Opt; use Opt; --- 30,35 ---- *************** package body Bcheck is *** 359,440 **** -- Second, all units are verified against the specified restrictions. procedure Check_Partition_Restrictions is ! R : array (Partition_Restrictions) of ALI_Id := (others => No_ALI_Id); ! -- Record the first unit specifying each partition restriction ! ! V : array (Partition_Restrictions) of ALI_Id := (others => No_ALI_Id); ! -- Record the last unit violating each partition restriction ! ! procedure List_Applicable_Restrictions; ! -- Output a list of restrictions that may be applied to the partition, ! -- without causing bind errors. ! ! ---------------------------------- ! -- List_Applicable_Restrictions -- ! ---------------------------------- ! ! procedure List_Applicable_Restrictions is ! Additional_Restrictions_Listed : Boolean := False; ! begin ! -- List any restrictions which were not violated and not specified ! for J in Partition_Restrictions loop ! if V (J) = No_ALI_Id and R (J) = No_ALI_Id then ! if not Additional_Restrictions_Listed then ! Write_Str ("The following additional restrictions may be" & ! " applied to this partition:"); ! Write_Eol; ! Additional_Restrictions_Listed := True; ! end if; ! Write_Str ("pragma Restrictions ("); ! declare ! S : constant String := Restriction_Id'Image (J); ! begin ! Name_Len := S'Length; ! Name_Buffer (1 .. Name_Len) := S; ! end; ! Set_Casing (Mixed_Case); ! Write_Str (Name_Buffer (1 .. Name_Len)); ! Write_Str (");"); ! Write_Eol; ! end if; ! end loop; ! end List_Applicable_Restrictions; ! -- Start of processing for Check_Partition_Restrictions begin ! Find_Restrictions : for A in ALIs.First .. ALIs.Last loop ! for J in Partition_Restrictions loop if R (J) = No_ALI_Id and ALIs.Table (A).Restrictions (J) = 'r' then R (J) := A; end if; end loop; ! end loop Find_Restrictions; - Find_Violations : for A in ALIs.First .. ALIs.Last loop ! for J in Partition_Restrictions loop if ALIs.Table (A).Restrictions (J) = 'v' and then not Is_Internal_File_Name (ALIs.Table (A).Sfile) then ! -- A violation of a restriction was found, so check whether ! -- that restriction was actually in effect. If so, give an ! -- error message. ! ! -- Note that all such violations found are reported. V (J) := A; ! if R (J) /= No_ALI_Id then ! Report_Violated_Restriction : declare M1 : constant String := "% has Restriction ("; S : constant String := Restriction_Id'Image (J); M2 : String (1 .. M1'Length + S'Length + 1); --- 357,427 ---- -- Second, all units are verified against the specified restrictions. procedure Check_Partition_Restrictions is + No_Restriction_List : array (All_Restrictions) of Boolean := + (No_Implicit_Conditionals => True, + -- This could modify and pessimize generated code ! No_Implicit_Dynamic_Code => True, ! -- This could modify and pessimize generated code ! No_Implicit_Loops => True, ! -- This could modify and pessimize generated code ! No_Recursion => True, ! -- Not checkable at compile time ! No_Reentrancy => True, ! -- Not checkable at compile time ! others => False); ! -- Define those restrictions that should be output if the gnatbind -r ! -- switch is used. Not all restrictions are output for the reasons given ! -- above in the list, and this array is used to test whether the ! -- corresponding pragma should be listed. True means that it should not ! -- be listed. ! R : array (All_Restrictions) of ALI_Id := (others => No_ALI_Id); ! -- Record the first unit specifying each compilation unit restriction ! V : array (All_Restrictions) of ALI_Id := (others => No_ALI_Id); ! -- Record the last unit violating each partition restriction. Note ! -- that entries in this array that do not correspond to partition ! -- restrictions can never be modified. ! Additional_Restrictions_Listed : Boolean := False; ! -- Set True if we have listed header for restrictions begin ! -- Loop to find restrictions ! for A in ALIs.First .. ALIs.Last loop ! for J in All_Restrictions loop if R (J) = No_ALI_Id and ALIs.Table (A).Restrictions (J) = 'r' then R (J) := A; end if; end loop; ! end loop; ! ! -- Loop to find violations for A in ALIs.First .. ALIs.Last loop ! for J in All_Restrictions loop if ALIs.Table (A).Restrictions (J) = 'v' and then not Is_Internal_File_Name (ALIs.Table (A).Sfile) then ! -- A violation of a restriction was found V (J) := A; ! -- If this is a paritition restriction, and the restriction ! -- was specified in some unit in the partition, then this ! -- is a violation of the consistency requirement, so we ! -- generate an appropriate error message. ! ! if R (J) /= No_ALI_Id ! and then J in Partition_Restrictions ! then ! declare M1 : constant String := "% has Restriction ("; S : constant String := Restriction_Id'Image (J); M2 : String (1 .. M1'Length + S'Length + 1); *************** package body Bcheck is *** 455,468 **** Error_Msg_Name_1 := ALIs.Table (A).Sfile; Consistency_Error_Msg ("but file % violates this restriction"); ! end Report_Violated_Restriction; end if; end if; end loop; ! end loop Find_Violations; ! if Debug_Flag_R then ! List_Applicable_Restrictions; end if; end Check_Partition_Restrictions; --- 442,488 ---- Error_Msg_Name_1 := ALIs.Table (A).Sfile; Consistency_Error_Msg ("but file % violates this restriction"); ! end; end if; end if; end loop; ! end loop; ! -- List applicable restrictions if option set ! ! if List_Restrictions then ! ! -- List any restrictions which were not violated and not specified ! ! for J in All_Restrictions loop ! if V (J) = No_ALI_Id ! and then R (J) = No_ALI_Id ! and then not No_Restriction_List (J) ! then ! if not Additional_Restrictions_Listed then ! Write_Eol; ! Write_Line ! ("The following additional restrictions may be" & ! " applied to this partition:"); ! Additional_Restrictions_Listed := True; ! end if; ! ! Write_Str ("pragma Restrictions ("); ! ! declare ! S : constant String := Restriction_Id'Image (J); ! ! begin ! Name_Len := S'Length; ! Name_Buffer (1 .. Name_Len) := S; ! end; ! ! Set_Casing (Mixed_Case); ! Write_Str (Name_Buffer (1 .. Name_Len)); ! Write_Str (");"); ! Write_Eol; ! end if; ! end loop; end if; end Check_Partition_Restrictions; diff -Nrc3pad gcc-3.2.3/gcc/ada/bcheck.ads gcc-3.3/gcc/ada/bcheck.ads *** gcc-3.2.3/gcc/ada/bcheck.ads 2002-05-04 03:27:33.000000000 +0000 --- gcc-3.3/gcc/ada/bcheck.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/binde.adb gcc-3.3/gcc/ada/binde.adb *** gcc-3.2.3/gcc/ada/binde.adb 2002-05-04 03:27:33.000000000 +0000 --- gcc-3.3/gcc/ada/binde.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/binde.ads gcc-3.3/gcc/ada/binde.ads *** gcc-3.2.3/gcc/ada/binde.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/binde.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/binderr.adb gcc-3.3/gcc/ada/binderr.adb *** gcc-3.2.3/gcc/ada/binderr.adb 2002-05-04 03:27:34.000000000 +0000 --- gcc-3.3/gcc/ada/binderr.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/binderr.ads gcc-3.3/gcc/ada/binderr.ads *** gcc-3.2.3/gcc/ada/binderr.ads 2002-05-04 03:27:34.000000000 +0000 --- gcc-3.3/gcc/ada/binderr.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/bindgen.adb gcc-3.3/gcc/ada/bindgen.adb *** gcc-3.2.3/gcc/ada/bindgen.adb 2002-05-04 03:27:34.000000000 +0000 --- gcc-3.3/gcc/ada/bindgen.adb 2002-11-15 01:45:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.10.2 $ -- -- -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Hostparm; *** 37,46 **** with Namet; use Namet; with Opt; use Opt; with Osint; use Osint; with Output; use Output; with Types; use Types; with Sdefault; use Sdefault; - with System; use System; with GNAT.Heap_Sort_A; use GNAT.Heap_Sort_A; --- 36,45 ---- with Namet; use Namet; with Opt; use Opt; with Osint; use Osint; + with Osint.B; use Osint.B; with Output; use Output; with Types; use Types; with Sdefault; use Sdefault; with GNAT.Heap_Sort_A; use GNAT.Heap_Sort_A; *************** package body Bindgen is *** 63,83 **** Num_Elab_Calls : Nat := 0; -- Number of generated calls to elaboration routines - subtype chars_ptr is Address; - ----------------------- -- Local Subprograms -- ----------------------- ! procedure WBI (Info : String) renames Osint.Write_Binder_Info; -- Convenient shorthand used throughout - function ABE_Boolean_Required (U : Unit_Id) return Boolean; - -- Given a unit id value U, determines if the corresponding unit requires - -- an access-before-elaboration check variable, i.e. it is a non-predefined - -- body for which no pragma Elaborate, Elaborate_All or Elaborate_Body is - -- present, and thus could require ABE checks. - procedure Resolve_Binder_Options; -- Set the value of With_GNARL and With_DECGNAT. The latter only on VMS -- since it tests for a package named "dec" which might cause a conflict --- 62,74 ---- Num_Elab_Calls : Nat := 0; -- Number of generated calls to elaboration routines ----------------------- -- Local Subprograms -- ----------------------- ! procedure WBI (Info : String) renames Osint.B.Write_Binder_Info; -- Convenient shorthand used throughout procedure Resolve_Binder_Options; -- Set the value of With_GNARL and With_DECGNAT. The latter only on VMS -- since it tests for a package named "dec" which might cause a conflict *************** package body Bindgen is *** 162,170 **** function Lt_Linker_Option (Op1, Op2 : Natural) return Boolean; -- Compare linker options, when sorting, first according to ! -- Is_Internal_File (internal files come later) and then by elaboration ! -- order position (latest to earliest) except its not possible to ! -- distinguish between a linker option in the spec and one in the body. procedure Move_Linker_Option (From : Natural; To : Natural); -- Move routine for sorting linker options --- 153,160 ---- function Lt_Linker_Option (Op1, Op2 : Natural) return Boolean; -- Compare linker options, when sorting, first according to ! -- Is_Internal_File (internal files come later) and then by ! -- elaboration order position (latest to earliest). procedure Move_Linker_Option (From : Natural; To : Natural); -- Move routine for sorting linker options *************** package body Bindgen is *** 204,212 **** -- If Last is greater than or equal to N, no effect, otherwise store -- blanks in Statement_Buffer bumping Last, until Last = N. - function Value (chars : chars_ptr) return String; - -- Return C NUL-terminated string at chars as an Ada string - procedure Write_Info_Ada_C (Ada : String; C : String; Common : String); -- For C code case, write C & Common, for Ada case write Ada & Common -- to current binder output file using Write_Binder_Info. --- 194,199 ---- *************** package body Bindgen is *** 218,248 **** -- First writes its argument (using Set_String (S)), then writes out the -- contents of statement buffer up to Last, and reset Last to 0 - -------------------------- - -- ABE_Boolean_Required -- - -------------------------- - - function ABE_Boolean_Required (U : Unit_Id) return Boolean is - Typ : constant Unit_Type := Units.Table (U).Utype; - Unit : Unit_Id; - - begin - if Typ /= Is_Body then - return False; - - else - Unit := U + 1; - - return (not Units.Table (Unit).Pure) - and then - (not Units.Table (Unit).Preelab) - and then - (not Units.Table (Unit).Elaborate_Body) - and then - (not Units.Table (Unit).Predefined); - end if; - end ABE_Boolean_Required; - ---------------------- -- Gen_Adafinal_Ada -- ---------------------- --- 205,210 ---- *************** package body Bindgen is *** 283,288 **** --- 245,251 ---- procedure Gen_Adainit_Ada is Main_Priority : Int renames ALIs.Table (ALIs.First).Main_Priority; + begin WBI (" procedure " & Ada_Init_Name.all & " is"); *************** package body Bindgen is *** 339,355 **** Write_Statement_Buffer; ! -- Normal case (not No_Run_Time mode). The global values are ! -- assigned using the runtime routine Set_Globals (we have to use ! -- the routine call, rather than define the globals in the binder ! -- file to deal with cross-library calls in some systems. if No_Run_Time_Specified then - - -- Case of No_Run_Time mode. The only global variable that might - -- be needed (by the Ravenscar profile) is the priority of the - -- environment. Also no exception tables are needed. - if Main_Priority /= No_Main_Priority then WBI (" Main_Priority : Integer;"); WBI (" pragma Import (C, Main_Priority," & --- 302,312 ---- Write_Statement_Buffer; ! -- Case of No_Run_Time mode. The only global variable that might ! -- be needed (by the Ravenscar profile) is the priority of the ! -- environment. Also no exception tables are needed. if No_Run_Time_Specified then if Main_Priority /= No_Main_Priority then WBI (" Main_Priority : Integer;"); WBI (" pragma Import (C, Main_Priority," & *************** package body Bindgen is *** 369,376 **** --- 326,351 ---- WBI (" null;"); end if; + -- Normal case (not No_Run_Time mode). The global values are + -- assigned using the runtime routine Set_Globals (we have to use + -- the routine call, rather than define the globals in the binder + -- file to deal with cross-library calls in some systems. + else + -- Generate restrictions string + + Set_String (" Restrictions : constant String :="); + Write_Statement_Buffer; + Set_String (" """); + + for J in Restrictions'Range loop + Set_Char (Restrictions (J)); + end loop; + + Set_String (""";"); + Write_Statement_Buffer; WBI (""); + WBI (" procedure Set_Globals"); WBI (" (Main_Priority : Integer;"); WBI (" Time_Slice_Value : Integer;"); *************** package body Bindgen is *** 378,392 **** WBI (" Locking_Policy : Character;"); WBI (" Queuing_Policy : Character;"); WBI (" Task_Dispatching_Policy : Character;"); ! WBI (" Adafinal : System.Address;"); WBI (" Unreserve_All_Interrupts : Integer;"); ! WBI (" Exception_Tracebacks : Integer);"); WBI (" pragma Import (C, Set_Globals, ""__gnat_set_globals"");"); - WBI (""); -- Import entry point for elaboration time signal handler -- installation, and indication of whether it's been called -- previously WBI (""); WBI (" procedure Install_Handler;"); WBI (" pragma Import (C, Install_Handler, " & --- 353,368 ---- WBI (" Locking_Policy : Character;"); WBI (" Queuing_Policy : Character;"); WBI (" Task_Dispatching_Policy : Character;"); ! WBI (" Restrictions : System.Address;"); WBI (" Unreserve_All_Interrupts : Integer;"); ! WBI (" Exception_Tracebacks : Integer;"); ! WBI (" Zero_Cost_Exceptions : Integer);"); WBI (" pragma Import (C, Set_Globals, ""__gnat_set_globals"");"); -- Import entry point for elaboration time signal handler -- installation, and indication of whether it's been called -- previously + WBI (""); WBI (" procedure Install_Handler;"); WBI (" pragma Import (C, Install_Handler, " & *************** package body Bindgen is *** 442,448 **** Set_String ("',"); Write_Statement_Buffer; ! WBI (" Adafinal => System.Null_Address,"); Set_String (" Unreserve_All_Interrupts => "); --- 418,424 ---- Set_String ("',"); Write_Statement_Buffer; ! WBI (" Restrictions => Restrictions'Address,"); Set_String (" Unreserve_All_Interrupts => "); *************** package body Bindgen is *** 463,468 **** --- 439,455 ---- Set_String ("0"); end if; + Set_String (","); + Write_Statement_Buffer; + + Set_String (" Zero_Cost_Exceptions => "); + + if Zero_Cost_Exceptions_Specified then + Set_String ("1"); + else + Set_String ("0"); + end if; + Set_String (");"); Write_Statement_Buffer; *************** package body Bindgen is *** 484,489 **** --- 471,477 ---- procedure Gen_Adainit_C is Main_Priority : Int renames ALIs.Table (ALIs.First).Main_Priority; + begin WBI ("void " & Ada_Init_Name.all & " ()"); WBI ("{"); *************** package body Bindgen is *** 508,513 **** --- 496,503 ---- Write_Statement_Buffer; + -- No run-time case + if No_Run_Time_Specified then -- Case of No_Run_Time mode. Set __gl_main_priority if needed *************** package body Bindgen is *** 520,526 **** --- 510,529 ---- Write_Statement_Buffer; end if; + -- Normal case (run time present) + else + -- Generate definition for restrictions string + + Set_String (" const char *restrictions = """); + + for J in Restrictions'Range loop + Set_Char (Restrictions (J)); + end loop; + + Set_String (""";"); + Write_Statement_Buffer; + -- Code for normal case (not in No_Run_Time mode) Gen_Exception_Table_C; *************** package body Bindgen is *** 553,611 **** end if; Set_Char (','); ! Tab_To (15); Set_String ("/* Time_Slice_Value */"); Write_Statement_Buffer; Set_String (" '"); Set_Char (ALIs.Table (ALIs.First).WC_Encoding); Set_String ("',"); ! Tab_To (15); Set_String ("/* WC_Encoding */"); Write_Statement_Buffer; Set_String (" '"); Set_Char (Locking_Policy_Specified); Set_String ("',"); ! Tab_To (15); Set_String ("/* Locking_Policy */"); Write_Statement_Buffer; Set_String (" '"); Set_Char (Queuing_Policy_Specified); Set_String ("',"); ! Tab_To (15); Set_String ("/* Queuing_Policy */"); Write_Statement_Buffer; Set_String (" '"); Set_Char (Task_Dispatching_Policy_Specified); Set_String ("',"); ! Tab_To (15); Set_String ("/* Tasking_Dispatching_Policy */"); Write_Statement_Buffer; Set_String (" "); ! Set_String ("0,"); ! Tab_To (15); ! Set_String ("/* Finalization routine address, not used anymore */"); Write_Statement_Buffer; Set_String (" "); Set_Int (Boolean'Pos (Unreserve_All_Interrupts_Specified)); Set_String (","); ! Tab_To (15); Set_String ("/* Unreserve_All_Interrupts */"); Write_Statement_Buffer; Set_String (" "); Set_Int (Boolean'Pos (Exception_Tracebacks)); ! Set_String (");"); ! Tab_To (15); Set_String ("/* Exception_Tracebacks */"); Write_Statement_Buffer; -- Install elaboration time signal handler WBI (" if (__gnat_handler_installed == 0)"); WBI (" {"); WBI (" __gnat_install_handler ();"); --- 556,623 ---- end if; Set_Char (','); ! Tab_To (20); Set_String ("/* Time_Slice_Value */"); Write_Statement_Buffer; Set_String (" '"); Set_Char (ALIs.Table (ALIs.First).WC_Encoding); Set_String ("',"); ! Tab_To (20); Set_String ("/* WC_Encoding */"); Write_Statement_Buffer; Set_String (" '"); Set_Char (Locking_Policy_Specified); Set_String ("',"); ! Tab_To (20); Set_String ("/* Locking_Policy */"); Write_Statement_Buffer; Set_String (" '"); Set_Char (Queuing_Policy_Specified); Set_String ("',"); ! Tab_To (20); Set_String ("/* Queuing_Policy */"); Write_Statement_Buffer; Set_String (" '"); Set_Char (Task_Dispatching_Policy_Specified); Set_String ("',"); ! Tab_To (20); Set_String ("/* Tasking_Dispatching_Policy */"); Write_Statement_Buffer; Set_String (" "); ! Set_String ("restrictions"); ! Set_String (","); ! Tab_To (20); ! Set_String ("/* Restrictions */"); Write_Statement_Buffer; Set_String (" "); Set_Int (Boolean'Pos (Unreserve_All_Interrupts_Specified)); Set_String (","); ! Tab_To (20); Set_String ("/* Unreserve_All_Interrupts */"); Write_Statement_Buffer; Set_String (" "); Set_Int (Boolean'Pos (Exception_Tracebacks)); ! Set_String (","); ! Tab_To (20); Set_String ("/* Exception_Tracebacks */"); Write_Statement_Buffer; + Set_String (" "); + Set_Int (Boolean'Pos (Zero_Cost_Exceptions_Specified)); + Set_String (");"); + Tab_To (20); + Set_String ("/* Zero_Cost_Exceptions */"); + Write_Statement_Buffer; + -- Install elaboration time signal handler + WBI (" if (__gnat_handler_installed == 0)"); WBI (" {"); WBI (" __gnat_install_handler ();"); *************** package body Bindgen is *** 635,651 **** -- and spec are different and we are currently processing -- the body, in which case it is the spec (Unum + 1). - procedure Set_Elab_Entity; - -- Set name of elaboration entity flag - - procedure Set_Elab_Entity is - begin - Get_Decoded_Name_String_With_Brackets (U.Uname); - Name_Len := Name_Len - 2; - Set_Casing (U.Icasing); - Set_Name_Buffer; - end Set_Elab_Entity; - begin if U.Utype = Is_Body then Unum_Spec := Unum + 1; --- 647,652 ---- *************** package body Bindgen is *** 1169,1175 **** procedure Gen_Main_Ada is Target : constant String_Ptr := Target_Name; VxWorks_Target : constant Boolean := ! Target (Target'Last - 7 .. Target'Last) = "vxworks/"; begin WBI (""); --- 1170,1177 ---- procedure Gen_Main_Ada is Target : constant String_Ptr := Target_Name; VxWorks_Target : constant Boolean := ! Target (Target'Last - 7 .. Target'Last) = "vxworks/" ! or else Target (Target'Last - 9 .. Target'Last) = "vxworksae/"; begin WBI (""); *************** package body Bindgen is *** 1237,1242 **** --- 1239,1257 ---- WBI (""); end if; + -- Generate a reference to Ada_Main_Program_Name. This symbol is + -- not referenced elsewhere in the generated program, but is needed + -- by the debugger (that's why it is generated in the first place). + -- The reference stops Ada_Main_Program_Name from being optimized + -- away by smart linkers, such as the AiX linker. + + if Bind_Main_Program then + WBI + (" Ensure_Reference : System.Address := " & + "Ada_Main_Program_Name'Address;"); + WBI (""); + end if; + WBI (" begin"); -- On VxWorks, there are no command line arguments *************** package body Bindgen is *** 1311,1317 **** procedure Gen_Main_C is Target : constant String_Ptr := Target_Name; VxWorks_Target : constant Boolean := ! Target (Target'Last - 7 .. Target'Last) = "vxworks/"; begin Set_String ("int "); --- 1326,1333 ---- procedure Gen_Main_C is Target : constant String_Ptr := Target_Name; VxWorks_Target : constant Boolean := ! Target (Target'Last - 7 .. Target'Last) = "vxworks/" ! or else Target (Target'Last - 9 .. Target'Last) = "vxworksae/"; begin Set_String ("int "); *************** package body Bindgen is *** 1347,1352 **** --- 1363,1379 ---- WBI (" char **envp;"); WBI ("{"); + -- Generate a reference to __gnat_ada_main_program_name. This symbol + -- is not referenced elsewhere in the generated program, but is + -- needed by the debugger (that's why it is generated in the first + -- place). The reference stops Ada_Main_Program_Name from being + -- optimized away by smart linkers, such as the AiX linker. + + if Bind_Main_Program then + WBI (" char *ensure_reference = __gnat_ada_main_program_name;"); + WBI (""); + end if; + if ALIs.Table (ALIs.First).Main_Program = Func then WBI (" int result;"); end if; *************** package body Bindgen is *** 1439,1445 **** ------------------------------ procedure Gen_Object_Files_Options is ! Lgnat : Integer; procedure Write_Linker_Option; -- Write binder info linker option. --- 1466,1475 ---- ------------------------------ procedure Gen_Object_Files_Options is ! Lgnat : Natural; ! -- This keeps track of the position in the sorted set of entries ! -- in the Linker_Options table of where the first entry from an ! -- internal file appears. procedure Write_Linker_Option; -- Write binder info linker option. *************** package body Bindgen is *** 1546,1555 **** -- Sort linker options ! Sort (Linker_Options.Last, Move_Linker_Option'Access, ! Lt_Linker_Option'Access); ! -- Write user linker options Lgnat := Linker_Options.Last + 1; --- 1576,1615 ---- -- Sort linker options ! -- This sort accomplishes two important purposes: ! -- a) All application files are sorted to the front, and all ! -- GNAT internal files are sorted to the end. This results ! -- in a well defined dividing line between the two sets of ! -- files, for the purpose of inserting certain standard ! -- library references into the linker arguments list. ! ! -- b) Given two different units, we sort the linker options so ! -- that those from a unit earlier in the elaboration order ! -- comes later in the list. This is a heuristic designed ! -- to create a more friendly order of linker options when ! -- the operations appear in separate units. The idea is that ! -- if unit A must be elaborated before unit B, then it is ! -- more likely that B references libraries included by A, ! -- than vice versa, so we want the libraries included by ! -- A to come after the libraries included by B. ! ! -- These two criteria are implemented by function Lt_Linker_Option. ! -- Note that a special case of b) is that specs are elaborated before ! -- bodies, so linker options from specs come after linker options ! -- for bodies, and again, the assumption is that libraries used by ! -- the body are more likely to reference libraries used by the spec, ! -- than vice versa. ! ! Sort ! (Linker_Options.Last, ! Move_Linker_Option'Access, ! Lt_Linker_Option'Access); ! ! -- Write user linker options, i.e. the set of linker options that ! -- come from all files other than GNAT internal files, Lgnat is ! -- left set to point to the first entry from a GNAT internal file, ! -- or past the end of the entriers if there are no internal files. Lgnat := Linker_Options.Last + 1; *************** package body Bindgen is *** 1563,1570 **** end if; end loop; ! if not (No_Run_Time_Specified or else Opt.No_Stdlib) then Name_Len := 0; if Opt.Shared_Libgnat then --- 1623,1634 ---- end if; end loop; ! -- Now we insert standard linker options that must appear after the ! -- entries from user files, and before the entries from GNAT run-time ! -- files. The reason for this decision is that libraries referenced ! -- by internal routines may reference these standard library entries. + if not (No_Run_Time_Specified or else Opt.No_Stdlib) then Name_Len := 0; if Opt.Shared_Libgnat then *************** package body Bindgen is *** 1573,1579 **** Add_Str_To_Name_Buffer ("-static"); end if; ! -- Write directly to avoid -K output. Write_Info_Ada_C (" -- ", "", Name_Buffer (1 .. Name_Len)); --- 1637,1643 ---- Add_Str_To_Name_Buffer ("-static"); end if; ! -- Write directly to avoid -K output (why???) Write_Info_Ada_C (" -- ", "", Name_Buffer (1 .. Name_Len)); *************** package body Bindgen is *** 1592,1601 **** Name_Len := 0; Add_Str_To_Name_Buffer ("-lgnat"); Write_Linker_Option; - end if; ! -- Write internal linker options for J in Lgnat .. Linker_Options.Last loop Get_Name_String (Linker_Options.Table (J).Name); --- 1656,1664 ---- Name_Len := 0; Add_Str_To_Name_Buffer ("-lgnat"); Write_Linker_Option; end if; ! -- Write linker options from all internal files for J in Lgnat .. Linker_Options.Last loop Get_Name_String (Linker_Options.Table (J).Name); *************** package body Bindgen is *** 1616,1623 **** procedure Gen_Output_File (Filename : String) is - -- Start of processing for Gen_Output_File - begin -- Override Ada_Bind_File and Bind_Main_Program for Java since -- JGNAT only supports Ada code, and the main program is already --- 1679,1684 ---- *************** package body Bindgen is *** 1672,1678 **** Target : constant String_Ptr := Target_Name; VxWorks_Target : constant Boolean := ! Target (Target'Last - 7 .. Target'Last) = "vxworks/"; begin -- Create spec first --- 1733,1740 ---- Target : constant String_Ptr := Target_Name; VxWorks_Target : constant Boolean := ! Target (Target'Last - 7 .. Target'Last) = "vxworks/" ! or else Target (Target'Last - 9 .. Target'Last) = "vxworksae/"; begin -- Create spec first *************** package body Bindgen is *** 1746,1752 **** end if; end if; ! -- Generate the GNAT_Version and Ada_Main_Program_name info only for -- the main program. Otherwise, it can lead under some circumstances -- to a symbol duplication during the link (for instance when a -- C program uses 2 Ada libraries) --- 1808,1814 ---- end if; end if; ! -- Generate the GNAT_Version and Ada_Main_Program_Name info only for -- the main program. Otherwise, it can lead under some circumstances -- to a symbol duplication during the link (for instance when a -- C program uses 2 Ada libraries) *************** package body Bindgen is *** 1931,1938 **** WBI (""); WBI ("extern void __gnat_set_globals "); ! WBI (" PARAMS ((int, int, int, int, int, int, "); ! WBI (" void (*) PARAMS ((void)), int, int));"); WBI ("extern void " & Ada_Final_Name.all & " PARAMS ((void));"); WBI ("extern void " & Ada_Init_Name.all & " PARAMS ((void));"); --- 1993,2000 ---- WBI (""); WBI ("extern void __gnat_set_globals "); ! WBI (" PARAMS ((int, int, int, int, int, int, const char *,"); ! WBI (" int, int, int));"); WBI ("extern void " & Ada_Final_Name.all & " PARAMS ((void));"); WBI ("extern void " & Ada_Init_Name.all & " PARAMS ((void));"); *************** package body Bindgen is *** 2572,2578 **** function Get_Main_Name return String is Target : constant String_Ptr := Target_Name; VxWorks_Target : constant Boolean := ! Target (Target'Last - 7 .. Target'Last) = "vxworks/"; begin -- Explicit name given with -M switch --- 2634,2641 ---- function Get_Main_Name return String is Target : constant String_Ptr := Target_Name; VxWorks_Target : constant Boolean := ! Target (Target'Last - 7 .. Target'Last) = "vxworks/" ! or else Target (Target'Last - 9 .. Target'Last) = "vxworksae/"; begin -- Explicit name given with -M switch *************** package body Bindgen is *** 2592,2598 **** -- since we can't have dots in a nested program name. Note that -- we do not include the %b at the end of the unit name. ! for J in reverse 1 .. Name_Len - 3 loop if J = 1 or else Name_Buffer (J - 1) = '.' then return Name_Buffer (J .. Name_Len - 2); end if; --- 2655,2661 ---- -- since we can't have dots in a nested program name. Note that -- we do not include the %b at the end of the unit name. ! for J in reverse 1 .. Name_Len - 2 loop if J = 1 or else Name_Buffer (J - 1) = '.' then return Name_Buffer (J .. Name_Len - 2); end if; *************** package body Bindgen is *** 2613,2639 **** function Lt_Linker_Option (Op1, Op2 : Natural) return Boolean is begin if Linker_Options.Table (Op1).Internal_File /= Linker_Options.Table (Op2).Internal_File then return Linker_Options.Table (Op1).Internal_File < ! Linker_Options.Table (Op2).Internal_File; else ! if Units.Table (Linker_Options.Table (Op1).Unit).Elab_Position ! /= ! Units.Table (Linker_Options.Table (Op2).Unit).Elab_Position ! then ! return Units.Table (Linker_Options.Table (Op1).Unit).Elab_Position ! > ! Units.Table (Linker_Options.Table (Op2).Unit).Elab_Position; - else - return Linker_Options.Table (Op1).Original_Pos - < - Linker_Options.Table (Op2).Original_Pos; - end if; end if; end Lt_Linker_Option; --- 2676,2702 ---- function Lt_Linker_Option (Op1, Op2 : Natural) return Boolean is begin + -- Sort internal files last + if Linker_Options.Table (Op1).Internal_File /= Linker_Options.Table (Op2).Internal_File then + -- Note: following test uses False < True + return Linker_Options.Table (Op1).Internal_File < ! Linker_Options.Table (Op2).Internal_File; ! ! -- If both internal or both non-internal, sort according to the ! -- elaboration position. A unit that is elaborated later should ! -- come earlier in the linker options list. ! else ! return Units.Table (Linker_Options.Table (Op1).Unit).Elab_Position ! > ! Units.Table (Linker_Options.Table (Op2).Unit).Elab_Position; end if; end Lt_Linker_Option; *************** package body Bindgen is *** 2791,2821 **** end loop; end Tab_To; - ----------- - -- Value -- - ----------- - - function Value (chars : chars_ptr) return String is - function Strlen (chars : chars_ptr) return Natural; - pragma Import (C, Strlen); - - begin - if chars = Null_Address then - return ""; - - else - declare - subtype Result_Type is String (1 .. Strlen (chars)); - - Result : Result_Type; - for Result'Address use chars; - - begin - return Result; - end; - end if; - end Value; - ---------------------- -- Write_Info_Ada_C -- ---------------------- --- 2854,2859 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/bindgen.ads gcc-3.3/gcc/ada/bindgen.ads *** gcc-3.2.3/gcc/ada/bindgen.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/bindgen.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/bindusg.adb gcc-3.3/gcc/ada/bindusg.adb *** gcc-3.2.3/gcc/ada/bindusg.adb 2002-05-04 03:27:35.000000000 +0000 --- gcc-3.3/gcc/ada/bindusg.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Output; use Output; *** 31,45 **** procedure Bindusg is - procedure Write_Switch_Char; - -- Write two spaces followed by appropriate switch character - - procedure Write_Switch_Char is - begin - Write_Str (" "); - Write_Char (Switch_Character); - end Write_Switch_Char; - -- Start of processing for Bindusg begin --- 30,35 ---- *************** begin *** 54,260 **** -- Line for -aO switch ! Write_Switch_Char; ! Write_Str ("aOdir Specify library files search path"); Write_Eol; -- Line for -aI switch ! Write_Switch_Char; ! Write_Str ("aIdir Specify source files search path"); Write_Eol; -- Line for A switch ! Write_Switch_Char; ! Write_Str ("A Generate binder program in Ada (default)"); Write_Eol; -- Line for -b switch ! Write_Switch_Char; ! Write_Str ("b Generate brief messages to std"); Write_Str ("err even if verbose mode set"); Write_Eol; -- Line for -c switch ! Write_Switch_Char; ! Write_Str ("c Check only, no generation of b"); Write_Str ("inder output file"); Write_Eol; -- Line for C switch ! Write_Switch_Char; ! Write_Str ("C Generate binder program in C"); Write_Eol; -- Line for -e switch ! Write_Switch_Char; ! Write_Str ("e Output complete list of elabor"); Write_Str ("ation order dependencies"); Write_Eol; -- Line for -E switch ! Write_Switch_Char; ! Write_Str ("E Store tracebacks in Exception occurrences"); Write_Eol; -- Line for -h switch ! Write_Switch_Char; ! Write_Str ("h Output this usage (help) infor"); Write_Str ("mation"); Write_Eol; -- Lines for -I switch ! Write_Switch_Char; ! Write_Str ("Idir Specify library and source files search path"); Write_Eol; ! Write_Switch_Char; ! Write_Str ("I- Don't look for sources & library files"); Write_Str (" in default directory"); Write_Eol; -- Line for -K switch ! Write_Switch_Char; ! Write_Str ("K Give list of linker options specified for link"); Write_Eol; -- Line for -l switch ! Write_Switch_Char; ! Write_Str ("l Output chosen elaboration order"); Write_Eol; -- Line of -L switch ! Write_Switch_Char; ! Write_Str ("Lxyz Library build: adainit/final "); Write_Str ("renamed to xyzinit/final, implies -n"); Write_Eol; -- Line for -M switch ! Write_Switch_Char; ! Write_Str ("Mxyz Rename generated main program from main to xyz"); Write_Eol; -- Line for -m switch ! Write_Switch_Char; ! Write_Str ("mnnn Limit number of detected error"); Write_Str ("s to nnn (1-999)"); Write_Eol; -- Line for -n switch ! Write_Switch_Char; ! Write_Str ("n No Ada main program (foreign main routine)"); Write_Eol; -- Line for -nostdinc ! Write_Switch_Char; ! Write_Str ("nostdinc Don't look for source files"); Write_Str (" in the system default directory"); Write_Eol; -- Line for -nostdlib ! Write_Switch_Char; ! Write_Str ("nostdlib Don't look for library files"); Write_Str (" in the system default directory"); Write_Eol; -- Line for -o switch ! Write_Switch_Char; ! Write_Str ("o file Give the output file name (default is b~xxx.adb) "); Write_Eol; -- Line for -O switch ! Write_Switch_Char; ! Write_Str ("O Give list of objects required for link"); Write_Eol; -- Line for -p switch ! Write_Switch_Char; ! Write_Str ("p Pessimistic (worst-case) elaborat"); Write_Str ("ion order"); Write_Eol; -- Line for -s switch ! Write_Switch_Char; ! Write_Str ("s Require all source files to be"); Write_Str (" present"); Write_Eol; -- Line for -Sxx switch ! Write_Switch_Char; ! Write_Str ("S?? Sin/lo/hi/xx for Initialize_Scalars"); Write_Str (" invalid/low/high/hex"); Write_Eol; -- Line for -static ! Write_Switch_Char; ! Write_Str ("static Link against a static GNAT run time"); Write_Eol; -- Line for -shared ! Write_Switch_Char; ! Write_Str ("shared Link against a shared GNAT run time"); Write_Eol; -- Line for -t switch ! Write_Switch_Char; ! Write_Str ("t Tolerate time stamp and other consistency errors"); Write_Eol; -- Line for -T switch ! Write_Switch_Char; ! Write_Str ("Tn Set time slice value to n microseconds (n >= 0)"); Write_Eol; -- Line for -v switch ! Write_Switch_Char; ! Write_Str ("v Verbose mode. Error messages, "); Write_Str ("header, summary output to stdout"); Write_Eol; -- Lines for -w switch ! Write_Switch_Char; ! Write_Str ("wx Warning mode. (x=s/e for supp"); Write_Str ("ress/treat as error)"); Write_Eol; -- Line for -x switch ! Write_Switch_Char; ! Write_Str ("x Exclude source files (check ob"); Write_Str ("ject consistency only)"); Write_Eol; -- Line for -z switch ! Write_Switch_Char; ! Write_Str ("z No main subprogram (zero main)"); Write_Eol; -- Line for sfile --- 44,229 ---- -- Line for -aO switch ! Write_Str (" -aOdir Specify library files search path"); Write_Eol; -- Line for -aI switch ! Write_Str (" -aIdir Specify source files search path"); Write_Eol; -- Line for A switch ! Write_Str (" -A Generate binder program in Ada (default)"); Write_Eol; -- Line for -b switch ! Write_Str (" -b Generate brief messages to std"); Write_Str ("err even if verbose mode set"); Write_Eol; -- Line for -c switch ! Write_Str (" -c Check only, no generation of b"); Write_Str ("inder output file"); Write_Eol; -- Line for C switch ! Write_Str (" -C Generate binder program in C"); Write_Eol; -- Line for -e switch ! Write_Str (" -e Output complete list of elabor"); Write_Str ("ation order dependencies"); Write_Eol; -- Line for -E switch ! Write_Str (" -E Store tracebacks in Exception occurrences"); Write_Eol; -- Line for -h switch ! Write_Str (" -h Output this usage (help) infor"); Write_Str ("mation"); Write_Eol; -- Lines for -I switch ! Write_Str (" -Idir Specify library and source files search path"); Write_Eol; ! Write_Str (" -I- Don't look for sources & library files"); Write_Str (" in default directory"); Write_Eol; -- Line for -K switch ! Write_Str (" -K Give list of linker options specified for link"); Write_Eol; -- Line for -l switch ! Write_Str (" -l Output chosen elaboration order"); Write_Eol; -- Line of -L switch ! Write_Str (" -Lxyz Library build: adainit/final "); Write_Str ("renamed to xyzinit/final, implies -n"); Write_Eol; -- Line for -M switch ! Write_Str (" -Mxyz Rename generated main program from main to xyz"); Write_Eol; -- Line for -m switch ! Write_Str (" -mnnn Limit number of detected error"); Write_Str ("s to nnn (1-999)"); Write_Eol; -- Line for -n switch ! Write_Str (" -n No Ada main program (foreign main routine)"); Write_Eol; -- Line for -nostdinc ! Write_Str (" -nostdinc Don't look for source files"); Write_Str (" in the system default directory"); Write_Eol; -- Line for -nostdlib ! Write_Str (" -nostdlib Don't look for library files"); Write_Str (" in the system default directory"); Write_Eol; -- Line for -o switch ! Write_Str (" -o file Give the output file name (default is b~xxx.adb) "); Write_Eol; -- Line for -O switch ! Write_Str (" -O Give list of objects required for link"); Write_Eol; -- Line for -p switch ! Write_Str (" -p Pessimistic (worst-case) elaborat"); Write_Str ("ion order"); Write_Eol; + -- Line for -r switch + + Write_Str (" -r List restrictions that could be a"); + Write_Str ("pplied to this partition"); + Write_Eol; + -- Line for -s switch ! Write_Str (" -s Require all source files to be"); Write_Str (" present"); Write_Eol; -- Line for -Sxx switch ! Write_Str (" -S?? Sin/lo/hi/xx for Initialize_Scalars"); Write_Str (" invalid/low/high/hex"); Write_Eol; -- Line for -static ! Write_Str (" -static Link against a static GNAT run time"); Write_Eol; -- Line for -shared ! Write_Str (" -shared Link against a shared GNAT run time"); Write_Eol; -- Line for -t switch ! Write_Str (" -t Tolerate time stamp and other consistency errors"); Write_Eol; -- Line for -T switch ! Write_Str (" -Tn Set time slice value to n microseconds (n >= 0)"); Write_Eol; -- Line for -v switch ! Write_Str (" -v Verbose mode. Error messages, "); Write_Str ("header, summary output to stdout"); Write_Eol; -- Lines for -w switch ! Write_Str (" -wx Warning mode. (x=s/e for supp"); Write_Str ("ress/treat as error)"); Write_Eol; -- Line for -x switch ! Write_Str (" -x Exclude source files (check ob"); Write_Str ("ject consistency only)"); Write_Eol; -- Line for -z switch ! Write_Str (" -z No main subprogram (zero main)"); ! Write_Eol; ! ! -- Line for --RTS ! ! Write_Str (" --RTS=dir specify the default source and object search path"); Write_Eol; -- Line for sfile diff -Nrc3pad gcc-3.2.3/gcc/ada/bindusg.ads gcc-3.3/gcc/ada/bindusg.ads *** gcc-3.2.3/gcc/ada/bindusg.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/bindusg.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/butil.adb gcc-3.3/gcc/ada/butil.adb *** gcc-3.2.3/gcc/ada/butil.adb 2002-05-04 03:27:35.000000000 +0000 --- gcc-3.3/gcc/ada/butil.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/butil.ads gcc-3.3/gcc/ada/butil.ads *** gcc-3.2.3/gcc/ada/butil.ads 2002-05-04 03:27:35.000000000 +0000 --- gcc-3.3/gcc/ada/butil.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/cal.c gcc-3.3/gcc/ada/cal.c *** gcc-3.2.3/gcc/ada/cal.c 2002-05-04 03:27:35.000000000 +0000 --- gcc-3.3/gcc/ada/cal.c 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * C Implementation File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001, Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/calendar.ads gcc-3.3/gcc/ada/calendar.ads *** gcc-3.2.3/gcc/ada/calendar.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/calendar.ads 2002-03-14 10:59:05.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/casing.adb gcc-3.3/gcc/ada/casing.adb *** gcc-3.2.3/gcc/ada/casing.adb 2002-05-04 03:27:35.000000000 +0000 --- gcc-3.3/gcc/ada/casing.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/casing.ads gcc-3.3/gcc/ada/casing.ads *** gcc-3.2.3/gcc/ada/casing.ads 2002-05-04 03:27:35.000000000 +0000 --- gcc-3.3/gcc/ada/casing.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/ceinfo.adb gcc-3.3/gcc/ada/ceinfo.adb *** gcc-3.2.3/gcc/ada/ceinfo.adb 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/ceinfo.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.12.2 $ -- -- -- Copyright (C) 1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/ChangeLog gcc-3.3/gcc/ada/ChangeLog *** gcc-3.2.3/gcc/ada/ChangeLog 2003-04-22 06:14:27.000000000 +0000 --- gcc-3.3/gcc/ada/ChangeLog 2003-05-14 00:09:16.000000000 +0000 *************** *** 1,18 **** ! 2003-04-22 Release Manager ! * GCC 3.2.3 Released. 2003-03-31 Geert Bosch * link.c : Fix misspelled "const" keyword ! 2003-02-05 Gabriel Dos Reis ! * gnatvsn.ads: Bump version. ! 2003-02-05 Release Manager ! * GCC 3.2.2 Released. 2003-01-29 Joel Sherrill --- 1,64 ---- ! 2003-05-13 Release Manager ! * GCC 3.3 Released. + 2003-05-13 Release Manager + + * GCC 3.3 Released. + + 2003-05-13 Release Manager + + * GCC 3.3 Released. + + 2003-05-13 Release Manager + + * GCC 3.3 Released. + + 2003-04-30 Laurent Guerby + + PR ada/10546 + * 5iosinte.ads: Increase pthread_cond_t size to match recent + LinuxThread and NPTL version. + 2003-03-31 Geert Bosch + PR ada/10020 * link.c : Fix misspelled "const" keyword ! 2003-03-23 Mark Mitchell ! PR c++/7086 ! * utils2.c: Adjust calls to put_var_into_stack. ! 2003-03-05 Olivier Hainque ! PR ada/9961 ! * raise.c : (__gnat_Unwind_RaiseException): Add prototype to avoid ! warning, and fix return type for the IN_RTS && !SJLJ case. ! ! 2003-03-04 Olivier Hainque ! ! PR ada/9911 ! * a-except.adb (Unwind_RaiseException): Import a GNAT specific ! wrapper, which name remains constant whatever underlying GCC ! scheme. ! ! * raise.c (__gnat_Unwind_RaiseException): New wrappers, providing ! the stable interface needed for a-except. ! ! 2003-02-04 Joseph S. Myers ! ! * gnat_rm.texi, gnat_ug.texi: Update to GFDL 1.2. ! * gnat_ug_unx.texi, gnat_ug_vms.texi, gnat_ug_vxw.texi, ! gnat_ug_wnt.texi: Regenerate. ! ! 2003-01-29 Laurent Guerby ! ! PR ada/8344 ! * final.c: rename to adafinal.c to avoid file name conflicts with ! gcc file. ! * Makefile.in: match previous change. ! * Make-lang.in: match previous change. 2003-01-29 Joel Sherrill *************** *** 25,493 **** is likely needed for all newlib targets. * init.c: Add RTEMS specific version of __gnat_initialize(). ! 2003-01-29 Christian Cornelssen ! * Make-lang.in (gnattools, ada.install-common): ! Complete indentation fixes. ! (ada.install-common): Now really remove the erroneous and ! redundant gnatchop installation commands. ! 2003-01-28 Laurent Guerby ! PR ada/8344 ! * final.c: rename to adafinal.c to avoid file name conflicts with gcc file. ! * Makefile.in: match previous change. ! ! 2003-01-28 Christian Cornelssen ! * Make-lang.in (ada.install-common): Let $(DESTDIR)$(bindir) ! be created if necessary. Remove erroneous and redundant ! gnatchop installation commands. Test for gnatdll before ! attempting to install it. Use initial tab instead of spaces ! in continuation lines. ! (ada.uninstall): Uninstall gnat instead of gnatcmd. ! Also uninstall gnatfind, gnatxref, gnatlbr, and gnatdll ! from all plausible locations. ! * Make-lang.in (ada.install-common, ada.uninstall): ! Prepend $(DESTDIR) to the destination directory in all ! (un)installation commands. ! * Makefile.in (install-gnatlib): Ditto. Rewrite $(LN) ! commands to support DESTDIR with "ln" as well as with ! "ln -s". ! 2002-11-19 Release Manager ! * GCC 3.2.1 Released. ! 2002-11-19 Release Manager ! * GCC 3.2.1 Released. ! 2002-11-18 Release Manager ! * GCC 3.2.1 Released. 2002-08-25 Andre Leis ! David Billinghurst (David.Billinghurst@riotinto.com> ! * sysdep.c (__gnat_ttyname): include on cygwin ! 2002-08-14 Release Manager ! * GCC 3.2 Released. ! 2002-07-25 Release Manager ! * GCC 3.1.1 Released. ! 2002-05-26 Joseph S. Myers ! * gnatvsn.ads (Gnat_Version_String): Change to "3.1.1 20020526 ! (prerelease)". ! 2002-05-14 Release Manager ! * GCC 3.1 Released. ! 2002-05-14 Release Manager ! * GCC 3.1 Released. ! 2002-05-07 Florian Weimer ! * nmake.adt, treeprs.adt: Shorten long Revision: line. ! * xnmake.adb, xtreeprs.adb: Do not write comment trailer for ! Revision: lines. ! 2002-05-05 Florian Weimer ! * 4aintnam.ads, 4cintnam.ads, 4dintnam.ads, 4hintnam.ads, ! 4mintnam.ads, 4nintnam.ads, 4ointnam.ads, 4onumaux.ads, ! 4pintnam.ads, 4rintnam.ads, 4sintnam.ads, 4uintnam.ads, ! 4vcalend.ads, 4vintnam.ads, 4wintnam.ads, 4zintnam.ads, ! 4znumaux.ads, 5avxwork.ads, 5etpopse.adb, 5gintman.adb, ! 5gproinf.ads, 5gtasinf.adb, 5ninmaop.adb, 5nintman.adb, ! 5oparame.adb, 5pvxwork.ads, 5qvxwork.ads, 5rparame.adb, ! 5sintman.adb, 5stasinf.adb, 5stpopse.adb, 5svxwork.ads, ! 5uintman.adb, 5vinmaop.adb, 5vintman.adb, 5vtpopde.adb, ! 5vtpopde.ads, 5wosprim.adb, 6vinterf.ads, 7sinmaop.adb, ! 7sosprim.adb, 7stpopsp.adb, 86numaux.ads, 9drpc.adb, a-astaco.adb, ! a-astaco.ads, a-caldel.ads, a-calend.ads, a-chahan.ads, ! a-charac.ads, a-chlat1.ads, a-colien.adb, a-colien.ads, ! a-decima.adb, a-decima.ads, a-diocst.adb, a-diocst.ads, ! a-direio.adb, a-dynpri.ads, a-excpol.adb, a-filico.ads, ! a-finali.ads, a-flteio.ads, a-fwteio.ads, a-inteio.ads, ! a-interr.adb, a-intnam.ads, a-intsig.adb, a-intsig.ads, ! a-ioexce.ads, a-iwteio.ads, a-lfteio.ads, a-lfwtio.ads, ! a-liteio.ads, a-liwtio.ads, a-llftio.ads, a-llfwti.ads, ! a-llitio.ads, a-lliwti.ads, a-ncelfu.ads, a-ngcoty.ads, ! a-ngelfu.ads, a-nlcefu.ads, a-nlcoty.ads, a-nlelfu.ads, ! a-nllcef.ads, a-nllcty.ads, a-nllefu.ads, a-nscefu.ads, ! a-nscoty.ads, a-nselfu.ads, a-nucoty.ads, a-nuflra.adb, ! a-nuflra.ads, a-numaux.ads, a-numeri.ads, a-sequio.ads, ! a-sfteio.ads, a-sfwtio.ads, a-siocst.adb, a-siocst.ads, ! a-siteio.ads, a-siwtio.ads, a-ssicst.adb, a-ssicst.ads, ! a-ssitio.ads, a-ssiwti.ads, a-storio.adb, a-storio.ads, ! a-stream.ads, a-strfix.ads, a-string.ads, a-strsea.adb, ! a-strsea.ads, a-strunb.ads, a-ststio.ads, a-stunau.adb, ! a-stunau.ads, a-stwibo.ads, a-stwifi.adb, a-stwifi.ads, ! a-stwima.ads, a-stwise.adb, a-stwise.ads, a-sytaco.ads, ! a-tags.ads, a-tasatt.ads, a-teioed.ads, a-ticoau.adb, ! a-ticoau.ads, a-ticoio.adb, a-ticoio.ads, a-tideau.ads, ! a-tideio.ads, a-tienau.ads, a-tifiio.ads, a-tiflau.adb, ! a-tiflau.ads, a-tiflio.ads, a-tiinau.ads, a-tiinio.ads, ! a-timoio.adb, a-tiocst.adb, a-tiocst.ads, a-titest.adb, ! a-titest.ads, a-unccon.ads, a-uncdea.ads, a-wtcoau.adb, ! a-wtcoau.ads, a-wtcoio.adb, a-wtcoio.ads, a-wtcstr.adb, ! a-wtcstr.ads, a-wtdeio.ads, a-wtedit.ads, a-wtenau.ads, ! a-wtfiio.ads, a-wtflau.adb, a-wtflau.ads, a-wtflio.ads, ! a-wtinau.adb, a-wtinau.ads, a-wtinio.ads, a-wtmoau.adb, ! a-wtmoau.ads, a-wtmoio.adb, a-wtmoio.ads, a-wttest.adb, ! a-wttest.ads, ada.ads, binde.ads, bindgen.ads, bindusg.ads, ! calendar.ads, ceinfo.adb, debug_a.adb, debug_a.ads, directio.ads, ! elists.ads, exp_attr.ads, exp_ch10.ads, exp_ch12.ads, ! exp_ch13.ads, exp_ch2.ads, exp_ch6.ads, exp_code.ads, ! exp_disp.ads, exp_dist.ads, exp_fixd.ads, exp_imgv.ads, ! exp_intr.ads, exp_prag.ads, exp_smem.ads, exp_vfpt.adb, ! exp_vfpt.ads, frontend.ads, g-busora.adb, g-busorg.adb, ! g-casuti.adb, g-casuti.ads, g-curexc.ads, g-debuti.adb, ! g-debuti.ads, g-hesora.adb, g-hesorg.adb, g-io_aux.ads, ! g-moreex.adb, g-speche.ads, g-spitbo.adb, g-spitbo.ads, ! g-sptabo.ads, g-sptain.ads, g-sptavs.ads, get_targ.adb, ! gnat1drv.ads, gnatbind.ads, gnatcmd.ads, gnatlink.ads, gnatls.ads, ! gnatmake.adb, gnatmake.ads, gnatprep.ads, gnatpsys.adb, hlo.adb, ! hlo.ads, i-c.ads, i-cexten.ads, i-fortra.adb, i-os2err.ads, ! i-os2lib.ads, i-os2syn.ads, i-os2thr.ads, i-pacdec.ads, ! interfac.ads, ioexcept.ads, itypes.ads, krunch.ads, lib-sort.adb, ! live.ads, machcode.ads, makeusg.ads, math_lib.adb, mdllfile.adb, ! nlists.adb, nlists.ads, par-ch2.adb, par-labl.adb, par.ads, ! prj-com.ads, s-addima.adb, s-addima.ads, s-arit64.ads, ! s-assert.adb, s-assert.ads, s-asthan.adb, s-asthan.ads, ! s-atacco.adb, s-chepoo.ads, s-direio.ads, s-errrep.adb, ! s-errrep.ads, s-exnflt.ads, s-exngen.ads, s-exnint.ads, ! s-exnlfl.ads, s-exnlin.ads, s-exnllf.ads, s-exnlli.ads, ! s-exnsfl.ads, s-exnsin.ads, s-exnssi.ads, s-expflt.ads, ! s-expgen.ads, s-expint.ads, s-explfl.ads, s-explin.ads, ! s-expllf.ads, s-explli.ads, s-expllu.adb, s-expllu.ads, ! s-expmod.adb, s-expmod.ads, s-expsfl.ads, s-expsin.ads, ! s-expssi.ads, s-expuns.adb, s-expuns.ads, s-fatflt.ads, ! s-fatlfl.ads, s-fatllf.ads, s-fatsfl.ads, s-finimp.ads, ! s-fore.adb, s-fore.ads, s-gloloc.adb, s-imgbiu.adb, s-imgboo.adb, ! s-imgcha.adb, s-imgint.adb, s-imgllb.adb, s-imglld.adb, ! s-imglli.adb, s-imgllu.adb, s-imgllw.adb, s-imguns.adb, ! s-imgwch.adb, s-imgwiu.adb, s-inmaop.ads, s-io.ads, s-mantis.adb, ! s-mantis.ads, s-pack03.ads, s-pack05.ads, s-pack07.ads, ! s-pack09.ads, s-pack11.ads, s-pack13.ads, s-pack15.ads, ! s-pack17.ads, s-pack19.ads, s-pack21.ads, s-pack23.ads, ! s-pack25.ads, s-pack27.ads, s-pack29.ads, s-pack31.ads, ! s-pack33.ads, s-pack35.ads, s-pack37.ads, s-pack39.ads, ! s-pack41.ads, s-pack43.ads, s-pack45.ads, s-pack47.ads, ! s-pack49.ads, s-pack51.ads, s-pack53.ads, s-pack55.ads, ! s-pack57.ads, s-pack59.ads, s-pack61.ads, s-pack63.ads, ! s-pooglo.ads, s-pooloc.ads, s-poosiz.ads, s-proinf.adb, ! s-proinf.ads, s-rpc.ads, s-sequio.adb, s-sequio.ads, s-shasto.ads, ! s-sopco3.adb, s-sopco4.adb, s-sopco5.adb, s-stoele.adb, ! s-stoele.ads, s-stopoo.ads, s-stratt.adb, s-stratt.ads, ! s-strops.adb, s-taenca.ads, s-tasinf.adb, s-tasren.ads, ! s-tasuti.ads, s-vaflop.ads, s-valboo.adb, s-valboo.ads, ! s-valcha.adb, s-valdec.adb, s-valdec.ads, s-valint.adb, ! s-valint.ads, s-vallld.adb, s-vallld.ads, s-vallli.adb, ! s-vallli.ads, s-valllu.adb, s-valllu.ads, s-valrea.ads, ! s-valuns.adb, s-valuns.ads, s-valuti.ads, s-valwch.adb, ! s-vercon.adb, s-vercon.ads, s-vmexta.ads, s-wchcon.ads, ! s-wchjis.adb, s-wchjis.ads, s-wchstw.ads, s-wchwts.adb, ! s-wchwts.ads, s-widboo.adb, s-widboo.ads, s-widcha.adb, ! s-widcha.ads, s-widlli.adb, s-widlli.ads, s-widllu.adb, ! s-widllu.ads, s-widwch.adb, s-widwch.ads, s-wwdcha.adb, ! s-wwdcha.ads, s-wwdwch.ads, scn-nlit.adb, sdefault.ads, ! sem_aggr.ads, sem_ch10.ads, sem_ch11.ads, sem_ch2.adb, ! sem_ch2.ads, sem_ch4.ads, sem_ch5.ads, sem_ch6.ads, sem_ch7.ads, ! sem_ch8.ads, sem_disp.ads, sem_elim.ads, sem_intr.ads, ! sem_maps.adb, sem_mech.ads, sem_prag.ads, sem_smem.ads, ! sem_vfpt.ads, sequenio.ads, sinput-l.ads, snames.adb, stand.adb, ! switch.ads, text_io.ads, tree_gen.ads, tree_in.ads, tree_io.ads, ! treepr.ads, uname.ads, unchconv.ads, unchdeal.ads, urealp.ads, ! usage.ads, widechar.ads: Adjust Revision: lines which were too ! long. ! 2002-05-03 Joe Buck ! * 1aexcept.adb, 1aexcept.ads, 41intnam.ads, 42intnam.ads, ! 4aintnam.ads, 4cintnam.ads, 4dintnam.ads, 4hexcpol.adb, ! 4lintnam.ads, 4mintnam.ads, 4nintnam.ads, 4onumaux.ads, ! 4pintnam.ads, 4rintnam.ads, 4sintnam.ads, 4uintnam.ads, ! 4vcalend.adb, 4vintnam.ads, 4wcalend.adb, 4wexcpol.adb, ! 4wintnam.ads, 4zintnam.ads, 4znumaux.ads, 4zsytaco.adb, ! 4zsytaco.ads, 51osinte.adb, 51osinte.ads, 52osinte.adb, ! 52osinte.ads, 52system.ads, 53osinte.ads, 5aosinte.ads, ! 5asystem.ads, 5atasinf.ads, 5ataspri.ads, 5avxwork.ads, ! 5bosinte.ads, 5bsystem.ads, 5cosinte.ads, 5dosinte.ads, ! 5esystem.ads, 5fosinte.ads, 5fsystem.ads, 5ftasinf.ads, ! 5ginterr.adb, 5gmastop.adb, 5gosinte.ads, 5gproinf.adb, ! 5gproinf.ads, 5gsystem.ads, 5gtasinf.adb, 5gtasinf.ads, ! 5gtpgetc.adb, 5hparame.ads, 5hsystem.ads, 5htaspri.ads, ! 5iosinte.ads, 5itaspri.ads, 5ksystem.ads, 5kvxwork.ads, ! 5losinte.ads, 5lsystem.ads, 5mosinte.ads, 5mvxwork.ads, ! 5ninmaop.adb, 5nintman.adb, 5nosinte.ads, 5ntaspri.ads, ! 5oosprim.adb, 5oparame.adb, 5osystem.ads, 5posinte.ads, ! 5posprim.adb, 5pvxwork.ads, 5qparame.ads, 5qvxwork.ads, ! 5rosinte.ads, 5rparame.adb, 5sintman.adb, 5sosinte.ads, ! 5sparame.adb, 5ssystem.ads, 5stasinf.adb, 5stasinf.ads, ! 5staspri.ads, 5svxwork.ads, 5tosinte.ads, 5uosinte.ads, ! 5vasthan.adb, 5vinterr.adb, 5vintman.ads, 5vosinte.ads, ! 5vosprim.adb, 5vosprim.ads, 5vparame.ads, 5vsystem.ads, ! 5vtaspri.ads, 5vtpopde.adb, 5vtpopde.ads, 5vvaflop.adb, ! 5wintman.adb, 5wmemory.adb, 5wosinte.ads, 5wosprim.adb, ! 5wsystem.ads, 5wtaprop.adb, 5wtaspri.ads, 5ysystem.ads, ! 5zinterr.adb, 5zosinte.adb, 5zosinte.ads, 5zosprim.adb, ! 5zparame.ads, 5zsystem.ads, 6vcpp.adb, 6vcstrea.adb, ! 7sosprim.adb, 86numaux.adb, 86numaux.ads, 9drpc.adb, ! a-astaco.adb, a-caldel.ads, a-calend.adb, a-calend.ads, ! a-chahan.adb, a-chahan.ads, a-colien.adb, a-colien.ads, ! a-colire.adb, a-colire.ads, a-comlin.adb, a-comlin.ads, ! a-cwila1.ads, a-decima.adb, a-decima.ads, a-diocst.adb, ! a-diocst.ads, a-direio.adb, a-direio.ads, a-einuoc.adb, ! a-einuoc.ads, a-except.adb, a-except.ads, a-excpol.adb, ! a-exctra.adb, a-exctra.ads, a-filico.adb, a-filico.ads, ! a-finali.adb, a-finali.ads, a-interr.ads, a-intsig.adb, ! a-intsig.ads, a-ngcefu.adb, a-ngcoty.adb, a-ngcoty.ads, ! a-ngelfu.adb, a-nudira.adb, a-nudira.ads, a-nuflra.adb, ! a-nuflra.ads, a-numaux.ads, a-reatim.ads, a-retide.ads, ! a-sequio.adb, a-sequio.ads, a-siocst.adb, a-siocst.ads, ! a-ssicst.adb, a-ssicst.ads, a-stmaco.ads, a-storio.adb, ! a-strbou.adb, a-strbou.ads, a-stream.ads, a-strfix.adb, ! a-strfix.ads, a-strmap.adb, a-strmap.ads, a-strsea.adb, ! a-strsea.ads, a-strunb.adb, a-strunb.ads, a-ststio.adb, ! a-ststio.ads, a-stunau.adb, a-stunau.ads, a-stwibo.adb, ! a-stwibo.ads, a-stwifi.adb, a-stwima.adb, a-stwima.ads, ! a-stwise.adb, a-stwise.ads, a-stwiun.adb, a-stwiun.ads, ! a-suteio.adb, a-suteio.ads, a-swmwco.ads, a-swuwti.adb, ! a-swuwti.ads, a-sytaco.adb, a-sytaco.ads, a-tags.adb, ! a-tags.ads, a-tasatt.ads, a-taside.adb, a-taside.ads, ! a-teioed.adb, a-teioed.ads, a-textio.adb, a-textio.ads, ! a-ticoau.adb, a-ticoau.ads, a-ticoio.adb, a-ticoio.ads, ! a-tideau.adb, a-tideau.ads, a-tideio.adb, a-tideio.ads, ! a-tienau.adb, a-tienau.ads, a-tienio.adb, a-tienio.ads, ! a-tifiio.adb, a-tifiio.ads, a-tiflau.adb, a-tiflau.ads, ! a-tiflio.adb, a-tiflio.ads, a-tigeau.adb, a-tigeau.ads, ! a-tiinau.adb, a-tiinau.ads, a-tiinio.adb, a-tiinio.ads, ! a-timoau.adb, a-timoau.ads, a-timoio.adb, a-timoio.ads, ! a-tiocst.adb, a-tiocst.ads, a-titest.adb, a-witeio.adb, ! a-witeio.ads, a-wtcoau.adb, a-wtcoau.ads, a-wtcoio.adb, ! a-wtcstr.adb, a-wtcstr.ads, a-wtdeau.adb, a-wtdeau.ads, ! a-wtdeio.adb, a-wtdeio.ads, a-wtedit.adb, a-wtedit.ads, ! a-wtenau.adb, a-wtenau.ads, a-wtenio.adb, a-wtenio.ads, ! a-wtfiio.adb, a-wtfiio.ads, a-wtflau.adb, a-wtflau.ads, ! a-wtflio.adb, a-wtflio.ads, a-wtgeau.adb, a-wtgeau.ads, ! a-wtinau.adb, a-wtinau.ads, a-wtinio.adb, a-wtmoau.adb, ! a-wtmoau.ads, a-wtmoio.adb, a-wtmoio.ads, a-wttest.adb, ! ada-tree.def, ada-tree.h, ada.h, adaint.c, adaint.h, ! ali-util.adb, ali-util.ads, ali.adb, ali.ads, alloc.ads, ! argv.c, atree.adb, atree.ads, atree.h, back_end.adb, ! back_end.ads, bcheck.adb, bcheck.ads, binde.adb, binde.ads, ! binderr.adb, binderr.ads, bindgen.adb, bindgen.ads, ! bindusg.adb, bindusg.ads, butil.adb, butil.ads, cal.c, ! casing.adb, casing.ads, ceinfo.adb, checks.adb, checks.ads, ! cio.c, comperr.adb, comperr.ads, csets.adb, csets.ads, ! csinfo.adb, cstand.adb, cstand.ads, cstreams.c, cuintp.c, ! debug.adb, debug.ads, debug_a.adb, debug_a.ads, dec-io.adb, ! dec-io.ads, dec.ads, decl.c, deftarg.c, einfo.adb, einfo.ads, ! einfo.h, elists.adb, elists.ads, elists.h, errno.c, errout.adb, ! errout.ads, eval_fat.adb, eval_fat.ads, exit.c, exp_aggr.adb, ! exp_aggr.ads, exp_attr.adb, exp_attr.ads, exp_ch10.ads, ! exp_ch11.adb, exp_ch11.ads, exp_ch12.adb, exp_ch12.ads, ! exp_ch13.adb, exp_ch13.ads, exp_ch2.adb, exp_ch2.ads, ! exp_ch3.adb, exp_ch3.ads, exp_ch4.adb, exp_ch4.ads, ! exp_ch5.adb, exp_ch5.ads, exp_ch6.adb, exp_ch6.ads, ! exp_ch7.adb, exp_ch7.ads, exp_ch8.adb, exp_ch8.ads, ! exp_ch9.adb, exp_ch9.ads, exp_code.adb, exp_code.ads, ! exp_dbug.adb, exp_dbug.ads, exp_disp.adb, exp_disp.ads, ! exp_dist.adb, exp_dist.ads, exp_fixd.adb, exp_fixd.ads, ! exp_imgv.adb, exp_imgv.ads, exp_intr.adb, exp_intr.ads, ! exp_pakd.adb, exp_pakd.ads, exp_prag.adb, exp_prag.ads, ! exp_smem.adb, exp_smem.ads, exp_strm.adb, exp_strm.ads, ! exp_tss.adb, exp_tss.ads, exp_util.adb, exp_util.ads, ! exp_vfpt.adb, exp_vfpt.ads, expander.adb, expander.ads, fe.h, ! final.c, fmap.adb, fmap.ads, fname-sf.adb, fname-sf.ads, ! fname-uf.adb, fname-uf.ads, fname.adb, fname.ads, freeze.adb, ! freeze.ads, frontend.adb, frontend.ads, g-calend.ads, ! g-comlin.adb, g-debpoo.adb, g-debpoo.ads, g-locfil.adb, ! g-os_lib.ads, g-regist.adb, g-regist.ads, get_targ.adb, ! get_targ.ads, gigi.h, gmem.c, gnat1drv.adb, gnat1drv.ads, ! gnat_ug.texi, gnatbind.adb, gnatbind.ads, gnatbl.c, ! gnatcmd.adb, gnatcmd.ads, gnatdll.adb, gnatfind.adb, ! gnatkr.adb, gnatkr.ads, gnatlbr.adb, gnatlink.adb, ! gnatlink.ads, gnatls.adb, gnatls.ads, gnatmain.adb, ! gnatmain.ads, gnatmake.adb, gnatmake.ads, gnatmem.adb, ! gnatprep.adb, gnatprep.ads, gnatpsta.adb, gnatpsys.adb, ! gnatvsn.ads, gnatxref.adb, hlo.adb, hlo.ads, hostparm.ads, ! i-c.adb, i-cexten.ads, i-cobol.adb, i-cobol.ads, i-cpoint.adb, ! i-cpoint.ads, i-cpp.adb, i-cpp.ads, i-cstrea.adb, i-cstrea.ads, ! i-cstrin.adb, i-cstrin.ads, i-fortra.adb, i-os2err.ads, ! i-os2lib.adb, i-os2lib.ads, i-os2syn.ads, i-os2thr.ads, ! i-pacdec.adb, i-pacdec.ads, impunit.adb, impunit.ads, init.c, ! inline.adb, inline.ads, io-aux.c, itypes.adb, itypes.ads, ! krunch.adb, krunch.ads, lang-options.h, lang-specs.h, ! layout.adb, layout.ads, lib-list.adb, lib-load.adb, ! lib-load.ads, lib-sort.adb, lib-util.adb, lib-util.ads, ! lib-writ.adb, lib-writ.ads, lib-xref.adb, lib-xref.ads, ! lib.adb, lib.ads, link.c, live.adb, live.ads, make.adb, ! make.ads, makeusg.adb, makeusg.ads, math_lib.adb, mdll.adb, ! mdll.ads, mdllfile.adb, mdllfile.ads, mdlltool.adb, ! mdlltool.ads, memtrack.adb, misc.c, namet.adb, namet.ads, ! namet.h, nlists.adb, nlists.ads, nlists.h, nmake.adb, ! nmake.ads, nmake.adt, opt.adb, opt.ads, osint.adb, osint.ads, ! output.adb, output.ads, par-ch10.adb, par-ch11.adb, ! par-ch12.adb, par-ch13.adb, par-ch2.adb, par-ch3.adb, ! par-ch4.adb, par-ch5.adb, par-ch6.adb, par-ch7.adb, ! par-ch8.adb, par-ch9.adb, par-endh.adb, par-labl.adb, ! par-load.adb, par-prag.adb, par-sync.adb, par-tchk.adb, ! par-util.adb, par.adb, par.ads, prj-attr.adb, prj-attr.ads, ! prj-com.adb, prj-com.ads, prj-dect.adb, prj-dect.ads, ! prj-env.adb, prj-env.ads, prj-ext.adb, prj-ext.ads, ! prj-nmsc.adb, prj-nmsc.ads, prj-pars.adb, prj-pars.ads, ! prj-part.adb, prj-part.ads, prj-proc.adb, prj-proc.ads, ! prj-strt.adb, prj-strt.ads, prj-tree.adb, prj-tree.ads, ! prj-util.adb, prj-util.ads, prj.adb, prj.ads, raise.c, raise.h, ! repinfo.adb, repinfo.ads, repinfo.h, restrict.adb, ! restrict.ads, rident.ads, rtsfind.adb, rtsfind.ads, ! s-addima.adb, s-addima.ads, s-arit64.adb, s-arit64.ads, ! s-assert.adb, s-assert.ads, s-asthan.adb, s-asthan.ads, ! s-atacco.adb, s-auxdec.adb, s-auxdec.ads, s-bitops.adb, ! s-bitops.ads, s-chepoo.ads, s-direio.adb, s-direio.ads, ! s-except.ads, s-exctab.adb, s-exctab.ads, s-exnflt.ads, ! s-exngen.adb, s-exngen.ads, s-exnint.ads, s-exnlfl.ads, ! s-exnlin.ads, s-exnllf.ads, s-exnlli.ads, s-exnsfl.ads, ! s-exnsin.ads, s-exnssi.ads, s-expflt.ads, s-expgen.adb, ! s-expgen.ads, s-expint.ads, s-explfl.ads, s-explin.ads, ! s-expllf.ads, s-explli.ads, s-expllu.adb, s-expllu.ads, ! s-expmod.adb, s-expmod.ads, s-expsfl.ads, s-expsin.ads, ! s-expssi.ads, s-expuns.adb, s-expuns.ads, s-fatflt.ads, ! s-fatgen.adb, s-fatgen.ads, s-fatlfl.ads, s-fatllf.ads, ! s-fatsfl.ads, s-ficobl.ads, s-fileio.adb, s-fileio.ads, ! s-finimp.adb, s-finimp.ads, s-finroo.adb, s-finroo.ads, ! s-fore.adb, s-fore.ads, s-imgbiu.adb, s-imgbiu.ads, ! s-imgboo.adb, s-imgboo.ads, s-imgcha.adb, s-imgcha.ads, ! s-imgdec.adb, s-imgdec.ads, s-imgenu.adb, s-imgenu.ads, ! s-imgint.adb, s-imgint.ads, s-imgllb.adb, s-imgllb.ads, ! s-imglld.adb, s-imglld.ads, s-imglli.adb, s-imglli.ads, ! s-imgllu.adb, s-imgllu.ads, s-imgllw.adb, s-imgllw.ads, ! s-imgrea.adb, s-imgrea.ads, s-imguns.adb, s-imguns.ads, ! s-imgwch.adb, s-imgwch.ads, s-imgwiu.adb, s-imgwiu.ads, ! s-inmaop.ads, s-interr.adb, s-interr.ads, s-intman.ads, ! s-io.adb, s-io.ads, s-maccod.ads, s-mantis.adb, s-mantis.ads, ! s-memory.adb, s-memory.ads, s-osprim.ads, s-pack03.adb, ! s-pack03.ads, s-pack05.adb, s-pack05.ads, s-pack06.adb, ! s-pack06.ads, s-pack07.adb, s-pack07.ads, s-pack09.adb, ! s-pack09.ads, s-pack10.adb, s-pack10.ads, s-pack11.adb, ! s-pack11.ads, s-pack12.adb, s-pack12.ads, s-pack13.adb, ! s-pack13.ads, s-pack14.adb, s-pack14.ads, s-pack15.adb, ! s-pack15.ads, s-pack17.adb, s-pack17.ads, s-pack18.adb, ! s-pack18.ads, s-pack19.adb, s-pack19.ads, s-pack20.adb, ! s-pack20.ads, s-pack21.adb, s-pack21.ads, s-pack22.adb, ! s-pack22.ads, s-pack23.adb, s-pack23.ads, s-pack24.adb, ! s-pack24.ads, s-pack25.adb, s-pack25.ads, s-pack26.adb, ! s-pack26.ads, s-pack27.adb, s-pack27.ads, s-pack28.adb, ! s-pack28.ads, s-pack29.adb, s-pack29.ads, s-pack30.adb, ! s-pack30.ads, s-pack31.adb, s-pack31.ads, s-pack33.adb, ! s-pack33.ads, s-pack34.adb, s-pack34.ads, s-pack35.adb, ! s-pack35.ads, s-pack36.adb, s-pack36.ads, s-pack37.adb, ! s-pack37.ads, s-pack38.adb, s-pack38.ads, s-pack39.adb, ! s-pack39.ads, s-pack40.adb, s-pack40.ads, s-pack41.adb, ! s-pack41.ads, s-pack42.adb, s-pack42.ads, s-pack43.adb, ! s-pack43.ads, s-pack44.adb, s-pack44.ads, s-pack45.adb, ! s-pack45.ads, s-pack46.adb, s-pack46.ads, s-pack47.adb, ! s-pack47.ads, s-pack48.adb, s-pack48.ads, s-pack49.adb, ! s-pack49.ads, s-pack50.adb, s-pack50.ads, s-pack51.adb, ! s-pack51.ads, s-pack52.adb, s-pack52.ads, s-pack53.adb, ! s-pack53.ads, s-pack54.adb, s-pack54.ads, s-pack55.adb, ! s-pack55.ads, s-pack56.adb, s-pack56.ads, s-pack57.adb, ! s-pack57.ads, s-pack58.adb, s-pack58.ads, s-pack59.adb, ! s-pack59.ads, s-pack60.adb, s-pack60.ads, s-pack61.adb, ! s-pack61.ads, s-pack62.adb, s-pack62.ads, s-pack63.adb, ! s-pack63.ads, s-parame.adb, s-parame.ads, s-parint.adb, ! s-parint.ads, s-pooglo.adb, s-pooglo.ads, s-pooloc.adb, ! s-pooloc.ads, s-poosiz.adb, s-poosiz.ads, s-powtab.ads, ! s-proinf.adb, s-proinf.ads, s-rpc.adb, s-rpc.ads, s-scaval.ads, ! s-secsta.adb, s-secsta.ads, s-sequio.adb, s-sequio.ads, ! s-shasto.adb, s-shasto.ads, s-soflin.adb, s-soflin.ads, ! s-sopco3.adb, s-sopco3.ads, s-sopco4.adb, s-sopco4.ads, ! s-sopco5.adb, s-sopco5.ads, s-stache.adb, s-stache.ads, ! s-stalib.adb, s-stalib.ads, s-stoele.adb, s-stopoo.ads, ! s-stratt.adb, s-stratt.ads, s-strops.adb, s-strops.ads, ! s-taprob.ads, s-taprop.ads, s-tarest.ads, s-tasdeb.adb, ! s-tasdeb.ads, s-tasinf.adb, s-tasinf.ads, s-tasini.ads, ! s-taskin.ads, s-tasren.ads, s-tasres.ads, s-tassta.ads, ! s-tpinop.adb, s-tpinop.ads, s-tpoben.ads, s-tpobop.ads, ! s-unstyp.ads, s-vaflop.adb, s-vaflop.ads, s-valboo.adb, ! s-valboo.ads, s-valcha.adb, s-valcha.ads, s-valdec.adb, ! s-valdec.ads, s-valenu.adb, s-valenu.ads, s-valint.adb, ! s-valint.ads, s-vallld.adb, s-vallld.ads, s-vallli.adb, ! s-vallli.ads, s-valllu.adb, s-valllu.ads, s-valrea.adb, ! s-valrea.ads, s-valuns.adb, s-valuns.ads, s-valuti.adb, ! s-valuti.ads, s-valwch.adb, s-valwch.ads, s-vercon.adb, ! s-vercon.ads, s-vmexta.adb, s-vmexta.ads, s-wchcnv.adb, ! s-wchcnv.ads, s-wchcon.ads, s-wchjis.adb, s-wchjis.ads, ! s-wchstw.adb, s-wchstw.ads, s-wchwts.adb, s-wchwts.ads, ! s-widboo.adb, s-widboo.ads, s-widcha.adb, s-widcha.ads, ! s-widenu.adb, s-widenu.ads, s-widlli.adb, s-widlli.ads, ! s-widllu.adb, s-widllu.ads, s-widwch.adb, s-widwch.ads, ! s-wwdcha.adb, s-wwdcha.ads, s-wwdenu.adb, s-wwdenu.ads, ! s-wwdwch.adb, s-wwdwch.ads, scans.adb, scans.ads, scn-nlit.adb, ! scn-slit.adb, scn.adb, scn.ads, sdefault.ads, sem.adb, sem.ads, ! sem_aggr.adb, sem_aggr.ads, sem_attr.adb, sem_attr.ads, ! sem_case.adb, sem_case.ads, sem_cat.adb, sem_cat.ads, ! sem_ch10.adb, sem_ch10.ads, sem_ch11.adb, sem_ch11.ads, ! sem_ch12.adb, sem_ch12.ads, sem_ch13.adb, sem_ch13.ads, ! sem_ch2.adb, sem_ch2.ads, sem_ch3.adb, sem_ch3.ads, ! sem_ch4.adb, sem_ch4.ads, sem_ch5.adb, sem_ch5.ads, ! sem_ch6.adb, sem_ch6.ads, sem_ch7.adb, sem_ch7.ads, ! sem_ch8.adb, sem_ch8.ads, sem_ch9.adb, sem_ch9.ads, ! sem_disp.adb, sem_disp.ads, sem_dist.adb, sem_dist.ads, ! sem_elab.adb, sem_elab.ads, sem_elim.adb, sem_elim.ads, ! sem_eval.adb, sem_eval.ads, sem_intr.adb, sem_intr.ads, ! sem_maps.adb, sem_maps.ads, sem_mech.adb, sem_mech.ads, ! sem_prag.adb, sem_prag.ads, sem_res.adb, sem_res.ads, ! sem_smem.adb, sem_smem.ads, sem_type.adb, sem_type.ads, ! sem_util.adb, sem_util.ads, sem_vfpt.adb, sem_vfpt.ads, ! sem_warn.adb, sem_warn.ads, sfn_scan.adb, sfn_scan.ads, ! sinfo-cn.adb, sinfo-cn.ads, sinfo.adb, sinfo.ads, sinfo.h, ! sinput-l.adb, sinput-l.ads, sinput-p.adb, sinput-p.ads, ! sinput.adb, sinput.ads, snames.adb, snames.ads, snames.h, ! sprint.adb, sprint.ads, stand.adb, stand.ads, stringt.adb, ! stringt.ads, stringt.h, style.adb, style.ads, stylesw.adb, ! stylesw.ads, switch.adb, switch.ads, sysdep.c, system.ads, ! table.adb, table.ads, targparm.adb, targparm.ads, targtyps.c, ! tbuild.adb, tbuild.ads, trans.c, tree_gen.adb, tree_gen.ads, ! tree_in.adb, tree_in.ads, tree_io.adb, tree_io.ads, treepr.adb, ! treepr.ads, treeprs.ads, treeprs.adt, ttypef.ads, ttypes.ads, ! types.adb, types.ads, types.h, uintp.adb, uintp.ads, uintp.h, ! uname.adb, uname.ads, urealp.adb, urealp.ads, urealp.h, ! usage.adb, usage.ads, utils.c, utils2.c, validsw.adb, ! validsw.ads, widechar.adb, widechar.ads, xeinfo.adb, ! xnmake.adb, xr_tabls.adb, xr_tabls.ads, xref_lib.adb, ! xref_lib.ads, xsinfo.adb, xsnames.adb, xtreeprs.adb : Change ! Ada Core Technologies from maintainer to contributor. ! 2002-05-02 John David Anglin ! * Makefile.in (ALL_ADAFLAGS, MOST_ADAFLAGS): Add CFLAGS to defines. ! 2002-05-01 Geert Bosch ! * comperr.adb : Fix typo. ! 2002-05-01 Geert Bosch ! * bindgen.adb (Public_Version_Warning): Remove. ! * gnatvsn.ads : Change to match GCC 3.1 version. ! * comperr.adb : Change bug box, remove ACT-specific circuitry. ! * comperr.ads : Update comments to reflect changed bug message. 2002-04-21 Joseph S. Myers --- 71,695 ---- is likely needed for all newlib targets. * init.c: Add RTEMS specific version of __gnat_initialize(). ! 2003-01-28 Christian Cornelssen ! * Make-lang.in (ada.install-info): Let $(DESTDIR)$(infodir) ! be created if necessary. ! (ada.install-common): Let $(DESTDIR)$(bindir) be created ! if necessary. Remove erroneous and redundant gnatchop ! installation commands. Test for gnatdll before attempting ! to install it. ! (ada.uninstall): Also uninstall gnatfind, gnatxref, gnatlbr, ! and gnatdll from all plausible locations. ! (cross-gnattools, ada.install-common): Use initial tab ! instead of spaces in continuation lines. ! 2003-01-26 Christian Cornelssen ! * Make-lang.in (ada.install-info, ada.install-common) ! (ada.uninstall): Prepend $(DESTDIR) to the destination ! directory in all (un)installation commands. ! * Makefile.in (install-gnatlib, install-rts): Ditto. ! 2002-12-28 Joseph S. Myers ! * gnat_rm.texi, gnat_ug.texi: Use @copying. ! * gnat_ug_unx.texi, gnat_ug_vms.texi, gnat_ug_vxw.texi, ! gnat_ug_wnt.texi: Regenerate. ! 2002-12-23 Joseph S. Myers ! * gnat_rm.texi: Include gcc-common.texi. Use GCC version number ! only. ! * Make-lang.in ($(srcdir)/ada/gnat_ug_unx.info, ! $(srcdir)/ada/gnat_ug_vms.info, $(srcdir)/ada/gnat_ug_vxw.info, ! $(srcdir)/ada/gnat_ug_wnt.info, $(srcdir)/ada/gnat_rm.info, ! ada/gnat_ug_unx.dvi, ada/gnat_ug_vms.dvi, ada/gnat_ug_vxw.dvi, ! ada/gnat_ug_wnt.dvi, ada/gnat_rm.dvi): Depend on ! $(srcdir)/doc/include/gcc-common.texi. ! 2002-11-18 Nathanael Nerode ! * adaint.c (__gnat_tmp_name): Better, but good enough for now, ! solution to buffer overflow bug on GNU/Linux. ! 2002-11-14 Nathanael Nerode ! Closes PR ada/5856 and PR ada/6919 ! ! * bindgen.adb: Remove all references to Public_Version. ! * comperr.adb: Remove all references to Public_Version and ! GNATPRO_Version; correct bug reporting instructions. ! * comperr.ads: Change to match bug box. ! * gnatvsn.ads: Remove all references to Public version and ! GNATPRO version. ! 2002-11-13 Nathanael Nerode ! PR ada/6919 ! * adaint.c (__gnat_tmp_name): Remove buffer overflow bug on ! GNU/Linux. ! PR ada/6558 ! * config-lang.in: Remove diff_excludes. ! ! 2002-11-05 Graham Stott ! PR ada/8358 ! * trans.c (gnu_pending_elaboration_lists): New GC root. ! (build_unit_elab): Use.. ! ! 2002-10-30 Geert Bosch ! PR ada/6558 ! * misc.c : Include optabs.h ! ! * Make-lang.in (misc.o): Add dependency on optabs.h ! ! 2002-10-29 Geert Bosch ! PR ada/6558 ! * Make-lang.in (gnatbind): Depend on CONFIG_H ! ! 2002-10-29 Geert bosch ! PR ada/6558 ! * misc.c: Unrevert misc.c (1.13) ! ! 2002-10-28 Nathanael Nerode ! ! * a-chlat9.ads a-cwila9.ads a-dynpri.adb a-retide.adb: Update ! maintainership comments. ! ! 2002-09-25 Nathanael Nerode ! PR ada/5904 ! * 5ataprop.adb 5atpopsp.adb 5bosinte.adb 5ftaprop.adb ! 5gtaprop.adb 5htaprop.adb 5rosinte.ads 5staprop.adb ! 5stpopse.adb 5vtaspri.ads 5zintman.adb 5ztaprop.adb ! 7staprop.adb: Correct statements in comments about ! maintainership of GNAT. ! ! PR ada/5904 ! * 1ssecsta.adb 1ssecsta.ads adadecode.c adadecode.h aux-io.c ! gnatname.adb gnatname.ads mkdir.c osint-b.adb osint-b.ads ! osint-c.adb osint-c.ads osint-l.adb osint-l.ads osint-m.adb ! osint-m.ads prj-makr.adb prj-makr.ads prj-pp.adb prj-pp.ads ! s-atacco.ads s-traceb.adb s-traceb.ads s-traces.adb ! s-traces.ads s-tratas.adb s-tratas.ads sinput-d.adb ! sinput-d.ads switch-b.adb switch-b.ads switch-c.adb ! switch-c.ads switch-m.adb switch-m.ads: Correct statements in ! comments about maintainership of GNAT. ! ! PR ada/6919 (forward port of patch for PR ada/5904) ! * 1aexcept.adb 1aexcept.ads 41intnam.ads 42intnam.ads ! 4aintnam.ads 4cintnam.ads 4dintnam.ads 4hexcpol.adb ! 4lintnam.ads 4mintnam.ads 4nintnam.ads 4onumaux.ads ! 4pintnam.ads 4rintnam.ads 4sintnam.ads 4uintnam.ads ! 4vcalend.adb 4vintnam.ads 4wcalend.adb 4wexcpol.adb ! 4wintnam.ads 4zintnam.ads 4znumaux.ads 4zsytaco.adb ! 4zsytaco.ads 51osinte.adb 51osinte.ads 52osinte.adb ! 52osinte.ads 52system.ads 53osinte.ads 5aosinte.ads ! 5asystem.ads 5atasinf.ads 5ataspri.ads 5avxwork.ads ! 5bosinte.ads 5bsystem.ads 5cosinte.ads 5dosinte.ads ! 5esystem.ads 5fosinte.ads 5fsystem.ads 5ftasinf.ads ! 5ginterr.adb 5gmastop.adb 5gosinte.ads 5gproinf.adb ! 5gproinf.ads 5gsystem.ads 5gtasinf.adb 5gtasinf.ads ! 5gtpgetc.adb 5hparame.ads 5hsystem.ads 5htaspri.ads ! 5iosinte.ads 5itaspri.ads 5ksystem.ads 5kvxwork.ads ! 5losinte.ads 5lsystem.ads 5mosinte.ads 5mvxwork.ads ! 5ninmaop.adb 5nintman.adb 5nosinte.ads 5ntaspri.ads ! 5oosprim.adb 5oparame.adb 5osystem.ads 5posinte.ads ! 5posprim.adb 5pvxwork.ads 5rosinte.ads 5rparame.adb ! 5sintman.adb 5sosinte.ads 5sparame.adb 5ssystem.ads ! 5stasinf.adb 5stasinf.ads 5staspri.ads 5svxwork.ads ! 5tosinte.ads 5uosinte.ads 5vasthan.adb 5vinterr.adb ! 5vintman.ads 5vosinte.ads 5vosprim.adb 5vosprim.ads ! 5vparame.ads 5vsystem.ads 5vtaspri.ads 5vtpopde.adb ! 5vtpopde.ads 5vvaflop.adb 5wintman.adb 5wmemory.adb ! 5wosinte.ads 5wosprim.adb 5wsystem.ads 5wtaprop.adb ! 5wtaspri.ads 5ysystem.ads 5zinterr.adb 5zosinte.adb ! 5zosinte.ads 5zosprim.adb 5zsystem.ads 6vcpp.adb 6vcstrea.adb ! 7sosprim.adb 86numaux.adb 86numaux.ads 9drpc.adb a-astaco.adb ! a-caldel.ads a-calend.adb a-calend.ads a-chahan.adb ! a-chahan.ads a-colien.adb a-colien.ads a-colire.adb ! a-colire.ads a-comlin.adb a-comlin.ads a-cwila1.ads ! a-decima.adb a-decima.ads a-diocst.adb a-diocst.ads ! a-direio.adb a-direio.ads a-einuoc.adb a-einuoc.ads ! a-except.adb a-except.ads a-excpol.adb a-exctra.adb ! a-exctra.ads a-filico.adb a-filico.ads a-finali.adb ! a-finali.ads a-interr.ads a-intsig.adb a-intsig.ads ! a-ngcefu.adb a-ngcoty.adb a-ngcoty.ads a-ngelfu.adb ! a-nudira.adb a-nudira.ads a-nuflra.adb a-nuflra.ads ! a-numaux.ads a-reatim.ads a-retide.ads a-sequio.adb ! a-sequio.ads a-siocst.adb a-siocst.ads a-ssicst.adb ! a-ssicst.ads a-stmaco.ads a-storio.adb a-strbou.adb ! a-strbou.ads a-stream.ads a-strfix.adb a-strfix.ads ! a-strmap.adb a-strmap.ads a-strsea.adb a-strsea.ads ! a-strunb.adb a-strunb.ads a-ststio.adb a-ststio.ads ! a-stunau.adb a-stunau.ads a-stwibo.adb a-stwibo.ads ! a-stwifi.adb a-stwima.adb a-stwima.ads a-stwise.adb ! a-stwise.ads a-stwiun.adb a-stwiun.ads a-suteio.adb ! a-suteio.ads a-swmwco.ads a-swuwti.adb a-swuwti.ads ! a-sytaco.adb a-sytaco.ads a-tags.adb a-tags.ads a-tasatt.ads ! a-taside.adb a-taside.ads a-teioed.adb a-teioed.ads ! a-textio.adb a-textio.ads a-ticoau.adb a-ticoau.ads ! a-ticoio.adb a-ticoio.ads a-tideau.adb a-tideau.ads ! a-tideio.adb a-tideio.ads a-tienau.adb a-tienau.ads ! a-tienio.adb a-tienio.ads a-tifiio.adb a-tifiio.ads ! a-tiflau.adb a-tiflau.ads a-tiflio.adb a-tiflio.ads ! a-tigeau.adb a-tigeau.ads a-tiinau.adb a-tiinau.ads ! a-tiinio.adb a-tiinio.ads a-timoau.adb a-timoau.ads ! a-timoio.adb a-timoio.ads a-tiocst.adb a-tiocst.ads ! a-titest.adb a-witeio.adb a-witeio.ads a-wtcoau.adb ! a-wtcoau.ads a-wtcoio.adb a-wtcstr.adb a-wtcstr.ads ! a-wtdeau.adb a-wtdeau.ads a-wtdeio.adb a-wtdeio.ads ! a-wtedit.adb a-wtedit.ads a-wtenau.adb a-wtenau.ads ! a-wtenio.adb a-wtenio.ads a-wtfiio.adb a-wtfiio.ads ! a-wtflau.adb a-wtflau.ads a-wtflio.adb a-wtflio.ads ! a-wtgeau.adb a-wtgeau.ads a-wtinau.adb a-wtinau.ads ! a-wtinio.adb a-wtmoau.adb a-wtmoau.ads a-wtmoio.adb ! a-wtmoio.ads a-wttest.adb ada-tree.def ada-tree.h ada.h ! adaint.c adaint.h ali-util.adb ali-util.ads ali.adb ali.ads ! alloc.ads argv.c atree.adb atree.ads atree.h back_end.adb ! back_end.ads bcheck.adb bcheck.ads binde.adb binde.ads ! binderr.adb binderr.ads bindgen.adb bindgen.ads bindusg.adb ! bindusg.ads butil.adb butil.ads cal.c casing.adb casing.ads ! ceinfo.adb checks.adb checks.ads cio.c comperr.adb comperr.ads ! csets.adb csets.ads csinfo.adb cstand.adb cstand.ads ! cstreams.c cuintp.c debug.adb debug.ads debug_a.adb ! debug_a.ads dec-io.adb dec-io.ads dec.ads decl.c deftarg.c ! einfo.adb einfo.ads einfo.h elists.adb elists.ads elists.h ! errno.c errout.adb errout.ads eval_fat.adb eval_fat.ads exit.c ! exp_aggr.adb exp_aggr.ads exp_attr.adb exp_attr.ads ! exp_ch10.ads exp_ch11.adb exp_ch11.ads exp_ch12.adb ! exp_ch12.ads exp_ch13.adb exp_ch13.ads exp_ch2.adb exp_ch2.ads ! exp_ch3.adb exp_ch3.ads exp_ch4.adb exp_ch4.ads exp_ch5.adb ! exp_ch5.ads exp_ch6.adb exp_ch6.ads exp_ch7.adb exp_ch7.ads ! exp_ch8.adb exp_ch8.ads exp_ch9.adb exp_ch9.ads exp_code.adb ! exp_code.ads exp_dbug.adb exp_dbug.ads exp_disp.adb ! exp_disp.ads exp_dist.adb exp_dist.ads exp_fixd.adb ! exp_fixd.ads exp_imgv.adb exp_imgv.ads exp_intr.adb ! exp_intr.ads exp_pakd.adb exp_pakd.ads exp_prag.adb ! exp_prag.ads exp_smem.adb exp_smem.ads exp_strm.adb ! exp_strm.ads exp_tss.adb exp_tss.ads exp_util.adb exp_util.ads ! exp_vfpt.adb exp_vfpt.ads expander.adb expander.ads fe.h ! final.c fmap.adb fmap.ads fname-sf.adb fname-sf.ads ! fname-uf.adb fname-uf.ads fname.adb fname.ads freeze.adb ! freeze.ads frontend.adb frontend.ads g-calend.ads g-comlin.adb ! g-debpoo.adb g-debpoo.ads g-locfil.adb g-os_lib.ads ! g-regist.adb g-regist.ads get_targ.adb get_targ.ads gigi.h ! gmem.c gnat1drv.adb gnat1drv.ads gnat_ug.texi gnatbind.adb ! gnatbind.ads gnatbl.c gnatcmd.adb gnatcmd.ads gnatdll.adb ! gnatfind.adb gnatkr.adb gnatkr.ads gnatlbr.adb gnatlink.adb ! gnatlink.ads gnatls.adb gnatls.ads gnatmake.adb gnatmake.ads ! gnatmem.adb gnatprep.adb gnatprep.ads gnatpsta.adb gnatvsn.ads ! gnatxref.adb hlo.adb hlo.ads hostparm.ads i-c.adb i-cexten.ads ! i-cobol.adb i-cobol.ads i-cpoint.adb i-cpoint.ads i-cpp.adb ! i-cpp.ads i-cstrea.adb i-cstrea.ads i-cstrin.adb i-cstrin.ads ! i-fortra.adb i-os2err.ads i-os2lib.adb i-os2lib.ads ! i-os2syn.ads i-os2thr.ads i-pacdec.adb i-pacdec.ads ! impunit.adb impunit.ads init.c inline.adb inline.ads io-aux.c ! itypes.adb itypes.ads krunch.adb krunch.ads lang-options.h ! lang-specs.h layout.adb layout.ads lib-list.adb lib-load.adb ! lib-load.ads lib-sort.adb lib-util.adb lib-util.ads ! lib-writ.adb lib-writ.ads lib-xref.adb lib-xref.ads lib.adb ! lib.ads link.c live.adb live.ads make.adb make.ads makeusg.adb ! makeusg.ads math_lib.adb mdll.adb mdll.ads memtrack.adb misc.c ! namet.adb namet.ads namet.h nlists.adb nlists.ads nlists.h ! nmake.adb nmake.ads nmake.adt opt.adb opt.ads osint.adb ! osint.ads output.adb output.ads par-ch10.adb par-ch11.adb ! par-ch12.adb par-ch13.adb par-ch2.adb par-ch3.adb par-ch4.adb ! par-ch5.adb par-ch6.adb par-ch7.adb par-ch8.adb par-ch9.adb ! par-endh.adb par-labl.adb par-load.adb par-prag.adb ! par-sync.adb par-tchk.adb par-util.adb par.adb par.ads ! prj-attr.adb prj-attr.ads prj-com.adb prj-com.ads prj-dect.adb ! prj-dect.ads prj-env.adb prj-env.ads prj-ext.adb prj-ext.ads ! prj-nmsc.adb prj-nmsc.ads prj-pars.adb prj-pars.ads ! prj-part.adb prj-part.ads prj-proc.adb prj-proc.ads ! prj-strt.adb prj-strt.ads prj-tree.adb prj-tree.ads ! prj-util.adb prj-util.ads prj.adb prj.ads raise.c raise.h ! repinfo.adb repinfo.ads repinfo.h restrict.adb restrict.ads ! rident.ads rtsfind.adb rtsfind.ads s-addima.adb s-addima.ads ! s-arit64.adb s-arit64.ads s-assert.adb s-assert.ads ! s-asthan.adb s-asthan.ads s-atacco.adb s-auxdec.adb ! s-auxdec.ads s-bitops.adb s-bitops.ads s-chepoo.ads ! s-direio.adb s-direio.ads s-except.ads s-exctab.adb ! s-exctab.ads s-exnflt.ads s-exngen.adb s-exngen.ads ! s-exnint.ads s-exnlfl.ads s-exnlin.ads s-exnllf.ads ! s-exnlli.ads s-exnsfl.ads s-exnsin.ads s-exnssi.ads ! s-expflt.ads s-expgen.adb s-expgen.ads s-expint.ads ! s-explfl.ads s-explin.ads s-expllf.ads s-explli.ads ! s-expllu.adb s-expllu.ads s-expmod.adb s-expmod.ads ! s-expsfl.ads s-expsin.ads s-expssi.ads s-expuns.adb ! s-expuns.ads s-fatflt.ads s-fatgen.adb s-fatgen.ads ! s-fatlfl.ads s-fatllf.ads s-fatsfl.ads s-ficobl.ads ! s-fileio.adb s-fileio.ads s-finimp.adb s-finimp.ads ! s-finroo.adb s-finroo.ads s-fore.adb s-fore.ads s-imgbiu.adb ! s-imgbiu.ads s-imgboo.adb s-imgboo.ads s-imgcha.adb ! s-imgcha.ads s-imgdec.adb s-imgdec.ads s-imgenu.adb ! s-imgenu.ads s-imgint.adb s-imgint.ads s-imgllb.adb ! s-imgllb.ads s-imglld.adb s-imglld.ads s-imglli.adb ! s-imglli.ads s-imgllu.adb s-imgllu.ads s-imgllw.adb ! s-imgllw.ads s-imgrea.adb s-imgrea.ads s-imguns.adb ! s-imguns.ads s-imgwch.adb s-imgwch.ads s-imgwiu.adb ! s-imgwiu.ads s-inmaop.ads s-interr.adb s-interr.ads ! s-intman.ads s-io.adb s-io.ads s-maccod.ads s-mantis.adb ! s-mantis.ads s-memory.adb s-memory.ads s-osprim.ads ! s-pack03.adb s-pack03.ads s-pack05.adb s-pack05.ads ! s-pack06.adb s-pack06.ads s-pack07.adb s-pack07.ads ! s-pack09.adb s-pack09.ads s-pack10.adb s-pack10.ads ! s-pack11.adb s-pack11.ads s-pack12.adb s-pack12.ads ! s-pack13.adb s-pack13.ads s-pack14.adb s-pack14.ads ! s-pack15.adb s-pack15.ads s-pack17.adb s-pack17.ads ! s-pack18.adb s-pack18.ads s-pack19.adb s-pack19.ads ! s-pack20.adb s-pack20.ads s-pack21.adb s-pack21.ads ! s-pack22.adb s-pack22.ads s-pack23.adb s-pack23.ads ! s-pack24.adb s-pack24.ads s-pack25.adb s-pack25.ads ! s-pack26.adb s-pack26.ads s-pack27.adb s-pack27.ads ! s-pack28.adb s-pack28.ads s-pack29.adb s-pack29.ads ! s-pack30.adb s-pack30.ads s-pack31.adb s-pack31.ads ! s-pack33.adb s-pack33.ads s-pack34.adb s-pack34.ads ! s-pack35.adb s-pack35.ads s-pack36.adb s-pack36.ads ! s-pack37.adb s-pack37.ads s-pack38.adb s-pack38.ads ! s-pack39.adb s-pack39.ads s-pack40.adb s-pack40.ads ! s-pack41.adb s-pack41.ads s-pack42.adb s-pack42.ads ! s-pack43.adb s-pack43.ads s-pack44.adb s-pack44.ads ! s-pack45.adb s-pack45.ads s-pack46.adb s-pack46.ads ! s-pack47.adb s-pack47.ads s-pack48.adb s-pack48.ads ! s-pack49.adb s-pack49.ads s-pack50.adb s-pack50.ads ! s-pack51.adb s-pack51.ads s-pack52.adb s-pack52.ads ! s-pack53.adb s-pack53.ads s-pack54.adb s-pack54.ads ! s-pack55.adb s-pack55.ads s-pack56.adb s-pack56.ads ! s-pack57.adb s-pack57.ads s-pack58.adb s-pack58.ads ! s-pack59.adb s-pack59.ads s-pack60.adb s-pack60.ads ! s-pack61.adb s-pack61.ads s-pack62.adb s-pack62.ads ! s-pack63.adb s-pack63.ads s-parame.adb s-parame.ads ! s-parint.adb s-parint.ads s-pooglo.adb s-pooglo.ads ! s-pooloc.adb s-pooloc.ads s-poosiz.adb s-poosiz.ads ! s-powtab.ads s-proinf.adb s-proinf.ads s-rpc.adb s-rpc.ads ! s-scaval.ads s-secsta.adb s-secsta.ads s-sequio.adb ! s-sequio.ads s-shasto.adb s-shasto.ads s-soflin.adb ! s-soflin.ads s-sopco3.adb s-sopco3.ads s-sopco4.adb ! s-sopco4.ads s-sopco5.adb s-sopco5.ads s-stache.adb ! s-stache.ads s-stalib.adb s-stalib.ads s-stoele.adb ! s-stopoo.ads s-stratt.adb s-stratt.ads s-strops.adb ! s-strops.ads s-taprob.ads s-taprop.ads s-tarest.ads ! s-tasdeb.adb s-tasdeb.ads s-tasinf.adb s-tasinf.ads ! s-tasini.ads s-taskin.ads s-tasren.ads s-tasres.ads ! s-tassta.ads s-tpinop.adb s-tpinop.ads s-tpoben.ads ! s-tpobop.ads s-unstyp.ads s-vaflop.adb s-vaflop.ads ! s-valboo.adb s-valboo.ads s-valcha.adb s-valcha.ads ! s-valdec.adb s-valdec.ads s-valenu.adb s-valenu.ads ! s-valint.adb s-valint.ads s-vallld.adb s-vallld.ads ! s-vallli.adb s-vallli.ads s-valllu.adb s-valllu.ads ! s-valrea.adb s-valrea.ads s-valuns.adb s-valuns.ads ! s-valuti.adb s-valuti.ads s-valwch.adb s-valwch.ads ! s-vercon.adb s-vercon.ads s-vmexta.adb s-vmexta.ads ! s-wchcnv.adb s-wchcnv.ads s-wchcon.ads s-wchjis.adb ! s-wchjis.ads s-wchstw.adb s-wchstw.ads s-wchwts.adb ! s-wchwts.ads s-widboo.adb s-widboo.ads s-widcha.adb ! s-widcha.ads s-widenu.adb s-widenu.ads s-widlli.adb ! s-widlli.ads s-widllu.adb s-widllu.ads s-widwch.adb ! s-widwch.ads s-wwdcha.adb s-wwdcha.ads s-wwdenu.adb ! s-wwdenu.ads s-wwdwch.adb s-wwdwch.ads scans.adb scans.ads ! scn-nlit.adb scn-slit.adb scn.adb scn.ads sdefault.ads sem.adb ! sem.ads sem_aggr.adb sem_aggr.ads sem_attr.adb sem_attr.ads ! sem_case.adb sem_case.ads sem_cat.adb sem_cat.ads sem_ch10.adb ! sem_ch10.ads sem_ch11.adb sem_ch11.ads sem_ch12.adb ! sem_ch12.ads sem_ch13.adb sem_ch13.ads sem_ch2.adb sem_ch2.ads ! sem_ch3.adb sem_ch3.ads sem_ch4.adb sem_ch4.ads sem_ch5.adb ! sem_ch5.ads sem_ch6.adb sem_ch6.ads sem_ch7.adb sem_ch7.ads ! sem_ch8.adb sem_ch8.ads sem_ch9.adb sem_ch9.ads sem_disp.adb ! sem_disp.ads sem_dist.adb sem_dist.ads sem_elab.adb ! sem_elab.ads sem_elim.adb sem_elim.ads sem_eval.adb ! sem_eval.ads sem_intr.adb sem_intr.ads sem_maps.adb ! sem_maps.ads sem_mech.adb sem_mech.ads sem_prag.adb ! sem_prag.ads sem_res.adb sem_res.ads sem_smem.adb sem_smem.ads ! sem_type.adb sem_type.ads sem_util.adb sem_util.ads ! sem_vfpt.adb sem_vfpt.ads sem_warn.adb sem_warn.ads ! sfn_scan.adb sfn_scan.ads sinfo-cn.adb sinfo-cn.ads sinfo.adb ! sinfo.ads sinfo.h sinput-l.adb sinput-l.ads sinput-p.adb ! sinput-p.ads sinput.adb sinput.ads snames.adb snames.ads ! snames.h sprint.adb sprint.ads stand.adb stand.ads stringt.adb ! stringt.ads stringt.h style.adb style.ads stylesw.adb ! stylesw.ads switch.adb switch.ads sysdep.c system.ads ! table.adb table.ads targparm.adb targparm.ads targtyps.c ! tbuild.adb tbuild.ads trans.c tree_gen.adb tree_gen.ads ! tree_in.adb tree_in.ads tree_io.adb tree_io.ads treepr.adb ! treepr.ads treeprs.ads treeprs.adt ttypef.ads ttypes.ads ! types.adb types.ads types.h uintp.adb uintp.ads uintp.h ! uname.adb uname.ads urealp.adb urealp.ads urealp.h usage.adb ! usage.ads utils.c utils2.c validsw.adb validsw.ads ! widechar.adb widechar.ads xeinfo.adb xnmake.adb xr_tabls.adb ! xr_tabls.ads xref_lib.adb xref_lib.ads xsinfo.adb xsnames.adb ! xtreeprs.adb: Correct statements in comments about maintainership ! of GNAT. ! ! 2002-09-23 Zack Weinberg ! ! * Make-lang.in (EXTRA_GNATBIND_OBJS): Add version.o. ! * Makefile.in (TOOLS_LIBS): Add ../../version.o. ! * gnatvsn.ads: Gnat_Version_String is now a function. ! * gnatvsn.adb: New file. When asked for Gnat_Version_String, ! copy the C version_string into a String and return it. ! * gnatcmd.adb, gnatkr.adb, gnatlbr.adb, gnatlink.adb, ! gnatls.adb,gnatmake.adb, gnatprep.adb, gnatpsta.adb: ! Remove pragma Ident (Gnat_Version_String). If this was the ! sole use of package Gnatvsn, remove the with statement too. ! * gnat1drv.adb: Tweak -gnatv output. ! ! 2002-09-17 Richard Henderson ! ! * trans.c (tree_transform): Use real_ldexp not REAL_VALUE_LDEXP. ! * config/dsp16xx/dsp16xx.md (fixuns_trunchfhi2): Use real_2expN. ! * config/mips/mips.md (fixuns_truncdfsi2): Likewise. ! (fixuns_truncdfdi2, fixuns_truncsfsi2, fixuns_truncsfdi2): Likewise. ! * config/m68k/m68k.c (floating_exact_log2): Use real_exponent ! and real_2expN instead of a loop. ! * doc/tm.texi (REAL_VALUE_LDEXP): Remove. ! (REAL_VALUE_RNDZINT, REAL_VALUE_UNSIGNED_RNDZINT): Remove. 2002-08-25 Andre Leis ! David Billinghurst (David.Billinghurst@riotinto.com> ! * sysdep.c (__gnat_ttyname): include on cygwin ! 2002-08-13 Rainer Orth ! * Make-lang.in (gnatbind$(exeext)): Link with $(SYSLIBS). ! Remove $(CONFIG_H) dependency. ! 2002-08-08 Nathan Sidwell ! * ada/Make-lang.in (ada.mostlyclean): Remove coverage files. ! 2002-07-29 Kaveh R. Ghazi ! * adadecode.c (ada_demangle): Use xstrdup in lieu of ! xmalloc/strcpy. ! * misc.c (gnat_decode_option): Likewise. ! 2002-07-15 Florian Weimer ! * make.adb (Add_Switch): Make Generic_Position a procedure. The ! function approach did not work well because of a side effect (the ! function call could reallocate the table which was being indexed ! using its result). Fixes ada/4851. [RESURRECTED] ! 2002-07-01 Roger Sayle ! * ada/utils.c (builtin_function): Accept an additional parameter. ! 2002-06-28 Andreas Jaeger ! PR ada/7144 ! * Makefile.in: Fix typo in comment, patch by Adrian Knoth ! . ! 2002-06-24 Kaveh R. Ghazi ! * Makefile.in (SHELL): Set to @SHELL@. ! 2002-06-20 Kaveh R. Ghazi ! * utils.c (init_gigi_decls): Use ARRAY_SIZE in lieu of explicit ! array size calculation. ! 2002-06-04 Andreas Jaeger ! * Make-lang.in (gnatbind): Readd rule that has been lost in last ! patch. ! 2002-06-03 Geoffrey Keating ! Merge from pch-branch: ! * config-lang.in (gtfiles): Add ada-tree.h. ! * ada-tree.h (SET_TYPE_CI_CO_LIST): New. ! (SET_TYPE_MODULUS): New. ! (SET_TYPE_INDEX): New. ! (SET_TYPE_DIGITS_VALUE): New. ! (SET_TYPE_RM_SIZE): New. ! (SET_TYPE_UNCONSTRAINED_ARRAY): New. ! (SET_TYPE_ADA_SIZE): New. ! (SET_TYPE_ACTUAL_BOUNDS): New. ! (SET_DECL_CONST_CORRESPONDING_VAR): New. ! (SET_DECL_ORIGINAL_FIELD): New. ! (TREE_LOOP_ID): Correct typo. ! * decl.c: Use new macros. ! * utils.c: Include debug.h, use new macros. ! * utils2.c: Use new macros. ! * ada-tree.h: Update all macros for new tree description. ! (struct tree_loop_id): New. ! (union lang_tree_node): New. ! (struct lang_decl): New. ! (struct lang_type): New. ! * misc.c (gnat_mark_tree): Delete. ! (LANG_HOOKS_MARK_TREE): Delete. ! * trans.c (tree_transform): No longer any need to cast ! for TREE_LOOP_ID. ! * utils.c (struct language_function): New dummy structure. ! * Makefile.in (decl.o): gt-ada- is in objdir, not srcdir. ! (misc.o): Likewise. ! (utils.o): Likewise; also gtype-ada.h. ! * Make-lang.in (gnat1): Add dependency on s-gtype. ! (gnatbind): Add dependency on $(CONFIG_H). ! * utils.c: Correct last #include. ! (stuct e_stack): Remove unnecessary 'static'. ! (mark_e_stack): Remove unused prototype. ! * scn-nlit.adb: Remove whitespace after version number to ! keep lines under 80 chars. ! * snames.adb: Likewise. ! * treepr.ads: Likewise. ! * Makefile.in (decl.o): Include gt-ada-.h. ! (misc.o): Likewise. ! (utils.o): Include gt-ada-.h and gtype-ada.h. ! * config-lang.in (gtfiles): New. ! * decl.c: Use gengtype for roots. ! * gigi.h: Use gengtype for roots. ! * trans.c: Use gengtype for roots. ! * utils.c: Use gengtype for roots, marking. Include gtype-ada.h. ! ! 2002-06-02 Gabriel Dos Reis ! ! * misc.c (gnat_init): Adjust setting of internal_error_function. ! ! 2002-06-01 Joseph S. Myers ! ! * gnat_ug.texi: Use @ifnottex instead of @ifinfo. ! * gnat_ug_unx.texi, gnat_ug_vms.texi, gnat_ug_vxw.texi, ! gnat_ug_wnt.texi: Regenerate. ! ! 2002-05-31 Florian Weimer ! ! * 5ntaprop.adb (with System.OS_Primitives): Remove. ! ! * cstreams.c (max_path_len): Move from here ... ! * adaint.c (__gnat_max_path_len): ... to here. ! * adaint.c (__gnat_max_path_len): Declare. ! * g-dirope.adb (Max_Path): Adjust. ! * g-os_lib.adb (Normalize_Pathname.Max_Path): Adjust. ! * i-cstrea.ads (max_path_len): Adjust. ! * osint.adb (Get_RTS_Search_Dir.Max_Path): Adjust. ! * xr_tabls.adb (Dir_Name.Max_Path: Adjust. ! ! * Makefile.in, Make-lang.in: Documentation is now built in ! Make-lang.in. Store Info and generated Texinfo files in the ! source directory. ! * gnat_ug.texi: Remove CVS keywords, correct version number. ! Set file name correctly. ! ! * gnat_ug_*.texi: Add. ! * .cvsignore: Ignore generated Texinfo files. ! ! 2002-05-30 Zack Weinberg ! ! * ada.h: Add MI guard macro. ! (SUBTYPE): Define constants with an anonymous enum, not static ! const variables. ! (IN): Cast constants to appropriate type before use. ! ! 2002-05-26 Joseph S. Myers ! ! * gnatvsn.ads (Gnat_Version_String): Change to "3.2 20020526 ! (experimental)". ! ! 2002-05-23 Rainer Orth ! ! * Make-lang.in (CP, ECHO): Copy from Makefile.in. ! (X_ADA_CFLAGS, T_ADA_CFLAGS, X_ADAFLAGS, T_ADAFLAGS): Likewise. ! (ALL_ADAFLAGS, FORCE_DEBUG_ADAFLAGS, ADA_CFLAGS): Likewise. ! (ALL_ADA_CFLAGS): Likewise. ! (ADA_INCLUDES): Likewise. ! Adapt for new working dir. ! (GNATBIND): Use Makefile.in version. ! (.SUFFIXES): Copy from Makefile.in. ! (ada-warn): Define. ! (.adb.o, .ads.o): Copy from Makefile.in. ! Added $(OUTPUT_OPTION). ! (GNAT1_C_OBJS): Moved from Makefile.in. ! Prefix with ada subdir. ! (GNAT_ADA_OBJS, GNAT1_ADA_OBJS, GNAT1_OBJS, GNATBIND_OBJS): Likewise. ! (EXTRA_GNAT1_OBJS): Moved from Makefile.in. ! Adapt for new working dir. ! (EXTRA_GNATBIND_OBJS): Likewise. ! (ADA_BACKEND): Moved from Makefile.in. ! Renamed to avoid conflict with global BACKEND. ! Use that one. ! (TARGET_ADA_SRCS): Moved from Makefile.in. ! (gnat1$(exeext)): Replaced recursive rule with Makefile.in version. ! Use ADA_BACKEND. ! (gnatbind$(exeext)): Replaced recursive rule with Makefile.in version. ! (ada_extra_files): Moved from Makefile.in. ! Prefix with ada subdir. ! (ada/b_gnat1.c, ada/b_gnat1.o, ada/b_gnatb.c, ada/b_gnatb.o): Likewise. ! (ada/treeprs.ads, ada/einfo.h, ada/sinfo.h, ada/nmake.adb): Likewise. ! (ada/nmake.ads): Likewise. ! (update-sources): Moved from Makefile.in. ! Prefix with ada subdir. ! (ada/sdefault.adb, ada/stamp-sdefault, ada/sdefault.o): Likewise. ! (ADA_TREE_H): Likewise. ! (ada/a-except.o, ada/s-assert.o, ada/s-memory.o): Likewise. ! (ada/memtrack.o): Likewise. ! (ada/adadecode.o): Likewise. ! Update dependencies. ! (ada/adaint.o): New. ! (ada/argv.o): Moved from Makefile.in. ! Prefix with ada subdir. ! Update dependencies. ! (ada/cstreams.o, ada/exit.o, ada/final.o, ada/link.o): Likewise. ! (ada/cio.o, ada/init.o, ada/raise.o, ada/tracebak.o): Likewise. ! (ada/cuintp.o, ada/decl.o, ada/misc.o): Moved from Makefile.in. ! Prefix with ada subdir. ! (ada/targtyps.o, ada/trans.o, ada/utils.o, ada/utils2.o): Likewise. ! (GNAT DEPENDENCIES): Regenerate. ! * Makefile.in (MACHMODE_H, RTL_H, TREE_H): Removed, provided by ! toplevel Makefile.in. ! (EXTRA_GNAT1_OBJS, EXTRA_GNATBIND_OBJS): Removed. ! (TARGET_ADA_SRCS): Removed. ! (GNAT1_C_OBJS, GNAT_ADA_OBJS, GNAT1_ADA_OBJS, GNAT1_OBJS): Likewise. ! (GNATBIND_OBJS): Likewise. ! (ADA_INCLUDE_DIR, ADA_RTL_OBJ_DIR): Moved here. ! (BACKEND): Removed. ! (../gnat1$(exeext), ../gnatbind$(exeext)): Likewise. ! (TREE_H): Likewise. ! (ada_extra_files): Likewise. ! (b_gnat1.c, b_gnat1.o, b_gnatb.c, b_gnatb.o): Likewise. ! (treeprs.ads, einfo.h, sinfo.h, nmake.adb, nmake.ads): Likewise. ! (update-sources): Likewise. ! (sdefault.adb, stamp-sdefault, sdefault.o): Likewise ! (ADA_TREE_H): Likewise. ! (adadecoce.o): Likewise. ! (cuintp.o, decl.o, misc.o, trans.o, utils.o, utils2.o): Likewise. ! (GNAT DEPENDENCIES): Likewise. ! ! 2002-05-16 Rainer Orth ! ! * Makefile.adalib: Allow for PWDCMD to override hardcoded pwd. ! * Makefile.in: Likewise. ! ! 2002-05-14 Rainer Orth ! ! * Make-lang.in (gnat1$(exeext), gnatbind$(exeext), gnattools): ! Restore $(CONFIG_H) and prefix.o dependencies. ! (ada.stage[1-4]): Depend on stage?-start. ! ! * Makefile.in (b_gnatb.c): Depend on interfac.o. ! ! 2002-05-02 Jim Wilson ! ! * utils.c (finish_record_type): Change record_size to record_type. ! ! 2001-05-02 John David Anglin ! ! * ada/Makefile.in (X_ADA_CFLAGS, T_ADA_CFLAGS): New fragment overrides. ! (ALL_ADA_CFLAGS): Define. Replace ADA_CFLAGS with ALL_ADA_CFLAGS in ! ALL_ADAFLAGS, MOST_ADAFLAGS, and all compilations using CC. ! ! 2002-04-25 Neil Booth ! ! * misc.c (gnat_parse_file): Update. ! ! 2002-04-24 Neil Booth ! ! * misc.c (gnat_init): Don't set lang_attribute_common. 2002-04-21 Joseph S. Myers *************** *** 503,527 **** * xgnatug.adb, ug_words: New files. * Makefile.in (doc, dvi): New targets. Build gnat_ug_*, ! gnat_rm and gnat-style manuals. ! * adaint.c (__gnat_tmp_name): Remove buffer overflow bug on ! GNU/Linux. 2002-04-16 Mark Mitchell * trans.c (tree_transform): Add has_scope argument to expand_start_stmt_expr. 2002-04-04 Laurent Guerby * make.adb: Implement -margs, remove restriction about file name placement. * makeusg.adb: Documentation update. 2002-03-11 Richard Henderson * Makefile.in (.NOTPARALLEL): Add fake tag. 2002-02-07 Richard Henderson * adaint.c (__gnat_to_gm_time): First arg is int, not time_t. --- 705,1039 ---- * xgnatug.adb, ug_words: New files. * Makefile.in (doc, dvi): New targets. Build gnat_ug_*, ! gnat_rm and gnat-style manuals. ! 2002-04-18 Neil Booth ! ! * gigi.h (incomplete_type_error): Remove. ! * utils.c (incomplete_type_error): Remove. 2002-04-16 Mark Mitchell * trans.c (tree_transform): Add has_scope argument to expand_start_stmt_expr. + 2002-04-04 Neil Booth + + * gigi.h (truthvalue_conversion): Rename. + * misc.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine. + * trans.c (tree_transform): Update. + * utils2.c (truthvalue_conversion): Rename, update. + (build_binary_op, build_unary_op): Update. + 2002-04-04 Laurent Guerby * make.adb: Implement -margs, remove restriction about file name placement. * makeusg.adb: Documentation update. + * Makefile.in (TOOLS_FLAGS_TO_PASS): Add VPATH=$(fsrcdir). + * Makefile.in (gnattools3): Comment out, gnatmem does not build without libaddr2line. + + 2002-04-04 Neil Booth + + * utils.c (create_subprog_decl): Use SET_DECL_ASSEMBLER_NAME. + (builtin_function): Similarly. + + 2002-04-01 Neil Booth + + * decl.c (gnat_to_gnu_entity): Update. + * gigi.h (mark_addressable): Rename. + * misc.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine. + * trans.c (tree_transform): Update. + * utils.c (create_var_decl): Update. + * util2.c (build_binary_op, build_unary_op, + fill_vms_descriptor): Update. + (mark_addressable): Rename, update. + + 2002-04-01 Neil Booth + + * gigi.h (unsigned_type, signed_type, signed_or_unsigned_type): + Rename. + * misc.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE, + LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New. + * trans.c (tree_transform, convert_with_check): Update. + * utils.c (unsigned_type, signed_type, signed_or_unsigned_type): + Rename. + + 2002-03-31 Neil Booth + + * gigi.h (finish_incomplete_decl): Rename. + * misc.c (LANG_HOOKS_FINISH_INCOMPLETE_DECL): Redefine. + * utils.c (gnat_init_decl_processing): Don't set hook. + (finish_incomplete_decl): Rename. + + 2002-03-29 Andreas Schwab + + * Makefile.in: Pass VPATH=$(fsrcdir) when calling make in rts + directory. + + 2001-03-28 Robert Dewar + + * checks.ads: + (Remove_Checks): New procedure + + * checks.adb: + (Remove_Checks): New procedure + + * exp_util.adb: + Use new Duplicate_Subexpr functions + (Duplicate_Subexpr_No_Checks): New procedure + (Duplicate_Subexpr_No_Checks_Orig): New procedure + (Duplicate_Subexpr): Restore original form (checks duplicated) + (Duplicate_Subexpr): Call Remove_Checks + + * exp_util.ads: + (Duplicate_Subexpr_No_Checks): New procedure + (Duplicate_Subexpr_No_Checks_Orig): New procedure + Add 2002 to copyright notice + + * sem_util.adb: Use new Duplicate_Subexpr functions + + * sem_eval.adb: + (Eval_Indexed_Component): This is the place to call + Constant_Array_Ref and to replace the value. We simply merge + the code of this function in here, since it is now no longer + used elsewhere. This fixes the problem of the back end not + realizing we were clever enough to see that this was + constant. + (Expr_Val): Remove call to Constant_Array_Ref + (Expr_Rep_Val): Remove call to Constant_Array_Ref + Minor reformatting + (Constant_Array_Ref): Deal with string literals (patch + suggested by Zack Weinberg on the gcc list) + + 2001-03-28 Ed Schonberg + + * exp_util.adb: Duplicate_Subexpr_No_Checks_Orig => + Duplicate_Subexpr_Move_Checks. + + * exp_util.ads: Duplicate_Subexpr_No_Checks_Orig => + Duplicate_Subexpr_Move_Checks. + + * sem_eval.adb: (Constant_Array_Ref): Verify that constant + value of array exists before retrieving it (it may a private + protected component in a function). + + 2002-03-28 Geert Bosch + + * prj-pp.adb : New file. + + * prj-pp.ads : New file. + + 2002-03-28 Andreas Jaeger + + * Makefile.in (stamp-sdefault): Fix path for Makefile. + + 2002-03-28 Neil Booth + + * misc.c (gnat_expand_expr): Move prototype. + + 2002-03-27 Neil Booth + + * misc.c (insert_default_attributes): Remove. + + 2002-03-27 Neil Booth + + * misc.c (LANG_HOOKS_EXPAND_EXPR): Redefine. + (gnat_init): Don't set hook. + (gnat_expand_expr): Fix prototype. + + 2002-03-27 Neil Booth + + * misc.c (ggc_p): Remove. + + 2002-03-27 Geert Bosch + + * prj-makr.ads, prj-makr.adb : New files. + + 2002-03-26 Neil Booth + + * misc.c (LANG_HOOKS_MARK_TREE): Redefine. + (lang_mark_tree): Make static, rename. + + 2002-03-25 Neil Booth + + * misc.c (maybe_build_cleanup): Remove. + + 2002-03-24 Neil Booth + + * gigi.h (yyparse): Remove. + + 2002-03-23 Florian Weimer + + * gnat_rm.texi: Sync with ACT version. + (From Ben Brosgol ) + + 2002-03-20 Neil Booth + + * misc.c (LANG_HOOKS_DECL_PRINTABLE_NAME): Redefine. + (gnat_init): Remove old hook. + + 2002-03-17 Neil Booth + + * misc.c (LANG_HOOKS_PARSE_FILE): Redefine. + (yyparse): Rename gnat_parse_file. + + 2002-03-14 Geoffrey Keating + + Delete all lines containing "$Revision:". + * xeinfo.adb: Don't look for revision numbers. + * xnmake.adb: Likewise. + * xsinfo.adb: Likewise. + * xsnames.adb: Likewise. + * xtreeprs.adb: Likewise. + + 2002-03-12 Kaveh R. Ghazi + + * misc.c (gnat_tree_code_type, gnat_tree_code_length, + gnat_tree_code_name): Delete. + (tree_code_type, tree_code_length, tree_code_name): Define. + (gnat_init): Don't try to copy into the various tree_code + arrays. 2002-03-11 Richard Henderson * Makefile.in (.NOTPARALLEL): Add fake tag. + 2002-03-07 Geert Bosch + + * adadecode.c, adadecode.h, aux-io.c, s-traces.adb, s-traces.ads, + s-tratas.adb, s-tratas.ads, sinput-d.adb, sinput-d.ads, + switch-b.adb, switch-b.ads, switch-c.adb, switch-c.ads, + switch-m.adb, switch-m.ads : New files. + + 2002-03-07 Geert Bosch + + * 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads, + 4dintnam.ads, 4gintnam.ads, 4hintnam.ads, 4lintnam.ads, + 4mintnam.ads, 4pintnam.ads, 4rintnam.ads, 4sintnam.ads, + 4uintnam.ads, 4vcalend.adb, 4zintnam.ads, 52system.ads, + 5amastop.adb, 5asystem.ads, 5ataprop.adb, 5atpopsp.adb, + 5avxwork.ads, 5bosinte.adb, 5bsystem.ads, 5esystem.ads, + 5fsystem.ads, 5ftaprop.adb, 5ginterr.adb, 5gmastop.adb, + 5gsystem.ads, 5gtaprop.adb, 5gtasinf.adb, 5gtasinf.ads, + 5hparame.ads, 5hsystem.ads, 5htaprop.adb, 5htraceb.adb, + 5itaprop.adb, 5ksystem.ads, 5kvxwork.ads, 5lintman.adb, + 5lsystem.ads, 5mvxwork.ads, 5ninmaop.adb, 5nosinte.ads, + 5ntaprop.adb, 5ointerr.adb, 5omastop.adb, 5oosinte.adb, + 5osystem.ads, 5otaprop.adb, 5otaspri.ads, 5pvxwork.ads, + 5qtaprop.adb, 5sintman.adb, 5ssystem.ads, 5staprop.adb, + 5stpopse.adb, 5svxwork.ads, 5tosinte.ads, 5uintman.adb, + 5vasthan.adb, 5vinmaop.adb, 5vinterr.adb, 5vintman.adb, + 5vmastop.adb, 5vparame.ads, 5vsystem.ads, 5vtaprop.adb, + 5vtpopde.adb, 5wmemory.adb, 5wsystem.ads, 5wtaprop.adb, + 5ysystem.ads, 5zinterr.adb, 5zintman.adb, 5zosinte.adb, + 5zosinte.ads, 5zsystem.ads, 5ztaprop.adb, 6vcpp.adb, 6vcstrea.adb, + 7sintman.adb, 7staprop.adb, 7stpopsp.adb, 9drpc.adb, + Make-lang.in, Makefile.in, a-caldel.adb, a-comlin.ads, + a-dynpri.adb, a-except.adb, a-except.ads, a-finali.adb, + a-ncelfu.ads, a-reatim.adb, a-retide.adb, a-stream.ads, + a-ststio.adb, a-ststio.ads, a-stwifi.adb, a-tags.adb, a-tasatt.adb, + a-textio.adb, a-tideau.adb, a-tiflau.adb, a-tigeau.adb, + a-tigeau.ads, a-tiinau.adb, a-timoau.adb, a-witeio.adb, + a-wtdeau.adb, a-wtenau.adb, a-wtflau.adb, a-wtgeau.adb, + a-wtgeau.ads, a-wtinau.adb, a-wtmoau.adb, ada-tree.def, ada-tree.h, + adaint.c, adaint.h, ali-util.adb, ali.adb, ali.ads, atree.adb, + atree.ads, atree.h, back_end.adb, bcheck.adb, bindgen.adb, + bindusg.adb, checks.adb, comperr.adb, config-lang.in, csets.adb, + csets.ads, cstand.adb, cstreams.c, debug.adb, debug.ads, decl.c, + einfo.adb, einfo.ads, einfo.h, elists.h, errout.adb, errout.ads, + eval_fat.adb, exp_aggr.adb, exp_attr.adb, exp_ch11.adb, + exp_ch12.adb, exp_ch13.adb, exp_ch2.adb, exp_ch3.adb, exp_ch3.ads, + exp_ch4.adb, exp_ch5.adb, exp_ch6.adb, exp_ch7.adb, exp_ch7.ads, + exp_ch9.adb, exp_ch9.ads, exp_dbug.adb, exp_dbug.ads, exp_disp.ads, + exp_dist.adb, exp_fixd.adb, exp_intr.adb, exp_pakd.adb, + exp_prag.adb, exp_strm.adb, exp_util.adb, exp_util.ads, + expander.adb, expect.c, fe.h, fmap.adb, fmap.ads, fname-uf.adb, + freeze.adb, frontend.adb, g-awk.adb, g-cgideb.adb, g-comlin.adb, + g-comlin.ads, g-debpoo.adb, g-dirope.adb, g-dirope.ads, + g-dyntab.adb, g-expect.adb, g-expect.ads, g-io.ads, g-io_aux.adb, + g-io_aux.ads, g-locfil.adb, g-locfil.ads, g-os_lib.adb, + g-os_lib.ads, g-regexp.adb, g-regpat.adb, g-socket.adb, + g-socket.ads, g-spipat.adb, g-table.adb, g-trasym.adb, + g-trasym.ads, gigi.h, gmem.c, gnat1drv.adb, gnatbind.adb, gnatbl.c, + gnatchop.adb, gnatcmd.adb, gnatdll.adb, gnatfind.adb, gnatlbr.adb, + gnatlink.adb, gnatls.adb, gnatmem.adb, gnatprep.adb, gnatvsn.ads, + gnatxref.adb, hlo.adb, hostparm.ads, i-cobol.adb, i-cpp.adb, + i-cstrea.ads, i-cstrin.adb, i-pacdec.adb, i-vxwork.ads, + impunit.adb, init.c, inline.adb, io-aux.c, layout.adb, lib-load.adb, + lib-util.adb, lib-writ.adb, lib-writ.ads, lib-xref.adb, + lib-xref.ads, lib.adb, lib.ads, make.adb, makeusg.adb, mdll.adb, + memroot.adb, misc.c, mlib-tgt.adb, mlib-utl.adb, mlib-utl.ads, + mlib.adb, namet.adb, namet.ads, namet.h, nlists.h, nmake.adb, + nmake.ads, nmake.adt, opt.adb, opt.ads, osint.adb, osint.ads, + output.adb, output.ads, par-ch2.adb, par-ch3.adb, par-ch5.adb, + par-prag.adb, par-tchk.adb, par-util.adb, par.adb, prj-attr.adb, + prj-dect.adb, prj-env.adb, prj-env.ads, prj-nmsc.adb, prj-part.adb, + prj-proc.adb, prj-strt.adb, prj-tree.adb, prj-tree.ads, prj.adb, + prj.ads, raise.c, raise.h, repinfo.adb, restrict.adb, restrict.ads, + rident.ads, rtsfind.adb, rtsfind.ads, s-arit64.adb, s-asthan.adb, + s-atacco.adb, s-atacco.ads, s-auxdec.adb, s-crc32.adb, s-crc32.ads, + s-direio.adb, s-fatgen.adb, s-fileio.adb, s-finimp.adb, + s-gloloc.adb, s-gloloc.ads, s-interr.adb, s-mastop.adb, + s-mastop.ads, s-memory.adb, s-parame.ads, s-parint.adb, + s-pooglo.adb, s-pooloc.adb, s-rpc.adb, s-secsta.adb, s-sequio.adb, + s-shasto.adb, s-soflin.adb, s-soflin.ads, s-stache.adb, + s-taasde.adb, s-taasde.ads, s-tadeca.adb, s-tadeca.ads, + s-tadert.adb, s-tadert.ads, s-taenca.adb, s-taenca.ads, + s-taprob.adb, s-taprop.ads, s-tarest.adb, s-tasdeb.adb, + s-tasini.adb, s-tasini.ads, s-taskin.adb, s-taskin.ads, + s-tasque.adb, s-tasque.ads, s-tasren.adb, s-tasren.ads, + s-tassta.adb, s-tasuti.adb, s-tasuti.ads, s-tataat.adb, + s-tataat.ads, s-tpoben.adb, s-tpoben.ads, s-tpobop.adb, + s-tposen.adb, s-tposen.ads, s-traceb.adb, s-traceb.ads, + s-unstyp.ads, s-widenu.adb, scn-nlit.adb, scn.adb, sem.adb, + sem_aggr.adb, sem_attr.adb, sem_attr.ads, sem_case.adb, + sem_ch10.adb, sem_ch11.adb, sem_ch11.ads, sem_ch12.adb, + sem_ch13.adb, sem_ch13.ads, sem_ch2.adb, sem_ch3.adb, sem_ch3.ads, + sem_ch4.adb, sem_ch5.adb, sem_ch6.adb, sem_ch6.ads, sem_ch7.adb, + sem_ch8.adb, sem_ch8.ads, sem_ch9.adb, sem_disp.adb, sem_dist.adb, + sem_elab.adb, sem_elim.adb, sem_elim.ads, sem_eval.adb, + sem_intr.adb, sem_mech.adb, sem_prag.adb, sem_res.adb, + sem_type.adb, sem_util.adb, sem_util.ads, sem_vfpt.adb, + sem_warn.adb, sinfo.adb, sinfo.ads, sinfo.h, sinput-l.adb, + sinput-l.ads, sinput.adb, sinput.ads, snames.adb, snames.ads, + snames.h, sprint.adb, sprint.ads, stringt.adb, stringt.ads, + stringt.h, style.adb, switch.adb, switch.ads, sysdep.c, system.ads, + table.adb, targparm.adb, targparm.ads, targtyps.c, tbuild.adb, + tbuild.ads, tracebak.c, trans.c, tree_gen.adb, tree_io.adb, + treepr.adb, treepr.ads, treeprs.ads, treeprs.adt, ttypes.ads, + types.adb, types.ads, types.h, uintp.ads, urealp.ads, usage.adb, + utils.c, utils2.c, validsw.adb, xnmake.adb, xr_tabls.adb, + xr_tabls.ads, xref_lib.adb, xref_lib.ads : Merge in ACT changes. + + * 1ssecsta.adb, 1ssecsta.ads, a-chlat9.ads, a-cwila9.ads, + g-enblsp.adb, g-md5.adb, g-md5.ads, gnatname.adb, gnatname.ads, + mkdir.c, osint-b.adb, osint-b.ads, osint-c.adb, osint-c.ads, + osint-l.adb, osint-l.ads, osint-m.adb, osint-m.ads : New files + + * 3lsoccon.ads, 5qparame.ads, 5qvxwork.ads, 5smastop.adb, + 5zparame.ads, gnatmain.adb, gnatmain.ads, gnatpsys.adb : Removed + + * mdllfile.adb, mdllfile.ads, mdlltool.adb, mdlltool.ads : Renamed + to mdll-fil.ad[bs] and mdll-util.ad[bs] + + * mdll-fil.adb, mdll-fil.ads, mdll-utl.adb, mdll-utl.ads : Renamed + from mdllfile.ad[bs] and mdlltool.ad[bs] + + 2002-03-03 Kaveh R. Ghazi + + * utils.c (init_gnat_to_gnu, init_gigi_decls): Use ARRAY_SIZE in + lieu of explicit sizeof/sizeof. + + 2002-02-28 Neil Booth + + * misc.c (copy_lang_decl): Remove. + + 2002-02-27 Zack Weinberg + + * misc.c: Delete traditional-mode-related code copied from the + C front end but not used, or used only to permit the compiler + to link. + 2002-02-07 Richard Henderson * adaint.c (__gnat_to_gm_time): First arg is int, not time_t. *************** *** 545,551 **** * gnat-style.texi (Declarations and Types): Remove ancient style rule which was mandated by code generation issues. ! * gnat-style.texi (header): Add @dircategory, @direntry. (title page): Remove date. (general) Add @./@: where approriate, and two spaces after the --- 1057,1063 ---- * gnat-style.texi (Declarations and Types): Remove ancient style rule which was mandated by code generation issues. ! * gnat-style.texi (header): Add @dircategory, @direntry. (title page): Remove date. (general) Add @./@: where approriate, and two spaces after the *************** *** 574,655 **** 2001-12-19 Robert Dewar * bindgen.adb: Minor reformatting ! * cstand.adb: Minor reformatting ! * fmap.adb: Minor reformatting Change name from Add for Add_To_File_Map (Add is much too generic) Change Path_Name_Of to Mapped_Path_Name Change File_Name_Of to Mapped_File_Name Fix copyright dates in header ! * fmap.ads: Change name from Add for Add_To_File_Map (Add is much too generic) Change Path_Name_Of to Mapped_Path_Name Change File_Name_Of to Mapped_File_Name Fix copyright dates in header ! * fname-uf.adb: Minor reformatting. New names of stuff in Fmap. Add use clause for Fmap. ! * make.adb: Minor reformatting ! * osint.adb: Minor reformatting. Change of names in Fmap. Add use clause for Fmap. ! * prj-env.adb: Minor reformatting ! * prj-env.ads: Minor reformatting ! ! * switch.adb: Minor reformatting. Do proper raise of Bad_Switch if ! error found (there were odd exceptions to this general rule in -gnatec/-gnatem processing) ! 2001-12-19 Olivier Hainque ! * raise.c (__gnat_eh_personality): Exception handling personality ! routine for Ada. Still in rough state, inspired from the C++ version and still containing a bunch of debugging artifacts. ! (parse_lsda_header, get_ttype_entry): Local (static) helpers, also inspired from the C++ library. ! ! * raise.c (eh_personality): Add comments. Part of work for the GCC 3 exception handling integration. ! 2001-12-19 Arnaud Charlet * Makefile.in: Remove use of 5smastop.adb which is obsolete. (HIE_SOURCES): Add s-secsta.ad{s,b}. (HIE_OBJS): Add s-fat*.o ! (RAVEN_SOURCES): Remove files that are no longer required. Add interrupt handling files. (RAVEN_MOD): Removed, no longer needed. ! 2001-12-19 Robert Dewar * a-ngelfu.adb: Remove ??? comment for inappropriate Inline_Always Add 2001 to copyright date ! ! * g-regpat.adb: Change pragma Inline_Always to Inline. There is no need to force universal inlining for these cases. ! 2001-12-19 Arnaud Charlet ! * s-taprob.adb: Minor clean ups so that this unit can be used in Ravenscar HI. ! * exp_ch7.adb: Allow use of secondary stack in HI mode. Disallow it when pragma Restrictions (No_Secondary_Stack) is specified. ! 2001-12-19 Vincent Celier ! * prj-tree.ads (Project_Node_Record): Add comments for components Pkg_Id and Case_Insensitive. ! 2001-12-19 Pascal Obry * g-socket.adb: Minor reformatting. Found while reading code. ! 2001-12-19 Robert Dewar * prj-tree.ads: Minor reformatting --- 1086,1167 ---- 2001-12-19 Robert Dewar * bindgen.adb: Minor reformatting ! * cstand.adb: Minor reformatting ! * fmap.adb: Minor reformatting Change name from Add for Add_To_File_Map (Add is much too generic) Change Path_Name_Of to Mapped_Path_Name Change File_Name_Of to Mapped_File_Name Fix copyright dates in header ! * fmap.ads: Change name from Add for Add_To_File_Map (Add is much too generic) Change Path_Name_Of to Mapped_Path_Name Change File_Name_Of to Mapped_File_Name Fix copyright dates in header ! * fname-uf.adb: Minor reformatting. New names of stuff in Fmap. Add use clause for Fmap. ! * make.adb: Minor reformatting ! * osint.adb: Minor reformatting. Change of names in Fmap. Add use clause for Fmap. ! * prj-env.adb: Minor reformatting ! * prj-env.ads: Minor reformatting ! ! * switch.adb: Minor reformatting. Do proper raise of Bad_Switch if ! error found (there were odd exceptions to this general rule in -gnatec/-gnatem processing) ! 2001-12-19 Olivier Hainque ! * raise.c (__gnat_eh_personality): Exception handling personality ! routine for Ada. Still in rough state, inspired from the C++ version and still containing a bunch of debugging artifacts. ! (parse_lsda_header, get_ttype_entry): Local (static) helpers, also inspired from the C++ library. ! ! * raise.c (eh_personality): Add comments. Part of work for the GCC 3 exception handling integration. ! 2001-12-19 Arnaud Charlet * Makefile.in: Remove use of 5smastop.adb which is obsolete. (HIE_SOURCES): Add s-secsta.ad{s,b}. (HIE_OBJS): Add s-fat*.o ! (RAVEN_SOURCES): Remove files that are no longer required. Add interrupt handling files. (RAVEN_MOD): Removed, no longer needed. ! 2001-12-19 Robert Dewar * a-ngelfu.adb: Remove ??? comment for inappropriate Inline_Always Add 2001 to copyright date ! ! * g-regpat.adb: Change pragma Inline_Always to Inline. There is no need to force universal inlining for these cases. ! 2001-12-19 Arnaud Charlet ! * s-taprob.adb: Minor clean ups so that this unit can be used in Ravenscar HI. ! * exp_ch7.adb: Allow use of secondary stack in HI mode. Disallow it when pragma Restrictions (No_Secondary_Stack) is specified. ! 2001-12-19 Vincent Celier ! * prj-tree.ads (Project_Node_Record): Add comments for components Pkg_Id and Case_Insensitive. ! 2001-12-19 Pascal Obry * g-socket.adb: Minor reformatting. Found while reading code. ! 2001-12-19 Robert Dewar * prj-tree.ads: Minor reformatting *************** *** 660,752 **** 2001-12-17 Ed Schonberg ! * sem_res.adb (Resolve_Selected_Component): do not generate a ! discriminant check if the selected component is a component of the argument of an initialization procedure. ! * trans.c (tree_transform, case of arithmetic operators): If result ! type is private, the gnu_type is the base type of the full view, given that the full view itself may be a subtype. ! 2001-12-17 Robert Dewar * sem_res.adb: Minor reformatting ! ! * trans.c (tree_transform, case N_Real_Literal): Add missing third ! parameter in call to Machine (unknown horrible effects from this omission). ! * urealp.h: Add definition of Round_Even for call to Machine Add third parameter for Machine ! 2001-12-17 Ed Schonberg ! * sem_warn.adb (Check_One_Unit): Suppress warnings completely on predefined units in No_Run_Time mode. ! 2001-12-17 Richard Kenner * misc.c (insn-codes.h): Now include. ! 2001-12-17 Olivier Hainque ! * a-except.adb: Preparation work for future integration of the GCC 3 exception handling mechanism (Notify_Handled_Exception, Notify_Unhandled_Exception): New routines to factorize previous code sequences and make them externally callable, e.g. for the Ada personality routine when the GCC 3 mechanism is used. (Propagate_Exception, Raise_Current_Excep, Raise_From_Signal_Handler): Use the new notification routines. ! 2001-12-17 Emmanuel Briot * prj-tree.ads (First_Choice_Of): Document the when others case ! 2001-12-17 Arnaud Charlet ! * bindgen.adb (Gen_Ada_Init_*): Set priority of environment task in HI-E mode, in order to support Ravenscar profile properly. ! ! * cstand.adb (Create_Standard): Duration is a 32 bit type in HI-E mode on 32 bits targets. ! 2001-12-17 Vincent Celier * fmap.adb: Initial version. ! * fmap.ads: Initial version. ! * fname-uf.adb (Get_File_Name): Use mapping if unit name mapped. If search is successfully done, add to mapping. ! * frontend.adb: Initialize the mapping if a -gnatem switch was used. ! * make.adb: (Gnatmake): Add new local variable Mapping_File_Name. Create mapping file when using project file(s). Delete mapping file before exiting. ! * opt.ads (Mapping_File_Name): New variable ! * osint.adb (Find_File): Use path name found in mapping, if any. ! * prj-env.adb (Create_Mapping_File): New procedure ! * prj-env.ads (Create_Mapping_File): New procedure. ! ! * switch.adb (Scan_Front_End_Switches): Add processing for -gnatem (Mapping_File) ! * usage.adb: Add entry for new switch -gnatem. ! * Makefile.in: Add dependencies for fmap.o. ! 2001-12-17 Ed Schonberg ! * sem_ch10.adb (Analyze_With_Clause): Retrieve proper entity when unit is a package instantiation rewritten as a package body. (Install_Withed_Unit): Undo previous change, now redundant. ! 2001-12-17 Gary Dismukes * layout.adb: --- 1172,1264 ---- 2001-12-17 Ed Schonberg ! * sem_res.adb (Resolve_Selected_Component): do not generate a ! discriminant check if the selected component is a component of the argument of an initialization procedure. ! * trans.c (tree_transform, case of arithmetic operators): If result ! type is private, the gnu_type is the base type of the full view, given that the full view itself may be a subtype. ! 2001-12-17 Robert Dewar * sem_res.adb: Minor reformatting ! ! * trans.c (tree_transform, case N_Real_Literal): Add missing third ! parameter in call to Machine (unknown horrible effects from this omission). ! * urealp.h: Add definition of Round_Even for call to Machine Add third parameter for Machine ! 2001-12-17 Ed Schonberg ! * sem_warn.adb (Check_One_Unit): Suppress warnings completely on predefined units in No_Run_Time mode. ! 2001-12-17 Richard Kenner * misc.c (insn-codes.h): Now include. ! 2001-12-17 Olivier Hainque ! * a-except.adb: Preparation work for future integration of the GCC 3 exception handling mechanism (Notify_Handled_Exception, Notify_Unhandled_Exception): New routines to factorize previous code sequences and make them externally callable, e.g. for the Ada personality routine when the GCC 3 mechanism is used. (Propagate_Exception, Raise_Current_Excep, Raise_From_Signal_Handler): Use the new notification routines. ! 2001-12-17 Emmanuel Briot * prj-tree.ads (First_Choice_Of): Document the when others case ! 2001-12-17 Arnaud Charlet ! * bindgen.adb (Gen_Ada_Init_*): Set priority of environment task in HI-E mode, in order to support Ravenscar profile properly. ! ! * cstand.adb (Create_Standard): Duration is a 32 bit type in HI-E mode on 32 bits targets. ! 2001-12-17 Vincent Celier * fmap.adb: Initial version. ! * fmap.ads: Initial version. ! * fname-uf.adb (Get_File_Name): Use mapping if unit name mapped. If search is successfully done, add to mapping. ! * frontend.adb: Initialize the mapping if a -gnatem switch was used. ! * make.adb: (Gnatmake): Add new local variable Mapping_File_Name. Create mapping file when using project file(s). Delete mapping file before exiting. ! * opt.ads (Mapping_File_Name): New variable ! * osint.adb (Find_File): Use path name found in mapping, if any. ! * prj-env.adb (Create_Mapping_File): New procedure ! * prj-env.ads (Create_Mapping_File): New procedure. ! ! * switch.adb (Scan_Front_End_Switches): Add processing for -gnatem (Mapping_File) ! * usage.adb: Add entry for new switch -gnatem. ! * Makefile.in: Add dependencies for fmap.o. ! 2001-12-17 Ed Schonberg ! * sem_ch10.adb (Analyze_With_Clause): Retrieve proper entity when unit is a package instantiation rewritten as a package body. (Install_Withed_Unit): Undo previous change, now redundant. ! 2001-12-17 Gary Dismukes * layout.adb: *************** *** 756,764 **** (Layout_Array_Type): Convert Len expression to Unsigned after calls to Compute_Length and Determine_Range. Above changes fix problem with length computation for supernull arrays ! where Max (Len, 0) wasn't getting applied due to the Unsigned conversion used by Compute_Length. ! 2001-12-17 Arnaud Charlet * rtsfind.ads: --- 1268,1276 ---- (Layout_Array_Type): Convert Len expression to Unsigned after calls to Compute_Length and Determine_Range. Above changes fix problem with length computation for supernull arrays ! where Max (Len, 0) wasn't getting applied due to the Unsigned conversion used by Compute_Length. ! 2001-12-17 Arnaud Charlet * rtsfind.ads: *************** *** 767,837 **** (OK_To_Use_In_Ravenscar_Mode): New table needed to implement Ravenscar in HI-E mode. Remove unused entity RE_Exception_Data. ! * rtsfind.adb (RTE): Allow Ravenscar Profile in HI mode. ! * rident.ads (No_Secondary_Stack): New restriction. 2001-12-17 Joel Brobecker ! * gnat_rm.texi: Fix minor typos. Found while reading the section regarding "Bit_Order Clauses" that was sent to a customer. Very interesting documentation! ! 2001-12-17 Robert Dewar ! * sem_case.adb (Choice_Image): Avoid creating improper character ! literal names by using the routine Set_Character_Literal_Name. This fixes bombs in certain error message cases. ! 2001-12-17 Arnaud Charlet * a-reatim.adb: Minor reformatting. ! 2001-12-17 Ed Schonberg ! * sem_ch12.adb (Validate_Derived_Type_Instance): Handle properly the ! case where the formal is an extension of another formal in the current unit or in a parent generic unit. ! 2001-12-17 Arnaud Charlet ! * s-tposen.adb: Update comments. Minor reformatting. Minor code clean up. ! * s-tarest.adb: Update comments. Minor code reorganization. ! 2001-12-17 Gary Dismukes ! * exp_attr.adb (Attribute_Tag): Suppress expansion of 'Tag when Java_VM. ! 2001-12-17 Robert Dewar * exp_attr.adb: Minor reformatting ! 2001-12-17 Ed Schonberg ! * sem_ch3.adb (Build_Derived_Private_Type): Refine check to handle derivations nested within a child unit: verify that the parent type is declared in an outer scope. ! 2001-12-17 Robert Dewar * sem_ch12.adb: Minor reformatting ! 2001-12-17 Ed Schonberg ! * sem_warn.adb (Check_One_Unit): In No_Run_Time mode, do not post ! warning if current unit is a predefined one, from which bodies may have been deleted. ! 2001-12-17 Robert Dewar * eval_fat.ads: Add comment that Round_Even is referenced in Ada code Fix header format. Add 2001 to copyright date. ! ! * exp_dbug.adb (Get_Encoded_Name): Fix out of bounds reference, which caused CE during compilation if checks were enabled. 2001-12-17 Vincent Celier --- 1279,1349 ---- (OK_To_Use_In_Ravenscar_Mode): New table needed to implement Ravenscar in HI-E mode. Remove unused entity RE_Exception_Data. ! * rtsfind.adb (RTE): Allow Ravenscar Profile in HI mode. ! * rident.ads (No_Secondary_Stack): New restriction. 2001-12-17 Joel Brobecker ! * gnat_rm.texi: Fix minor typos. Found while reading the section regarding "Bit_Order Clauses" that was sent to a customer. Very interesting documentation! ! 2001-12-17 Robert Dewar ! * sem_case.adb (Choice_Image): Avoid creating improper character ! literal names by using the routine Set_Character_Literal_Name. This fixes bombs in certain error message cases. ! 2001-12-17 Arnaud Charlet * a-reatim.adb: Minor reformatting. ! 2001-12-17 Ed Schonberg ! * sem_ch12.adb (Validate_Derived_Type_Instance): Handle properly the ! case where the formal is an extension of another formal in the current unit or in a parent generic unit. ! 2001-12-17 Arnaud Charlet ! * s-tposen.adb: Update comments. Minor reformatting. Minor code clean up. ! * s-tarest.adb: Update comments. Minor code reorganization. ! 2001-12-17 Gary Dismukes ! * exp_attr.adb (Attribute_Tag): Suppress expansion of 'Tag when Java_VM. ! 2001-12-17 Robert Dewar * exp_attr.adb: Minor reformatting ! 2001-12-17 Ed Schonberg ! * sem_ch3.adb (Build_Derived_Private_Type): Refine check to handle derivations nested within a child unit: verify that the parent type is declared in an outer scope. ! 2001-12-17 Robert Dewar * sem_ch12.adb: Minor reformatting ! 2001-12-17 Ed Schonberg ! * sem_warn.adb (Check_One_Unit): In No_Run_Time mode, do not post ! warning if current unit is a predefined one, from which bodies may have been deleted. ! 2001-12-17 Robert Dewar * eval_fat.ads: Add comment that Round_Even is referenced in Ada code Fix header format. Add 2001 to copyright date. ! ! * exp_dbug.adb (Get_Encoded_Name): Fix out of bounds reference, which caused CE during compilation if checks were enabled. 2001-12-17 Vincent Celier *************** *** 843,859 **** (Collect_Arguments_And_Compile): Use new function Switches_Of. When using a project file, test if there are any relative search path. Fail if there are any. ! (Gnatmake): Only add switches for the primary directory when not using ! a project file. When using a project file, change directory to the ! object directory of the main project file. When using a project file, ! test if there are any relative search path. Fail if there are any. ! When using a project file, fail if specified executable is relative ! path with directory information, and prepend executable, if not ! specified as an absolute path, with the exec directory. Make sure that only one -o switch is transmitted to the linker. ! * prj-attr.adb (Initialization_Data): Add project attribute Exec_Dir ! * prj-nmsc.adb: (Ada_Check): Get Spec_Suffix_Loc and Impl_Suffix_Loc, when using a non standard naming scheme. --- 1355,1371 ---- (Collect_Arguments_And_Compile): Use new function Switches_Of. When using a project file, test if there are any relative search path. Fail if there are any. ! (Gnatmake): Only add switches for the primary directory when not using ! a project file. When using a project file, change directory to the ! object directory of the main project file. When using a project file, ! test if there are any relative search path. Fail if there are any. ! When using a project file, fail if specified executable is relative ! path with directory information, and prepend executable, if not ! specified as an absolute path, with the exec directory. Make sure that only one -o switch is transmitted to the linker. ! * prj-attr.adb (Initialization_Data): Add project attribute Exec_Dir ! * prj-nmsc.adb: (Ada_Check): Get Spec_Suffix_Loc and Impl_Suffix_Loc, when using a non standard naming scheme. *************** *** 861,941 **** do not raise exceptions. (Is_Illegal_Append): Return True if there is no dot in the suffix. (Language_Independent_Check): Check the exec directory. ! * prj.adb (Project_Empty): Add new component Exec_Directory ! * prj.ads: (Default_Ada_Spec_Suffix, Default_Ada_Impl_Suffix): Add defaults. (Project_Data): Add component Exec_Directory ! * snames.adb: Updated to match snames.ads revision 1.215 ! * snames.ads: Added Exec_Dir ! 2001-12-17 Robert Dewar * make.adb: Minor reformatting ! * prj-nmsc.adb: Minor reformatting ! * snames.adb: Updated to match snames.ads ! * snames.ads: Alphebetize entries for project file 2001-12-17 Ed Schonberg ! * trans.c (process_freeze_entity): Do nothing if the entity is a subprogram that was already elaborated. ! 2001-12-17 Richard Kenner ! ! * decl.c (gnat_to_gnu_entity, object): Do not back-annotate Alignment and Esize if object is referenced via pointer. 2001-12-17 Ed Schonberg ! * sem_ch3.adb (Analyze_Variant_Part): check that type of discriminant is discrete before analyzing choices. ! 2001-12-17 Joel Brobecker ! * bindgen.adb (Gen_Output_File_Ada): Generate a new C-like string ! containing the name of the Ada Main Program. This string is mainly intended for the debugger. (Gen_Output_File_C): Do the equivalent change when generating a C file. ! 2001-12-17 Robert Dewar * ali.adb: Set new Dummy_Entry field in dependency entry ! * ali.ads: Add Dummy_Entry field to source dependency table ! * bcheck.adb (Check_Consistency): Ignore dummy D lines ! * lib-writ.adb (Writ_ALI): Write dummy D lines for missing source files ! * lib-writ.ads: Document dummy D lines for missing files. ! * types.ads: (Dummy_Time_Stamp): New value for non-existant files 2001-12-17 Robert Dewar * ali.adb: Type reference does not reset current file. ! * ali.adb: Recognize and scan renaming reference ! * ali.ads: Add spec for storing renaming references. ! * lib-xref.ads: Add documentation for handling of renaming references ! * lib-xref.adb: Implement output of renaming reference. ! * checks.adb: (Determine_Range): Document local variables (Determine_Range): Make sure Hbound is initialized. It looks as though there could be a real problem here with an uninitialized reference to Hbound, but no actual example of failure has been found. ! 2001-12-17 Laurent Pautet * g-socket.ads: --- 1373,1453 ---- do not raise exceptions. (Is_Illegal_Append): Return True if there is no dot in the suffix. (Language_Independent_Check): Check the exec directory. ! * prj.adb (Project_Empty): Add new component Exec_Directory ! * prj.ads: (Default_Ada_Spec_Suffix, Default_Ada_Impl_Suffix): Add defaults. (Project_Data): Add component Exec_Directory ! * snames.adb: Updated to match snames.ads revision 1.215 ! * snames.ads: Added Exec_Dir ! 2001-12-17 Robert Dewar * make.adb: Minor reformatting ! * prj-nmsc.adb: Minor reformatting ! * snames.adb: Updated to match snames.ads ! * snames.ads: Alphebetize entries for project file 2001-12-17 Ed Schonberg ! * trans.c (process_freeze_entity): Do nothing if the entity is a subprogram that was already elaborated. ! 2001-12-17 Richard Kenner ! ! * decl.c (gnat_to_gnu_entity, object): Do not back-annotate Alignment and Esize if object is referenced via pointer. 2001-12-17 Ed Schonberg ! * sem_ch3.adb (Analyze_Variant_Part): check that type of discriminant is discrete before analyzing choices. ! 2001-12-17 Joel Brobecker ! * bindgen.adb (Gen_Output_File_Ada): Generate a new C-like string ! containing the name of the Ada Main Program. This string is mainly intended for the debugger. (Gen_Output_File_C): Do the equivalent change when generating a C file. ! 2001-12-17 Robert Dewar * ali.adb: Set new Dummy_Entry field in dependency entry ! * ali.ads: Add Dummy_Entry field to source dependency table ! * bcheck.adb (Check_Consistency): Ignore dummy D lines ! * lib-writ.adb (Writ_ALI): Write dummy D lines for missing source files ! * lib-writ.ads: Document dummy D lines for missing files. ! * types.ads: (Dummy_Time_Stamp): New value for non-existant files 2001-12-17 Robert Dewar * ali.adb: Type reference does not reset current file. ! * ali.adb: Recognize and scan renaming reference ! * ali.ads: Add spec for storing renaming references. ! * lib-xref.ads: Add documentation for handling of renaming references ! * lib-xref.adb: Implement output of renaming reference. ! * checks.adb: (Determine_Range): Document local variables (Determine_Range): Make sure Hbound is initialized. It looks as though there could be a real problem here with an uninitialized reference to Hbound, but no actual example of failure has been found. ! 2001-12-17 Laurent Pautet * g-socket.ads: *************** *** 948,959 **** 2001-12-17 Robert Dewar ! * frontend.adb: Move call to Check_Unused_Withs from Frontend, so that it happens before modification of Sloc values for -gnatD. ! ! * gnat1drv.adb: Move call to Check_Unused_Withs to Frontend, so that it happens before modification of Sloc values for -gnatD. ! * switch.adb: Minor reformatting 2001-12-15 Richard Henderson --- 1460,1471 ---- 2001-12-17 Robert Dewar ! * frontend.adb: Move call to Check_Unused_Withs from Frontend, so that it happens before modification of Sloc values for -gnatD. ! ! * gnat1drv.adb: Move call to Check_Unused_Withs to Frontend, so that it happens before modification of Sloc values for -gnatD. ! * switch.adb: Minor reformatting 2001-12-15 Richard Henderson *************** *** 990,1058 **** 2001-12-14 Vincent Celier ! * osint.adb(Create_Debug_File): When an object file is specified, put the .dg file in the same directory as the object file. ! 2001-12-14 Robert Dewar * osint.adb: Minor reformatting ! ! * lib-xref.adb (Output_Instantiation): New procedure to generate instantiation references. ! * lib-xref.ads: Add documentation of handling of generic references. ! ! * ali.adb (Read_Instantiation_Ref): New procedure to read instantiation references ! * ali.ads: Add spec for storing instantiation references ! * bindusg.adb: Minor reformatting ! * switch.adb: Add entry for Latin-5 (Cyrillic ISO-8859-5) ! * usage.adb: Add entry for Latin-5 (Cyrillic ISO-8859-5) ! * gnatcmd.adb: Add entry for Latin-5 (Cyrillic ISO-8859-5) ! * csets.adb: Add entry for Latin-5 (Cyrillic ISO-8859-5) ! * csets.ads: Fix header format Add 2001 to copyright date Add entry for Latin-5 (Cyrillic ISO-8859-5) ! 2001-12-14 Matt Gingell ! * adaint.c: mktemp is a macro on Lynx and can not be used as an expression. ! 2001-12-14 Richard Kenner ! * misc.c (gnat_expand_constant): Do not strip UNCHECKED_CONVERT_EXPR if operand is CONSTRUCTOR. ! 2001-12-14 Ed Schonberg ! * trans.c (tree_transform, case N_Assignment_Statement): Set lineno ! before emiting check on right-hand side, so that exception information is correct. 2001-12-14 Richard Kenner ! ! * utils.c (create_var_decl): Throw away initializing expression if just annotating types and non-constant. ! 2001-12-14 Vincent Celier * prj-nmsc.adb: (Ada_Check): Migrate drom Ada_Default_... to Default_Ada_... ! ! * prj.adb: (Ada_Default_Spec_Suffix, Ada_Default_Impl_Suffix): Remove functions. (Default_Ada_Spec_Suffix, Default_Ada_Impl_Suffix): Move to spec. ! ! * prj.ads: (Ada_Default_Spec_Suffix, Ada_Default_Impl_Suffix): Remove functions. (Default_Ada_Spec_Suffix, Default_Ada_Impl_Suffix): Move from body. --- 1502,1570 ---- 2001-12-14 Vincent Celier ! * osint.adb(Create_Debug_File): When an object file is specified, put the .dg file in the same directory as the object file. ! 2001-12-14 Robert Dewar * osint.adb: Minor reformatting ! ! * lib-xref.adb (Output_Instantiation): New procedure to generate instantiation references. ! * lib-xref.ads: Add documentation of handling of generic references. ! ! * ali.adb (Read_Instantiation_Ref): New procedure to read instantiation references ! * ali.ads: Add spec for storing instantiation references ! * bindusg.adb: Minor reformatting ! * switch.adb: Add entry for Latin-5 (Cyrillic ISO-8859-5) ! * usage.adb: Add entry for Latin-5 (Cyrillic ISO-8859-5) ! * gnatcmd.adb: Add entry for Latin-5 (Cyrillic ISO-8859-5) ! * csets.adb: Add entry for Latin-5 (Cyrillic ISO-8859-5) ! * csets.ads: Fix header format Add 2001 to copyright date Add entry for Latin-5 (Cyrillic ISO-8859-5) ! 2001-12-14 Matt Gingell ! * adaint.c: mktemp is a macro on Lynx and can not be used as an expression. ! 2001-12-14 Richard Kenner ! * misc.c (gnat_expand_constant): Do not strip UNCHECKED_CONVERT_EXPR if operand is CONSTRUCTOR. ! 2001-12-14 Ed Schonberg ! * trans.c (tree_transform, case N_Assignment_Statement): Set lineno ! before emiting check on right-hand side, so that exception information is correct. 2001-12-14 Richard Kenner ! ! * utils.c (create_var_decl): Throw away initializing expression if just annotating types and non-constant. ! 2001-12-14 Vincent Celier * prj-nmsc.adb: (Ada_Check): Migrate drom Ada_Default_... to Default_Ada_... ! ! * prj.adb: (Ada_Default_Spec_Suffix, Ada_Default_Impl_Suffix): Remove functions. (Default_Ada_Spec_Suffix, Default_Ada_Impl_Suffix): Move to spec. ! ! * prj.ads: (Ada_Default_Spec_Suffix, Ada_Default_Impl_Suffix): Remove functions. (Default_Ada_Spec_Suffix, Default_Ada_Impl_Suffix): Move from body. *************** *** 1086,1263 **** 2001-12-12 Ed Schonberg ! * sem_ch12.adb (Save_Entity_Descendant): Use syntactic field names on known node types, rather than untyped fields. Further cleanups. ! 2001-12-12 Robert Dewar * sem_ch12.adb: (Save_Entity_Descendant): Minor comment update. (Copy_Generic_Node): Deal with incorrect reference to Associated_Node ! of an N_Attribute_Reference node. As per note below, this does not eliminate need for Associated_Node in attribute ref nodes. ! (Associated_Node): Documentation explicitly mentions attribute reference nodes, since this field is used in such nodes. ! * sem_ch12.adb (Associated_Node): Minor documentation cleanup. 2001-12-12 Robert Dewar * s-stalib.adb: Add more comments on with statements being needed ! * par-ch12.adb: Minor reformatting ! * prj-dect.ads: Fix copyright header ! ! * s-arit64.adb (Multiply_With_Ovflo_Check): Fix case where both inputs fit in 32 bits, but the result still overflows. ! * s-fatgen.ads: Minor comment improvement ! 2001-12-12 Ed Schonberg ! * sem_ch4.adb (Analyze_Selected_Component): If the prefix is of a ! formal derived type, look for an inherited component from the full view of the parent, if any. ! 2001-12-12 Robert Dewar * checks.ads (Apply_Alignment_Check): New procedure. ! ! * exp_ch13.adb (Expand_N_Freeze_Entity): Generate dynamic check to ! ensure that the alignment of objects with address clauses is appropriate, and raise PE if not. ! * exp_util.ads (Must_Be_Aligned): Removed, replaced by Exp_Pakd.Known_Aligned_Enough ! * mdllfile.ads: Minor reformatting * mlib-fil.ads: Minor reformatting ! 2001-12-12 Ed Schonberg ! * exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Extend previous ! fix to any component reference if enclosing record has non-standard representation. ! 2001-12-12 Vincent Celier ! * g-dirope.ads (Find, Wildcard_Iterator): Moved to child package Iteration ! 2001-12-12 Ed Schonberg ! * freeze.ads: Make Freeze_Fixed_Point_Type visible, for use in sem_attr. ! 2001-12-12 Robert Dewar * impunit.adb: Add entry for GNAT.Directory_Operations.Iteration ! 2001-12-12 Emmanuel Briot * g-regexp.adb: Remove all debug code, since it isn't required anymore, and it adds dependencies to system.io. ! 2001-12-12 Pascal Obry ! * g-dirope.adb (Expand_Path.Var): Correctly detect end of variable name. 2001-12-11 Ed Schonberg * sem_ch10.adb (Install_Withed_Unit): If the unit is a generic instance ! that is the parent of other generics, the instance body replaces the ! instance node. Retrieve the instance of the spec, which is the one that is visible in clients and within the body. 2001-12-11 Vincent Celier * gnatmain.adb: Initial version. ! * gnatmain.ads: Initial version. ! * prj-attr.adb (Initialisation_Data): Add package Gnatstub. ! * snames.adb: Updated to match snames.ads. ! * snames.ads: Added Gnatstub. ! 2001-12-11 Vincent Celier ! * prj-attr.adb (Initialization_Data): Change name from Initialisation_Data. ! 2001-12-11 Emmanuel Briot * g-regpat.adb (Parse_Literal): Properly handle simple operators ?, + and * applied to backslashed expressions like \r. ! 2001-12-11 Vasiliy Fofanov ! * g-os_lib.ads: String_List type added, Argument_List type is now subtype of String_List. ! 2001-12-11 Robert Dewar * g-os_lib.ads: Change copyright to FSF Add comments for String_List type ! 2001-12-11 Vincent Celier ! * g-dirope.adb (Expand_Path): Fix bug. (wrong length when adding a string to the buffer). 2001-12-11 Ed Schonberg * freeze.adb: Make Freeze_Fixed_Point_Type visible, for use in sem_attr. ! * sem_attr.adb: Simplify previous fix for Address. ! (Set_Bounds): If prefix is a non-frozen fixed-point type, freeze now, ! to avoid anomalies where the bound of the type appears to raise constraint error. 2001-12-11 Robert Dewar ! * lib-xref.adb (Output_Refs): Make sure pointers are always properly handled. ! 2001-12-11 Ed Schonberg ! * sem_ch12.adb (Analyze_Subprogram_Instantiation): Check for a renamed unit before checking for recursive instantiations. ! 2001-12-11 Emmanuel Briot * prj.ads: Add comments for some of the fields. 2001-12-11 Robert Dewar ! * lib-xref.adb (Output_Refs): Don't output type references outside the main unit if they are not otherwise referenced. ! 2001-12-11 Ed Schonberg ! * sem_attr.adb (Analyze_attribute, case Address and Size): Simplify code and diagnose additional illegal uses ! ! * sem_util.adb (Is_Object_Reference): An indexed component is an object only if the prefix is. ! 2001-12-11 Vincent Celier * g-diopit.adb: Initial version. ! * g-diopit.ads: Initial version. ! * g-dirope.adb: (Expand_Path): Avoid use of Unbounded_String (Find, Wildcard_Iterator): Moved to child package Iteration ! * Makefile.in: Added g-diopit.o to GNATRTL_NONTASKING_OBJS ! 2001-12-11 Robert Dewar * sem_attr.adb: Minor reformatting --- 1598,1775 ---- 2001-12-12 Ed Schonberg ! * sem_ch12.adb (Save_Entity_Descendant): Use syntactic field names on known node types, rather than untyped fields. Further cleanups. ! 2001-12-12 Robert Dewar * sem_ch12.adb: (Save_Entity_Descendant): Minor comment update. (Copy_Generic_Node): Deal with incorrect reference to Associated_Node ! of an N_Attribute_Reference node. As per note below, this does not eliminate need for Associated_Node in attribute ref nodes. ! (Associated_Node): Documentation explicitly mentions attribute reference nodes, since this field is used in such nodes. ! * sem_ch12.adb (Associated_Node): Minor documentation cleanup. 2001-12-12 Robert Dewar * s-stalib.adb: Add more comments on with statements being needed ! * par-ch12.adb: Minor reformatting ! * prj-dect.ads: Fix copyright header ! ! * s-arit64.adb (Multiply_With_Ovflo_Check): Fix case where both inputs fit in 32 bits, but the result still overflows. ! * s-fatgen.ads: Minor comment improvement ! 2001-12-12 Ed Schonberg ! * sem_ch4.adb (Analyze_Selected_Component): If the prefix is of a ! formal derived type, look for an inherited component from the full view of the parent, if any. ! 2001-12-12 Robert Dewar * checks.ads (Apply_Alignment_Check): New procedure. ! ! * exp_ch13.adb (Expand_N_Freeze_Entity): Generate dynamic check to ! ensure that the alignment of objects with address clauses is appropriate, and raise PE if not. ! * exp_util.ads (Must_Be_Aligned): Removed, replaced by Exp_Pakd.Known_Aligned_Enough ! * mdllfile.ads: Minor reformatting * mlib-fil.ads: Minor reformatting ! 2001-12-12 Ed Schonberg ! * exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Extend previous ! fix to any component reference if enclosing record has non-standard representation. ! 2001-12-12 Vincent Celier ! * g-dirope.ads (Find, Wildcard_Iterator): Moved to child package Iteration ! 2001-12-12 Ed Schonberg ! * freeze.ads: Make Freeze_Fixed_Point_Type visible, for use in sem_attr. ! 2001-12-12 Robert Dewar * impunit.adb: Add entry for GNAT.Directory_Operations.Iteration ! 2001-12-12 Emmanuel Briot * g-regexp.adb: Remove all debug code, since it isn't required anymore, and it adds dependencies to system.io. ! 2001-12-12 Pascal Obry ! * g-dirope.adb (Expand_Path.Var): Correctly detect end of variable name. 2001-12-11 Ed Schonberg * sem_ch10.adb (Install_Withed_Unit): If the unit is a generic instance ! that is the parent of other generics, the instance body replaces the ! instance node. Retrieve the instance of the spec, which is the one that is visible in clients and within the body. 2001-12-11 Vincent Celier * gnatmain.adb: Initial version. ! * gnatmain.ads: Initial version. ! * prj-attr.adb (Initialisation_Data): Add package Gnatstub. ! * snames.adb: Updated to match snames.ads. ! * snames.ads: Added Gnatstub. ! 2001-12-11 Vincent Celier ! * prj-attr.adb (Initialization_Data): Change name from Initialisation_Data. ! 2001-12-11 Emmanuel Briot * g-regpat.adb (Parse_Literal): Properly handle simple operators ?, + and * applied to backslashed expressions like \r. ! 2001-12-11 Vasiliy Fofanov ! * g-os_lib.ads: String_List type added, Argument_List type is now subtype of String_List. ! 2001-12-11 Robert Dewar * g-os_lib.ads: Change copyright to FSF Add comments for String_List type ! 2001-12-11 Vincent Celier ! * g-dirope.adb (Expand_Path): Fix bug. (wrong length when adding a string to the buffer). 2001-12-11 Ed Schonberg * freeze.adb: Make Freeze_Fixed_Point_Type visible, for use in sem_attr. ! * sem_attr.adb: Simplify previous fix for Address. ! (Set_Bounds): If prefix is a non-frozen fixed-point type, freeze now, ! to avoid anomalies where the bound of the type appears to raise constraint error. 2001-12-11 Robert Dewar ! * lib-xref.adb (Output_Refs): Make sure pointers are always properly handled. ! 2001-12-11 Ed Schonberg ! * sem_ch12.adb (Analyze_Subprogram_Instantiation): Check for a renamed unit before checking for recursive instantiations. ! 2001-12-11 Emmanuel Briot * prj.ads: Add comments for some of the fields. 2001-12-11 Robert Dewar ! * lib-xref.adb (Output_Refs): Don't output type references outside the main unit if they are not otherwise referenced. ! 2001-12-11 Ed Schonberg ! * sem_attr.adb (Analyze_attribute, case Address and Size): Simplify code and diagnose additional illegal uses ! ! * sem_util.adb (Is_Object_Reference): An indexed component is an object only if the prefix is. ! 2001-12-11 Vincent Celier * g-diopit.adb: Initial version. ! * g-diopit.ads: Initial version. ! * g-dirope.adb: (Expand_Path): Avoid use of Unbounded_String (Find, Wildcard_Iterator): Moved to child package Iteration ! * Makefile.in: Added g-diopit.o to GNATRTL_NONTASKING_OBJS ! 2001-12-11 Robert Dewar * sem_attr.adb: Minor reformatting *************** *** 1265,1307 **** 2001-12-11 Ed Schonberg * sem_ch3.adb: Clarify some ???. ! 2001-12-11 Robert Dewar ! * exp_util.adb (Must_Be_Aligned): Removed, replaced by Exp_Pakd.Known_Aligned_Enough ! ! * sem_ch13.adb (Check_Address_Alignment): Removed, extended version is moved to Exp_Ch13. 2001-12-11 Robert Dewar * einfo.ads: Minor reformatting ! * exp_ch5.adb: Add comment for previous.change ! * ali.adb: New interface for extended typeref stuff. ! * ali.ads: New interface for typeref stuff. ! * checks.adb (Apply_Alignment_Check): New procedure. ! * debug.adb: Add -gnatdM for modified ALI output ! * exp_pakd.adb (Known_Aligned_Enough): Replaces Known_Aligned_Enough. ! ! * lib-xref.adb: Extend generation of <..> notation to cover ! subtype/object types. Note that this is a complete rewrite, ! getting rid of the very nasty quadratic algorithm previously used for derived type output. ! ! * lib-xref.ads: Extend description of <..> notation to cover ! subtype/object types. Uses {..} for these other cases. Also use (..) for pointer types. ! * sem_util.adb (Check_Potentially_Blocking_Operation): Slight cleanup. ! ! * exp_pakd.adb: Minor reformatting. Note that prevous RH should say: (Known_Aligned_Enough): Replaces Must_Be_Aligned. 2001-12-11 Vincent Celier --- 1777,1819 ---- 2001-12-11 Ed Schonberg * sem_ch3.adb: Clarify some ???. ! 2001-12-11 Robert Dewar ! * exp_util.adb (Must_Be_Aligned): Removed, replaced by Exp_Pakd.Known_Aligned_Enough ! ! * sem_ch13.adb (Check_Address_Alignment): Removed, extended version is moved to Exp_Ch13. 2001-12-11 Robert Dewar * einfo.ads: Minor reformatting ! * exp_ch5.adb: Add comment for previous.change ! * ali.adb: New interface for extended typeref stuff. ! * ali.ads: New interface for typeref stuff. ! * checks.adb (Apply_Alignment_Check): New procedure. ! * debug.adb: Add -gnatdM for modified ALI output ! * exp_pakd.adb (Known_Aligned_Enough): Replaces Known_Aligned_Enough. ! ! * lib-xref.adb: Extend generation of <..> notation to cover ! subtype/object types. Note that this is a complete rewrite, ! getting rid of the very nasty quadratic algorithm previously used for derived type output. ! ! * lib-xref.ads: Extend description of <..> notation to cover ! subtype/object types. Uses {..} for these other cases. Also use (..) for pointer types. ! * sem_util.adb (Check_Potentially_Blocking_Operation): Slight cleanup. ! ! * exp_pakd.adb: Minor reformatting. Note that prevous RH should say: (Known_Aligned_Enough): Replaces Must_Be_Aligned. 2001-12-11 Vincent Celier *************** *** 1310,1354 **** Changed /COMPILE_ONLY to /ACTIONS=COMPILE Changed /BIND_ONLY to /ACTIONS=BIND Changed /LINK_ONLY to /ACTIONS=LINK ! 2001-12-11 Ed Schonberg * sem_ch8.adb (Find_Selected_Component): improved search for a candidate package in case of error. ! * sem_ch12.adb (Inline_Instance_Body): place head of use_clause chain back on scope stack before reinstalling use clauses. ! * exp_ch5.adb (Expand_N_If_Statement): if Constant_Condition_Warnings is enabled, do not kill the code for the condition, to preserve warning. 2001-12-11 Robert Dewar ! * checks.adb (Insert_Valid_Check): Apply validity check to expression of conversion, not to result of conversion. 2001-12-11 Ed Schonberg ! ! * sem_ch3.adb (Build_Derived_Record_Type): set Controlled flag ! before freezing parent. If the declarations are mutually recursive, ! an access to the current record type may be frozen before the derivation is complete. 2001-12-05 Vincent Celier ! * gnatcmd.adb: (MAKE): Add new translations: -b /BIND_ONLY, -c /COMPILE_ONLY, -l /LINK_ONLY ! * opt.ads: (Bind_Only): New Flag (Link_Only): New flag ! ! * switch.adb (Scan_Make_Switches): Add processing for -b (Bind_Only) and -l (Link_Only) ! * makeusg.adb: Add new switches -b and -l. Update Copyright notice. ! * make.adb: (Do_Compile_Step, Do_Bind_Step, Do_Link_Step): New flags. (Gnatmake): Set the step flags. Only perform a step if the --- 1822,1866 ---- Changed /COMPILE_ONLY to /ACTIONS=COMPILE Changed /BIND_ONLY to /ACTIONS=BIND Changed /LINK_ONLY to /ACTIONS=LINK ! 2001-12-11 Ed Schonberg * sem_ch8.adb (Find_Selected_Component): improved search for a candidate package in case of error. ! * sem_ch12.adb (Inline_Instance_Body): place head of use_clause chain back on scope stack before reinstalling use clauses. ! * exp_ch5.adb (Expand_N_If_Statement): if Constant_Condition_Warnings is enabled, do not kill the code for the condition, to preserve warning. 2001-12-11 Robert Dewar ! * checks.adb (Insert_Valid_Check): Apply validity check to expression of conversion, not to result of conversion. 2001-12-11 Ed Schonberg ! ! * sem_ch3.adb (Build_Derived_Record_Type): set Controlled flag ! before freezing parent. If the declarations are mutually recursive, ! an access to the current record type may be frozen before the derivation is complete. 2001-12-05 Vincent Celier ! * gnatcmd.adb: (MAKE): Add new translations: -b /BIND_ONLY, -c /COMPILE_ONLY, -l /LINK_ONLY ! * opt.ads: (Bind_Only): New Flag (Link_Only): New flag ! ! * switch.adb (Scan_Make_Switches): Add processing for -b (Bind_Only) and -l (Link_Only) ! * makeusg.adb: Add new switches -b and -l. Update Copyright notice. ! * make.adb: (Do_Compile_Step, Do_Bind_Step, Do_Link_Step): New flags. (Gnatmake): Set the step flags. Only perform a step if the *************** *** 1358,1385 **** 2001-12-05 Ed Schonberg ! * sem_eval.adb (Eval_Concatenation): If left operand is a null string, get bounds from right operand. ! * sem_eval.adb: Minor reformatting ! ! * exp_util.adb (Make_Literal_Range): use bound of literal rather than Index'First, its lower bound may be different from 1. ! ! * exp_util.adb: Undo earlier change, fixes ACVC regressions C48009B and C48009J ! 2001-12-05 Vincent Celier * prj-nmsc.adb Minor reformatting ! ! * prj-nmsc.adb (Language_Independent_Check): Reset Library flag if set and libraries are not supported. ! 2001-12-05 Ed Schonberg ! * sem_ch3.adb (Build_Derived_Private_Type): set Public status of ! private view explicitly, so the back-end can treat as a global when appropriate. 2001-12-05 Ed Schonberg --- 1870,1897 ---- 2001-12-05 Ed Schonberg ! * sem_eval.adb (Eval_Concatenation): If left operand is a null string, get bounds from right operand. ! * sem_eval.adb: Minor reformatting ! ! * exp_util.adb (Make_Literal_Range): use bound of literal rather than Index'First, its lower bound may be different from 1. ! ! * exp_util.adb: Undo earlier change, fixes ACVC regressions C48009B and C48009J ! 2001-12-05 Vincent Celier * prj-nmsc.adb Minor reformatting ! ! * prj-nmsc.adb (Language_Independent_Check): Reset Library flag if set and libraries are not supported. ! 2001-12-05 Ed Schonberg ! * sem_ch3.adb (Build_Derived_Private_Type): set Public status of ! private view explicitly, so the back-end can treat as a global when appropriate. 2001-12-05 Ed Schonberg *************** *** 1388,1404 **** unit, always replace instance node with new body, for ASIS use. 2001-12-05 Vincent Celier ! ! * prj-nmsc.adb (Language_Independent_Check): Issue a warning if ! libraries are not supported and both attributes Library_Name and Library_Dir are specified. ! ! * prj-proc.adb (Expression): Set location of Result to location of first term. ! * Makefile.in: Add mlib.o, mlib-fil.o, mlib-tgt and mlib-utl to GNATLS. (prj-nmsc is now importing MLib.Tgt) ! * prj-proc.adb: Put the change indicated above that was forgotten. 2001-12-05 Robert Dewar --- 1900,1916 ---- unit, always replace instance node with new body, for ASIS use. 2001-12-05 Vincent Celier ! ! * prj-nmsc.adb (Language_Independent_Check): Issue a warning if ! libraries are not supported and both attributes Library_Name and Library_Dir are specified. ! ! * prj-proc.adb (Expression): Set location of Result to location of first term. ! * Makefile.in: Add mlib.o, mlib-fil.o, mlib-tgt and mlib-utl to GNATLS. (prj-nmsc is now importing MLib.Tgt) ! * prj-proc.adb: Put the change indicated above that was forgotten. 2001-12-05 Robert Dewar *************** *** 1409,1442 **** * sem_ch3.adb (Build_Derived_Concurrent_Type): If derivation imposes a constraint, introduce explicit subtype declaration and derive from it. ! * sem_ch3.adb: Minor reformatting 2001-12-05 Robert Dewar ! * checks.adb (Determine_Range): Increase cache size for checks. Minor reformatting ! * exp_ch6.adb: Minor reformatting (Expand_N_Subprogram_Body): Reset Is_Pure for any subprogram that has a parameter whose root type is System.Address, since treating such subprograms as pure in the code generator is almost surely a mistake that will lead to unexpected results. ! ! * exp_util.adb (Remove_Side_Effects): Clean up old ??? comment and change handling of conversions. ! * g-regexp.adb: Use System.IO instead of Ada.Text_IO. 2001-12-05 Ed Schonberg ! * sem_ch3.adb (Analyze_Object_Declaration): If expression is an ! aggregate with static wrong size, attach generated Raise node to declaration. 2001-12-05 Robert Dewar ! * sem_attr.adb (Analyze_Attribute): Defend against bad Val attribute. Fixes compilation abandoned bomb in B24009B. 2001-12-05 Ed Schonberg --- 1921,1954 ---- * sem_ch3.adb (Build_Derived_Concurrent_Type): If derivation imposes a constraint, introduce explicit subtype declaration and derive from it. ! * sem_ch3.adb: Minor reformatting 2001-12-05 Robert Dewar ! * checks.adb (Determine_Range): Increase cache size for checks. Minor reformatting ! * exp_ch6.adb: Minor reformatting (Expand_N_Subprogram_Body): Reset Is_Pure for any subprogram that has a parameter whose root type is System.Address, since treating such subprograms as pure in the code generator is almost surely a mistake that will lead to unexpected results. ! ! * exp_util.adb (Remove_Side_Effects): Clean up old ??? comment and change handling of conversions. ! * g-regexp.adb: Use System.IO instead of Ada.Text_IO. 2001-12-05 Ed Schonberg ! * sem_ch3.adb (Analyze_Object_Declaration): If expression is an ! aggregate with static wrong size, attach generated Raise node to declaration. 2001-12-05 Robert Dewar ! * sem_attr.adb (Analyze_Attribute): Defend against bad Val attribute. Fixes compilation abandoned bomb in B24009B. 2001-12-05 Ed Schonberg *************** *** 1450,1460 **** * prj-dect.ads: Add ??? comment Add 2001 to copyright notice (was not done in after all) ! * prj-part.adb: Minor reformatting. Reword one awkward error message. ! * prj.ads: Minor reformatting throughout, and add some ??? comments ! * snames.ads: Minor reformatting 2001-12-05 Geert Bosch --- 1962,1972 ---- * prj-dect.ads: Add ??? comment Add 2001 to copyright notice (was not done in after all) ! * prj-part.adb: Minor reformatting. Reword one awkward error message. ! * prj.ads: Minor reformatting throughout, and add some ??? comments ! * snames.ads: Minor reformatting 2001-12-05 Geert Bosch *************** *** 1464,1493 **** 2001-12-05 Vincent Celier * prj-dect.adb (Parse): Rename parameter Modifying to Extends. ! * prj-dect.ads (Parse): Rename parameter Modifying to Extends. ! * prj-env.adb: Minor comment changes (modifying -> extends). ! * prj-nmsc.adb: Minor comment changes (modifying -> extends). ! ! * prj-part.adb (Parse_Single_Project): Change Tok_Modifying to Tok_Extends. ! * prj.adb (Initialize): Change Modifying to Extends. ! * scans.ads (Token_Type): Change Tok_Modifying to Tok_Extends. ! * prj.ads: Minor comment change (Modifying -> extending). ! * snames.ads: Change modifying to extends. 2001-12-05 Robert Dewar ! * sem_warn.adb: Remove stuff for conditionals, we are not going to do this after all. ! ! * sem_warn.ads: Remove stuff for conditionals, we are not going to do this after all. Add 2001 to copyright notice 2001-12-04 Geert Bosch --- 1976,2005 ---- 2001-12-05 Vincent Celier * prj-dect.adb (Parse): Rename parameter Modifying to Extends. ! * prj-dect.ads (Parse): Rename parameter Modifying to Extends. ! * prj-env.adb: Minor comment changes (modifying -> extends). ! * prj-nmsc.adb: Minor comment changes (modifying -> extends). ! ! * prj-part.adb (Parse_Single_Project): Change Tok_Modifying to Tok_Extends. ! * prj.adb (Initialize): Change Modifying to Extends. ! * scans.ads (Token_Type): Change Tok_Modifying to Tok_Extends. ! * prj.ads: Minor comment change (Modifying -> extending). ! * snames.ads: Change modifying to extends. 2001-12-05 Robert Dewar ! * sem_warn.adb: Remove stuff for conditionals, we are not going to do this after all. ! ! * sem_warn.ads: Remove stuff for conditionals, we are not going to do this after all. Add 2001 to copyright notice 2001-12-04 Geert Bosch *************** *** 1496,1505 **** 2001-12-04 Robert Dewar ! * errout.adb (Error_Msg): Ignore attempt to put error msg at junk ! location if we already have errors. Stops some cases of cascaded errors. ! * errout.adb: Improve comment. 2001-12-04 Robert Dewar --- 2008,2017 ---- 2001-12-04 Robert Dewar ! * errout.adb (Error_Msg): Ignore attempt to put error msg at junk ! location if we already have errors. Stops some cases of cascaded errors. ! * errout.adb: Improve comment. 2001-12-04 Robert Dewar *************** *** 1507,1514 **** * sem_ch12.adb: (Analyze_Formal_Type_Definition): Defend against Error. (Analyze_Formal_Subprogram): Defend against Error. ! ! * par-ch12.adb (F_Formal_Type_Declaration): In case of error, remove following semicolon if present. Removes cascaded error. 2001-12-04 Douglas B. Rupp --- 2019,2026 ---- * sem_ch12.adb: (Analyze_Formal_Type_Definition): Defend against Error. (Analyze_Formal_Subprogram): Defend against Error. ! ! * par-ch12.adb (F_Formal_Type_Declaration): In case of error, remove following semicolon if present. Removes cascaded error. 2001-12-04 Douglas B. Rupp *************** *** 1525,1546 **** 2001-12-04 Ed Schonberg ! * einfo.ads: Block_Node points to the identifier of the block, not to ! the block node itself, to preserve the link when the block is ! rewritten, e.g. within an if-statement with a static condition. ! ! * inline.adb (Cleanup_Scopes): recover block statement from block entity using new meaning of Block_Node. ! ! * sem_ch5.adb (Analyze_Block_Statement): set Block_Node to point to identifier of block node, rather than to node itself. 2001-12-04 Gary Dismukes ! * layout.adb: (Get_Max_Size): Fix "start of processing" comment to say Get_Max_Size. (Discrimify): Go back to setting the Etypes of the selected component ! because the Vname component does not exist at this point and will fail name resolution. Also set Analyzed. Remove with and use of Sem_Res. --- 2037,2058 ---- 2001-12-04 Ed Schonberg ! * einfo.ads: Block_Node points to the identifier of the block, not to ! the block node itself, to preserve the link when the block is ! rewritten, e.g. within an if-statement with a static condition. ! ! * inline.adb (Cleanup_Scopes): recover block statement from block entity using new meaning of Block_Node. ! ! * sem_ch5.adb (Analyze_Block_Statement): set Block_Node to point to identifier of block node, rather than to node itself. 2001-12-04 Gary Dismukes ! * layout.adb: (Get_Max_Size): Fix "start of processing" comment to say Get_Max_Size. (Discrimify): Go back to setting the Etypes of the selected component ! because the Vname component does not exist at this point and will fail name resolution. Also set Analyzed. Remove with and use of Sem_Res. *************** *** 1557,1584 **** 2001-12-04 Ed Schonberg ! * sem_ch7.adb (New_Private_Type): Set Is_Tagged_Type flag before processing discriminants to diagnose illegal default values. 2001-12-04 Ed Schonberg ! * sem_attr.adb (Resolve_Attribute): Handle properly an non-classwide ! access discriminant within a type extension that constrains its parent discriminants. 2001-12-04 Ed Schonberg ! * sem_ch3.adb (Find_Type_Of_Subtype_Indic): If subtype indication is malformed, use instance of Any_Id to allow analysis to proceed. ! ! * par-ch12.adb (P_Formal_Type_Declaration): Propagate Error if type definition is illegal. (P_Formal_Derived_Type_Definition): Better recovery when TAGGED is misplaced. 2001-12-04 Ed Schonberg ! * sem_warn.adb (Output_Unreferenced_Messages): Extend previous fix to constants. 2001-12-04 Robert Dewar --- 2069,2096 ---- 2001-12-04 Ed Schonberg ! * sem_ch7.adb (New_Private_Type): Set Is_Tagged_Type flag before processing discriminants to diagnose illegal default values. 2001-12-04 Ed Schonberg ! * sem_attr.adb (Resolve_Attribute): Handle properly an non-classwide ! access discriminant within a type extension that constrains its parent discriminants. 2001-12-04 Ed Schonberg ! * sem_ch3.adb (Find_Type_Of_Subtype_Indic): If subtype indication is malformed, use instance of Any_Id to allow analysis to proceed. ! ! * par-ch12.adb (P_Formal_Type_Declaration): Propagate Error if type definition is illegal. (P_Formal_Derived_Type_Definition): Better recovery when TAGGED is misplaced. 2001-12-04 Ed Schonberg ! * sem_warn.adb (Output_Unreferenced_Messages): Extend previous fix to constants. 2001-12-04 Robert Dewar *************** *** 1588,1601 **** 2001-12-04 Robert Dewar * exp_util.adb: Minor reformatting from last change ! ! * errout.adb (Check_For_Warning): For a Raised_Constraint_Error node ! which is a rewriting of an expression, traverse the original expression to remove warnings that may have been posted on it. 2001-12-04 Ed Schonberg ! * exp_util.adb (Must_Be_Aligned): Return false for a component of a record that has other packed components. 2001-12-04 Douglass B. Rupp --- 2100,2113 ---- 2001-12-04 Robert Dewar * exp_util.adb: Minor reformatting from last change ! ! * errout.adb (Check_For_Warning): For a Raised_Constraint_Error node ! which is a rewriting of an expression, traverse the original expression to remove warnings that may have been posted on it. 2001-12-04 Ed Schonberg ! * exp_util.adb (Must_Be_Aligned): Return false for a component of a record that has other packed components. 2001-12-04 Douglass B. Rupp *************** *** 1608,1614 **** 2001-12-04 Arnaud Charlet ! * Makefile.adalib: Clarify step 3 (use of gnat.adc) as it causes more confusion than it solves. 2001-12-04 Geert bosch --- 2120,2126 ---- 2001-12-04 Arnaud Charlet ! * Makefile.adalib: Clarify step 3 (use of gnat.adc) as it causes more confusion than it solves. 2001-12-04 Geert bosch *************** *** 1617,1628 **** 2001-12-04 Geert Bosch ! * Makefile.in (update-sources): New target. For use by gcc_release script. 2001-12-04 Ed Schonberg ! * sem_prag.adb (Analyze_Pragma, case Validity_Checks): do not treat as a configuration pragma, it is now legal wherever a pragma can appear. 2001-12-04 Zack Weinberg --- 2129,2140 ---- 2001-12-04 Geert Bosch ! * Makefile.in (update-sources): New target. For use by gcc_release script. 2001-12-04 Ed Schonberg ! * sem_prag.adb (Analyze_Pragma, case Validity_Checks): do not treat as a configuration pragma, it is now legal wherever a pragma can appear. 2001-12-04 Zack Weinberg *************** *** 1635,1643 **** * einfo.adb (Has_Pragma_Pure_Function): New flag. Fix problem that stopped ceinfo from working ! * einfo.ads (Has_Pragma_Pure_Function): New flag. ! * sem_prag.adb (Pure_Function): Set new flag Has_Pragma_Pure_Function. 2001-12-04 Douglas B. Rupp --- 2147,2155 ---- * einfo.adb (Has_Pragma_Pure_Function): New flag. Fix problem that stopped ceinfo from working ! * einfo.ads (Has_Pragma_Pure_Function): New flag. ! * sem_prag.adb (Pure_Function): Set new flag Has_Pragma_Pure_Function. 2001-12-04 Douglas B. Rupp *************** *** 1647,1667 **** (Preserve_Mode): New boolean. (Write_Unit): Pass time stamp. Implement -p switch (preserve time stamps). ! * gnatcmd.adb (CHOP): Add translation for -p (/PRESERVE). ! * gnatchop.adb: Do usage info for -p switch ! * adaint.h (__gnat_set_file_time_name): New function ! * adaint.c (__gnat_set_file_time_name): Implement ! * adaint.h: Fix typo 2001-12-03 Robert Dewar * sinfo.ads: Minor reformatting. N_Freeze_Entity node does not ! have Associated_Node. 2001-12-03 Robert Dewar --- 2159,2179 ---- (Preserve_Mode): New boolean. (Write_Unit): Pass time stamp. Implement -p switch (preserve time stamps). ! * gnatcmd.adb (CHOP): Add translation for -p (/PRESERVE). ! * gnatchop.adb: Do usage info for -p switch ! * adaint.h (__gnat_set_file_time_name): New function ! * adaint.c (__gnat_set_file_time_name): Implement ! * adaint.h: Fix typo 2001-12-03 Robert Dewar * sinfo.ads: Minor reformatting. N_Freeze_Entity node does not ! have Associated_Node. 2001-12-03 Robert Dewar *************** Thu Nov 15 18:16:17 2001 Richard Kenner *** 2034,2040 **** 2001-10-26 Vincent Celier * g-os_lib.adb (Normalize_Pathname): Preserve the double slash ! ("//") that precede the drive letter on Interix. 2001-10-26 Geert Bosch --- 2546,2552 ---- 2001-10-26 Vincent Celier * g-os_lib.adb (Normalize_Pathname): Preserve the double slash ! ("//") that precede the drive letter on Interix. 2001-10-26 Geert Bosch *************** Thu Nov 15 18:16:17 2001 Richard Kenner *** 2043,2049 **** 2001-10-25 Robert Dewar * sem_ch8.adb (Analyze_Package_Renaming): Skip analysis if Name ! is Error. Similar change for other renaming cases. 2001-10-25 Robert Dewar --- 2555,2561 ---- 2001-10-25 Robert Dewar * sem_ch8.adb (Analyze_Package_Renaming): Skip analysis if Name ! is Error. Similar change for other renaming cases. 2001-10-25 Robert Dewar *************** Thu Nov 15 18:16:17 2001 Richard Kenner *** 2053,2074 **** 2001-10-25 Ed Schonberg * par-ch3.adb (P_Subtype_Mark_Resync): for an anonymous array ! return Error rather than Empty so that analysis can proceed. 2001-10-25 Ed Schonberg * sem_util.adb (Enter_Name): better handling of cascaded error ! messages when a unit appears in its own context. 2001-10-25 Ed Schonberg * sem_util.adb (Defining_Entity): in case of error, attach created ! entity to specification, so that semantic analysis can proceed. 2001-10-25 Robert Dewar * sem_util.adb ! (Defining_Entity): Deal with Error. (Process_End_Label): Deal with bad end label for. 2001-10-25 Ed Schonberg --- 2565,2586 ---- 2001-10-25 Ed Schonberg * par-ch3.adb (P_Subtype_Mark_Resync): for an anonymous array ! return Error rather than Empty so that analysis can proceed. 2001-10-25 Ed Schonberg * sem_util.adb (Enter_Name): better handling of cascaded error ! messages when a unit appears in its own context. 2001-10-25 Ed Schonberg * sem_util.adb (Defining_Entity): in case of error, attach created ! entity to specification, so that semantic analysis can proceed. 2001-10-25 Robert Dewar * sem_util.adb ! (Defining_Entity): Deal with Error. (Process_End_Label): Deal with bad end label for. 2001-10-25 Ed Schonberg *************** Thu Nov 15 18:16:17 2001 Richard Kenner *** 2088,2107 **** 2001-10-25 Ed Schonberg * sem_res.adb (Resolve_Call): if the call is actually an indexing ! operation on the result of a parameterless call, perform elaboration ! check after the node has been properly rewritten. * sem_ch12.adb (Copy_Generic_Node): after the proper body has been ! inlined within the generic tree, the defining identifier is not a ! compilation_unit. 2001-10-25 Ed Schonberg * sem_res.adb (Resolve): special-case resolution of Null in an ! instance or an inlined body to avoid view conflicts. * sem_ch12.adb (Copy_Generic_Node): for allocators, check for view ! compatibility by retrieving the access type of the generic copy. 2001-10-25 Robert Dewar --- 2600,2619 ---- 2001-10-25 Ed Schonberg * sem_res.adb (Resolve_Call): if the call is actually an indexing ! operation on the result of a parameterless call, perform elaboration ! check after the node has been properly rewritten. * sem_ch12.adb (Copy_Generic_Node): after the proper body has been ! inlined within the generic tree, the defining identifier is not a ! compilation_unit. 2001-10-25 Ed Schonberg * sem_res.adb (Resolve): special-case resolution of Null in an ! instance or an inlined body to avoid view conflicts. * sem_ch12.adb (Copy_Generic_Node): for allocators, check for view ! compatibility by retrieving the access type of the generic copy. 2001-10-25 Robert Dewar *************** Thu Nov 15 18:16:17 2001 Richard Kenner *** 2120,2129 **** 2001-10-25 Pascal Obry * gnatmem.adb (Read_Next): fix Curs2 value to properly handle quiet ! mode case for ALLOC case. * gnatmem.adb (Read_Next): correctly fix parsing in Quiet mode on ! all platforms. Improvement of last change. 2001-10-25 Robert Dewar --- 2632,2641 ---- 2001-10-25 Pascal Obry * gnatmem.adb (Read_Next): fix Curs2 value to properly handle quiet ! mode case for ALLOC case. * gnatmem.adb (Read_Next): correctly fix parsing in Quiet mode on ! all platforms. Improvement of last change. 2001-10-25 Robert Dewar *************** Thu Nov 15 18:16:17 2001 Richard Kenner *** 2136,2160 **** 2001-10-25 Pascal Obry * osint.adb (Read_Default_Search_Dirs): correctly detect relative ! pathnames in UNIX and DOS style with drive letter. (Is_Relative): new routine. * osint.adb: Minor reformatting * osint.adb (Is_Relative): implementation using ! GNAT.OS_Lib.Is_Absolute_Path. Better fix. 2001-10-25 Pascal Obry * g-dirope.adb (Basename): correctly compute offset between the ! original Path and the translated one. * g-dirope.adb: (Base_Name): add some comments. 2001-10-25 Robert Dewar * exp_imgv.adb (Expand_Image_Attribute): Defend against bad use ! in HIE mode, avoids compilation abandoned message * exp_imgv.adb: Correct typo in previous change --- 2648,2672 ---- 2001-10-25 Pascal Obry * osint.adb (Read_Default_Search_Dirs): correctly detect relative ! pathnames in UNIX and DOS style with drive letter. (Is_Relative): new routine. * osint.adb: Minor reformatting * osint.adb (Is_Relative): implementation using ! GNAT.OS_Lib.Is_Absolute_Path. Better fix. 2001-10-25 Pascal Obry * g-dirope.adb (Basename): correctly compute offset between the ! original Path and the translated one. * g-dirope.adb: (Base_Name): add some comments. 2001-10-25 Robert Dewar * exp_imgv.adb (Expand_Image_Attribute): Defend against bad use ! in HIE mode, avoids compilation abandoned message * exp_imgv.adb: Correct typo in previous change *************** Thu Nov 15 18:16:17 2001 Richard Kenner *** 2764,2777 **** 2001-10-02 Geert Bosch * misc.c (insert_default_attributes): Add dummy version. - 2003-01-27 Christian Cornelssen - - * Make-lang.in (ada.install-common): Let $(DESTDIR)$(bindir) - be created if necessary. Remove erroneous and redundant - gnatchop installation commands. Test for gnatdll before - attempting to install it. Use initial tab instead of spaces - in continuation lines. - (ada.uninstall): Uninstall gnat instead of gnatcmd. - Also uninstall gnatfind, gnatxref, gnatlbr, and gnatdll - from all plausible locations. - --- 3276,3278 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/checks.adb gcc-3.3/gcc/ada/checks.adb *** gcc-3.2.3/gcc/ada/checks.adb 2002-05-04 03:27:35.000000000 +0000 --- gcc-3.3/gcc/ada/checks.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.6.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Sem_Warn; use Sem_Warn; *** 47,52 **** --- 46,52 ---- with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; + with Targparm; use Targparm; with Tbuild; use Tbuild; with Ttypes; use Ttypes; with Urealp; use Urealp; *************** package body Checks is *** 197,203 **** else Append_To ! (Stmts, Make_Raise_Constraint_Error (Internal_Static_Sloc)); end if; end loop; end Append_Range_Checks; --- 197,205 ---- else Append_To ! (Stmts, ! Make_Raise_Constraint_Error (Internal_Static_Sloc, ! Reason => CE_Range_Check_Failed)); end if; end loop; end Append_Range_Checks; *************** package body Checks is *** 272,278 **** Condition => Make_Op_Gt (Loc, Left_Opnd => Param_Level, ! Right_Opnd => Type_Level))); Analyze_And_Resolve (N); end if; --- 274,281 ---- Condition => Make_Op_Gt (Loc, Left_Opnd => Param_Level, ! Right_Opnd => Type_Level), ! Reason => PE_Accessibility_Check_Failed)); Analyze_And_Resolve (N); end if; *************** package body Checks is *** 315,325 **** and then Known_Alignment (E) then if Expr_Value (Expr) mod Alignment (E) /= 0 then ! Insert_Action (N, ! Make_Raise_Program_Error (Loc)); ! Error_Msg_NE ! ("?specified address for& not " & ! "consistent with alignment", Expr, E); end if; -- Here we do not know if the value is acceptable, generate --- 318,329 ---- and then Known_Alignment (E) then if Expr_Value (Expr) mod Alignment (E) /= 0 then ! Insert_Action (N, ! Make_Raise_Program_Error (Loc, ! Reason => PE_Misaligned_Address_Value)); ! Error_Msg_NE ! ("?specified address for& not " & ! "consistent with alignment", Expr, E); end if; -- Here we do not know if the value is acceptable, generate *************** package body Checks is *** 343,349 **** Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (E, Loc), Attribute_Name => Name_Alignment)), ! Right_Opnd => Make_Integer_Literal (Loc, Uint_0))), Suppress => All_Checks); end if; end if; --- 347,354 ---- Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (E, Loc), Attribute_Name => Name_Alignment)), ! Right_Opnd => Make_Integer_Literal (Loc, Uint_0)), ! Reason => PE_Misaligned_Address_Value), Suppress => All_Checks); end if; end if; *************** package body Checks is *** 377,385 **** OK : Boolean; begin ! if not Software_Overflow_Checking ! or else not Do_Overflow_Check (N) ! or else not Expander_Active then return; end if; --- 382,390 ---- OK : Boolean; begin ! if Backend_Overflow_Checks_On_Target ! or not Do_Overflow_Check (N) ! or not Expander_Active then return; end if; *************** package body Checks is *** 682,688 **** if Static and then Siz >= Check_Siz then Insert_Action (N, ! Make_Raise_Storage_Error (Loc)); Warn_On_Instance := True; Error_Msg_N ("?Storage_Error will be raised at run-time", N); Warn_On_Instance := False; --- 687,694 ---- if Static and then Siz >= Check_Siz then Insert_Action (N, ! Make_Raise_Storage_Error (Loc, ! Reason => SE_Object_Too_Large)); Warn_On_Instance := True; Error_Msg_N ("?Storage_Error will be raised at run-time", N); Warn_On_Instance := False; *************** package body Checks is *** 739,749 **** Make_Op_Ge (Loc, Left_Opnd => Sizx, Right_Opnd => ! Make_Integer_Literal (Loc, Check_Siz))); Set_Size_Check_Code (Defining_Identifier (N), Code); Insert_Action (N, Code); - end Apply_Array_Size_Check; ---------------------------- --- 745,755 ---- Make_Op_Ge (Loc, Left_Opnd => Sizx, Right_Opnd => ! Make_Integer_Literal (Loc, Check_Siz)), ! Reason => SE_Object_Too_Large); Set_Size_Check_Code (Defining_Identifier (N), Code); Insert_Action (N, Code); end Apply_Array_Size_Check; ---------------------------- *************** package body Checks is *** 1026,1032 **** exit; else Apply_Compile_Time_Constraint_Error ! (N, "incorrect value for discriminant&?", Ent => Discr); return; end if; end if; --- 1032,1039 ---- exit; else Apply_Compile_Time_Constraint_Error ! (N, "incorrect value for discriminant&?", ! CE_Discriminant_Check_Failed, Ent => Discr); return; end if; end if; *************** package body Checks is *** 1070,1076 **** end if; Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, Condition => Cond)); end Apply_Discriminant_Check; --- 1077,1085 ---- end if; Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Discriminant_Check_Failed)); end Apply_Discriminant_Check; *************** package body Checks is *** 1094,1100 **** begin if Expander_Active ! and then Software_Overflow_Checking then Determine_Range (Right, ROK, Rlo, Rhi); --- 1103,1109 ---- begin if Expander_Active ! and not Backend_Divide_Checks_On_Target then Determine_Range (Right, ROK, Rlo, Rhi); *************** package body Checks is *** 1109,1115 **** Condition => Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Right), ! Right_Opnd => Make_Integer_Literal (Loc, 0)))); end if; end if; --- 1118,1125 ---- Condition => Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Right), ! Right_Opnd => Make_Integer_Literal (Loc, 0)), ! Reason => CE_Divide_By_Zero)); end if; end if; *************** package body Checks is *** 1139,1145 **** Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Right), Right_Opnd => ! Make_Integer_Literal (Loc, -1))))); end if; end if; end if; --- 1149,1156 ---- Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Right), Right_Opnd => ! Make_Integer_Literal (Loc, -1))), ! Reason => CE_Overflow_Check_Failed)); end if; end if; end if; *************** package body Checks is *** 1211,1217 **** procedure Bad_Value is begin Apply_Compile_Time_Constraint_Error ! (Expr, "value not in range of}?", Ent => Target_Typ, Typ => Target_Typ); end Bad_Value; --- 1222,1228 ---- procedure Bad_Value is begin Apply_Compile_Time_Constraint_Error ! (Expr, "value not in range of}?", CE_Range_Check_Failed, Ent => Target_Typ, Typ => Target_Typ); end Bad_Value; *************** package body Checks is *** 1439,1445 **** (not Length_Checks_Suppressed (Target_Typ)); begin ! if not Expander_Active or else not Checks_On then return; end if; --- 1450,1456 ---- (not Length_Checks_Suppressed (Target_Typ)); begin ! if not Expander_Active then return; end if; *************** package body Checks is *** 1478,1490 **** then Cond := Condition (R_Cno); ! if not Has_Dynamic_Length_Check (Ck_Node) then Insert_Action (Ck_Node, R_Cno); if not Do_Static then Set_Has_Dynamic_Length_Check (Ck_Node); end if; - end if; -- Output a warning if the condition is known to be True --- 1489,1502 ---- then Cond := Condition (R_Cno); ! if not Has_Dynamic_Length_Check (Ck_Node) ! and then Checks_On ! then Insert_Action (Ck_Node, R_Cno); if not Do_Static then Set_Has_Dynamic_Length_Check (Ck_Node); end if; end if; -- Output a warning if the condition is known to be True *************** package body Checks is *** 1494,1499 **** --- 1506,1512 ---- then Apply_Compile_Time_Constraint_Error (Ck_Node, "wrong length for array of}?", + CE_Length_Check_Failed, Ent => Target_Typ, Typ => Target_Typ); *************** package body Checks is *** 1576,1581 **** --- 1589,1595 ---- if Nkind (Ck_Node) = N_Range then Apply_Compile_Time_Constraint_Error (Low_Bound (Ck_Node), "static range out of bounds of}?", + CE_Range_Check_Failed, Ent => Target_Typ, Typ => Target_Typ); *************** package body Checks is *** 1584,1589 **** --- 1598,1604 ---- else Apply_Compile_Time_Constraint_Error (Ck_Node, "static value out of range of}?", + CE_Range_Check_Failed, Ent => Target_Typ, Typ => Target_Typ); end if; *************** package body Checks is *** 1661,1670 **** if Inside_A_Generic then return; ! -- Skip these checks if errors detected, there are some nasty -- situations of incomplete trees that blow things up. ! elsif Errors_Detected > 0 then return; -- Scalar type conversions of the form Target_Type (Expr) require --- 1676,1685 ---- if Inside_A_Generic then return; ! -- Skip these checks if serious errors detected, there are some nasty -- situations of incomplete trees that blow things up. ! elsif Serious_Errors_Detected > 0 then return; -- Scalar type conversions of the form Target_Type (Expr) require *************** package body Checks is *** 1778,1784 **** Set_Discriminant_Constraint (Expr_Type, Old_Constraints); Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, Condition => Cond)); end; -- should there be other checks here for array types ??? --- 1793,1801 ---- Set_Discriminant_Constraint (Expr_Type, Old_Constraints); Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Discriminant_Check_Failed)); end; -- should there be other checks here for array types ??? *************** package body Checks is *** 2774,2780 **** else Check_Node := ! Make_Raise_Constraint_Error (Internal_Static_Sloc); Mark_Rewrite_Insertion (Check_Node); if Do_Before then --- 2791,2798 ---- else Check_Node := ! Make_Raise_Constraint_Error (Internal_Static_Sloc, ! Reason => CE_Range_Check_Failed); Mark_Rewrite_Insertion (Check_Node); if Do_Before then *************** package body Checks is *** 2812,2818 **** Exp := Expression (Exp); end loop; ! -- insert the validity check. Note that we do this with validity -- checks turned off, to avoid recursion, we do not want validity -- checks on the validity checking code itself! --- 2830,2836 ---- Exp := Expression (Exp); end loop; ! -- Insert the validity check. Note that we do this with validity -- checks turned off, to avoid recursion, we do not want validity -- checks on the validity checking code itself! *************** package body Checks is *** 2826,2832 **** Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr (Exp, Name_Req => True), ! Attribute_Name => Name_Valid))), Suppress => All_Checks); Validity_Checks_On := True; end Insert_Valid_Check; --- 2844,2851 ---- Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr (Exp, Name_Req => True), ! Attribute_Name => Name_Valid)), ! Reason => CE_Invalid_Data), Suppress => All_Checks); Validity_Checks_On := True; end Insert_Valid_Check; *************** package body Checks is *** 2840,2846 **** Typ : constant Entity_Id := Etype (R_Cno); begin ! Rewrite (R_Cno, Make_Raise_Constraint_Error (Loc)); Set_Analyzed (R_Cno); Set_Etype (R_Cno, Typ); Set_Raises_Constraint_Error (R_Cno); --- 2859,2867 ---- Typ : constant Entity_Id := Etype (R_Cno); begin ! Rewrite (R_Cno, ! Make_Raise_Constraint_Error (Loc, ! Reason => CE_Range_Check_Failed)); Set_Analyzed (R_Cno); Set_Etype (R_Cno, Typ); Set_Raises_Constraint_Error (R_Cno); *************** package body Checks is *** 2897,2902 **** --- 2918,3021 ---- or else Vax_Float (E); end Range_Checks_Suppressed; + ------------------- + -- Remove_Checks -- + ------------------- + + procedure Remove_Checks (Expr : Node_Id) is + Discard : Traverse_Result; + + function Process (N : Node_Id) return Traverse_Result; + -- Process a single node during the traversal + + function Traverse is new Traverse_Func (Process); + -- The traversal function itself + + ------------- + -- Process -- + ------------- + + function Process (N : Node_Id) return Traverse_Result is + begin + if Nkind (N) not in N_Subexpr then + return Skip; + end if; + + Set_Do_Range_Check (N, False); + + case Nkind (N) is + when N_And_Then => + Discard := Traverse (Left_Opnd (N)); + return Skip; + + when N_Attribute_Reference => + Set_Do_Access_Check (N, False); + Set_Do_Overflow_Check (N, False); + + when N_Explicit_Dereference => + Set_Do_Access_Check (N, False); + + when N_Function_Call => + Set_Do_Tag_Check (N, False); + + when N_Indexed_Component => + Set_Do_Access_Check (N, False); + + when N_Op => + Set_Do_Overflow_Check (N, False); + + case Nkind (N) is + when N_Op_Divide => + Set_Do_Division_Check (N, False); + + when N_Op_And => + Set_Do_Length_Check (N, False); + + when N_Op_Mod => + Set_Do_Division_Check (N, False); + + when N_Op_Or => + Set_Do_Length_Check (N, False); + + when N_Op_Rem => + Set_Do_Division_Check (N, False); + + when N_Op_Xor => + Set_Do_Length_Check (N, False); + + when others => + null; + end case; + + when N_Or_Else => + Discard := Traverse (Left_Opnd (N)); + return Skip; + + when N_Selected_Component => + Set_Do_Access_Check (N, False); + Set_Do_Discriminant_Check (N, False); + + when N_Slice => + Set_Do_Access_Check (N, False); + + when N_Type_Conversion => + Set_Do_Length_Check (N, False); + Set_Do_Overflow_Check (N, False); + Set_Do_Tag_Check (N, False); + + when others => + null; + end case; + + return OK; + end Process; + + -- Start of processing for Remove_Checks + + begin + Discard := Traverse (Expr); + end Remove_Checks; + ---------------------------- -- Selected_Length_Checks -- ---------------------------- *************** package body Checks is *** 3274,3280 **** for Indx in 1 .. Ndims loop if not (Nkind (L_Index) = N_Raise_Constraint_Error ! or else Nkind (R_Index) = N_Raise_Constraint_Error) then Get_Index_Bounds (L_Index, L_Low, L_High); Get_Index_Bounds (R_Index, R_Low, R_High); --- 3393,3400 ---- for Indx in 1 .. Ndims loop if not (Nkind (L_Index) = N_Raise_Constraint_Error ! or else ! Nkind (R_Index) = N_Raise_Constraint_Error) then Get_Index_Bounds (L_Index, L_Low, L_High); Get_Index_Bounds (R_Index, R_Low, R_High); *************** package body Checks is *** 3351,3357 **** else declare ! Ndims : Nat := Number_Dimensions (T_Typ); begin -- Build the condition for the explicit dereference case --- 3471,3477 ---- else declare ! Ndims : Nat := Number_Dimensions (T_Typ); begin -- Build the condition for the explicit dereference case *************** package body Checks is *** 3372,3382 **** Cond := Guard_Access (Cond, Loc, Ck_Node); end if; ! Add_Check (Make_Raise_Constraint_Error (Loc, Condition => Cond)); end if; return Ret_Result; - end Selected_Length_Checks; --------------------------- --- 3492,3504 ---- Cond := Guard_Access (Cond, Loc, Ck_Node); end if; ! Add_Check ! (Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Length_Check_Failed)); end if; return Ret_Result; end Selected_Length_Checks; --------------------------- *************** package body Checks is *** 4074,4080 **** for Indx in 1 .. Ndims loop if not (Nkind (L_Index) = N_Raise_Constraint_Error ! or else Nkind (R_Index) = N_Raise_Constraint_Error) then Get_Index_Bounds (L_Index, L_Low, L_High); Get_Index_Bounds (R_Index, R_Low, R_High); --- 4196,4203 ---- for Indx in 1 .. Ndims loop if not (Nkind (L_Index) = N_Raise_Constraint_Error ! or else ! Nkind (R_Index) = N_Raise_Constraint_Error) then Get_Index_Bounds (L_Index, L_Low, L_High); Get_Index_Bounds (R_Index, R_Low, R_High); *************** package body Checks is *** 4193,4203 **** Cond := Guard_Access (Cond, Loc, Ck_Node); end if; ! Add_Check (Make_Raise_Constraint_Error (Loc, Condition => Cond)); end if; return Ret_Result; - end Selected_Range_Checks; ------------------------------- --- 4316,4328 ---- Cond := Guard_Access (Cond, Loc, Ck_Node); end if; ! Add_Check ! (Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Range_Check_Failed)); end if; return Ret_Result; end Selected_Range_Checks; ------------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/checks.ads gcc-3.3/gcc/ada/checks.ads *** gcc-3.2.3/gcc/ada/checks.ads 2002-05-04 03:27:35.000000000 +0000 --- gcc-3.3/gcc/ada/checks.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Checks is *** 497,502 **** --- 496,506 ---- -- the sense of the 'Valid attribute returning True. Constraint_Error -- will be raised if the value is not valid. + procedure Remove_Checks (Expr : Node_Id); + -- Remove all checks from Expr except those that are only executed + -- conditionally (on the right side of And Then/Or Else. This call + -- removes only embedded checks (Do_Range_Check, Do_Overflow_Check). + private type Check_Result is array (Positive range 1 .. 2) of Node_Id; diff -Nrc3pad gcc-3.2.3/gcc/ada/cio.c gcc-3.3/gcc/ada/cio.c *** gcc-3.2.3/gcc/ada/cio.c 2002-05-04 03:27:36.000000000 +0000 --- gcc-3.3/gcc/ada/cio.c 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * C Implementation File * * * - * $Revision: 1.2.12.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/comperr.adb gcc-3.3/gcc/ada/comperr.adb *** gcc-3.2.3/gcc/ada/comperr.adb 2002-05-04 03:27:36.000000000 +0000 --- gcc-3.3/gcc/ada/comperr.adb 2002-11-15 01:45:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.3 $ -- -- -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Comperr is *** 76,84 **** --- 75,92 ---- (X : String; Code : Integer := 0) is + -- The procedures below output a "bug box" with information about + -- the cause of the compiler abort and about the preferred method + -- of reporting bugs. The default is a bug box appropriate for + -- the FSF version of GNAT. + procedure End_Line; -- Add blanks up to column 76, and then a final vertical bar + -------------- + -- End_Line -- + -------------- + procedure End_Line is begin Repeat_Char (' ', 76, '|'); *************** package body Comperr is *** 96,108 **** Abort_In_Progress := True; ! -- If errors have already occurred, then we guess that the abort may ! -- well be caused by previous errors, and we don't make too much fuss ! -- about it, since we want to let the programmer fix the errors first. -- Debug flag K disables this behavior (useful for debugging) ! if Errors_Detected /= 0 and then not Debug_Flag_K then Errout.Finalize; Set_Standard_Error; --- 104,116 ---- Abort_In_Progress := True; ! -- If any errors have already occurred, then we guess that the abort ! -- may well be caused by previous errors, and we don't make too much ! -- fuss about it, since we want to let programmer fix the errors first. -- Debug flag K disables this behavior (useful for debugging) ! if Total_Errors_Detected /= 0 and then not Debug_Flag_K then Errout.Finalize; Set_Standard_Error; *************** package body Comperr is *** 251,258 **** else Write_Str ! ("| Please submit a bug report, see" & ! " http://gcc.gnu.org/bugs.html."); End_Line; Write_Str --- 259,266 ---- else Write_Str ! ("| Please submit a bug report; see" & ! " http://gcc.gnu.org/bugs.html."); End_Line; Write_Str *************** package body Comperr is *** 270,276 **** End_Line; Write_Str ! ("| (concatenated together with no headers between files)."); End_Line; end if; --- 278,284 ---- End_Line; Write_Str ! ("| concatenated together with no headers between files."); End_Line; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/comperr.ads gcc-3.3/gcc/ada/comperr.ads *** gcc-3.2.3/gcc/ada/comperr.ads 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/comperr.ads 2002-11-15 01:45:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Comperr is *** 57,63 **** -- information on the version number, type of abort, and source location. -- Normally the remaining text is of the following form: ! -- Please submit bug a report, see http://gcc.gnu.org/bugs.html. -- Include the entire contents of this bug box in the report. -- Include the exact gcc or gnatmake command that you entered. -- Also include sources listed below in gnatchop format --- 56,63 ---- -- information on the version number, type of abort, and source location. -- Normally the remaining text is of the following form: ! ! -- Please submit a bug report; see http://gcc.gnu.org/bugs.html. -- Include the entire contents of this bug box in the report. -- Include the exact gcc or gnatmake command that you entered. -- Also include sources listed below in gnatchop format diff -Nrc3pad gcc-3.2.3/gcc/ada/config-lang.in gcc-3.3/gcc/ada/config-lang.in *** gcc-3.2.3/gcc/ada/config-lang.in 2001-12-20 00:20:43.000000000 +0000 --- gcc-3.3/gcc/ada/config-lang.in 2002-11-13 21:19:51.000000000 +0000 *************** compilers="gnat1\$(exeext)" *** 34,37 **** --- 34,39 ---- stagestuff="gnatbind\$(exeext) gnat1\$(exeext)" + gtfiles="\$(srcdir)/ada/ada-tree.h \$(srcdir)/ada/gigi.h \$(srcdir)/ada/decl.c \$(srcdir)/ada/trans.c \$(srcdir)/ada/utils.c" + outputs=ada/Makefile diff -Nrc3pad gcc-3.2.3/gcc/ada/csets.adb gcc-3.3/gcc/ada/csets.adb *** gcc-3.2.3/gcc/ada/csets.adb 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/csets.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Csets is *** 168,176 **** X_FE : constant Character := Character'Val (16#FE#); X_FF : constant Character := Character'Val (16#FF#); ! ----------------------------- ! -- Definitions for Latin-1 -- ! ----------------------------- Fold_Latin_1 : Translate_Table := Translate_Table'( --- 167,175 ---- X_FE : constant Character := Character'Val (16#FE#); X_FF : constant Character := Character'Val (16#FF#); ! ------------------------------------------ ! -- Definitions for Latin-1 (ISO 8859-1) -- ! ------------------------------------------ Fold_Latin_1 : Translate_Table := Translate_Table'( *************** package body Csets is *** 243,251 **** others => ' '); ! ----------------------------- ! -- Definitions for Latin-2 -- ! ----------------------------- Fold_Latin_2 : Translate_Table := Translate_Table'( --- 242,250 ---- others => ' '); ! ------------------------------------------ ! -- Definitions for Latin-2 (ISO 8859-2) -- ! ------------------------------------------ Fold_Latin_2 : Translate_Table := Translate_Table'( *************** package body Csets is *** 318,326 **** others => ' '); ! ----------------------------- ! -- Definitions for Latin-3 -- ! ----------------------------- Fold_Latin_3 : Translate_Table := Translate_Table'( --- 317,325 ---- others => ' '); ! ------------------------------------------ ! -- Definitions for Latin-3 (ISO 8859-3) -- ! ------------------------------------------ Fold_Latin_3 : Translate_Table := Translate_Table'( *************** package body Csets is *** 393,401 **** others => ' '); ! ----------------------------- ! -- Definitions for Latin-4 -- ! ----------------------------- Fold_Latin_4 : Translate_Table := Translate_Table'( --- 392,400 ---- others => ' '); ! ------------------------------------------ ! -- Definitions for Latin-4 (ISO 8859-4) -- ! ------------------------------------------ Fold_Latin_4 : Translate_Table := Translate_Table'( *************** package body Csets is *** 543,548 **** --- 542,622 ---- others => ' '); + ------------------------------------------ + -- Definitions for Latin-9 (ISO 8859-9) -- + ------------------------------------------ + + Fold_Latin_9 : Translate_Table := Translate_Table'( + + 'a' => 'A', X_E0 => X_C0, X_F0 => X_D0, + 'b' => 'B', X_E1 => X_C1, X_F1 => X_D1, + 'c' => 'C', X_E2 => X_C2, X_F2 => X_D2, + 'd' => 'D', X_E3 => X_C3, X_F3 => X_D3, + 'e' => 'E', X_E4 => X_C4, X_F4 => X_D4, + 'f' => 'F', X_E5 => X_C5, X_F5 => X_D5, + 'g' => 'G', X_E6 => X_C6, X_F6 => X_D6, + 'h' => 'H', X_E7 => X_C7, + 'i' => 'I', X_E8 => X_C8, X_F8 => X_D8, + 'j' => 'J', X_E9 => X_C9, X_F9 => X_D9, + 'k' => 'K', X_EA => X_CA, X_FA => X_DA, + 'l' => 'L', X_EB => X_CB, X_FB => X_DB, + 'm' => 'M', X_EC => X_CC, X_FC => X_DC, + 'n' => 'N', X_ED => X_CD, X_FD => X_DD, + 'o' => 'O', X_EE => X_CE, X_FE => X_DE, + 'p' => 'P', X_EF => X_CF, + 'q' => 'Q', X_A8 => X_A6, + 'r' => 'R', X_B8 => X_B4, + 's' => 'S', X_BD => X_BC, + 't' => 'T', X_BE => X_FF, + 'u' => 'U', + 'v' => 'V', + 'w' => 'W', + 'x' => 'X', + 'y' => 'Y', + 'z' => 'Z', + + 'A' => 'A', X_C0 => X_C0, X_D0 => X_D0, + 'B' => 'B', X_C1 => X_C1, X_D1 => X_D1, + 'C' => 'C', X_C2 => X_C2, X_D2 => X_D2, + 'D' => 'D', X_C3 => X_C3, X_D3 => X_D3, + 'E' => 'E', X_C4 => X_C4, X_D4 => X_D4, + 'F' => 'F', X_C5 => X_C5, X_D5 => X_D5, + 'G' => 'G', X_C6 => X_C6, X_D6 => X_D6, + 'H' => 'H', X_C7 => X_C7, + 'I' => 'I', X_C8 => X_C8, X_D8 => X_D8, + 'J' => 'J', X_C9 => X_C9, X_D9 => X_D9, + 'K' => 'K', X_CA => X_CA, X_DA => X_DA, + 'L' => 'L', X_CB => X_CB, X_DB => X_DB, + 'M' => 'M', X_CC => X_CC, X_DC => X_DC, + 'N' => 'N', X_CD => X_CD, X_DD => X_DD, + 'O' => 'O', X_CE => X_CE, X_DE => X_DE, + 'P' => 'P', X_CF => X_CF, X_DF => X_DF, X_FF => X_FF, + 'Q' => 'Q', X_A6 => X_A6, + 'R' => 'R', X_B4 => X_B4, + 'S' => 'S', X_BC => X_BC, + 'T' => 'T', + 'U' => 'U', + 'V' => 'V', + 'W' => 'W', + 'X' => 'X', + 'Y' => 'Y', + 'Z' => 'Z', + + '0' => '0', + '1' => '1', + '2' => '2', + '3' => '3', + '4' => '4', + '5' => '5', + '6' => '6', + '7' => '7', + '8' => '8', + '9' => '9', + + '_' => '_', + + others => ' '); + -------------------------------------------- -- Definitions for IBM PC (Code Page 437) -- -------------------------------------------- *************** package body Csets is *** 1024,1030 **** procedure Initialize is begin - -- Set Fold_Upper table from source code indication if Identifier_Character_Set = '1' --- 1098,1103 ---- *************** package body Csets is *** 1050,1055 **** --- 1123,1131 ---- elsif Identifier_Character_Set = '8' then Fold_Upper := Fold_IBM_PC_850; + elsif Identifier_Character_Set = '9' then + Fold_Upper := Fold_Latin_9; + elsif Identifier_Character_Set = 'f' then Fold_Upper := Fold_Full_Upper_Half; diff -Nrc3pad gcc-3.2.3/gcc/ada/csets.ads gcc-3.3/gcc/ada/csets.ads *** gcc-3.2.3/gcc/ada/csets.ads 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/csets.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** pragma Elaborate_Body (Csets); *** 64,76 **** -- The character set in use is specified by the value stored in -- Opt.Identifier_Character_Set, which has the following settings: ! -- '1' Latin-1 ! -- '2' Latin-2 ! -- '3' Latin-3 ! -- '4' Latin-4 ! -- '5' Latin-5 (Cyrillic ISO-8859-5) ! -- 'p' IBM PC (code page 437) ! -- '8' IBM PC (code page 850) -- 'f' Full upper set (all distinct) -- 'n' No upper characters (Ada/83 rules) -- 'w' Latin-1 plus wide characters also allowed --- 63,76 ---- -- The character set in use is specified by the value stored in -- Opt.Identifier_Character_Set, which has the following settings: ! -- '1' Latin-1 (ISO-8859-1) ! -- '2' Latin-2 (ISO-8859-2) ! -- '3' Latin-3 (ISO-8859-3) ! -- '4' Latin-4 (ISO-8859-4) ! -- '5' Latin-5 (ISO-8859-5, Cyrillic) ! -- 'p' IBM PC (code page 437) ! -- '8' IBM PC (code page 850) ! -- '9' Latin-9 (ISO-9959-9) -- 'f' Full upper set (all distinct) -- 'n' No upper characters (Ada/83 rules) -- 'w' Latin-1 plus wide characters also allowed diff -Nrc3pad gcc-3.2.3/gcc/ada/csinfo.adb gcc-3.3/gcc/ada/csinfo.adb *** gcc-3.2.3/gcc/ada/csinfo.adb 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/csinfo.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/cstand.adb gcc-3.3/gcc/ada/cstand.adb *** gcc-3.2.3/gcc/ada/cstand.adb 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/cstand.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body CStand is *** 353,359 **** Set_Ekind (Standard_Boolean, E_Enumeration_Type); Set_First_Literal (Standard_Boolean, Standard_False); Set_Etype (Standard_Boolean, Standard_Boolean); ! Init_Esize (Standard_Boolean, 8); Init_RM_Size (Standard_Boolean, 1); Set_Prim_Alignment (Standard_Boolean); --- 352,358 ---- Set_Ekind (Standard_Boolean, E_Enumeration_Type); Set_First_Literal (Standard_Boolean, Standard_False); Set_Etype (Standard_Boolean, Standard_Boolean); ! Init_Esize (Standard_Boolean, Standard_Character_Size); Init_RM_Size (Standard_Boolean, 1); Set_Prim_Alignment (Standard_Boolean); *************** package body CStand is *** 471,477 **** Set_Ekind (Standard_Character, E_Enumeration_Type); Set_Etype (Standard_Character, Standard_Character); ! Init_Size (Standard_Character, Standard_Character_Size); Set_Prim_Alignment (Standard_Character); Set_Is_Unsigned_Type (Standard_Character); --- 470,477 ---- Set_Ekind (Standard_Character, E_Enumeration_Type); Set_Etype (Standard_Character, Standard_Character); ! Init_Esize (Standard_Character, Standard_Character_Size); ! Init_RM_Size (Standard_Character, 8); Set_Prim_Alignment (Standard_Character); Set_Is_Unsigned_Type (Standard_Character); *************** package body CStand is *** 800,806 **** Set_Ekind (Any_Boolean, E_Enumeration_Type); Set_Scope (Any_Boolean, Standard_Standard); Set_Etype (Any_Boolean, Standard_Boolean); ! Init_Esize (Any_Boolean, 8); Init_RM_Size (Any_Boolean, 1); Set_Prim_Alignment (Any_Boolean); Set_Is_Unsigned_Type (Any_Boolean); --- 800,806 ---- Set_Ekind (Any_Boolean, E_Enumeration_Type); Set_Scope (Any_Boolean, Standard_Standard); Set_Etype (Any_Boolean, Standard_Boolean); ! Init_Esize (Any_Boolean, Standard_Character_Size); Init_RM_Size (Any_Boolean, 1); Set_Prim_Alignment (Any_Boolean); Set_Is_Unsigned_Type (Any_Boolean); *************** package body CStand is *** 813,819 **** Set_Etype (Any_Character, Any_Character); Set_Is_Unsigned_Type (Any_Character); Set_Is_Character_Type (Any_Character); ! Init_Size (Any_Character, Standard_Character_Size); Set_Prim_Alignment (Any_Character); Set_Scalar_Range (Any_Character, Scalar_Range (Standard_Character)); Make_Name (Any_Character, "a character type"); --- 813,820 ---- Set_Etype (Any_Character, Any_Character); Set_Is_Unsigned_Type (Any_Character); Set_Is_Character_Type (Any_Character); ! Init_Esize (Any_Character, Standard_Character_Size); ! Init_RM_Size (Any_Character, 8); Set_Prim_Alignment (Any_Character); Set_Scalar_Range (Any_Character, Scalar_Range (Standard_Character)); Make_Name (Any_Character, "a character type"); diff -Nrc3pad gcc-3.2.3/gcc/ada/cstand.ads gcc-3.3/gcc/ada/cstand.ads *** gcc-3.2.3/gcc/ada/cstand.ads 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/cstand.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/cstreams.c gcc-3.3/gcc/ada/cstreams.c *** gcc-3.2.3/gcc/ada/cstreams.c 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/cstreams.c 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * Auxiliary C functions for Interfaces.C.Streams * * * - * $Revision: 1.2.12.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- *************** *** 49,68 **** #include "adaint.h" ! #ifdef __EMX__ ! int max_path_len = _MAX_PATH; ! #elif defined (VMS) #include ! int max_path_len = 255; /* PATH_MAX */ ! ! #elif defined (__vxworks) || defined (__OPENNT) ! ! int max_path_len = PATH_MAX; ! ! #else #ifdef linux - /* Don't use macros on GNU/Linux since they cause incompatible changes between glibc 2.0 and 2.1 */ --- 48,58 ---- #include "adaint.h" ! #ifdef VMS #include ! #endif #ifdef linux /* Don't use macros on GNU/Linux since they cause incompatible changes between glibc 2.0 and 2.1 */ *************** int max_path_len = PATH_MAX; *** 75,86 **** #ifdef stdout # undef stdout #endif - - #endif - - #include - - int max_path_len = MAXPATHLEN; #endif /* The _IONBF value in CYGNUS or MINGW32 stdio.h is wrong. */ --- 65,70 ---- *************** __gnat_full_name (nam, buffer) *** 182,192 **** #if defined(__EMX__) || defined (__MINGW32__) /* If this is a device file return it as is; under Windows NT and OS/2 a device file end with ":". */ ! if (nam [strlen (nam) - 1] == ':') strcpy (buffer, nam); else { ! _fullpath (buffer, nam, max_path_len); for (p = buffer; *p; p++) if (*p == '/') --- 166,176 ---- #if defined(__EMX__) || defined (__MINGW32__) /* If this is a device file return it as is; under Windows NT and OS/2 a device file end with ":". */ ! if (nam[strlen (nam) - 1] == ':') strcpy (buffer, nam); else { ! _fullpath (buffer, nam, __gnat_max_path_len); for (p = buffer; *p; p++) if (*p == '/') *************** __gnat_full_name (nam, buffer) *** 211,220 **** strcpy (buffer, __gnat_to_host_file_spec (buffer)); else { ! char nambuffer [MAXPATHLEN]; strcpy (nambuffer, buffer); ! strcpy (buffer, getcwd (buffer, max_path_len, 0)); strcat (buffer, "/"); strcat (buffer, nambuffer); strcpy (buffer, __gnat_to_host_file_spec (buffer)); --- 195,204 ---- strcpy (buffer, __gnat_to_host_file_spec (buffer)); else { ! char *nambuffer = alloca (__gnat_max_path_len); strcpy (nambuffer, buffer); ! strcpy (buffer, getcwd (buffer, __gnat_max_path_len, 0)); strcat (buffer, "/"); strcat (buffer, nambuffer); strcpy (buffer, __gnat_to_host_file_spec (buffer)); *************** __gnat_full_name (nam, buffer) *** 225,231 **** #else if (nam[0] != '/') { ! p = getcwd (buffer, max_path_len); if (p == 0) { buffer[0] = '\0'; --- 209,215 ---- #else if (nam[0] != '/') { ! p = getcwd (buffer, __gnat_max_path_len); if (p == 0) { buffer[0] = '\0'; diff -Nrc3pad gcc-3.2.3/gcc/ada/cuintp.c gcc-3.3/gcc/ada/cuintp.c *** gcc-3.2.3/gcc/ada/cuintp.c 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/cuintp.c 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * C Implementation File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/.cvsignore gcc-3.3/gcc/ada/.cvsignore *** gcc-3.2.3/gcc/ada/.cvsignore 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/.cvsignore 2002-05-31 10:47:33.000000000 +0000 *************** *** 0 **** --- 1,6 ---- + gnat_ug_unx.info* + gnat_ug_vms.info* + gnat_ug_vxw.info* + gnat_ug_wnt.info* + gnat_rm.info* + gnat-style.info* diff -Nrc3pad gcc-3.2.3/gcc/ada/debug_a.adb gcc-3.3/gcc/ada/debug_a.adb *** gcc-3.2.3/gcc/ada/debug_a.adb 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/debug_a.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/debug_a.ads gcc-3.3/gcc/ada/debug_a.ads *** gcc-3.2.3/gcc/ada/debug_a.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/debug_a.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/debug.adb gcc-3.3/gcc/ada/debug.adb *** gcc-3.2.3/gcc/ada/debug.adb 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/debug.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Debug is *** 57,63 **** -- dn Generate messages for node/list allocation -- do Print source from tree (original code only) -- dp Generate messages for parser scope stack push/pops ! -- dq -- dr Generate parser resynchronization messages -- ds Print source from tree (including original and generated stuff) -- dt Print full tree --- 56,62 ---- -- dn Generate messages for node/list allocation -- do Print source from tree (original code only) -- dp Generate messages for parser scope stack push/pops ! -- dq No auto-alignment of small records -- dr Generate parser resynchronization messages -- ds Print source from tree (including original and generated stuff) -- dt Print full tree *************** package body Debug is *** 74,86 **** -- dD Delete elaboration checks in inner level routines -- dE Apply elaboration checks to predefined units -- dF Front end data layout enabled. ! -- dG Generate input showing file creating info for debug file -- dH Hold (kill) call to gigi -- dI Inhibit internal name numbering in gnatG listing -- dJ Output debugging trace info for JGNAT (Java VM version of GNAT) -- dK Kill all error messages -- dL Output trace information on elaboration checking ! -- dM Modified ali file output -- dN Do not generate file/line exception messages -- dO Output immediate error messages -- dP Do not check for controlled objects in preelaborable packages --- 73,85 ---- -- dD Delete elaboration checks in inner level routines -- dE Apply elaboration checks to predefined units -- dF Front end data layout enabled. ! -- dG -- dH Hold (kill) call to gigi -- dI Inhibit internal name numbering in gnatG listing -- dJ Output debugging trace info for JGNAT (Java VM version of GNAT) -- dK Kill all error messages -- dL Output trace information on elaboration checking ! -- dM -- dN Do not generate file/line exception messages -- dO Output immediate error messages -- dP Do not check for controlled objects in preelaborable packages *************** package body Debug is *** 124,130 **** -- do -- dp -- dq ! -- dr List additional restrictions that may be specified -- ds -- dt -- du List units as they are acquired --- 123,129 ---- -- do -- dp -- dq ! -- dr -- ds -- dt -- du List units as they are acquired *************** package body Debug is *** 166,172 **** -- dr -- ds -- dt ! -- du -- dv -- dw Prints the list of units withed by the unit currently explored -- dx --- 165,171 ---- -- dr -- ds -- dt ! -- du List units as their ali files are acquired -- dv -- dw Prints the list of units withed by the unit currently explored -- dx *************** package body Debug is *** 192,197 **** --- 191,200 ---- -- resolved, or evaluated. This option is useful for finding out -- exactly where a bomb during semantic analysis is occurring. + -- dA Normally the output from -gnatR excludes private types and all + -- internal entities. This debug flag causes representation info + -- for these entities to be output as well. + -- db In Exp_Dbug, certain type names are encoded to include debugging -- information. This debug switch causes lines to be output showing -- the encodings used. *************** package body Debug is *** 238,246 **** -- non-source generated null statements, and freeze nodes, which -- are normally omitted in -gnatG mode. - -- dG Print trace information showing calls to Create_Debug_Source and - -- Write_Debug_Line. Used for debugging -gnatD operation problems. - -- dh Generates a table at the end of a compilation showing how the hash -- table chains built by the Namet package are loaded. This is useful -- in ensuring that the hashing algorithm (in Namet.Hash) is working --- 241,246 ---- *************** package body Debug is *** 284,294 **** -- attempting to generate code with this flag set may blow up. -- The flag also forces the use of 64-bits for Long_Integer. - -- dM Generate modified ALI output. Several ALI extensions are being - -- developed for version 3.15w, and this switch is used to enable - -- these extensions. This switch will disappear when this work is - -- completed. - -- dn Generate messages for node/list allocation. Each time a node or -- list header is allocated, a line of output is generated. Certain -- other basic tree operations also cause a line of output to be --- 284,289 ---- *************** package body Debug is *** 308,313 **** --- 303,314 ---- -- pushed or popped. Useful in debugging situations where the -- parser scope stack ends up incorrectly synchronized + -- dq In layout version 1.38, 2002/01/12, a circuit was implemented + -- to give decent default alignment to short records that had no + -- specific alignment set. This debug option restores the previous + -- behavior of giving such records poor alignments, typically 1. + -- This may be useful in dealing with transition. + -- dr Generate parser resynchronization messages. Normally the parser -- resynchronizes quietly. With this debug option, two messages -- are generated, one when the parser starts a resynchronization *************** package body Debug is *** 463,471 **** -- the algorithm used to determine a correct order of elaboration. This -- is useful in diagnosing any problems in its behavior. - -- dr List restrictions which have not been specified, but could have - -- been without causing bind errors. - -- du List unit name and file name for each unit as it is read in ------------------------------------------------------------ --- 464,469 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/debug.ads gcc-3.3/gcc/ada/debug.ads *** gcc-3.2.3/gcc/ada/debug.ads 2002-05-04 03:27:37.000000000 +0000 --- gcc-3.3/gcc/ada/debug.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-1999 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Debug is *** 37,52 **** pragma Preelaborate (Debug); -- This package contains global flags used to control the inclusion ! -- of debugging code in various phases of the compiler. ------------------------- -- Dynamic Debug Flags -- ------------------------- ! -- Thirty six flags that can be used to active various specialized -- debugging output information. The flags are preset to False, which -- corresponds to the given output being suppressed. The individual ! -- flags can be turned on using the undocumented switch /dxxx where -- xxx is a string of letters for flags to be turned on. Documentation -- on the current usage of these flags is contained in the body of Debug -- rather than the spec, so that we don't have to recompile the world --- 36,52 ---- pragma Preelaborate (Debug); -- This package contains global flags used to control the inclusion ! -- of debugging code in various phases of the compiler. Some of these ! -- flags are also used by the binder and gnatmake. ------------------------- -- Dynamic Debug Flags -- ------------------------- ! -- Sixty two flags that can be used to active various specialized -- debugging output information. The flags are preset to False, which -- corresponds to the given output being suppressed. The individual ! -- flags can be turned on using the undocumented switch dxxx where -- xxx is a string of letters for flags to be turned on. Documentation -- on the current usage of these flags is contained in the body of Debug -- rather than the spec, so that we don't have to recompile the world diff -Nrc3pad gcc-3.2.3/gcc/ada/dec.ads gcc-3.3/gcc/ada/dec.ads *** gcc-3.2.3/gcc/ada/dec.ads 2002-05-04 03:27:38.000000000 +0000 --- gcc-3.3/gcc/ada/dec.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/dec-io.adb gcc-3.3/gcc/ada/dec-io.adb *** gcc-3.2.3/gcc/ada/dec-io.adb 2002-05-04 03:27:38.000000000 +0000 --- gcc-3.3/gcc/ada/dec-io.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/dec-io.ads gcc-3.3/gcc/ada/dec-io.ads *** gcc-3.2.3/gcc/ada/dec-io.ads 2002-05-04 03:27:38.000000000 +0000 --- gcc-3.3/gcc/ada/dec-io.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/decl.c gcc-3.3/gcc/ada/decl.c *** gcc-3.2.3/gcc/ada/decl.c 2002-05-04 03:27:38.000000000 +0000 --- gcc-3.3/gcc/ada/decl.c 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** * * * C Implementation File * * * - * $Revision: 1.9.10.1 $ * * ! * Copyright (C) 1992-2001, 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- * --- 6,13 ---- * * * C Implementation File * * * * * ! * Copyright (C) 1992-2002, 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- * *************** static void components_to_record PARAMS *** 100,106 **** static int compare_field_bitpos PARAMS ((const PTR, const PTR)); static Uint annotate_value PARAMS ((tree)); static void annotate_rep PARAMS ((Entity_Id, tree)); ! static tree compute_field_positions PARAMS ((tree, tree, tree, tree)); static tree validate_size PARAMS ((Uint, tree, Entity_Id, enum tree_code, int, int)); static void set_rm_size PARAMS ((Uint, tree, Entity_Id)); --- 99,106 ---- static int compare_field_bitpos PARAMS ((const PTR, const PTR)); static Uint annotate_value PARAMS ((tree)); static void annotate_rep PARAMS ((Entity_Id, tree)); ! static tree compute_field_positions PARAMS ((tree, tree, tree, tree, ! unsigned int)); static tree validate_size PARAMS ((Uint, tree, Entity_Id, enum tree_code, int, int)); static void set_rm_size PARAMS ((Uint, tree, Entity_Id)); *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 579,596 **** if (TREE_CODE (gnu_size) != INTEGER_CST && contains_placeholder_p (gnu_size)) { ! tree gnu_temp = gnu_expr; ! ! /* Strip off any conversions in GNU_EXPR since ! they can't be changing the size to allocate. */ ! while (TREE_CODE (gnu_temp) == UNCHECKED_CONVERT_EXPR) ! gnu_temp = TREE_OPERAND (gnu_temp, 0); ! ! gnu_size = TYPE_SIZE (TREE_TYPE (gnu_temp)); if (TREE_CODE (gnu_size) != INTEGER_CST && contains_placeholder_p (gnu_size)) gnu_size = build (WITH_RECORD_EXPR, bitsizetype, ! gnu_size, gnu_temp); } } --- 579,589 ---- if (TREE_CODE (gnu_size) != INTEGER_CST && contains_placeholder_p (gnu_size)) { ! gnu_size = TYPE_SIZE (TREE_TYPE (gnu_expr)); if (TREE_CODE (gnu_size) != INTEGER_CST && contains_placeholder_p (gnu_size)) gnu_size = build (WITH_RECORD_EXPR, bitsizetype, ! gnu_size, gnu_expr); } } *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 687,692 **** --- 680,694 ---- check_ok_for_atomic (gnu_inner, gnat_entity, 1); } + /* Now check if the type of the object allows atomic access. Note + that we must test the type, even if this object has size and + alignment to allow such access, because we will be going + inside the padded record to assign to the object. We could fix + this by always copying via an intermediate value, but it's not + clear it's worth the effort. */ + if (Is_Atomic (gnat_entity)) + check_ok_for_atomic (gnu_type, gnat_entity, 0); + /* Make a new type with the desired size and alignment, if needed. */ gnu_type = maybe_pad_type (gnu_type, gnu_size, align, gnat_entity, "PAD", 0, definition, 1); *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 1042,1061 **** || Address_Taken (gnat_entity) || Is_Aliased (gnat_entity) || Is_Aliased (Etype (gnat_entity)))) ! DECL_CONST_CORRESPONDING_VAR (gnu_decl) ! = create_var_decl (gnu_entity_id, gnu_ext_name, gnu_type, gnu_expr, 0, Is_Public (gnat_entity), 0, ! static_p, 0); ! ! if (Is_Atomic (gnat_entity)) ! check_ok_for_atomic (gnu_decl, gnat_entity, 0); /* If this is declared in a block that contains an block with an exception handler, we must force this variable in memory to suppress an invalid optimization. */ ! if (Has_Nested_Block_With_Handler (Scope (gnat_entity))) { ! mark_addressable (gnu_decl); flush_addressof (gnu_decl); } --- 1044,1061 ---- || Address_Taken (gnat_entity) || Is_Aliased (gnat_entity) || Is_Aliased (Etype (gnat_entity)))) ! SET_DECL_CONST_CORRESPONDING_VAR (gnu_decl, ! create_var_decl (gnu_entity_id, gnu_ext_name, gnu_type, gnu_expr, 0, Is_Public (gnat_entity), 0, ! static_p, 0)); /* If this is declared in a block that contains an block with an exception handler, we must force this variable in memory to suppress an invalid optimization. */ ! if (Has_Nested_Block_With_Handler (Scope (gnat_entity)) ! && Exception_Mechanism != GCC_ZCX) { ! gnat_mark_addressable (gnu_decl); flush_addressof (gnu_decl); } *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 1184,1190 **** if (! integer_zerop (gnu_modulus)) { TYPE_MODULAR_P (gnu_type) = 1; ! TYPE_MODULUS (gnu_type) = gnu_modulus; gnu_high = fold (build (MINUS_EXPR, gnu_type, gnu_modulus, convert (gnu_type, integer_one_node))); } --- 1184,1190 ---- if (! integer_zerop (gnu_modulus)) { TYPE_MODULAR_P (gnu_type) = 1; ! SET_TYPE_MODULUS (gnu_type, gnu_modulus); gnu_high = fold (build (MINUS_EXPR, gnu_type, gnu_modulus, convert (gnu_type, integer_one_node))); } *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 1308,1314 **** gnu_field_type, gnu_type, 1, 0, 0, 1), finish_record_type (gnu_type, gnu_field, 0, 0); TYPE_LEFT_JUSTIFIED_MODULAR_P (gnu_type) = 1; ! TYPE_ADA_SIZE (gnu_type) = bitsize_int (esize); } break; --- 1308,1314 ---- gnu_field_type, gnu_type, 1, 0, 0, 1), finish_record_type (gnu_type, gnu_field, 0, 0); TYPE_LEFT_JUSTIFIED_MODULAR_P (gnu_type) = 1; ! SET_TYPE_ADA_SIZE (gnu_type, bitsize_int (esize)); } break; *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 1320,1327 **** { gnu_type = make_signed_type (esize); TYPE_VAX_FLOATING_POINT_P (gnu_type) = 1; ! TYPE_DIGITS_VALUE (gnu_type) ! = UI_To_Int (Digits_Value (gnat_entity)); break; } --- 1320,1327 ---- { gnu_type = make_signed_type (esize); TYPE_VAX_FLOATING_POINT_P (gnu_type) = 1; ! SET_TYPE_DIGITS_VALUE (gnu_type, ! UI_To_Int (Digits_Value (gnat_entity))); break; } *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 1619,1636 **** = TYPE_REFERENCE_TO (gnu_type) = gnu_fat_type; TYPE_MODE (gnu_type) = BLKmode; TYPE_ALIGN (gnu_type) = TYPE_ALIGN (tem); ! TYPE_UNCONSTRAINED_ARRAY (gnu_fat_type) = gnu_type; /* If the maximum size doesn't overflow, use it. */ if (TREE_CODE (gnu_max_size) == INTEGER_CST && ! TREE_OVERFLOW (gnu_max_size)) ! { ! TYPE_SIZE (tem) ! = size_binop (MIN_EXPR, gnu_max_size, TYPE_SIZE (tem)); ! TYPE_SIZE_UNIT (tem) ! = size_binop (MIN_EXPR, gnu_max_size_unit, ! TYPE_SIZE_UNIT (tem)); ! } create_type_decl (create_concat_name (gnat_entity, "XUA"), tem, 0, ! Comes_From_Source (gnat_entity), --- 1619,1636 ---- = TYPE_REFERENCE_TO (gnu_type) = gnu_fat_type; TYPE_MODE (gnu_type) = BLKmode; TYPE_ALIGN (gnu_type) = TYPE_ALIGN (tem); ! SET_TYPE_UNCONSTRAINED_ARRAY (gnu_fat_type, gnu_type); /* If the maximum size doesn't overflow, use it. */ if (TREE_CODE (gnu_max_size) == INTEGER_CST && ! TREE_OVERFLOW (gnu_max_size)) ! TYPE_SIZE (tem) ! = size_binop (MIN_EXPR, gnu_max_size, TYPE_SIZE (tem)); ! if (TREE_CODE (gnu_max_size_unit) == INTEGER_CST ! && ! TREE_OVERFLOW (gnu_max_size_unit)) ! TYPE_SIZE_UNIT (tem) ! = size_binop (MIN_EXPR, gnu_max_size_unit, ! TYPE_SIZE_UNIT (tem)); create_type_decl (create_concat_name (gnat_entity, "XUA"), tem, 0, ! Comes_From_Source (gnat_entity), *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 1647,1653 **** DECL_FIELD_OFFSET (TREE_CHAIN (TYPE_FIELDS (tem))) = size_zero_node; DECL_FIELD_BIT_OFFSET (TREE_CHAIN (TYPE_FIELDS (tem))) = bitsize_zero_node; ! TYPE_UNCONSTRAINED_ARRAY (tem) = gnu_type; TYPE_OBJECT_RECORD_TYPE (gnu_type) = tem; /* Give the thin pointer type a name. */ --- 1647,1653 ---- DECL_FIELD_OFFSET (TREE_CHAIN (TYPE_FIELDS (tem))) = size_zero_node; DECL_FIELD_BIT_OFFSET (TREE_CHAIN (TYPE_FIELDS (tem))) = bitsize_zero_node; ! SET_TYPE_UNCONSTRAINED_ARRAY (tem, gnu_type); TYPE_OBJECT_RECORD_TYPE (gnu_type) = tem; /* Give the thin pointer type a name. */ *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 1977,1982 **** --- 1977,1984 ---- && contains_placeholder_p (TYPE_SIZE (gnu_type)) && ! (TREE_CODE (gnu_max_size) == INTEGER_CST && TREE_OVERFLOW (gnu_max_size)) + && ! (TREE_CODE (gnu_max_size_unit) == INTEGER_CST + && TREE_OVERFLOW (gnu_max_size_unit)) && ! max_overflow) { TYPE_SIZE (gnu_type) = size_binop (MIN_EXPR, gnu_max_size, *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2023,2031 **** gnu_inner_type = gnu_type = TREE_TYPE (gnu_decl); save_gnu_tree (gnat_entity, NULL_TREE, 0); ! if (TREE_CODE (gnu_inner_type) == RECORD_TYPE ! && (TYPE_LEFT_JUSTIFIED_MODULAR_P (gnu_inner_type) ! || TYPE_IS_PADDING_P (gnu_inner_type))) gnu_inner_type = TREE_TYPE (TYPE_FIELDS (gnu_inner_type)); /* We need to point the type we just made to our index type so --- 2025,2033 ---- gnu_inner_type = gnu_type = TREE_TYPE (gnu_decl); save_gnu_tree (gnat_entity, NULL_TREE, 0); ! while (TREE_CODE (gnu_inner_type) == RECORD_TYPE ! && (TYPE_LEFT_JUSTIFIED_MODULAR_P (gnu_inner_type) ! || TYPE_IS_PADDING_P (gnu_inner_type))) gnu_inner_type = TREE_TYPE (TYPE_FIELDS (gnu_inner_type)); /* We need to point the type we just made to our index type so *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2064,2081 **** TYPE_HAS_ACTUAL_BOUNDS_P (gnu_inner_type) = 1; } ! TYPE_ACTUAL_BOUNDS (gnu_inner_type) = NULL_TREE; for (gnat_index = First_Index (gnat_entity); Present (gnat_index); gnat_index = Next_Index (gnat_index)) ! TYPE_ACTUAL_BOUNDS (gnu_inner_type) ! = tree_cons (NULL_TREE, get_unpadded_type (Etype (gnat_index)), ! TYPE_ACTUAL_BOUNDS (gnu_inner_type)); if (Convention (gnat_entity) != Convention_Fortran) ! TYPE_ACTUAL_BOUNDS (gnu_inner_type) ! = nreverse (TYPE_ACTUAL_BOUNDS (gnu_inner_type)); if (TREE_CODE (gnu_type) == RECORD_TYPE && TYPE_LEFT_JUSTIFIED_MODULAR_P (gnu_type)) --- 2066,2083 ---- TYPE_HAS_ACTUAL_BOUNDS_P (gnu_inner_type) = 1; } ! SET_TYPE_ACTUAL_BOUNDS (gnu_inner_type, NULL_TREE); for (gnat_index = First_Index (gnat_entity); Present (gnat_index); gnat_index = Next_Index (gnat_index)) ! SET_TYPE_ACTUAL_BOUNDS (gnu_inner_type, ! tree_cons (NULL_TREE, get_unpadded_type (Etype (gnat_index)), ! TYPE_ACTUAL_BOUNDS (gnu_inner_type))); if (Convention (gnat_entity) != Convention_Fortran) ! SET_TYPE_ACTUAL_BOUNDS (gnu_inner_type, ! nreverse (TYPE_ACTUAL_BOUNDS (gnu_inner_type))); if (TREE_CODE (gnu_type) == RECORD_TYPE && TYPE_LEFT_JUSTIFIED_MODULAR_P (gnu_type)) *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2152,2158 **** the tree. */ case E_Record_Type: - #if 0 if (Has_Complex_Representation (gnat_entity)) { gnu_type --- 2154,2159 ---- *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2164,2176 **** (Type_Definition (Declaration_Node (gnat_entity))))))))); ! /* ??? For now, don't use Complex if the real type is shorter than ! a word. */ ! if (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (gnu_type))) ! >= BITS_PER_WORD) ! break; } - #endif { Node_Id full_definition = Declaration_Node (gnat_entity); --- 2165,2173 ---- (Type_Definition (Declaration_Node (gnat_entity))))))))); ! ! break; } { Node_Id full_definition = Declaration_Node (gnat_entity); *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2469,2475 **** tree gnu_field_list = 0; tree gnu_pos_list = compute_field_positions (gnu_orig_type, NULL_TREE, ! size_zero_node, bitsize_zero_node); tree gnu_subst_list = substitution_list (gnat_entity, gnat_base_type, NULL_TREE, definition); --- 2466,2473 ---- tree gnu_field_list = 0; tree gnu_pos_list = compute_field_positions (gnu_orig_type, NULL_TREE, ! size_zero_node, bitsize_zero_node, ! BIGGEST_ALIGNMENT); tree gnu_subst_list = substitution_list (gnat_entity, gnat_base_type, NULL_TREE, definition); *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2485,2491 **** gnu_pos_list = compute_field_positions (gnat_to_gnu_type (Etype (gnat_root_type)), ! gnu_pos_list, size_zero_node, bitsize_zero_node); if (Present (Parent_Subtype (gnat_root_type))) gnu_subst_list --- 2483,2490 ---- gnu_pos_list = compute_field_positions (gnat_to_gnu_type (Etype (gnat_root_type)), ! gnu_pos_list, size_zero_node, bitsize_zero_node, ! BIGGEST_ALIGNMENT); if (Present (Parent_Subtype (gnat_root_type))) gnu_subst_list *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2511,2521 **** = TREE_VALUE (purpose_member (gnu_old_field, gnu_pos_list)); tree gnu_pos = TREE_PURPOSE (gnu_offset); ! tree gnu_bitpos = TREE_VALUE (gnu_offset); tree gnu_field_type = gnat_to_gnu_type (Etype (gnat_field)); tree gnu_size = TYPE_SIZE (gnu_field_type); tree gnu_new_pos = 0; tree gnu_field; /* If there was a component clause, the field types must be --- 2510,2523 ---- = TREE_VALUE (purpose_member (gnu_old_field, gnu_pos_list)); tree gnu_pos = TREE_PURPOSE (gnu_offset); ! tree gnu_bitpos = TREE_VALUE (TREE_VALUE (gnu_offset)); tree gnu_field_type = gnat_to_gnu_type (Etype (gnat_field)); tree gnu_size = TYPE_SIZE (gnu_field_type); tree gnu_new_pos = 0; + unsigned int offset_align + = tree_low_cst (TREE_PURPOSE (TREE_VALUE (gnu_offset)), + 1); tree gnu_field; /* If there was a component clause, the field types must be *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2561,2572 **** if (! TREE_CONSTANT (gnu_pos)) { ! normalize_offset (&gnu_pos, &gnu_bitpos, ! DECL_OFFSET_ALIGN (gnu_old_field)); DECL_FIELD_OFFSET (gnu_field) = gnu_pos; DECL_FIELD_BIT_OFFSET (gnu_field) = gnu_bitpos; ! SET_DECL_OFFSET_ALIGN ! (gnu_field, DECL_OFFSET_ALIGN (gnu_old_field)); DECL_SIZE (gnu_field) = gnu_size; DECL_SIZE_UNIT (gnu_field) = convert (sizetype, --- 2563,2572 ---- if (! TREE_CONSTANT (gnu_pos)) { ! normalize_offset (&gnu_pos, &gnu_bitpos, offset_align); DECL_FIELD_OFFSET (gnu_field) = gnu_pos; DECL_FIELD_BIT_OFFSET (gnu_field) = gnu_bitpos; ! SET_DECL_OFFSET_ALIGN (gnu_field, offset_align); DECL_SIZE (gnu_field) = gnu_size; DECL_SIZE_UNIT (gnu_field) = convert (sizetype, *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2577,2585 **** DECL_INTERNAL_P (gnu_field) = DECL_INTERNAL_P (gnu_old_field); ! DECL_ORIGINAL_FIELD (gnu_field) ! = DECL_ORIGINAL_FIELD (gnu_old_field) != 0 ! ? DECL_ORIGINAL_FIELD (gnu_old_field) : gnu_old_field; DECL_DISCRIMINANT_NUMBER (gnu_field) = DECL_DISCRIMINANT_NUMBER (gnu_old_field); TREE_THIS_VOLATILE (gnu_field) --- 2577,2586 ---- DECL_INTERNAL_P (gnu_field) = DECL_INTERNAL_P (gnu_old_field); ! SET_DECL_ORIGINAL_FIELD (gnu_field, ! (DECL_ORIGINAL_FIELD (gnu_old_field) != 0 ! ? DECL_ORIGINAL_FIELD (gnu_old_field) ! : gnu_old_field)); DECL_DISCRIMINANT_NUMBER (gnu_field) = DECL_DISCRIMINANT_NUMBER (gnu_old_field); TREE_THIS_VOLATILE (gnu_field) *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2598,2604 **** TYPE_ALIGN (gnu_type) = TYPE_ALIGN (gnu_base_type); TYPE_SIZE (gnu_type) = TYPE_SIZE (gnu_base_type); TYPE_SIZE_UNIT (gnu_type) = TYPE_SIZE_UNIT (gnu_base_type); ! TYPE_ADA_SIZE (gnu_type) = TYPE_ADA_SIZE (gnu_base_type); if (TREE_CODE (TYPE_SIZE (gnu_type)) != INTEGER_CST && contains_placeholder_p (TYPE_SIZE (gnu_type))) --- 2599,2605 ---- TYPE_ALIGN (gnu_type) = TYPE_ALIGN (gnu_base_type); TYPE_SIZE (gnu_type) = TYPE_SIZE (gnu_base_type); TYPE_SIZE_UNIT (gnu_type) = TYPE_SIZE_UNIT (gnu_base_type); ! SET_TYPE_ADA_SIZE (gnu_type, TYPE_ADA_SIZE (gnu_base_type)); if (TREE_CODE (TYPE_SIZE (gnu_type)) != INTEGER_CST && contains_placeholder_p (TYPE_SIZE (gnu_type))) *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2623,2632 **** && contains_placeholder_p (TYPE_ADA_SIZE (gnu_type))) for (gnu_temp = gnu_subst_list; gnu_temp; gnu_temp = TREE_CHAIN (gnu_temp)) ! TYPE_ADA_SIZE (gnu_type) ! = substitute_in_expr (TYPE_ADA_SIZE (gnu_type), TREE_PURPOSE (gnu_temp), ! TREE_VALUE (gnu_temp)); /* Recompute the mode of this record type now that we know its actual size. */ --- 2624,2633 ---- && contains_placeholder_p (TYPE_ADA_SIZE (gnu_type))) for (gnu_temp = gnu_subst_list; gnu_temp; gnu_temp = TREE_CHAIN (gnu_temp)) ! SET_TYPE_ADA_SIZE (gnu_type, ! substitute_in_expr (TYPE_ADA_SIZE (gnu_type), TREE_PURPOSE (gnu_temp), ! TREE_VALUE (gnu_temp))); /* Recompute the mode of this record type now that we know its actual size. */ *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2763,2768 **** --- 2764,2777 ---- && ! Is_Constrained (gnat_desig_full)) gnat_desig_full = Etype (gnat_desig_full); + /* If the designated type is a subtype of an incomplete record type, + use the parent type to avoid order of elaboration issues. This + can lose some code efficiency, but there is no alternative. */ + if (Present (gnat_desig_full) + && Ekind (gnat_desig_full) == E_Record_Subtype + && Ekind (Etype (gnat_desig_full)) == E_Record_Type) + gnat_desig_full = Etype (gnat_desig_full); + /* If we are pointing to an incomplete type whose completion is an unconstrained array, make a fat pointer type instead of a pointer to VOID. The two types in our fields will be pointers to VOID and *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 2808,2814 **** if (gnu_type == 0) { gnu_type = make_node (RECORD_TYPE); ! TYPE_UNCONSTRAINED_ARRAY (gnu_type) = gnu_old; TYPE_POINTER_TO (gnu_old) = gnu_type; set_lineno (gnat_entity, 0); --- 2817,2823 ---- if (gnu_type == 0) { gnu_type = make_node (RECORD_TYPE); ! SET_TYPE_UNCONSTRAINED_ARRAY (gnu_type, gnu_old); TYPE_POINTER_TO (gnu_old) = gnu_type; set_lineno (gnat_entity, 0); *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 3416,3422 **** if (Present (Interface_Name (gnat_entity)) || ! (Is_Imported (gnat_entity) || Is_Exported (gnat_entity))) ! gnu_ext_name = create_concat_name (gnat_entity, 0); set_lineno (gnat_entity, 0); --- 3425,3443 ---- if (Present (Interface_Name (gnat_entity)) || ! (Is_Imported (gnat_entity) || Is_Exported (gnat_entity))) ! { ! gnu_ext_name = create_concat_name (gnat_entity, 0); ! ! /* If there wasn't a specified Interface_Name, use this for the ! main name of the entity. This will cause GCC to allow ! qualification of a nested subprogram with a unique ID. We ! need this in case there is an overloaded subprogram somewhere ! up the scope chain. ! ! ??? This may be a kludge. */ ! if (No (Interface_Name (gnat_entity))) ! gnu_entity_id = gnu_ext_name; ! } set_lineno (gnat_entity, 0); *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 3579,3585 **** if ((gnu_decl == 0 || this_made_decl) && IN (kind, Type_Kind)) { if (Is_Tagged_Type (gnat_entity)) ! TYPE_ALIGN_OK_P (gnu_type) = 1; if (AGGREGATE_TYPE_P (gnu_type) && Is_By_Reference_Type (gnat_entity)) TYPE_BY_REFERENCE_P (gnu_type) = 1; --- 3600,3606 ---- if ((gnu_decl == 0 || this_made_decl) && IN (kind, Type_Kind)) { if (Is_Tagged_Type (gnat_entity)) ! TYPE_ALIGN_OK (gnu_type) = 1; if (AGGREGATE_TYPE_P (gnu_type) && Is_By_Reference_Type (gnat_entity)) TYPE_BY_REFERENCE_P (gnu_type) = 1; *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 3650,3677 **** if (TREE_CODE (gnu_type) == RECORD_TYPE && operand_equal_p (TYPE_ADA_SIZE (gnu_type), TYPE_SIZE (gnu_type), 0)) - TYPE_ADA_SIZE (gnu_type) = TYPE_SIZE (gnu_type) - = elaborate_expression_1 (gnat_entity, gnat_entity, - TYPE_SIZE (gnu_type), - get_identifier ("SIZE"), - definition, 0); - else if (TREE_CODE (gnu_type) == RECORD_TYPE) { - TYPE_ADA_SIZE (gnu_type) - = elaborate_expression_1 (gnat_entity, gnat_entity, - TYPE_ADA_SIZE (gnu_type), - get_identifier ("RM_SIZE"), - definition, 0); TYPE_SIZE (gnu_type) = elaborate_expression_1 (gnat_entity, gnat_entity, TYPE_SIZE (gnu_type), get_identifier ("SIZE"), definition, 0); ! TYPE_SIZE_UNIT (gnu_type) ! = elaborate_expression_1 (gnat_entity, gnat_entity, ! TYPE_SIZE_UNIT (gnu_type), ! get_identifier ("SIZE_UNIT"), ! definition, 0); } else { --- 3671,3683 ---- if (TREE_CODE (gnu_type) == RECORD_TYPE && operand_equal_p (TYPE_ADA_SIZE (gnu_type), TYPE_SIZE (gnu_type), 0)) { TYPE_SIZE (gnu_type) = elaborate_expression_1 (gnat_entity, gnat_entity, TYPE_SIZE (gnu_type), get_identifier ("SIZE"), definition, 0); ! SET_TYPE_ADA_SIZE (gnu_type, TYPE_SIZE (gnu_type)); } else { *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 3680,3690 **** TYPE_SIZE (gnu_type), get_identifier ("SIZE"), definition, 0); TYPE_SIZE_UNIT (gnu_type) ! = elaborate_expression_1 (gnat_entity, gnat_entity, ! TYPE_SIZE_UNIT (gnu_type), ! get_identifier ("SIZE_UNIT"), ! definition, 0); } } --- 3686,3713 ---- TYPE_SIZE (gnu_type), get_identifier ("SIZE"), definition, 0); + + /* ??? For now, store the size as a multiple of the alignment + in bytes so that we can see the alignment from the tree. */ TYPE_SIZE_UNIT (gnu_type) ! = build_binary_op ! (MULT_EXPR, sizetype, ! elaborate_expression_1 ! (gnat_entity, gnat_entity, ! build_binary_op (EXACT_DIV_EXPR, sizetype, ! TYPE_SIZE_UNIT (gnu_type), ! size_int (TYPE_ALIGN (gnu_type) ! / BITS_PER_UNIT)), ! get_identifier ("SIZE_A_UNIT"), ! definition, 0), ! size_int (TYPE_ALIGN (gnu_type) / BITS_PER_UNIT)); ! ! if (TREE_CODE (gnu_type) == RECORD_TYPE) ! SET_TYPE_ADA_SIZE (gnu_type, ! elaborate_expression_1 (gnat_entity, gnat_entity, ! TYPE_ADA_SIZE (gnu_type), ! get_identifier ("RM_SIZE"), ! definition, 0)); } } *************** gnat_to_gnu_entity (gnat_entity, gnu_exp *** 3699,3711 **** { tree gnu_field = get_gnu_tree (gnat_temp); if (TREE_CODE (DECL_FIELD_OFFSET (gnu_field)) != INTEGER_CST && ! contains_placeholder_p (DECL_FIELD_OFFSET (gnu_field))) DECL_FIELD_OFFSET (gnu_field) ! = elaborate_expression_1 (gnat_temp, gnat_temp, ! DECL_FIELD_OFFSET (gnu_field), ! get_identifier ("OFFSET"), ! definition, 0); } gnu_type = build_qualified_type (gnu_type, --- 3722,3746 ---- { tree gnu_field = get_gnu_tree (gnat_temp); + /* ??? Unfortunately, GCC needs to be able to prove the + alignment of this offset and if it's a variable, it can't. + In GCC 3.2, we'll use DECL_OFFSET_ALIGN in some way, but + right now, we have to put in an explicit multiply and + divide by that value. */ if (TREE_CODE (DECL_FIELD_OFFSET (gnu_field)) != INTEGER_CST && ! contains_placeholder_p (DECL_FIELD_OFFSET (gnu_field))) DECL_FIELD_OFFSET (gnu_field) ! = build_binary_op ! (MULT_EXPR, sizetype, ! elaborate_expression_1 ! (gnat_temp, gnat_temp, ! build_binary_op (EXACT_DIV_EXPR, sizetype, ! DECL_FIELD_OFFSET (gnu_field), ! size_int (DECL_OFFSET_ALIGN (gnu_field) ! / BITS_PER_UNIT)), ! get_identifier ("OFFSET"), ! definition, 0), ! size_int (DECL_OFFSET_ALIGN (gnu_field) / BITS_PER_UNIT)); } gnu_type = build_qualified_type (gnu_type, *************** substitution_list (gnat_subtype, gnat_ty *** 4009,4015 **** /* For the following two functions: for each GNAT entity, the GCC tree node used as a dummy for that entity, if any. */ ! static tree *dummy_node_table; /* Initialize the above table. */ --- 4044,4050 ---- /* For the following two functions: for each GNAT entity, the GCC tree node used as a dummy for that entity, if any. */ ! static GTY((length ("max_gnat_nodes"))) tree * dummy_node_table; /* Initialize the above table. */ *************** init_dummy_type () *** 4018,4025 **** { Node_Id gnat_node; ! dummy_node_table = (tree *) xmalloc (max_gnat_nodes * sizeof (tree)); ! ggc_add_tree_root (dummy_node_table, max_gnat_nodes); for (gnat_node = 0; gnat_node < max_gnat_nodes; gnat_node++) dummy_node_table[gnat_node] = NULL_TREE; --- 4053,4059 ---- { Node_Id gnat_node; ! dummy_node_table = (tree *) ggc_alloc (max_gnat_nodes * sizeof (tree)); for (gnat_node = 0; gnat_node < max_gnat_nodes; gnat_node++) dummy_node_table[gnat_node] = NULL_TREE; *************** elaborate_expression_1 (gnat_expr, gnat_ *** 4267,4282 **** int need_debug; { tree gnu_decl = 0; - tree gnu_inner_expr = gnu_expr; - int expr_variable; - int expr_global = Is_Public (gnat_entity) || global_bindings_p (); - /* Strip any conversions to see if the expression is a readonly variable. ??? This really should remain readonly, but we have to think about the typing of the tree here. */ ! while (TREE_CODE (gnu_inner_expr) == NOP_EXPR ! && TREE_CODE (gnu_inner_expr) == CONVERT_EXPR) ! gnu_inner_expr = TREE_OPERAND (gnu_inner_expr, 0); /* In most cases, we won't see a naked FIELD_DECL here because a discriminant reference will have been replaced with a COMPONENT_REF --- 4301,4312 ---- int need_debug; { tree gnu_decl = 0; /* Strip any conversions to see if the expression is a readonly variable. ??? This really should remain readonly, but we have to think about the typing of the tree here. */ ! tree gnu_inner_expr = remove_conversions (gnu_expr, 1); ! int expr_global = Is_Public (gnat_entity) || global_bindings_p (); ! int expr_variable; /* In most cases, we won't see a naked FIELD_DECL here because a discriminant reference will have been replaced with a COMPONENT_REF *************** elaborate_expression_1 (gnat_expr, gnat_ *** 4326,4331 **** --- 4356,4363 ---- can do the right thing in the local case. */ if (expr_global && expr_variable) return gnu_decl; + else if (! expr_variable) + return gnu_expr; else return maybe_variable (gnu_expr, gnat_expr); } *************** make_packable_type (type) *** 4418,4426 **** ! DECL_NONADDRESSABLE_P (old_field)); DECL_INTERNAL_P (new_field) = DECL_INTERNAL_P (old_field); ! DECL_ORIGINAL_FIELD (new_field) ! = (DECL_ORIGINAL_FIELD (old_field) != 0 ! ? DECL_ORIGINAL_FIELD (old_field) : old_field); TREE_CHAIN (new_field) = field_list; field_list = new_field; } --- 4450,4458 ---- ! DECL_NONADDRESSABLE_P (old_field)); DECL_INTERNAL_P (new_field) = DECL_INTERNAL_P (old_field); ! SET_DECL_ORIGINAL_FIELD (new_field, ! (DECL_ORIGINAL_FIELD (old_field) != 0 ! ? DECL_ORIGINAL_FIELD (old_field) : old_field)); TREE_CHAIN (new_field) = field_list; field_list = new_field; } *************** maybe_pad_type (type, size, align, gnat_ *** 4554,4560 **** /* Keep the RM_Size of the padded record as that of the old record if requested. */ ! TYPE_ADA_SIZE (record) = same_rm_size ? size : rm_size (type); /* Unless debugging information isn't being written for the input type, write a record that shows what we are a subtype of and also make a --- 4586,4592 ---- /* Keep the RM_Size of the padded record as that of the old record if requested. */ ! SET_TYPE_ADA_SIZE (record, same_rm_size ? size : rm_size (type)); /* Unless debugging information isn't being written for the input type, write a record that shows what we are a subtype of and also make a *************** gnat_to_gnu_field (gnat_field, gnu_recor *** 4757,4771 **** gnu_size = validate_size (Esize (gnat_field), gnu_field_type, gnat_field, FIELD_DECL, 0, 1); ! /* If we are packing this record and the field type is also a record that's BLKmode and with a small constant size, see if we can get a better form of the type that allows more packing. If we can, show a size was specified for it if there wasn't one so we know to make this a bitfield and avoid making things wider. */ ! if (packed && TREE_CODE (gnu_field_type) == RECORD_TYPE && TYPE_MODE (gnu_field_type) == BLKmode && host_integerp (TYPE_SIZE (gnu_field_type), 1) ! && compare_tree_int (TYPE_SIZE (gnu_field_type), BIGGEST_ALIGNMENT) <= 0) { gnu_field_type = make_packable_type (gnu_field_type); --- 4789,4814 ---- gnu_size = validate_size (Esize (gnat_field), gnu_field_type, gnat_field, FIELD_DECL, 0, 1); ! /* If the field's type is a left-justified modular type, make the field ! the type of the inner object unless it is aliases. We don't need ! the the wrapper here and it can prevent packing. */ ! if (! Is_Aliased (gnat_field) && TREE_CODE (gnu_field_type) == RECORD_TYPE ! && TYPE_LEFT_JUSTIFIED_MODULAR_P (gnu_field_type)) ! gnu_field_type = TREE_TYPE (TYPE_FIELDS (gnu_field_type)); ! ! /* If we are packing this record or we have a specified size that's ! smaller than that of the field type and the field type is also a record that's BLKmode and with a small constant size, see if we can get a better form of the type that allows more packing. If we can, show a size was specified for it if there wasn't one so we know to make this a bitfield and avoid making things wider. */ ! if (TREE_CODE (gnu_field_type) == RECORD_TYPE && TYPE_MODE (gnu_field_type) == BLKmode && host_integerp (TYPE_SIZE (gnu_field_type), 1) ! && compare_tree_int (TYPE_SIZE (gnu_field_type), BIGGEST_ALIGNMENT) <= 0 ! && (packed ! || (gnu_size != 0 && tree_int_cst_lt (gnu_size, ! TYPE_SIZE (gnu_field_type))))) { gnu_field_type = make_packable_type (gnu_field_type); *************** gnat_to_gnu_field (gnat_field, gnu_recor *** 4839,4845 **** if (Is_Aliased (gnat_field)) post_error_ne_num ("position of aliased field& must be multiple of ^ bits", ! Component_Clause (gnat_field), gnat_field, TYPE_ALIGN (gnu_field_type)); else if (Is_Volatile (gnat_field)) --- 4882,4888 ---- if (Is_Aliased (gnat_field)) post_error_ne_num ("position of aliased field& must be multiple of ^ bits", ! First_Bit (Component_Clause (gnat_field)), gnat_field, TYPE_ALIGN (gnu_field_type)); else if (Is_Volatile (gnat_field)) *************** gnat_to_gnu_field (gnat_field, gnu_recor *** 4897,4909 **** } /* We need to make the size the maximum for the type if it is ! self-referential and an unconstrained type. */ if (TREE_CODE (gnu_field_type) == RECORD_TYPE && gnu_size == 0 && ! TREE_CONSTANT (TYPE_SIZE (gnu_field_type)) && contains_placeholder_p (TYPE_SIZE (gnu_field_type)) && ! Is_Constrained (Underlying_Type (Etype (gnat_field)))) ! gnu_size = max_size (TYPE_SIZE (gnu_field_type), 1); /* If no size is specified (or if there was an error), don't specify a position. */ --- 4940,4956 ---- } /* We need to make the size the maximum for the type if it is ! self-referential and an unconstrained type. In that case, we can't ! pack the field since we can't make a copy to align it. */ if (TREE_CODE (gnu_field_type) == RECORD_TYPE && gnu_size == 0 && ! TREE_CONSTANT (TYPE_SIZE (gnu_field_type)) && contains_placeholder_p (TYPE_SIZE (gnu_field_type)) && ! Is_Constrained (Underlying_Type (Etype (gnat_field)))) ! { ! gnu_size = max_size (TYPE_SIZE (gnu_field_type), 1); ! packed = 0; ! } /* If no size is specified (or if there was an error), don't specify a position. */ *************** annotate_rep (gnat_entity, gnu_type) *** 5383,5389 **** (we can get the sizes easily at any time) by a recursive call and then update all the sizes into the tree. */ gnu_list = compute_field_positions (gnu_type, NULL_TREE, ! size_zero_node, bitsize_zero_node); for (gnat_field = First_Entity (gnat_entity); Present (gnat_field); gnat_field = Next_Entity (gnat_field)) --- 5430,5437 ---- (we can get the sizes easily at any time) by a recursive call and then update all the sizes into the tree. */ gnu_list = compute_field_positions (gnu_type, NULL_TREE, ! size_zero_node, bitsize_zero_node, ! BIGGEST_ALIGNMENT); for (gnat_field = First_Entity (gnat_entity); Present (gnat_field); gnat_field = Next_Entity (gnat_field)) *************** annotate_rep (gnat_entity, gnu_type) *** 5398,5422 **** (gnat_field, annotate_value (bit_from_pos (TREE_PURPOSE (TREE_VALUE (gnu_entry)), ! TREE_VALUE (TREE_VALUE (gnu_entry))))); Set_Esize (gnat_field, annotate_value (DECL_SIZE (TREE_PURPOSE (gnu_entry)))); } } ! /* Scan all fields in GNU_TYPE and build entries where TREE_PURPOSE is ! the FIELD_DECL and TREE_VALUE a TREE_LIST with TREE_PURPOSE being the ! byte position and TREE_VALUE being the bit position. GNU_POS is to ! be added to the position, GNU_BITPOS to the bit position, and GNU_LIST ! is the entries so far. */ static tree ! compute_field_positions (gnu_type, gnu_list, gnu_pos, gnu_bitpos) tree gnu_type; tree gnu_list; tree gnu_pos; tree gnu_bitpos; { tree gnu_field; tree gnu_result = gnu_list; --- 5446,5474 ---- (gnat_field, annotate_value (bit_from_pos (TREE_PURPOSE (TREE_VALUE (gnu_entry)), ! TREE_VALUE (TREE_VALUE ! (TREE_VALUE (gnu_entry)))))); Set_Esize (gnat_field, annotate_value (DECL_SIZE (TREE_PURPOSE (gnu_entry)))); } } ! /* Scan all fields in GNU_TYPE and build entries where TREE_PURPOSE is the ! FIELD_DECL and TREE_VALUE a TREE_LIST with TREE_PURPOSE being the byte ! position and TREE_VALUE being a TREE_LIST with TREE_PURPOSE the value to be ! placed into DECL_OFFSET_ALIGN and TREE_VALUE the bit position. GNU_POS is ! to be added to the position, GNU_BITPOS to the bit position, OFFSET_ALIGN is ! the present value of DECL_OFFSET_ALIGN and GNU_LIST is a list of the entries ! so far. */ static tree ! compute_field_positions (gnu_type, gnu_list, gnu_pos, gnu_bitpos, offset_align) tree gnu_type; tree gnu_list; tree gnu_pos; tree gnu_bitpos; + unsigned int offset_align; { tree gnu_field; tree gnu_result = gnu_list; *************** compute_field_positions (gnu_type, gnu_l *** 5426,5443 **** { tree gnu_our_bitpos = size_binop (PLUS_EXPR, gnu_bitpos, DECL_FIELD_BIT_OFFSET (gnu_field)); ! tree gnu_our_pos = size_binop (PLUS_EXPR, gnu_pos, ! DECL_FIELD_OFFSET (gnu_field)); gnu_result = tree_cons (gnu_field, ! tree_cons (gnu_our_pos, gnu_our_bitpos, NULL_TREE), gnu_result); if (DECL_INTERNAL_P (gnu_field)) gnu_result ! = compute_field_positions (TREE_TYPE (gnu_field), ! gnu_result, gnu_our_pos, gnu_our_bitpos); } return gnu_result; --- 5478,5501 ---- { tree gnu_our_bitpos = size_binop (PLUS_EXPR, gnu_bitpos, DECL_FIELD_BIT_OFFSET (gnu_field)); ! tree gnu_our_offset = size_binop (PLUS_EXPR, gnu_pos, ! DECL_FIELD_OFFSET (gnu_field)); ! unsigned int our_offset_align ! = MIN (offset_align, DECL_OFFSET_ALIGN (gnu_field)); gnu_result = tree_cons (gnu_field, ! tree_cons (gnu_our_offset, ! tree_cons (size_int (our_offset_align), ! gnu_our_bitpos, NULL_TREE), ! NULL_TREE), gnu_result); if (DECL_INTERNAL_P (gnu_field)) gnu_result ! = compute_field_positions (TREE_TYPE (gnu_field), gnu_result, ! gnu_our_offset, gnu_our_bitpos, ! our_offset_align); } return gnu_result; *************** set_rm_size (uint_size, gnu_type, gnat_e *** 5641,5652 **** && Is_Discrete_Or_Fixed_Point_Type (gnat_entity)) TYPE_RM_SIZE_INT (gnu_type) = size; else if (TREE_CODE (gnu_type) == ENUMERAL_TYPE) ! TYPE_RM_SIZE_ENUM (gnu_type) = size; else if ((TREE_CODE (gnu_type) == RECORD_TYPE || TREE_CODE (gnu_type) == UNION_TYPE || TREE_CODE (gnu_type) == QUAL_UNION_TYPE) && ! TYPE_IS_FAT_POINTER_P (gnu_type)) ! TYPE_ADA_SIZE (gnu_type) = size; } /* Given a type TYPE, return a new type whose size is appropriate for SIZE. --- 5699,5710 ---- && Is_Discrete_Or_Fixed_Point_Type (gnat_entity)) TYPE_RM_SIZE_INT (gnu_type) = size; else if (TREE_CODE (gnu_type) == ENUMERAL_TYPE) ! SET_TYPE_RM_SIZE_ENUM (gnu_type, size); else if ((TREE_CODE (gnu_type) == RECORD_TYPE || TREE_CODE (gnu_type) == UNION_TYPE || TREE_CODE (gnu_type) == QUAL_UNION_TYPE) && ! TYPE_IS_FAT_POINTER_P (gnu_type)) ! SET_TYPE_ADA_SIZE (gnu_type, size); } /* Given a type TYPE, return a new type whose size is appropriate for SIZE. *************** validate_alignment (alignment, gnat_enti *** 5743,5748 **** --- 5801,5812 ---- if (Present (Alignment_Clause (gnat_entity))) gnat_error_node = Expression (Alignment_Clause (gnat_entity)); + /* Don't worry about checking alignment if alignment was not specified + by the source program and we already posted an error for this entity. */ + + if (Error_Posted (gnat_entity) && !Has_Alignment_Clause (gnat_entity)) + return align; + /* Within GCC, an alignment is an integer, so we must make sure a value is specified that fits in that range. Also, alignments of more than MAX_OFILE_ALIGNMENT can't be supported. */ *************** gnat_substitute_in_type (t, f, r) *** 5874,5881 **** new = build_range_type (TREE_TYPE (t), low, high); if (TYPE_INDEX_TYPE (t)) ! TYPE_INDEX_TYPE (new) ! = gnat_substitute_in_type (TYPE_INDEX_TYPE (t), f, r); return new; } --- 5938,5945 ---- new = build_range_type (TREE_TYPE (t), low, high); if (TYPE_INDEX_TYPE (t)) ! SET_TYPE_INDEX_TYPE (new, ! gnat_substitute_in_type (TYPE_INDEX_TYPE (t), f, r)); return new; } *************** gnat_substitute_in_type (t, f, r) *** 5995,6003 **** } DECL_CONTEXT (new_field) = new; ! DECL_ORIGINAL_FIELD (new_field) ! = DECL_ORIGINAL_FIELD (field) != 0 ! ? DECL_ORIGINAL_FIELD (field) : field; /* If the size of the old field was set at a constant, propagate the size in case the type's size was variable. --- 6059,6067 ---- } DECL_CONTEXT (new_field) = new; ! SET_DECL_ORIGINAL_FIELD (new_field, ! (DECL_ORIGINAL_FIELD (field) != 0 ! ? DECL_ORIGINAL_FIELD (field) : field)); /* If the size of the old field was set at a constant, propagate the size in case the type's size was variable. *************** gnat_substitute_in_type (t, f, r) *** 6060,6066 **** { TYPE_SIZE (new) = TYPE_SIZE (t); TYPE_SIZE_UNIT (new) = TYPE_SIZE_UNIT (t); ! TYPE_ADA_SIZE (new) = TYPE_ADA_SIZE (t); } return new; --- 6124,6130 ---- { TYPE_SIZE (new) = TYPE_SIZE (t); TYPE_SIZE_UNIT (new) = TYPE_SIZE_UNIT (t); ! SET_TYPE_ADA_SIZE (new, TYPE_ADA_SIZE (t)); } return new; *************** concat_id_with_name (gnu_id, suffix) *** 6148,6150 **** --- 6212,6216 ---- strcpy (Name_Buffer + len, suffix); return get_identifier (Name_Buffer); } + + #include "gt-ada-decl.h" diff -Nrc3pad gcc-3.2.3/gcc/ada/deftarg.c gcc-3.3/gcc/ada/deftarg.c *** gcc-3.2.3/gcc/ada/deftarg.c 2002-05-04 03:27:38.000000000 +0000 --- gcc-3.3/gcc/ada/deftarg.c 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * Body * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/directio.ads gcc-3.3/gcc/ada/directio.ads *** gcc-3.2.3/gcc/ada/directio.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/directio.ads 2002-03-14 10:59:07.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/einfo.adb gcc-3.3/gcc/ada/einfo.adb *** gcc-3.2.3/gcc/ada/einfo.adb 2002-05-04 03:27:38.000000000 +0000 --- gcc-3.3/gcc/ada/einfo.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Atree; use Atree; *** 40,46 **** with Namet; use Namet; with Nlists; use Nlists; with Sinfo; use Sinfo; - with Snames; use Snames; with Stand; use Stand; with Output; use Output; --- 39,44 ---- *************** package body Einfo is *** 181,188 **** -- Accept_Address Elist21 -- Default_Expr_Function Node21 -- Discriminant_Constraint Elist21 - -- Small_Value Ureal21 -- Interface_Name Node21 -- Associated_Storage_Pool Node22 -- Component_Size Uint22 --- 179,187 ---- -- Accept_Address Elist21 -- Default_Expr_Function Node21 -- Discriminant_Constraint Elist21 -- Interface_Name Node21 + -- Original_Array_Type Node21 + -- Small_Value Ureal21 -- Associated_Storage_Pool Node22 -- Component_Size Uint22 *************** package body Einfo is *** 395,402 **** -- Size_Depends_On_Discriminant Flag177 -- Is_Null_Init_Proc Flag178 -- Has_Pragma_Pure_Function Flag179 - -- (unused) Flag180 -- (unused) Flag181 -- (unused) Flag182 -- (unused) Flag183 --- 394,401 ---- -- Size_Depends_On_Discriminant Flag177 -- Is_Null_Init_Proc Flag178 -- Has_Pragma_Pure_Function Flag179 + -- Has_Pragma_Unreferenced Flag180 -- (unused) Flag181 -- (unused) Flag182 -- (unused) Flag183 *************** package body Einfo is *** 413,419 **** function Access_Disp_Table (Id : E) return E is begin pragma Assert (Is_Tagged_Type (Id)); ! return Node16 (Base_Type (Underlying_Type (Base_Type (Id)))); end Access_Disp_Table; function Actual_Subtype (Id : E) return E is --- 412,418 ---- function Access_Disp_Table (Id : E) return E is begin pragma Assert (Is_Tagged_Type (Id)); ! return Node16 (Implementation_Base_Type (Id)); end Access_Disp_Table; function Actual_Subtype (Id : E) return E is *************** package body Einfo is *** 463,469 **** function Associated_Storage_Pool (Id : E) return E is begin pragma Assert (Is_Access_Type (Id)); ! return Node22 (Id); end Associated_Storage_Pool; function Barrier_Function (Id : E) return N is --- 462,468 ---- function Associated_Storage_Pool (Id : E) return E is begin pragma Assert (Is_Access_Type (Id)); ! return Node22 (Root_Type (Id)); end Associated_Storage_Pool; function Barrier_Function (Id : E) return N is *************** package body Einfo is *** 1090,1095 **** --- 1089,1099 ---- return Flag179 (Id); end Has_Pragma_Pure_Function; + function Has_Pragma_Unreferenced (Id : E) return B is + begin + return Flag180 (Id); + end Has_Pragma_Unreferenced; + function Has_Primitive_Operations (Id : E) return B is begin pragma Assert (Is_Type (Id)); *************** package body Einfo is *** 1109,1115 **** function Has_Record_Rep_Clause (Id : E) return B is begin pragma Assert (Is_Record_Type (Id)); ! return Flag65 (Id); end Has_Record_Rep_Clause; function Has_Recursive_Call (Id : E) return B is --- 1113,1119 ---- function Has_Record_Rep_Clause (Id : E) return B is begin pragma Assert (Is_Record_Type (Id)); ! return Flag65 (Implementation_Base_Type (Id)); end Has_Record_Rep_Clause; function Has_Recursive_Call (Id : E) return B is *************** package body Einfo is *** 1131,1137 **** function Has_Specified_Layout (Id : E) return B is begin pragma Assert (Is_Type (Id)); ! return Flag100 (Id); end Has_Specified_Layout; function Has_Storage_Size_Clause (Id : E) return B is --- 1135,1141 ---- function Has_Specified_Layout (Id : E) return B is begin pragma Assert (Is_Type (Id)); ! return Flag100 (Implementation_Base_Type (Id)); end Has_Specified_Layout; function Has_Storage_Size_Clause (Id : E) return B is *************** package body Einfo is *** 1721,1726 **** --- 1725,1736 ---- return Node17 (Id); end Object_Ref; + function Original_Array_Type (Id : E) return E is + begin + pragma Assert (Is_Array_Type (Id) or else Is_Modular_Integer_Type (Id)); + return Node21 (Id); + end Original_Array_Type; + function Original_Record_Component (Id : E) return E is begin return Node22 (Id); *************** package body Einfo is *** 2241,2248 **** procedure Set_Access_Disp_Table (Id : E; V : E) is begin ! pragma Assert (Is_Tagged_Type (Id)); ! Set_Node16 (Base_Type (Id), V); end Set_Access_Disp_Table; procedure Set_Associated_Final_Chain (Id : E; V : E) is --- 2251,2258 ---- procedure Set_Access_Disp_Table (Id : E; V : E) is begin ! pragma Assert (Is_Tagged_Type (Id) and then Id = Base_Type (Id)); ! Set_Node16 (Id, V); end Set_Access_Disp_Table; procedure Set_Associated_Final_Chain (Id : E; V : E) is *************** package body Einfo is *** 2263,2269 **** procedure Set_Associated_Storage_Pool (Id : E; V : E) is begin ! pragma Assert (Is_Access_Type (Id)); Set_Node22 (Id, V); end Set_Associated_Storage_Pool; --- 2273,2279 ---- procedure Set_Associated_Storage_Pool (Id : E; V : E) is begin ! pragma Assert (Is_Access_Type (Id) and then Id = Base_Type (Id)); Set_Node22 (Id, V); end Set_Associated_Storage_Pool; *************** package body Einfo is *** 2349,2360 **** procedure Set_Component_Size (Id : E; V : U) is begin ! pragma Assert (Is_Array_Type (Id)); ! Set_Uint22 (Base_Type (Id), V); end Set_Component_Size; procedure Set_Component_Type (Id : E; V : E) is begin Set_Node20 (Id, V); end Set_Component_Type; --- 2359,2371 ---- procedure Set_Component_Size (Id : E; V : U) is begin ! pragma Assert (Is_Array_Type (Id) and then Id = Base_Type (Id)); ! Set_Uint22 (Id, V); end Set_Component_Size; procedure Set_Component_Type (Id : E; V : E) is begin + pragma Assert (Is_Array_Type (Id) and then Id = Base_Type (Id)); Set_Node20 (Id, V); end Set_Component_Type; *************** package body Einfo is *** 2669,2676 **** procedure Set_Finalize_Storage_Only (Id : E; V : B := True) is begin ! pragma Assert (Is_Type (Id)); ! Set_Flag158 (Base_Type (Id), V); end Set_Finalize_Storage_Only; procedure Set_First_Entity (Id : E; V : E) is --- 2680,2687 ---- procedure Set_Finalize_Storage_Only (Id : E; V : B := True) is begin ! pragma Assert (Is_Type (Id) and then Id = Base_Type (Id)); ! Set_Flag158 (Id, V); end Set_Finalize_Storage_Only; procedure Set_First_Entity (Id : E; V : E) is *************** package body Einfo is *** 2790,2803 **** procedure Set_Has_Complex_Representation (Id : E; V : B := True) is begin ! pragma Assert (Is_Record_Type (Id)); ! Set_Flag140 (Implementation_Base_Type (Id), V); end Set_Has_Complex_Representation; procedure Set_Has_Component_Size_Clause (Id : E; V : B := True) is begin ! pragma Assert (Is_Array_Type (Id)); ! Set_Flag68 (Implementation_Base_Type (Id), V); end Set_Has_Component_Size_Clause; procedure Set_Has_Controlled_Component (Id : E; V : B := True) is --- 2801,2814 ---- procedure Set_Has_Complex_Representation (Id : E; V : B := True) is begin ! pragma Assert (Ekind (Id) = E_Record_Type); ! Set_Flag140 (Id, V); end Set_Has_Complex_Representation; procedure Set_Has_Component_Size_Clause (Id : E; V : B := True) is begin ! pragma Assert (Ekind (Id) = E_Array_Type); ! Set_Flag68 (Id, V); end Set_Has_Component_Size_Clause; procedure Set_Has_Controlled_Component (Id : E; V : B := True) is *************** package body Einfo is *** 2924,2930 **** procedure Set_Has_Pragma_Pack (Id : E; V : B := True) is begin pragma Assert (Is_Array_Type (Id) or else Is_Record_Type (Id)); ! Set_Flag121 (Implementation_Base_Type (Id), V); end Set_Has_Pragma_Pack; procedure Set_Has_Pragma_Pure_Function (Id : E; V : B := True) is --- 2935,2942 ---- procedure Set_Has_Pragma_Pack (Id : E; V : B := True) is begin pragma Assert (Is_Array_Type (Id) or else Is_Record_Type (Id)); ! pragma Assert (Id = Base_Type (Id)); ! Set_Flag121 (Id, V); end Set_Has_Pragma_Pack; procedure Set_Has_Pragma_Pure_Function (Id : E; V : B := True) is *************** package body Einfo is *** 2933,2942 **** Set_Flag179 (Id, V); end Set_Has_Pragma_Pure_Function; procedure Set_Has_Primitive_Operations (Id : E; V : B := True) is begin ! pragma Assert (Is_Type (Id)); ! Set_Flag120 (Base_Type (Id), V); end Set_Has_Primitive_Operations; procedure Set_Has_Private_Declaration (Id : E; V : B := True) is --- 2945,2959 ---- Set_Flag179 (Id, V); end Set_Has_Pragma_Pure_Function; + procedure Set_Has_Pragma_Unreferenced (Id : E; V : B := True) is + begin + Set_Flag180 (Id, V); + end Set_Has_Pragma_Unreferenced; + procedure Set_Has_Primitive_Operations (Id : E; V : B := True) is begin ! pragma Assert (Id = Base_Type (Id)); ! Set_Flag120 (Id, V); end Set_Has_Primitive_Operations; procedure Set_Has_Private_Declaration (Id : E; V : B := True) is *************** package body Einfo is *** 2951,2957 **** procedure Set_Has_Record_Rep_Clause (Id : E; V : B := True) is begin ! pragma Assert (Is_Record_Type (Id)); Set_Flag65 (Id, V); end Set_Has_Record_Rep_Clause; --- 2968,2974 ---- procedure Set_Has_Record_Rep_Clause (Id : E; V : B := True) is begin ! pragma Assert (Id = Base_Type (Id)); Set_Flag65 (Id, V); end Set_Has_Record_Rep_Clause; *************** package body Einfo is *** 2973,2979 **** procedure Set_Has_Specified_Layout (Id : E; V : B := True) is begin ! pragma Assert (Is_Type (Id)); Set_Flag100 (Id, V); end Set_Has_Specified_Layout; --- 2990,2996 ---- procedure Set_Has_Specified_Layout (Id : E; V : B := True) is begin ! pragma Assert (Id = Base_Type (Id)); Set_Flag100 (Id, V); end Set_Has_Specified_Layout; *************** package body Einfo is *** 3087,3093 **** procedure Set_Is_Bit_Packed_Array (Id : E; V : B := True) is begin ! Set_Flag122 (Implementation_Base_Type (Id), V); end Set_Is_Bit_Packed_Array; procedure Set_Is_Called (Id : E; V : B := True) is --- 3104,3113 ---- procedure Set_Is_Bit_Packed_Array (Id : E; V : B := True) is begin ! pragma Assert ((not V) ! or else (Is_Array_Type (Id) and then Id = Base_Type (Id))); ! ! Set_Flag122 (Id, V); end Set_Is_Bit_Packed_Array; procedure Set_Is_Called (Id : E; V : B := True) is *************** package body Einfo is *** 3536,3542 **** procedure Set_No_Pool_Assigned (Id : E; V : B := True) is begin ! pragma Assert (Is_Access_Type (Id) and then Root_Type (Id) = Id); Set_Flag131 (Id, V); end Set_No_Pool_Assigned; --- 3556,3562 ---- procedure Set_No_Pool_Assigned (Id : E; V : B := True) is begin ! pragma Assert (Is_Access_Type (Id) and then Base_Type (Id) = Id); Set_Flag131 (Id, V); end Set_No_Pool_Assigned; *************** package body Einfo is *** 3593,3598 **** --- 3613,3624 ---- Set_Node17 (Id, V); end Set_Object_Ref; + procedure Set_Original_Array_Type (Id : E; V : E) is + begin + pragma Assert (Is_Array_Type (Id) or else Is_Modular_Integer_Type (Id)); + Set_Node21 (Id, V); + end Set_Original_Array_Type; + procedure Set_Original_Record_Component (Id : E; V : E) is begin Set_Node22 (Id, V); *************** package body Einfo is *** 3861,3866 **** --- 3887,3893 ---- procedure Set_Suppress_Init_Proc (Id : E; V : B := True) is begin + pragma Assert (Id = Base_Type (Id)); Set_Flag105 (Id, V); end Set_Suppress_Init_Proc; *************** package body Einfo is *** 4055,4061 **** function Known_Alignment (E : Entity_Id) return B is begin ! return Uint14 (E) /= Uint_0; end Known_Alignment; function Known_Component_Bit_Offset (E : Entity_Id) return B is --- 4082,4089 ---- function Known_Alignment (E : Entity_Id) return B is begin ! return Uint14 (E) /= Uint_0 ! and then Uint14 (E) /= No_Uint; end Known_Alignment; function Known_Component_Bit_Offset (E : Entity_Id) return B is *************** package body Einfo is *** 4065,4076 **** function Known_Component_Size (E : Entity_Id) return B is begin ! return Uint22 (Base_Type (E)) /= Uint_0; end Known_Component_Size; function Known_Esize (E : Entity_Id) return B is begin ! return Uint12 (E) /= Uint_0; end Known_Esize; function Known_Normalized_First_Bit (E : Entity_Id) return B is --- 4093,4106 ---- function Known_Component_Size (E : Entity_Id) return B is begin ! return Uint22 (Base_Type (E)) /= Uint_0 ! and then Uint22 (Base_Type (E)) /= No_Uint; end Known_Component_Size; function Known_Esize (E : Entity_Id) return B is begin ! return Uint12 (E) /= Uint_0 ! and then Uint12 (E) /= No_Uint; end Known_Esize; function Known_Normalized_First_Bit (E : Entity_Id) return B is *************** package body Einfo is *** 4090,4097 **** function Known_RM_Size (E : Entity_Id) return B is begin ! return Uint13 (E) /= Uint_0 ! or else Is_Discrete_Type (E); end Known_RM_Size; function Known_Static_Component_Bit_Offset (E : Entity_Id) return B is --- 4120,4128 ---- function Known_RM_Size (E : Entity_Id) return B is begin ! return Uint13 (E) /= No_Uint ! and then (Uint13 (E) /= Uint_0 ! or else Is_Discrete_Type (E)); end Known_RM_Size; function Known_Static_Component_Bit_Offset (E : Entity_Id) return B is *************** package body Einfo is *** 4110,4115 **** --- 4141,4152 ---- return Uint12 (E) > Uint_0; end Known_Static_Esize; + function Known_Static_Normalized_First_Bit (E : Entity_Id) return B is + begin + return Uint8 (E) /= No_Uint + and then Uint8 (E) >= Uint_0; + end Known_Static_Normalized_First_Bit; + function Known_Static_Normalized_Position (E : Entity_Id) return B is begin return Uint9 (E) /= No_Uint *************** package body Einfo is *** 4130,4136 **** function Unknown_Alignment (E : Entity_Id) return B is begin ! return Uint14 (E) = Uint_0; end Unknown_Alignment; function Unknown_Component_Bit_Offset (E : Entity_Id) return B is --- 4167,4174 ---- function Unknown_Alignment (E : Entity_Id) return B is begin ! return Uint14 (E) = Uint_0 ! or else Uint14 (E) = No_Uint; end Unknown_Alignment; function Unknown_Component_Bit_Offset (E : Entity_Id) return B is *************** package body Einfo is *** 4140,4151 **** function Unknown_Component_Size (E : Entity_Id) return B is begin ! return Uint22 (Base_Type (E)) = Uint_0; end Unknown_Component_Size; function Unknown_Esize (E : Entity_Id) return B is begin ! return Uint12 (E) = Uint_0; end Unknown_Esize; function Unknown_Normalized_First_Bit (E : Entity_Id) return B is --- 4178,4193 ---- function Unknown_Component_Size (E : Entity_Id) return B is begin ! return Uint22 (Base_Type (E)) = Uint_0 ! or else ! Uint22 (Base_Type (E)) = No_Uint; end Unknown_Component_Size; function Unknown_Esize (E : Entity_Id) return B is begin ! return Uint12 (E) = No_Uint ! or else ! Uint12 (E) = Uint_0; end Unknown_Esize; function Unknown_Normalized_First_Bit (E : Entity_Id) return B is *************** package body Einfo is *** 4165,4172 **** function Unknown_RM_Size (E : Entity_Id) return B is begin ! return Uint13 (E) = Uint_0 ! and then not Is_Discrete_Type (E); end Unknown_RM_Size; -------------------- --- 4207,4215 ---- function Unknown_RM_Size (E : Entity_Id) return B is begin ! return (Uint13 (E) = Uint_0 ! and then not Is_Discrete_Type (E)) ! or else Uint13 (E) = No_Uint; end Unknown_RM_Size; -------------------- *************** package body Einfo is *** 4686,4691 **** --- 4729,4804 ---- end if; end First_Subtype; + ------------------------------------- + -- Get_Attribute_Definition_Clause -- + ------------------------------------- + + function Get_Attribute_Definition_Clause + (E : Entity_Id; + Id : Attribute_Id) + return Node_Id + is + N : Node_Id; + + begin + N := First_Rep_Item (E); + while Present (N) loop + if Nkind (N) = N_Attribute_Definition_Clause + and then Get_Attribute_Id (Chars (N)) = Id + then + return N; + else + Next_Rep_Item (N); + end if; + end loop; + + return Empty; + end Get_Attribute_Definition_Clause; + + -------------------- + -- Get_Rep_Pragma -- + -------------------- + + function Get_Rep_Pragma (E : Entity_Id; Nam : Name_Id) return Node_Id is + N : Node_Id; + Typ : Entity_Id; + + begin + N := First_Rep_Item (E); + + while Present (N) loop + if Nkind (N) = N_Pragma and then Chars (N) = Nam then + + if Nam = Name_Stream_Convert then + + -- For tagged types this pragma is not inherited, so we + -- must verify that it is defined for the given type and + -- not an ancestor. + + Typ := Entity (Expression + (First (Pragma_Argument_Associations (N)))); + + if not Is_Tagged_Type (E) + or else E = Typ + or else (Is_Private_Type (Typ) + and then E = Full_View (Typ)) + then + return N; + else + Next_Rep_Item (N); + end if; + + else + return N; + end if; + else + Next_Rep_Item (N); + end if; + end loop; + + return Empty; + end Get_Rep_Pragma; + ------------------------ -- Has_Attach_Handler -- ------------------------ *************** package body Einfo is *** 4808,4814 **** -- happen in error situations and should avoid some error bombs. if Present (Imptyp) then ! return Imptyp; else return Bastyp; end if; --- 4921,4927 ---- -- happen in error situations and should avoid some error bombs. if Present (Imptyp) then ! return Base_Type (Imptyp); else return Bastyp; end if; *************** package body Einfo is *** 5845,5850 **** --- 5958,5964 ---- W ("Has_Pragma_Inline", Flag157 (Id)); W ("Has_Pragma_Pack", Flag121 (Id)); W ("Has_Pragma_Pure_Function", Flag179 (Id)); + W ("Has_Pragma_Unreferenced", Flag180 (Id)); W ("Has_Primitive_Operations", Flag120 (Id)); W ("Has_Private_Declaration", Flag155 (Id)); W ("Has_Qualified_Name", Flag161 (Id)); *************** package body Einfo is *** 6099,6104 **** --- 6213,6220 ---- ----------------------- procedure Write_Field6_Name (Id : Entity_Id) is + pragma Warnings (Off, Id); + begin Write_Str ("First_Rep_Item"); end Write_Field6_Name; *************** package body Einfo is *** 6108,6113 **** --- 6224,6231 ---- ----------------------- procedure Write_Field7_Name (Id : Entity_Id) is + pragma Warnings (Off, Id); + begin Write_Str ("Freeze_Node"); end Write_Field7_Name; *************** package body Einfo is *** 6124,6130 **** Write_Str ("Normalized_First_Bit"); when Formal_Kind | ! E_Function => Write_Str ("Mechanism"); when Type_Kind => --- 6242,6249 ---- Write_Str ("Normalized_First_Bit"); when Formal_Kind | ! E_Function | ! E_Subprogram_Body => Write_Str ("Mechanism"); when Type_Kind => *************** package body Einfo is *** 6686,6691 **** --- 6805,6814 ---- when E_In_Parameter => Write_Str ("Default_Expr_Function"); + when Array_Kind | + Modular_Integer_Kind => + Write_Str ("Original_Array_Type"); + when others => Write_Str ("Field21??"); end case; diff -Nrc3pad gcc-3.2.3/gcc/ada/einfo.ads gcc-3.3/gcc/ada/einfo.ads *** gcc-3.2.3/gcc/ada/einfo.ads 2002-05-04 03:27:39.000000000 +0000 --- gcc-3.3/gcc/ada/einfo.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.7.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** *** 33,38 **** --- 32,38 ---- -- -- ------------------------------------------------------------------------------ + with Snames; use Snames; with Types; use Types; with Uintp; use Uintp; with Urealp; use Urealp; *************** package Einfo is *** 270,286 **** -- are so noted by the notation [base type only]. These are cases where the -- attribute of any subtype is the same as the attribute of the base type. -- The attribute can be referenced on a subtype (and automatically retrieves ! -- the value from the base type), and if an attempt is made to set them on ! -- other than a subtype, they will instead be set on the corresponding base ! -- type. -- Other attributes are noted as applying the implementation base type only. -- These are representation attributes which must always apply to a full -- non-private type, and where the attributes are always on the full type. -- The attribute can be referenced on a subtype (and automatically retries ! -- the value from the implementation base type), and if an attempt is made ! -- to set them on other than a subtype, they will instead be set on the ! -- corresponding implementation base type. -- Accept_Address (Elist21) -- Present in entries. If an accept has a statement sequence, then an --- 270,287 ---- -- are so noted by the notation [base type only]. These are cases where the -- attribute of any subtype is the same as the attribute of the base type. -- The attribute can be referenced on a subtype (and automatically retrieves ! -- the value from the base type). However, it is an error to try to set the ! -- attribute on other than the base type, and if assertions are enabled, ! -- an attempt to set the attribute on a subtype will raise an assert error. -- Other attributes are noted as applying the implementation base type only. -- These are representation attributes which must always apply to a full -- non-private type, and where the attributes are always on the full type. -- The attribute can be referenced on a subtype (and automatically retries ! -- the value from the implementation base type). However, it is an error ! -- to try to set the attribute on other than the implementation base type, ! -- and if assertions are enabled, an attempt to set the attribute on a ! -- subtype will raise an assert error. -- Accept_Address (Elist21) -- Present in entries. If an accept has a statement sequence, then an *************** package Einfo is *** 309,315 **** -- rather irregular, and the semantic checks that depend on the nominal -- subtype being unconstrained use flag Is_Constr_Subt_For_U_Nominal(qv). ! -- Access_Disp_Table (Node16) [base type only] -- Present in record type entities. For a tagged type, points to the -- dispatch table associated with the tagged type. For a non-tagged -- record, contains Empty. --- 310,316 ---- -- rather irregular, and the semantic checks that depend on the nominal -- subtype being unconstrained use flag Is_Constr_Subt_For_U_Nominal(qv). ! -- Access_Disp_Table (Node16) [implementation base type only] -- Present in record type entities. For a tagged type, points to the -- dispatch table associated with the tagged type. For a non-tagged -- record, contains Empty. *************** package Einfo is *** 367,376 **** -- the node whose elaboration generated the Itype. This is used for -- copying trees, to determine whether or not to copy an Itype. ! -- Associated_Storage_Pool (Node22) -- Present in simple and general access type entities. References the -- storage pool to be used for the corresponding collection. A value of ! -- Empty means that the default pool is to be used. -- Associated_Final_Chain (Node23) -- Present in simple and general access type entities. References the --- 368,379 ---- -- the node whose elaboration generated the Itype. This is used for -- copying trees, to determine whether or not to copy an Itype. ! -- Associated_Storage_Pool (Node22) [root type only] -- Present in simple and general access type entities. References the -- storage pool to be used for the corresponding collection. A value of ! -- Empty means that the default pool is to be used. This is present ! -- only in the root type, since derived types must have the same pool ! -- as the parent type. -- Associated_Final_Chain (Node23) -- Present in simple and general access type entities. References the *************** package Einfo is *** 400,406 **** -- for finalization purposes, The block entity has an implicit label -- declaration in the enclosing declarative part, and has otherwise -- no direct connection in the tree with the block statement. The ! -- link is to the identifier (which is an occurrence of the entity) -- and not to the block_statement itself, because the statement may -- be rewritten, e.g. in the process of removing dead code. --- 403,409 ---- -- for finalization purposes, The block entity has an implicit label -- declaration in the enclosing declarative part, and has otherwise -- no direct connection in the tree with the block statement. The ! -- link is to the identifier (which is an occurence of the entity) -- and not to the block_statement itself, because the statement may -- be rewritten, e.g. in the process of removing dead code. *************** package Einfo is *** 511,519 **** -- for details of these values. -- Component_Type (Node20) [implementation base type only] ! -- Present in array types and subtypes, and also in the special ! -- enumeration table type created for enumeration type. References ! -- the entity for the component type. -- Constant_Value (synthesized) -- Applies to constants, named integers, and named reals. Obtains --- 514,520 ---- -- for details of these values. -- Component_Type (Node20) [implementation base type only] ! -- Present in array types and string types. References component type. -- Constant_Value (synthesized) -- Applies to constants, named integers, and named reals. Obtains *************** package Einfo is *** 1360,1368 **** -- Pure_Function was given for the entity. In some cases, we need to -- know that Is_Pure was explicitly set using this pragma. -- Has_Primitive_Operations (Flag120) [base type only] -- Present in all type entities. Set if at least one primitive operation ! -- is defined on the type. This flag is not yet properly set ??? -- Has_Private_Ancestor (synthesized) -- Applies to all type and subtype entities. Returns True if at least --- 1361,1375 ---- -- Pure_Function was given for the entity. In some cases, we need to -- know that Is_Pure was explicitly set using this pragma. + -- Has_Pragma_Unreferenced (Flag180) + -- Present in all entities. Set if a valid pragma Unreferenced applies + -- to the pragma, indicating that no warning should be given if the + -- entity has no references, but a warning should be given if it is + -- in fact referenced. + -- Has_Primitive_Operations (Flag120) [base type only] -- Present in all type entities. Set if at least one primitive operation ! -- is defined for the type. -- Has_Private_Ancestor (synthesized) -- Applies to all type and subtype entities. Returns True if at least *************** package Einfo is *** 1386,1392 **** -- the flag Has_Fully_Qualified_Name, which is set if the name does -- indeed include the fully qualified name. ! -- Has_Record_Rep_Clause (Flag65) -- Present in record types. Set if a record representation clause has -- been given for this record type. Used to prevent more than one such -- clause for a given record type. Note that this is initially cleared --- 1393,1399 ---- -- the flag Has_Fully_Qualified_Name, which is set if the name does -- indeed include the fully qualified name. ! -- Has_Record_Rep_Clause (Flag65) [implementation base type only] -- Present in record types. Set if a record representation clause has -- been given for this record type. Used to prevent more than one such -- clause for a given record type. Note that this is initially cleared *************** package Einfo is *** 1412,1418 **** -- initially cleared for a derived type, even though the Small for such -- a type is inherited from a Small clause given for the parent type. ! -- Has_Specified_Layout (Flag100) -- Present in all type entities. Set for a record type or subtype if -- the record layout has been specified by a record representation -- clause. Note that this differs from the flag Has_Record_Rep_Clause --- 1419,1425 ---- -- initially cleared for a derived type, even though the Small for such -- a type is inherited from a Small clause given for the parent type. ! -- Has_Specified_Layout (Flag100) [implementation base type only] -- Present in all type entities. Set for a record type or subtype if -- the record layout has been specified by a record representation -- clause. Note that this differs from the flag Has_Record_Rep_Clause *************** package Einfo is *** 1575,1581 **** -- Present in all type entities and in procedure entities. Set -- if a pragma Asynchronous applies to the entity. ! -- Is_Bit_Packed_Array (Flag122) -- Present in all entities. This flag is set for a packed array -- type that is bit packed (i.e. the component size is known by the -- front end and is in the range 1-7, 9-15, or 17-31). Is_Packed is --- 1582,1588 ---- -- Present in all type entities and in procedure entities. Set -- if a pragma Asynchronous applies to the entity. ! -- Is_Bit_Packed_Array (Flag122) [implementation base type only] -- Present in all entities. This flag is set for a packed array -- type that is bit packed (i.e. the component size is known by the -- front end and is in the range 1-7, 9-15, or 17-31). Is_Packed is *************** package Einfo is *** 1718,1724 **** -- Is_Eliminated (Flag124) -- Present in type entities, subprogram entities, and object entities. -- Indicates that the corresponding entity has been eliminated by use ! -- of pragma Eliminate. -- Is_Enumeration_Type (synthesized) -- Present in all entities, true for enumeration types and subtypes --- 1725,1732 ---- -- Is_Eliminated (Flag124) -- Present in type entities, subprogram entities, and object entities. -- Indicates that the corresponding entity has been eliminated by use ! -- of pragma Eliminate. Also used to mark subprogram entities whose ! -- declaration and body are within unreachable code that is removed. -- Is_Enumeration_Type (synthesized) -- Present in all entities, true for enumeration types and subtypes *************** package Einfo is *** 2012,2018 **** -- if the type appears in the Packed_Array_Type field of some other type -- entity. It is used by Gigi to activate the special processing for such -- types (unchecked conversions that would not otherwise be allowed are ! -- allowed for such types). -- Is_Potentially_Use_Visible (Flag9) -- Present in all entities. Set if entity is potentially use visible, --- 2020,2028 ---- -- if the type appears in the Packed_Array_Type field of some other type -- entity. It is used by Gigi to activate the special processing for such -- types (unchecked conversions that would not otherwise be allowed are ! -- allowed for such types). If the Is_Packed_Array_Type flag is set in ! -- an entity, then the Original_Array_Type field of this entity points ! -- to the original array type for which this is the packed array type. -- Is_Potentially_Use_Visible (Flag9) -- Present in all entities. Set if entity is potentially use visible, *************** package Einfo is *** 2251,2257 **** -- Mechanism (Uint8) (returned as Mechanism_Type) -- Present in functions and non-generic formal parameters. Indicates -- the mechanism to be used for the function return or for the formal ! -- parameter. See separate section on passing mechanisms. -- Modulus (Uint17) [base type only] -- Present in modular types. Contains the modulus. For the binary --- 2261,2269 ---- -- Mechanism (Uint8) (returned as Mechanism_Type) -- Present in functions and non-generic formal parameters. Indicates -- the mechanism to be used for the function return or for the formal ! -- parameter. See separate section on passing mechanisms. This field ! -- is also set (to the default value of zero) in a subprogram body ! -- entity but not used in this context. -- Modulus (Uint17) [base type only] -- Present in modular types. Contains the modulus. For the binary *************** package Einfo is *** 2382,2388 **** -- Present in access types. Set if a storage size clause applies to -- the variable with a compile time known value of zero. This flag is -- used to generate warnings if any attempt is made to allocate an ! -- instance of such an access type. -- No_Return (Flag113) -- Present in procedure and generic procedure entries. Indicates that --- 2394,2401 ---- -- Present in access types. Set if a storage size clause applies to -- the variable with a compile time known value of zero. This flag is -- used to generate warnings if any attempt is made to allocate an ! -- instance of such an access type. This is set only in the root ! -- type, since derived types must have the same pool. -- No_Return (Flag113) -- Present in procedure and generic procedure entries. Indicates that *************** package Einfo is *** 2426,2431 **** --- 2439,2451 ---- -- Applies to subprograms and subprogram types. Yields the number of -- formals as a value of type Pos. + -- Original_Array_Type (Node21) + -- Present in modular types and array types and subtypes. Set only + -- if the Is_Packed_Array_Type flag is set, indicating that the type + -- is the implementation type for a packed array, and in this case it + -- points to the original array type for which this is the packed + -- array implementation type. + -- Object_Ref (Node17) -- Present in protected bodies. This is an implicit prival for the -- Protection object associated with a protected object. See Prival *************** package Einfo is *** 2466,2472 **** -- Parameter_Mode (synthesized) -- Applies to formal parameter entities. This is a synonym for Ekind, -- used when obtaining the formal kind of a formal parameter (the result ! -- is one of E_[In/Out/In_Out]_Parameter) -- Parent_Subtype (Node19) -- Present in E_Record_Type. Points to the subtype to use for a --- 2486,2492 ---- -- Parameter_Mode (synthesized) -- Applies to formal parameter entities. This is a synonym for Ekind, -- used when obtaining the formal kind of a formal parameter (the result ! -- is one of E_[In/Out/In_Out]_Paramter) -- Parent_Subtype (Node19) -- Present in E_Record_Type. Points to the subtype to use for a *************** package Einfo is *** 2616,2622 **** -- returns the result by reference, either because its return typ is a -- by-reference-type or because it uses explicitly the secondary stack. ! -- Reverse_Bit_Order (Flag164) -- Present in all record type entities. Set if a valid pragma an -- attribute represention clause for Bit_Order has reversed the order -- of bits from the default value. When this flag is set, a component --- 2636,2642 ---- -- returns the result by reference, either because its return typ is a -- by-reference-type or because it uses explicitly the secondary stack. ! -- Reverse_Bit_Order (Flag164) [base type only] -- Present in all record type entities. Set if a valid pragma an -- attribute represention clause for Bit_Order has reversed the order -- of bits from the default value. When this flag is set, a component *************** package Einfo is *** 3668,3677 **** -- Has_Homonym (Flag56) -- Has_Pragma_Elaborate_Body (Flag150) -- Has_Pragma_Inline (Flag157) -- Has_Private_Declaration (Flag155) -- Has_Qualified_Name (Flag161) -- Has_Unknown_Discriminants (Flag72) ! -- Is_Bit_Packed_Array (Flag122) -- Is_Child_Unit (Flag73) -- Is_Compilation_Unit (Flag149) -- Is_Completely_Hidden (Flag103) --- 3688,3698 ---- -- Has_Homonym (Flag56) -- Has_Pragma_Elaborate_Body (Flag150) -- Has_Pragma_Inline (Flag157) + -- Has_Pragma_Unreferenced (Flag180) -- Has_Private_Declaration (Flag155) -- Has_Qualified_Name (Flag161) -- Has_Unknown_Discriminants (Flag72) ! -- Is_Bit_Packed_Array (Flag122) (base type only) -- Is_Child_Unit (Flag73) -- Is_Compilation_Unit (Flag149) -- Is_Completely_Hidden (Flag103) *************** package Einfo is *** 3745,3756 **** -- Discard_Names (Flag88) -- Finalize_Storage_Only (Flag158) (base type only) -- From_With_Type (Flag159) ! -- Has_Aliased_Components (Flag135) -- Has_Alignment_Clause (Flag46) -- Has_Atomic_Components (Flag86) (base type only) -- Has_Complex_Representation (Flag140) (base type only) -- Has_Discriminants (Flag5) ! -- Has_Non_Standard_Rep (Flag75) -- Has_Object_Size_Clause (Flag172) -- Has_Primitive_Operations (Flag120) (base type only) -- Has_Size_Clause (Flag29) --- 3766,3777 ---- -- Discard_Names (Flag88) -- Finalize_Storage_Only (Flag158) (base type only) -- From_With_Type (Flag159) ! -- Has_Aliased_Components (Flag135) (base type only) -- Has_Alignment_Clause (Flag46) -- Has_Atomic_Components (Flag86) (base type only) -- Has_Complex_Representation (Flag140) (base type only) -- Has_Discriminants (Flag5) ! -- Has_Non_Standard_Rep (Flag75) (base type only) -- Has_Object_Size_Clause (Flag172) -- Has_Primitive_Operations (Flag120) (base type only) -- Has_Size_Clause (Flag29) *************** package Einfo is *** 3778,3784 **** -- Is_Volatile (Flag16) -- Size_Depends_On_Discriminant (Flag177) -- Size_Known_At_Compile_Time (Flag92) ! -- Strict_Alignment (Flag145) -- Suppress_Init_Proc (Flag105) (base type only) -- Alignment_Clause (synth) --- 3799,3805 ---- -- Is_Volatile (Flag16) -- Size_Depends_On_Discriminant (Flag177) -- Size_Known_At_Compile_Time (Flag92) ! -- Strict_Alignment (Flag145) (base type only) -- Suppress_Init_Proc (Flag105) (base type only) -- Alignment_Clause (synth) *************** package Einfo is *** 3811,3825 **** -- E_Access_Type -- E_Access_Subtype ! -- Storage_Size_Variable (Node15) (root type only) -- Master_Id (Node17) -- Directly_Designated_Type (Node20) ! -- Associated_Storage_Pool (Node22) -- Associated_Final_Chain (Node23) -- Has_Pragma_Controlled (Flag27) (base type only) ! -- Has_Storage_Size_Clause (Flag23) (root type only) -- Is_Access_Constant (Flag69) ! -- No_Pool_Assigned (Flag131) (root type only) -- (plus type attributes) -- E_Access_Attribute_Type --- 3832,3846 ---- -- E_Access_Type -- E_Access_Subtype ! -- Storage_Size_Variable (Node15) (base type only) -- Master_Id (Node17) -- Directly_Designated_Type (Node20) ! -- Associated_Storage_Pool (Node22) (base type only) -- Associated_Final_Chain (Node23) -- Has_Pragma_Controlled (Flag27) (base type only) ! -- Has_Storage_Size_Clause (Flag23) (base type only) -- Is_Access_Constant (Flag69) ! -- No_Pool_Assigned (Flag131) (base type only) -- (plus type attributes) -- E_Access_Attribute_Type *************** package Einfo is *** 3840,3845 **** --- 3861,3867 ---- -- First_Index (Node17) -- Related_Array_Object (Node19) -- Component_Type (Node20) (base type only) + -- Original_Array_Type (Node21) -- Component_Size (Uint22) (base type only) -- Packed_Array_Type (Node23) -- Component_Alignment (special) (base type only) *************** package Einfo is *** 4089,4095 **** -- Storage_Size_Variable (Node15) (base type only) -- Master_Id (Node17) -- Directly_Designated_Type (Node20) ! -- Associated_Storage_Pool (Node22) -- Associated_Final_Chain (Node23) -- (plus type attributes) --- 4111,4117 ---- -- Storage_Size_Variable (Node15) (base type only) -- Master_Id (Node17) -- Directly_Designated_Type (Node20) ! -- Associated_Storage_Pool (Node22) (base type only) -- Associated_Final_Chain (Node23) -- (plus type attributes) *************** package Einfo is *** 4163,4168 **** --- 4185,4191 ---- -- E_Modular_Integer_Type -- E_Modular_Integer_Subtype -- Modulus (Uint17) (base type only) + -- Original_Array_Type (Node21) -- Scalar_Range (Node20) -- Non_Binary_Modulus (Flag58) (base type only) -- Has_Biased_Representation (Flag139) *************** package Einfo is *** 4352,4364 **** -- Parent_Subtype (Node19) -- Last_Entity (Node20) -- Discriminant_Constraint (Elist21) ! -- Corresponding_Remote_Type (Node22) (base type only) -- Girder_Constraint (Elist23) -- Component_Alignment (special) (base type only) -- C_Pass_By_Copy (Flag125) (base type only) -- Has_Controlled_Component (Flag43) (base type only) -- Has_External_Tag_Rep_Clause (Flag110) ! -- Has_Record_Rep_Clause (Flag65) -- Is_Concurrent_Record_Type (Flag20) -- Is_Constrained (Flag12) -- Is_Controlled (Flag42) (base type only) --- 4375,4387 ---- -- Parent_Subtype (Node19) -- Last_Entity (Node20) -- Discriminant_Constraint (Elist21) ! -- Corresponding_Remote_Type (Node22) -- Girder_Constraint (Elist23) -- Component_Alignment (special) (base type only) -- C_Pass_By_Copy (Flag125) (base type only) -- Has_Controlled_Component (Flag43) (base type only) -- Has_External_Tag_Rep_Clause (Flag110) ! -- Has_Record_Rep_Clause (Flag65) (base type only) -- Is_Concurrent_Record_Type (Flag20) -- Is_Constrained (Flag12) -- Is_Controlled (Flag42) (base type only) *************** package Einfo is *** 4383,4389 **** -- Has_Completion (Flag26) -- Has_Completion_In_Body (Flag71) -- Has_Controlled_Component (Flag43) (base type only) ! -- Has_Record_Rep_Clause (Flag65) -- Has_External_Tag_Rep_Clause (Flag110) -- Is_Concurrent_Record_Type (Flag20) -- Is_Constrained (Flag12) --- 4406,4412 ---- -- Has_Completion (Flag26) -- Has_Completion_In_Body (Flag71) -- Has_Controlled_Component (Flag43) (base type only) ! -- Has_Record_Rep_Clause (Flag65) (base type only) -- Has_External_Tag_Rep_Clause (Flag110) -- Is_Concurrent_Record_Type (Flag20) -- Is_Constrained (Flag12) *************** package Einfo is *** 4416,4426 **** -- String_Literal_Low_Bound (Node15) -- String_Literal_Length (Uint16) -- First_Index (Node17) (always Empty) - -- Component_Type (Node20) (base type only) -- Packed_Array_Type (Node23) -- (plus type attributes) -- E_Subprogram_Body -- First_Entity (Node17) -- Last_Entity (Node20) -- Scope_Depth_Value (Uint22) --- 4439,4449 ---- -- String_Literal_Low_Bound (Node15) -- String_Literal_Length (Uint16) -- First_Index (Node17) (always Empty) -- Packed_Array_Type (Node23) -- (plus type attributes) -- E_Subprogram_Body + -- Mechanism (Uint8) -- First_Entity (Node17) -- Last_Entity (Node20) -- Scope_Depth_Value (Uint22) *************** package Einfo is *** 4845,4850 **** --- 4868,4874 ---- function Has_Pragma_Inline (Id : E) return B; function Has_Pragma_Pack (Id : E) return B; function Has_Pragma_Pure_Function (Id : E) return B; + function Has_Pragma_Unreferenced (Id : E) return B; function Has_Primitive_Operations (Id : E) return B; function Has_Qualified_Name (Id : E) return B; function Has_Record_Rep_Clause (Id : E) return B; *************** package Einfo is *** 4955,4960 **** --- 4979,4985 ---- function Normalized_Position_Max (Id : E) return U; function Not_Source_Assigned (Id : E) return B; function Object_Ref (Id : E) return E; + function Original_Array_Type (Id : E) return E; function Original_Record_Component (Id : E) return E; function Packed_Array_Type (Id : E) return E; function Parent_Subtype (Id : E) return E; *************** package Einfo is *** 5137,5151 **** -- possible, so we do not need a separate Known_Static calls in -- these cases. The not set (unknown values are as follows: ! -- Alignment Uint_0 ! -- Component_Size Uint_0 -- Component_Bit_Offset No_Uint ! -- Digits_Value Uint_0 ! -- Esize Uint_0 -- Normalized_First_Bit No_Uint -- Normalized_Position No_Uint -- Normalized_Position_Max No_Uint ! -- RM_Size Uint_0 -- It would be cleaner to use No_Uint in all these cases, but historically -- we chose to use Uint_0 at first, and the change over will take time ??? --- 5162,5176 ---- -- possible, so we do not need a separate Known_Static calls in -- these cases. The not set (unknown values are as follows: ! -- Alignment Uint_0 or No_Uint ! -- Component_Size Uint_0 or No_Uint -- Component_Bit_Offset No_Uint ! -- Digits_Value Uint_0 or No_Uint ! -- Esize Uint_0 or No_Uint -- Normalized_First_Bit No_Uint -- Normalized_Position No_Uint -- Normalized_Position_Max No_Uint ! -- RM_Size Uint_0 or No_Uint -- It would be cleaner to use No_Uint in all these cases, but historically -- we chose to use Uint_0 at first, and the change over will take time ??? *************** package Einfo is *** 5166,5171 **** --- 5191,5197 ---- function Known_Static_Component_Bit_Offset (E : Entity_Id) return B; function Known_Static_Component_Size (E : Entity_Id) return B; function Known_Static_Esize (E : Entity_Id) return B; + function Known_Static_Normalized_First_Bit (E : Entity_Id) return B; function Known_Static_Normalized_Position (E : Entity_Id) return B; function Known_Static_Normalized_Position_Max (E : Entity_Id) return B; function Known_Static_RM_Size (E : Entity_Id) return B; *************** package Einfo is *** 5301,5306 **** --- 5327,5333 ---- procedure Set_Has_Pragma_Inline (Id : E; V : B := True); procedure Set_Has_Pragma_Pack (Id : E; V : B := True); procedure Set_Has_Pragma_Pure_Function (Id : E; V : B := True); + procedure Set_Has_Pragma_Unreferenced (Id : E; V : B := True); procedure Set_Has_Primitive_Operations (Id : E; V : B := True); procedure Set_Has_Private_Declaration (Id : E; V : B := True); procedure Set_Has_Qualified_Name (Id : E; V : B := True); *************** package Einfo is *** 5416,5421 **** --- 5443,5449 ---- procedure Set_Normalized_Position_Max (Id : E; V : U); procedure Set_Not_Source_Assigned (Id : E; V : B := True); procedure Set_Object_Ref (Id : E; V : E); + procedure Set_Original_Array_Type (Id : E; V : E); procedure Set_Original_Record_Component (Id : E; V : E); procedure Set_Packed_Array_Type (Id : E; V : E); procedure Set_Parent_Subtype (Id : E; V : E); *************** package Einfo is *** 5590,5595 **** --- 5618,5637 ---- procedure Append_Entity (Id : Entity_Id; V : Entity_Id); -- Add an entity to the list of entities declared in the scope V + function Get_Rep_Pragma (E : Entity_Id; Nam : Name_Id) return Node_Id; + -- Searches the Rep_Item chain for the given entity E, for an instance + -- of a representation pragma with the given name Nam. If found then + -- the value returned is the N_Pragma node, otherwise Empty is returned. + + function Get_Attribute_Definition_Clause + (E : Entity_Id; + Id : Attribute_Id) + return Node_Id; + -- Searches the Rep_Item chain for a given entity E, for an instance + -- of an attribute definition clause with the given attibute Id Id. If + -- found, the value returned is the N_Attribute_Definition_Clause node, + -- otherwise Empty is returned. + function Is_Entity_Name (N : Node_Id) return Boolean; -- Test if the node N is the name of an entity (i.e. is an identifier, -- expanded name, or an attribute reference that returns an entity). *************** package Einfo is *** 5769,5774 **** --- 5811,5817 ---- pragma Inline (Has_Pragma_Inline); pragma Inline (Has_Pragma_Pack); pragma Inline (Has_Pragma_Pure_Function); + pragma Inline (Has_Pragma_Unreferenced); pragma Inline (Has_Primitive_Operations); pragma Inline (Has_Private_Declaration); pragma Inline (Has_Qualified_Name); *************** package Einfo is *** 5920,5925 **** --- 5963,5969 ---- pragma Inline (Normalized_Position_Max); pragma Inline (Not_Source_Assigned); pragma Inline (Object_Ref); + pragma Inline (Original_Array_Type); pragma Inline (Original_Record_Component); pragma Inline (Packed_Array_Type); pragma Inline (Parameter_Mode); *************** package Einfo is *** 5988,6006 **** pragma Inline (Init_Esize); pragma Inline (Init_RM_Size); - pragma Inline (Known_Alignment); - pragma Inline (Known_Component_Bit_Offset); - pragma Inline (Known_Component_Size); - pragma Inline (Known_Esize); - - pragma Inline (Known_Static_Component_Size); - pragma Inline (Known_Static_Esize); - - pragma Inline (Unknown_Alignment); - pragma Inline (Unknown_Component_Bit_Offset); - pragma Inline (Unknown_Component_Size); - pragma Inline (Unknown_Esize); - pragma Inline (Set_Accept_Address); pragma Inline (Set_Access_Disp_Table); pragma Inline (Set_Actual_Subtype); --- 6032,6037 ---- *************** package Einfo is *** 6115,6120 **** --- 6146,6152 ---- pragma Inline (Set_Has_Pragma_Inline); pragma Inline (Set_Has_Pragma_Pack); pragma Inline (Set_Has_Pragma_Pure_Function); + pragma Inline (Set_Has_Pragma_Unreferenced); pragma Inline (Set_Has_Primitive_Operations); pragma Inline (Set_Has_Private_Declaration); pragma Inline (Set_Has_Qualified_Name); *************** package Einfo is *** 6230,6235 **** --- 6262,6268 ---- pragma Inline (Set_Normalized_Position_Max); pragma Inline (Set_Not_Source_Assigned); pragma Inline (Set_Object_Ref); + pragma Inline (Set_Original_Array_Type); pragma Inline (Set_Original_Record_Component); pragma Inline (Set_Packed_Array_Type); pragma Inline (Set_Parent_Subtype); diff -Nrc3pad gcc-3.2.3/gcc/ada/einfo.h gcc-3.3/gcc/ada/einfo.h *** gcc-3.2.3/gcc/ada/einfo.h 2003-04-22 06:56:18.000000000 +0000 --- gcc-3.3/gcc/ada/einfo.h 2003-05-14 00:18:14.000000000 +0000 *************** *** 6,16 **** /* */ /* C Header File */ /* */ ! /* Generated by xeinfo revision 1.2 using */ ! /* einfo.ads revision 1.7 */ ! /* einfo.adb revision 1.4 */ /* */ ! /* Copyright (C) 1992-2001 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- */ --- 6,16 ---- /* */ /* C Header File */ /* */ ! /* Generated by xeinfo revision 1.3 using */ ! /* einfo.ads revision 1.654 */ ! /* einfo.adb revision 1.642 */ /* */ ! /* Copyright (C) 1992-2002 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- */ *************** *** 361,366 **** --- 361,367 ---- INLINE B Has_Pragma_Inline (E Id); INLINE B Has_Pragma_Pack (E Id); INLINE B Has_Pragma_Pure_Function (E Id); + INLINE B Has_Pragma_Unreferenced (E Id); INLINE B Has_Primitive_Operations (E Id); INLINE B Has_Qualified_Name (E Id); INLINE B Has_Record_Rep_Clause (E Id); *************** *** 474,479 **** --- 475,481 ---- INLINE U Normalized_Position_Max (E Id); INLINE B Not_Source_Assigned (E Id); INLINE E Object_Ref (E Id); + INLINE E Original_Array_Type (E Id); INLINE E Original_Record_Component (E Id); INLINE E Packed_Array_Type (E Id); INLINE E Parent_Subtype (E Id); *************** *** 723,732 **** #define Underlying_Type einfo__underlying_type E Underlying_Type (E Id); ! INLINE B Known_Alignment (Entity_Id E); ! INLINE B Known_Component_Bit_Offset (Entity_Id E); ! INLINE B Known_Component_Size (Entity_Id E); ! INLINE B Known_Esize (Entity_Id E); #define Known_Normalized_First_Bit einfo__known_normalized_first_bit B Known_Normalized_First_Bit (Entity_Id E); --- 725,741 ---- #define Underlying_Type einfo__underlying_type E Underlying_Type (E Id); ! #define Known_Alignment einfo__known_alignment ! B Known_Alignment (Entity_Id E); ! ! #define Known_Component_Bit_Offset einfo__known_component_bit_offset ! B Known_Component_Bit_Offset (Entity_Id E); ! ! #define Known_Component_Size einfo__known_component_size ! B Known_Component_Size (Entity_Id E); ! ! #define Known_Esize einfo__known_esize ! B Known_Esize (Entity_Id E); #define Known_Normalized_First_Bit einfo__known_normalized_first_bit B Known_Normalized_First_Bit (Entity_Id E); *************** *** 743,750 **** #define Known_Static_Component_Bit_Offset einfo__known_static_component_bit_offset B Known_Static_Component_Bit_Offset (Entity_Id E); ! INLINE B Known_Static_Component_Size (Entity_Id E); ! INLINE B Known_Static_Esize (Entity_Id E); #define Known_Static_Normalized_Position einfo__known_static_normalized_position B Known_Static_Normalized_Position (Entity_Id E); --- 752,765 ---- #define Known_Static_Component_Bit_Offset einfo__known_static_component_bit_offset B Known_Static_Component_Bit_Offset (Entity_Id E); ! #define Known_Static_Component_Size einfo__known_static_component_size ! B Known_Static_Component_Size (Entity_Id E); ! ! #define Known_Static_Esize einfo__known_static_esize ! B Known_Static_Esize (Entity_Id E); ! ! #define Known_Static_Normalized_First_Bit einfo__known_static_normalized_first_bit ! B Known_Static_Normalized_First_Bit (Entity_Id E); #define Known_Static_Normalized_Position einfo__known_static_normalized_position B Known_Static_Normalized_Position (Entity_Id E); *************** *** 755,764 **** #define Known_Static_RM_Size einfo__known_static_rm_size B Known_Static_RM_Size (Entity_Id E); ! INLINE B Unknown_Alignment (Entity_Id E); ! INLINE B Unknown_Component_Bit_Offset (Entity_Id E); ! INLINE B Unknown_Component_Size (Entity_Id E); ! INLINE B Unknown_Esize (Entity_Id E); #define Unknown_Normalized_First_Bit einfo__unknown_normalized_first_bit B Unknown_Normalized_First_Bit (Entity_Id E); --- 770,786 ---- #define Known_Static_RM_Size einfo__known_static_rm_size B Known_Static_RM_Size (Entity_Id E); ! #define Unknown_Alignment einfo__unknown_alignment ! B Unknown_Alignment (Entity_Id E); ! ! #define Unknown_Component_Bit_Offset einfo__unknown_component_bit_offset ! B Unknown_Component_Bit_Offset (Entity_Id E); ! ! #define Unknown_Component_Size einfo__unknown_component_size ! B Unknown_Component_Size (Entity_Id E); ! ! #define Unknown_Esize einfo__unknown_esize ! B Unknown_Esize (Entity_Id E); #define Unknown_Normalized_First_Bit einfo__unknown_normalized_first_bit B Unknown_Normalized_First_Bit (Entity_Id E); *************** *** 777,783 **** { return Elist21 (Id); } INLINE E Access_Disp_Table (E Id) ! { return Node16 (Base_Type (Underlying_Type (Base_Type (Id)))); } INLINE E Actual_Subtype (E Id) { return Node17 (Id); } --- 799,805 ---- { return Elist21 (Id); } INLINE E Access_Disp_Table (E Id) ! { return Node16 (Implementation_Base_Type (Id)); } INLINE E Actual_Subtype (E Id) { return Node17 (Id); } *************** *** 801,807 **** { return Node8 (Id); } INLINE E Associated_Storage_Pool (E Id) ! { return Node22 (Id); } INLINE N Barrier_Function (E Id) { return Node12 (Id); } --- 823,829 ---- { return Node8 (Id); } INLINE E Associated_Storage_Pool (E Id) ! { return Node22 (Root_Type (Id)); } INLINE N Barrier_Function (E Id) { return Node12 (Id); } *************** *** 1121,1126 **** --- 1143,1151 ---- INLINE B Has_Pragma_Pure_Function (E Id) { return Flag179 (Id); } + INLINE B Has_Pragma_Unreferenced (E Id) + { return Flag180 (Id); } + INLINE B Has_Primitive_Operations (E Id) { return Flag120 (Base_Type (Id)); } *************** *** 1131,1137 **** { return Flag161 (Id); } INLINE B Has_Record_Rep_Clause (E Id) ! { return Flag65 (Id); } INLINE B Has_Recursive_Call (E Id) { return Flag143 (Id); } --- 1156,1162 ---- { return Flag161 (Id); } INLINE B Has_Record_Rep_Clause (E Id) ! { return Flag65 (Implementation_Base_Type (Id)); } INLINE B Has_Recursive_Call (E Id) { return Flag143 (Id); } *************** *** 1143,1149 **** { return Flag67 (Id); } INLINE B Has_Specified_Layout (E Id) ! { return Flag100 (Id); } INLINE B Has_Storage_Size_Clause (E Id) { return Flag23 (Implementation_Base_Type (Id)); } --- 1168,1174 ---- { return Flag67 (Id); } INLINE B Has_Specified_Layout (E Id) ! { return Flag100 (Implementation_Base_Type (Id)); } INLINE B Has_Storage_Size_Clause (E Id) { return Flag23 (Implementation_Base_Type (Id)); } *************** *** 1463,1468 **** --- 1488,1496 ---- INLINE E Object_Ref (E Id) { return Node17 (Id); } + INLINE E Original_Array_Type (E Id) + { return Node21 (Id); } + INLINE E Original_Record_Component (E Id) { return Node22 (Id); } *************** *** 1745,1780 **** INLINE B Is_Type (E Id) { return IN (Ekind (Id), Type_Kind); } - INLINE B Known_Alignment (Entity_Id E) - { return Uint14 (E) != Uint_0; } - - INLINE B Known_Component_Bit_Offset (Entity_Id E) - { return Uint11 (E) != No_Uint; } - - INLINE B Known_Component_Size (Entity_Id E) - { return Uint22 (Base_Type (E)) != Uint_0; } - - INLINE B Known_Esize (Entity_Id E) - { return Uint12 (E) != Uint_0; } - - INLINE B Known_Static_Component_Size (Entity_Id E) - { return Uint22 (Base_Type (E)) > Uint_0; } - - INLINE B Known_Static_Esize (Entity_Id E) - { return Uint12 (E) > Uint_0; } - - INLINE B Unknown_Alignment (Entity_Id E) - { return Uint14 (E) == Uint_0; } - - INLINE B Unknown_Component_Bit_Offset (Entity_Id E) - { return Uint11 (E) == No_Uint; } - - INLINE B Unknown_Component_Size (Entity_Id E) - { return Uint22 (Base_Type (E)) == Uint_0; } - - INLINE B Unknown_Esize (Entity_Id E) - { return Uint12 (E) == Uint_0; } - INLINE N Entry_Index_Type (E Id) { return Etype (Discrete_Subtype_Definition (Parent (Id))); } --- 1773,1778 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/elists.adb gcc-3.3/gcc/ada/elists.adb *** gcc-3.2.3/gcc/ada/elists.adb 2002-05-04 03:27:40.000000000 +0000 --- gcc-3.3/gcc/ada/elists.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/elists.ads gcc-3.3/gcc/ada/elists.ads *** gcc-3.2.3/gcc/ada/elists.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/elists.ads 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/elists.h gcc-3.3/gcc/ada/elists.h *** gcc-3.2.3/gcc/ada/elists.h 2002-05-04 03:27:41.000000000 +0000 --- gcc-3.3/gcc/ada/elists.h 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- *************** struct Elmt_Item *** 51,59 **** /* The element list headers and element descriptors themselves are stored in two arrays. The pointers to these arrays are passed as a parameter to the tree transformer procedure and stored in the global variables Elists_Ptr ! and Elmts_Ptr after adjusting them by subtracting Elist_First_Entry and ! Elmt_First_Entry, so that Elist_Id and Elmt_Id values can be used as ! subscripts into these arrays */ extern struct Elist_Header *Elists_Ptr; extern struct Elmt_Item *Elmts_Ptr; --- 50,56 ---- /* The element list headers and element descriptors themselves are stored in two arrays. The pointers to these arrays are passed as a parameter to the tree transformer procedure and stored in the global variables Elists_Ptr ! and Elmts_Ptr. */ extern struct Elist_Header *Elists_Ptr; extern struct Elmt_Item *Elmts_Ptr; *************** INLINE Node_Id *** 70,97 **** Node (Elmt) Elmt_Id Elmt; { ! return Elmts_Ptr [Elmt].node; } INLINE Elmt_Id First_Elmt (List) Elist_Id List; { ! return Elists_Ptr [List].first; } INLINE Elmt_Id Last_Elmt (List) Elist_Id List; { ! return Elists_Ptr [List].last; } INLINE Elmt_Id Next_Elmt (Node) Elmt_Id Node; { ! Int N = Elmts_Ptr [Node].next; if (IN (N, Elist_Range)) return No_Elmt; --- 67,94 ---- Node (Elmt) Elmt_Id Elmt; { ! return Elmts_Ptr[Elmt - First_Elmt_Id].node; } INLINE Elmt_Id First_Elmt (List) Elist_Id List; { ! return Elists_Ptr[List - First_Elist_Id].first; } INLINE Elmt_Id Last_Elmt (List) Elist_Id List; { ! return Elists_Ptr[List - First_Elist_Id].last; } INLINE Elmt_Id Next_Elmt (Node) Elmt_Id Node; { ! Int N = Elmts_Ptr[Node - First_Elmt_Id].next; if (IN (N, Elist_Range)) return No_Elmt; *************** INLINE Boolean *** 103,107 **** Is_Empty_Elmt_List (Id) Elist_Id Id; { ! return Elists_Ptr [Id].first == No_Elmt; } --- 100,104 ---- Is_Empty_Elmt_List (Id) Elist_Id Id; { ! return Elists_Ptr[Id - First_Elist_Id].first == No_Elmt; } diff -Nrc3pad gcc-3.2.3/gcc/ada/errno.c gcc-3.3/gcc/ada/errno.c *** gcc-3.2.3/gcc/ada/errno.c 2002-05-04 03:27:41.000000000 +0000 --- gcc-3.3/gcc/ada/errno.c 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,12 **** * * * C Implementation File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/errout.adb gcc-3.3/gcc/ada/errout.adb *** gcc-3.2.3/gcc/ada/errout.adb 2002-05-04 03:27:41.000000000 +0000 --- gcc-3.3/gcc/ada/errout.adb 2002-10-23 07:33:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Hostparm; *** 42,47 **** --- 41,47 ---- with Lib; use Lib; with Namet; use Namet; with Opt; use Opt; + with Nlists; use Nlists; with Output; use Output; with Scans; use Scans; with Sinput; use Sinput; *************** package body Errout is *** 72,77 **** --- 72,80 ---- Is_Warning_Msg : Boolean; -- Set by Set_Msg_Text to indicate if current message is warning message + Is_Serious_Error : Boolean; + -- Set by Set_Msg_Text to indicate if current message is serious error + Is_Unconditional_Msg : Boolean; -- Set by Set_Msg_Text to indicate if current message is unconditional *************** package body Errout is *** 161,166 **** --- 164,172 ---- Warn : Boolean; -- True if warning message (i.e. insertion character ? appeared) + Serious : Boolean; + -- True if serious error message (not a warning and no | character) + Uncond : Boolean; -- True if unconditional message (i.e. insertion character ! appeared) *************** package body Errout is *** 399,404 **** --- 405,422 ---- -- Outputs up to N levels of qualification for the given entity. For -- example, the entity A.B.C.D will output B.C. if N = 2. + function Special_Msg_Delete + (Msg : String; + N : Node_Or_Entity_Id; + E : Node_Or_Entity_Id) + return Boolean; + -- This function is called from Error_Msg_NEL, passing the message Msg, + -- node N on which the error is to be posted, and the entity or node E + -- to be used for an & insertion in the message if any. The job of this + -- procedure is to test for certain cascaded messages that we would like + -- to suppress. If the message is to be suppressed then we return True. + -- If the message should be generated (the normal case) False is returned. + procedure Test_Warning_Msg (Msg : String); -- Sets Is_Warning_Msg true if Msg is a warning message (contains a -- question mark character), and False otherwise. *************** package body Errout is *** 506,511 **** --- 524,533 ---- -- always know that Keep has at least as many continuations as -- Delete (since we always delete the shorter sequence). + ---------------- + -- Delete_Msg -- + ---------------- + procedure Delete_Msg (Delete, Keep : Error_Msg_Id) is D, K : Error_Msg_Id; *************** package body Errout is *** 521,527 **** if Errors.Table (D).Warn then Warnings_Detected := Warnings_Detected - 1; else ! Errors_Detected := Errors_Detected - 1; end if; -- Substitute shorter of the two error messages --- 543,553 ---- if Errors.Table (D).Warn then Warnings_Detected := Warnings_Detected - 1; else ! Total_Errors_Detected := Total_Errors_Detected - 1; ! ! if Errors.Table (D).Serious then ! Serious_Errors_Detected := Serious_Errors_Detected - 1; ! end if; end if; -- Substitute shorter of the two error messages *************** package body Errout is *** 602,608 **** function Compilation_Errors return Boolean is begin ! return Errors_Detected /= 0 or else (Warnings_Detected /= 0 and then Warning_Mode = Treat_As_Error); end Compilation_Errors; --- 628,634 ---- function Compilation_Errors return Boolean is begin ! return Total_Errors_Detected /= 0 or else (Warnings_Detected /= 0 and then Warning_Mode = Treat_As_Error); end Compilation_Errors; *************** package body Errout is *** 647,652 **** --- 673,679 ---- w (" Line = ", Int (E.Line)); w (" Col = ", Int (E.Col)); w (" Warn = ", E.Warn); + w (" Serious = ", E.Serious); w (" Uncond = ", E.Uncond); w (" Msg_Cont = ", E.Msg_Cont); w (" Deleted = ", E.Deleted); *************** package body Errout is *** 679,685 **** -- that this is safe in the sense that proceeding will surely bomb. if Flag_Location < First_Source_Ptr ! and then Errors_Detected > 0 then return; end if; --- 706,712 ---- -- that this is safe in the sense that proceeding will surely bomb. if Flag_Location < First_Source_Ptr ! and then Total_Errors_Detected > 0 then return; end if; *************** package body Errout is *** 976,986 **** Orig_Loc : constant Source_Ptr := Original_Location (Flag_Location); ! procedure Handle_Fatal_Error; ! -- Internal procedure to do all error message handling other than ! -- bumping the error count and arranging for the message to be output. ! procedure Handle_Fatal_Error is begin -- Turn off code generation if not done already --- 1003,1018 ---- Orig_Loc : constant Source_Ptr := Original_Location (Flag_Location); ! procedure Handle_Serious_Error; ! -- Internal procedure to do all error message handling for a serious ! -- error message, other than bumping the error counts and arranging ! -- for the message to be output. ! -------------------------- ! -- Handle_Serious_Error -- ! -------------------------- ! ! procedure Handle_Serious_Error is begin -- Turn off code generation if not done already *************** package body Errout is *** 991,997 **** -- Set the fatal error flag in the unit table unless we are -- in Try_Semantics mode. This stops the semantics from being ! -- performed if we find a parser error. This is skipped if we -- are currently dealing with the configuration pragma file. if not Try_Semantics --- 1023,1029 ---- -- Set the fatal error flag in the unit table unless we are -- in Try_Semantics mode. This stops the semantics from being ! -- performed if we find a serious error. This is skipped if we -- are currently dealing with the configuration pragma file. if not Try_Semantics *************** package body Errout is *** 999,1005 **** then Set_Fatal_Error (Get_Source_Unit (Orig_Loc)); end if; ! end Handle_Fatal_Error; -- Start of processing for Error_Msg_Internal --- 1031,1037 ---- then Set_Fatal_Error (Get_Source_Unit (Orig_Loc)); end if; ! end Handle_Serious_Error; -- Start of processing for Error_Msg_Internal *************** package body Errout is *** 1039,1045 **** if Kill_Message and then not All_Errors_Mode ! and then Errors_Detected /= 0 then if not Continuation then Last_Killed := True; --- 1071,1077 ---- if Kill_Message and then not All_Errors_Mode ! and then Total_Errors_Detected /= 0 then if not Continuation then Last_Killed := True; *************** package body Errout is *** 1059,1065 **** -- where we do this special processing, bypassing message output. if Ignore_Errors_Enable > 0 then ! Handle_Fatal_Error; return; end if; --- 1091,1100 ---- -- where we do this special processing, bypassing message output. if Ignore_Errors_Enable > 0 then ! if Is_Serious_Error then ! Handle_Serious_Error; ! end if; ! return; end if; *************** package body Errout is *** 1075,1080 **** --- 1110,1116 ---- Errors.Table (Cur_Msg).Line := Get_Physical_Line_Number (Orig_Loc); Errors.Table (Cur_Msg).Col := Get_Column_Number (Orig_Loc); Errors.Table (Cur_Msg).Warn := Is_Warning_Msg; + Errors.Table (Cur_Msg).Serious := Is_Serious_Error; Errors.Table (Cur_Msg).Uncond := Is_Unconditional_Msg; Errors.Table (Cur_Msg).Msg_Cont := Continuation; Errors.Table (Cur_Msg).Deleted := False; *************** package body Errout is *** 1181,1193 **** if Errors.Table (Cur_Msg).Warn then Warnings_Detected := Warnings_Detected + 1; else ! Errors_Detected := Errors_Detected + 1; ! Handle_Fatal_Error; end if; -- Terminate if max errors reached ! if Errors_Detected + Warnings_Detected = Maximum_Errors then raise Unrecoverable_Error; end if; --- 1217,1233 ---- if Errors.Table (Cur_Msg).Warn then Warnings_Detected := Warnings_Detected + 1; else ! Total_Errors_Detected := Total_Errors_Detected + 1; ! ! if Errors.Table (Cur_Msg).Serious then ! Serious_Errors_Detected := Serious_Errors_Detected + 1; ! Handle_Serious_Error; ! end if; end if; -- Terminate if max errors reached ! if Total_Errors_Detected + Warnings_Detected = Maximum_Errors then raise Unrecoverable_Error; end if; *************** package body Errout is *** 1199,1228 **** procedure Error_Msg_N (Msg : String; N : Node_Or_Entity_Id) is begin ! if No_Warnings (N) then ! Test_Warning_Msg (Msg); ! ! if Is_Warning_Msg then ! return; ! end if; ! end if; ! ! if All_Errors_Mode ! or else Msg (Msg'Last) = '!' ! or else OK_Node (N) ! or else (Msg (1) = '\' and not Last_Killed) ! then ! Debug_Output (N); ! Error_Msg_Node_1 := N; ! Error_Msg (Msg, Sloc (N)); ! ! else ! Last_Killed := True; ! end if; ! ! if not Is_Warning_Msg then ! Set_Posted (N); ! end if; end Error_Msg_N; ------------------ --- 1239,1245 ---- procedure Error_Msg_N (Msg : String; N : Node_Or_Entity_Id) is begin ! Error_Msg_NEL (Msg, N, N, Sloc (N)); end Error_Msg_N; ------------------ *************** package body Errout is *** 1235,1240 **** --- 1252,1275 ---- E : Node_Or_Entity_Id) is begin + Error_Msg_NEL (Msg, N, E, Sloc (N)); + end Error_Msg_NE; + + ------------------- + -- Error_Msg_NEL -- + ------------------- + + procedure Error_Msg_NEL + (Msg : String; + N : Node_Or_Entity_Id; + E : Node_Or_Entity_Id; + Flag_Location : Source_Ptr) + is + begin + if Special_Msg_Delete (Msg, N, E) then + return; + end if; + if No_Warnings (N) or else No_Warnings (E) then Test_Warning_Msg (Msg); *************** package body Errout is *** 1250,1256 **** then Debug_Output (N); Error_Msg_Node_1 := E; ! Error_Msg (Msg, Sloc (N)); else Last_Killed := True; --- 1285,1291 ---- then Debug_Output (N); Error_Msg_Node_1 := E; ! Error_Msg (Msg, Flag_Location); else Last_Killed := True; *************** package body Errout is *** 1259,1265 **** if not Is_Warning_Msg then Set_Posted (N); end if; ! end Error_Msg_NE; ----------------- -- Error_Msg_S -- --- 1294,1300 ---- if not Is_Warning_Msg then Set_Posted (N); end if; ! end Error_Msg_NEL; ----------------- -- Error_Msg_S -- *************** package body Errout is *** 1431,1437 **** -- Extra blank line if error messages or source listing were output ! if Errors_Detected + Warnings_Detected > 0 or else Full_List then Write_Eol; end if; --- 1466,1474 ---- -- Extra blank line if error messages or source listing were output ! if Total_Errors_Detected + Warnings_Detected > 0 ! or else Full_List ! then Write_Eol; end if; *************** package body Errout is *** 1447,1453 **** -- the stdout buffer was flushed, giving an extra line feed after -- the prefix. ! if Errors_Detected + Warnings_Detected /= 0 and then not Brief_Output and then (Verbose_Mode or Full_List) then --- 1484,1490 ---- -- the stdout buffer was flushed, giving an extra line feed after -- the prefix. ! if Total_Errors_Detected + Warnings_Detected /= 0 and then not Brief_Output and then (Verbose_Mode or Full_List) then *************** package body Errout is *** 1465,1478 **** Write_Str (" lines: "); end if; ! if Errors_Detected = 0 then Write_Str ("No errors"); ! elsif Errors_Detected = 1 then Write_Str ("1 error"); else ! Write_Int (Errors_Detected); Write_Str (" errors"); end if; --- 1502,1515 ---- Write_Str (" lines: "); end if; ! if Total_Errors_Detected = 0 then Write_Str ("No errors"); ! elsif Total_Errors_Detected = 1 then Write_Str ("1 error"); else ! Write_Int (Total_Errors_Detected); Write_Str (" errors"); end if; *************** package body Errout is *** 1501,1507 **** end if; if Maximum_Errors /= 0 ! and then Errors_Detected + Warnings_Detected = Maximum_Errors then Set_Standard_Error; Write_Str ("fatal error: maximum errors reached"); --- 1538,1544 ---- end if; if Maximum_Errors /= 0 ! and then Total_Errors_Detected + Warnings_Detected = Maximum_Errors then Set_Standard_Error; Write_Str ("fatal error: maximum errors reached"); *************** package body Errout is *** 1510,1516 **** end if; if Warning_Mode = Treat_As_Error then ! Errors_Detected := Errors_Detected + Warnings_Detected; Warnings_Detected := 0; end if; --- 1547,1553 ---- end if; if Warning_Mode = Treat_As_Error then ! Total_Errors_Detected := Total_Errors_Detected + Warnings_Detected; Warnings_Detected := 0; end if; *************** package body Errout is *** 1542,1548 **** begin Errors.Init; Error_Msgs := No_Error_Msg; ! Errors_Detected := 0; Warnings_Detected := 0; Cur_Msg := No_Error_Msg; List_Pragmas.Init; --- 1579,1586 ---- begin Errors.Init; Error_Msgs := No_Error_Msg; ! Serious_Errors_Detected := 0; ! Total_Errors_Detected := 0; Warnings_Detected := 0; Cur_Msg := No_Error_Msg; List_Pragmas.Init; *************** package body Errout is *** 1907,1913 **** if Errors.Table (E).Warn then Warnings_Detected := Warnings_Detected - 1; else ! Errors_Detected := Errors_Detected - 1; end if; return True; --- 1945,1955 ---- if Errors.Table (E).Warn then Warnings_Detected := Warnings_Detected - 1; else ! Total_Errors_Detected := Total_Errors_Detected - 1; ! ! if Errors.Table (E).Serious then ! Serious_Errors_Detected := Serious_Errors_Detected - 1; ! end if; end if; return True; *************** package body Errout is *** 1996,2016 **** if Nkind (N) = N_Raise_Constraint_Error and then Original_Node (N) /= N then -- Warnings may have been posted on subexpressions of ! -- the original tree. We temporarily replace the raise ! -- statement with the original expression to remove ! -- those warnings, whose sloc do not match those of ! -- any node in the current tree. declare - Old : Node_Id := N; Status : Traverse_Result; begin ! Rewrite (N, Original_Node (N)); ! Status := Check_For_Warning (N); ! Rewrite (N, Old); return Status; end; --- 2038,2064 ---- if Nkind (N) = N_Raise_Constraint_Error and then Original_Node (N) /= N + and then No (Condition (N)) then -- Warnings may have been posted on subexpressions of ! -- the original tree. We place the original node back ! -- on the tree to remove those warnings, whose sloc ! -- do not match those of any node in the current tree. ! -- Given that we are in unreachable code, this modification ! -- to the tree is harmless. declare Status : Traverse_Result; begin ! if Is_List_Member (N) then ! Set_Condition (N, Original_Node (N)); ! Status := Check_All_Warnings (Condition (N)); ! else ! Rewrite (N, Original_Node (N)); ! Status := Check_All_Warnings (N); ! end if; ! return Status; end; *************** package body Errout is *** 2825,2830 **** --- 2873,2881 ---- elsif C = '?' then null; + elsif C = '|' then + null; + elsif C = ''' then Set_Msg_Char (Text (P)); P := P + 1; *************** package body Errout is *** 2887,2892 **** --- 2938,2954 ---- Set_Error_Posted (P); exit when Nkind (P) not in N_Subexpr; end loop; + + -- A special check, if we just posted an error on an attribute + -- definition clause, then also set the entity involved as posted. + -- For example, this stops complaining about the alignment after + -- complaining about the size, which is likely to be useless. + + if Nkind (P) = N_Attribute_Definition_Clause then + if Is_Entity_Name (Name (P)) then + Set_Error_Posted (Entity (Name (P))); + end if; + end if; end Set_Posted; ----------------------- *************** package body Errout is *** 2963,2977 **** end if; end Set_Warnings_Mode_On; ! ---------------------- ! -- Test_Warning_Msg -- ! ---------------------- procedure Test_Warning_Msg (Msg : String) is begin if Msg'Length > 7 and then Msg (1 .. 7) = "(style)" then Is_Warning_Msg := True; ! return; end if; for J in Msg'Range loop --- 3025,3102 ---- end if; end Set_Warnings_Mode_On; ! ------------------------ ! -- Special_Msg_Delete -- ! ------------------------ ! ! function Special_Msg_Delete ! (Msg : String; ! N : Node_Or_Entity_Id; ! E : Node_Or_Entity_Id) ! return Boolean ! is ! begin ! -- Never delete messages in -gnatdO mode ! ! if Debug_Flag_OO then ! return False; ! ! -- When an atomic object refers to a non-atomic type in the same ! -- scope, we implicitly make the type atomic. In the non-error ! -- case this is surely safe (and in fact prevents an error from ! -- occurring if the type is not atomic by default). But if the ! -- object cannot be made atomic, then we introduce an extra junk ! -- message by this manipulation, which we get rid of here. ! ! -- We identify this case by the fact that it references a type for ! -- which Is_Atomic is set, but there is no Atomic pragma setting it. ! ! elsif Msg = "atomic access to & cannot be guaranteed" ! and then Is_Type (E) ! and then Is_Atomic (E) ! and then No (Get_Rep_Pragma (E, Name_Atomic)) ! then ! return True; ! ! -- When a size is wrong for a frozen type there is no explicit ! -- size clause, and other errors have occurred, suppress the ! -- message, since it is likely that this size error is a cascaded ! -- result of other errors. The reason we eliminate unfrozen types ! -- is that messages issued before the freeze type are for sure OK. ! ! elsif Msg = "size for& too small, minimum allowed is ^" ! and then Is_Frozen (E) ! and then Serious_Errors_Detected > 0 ! and then Nkind (N) /= N_Component_Clause ! and then Nkind (Parent (N)) /= N_Component_Clause ! and then ! No (Get_Attribute_Definition_Clause (E, Attribute_Size)) ! and then ! No (Get_Attribute_Definition_Clause (E, Attribute_Object_Size)) ! and then ! No (Get_Attribute_Definition_Clause (E, Attribute_Value_Size)) ! then ! return True; ! ! -- All special tests complete, so go ahead with message ! ! else ! return False; ! end if; ! end Special_Msg_Delete; ! ! ------------------------------ ! -- Test_Warning_Serious_Msg -- ! ------------------------------ procedure Test_Warning_Msg (Msg : String) is begin + Is_Serious_Error := True; + if Msg'Length > 7 and then Msg (1 .. 7) = "(style)" then Is_Warning_Msg := True; ! else ! Is_Warning_Msg := False; end if; for J in Msg'Range loop *************** package body Errout is *** 2979,2989 **** and then (J = Msg'First or else Msg (J - 1) /= ''') then Is_Warning_Msg := True; ! return; end if; end loop; ! Is_Warning_Msg := False; end Test_Warning_Msg; -------------------------- --- 3104,3120 ---- and then (J = Msg'First or else Msg (J - 1) /= ''') then Is_Warning_Msg := True; ! ! elsif Msg (J) = '|' ! and then (J = Msg'First or else Msg (J - 1) /= ''') ! then ! Is_Serious_Error := False; end if; end loop; ! if Is_Warning_Msg then ! Is_Serious_Error := False; ! end if; end Test_Warning_Msg; -------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/errout.ads gcc-3.3/gcc/ada/errout.ads *** gcc-3.2.3/gcc/ada/errout.ads 2002-05-04 03:27:41.000000000 +0000 --- gcc-3.3/gcc/ada/errout.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Uintp; use Uintp; *** 37,44 **** package Errout is ! Errors_Detected : Nat; ! -- Number of errors detected so far Warnings_Detected : Nat; -- Number of warnings detected --- 36,50 ---- package Errout is ! Serious_Errors_Detected : Nat; ! -- This is a count of errors that are serious enough to stop expansion, ! -- and hence to prevent generation of an object file even if the ! -- switch -gnatQ is set. ! ! Total_Errors_Detected : Nat; ! -- Number of errors detected so far. Includes count of serious errors ! -- and non-serious errors, so this value is always greater than or ! -- equal to the Serious_Errors_Detected value. Warnings_Detected : Nat; -- Number of warnings detected *************** package Errout is *** 242,247 **** --- 248,261 ---- -- of messages are treated as a unit. The \ character must be -- the first character of the message text. + -- Insertion character | (vertical bar, non-serious error) + -- By default, error messages (other than warning messages) are + -- considered to be fatal error messages which prevent expansion + -- or generation of code in the presence of the -gnatQ switch. + -- If the insertion character | appears, the message is considered + -- to be non-serious, and does not cause Serious_Errors_Detected + -- to be incremented (so expansion is not prevented by such a msg). + ----------------------------------------------------- -- Global Values Used for Error Message Insertions -- ----------------------------------------------------- *************** package Errout is *** 462,478 **** -- from the latter is much more common (and is the most usual way of -- generating error messages from the analyzer). The message text may -- contain a single & insertion, which will reference the given node. procedure Error_Msg_NE (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id); ! -- Output a message at the Sloc of the given node, with an insertion of ! -- the name from the given entity node. This is used by the semantic -- routines, where this is a common error message situation. The Msg -- text will contain a & or } as usual to mark the insertion point. -- This routine can be called from the parser or the analyzer. procedure Change_Error_Text (Error_Id : Error_Msg_Id; New_Msg : String); -- The error message text of the message identified by Id is replaced by -- the given text. This text may contain insertion characters in the --- 476,503 ---- -- from the latter is much more common (and is the most usual way of -- generating error messages from the analyzer). The message text may -- contain a single & insertion, which will reference the given node. + -- The message is suppressed if the node N already has a message posted, + -- or if it is a warning and warnings and N is an entity node for which + -- warnings are suppressed. procedure Error_Msg_NE (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id); ! -- Output a message at the Sloc of the given node N, with an insertion of ! -- the name from the given entity node E. This is used by the semantic -- routines, where this is a common error message situation. The Msg -- text will contain a & or } as usual to mark the insertion point. -- This routine can be called from the parser or the analyzer. + procedure Error_Msg_NEL + (Msg : String; + N : Node_Or_Entity_Id; + E : Node_Or_Entity_Id; + Flag_Location : Source_Ptr); + -- Exactly the same as Error_Msg_NE, except that the flag is placed at + -- the specified Flag_Location instead of at Sloc (N). + procedure Change_Error_Text (Error_Id : Error_Msg_Id; New_Msg : String); -- The error message text of the message identified by Id is replaced by -- the given text. This text may contain insertion characters in the diff -Nrc3pad gcc-3.2.3/gcc/ada/eval_fat.adb gcc-3.3/gcc/ada/eval_fat.adb *** gcc-3.2.3/gcc/ada/eval_fat.adb 2002-05-04 03:27:42.000000000 +0000 --- gcc-3.3/gcc/ada/eval_fat.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Eval_Fat is *** 145,150 **** --- 144,150 ---- --------------- function Copy_Sign (RT : R; Value, Sign : T) return T is + pragma Warnings (Off, RT); Result : T; begin *************** package body Eval_Fat is *** 838,843 **** --- 838,845 ---- ------------- function Scaling (RT : R; X : T; Adjustment : UI) return T is + pragma Warnings (Off, RT); + begin if Rbase (X) = Radix then return UR_From_Components *************** package body Eval_Fat is *** 894,899 **** --- 896,903 ---- ---------------- function Truncation (RT : R; X : T) return T is + pragma Warnings (Off, RT); + begin return UR_From_Uint (UR_Trunc (X)); end Truncation; diff -Nrc3pad gcc-3.2.3/gcc/ada/eval_fat.ads gcc-3.3/gcc/ada/eval_fat.ads *** gcc-3.2.3/gcc/ada/eval_fat.ads 2002-05-04 03:27:43.000000000 +0000 --- gcc-3.3/gcc/ada/eval_fat.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exit.c gcc-3.3/gcc/ada/exit.c *** gcc-3.2.3/gcc/ada/exit.c 2002-05-04 03:27:43.000000000 +0000 --- gcc-3.3/gcc/ada/exit.c 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** * * * C Implementation File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_aggr.adb gcc-3.3/gcc/ada/exp_aggr.adb *** gcc-3.2.3/gcc/ada/exp_aggr.adb 2002-05-04 03:27:43.000000000 +0000 --- gcc-3.3/gcc/ada/exp_aggr.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** *** 28,33 **** --- 27,33 ---- with Atree; use Atree; with Checks; use Checks; + with Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Expander; use Expander; *************** with Exp_Ch7; use Exp_Ch7; *** 37,46 **** --- 37,48 ---- with Freeze; use Freeze; with Hostparm; use Hostparm; with Itypes; use Itypes; + with Lib; use Lib; with Nmake; use Nmake; with Nlists; use Nlists; with Restrict; use Restrict; with Rtsfind; use Rtsfind; + with Ttypes; use Ttypes; with Sem; use Sem; with Sem_Ch3; use Sem_Ch3; with Sem_Eval; use Sem_Eval; *************** package body Exp_Aggr is *** 113,122 **** -- an entity that allows to know if the value being created needs to be -- attached to the final list in case of pragma finalize_Storage_Only. ----------------------------------------------------- ! -- Local subprograms for array aggregate expansion -- ----------------------------------------------------- procedure Expand_Array_Aggregate (N : Node_Id); -- This is the top-level routine to perform array aggregate expansion. -- N is the N_Aggregate node to be expanded. --- 115,155 ---- -- an entity that allows to know if the value being created needs to be -- attached to the final list in case of pragma finalize_Storage_Only. + procedure Initialize_Discriminants (N : Node_Id; Typ : Entity_Id); + -- If the type of the aggregate is a type extension with renamed discrimi- + -- nants, we must initialize the hidden discriminants of the parent. + -- Otherwise, the target object must not be initialized. The discriminants + -- are initialized by calling the initialization procedure for the type. + -- This is incorrect if the initialization of other components has any + -- side effects. We restrict this call to the case where the parent type + -- has a variant part, because this is the only case where the hidden + -- discriminants are accessed, namely when calling discriminant checking + -- functions of the parent type, and when applying a stream attribute to + -- an object of the derived type. + ----------------------------------------------------- ! -- Local Subprograms for Array Aggregate Expansion -- ----------------------------------------------------- + procedure Convert_To_Positional + (N : Node_Id; + Max_Others_Replicate : Nat := 5; + Handle_Bit_Packed : Boolean := False); + -- If possible, convert named notation to positional notation. This + -- conversion is possible only in some static cases. If the conversion + -- is possible, then N is rewritten with the analyzed converted + -- aggregate. The parameter Max_Others_Replicate controls the maximum + -- number of values corresponding to an others choice that will be + -- converted to positional notation (the default of 5 is the normal + -- limit, and reflects the fact that normally the loop is better than + -- a lot of separate assignments). Note that this limit gets overridden + -- in any case if either of the restrictions No_Elaboration_Code or + -- No_Implicit_Loops is set. The parameter Handle_Bit_Packed is usually + -- set False (since we do not expect the back end to handle bit packed + -- arrays, so the normal case of conversion is pointless), but in the + -- special case of a call from Packed_Array_Aggregate_Handled, we set + -- this parameter to True, since these are cases we handle in there. + procedure Expand_Array_Aggregate (N : Node_Id); -- This is the top-level routine to perform array aggregate expansion. -- N is the N_Aggregate node to be expanded. *************** package body Exp_Aggr is *** 185,194 **** -- use this routine. This is needed to deal with assignments to -- initialized constants that are done in place. ! function Safe_Slice_Assignment ! (N : Node_Id; ! Typ : Entity_Id) ! return Boolean; -- If a slice assignment has an aggregate with a single others_choice, -- the assignment can be done in place even if bounds are not static, -- by converting it into a loop over the discrete range of the slice. --- 218,233 ---- -- use this routine. This is needed to deal with assignments to -- initialized constants that are done in place. ! function Packed_Array_Aggregate_Handled (N : Node_Id) return Boolean; ! -- Given an array aggregate, this function handles the case of a packed ! -- array aggregate with all constant values, where the aggregate can be ! -- evaluated at compile time. If this is possible, then N is rewritten ! -- to be its proper compile time value with all the components properly ! -- assembled. The expression is analyzed and resolved and True is ! -- returned. If this transformation is not possible, N is unchanged ! -- and False is returned ! ! function Safe_Slice_Assignment (N : Node_Id) return Boolean; -- If a slice assignment has an aggregate with a single others_choice, -- the assignment can be done in place even if bounds are not static, -- by converting it into a loop over the discrete range of the slice. *************** package body Exp_Aggr is *** 340,349 **** -- we always generate something like: ! -- I : Index_Type := Index_Of_Last_Positional_Element; ! -- while I < H loop ! -- I := Index_Base'Succ (I) ! -- Tmp (I) := E; -- end loop; function Build_Array_Aggr_Code --- 379,388 ---- -- we always generate something like: ! -- J : Index_Type := Index_Of_Last_Positional_Element; ! -- while J < H loop ! -- J := Index_Base'Succ (J) ! -- Tmp (J) := E; -- end loop; function Build_Array_Aggr_Code *************** package body Exp_Aggr is *** 401,410 **** -- If the input aggregate N to Build_Loop contains no sub-aggregates, -- This routine returns the while loop statement -- ! -- I : Index_Base := L; ! -- while I < H loop ! -- I := Index_Base'Succ (I); ! -- Into (Indices, I) := Expr; -- end loop; -- -- Otherwise we call Build_Code recursively. --- 440,449 ---- -- If the input aggregate N to Build_Loop contains no sub-aggregates, -- This routine returns the while loop statement -- ! -- J : Index_Base := L; ! -- while J < H loop ! -- J := Index_Base'Succ (J); ! -- Into (Indices, J) := Expr; -- end loop; -- -- Otherwise we call Build_Code recursively. *************** package body Exp_Aggr is *** 788,800 **** -------------- function Gen_Loop (L, H : Node_Id; Expr : Node_Id) return List_Id is ! L_I : Node_Id; L_Range : Node_Id; -- Index_Base'(L) .. Index_Base'(H) L_Iteration_Scheme : Node_Id; ! -- L_I in Index_Base'(L) .. Index_Base'(H) L_Body : List_Id; -- The statements to execute in the loop --- 827,839 ---- -------------- function Gen_Loop (L, H : Node_Id; Expr : Node_Id) return List_Id is ! L_J : Node_Id; L_Range : Node_Id; -- Index_Base'(L) .. Index_Base'(H) L_Iteration_Scheme : Node_Id; ! -- L_J in Index_Base'(L) .. Index_Base'(H) L_Body : List_Id; -- The statements to execute in the loop *************** package body Exp_Aggr is *** 855,863 **** return S; end if; ! -- Otherwise construct the loop, starting with the loop index L_I ! L_I := Make_Defining_Identifier (Loc, New_Internal_Name ('I')); -- Construct "L .. H" --- 894,902 ---- return S; end if; ! -- Otherwise construct the loop, starting with the loop index L_J ! L_J := Make_Defining_Identifier (Loc, New_Internal_Name ('J')); -- Construct "L .. H" *************** package body Exp_Aggr is *** 873,879 **** Subtype_Mark => Index_Base_Name, Expression => H)); ! -- Construct "for L_I in Index_Base range L .. H" L_Iteration_Scheme := Make_Iteration_Scheme --- 912,918 ---- Subtype_Mark => Index_Base_Name, Expression => H)); ! -- Construct "for L_J in Index_Base range L .. H" L_Iteration_Scheme := Make_Iteration_Scheme *************** package body Exp_Aggr is *** 881,892 **** Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, ! Defining_Identifier => L_I, Discrete_Subtype_Definition => L_Range)); -- Construct the statements to execute in the loop body ! L_Body := Gen_Assign (New_Reference_To (L_I, Loc), Expr); -- Construct the final loop --- 920,931 ---- Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, ! Defining_Identifier => L_J, Discrete_Subtype_Definition => L_Range)); -- Construct the statements to execute in the loop body ! L_Body := Gen_Assign (New_Reference_To (L_J, Loc), Expr); -- Construct the final loop *************** package body Exp_Aggr is *** 905,931 **** -- The code built is ! -- W_I : Index_Base := L; ! -- while W_I < H loop ! -- W_I := Index_Base'Succ (W); -- L_Body; -- end loop; function Gen_While (L, H : Node_Id; Expr : Node_Id) return List_Id is ! W_I : Node_Id; W_Decl : Node_Id; ! -- W_I : Base_Type := L; W_Iteration_Scheme : Node_Id; ! -- while W_I < H W_Index_Succ : Node_Id; ! -- Index_Base'Succ (I) W_Increment : Node_Id; ! -- W_I := Index_Base'Succ (W) W_Body : List_Id := New_List; -- The statements to execute in the loop --- 944,970 ---- -- The code built is ! -- W_J : Index_Base := L; ! -- while W_J < H loop ! -- W_J := Index_Base'Succ (W); -- L_Body; -- end loop; function Gen_While (L, H : Node_Id; Expr : Node_Id) return List_Id is ! W_J : Node_Id; W_Decl : Node_Id; ! -- W_J : Base_Type := L; W_Iteration_Scheme : Node_Id; ! -- while W_J < H W_Index_Succ : Node_Id; ! -- Index_Base'Succ (J) W_Increment : Node_Id; ! -- W_J := Index_Base'Succ (W) W_Body : List_Id := New_List; -- The statements to execute in the loop *************** package body Exp_Aggr is *** 941,953 **** return S; end if; ! -- Build the decl of W_I ! W_I := Make_Defining_Identifier (Loc, New_Internal_Name ('I')); W_Decl := Make_Object_Declaration (Loc, ! Defining_Identifier => W_I, Object_Definition => Index_Base_Name, Expression => L); --- 980,992 ---- return S; end if; ! -- Build the decl of W_J ! W_J := Make_Defining_Identifier (Loc, New_Internal_Name ('J')); W_Decl := Make_Object_Declaration (Loc, ! Defining_Identifier => W_J, Object_Definition => Index_Base_Name, Expression => L); *************** package body Exp_Aggr is *** 957,970 **** Append_To (S, W_Decl); ! -- construct " while W_I < H" W_Iteration_Scheme := Make_Iteration_Scheme (Loc, Condition => Make_Op_Lt (Loc, ! Left_Opnd => New_Reference_To (W_I, Loc), Right_Opnd => New_Copy_Tree (H))); -- Construct the statements to execute in the loop body --- 996,1009 ---- Append_To (S, W_Decl); ! -- construct " while W_J < H" W_Iteration_Scheme := Make_Iteration_Scheme (Loc, Condition => Make_Op_Lt (Loc, ! Left_Opnd => New_Reference_To (W_J, Loc), Right_Opnd => New_Copy_Tree (H))); -- Construct the statements to execute in the loop body *************** package body Exp_Aggr is *** 974,990 **** (Loc, Prefix => Index_Base_Name, Attribute_Name => Name_Succ, ! Expressions => New_List (New_Reference_To (W_I, Loc))); W_Increment := Make_OK_Assignment_Statement (Loc, ! Name => New_Reference_To (W_I, Loc), Expression => W_Index_Succ); Append_To (W_Body, W_Increment); Append_List_To (W_Body, ! Gen_Assign (New_Reference_To (W_I, Loc), Expr)); -- Construct the final loop --- 1013,1029 ---- (Loc, Prefix => Index_Base_Name, Attribute_Name => Name_Succ, ! Expressions => New_List (New_Reference_To (W_J, Loc))); W_Increment := Make_OK_Assignment_Statement (Loc, ! Name => New_Reference_To (W_J, Loc), Expression => W_Index_Succ); Append_To (W_Body, W_Increment); Append_List_To (W_Body, ! Gen_Assign (New_Reference_To (W_J, Loc), Expr)); -- Construct the final loop *************** package body Exp_Aggr is *** 1417,1424 **** Selector_Name => New_Occurrence_Of (Discr, Loc)), Right_Opnd => Disc_Value); ! Append_To (L, Make_Raise_Constraint_Error (Loc, ! Condition => Cond)); end if; Next_Discriminant (Discr); --- 1456,1465 ---- Selector_Name => New_Occurrence_Of (Discr, Loc)), Right_Opnd => Disc_Value); ! Append_To (L, ! Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Discriminant_Check_Failed)); end if; Next_Discriminant (Discr); *************** package body Exp_Aggr is *** 1556,1562 **** --- 1597,1606 ---- Subtype_Indication => New_Indic); -- Itypes must be analyzed with checks off + -- Declaration must have a parent for proper + -- handling of subsidiary actions. + Set_Parent (Subt_Decl, N); Analyze (Subt_Decl, Suppress => All_Checks); end; end if; *************** package body Exp_Aggr is *** 2073,2078 **** --- 2117,2123 ---- Insert_Actions_After (N, Late_Expansion (Aggr, Typ, Occ, Obj => Obj)); Set_No_Initialization (N); + Initialize_Discriminants (N, Typ); end Convert_Aggr_In_Object_Decl; ---------------------------- *************** package body Exp_Aggr is *** 2151,2156 **** --- 2196,2202 ---- Set_No_Initialization (Instr); Insert_Action (N, Instr); + Initialize_Discriminants (Instr, Typ); Target_Expr := New_Occurrence_Of (Temp, Loc); Insert_Actions (N, Build_Record_Aggr_Code (N, Typ, Target_Expr)); *************** package body Exp_Aggr is *** 2158,2163 **** --- 2204,2442 ---- Analyze_And_Resolve (N, Typ); end Convert_To_Assignments; + --------------------------- + -- Convert_To_Positional -- + --------------------------- + + procedure Convert_To_Positional + (N : Node_Id; + Max_Others_Replicate : Nat := 5; + Handle_Bit_Packed : Boolean := False) + is + Loc : constant Source_Ptr := Sloc (N); + Typ : constant Entity_Id := Etype (N); + Ndim : constant Pos := Number_Dimensions (Typ); + Xtyp : constant Entity_Id := Etype (First_Index (Typ)); + Indx : constant Node_Id := First_Index (Base_Type (Typ)); + Blo : constant Node_Id := Type_Low_Bound (Etype (Indx)); + Lo : constant Node_Id := Type_Low_Bound (Xtyp); + Hi : constant Node_Id := Type_High_Bound (Xtyp); + Lov : Uint; + Hiv : Uint; + + -- The following constant determines the maximum size of an + -- aggregate produced by converting named to positional + -- notation (e.g. from others clauses). This avoids running + -- away with attempts to convert huge aggregates. + + -- The normal limit is 5000, but we increase this limit to + -- 2**24 (about 16 million) if Restrictions (No_Elaboration_Code) + -- or Restrictions (No_Implicit_Loops) is specified, since in + -- either case, we are at risk of declaring the program illegal + -- because of this limit. + + Max_Aggr_Size : constant Nat := + 5000 + (2 ** 24 - 5000) * Boolean'Pos + (Restrictions (No_Elaboration_Code) + or else + Restrictions (No_Implicit_Loops)); + + begin + -- For now, we only handle the one dimensional case and aggregates + -- that are not part of a component_association + + if Ndim > 1 or else Nkind (Parent (N)) = N_Aggregate + or else Nkind (Parent (N)) = N_Component_Association + then + return; + end if; + + -- If already positional, nothing to do! + + if No (Component_Associations (N)) then + return; + end if; + + -- Bounds need to be known at compile time + + if not Compile_Time_Known_Value (Lo) + or else not Compile_Time_Known_Value (Hi) + then + return; + end if; + + -- Normally we do not attempt to convert bit packed arrays. The + -- exception is when we are explicitly asked to do so (this call + -- is from the Packed_Array_Aggregate_Handled procedure). + + if Is_Bit_Packed_Array (Typ) + and then not Handle_Bit_Packed + then + return; + end if; + + -- Do not convert to positional if controlled components are + -- involved since these require special processing + + if Has_Controlled_Component (Typ) then + return; + end if; + + -- Get bounds and check reasonable size (positive, not too large) + -- Also only handle bounds starting at the base type low bound for now + -- since the compiler isn't able to handle different low bounds yet. + + Lov := Expr_Value (Lo); + Hiv := Expr_Value (Hi); + + if Hiv < Lov + or else (Hiv - Lov > Max_Aggr_Size) + or else not Compile_Time_Known_Value (Blo) + or else (Lov /= Expr_Value (Blo)) + then + return; + end if; + + -- Bounds must be in integer range (for array Vals below) + + if not UI_Is_In_Int_Range (Lov) + or else + not UI_Is_In_Int_Range (Hiv) + then + return; + end if; + + -- Determine if set of alternatives is suitable for conversion + -- and build an array containing the values in sequence. + + declare + Vals : array (UI_To_Int (Lov) .. UI_To_Int (Hiv)) + of Node_Id := (others => Empty); + -- The values in the aggregate sorted appropriately + + Vlist : List_Id; + -- Same data as Vals in list form + + Rep_Count : Nat; + -- Used to validate Max_Others_Replicate limit + + Elmt : Node_Id; + Num : Int := UI_To_Int (Lov); + Choice : Node_Id; + Lo, Hi : Node_Id; + + begin + if Present (Expressions (N)) then + Elmt := First (Expressions (N)); + while Present (Elmt) loop + Vals (Num) := Relocate_Node (Elmt); + Num := Num + 1; + Next (Elmt); + end loop; + end if; + + Elmt := First (Component_Associations (N)); + Component_Loop : while Present (Elmt) loop + + Choice := First (Choices (Elmt)); + Choice_Loop : while Present (Choice) loop + + -- If we have an others choice, fill in the missing elements + -- subject to the limit established by Max_Others_Replicate. + + if Nkind (Choice) = N_Others_Choice then + Rep_Count := 0; + + for J in Vals'Range loop + if No (Vals (J)) then + Vals (J) := New_Copy_Tree (Expression (Elmt)); + Rep_Count := Rep_Count + 1; + + -- Check for maximum others replication. Note that + -- we skip this test if either of the restrictions + -- No_Elaboration_Code or No_Implicit_Loops is + -- active, or if this is a preelaborable unit. + + if Rep_Count > Max_Others_Replicate + and then not Restrictions (No_Elaboration_Code) + and then not Restrictions (No_Implicit_Loops) + and then not + Is_Preelaborated (Cunit_Entity (Current_Sem_Unit)) + then + return; + end if; + end if; + end loop; + + exit Component_Loop; + + -- Case of a subtype mark + + elsif (Nkind (Choice) = N_Identifier + and then Is_Type (Entity (Choice))) + then + Lo := Type_Low_Bound (Etype (Choice)); + Hi := Type_High_Bound (Etype (Choice)); + + -- Case of subtype indication + + elsif Nkind (Choice) = N_Subtype_Indication then + Lo := Low_Bound (Range_Expression (Constraint (Choice))); + Hi := High_Bound (Range_Expression (Constraint (Choice))); + + -- Case of a range + + elsif Nkind (Choice) = N_Range then + Lo := Low_Bound (Choice); + Hi := High_Bound (Choice); + + -- Normal subexpression case + + else pragma Assert (Nkind (Choice) in N_Subexpr); + if not Compile_Time_Known_Value (Choice) then + return; + + else + Vals (UI_To_Int (Expr_Value (Choice))) := + New_Copy_Tree (Expression (Elmt)); + goto Continue; + end if; + end if; + + -- Range cases merge with Lo,Hi said + + if not Compile_Time_Known_Value (Lo) + or else + not Compile_Time_Known_Value (Hi) + then + return; + else + for J in UI_To_Int (Expr_Value (Lo)) .. + UI_To_Int (Expr_Value (Hi)) + loop + Vals (J) := New_Copy_Tree (Expression (Elmt)); + end loop; + end if; + + <> + Next (Choice); + end loop Choice_Loop; + + Next (Elmt); + end loop Component_Loop; + + -- If we get here the conversion is possible + + Vlist := New_List; + for J in Vals'Range loop + Append (Vals (J), Vlist); + end loop; + + Rewrite (N, Make_Aggregate (Loc, Expressions => Vlist)); + Analyze_And_Resolve (N, Typ); + end; + end Convert_To_Positional; + ---------------------------- -- Expand_Array_Aggregate -- ---------------------------- *************** package body Exp_Aggr is *** 2190,2196 **** Typ : constant Entity_Id := Etype (N); Ctyp : constant Entity_Id := Component_Type (Typ); ! -- Typ is the correct constrained array subtype of the aggregate and -- Ctyp is the corresponding component type. Aggr_Dimension : constant Pos := Number_Dimensions (Typ); --- 2469,2475 ---- Typ : constant Entity_Id := Etype (N); Ctyp : constant Entity_Id := Component_Type (Typ); ! -- Typ is the correct constrained array subtype of the aggregate -- Ctyp is the corresponding component type. Aggr_Dimension : constant Pos := Number_Dimensions (Typ); *************** package body Exp_Aggr is *** 2208,2217 **** -- is the expression in an assignment, assignment in place may be -- possible, provided other conditions are met on the LHS. ! Others_Present : array (1 .. Aggr_Dimension) of Boolean ! := (others => False); ! -- If Others_Present (I) is True, then there is an others choice ! -- in one of the sub-aggregates of N at dimension I. procedure Build_Constrained_Type (Positional : Boolean); -- If the subtype is not static or unconstrained, build a constrained --- 2487,2496 ---- -- is the expression in an assignment, assignment in place may be -- possible, provided other conditions are met on the LHS. ! Others_Present : array (1 .. Aggr_Dimension) of Boolean := ! (others => False); ! -- If Others_Present (J) is True, then there is an others choice ! -- in one of the sub-aggregates of N at dimension J. procedure Build_Constrained_Type (Positional : Boolean); -- If the subtype is not static or unconstrained, build a constrained *************** package body Exp_Aggr is *** 2233,2244 **** -- array sub-aggregate we start the computation from. Dim is the -- dimension corresponding to the sub-aggregate. - procedure Convert_To_Positional (N : Node_Id); - -- If possible, convert named notation to positional notation. This - -- conversion is possible only in some static cases. If the conversion - -- is possible, then N is rewritten with the analyzed converted - -- aggregate. - function Has_Address_Clause (D : Node_Id) return Boolean; -- If the aggregate is the expression in an object declaration, it -- cannot be expanded in place. This function does a lookahead in the --- 2512,2517 ---- *************** package body Exp_Aggr is *** 2401,2407 **** Set_Analyzed (Left_Opnd (Left_Opnd (Cond)), False); Set_Analyzed (Right_Opnd (Left_Opnd (Cond)), False); Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, Condition => Cond)); end if; end Check_Bounds; --- 2674,2682 ---- Set_Analyzed (Left_Opnd (Left_Opnd (Cond)), False); Set_Analyzed (Right_Opnd (Left_Opnd (Cond)), False); Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Length_Check_Failed)); end if; end Check_Bounds; *************** package body Exp_Aggr is *** 2473,2479 **** if Present (Cond) then Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, Condition => Cond)); end if; -- Now look inside the sub-aggregate to see if there is more work --- 2748,2756 ---- if Present (Cond) then Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Length_Check_Failed)); end if; -- Now look inside the sub-aggregate to see if there is more work *************** package body Exp_Aggr is *** 2514,2519 **** --- 2791,2797 ---- begin if Present (Component_Associations (Sub_Aggr)) then Assoc := Last (Component_Associations (Sub_Aggr)); + if Nkind (First (Choices (Assoc))) = N_Others_Choice then Others_Present (Dim) := True; end if; *************** package body Exp_Aggr is *** 2546,2769 **** end if; end Compute_Others_Present; - --------------------------- - -- Convert_To_Positional -- - --------------------------- - - procedure Convert_To_Positional (N : Node_Id) is - Typ : constant Entity_Id := Etype (N); - Ndim : constant Pos := Number_Dimensions (Typ); - Xtyp : constant Entity_Id := Etype (First_Index (Typ)); - Blo : constant Node_Id := - Type_Low_Bound (Etype (First_Index (Base_Type (Typ)))); - Lo : constant Node_Id := Type_Low_Bound (Xtyp); - Hi : constant Node_Id := Type_High_Bound (Xtyp); - Lov : Uint; - Hiv : Uint; - - Max_Aggr_Size : constant := 500; - -- Maximum size of aggregate produced by converting positional to - -- named notation. This avoids running away with attempts to - -- convert huge aggregates. - - Max_Others_Replicate : constant := 5; - -- This constant defines the maximum expansion of an others clause - -- into a list of values. This applies when converting a named - -- aggregate to positional form for processing by the back end. - -- If a given others clause generates more than five values, the - -- aggregate is retained as named, since the loop is more compact. - -- However, this constant is completely overridden if restriction - -- No_Elaboration_Code is active, since in this case, the loop - -- would not be allowed anyway. Similarly No_Implicit_Loops causes - -- this parameter to be ignored. - - begin - -- For now, we only handle the one dimensional case and aggregates - -- that are not part of a component_association - - if Ndim > 1 or else Nkind (Parent (N)) = N_Aggregate - or else Nkind (Parent (N)) = N_Component_Association - then - return; - end if; - - -- If already positional, nothing to do! - - if No (Component_Associations (N)) then - return; - end if; - - -- Bounds need to be known at compile time - - if not Compile_Time_Known_Value (Lo) - or else not Compile_Time_Known_Value (Hi) - then - return; - end if; - - -- Do not attempt to convert bit packed arrays, since they cannot - -- be handled by the backend in any case. - - if Is_Bit_Packed_Array (Typ) then - return; - end if; - - -- Do not convert to positional if controlled components are - -- involved since these require special processing - - if Has_Controlled_Component (Typ) then - return; - end if; - - -- Get bounds and check reasonable size (positive, not too large) - -- Also only handle bounds starting at the base type low bound for - -- now since the compiler isn't able to handle different low bounds - -- yet - - Lov := Expr_Value (Lo); - Hiv := Expr_Value (Hi); - - if Hiv < Lov - or else (Hiv - Lov > Max_Aggr_Size) - or else not Compile_Time_Known_Value (Blo) - or else (Lov /= Expr_Value (Blo)) - then - return; - end if; - - -- Bounds must be in integer range (for array Vals below) - - if not UI_Is_In_Int_Range (Lov) - or else - not UI_Is_In_Int_Range (Hiv) - then - return; - end if; - - -- Determine if set of alternatives is suitable for conversion - -- and build an array containing the values in sequence. - - declare - Vals : array (UI_To_Int (Lov) .. UI_To_Int (Hiv)) - of Node_Id := (others => Empty); - -- The values in the aggregate sorted appropriately - - Vlist : List_Id; - -- Same data as Vals in list form - - Rep_Count : Nat; - -- Used to validate Max_Others_Replicate limit - - Elmt : Node_Id; - Num : Int := UI_To_Int (Lov); - Choice : Node_Id; - Lo, Hi : Node_Id; - - begin - if Present (Expressions (N)) then - Elmt := First (Expressions (N)); - while Present (Elmt) loop - Vals (Num) := Relocate_Node (Elmt); - Num := Num + 1; - Next (Elmt); - end loop; - end if; - - Elmt := First (Component_Associations (N)); - Component_Loop : while Present (Elmt) loop - - Choice := First (Choices (Elmt)); - Choice_Loop : while Present (Choice) loop - - -- If we have an others choice, fill in the missing elements - -- subject to the limit established by Max_Others_Replicate. - - if Nkind (Choice) = N_Others_Choice then - Rep_Count := 0; - - for J in Vals'Range loop - if No (Vals (J)) then - Vals (J) := New_Copy_Tree (Expression (Elmt)); - Rep_Count := Rep_Count + 1; - - if Rep_Count > Max_Others_Replicate - and then not Restrictions (No_Elaboration_Code) - and then not Restrictions (No_Implicit_Loops) - then - return; - end if; - end if; - end loop; - - exit Component_Loop; - - -- Case of a subtype mark - - elsif (Nkind (Choice) = N_Identifier - and then Is_Type (Entity (Choice))) - then - Lo := Type_Low_Bound (Etype (Choice)); - Hi := Type_High_Bound (Etype (Choice)); - - -- Case of subtype indication - - elsif Nkind (Choice) = N_Subtype_Indication then - Lo := Low_Bound (Range_Expression (Constraint (Choice))); - Hi := High_Bound (Range_Expression (Constraint (Choice))); - - -- Case of a range - - elsif Nkind (Choice) = N_Range then - Lo := Low_Bound (Choice); - Hi := High_Bound (Choice); - - -- Normal subexpression case - - else pragma Assert (Nkind (Choice) in N_Subexpr); - if not Compile_Time_Known_Value (Choice) then - return; - - else - Vals (UI_To_Int (Expr_Value (Choice))) := - New_Copy_Tree (Expression (Elmt)); - goto Continue; - end if; - end if; - - -- Range cases merge with Lo,Hi said - - if not Compile_Time_Known_Value (Lo) - or else - not Compile_Time_Known_Value (Hi) - then - return; - else - for J in UI_To_Int (Expr_Value (Lo)) .. - UI_To_Int (Expr_Value (Hi)) - loop - Vals (J) := New_Copy_Tree (Expression (Elmt)); - end loop; - end if; - - <> - Next (Choice); - end loop Choice_Loop; - - Next (Elmt); - end loop Component_Loop; - - -- If we get here the conversion is possible - - Vlist := New_List; - for J in Vals'Range loop - Append (Vals (J), Vlist); - end loop; - - Rewrite (N, Make_Aggregate (Loc, Expressions => Vlist)); - Analyze_And_Resolve (N, Typ); - end; - end Convert_To_Positional; - ------------------------- -- Has_Address_Clause -- ------------------------- --- 2824,2829 ---- *************** package body Exp_Aggr is *** 2805,2810 **** --- 2865,2874 ---- Obj_Lo : Node_Id; Obj_Hi : Node_Id; + function Is_Others_Aggregate (Aggr : Node_Id) return Boolean; + -- Aggregates that consist of a single Others choice are safe + -- if the single expression is. + function Safe_Aggregate (Aggr : Node_Id) return Boolean; -- Check recursively that each component of a (sub)aggregate does -- not depend on the variable being assigned to. *************** package body Exp_Aggr is *** 2813,2818 **** --- 2877,2894 ---- -- Verify that an expression cannot depend on the variable being -- assigned to. Room for improvement here (but less than before). + ------------------------- + -- Is_Others_Aggregate -- + ------------------------- + + function Is_Others_Aggregate (Aggr : Node_Id) return Boolean is + begin + return No (Expressions (Aggr)) + and then Nkind + (First (Choices (First (Component_Associations (Aggr))))) + = N_Others_Choice; + end Is_Others_Aggregate; + -------------------- -- Safe_Aggregate -- -------------------- *************** package body Exp_Aggr is *** 2907,2919 **** if not Analyzed (Comp) then if Is_Overloaded (Expr) then return False; end if; Comp := New_Copy_Tree (Expr); Analyze (Comp); end if; ! return Check_Component (Comp); end Safe_Component; -- Start of processing for In_Place_Assign_OK --- 2983,3010 ---- if not Analyzed (Comp) then if Is_Overloaded (Expr) then return False; + + elsif Nkind (Expr) = N_Aggregate + and then not Is_Others_Aggregate (Expr) + then + return False; + + elsif Nkind (Expr) = N_Allocator then + -- For now, too complex to analyze. + + return False; end if; Comp := New_Copy_Tree (Expr); + Set_Parent (Comp, Parent (Expr)); Analyze (Comp); end if; ! if Nkind (Comp) = N_Aggregate then ! return Safe_Aggregate (Comp); ! else ! return Check_Component (Comp); ! end if; end Safe_Component; -- Start of processing for In_Place_Assign_OK *************** package body Exp_Aggr is *** 2929,2939 **** -- are derived from the left-hand side, and the assignment is -- safe if the expression is. ! if No (Expressions (N)) ! and then Nkind ! (First (Choices (First (Component_Associations (N))))) ! = N_Others_Choice ! then return Safe_Component (Expression (First (Component_Associations (N)))); --- 3020,3026 ---- -- are derived from the left-hand side, and the assignment is -- safe if the expression is. ! if Is_Others_Aggregate (N) then return Safe_Component (Expression (First (Component_Associations (N)))); *************** package body Exp_Aggr is *** 3041,3047 **** end if; -- If we are dealing with a positional sub-aggregate with an ! -- others choice, compute the number or positional elements. if Need_To_Check and then Present (Expressions (Sub_Aggr)) then Expr := First (Expressions (Sub_Aggr)); --- 3128,3134 ---- end if; -- If we are dealing with a positional sub-aggregate with an ! -- others choice then compute the number or positional elements. if Need_To_Check and then Present (Expressions (Sub_Aggr)) then Expr := First (Expressions (Sub_Aggr)); *************** package body Exp_Aggr is *** 3056,3065 **** elsif Need_To_Check then Compute_Choices_Lo_And_Choices_Hi : declare Table : Case_Table_Type (1 .. Nb_Choices); -- Used to sort all the different choice values ! I : Pos := 1; Low : Node_Id; High : Node_Id; --- 3143,3153 ---- elsif Need_To_Check then Compute_Choices_Lo_And_Choices_Hi : declare + Table : Case_Table_Type (1 .. Nb_Choices); -- Used to sort all the different choice values ! J : Pos := 1; Low : Node_Id; High : Node_Id; *************** package body Exp_Aggr is *** 3073,3082 **** end if; Get_Index_Bounds (Choice, Low, High); ! Table (I).Choice_Lo := Low; ! Table (I).Choice_Hi := High; ! I := I + 1; Next (Choice); end loop; --- 3161,3170 ---- end if; Get_Index_Bounds (Choice, Low, High); ! Table (J).Choice_Lo := Low; ! Table (J).Choice_Hi := High; ! J := J + 1; Next (Choice); end loop; *************** package body Exp_Aggr is *** 3148,3154 **** if Present (Cond) then Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, Condition => Cond)); end if; -- Now look inside the sub-aggregate to see if there is more work --- 3236,3244 ---- if Present (Cond) then Insert_Action (N, ! Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Length_Check_Failed)); end if; -- Now look inside the sub-aggregate to see if there is more work *************** package body Exp_Aggr is *** 3201,3210 **** return; end if; ! -- If during semantic analysis it has been determined that aggregate N ! -- will raise Constraint_Error at run-time, then the aggregate node ! -- has been replaced with an N_Raise_Constraint_Error node and we ! -- should never get here. pragma Assert (not Raises_Constraint_Error (N)); --- 3291,3300 ---- return; end if; ! -- If the semantic analyzer has determined that aggregate N will raise ! -- Constraint_Error at run-time, then the aggregate node has been ! -- replaced with an N_Raise_Constraint_Error node and we should ! -- never get here. pragma Assert (not Raises_Constraint_Error (N)); *************** package body Exp_Aggr is *** 3343,3348 **** --- 3433,3445 ---- -- Look if in place aggregate expansion is possible + -- First case to test for is packed array aggregate that we can + -- handle at compile time. If so, return with transformation done. + + if Packed_Array_Aggregate_Handled (N) then + return; + end if; + -- For object declarations we build the aggregate in place, unless -- the array is bit-packed or the component is controlled. *************** package body Exp_Aggr is *** 3370,3376 **** and then not Has_Controlled_Component (Typ) and then not Has_Address_Clause (Parent (N)) then - Tmp := Defining_Identifier (Parent (N)); Set_No_Initialization (Parent (N)); Set_Expression (Parent (N), Empty); --- 3467,3472 ---- *************** package body Exp_Aggr is *** 3402,3415 **** end if; elsif Maybe_In_Place_OK and then Nkind (Name (Parent (N))) = N_Slice ! and then Safe_Slice_Assignment (N, Typ) then ! -- Safe_Slice_Assignment rewrites assignment as a loop. return; else Tmp := Make_Defining_Identifier (Loc, New_Internal_Name ('A')); Tmp_Decl := Make_Object_Declaration --- 3498,3522 ---- end if; elsif Maybe_In_Place_OK + and then Nkind (Name (Parent (N))) = N_Explicit_Dereference + and then Is_Entity_Name (Prefix (Name (Parent (N)))) + then + Tmp := Name (Parent (N)); + + if Etype (Tmp) /= Etype (N) then + Apply_Length_Check (N, Etype (Tmp)); + end if; + + elsif Maybe_In_Place_OK and then Nkind (Name (Parent (N))) = N_Slice ! and then Safe_Slice_Assignment (N) then ! -- Safe_Slice_Assignment rewrites assignment as a loop return; else + Maybe_In_Place_OK := False; Tmp := Make_Defining_Identifier (Loc, New_Internal_Name ('A')); Tmp_Decl := Make_Object_Declaration *************** package body Exp_Aggr is *** 3437,3447 **** -- index checks because this code is guaranteed not to raise CE -- on index checks. However we should *not* suppress all checks. ! Aggr_Code := ! Build_Array_Aggr_Code (N, ! Index => First_Index (Typ), ! Into => New_Reference_To (Tmp, Loc), ! Scalar_Comp => Is_Scalar_Type (Ctyp)); if Comes_From_Source (Tmp) then Insert_Actions_After (Parent (N), Aggr_Code); --- 3544,3568 ---- -- index checks because this code is guaranteed not to raise CE -- on index checks. However we should *not* suppress all checks. ! declare ! Target : Node_Id; ! ! begin ! if Nkind (Tmp) = N_Defining_Identifier then ! Target := New_Reference_To (Tmp, Loc); ! ! else ! -- Name in assignment is explicit dereference. ! ! Target := New_Copy (Tmp); ! end if; ! ! Aggr_Code := ! Build_Array_Aggr_Code (N, ! Index => First_Index (Typ), ! Into => Target, ! Scalar_Comp => Is_Scalar_Type (Ctyp)); ! end; if Comes_From_Source (Tmp) then Insert_Actions_After (Parent (N), Aggr_Code); *************** package body Exp_Aggr is *** 3450,3461 **** Insert_Actions (N, Aggr_Code); end if; if Nkind (Parent (N)) = N_Assignment_Statement ! and then Is_Entity_Name (Name (Parent (N))) ! and then Tmp = Entity (Name (Parent (N))) then Rewrite (Parent (N), Make_Null_Statement (Loc)); - Analyze (N); elsif Nkind (Parent (N)) /= N_Object_Declaration or else Tmp /= Defining_Identifier (Parent (N)) --- 3571,3583 ---- Insert_Actions (N, Aggr_Code); end if; + -- If the aggregate has been assigned in place, remove the original + -- assignment. + if Nkind (Parent (N)) = N_Assignment_Statement ! and then Maybe_In_Place_OK then Rewrite (Parent (N), Make_Null_Statement (Loc)); elsif Nkind (Parent (N)) /= N_Object_Declaration or else Tmp /= Defining_Identifier (Parent (N)) *************** package body Exp_Aggr is *** 3634,3655 **** -- can be handled by gigi. else ! if not Has_Discriminants (Typ) then ! ! -- This bizarre if/elsif is to avoid a compiler crash ??? null; elsif Is_Derived_Type (Typ) then ! -- Non-girder discriminants are replaced with girder discriminants ! declare First_Comp : Node_Id; Discriminant : Entity_Id; begin ! -- Remove all the discriminants First_Comp := First (Component_Associations (N)); --- 3756,3823 ---- -- can be handled by gigi. else ! -- If no discriminants, nothing special to do + if not Has_Discriminants (Typ) then null; + -- Case of discriminants present + elsif Is_Derived_Type (Typ) then ! -- For untagged types, non-girder discriminants are replaced ! -- with girder discriminants, which are the ones that gigi uses ! -- to describe the type and its components. ! Generate_Aggregate_For_Derived_Type : declare First_Comp : Node_Id; Discriminant : Entity_Id; + Constraints : List_Id := New_List; + Decl : Node_Id; + Num_Disc : Int := 0; + Num_Gird : Int := 0; + + procedure Prepend_Girder_Values (T : Entity_Id); + -- Scan the list of girder discriminants of the type, and + -- add their values to the aggregate being built. + + --------------------------- + -- Prepend_Girder_Values -- + --------------------------- + + procedure Prepend_Girder_Values (T : Entity_Id) is + begin + Discriminant := First_Girder_Discriminant (T); + + while Present (Discriminant) loop + New_Comp := + Make_Component_Association (Loc, + Choices => + New_List (New_Occurrence_Of (Discriminant, Loc)), + + Expression => + New_Copy_Tree ( + Get_Discriminant_Value ( + Discriminant, + Typ, + Discriminant_Constraint (Typ)))); + + if No (First_Comp) then + Prepend_To (Component_Associations (N), New_Comp); + else + Insert_After (First_Comp, New_Comp); + end if; + + First_Comp := New_Comp; + Next_Girder_Discriminant (Discriminant); + end loop; + end Prepend_Girder_Values; + + -- Start of processing for Generate_Aggregate_For_Derived_Type begin ! -- Remove the associations for the discriminant of ! -- the derived type. First_Comp := First (Component_Associations (N)); *************** package body Exp_Aggr is *** 3661,3697 **** E_Discriminant then Remove (Comp); end if; end loop; ! -- Insert girder discriminant associations ! -- in the correct order First_Comp := Empty; - Discriminant := First_Girder_Discriminant (Typ); - while Present (Discriminant) loop - New_Comp := - Make_Component_Association (Loc, - Choices => - New_List (New_Occurrence_Of (Discriminant, Loc)), ! Expression => ! New_Copy_Tree ( ! Get_Discriminant_Value ( ! Discriminant, ! Typ, ! Discriminant_Constraint (Typ)))); ! ! if No (First_Comp) then ! Prepend_To (Component_Associations (N), New_Comp); ! else ! Insert_After (First_Comp, New_Comp); ! end if; ! First_Comp := New_Comp; Next_Girder_Discriminant (Discriminant); end loop; ! end; end if; if Is_Tagged_Type (Typ) then --- 3829,3907 ---- E_Discriminant then Remove (Comp); + Num_Disc := Num_Disc + 1; end if; end loop; ! -- Insert girder discriminant associations in the correct ! -- order. If there are more girder discriminants than new ! -- discriminants, there is at least one new discriminant ! -- that constrains more than one of the girders. In this ! -- case we need to construct a proper subtype of the parent ! -- type, in order to supply values to all the components. ! -- Otherwise there is one-one correspondence between the ! -- constraints and the girder discriminants. First_Comp := Empty; ! Discriminant := First_Girder_Discriminant (Base_Type (Typ)); ! while Present (Discriminant) loop ! Num_Gird := Num_Gird + 1; Next_Girder_Discriminant (Discriminant); end loop; ! ! -- Case of more girder discriminants than new discriminants ! ! if Num_Gird > Num_Disc then ! ! -- Create a proper subtype of the parent type, which is ! -- the proper implementation type for the aggregate, and ! -- convert it to the intended target type. ! ! Discriminant := First_Girder_Discriminant (Base_Type (Typ)); ! ! while Present (Discriminant) loop ! New_Comp := ! New_Copy_Tree ( ! Get_Discriminant_Value ( ! Discriminant, ! Typ, ! Discriminant_Constraint (Typ))); ! Append (New_Comp, Constraints); ! Next_Girder_Discriminant (Discriminant); ! end loop; ! ! Decl := ! Make_Subtype_Declaration (Loc, ! Defining_Identifier => ! Make_Defining_Identifier (Loc, ! New_Internal_Name ('T')), ! Subtype_Indication => ! Make_Subtype_Indication (Loc, ! Subtype_Mark => ! New_Occurrence_Of (Etype (Base_Type (Typ)), Loc), ! Constraint => ! Make_Index_Or_Discriminant_Constraint ! (Loc, Constraints))); ! ! Insert_Action (N, Decl); ! Prepend_Girder_Values (Base_Type (Typ)); ! ! Set_Etype (N, Defining_Identifier (Decl)); ! Set_Analyzed (N); ! ! Rewrite (N, Unchecked_Convert_To (Typ, N)); ! Analyze (N); ! ! -- Case where we do not have fewer new discriminants than ! -- girder discriminants, so in this case we can simply ! -- use the girder discriminants of the subtype. ! ! else ! Prepend_Girder_Values (Typ); ! end if; ! end Generate_Aggregate_For_Derived_Type; end if; if Is_Tagged_Type (Typ) then *************** package body Exp_Aggr is *** 3936,3961 **** return Nb_Choices; end Number_Of_Choices; --------------------------- -- Safe_Slice_Assignment -- --------------------------- ! function Safe_Slice_Assignment ! (N : Node_Id; ! Typ : Entity_Id) ! return Boolean ! is Loc : constant Source_Ptr := Sloc (Parent (N)); Pref : constant Node_Id := Prefix (Name (Parent (N))); Range_Node : constant Node_Id := Discrete_Range (Name (Parent (N))); Expr : Node_Id; ! L_I : Entity_Id; L_Iter : Node_Id; L_Body : Node_Id; Stat : Node_Id; begin ! -- Generate: For J in Range loop Pref (I) := Expr; end loop; if Comes_From_Source (N) and then No (Expressions (N)) --- 4146,4409 ---- return Nb_Choices; end Number_Of_Choices; + ------------------------------------ + -- Packed_Array_Aggregate_Handled -- + ------------------------------------ + + -- The current version of this procedure will handle at compile time + -- any array aggregate that meets these conditions: + + -- One dimensional, bit packed + -- Underlying packed type is modular type + -- Bounds are within 32-bit Int range + -- All bounds and values are static + + function Packed_Array_Aggregate_Handled (N : Node_Id) return Boolean is + Loc : constant Source_Ptr := Sloc (N); + Typ : constant Entity_Id := Etype (N); + Ctyp : constant Entity_Id := Component_Type (Typ); + + Not_Handled : exception; + -- Exception raised if this aggregate cannot be handled + + begin + -- For now, handle only one dimensional bit packed arrays + + if not Is_Bit_Packed_Array (Typ) + or else Number_Dimensions (Typ) > 1 + or else not Is_Modular_Integer_Type (Packed_Array_Type (Typ)) + then + return False; + end if; + + declare + Csiz : constant Nat := UI_To_Int (Component_Size (Typ)); + + Lo : Node_Id; + Hi : Node_Id; + -- Bounds of index type + + Lob : Uint; + Hib : Uint; + -- Values of bounds if compile time known + + function Get_Component_Val (N : Node_Id) return Uint; + -- Given a expression value N of the component type Ctyp, returns + -- A value of Csiz (component size) bits representing this value. + -- If the value is non-static or any other reason exists why the + -- value cannot be returned, then Not_Handled is raised. + + ----------------------- + -- Get_Component_Val -- + ----------------------- + + function Get_Component_Val (N : Node_Id) return Uint is + Val : Uint; + + begin + -- We have to analyze the expression here before doing any further + -- processing here. The analysis of such expressions is deferred + -- till expansion to prevent some problems of premature analysis. + + Analyze_And_Resolve (N, Ctyp); + + -- Must have a compile time value + + if not Compile_Time_Known_Value (N) then + raise Not_Handled; + end if; + + Val := Expr_Rep_Value (N); + + -- Adjust for bias, and strip proper number of bits + + if Has_Biased_Representation (Ctyp) then + Val := Val - Expr_Value (Type_Low_Bound (Ctyp)); + end if; + + return Val mod Uint_2 ** Csiz; + end Get_Component_Val; + + -- Here we know we have a one dimensional bit packed array + + begin + Get_Index_Bounds (First_Index (Typ), Lo, Hi); + + -- Cannot do anything if bounds are dynamic + + if not Compile_Time_Known_Value (Lo) + or else + not Compile_Time_Known_Value (Hi) + then + return False; + end if; + + -- Or are silly out of range of int bounds + + Lob := Expr_Value (Lo); + Hib := Expr_Value (Hi); + + if not UI_Is_In_Int_Range (Lob) + or else + not UI_Is_In_Int_Range (Hib) + then + return False; + end if; + + -- At this stage we have a suitable aggregate for handling + -- at compile time (the only remaining checks, are that the + -- values of expressions in the aggregate are compile time + -- known (check performed by Get_Component_Val), and that + -- any subtypes or ranges are statically known. + + -- If the aggregate is not fully positional at this stage, + -- then convert it to positional form. Either this will fail, + -- in which case we can do nothing, or it will succeed, in + -- which case we have succeeded in handling the aggregate, + -- or it will stay an aggregate, in which case we have failed + -- to handle this case. + + if Present (Component_Associations (N)) then + Convert_To_Positional + (N, Max_Others_Replicate => 64, Handle_Bit_Packed => True); + return Nkind (N) /= N_Aggregate; + end if; + + -- Otherwise we are all positional, so convert to proper value + + declare + Lov : constant Nat := UI_To_Int (Lob); + Hiv : constant Nat := UI_To_Int (Hib); + + Len : constant Nat := Int'Max (0, Hiv - Lov + 1); + -- The length of the array (number of elements) + + Aggregate_Val : Uint; + -- Value of aggregate. The value is set in the low order + -- bits of this value. For the little-endian case, the + -- values are stored from low-order to high-order and + -- for the big-endian case the values are stored from + -- high-order to low-order. Note that gigi will take care + -- of the conversions to left justify the value in the big + -- endian case (because of left justified modular type + -- processing), so we do not have to worry about that here. + + Lit : Node_Id; + -- Integer literal for resulting constructed value + + Shift : Nat; + -- Shift count from low order for next value + + Incr : Int; + -- Shift increment for loop + + Expr : Node_Id; + -- Next expression from positional parameters of aggregate + + begin + -- For little endian, we fill up the low order bits of the + -- target value. For big endian we fill up the high order + -- bits of the target value (which is a left justified + -- modular value). + + if Bytes_Big_Endian xor Debug_Flag_8 then + Shift := Csiz * (Len - 1); + Incr := -Csiz; + else + Shift := 0; + Incr := +Csiz; + end if; + + -- Loop to set the values + + Aggregate_Val := Uint_0; + Expr := First (Expressions (N)); + for J in 1 .. Len loop + Aggregate_Val := + Aggregate_Val + Get_Component_Val (Expr) * Uint_2 ** Shift; + Shift := Shift + Incr; + Next (Expr); + end loop; + + -- Now we can rewrite with the proper value + + Lit := + Make_Integer_Literal (Loc, + Intval => Aggregate_Val); + Set_Print_In_Hex (Lit); + + -- Construct the expression using this literal. Note that it is + -- important to qualify the literal with its proper modular type + -- since universal integer does not have the required range and + -- also this is a left justified modular type, which is important + -- in the big-endian case. + + Rewrite (N, + Unchecked_Convert_To (Typ, + Make_Qualified_Expression (Loc, + Subtype_Mark => + New_Occurrence_Of (Packed_Array_Type (Typ), Loc), + Expression => Lit))); + + Analyze_And_Resolve (N, Typ); + return True; + end; + end; + + exception + when Not_Handled => + return False; + end Packed_Array_Aggregate_Handled; + + ------------------------------ + -- Initialize_Discriminants -- + ------------------------------ + + procedure Initialize_Discriminants (N : Node_Id; Typ : Entity_Id) is + Loc : constant Source_Ptr := Sloc (N); + Bas : constant Entity_Id := Base_Type (Typ); + Par : constant Entity_Id := Etype (Bas); + Decl : constant Node_Id := Parent (Par); + Ref : Node_Id; + + begin + if Is_Tagged_Type (Bas) + and then Is_Derived_Type (Bas) + and then Has_Discriminants (Par) + and then Has_Discriminants (Bas) + and then Number_Discriminants (Bas) /= Number_Discriminants (Par) + and then Nkind (Decl) = N_Full_Type_Declaration + and then Nkind (Type_Definition (Decl)) = N_Record_Definition + and then Present + (Variant_Part (Component_List (Type_Definition (Decl)))) + and then Nkind (N) /= N_Extension_Aggregate + then + + -- Call init_proc to set discriminants. + -- There should eventually be a special procedure for this ??? + + Ref := New_Reference_To (Defining_Identifier (N), Loc); + Insert_Actions_After (N, + Build_Initialization_Call (Sloc (N), Ref, Typ)); + end if; + end Initialize_Discriminants; + --------------------------- -- Safe_Slice_Assignment -- --------------------------- ! function Safe_Slice_Assignment (N : Node_Id) return Boolean is Loc : constant Source_Ptr := Sloc (Parent (N)); Pref : constant Node_Id := Prefix (Name (Parent (N))); Range_Node : constant Node_Id := Discrete_Range (Name (Parent (N))); Expr : Node_Id; ! L_J : Entity_Id; L_Iter : Node_Id; L_Body : Node_Id; Stat : Node_Id; begin ! -- Generate: for J in Range loop Pref (J) := Expr; end loop; if Comes_From_Source (N) and then No (Expressions (N)) *************** package body Exp_Aggr is *** 3964,3977 **** then Expr := Expression (First (Component_Associations (N))); ! L_I := Make_Defining_Identifier (Loc, New_Internal_Name ('I')); L_Iter := Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, ! Defining_Identifier => L_I, Discrete_Subtype_Definition => Relocate_Node (Range_Node))); L_Body := --- 4412,4425 ---- then Expr := Expression (First (Component_Associations (N))); ! L_J := Make_Defining_Identifier (Loc, New_Internal_Name ('J')); L_Iter := Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, ! Defining_Identifier => L_J, Discrete_Subtype_Definition => Relocate_Node (Range_Node))); L_Body := *************** package body Exp_Aggr is *** 3979,3985 **** Name => Make_Indexed_Component (Loc, Prefix => Relocate_Node (Pref), ! Expressions => New_List (New_Occurrence_Of (L_I, Loc))), Expression => Relocate_Node (Expr)); -- Construct the final loop --- 4427,4433 ---- Name => Make_Indexed_Component (Loc, Prefix => Relocate_Node (Pref), ! Expressions => New_List (New_Occurrence_Of (L_J, Loc))), Expression => Relocate_Node (Expr)); -- Construct the final loop diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_aggr.ads gcc-3.3/gcc/ada/exp_aggr.ads *** gcc-3.2.3/gcc/ada/exp_aggr.ads 2002-05-04 03:27:43.000000000 +0000 --- gcc-3.3/gcc/ada/exp_aggr.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/expander.adb gcc-3.3/gcc/ada/expander.adb *** gcc-3.2.3/gcc/ada/expander.adb 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/expander.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Expander is *** 103,109 **** -- expansion on (see the spec of sem). -- Finally, expansion is turned off in a regular compilation if there ! -- are semantic errors. In that case there will be no further expansion, -- but one cleanup action may be required: if a transient scope was -- created (e.g. for a function that returns an unconstrained type) -- the scope may still be on the stack, and must be removed explicitly, --- 102,108 ---- -- expansion on (see the spec of sem). -- Finally, expansion is turned off in a regular compilation if there ! -- are serious errors. In that case there will be no further expansion, -- but one cleanup action may be required: if a transient scope was -- created (e.g. for a function that returns an unconstrained type) -- the scope may still be on the stack, and must be removed explicitly, *************** package body Expander is *** 113,119 **** if not Expander_Active then Set_Analyzed (N, Full_Analysis); ! if Errors_Detected > 0 and then Scope_Is_Transient then Scope_Stack.Table --- 112,118 ---- if not Expander_Active then Set_Analyzed (N, Full_Analysis); ! if Serious_Errors_Detected > 0 and then Scope_Is_Transient then Scope_Stack.Table *************** package body Expander is *** 127,133 **** return; else - Debug_A_Entry ("expanding ", N); -- Processing depends on node kind. For full details on the expansion --- 126,131 ---- *************** package body Expander is *** 473,479 **** Expander_Active := Expander_Flags.Table (Expander_Flags.Last); Expander_Flags.Decrement_Last; ! if Errors_Detected /= 0 then Expander_Active := False; end if; end Expander_Mode_Restore; --- 471,477 ---- Expander_Active := Expander_Flags.Table (Expander_Flags.Last); Expander_Flags.Decrement_Last; ! if Serious_Errors_Detected /= 0 then Expander_Active := False; end if; end Expander_Mode_Restore; diff -Nrc3pad gcc-3.2.3/gcc/ada/expander.ads gcc-3.3/gcc/ada/expander.ads *** gcc-3.2.3/gcc/ada/expander.ads 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/expander.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_attr.adb gcc-3.3/gcc/ada/exp_attr.adb *** gcc-3.2.3/gcc/ada/exp_attr.adb 2002-05-04 03:27:43.000000000 +0000 --- gcc-3.3/gcc/ada/exp_attr.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Rtsfind; use Rtsfind; *** 48,54 **** with Sem; use Sem; with Sem_Ch7; use Sem_Ch7; with Sem_Ch8; use Sem_Ch8; - with Sem_Ch13; use Sem_Ch13; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; --- 47,52 ---- *************** package body Exp_Attr is *** 452,458 **** declare Agg : Node_Id; Sub : Entity_Id; ! E_T : constant Entity_Id := Equivalent_Type (Typ); Acc : constant Entity_Id := Etype (Next_Component (First_Component (E_T))); Obj_Ref : Node_Id; --- 450,456 ---- declare Agg : Node_Id; Sub : Entity_Id; ! E_T : constant Entity_Id := Equivalent_Type (Btyp); Acc : constant Entity_Id := Etype (Next_Component (First_Component (E_T))); Obj_Ref : Node_Id; *************** package body Exp_Attr is *** 511,517 **** Rewrite (N, Agg); ! Analyze_And_Resolve (N, Equivalent_Type (Typ)); -- For subsequent analysis, the node must retain its type. -- The backend will replace it with the equivalent type where --- 509,515 ---- Rewrite (N, Agg); ! Analyze_And_Resolve (N, E_T); -- For subsequent analysis, the node must retain its type. -- The backend will replace it with the equivalent type where *************** package body Exp_Attr is *** 3761,3768 **** Attribute_Machine_Overflows | Attribute_Machine_Radix | Attribute_Machine_Rounds | - Attribute_Max_Interrupt_Priority | - Attribute_Max_Priority | Attribute_Maximum_Alignment | Attribute_Model_Emin | Attribute_Model_Epsilon | --- 3759,3764 ---- *************** package body Exp_Attr is *** 3780,3786 **** Attribute_Signed_Zeros | Attribute_Small | Attribute_Storage_Unit | - Attribute_Tick | Attribute_Type_Class | Attribute_Universal_Literal_String | Attribute_Wchar_T_Size | --- 3776,3781 ---- *************** package body Exp_Attr is *** 3836,3842 **** Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Base_Type (Etype (Prefix (N))), Loc), ! Attribute_Name => Cnam)))); end Expand_Pred_Succ; --- 3831,3838 ---- Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Base_Type (Etype (Prefix (N))), Loc), ! Attribute_Name => Cnam)), ! Reason => CE_Overflow_Check_Failed)); end Expand_Pred_Succ; *************** package body Exp_Attr is *** 3862,3879 **** -- If Typ is a derived type, it may inherit attributes from some -- ancestor which is not the ultimate underlying one. if Is_Derived_Type (P_Type) then ! while Is_Derived_Type (P_Type) loop ! Proc := TSS (Base_Type (Etype (Typ)), Nam); ! ! if Present (Proc) then ! return Proc; ! else ! P_Type := Base_Type (Etype (P_Type)); ! end if; ! end loop; end if; -- If nothing else, use the TSS of the root type. --- 3858,3880 ---- -- If Typ is a derived type, it may inherit attributes from some -- ancestor which is not the ultimate underlying one. + -- If Typ is a derived tagged type, the corresponding primitive + -- operation has been created explicitly. if Is_Derived_Type (P_Type) then + if Is_Tagged_Type (P_Type) then + return Find_Prim_Op (P_Type, Nam); + else + while Is_Derived_Type (P_Type) loop + Proc := TSS (Base_Type (Etype (Typ)), Nam); ! if Present (Proc) then ! return Proc; ! else ! P_Type := Base_Type (Etype (P_Type)); ! end if; ! end loop; ! end if; end if; -- If nothing else, use the TSS of the root type. diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_attr.ads gcc-3.3/gcc/ada/exp_attr.ads *** gcc-3.2.3/gcc/ada/exp_attr.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/exp_attr.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch10.ads gcc-3.3/gcc/ada/exp_ch10.ads *** gcc-3.2.3/gcc/ada/exp_ch10.ads 2002-05-07 08:22:11.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch10.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch11.adb gcc-3.3/gcc/ada/exp_ch11.adb *** gcc-3.2.3/gcc/ada/exp_ch11.adb 2002-05-04 03:27:45.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch11.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Atree; use Atree; *** 30,35 **** --- 29,35 ---- with Casing; use Casing; with Debug; use Debug; with Einfo; use Einfo; + with Errout; use Errout; with Exp_Ch7; use Exp_Ch7; with Exp_Util; use Exp_Util; with Hostparm; use Hostparm; *************** package body Exp_Ch11 is *** 657,674 **** -- Routine to prepend a call to the procedure referenced by Proc at -- the start of the handler code for the current Handler. procedure Prepend_Call_To_Handler (Proc : RE_Id; Args : List_Id := No_List) is ! Call : constant Node_Id := ! Make_Procedure_Call_Statement (Loc, ! Name => New_Occurrence_Of (RTE (Proc), Loc), ! Parameter_Associations => Args); begin ! Prepend_To (Statements (Handler), Call); ! Analyze (Call, Suppress => All_Checks); end Prepend_Call_To_Handler; -- Start of processing for Expand_Exception_Handlers --- 657,688 ---- -- Routine to prepend a call to the procedure referenced by Proc at -- the start of the handler code for the current Handler. + ----------------------------- + -- Prepend_Call_To_Handler -- + ----------------------------- + procedure Prepend_Call_To_Handler (Proc : RE_Id; Args : List_Id := No_List) is ! Ent : constant Entity_Id := RTE (Proc); begin ! -- If we have no Entity, then we are probably in no run time mode ! -- or some weird error has occured. In either case do do nothing! ! ! if Present (Ent) then ! declare ! Call : constant Node_Id := ! Make_Procedure_Call_Statement (Loc, ! Name => New_Occurrence_Of (RTE (Proc), Loc), ! Parameter_Associations => Args); ! ! begin ! Prepend_To (Statements (Handler), Call); ! Analyze (Call, Suppress => All_Checks); ! end; ! end if; end Prepend_Call_To_Handler; -- Start of processing for Expand_Exception_Handlers *************** package body Exp_Ch11 is *** 934,940 **** procedure Expand_N_Handled_Sequence_Of_Statements (N : Node_Id) is begin ! if Present (Exception_Handlers (N)) then Expand_Exception_Handlers (N); end if; --- 948,956 ---- procedure Expand_N_Handled_Sequence_Of_Statements (N : Node_Id) is begin ! if Present (Exception_Handlers (N)) ! and then not Restrictions (No_Exception_Handlers) ! then Expand_Exception_Handlers (N); end if; *************** package body Exp_Ch11 is *** 1007,1024 **** -- but this is also faster in all modes). if Present (Name (N)) and then Nkind (Name (N)) = N_Identifier then ! if Entity (Name (N)) = Standard_Program_Error then ! Rewrite (N, Make_Raise_Program_Error (Loc)); Analyze (N); return; ! elsif Entity (Name (N)) = Standard_Constraint_Error then ! Rewrite (N, Make_Raise_Constraint_Error (Loc)); Analyze (N); return; elsif Entity (Name (N)) = Standard_Storage_Error then ! Rewrite (N, Make_Raise_Storage_Error (Loc)); Analyze (N); return; end if; --- 1023,1046 ---- -- but this is also faster in all modes). if Present (Name (N)) and then Nkind (Name (N)) = N_Identifier then ! if Entity (Name (N)) = Standard_Constraint_Error then ! Rewrite (N, ! Make_Raise_Constraint_Error (Loc, ! Reason => CE_Explicit_Raise)); Analyze (N); return; ! elsif Entity (Name (N)) = Standard_Program_Error then ! Rewrite (N, ! Make_Raise_Program_Error (Loc, ! Reason => PE_Explicit_Raise)); Analyze (N); return; elsif Entity (Name (N)) = Standard_Storage_Error then ! Rewrite (N, ! Make_Raise_Storage_Error (Loc, ! Reason => SE_Explicit_Raise)); Analyze (N); return; end if; *************** package body Exp_Ch11 is *** 1037,1042 **** --- 1059,1071 ---- begin Build_Location_String (Loc); + -- If the exception is a renaming, use the exception that it + -- renames (which might be a predefined exception, e.g.). + + if Present (Renamed_Object (Id)) then + Id := Renamed_Object (Id); + end if; + -- Build a C compatible string in case of no exception handlers, -- since this is what the last chance handler is expecting. *************** package body Exp_Ch11 is *** 1234,1239 **** --- 1263,1272 ---- return; end if; + if Restrictions (No_Exception_Handlers) then + return; + end if; + -- Suppress descriptor if we are not generating code. This happens -- in the case of a -gnatc -gnatt compilation where we force generics -- to be generated, but we still don't want exception tables. *************** package body Exp_Ch11 is *** 1583,1588 **** --- 1616,1635 ---- Adecl : Node_Id; begin + -- If N is empty with prior errors, ignore + + if Total_Errors_Detected /= 0 and then No (N) then + return; + end if; + + -- Do not generate if no exceptions + + if Restrictions (No_Exception_Handlers) then + return; + end if; + + -- Otherwise generate descriptor + Adecl := Aux_Decls_Node (Parent (N)); if No (Actions (Adecl)) then *************** package body Exp_Ch11 is *** 1600,1615 **** (N : Node_Id; Spec : Entity_Id) is - HSS : constant Node_Id := Handled_Statement_Sequence (N); - begin ! if No (Exception_Handlers (HSS)) then ! Generate_Subprogram_Descriptor ! (N, Sloc (N), Spec, Statements (HSS)); ! else ! Generate_Subprogram_Descriptor ! (N, Sloc (N), Spec, Statements (Last (Exception_Handlers (HSS)))); end if; end Generate_Subprogram_Descriptor_For_Subprogram; ----------------------------------- --- 1647,1680 ---- (N : Node_Id; Spec : Entity_Id) is begin ! -- If we have no subprogram body and prior errors, ignore ! ! if Total_Errors_Detected /= 0 and then No (N) then ! return; end if; + + -- Do not generate if no exceptions + + if Restrictions (No_Exception_Handlers) then + return; + end if; + + -- Else generate descriptor + + declare + HSS : constant Node_Id := Handled_Statement_Sequence (N); + + begin + if No (Exception_Handlers (HSS)) then + Generate_Subprogram_Descriptor + (N, Sloc (N), Spec, Statements (HSS)); + else + Generate_Subprogram_Descriptor + (N, Sloc (N), + Spec, Statements (Last (Exception_Handlers (HSS)))); + end if; + end; end Generate_Subprogram_Descriptor_For_Subprogram; ----------------------------------- *************** package body Exp_Ch11 is *** 1635,1640 **** --- 1700,1711 ---- return; end if; + -- Nothing to do if no exceptions + + if Restrictions (No_Exception_Handlers) then + return; + end if; + -- Remove any entries from SD_List that correspond to eliminated -- subprograms. diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch11.ads gcc-3.3/gcc/ada/exp_ch11.ads *** gcc-3.2.3/gcc/ada/exp_ch11.ads 2002-05-04 03:27:45.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch11.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch12.adb gcc-3.3/gcc/ada/exp_ch12.adb *** gcc-3.2.3/gcc/ada/exp_ch12.adb 2002-05-04 03:27:46.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch12.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1997-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2002 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- -- *************** package body Exp_Ch12 is *** 62,68 **** Condition => Make_Op_Not (Loc, Right_Opnd => ! New_Occurrence_Of (Elaboration_Entity (Ent), Loc)))); end if; end Expand_N_Generic_Instantiation; --- 61,68 ---- Condition => Make_Op_Not (Loc, Right_Opnd => ! New_Occurrence_Of (Elaboration_Entity (Ent), Loc)), ! Reason => PE_Access_Before_Elaboration)); end if; end Expand_N_Generic_Instantiation; diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch12.ads gcc-3.3/gcc/ada/exp_ch12.ads *** gcc-3.2.3/gcc/ada/exp_ch12.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch12.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch13.adb gcc-3.3/gcc/ada/exp_ch13.adb *** gcc-3.2.3/gcc/ada/exp_ch13.adb 2002-05-04 03:27:46.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch13.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with Uintp; use Uintp; *** 50,55 **** --- 49,59 ---- package body Exp_Ch13 is + procedure Expand_External_Tag_Definition (N : Node_Id); + -- The code to assign and register an external tag must be elaborated + -- after the dispatch table has been created, so the expansion of the + -- attribute definition node is delayed until after the type is frozen. + ------------------------------------------ -- Expand_N_Attribute_Definition_Clause -- ------------------------------------------ *************** package body Exp_Ch13 is *** 115,184 **** end if; ------------------ - -- External_Tag -- - ------------------ - - -- For the rep clause "for x'external_tag use y" generate: - - -- xV : constant string := y; - -- Set_External_Tag (x'tag, xV'Address); - -- Register_Tag (x'tag); - - -- note that register_tag has been delayed up to now because - -- the external_tag must be set before resistering. - - when Attribute_External_Tag => External_Tag : declare - E : Entity_Id; - Old_Val : String_Id := Strval (Expr_Value_S (Exp)); - New_Val : String_Id; - - begin - -- Create a new nul terminated string if it is not already - - if String_Length (Old_Val) > 0 - and then Get_String_Char (Old_Val, String_Length (Old_Val)) = 0 - then - New_Val := Old_Val; - else - Start_String (Old_Val); - Store_String_Char (Get_Char_Code (ASCII.NUL)); - New_Val := End_String; - end if; - - E := - Make_Defining_Identifier (Loc, - New_External_Name (Chars (Ent), 'A')); - - Insert_Action (N, - Make_Object_Declaration (Loc, - Defining_Identifier => E, - Constant_Present => True, - Object_Definition => - New_Reference_To (Standard_String, Loc), - Expression => - Make_String_Literal (Loc, Strval => New_Val))); - - Insert_Actions (N, New_List ( - Make_Procedure_Call_Statement (Loc, - Name => New_Reference_To (RTE (RE_Set_External_Tag), Loc), - Parameter_Associations => New_List ( - Make_Attribute_Reference (Loc, - Attribute_Name => Name_Tag, - Prefix => New_Occurrence_Of (Ent, Loc)), - - Make_Attribute_Reference (Loc, - Attribute_Name => Name_Address, - Prefix => New_Occurrence_Of (E, Loc)))), - - Make_Procedure_Call_Statement (Loc, - Name => New_Reference_To (RTE (RE_Register_Tag), Loc), - Parameter_Associations => New_List ( - Make_Attribute_Reference (Loc, - Attribute_Name => Name_Tag, - Prefix => New_Occurrence_Of (Ent, Loc)))))); - end External_Tag; - - ------------------ -- Storage_Size -- ------------------ --- 119,124 ---- *************** package body Exp_Ch13 is *** 224,229 **** --- 164,239 ---- end Expand_N_Attribute_Definition_Clause; + ------------------------------------- + -- Expand_External_Tag_Definition -- + ------------------------------------- + + procedure Expand_External_Tag_Definition (N : Node_Id) is + Loc : constant Source_Ptr := Sloc (N); + Ent : constant Entity_Id := Entity (Name (N)); + E : Entity_Id; + Old_Val : String_Id := Strval (Expr_Value_S (Expression (N))); + New_Val : String_Id; + + begin + + -- For the rep clause "for x'external_tag use y" generate: + + -- xV : constant string := y; + -- Set_External_Tag (x'tag, xV'Address); + -- Register_Tag (x'tag); + + -- note that register_tag has been delayed up to now because + -- the external_tag must be set before registering. + + -- Create a new nul terminated string if it is not already + + if String_Length (Old_Val) > 0 + and then Get_String_Char (Old_Val, String_Length (Old_Val)) = 0 + then + New_Val := Old_Val; + else + Start_String (Old_Val); + Store_String_Char (Get_Char_Code (ASCII.NUL)); + New_Val := End_String; + end if; + + E := + Make_Defining_Identifier (Loc, + New_External_Name (Chars (Ent), 'A')); + + -- The generated actions must be elaborated at the subsequent + -- freeze point, not at the point of the attribute definition. + + Append_Freeze_Action (Ent, + Make_Object_Declaration (Loc, + Defining_Identifier => E, + Constant_Present => True, + Object_Definition => + New_Reference_To (Standard_String, Loc), + Expression => + Make_String_Literal (Loc, Strval => New_Val))); + + Append_Freeze_Actions (Ent, New_List ( + Make_Procedure_Call_Statement (Loc, + Name => New_Reference_To (RTE (RE_Set_External_Tag), Loc), + Parameter_Associations => New_List ( + Make_Attribute_Reference (Loc, + Attribute_Name => Name_Tag, + Prefix => New_Occurrence_Of (Ent, Loc)), + + Make_Attribute_Reference (Loc, + Attribute_Name => Name_Address, + Prefix => New_Occurrence_Of (E, Loc)))), + + Make_Procedure_Call_Statement (Loc, + Name => New_Reference_To (RTE (RE_Register_Tag), Loc), + Parameter_Associations => New_List ( + Make_Attribute_Reference (Loc, + Attribute_Name => Name_Tag, + Prefix => New_Occurrence_Of (Ent, Loc)))))); + end Expand_External_Tag_Definition; + ---------------------------- -- Expand_N_Freeze_Entity -- ---------------------------- *************** package body Exp_Ch13 is *** 309,314 **** --- 319,340 ---- if Is_Enumeration_Type (E) then Build_Enumeration_Image_Tables (E, N); + + elsif Is_Tagged_Type (E) + and then Is_First_Subtype (E) + then + + -- Check for a definition of External_Tag, whose expansion must + -- be delayed until the dispatch table is built. + + declare + Def : Node_Id := + Get_Attribute_Definition_Clause (E, Attribute_External_Tag); + begin + if Present (Def) then + Expand_External_Tag_Definition (Def); + end if; + end; end if; -- If subprogram, freeze the subprogram diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch13.ads gcc-3.3/gcc/ada/exp_ch13.ads *** gcc-3.2.3/gcc/ada/exp_ch13.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch13.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch2.adb gcc-3.3/gcc/ada/exp_ch2.adb *** gcc-3.2.3/gcc/ada/exp_ch2.adb 2002-05-04 03:27:46.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch2.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 29,34 **** --- 28,34 ---- with Atree; use Atree; with Einfo; use Einfo; with Elists; use Elists; + with Errout; use Errout; with Exp_Smem; use Exp_Smem; with Exp_Util; use Exp_Util; with Exp_VFpt; use Exp_VFpt; *************** package body Exp_Ch2 is *** 210,215 **** --- 210,221 ---- E : constant Entity_Id := Entity (N); begin + -- Defend against errors + + if No (E) and then Total_Errors_Detected /= 0 then + return; + end if; + if Ekind (E) = E_Discriminant then Expand_Discriminant (N); diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch2.ads gcc-3.3/gcc/ada/exp_ch2.ads *** gcc-3.2.3/gcc/ada/exp_ch2.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch2.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch3.adb gcc-3.3/gcc/ada/exp_ch3.adb *** gcc-3.2.3/gcc/ada/exp_ch3.adb 2002-05-04 03:27:46.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch3.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Atree; use Atree; *** 30,35 **** --- 29,35 ---- with Checks; use Checks; with Einfo; use Einfo; with Elists; use Elists; + with Errout; use Errout; with Exp_Aggr; use Exp_Aggr; with Exp_Ch4; use Exp_Ch4; with Exp_Ch7; use Exp_Ch7; *************** package body Exp_Ch3 is *** 118,123 **** --- 118,128 ---- -- Create An Equality function for the non-tagged variant record 'Typ' -- and attach it to the TSS list + procedure Check_Stream_Attributes (Typ : Entity_Id); + -- Check that if a limited extension has a parent with user-defined + -- stream attributes, any limited component of the extension also has + -- the corresponding user-defined stream attributes. + procedure Expand_Tagged_Root (T : Entity_Id); -- Add a field _Tag at the beginning of the record. This field carries -- the value of the access to the Dispatch table. This procedure is only *************** package body Exp_Ch3 is *** 147,152 **** --- 152,161 ---- -- applies only to E_Record_Type entities, not to class wide types, -- record subtypes, or private types. + procedure Freeze_Stream_Operations (N : Node_Id; Typ : Entity_Id); + -- Treat user-defined stream operations as renaming_as_body if the + -- subprogram they rename is not frozen when the type is frozen. + function Init_Formals (Typ : Entity_Id) return List_Id; -- This function builds the list of formals for an initialization routine. -- The first formal is always _Init with the given type. For task value *************** package body Exp_Ch3 is *** 561,567 **** Set_Ekind (Proc_Id, E_Procedure); Set_Is_Public (Proc_Id, Is_Public (A_Type)); - Set_Is_Inlined (Proc_Id); Set_Is_Internal (Proc_Id); Set_Has_Completion (Proc_Id); --- 570,575 ---- *************** package body Exp_Ch3 is *** 569,574 **** --- 577,593 ---- Set_Debug_Info_Off (Proc_Id); end if; + -- Set inlined unless controlled stuff or tasks around, in which + -- case we do not want to inline, because nested stuff may cause + -- difficulties in interunit inlining, and furthermore there is + -- in any case no point in inlining such complex init procs. + + if not Has_Task (Proc_Id) + and then not Controlled_Type (Proc_Id) + then + Set_Is_Inlined (Proc_Id); + end if; + -- Associate Init_Proc with type, and determine if the procedure -- is null (happens because of the Initialize_Scalars pragma case, -- where we have to generate a null procedure in case it is called *************** package body Exp_Ch3 is *** 1325,1338 **** -- of the initialization procedure (by calling all the preceding -- auxiliary routines), and install it as the _init TSS. ! procedure Build_Record_Checks ! (S : Node_Id; ! Related_Nod : Node_Id; ! Check_List : List_Id); -- Add range checks to components of disciminated records. S is a ! -- subtype indication of a record component. Related_Nod is passed ! -- for compatibility with Process_Range_Expr_In_Decl. Check_List is ! -- a list to which the check actions are appended. function Component_Needs_Simple_Initialization (T : Entity_Id) --- 1344,1353 ---- -- of the initialization procedure (by calling all the preceding -- auxiliary routines), and install it as the _init TSS. ! procedure Build_Record_Checks (S : Node_Id; Check_List : List_Id); -- Add range checks to components of disciminated records. S is a ! -- subtype indication of a record component. Check_List is a list ! -- to which the check actions are appended. function Component_Needs_Simple_Initialization (T : Entity_Id) *************** package body Exp_Ch3 is *** 1345,1364 **** -- initialized by other means. procedure Constrain_Array ! (SI : Node_Id; ! Related_Nod : Node_Id; ! Check_List : List_Id); -- Called from Build_Record_Checks. -- Apply a list of index constraints to an unconstrained array type. -- The first parameter is the entity for the resulting subtype. ! -- Related_Nod is passed for compatibility with Process_Range_Expr_In_ ! -- Decl. Check_List is a list to which the check actions are appended. procedure Constrain_Index ! (Index : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id; ! Check_List : List_Id); -- Called from Build_Record_Checks. -- Process an index constraint in a constrained array declaration. -- The constraint can be a subtype name, or a range with or without --- 1360,1376 ---- -- initialized by other means. procedure Constrain_Array ! (SI : Node_Id; ! Check_List : List_Id); -- Called from Build_Record_Checks. -- Apply a list of index constraints to an unconstrained array type. -- The first parameter is the entity for the resulting subtype. ! -- Check_List is a list to which the check actions are appended. procedure Constrain_Index ! (Index : Node_Id; ! S : Node_Id; ! Check_List : List_Id); -- Called from Build_Record_Checks. -- Process an index constraint in a constrained array declaration. -- The constraint can be a subtype name, or a range with or without *************** package body Exp_Ch3 is *** 1864,1873 **** Decl := First_Non_Pragma (Component_Items (Comp_List)); while Present (Decl) loop Loc := Sloc (Decl); ! Build_Record_Checks ! (Subtype_Indication (Decl), ! Decl, ! Check_List); Id := Defining_Identifier (Decl); Typ := Etype (Id); --- 1876,1882 ---- Decl := First_Non_Pragma (Component_Items (Comp_List)); while Present (Decl) loop Loc := Sloc (Decl); ! Build_Record_Checks (Subtype_Indication (Decl), Check_List); Id := Defining_Identifier (Decl); Typ := Etype (Id); *************** package body Exp_Ch3 is *** 2065,2079 **** -- Build_Record_Checks -- ------------------------- ! procedure Build_Record_Checks ! (S : Node_Id; ! Related_Nod : Node_Id; ! Check_List : List_Id) ! is P : Node_Id; Subtype_Mark_Id : Entity_Id; - begin if Nkind (S) = N_Subtype_Indication then Find_Type (Subtype_Mark (S)); P := Parent (S); --- 2074,2084 ---- -- Build_Record_Checks -- ------------------------- ! procedure Build_Record_Checks (S : Node_Id; Check_List : List_Id) is P : Node_Id; Subtype_Mark_Id : Entity_Id; + begin if Nkind (S) = N_Subtype_Indication then Find_Type (Subtype_Mark (S)); P := Parent (S); *************** package body Exp_Ch3 is *** 2084,2096 **** case Ekind (Subtype_Mark_Id) is when Array_Kind => ! Constrain_Array (S, Related_Nod, Check_List); when others => null; end case; end if; - end Build_Record_Checks; ------------------------------------------- --- 2089,2100 ---- case Ekind (Subtype_Mark_Id) is when Array_Kind => ! Constrain_Array (S, Check_List); when others => null; end case; end if; end Build_Record_Checks; ------------------------------------------- *************** package body Exp_Ch3 is *** 2114,2120 **** procedure Constrain_Array (SI : Node_Id; - Related_Nod : Node_Id; Check_List : List_Id) is C : constant Node_Id := Constraint (SI); --- 2118,2123 ---- *************** package body Exp_Ch3 is *** 2148,2154 **** -- Apply constraints to each index type for J in 1 .. Number_Of_Constraints loop ! Constrain_Index (Index, S, Related_Nod, Check_List); Next (Index); Next (S); end loop; --- 2151,2157 ---- -- Apply constraints to each index type for J in 1 .. Number_Of_Constraints loop ! Constrain_Index (Index, S, Check_List); Next (Index); Next (S); end loop; *************** package body Exp_Ch3 is *** 2162,2175 **** procedure Constrain_Index (Index : Node_Id; S : Node_Id; - Related_Nod : Node_Id; Check_List : List_Id) is T : constant Entity_Id := Etype (Index); begin if Nkind (S) = N_Range then ! Process_Range_Expr_In_Decl (S, T, Related_Nod, Check_List); end if; end Constrain_Index; --- 2165,2177 ---- procedure Constrain_Index (Index : Node_Id; S : Node_Id; Check_List : List_Id) is T : constant Entity_Id := Etype (Index); begin if Nkind (S) = N_Range then ! Process_Range_Expr_In_Decl (S, T, Check_List); end if; end Constrain_Index; *************** package body Exp_Ch3 is *** 2376,2383 **** -- yet. The initialization of controlled records contains a nested -- clean-up procedure that makes it impractical to inline as well, -- and leads to undefined symbols if inlined in a different unit. ! if not Is_Protected_Record_Type (Rec_Type) and then not Controlled_Type (Rec_Type) then Set_Is_Inlined (Proc_Id); --- 2378,2387 ---- -- yet. The initialization of controlled records contains a nested -- clean-up procedure that makes it impractical to inline as well, -- and leads to undefined symbols if inlined in a different unit. + -- Similar considerations apply to task types. ! if not Is_Concurrent_Type (Rec_Type) ! and then not Has_Task (Rec_Type) and then not Controlled_Type (Rec_Type) then Set_Is_Inlined (Proc_Id); *************** package body Exp_Ch3 is *** 2482,2489 **** if Has_Unchecked_Union (Typ) then Append_To (Stmts, ! Make_Raise_Program_Error (Loc)); ! else Append_To (Stmts, Make_Eq_If (Typ, --- 2486,2493 ---- if Has_Unchecked_Union (Typ) then Append_To (Stmts, ! Make_Raise_Program_Error (Loc, ! Reason => PE_Unchecked_Union_Restriction)); else Append_To (Stmts, Make_Eq_If (Typ, *************** package body Exp_Ch3 is *** 2504,2509 **** --- 2508,2548 ---- end if; end Build_Variant_Record_Equality; + ----------------------------- + -- Check_Stream_Attributes -- + ----------------------------- + + procedure Check_Stream_Attributes (Typ : Entity_Id) is + Comp : Entity_Id; + Par : constant Entity_Id := Root_Type (Base_Type (Typ)); + Par_Read : Boolean := Present (TSS (Par, Name_uRead)); + Par_Write : Boolean := Present (TSS (Par, Name_uWrite)); + + begin + if Par_Read or else Par_Write then + Comp := First_Component (Typ); + while Present (Comp) loop + if Comes_From_Source (Comp) + and then Original_Record_Component (Comp) = Comp + and then Is_Limited_Type (Etype (Comp)) + then + if (Par_Read and then + No (TSS (Base_Type (Etype (Comp)), Name_uRead))) + or else + (Par_Write and then + No (TSS (Base_Type (Etype (Comp)), Name_uWrite))) + then + Error_Msg_N + ("|component must have Stream attribute", + Parent (Comp)); + end if; + end if; + + Next_Component (Comp); + end loop; + end if; + end Check_Stream_Attributes; + --------------------------- -- Expand_Derived_Record -- --------------------------- *************** package body Exp_Ch3 is *** 2679,2685 **** end if; elsif Has_Task (Def_Id) then ! Expand_Previous_Access_Type (N, Def_Id); end if; Par_Id := Etype (B_Id); --- 2718,2724 ---- end if; elsif Has_Task (Def_Id) then ! Expand_Previous_Access_Type (Def_Id); end if; Par_Id := Etype (B_Id); *************** package body Exp_Ch3 is *** 2757,2766 **** Expr_Q : Node_Id; begin -- Don't do anything for deferred constants. All proper actions will -- be expanded during the redeclaration. ! if No (Expr) and Constant_Present (N) then return; end if; --- 2796,2814 ---- Expr_Q : Node_Id; begin + -- If we have a task type in no run time mode, then complain and ignore + + if No_Run_Time + and then not Restricted_Profile + and then Is_Task_Type (Typ) + then + Disallow_In_No_Run_Time_Mode (N); + return; + -- Don't do anything for deferred constants. All proper actions will -- be expanded during the redeclaration. ! elsif No (Expr) and Constant_Present (N) then return; end if; *************** package body Exp_Ch3 is *** 2870,2875 **** --- 2918,2931 ---- Insert_Actions_After (N, Build_Initialization_Call (Loc, Id_Ref, Typ)); + -- The initialization call may well set Not_Source_Assigned + -- to False, because it looks like an modification, but the + -- proper criterion is whether or not the type is at least + -- partially initialized, so reset the flag appropriately. + + Set_Not_Source_Assigned + (Def_Id, not Is_Partially_Initialized_Type (Typ)); + -- If simple initialization is required, then set an appropriate -- simple initialization expression in place. This special -- initialization is required even though No_Init_Flag is present. *************** package body Exp_Ch3 is *** 3076,3082 **** -- Expand_Previous_Access_Type -- --------------------------------- ! procedure Expand_Previous_Access_Type (N : Node_Id; Def_Id : Entity_Id) is T : Entity_Id := First_Entity (Current_Scope); begin --- 3132,3138 ---- -- Expand_Previous_Access_Type -- --------------------------------- ! procedure Expand_Previous_Access_Type (Def_Id : Entity_Id) is T : Entity_Id := First_Entity (Current_Scope); begin *************** package body Exp_Ch3 is *** 3456,3462 **** Discrete_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List ( Make_Raise_Program_Error (Loc, ! Condition => Make_Identifier (Loc, Name_uF)), Make_Return_Statement (Loc, Expression => Make_Integer_Literal (Loc, -1))))); --- 3512,3519 ---- Discrete_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List ( Make_Raise_Program_Error (Loc, ! Condition => Make_Identifier (Loc, Name_uF), ! Reason => PE_Invalid_Data), Make_Return_Statement (Loc, Expression => Make_Integer_Literal (Loc, -1))))); *************** package body Exp_Ch3 is *** 3568,3573 **** --- 3625,3637 ---- end; end if; + if Is_Derived_Type (Def_Id) + and then Is_Limited_Type (Def_Id) + and then Is_Tagged_Type (Def_Id) + then + Check_Stream_Attributes (Def_Id); + end if; + -- Update task and controlled component flags, because some of the -- component types may have been private at the point of the record -- declaration. *************** package body Exp_Ch3 is *** 3760,3765 **** --- 3824,3863 ---- end Freeze_Record_Type; + ------------------------------ + -- Freeze_Stream_Operations -- + ------------------------------ + + procedure Freeze_Stream_Operations (N : Node_Id; Typ : Entity_Id) is + Names : constant array (1 .. 4) of Name_Id := + (Name_uInput, Name_uOutput, Name_uRead, Name_uWrite); + Stream_Op : Entity_Id; + + begin + -- Primitive operations of tagged types are frozen when the dispatch + -- table is constructed. + + if not Comes_From_Source (Typ) + or else Is_Tagged_Type (Typ) + then + return; + end if; + + for J in Names'Range loop + Stream_Op := TSS (Typ, Names (J)); + + if Present (Stream_Op) + and then Is_Subprogram (Stream_Op) + and then Nkind (Unit_Declaration_Node (Stream_Op)) = + N_Subprogram_Declaration + and then not Is_Frozen (Stream_Op) + then + Append_Freeze_Actions + (Typ, Freeze_Entity (Stream_Op, Sloc (N))); + end if; + end loop; + end Freeze_Stream_Operations; + ----------------- -- Freeze_Type -- ----------------- *************** package body Exp_Ch3 is *** 3974,3980 **** -- Third discriminant is the alignment DT_Align))))); - end; Set_Associated_Storage_Pool (Def_Id, Pool_Object); --- 4072,4077 ---- *************** package body Exp_Ch3 is *** 3990,3996 **** -- when analyzing the rep. clause null; - end if; -- For access-to-controlled types (including class-wide types --- 4087,4092 ---- *************** package body Exp_Ch3 is *** 4078,4083 **** --- 4174,4181 ---- -- the freeze nodes are there for use by Gigi. end if; + + Freeze_Stream_Operations (N, Def_Id); end Freeze_Type; ------------------------- *************** package body Exp_Ch3 is *** 4095,4103 **** Val_RE : RE_Id; begin -- For scalars, we must have normalize/initialize scalars case ! if Is_Scalar_Type (T) then pragma Assert (Init_Or_Norm_Scalars); -- Processing for Normalize_Scalars case --- 4193,4226 ---- Val_RE : RE_Id; begin + -- For a private type, we should always have an underlying type + -- (because this was already checked in Needs_Simple_Initialization). + -- What we do is to get the value for the underlying type and then + -- do an Unchecked_Convert to the private type. + + if Is_Private_Type (T) then + Val := Get_Simple_Init_Val (Underlying_Type (T), Loc); + + -- A special case, if the underlying value is null, then qualify + -- it with the underlying type, so that the null is properly typed + -- Similarly, if it is an aggregate it must be qualified, because + -- an unchecked conversion does not provide a context for it. + + if Nkind (Val) = N_Null + or else Nkind (Val) = N_Aggregate + then + Val := + Make_Qualified_Expression (Loc, + Subtype_Mark => + New_Occurrence_Of (Underlying_Type (T), Loc), + Expression => Val); + end if; + + return Unchecked_Convert_To (T, Val); + -- For scalars, we must have normalize/initialize scalars case ! elsif Is_Scalar_Type (T) then pragma Assert (Init_Or_Norm_Scalars); -- Processing for Normalize_Scalars case *************** package body Exp_Ch3 is *** 4248,4280 **** return Nod; end; ! -- Otherwise we have a case of a private type whose underlying type ! -- needs simple initialization. In this case, we get the value for ! -- the underlying type, then unchecked convert to the private type. else ! pragma Assert ! (Is_Private_Type (T) ! and then Present (Underlying_Type (T))); ! ! Val := Get_Simple_Init_Val (Underlying_Type (T), Loc); ! ! -- A special case, if the underlying value is null, then qualify ! -- it with the underlying type, so that the null is properly typed ! -- Similarly, if it is an aggregate it must be qualified, because ! -- an unchecked conversion does not provide a context for it. ! ! if Nkind (Val) = N_Null ! or else Nkind (Val) = N_Aggregate ! then ! Val := ! Make_Qualified_Expression (Loc, ! Subtype_Mark => ! New_Occurrence_Of (Underlying_Type (T), Loc), ! Expression => Val); ! end if; ! ! return Unchecked_Convert_To (T, Val); end if; end Get_Simple_Init_Val; --- 4371,4382 ---- return Nod; end; ! -- No other possibilities should arise, since we should only be ! -- calling Get_Simple_Init_Val if Needs_Simple_Initialization ! -- returned True, indicating one of the above cases held. else ! raise Program_Error; end if; end Get_Simple_Init_Val; *************** package body Exp_Ch3 is *** 4718,4728 **** function Needs_Simple_Initialization (T : Entity_Id) return Boolean is begin -- Cases needing simple initialization are access types, and, if pragma -- Normalize_Scalars or Initialize_Scalars is in effect, then all scalar -- types. ! if Is_Access_Type (T) or else (Init_Or_Norm_Scalars and then (Is_Scalar_Type (T))) or else (Is_Bit_Packed_Array (T) --- 4820,4845 ---- function Needs_Simple_Initialization (T : Entity_Id) return Boolean is begin + -- Check for private type, in which case test applies to the + -- underlying type of the private type. + + if Is_Private_Type (T) then + declare + RT : constant Entity_Id := Underlying_Type (T); + + begin + if Present (RT) then + return Needs_Simple_Initialization (RT); + else + return False; + end if; + end; + -- Cases needing simple initialization are access types, and, if pragma -- Normalize_Scalars or Initialize_Scalars is in effect, then all scalar -- types. ! elsif Is_Access_Type (T) or else (Init_Or_Norm_Scalars and then (Is_Scalar_Type (T))) or else (Is_Bit_Packed_Array (T) *************** package body Exp_Ch3 is *** 4745,4765 **** then return True; - -- Check for private type, in which case test applies to the - -- underlying type of the private type. - - elsif Is_Private_Type (T) then - declare - RT : constant Entity_Id := Underlying_Type (T); - - begin - if Present (RT) then - return Needs_Simple_Initialization (RT); - else - return False; - end if; - end; - else return False; end if; --- 4862,4867 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch3.ads gcc-3.3/gcc/ada/exp_ch3.ads *** gcc-3.2.3/gcc/ada/exp_ch3.ads 2002-05-04 03:27:46.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch3.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Exp_Ch3 is *** 38,45 **** procedure Expand_N_Variant_Part (N : Node_Id); procedure Expand_N_Full_Type_Declaration (N : Node_Id); ! procedure Expand_Previous_Access_Type (N : Node_Id; Def_Id : Entity_Id); ! -- For a full type declaration that contains tasks, or that is a task, -- check whether there exists an access type whose designated type is an -- incomplete declarations for the current composite type. If so, build -- the master for that access type, now that it is known to denote an --- 37,44 ---- procedure Expand_N_Variant_Part (N : Node_Id); procedure Expand_N_Full_Type_Declaration (N : Node_Id); ! procedure Expand_Previous_Access_Type (Def_Id : Entity_Id); ! -- For a full type declaration that contains tasks, or that is a task, -- check whether there exists an access type whose designated type is an -- incomplete declarations for the current composite type. If so, build -- the master for that access type, now that it is known to denote an diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch4.adb gcc-3.3/gcc/ada/exp_ch4.adb *** gcc-3.2.3/gcc/ada/exp_ch4.adb 2002-05-04 03:27:48.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch4.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with Inline; use Inline; *** 46,51 **** --- 45,51 ---- with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; + with Restrict; use Restrict; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Cat; use Sem_Cat; *************** with Sem_Eval; use Sem_Eval; *** 54,63 **** --- 54,65 ---- with Sem_Res; use Sem_Res; with Sem_Type; use Sem_Type; with Sem_Util; use Sem_Util; + with Sem_Warn; use Sem_Warn; with Sinfo; use Sinfo; with Sinfo.CN; use Sinfo.CN; with Snames; use Snames; with Stand; use Stand; + with Targparm; use Targparm; with Tbuild; use Tbuild; with Ttypes; use Ttypes; with Uintp; use Uintp; *************** package body Exp_Ch4 is *** 1298,1308 **** end if; -- If we have anything other than Standard_Character or ! -- Standard_String, then we must have had an error earlier. ! -- So we just abandon the attempt at expansion. else ! pragma Assert (Errors_Detected > 0); return; end if; --- 1300,1310 ---- end if; -- If we have anything other than Standard_Character or ! -- Standard_String, then we must have had a serious error ! -- earlier, so we just abandon the attempt at expansion. else ! pragma Assert (Serious_Errors_Detected > 0); return; end if; *************** package body Exp_Ch4 is *** 1649,1658 **** if Nkind (Expression (Exp)) = N_Raise_Constraint_Error then ! -- Propagate constraint_error to enclosing allocator. ! Rewrite ! (Exp, New_Copy (Expression (Exp))); end if; else -- First check against the type of the qualified expression --- 1651,1659 ---- if Nkind (Expression (Exp)) = N_Raise_Constraint_Error then ! -- Propagate constraint_error to enclosing allocator ! Rewrite (Exp, New_Copy (Expression (Exp))); end if; else -- First check against the type of the qualified expression *************** package body Exp_Ch4 is *** 2572,2578 **** -- Deal with software overflow checking ! if Software_Overflow_Checking and then Is_Signed_Integer_Type (Etype (N)) and then Do_Overflow_Check (N) then --- 2573,2579 ---- -- Deal with software overflow checking ! if not Backend_Overflow_Checks_On_Target and then Is_Signed_Integer_Type (Etype (N)) and then Do_Overflow_Check (N) then *************** package body Exp_Ch4 is *** 3069,3074 **** --- 3070,3076 ---- Typ : constant Entity_Id := Etype (N); Rtyp : constant Entity_Id := Root_Type (Typ); Base : constant Node_Id := Relocate_Node (Left_Opnd (N)); + Bastyp : constant Node_Id := Etype (Base); Exp : constant Node_Id := Relocate_Node (Right_Opnd (N)); Exptyp : constant Entity_Id := Etype (Exp); Ovflo : constant Boolean := Do_Overflow_Check (N); *************** package body Exp_Ch4 is *** 3081,3086 **** --- 3083,3118 ---- begin Binary_Op_Validity_Checks (N); + -- If either operand is of a private type, then we have the use of + -- an intrinsic operator, and we get rid of the privateness, by using + -- root types of underlying types for the actual operation. Otherwise + -- the private types will cause trouble if we expand multiplications + -- or shifts etc. We also do this transformation if the result type + -- is different from the base type. + + if Is_Private_Type (Etype (Base)) + or else + Is_Private_Type (Typ) + or else + Is_Private_Type (Exptyp) + or else + Rtyp /= Root_Type (Bastyp) + then + declare + Bt : constant Entity_Id := Root_Type (Underlying_Type (Bastyp)); + Et : constant Entity_Id := Root_Type (Underlying_Type (Exptyp)); + + begin + Rewrite (N, + Unchecked_Convert_To (Typ, + Make_Op_Expon (Loc, + Left_Opnd => Unchecked_Convert_To (Bt, Base), + Right_Opnd => Unchecked_Convert_To (Et, Exp)))); + Analyze_And_Resolve (N, Typ); + return; + end; + end if; + -- At this point the exponentiation must be dynamic since the static -- case has already been folded after Resolve by Eval_Op_Expon. *************** package body Exp_Ch4 is *** 3201,3209 **** end; end if; ! -- Fall through if exponentiation must be done using a runtime routine. ! -- First deal with modular case. if Is_Modular_Integer_Type (Rtyp) then --- 3233,3246 ---- end; end if; ! -- Fall through if exponentiation must be done using a runtime routine ! if No_Run_Time then ! Disallow_In_No_Run_Time_Mode (N); ! return; ! end if; ! ! -- First deal with modular case if Is_Modular_Integer_Type (Rtyp) then *************** package body Exp_Ch4 is *** 3496,3502 **** begin Unary_Op_Validity_Checks (N); ! if Software_Overflow_Checking and then Is_Signed_Integer_Type (Etype (N)) and then Do_Overflow_Check (N) then --- 3533,3539 ---- begin Unary_Op_Validity_Checks (N); ! if not Backend_Overflow_Checks_On_Target and then Is_Signed_Integer_Type (Etype (N)) and then Do_Overflow_Check (N) then *************** package body Exp_Ch4 is *** 4738,4762 **** Expression => Conv), Make_Raise_Constraint_Error (Loc, ! Condition => ! Make_Or_Else (Loc, ! Left_Opnd => ! Make_Op_Lt (Loc, ! Left_Opnd => New_Occurrence_Of (Tnn, Loc), ! Right_Opnd => ! Make_Attribute_Reference (Loc, ! Attribute_Name => Name_First, ! Prefix => ! New_Occurrence_Of (Target_Type, Loc))), ! Right_Opnd => ! Make_Op_Gt (Loc, ! Left_Opnd => New_Occurrence_Of (Tnn, Loc), ! Right_Opnd => ! Make_Attribute_Reference (Loc, ! Attribute_Name => Name_Last, ! Prefix => ! New_Occurrence_Of (Target_Type, Loc))))))); Rewrite (N, New_Occurrence_Of (Tnn, Loc)); Analyze_And_Resolve (N, Btyp); --- 4775,4800 ---- Expression => Conv), Make_Raise_Constraint_Error (Loc, ! Condition => ! Make_Or_Else (Loc, ! Left_Opnd => ! Make_Op_Lt (Loc, ! Left_Opnd => New_Occurrence_Of (Tnn, Loc), ! Right_Opnd => ! Make_Attribute_Reference (Loc, ! Attribute_Name => Name_First, ! Prefix => ! New_Occurrence_Of (Target_Type, Loc))), ! Right_Opnd => ! Make_Op_Gt (Loc, ! Left_Opnd => New_Occurrence_Of (Tnn, Loc), ! Right_Opnd => ! Make_Attribute_Reference (Loc, ! Attribute_Name => Name_Last, ! Prefix => ! New_Occurrence_Of (Target_Type, Loc)))), ! Reason => CE_Range_Check_Failed))); Rewrite (N, New_Occurrence_Of (Tnn, Loc)); Analyze_And_Resolve (N, Btyp); *************** package body Exp_Ch4 is *** 4826,4835 **** -- cases. elsif In_Instance_Body ! and then Type_Access_Level (Operand_Type) ! > Type_Access_Level (Target_Type) then ! Rewrite (N, Make_Raise_Program_Error (Sloc (N))); Set_Etype (N, Target_Type); -- When the operand is a selected access discriminant --- 4864,4875 ---- -- cases. elsif In_Instance_Body ! and then Type_Access_Level (Operand_Type) > ! Type_Access_Level (Target_Type) then ! Rewrite (N, ! Make_Raise_Program_Error (Sloc (N), ! Reason => PE_Accessibility_Check_Failed)); Set_Etype (N, Target_Type); -- When the operand is a selected access discriminant *************** package body Exp_Ch4 is *** 4845,4851 **** and then Object_Access_Level (Operand) > Type_Access_Level (Target_Type) then ! Rewrite (N, Make_Raise_Program_Error (Sloc (N))); Set_Etype (N, Target_Type); end if; end if; --- 4885,4893 ---- and then Object_Access_Level (Operand) > Type_Access_Level (Target_Type) then ! Rewrite (N, ! Make_Raise_Program_Error (Sloc (N), ! Reason => PE_Accessibility_Check_Failed)); Set_Etype (N, Target_Type); end if; end if; *************** package body Exp_Ch4 is *** 4936,4942 **** Insert_Action (N, Make_Raise_Constraint_Error (Loc, ! Condition => Cond)); Change_Conversion_To_Unchecked (N); Analyze_And_Resolve (N, Target_Type); --- 4978,4985 ---- Insert_Action (N, Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Tag_Check_Failed)); Change_Conversion_To_Unchecked (N); Analyze_And_Resolve (N, Target_Type); *************** package body Exp_Ch4 is *** 5310,5322 **** -- statement directly. if No (Parent (Lhs)) then ! Result := Make_Raise_Program_Error (Loc); Set_Etype (Result, Standard_Boolean); return Result; else Insert_Action (Lhs, ! Make_Raise_Program_Error (Loc)); return New_Occurrence_Of (Standard_True, Loc); end if; end if; --- 5353,5368 ---- -- statement directly. if No (Parent (Lhs)) then ! Result := ! Make_Raise_Program_Error (Loc, ! Reason => PE_Unchecked_Union_Restriction); Set_Etype (Result, Standard_Boolean); return Result; else Insert_Action (Lhs, ! Make_Raise_Program_Error (Loc, ! Reason => PE_Unchecked_Union_Restriction)); return New_Occurrence_Of (Standard_True, Loc); end if; end if; *************** package body Exp_Ch4 is *** 5919,5929 **** --- 5965,5977 ---- Rewrite (N, Convert_To (Typ, New_Occurrence_Of (Standard_True, Sloc (N)))); Analyze_And_Resolve (N, Typ); + Warn_On_Known_Condition (N); elsif False_Result then Rewrite (N, Convert_To (Typ, New_Occurrence_Of (Standard_False, Sloc (N)))); Analyze_And_Resolve (N, Typ); + Warn_On_Known_Condition (N); end if; end Rewrite_Comparison; diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch4.ads gcc-3.3/gcc/ada/exp_ch4.ads *** gcc-3.2.3/gcc/ada/exp_ch4.ads 2002-05-04 03:27:49.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch4.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch5.adb gcc-3.3/gcc/ada/exp_ch5.adb *** gcc-3.2.3/gcc/ada/exp_ch5.adb 2002-05-04 03:27:50.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch5.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Exp_Ch5 is *** 311,322 **** -- Note: overlap is never possible if there is a change of -- representation, so we can exclude this case - -- In the case of compiling for the Java Virtual Machine, - -- slices are always passed by making a copy, so we don't - -- have to worry about overlap. We also want to prevent - -- generation of "<" comparisons for array addresses, - -- since that's a meaningless operation on the JVM. - if Ndim = 1 and then not Crep and then --- 310,315 ---- *************** package body Exp_Ch5 is *** 325,330 **** --- 318,330 ---- (Lhs_Formal and Rhs_Non_Local_Var) or else (Rhs_Formal and Lhs_Non_Local_Var)) + + -- In the case of compiling for the Java Virtual Machine, + -- slices are always passed by making a copy, so we don't + -- have to worry about overlap. We also want to prevent + -- generation of "<" comparisons for array addresses, + -- since that's a meaningless operation on the JVM. + and then not Java_VM then Set_Forwards_OK (N, False); *************** package body Exp_Ch5 is *** 352,366 **** elsif Has_Controlled_Component (L_Type) then Loop_Required := True; ! -- The only remaining cases involve slice assignments. If no slices ! -- are involved, then the assignment can definitely be handled by gigi. ! -- unless we have the parameter case mentioned above. elsif not L_Slice and not R_Slice then ! -- The following is temporary code??? It is not clear why it is ! -- necessary. For further investigation, look at the following ! -- short program which fails: -- procedure C52 is -- type BITS is array(INTEGER range <>) of BOOLEAN; --- 352,375 ---- elsif Has_Controlled_Component (L_Type) then Loop_Required := True; ! -- Case where no slice is involved elsif not L_Slice and not R_Slice then ! -- The following code deals with the case of unconstrained bit ! -- packed arrays. The problem is that the template for such ! -- arrays contains the bounds of the actual source level array, ! ! -- But the copy of an entire array requires the bounds of the ! -- underlying array. It would be nice if the back end could take ! -- care of this, but right now it does not know how, so if we ! -- have such a type, then we expand out into a loop, which is ! -- inefficient but works correctly. If we don't do this, we ! -- get the wrong length computed for the array to be moved. ! -- The two cases we need to worry about are: ! ! -- Explicit deference of an unconstrained packed array type as ! -- in the following example: -- procedure C52 is -- type BITS is array(INTEGER range <>) of BOOLEAN; *************** package body Exp_Ch5 is *** 373,394 **** -- P2.ALL := P1.ALL; -- end C52; ! -- To deal with the above, we expand out if either of the operands ! -- is an explicit dereference to an unconstrained bit packed array. ! Temporary_Code : declare ! function Is_Deref_Of_UBP (Opnd : Node_Id) return Boolean; ! -- Function to perform required test for special case above ! function Is_Deref_Of_UBP (Opnd : Node_Id) return Boolean is P_Type : Entity_Id; Des_Type : Entity_Id; begin ! if Nkind (Opnd) /= N_Explicit_Dereference then ! return False; ! else ! P_Type := Etype (Prefix (Opnd)); if not Is_Access_Type (P_Type) then return False; --- 382,426 ---- -- P2.ALL := P1.ALL; -- end C52; ! -- A formal parameter reference with an unconstrained bit ! -- array type is the other case we need to worry about (here ! -- we assume the same BITS type declared above: ! -- procedure Write_All (File : out BITS; Contents : in BITS); ! -- begin ! -- File.Storage := Contents; ! -- end Write_All; ! -- We expand to a loop in either of these two cases. ! ! -- Question for future thought. Another potentially more efficient ! -- approach would be to create the actual subtype, and then do an ! -- unchecked conversion to this actual subtype ??? ! ! Check_Unconstrained_Bit_Packed_Array : declare ! ! function Is_UBPA_Reference (Opnd : Node_Id) return Boolean; ! -- Function to perform required test for the first case, ! -- above (dereference of an unconstrained bit packed array) ! ! ----------------------- ! -- Is_UBPA_Reference -- ! ----------------------- ! ! function Is_UBPA_Reference (Opnd : Node_Id) return Boolean is ! Typ : constant Entity_Id := Underlying_Type (Etype (Opnd)); P_Type : Entity_Id; Des_Type : Entity_Id; begin ! if Present (Packed_Array_Type (Typ)) ! and then Is_Array_Type (Packed_Array_Type (Typ)) ! and then not Is_Constrained (Packed_Array_Type (Typ)) ! then ! return True; ! ! elsif Nkind (Opnd) = N_Explicit_Dereference then ! P_Type := Underlying_Type (Etype (Prefix (Opnd))); if not Is_Access_Type (P_Type) then return False; *************** package body Exp_Ch5 is *** 399,422 **** Is_Bit_Packed_Array (Des_Type) and then not Is_Constrained (Des_Type); end if; end if; ! end Is_Deref_Of_UBP; ! -- Start of processing for temporary code begin ! if Is_Deref_Of_UBP (Lhs) or else ! Is_Deref_Of_UBP (Rhs) then Loop_Required := True; ! -- Normal case (will be only case when above temp code removed ??? elsif Forwards_OK (N) then return; end if; ! end Temporary_Code; -- Gigi can always handle the assignment if the right side is a string -- literal (note that overlap is definitely impossible in this case). --- 431,462 ---- Is_Bit_Packed_Array (Des_Type) and then not Is_Constrained (Des_Type); end if; + + else + return False; end if; ! end Is_UBPA_Reference; ! -- Start of processing for Check_Unconstrained_Bit_Packed_Array begin ! if Is_UBPA_Reference (Lhs) or else ! Is_UBPA_Reference (Rhs) then Loop_Required := True; ! -- Here if we do not have the case of a reference to a bit ! -- packed unconstrained array case. In this case gigi can ! -- most certainly handle the assignment if a forwards move ! -- is allowed. ! ! -- (could it handle the backwards case also???) elsif Forwards_OK (N) then return; end if; ! end Check_Unconstrained_Bit_Packed_Array; -- Gigi can always handle the assignment if the right side is a string -- literal (note that overlap is definitely impossible in this case). *************** package body Exp_Ch5 is *** 1498,1504 **** Exception_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List ( ! Make_Raise_Program_Error (Loc))))))); end if; end if; --- 1538,1547 ---- Exception_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List ( ! Make_Raise_Program_Error (Loc, ! Reason => ! PE_Finalize_Raised_Exception) ! )))))); end if; end if; *************** package body Exp_Ch5 is *** 2378,2384 **** Right_Opnd => Unchecked_Convert_To (RTE (RE_Tag), New_Reference_To ! (Access_Disp_Table (Base_Type (Utyp)), Loc))))); -- If the result type is a specific nonlimited tagged type, -- then we have to ensure that the tag of the result is that --- 2421,2428 ---- Right_Opnd => Unchecked_Convert_To (RTE (RE_Tag), New_Reference_To ! (Access_Disp_Table (Base_Type (Utyp)), Loc))), ! Reason => CE_Tag_Check_Failed)); -- If the result type is a specific nonlimited tagged type, -- then we have to ensure that the tag of the result is that *************** package body Exp_Ch5 is *** 2716,2728 **** and then No_Initialization (Parent (Entity (Expression (L)))) then null; - - elsif Nkind (L) = N_Indexed_Component - and then Is_Entity_Name (Original_Node (Prefix (L))) - and then Is_Entry_Formal (Entity (Original_Node (Prefix (L)))) - then - null; - else Append_List_To (Res, Make_Final_Call ( --- 2760,2765 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch5.ads gcc-3.3/gcc/ada/exp_ch5.ads *** gcc-3.2.3/gcc/ada/exp_ch5.ads 2002-05-04 03:27:51.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch5.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch6.adb gcc-3.3/gcc/ada/exp_ch6.adb *** gcc-3.2.3/gcc/ada/exp_ch6.adb 2002-05-04 03:27:51.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch6.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Exp_Ch6 is *** 464,470 **** Make_If_Statement (Loc, Condition => Test, Then_Statements => New_List ( ! Make_Raise_Storage_Error (Loc)), Else_Statements => New_List ( Relocate_Node (Node (Call))))); --- 463,470 ---- Make_If_Statement (Loc, Condition => Test, Then_Statements => New_List ( ! Make_Raise_Storage_Error (Loc, ! Reason => SE_Infinite_Recursion)), Else_Statements => New_List ( Relocate_Node (Node (Call))))); *************** package body Exp_Ch6 is *** 1208,1213 **** --- 1208,1219 ---- -- Start of processing for Expand_Call begin + -- Ignore if previous error + + if Nkind (N) in N_Has_Etype and then Etype (N) = Any_Type then + return; + end if; + -- Call using access to subprogram with explicit dereference if Nkind (Name (N)) = N_Explicit_Dereference then *************** package body Exp_Ch6 is *** 1474,1480 **** Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Prev), Right_Opnd => Make_Null (Loc)); ! Insert_Action (Prev, Make_Raise_Constraint_Error (Loc, Cond)); end if; -- Perform appropriate validity checks on parameters --- 1480,1489 ---- Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Prev), Right_Opnd => Make_Null (Loc)); ! Insert_Action (Prev, ! Make_Raise_Constraint_Error (Loc, ! Condition => Cond, ! Reason => CE_Access_Parameter_Is_Null)); end if; -- Perform appropriate validity checks on parameters *************** package body Exp_Ch6 is *** 1678,1683 **** --- 1687,1693 ---- if Etype (Formal) /= Etype (Parent_Formal) and then Is_Scalar_Type (Etype (Formal)) and then Ekind (Formal) = E_In_Parameter + and then not Raises_Constraint_Error (Actual) then Rewrite (Actual, OK_Convert_To (Etype (Parent_Formal), *************** package body Exp_Ch6 is *** 2169,2175 **** -- use a qualified expression, because an aggregate is not a -- legal argument of a conversion. ! if Nkind (Expression (N)) = N_Aggregate then Ret := Make_Qualified_Expression (Sloc (N), Subtype_Mark => New_Occurrence_Of (Ret_Type, Sloc (N)), --- 2179,2187 ---- -- use a qualified expression, because an aggregate is not a -- legal argument of a conversion. ! if Nkind (Expression (N)) = N_Aggregate ! or else Nkind (Expression (N)) = N_Null ! then Ret := Make_Qualified_Expression (Sloc (N), Subtype_Mark => New_Occurrence_Of (Ret_Type, Sloc (N)), *************** package body Exp_Ch6 is *** 2876,2882 **** Make_Block_Statement (Hloc, Handled_Statement_Sequence => H); Rais : constant Node_Id := ! Make_Raise_Program_Error (Hloc); begin Set_Handled_Statement_Sequence (N, --- 2888,2895 ---- Make_Block_Statement (Hloc, Handled_Statement_Sequence => H); Rais : constant Node_Id := ! Make_Raise_Program_Error (Hloc, ! Reason => PE_Missing_Return); begin Set_Handled_Statement_Sequence (N, *************** package body Exp_Ch6 is *** 2912,2918 **** if Present (Next_Op) then Dec := Parent (Base_Type (Scop)); Set_Privals (Dec, Next_Op, Loc); ! Set_Discriminals (Dec, Next_Op, Loc); end if; end if; --- 2925,2931 ---- if Present (Next_Op) then Dec := Parent (Base_Type (Scop)); Set_Privals (Dec, Next_Op, Loc); ! Set_Discriminals (Dec); end if; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch6.ads gcc-3.3/gcc/ada/exp_ch6.ads *** gcc-3.2.3/gcc/ada/exp_ch6.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch6.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch7.adb gcc-3.3/gcc/ada/exp_ch7.adb *** gcc-3.2.3/gcc/ada/exp_ch7.adb 2002-05-04 03:27:52.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch7.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Exp_Ch7 is *** 380,401 **** ---------------------- procedure Build_Final_List (N : Node_Id; Typ : Entity_Id) is ! Loc : constant Source_Ptr := Sloc (N); begin Set_Associated_Final_Chain (Typ, Make_Defining_Identifier (Loc, New_External_Name (Chars (Typ), 'L'))); ! Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Associated_Final_Chain (Typ), Object_Definition => New_Reference_To ! (RTE (RE_List_Controller), Loc))); end Build_Final_List; ----------------------------- -- Build_Record_Deep_Procs -- ----------------------------- --- 379,434 ---- ---------------------- procedure Build_Final_List (N : Node_Id; Typ : Entity_Id) is ! Loc : constant Source_Ptr := Sloc (N); ! Decl : Node_Id; begin Set_Associated_Final_Chain (Typ, Make_Defining_Identifier (Loc, New_External_Name (Chars (Typ), 'L'))); ! Decl := Make_Object_Declaration (Loc, Defining_Identifier => Associated_Final_Chain (Typ), Object_Definition => New_Reference_To ! (RTE (RE_List_Controller), Loc)); ! ! -- The type may have been frozen already, and this is a late ! -- freezing action, in which case the declaration must be elaborated ! -- at once. If the call is for an allocator, the chain must also be ! -- created now, because the freezing of the type does not build one. ! -- Otherwise, the declaration is one of the freezing actions for a ! -- user-defined type. ! ! if Is_Frozen (Typ) ! or else (Nkind (N) = N_Allocator ! and then Ekind (Etype (N)) = E_Anonymous_Access_Type) ! then ! Insert_Action (N, Decl); ! else ! Append_Freeze_Action (Typ, Decl); ! end if; end Build_Final_List; + --------------------- + -- Build_Late_Proc -- + --------------------- + + procedure Build_Late_Proc (Typ : Entity_Id; Nam : Name_Id) is + begin + for Final_Prim in Name_Of'Range loop + if Name_Of (Final_Prim) = Nam then + Set_TSS (Typ, + Make_Deep_Proc ( + Prim => Final_Prim, + Typ => Typ, + Stmts => Make_Deep_Record_Body (Final_Prim, Typ))); + end if; + end loop; + end Build_Late_Proc; + ----------------------------- -- Build_Record_Deep_Procs -- ----------------------------- *************** package body Exp_Ch7 is *** 428,445 **** --------------------- function Controlled_Type (T : Entity_Id) return Boolean is begin ! -- Class-wide types are considered controlled because they may contain ! -- an extension that has controlled components return (Is_Class_Wide_Type (T) and then not No_Run_Time and then not In_Finalization_Root (T)) or else Is_Controlled (T) ! or else Has_Controlled_Component (T) or else (Is_Concurrent_Type (T) ! and then Present (Corresponding_Record_Type (T)) ! and then Controlled_Type (Corresponding_Record_Type (T))); end Controlled_Type; -------------------------- --- 461,525 ---- --------------------- function Controlled_Type (T : Entity_Id) return Boolean is + + function Has_Some_Controlled_Component (Rec : Entity_Id) return Boolean; + -- If type is not frozen yet, check explicitly among its components, + -- because flag is not necessarily set. + + ------------------------------------ + -- Has_Some_Controlled_Component -- + ------------------------------------ + + function Has_Some_Controlled_Component (Rec : Entity_Id) + return Boolean + is + Comp : Entity_Id; + + begin + if Has_Controlled_Component (Rec) then + return True; + + elsif not Is_Frozen (Rec) then + if Is_Record_Type (Rec) then + Comp := First_Entity (Rec); + + while Present (Comp) loop + if not Is_Type (Comp) + and then Controlled_Type (Etype (Comp)) + then + return True; + end if; + + Next_Entity (Comp); + end loop; + + return False; + + elsif Is_Array_Type (Rec) then + return Is_Controlled (Component_Type (Rec)); + + else + return Has_Controlled_Component (Rec); + end if; + else + return False; + end if; + end Has_Some_Controlled_Component; + + -- Start of processing for Controlled_Type + begin ! -- Class-wide types must be treated as controlled because they may ! -- contain an extension that has controlled components return (Is_Class_Wide_Type (T) and then not No_Run_Time and then not In_Finalization_Root (T)) or else Is_Controlled (T) ! or else Has_Some_Controlled_Component (T) or else (Is_Concurrent_Type (T) ! and then Present (Corresponding_Record_Type (T)) ! and then Controlled_Type (Corresponding_Record_Type (T))); end Controlled_Type; -------------------------- *************** package body Exp_Ch7 is *** 2040,2046 **** Make_Exception_Handler (Loc, Exception_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List ( ! Make_Raise_Program_Error (Loc)))); end if; Proc_Name := Make_Defining_Identifier (Loc, Deep_Name_Of (Prim)); --- 2120,2127 ---- Make_Exception_Handler (Loc, Exception_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List ( ! Make_Raise_Program_Error (Loc, ! Reason => PE_Finalize_Raised_Exception)))); end if; Proc_Name := Make_Defining_Identifier (Loc, Deep_Name_Of (Prim)); diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch7.ads gcc-3.3/gcc/ada/exp_ch7.ads *** gcc-3.2.3/gcc/ada/exp_ch7.ads 2002-05-04 03:27:53.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch7.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package Exp_Ch7 is *** 52,57 **** --- 51,60 ---- -- Create the procedures Deep_Initialize, Deep_Adjust and Deep_Finalize -- that take care of finalization management at run-time. + procedure Build_Late_Proc (Typ : Entity_Id; Nam : Name_Id); + -- Build one controlling procedure when a late body overrides one of + -- the controlling operations. + function Controller_Component (Typ : Entity_Id) return Entity_Id; -- Returns the entity of the component whose name is 'Name_uController' diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch8.adb gcc-3.3/gcc/ada/exp_ch8.adb *** gcc-3.2.3/gcc/ada/exp_ch8.adb 2002-05-04 03:27:53.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch8.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch8.ads gcc-3.3/gcc/ada/exp_ch8.ads *** gcc-3.2.3/gcc/ada/exp_ch8.ads 2002-05-04 03:27:53.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch8.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch9.adb gcc-3.3/gcc/ada/exp_ch9.adb *** gcc-3.2.3/gcc/ada/exp_ch9.adb 2002-05-04 03:27:53.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch9.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Exp_Ch9 is *** 99,108 **** -- of the System.Address pointer passed to entry barrier functions -- and entry body procedures. - function Array_Type (E : Entity_Id; Trec : Node_Id) return Entity_Id; - -- Find the array type associated with an entry family in the - -- associated record for the task type. - function Build_Accept_Body (Astat : Node_Id) return Node_Id; -- Transform accept statement into a block with added exception handler. -- Used both for simple accept statements and for accept alternatives in --- 98,103 ---- *************** package body Exp_Ch9 is *** 592,622 **** end Add_Private_Declarations; - ---------------- - -- Array_Type -- - ---------------- - - function Array_Type (E : Entity_Id; Trec : Node_Id) return Entity_Id is - Arr : Entity_Id := First_Component (Trec); - - begin - while Present (Arr) loop - exit when Ekind (Arr) = E_Component - and then Is_Array_Type (Etype (Arr)) - and then Chars (Arr) = Chars (E); - - Next_Component (Arr); - end loop; - - -- This used to return Arr itself, but this caused problems - -- when used in expanding a protected type, possibly because - -- the record of which it is a component is not frozen yet. - -- I am going to try the type instead. This may pose visibility - -- problems. ??? - - return Etype (Arr); - end Array_Type; - ----------------------- -- Build_Accept_Body -- ----------------------- --- 587,592 ---- *************** package body Exp_Ch9 is *** 3283,3289 **** Update_Prival_Subtypes (B_F); Set_Privals (Spec_Decl, N, Loc); ! Set_Discriminals (Spec_Decl, N, Loc); Set_Scope (Func, Scope (Prot)); else Analyze (Cond); --- 3253,3259 ---- Update_Prival_Subtypes (B_F); Set_Privals (Spec_Decl, N, Loc); ! Set_Discriminals (Spec_Decl); Set_Scope (Func, Scope (Prot)); else Analyze (Cond); *************** package body Exp_Ch9 is *** 4408,4414 **** if Present (Next_Op) then Set_Privals (Dec, Next_Op, Loc); ! Set_Discriminals (Dec, Next_Op, Loc); end if; end Expand_N_Entry_Body; --- 4378,4384 ---- if Present (Next_Op) then Set_Privals (Dec, Next_Op, Loc); ! Set_Discriminals (Dec); end if; end Expand_N_Entry_Body; *************** package body Exp_Ch9 is *** 5793,5799 **** Condition => Make_Op_Eq (Loc, Left_Opnd => New_Reference_To (Xnam, Loc), Right_Opnd => ! New_Reference_To (RTE (RE_No_Rendezvous), Loc)))); return Stats; end Accept_Or_Raise; --- 5763,5770 ---- Condition => Make_Op_Eq (Loc, Left_Opnd => New_Reference_To (Xnam, Loc), Right_Opnd => ! New_Reference_To (RTE (RE_No_Rendezvous), Loc)), ! Reason => PE_All_Guards_Closed)); return Stats; end Accept_Or_Raise; *************** package body Exp_Ch9 is *** 6756,6761 **** --- 6727,6743 ---- New_N : Node_Id; begin + -- Do not attempt expansion if in no run time mode + + if No_Run_Time + and then not Restricted_Profile + then + Disallow_In_No_Run_Time_Mode (N); + return; + end if; + + -- Here we start the expansion by generating discriminal declarations + Add_Discriminal_Declarations (Declarations (N), Ttyp, Name_uTask, Loc); -- Add a call to Abort_Undefer at the very beginning of the task *************** package body Exp_Ch9 is *** 6922,6948 **** Tasktyp : constant Entity_Id := Etype (Defining_Identifier (N)); Tasknm : constant Name_Id := Chars (Tasktyp); Taskdef : constant Node_Id := Task_Definition (N); - Proc_Spec : Node_Id; Rec_Decl : Node_Id; Rec_Ent : Entity_Id; Cdecls : List_Id; - Elab_Decl : Node_Id; Size_Decl : Node_Id; Body_Decl : Node_Id; begin ! if Present (Corresponding_Record_Type (Tasktyp)) then return; ! else ! Rec_Decl := Build_Corresponding_Record (N, Tasktyp, Loc); ! Rec_Ent := Defining_Identifier (Rec_Decl); ! Cdecls := Component_Items ! (Component_List (Type_Definition (Rec_Decl))); end if; Qualify_Entity_Names (N); -- First create the elaboration variable --- 6904,6940 ---- Tasktyp : constant Entity_Id := Etype (Defining_Identifier (N)); Tasknm : constant Name_Id := Chars (Tasktyp); Taskdef : constant Node_Id := Task_Definition (N); + Proc_Spec : Node_Id; Rec_Decl : Node_Id; Rec_Ent : Entity_Id; Cdecls : List_Id; Elab_Decl : Node_Id; Size_Decl : Node_Id; Body_Decl : Node_Id; begin ! -- Do not attempt expansion if in no run time mode ! ! if No_Run_Time ! and then not Restricted_Profile ! then ! Disallow_In_No_Run_Time_Mode (N); return; ! -- If already expanded, nothing to do ! ! elsif Present (Corresponding_Record_Type (Tasktyp)) then ! return; end if; + -- Here we will do the expansion + + Rec_Decl := Build_Corresponding_Record (N, Tasktyp, Loc); + Rec_Ent := Defining_Identifier (Rec_Decl); + Cdecls := Component_Items (Component_List + (Type_Definition (Rec_Decl))); + Qualify_Entity_Names (N); -- First create the elaboration variable *************** package body Exp_Ch9 is *** 6994,7000 **** -- This is done last, since the corresponding record initialization -- procedure will reference the previously created entities. ! -- Fill in the component declarations. First the _Task_Id field: Append_To (Cdecls, Make_Component_Declaration (Loc, --- 6986,6992 ---- -- This is done last, since the corresponding record initialization -- procedure will reference the previously created entities. ! -- Fill in the component declarations. First the _Task_Id field. Append_To (Cdecls, Make_Component_Declaration (Loc, *************** package body Exp_Ch9 is *** 7116,7122 **** -- Complete the expansion of access types to the current task -- type, if any were declared. ! Expand_Previous_Access_Type (N, Tasktyp); end Expand_N_Task_Type_Declaration; ------------------------------- --- 7108,7114 ---- -- Complete the expansion of access types to the current task -- type, if any were declared. ! Expand_Previous_Access_Type (Tasktyp); end Expand_N_Task_Type_Declaration; ------------------------------- *************** package body Exp_Ch9 is *** 7462,7468 **** Op := First_Protected_Operation (Declarations (N)); if Present (Op) then ! Set_Discriminals (Parent (Spec_Id), Op, Sloc (N)); Set_Privals (Parent (Spec_Id), Op, Sloc (N)); end if; end if; --- 7454,7460 ---- Op := First_Protected_Operation (Declarations (N)); if Present (Op) then ! Set_Discriminals (Parent (Spec_Id)); Set_Privals (Parent (Spec_Id), Op, Sloc (N)); end if; end if; *************** package body Exp_Ch9 is *** 8268,8278 **** -- Set_Discriminals -- ---------------------- ! procedure Set_Discriminals ! (Dec : Node_Id; ! Op : Node_Id; ! Loc : Source_Ptr) ! is D : Entity_Id; Pdef : Entity_Id; D_Minal : Entity_Id; --- 8260,8266 ---- -- Set_Discriminals -- ---------------------- ! procedure Set_Discriminals (Dec : Node_Id) is D : Entity_Id; Pdef : Entity_Id; D_Minal : Entity_Id; *************** package body Exp_Ch9 is *** 8497,8502 **** --- 8485,8505 ---- Update_Array_Bounds (Etype (Defining_Identifier (N))); return OK; + -- For array components of discriminated records, use the + -- base type directly, because it may depend indirectly + -- on the discriminants of the protected type. Cleaner would + -- be a systematic mechanism to compute actual subtypes of + -- private components ??? + + elsif Nkind (N) in N_Has_Etype + and then Present (Etype (N)) + and then Is_Array_Type (Etype (N)) + and then Nkind (N) = N_Selected_Component + and then Has_Discriminants (Etype (Prefix (N))) + then + Set_Etype (N, Base_Type (Etype (N))); + return OK; + else if Nkind (N) in N_Has_Etype and then Present (Etype (N)) diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_ch9.ads gcc-3.3/gcc/ada/exp_ch9.ads *** gcc-3.2.3/gcc/ada/exp_ch9.ads 2002-05-04 03:27:54.000000000 +0000 --- gcc-3.3/gcc/ada/exp_ch9.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-1999 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package Exp_Ch9 is *** 289,298 **** -- Given a protected operation node (a subprogram or entry body), -- find the following node in the declarations list. ! procedure Set_Discriminals ! (Dec : Node_Id; ! Op : Node_Id; ! Loc : Source_Ptr); -- Replace discriminals in a protected type for use by the -- next protected operation on the type. Each operation needs a -- new set of discirminals, since it needs a unique renaming of --- 288,294 ---- -- Given a protected operation node (a subprogram or entry body), -- find the following node in the declarations list. ! procedure Set_Discriminals (Dec : Node_Id); -- Replace discriminals in a protected type for use by the -- next protected operation on the type. Each operation needs a -- new set of discirminals, since it needs a unique renaming of diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_code.adb gcc-3.3/gcc/ada/exp_code.adb *** gcc-3.2.3/gcc/ada/exp_code.adb 2002-05-04 03:27:55.000000000 +0000 --- gcc-3.3/gcc/ada/exp_code.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_code.ads gcc-3.3/gcc/ada/exp_code.ads *** gcc-3.2.3/gcc/ada/exp_code.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_code.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_dbug.adb gcc-3.3/gcc/ada/exp_dbug.adb *** gcc-3.2.3/gcc/ada/exp_dbug.adb 2002-05-04 03:27:56.000000000 +0000 --- gcc-3.3/gcc/ada/exp_dbug.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1996-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1996-2002 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- -- *************** with Opt; use Opt; *** 41,47 **** with Output; use Output; with Sem_Eval; use Sem_Eval; with Sem_Util; use Sem_Util; ! with Sinput; use Sinput; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; --- 40,46 ---- with Output; use Output; with Sem_Eval; use Sem_Eval; with Sem_Util; use Sem_Util; ! with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; *************** package body Exp_Dbug is *** 139,144 **** --- 138,156 ---- -- building this name to realize efficiently that b needs further -- qualification. + -------------------- + -- Homonym_Suffix -- + -------------------- + + -- The string defined here (and its associated length) is used to + -- gather the homonym string that will be appended to Name_Buffer + -- when the name is complete. Strip_Suffixes appends to this string + -- as does Append_Homonym_Number, and Output_Homonym_Numbers_Suffix + -- appends the string to the end of Name_Buffer. + + Homonym_Numbers : String (1 .. 256); + Homonym_Len : Natural := 0; + ---------------------- -- Local Procedures -- ---------------------- *************** package body Exp_Dbug is *** 150,155 **** --- 162,171 ---- -- Add nnn_ddd to Name_Buffer, where nnn and ddd are integer values of -- the normalized numerator and denominator of the given real value. + procedure Append_Homonym_Number (E : Entity_Id); + -- If the entity E has homonyms in the same scope, then make an entry + -- in the Homonym_Numbers array, bumping Homonym_Count accordingly. + function Bounds_Match_Size (E : Entity_Id) return Boolean; -- Determine whether the bounds of E match the size of the type. This is -- used to determine whether encoding is required for a discrete type. *************** package body Exp_Dbug is *** 171,176 **** --- 187,195 ---- -- sequence in the string S (defined as two underscores -- which are preceded and followed by a non-underscore) + procedure Output_Homonym_Numbers_Suffix; + -- If homonym numbers are stored, then output them into Name_Buffer. + procedure Prepend_String_To_Buffer (S : String); -- Prepend given string to the contents of the string buffer, updating -- the value in Name_Len (i.e. string is added at start of buffer). *************** package body Exp_Dbug is *** 185,196 **** -- If not already done, replaces the Chars field of the given entity -- with the appropriate fully qualified name. ! procedure Strip_BNPE_Suffix (Suffix_Found : in out Boolean); -- Given an qualified entity name in Name_Buffer, remove any plain X or -- X{nb} qualification suffix. The contents of Name_Buffer is not changed -- but Name_Len may be adjusted on return to remove the suffix. If a ! -- suffix is found and stripped, then Suffix_Found is set to True. If ! -- no suffix is found, then Suffix_Found is not modified. ------------------------ -- Add_Real_To_Buffer -- --- 204,218 ---- -- If not already done, replaces the Chars field of the given entity -- with the appropriate fully qualified name. ! procedure Strip_Suffixes (BNPE_Suffix_Found : in out Boolean); -- Given an qualified entity name in Name_Buffer, remove any plain X or -- X{nb} qualification suffix. The contents of Name_Buffer is not changed -- but Name_Len may be adjusted on return to remove the suffix. If a ! -- BNPE suffix is found and stripped, then BNPE_Suffix_Found is set to ! -- True. If no suffix is found, then BNPE_Suffix_Found is not modified. ! -- This routine also searches for a homonym suffix, and if one is found ! -- it is also stripped, and the entries are added to the global homonym ! -- list (Homonym_Numbers) so that they can later be put back. ------------------------ -- Add_Real_To_Buffer -- *************** package body Exp_Dbug is *** 218,223 **** --- 240,296 ---- end if; end Add_Uint_To_Buffer; + --------------------------- + -- Append_Homonym_Number -- + --------------------------- + + procedure Append_Homonym_Number (E : Entity_Id) is + + procedure Add_Nat_To_H (Nr : Nat); + -- Little procedure to append Nr to Homonym_Numbers + + ------------------ + -- Add_Nat_To_H -- + ------------------ + + procedure Add_Nat_To_H (Nr : Nat) is + begin + if Nr >= 10 then + Add_Nat_To_H (Nr / 10); + end if; + + Homonym_Len := Homonym_Len + 1; + Homonym_Numbers (Homonym_Len) := + Character'Val (Nr mod 10 + Character'Pos ('0')); + end Add_Nat_To_H; + + -- Start of processing for Append_Homonym_Number + + begin + if Has_Homonym (E) then + declare + H : Entity_Id := Homonym (E); + Nr : Nat := 1; + + begin + while Present (H) loop + if (Scope (H) = Scope (E)) then + Nr := Nr + 1; + end if; + + H := Homonym (H); + end loop; + + if Homonym_Len > 0 then + Homonym_Len := Homonym_Len + 1; + Homonym_Numbers (Homonym_Len) := '_'; + end if; + + Add_Nat_To_H (Nr); + end; + end if; + end Append_Homonym_Number; + ----------------------- -- Bounds_Match_Size -- ----------------------- *************** package body Exp_Dbug is *** 827,841 **** Name_Buffer (Name_Len + 1) := ASCII.NUL; end Get_Encoded_Name; - ------------------- - -- Get_Entity_Id -- - ------------------- - - function Get_Entity_Id (External_Name : String) return Entity_Id is - begin - return Empty; - end Get_Entity_Id; - ----------------------- -- Get_External_Name -- ----------------------- --- 900,905 ---- *************** package body Exp_Dbug is *** 867,875 **** then Get_Qualified_Name_And_Append (Scope (Entity)); Add_Str_To_Name_Buffer ("__"); end if; - Get_Name_String_And_Append (Chars (Entity)); end Get_Qualified_Name_And_Append; -- Start of processing for Get_External_Name --- 931,943 ---- then Get_Qualified_Name_And_Append (Scope (Entity)); Add_Str_To_Name_Buffer ("__"); + Get_Name_String_And_Append (Chars (Entity)); + Append_Homonym_Number (Entity); + + else + Get_Name_String_And_Append (Chars (Entity)); end if; end Get_Qualified_Name_And_Append; -- Start of processing for Get_External_Name *************** package body Exp_Dbug is *** 934,965 **** end if; Get_Qualified_Name_And_Append (E); - - if Has_Homonym (E) then - declare - H : Entity_Id := Homonym (E); - Nr : Nat := 1; - - begin - while Present (H) loop - if (Scope (H) = Scope (E)) then - Nr := Nr + 1; - end if; - - H := Homonym (H); - end loop; - - if Nr > 1 then - if No_Dollar_In_Label then - Add_Str_To_Name_Buffer ("__"); - else - Add_Char_To_Name_Buffer ('$'); - end if; - - Add_Nat_To_Name_Buffer (Nr); - end if; - end; - end if; end if; Name_Buffer (Name_Len + 1) := ASCII.Nul; --- 1002,1007 ---- *************** package body Exp_Dbug is *** 1103,1108 **** --- 1145,1190 ---- return Name_Find; end Make_Packed_Array_Type_Name; + ----------------------------------- + -- Output_Homonym_Numbers_Suffix -- + ----------------------------------- + + procedure Output_Homonym_Numbers_Suffix is + J : Natural; + + begin + if Homonym_Len > 0 then + + -- Check for all 1's, in which case we do not output + + J := 1; + loop + exit when Homonym_Numbers (J) /= '1'; + + -- If we reached end of string we do not output + + if J = Homonym_Len then + Homonym_Len := 0; + return; + end if; + + exit when Homonym_Numbers (J + 1) /= '_'; + J := J + 2; + end loop; + + -- If we exit the loop then suffix must be output + + if No_Dollar_In_Label then + Add_Str_To_Name_Buffer ("__"); + else + Add_Char_To_Name_Buffer ('$'); + end if; + + Add_Str_To_Name_Buffer (Homonym_Numbers (1 .. Homonym_Len)); + Homonym_Len := 0; + end if; + end Output_Homonym_Numbers_Suffix; + ------------------------------ -- Prepend_String_To_Buffer -- ------------------------------ *************** package body Exp_Dbug is *** 1240,1251 **** Discard : Boolean := False; begin -- If this we are qualifying entities local to a generic -- instance, use the name of the original instantiation, -- not that of the anonymous subprogram in the wrapper -- package, so that gdb doesn't have to know about these. ! if Is_Generic_Instance (E) and then Is_Subprogram (E) and then not Comes_From_Source (E) and then not Is_Compilation_Unit (Scope (E)) --- 1322,1338 ---- Discard : Boolean := False; begin + -- Ignore empty entry (can happen in error cases) + + if No (E) then + return; + -- If this we are qualifying entities local to a generic -- instance, use the name of the original instantiation, -- not that of the anonymous subprogram in the wrapper -- package, so that gdb doesn't have to know about these. ! elsif Is_Generic_Instance (E) and then Is_Subprogram (E) and then not Comes_From_Source (E) and then not Is_Compilation_Unit (Scope (E)) *************** package body Exp_Dbug is *** 1258,1264 **** if Has_Fully_Qualified_Name (E) then Get_Name_String (Chars (E)); ! Strip_BNPE_Suffix (Discard); Full_Qualify_Name (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); Full_Qualify_Len := Name_Len; Set_Has_Fully_Qualified_Name (Ent); --- 1345,1351 ---- if Has_Fully_Qualified_Name (E) then Get_Name_String (Chars (E)); ! Strip_Suffixes (Discard); Full_Qualify_Name (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); Full_Qualify_Len := Name_Len; Set_Has_Fully_Qualified_Name (Ent); *************** package body Exp_Dbug is *** 1285,1290 **** --- 1372,1378 ---- (Full_Qualify_Len + 1 .. Full_Qualify_Len + Name_Len) := Name_Buffer (1 .. Name_Len); Full_Qualify_Len := Full_Qualify_Len + Name_Len; + Append_Homonym_Number (E); end if; if Is_BNPE (E) then *************** package body Exp_Dbug is *** 1367,1373 **** if Has_Qualified_Name (E) then Get_Name_String_And_Append (Chars (E)); ! Strip_BNPE_Suffix (BNPE_Suffix_Needed); -- If the top level name we are adding is itself fully -- qualified, then that means that the name that we are --- 1455,1461 ---- if Has_Qualified_Name (E) then Get_Name_String_And_Append (Chars (E)); ! Strip_Suffixes (BNPE_Suffix_Needed); -- If the top level name we are adding is itself fully -- qualified, then that means that the name that we are *************** package body Exp_Dbug is *** 1395,1400 **** --- 1483,1490 ---- if Is_BNPE (E) then BNPE_Suffix_Needed := True; end if; + + Append_Homonym_Number (E); end if; end Set_Entity_Name; *************** package body Exp_Dbug is *** 1409,1414 **** --- 1499,1505 ---- elsif Ekind (Ent) = E_Enumeration_Literal and then Present (Debug_Renaming_Link (Ent)) then + Name_Len := 0; Set_Entity_Name (Debug_Renaming_Link (Ent)); Get_Name_String (Chars (Ent)); Prepend_String_To_Buffer *************** package body Exp_Dbug is *** 1436,1441 **** --- 1527,1534 ---- -- Fall through with a fully qualified name in Name_Buffer/Name_Len + Output_Homonym_Numbers_Suffix; + -- Add body-nested package suffix if required if BNPE_Suffix_Needed *************** package body Exp_Dbug is *** 1474,1723 **** Name_Qualify_Units.Append (N); end Qualify_Entity_Names; - -------------------------------- - -- Save_Unitname_And_Use_List -- - -------------------------------- - - procedure Save_Unitname_And_Use_List - (Main_Unit_Node : Node_Id; - Main_Kind : Node_Kind) - is - INITIAL_NAME_LENGTH : constant := 1024; - - Item : Node_Id; - Pack_Name : Node_Id; - - Unit_Spec : Node_Id := 0; - Unit_Body : Node_Id := 0; - - Main_Name : String_Id; - -- Fully qualified name of Main Unit - - Unit_Name : String_Id; - -- Name of unit specified in a Use clause - - Spec_Unit_Index : Source_File_Index; - Spec_File_Name : File_Name_Type := No_File; - - Body_Unit_Index : Source_File_Index; - Body_File_Name : File_Name_Type := No_File; - - type String_Ptr is access all String; - - Spec_File_Name_Str : String_Ptr; - Body_File_Name_Str : String_Ptr; - - type Label is record - Label_Name : String_Ptr; - Name_Length : Integer; - Pos : Integer; - end record; - - Spec_Label : Label; - Body_Label : Label; - - procedure Initialize (L : out Label); - -- Initialize label - - procedure Append (L : in out Label; Ch : Character); - -- Append character to label - - procedure Append (L : in out Label; Str : String); - -- Append string to label - - procedure Append_Name (L : in out Label; Unit_Name : String_Id); - -- Append name to label - - function Sufficient_Space - (L : Label; - Unit_Name : String_Id) - return Boolean; - -- Does sufficient space exist to append another name? - - procedure Append (L : in out Label; Str : String) is - begin - L.Label_Name (L.Pos + 1 .. L.Pos + Str'Length) := Str; - L.Pos := L.Pos + Str'Length; - end Append; - - procedure Append (L : in out Label; Ch : Character) is - begin - L.Pos := L.Pos + 1; - L.Label_Name (L.Pos) := Ch; - end Append; - - procedure Append_Name (L : in out Label; Unit_Name : String_Id) is - Char : Char_Code; - Upper_Offset : constant := Character'Pos ('a') - Character'Pos ('A'); - - begin - for J in 1 .. String_Length (Unit_Name) loop - Char := Get_String_Char (Unit_Name, J); - - if Character'Val (Char) = '.' then - Append (L, "__"); - elsif Character'Val (Char) in 'A' .. 'Z' then - Append (L, Character'Val (Char + Upper_Offset)); - elsif Char /= 0 then - Append (L, Character'Val (Char)); - end if; - end loop; - end Append_Name; - - procedure Initialize (L : out Label) is - begin - L.Name_Length := INITIAL_NAME_LENGTH; - L.Pos := 0; - L.Label_Name := new String (1 .. L.Name_Length); - end Initialize; - - function Sufficient_Space - (L : Label; - Unit_Name : String_Id) - return Boolean - is - Len : Integer := Integer (String_Length (Unit_Name)) + 1; - - begin - for J in 1 .. String_Length (Unit_Name) loop - if Character'Val (Get_String_Char (Unit_Name, J)) = '.' then - Len := Len + 1; - end if; - end loop; - - return L.Pos + Len < L.Name_Length; - end Sufficient_Space; - - -- Start of processing for Save_Unitname_And_Use_List - - begin - Initialize (Spec_Label); - Initialize (Body_Label); - - case Main_Kind is - when N_Package_Declaration => - Main_Name := Full_Qualified_Name - (Defining_Unit_Name (Specification (Unit (Main_Unit_Node)))); - Unit_Spec := Main_Unit_Node; - Append (Spec_Label, "_LPS__"); - Append (Body_Label, "_LPB__"); - - when N_Package_Body => - Unit_Spec := Corresponding_Spec (Unit (Main_Unit_Node)); - Unit_Body := Main_Unit_Node; - Main_Name := Full_Qualified_Name (Unit_Spec); - Append (Spec_Label, "_LPS__"); - Append (Body_Label, "_LPB__"); - - when N_Subprogram_Body => - Unit_Body := Main_Unit_Node; - - if Present (Corresponding_Spec (Unit (Main_Unit_Node))) then - Unit_Spec := Corresponding_Spec (Unit (Main_Unit_Node)); - Main_Name := Full_Qualified_Name - (Corresponding_Spec (Unit (Main_Unit_Node))); - else - Main_Name := Full_Qualified_Name - (Defining_Unit_Name (Specification (Unit (Main_Unit_Node)))); - end if; - - Append (Spec_Label, "_LSS__"); - Append (Body_Label, "_LSB__"); - - when others => - return; - end case; - - Append_Name (Spec_Label, Main_Name); - Append_Name (Body_Label, Main_Name); - - -- If we have a body, process it first - - if Present (Unit_Body) then - - Item := First (Context_Items (Unit_Body)); - - while Present (Item) loop - if Nkind (Item) = N_Use_Package_Clause then - Pack_Name := First (Names (Item)); - while Present (Pack_Name) loop - Unit_Name := Full_Qualified_Name (Entity (Pack_Name)); - - if Sufficient_Space (Body_Label, Unit_Name) then - Append (Body_Label, '$'); - Append_Name (Body_Label, Unit_Name); - end if; - - Pack_Name := Next (Pack_Name); - end loop; - end if; - - Item := Next (Item); - end loop; - end if; - - while Present (Unit_Spec) and then - Nkind (Unit_Spec) /= N_Compilation_Unit - loop - Unit_Spec := Parent (Unit_Spec); - end loop; - - if Present (Unit_Spec) then - - Item := First (Context_Items (Unit_Spec)); - - while Present (Item) loop - if Nkind (Item) = N_Use_Package_Clause then - Pack_Name := First (Names (Item)); - while Present (Pack_Name) loop - Unit_Name := Full_Qualified_Name (Entity (Pack_Name)); - - if Sufficient_Space (Spec_Label, Unit_Name) then - Append (Spec_Label, '$'); - Append_Name (Spec_Label, Unit_Name); - end if; - - if Sufficient_Space (Body_Label, Unit_Name) then - Append (Body_Label, '$'); - Append_Name (Body_Label, Unit_Name); - end if; - - Pack_Name := Next (Pack_Name); - end loop; - end if; - - Item := Next (Item); - end loop; - end if; - - if Present (Unit_Spec) then - Append (Spec_Label, Character'Val (0)); - Spec_Unit_Index := Source_Index (Get_Cunit_Unit_Number (Unit_Spec)); - Spec_File_Name := Full_File_Name (Spec_Unit_Index); - Get_Name_String (Spec_File_Name); - Spec_File_Name_Str := new String (1 .. Name_Len + 1); - Spec_File_Name_Str (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); - Spec_File_Name_Str (Name_Len + 1) := Character'Val (0); - Spec_Filename := Spec_File_Name_Str (1)'Unrestricted_Access; - Spec_Context_List := - Spec_Label.Label_Name.all (1)'Unrestricted_Access; - end if; - - if Present (Unit_Body) then - Append (Body_Label, Character'Val (0)); - Body_Unit_Index := Source_Index (Get_Cunit_Unit_Number (Unit_Body)); - Body_File_Name := Full_File_Name (Body_Unit_Index); - Get_Name_String (Body_File_Name); - Body_File_Name_Str := new String (1 .. Name_Len + 1); - Body_File_Name_Str (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); - Body_File_Name_Str (Name_Len + 1) := Character'Val (0); - Body_Filename := Body_File_Name_Str (1)'Unrestricted_Access; - Body_Context_List := - Body_Label.Label_Name.all (1)'Unrestricted_Access; - end if; - - end Save_Unitname_And_Use_List; - --------- -- SEq -- --------- --- 1567,1572 ---- *************** package body Exp_Dbug is *** 1737,1757 **** (Hindex'First + Hindex (CDN_Hash (S.all) mod Hindex'Range_Length)); end SHash; ! ----------------------- ! -- Strip_BNPE_Suffix -- ! ----------------------- - procedure Strip_BNPE_Suffix (Suffix_Found : in out Boolean) is begin for J in reverse 2 .. Name_Len loop if Name_Buffer (J) = 'X' then Name_Len := J - 1; ! Suffix_Found := True; exit; end if; exit when Name_Buffer (J) /= 'b' and then Name_Buffer (J) /= 'n'; end loop; ! end Strip_BNPE_Suffix; end Exp_Dbug; --- 1586,1661 ---- (Hindex'First + Hindex (CDN_Hash (S.all) mod Hindex'Range_Length)); end SHash; ! -------------------- ! -- Strip_Suffixes -- ! -------------------- ! ! procedure Strip_Suffixes (BNPE_Suffix_Found : in out Boolean) is ! SL : Natural; begin + -- Search for and strip BNPE suffix + for J in reverse 2 .. Name_Len loop if Name_Buffer (J) = 'X' then Name_Len := J - 1; ! BNPE_Suffix_Found := True; exit; end if; exit when Name_Buffer (J) /= 'b' and then Name_Buffer (J) /= 'n'; end loop; ! ! -- Search for and strip homonym numbers suffix ! ! -- Case of __ used for homonym numbers suffix ! ! if No_Dollar_In_Label then ! for J in reverse 2 .. Name_Len - 2 loop ! if Name_Buffer (J) = '_' ! and then Name_Buffer (J + 1) = '_' ! then ! if Name_Buffer (J + 2) in '0' .. '9' then ! if Homonym_Len > 0 then ! Homonym_Len := Homonym_Len + 1; ! Homonym_Numbers (Homonym_Len) := '-'; ! end if; ! ! SL := Name_Len - (J + 1); ! ! Homonym_Numbers (Homonym_Len + 1 .. Homonym_Len + SL) := ! Name_Buffer (J + 2 .. Name_Len); ! Name_Len := J - 1; ! Homonym_Len := Homonym_Len + SL; ! end if; ! ! exit; ! end if; ! end loop; ! ! -- Case of $ used for homonym numbers suffix ! ! else ! for J in reverse 2 .. Name_Len - 1 loop ! if Name_Buffer (J) = '$' then ! if Name_Buffer (J + 1) in '0' .. '9' then ! if Homonym_Len > 0 then ! Homonym_Len := Homonym_Len + 1; ! Homonym_Numbers (Homonym_Len) := '-'; ! end if; ! ! SL := Name_Len - J; ! ! Homonym_Numbers (Homonym_Len + 1 .. Homonym_Len + SL) := ! Name_Buffer (J + 1 .. Name_Len); ! Name_Len := J - 1; ! Homonym_Len := Homonym_Len + SL; ! end if; ! ! exit; ! end if; ! end loop; ! end if; ! end Strip_Suffixes; end Exp_Dbug; diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_dbug.ads gcc-3.3/gcc/ada/exp_dbug.ads *** gcc-3.2.3/gcc/ada/exp_dbug.ads 2002-05-04 03:27:56.000000000 +0000 --- gcc-3.3/gcc/ada/exp_dbug.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1996-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1996-2002 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- -- *************** *** 30,36 **** -- debugger. In accordance with the Dwarf 2.2 specification, certain -- type names are encoded to provide information to the debugger. - with Sinfo; use Sinfo; with Types; use Types; with Uintp; use Uintp; with Get_Targ; use Get_Targ; --- 29,34 ---- *************** package Exp_Dbug is *** 63,71 **** -- case of nested procedures.) In addition, we also consider all types -- to be global entities, even if they are defined within a procedure. ! -- The reason for full treating all type names as global entities is ! -- that a number of our type encodings work by having related type ! -- names, and we need the full qualification to keep this unique. -- For global entities, the encoded name includes all components of the -- fully expanded name (but omitting Standard at the start). For example, --- 61,69 ---- -- case of nested procedures.) In addition, we also consider all types -- to be global entities, even if they are defined within a procedure. ! -- The reason for treating all type names as global entities is that ! -- a number of our type encodings work by having related type names, ! -- and we need the full qualification to keep this unique. -- For global entities, the encoded name includes all components of the -- fully expanded name (but omitting Standard at the start). For example, *************** package Exp_Dbug is *** 95,104 **** -- The separating dots are translated into double underscores. - -- Note: there is one exception, which is that on IRIX, for workshop - -- back compatibility, dots are retained as dots. In the rest of this - -- document we assume the double underscore encoding. - ----------------------------- -- Handling of Overloading -- ----------------------------- --- 93,98 ---- *************** package Exp_Dbug is *** 107,167 **** -- subprograms, since overloading can legitimately result in a -- case of two entities with exactly the same fully qualified names. -- To distinguish between entries in a set of overloaded subprograms, ! -- the encoded names are serialized by adding one of the two suffixes: -- $n (dollar sign) -- __nn (two underscores) ! -- where nn is a serial number (1 for the first overloaded function, ! -- 2 for the second, etc.). The former suffix is used when a dollar ! -- sign is a valid symbol on the target machine and the latter is ! -- used when it is not. No suffix need appear on the encoding of ! -- the first overloading of a subprogram. -- These names are prefixed by the normal full qualification. So -- for example, the third instance of the subprogram qrs in package ! -- yz would have one of the two names: -- yz__qrs$3 - -- yz__qrs__3 ! -- The serial number always appears at the end as shown, even in the ! -- case of subprograms nested inside overloaded subprograms, and only ! -- when the named subprogram is overloaded. For example, consider ! -- the following situation: -- package body Yz is ! -- procedure Qrs is -- Encoded name is yz__qrs ! -- procedure Tuv is ... end; -- Encoded name is yz__qrs__tuv -- begin ... end Qrs; ! -- procedure Qrs (X: Integer) is -- Encoded name is yz__qrs__2 ! -- procedure Tuv is ... end; -- Encoded name is yz__qrs__tuv ! -- -- (not yz__qrs__2__tuv). ! -- procedure Tuv (X: INTEGER) -- Encoded name is yz__qrs__tuv__2 -- begin ... end Tuv; ! -- procedure Tuv (X: INTEGER) -- Encoded name is yz__qrs__tuv__3 -- begin ... end Tuv; -- begin ... end Qrs; -- end Yz; - -- This example also serves to illustrate, a case in which the - -- debugging data are currently ambiguous. The two parameterless - -- versions of Yz.Qrs.Tuv have the same encoded names in the - -- debugging data. However, the actual external symbols (which - -- linkers use to resolve references) will be modified with an - -- an additional suffix so that they do not clash. Thus, there will - -- be cases in which the name of a function shown in the debugging - -- data differs from that function's "official" external name, and - -- in which several different functions have exactly the same name - -- as far as the debugger is concerned. We don't consider this too - -- much of a problem, since the only way the user has of referring - -- to these functions by name is, in fact, Yz.Qrs.Tuv, so that the - -- reference is inherently ambiguous from the user's perspective, - -- regardless of internal encodings (in these cases, the debugger - -- can provide a menu of options to allow the user to disambiguate). - -------------------- -- Operator Names -- -------------------- --- 101,159 ---- -- subprograms, since overloading can legitimately result in a -- case of two entities with exactly the same fully qualified names. -- To distinguish between entries in a set of overloaded subprograms, ! -- the encoded names are serialized by adding one of the suffixes: -- $n (dollar sign) -- __nn (two underscores) ! -- where nn is a serial number (2 for the second overloaded function, ! -- 2 for the third, etc.). We use $ if this symbol is allowed, and ! -- double underscore if it is not. In the remaining examples in this ! -- section, we use a $ sign, but the $ is replaced by __ throughout ! -- these examples if $ sign is not available. A suffix of $1 is ! -- always omitted (i.e. no suffix implies the first instance). -- These names are prefixed by the normal full qualification. So -- for example, the third instance of the subprogram qrs in package ! -- yz would have the name: -- yz__qrs$3 ! -- A more subtle case arises with entities declared within overloaded ! -- subprograms. If we have two overloaded subprograms, and both declare ! -- an entity xyz, then the fully expanded name of the two xyz's is the ! -- same. To distinguish these, we add the same __n suffix at the end of ! -- the inner entity names. ! ! -- In more complex cases, we can have multiple levels of overloading, ! -- and we must make sure to distinguish which final declarative region ! -- we are talking about. For this purpose, we use a more complex suffix ! -- which has the form: ! ! -- $nn_nn_nn ... ! ! -- where the nn values are the homonym numbers as needed for any of ! -- the qualifying entities, separated by a single underscore. If all ! -- the nn values are 1, the suffix is omitted, Otherwise the suffix ! -- is present (including any values of 1). The following example ! -- shows how this suffixing works. -- package body Yz is ! -- procedure Qrs is -- Name is yz__qrs ! -- procedure Tuv is ... end; -- Name is yz__qrs__tuv -- begin ... end Qrs; ! -- procedure Qrs (X: Int) is -- Name is yz__qrs$2 ! -- procedure Tuv is ... end; -- Name is yz__qrs__tuv$2_1 ! -- procedure Tuv (X: Int) is -- Name is yz__qrs__tuv$2_2 -- begin ... end Tuv; ! -- procedure Tuv (X: Float) is -- Name is yz__qrs__tuv$2_3 ! -- type m is new float; -- Name is yz__qrs__tuv__m$2_3 -- begin ... end Tuv; -- begin ... end Qrs; -- end Yz; -------------------- -- Operator Names -- -------------------- *************** package Exp_Dbug is *** 217,223 **** -- interpretation 1: entity c in child package a.b -- interpretation 2: entity c in nested package b in body of a ! -- It is perfectly valid in both cases for both interpretations to -- be valid within a single program. This is a bit of a surprise since -- certainly in Ada 83, full qualification was sufficient, but not in -- Ada 95. The result is that the above scheme can result in duplicate --- 209,215 ---- -- interpretation 1: entity c in child package a.b -- interpretation 2: entity c in nested package b in body of a ! -- It is perfectly legal in both cases for both interpretations to -- be valid within a single program. This is a bit of a surprise since -- certainly in Ada 83, full qualification was sufficient, but not in -- Ada 95. The result is that the above scheme can result in duplicate *************** package Exp_Dbug is *** 367,376 **** -- from outside of the object, and a non-locking one that is used for -- calls from other operations on the same object. The locking operation -- simply acquires the lock, and then calls the non-locking version. ! -- The names of all of these have a prefix constructed from the name ! -- of the name of the type, the string "PT", and a suffix which is P ! -- or N, depending on whether this is the protected or non-locking ! -- version of the operation. -- Given the declaration: --- 359,367 ---- -- from outside of the object, and a non-locking one that is used for -- calls from other operations on the same object. The locking operation -- simply acquires the lock, and then calls the non-locking version. ! -- The names of all of these have a prefix constructed from the name of ! -- the type, the string "PT", and a suffix which is P or N, depending on ! -- whether this is the protected/non-locking version of the operation. -- Given the declaration: *************** package Exp_Dbug is *** 410,416 **** -- or "X_" if the next entity is a subunit) -- - the name of the entity -- - the string "$" (or "__" if target does not allow "$"), followed ! -- by homonym number, if the entity is an overloaded subprogram procedure Get_External_Name_With_Suffix (Entity : Entity_Id; --- 401,408 ---- -- or "X_" if the next entity is a subunit) -- - the name of the entity -- - the string "$" (or "__" if target does not allow "$"), followed ! -- by homonym suffix, if the entity is an overloaded subprogram ! -- or is defined within an overloaded subprogram. procedure Get_External_Name_With_Suffix (Entity : Entity_Id; *************** package Exp_Dbug is *** 424,436 **** -- or "X_" if the next entity is a subunit) -- - the name of the entity -- - the string "$" (or "__" if target does not allow "$"), followed ! -- by homonym number, if the entity is an overloaded subprogram -- - the string "___" followed by Suffix - function Get_Entity_Id (External_Name : String) return Entity_Id; - -- Find entity in current compilation unit, which has the given - -- External_Name. - ---------------------------- -- Debug Name Compression -- ---------------------------- --- 416,425 ---- -- or "X_" if the next entity is a subunit) -- - the name of the entity -- - the string "$" (or "__" if target does not allow "$"), followed ! -- by homonym suffix, if the entity is an overloaded subprogram ! -- or is defined within an overloaded subprogram. -- - the string "___" followed by Suffix ---------------------------- -- Debug Name Compression -- ---------------------------- *************** package Exp_Dbug is *** 653,658 **** --- 642,663 ---- -- or static values, with the encoding first for the lower bound, -- then for the upper bound, as previously described. + ------------------- + -- Modular Types -- + ------------------- + + -- A type declared + + -- type x is mod N; + + -- Is encoded as a subrange of an unsigned base type with lower bound + -- 0 and upper bound N. That is, there is no name encoding. We use + -- the standard encodings provided by the debugging format. Thus + -- we give these types a non-standard interpretation: the standard + -- interpretation of our encoding would not, in general, imply that + -- arithmetic on type x was to be performed modulo N (especially not + -- when N is not a power of 2). + ------------------ -- Biased Types -- ------------------ *************** package Exp_Dbug is *** 760,765 **** --- 765,785 ---- -- that contains the variants is replaced by a normal C union. -- In this case, the positions are all zero. + -- Discriminants appear before any variable-length fields that depend + -- on them, with one exception. In some cases, a discriminant + -- governing the choice of a variant clause may appear in the list + -- of fields of an XVE type after the entry for the variant clause + -- itself (this can happen in the presence of a representation clause + -- for the record type in the source program). However, when this + -- happens, the discriminant's position may be determined by first + -- applying the rules described in this section, ignoring the variant + -- clause. As a result, discriminants can always be located + -- independently of the variable-length fields that depend on them. + + -- The size of the ___XVE or ___XVU record or union is set to the + -- alignment (in bytes) of the original object so that the debugger + -- can calculate the size of the original type. + -- As an example of this encoding, consider the declarations: -- type Q is array (1 .. V1) of Float; -- alignment 4 *************** package Exp_Dbug is *** 805,819 **** -- but this may not be detected in this case by the conversion -- routines. - -- All discriminants always appear before any variable-length - -- fields that depend on them. So they can be located independent - -- of the variable-length field, using the standard procedure for - -- computing positions described above. - - -- The size of the ___XVE or ___XVU record or union is set to the - -- alignment (in bytes) of the original object so that the debugger - -- can calculate the size of the original type. - -- 3) Our conventions do not cover all XVE-encoded records in which -- some, but not all, fields have representation clauses. Such -- records may, therefore, be displayed incorrectly by debuggers. --- 825,830 ---- *************** package Exp_Dbug is *** 1350,1428 **** -- the second enumeration literal would be named QU43 and the -- value assigned to it would be 1. - ------------------- - -- Modular Types -- - ------------------- - - -- A type declared - - -- type x is mod N; - - -- Is encoded as a subrange of an unsigned base type with lower bound - -- 0 and upper bound N. That is, there is no name encoding; we only use - -- the standard encodings provided by the debugging format. Thus, - -- we give these types a non-standard interpretation: the standard - -- interpretation of our encoding would not, in general, imply that - -- arithmetic on type x was to be performed modulo N (especially not - -- when N is not a power of 2). - - --------------------- - -- Context Clauses -- - --------------------- - - -- The SGI Workshop debugger requires a very peculiar and nonstandard - -- symbol name containing $ signs to be generated that records the - -- use clauses that are used in a unit. GDB does not use this name, - -- since it takes a different philsophy of universal use visibility, - -- with manual resolution of any ambiguities. - - -- The routines and data in this section are used to prepare this - -- specialized name, whose exact contents are described below. Gigi - -- will output this encoded name only in the SGI case (indeed, not - -- only is it useless on other targets, but hazardous, given the use - -- of the non-standard character $ rejected by many assemblers.) - - -- "Use" clauses are encoded as follows: - - -- _LSS__ prefix for clauses in a subprogram spec - -- _LSB__ prefix for clauses in a subprogram body - -- _LPS__ prefix for clauses in a package spec - -- _LPB__ prefix for clauses in a package body - - -- Following the prefix is the fully qualified filename, followed by - -- '$' separated names of fully qualified units in the "use" clause. - -- If a unit appears in both the spec and the body "use" clause, it - -- will appear once in the _L[SP]S__ encoding and twice in the _L[SP]B__ - -- encoding. The encoding appears as a global symbol in the object file. - - ------------------------------------------------------------------------ - -- Subprograms and Declarations for Handling Context Clause Encodings -- - ------------------------------------------------------------------------ - - procedure Save_Unitname_And_Use_List - (Main_Unit_Node : Node_Id; - Main_Kind : Node_Kind); - -- Creates a string containing the current compilation unit name - -- and a dollar sign delimited list of packages named in a Use_Package - -- clause for the compilation unit. Needed for the SGI debugger. The - -- procedure is called unconditionally to set the variables declared - -- below, then gigi decides whether or not to use the values. - - -- The following variables are used for communication between the front - -- end and the debugging output routines in Gigi. - - type Char_Ptr is access all Character; - pragma Convention (C, Char_Ptr); - -- Character pointers accessed from C - - Spec_Context_List, Body_Context_List : Char_Ptr; - -- List of use package clauses for spec and body, respectively, as - -- built by the call to Save_Unitname_And_Use_List. Used by gigi if - -- these strings are to be output. - - Spec_Filename, Body_Filename : Char_Ptr; - -- Filenames for the spec and body, respectively, as built by the - -- call to Save_Unitname_And_Use_List. Used by gigi if these strings - -- are to be output. - end Exp_Dbug; --- 1361,1364 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_disp.adb gcc-3.3/gcc/ada/exp_disp.adb *** gcc-3.2.3/gcc/ada/exp_disp.adb 2002-05-04 03:27:56.000000000 +0000 --- gcc-3.3/gcc/ada/exp_disp.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_disp.ads gcc-3.3/gcc/ada/exp_disp.ads *** gcc-3.2.3/gcc/ada/exp_disp.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_disp.ads 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1998 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package Exp_Disp is *** 54,60 **** TSD_Entry_Size, TSD_Prologue_Size); - function Fill_DT_Entry (Loc : Source_Ptr; Prim : Entity_Id) --- 53,58 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_dist.adb gcc-3.3/gcc/ada/exp_dist.adb *** gcc-3.2.3/gcc/ada/exp_dist.adb 2002-05-04 03:27:57.000000000 +0000 --- gcc-3.3/gcc/ada/exp_dist.adb 2002-10-23 07:33:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Exp_Dist is *** 58,64 **** -- form: -- type Stub is tagged record -- [...declaration similar to s-parint.ads RACW_Stub_Type...] ! -- end Stub; -- is built. This type has two properties: -- -- 1) Since it has the same structure than RACW_Stub_Type, it can be --- 57,63 ---- -- form: -- type Stub is tagged record -- [...declaration similar to s-parint.ads RACW_Stub_Type...] ! -- end record; -- is built. This type has two properties: -- -- 1) Since it has the same structure than RACW_Stub_Type, it can be *************** package body Exp_Dist is *** 2635,2641 **** Append_To (Decls, Make_Raise_Constraint_Error (Loc, Condition => ! Make_Op_Not (Loc, Right_Opnd => Condition))); end Insert_Partition_Check; -- Start of processing for Build_Subprogram_Calling_Stubs --- 2634,2641 ---- Append_To (Decls, Make_Raise_Constraint_Error (Loc, Condition => ! Make_Op_Not (Loc, Right_Opnd => Condition), ! Reason => CE_Partition_Check_Failed)); end Insert_Partition_Check; -- Start of processing for Build_Subprogram_Calling_Stubs diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_dist.ads gcc-3.3/gcc/ada/exp_dist.ads *** gcc-3.2.3/gcc/ada/exp_dist.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_dist.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/expect.c gcc-3.3/gcc/ada/expect.c *** gcc-3.2.3/gcc/ada/expect.c 2001-10-02 14:08:33.000000000 +0000 --- gcc-3.3/gcc/ada/expect.c 2002-03-14 10:59:16.000000000 +0000 *************** *** 6,14 **** * * * C Implementation File * * * - * $Revision: 1.1 $ * * ! * Copyright (C) 2001 Ada Core Technologies, 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- * --- 6,13 ---- * * * C Implementation File * * * * * ! * Copyright (C) 2001-2002 Ada Core Technologies, 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- * *************** __gnat_expect_fork () *** 74,84 **** } void ! __gnat_expect_portable_execvp (cmd, argv) char *cmd; char *argv[]; { ! (void) spawnve (_P_NOWAIT, cmd, argv, NULL); } int --- 73,84 ---- } void ! __gnat_expect_portable_execvp (pid, cmd, argv) ! int *pid; char *cmd; char *argv[]; { ! *pid = (int) spawnve (_P_NOWAIT, cmd, argv, NULL); } int *************** __gnat_expect_poll (fd, num_fd, timeout, *** 108,122 **** is_set[i] = 0; for (i = 0; i < num_fd; i++) ! handles[i] = (HANDLE) _get_osfhandle (fd [i]); ! num = timeout / 10; while (1) { for (i = 0; i < num_fd; i++) { ! if (!PeekNamedPipe (handles [i], NULL, 0, NULL, &avail, NULL)) return -1; if (avail > 0) --- 108,122 ---- is_set[i] = 0; for (i = 0; i < num_fd; i++) ! handles[i] = (HANDLE) _get_osfhandle (fd[i]); ! num = timeout / 50; while (1) { for (i = 0; i < num_fd; i++) { ! if (!PeekNamedPipe (handles[i], NULL, 0, NULL, &avail, NULL)) return -1; if (avail > 0) *************** __gnat_expect_poll (fd, num_fd, timeout, *** 129,139 **** if (timeout >= 0 && num == 0) return 0; ! Sleep (10); num--; } } #elif defined (unix) #include --- 129,258 ---- if (timeout >= 0 && num == 0) return 0; ! Sleep (50); num--; } } + #elif defined (VMS) + #include + #include + #include + #include + #include + #include + #include + #include + #include + + int + __gnat_pipe (fd) + int *fd; + { + return pipe (fd); + } + + int + __gnat_expect_fork () + { + return -1; + } + + void + __gnat_expect_portable_execvp (pid, cmd, argv) + int *pid; + char *cmd; + char *argv[]; + { + *pid = (int) getpid(); + /* Since cmd is fully qualified, it is incorrect to to call execvp */ + execv (cmd, argv); + } + + int + __gnat_expect_poll (fd, num_fd, timeout, is_set) + int *fd; + int num_fd; + int timeout; + int *is_set; + { + int i, num, ready = 0; + unsigned int status; + int mbxchans [num_fd]; + struct dsc$descriptor_s mbxname; + struct io_status_block { + short int condition; + short int count; + int dev; + } iosb; + char buf [256]; + + for (i = 0; i < num_fd; i++) + is_set[i] = 0; + + for (i = 0; i < num_fd; i++) + { + + /* Get name of the mailbox used in the pipe */ + getname (fd [i], buf); + + /* Assign a channel to the mailbox */ + if (strlen (buf) > 0) + { + mbxname.dsc$w_length = strlen (buf); + mbxname.dsc$b_dtype = DSC$K_DTYPE_T; + mbxname.dsc$b_class = DSC$K_CLASS_S; + mbxname.dsc$a_pointer = buf; + + status = SYS$ASSIGN (&mbxname, &mbxchans[i], 0, 0, 0); + } + } + + num = timeout / 100; + + while (1) + { + for (i = 0; i < num_fd; i++) + { + if (mbxchans[i] > 0) + { + + /* Peek in the mailbox to see if there's data */ + status = SYS$QIOW + (0, mbxchans[i], IO$_SENSEMODE|IO$M_READERCHECK, + &iosb, 0, 0, 0, 0, 0, 0, 0, 0); + + if (iosb.count > 0) + { + is_set[i] = 1; + ready = 1; + goto deassign; + } + } + } + + if (timeout >= 0 && num == 0) + { + ready = 0; + goto deassign; + } + + usleep (100000); + num--; + } + + deassign: + + /* Deassign channels assigned above */ + for (i = 0; i < num_fd; i++) + { + if (mbxchans[i] > 0) + status = SYS$DASSGN (mbxchans[i]); + } + + return ready; + } + #elif defined (unix) #include *************** __gnat_expect_fork () *** 165,174 **** } void ! __gnat_expect_portable_execvp (cmd, argv) char *cmd; char *argv[]; { execvp (cmd, argv); } --- 284,295 ---- } void ! __gnat_expect_portable_execvp (pid, cmd, argv) ! int *pid; char *cmd; char *argv[]; { + *pid = (int) getpid(); execvp (cmd, argv); } *************** __gnat_expect_poll (fd, num_fd, timeout, *** 189,197 **** for (i = 0; i < num_fd; i++) { ! FD_SET (fd [i], &rset); ! if (fd [i] > max_fd) ! max_fd = fd [i]; } tv.tv_sec = timeout / 1000; --- 310,318 ---- for (i = 0; i < num_fd; i++) { ! FD_SET (fd[i], &rset); ! if (fd[i] > max_fd) ! max_fd = fd[i]; } tv.tv_sec = timeout / 1000; *************** __gnat_expect_poll (fd, num_fd, timeout, *** 201,207 **** if (ready > 0) for (i = 0; i < num_fd; i++) ! is_set [i] = (FD_ISSET (fd [i], &rset) ? 1 : 0); return ready; } --- 322,328 ---- if (ready > 0) for (i = 0; i < num_fd; i++) ! is_set[i] = (FD_ISSET (fd[i], &rset) ? 1 : 0); return ready; } *************** __gnat_expect_fork () *** 222,231 **** } void ! __gnat_expect_portable_execvp (cmd, argv) char *cmd; char *argv[]; { } int --- 343,354 ---- } void ! __gnat_expect_portable_execvp (pid, cmd, argv) ! int *pid; char *cmd; char *argv[]; { + *pid = 0; } int diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_fixd.adb gcc-3.3/gcc/ada/exp_fixd.adb *** gcc-3.2.3/gcc/ada/exp_fixd.adb 2002-05-04 03:27:58.000000000 +0000 --- gcc-3.3/gcc/ada/exp_fixd.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Exp_Fixd is *** 1960,1965 **** --- 1959,1971 ---- Right : constant Node_Id := Right_Opnd (N); begin + -- Suppress expansion of a fixed-by-fixed division if the + -- operation is supported directly by the target. + + if Target_Has_Fixed_Ops (Etype (Left), Etype (Right), Etype (N)) then + return; + end if; + if Etype (Left) = Universal_Real then Do_Divide_Universal_Fixed (N); *************** package body Exp_Fixd is *** 2100,2105 **** --- 2106,2118 ---- end Rewrite_Non_Static_Universal; begin + -- Suppress expansion of a fixed-by-fixed multiplication if the + -- operation is supported directly by the target. + + if Target_Has_Fixed_Ops (Etype (Left), Etype (Right), Etype (N)) then + return; + end if; + if Etype (Left) = Universal_Real then if Nkind (Left) = N_Real_Literal then Do_Multiply_Fixed_Universal (N, Right, Left); diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_fixd.ads gcc-3.3/gcc/ada/exp_fixd.ads *** gcc-3.2.3/gcc/ada/exp_fixd.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_fixd.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_imgv.adb gcc-3.3/gcc/ada/exp_imgv.adb *** gcc-3.2.3/gcc/ada/exp_imgv.adb 2002-05-04 03:27:59.000000000 +0000 --- gcc-3.3/gcc/ada/exp_imgv.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_imgv.ads gcc-3.3/gcc/ada/exp_imgv.ads *** gcc-3.2.3/gcc/ada/exp_imgv.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_imgv.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_intr.adb gcc-3.3/gcc/ada/exp_intr.adb *** gcc-3.2.3/gcc/ada/exp_intr.adb 2002-05-04 03:27:59.000000000 +0000 --- gcc-3.3/gcc/ada/exp_intr.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Exp_Intr is *** 82,92 **** -- Expand a call to an instantiation of Unchecked_Convertion into a node -- N_Unchecked_Type_Conversion. ! procedure Expand_Unc_Deallocation (N : Node_Id; E : Entity_Id); -- Expand a call to an instantiation of Unchecked_Deallocation into a node -- N_Free_Statement and appropriate context. ! procedure Expand_Source_Info (N : Node_Id; E : Entity_Id; Nam : Name_Id); -- Rewrite the node by the appropriate string or positive constant. -- Nam can be one of the following: -- Name_File - expand string that is the name of source file --- 81,91 ---- -- Expand a call to an instantiation of Unchecked_Convertion into a node -- N_Unchecked_Type_Conversion. ! procedure Expand_Unc_Deallocation (N : Node_Id); -- Expand a call to an instantiation of Unchecked_Deallocation into a node -- N_Free_Statement and appropriate context. ! procedure Expand_Source_Info (N : Node_Id; Nam : Name_Id); -- Rewrite the node by the appropriate string or positive constant. -- Nam can be one of the following: -- Name_File - expand string that is the name of source file *************** package body Exp_Intr is *** 267,280 **** Expand_Unc_Conversion (N, E); elsif Nam = Name_Unchecked_Deallocation then ! Expand_Unc_Deallocation (N, E); elsif Nam = Name_File or else Nam = Name_Line or else Nam = Name_Source_Location or else Nam = Name_Enclosing_Entity then ! Expand_Source_Info (N, E, Nam); else -- Only other possibility is a renaming, in which case we expand --- 266,279 ---- Expand_Unc_Conversion (N, E); elsif Nam = Name_Unchecked_Deallocation then ! Expand_Unc_Deallocation (N); elsif Nam = Name_File or else Nam = Name_Line or else Nam = Name_Source_Location or else Nam = Name_Enclosing_Entity then ! Expand_Source_Info (N, Nam); else -- Only other possibility is a renaming, in which case we expand *************** package body Exp_Intr is *** 389,395 **** -- Expand_Source_Info -- ------------------------ ! procedure Expand_Source_Info (N : Node_Id; E : Entity_Id; Nam : Name_Id) is Loc : constant Source_Ptr := Sloc (N); Ent : Entity_Id; --- 388,394 ---- -- Expand_Source_Info -- ------------------------ ! procedure Expand_Source_Info (N : Node_Id; Nam : Name_Id) is Loc : constant Source_Ptr := Sloc (N); Ent : Entity_Id; *************** package body Exp_Intr is *** 515,521 **** -- task itself is freed if it is terminated, ditto for a simple protected -- object, with a call to Finalize_Protection ! procedure Expand_Unc_Deallocation (N : Node_Id; E : Entity_Id) is Loc : constant Source_Ptr := Sloc (N); Arg : constant Node_Id := First_Actual (N); Typ : constant Entity_Id := Etype (Arg); --- 514,520 ---- -- task itself is freed if it is terminated, ditto for a simple protected -- object, with a call to Finalize_Protection ! procedure Expand_Unc_Deallocation (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Arg : constant Node_Id := First_Actual (N); Typ : constant Entity_Id := Etype (Arg); diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_intr.ads gcc-3.3/gcc/ada/exp_intr.ads *** gcc-3.2.3/gcc/ada/exp_intr.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_intr.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_pakd.adb gcc-3.3/gcc/ada/exp_pakd.adb *** gcc-3.2.3/gcc/ada/exp_pakd.adb 2002-05-04 03:27:59.000000000 +0000 --- gcc-3.3/gcc/ada/exp_pakd.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Exp_Pakd is *** 591,597 **** Right_Opnd => Convert_To (Standard_Integer, Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_First))); -- For larger integer types, subtract first, then convert to --- 590,596 ---- Right_Opnd => Convert_To (Standard_Integer, Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_First))); -- For larger integer types, subtract first, then convert to *************** package body Exp_Pakd is *** 606,612 **** Left_Opnd => Newsub, Right_Opnd => Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_First))); end if; --- 605,611 ---- Left_Opnd => Newsub, Right_Opnd => Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_First))); end if; *************** package body Exp_Pakd is *** 625,642 **** Make_Op_Subtract (Loc, Left_Opnd => Convert_To (Standard_Integer, Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_Pos, ! Expressions => New_List (Newsub))), Right_Opnd => Convert_To (Standard_Integer, Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_Pos, ! Expressions => New_List ( Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_First))))); end if; --- 624,641 ---- Make_Op_Subtract (Loc, Left_Opnd => Convert_To (Standard_Integer, Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_Pos, ! Expressions => New_List (Newsub))), Right_Opnd => Convert_To (Standard_Integer, Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_Pos, ! Expressions => New_List ( Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Styp, Loc), Attribute_Name => Name_First))))); end if; *************** package body Exp_Pakd is *** 761,767 **** end if; Set_Is_Itype (PAT, True); ! Set_Is_Packed_Array_Type (PAT, True); Analyze (Decl, Suppress => All_Checks); if Pushed_Scope then --- 760,766 ---- end if; Set_Is_Itype (PAT, True); ! Set_Packed_Array_Type (Typ, PAT); Analyze (Decl, Suppress => All_Checks); if Pushed_Scope then *************** package body Exp_Pakd is *** 780,789 **** -- Set remaining fields of packed array type ! Init_Alignment (PAT); ! Set_Parent (PAT, Empty); ! Set_Packed_Array_Type (Typ, PAT); Set_Associated_Node_For_Itype (PAT, Typ); -- We definitely do not want to delay freezing for packed array -- types. This is of particular importance for the itypes that --- 779,789 ---- -- Set remaining fields of packed array type ! Init_Alignment (PAT); ! Set_Parent (PAT, Empty); Set_Associated_Node_For_Itype (PAT, Typ); + Set_Is_Packed_Array_Type (PAT, True); + Set_Original_Array_Type (PAT, Typ); -- We definitely do not want to delay freezing for packed array -- types. This is of particular importance for the itypes that *************** package body Exp_Pakd is *** 801,814 **** procedure Set_PB_Type is begin -- If the user has specified an explicit alignment for the ! -- component, take it into account. if Csize <= 2 or else Csize = 4 or else Csize mod 2 /= 0 or else Component_Alignment (Typ) = Calign_Storage_Unit then PB_Type := RTE (RE_Packed_Bytes1); ! elsif Csize mod 4 /= 0 then PB_Type := RTE (RE_Packed_Bytes2); else --- 801,817 ---- procedure Set_PB_Type is begin -- If the user has specified an explicit alignment for the ! -- type or component, take it into account. if Csize <= 2 or else Csize = 4 or else Csize mod 2 /= 0 + or else Alignment (Typ) = 1 or else Component_Alignment (Typ) = Calign_Storage_Unit then PB_Type := RTE (RE_Packed_Bytes1); ! elsif Csize mod 4 /= 0 ! or else Alignment (Typ) = 2 ! then PB_Type := RTE (RE_Packed_Bytes2); else *************** package body Exp_Pakd is *** 973,989 **** Type_Definition => Typedef); end; Install_PAT; return; ! -- Case of bit-packing required for unconstrained array. We simply ! -- use Packed_Bytes{1,2,4} as appropriate, and we do not need to ! -- construct a special packed array type. elsif not Is_Constrained (Typ) then Set_PB_Type; ! Set_Packed_Array_Type (Typ, PB_Type); ! Set_Is_Packed_Array_Type (Packed_Array_Type (Typ), True); return; -- Remaining code is for the case of bit-packing for constrained array --- 976,1003 ---- Type_Definition => Typedef); end; + -- Set type as packed array type and install it + + Set_Is_Packed_Array_Type (PAT); Install_PAT; return; ! -- Case of bit-packing required for unconstrained array. We create ! -- a subtype that is equivalent to use Packed_Bytes{1,2,4} as needed. elsif not Is_Constrained (Typ) then + PAT := + Make_Defining_Identifier (Loc, + Chars => Make_Packed_Array_Type_Name (Typ, Csize)); + + Set_Packed_Array_Type (Typ, PAT); Set_PB_Type; ! ! Decl := ! Make_Subtype_Declaration (Loc, ! Defining_Identifier => PAT, ! Subtype_Indication => New_Occurrence_Of (PB_Type, Loc)); ! Install_PAT; return; -- Remaining code is for the case of bit-packing for constrained array *************** package body Exp_Pakd is *** 1453,1461 **** Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Set_nn, Loc), Parameter_Associations => New_List ( ! Make_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => Obj), Subscr, Unchecked_Convert_To (Bits_nn, Convert_To (Ctyp, Rhs))))); --- 1467,1475 ---- Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Set_nn, Loc), Parameter_Associations => New_List ( ! Make_Byte_Aligned_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => Obj), Subscr, Unchecked_Convert_To (Bits_nn, Convert_To (Ctyp, Rhs))))); *************** package body Exp_Pakd is *** 1507,1519 **** Left_Opnd => Subscr, Right_Opnd => Make_Attribute_Reference (Ploc, ! Prefix => New_Occurrence_Of (Atyp, Ploc), Attribute_Name => Name_Component_Size)); elsif Nkind (Pref) = N_Selected_Component then Term := Make_Attribute_Reference (Ploc, ! Prefix => Selector_Name (Pref), Attribute_Name => Name_Bit_Position); else --- 1521,1533 ---- Left_Opnd => Subscr, Right_Opnd => Make_Attribute_Reference (Ploc, ! Prefix => New_Occurrence_Of (Atyp, Ploc), Attribute_Name => Name_Component_Size)); elsif Nkind (Pref) = N_Selected_Component then Term := Make_Attribute_Reference (Ploc, ! Prefix => Selector_Name (Pref), Attribute_Name => Name_Bit_Position); else *************** package body Exp_Pakd is *** 1541,1547 **** Left_Opnd => Unchecked_Convert_To (RTE (RE_Integer_Address), Make_Attribute_Reference (Loc, ! Prefix => Pref, Attribute_Name => Name_Address)), Right_Opnd => --- 1555,1561 ---- Left_Opnd => Unchecked_Convert_To (RTE (RE_Integer_Address), Make_Attribute_Reference (Loc, ! Prefix => Pref, Attribute_Name => Name_Address)), Right_Opnd => *************** package body Exp_Pakd is *** 1619,1625 **** Right_Opnd => Convert_To (BT, ! New_Occurrence_Of (Standard_True, Loc)))))); end; end if; --- 1633,1640 ---- Right_Opnd => Convert_To (BT, ! New_Occurrence_Of (Standard_True, Loc)))), ! Reason => CE_Range_Check_Failed)); end; end if; *************** package body Exp_Pakd is *** 1701,1709 **** Name => New_Occurrence_Of (RTE (E_Id), Loc), Parameter_Associations => New_List ( ! Make_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => L), Make_Op_Multiply (Loc, Left_Opnd => --- 1716,1724 ---- Name => New_Occurrence_Of (RTE (E_Id), Loc), Parameter_Associations => New_List ( ! Make_Byte_Aligned_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => L), Make_Op_Multiply (Loc, Left_Opnd => *************** package body Exp_Pakd is *** 1715,1723 **** Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Ltyp))), ! Make_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => R), Make_Op_Multiply (Loc, Left_Opnd => --- 1730,1738 ---- Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Ltyp))), ! Make_Byte_Aligned_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => R), Make_Op_Multiply (Loc, Left_Opnd => *************** package body Exp_Pakd is *** 1729,1735 **** Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Rtyp))), ! Make_Attribute_Reference (Loc, Attribute_Name => Name_Address, Prefix => New_Occurrence_Of (Result_Ent, Loc)))))); --- 1744,1750 ---- Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Rtyp))), ! Make_Byte_Aligned_Attribute_Reference (Loc, Attribute_Name => Name_Address, Prefix => New_Occurrence_Of (Result_Ent, Loc)))))); *************** package body Exp_Pakd is *** 1841,1849 **** Make_Function_Call (Loc, Name => New_Occurrence_Of (Get_nn, Loc), Parameter_Associations => New_List ( ! Make_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => Obj), Subscr)))); end; end if; --- 1856,1864 ---- Make_Function_Call (Loc, Name => New_Occurrence_Of (Get_nn, Loc), Parameter_Associations => New_List ( ! Make_Byte_Aligned_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => Obj), Subscr)))); end; end if; *************** package body Exp_Pakd is *** 1885,1891 **** Left_Opnd => Make_Attribute_Reference (Loc, Attribute_Name => Name_Length, ! Prefix => New_Occurrence_Of (Ltyp, Loc)), Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Ltyp))); --- 1900,1906 ---- Left_Opnd => Make_Attribute_Reference (Loc, Attribute_Name => Name_Length, ! Prefix => New_Occurrence_Of (Ltyp, Loc)), Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Ltyp))); *************** package body Exp_Pakd is *** 1894,1900 **** Left_Opnd => Make_Attribute_Reference (Loc, Attribute_Name => Name_Length, ! Prefix => New_Occurrence_Of (Rtyp, Loc)), Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Rtyp))); --- 1909,1915 ---- Left_Opnd => Make_Attribute_Reference (Loc, Attribute_Name => Name_Length, ! Prefix => New_Occurrence_Of (Rtyp, Loc)), Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Rtyp))); *************** package body Exp_Pakd is *** 1934,1948 **** Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Bit_Eq), Loc), Parameter_Associations => New_List ( ! Make_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => L), LLexpr, ! Make_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => R), RLexpr))); end if; --- 1949,1963 ---- Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Bit_Eq), Loc), Parameter_Associations => New_List ( ! Make_Byte_Aligned_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => L), LLexpr, ! Make_Byte_Aligned_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => R), RLexpr))); end if; *************** package body Exp_Pakd is *** 1995,2001 **** Right_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (CT, Loc), ! Attribute_Name => Name_Last)))); end; -- Now that that silliness is taken care of, get packed array type --- 2010,2017 ---- Right_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (CT, Loc), ! Attribute_Name => Name_Last)), ! Reason => CE_Range_Check_Failed)); end; -- Now that that silliness is taken care of, get packed array type *************** package body Exp_Pakd is *** 2052,2060 **** Name => New_Occurrence_Of (RTE (RE_Bit_Not), Loc), Parameter_Associations => New_List ( ! Make_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => Opnd), Make_Op_Multiply (Loc, Left_Opnd => --- 2068,2076 ---- Name => New_Occurrence_Of (RTE (RE_Bit_Not), Loc), Parameter_Associations => New_List ( ! Make_Byte_Aligned_Attribute_Reference (Loc, Attribute_Name => Name_Address, ! Prefix => Opnd), Make_Op_Multiply (Loc, Left_Opnd => *************** package body Exp_Pakd is *** 2066,2072 **** Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Rtyp))), ! Make_Attribute_Reference (Loc, Attribute_Name => Name_Address, Prefix => New_Occurrence_Of (Result_Ent, Loc)))))); --- 2082,2088 ---- Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Rtyp))), ! Make_Byte_Aligned_Attribute_Reference (Loc, Attribute_Name => Name_Address, Prefix => New_Occurrence_Of (Result_Ent, Loc)))))); *************** package body Exp_Pakd is *** 2146,2158 **** -- If we have a specified alignment, see if it is sufficient, if not -- then we can't possibly be aligned enough in any case. ! elsif Is_Entity_Name (Obj) ! and then Known_Alignment (Entity (Obj)) ! then -- Alignment required is 4 if size is a multiple of 4, and -- 2 otherwise (e.g. 12 bits requires 4, 10 bits requires 2) ! if Alignment (Entity (Obj)) < 4 - (Csiz mod 4) then return False; end if; end if; --- 2162,2172 ---- -- If we have a specified alignment, see if it is sufficient, if not -- then we can't possibly be aligned enough in any case. ! elsif Known_Alignment (Etype (Obj)) then -- Alignment required is 4 if size is a multiple of 4, and -- 2 otherwise (e.g. 12 bits requires 4, 10 bits requires 2) ! if Alignment (Etype (Obj)) < 4 - (Csiz mod 4) then return False; end if; end if; *************** package body Exp_Pakd is *** 2345,2351 **** then Rewrite (Expr, Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Expr_Typ, Loc), Attribute_Name => Name_Pos, Expressions => New_List (Relocate_Node (Expr)))); Analyze_And_Resolve (Expr, Standard_Natural); --- 2359,2365 ---- then Rewrite (Expr, Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Expr_Typ, Loc), Attribute_Name => Name_Pos, Expressions => New_List (Relocate_Node (Expr)))); Analyze_And_Resolve (Expr, Standard_Natural); diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_pakd.ads gcc-3.3/gcc/ada/exp_pakd.ads *** gcc-3.2.3/gcc/ada/exp_pakd.ads 2002-05-04 03:28:00.000000000 +0000 --- gcc-3.3/gcc/ada/exp_pakd.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_prag.adb gcc-3.3/gcc/ada/exp_prag.adb *** gcc-3.2.3/gcc/ada/exp_prag.adb 2002-05-04 03:28:00.000000000 +0000 --- gcc-3.3/gcc/ada/exp_prag.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Exp_Prag is *** 59,65 **** function Arg1 (N : Node_Id) return Node_Id; function Arg2 (N : Node_Id) return Node_Id; - function Arg3 (N : Node_Id) return Node_Id; -- Obtain specified Pragma_Argument_Association procedure Expand_Pragma_Abort_Defer (N : Node_Id); --- 58,63 ---- *************** package body Exp_Prag is *** 69,93 **** procedure Expand_Pragma_Inspection_Point (N : Node_Id); procedure Expand_Pragma_Interrupt_Priority (N : Node_Id); ! -------------- ! -- Arg1,2,3 -- ! -------------- function Arg1 (N : Node_Id) return Node_Id is begin return First (Pragma_Argument_Associations (N)); end Arg1; function Arg2 (N : Node_Id) return Node_Id is begin return Next (Arg1 (N)); end Arg2; - function Arg3 (N : Node_Id) return Node_Id is - begin - return Next (Arg2 (N)); - end Arg3; - --------------------- -- Expand_N_Pragma -- --------------------- --- 67,90 ---- procedure Expand_Pragma_Inspection_Point (N : Node_Id); procedure Expand_Pragma_Interrupt_Priority (N : Node_Id); ! ---------- ! -- Arg1 -- ! ---------- function Arg1 (N : Node_Id) return Node_Id is begin return First (Pragma_Argument_Associations (N)); end Arg1; + ---------- + -- Arg2 -- + ---------- + function Arg2 (N : Node_Id) return Node_Id is begin return Next (Arg1 (N)); end Arg2; --------------------- -- Expand_N_Pragma -- --------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_prag.ads gcc-3.3/gcc/ada/exp_prag.ads *** gcc-3.2.3/gcc/ada/exp_prag.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_prag.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_smem.adb gcc-3.3/gcc/ada/exp_smem.adb *** gcc-3.2.3/gcc/ada/exp_smem.adb 2002-05-04 03:28:01.000000000 +0000 --- gcc-3.3/gcc/ada/exp_smem.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_smem.ads gcc-3.3/gcc/ada/exp_smem.ads *** gcc-3.2.3/gcc/ada/exp_smem.ads 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_smem.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1998-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_strm.adb gcc-3.3/gcc/ada/exp_strm.adb *** gcc-3.2.3/gcc/ada/exp_strm.adb 2002-05-04 03:28:01.000000000 +0000 --- gcc-3.3/gcc/ada/exp_strm.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Exp_Strm is *** 807,813 **** -- procedure is erroneous, because there are no discriminants to read. if Is_Unchecked_Union (Typ) then ! Stms := New_List (Make_Raise_Program_Error (Loc)); end if; if Is_Non_Empty_List ( --- 806,815 ---- -- procedure is erroneous, because there are no discriminants to read. if Is_Unchecked_Union (Typ) then ! Stms := ! New_List ( ! Make_Raise_Program_Error (Loc, ! Reason => PE_Unchecked_Union_Restriction)); end if; if Is_Non_Empty_List ( *************** package body Exp_Strm is *** 870,876 **** -- because there are no discriminants to write. if Is_Unchecked_Union (Typ) then ! Stms := New_List (Make_Raise_Program_Error (Loc)); end if; if Is_Non_Empty_List ( --- 872,881 ---- -- because there are no discriminants to write. if Is_Unchecked_Union (Typ) then ! Stms := ! New_List ( ! Make_Raise_Program_Error (Loc, ! Reason => PE_Unchecked_Union_Restriction)); end if; if Is_Non_Empty_List ( *************** package body Exp_Strm is *** 890,899 **** -- The function we build looks like -- function InputN (S : access RST) return Typ is ! -- C1 : constant Disc_Type_1 := Discr_Type_1'Input (S); ! -- C2 : constant Disc_Type_1 := Discr_Type_2'Input (S); -- ... ! -- Cn : constant Disc_Type_1 := Discr_Type_n'Input (S); -- V : Typ (C1, C2, .. Cn) -- begin --- 895,907 ---- -- The function we build looks like -- function InputN (S : access RST) return Typ is ! -- C1 : constant Disc_Type_1; ! -- Discr_Type_1'Read (S, C1); ! -- C2 : constant Disc_Type_2; ! -- Discr_Type_2'Read (S, C2); -- ... ! -- Cn : constant Disc_Type_n; ! -- Discr_Type_n'Read (S, Cn); -- V : Typ (C1, C2, .. Cn) -- begin *************** package body Exp_Strm is *** 934,947 **** Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Cn), ! Object_Definition => New_Occurrence_Of (Etype (Discr), Loc), ! Expression => ! Make_Attribute_Reference (Loc, ! Prefix => ! New_Occurrence_Of ! (Stream_Base_Type (Etype (Discr)), Loc), ! Attribute_Name => Name_Input, ! Expressions => New_List (Make_Identifier (Loc, Name_S))))); Append_To (Constr, Make_Identifier (Loc, Cn)); --- 942,957 ---- Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Cn), ! Object_Definition => ! New_Occurrence_Of (Etype (Discr), Loc))); ! ! Append_To (Decls, ! Make_Attribute_Reference (Loc, ! Prefix => New_Occurrence_Of (Etype (Discr), Loc), ! Attribute_Name => Name_Read, ! Expressions => New_List ( ! Make_Identifier (Loc, Name_S), ! Make_Identifier (Loc, Cn)))); Append_To (Constr, Make_Identifier (Loc, Cn)); *************** package body Exp_Strm is *** 1161,1167 **** if Present (VP) then if Is_Unchecked_Union (Scope (Entity (Name (VP)))) then ! return New_List (Make_Raise_Program_Error (Sloc (VP))); end if; V := First_Non_Pragma (Variants (VP)); --- 1171,1179 ---- if Present (VP) then if Is_Unchecked_Union (Scope (Entity (Name (VP)))) then ! return New_List ( ! Make_Raise_Program_Error (Sloc (VP), ! Reason => PE_Unchecked_Union_Restriction)); end if; V := First_Non_Pragma (Variants (VP)); diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_strm.ads gcc-3.3/gcc/ada/exp_strm.ads *** gcc-3.2.3/gcc/ada/exp_strm.ads 2002-05-04 03:28:01.000000000 +0000 --- gcc-3.3/gcc/ada/exp_strm.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_tss.adb gcc-3.3/gcc/ada/exp_tss.adb *** gcc-3.2.3/gcc/ada/exp_tss.adb 2002-05-04 03:28:01.000000000 +0000 --- gcc-3.3/gcc/ada/exp_tss.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_tss.ads gcc-3.3/gcc/ada/exp_tss.ads *** gcc-3.2.3/gcc/ada/exp_tss.ads 2002-05-04 03:28:01.000000000 +0000 --- gcc-3.3/gcc/ada/exp_tss.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_util.adb gcc-3.3/gcc/ada/exp_util.adb *** gcc-3.2.3/gcc/ada/exp_util.adb 2002-05-04 03:28:01.000000000 +0000 --- gcc-3.3/gcc/ada/exp_util.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.9.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with Sem_Util; use Sem_Util; *** 50,58 **** --- 49,59 ---- with Sinfo; use Sinfo; with Stand; use Stand; with Stringt; use Stringt; + with Targparm; use Targparm; with Tbuild; use Tbuild; with Ttypes; use Ttypes; with Uintp; use Uintp; + with Urealp; use Urealp; with Validsw; use Validsw; package body Exp_Util is *************** package body Exp_Util is *** 98,104 **** function Build_Task_Record_Image (Loc : Source_Ptr; Id_Ref : Node_Id; - A_Type : Entity_Id; Dyn : Boolean := False) return Node_Id; -- Build function to generate the image string for a task that is a --- 99,104 ---- *************** package body Exp_Util is *** 633,639 **** T_Id := Make_Defining_Identifier (Loc, New_External_Name (Chars (Selector_Name (Id_Ref)), 'I')); ! Fun := Build_Task_Record_Image (Loc, Id_Ref, A_Type, Is_Dyn); elsif Nkind (Id_Ref) = N_Indexed_Component then T_Id := --- 633,639 ---- T_Id := Make_Defining_Identifier (Loc, New_External_Name (Chars (Selector_Name (Id_Ref)), 'I')); ! Fun := Build_Task_Record_Image (Loc, Id_Ref, Is_Dyn); elsif Nkind (Id_Ref) = N_Indexed_Component then T_Id := *************** package body Exp_Util is *** 786,792 **** function Build_Task_Record_Image (Loc : Source_Ptr; Id_Ref : Node_Id; - A_Type : Entity_Id; Dyn : Boolean := False) return Node_Id is --- 786,791 ---- *************** package body Exp_Util is *** 970,975 **** --- 969,1010 ---- return New_Copy_Tree (Exp); end Duplicate_Subexpr; + --------------------------------- + -- Duplicate_Subexpr_No_Checks -- + --------------------------------- + + function Duplicate_Subexpr_No_Checks + (Exp : Node_Id; + Name_Req : Boolean := False) + return Node_Id + is + New_Exp : Node_Id; + + begin + Remove_Side_Effects (Exp, Name_Req); + New_Exp := New_Copy_Tree (Exp); + Remove_Checks (New_Exp); + return New_Exp; + end Duplicate_Subexpr_No_Checks; + + ----------------------------------- + -- Duplicate_Subexpr_Move_Checks -- + ----------------------------------- + + function Duplicate_Subexpr_Move_Checks + (Exp : Node_Id; + Name_Req : Boolean := False) + return Node_Id + is + New_Exp : Node_Id; + + begin + Remove_Side_Effects (Exp, Name_Req); + New_Exp := New_Copy_Tree (Exp); + Remove_Checks (Exp); + return New_Exp; + end Duplicate_Subexpr_Move_Checks; + -------------------- -- Ensure_Defined -- -------------------- *************** package body Exp_Util is *** 1657,1663 **** if Nkind (Parent (P)) = N_Aggregate and then Present (Aggregate_Bounds (Parent (P))) and then Nkind (First (Choices (P))) = N_Others_Choice - and then Nkind (First (Ins_Actions)) /= N_Freeze_Entity then if No (Loop_Actions (P)) then Set_Loop_Actions (P, Ins_Actions); --- 1692,1697 ---- *************** package body Exp_Util is *** 2093,2104 **** Remove_Handler_Entries (N); Remove_Warning_Messages (N); ! -- Recurse into block statements to process declarations/statements ! if Nkind (N) = N_Block_Statement then Kill_Dead_Code (Declarations (N)); Kill_Dead_Code (Statements (Handled_Statement_Sequence (N))); -- Recurse into composite statement to kill individual statements, -- in particular instantiations. --- 2127,2146 ---- Remove_Handler_Entries (N); Remove_Warning_Messages (N); ! -- Recurse into block statements and bodies to process declarations ! -- and statements ! if Nkind (N) = N_Block_Statement ! or else Nkind (N) = N_Subprogram_Body ! or else Nkind (N) = N_Package_Body ! then Kill_Dead_Code (Declarations (N)); Kill_Dead_Code (Statements (Handled_Statement_Sequence (N))); + if Nkind (N) = N_Subprogram_Body then + Set_Is_Eliminated (Defining_Entity (N)); + end if; + -- Recurse into composite statement to kill individual statements, -- in particular instantiations. *************** package body Exp_Util is *** 2168,2173 **** --- 2210,2298 ---- end if; end Known_Non_Negative; + -------------------------- + -- Target_Has_Fixed_Ops -- + -------------------------- + + Integer_Sized_Small : Ureal; + -- Set to 2.0 ** -(Integer'Size - 1) the first time that this + -- function is called (we don't want to compute it more than once!) + + Long_Integer_Sized_Small : Ureal; + -- Set to 2.0 ** -(Long_Integer'Size - 1) the first time that this + -- functoin is called (we don't want to compute it more than once) + + First_Time_For_THFO : Boolean := True; + -- Set to False after first call (if Fractional_Fixed_Ops_On_Target) + + function Target_Has_Fixed_Ops + (Left_Typ : Entity_Id; + Right_Typ : Entity_Id; + Result_Typ : Entity_Id) + return Boolean + is + function Is_Fractional_Type (Typ : Entity_Id) return Boolean; + -- Return True if the given type is a fixed-point type with a small + -- value equal to 2 ** (-(T'Object_Size - 1)) and whose values have + -- an absolute value less than 1.0. This is currently limited + -- to fixed-point types that map to Integer or Long_Integer. + + ------------------------ + -- Is_Fractional_Type -- + ------------------------ + + function Is_Fractional_Type (Typ : Entity_Id) return Boolean is + begin + if Esize (Typ) = Standard_Integer_Size then + return Small_Value (Typ) = Integer_Sized_Small; + + elsif Esize (Typ) = Standard_Long_Integer_Size then + return Small_Value (Typ) = Long_Integer_Sized_Small; + + else + return False; + end if; + end Is_Fractional_Type; + + -- Start of processing for Target_Has_Fixed_Ops + + begin + -- Return False if Fractional_Fixed_Ops_On_Target is false + + if not Fractional_Fixed_Ops_On_Target then + return False; + end if; + + -- Here the target has Fractional_Fixed_Ops, if first time, compute + -- standard constants used by Is_Fractional_Type. + + if First_Time_For_THFO then + First_Time_For_THFO := False; + + Integer_Sized_Small := + UR_From_Components + (Num => Uint_1, + Den => UI_From_Int (Standard_Integer_Size - 1), + Rbase => 2); + + Long_Integer_Sized_Small := + UR_From_Components + (Num => Uint_1, + Den => UI_From_Int (Standard_Long_Integer_Size - 1), + Rbase => 2); + end if; + + -- Return True if target supports fixed-by-fixed multiply/divide + -- for fractional fixed-point types (see Is_Fractional_Type) and + -- the operand and result types are equivalent fractional types. + + return Is_Fractional_Type (Base_Type (Left_Typ)) + and then Is_Fractional_Type (Base_Type (Right_Typ)) + and then Is_Fractional_Type (Base_Type (Result_Typ)) + and then Esize (Left_Typ) = Esize (Right_Typ) + and then Esize (Left_Typ) = Esize (Result_Typ); + end Target_Has_Fixed_Ops; + ----------------------------- -- Make_CW_Equivalent_Type -- ----------------------------- *************** package body Exp_Util is *** 2221,2227 **** Make_Op_Subtract (Loc, Left_Opnd => Make_Attribute_Reference (Loc, ! Prefix => OK_Convert_To (T, Duplicate_Subexpr (E)), Attribute_Name => Name_Size), Right_Opnd => Make_Attribute_Reference (Loc, --- 2346,2353 ---- Make_Op_Subtract (Loc, Left_Opnd => Make_Attribute_Reference (Loc, ! Prefix => ! OK_Convert_To (T, Duplicate_Subexpr_No_Checks (E)), Attribute_Name => Name_Size), Right_Opnd => Make_Attribute_Reference (Loc, *************** package body Exp_Util is *** 2363,2369 **** Utyp := Underlying_Type (Unc_Typ); Full_Subtyp := Make_Defining_Identifier (Loc, New_Internal_Name ('C')); ! Full_Exp := Unchecked_Convert_To (Utyp, Duplicate_Subexpr (E)); Set_Parent (Full_Exp, Parent (E)); Priv_Subtyp := --- 2489,2497 ---- Utyp := Underlying_Type (Unc_Typ); Full_Subtyp := Make_Defining_Identifier (Loc, New_Internal_Name ('C')); ! Full_Exp := ! Unchecked_Convert_To ! (Utyp, Duplicate_Subexpr_No_Checks (E)); Set_Parent (Full_Exp, Parent (E)); Priv_Subtyp := *************** package body Exp_Util is *** 2401,2413 **** Make_Range (Loc, Low_Bound => Make_Attribute_Reference (Loc, ! Prefix => Duplicate_Subexpr (E), Attribute_Name => Name_First, Expressions => New_List ( Make_Integer_Literal (Loc, J))), High_Bound => Make_Attribute_Reference (Loc, ! Prefix => Duplicate_Subexpr (E), Attribute_Name => Name_Last, Expressions => New_List ( Make_Integer_Literal (Loc, J))))); --- 2529,2542 ---- Make_Range (Loc, Low_Bound => Make_Attribute_Reference (Loc, ! Prefix => Duplicate_Subexpr_No_Checks (E), Attribute_Name => Name_First, Expressions => New_List ( Make_Integer_Literal (Loc, J))), + High_Bound => Make_Attribute_Reference (Loc, ! Prefix => Duplicate_Subexpr_No_Checks (E), Attribute_Name => Name_Last, Expressions => New_List ( Make_Integer_Literal (Loc, J))))); *************** package body Exp_Util is *** 2441,2447 **** Append_To (List_Constr, Make_Selected_Component (Loc, ! Prefix => Duplicate_Subexpr (E), Selector_Name => New_Reference_To (D, Loc))); Next_Discriminant (D); --- 2570,2576 ---- Append_To (List_Constr, Make_Selected_Component (Loc, ! Prefix => Duplicate_Subexpr_No_Checks (E), Selector_Name => New_Reference_To (D, Loc))); Next_Discriminant (D); diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_util.ads gcc-3.3/gcc/ada/exp_util.ads *** gcc-3.2.3/gcc/ada/exp_util.ads 2002-05-04 03:28:01.000000000 +0000 --- gcc-3.3/gcc/ada/exp_util.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Exp_Util is *** 244,249 **** --- 243,274 ---- -- copy after it is attached to the tree. The Name_Req flag is set to -- ensure that the result is suitable for use in a context requiring a -- name (e.g. the prefix of an attribute reference). + -- + -- Note that if there are any run time checks in Exp, these same checks + -- will be duplicated in the returned duplicated expression. The two + -- following functions allow this behavior to be modified. + + function Duplicate_Subexpr_No_Checks + (Exp : Node_Id; + Name_Req : Boolean := False) + return Node_Id; + -- Identical in effect to Duplicate_Subexpr, except that Remove_Checks + -- is called on the result, so that the duplicated expression does not + -- include checks. This is appropriate for use when Exp, the original + -- expression is unconditionally elaborated before the duplicated + -- expression, so that there is no need to repeat any checks. + + function Duplicate_Subexpr_Move_Checks + (Exp : Node_Id; + Name_Req : Boolean := False) + return Node_Id; + -- Identical in effect to Duplicate_Subexpr, except that Remove_Checks + -- is called on Exp after the duplication is complete, so that the + -- original expression does not include checks. In this case the result + -- returned (the duplicated expression) will retain the original checks. + -- This is appropriate for use when the duplicated expression is sure + -- to be elaborated before the original expression Exp, so that there + -- is no need to repeat the checks. procedure Ensure_Defined (Typ : Entity_Id; N : Node_Id); -- This procedure ensures that type referenced by Typ is defined. For the *************** package Exp_Util is *** 407,412 **** --- 432,447 ---- -- in the binder. We do that so that we can detect cases where this is -- the only elaboration action that is required. + function Target_Has_Fixed_Ops + (Left_Typ : Entity_Id; + Right_Typ : Entity_Id; + Result_Typ : Entity_Id) + return Boolean; + -- Returns True if and only if the target machine has direct support + -- for fixed-by-fixed multiplications and divisions for the given + -- operand and result types. This is called in package Exp_Fixd to + -- determine whether to expand such operations. + procedure Wrap_Cleanup_Procedure (N : Node_Id); -- Given an N_Subprogram_Body node, this procedure adds an Abort_Defer -- call at the start of the statement sequence, and an Abort_Undefer call diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_vfpt.adb gcc-3.3/gcc/ada/exp_vfpt.adb *** gcc-3.2.3/gcc/ada/exp_vfpt.adb 2002-05-07 08:22:12.000000000 +0000 --- gcc-3.3/gcc/ada/exp_vfpt.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/exp_vfpt.ads gcc-3.3/gcc/ada/exp_vfpt.ads *** gcc-3.2.3/gcc/ada/exp_vfpt.ads 2002-05-07 08:22:13.000000000 +0000 --- gcc-3.3/gcc/ada/exp_vfpt.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/fe.h gcc-3.3/gcc/ada/fe.h *** gcc-3.2.3/gcc/ada/fe.h 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/fe.h 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * ! * Copyright (C) 1992-2001 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- * --- 6,13 ---- * * * C Header File * * * * * ! * Copyright (C) 1992-2002 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- * *************** extern void Set_RM_Size PARAMS ((Entit *** 81,86 **** --- 80,93 ---- extern void Set_Component_Bit_Offset PARAMS ((Entity_Id, Uint)); extern void Set_Present_Expr PARAMS ((Node_Id, Uint)); + /* Test if the node N is the name of an entity (i.e. is an identifier, + expanded name, or an attribute reference that returns an entity). */ + #define Is_Entity_Name einfo__is_entity_name + extern Boolean Is_Entity_Name PARAMS ((Node_Id)); + + #define Get_Attribute_Definition_Clause einfo__get_attribute_definition_clause + extern Node_Id Get_Attribute_Definition_Clause PARAMS ((Entity_Id, char)); + /* errout: */ #define Error_Msg_N errout__error_msg_n *************** extern Boolean In_Extended_Main_Code_Uni *** 144,150 **** --- 151,162 ---- /* opt: */ #define Global_Discard_Names opt__global_discard_names + #define Exception_Mechanism opt__exception_mechanism + + typedef enum {Setjmp_Longjmp, Front_End_ZCX, GCC_ZCX} Exception_Mechanism_Type; + extern Boolean Global_Discard_Names; + extern Exception_Mechanism_Type Exception_Mechanism; /* restrict: */ *************** extern Boolean Global_Discard_Names; *** 154,165 **** extern void Check_Elaboration_Code_Allowed PARAMS ((Node_Id)); extern Boolean No_Exception_Handlers_Set PARAMS ((void)); - /* sem_ch13: */ - - #define Get_Attribute_Definition_Clause \ - sem_ch13__get_attribute_definition_clause - extern Node_Id Get_Attribute_Definition_Clause PARAMS ((Entity_Id, char)); - /* sem_eval: */ #define Compile_Time_Known_Value sem_eval__compile_time_known_value --- 166,171 ---- *************** extern void Set_Has_No_Elaboration_Code *** 194,197 **** #define Stack_Check_Probes_On_Target targparm__stack_check_probes_on_target extern Boolean Stack_Check_Probes_On_Target; - --- 200,202 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/fmap.adb gcc-3.3/gcc/ada/fmap.adb *** gcc-3.2.3/gcc/ada/fmap.adb 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/fmap.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.14.1 $ -- -- -- Copyright (C) 2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 26,34 **** -- -- ------------------------------------------------------------------------------ ! with Namet; use Namet; ! with Osint; use Osint; ! with Output; use Output; with Table; with Unchecked_Conversion; --- 25,35 ---- -- -- ------------------------------------------------------------------------------ ! with GNAT.OS_Lib; use GNAT.OS_Lib; ! with Namet; use Namet; ! with Opt; use Opt; ! with Osint; use Osint; ! with Output; use Output; with Table; with Unchecked_Conversion; *************** package body Fmap is *** 43,50 **** function To_Big_String_Ptr is new Unchecked_Conversion (Source_Buffer_Ptr, Big_String_Ptr); package File_Mapping is new Table.Table ( ! Table_Component_Type => File_Name_Type, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => 1_000, --- 44,56 ---- function To_Big_String_Ptr is new Unchecked_Conversion (Source_Buffer_Ptr, Big_String_Ptr); + type Mapping is record + Uname : Unit_Name_Type; + Fname : File_Name_Type; + end record; + package File_Mapping is new Table.Table ( ! Table_Component_Type => Mapping, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => 1_000, *************** package body Fmap is *** 53,59 **** -- Mapping table to map unit names to file names. package Path_Mapping is new Table.Table ( ! Table_Component_Type => File_Name_Type, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => 1_000, --- 59,65 ---- -- Mapping table to map unit names to file names. package Path_Mapping is new Table.Table ( ! Table_Component_Type => Mapping, Table_Index_Type => Int, Table_Low_Bound => 0, Table_Initial => 1_000, *************** package body Fmap is *** 89,94 **** --- 95,102 ---- -- Hash table to map file names to path names. Used in conjunction with -- table Path_Mapping above. + Last_In_Table : Int := 0; + --------------------- -- Add_To_File_Map -- --------------------- *************** package body Fmap is *** 101,110 **** begin File_Mapping.Increment_Last; Unit_Hash_Table.Set (Unit_Name, File_Mapping.Last); ! File_Mapping.Table (File_Mapping.Last) := File_Name; Path_Mapping.Increment_Last; File_Hash_Table.Set (File_Name, Path_Mapping.Last); ! Path_Mapping.Table (Path_Mapping.Last) := Path_Name; end Add_To_File_Map; ---------- --- 109,120 ---- begin File_Mapping.Increment_Last; Unit_Hash_Table.Set (Unit_Name, File_Mapping.Last); ! File_Mapping.Table (File_Mapping.Last) := ! (Uname => Unit_Name, Fname => File_Name); Path_Mapping.Increment_Last; File_Hash_Table.Set (File_Name, Path_Mapping.Last); ! Path_Mapping.Table (Path_Mapping.Last) := ! (Uname => Unit_Name, Fname => Path_Name); end Add_To_File_Map; ---------- *************** package body Fmap is *** 126,138 **** BS : Big_String_Ptr; SP : String_Ptr; ! Deb : Positive := 1; ! Fin : Natural := 0; Uname : Unit_Name_Type; Fname : Name_Id; Pname : Name_Id; procedure Empty_Tables; -- Remove all entries in case of incorrect mapping file --- 136,150 ---- BS : Big_String_Ptr; SP : String_Ptr; ! First : Positive := 1; ! Last : Natural := 0; Uname : Unit_Name_Type; Fname : Name_Id; Pname : Name_Id; + The_Mapping : Mapping; + procedure Empty_Tables; -- Remove all entries in case of incorrect mapping file *************** package body Fmap is *** 153,158 **** --- 165,171 ---- File_Hash_Table.Reset; Path_Mapping.Set_Last (0); File_Mapping.Set_Last (0); + Last_In_Table := 0; end Empty_Tables; -------------- *************** package body Fmap is *** 163,191 **** use ASCII; begin ! Deb := Fin + 1; -- If not at the end of file, skip the end of line ! while Deb < SP'Last ! and then (SP (Deb) = CR ! or else SP (Deb) = LF ! or else SP (Deb) = EOF) loop ! Deb := Deb + 1; end loop; ! -- If not at the end of line, find the end of this new line ! if Deb < SP'Last and then SP (Deb) /= EOF then ! Fin := Deb; ! while Fin < SP'Last ! and then SP (Fin + 1) /= CR ! and then SP (Fin + 1) /= LF ! and then SP (Fin + 1) /= EOF loop ! Fin := Fin + 1; end loop; end if; --- 176,204 ---- use ASCII; begin ! First := Last + 1; -- If not at the end of file, skip the end of line ! while First < SP'Last ! and then (SP (First) = CR ! or else SP (First) = LF ! or else SP (First) = EOF) loop ! First := First + 1; end loop; ! -- If not at the end of file, find the end of this new line ! if First < SP'Last and then SP (First) /= EOF then ! Last := First; ! while Last < SP'Last ! and then SP (Last + 1) /= CR ! and then SP (Last + 1) /= LF ! and then SP (Last + 1) /= EOF loop ! Last := Last + 1; end loop; end if; *************** package body Fmap is *** 197,218 **** procedure Report_Truncated is begin ! Write_Str ("warning: mapping file """); ! Write_Str (File_Name); ! Write_Line (""" is truncated"); end Report_Truncated; -- Start of procedure Initialize begin Name_Len := File_Name'Length; Name_Buffer (1 .. Name_Len) := File_Name; Read_Source_File (Name_Enter, 0, Hi, Src, Config); if Src = null then ! Write_Str ("warning: could not read mapping file """); ! Write_Str (File_Name); ! Write_Line (""""); else BS := To_Big_String_Ptr (Src); --- 210,236 ---- procedure Report_Truncated is begin ! if not Quiet_Output then ! Write_Str ("warning: mapping file """); ! Write_Str (File_Name); ! Write_Line (""" is truncated"); ! end if; end Report_Truncated; -- Start of procedure Initialize begin + Empty_Tables; Name_Len := File_Name'Length; Name_Buffer (1 .. Name_Len) := File_Name; Read_Source_File (Name_Enter, 0, Hi, Src, Config); if Src = null then ! if not Quiet_Output then ! Write_Str ("warning: could not read mapping file """); ! Write_Str (File_Name); ! Write_Line (""""); ! end if; else BS := To_Big_String_Ptr (Src); *************** package body Fmap is *** 225,238 **** -- Exit if end of file has been reached ! exit when Deb > Fin; ! pragma Assert (Fin >= Deb + 2); ! pragma Assert (SP (Fin - 1) = '%'); ! pragma Assert (SP (Fin) = 's' or else SP (Fin) = 'b'); ! Name_Len := Fin - Deb + 1; ! Name_Buffer (1 .. Name_Len) := SP (Deb .. Fin); Uname := Name_Find; -- Get the file name --- 243,256 ---- -- Exit if end of file has been reached ! exit when First > Last; ! pragma Assert (Last >= First + 2); ! pragma Assert (SP (Last - 1) = '%'); ! pragma Assert (SP (Last) = 's' or else SP (Last) = 'b'); ! Name_Len := Last - First + 1; ! Name_Buffer (1 .. Name_Len) := SP (First .. Last); Uname := Name_Find; -- Get the file name *************** package body Fmap is *** 241,254 **** -- If end of line has been reached, file is truncated ! if Deb > Fin then Report_Truncated; Empty_Tables; return; end if; ! Name_Len := Fin - Deb + 1; ! Name_Buffer (1 .. Name_Len) := SP (Deb .. Fin); Fname := Name_Find; -- Get the path name --- 259,272 ---- -- If end of line has been reached, file is truncated ! if First > Last then Report_Truncated; Empty_Tables; return; end if; ! Name_Len := Last - First + 1; ! Name_Buffer (1 .. Name_Len) := SP (First .. Last); Fname := Name_Find; -- Get the path name *************** package body Fmap is *** 257,290 **** -- If end of line has been reached, file is truncated ! if Deb > Fin then Report_Truncated; Empty_Tables; return; end if; ! Name_Len := Fin - Deb + 1; ! Name_Buffer (1 .. Name_Len) := SP (Deb .. Fin); Pname := Name_Find; -- Check for duplicate entries if Unit_Hash_Table.Get (Uname) /= No_Entry then ! Write_Str ("warning: duplicate entry """); ! Write_Str (Get_Name_String (Uname)); ! Write_Str (""" in mapping file """); ! Write_Str (File_Name); ! Write_Line (""""); Empty_Tables; return; end if; if File_Hash_Table.Get (Fname) /= No_Entry then ! Write_Str ("warning: duplicate entry """); ! Write_Str (Get_Name_String (Fname)); ! Write_Str (""" in mapping file """); ! Write_Str (File_Name); ! Write_Line (""""); Empty_Tables; return; end if; --- 275,322 ---- -- If end of line has been reached, file is truncated ! if First > Last then Report_Truncated; Empty_Tables; return; end if; ! Name_Len := Last - First + 1; ! Name_Buffer (1 .. Name_Len) := SP (First .. Last); Pname := Name_Find; -- Check for duplicate entries if Unit_Hash_Table.Get (Uname) /= No_Entry then ! if not Quiet_Output then ! Write_Str ("warning: duplicate entry """); ! Write_Str (Get_Name_String (Uname)); ! Write_Str (""" in mapping file """); ! Write_Str (File_Name); ! Write_Line (""""); ! The_Mapping := ! File_Mapping.Table (Unit_Hash_Table.Get (Uname)); ! Write_Line (Get_Name_String (The_Mapping.Uname)); ! Write_Line (Get_Name_String (The_Mapping.Fname)); ! end if; ! Empty_Tables; return; end if; if File_Hash_Table.Get (Fname) /= No_Entry then ! if not Quiet_Output then ! Write_Str ("warning: duplicate entry """); ! Write_Str (Get_Name_String (Fname)); ! Write_Str (""" in mapping file """); ! Write_Str (File_Name); ! Write_Line (""""); ! The_Mapping := ! Path_Mapping.Table (File_Hash_Table.Get (Fname)); ! Write_Line (Get_Name_String (The_Mapping.Uname)); ! Write_Line (Get_Name_String (The_Mapping.Fname)); ! end if; ! Empty_Tables; return; end if; *************** package body Fmap is *** 294,299 **** --- 326,336 ---- Add_To_File_Map (Uname, Fname, Pname); end loop; end if; + + -- Record the length of the two mapping tables + + Last_In_Table := File_Mapping.Last; + end Initialize; ---------------------- *************** package body Fmap is *** 307,313 **** if The_Index = No_Entry then return No_File; else ! return File_Mapping.Table (The_Index); end if; end Mapped_File_Name; --- 344,350 ---- if The_Index = No_Entry then return No_File; else ! return File_Mapping.Table (The_Index).Fname; end if; end Mapped_File_Name; *************** package body Fmap is *** 324,331 **** if Index = No_Entry then return No_File; else ! return Path_Mapping.Table (Index); end if; end Mapped_Path_Name; end Fmap; --- 361,443 ---- if Index = No_Entry then return No_File; else ! return Path_Mapping.Table (Index).Fname; end if; end Mapped_Path_Name; + ------------------------- + -- Update_Mapping_File -- + ------------------------- + + procedure Update_Mapping_File (File_Name : String) is + File : File_Descriptor; + + procedure Put_Line (Name : Name_Id); + -- Put Name as a line in the Mapping File + + -------------- + -- Put_Line -- + -------------- + + procedure Put_Line (Name : Name_Id) is + N_Bytes : Integer; + begin + Get_Name_String (Name); + Name_Len := Name_Len + 1; + Name_Buffer (Name_Len) := ASCII.LF; + N_Bytes := Write (File, Name_Buffer (1)'Address, Name_Len); + + if N_Bytes < Name_Len then + Fail ("disk full"); + end if; + + end Put_Line; + + -- Start of Update_Mapping_File + + begin + + -- Only Update if there are new entries in the mappings + + if Last_In_Table < File_Mapping.Last then + + -- If the tables have been emptied, recreate the file. + -- Otherwise, append to it. + + if Last_In_Table = 0 then + declare + Discard : Boolean; + + begin + Delete_File (File_Name, Discard); + end; + + File := Create_File (File_Name, Binary); + + else + File := Open_Read_Write (Name => File_Name, Fmode => Binary); + end if; + + if File /= Invalid_FD then + if Last_In_Table > 0 then + Lseek (File, 0, Seek_End); + end if; + + for Unit in Last_In_Table + 1 .. File_Mapping.Last loop + Put_Line (File_Mapping.Table (Unit).Uname); + Put_Line (File_Mapping.Table (Unit).Fname); + Put_Line (Path_Mapping.Table (Unit).Fname); + end loop; + + Close (File); + + elsif not Quiet_Output then + Write_Str ("warning: could not open mapping file """); + Write_Str (File_Name); + Write_Line (""" for update"); + end if; + + end if; + end Update_Mapping_File; + end Fmap; diff -Nrc3pad gcc-3.2.3/gcc/ada/fmap.ads gcc-3.3/gcc/ada/fmap.ads *** gcc-3.2.3/gcc/ada/fmap.ads 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/fmap.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.14.1 $ -- -- -- Copyright (C) 2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Fmap is *** 37,42 **** --- 36,43 ---- -- Initialize the mappings from the mapping file File_Name. -- If the mapping file is incorrect (non existent file, truncated file, -- duplicate entries), output a warning and do not initialize the mappings. + -- Record the state of the mapping tables in case Update is called + -- later on. function Mapped_Path_Name (File : File_Name_Type) return File_Name_Type; -- Return the path name mapped to the file name File. *************** package Fmap is *** 52,55 **** --- 53,62 ---- Path_Name : File_Name_Type); -- Add mapping of Unit_Name to File_Name and of File_Name to Path_Name + procedure Update_Mapping_File (File_Name : String); + -- If Add_To_File_Map has been called (after Initialize or any time + -- if Initialize has not been called), append the new entries to the + -- to the mapping file. + -- What is the significance of the parameter File_Name ??? + end Fmap; diff -Nrc3pad gcc-3.2.3/gcc/ada/fname.adb gcc-3.3/gcc/ada/fname.adb *** gcc-3.2.3/gcc/ada/fname.adb 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/fname.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/fname.ads gcc-3.3/gcc/ada/fname.ads *** gcc-3.2.3/gcc/ada/fname.ads 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/fname.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/fname-sf.adb gcc-3.3/gcc/ada/fname-sf.adb *** gcc-3.2.3/gcc/ada/fname-sf.adb 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/fname-sf.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/fname-sf.ads gcc-3.3/gcc/ada/fname-sf.ads *** gcc-3.2.3/gcc/ada/fname-sf.ads 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/fname-sf.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/fname-uf.adb gcc-3.3/gcc/ada/fname-uf.adb *** gcc-3.2.3/gcc/ada/fname-uf.adb 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/fname-uf.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Fname.UF is *** 370,405 **** Fnam := File_Name_Type (Name_Find); ! -- If we are in the first search of the table, then ! -- we check if the file is present, and only accept ! -- the entry if it is indeed present. For the second ! -- search, we accept the entry without this check. ! ! -- If we only have two entries in the table, then there ! -- is no point in seeing if the file exists, since we ! -- will end up accepting it anyway on the second search, ! -- so just quit and accept it now to save time. ! if No_File_Check or else SFN_Patterns.Last = 2 then return Fnam; ! -- Check if file exists and if so, return the entry else Pname := Find_File (Fnam, Source); ! -- Check if file exists and if so, return the entry if Pname /= No_File then -- Add to mapping, so that we don't do another -- path search in Find_File for this file name Add_To_File_Map (Get_File_Name.Uname, Fnam, Pname); return Fnam; ! -- This entry does not match after all, because this is ! -- the first search loop, and the file does not exist. else Fnam := No_File; --- 369,411 ---- Fnam := File_Name_Type (Name_Find); ! -- If we are in the second search of the table, we accept ! -- the file name without checking, because we know that ! -- the file does not exist. ! if No_File_Check then return Fnam; ! -- Otherwise we check if the file exists else Pname := Find_File (Fnam, Source); ! -- If it does exist, we add it to the mappings and ! -- return the file name. if Pname /= No_File then -- Add to mapping, so that we don't do another -- path search in Find_File for this file name + -- and, if we use a mapping file, we are ready + -- to update it at the end of this compilation + -- for the benefit of other compilation processes. Add_To_File_Map (Get_File_Name.Uname, Fnam, Pname); return Fnam; ! -- If there are only two entries, they are those of ! -- the default GNAT naming scheme. The file does ! -- not exist, but there is no point doing the ! -- second search, because we will end up with the ! -- same file name. Just return the file name. ! ! elsif SFN_Patterns.Last = 2 then ! return Fnam; ! ! -- The file does not exist, but there may be other ! -- naming scheme. Keep on searching. else Fnam := No_File; diff -Nrc3pad gcc-3.2.3/gcc/ada/fname-uf.ads gcc-3.3/gcc/ada/fname-uf.ads *** gcc-3.2.3/gcc/ada/fname-uf.ads 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/fname-uf.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/freeze.adb gcc-3.3/gcc/ada/freeze.adb *** gcc-3.2.3/gcc/ada/freeze.adb 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/freeze.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with Exp_Ch11; use Exp_Ch11; *** 36,41 **** --- 35,41 ---- with Exp_Pakd; use Exp_Pakd; with Exp_Util; use Exp_Util; with Layout; use Layout; + with Lib.Xref; use Lib.Xref; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; *************** package body Freeze is *** 248,254 **** end if; if Is_Entity_Name (Nam) then ! Call_Name := New_Reference_To (Old_S, Loc); else Call_Name := New_Copy (Name (N)); --- 248,265 ---- end if; if Is_Entity_Name (Nam) then ! ! -- If the renamed entity is a predefined operator, retain full ! -- name to ensure its visibility. ! ! if Ekind (Old_S) = E_Operator ! and then Nkind (Nam) = N_Expanded_Name ! then ! Call_Name := New_Copy (Name (N)); ! else ! Call_Name := New_Reference_To (Old_S, Loc); ! end if; ! else Call_Name := New_Copy (Name (N)); *************** package body Freeze is *** 291,296 **** --- 302,309 ---- -- in the declaration. However, default values that are aggregates -- are rewritten when partially analyzed, so we recover the original -- aggregate to insure that subsequent conformity checking works. + -- Similarly, if the default expression was constant-folded, recover + -- the original expression. Formal := First_Formal (Defining_Entity (Decl)); *************** package body Freeze is *** 308,314 **** Set_Entity (Parameter_Type (Param_Spec), Etype (O_Formal)); end if; ! elsif Nkind (Default_Value (O_Formal)) = N_Aggregate then Set_Expression (Param_Spec, New_Copy_Tree (Original_Node (Default_Value (O_Formal)))); end if; --- 321,330 ---- Set_Entity (Parameter_Type (Param_Spec), Etype (O_Formal)); end if; ! elsif Nkind (Default_Value (O_Formal)) = N_Aggregate ! or else Nkind (Original_Node (Default_Value (O_Formal))) /= ! Nkind (Default_Value (O_Formal)) ! then Set_Expression (Param_Spec, New_Copy_Tree (Original_Node (Default_Value (O_Formal)))); end if; *************** package body Freeze is *** 409,417 **** -- to give a smaller size. function Size_Known (T : Entity_Id) return Boolean; ! -- Recursive function that does all the work. ! -- Is this right??? isn't recursive case already handled??? ! -- certainly yes for normal call, but what about bogus sem_res call??? function Static_Discriminated_Components (T : Entity_Id) return Boolean; -- If T is a constrained subtype, its size is not known if any of its --- 425,431 ---- -- to give a smaller size. function Size_Known (T : Entity_Id) return Boolean; ! -- Recursive function that does all the work function Static_Discriminated_Components (T : Entity_Id) return Boolean; -- If T is a constrained subtype, its size is not known if any of its *************** package body Freeze is *** 468,476 **** if Size_Known_At_Compile_Time (T) then return True; - elsif Error_Posted (T) then - return False; - elsif Is_Scalar_Type (T) or else Is_Task_Type (T) then --- 482,487 ---- *************** package body Freeze is *** 485,490 **** --- 496,507 ---- elsif not Is_Constrained (T) then return False; + -- Don't do any recursion on type with error posted, since + -- we may have a malformed type that leads us into a loop + + elsif Error_Posted (T) then + return False; + elsif not Size_Known (Component_Type (T)) then return False; end if; *************** package body Freeze is *** 541,547 **** and then not Is_Generic_Type (T) and then Present (Underlying_Type (T)) then ! return Size_Known (Underlying_Type (T)); elsif Is_Record_Type (T) then if Is_Class_Wide_Type (T) then --- 558,571 ---- and then not Is_Generic_Type (T) and then Present (Underlying_Type (T)) then ! -- Don't do any recursion on type with error posted, since ! -- we may have a malformed type that leads us into a loop ! ! if Error_Posted (T) then ! return False; ! else ! return Size_Known (Underlying_Type (T)); ! end if; elsif Is_Record_Type (T) then if Is_Class_Wide_Type (T) then *************** package body Freeze is *** 551,556 **** --- 575,586 ---- return Size_Known_At_Compile_Time (Base_Type (T)) and then Static_Discriminated_Components (T); + -- Don't do any recursion on type with error posted, since + -- we may have a malformed type that leads us into a loop + + elsif Error_Posted (T) then + return False; + else declare Packed_Size_Known : Boolean := Is_Packed (T); *************** package body Freeze is *** 1218,1223 **** --- 1248,1264 ---- end if; end; + -- If this is a constrained subtype of an already frozen type, + -- make the subtype frozen as well. It might otherwise be frozen + -- in the wrong scope, and a freeze node on subtype has no effect. + + elsif Is_Access_Type (Etype (Comp)) + and then not Is_Frozen (Designated_Type (Etype (Comp))) + and then Is_Itype (Designated_Type (Etype (Comp))) + and then Is_Frozen (Base_Type (Designated_Type (Etype (Comp)))) + then + Set_Is_Frozen (Designated_Type (Etype (Comp))); + elsif Is_Array_Type (Etype (Comp)) and then Is_Access_Type (Component_Type (Etype (Comp))) and then Present (Parent (Comp)) *************** package body Freeze is *** 1250,1258 **** if Present (CC) then Placed_Component := True; ! if not Size_Known_At_Compile_Time (Underlying_Type (Etype (Comp))) - and then not Inside_A_Generic then Error_Msg_N ("component clause not allowed for variable " & --- 1291,1301 ---- if Present (CC) then Placed_Component := True; ! if Inside_A_Generic then ! null; ! ! elsif not Size_Known_At_Compile_Time (Underlying_Type (Etype (Comp))) then Error_Msg_N ("component clause not allowed for variable " & *************** package body Freeze is *** 1827,1835 **** Next_Index (Indx); end loop; ! -- For base type, propagate flags for component type if Ekind (E) = E_Array_Type then if Is_Controlled (Component_Type (E)) or else Has_Controlled_Component (Ctyp) then --- 1870,1881 ---- Next_Index (Indx); end loop; ! -- Processing that is done only for base types if Ekind (E) = E_Array_Type then + + -- Propagate flags for component type + if Is_Controlled (Component_Type (E)) or else Has_Controlled_Component (Ctyp) then *************** package body Freeze is *** 1839,1856 **** if Has_Unchecked_Union (Component_Type (E)) then Set_Has_Unchecked_Union (E); end if; - end if; ! -- If packing was requested or if the component size was set ! -- explicitly, then see if bit packing is required. This ! -- processing is only done for base types, since all the ! -- representation aspects involved are type-related. This ! -- is not just an optimization, if we start processing the ! -- subtypes, they intefere with the settings on the base ! -- type (this is because Is_Packed has a slightly different ! -- meaning before and after freezing). - if E = Base_Type (E) then declare Csiz : Uint; Esiz : Uint; --- 1885,1900 ---- if Has_Unchecked_Union (Component_Type (E)) then Set_Has_Unchecked_Union (E); end if; ! -- If packing was requested or if the component size was set ! -- explicitly, then see if bit packing is required. This ! -- processing is only done for base types, since all the ! -- representation aspects involved are type-related. This ! -- is not just an optimization, if we start processing the ! -- subtypes, they intefere with the settings on the base ! -- type (this is because Is_Packed has a slightly different ! -- meaning before and after freezing). declare Csiz : Uint; Esiz : Uint; *************** package body Freeze is *** 1939,1944 **** --- 1983,2045 ---- end if; end if; end; + + -- Processing that is done only for subtypes + + else + -- Acquire alignment from base type + + if Unknown_Alignment (E) then + Set_Alignment (E, Alignment (Base_Type (E))); + end if; + end if; + + -- Check one common case of a size given where the array + -- needs to be packed, but was not so the size cannot be + -- honored. This would of course be caught by the backend, + -- and indeed we don't catch all cases. The point is that + -- we can give a better error message in those cases that + -- we do catch with the circuitry here. + + if Present (Size_Clause (E)) + and then Known_Static_Esize (E) + and then not Has_Pragma_Pack (E) + and then Number_Dimensions (E) = 1 + and then not Has_Component_Size_Clause (E) + and then Known_Static_Component_Size (E) + then + declare + Lo, Hi : Node_Id; + Ctyp : constant Entity_Id := Component_Type (E); + + begin + Get_Index_Bounds (First_Index (E), Lo, Hi); + + if Compile_Time_Known_Value (Lo) + and then Compile_Time_Known_Value (Hi) + and then Known_Static_RM_Size (Ctyp) + and then RM_Size (Ctyp) < 64 + then + declare + Lov : constant Uint := Expr_Value (Lo); + Hiv : constant Uint := Expr_Value (Hi); + Len : constant Uint := + UI_Max (Uint_0, Hiv - Lov + 1); + + begin + if Esize (E) < Len * Component_Size (E) + and then Esize (E) = Len * RM_Size (Ctyp) + then + Error_Msg_NE + ("size given for& too small", + Size_Clause (E), E); + Error_Msg_N + ("\explicit pragma Pack is required", + Size_Clause (E)); + end if; + end; + end if; + end; end if; -- If any of the index types was an enumeration type with *************** package body Freeze is *** 2241,2250 **** elsif Has_Discriminants (E) and Is_Constrained (E) then - declare Constraint : Elmt_Id; Expr : Node_Id; begin Constraint := First_Elmt (Discriminant_Constraint (E)); --- 2342,2351 ---- elsif Has_Discriminants (E) and Is_Constrained (E) then declare Constraint : Elmt_Id; Expr : Node_Id; + begin Constraint := First_Elmt (Discriminant_Constraint (E)); *************** package body Freeze is *** 2285,2293 **** then declare Prim_List : constant Elist_Id := Primitive_Operations (E); ! Prim : Elmt_Id := First_Elmt (Prim_List); begin while Present (Prim) loop if Convention (Node (Prim)) = Convention_Ada then Set_Convention (Node (Prim), Convention (E)); --- 2386,2395 ---- then declare Prim_List : constant Elist_Id := Primitive_Operations (E); ! Prim : Elmt_Id; begin + Prim := First_Elmt (Prim_List); while Present (Prim) loop if Convention (Node (Prim)) = Convention_Ada then Set_Convention (Node (Prim), Convention (E)); *************** package body Freeze is *** 2299,2304 **** --- 2401,2443 ---- end if; end if; + -- Generate primitive operation references for a tagged type + + if Is_Tagged_Type (E) + and then not Is_Class_Wide_Type (E) + then + declare + Prim_List : constant Elist_Id := Primitive_Operations (E); + Prim : Elmt_Id; + Ent : Entity_Id; + + begin + Prim := First_Elmt (Prim_List); + while Present (Prim) loop + Ent := Node (Prim); + + -- If the operation is derived, get the original for + -- cross-reference purposes (it is the original for + -- which we want the xref, and for which the comes + -- from source test needs to be performed). + + while Present (Alias (Ent)) loop + Ent := Alias (Ent); + end loop; + + Generate_Reference (E, Ent, 'p', Set_Ref => False); + Next_Elmt (Prim); + end loop; + + -- If we get an exception, then something peculiar has happened + -- probably as a result of a previous error. Since this is only + -- for non-critical cross-references, ignore the error. + + exception + when others => null; + end; + end if; + -- Now that all types from which E may depend are frozen, see -- if the size is known at compile time, if it must be unsigned, -- or if strict alignent is required *************** package body Freeze is *** 2316,2324 **** if Has_Size_Clause (E) and then not Size_Known_At_Compile_Time (E) then ! Error_Msg_N ! ("size clause not allowed for variable length type", ! Size_Clause (E)); end if; -- Remaining process is to set/verify the representation information, --- 2455,2468 ---- if Has_Size_Clause (E) and then not Size_Known_At_Compile_Time (E) then ! -- Supress this message if errors posted on E, even if we are ! -- in all errors mode, since this is often a junk message ! ! if not Error_Posted (E) then ! Error_Msg_N ! ("size clause not allowed for variable length type", ! Size_Clause (E)); ! end if; end if; -- Remaining process is to set/verify the representation information, diff -Nrc3pad gcc-3.2.3/gcc/ada/freeze.ads gcc-3.3/gcc/ada/freeze.ads *** gcc-3.2.3/gcc/ada/freeze.ads 2002-05-04 03:28:03.000000000 +0000 --- gcc-3.3/gcc/ada/freeze.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.4.10.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/frontend.adb gcc-3.3/gcc/ada/frontend.adb *** gcc-3.2.3/gcc/ada/frontend.adb 2002-05-04 03:28:05.000000000 +0000 --- gcc-3.3/gcc/ada/frontend.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** begin *** 292,304 **** -- make sure that all the necessary information is at hand. Exp_Ch11.Generate_Unit_Exception_Table; - - -- Save the unit name and list of packages named in Use_Package - -- clauses for subsequent use in generating a special symbol for - -- the debugger for certain targets that require this. - - Exp_Dbug.Save_Unitname_And_Use_List - (Cunit (Main_Unit), Nkind (Unit (Cunit (Main_Unit)))); end if; -- List library units if requested --- 291,296 ---- *************** begin *** 328,331 **** --- 320,331 ---- -- of -gnatD, where it rewrites all source locations in the tree. Sprint.Source_Dump; + + -- If a mapping file has been specified by a -gnatem switch, + -- update it if there has been some sourcs that were not in the mappings. + + if Mapping_File_Name /= null then + Fmap.Update_Mapping_File (Mapping_File_Name.all); + end if; + end Frontend; diff -Nrc3pad gcc-3.2.3/gcc/ada/frontend.ads gcc-3.3/gcc/ada/frontend.ads *** gcc-3.2.3/gcc/ada/frontend.ads 2002-05-07 08:22:13.000000000 +0000 --- gcc-3.3/gcc/ada/frontend.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-awk.adb gcc-3.3/gcc/ada/g-awk.adb *** gcc-3.2.3/gcc/ada/g-awk.adb 2001-10-28 12:55:50.000000000 +0000 --- gcc-3.3/gcc/ada/g-awk.adb 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** package body GNAT.AWK is *** 383,388 **** --- 382,389 ---- (A : Simple_Action; Session : Session_Type) is + pragma Warnings (Off, Session); + begin A.Proc.all; end Call; *************** package body GNAT.AWK is *** 446,451 **** --- 447,454 ---- Session : Session_Type) return Boolean is + pragma Warnings (Off, Session); + begin return P.Pattern.all; end Match; *************** package body GNAT.AWK is *** 455,460 **** --- 458,465 ---- ------------- procedure Release (P : in out Pattern) is + pragma Warnings (Off, P); + begin null; end Release; *************** package body GNAT.AWK is *** 907,920 **** Read_Line (Session); Split_Line (Session); ! if Callbacks in Only .. Pass_Through then ! Filter_Active := Apply_Filters (Session); ! end if; ! exit when Callbacks = None ! or else Callbacks = Pass_Through ! or else (Callbacks = Only and then not Filter_Active); end loop; end Get_Line; --- 912,931 ---- Read_Line (Session); Split_Line (Session); ! case Callbacks is ! when None => ! exit; ! ! when Only => ! Filter_Active := Apply_Filters (Session); ! exit when not Filter_Active; ! ! when Pass_Through => ! Filter_Active := Apply_Filters (Session); ! exit; + end case; end loop; end Get_Line; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-awk.ads gcc-3.3/gcc/ada/g-awk.ads *** gcc-3.2.3/gcc/ada/g-awk.ads 2001-10-25 19:56:43.000000000 +0000 --- gcc-3.3/gcc/ada/g-awk.ads 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-busora.adb gcc-3.3/gcc/ada/g-busora.adb *** gcc-3.2.3/gcc/ada/g-busora.adb 2002-05-07 08:22:14.000000000 +0000 --- gcc-3.3/gcc/ada/g-busora.adb 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1995-1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-busora.ads gcc-3.3/gcc/ada/g-busora.ads *** gcc-3.2.3/gcc/ada/g-busora.ads 2001-10-02 14:15:29.000000000 +0000 --- gcc-3.3/gcc/ada/g-busora.ads 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1995-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-busorg.adb gcc-3.3/gcc/ada/g-busorg.adb *** gcc-3.2.3/gcc/ada/g-busorg.adb 2002-05-07 08:22:14.000000000 +0000 --- gcc-3.3/gcc/ada/g-busorg.adb 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1995-1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-busorg.ads gcc-3.3/gcc/ada/g-busorg.ads *** gcc-3.2.3/gcc/ada/g-busorg.ads 2001-10-02 14:15:29.000000000 +0000 --- gcc-3.3/gcc/ada/g-busorg.ads 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1995-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-calend.adb gcc-3.3/gcc/ada/g-calend.adb *** gcc-3.2.3/gcc/ada/g-calend.adb 2001-10-02 14:15:29.000000000 +0000 --- gcc-3.3/gcc/ada/g-calend.adb 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1999-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-calend.ads gcc-3.3/gcc/ada/g-calend.ads *** gcc-3.2.3/gcc/ada/g-calend.ads 2002-05-04 03:28:05.000000000 +0000 --- gcc-3.3/gcc/ada/g-calend.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-casuti.adb gcc-3.3/gcc/ada/g-casuti.adb *** gcc-3.2.3/gcc/ada/g-casuti.adb 2002-05-07 08:22:14.000000000 +0000 --- gcc-3.3/gcc/ada/g-casuti.adb 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1995-1999 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-casuti.ads gcc-3.3/gcc/ada/g-casuti.ads *** gcc-3.2.3/gcc/ada/g-casuti.ads 2002-05-07 08:22:15.000000000 +0000 --- gcc-3.3/gcc/ada/g-casuti.ads 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1995-1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-catiio.adb gcc-3.3/gcc/ada/g-catiio.adb *** gcc-3.2.3/gcc/ada/g-catiio.adb 2001-10-02 14:15:30.000000000 +0000 --- gcc-3.3/gcc/ada/g-catiio.adb 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1999-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-catiio.ads gcc-3.3/gcc/ada/g-catiio.ads *** gcc-3.2.3/gcc/ada/g-catiio.ads 2001-10-02 14:15:30.000000000 +0000 --- gcc-3.3/gcc/ada/g-catiio.ads 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1999-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-cgi.adb gcc-3.3/gcc/ada/g-cgi.adb *** gcc-3.2.3/gcc/ada/g-cgi.adb 2001-10-02 14:15:30.000000000 +0000 --- gcc-3.3/gcc/ada/g-cgi.adb 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-cgi.ads gcc-3.3/gcc/ada/g-cgi.ads *** gcc-3.2.3/gcc/ada/g-cgi.ads 2001-12-16 01:13:40.000000000 +0000 --- gcc-3.3/gcc/ada/g-cgi.ads 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-cgicoo.adb gcc-3.3/gcc/ada/g-cgicoo.adb *** gcc-3.2.3/gcc/ada/g-cgicoo.adb 2001-10-02 14:15:30.000000000 +0000 --- gcc-3.3/gcc/ada/g-cgicoo.adb 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-cgicoo.ads gcc-3.3/gcc/ada/g-cgicoo.ads *** gcc-3.2.3/gcc/ada/g-cgicoo.ads 2001-10-02 14:15:30.000000000 +0000 --- gcc-3.3/gcc/ada/g-cgicoo.ads 2002-03-14 10:59:17.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-cgideb.adb gcc-3.3/gcc/ada/g-cgideb.adb *** gcc-3.2.3/gcc/ada/g-cgideb.adb 2001-10-02 14:15:30.000000000 +0000 --- gcc-3.3/gcc/ada/g-cgideb.adb 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** package body GNAT.CGI.Debug is *** 208,213 **** --- 207,214 ---- ------------ function Header (IO : in Format; Str : in String) return String is + pragma Warnings (Off, IO); + begin return "

" & Str & "

" & NL; end Header; *************** package body GNAT.CGI.Debug is *** 226,231 **** --- 227,234 ---- -------------- function New_Line (IO : in Format) return String is + pragma Warnings (Off, IO); + begin return "
" & NL; end New_Line; *************** package body GNAT.CGI.Debug is *** 235,240 **** --- 238,245 ---- ----------- function Title (IO : in Format; Str : in String) return String is + pragma Warnings (Off, IO); + begin return "

" & Str & "

" & NL; end Title; *************** package body GNAT.CGI.Debug is *** 249,254 **** --- 254,261 ---- Value : String) return String is + pragma Warnings (Off, IO); + begin return Bold (Name) & " = " & Italic (Value); end Variable; *************** package body GNAT.CGI.Debug is *** 275,280 **** --- 282,289 ---- -------------- function New_Line (IO : in Format) return String is + pragma Warnings (Off, IO); + begin return String'(1 => ASCII.LF); end New_Line; *************** package body GNAT.CGI.Debug is *** 301,306 **** --- 310,317 ---- Value : String) return String is + pragma Warnings (Off, IO); + begin return " " & Name & " = " & Value; end Variable; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-cgideb.ads gcc-3.3/gcc/ada/g-cgideb.ads *** gcc-3.2.3/gcc/ada/g-cgideb.ads 2001-10-02 14:15:30.000000000 +0000 --- gcc-3.3/gcc/ada/g-cgideb.ads 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-comlin.adb gcc-3.3/gcc/ada/g-comlin.adb *** gcc-3.2.3/gcc/ada/g-comlin.adb 2002-05-04 03:28:05.000000000 +0000 --- gcc-3.3/gcc/ada/g-comlin.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1999-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1999-2002 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- -- *************** *** 33,38 **** --- 32,38 ---- ------------------------------------------------------------------------------ with Ada.Command_Line; + with GNAT.OS_Lib; use GNAT.OS_Lib; package body GNAT.Command_Line is *************** package body GNAT.Command_Line is *** 41,52 **** type Section_Number is new Natural range 0 .. 65534; for Section_Number'Size use 16; ! type Parameter_Type is ! record ! Arg_Num : Positive; ! First : Positive; ! Last : Positive; ! end record; The_Parameter : Parameter_Type; The_Switch : Parameter_Type; -- This type and this variable are provided to store the current switch --- 41,51 ---- type Section_Number is new Natural range 0 .. 65534; for Section_Number'Size use 16; ! type Parameter_Type is record ! Arg_Num : Positive; ! First : Positive; ! Last : Positive; ! end record; The_Parameter : Parameter_Type; The_Switch : Parameter_Type; -- This type and this variable are provided to store the current switch *************** package body GNAT.Command_Line is *** 101,108 **** -- Go to the next argument on the command line. If we are at the end -- of the current section, we want to make sure there is no other -- identical section on the command line (there might be multiple ! -- instances of -largs). ! -- Return True if there as another argument, False otherwise --------------- -- Expansion -- --- 100,138 ---- -- Go to the next argument on the command line. If we are at the end -- of the current section, we want to make sure there is no other -- identical section on the command line (there might be multiple ! -- instances of -largs). Returns True iff there is another argument. ! ! function Get_File_Names_Case_Sensitive return Integer; ! pragma Import (C, Get_File_Names_Case_Sensitive, ! "__gnat_get_file_names_case_sensitive"); ! File_Names_Case_Sensitive : constant Boolean := ! Get_File_Names_Case_Sensitive /= 0; ! ! procedure Canonical_Case_File_Name (S : in out String); ! -- Given a file name, converts it to canonical case form. For systems ! -- where file names are case sensitive, this procedure has no effect. ! -- If file names are not case sensitive (i.e. for example if you have ! -- the file "xyz.adb", you can refer to it as XYZ.adb or XyZ.AdB), then ! -- this call converts the given string to canonical all lower case form, ! -- so that two file names compare equal if they refer to the same file. ! ! ------------------------------ ! -- Canonical_Case_File_Name -- ! ------------------------------ ! ! procedure Canonical_Case_File_Name (S : in out String) is ! begin ! if not File_Names_Case_Sensitive then ! for J in S'Range loop ! if S (J) in 'A' .. 'Z' then ! S (J) := Character'Val ( ! Character'Pos (S (J)) + ! Character'Pos ('a') - ! Character'Pos ('A')); ! end if; ! end loop; ! end if; ! end Canonical_Case_File_Name; --------------- -- Expansion -- *************** package body GNAT.Command_Line is *** 116,132 **** Last : Natural; It : Pointer := Iterator'Unrestricted_Access; begin loop ! Read (It.Dir, S, Last); if Last = 0 then ! Close (It.Dir); ! return String'(1 .. 0 => ' '); ! end if; ! if GNAT.Regexp.Match (S (1 .. Last), Iterator.Regexp) then ! return S (1 .. Last); end if; end loop; --- 146,226 ---- Last : Natural; It : Pointer := Iterator'Unrestricted_Access; + Current : Depth := It.Current_Depth; + NL : Positive; + begin + -- It is assumed that a directory is opened at the current level; + -- otherwise, GNAT.Directory_Operations.Directory_Error will be raised + -- at the first call to Read. + loop ! Read (It.Levels (Current).Dir, S, Last); ! ! -- If we have exhausted the directory, close it and go back one level if Last = 0 then ! Close (It.Levels (Current).Dir); ! -- If we are at level 1, we are finished; return an empty string. ! ! if Current = 1 then ! return String'(1 .. 0 => ' '); ! else ! -- Otherwise, continue with the directory at the previous level ! ! Current := Current - 1; ! It.Current_Depth := Current; ! end if; ! ! -- If this is a directory, that is neither "." or "..", attempt to ! -- go to the next level. ! ! elsif Is_Directory ! (It.Dir_Name (1 .. It.Levels (Current).Name_Last) & S (1 .. Last)) ! and then S (1 .. Last) /= "." ! and then S (1 .. Last) /= ".." ! then ! -- We can go to the next level only if we have not reached the ! -- maximum depth, ! ! if Current < It.Maximum_Depth then ! NL := It.Levels (Current).Name_Last; ! ! -- And if relative path of this new directory is not too long ! ! if NL + Last + 1 < Max_Path_Length then ! Current := Current + 1; ! It.Current_Depth := Current; ! It.Dir_Name (NL + 1 .. NL + Last) := S (1 .. Last); ! NL := NL + Last + 1; ! It.Dir_Name (NL) := Directory_Separator; ! It.Levels (Current).Name_Last := NL; ! Canonical_Case_File_Name (It.Dir_Name (1 .. NL)); ! ! -- Open the new directory, and read from it ! ! GNAT.Directory_Operations.Open ! (It.Levels (Current).Dir, It.Dir_Name (1 .. NL)); ! end if; ! end if; ! ! -- If not a directory, check the relative path against the pattern ! ! else ! declare ! Name : String := ! It.Dir_Name (It.Start .. It.Levels (Current).Name_Last) & ! S (1 .. Last); ! begin ! Canonical_Case_File_Name (Name); ! ! -- If it matches, return the relative path ! ! if GNAT.Regexp.Match (Name, Iterator.Regexp) then ! return Name; ! end if; ! end; end if; end loop; *************** package body GNAT.Command_Line is *** 155,167 **** if In_Expansion then declare S : String := Expansion (Expansion_It); begin if S'Length /= 0 then return S; else In_Expansion := False; end if; - end; end if; --- 249,261 ---- if In_Expansion then declare S : String := Expansion (Expansion_It); + begin if S'Length /= 0 then return S; else In_Expansion := False; end if; end; end if; *************** package body GNAT.Command_Line is *** 206,212 **** Current_Argument := Current_Argument + 1; ! -- Could it be a file name with wild cards to expand ? if Do_Expansion then declare --- 300,306 ---- Current_Argument := Current_Argument + 1; ! -- Could it be a file name with wild cards to expand? if Do_Expansion then declare *************** package body GNAT.Command_Line is *** 238,253 **** ------------ function Getopt (Switches : String) return Character is ! Dummy : Boolean; begin ! -- If we have finished to parse the current command line item (there -- might be multiple switches in a single item), then go to the next -- element if Current_Argument > CL.Argument_Count or else (Current_Index > CL.Argument (Current_Argument)'Last ! and then not Goto_Next_Argument_In_Section) then return ASCII.NUL; end if; --- 332,347 ---- ------------ function Getopt (Switches : String) return Character is ! Dummy : Boolean; begin ! -- If we have finished parsing the current command line item (there -- might be multiple switches in a single item), then go to the next -- element if Current_Argument > CL.Argument_Count or else (Current_Index > CL.Argument (Current_Argument)'Last ! and then not Goto_Next_Argument_In_Section) then return ASCII.NUL; end if; *************** package body GNAT.Command_Line is *** 302,310 **** Length := Length + 1; end loop; ! if (Switches (Length - 1) = ':' ! or else Switches (Length - 1) = '?' ! or else Switches (Length - 1) = '!') and then Length > Index + 1 then Length := Length - 1; --- 396,405 ---- Length := Length + 1; end loop; ! if (Switches (Length - 1) = ':' or else ! Switches (Length - 1) = '=' or else ! Switches (Length - 1) = '?' or else ! Switches (Length - 1) = '!') and then Length > Index + 1 then Length := Length - 1; *************** package body GNAT.Command_Line is *** 314,321 **** if Current_Index + Length - 1 - Index <= Arg'Last and then ! Switches (Index .. Length - 1) = ! Arg (Current_Index .. Current_Index + Length - 1 - Index) and then Length - Index > Max_Length then Index_Switches := Index; --- 409,416 ---- if Current_Index + Length - 1 - Index <= Arg'Last and then ! Switches (Index .. Length - 1) = ! Arg (Current_Index .. Current_Index + Length - 1 - Index) and then Length - Index > Max_Length then Index_Switches := Index; *************** package body GNAT.Command_Line is *** 323,340 **** end if; -- Look for the next switch in Switches while Index <= Switches'Last and then Switches (Index) /= ' ' loop Index := Index + 1; end loop; - Index := Index + 1; end loop; End_Index := Current_Index + Max_Length - 1; ! -- If the switch is not accepted, skip it, unless we had a '*' in ! -- Switches if Index_Switches = 0 then if Switches (Switches'First) = '*' then --- 418,435 ---- end if; -- Look for the next switch in Switches + while Index <= Switches'Last and then Switches (Index) /= ' ' loop Index := Index + 1; end loop; + Index := Index + 1; end loop; End_Index := Current_Index + Max_Length - 1; ! -- If switch is not accepted, skip it, unless we had '*' in Switches if Index_Switches = 0 then if Switches (Switches'First) = '*' then *************** package body GNAT.Command_Line is *** 360,366 **** First => Current_Index, Last => End_Index); ! -- If switch needs an argument if Index_Switches + Max_Length <= Switches'Last then --- 455,461 ---- First => Current_Index, Last => End_Index); ! -- Case of switch needs an argument if Index_Switches + Max_Length <= Switches'Last then *************** package body GNAT.Command_Line is *** 390,395 **** --- 485,527 ---- raise Invalid_Parameter; end if; + when '=' => + + -- If the switch is of the form =xxx + + if End_Index < Arg'Last then + + if Arg (End_Index + 1) = '=' + and then End_Index + 1 < Arg'Last + then + Set_Parameter (The_Parameter, + Arg_Num => Current_Argument, + First => End_Index + 2, + Last => Arg'Last); + Dummy := Goto_Next_Argument_In_Section; + + else + Current_Index := End_Index + 1; + raise Invalid_Parameter; + end if; + + -- If the switch is of the form xxx + + elsif Section (Current_Argument + 1) /= 0 then + Set_Parameter + (The_Parameter, + Arg_Num => Current_Argument + 1, + First => 1, + Last => CL.Argument (Current_Argument + 1)'Last); + Current_Argument := Current_Argument + 1; + Is_Switch (Current_Argument) := True; + Dummy := Goto_Next_Argument_In_Section; + + else + Current_Index := End_Index + 1; + raise Invalid_Parameter; + end if; + when '!' => if End_Index < Arg'Last then *************** package body GNAT.Command_Line is *** 447,452 **** --- 579,585 ---- if Current_Argument > CL.Argument_Count then return False; end if; + Current_Argument := Current_Argument + 1; exit when Section (Current_Argument) = Current_Section; end loop; *************** package body GNAT.Command_Line is *** 478,483 **** --- 611,617 ---- then Current_Argument := Index + 1; Current_Index := 1; + if Current_Argument <= CL.Argument_Count then Current_Section := Section (Current_Argument); end if; *************** package body GNAT.Command_Line is *** 486,491 **** --- 620,626 ---- Index := Index + 1; end loop; + Current_Argument := Positive'Last; Current_Index := 2; -- so that Get_Argument returns nothing end Goto_Section; *************** package body GNAT.Command_Line is *** 529,536 **** for Index in 1 .. CL.Argument_Count loop if CL.Argument (Index)(1) = Switch_Character ! and then CL.Argument (Index) = Switch_Character ! & Section_Delimiters (Section_Index .. Last - 1) then Section (Index) := 0; Delimiter_Found := True; --- 664,673 ---- for Index in 1 .. CL.Argument_Count loop if CL.Argument (Index)(1) = Switch_Character ! and then ! CL.Argument (Index) = Switch_Character & ! Section_Delimiters ! (Section_Index .. Last - 1) then Section (Index) := 0; Delimiter_Found := True; *************** package body GNAT.Command_Line is *** 576,582 **** (Variable : out Parameter_Type; Arg_Num : Positive; First : Positive; ! Last : Positive) is begin Variable.Arg_Num := Arg_Num; Variable.First := First; --- 713,720 ---- (Variable : out Parameter_Type; Arg_Num : Positive; First : Positive; ! Last : Positive) ! is begin Variable.Arg_Num := Arg_Num; Variable.First := First; *************** package body GNAT.Command_Line is *** 595,610 **** is Directory_Separator : Character; pragma Import (C, Directory_Separator, "__gnat_dir_separator"); begin if Directory = "" then ! GNAT.Directory_Operations.Open ! (Iterator.Dir, "." & Directory_Separator); else ! GNAT.Directory_Operations.Open (Iterator.Dir, Directory); end if; ! Iterator.Regexp := GNAT.Regexp.Compile (Pattern, Basic_Regexp, True); end Start_Expansion; begin --- 733,796 ---- is Directory_Separator : Character; pragma Import (C, Directory_Separator, "__gnat_dir_separator"); + First : Positive := Pattern'First; + + Pat : String := Pattern; begin + Canonical_Case_File_Name (Pat); + Iterator.Current_Depth := 1; + + -- If Directory is unspecified, use the current directory ("./" or ".\") + if Directory = "" then ! Iterator.Dir_Name (1 .. 2) := "." & Directory_Separator; ! Iterator.Start := 3; ! else ! Iterator.Dir_Name (1 .. Directory'Length) := Directory; ! Iterator.Start := Directory'Length + 1; ! Canonical_Case_File_Name (Iterator.Dir_Name (1 .. Directory'Length)); ! ! -- Make sure that the last character is a directory separator ! ! if Directory (Directory'Last) /= Directory_Separator then ! Iterator.Dir_Name (Iterator.Start) := Directory_Separator; ! Iterator.Start := Iterator.Start + 1; ! end if; end if; ! Iterator.Levels (1).Name_Last := Iterator.Start - 1; ! ! -- Open the initial Directory, at depth 1 ! ! GNAT.Directory_Operations.Open ! (Iterator.Levels (1).Dir, Iterator.Dir_Name (1 .. Iterator.Start - 1)); ! ! -- If in the current directory and the pattern starts with "./", ! -- drop the "./" from the pattern. ! ! if Directory = "" and then Pat'Length > 2 ! and then Pat (Pat'First .. Pat'First + 1) = "./" ! then ! First := Pat'First + 2; ! end if; ! ! Iterator.Regexp := ! GNAT.Regexp.Compile (Pat (First .. Pat'Last), Basic_Regexp, True); ! ! Iterator.Maximum_Depth := 1; ! ! -- Maximum_Depth is equal to 1 plus the number of directory separators ! -- in the pattern. ! ! for Index in First .. Pat'Last loop ! if Pat (Index) = Directory_Separator then ! Iterator.Maximum_Depth := Iterator.Maximum_Depth + 1; ! exit when Iterator.Maximum_Depth = Max_Depth; ! end if; ! end loop; ! end Start_Expansion; begin diff -Nrc3pad gcc-3.2.3/gcc/ada/g-comlin.ads gcc-3.3/gcc/ada/g-comlin.ads *** gcc-3.2.3/gcc/ada/g-comlin.ads 2001-12-13 00:03:51.000000000 +0000 --- gcc-3.3/gcc/ada/g-comlin.ads 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1999-2002 Ada Core Technologies, 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- -- *************** *** 36,54 **** -- This package provides an interface to Ada.Command_Line, to do the -- parsing of command line arguments. Here is a small usage example: ! -- -- begin -- loop -- case Getopt ("a b: ad") is -- Accepts '-a', '-ad', or '-b argument' -- when ASCII.NUL => exit; ! -- -- when 'a' => -- if Full_Switch = "a" then -- Put_Line ("Got a"); -- else -- Put_Line ("Got ad"); -- end if; ! -- -- when 'b' => -- Put_Line ("Got b + " & Parameter); -- --- 35,53 ---- -- This package provides an interface to Ada.Command_Line, to do the -- parsing of command line arguments. Here is a small usage example: ! -- begin -- loop -- case Getopt ("a b: ad") is -- Accepts '-a', '-ad', or '-b argument' -- when ASCII.NUL => exit; ! -- when 'a' => -- if Full_Switch = "a" then -- Put_Line ("Got a"); -- else -- Put_Line ("Got ad"); -- end if; ! -- when 'b' => -- Put_Line ("Got b + " & Parameter); -- *************** *** 56,66 **** -- raise Program_Error; -- cannot occur! -- end case; -- end loop; ! -- -- loop -- declare -- S : constant String := Get_Argument (Do_Expansion => True); - -- begin -- exit when S'Length = 0; -- Put_Line ("Got " & S); --- 55,64 ---- -- raise Program_Error; -- cannot occur! -- end case; -- end loop; ! -- loop -- declare -- S : constant String := Get_Argument (Do_Expansion => True); -- begin -- exit when S'Length = 0; -- Put_Line ("Got " & S); *************** *** 71,97 **** -- when Invalid_Switch => Put_Line ("Invalid Switch " & Full_Switch); -- when Invalid_Parameter => Put_Line ("No parameter for " & Full_Switch); -- end; ! -- -- A more complicated example would involve the use of sections for the -- switches, as for instance in gnatmake. These sections are separated by -- special switches, chosen by the programer. Each section act as a -- command line of its own. ! -- -- begin -- Initialize_Option_Scan ('-', False, "largs bargs cargs"); -- loop ! -- -- same loop as above to get switches and arguments -- end loop; ! -- -- Goto_Section ("bargs"); -- loop ! -- -- same loop as above to get switches and arguments -- -- The supports switches in Get_Opt might be different -- end loop; ! -- -- Goto_Section ("cargs"); -- loop ! -- -- same loop as above to get switches and arguments -- -- The supports switches in Get_Opt might be different -- end loop; -- end; --- 69,95 ---- -- when Invalid_Switch => Put_Line ("Invalid Switch " & Full_Switch); -- when Invalid_Parameter => Put_Line ("No parameter for " & Full_Switch); -- end; ! -- A more complicated example would involve the use of sections for the -- switches, as for instance in gnatmake. These sections are separated by -- special switches, chosen by the programer. Each section act as a -- command line of its own. ! -- begin -- Initialize_Option_Scan ('-', False, "largs bargs cargs"); -- loop ! -- -- Same loop as above to get switches and arguments -- end loop; ! -- Goto_Section ("bargs"); -- loop ! -- -- Same loop as above to get switches and arguments -- -- The supports switches in Get_Opt might be different -- end loop; ! -- Goto_Section ("cargs"); -- loop ! -- -- Same loop as above to get switches and arguments -- -- The supports switches in Get_Opt might be different -- end loop; -- end; *************** package GNAT.Command_Line is *** 161,166 **** --- 159,166 ---- -- -- ':' The switch requires a parameter. There can optionally be a space -- on the command line between the switch and its parameter + -- '=' The switch requires a parameter. There can either be a '=' or a + -- space on the command line between the switch and its parameter -- '!' The switch requires a parameter, but there can be no space on the -- command line between the switch and its parameter -- '?' The switch may have an optional parameter. There can no space *************** package GNAT.Command_Line is *** 238,253 **** Pattern : String; Directory : String := ""; Basic_Regexp : Boolean := True); ! -- Initialize an wild card expansion. The next calls to Expansion will -- return the next file name in Directory which match Pattern (Pattern -- is a regular expression, using only the Unix shell and DOS syntax if ! -- Basic_Regexp is True. When Directory is an empty string, the current -- directory is searched. function Expansion (Iterator : Expansion_Iterator) return String; -- Return the next file in the directory matching the parameters given -- to Start_Expansion and updates Iterator to point to the next entry. ! -- Returns an empty string when there are no more files in the directory. -- If Expansion is called again after an empty string has been returned, -- then the exception GNAT.Directory_Operations.Directory_Error is raised. --- 238,264 ---- Pattern : String; Directory : String := ""; Basic_Regexp : Boolean := True); ! -- Initialize a wild card expansion. The next calls to Expansion will -- return the next file name in Directory which match Pattern (Pattern -- is a regular expression, using only the Unix shell and DOS syntax if ! -- Basic_Regexp is True). When Directory is an empty string, the current -- directory is searched. + -- + -- Pattern may contains directory separators (as in "src/*/*.ada"). + -- Subdirectories of Directory will also be searched, up to one + -- hundred levels deep. + -- + -- When Start_Expansion has been called, function Expansion should be + -- called repetitively until it returns an empty string, before + -- Start_Expansion can be called again with the same Expansion_Iterator + -- variable. function Expansion (Iterator : Expansion_Iterator) return String; -- Return the next file in the directory matching the parameters given -- to Start_Expansion and updates Iterator to point to the next entry. ! -- Returns an empty string when there are no more files in the directory ! -- and its subdirectories. ! -- -- If Expansion is called again after an empty string has been returned, -- then the exception GNAT.Directory_Operations.Directory_Error is raised. *************** package GNAT.Command_Line is *** 263,271 **** private type Expansion_Iterator is limited record ! Dir : GNAT.Directory_Operations.Dir_Type; Regexp : GNAT.Regexp.Regexp; end record; end GNAT.Command_Line; --- 274,312 ---- private + Max_Depth : constant := 100; + -- Maximum depth of subdirectories + + Max_Path_Length : constant := 1024; + -- Maximum length of relative path + + type Depth is range 1 .. Max_Depth; + + type Level is record + Name_Last : Natural := 0; + Dir : GNAT.Directory_Operations.Dir_Type; + end record; + + type Level_Array is array (Depth) of Level; + type Expansion_Iterator is limited record ! Start : Positive := 1; ! -- Position of the first character of the relative path to check ! -- against the pattern. ! ! Dir_Name : String (1 .. Max_Path_Length); ! ! Current_Depth : Depth := 1; ! ! Levels : Level_Array; ! Regexp : GNAT.Regexp.Regexp; + -- Regular expression built with the pattern + + Maximum_Depth : Depth := 1; + -- The maximum depth of directories, reflecting the number of + -- directory separators in the pattern. + end record; end GNAT.Command_Line; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-crc32.adb gcc-3.3/gcc/ada/g-crc32.adb *** gcc-3.2.3/gcc/ada/g-crc32.adb 2001-10-11 23:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/g-crc32.adb 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-crc32.ads gcc-3.3/gcc/ada/g-crc32.ads *** gcc-3.2.3/gcc/ada/g-crc32.ads 2001-10-11 23:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/g-crc32.ads 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-curexc.ads gcc-3.3/gcc/ada/g-curexc.ads *** gcc-3.2.3/gcc/ada/g-curexc.ads 2002-05-07 08:22:15.000000000 +0000 --- gcc-3.3/gcc/ada/g-curexc.ads 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1996-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-debpoo.adb gcc-3.3/gcc/ada/g-debpoo.adb *** gcc-3.2.3/gcc/ada/g-debpoo.adb 2002-05-04 03:28:05.000000000 +0000 --- gcc-3.3/gcc/ada/g-debpoo.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body GNAT.Debug_Pools is *** 68,74 **** (Pool : in out Debug_Pool; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Count; ! Alignment : Storage_Count) is begin Storage_Address := Alloc (size_t (Size_In_Storage_Elements)); --- 67,76 ---- (Pool : in out Debug_Pool; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Count; ! Alignment : Storage_Count) ! is ! pragma Warnings (Off, Alignment); ! begin Storage_Address := Alloc (size_t (Size_In_Storage_Elements)); *************** package body GNAT.Debug_Pools is *** 94,101 **** Size_In_Storage_Elements : Storage_Count; Alignment : Storage_Count) is procedure Free (Address : System.Address; Siz : Storage_Count); ! -- Faked free, that reset all the deallocated storage to "DEADBEEF" procedure Free (Address : System.Address; Siz : Storage_Count) is DB1 : constant Integer := 16#DEAD#; --- 96,105 ---- Size_In_Storage_Elements : Storage_Count; Alignment : Storage_Count) is + pragma Warnings (Off, Alignment); + procedure Free (Address : System.Address; Siz : Storage_Count); ! -- Fake free, that resets all the deallocated storage to "DEADBEEF" procedure Free (Address : System.Address; Siz : Storage_Count) is DB1 : constant Integer := 16#DEAD#; *************** package body GNAT.Debug_Pools is *** 151,156 **** --- 155,164 ---- Size_In_Storage_Elements : Storage_Count; Alignment : Storage_Count) is + pragma Warnings (Off, Pool); + pragma Warnings (Off, Size_In_Storage_Elements); + pragma Warnings (Off, Alignment); + S : State := Table.Get (Storage_Address); Max_Dim : constant := 3; Dim : Integer := 1; *************** package body GNAT.Debug_Pools is *** 216,221 **** --- 224,231 ---- ------------------ function Storage_Size (Pool : Debug_Pool) return Storage_Count is + pragma Warnings (Off, Pool); + begin return Storage_Count'Last; end Storage_Size; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-debpoo.ads gcc-3.3/gcc/ada/g-debpoo.ads *** gcc-3.2.3/gcc/ada/g-debpoo.ads 2002-05-04 03:28:05.000000000 +0000 --- gcc-3.3/gcc/ada/g-debpoo.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-debuti.adb gcc-3.3/gcc/ada/g-debuti.adb *** gcc-3.2.3/gcc/ada/g-debuti.adb 2002-05-07 08:22:15.000000000 +0000 --- gcc-3.3/gcc/ada/g-debuti.adb 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-debuti.ads gcc-3.3/gcc/ada/g-debuti.ads *** gcc-3.2.3/gcc/ada/g-debuti.ads 2002-05-07 08:22:15.000000000 +0000 --- gcc-3.3/gcc/ada/g-debuti.ads 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1995-1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-diopit.adb gcc-3.3/gcc/ada/g-diopit.adb *** gcc-3.2.3/gcc/ada/g-diopit.adb 2001-12-11 22:50:45.000000000 +0000 --- gcc-3.3/gcc/ada/g-diopit.adb 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-diopit.ads gcc-3.3/gcc/ada/g-diopit.ads *** gcc-3.2.3/gcc/ada/g-diopit.ads 2001-12-11 22:50:45.000000000 +0000 --- gcc-3.3/gcc/ada/g-diopit.ads 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-dirope.adb gcc-3.3/gcc/ada/g-dirope.adb *** gcc-3.2.3/gcc/ada/g-dirope.adb 2001-12-12 21:26:45.000000000 +0000 --- gcc-3.3/gcc/ada/g-dirope.adb 2002-05-31 18:08:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.6 $ -- -- -- Copyright (C) 1998-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** package body GNAT.Directory_Operations i *** 460,470 **** end File_Name; --------------------- -- Get_Current_Dir -- --------------------- Max_Path : Integer; ! pragma Import (C, Max_Path, "max_path_len"); function Get_Current_Dir return Dir_Name_Str is Current_Dir : String (1 .. Max_Path + 1); --- 459,508 ---- end File_Name; --------------------- + -- Format_Pathname -- + --------------------- + + function Format_Pathname + (Path : Path_Name; + Style : Path_Style := System_Default) + return String + is + N_Path : String := Path; + K : Positive := N_Path'First; + Prev_Dirsep : Boolean := False; + + begin + for J in Path'Range loop + + if Strings.Maps.Is_In (Path (J), Dir_Seps) then + if not Prev_Dirsep then + case Style is + when UNIX => N_Path (K) := '/'; + when DOS => N_Path (K) := '\'; + when System_Default => N_Path (K) := Dir_Separator; + end case; + + K := K + 1; + end if; + + Prev_Dirsep := True; + + else + N_Path (K) := Path (J); + K := K + 1; + Prev_Dirsep := False; + end if; + end loop; + + return N_Path (N_Path'First .. K - 1); + end Format_Pathname; + + --------------------- -- Get_Current_Dir -- --------------------- Max_Path : Integer; ! pragma Import (C, Max_Path, "__gnat_max_path_len"); function Get_Current_Dir return Dir_Name_Str is Current_Dir : String (1 .. Max_Path + 1); *************** package body GNAT.Directory_Operations i *** 522,567 **** end if; end Make_Dir; - ------------------------ - -- Normalize_Pathname -- - ------------------------ - - function Normalize_Pathname - (Path : Path_Name; - Style : Path_Style := System_Default) - return String - is - N_Path : String := Path; - K : Positive := N_Path'First; - Prev_Dirsep : Boolean := False; - - begin - for J in Path'Range loop - - if Strings.Maps.Is_In (Path (J), Dir_Seps) then - if not Prev_Dirsep then - - case Style is - when UNIX => N_Path (K) := '/'; - when DOS => N_Path (K) := '\'; - when System_Default => N_Path (K) := Dir_Separator; - end case; - - K := K + 1; - end if; - - Prev_Dirsep := True; - - else - N_Path (K) := Path (J); - K := K + 1; - Prev_Dirsep := False; - end if; - end loop; - - return N_Path (N_Path'First .. K - 1); - end Normalize_Pathname; - ---------- -- Open -- ---------- --- 560,565 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-dirope.ads gcc-3.3/gcc/ada/g-dirope.ads *** gcc-3.2.3/gcc/ada/g-dirope.ads 2001-12-12 21:26:44.000000000 +0000 --- gcc-3.3/gcc/ada/g-dirope.ads 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 1998-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** package GNAT.Directory_Operations is *** 136,142 **** type Path_Style is (UNIX, DOS, System_Default); ! function Normalize_Pathname (Path : Path_Name; Style : Path_Style := System_Default) return Path_Name; --- 135,141 ---- type Path_Style is (UNIX, DOS, System_Default); ! function Format_Pathname (Path : Path_Name; Style : Path_Style := System_Default) return Path_Name; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-dyntab.adb gcc-3.3/gcc/ada/g-dyntab.adb *** gcc-3.2.3/gcc/ada/g-dyntab.adb 2001-10-02 14:15:30.000000000 +0000 --- gcc-3.3/gcc/ada/g-dyntab.adb 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** *** 32,46 **** -- -- ------------------------------------------------------------------------------ ! with System; use System; package body GNAT.Dynamic_Tables is Min : constant Integer := Integer (Table_Low_Bound); -- Subscript of the minimum entry in the currently allocated table - type size_t is new Integer; - ----------------------- -- Local Subprograms -- ----------------------- --- 31,45 ---- -- -- ------------------------------------------------------------------------------ ! with System; use System; ! with System.Memory; use System.Memory; ! with System.Address_To_Access_Conversions; package body GNAT.Dynamic_Tables is Min : constant Integer := Integer (Table_Low_Bound); -- Subscript of the minimum entry in the currently allocated table ----------------------- -- Local Subprograms -- ----------------------- *************** package body GNAT.Dynamic_Tables is *** 50,55 **** --- 49,66 ---- -- in Max. Works correctly to do an initial allocation if the table -- is currently null. + package Table_Conversions is + new System.Address_To_Access_Conversions (Big_Table_Type); + -- Address and Access conversions for a Table object. + + function To_Address (Table : Table_Ptr) return Address; + pragma Inline (To_Address); + -- Returns the Address for the Table object. + + function To_Pointer (Table : Address) return Table_Ptr; + pragma Inline (To_Pointer); + -- Returns the Access pointer for the Table object. + -------------- -- Allocate -- -------------- *************** package body GNAT.Dynamic_Tables is *** 90,100 **** ---------- procedure Free (T : in out Instance) is - procedure free (T : Table_Ptr); - pragma Import (C, free); - begin ! free (T.Table); T.Table := null; T.P.Length := 0; end Free; --- 101,108 ---- ---------- procedure Free (T : in out Instance) is begin ! Free (To_Address (T.Table)); T.Table := null; T.P.Length := 0; end Free; *************** package body GNAT.Dynamic_Tables is *** 155,172 **** ---------------- procedure Reallocate (T : in out Instance) is - - function realloc - (memblock : Table_Ptr; - size : size_t) - return Table_Ptr; - pragma Import (C, realloc); - - function malloc - (size : size_t) - return Table_Ptr; - pragma Import (C, malloc); - New_Size : size_t; begin --- 163,168 ---- *************** package body GNAT.Dynamic_Tables is *** 182,194 **** (Table_Type'Component_Size / Storage_Unit)); if T.Table = null then ! T.Table := malloc (New_Size); elsif New_Size > 0 then T.Table := ! realloc ! (memblock => T.Table, ! size => New_Size); end if; if T.P.Length /= 0 and then T.Table = null then --- 178,189 ---- (Table_Type'Component_Size / Storage_Unit)); if T.Table = null then ! T.Table := To_Pointer (Alloc (New_Size)); elsif New_Size > 0 then T.Table := ! To_Pointer (Realloc (Ptr => To_Address (T.Table), ! Size => New_Size)); end if; if T.P.Length /= 0 and then T.Table = null then *************** package body GNAT.Dynamic_Tables is *** 243,246 **** --- 238,260 ---- end if; end Set_Last; + ---------------- + -- To_Address -- + ---------------- + + function To_Address (Table : Table_Ptr) return Address is + begin + return Table_Conversions.To_Address + (Table_Conversions.Object_Pointer (Table)); + end To_Address; + + ---------------- + -- To_Pointer -- + ---------------- + + function To_Pointer (Table : Address) return Table_Ptr is + begin + return Table_Ptr (Table_Conversions.To_Pointer (Table)); + end To_Pointer; + end GNAT.Dynamic_Tables; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-dyntab.ads gcc-3.3/gcc/ada/g-dyntab.ads *** gcc-3.2.3/gcc/ada/g-dyntab.ads 2001-10-28 12:55:50.000000000 +0000 --- gcc-3.3/gcc/ada/g-dyntab.ads 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-enblsp.adb gcc-3.3/gcc/ada/g-enblsp.adb *** gcc-3.2.3/gcc/ada/g-enblsp.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/g-enblsp.adb 2002-03-14 10:59:18.000000000 +0000 *************** *** 0 **** --- 1,116 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT LIBRARY COMPONENTS -- + -- -- + -- G N A T . E X P E C T . N O N _ B L O C K I N G _ S P A W N -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2002 Ada Core Technologies, 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). -- + -- -- + ------------------------------------------------------------------------------ + + -- This is the default version. Used everywhere except VMS. + + separate (GNAT.Expect) + procedure Non_Blocking_Spawn + (Descriptor : out Process_Descriptor'Class; + Command : String; + Args : GNAT.OS_Lib.Argument_List; + Buffer_Size : Natural := 4096; + Err_To_Out : Boolean := False) + is + function Fork return Process_Id; + pragma Import (C, Fork, "__gnat_expect_fork"); + -- Starts a new process if possible. + -- See the Unix command fork for more information. On systems that + -- don't support this capability (Windows...), this command does + -- nothing, and Fork will return Null_Pid. + + Pipe1, Pipe2, Pipe3 : aliased Pipe_Type; + + Arg : String_Access; + Arg_List : aliased array (1 .. Args'Length + 2) of System.Address; + + Command_With_Path : String_Access; + + begin + -- Create the rest of the pipes + + Set_Up_Communications + (Descriptor, Err_To_Out, Pipe1'Access, Pipe2'Access, Pipe3'Access); + + -- Fork a new process + + Descriptor.Pid := Fork; + + -- Are we now in the child (or, for Windows, still in the common + -- process). + + if Descriptor.Pid = Null_Pid then + + Command_With_Path := Locate_Exec_On_Path (Command); + + -- Prepare an array of arguments to pass to C + Arg := new String (1 .. Command_With_Path'Length + 1); + Arg (1 .. Command_With_Path'Length) := Command_With_Path.all; + Arg (Arg'Last) := ASCII.Nul; + Arg_List (1) := Arg.all'Address; + + for J in Args'Range loop + Arg := new String (1 .. Args (J)'Length + 1); + Arg (1 .. Args (J)'Length) := Args (J).all; + Arg (Arg'Last) := ASCII.Nul; + Arg_List (J + 2 - Args'First) := Arg.all'Address; + end loop; + + Arg_List (Arg_List'Last) := System.Null_Address; + + -- This does not return on Unix systems + + Set_Up_Child_Communications + (Descriptor, Pipe1, Pipe2, Pipe3, Command_With_Path.all, + Arg_List'Address); + + Free (Command_With_Path); + end if; + + -- Did we have an error when spawning the child ? + + if Descriptor.Pid < Null_Pid then + null; + else + -- We are now in the parent process + + Set_Up_Parent_Communications (Descriptor, Pipe1, Pipe2, Pipe3); + end if; + + -- Create the buffer + + Descriptor.Buffer_Size := Buffer_Size; + + if Buffer_Size /= 0 then + Descriptor.Buffer := new String (1 .. Positive (Buffer_Size)); + end if; + end Non_Blocking_Spawn; diff -Nrc3pad gcc-3.2.3/gcc/ada/get_targ.adb gcc-3.3/gcc/ada/get_targ.adb *** gcc-3.2.3/gcc/ada/get_targ.adb 2002-05-07 08:22:17.000000000 +0000 --- gcc-3.3/gcc/ada/get_targ.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/get_targ.ads gcc-3.3/gcc/ada/get_targ.ads *** gcc-3.2.3/gcc/ada/get_targ.ads 2002-05-04 03:28:06.000000000 +0000 --- gcc-3.3/gcc/ada/get_targ.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-except.ads gcc-3.3/gcc/ada/g-except.ads *** gcc-3.2.3/gcc/ada/g-except.ads 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-except.ads 2002-03-14 10:59:18.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-exctra.adb gcc-3.3/gcc/ada/g-exctra.adb *** gcc-3.2.3/gcc/ada/g-exctra.adb 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-exctra.adb 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-exctra.ads gcc-3.3/gcc/ada/g-exctra.ads *** gcc-3.2.3/gcc/ada/g-exctra.ads 2001-12-16 01:13:40.000000000 +0000 --- gcc-3.3/gcc/ada/g-exctra.ads 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-expect.adb gcc-3.3/gcc/ada/g-expect.adb *** gcc-3.2.3/gcc/ada/g-expect.adb 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-expect.adb 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 2000-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2000-2002 Ada Core Technologies, 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- -- *************** *** 32,50 **** -- -- ------------------------------------------------------------------------------ with GNAT.IO; with GNAT.OS_Lib; use GNAT.OS_Lib; with GNAT.Regpat; use GNAT.Regpat; ! with System; use System; ! with Unchecked_Conversion; with Unchecked_Deallocation; - with Ada.Calendar; use Ada.Calendar; package body GNAT.Expect is - function To_Pid is new - Unchecked_Conversion (OS_Lib.Process_Id, Process_Id); - type Array_Of_Pd is array (Positive range <>) of Process_Descriptor_Access; procedure Expect_Internal --- 31,47 ---- -- -- ------------------------------------------------------------------------------ + with System; use System; + with Ada.Calendar; use Ada.Calendar; + with GNAT.IO; with GNAT.OS_Lib; use GNAT.OS_Lib; with GNAT.Regpat; use GNAT.Regpat; ! with Unchecked_Deallocation; package body GNAT.Expect is type Array_Of_Pd is array (Positive range <>) of Process_Descriptor_Access; procedure Expect_Internal *************** package body GNAT.Expect is *** 96,104 **** pragma Import (C, Create_Pipe, "__gnat_pipe"); function Read ! (Fd : File_Descriptor; ! A : System.Address; ! N : Integer) return Integer; pragma Import (C, Read, "read"); -- Read N bytes to address A from file referenced by FD. Returned value -- is count of bytes actually read, which can be less than N at EOF. --- 93,102 ---- pragma Import (C, Create_Pipe, "__gnat_pipe"); function Read ! (Fd : File_Descriptor; ! A : System.Address; ! N : Integer) ! return Integer; pragma Import (C, Read, "read"); -- Read N bytes to address A from file referenced by FD. Returned value -- is count of bytes actually read, which can be less than N at EOF. *************** package body GNAT.Expect is *** 108,116 **** -- Close a file given its file descriptor. function Write ! (Fd : File_Descriptor; ! A : System.Address; ! N : Integer) return Integer; pragma Import (C, Write, "write"); -- Read N bytes to address A from file referenced by FD. Returned value -- is count of bytes actually read, which can be less than N at EOF. --- 106,115 ---- -- Close a file given its file descriptor. function Write ! (Fd : File_Descriptor; ! A : System.Address; ! N : Integer) ! return Integer; pragma Import (C, Write, "write"); -- Read N bytes to address A from file referenced by FD. Returned value -- is count of bytes actually read, which can be less than N at EOF. *************** package body GNAT.Expect is *** 128,133 **** --- 127,136 ---- -- -- Out_Is_Set is set to 1 if data was available, 0 otherwise. + function Waitpid (Pid : Process_Id) return Integer; + pragma Import (C, Waitpid, "__gnat_waitpid"); + -- Wait for a specific process id, and return its exit code. + --------- -- "+" -- --------- *************** package body GNAT.Expect is *** 171,178 **** if Current = null then Descriptor.Filters := new Filter_List_Elem' ! (Filter => Filter, Filter_On => Filter_On, ! User_Data => User_Data, Next => null); else Current.Next := new Filter_List_Elem' --- 174,181 ---- if Current = null then Descriptor.Filters := new Filter_List_Elem' ! (Filter => Filter, Filter_On => Filter_On, ! User_Data => User_Data, Next => null); else Current.Next := new Filter_List_Elem' *************** package body GNAT.Expect is *** 218,227 **** -- Close -- ----------- ! procedure Close (Descriptor : in out Process_Descriptor) is ! Success : Boolean; ! Pid : OS_Lib.Process_Id; ! begin Close (Descriptor.Input_Fd); --- 221,230 ---- -- Close -- ----------- ! procedure Close ! (Descriptor : in out Process_Descriptor; ! Status : out Integer) ! is begin Close (Descriptor.Input_Fd); *************** package body GNAT.Expect is *** 231,244 **** Close (Descriptor.Output_Fd); ! -- ??? Should have timeouts for different signals, see ddd Kill (Descriptor.Pid, 9); GNAT.OS_Lib.Free (Descriptor.Buffer); Descriptor.Buffer_Size := 0; ! Wait_Process (Pid, Success); ! Descriptor.Pid := To_Pid (Pid); end Close; ------------ --- 234,252 ---- Close (Descriptor.Output_Fd); ! -- ??? Should have timeouts for different signals Kill (Descriptor.Pid, 9); GNAT.OS_Lib.Free (Descriptor.Buffer); Descriptor.Buffer_Size := 0; ! Status := Waitpid (Descriptor.Pid); ! end Close; ! ! procedure Close (Descriptor : in out Process_Descriptor) is ! Status : Integer; ! begin ! Close (Descriptor, Status); end Close; ------------ *************** package body GNAT.Expect is *** 545,551 **** Num_Descriptors : Integer; Buffer_Size : Integer := 0; ! N : Integer; type File_Descriptor_Array is array (Descriptors'Range) of File_Descriptor; --- 553,559 ---- Num_Descriptors : Integer; Buffer_Size : Integer := 0; ! N : Integer; type File_Descriptor_Array is array (Descriptors'Range) of File_Descriptor; *************** package body GNAT.Expect is *** 849,927 **** Buffer_Size : Natural := 4096; Err_To_Out : Boolean := False) is ! function Fork return Process_Id; ! pragma Import (C, Fork, "__gnat_expect_fork"); ! -- Starts a new process if possible. ! -- See the Unix command fork for more information. On systems that ! -- don't support this capability (Windows...), this command does ! -- nothing, and Fork will return Null_Pid. ! ! Pipe1, Pipe2, Pipe3 : aliased Pipe_Type; ! ! Arg : String_Access; ! Arg_List : aliased array (1 .. Args'Length + 2) of System.Address; ! ! Command_With_Path : String_Access; ! ! begin ! -- Create the rest of the pipes ! ! Set_Up_Communications ! (Descriptor, Err_To_Out, Pipe1'Access, Pipe2'Access, Pipe3'Access); ! ! -- Fork a new process ! ! Descriptor.Pid := Fork; ! ! -- Are we now in the child (or, for Windows, still in the common ! -- process). ! ! if Descriptor.Pid = Null_Pid then ! ! Command_With_Path := Locate_Exec_On_Path (Command); ! ! -- Prepare an array of arguments to pass to C ! Arg := new String (1 .. Command_With_Path'Length + 1); ! Arg (1 .. Command_With_Path'Length) := Command_With_Path.all; ! Arg (Arg'Last) := ASCII.Nul; ! Arg_List (1) := Arg.all'Address; ! ! for J in Args'Range loop ! Arg := new String (1 .. Args (J)'Length + 1); ! Arg (1 .. Args (J)'Length) := Args (J).all; ! Arg (Arg'Last) := ASCII.Nul; ! Arg_List (J + 2 - Args'First) := Arg.all'Address; ! end loop; ! ! Arg_List (Arg_List'Last) := System.Null_Address; ! ! -- This does not return on Unix systems ! ! Set_Up_Child_Communications ! (Descriptor, Pipe1, Pipe2, Pipe3, Command_With_Path.all, ! Arg_List'Address); ! ! Free (Command_With_Path); ! end if; ! ! -- Did we have an error when spawning the child ? ! ! if Descriptor.Pid < Null_Pid then ! null; ! else ! -- We are now in the parent process ! ! Set_Up_Parent_Communications (Descriptor, Pipe1, Pipe2, Pipe3); ! end if; ! ! -- Create the buffer ! ! Descriptor.Buffer_Size := Buffer_Size; ! ! if Buffer_Size /= 0 then ! Descriptor.Buffer := new String (1 .. Positive (Buffer_Size)); ! end if; ! end Non_Blocking_Spawn; ------------------------- -- Reinitialize_Buffer -- --- 857,863 ---- Buffer_Size : Natural := 4096; Err_To_Out : Boolean := False) is ! separate; ------------------------- -- Reinitialize_Buffer -- *************** package body GNAT.Expect is *** 1061,1067 **** Cmd : in String; Args : in System.Address) is ! Input, Output, Error : File_Descriptor; begin -- Since Windows does not have a separate fork/exec, we need to --- 997,1007 ---- Cmd : in String; Args : in System.Address) is ! pragma Warnings (Off, Pid); ! ! Input : File_Descriptor; ! Output : File_Descriptor; ! Error : File_Descriptor; begin -- Since Windows does not have a separate fork/exec, we need to *************** package body GNAT.Expect is *** 1084,1090 **** Dup2 (Pipe2.Output, GNAT.OS_Lib.Standout); Dup2 (Pipe3.Output, GNAT.OS_Lib.Standerr); ! Portable_Execvp (Cmd & ASCII.Nul, Args); -- The following commands are not executed on Unix systems, and are -- only required for Windows systems. We are now in the parent process. --- 1024,1030 ---- Dup2 (Pipe2.Output, GNAT.OS_Lib.Standout); Dup2 (Pipe3.Output, GNAT.OS_Lib.Standerr); ! Portable_Execvp (Pid.Pid'Access, Cmd & ASCII.Nul, Args); -- The following commands are not executed on Unix systems, and are -- only required for Windows systems. We are now in the parent process. *************** package body GNAT.Expect is *** 1108,1114 **** Err_To_Out : Boolean; Pipe1 : access Pipe_Type; Pipe2 : access Pipe_Type; ! Pipe3 : access Pipe_Type) is begin -- Create the pipes --- 1048,1055 ---- Err_To_Out : Boolean; Pipe1 : access Pipe_Type; Pipe2 : access Pipe_Type; ! Pipe3 : access Pipe_Type) ! is begin -- Create the pipes *************** package body GNAT.Expect is *** 1144,1149 **** --- 1085,1092 ---- Pipe2 : in out Pipe_Type; Pipe3 : in out Pipe_Type) is + pragma Warnings (Off, Pid); + begin Close (Pipe1.Input); Close (Pipe2.Output); *************** package body GNAT.Expect is *** 1159,1164 **** --- 1102,1110 ---- Str : String; User_Data : System.Address := System.Null_Address) is + pragma Warnings (Off, Descriptor); + pragma Warnings (Off, User_Data); + begin GNAT.IO.Put (Str); end Trace_Filter; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-expect.ads gcc-3.3/gcc/ada/g-expect.ads *** gcc-3.2.3/gcc/ada/g-expect.ads 2001-12-16 01:13:40.000000000 +0000 --- gcc-3.3/gcc/ada/g-expect.ads 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 2000-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 2000-2002 Ada Core Technologies, 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- -- *************** *** 48,54 **** -- -- Usage example: -- ! -- Non_Blocking_Spawn (Fd, "ftp machine@domaine"); -- Timeout := 10000; -- 10 seconds -- Expect (Fd, Result, Regexp_Array'(+"\(user\)", +"\(passwd\)"), -- Timeout); --- 47,55 ---- -- -- Usage example: -- ! -- Non_Blocking_Spawn ! -- (Fd, "ftp", ! -- (1 => new String' ("machine@domaine"))); -- Timeout := 10000; -- 10 seconds -- Expect (Fd, Result, Regexp_Array'(+"\(user\)", +"\(passwd\)"), -- Timeout); *************** *** 78,89 **** -- processes, where you can give your own input and output filters every -- time characters are read from or written to the process. -- ! -- procedure My_Filter (Descriptor : Process_Descriptor; Str : String) is -- begin -- Put_Line (Str); -- end; -- ! -- Fd := Non_Blocking_Spawn ("tail -f a_file"); -- Add_Filter (Fd, My_Filter'Access, Output); -- Expect (Fd, Result, "", 0); -- wait forever -- --- 79,96 ---- -- processes, where you can give your own input and output filters every -- time characters are read from or written to the process. -- ! -- procedure My_Filter ! -- (Descriptor : Process_Descriptor'Class; ! -- Str : String; ! -- User_Data : System.Address) ! -- is -- begin -- Put_Line (Str); -- end; -- ! -- Non_Blocking_Spawn ! -- (Fd, "tail", ! -- (new String' ("-f"), new String' ("a_file"))); -- Add_Filter (Fd, My_Filter'Access, Output); -- Expect (Fd, Result, "", 0); -- wait forever -- *************** *** 98,105 **** -- existing output, it is recommended to do something like: -- -- Expect (Fd, Result, ".*", Timeout => 0); ! -- -- empty the buffer, by matching everything (after checking ! -- -- if there was any input). -- Send (Fd, "command"); -- Expect (Fd, Result, ".."); -- match only on the output of command -- --- 105,113 ---- -- existing output, it is recommended to do something like: -- -- Expect (Fd, Result, ".*", Timeout => 0); ! -- -- Empty the buffer, by matching everything (after checking ! -- -- if there was any input). ! -- -- Send (Fd, "command"); -- Expect (Fd, Result, ".."); -- match only on the output of command -- *************** package GNAT.Expect is *** 179,184 **** --- 187,198 ---- -- does the 'wait' command required to clean up the process table. -- This also frees the buffer associated with the process id. + procedure Close + (Descriptor : in out Process_Descriptor; + Status : out Integer); + -- Same as above, but also returns the exit status of the process, + -- as set for example by the procedure GNAT.OS_Lib.OS_Exit. + procedure Send_Signal (Descriptor : Process_Descriptor; Signal : Integer); *************** package GNAT.Expect is *** 510,529 **** -- valid process that died while Expect was executing. It is also raised -- when Expect receives an end-of-file. - ------------------------ - -- Internal functions -- - ------------------------ - - -- The following subprograms are provided so that it is easy to write - -- extensions to this package. However, clients should not use these - -- routines directly. - - procedure Portable_Execvp (Cmd : String; Args : System.Address); - -- Executes, in a portable way, the command Cmd (full path must be - -- specified), with the given Args. Note that the first element in Args - -- must be the executable name, and the last element must be a null - -- pointer - private type Filter_List_Elem; type Filter_List is access Filter_List_Elem; --- 524,529 ---- *************** private *** 568,574 **** -- newly created process. type Process_Descriptor is tagged record ! Pid : Process_Id := Invalid_Pid; Input_Fd : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD; Output_Fd : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD; Error_Fd : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD; --- 568,574 ---- -- newly created process. type Process_Descriptor is tagged record ! Pid : aliased Process_Id := Invalid_Pid; Input_Fd : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD; Output_Fd : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD; Error_Fd : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD; *************** private *** 584,589 **** --- 584,601 ---- Last_Match_End : Natural := 0; end record; + -- The following subprogram is provided for use in the body, and also + -- possibly in future child units providing extensions to this package. + + procedure Portable_Execvp + (Pid : access Process_Id; + Cmd : String; + Args : System.Address); pragma Import (C, Portable_Execvp, "__gnat_expect_portable_execvp"); + -- Executes, in a portable way, the command Cmd (full path must be + -- specified), with the given Args. Args must be an array of string + -- pointers. Note that the first element in Args must be the executable + -- name, and the last element must be a null pointer. The returned value + -- in Pid is the process ID, or zero if not supported on the platform. end GNAT.Expect; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-flocon.ads gcc-3.3/gcc/ada/g-flocon.ads *** gcc-3.2.3/gcc/ada/g-flocon.ads 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-flocon.ads 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-hesora.adb gcc-3.3/gcc/ada/g-hesora.adb *** gcc-3.2.3/gcc/ada/g-hesora.adb 2002-05-07 08:22:15.000000000 +0000 --- gcc-3.3/gcc/ada/g-hesora.adb 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1995-1999 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-hesora.ads gcc-3.3/gcc/ada/g-hesora.ads *** gcc-3.2.3/gcc/ada/g-hesora.ads 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-hesora.ads 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1995-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-hesorg.adb gcc-3.3/gcc/ada/g-hesorg.adb *** gcc-3.2.3/gcc/ada/g-hesorg.adb 2002-05-07 08:22:16.000000000 +0000 --- gcc-3.3/gcc/ada/g-hesorg.adb 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1995-1999 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-hesorg.ads gcc-3.3/gcc/ada/g-hesorg.ads *** gcc-3.2.3/gcc/ada/g-hesorg.ads 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-hesorg.ads 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1995-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-htable.adb gcc-3.3/gcc/ada/g-htable.adb *** gcc-3.2.3/gcc/ada/g-htable.adb 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-htable.adb 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1995-1999 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-htable.ads gcc-3.3/gcc/ada/g-htable.ads *** gcc-3.2.3/gcc/ada/g-htable.ads 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-htable.ads 2002-03-14 10:59:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1995-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gigi.h gcc-3.3/gcc/ada/gigi.h *** gcc-3.2.3/gcc/ada/gigi.h 2002-05-04 03:28:06.000000000 +0000 --- gcc-3.3/gcc/ada/gigi.h 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** * * * C Header File * * * - * $Revision: 1.3.10.1 $ * * ! * Copyright (C) 1992-2001 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- * --- 6,13 ---- * * * C Header File * * * * * ! * Copyright (C) 1992-2002 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- * *************** extern void update_setjmp_buf PARAMS ((t *** 60,77 **** default. */ extern int default_pass_by_ref PARAMS ((tree)); ! /* GNU_TYPE is the type of a subprogram parameter. Determine from the type if ! it should be passed by reference. */ extern int must_pass_by_ref PARAMS ((tree)); ! /* Elaboration routines for the front end */ ! extern void elab_all_gnat PARAMS ((void)); ! /* Emit a label UNITNAME_LABEL and specify that it is part of source ! file FILENAME. If this is being written for SGI's Workshop ! debugger, and we are writing Dwarf2 debugging information, add ! additional debug info. */ ! extern void emit_unit_label PARAMS ((char *, char *)); /* Initialize DUMMY_NODE_TABLE. */ extern void init_dummy_type PARAMS ((void)); --- 59,73 ---- default. */ extern int default_pass_by_ref PARAMS ((tree)); ! /* GNU_TYPE is the type of a subprogram parameter. Determine from the type ! if it should be passed by reference. */ extern int must_pass_by_ref PARAMS ((tree)); ! /* This function returns the version of GCC being used. Here it's GCC 3. */ ! extern int gcc_version PARAMS ((void)); ! /* Elaboration routines for the front end. */ ! extern void elab_all_gnat PARAMS ((void)); /* Initialize DUMMY_NODE_TABLE. */ extern void init_dummy_type PARAMS ((void)); *************** extern const char *ref_filename; *** 163,173 **** /* List of TREE_LIST nodes representing a block stack. TREE_VALUE of each gives the variable used for the setjmp buffer in the current block, if any. */ ! extern tree gnu_block_stack; ! ! /* For most front-ends, this is the parser for the language. For us, we ! process the GNAT tree. */ ! extern int yyparse PARAMS ((void)); /* This is the main program of the back-end. It sets up all the table structures and then generates code. */ --- 159,165 ---- /* List of TREE_LIST nodes representing a block stack. TREE_VALUE of each gives the variable used for the setjmp buffer in the current block, if any. */ ! extern GTY(()) tree gnu_block_stack; /* This is the main program of the back-end. It sets up all the table structures and then generates code. */ *************** extern void post_error_ne_tree_2 PARAMS *** 235,243 **** /* Set the node for a second '&' in the error message. */ extern void set_second_error_entity PARAMS ((Entity_Id)); ! /* Surround EXP with a SAVE_EXPR, but handle unconstrained objects specially ! since it doesn't make any sense to put them in a SAVE_EXPR. */ ! extern tree make_save_expr PARAMS ((tree)); /* Signal abort, with "Gigi abort" as the error label, and error_gnat_node as the relevant node that provides the location info for the error. --- 227,234 ---- /* Set the node for a second '&' in the error message. */ extern void set_second_error_entity PARAMS ((Entity_Id)); ! /* Protect EXP from multiple evaluation. This may make a SAVE_EXPR. */ ! extern tree protect_multiple_eval PARAMS ((tree)); /* Signal abort, with "Gigi abort" as the error label, and error_gnat_node as the relevant node that provides the location info for the error. *************** enum standard_datatypes *** 355,366 **** ADT_setjmp_decl, ADT_longjmp_decl, ADT_raise_nodefer_decl, - ADT_raise_constraint_error_decl, - ADT_raise_program_error_decl, - ADT_raise_storage_error_decl, ADT_LAST}; ! extern tree gnat_std_decls[(int) ADT_LAST]; #define longest_float_type_node gnat_std_decls[(int) ADT_longest_float_type] #define void_type_decl_node gnat_std_decls[(int) ADT_void_type_decl] --- 346,355 ---- ADT_setjmp_decl, ADT_longjmp_decl, ADT_raise_nodefer_decl, ADT_LAST}; ! extern GTY(()) tree gnat_std_decls[(int) ADT_LAST]; ! extern GTY(()) tree gnat_raise_decls[(int) LAST_REASON_CODE + 1]; #define longest_float_type_node gnat_std_decls[(int) ADT_longest_float_type] #define void_type_decl_node gnat_std_decls[(int) ADT_void_type_decl] *************** extern tree gnat_std_decls[(int) ADT_LAS *** 378,389 **** #define setjmp_decl gnat_std_decls[(int) ADT_setjmp_decl] #define longjmp_decl gnat_std_decls[(int) ADT_longjmp_decl] #define raise_nodefer_decl gnat_std_decls[(int) ADT_raise_nodefer_decl] - #define raise_constraint_error_decl \ - gnat_std_decls[(int) ADT_raise_constraint_error_decl] - #define raise_program_error_decl \ - gnat_std_decls[(int) ADT_raise_program_error_decl] - #define raise_storage_error_decl \ - gnat_std_decls[(int) ADT_raise_storage_error_decl] /* Routines expected by the gcc back-end. They must have exactly the same prototype and names as below. */ --- 367,372 ---- *************** extern tree pushdecl PARAMS ((tree)); *** 435,470 **** in the gcc back-end and initialize the global binding level. */ extern void gnat_init_decl_processing PARAMS ((void)); extern void init_gigi_decls PARAMS ((tree, tree)); /* Return an integer type with the number of bits of precision given by PRECISION. UNSIGNEDP is nonzero if the type is unsigned; otherwise it is a signed type. */ ! extern tree type_for_size PARAMS ((unsigned, int)); /* Return a data type that has machine mode MODE. UNSIGNEDP selects an unsigned type; otherwise a signed type is returned. */ ! extern tree type_for_mode PARAMS ((enum machine_mode, int)); /* Return the unsigned version of a TYPE_NODE, a scalar type. */ ! extern tree unsigned_type PARAMS ((tree)); /* Return the signed version of a TYPE_NODE, a scalar type. */ ! extern tree signed_type PARAMS ((tree)); /* Return a type the same as TYPE except unsigned or signed according to UNSIGNEDP. */ ! extern tree signed_or_unsigned_type PARAMS ((int, tree)); ! ! /* This routine is called in tree.c to print an error message for invalid use ! of an incomplete type. */ ! extern void incomplete_type_error PARAMS ((tree, tree)); /* This function is called indirectly from toplev.c to handle incomplete declarations, i.e. VAR_DECL nodes whose DECL_SIZE is zero. To be precise, compile_file in toplev.c makes an indirect call through the function pointer incomplete_decl_finalize_hook which is initialized to this routine in init_decl_processing. */ ! extern void finish_incomplete_decl PARAMS ((tree)); /* Create an expression whose value is that of EXPR, converted to type TYPE. The TREE_TYPE of the value --- 418,450 ---- in the gcc back-end and initialize the global binding level. */ extern void gnat_init_decl_processing PARAMS ((void)); extern void init_gigi_decls PARAMS ((tree, tree)); + extern void gnat_init_gcc_eh PARAMS ((void)); /* Return an integer type with the number of bits of precision given by PRECISION. UNSIGNEDP is nonzero if the type is unsigned; otherwise it is a signed type. */ ! extern tree gnat_type_for_size PARAMS ((unsigned, int)); /* Return a data type that has machine mode MODE. UNSIGNEDP selects an unsigned type; otherwise a signed type is returned. */ ! extern tree gnat_type_for_mode PARAMS ((enum machine_mode, int)); /* Return the unsigned version of a TYPE_NODE, a scalar type. */ ! extern tree gnat_unsigned_type PARAMS ((tree)); /* Return the signed version of a TYPE_NODE, a scalar type. */ ! extern tree gnat_signed_type PARAMS ((tree)); /* Return a type the same as TYPE except unsigned or signed according to UNSIGNEDP. */ ! extern tree gnat_signed_or_unsigned_type PARAMS ((int, tree)); /* This function is called indirectly from toplev.c to handle incomplete declarations, i.e. VAR_DECL nodes whose DECL_SIZE is zero. To be precise, compile_file in toplev.c makes an indirect call through the function pointer incomplete_decl_finalize_hook which is initialized to this routine in init_decl_processing. */ ! extern void gnat_finish_incomplete_decl PARAMS ((tree)); /* Create an expression whose value is that of EXPR, converted to type TYPE. The TREE_TYPE of the value *************** extern void update_pointer_to PARAMS (( *** 645,652 **** extern tree max_size PARAMS ((tree, int)); /* Remove all conversions that are done in EXP. This includes converting ! from a padded type or converting to a left-justified modular type. */ ! extern tree remove_conversions PARAMS ((tree)); /* If EXP's type is an UNCONSTRAINED_ARRAY_TYPE, return an expression that refers to the underlying array. If its type has TYPE_CONTAINS_TEMPLATE_P, --- 625,634 ---- extern tree max_size PARAMS ((tree, int)); /* Remove all conversions that are done in EXP. This includes converting ! from a padded type or to a left-justified modular type. If TRUE_ADDRESS ! is nonzero, always return the address of the containing object even if ! the address is not bit-aligned. */ ! extern tree remove_conversions PARAMS ((tree, int)); /* If EXP's type is an UNCONSTRAINED_ARRAY_TYPE, return an expression that refers to the underlying array. If its type has TYPE_CONTAINS_TEMPLATE_P, *************** extern tree unchecked_convert PARAMS (( *** 668,674 **** The resulting type should always be the same as the input type. This function is simpler than the corresponding C version since the only possible operands will be things of Boolean type. */ ! extern tree truthvalue_conversion PARAMS((tree)); /* Return the base type of TYPE. */ extern tree get_base_type PARAMS((tree)); --- 650,656 ---- The resulting type should always be the same as the input type. This function is simpler than the corresponding C version since the only possible operands will be things of Boolean type. */ ! extern tree gnat_truthvalue_conversion PARAMS((tree)); /* Return the base type of TYPE. */ extern tree get_base_type PARAMS((tree)); *************** extern tree build_call_2_expr PARAMS((tr *** 705,713 **** /* Likewise to call FUNDECL with no arguments. */ extern tree build_call_0_expr PARAMS((tree)); ! /* Call a function FCN that raises an exception and pass the line ! number and file name, if requested. */ ! extern tree build_call_raise PARAMS((tree)); /* Return a CONSTRUCTOR of TYPE whose list is LIST. */ extern tree build_constructor PARAMS((tree, tree)); --- 687,695 ---- /* Likewise to call FUNDECL with no arguments. */ extern tree build_call_0_expr PARAMS((tree)); ! /* Call a function that raises an exception and pass the line number and file ! name, if requested. MSG says which exception function to call. */ ! extern tree build_call_raise PARAMS((int)); /* Return a CONSTRUCTOR of TYPE whose list is LIST. */ extern tree build_constructor PARAMS((tree, tree)); *************** extern tree build_allocator PARAMS((tree *** 741,748 **** extern tree fill_vms_descriptor PARAMS((tree, Entity_Id)); /* Indicate that we need to make the address of EXPR_NODE and it therefore ! should not be allocated in a register. Return 1 if successful. */ ! extern int mark_addressable PARAMS((tree)); /* These functions return the basic data type sizes and related parameters about the target machine. */ --- 723,730 ---- extern tree fill_vms_descriptor PARAMS((tree, Entity_Id)); /* Indicate that we need to make the address of EXPR_NODE and it therefore ! should not be allocated in a register. Return true if successful. */ ! extern bool gnat_mark_addressable PARAMS((tree)); /* These functions return the basic data type sizes and related parameters about the target machine. */ diff -Nrc3pad gcc-3.2.3/gcc/ada/g-io.adb gcc-3.3/gcc/ada/g-io.adb *** gcc-3.2.3/gcc/ada/g-io.adb 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-io.adb 2002-03-14 10:59:20.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1995-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-io.ads gcc-3.3/gcc/ada/g-io.ads *** gcc-3.2.3/gcc/ada/g-io.ads 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-io.ads 2002-03-14 10:59:20.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1995-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** *** 36,45 **** -- A simple text I/O package that can be used for simple I/O functions in -- user programs as required. This package is also preelaborated, unlike ! -- Text_Io, and can thus be with'ed by preelaborated library units. -- Note that Data_Error is not raised by these subprograms for bad data. ! -- If such checks are needed then the regular Text_IO package such be used. package GNAT.IO is pragma Preelaborate (IO); --- 35,44 ---- -- A simple text I/O package that can be used for simple I/O functions in -- user programs as required. This package is also preelaborated, unlike ! -- Text_IO, and can thus be with'ed by preelaborated library units. -- Note that Data_Error is not raised by these subprograms for bad data. ! -- If such checks are needed then the regular Text_IO package must be used. package GNAT.IO is pragma Preelaborate (IO); diff -Nrc3pad gcc-3.2.3/gcc/ada/g-io_aux.adb gcc-3.3/gcc/ada/g-io_aux.adb *** gcc-3.2.3/gcc/ada/g-io_aux.adb 2001-10-02 14:15:31.000000000 +0000 --- gcc-3.3/gcc/ada/g-io_aux.adb 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1995-2000 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1995-2002 Ada Core Technologies, 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-io_aux.ads gcc-3.3/gcc/ada/g-io_aux.ads *** gcc-3.2.3/gcc/ada/g-io_aux.ads 2002-05-07 08:22:16.000000000 +0000 --- gcc-3.3/gcc/ada/g-io_aux.ads 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1995-1998 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1995-2002 Ada Core Technologies, 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-locfil.adb gcc-3.3/gcc/ada/g-locfil.adb *** gcc-3.2.3/gcc/ada/g-locfil.adb 2002-05-04 03:28:05.000000000 +0000 --- gcc-3.3/gcc/ada/g-locfil.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body GNAT.Lock_Files is *** 44,51 **** --------------- procedure Lock_File ! (Directory : String; ! Lock_File_Name : String; Wait : Duration := 1.0; Retries : Natural := Natural'Last) is --- 43,50 ---- --------------- procedure Lock_File ! (Directory : Path_Name; ! Lock_File_Name : Path_Name; Wait : Duration := 1.0; Retries : Natural := Natural'Last) is *************** package body GNAT.Lock_Files is *** 56,68 **** --- 55,80 ---- pragma Import (C, Try_Lock, "__gnat_try_lock"); begin + -- If a directory separator was provided, just remove the one we have + -- added above. + + if Directory (Directory'Last) = Dir_Separator + or else Directory (Directory'Last) = '/' + then + Dir (Dir'Last - 1) := ASCII.Nul; + end if; + + -- Try to lock the file Retries times + for I in 0 .. Retries loop if Try_Lock (Dir'Address, File'Address) = 1 then return; end if; + exit when I = Retries; delay Wait; end loop; + raise Lock_Error; end Lock_File; *************** package body GNAT.Lock_Files is *** 71,83 **** --------------- procedure Lock_File ! (Lock_File_Name : String; Wait : Duration := 1.0; Retries : Natural := Natural'Last) is begin for J in reverse Lock_File_Name'Range loop ! if Lock_File_Name (J) = Dir_Separator then Lock_File (Lock_File_Name (Lock_File_Name'First .. J - 1), Lock_File_Name (J + 1 .. Lock_File_Name'Last), --- 83,97 ---- --------------- procedure Lock_File ! (Lock_File_Name : Path_Name; Wait : Duration := 1.0; Retries : Natural := Natural'Last) is begin for J in reverse Lock_File_Name'Range loop ! if Lock_File_Name (J) = Dir_Separator ! or else Lock_File_Name (J) = '/' ! then Lock_File (Lock_File_Name (Lock_File_Name'First .. J - 1), Lock_File_Name (J + 1 .. Lock_File_Name'Last), *************** package body GNAT.Lock_Files is *** 94,100 **** -- Unlock_File -- ----------------- ! procedure Unlock_File (Lock_File_Name : String) is S : aliased String := Lock_File_Name & ASCII.NUL; procedure unlink (A : System.Address); --- 108,114 ---- -- Unlock_File -- ----------------- ! procedure Unlock_File (Lock_File_Name : Path_Name) is S : aliased String := Lock_File_Name & ASCII.NUL; procedure unlink (A : System.Address); *************** package body GNAT.Lock_Files is *** 108,116 **** -- Unlock_File -- ----------------- ! procedure Unlock_File (Directory : String; Lock_File_Name : String) is begin ! Unlock_File (Directory & Dir_Separator & Lock_File_Name); end Unlock_File; end GNAT.Lock_Files; --- 122,136 ---- -- Unlock_File -- ----------------- ! procedure Unlock_File (Directory : Path_Name; Lock_File_Name : Path_Name) is begin ! if Directory (Directory'Last) = Dir_Separator ! or else Directory (Directory'Last) = '/' ! then ! Unlock_File (Directory & Lock_File_Name); ! else ! Unlock_File (Directory & Dir_Separator & Lock_File_Name); ! end if; end Unlock_File; end GNAT.Lock_Files; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-locfil.ads gcc-3.3/gcc/ada/g-locfil.ads *** gcc-3.2.3/gcc/ada/g-locfil.ads 2001-10-02 14:15:32.000000000 +0000 --- gcc-3.3/gcc/ada/g-locfil.ads 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1995-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** *** 32,39 **** -- -- ------------------------------------------------------------------------------ ! -- This package contains the necessary routines for using files for the ! -- purpose of providing realiable system wide locking capability. package GNAT.Lock_Files is pragma Preelaborate; --- 31,38 ---- -- -- ------------------------------------------------------------------------------ ! -- This package contains the necessary routines for using files for the ! -- purpose of providing realiable system wide locking capability. package GNAT.Lock_Files is pragma Preelaborate; *************** pragma Preelaborate; *** 41,67 **** Lock_Error : exception; -- Exception raised if file cannot be locked procedure Lock_File ! (Directory : String; ! Lock_File_Name : String; Wait : Duration := 1.0; Retries : Natural := Natural'Last); -- Create a lock file Lock_File_Name in directory Directory. If the file -- cannot be locked because someone already owns the lock, this procedure -- waits Wait seconds and retries at most Retries times. If the file -- still cannot be locked, Lock_Error is raised. The default is to try ! -- every second, almost forever (Natural'Last times). procedure Lock_File ! (Lock_File_Name : String; Wait : Duration := 1.0; Retries : Natural := Natural'Last); -- See above. The full lock file path is given as one string. ! procedure Unlock_File (Directory : String; Lock_File_Name : String); ! -- Unlock a file ! procedure Unlock_File (Lock_File_Name : String); -- Unlock a file whose full path is given in Lock_File_Name end GNAT.Lock_Files; --- 40,74 ---- Lock_Error : exception; -- Exception raised if file cannot be locked + subtype Path_Name is String; + -- Pathname is used by all services provided in this unit to specified + -- directory name and file name. On DOS based systems both directory + -- separators are handled (i.e. slash and backslash). + procedure Lock_File ! (Directory : Path_Name; ! Lock_File_Name : Path_Name; Wait : Duration := 1.0; Retries : Natural := Natural'Last); -- Create a lock file Lock_File_Name in directory Directory. If the file -- cannot be locked because someone already owns the lock, this procedure -- waits Wait seconds and retries at most Retries times. If the file -- still cannot be locked, Lock_Error is raised. The default is to try ! -- every second, almost forever (Natural'Last times). The full path of ! -- the file is constructed by concatenating Directory and Lock_File_Name. ! -- Directory can optionally terminate with a directory separator. procedure Lock_File ! (Lock_File_Name : Path_Name; Wait : Duration := 1.0; Retries : Natural := Natural'Last); -- See above. The full lock file path is given as one string. ! procedure Unlock_File (Directory : Path_Name; Lock_File_Name : Path_Name); ! -- Unlock a file. Directory can optionally terminate with a directory ! -- separator. ! procedure Unlock_File (Lock_File_Name : Path_Name); -- Unlock a file whose full path is given in Lock_File_Name end GNAT.Lock_Files; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-md5.adb gcc-3.3/gcc/ada/g-md5.adb *** gcc-3.2.3/gcc/ada/g-md5.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/g-md5.adb 2002-03-14 10:59:21.000000000 +0000 *************** *** 0 **** --- 1,550 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT LIBRARY COMPONENTS -- + -- -- + -- G N A T . M D 5 -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2002 Ada Core Technologies, 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). -- + -- -- + ------------------------------------------------------------------------------ + + with Ada.Unchecked_Conversion; + + package body GNAT.MD5 is + + use Interfaces; + + Padding : constant String := + (1 => Character'Val (16#80#), 2 .. 64 => ASCII.NUL); + + Hex_Digit : constant array (Unsigned_32 range 0 .. 15) of Character := + ('0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); + -- Look-up table for each hex digit of the Message-Digest. + -- Used by function Digest (Context). + + -- The sixten values used to rotate the context words. + -- Four for each rounds. Used in procedure Transform. + + -- Round 1 + + S11 : constant := 7; + S12 : constant := 12; + S13 : constant := 17; + S14 : constant := 22; + + -- Round 2 + + S21 : constant := 5; + S22 : constant := 9; + S23 : constant := 14; + S24 : constant := 20; + + -- Round 3 + + S31 : constant := 4; + S32 : constant := 11; + S33 : constant := 16; + S34 : constant := 23; + + -- Round 4 + + S41 : constant := 6; + S42 : constant := 10; + S43 : constant := 15; + S44 : constant := 21; + + type Sixteen_Words is array (Natural range 0 .. 15) + of Interfaces.Unsigned_32; + -- Sixteen 32-bit words, converted from block of 64 characters. + -- Used in procedure Decode and Transform. + + procedure Decode + (Block : String; + X : out Sixteen_Words); + -- Convert a String of 64 characters into 16 32-bit numbers + + -- The following functions (F, FF, G, GG, H, HH, I and II) are the + -- equivalent of the macros of the same name in the example + -- C implementation in the annex of RFC 1321. + + function F (X, Y, Z : Unsigned_32) return Unsigned_32; + pragma Inline (F); + + procedure FF + (A : in out Unsigned_32; + B, C, D : Unsigned_32; + X : Unsigned_32; + AC : Unsigned_32; + S : Positive); + pragma Inline (FF); + + function G (X, Y, Z : Unsigned_32) return Unsigned_32; + pragma Inline (G); + + procedure GG + (A : in out Unsigned_32; + B, C, D : Unsigned_32; + X : Unsigned_32; + AC : Unsigned_32; + S : Positive); + pragma Inline (GG); + + function H (X, Y, Z : Unsigned_32) return Unsigned_32; + pragma Inline (H); + + procedure HH + (A : in out Unsigned_32; + B, C, D : Unsigned_32; + X : Unsigned_32; + AC : Unsigned_32; + S : Positive); + pragma Inline (HH); + + function I (X, Y, Z : Unsigned_32) return Unsigned_32; + pragma Inline (I); + + procedure II + (A : in out Unsigned_32; + B, C, D : Unsigned_32; + X : Unsigned_32; + AC : Unsigned_32; + S : Positive); + pragma Inline (II); + + procedure Transform + (C : in out Context; + Block : String); + -- Process one block of 64 characters. + + ------------ + -- Decode -- + ------------ + + procedure Decode + (Block : String; + X : out Sixteen_Words) + is + Cur : Positive := Block'First; + + begin + pragma Assert (Block'Length = 64); + + for Index in X'Range loop + X (Index) := + Unsigned_32 (Character'Pos (Block (Cur))) + + Shift_Left (Unsigned_32 (Character'Pos (Block (Cur + 1))), 8) + + Shift_Left (Unsigned_32 (Character'Pos (Block (Cur + 2))), 16) + + Shift_Left (Unsigned_32 (Character'Pos (Block (Cur + 3))), 24); + Cur := Cur + 4; + end loop; + end Decode; + + ------------ + -- Digest -- + ------------ + + function Digest (C : Context) return Message_Digest is + Result : Message_Digest; + + Cur : Natural := 1; + -- Index in Result where the next character will be placed. + + procedure Convert (X : Unsigned_32); + -- Put the contribution of one of the four words (A, B, C, D) of the + -- Context in Result. Increments Cur. + + ------------- + -- Convert -- + ------------- + + procedure Convert (X : Unsigned_32) is + Y : Unsigned_32 := X; + + begin + for J in 1 .. 4 loop + Result (Cur + 1) := Hex_Digit (Y and Unsigned_32'(16#0F#)); + Y := Shift_Right (Y, 4); + Result (Cur) := Hex_Digit (Y and Unsigned_32'(16#0F#)); + Y := Shift_Right (Y, 4); + Cur := Cur + 2; + end loop; + end Convert; + + -- Start of processing for Digest + + begin + Convert (C.A); + Convert (C.B); + Convert (C.C); + Convert (C.D); + return Result; + end Digest; + + function Digest (S : String) return Message_Digest is + C : Context; + + begin + Update (C, S); + return Digest (C); + end Digest; + + function Digest + (A : Ada.Streams.Stream_Element_Array) + return Message_Digest + is + C : Context; + + begin + Update (C, A); + return Digest (C); + end Digest; + + ------- + -- F -- + ------- + + function F (X, Y, Z : Unsigned_32) return Unsigned_32 is + begin + return (X and Y) or ((not X) and Z); + end F; + + -------- + -- FF -- + -------- + + procedure FF + (A : in out Unsigned_32; + B, C, D : Unsigned_32; + X : Unsigned_32; + AC : Unsigned_32; + S : Positive) + is + begin + A := A + F (B, C, D) + X + AC; + A := Rotate_Left (A, S); + A := A + B; + end FF; + + ------- + -- G -- + ------- + + function G (X, Y, Z : Unsigned_32) return Unsigned_32 is + begin + return (X and Z) or (Y and (not Z)); + end G; + + -------- + -- GG -- + -------- + + procedure GG + (A : in out Unsigned_32; + B, C, D : Unsigned_32; + X : Unsigned_32; + AC : Unsigned_32; + S : Positive) + is + begin + A := A + G (B, C, D) + X + AC; + A := Rotate_Left (A, S); + A := A + B; + end GG; + + ------- + -- H -- + ------- + + function H (X, Y, Z : Unsigned_32) return Unsigned_32 is + begin + return X xor Y xor Z; + end H; + + -------- + -- HH -- + -------- + + procedure HH + (A : in out Unsigned_32; + B, C, D : Unsigned_32; + X : Unsigned_32; + AC : Unsigned_32; + S : Positive) + is + begin + A := A + H (B, C, D) + X + AC; + A := Rotate_Left (A, S); + A := A + B; + end HH; + + ------- + -- I -- + ------- + + function I (X, Y, Z : Unsigned_32) return Unsigned_32 is + begin + return Y xor (X or (not Z)); + end I; + + -------- + -- II -- + -------- + + procedure II + (A : in out Unsigned_32; + B, C, D : Unsigned_32; + X : Unsigned_32; + AC : Unsigned_32; + S : Positive) + is + begin + A := A + I (B, C, D) + X + AC; + A := Rotate_Left (A, S); + A := A + B; + end II; + + --------------- + -- Transform -- + --------------- + + procedure Transform + (C : in out Context; + Block : String) + is + X : Sixteen_Words; + + AA : Unsigned_32 := C.A; + BB : Unsigned_32 := C.B; + CC : Unsigned_32 := C.C; + DD : Unsigned_32 := C.D; + + begin + pragma Assert (Block'Length = 64); + + Decode (Block, X); + + -- Round 1 + + FF (AA, BB, CC, DD, X (00), 16#D76aa478#, S11); -- 1 + FF (DD, AA, BB, CC, X (01), 16#E8c7b756#, S12); -- 2 + FF (CC, DD, AA, BB, X (02), 16#242070db#, S13); -- 3 + FF (BB, CC, DD, AA, X (03), 16#C1bdceee#, S14); -- 4 + + FF (AA, BB, CC, DD, X (04), 16#f57c0faf#, S11); -- 5 + FF (DD, AA, BB, CC, X (05), 16#4787c62a#, S12); -- 6 + FF (CC, DD, AA, BB, X (06), 16#a8304613#, S13); -- 7 + FF (BB, CC, DD, AA, X (07), 16#fd469501#, S14); -- 8 + + FF (AA, BB, CC, DD, X (08), 16#698098d8#, S11); -- 9 + FF (DD, AA, BB, CC, X (09), 16#8b44f7af#, S12); -- 10 + FF (CC, DD, AA, BB, X (10), 16#ffff5bb1#, S13); -- 11 + FF (BB, CC, DD, AA, X (11), 16#895cd7be#, S14); -- 12 + + FF (AA, BB, CC, DD, X (12), 16#6b901122#, S11); -- 13 + FF (DD, AA, BB, CC, X (13), 16#fd987193#, S12); -- 14 + FF (CC, DD, AA, BB, X (14), 16#a679438e#, S13); -- 15 + FF (BB, CC, DD, AA, X (15), 16#49b40821#, S14); -- 16 + + -- Round 2 + + GG (AA, BB, CC, DD, X (01), 16#f61e2562#, S21); -- 17 + GG (DD, AA, BB, CC, X (06), 16#c040b340#, S22); -- 18 + GG (CC, DD, AA, BB, X (11), 16#265e5a51#, S23); -- 19 + GG (BB, CC, DD, AA, X (00), 16#e9b6c7aa#, S24); -- 20 + + GG (AA, BB, CC, DD, X (05), 16#d62f105d#, S21); -- 21 + GG (DD, AA, BB, CC, X (10), 16#02441453#, S22); -- 22 + GG (CC, DD, AA, BB, X (15), 16#d8a1e681#, S23); -- 23 + GG (BB, CC, DD, AA, X (04), 16#e7d3fbc8#, S24); -- 24 + + GG (AA, BB, CC, DD, X (09), 16#21e1cde6#, S21); -- 25 + GG (DD, AA, BB, CC, X (14), 16#c33707d6#, S22); -- 26 + GG (CC, DD, AA, BB, X (03), 16#f4d50d87#, S23); -- 27 + GG (BB, CC, DD, AA, X (08), 16#455a14ed#, S24); -- 28 + + GG (AA, BB, CC, DD, X (13), 16#a9e3e905#, S21); -- 29 + GG (DD, AA, BB, CC, X (02), 16#fcefa3f8#, S22); -- 30 + GG (CC, DD, AA, BB, X (07), 16#676f02d9#, S23); -- 31 + GG (BB, CC, DD, AA, X (12), 16#8d2a4c8a#, S24); -- 32 + + -- Round 3 + + HH (AA, BB, CC, DD, X (05), 16#fffa3942#, S31); -- 33 + HH (DD, AA, BB, CC, X (08), 16#8771f681#, S32); -- 34 + HH (CC, DD, AA, BB, X (11), 16#6d9d6122#, S33); -- 35 + HH (BB, CC, DD, AA, X (14), 16#fde5380c#, S34); -- 36 + + HH (AA, BB, CC, DD, X (01), 16#a4beea44#, S31); -- 37 + HH (DD, AA, BB, CC, X (04), 16#4bdecfa9#, S32); -- 38 + HH (CC, DD, AA, BB, X (07), 16#f6bb4b60#, S33); -- 39 + HH (BB, CC, DD, AA, X (10), 16#bebfbc70#, S34); -- 40 + + HH (AA, BB, CC, DD, X (13), 16#289b7ec6#, S31); -- 41 + HH (DD, AA, BB, CC, X (00), 16#eaa127fa#, S32); -- 42 + HH (CC, DD, AA, BB, X (03), 16#d4ef3085#, S33); -- 43 + HH (BB, CC, DD, AA, X (06), 16#04881d05#, S34); -- 44 + + HH (AA, BB, CC, DD, X (09), 16#d9d4d039#, S31); -- 45 + HH (DD, AA, BB, CC, X (12), 16#e6db99e5#, S32); -- 46 + HH (CC, DD, AA, BB, X (15), 16#1fa27cf8#, S33); -- 47 + HH (BB, CC, DD, AA, X (02), 16#c4ac5665#, S34); -- 48 + + -- Round 4 + + II (AA, BB, CC, DD, X (00), 16#f4292244#, S41); -- 49 + II (DD, AA, BB, CC, X (07), 16#432aff97#, S42); -- 50 + II (CC, DD, AA, BB, X (14), 16#ab9423a7#, S43); -- 51 + II (BB, CC, DD, AA, X (05), 16#fc93a039#, S44); -- 52 + + II (AA, BB, CC, DD, X (12), 16#655b59c3#, S41); -- 53 + II (DD, AA, BB, CC, X (03), 16#8f0ccc92#, S42); -- 54 + II (CC, DD, AA, BB, X (10), 16#ffeff47d#, S43); -- 55 + II (BB, CC, DD, AA, X (01), 16#85845dd1#, S44); -- 56 + + II (AA, BB, CC, DD, X (08), 16#6fa87e4f#, S41); -- 57 + II (DD, AA, BB, CC, X (15), 16#fe2ce6e0#, S42); -- 58 + II (CC, DD, AA, BB, X (06), 16#a3014314#, S43); -- 59 + II (BB, CC, DD, AA, X (13), 16#4e0811a1#, S44); -- 60 + + II (AA, BB, CC, DD, X (04), 16#f7537e82#, S41); -- 61 + II (DD, AA, BB, CC, X (11), 16#bd3af235#, S42); -- 62 + II (CC, DD, AA, BB, X (02), 16#2ad7d2bb#, S43); -- 63 + II (BB, CC, DD, AA, X (09), 16#eb86d391#, S44); -- 64 + + C.A := C.A + AA; + C.B := C.B + BB; + C.C := C.C + CC; + C.D := C.D + DD; + + end Transform; + + ------------ + -- Update -- + ------------ + + procedure Update + (C : in out Context; + Input : String) + is + Cur : Positive := Input'First; + Last_Block : String (1 .. 64); + + begin + while Cur + 63 <= Input'Last loop + Transform (C, Input (Cur .. Cur + 63)); + Cur := Cur + 64; + end loop; + + Last_Block (1 .. Input'Last - Cur + 1) := Input (Cur .. Input'Last); + + if Input'Last - Cur + 1 > 56 then + Cur := Input'Last - Cur + 2; + Last_Block (Cur .. 64) := Padding (1 .. 64 - Cur + 1); + Transform (C, Last_Block); + Last_Block := (others => ASCII.NUL); + + else + Cur := Input'Last - Cur + 2; + Last_Block (Cur .. 56) := Padding (1 .. 56 - Cur + 1); + end if; + + -- Add the input length as 8 characters + + Last_Block (57 .. 64) := (others => ASCII.NUL); + + declare + L : Unsigned_64 := Unsigned_64 (Input'Length) * 8; + + begin + Cur := 57; + while L > 0 loop + Last_Block (Cur) := Character'Val (L and 16#Ff#); + L := Shift_Right (L, 8); + Cur := Cur + 1; + end loop; + end; + + Transform (C, Last_Block); + end Update; + + procedure Update + (C : in out Context; + Input : Ada.Streams.Stream_Element_Array) + is + subtype Stream_Array is Ada.Streams.Stream_Element_Array (Input'Range); + subtype Stream_String is + String (1 + Integer (Input'First) .. 1 + Integer (Input'Last)); + + function To_String is new Ada.Unchecked_Conversion + (Stream_Array, Stream_String); + + String_Input : constant String := To_String (Input); + begin + Update (C, String_Input); + end Update; + + ----------------- + -- Wide_Digest -- + ----------------- + + function Wide_Digest (W : Wide_String) return Message_Digest is + C : Context; + + begin + Wide_Update (C, W); + return Digest (C); + end Wide_Digest; + + ----------------- + -- Wide_Update -- + ----------------- + + procedure Wide_Update + (C : in out Context; + Input : Wide_String) + is + + String_Input : String (1 .. 2 * Input'Length); + Cur : Positive := 1; + + begin + for Index in Input'Range loop + String_Input (Cur) := + Character'Val + (Unsigned_32 (Wide_Character'Pos (Input (Index))) and 16#FF#); + Cur := Cur + 1; + String_Input (Cur) := + Character'Val + (Shift_Right (Unsigned_32 (Wide_Character'Pos (Input (Index))), 8) + and 16#FF#); + Cur := Cur + 1; + end loop; + + Update (C, String_Input); + end Wide_Update; + + end GNAT.MD5; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-md5.ads gcc-3.3/gcc/ada/g-md5.ads *** gcc-3.2.3/gcc/ada/g-md5.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/g-md5.ads 2002-03-14 10:59:21.000000000 +0000 *************** *** 0 **** --- 1,106 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT LIBRARY COMPONENTS -- + -- -- + -- G N A T . M D 5 -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2002 Ada Core Technologies, 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). -- + -- -- + ------------------------------------------------------------------------------ + -- + -- This package implements the MD5 Message-Digest Algorithm as described in + -- RFC 1321. The complete text of RFC 1321 can be found at: + -- + -- http://www.ietf.org/rfc/rfc1321.txt + -- + -- The implementation is derived from the RSA Data Secutity, Inc. MD5 + -- Message-Digest Algorithm, as described in RFC 1321. + + with Ada.Streams; + with Interfaces; + + package GNAT.MD5 is + + type Context is private; + -- This type is the four-word (16 byte) MD buffer, as described in + -- RFC 1321 (3.3). It initial value is Initial_Context below. + + Initial_Context : constant Context; + -- Initial value of a Context object. May be used to reinitialize + -- a Context value by simple assignment of this value to the object. + + procedure Update + (C : in out Context; + Input : String); + procedure Wide_Update + (C : in out Context; + Input : Wide_String); + procedure Update + (C : in out Context; + Input : Ada.Streams.Stream_Element_Array); + -- Modify the Context C. If C has the initial value Initial_Context, + -- then, after a call to one of these procedures, Digest (C) will return + -- the Message-Digest of Input. + -- + -- These procedures may be called successively with the same context and + -- different inputs. However, several successive calls will not produce + -- the same final context as a call with the concatenation of the inputs. + + subtype Message_Digest is String (1 .. 32); + -- The string type returned by function Digest. + + function Digest (C : Context) return Message_Digest; + -- Extracts the Message-Digest from a context. This function should be + -- used after one or several calls to Update. + + function Digest (S : String) return Message_Digest; + function Wide_Digest (W : Wide_String) return Message_Digest; + function Digest + (A : Ada.Streams.Stream_Element_Array) + return Message_Digest; + -- These functions are equivalent to the corresponding Update (or + -- Wide_Update) on a default initialized Context, followed by Digest + -- on the resulting Context. + + private + + -- Magic numbers + Initial_A : constant := 16#67452301#; + Initial_B : constant := 16#EFCDAB89#; + Initial_C : constant := 16#98BADCFE#; + Initial_D : constant := 16#10325476#; + + type Context is record + A : Interfaces.Unsigned_32 := Initial_A; + B : Interfaces.Unsigned_32 := Initial_B; + C : Interfaces.Unsigned_32 := Initial_C; + D : Interfaces.Unsigned_32 := Initial_D; + end record; + + Initial_Context : constant Context := + (A => Initial_A, B => Initial_B, C => Initial_C, D => Initial_D); + + end GNAT.MD5; diff -Nrc3pad gcc-3.2.3/gcc/ada/gmem.c gcc-3.3/gcc/ada/gmem.c *** gcc-3.2.3/gcc/ada/gmem.c 2002-05-04 03:28:06.000000000 +0000 --- gcc-3.3/gcc/ada/gmem.c 2002-10-23 07:33:24.000000000 +0000 *************** *** 4,10 **** * * * G M E M * * * - * $Revision: 1.3.12.1 $ * * * C Implementation File * * * --- 4,9 ---- *************** static FILE *gmemfile; *** 69,75 **** /* tb_len is the number of call level supported by this module */ #define TB_LEN 200 ! static char *tracebk [TB_LEN]; static int cur_tb_len, cur_tb_pos; extern void convert_addresses PARAMS ((char *[], int, void *, --- 68,74 ---- /* tb_len is the number of call level supported by this module */ #define TB_LEN 200 ! static char *tracebk[TB_LEN]; static int cur_tb_len, cur_tb_pos; extern void convert_addresses PARAMS ((char *[], int, void *, *************** __gnat_gmem_a2l_initialize (exename) *** 123,132 **** char *exename; { extern char **gnat_argv; ! char s [100]; int l; ! gnat_argv [0] = exename; convert_addresses (tracebk, 1, s, &l); } --- 122,131 ---- char *exename; { extern char **gnat_argv; ! char s[100]; int l; ! gnat_argv[0] = exename; convert_addresses (tracebk, 1, s, &l); } *************** __gnat_gmem_read_bt_frame (buf) *** 201,208 **** if (cur_tb_pos >= cur_tb_len) { ! buf [0] = ' '; ! buf [1] = '\0'; return; } --- 200,207 ---- if (cur_tb_pos >= cur_tb_len) { ! buf[0] = ' '; ! buf[1] = '\0'; return; } diff -Nrc3pad gcc-3.2.3/gcc/ada/g-moreex.adb gcc-3.3/gcc/ada/g-moreex.adb *** gcc-3.2.3/gcc/ada/g-moreex.adb 2002-05-07 08:22:16.000000000 +0000 --- gcc-3.3/gcc/ada/g-moreex.adb 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-moreex.ads gcc-3.3/gcc/ada/g-moreex.ads *** gcc-3.2.3/gcc/ada/g-moreex.ads 2001-10-02 14:15:32.000000000 +0000 --- gcc-3.3/gcc/ada/g-moreex.ads 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat1drv.adb gcc-3.3/gcc/ada/gnat1drv.adb *** gcc-3.2.3/gcc/ada/gnat1drv.adb 2002-05-04 03:28:06.000000000 +0000 --- gcc-3.3/gcc/ada/gnat1drv.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** begin *** 90,101 **** -- nested blocks, so that the outer one handles unrecoverable error. begin ! Osint.Initialize (Compiler); Scan_Compiler_Arguments; Osint.Add_Default_Search_Dirs; Sinput.Initialize; - Lib.Initialize; Sem.Initialize; Csets.Initialize; Uintp.Initialize; --- 89,103 ---- -- nested blocks, so that the outer one handles unrecoverable error. begin ! -- Lib.Initialize need to be called before Scan_Compiler_Arguments, ! -- because it initialize a table that is filled by ! -- Scan_Compiler_Arguments. ! ! Lib.Initialize; Scan_Compiler_Arguments; Osint.Add_Default_Search_Dirs; Sinput.Initialize; Sem.Initialize; Csets.Initialize; Uintp.Initialize; *************** begin *** 107,112 **** --- 109,122 ---- Inline.Initialize; Sem_Ch13.Initialize; + -- Acquire target parameters and perform required setup + + Targparm.Get_Target_Parameters; + + if Targparm.High_Integrity_Mode_On_Target then + Set_No_Run_Time_Mode; + end if; + -- Output copyright notice if full list mode if (Verbose_Mode or Full_List) *************** begin *** 114,130 **** then Write_Eol; Write_Str ("GNAT "); - Write_Str (Gnat_Version_String); - Write_Str (" Copyright 1992-2001 Free Software Foundation, Inc."); - Write_Eol; - end if; - - -- Acquire target parameters and perform required setup ! Targparm.Get_Target_Parameters; ! if Targparm.High_Integrity_Mode_On_Target then ! Set_No_Run_Time_Mode; end if; -- Before we do anything else, adjust certain global values for --- 124,138 ---- then Write_Eol; Write_Str ("GNAT "); ! if Targparm.High_Integrity_Mode_On_Target then ! Write_Str ("Pro High Integrity "); ! end if; ! Write_Str (Gnat_Version_String); ! Write_Eol; ! Write_Str ("Copyright 1992-2002 Free Software Foundation, Inc."); ! Write_Eol; end if; -- Before we do anything else, adjust certain global values for *************** begin *** 173,178 **** --- 181,203 ---- end if; end if; + -- Set proper status for overflow checks. We turn on overflow checks + -- if -gnatp was not specified, and either -gnato is set or the back + -- end takes care of overflow checks. Otherwise we suppress overflow + -- checks by default (since front end checks are expensive). + + if not Opt.Suppress_Checks + and then (Opt.Enable_Overflow_Checks + or else + (Targparm.Backend_Divide_Checks_On_Target + and + Targparm.Backend_Overflow_Checks_On_Target)) + then + Suppress_Options.Overflow_Checks := False; + else + Suppress_Options.Overflow_Checks := True; + end if; + -- Check we have exactly one source file, this happens only in -- the case where the driver is called directly, it cannot happen -- when gnat1 is invoked from gcc in the normal case. diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat1drv.ads gcc-3.3/gcc/ada/gnat1drv.ads *** gcc-3.2.3/gcc/ada/gnat1drv.ads 2002-05-07 08:22:17.000000000 +0000 --- gcc-3.3/gcc/ada/gnat1drv.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat.ads gcc-3.3/gcc/ada/gnat.ads *** gcc-3.2.3/gcc/ada/gnat.ads 2001-10-02 14:15:35.000000000 +0000 --- gcc-3.3/gcc/ada/gnat.ads 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1992-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatbind.adb gcc-3.3/gcc/ada/gnatbind.adb *** gcc-3.2.3/gcc/ada/gnatbind.adb 2002-05-04 03:28:09.000000000 +0000 --- gcc-3.3/gcc/ada/gnatbind.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Gnatvsn; use Gnatvsn; *** 39,46 **** --- 38,48 ---- with Namet; use Namet; with Opt; use Opt; with Osint; use Osint; + with Osint.B; use Osint.B; with Output; use Output; with Switch; use Switch; + with Switch.B; use Switch.B; + with Targparm; use Targparm; with Types; use Types; procedure Gnatbind is *************** procedure Gnatbind is *** 86,94 **** Output_File_Name_Seen := True; if Argv'Length = 0 ! or else (Argv'Length >= 1 ! and then (Argv (1) = Switch_Character ! or else Argv (1) = '-')) then Fail ("output File_Name missing after -o"); --- 88,94 ---- Output_File_Name_Seen := True; if Argv'Length = 0 ! or else (Argv'Length >= 1 and then Argv (1) = '-') then Fail ("output File_Name missing after -o"); *************** procedure Gnatbind is *** 96,105 **** Output_File_Name := new String'(Argv); end if; ! elsif Argv'Length >= 2 ! and then (Argv (1) = Switch_Character ! or else Argv (1) = '-') ! then -- -I- if Argv (2 .. Argv'Last) = "I-" then --- 96,103 ---- Output_File_Name := new String'(Argv); end if; ! elsif Argv'Length >= 2 and then Argv (1) = '-' then ! -- -I- if Argv (2 .. Argv'Last) = "I-" then *************** procedure Gnatbind is *** 227,235 **** if Argv'Length > 4 and then Argv (Argv'Last - 3 .. Argv'Last) = ".ali" then ! Set_Main_File_Name (Argv); else ! Set_Main_File_Name (Argv & ".ali"); end if; end if; end Scan_Bind_Arg; --- 225,233 ---- if Argv'Length > 4 and then Argv (Argv'Last - 3 .. Argv'Last) = ".ali" then ! Add_File (Argv); else ! Add_File (Argv & ".ali"); end if; end if; end Scan_Bind_Arg; *************** procedure Gnatbind is *** 237,243 **** -- Start of processing for Gnatbind begin - Osint.Initialize (Binder); -- Set default for Shared_Libgnat option --- 235,240 ---- *************** begin *** 315,324 **** Osint.Add_Default_Search_Dirs; if Verbose_Mode then Write_Eol; Write_Str ("GNATBIND "); Write_Str (Gnat_Version_String); ! Write_Str (" Copyright 1995-2001 Free Software Foundation, Inc."); Write_Eol; end if; --- 312,329 ---- Osint.Add_Default_Search_Dirs; if Verbose_Mode then + Namet.Initialize; + Targparm.Get_Target_Parameters; + Write_Eol; Write_Str ("GNATBIND "); + + if Targparm.High_Integrity_Mode_On_Target then + Write_Str ("Pro High Integrity "); + end if; + Write_Str (Gnat_Version_String); ! Write_Str (" Copyright 1995-2002 Free Software Foundation, Inc."); Write_Eol; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatbind.ads gcc-3.3/gcc/ada/gnatbind.ads *** gcc-3.2.3/gcc/ada/gnatbind.ads 2002-05-07 08:22:17.000000000 +0000 --- gcc-3.3/gcc/ada/gnatbind.ads 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatbl.c gcc-3.3/gcc/ada/gnatbl.c *** gcc-3.2.3/gcc/ada/gnatbl.c 2002-05-04 03:28:11.000000000 +0000 --- gcc-3.3/gcc/ada/gnatbl.c 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** * * * C Implementation File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- *************** addarg (str) *** 89,95 **** = (char **) xcalloc (link_arg_max + 1000, sizeof (char *)); for (i = 0; i <= link_arg_max; i++) ! new_link_args [i] = link_args [i]; if (link_args) free (link_args); --- 88,94 ---- = (char **) xcalloc (link_arg_max + 1000, sizeof (char *)); for (i = 0; i <= link_arg_max; i++) ! new_link_args[i] = link_args[i]; if (link_args) free (link_args); *************** addarg (str) *** 98,104 **** link_args = new_link_args; } ! link_args [link_arg_index] = str; } static void --- 97,103 ---- link_args = new_link_args; } ! link_args[link_arg_index] = str; } static void *************** process_args (p_argc, argv) *** 124,147 **** } /* -B is passed on to gcc */ ! if (! strncmp (argv [i], "-B", 2)) gcc_B_arg = argv[i]; /* -v turns on verbose option here and is passed on to gcc */ ! if (! strcmp (argv [i], "-v")) verbose = 1; ! if (! strcmp (argv [i], "-o")) { o_present = 1; ! exec_file_name = argv [i + 1]; } ! if (! strcmp (argv [i], "-g")) g_present = 1; ! if (! strcmp (argv [i], "-gnatbind")) { /* Explicit naming of binder. Grab the value then remove the two arguments from the argument list. */ --- 123,146 ---- } /* -B is passed on to gcc */ ! if (! strncmp (argv[i], "-B", 2)) gcc_B_arg = argv[i]; /* -v turns on verbose option here and is passed on to gcc */ ! if (! strcmp (argv[i], "-v")) verbose = 1; ! if (! strcmp (argv[i], "-o")) { o_present = 1; ! exec_file_name = argv[i + 1]; } ! if (! strcmp (argv[i], "-g")) g_present = 1; ! if (! strcmp (argv[i], "-gnatbind")) { /* Explicit naming of binder. Grab the value then remove the two arguments from the argument list. */ *************** process_args (p_argc, argv) *** 151,202 **** exit (1); } ! binder_path = __gnat_locate_exec (argv [i + 1], (char *) "."); if (!binder_path) { ! fprintf (stderr, "Could not locate binder: %s\n", argv [i + 1]); exit (1); } for (j = i + 2; j < *p_argc; j++) ! argv [j - 2] = argv [j]; (*p_argc) -= 2; i--; } ! else if (! strcmp (argv [i], "-linkonly")) { /* Don't call the binder. Set the flag and then remove the argument from the argument list. */ linkonly = 1; for (j = i + 1; j < *p_argc; j++) ! argv [j - 1] = argv [j]; ! (*p_argc) -= 1; i--; } ! else if (! strcmp (argv [i], "-gnatlink")) { /* Explicit naming of binder. Grab the value then remove the two arguments from the argument list. */ if (i + 1 >= *p_argc) ! { ! fprintf (stderr, "Missing argument for -gnatlink\n"); ! exit (1); ! } ! linker_path = __gnat_locate_exec (argv [i + 1], (char *) "."); if (!linker_path) { ! fprintf (stderr, "Could not locate linker: %s\n", argv [i + 1]); exit (1); } for (j = i + 2; j < *p_argc; j++) ! argv [j - 2] = argv [j]; ! (*p_argc) -= 2; i--; } } --- 150,201 ---- exit (1); } ! binder_path = __gnat_locate_exec (argv[i + 1], (char *) "."); if (!binder_path) { ! fprintf (stderr, "Could not locate binder: %s\n", argv[i + 1]); exit (1); } for (j = i + 2; j < *p_argc; j++) ! argv[j - 2] = argv[j]; (*p_argc) -= 2; i--; } ! else if (! strcmp (argv[i], "-linkonly")) { /* Don't call the binder. Set the flag and then remove the argument from the argument list. */ linkonly = 1; for (j = i + 1; j < *p_argc; j++) ! argv[j - 1] = argv[j]; ! *p_argc -= 1; i--; } ! else if (! strcmp (argv[i], "-gnatlink")) { /* Explicit naming of binder. Grab the value then remove the two arguments from the argument list. */ if (i + 1 >= *p_argc) ! { ! fprintf (stderr, "Missing argument for -gnatlink\n"); ! exit (1); ! } ! linker_path = __gnat_locate_exec (argv[i + 1], (char *) "."); if (!linker_path) { ! fprintf (stderr, "Could not locate linker: %s\n", argv[i + 1]); exit (1); } for (j = i + 2; j < *p_argc; j++) ! argv[j - 2] = argv[j]; ! *p_argc -= 2; i--; } } *************** main (argc, argv) *** 214,224 **** #ifdef VMS /* Warning: getenv only retrieves the first directory in VAXC$PATH */ char *pathval = ! strdup (__gnat_to_canonical_dir_spec (getenv ("VAXC$PATH"), 0)); #else char *pathval = getenv ("PATH"); #endif ! char *spawn_args [5]; int spawn_index = 0; #if defined (__EMX__) || defined(MSDOS) --- 213,223 ---- #ifdef VMS /* Warning: getenv only retrieves the first directory in VAXC$PATH */ char *pathval = ! xstrdup (__gnat_to_canonical_dir_spec (getenv ("VAXC$PATH"), 0)); #else char *pathval = getenv ("PATH"); #endif ! char *spawn_args[5]; int spawn_index = 0; #if defined (__EMX__) || defined(MSDOS) *************** main (argc, argv) *** 290,298 **** for (i = 1; i < argc; i++) { ! int arg_len = strlen (argv [i]); ! if (arg_len > 4 && ! strcmp (&argv [i][arg_len - 4], ".ali")) { if (done_an_ali) { --- 289,297 ---- for (i = 1; i < argc; i++) { ! int arg_len = strlen (argv[i]); ! if (arg_len > 4 && ! strcmp (&argv[i][arg_len - 4], ".ali")) { if (done_an_ali) { *************** main (argc, argv) *** 303,326 **** done_an_ali = 1; ! if (__gnat_is_regular_file (argv [i])) { ali_file_name = argv[i]; if (!linkonly) { /* Run gnatbind */ spawn_index = 0; ! spawn_args [spawn_index++] = binder_path; ! spawn_args [spawn_index++] = ali_file_name; for (j = 0 ; j <= bind_arg_index ; j++ ) ! spawn_args [spawn_index++] = bind_args [j]; ! spawn_args [spawn_index] = 0; if (verbose) { int i; for (i = 0; i < 2; i++) ! printf ("%s ", spawn_args [i]); putchar ('\n'); } --- 302,325 ---- done_an_ali = 1; ! if (__gnat_is_regular_file (argv[i])) { ali_file_name = argv[i]; if (!linkonly) { /* Run gnatbind */ spawn_index = 0; ! spawn_args[spawn_index++] = binder_path; ! spawn_args[spawn_index++] = ali_file_name; for (j = 0 ; j <= bind_arg_index ; j++ ) ! spawn_args[spawn_index++] = bind_args[j]; ! spawn_args[spawn_index] = 0; if (verbose) { int i; for (i = 0; i < 2; i++) ! printf ("%s ", spawn_args[i]); putchar ('\n'); } *************** main (argc, argv) *** 331,349 **** } } else ! addarg (argv [i]); } #ifdef MSDOS ! else if (!strcmp (argv [i], "-o")) { ! addarg (argv [i]); if (i < argc) i++; { char *ptr = strstr (argv[i], ".exe"); ! arg_len = strlen (argv [i]); coff2exe_args[1] = malloc (arg_len + 1); strcpy (coff2exe_args[1], argv[i]); if (ptr != NULL && strlen (ptr) == 4) --- 330,348 ---- } } else ! addarg (argv[i]); } #ifdef MSDOS ! else if (!strcmp (argv[i], "-o")) { ! addarg (argv[i]); if (i < argc) i++; { char *ptr = strstr (argv[i], ".exe"); ! arg_len = strlen (argv[i]); coff2exe_args[1] = malloc (arg_len + 1); strcpy (coff2exe_args[1], argv[i]); if (ptr != NULL && strlen (ptr) == 4) *************** main (argc, argv) *** 354,360 **** } #endif else ! addarg (argv [i]); } if (! done_an_ali) --- 353,359 ---- } #endif else ! addarg (argv[i]); } if (! done_an_ali) *************** main (argc, argv) *** 371,377 **** int i; for (i = 0; i < link_arg_index; i++) ! printf ("%s ", link_args [i]); putchar ('\n'); } --- 370,376 ---- int i; for (i = 0; i < link_arg_index; i++) ! printf ("%s ", link_args[i]); putchar ('\n'); } diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatchop.adb gcc-3.3/gcc/ada/gnatchop.adb *** gcc-3.2.3/gcc/ada/gnatchop.adb 2001-12-16 01:13:40.000000000 +0000 --- gcc-3.3/gcc/ada/gnatchop.adb 2002-03-14 10:59:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4 $ -- -- -- Copyright (C) 1998-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** procedure Gnatchop is *** 49,54 **** --- 48,59 ---- Config_File_Name : constant String_Access := new String'("gnat.adc"); -- The name of the file holding the GNAT configuration pragmas + Gcc : String_Access := new String'("gcc"); + -- May be modified by switch --GCC= + + Gcc_Set : Boolean := False; + -- True if a switch --GCC= is used + Gnat_Cmd : String_Access; -- Command to execute the GNAT compiler *************** procedure Gnatchop is *** 223,231 **** Integer'Image (Maximum_File_Name_Length); ! function Locate_Executable (Program_Name : String) return String_Access; -- Locate executable for given program name. This takes into account ! -- the target-prefix of the current command. subtype EOL_Length is Natural range 0 .. 2; -- Possible lengths of end of line sequence --- 228,239 ---- Integer'Image (Maximum_File_Name_Length); ! function Locate_Executable ! (Program_Name : String; ! Look_For_Prefix : Boolean := True) ! return String_Access; -- Locate executable for given program name. This takes into account ! -- the target-prefix of the current command, if Look_For_Prefix is True. subtype EOL_Length is Natural range 0 .. 2; -- Possible lengths of end of line sequence *************** procedure Gnatchop is *** 492,526 **** -- Locate_Executable -- ----------------------- ! function Locate_Executable (Program_Name : String) return String_Access is Current_Command : constant String := Command_Name; ! End_Of_Prefix : Natural; Start_Of_Prefix : Positive := Current_Command'First; Result : String_Access; begin - -- Find Start_Of_Prefix ! for J in reverse Current_Command'Range loop ! if Current_Command (J) = '/' or ! Current_Command (J) = Directory_Separator or ! Current_Command (J) = ':' ! then ! Start_Of_Prefix := J + 1; ! exit; ! end if; ! end loop; ! -- Find End_Of_Prefix ! End_Of_Prefix := Start_Of_Prefix - 1; ! for J in reverse Start_Of_Prefix .. Current_Command'Last loop ! if Current_Command (J) = '-' then ! End_Of_Prefix := J; ! exit; ! end if; ! end loop; declare Command : constant String := --- 500,541 ---- -- Locate_Executable -- ----------------------- ! function Locate_Executable ! (Program_Name : String; ! Look_For_Prefix : Boolean := True) ! return String_Access ! is Current_Command : constant String := Command_Name; ! End_Of_Prefix : Natural := Current_Command'First - 1; Start_Of_Prefix : Positive := Current_Command'First; Result : String_Access; begin ! if Look_For_Prefix then ! -- Find Start_Of_Prefix ! for J in reverse Current_Command'Range loop ! if Current_Command (J) = '/' or ! Current_Command (J) = Directory_Separator or ! Current_Command (J) = ':' ! then ! Start_Of_Prefix := J + 1; ! exit; ! end if; ! end loop; ! -- Find End_Of_Prefix ! End_Of_Prefix := Start_Of_Prefix - 1; ! ! for J in reverse Start_Of_Prefix .. Current_Command'Last loop ! if Current_Command (J) = '-' then ! End_Of_Prefix := J; ! exit; ! end if; ! end loop; ! end if; declare Command : constant String := *************** procedure Gnatchop is *** 1058,1067 **** -- Scan options first loop ! case Getopt ("c gnat? h k? p q r v w x") is when ASCII.NUL => exit; when 'c' => Compilation_Mode := True; --- 1073,1086 ---- -- Scan options first loop ! case Getopt ("c gnat? h k? p q r v w x -GCC=!") is when ASCII.NUL => exit; + when '-' => + Gcc := new String'(Parameter); + Gcc_Set := True; + when 'c' => Compilation_Mode := True; *************** procedure Gnatchop is *** 1300,1306 **** begin Put_Line ("Usage: gnatchop [-c] [-h] [-k#] " & ! "[-r] [-p] [-q] [-v] [-w] [-x] file [file ...] [dir]"); New_Line; Put_Line --- 1319,1325 ---- begin Put_Line ("Usage: gnatchop [-c] [-h] [-k#] " & ! "[-r] [-p] [-q] [-v] [-w] [-x] [--GCC=xx] file [file ...] [dir]"); New_Line; Put_Line *************** procedure Gnatchop is *** 1343,1348 **** --- 1362,1370 ---- Put_Line (" -x exit on error"); + Put_Line + (" --GCC=xx specify the path of the gnat parser to be used"); + New_Line; Put_Line (" file... list of source files to be chopped"); *************** procedure Gnatchop is *** 1638,1651 **** -- Start of processing for gnatchop begin - -- Check presence of required executables - - Gnat_Cmd := Locate_Executable ("gcc"); - - if Gnat_Cmd = null then - goto No_Files_Written; - end if; - -- Process command line options and initialize global variables if not Scan_Arguments then --- 1660,1665 ---- *************** begin *** 1653,1658 **** --- 1667,1680 ---- return; end if; + -- Check presence of required executables + + Gnat_Cmd := Locate_Executable (Gcc.all, not Gcc_Set); + + if Gnat_Cmd = null then + goto No_Files_Written; + end if; + -- First parse all files and read offset information for Num in 1 .. File.Last loop diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatcmd.adb gcc-3.3/gcc/ada/gnatcmd.adb *** gcc-3.2.3/gcc/ada/gnatcmd.adb 2002-05-04 03:28:11.000000000 +0000 --- gcc-3.3/gcc/ada/gnatcmd.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.8.10.1 $ -- -- ! -- Copyright (C) 1996-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1996-2002 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- -- *************** *** 26,47 **** -- -- ------------------------------------------------------------------------------ ! with Ada.Characters.Handling; use Ada.Characters.Handling; ! with Ada.Command_Line; use Ada.Command_Line; ! with Ada.Text_IO; use Ada.Text_IO; with Osint; use Osint; with Sdefault; use Sdefault; with Hostparm; use Hostparm; -- Used to determine if we are in VMS or not for error message purposes with Gnatvsn; with GNAT.OS_Lib; use GNAT.OS_Lib; with Table; procedure GNATCmd is ! pragma Ident (Gnatvsn.Gnat_Version_String); ------------------ -- SWITCH TABLE -- --- 25,96 ---- -- -- ------------------------------------------------------------------------------ ! with GNAT.Directory_Operations; use GNAT.Directory_Operations; + with Csets; + with MLib.Tgt; + with MLib.Utl; + with Namet; use Namet; + with Opt; with Osint; use Osint; + with Output; + with Prj; use Prj; + with Prj.Env; + with Prj.Ext; use Prj.Ext; + with Prj.Pars; + with Prj.Util; use Prj.Util; with Sdefault; use Sdefault; + with Snames; use Snames; + with Stringt; use Stringt; + with Table; + with Types; use Types; with Hostparm; use Hostparm; -- Used to determine if we are in VMS or not for error message purposes + with Ada.Characters.Handling; use Ada.Characters.Handling; + with Ada.Command_Line; use Ada.Command_Line; + with Ada.Text_IO; use Ada.Text_IO; + with Gnatvsn; with GNAT.OS_Lib; use GNAT.OS_Lib; with Table; procedure GNATCmd is ! ! Ada_Include_Path : constant String := "ADA_INCLUDE_PATH"; ! Ada_Objects_Path : constant String := "ADA_OBJECTS_PATH"; ! ! Project_File : String_Access; ! Project : Prj.Project_Id; ! Current_Verbosity : Prj.Verbosity := Prj.Default; ! Tool_Package_Name : Name_Id := No_Name; ! ! -- This flag indicates a switch -p (for gnatxref and gnatfind) for ! -- an old fashioned project file. -p cannot be used in conjonction ! -- with -P. ! ! Old_Project_File_Used : Boolean := False; ! ! -- A table to keep the switches on the command line ! ! package Last_Switches is new Table.Table ! (Table_Component_Type => String_Access, ! Table_Index_Type => Integer, ! Table_Low_Bound => 1, ! Table_Initial => 20, ! Table_Increment => 100, ! Table_Name => "Gnatcmd.Last_Switches"); ! ! -- A table to keep the switches from the project file ! ! package First_Switches is new Table.Table ! (Table_Component_Type => String_Access, ! Table_Index_Type => Integer, ! Table_Low_Bound => 1, ! Table_Initial => 20, ! Table_Increment => 100, ! Table_Name => "Gnatcmd.First_Switches"); ------------------ -- SWITCH TABLE -- *************** procedure GNATCmd is *** 56,61 **** --- 105,111 ---- -- DIRECT_TRANSLATION -- | DIRECTORIES_TRANSLATION -- | FILE_TRANSLATION + -- | NO_SPACE_FILE_TRANSL -- | NUMERIC_TRANSLATION -- | STRING_TRANSLATION -- | OPTIONS_TRANSLATION *************** procedure GNATCmd is *** 67,72 **** --- 117,123 ---- -- DIRECTORIES_TRANSLATION ::= =* UNIX_SWITCH * -- DIRECTORY_TRANSLATION ::= =% UNIX_SWITCH % -- FILE_TRANSLATION ::= =@ UNIX_SWITCH @ + -- NO_SPACE_FILE_TRANSL ::= =< UNIX_SWITCH > -- NUMERIC_TRANSLATION ::= =# UNIX_SWITCH # | # number # -- STRING_TRANSLATION ::= =" UNIX_SWITCH " -- OPTIONS_TRANSLATION ::= =OPTION {space OPTION} *************** procedure GNATCmd is *** 106,111 **** --- 157,165 ---- -- file is allowed, not a list of files, and only one unix switch is -- generated as a result. + -- the NO_SPACE_FILE_TRANSL is similar to FILE_TRANSLATION, except that + -- no space is inserted between the switch and the file name. + -- The NUMERIC_TRANSLATION format is similar to the FILE_TRANSLATION case -- except that the parameter is a decimal integer in the range 0 to 999. *************** procedure GNATCmd is *** 169,176 **** S_Ext_Ref : aliased constant S := "/EXTERNAL_REFERENCE=" & '"' & "-X" & '"'; ! S_Project_File : aliased constant S := "/PROJECT_FILE=*" & ! "-P*"; S_Project_Verb : aliased constant S := "/PROJECT_FILE_VERBOSITY=" & "DEFAULT " & "-vP0 " & --- 223,230 ---- S_Ext_Ref : aliased constant S := "/EXTERNAL_REFERENCE=" & '"' & "-X" & '"'; ! S_Project_File : aliased constant S := "/PROJECT_FILE=<" & ! "-P>"; S_Project_Verb : aliased constant S := "/PROJECT_FILE_VERBOSITY=" & "DEFAULT " & "-vP0 " & *************** procedure GNATCmd is *** 220,231 **** --- 274,299 ---- S_Bind_Error : aliased constant S := "/ERROR_LIMIT=#" & "-m#"; + S_Bind_Help : aliased constant S := "/HELP " & + "-h"; + + S_Bind_Init : aliased constant S := "/INITIALIZE_SCALARS=" & + "INVALID " & + "-Sin " & + "LOW " & + "-Slo " & + "HIGH " & + "-Shi"; + S_Bind_Library : aliased constant S := "/LIBRARY_SEARCH=*" & "-aO*"; S_Bind_Linker : aliased constant S := "/LINKER_OPTION_LIST " & "-K"; + S_Bind_List : aliased constant S := "/LIST_RESTRICTIONS " & + "-r"; + S_Bind_Main : aliased constant S := "/MAIN " & "!-n"; *************** procedure GNATCmd is *** 235,240 **** --- 303,311 ---- S_Bind_Nostlib : aliased constant S := "/NOSTD_LIBRARIES " & "-nostdlib"; + S_Bind_No_Time : aliased constant S := "/NO_TIME_STAMP_CHECK " & + "-t"; + S_Bind_Object : aliased constant S := "/OBJECT_LIST " & "-O"; *************** procedure GNATCmd is *** 261,268 **** S_Bind_ReadX : aliased constant S := "/NOREAD_SOURCES " & "-x"; ! S_Bind_Rename : aliased constant S := "/RENAME_MAIN " & ! "-r"; S_Bind_Report : aliased constant S := "/REPORT_ERRORS=" & "VERBOSE " & --- 332,339 ---- S_Bind_ReadX : aliased constant S := "/NOREAD_SOURCES " & "-x"; ! S_Bind_Rename : aliased constant S := "/RENAME_MAIN=<" & ! "-M>"; S_Bind_Report : aliased constant S := "/REPORT_ERRORS=" & "VERBOSE " & *************** procedure GNATCmd is *** 275,285 **** S_Bind_ReportX : aliased constant S := "/NOREPORT_ERRORS " & "!-b,!-v"; S_Bind_Search : aliased constant S := "/SEARCH=*" & "-I*"; S_Bind_Shared : aliased constant S := "/SHARED " & ! "-shared"; S_Bind_Source : aliased constant S := "/SOURCE_SEARCH=*" & "-aI*"; --- 346,365 ---- S_Bind_ReportX : aliased constant S := "/NOREPORT_ERRORS " & "!-b,!-v"; + S_Bind_Restr : aliased constant S := "/RESTRICTION_LIST " & + "-r"; + + S_Bind_RTS : aliased constant S := "/RUNTIME_SYSTEM=|" & + "--RTS=|"; + S_Bind_Search : aliased constant S := "/SEARCH=*" & "-I*"; S_Bind_Shared : aliased constant S := "/SHARED " & ! "-shared"; ! ! S_Bind_Slice : aliased constant S := "/TIME_SLICE=#" & ! "-T#"; S_Bind_Source : aliased constant S := "/SOURCE_SEARCH=*" & "-aI*"; *************** procedure GNATCmd is *** 299,339 **** "-we"; S_Bind_WarnX : aliased constant S := "/NOWARNINGS " & ! "-ws"; ! Bind_Switches : aliased constant Switches := ( ! S_Bind_Bind 'Access, ! S_Bind_Build 'Access, ! S_Bind_Current 'Access, ! S_Bind_Debug 'Access, ! S_Bind_DebugX 'Access, ! S_Bind_Elab 'Access, ! S_Bind_Error 'Access, ! S_Ext_Ref 'Access, ! S_Bind_Library 'Access, ! S_Bind_Linker 'Access, ! S_Bind_Main 'Access, ! S_Bind_Nostinc 'Access, ! S_Bind_Nostlib 'Access, ! S_Bind_Object 'Access, ! S_Bind_Order 'Access, ! S_Bind_Output 'Access, ! S_Bind_OutputX 'Access, ! S_Bind_Pess 'Access, ! S_Project_File 'Access, ! S_Project_Verb 'Access, ! S_Bind_Read 'Access, ! S_Bind_ReadX 'Access, ! S_Bind_Rename 'Access, ! S_Bind_Report 'Access, ! S_Bind_ReportX 'Access, ! S_Bind_Search 'Access, ! S_Bind_Shared 'Access, ! S_Bind_Source 'Access, ! S_Bind_Time 'Access, ! S_Bind_Verbose 'Access, ! S_Bind_Warn 'Access, ! S_Bind_WarnX 'Access); ---------------------------- -- Switches for GNAT CHOP -- --- 379,426 ---- "-we"; S_Bind_WarnX : aliased constant S := "/NOWARNINGS " & ! "-ws"; ! Bind_Switches : aliased constant Switches := ! (S_Bind_Bind 'Access, ! S_Bind_Build 'Access, ! S_Bind_Current 'Access, ! S_Bind_Debug 'Access, ! S_Bind_DebugX 'Access, ! S_Bind_Elab 'Access, ! S_Bind_Error 'Access, ! S_Ext_Ref 'Access, ! S_Bind_Help 'Access, ! S_Bind_Init 'Access, ! S_Bind_Library 'Access, ! S_Bind_Linker 'Access, ! S_Bind_List 'Access, ! S_Bind_Main 'Access, ! S_Bind_Nostinc 'Access, ! S_Bind_Nostlib 'Access, ! S_Bind_No_Time 'Access, ! S_Bind_Object 'Access, ! S_Bind_Order 'Access, ! S_Bind_Output 'Access, ! S_Bind_OutputX 'Access, ! S_Bind_Pess 'Access, ! S_Project_File 'Access, ! S_Project_Verb 'Access, ! S_Bind_Read 'Access, ! S_Bind_ReadX 'Access, ! S_Bind_Rename 'Access, ! S_Bind_Report 'Access, ! S_Bind_ReportX 'Access, ! S_Bind_Restr 'Access, ! S_Bind_RTS 'Access, ! S_Bind_Search 'Access, ! S_Bind_Shared 'Access, ! S_Bind_Slice 'Access, ! S_Bind_Source 'Access, ! S_Bind_Time 'Access, ! S_Bind_Verbose 'Access, ! S_Bind_Warn 'Access, ! S_Bind_WarnX 'Access); ---------------------------- -- Switches for GNAT CHOP -- *************** procedure GNATCmd is *** 363,390 **** S_Chop_Verb : aliased constant S := "/VERBOSE " & "-v"; ! Chop_Switches : aliased constant Switches := ( ! S_Chop_Comp 'Access, ! S_Chop_File 'Access, ! S_Chop_Help 'Access, ! S_Chop_Over 'Access, ! S_Chop_Pres 'Access, ! S_Chop_Quiet 'Access, ! S_Chop_Ref 'Access, ! S_Chop_Verb 'Access); ------------------------------- -- Switches for GNAT COMPILE -- ------------------------------- S_GCC_Ada_83 : aliased constant S := "/83 " & ! "-gnat83"; S_GCC_Ada_95 : aliased constant S := "/95 " & ! "!-gnat83"; S_GCC_Asm : aliased constant S := "/ASM " & ! "-S,!-c"; S_GCC_Checks : aliased constant S := "/CHECKS=" & "FULL " & --- 450,477 ---- S_Chop_Verb : aliased constant S := "/VERBOSE " & "-v"; ! Chop_Switches : aliased constant Switches := ! (S_Chop_Comp 'Access, ! S_Chop_File 'Access, ! S_Chop_Help 'Access, ! S_Chop_Over 'Access, ! S_Chop_Pres 'Access, ! S_Chop_Quiet 'Access, ! S_Chop_Ref 'Access, ! S_Chop_Verb 'Access); ------------------------------- -- Switches for GNAT COMPILE -- ------------------------------- S_GCC_Ada_83 : aliased constant S := "/83 " & ! "-gnat83"; S_GCC_Ada_95 : aliased constant S := "/95 " & ! "!-gnat83"; S_GCC_Asm : aliased constant S := "/ASM " & ! "-S,!-c"; S_GCC_Checks : aliased constant S := "/CHECKS=" & "FULL " & *************** procedure GNATCmd is *** 404,413 **** "-gnatp,!-gnato,!-gnatE"; S_GCC_Compres : aliased constant S := "/COMPRESS_NAMES " & ! "-gnatC"; S_GCC_Current : aliased constant S := "/CURRENT_DIRECTORY " & ! "!-I-"; S_GCC_Debug : aliased constant S := "/DEBUG=" & "SYMBOLS " & --- 491,503 ---- "-gnatp,!-gnato,!-gnatE"; S_GCC_Compres : aliased constant S := "/COMPRESS_NAMES " & ! "-gnatC"; ! ! S_GCC_Config : aliased constant S := "/CONFIGURATION_PRAGMAS_FILE=<" & ! "-gnatec>"; S_GCC_Current : aliased constant S := "/CURRENT_DIRECTORY " & ! "!-I-"; S_GCC_Debug : aliased constant S := "/DEBUG=" & "SYMBOLS " & *************** procedure GNATCmd is *** 424,436 **** "-g0"; S_GCC_DebugX : aliased constant S := "/NODEBUG " & ! "!-g"; S_GCC_Dist : aliased constant S := "/DISTRIBUTION_STUBS=" & "RECEIVER " & "-gnatzr " & "CALLER " & ! "-gnatzc"; S_GCC_DistX : aliased constant S := "/NODISTRIBUTION_STUBS " & "!-gnatzr,!-gnatzc"; --- 514,526 ---- "-g0"; S_GCC_DebugX : aliased constant S := "/NODEBUG " & ! "!-g"; S_GCC_Dist : aliased constant S := "/DISTRIBUTION_STUBS=" & "RECEIVER " & "-gnatzr " & "CALLER " & ! "-gnatzc"; S_GCC_DistX : aliased constant S := "/NODISTRIBUTION_STUBS " & "!-gnatzr,!-gnatzc"; *************** procedure GNATCmd is *** 453,458 **** --- 543,551 ---- S_GCC_Force : aliased constant S := "/FORCE_ALI " & "-gnatQ"; + S_GCC_Help : aliased constant S := "/HELP " & + "-gnath"; + S_GCC_Ident : aliased constant S := "/IDENTIFIER_CHARACTER_SET=" & "DEFAULT " & "-gnati1 " & *************** procedure GNATCmd is *** 480,502 **** S_GCC_IdentX : aliased constant S := "/NOIDENTIFIER_CHARACTER_SET " & "-gnati1"; S_GCC_Inline : aliased constant S := "/INLINE=" & "PRAGMA " & "-gnatn " & "SUPPRESS " & ! "-fno-inline"; S_GCC_InlineX : aliased constant S := "/NOINLINE " & ! "!-gnatn"; S_GCC_List : aliased constant S := "/LIST " & ! "-gnatl"; S_GCC_Noload : aliased constant S := "/NOLOAD " & ! "-gnatc"; S_GCC_Nostinc : aliased constant S := "/NOSTD_INCLUDES " & ! "-nostdinc"; S_GCC_Opt : aliased constant S := "/OPTIMIZE=" & "ALL " & --- 573,609 ---- S_GCC_IdentX : aliased constant S := "/NOIDENTIFIER_CHARACTER_SET " & "-gnati1"; + S_GCC_Immed : aliased constant S := "/IMMEDIATE_ERRORS " & + "-gnatdO"; + S_GCC_Inline : aliased constant S := "/INLINE=" & "PRAGMA " & "-gnatn " & + "FULL " & + "-gnatN " & "SUPPRESS " & ! "-fno-inline"; S_GCC_InlineX : aliased constant S := "/NOINLINE " & ! "!-gnatn"; ! ! S_GCC_Jumps : aliased constant S := "/LONGJMP_SETJMP " & ! "-gnatL"; ! ! S_GCC_Length : aliased constant S := "/MAX_LINE_LENGTH=#" & ! "-gnatyM#"; S_GCC_List : aliased constant S := "/LIST " & ! "-gnatl"; ! ! S_GCC_Noadc : aliased constant S := "/NO_GNAT_ADC " & ! "-gnatA"; S_GCC_Noload : aliased constant S := "/NOLOAD " & ! "-gnatc"; S_GCC_Nostinc : aliased constant S := "/NOSTD_INCLUDES " & ! "-nostdinc"; S_GCC_Opt : aliased constant S := "/OPTIMIZE=" & "ALL " & *************** procedure GNATCmd is *** 515,520 **** --- 622,630 ---- S_GCC_OptX : aliased constant S := "/NOOPTIMIZE " & "-O0,!-O1,!-O2,!-O3"; + S_GCC_Polling : aliased constant S := "/POLLING " & + "-gnatP"; + S_GCC_Report : aliased constant S := "/REPORT_ERRORS=" & "VERBOSE " & "-gnatv " & *************** procedure GNATCmd is *** 532,546 **** S_GCC_Repinfo : aliased constant S := "/REPRESENTATION_INFO=" & "ARRAYS " & ! "-gnatR1 " & "NONE " & ! "-gnatR0 " & "OBJECTS " & ! "-gnatR2 " & "SYMBOLIC " & ! "-gnatR3 " & "DEFAULT " & ! "-gnatR"; S_GCC_RepinfX : aliased constant S := "/NOREPRESENTATION_INFO " & "!-gnatR"; --- 642,656 ---- S_GCC_Repinfo : aliased constant S := "/REPRESENTATION_INFO=" & "ARRAYS " & ! "-gnatR1 " & "NONE " & ! "-gnatR0 " & "OBJECTS " & ! "-gnatR2 " & "SYMBOLIC " & ! "-gnatR3 " & "DEFAULT " & ! "-gnatR"; S_GCC_RepinfX : aliased constant S := "/NOREPRESENTATION_INFO " & "!-gnatR"; *************** procedure GNATCmd is *** 599,605 **** "!-gnatg,!-gnatr " & "PRAGMA " & "-gnatyp " & ! "REFERENCES " & "-gnatr " & "SPECS " & "-gnatys " & --- 709,715 ---- "!-gnatg,!-gnatr " & "PRAGMA " & "-gnatyp " & ! "RM_COLUMN_LAYOUT " & "-gnatr " & "SPECS " & "-gnatys " & *************** procedure GNATCmd is *** 632,676 **** S_GCC_Valid : aliased constant S := "/VALIDITY_CHECKING=" & "DEFAULT " & ! "-gnatVd " & "NODEFAULT " & ! "-gnatVD " & "COPIES " & ! "-gnatVc " & "NOCOPIES " & ! "-gnatVC " & "FLOATS " & ! "-gnatVf " & "NOFLOATS " & ! "-gnatVF " & "IN_PARAMS " & ! "-gnatVi " & "NOIN_PARAMS " & ! "-gnatVI " & "MOD_PARAMS " & ! "-gnatVm " & "NOMOD_PARAMS " & ! "-gnatVM " & "OPERANDS " & ! "-gnatVo " & "NOOPERANDS " & ! "-gnatVO " & "RETURNS " & ! "-gnatVr " & "NORETURNS " & ! "-gnatVR " & "SUBSCRIPTS " & ! "-gnatVs " & "NOSUBSCRIPTS " & ! "-gnatVS " & "TESTS " & ! "-gnatVt " & "NOTESTS " & ! "-gnatVT " & "ALL " & ! "-gnatVa " & "NONE " & ! "-gnatVn"; S_GCC_Verbose : aliased constant S := "/VERBOSE " & "-v"; --- 742,786 ---- S_GCC_Valid : aliased constant S := "/VALIDITY_CHECKING=" & "DEFAULT " & ! "-gnatVd " & "NODEFAULT " & ! "-gnatVD " & "COPIES " & ! "-gnatVc " & "NOCOPIES " & ! "-gnatVC " & "FLOATS " & ! "-gnatVf " & "NOFLOATS " & ! "-gnatVF " & "IN_PARAMS " & ! "-gnatVi " & "NOIN_PARAMS " & ! "-gnatVI " & "MOD_PARAMS " & ! "-gnatVm " & "NOMOD_PARAMS " & ! "-gnatVM " & "OPERANDS " & ! "-gnatVo " & "NOOPERANDS " & ! "-gnatVO " & "RETURNS " & ! "-gnatVr " & "NORETURNS " & ! "-gnatVR " & "SUBSCRIPTS " & ! "-gnatVs " & "NOSUBSCRIPTS " & ! "-gnatVS " & "TESTS " & ! "-gnatVt " & "NOTESTS " & ! "-gnatVT " & "ALL " & ! "-gnatVa " & "NONE " & ! "-gnatVn"; S_GCC_Verbose : aliased constant S := "/VERBOSE " & "-v"; *************** procedure GNATCmd is *** 680,689 **** --- 790,807 ---- "!-gnatws,!-gnatwe " & "ALL_GCC " & "-Wall " & + "BIASED_ROUNDING " & + "-gnatwb " & + "NOBIASED_ROUNDING " & + "-gnatwB " & "CONDITIONALS " & "-gnatwc " & "NOCONDITIONALS " & "-gnatwC " & + "IMPLICIT_DEREFERENCE " & + "-gnatwd " & + "NO_IMPLICIT_DEREFERENCE " & + "-gnatwD " & "ELABORATION " & "-gnatwl " & "NOELABORATION " & *************** procedure GNATCmd is *** 698,703 **** --- 816,825 ---- "-gnatwi " & "NOIMPLEMENTATION " & "-gnatwI " & + "INEFFECTIVE_INLINE " & + "-gnatwp " & + "NOINEFFECTIVE_INLINE " & + "-gnatwP " & "OPTIONAL " & "-gnatwa " & "NOOPTIONAL " & *************** procedure GNATCmd is *** 714,719 **** --- 836,845 ---- "-gnatws " & "UNINITIALIZED " & "-Wuninitialized " & + "UNREFERENCED_FORMALS " & + "-gnatwf " & + "NOUNREFERENCED_FORMALS " & + "-gnatwF " & "UNUSED " & "-gnatwu " & "NOUNUSED " & *************** procedure GNATCmd is *** 739,804 **** "-gnatWe"; S_GCC_WideX : aliased constant S := "/NOWIDE_CHARACTER_ENCODING " & ! "-gnatWn"; S_GCC_Xdebug : aliased constant S := "/XDEBUG " & ! "-gnatD"; S_GCC_Xref : aliased constant S := "/XREF=" & "GENERATE " & ! "!-gnatx " & "SUPPRESS " & ! "-gnatx"; ! GCC_Switches : aliased constant Switches := ( ! S_GCC_Ada_83 'Access, ! S_GCC_Ada_95 'Access, ! S_GCC_Asm 'Access, ! S_GCC_Checks 'Access, ! S_GCC_ChecksX 'Access, ! S_GCC_Compres 'Access, ! S_GCC_Current 'Access, ! S_GCC_Debug 'Access, ! S_GCC_DebugX 'Access, ! S_GCC_Dist 'Access, ! S_GCC_DistX 'Access, ! S_GCC_Error 'Access, ! S_GCC_ErrorX 'Access, ! S_GCC_Expand 'Access, ! S_GCC_Extend 'Access, ! S_GCC_File 'Access, ! S_GCC_Force 'Access, ! S_GCC_Ident 'Access, ! S_GCC_IdentX 'Access, ! S_GCC_Inline 'Access, ! S_GCC_InlineX 'Access, ! S_GCC_List 'Access, ! S_GCC_Noload 'Access, ! S_GCC_Nostinc 'Access, ! S_GCC_Opt 'Access, ! S_GCC_OptX 'Access, ! S_GCC_Report 'Access, ! S_GCC_ReportX 'Access, ! S_GCC_Repinfo 'Access, ! S_GCC_RepinfX 'Access, ! S_GCC_Search 'Access, ! S_GCC_Style 'Access, ! S_GCC_StyleX 'Access, ! S_GCC_Syntax 'Access, ! S_GCC_Trace 'Access, ! S_GCC_Tree 'Access, ! S_GCC_Trys 'Access, ! S_GCC_Units 'Access, ! S_GCC_Unique 'Access, ! S_GCC_Upcase 'Access, ! S_GCC_Valid 'Access, ! S_GCC_Verbose 'Access, ! S_GCC_Warn 'Access, ! S_GCC_WarnX 'Access, ! S_GCC_Wide 'Access, ! S_GCC_WideX 'Access, ! S_GCC_Xdebug 'Access, ! S_GCC_Xref 'Access); ---------------------------- -- Switches for GNAT ELIM -- --- 865,940 ---- "-gnatWe"; S_GCC_WideX : aliased constant S := "/NOWIDE_CHARACTER_ENCODING " & ! "-gnatWn"; S_GCC_Xdebug : aliased constant S := "/XDEBUG " & ! "-gnatD"; S_GCC_Xref : aliased constant S := "/XREF=" & "GENERATE " & ! "!-gnatx " & "SUPPRESS " & ! "-gnatx"; ! GCC_Switches : aliased constant Switches := ! (S_GCC_Ada_83 'Access, ! S_GCC_Ada_95 'Access, ! S_GCC_Asm 'Access, ! S_GCC_Checks 'Access, ! S_GCC_ChecksX 'Access, ! S_GCC_Compres 'Access, ! S_GCC_Config 'Access, ! S_GCC_Current 'Access, ! S_GCC_Debug 'Access, ! S_GCC_DebugX 'Access, ! S_GCC_Dist 'Access, ! S_GCC_DistX 'Access, ! S_GCC_Error 'Access, ! S_GCC_ErrorX 'Access, ! S_GCC_Expand 'Access, ! S_GCC_Extend 'Access, ! S_Ext_Ref 'Access, ! S_GCC_File 'Access, ! S_GCC_Force 'Access, ! S_GCC_Help 'Access, ! S_GCC_Ident 'Access, ! S_GCC_IdentX 'Access, ! S_GCC_Immed 'Access, ! S_GCC_Inline 'Access, ! S_GCC_InlineX 'Access, ! S_GCC_Jumps 'Access, ! S_GCC_Length 'Access, ! S_GCC_List 'Access, ! S_GCC_Noadc 'Access, ! S_GCC_Noload 'Access, ! S_GCC_Nostinc 'Access, ! S_GCC_Opt 'Access, ! S_GCC_OptX 'Access, ! S_GCC_Polling 'Access, ! S_Project_File'Access, ! S_Project_Verb'Access, ! S_GCC_Report 'Access, ! S_GCC_ReportX 'Access, ! S_GCC_Repinfo 'Access, ! S_GCC_RepinfX 'Access, ! S_GCC_Search 'Access, ! S_GCC_Style 'Access, ! S_GCC_StyleX 'Access, ! S_GCC_Syntax 'Access, ! S_GCC_Trace 'Access, ! S_GCC_Tree 'Access, ! S_GCC_Trys 'Access, ! S_GCC_Units 'Access, ! S_GCC_Unique 'Access, ! S_GCC_Upcase 'Access, ! S_GCC_Valid 'Access, ! S_GCC_Verbose 'Access, ! S_GCC_Warn 'Access, ! S_GCC_WarnX 'Access, ! S_GCC_Wide 'Access, ! S_GCC_WideX 'Access, ! S_GCC_Xdebug 'Access, ! S_GCC_Xref 'Access); ---------------------------- -- Switches for GNAT ELIM -- *************** procedure GNATCmd is *** 807,822 **** S_Elim_All : aliased constant S := "/ALL " & "-a"; S_Elim_Miss : aliased constant S := "/MISSED " & "-m"; S_Elim_Verb : aliased constant S := "/VERBOSE " & "-v"; ! Elim_Switches : aliased constant Switches := ( ! S_Elim_All 'Access, ! S_Elim_Miss 'Access, ! S_Elim_Verb 'Access); ---------------------------- -- Switches for GNAT FIND -- --- 943,970 ---- S_Elim_All : aliased constant S := "/ALL " & "-a"; + S_Elim_Bind : aliased constant S := "/BIND_FILE=<" & + "-b>"; + S_Elim_Miss : aliased constant S := "/MISSED " & "-m"; + S_Elim_Quiet : aliased constant S := "/QUIET " & + "-q"; + + S_Elim_Tree : aliased constant S := "/TREE_DIRS=*" & + "-T*"; + S_Elim_Verb : aliased constant S := "/VERBOSE " & "-v"; ! Elim_Switches : aliased constant Switches := ! (S_Elim_All 'Access, ! S_Elim_Bind 'Access, ! S_Elim_Miss 'Access, ! S_Elim_Quiet 'Access, ! S_Elim_Tree 'Access, ! S_Elim_Verb 'Access); ---------------------------- -- Switches for GNAT FIND -- *************** procedure GNATCmd is *** 825,830 **** --- 973,981 ---- S_Find_All : aliased constant S := "/ALL_FILES " & "-a"; + S_Find_Deriv : aliased constant S := "/DERIVED_TYPE_INFORMATION " & + "-d"; + S_Find_Expr : aliased constant S := "/EXPRESSIONS " & "-e"; *************** procedure GNATCmd is *** 834,839 **** --- 985,996 ---- S_Find_Ignore : aliased constant S := "/IGNORE_LOCALS " & "-g"; + S_Find_Nostinc : aliased constant S := "/NOSTD_INCLUDES " & + "-nostdinc"; + + S_Find_Nostlib : aliased constant S := "/NOSTD_LIBRARIES " & + "-nostdlib"; + S_Find_Object : aliased constant S := "/OBJECT_SEARCH=*" & "-aO*"; *************** procedure GNATCmd is *** 852,863 **** S_Find_Source : aliased constant S := "/SOURCE_SEARCH=*" & "-aI*"; ! Find_Switches : aliased constant Switches := ( ! S_Find_All 'Access, S_Find_Expr 'Access, S_Ext_Ref 'Access, S_Find_Full 'Access, S_Find_Ignore 'Access, S_Find_Object 'Access, S_Find_Print 'Access, S_Find_Project 'Access, --- 1009,1026 ---- S_Find_Source : aliased constant S := "/SOURCE_SEARCH=*" & "-aI*"; ! S_Find_Types : aliased constant S := "/TYPE_HIERARCHY " & ! "-t"; ! ! Find_Switches : aliased constant Switches := ! (S_Find_All 'Access, ! S_Find_Deriv 'Access, S_Find_Expr 'Access, S_Ext_Ref 'Access, S_Find_Full 'Access, S_Find_Ignore 'Access, + S_Find_Nostinc 'Access, + S_Find_Nostlib 'Access, S_Find_Object 'Access, S_Find_Print 'Access, S_Find_Project 'Access, *************** procedure GNATCmd is *** 865,871 **** S_Project_Verb 'Access, S_Find_Ref 'Access, S_Find_Search 'Access, ! S_Find_Source 'Access); ------------------------------ -- Switches for GNAT KRUNCH -- --- 1028,1035 ---- S_Project_Verb 'Access, S_Find_Ref 'Access, S_Find_Search 'Access, ! S_Find_Source 'Access, ! S_Find_Types 'Access); ------------------------------ -- Switches for GNAT KRUNCH -- *************** procedure GNATCmd is *** 874,881 **** S_Krunch_Count : aliased constant S := "/COUNT=#" & "`#"; ! Krunch_Switches : aliased constant Switches := (1 .. 1 => ! S_Krunch_Count 'Access); ------------------------------- -- Switches for GNAT LIBRARY -- --- 1038,1045 ---- S_Krunch_Count : aliased constant S := "/COUNT=#" & "`#"; ! Krunch_Switches : aliased constant Switches := ! (1 .. 1 => S_Krunch_Count 'Access); ------------------------------- -- Switches for GNAT LIBRARY -- *************** procedure GNATCmd is *** 885,903 **** "--config=@"; S_Lbr_Create : aliased constant S := "/CREATE=%" & ! "--create=%"; S_Lbr_Delete : aliased constant S := "/DELETE=%" & ! "--delete=%"; S_Lbr_Set : aliased constant S := "/SET=%" & ! "--set=%"; ! Lbr_Switches : aliased constant Switches := ( ! S_Lbr_Config 'Access, ! S_Lbr_Create 'Access, ! S_Lbr_Delete 'Access, ! S_Lbr_Set 'Access); ---------------------------- -- Switches for GNAT LINK -- --- 1049,1067 ---- "--config=@"; S_Lbr_Create : aliased constant S := "/CREATE=%" & ! "--create=%"; S_Lbr_Delete : aliased constant S := "/DELETE=%" & ! "--delete=%"; S_Lbr_Set : aliased constant S := "/SET=%" & ! "--set=%"; ! Lbr_Switches : aliased constant Switches := ! (S_Lbr_Config 'Access, ! S_Lbr_Create 'Access, ! S_Lbr_Delete 'Access, ! S_Lbr_Set 'Access); ---------------------------- -- Switches for GNAT LINK -- *************** procedure GNATCmd is *** 922,927 **** --- 1086,1094 ---- S_Link_Execut : aliased constant S := "/EXECUTABLE=@" & "-o@"; + S_Link_Force : aliased constant S := "/FORCE_OBJECT_FILE_LIST " & + "-f"; + S_Link_Ident : aliased constant S := "/IDENTIFICATION=" & '"' & "--for-linker=IDENT=" & '"'; *************** procedure GNATCmd is *** 944,954 **** S_Link_ZZZZZ : aliased constant S := "/ " & "--for-linker="; ! Link_Switches : aliased constant Switches := ( ! S_Link_Bind 'Access, S_Link_Debug 'Access, S_Link_Execut 'Access, S_Ext_Ref 'Access, S_Link_Ident 'Access, S_Link_Nocomp 'Access, S_Link_Nofiles 'Access, --- 1111,1122 ---- S_Link_ZZZZZ : aliased constant S := "/ " & "--for-linker="; ! Link_Switches : aliased constant Switches := ! (S_Link_Bind 'Access, S_Link_Debug 'Access, S_Link_Execut 'Access, S_Ext_Ref 'Access, + S_Link_Force 'Access, S_Link_Ident 'Access, S_Link_Nocomp 'Access, S_Link_Nofiles 'Access, *************** procedure GNATCmd is *** 969,977 **** S_List_Current : aliased constant S := "/CURRENT_DIRECTORY " & "!-I-"; - S_List_Depend : aliased constant S := "/DEPENDENCIES " & - "-d"; - S_List_Nostinc : aliased constant S := "/NOSTD_INCLUDES " & "-nostdinc"; --- 1137,1142 ---- *************** procedure GNATCmd is *** 981,986 **** --- 1146,1153 ---- S_List_Output : aliased constant S := "/OUTPUT=" & "SOURCES " & "-s " & + "DEPEND " & + "-d " & "OBJECTS " & "-o " & "UNITS " & *************** procedure GNATCmd is *** 996,1013 **** S_List_Source : aliased constant S := "/SOURCE_SEARCH=*" & "-aI*"; ! List_Switches : aliased constant Switches := ( ! S_List_All 'Access, ! S_List_Current 'Access, ! S_List_Depend 'Access, ! S_Ext_Ref 'Access, ! S_List_Nostinc 'Access, ! S_List_Object 'Access, ! S_List_Output 'Access, ! S_Project_File 'Access, ! S_Project_Verb 'Access, ! S_List_Search 'Access, ! S_List_Source 'Access); ---------------------------- -- Switches for GNAT MAKE -- --- 1163,1179 ---- S_List_Source : aliased constant S := "/SOURCE_SEARCH=*" & "-aI*"; ! List_Switches : aliased constant Switches := ! (S_List_All 'Access, ! S_List_Current 'Access, ! S_Ext_Ref 'Access, ! S_List_Nostinc 'Access, ! S_List_Object 'Access, ! S_List_Output 'Access, ! S_Project_File 'Access, ! S_Project_Verb 'Access, ! S_List_Search 'Access, ! S_List_Source 'Access); ---------------------------- -- Switches for GNAT MAKE -- *************** procedure GNATCmd is *** 1015,1025 **** S_Make_Actions : aliased constant S := "/ACTIONS=" & "COMPILE " & ! "-c " & "BIND " & ! "-b " & "LINK " & ! "-l "; S_Make_All : aliased constant S := "/ALL_FILES " & "-a"; --- 1181,1191 ---- S_Make_Actions : aliased constant S := "/ACTIONS=" & "COMPILE " & ! "-c " & "BIND " & ! "-b " & "LINK " & ! "-l "; S_Make_All : aliased constant S := "/ALL_FILES " & "-a"; *************** procedure GNATCmd is *** 1052,1058 **** "-f"; S_Make_Inplace : aliased constant S := "/IN_PLACE " & ! "-i"; S_Make_Library : aliased constant S := "/LIBRARY_SEARCH=*" & "-L*"; --- 1218,1224 ---- "-f"; S_Make_Inplace : aliased constant S := "/IN_PLACE " & ! "-i"; S_Make_Library : aliased constant S := "/LIBRARY_SEARCH=*" & "-L*"; *************** procedure GNATCmd is *** 1060,1071 **** S_Make_Link : aliased constant S := "/LINKER_QUALIFIERS=?" & "-largs LINK"; S_Make_Minimal : aliased constant S := "/MINIMAL_RECOMPILATION " & ! "-m"; S_Make_Nolink : aliased constant S := "/NOLINK " & "-c"; S_Make_Nostinc : aliased constant S := "/NOSTD_INCLUDES " & "-nostdinc"; --- 1226,1243 ---- S_Make_Link : aliased constant S := "/LINKER_QUALIFIERS=?" & "-largs LINK"; + S_Make_Mapping : aliased constant S := "/MAPPING " & + "-C"; + S_Make_Minimal : aliased constant S := "/MINIMAL_RECOMPILATION " & ! "-m"; S_Make_Nolink : aliased constant S := "/NOLINK " & "-c"; + S_Make_Nomain : aliased constant S := "/NOMAIN " & + "-z"; + S_Make_Nostinc : aliased constant S := "/NOSTD_INCLUDES " & "-nostdinc"; *************** procedure GNATCmd is *** 1087,1092 **** --- 1259,1267 ---- S_Make_Reason : aliased constant S := "/REASONS " & "-v"; + S_Make_RTS : aliased constant S := "/RUNTIME_SYSTEM=|" & + "--RTS=|"; + S_Make_Search : aliased constant S := "/SEARCH=*" & "-I*"; *************** procedure GNATCmd is *** 1096,1140 **** S_Make_Source : aliased constant S := "/SOURCE_SEARCH=*" & "-aI*"; S_Make_Verbose : aliased constant S := "/VERBOSE " & "-v"; ! Make_Switches : aliased constant Switches := ( ! S_Make_Actions 'Access, ! S_Make_All 'Access, ! S_Make_Bind 'Access, ! S_Make_Comp 'Access, ! S_Make_Cond 'Access, ! S_Make_Cont 'Access, ! S_Make_Current 'Access, ! S_Make_Dep 'Access, ! S_Make_Doobj 'Access, ! S_Make_Execut 'Access, ! S_Ext_Ref 'Access, ! S_Make_Force 'Access, ! S_Make_Inplace 'Access, ! S_Make_Library 'Access, ! S_Make_Link 'Access, ! S_Make_Minimal 'Access, ! S_Make_Nolink 'Access, ! S_Make_Nostinc 'Access, ! S_Make_Nostlib 'Access, ! S_Make_Object 'Access, ! S_Make_Proc 'Access, ! S_Project_File 'Access, ! S_Project_Verb 'Access, ! S_Make_Nojobs 'Access, ! S_Make_Quiet 'Access, ! S_Make_Reason 'Access, ! S_Make_Search 'Access, ! S_Make_Skip 'Access, ! S_Make_Source 'Access, ! S_Make_Verbose 'Access); ---------------------------------- -- Switches for GNAT PREPROCESS -- ---------------------------------- S_Prep_Blank : aliased constant S := "/BLANK_LINES " & "-b"; --- 1271,1359 ---- S_Make_Source : aliased constant S := "/SOURCE_SEARCH=*" & "-aI*"; + S_Make_Switch : aliased constant S := "/SWITCH_CHECK " & + "-s"; + + S_Make_Unique : aliased constant S := "/UNIQUE " & + "-u"; + S_Make_Verbose : aliased constant S := "/VERBOSE " & "-v"; ! Make_Switches : aliased constant Switches := ! (S_Make_Actions 'Access, ! S_Make_All 'Access, ! S_Make_Bind 'Access, ! S_Make_Comp 'Access, ! S_Make_Cond 'Access, ! S_Make_Cont 'Access, ! S_Make_Current 'Access, ! S_Make_Dep 'Access, ! S_Make_Doobj 'Access, ! S_Make_Execut 'Access, ! S_Ext_Ref 'Access, ! S_Make_Force 'Access, ! S_Make_Inplace 'Access, ! S_Make_Library 'Access, ! S_Make_Link 'Access, ! S_Make_Mapping 'Access, ! S_Make_Minimal 'Access, ! S_Make_Nolink 'Access, ! S_Make_Nomain 'Access, ! S_Make_Nostinc 'Access, ! S_Make_Nostlib 'Access, ! S_Make_Object 'Access, ! S_Make_Proc 'Access, ! S_Project_File 'Access, ! S_Project_Verb 'Access, ! S_Make_Nojobs 'Access, ! S_Make_Quiet 'Access, ! S_Make_Reason 'Access, ! S_Make_RTS 'Access, ! S_Make_Search 'Access, ! S_Make_Skip 'Access, ! S_Make_Source 'Access, ! S_Make_Switch 'Access, ! S_Make_Unique 'Access, ! S_Make_Verbose 'Access); ! ! ---------------------------- ! -- Switches for GNAT Name -- ! ---------------------------- ! ! S_Name_Conf : aliased constant S := "/CONFIG_FILE=<" & ! "-c>"; ! ! S_Name_Dirs : aliased constant S := "/SOURCE_DIRS=*" & ! "-d*"; ! ! S_Name_Dfile : aliased constant S := "/DIRS_FILE=<" & ! "-D>"; ! ! S_Name_Help : aliased constant S := "/HELP" & ! " -h"; ! ! S_Name_Proj : aliased constant S := "/PROJECT_FILE=<" & ! "-P>"; ! ! S_Name_Verbose : aliased constant S := "/VERBOSE" & ! " -v"; ! ! Name_Switches : aliased constant Switches := ! (S_Name_Conf 'Access, ! S_Name_Dirs 'Access, ! S_Name_Dfile 'Access, ! S_Name_Help 'Access, ! S_Name_Proj 'Access, ! S_Name_Verbose 'Access); ---------------------------------- -- Switches for GNAT PREPROCESS -- ---------------------------------- + S_Prep_Assoc : aliased constant S := "/ASSOCIATE=" & '"' & + "-D" & '"'; + S_Prep_Blank : aliased constant S := "/BLANK_LINES " & "-b"; *************** procedure GNATCmd is *** 1153,1173 **** S_Prep_Undef : aliased constant S := "/UNDEFINED " & "-u"; ! S_Prep_Verbose : aliased constant S := "/VERBOSE " & ! "-v"; ! ! S_Prep_Version : aliased constant S := "/VERSION " & ! "-v"; ! ! Prep_Switches : aliased constant Switches := ( ! S_Prep_Blank 'Access, ! S_Prep_Com 'Access, ! S_Prep_Ref 'Access, ! S_Prep_Remove 'Access, ! S_Prep_Symbols 'Access, ! S_Prep_Undef 'Access, ! S_Prep_Verbose 'Access, ! S_Prep_Version 'Access); ------------------------------ -- Switches for GNAT SHARED -- --- 1372,1385 ---- S_Prep_Undef : aliased constant S := "/UNDEFINED " & "-u"; ! Prep_Switches : aliased constant Switches := ! (S_Prep_Assoc 'Access, ! S_Prep_Blank 'Access, ! S_Prep_Com 'Access, ! S_Prep_Ref 'Access, ! S_Prep_Remove 'Access, ! S_Prep_Symbols 'Access, ! S_Prep_Undef 'Access); ------------------------------ -- Switches for GNAT SHARED -- *************** procedure GNATCmd is *** 1202,1209 **** S_Shared_ZZZZZ : aliased constant S := "/ " & "--for-linker="; ! Shared_Switches : aliased constant Switches := ( ! S_Shared_Debug 'Access, S_Shared_Image 'Access, S_Shared_Ident 'Access, S_Shared_Nofiles 'Access, --- 1414,1421 ---- S_Shared_ZZZZZ : aliased constant S := "/ " & "--for-linker="; ! Shared_Switches : aliased constant Switches := ! (S_Shared_Debug 'Access, S_Shared_Image 'Access, S_Shared_Ident 'Access, S_Shared_Nofiles 'Access, *************** procedure GNATCmd is *** 1256,1277 **** S_Stub_Verbose : aliased constant S := "/VERBOSE " & "-v"; ! Stub_Switches : aliased constant Switches := ( ! S_Stub_Current 'Access, ! S_Stub_Full 'Access, ! S_Stub_Header 'Access, ! S_Stub_Indent 'Access, ! S_Stub_Length 'Access, ! S_Stub_Quiet 'Access, ! S_Stub_Search 'Access, ! S_Stub_Tree 'Access, ! S_Stub_Verbose 'Access); ! ! ------------------------------ ! -- Switches for GNAT SYSTEM -- ! ------------------------------ ! ! System_Switches : aliased constant Switches := (1 .. 0 => null); ---------------------------- -- Switches for GNAT XREF -- --- 1468,1483 ---- S_Stub_Verbose : aliased constant S := "/VERBOSE " & "-v"; ! Stub_Switches : aliased constant Switches := ! (S_Stub_Current 'Access, ! S_Stub_Full 'Access, ! S_Stub_Header 'Access, ! S_Stub_Indent 'Access, ! S_Stub_Length 'Access, ! S_Stub_Quiet 'Access, ! S_Stub_Search 'Access, ! S_Stub_Tree 'Access, ! S_Stub_Verbose 'Access); ---------------------------- -- Switches for GNAT XREF -- *************** procedure GNATCmd is *** 1280,1291 **** --- 1486,1506 ---- S_Xref_All : aliased constant S := "/ALL_FILES " & "-a"; + S_Xref_Deriv : aliased constant S := "/DERIVED_TYPES " & + "-d"; + S_Xref_Full : aliased constant S := "/FULL_PATHNAME " & "-f"; S_Xref_Global : aliased constant S := "/IGNORE_LOCALS " & "-g"; + S_Xref_Nostinc : aliased constant S := "/NOSTD_INCLUDES " & + "-nostdinc"; + + S_Xref_Nostlib : aliased constant S := "/NOSTD_LIBRARIES " & + "-nostdlib"; + S_Xref_Object : aliased constant S := "/OBJECT_SEARCH=*" & "-aO*"; *************** procedure GNATCmd is *** 1301,1318 **** S_Xref_Output : aliased constant S := "/UNUSED " & "-u"; ! Xref_Switches : aliased constant Switches := ( ! S_Xref_All 'Access, S_Ext_Ref 'Access, S_Xref_Full 'Access, S_Xref_Global 'Access, S_Xref_Object 'Access, S_Xref_Project 'Access, S_Project_File 'Access, S_Project_Verb 'Access, S_Xref_Search 'Access, S_Xref_Source 'Access, ! S_Xref_Output 'Access); ------------------- -- COMMAND TABLE -- --- 1516,1540 ---- S_Xref_Output : aliased constant S := "/UNUSED " & "-u"; ! S_Xref_Tags : aliased constant S := "/TAGS " & ! "-v"; ! ! Xref_Switches : aliased constant Switches := ! (S_Xref_All 'Access, ! S_Xref_Deriv 'Access, S_Ext_Ref 'Access, S_Xref_Full 'Access, S_Xref_Global 'Access, + S_Xref_Nostinc 'Access, + S_Xref_Nostlib 'Access, S_Xref_Object 'Access, S_Xref_Project 'Access, S_Project_File 'Access, S_Project_Verb 'Access, S_Xref_Search 'Access, S_Xref_Source 'Access, ! S_Xref_Output 'Access, ! S_Xref_Tags 'Access); ------------------- -- COMMAND TABLE -- *************** procedure GNATCmd is *** 1334,1342 **** -- A parameter that's passed through as is (not canonicalized) Unlimited_Files, ! -- An unlimited number of writespace separate file or directory -- parameters including wildcard specifications. Files_Or_Wildcard); -- A comma separated list of files and/or wildcard file specifications. -- A comma preceded by or followed by whitespace is considered as a --- 1556,1568 ---- -- A parameter that's passed through as is (not canonicalized) Unlimited_Files, ! -- An unlimited number of whitespace separate file or directory -- parameters including wildcard specifications. + Unlimited_As_Is, + -- Un unlimited number of whitespace separated paameters that are + -- passed through as is (not canonicalized). + Files_Or_Wildcard); -- A comma separated list of files and/or wildcard file specifications. -- A comma preceded by or followed by whitespace is considered as a *************** procedure GNATCmd is *** 1345,1350 **** --- 1571,1593 ---- type Parameter_Array is array (Natural range <>) of Parameter_Type; type Parameter_Ref is access all Parameter_Array; + type Command_Type is + (Bind, Chop, Compile, Elim, Find, Krunch, Library, Link, List, + Make, Name, Preprocess, Shared, Standard, Stub, Xref, Undefined); + + type Alternate_Command is (Comp, Ls, Kr, Prep, Psta); + -- Alternate command libel for non VMS system + + Corresponding_To : constant array (Alternate_Command) of Command_Type := + (Comp => Compile, + Ls => List, + Kr => Krunch, + Prep => Preprocess, + Psta => Standard); + -- Mapping of alternate commands to commands + + subtype Real_Command_Type is Command_Type range Bind .. Xref; + type Command_Entry is record Cname : String_Ptr; -- Command name for GNAT xxx command *************** procedure GNATCmd is *** 1352,1360 **** Usage : String_Ptr; -- A usage string, used for error messages ! Unixcmd : String_Ptr; -- Corresponding Unix command Switches : Switches_Ptr; -- Pointer to array of switch strings --- 1595,1609 ---- Usage : String_Ptr; -- A usage string, used for error messages ! Unixcmd : String_Ptr; -- Corresponding Unix command + Unixsws : Argument_List_Access; + -- Switches for the Unix command + + VMS_Only : Boolean; + -- When True, the command can only be used on VMS + Switches : Switches_Ptr; -- Pointer to array of switch strings *************** procedure GNATCmd is *** 1398,1406 **** -- Example: GNAT LIBRARY /SET=[.VAXFLOATLIB] T_File, ! -- A quailifier followed by a filename -- Example: GNAT LINK /EXECUTABLE=FOO.EXE T_Numeric, -- A qualifier followed by a numeric value. -- Example: GNAT CHOP /FILE_NAME_MAX_LENGTH=39 --- 1647,1659 ---- -- Example: GNAT LIBRARY /SET=[.VAXFLOATLIB] T_File, ! -- A qualifier followed by a filename -- Example: GNAT LINK /EXECUTABLE=FOO.EXE + T_No_Space_File, + -- A qualifier followed by a filename + -- Example: GNAT MAKE /PROJECT_FILE=PRJ.GPR + T_Numeric, -- A qualifier followed by a numeric value. -- Example: GNAT CHOP /FILE_NAME_MAX_LENGTH=39 *************** procedure GNATCmd is *** 1429,1435 **** -- A qualifier followed by a legal linker symbol prefix. Only used -- for BIND /BUILD_LIBRARY (gnatbind -Lxyz). -- Example: GNAT BIND /BUILD_LIBRARY=foobar ! ); type Item (Id : Item_Id); type Item_Ptr is access all Item; --- 1682,1688 ---- -- A qualifier followed by a legal linker symbol prefix. Only used -- for BIND /BUILD_LIBRARY (gnatbind -Lxyz). -- Example: GNAT BIND /BUILD_LIBRARY=foobar ! ); type Item (Id : Item_Id); type Item_Ptr is access all Item; *************** procedure GNATCmd is *** 1441,1447 **** Next : Item_Ptr; -- Pointer to next item on list, always has the same Id value ! Unix_String : String_Ptr; -- Corresponding Unix string. For a command, this is the unix command -- name and possible default switches. For a switch or option it is -- the unix switch string. --- 1694,1702 ---- Next : Item_Ptr; -- Pointer to next item on list, always has the same Id value ! Command : Command_Type := Undefined; ! ! Unix_String : String_Ptr := null; -- Corresponding Unix string. For a command, this is the unix command -- name and possible default switches. For a switch or option it is -- the unix switch string. *************** procedure GNATCmd is *** 1511,1516 **** --- 1766,1773 ---- Errors : Natural := 0; -- Count errors detected + Command_Arg : Positive := 1; + Command : Item_Ptr; -- Pointer to command item for current command *************** procedure GNATCmd is *** 1521,1533 **** My_Exit_Status : Exit_Status := Success; ! package Buffer is new Table.Table ( ! Table_Component_Type => Character, ! Table_Index_Type => Integer, ! Table_Low_Bound => 1, ! Table_Initial => 4096, ! Table_Increment => 2, ! Table_Name => "Buffer"); Param_Count : Natural := 0; -- Number of parameter arguments so far --- 1778,1790 ---- My_Exit_Status : Exit_Status := Success; ! package Buffer is new Table.Table ! (Table_Component_Type => Character, ! Table_Index_Type => Integer, ! Table_Low_Bound => 1, ! Table_Initial => 4096, ! Table_Increment => 2, ! Table_Name => "Buffer"); Param_Count : Natural := 0; -- Number of parameter arguments so far *************** procedure GNATCmd is *** 1536,1548 **** -- Argument number Display_Command : Boolean := False; ! -- Set true if /? switch causes display of generated command ----------------------- -- Local Subprograms -- ----------------------- ! function Init_Object_Dirs return String_Ptr; function Invert_Sense (S : String) return String_Ptr; -- Given a unix switch string S, computes the inverse (adding or --- 1793,1812 ---- -- Argument number Display_Command : Boolean := False; ! -- Set true if /? switch causes display of generated command (on VMS) ! ! The_Command : Command_Type; ! -- The command used ----------------------- -- Local Subprograms -- ----------------------- ! function Index (Char : Character; Str : String) return Natural; ! -- Returns the first occurrence of Char in Str. ! -- Returns 0 if Char is not in Str. ! ! function Init_Object_Dirs return Argument_List; function Invert_Sense (S : String) return String_Ptr; -- Given a unix switch string S, computes the inverse (adding or *************** procedure GNATCmd is *** 1575,1580 **** --- 1839,1847 ---- -- error message is generated in a not found situation (null is still -- returned to indicate the not-found situation). + procedure Non_VMS_Usage; + -- Display usage for platforms other than VMS + function OK_Alphanumerplus (S : String) return Boolean; -- Checks that S is a string of alphanumeric characters, -- returning True if all alphanumeric characters, *************** procedure GNATCmd is *** 1584,1589 **** --- 1851,1859 ---- -- Checks that S is a string of digits, returning True if all digits, -- False if empty or a non-digit is present. + procedure Output_Version; + -- Output the version of this program + procedure Place (C : Character); -- Place a single character in the buffer, updating Ptr *************** procedure GNATCmd is *** 1598,1603 **** --- 1868,1884 ---- -- updating Ptr appropriatelly. Note that in the case of use of ! the -- result may be to remove a previously placed switch. + procedure Set_Library_For + (Project : Project_Id; + There_Are_Libraries : in out Boolean); + -- If Project is a library project, add the correct + -- -L and -l switches to the linker invocation. + + procedure Set_Libraries is + new For_Every_Project_Imported (Boolean, Set_Library_For); + -- Add the -L and -l switches to the linker for all + -- of the library projects. + procedure Validate_Command_Or_Option (N : String_Ptr); -- Check that N is a valid command or option name, i.e. that it is of the -- form of an Ada identifier with upper case letters and underscores. *************** procedure GNATCmd is *** 1606,1618 **** -- Check that S is a valid switch string as described in the syntax for -- the switch table item UNIX_SWITCH or else begins with a backquote. ---------------------- -- Init_Object_Dirs -- ---------------------- ! function Init_Object_Dirs return String_Ptr is Object_Dirs : Integer; ! Object_Dir : array (Integer range 1 .. 256) of String_Access; Object_Dir_Name : String_Access; begin --- 1887,1917 ---- -- Check that S is a valid switch string as described in the syntax for -- the switch table item UNIX_SWITCH or else begins with a backquote. + procedure VMS_Conversion (The_Command : out Command_Type); + -- Converts VMS command line to equivalent Unix command line + + ----------- + -- Index -- + ----------- + + function Index (Char : Character; Str : String) return Natural is + begin + for Index in Str'Range loop + if Str (Index) = Char then + return Index; + end if; + end loop; + + return 0; + end Index; + ---------------------- -- Init_Object_Dirs -- ---------------------- ! function Init_Object_Dirs return Argument_List is Object_Dirs : Integer; ! Object_Dir : Argument_List (1 .. 256); Object_Dir_Name : String_Access; begin *************** procedure GNATCmd is *** 1627,1692 **** begin exit when Dir = null; Object_Dirs := Object_Dirs + 1; ! Object_Dir (Object_Dirs) ! := String_Access (Normalize_Directory_Name (Dir.all)); end; end loop; ! for Dirs in 1 .. Object_Dirs loop ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := '-'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'L'; ! Object_Dir_Name := new String'( ! To_Canonical_Dir_Spec ! (To_Host_Dir_Spec (Object_Dir (Dirs).all, True).all, True).all); ! ! for J in Object_Dir_Name'Range loop ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := Object_Dir_Name (J); ! end loop; ! ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := ' '; ! end loop; ! ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := '-'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'l'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'g'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'n'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'a'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 't'; if Hostparm.OpenVMS then ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := ' '; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := '-'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'l'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'd'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'e'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'c'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'g'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'n'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 'a'; ! Buffer.Increment_Last; ! Buffer.Table (Buffer.Last) := 't'; end if; ! return new String'(String (Buffer.Table (1 .. Buffer.Last))); end Init_Object_Dirs; ------------------ --- 1926,1949 ---- begin exit when Dir = null; Object_Dirs := Object_Dirs + 1; ! Object_Dir (Object_Dirs) := ! new String'("-L" & ! To_Canonical_Dir_Spec ! (To_Host_Dir_Spec ! (Normalize_Directory_Name (Dir.all).all, ! True).all, True).all); end; end loop; ! Object_Dirs := Object_Dirs + 1; ! Object_Dir (Object_Dirs) := new String'("-lgnat"); if Hostparm.OpenVMS then ! Object_Dirs := Object_Dirs + 1; ! Object_Dir (Object_Dirs) := new String'("-ldecgnat"); end if; ! return Object_Dir (1 .. Object_Dirs); end Init_Object_Dirs; ------------------ *************** procedure GNATCmd is *** 1781,1787 **** (S : String; Itm : Item_Ptr; Quiet : Boolean := False) ! return Item_Ptr is P1, P2 : Item_Ptr; --- 2038,2044 ---- (S : String; Itm : Item_Ptr; Quiet : Boolean := False) ! return Item_Ptr is P1, P2 : Item_Ptr; *************** procedure GNATCmd is *** 1789,1794 **** --- 2046,2055 ---- -- Little procedure to output command/qualifier/option as appropriate -- and bump error count. + --------- + -- Err -- + --------- + procedure Err is begin if Quiet then *************** procedure GNATCmd is *** 1820,1826 **** Put (Standard_Error, ": "); Put (Standard_Error, S); - end Err; -- Start of processing for Matching_Name --- 2081,2086 ---- *************** procedure GNATCmd is *** 1937,1942 **** --- 2197,2213 ---- end if; end OK_Integer; + -------------------- + -- Output_Version -- + -------------------- + + procedure Output_Version is + begin + Put ("GNAT "); + Put (Gnatvsn.Gnat_Version_String); + Put_Line (" Copyright 1996-2002 Free Software Foundation, Inc."); + end Output_Version; + ----------- -- Place -- ----------- *************** procedure GNATCmd is *** 1945,1950 **** --- 2216,2226 ---- begin Buffer.Increment_Last; Buffer.Table (Buffer.Last) := C; + + -- Do not put a space as the first character in the buffer + if C = ' ' and then Buffer.Last = 1 then + Buffer.Decrement_Last; + end if; end Place; procedure Place (S : String) is *************** procedure GNATCmd is *** 1999,2006 **** P3 := 2; while P3 <= Buffer.Last - Slen loop if Buffer.Table (P3) = ' ' ! and then String (Buffer.Table (P3 + 1 .. P3 + Slen)) ! = S (P1 .. P2) and then (P3 + Slen = Buffer.Last or else Buffer.Table (P3 + Slen + 1) = ' ') --- 2275,2282 ---- P3 := 2; while P3 <= Buffer.Last - Slen loop if Buffer.Table (P3) = ' ' ! and then String (Buffer.Table (P3 + 1 .. P3 + Slen)) = ! S (P1 .. P2) and then (P3 + Slen = Buffer.Last or else Buffer.Table (P3 + Slen + 1) = ' ') *************** procedure GNATCmd is *** 2028,2033 **** --- 2304,2362 ---- end loop; end Place_Unix_Switches; + --------------------- + -- Set_Library_For -- + --------------------- + + procedure Set_Library_For + (Project : Project_Id; + There_Are_Libraries : in out Boolean) + is + begin + -- Case of library project + + if Projects.Table (Project).Library then + There_Are_Libraries := True; + + -- Add the -L switch + + Last_Switches.Increment_Last; + Last_Switches.Table (Last_Switches.Last) := + new String'("-L" & + Get_Name_String + (Projects.Table (Project).Library_Dir)); + + -- Add the -l switch + + Last_Switches.Increment_Last; + Last_Switches.Table (Last_Switches.Last) := + new String'("-l" & + Get_Name_String + (Projects.Table (Project).Library_Name)); + + -- Add the Wl,-rpath switch if library non static + + if Projects.Table (Project).Library_Kind /= Static then + declare + Option : constant String_Access := + MLib.Tgt.Linker_Library_Path_Option + (Get_Name_String + (Projects.Table (Project).Library_Dir)); + + begin + if Option /= null then + Last_Switches.Increment_Last; + Last_Switches.Table (Last_Switches.Last) := + Option; + end if; + + end; + + end if; + + end if; + end Set_Library_For; + -------------------------------- -- Validate_Command_Or_Option -- -------------------------------- *************** procedure GNATCmd is *** 2073,2792 **** -- List of Commands -- ---------------------- ! -- Note that we put this after all the local bodies to avoid ! -- some access before elaboration problems. ! Command_List : array (Natural range <>) of Command_Entry := ( ! (Cname => new S'("BIND"), ! Usage => new S'("GNAT BIND file[.ali] /qualifiers"), ! Unixcmd => new S'("gnatbind"), ! Switches => Bind_Switches'Access, ! Params => new Parameter_Array'(1 => File), ! Defext => "ali"), ! (Cname => new S'("CHOP"), ! Usage => new S'("GNAT CHOP file [directory] /qualifiers"), ! Unixcmd => new S'("gnatchop"), ! Switches => Chop_Switches'Access, ! Params => new Parameter_Array'(1 => File, 2 => Optional_File), ! Defext => " "), ! (Cname => new S'("COMPILE"), ! Usage => new S'("GNAT COMPILE filespec[,...] /qualifiers"), ! Unixcmd => new S'("gcc -c -x ada"), ! Switches => GCC_Switches'Access, ! Params => new Parameter_Array'(1 => Files_Or_Wildcard), ! Defext => " "), ! (Cname => new S'("ELIM"), ! Usage => new S'("GNAT ELIM name /qualifiers"), ! Unixcmd => new S'("gnatelim"), ! Switches => Elim_Switches'Access, ! Params => new Parameter_Array'(1 => Other_As_Is), ! Defext => "ali"), ! (Cname => new S'("FIND"), ! Usage => new S'("GNAT FIND pattern[:sourcefile[:line[:column]]]" & ! " filespec[,...] /qualifiers"), ! Unixcmd => new S'("gnatfind"), ! Switches => Find_Switches'Access, ! Params => new Parameter_Array'(1 => Other_As_Is, ! 2 => Files_Or_Wildcard), ! Defext => "ali"), ! (Cname => new S'("KRUNCH"), ! Usage => new S'("GNAT KRUNCH file [/COUNT=nnn]"), ! Unixcmd => new S'("gnatkr"), ! Switches => Krunch_Switches'Access, ! Params => new Parameter_Array'(1 => File), ! Defext => " "), ! (Cname => new S'("LIBRARY"), ! Usage => new S'("GNAT LIBRARY /[CREATE | SET | DELETE]=directory" ! & " [/CONFIG=file]"), ! Unixcmd => new S'("gnatlbr"), ! Switches => Lbr_Switches'Access, ! Params => new Parameter_Array'(1 .. 0 => File), ! Defext => " "), ! (Cname => new S'("LINK"), ! Usage => new S'("GNAT LINK file[.ali]" ! & " [extra obj_&_lib_&_exe_&_opt files]" ! & " /qualifiers"), ! Unixcmd => new S'("gnatlink"), ! Switches => Link_Switches'Access, ! Params => new Parameter_Array'(1 => Unlimited_Files), ! Defext => "ali"), ! (Cname => new S'("LIST"), ! Usage => new S'("GNAT LIST /qualifiers object_or_ali_file"), ! Unixcmd => new S'("gnatls"), ! Switches => List_Switches'Access, ! Params => new Parameter_Array'(1 => File), ! Defext => "ali"), ! (Cname => new S'("MAKE"), ! Usage => ! new S'("GNAT MAKE file /qualifiers (includes COMPILE /qualifiers)"), ! Unixcmd => new S'("gnatmake"), ! Switches => Make_Switches'Access, ! Params => new Parameter_Array'(1 => File), ! Defext => " "), ! (Cname => new S'("PREPROCESS"), ! Usage => new S'("GNAT PREPROCESS ifile ofile dfile /qualifiers"), ! Unixcmd => new S'("gnatprep"), ! Switches => Prep_Switches'Access, ! Params => new Parameter_Array'(1 .. 3 => File), ! Defext => " "), ! (Cname => new S'("SHARED"), ! Usage => new S'("GNAT SHARED [obj_&_lib_&_exe_&_opt files]" ! & " /qualifiers"), ! Unixcmd => new S'("gcc -shared " & Init_Object_Dirs.all), ! Switches => Shared_Switches'Access, ! Params => new Parameter_Array'(1 => Unlimited_Files), ! Defext => " "), ! (Cname => new S'("STANDARD"), ! Usage => new S'("GNAT STANDARD"), ! Unixcmd => new S'("gnatpsta"), ! Switches => Standard_Switches'Access, ! Params => new Parameter_Array'(1 .. 0 => File), ! Defext => " "), ! (Cname => new S'("STUB"), ! Usage => new S'("GNAT STUB file [directory] /qualifiers"), ! Unixcmd => new S'("gnatstub"), ! Switches => Stub_Switches'Access, ! Params => new Parameter_Array'(1 => File, 2 => Optional_File), ! Defext => " "), ! (Cname => new S'("SYSTEM"), ! Usage => new S'("GNAT SYSTEM"), ! Unixcmd => new S'("gnatpsys"), ! Switches => System_Switches'Access, ! Params => new Parameter_Array'(1 .. 0 => File), ! Defext => " "), ! (Cname => new S'("XREF"), ! Usage => new S'("GNAT XREF filespec[,...] /qualifiers"), ! Unixcmd => new S'("gnatxref"), ! Switches => Xref_Switches'Access, ! Params => new Parameter_Array'(1 => Files_Or_Wildcard), ! Defext => "ali") ! ); ! ------------------------------------- ! -- Start of processing for GNATCmd -- ! ------------------------------------- ! begin ! Buffer.Init; ! -- First we must preprocess the string form of the command and options ! -- list into the internal form that we use. ! for C in Command_List'Range loop ! declare ! Command : Item_Ptr := new Command_Item; ! Last_Switch : Item_Ptr; ! -- Last switch in list ! begin ! -- Link new command item into list of commands ! if Last_Command = null then ! Commands := Command; ! else ! Last_Command.Next := Command; ! end if; ! Last_Command := Command; ! -- Fill in fields of new command item ! Command.Name := Command_List (C).Cname; ! Command.Usage := Command_List (C).Usage; ! Command.Unix_String := Command_List (C).Unixcmd; ! Command.Params := Command_List (C).Params; ! Command.Defext := Command_List (C).Defext; ! Validate_Command_Or_Option (Command.Name); ! -- Process the switch list ! for S in Command_List (C).Switches'Range loop ! declare ! SS : constant String_Ptr := Command_List (C).Switches (S); ! P : Natural := SS'First; ! Sw : Item_Ptr := new Switch_Item; ! Last_Opt : Item_Ptr; ! -- Pointer to last option ! begin ! -- Link new switch item into list of switches ! if Last_Switch = null then ! Command.Switches := Sw; ! else ! Last_Switch.Next := Sw; ! end if; ! Last_Switch := Sw; ! -- Process switch string, first get name ! while SS (P) /= ' ' and SS (P) /= '=' loop ! P := P + 1; ! end loop; ! Sw.Name := new String'(SS (SS'First .. P - 1)); ! -- Direct translation case ! if SS (P) = ' ' then ! Sw.Translation := T_Direct; ! Sw.Unix_String := new String'(SS (P + 1 .. SS'Last)); ! Validate_Unix_Switch (Sw.Unix_String); ! if SS (P - 1) = '>' then ! Sw.Translation := T_Other; ! elsif SS (P + 1) = '`' then ! null; ! -- Create the inverted case (/NO ..) ! elsif SS (SS'First + 1 .. SS'First + 2) /= "NO" then ! Sw := new Switch_Item; Last_Switch.Next := Sw; - Last_Switch := Sw; - - Sw.Name := - new String'("/NO" & SS (SS'First + 1 .. P - 1)); - Sw.Translation := T_Direct; - Sw.Unix_String := Invert_Sense (SS (P + 1 .. SS'Last)); - Validate_Unix_Switch (Sw.Unix_String); end if; ! -- Directories translation case ! ! elsif SS (P + 1) = '*' then ! pragma Assert (SS (SS'Last) = '*'); ! Sw.Translation := T_Directories; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! ! -- Directory translation case ! ! elsif SS (P + 1) = '%' then ! pragma Assert (SS (SS'Last) = '%'); ! Sw.Translation := T_Directory; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! ! -- File translation case ! elsif SS (P + 1) = '@' then ! pragma Assert (SS (SS'Last) = '@'); ! Sw.Translation := T_File; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- Numeric translation case ! elsif SS (P + 1) = '#' then ! pragma Assert (SS (SS'Last) = '#'); ! Sw.Translation := T_Numeric; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- Alphanumerplus translation case ! elsif SS (P + 1) = '|' then ! pragma Assert (SS (SS'Last) = '|'); ! Sw.Translation := T_Alphanumplus; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- String translation case ! elsif SS (P + 1) = '"' then ! pragma Assert (SS (SS'Last) = '"'); ! Sw.Translation := T_String; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- Commands translation case ! elsif SS (P + 1) = '?' then ! Sw.Translation := T_Commands; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last)); ! -- Options translation case ! else ! Sw.Translation := T_Options; ! Sw.Unix_String := new String'(""); ! P := P + 1; -- bump past = ! while P <= SS'Last loop ! declare ! Opt : Item_Ptr := new Option_Item; ! Q : Natural; ! begin ! -- Link new option item into options list ! if Last_Opt = null then ! Sw.Options := Opt; ! else ! Last_Opt.Next := Opt; ! end if; ! Last_Opt := Opt; ! -- Fill in fields of new option item ! Q := P; ! while SS (Q) /= ' ' loop ! Q := Q + 1; ! end loop; ! Opt.Name := new String'(SS (P .. Q - 1)); ! Validate_Command_Or_Option (Opt.Name); ! P := Q + 1; ! Q := P; ! while Q <= SS'Last and then SS (Q) /= ' ' loop ! Q := Q + 1; ! end loop; ! Opt.Unix_String := new String'(SS (P .. Q - 1)); ! Validate_Unix_Switch (Opt.Unix_String); ! P := Q + 1; ! end; ! end loop; ! end if; ! end; ! end loop; ! end; ! end loop; ! -- If no parameters, give complete list of commands ! if Argument_Count = 0 then ! Put_Line ("List of available commands"); ! New_Line; ! while Commands /= null loop ! Put (Commands.Usage.all); ! Set_Col (53); ! Put_Line (Commands.Unix_String.all); ! Commands := Commands.Next; ! end loop; ! raise Normal_Exit; ! end if; ! Arg_Num := 1; ! loop ! exit when Arg_Num > Argument_Count; ! declare ! Argv : String_Access; ! Arg_Idx : Integer; ! function Get_Arg_End ! (Argv : String; ! Arg_Idx : Integer) ! return Integer; ! -- Begins looking at Arg_Idx + 1 and returns the index of the ! -- last character before a slash or else the index of the last ! -- character in the string Argv. ! function Get_Arg_End ! (Argv : String; ! Arg_Idx : Integer) ! return Integer ! is ! begin ! for J in Arg_Idx + 1 .. Argv'Last loop ! if Argv (J) = '/' then ! return J - 1; ! end if; ! end loop; ! return Argv'Last; ! end Get_Arg_End; ! begin ! Argv := new String'(Argument (Arg_Num)); ! Arg_Idx := Argv'First; ! <> ! loop ! declare ! Next_Arg_Idx : Integer; ! Arg : String_Access; ! begin ! Next_Arg_Idx := Get_Arg_End (Argv.all, Arg_Idx); ! Arg := new String'(Argv (Arg_Idx .. Next_Arg_Idx)); ! -- The first one must be a command name ! if Arg_Num = 1 and then Arg_Idx = Argv'First then ! Command := Matching_Name (Arg.all, Commands); ! if Command = null then ! raise Error_Exit; end if; ! -- Give usage information if only command given ! if Argument_Count = 1 and then Next_Arg_Idx = Argv'Last ! and then ! not (Command.Name.all = "SYSTEM" ! or else Command.Name.all = "STANDARD") ! then ! Put_Line ("List of available qualifiers and options"); ! New_Line; ! Put (Command.Usage.all); ! Set_Col (53); ! Put_Line (Command.Unix_String.all); ! declare ! Sw : Item_Ptr := Command.Switches; ! begin ! while Sw /= null loop ! Put (" "); ! Put (Sw.Name.all); ! case Sw.Translation is ! when T_Other => ! Set_Col (53); ! Put_Line (Sw.Unix_String.all & "/"); ! when T_Direct => ! Set_Col (53); ! Put_Line (Sw.Unix_String.all); ! when T_Directories => ! Put ("=(direc,direc,..direc)"); ! Set_Col (53); ! Put (Sw.Unix_String.all); ! Put (" direc "); ! Put (Sw.Unix_String.all); ! Put_Line (" direc ..."); ! when T_Directory => ! Put ("=directory"); ! Set_Col (53); ! Put (Sw.Unix_String.all); ! if Sw.Unix_String (Sw.Unix_String'Last) ! /= '=' ! then ! Put (' '); ! end if; ! Put_Line ("directory "); ! when T_File => ! Put ("=file"); ! Set_Col (53); ! Put (Sw.Unix_String.all); ! if Sw.Unix_String (Sw.Unix_String'Last) ! /= '=' ! then ! Put (' '); ! end if; ! Put_Line ("file "); ! when T_Numeric => ! Put ("=nnn"); ! Set_Col (53); ! if Sw.Unix_String (Sw.Unix_String'First) ! = '`' ! then ! Put (Sw.Unix_String ! (Sw.Unix_String'First + 1 ! .. Sw.Unix_String'Last)); ! else ! Put (Sw.Unix_String.all); ! end if; ! Put_Line ("nnn"); ! when T_Alphanumplus => ! Put ("=xyz"); ! Set_Col (53); ! if Sw.Unix_String (Sw.Unix_String'First) ! = '`' ! then ! Put (Sw.Unix_String ! (Sw.Unix_String'First + 1 ! .. Sw.Unix_String'Last)); ! else ! Put (Sw.Unix_String.all); ! end if; ! Put_Line ("xyz"); ! when T_String => ! Put ("="); ! Put ('"'); ! Put (""); ! Put ('"'); ! Set_Col (53); ! Put (Sw.Unix_String.all); ! if Sw.Unix_String (Sw.Unix_String'Last) ! /= '=' ! then ! Put (' '); ! end if; ! Put (""); ! New_Line; ! when T_Commands => ! Put (" (switches for "); ! Put (Sw.Unix_String ( ! Sw.Unix_String'First + 7 ! .. Sw.Unix_String'Last)); ! Put (')'); ! Set_Col (53); ! Put (Sw.Unix_String ( ! Sw.Unix_String'First ! .. Sw.Unix_String'First + 5)); ! Put_Line (" switches"); ! when T_Options => ! declare ! Opt : Item_Ptr := Sw.Options; ! begin ! Put_Line ("=(option,option..)"); ! while Opt /= null loop ! Put (" "); ! Put (Opt.Name.all); ! if Opt = Sw.Options then ! Put (" (D)"); ! end if; Set_Col (53); ! Put_Line (Opt.Unix_String.all); ! Opt := Opt.Next; ! end loop; ! end; ! end case; ! Sw := Sw.Next; ! end loop; ! end; ! raise Normal_Exit; ! end if; ! Place (Command.Unix_String.all); ! -- Special handling for internal debugging switch /? ! elsif Arg.all = "/?" then ! Display_Command := True; ! -- Copy -switch unchanged ! elsif Arg (Arg'First) = '-' then ! Place (' '); ! Place (Arg.all); ! -- Copy quoted switch with quotes stripped ! elsif Arg (Arg'First) = '"' then ! if Arg (Arg'Last) /= '"' then ! Put (Standard_Error, "misquoted argument: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! else ! Put (Arg (Arg'First + 1 .. Arg'Last - 1)); ! end if; ! -- Parameter Argument ! elsif Arg (Arg'First) /= '/' ! and then Make_Commands_Active = null ! then ! Param_Count := Param_Count + 1; ! if Param_Count <= Command.Params'Length then ! case Command.Params (Param_Count) is ! when File | Optional_File => ! declare ! Normal_File : String_Access ! := To_Canonical_File_Spec (Arg.all); ! begin ! Place (' '); ! Place_Lower (Normal_File.all); ! if Is_Extensionless (Normal_File.all) ! and then Command.Defext /= " " ! then ! Place ('.'); ! Place (Command.Defext); ! end if; ! end; ! when Unlimited_Files => ! declare ! Normal_File : String_Access ! := To_Canonical_File_Spec (Arg.all); ! File_Is_Wild : Boolean := False; ! File_List : String_Access_List_Access; ! begin ! for I in Arg'Range loop ! if Arg (I) = '*' ! or else Arg (I) = '%' ! then ! File_Is_Wild := True; ! end if; ! end loop; ! if File_Is_Wild then ! File_List := To_Canonical_File_List ! (Arg.all, False); ! for I in File_List.all'Range loop ! Place (' '); ! Place_Lower (File_List.all (I).all); ! end loop; ! else ! Place (' '); ! Place_Lower (Normal_File.all); ! if Is_Extensionless (Normal_File.all) ! and then Command.Defext /= " " ! then ! Place ('.'); ! Place (Command.Defext); ! end if; ! end if; ! Param_Count := Param_Count - 1; end; ! when Other_As_Is => ! Place (' '); ! Place (Arg.all); ! when Files_Or_Wildcard => ! -- Remove spaces from a comma separated list ! -- of file names and adjust control variables ! -- accordingly. ! while Arg_Num < Argument_Count and then ! (Argv (Argv'Last) = ',' xor ! Argument (Arg_Num + 1) ! (Argument (Arg_Num + 1)'First) = ',') ! loop ! Argv := new String'(Argv.all ! & Argument (Arg_Num + 1)); ! Arg_Num := Arg_Num + 1; ! Arg_Idx := Argv'First; ! Next_Arg_Idx := Get_Arg_End (Argv.all, Arg_Idx); ! Arg := ! new String'(Argv (Arg_Idx .. Next_Arg_Idx)); ! end loop; ! -- Parse the comma separated list of VMS filenames ! -- and place them on the command line as space ! -- separated Unix style filenames. Lower case and ! -- add default extension as appropriate. ! declare ! Arg1_Idx : Integer := Arg'First; ! function Get_Arg1_End ! (Arg : String; Arg_Idx : Integer) ! return Integer; ! -- Begins looking at Arg_Idx + 1 and ! -- returns the index of the last character ! -- before a comma or else the index of the ! -- last character in the string Arg. ! function Get_Arg1_End ! (Arg : String; Arg_Idx : Integer) ! return Integer ! is ! begin ! for I in Arg_Idx + 1 .. Arg'Last loop ! if Arg (I) = ',' then ! return I - 1; ! end if; ! end loop; ! return Arg'Last; ! end Get_Arg1_End; ! begin ! loop ! declare ! Next_Arg1_Idx : Integer ! := Get_Arg1_End (Arg.all, Arg1_Idx); ! Arg1 : String ! := Arg (Arg1_Idx .. Next_Arg1_Idx); ! Normal_File : String_Access ! := To_Canonical_File_Spec (Arg1); begin Place (' '); Place_Lower (Normal_File.all); --- 2402,3145 ---- -- List of Commands -- ---------------------- ! -- Note that we put this after all the local bodies (except Non_VMS_Usage ! -- and VMS_Conversion that use Command_List) to avoid some access before ! -- elaboration problems. ! Command_List : constant array (Real_Command_Type) of Command_Entry := ! (Bind => ! (Cname => new S'("BIND"), ! Usage => new S'("GNAT BIND file[.ali] /qualifiers"), ! VMS_Only => False, ! Unixcmd => new S'("gnatbind"), ! Unixsws => null, ! Switches => Bind_Switches'Access, ! Params => new Parameter_Array'(1 => File), ! Defext => "ali"), ! Chop => ! (Cname => new S'("CHOP"), ! Usage => new S'("GNAT CHOP file [directory] /qualifiers"), ! VMS_Only => False, ! Unixcmd => new S'("gnatchop"), ! Unixsws => null, ! Switches => Chop_Switches'Access, ! Params => new Parameter_Array'(1 => File, 2 => Optional_File), ! Defext => " "), ! Compile => ! (Cname => new S'("COMPILE"), ! Usage => new S'("GNAT COMPILE filespec[,...] /qualifiers"), ! VMS_Only => False, ! Unixcmd => new S'("gnatmake"), ! Unixsws => new Argument_List' (1 => new String'("-f"), ! 2 => new String'("-u"), ! 3 => new String'("-c")), ! Switches => GCC_Switches'Access, ! Params => new Parameter_Array'(1 => Files_Or_Wildcard), ! Defext => " "), ! Elim => ! (Cname => new S'("ELIM"), ! Usage => new S'("GNAT ELIM name /qualifiers"), ! VMS_Only => False, ! Unixcmd => new S'("gnatelim"), ! Unixsws => null, ! Switches => Elim_Switches'Access, ! Params => new Parameter_Array'(1 => Other_As_Is), ! Defext => "ali"), ! Find => ! (Cname => new S'("FIND"), ! Usage => new S'("GNAT FIND pattern[:sourcefile[:line" ! & "[:column]]] filespec[,...] /qualifiers"), ! VMS_Only => False, ! Unixcmd => new S'("gnatfind"), ! Unixsws => null, ! Switches => Find_Switches'Access, ! Params => new Parameter_Array'(1 => Other_As_Is, ! 2 => Files_Or_Wildcard), ! Defext => "ali"), ! Krunch => ! (Cname => new S'("KRUNCH"), ! Usage => new S'("GNAT KRUNCH file [/COUNT=nnn]"), ! VMS_Only => False, ! Unixcmd => new S'("gnatkr"), ! Unixsws => null, ! Switches => Krunch_Switches'Access, ! Params => new Parameter_Array'(1 => File), ! Defext => " "), ! Library => ! (Cname => new S'("LIBRARY"), ! Usage => new S'("GNAT LIBRARY /[CREATE | SET | DELETE]" ! & "=directory [/CONFIG=file]"), ! VMS_Only => True, ! Unixcmd => new S'("gnatlbr"), ! Unixsws => null, ! Switches => Lbr_Switches'Access, ! Params => new Parameter_Array'(1 .. 0 => File), ! Defext => " "), ! Link => ! (Cname => new S'("LINK"), ! Usage => new S'("GNAT LINK file[.ali]" ! & " [extra obj_&_lib_&_exe_&_opt files]" ! & " /qualifiers"), ! VMS_Only => False, ! Unixcmd => new S'("gnatlink"), ! Unixsws => null, ! Switches => Link_Switches'Access, ! Params => new Parameter_Array'(1 => Unlimited_Files), ! Defext => "ali"), ! List => ! (Cname => new S'("LIST"), ! Usage => new S'("GNAT LIST /qualifiers object_or_ali_file"), ! VMS_Only => False, ! Unixcmd => new S'("gnatls"), ! Unixsws => null, ! Switches => List_Switches'Access, ! Params => new Parameter_Array'(1 => File), ! Defext => "ali"), ! Make => ! (Cname => new S'("MAKE"), ! Usage => new S'("GNAT MAKE file /qualifiers (includes " ! & "COMPILE /qualifiers)"), ! VMS_Only => False, ! Unixcmd => new S'("gnatmake"), ! Unixsws => null, ! Switches => Make_Switches'Access, ! Params => new Parameter_Array'(1 => File), ! Defext => " "), ! Name => ! (Cname => new S'("NAME"), ! Usage => new S'("GNAT NAME /qualifiers naming-pattern " ! & "[naming-patterns]"), ! VMS_Only => False, ! Unixcmd => new S'("gnatname"), ! Unixsws => null, ! Switches => Name_Switches'Access, ! Params => new Parameter_Array'(1 => Unlimited_As_Is), ! Defext => " "), ! Preprocess => ! (Cname => new S'("PREPROCESS"), ! Usage => new S'("GNAT PREPROCESS ifile ofile dfile /qualifiers"), ! VMS_Only => False, ! Unixcmd => new S'("gnatprep"), ! Unixsws => null, ! Switches => Prep_Switches'Access, ! Params => new Parameter_Array'(1 .. 3 => File), ! Defext => " "), ! Shared => ! (Cname => new S'("SHARED"), ! Usage => new S'("GNAT SHARED [obj_&_lib_&_exe_&_opt" ! & "files] /qualifiers"), ! VMS_Only => True, ! Unixcmd => new S'("gcc"), ! Unixsws => new Argument_List'(new String'("-shared") ! & Init_Object_Dirs), ! Switches => Shared_Switches'Access, ! Params => new Parameter_Array'(1 => Unlimited_Files), ! Defext => " "), ! Standard => ! (Cname => new S'("STANDARD"), ! Usage => new S'("GNAT STANDARD"), ! VMS_Only => False, ! Unixcmd => new S'("gnatpsta"), ! Unixsws => null, ! Switches => Standard_Switches'Access, ! Params => new Parameter_Array'(1 .. 0 => File), ! Defext => " "), ! Stub => ! (Cname => new S'("STUB"), ! Usage => new S'("GNAT STUB file [directory]/qualifiers"), ! VMS_Only => False, ! Unixcmd => new S'("gnatstub"), ! Unixsws => null, ! Switches => Stub_Switches'Access, ! Params => new Parameter_Array'(1 => File, 2 => Optional_File), ! Defext => " "), ! Xref => ! (Cname => new S'("XREF"), ! Usage => new S'("GNAT XREF filespec[,...] /qualifiers"), ! VMS_Only => False, ! Unixcmd => new S'("gnatxref"), ! Unixsws => null, ! Switches => Xref_Switches'Access, ! Params => new Parameter_Array'(1 => Files_Or_Wildcard), ! Defext => "ali") ! ); ! ------------------- ! -- Non_VMS_Usage -- ! ------------------- ! procedure Non_VMS_Usage is ! begin ! Output_Version; ! New_Line; ! Put_Line ("List of available commands"); ! New_Line; ! for C in Command_List'Range loop ! if not Command_List (C).VMS_Only then ! Put ("GNAT " & Command_List (C).Cname.all); ! Set_Col (25); ! Put (Command_List (C).Unixcmd.all); ! declare ! Sws : Argument_List_Access renames Command_List (C).Unixsws; ! begin ! if Sws /= null then ! for J in Sws'Range loop ! Put (' '); ! Put (Sws (J).all); ! end loop; ! end if; ! end; ! New_Line; ! end if; ! end loop; ! New_Line; ! Put_Line ("Commands FIND, LIST and XREF accept project file " & ! "switches -vPx, -Pprj and -Xnam=val"); ! New_Line; ! end Non_VMS_Usage; ! -------------------- ! -- VMS_Conversion -- ! -------------------- ! procedure VMS_Conversion (The_Command : out Command_Type) is ! begin ! Buffer.Init; ! -- First we must preprocess the string form of the command and options ! -- list into the internal form that we use. ! for C in Real_Command_Type loop ! declare ! Command : Item_Ptr := new Command_Item; ! Last_Switch : Item_Ptr; ! -- Last switch in list ! begin ! -- Link new command item into list of commands ! if Last_Command = null then ! Commands := Command; ! else ! Last_Command.Next := Command; ! end if; ! Last_Command := Command; ! -- Fill in fields of new command item ! Command.Name := Command_List (C).Cname; ! Command.Usage := Command_List (C).Usage; ! Command.Command := C; ! if Command_List (C).Unixsws = null then ! Command.Unix_String := Command_List (C).Unixcmd; ! else ! declare ! Cmd : String (1 .. 5_000); ! Last : Natural := 0; ! Sws : Argument_List_Access := Command_List (C).Unixsws; ! begin ! Cmd (1 .. Command_List (C).Unixcmd'Length) := ! Command_List (C).Unixcmd.all; ! Last := Command_List (C).Unixcmd'Length; ! for J in Sws'Range loop ! Last := Last + 1; ! Cmd (Last) := ' '; ! Cmd (Last + 1 .. Last + Sws (J)'Length) := ! Sws (J).all; ! Last := Last + Sws (J)'Length; ! end loop; ! Command.Unix_String := new String'(Cmd (1 .. Last)); ! end; ! end if; ! Command.Params := Command_List (C).Params; ! Command.Defext := Command_List (C).Defext; ! Validate_Command_Or_Option (Command.Name); ! -- Process the switch list ! for S in Command_List (C).Switches'Range loop ! declare ! SS : constant String_Ptr := Command_List (C).Switches (S); ! P : Natural := SS'First; ! Sw : Item_Ptr := new Switch_Item; ! Last_Opt : Item_Ptr; ! -- Pointer to last option ! begin ! -- Link new switch item into list of switches ! if Last_Switch = null then ! Command.Switches := Sw; ! else Last_Switch.Next := Sw; end if; ! Last_Switch := Sw; ! -- Process switch string, first get name ! while SS (P) /= ' ' and SS (P) /= '=' loop ! P := P + 1; ! end loop; ! Sw.Name := new String'(SS (SS'First .. P - 1)); ! -- Direct translation case ! if SS (P) = ' ' then ! Sw.Translation := T_Direct; ! Sw.Unix_String := new String'(SS (P + 1 .. SS'Last)); ! Validate_Unix_Switch (Sw.Unix_String); ! if SS (P - 1) = '>' then ! Sw.Translation := T_Other; ! elsif SS (P + 1) = '`' then ! null; ! -- Create the inverted case (/NO ..) ! elsif SS (SS'First + 1 .. SS'First + 2) /= "NO" then ! Sw := new Switch_Item; ! Last_Switch.Next := Sw; ! Last_Switch := Sw; ! Sw.Name := ! new String'("/NO" & SS (SS'First + 1 .. P - 1)); ! Sw.Translation := T_Direct; ! Sw.Unix_String := Invert_Sense (SS (P + 1 .. SS'Last)); ! Validate_Unix_Switch (Sw.Unix_String); ! end if; ! -- Directories translation case ! elsif SS (P + 1) = '*' then ! pragma Assert (SS (SS'Last) = '*'); ! Sw.Translation := T_Directories; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- Directory translation case ! elsif SS (P + 1) = '%' then ! pragma Assert (SS (SS'Last) = '%'); ! Sw.Translation := T_Directory; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- File translation case ! elsif SS (P + 1) = '@' then ! pragma Assert (SS (SS'Last) = '@'); ! Sw.Translation := T_File; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- No space file translation case ! elsif SS (P + 1) = '<' then ! pragma Assert (SS (SS'Last) = '>'); ! Sw.Translation := T_No_Space_File; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- Numeric translation case ! elsif SS (P + 1) = '#' then ! pragma Assert (SS (SS'Last) = '#'); ! Sw.Translation := T_Numeric; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- Alphanumerplus translation case ! elsif SS (P + 1) = '|' then ! pragma Assert (SS (SS'Last) = '|'); ! Sw.Translation := T_Alphanumplus; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- String translation case ! elsif SS (P + 1) = '"' then ! pragma Assert (SS (SS'Last) = '"'); ! Sw.Translation := T_String; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last - 1)); ! Validate_Unix_Switch (Sw.Unix_String); ! -- Commands translation case ! elsif SS (P + 1) = '?' then ! Sw.Translation := T_Commands; ! Sw.Unix_String := new String'(SS (P + 2 .. SS'Last)); ! -- Options translation case ! else ! Sw.Translation := T_Options; ! Sw.Unix_String := new String'(""); ! P := P + 1; -- bump past = ! while P <= SS'Last loop ! declare ! Opt : Item_Ptr := new Option_Item; ! Q : Natural; ! begin ! -- Link new option item into options list ! if Last_Opt = null then ! Sw.Options := Opt; ! else ! Last_Opt.Next := Opt; ! end if; ! Last_Opt := Opt; ! -- Fill in fields of new option item ! Q := P; ! while SS (Q) /= ' ' loop ! Q := Q + 1; ! end loop; ! Opt.Name := new String'(SS (P .. Q - 1)); ! Validate_Command_Or_Option (Opt.Name); ! P := Q + 1; ! Q := P; ! while Q <= SS'Last and then SS (Q) /= ' ' loop ! Q := Q + 1; ! end loop; ! Opt.Unix_String := new String'(SS (P .. Q - 1)); ! Validate_Unix_Switch (Opt.Unix_String); ! P := Q + 1; ! end; ! end loop; end if; + end; + end loop; + end; + end loop; ! -- If no parameters, give complete list of commands ! if Argument_Count = 0 then ! Output_Version; ! New_Line; ! Put_Line ("List of available commands"); ! New_Line; ! while Commands /= null loop ! Put (Commands.Usage.all); ! Set_Col (53); ! Put_Line (Commands.Unix_String.all); ! Commands := Commands.Next; ! end loop; ! raise Normal_Exit; ! end if; ! Arg_Num := 1; ! -- Loop through arguments ! while Arg_Num <= Argument_Count loop ! Process_Argument : declare ! Argv : String_Access; ! Arg_Idx : Integer; ! function Get_Arg_End ! (Argv : String; ! Arg_Idx : Integer) ! return Integer; ! -- Begins looking at Arg_Idx + 1 and returns the index of the ! -- last character before a slash or else the index of the last ! -- character in the string Argv. ! ----------------- ! -- Get_Arg_End -- ! ----------------- ! function Get_Arg_End ! (Argv : String; ! Arg_Idx : Integer) ! return Integer ! is ! begin ! for J in Arg_Idx + 1 .. Argv'Last loop ! if Argv (J) = '/' then ! return J - 1; ! end if; ! end loop; ! return Argv'Last; ! end Get_Arg_End; ! -- Start of processing for Process_Argument ! begin ! Argv := new String'(Argument (Arg_Num)); ! Arg_Idx := Argv'First; ! <> ! loop ! declare ! Next_Arg_Idx : Integer; ! Arg : String_Access; ! begin ! Next_Arg_Idx := Get_Arg_End (Argv.all, Arg_Idx); ! Arg := new String'(Argv (Arg_Idx .. Next_Arg_Idx)); ! -- The first one must be a command name ! if Arg_Num = 1 and then Arg_Idx = Argv'First then ! Command := Matching_Name (Arg.all, Commands); ! if Command = null then ! raise Error_Exit; ! end if; ! The_Command := Command.Command; ! -- Give usage information if only command given ! if Argument_Count = 1 and then Next_Arg_Idx = Argv'Last ! and then Command.Command /= Standard ! then ! Output_Version; ! New_Line; ! Put_Line ! ("List of available qualifiers and options"); ! New_Line; ! Put (Command.Usage.all); ! Set_Col (53); ! Put_Line (Command.Unix_String.all); ! declare ! Sw : Item_Ptr := Command.Switches; ! begin ! while Sw /= null loop ! Put (" "); ! Put (Sw.Name.all); ! case Sw.Translation is ! when T_Other => ! Set_Col (53); ! Put_Line (Sw.Unix_String.all & ! "/"); ! when T_Direct => ! Set_Col (53); ! Put_Line (Sw.Unix_String.all); ! when T_Directories => ! Put ("=(direc,direc,..direc)"); ! Set_Col (53); ! Put (Sw.Unix_String.all); ! Put (" direc "); ! Put (Sw.Unix_String.all); ! Put_Line (" direc ..."); + when T_Directory => + Put ("=directory"); Set_Col (53); ! Put (Sw.Unix_String.all); ! if Sw.Unix_String (Sw.Unix_String'Last) ! /= '=' ! then ! Put (' '); ! end if; ! Put_Line ("directory "); ! when T_File | T_No_Space_File => ! Put ("=file"); ! Set_Col (53); ! Put (Sw.Unix_String.all); ! if Sw.Translation = T_File ! and then Sw.Unix_String ! (Sw.Unix_String'Last) ! /= '=' ! then ! Put (' '); ! end if; ! Put_Line ("file "); ! when T_Numeric => ! Put ("=nnn"); ! Set_Col (53); ! if Sw.Unix_String (Sw.Unix_String'First) ! = '`' ! then ! Put (Sw.Unix_String ! (Sw.Unix_String'First + 1 ! .. Sw.Unix_String'Last)); ! else ! Put (Sw.Unix_String.all); ! end if; ! Put_Line ("nnn"); ! when T_Alphanumplus => ! Put ("=xyz"); ! Set_Col (53); ! if Sw.Unix_String (Sw.Unix_String'First) ! = '`' ! then ! Put (Sw.Unix_String ! (Sw.Unix_String'First + 1 ! .. Sw.Unix_String'Last)); ! else ! Put (Sw.Unix_String.all); ! end if; ! Put_Line ("xyz"); ! when T_String => ! Put ("="); ! Put ('"'); ! Put (""); ! Put ('"'); ! Set_Col (53); ! Put (Sw.Unix_String.all); ! if Sw.Unix_String (Sw.Unix_String'Last) ! /= '=' ! then ! Put (' '); ! end if; ! Put (""); ! New_Line; ! when T_Commands => ! Put (" (switches for "); ! Put (Sw.Unix_String ! (Sw.Unix_String'First + 7 ! .. Sw.Unix_String'Last)); ! Put (')'); ! Set_Col (53); ! Put (Sw.Unix_String ! (Sw.Unix_String'First ! .. Sw.Unix_String'First + 5)); ! Put_Line (" switches"); ! when T_Options => ! declare ! Opt : Item_Ptr := Sw.Options; ! begin ! Put_Line ("=(option,option..)"); ! while Opt /= null loop ! Put (" "); ! Put (Opt.Name.all); ! if Opt = Sw.Options then ! Put (" (D)"); ! end if; ! Set_Col (53); ! Put_Line (Opt.Unix_String.all); ! Opt := Opt.Next; ! end loop; ! end; ! end case; ! Sw := Sw.Next; ! end loop; end; ! raise Normal_Exit; ! end if; ! -- Place (Command.Unix_String.all); ! -- Special handling for internal debugging switch /? ! elsif Arg.all = "/?" then ! Display_Command := True; ! -- Copy -switch unchanged ! elsif Arg (Arg'First) = '-' then ! Place (' '); ! Place (Arg.all); ! -- Copy quoted switch with quotes stripped ! elsif Arg (Arg'First) = '"' then ! if Arg (Arg'Last) /= '"' then ! Put (Standard_Error, "misquoted argument: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! else ! Place (' '); ! Place (Arg (Arg'First + 1 .. Arg'Last - 1)); ! end if; ! -- Parameter Argument ! elsif Arg (Arg'First) /= '/' ! and then Make_Commands_Active = null ! then ! Param_Count := Param_Count + 1; ! if Param_Count <= Command.Params'Length then ! ! case Command.Params (Param_Count) is + when File | Optional_File => + declare + Normal_File : String_Access + := To_Canonical_File_Spec (Arg.all); begin Place (' '); Place_Lower (Normal_File.all); *************** begin *** 2797,3313 **** Place ('.'); Place (Command.Defext); end if; - - Arg1_Idx := Next_Arg1_Idx + 1; end; ! exit when Arg1_Idx > Arg'Last; ! -- Don't allow two or more commas in a row ! if Arg (Arg1_Idx) = ',' then ! Arg1_Idx := Arg1_Idx + 1; ! if Arg1_Idx > Arg'Last or else ! Arg (Arg1_Idx) = ',' ! then ! Put_Line (Standard_Error, ! "Malformed Parameter: " & Arg.all); ! Put (Standard_Error, "usage: "); ! Put_Line (Standard_Error, ! Command.Usage.all); ! raise Error_Exit; end if; - end if; ! end loop; ! end; ! end case; ! end if; ! -- Qualifier argument ! else ! declare ! Sw : Item_Ptr; ! SwP : Natural; ! P2 : Natural; ! Endp : Natural := 0; -- avoid warning! ! Opt : Item_Ptr; ! begin ! SwP := Arg'First; ! while SwP < Arg'Last and then Arg (SwP + 1) /= '=' loop ! SwP := SwP + 1; ! end loop; ! -- At this point, the switch name is in ! -- Arg (Arg'First..SwP) and if that is not the whole ! -- switch, then there is an equal sign at ! -- Arg (SwP + 1) and the rest of Arg is what comes ! -- after the equal sign. ! -- If make commands are active, see if we have another ! -- COMMANDS_TRANSLATION switch belonging to gnatmake. ! if Make_Commands_Active /= null then ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Command.Switches, ! Quiet => True); ! if Sw /= null and then Sw.Translation = T_Commands then ! null; ! else ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Make_Commands_Active.Switches, ! Quiet => False); ! end if; ! -- For case of GNAT MAKE or CHOP, if we cannot find the ! -- switch, then see if it is a recognized compiler switch ! -- instead, and if so process the compiler switch. ! elsif Command.Name.all = "MAKE" ! or else Command.Name.all = "CHOP" then ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Command.Switches, ! Quiet => True); ! if Sw = null then ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Matching_Name ("COMPILE", Commands).Switches, ! Quiet => False); end if; ! -- For all other cases, just search the relevant command else ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Command.Switches, ! Quiet => False); ! end if; ! if Sw /= null then ! case Sw.Translation is ! when T_Direct => ! Place_Unix_Switches (Sw.Unix_String); ! if Arg (SwP + 1) = '=' then ! Put (Standard_Error, ! "qualifier options ignored: "); ! Put_Line (Standard_Error, Arg.all); ! end if; ! when T_Directories => ! if SwP + 1 > Arg'Last then ! Put (Standard_Error, ! "missing directories for: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! elsif Arg (SwP + 2) /= '(' then ! SwP := SwP + 2; ! Endp := Arg'Last; ! elsif Arg (Arg'Last) /= ')' then ! -- Remove spaces from a comma separated list ! -- of file names and adjust control ! -- variables accordingly. ! if Arg_Num < Argument_Count and then ! (Argv (Argv'Last) = ',' xor ! Argument (Arg_Num + 1) ! (Argument (Arg_Num + 1)'First) = ',') ! then ! Argv := new String'(Argv.all ! & Argument (Arg_Num + 1)); ! Arg_Num := Arg_Num + 1; ! Arg_Idx := Argv'First; ! Next_Arg_Idx ! := Get_Arg_End (Argv.all, Arg_Idx); ! Arg := new String' ! (Argv (Arg_Idx .. Next_Arg_Idx)); ! goto Tryagain_After_Coalesce; ! end if; ! Put (Standard_Error, ! "incorrectly parenthesized " & ! "or malformed argument: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! else ! SwP := SwP + 3; ! Endp := Arg'Last - 1; end if; ! while SwP <= Endp loop ! declare ! Dir_Is_Wild : Boolean := False; ! Dir_Maybe_Is_Wild : Boolean := False; ! Dir_List : String_Access_List_Access; ! begin ! P2 := SwP; ! while P2 < Endp ! and then Arg (P2 + 1) /= ',' ! loop ! -- A wildcard directory spec on VMS ! -- will contain either * or % or ... ! if Arg (P2) = '*' then ! Dir_Is_Wild := True; ! elsif Arg (P2) = '%' then ! Dir_Is_Wild := True; ! elsif Dir_Maybe_Is_Wild ! and then Arg (P2) = '.' ! and then Arg (P2 + 1) = '.' then ! Dir_Is_Wild := True; ! Dir_Maybe_Is_Wild := False; ! elsif Dir_Maybe_Is_Wild then ! Dir_Maybe_Is_Wild := False; ! elsif Arg (P2) = '.' ! and then Arg (P2 + 1) = '.' then ! Dir_Maybe_Is_Wild := True; end if; ! P2 := P2 + 1; ! end loop; ! if (Dir_Is_Wild) then ! Dir_List := To_Canonical_File_List ! (Arg (SwP .. P2), True); - for I in Dir_List.all'Range loop - Place_Unix_Switches (Sw.Unix_String); - Place_Lower (Dir_List.all (I).all); - end loop; else Place_Unix_Switches (Sw.Unix_String); ! Place_Lower (To_Canonical_Dir_Spec ! (Arg (SwP .. P2), False).all); end if; ! SwP := P2 + 2; ! end; ! end loop; ! when T_Directory => ! if SwP + 1 > Arg'Last then ! Put (Standard_Error, ! "missing directory for: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! else ! Place_Unix_Switches (Sw.Unix_String); ! -- Some switches end in "=". No space here - if Sw.Unix_String - (Sw.Unix_String'Last) /= '=' - then Place (' '); ! end if; ! Place_Lower (To_Canonical_Dir_Spec ! (Arg (SwP + 2 .. Arg'Last), False).all); ! end if; ! when T_File => ! if SwP + 1 > Arg'Last then ! Put (Standard_Error, "missing file for: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! else ! Place_Unix_Switches (Sw.Unix_String); ! -- Some switches end in "=". No space here ! if Sw.Unix_String ! (Sw.Unix_String'Last) /= '=' ! then ! Place (' '); ! end if; ! Place_Lower (To_Canonical_File_Spec ! (Arg (SwP + 2 .. Arg'Last)).all); ! end if; ! when T_Numeric => ! if OK_Integer (Arg (SwP + 2 .. Arg'Last)) then ! Place_Unix_Switches (Sw.Unix_String); ! Place (Arg (SwP + 2 .. Arg'Last)); ! else ! Put (Standard_Error, "argument for "); ! Put (Standard_Error, Sw.Name.all); ! Put_Line (Standard_Error, " must be numeric"); ! Errors := Errors + 1; ! end if; ! when T_Alphanumplus => ! if ! OK_Alphanumerplus (Arg (SwP + 2 .. Arg'Last)) ! then ! Place_Unix_Switches (Sw.Unix_String); ! Place (Arg (SwP + 2 .. Arg'Last)); ! else ! Put (Standard_Error, "argument for "); ! Put (Standard_Error, Sw.Name.all); ! Put_Line (Standard_Error, ! " must be alphanumeric"); ! Errors := Errors + 1; ! end if; ! when T_String => ! -- A String value must be extended to the ! -- end of the Argv, otherwise strings like ! -- "foo/bar" get split at the slash. ! -- ! -- The begining and ending of the string ! -- are flagged with embedded nulls which ! -- are removed when building the Spawn ! -- call. Nulls are use because they won't ! -- show up in a /? output. Quotes aren't ! -- used because that would make it difficult ! -- to embed them. ! Place_Unix_Switches (Sw.Unix_String); ! if Next_Arg_Idx /= Argv'Last then ! Next_Arg_Idx := Argv'Last; ! Arg := new String' ! (Argv (Arg_Idx .. Next_Arg_Idx)); ! SwP := Arg'First; ! while SwP < Arg'Last and then ! Arg (SwP + 1) /= '=' loop ! SwP := SwP + 1; ! end loop; ! end if; ! Place (ASCII.NUL); ! Place (Arg (SwP + 2 .. Arg'Last)); ! Place (ASCII.NUL); ! when T_Commands => ! -- Output -largs/-bargs/-cargs ! Place (' '); ! Place (Sw.Unix_String ! (Sw.Unix_String'First .. ! Sw.Unix_String'First + 5)); ! -- Set source of new commands, also setting this ! -- non-null indicates that we are in the special ! -- commands mode for processing the -xargs case. ! Make_Commands_Active := ! Matching_Name ! (Sw.Unix_String ! (Sw.Unix_String'First + 7 .. ! Sw.Unix_String'Last), ! Commands); ! when T_Options => ! if SwP + 1 > Arg'Last then ! Place_Unix_Switches (Sw.Options.Unix_String); ! SwP := Endp + 1; ! elsif Arg (SwP + 2) /= '(' then ! SwP := SwP + 2; ! Endp := Arg'Last; ! elsif Arg (Arg'Last) /= ')' then ! Put (Standard_Error, ! "incorrectly parenthesized argument: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! SwP := Endp + 1; ! else ! SwP := SwP + 3; ! Endp := Arg'Last - 1; ! end if; ! while SwP <= Endp loop ! P2 := SwP; ! while P2 < Endp ! and then Arg (P2 + 1) /= ',' ! loop ! P2 := P2 + 1; ! end loop; ! -- Option name is in Arg (SwP .. P2) ! Opt := Matching_Name (Arg (SwP .. P2), ! Sw.Options); ! if Opt /= null then ! Place_Unix_Switches (Opt.Unix_String); ! end if; ! SwP := P2 + 2; ! end loop; ! when T_Other => ! Place_Unix_Switches ! (new String'(Sw.Unix_String.all & Arg.all)); ! end case; end if; ! end; end if; ! Arg_Idx := Next_Arg_Idx + 1; ! end; ! exit when Arg_Idx > Argv'Last; ! end loop; ! end; ! Arg_Num := Arg_Num + 1; ! end loop; ! if Display_Command then ! Put (Standard_Error, "generated command -->"); ! Put (Standard_Error, String (Buffer.Table (1 .. Buffer.Last))); ! Put (Standard_Error, "<--"); ! New_Line (Standard_Error); ! raise Normal_Exit; ! end if; ! -- Gross error checking that the number of parameters is correct. ! -- Not applicable to Unlimited_Files parameters. ! if not ((Param_Count = Command.Params'Length - 1 and then ! Command.Params (Param_Count + 1) = Unlimited_Files) ! or else (Param_Count <= Command.Params'Length)) then ! Put_Line (Standard_Error, ! "Parameter count of " ! & Integer'Image (Param_Count) ! & " not equal to expected " ! & Integer'Image (Command.Params'Length)); ! Put (Standard_Error, "usage: "); ! Put_Line (Standard_Error, Command.Usage.all); ! Errors := Errors + 1; ! end if; - if Errors > 0 then - raise Error_Exit; else ! -- Prepare arguments for a call to spawn, filtering out ! -- embedded nulls place there to delineate strings. ! declare ! Pname_Ptr : Natural; ! Args : Argument_List (1 .. 500); ! Nargs : Natural; ! P1, P2 : Natural; ! Exec_Path : String_Access; ! Inside_Nul : Boolean := False; ! Arg : String (1 .. 1024); ! Arg_Ctr : Natural; ! begin ! Pname_Ptr := 1; ! while Pname_Ptr < Buffer.Last ! and then Buffer.Table (Pname_Ptr + 1) /= ' ' ! loop ! Pname_Ptr := Pname_Ptr + 1; end loop; ! P1 := Pname_Ptr + 2; ! Arg_Ctr := 1; ! Arg (Arg_Ctr) := Buffer.Table (P1); ! Nargs := 0; ! while P1 <= Buffer.Last loop ! if Buffer.Table (P1) = ASCII.NUL then ! if Inside_Nul then ! Inside_Nul := False; ! else ! Inside_Nul := True; ! end if; ! end if; ! if Buffer.Table (P1) = ' ' and then not Inside_Nul then ! P1 := P1 + 1; ! Arg_Ctr := Arg_Ctr + 1; ! Arg (Arg_Ctr) := Buffer.Table (P1); ! else ! Nargs := Nargs + 1; ! P2 := P1; - while P2 < Buffer.Last - and then (Buffer.Table (P2 + 1) /= ' ' or else - Inside_Nul) - loop - P2 := P2 + 1; - Arg_Ctr := Arg_Ctr + 1; - Arg (Arg_Ctr) := Buffer.Table (P2); - if Buffer.Table (P2) = ASCII.NUL then - Arg_Ctr := Arg_Ctr - 1; - if Inside_Nul then - Inside_Nul := False; else ! Inside_Nul := True; end if; end if; - end loop; ! Args (Nargs) := new String'(String (Arg (1 .. Arg_Ctr))); ! P1 := P2 + 2; ! Arg_Ctr := 1; ! Arg (Arg_Ctr) := Buffer.Table (P1); end if; end loop; ! Exec_Path := Locate_Exec_On_Path ! (String (Buffer.Table (1 .. Pname_Ptr))); ! if Exec_Path = null then ! Put_Line (Standard_Error, ! "Couldn't locate " ! & String (Buffer.Table (1 .. Pname_Ptr))); ! raise Error_Exit; end if; My_Exit_Status ! := Exit_Status (Spawn (Exec_Path.all, Args (1 .. Nargs))); ! end; ! ! raise Normal_Exit; ! end if; exception when Error_Exit => --- 3150,4258 ---- Place ('.'); Place (Command.Defext); end if; end; ! when Unlimited_Files => ! declare ! Normal_File : String_Access ! := To_Canonical_File_Spec (Arg.all); ! File_Is_Wild : Boolean := False; ! File_List : String_Access_List_Access; ! begin ! for I in Arg'Range loop ! if Arg (I) = '*' ! or else Arg (I) = '%' ! then ! File_Is_Wild := True; ! end if; ! end loop; ! if File_Is_Wild then ! File_List := To_Canonical_File_List ! (Arg.all, False); ! ! for I in File_List.all'Range loop ! Place (' '); ! Place_Lower (File_List.all (I).all); ! end loop; ! else ! Place (' '); ! Place_Lower (Normal_File.all); ! ! if Is_Extensionless (Normal_File.all) ! and then Command.Defext /= " " ! then ! Place ('.'); ! Place (Command.Defext); ! end if; end if; ! Param_Count := Param_Count - 1; ! end; ! when Other_As_Is => ! Place (' '); ! Place (Arg.all); ! when Unlimited_As_Is => ! Place (' '); ! Place (Arg.all); ! Param_Count := Param_Count - 1; ! when Files_Or_Wildcard => ! -- Remove spaces from a comma separated list ! -- of file names and adjust control variables ! -- accordingly. ! while Arg_Num < Argument_Count and then ! (Argv (Argv'Last) = ',' xor ! Argument (Arg_Num + 1) ! (Argument (Arg_Num + 1)'First) = ',') ! loop ! Argv := new String' ! (Argv.all & Argument (Arg_Num + 1)); ! Arg_Num := Arg_Num + 1; ! Arg_Idx := Argv'First; ! Next_Arg_Idx := ! Get_Arg_End (Argv.all, Arg_Idx); ! Arg := new String' ! (Argv (Arg_Idx .. Next_Arg_Idx)); ! end loop; ! -- Parse the comma separated list of VMS ! -- filenames and place them on the command ! -- line as space separated Unix style ! -- filenames. Lower case and add default ! -- extension as appropriate. ! declare ! Arg1_Idx : Integer := Arg'First; ! function Get_Arg1_End ! (Arg : String; Arg_Idx : Integer) ! return Integer; ! -- Begins looking at Arg_Idx + 1 and ! -- returns the index of the last character ! -- before a comma or else the index of the ! -- last character in the string Arg. ! function Get_Arg1_End ! (Arg : String; Arg_Idx : Integer) ! return Integer ! is ! begin ! for I in Arg_Idx + 1 .. Arg'Last loop ! if Arg (I) = ',' then ! return I - 1; ! end if; ! end loop; ! return Arg'Last; ! end Get_Arg1_End; ! begin ! loop ! declare ! Next_Arg1_Idx : Integer := ! Get_Arg1_End (Arg.all, Arg1_Idx); ! ! Arg1 : String := ! Arg (Arg1_Idx .. Next_Arg1_Idx); ! ! Normal_File : String_Access := ! To_Canonical_File_Spec (Arg1); ! ! begin ! Place (' '); ! Place_Lower (Normal_File.all); ! ! if Is_Extensionless (Normal_File.all) ! and then Command.Defext /= " " ! then ! Place ('.'); ! Place (Command.Defext); ! end if; ! ! Arg1_Idx := Next_Arg1_Idx + 1; ! end; ! ! exit when Arg1_Idx > Arg'Last; ! ! -- Don't allow two or more commas in ! -- a row ! ! if Arg (Arg1_Idx) = ',' then ! Arg1_Idx := Arg1_Idx + 1; ! if Arg1_Idx > Arg'Last or else ! Arg (Arg1_Idx) = ',' ! then ! Put_Line ! (Standard_Error, ! "Malformed Parameter: " & ! Arg.all); ! Put (Standard_Error, "usage: "); ! Put_Line (Standard_Error, ! Command.Usage.all); ! raise Error_Exit; ! end if; ! end if; ! ! end loop; ! end; ! end case; end if; ! -- Qualifier argument else ! declare ! Sw : Item_Ptr; ! SwP : Natural; ! P2 : Natural; ! Endp : Natural := 0; -- avoid warning! ! Opt : Item_Ptr; ! begin ! SwP := Arg'First; ! while SwP < Arg'Last ! and then Arg (SwP + 1) /= '=' ! loop ! SwP := SwP + 1; ! end loop; ! -- At this point, the switch name is in ! -- Arg (Arg'First..SwP) and if that is not the ! -- whole switch, then there is an equal sign at ! -- Arg (SwP + 1) and the rest of Arg is what comes ! -- after the equal sign. ! -- If make commands are active, see if we have ! -- another COMMANDS_TRANSLATION switch belonging ! -- to gnatmake. ! if Make_Commands_Active /= null then ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Command.Switches, ! Quiet => True); ! if Sw /= null ! and then Sw.Translation = T_Commands ! then ! null; ! else ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Make_Commands_Active.Switches, ! Quiet => False); ! end if; ! -- For case of GNAT MAKE or CHOP, if we cannot ! -- find the switch, then see if it is a ! -- recognized compiler switch instead, and if ! -- so process the compiler switch. ! elsif Command.Name.all = "MAKE" ! or else Command.Name.all = "CHOP" then ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Command.Switches, ! Quiet => True); ! if Sw = null then ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Matching_Name ! ("COMPILE", Commands).Switches, ! Quiet => False); end if; ! -- For all other cases, just search the relevant ! -- command. ! else ! Sw := ! Matching_Name ! (Arg (Arg'First .. SwP), ! Command.Switches, ! Quiet => False); ! end if; ! if Sw /= null then ! case Sw.Translation is ! when T_Direct => ! Place_Unix_Switches (Sw.Unix_String); ! if SwP < Arg'Last ! and then Arg (SwP + 1) = '=' ! then ! Put (Standard_Error, ! "qualifier options ignored: "); ! Put_Line (Standard_Error, Arg.all); ! end if; ! when T_Directories => ! if SwP + 1 > Arg'Last then ! Put (Standard_Error, ! "missing directories for: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! elsif Arg (SwP + 2) /= '(' then ! SwP := SwP + 2; ! Endp := Arg'Last; ! ! elsif Arg (Arg'Last) /= ')' then ! ! -- Remove spaces from a comma separated ! -- list of file names and adjust ! -- control variables accordingly. ! ! if Arg_Num < Argument_Count and then ! (Argv (Argv'Last) = ',' xor ! Argument (Arg_Num + 1) ! (Argument (Arg_Num + 1)'First) = ',') then ! Argv := ! new String'(Argv.all ! & Argument ! (Arg_Num + 1)); ! Arg_Num := Arg_Num + 1; ! Arg_Idx := Argv'First; ! Next_Arg_Idx ! := Get_Arg_End (Argv.all, Arg_Idx); ! Arg := new String' ! (Argv (Arg_Idx .. Next_Arg_Idx)); ! goto Tryagain_After_Coalesce; ! end if; ! Put (Standard_Error, ! "incorrectly parenthesized " & ! "or malformed argument: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! else ! SwP := SwP + 3; ! Endp := Arg'Last - 1; ! end if; ! ! while SwP <= Endp loop ! declare ! Dir_Is_Wild : Boolean := False; ! Dir_Maybe_Is_Wild : Boolean := False; ! Dir_List : String_Access_List_Access; ! begin ! P2 := SwP; ! ! while P2 < Endp ! and then Arg (P2 + 1) /= ',' ! loop ! ! -- A wildcard directory spec on ! -- VMS will contain either * or ! -- % or ... ! ! if Arg (P2) = '*' then ! Dir_Is_Wild := True; ! ! elsif Arg (P2) = '%' then ! Dir_Is_Wild := True; ! ! elsif Dir_Maybe_Is_Wild ! and then Arg (P2) = '.' ! and then Arg (P2 + 1) = '.' ! then ! Dir_Is_Wild := True; ! Dir_Maybe_Is_Wild := False; ! ! elsif Dir_Maybe_Is_Wild then ! Dir_Maybe_Is_Wild := False; ! ! elsif Arg (P2) = '.' ! and then Arg (P2 + 1) = '.' ! then ! Dir_Maybe_Is_Wild := True; ! ! end if; ! ! P2 := P2 + 1; ! end loop; ! ! if (Dir_Is_Wild) then ! Dir_List := To_Canonical_File_List ! (Arg (SwP .. P2), True); ! ! for I in Dir_List.all'Range loop ! Place_Unix_Switches ! (Sw.Unix_String); ! Place_Lower ! (Dir_List.all (I).all); ! end loop; ! else ! Place_Unix_Switches ! (Sw.Unix_String); ! Place_Lower ! (To_Canonical_Dir_Spec ! (Arg (SwP .. P2), False).all); ! end if; ! ! SwP := P2 + 2; ! end; ! end loop; ! ! when T_Directory => ! if SwP + 1 > Arg'Last then ! Put (Standard_Error, ! "missing directory for: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! ! else ! Place_Unix_Switches (Sw.Unix_String); ! ! -- Some switches end in "=". No space ! -- here ! ! if Sw.Unix_String ! (Sw.Unix_String'Last) /= '=' then ! Place (' '); ! end if; + Place_Lower + (To_Canonical_Dir_Spec + (Arg (SwP + 2 .. Arg'Last), + False).all); + end if; + + when T_File | T_No_Space_File => + if SwP + 1 > Arg'Last then + Put (Standard_Error, + "missing file for: "); + Put_Line (Standard_Error, Arg.all); + Errors := Errors + 1; + + else + Place_Unix_Switches (Sw.Unix_String); + + -- Some switches end in "=". No space + -- here. + + if Sw.Translation = T_File + and then Sw.Unix_String + (Sw.Unix_String'Last) /= '=' + then + Place (' '); end if; ! Place_Lower ! (To_Canonical_File_Spec ! (Arg (SwP + 2 .. Arg'Last)).all); ! end if; ! when T_Numeric => ! if ! OK_Integer (Arg (SwP + 2 .. Arg'Last)) ! then ! Place_Unix_Switches (Sw.Unix_String); ! Place (Arg (SwP + 2 .. Arg'Last)); else + Put (Standard_Error, "argument for "); + Put (Standard_Error, Sw.Name.all); + Put_Line + (Standard_Error, " must be numeric"); + Errors := Errors + 1; + end if; + + when T_Alphanumplus => + if + OK_Alphanumerplus + (Arg (SwP + 2 .. Arg'Last)) + then Place_Unix_Switches (Sw.Unix_String); ! Place (Arg (SwP + 2 .. Arg'Last)); ! ! else ! Put (Standard_Error, "argument for "); ! Put (Standard_Error, Sw.Name.all); ! Put_Line (Standard_Error, ! " must be alphanumeric"); ! Errors := Errors + 1; end if; ! when T_String => ! -- A String value must be extended to the ! -- end of the Argv, otherwise strings like ! -- "foo/bar" get split at the slash. ! -- ! -- The begining and ending of the string ! -- are flagged with embedded nulls which ! -- are removed when building the Spawn ! -- call. Nulls are use because they won't ! -- show up in a /? output. Quotes aren't ! -- used because that would make it ! -- difficult to embed them. ! Place_Unix_Switches (Sw.Unix_String); ! if Next_Arg_Idx /= Argv'Last then ! Next_Arg_Idx := Argv'Last; ! Arg := new String' ! (Argv (Arg_Idx .. Next_Arg_Idx)); ! SwP := Arg'First; ! while SwP < Arg'Last and then ! Arg (SwP + 1) /= '=' loop ! SwP := SwP + 1; ! end loop; ! end if; ! Place (ASCII.NUL); ! Place (Arg (SwP + 2 .. Arg'Last)); ! Place (ASCII.NUL); ! ! when T_Commands => ! ! -- Output -largs/-bargs/-cargs Place (' '); ! Place (Sw.Unix_String ! (Sw.Unix_String'First .. ! Sw.Unix_String'First + 5)); ! -- Set source of new commands, also ! -- setting this non-null indicates that ! -- we are in the special commands mode ! -- for processing the -xargs case. ! Make_Commands_Active := ! Matching_Name ! (Sw.Unix_String ! (Sw.Unix_String'First + 7 .. ! Sw.Unix_String'Last), ! Commands); ! when T_Options => ! if SwP + 1 > Arg'Last then ! Place_Unix_Switches ! (Sw.Options.Unix_String); ! SwP := Endp + 1; ! elsif Arg (SwP + 2) /= '(' then ! SwP := SwP + 2; ! Endp := Arg'Last; ! elsif Arg (Arg'Last) /= ')' then ! Put ! (Standard_Error, ! "incorrectly parenthesized " & ! "argument: "); ! Put_Line (Standard_Error, Arg.all); ! Errors := Errors + 1; ! SwP := Endp + 1; ! else ! SwP := SwP + 3; ! Endp := Arg'Last - 1; ! end if; ! while SwP <= Endp loop ! P2 := SwP; ! while P2 < Endp ! and then Arg (P2 + 1) /= ',' ! loop ! P2 := P2 + 1; ! end loop; ! -- Option name is in Arg (SwP .. P2) ! Opt := Matching_Name (Arg (SwP .. P2), ! Sw.Options); ! if Opt /= null then ! Place_Unix_Switches ! (Opt.Unix_String); ! end if; ! SwP := P2 + 2; ! end loop; ! when T_Other => ! Place_Unix_Switches ! (new String'(Sw.Unix_String.all & ! Arg.all)); ! end case; ! end if; ! end; ! end if; ! Arg_Idx := Next_Arg_Idx + 1; ! end; ! exit when Arg_Idx > Argv'Last; ! end loop; ! end Process_Argument; ! Arg_Num := Arg_Num + 1; ! end loop; ! if Display_Command then ! Put (Standard_Error, "generated command -->"); ! Put (Standard_Error, Command_List (The_Command).Unixcmd.all); ! if Command_List (The_Command).Unixsws /= null then ! for J in Command_List (The_Command).Unixsws'Range loop ! Put (Standard_Error, " "); ! Put (Standard_Error, ! Command_List (The_Command).Unixsws (J).all); ! end loop; ! end if; ! Put (Standard_Error, " "); ! Put (Standard_Error, String (Buffer.Table (1 .. Buffer.Last))); ! Put (Standard_Error, "<--"); ! New_Line (Standard_Error); ! raise Normal_Exit; ! end if; ! -- Gross error checking that the number of parameters is correct. ! -- Not applicable to Unlimited_Files parameters. ! if (Param_Count = Command.Params'Length - 1 ! and then Command.Params (Param_Count + 1) = Unlimited_Files) ! or else Param_Count <= Command.Params'Length ! then ! null; ! else ! Put_Line (Standard_Error, ! "Parameter count of " ! & Integer'Image (Param_Count) ! & " not equal to expected " ! & Integer'Image (Command.Params'Length)); ! Put (Standard_Error, "usage: "); ! Put_Line (Standard_Error, Command.Usage.all); ! Errors := Errors + 1; ! end if; ! if Errors > 0 then ! raise Error_Exit; ! else ! -- Prepare arguments for a call to spawn, filtering out ! -- embedded nulls place there to delineate strings. ! declare ! P1, P2 : Natural; ! Inside_Nul : Boolean := False; ! Arg : String (1 .. 1024); ! Arg_Ctr : Natural; ! begin ! P1 := 1; ! while P1 <= Buffer.Last and then Buffer.Table (P1) = ' ' loop ! P1 := P1 + 1; ! end loop; ! Arg_Ctr := 1; ! Arg (Arg_Ctr) := Buffer.Table (P1); ! while P1 <= Buffer.Last loop ! if Buffer.Table (P1) = ASCII.NUL then ! if Inside_Nul then ! Inside_Nul := False; ! else ! Inside_Nul := True; ! end if; ! end if; ! ! if Buffer.Table (P1) = ' ' and then not Inside_Nul then ! P1 := P1 + 1; ! Arg_Ctr := Arg_Ctr + 1; ! Arg (Arg_Ctr) := Buffer.Table (P1); ! ! else ! Last_Switches.Increment_Last; ! P2 := P1; ! ! while P2 < Buffer.Last ! and then (Buffer.Table (P2 + 1) /= ' ' or else ! Inside_Nul) ! loop ! P2 := P2 + 1; ! Arg_Ctr := Arg_Ctr + 1; ! Arg (Arg_Ctr) := Buffer.Table (P2); ! if Buffer.Table (P2) = ASCII.NUL then ! Arg_Ctr := Arg_Ctr - 1; ! if Inside_Nul then ! Inside_Nul := False; ! else ! Inside_Nul := True; ! end if; end if; ! end loop; ! ! Last_Switches.Table (Last_Switches.Last) := ! new String'(String (Arg (1 .. Arg_Ctr))); ! P1 := P2 + 2; ! Arg_Ctr := 1; ! Arg (Arg_Ctr) := Buffer.Table (P1); end if; + end loop; + end; + end if; + end VMS_Conversion; ! ------------------------------------- ! -- Start of processing for GNATCmd -- ! ------------------------------------- ! begin ! -- Initializations ! Namet.Initialize; ! Csets.Initialize; ! Snames.Initialize; ! Prj.Initialize; ! Last_Switches.Init; ! Last_Switches.Set_Last (0); ! First_Switches.Init; ! First_Switches.Set_Last (0); ! ! -- If on VMS, or if VMS emulation is on, convert VMS style /qualifiers, ! -- filenames and pathnames to Unix style. ! ! if Hostparm.OpenVMS ! or else To_Lower (Getenv ("EMULATE_VMS").all) = "true" then ! VMS_Conversion (The_Command); ! ! -- If not on VMS, scan the command line directly else ! if Argument_Count = 0 then ! Non_VMS_Usage; ! return; ! else ! begin ! if Argument_Count > 1 and then Argument (1) = "-v" then ! Opt.Verbose_Mode := True; ! Command_Arg := 2; ! end if; ! The_Command := Real_Command_Type'Value (Argument (Command_Arg)); ! if Command_List (The_Command).VMS_Only then ! Non_VMS_Usage; ! Fail ("Command """ & Command_List (The_Command).Cname.all & ! """ can only be used on VMS"); ! end if; ! exception ! when Constraint_Error => ! -- Check if it is an alternate command ! declare ! Alternate : Alternate_Command; ! ! begin ! Alternate := Alternate_Command'Value ! (Argument (Command_Arg)); ! The_Command := Corresponding_To (Alternate); ! ! exception ! when Constraint_Error => ! Non_VMS_Usage; ! Fail ("Unknown command: " & Argument (Command_Arg)); ! end; ! end; ! ! for Arg in Command_Arg + 1 .. Argument_Count loop ! Last_Switches.Increment_Last; ! Last_Switches.Table (Last_Switches.Last) := ! new String'(Argument (Arg)); end loop; + end if; + end if; ! declare ! Program : constant String := ! Program_Name (Command_List (The_Command).Unixcmd.all).all; ! Exec_Path : String_Access; ! begin ! -- Locate the executable for the command ! Exec_Path := Locate_Exec_On_Path (Program); ! if Exec_Path = null then ! Put_Line (Standard_Error, "Couldn't locate " & Program); ! raise Error_Exit; ! end if; ! ! -- If there are switches for the executable, put them as first switches ! ! if Command_List (The_Command).Unixsws /= null then ! for J in Command_List (The_Command).Unixsws'Range loop ! First_Switches.Increment_Last; ! First_Switches.Table (First_Switches.Last) := ! Command_List (The_Command).Unixsws (J); ! end loop; ! end if; ! ! -- For BIND, FIND, LINK, LIST and XREF, look for project file related ! -- switches. ! ! if The_Command = Bind ! or else The_Command = Find ! or else The_Command = Link ! or else The_Command = List ! or else The_Command = Xref ! then ! case The_Command is ! when Bind => ! Tool_Package_Name := Name_Binder; ! when Find => ! Tool_Package_Name := Name_Finder; ! when Link => ! Tool_Package_Name := Name_Linker; ! when List => ! Tool_Package_Name := Name_Gnatls; ! when Xref => ! Tool_Package_Name := Name_Cross_Reference; ! when others => ! null; ! end case; ! ! declare ! Arg_Num : Positive := 1; ! Argv : String_Access; ! ! procedure Remove_Switch (Num : Positive); ! -- Remove a project related switch from table Last_Switches ! ! ------------------- ! -- Remove_Switch -- ! ------------------- ! ! procedure Remove_Switch (Num : Positive) is ! begin ! Last_Switches.Table (Num .. Last_Switches.Last - 1) := ! Last_Switches.Table (Num + 1 .. Last_Switches.Last); ! Last_Switches.Decrement_Last; ! end Remove_Switch; ! ! -- Start of processing for ??? (need block name here) ! ! begin ! while Arg_Num <= Last_Switches.Last loop ! Argv := Last_Switches.Table (Arg_Num); ! ! if Argv (Argv'First) = '-' then ! if Argv'Length = 1 then ! Fail ("switch character cannot be followed by a blank"); ! end if; ! ! -- The two style project files (-p and -P) cannot be used ! -- together ! ! if (The_Command = Find or else The_Command = Xref) ! and then Argv (2) = 'p' ! then ! Old_Project_File_Used := True; ! if Project_File /= null then ! Fail ("-P and -p cannot be used together"); ! end if; ! end if; ! ! -- -vPx Specify verbosity while parsing project files ! ! if Argv'Length = 4 ! and then Argv (Argv'First + 1 .. Argv'First + 2) = "vP" ! then ! case Argv (Argv'Last) is ! when '0' => ! Current_Verbosity := Prj.Default; ! when '1' => ! Current_Verbosity := Prj.Medium; ! when '2' => ! Current_Verbosity := Prj.High; ! when others => ! Fail ("Invalid switch: " & Argv.all); ! end case; ! ! Remove_Switch (Arg_Num); ! ! -- -Pproject_file Specify project file to be used ! ! elsif Argv'Length >= 3 ! and then Argv (Argv'First + 1) = 'P' ! then ! ! -- Only one -P switch can be used ! ! if Project_File /= null then ! Fail (Argv.all & ! ": second project file forbidden (first is """ & ! Project_File.all & """)"); ! ! -- The two style project files (-p and -P) cannot be ! -- used together. ! ! elsif Old_Project_File_Used then ! Fail ("-p and -P cannot be used together"); else ! Project_File := ! new String'(Argv (Argv'First + 2 .. Argv'Last)); end if; + + Remove_Switch (Arg_Num); + + -- -Xexternal=value Specify an external reference to be + -- used in project files + + elsif Argv'Length >= 5 + and then Argv (Argv'First + 1) = 'X' + then + declare + Equal_Pos : constant Natural := + Index ('=', Argv (Argv'First + 2 .. Argv'Last)); + begin + if Equal_Pos >= Argv'First + 3 and then + Equal_Pos /= Argv'Last then + Add (External_Name => + Argv (Argv'First + 2 .. Equal_Pos - 1), + Value => Argv (Equal_Pos + 1 .. Argv'Last)); + else + Fail (Argv.all & + " is not a valid external assignment."); + end if; + end; + + Remove_Switch (Arg_Num); + + else + Arg_Num := Arg_Num + 1; end if; ! else ! Arg_Num := Arg_Num + 1; ! end if; ! end loop; ! end; ! end if; ! ! -- If there is a project file specified, parse it, get the switches ! -- for the tool and setup PATH environment variables. ! ! if Project_File /= null then ! Prj.Pars.Set_Verbosity (To => Current_Verbosity); ! ! Prj.Pars.Parse ! (Project => Project, ! Project_File_Name => Project_File.all); ! ! if Project = Prj.No_Project then ! Fail ("""" & Project_File.all & """ processing failed"); ! end if; ! ! -- Check if a package with the name of the tool is in the project ! -- file and if there is one, get the switches, if any, and scan them. ! ! declare ! Data : Prj.Project_Data := Prj.Projects.Table (Project); ! Pkg : Prj.Package_Id := ! Prj.Util.Value_Of ! (Name => Tool_Package_Name, ! In_Packages => Data.Decl.Packages); ! ! Element : Package_Element; ! ! Default_Switches_Array : Array_Element_Id; ! ! The_Switches : Prj.Variable_Value; ! Current : Prj.String_List_Id; ! The_String : String_Element; ! ! begin ! if Pkg /= No_Package then ! Element := Packages.Table (Pkg); ! ! -- Packages Gnatls has a single attribute Switches, that is ! -- not an associative array. ! ! if The_Command = List then ! The_Switches := ! Prj.Util.Value_Of ! (Variable_Name => Snames.Name_Switches, ! In_Variables => Element.Decl.Attributes); ! ! -- Packages Binder (for gnatbind), Cross_Reference (for ! -- gnatxref), Linker (for gnatlink) and Finder ! -- (for gnatfind) have an attributed Default_Switches, ! -- an associative array, indexed by the name of the ! -- programming language. ! else ! Default_Switches_Array := ! Prj.Util.Value_Of ! (Name => Name_Default_Switches, ! In_Arrays => Packages.Table (Pkg).Decl.Arrays); ! The_Switches := Prj.Util.Value_Of ! (Index => Name_Ada, ! In_Array => Default_Switches_Array); ! ! end if; ! ! -- If there are switches specified in the package of the ! -- project file corresponding to the tool, scan them. ! ! case The_Switches.Kind is ! when Prj.Undefined => ! null; ! ! when Prj.Single => ! if String_Length (The_Switches.Value) > 0 then ! String_To_Name_Buffer (The_Switches.Value); ! First_Switches.Increment_Last; ! First_Switches.Table (First_Switches.Last) := ! new String'(Name_Buffer (1 .. Name_Len)); ! end if; ! ! when Prj.List => ! Current := The_Switches.Values; ! while Current /= Prj.Nil_String loop ! The_String := String_Elements.Table (Current); ! ! if String_Length (The_String.Value) > 0 then ! String_To_Name_Buffer (The_String.Value); ! First_Switches.Increment_Last; ! First_Switches.Table (First_Switches.Last) := ! new String'(Name_Buffer (1 .. Name_Len)); ! end if; ! ! Current := The_String.Next; ! end loop; ! end case; end if; + end; + + -- Set up the environment variables ADA_INCLUDE_PATH and + -- ADA_OBJECTS_PATH. + + Setenv + (Name => Ada_Include_Path, + Value => Prj.Env.Ada_Include_Path (Project).all); + Setenv + (Name => Ada_Objects_Path, + Value => Prj.Env.Ada_Objects_Path + (Project, Including_Libraries => False).all); + + if The_Command = Bind or else The_Command = Link then + Change_Dir + (Get_Name_String + (Projects.Table (Project).Object_Directory)); + end if; + + if The_Command = Link then + + -- Add the default search directories, to be able to find + -- libgnat in call to MLib.Utl.Lib_Directory. + + Add_Default_Search_Dirs; + + declare + There_Are_Libraries : Boolean := False; + + begin + -- Check if there are library project files + + if MLib.Tgt.Libraries_Are_Supported then + Set_Libraries (Project, There_Are_Libraries); + end if; + + -- If there are, add the necessary additional switches + + if There_Are_Libraries then + + -- Add -L -lgnarl -lgnat -Wl,-rpath, + + Last_Switches.Increment_Last; + Last_Switches.Table (Last_Switches.Last) := + new String'("-L" & MLib.Utl.Lib_Directory); + Last_Switches.Increment_Last; + Last_Switches.Table (Last_Switches.Last) := + new String'("-lgnarl"); + Last_Switches.Increment_Last; + Last_Switches.Table (Last_Switches.Last) := + new String'("-lgnat"); + + declare + Option : constant String_Access := + MLib.Tgt.Linker_Library_Path_Option + (MLib.Utl.Lib_Directory); + + begin + if Option /= null then + Last_Switches.Increment_Last; + Last_Switches.Table (Last_Switches.Last) := + Option; + end if; + end; + end if; + end; + end if; + end if; + + -- Gather all the arguments and invoke the executable + + declare + The_Args : Argument_List + (1 .. First_Switches.Last + Last_Switches.Last); + Arg_Num : Natural := 0; + begin + for J in 1 .. First_Switches.Last loop + Arg_Num := Arg_Num + 1; + The_Args (Arg_Num) := First_Switches.Table (J); end loop; ! for J in 1 .. Last_Switches.Last loop ! Arg_Num := Arg_Num + 1; ! The_Args (Arg_Num) := Last_Switches.Table (J); ! end loop; ! if Opt.Verbose_Mode then ! Output.Write_Str (Exec_Path.all); ! ! for Arg in The_Args'Range loop ! Output.Write_Char (' '); ! Output.Write_Str (The_Args (Arg).all); ! end loop; ! ! Output.Write_Eol; end if; My_Exit_Status ! := Exit_Status (Spawn (Exec_Path.all, The_Args)); ! raise Normal_Exit; end; ! end; exception when Error_Exit => diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatcmd.ads gcc-3.3/gcc/ada/gnatcmd.ads *** gcc-3.2.3/gcc/ada/gnatcmd.ads 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/gnatcmd.ads 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatdll.adb gcc-3.3/gcc/ada/gnatdll.adb *** gcc-3.2.3/gcc/ada/gnatdll.adb 2002-05-04 03:28:11.000000000 +0000 --- gcc-3.3/gcc/ada/gnatdll.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1997-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2002, 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- -- *************** with GNAT.OS_Lib; *** 37,44 **** with GNAT.Command_Line; with Gnatvsn; ! with MDLL.Files; ! with MDLL.Tools; procedure Gnatdll is --- 36,43 ---- with GNAT.Command_Line; with Gnatvsn; ! with MDLL.Fil; ! with MDLL.Utl; procedure Gnatdll is *************** procedure Gnatdll is *** 62,72 **** -- Check the context before runing any commands to build the library Syntax_Error : exception; Context_Error : exception; ! -- What are these for ??? Help : Boolean := False; ! -- What is this for ??? Version : constant String := Gnatvsn.Gnat_Version_String; -- Why should it be necessary to make a copy of this --- 61,75 ---- -- Check the context before runing any commands to build the library Syntax_Error : exception; + -- Raised when a syntax error is detected, in this case a usage info will + -- be displayed. + Context_Error : exception; ! -- Raised when some files (specifed on the command line) are missing to ! -- build the DLL. Help : Boolean := False; ! -- Help will be set to True the usage information is to be displayed. Version : constant String := Gnatvsn.Gnat_Version_String; -- Why should it be necessary to make a copy of this *************** procedure Gnatdll is *** 75,85 **** -- Default address for non relocatable DLL (Win32) Lib_Filename : Unbounded_String := Null_Unbounded_String; Def_Filename : Unbounded_String := Null_Unbounded_String; List_Filename : Unbounded_String := Null_Unbounded_String; DLL_Address : Unbounded_String := To_Unbounded_String (Default_DLL_Address); ! -- What are the above ??? Objects_Files : Argument_List_Access := Null_Argument_List_Access; -- List of objects to put inside the library --- 78,94 ---- -- Default address for non relocatable DLL (Win32) Lib_Filename : Unbounded_String := Null_Unbounded_String; + -- The DLL filename that will be created (.dll) + Def_Filename : Unbounded_String := Null_Unbounded_String; + -- The definition filename (.def) + List_Filename : Unbounded_String := Null_Unbounded_String; + -- The name of the file containing the objects file to put into the DLL + DLL_Address : Unbounded_String := To_Unbounded_String (Default_DLL_Address); ! -- The DLL's base address Objects_Files : Argument_List_Access := Null_Argument_List_Access; -- List of objects to put inside the library *************** procedure Gnatdll is *** 95,107 **** Bargs_Options : Argument_List_Access := Null_Argument_List_Access; -- GNAT linker and binder args options ! type Build_Mode_State is (Import_Lib, Dynamic_Lib, Nil); ! -- Comments needed ??? Build_Mode : Build_Mode_State := Nil; Must_Build_Relocatable : Boolean := True; ! Build_Import : Boolean := True; ! -- Comments needed ------------ -- Syntax -- --- 104,121 ---- Bargs_Options : Argument_List_Access := Null_Argument_List_Access; -- GNAT linker and binder args options ! type Build_Mode_State is (Import_Lib, Dynamic_Lib, Dynamic_Lib_Only, Nil); ! -- Import_Lib means only the .a file will be created, Dynamic_Lib means ! -- that both the DLL and the import library will be created. ! -- Dynamic_Lib_Only means that only the DLL will be created (no import ! -- library). Build_Mode : Build_Mode_State := Nil; + -- Will be set when parsing the command line. + Must_Build_Relocatable : Boolean := True; ! -- True means build a relocatable DLL, will be set to False if a ! -- non-relocatable DLL must be built. ------------ -- Syntax -- *************** procedure Gnatdll is *** 130,135 **** --- 144,151 ---- P (" -e file Definition file containing exports"); P (" -d file Put objects in the relocatable dynamic " & "library "); + P (" -b addr Set base address for the relocatable DLL"); + P (" default address is " & Default_DLL_Address); P (" -a[addr] Build non-relocatable DLL at address "); P (" if is not specified use " & Default_DLL_Address); *************** procedure Gnatdll is *** 159,174 **** use GNAT.Command_Line; procedure Add_File (Filename : in String); ! -- add one file to the list of file to handle procedure Add_Files_From_List (List_Filename : in String); ! -- add the files listed in List_Filename (one by line) to the list -- of file to handle - procedure Ali_To_Object_List; - -- for each ali file in Afiles set put a corresponding object file in - -- Ofiles set. - Max_Files : constant := 5_000; Max_Options : constant := 100; -- These are arbitrary limits, a better way will be to use linked list. --- 175,186 ---- use GNAT.Command_Line; procedure Add_File (Filename : in String); ! -- Add one file to the list of file to handle procedure Add_Files_From_List (List_Filename : in String); ! -- Add the files listed in List_Filename (one by line) to the list -- of file to handle Max_Files : constant := 5_000; Max_Options : constant := 100; -- These are arbitrary limits, a better way will be to use linked list. *************** procedure Gnatdll is *** 196,211 **** B : Positive := Bopts'First; -- A list of -bargs options (B is next entry to be used) -------------- -- Add_File -- -------------- procedure Add_File (Filename : in String) is begin ! -- others files are to be put inside the dynamic library ! -- ??? this makes no sense, should it be "Other files ..." ! ! if Files.Is_Ali (Filename) then Check (Filename); --- 208,223 ---- B : Positive := Bopts'First; -- A list of -bargs options (B is next entry to be used) + Build_Import : Boolean := True; + -- Set to Fals if option -n if specified (no-import). + -------------- -- Add_File -- -------------- procedure Add_File (Filename : in String) is begin ! if Fil.Is_Ali (Filename) then Check (Filename); *************** procedure Gnatdll is *** 215,221 **** Afiles (A) := new String'(Filename); A := A + 1; ! elsif Files.Is_Obj (Filename) then Check (Filename); --- 227,233 ---- Afiles (A) := new String'(Filename); A := A + 1; ! elsif Fil.Is_Obj (Filename) then Check (Filename); *************** procedure Gnatdll is *** 253,270 **** Text_IO.Close (File); end Add_Files_From_List; - ------------------------ - -- Ali_To_Object_List -- - ------------------------ - - procedure Ali_To_Object_List is - begin - for K in 1 .. A - 1 loop - Ofiles (O) := new String'(Files.Ext_To (Afiles (K).all, "o")); - O := O + 1; - end loop; - end Ali_To_Object_List; - -- Start of processing for Parse_Command_Line begin --- 265,270 ---- *************** procedure Gnatdll is *** 273,279 **** -- scan gnatdll switches loop ! case Getopt ("g h v q k a? d: e: l: n I:") is when ASCII.Nul => exit; --- 273,279 ---- -- scan gnatdll switches loop ! case Getopt ("g h v q k a? b: d: e: l: n I:") is when ASCII.Nul => exit; *************** procedure Gnatdll is *** 326,331 **** --- 326,337 ---- Must_Build_Relocatable := False; + when 'b' => + + DLL_Address := To_Unbounded_String (Parameter); + + Must_Build_Relocatable := True; + when 'e' => Def_Filename := To_Unbounded_String (Parameter); *************** procedure Gnatdll is *** 338,344 **** if Def_Filename = Null_Unbounded_String then Def_Filename := To_Unbounded_String ! (Files.Ext_To (Parameter, "def")); end if; Build_Mode := Dynamic_Lib; --- 344,350 ---- if Def_Filename = Null_Unbounded_String then Def_Filename := To_Unbounded_String ! (Fil.Ext_To (Parameter, "def")); end if; Build_Mode := Dynamic_Lib; *************** procedure Gnatdll is *** 419,424 **** --- 425,441 ---- "nothing to do."); end if; + -- -n option but no file specified + + if not Build_Import + and then A = Afiles'First + and then O = Ofiles'First + then + Exceptions.Raise_Exception + (Syntax_Error'Identity, + "-n specified but there are no objects to build the library."); + end if; + -- Check if we want to build an import library (option -e and -- no file specified) *************** procedure Gnatdll is *** 429,434 **** --- 446,457 ---- Build_Mode := Import_Lib; end if; + -- Check if only a dynamic library must be built. + + if Build_Mode = Dynamic_Lib and then not Build_Import then + Build_Mode := Dynamic_Lib_Only; + end if; + if O /= Ofiles'First then Objects_Files := new OS_Lib.Argument_List'(Ofiles (1 .. O - 1)); end if; *************** begin *** 495,501 **** Text_IO.New_Line; end if; ! MDLL.Tools.Locate; if Help or else (MDLL.Verbose and then Ada.Command_Line.Argument_Count = 1) --- 518,524 ---- Text_IO.New_Line; end if; ! MDLL.Utl.Locate; if Help or else (MDLL.Verbose and then Ada.Command_Line.Argument_Count = 1) *************** begin *** 521,528 **** To_String (Lib_Filename), To_String (Def_Filename), To_String (DLL_Address), ! Build_Import, ! Must_Build_Relocatable); when Nil => null; --- 544,564 ---- To_String (Lib_Filename), To_String (Def_Filename), To_String (DLL_Address), ! Build_Import => True, ! Relocatable => Must_Build_Relocatable); ! ! when Dynamic_Lib_Only => ! MDLL.Build_Dynamic_Library ! (Objects_Files.all, ! Ali_Files.all, ! Options.all, ! Bargs_Options.all, ! Largs_Options.all, ! To_String (Lib_Filename), ! To_String (Def_Filename), ! To_String (DLL_Address), ! Build_Import => False, ! Relocatable => Must_Build_Relocatable); when Nil => null; diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatfind.adb gcc-3.3/gcc/ada/gnatfind.adb *** gcc-3.2.3/gcc/ada/gnatfind.adb 2002-05-04 03:28:11.000000000 +0000 --- gcc-3.3/gcc/ada/gnatfind.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1998-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2002 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- -- *************** *** 23,35 **** -- -- ------------------------------------------------------------------------------ ! with Xr_Tabls; ! with Xref_Lib; use Xref_Lib; ! with Ada.Text_IO; ! with GNAT.Command_Line; with Gnatvsn; ! with Osint; with Ada.Strings.Fixed; use Ada.Strings.Fixed; --------------- -- Gnatfind -- --- 22,38 ---- -- -- ------------------------------------------------------------------------------ ! with Xr_Tabls; use Xr_Tabls; ! with Xref_Lib; use Xref_Lib; ! with Osint; use Osint; ! with Types; use Types; ! with Gnatvsn; ! with Opt; ! with Ada.Strings.Fixed; use Ada.Strings.Fixed; + with Ada.Text_IO; use Ada.Text_IO; + with GNAT.Command_Line; use GNAT.Command_Line; --------------- -- Gnatfind -- *************** procedure Gnatfind is *** 69,83 **** procedure Parse_Cmd_Line is begin loop ! case GNAT.Command_Line.Getopt ("a aI: aO: d e f g h I: p: r s t") is when ASCII.NUL => exit; when 'a' => if GNAT.Command_Line.Full_Switch = "a" then Read_Only := True; elsif GNAT.Command_Line.Full_Switch = "aI" then Osint.Add_Src_Search_Dir (GNAT.Command_Line.Parameter); else Osint.Add_Lib_Search_Dir (GNAT.Command_Line.Parameter); end if; --- 72,91 ---- procedure Parse_Cmd_Line is begin loop ! case ! GNAT.Command_Line.Getopt ! ("a aI: aO: d e f g h I: nostdinc nostdlib p: r s t -RTS=") ! is when ASCII.NUL => exit; when 'a' => if GNAT.Command_Line.Full_Switch = "a" then Read_Only := True; + elsif GNAT.Command_Line.Full_Switch = "aI" then Osint.Add_Src_Search_Dir (GNAT.Command_Line.Parameter); + else Osint.Add_Lib_Search_Dir (GNAT.Command_Line.Parameter); end if; *************** procedure Gnatfind is *** 101,109 **** --- 109,126 ---- Osint.Add_Src_Search_Dir (GNAT.Command_Line.Parameter); Osint.Add_Lib_Search_Dir (GNAT.Command_Line.Parameter); + when 'n' => + if GNAT.Command_Line.Full_Switch = "nostdinc" then + Opt.No_Stdinc := True; + + elsif GNAT.Command_Line.Full_Switch = "nostlib" then + Opt.No_Stdlib := True; + end if; + when 'p' => declare S : constant String := GNAT.Command_Line.Parameter; + begin Prj_File_Length := S'Length; Prj_File (1 .. Prj_File_Length) := S; *************** procedure Gnatfind is *** 118,123 **** --- 135,173 ---- when 't' => Type_Tree := True; + -- Only switch starting with -- recognized is --RTS + + when '-' => + Opt.No_Stdinc := True; + Opt.RTS_Switch := True; + + declare + Src_Path_Name : String_Ptr := + Get_RTS_Search_Dir + (GNAT.Command_Line.Parameter, Include); + Lib_Path_Name : String_Ptr := + Get_RTS_Search_Dir + (GNAT.Command_Line.Parameter, Objects); + + begin + if Src_Path_Name /= null and then Lib_Path_Name /= null then + Add_Search_Dirs (Src_Path_Name, Include); + Add_Search_Dirs (Lib_Path_Name, Objects); + + elsif Src_Path_Name = null and then Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude and adalib directories"); + + elsif Src_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude directory"); + + elsif Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adalib directory"); + end if; + end; + when others => Write_Usage; end case; *************** procedure Gnatfind is *** 128,133 **** --- 178,184 ---- loop declare S : constant String := GNAT.Command_Line.Get_Argument; + begin exit when S'Length = 0; *************** procedure Gnatfind is *** 145,151 **** -- Next arguments are the files to search else ! Add_File (S); Wide_Search := False; Nb_File := Nb_File + 1; end if; --- 196,202 ---- -- Next arguments are the files to search else ! Add_Xref_File (S); Wide_Search := False; Nb_File := Nb_File + 1; end if; *************** procedure Gnatfind is *** 160,166 **** when GNAT.Command_Line.Invalid_Parameter => Ada.Text_IO.Put_Line ("Parameter missing for : " ! & GNAT.Command_Line.Parameter); Write_Usage; when Xref_Lib.Invalid_Argument => --- 211,217 ---- when GNAT.Command_Line.Invalid_Parameter => Ada.Text_IO.Put_Line ("Parameter missing for : " ! & GNAT.Command_Line.Full_Switch); Write_Usage; when Xref_Lib.Invalid_Argument => *************** procedure Gnatfind is *** 173,183 **** ----------------- procedure Write_Usage is - use Ada.Text_IO; - begin Put_Line ("GNATFIND " & Gnatvsn.Gnat_Version_String ! & " Copyright 1998-2001, Ada Core Technologies Inc."); Put_Line ("Usage: gnatfind pattern[:sourcefile[:line[:column]]] " & "[file1 file2 ...]"); New_Line; --- 224,232 ---- ----------------- procedure Write_Usage is begin Put_Line ("GNATFIND " & Gnatvsn.Gnat_Version_String ! & " Copyright 1998-2002, Ada Core Technologies Inc."); Put_Line ("Usage: gnatfind pattern[:sourcefile[:line[:column]]] " & "[file1 file2 ...]"); New_Line; *************** procedure Gnatfind is *** 193,220 **** & "references. This parameters are optional"); New_Line; Put_Line ("gnatfind switches:"); ! Put_Line (" -a Consider all files, even when the ali file is " & "readonly"); ! Put_Line (" -aIdir Specify source files search path"); ! Put_Line (" -aOdir Specify library/object files search path"); ! Put_Line (" -d Output derived type information"); ! Put_Line (" -e Use the full regular expression set for pattern"); ! Put_Line (" -f Output full path name"); ! Put_Line (" -g Output information only for global symbols"); ! Put_Line (" -Idir Like -aIdir -aOdir"); ! Put_Line (" -p file Use file as the default project file"); ! Put_Line (" -r Find all references (default to find declaration" & " only)"); ! Put_Line (" -s Print source line"); ! Put_Line (" -t Print type hierarchy"); New_Line; raise Usage_Error; end Write_Usage; ! begin ! Osint.Initialize (Osint.Compiler); Parse_Cmd_Line; if not Have_Entity then --- 242,276 ---- & "references. This parameters are optional"); New_Line; Put_Line ("gnatfind switches:"); ! Put_Line (" -a Consider all files, even when the ali file is " & "readonly"); ! Put_Line (" -aIdir Specify source files search path"); ! Put_Line (" -aOdir Specify library/object files search path"); ! Put_Line (" -d Output derived type information"); ! Put_Line (" -e Use the full regular expression set for " ! & "pattern"); ! Put_Line (" -f Output full path name"); ! Put_Line (" -g Output information only for global symbols"); ! Put_Line (" -Idir Like -aIdir -aOdir"); ! Put_Line (" -nostdinc Don't look for sources in the system default" ! & " directory"); ! Put_Line (" -nostdlib Don't look for library files in the system" ! & " default directory"); ! Put_Line (" --RTS=dir specify the default source and object search" ! & " path"); ! Put_Line (" -p file Use file as the default project file"); ! Put_Line (" -r Find all references (default to find declaration" & " only)"); ! Put_Line (" -s Print source line"); ! Put_Line (" -t Print type hierarchy"); New_Line; raise Usage_Error; end Write_Usage; ! -- Start of processing for Gnatfind + begin Parse_Cmd_Line; if not Have_Entity then diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatkr.adb gcc-3.3/gcc/ada/gnatkr.adb *** gcc-3.2.3/gcc/ada/gnatkr.adb 2002-05-04 03:28:12.000000000 +0000 --- gcc-3.3/gcc/ada/gnatkr.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 28,39 **** with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Command_Line; use Ada.Command_Line; - with Gnatvsn; with Krunch; with System.IO; use System.IO; procedure Gnatkr is - pragma Ident (Gnatvsn.Gnat_Version_String); Count : Natural; Maxlen : Integer; --- 27,36 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatkr.ads gcc-3.3/gcc/ada/gnatkr.ads *** gcc-3.2.3/gcc/ada/gnatkr.ads 2002-05-04 03:28:12.000000000 +0000 --- gcc-3.3/gcc/ada/gnatkr.ads 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatlbr.adb gcc-3.3/gcc/ada/gnatlbr.adb *** gcc-3.2.3/gcc/ada/gnatlbr.adb 2002-05-04 03:28:12.000000000 +0000 --- gcc-3.3/gcc/ada/gnatlbr.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1997-2000 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2001 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- -- *************** *** 46,59 **** with Ada.Command_Line; use Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; with GNAT.OS_Lib; use GNAT.OS_Lib; - with Gnatvsn; use Gnatvsn; with Interfaces.C_Streams; use Interfaces.C_Streams; with Osint; use Osint; with Sdefault; use Sdefault; with System; procedure GnatLbr is - pragma Ident (Gnat_Version_String); type Lib_Mode is (None, Create, Set, Delete); Next_Arg : Integer; --- 45,56 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatlink.adb gcc-3.3/gcc/ada/gnatlink.adb *** gcc-3.2.3/gcc/ada/gnatlink.adb 2002-05-04 03:28:12.000000000 +0000 --- gcc-3.3/gcc/ada/gnatlink.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1996-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1996-2002 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- -- *************** *** 28,39 **** --- 27,43 ---- -- Gnatlink usage: please consult the gnat documentation + with Ada.Exceptions; use Ada.Exceptions; + with ALI; use ALI; with Gnatvsn; use Gnatvsn; with Hostparm; + with Namet; use Namet; with Osint; use Osint; with Output; use Output; + with Switch; use Switch; with System; use System; with Table; + with Types; with Ada.Command_Line; use Ada.Command_Line; with GNAT.OS_Lib; use GNAT.OS_Lib; *************** with Interfaces.C_Streams; use Interface *** 41,48 **** procedure Gnatlink is - pragma Ident (Gnat_Version_String); - package Gcc_Linker_Options is new Table.Table ( Table_Component_Type => String_Access, Table_Index_Type => Integer, --- 45,50 ---- *************** procedure Gnatlink is *** 97,102 **** --- 99,114 ---- -- file. Only application objects are collected there (see details in -- Linker_Objects table comments) + package Binder_Options_From_ALI is new Table.Table ( + Table_Component_Type => String_Access, + Table_Index_Type => Integer, + Table_Low_Bound => 1, -- equals low bound of Argument_List for Spawn + Table_Initial => 20, + Table_Increment => 100, + Table_Name => "Gnatlink.Binder_Options_From_ALI"); + -- This table collects the switches from the ALI file of the main + -- subprogram. + package Binder_Options is new Table.Table ( Table_Component_Type => String_Access, Table_Index_Type => Integer, *************** procedure Gnatlink is *** 139,144 **** --- 151,158 ---- Ada_Bind_File : Boolean := True; -- Set to True if bind file is generated in Ada + Standard_Gcc : Boolean := True; + Compile_Bind_File : Boolean := True; -- Set to False if bind file is not to be compiled *************** procedure Gnatlink is *** 250,279 **** Next_Arg : Integer; begin - Binder_Options.Increment_Last; - Binder_Options.Table (Binder_Options.Last) := new String'("-c"); - - -- If the main program is in Ada it is compiled with the following - -- switches: - - -- -gnatA stops reading gnat.adc, since we don't know what - -- pagmas would work, and we do not need it anyway. - - -- -gnatWb allows brackets coding for wide characters - - -- -gnatiw allows wide characters in identifiers. This is needed - -- because bindgen uses brackets encoding for all upper - -- half and wide characters in identifier names. - - if Ada_Bind_File then - Binder_Options.Increment_Last; - Binder_Options.Table (Binder_Options.Last) := new String'("-gnatA"); - Binder_Options.Increment_Last; - Binder_Options.Table (Binder_Options.Last) := new String'("-gnatWb"); - Binder_Options.Increment_Last; - Binder_Options.Table (Binder_Options.Last) := new String'("-gnatiw"); - end if; - -- Loop through arguments of gnatlink command Next_Arg := 1; --- 264,269 ---- *************** procedure Gnatlink is *** 288,296 **** -- We definitely need section by section comments here ??? ! if Arg'Length /= 0 ! and then (Arg (1) = Switch_Character or else Arg (1) = '-') ! then if Arg'Length > 4 and then Arg (2 .. 5) = "gnat" then --- 278,284 ---- -- We definitely need section by section comments here ??? ! if Arg'Length /= 0 and then Arg (1) = '-' then if Arg'Length > 4 and then Arg (2 .. 5) = "gnat" then *************** procedure Gnatlink is *** 440,445 **** --- 428,434 ---- begin Gcc := new String'(Program_Args.all (1).all); + Standard_Gcc := False; -- Set appropriate flags for switches passed *************** procedure Gnatlink is *** 449,458 **** AF : Integer := Arg'First; begin ! if Arg'Length /= 0 ! and then (Arg (AF) = Switch_Character ! or else Arg (AF) = '-') ! then if Arg (AF + 1) = 'g' and then (Arg'Length = 2 or else Arg (AF + 2) in '0' .. '3' --- 438,444 ---- AF : Integer := Arg'First; begin ! if Arg'Length /= 0 and then Arg (AF) = '-' then if Arg (AF + 1) = 'g' and then (Arg'Length = 2 or else Arg (AF + 2) in '0' .. '3' *************** procedure Gnatlink is *** 765,895 **** if Next_Line (Nfirst .. Nlast) /= End_Info then loop ! -- Add binder options only if not already set on the command ! -- line. This rule is a way to control the linker options order. ! ! if not Is_Option_Present ! (Next_Line (Nfirst .. Nlast)) ! then ! if Next_Line (Nfirst .. Nlast) = "-static" then ! GNAT_Static := True; ! ! elsif Next_Line (Nfirst .. Nlast) = "-shared" then ! GNAT_Shared := True; ! else ! if Nlast > Nfirst + 2 and then ! Next_Line (Nfirst .. Nfirst + 1) = "-L" ! then ! -- Construct a library search path for use later ! -- to locate static gnatlib libraries. ! if Libpath.Last > 1 then ! Libpath.Increment_Last; ! Libpath.Table (Libpath.Last) := Path_Separator; ! end if; ! for I in Nfirst + 2 .. Nlast loop ! Libpath.Increment_Last; ! Libpath.Table (Libpath.Last) := Next_Line (I); ! end loop; ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) := ! new String'(Next_Line (Nfirst .. Nlast)); ! elsif Next_Line (Nfirst .. Nlast) = "-ldecgnat" ! or else Next_Line (Nfirst .. Nlast) = "-lgnarl" ! or else Next_Line (Nfirst .. Nlast) = "-lgnat" ! then ! -- Given a Gnat standard library, search the ! -- library path to find the library location ! declare ! File_Path : String_Access; ! Object_Lib_Extension : constant String := ! Value ! (Object_Library_Ext_Ptr); ! File_Name : String := ! "lib" & ! Next_Line (Nfirst + 2 .. Nlast) & ! Object_Lib_Extension; ! begin ! File_Path := ! Locate_Regular_File ! (File_Name, ! String (Libpath.Table (1 .. Libpath.Last))); ! if File_Path /= null then ! if GNAT_Static then ! -- If static gnatlib found, explicitly ! -- specify to overcome possible linker ! -- default usage of shared version. ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) := ! new String'(File_Path.all); ! elsif GNAT_Shared then ! -- If shared gnatlib desired, add the ! -- appropriate system specific switch ! -- so that it can be located at runtime. ! declare ! Run_Path_Opt : constant String := ! Value ! (Run_Path_Option_Ptr); ! begin ! if Run_Path_Opt'Length /= 0 then ! -- Output the system specific linker ! -- command that allows the image ! -- activator to find the shared library ! -- at runtime. ! Linker_Options.Increment_Last; ! Linker_Options.Table ! (Linker_Options.Last) := ! new String'(Run_Path_Opt ! & File_Path ! (1 .. File_Path'Length ! - File_Name'Length)); ! end if; Linker_Options.Increment_Last; ! Linker_Options.Table ! (Linker_Options.Last) := ! new String'(Next_Line ! (Nfirst .. Nlast)); ! ! end; ! end if; ! else ! -- If gnatlib library not found, then ! -- add it anyway in case some other ! -- mechanimsm may find it. ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) := ! new String'(Next_Line (Nfirst .. Nlast)); ! end if; ! end; ! else ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) := ! new String'(Next_Line (Nfirst .. Nlast)); ! end if; end if; end if; --- 751,866 ---- if Next_Line (Nfirst .. Nlast) /= End_Info then loop ! if Next_Line (Nfirst .. Nlast) = "-static" then ! GNAT_Static := True; ! elsif Next_Line (Nfirst .. Nlast) = "-shared" then ! GNAT_Shared := True; ! -- Add binder options only if not already set on the command ! -- line. This rule is a way to control the linker options order. ! elsif not Is_Option_Present (Next_Line (Nfirst .. Nlast)) then ! if Nlast > Nfirst + 2 and then ! Next_Line (Nfirst .. Nfirst + 1) = "-L" ! then ! -- Construct a library search path for use later ! -- to locate static gnatlib libraries. ! if Libpath.Last > 1 then ! Libpath.Increment_Last; ! Libpath.Table (Libpath.Last) := Path_Separator; ! end if; ! for I in Nfirst + 2 .. Nlast loop ! Libpath.Increment_Last; ! Libpath.Table (Libpath.Last) := Next_Line (I); ! end loop; ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) := ! new String'(Next_Line (Nfirst .. Nlast)); ! elsif Next_Line (Nfirst .. Nlast) = "-ldecgnat" ! or else Next_Line (Nfirst .. Nlast) = "-lgnarl" ! or else Next_Line (Nfirst .. Nlast) = "-lgnat" ! then ! -- Given a Gnat standard library, search the ! -- library path to find the library location ! declare ! File_Path : String_Access; ! Object_Lib_Extension : constant String := ! Value (Object_Library_Ext_Ptr); ! File_Name : String := "lib" & ! Next_Line (Nfirst + 2 .. Nlast) & Object_Lib_Extension; ! begin ! File_Path := ! Locate_Regular_File (File_Name, ! String (Libpath.Table (1 .. Libpath.Last))); ! if File_Path /= null then ! if GNAT_Static then ! -- If static gnatlib found, explicitly ! -- specify to overcome possible linker ! -- default usage of shared version. ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) := ! new String'(File_Path.all); ! elsif GNAT_Shared then ! -- If shared gnatlib desired, add the ! -- appropriate system specific switch ! -- so that it can be located at runtime. ! declare ! Run_Path_Opt : constant String := ! Value (Run_Path_Option_Ptr); ! begin ! if Run_Path_Opt'Length /= 0 then ! -- Output the system specific linker ! -- command that allows the image ! -- activator to find the shared library ! -- at runtime. Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) ! := new String'(Run_Path_Opt ! & File_Path ! (1 .. File_Path'Length ! - File_Name'Length)); ! end if; ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) ! := new String'(Next_Line (Nfirst .. Nlast)); ! end; ! end if; ! else ! -- If gnatlib library not found, then ! -- add it anyway in case some other ! -- mechanimsm may find it. ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) ! := new String'(Next_Line (Nfirst .. Nlast)); ! end if; ! end; ! else ! Linker_Options.Increment_Last; ! Linker_Options.Table (Linker_Options.Last) ! := new String'(Next_Line (Nfirst .. Nlast)); end if; end if; *************** procedure Gnatlink is *** 897,904 **** exit when Next_Line (Nfirst .. Nlast) = End_Info; if Ada_Bind_File then ! Next_Line (Nfirst .. Nlast - 8) := ! Next_Line (Nfirst + 8 .. Nlast); Nlast := Nlast - 8; end if; end loop; --- 868,875 ---- exit when Next_Line (Nfirst .. Nlast) = End_Info; if Ada_Bind_File then ! Next_Line (Nfirst .. Nlast - 8) ! := Next_Line (Nfirst + 8 .. Nlast); Nlast := Nlast - 8; end if; end loop; *************** procedure Gnatlink is *** 966,972 **** -- Start of processing for Gnatlink begin - if Argument_Count = 0 then Write_Usage; Exit_Program (E_Fatal); --- 937,942 ---- *************** begin *** 981,986 **** --- 951,986 ---- Process_Args; + -- We always compile with -c + + Binder_Options_From_ALI.Increment_Last; + Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) := + new String'("-c"); + + -- If the main program is in Ada it is compiled with the following + -- switches: + + -- -gnatA stops reading gnat.adc, since we don't know what + -- pagmas would work, and we do not need it anyway. + + -- -gnatWb allows brackets coding for wide characters + + -- -gnatiw allows wide characters in identifiers. This is needed + -- because bindgen uses brackets encoding for all upper + -- half and wide characters in identifier names. + + if Ada_Bind_File then + Binder_Options_From_ALI.Increment_Last; + Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) := + new String'("-gnatA"); + Binder_Options_From_ALI.Increment_Last; + Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) := + new String'("-gnatWb"); + Binder_Options_From_ALI.Increment_Last; + Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) := + new String'("-gnatiw"); + end if; + -- Locate all the necessary programs and verify required files are present Gcc_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Gcc.all); *************** begin *** 999,1011 **** if not Is_Regular_File (Ali_File_Name.all) then Exit_With_Error (Ali_File_Name.all & " not found."); end if; if Verbose_Mode then Write_Eol; Write_Str ("GNATLINK "); Write_Str (Gnat_Version_String); ! Write_Str (" Copyright 1996-2001 Free Software Foundation, Inc."); Write_Eol; end if; --- 999,1059 ---- if not Is_Regular_File (Ali_File_Name.all) then Exit_With_Error (Ali_File_Name.all & " not found."); + + -- Read the ALI file of the main subprogram if the binder generated + -- file is in Ada, it need to be compiled and no --GCC= switch has + -- been specified. Fetch the back end switches from this ALI file and use + -- these switches to compile the binder generated file + + elsif Ada_Bind_File + and then Compile_Bind_File + and then Standard_Gcc + then + -- Do some initializations + + Initialize_ALI; + Namet.Initialize; + Name_Len := Ali_File_Name'Length; + Name_Buffer (1 .. Name_Len) := Ali_File_Name.all; + + declare + use Types; + F : constant File_Name_Type := Name_Find; + T : Text_Buffer_Ptr; + A : ALI_Id; + + begin + -- Osint.Add_Default_Search_Dirs; + -- Load the ALI file + + T := Read_Library_Info (F, True); + + -- Read it + + A := Scan_ALI (F, T, False, False, False); + + if A /= No_ALI_Id then + for + Index in Units.Table (ALIs.Table (A).First_Unit).First_Arg + .. Units.Table (ALIs.Table (A).First_Unit).Last_Arg + loop + -- Do not compile with the front end switches + + if not Is_Front_End_Switch (Args.Table (Index).all) then + Binder_Options_From_ALI.Increment_Last; + Binder_Options_From_ALI.Table (Binder_Options_From_ALI.Last) + := String_Access (Args.Table (Index)); + end if; + end loop; + end if; + end; end if; if Verbose_Mode then Write_Eol; Write_Str ("GNATLINK "); Write_Str (Gnat_Version_String); ! Write_Str (" Copyright 1996-2002 Free Software Foundation, Inc."); Write_Eol; end if; *************** begin *** 1129,1139 **** if Compile_Bind_File then Bind_Step : declare Success : Boolean; ! Args : Argument_List (1 .. Binder_Options.Last + 1); begin ! for J in Binder_Options.First .. Binder_Options.Last loop ! Args (J) := Binder_Options.Table (J); end loop; Args (Args'Last) := Binder_Body_Src_File; --- 1177,1193 ---- if Compile_Bind_File then Bind_Step : declare Success : Boolean; ! Args : Argument_List ! (1 .. Binder_Options_From_ALI.Last + Binder_Options.Last + 1); begin ! for J in 1 .. Binder_Options_From_ALI.Last loop ! Args (J) := Binder_Options_From_ALI.Table (J); ! end loop; ! ! for J in 1 .. Binder_Options.Last loop ! Args (Binder_Options_From_ALI.Last + J) := ! Binder_Options.Table (J); end loop; Args (Args'Last) := Binder_Body_Src_File; *************** begin *** 1346,1351 **** Exit_Program (E_Success); exception ! when others => Exit_With_Error ("INTERNAL ERROR. Please report."); end Gnatlink; --- 1400,1406 ---- Exit_Program (E_Success); exception ! when X : others => ! Write_Line (Exception_Information (X)); Exit_With_Error ("INTERNAL ERROR. Please report."); end Gnatlink; diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatlink.ads gcc-3.3/gcc/ada/gnatlink.ads *** gcc-3.2.3/gcc/ada/gnatlink.ads 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/gnatlink.ads 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatls.adb gcc-3.3/gcc/ada/gnatls.adb *** gcc-3.2.3/gcc/ada/gnatls.adb 2002-05-04 03:28:12.000000000 +0000 --- gcc-3.3/gcc/ada/gnatls.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with ALI; use ALI; *** 30,54 **** with ALI.Util; use ALI.Util; with Binderr; use Binderr; with Butil; use Butil; - with Csets; with Fname; use Fname; with Gnatvsn; use Gnatvsn; with GNAT.OS_Lib; use GNAT.OS_Lib; with Namet; use Namet; with Opt; use Opt; with Osint; use Osint; with Output; use Output; ! with Prj; use Prj; ! with Prj.Pars; use Prj.Pars; ! with Prj.Env; ! with Prj.Ext; use Prj.Ext; ! with Prj.Util; use Prj.Util; ! with Snames; use Snames; ! with Stringt; use Stringt; with Types; use Types; procedure Gnatls is - pragma Ident (Gnat_Version_String); Max_Column : constant := 80; --- 29,46 ---- with ALI.Util; use ALI.Util; with Binderr; use Binderr; with Butil; use Butil; with Fname; use Fname; with Gnatvsn; use Gnatvsn; with GNAT.OS_Lib; use GNAT.OS_Lib; with Namet; use Namet; with Opt; use Opt; with Osint; use Osint; + with Osint.L; use Osint.L; with Output; use Output; ! with Targparm; use Targparm; with Types; use Types; procedure Gnatls is Max_Column : constant := 80; *************** procedure Gnatls is *** 66,71 **** --- 58,64 ---- Value : String_Access; Next : Dir_Ref; end record; + -- ??? comment needed First_Source_Dir : Dir_Ref; Last_Source_Dir : Dir_Ref; *************** procedure Gnatls is *** 91,100 **** -- When True, lines are too long for multi-column output and each -- item of information is on a different line. - Project_File : String_Access; - Project : Prj.Project_Id; - Current_Verbosity : Prj.Verbosity := Prj.Default; - Selective_Output : Boolean := False; Print_Usage : Boolean := False; Print_Unit : Boolean := True; --- 84,89 ---- *************** procedure Gnatls is *** 144,153 **** function Corresponding_Sdep_Entry (A : ALI_Id; U : Unit_Id) return Sdep_Id; -- Give the Sdep entry corresponding to the unit U in ali record A. - function Index (Char : Character; Str : String) return Natural; - -- Returns the first occurrence of Char in Str. - -- Returns 0 if Char is not in Str. - procedure Output_Object (O : File_Name_Type); -- Print out the name of the object when requested --- 133,138 ---- *************** procedure Gnatls is *** 246,255 **** Write_Eol; Error_Msg ("wrong ALI format, can't find dependency line for & in %"); Exit_Program (E_Fatal); - - -- Not needed since we exit the program but avoids compiler warning - - raise Program_Error; end Corresponding_Sdep_Entry; ------------------------- --- 231,236 ---- *************** procedure Gnatls is *** 319,328 **** end if; Source_Start := Unit_End + 1; if Source_Start > Spaces'Last then Source_Start := Spaces'Last; end if; ! Source_End := Source_Start - 1; if Print_Source then Source_End := Source_Start + Max_Src_Length; --- 300,311 ---- end if; Source_Start := Unit_End + 1; + if Source_Start > Spaces'Last then Source_Start := Spaces'Last; end if; ! ! Source_End := Source_Start - 1; if Print_Source then Source_End := Source_Start + Max_Src_Length; *************** procedure Gnatls is *** 370,401 **** end if; end Find_Status; - ----------- - -- Index -- - ----------- - - function Index (Char : Character; Str : String) return Natural is - begin - for Index in Str'Range loop - if Str (Index) = Char then - return Index; - end if; - end loop; - - return 0; - end Index; - ------------------- -- Output_Object -- ------------------- procedure Output_Object (O : File_Name_Type) is Object_Name : String_Access; begin if Print_Object then Get_Name_String (O); Object_Name := To_Host_File_Spec (Name_Buffer (1 .. Name_Len)); Write_Str (Object_Name.all); if Print_Source or else Print_Unit then if Too_Long then Write_Eol; --- 353,371 ---- end if; end Find_Status; ------------------- -- Output_Object -- ------------------- procedure Output_Object (O : File_Name_Type) is Object_Name : String_Access; + begin if Print_Object then Get_Name_String (O); Object_Name := To_Host_File_Spec (Name_Buffer (1 .. Name_Len)); Write_Str (Object_Name.all); + if Print_Source or else Print_Unit then if Too_Long then Write_Eol; *************** procedure Gnatls is *** 611,714 **** return; end if; ! if Argv (1) = Switch_Character or else Argv (1) = '-' then if Argv'Length = 1 then Fail ("switch character cannot be followed by a blank"); ! -- -I- elsif Argv (2 .. Argv'Last) = "I-" then Opt.Look_In_Primary_Dir := False; ! -- Forbid -?- or -??- where ? is any character elsif (Argv'Length = 3 and then Argv (3) = '-') or else (Argv'Length = 4 and then Argv (4) = '-') then Fail ("Trailing ""-"" at the end of ", Argv, " forbidden."); ! -- -Idir elsif Argv (2) = 'I' then Add_Source_Dir (Argv (3 .. Argv'Last), And_Save); Add_Lib_Dir (Argv (3 .. Argv'Last), And_Save); ! -- -aIdir (to gcc this is like a -I switch) elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aI" then Add_Source_Dir (Argv (4 .. Argv'Last), And_Save); ! -- -aOdir elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aO" then Add_Lib_Dir (Argv (4 .. Argv'Last), And_Save); ! -- -aLdir (to gnatbind this is like a -aO switch) elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aL" then Add_Lib_Dir (Argv (4 .. Argv'Last), And_Save); ! -- -vPx ! ! elsif Argv'Length = 4 and then Argv (2 .. 3) = "vP" then ! case Argv (4) is ! when '0' => ! Current_Verbosity := Prj.Default; ! when '1' => ! Current_Verbosity := Prj.Medium; ! when '2' => ! Current_Verbosity := Prj.High; ! when others => ! null; ! end case; ! ! -- -Pproject_file ! ! elsif Argv'Length >= 3 and then Argv (2) = 'P' then ! if Project_File /= null then ! Fail (Argv & ": second project file forbidden (first is """ & ! Project_File.all & """)"); ! else ! Project_File := new String'(Argv (3 .. Argv'Last)); ! end if; ! ! -- -Xexternal=value ! ! elsif Argv'Length >= 5 and then Argv (2) = 'X' then ! declare ! Equal_Pos : constant Natural := ! Index ('=', Argv (3 .. Argv'Last)); ! begin ! if Equal_Pos >= 4 and then ! Equal_Pos /= Argv'Last then ! Add (External_Name => Argv (3 .. Equal_Pos - 1), ! Value => Argv (Equal_Pos + 1 .. Argv'Last)); ! else ! Fail (Argv & " is not a valid external assignment."); ! end if; ! end; elsif Argv (2 .. Argv'Last) = "nostdinc" then Opt.No_Stdinc := True; elsif Argv'Length = 2 then case Argv (2) is ! when 'a' => Also_Predef := True; ! when 'h' => Print_Usage := True; when 'u' => Reset_Print; Print_Unit := True; when 's' => Reset_Print; Print_Source := True; when 'o' => Reset_Print; Print_Object := True; ! when 'v' => Verbose_Mode := True; ! when 'd' => Dependable := True; when others => null; end case; end if; ! -- If not a switch it must be a file name else ! Set_Main_File_Name (Argv); end if; end Scan_Ls_Arg; --- 581,699 ---- return; end if; ! if Argv (1) = '-' then if Argv'Length = 1 then Fail ("switch character cannot be followed by a blank"); ! -- Processing for -I- elsif Argv (2 .. Argv'Last) = "I-" then Opt.Look_In_Primary_Dir := False; ! -- Forbid -?- or -??- where ? is any character elsif (Argv'Length = 3 and then Argv (3) = '-') or else (Argv'Length = 4 and then Argv (4) = '-') then Fail ("Trailing ""-"" at the end of ", Argv, " forbidden."); ! -- Processing for -Idir elsif Argv (2) = 'I' then Add_Source_Dir (Argv (3 .. Argv'Last), And_Save); Add_Lib_Dir (Argv (3 .. Argv'Last), And_Save); ! -- Processing for -aIdir (to gcc this is like a -I switch) elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aI" then Add_Source_Dir (Argv (4 .. Argv'Last), And_Save); ! -- Processing for -aOdir elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aO" then Add_Lib_Dir (Argv (4 .. Argv'Last), And_Save); ! -- Processing for -aLdir (to gnatbind this is like a -aO switch) elsif Argv'Length >= 3 and then Argv (2 .. 3) = "aL" then Add_Lib_Dir (Argv (4 .. Argv'Last), And_Save); ! -- Processing for -nostdinc elsif Argv (2 .. Argv'Last) = "nostdinc" then Opt.No_Stdinc := True; + -- Processing for one character switches + elsif Argv'Length = 2 then case Argv (2) is ! when 'a' => Also_Predef := True; ! when 'h' => Print_Usage := True; when 'u' => Reset_Print; Print_Unit := True; when 's' => Reset_Print; Print_Source := True; when 'o' => Reset_Print; Print_Object := True; ! when 'v' => Verbose_Mode := True; ! when 'd' => Dependable := True; ! when others => null; end case; + + -- Processing for --RTS=path + + elsif Argv (1 .. 5) = "--RTS" then + + if Argv (6) /= '=' or else + (Argv (6) = '=' + and then Argv'Length = 6) + then + Osint.Fail ("missing path for --RTS"); + + else + -- Valid --RTS switch + + Opt.No_Stdinc := True; + Opt.RTS_Switch := True; + + declare + Src_Path_Name : String_Ptr := + String_Ptr + (Get_RTS_Search_Dir + (Argv (7 .. Argv'Last), Include)); + Lib_Path_Name : String_Ptr := + String_Ptr + (Get_RTS_Search_Dir + (Argv (7 .. Argv'Last), Objects)); + + begin + if Src_Path_Name /= null + and then Lib_Path_Name /= null + then + Add_Search_Dirs (Src_Path_Name, Include); + Add_Search_Dirs (Lib_Path_Name, Objects); + + elsif Src_Path_Name = null + and then Lib_Path_Name = null + then + Osint.Fail ("RTS path not valid: missing " & + "adainclude and adalib directories"); + + elsif Src_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude directory"); + + elsif Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adalib directory"); + end if; + end; + end if; end if; ! -- If not a switch, it must be a file name else ! Add_File (Argv); end if; end Scan_Ls_Arg; *************** procedure Gnatls is *** 717,730 **** ----------- procedure Usage is - procedure Write_Switch_Char; - -- Write two spaces followed by appropriate switch character - - procedure Write_Switch_Char is - begin - Write_Str (" "); - Write_Char (Switch_Character); - end Write_Switch_Char; -- Start of processing for Usage --- 702,707 ---- *************** procedure Gnatls is *** 744,838 **** -- Line for -a ! Write_Switch_Char; ! Write_Str ("a also output relevant predefined units"); Write_Eol; -- Line for -u ! Write_Switch_Char; ! Write_Str ("u output only relevant unit names"); Write_Eol; -- Line for -h ! Write_Switch_Char; ! Write_Str ("h output this help message"); Write_Eol; -- Line for -s ! Write_Switch_Char; ! Write_Str ("s output only relevant source names"); Write_Eol; -- Line for -o ! Write_Switch_Char; ! Write_Str ("o output only relevant object names"); Write_Eol; -- Line for -d ! Write_Switch_Char; ! Write_Str ("d output sources on which specified units depend"); Write_Eol; -- Line for -v ! Write_Switch_Char; ! Write_Str ("v verbose output, full path and unit information"); Write_Eol; Write_Eol; -- Line for -aI switch ! Write_Switch_Char; ! Write_Str ("aIdir specify source files search path"); Write_Eol; -- Line for -aO switch ! Write_Switch_Char; ! Write_Str ("aOdir specify object files search path"); Write_Eol; -- Line for -I switch ! Write_Switch_Char; ! Write_Str ("Idir like -aIdir -aOdir"); Write_Eol; -- Line for -I- switch ! Write_Switch_Char; ! Write_Str ("I- do not look for sources & object files"); Write_Str (" in the default directory"); Write_Eol; ! -- Line for -vPx ! ! Write_Switch_Char; ! Write_Str ("vPx verbosity for project file (0, 1 or 2)"); ! Write_Eol; ! ! -- Line for -Pproject_file ! ! Write_Switch_Char; ! Write_Str ("Pprj use a project file prj"); ! Write_Eol; ! ! -- Line for -Xexternal=value ! Write_Switch_Char; ! Write_Str ("Xext=val specify an external value."); Write_Eol; ! -- Line for -nostdinc ! Write_Switch_Char; ! Write_Str ("nostdinc do not look for source files"); ! Write_Str (" in the system default directory"); Write_Eol; -- File Status explanation --- 721,791 ---- -- Line for -a ! Write_Str (" -a also output relevant predefined units"); Write_Eol; -- Line for -u ! Write_Str (" -u output only relevant unit names"); Write_Eol; -- Line for -h ! Write_Str (" -h output this help message"); Write_Eol; -- Line for -s ! Write_Str (" -s output only relevant source names"); Write_Eol; -- Line for -o ! Write_Str (" -o output only relevant object names"); Write_Eol; -- Line for -d ! Write_Str (" -d output sources on which specified units depend"); Write_Eol; -- Line for -v ! Write_Str (" -v verbose output, full path and unit information"); Write_Eol; Write_Eol; -- Line for -aI switch ! Write_Str (" -aIdir specify source files search path"); Write_Eol; -- Line for -aO switch ! Write_Str (" -aOdir specify object files search path"); Write_Eol; -- Line for -I switch ! Write_Str (" -Idir like -aIdir -aOdir"); Write_Eol; -- Line for -I- switch ! Write_Str (" -I- do not look for sources & object files"); Write_Str (" in the default directory"); Write_Eol; ! -- Line for -nostdinc ! Write_Str (" -nostdinc do not look for source files"); ! Write_Str (" in the system default directory"); Write_Eol; ! -- Line for --RTS ! Write_Str (" --RTS=dir specify the default source and object search" ! & " path"); Write_Eol; -- File Status explanation *************** procedure Gnatls is *** 854,867 **** -- Start of processing for Gnatls begin - Osint.Initialize (Binder); - - Namet.Initialize; - Csets.Initialize; - - Snames.Initialize; - - Prj.Initialize; -- Use low level argument routines to avoid dragging in the secondary stack --- 807,812 ---- *************** begin *** 879,966 **** Next_Arg := Next_Arg + 1; end loop Scan_Args; - -- If a switch -P is used, parse the project file - - if Project_File /= null then - - Prj.Pars.Set_Verbosity (To => Current_Verbosity); - - Prj.Pars.Parse - (Project => Project, - Project_File_Name => Project_File.all); - - if Project = Prj.No_Project then - Fail ("""" & Project_File.all & """ processing failed"); - end if; - - -- Add the source directories and the object directories - -- to the searched directories. - - declare - procedure Register_Source_Dirs is new - Prj.Env.For_All_Source_Dirs (Add_Src_Search_Dir); - - procedure Register_Object_Dirs is new - Prj.Env.For_All_Object_Dirs (Add_Lib_Search_Dir); - - begin - Register_Source_Dirs (Project); - Register_Object_Dirs (Project); - end; - - -- Check if a package gnatls is in the project file and if there is - -- there is one, get the switches, if any, and scan them. - - declare - Data : Prj.Project_Data := Prj.Projects.Table (Project); - Pkg : Prj.Package_Id := - Prj.Util.Value_Of - (Name => Name_Gnatls, - In_Packages => Data.Decl.Packages); - Element : Package_Element; - Switches : Prj.Variable_Value; - Current : Prj.String_List_Id; - The_String : String_Element; - - begin - if Pkg /= No_Package then - Element := Packages.Table (Pkg); - Switches := - Prj.Util.Value_Of - (Variable_Name => Name_Switches, - In_Variables => Element.Decl.Attributes); - - case Switches.Kind is - when Prj.Undefined => - null; - - when Prj.Single => - if String_Length (Switches.Value) > 0 then - String_To_Name_Buffer (Switches.Value); - Scan_Ls_Arg - (Name_Buffer (1 .. Name_Len), - And_Save => False); - end if; - - when Prj.List => - Current := Switches.Values; - while Current /= Prj.Nil_String loop - The_String := String_Elements.Table (Current); - - if String_Length (The_String.Value) > 0 then - String_To_Name_Buffer (The_String.Value); - Scan_Ls_Arg - (Name_Buffer (1 .. Name_Len), - And_Save => False); - end if; - - Current := The_String.Next; - end loop; - end case; - end if; - end; - end if; - -- Add the source and object directories specified on the -- command line, if any, to the searched directories. --- 824,829 ---- *************** begin *** 974,984 **** First_Lib_Dir := First_Lib_Dir.Next; end loop; ! -- Finally, add the default directories. Osint.Add_Default_Search_Dirs; if Verbose_Mode then -- WARNING: the output of gnatls -v is used during the compilation -- and installation of GLADE to recreate sdefault.adb and locate --- 837,849 ---- First_Lib_Dir := First_Lib_Dir.Next; end loop; ! -- Finally, add the default directories and obtain target parameters Osint.Add_Default_Search_Dirs; if Verbose_Mode then + Namet.Initialize; + Targparm.Get_Target_Parameters; -- WARNING: the output of gnatls -v is used during the compilation -- and installation of GLADE to recreate sdefault.adb and locate *************** begin *** 987,994 **** Write_Eol; Write_Str ("GNATLS "); Write_Str (Gnat_Version_String); ! Write_Str (" Copyright 1997-2001 Free Software Foundation, Inc."); Write_Eol; Write_Eol; Write_Str ("Source Search Path:"); --- 852,864 ---- Write_Eol; Write_Str ("GNATLS "); + + if Targparm.High_Integrity_Mode_On_Target then + Write_Str ("Pro High Integrity "); + end if; + Write_Str (Gnat_Version_String); ! Write_Str (" Copyright 1997-2002 Free Software Foundation, Inc."); Write_Eol; Write_Eol; Write_Str ("Source Search Path:"); *************** begin *** 1042,1047 **** --- 912,918 ---- Exit_Program (E_Fatal); end if; + Namet.Initialize; Initialize_ALI; Initialize_ALI_Source; *************** begin *** 1131,1140 **** --- 1002,1013 ---- if Verbose_Mode then Write_Str (" "); Output_Source (D); + elsif Too_Long then Write_Str (" "); Output_Source (D); Write_Eol; + else Write_Str (Spaces (1 .. Source_Start - 2)); Output_Source (D); diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatls.ads gcc-3.3/gcc/ada/gnatls.ads *** gcc-3.2.3/gcc/ada/gnatls.ads 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/gnatls.ads 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatmain.adb gcc-3.3/gcc/ada/gnatmain.adb *** gcc-3.2.3/gcc/ada/gnatmain.adb 2002-05-04 03:28:12.000000000 +0000 --- gcc-3.3/gcc/ada/gnatmain.adb 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,594 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- G N A T M A I N -- - -- -- - -- B o d y -- - -- -- - -- $Revision: 1.2.12.1 $ - -- -- - -- Copyright (C) 1992-2001 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - with Csets; - with GNAT.Case_Util; - with GNAT.OS_Lib; use GNAT.OS_Lib; - with Namet; use Namet; - with Opt; - with Osint; use Osint; - with Output; use Output; - with Prj; use Prj; - with Prj.Env; - with Prj.Ext; use Prj.Ext; - with Prj.Pars; - with Prj.Util; use Prj.Util; - with Snames; use Snames; - with Stringt; use Stringt; - with Table; - with Types; use Types; - - procedure Gnatmain is - - Ada_Include_Path : constant String := "ADA_INCLUDE_PATH"; - Ada_Objects_Path : constant String := "ADA_OBJECTS_PATH"; - - type Tool_Type is (None, List, Xref, Find, Stub, Make, Comp, Bind, Link); - - -- The tool that is going to be called - - Tool : Tool_Type := None; - - -- For each tool, Tool_Package_Names contains the name of the - -- corresponding package in the project file. - - Tool_Package_Names : constant array (Tool_Type) of Name_Id := - (None => No_Name, - List => Name_Gnatls, - Xref => Name_Cross_Reference, - Find => Name_Finder, - Stub => Name_Gnatstub, - Comp => No_Name, - Make => No_Name, - Bind => No_Name, - Link => No_Name); - - -- For each tool, Tool_Names contains the name of the executable - -- to be spawned. - - Gnatmake : constant String_Access := new String'("gnatmake"); - - Tool_Names : constant array (Tool_Type) of String_Access := - (None => null, - List => new String'("gnatls"), - Xref => new String'("gnatxref"), - Find => new String'("gnatfind"), - Stub => new String'("gnatstub"), - Comp => Gnatmake, - Make => Gnatmake, - Bind => Gnatmake, - Link => Gnatmake); - - Project_File : String_Access; - Project : Prj.Project_Id; - Current_Verbosity : Prj.Verbosity := Prj.Default; - - -- This flag indicates a switch -p (for gnatxref and gnatfind) for - -- an old fashioned project file. -p cannot be used in conjonction - -- with -P. - - Old_Project_File_Used : Boolean := False; - - Next_Arg : Positive; - - -- A table to keep the switches on the command line - - package Saved_Switches is new Table.Table ( - Table_Component_Type => String_Access, - Table_Index_Type => Integer, - Table_Low_Bound => 1, - Table_Initial => 20, - Table_Increment => 100, - Table_Name => "Gnatmain.Saved_Switches"); - - -- A table to keep the switches from the project file - - package Switches is new Table.Table ( - Table_Component_Type => String_Access, - Table_Index_Type => Integer, - Table_Low_Bound => 1, - Table_Initial => 20, - Table_Increment => 100, - Table_Name => "Gnatmain.Switches"); - - procedure Add_Switch (Argv : String; And_Save : Boolean); - -- Add a switch in one of the tables above - - procedure Display (Program : String; Args : Argument_List); - -- Displays Program followed by the arguments in Args - - function Index (Char : Character; Str : String) return Natural; - -- Returns the first occurrence of Char in Str. - -- Returns 0 if Char is not in Str. - - procedure Scan_Arg (Argv : String; And_Save : Boolean); - -- Scan and process arguments. Argv is a single argument. - - procedure Usage; - -- Output usage - - ---------------- - -- Add_Switch -- - ---------------- - - procedure Add_Switch (Argv : String; And_Save : Boolean) is - begin - if And_Save then - Saved_Switches.Increment_Last; - Saved_Switches.Table (Saved_Switches.Last) := new String'(Argv); - - else - Switches.Increment_Last; - Switches.Table (Switches.Last) := new String'(Argv); - end if; - end Add_Switch; - - ------------- - -- Display -- - ------------- - - procedure Display (Program : String; Args : Argument_List) is - begin - if not Opt.Quiet_Output then - Write_Str (Program); - - for J in Args'Range loop - Write_Str (" "); - Write_Str (Args (J).all); - end loop; - - Write_Eol; - end if; - end Display; - - ----------- - -- Index -- - ----------- - - function Index (Char : Character; Str : String) return Natural is - begin - for Index in Str'Range loop - if Str (Index) = Char then - return Index; - end if; - end loop; - - return 0; - end Index; - - -------------- - -- Scan_Arg -- - -------------- - - procedure Scan_Arg (Argv : String; And_Save : Boolean) is - begin - pragma Assert (Argv'First = 1); - - if Argv'Length = 0 then - return; - end if; - - if Argv (1) = Switch_Character or else Argv (1) = '-' then - - if Argv'Length = 1 then - Fail ("switch character cannot be followed by a blank"); - end if; - - -- The two style project files (-p and -P) cannot be used together - - if (Tool = Find or else Tool = Xref) - and then Argv (2) = 'p' - then - Old_Project_File_Used := True; - if Project_File /= null then - Fail ("-P and -p cannot be used together"); - end if; - end if; - - -- -q Be quiet: do not output tool command - - if Argv (2 .. Argv'Last) = "q" then - Opt.Quiet_Output := True; - - -- Only gnatstub and gnatmake have a -q switch - - if Tool = Stub or else Tool_Names (Tool) = Gnatmake then - Add_Switch (Argv, And_Save); - end if; - - -- gnatmake will take care of the project file related switches - - elsif Tool_Names (Tool) = Gnatmake then - Add_Switch (Argv, And_Save); - - -- -vPx Specify verbosity while parsing project files - - elsif Argv'Length = 4 and then Argv (2 .. 3) = "vP" then - case Argv (4) is - when '0' => - Current_Verbosity := Prj.Default; - when '1' => - Current_Verbosity := Prj.Medium; - when '2' => - Current_Verbosity := Prj.High; - when others => - null; - end case; - - -- -Pproject_file Specify project file to be used - - elsif Argv'Length >= 3 and then Argv (2) = 'P' then - - -- Only one -P switch can be used - - if Project_File /= null then - Fail (Argv & ": second project file forbidden (first is """ & - Project_File.all & """)"); - - -- The two style project files (-p and -P) cannot be used together - - elsif Old_Project_File_Used then - Fail ("-p and -P cannot be used together"); - - else - Project_File := new String'(Argv (3 .. Argv'Last)); - end if; - - -- -Xexternal=value Specify an external reference to be used - -- in project files - - elsif Argv'Length >= 5 and then Argv (2) = 'X' then - declare - Equal_Pos : constant Natural := - Index ('=', Argv (3 .. Argv'Last)); - begin - if Equal_Pos >= 4 and then - Equal_Pos /= Argv'Last then - Add (External_Name => Argv (3 .. Equal_Pos - 1), - Value => Argv (Equal_Pos + 1 .. Argv'Last)); - else - Fail (Argv & " is not a valid external assignment."); - end if; - end; - - else - Add_Switch (Argv, And_Save); - end if; - - else - Add_Switch (Argv, And_Save); - end if; - - end Scan_Arg; - - ----------- - -- Usage -- - ----------- - - procedure Usage is - begin - Write_Str ("Usage: "); - Write_Eol; - - Osint.Write_Program_Name; - Write_Str (" list switches [list of object files]"); - Write_Eol; - - Osint.Write_Program_Name; - Write_Str (" xref switches file1 file2 ..."); - Write_Eol; - - Osint.Write_Program_Name; - Write_Str (" find switches pattern[:sourcefile[:line[:column]]] " & - "[file1 file2 ...]"); - Write_Eol; - - Osint.Write_Program_Name; - Write_Str (" stub switches filename [directory]"); - Write_Eol; - - Osint.Write_Program_Name; - Write_Str (" comp switches files"); - Write_Eol; - - Osint.Write_Program_Name; - Write_Str (" make switches [files]"); - Write_Eol; - - Osint.Write_Program_Name; - Write_Str (" bind switches files"); - Write_Eol; - - Osint.Write_Program_Name; - Write_Str (" link switches files"); - Write_Eol; - - Write_Eol; - - Write_Str ("switches interpreted by "); - Osint.Write_Program_Name; - Write_Str (" for List Xref and Find:"); - Write_Eol; - - Write_Str (" -q Be quiet: do not output tool command"); - Write_Eol; - - Write_Str (" -Pproj Use GNAT Project File proj"); - Write_Eol; - - Write_Str (" -vPx Specify verbosity when parsing " & - "GNAT Project Files"); - Write_Eol; - - Write_Str (" -Xnm=val Specify an external reference for " & - "GNAT Project Files"); - Write_Eol; - - Write_Eol; - - Write_Str ("all other arguments are transmited to the tool"); - Write_Eol; - - Write_Eol; - - end Usage; - - begin - - Osint.Initialize (Unspecified); - - Namet.Initialize; - Csets.Initialize; - - Snames.Initialize; - - Prj.Initialize; - - if Arg_Count = 1 then - Usage; - return; - end if; - - -- Get the name of the tool - - declare - Tool_Name : String (1 .. Len_Arg (1)); - - begin - Fill_Arg (Tool_Name'Address, 1); - GNAT.Case_Util.To_Lower (Tool_Name); - - if Tool_Name = "list" then - Tool := List; - - elsif Tool_Name = "xref" then - Tool := Xref; - - elsif Tool_Name = "find" then - Tool := Find; - - elsif Tool_Name = "stub" then - Tool := Stub; - - elsif Tool_Name = "comp" then - Tool := Comp; - - elsif Tool_Name = "make" then - Tool := Make; - - elsif Tool_Name = "bind" then - Tool := Bind; - - elsif Tool_Name = "link" then - Tool := Link; - - else - Fail ("first argument needs to be ""list"", ""xref"", ""find""" & - ", ""stub"", ""comp"", ""make"", ""bind"" or ""link"""); - end if; - end; - - Next_Arg := 2; - - -- Get the command line switches that follow the name of the tool - - Scan_Args : while Next_Arg < Arg_Count loop - declare - Next_Argv : String (1 .. Len_Arg (Next_Arg)); - - begin - Fill_Arg (Next_Argv'Address, Next_Arg); - Scan_Arg (Next_Argv, And_Save => True); - end; - - Next_Arg := Next_Arg + 1; - end loop Scan_Args; - - -- If a switch -P was specified, parse the project file. - -- Project_File is always null if we are going to invoke gnatmake, - -- that is when Tool is Comp, Make, Bind or Link. - - if Project_File /= null then - - Prj.Pars.Set_Verbosity (To => Current_Verbosity); - - Prj.Pars.Parse - (Project => Project, - Project_File_Name => Project_File.all); - - if Project = Prj.No_Project then - Fail ("""" & Project_File.all & """ processing failed"); - end if; - - -- Check if a package with the name of the tool is in the project file - -- and if there is one, get the switches, if any, and scan them. - - declare - Data : Prj.Project_Data := Prj.Projects.Table (Project); - Pkg : Prj.Package_Id := - Prj.Util.Value_Of - (Name => Tool_Package_Names (Tool), - In_Packages => Data.Decl.Packages); - Element : Package_Element; - Default_Switches_Array : Array_Element_Id; - Switches : Prj.Variable_Value; - Current : Prj.String_List_Id; - The_String : String_Element; - - begin - if Pkg /= No_Package then - Element := Packages.Table (Pkg); - - -- Packages Gnatls and Gnatstub have a single attribute Switches, - -- that is not an associative array. - - if Tool = List or else Tool = Stub then - Switches := - Prj.Util.Value_Of - (Variable_Name => Name_Switches, - In_Variables => Element.Decl.Attributes); - - -- Packages Cross_Reference (for gnatxref) and Finder - -- (for gnatfind) have an attributed Default_Switches, - -- an associative array, indexed by the name of the - -- programming language. - else - Default_Switches_Array := - Prj.Util.Value_Of - (Name => Name_Default_Switches, - In_Arrays => Packages.Table (Pkg).Decl.Arrays); - Switches := Prj.Util.Value_Of - (Index => Name_Ada, - In_Array => Default_Switches_Array); - - end if; - - -- If there are switches specified in the package of the - -- project file corresponding to the tool, scan them. - - case Switches.Kind is - when Prj.Undefined => - null; - - when Prj.Single => - if String_Length (Switches.Value) > 0 then - String_To_Name_Buffer (Switches.Value); - Scan_Arg - (Name_Buffer (1 .. Name_Len), - And_Save => False); - end if; - - when Prj.List => - Current := Switches.Values; - while Current /= Prj.Nil_String loop - The_String := String_Elements.Table (Current); - - if String_Length (The_String.Value) > 0 then - String_To_Name_Buffer (The_String.Value); - Scan_Arg - (Name_Buffer (1 .. Name_Len), - And_Save => False); - end if; - - Current := The_String.Next; - end loop; - end case; - end if; - end; - - -- Set up the environment variables ADA_INCLUDE_PATH and - -- ADA_OBJECTS_PATH. - - Setenv - (Name => Ada_Include_Path, - Value => Prj.Env.Ada_Include_Path (Project).all); - Setenv - (Name => Ada_Objects_Path, - Value => Prj.Env.Ada_Objects_Path - (Project, Including_Libraries => False).all); - - end if; - - -- Gather all the arguments, those from the project file first, - -- locate the tool and call it with the arguments. - - declare - Args : Argument_List (1 .. Switches.Last + Saved_Switches.Last + 4); - Arg_Num : Natural := 0; - Tool_Path : String_Access; - Success : Boolean; - - procedure Add (Arg : String_Access); - - procedure Add (Arg : String_Access) is - begin - Arg_Num := Arg_Num + 1; - Args (Arg_Num) := Arg; - end Add; - - begin - - case Tool is - when Comp => - Add (new String'("-u")); - Add (new String'("-f")); - - when Bind => - Add (new String'("-b")); - - when Link => - Add (new String'("-l")); - - when others => - null; - - end case; - - for Index in 1 .. Switches.Last loop - Arg_Num := Arg_Num + 1; - Args (Arg_Num) := Switches.Table (Index); - end loop; - - for Index in 1 .. Saved_Switches.Last loop - Arg_Num := Arg_Num + 1; - Args (Arg_Num) := Saved_Switches.Table (Index); - end loop; - - Tool_Path := GNAT.OS_Lib.Locate_Exec_On_Path (Tool_Names (Tool).all); - - if Tool_Path = null then - Fail ("error, unable to locate " & Tool_Names (Tool).all); - end if; - - Display (Tool_Names (Tool).all, Args (1 .. Arg_Num)); - - GNAT.OS_Lib.Spawn (Tool_Path.all, Args (1 .. Arg_Num), Success); - - end; - - end Gnatmain; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatmain.ads gcc-3.3/gcc/ada/gnatmain.ads *** gcc-3.2.3/gcc/ada/gnatmain.ads 2002-05-04 03:28:12.000000000 +0000 --- gcc-3.3/gcc/ada/gnatmain.ads 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,38 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- G N A T M A I N -- - -- -- - -- S p e c -- - -- -- - -- $Revision: 1.1.14.1 $ - -- -- - -- Copyright (C) 1992-2001 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - -- This procedure is the project-aware driver for the GNAT tools. - -- For gnatls, gnatxref, gnatfind and gnatstub, it setup the environment - -- variables ADA_INCLUDE_PATH and ADA_OBJECT_PATH and gather the switches - -- and file names from the project file (if any) and from the common line, - -- then call the non project-aware tool (gnatls, gnatxref, gnatfind or - -- gnatstub). - -- For other tools (compiler, binder, linker, gnatmake), it invokes - -- gnatmake with the proper switches. - - procedure Gnatmain; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatmake.adb gcc-3.3/gcc/ada/gnatmake.adb *** gcc-3.2.3/gcc/ada/gnatmake.adb 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/gnatmake.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 28,39 **** -- Gnatmake usage: please consult the gnat documentation - with Gnatvsn; with Make; procedure Gnatmake is - pragma Ident (Gnatvsn.Gnat_Version_String); - begin -- The real work is done in Package Make. Gnatmake used to be a standalone -- routine. Now Gnatmake's facilities have been placed in a package --- 27,35 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatmake.ads gcc-3.3/gcc/ada/gnatmake.ads *** gcc-3.2.3/gcc/ada/gnatmake.ads 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/gnatmake.ads 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatmem.adb gcc-3.3/gcc/ada/gnatmem.adb *** gcc-3.2.3/gcc/ada/gnatmem.adb 2002-05-04 03:28:12.000000000 +0000 --- gcc-3.3/gcc/ada/gnatmem.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1997-2001, Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2002, Ada Core Technologies, 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- -- *************** procedure Gnatmem is *** 328,335 **** Put_Line (FD, " silent"); Put_Line (FD, " set lang c"); Put_Line (FD, " set print address on"); ! Put_Line (FD, " finish"); ! Put_Line (FD, " set $gm_addr = $"); Put_Line (FD, " printf ""\n\n"""); Put_Line (FD, " printf ""ALLOC^0x%x^\n"", $gm_addr"); Put_Line (FD, " set print address off"); --- 327,334 ---- Put_Line (FD, " silent"); Put_Line (FD, " set lang c"); Put_Line (FD, " set print address on"); ! Put_Line (FD, " up"); ! Put_Line (FD, " set $gm_addr = $pc"); Put_Line (FD, " printf ""\n\n"""); Put_Line (FD, " printf ""ALLOC^0x%x^\n"", $gm_addr"); Put_Line (FD, " set print address off"); *************** procedure Gnatmem is *** 341,348 **** Put_Line (FD, " set lang c"); Put_Line (FD, " set $gm_size = size"); Put_Line (FD, " set print address on"); ! Put_Line (FD, " finish"); ! Put_Line (FD, " set $gm_addr = $"); Put_Line (FD, " printf ""\n\n"""); Put_Line (FD, " printf ""ALLOC^%d^0x%x^\n"", $gm_size, $gm_addr"); Put_Line (FD, " set print address off"); --- 340,347 ---- Put_Line (FD, " set lang c"); Put_Line (FD, " set $gm_size = size"); Put_Line (FD, " set print address on"); ! Put_Line (FD, " up"); ! Put_Line (FD, " set $gm_addr = $pc"); Put_Line (FD, " printf ""\n\n"""); Put_Line (FD, " printf ""ALLOC^%d^0x%x^\n"", $gm_size, $gm_addr"); Put_Line (FD, " set print address off"); *************** procedure Gnatmem is *** 352,358 **** Put (FD, " backtrace"); if BT_Depth /= 0 then ! Put (FD, Integer'Image (BT_Depth)); end if; New_Line (FD); --- 351,357 ---- Put (FD, " backtrace"); if BT_Depth /= 0 then ! Put (FD, Integer'Image (BT_Depth + 1)); end if; New_Line (FD); *************** procedure Gnatmem is *** 369,380 **** Put_Line (FD, " printf ""\n\n"""); Put_Line (FD, " printf ""DEALL^0x%x^\n"", ptr"); Put_Line (FD, " set print address off"); ! Put_Line (FD, " finish"); Put (FD, " backtrace"); if BT_Depth /= 0 then ! Put (FD, Integer'Image (BT_Depth)); end if; New_Line (FD); --- 368,379 ---- Put_Line (FD, " printf ""\n\n"""); Put_Line (FD, " printf ""DEALL^0x%x^\n"", ptr"); Put_Line (FD, " set print address off"); ! Put_Line (FD, " up"); Put (FD, " backtrace"); if BT_Depth /= 0 then ! Put (FD, Integer'Image (BT_Depth + 1)); end if; New_Line (FD); *************** procedure Gnatmem is *** 434,440 **** New_Line; Put ("GNATMEM "); Put (Gnat_Version_String); ! Put_Line (" Copyright 1997-2000 Free Software Foundation, Inc."); New_Line; if Cross_Case then --- 433,439 ---- New_Line; Put ("GNATMEM "); Put (Gnat_Version_String); ! Put_Line (" Copyright 1997-2002 Free Software Foundation, Inc."); New_Line; if Cross_Case then diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatname.adb gcc-3.3/gcc/ada/gnatname.adb *** gcc-3.2.3/gcc/ada/gnatname.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnatname.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,336 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- G N A T N A M E -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001-2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with Gnatvsn; + with Opt; + with Osint; use Osint; + with Output; use Output; + with Prj.Makr; + with Table; + + with Ada.Text_IO; use Ada.Text_IO; + with GNAT.Command_Line; use GNAT.Command_Line; + with GNAT.OS_Lib; use GNAT.OS_Lib; + + procedure Gnatname is + + Usage_Output : Boolean := False; + -- Set to True when usage is output, to avoid multiple output + + Usage_Needed : Boolean := False; + -- Set to True by -h switch + + Version_Output : Boolean := False; + -- Set to True when version is output, to avoid multiple output + + Very_Verbose : Boolean := False; + -- Set to True with -v -v + + Create_Project : Boolean := False; + -- Set to True with a -P switch + + File_Path : String_Access := new String'("gnat.adc"); + -- Path name of the file specified by -c or -P switch + + File_Set : Boolean := False; + -- Set to True by -c or -P switch. + -- Used to detect multiple -c/-P switches. + + package Excluded_Patterns is new Table.Table + (Table_Component_Type => String_Access, + Table_Index_Type => Natural, + Table_Low_Bound => 0, + Table_Initial => 10, + Table_Increment => 10, + Table_Name => "Gnatname.Excluded_Patterns"); + -- Table to accumulate the negative patterns. + + package Patterns is new Table.Table + (Table_Component_Type => String_Access, + Table_Index_Type => Natural, + Table_Low_Bound => 0, + Table_Initial => 10, + Table_Increment => 10, + Table_Name => "Gnatname.Patterns"); + -- Table to accumulate the name patterns. + + package Source_Directories is new Table.Table + (Table_Component_Type => String_Access, + Table_Index_Type => Natural, + Table_Low_Bound => 0, + Table_Initial => 10, + Table_Increment => 10, + Table_Name => "Gnatname.Source_Directories"); + -- Table to accumulate the source directories specified directly with -d + -- or indirectly with -D. + + procedure Output_Version; + -- Print name and version + + procedure Usage; + -- Print usage + + procedure Scan_Args; + -- Scan the command line arguments + + procedure Add_Source_Directory (S : String); + -- Add S in the Source_Directories table + + procedure Get_Directories (From_File : String); + -- Read a source directory text file + + -------------------------- + -- Add_Source_Directory -- + -------------------------- + + procedure Add_Source_Directory (S : String) is + begin + Source_Directories.Increment_Last; + Source_Directories.Table (Source_Directories.Last) := new String'(S); + end Add_Source_Directory; + + --------------------- + -- Get_Directories -- + --------------------- + + procedure Get_Directories (From_File : String) is + File : Ada.Text_IO.File_Type; + Line : String (1 .. 2_000); + Last : Natural; + + begin + Open (File, In_File, From_File); + + while not End_Of_File (File) loop + Get_Line (File, Line, Last); + + if Last /= 0 then + Add_Source_Directory (Line (1 .. Last)); + end if; + end loop; + + Close (File); + + exception + when Name_Error => + Fail ("cannot open source directory """ & From_File & '"'); + end Get_Directories; + + -------------------- + -- Output_Version -- + -------------------- + + procedure Output_Version is + begin + if not Version_Output then + Version_Output := True; + Output.Write_Eol; + Output.Write_Str ("GNATNAME "); + Output.Write_Str (Gnatvsn.Gnat_Version_String); + Output.Write_Line + (" Copyright 2001-2002 Free Software Foundation, Inc."); + end if; + end Output_Version; + + --------------- + -- Scan_Args -- + --------------- + + procedure Scan_Args is + begin + Initialize_Option_Scan; + + -- Scan options first + + loop + case Getopt ("c: d: D: h P: v x:") is + when ASCII.NUL => + exit; + + when 'c' => + if File_Set then + Fail ("only one -P or -c switch may be specified"); + end if; + + File_Set := True; + File_Path := new String'(Parameter); + Create_Project := False; + + when 'd' => + Add_Source_Directory (Parameter); + + when 'D' => + Get_Directories (Parameter); + + when 'h' => + Usage_Needed := True; + + when 'P' => + if File_Set then + Fail ("only one -c or -P switch may be specified"); + end if; + + File_Set := True; + File_Path := new String'(Parameter); + Create_Project := True; + + when 'v' => + if Opt.Verbose_Mode then + Very_Verbose := True; + + else + Opt.Verbose_Mode := True; + end if; + + when 'x' => + Excluded_Patterns.Increment_Last; + Excluded_Patterns.Table (Excluded_Patterns.Last) := + new String'(Parameter); + + when others => + null; + end case; + end loop; + + -- Now, get the name patterns, if any + + loop + declare + S : constant String := Get_Argument (Do_Expansion => False); + + begin + exit when S = ""; + Patterns.Increment_Last; + Patterns.Table (Patterns.Last) := new String'(S); + end; + end loop; + + exception + when Invalid_Switch => + Fail ("invalid switch " & Full_Switch); + + end Scan_Args; + + ----------- + -- Usage -- + ----------- + + procedure Usage is + begin + if not Usage_Output then + Usage_Needed := False; + Usage_Output := True; + Write_Str ("Usage: "); + Osint.Write_Program_Name; + Write_Line (" [switches] naming-pattern [naming-patterns]"); + Write_Eol; + Write_Line ("switches:"); + + Write_Line (" -cfile create configuration pragmas file"); + Write_Line (" -ddir use dir as one of the source directories"); + Write_Line (" -Dfile get source directories from file"); + Write_Line (" -h output this help message"); + Write_Line (" -Pproj update or create project file proj"); + Write_Line (" -v verbose output"); + Write_Line (" -v -v very verbose output"); + Write_Line (" -xpat exclude pattern pat"); + end if; + end Usage; + + -- Start of processing for Gnatname + + begin + -- Initialize tables + + Excluded_Patterns.Set_Last (0); + Patterns.Set_Last (0); + Source_Directories.Set_Last (0); + + -- Get the arguments + + Scan_Args; + + if Opt.Verbose_Mode then + Output_Version; + end if; + + if Usage_Needed then + Usage; + end if; + + -- If no pattern was specified, print the usage and return + + if Patterns.Last = 0 then + Usage; + return; + end if; + + -- If no source directory was specified, use the current directory as the + -- unique directory. Note that if a file was specified with directory + -- information, the current directory is the directory of the specified + -- file. + + if Source_Directories.Last = 0 then + Source_Directories.Increment_Last; + Source_Directories.Table (Source_Directories.Last) := new String'("."); + end if; + + declare + Directories : Argument_List (1 .. Integer (Source_Directories.Last)); + Name_Patterns : Argument_List (1 .. Integer (Patterns.Last)); + Excl_Patterns : Argument_List (1 .. Integer (Excluded_Patterns.Last)); + + begin + -- Build the Directories and Name_Patterns arguments + + for Index in Directories'Range loop + Directories (Index) := Source_Directories.Table (Index); + end loop; + + for Index in Name_Patterns'Range loop + Name_Patterns (Index) := Patterns.Table (Index); + end loop; + + for Index in Excl_Patterns'Range loop + Excl_Patterns (Index) := Excluded_Patterns.Table (Index); + end loop; + + -- Call Prj.Makr.Make where the real work is done + + Prj.Makr.Make + (File_Path => File_Path.all, + Project_File => Create_Project, + Directories => Directories, + Name_Patterns => Name_Patterns, + Excluded_Patterns => Excl_Patterns, + Very_Verbose => Very_Verbose); + end; + + if Opt.Verbose_Mode then + Write_Eol; + end if; + end Gnatname; diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatname.ads gcc-3.3/gcc/ada/gnatname.ads *** gcc-3.2.3/gcc/ada/gnatname.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnatname.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,32 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- G N A T N A M E -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- Tool for dealing with source files with arbitrary naming conventions. + -- It either creates a configuration pragmas file, or updates or creates + -- a project file. + + procedure Gnatname; diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatprep.adb gcc-3.3/gcc/ada/gnatprep.adb *** gcc-3.2.3/gcc/ada/gnatprep.adb 2002-05-04 03:28:12.000000000 +0000 --- gcc-3.3/gcc/ada/gnatprep.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1996-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1996-2002, 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- -- *************** with GNAT.Command_Line; *** 37,45 **** with Gnatvsn; procedure GNATprep is - pragma Ident (Gnatvsn.Gnat_Version_String); - - Version_String : constant String := "$Revision: 1.1.16.1 $"; type Strptr is access String; --- 36,41 ---- *************** procedure GNATprep is *** 58,69 **** -- Argument Line Data -- ------------------------ - Infile_Name : Strptr; Outfile_Name : Strptr; Deffile_Name : Strptr; -- Names of files ! Infile : File_Type; Outfile : File_Type; Deffile : File_Type; --- 54,76 ---- -- Argument Line Data -- ------------------------ Outfile_Name : Strptr; Deffile_Name : Strptr; -- Names of files ! type Input; ! type Input_Ptr is access Input; ! type Input is record ! File : File_Type; ! Next : Input_Ptr; ! Prev : Input_Ptr; ! Name : Strptr; ! Line_Num : Natural := 0; ! end record; ! -- Data for the current input file (main input file or included file ! -- or definition file). ! ! Infile : Input_Ptr := new Input; Outfile : File_Type; Deffile : File_Type; *************** procedure GNATprep is *** 100,114 **** Line_Length : Natural; -- Length of line in Line_Buffer - Line_Num : Natural; - -- Current input file line number - Ptr : Natural; -- Input scan pointer for line in Line_Buffer type Keyword is (K_Not, K_Then, K_If, K_Else, K_End, K_Elsif, K_And, K_Or, K_Open_Paren, K_Close_Paren, ! K_Defined, K_Andthen, K_Orelse, K_Equal, K_None); -- Keywords that are recognized on preprocessor lines. K_None indicates -- that no keyword was present. --- 107,119 ---- Line_Length : Natural; -- Length of line in Line_Buffer Ptr : Natural; -- Input scan pointer for line in Line_Buffer type Keyword is (K_Not, K_Then, K_If, K_Else, K_End, K_Elsif, K_And, K_Or, K_Open_Paren, K_Close_Paren, ! K_Defined, K_Andthen, K_Orelse, K_Equal, K_Include, ! K_None); -- Keywords that are recognized on preprocessor lines. K_None indicates -- that no keyword was present. *************** procedure GNATprep is *** 131,136 **** --- 136,144 ---- If_Line : Positive; -- Line number for #if line + If_Name : Strptr; + -- File name of #if line + Else_Line : Natural; -- Line number for #else line, zero = no else seen yet *************** procedure GNATprep is *** 141,146 **** --- 149,155 ---- -- True if either the #if condition or one of the previously seen -- #elsif lines was true, meaning that any future #elsif sections -- or the #else section, is to be deleted. + end record; PP_Depth : Natural; *************** procedure GNATprep is *** 162,168 **** procedure Error (Msg : String); -- Post error message with given text. The line number is taken from ! -- Line_Num, and the column number from Ptr. function Eval_Condition (Parenthesis : Natural := 0; --- 171,177 ---- procedure Error (Msg : String); -- Post error message with given text. The line number is taken from ! -- Infile.Line_Num, and the column number from Ptr. function Eval_Condition (Parenthesis : Natural := 0; *************** procedure GNATprep is *** 184,189 **** --- 193,201 ---- procedure Help_Page; -- Print a help page to summarize the usage of gnatprep + function Image (N : Natural) return String; + -- Returns Natural'Image (N) without the initial space + function Is_Preprocessor_Line return Boolean; -- Tests if current line is a preprocessor line, i.e. that its first -- non-blank character is a # character. If so, then a result of True *************** procedure GNATprep is *** 244,250 **** ----------- procedure Error (Msg : String) is ! L : constant String := Natural'Image (Line_Num); C : constant String := Natural'Image (Ptr); begin --- 256,262 ---- ----------- procedure Error (Msg : String) is ! L : constant String := Natural'Image (Infile.Line_Num); C : constant String := Natural'Image (Ptr); begin *************** procedure GNATprep is *** 419,424 **** --- 431,437 ---- when K_Equal => -- Read the second part of the statement + Skip_Spaces; Start_Sym := Ptr; *************** procedure GNATprep is *** 510,518 **** procedure Help_Page is begin Put_Line (Standard_Error, ! "GNAT Preprocessor Version " & ! Version_String (12 .. 15) & ! " Copyright 1996-2001 Free Software Foundation, Inc."); Put_Line (Standard_Error, "Usage: gnatprep [-bcrsu] [-Dsymbol=value] infile " & "outfile [deffile]"); --- 523,531 ---- procedure Help_Page is begin Put_Line (Standard_Error, ! "GNAT Preprocessor " & ! Gnatvsn.Gnat_Version_String & ! " Copyright 1996-2002 Free Software Foundation, Inc."); Put_Line (Standard_Error, "Usage: gnatprep [-bcrsu] [-Dsymbol=value] infile " & "outfile [deffile]"); *************** procedure GNATprep is *** 533,538 **** --- 546,561 ---- New_Line (Standard_Error); end Help_Page; + ----------- + -- Image -- + ----------- + + function Image (N : Natural) return String is + Result : constant String := Natural'Image (N); + begin + return Result (Result'First + 1 .. Result'Last); + end Image; + -------------------------- -- Is_Preprocessor_Line -- -------------------------- *************** procedure GNATprep is *** 654,667 **** begin Open (Deffile, In_File, Deffile_Name.all); ! Line_Num := 0; Current_File_Name := Deffile_Name; -- Loop through lines in symbol definitions file while not End_Of_File (Deffile) loop Get_Line (Deffile, Line_Buffer, Line_Length); ! Line_Num := Line_Num + 1; Ptr := 1; Skip_Spaces; --- 677,692 ---- begin Open (Deffile, In_File, Deffile_Name.all); ! -- Initialize data for procedure Error ! ! Infile.Line_Num := 0; Current_File_Name := Deffile_Name; -- Loop through lines in symbol definitions file while not End_Of_File (Deffile) loop Get_Line (Deffile, Line_Buffer, Line_Length); ! Infile.Line_Num := Infile.Line_Num + 1; Ptr := 1; Skip_Spaces; *************** procedure GNATprep is *** 826,831 **** --- 851,859 ---- elsif Matching_Strings (Sym, "'defined") then return K_Defined; + elsif Matching_Strings (Sym, "include") then + return K_Include; + elsif Sym = "(" then return K_Open_Paren; *************** begin *** 991,998 **** begin exit when S'Length = 0; ! if Infile_Name = null then ! Infile_Name := new String'(S); elsif Outfile_Name = null then Outfile_Name := new String'(S); elsif Deffile_Name = null then --- 1019,1026 ---- begin exit when S'Length = 0; ! if Infile.Name = null then ! Infile.Name := new String'(S); elsif Outfile_Name = null then Outfile_Name := new String'(S); elsif Deffile_Name = null then *************** begin *** 1005,1011 **** -- Test we had all the arguments needed ! if Infile_Name = null or else Outfile_Name = null then raise Usage_Error; --- 1033,1039 ---- -- Test we had all the arguments needed ! if Infile.Name = null or else Outfile_Name = null then raise Usage_Error; *************** begin *** 1111,1121 **** -- Open files and initialize preprocessing begin ! Open (Infile, In_File, Infile_Name.all); exception when Name_Error => ! Put_Line (Standard_Error, "cannot open " & Infile_Name.all); raise Fatal_Error; end; --- 1139,1149 ---- -- Open files and initialize preprocessing begin ! Open (Infile.File, In_File, Infile.Name.all); exception when Name_Error => ! Put_Line (Standard_Error, "cannot open " & Infile.Name.all); raise Fatal_Error; end; *************** begin *** 1128,1149 **** raise Fatal_Error; end; ! if Source_Ref_Pragma then ! Put_Line ! (Outfile, "pragma Source_Reference (1, """ & Infile_Name.all & """);"); ! end if; ! ! Line_Num := 0; ! Current_File_Name := Infile_Name; PP_Depth := 0; PP (0).Deleting := False; -- Loop through lines in input file ! while not End_Of_File (Infile) loop ! Get_Line (Infile, Line_Buffer, Line_Length); ! Line_Num := Line_Num + 1; -- Handle preprocessor line --- 1156,1189 ---- raise Fatal_Error; end; ! Infile.Line_Num := 0; ! Current_File_Name := Infile.Name; PP_Depth := 0; PP (0).Deleting := False; + -- We return here after we start reading an include file and after + -- we have finished reading an include file. + + <> + + -- If we generate Source_Reference pragmas, then generate one + -- either with line number 1 for a newly included file, or + -- with the number of the next line when we have returned to the + -- including file. + + if Source_Ref_Pragma then + Put_Line + (Outfile, "pragma Source_Reference (" & + Image (Infile.Line_Num + 1) & + ", """ & Infile.Name.all & """);"); + end if; + -- Loop through lines in input file ! while not End_Of_File (Infile.File) loop ! Get_Line (Infile.File, Line_Buffer, Line_Length); ! Infile.Line_Num := Infile.Line_Num + 1; -- Handle preprocessor line *************** begin *** 1152,1157 **** --- 1192,1303 ---- case K is + -- Include file + + when K_Include => + -- Ignore if Deleting is True + + if PP (PP_Depth).Deleting then + goto Output; + end if; + + Skip_Spaces; + + if Ptr >= Line_Length then + Error ("no file to include"); + + elsif Line_Buffer (Ptr) /= '"' then + Error + ("file to include must be specified as a literal string"); + + else + declare + Start_File : constant Positive := Ptr + 1; + + begin + Ptr := Line_Length; + + while Line_Buffer (Ptr) = ' ' + or else Line_Buffer (Ptr) = ASCII.HT + loop + Ptr := Ptr - 1; + end loop; + + if Ptr <= Start_File + or else Line_Buffer (Ptr) /= '"' + then + Error ("no string literal for included file"); + + else + if Infile.Next = null then + Infile.Next := new Input; + Infile.Next.Prev := Infile; + end if; + + Infile := Infile.Next; + Infile.Name := + new String'(Line_Buffer (Start_File .. Ptr - 1)); + + -- Check for circularity: an file including itself, + -- either directly or indirectly. + + declare + File : Input_Ptr := Infile.Prev; + + begin + while File /= null + and then File.Name.all /= Infile.Name.all + loop + File := File.Prev; + end loop; + + if File /= null then + Infile := Infile.Prev; + Error ("circularity in included files"); + + while File.Prev /= null loop + File := File.Prev; + end loop; + + while File /= Infile.Next loop + Error ('"' & File.Name.all & + """ includes """ & + File.Next.Name.all & '"'); + File := File.Next; + end loop; + + else + -- We have a file name and no circularity. + -- Open the file and record an error if the + -- file cannot be opened. + + begin + Open (Infile.File, In_File, Infile.Name.all); + Current_File_Name := Infile.Name; + Infile.Line_Num := 0; + + -- If we use Source_Reference pragma, + -- we need to output one for this new file. + goto Read_In_File; + + exception + when Name_Error => + + -- We need to set the input file to + -- the including file, so that the + -- line number is correct when reporting + -- the error. + + Infile := Infile.Prev; + Error ("cannot open """ & + Infile.Next.Name.all & '"'); + end; + end if; + end; + end if; + end; + end if; + -- If/Elsif processing when K_If | K_Elsif => *************** begin *** 1165,1171 **** if K = K_If then PP_Depth := PP_Depth + 1; PP (PP_Depth) := ! (If_Line => Line_Num, Else_Line => 0, Deleting => False, Match_Seen => PP (PP_Depth - 1).Deleting); --- 1311,1318 ---- if K = K_If then PP_Depth := PP_Depth + 1; PP (PP_Depth) := ! (If_Line => Infile.Line_Num, ! If_Name => Infile.Name, Else_Line => 0, Deleting => False, Match_Seen => PP (PP_Depth - 1).Deleting); *************** begin *** 1202,1208 **** ")"); else ! PP (PP_Depth).Else_Line := Line_Num; PP (PP_Depth).Deleting := PP (PP_Depth).Match_Seen; end if; --- 1349,1355 ---- ")"); else ! PP (PP_Depth).Else_Line := Infile.Line_Num; PP (PP_Depth).Deleting := PP (PP_Depth).Match_Seen; end if; *************** begin *** 1356,1364 **** end if; end loop; for J in 1 .. PP_Depth loop ! Error ("no matching #end for #if at line" & ! Natural'Image (PP (J).If_Line)); end loop; if Num_Errors = 0 then --- 1503,1527 ---- end if; end loop; + -- If we have finished reading an included file, close it and continue + -- with the next line of the including file. + + if Infile.Prev /= null then + Close (Infile.File); + Infile := Infile.Prev; + Current_File_Name := Infile.Name; + goto Read_In_File; + end if; + for J in 1 .. PP_Depth loop ! if PP (J).If_Name = Infile.Name then ! Error ("no matching #end for #if at line" & ! Natural'Image (PP (J).If_Line)); ! else ! Error ("no matching #end for #if at line" & ! Natural'Image (PP (J).If_Line) & ! " of file """ & PP (J).If_Name.all & '"'); ! end if; end loop; if Num_Errors = 0 then diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatprep.ads gcc-3.3/gcc/ada/gnatprep.ads *** gcc-3.2.3/gcc/ada/gnatprep.ads 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/gnatprep.ads 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatpsta.adb gcc-3.3/gcc/ada/gnatpsta.adb *** gcc-3.2.3/gcc/ada/gnatpsta.adb 2002-05-04 03:28:13.000000000 +0000 --- gcc-3.3/gcc/ada/gnatpsta.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 35,47 **** -- integer and floating point sizes. with Ada.Text_IO; use Ada.Text_IO; - with Gnatvsn; with Ttypef; use Ttypef; with Ttypes; use Ttypes; with Types; use Types; procedure GnatPsta is - pragma Ident (Gnatvsn.Gnat_Version_String); procedure P (Item : String) renames Ada.Text_IO.Put_Line; --- 34,44 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatpsys.adb gcc-3.3/gcc/ada/gnatpsys.adb *** gcc-3.2.3/gcc/ada/gnatpsys.adb 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/gnatpsys.adb 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,171 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT SYSTEM UTILITIES -- - -- -- - -- G N A T P S Y S -- - -- -- - -- B o d y -- - -- -- - -- $Revision: 1.1.16.2 $ - -- -- - -- Copyright (C) 1997 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - -- Program to print out listing of System package with all constants - -- appearing explicitly. - - with Ada.Text_IO; - with System; use System; - with Gnatvsn; - - procedure GnatPsys is - pragma Ident (Gnatvsn.Gnat_Version_String); - - procedure P (Item : String) renames Ada.Text_IO.Put_Line; - - begin - P ("package System is"); - - P ("pragma Pure (System);"); - - P (""); - - P (" type Name is (SYSTEM_NAME_GNAT);"); - - P (" System_Name : constant Name := SYSTEM_NAME_GNAT;"); - - P (""); - - P (" -- System-Dependent Named Numbers"); - - P (""); - - P (" Min_Int : constant := -(2 **" & - Long_Long_Integer'Image (Long_Long_Integer'Size - 1) & ");"); - - P (" Max_Int : constant := 2 **" & - Long_Long_Integer'Image (Long_Long_Integer'Size - 1) & " - 1;"); - - P (""); - - P (" Max_Binary_Modulus : constant := 2 **" & - Long_Long_Integer'Image (Long_Long_Integer'Size) & ";"); - - P (" Max_Nonbinary_Modulus : constant :=" & - Integer'Image (Integer'Last) & ";"); - - P (""); - - P (" Max_Base_Digits : constant :=" & - Natural'Image (Long_Long_Float'Digits) & ";"); - - P (" Max_Digits : constant :=" & - Natural'Image (Long_Long_Float'Digits) & ";"); - - P (""); - - P (" Max_Mantissa : constant := 63;"); - - P (" Fine_Delta : constant := 2.0 ** (-Max_Mantissa);"); - - P (""); - - P (" Tick : constant :=" & - Duration'Image (Duration (Standard'Tick)) & ";"); - - P (""); - - P (" -- Storage-related Declarations"); - - P (""); - - P (" type Address is private;"); - - P (" Null_Address : constant Address;"); - - P (""); - - P (" Storage_Unit : constant :=" & - Natural'Image (Standard'Storage_Unit) & ";"); - - P (" Word_Size : constant :=" & - Natural'Image (Standard'Word_Size) & ";"); - - P (" Memory_Size : constant := 2 **" & - Natural'Image (Standard'Address_Size) & ";"); - - P (""); - P (" -- Address comparison"); - P (""); - P (" function ""<"" (Left, Right : Address) return Boolean;"); - P (" function ""<="" (Left, Right : Address) return Boolean;"); - P (" function "">"" (Left, Right : Address) return Boolean;"); - P (" function "">="" (Left, Right : Address) return Boolean;"); - P (" function ""="" (Left, Right : Address) return Boolean;"); - P (""); - P (" pragma Import (Intrinsic, ""<""); "); - P (" pragma Import (Intrinsic, ""<="");"); - P (" pragma Import (Intrinsic, "">""); "); - P (" pragma Import (Intrinsic, "">="");"); - P (" pragma Import (Intrinsic, ""=""); "); - P (""); - P (" -- Other System-Dependent Declarations"); - P (""); - P (" type Bit_Order is (High_Order_First, Low_Order_First);"); - P (" Default_Bit_Order : constant Bit_Order;"); - P (""); - P (" -- Priority-related Declarations (RM D.1)"); - P (""); - P (" subtype Any_Priority is Integer range 0 .." & - Natural'Image (Standard'Max_Interrupt_Priority) & ";"); - - P (""); - - P (" subtype Priority is Any_Priority range 0 .." & - Natural'Image (Standard'Max_Priority) & ";"); - - P (""); - - P (" subtype Interrupt_Priority is Any_Priority range" & - Natural'Image (Standard'Max_Priority + 1) & " .." & - Natural'Image (Standard'Max_Interrupt_Priority) & ";"); - - P (""); - - P (" Default_Priority : constant Priority :=" & - Natural'Image ((Priority'First + Priority'Last) / 2) & ";"); - - P (""); - - P ("private"); - - P (""); - - P (" type Address is mod Memory_Size; "); - - P (" Null_Address : constant Address := 0; "); - - P (" "); - - P (" Default_Bit_Order : constant Bit_Order := " & - Bit_Order'Image (Bit_Order'Val (Standard'Default_Bit_Order)) & ";"); - - P (""); - - P ("end System;"); - end GnatPsys; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_rm.info gcc-3.3/gcc/ada/gnat_rm.info *** gcc-3.2.3/gcc/ada/gnat_rm.info 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_rm.info 2003-05-14 00:31:47.000000000 +0000 *************** *** 0 **** --- 1,11455 ---- + This is ada/gnat_rm.info, produced by makeinfo version 4.2 from + ada/gnat_rm.texi. + + INFO-DIR-SECTION GNU Ada tools + START-INFO-DIR-ENTRY + * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools. + END-INFO-DIR-ENTRY + + Copyright (C) 1995-2001, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT Reference Manual", and with no Back-Cover + Texts. A copy of the license is included in the section entitled "GNU + Free Documentation License". +  + File: gnat_rm.info, Node: Top, Next: About This Guide, Prev: (dir), Up: (dir) + + GNAT Reference Manual + ********************* + + GNAT Reference Manual + + GNAT, The GNU Ada 95 Compiler + + GNAT Version for GCC 3.3 + + Ada Core Technologies, Inc. + + Copyright (C) 1995-2001, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT Reference Manual", and with no Back-Cover + Texts. A copy of the license is included in the section entitled "GNU + Free Documentation License". + * Menu: + + * About This Guide:: + * Implementation Defined Pragmas:: + * Implementation Defined Attributes:: + * Implementation Advice:: + * Implementation Defined Characteristics:: + * Intrinsic Subprograms:: + * Representation Clauses and Pragmas:: + * Standard Library Routines:: + * The Implementation of Standard I/O:: + * The GNAT Library:: + * Interfacing to Other Languages:: + * Machine Code Insertions:: + * GNAT Implementation of Tasking:: + * Code generation for array aggregates:: + * Specialized Needs Annexes:: + * Compatibility Guide:: + * GNU Free Documentation License:: + * Index:: + + --- The Detailed Node Listing --- + + About This Guide + + * What This Reference Manual Contains:: + * Related Information:: + + The Implementation of Standard I/O + + * Standard I/O Packages:: + * FORM Strings:: + * Direct_IO:: + * Sequential_IO:: + * Text_IO:: + * Wide_Text_IO:: + * Stream_IO:: + * Shared Files:: + * Open Modes:: + * Operations on C Streams:: + * Interfacing to C Streams:: + + The GNAT Library + + * Ada.Characters.Latin_9 (a-chlat9.ads):: + * Ada.Characters.Wide_Latin_1 (a-cwila1.ads):: + * Ada.Characters.Wide_Latin_9 (a-cwila9.ads):: + * Ada.Command_Line.Remove (a-colire.ads):: + * Ada.Direct_IO.C_Streams (a-diocst.ads):: + * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads):: + * Ada.Sequential_IO.C_Streams (a-siocst.ads):: + * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads):: + * Ada.Strings.Unbounded.Text_IO (a-suteio.ads):: + * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads):: + * Ada.Text_IO.C_Streams (a-tiocst.ads):: + * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads):: + * GNAT.AWK (g-awk.ads):: + * GNAT.Bubble_Sort_A (g-busora.ads):: + * GNAT.Bubble_Sort_G (g-busorg.ads):: + * GNAT.Calendar (g-calend.ads):: + * GNAT.Calendar.Time_IO (g-catiio.ads):: + * GNAT.Case_Util (g-casuti.ads):: + * GNAT.CGI (g-cgi.ads):: + * GNAT.CGI.Cookie (g-cgicoo.ads):: + * GNAT.CGI.Debug (g-cgideb.ads):: + * GNAT.Command_Line (g-comlin.ads):: + * GNAT.CRC32 (g-crc32.ads):: + * GNAT.Current_Exception (g-curexc.ads):: + * GNAT.Debug_Pools (g-debpoo.ads):: + * GNAT.Debug_Utilities (g-debuti.ads):: + * GNAT.Directory_Operations (g-dirope.ads):: + * GNAT.Dynamic_Tables (g-dyntab.ads):: + * GNAT.Exception_Traces (g-exctra.ads):: + * GNAT.Expect (g-expect.ads):: + * GNAT.Float_Control (g-flocon.ads):: + * GNAT.Heap_Sort_A (g-hesora.ads):: + * GNAT.Heap_Sort_G (g-hesorg.ads):: + * GNAT.HTable (g-htable.ads):: + * GNAT.IO (g-io.ads):: + * GNAT.IO_Aux (g-io_aux.ads):: + * GNAT.Lock_Files (g-locfil.ads):: + * GNAT.MD5 (g-md5.ads):: + * GNAT.Most_Recent_Exception (g-moreex.ads):: + * GNAT.OS_Lib (g-os_lib.ads):: + * GNAT.Regexp (g-regexp.ads):: + * GNAT.Registry (g-regist.ads):: + * GNAT.Regpat (g-regpat.ads):: + * GNAT.Sockets (g-socket.ads):: + * GNAT.Source_Info (g-souinf.ads):: + * GNAT.Spell_Checker (g-speche.ads):: + * GNAT.Spitbol.Patterns (g-spipat.ads):: + * GNAT.Spitbol (g-spitbo.ads):: + * GNAT.Spitbol.Table_Boolean (g-sptabo.ads):: + * GNAT.Spitbol.Table_Integer (g-sptain.ads):: + * GNAT.Spitbol.Table_VString (g-sptavs.ads):: + * GNAT.Table (g-table.ads):: + * GNAT.Task_Lock (g-tasloc.ads):: + * GNAT.Threads (g-thread.ads):: + * GNAT.Traceback (g-traceb.ads):: + * GNAT.Traceback.Symbolic (g-trasym.ads):: + * Interfaces.C.Extensions (i-cexten.ads):: + * Interfaces.C.Streams (i-cstrea.ads):: + * Interfaces.CPP (i-cpp.ads):: + * Interfaces.Os2lib (i-os2lib.ads):: + * Interfaces.Os2lib.Errors (i-os2err.ads):: + * Interfaces.Os2lib.Synchronization (i-os2syn.ads):: + * Interfaces.Os2lib.Threads (i-os2thr.ads):: + * Interfaces.Packed_Decimal (i-pacdec.ads):: + * Interfaces.VxWorks (i-vxwork.ads):: + * Interfaces.VxWorks.IO (i-vxwoio.ads):: + * System.Address_Image (s-addima.ads):: + * System.Assertions (s-assert.ads):: + * System.Partition_Interface (s-parint.ads):: + * System.Task_Info (s-tasinf.ads):: + * System.Wch_Cnv (s-wchcnv.ads):: + * System.Wch_Con (s-wchcon.ads):: + + Text_IO + + * Text_IO Stream Pointer Positioning:: + * Text_IO Reading and Writing Non-Regular Files:: + * Get_Immediate:: + * Treating Text_IO Files as Streams:: + * Text_IO Extensions:: + * Text_IO Facilities for Unbounded Strings:: + + Wide_Text_IO + + * Wide_Text_IO Stream Pointer Positioning:: + * Wide_Text_IO Reading and Writing Non-Regular Files:: + + Interfacing to Other Languages + + * Interfacing to C:: + * Interfacing to C++:: + * Interfacing to COBOL:: + * Interfacing to Fortran:: + * Interfacing to non-GNAT Ada code:: + + GNAT Implementation of Tasking + + * Mapping Ada Tasks onto the Underlying Kernel Threads:: + * Ensuring Compliance with the Real-Time Annex:: + +  + File: gnat_rm.info, Node: About This Guide, Next: Implementation Defined Pragmas, Prev: Top, Up: Top + + About This Guide + **************** + + This manual contains useful information in writing programs using the + GNAT compiler. It includes information on implementation dependent + characteristics of GNAT, including all the information required by Annex + M of the standard. + + Ada 95 is designed to be highly portable,and guarantees that, for + most programs, Ada 95 compilers behave in exactly the same manner on + different machines. However, since Ada 95 is designed to be used in a + wide variety of applications, it also contains a number of system + dependent features to Functbe used in interfacing to the external world. + + Note: Any program that makes use of implementation-dependent features + may be non-portable. You should follow good programming practice and + isolate and clearly document any sections of your program that make use + of these features in a non-portable manner. + + * Menu: + + * What This Reference Manual Contains:: + * Conventions:: + * Related Information:: + +  + File: gnat_rm.info, Node: What This Reference Manual Contains, Next: Conventions, Up: About This Guide + + What This Reference Manual Contains + =================================== + + This reference manual contains the following chapters: + + * *Note Implementation Defined Pragmas:: lists GNAT + implementation-dependent pragmas, which can be used to extend and + enhance the functionality of the compiler. + + * *Note Implementation Defined Attributes:: lists GNAT + implementation-dependent attributes which can be used to extend and + enhance the functionality of the compiler. + + * *Note Implementation Advice:: provides information on generally + desirable behavior which are not requirements that all compilers + must follow since it cannot be provided on all systems, or which + may be undesirable on some systems. + + * *Note Implementation Defined Characteristics:: provides a guide to + minimizing implementation dependent features. + + * *Note Intrinsic Subprograms:: describes the intrinsic subprograms + implemented by GNAT, and how they can be imported into user + application programs. + + * *Note Representation Clauses and Pragmas:: describes in detail the + way that GNAT represents data, and in particular the exact set of + representation clauses and pragmas that is accepted. + + * *Note Standard Library Routines:: provides a listing of packages + and a brief description of the functionality that is provided by + Ada's extensive set of standard library routines as implemented by + GNAT. + + * *Note The Implementation of Standard I/O:: details how the GNAT + implementation of the input-output facilities. + + * *Note Interfacing to Other Languages:: describes how programs + written in Ada using GNAT can be interfaced to other programming + languages. + + * *Note Specialized Needs Annexes:: describes the GNAT + implementation of all of the special needs annexes. + + * *Note Compatibility Guide:: includes sections on compatibility of + GNAT with other Ada 83 and Ada 95 compilation systems, to assist + in porting code from other environments. + + This reference manual assumes that you are familiar with Ada 95 + language, as described in the International Standard + ANSI/ISO/IEC-8652:1995, Jan 1995. + +  + File: gnat_rm.info, Node: Conventions, Next: Related Information, Prev: What This Reference Manual Contains, Up: About This Guide + + Conventions + =========== + + Following are examples of the typographical and graphic conventions used + in this guide: + + * `Functions', `utility program names', `standard names', and + `classes'. + + * `Option flags' + + * `File Names', `button names', and `field names'. + + * `Variables'. + + * _Emphasis_. + + * [optional information or parameters] + + * Examples are described by text + and then shown this way. + + Commands that are entered by the user are preceded in this manual by the + characters `$ ' (dollar sign followed by space). If your system uses + this sequence as a prompt, then the commands will appear exactly as you + see them in the manual. If your system uses some other prompt, then + the command will appear with the `$' replaced by whatever prompt + character you are using. + +  + File: gnat_rm.info, Node: Related Information, Prev: Conventions, Up: About This Guide + + Related Information + =================== + + See the following documents for further information on GNAT: + + * `GNAT User's Guide', which provides information on how to use the + GNAT compiler system. + + * `Ada 95 Reference Manual', which contains all reference material + for the Ada 95 programming language. + + * `Ada 95 Annotated Reference Manual', which is an annotated version + of the standard reference manual cited above. The annotations + describe detailed aspects of the design decision, and in + particular contain useful sections on Ada 83 compatibility. + + * `DEC Ada, Technical Overview and Comparison on DIGITAL Platforms', + which contains specific information on compatibility between GNAT + and DEC Ada 83 systems. + + * `DEC Ada, Language Reference Manual, part number AA-PYZAB-TK' which + describes in detail the pragmas and attributes provided by the DEC + Ada 83 compiler system. + + +  + File: gnat_rm.info, Node: Implementation Defined Pragmas, Next: Implementation Defined Attributes, Prev: About This Guide, Up: Top + + Implementation Defined Pragmas + ****************************** + + Ada 95 defines a set of pragmas that can be used to supply additional + information to the compiler. These language defined pragmas are + implemented in GNAT and work as described in the Ada 95 Reference + Manual. + + In addition, Ada 95 allows implementations to define additional + pragmas whose meaning is defined by the implementation. GNAT provides + a number of these implementation-dependent pragmas which can be used to + extend and enhance the functionality of the compiler. This section of + the GNAT Reference Manual describes these additional pragmas. + + Note that any program using these pragmas may not be portable to + other compilers (although GNAT implements this set of pragmas on all + platforms). Therefore if portability to other compilers is an important + consideration, the use of these pragmas should be minimized. + + `pragma Abort_Defer' + Syntax: + + pragma Abort_Defer; + + This pragma must appear at the start of the statement sequence of a + handled sequence of statements (right after the `begin'). It has + the effect of deferring aborts for the sequence of statements (but + not for the declarations or handlers, if any, associated with this + statement sequence). + + `pragma Ada_83' + Syntax: + + pragma Ada_83; + + A configuration pragma that establishes Ada 83 mode for the unit to + which it applies, regardless of the mode set by the command line + switches. In Ada 83 mode, GNAT attempts to be as compatible with + the syntax and semantics of Ada 83, as defined in the original Ada + 83 Reference Manual as possible. In particular, the new Ada 95 + keywords are not recognized, optional package bodies are allowed, + and generics may name types with unknown discriminants without + using the `(<>)' notation. In addition, some but not all of the + additional restrictions of Ada 83 are enforced. + + Ada 83 mode is intended for two purposes. Firstly, it allows + existing legacy Ada 83 code to be compiled and adapted to GNAT + with less effort. Secondly, it aids in keeping code backwards + compatible with Ada 83. However, there is no guarantee that code + that is processed correctly by GNAT in Ada 83 mode will in fact + compile and execute with an Ada 83 compiler, since GNAT does not + enforce all the additional checks required by Ada 83. + + `pragma Ada_95' + Syntax: + + pragma Ada_95; + + A configuration pragma that establishes Ada 95 mode for the unit + to which it applies, regardless of the mode set by the command + line switches. This mode is set automatically for the `Ada' and + `System' packages and their children, so you need not specify it + in these contexts. This pragma is useful when writing a reusable + component that itself uses Ada 95 features, but which is intended + to be usable from either Ada 83 or Ada 95 programs. + + `pragma Annotate' + Syntax: + + pragma Annotate (IDENTIFIER {, ARG}); + + ARG ::= NAME | EXPRESSION + + This pragma is used to annotate programs. IDENTIFIER identifies + the type of annotation. GNAT verifies this is an identifier, but + does not otherwise analyze it. The ARG argument can be either a + string literal or an expression. String literals are assumed to + be of type `Standard.String'. Names of entities are simply + analyzed as entity names. All other expressions are analyzed as + expressions, and must be unambiguous. + + The analyzed pragma is retained in the tree, but not otherwise + processed by any part of the GNAT compiler. This pragma is + intended for use by external tools, including ASIS. + + `pragma Assert' + Syntax: + + pragma Assert ( + boolean_EXPRESSION + [, static_string_EXPRESSION]) + + The effect of this pragma depends on whether the corresponding + command line switch is set to activate assertions. The pragma + expands into code equivalent to the following: + + if assertions-enabled then + if not boolean_EXPRESSION then + System.Assertions.Raise_Assert_Failure + (string_EXPRESSION); + end if; + end if; + + The string argument, if given, is the message that will be + associated with the exception occurrence if the exception is + raised. If no second argument is given, the default message is + `FILE:NNN', where FILE is the name of the source file containing + the assert, and NNN is the line number of the assert. A pragma is + not a statement, so if a statement sequence contains nothing but a + pragma assert, then a null statement is required in addition, as + in: + + ... + if J > 3 then + pragma Assert (K > 3, "Bad value for K"); + null; + end if; + + Note that, as with the `if' statement to which it is equivalent, + the type of the expression is either `Standard.Boolean', or any + type derived from this standard type. + + If assertions are disabled (switch `-gnata' not used), then there + is no effect (and in particular, any side effects from the + expression are suppressed). More precisely it is not quite true + that the pragma has no effect, since the expression is analyzed, + and may cause types to be frozen if they are mentioned here for + the first time. + + If assertions are enabled, then the given expression is tested, + and if it is `False' then `System.Assertions.Raise_Assert_Failure' + is called which results in the raising of `Assert_Failure' with + the given message. + + If the boolean expression has side effects, these side effects + will turn on and off with the setting of the assertions mode, + resulting in assertions that have an effect on the program. You + should generally avoid side effects in the expression arguments of + this pragma. However, the expressions are analyzed for semantic + correctness whether or not assertions are enabled, so turning + assertions on and off cannot affect the legality of a program. + + `pragma Ast_Entry' + Syntax: + + pragma AST_Entry (entry_IDENTIFIER); + + This pragma is implemented only in the OpenVMS implementation of + GNAT. The argument is the simple name of a single entry; at most + one `AST_Entry' pragma is allowed for any given entry. This + pragma must be used in conjunction with the `AST_Entry' attribute, + and is only allowed after the entry declaration and in the same + task type specification or single task as the entry to which it + applies. This pragma specifies that the given entry may be used + to handle an OpenVMS asynchronous system trap (`AST') resulting + from an OpenVMS system service call. The pragma does not affect + normal use of the entry. For further details on this pragma, see + the DEC Ada Language Reference Manual, section 9.12a. + + `pragma C_Pass_By_Copy' + Syntax: + + pragma C_Pass_By_Copy + ([Max_Size =>] static_integer_EXPRESSION); + + Normally the default mechanism for passing C convention records to + C convention subprograms is to pass them by reference, as + suggested by RM B.3(69). Use the configuration pragma + `C_Pass_By_Copy' to change this default, by requiring that record + formal parameters be passed by copy if all of the following + conditions are met: + + * The size of the record type does not exceed + STATIC_INTEGER_EXPRESSION. + + * The record type has `Convention C'. + + * The formal parameter has this record type, and the subprogram + has a foreign (non-Ada) convention. + + If these conditions are met the argument is passed by copy, i.e. + in a manner consistent with what C expects if the corresponding + formal in the C prototype is a struct (rather than a pointer to a + struct). + + You can also pass records by copy by specifying the convention + `C_Pass_By_Copy' for the record type, or by using the extended + `Import' and `Export' pragmas, which allow specification of + passing mechanisms on a parameter by parameter basis. + + `pragma Comment' + Syntax: + + pragma Comment (static_string_EXPRESSION); + + This is almost identical in effect to pragma `Ident'. It allows + the placement of a comment into the object file and hence into the + executable file if the operating system permits such usage. The + difference is that `Comment', unlike `Ident', has no limit on the + length of the string argument, and no limitations on placement of + the pragma (it can be placed anywhere in the main source unit). + + `pragma Common_Object' + Syntax: + + pragma Common_Object ( + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL] + [, [Size =>] EXTERNAL_SYMBOL] ) + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + This pragma enables the shared use of variables stored in overlaid + linker areas corresponding to the use of `COMMON' in Fortran. The + single object LOCAL_NAME is assigned to the area designated by the + EXTERNAL argument. You may define a record to correspond to a + series of fields. The SIZE argument is syntax checked in GNAT, + but otherwise ignored. + + `Common_Object' is not supported on all platforms. If no support + is available, then the code generator will issue a message + indicating that the necessary attribute for implementation of this + pragma is not available. + + `pragma Complex_Representation' + Syntax: + + pragma Complex_Representation + ([Entity =>] LOCAL_NAME); + + The ENTITY argument must be the name of a record type which has + two fields of the same floating-point type. The effect of this + pragma is to force gcc to use the special internal complex + representation form for this record, which may be more efficient. + Note that this may result in the code for this type not conforming + to standard ABI (application binary interface) requirements for + the handling of record types. For example, in some environments, + there is a requirement for passing records by pointer, and the use + of this pragma may result in passing this type in floating-point + registers. + + `pragma Component_Alignment' + Syntax: + + pragma Component_Alignment ( + [Form =>] ALIGNMENT_CHOICE + [, [Name =>] type_LOCAL_NAME]); + + ALIGNMENT_CHOICE ::= + Component_Size + | Component_Size_4 + | Storage_Unit + | Default + + Specifies the alignment of components in array or record types. + The meaning of the FORM argument is as follows: + + `Component_Size' + Aligns scalar components and subcomponents of the array or + record type on boundaries appropriate to their inherent size + (naturally aligned). For example, 1-byte components are + aligned on byte boundaries, 2-byte integer components are + aligned on 2-byte boundaries, 4-byte integer components are + aligned on 4-byte boundaries and so on. These alignment + rules correspond to the normal rules for C compilers on all + machines except the VAX. + + `Component_Size_4' + Naturally aligns components with a size of four or fewer + bytes. Components that are larger than 4 bytes are placed on + the next 4-byte boundary. + + `Storage_Unit' + Specifies that array or record components are byte aligned, + i.e. aligned on boundaries determined by the value of the + constant `System.Storage_Unit'. + + `Default' + Specifies that array or record components are aligned on + default boundaries, appropriate to the underlying hardware or + operating system or both. For OpenVMS VAX systems, the + `Default' choice is the same as the `Storage_Unit' choice + (byte alignment). For all other systems, the `Default' + choice is the same as `Component_Size' (natural alignment). + + If the `Name' parameter is present, TYPE_LOCAL_NAME must refer to + a local record or array type, and the specified alignment choice + applies to the specified type. The use of `Component_Alignment' + together with a pragma `Pack' causes the `Component_Alignment' + pragma to be ignored. The use of `Component_Alignment' together + with a record representation clause is only effective for fields + not specified by the representation clause. + + If the `Name' parameter is absent, the pragma can be used as either + a configuration pragma, in which case it applies to one or more + units in accordance with the normal rules for configuration + pragmas, or it can be used within a declarative part, in which + case it applies to types that are declared within this declarative + part, or within any nested scope within this declarative part. In + either case it specifies the alignment to be applied to any record + or array type which has otherwise standard representation. + + If the alignment for a record or array type is not specified (using + pragma `Pack', pragma `Component_Alignment', or a record rep + clause), the GNAT uses the default alignment as described + previously. + + `pragma Convention_Identifier' + Syntax: + + pragma Convention_Identifier ( + [Name =>] IDENTIFIER, + [Convention =>] convention_IDENTIFIER); + + This pragma provides a mechanism for supplying synonyms for + existing convention identifiers. The `Name' identifier can + subsequently be used as a synonym for the given convention in + other pragmas (including for example pragma `Import' or another + `Convention_Identifier' pragma). As an example of the use of this, + suppose you had legacy code which used Fortran77 as the identifier + for Fortran. Then the pragma: + + pragma Convention_Indentifier (Fortran77, Fortran); + + would allow the use of the convention identifier `Fortran77' in + subsequent code, avoiding the need to modify the sources. As + another example, you could use this to parametrize convention + requirements according to systems. Suppose you needed to use + `Stdcall' on windows systems, and `C' on some other system, then + you could define a convention identifier `Library' and use a single + `Convention_Identifier' pragma to specify which convention would + be used system-wide. + + `pragma CPP_Class' + Syntax: + + pragma CPP_Class ([Entity =>] LOCAL_NAME); + + The argument denotes an entity in the current declarative region + that is declared as a tagged or untagged record type. It + indicates that the type corresponds to an externally declared C++ + class type, and is to be laid out the same way that C++ would lay + out the type. + + If (and only if) the type is tagged, at least one component in the + record must be of type `Interfaces.CPP.Vtable_Ptr', corresponding + to the C++ Vtable (or Vtables in the case of multiple inheritance) + used for dispatching. + + Types for which `CPP_Class' is specified do not have assignment or + equality operators defined (such operations can be imported or + declared as subprograms as required). Initialization is allowed + only by constructor functions (see pragma `CPP_Constructor'). + + Pragma `CPP_Class' is intended primarily for automatic generation + using an automatic binding generator tool. See *Note Interfacing + to C++:: for related information. + + `pragma CPP_Constructor' + Syntax: + + pragma CPP_Constructor ([Entity =>] LOCAL_NAME); + + This pragma identifies an imported function (imported in the usual + way with pragma `Import') as corresponding to a C++ constructor. + The argument is a name that must have been previously mentioned in + a pragma `Import' with `Convention' = `CPP', and must be of one of + the following forms: + + * `function FNAME return T'Class' + + * `function FNAME (...) return T'Class' + + where T is a tagged type to which the pragma `CPP_Class' applies. + + The first form is the default constructor, used when an object of + type T is created on the Ada side with no explicit constructor. + Other constructors (including the copy constructor, which is + simply a special case of the second form in which the one and only + argument is of type T), can only appear in two contexts: + + * On the right side of an initialization of an object of type T. + + * In an extension aggregate for an object of a type derived + from T. + + Although the constructor is described as a function that returns a + value on the Ada side, it is typically a procedure with an extra + implicit argument (the object being initialized) at the + implementation level. GNAT issues the appropriate call, whatever + it is, to get the object properly initialized. + + In the case of derived objects, you may use one of two possible + forms for declaring and creating an object: + + * `New_Object : Derived_T' + + * `New_Object : Derived_T := (CONSTRUCTOR-FUNCTION-CALL WITH + ...)' + + In the first case the default constructor is called and extension + fields if any are initialized according to the default + initialization expressions in the Ada declaration. In the second + case, the given constructor is called and the extension aggregate + indicates the explicit values of the extension fields. + + If no constructors are imported, it is impossible to create any + objects on the Ada side. If no default constructor is imported, + only the initialization forms using an explicit call to a + constructor are permitted. + + Pragma `CPP_Constructor' is intended primarily for automatic + generation using an automatic binding generator tool. See *Note + Interfacing to C++:: for more related information. + + `pragma CPP_Virtual' + Syntax: + + pragma CPP_Virtual + [Entity =>] ENTITY, + [, [Vtable_Ptr =>] vtable_ENTITY,] + [, [Position =>] static_integer_EXPRESSION]) + + This pragma serves the same function as pragma `Import' in that + case of a virtual function imported from C++. The ENTITY argument + must be a primitive subprogram of a tagged type to which pragma + `CPP_Class' applies. The VTABLE_PTR argument specifies the + Vtable_Ptr component which contains the entry for this virtual + function. The POSITION argument is the sequential number counting + virtual functions for this Vtable starting at 1. + + The `Vtable_Ptr' and `Position' arguments may be omitted if there + is one Vtable_Ptr present (single inheritance case) and all + virtual functions are imported. In that case the compiler can + deduce both these values. + + No `External_Name' or `Link_Name' arguments are required for a + virtual function, since it is always accessed indirectly via the + appropriate Vtable entry. + + Pragma `CPP_Virtual' is intended primarily for automatic generation + using an automatic binding generator tool. See *Note Interfacing + to C++:: for related information. + + `pragma CPP_Vtable' + Syntax: + + pragma CPP_Vtable ( + [Entity =>] ENTITY, + [Vtable_Ptr =>] vtable_ENTITY, + [Entry_Count =>] static_integer_EXPRESSION); + + Given a record to which the pragma `CPP_Class' applies, this + pragma can be specified for each component of type + `CPP.Interfaces.Vtable_Ptr'. ENTITY is the tagged type, VTABLE_PTR + is the record field of type `Vtable_Ptr', and ENTRY_COUNT is the + number of virtual functions on the C++ side. Not all of these + functions need to be imported on the Ada side. + + You may omit the `CPP_Vtable' pragma if there is only one + `Vtable_Ptr' component in the record and all virtual functions are + imported on the Ada side (the default value for the entry count in + this case is simply the total number of virtual functions). + + Pragma `CPP_Vtable' is intended primarily for automatic generation + using an automatic binding generator tool. See *Note Interfacing + to C++:: for related information. + + `pragma Debug' + Syntax: + + pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON); + + PROCEDURE_CALL_WITHOUT_SEMICOLON ::= + PROCEDURE_NAME + | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART + + The argument has the syntactic form of an expression, meeting the + syntactic requirements for pragmas. + + If assertions are not enabled on the command line, this pragma has + no effect. If asserts are enabled, the semantics of the pragma is + exactly equivalent to the procedure call statement corresponding + to the argument with a terminating semicolon. Pragmas are + permitted in sequences of declarations, so you can use pragma + `Debug' to intersperse calls to debug procedures in the middle of + declarations. + + `pragma Elaboration_Checks' + Syntax: + + pragma Elaboration_Checks (RM | Static); + + This is a configuration pragma that provides control over the + elaboration model used by the compilation affected by the pragma. + If the parameter is RM, then the dynamic elaboration model + described in the Ada Reference Manual is used, as though the + `-gnatE' switch had been specified on the command line. If the + parameter is Static, then the default GNAT static model is used. + This configuration pragma overrides the setting of the command + line. For full details on the elaboration models used by the GNAT + compiler, see section "Elaboration Order Handling in GNAT" in the + `GNAT User's Guide'. + + `pragma Eliminate' + Syntax: + + pragma Eliminate ( + [Unit_Name =>] IDENTIFIER | + SELECTED_COMPONENT); + + pragma Eliminate ( + [Unit_Name =>] IDENTIFIER | + SELECTED_COMPONENT, + [Entity =>] IDENTIFIER | + SELECTED_COMPONENT | + STRING_LITERAL + [,[Parameter_Types =>] PARAMETER_TYPES] + [,[Result_Type =>] result_SUBTYPE_NAME] + [,[Homonym_Number =>] INTEGER_LITERAL]); + + PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME}) + SUBTYPE_NAME ::= STRING_LITERAL + + This pragma indicates that the given entity is not used outside the + compilation unit it is defined in. The entity may be either a + subprogram or a variable. + + If the entity to be eliminated is a library level subprogram, then + the first form of pragma `Eliminate' is used with only a single + argument. In this form, the `Unit_Name' argument specifies the + name of the library level unit to be eliminated. + + In all other cases, both `Unit_Name' and `Entity' arguments are + required. item is an entity of a library package, then the first + argument specifies the unit name, and the second argument specifies + the particular entity. If the second argument is in string form, + it must correspond to the internal manner in which GNAT stores + entity names (see compilation unit Namet in the compiler sources + for details). + + The remaining parameters are optionally used to distinguish + between overloaded subprograms. There are two ways of doing this. + + Use `Parameter_Types' and `Result_Type' to specify the profile of + the subprogram to be eliminated in a manner similar to that used + for the extended `Import' and `Export' pragmas, except that the + subtype names are always given as string literals, again + corresponding to the internal manner in which GNAT stores entity + names. + + Alternatively, the `Homonym_Number' parameter is used to specify + which overloaded alternative is to be eliminated. A value of 1 + indicates the first subprogram (in lexical order), 2 indicates the + second etc. + + The effect of the pragma is to allow the compiler to eliminate the + code or data associated with the named entity. Any reference to + an eliminated entity outside the compilation unit it is defined in, + causes a compile time or link time error. + + The parameters of this pragma may be given in any order, as long as + the usual rules for use of named parameters and position parameters + are used. + + The intention of pragma `Eliminate' is to allow a program to be + compiled in a system independent manner, with unused entities + eliminated, without the requirement of modifying the source text. + Normally the required set of `Eliminate' pragmas is constructed + automatically using the gnatelim tool. Elimination of unused + entities local to a compilation unit is automatic, without + requiring the use of pragma `Eliminate'. + + Note that the reason this pragma takes string literals where names + might be expected is that a pragma `Eliminate' can appear in a + context where the relevant names are not visible. + + `pragma Export_Exception' + Syntax: + + pragma Export_Exception ( + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL,] + [, [Form =>] Ada | VMS] + [, [Code =>] static_integer_EXPRESSION]); + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + This pragma is implemented only in the OpenVMS implementation of + GNAT. It causes the specified exception to be propagated outside + of the Ada program, so that it can be handled by programs written + in other OpenVMS languages. This pragma establishes an external + name for an Ada exception and makes the name available to the + OpenVMS Linker as a global symbol. For further details on this + pragma, see the DEC Ada Language Reference Manual, section + 13.9a3.2. + + `pragma Export_Function ...' + Syntax: + + pragma Export_Function ( + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL] + [, [Parameter_Types =>] PARAMETER_TYPES] + [, [Result_Type =>] result_SUBTYPE_MARK] + [, [Mechanism =>] MECHANISM] + [, [Result_Mechanism =>] MECHANISM_NAME]); + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + PARAMETER_TYPES ::= + null + | SUBTYPE_MARK {, SUBTYPE_MARK} + + MECHANISM ::= + MECHANISM_NAME + | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION}) + + MECHANISM_ASSOCIATION ::= + [formal_parameter_NAME =>] MECHANISM_NAME + + MECHANISM_NAME ::= + Value + | Reference + | Descriptor [([Class =>] CLASS_NAME)] + + CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca + + Use this pragma to make a function externally callable and + optionally provide information on mechanisms to be used for + passing parameter and result values. We recommend, for the + purposes of improving portability, this pragma always be used in + conjunction with a separate pragma `Export', which must precede + the pragma `Export_Function'. GNAT does not require a separate + pragma `Export', but if none is present, `Convention Ada' is + assumed, which is usually not what is wanted, so it is usually + appropriate to use this pragma in conjunction with a `Export' or + `Convention' pragma that specifies the desired foreign convention. + Pragma `Export_Function' (and `Export', if present) must appear in + the same declarative region as the function to which they apply. + + INTERNAL_NAME must uniquely designate the function to which the + pragma applies. If more than one function name exists of this + name in the declarative part you must use the `Parameter_Types' and + `Result_Type' parameters is mandatory to achieve the required + unique designation. SUBTYPE_ MARKs in these parameters must + exactly match the subtypes in the corresponding function + specification, using positional notation to match parameters with + subtype marks. Passing by descriptor is supported only on the + OpenVMS ports of GNAT. + + `pragma Export_Object ...' + Syntax: + + pragma Export_Object + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL] + [, [Size =>] EXTERNAL_SYMBOL] + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + This pragma designates an object as exported, and apart from the + extended rules for external symbols, is identical in effect to the + use of the normal `Export' pragma applied to an object. You may + use a separate Export pragma (and you probably should from the + point of view of portability), but it is not required. SIZE is + syntax checked, but otherwise ignored by GNAT. + + `pragma Export_Procedure ...' + Syntax: + + pragma Export_Procedure ( + [Internal =>] LOCAL_NAME + [, [External =>] EXTERNAL_SYMBOL] + [, [Parameter_Types =>] PARAMETER_TYPES] + [, [Mechanism =>] MECHANISM]); + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + PARAMETER_TYPES ::= + null + | SUBTYPE_MARK {, SUBTYPE_MARK} + + MECHANISM ::= + MECHANISM_NAME + | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION}) + + MECHANISM_ASSOCIATION ::= + [formal_parameter_NAME =>] MECHANISM_NAME + + MECHANISM_NAME ::= + Value + | Reference + | Descriptor [([Class =>] CLASS_NAME)] + + CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca + + This pragma is identical to `Export_Function' except that it + applies to a procedure rather than a function and the parameters + `Result_Type' and `Result_Mechanism' are not permitted. GNAT does + not require a separate pragma `Export', but if none is present, + `Convention Ada' is assumed, which is usually not what is wanted, + so it is usually appropriate to use this pragma in conjunction + with a `Export' or `Convention' pragma that specifies the desired + foreign convention. + + `pragma Export_Valued_Procedure' + Syntax: + + pragma Export_Valued_Procedure ( + [Internal =>] LOCAL_NAME + [, [External =>] EXTERNAL_SYMBOL] + [, [Parameter_Types =>] PARAMETER_TYPES] + [, [Mechanism =>] MECHANISM]); + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + PARAMETER_TYPES ::= + null + | SUBTYPE_MARK {, SUBTYPE_MARK} + + MECHANISM ::= + MECHANISM_NAME + | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION}) + + MECHANISM_ASSOCIATION ::= + [formal_parameter_NAME =>] MECHANISM_NAME + + MECHANISM_NAME ::= + Value + | Reference + | Descriptor [([Class =>] CLASS_NAME)] + + CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca + + This pragma is identical to `Export_Procedure' except that the + first parameter of LOCAL_NAME, which must be present, must be of + mode `OUT', and externally the subprogram is treated as a function + with this parameter as the result of the function. GNAT provides + for this capability to allow the use of `OUT' and `IN OUT' + parameters in interfacing to external functions (which are not + permitted in Ada functions). GNAT does not require a separate + pragma `Export', but if none is present, `Convention Ada' is + assumed, which is almost certainly not what is wanted since the + whole point of this pragma is to interface with foreign language + functions, so it is usually appropriate to use this pragma in + conjunction with a `Export' or `Convention' pragma that specifies + the desired foreign convention. + + `pragma Extend_System' + Syntax: + + pragma Extend_System ([Name =>] IDENTIFIER); + + This pragma is used to provide backwards compatibility with other + implementations that extend the facilities of package `System'. In + GNAT, `System' contains only the definitions that are present in + the Ada 95 RM. However, other implementations, notably the DEC + Ada 83 implementation, provide many extensions to package `System'. + + For each such implementation accommodated by this pragma, GNAT + provides a package `Aux_XXX', e.g. `Aux_DEC' for the DEC Ada 83 + implementation, which provides the required additional + definitions. You can use this package in two ways. You can + `with' it in the normal way and access entities either by + selection or using a `use' clause. In this case no special + processing is required. + + However, if existing code contains references such as `System.XXX' + where XXX is an entity in the extended definitions provided in + package `System', you may use this pragma to extend visibility in + `System' in a non-standard way that provides greater compatibility + with the existing code. Pragma `Extend_System' is a configuration + pragma whose single argument is the name of the package containing + the extended definition (e.g. `Aux_DEC' for the DEC Ada case). A + unit compiled under control of this pragma will be processed using + special visibility processing that looks in package + `System.Aux_XXX' where `Aux_XXX' is the pragma argument for any + entity referenced in package `System', but not found in package + `System'. + + You can use this pragma either to access a predefined `System' + extension supplied with the compiler, for example `Aux_DEC' or you + can construct your own extension unit following the above + definition. Note that such a package is a child of `System' and + thus is considered part of the implementation. To compile it you + will have to use the appropriate switch for compiling system + units. See the GNAT User's Guide for details. + + `pragma External' + Syntax: + + pragma External ( + [ Convention =>] convention_IDENTIFIER, + [ Entity =>] local_NAME + [, [External_Name =>] static_string_EXPRESSION ] + [, [Link_Name =>] static_string_EXPRESSION ]); + + This pragma is identical in syntax and semantics to pragma + `Export' as defined in the Ada Reference Manual. It is provided + for compatibility with some Ada 83 compilers that used this pragma + for exactly the same purposes as pragma `Export' before the latter + was standardized. + + `pragma External_Name_Casing' + Syntax: + + pragma External_Name_Casing ( + Uppercase | Lowercase + [, Uppercase | Lowercase | As_Is]); + + This pragma provides control over the casing of external names + associated with Import and Export pragmas. There are two cases to + consider: + + Implicit external names + Implicit external names are derived from identifiers. The + most common case arises when a standard Ada 95 Import or + Export pragma is used with only two arguments, as in: + + pragma Import (C, C_Routine); + + Since Ada is a case insensitive language, the spelling of the + identifier in the Ada source program does not provide any + information on the desired casing of the external name, and + so a convention is needed. In GNAT the default treatment is + that such names are converted to all lower case letters. + This corresponds to the normal C style in many environments. + The first argument of pragma `External_Name_Casing' can be + used to control this treatment. If `Uppercase' is specified, + then the name will be forced to all uppercase letters. If + `Lowercase' is specified, then the normal default of all + lower case letters will be used. + + This same implicit treatment is also used in the case of + extended DEC Ada 83 compatible Import and Export pragmas + where an external name is explicitly specified using an + identifier rather than a string. + + Explicit external names + Explicit external names are given as string literals. The + most common case arises when a standard Ada 95 Import or + Export pragma is used with three arguments, as in: + + pragma Import (C, C_Routine, "C_routine"); + + In this case, the string literal normally provides the exact + casing required for the external name. The second argument + of pragma `External_Name_Casing' may be used to modify this + behavior. If `Uppercase' is specified, then the name will be + forced to all uppercase letters. If `Lowercase' is specified, + then the name will be forced to all lowercase letters. A + specification of `As_Is' provides the normal default behavior + in which the casing is taken from the string provided. + + This pragma may appear anywhere that a pragma is valid. In + particular, it can be used as a configuration pragma in the + `gnat.adc' file, in which case it applies to all subsequent + compilations, or it can be used as a program unit pragma, in which + case it only applies to the current unit, or it can be used more + locally to control individual Import/Export pragmas. + + It is primarily intended for use with OpenVMS systems, where many + compilers convert all symbols to upper case by default. For + interfacing to such compilers (e.g. the DEC C compiler), it may be + convenient to use the pragma: + + pragma External_Name_Casing (Uppercase, Uppercase); + + to enforce the upper casing of all external symbols. + + `pragma Finalize_Storage_Only' + Syntax: + + pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME); + + This pragma allows the compiler not to emit a Finalize call for + objects defined at the library level. This is mostly useful for + types where finalization is only used to deal with storage + reclamation since in most environments it is not necessary to + reclaim memory just before terminating execution, hence the name. + + `pragma Float_Representation' + Syntax: + + pragma Float_Representation (FLOAT_REP); + + FLOAT_REP ::= VAX_Float | IEEE_Float + + This pragma is implemented only in the OpenVMS implementation of + GNAT. It allows control over the internal representation chosen + for the predefined floating point types declared in the packages + `Standard' and `System'. For further details on this pragma, see + the DEC Ada Language Reference Manual, section 3.5.7a. Note that + to use this pragma, the standard runtime libraries must be + recompiled. See the description of the `GNAT LIBRARY' command in + the OpenVMS version of the GNAT Users Guide for details on the use + of this command. + + `pragma Ident' + Syntax: + + pragma Ident (static_string_EXPRESSION); + + This pragma provides a string identification in the generated + object file, if the system supports the concept of this kind of + identification string. The maximum permitted length of the string + literal is 31 characters. This pragma is allowed only in the + outermost declarative part or declarative items of a compilation + unit. On OpenVMS systems, the effect of the pragma is identical + to the effect of the DEC Ada 83 pragma of the same name. + + `pragma Import_Exception' + Syntax: + + pragma Import_Exception ( + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL,] + [, [Form =>] Ada | VMS] + [, [Code =>] static_integer_EXPRESSION]); + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + This pragma is implemented only in the OpenVMS implementation of + GNAT. It allows OpenVMS conditions (for example, from OpenVMS + system services or other OpenVMS languages) to be propagated to + Ada programs as Ada exceptions. The pragma specifies that the + exception associated with an exception declaration in an Ada + program be defined externally (in non-Ada code). For further + details on this pragma, see the DEC Ada Language Reference Manual, + section 13.9a.3.1. + + `pragma Import_Function ...' + Syntax: + + pragma Import_Function ( + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL] + [, [Parameter_Types =>] PARAMETER_TYPES] + [, [Result_Type =>] SUBTYPE_MARK] + [, [Mechanism =>] MECHANISM] + [, [Result_Mechanism =>] MECHANISM_NAME] + [, [First_Optional_Parameter =>] IDENTIFIER]); + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + PARAMETER_TYPES ::= + null + | SUBTYPE_MARK {, SUBTYPE_MARK} + + MECHANISM ::= + MECHANISM_NAME + | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION}) + + MECHANISM_ASSOCIATION ::= + [formal_parameter_NAME =>] MECHANISM_NAME + + MECHANISM_NAME ::= + Value + | Reference + | Descriptor [([Class =>] CLASS_NAME)] + + CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca + + This pragma is used in conjunction with a pragma `Import' to + specify additional information for an imported function. The + pragma `Import' (or equivalent pragma `Interface') must precede the + `Import_Function' pragma and both must appear in the same + declarative part as the function specification. + + The INTERNAL_NAME argument must uniquely designate the function to + which the pragma applies. If more than one function name exists + of this name in the declarative part you must use the + `Parameter_Types' and RESULT_TYPE parameters to achieve the + required unique designation. Subtype marks in these parameters + must exactly match the subtypes in the corresponding function + specification, using positional notation to match parameters with + subtype marks. + + You may optionally use the MECHANISM and RESULT_MECHANISM + parameters to specify passing mechanisms for the parameters and + result. If you specify a single mechanism name, it applies to all + parameters. Otherwise you may specify a mechanism on a parameter + by parameter basis using either positional or named notation. If + the mechanism is not specified, the default mechanism is used. + + Passing by descriptor is supported only on the to OpenVMS ports of + GNAT. + + `First_Optional_Parameter' applies only to OpenVMS ports of GNAT. + It specifies that the designated parameter and all following + parameters are optional, meaning that they are not passed at the + generated code level (this is distinct from the notion of optional + parameters in Ada where the parameters are passed anyway with the + designated optional parameters). All optional parameters must be + of mode `IN' and have default parameter values that are either + known at compile time expressions, or uses of the + `'Null_Parameter' attribute. + + `pragma Import_Object' + Syntax: + + pragma Import_Object + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL], + [, [Size =>] EXTERNAL_SYMBOL]) + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + This pragma designates an object as imported, and apart from the + extended rules for external symbols, is identical in effect to the + use of the normal `Import' pragma applied to an object. Unlike the + subprogram case, you need not use a separate `Import' pragma, + although you may do so (and probably should do so from a + portability point of view). SIZE is syntax checked, but otherwise + ignored by GNAT. + + `pragma Import_Procedure' + Syntax: + + pragma Import_Procedure ( + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL] + [, [Parameter_Types =>] PARAMETER_TYPES] + [, [Mechanism =>] MECHANISM] + [, [First_Optional_Parameter =>] IDENTIFIER]); + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + PARAMETER_TYPES ::= + null + | SUBTYPE_MARK {, SUBTYPE_MARK} + + MECHANISM ::= + MECHANISM_NAME + | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION}) + + MECHANISM_ASSOCIATION ::= + [formal_parameter_NAME =>] MECHANISM_NAME + + MECHANISM_NAME ::= + Value + | Reference + | Descriptor [([Class =>] CLASS_NAME)] + + CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca + + This pragma is identical to `Import_Function' except that it + applies to a procedure rather than a function and the parameters + `Result_Type' and `Result_Mechanism' are not permitted. + + `pragma Import_Valued_Procedure ...' + Syntax: + + pragma Import_Valued_Procedure ( + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL] + [, [Parameter_Types =>] PARAMETER_TYPES] + [, [Mechanism =>] MECHANISM] + [, [First_Optional_Parameter =>] IDENTIFIER]); + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + PARAMETER_TYPES ::= + null + | SUBTYPE_MARK {, SUBTYPE_MARK} + + MECHANISM ::= + MECHANISM_NAME + | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION}) + + MECHANISM_ASSOCIATION ::= + [formal_parameter_NAME =>] MECHANISM_NAME + + MECHANISM_NAME ::= + Value + | Reference + | Descriptor [([Class =>] CLASS_NAME)] + + CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca + + This pragma is identical to `Import_Procedure' except that the + first parameter of LOCAL_NAME, which must be present, must be of + mode `OUT', and externally the subprogram is treated as a function + with this parameter as the result of the function. The purpose of + this capability is to allow the use of `OUT' and `IN OUT' + parameters in interfacing to external functions (which are not + permitted in Ada functions). You may optionally use the + `Mechanism' parameters to specify passing mechanisms for the + parameters. If you specify a single mechanism name, it applies to + all parameters. Otherwise you may specify a mechanism on a + parameter by parameter basis using either positional or named + notation. If the mechanism is not specified, the default + mechanism is used. + + Note that it is important to use this pragma in conjunction with a + separate pragma Import that specifies the desired convention, + since otherwise the default convention is Ada, which is almost + certainly not what is required. + + `pragma Initialize_Scalars' + Syntax: + + pragma Initialize_Scalars; + + This pragma is similar to `Normalize_Scalars' conceptually but has + two important differences. First, there is no requirement for the + pragma to be used uniformly in all units of a partition, in + particular, it is fine to use this just for some or all of the + application units of a partition, without needing to recompile the + run-time library. + + In the case where some units are compiled with the pragma, and + some without, then a declaration of a variable where the type is + defined in package Standard or is locally declared will always be + subject to initialization, as will any declaration of a scalar + variable. For composite variables, whether the variable is + initialized may also depend on whether the package in which the + type of the variable is declared is compiled with the pragma. + + The other important difference is that there is control over the + value used for initializing scalar objects. At bind time, you can + select whether to initialize with invalid values (like + Normalize_Scalars), or with high or low values, or with a + specified bit pattern. See the users guide for binder options for + specifying these cases. + + This means that you can compile a program, and then without having + to recompile the program, you can run it with different values + being used for initializing otherwise uninitialized values, to + test if your program behavior depends on the choice. Of course + the behavior should not change, and if it does, then most likely + you have an erroneous reference to an uninitialized value. + + Note that pragma `Initialize_Scalars' is particularly useful in + conjunction with the enhanced validity checking that is now + provided in GNAT, which checks for invalid values under more + conditions. Using this feature (see description of the `-gnatv' + flag in the users guide) in conjunction with pragma + `Initialize_Scalars' provides a powerful new tool to assist in the + detection of problems caused by uninitialized variables. + + `pragma Inline_Always' + Syntax: + + pragma Inline_Always (NAME [, NAME]); + + Similar to pragma `Inline' except that inlining is not subject to + the use of option `-gnatn' for inter-unit inlining. + + `pragma Inline_Generic' + Syntax: + + pragma Inline_Generic (generic_package_NAME) + + This is implemented for compatibility with DEC Ada 83 and is + recognized, but otherwise ignored, by GNAT. All generic + instantiations are inlined by default when using GNAT. + + `pragma Interface' + Syntax: + + pragma Interface ( + [Convention =>] convention_identifier, + [Entity =>] local_name + [, [External_Name =>] static_string_expression], + [, [Link_Name =>] static_string_expression]); + + This pragma is identical in syntax and semantics to the standard + Ada 95 pragma `Import'. It is provided for compatibility with Ada + 83. The definition is upwards compatible both with pragma + `Interface' as defined in the Ada 83 Reference Manual, and also + with some extended implementations of this pragma in certain Ada 83 + implementations. + + `pragma Interface_Name' + Syntax: + + pragma Interface_Name ( + [Entity =>] LOCAL_NAME + [, [External_Name =>] static_string_EXPRESSION] + [, [Link_Name =>] static_string_EXPRESSION]); + + This pragma provides an alternative way of specifying the + interface name for an interfaced subprogram, and is provided for + compatibility with Ada 83 compilers that use the pragma for this + purpose. You must provide at least one of EXTERNAL_NAME or + LINK_NAME. + + `pragma License' + Syntax: + + pragma License (Unrestricted | GPL | Modified_GPL | Restricted); + + This pragma is provided to allow automated checking for + appropriate license conditions with respect to the standard and + modified GPL. A pragma `License', which is a configuration pragma + that typically appears at the start of a source file or in a + separate `gnat.adc' file, specifies the licensing conditions of a + unit as follows: + + * Unrestricted This is used for a unit that can be freely used + with no license restrictions. Examples of such units are + public domain units, and units from the Ada Reference Manual. + + * GPL This is used for a unit that is licensed under the + unmodified GPL, and which therefore cannot be `with''ed by a + restricted unit. + + * Modified_GPL This is used for a unit licensed under the GNAT + modified GPL that includes a special exception paragraph that + specifically permits the inclusion of the unit in programs + without requiring the entire program to be released under the + GPL. This is the license used for the GNAT run-time which + ensures that the run-time can be used freely in any program + without GPL concerns. + + * Restricted This is used for a unit that is restricted in that + it is not permitted to depend on units that are licensed + under the GPL. Typical examples are proprietary code that is + to be released under more restrictive license conditions. + Note that restricted units are permitted to `with' units + which are licensed under the modified GPL (this is the whole + point of the modified GPL). + + + Normally a unit with no `License' pragma is considered to have an + unknown license, and no checking is done. However, standard GNAT + headers are recognized, and license information is derived from + them as follows. + + A GNAT license header starts with a line containing 78 + hyphens. The following comment text is searched for the + appearence of any of the following strings. + + If the string "GNU General Public License" is found, then the + unit is assumed to have GPL license, unless the string "As a + special exception" follows, in which case the license is + assumed to be modified GPL. + + If one of the strings "This specification is adapated from + the Ada Semantic Interface" or "This specification is derived + from the Ada Reference Manual" is found then the unit is + assumed to be unrestricted. + + These default actions means that a program with a restricted + license pragma will automatically get warnings if a GPL unit is + inappropriately `with''ed. For example, the program: + + with Sem_Ch3; + with GNAT.Sockets; + procedure Secret_Stuff is + ... + end Secret_Stuff + + if compiled with pragma `License' (`Restricted') in a `gnat.adc' + file will generate the warning: + + 1. with Sem_Ch3; + | + >>> license of withed unit "Sem_Ch3" is incompatible + + 2. with GNAT.Sockets; + 3. procedure Secret_Stuff is + + Here we get a warning on `Sem_Ch3' since it is part of the GNAT + compiler and is licensed under the GPL, but no warning for + `GNAT.Sockets' which is part of the GNAT run time, and is + therefore licensed under the modified GPL. + + `pragma Link_With' + Syntax: + + pragma Link_With (static_string_EXPRESSION {,static_string_EXPRESSION}); + + This pragma is provided for compatibility with certain Ada 83 + compilers. It has exactly the same effect as pragma + `Linker_Options' except that spaces occurring within one of the + string expressions are treated as separators. For example, in the + following case: + + pragma Link_With ("-labc -ldef"); + + results in passing the strings `-labc' and `-ldef' as two separate + arguments to the linker. In addition pragma Link_With allows + multiple arguments, with the same effect as successive pragmas. + + `pragma Linker_Alias' + Syntax: + + pragma Linker_Alias ( + [Entity =>] LOCAL_NAME + [Alias =>] static_string_EXPRESSION); + + This pragma establishes a linker alias for the given named entity. + For further details on the exact effect, consult the GCC manual. + + `pragma Linker_Section' + Syntax: + + pragma Linker_Section ( + [Entity =>] LOCAL_NAME + [Section =>] static_string_EXPRESSION); + + This pragma specifies the name of the linker section for the given + entity. For further details on the exact effect, consult the GCC + manual. + + `pragma No_Run_Time' + Syntax: + + pragma No_Run_Time; + + This is a configuration pragma that makes sure the user code does + not use nor need anything from the GNAT run time. This is mostly + useful in context where code certification is required. Please + consult the `GNAT Pro High-Integrity Edition User's Guide' for + additional information. + + `pragma Normalize_Scalars' + Syntax: + + pragma Normalize_Scalars; + + This is a language defined pragma which is fully implemented in + GNAT. The effect is to cause all scalar objects that are not + otherwise initialized to be initialized. The initial values are + implementation dependent and are as follows: + + `Standard.Character' + Objects whose root type is Standard.Character are initialized + to Character'Last. This will be out of range of the subtype + only if the subtype range excludes this value. + + `Standard.Wide_Character' + Objects whose root type is Standard.Wide_Character are + initialized to Wide_Character'Last. This will be out of + range of the subtype only if the subtype range excludes this + value. + + `Integer types' + Objects of an integer type are initialized to + base_type'First, where base_type is the base type of the + object type. This will be out of range of the subtype only + if the subtype range excludes this value. For example, if + you declare the subtype: + + subtype Ityp is integer range 1 .. 10; + + then objects of type x will be initialized to Integer'First, + a negative number that is certainly outside the range of + subtype `Ityp'. + + `Real types' + Objects of all real types (fixed and floating) are + initialized to base_type'First, where base_Type is the base + type of the object type. This will be out of range of the + subtype only if the subtype range excludes this value. + + `Modular types' + Objects of a modular type are initialized to typ'Last. This + will be out of range of the subtype only if the subtype + excludes this value. + + `Enumeration types' + Objects of an enumeration type are initialized to all + one-bits, i.e. to the value `2 ** typ'Size - 1'. This will + be out of range of the enumeration subtype in all cases + except where the subtype contains exactly 2**8, 2**16, or + 2**32 elements. + + `pragma Long_Float' + Syntax: + + pragma Long_Float (FLOAT_FORMAT); + + FLOAT_FORMAT ::= D_Float | G_Float + + This pragma is implemented only in the OpenVMS implementation of + GNAT. It allows control over the internal representation chosen + for the predefined type `Long_Float' and for floating point type + representations with `digits' specified in the range 7 through 15. + For further details on this pragma, see the `DEC Ada Language + Reference Manual', section 3.5.7b. Note that to use this pragma, + the standard runtime libraries must be recompiled. See the + description of the `GNAT LIBRARY' command in the OpenVMS version + of the GNAT User's Guide for details on the use of this command. + + `pragma Machine_Attribute ...' + Syntax: + + pragma Machine_Attribute ( + [Attribute_Name =>] string_EXPRESSION, + [Entity =>] LOCAL_NAME); + + Machine dependent attributes can be specified for types and/or + declarations. Currently only subprogram entities are supported. + This pragma is semantically equivalent to + `__attribute__((STRING_EXPRESSION))' in GNU C, where + `STRING_EXPRESSION' is recognized by the GNU C macros + `VALID_MACHINE_TYPE_ATTRIBUTE' and `VALID_MACHINE_DECL_ATTRIBUTE' + which are defined in the configuration header file `tm.h' for each + machine. See the GCC manual for further information. + + `pragma Main_Storage' + Syntax: + + pragma Main_Storage + (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]); + + MAIN_STORAGE_OPTION ::= + [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION + | [TOP_GUARD =>] static_SIMPLE_EXPRESSION + + This pragma is provided for compatibility with OpenVMS Vax + Systems. It has no effect in GNAT, other than being syntax + checked. Note that the pragma also has no effect in DEC Ada 83 + for OpenVMS Alpha Systems. + + `pragma No_Return' + Syntax: + + pragma No_Return (procedure_LOCAL_NAME); + + PROCEDURE_LOCAL_NAME must refer to one or more procedure + declarations in the current declarative part. A procedure to + which this pragma is applied may not contain any explicit `return' + statements, and also may not contain any implicit return + statements from falling off the end of a statement sequence. One + use of this pragma is to identify procedures whose only purpose is + to raise an exception. + + Another use of this pragma is to suppress incorrect warnings about + missing returns in functions, where the last statement of a + function statement sequence is a call to such a procedure. + + `pragma Passive' + Syntax: + + pragma Passive ([Semaphore | No]); + + Syntax checked, but otherwise ignored by GNAT. This is recognized + for compatibility with DEC Ada 83 implementations, where it is + used within a task definition to request that a task be made + passive. If the argument `Semaphore' is present, or no argument + is omitted, then DEC Ada 83 treats the pragma as an assertion that + the containing task is passive and that optimization of context + switch with this task is permitted and desired. If the argument + `No' is present, the task must not be optimized. GNAT does not + attempt to optimize any tasks in this manner (since protected + objects are available in place of passive tasks). + + `pragma Polling' + Syntax: + + pragma Polling (ON | OFF); + + This pragma controls the generation of polling code. This is + normally off. If `pragma Polling (ON)' is used then periodic + calls are generated to the routine `Ada.Exceptions.Poll'. This + routine is a separate unit in the runtime library, and can be + found in file `a-excpol.adb'. + + Pragma `Polling' can appear as a configuration pragma (for example + it can be placed in the `gnat.adc' file) to enable polling + globally, or it can be used in the statement or declaration + sequence to control polling more locally. + + A call to the polling routine is generated at the start of every + loop and at the start of every subprogram call. This guarantees + that the `Poll' routine is called frequently, and places an upper + bound (determined by the complexity of the code) on the period + between two `Poll' calls. + + The primary purpose of the polling interface is to enable + asynchronous aborts on targets that cannot otherwise support it + (for example Windows NT), but it may be used for any other purpose + requiring periodic polling. The standard version is null, and can + be replaced by a user program. This will require re-compilation + of the `Ada.Exceptions' package that can be found in files + `a-except.ads' and `a-except.adb'. + + A standard alternative unit (in file `4wexcpol.adb' in the + standard GNAT distribution) is used to enable the asynchronous + abort capability on targets that do not normally support the + capability. The version of `Poll' in this file makes a call to + the appropriate runtime routine to test for an abort condition. + + Note that polling can also be enabled by use of the `-gnatP' + switch. See the `GNAT User's Guide' for details. + + `pragma Propagate_Exceptions' + Syntax: + + pragma Propagate_Exceptions (subprogram_LOCAL_NAME); + + This pragma indicates that the given entity, which is the name of + an imported foreign-language subprogram may receive an Ada + exception, and that the exception should be propagated. It is + relevant only if zero cost exception handling is in use, and is + thus never needed if the alternative `longjmp' / `setjmp' + implementation of exceptions is used (although it is harmless to + use it in such cases). + + The implementation of fast exceptions always properly propagates + exceptions through Ada code, as described in the Ada Reference + Manual. However, this manual is silent about the propagation of + exceptions through foreign code. For example, consider the + situation where `P1' calls `P2', and `P2' calls `P3', where `P1' + and `P3' are in Ada, but `P2' is in C. `P3' raises an Ada + exception. The question is whether or not it will be propagated + through `P2' and can be handled in `P1'. + + For the `longjmp' / `setjmp' implementation of exceptions, the + answer is always yes. For some targets on which zero cost + exception handling is implemented, the answer is also always yes. + However, there are some targets, notably in the current version + all x86 architecture targets, in which the answer is that such + propagation does not happen automatically. If such propagation is + required on these targets, it is mandatory to use + `Propagate_Exceptions' to name all foreign language routines + through which Ada exceptions may be propagated. + + `pragma Psect_Object' + Syntax: + + pragma Psect_Object + [Internal =>] LOCAL_NAME, + [, [External =>] EXTERNAL_SYMBOL] + [, [Size =>] EXTERNAL_SYMBOL] + + EXTERNAL_SYMBOL ::= + IDENTIFIER + | static_string_EXPRESSION + + This pragma is identical in effect to pragma `Common_Object'. + + `pragma Pure_Function' + Syntax: + + pragma Pure_Function ([Entity =>] function_LOCAL_NAME); + + This pragma appears in the same declarative part as a function + declaration (or a set of function declarations if more than one + overloaded declaration exists, in which case the pragma applies to + all entities). If specifies that the function `Entity' is to be + considered pure for the purposes of code generation. This means + that the compiler can assume that there are no side effects, and + in particular that two calls with identical arguments produce the + same result. It also means that the function can be used in an + address clause. + + Note that, quite deliberately, there are no static checks to try + to ensure that this promise is met, so `Pure_Function' can be used + with functions that are conceptually pure, even if they do modify + global variables. For example, a square root function that is + instrumented to count the number of times it is called is still + conceptually pure, and can still be optimized, even though it + modifies a global variable (the count). Memo functions are another + example (where a table of previous calls is kept and consulted to + avoid re-computation). + + Note: Most functions in a `Pure' package are automatically pure, + and there is no need to use pragma `Pure_Function' for such + functions. An exception is any function that has at least one + formal of type `System.Address' or a type derived from it. Such + functions are not considered pure by default, since the compiler + assumes that the `Address' parameter may be functioning as a + pointer and that the referenced data may change even if the + address value does not. The use of pragma `Pure_Function' for + such a function will override this default assumption, and cause + the compiler to treat such a function as pure. + + Note: If pragma `Pure_Function' is applied to a renamed function, + it applies to the underlying renamed function. This can be used to + disambiguate cases of overloading where some but not all functions + in a set of overloaded functions are to be designated as pure. + + `pragma Ravenscar' + Syntax: + + pragma Ravenscar + + A configuration pragma that establishes the following set of + restrictions: + + `No_Abort_Statements' + [RM D.7] There are no abort_statements, and there are no + calls to Task_Identification.Abort_Task. + + `No_Select_Statements' + There are no select_statements. + + `No_Task_Hierarchy' + [RM D.7] All (non-environment) tasks depend directly on the + environment task of the partition. + + `No_Task_Allocators' + [RM D.7] There are no allocators for task types or types + containing task subcomponents. + + `No_Dynamic_Priorities' + [RM D.7] There are no semantic dependencies on the package + Dynamic_Priorities. + + `No_Terminate_Alternatives' + [RM D.7] There are no selective_accepts with + terminate_alternatives + + `No_Dynamic_Interrupts' + There are no semantic dependencies on Ada.Interrupts. + + `No_Protected_Type_Allocators' + There are no allocators for protected types or types + containing protected subcomponents. + + `No_Local_Protected_Objects' + Protected objects and access types that designate such + objects shall be declared only at library level. + + `No_Requeue' + Requeue statements are not allowed. + + `No_Calendar' + There are no semantic dependencies on the package + Ada.Calendar. + + `No_Relative_Delay' + There are no delay_relative_statements. + + `No_Task_Attributes' + There are no semantic dependencies on the Ada.Task_Attributes + package and there are no references to the attributes + Callable and Terminated [RM 9.9]. + + `Static_Storage_Size' + The expression for pragma Storage_Size is static. + + `Boolean_Entry_Barriers' + Entry barrier condition expressions shall be boolean objects + which are declared in the protected type which contains the + entry. + + `Max_Asynchronous_Select_Nesting = 0' + [RM D.7] Specifies the maximum dynamic nesting level of + asynchronous_selects. A value of zero prevents the use of + any asynchronous_select. + + `Max_Task_Entries = 0' + [RM D.7] Specifies the maximum number of entries per task. + The bounds of every entry family of a task unit shall be + static, or shall be defined by a discriminant of a subtype + whose corresponding bound is static. A value of zero + indicates that no rendezvous are possible. For the Ravenscar + pragma, the value of Max_Task_Entries is always 0 (zero). + + `Max_Protected_Entries = 1' + [RM D.7] Specifies the maximum number of entries per + protected type. The bounds of every entry family of a + protected unit shall be static, or shall be defined by a + discriminant of a subtype whose corresponding bound is + static. For the Ravenscar pragma the value of + Max_Protected_Entries is always 1. + + `Max_Select_Alternatives = 0' + [RM D.7] Specifies the maximum number of alternatives in a + selective_accept. For the Ravenscar pragma the value if + always 0. + + `No_Task_Termination' + Tasks which terminate are erroneous. + + `No_Entry_Queue' + No task can be queued on a protected entry. Note that this + restrictions is checked at run time. The violation of this + restriction generates a Program_Error exception. + + This set of restrictions corresponds to the definition of the + "Ravenscar Profile" for limited tasking, devised and published by + the `International Real-Time Ada Workshop', 1997. + + The above set is a superset of the restrictions provided by pragma + `Restricted_Run_Time', it includes six additional restrictions + (`Boolean_Entry_Barriers', `No_Select_Statements', `No_Calendar', + `Static_Storage_Size', `No_Relative_Delay' and + `No_Task_Termination'). This means that pragma `Ravenscar', like + the pragma `Restricted_Run_Time', automatically causes the use of + a simplified, more efficient version of the tasking run-time + system. + + `pragma Restricted_Run_Time' + Syntax: + + pragma Restricted_Run_Time + + A configuration pragma that establishes the following set of + restrictions: + + * No_Abort_Statements + + * No_Asynchronous_Control + + * No_Entry_Queue + + * No_Task_Hierarchy + + * No_Task_Allocators + + * No_Dynamic_Priorities + + * No_Terminate_Alternatives + + * No_Dynamic_Interrupts + + * No_Protected_Type_Allocators + + * No_Local_Protected_Objects + + * No_Requeue + + * No_Task_Attributes + + * Max_Asynchronous_Select_Nesting = 0 + + * Max_Task_Entries = 0 + + * Max_Protected_Entries = 1 + + * Max_Select_Alternatives = 0 + + This set of restrictions causes the automatic selection of a + simplified version of the run time that provides improved + performance for the limited set of tasking functionality permitted + by this set of restrictions. + + `pragma Share_Generic' + Syntax: + + pragma Share_Generic (NAME {, NAME}); + + This pragma is recognized for compatibility with other Ada + compilers but is ignored by GNAT. GNAT does not provide the + capability for sharing of generic code. All generic + instantiations result in making an inlined copy of the template + with appropriate substitutions. + + `pragma Source_File_Name' + Syntax: + + pragma Source_File_Name ( + [Unit_Name =>] unit_NAME, + Spec_File_Name => STRING_LITERAL); + + pragma Source_File_Name ( + [Unit_Name =>] unit_NAME, + Body_File_Name => STRING_LITERAL); + + Use this to override the normal naming convention. It is a + configuration pragma, and so has the usual applicability of + configuration pragmas (i.e. it applies to either an entire + partition, or to all units in a compilation, or to a single unit, + depending on how it is used. UNIT_NAME is mapped to + FILE_NAME_LITERAL. The identifier for the second argument is + required, and indicates whether this is the file name for the spec + or for the body. + + Another form of the `Source_File_Name' pragma allows the + specification of patterns defining alternative file naming schemes + to apply to all files. + + pragma Source_File_Name + (Spec_File_Name => STRING_LITERAL + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name + (Body_File_Name => STRING_LITERAL + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name + (Subunit_File_Name => STRING_LITERAL + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + CASING_SPEC ::= Lowercase | Uppercase | Mixedcase + + The first argument is a pattern that contains a single asterisk + indicating the point at which the unit name is to be inserted in + the pattern string to form the file name. The second argument is + optional. If present it specifies the casing of the unit name in + the resulting file name string. The default is lower case. + Finally the third argument allows for systematic replacement of + any dots in the unit name by the specified string literal. + + For more details on the use of the `Source_File_Name' pragma, see + the sections "Using Other File Names" and "Alternative File Naming + Schemes" in the `GNAT User's Guide'. + + `pragma Source_Reference' + Syntax: + + pragma Source_Reference (INTEGER_LITERAL, + STRING_LITERAL); + + This pragma must appear as the first line of a source file. + INTEGER_LITERAL is the logical line number of the line following + the pragma line (for use in error messages and debugging + information). STRING_LITERAL is a static string constant that + specifies the file name to be used in error messages and debugging + information. This is most notably used for the output of + `gnatchop' with the `-r' switch, to make sure that the original + unchopped source file is the one referred to. + + The second argument must be a string literal, it cannot be a static + string expression other than a string literal. This is because + its value is needed for error messages issued by all phases of the + compiler. + + `pragma Stream_Convert' + Syntax: + + pragma Stream_Convert ( + [Entity =>] type_LOCAL_NAME, + [Read =>] function_NAME, + [Write =>] function NAME); + + This pragma provides an efficient way of providing stream + functions for types defined in packages. Not only is it simpler + to use than declaring the necessary functions with attribute + representation clauses, but more significantly, it allows the + declaration to made in such a way that the stream packages are not + loaded unless they are needed. The use of the Stream_Convert + pragma adds no overhead at all, unless the stream attributes are + actually used on the designated type. + + The first argument specifies the type for which stream functions + are provided. The second parameter provides a function used to + read values of this type. It must name a function whose argument + type may be any subtype, and whose returned type must be the type + given as the first argument to the pragma. + + The meaning of the READ parameter is that if a stream attribute + directly or indirectly specifies reading of the type given as the + first parameter, then a value of the type given as the argument to + the Read function is read from the stream, and then the Read + function is used to convert this to the required target type. + + Similarly the WRITE parameter specifies how to treat write + attributes that directly or indirectly apply to the type given as + the first parameter. It must have an input parameter of the type + specified by the first parameter, and the return type must be the + same as the input type of the Read function. The effect is to + first call the Write function to convert to the given stream type, + and then write the result type to the stream. + + The Read and Write functions must not be overloaded subprograms. + If necessary renamings can be supplied to meet this requirement. + The usage of this attribute is best illustrated by a simple + example, taken from the GNAT implementation of package + Ada.Strings.Unbounded: + + function To_Unbounded (S : String) + return Unbounded_String + renames To_Unbounded_String; + + pragma Stream_Convert + (Unbounded_String, To_Unbounded, To_String); + + The specifications of the referenced functions, as given in the + Ada 95 Reference Manual are: + + function To_Unbounded_String (Source : String) + return Unbounded_String; + + function To_String (Source : Unbounded_String) + return String; + + The effect is that if the value of an unbounded string is written + to a stream, then the representation of the item in the stream is + in the same format used for `Standard.String', and this same + representation is expected when a value of this type is read from + the stream. + + `pragma Style_Checks' + Syntax: + + pragma Style_Checks (string_LITERAL | ALL_CHECKS | + On | Off [, LOCAL_NAME]); + + This pragma is used in conjunction with compiler switches to + control the built in style checking provided by GNAT. The + compiler switches, if set provide an initial setting for the + switches, and this pragma may be used to modify these settings, or + the settings may be provided entirely by the use of the pragma. + This pragma can be used anywhere that a pragma is legal, including + use as a configuration pragma (including use in the `gnat.adc' + file). + + The form with a string literal specifies which style options are + to be activated. These are additive, so they apply in addition to + any previously set style check options. The codes for the options + are the same as those used in the `-gnaty' switch to `gcc' or + `gnatmake'. For example the following two methods can be used to + enable layout checking: + + pragma Style_Checks ("l"); + gcc -c -gnatyl ... + + The form ALL_CHECKS activates all standard checks (its use is + equivalent to the use of the `gnaty' switch with no options. See + GNAT User's Guide for details. + + The forms with `Off' and `On' can be used to temporarily disable + style checks as shown in the following example: + + pragma Style_Checks ("k"); -- requires keywords in lower case + pragma Style_Checks (Off); -- turn off style checks + NULL; -- this will not generate an error message + pragma Style_Checks (On); -- turn style checks back on + NULL; -- this will generate an error message + + Finally the two argument form is allowed only if the first + argument is `On' or `Off'. The effect is to turn of semantic + style checks for the specified entity, as shown in the following + example: + + pragma Style_Checks ("r"); -- require consistency of identifier casing + Arg : Integer; + Rf1 : Integer := ARG; -- incorrect, wrong case + pragma Style_Checks (Off, Arg); + Rf2 : Integer := ARG; -- OK, no error + + `pragma Subtitle' + Syntax: + + pragma Subtitle ([Subtitle =>] STRING_LITERAL); + + This pragma is recognized for compatibility with other Ada + compilers but is ignored by GNAT. + + `pragma Suppress_All' + Syntax: + + pragma Suppress_All; + + This pragma can only appear immediately following a compilation + unit. The effect is to apply `Suppress (All_Checks)' to the unit + which it follows. This pragma is implemented for compatibility + with DEC Ada 83 usage. The use of pragma `Suppress (All_Checks)' + as a normal configuration pragma is the preferred usage in GNAT. + + `pragma Suppress_Initialization' + Syntax: + + pragma Suppress_Initialization ([Entity =>] type_Name); + + This pragma suppresses any implicit or explicit initialization + associated with the given type name for all variables of this type. + + `pragma Task_Info' + Syntax + + pragma Task_Info (EXPRESSION); + + This pragma appears within a task definition (like pragma + `Priority') and applies to the task in which it appears. The + argument must be of type `System.Task_Info.Task_Info_Type'. The + `Task_Info' pragma provides system dependent control over aspect + of tasking implementation, for example, the ability to map tasks + to specific processors. For details on the facilities available + for the version of GNAT that you are using, see the documentation + in the specification of package System.Task_Info in the runtime + library. + + `pragma Task_Name' + Syntax + + pragma Task_Name (string_EXPRESSION); + + This pragma appears within a task definition (like pragma + `Priority') and applies to the task in which it appears. The + argument must be of type String, and provides a name to be used for + the task instance when the task is created. Note that this + expression is not required to be static, and in particular, it can + contain references to task discriminants. This facility can be + used to provide different names for different tasks as they are + created, as illustrated in the example below. + + The task name is recorded internally in the run-time structures + and is accessible to tools like the debugger. In addition the + routine `Ada.Task_Identification.Image' will return this string, + with a unique task address appended. + + -- Example of the use of pragma Task_Name + + with Ada.Task_Identification; + use Ada.Task_Identification; + with Text_IO; use Text_IO; + procedure t3 is + + type Astring is access String; + + task type Task_Typ (Name : access String) is + pragma Task_Name (Name.all); + end Task_Typ; + + task body Task_Typ is + Nam : constant String := Image (Current_Task); + begin + Put_Line ("-->" & Nam (1 .. 14) & "<--"); + end Task_Typ; + + type Ptr_Task is access Task_Typ; + Task_Var : Ptr_Task; + + begin + Task_Var := + new Task_Typ (new String'("This is task 1")); + Task_Var := + new Task_Typ (new String'("This is task 2")); + end; + + `pragma Task_Storage' + Syntax: + + pragma Task_Storage + [Task_Type =>] LOCAL_NAME, + [Top_Guard =>] static_integer_EXPRESSION); + + This pragma specifies the length of the guard area for tasks. The + guard area is an additional storage area allocated to a task. A + value of zero means that either no guard area is created or a + minimal guard area is created, depending on the target. This + pragma can appear anywhere a `Storage_Size' attribute definition + clause is allowed for a task type. + + `pragma Time_Slice' + Syntax: + + pragma Time_Slice (static_duration_EXPRESSION); + + For implementations of GNAT on operating systems where it is + possible to supply a time slice value, this pragma may be used for + this purpose. It is ignored if it is used in a system that does + not allow this control, or if it appears in other than the main + program unit. Note that the effect of this pragma is identical to + the effect of the DEC Ada 83 pragma of the same name when + operating under OpenVMS systems. + + `pragma Title' + Syntax: + + pragma Title (TITLING_OPTION [, TITLING OPTION]); + + TITLING_OPTION ::= + [Title =>] STRING_LITERAL, + | [Subtitle =>] STRING_LITERAL + + Syntax checked but otherwise ignored by GNAT. This is a listing + control pragma used in DEC Ada 83 implementations to provide a + title and/or subtitle for the program listing. The program + listing generated by GNAT does not have titles or subtitles. + + Unlike other pragmas, the full flexibility of named notation is + allowed for this pragma, i.e. the parameters may be given in any + order if named notation is used, and named and positional notation + can be mixed following the normal rules for procedure calls in Ada. + + `pragma Unchecked_Union' + Syntax: + + pragma Unchecked_Union (first_subtype_LOCAL_NAME) + + This pragma is used to declare that the specified type should be + represented in a manner equivalent to a C union type, and is + intended only for use in interfacing with C code that uses union + types. In Ada terms, the named type must obey the following rules: + + * It is a non-tagged non-limited record type. + + * It has a single discrete discriminant with a default value. + + * The component list consists of a single variant part. + + * Each variant has a component list with a single component. + + * No nested variants are allowed. + + * No component has an explicit default value. + + * No component has a non-static constraint. + + In addition, given a type that meets the above requirements, the + following restrictions apply to its use throughout the program: + + * The discriminant name can be mentioned only in an aggregate. + + * No subtypes may be created of this type. + + * The type may not be constrained by giving a discriminant + value. + + * The type cannot be passed as the actual for a generic formal + with a discriminant. + + Equality and inequality operations on `unchecked_unions' are not + available, since there is no discriminant to compare and the + compiler does not even know how many bits to compare. It is + implementation dependent whether this is detected at compile time + as an illegality or whether it is undetected and considered to be + an erroneous construct. In GNAT, a direct comparison is illegal, + but GNAT does not attempt to catch the composite case (where two + composites are compared that contain an unchecked union + component), so such comparisons are simply considered erroneous. + + The layout of the resulting type corresponds exactly to a C union, + where each branch of the union corresponds to a single variant in + the Ada record. The semantics of the Ada program is not changed + in any way by the pragma, i.e. provided the above restrictions are + followed, and no erroneous incorrect references to fields or + erroneous comparisons occur, the semantics is exactly as described + by the Ada reference manual. Pragma `Suppress + (Discriminant_Check)' applies implicitly to the type and the + default convention is C + + `pragma Unimplemented_Unit' + Syntax: + + pragma Unimplemented_Unit; + + If this pragma occurs in a unit that is processed by the compiler, + GNAT aborts with the message `XXX not implemented', where XXX is + the name of the current compilation unit. This pragma is intended + to allow the compiler to handle unimplemented library units in a + clean manner. + + The abort only happens if code is being generated. Thus you can + use specs of unimplemented packages in syntax or semantic checking + mode. + + `pragma Unreferenced' + Syntax: + + pragma Unreferenced (local_Name {, local_Name}); + + This pragma signals that the entities whose names are listed are + deliberately not referenced. This suppresses warnings about the + entities being unreferenced, and in addition a warning will be + generated if one of these entities is in fact referenced. + + This is particularly useful for clearly signalling that a + particular parameter is not referenced in some particular + subprogram implementation and that this is deliberate. It can also + be useful in the case of objects declared only for their + initialization or finalization side effects. + + If `local_Name' identifies more than one matching homonym in the + current scope, then the entity most recently declared is the one + to which the pragma applies. + + `pragma Unreserve_All_Interrupts' + Syntax: + + pragma Unreserve_All_Interrupts; + + Normally certain interrupts are reserved to the implementation. + Any attempt to attach an interrupt causes Program_Error to be + raised, as described in RM C.3.2(22). A typical example is the + `SIGINT' interrupt used in many systems for an `Ctrl-C' interrupt. + Normally this interrupt is reserved to the implementation, so + that `Ctrl-C' can be used to interrupt execution. + + If the pragma `Unreserve_All_Interrupts' appears anywhere in any + unit in a program, then all such interrupts are unreserved. This + allows the program to handle these interrupts, but disables their + standard functions. For example, if this pragma is used, then + pressing `Ctrl-C' will not automatically interrupt execution. + However, a program can then handle the `SIGINT' interrupt as it + chooses. + + For a full list of the interrupts handled in a specific + implementation, see the source code for the specification of + `Ada.Interrupts.Names' in file `a-intnam.ads'. This is a target + dependent file that contains the list of interrupts recognized for + a given target. The documentation in this file also specifies + what interrupts are affected by the use of the + `Unreserve_All_Interrupts' pragma. + + `pragma Unsuppress' + Syntax: + + pragma Unsuppress (IDENTIFIER [, [On =>] NAME]); + + This pragma undoes the effect of a previous pragma `Suppress'. If + there is no corresponding pragma `Suppress' in effect, it has no + effect. The range of the effect is the same as for pragma + `Suppress'. The meaning of the arguments is identical to that used + in pragma `Suppress'. + + One important application is to ensure that checks are on in cases + where code depends on the checks for its correct functioning, so + that the code will compile correctly even if the compiler switches + are set to suppress checks. + + `pragma Use_VADS_Size' + Syntax: + + pragma Use_VADS_Size; + + This is a configuration pragma. In a unit to which it applies, + any use of the 'Size attribute is automatically interpreted as a + use of the 'VADS_Size attribute. Note that this may result in + incorrect semantic processing of valid Ada 95 programs. This is + intended to aid in the handling of legacy code which depends on + the interpretation of Size as implemented in the VADS compiler. + See description of the VADS_Size attribute for further details. + + `pragma Validity_Checks' + Syntax: + + pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off); + + This pragma is used in conjunction with compiler switches to + control the built in validity checking provided by GNAT. The + compiler switches, if set provide an initial setting for the + switches, and this pragma may be used to modify these settings, or + the settings may be provided entirely by the use of the pragma. + This pragma can be used anywhere that a pragma is legal, including + use as a configuration pragma (including use in the `gnat.adc' + file). + + The form with a string literal specifies which validity options + are to be activated. The validity checks are first set to include + only the default reference manual settings, and then a string of + letters in the string specifies the exact set of options required. + The form of this string is exactly as described for the `-gnatVx' + compiler switch (see the GNAT users guide for details). For + example the following two methods can be used to enable validity + checking for mode `in' and `in out' subprogram parameters: + + pragma Validity_Checks ("im"); + gcc -c -gnatVim ... + + The form ALL_CHECKS activates all standard checks (its use is + equivalent to the use of the `gnatva' switch. + + The forms with `Off' and `On' can be used to temporarily disable + validity checks as shown in the following example: + + pragma Validity_Checks ("c"); -- validity checks for copies + pragma Validity_Checks (Off); -- turn off validity checks + A := B; -- B will not be validity checked + pragma Validity_Checks (On); -- turn validity checks back on + A := C; -- C will be validity checked + + `pragma Volatile' + Syntax: + + pragma Volatile (local_NAME) + + This pragma is defined by the Ada 95 Reference Manual, and the GNAT + implementation is fully conformant with this definition. The + reason it is mentioned in this section is that a pragma of the + same name was supplied in some Ada 83 compilers, including DEC Ada + 83. The Ada 95 implementation of pragma Volatile is upwards + compatible with the implementation in Dec Ada 83. + + `pragma Warnings' + Syntax: + + pragma Warnings (On | Off [, LOCAL_NAME]); + + Normally warnings are enabled, with the output being controlled by + the command line switch. Warnings (`Off') turns off generation of + warnings until a Warnings (`On') is encountered or the end of the + current unit. If generation of warnings is turned off using this + pragma, then no warning messages are output, regardless of the + setting of the command line switches. + + The form with a single argument is a configuration pragma. + + If the LOCAL_NAME parameter is present, warnings are suppressed for + the specified entity. This suppression is effective from the + point where it occurs till the end of the extended scope of the + variable (similar to the scope of `Suppress'). + + `pragma Weak_External' + Syntax: + + pragma Weak_External ([Entity =>] LOCAL_NAME); + + This pragma specifies that the given entity should be marked as a + weak external (one that does not have to be resolved) for the + linker. For further details, consult the GCC manual. + +  + File: gnat_rm.info, Node: Implementation Defined Attributes, Next: Implementation Advice, Prev: Implementation Defined Pragmas, Up: Top + + Implementation Defined Attributes + ********************************* + + Ada 95 defines (throughout the Ada 95 reference manual, summarized + in annex K), a set of attributes that provide useful additional + functionality in all areas of the language. These language defined + attributes are implemented in GNAT and work as described in the Ada 95 + Reference Manual. + + In addition, Ada 95 allows implementations to define additional + attributes whose meaning is defined by the implementation. GNAT + provides a number of these implementation-dependent attributes which + can be used to extend and enhance the functionality of the compiler. + This section of the GNAT reference manual describes these additional + attributes. + + Note that any program using these attributes may not be portable to + other compilers (although GNAT implements this set of attributes on all + platforms). Therefore if portability to other compilers is an important + consideration, you should minimize the use of these attributes. + + `Abort_Signal' + `Standard'Abort_Signal' (`Standard' is the only allowed prefix) + provides the entity for the special exception used to signal task + abort or asynchronous transfer of control. Normally this attribute + should only be used in the tasking runtime (it is highly peculiar, + and completely outside the normal semantics of Ada, for a user + program to intercept the abort exception). + + `Address_Size' + `Standard'Address_Size' (`Standard' is the only allowed prefix) is + a static constant giving the number of bits in an `Address'. It + is used primarily for constructing the definition of `Memory_Size' + in package `Standard', but may be freely used in user programs and + has the advantage of being static, while a direct reference to + System.Address'Size is non-static because Address is a private + type. + + `Asm_Input' + The `Asm_Input' attribute denotes a function that takes two + parameters. The first is a string, the second is an expression of + the type designated by the prefix. The first (string) argument is + required to be a static expression, and is the constraint for the + parameter, (e.g. what kind of register is required). The second + argument is the value to be used as the input argument. The + possible values for the constant are the same as those used in the + RTL, and are dependent on the configuration file used to built the + GCC back end. *Note Machine Code Insertions:: + + `Asm_Output' + The `Asm_Output' attribute denotes a function that takes two + parameters. The first is a string, the second is the name of a + variable of the type designated by the attribute prefix. The + first (string) argument is required to be a static expression and + designates the constraint for the parameter (e.g. what kind of + register is required). The second argument is the variable to be + updated with the result. The possible values for constraint are + the same as those used in the RTL, and are dependent on the + configuration file used to build the GCC back end. If there are + no output operands, then this argument may either be omitted, or + explicitly given as `No_Output_Operands'. *Note Machine Code + Insertions:: + + `AST_Entry' + This attribute is implemented only in OpenVMS versions of GNAT. + Applied to the name of an entry, it yields a value of the + predefined type AST_Handler (declared in the predefined package + System, as extended by the use of pragma `Extend_System + (Aux_DEC)'). This value enables the given entry to be called when + an AST occurs. For further details, refer to the `DEC Ada + Language Reference Manual', section 9.12a. + + `Bit' + `OBJ'Bit', where OBJ is any object, yields the bit offset within + the storage unit (byte) that contains the first bit of storage + allocated for the object. The value of this attribute is of the + type `Universal_Integer', and is always a non-negative number not + exceeding the value of `System.Storage_Unit'. + + For an object that is a variable or a constant allocated in a + register, the value is zero. (The use of this attribute does not + force the allocation of a variable to memory). + + For an object that is a formal parameter, this attribute applies + to either the matching actual parameter or to a copy of the + matching actual parameter. + + For an access object the value is zero. Note that `OBJ.all'Bit' + is subject to an `Access_Check' for the designated object. + Similarly for a record component `X.C'Bit' is subject to a + discriminant check and `X(I).Bit' and `X(I1..I2)'Bit' are subject + to index checks. + + This attribute is designed to be compatible with the DEC Ada 83 + definition and implementation of the `Bit' attribute. + + `Bit_Position' + `R.C'Bit', where R is a record object and C is one of the fields + of the record type, yields the bit offset within the record + contains the first bit of storage allocated for the object. The + value of this attribute is of the type `Universal_Integer'. The + value depends only on the field C and is independent of the + alignment of the containing record R. + + `Code_Address' + The `'Address' attribute may be applied to subprograms in Ada 95, + but the intended effect from the Ada 95 reference manual seems to + be to provide an address value which can be used to call the + subprogram by means of an address clause as in the following + example: + + procedure K is ... + + procedure L; + for L'Address use K'Address; + pragma Import (Ada, L); + + A call to `L' is then expected to result in a call to `K'. In Ada + 83, where there were no access-to-subprogram values, this was a + common work around for getting the effect of an indirect call. + GNAT implements the above use of `Address' and the technique + illustrated by the example code works correctly. + + However, for some purposes, it is useful to have the address of + the start of the generated code for the subprogram. On some + architectures, this is not necessarily the same as the `Address' + value described above. For example, the `Address' value may + reference a subprogram descriptor rather than the subprogram + itself. + + The `'Code_Address' attribute, which can only be applied to + subprogram entities, always returns the address of the start of the + generated code of the specified subprogram, which may or may not be + the same value as is returned by the corresponding `'Address' + attribute. + + `Default_Bit_Order' + `Standard'Default_Bit_Order' (`Standard' is the only permissible + prefix), provides the value `System.Default_Bit_Order' as a `Pos' + value (0 for `High_Order_First', 1 for `Low_Order_First'). This + is used to construct the definition of `Default_Bit_Order' in + package `System'. + + `Elaborated' + The prefix of the `'Elaborated' attribute must be a unit name. The + value is a Boolean which indicates whether or not the given unit + has been elaborated. This attribute is primarily intended for + internal use by the generated code for dynamic elaboration + checking, but it can also be used in user programs. The value + will always be True once elaboration of all units has been + completed. + + `Elab_Body' + This attribute can only be applied to a program unit name. It + returns the entity for the corresponding elaboration procedure for + elaborating the body of the referenced unit. This is used in the + main generated elaboration procedure by the binder and is not + normally used in any other context. However, there may be + specialized situations in which it is useful to be able to call + this elaboration procedure from Ada code, e.g. if it is necessary + to do selective re-elaboration to fix some error. + + `Elab_Spec' + This attribute can only be applied to a program unit name. It + returns the entity for the corresponding elaboration procedure for + elaborating the specification of the referenced unit. This is + used in the main generated elaboration procedure by the binder and + is not normally used in any other context. However, there may be + specialized situations in which it is useful to be able to call + this elaboration procedure from Ada code, e.g. if it is necessary + to do selective re-elaboration to fix some error. + + `Emax' + The `Emax' attribute is provided for compatibility with Ada 83. + See the Ada 83 reference manual for an exact description of the + semantics of this attribute. + + `Enum_Rep' + For every enumeration subtype S, `S'Enum_Rep' denotes a function + with the following specification: + + function S'Enum_Rep (Arg : S'Base) + return Universal_Integer; + + It is also allowable to apply `Enum_Rep' directly to an object of + an enumeration type or to a non-overloaded enumeration literal. + In this case `S'Enum_Rep' is equivalent to `TYP'Enum_Rep(S)' where + TYP is the type of the enumeration literal or object. + + The function returns the representation value for the given + enumeration value. This will be equal to value of the `Pos' + attribute in the absence of an enumeration representation clause. + This is a static attribute (i.e. the result is static if the + argument is static). + + `S'Enum_Rep' can also be used with integer types and objects, in + which case it simply returns the integer value. The reason for + this is to allow it to be used for `(<>)' discrete formal + arguments in a generic unit that can be instantiated with either + enumeration types or integer types. Note that if `Enum_Rep' is + used on a modular type whose upper bound exceeds the upper bound + of the largest signed integer type, and the argument is a + variable, so that the universal integer calculation is done at + run-time, then the call to `Enum_Rep' may raise `Constraint_Error'. + + `Epsilon' + The `Epsilon' attribute is provided for compatibility with Ada 83. + See the Ada 83 reference manual for an exact description of the + semantics of this attribute. + + `Fixed_Value' + For every fixed-point type S, `S'Fixed_Value' denotes a function + with the following specification: + + function S'Fixed_Value (Arg : Universal_Integer) + return S; + + The value returned is the fixed-point value V such that + + V = Arg * S'Small + + The effect is thus equivalent to first converting the argument to + the integer type used to represent S, and then doing an unchecked + conversion to the fixed-point type. This attribute is primarily + intended for use in implementation of the input-output functions + for fixed-point values. + + `Has_Discriminants' + The prefix of the `Has_Discriminants' attribute is a type. The + result is a Boolean value which is True if the type has + discriminants, and False otherwise. The intended use of this + attribute is in conjunction with generic definitions. If the + attribute is applied to a generic private type, it indicates + whether or not the corresponding actual type has discriminants. + + `Img' + The `Img' attribute differs from `Image' in that it may be applied + to objects as well as types, in which case it gives the `Image' + for the subtype of the object. This is convenient for debugging: + + Put_Line ("X = " & X'Img); + + has the same meaning as the more verbose: + + Put_Line ("X = " & TYPE'Image (X)); + + where TYPE is the subtype of the object X. + + `Integer_Value' + For every integer type S, `S'Integer_Value' denotes a function + with the following specification: + + function S'Integer_Value (Arg : Universal_Fixed) + return S; + + The value returned is the integer value V, such that + + Arg = V * TYPE'Small + + The effect is thus equivalent to first doing an unchecked convert + from the fixed-point type to its corresponding implementation + type, and then converting the result to the target integer type. + This attribute is primarily intended for use in implementation of + the standard input-output functions for fixed-point values. + + `Large' + The `Large' attribute is provided for compatibility with Ada 83. + See the Ada 83 reference manual for an exact description of the + semantics of this attribute. + + `Machine_Size' + This attribute is identical to the `Object_Size' attribute. It is + provided for compatibility with the DEC Ada 83 attribute of this + name. + + `Mantissa' + The `Mantissa' attribute is provided for compatibility with Ada + 83. See the Ada 83 reference manual for an exact description of + the semantics of this attribute. + + `Max_Interrupt_Priority' + `Standard'Max_Interrupt_Priority' (`Standard' is the only + permissible prefix), provides the value + `System.Max_Interrupt_Priority' and is intended primarily for + constructing this definition in package `System'. + + `Max_Priority' + `Standard'Max_Priority' (`Standard' is the only permissible + prefix) provides the value `System.Max_Priority' and is intended + primarily for constructing this definition in package `System'. + + `Maximum_Alignment' + `Standard'Maximum_Alignment' (`Standard' is the only permissible + prefix) provides the maximum useful alignment value for the + target. This is a static value that can be used to specify the + alignment for an object, guaranteeing that it is properly aligned + in all cases. This is useful when an external object is imported + and its alignment requirements are unknown. + + `Mechanism_Code' + `FUNCTION'Mechanism_Code' yields an integer code for the mechanism + used for the result of function, and `SUBPROGRAM'Mechanism_Code + (N)' yields the mechanism used for formal parameter number N (a + static integer value with 1 meaning the first parameter) of + SUBPROGRAM. The code returned is: + + 1 + by copy (value) + + 2 + by reference + + 3 + by descriptor (default descriptor class) + + 4 + by descriptor (UBS: unaligned bit string) + + 5 + by descriptor (UBSB: aligned bit string with arbitrary bounds) + + 6 + by descriptor (UBA: unaligned bit array) + + 7 + by descriptor (S: string, also scalar access type parameter) + + 8 + by descriptor (SB: string with arbitrary bounds) + + 9 + by descriptor (A: contiguous array) + + 10 + by descriptor (NCA: non-contiguous array) + + Values from 3 through 10 are only relevant to Digital OpenVMS + implementations. + + `Null_Parameter' + A reference `T'Null_Parameter' denotes an imaginary object of type + or subtype T allocated at machine address zero. The attribute is + allowed only as the default expression of a formal parameter, or as + an actual expression of a subprogram call. In either case, the + subprogram must be imported. + + The identity of the object is represented by the address zero in + the argument list, independent of the passing mechanism (explicit + or default). + + This capability is needed to specify that a zero address should be + passed for a record or other composite object passed by reference. + There is no way of indicating this without the `Null_Parameter' + attribute. + + `Object_Size' + The size of an object is not necessarily the same as the size of + the type of an object. This is because by default object sizes + are increased to be a multiple of the alignment of the object. + For example, `Natural'Size' is 31, but by default objects of type + `Natural' will have a size of 32 bits. Similarly, a record + containing an integer and a character: + + type Rec is record + I : Integer; + C : Character; + end record; + + will have a size of 40 (that is `Rec'Size' will be 40. The + alignment will be 4, because of the integer field, and so the + default size of record objects for this type will be 64 (8 bytes). + + The `TYPE'Object_Size' attribute has been added to GNAT to allow + the default object size of a type to be easily determined. For + example, `Natural'Object_Size' is 32, and `Rec'Object_Size' (for + the record type in the above example) will be 64. Note also that, + unlike the situation with the `Size' attribute as defined in the + Ada RM, the `Object_Size' attribute can be specified individually + for different subtypes. For example: + + type R is new Integer; + subtype R1 is R range 1 .. 10; + subtype R2 is R range 1 .. 10; + for R2'Object_Size use 8; + + In this example, `R'Object_Size' and `R1'Object_Size' are both 32 + since the default object size for a subtype is the same as the + object size for the parent subtype. This means that objects of + type `R' or `R1' will by default be 32 bits (four bytes). But + objects of type `R2' will be only 8 bits (one byte), since + `R2'Object_Size' has been set to 8. + + `Passed_By_Reference' + `TYPE'Passed_By_Reference' for any subtype TYPE returns a value of + type `Boolean' value that is `True' if the type is normally passed + by reference and `False' if the type is normally passed by copy in + calls. For scalar types, the result is always `False' and is + static. For non-scalar types, the result is non-static. + + `Range_Length' + `TYPE'Range_Length' for any discrete type TYPE yields the number + of values represented by the subtype (zero for a null range). The + result is static for static subtypes. `Range_Length' applied to + the index subtype of a one dimensional array always gives the same + result as `Range' applied to the array itself. + + `Safe_Emax' + The `Safe_Emax' attribute is provided for compatibility with Ada + 83. See the Ada 83 reference manual for an exact description of + the semantics of this attribute. + + `Safe_Large' + The `Safe_Large' attribute is provided for compatibility with Ada + 83. See the Ada 83 reference manual for an exact description of + the semantics of this attribute. + + `Safe_Large' + The `Safe_Large' attribute is provided for compatibility with Ada + 83. See the Ada 83 reference manual for an exact description of + the semantics of this attribute. + + `Small' + The `Small' attribute is defined in Ada 95 only for fixed-point + types. GNAT also allows this attribute to be applied to + floating-point types for compatibility with Ada 83. See the Ada + 83 reference manual for an exact description of the semantics of + this attribute when applied to floating-point types. + + `Storage_Unit' + `Standard'Storage_Unit' (`Standard' is the only permissible + prefix) provides the value `System.Storage_Unit' and is intended + primarily for constructing this definition in package `System'. + + `Tick' + `Standard'Tick' (`Standard' is the only permissible prefix) + provides the value of `System.Tick' and is intended primarily for + constructing this definition in package `System'. + + `To_Address' + The `System'To_Address' (`System' is the only permissible prefix) + denotes a function identical to + `System.Storage_Elements.To_Address' except that it is a static + attribute. This means that if its argument is a static + expression, then the result of the attribute is a static + expression. The result is that such an expression can be used in + contexts (e.g. preelaborable packages) which require a static + expression and where the function call could not be used (since + the function call is always non-static, even if its argument is + static). + + `Type_Class' + `TYPE'Type_Class' for any type or subtype TYPE yields the value of + the type class for the full type of TYPE. If TYPE is a generic + formal type, the value is the value for the corresponding actual + subtype. The value of this attribute is of type + `System.Aux_DEC.Type_Class', which has the following definition: + + type Type_Class is + (Type_Class_Enumeration, + Type_Class_Integer, + Type_Class_Fixed_Point, + Type_Class_Floating_Point, + Type_Class_Array, + Type_Class_Record, + Type_Class_Access, + Type_Class_Task, + Type_Class_Address); + + Protected types yield the value `Type_Class_Task', which thus + applies to all concurrent types. This attribute is designed to be + compatible with the DEC Ada 83 attribute of the same name. + + `UET_Address' + The `UET_Address' attribute can only be used for a prefix which + denotes a library package. It yields the address of the unit + exception table when zero cost exception handling is used. This + attribute is intended only for use within the GNAT implementation. + See the unit `Ada.Exceptions' in files `a-except.ads' and + `a-except.adb' for details on how this attribute is used in the + implementation. + + `Universal_Literal_String' + The prefix of `Universal_Literal_String' must be a named number. + The static result is the string consisting of the characters of + the number as defined in the original source. This allows the user + program to access the actual text of named numbers without + intermediate conversions and without the need to enclose the + strings in quotes (which would preclude their use as numbers). + This is used internally for the construction of values of the + floating-point attributes from the file `ttypef.ads', but may also + be used by user programs. + + `Unrestricted_Access' + The `Unrestricted_Access' attribute is similar to `Access' except + that all accessibility and aliased view checks are omitted. This + is a user-beware attribute. It is similar to `Address', for which + it is a desirable replacement where the value desired is an access + type. In other words, its effect is identical to first applying + the `Address' attribute and then doing an unchecked conversion to + a desired access type. In GNAT, but not necessarily in other + implementations, the use of static chains for inner level + subprograms means that `Unrestricted_Access' applied to a + subprogram yields a value that can be called as long as the + subprogram is in scope (normal Ada 95 accessibility rules restrict + this usage). + + `VADS_Size' + The `'VADS_Size' attribute is intended to make it easier to port + legacy code which relies on the semantics of `'Size' as implemented + by the VADS Ada 83 compiler. GNAT makes a best effort at + duplicating the same semantic interpretation. In particular, + `'VADS_Size' applied to a predefined or other primitive type with + no Size clause yields the Object_Size (for example, `Natural'Size' + is 32 rather than 31 on typical machines). In addition + `'VADS_Size' applied to an object gives the result that would be + obtained by applying the attribute to the corresponding type. + + `Value_Size' + `TYPE'Value_Size' is the number of bits required to represent a + value of the given subtype. It is the same as `TYPE'Size', but, + unlike `Size', may be set for non-first subtypes. + + `Wchar_T_Size' + `Standard'Wchar_T_Size' (`Standard' is the only permissible + prefix) provides the size in bits of the C `wchar_t' type + primarily for constructing the definition of this type in package + `Interfaces.C'. + + `Word_Size' + `Standard'Word_Size' (`Standard' is the only permissible prefix) + provides the value `System.Word_Size' and is intended primarily + for constructing this definition in package `System'. + +  + File: gnat_rm.info, Node: Implementation Advice, Next: Implementation Defined Characteristics, Prev: Implementation Defined Attributes, Up: Top + + Implementation Advice + ********************* + + The main text of the Ada 95 Reference Manual describes the required + behavior of all Ada 95 compilers, and the GNAT compiler conforms to + these requirements. + + In addition, there are sections throughout the Ada 95 reference + manual headed by the phrase "implementation advice". These sections + are not normative, i.e. they do not specify requirements that all + compilers must follow. Rather they provide advice on generally + desirable behavior. You may wonder why they are not requirements. The + most typical answer is that they describe behavior that seems generally + desirable, but cannot be provided on all systems, or which may be + undesirable on some systems. + + As far as practical, GNAT follows the implementation advice sections + in the Ada 95 Reference Manual. This chapter contains a table giving + the reference manual section number, paragraph number and several + keywords for each advice. Each entry consists of the text of the + advice followed by the GNAT interpretation of this advice. Most often, + this simply says "followed", which means that GNAT follows the advice. + However, in a number of cases, GNAT deliberately deviates from this + advice, in which case the text describes what GNAT does and why. + + *1.1.3(20): Error Detection* + + If an implementation detects the use of an unsupported Specialized + Needs Annex feature at run time, it should raise `Program_Error' if + feasible. + Not relevant. All specialized needs annex features are either + supported, or diagnosed at compile time. + + *1.1.3(31): Child Units* + + If an implementation wishes to provide implementation-defined + extensions to the functionality of a language-defined library + unit, it should normally do so by adding children to the library + unit. + Followed. + + *1.1.5(12): Bounded Errors* + + If an implementation detects a bounded error or erroneous + execution, it should raise `Program_Error'. + Followed in all cases in which the implementation detects a bounded + error or erroneous execution. Not all such situations are + detected at runtime. + + *2.8(16): Pragmas* + + Normally, implementation-defined pragmas should have no semantic + effect for error-free programs; that is, if the + implementation-defined pragmas are removed from a working program, + the program should still be legal, and should still have the same + semantics. + The following implementation defined pragmas are exceptions to this + rule: + + `Abort_Defer' + Affects semantics + + `Ada_83' + Affects legality + + `Assert' + Affects semantics + + `CPP_Class' + Affects semantics + + `CPP_Constructor' + Affects semantics + + `CPP_Virtual' + Affects semantics + + `CPP_Vtable' + Affects semantics + + `Debug' + Affects semantics + + `Interface_Name' + Affects semantics + + `Machine_Attribute' + Affects semantics + + `Unimplemented_Unit' + Affects legality + + `Unchecked_Union' + Affects semantics + + In each of the above cases, it is essential to the purpose of the + pragma that this advice not be followed. For details see the + separate section on implementation defined pragmas. + + *2.8(17-19): Pragmas* + + Normally, an implementation should not define pragmas that can + make an illegal program legal, except as follows: + + + A pragma used to complete a declaration, such as a pragma `Import'; + + + A pragma used to configure the environment by adding, removing, or + replacing `library_items'. + See response to paragraph 16 of this same section. + + *3.5.2(5): Alternative Character Sets* + + If an implementation supports a mode with alternative + interpretations for `Character' and `Wide_Character', the set of + graphic characters of `Character' should nevertheless remain a + proper subset of the set of graphic characters of + `Wide_Character'. Any character set "localizations" should be + reflected in the results of the subprograms defined in the + language-defined package `Characters.Handling' (see A.3) available + in such a mode. In a mode with an alternative interpretation of + `Character', the implementation should also support a + corresponding change in what is a legal `identifier_letter'. + Not all wide character modes follow this advice, in particular the + JIS and IEC modes reflect standard usage in Japan, and in these + encoding, the upper half of the Latin-1 set is not part of the + wide-character subset, since the most significant bit is used for + wide character encoding. However, this only applies to the + external forms. Internally there is no such restriction. + + *3.5.4(28): Integer Types* + + An implementation should support `Long_Integer' in addition to + `Integer' if the target machine supports 32-bit (or longer) + arithmetic. No other named integer subtypes are recommended for + package `Standard'. Instead, appropriate named integer subtypes + should be provided in the library package `Interfaces' (see B.2). + `Long_Integer' is supported. Other standard integer types are + supported so this advice is not fully followed. These types are + supported for convenient interface to C, and so that all hardware + types of the machine are easily available. + + *3.5.4(29): Integer Types* + + An implementation for a two's complement machine should support + modular types with a binary modulus up to `System.Max_Int*2+2'. An + implementation should support a non-binary modules up to + `Integer'Last'. + Followed. + + *3.5.5(8): Enumeration Values* + + For the evaluation of a call on `S'Pos' for an enumeration + subtype, if the value of the operand does not correspond to the + internal code for any enumeration literal of its type (perhaps due + to an un-initialized variable), then the implementation should + raise `Program_Error'. This is particularly important for + enumeration types with noncontiguous internal codes specified by an + enumeration_representation_clause. + Followed. + + *3.5.7(17): Float Types* + + An implementation should support `Long_Float' in addition to + `Float' if the target machine supports 11 or more digits of + precision. No other named floating point subtypes are recommended + for package `Standard'. Instead, appropriate named floating point + subtypes should be provided in the library package `Interfaces' + (see B.2). + `Short_Float' and `Long_Long_Float' are also provided. The former + provides improved compatibility with other implementations + supporting this type. The latter corresponds to the highest + precision floating-point type supported by the hardware. On most + machines, this will be the same as `Long_Float', but on some + machines, it will correspond to the IEEE extended form. The + notable case is all ia32 (x86) implementations, where + `Long_Long_Float' corresponds to the 80-bit extended precision + format supported in hardware on this processor. Note that the + 128-bit format on SPARC is not supported, since this is a software + rather than a hardware format. + + *3.6.2(11): Multidimensional Arrays* + + An implementation should normally represent multidimensional + arrays in row-major order, consistent with the notation used for + multidimensional array aggregates (see 4.3.3). However, if a + pragma `Convention' (`Fortran', ...) applies to a multidimensional + array type, then column-major order should be used instead (see + B.5, "Interfacing with Fortran"). + Followed. + + *9.6(30-31): Duration'Small* + + Whenever possible in an implementation, the value of + `Duration'Small' should be no greater than 100 microseconds. + Followed. (`Duration'Small' = 10**(-9)). + + + The time base for `delay_relative_statements' should be monotonic; + it need not be the same time base as used for `Calendar.Clock'. + Followed. + + *10.2.1(12): Consistent Representation* + + In an implementation, a type declared in a pre-elaborated package + should have the same representation in every elaboration of a + given version of the package, whether the elaborations occur in + distinct executions of the same program, or in executions of + distinct programs or partitions that include the given version. + Followed, except in the case of tagged types. Tagged types involve + implicit pointers to a local copy of a dispatch table, and these + pointers have representations which thus depend on a particular + elaboration of the package. It is not easy to see how it would be + possible to follow this advice without severely impacting + efficiency of execution. + + *11.4.1(19): Exception Information* + + `Exception_Message' by default and `Exception_Information' should + produce information useful for debugging. `Exception_Message' + should be short, about one line. `Exception_Information' can be + long. `Exception_Message' should not include the + `Exception_Name'. `Exception_Information' should include both the + `Exception_Name' and the `Exception_Message'. + Followed. For each exception that doesn't have a specified + `Exception_Message', the compiler generates one containing the + location of the raise statement. This location has the form + "file:line", where file is the short file name (without path + information) and line is the line number in the file. Note that + in the case of the Zero Cost Exception mechanism, these messages + become redundant with the Exception_Information that contains a + full backtrace of the calling sequence, so they are disabled. To + disable explicitly the generation of the source location message, + use the Pragma `Discard_Names'. + + *11.5(28): Suppression of Checks* + + The implementation should minimize the code executed for checks + that have been suppressed. + Followed. + + *13.1 (21-24): Representation Clauses* + + The recommended level of support for all representation items is + qualified as follows: + + + An implementation need not support representation items containing + non-static expressions, except that an implementation should + support a representation item for a given entity if each + non-static expression in the representation item is a name that + statically denotes a constant declared before the entity. + Followed. GNAT does not support non-static expressions in + representation clauses unless they are constants declared before + the entity. For example: + + X : typ; + for X'Address use To_address (16#2000#); + + will be rejected, since the To_Address expression is non-static. + Instead write: + + X_Address : constant Address : = + To_Address ((16#2000#); + X : typ; + for X'Address use X_Address; + + + An implementation need not support a specification for the `Size' + for a given composite subtype, nor the size or storage place for an + object (including a component) of a given composite subtype, + unless the constraints on the subtype and its composite + subcomponents (if any) are all static constraints. + Followed. Size Clauses are not permitted on non-static + components, as described above. + + + An aliased component, or a component whose type is by-reference, + should always be allocated at an addressable location. + Followed. + + *13.2(6-8): Packed Types* + + If a type is packed, then the implementation should try to minimize + storage allocated to objects of the type, possibly at the expense + of speed of accessing components, subject to reasonable complexity + in addressing calculations. + + + The recommended level of support pragma `Pack' is: + + For a packed record type, the components should be packed as + tightly as possible subject to the Sizes of the component + subtypes, and subject to any `record_representation_clause' that + applies to the type; the implementation may, but need not, reorder + components or cross aligned word boundaries to improve the + packing. A component whose `Size' is greater than the word size + may be allocated an integral number of words. + Followed. Tight packing of arrays is supported for all component + sizes up to 64-bits. + + + An implementation should support Address clauses for imported + subprograms. + Followed. + + *13.3(14-19): Address Clauses* + + For an array X, `X'Address' should point at the first component of + the array, and not at the array bounds. + Followed. + + + The recommended level of support for the `Address' attribute is: + + `X'Address' should produce a useful result if X is an object that + is aliased or of a by-reference type, or is an entity whose + `Address' has been specified. + Followed. A valid address will be produced even if none of those + conditions have been met. If necessary, the object is forced into + memory to ensure the address is valid. + + + An implementation should support `Address' clauses for imported + subprograms. + Followed. + + + Objects (including subcomponents) that are aliased or of a + by-reference type should be allocated on storage element + boundaries. + Followed. + + + If the `Address' of an object is specified, or it is imported or + exported, then the implementation should not perform optimizations + based on assumptions of no aliases. + Followed. + + *13.3(29-35): Alignment Clauses* + + The recommended level of support for the `Alignment' attribute for + subtypes is: + + An implementation should support specified Alignments that are + factors and multiples of the number of storage elements per word, + subject to the following: + Followed. + + + An implementation need not support specified `Alignment's for + combinations of `Size's and `Alignment's that cannot be easily + loaded and stored by available machine instructions. + Followed. + + + An implementation need not support specified `Alignment's that are + greater than the maximum `Alignment' the implementation ever + returns by default. + Followed. + + + The recommended level of support for the `Alignment' attribute for + objects is: + + Same as above, for subtypes, but in addition: + Followed. + + + For stand-alone library-level objects of statically constrained + subtypes, the implementation should support all `Alignment's + supported by the target linker. For example, page alignment is + likely to be supported for such objects, but not for subtypes. + Followed. + + *13.3(42-43): Size Clauses* + + The recommended level of support for the `Size' attribute of + objects is: + + A `Size' clause should be supported for an object if the specified + `Size' is at least as large as its subtype's `Size', and + corresponds to a size in storage elements that is a multiple of the + object's `Alignment' (if the `Alignment' is nonzero). + Followed. + + *13.3(50-56): Size Clauses* + + If the `Size' of a subtype is specified, and allows for efficient + independent addressability (see 9.10) on the target architecture, + then the `Size' of the following objects of the subtype should + equal the `Size' of the subtype: + + Aliased objects (including components). + Followed. + + + `Size' clause on a composite subtype should not affect the + internal layout of components. + Followed. + + + The recommended level of support for the `Size' attribute of + subtypes is: + + + The `Size' (if not specified) of a static discrete or fixed point + subtype should be the number of bits needed to represent each value + belonging to the subtype using an unbiased representation, leaving + space for a sign bit only if the subtype contains negative values. + If such a subtype is a first subtype, then an implementation + should support a specified `Size' for it that reflects this + representation. + Followed. + + + For a subtype implemented with levels of indirection, the `Size' + should include the size of the pointers, but not the size of what + they point at. + Followed. + + *13.3(71-73): Component Size Clauses* + + The recommended level of support for the `Component_Size' + attribute is: + + + An implementation need not support specified `Component_Sizes' + that are less than the `Size' of the component subtype. + Followed. + + + An implementation should support specified `Component_Size's that + are factors and multiples of the word size. For such + `Component_Size's, the array should contain no gaps between + components. For other `Component_Size's (if supported), the array + should contain no gaps between components when packing is also + specified; the implementation should forbid this combination in + cases where it cannot support a no-gaps representation. + Followed. + + *13.4(9-10): Enumeration Representation Clauses* + + The recommended level of support for enumeration representation + clauses is: + + An implementation need not support enumeration representation + clauses for boolean types, but should at minimum support the + internal codes in the range `System.Min_Int.System.Max_Int'. + Followed. + + *13.5.1(17-22): Record Representation Clauses* + + The recommended level of support for + `record_representation_clauses' is: + + An implementation should support storage places that can be + extracted with a load, mask, shift sequence of machine code, and + set with a load, shift, mask, store sequence, given the available + machine instructions and run-time model. + Followed. + + + A storage place should be supported if its size is equal to the + `Size' of the component subtype, and it starts and ends on a + boundary that obeys the `Alignment' of the component subtype. + Followed. + + + If the default bit ordering applies to the declaration of a given + type, then for a component whose subtype's `Size' is less than the + word size, any storage place that does not cross an aligned word + boundary should be supported. + Followed. + + + An implementation may reserve a storage place for the tag field of + a tagged type, and disallow other components from overlapping that + place. + Followed. The storage place for the tag field is the beginning of + the tagged record, and its size is Address'Size. GNAT will reject + an explicit component clause for the tag field. + + + An implementation need not support a `component_clause' for a + component of an extension part if the storage place is not after + the storage places of all components of the parent type, whether + or not those storage places had been specified. + Followed. The above advice on record representation clauses is + followed, and all mentioned features are implemented. + + *13.5.2(5): Storage Place Attributes* + + If a component is represented using some form of pointer (such as + an offset) to the actual data of the component, and this data is + contiguous with the rest of the object, then the storage place + attributes should reflect the place of the actual data, not the + pointer. If a component is allocated discontinuously from the + rest of the object, then a warning should be generated upon + reference to one of its storage place attributes. + Followed. There are no such components in GNAT. + + *13.5.3(7-8): Bit Ordering* + + The recommended level of support for the non-default bit ordering + is: + + + If `Word_Size' = `Storage_Unit', then the implementation should + support the non-default bit ordering in addition to the default + bit ordering. + Followed. Word size does not equal storage size in this + implementation. Thus non-default bit ordering is not supported. + + *13.7(37): Address as Private* + + `Address' should be of a private type. + Followed. + + *13.7.1(16): Address Operations* + + Operations in `System' and its children should reflect the target + environment semantics as closely as is reasonable. For example, + on most machines, it makes sense for address arithmetic to "wrap + around". Operations that do not make sense should raise + `Program_Error'. + Followed. Address arithmetic is modular arithmetic that wraps + around. No operation raises `Program_Error', since all operations + make sense. + + *13.9(14-17): Unchecked Conversion* + + The `Size' of an array object should not include its bounds; hence, + the bounds should not be part of the converted data. + Followed. + + + The implementation should not generate unnecessary run-time checks + to ensure that the representation of S is a representation of the + target type. It should take advantage of the permission to return + by reference when possible. Restrictions on unchecked conversions + should be avoided unless required by the target environment. + Followed. There are no restrictions on unchecked conversion. A + warning is generated if the source and target types do not have + the same size since the semantics in this case may be target + dependent. + + + The recommended level of support for unchecked conversions is: + + + Unchecked conversions should be supported and should be reversible + in the cases where this clause defines the result. To enable + meaningful use of unchecked conversion, a contiguous + representation should be used for elementary subtypes, for + statically constrained array subtypes whose component subtype is + one of the subtypes described in this paragraph, and for record + subtypes without discriminants whose component subtypes are + described in this paragraph. + Followed. + + *13.11(23-25): Implicit Heap Usage* + + An implementation should document any cases in which it dynamically + allocates heap storage for a purpose other than the evaluation of + an allocator. + Followed, the only other points at which heap storage is + dynamically allocated are as follows: + + * At initial elaboration time, to allocate dynamically sized + global objects. + + * To allocate space for a task when a task is created. + + * To extend the secondary stack dynamically when needed. The + secondary stack is used for returning variable length results. + + + A default (implementation-provided) storage pool for an + access-to-constant type should not have overhead to support + deallocation of individual objects. + Followed. + + + A storage pool for an anonymous access type should be created at + the point of an allocator for the type, and be reclaimed when the + designated object becomes inaccessible. + Followed. + + *13.11.2(17): Unchecked De-allocation* + + For a standard storage pool, `Free' should actually reclaim the + storage. + Followed. + + *13.13.2(17): Stream Oriented Attributes* + + If a stream element is the same size as a storage element, then the + normal in-memory representation should be used by `Read' and + `Write' for scalar objects. Otherwise, `Read' and `Write' should + use the smallest number of stream elements needed to represent all + values in the base range of the scalar type. + Followed. In particular, the interpretation chosen is that of + AI-195, which specifies that the size to be used is that of the + first subtype. + + *A.1(52): Implementation Advice* + + If an implementation provides additional named predefined integer + types, then the names should end with `Integer' as in + `Long_Integer'. If an implementation provides additional named + predefined floating point types, then the names should end with + `Float' as in `Long_Float'. + Followed. + + *A.3.2(49): `Ada.Characters.Handling'* + + If an implementation provides a localized definition of `Character' + or `Wide_Character', then the effects of the subprograms in + `Characters.Handling' should reflect the localizations. See also + 3.5.2. + Followed. GNAT provides no such localized definitions. + + *A.4.4(106): Bounded-Length String Handling* + + Bounded string objects should not be implemented by implicit + pointers and dynamic allocation. + Followed. No implicit pointers or dynamic allocation are used. + + *A.5.2(46-47): Random Number Generation* + + Any storage associated with an object of type `Generator' should be + reclaimed on exit from the scope of the object. + Followed. + + + If the generator period is sufficiently long in relation to the + number of distinct initiator values, then each possible value of + `Initiator' passed to `Reset' should initiate a sequence of random + numbers that does not, in a practical sense, overlap the sequence + initiated by any other value. If this is not possible, then the + mapping between initiator values and generator states should be a + rapidly varying function of the initiator value. + Followed. The generator period is sufficiently long for the first + condition here to hold true. + + *A.10.7(23): `Get_Immediate'* + + The `Get_Immediate' procedures should be implemented with + unbuffered input. For a device such as a keyboard, input should be + "available" if a key has already been typed, whereas for a disk + file, input should always be available except at end of file. For + a file associated with a keyboard-like device, any line-editing + features of the underlying operating system should be disabled + during the execution of `Get_Immediate'. + Followed. + + *B.1(39-41): Pragma `Export'* + + If an implementation supports pragma `Export' to a given language, + then it should also allow the main subprogram to be written in that + language. It should support some mechanism for invoking the + elaboration of the Ada library units included in the system, and + for invoking the finalization of the environment task. On typical + systems, the recommended mechanism is to provide two subprograms + whose link names are `adainit' and `adafinal'. `adainit' should + contain the elaboration code for library units. `adafinal' should + contain the finalization code. These subprograms should have no + effect the second and subsequent time they are called. + Followed. + + + Automatic elaboration of pre-elaborated packages should be + provided when pragma `Export' is supported. + Followed when the main program is in Ada. If the main program is + in a foreign language, then `adainit' must be called to elaborate + pre-elaborated packages. + + + For each supported convention L other than `Intrinsic', an + implementation should support `Import' and `Export' pragmas for + objects of L-compatible types and for subprograms, and pragma + `Convention' for L-eligible types and for subprograms, presuming + the other language has corresponding features. Pragma + `Convention' need not be supported for scalar types. + Followed. + + *B.2(12-13): Package `Interfaces'* + + For each implementation-defined convention identifier, there + should be a child package of package Interfaces with the + corresponding name. This package should contain any declarations + that would be useful for interfacing to the language + (implementation) represented by the convention. Any declarations + useful for interfacing to any language on the given hardware + architecture should be provided directly in `Interfaces'. + Followed. An additional package not defined in the Ada 95 + Reference Manual is `Interfaces.CPP', used for interfacing to C++. + + + An implementation supporting an interface to C, COBOL, or Fortran + should provide the corresponding package or packages described in + the following clauses. + Followed. GNAT provides all the packages described in this + section. + + *B.3(63-71): Interfacing with C* + + An implementation should support the following interface + correspondences between Ada and C. + Followed. + + + An Ada procedure corresponds to a void-returning C function. + Followed. + + + An Ada function corresponds to a non-void C function. + Followed. + + + An Ada `in' scalar parameter is passed as a scalar argument to a C + function. + Followed. + + + An Ada `in' parameter of an access-to-object type with designated + type T is passed as a `T*' argument to a C function, where T is + the C type corresponding to the Ada type T. + Followed. + + + An Ada access T parameter, or an Ada `out' or `in out' parameter + of an elementary type T, is passed as a `T*' argument to a C + function, where T is the C type corresponding to the Ada type T. + In the case of an elementary `out' or `in out' parameter, a + pointer to a temporary copy is used to preserve by-copy semantics. + Followed. + + + An Ada parameter of a record type T, of any mode, is passed as a + `T*' argument to a C function, where T is the C structure + corresponding to the Ada type T. + Followed. This convention may be overridden by the use of the + C_Pass_By_Copy pragma, or Convention, or by explicitly specifying + the mechanism for a given call using an extended import or export + pragma. + + + An Ada parameter of an array type with component type T, of any + mode, is passed as a `T*' argument to a C function, where T is the + C type corresponding to the Ada type T. + Followed. + + + An Ada parameter of an access-to-subprogram type is passed as a + pointer to a C function whose prototype corresponds to the + designated subprogram's specification. + Followed. + + *B.4(95-98): Interfacing with COBOL* + + An Ada implementation should support the following interface + correspondences between Ada and COBOL. + Followed. + + + An Ada access T parameter is passed as a `BY REFERENCE' data item + of the COBOL type corresponding to T. + Followed. + + + An Ada in scalar parameter is passed as a `BY CONTENT' data item of + the corresponding COBOL type. + Followed. + + + Any other Ada parameter is passed as a `BY REFERENCE' data item of + the COBOL type corresponding to the Ada parameter type; for + scalars, a local copy is used if necessary to ensure by-copy + semantics. + Followed. + + *B.5(22-26): Interfacing with Fortran* + + An Ada implementation should support the following interface + correspondences between Ada and Fortran: + Followed. + + + An Ada procedure corresponds to a Fortran subroutine. + Followed. + + + An Ada function corresponds to a Fortran function. + Followed. + + + An Ada parameter of an elementary, array, or record type T is + passed as a T argument to a Fortran procedure, where T is the + Fortran type corresponding to the Ada type T, and where the INTENT + attribute of the corresponding dummy argument matches the Ada + formal parameter mode; the Fortran implementation's parameter + passing conventions are used. For elementary types, a local copy + is used if necessary to ensure by-copy semantics. + Followed. + + + An Ada parameter of an access-to-subprogram type is passed as a + reference to a Fortran procedure whose interface corresponds to the + designated subprogram's specification. + Followed. + + *C.1(3-5): Access to Machine Operations* + + The machine code or intrinsic support should allow access to all + operations normally available to assembly language programmers for + the target environment, including privileged instructions, if any. + Followed. + + + The interfacing pragmas (see Annex B) should support interface to + assembler; the default assembler should be associated with the + convention identifier `Assembler'. + Followed. + + + If an entity is exported to assembly language, then the + implementation should allocate it at an addressable location, and + should ensure that it is retained by the linking process, even if + not otherwise referenced from the Ada code. The implementation + should assume that any call to a machine code or assembler + subprogram is allowed to read or update every object that is + specified as exported. + Followed. + + *C.1(10-16): Access to Machine Operations* + + The implementation should ensure that little or no overhead is + associated with calling intrinsic and machine-code subprograms. + Followed for both intrinsics and machine-code subprograms. + + + It is recommended that intrinsic subprograms be provided for + convenient access to any machine operations that provide special + capabilities or efficiency and that are not otherwise available + through the language constructs. + Followed. A full set of machine operation intrinsic subprograms + is provided. + + + Atomic read-modify-write operations--e.g., test and set, compare + and swap, decrement and test, enqueue/dequeue. + Followed on any target supporting such operations. + + + Standard numeric functions--e.g., sin, log. + Followed on any target supporting such operations. + + + String manipulation operations--e.g., translate and test. + Followed on any target supporting such operations. + + + Vector operations--e.g., compare vector against thresholds. + Followed on any target supporting such operations. + + + Direct operations on I/O ports. + Followed on any target supporting such operations. + + *C.3(28): Interrupt Support* + + If the `Ceiling_Locking' policy is not in effect, the + implementation should provide means for the application to specify + which interrupts are to be blocked during protected actions, if + the underlying system allows for a finer-grain control of + interrupt blocking. + Followed. The underlying system does not allow for finer-grain + control of interrupt blocking. + + *C.3.1(20-21): Protected Procedure Handlers* + + Whenever possible, the implementation should allow interrupt + handlers to be called directly by the hardware. + Followed on any target where the underlying operating system + permits such direct calls. + + + Whenever practical, violations of any implementation-defined + restrictions should be detected before run time. + Followed. Compile time warnings are given when possible. + + *C.3.2(25): Package `Interrupts'* + + If implementation-defined forms of interrupt handler procedures are + supported, such as protected procedures with parameters, then for + each such form of a handler, a type analogous to + `Parameterless_Handler' should be specified in a child package of + `Interrupts', with the same operations as in the predefined + package Interrupts. + Followed. + + *C.4(14): Pre-elaboration Requirements* + + It is recommended that pre-elaborated packages be implemented in + such a way that there should be little or no code executed at run + time for the elaboration of entities not already covered by the + Implementation Requirements. + Followed. Executable code is generated in some cases, e.g. loops + to initialize large arrays. + + *C.5(8): Pragma `Discard_Names'* + + If the pragma applies to an entity, then the implementation should + reduce the amount of storage used for storing names associated + with that entity. + Followed. + + *C.7.2(30): The Package Task_Attributes* + + Some implementations are targeted to domains in which memory use + at run time must be completely deterministic. For such + implementations, it is recommended that the storage for task + attributes will be pre-allocated statically and not from the heap. + This can be accomplished by either placing restrictions on the + number and the size of the task's attributes, or by using the + pre-allocated storage for the first N attribute objects, and the + heap for the others. In the latter case, N should be documented. + Not followed. This implementation is not targeted to such a + domain. + + *D.3(17): Locking Policies* + + The implementation should use names that end with `_Locking' for + locking policies defined by the implementation. + Followed. A single implementation-defined locking policy is + defined, whose name (`Inheritance_Locking') follows this + suggestion. + + *D.4(16): Entry Queuing Policies* + + Names that end with `_Queuing' should be used for all + implementation-defined queuing policies. + Followed. No such implementation-defined queueing policies exist. + + *D.6(9-10): Preemptive Abort* + + Even though the `abort_statement' is included in the list of + potentially blocking operations (see 9.5.1), it is recommended + that this statement be implemented in a way that never requires + the task executing the `abort_statement' to block. + Followed. + + + On a multi-processor, the delay associated with aborting a task on + another processor should be bounded; the implementation should use + periodic polling, if necessary, to achieve this. + Followed. + + *D.7(21): Tasking Restrictions* + + When feasible, the implementation should take advantage of the + specified restrictions to produce a more efficient implementation. + GNAT currently takes advantage of these restrictions by providing + an optimized run time when the Ravenscar profile and the GNAT + restricted run time set of restrictions are specified. See pragma + `Ravenscar' and pragma `Restricted_Run_Time' for more details. + + *D.8(47-49): Monotonic Time* + + When appropriate, implementations should provide configuration + mechanisms to change the value of `Tick'. + Such configuration mechanisms are not appropriate to this + implementation and are thus not supported. + + + It is recommended that `Calendar.Clock' and `Real_Time.Clock' be + implemented as transformations of the same time base. + Followed. + + + It is recommended that the "best" time base which exists in the + underlying system be available to the application through `Clock'. + "Best" may mean highest accuracy or largest range. + Followed. + + *E.5(28-29): Partition Communication Subsystem* + + Whenever possible, the PCS on the called partition should allow for + multiple tasks to call the RPC-receiver with different messages and + should allow them to block until the corresponding subprogram body + returns. + Followed by GLADE, a separately supplied PCS that can be used with + GNAT. + + + The `Write' operation on a stream of type `Params_Stream_Type' + should raise `Storage_Error' if it runs out of space trying to + write the `Item' into the stream. + Followed by GLADE, a separately supplied PCS that can be used with + GNAT. + + *F(7): COBOL Support* + + If COBOL (respectively, C) is widely supported in the target + environment, implementations supporting the Information Systems + Annex should provide the child package `Interfaces.COBOL' + (respectively, `Interfaces.C') specified in Annex B and should + support a `convention_identifier' of COBOL (respectively, C) in + the interfacing pragmas (see Annex B), thus allowing Ada programs + to interface with programs written in that language. + Followed. + + *F.1(2): Decimal Radix Support* + + Packed decimal should be used as the internal representation for + objects of subtype S when S'Machine_Radix = 10. + Not followed. GNAT ignores S'Machine_Radix and always uses binary + representations. + + *G: Numerics* + + + If Fortran (respectively, C) is widely supported in the target + environment, implementations supporting the Numerics Annex should + provide the child package `Interfaces.Fortran' (respectively, + `Interfaces.C') specified in Annex B and should support a + `convention_identifier' of Fortran (respectively, C) in the + interfacing pragmas (see Annex B), thus allowing Ada programs to + interface with programs written in that language. + Followed. + + *G.1.1(56-58): Complex Types* + + + Because the usual mathematical meaning of multiplication of a + complex operand and a real operand is that of the scaling of both + components of the former by the latter, an implementation should + not perform this operation by first promoting the real operand to + complex type and then performing a full complex multiplication. + In systems that, in the future, support an Ada binding to IEC + 559:1989, the latter technique will not generate the required + result when one of the components of the complex operand is + infinite. (Explicit multiplication of the infinite component by + the zero component obtained during promotion yields a NaN that + propagates into the final result.) Analogous advice applies in the + case of multiplication of a complex operand and a pure-imaginary + operand, and in the case of division of a complex operand by a + real or pure-imaginary operand. + Not followed. + + + Similarly, because the usual mathematical meaning of addition of a + complex operand and a real operand is that the imaginary operand + remains unchanged, an implementation should not perform this + operation by first promoting the real operand to complex type and + then performing a full complex addition. In implementations in + which the `Signed_Zeros' attribute of the component type is `True' + (and which therefore conform to IEC 559:1989 in regard to the + handling of the sign of zero in predefined arithmetic operations), + the latter technique will not generate the required result when + the imaginary component of the complex operand is a negatively + signed zero. (Explicit addition of the negative zero to the zero + obtained during promotion yields a positive zero.) Analogous + advice applies in the case of addition of a complex operand and a + pure-imaginary operand, and in the case of subtraction of a + complex operand and a real or pure-imaginary operand. + Not followed. + + + Implementations in which `Real'Signed_Zeros' is `True' should + attempt to provide a rational treatment of the signs of zero + results and result components. As one example, the result of the + `Argument' function should have the sign of the imaginary + component of the parameter `X' when the point represented by that + parameter lies on the positive real axis; as another, the sign of + the imaginary component of the `Compose_From_Polar' function + should be the same as (respectively, the opposite of) that of the + `Argument' parameter when that parameter has a value of zero and + the `Modulus' parameter has a nonnegative (respectively, negative) + value. + Followed. + + *G.1.2(49): Complex Elementary Functions* + + Implementations in which `Complex_Types.Real'Signed_Zeros' is + `True' should attempt to provide a rational treatment of the signs + of zero results and result components. For example, many of the + complex elementary functions have components that are odd + functions of one of the parameter components; in these cases, the + result component should have the sign of the parameter component + at the origin. Other complex elementary functions have zero + components whose sign is opposite that of a parameter component at + the origin, or is always positive or always negative. + Followed. + + *G.2.4(19): Accuracy Requirements* + + The versions of the forward trigonometric functions without a + `Cycle' parameter should not be implemented by calling the + corresponding version with a `Cycle' parameter of + `2.0*Numerics.Pi', since this will not provide the required + accuracy in some portions of the domain. For the same reason, the + version of `Log' without a `Base' parameter should not be + implemented by calling the corresponding version with a `Base' + parameter of `Numerics.e'. + Followed. + + *G.2.6(15): Complex Arithmetic Accuracy* + + The version of the `Compose_From_Polar' function without a `Cycle' + parameter should not be implemented by calling the corresponding + version with a `Cycle' parameter of `2.0*Numerics.Pi', since this + will not provide the required accuracy in some portions of the + domain. + Followed. + +  + File: gnat_rm.info, Node: Implementation Defined Characteristics, Next: Intrinsic Subprograms, Prev: Implementation Advice, Up: Top + + Implementation Defined Characteristics + ************************************** + + In addition to the implementation dependent pragmas and attributes, + and the implementation advice, there are a number of other features of + Ada 95 that are potentially implementation dependent. These are + mentioned throughout the Ada 95 Reference Manual, and are summarized in + annex M. + + A requirement for conforming Ada compilers is that they provide + documentation describing how the implementation deals with each of these + issues. In this chapter, you will find each point in annex M listed + followed by a description in italic font of how GNAT handles the + implementation dependence. + + You can use this chapter as a guide to minimizing implementation + dependent features in your programs if portability to other compilers + and other operating systems is an important consideration. The numbers + in each section below correspond to the paragraph number in the Ada 95 + Reference Manual. + + + *2*. Whether or not each recommendation given in Implementation Advice + is followed. See 1.1.2(37). + + *Note Implementation Advice::. + + + *3*. Capacity limitations of the implementation. See 1.1.3(3). + + The complexity of programs that can be processed is limited only by the + total amount of available virtual memory, and disk space for the + generated object files. + + + *4*. Variations from the standard that are impractical to avoid given + the implementation's execution environment. See 1.1.3(6). + + There are no variations from the standard. + + + *5*. Which `code_statement's cause external interactions. See + 1.1.3(10). + + Any `code_statement' can potentially cause external interactions. + + + *6*. The coded representation for the text of an Ada program. See + 2.1(4). + + See separate section on source representation. + + + *7*. The control functions allowed in comments. See 2.1(14). + + See separate section on source representation. + + + *8*. The representation for an end of line. See 2.2(2). + + See separate section on source representation. + + + *9*. Maximum supported line length and lexical element length. See + 2.2(15). + + The maximum line length is 255 characters an the maximum length of a + lexical element is also 255 characters. + + + *10*. Implementation defined pragmas. See 2.8(14). + + *Note Implementation Defined Pragmas::. + + + *11*. Effect of pragma `Optimize'. See 2.8(27). + + Pragma `Optimize', if given with a `Time' or `Space' parameter, checks + that the optimization flag is set, and aborts if it is not. + + + *12*. The sequence of characters of the value returned by `S'Image' + when some of the graphic characters of `S'Wide_Image' are not defined + in `Character'. See 3.5(37). + + The sequence of characters is as defined by the wide character encoding + method used for the source. See section on source representation for + further details. + + + *13*. The predefined integer types declared in `Standard'. See + 3.5.4(25). + + `Short_Short_Integer' + 8 bit signed + + `Short_Integer' + (Short) 16 bit signed + + `Integer' + 32 bit signed + + `Long_Integer' + 64 bit signed (Alpha OpenVMS only) 32 bit signed (all other + targets) + + `Long_Long_Integer' + 64 bit signed + + + *14*. Any nonstandard integer types and the operators defined for + them. See 3.5.4(26). + + There are no nonstandard integer types. + + + *15*. Any nonstandard real types and the operators defined for them. + See 3.5.6(8). + + There are no nonstandard real types. + + + *16*. What combinations of requested decimal precision and range are + supported for floating point types. See 3.5.7(7). + + The precision and range is as defined by the IEEE standard. + + + *17*. The predefined floating point types declared in `Standard'. See + 3.5.7(16). + + `Short_Float' + 32 bit IEEE short + + `Float' + (Short) 32 bit IEEE short + + `Long_Float' + 64 bit IEEE long + + `Long_Long_Float' + 64 bit IEEE long (80 bit IEEE long on x86 processors) + + + *18*. The small of an ordinary fixed point type. See 3.5.9(8). + + `Fine_Delta' is 2**(-63) + + + *19*. What combinations of small, range, and digits are supported for + fixed point types. See 3.5.9(10). + + Any combinations are permitted that do not result in a small less than + `Fine_Delta' and do not result in a mantissa larger than 63 bits. If + the mantissa is larger than 53 bits on machines where Long_Long_Float + is 64 bits (true of all architectures except ia32), then the output from + Text_IO is accurate to only 53 bits, rather than the full mantissa. + This is because floating-point conversions are used to convert fixed + point. + + + *20*. The result of `Tags.Expanded_Name' for types declared within an + unnamed `block_statement'. See 3.9(10). + + Block numbers of the form `BNNN', where NNN is a decimal integer are + allocated. + + + *21*. Implementation-defined attributes. See 4.1.4(12). + + *Note Implementation Defined Attributes::. + + + *22*. Any implementation-defined time types. See 9.6(6). + + There are no implementation-defined time types. + + + *23*. The time base associated with relative delays. + + See 9.6(20). The time base used is that provided by the C library + function `gettimeofday'. + + + *24*. The time base of the type `Calendar.Time'. See 9.6(23). + + The time base used is that provided by the C library function + `gettimeofday'. + + + *25*. The time zone used for package `Calendar' operations. See + 9.6(24). + + The time zone used by package `Calendar' is the current system time zone + setting for local time, as accessed by the C library function + `localtime'. + + + *26*. Any limit on `delay_until_statements' of `select_statements'. + See 9.6(29). + + There are no such limits. + + + *27*. Whether or not two non overlapping parts of a composite object + are independently addressable, in the case where packing, record + layout, or `Component_Size' is specified for the object. See 9.10(1). + + Separate components are independently addressable if they do not share + overlapping storage units. + + + *28*. The representation for a compilation. See 10.1(2). + + A compilation is represented by a sequence of files presented to the + compiler in a single invocation of the `gcc' command. + + + *29*. Any restrictions on compilations that contain multiple + compilation_units. See 10.1(4). + + No single file can contain more than one compilation unit, but any + sequence of files can be presented to the compiler as a single + compilation. + + + *30*. The mechanisms for creating an environment and for adding and + replacing compilation units. See 10.1.4(3). + + See separate section on compilation model. + + + *31*. The manner of explicitly assigning library units to a partition. + See 10.2(2). + + If a unit contains an Ada main program, then the Ada units for the + partition are determined by recursive application of the rules in the + Ada Reference Manual section 10.2(2-6). In other words, the Ada units + will be those that are needed by the main program, and then this + definition of need is applied recursively to those units, and the + partition contains the transitive closure determined by this + relationship. In short, all the necessary units are included, with no + need to explicitly specify the list. If additional units are required, + e.g. by foreign language units, then all units must be mentioned in the + context clause of one of the needed Ada units. + + If the partition contains no main program, or if the main program is + in a language other than Ada, then GNAT provides the binder options + `-z' and `-n' respectively, and in this case a list of units can be + explicitly supplied to the binder for inclusion in the partition (all + units needed by these units will also be included automatically). For + full details on the use of these options, refer to the `GNAT User's + Guide' sections on Binding and Linking. + + + *32*. The implementation-defined means, if any, of specifying which + compilation units are needed by a given compilation unit. See 10.2(2). + + The units needed by a given compilation unit are as defined in the Ada + Reference Manual section 10.2(2-6). There are no + implementation-defined pragmas or other implementation-defined means + for specifying needed units. + + + *33*. The manner of designating the main subprogram of a partition. + See 10.2(7). + + The main program is designated by providing the name of the + corresponding `ALI' file as the input parameter to the binder. + + + *34*. The order of elaboration of `library_items'. See 10.2(18). + + The first constraint on ordering is that it meets the requirements of + chapter 10 of the Ada 95 Reference Manual. This still leaves some + implementation dependent choices, which are resolved by first + elaborating bodies as early as possible (i.e. in preference to specs + where there is a choice), and second by evaluating the immediate with + clauses of a unit to determine the probably best choice, and third by + elaborating in alphabetical order of unit names where a choice still + remains. + + + *35*. Parameter passing and function return for the main subprogram. + See 10.2(21). + + The main program has no parameters. It may be a procedure, or a + function returning an integer type. In the latter case, the returned + integer value is the return code of the program. + + + *36*. The mechanisms for building and running partitions. See + 10.2(24). + + GNAT itself supports programs with only a single partition. The + GNATDIST tool provided with the GLADE package (which also includes an + implementation of the PCS) provides a completely flexible method for + building and running programs consisting of multiple partitions. See + the separate GLADE manual for details. + + + *37*. The details of program execution, including program termination. + See 10.2(25). + + See separate section on compilation model. + + + *38*. The semantics of any non-active partitions supported by the + implementation. See 10.2(28). + + Passive partitions are supported on targets where shared memory is + provided by the operating system. See the GLADE reference manual for + further details. + + + *39*. The information returned by `Exception_Message'. See 11.4.1(10). + + Exception message returns the null string unless a specific message has + been passed by the program. + + + *40*. The result of `Exceptions.Exception_Name' for types declared + within an unnamed `block_statement'. See 11.4.1(12). + + Blocks have implementation defined names of the form `BNNN' where NNN + is an integer. + + + *41*. The information returned by `Exception_Information'. See + 11.4.1(13). + + `Exception_Information' returns a string in the following format: + + _Exception_Name:_ nnnnn + _Message:_ mmmmm + _PID:_ ppp + _Call stack traceback locations:_ + 0xhhhh 0xhhhh 0xhhhh ... 0xhhh + + where + + * `nnnn' is the fully qualified name of the exception in all upper + case letters. This line is always present. + + * `mmmm' is the message (this line present only if message is + non-null) + + * `ppp' is the Process Id value as a decimal integer (this line is + present only if the Process Id is non-zero). Currently we are not + making use of this field. + + * The Call stack traceback locations line and the following values + are present only if at least one traceback location was recorded. + The values are given in C style format, with lower case letters + for a-f, and only as many digits present as are necessary. + + The line terminator sequence at the end of each line, including the + last line is a single `LF' character (`16#0A#'). + + + *42*. Implementation-defined check names. See 11.5(27). + + No implementation-defined check names are supported. + + + *43*. The interpretation of each aspect of representation. See + 13.1(20). + + See separate section on data representations. + + + *44*. Any restrictions placed upon representation items. See 13.1(20). + + See separate section on data representations. + + + *45*. The meaning of `Size' for indefinite subtypes. See 13.3(48). + + Size for an indefinite subtype is the maximum possible size, except that + for the case of a subprogram parameter, the size of the parameter object + is the actual size. + + + *46*. The default external representation for a type tag. See + 13.3(75). + + The default external representation for a type tag is the fully expanded + name of the type in upper case letters. + + + *47*. What determines whether a compilation unit is the same in two + different partitions. See 13.3(76). + + A compilation unit is the same in two different partitions if and only + if it derives from the same source file. + + + *48*. Implementation-defined components. See 13.5.1(15). + + The only implementation defined component is the tag for a tagged type, + which contains a pointer to the dispatching table. + + + *49*. If `Word_Size' = `Storage_Unit', the default bit ordering. See + 13.5.3(5). + + `Word_Size' (32) is not the same as `Storage_Unit' (8) for this + implementation, so no non-default bit ordering is supported. The + default bit ordering corresponds to the natural endianness of the + target architecture. + + + *50*. The contents of the visible part of package `System' and its + language-defined children. See 13.7(2). + + See the definition of these packages in files `system.ads' and + `s-stoele.ads'. + + + *51*. The contents of the visible part of package + `System.Machine_Code', and the meaning of `code_statements'. See + 13.8(7). + + See the definition and documentation in file `s-maccod.ads'. + + + *52*. The effect of unchecked conversion. See 13.9(11). + + Unchecked conversion between types of the same size and results in an + uninterpreted transmission of the bits from one type to the other. If + the types are of unequal sizes, then in the case of discrete types, a + shorter source is first zero or sign extended as necessary, and a + shorter target is simply truncated on the left. For all non-discrete + types, the source is first copied if necessary to ensure that the + alignment requirements of the target are met, then a pointer is + constructed to the source value, and the result is obtained by + dereferencing this pointer after converting it to be a pointer to the + target type. + + + *53*. The manner of choosing a storage pool for an access type when + `Storage_Pool' is not specified for the type. See 13.11(17). + + There are 3 different standard pools used by the compiler when + `Storage_Pool' is not specified depending whether the type is local to + a subprogram or defined at the library level and whether + `Storage_Size'is specified or not. See documentation in the runtime + library units `System.Pool_Global', `System.Pool_Size' and + `System.Pool_Local' in files `s-poosiz.ads', `s-pooglo.ads' and + `s-pooloc.ads' for full details on the default pools used. + + + *54*. Whether or not the implementation provides user-accessible names + for the standard pool type(s). See 13.11(17). + + See documentation in the sources of the run time mentioned in paragraph + *53* . All these pools are accessible by means of `with''ing these + units. + + + *55*. The meaning of `Storage_Size'. See 13.11(18). + + `Storage_Size' is measured in storage units, and refers to the total + space available for an access type collection, or to the primary stack + space for a task. + + + *56*. Implementation-defined aspects of storage pools. See 13.11(22). + + See documentation in the sources of the run time mentioned in paragraph + *53* for details on GNAT-defined aspects of storage pools. + + + *57*. The set of restrictions allowed in a pragma `Restrictions'. See + 13.12(7). + + All RM defined Restriction identifiers are implemented. The following + additional restriction identifiers are provided. There are two separate + lists of implementation dependent restriction identifiers. The first + set requires consistency throughout a partition (in other words, if the + restriction identifier is used for any compilation unit in the + partition, then all compilation units in the partition must obey the + restriction. + + `Boolean_Entry_Barriers' + This restriction ensures at compile time that barriers in entry + declarations for protected types are restricted to references to + simple boolean variables defined in the private part of the + protected type. No other form of entry barriers is permitted. + This is one of the restrictions of the Ravenscar profile for + limited tasking (see also pragma `Ravenscar'). + + `Max_Entry_Queue_Depth => Expr' + This restriction is a declaration that any protected entry + compiled in the scope of the restriction has at most the specified + number of tasks waiting on the entry at any one time, and so no + queue is required. This restriction is not checked at compile + time. A program execution is erroneous if an attempt is made to + queue more than the specified number of tasks on such an entry. + + `No_Calendar' + This restriction ensures at compile time that there is no implicit + or explicit dependence on the package `Ada.Calendar'. + + `No_Dynamic_Interrupts' + This restriction ensures at compile time that there is no attempt + to dynamically associate interrupts. Only static association is + allowed. + + `No_Enumeration_Maps' + This restriction ensures at compile time that no operations + requiring enumeration maps are used (that is Image and Value + attributes applied to enumeration types). + + `No_Entry_Calls_In_Elaboration_Code' + This restriction ensures at compile time that no task or protected + entry calls are made during elaboration code. As a result of the + use of this restriction, the compiler can assume that no code past + an accept statement in a task can be executed at elaboration time. + + `No_Exception_Handlers' + This restriction ensures at compile time that there are no explicit + exception handlers. + + `No_Implicit_Conditionals' + This restriction ensures that the generated code does not contain + any implicit conditionals, either by modifying the generated code + where possible, or by rejecting any construct that would otherwise + generate an implicit conditional. The details and use of this + restriction are described in more detail in the High Integrity + product documentation. + + `No_Implicit_Loops' + This restriction ensures that the generated code does not contain + any implicit `for' loops, either by modifying the generated code + where possible, or by rejecting any construct that would otherwise + generate an implicit `for' loop. The details and use of this + restriction are described in more detail in the High Integrity + product documentation. + + `No_Local_Protected_Objects' + This restriction ensures at compile time that protected objects are + only declared at the library level. + + `No_Protected_Type_Allocators' + This restriction ensures at compile time that there are no + allocator expressions that attempt to allocate protected objects. + + `No_Secondary_Stack' + This restriction ensures at compile time that the generated code + does not contain any reference to the secondary stack. The + secondary stack is used to implement functions returning + unconstrained objects (arrays or records) on some targets. The + details and use of this restriction are described in more detail + in the High Integrity product documentation. + + `No_Select_Statements' + This restriction ensures at compile time no select statements of + any kind are permitted, that is the keyword `select' may not + appear. This is one of the restrictions of the Ravenscar profile + for limited tasking (see also pragma `Ravenscar'). + + `No_Standard_Storage_Pools' + This restriction ensures at compile time that no access types use + the standard default storage pool. Any access type declared must + have an explicit Storage_Pool attribute defined specifying a + user-defined storage pool. + + `No_Streams' + This restriction ensures at compile time that there are no + implicit or explicit dependencies on the package `Ada.Streams'. + + `No_Task_Attributes' + This restriction ensures at compile time that there are no + implicit or explicit dependencies on the package + `Ada.Task_Attributes'. + + `No_Task_Termination' + This restriction ensures at compile time that no terminate + alternatives appear in any task body. + + `No_Tasking' + This restriction prevents the declaration of tasks or task types + throughout the partition. It is similar in effect to the use of + `Max_Tasks => 0' except that violations are caught at compile time + and cause an error message to be output either by the compiler or + binder. + + `No_Wide_Characters' + This restriction ensures at compile time that no uses of the types + `Wide_Character' or `Wide_String' appear, and that no wide + character literals appear in the program (that is literals + representing characters not in type `Character'. + + `Static_Priorities' + This restriction ensures at compile time that all priority + expressions are static, and that there are no dependencies on the + package `Ada.Dynamic_Priorities'. + + `Static_Storage_Size' + This restriction ensures at compile time that any expression + appearing in a Storage_Size pragma or attribute definition clause + is static. + + The second set of implementation dependent restriction identifiers does + not require partition-wide consistency. The restriction may be + enforced for a single compilation unit without any effect on any of the + other compilation units in the partition. + + `No_Elaboration_Code' + This restriction ensures at compile time that no elaboration code + is generated. Note that this is not the same condition as is + enforced by pragma `Preelaborate'. There are cases in which + pragma `Preelaborate' still permits code to be generated (e.g. + code to initialize a large array to all zeroes), and there are + cases of units which do not meet the requirements for pragma + `Preelaborate', but for which no elaboration code is generated. + Generally, it is the case that preelaborable units will meet the + restrictions, with the exception of large aggregates initialized + with an others_clause, and exception declarations (which generate + calls to a run-time registry procedure). Note that this + restriction is enforced on a unit by unit basis, it need not be + obeyed consistently throughout a partition. + + `No_Entry_Queue' + This restriction is a declaration that any protected entry + compiled in the scope of the restriction has at most one task + waiting on the entry at any one time, and so no queue is required. + This restriction is not checked at compile time. A program + execution is erroneous if an attempt is made to queue a second + task on such an entry. + + `No_Implementation_Attributes' + This restriction checks at compile time that no GNAT-defined + attributes are present. With this restriction, the only + attributes that can be used are those defined in the Ada 95 + Reference Manual. + + `No_Implementation_Pragmas' + This restriction checks at compile time that no GNAT-defined + pragmas are present. With this restriction, the only pragmas that + can be used are those defined in the Ada 95 Reference Manual. + + `No_Implementation_Restrictions' + This restriction checks at compile time that no GNAT-defined + restriction identifiers (other than + `No_Implementation_Restrictions' itself) are present. With this + restriction, the only other restriction identifiers that can be + used are those defined in the Ada 95 Reference Manual. + + + *58*. The consequences of violating limitations on `Restrictions' + pragmas. See 13.12(9). + + Restrictions that can be checked at compile time result in illegalities + if violated. Currently there are no other consequences of violating + restrictions. + + + *59*. The representation used by the `Read' and `Write' attributes of + elementary types in terms of stream elements. See 13.13.2(9). + + The representation is the in-memory representation of the base type of + the type, using the number of bits corresponding to the `TYPE'Size' + value, and the natural ordering of the machine. + + + *60*. The names and characteristics of the numeric subtypes declared + in the visible part of package `Standard'. See A.1(3). + + See items describing the integer and floating-point types supported. + + + *61*. The accuracy actually achieved by the elementary functions. See + A.5.1(1). + + The elementary functions correspond to the functions available in the C + library. Only fast math mode is implemented. + + + *62*. The sign of a zero result from some of the operators or + functions in `Numerics.Generic_Elementary_Functions', when + `Float_Type'Signed_Zeros' is `True'. See A.5.1(46). + + The sign of zeroes follows the requirements of the IEEE 754 standard on + floating-point. + + + *63*. The value of `Numerics.Float_Random.Max_Image_Width'. See + A.5.2(27). + + Maximum image width is 649, see library file `a-numran.ads'. + + + *64*. The value of `Numerics.Discrete_Random.Max_Image_Width'. See + A.5.2(27). + + Maximum image width is 80, see library file `a-nudira.ads'. + + + *65*. The algorithms for random number generation. See A.5.2(32). + + The algorithm is documented in the source files `a-numran.ads' and + `a-numran.adb'. + + + *66*. The string representation of a random number generator's state. + See A.5.2(38). + + See the documentation contained in the file `a-numran.adb'. + + + *67*. The minimum time interval between calls to the time-dependent + Reset procedure that are guaranteed to initiate different random number + sequences. See A.5.2(45). + + The minimum period between reset calls to guarantee distinct series of + random numbers is one microsecond. + + + *68*. The values of the `Model_Mantissa', `Model_Emin', + `Model_Epsilon', `Model', `Safe_First', and `Safe_Last' attributes, if + the Numerics Annex is not supported. See A.5.3(72). + + See the source file `ttypef.ads' for the values of all numeric + attributes. + + + *69*. Any implementation-defined characteristics of the input-output + packages. See A.7(14). + + There are no special implementation defined characteristics for these + packages. + + + *70*. The value of `Buffer_Size' in `Storage_IO'. See A.9(10). + + All type representations are contiguous, and the `Buffer_Size' is the + value of `TYPE'Size' rounded up to the next storage unit boundary. + + + *71*. External files for standard input, standard output, and standard + error See A.10(5). + + These files are mapped onto the files provided by the C streams + libraries. See source file `i-cstrea.ads' for further details. + + + *72*. The accuracy of the value produced by `Put'. See A.10.9(36). + + If more digits are requested in the output than are represented by the + precision of the value, zeroes are output in the corresponding least + significant digit positions. + + + *73*. The meaning of `Argument_Count', `Argument', and `Command_Name'. + See A.15(1). + + These are mapped onto the `argv' and `argc' parameters of the main + program in the natural manner. + + + *74*. Implementation-defined convention names. See B.1(11). + + The following convention names are supported + + `Ada' + Ada + + `Assembler' + Assembly language + + `Asm' + Synonym for Assembler + + `Assembly' + Synonym for Assembler + + `C' + C + + `C_Pass_By_Copy' + Allowed only for record types, like C, but also notes that record + is to be passed by copy rather than reference. + + `COBOL' + COBOL + + `CPP' + C++ + + `Default' + Treated the same as C + + `External' + Treated the same as C + + `Fortran' + Fortran + + `Intrinsic' + For support of pragma `Import' with convention Intrinsic, see + separate section on Intrinsic Subprograms. + + `Stdcall' + Stdcall (used for Windows implementations only). This convention + correspond to the WINAPI (previously called Pascal convention) + C/C++ convention under Windows. A function with this convention + cleans the stack before exit. + + `DLL' + Synonym for Stdcall + + `Win32' + Synonym for Stdcall + + `Stubbed' + Stubbed is a special convention used to indicate that the body of + the subprogram will be entirely ignored. Any call to the + subprogram is converted into a raise of the `Program_Error' + exception. If a pragma `Import' specifies convention `stubbed' + then no body need be present at all. This convention is useful + during development for the inclusion of subprograms whose body has + not yet been written. + + In addition, all otherwise unrecognized convention names are also + treated as being synonymous with convention C. In all implementations + except for VMS, use of such other names results in a warning. In VMS + implementations, these names are accepted silently. + + + *75*. The meaning of link names. See B.1(36). + + Link names are the actual names used by the linker. + + + *76*. The manner of choosing link names when neither the link name nor + the address of an imported or exported entity is specified. See + B.1(36). + + The default linker name is that which would be assigned by the relevant + external language, interpreting the Ada name as being in all lower case + letters. + + + *77*. The effect of pragma `Linker_Options'. See B.1(37). + + The string passed to `Linker_Options' is presented uninterpreted as an + argument to the link command, unless it contains Ascii.NUL characters. + NUL characters if they appear act as argument separators, so for example + + pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef"); + + causes two separate arguments `-labc' and `-ldef' to be passed to the + linker. The order of linker options is preserved for a given unit. The + final list of options passed to the linker is in reverse order of the + elaboration order. For example, linker options fo a body always appear + before the options from the corresponding package spec. + + + *78*. The contents of the visible part of package `Interfaces' and its + language-defined descendants. See B.2(1). + + See files with prefix `i-' in the distributed library. + + + *79*. Implementation-defined children of package `Interfaces'. The + contents of the visible part of package `Interfaces'. See B.2(11). + + See files with prefix `i-' in the distributed library. + + + *80*. The types `Floating', `Long_Floating', `Binary', `Long_Binary', + `Decimal_ Element', and `COBOL_Character'; and the initialization of + the variables `Ada_To_COBOL' and `COBOL_To_Ada', in `Interfaces.COBOL'. + See B.4(50). + + `Floating' + Float + + `Long_Floating' + (Floating) Long_Float + + `Binary' + Integer + + `Long_Binary' + Long_Long_Integer + + `Decimal_Element' + Character + + `COBOL_Character' + Character + + For initialization, see the file `i-cobol.ads' in the distributed + library. + + + *81*. Support for access to machine instructions. See C.1(1). + + See documentation in file `s-maccod.ads' in the distributed library. + + + *82*. Implementation-defined aspects of access to machine operations. + See C.1(9). + + See documentation in file `s-maccod.ads' in the distributed library. + + + *83*. Implementation-defined aspects of interrupts. See C.3(2). + + Interrupts are mapped to signals or conditions as appropriate. See + definition of unit `Ada.Interrupt_Names' in source file `a-intnam.ads' + for details on the interrupts supported on a particular target. + + + *84*. Implementation-defined aspects of pre-elaboration. See C.4(13). + + GNAT does not permit a partition to be restarted without reloading, + except under control of the debugger. + + + *85*. The semantics of pragma `Discard_Names'. See C.5(7). + + Pragma `Discard_Names' causes names of enumeration literals to be + suppressed. In the presence of this pragma, the Image attribute + provides the image of the Pos of the literal, and Value accepts Pos + values. + + + *86*. The result of the `Task_Identification.Image' attribute. See + C.7.1(7). + + The result of this attribute is an 8-digit hexadecimal string + representing the virtual address of the task control block. + + + *87*. The value of `Current_Task' when in a protected entry or + interrupt handler. See C.7.1(17). + + Protected entries or interrupt handlers can be executed by any + convenient thread, so the value of `Current_Task' is undefined. + + + *88*. The effect of calling `Current_Task' from an entry body or + interrupt handler. See C.7.1(19). + + The effect of calling `Current_Task' from an entry body or interrupt + handler is to return the identification of the task currently executing + the code. + + + *89*. Implementation-defined aspects of `Task_Attributes'. See + C.7.2(19). + + There are no implementation-defined aspects of `Task_Attributes'. + + + *90*. Values of all `Metrics'. See D(2). + + The metrics information for GNAT depends on the performance of the + underlying operating system. The sources of the run-time for tasking + implementation, together with the output from `-gnatG' can be used to + determine the exact sequence of operating systems calls made to + implement various tasking constructs. Together with appropriate + information on the performance of the underlying operating system, on + the exact target in use, this information can be used to determine the + required metrics. + + + *91*. The declarations of `Any_Priority' and `Priority'. See D.1(11). + + See declarations in file `system.ads'. + + + *92*. Implementation-defined execution resources. See D.1(15). + + There are no implementation-defined execution resources. + + + *93*. Whether, on a multiprocessor, a task that is waiting for access + to a protected object keeps its processor busy. See D.2.1(3). + + On a multi-processor, a task that is waiting for access to a protected + object does not keep its processor busy. + + + *94*. The affect of implementation defined execution resources on task + dispatching. See D.2.1(9). + + Tasks map to threads in the threads package used by GNAT. Where + possible and appropriate, these threads correspond to native threads of + the underlying operating system. + + + *95*. Implementation-defined `policy_identifiers' allowed in a pragma + `Task_Dispatching_Policy'. See D.2.2(3). + + There are no implementation-defined policy-identifiers allowed in this + pragma. + + + *96*. Implementation-defined aspects of priority inversion. See + D.2.2(16). + + Execution of a task cannot be preempted by the implementation processing + of delay expirations for lower priority tasks. + + + *97*. Implementation defined task dispatching. See D.2.2(18). + + The policy is the same as that of the underlying threads implementation. + + + *98*. Implementation-defined `policy_identifiers' allowed in a pragma + `Locking_Policy'. See D.3(4). + + The only implementation defined policy permitted in GNAT is + `Inheritance_Locking'. On targets that support this policy, locking is + implemented by inheritance, i.e. the task owning the lock operates at a + priority equal to the highest priority of any task currently requesting + the lock. + + + *99*. Default ceiling priorities. See D.3(10). + + The ceiling priority of protected objects of the type + `System.Interrupt_Priority'Last' as described in the Ada 95 Reference + Manual D.3(10), + + + *100*. The ceiling of any protected object used internally by the + implementation. See D.3(16). + + The ceiling priority of internal protected objects is + `System.Priority'Last'. + + + *101*. Implementation-defined queuing policies. See D.4(1). + + There are no implementation-defined queueing policies. + + + *102*. On a multiprocessor, any conditions that cause the completion + of an aborted construct to be delayed later than what is specified for + a single processor. See D.6(3). + + The semantics for abort on a multi-processor is the same as on a single + processor, there are no further delays. + + + *103*. Any operations that implicitly require heap storage allocation. + See D.7(8). + + The only operation that implicitly requires heap storage allocation is + task creation. + + + *104*. Implementation-defined aspects of pragma `Restrictions'. See + D.7(20). + + There are no such implementation-defined aspects. + + + *105*. Implementation-defined aspects of package `Real_Time'. See + D.8(17). + + There are no implementation defined aspects of package `Real_Time'. + + + *106*. Implementation-defined aspects of `delay_statements'. See + D.9(8). + + Any difference greater than one microsecond will cause the task to be + delayed (see D.9(7)). + + + *107*. The upper bound on the duration of interrupt blocking caused by + the implementation. See D.12(5). + + The upper bound is determined by the underlying operating system. In + no cases is it more than 10 milliseconds. + + + *108*. The means for creating and executing distributed programs. See + E(5). + + The GLADE package provides a utility GNATDIST for creating and executing + distributed programs. See the GLADE reference manual for further + details. + + + *109*. Any events that can result in a partition becoming + inaccessible. See E.1(7). + + See the GLADE reference manual for full details on such events. + + + *110*. The scheduling policies, treatment of priorities, and + management of shared resources between partitions in certain cases. See + E.1(11). + + See the GLADE reference manual for full details on these aspects of + multi-partition execution. + + + *111*. Events that cause the version of a compilation unit to change. + See E.3(5). + + Editing the source file of a compilation unit, or the source files of + any units on which it is dependent in a significant way cause the + version to change. No other actions cause the version number to + change. All changes are significant except those which affect only + layout, capitalization or comments. + + + *112*. Whether the execution of the remote subprogram is immediately + aborted as a result of cancellation. See E.4(13). + + See the GLADE reference manual for details on the effect of abort in a + distributed application. + + + *113*. Implementation-defined aspects of the PCS. See E.5(25). + + See the GLADE reference manual for a full description of all + implementation defined aspects of the PCS. + + + *114*. Implementation-defined interfaces in the PCS. See E.5(26). + + See the GLADE reference manual for a full description of all + implementation defined interfaces. + + + *115*. The values of named numbers in the package `Decimal'. See + F.2(7). + + `Max_Scale' + +18 + + `Min_Scale' + -18 + + `Min_Delta' + 1.0E-18 + + `Max_Delta' + 1.0E+18 + + `Max_Decimal_Digits' + 18 + + + *116*. The value of `Max_Picture_Length' in the package + `Text_IO.Editing'. See F.3.3(16). + + 64 + + + *117*. The value of `Max_Picture_Length' in the package + `Wide_Text_IO.Editing'. See F.3.4(5). + + 64 + + + *118*. The accuracy actually achieved by the complex elementary + functions and by other complex arithmetic operations. See G.1(1). + + Standard library functions are used for the complex arithmetic + operations. Only fast math mode is currently supported. + + + *119*. The sign of a zero result (or a component thereof) from any + operator or function in `Numerics.Generic_Complex_Types', when + `Real'Signed_Zeros' is True. See G.1.1(53). + + The signs of zero values are as recommended by the relevant + implementation advice. + + + *120*. The sign of a zero result (or a component thereof) from any + operator or function in + `Numerics.Generic_Complex_Elementary_Functions', when + `Real'Signed_Zeros' is `True'. See G.1.2(45). + + The signs of zero values are as recommended by the relevant + implementation advice. + + + *121*. Whether the strict mode or the relaxed mode is the default. + See G.2(2). + + The strict mode is the default. There is no separate relaxed mode. + GNAT provides a highly efficient implementation of strict mode. + + + *122*. The result interval in certain cases of fixed-to-float + conversion. See G.2.1(10). + + For cases where the result interval is implementation dependent, the + accuracy is that provided by performing all operations in 64-bit IEEE + floating-point format. + + + *123*. The result of a floating point arithmetic operation in overflow + situations, when the `Machine_Overflows' attribute of the result type + is `False'. See G.2.1(13). + + Infinite and Nan values are produced as dictated by the IEEE + floating-point standard. + + + *124*. The result interval for division (or exponentiation by a + negative exponent), when the floating point hardware implements division + as multiplication by a reciprocal. See G.2.1(16). + + Not relevant, division is IEEE exact. + + + *125*. The definition of close result set, which determines the + accuracy of certain fixed point multiplications and divisions. See + G.2.3(5). + + Operations in the close result set are performed using IEEE long format + floating-point arithmetic. The input operands are converted to + floating-point, the operation is done in floating-point, and the result + is converted to the target type. + + + *126*. Conditions on a `universal_real' operand of a fixed point + multiplication or division for which the result shall be in the perfect + result set. See G.2.3(22). + + The result is only defined to be in the perfect result set if the result + can be computed by a single scaling operation involving a scale factor + representable in 64-bits. + + + *127*. The result of a fixed point arithmetic operation in overflow + situations, when the `Machine_Overflows' attribute of the result type + is `False'. See G.2.3(27). + + Not relevant, `Machine_Overflows' is `True' for fixed-point types. + + + *128*. The result of an elementary function reference in overflow + situations, when the `Machine_Overflows' attribute of the result type + is `False'. See G.2.4(4). + + IEEE infinite and Nan values are produced as appropriate. + + + *129*. The value of the angle threshold, within which certain + elementary functions, complex arithmetic operations, and complex + elementary functions yield results conforming to a maximum relative + error bound. See G.2.4(10). + + Information on this subject is not yet available. + + + *130*. The accuracy of certain elementary functions for parameters + beyond the angle threshold. See G.2.4(10). + + Information on this subject is not yet available. + + + *131*. The result of a complex arithmetic operation or complex + elementary function reference in overflow situations, when the + `Machine_Overflows' attribute of the corresponding real type is + `False'. See G.2.6(5). + + IEEE infinite and Nan values are produced as appropriate. + + + *132*. The accuracy of certain complex arithmetic operations and + certain complex elementary functions for parameters (or components + thereof) beyond the angle threshold. See G.2.6(8). + + Information on those subjects is not yet available. + + + *133*. Information regarding bounded errors and erroneous execution. + See H.2(1). + + Information on this subject is not yet available. + + + *134*. Implementation-defined aspects of pragma `Inspection_Point'. + See H.3.2(8). + + Pragma `Inspection_Point' ensures that the variable is live and can be + examined by the debugger at the inspection point. + + + *135*. Implementation-defined aspects of pragma `Restrictions'. See + H.4(25). + + There are no implementation-defined aspects of pragma `Restrictions'. + The use of pragma `Restrictions [No_Exceptions]' has no effect on the + generated code. Checks must suppressed by use of pragma `Suppress'. + + + *136*. Any restrictions on pragma `Restrictions'. See H.4(27). + + There are no restrictions on pragma `Restrictions'. + +  + File: gnat_rm.info, Node: Intrinsic Subprograms, Next: Representation Clauses and Pragmas, Prev: Implementation Defined Characteristics, Up: Top + + Intrinsic Subprograms + ********************* + + * Menu: + + * Intrinsic Operators:: + * Enclosing_Entity:: + * Exception_Information:: + * Exception_Message:: + * Exception_Name:: + * File:: + * Line:: + * Rotate_Left:: + * Rotate_Right:: + * Shift_Left:: + * Shift_Right:: + * Shift_Right_Arithmetic:: + * Source_Location:: + + GNAT allows a user application program to write the declaration: + + pragma Import (Intrinsic, name); + + providing that the name corresponds to one of the implemented intrinsic + subprograms in GNAT, and that the parameter profile of the referenced + subprogram meets the requirements. This chapter describes the set of + implemented intrinsic subprograms, and the requirements on parameter + profiles. Note that no body is supplied; as with other uses of pragma + Import, the body is supplied elsewhere (in this case by the compiler + itself). Note that any use of this feature is potentially + non-portable, since the Ada standard does not require Ada compilers to + implement this feature. + +  + File: gnat_rm.info, Node: Intrinsic Operators, Next: Enclosing_Entity, Up: Intrinsic Subprograms + + Intrinsic Operators + =================== + + All the predefined numeric operators in package Standard in `pragma + Import (Intrinsic,..)' declarations. In the binary operator case, the + operands must have the same size. The operand or operands must also be + appropriate for the operator. For example, for addition, the operands + must both be floating-point or both be fixed-point, and the right + operand for `"**"' must have a root type of `Standard.Integer'Base'. + You can use an intrinsic operator declaration as in the following + example: + + type Int1 is new Integer; + type Int2 is new Integer; + + function "+" (X1 : Int1; X2 : Int2) return Int1; + function "+" (X1 : Int1; X2 : Int2) return Int2; + pragma Import (Intrinsic, "+"); + + This declaration would permit "mixed mode" arithmetic on items of the + differing types `Int1' and `Int2'. It is also possible to specify such + operators for private types, if the full views are appropriate + arithmetic types. + +  + File: gnat_rm.info, Node: Enclosing_Entity, Next: Exception_Information, Prev: Intrinsic Operators, Up: Intrinsic Subprograms + + Enclosing_Entity + ================ + + This intrinsic subprogram is used in the implementation of the library + routine `GNAT.Source_Info'. The only useful use of the intrinsic + import in this case is the one in this unit, so an application program + should simply call the function `GNAT.Source_Info.Enclosing_Entity' to + obtain the name of the current subprogram, package, task, entry, or + protected subprogram. + +  + File: gnat_rm.info, Node: Exception_Information, Next: Exception_Message, Prev: Enclosing_Entity, Up: Intrinsic Subprograms + + Exception_Information + ===================== + + This intrinsic subprogram is used in the implementation of the library + routine `GNAT.Current_Exception'. The only useful use of the intrinsic + import in this case is the one in this unit, so an application program + should simply call the function + `GNAT.Current_Exception.Exception_Information' to obtain the exception + information associated with the current exception. + +  + File: gnat_rm.info, Node: Exception_Message, Next: Exception_Name, Prev: Exception_Information, Up: Intrinsic Subprograms + + Exception_Message + ================= + + This intrinsic subprogram is used in the implementation of the library + routine `GNAT.Current_Exception'. The only useful use of the intrinsic + import in this case is the one in this unit, so an application program + should simply call the function + `GNAT.Current_Exception.Exception_Message' to obtain the message + associated with the current exception. + +  + File: gnat_rm.info, Node: Exception_Name, Next: File, Prev: Exception_Message, Up: Intrinsic Subprograms + + Exception_Name + ============== + + This intrinsic subprogram is used in the implementation of the library + routine `GNAT.Current_Exception'. The only useful use of the intrinsic + import in this case is the one in this unit, so an application program + should simply call the function `GNAT.Current_Exception.Exception_Name' + to obtain the name of the current exception. + +  + File: gnat_rm.info, Node: File, Next: Line, Prev: Exception_Name, Up: Intrinsic Subprograms + + File + ==== + + This intrinsic subprogram is used in the implementation of the library + routine `GNAT.Source_Info'. The only useful use of the intrinsic + import in this case is the one in this unit, so an application program + should simply call the function `GNAT.Source_Info.File' to obtain the + name of the current file. + +  + File: gnat_rm.info, Node: Line, Next: Rotate_Left, Prev: File, Up: Intrinsic Subprograms + + Line + ==== + + This intrinsic subprogram is used in the implementation of the library + routine `GNAT.Source_Info'. The only useful use of the intrinsic + import in this case is the one in this unit, so an application program + should simply call the function `GNAT.Source_Info.Line' to obtain the + number of the current source line. + +  + File: gnat_rm.info, Node: Rotate_Left, Next: Rotate_Right, Prev: Line, Up: Intrinsic Subprograms + + Rotate_Left + =========== + + In standard Ada 95, the `Rotate_Left' function is available only for + the predefined modular types in package `Interfaces'. However, in GNAT + it is possible to define a Rotate_Left function for a user defined + modular type or any signed integer type as in this example: + + function Shift_Left + (Value : My_Modular_Type; + Amount : Natural) + return My_Modular_Type; + + The requirements are that the profile be exactly as in the example + above. The only modifications allowed are in the formal parameter + names, and in the type of `Value' and the return type, which must be + the same, and must be either a signed integer type, or a modular + integer type with a binary modulus, and the size must be 8. 16, 32 or + 64 bits. + +  + File: gnat_rm.info, Node: Rotate_Right, Next: Shift_Left, Prev: Rotate_Left, Up: Intrinsic Subprograms + + Rotate_Right + ============ + + A `Rotate_Right' function can be defined for any user defined binary + modular integer type, or signed integer type, as described above for + `Rotate_Left'. + +  + File: gnat_rm.info, Node: Shift_Left, Next: Shift_Right, Prev: Rotate_Right, Up: Intrinsic Subprograms + + Shift_Left + ========== + + A `Shift_Left' function can be defined for any user defined binary + modular integer type, or signed integer type, as described above for + `Rotate_Left'. + +  + File: gnat_rm.info, Node: Shift_Right, Next: Shift_Right_Arithmetic, Prev: Shift_Left, Up: Intrinsic Subprograms + + Shift_Right + =========== + + A `Shift_Right' function can be defined for any user defined binary + modular integer type, or signed integer type, as described above for + `Rotate_Left'. + +  + File: gnat_rm.info, Node: Shift_Right_Arithmetic, Next: Source_Location, Prev: Shift_Right, Up: Intrinsic Subprograms + + Shift_Right_Arithmetic + ====================== + + A `Shift_Right_Arithmetic' function can be defined for any user defined + binary modular integer type, or signed integer type, as described above + for `Rotate_Left'. + +  + File: gnat_rm.info, Node: Source_Location, Prev: Shift_Right_Arithmetic, Up: Intrinsic Subprograms + + Source_Location + =============== + + This intrinsic subprogram is used in the implementation of the library + routine `GNAT.Source_Info'. The only useful use of the intrinsic + import in this case is the one in this unit, so an application program + should simply call the function `GNAT.Source_Info.Source_Location' to + obtain the current source file location. + +  + File: gnat_rm.info, Node: Representation Clauses and Pragmas, Next: Standard Library Routines, Prev: Intrinsic Subprograms, Up: Top + + Representation Clauses and Pragmas + ********************************** + + * Menu: + + * Alignment Clauses:: + * Size Clauses:: + * Storage_Size Clauses:: + * Size of Variant Record Objects:: + * Biased Representation :: + * Value_Size and Object_Size Clauses:: + * Component_Size Clauses:: + * Bit_Order Clauses:: + * Effect of Bit_Order on Byte Ordering:: + * Pragma Pack for Arrays:: + * Pragma Pack for Records:: + * Record Representation Clauses:: + * Enumeration Clauses:: + * Address Clauses:: + * Effect of Convention on Representation:: + * Determining the Representations chosen by GNAT:: + + This section describes the representation clauses accepted by GNAT, and + their effect on the representation of corresponding data objects. + + GNAT fully implements Annex C (Systems Programming). This means + that all the implementation advice sections in chapter 13 are fully + implemented. However, these sections only require a minimal level of + support for representation clauses. GNAT provides much more extensive + capabilities, and this section describes the additional capabilities + provided. + +  + File: gnat_rm.info, Node: Alignment Clauses, Next: Size Clauses, Up: Representation Clauses and Pragmas + + Alignment Clauses + ================= + + GNAT requires that all alignment clauses specify a power of 2, and all + default alignments are always a power of 2. The default alignment + values are as follows: + + * Primitive Types For primitive types, the alignment is the maximum + of the actual size of objects of the type, and the maximum + alignment supported by the target. For example, for type + Long_Float, the object size is 8 bytes, and the default alignment + will be 8 on any target that supports alignments this large, but + on some targets, the maximum alignment may be smaller than 8, in + which case objects of type Long_Float will be maximally aligned. + + * Arrays For arrays, the alignment is equal to the alignment of the + component type for the normal case where no packing or component + size is given. If the array is packed, and the packing is + effective (see separate section on packed arrays), then the + alignment will be one for long packed arrays, or arrays whose + length is not known at compile time. For short packed arrays, + which are handled internally as modular types, the alignment will + be as described for primitive types, e.g. a packed array of length + 31 bits will have an object size of four bytes, and an alignment + of 4. + + * Records For the normal non-packed case, the alignment of a record + is equal to the maximum alignment of any of its components. For + tagged records, this includes the implicit access type used for + the tag. If a pragma `Pack' is used and all fields are packable + (see separate section on pragma `Pack'), then the resulting + alignment is 1. + + A special case is when the size of the record is given explicitly, + or a full record representation clause is given, and the size of + the record is 2, 4, or 8 bytes. In this case, an alignment is + chosen to match the size of the record. For example, if we have: + + type Small is record + A, B : Character; + end record; + + then the default alignment of the record type `Small' is 2, not 1. + This leads to more efficient code when the record is treated as a + unit, and also allows the type to specified as `Atomic' on + architectures requiring strict alignment. + + + An alignment clause may always specify a larger alignment than the + default value, up to some maximum value dependent on the target + (obtainable by using the attribute reference System'Maximum_Alignment). + The only case in which it is permissible to specify a smaller + alignment than the default value is in the case of a record for which a + record representation clause is given. In this case, packable fields + for which a component clause is given still result in a default + alignment corresponding to the original type, but this may be + overridden, since these components in fact only require an alignment of + one byte. For example, given + + type v is record + a : integer; + end record; + + for v use record + a at 0 range 0 .. 31; + end record; + + for v'alignment use 1; + + The default alignment for the type `v' is 4, as a result of the integer + field in the record, but since this field is placed with a component + clause, it is permissible, as shown, to override the default alignment + of the record to a smaller value. + +  + File: gnat_rm.info, Node: Size Clauses, Next: Storage_Size Clauses, Prev: Alignment Clauses, Up: Representation Clauses and Pragmas + + Size Clauses + ============ + + The default size of types is as specified in the reference manual. For + objects, GNAT will generally increase the type size so that the object + size is a multiple of storage units, and also a multiple of the + alignment. For example + + type Smallint is range 1 .. 6; + + type Rec is record + y1 : integer; + y2 : boolean; + end record; + + In this example, `Smallint' has a size of 3, as specified by the RM + rules, but objects of this type will have a size of 8, since objects by + default occupy an integral number of storage units. On some targets, + notably older versions of the Digital Alpha, the size of stand alone + objects of this type may be 32, reflecting the inability of the + hardware to do byte load/stores. + + Similarly, the size of type `Rec' is 40 bits, but the alignment is + 4, so objects of this type will have their size increased to 64 bits so + that it is a multiple of the alignment. The reason for this decision, + which is in accordance with the specific note in RM 13.3(43): + + A Size clause should be supported for an object if the specified + Size is at least as large as its subtype's Size, and corresponds + to a size in storage elements that is a multiple of the object's + Alignment (if the Alignment is nonzero). + + An explicit size clause may be used to override the default size by + increasing it. For example, if we have: + + type My_Boolean is new Boolean; + for My_Boolean'Size use 32; + + then objects of this type will always be 32 bits long. In the case of + discrete types, the size can be increased up to 64 bits, with the effect + that the entire specified field is used to hold the value, sign- or + zero-extended as appropriate. If more than 64 bits is specified, then + padding space is allocated after the value, and a warning is issued that + there are unused bits. + + Similarly the size of records and arrays may be increased, and the + effect is to add padding bits after the value. This also causes a + warning message to be generated. + + The largest Size value permitted in GNAT is 2**32-1. Since this is a + Size in bits, this corresponds to an object of size 256 megabytes (minus + one). This limitation is true on all targets. The reason for this + limitation is that it improves the quality of the code in many cases if + it is known that a Size value can be accommodated in an object of type + Integer. + +  + File: gnat_rm.info, Node: Storage_Size Clauses, Next: Size of Variant Record Objects, Prev: Size Clauses, Up: Representation Clauses and Pragmas + + Storage_Size Clauses + ==================== + + For tasks, the `Storage_Size' clause specifies the amount of space to + be allocated for the task stack. This cannot be extended, and if the + stack is exhausted, then `Storage_Error' will be raised if stack + checking is enabled. If the default size of 20K bytes is insufficient, + then you need to use a `Storage_Size' attribute definition clause, or a + `Storage_Size' pragma in the task definition to set the appropriate + required size. A useful technique is to include in every task + definition a pragma of the form: + + pragma Storage_Size (Default_Stack_Size); + + Then Default_Stack_Size can be defined in a global package, and modified + as required. Any tasks requiring different task stack sizes from the + default can have an appropriate alternative reference in the pragma. + + For access types, the `Storage_Size' clause specifies the maximum + space available for allocation of objects of the type. If this space is + exceeded then `Storage_Error' will be raised by an allocation attempt. + In the case where the access type is declared local to a subprogram, the + use of a `Storage_Size' clause triggers automatic use of a special + predefined storage pool (`System.Pool_Size') that ensures that all + space for the pool is automatically reclaimed on exit from the scope in + which the type is declared. + + A special case recognized by the compiler is the specification of a + `Storage_Size' of zero for an access type. This means that no items + can be allocated from the pool, and this is recognized at compile time, + and all the overhead normally associated with maintaining a fixed size + storage pool is eliminated. Consider the following example: + + procedure p is + type R is array (Natural) of Character; + type P is access all R; + for P'Storage_Size use 0; + -- Above access type intended only for interfacing purposes + + y : P; + + procedure g (m : P); + pragma Import (C, g); + + -- ... + + begin + -- ... + y := new R; + end; + + As indicated in this example, these dummy storage pools are often + useful in connection with interfacing where no object will ever be + allocated. If you compile the above example, you get the warning: + + p.adb:16:09: warning: allocation from empty storage pool + p.adb:16:09: warning: Storage_Error will be raised at run time + + Of course in practice, there will not be any explicit allocators in the + case of such an access declaration. + +  + File: gnat_rm.info, Node: Size of Variant Record Objects, Next: Biased Representation, Prev: Storage_Size Clauses, Up: Representation Clauses and Pragmas + + Size of Variant Record Objects + ============================== + + An issue arises in the case of variant record objects of whether Size + gives information about a particular variant, or the maximum size + required for any variant. Consider the following program + + with Text_IO; use Text_IO; + procedure q is + type R1 (A : Boolean := False) is record + case A is + when True => X : Character; + when False => null; + end case; + end record; + + V1 : R1 (False); + V2 : R1; + + begin + Put_Line (Integer'Image (V1'Size)); + Put_Line (Integer'Image (V2'Size)); + end q; + + Here we are dealing with a variant record, where the True variant + requires 16 bits, and the False variant requires 8 bits. In the above + example, both V1 and V2 contain the False variant, which is only 8 bits + long. However, the result of running the program is: + + 8 + 16 + + The reason for the difference here is that the discriminant value of V1 + is fixed, and will always be False. It is not possible to assign a + True variant value to V1, therefore 8 bits is sufficient. On the other + hand, in the case of V2, the initial discriminant value is False (from + the default), but it is possible to assign a True variant value to V2, + therefore 16 bits must be allocated for V2 in the general case, even + fewer bits may be needed at any particular point during the program + execution. + + As can be seen from the output of this program, the `'Size' + attribute applied to such an object in GNAT gives the actual allocated + size of the variable, which is the largest size of any of the variants. + The Ada Reference Manual is not completely clear on what choice should + be made here, but the GNAT behavior seems most consistent with the + language in the RM. + + In some cases, it may be desirable to obtain the size of the current + variant, rather than the size of the largest variant. This can be + achieved in GNAT by making use of the fact that in the case of a + subprogram parameter, GNAT does indeed return the size of the current + variant (because a subprogram has no way of knowing how much space is + actually allocated for the actual). + + Consider the following modified version of the above program: + + with Text_IO; use Text_IO; + procedure q is + type R1 (A : Boolean := False) is record + case A is + when True => X : Character; + when False => null; + end case; + end record; + + V2 : R1; + + function Size (V : R1) return Integer is + begin + return V'Size; + end Size; + + begin + Put_Line (Integer'Image (V2'Size)); + Put_Line (Integer'IMage (Size (V2))); + V2 := (True, 'x'); + Put_Line (Integer'Image (V2'Size)); + Put_Line (Integer'IMage (Size (V2))); + end q; + + The output from this program is + + 16 + 8 + 16 + 16 + + Here we see that while the `'Size' attribute always returns the maximum + size, regardless of the current variant value, the `Size' function does + indeed return the size of the current variant value. + +  + File: gnat_rm.info, Node: Biased Representation, Next: Value_Size and Object_Size Clauses, Prev: Size of Variant Record Objects, Up: Representation Clauses and Pragmas + + Biased Representation + ===================== + + In the case of scalars with a range starting at other than zero, it is + possible in some cases to specify a size smaller than the default + minimum value, and in such cases, GNAT uses an unsigned biased + representation, in which zero is used to represent the lower bound, and + successive values represent successive values of the type. + + For example, suppose we have the declaration: + + type Small is range -7 .. -4; + for Small'Size use 2; + + Although the default size of type `Small' is 4, the `Size' clause is + accepted by GNAT and results in the following representation scheme: + + -7 is represented as 2#00# + -6 is represented as 2#01# + -5 is represented as 2#10# + -4 is represented as 2#11# + + Biased representation is only used if the specified `Size' clause + cannot be accepted in any other manner. These reduced sizes that force + biased representation can be used for all discrete types except for + enumeration types for which a representation clause is given. + +  + File: gnat_rm.info, Node: Value_Size and Object_Size Clauses, Next: Component_Size Clauses, Prev: Biased Representation, Up: Representation Clauses and Pragmas + + Value_Size and Object_Size Clauses + ================================== + + In Ada 95, the `Size' of a discrete type is the minimum number of bits + required to hold values of the type. Although this interpretation was + allowed in Ada 83, it was not required, and this requirement in practice + can cause some significant difficulties. For example, in most Ada 83 + compilers, `Natural'Size' was 32. However, in Ada-95, `Natural'Size' is + typically 31. This means that code may change in behavior when moving + from Ada 83 to Ada 95. For example, consider: + + type Rec is record; + A : Natural; + B : Natural; + end record; + + for Rec use record + for A use at 0 range 0 .. Natural'Size - 1; + for B use at 0 range Natural'Size .. 2 * Natural'Size - 1; + end record; + + In the above code, since the typical size of `Natural' objects is 32 + bits and `Natural'Size' is 31, the above code can cause unexpected + inefficient packing in Ada 95, and in general there are surprising + cases where the fact that the object size can exceed the size of the + type causes surprises. + + To help get around this problem GNAT provides two implementation + dependent attributes `Value_Size' and `Object_Size'. When applied to a + type, these attributes yield the size of the type (corresponding to the + RM defined size attribute), and the size of objects of the type + respectively. + + The `Object_Size' is used for determining the default size of + objects and components. This size value can be referred to using the + `Object_Size' attribute. The phrase "is used" here means that it is + the basis of the determination of the size. The backend is free to pad + this up if necessary for efficiency, e.g. an 8-bit stand-alone + character might be stored in 32 bits on a machine with no efficient + byte access instructions such as the Alpha. + + The default rules for the value of `Object_Size' for fixed-point and + discrete types are as follows: + + * The `Object_Size' for base subtypes reflect the natural hardware + size in bits (run the utility `gnatpsta' to find those values for + numeric types). Enumeration types and fixed-point base subtypes + have 8, 16, 32 or 64 bits for this size, depending on the range of + values to be stored. + + * The `Object_Size' of a subtype is the same as the `Object_Size' of + the type from which it is obtained. + + * The `Object_Size' of a derived base type is copied from the parent + base type, and the `Object_Size' of a derived first subtype is + copied from the parent first subtype. + + The `Value_Size' attribute is the number of bits required to store a + value of the type. This size can be referred to using the `Value_Size' + attribute. This value is used to determine how tightly to pack records + or arrays with components of this type, and also affects the semantics + of unchecked conversion (unchecked conversions where the `Value_Size' + values differ generate a warning, and are potentially target dependent). + + The default rules for the value of `Value_Size' are as follows: + + * The `Value_Size' for a base subtype is the minimum number of bits + required to store all values of the type (including the sign bit + only if negative values are possible). + + * If a subtype statically matches the first subtype of a given type, + then it has by default the same `Value_Size' as the first subtype. + This is a consequence of RM 13.1(14) ("if two subtypes statically + match, then their subtype-specific aspects are the same".) + + * All other subtypes have a `Value_Size' corresponding to the minimum + number of bits required to store all values of the subtype. For + dynamic bounds, it is assumed that the value can range down or up + to the corresponding bound of the ancestor + + The RM defined attribute `Size' corresponds to the `Value_Size' + attribute. + + The `Size' attribute may be defined for a first-named subtype. This + sets the `Value_Size' of the first-named subtype to the given value, + and the `Object_Size' of this first-named subtype to the given value + padded up to an appropriate boundary. It is a consequence of the + default rules above that this `Object_Size' will apply to all further + subtypes. On the other hand, `Value_Size' is affected only for the + first subtype, any dynamic subtypes obtained from it directly, and any + statically matching subtypes. The `Value_Size' of any other static + subtypes is not affected. + + `Value_Size' and `Object_Size' may be explicitly set for any subtype + using an attribute definition clause. Note that the use of these + attributes can cause the RM 13.1(14) rule to be violated. If two + access types reference aliased objects whose subtypes have differing + `Object_Size' values as a result of explicit attribute definition + clauses, then it is erroneous to convert from one access subtype to the + other. + + At the implementation level, Esize stores the Object_SIze and the + RM_Size field stores the `Value_Size' (and hence the value of the + `Size' attribute, which, as noted above, is equivalent to `Value_Size'). + + To get a feel for the difference, consider the following examples + (note that in each case the base is short_short_integer with a size of + 8): + + Object_Size Value_Size + + type x1 is range 0 .. 5; 8 3 + + type x2 is range 0 .. 5; + for x2'size use 12; 12 12 + + subtype x3 is x2 range 0 .. 3; 12 2 + + subtype x4 is x2'base range 0 .. 10; 8 4 + + subtype x5 is x2 range 0 .. dynamic; 12 (7) + + subtype x6 is x2'base range 0 .. dynamic; 8 (7) + + Note: the entries marked (7) are not actually specified by the Ada 95 + RM, but it seems in the spirit of the RM rules to allocate the minimum + number of bits known to be large enough to hold the given range of + values. + + So far, so good, but GNAT has to obey the RM rules, so the question + is under what conditions must the RM `Size' be used. The following is + a list of the occasions on which the RM `Size' must be used: + + * Component size for packed arrays or records + + * Value of the attribute `Size' for a type + + * Warning about sizes not matching for unchecked conversion + + For types other than discrete and fixed-point types, the `Object_Size' + and Value_Size are the same (and equivalent to the RM attribute `Size'). + Only `Size' may be specified for such types. + +  + File: gnat_rm.info, Node: Component_Size Clauses, Next: Bit_Order Clauses, Prev: Value_Size and Object_Size Clauses, Up: Representation Clauses and Pragmas + + Component_Size Clauses + ====================== + + Normally, the value specified in a component clause must be consistent + with the subtype of the array component with regard to size and + alignment. In other words, the value specified must be at least equal + to the size of this subtype, and must be a multiple of the alignment + value. + + In addition, component size clauses are allowed which cause the array + to be packed, by specifying a smaller value. The cases in which this + is allowed are for component size values in the range 1 through 63. + The value specified must not be smaller than the Size of the subtype. + GNAT will accurately honor all packing requests in this range. For + example, if we have: + + type r is array (1 .. 8) of Natural; + for r'Size use 31; + + then the resulting array has a length of 31 bytes (248 bits = 8 * 31). + Of course access to the components of such an array is considerably + less efficient than if the natural component size of 32 is used. + +  + File: gnat_rm.info, Node: Bit_Order Clauses, Next: Effect of Bit_Order on Byte Ordering, Prev: Component_Size Clauses, Up: Representation Clauses and Pragmas + + Bit_Order Clauses + ================= + + For record subtypes, GNAT permits the specification of the `Bit_Order' + attribute. The specification may either correspond to the default bit + order for the target, in which case the specification has no effect and + places no additional restrictions, or it may be for the non-standard + setting (that is the opposite of the default). + + In the case where the non-standard value is specified, the effect is + to renumber bits within each byte, but the ordering of bytes is not + affected. There are certain restrictions placed on component clauses + as follows: + + * Components fitting within a single storage unit. + + These are unrestricted, and the effect is merely to renumber bits. + For example if we are on a little-endian machine with + `Low_Order_First' being the default, then the following two + declarations have exactly the same effect: + + type R1 is record + A : Boolean; + B : Integer range 1 .. 120; + end record; + + for R1 use record + A at 0 range 0 .. 0; + B at 0 range 1 .. 7; + end record; + + type R2 is record + A : Boolean; + B : Integer range 1 .. 120; + end record; + + for R2'Bit_Order use High_Order_First; + + for R2 use record + A at 0 range 7 .. 7; + B at 0 range 0 .. 6; + end record; + + The useful application here is to write the second declaration + with the `Bit_Order' attribute definition clause, and know that it + will be treated the same, regardless of whether the target is + little-endian or big-endian. + + * Components occupying an integral number of bytes. + + These are components that exactly fit in two or more bytes. Such + component declarations are allowed, but have no effect, since it + is important to realize that the `Bit_Order' specification does + not affect the ordering of bytes. In particular, the following + attempt at getting an endian-independent integer does not work: + + type R2 is record + A : Integer; + end record; + + for R2'Bit_Order use High_Order_First; + + for R2 use record + A at 0 range 0 .. 31; + end record; + + This declaration will result in a little-endian integer on a + little-endian machine, and a big-endian integer on a big-endian + machine. If byte flipping is required for interoperability + between big- and little-endian machines, this must be explicitly + programmed. This capability is not provided by `Bit_Order'. + + * Components that are positioned across byte boundaries + + but do not occupy an integral number of bytes. Given that bytes + are not reordered, such fields would occupy a non-contiguous + sequence of bits in memory, requiring non-trivial code to + reassemble. They are for this reason not permitted, and any + component clause specifying such a layout will be flagged as + illegal by GNAT. + + + Since the misconception that Bit_Order automatically deals with all + endian-related incompatibilities is a common one, the specification of + a component field that is an integral number of bytes will always + generate a warning. This warning may be suppressed using `pragma + Suppress' if desired. The following section contains additional + details regarding the issue of byte ordering. + +  + File: gnat_rm.info, Node: Effect of Bit_Order on Byte Ordering, Next: Pragma Pack for Arrays, Prev: Bit_Order Clauses, Up: Representation Clauses and Pragmas + + Effect of Bit_Order on Byte Ordering + ==================================== + + In this section we will review the effect of the `Bit_Order' attribute + definition clause on byte ordering. Briefly, it has no effect at all, + but a detailed example will be helpful. Before giving this example, + let us review the precise definition of the effect of defining + `Bit_Order'. The effect of a non-standard bit order is described in + section 15.5.3 of the Ada Reference Manual: + + 2 A bit ordering is a method of interpreting the meaning of + the storage place attributes. + + To understand the precise definition of storage place attributes in + this context, we visit section 13.5.1 of the manual: + + 13 A record_representation_clause (without the mod_clause) + specifies the layout. The storage place attributes (see 13.5.2) + are taken from the values of the position, first_bit, and last_bit + expressions after normalizing those values so that first_bit is + less than Storage_Unit. + + The critical point here is that storage places are taken from the + values after normalization, not before. So the `Bit_Order' + interpretation applies to normalized values. The interpretation is + described in the later part of the 15.5.3 paragraph: + + 2 A bit ordering is a method of interpreting the meaning of + the storage place attributes. High_Order_First (known in the + vernacular as ``big endian'') means that the first bit of a + storage element (bit 0) is the most significant bit (interpreting + the sequence of bits that represent a component as an unsigned + integer value). Low_Order_First (known in the vernacular as + ``little endian'') means the opposite: the first bit is the + least significant. + + Note that the numbering is with respect to the bits of a storage unit. + In other words, the specification affects only the numbering of bits + within a single storage unit. + + We can make the effect clearer by giving an example. + + Suppose that we have an external device which presents two bytes, + the first byte presented, which is the first (low addressed byte) of + the two byte record is called Master, and the second byte is called + Slave. + + The left most (most significant bit is called Control for each byte, + and the remaining 7 bits are called V1, V2, ... V7, where V7 is the + rightmost (least significant) bit. + + On a big-endian machine, we can write the following representation + clause + + type Data is record + Master_Control : Bit; + Master_V1 : Bit; + Master_V2 : Bit; + Master_V3 : Bit; + Master_V4 : Bit; + Master_V5 : Bit; + Master_V6 : Bit; + Master_V7 : Bit; + Slave_Control : Bit; + Slave_V1 : Bit; + Slave_V2 : Bit; + Slave_V3 : Bit; + Slave_V4 : Bit; + Slave_V5 : Bit; + Slave_V6 : Bit; + Slave_V7 : Bit; + end record; + + for Data use record + Master_Control at 0 range 0 .. 0; + Master_V1 at 0 range 1 .. 1; + Master_V2 at 0 range 2 .. 2; + Master_V3 at 0 range 3 .. 3; + Master_V4 at 0 range 4 .. 4; + Master_V5 at 0 range 5 .. 5; + Master_V6 at 0 range 6 .. 6; + Master_V7 at 0 range 7 .. 7; + Slave_Control at 1 range 0 .. 0; + Slave_V1 at 1 range 1 .. 1; + Slave_V2 at 1 range 2 .. 2; + Slave_V3 at 1 range 3 .. 3; + Slave_V4 at 1 range 4 .. 4; + Slave_V5 at 1 range 5 .. 5; + Slave_V6 at 1 range 6 .. 6; + Slave_V7 at 1 range 7 .. 7; + end record; + + Now if we move this to a little endian machine, then the bit ordering + within the byte is backwards, so we have to rewrite the record rep + clause as: + + for Data use record + Master_Control at 0 range 7 .. 7; + Master_V1 at 0 range 6 .. 6; + Master_V2 at 0 range 5 .. 5; + Master_V3 at 0 range 4 .. 4; + Master_V4 at 0 range 3 .. 3; + Master_V5 at 0 range 2 .. 2; + Master_V6 at 0 range 1 .. 1; + Master_V7 at 0 range 0 .. 0; + Slave_Control at 1 range 7 .. 7; + Slave_V1 at 1 range 6 .. 6; + Slave_V2 at 1 range 5 .. 5; + Slave_V3 at 1 range 4 .. 4; + Slave_V4 at 1 range 3 .. 3; + Slave_V5 at 1 range 2 .. 2; + Slave_V6 at 1 range 1 .. 1; + Slave_V7 at 1 range 0 .. 0; + end record; + + It is a nuisance to have to rewrite the clause, especially if the + code has to be maintained on both machines. However, this is a case + that we can handle with the `Bit_Order' attribute if it is implemented. + Note that the implementation is not required on byte addressed + machines, but it is indeed implemented in GNAT. This means that we can + simply use the first record clause, together with the declaration + + for Data'Bit_Order use High_Order_First; + + and the effect is what is desired, namely the layout is exactly the + same, independent of whether the code is compiled on a big-endian or + little-endian machine. + + The important point to understand is that byte ordering is not + affected. A `Bit_Order' attribute definition never affects which byte + a field ends up in, only where it ends up in that byte. To make this + clear, let us rewrite the record rep clause of the previous example as: + + for Data'Bit_Order use High_Order_First; + for Data use record + Master_Control at 0 range 0 .. 0; + Master_V1 at 0 range 1 .. 1; + Master_V2 at 0 range 2 .. 2; + Master_V3 at 0 range 3 .. 3; + Master_V4 at 0 range 4 .. 4; + Master_V5 at 0 range 5 .. 5; + Master_V6 at 0 range 6 .. 6; + Master_V7 at 0 range 7 .. 7; + Slave_Control at 0 range 8 .. 8; + Slave_V1 at 0 range 9 .. 9; + Slave_V2 at 0 range 10 .. 10; + Slave_V3 at 0 range 11 .. 11; + Slave_V4 at 0 range 12 .. 12; + Slave_V5 at 0 range 13 .. 13; + Slave_V6 at 0 range 14 .. 14; + Slave_V7 at 0 range 15 .. 15; + end record; + + This is exactly equivalent to saying (a repeat of the first example): + + for Data'Bit_Order use High_Order_First; + for Data use record + Master_Control at 0 range 0 .. 0; + Master_V1 at 0 range 1 .. 1; + Master_V2 at 0 range 2 .. 2; + Master_V3 at 0 range 3 .. 3; + Master_V4 at 0 range 4 .. 4; + Master_V5 at 0 range 5 .. 5; + Master_V6 at 0 range 6 .. 6; + Master_V7 at 0 range 7 .. 7; + Slave_Control at 1 range 0 .. 0; + Slave_V1 at 1 range 1 .. 1; + Slave_V2 at 1 range 2 .. 2; + Slave_V3 at 1 range 3 .. 3; + Slave_V4 at 1 range 4 .. 4; + Slave_V5 at 1 range 5 .. 5; + Slave_V6 at 1 range 6 .. 6; + Slave_V7 at 1 range 7 .. 7; + end record; + + Why are they equivalent? Well take a specific field, the `Slave_V2' + field. The storage place attributes are obtained by normalizing the + values given so that the `First_Bit' value is less than 8. After + nromalizing the values (0,10,10) we get (1,2,2) which is exactly what + we specified in the other case. + + Now one might expect that the `Bit_Order' attribute might affect bit + numbering within the entire record component (two bytes in this case, + thus affecting which byte fields end up in), but that is not the way + this feature is defined, it only affects numbering of bits, not which + byte they end up in. + + Consequently it never makes sense to specify a starting bit number + greater than 7 (for a byte addressable field) if an attribute + definition for `Bit_Order' has been given, and indeed it may be + actively confusing to specify such a value, so the compiler generates a + warning for such usage. + + If you do need to control byte ordering then appropriate conditional + values must be used. If in our example, the slave byte came first on + some machines we might write: + + Master_Byte_First constant Boolean := ...; + + Master_Byte : constant Natural := + 1 - Boolean'Pos (Master_Byte_First); + Slave_Byte : constant Natural := + Boolean'Pos (Master_Byte_First); + + for Data'Bit_Order use High_Order_First; + for Data use record + Master_Control at Master_Byte range 0 .. 0; + Master_V1 at Master_Byte range 1 .. 1; + Master_V2 at Master_Byte range 2 .. 2; + Master_V3 at Master_Byte range 3 .. 3; + Master_V4 at Master_Byte range 4 .. 4; + Master_V5 at Master_Byte range 5 .. 5; + Master_V6 at Master_Byte range 6 .. 6; + Master_V7 at Master_Byte range 7 .. 7; + Slave_Control at Slave_Byte range 0 .. 0; + Slave_V1 at Slave_Byte range 1 .. 1; + Slave_V2 at Slave_Byte range 2 .. 2; + Slave_V3 at Slave_Byte range 3 .. 3; + Slave_V4 at Slave_Byte range 4 .. 4; + Slave_V5 at Slave_Byte range 5 .. 5; + Slave_V6 at Slave_Byte range 6 .. 6; + Slave_V7 at Slave_Byte range 7 .. 7; + end record; + + Now to switch between machines, all that is necessary is to set the + boolean constant `Master_Byte_First' in an appropriate manner. + +  + File: gnat_rm.info, Node: Pragma Pack for Arrays, Next: Pragma Pack for Records, Prev: Effect of Bit_Order on Byte Ordering, Up: Representation Clauses and Pragmas + + Pragma Pack for Arrays + ====================== + + Pragma `Pack' applied to an array has no effect unless the component + type is packable. For a component type to be packable, it must be one + of the following cases: + + * Any scalar type + + * Any fixed-point type + + * Any type whose size is specified with a size clause + + * Any packed array type with a static size + + For all these cases, if the component subtype size is in the range 1 + through 63, then the effect of the pragma `Pack' is exactly as though a + component size were specified giving the component subtype size. For + example if we have: + + type r is range 0 .. 17; + + type ar is array (1 .. 8) of r; + pragma Pack (ar); + + Then the component size of `ar' will be set to 5 (i.e. to `r'size', and + the size of the array `ar' will be exactly 40 bits. + + Note that in some cases this rather fierce approach to packing can + produce unexpected effects. For example, in Ada 95, type Natural + typically has a size of 31, meaning that if you pack an array of + Natural, you get 31-bit close packing, which saves a few bits, but + results in far less efficient access. Since many other Ada compilers + will ignore such a packing request, GNAT will generate a warning on + some uses of pragma `Pack' that it guesses might not be what is + intended. You can easily remove this warning by using an explicit + `Component_Size' setting instead, which never generates a warning, + since the intention of the programmer is clear in this case. + + GNAT treats packed arrays in one of two ways. If the size of the + array is known at compile time and is less than 64 bits, then + internally the array is represented as a single modular type, of + exactly the appropriate number of bits. If the length is greater than + 63 bits, or is not known at compile time, then the packed array is + represented as an array of bytes, and the length is always a multiple + of 8 bits. + +  + File: gnat_rm.info, Node: Pragma Pack for Records, Next: Record Representation Clauses, Prev: Pragma Pack for Arrays, Up: Representation Clauses and Pragmas + + Pragma Pack for Records + ======================= + + Pragma `Pack' applied to a record will pack the components to reduce + wasted space from alignment gaps and by reducing the amount of space + taken by components. We distinguish between package components and + non-packable components. Components of the following types are + considered packable: + + * All scalar types are packable. + + * All fixed-point types are represented internally as integers, and + are packable. + + * Small packed arrays, whose size does not exceed 64 bits, and where + the size is statically known at compile time, are represented + internally as modular integers, and so they are also packable. + + + All packable components occupy the exact number of bits corresponding to + their `Size' value, and are packed with no padding bits, i.e. they can + start on an arbitrary bit boundary. + + All other types are non-packable, they occupy an integral number of + storage units, and are placed at a boundary corresponding to their + alignment requirements. + + For example, consider the record + + type Rb1 is array (1 .. 13) of Boolean; + pragma Pack (rb1); + + type Rb2 is array (1 .. 65) of Boolean; + pragma Pack (rb2); + + type x2 is record + l1 : Boolean; + l2 : Duration; + l3 : Float; + l4 : Boolean; + l5 : Rb1; + l6 : Rb2; + end record; + pragma Pack (x2); + + The representation for the record x2 is as follows: + + for x2'Size use 224; + for x2 use record + l1 at 0 range 0 .. 0; + l2 at 0 range 1 .. 64; + l3 at 12 range 0 .. 31; + l4 at 16 range 0 .. 0; + l5 at 16 range 1 .. 13; + l6 at 18 range 0 .. 71; + end record; + + Studying this example, we see that the packable fields `l1' and `l2' are + of length equal to their sizes, and placed at specific bit boundaries + (and not byte boundaries) to eliminate padding. But `l3' is of a + non-packable float type, so it is on the next appropriate alignment + boundary. + + The next two fields are fully packable, so `l4' and `l5' are + minimally packed with no gaps. However, type `Rb2' is a packed array + that is longer than 64 bits, so it is itself non-packable. Thus the + `l6' field is aligned to the next byte boundary, and takes an integral + number of bytes, i.e. 72 bits. + +  + File: gnat_rm.info, Node: Record Representation Clauses, Next: Enumeration Clauses, Prev: Pragma Pack for Records, Up: Representation Clauses and Pragmas + + Record Representation Clauses + ============================= + + Record representation clauses may be given for all record types, + including types obtained by record extension. Component clauses are + allowed for any static component. The restrictions on component + clauses depend on the type of the component. + + For all components of an elementary type, the only restriction on + component clauses is that the size must be at least the 'Size value of + the type (actually the Value_Size). There are no restrictions due to + alignment, and such components may freely cross storage boundaries. + + Packed arrays with a size up to and including 64 bits are represented + internally using a modular type with the appropriate number of bits, and + thus the same lack of restriction applies. For example, if you declare: + + type R is array (1 .. 49) of Boolean; + pragma Pack (R); + for R'Size use 49; + + then a component clause for a component of type R may start on any + specified bit boundary, and may specify a value of 49 bits or greater. + + For non-primitive types, including packed arrays with a size greater + than 64 bits, component clauses must respect the alignment requirement + of the type, in particular, always starting on a byte boundary, and the + length must be a multiple of the storage unit. + + The tag field of a tagged type always occupies an address sized + field at the start of the record. No component clause may attempt to + overlay this tag. + + In the case of a record extension T1, of a type T, no component + clause applied to the type T1 can specify a storage location that would + overlap the first T'Size bytes of the record. + +  + File: gnat_rm.info, Node: Enumeration Clauses, Next: Address Clauses, Prev: Record Representation Clauses, Up: Representation Clauses and Pragmas + + Enumeration Clauses + =================== + + The only restriction on enumeration clauses is that the range of + values must be representable. For the signed case, if one or more of + the representation values are negative, all values must be in the range: + + System.Min_Int .. System.Max_Int + + For the unsigned case, where all values are non negative, the values + must be in the range: + + 0 .. System.Max_Binary_Modulus; + + A _confirming_ representation clause is one in which the values range + from 0 in sequence, i.e. a clause that confirms the default + representation for an enumeration type. Such a confirming + representation is permitted by these rules, and is specially recognized + by the compiler so that no extra overhead results from the use of such + a clause. + + If an array has an index type which is an enumeration type to which + an enumeration clause has been applied, then the array is stored in a + compact manner. Consider the declarations: + + type r is (A, B, C); + for r use (A => 1, B => 5, C => 10); + type t is array (r) of Character; + + The array type t corresponds to a vector with exactly three elements and + has a default size equal to `3*Character'Size'. This ensures efficient + use of space, but means that accesses to elements of the array will + incur the overhead of converting representation values to the + corresponding positional values, (i.e. the value delivered by the `Pos' + attribute). + +  + File: gnat_rm.info, Node: Address Clauses, Next: Effect of Convention on Representation, Prev: Enumeration Clauses, Up: Representation Clauses and Pragmas + + Address Clauses + =============== + + The reference manual allows a general restriction on representation + clauses, as found in RM 13.1(22): + + An implementation need not support representation + items containing nonstatic expressions, except that + an implementation should support a representation item + for a given entity if each nonstatic expression in the + representation item is a name that statically denotes + a constant declared before the entity. + + In practice this is applicable only to address clauses, since this is + the only case in which a non-static expression is permitted by the + syntax. As the AARM notes in sections 13.1 (22.a-22.h): + + 22.a Reason: This is to avoid the following sort + of thing: + + 22.b X : Integer := F(...); + Y : Address := G(...); + for X'Address use Y; + + 22.c In the above, we have to evaluate the + initialization expression for X before we + know where to put the result. This seems + like an unreasonable implementation burden. + + 22.d The above code should instead be written + like this: + + 22.e Y : constant Address := G(...); + X : Integer := F(...); + for X'Address use Y; + + 22.f This allows the expression ``Y'' to be safely + evaluated before X is created. + + 22.g The constant could be a formal parameter of mode in. + + 22.h An implementation can support other nonstatic + expressions if it wants to. Expressions of type + Address are hardly ever static, but their value + might be known at compile time anyway in many + cases. + + GNAT does indeed permit many additional cases of non-static + expressions. In particular, if the type involved is elementary there + are no restrictions (since in this case, holding a temporary copy of + the initialization value, if one is present, is inexpensive). In + addition, if there is no implicit or explicit initialization, then + there are no restrictions. GNAT will reject only the case where all + three of these conditions hold: + + * The type of the item is non-elementary (e.g. a record or array). + + * There is explicit or implicit initialization required for the + object. + + * The address value is non-static. Here GNAT is more permissive + than the RM, and allows the address value to be the address of a + previously declared stand-alone variable, as long as it does not + itself have an address clause. + + Anchor : Some_Initialized_Type; + Overlay : Some_Initialized_Type; + for Overlay'Address use Anchor'Address; + + However, the prefix of the address clause cannot be an array + component, or a component of a discriminated record. + + + As noted above in section 22.h, address values are typically + non-static. In particular the To_Address function, even if applied to + a literal value, is a non-static function call. To avoid this minor + annoyance, GNAT provides the implementation defined attribute + 'To_Address. The following two expressions have identical values: + + Another issue with address clauses is the interaction with alignment + requirements. When an address clause is given for an object, the + address value must be consistent with the alignment of the object + (which is usually the same as the alignment of the type of the object). + If an address clause is given that specifies an inappropriately + aligned address value, then the program execution is erroneous. + + Since this source of erroneous behavior can have unfortunate + effects, GNAT checks (at compile time if possible, generating a + warning, or at execution time with a run-time check) that the alignment + is appropriate. If the run-time check fails, then `Program_Error' is + raised. This run-time check is suppressed if range checks are + suppressed, or if `pragma Restrictions (No_Elaboration_Code)' is in + effect. + + To_Address (16#1234_0000#) + System'To_Address (16#1234_0000#); + + except that the second form is considered to be a static expression, and + thus when used as an address clause value is always permitted. + + Additionally, GNAT treats as static an address clause that is an + unchecked_conversion of a static integer value. This simplifies the + porting of legacy code, and provides a portable equivalent to the GNAT + attribute To_Address. + + An address clause cannot be given for an exported object. More + understandably the real restriction is that objects with an address + clause cannot be exported. This is because such variables are not + defined by the Ada program, so there is no external object so export. + + It is permissible to give an address clause and a pragma Import for + the same object. In this case, the variable is not really defined by + the Ada program, so there is no external symbol to be linked. The link + name and the external name are ignored in this case. The reason that + we allow this combination is that it provides a useful idiom to avoid + unwanted initializations on objects with address clauses. + + When an address clause is given for an object that has implicit or + explicit initialization, then by default initialization takes place. + This means that the effect of the object declaration is to overwrite the + memory at the specified address. This is almost always not what the + programmer wants, so GNAT will output a warning: + + with System; + package G is + type R is record + M : Integer := 0; + end record; + + Ext : R; + for Ext'Address use System'To_Address (16#1234_1234#); + | + >>> warning: implicit initialization of "Ext" may + modify overlaid storage + >>> warning: use pragma Import for "Ext" to suppress + initialization (RM B(24)) + + end G; + + As indicated by the warning message, the solution is to use a (dummy) + pragma Import to suppress this initialization. The pragma tell the + compiler that the object is declared and initialized elsewhere. The + following package compiles without warnings (and the initialization is + suppressed): + + with System; + package G is + type R is record + M : Integer := 0; + end record; + + Ext : R; + for Ext'Address use System'To_Address (16#1234_1234#); + pragma Import (Ada, Ext); + end G; + +  + File: gnat_rm.info, Node: Effect of Convention on Representation, Next: Determining the Representations chosen by GNAT, Prev: Address Clauses, Up: Representation Clauses and Pragmas + + Effect of Convention on Representation + ====================================== + + Normally the specification of a foreign language convention for a type + or an object has no effect on the chosen representation. In + particular, the representation chosen for data in GNAT generally meets + the standard system conventions, and for example records are laid out + in a manner that is consistent with C. This means that specifying + convention C (for example) has no effect. + + There are three exceptions to this general rule: + + * Convention Fortran and array subtypes If pragma Convention Fortran + is specified for an array subtype, then in accordance with the + implementation advice in section 3.6.2(11) of the Ada Reference + Manual, the array will be stored in a Fortran-compatible + column-major manner, instead of the normal default row-major order. + + * Convention C and enumeration types GNAT normally stores + enumeration types in 8, 16, or 32 bits as required to accommodate + all values of the type. For example, for the enumeration type + declared by: + + type Color is (Red, Green, Blue); + + 8 bits is sufficient to store all values of the type, so by + default, objects of type `Color' will be represented using 8 bits. + However, normal C convention is to use 32 bits for all enum + values in C, since enum values are essentially of type int. If + pragma `Convention C' is specified for an Ada enumeration type, + then the size is modified as necessary (usually to 32 bits) to be + consistent with the C convention for enum values. + + * Convention C/Fortran and Boolean types In C, the usual convention + for boolean values, that is values used for conditions, is that + zero represents false, and nonzero values represent true. In Ada, + the normal convention is that two specific values, typically 0/1, + are used to represent false/true respectively. + + Fortran has a similar convention for `LOGICAL' values (any nonzero + value represents true). + + To accommodate the Fortran and C conventions, if a pragma + Convention specifies C or Fortran convention for a derived + Boolean, as in the following example: + + type C_Switch is new Boolean; + pragma Convention (C, C_Switch); + + then the GNAT generated code will treat any nonzero value as true. + For truth values generated by GNAT, the conventional value 1 will + be used for True, but when one of these values is read, any + nonzero value is treated as True. + + +  + File: gnat_rm.info, Node: Determining the Representations chosen by GNAT, Prev: Effect of Convention on Representation, Up: Representation Clauses and Pragmas + + Determining the Representations chosen by GNAT + ============================================== + + Although the descriptions in this section are intended to be complete, + it is often easier to simply experiment to see what GNAT accepts and + what the effect is on the layout of types and objects. + + As required by the Ada RM, if a representation clause is not + accepted, then it must be rejected as illegal by the compiler. + However, when a representation clause or pragma is accepted, there can + still be questions of what the compiler actually does. For example, if + a partial record representation clause specifies the location of some + components and not others, then where are the non-specified components + placed? Or if pragma `Pack' is used on a record, then exactly where are + the resulting fields placed? The section on pragma `Pack' in this + chapter can be used to answer the second question, but it is often + easier to just see what the compiler does. + + For this purpose, GNAT provides the option `-gnatR'. If you compile + with this option, then the compiler will output information on the + actual representations chosen, in a format similar to source + representation clauses. For example, if we compile the package: + + package q is + type r (x : boolean) is tagged record + case x is + when True => S : String (1 .. 100); + when False => null; + end case; + end record; + + type r2 is new r (false) with record + y2 : integer; + end record; + + for r2 use record + y2 at 16 range 0 .. 31; + end record; + + type x is record + y : character; + end record; + + type x1 is array (1 .. 10) of x; + for x1'component_size use 11; + + type ia is access integer; + + type Rb1 is array (1 .. 13) of Boolean; + pragma Pack (rb1); + + type Rb2 is array (1 .. 65) of Boolean; + pragma Pack (rb2); + + type x2 is record + l1 : Boolean; + l2 : Duration; + l3 : Float; + l4 : Boolean; + l5 : Rb1; + l6 : Rb2; + end record; + pragma Pack (x2); + end q; + + using the switch `-gnatR' we obtain the following output: + + Representation information for unit q + ------------------------------------- + + for r'Size use ??; + for r'Alignment use 4; + for r use record + x at 4 range 0 .. 7; + _tag at 0 range 0 .. 31; + s at 5 range 0 .. 799; + end record; + + for r2'Size use 160; + for r2'Alignment use 4; + for r2 use record + x at 4 range 0 .. 7; + _tag at 0 range 0 .. 31; + _parent at 0 range 0 .. 63; + y2 at 16 range 0 .. 31; + end record; + + for x'Size use 8; + for x'Alignment use 1; + for x use record + y at 0 range 0 .. 7; + end record; + + for x1'Size use 112; + for x1'Alignment use 1; + for x1'Component_Size use 11; + + for rb1'Size use 13; + for rb1'Alignment use 2; + for rb1'Component_Size use 1; + + for rb2'Size use 72; + for rb2'Alignment use 1; + for rb2'Component_Size use 1; + + for x2'Size use 224; + for x2'Alignment use 4; + for x2 use record + l1 at 0 range 0 .. 0; + l2 at 0 range 1 .. 64; + l3 at 12 range 0 .. 31; + l4 at 16 range 0 .. 0; + l5 at 16 range 1 .. 13; + l6 at 18 range 0 .. 71; + end record; + + The Size values are actually the Object_Size, i.e. the default size that + will be allocated for objects of the type. The ?? size for type r + indicates that we have a variant record, and the actual size of objects + will depend on the discriminant value. + + The Alignment values show the actual alignment chosen by the compiler + for each record or array type. + + The record representation clause for type r shows where all fields + are placed, including the compiler generated tag field (whose location + cannot be controlled by the programmer). + + The record representation clause for the type extension r2 shows all + the fields present, including the parent field, which is a copy of the + fields of the parent type of r2, i.e. r1. + + The component size and size clauses for types rb1 and rb2 show the + exact effect of pragma `Pack' on these arrays, and the record + representation clause for type x2 shows how pragma `Pack' affects this + record type. + + In some cases, it may be useful to cut and paste the representation + clauses generated by the compiler into the original source to fix and + guarantee the actual representation to be used. + +  + File: gnat_rm.info, Node: Standard Library Routines, Next: The Implementation of Standard I/O, Prev: Representation Clauses and Pragmas, Up: Top + + Standard Library Routines + ************************* + + The Ada 95 Reference Manual contains in Annex A a full description of an + extensive set of standard library routines that can be used in any Ada + program, and which must be provided by all Ada compilers. They are + analogous to the standard C library used by C programs. + + GNAT implements all of the facilities described in annex A, and for + most purposes the description in the Ada 95 reference manual, or + appropriate Ada text book, will be sufficient for making use of these + facilities. + + In the case of the input-output facilities, *Note The Implementation + of Standard I/O::, gives details on exactly how GNAT interfaces to the + file system. For the remaining packages, the Ada 95 reference manual + should be sufficient. The following is a list of the packages included, + together with a brief description of the functionality that is provided. + + For completeness, references are included to other predefined library + routines defined in other sections of the Ada 95 reference manual + (these are cross-indexed from annex A). + + `Ada (A.2)' + This is a parent package for all the standard library packages. + It is usually included implicitly in your program, and itself + contains no useful data or routines. + + `Ada.Calendar (9.6)' + `Calendar' provides time of day access, and routines for + manipulating times and durations. + + `Ada.Characters (A.3.1)' + This is a dummy parent package that contains no useful entities + + `Ada.Characters.Handling (A.3.2)' + This package provides some basic character handling capabilities, + including classification functions for classes of characters (e.g. + test for letters, or digits). + + `Ada.Characters.Latin_1 (A.3.3)' + This package includes a complete set of definitions of the + characters that appear in type CHARACTER. It is useful for + writing programs that will run in international environments. For + example, if you want an upper case E with an acute accent in a + string, it is often better to use the definition of `UC_E_Acute' + in this package. Then your program will print in an + understandable manner even if your environment does not support + these extended characters. + + `Ada.Command_Line (A.15)' + This package provides access to the command line parameters and + the name of the current program (analogous to the use of `argc' + and `argv' in C), and also allows the exit status for the program + to be set in a system-independent manner. + + `Ada.Decimal (F.2)' + This package provides constants describing the range of decimal + numbers implemented, and also a decimal divide routine (analogous + to the COBOL verb DIVIDE .. GIVING .. REMAINDER ..) + + `Ada.Direct_IO (A.8.4)' + This package provides input-output using a model of a set of + records of fixed-length, containing an arbitrary definite Ada + type, indexed by an integer record number. + + `Ada.Dynamic_Priorities (D.5)' + This package allows the priorities of a task to be adjusted + dynamically as the task is running. + + `Ada.Exceptions (11.4.1)' + This package provides additional information on exceptions, and + also contains facilities for treating exceptions as data objects, + and raising exceptions with associated messages. + + `Ada.Finalization (7.6)' + This package contains the declarations and subprograms to support + the use of controlled types, providing for automatic + initialization and finalization (analogous to the constructors and + destructors of C++) + + `Ada.Interrupts (C.3.2)' + This package provides facilities for interfacing to interrupts, + which includes the set of signals or conditions that can be raised + and recognized as interrupts. + + `Ada.Interrupts.Names (C.3.2)' + This package provides the set of interrupt names (actually signal + or condition names) that can be handled by GNAT. + + `Ada.IO_Exceptions (A.13)' + This package defines the set of exceptions that can be raised by + use of the standard IO packages. + + `Ada.Numerics' + This package contains some standard constants and exceptions used + throughout the numerics packages. Note that the constants pi and + e are defined here, and it is better to use these definitions than + rolling your own. + + `Ada.Numerics.Complex_Elementary_Functions' + Provides the implementation of standard elementary functions (such + as log and trigonometric functions) operating on complex numbers + using the standard `Float' and the `Complex' and `Imaginary' types + created by the package `Numerics.Complex_Types'. + + `Ada.Numerics.Complex_Types' + This is a predefined instantiation of + `Numerics.Generic_Complex_Types' using `Standard.Float' to build + the type `Complex' and `Imaginary'. + + `Ada.Numerics.Discrete_Random' + This package provides a random number generator suitable for + generating random integer values from a specified range. + + `Ada.Numerics.Float_Random' + This package provides a random number generator suitable for + generating uniformly distributed floating point values. + + `Ada.Numerics.Generic_Complex_Elementary_Functions' + This is a generic version of the package that provides the + implementation of standard elementary functions (such as log and + trigonometric functions) for an arbitrary complex type. + + The following predefined instantiations of this package are + provided: + + `Short_Float' + `Ada.Numerics.Short_Complex_Elementary_Functions' + + `Float' + `Ada.Numerics.Complex_Elementary_Functions' + + `Long_Float' + `Ada.Numerics. Long_Complex_Elementary_Functions' + + `Ada.Numerics.Generic_Complex_Types' + This is a generic package that allows the creation of complex + types, with associated complex arithmetic operations. + + The following predefined instantiations of this package exist + `Short_Float' + `Ada.Numerics.Short_Complex_Complex_Types' + + `Float' + `Ada.Numerics.Complex_Complex_Types' + + `Long_Float' + `Ada.Numerics.Long_Complex_Complex_Types' + + `Ada.Numerics.Generic_Elementary_Functions' + This is a generic package that provides the implementation of + standard elementary functions (such as log an trigonometric + functions) for an arbitrary float type. + + The following predefined instantiations of this package exist + + `Short_Float' + `Ada.Numerics.Short_Elementary_Functions' + + `Float' + `Ada.Numerics.Elementary_Functions' + + `Long_Float' + `Ada.Numerics.Long_Elementary_Functions' + + `Ada.Real_Time (D.8)' + This package provides facilities similar to those of `Calendar', + but operating with a finer clock suitable for real time control. + Note that annex D requires that there be no backward clock jumps, + and GNAT generally guarantees this behavior, but of course if the + external clock on which the GNAT runtime depends is deliberately + reset by some external event, then such a backward jump may occur. + + `Ada.Sequential_IO (A.8.1)' + This package provides input-output facilities for sequential files, + which can contain a sequence of values of a single type, which can + be any Ada type, including indefinite (unconstrained) types. + + `Ada.Storage_IO (A.9)' + This package provides a facility for mapping arbitrary Ada types + to and from a storage buffer. It is primarily intended for the + creation of new IO packages. + + `Ada.Streams (13.13.1)' + This is a generic package that provides the basic support for the + concept of streams as used by the stream attributes (`Input', + `Output', `Read' and `Write'). + + `Ada.Streams.Stream_IO (A.12.1)' + This package is a specialization of the type `Streams' defined in + package `Streams' together with a set of operations providing + Stream_IO capability. The Stream_IO model permits both random and + sequential access to a file which can contain an arbitrary set of + values of one or more Ada types. + + `Ada.Strings (A.4.1)' + This package provides some basic constants used by the string + handling packages. + + `Ada.Strings.Bounded (A.4.4)' + This package provides facilities for handling variable length + strings. The bounded model requires a maximum length. It is thus + somewhat more limited than the unbounded model, but avoids the use + of dynamic allocation or finalization. + + `Ada.Strings.Fixed (A.4.3)' + This package provides facilities for handling fixed length strings. + + `Ada.Strings.Maps (A.4.2)' + This package provides facilities for handling character mappings + and arbitrarily defined subsets of characters. For instance it is + useful in defining specialized translation tables. + + `Ada.Strings.Maps.Constants (A.4.6)' + This package provides a standard set of predefined mappings and + predefined character sets. For example, the standard upper to + lower case conversion table is found in this package. Note that + upper to lower case conversion is non-trivial if you want to take + the entire set of characters, including extended characters like E + with an acute accent, into account. You should use the mappings + in this package (rather than adding 32 yourself) to do case + mappings. + + `Ada.Strings.Unbounded (A.4.5)' + This package provides facilities for handling variable length + strings. The unbounded model allows arbitrary length strings, but + requires the use of dynamic allocation and finalization. + + `Ada.Strings.Wide_Bounded (A.4.7)' + `Ada.Strings.Wide_Fixed (A.4.7)' + `Ada.Strings.Wide_Maps (A.4.7)' + `Ada.Strings.Wide_Maps.Constants (A.4.7)' + `Ada.Strings.Wide_Unbounded (A.4.7)' + These package provide analogous capabilities to the corresponding + packages without `Wide_' in the name, but operate with the types + `Wide_String' and `Wide_Character' instead of `String' and + `Character'. + + `Ada.Synchronous_Task_Control (D.10)' + This package provides some standard facilities for controlling task + communication in a synchronous manner. + + `Ada.Tags' + This package contains definitions for manipulation of the tags of + tagged values. + + `Ada.Task_Attributes' + This package provides the capability of associating arbitrary + task-specific data with separate tasks. + + `Ada.Text_IO' + This package provides basic text input-output capabilities for + character, string and numeric data. The subpackages of this + package are listed next. + + `Ada.Text_IO.Decimal_IO' + Provides input-output facilities for decimal fixed-point types + + `Ada.Text_IO.Enumeration_IO' + Provides input-output facilities for enumeration types. + + `Ada.Text_IO.Fixed_IO' + Provides input-output facilities for ordinary fixed-point types. + + `Ada.Text_IO.Float_IO' + Provides input-output facilities for float types. The following + predefined instantiations of this generic package are available: + + `Short_Float' + `Short_Float_Text_IO' + + `Float' + `Float_Text_IO' + + `Long_Float' + `Long_Float_Text_IO' + + `Ada.Text_IO.Integer_IO' + Provides input-output facilities for integer types. The following + predefined instantiations of this generic package are available: + + `Short_Short_Integer' + `Ada.Short_Short_Integer_Text_IO' + + `Short_Integer' + `Ada.Short_Integer_Text_IO' + + `Integer' + `Ada.Integer_Text_IO' + + `Long_Integer' + `Ada.Long_Integer_Text_IO' + + `Long_Long_Integer' + `Ada.Long_Long_Integer_Text_IO' + + `Ada.Text_IO.Modular_IO' + Provides input-output facilities for modular (unsigned) types + + `Ada.Text_IO.Complex_IO (G.1.3)' + This package provides basic text input-output capabilities for + complex data. + + `Ada.Text_IO.Editing (F.3.3)' + This package contains routines for edited output, analogous to the + use of pictures in COBOL. The picture formats used by this + package are a close copy of the facility in COBOL. + + `Ada.Text_IO.Text_Streams (A.12.2)' + This package provides a facility that allows Text_IO files to be + treated as streams, so that the stream attributes can be used for + writing arbitrary data, including binary data, to Text_IO files. + + `Ada.Unchecked_Conversion (13.9)' + This generic package allows arbitrary conversion from one type to + another of the same size, providing for breaking the type safety in + special circumstances. + + If the types have the same Size (more accurately the same + Value_Size), then the effect is simply to transfer the bits from + the source to the target type without any modification. This + usage is well defined, and for simple types whose representation + is typically the same across all implementations, gives a portable + method of performing such conversions. + + If the types do not have the same size, then the result is + implementation defined, and thus may be non-portable. The + following describes how GNAT handles such unchecked conversion + cases. + + If the types are of different sizes, and are both discrete types, + then the effect is of a normal type conversion without any + constraint checking. In particular if the result type has a + larger size, the result will be zero or sign extended. If the + result type has a smaller size, the result will be truncated by + ignoring high order bits. + + If the types are of different sizes, and are not both discrete + types, then the conversion works as though pointers were created + to the source and target, and the pointer value is converted. The + effect is that bits are copied from successive low order storage + units and bits of the source up to the length of the target type. + + A warning is issued if the lengths differ, since the effect in this + case is implementation dependent, and the above behavior may not + match that of some other compiler. + + A pointer to one type may be converted to a pointer to another + type using unchecked conversion. The only case in which the + effect is undefined is when one or both pointers are pointers to + unconstrained array types. In this case, the bounds information + may get incorrectly transferred, and in particular, GNAT uses + double size pointers for such types, and it is meaningless to + convert between such pointer types. GNAT will issue a warning if + the alignment of the target designated type is more strict than + the alignment of the source designated type (since the result may + be unaligned in this case). + + A pointer other than a pointer to an unconstrained array type may + be converted to and from System.Address. Such usage is common in + Ada 83 programs, but note that Ada.Address_To_Access_Conversions + is the preferred method of performing such conversions in Ada 95. + Neither unchecked conversion nor Ada.Address_To_Access_Conversions + should be used in conjunction with pointers to unconstrained + objects, since the bounds information cannot be handled correctly + in this case. + + `Ada.Unchecked_Deallocation (13.11.2)' + This generic package allows explicit freeing of storage previously + allocated by use of an allocator. + + `Ada.Wide_Text_IO (A.11)' + This package is similar to `Ada.Text_IO', except that the external + file supports wide character representations, and the internal + types are `Wide_Character' and `Wide_String' instead of `Character' + and `String'. It contains generic subpackages listed next. + + `Ada.Wide_Text_IO.Decimal_IO' + Provides input-output facilities for decimal fixed-point types + + `Ada.Wide_Text_IO.Enumeration_IO' + Provides input-output facilities for enumeration types. + + `Ada.Wide_Text_IO.Fixed_IO' + Provides input-output facilities for ordinary fixed-point types. + + `Ada.Wide_Text_IO.Float_IO' + Provides input-output facilities for float types. The following + predefined instantiations of this generic package are available: + + `Short_Float' + `Short_Float_Wide_Text_IO' + + `Float' + `Float_Wide_Text_IO' + + `Long_Float' + `Long_Float_Wide_Text_IO' + + `Ada.Wide_Text_IO.Integer_IO' + Provides input-output facilities for integer types. The following + predefined instantiations of this generic package are available: + + `Short_Short_Integer' + `Ada.Short_Short_Integer_Wide_Text_IO' + + `Short_Integer' + `Ada.Short_Integer_Wide_Text_IO' + + `Integer' + `Ada.Integer_Wide_Text_IO' + + `Long_Integer' + `Ada.Long_Integer_Wide_Text_IO' + + `Long_Long_Integer' + `Ada.Long_Long_Integer_Wide_Text_IO' + + `Ada.Wide_Text_IO.Modular_IO' + Provides input-output facilities for modular (unsigned) types + + `Ada.Wide_Text_IO.Complex_IO (G.1.3)' + This package is similar to `Ada.Text_IO.Complex_IO', except that + the external file supports wide character representations. + + `Ada.Wide_Text_IO.Editing (F.3.4)' + This package is similar to `Ada.Text_IO.Editing', except that the + types are `Wide_Character' and `Wide_String' instead of + `Character' and `String'. + + `Ada.Wide_Text_IO.Streams (A.12.3)' + This package is similar to `Ada.Text_IO.Streams', except that the + types are `Wide_Character' and `Wide_String' instead of + `Character' and `String'. + +  + File: gnat_rm.info, Node: The Implementation of Standard I/O, Next: The GNAT Library, Prev: Standard Library Routines, Up: Top + + The Implementation of Standard I/O + ********************************** + + GNAT implements all the required input-output facilities described in + A.6 through A.14. These sections of the Ada 95 reference manual + describe the required behavior of these packages from the Ada point of + view, and if you are writing a portable Ada program that does not need + to know the exact manner in which Ada maps to the outside world when it + comes to reading or writing external files, then you do not need to + read this chapter. As long as your files are all regular files (not + pipes or devices), and as long as you write and read the files only + from Ada, the description in the Ada 95 reference manual is sufficient. + + However, if you want to do input-output to pipes or other devices, + such as the keyboard or screen, or if the files you are dealing with are + either generated by some other language, or to be read by some other + language, then you need to know more about the details of how the GNAT + implementation of these input-output facilities behaves. + + In this chapter we give a detailed description of exactly how GNAT + interfaces to the file system. As always, the sources of the system are + available to you for answering questions at an even more detailed level, + but for most purposes the information in this chapter will suffice. + + Another reason that you may need to know more about how input-output + is implemented arises when you have a program written in mixed languages + where, for example, files are shared between the C and Ada sections of + the same program. GNAT provides some additional facilities, in the form + of additional child library packages, that facilitate this sharing, and + these additional facilities are also described in this chapter. + + * Menu: + + * Standard I/O Packages:: + * FORM Strings:: + * Direct_IO:: + * Sequential_IO:: + * Text_IO:: + * Wide_Text_IO:: + * Stream_IO:: + * Shared Files:: + * Open Modes:: + * Operations on C Streams:: + * Interfacing to C Streams:: + +  + File: gnat_rm.info, Node: Standard I/O Packages, Next: FORM Strings, Up: The Implementation of Standard I/O + + Standard I/O Packages + ===================== + + The Standard I/O packages described in Annex A for + + * Ada.Text_IO + + * Ada.Text_IO.Complex_IO + + * Ada.Text_IO.Text_Streams, + + * Ada.Wide_Text_IO + + * Ada.Wide_Text_IO.Complex_IO, + + * Ada.Wide_Text_IO.Text_Streams + + * Ada.Stream_IO + + * Ada.Sequential_IO + + * Ada.Direct_IO + + are implemented using the C library streams facility; where + + * All files are opened using `fopen'. + + * All input/output operations use `fread'/`fwrite'. + + There is no internal buffering of any kind at the Ada library level. + The only buffering is that provided at the system level in the + implementation of the C library routines that support streams. This + facilitates shared use of these streams by mixed language programs. + +  + File: gnat_rm.info, Node: FORM Strings, Next: Direct_IO, Prev: Standard I/O Packages, Up: The Implementation of Standard I/O + + FORM Strings + ============ + + The format of a FORM string in GNAT is: + + "keyword=value,keyword=value,...,keyword=value" + + where letters may be in upper or lower case, and there are no spaces + between values. The order of the entries is not important. Currently + there are two keywords defined. + + SHARED=[YES|NO] + WCEM=[n|h|u|s\e] + + The use of these parameters is described later in this section. + +  + File: gnat_rm.info, Node: Direct_IO, Next: Sequential_IO, Prev: FORM Strings, Up: The Implementation of Standard I/O + + Direct_IO + ========= + + Direct_IO can only be instantiated for definite types. This is a + restriction of the Ada language, which means that the records are fixed + length (the length being determined by `TYPE'Size', rounded up to the + next storage unit boundary if necessary). + + The records of a Direct_IO file are simply written to the file in + index sequence, with the first record starting at offset zero, and + subsequent records following. There is no control information of any + kind. For example, if 32-bit integers are being written, each record + takes 4-bytes, so the record at index K starts at offset (K-1)*4. + + There is no limit on the size of Direct_IO files, they are expanded + as necessary to accommodate whatever records are written to the file. + +  + File: gnat_rm.info, Node: Sequential_IO, Next: Text_IO, Prev: Direct_IO, Up: The Implementation of Standard I/O + + Sequential_IO + ============= + + Sequential_IO may be instantiated with either a definite (constrained) + or indefinite (unconstrained) type. + + For the definite type case, the elements written to the file are + simply the memory images of the data values with no control information + of any kind. The resulting file should be read using the same type, no + validity checking is performed on input. + + For the indefinite type case, the elements written consist of two + parts. First is the size of the data item, written as the memory image + of a `Interfaces.C.size_t' value, followed by the memory image of the + data value. The resulting file can only be read using the same + (unconstrained) type. Normal assignment checks are performed on these + read operations, and if these checks fail, `Data_Error' is raised. In + particular, in the array case, the lengths must match, and in the + variant record case, if the variable for a particular read operation is + constrained, the discriminants must match. + + Note that it is not possible to use Sequential_IO to write variable + length array items, and then read the data back into different length + arrays. For example, the following will raise `Data_Error': + + package IO is new Sequential_IO (String); + F : IO.File_Type; + S : String (1..4); + ... + IO.Create (F) + IO.Write (F, "hello!") + IO.Reset (F, Mode=>In_File); + IO.Read (F, S); + Put_Line (S); + + On some Ada implementations, this will print `hell', but the program + is clearly incorrect, since there is only one element in the file, and + that element is the string `hello!'. + + In Ada 95, this kind of behavior can be legitimately achieved using + Stream_IO, and this is the preferred mechanism. In particular, the + above program fragment rewritten to use Stream_IO will work correctly. + +  + File: gnat_rm.info, Node: Text_IO, Next: Wide_Text_IO, Prev: Sequential_IO, Up: The Implementation of Standard I/O + + Text_IO + ======= + + Text_IO files consist of a stream of characters containing the following + special control characters: + + LF (line feed, 16#0A#) Line Mark + FF (form feed, 16#0C#) Page Mark + + A canonical Text_IO file is defined as one in which the following + conditions are met: + + * The character `LF' is used only as a line mark, i.e. to mark the + end of the line. + + * The character `FF' is used only as a page mark, i.e. to mark the + end of a page and consequently can appear only immediately + following a `LF' (line mark) character. + + * The file ends with either `LF' (line mark) or `LF'-`FF' (line + mark, page mark). In the former case, the page mark is implicitly + assumed to be present. + + A file written using Text_IO will be in canonical form provided that + no explicit `LF' or `FF' characters are written using `Put' or + `Put_Line'. There will be no `FF' character at the end of the file + unless an explicit `New_Page' operation was performed before closing + the file. + + A canonical Text_IO file that is a regular file, i.e. not a device + or a pipe, can be read using any of the routines in Text_IO. The + semantics in this case will be exactly as defined in the Ada 95 + reference manual and all the routines in Text_IO are fully implemented. + + A text file that does not meet the requirements for a canonical + Text_IO file has one of the following: + + * The file contains `FF' characters not immediately following a `LF' + character. + + * The file contains `LF' or `FF' characters written by `Put' or + `Put_Line', which are not logically considered to be line marks or + page marks. + + * The file ends in a character other than `LF' or `FF', i.e. there + is no explicit line mark or page mark at the end of the file. + + Text_IO can be used to read such non-standard text files but + subprograms to do with line or page numbers do not have defined + meanings. In particular, a `FF' character that does not follow a `LF' + character may or may not be treated as a page mark from the point of + view of page and line numbering. Every `LF' character is considered to + end a line, and there is an implied `LF' character at the end of the + file. + + * Menu: + + * Text_IO Stream Pointer Positioning:: + * Text_IO Reading and Writing Non-Regular Files:: + * Get_Immediate:: + * Treating Text_IO Files as Streams:: + * Text_IO Extensions:: + * Text_IO Facilities for Unbounded Strings:: + +  + File: gnat_rm.info, Node: Text_IO Stream Pointer Positioning, Next: Text_IO Reading and Writing Non-Regular Files, Up: Text_IO + + Stream Pointer Positioning + -------------------------- + + `Ada.Text_IO' has a definition of current position for a file that is + being read. No internal buffering occurs in Text_IO, and usually the + physical position in the stream used to implement the file corresponds + to this logical position defined by Text_IO. There are two exceptions: + + * After a call to `End_Of_Page' that returns `True', the stream is + positioned past the `LF' (line mark) that precedes the page mark. + Text_IO maintains an internal flag so that subsequent read + operations properly handle the logical position which is unchanged + by the `End_Of_Page' call. + + * After a call to `End_Of_File' that returns `True', if the Text_IO + file was positioned before the line mark at the end of file before + the call, then the logical position is unchanged, but the stream + is physically positioned right at the end of file (past the line + mark, and past a possible page mark following the line mark. + Again Text_IO maintains internal flags so that subsequent read + operations properly handle the logical position. + + These discrepancies have no effect on the observable behavior of + Text_IO, but if a single Ada stream is shared between a C program and + Ada program, or shared (using `shared=yes' in the form string) between + two Ada files, then the difference may be observable in some situations. + +  + File: gnat_rm.info, Node: Text_IO Reading and Writing Non-Regular Files, Next: Get_Immediate, Prev: Text_IO Stream Pointer Positioning, Up: Text_IO + + Reading and Writing Non-Regular Files + ------------------------------------- + + A non-regular file is a device (such as a keyboard), or a pipe. Text_IO + can be used for reading and writing. Writing is not affected and the + sequence of characters output is identical to the normal file case, but + for reading, the behavior of Text_IO is modified to avoid undesirable + look-ahead as follows: + + An input file that is not a regular file is considered to have no + page marks. Any `Ascii.FF' characters (the character normally used for + a page mark) appearing in the file are considered to be data + characters. In particular: + + * `Get_Line' and `Skip_Line' do not test for a page mark following a + line mark. If a page mark appears, it will be treated as a data + character. + + * This avoids the need to wait for an extra character to be typed or + entered from the pipe to complete one of these operations. + + * `End_Of_Page' always returns `False' + + * `End_Of_File' will return `False' if there is a page mark at the + end of the file. + + Output to non-regular files is the same as for regular files. Page + marks may be written to non-regular files using `New_Page', but as noted + above they will not be treated as page marks on input if the output is + piped to another Ada program. + + Another important discrepancy when reading non-regular files is that + the end of file indication is not "sticky". If an end of file is + entered, e.g. by pressing the key, then end of file is signalled + once (i.e. the test `End_Of_File' will yield `True', or a read will + raise `End_Error'), but then reading can resume to read data past that + end of file indication, until another end of file indication is entered. + +  + File: gnat_rm.info, Node: Get_Immediate, Next: Treating Text_IO Files as Streams, Prev: Text_IO Reading and Writing Non-Regular Files, Up: Text_IO + + Get_Immediate + ------------- + + Get_Immediate returns the next character (including control characters) + from the input file. In particular, Get_Immediate will return LF or FF + characters used as line marks or page marks. Such operations leave the + file positioned past the control character, and it is thus not treated + as having its normal function. This means that page, line and column + counts after this kind of Get_Immediate call are set as though the mark + did not occur. In the case where a Get_Immediate leaves the file + positioned between the line mark and page mark (which is not normally + possible), it is undefined whether the FF character will be treated as a + page mark. + +  + File: gnat_rm.info, Node: Treating Text_IO Files as Streams, Next: Text_IO Extensions, Prev: Get_Immediate, Up: Text_IO + + Treating Text_IO Files as Streams + --------------------------------- + + The package `Text_IO.Streams' allows a Text_IO file to be treated as a + stream. Data written to a Text_IO file in this stream mode is binary + data. If this binary data contains bytes 16#0A# (`LF') or 16#0C# + (`FF'), the resulting file may have non-standard format. Similarly if + read operations are used to read from a Text_IO file treated as a + stream, then `LF' and `FF' characters may be skipped and the effect is + similar to that described above for `Get_Immediate'. + +  + File: gnat_rm.info, Node: Text_IO Extensions, Next: Text_IO Facilities for Unbounded Strings, Prev: Treating Text_IO Files as Streams, Up: Text_IO + + Text_IO Extensions + ------------------ + + A package GNAT.IO_Aux in the GNAT library provides some useful + extensions to the standard `Text_IO' package: + + * function File_Exists (Name : String) return Boolean; Determines if + a file of the given name exists and can be successfully opened + (without actually performing the open operation). + + * function Get_Line return String; Reads a string from the standard + input file. The value returned is exactly the length of the line + that was read. + + * function Get_Line (File : Ada.Text_IO.File_Type) return String; + Similar, except that the parameter File specifies the file from + which the string is to be read. + + +  + File: gnat_rm.info, Node: Text_IO Facilities for Unbounded Strings, Prev: Text_IO Extensions, Up: Text_IO + + Text_IO Facilities for Unbounded Strings + ---------------------------------------- + + The package `Ada.Strings.Unbounded.Text_IO' in library files + `a-suteio.ads/adb' contains some GNAT-specific subprograms useful for + Text_IO operations on unbounded strings: + + * function Get_Line (File : File_Type) return Unbounded_String; + Reads a line from the specified file and returns the result as an + unbounded string. + + * procedure Put (File : File_Type; U : Unbounded_String); Writes the + value of the given unbounded string to the specified file Similar + to the effect of `Put (To_String (U))' except that an extra copy + is avoided. + + * procedure Put_Line (File : File_Type; U : Unbounded_String); + Writes the value of the given unbounded string to the specified + file, followed by a `New_Line'. Similar to the effect of + `Put_Line (To_String (U))' except that an extra copy is avoided. + + In the above procedures, `File' is of type `Ada.Text_IO.File_Type' and + is optional. If the parameter is omitted, then the standard input or + output file is referenced as appropriate. + + The package `Ada.Strings.Wide_Unbounded.Wide_Text_IO' in library + files `a-swuwti.ads' and `a-swuwti.adb' provides similar extended + `Wide_Text_IO' functionality for unbounded wide strings. + +  + File: gnat_rm.info, Node: Wide_Text_IO, Next: Stream_IO, Prev: Text_IO, Up: The Implementation of Standard I/O + + Wide_Text_IO + ============ + + `Wide_Text_IO' is similar in most respects to Text_IO, except that both + input and output files may contain special sequences that represent + wide character values. The encoding scheme for a given file may be + specified using a FORM parameter: + + WCEM=X + + as part of the FORM string (WCEM = wide character encoding method), + where X is one of the following characters + + `h' + Hex ESC encoding + + `u' + Upper half encoding + + `s' + Shift-JIS encoding + + `e' + EUC Encoding + + `8' + UTF-8 encoding + + `b' + Brackets encoding + + The encoding methods match those that can be used in a source + program, but there is no requirement that the encoding method used for + the source program be the same as the encoding method used for files, + and different files may use different encoding methods. + + The default encoding method for the standard files, and for opened + files for which no WCEM parameter is given in the FORM string matches + the wide character encoding specified for the main program (the default + being brackets encoding if no coding method was specified with -gnatW). + + Hex Coding + In this encoding, a wide character is represented by a five + character sequence: + + ESC a b c d + + where A, B, C, D are the four hexadecimal characters (using upper + case letters) of the wide character code. For example, ESC A345 + is used to represent the wide character with code 16#A345#. This + scheme is compatible with use of the full `Wide_Character' set. + + Upper Half Coding + The wide character with encoding 16#abcd#, where the upper bit is + on (i.e. a is in the range 8-F) is represented as two bytes 16#ab# + and 16#cd#. The second byte may never be a format control + character, but is not required to be in the upper half. This + method can be also used for shift-JIS or EUC where the internal + coding matches the external coding. + + Shift JIS Coding + A wide character is represented by a two character sequence 16#ab# + and 16#cd#, with the restrictions described for upper half + encoding as described above. The internal character code is the + corresponding JIS character according to the standard algorithm + for Shift-JIS conversion. Only characters defined in the JIS code + set table can be used with this encoding method. + + EUC Coding + A wide character is represented by a two character sequence 16#ab# + and 16#cd#, with both characters being in the upper half. The + internal character code is the corresponding JIS character + according to the EUC encoding algorithm. Only characters defined + in the JIS code set table can be used with this encoding method. + + UTF-8 Coding + A wide character is represented using UCS Transformation Format 8 + (UTF-8) as defined in Annex R of ISO 10646-1/Am.2. Depending on + the character value, the representation is a one, two, or three + byte sequence: + + 16#0000#-16#007f#: 2#0xxxxxxx# + 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx# + 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx# + + where the xxx bits correspond to the left-padded bits of the + 16-bit character value. Note that all lower half ASCII characters + are represented as ASCII bytes and all upper half characters and + other wide characters are represented as sequences of upper-half + (The full UTF-8 scheme allows for encoding 31-bit characters as + 6-byte sequences, but in this implementation, all UTF-8 sequences + of four or more bytes length will raise a Constraint_Error, as + will all invalid UTF-8 sequences.) + + Brackets Coding + In this encoding, a wide character is represented by the following + eight character sequence: + + [ " a b c d " ] + + Where `a', `b', `c', `d' are the four hexadecimal characters + (using uppercase letters) of the wide character code. For + example, `["A345"]' is used to represent the wide character with + code `16#A345#'. This scheme is compatible with use of the full + Wide_Character set. On input, brackets coding can also be used + for upper half characters, e.g. `["C1"]' for lower case a. + However, on output, brackets notation is only used for wide + characters with a code greater than `16#FF#'. + + For the coding schemes other than Hex and Brackets encoding, not all + wide character values can be represented. An attempt to output a + character that cannot be represented using the encoding scheme for the + file causes Constraint_Error to be raised. An invalid wide character + sequence on input also causes Constraint_Error to be raised. + + * Menu: + + * Wide_Text_IO Stream Pointer Positioning:: + * Wide_Text_IO Reading and Writing Non-Regular Files:: + +  + File: gnat_rm.info, Node: Wide_Text_IO Stream Pointer Positioning, Next: Wide_Text_IO Reading and Writing Non-Regular Files, Up: Wide_Text_IO + + Stream Pointer Positioning + -------------------------- + + `Ada.Wide_Text_IO' is similar to `Ada.Text_IO' in its handling of + stream pointer positioning (*note Text_IO::). There is one additional + case: + + If `Ada.Wide_Text_IO.Look_Ahead' reads a character outside the + normal lower ASCII set (i.e. a character in the range: + + Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#) + + then although the logical position of the file pointer is unchanged by + the `Look_Ahead' call, the stream is physically positioned past the + wide character sequence. Again this is to avoid the need for buffering + or backup, and all `Wide_Text_IO' routines check the internal + indication that this situation has occurred so that this is not visible + to a normal program using `Wide_Text_IO'. However, this discrepancy + can be observed if the wide text file shares a stream with another file. + +  + File: gnat_rm.info, Node: Wide_Text_IO Reading and Writing Non-Regular Files, Prev: Wide_Text_IO Stream Pointer Positioning, Up: Wide_Text_IO + + Reading and Writing Non-Regular Files + ------------------------------------- + + As in the case of Text_IO, when a non-regular file is read, it is + assumed that the file contains no page marks (any form characters are + treated as data characters), and `End_Of_Page' always returns `False'. + Similarly, the end of file indication is not sticky, so it is possible + to read beyond an end of file. + +  + File: gnat_rm.info, Node: Stream_IO, Next: Shared Files, Prev: Wide_Text_IO, Up: The Implementation of Standard I/O + + Stream_IO + ========= + + A stream file is a sequence of bytes, where individual elements are + written to the file as described in the Ada 95 reference manual. The + type `Stream_Element' is simply a byte. There are two ways to read or + write a stream file. + + * The operations `Read' and `Write' directly read or write a + sequence of stream elements with no control information. + + * The stream attributes applied to a stream file transfer data in the + manner described for stream attributes. + +  + File: gnat_rm.info, Node: Shared Files, Next: Open Modes, Prev: Stream_IO, Up: The Implementation of Standard I/O + + Shared Files + ============ + + Section A.14 of the Ada 95 Reference Manual allows implementations to + provide a wide variety of behavior if an attempt is made to access the + same external file with two or more internal files. + + To provide a full range of functionality, while at the same time + minimizing the problems of portability caused by this implementation + dependence, GNAT handles file sharing as follows: + + * In the absence of a `shared=XXX' form parameter, an attempt to + open two or more files with the same full name is considered an + error and is not supported. The exception `Use_Error' will be + raised. Note that a file that is not explicitly closed by the + program remains open until the program terminates. + + * If the form parameter `shared=no' appears in the form string, the + file can be opened or created with its own separate stream + identifier, regardless of whether other files sharing the same + external file are opened. The exact effect depends on how the C + stream routines handle multiple accesses to the same external + files using separate streams. + + * If the form parameter `shared=yes' appears in the form string for + each of two or more files opened using the same full name, the same + stream is shared between these files, and the semantics are as + described in Ada 95 Reference Manual, Section A.14. + + When a program that opens multiple files with the same name is ported + from another Ada compiler to GNAT, the effect will be that `Use_Error' + is raised. + + The documentation of the original compiler and the documentation of + the program should then be examined to determine if file sharing was + expected, and `shared=XXX' parameters added to `Open' and `Create' + calls as required. + + When a program is ported from GNAT to some other Ada compiler, no + special attention is required unless the `shared=XXX' form parameter is + used in the program. In this case, you must examine the documentation + of the new compiler to see if it supports the required file sharing + semantics, and form strings modified appropriately. Of course it may + be the case that the program cannot be ported if the target compiler + does not support the required functionality. The best approach in + writing portable code is to avoid file sharing (and hence the use of + the `shared=XXX' parameter in the form string) completely. + + One common use of file sharing in Ada 83 is the use of + instantiations of Sequential_IO on the same file with different types, + to achieve heterogeneous input-output. Although this approach will + work in GNAT if `shared=yes' is specified, it is preferable in Ada 95 + to use Stream_IO for this purpose (using the stream attributes) + +  + File: gnat_rm.info, Node: Open Modes, Next: Operations on C Streams, Prev: Shared Files, Up: The Implementation of Standard I/O + + Open Modes + ========== + + `Open' and `Create' calls result in a call to `fopen' using the mode + shown in Table 6.1 + + + + Table 6-1 `Open' and `Create' Call Modes + OPEN CREATE + Append_File "r+" "w+" + In_File "r" "w+" + Out_File (Direct_IO) "r+" "w" + Out_File (all other cases) "w" "w" + Inout_File "r+" "w+" + + If text file translation is required, then either `b' or `t' is + added to the mode, depending on the setting of Text. Text file + translation refers to the mapping of CR/LF sequences in an external file + to LF characters internally. This mapping only occurs in DOS and + DOS-like systems, and is not relevant to other systems. + + A special case occurs with Stream_IO. As shown in the above table, + the file is initially opened in `r' or `w' mode for the `In_File' and + `Out_File' cases. If a `Set_Mode' operation subsequently requires + switching from reading to writing or vice-versa, then the file is + reopened in `r+' mode to permit the required operation. + +  + File: gnat_rm.info, Node: Operations on C Streams, Next: Interfacing to C Streams, Prev: Open Modes, Up: The Implementation of Standard I/O + + Operations on C Streams + ======================= + + The package `Interfaces.C_Streams' provides an Ada program with + direct access to the C library functions for operations on C streams: + + package Interfaces.C_Streams is + -- Note: the reason we do not use the types that are in + -- Interfaces.C is that we want to avoid dragging in the + -- code in this unit if possible. + subtype chars is System.Address; + -- Pointer to null-terminated array of characters + subtype FILEs is System.Address; + -- Corresponds to the C type FILE* + subtype voids is System.Address; + -- Corresponds to the C type void* + subtype int is Integer; + subtype long is Long_Integer; + -- Note: the above types are subtypes deliberately, and it + -- is part of this spec that the above correspondences are + -- guaranteed. This means that it is legitimate to, for + -- example, use Integer instead of int. We provide these + -- synonyms for clarity, but in some cases it may be + -- convenient to use the underlying types (for example to + -- avoid an unnecessary dependency of a spec on the spec + -- of this unit). + type size_t is mod 2 ** Standard'Address_Size; + NULL_Stream : constant FILEs; + -- Value returned (NULL in C) to indicate an + -- fdopen/fopen/tmpfile error + ---------------------------------- + -- Constants Defined in stdio.h -- + ---------------------------------- + EOF : constant int; + -- Used by a number of routines to indicate error or + -- end of file + IOFBF : constant int; + IOLBF : constant int; + IONBF : constant int; + -- Used to indicate buffering mode for setvbuf call + SEEK_CUR : constant int; + SEEK_END : constant int; + SEEK_SET : constant int; + -- Used to indicate origin for fseek call + function stdin return FILEs; + function stdout return FILEs; + function stderr return FILEs; + -- Streams associated with standard files + -------------------------- + -- Standard C functions -- + -------------------------- + -- The functions selected below are ones that are + -- available in DOS, OS/2, UNIX and Xenix (but not + -- necessarily in ANSI C). These are very thin interfaces + -- which copy exactly the C headers. For more + -- documentation on these functions, see the Microsoft C + -- "Run-Time Library Reference" (Microsoft Press, 1990, + -- ISBN 1-55615-225-6), which includes useful information + -- on system compatibility. + procedure clearerr (stream : FILEs); + function fclose (stream : FILEs) return int; + function fdopen (handle : int; mode : chars) return FILEs; + function feof (stream : FILEs) return int; + function ferror (stream : FILEs) return int; + function fflush (stream : FILEs) return int; + function fgetc (stream : FILEs) return int; + function fgets (strng : chars; n : int; stream : FILEs) + return chars; + function fileno (stream : FILEs) return int; + function fopen (filename : chars; Mode : chars) + return FILEs; + -- Note: to maintain target independence, use + -- text_translation_required, a boolean variable defined in + -- a-sysdep.c to deal with the target dependent text + -- translation requirement. If this variable is set, + -- then b/t should be appended to the standard mode + -- argument to set the text translation mode off or on + -- as required. + function fputc (C : int; stream : FILEs) return int; + function fputs (Strng : chars; Stream : FILEs) return int; + function fread + (buffer : voids; + size : size_t; + count : size_t; + stream : FILEs) + return size_t; + function freopen + (filename : chars; + mode : chars; + stream : FILEs) + return FILEs; + function fseek + (stream : FILEs; + offset : long; + origin : int) + return int; + function ftell (stream : FILEs) return long; + function fwrite + (buffer : voids; + size : size_t; + count : size_t; + stream : FILEs) + return size_t; + function isatty (handle : int) return int; + procedure mktemp (template : chars); + -- The return value (which is just a pointer to template) + -- is discarded + procedure rewind (stream : FILEs); + function rmtmp return int; + function setvbuf + (stream : FILEs; + buffer : chars; + mode : int; + size : size_t) + return int; + + function tmpfile return FILEs; + function ungetc (c : int; stream : FILEs) return int; + function unlink (filename : chars) return int; + --------------------- + -- Extra functions -- + --------------------- + -- These functions supply slightly thicker bindings than + -- those above. They are derived from functions in the + -- C Run-Time Library, but may do a bit more work than + -- just directly calling one of the Library functions. + function is_regular_file (handle : int) return int; + -- Tests if given handle is for a regular file (result 1) + -- or for a non-regular file (pipe or device, result 0). + --------------------------------- + -- Control of Text/Binary Mode -- + --------------------------------- + -- If text_translation_required is true, then the following + -- functions may be used to dynamically switch a file from + -- binary to text mode or vice versa. These functions have + -- no effect if text_translation_required is false (i.e. in + -- normal UNIX mode). Use fileno to get a stream handle. + procedure set_binary_mode (handle : int); + procedure set_text_mode (handle : int); + ---------------------------- + -- Full Path Name support -- + ---------------------------- + procedure full_name (nam : chars; buffer : chars); + -- Given a NUL terminated string representing a file + -- name, returns in buffer a NUL terminated string + -- representing the full path name for the file name. + -- On systems where it is relevant the drive is also + -- part of the full path name. It is the responsibility + -- of the caller to pass an actual parameter for buffer + -- that is big enough for any full path name. Use + -- max_path_len given below as the size of buffer. + max_path_len : integer; + -- Maximum length of an allowable full path name on the + -- system, including a terminating NUL character. + end Interfaces.C_Streams; + +  + File: gnat_rm.info, Node: Interfacing to C Streams, Prev: Operations on C Streams, Up: The Implementation of Standard I/O + + Interfacing to C Streams + ======================== + + The packages in this section permit interfacing Ada files to C Stream + operations. + + with Interfaces.C_Streams; + package Ada.Sequential_IO.C_Streams is + function C_Stream (F : File_Type) + return Interfaces.C_Streams.FILEs; + procedure Open + (File : in out File_Type; + Mode : in File_Mode; + C_Stream : in Interfaces.C_Streams.FILEs; + Form : in String := ""); + end Ada.Sequential_IO.C_Streams; + + with Interfaces.C_Streams; + package Ada.Direct_IO.C_Streams is + function C_Stream (F : File_Type) + return Interfaces.C_Streams.FILEs; + procedure Open + (File : in out File_Type; + Mode : in File_Mode; + C_Stream : in Interfaces.C_Streams.FILEs; + Form : in String := ""); + end Ada.Direct_IO.C_Streams; + + with Interfaces.C_Streams; + package Ada.Text_IO.C_Streams is + function C_Stream (F : File_Type) + return Interfaces.C_Streams.FILEs; + procedure Open + (File : in out File_Type; + Mode : in File_Mode; + C_Stream : in Interfaces.C_Streams.FILEs; + Form : in String := ""); + end Ada.Text_IO.C_Streams; + + with Interfaces.C_Streams; + package Ada.Wide_Text_IO.C_Streams is + function C_Stream (F : File_Type) + return Interfaces.C_Streams.FILEs; + procedure Open + (File : in out File_Type; + Mode : in File_Mode; + C_Stream : in Interfaces.C_Streams.FILEs; + Form : in String := ""); + end Ada.Wide_Text_IO.C_Streams; + + with Interfaces.C_Streams; + package Ada.Stream_IO.C_Streams is + function C_Stream (F : File_Type) + return Interfaces.C_Streams.FILEs; + procedure Open + (File : in out File_Type; + Mode : in File_Mode; + C_Stream : in Interfaces.C_Streams.FILEs; + Form : in String := ""); + end Ada.Stream_IO.C_Streams; + + In each of these five packages, the `C_Stream' function obtains the + `FILE' pointer from a currently opened Ada file. It is then possible + to use the `Interfaces.C_Streams' package to operate on this stream, or + the stream can be passed to a C program which can operate on it + directly. Of course the program is responsible for ensuring that only + appropriate sequences of operations are executed. + + One particular use of relevance to an Ada program is that the + `setvbuf' function can be used to control the buffering of the stream + used by an Ada file. In the absence of such a call the standard + default buffering is used. + + The `Open' procedures in these packages open a file giving an + existing C Stream instead of a file name. Typically this stream is + imported from a C program, allowing an Ada file to operate on an + existing C file. + +  + File: gnat_rm.info, Node: The GNAT Library, Next: Interfacing to Other Languages, Prev: The Implementation of Standard I/O, Up: Top + + The GNAT Library + **************** + + The GNAT library contains a number of general and special purpose + packages. It represents functionality that the GNAT developers have + found useful, and which is made available to GNAT users. The packages + described here are fully supported, and upwards compatibility will be + maintained in future releases, so you can use these facilities with the + confidence that the same functionality will be available in future + releases. + + The chapter here simply gives a brief summary of the facilities + available. The full documentation is found in the spec file for the + package. The full sources of these library packages, including both + spec and body, are provided with all GNAT releases. For example, to + find out the full specifications of the SPITBOL pattern matching + capability, including a full tutorial and extensive examples, look in + the `g-spipat.ads' file in the library. + + For each entry here, the package name (as it would appear in a `with' + clause) is given, followed by the name of the corresponding spec file in + parentheses. The packages are children in four hierarchies, `Ada', + `Interfaces', `System', and `GNAT', the latter being a GNAT-specific + hierarchy. + + Note that an application program should only use packages in one of + these four hierarchies if the package is defined in the Ada Reference + Manual, or is listed in this section of the GNAT Programmers Reference + Manual. All other units should be considered internal implementation + units and should not be directly `with''ed by application code. The + use of a `with' statement that references one of these internal + implementation units makes an application potentially dependent on + changes in versions of GNAT, and will generate a warning message. + + * Menu: + + * Ada.Characters.Latin_9 (a-chlat9.ads):: + * Ada.Characters.Wide_Latin_1 (a-cwila1.ads):: + * Ada.Characters.Wide_Latin_9 (a-cwila9.ads):: + * Ada.Command_Line.Remove (a-colire.ads):: + * Ada.Direct_IO.C_Streams (a-diocst.ads):: + * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads):: + * Ada.Sequential_IO.C_Streams (a-siocst.ads):: + * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads):: + * Ada.Strings.Unbounded.Text_IO (a-suteio.ads):: + * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads):: + * Ada.Text_IO.C_Streams (a-tiocst.ads):: + * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads):: + * GNAT.AWK (g-awk.ads):: + * GNAT.Bubble_Sort_A (g-busora.ads):: + * GNAT.Bubble_Sort_G (g-busorg.ads):: + * GNAT.Calendar (g-calend.ads):: + * GNAT.Calendar.Time_IO (g-catiio.ads):: + * GNAT.CRC32 (g-crc32.ads):: + * GNAT.Case_Util (g-casuti.ads):: + * GNAT.CGI (g-cgi.ads):: + * GNAT.CGI.Cookie (g-cgicoo.ads):: + * GNAT.CGI.Debug (g-cgideb.ads):: + * GNAT.Command_Line (g-comlin.ads):: + * GNAT.Current_Exception (g-curexc.ads):: + * GNAT.Debug_Pools (g-debpoo.ads):: + * GNAT.Debug_Utilities (g-debuti.ads):: + * GNAT.Directory_Operations (g-dirope.ads):: + * GNAT.Dynamic_Tables (g-dyntab.ads):: + * GNAT.Exception_Traces (g-exctra.ads):: + * GNAT.Expect (g-expect.ads):: + * GNAT.Float_Control (g-flocon.ads):: + * GNAT.Heap_Sort_A (g-hesora.ads):: + * GNAT.Heap_Sort_G (g-hesorg.ads):: + * GNAT.HTable (g-htable.ads):: + * GNAT.IO (g-io.ads):: + * GNAT.IO_Aux (g-io_aux.ads):: + * GNAT.Lock_Files (g-locfil.ads):: + * GNAT.MD5 (g-md5.ads):: + * GNAT.Most_Recent_Exception (g-moreex.ads):: + * GNAT.OS_Lib (g-os_lib.ads):: + * GNAT.Regexp (g-regexp.ads):: + * GNAT.Registry (g-regist.ads):: + * GNAT.Regpat (g-regpat.ads):: + * GNAT.Sockets (g-socket.ads):: + * GNAT.Source_Info (g-souinf.ads):: + * GNAT.Spell_Checker (g-speche.ads):: + * GNAT.Spitbol.Patterns (g-spipat.ads):: + * GNAT.Spitbol (g-spitbo.ads):: + * GNAT.Spitbol.Table_Boolean (g-sptabo.ads):: + * GNAT.Spitbol.Table_Integer (g-sptain.ads):: + * GNAT.Spitbol.Table_VString (g-sptavs.ads):: + * GNAT.Table (g-table.ads):: + * GNAT.Task_Lock (g-tasloc.ads):: + * GNAT.Threads (g-thread.ads):: + * GNAT.Traceback (g-traceb.ads):: + * GNAT.Traceback.Symbolic (g-trasym.ads):: + * Interfaces.C.Extensions (i-cexten.ads):: + * Interfaces.C.Streams (i-cstrea.ads):: + * Interfaces.CPP (i-cpp.ads):: + * Interfaces.Os2lib (i-os2lib.ads):: + * Interfaces.Os2lib.Errors (i-os2err.ads):: + * Interfaces.Os2lib.Synchronization (i-os2syn.ads):: + * Interfaces.Os2lib.Threads (i-os2thr.ads):: + * Interfaces.Packed_Decimal (i-pacdec.ads):: + * Interfaces.VxWorks (i-vxwork.ads):: + * Interfaces.VxWorks.IO (i-vxwoio.ads):: + * System.Address_Image (s-addima.ads):: + * System.Assertions (s-assert.ads):: + * System.Partition_Interface (s-parint.ads):: + * System.Task_Info (s-tasinf.ads):: + * System.Wch_Cnv (s-wchcnv.ads):: + * System.Wch_Con (s-wchcon.ads):: + +  + File: gnat_rm.info, Node: Ada.Characters.Latin_9 (a-chlat9.ads), Next: Ada.Characters.Wide_Latin_1 (a-cwila1.ads), Up: The GNAT Library + + `Ada.Characters.Latin_9' (`a-chlat9.ads') + ========================================= + + This child of `Ada.Characters' provides a set of definitions + corresponding to those in the RM-defined package + `Ada.Characters.Latin_1' but with the few modifications required for + `Latin-9' The provision of such a package is specifically authorized by + the Ada Reference Manual (RM A.3(27)). + +  + File: gnat_rm.info, Node: Ada.Characters.Wide_Latin_1 (a-cwila1.ads), Next: Ada.Characters.Wide_Latin_9 (a-cwila9.ads), Prev: Ada.Characters.Latin_9 (a-chlat9.ads), Up: The GNAT Library + + `Ada.Characters.Wide_Latin_1' (`a-cwila1.ads') + ============================================== + + This child of `Ada.Characters' provides a set of definitions + corresponding to those in the RM-defined package + `Ada.Characters.Latin_1' but with the types of the constants being + `Wide_Character' instead of `Character'. The provision of such a + package is specifically authorized by the Ada Reference Manual (RM + A.3(27)). + +  + File: gnat_rm.info, Node: Ada.Characters.Wide_Latin_9 (a-cwila9.ads), Next: Ada.Command_Line.Remove (a-colire.ads), Prev: Ada.Characters.Wide_Latin_1 (a-cwila1.ads), Up: The GNAT Library + + `Ada.Characters.Wide_Latin_9' (`a-cwila1.ads') + ============================================== + + This child of `Ada.Characters' provides a set of definitions + corresponding to those in the GNAT defined package + `Ada.Characters.Latin_9' but with the types of the constants being + `Wide_Character' instead of `Character'. The provision of such a + package is specifically authorized by the Ada Reference Manual (RM + A.3(27)). + +  + File: gnat_rm.info, Node: Ada.Command_Line.Remove (a-colire.ads), Next: Ada.Direct_IO.C_Streams (a-diocst.ads), Prev: Ada.Characters.Wide_Latin_9 (a-cwila9.ads), Up: The GNAT Library + + `Ada.Command_Line.Remove' (`a-colire.ads') + ========================================== + + This child of `Ada.Command_Line' provides a mechanism for logically + removing arguments from the argument list. Once removed, an argument + is not visible to further calls on the subprograms in + `Ada.Command_Line' will not see the removed argument. + +  + File: gnat_rm.info, Node: Ada.Direct_IO.C_Streams (a-diocst.ads), Next: Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads), Prev: Ada.Command_Line.Remove (a-colire.ads), Up: The GNAT Library + + `Ada.Direct_IO.C_Streams' (`a-diocst.ads') + ========================================== + + This package provides subprograms that allow interfacing between C + streams and `Direct_IO'. The stream identifier can be extracted from a + file opened on the Ada side, and an Ada file can be constructed from a + stream opened on the C side. + +  + File: gnat_rm.info, Node: Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads), Next: Ada.Sequential_IO.C_Streams (a-siocst.ads), Prev: Ada.Direct_IO.C_Streams (a-diocst.ads), Up: The GNAT Library + + `Ada.Exceptions.Is_Null_Occurrence' (`a-einuoc.ads') + ==================================================== + + This child subprogram provides a way of testing for the null exception + occurrence (`Null_Occurrence') without raising an exception. + +  + File: gnat_rm.info, Node: Ada.Sequential_IO.C_Streams (a-siocst.ads), Next: Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads), Prev: Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads), Up: The GNAT Library + + `Ada.Sequential_IO.C_Streams' (`a-siocst.ads') + ============================================== + + This package provides subprograms that allow interfacing between C + streams and `Sequential_IO'. The stream identifier can be extracted + from a file opened on the Ada side, and an Ada file can be constructed + from a stream opened on the C side. + +  + File: gnat_rm.info, Node: Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads), Next: Ada.Strings.Unbounded.Text_IO (a-suteio.ads), Prev: Ada.Sequential_IO.C_Streams (a-siocst.ads), Up: The GNAT Library + + `Ada.Streams.Stream_IO.C_Streams' (`a-ssicst.ads') + ================================================== + + This package provides subprograms that allow interfacing between C + streams and `Stream_IO'. The stream identifier can be extracted from a + file opened on the Ada side, and an Ada file can be constructed from a + stream opened on the C side. + +  + File: gnat_rm.info, Node: Ada.Strings.Unbounded.Text_IO (a-suteio.ads), Next: Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads), Prev: Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads), Up: The GNAT Library + + `Ada.Strings.Unbounded.Text_IO' (`a-suteio.ads') + ================================================ + + This package provides subprograms for Text_IO for unbounded strings, + avoiding the necessity for an intermediate operation with ordinary + strings. + +  + File: gnat_rm.info, Node: Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads), Next: Ada.Text_IO.C_Streams (a-tiocst.ads), Prev: Ada.Strings.Unbounded.Text_IO (a-suteio.ads), Up: The GNAT Library + + `Ada.Strings.Wide_Unbounded.Wide_Text_IO' (`a-swuwti.ads') + ========================================================== + + This package provides subprograms for Text_IO for unbounded wide + strings, avoiding the necessity for an intermediate operation with + ordinary wide strings. + +  + File: gnat_rm.info, Node: Ada.Text_IO.C_Streams (a-tiocst.ads), Next: Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads), Prev: Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads), Up: The GNAT Library + + `Ada.Text_IO.C_Streams' (`a-tiocst.ads') + ======================================== + + This package provides subprograms that allow interfacing between C + streams and `Text_IO'. The stream identifier can be extracted from a + file opened on the Ada side, and an Ada file can be constructed from a + stream opened on the C side. + +  + File: gnat_rm.info, Node: Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads), Next: GNAT.AWK (g-awk.ads), Prev: Ada.Text_IO.C_Streams (a-tiocst.ads), Up: The GNAT Library + + `Ada.Wide_Text_IO.C_Streams' (`a-wtcstr.ads') + ============================================= + + This package provides subprograms that allow interfacing between C + streams and `Wide_Text_IO'. The stream identifier can be extracted + from a file opened on the Ada side, and an Ada file can be constructed + from a stream opened on the C side. + +  + File: gnat_rm.info, Node: GNAT.AWK (g-awk.ads), Next: GNAT.Bubble_Sort_A (g-busora.ads), Prev: Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads), Up: The GNAT Library + + `GNAT.AWK' (`g-awk.ads') + ======================== + + Provides AWK-like parsing functions, with an easy interface for parsing + one or more files containing formatted data. The file is viewed as a + database where each record is a line and a field is a data element in + this line. + +  + File: gnat_rm.info, Node: GNAT.Bubble_Sort_A (g-busora.ads), Next: GNAT.Bubble_Sort_G (g-busorg.ads), Prev: GNAT.AWK (g-awk.ads), Up: The GNAT Library + + `GNAT.Bubble_Sort_A' (`g-busora.ads') + ===================================== + + Provides a general implementation of bubble sort usable for sorting + arbitrary data items. Move and comparison procedures are provided by + passing access-to-procedure values. + +  + File: gnat_rm.info, Node: GNAT.Bubble_Sort_G (g-busorg.ads), Next: GNAT.Calendar (g-calend.ads), Prev: GNAT.Bubble_Sort_A (g-busora.ads), Up: The GNAT Library + + `GNAT.Bubble_Sort_G' (`g-busorg.ads') + ===================================== + + Similar to `Bubble_Sort_A' except that the move and sorting procedures + are provided as generic parameters, this improves efficiency, especially + if the procedures can be inlined, at the expense of duplicating code for + multiple instantiations. + +  + File: gnat_rm.info, Node: GNAT.Calendar (g-calend.ads), Next: GNAT.Calendar.Time_IO (g-catiio.ads), Prev: GNAT.Bubble_Sort_G (g-busorg.ads), Up: The GNAT Library + + `GNAT.Calendar' (`g-calend.ads') + ================================ + + Extends the facilities provided by `Ada.Calendar' to include handling + of days of the week, an extended `Split' and `Time_Of' capability. + Also provides conversion of `Ada.Calendar.Time' values to and from the + C `timeval' format. + +  + File: gnat_rm.info, Node: GNAT.Calendar.Time_IO (g-catiio.ads), Next: GNAT.CRC32 (g-crc32.ads), Prev: GNAT.Calendar (g-calend.ads), Up: The GNAT Library + + `GNAT.Calendar.Time_IO' (`g-catiio.ads') + ======================================== + +  + File: gnat_rm.info, Node: GNAT.CRC32 (g-crc32.ads), Next: GNAT.Case_Util (g-casuti.ads), Prev: GNAT.Calendar.Time_IO (g-catiio.ads), Up: The GNAT Library + + `GNAT.CRC32' (`g-crc32.ads') + ============================ + + This package implements the CRC-32 algorithm. For a full description + of this algorithm you should have a look at: "Computation of Cyclic + Redundancy Checks via Table Look-Up", `Communications of the ACM', Vol. + 31 No. 8, pp. 1008-1013, Aug. 1988. Sarwate, D.V. + + Provides an extended capability for formatted output of time values with + full user control over the format. Modeled on the GNU Date + specification. + +  + File: gnat_rm.info, Node: GNAT.Case_Util (g-casuti.ads), Next: GNAT.CGI (g-cgi.ads), Prev: GNAT.CRC32 (g-crc32.ads), Up: The GNAT Library + + `GNAT.Case_Util' (`g-casuti.ads') + ================================= + + A set of simple routines for handling upper and lower casing of strings + without the overhead of the full casing tables in + `Ada.Characters.Handling'. + +  + File: gnat_rm.info, Node: GNAT.CGI (g-cgi.ads), Next: GNAT.CGI.Cookie (g-cgicoo.ads), Prev: GNAT.Case_Util (g-casuti.ads), Up: The GNAT Library + + `GNAT.CGI' (`g-cgi.ads') + ======================== + + This is a package for interfacing a GNAT program with a Web server via + the Common Gateway Interface (CGI). Basically this package parses the + CGI parameters, which are a set of key/value pairs sent by the Web + server. It builds a table whose index is the key and provides some + services to deal with this table. + +  + File: gnat_rm.info, Node: GNAT.CGI.Cookie (g-cgicoo.ads), Next: GNAT.CGI.Debug (g-cgideb.ads), Prev: GNAT.CGI (g-cgi.ads), Up: The GNAT Library + + `GNAT.CGI.Cookie' (`g-cgicoo.ads') + ================================== + + This is a package to interface a GNAT program with a Web server via the + Common Gateway Interface (CGI). It exports services to deal with Web + cookies (piece of information kept in the Web client software). + +  + File: gnat_rm.info, Node: GNAT.CGI.Debug (g-cgideb.ads), Next: GNAT.Command_Line (g-comlin.ads), Prev: GNAT.CGI.Cookie (g-cgicoo.ads), Up: The GNAT Library + + `GNAT.CGI.Debug' (`g-cgideb.ads') + ================================= + + This is a package to help debugging CGI (Common Gateway Interface) + programs written in Ada. + +  + File: gnat_rm.info, Node: GNAT.Command_Line (g-comlin.ads), Next: GNAT.Current_Exception (g-curexc.ads), Prev: GNAT.CGI.Debug (g-cgideb.ads), Up: The GNAT Library + + `GNAT.Command_Line' (`g-comlin.ads') + ==================================== + + Provides a high level interface to `Ada.Command_Line' facilities, + including the ability to scan for named switches with optional + parameters and expand file names using wild card notations. + +  + File: gnat_rm.info, Node: GNAT.Current_Exception (g-curexc.ads), Next: GNAT.Debug_Pools (g-debpoo.ads), Prev: GNAT.Command_Line (g-comlin.ads), Up: The GNAT Library + + `GNAT.Current_Exception' (`g-curexc.ads') + ========================================= + + Provides access to information on the current exception that has been + raised without the need for using the Ada-95 exception choice parameter + specification syntax. This is particularly useful in simulating + typical facilities for obtaining information about exceptions provided + by Ada 83 compilers. + +  + File: gnat_rm.info, Node: GNAT.Debug_Pools (g-debpoo.ads), Next: GNAT.Debug_Utilities (g-debuti.ads), Prev: GNAT.Current_Exception (g-curexc.ads), Up: The GNAT Library + + `GNAT.Debug_Pools' (`g-debpoo.ads') + =================================== + + Provide a debugging storage pools that helps tracking memory corruption + problems. See section "Finding memory problems with GNAT Debug Pool" in + the `GNAT User's Guide'. + +  + File: gnat_rm.info, Node: GNAT.Debug_Utilities (g-debuti.ads), Next: GNAT.Directory_Operations (g-dirope.ads), Prev: GNAT.Debug_Pools (g-debpoo.ads), Up: The GNAT Library + + `GNAT.Debug_Utilities' (`g-debuti.ads') + ======================================= + + Provides a few useful utilities for debugging purposes, including + conversion to and from string images of address values. + +  + File: gnat_rm.info, Node: GNAT.Directory_Operations (g-dirope.ads), Next: GNAT.Dynamic_Tables (g-dyntab.ads), Prev: GNAT.Debug_Utilities (g-debuti.ads), Up: The GNAT Library + + `GNAT.Directory_Operations' (g-dirope.ads) + ========================================== + + Provides a set of routines for manipulating directories, including + changing the current directory, making new directories, and scanning + the files in a directory. + +  + File: gnat_rm.info, Node: GNAT.Dynamic_Tables (g-dyntab.ads), Next: GNAT.Exception_Traces (g-exctra.ads), Prev: GNAT.Directory_Operations (g-dirope.ads), Up: The GNAT Library + + `GNAT.Dynamic_Tables' (`g-dyntab.ads') + ====================================== + + A generic package providing a single dimension array abstraction where + the length of the array can be dynamically modified. + + This package provides a facility similar to that of GNAT.Table, except + that this package declares a type that can be used to define dynamic + instances of the table, while an instantiation of GNAT.Table creates a + single instance of the table type. + +  + File: gnat_rm.info, Node: GNAT.Exception_Traces (g-exctra.ads), Next: GNAT.Expect (g-expect.ads), Prev: GNAT.Dynamic_Tables (g-dyntab.ads), Up: The GNAT Library + + `GNAT.Exception_Traces' (`g-exctra.ads') + ======================================== + + Provides an interface allowing to control automatic output upon + exception occurrences. + +  + File: gnat_rm.info, Node: GNAT.Expect (g-expect.ads), Next: GNAT.Float_Control (g-flocon.ads), Prev: GNAT.Exception_Traces (g-exctra.ads), Up: The GNAT Library + + `GNAT.Expect' (`g-expect.ads') + ============================== + + Provides a set of subprograms similar to what is available with the + standard Tcl Expect tool. It allows you to easily spawn and + communicate with an external process. You can send commands or inputs + to the process, and compare the output with some expected regular + expression. Currently GNAT.Expect is implemented on all native GNAT + ports except for OpenVMS. It is not implemented for cross ports, and + in particular is not implemented for VxWorks or LynxOS. + +  + File: gnat_rm.info, Node: GNAT.Float_Control (g-flocon.ads), Next: GNAT.Heap_Sort_A (g-hesora.ads), Prev: GNAT.Expect (g-expect.ads), Up: The GNAT Library + + `GNAT.Float_Control' (`g-flocon.ads') + ===================================== + + Provides an interface for resetting the floating-point processor into + the mode required for correct semantic operation in Ada. Some third + party library calls may cause this mode to be modified, and the Reset + procedure in this package can be used to reestablish the required mode. + +  + File: gnat_rm.info, Node: GNAT.Heap_Sort_A (g-hesora.ads), Next: GNAT.Heap_Sort_G (g-hesorg.ads), Prev: GNAT.Float_Control (g-flocon.ads), Up: The GNAT Library + + `GNAT.Heap_Sort_A' (`g-hesora.ads') + =================================== + + Provides a general implementation of heap sort usable for sorting + arbitrary data items. Move and comparison procedures are provided by + passing access-to-procedure values. The algorithm used is a modified + heap sort that performs approximately N*log(N) comparisons in the worst + case. + +  + File: gnat_rm.info, Node: GNAT.Heap_Sort_G (g-hesorg.ads), Next: GNAT.HTable (g-htable.ads), Prev: GNAT.Heap_Sort_A (g-hesora.ads), Up: The GNAT Library + + `GNAT.Heap_Sort_G' (`g-hesorg.ads') + =================================== + + Similar to `Heap_Sort_A' except that the move and sorting procedures + are provided as generic parameters, this improves efficiency, especially + if the procedures can be inlined, at the expense of duplicating code for + multiple instantiations. + +  + File: gnat_rm.info, Node: GNAT.HTable (g-htable.ads), Next: GNAT.IO (g-io.ads), Prev: GNAT.Heap_Sort_G (g-hesorg.ads), Up: The GNAT Library + + `GNAT.HTable' (`g-htable.ads') + ============================== + + A generic implementation of hash tables that can be used to hash + arbitrary data. Provides two approaches, one a simple static approach, + and the other allowing arbitrary dynamic hash tables. + +  + File: gnat_rm.info, Node: GNAT.IO (g-io.ads), Next: GNAT.IO_Aux (g-io_aux.ads), Prev: GNAT.HTable (g-htable.ads), Up: The GNAT Library + + `GNAT.IO' (`g-io.ads') + ====================== + + A simple preealborable input-output package that provides a subset of + simple Text_IO functions for reading characters and strings from + Standard_Input, and writing characters, strings and integers to either + Standard_Output or Standard_Error. + +  + File: gnat_rm.info, Node: GNAT.IO_Aux (g-io_aux.ads), Next: GNAT.Lock_Files (g-locfil.ads), Prev: GNAT.IO (g-io.ads), Up: The GNAT Library + + `GNAT.IO_Aux' (`g-io_aux.ads') + ============================== + + Provides some auxiliary functions for use with Text_IO, including a + test for whether a file exists, and functions for reading a line of + text. + +  + File: gnat_rm.info, Node: GNAT.Lock_Files (g-locfil.ads), Next: GNAT.MD5 (g-md5.ads), Prev: GNAT.IO_Aux (g-io_aux.ads), Up: The GNAT Library + + `GNAT.Lock_Files' (`g-locfil.ads') + ================================== + + Provides a general interface for using files as locks. Can be used for + providing program level synchronization. + +  + File: gnat_rm.info, Node: GNAT.MD5 (g-md5.ads), Next: GNAT.Most_Recent_Exception (g-moreex.ads), Prev: GNAT.Lock_Files (g-locfil.ads), Up: The GNAT Library + + `GNAT.MD5' (`g-md5.ads') + ======================== + + Implements the MD5 Message-Digest Algorithm as described in RFC 1321. + +  + File: gnat_rm.info, Node: GNAT.Most_Recent_Exception (g-moreex.ads), Next: GNAT.OS_Lib (g-os_lib.ads), Prev: GNAT.MD5 (g-md5.ads), Up: The GNAT Library + + `GNAT.Most_Recent_Exception' (`g-moreex.ads') + ============================================= + + Provides access to the most recently raised exception. Can be used for + various logging purposes, including duplicating functionality of some + Ada 83 implementation dependent extensions. + +  + File: gnat_rm.info, Node: GNAT.OS_Lib (g-os_lib.ads), Next: GNAT.Regexp (g-regexp.ads), Prev: GNAT.Most_Recent_Exception (g-moreex.ads), Up: The GNAT Library + + `GNAT.OS_Lib' (`g-os_lib.ads') + ============================== + + Provides a range of target independent operating system interface + functions, including time/date management, file operations, subprocess + management, including a portable spawn procedure, and access to + environment variables and error return codes. + +  + File: gnat_rm.info, Node: GNAT.Regexp (g-regexp.ads), Next: GNAT.Registry (g-regist.ads), Prev: GNAT.OS_Lib (g-os_lib.ads), Up: The GNAT Library + + `GNAT.Regexp' (`g-regexp.ads') + ============================== + + A simple implementation of regular expressions, using a subset of + regular expression syntax copied from familiar Unix style utilities. + This is the simples of the three pattern matching packages provided, + and is particularly suitable for "file globbing" applications. + +  + File: gnat_rm.info, Node: GNAT.Registry (g-regist.ads), Next: GNAT.Regpat (g-regpat.ads), Prev: GNAT.Regexp (g-regexp.ads), Up: The GNAT Library + + `GNAT.Registry' (`g-regist.ads') + ================================ + + This is a high level binding to the Windows registry. It is possible to + do simple things like reading a key value, creating a new key. For full + registry API, but at a lower level of abstraction, refer to the + Win32.Winreg package provided with the Win32Ada binding + +  + File: gnat_rm.info, Node: GNAT.Regpat (g-regpat.ads), Next: GNAT.Sockets (g-socket.ads), Prev: GNAT.Registry (g-regist.ads), Up: The GNAT Library + + `GNAT.Regpat' (`g-regpat.ads') + ============================== + + A complete implementation of Unix-style regular expression matching, + copied from the original V7 style regular expression library written in + C by Henry Spencer (and binary compatible with this C library). + +  + File: gnat_rm.info, Node: GNAT.Sockets (g-socket.ads), Next: GNAT.Source_Info (g-souinf.ads), Prev: GNAT.Regpat (g-regpat.ads), Up: The GNAT Library + + `GNAT.Sockets' (`g-socket.ads') + =============================== + + A high level and portable interface to develop sockets based + applications. This package is based on the sockets thin binding found + in GNAT.Sockets.Thin. Currently GNAT.Sockets is implemented on all + native GNAT ports except for OpenVMS. It is not implemented for the + LynxOS cross port. + +  + File: gnat_rm.info, Node: GNAT.Source_Info (g-souinf.ads), Next: GNAT.Spell_Checker (g-speche.ads), Prev: GNAT.Sockets (g-socket.ads), Up: The GNAT Library + + `GNAT.Source_Info' (`g-souinf.ads') + =================================== + + Provides subprograms that give access to source code information known + at compile time, such as the current file name and line number. + +  + File: gnat_rm.info, Node: GNAT.Spell_Checker (g-speche.ads), Next: GNAT.Spitbol.Patterns (g-spipat.ads), Prev: GNAT.Source_Info (g-souinf.ads), Up: The GNAT Library + + `GNAT.Spell_Checker' (`g-speche.ads') + ===================================== + + Provides a function for determining whether one string is a plausible + near misspelling of another string. + +  + File: gnat_rm.info, Node: GNAT.Spitbol.Patterns (g-spipat.ads), Next: GNAT.Spitbol (g-spitbo.ads), Prev: GNAT.Spell_Checker (g-speche.ads), Up: The GNAT Library + + `GNAT.Spitbol.Patterns' (`g-spipat.ads') + ======================================== + + A complete implementation of SNOBOL4 style pattern matching. This is + the most elaborate of the pattern matching packages provided. It fully + duplicates the SNOBOL4 dynamic pattern construction and matching + capabilities, using the efficient algorithm developed by Robert Dewar + for the SPITBOL system. + +  + File: gnat_rm.info, Node: GNAT.Spitbol (g-spitbo.ads), Next: GNAT.Spitbol.Table_Boolean (g-sptabo.ads), Prev: GNAT.Spitbol.Patterns (g-spipat.ads), Up: The GNAT Library + + `GNAT.Spitbol' (`g-spitbo.ads') + =============================== + + The top level package of the collection of SPITBOL-style functionality, + this package provides basic SNOBOL4 string manipulation functions, such + as Pad, Reverse, Trim, Substr capability, as well as a generic table + function useful for constructing arbitrary mappings from strings in the + style of the SNOBOL4 TABLE function. + +  + File: gnat_rm.info, Node: GNAT.Spitbol.Table_Boolean (g-sptabo.ads), Next: GNAT.Spitbol.Table_Integer (g-sptain.ads), Prev: GNAT.Spitbol (g-spitbo.ads), Up: The GNAT Library + + `GNAT.Spitbol.Table_Boolean' (`g-sptabo.ads') + ============================================= + + A library level of instantiation of `GNAT.Spitbol.Patterns.Table' for + type `Standard.Boolean', giving an implementation of sets of string + values. + +  + File: gnat_rm.info, Node: GNAT.Spitbol.Table_Integer (g-sptain.ads), Next: GNAT.Spitbol.Table_VString (g-sptavs.ads), Prev: GNAT.Spitbol.Table_Boolean (g-sptabo.ads), Up: The GNAT Library + + `GNAT.Spitbol.Table_Integer' (`g-sptain.ads') + ============================================= + + A library level of instantiation of `GNAT.Spitbol.Patterns.Table' for + type `Standard.Integer', giving an implementation of maps from string + to integer values. + +  + File: gnat_rm.info, Node: GNAT.Spitbol.Table_VString (g-sptavs.ads), Next: GNAT.Table (g-table.ads), Prev: GNAT.Spitbol.Table_Integer (g-sptain.ads), Up: The GNAT Library + + `GNAT.Spitbol.Table_VString' (`g-sptavs.ads') + ============================================= + + A library level of instantiation of GNAT.Spitbol.Patterns.Table for a + variable length string type, giving an implementation of general maps + from strings to strings. + +  + File: gnat_rm.info, Node: GNAT.Table (g-table.ads), Next: GNAT.Task_Lock (g-tasloc.ads), Prev: GNAT.Spitbol.Table_VString (g-sptavs.ads), Up: The GNAT Library + + `GNAT.Table' (`g-table.ads') + ============================ + + A generic package providing a single dimension array abstraction where + the length of the array can be dynamically modified. + + This package provides a facility similar to that of GNAT.Dynamic_Tables, + except that this package declares a single instance of the table type, + while an instantiation of GNAT.Dynamic_Tables creates a type that can be + used to define dynamic instances of the table. + +  + File: gnat_rm.info, Node: GNAT.Task_Lock (g-tasloc.ads), Next: GNAT.Threads (g-thread.ads), Prev: GNAT.Table (g-table.ads), Up: The GNAT Library + + `GNAT.Task_Lock' (`g-tasloc.ads') + ================================= + + A very simple facility for locking and unlocking sections of code using + a single global task lock. Appropriate for use in situations where + contention between tasks is very rarely expected. + +  + File: gnat_rm.info, Node: GNAT.Threads (g-thread.ads), Next: GNAT.Traceback (g-traceb.ads), Prev: GNAT.Task_Lock (g-tasloc.ads), Up: The GNAT Library + + `GNAT.Threads' (`g-thread.ads') + =============================== + + Provides facilities for creating and destroying threads with explicit + calls. These threads are known to the GNAT run-time system. These + subprograms are exported C-convention procedures intended to be called + from foreign code. By using these primitives rather than directly + calling operating systems routines, compatibility with the Ada tasking + runt-time is provided. + +  + File: gnat_rm.info, Node: GNAT.Traceback (g-traceb.ads), Next: GNAT.Traceback.Symbolic (g-trasym.ads), Prev: GNAT.Threads (g-thread.ads), Up: The GNAT Library + + `GNAT.Traceback' (`g-traceb.ads') + ================================= + + Provides a facility for obtaining non-symbolic traceback information, + useful in various debugging situations. + +  + File: gnat_rm.info, Node: GNAT.Traceback.Symbolic (g-trasym.ads), Next: Interfaces.C.Extensions (i-cexten.ads), Prev: GNAT.Traceback (g-traceb.ads), Up: The GNAT Library + + `GNAT.Traceback.Symbolic' (`g-trasym.ads') + ========================================== + + Provides symbolic traceback information that includes the subprogram + name and line number information. + +  + File: gnat_rm.info, Node: Interfaces.C.Extensions (i-cexten.ads), Next: Interfaces.C.Streams (i-cstrea.ads), Prev: GNAT.Traceback.Symbolic (g-trasym.ads), Up: The GNAT Library + + `Interfaces.C.Extensions' (`i-cexten.ads') + ========================================== + + This package contains additional C-related definitions, intended for + use with either manually or automatically generated bindings to C + libraries. + +  + File: gnat_rm.info, Node: Interfaces.C.Streams (i-cstrea.ads), Next: Interfaces.CPP (i-cpp.ads), Prev: Interfaces.C.Extensions (i-cexten.ads), Up: The GNAT Library + + `Interfaces.C.Streams' (`i-cstrea.ads') + ======================================= + + This package is a binding for the most commonly used operations on C + streams. + +  + File: gnat_rm.info, Node: Interfaces.CPP (i-cpp.ads), Next: Interfaces.Os2lib (i-os2lib.ads), Prev: Interfaces.C.Streams (i-cstrea.ads), Up: The GNAT Library + + `Interfaces.CPP' (`i-cpp.ads') + ============================== + + This package provides facilities for use in interfacing to C++. It is + primarily intended to be used in connection with automated tools for + the generation of C++ interfaces. + +  + File: gnat_rm.info, Node: Interfaces.Os2lib (i-os2lib.ads), Next: Interfaces.Os2lib.Errors (i-os2err.ads), Prev: Interfaces.CPP (i-cpp.ads), Up: The GNAT Library + + `Interfaces.Os2lib' (`i-os2lib.ads') + ==================================== + + This package provides interface definitions to the OS/2 library. It is + a thin binding which is a direct translation of the various `' + files. + +  + File: gnat_rm.info, Node: Interfaces.Os2lib.Errors (i-os2err.ads), Next: Interfaces.Os2lib.Synchronization (i-os2syn.ads), Prev: Interfaces.Os2lib (i-os2lib.ads), Up: The GNAT Library + + `Interfaces.Os2lib.Errors' (`i-os2err.ads') + =========================================== + + This package provides definitions of the OS/2 error codes. + +  + File: gnat_rm.info, Node: Interfaces.Os2lib.Synchronization (i-os2syn.ads), Next: Interfaces.Os2lib.Threads (i-os2thr.ads), Prev: Interfaces.Os2lib.Errors (i-os2err.ads), Up: The GNAT Library + + `Interfaces.Os2lib.Synchronization' (`i-os2syn.ads') + ==================================================== + + This is a child package that provides definitions for interfacing to + the `OS/2' synchronization primitives. + +  + File: gnat_rm.info, Node: Interfaces.Os2lib.Threads (i-os2thr.ads), Next: Interfaces.Packed_Decimal (i-pacdec.ads), Prev: Interfaces.Os2lib.Synchronization (i-os2syn.ads), Up: The GNAT Library + + `Interfaces.Os2lib.Threads' (`i-os2thr.ads') + ============================================ + + This is a child package that provides definitions for interfacing to + the `OS/2' thread primitives. + +  + File: gnat_rm.info, Node: Interfaces.Packed_Decimal (i-pacdec.ads), Next: Interfaces.VxWorks (i-vxwork.ads), Prev: Interfaces.Os2lib.Threads (i-os2thr.ads), Up: The GNAT Library + + `Interfaces.Packed_Decimal' (`i-pacdec.ads') + ============================================ + + This package provides a set of routines for conversions to and from a + packed decimal format compatible with that used on IBM mainframes. + +  + File: gnat_rm.info, Node: Interfaces.VxWorks (i-vxwork.ads), Next: Interfaces.VxWorks.IO (i-vxwoio.ads), Prev: Interfaces.Packed_Decimal (i-pacdec.ads), Up: The GNAT Library + + `Interfaces.VxWorks' (`i-vxwork.ads') + ===================================== + + This package provides a limited binding to the VxWorks API. In + particular, it interfaces with the VxWorks hardware interrupt + facilities. + +  + File: gnat_rm.info, Node: Interfaces.VxWorks.IO (i-vxwoio.ads), Next: System.Address_Image (s-addima.ads), Prev: Interfaces.VxWorks (i-vxwork.ads), Up: The GNAT Library + + `Interfaces.VxWorks.IO' (`i-vxwoio.ads') + ======================================== + + This package provides a limited binding to the VxWorks' I/O API. In + particular, it provides procedures that enable the use of Get_Immediate + under VxWorks. + +  + File: gnat_rm.info, Node: System.Address_Image (s-addima.ads), Next: System.Assertions (s-assert.ads), Prev: Interfaces.VxWorks.IO (i-vxwoio.ads), Up: The GNAT Library + + `System.Address_Image' (`s-addima.ads') + ======================================= + + This function provides a useful debugging function that gives an + (implementation dependent) string which identifies an address. + +  + File: gnat_rm.info, Node: System.Assertions (s-assert.ads), Next: System.Partition_Interface (s-parint.ads), Prev: System.Address_Image (s-addima.ads), Up: The GNAT Library + + `System.Assertions' (`s-assert.ads') + ==================================== + + This package provides the declaration of the exception raised by an + run-time assertion failure, as well as the routine that is used + internally to raise this assertion. + +  + File: gnat_rm.info, Node: System.Partition_Interface (s-parint.ads), Next: System.Task_Info (s-tasinf.ads), Prev: System.Assertions (s-assert.ads), Up: The GNAT Library + + `System.Partition_Interface' (`s-parint.ads') + ============================================= + + This package provides facilities for partition interfacing. It is used + primarily in a distribution context when using Annex E with `GLADE'. + +  + File: gnat_rm.info, Node: System.Task_Info (s-tasinf.ads), Next: System.Wch_Cnv (s-wchcnv.ads), Prev: System.Partition_Interface (s-parint.ads), Up: The GNAT Library + + `System.Task_Info' (`s-tasinf.ads') + =================================== + + This package provides target dependent functionality that is used to + support the `Task_Info' pragma + +  + File: gnat_rm.info, Node: System.Wch_Cnv (s-wchcnv.ads), Next: System.Wch_Con (s-wchcon.ads), Prev: System.Task_Info (s-tasinf.ads), Up: The GNAT Library + + `System.Wch_Cnv' (`s-wchcnv.ads') + ================================= + + This package provides routines for converting between wide characters + and a representation as a value of type `Standard.String', using a + specified wide character encoding method. It uses definitions in + package `System.Wch_Con'. + +  + File: gnat_rm.info, Node: System.Wch_Con (s-wchcon.ads), Prev: System.Wch_Cnv (s-wchcnv.ads), Up: The GNAT Library + + `System.Wch_Con' (`s-wchcon.ads') + ================================= + + This package provides definitions and descriptions of the various + methods used for encoding wide characters in ordinary strings. These + definitions are used by the package `System.Wch_Cnv'. + +  + File: gnat_rm.info, Node: Interfacing to Other Languages, Next: Machine Code Insertions, Prev: The GNAT Library, Up: Top + + Interfacing to Other Languages + ****************************** + + The facilities in annex B of the Ada 95 Reference Manual are fully + implemented in GNAT, and in addition, a full interface to C++ is + provided. + + * Menu: + + * Interfacing to C:: + * Interfacing to C++:: + * Interfacing to COBOL:: + * Interfacing to Fortran:: + * Interfacing to non-GNAT Ada code:: + +  + File: gnat_rm.info, Node: Interfacing to C, Next: Interfacing to C++, Up: Interfacing to Other Languages + + Interfacing to C + ================ + + Interfacing to C with GNAT can use one of two approaches: + + 1. The types in the package `Interfaces.C' may be used. + + 2. Standard Ada types may be used directly. This may be less + portable to other compilers, but will work on all GNAT compilers, + which guarantee correspondence between the C and Ada types. + + Pragma `Convention C' maybe applied to Ada types, but mostly has no + effect, since this is the default. The following table shows the + correspondence between Ada scalar types and the corresponding C types. + + `Integer' + `int' + + `Short_Integer' + `short' + + `Short_Short_Integer' + `signed char' + + `Long_Integer' + `long' + + `Long_Long_Integer' + `long long' + + `Short_Float' + `float' + + `Float' + `float' + + `Long_Float' + `double' + + `Long_Long_Float' + This is the longest floating-point type supported by the hardware. + + * Ada enumeration types map to C enumeration types directly if pragma + `Convention C' is specified, which causes them to have int length. + Without pragma `Convention C', Ada enumeration types map to 8, + 16, or 32 bits (i.e. C types `signed char', `short', `int', + respectively) depending on the number of values passed. This is + the only case in which pragma `Convention C' affects the + representation of an Ada type. + + * Ada access types map to C pointers, except for the case of + pointers to unconstrained types in Ada, which have no direct C + equivalent. + + * Ada arrays map directly to C arrays. + + * Ada records map directly to C structures. + + * Packed Ada records map to C structures where all members are bit + fields of the length corresponding to the `TYPE'Size' value in Ada. + +  + File: gnat_rm.info, Node: Interfacing to C++, Next: Interfacing to COBOL, Prev: Interfacing to C, Up: Interfacing to Other Languages + + Interfacing to C++ + ================== + + The interface to C++ makes use of the following pragmas, which are + primarily intended to be constructed automatically using a binding + generator tool, although it is possible to construct them by hand. Ada + Core Technologies does not currently supply a suitable binding + generator tool. + + Using these pragmas it is possible to achieve complete + inter-operability between Ada tagged types and C class definitions. + See *Note Implementation Defined Pragmas:: for more details. + + `pragma CPP_Class ([Entity =>] LOCAL_NAME)' + The argument denotes an entity in the current declarative region + that is declared as a tagged or untagged record type. It + indicates that the type corresponds to an externally declared C++ + class type, and is to be laid out the same way that C++ would lay + out the type. + + `pragma CPP_Constructor ([Entity =>] LOCAL_NAME)' + This pragma identifies an imported function (imported in the usual + way with pragma `Import') as corresponding to a C++ constructor. + + `pragma CPP_Vtable ...' + One `CPP_Vtable' pragma can be present for each component of type + `CPP.Interfaces.Vtable_Ptr' in a record to which pragma `CPP_Class' + applies. + +  + File: gnat_rm.info, Node: Interfacing to COBOL, Next: Interfacing to Fortran, Prev: Interfacing to C++, Up: Interfacing to Other Languages + + Interfacing to COBOL + ==================== + + Interfacing to COBOL is achieved as described in section B.4 of the Ada + 95 reference manual. + +  + File: gnat_rm.info, Node: Interfacing to Fortran, Next: Interfacing to non-GNAT Ada code, Prev: Interfacing to COBOL, Up: Interfacing to Other Languages + + Interfacing to Fortran + ====================== + + Interfacing to Fortran is achieved as described in section B.5 of the + reference manual. The pragma `Convention Fortran', applied to a + multi-dimensional array causes the array to be stored in column-major + order as required for convenient interface to Fortran. + +  + File: gnat_rm.info, Node: Interfacing to non-GNAT Ada code, Prev: Interfacing to Fortran, Up: Interfacing to Other Languages + + Interfacing to non-GNAT Ada code + ================================ + + It is possible to specify the convention `Ada' in a pragma `Import' + or pragma `Export'. However this refers to the calling conventions used + by GNAT, which may or may not be similar enough to those used by some + other Ada 83 or Ada 95 compiler to allow interoperation. + + If arguments types are kept simple, and if the foreign compiler + generally follows system calling conventions, then it may be possible + to integrate files compiled by other Ada compilers, provided that the + elaboration issues are adequately addressed (for example by eliminating + the need for any load time elaboration). + + In particular, GNAT running on VMS is designed to be highly + compatible with the DEC Ada 83 compiler, so this is one case in which + it is possible to import foreign units of this type, provided that the + data items passed are restricted to simple scalar values or simple + record types without variants, or simple array types with fixed bounds. + +  + File: gnat_rm.info, Node: Machine Code Insertions, Next: GNAT Implementation of Tasking, Prev: Interfacing to Other Languages, Up: Top + + Machine Code Insertions + *********************** + + Package `Machine_Code' provides machine code support as described in + the Ada 95 Reference Manual in two separate forms: + * Machine code statements, consisting of qualified expressions that + fit the requirements of RM section 13.8. + + * An intrinsic callable procedure, providing an alternative + mechanism of including machine instructions in a subprogram. + + The two features are similar, and both closely related to the + mechanism provided by the asm instruction in the GNU C compiler. Full + understanding and use of the facilities in this package requires + understanding the asm instruction as described in `Using and Porting + the GNU Compiler Collection (GCC)' by Richard Stallman. Calls to the + function `Asm' and the procedure `Asm' have identical semantic + restrictions and effects as described below. Both are provided so that + the procedure call can be used as a statement, and the function call + can be used to form a code_statement. + + The first example given in the GCC documentation is the C `asm' + instruction: + asm ("fsinx %1 %0" : "=f" (result) : "f" (angle)); + + The equivalent can be written for GNAT as: + + Asm ("fsinx %1 %0", + My_Float'Asm_Output ("=f", result), + My_Float'Asm_Input ("f", angle)); + + The first argument to `Asm' is the assembler template, and is + identical to what is used in GNU C. This string must be a static + expression. The second argument is the output operand list. It is + either a single `Asm_Output' attribute reference, or a list of such + references enclosed in parentheses (technically an array aggregate of + such references). + + The `Asm_Output' attribute denotes a function that takes two + parameters. The first is a string, the second is the name of a variable + of the type designated by the attribute prefix. The first (string) + argument is required to be a static expression and designates the + constraint for the parameter (e.g. what kind of register is required). + The second argument is the variable to be updated with the result. The + possible values for constraint are the same as those used in the RTL, + and are dependent on the configuration file used to build the GCC back + end. If there are no output operands, then this argument may either be + omitted, or explicitly given as `No_Output_Operands'. + + The second argument of `MY_FLOAT'Asm_Output' functions as though it + were an `out' parameter, which is a little curious, but all names have + the form of expressions, so there is no syntactic irregularity, even + though normally functions would not be permitted `out' parameters. The + third argument is the list of input operands. It is either a single + `Asm_Input' attribute reference, or a list of such references enclosed + in parentheses (technically an array aggregate of such references). + + The `Asm_Input' attribute denotes a function that takes two + parameters. The first is a string, the second is an expression of the + type designated by the prefix. The first (string) argument is required + to be a static expression, and is the constraint for the parameter, + (e.g. what kind of register is required). The second argument is the + value to be used as the input argument. The possible values for the + constant are the same as those used in the RTL, and are dependent on + the configuration file used to built the GCC back end. + + If there are no input operands, this argument may either be omitted, + or explicitly given as `No_Input_Operands'. The fourth argument, not + present in the above example, is a list of register names, called the + "clobber" argument. This argument, if given, must be a static string + expression, and is a space or comma separated list of names of registers + that must be considered destroyed as a result of the `Asm' call. If + this argument is the null string (the default value), then the code + generator assumes that no additional registers are destroyed. + + The fifth argument, not present in the above example, called the + "volatile" argument, is by default `False'. It can be set to the + literal value `True' to indicate to the code generator that all + optimizations with respect to the instruction specified should be + suppressed, and that in particular, for an instruction that has outputs, + the instruction will still be generated, even if none of the outputs are + used. See the full description in the GCC manual for further details. + + The `Asm' subprograms may be used in two ways. First the procedure + forms can be used anywhere a procedure call would be valid, and + correspond to what the RM calls "intrinsic" routines. Such calls can + be used to intersperse machine instructions with other Ada statements. + Second, the function forms, which return a dummy value of the limited + private type `Asm_Insn', can be used in code statements, and indeed + this is the only context where such calls are allowed. Code statements + appear as aggregates of the form: + + Asm_Insn'(Asm (...)); + Asm_Insn'(Asm_Volatile (...)); + + In accordance with RM rules, such code statements are allowed only + within subprograms whose entire body consists of such statements. It is + not permissible to intermix such statements with other Ada statements. + + Typically the form using intrinsic procedure calls is more convenient + and more flexible. The code statement form is provided to meet the RM + suggestion that such a facility should be made available. The following + is the exact syntax of the call to `Asm' (of course if named notation is + used, the arguments may be given in arbitrary order, following the + normal rules for use of positional and named arguments) + + ASM_CALL ::= Asm ( + [Template =>] static_string_EXPRESSION + [,[Outputs =>] OUTPUT_OPERAND_LIST ] + [,[Inputs =>] INPUT_OPERAND_LIST ] + [,[Clobber =>] static_string_EXPRESSION ] + [,[Volatile =>] static_boolean_EXPRESSION] ) + OUTPUT_OPERAND_LIST ::= + No_Output_Operands + | OUTPUT_OPERAND_ATTRIBUTE + | (OUTPUT_OPERAND_ATTRIBUTE {,OUTPUT_OPERAND_ATTRIBUTE}) + OUTPUT_OPERAND_ATTRIBUTE ::= + SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME) + INPUT_OPERAND_LIST ::= + No_Input_Operands + | INPUT_OPERAND_ATTRIBUTE + | (INPUT_OPERAND_ATTRIBUTE {,INPUT_OPERAND_ATTRIBUTE}) + INPUT_OPERAND_ATTRIBUTE ::= + SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION) + +  + File: gnat_rm.info, Node: GNAT Implementation of Tasking, Next: Code generation for array aggregates, Prev: Machine Code Insertions, Up: Top + + GNAT Implementation of Tasking + ****************************** + + * Menu: + + * Mapping Ada Tasks onto the Underlying Kernel Threads:: + * Ensuring Compliance with the Real-Time Annex:: + +  + File: gnat_rm.info, Node: Mapping Ada Tasks onto the Underlying Kernel Threads, Next: Ensuring Compliance with the Real-Time Annex, Up: GNAT Implementation of Tasking + + Mapping Ada Tasks onto the Underlying Kernel Threads + ==================================================== + + GNAT run-time system comprises two layers: + + * GNARL (GNAT Run-time Layer) + + * GNULL (GNAT Low-level Library) + + In GNAT, Ada's tasking services rely on a platform and OS independent + layer known as GNARL. This code is responsible for implementing the + correct semantics of Ada's task creation, rendezvous, protected + operations etc. + + GNARL decomposes Ada's tasking semantics into simpler lower level + operations such as create a thread, set the priority of a thread, + yield, create a lock, lock/unlock, etc. The spec for these low-level + operations constitutes GNULLI, the GNULL Interface. This interface is + directly inspired from the POSIX real-time API. + + If the underlying executive or OS implements the POSIX standard + faithfully, the GNULL Interface maps as is to the services offered by + the underlying kernel. Otherwise, some target dependent glue code maps + the services offered by the underlying kernel to the semantics expected + by GNARL. + + Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) + the key point is that each Ada task is mapped on a thread in the + underlying kernel. For example, in the case of VxWorks, one Ada task = + one VxWorks task. + + In addition Ada task priorities map onto the underlying thread + priorities. Mapping Ada tasks onto the underlying kernel threads has + several advantages: + + 1. The underlying scheduler is used to schedule the Ada tasks. This + makes Ada tasks as efficient as kernel threads from a scheduling + standpoint. + + 2. Interaction with code written in C containing threads is eased + since at the lowest level Ada tasks and C threads map onto the same + underlying kernel concept. + + 3. When an Ada task is blocked during I/O the remaining Ada tasks are + able to proceed. + + 4. On multi-processor systems Ada Tasks can execute in parallel. + +  + File: gnat_rm.info, Node: Ensuring Compliance with the Real-Time Annex, Prev: Mapping Ada Tasks onto the Underlying Kernel Threads, Up: GNAT Implementation of Tasking + + Ensuring Compliance with the Real-Time Annex + ============================================ + + The reader will be quick to notice that while mapping Ada tasks onto + the underlying threads has significant advantages, it does create some + complications when it comes to respecting the scheduling semantics + specified in the real-time annex (Annex D). + + For instance Annex D requires that for the FIFO_Within_Priorities + scheduling policy we have: + + When the active priority of a ready task that is not running + changes, or the setting of its base priority takes effect, the + task is removed from the ready queue for its old active priority + and is added at the tail of the ready queue for its new active + priority, except in the case where the active priority is lowered + due to the loss of inherited priority, in which case the task is + added at the head of the ready queue for its new active priority. + + While most kernels do put tasks at the end of the priority queue when + a task changes its priority, (which respects the main + FIFO_Within_Priorities requirement), almost none keep a thread at the + beginning of its priority queue when its priority drops from the loss + of inherited priority. + + As a result most vendors have provided incomplete Annex D + implementations. + + The GNAT run-time, has a nice cooperative solution to this problem + which ensures that accurate FIFO_Within_Priorities semantics are + respected. + + The principle is as follows. When an Ada task T is about to start + running, it checks whether some other Ada task R with the same priority + as T has been suspended due to the loss of priority inheritance. If + this is the case, T yields and is placed at the end of its priority + queue. When R arrives at the front of the queue it executes. + + Note that this simple scheme preserves the relative order of the + tasks that were ready to execute in the priority queue where R has been + placed at the end. + +  + File: gnat_rm.info, Node: Code generation for array aggregates, Next: Specialized Needs Annexes, Prev: GNAT Implementation of Tasking, Up: Top + + Code generation for array aggregates + ************************************ + + * Menu: + + * Static constant aggregates with static bounds:: + * Constant aggregates with an unconstrained nominal types:: + * Aggregates with static bounds:: + * Aggregates with non-static bounds:: + * Aggregates in assignments statements:: + + Aggregate have a rich syntax and allow the user to specify the + values of complex data structures by means of a single construct. As a + result, the code generated for aggregates can be quite complex and + involve loops, case statements and multiple assignments. In the + simplest cases, however, the compiler will recognize aggregates whose + components and constraints are fully static, and in those cases the + compiler will generate little or no executable code. The following is + an outline of the code that GNAT generates for various aggregate + constructs. For further details, the user will find it useful to + examine the output produced by the -gnatG flag to see the expanded + source that is input to the code generator. The user will also want to + examine the assembly code generated at various levels of optimization. + + The code generated for aggregates depends on the context, the + component values, and the type. In the context of an object + declaration the code generated is generally simpler than in the case of + an assignment. As a general rule, static component values and static + subtypes also lead to simpler code. + +  + File: gnat_rm.info, Node: Static constant aggregates with static bounds, Next: Constant aggregates with an unconstrained nominal types, Up: Code generation for array aggregates + + Static constant aggregates with static bounds + ============================================= + + For the declarations: + type One_Dim is array (1..10) of integer; + ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0); + + GNAT generates no executable code: the constant ar0 is placed in + static memory. The same is true for constant aggregates with named + associations: + + Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1); + Cr3 : constant One_Dim := (others => 7777); + + The same is true for multidimensional constant arrays such as: + + type two_dim is array (1..3, 1..3) of integer; + Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1)); + + The same is true for arrays of one-dimensional arrays: the following + are static: + + type ar1b is array (1..3) of boolean; + type ar_ar is array (1..3) of ar1b; + None : constant ar1b := (others => false); -- fully static + None2 : constant ar_ar := (1..3 => None); -- fully static + + However, for multidimensional aggregates with named associations, + GNAT will generate assignments and loops, even if all associations are + static. The following two declarations generate a loop for the first + dimension, and individual component assignments for the second + dimension: + + Zero1: constant two_dim := (1..3 => (1..3 => 0)); + Zero2: constant two_dim := (others => (others => 0)); + +  + File: gnat_rm.info, Node: Constant aggregates with an unconstrained nominal types, Next: Aggregates with static bounds, Prev: Static constant aggregates with static bounds, Up: Code generation for array aggregates + + Constant aggregates with an unconstrained nominal types + ======================================================= + + In such cases the aggregate itself establishes the subtype, so that + associations with `others' cannot be used. GNAT determines the bounds + for the actual subtype of the aggregate, and allocates the aggregate + statically as well. No code is generated for the following: + + type One_Unc is array (natural range <>) of integer; + Cr_Unc : constant One_Unc := (12,24,36); + +  + File: gnat_rm.info, Node: Aggregates with static bounds, Next: Aggregates with non-static bounds, Prev: Constant aggregates with an unconstrained nominal types, Up: Code generation for array aggregates + + Aggregates with static bounds + ============================= + + In all previous examples the aggregate was the initial (and + immutable) value of a constant. If the aggregate initializes a + variable, then code is generated for it as a combination of individual + assignments and loops over the target object. The declarations + + Cr_Var1 : One_Dim := (2, 5, 7, 11); + Cr_Var2 : One_Dim := (others > -1); + + generate the equivalent of + + Cr_Var1 (1) := 2; + Cr_Var1 (2) := 3; + Cr_Var1 (3) := 5; + Cr_Var1 (4) := 11; + + for I in Cr_Var2'range loop + Cr_Var2 (I) := =-1; + end loop; + +  + File: gnat_rm.info, Node: Aggregates with non-static bounds, Next: Aggregates in assignments statements, Prev: Aggregates with static bounds, Up: Code generation for array aggregates + + Aggregates with non-static bounds + ================================= + + If the bounds of the aggregate are not statically compatible with + the bounds of the nominal subtype of the target, then constraint + checks have to be generated on the bounds. For a multidimensional + array, constraint checks may have to be applied to sub-arrays + individually, if they do not have statically compatible subtypes. + +  + File: gnat_rm.info, Node: Aggregates in assignments statements, Prev: Aggregates with non-static bounds, Up: Code generation for array aggregates + + Aggregates in assignments statements + ==================================== + + In general, aggregate assignment requires the construction of a + temporary, and a copy from the temporary to the target of the + assignment. This is because it is not always possible to convert the + assignment into a series of individual component assignments. For + example, consider the simple case: + + A := (A(2), A(1)); + + This cannot be converted into: + + A(1) := A(2); + A(2) := A(1); + + So the aggregate has to be built first in a separate location, and + then copied into the target. GNAT recognizes simple cases where this + intermediate step is not required, and the assignments can be performed + in place, directly into the target. The following sufficient criteria + are applied: + + 1. The bounds of the aggregate are static, and the associations are + static. + + 2. The components of the aggregate are static constants, names of + simple variables that are not renamings, or expressions not + involving indexed components whose operands obey these rules. + + If any of these conditions are violated, the aggregate will be built + in a temporary (created either by the front-end or the code generator) + and then that temporary will be copied onto the target. + +  + File: gnat_rm.info, Node: Specialized Needs Annexes, Next: Compatibility Guide, Prev: Code generation for array aggregates, Up: Top + + Specialized Needs Annexes + ************************* + + Ada 95 defines a number of specialized needs annexes, which are not + required in all implementations. However, as described in this chapter, + GNAT implements all of these special needs annexes: + + Systems Programming (Annex C) + The Systems Programming Annex is fully implemented. + + Real-Time Systems (Annex D) + The Real-Time Systems Annex is fully implemented. + + Distributed Systems (Annex E) + Stub generation is fully implemented in the GNAT compiler. In + addition, a complete compatible PCS is available as part of the + GLADE system, a separate product. When the two products are used + in conjunction, this annex is fully implemented. + + Information Systems (Annex F) + The Information Systems annex is fully implemented. + + Numerics (Annex G) + The Numerics Annex is fully implemented. + + Safety and Security (Annex H) + The Safety and Security annex is fully implemented. + +  + File: gnat_rm.info, Node: Compatibility Guide, Next: GNU Free Documentation License, Prev: Specialized Needs Annexes, Up: Top + + Compatibility Guide + ******************* + + This chapter contains sections that describe compatibility issues + between GNAT and other Ada 83 and Ada 95 compilation systems, to aid in + porting applications developed in other Ada environments. + + * Menu: + + * Compatibility with Ada 83:: + * Compatibility with DEC Ada 83:: + * Compatibility with Other Ada 95 Systems:: + * Representation Clauses:: + +  + File: gnat_rm.info, Node: Compatibility with Ada 83, Next: Compatibility with DEC Ada 83, Up: Compatibility Guide + + Compatibility with Ada 83 + ========================= + + Ada 95 is designed to be highly upwards compatible with Ada 83. In + particular, the design intention is that the difficulties associated + with moving from Ada 83 to Ada 95 should be no greater than those that + occur when moving from one Ada 83 system to another. + + However, there are a number of points at which there are minor + incompatibilities. The Ada 95 Annotated Reference Manual contains full + details of these issues, and should be consulted for a complete + treatment. In practice the following are the most likely issues to be + encountered. + + Character range + The range of `Standard.Character' is now the full 256 characters + of Latin-1, whereas in most Ada 83 implementations it was + restricted to 128 characters. This may show up as compile time or + runtime errors. The desirable fix is to adapt the program to + accommodate the full character set, but in some cases it may be + convenient to define a subtype or derived type of Character that + covers only the restricted range. + + New reserved words + The identifiers `abstract', `aliased', `protected', `requeue', + `tagged', and `until' are reserved in Ada 95. Existing Ada 83 + code using any of these identifiers must be edited to use some + alternative name. + + Freezing rules + The rules in Ada 95 are slightly different with regard to the + point at which entities are frozen, and representation pragmas and + clauses are not permitted past the freeze point. This shows up + most typically in the form of an error message complaining that a + representation item appears too late, and the appropriate + corrective action is to move the item nearer to the declaration of + the entity to which it refers. + + A particular case is that representation pragmas (including the + extended DEC Ada 83 compatibility pragmas such as + `Export_Procedure'), cannot be applied to a subprogram body. If + necessary, a separate subprogram declaration must be introduced to + which the pragma can be applied. + + Optional bodies for library packages + In Ada 83, a package that did not require a package body was + nevertheless allowed to have one. This lead to certain surprises + in compiling large systems (situations in which the body could be + unexpectedly ignored). In Ada 95, if a package does not require a + body then it is not permitted to have a body. To fix this + problem, simply remove a redundant body if it is empty, or, if it + is non-empty, introduce a dummy declaration into the spec that + makes the body required. One approach is to add a private part to + the package declaration (if necessary), and define a parameterless + procedure called Requires_Body, which must then be given a dummy + procedure body in the package body, which then becomes required. + + `Numeric_Error' is now the same as `Constraint_Error' + In Ada 95, the exception `Numeric_Error' is a renaming of + `Constraint_Error'. This means that it is illegal to have + separate exception handlers for the two exceptions. The fix is + simply to remove the handler for the `Numeric_Error' case (since + even in Ada 83, a compiler was free to raise `Constraint_Error' in + place of `Numeric_Error' in all cases). + + Indefinite subtypes in generics + In Ada 83, it was permissible to pass an indefinite type (e.g. + `String') as the actual for a generic formal private type, but + then the instantiation would be illegal if there were any + instances of declarations of variables of this type in the generic + body. In Ada 95, to avoid this clear violation of the contract + model, the generic declaration clearly indicates whether or not + such instantiations are permitted. If a generic formal parameter + has explicit unknown discriminants, indicated by using `(<>)' + after the type name, then it can be instantiated with indefinite + types, but no variables can be declared of this type. Any attempt + to declare a variable will result in an illegality at the time the + generic is declared. If the `(<>)' notation is not used, then it + is illegal to instantiate the generic with an indefinite type. + This will show up as a compile time error, and the fix is usually + simply to add the `(<>)' to the generic declaration. + + All implementations of GNAT provide a switch that causes GNAT to + operate in Ada 83 mode. In this mode, some but not all compatibility + problems of the type described above are handled automatically. For + example, the new Ada 95 protected keywords are not recognized in this + mode. However, in practice, it is usually advisable to make the + necessary modifications to the program to remove the need for using + this switch. + +  + File: gnat_rm.info, Node: Compatibility with Other Ada 95 Systems, Next: Representation Clauses, Prev: Compatibility with DEC Ada 83, Up: Compatibility Guide + + Compatibility with Other Ada 95 Systems + ======================================= + + Providing that programs avoid the use of implementation dependent and + implementation defined features of Ada 95, as documented in the Ada 95 + reference manual, there should be a high degree of portability between + GNAT and other Ada 95 systems. The following are specific items which + have proved troublesome in moving GNAT programs to other Ada 95 + compilers, but do not affect porting code to GNAT. + + Ada 83 Pragmas and Attributes + Ada 95 compilers are allowed, but not required, to implement the + missing Ada 83 pragmas and attributes that are no longer defined + in Ada 95. GNAT implements all such pragmas and attributes, + eliminating this as a compatibility concern, but some other Ada 95 + compilers reject these pragmas and attributes. + + Special-needs Annexes + GNAT implements the full set of special needs annexes. At the + current time, it is the only Ada 95 compiler to do so. This means + that programs making use of these features may not be portable to + other Ada 95 compilation systems. + + Representation Clauses + Some other Ada 95 compilers implement only the minimal set of + representation clauses required by the Ada 95 reference manual. + GNAT goes far beyond this minimal set, as described in the next + section. + +  + File: gnat_rm.info, Node: Representation Clauses, Prev: Compatibility with Other Ada 95 Systems, Up: Compatibility Guide + + Representation Clauses + ====================== + + The Ada 83 reference manual was quite vague in describing both the + minimal required implementation of representation clauses, and also + their precise effects. The Ada 95 reference manual is much more + explicit, but the minimal set of capabilities required in Ada 95 is + quite limited. + + GNAT implements the full required set of capabilities described in + the Ada 95 reference manual, but also goes much beyond this, and in + particular an effort has been made to be compatible with existing Ada + 83 usage to the greatest extent possible. + + A few cases exist in which Ada 83 compiler behavior is incompatible + with requirements in the Ada 95 reference manual. These are instances + of intentional or accidental dependence on specific implementation + dependent characteristics of these Ada 83 compilers. The following is + a list of the cases most likely to arise in existing legacy Ada 83 code. + + Implicit Packing + Some Ada 83 compilers allowed a Size specification to cause + implicit packing of an array or record. This could cause + expensive implicit conversions for change of representation in the + presence of derived types, and the Ada design intends to avoid + this possibility. Subsequent AI's were issued to make it clear + that such implicit change of representation in response to a Size + clause is inadvisable, and this recommendation is represented + explicitly in the Ada 95 RM as implementation advice that is + followed by GNAT. The problem will show up as an error message + rejecting the size clause. The fix is simply to provide the + explicit pragma `Pack', or for more fine tuned control, provide a + Component_Size clause. + + Meaning of Size Attribute + The Size attribute in Ada 95 for discrete types is defined as + being the minimal number of bits required to hold values of the + type. For example, on a 32-bit machine, the size of Natural will + typically be 31 and not 32 (since no sign bit is required). Some + Ada 83 compilers gave 31, and some 32 in this situation. This + problem will usually show up as a compile time error, but not + always. It is a good idea to check all uses of the 'Size + attribute when porting Ada 83 code. The GNAT specific attribute + Object_Size can provide a useful way of duplicating the behavior of + some Ada 83 compiler systems. + + Size of Access Types + A common assumption in Ada 83 code is that an access type is in + fact a pointer, and that therefore it will be the same size as a + System.Address value. This assumption is true for GNAT in most + cases with one exception. For the case of a pointer to an + unconstrained array type (where the bounds may vary from one value + of the access type to another), the default is to use a "fat + pointer", which is represented as two separate pointers, one to + the bounds, and one to the array. This representation has a + number of advantages, including improved efficiency. However, it + may cause some difficulties in porting existing Ada 83 code which + makes the assumption that, for example, pointers fit in 32 bits on + a machine with 32-bit addressing. + + To get around this problem, GNAT also permits the use of "thin + pointers" for access types in this case (where the designated type + is an unconstrained array type). These thin pointers are indeed + the same size as a System.Address value. To specify a thin + pointer, use a size clause for the type, for example: + + type X is access all String; + for X'Size use Standard'Address_Size; + + which will cause the type X to be represented using a single + pointer. When using this representation, the bounds are right + behind the array. This representation is slightly less efficient, + and does not allow quite such flexibility in the use of foreign + pointers or in using the Unrestricted_Access attribute to create + pointers to non-aliased objects. But for any standard portable + use of the access type it will work in a functionally correct + manner and allow porting of existing code. Note that another way + of forcing a thin pointer representation is to use a component + size clause for the element size in an array, or a record + representation clause for an access field in a record. + +  + File: gnat_rm.info, Node: Compatibility with DEC Ada 83, Next: Compatibility with Other Ada 95 Systems, Prev: Compatibility with Ada 83, Up: Compatibility Guide + + Compatibility with DEC Ada 83 + ============================= + + The VMS version of GNAT fully implements all the pragmas and attributes + provided by DEC Ada 83, as well as providing the standard DEC Ada 83 + libraries, including Starlet. In addition, data layouts and parameter + passing conventions are highly compatible. This means that porting + existing DEC Ada 83 code to GNAT in VMS systems should be easier than + most other porting efforts. The following are some of the most + significant differences between GNAT and DEC Ada 83. + + Default floating-point representation + In GNAT, the default floating-point format is IEEE, whereas in DEC + Ada 83, it is VMS format. GNAT does implement the necessary + pragmas (Long_Float, Float_Representation) for changing this + default. + + System + The package System in GNAT exactly corresponds to the definition + in the Ada 95 reference manual, which means that it excludes many + of the DEC Ada 83 extensions. However, a separate package Aux_DEC + is provided that contains the additional definitions, and a + special pragma, Extend_System allows this package to be treated + transparently as an extension of package System. + + To_Address + The definitions provided by Aux_DEC are exactly compatible with + those in the DEC Ada 83 version of System, with one exception. + DEC Ada provides the following declarations: + + TO_ADDRESS(INTEGER) + TO_ADDRESS(UNSIGNED_LONGWORD) + TO_ADDRESS(universal_integer) + + The version of TO_ADDRESS taking a universal integer argument is + in fact an extension to Ada 83 not strictly compatible with the + reference manual. In GNAT, we are constrained to be exactly + compatible with the standard, and this means we cannot provide + this capability. In DEC Ada 83, the point of this definition is + to deal with a call like: + + TO_ADDRESS (16#12777#); + + Normally, according to the Ada 83 standard, one would expect this + to be ambiguous, since it matches both the INTEGER and + UNSIGNED_LONGWORD forms of TO_ADDRESS. However, in DEC Ada 83, + there is no ambiguity, since the definition using + universal_integer takes precedence. + + In GNAT, since the version with universal_integer cannot be + supplied, it is not possible to be 100% compatible. Since there + are many programs using numeric constants for the argument to + TO_ADDRESS, the decision in GNAT was to change the name of the + function in the UNSIGNED_LONGWORD case, so the declarations + provided in the GNAT version of AUX_Dec are: + + function To_Address (X : Integer) return Address; + pragma Pure_Function (To_Address); + + function To_Address_Long (X : Unsigned_Longword) + return Address; + pragma Pure_Function (To_Address_Long); + + This means that programs using TO_ADDRESS for UNSIGNED_LONGWORD + must change the name to TO_ADDRESS_LONG. + + Task_Id values + The Task_Id values assigned will be different in the two systems, + and GNAT does not provide a specified value for the Task_Id of the + environment task, which in GNAT is treated like any other declared + task. + + For full details on these and other less significant compatibility + issues, see appendix E of the Digital publication entitled `DEC Ada, + Technical Overview and Comparison on DIGITAL Platforms'. + + For GNAT running on other than VMS systems, all the DEC Ada 83 + pragmas and attributes are recognized, although only a subset of them + can sensibly be implemented. The description of pragmas in this + reference manual indicates whether or not they are applicable to + non-VMS systems. + +  + File: gnat_rm.info, Node: GNU Free Documentation License, Next: Index, Prev: Compatibility Guide, Up: Top + + GNU Free Documentation License + ****************************** + + Version 1.2, November 2002 + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. + We recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it + can be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You + accept the license if you copy, modify or distribute the work in a + way requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in + the notice that says that the Document is released under this + License. If a section does not fit the above definition of + Secondary then it is not allowed to be designated as Invariant. + The Document may contain zero Invariant Sections. If the Document + does not identify any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images + composed of pixels) generic paint programs or (for drawings) some + widely available drawing editor, and that is suitable for input to + text formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in an + otherwise Transparent file format whose markup, or absence of + markup, has been arranged to thwart or discourage subsequent + modification by readers is not Transparent. An image format is + not Transparent if used for any substantial amount of text. A + copy that is not "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and + standard-conforming simple HTML, PostScript or PDF designed for + human modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats that + can be read and edited only by proprietary word processors, SGML or + XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML, PostScript or PDF + produced by some word processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow + the conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the + title equally prominent and visible. You may add other material + on the covers in addition. Copying with changes limited to the + covers, as long as they preserve the title of the Document and + satisfy these conditions, can be treated as verbatim copying in + other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a computer-network location from + which the general network-using public has access to download + using public-standard network protocols a complete Transparent + copy of the Document, free of added material. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of + copies, to give them a chance to provide you with an updated + version of the Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with + the Modified Version filling the role of the Document, thus + licensing distribution and modification of the Modified Version to + whoever possesses a copy of it. In addition, you must do these + things in the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of + previous versions (which should, if there were any, be listed + in the History section of the Document). You may use the + same title as a previous version if the original publisher of + that version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on + the Title Page. If there is no section Entitled "History" in + the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, + then add an item describing the Modified Version as stated in + the previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in + the "History" section. You may omit a network location for a + work that was published at least four years before the + Document itself, or if the original publisher of the version + it refers to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the + section all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section + titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end + of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the + documents in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow + this License in all other respects regarding verbatim copying of + that document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warrany Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided for under this License. Any other + attempt to copy, modify, sublicense or distribute the Document is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + `http://www.gnu.org/copyleft/'. + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If + the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. + + ADDENDUM: How to use this License for your documents + ==================================================== + + To use this License in a document you have written, include a copy of + the License in the document and put the following copyright and license + notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover + Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other + combination of the three, merge those two alternatives to suit the + situation. + + If your document contains nontrivial examples of program code, we + recommend releasing these examples in parallel under your choice of + free software license, such as the GNU General Public License, to + permit their use in free software. + +  + File: gnat_rm.info, Node: Index, Prev: GNU Free Documentation License, Up: Top + + Index + ***** + + * Menu: + + * -gnatR switch: Determining the Representations chosen by GNAT. + * Abort_Defer: Implementation Defined Pragmas. + * Abort_Signal: Implementation Defined Attributes. + * Access, unrestricted: Implementation Defined Attributes. + * Accuracy requirements: Implementation Advice. + * Accuracy, complex arithmetic: Implementation Advice. + * Ada 83 attributes: Implementation Defined Attributes. + * Ada 95 ISO/ANSI Standard: What This Reference Manual Contains. + * Ada.Characters.Handling: Implementation Advice. + * Ada.Characters.Latin_9 (a-chlat9.ads): Ada.Characters.Latin_9 (a-chlat9.ads). + * Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada.Characters.Wide_Latin_1 (a-cwila1.ads). + * Ada.Characters.Wide_Latin_9 (a-cwila1.ads): Ada.Characters.Wide_Latin_9 (a-cwila9.ads). + * Ada.Command_Line.Remove (a-colire.ads): Ada.Command_Line.Remove (a-colire.ads). + * Ada.Direct_IO.C_Streams (a-diocst.ads): Ada.Direct_IO.C_Streams (a-diocst.ads). + * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads). + * Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada.Sequential_IO.C_Streams (a-siocst.ads). + * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads). + * Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada.Strings.Unbounded.Text_IO (a-suteio.ads). + * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads). + * Ada.Text_IO.C_Streams (a-tiocst.ads): Ada.Text_IO.C_Streams (a-tiocst.ads). + * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads). + * Ada_83: Implementation Defined Pragmas. + * Ada_95: Implementation Defined Pragmas. + * Address Clause: Address Clauses. + * Address clauses: Implementation Advice. + * Address image: System.Address_Image (s-addima.ads). + * Address of subprogram code: Implementation Defined Attributes. + * Address, as private type: Implementation Advice. + * Address, operations of: Implementation Advice. + * Address_Size: Implementation Defined Attributes. + * Alignment Clause: Alignment Clauses. + * Alignment clauses: Implementation Advice. + * Alignment, default: Alignment Clauses. + * Alignment, maximum: Implementation Defined Attributes. + * Alignments of components: Implementation Defined Pragmas. + * Alternative Character Sets: Implementation Advice. + * Annotate: Implementation Defined Pragmas. + * Argument passing mechanisms: Implementation Defined Pragmas. + * Arrays, extendable <1>: GNAT.Table (g-table.ads). + * Arrays, extendable: GNAT.Dynamic_Tables (g-dyntab.ads). + * Arrays, multidimensional: Implementation Advice. + * Asm_Input: Implementation Defined Attributes. + * Asm_Output: Implementation Defined Attributes. + * Assert: Implementation Defined Pragmas. + * Assert_Failure, exception: System.Assertions (s-assert.ads). + * Assertions: System.Assertions (s-assert.ads). + * AST_Entry: Implementation Defined Attributes. + * Ast_Entry: Implementation Defined Pragmas. + * Attribute: Address Clauses. + * AWK: GNAT.AWK (g-awk.ads). + * Biased representation: Biased Representation. + * Big endian: Implementation Defined Attributes. + * Bit: Implementation Defined Attributes. + * bit ordering: Bit_Order Clauses. + * Bit ordering: Implementation Advice. + * Bit_Order Clause: Bit_Order Clauses. + * Bit_Position: Implementation Defined Attributes. + * Boolean_Entry_Barriers: Implementation Defined Characteristics. + * Bounded errors: Implementation Advice. + * Bounded-length strings: Implementation Advice. + * Bubble sort <1>: GNAT.Bubble_Sort_G (g-busorg.ads). + * Bubble sort: GNAT.Bubble_Sort_A (g-busora.ads). + * byte ordering: Effect of Bit_Order on Byte Ordering. + * C streams, interfacing: Interfaces.C.Streams (i-cstrea.ads). + * C Streams, Interfacing with Direct_IO: Ada.Direct_IO.C_Streams (a-diocst.ads). + * C Streams, Interfacing with Sequential_IO: Ada.Sequential_IO.C_Streams (a-siocst.ads). + * C Streams, Interfacing with Stream_IO: Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads). + * C Streams, Interfacing with Text_IO: Ada.Text_IO.C_Streams (a-tiocst.ads). + * C Streams, Interfacing with Wide_Text_IO: Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads). + * C++ interfacing: Interfaces.CPP (i-cpp.ads). + * C, interfacing with: Implementation Advice. + * C_Pass_By_Copy: Implementation Defined Pragmas. + * Calendar <1>: GNAT.Calendar.Time_IO (g-catiio.ads). + * Calendar: GNAT.Calendar (g-calend.ads). + * Casing of External names: Implementation Defined Pragmas. + * Casing utilities: GNAT.Case_Util (g-casuti.ads). + * CGI (Common Gateway Interface): GNAT.CGI (g-cgi.ads). + * CGI (Common Gateway Interface) cookie support: GNAT.CGI.Cookie (g-cgicoo.ads). + * CGI (Common Gateway Interface) debugging: GNAT.CGI.Debug (g-cgideb.ads). + * Character handling (GNAT.Case_Util): GNAT.Case_Util (g-casuti.ads). + * Character Sets: Implementation Advice. + * Checks, suppression of: Implementation Advice. + * Child Units: Implementation Advice. + * COBOL support: Implementation Advice. + * COBOL, interfacing with: Implementation Advice. + * Code_Address: Implementation Defined Attributes. + * Command line: GNAT.Command_Line (g-comlin.ads). + * Command line, argument removal: Ada.Command_Line.Remove (a-colire.ads). + * Comment: Implementation Defined Pragmas. + * Common_Object: Implementation Defined Pragmas. + * Compatibility (between Ada 83 and Ada 95): Compatibility with Ada 83. + * Complex arithmetic accuracy: Implementation Advice. + * Complex elementary functions: Implementation Advice. + * Complex types: Implementation Advice. + * Complex_Representation: Implementation Defined Pragmas. + * Component Clause: Record Representation Clauses. + * Component_Alignment: Implementation Defined Pragmas. + * Component_Size: Implementation Defined Pragmas. + * Component_Size Clause: Component_Size Clauses. + * Component_Size clauses: Implementation Advice. + * Component_Size_4: Implementation Defined Pragmas. + * Convention, effect on representation: Effect of Convention on Representation. + * Convention_Identifier: Implementation Defined Pragmas. + * Conventions, synonyms: Implementation Defined Pragmas. + * Conventions, typographical: Conventions. + * Cookie support in CGI: GNAT.CGI.Cookie (g-cgicoo.ads). + * CPP_Class: Implementation Defined Pragmas. + * CPP_Constructor: Implementation Defined Pragmas. + * CPP_Virtual: Implementation Defined Pragmas. + * CPP_Vtable: Implementation Defined Pragmas. + * CRC32: GNAT.CRC32 (g-crc32.ads). + * Current exception: GNAT.Current_Exception (g-curexc.ads). + * Cyclic Redundancy Check: GNAT.CRC32 (g-crc32.ads). + * Debug: Implementation Defined Pragmas. + * Debug pools: GNAT.Debug_Pools (g-debpoo.ads). + * Debugging <1>: GNAT.Exception_Traces (g-exctra.ads). + * Debugging <2>: GNAT.Debug_Utilities (g-debuti.ads). + * Debugging: GNAT.Debug_Pools (g-debpoo.ads). + * debugging with Initialize_Scalars: Implementation Defined Pragmas. + * Dec Ada 83: Implementation Defined Pragmas. + * Dec Ada 83 casing compatibility: Implementation Defined Pragmas. + * Decimal radix support: Implementation Advice. + * Default_Bit_Order: Implementation Defined Attributes. + * Deferring aborts: Implementation Defined Pragmas. + * Directory operations: GNAT.Directory_Operations (g-dirope.ads). + * Discriminants, testing for: Implementation Defined Attributes. + * Duration'Small: Implementation Advice. + * Elab_Body: Implementation Defined Attributes. + * Elab_Spec: Implementation Defined Attributes. + * Elaborated: Implementation Defined Attributes. + * Elaboration control: Implementation Defined Pragmas. + * Elaboration_Checks: Implementation Defined Pragmas. + * Eliminate: Implementation Defined Pragmas. + * Elimination of unused subprograms: Implementation Defined Pragmas. + * Emax: Implementation Defined Attributes. + * Enclosing_Entity: Enclosing_Entity. + * Entry queuing policies: Implementation Advice. + * Enum_Rep: Implementation Defined Attributes. + * Enumeration representation clauses: Implementation Advice. + * Enumeration values: Implementation Advice. + * Epsilon: Implementation Defined Attributes. + * Error detection: Implementation Advice. + * Exception information: Implementation Advice. + * Exception retrieval: GNAT.Current_Exception (g-curexc.ads). + * Exception traces: GNAT.Exception_Traces (g-exctra.ads). + * Exception, obtaining most recent: GNAT.Most_Recent_Exception (g-moreex.ads). + * Exception_Information': Exception_Information. + * Exception_Message: Exception_Message. + * Exception_Name: Exception_Name. + * Export <1>: Address Clauses. + * Export: Implementation Advice. + * Export_Exception: Implementation Defined Pragmas. + * Export_Function: Implementation Defined Pragmas. + * Export_Object: Implementation Defined Pragmas. + * Export_Procedure: Implementation Defined Pragmas. + * Export_Valued_Procedure: Implementation Defined Pragmas. + * Extend_System: Implementation Defined Pragmas. + * External: Implementation Defined Pragmas. + * External Names, casing: Implementation Defined Pragmas. + * External_Name_Casing: Implementation Defined Pragmas. + * FDL, GNU Free Documentation License: GNU Free Documentation License. + * File: File. + * File locking: GNAT.Lock_Files (g-locfil.ads). + * Finalize_Storage_Only: Implementation Defined Pragmas. + * Fixed_Value: Implementation Defined Attributes. + * Float types: Implementation Advice. + * Float_Representation: Implementation Defined Pragmas. + * Floating-Point Processor: GNAT.Float_Control (g-flocon.ads). + * Foreign threads: GNAT.Threads (g-thread.ads). + * Fortran, interfacing with: Implementation Advice. + * Get_Immediate <1>: Get_Immediate. + * Get_Immediate: Implementation Advice. + * GNAT.AWK (g-awk.ads): GNAT.AWK (g-awk.ads). + * GNAT.Bubble_Sort_A (g-busora.ads): GNAT.Bubble_Sort_A (g-busora.ads). + * GNAT.Bubble_Sort_G (g-busorg.ads): GNAT.Bubble_Sort_G (g-busorg.ads). + * GNAT.Calendar (g-calend.ads): GNAT.Calendar (g-calend.ads). + * GNAT.Calendar.Time_IO (g-catiio.ads): GNAT.Calendar.Time_IO (g-catiio.ads). + * GNAT.Case_Util (g-casuti.ads): GNAT.Case_Util (g-casuti.ads). + * GNAT.CGI (g-cgi.ads): GNAT.CGI (g-cgi.ads). + * GNAT.CGI.Cookie (g-cgicoo.ads): GNAT.CGI.Cookie (g-cgicoo.ads). + * GNAT.CGI.Debug (g-cgideb.ads): GNAT.CGI.Debug (g-cgideb.ads). + * GNAT.Command_Line (g-comlin.ads): GNAT.Command_Line (g-comlin.ads). + * GNAT.CRC32 (g-crc32.ads): GNAT.CRC32 (g-crc32.ads). + * GNAT.Current_Exception (g-curexc.ads): GNAT.Current_Exception (g-curexc.ads). + * GNAT.Debug_Pools (g-debpoo.ads): GNAT.Debug_Pools (g-debpoo.ads). + * GNAT.Debug_Utilities (g-debuti.ads): GNAT.Debug_Utilities (g-debuti.ads). + * GNAT.Directory_Operations (g-dirope.ads): GNAT.Directory_Operations (g-dirope.ads). + * GNAT.Dynamic_Tables (g-dyntab.ads): GNAT.Dynamic_Tables (g-dyntab.ads). + * GNAT.Exception_Traces (g-exctra.ads): GNAT.Exception_Traces (g-exctra.ads). + * GNAT.Expect (g-expect.ads): GNAT.Expect (g-expect.ads). + * GNAT.Float_Control (g-flocon.ads): GNAT.Float_Control (g-flocon.ads). + * GNAT.Heap_Sort_A (g-hesora.ads): GNAT.Heap_Sort_A (g-hesora.ads). + * GNAT.Heap_Sort_G (g-hesorg.ads): GNAT.Heap_Sort_G (g-hesorg.ads). + * GNAT.HTable (g-htable.ads): GNAT.HTable (g-htable.ads). + * GNAT.IO (g-io.ads): GNAT.IO (g-io.ads). + * GNAT.IO_Aux (g-io_aux.ads): GNAT.IO_Aux (g-io_aux.ads). + * GNAT.Lock_Files (g-locfil.ads): GNAT.Lock_Files (g-locfil.ads). + * GNAT.MD5 (g-md5.ads): GNAT.MD5 (g-md5.ads). + * GNAT.Most_Recent_Exception (g-moreex.ads): GNAT.Most_Recent_Exception (g-moreex.ads). + * GNAT.OS_Lib (g-os_lib.ads): GNAT.OS_Lib (g-os_lib.ads). + * GNAT.Regexp (g-regexp.ads): GNAT.Regexp (g-regexp.ads). + * GNAT.Registry (g-regist.ads): GNAT.Registry (g-regist.ads). + * GNAT.Regpat (g-regpat.ads): GNAT.Regpat (g-regpat.ads). + * GNAT.Sockets (g-socket.ads): GNAT.Sockets (g-socket.ads). + * GNAT.Source_Info (g-souinf.ads): GNAT.Source_Info (g-souinf.ads). + * GNAT.Spell_Checker (g-speche.ads): GNAT.Spell_Checker (g-speche.ads). + * GNAT.Spitbol (g-spitbo.ads): GNAT.Spitbol (g-spitbo.ads). + * GNAT.Spitbol.Patterns (g-spipat.ads): GNAT.Spitbol.Patterns (g-spipat.ads). + * GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT.Spitbol.Table_Boolean (g-sptabo.ads). + * GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT.Spitbol.Table_Integer (g-sptain.ads). + * GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT.Spitbol.Table_VString (g-sptavs.ads). + * GNAT.Table (g-table.ads): GNAT.Table (g-table.ads). + * GNAT.Task_Lock (g-tasloc.ads): GNAT.Task_Lock (g-tasloc.ads). + * GNAT.Threads (g-thread.ads): GNAT.Threads (g-thread.ads). + * GNAT.Traceback (g-traceb.ads): GNAT.Traceback (g-traceb.ads). + * GNAT.Traceback.Symbolic (g-trasym.ads): GNAT.Traceback.Symbolic (g-trasym.ads). + * Has_Discriminants: Implementation Defined Attributes. + * Hash tables: GNAT.HTable (g-htable.ads). + * Heap usage, implicit: Implementation Advice. + * IBM Packed Format: Interfaces.Packed_Decimal (i-pacdec.ads). + * Ident: Implementation Defined Pragmas. + * Image, of an address: System.Address_Image (s-addima.ads). + * Img: Implementation Defined Attributes. + * Implementation-dependent features: About This Guide. + * Import: Address Clauses. + * Import_Exception: Implementation Defined Pragmas. + * Import_Function: Implementation Defined Pragmas. + * Import_Object: Implementation Defined Pragmas. + * Import_Procedure: Implementation Defined Pragmas. + * Import_Valued_Procedure: Implementation Defined Pragmas. + * Initialization, suppression of: Implementation Defined Pragmas. + * Initialize_Scalars: Implementation Defined Pragmas. + * Inline_Always: Implementation Defined Pragmas. + * Inline_Generic: Implementation Defined Pragmas. + * Input/Output facilities <1>: GNAT.IO_Aux (g-io_aux.ads). + * Input/Output facilities: GNAT.IO (g-io.ads). + * Integer maps: GNAT.Spitbol.Table_Integer (g-sptain.ads). + * Integer types: Implementation Advice. + * Integer_Value: Implementation Defined Attributes. + * Interface: Implementation Defined Pragmas. + * Interface_Name: Implementation Defined Pragmas. + * Interfaces: Implementation Advice. + * Interfaces.C.Extensions (i-cexten.ads): Interfaces.C.Extensions (i-cexten.ads). + * Interfaces.C.Streams (i-cstrea.ads): Interfaces.C.Streams (i-cstrea.ads). + * Interfaces.CPP (i-cpp.ads): Interfaces.CPP (i-cpp.ads). + * Interfaces.Os2lib (i-os2lib.ads): Interfaces.Os2lib (i-os2lib.ads). + * Interfaces.Os2lib.Errors (i-os2err.ads): Interfaces.Os2lib.Errors (i-os2err.ads). + * Interfaces.Os2lib.Synchronization (i-os2syn.ads): Interfaces.Os2lib.Synchronization (i-os2syn.ads). + * Interfaces.Os2lib.Threads (i-os2thr.ads): Interfaces.Os2lib.Threads (i-os2thr.ads). + * Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces.Packed_Decimal (i-pacdec.ads). + * Interfaces.VxWorks (i-vxwork.ads): Interfaces.VxWorks (i-vxwork.ads). + * Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces.VxWorks.IO (i-vxwoio.ads). + * Interfacing to C++: Implementation Defined Pragmas. + * Interfacing to VxWorks: Interfaces.VxWorks (i-vxwork.ads). + * Interfacing to VxWorks' I/O: Interfaces.VxWorks.IO (i-vxwoio.ads). + * Interfacing with C++: Implementation Defined Pragmas. + * Interfacing, to C++: Interfaces.CPP (i-cpp.ads). + * Interfacing, to OS/2 <1>: Interfaces.Os2lib.Threads (i-os2thr.ads). + * Interfacing, to OS/2 <2>: Interfaces.Os2lib.Synchronization (i-os2syn.ads). + * Interfacing, to OS/2 <3>: Interfaces.Os2lib.Errors (i-os2err.ads). + * Interfacing, to OS/2: Interfaces.Os2lib (i-os2lib.ads). + * Interrupt priority, maximum: Implementation Defined Attributes. + * Interrupt support: Implementation Advice. + * Interrupts: Implementation Advice. + * Intrinsic operator: Intrinsic Operators. + * Intrinsic Subprograms: Intrinsic Subprograms. + * Large: Implementation Defined Attributes. + * Latin-1: Compatibility with Ada 83. + * Latin_1 constants for Wide_Character: Ada.Characters.Wide_Latin_1 (a-cwila1.ads). + * Latin_9 constants for Character: Ada.Characters.Latin_9 (a-chlat9.ads). + * Latin_9 constants for Wide_Character: Ada.Characters.Wide_Latin_9 (a-cwila9.ads). + * License: Implementation Defined Pragmas. + * License checking: Implementation Defined Pragmas. + * Line: Line. + * Link_With: Implementation Defined Pragmas. + * Linker_Alias: Implementation Defined Pragmas. + * Linker_Section: Implementation Defined Pragmas. + * Little endian: Implementation Defined Attributes. + * Locking: GNAT.Task_Lock (g-tasloc.ads). + * Locking Policies: Implementation Advice. + * Locking using files: GNAT.Lock_Files (g-locfil.ads). + * Long_Float: Implementation Defined Pragmas. + * Machine operations: Implementation Advice. + * Machine_Attribute: Implementation Defined Pragmas. + * Machine_Size: Implementation Defined Attributes. + * Main_Storage: Implementation Defined Pragmas. + * Mantissa: Implementation Defined Attributes. + * Maps <1>: GNAT.Spitbol.Table_VString (g-sptavs.ads). + * Maps: GNAT.Spitbol.Table_Integer (g-sptain.ads). + * Max_Entry_Queue_Depth: Implementation Defined Characteristics. + * Max_Interrupt_Priority: Implementation Defined Attributes. + * Max_Priority: Implementation Defined Attributes. + * Maximum_Alignment: Implementation Defined Attributes. + * Mechanism_Code: Implementation Defined Attributes. + * Memory corruption debugging: GNAT.Debug_Pools (g-debpoo.ads). + * Message Digest MD5: GNAT.MD5 (g-md5.ads). + * Multidimensional arrays: Implementation Advice. + * Named numbers, representation of: Implementation Defined Attributes. + * No_Calendar: Implementation Defined Characteristics. + * No_Dynamic_Interrupts: Implementation Defined Characteristics. + * No_Elaboration_Code: Implementation Defined Characteristics. + * No_Entry_Calls_In_Elaboration_Code: Implementation Defined Characteristics. + * No_Entry_Queue: Implementation Defined Characteristics. + * No_Enumeration_Maps: Implementation Defined Characteristics. + * No_Exception_Handlers: Implementation Defined Characteristics. + * No_Implementation_Attributes: Implementation Defined Characteristics. + * No_Implementation_Pragmas: Implementation Defined Characteristics. + * No_Implementation_Restrictions: Implementation Defined Characteristics. + * No_Implicit_Conditionals: Implementation Defined Characteristics. + * No_Implicit_Loops: Implementation Defined Characteristics. + * No_Local_Protected_Objects: Implementation Defined Characteristics. + * No_Protected_Type_Allocators: Implementation Defined Characteristics. + * No_Return: Implementation Defined Pragmas. + * No_Run_Time: Implementation Defined Pragmas. + * No_Secondary_Stack: Implementation Defined Characteristics. + * No_Select_Statements: Implementation Defined Characteristics. + * No_Standard_Storage_Pools: Implementation Defined Characteristics. + * No_Streams: Implementation Defined Characteristics. + * No_Task_Attributes: Implementation Defined Characteristics. + * No_Task_Termination: Implementation Defined Characteristics. + * No_Tasking: Implementation Defined Characteristics. + * No_Wide_Characters: Implementation Defined Characteristics. + * Normalize_Scalars: Implementation Defined Pragmas. + * Null_Occurrence, testing for: Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads). + * Null_Parameter: Implementation Defined Attributes. + * Numerics: Implementation Advice. + * Object_Size <1>: Value_Size and Object_Size Clauses. + * Object_Size: Implementation Defined Attributes. + * OpenVMS <1>: Implementation Defined Attributes. + * OpenVMS: Implementation Defined Pragmas. + * Operating System interface: GNAT.OS_Lib (g-os_lib.ads). + * Operations, on Address: Implementation Advice. + * ordering, of bits: Bit_Order Clauses. + * ordering, of bytes: Effect of Bit_Order on Byte Ordering. + * OS/2 Error codes: Interfaces.Os2lib.Errors (i-os2err.ads). + * OS/2 interfacing <1>: Interfaces.Os2lib.Errors (i-os2err.ads). + * OS/2 interfacing: Interfaces.Os2lib (i-os2lib.ads). + * OS/2 synchronization primitives: Interfaces.Os2lib.Synchronization (i-os2syn.ads). + * OS/2 thread interfacing: Interfaces.Os2lib.Threads (i-os2thr.ads). + * Package Interfaces: Implementation Advice. + * Package Interrupts: Implementation Advice. + * Package Task_Attributes: Implementation Advice. + * Packed Decimal: Interfaces.Packed_Decimal (i-pacdec.ads). + * Packed types: Implementation Advice. + * Parameters, passing mechanism: Implementation Defined Attributes. + * Parameters, when passed by reference: Implementation Defined Attributes. + * Parsing: GNAT.AWK (g-awk.ads). + * Partition communication subsystem: Implementation Advice. + * Partition intefacing functions: System.Partition_Interface (s-parint.ads). + * Passed_By_Reference: Implementation Defined Attributes. + * Passing by copy: Implementation Defined Pragmas. + * Passing by descriptor: Implementation Defined Pragmas. + * Passive: Implementation Defined Pragmas. + * Pattern matching <1>: GNAT.Spitbol.Patterns (g-spipat.ads). + * Pattern matching <2>: GNAT.Regpat (g-regpat.ads). + * Pattern matching: GNAT.Regexp (g-regexp.ads). + * PCS: Implementation Advice. + * Polling: Implementation Defined Pragmas. + * Portability: About This Guide. + * Pragma Pack (for arrays): Pragma Pack for Arrays. + * Pragma Pack (for records): Pragma Pack for Records. + * Pragma, representation: Representation Clauses and Pragmas. + * Pragmas: Implementation Advice. + * Pre-elaboration requirements: Implementation Advice. + * Preemptive abort: Implementation Advice. + * Priority, maximum: Implementation Defined Attributes. + * Propagate_Exceptions: Implementation Defined Pragmas. + * Protected procedure handlers: Implementation Advice. + * Psect_Object: Implementation Defined Pragmas. + * Pure: Implementation Defined Pragmas. + * Pure_Function: Implementation Defined Pragmas. + * Random number generation: Implementation Advice. + * Range_Length: Implementation Defined Attributes. + * Ravenscar: Implementation Defined Pragmas. + * Record Representation Clause: Record Representation Clauses. + * Record representation clauses: Implementation Advice. + * Regular expressions <1>: GNAT.Regpat (g-regpat.ads). + * Regular expressions: GNAT.Regexp (g-regexp.ads). + * Removing command line arguments: Ada.Command_Line.Remove (a-colire.ads). + * Representation Clause: Representation Clauses and Pragmas. + * Representation Clauses: Representation Clauses and Pragmas. + * Representation clauses: Implementation Advice. + * Representation clauses, enumeration: Implementation Advice. + * Representation clauses, records: Implementation Advice. + * Representation of enums: Implementation Defined Attributes. + * Representation of wide characters: System.Wch_Cnv (s-wchcnv.ads). + * Representation Pragma: Representation Clauses and Pragmas. + * Representation, determination of: Determining the Representations chosen by GNAT. + * Restricted_Run_Time: Implementation Defined Pragmas. + * Return values, passing mechanism: Implementation Defined Attributes. + * Rotate_Left: Rotate_Left. + * Rotate_Right: Rotate_Right. + * Safe_Emax: Implementation Defined Attributes. + * Safe_Large: Implementation Defined Attributes. + * Sets of strings: GNAT.Spitbol.Table_Boolean (g-sptabo.ads). + * Share_Generic: Implementation Defined Pragmas. + * Shift_Left: Shift_Left. + * Shift_Right: Shift_Right. + * Shift_Right_Arithmetic: Shift_Right_Arithmetic. + * Simple I/O: GNAT.IO (g-io.ads). + * Size Clause: Size Clauses. + * Size clauses: Implementation Advice. + * Size for biased representation: Biased Representation. + * Size of Address: Implementation Defined Attributes. + * Size, of objects: Value_Size and Object_Size Clauses. + * Size, setting for not-first subtype: Implementation Defined Attributes. + * Size, used for objects: Implementation Defined Attributes. + * Size, VADS compatibility <1>: Implementation Defined Attributes. + * Size, VADS compatibility: Implementation Defined Pragmas. + * Size, variant record objects: Size of Variant Record Objects. + * Small: Implementation Defined Attributes. + * Sockets: GNAT.Sockets (g-socket.ads). + * Sorting <1>: GNAT.Heap_Sort_G (g-hesorg.ads). + * Sorting <2>: GNAT.Heap_Sort_A (g-hesora.ads). + * Sorting <3>: GNAT.Bubble_Sort_G (g-busorg.ads). + * Sorting: GNAT.Bubble_Sort_A (g-busora.ads). + * Source Information: GNAT.Source_Info (g-souinf.ads). + * Source_File_Name: Implementation Defined Pragmas. + * Source_Location: Source_Location. + * Source_Reference: Implementation Defined Pragmas. + * Spawn capability: GNAT.OS_Lib (g-os_lib.ads). + * Spell checking: GNAT.Spell_Checker (g-speche.ads). + * SPITBOL interface: GNAT.Spitbol (g-spitbo.ads). + * SPITBOL pattern matching: GNAT.Spitbol.Patterns (g-spipat.ads). + * SPITBOL Tables <1>: GNAT.Spitbol.Table_VString (g-sptavs.ads). + * SPITBOL Tables <2>: GNAT.Spitbol.Table_Integer (g-sptain.ads). + * SPITBOL Tables: GNAT.Spitbol.Table_Boolean (g-sptabo.ads). + * Static_Priorities: Implementation Defined Characteristics. + * Static_Storage_Size: Implementation Defined Characteristics. + * Storage place attributes: Implementation Advice. + * Storage_Size Clause: Storage_Size Clauses. + * Storage_Unit <1>: Implementation Defined Attributes. + * Storage_Unit: Implementation Defined Pragmas. + * Stream files: Treating Text_IO Files as Streams. + * Stream oriented attributes: Implementation Advice. + * Stream_Convert: Implementation Defined Pragmas. + * String maps: GNAT.Spitbol.Table_VString (g-sptavs.ads). + * Style_Checks: Implementation Defined Pragmas. + * Subprogram address: Implementation Defined Attributes. + * Subtitle: Implementation Defined Pragmas. + * Suppress_All: Implementation Defined Pragmas. + * Suppress_Initialization: Implementation Defined Pragmas. + * Suppressing initialization: Implementation Defined Pragmas. + * Suppression of checks: Implementation Advice. + * Synchronization, OS/2: Interfaces.Os2lib.Synchronization (i-os2syn.ads). + * system, extending: Implementation Defined Pragmas. + * System.Address_Image (s-addima.ads): System.Address_Image (s-addima.ads). + * System.Assertions (s-assert.ads): System.Assertions (s-assert.ads). + * System.Partition_Interface (s-parint.ads): System.Partition_Interface (s-parint.ads). + * System.Task_Info (s-tasinf.ads): System.Task_Info (s-tasinf.ads). + * System.Wch_Cnv (s-wchcnv.ads): System.Wch_Cnv (s-wchcnv.ads). + * System.Wch_Con (s-wchcon.ads): System.Wch_Con (s-wchcon.ads). + * Table implementation <1>: GNAT.Table (g-table.ads). + * Table implementation: GNAT.Dynamic_Tables (g-dyntab.ads). + * Task locking: GNAT.Task_Lock (g-tasloc.ads). + * Task synchronization: GNAT.Task_Lock (g-tasloc.ads). + * Task_Attributes: Implementation Advice. + * Task_Info: Implementation Defined Pragmas. + * Task_Info pragma: System.Task_Info (s-tasinf.ads). + * Task_Name: Implementation Defined Pragmas. + * Task_Storage: Implementation Defined Pragmas. + * Tasking restrictions: Implementation Advice. + * Text_IO: GNAT.IO_Aux (g-io_aux.ads). + * Text_IO extensions: Text_IO Extensions. + * Text_IO for unbounded strings: Text_IO Facilities for Unbounded Strings. + * Text_IO, extensions for unbounded strings: Ada.Strings.Unbounded.Text_IO (a-suteio.ads). + * Text_IO, extensions for unbounded wide strings: Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads). + * Thread control, OS/2: Interfaces.Os2lib.Threads (i-os2thr.ads). + * Threads, foreign: GNAT.Threads (g-thread.ads). + * Tick: Implementation Defined Attributes. + * Time: GNAT.Calendar.Time_IO (g-catiio.ads). + * Time, monotonic: Implementation Advice. + * Time_Slice: Implementation Defined Pragmas. + * Title: Implementation Defined Pragmas. + * To_Address <1>: Address Clauses. + * To_Address: Implementation Defined Attributes. + * Trace back facilities <1>: GNAT.Traceback.Symbolic (g-trasym.ads). + * Trace back facilities: GNAT.Traceback (g-traceb.ads). + * Type_Class: Implementation Defined Attributes. + * Typographical conventions: Conventions. + * UET_Address: Implementation Defined Attributes. + * Unbounded_String, IO support: Ada.Strings.Unbounded.Text_IO (a-suteio.ads). + * Unbounded_String, Text_IO operations: Text_IO Facilities for Unbounded Strings. + * Unbounded_Wide_String, IO support: Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads). + * Unchecked conversion: Implementation Advice. + * Unchecked deallocation: Implementation Advice. + * Unchecked_Union: Implementation Defined Pragmas. + * Unimplemented_Unit: Implementation Defined Pragmas. + * Unions in C: Implementation Defined Pragmas. + * Universal_Literal_String: Implementation Defined Attributes. + * Unreferenced: Implementation Defined Pragmas. + * Unreserve_All_Interrupts: Implementation Defined Pragmas. + * Unrestricted_Access: Implementation Defined Attributes. + * Unsuppress: Implementation Defined Pragmas. + * Use_VADS_Size: Implementation Defined Pragmas. + * VADS_Size: Implementation Defined Attributes. + * Validity_Checks: Implementation Defined Pragmas. + * Value_Size <1>: Value_Size and Object_Size Clauses. + * Value_Size: Implementation Defined Attributes. + * Variant record objects, size: Size of Variant Record Objects. + * Volatile: Implementation Defined Pragmas. + * VxWorks, Get_Immediate: Interfaces.VxWorks.IO (i-vxwoio.ads). + * VxWorks, I/O interfacing: Interfaces.VxWorks.IO (i-vxwoio.ads). + * VxWorks, interfacing: Interfaces.VxWorks (i-vxwork.ads). + * Warnings: Implementation Defined Pragmas. + * Warnings, unreferenced: Implementation Defined Pragmas. + * Wchar_T_Size: Implementation Defined Attributes. + * Weak_External: Implementation Defined Pragmas. + * Wide Character, Representation: System.Wch_Cnv (s-wchcnv.ads). + * Wide String, Conversion: System.Wch_Cnv (s-wchcnv.ads). + * Windows Registry: GNAT.Registry (g-regist.ads). + * Word_Size: Implementation Defined Attributes. + * Zero address, passing: Implementation Defined Attributes. + * Zero Cost Exceptions: Implementation Defined Pragmas. + + +  + Tag Table: + Node: Top228 + Node: About This Guide5848 + Node: What This Reference Manual Contains6921 + Node: Conventions9217 + Node: Related Information10153 + Node: Implementation Defined Pragmas11181 + Node: Implementation Defined Attributes109040 + Node: Implementation Advice133111 + Node: Implementation Defined Characteristics177746 + Node: Intrinsic Subprograms220486 + Node: Intrinsic Operators221621 + Node: Enclosing_Entity222711 + Node: Exception_Information223249 + Node: Exception_Message223794 + Node: Exception_Name224311 + Node: File224786 + Node: Line225201 + Node: Rotate_Left225622 + Node: Rotate_Right226501 + Node: Shift_Left226792 + Node: Shift_Right227077 + Node: Shift_Right_Arithmetic227375 + Node: Source_Location227711 + Node: Representation Clauses and Pragmas228169 + Node: Alignment Clauses229367 + Node: Size Clauses232851 + Node: Storage_Size Clauses235407 + Node: Size of Variant Record Objects238107 + Node: Biased Representation241391 + Node: Value_Size and Object_Size Clauses242607 + Node: Component_Size Clauses249318 + Node: Bit_Order Clauses250454 + Node: Effect of Bit_Order on Byte Ordering254161 + Node: Pragma Pack for Arrays264110 + Node: Pragma Pack for Records266192 + Node: Record Representation Clauses268701 + Node: Enumeration Clauses270510 + Node: Address Clauses272097 + Node: Effect of Convention on Representation278799 + Node: Determining the Representations chosen by GNAT281530 + Node: Standard Library Routines286345 + Node: The Implementation of Standard I/O303853 + Node: Standard I/O Packages305954 + Node: FORM Strings306834 + Node: Direct_IO307373 + Node: Sequential_IO308254 + Node: Text_IO310192 + Node: Text_IO Stream Pointer Positioning312727 + Node: Text_IO Reading and Writing Non-Regular Files314264 + Node: Get_Immediate316136 + Node: Treating Text_IO Files as Streams316969 + Node: Text_IO Extensions317634 + Node: Text_IO Facilities for Unbounded Strings318473 + Node: Wide_Text_IO319879 + Node: Wide_Text_IO Stream Pointer Positioning324736 + Node: Wide_Text_IO Reading and Writing Non-Regular Files325762 + Node: Stream_IO326297 + Node: Shared Files326918 + Node: Open Modes329754 + Node: Operations on C Streams331065 + Node: Interfacing to C Streams338030 + Node: The GNAT Library341119 + Node: Ada.Characters.Latin_9 (a-chlat9.ads)345794 + Node: Ada.Characters.Wide_Latin_1 (a-cwila1.ads)346312 + Node: Ada.Characters.Wide_Latin_9 (a-cwila9.ads)346921 + Node: Ada.Command_Line.Remove (a-colire.ads)347533 + Node: Ada.Direct_IO.C_Streams (a-diocst.ads)348057 + Node: Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)348580 + Node: Ada.Sequential_IO.C_Streams (a-siocst.ads)349020 + Node: Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)349567 + Node: Ada.Strings.Unbounded.Text_IO (a-suteio.ads)350114 + Node: Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)350575 + Node: Ada.Text_IO.C_Streams (a-tiocst.ads)351056 + Node: Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)351580 + Node: GNAT.AWK (g-awk.ads)352085 + Node: GNAT.Bubble_Sort_A (g-busora.ads)352526 + Node: GNAT.Bubble_Sort_G (g-busorg.ads)352936 + Node: GNAT.Calendar (g-calend.ads)353422 + Node: GNAT.Calendar.Time_IO (g-catiio.ads)353887 + Node: GNAT.CRC32 (g-crc32.ads)354130 + Node: GNAT.Case_Util (g-casuti.ads)354761 + Node: GNAT.CGI (g-cgi.ads)355125 + Node: GNAT.CGI.Cookie (g-cgicoo.ads)355639 + Node: GNAT.CGI.Debug (g-cgideb.ads)356068 + Node: GNAT.Command_Line (g-comlin.ads)356393 + Node: GNAT.Current_Exception (g-curexc.ads)356828 + Node: GNAT.Debug_Pools (g-debpoo.ads)357385 + Node: GNAT.Debug_Utilities (g-debuti.ads)357804 + Node: GNAT.Directory_Operations (g-dirope.ads)358186 + Node: GNAT.Dynamic_Tables (g-dyntab.ads)358617 + Node: GNAT.Exception_Traces (g-exctra.ads)359250 + Node: GNAT.Expect (g-expect.ads)359589 + Node: GNAT.Float_Control (g-flocon.ads)360281 + Node: GNAT.Heap_Sort_A (g-hesora.ads)360802 + Node: GNAT.Heap_Sort_G (g-hesorg.ads)361327 + Node: GNAT.HTable (g-htable.ads)361801 + Node: GNAT.IO (g-io.ads)362203 + Node: GNAT.IO_Aux (g-io_aux.ads)362634 + Node: GNAT.Lock_Files (g-locfil.ads)362989 + Node: GNAT.MD5 (g-md5.ads)363322 + Node: GNAT.Most_Recent_Exception (g-moreex.ads)363608 + Node: GNAT.OS_Lib (g-os_lib.ads)364047 + Node: GNAT.Regexp (g-regexp.ads)364523 + Node: GNAT.Registry (g-regist.ads)365006 + Node: GNAT.Regpat (g-regpat.ads)365492 + Node: GNAT.Sockets (g-socket.ads)365914 + Node: GNAT.Source_Info (g-souinf.ads)366424 + Node: GNAT.Spell_Checker (g-speche.ads)366796 + Node: GNAT.Spitbol.Patterns (g-spipat.ads)367152 + Node: GNAT.Spitbol (g-spitbo.ads)367705 + Node: GNAT.Spitbol.Table_Boolean (g-sptabo.ads)368269 + Node: GNAT.Spitbol.Table_Integer (g-sptain.ads)368690 + Node: GNAT.Spitbol.Table_VString (g-sptavs.ads)369138 + Node: GNAT.Table (g-table.ads)369575 + Node: GNAT.Task_Lock (g-tasloc.ads)370190 + Node: GNAT.Threads (g-thread.ads)370602 + Node: GNAT.Traceback (g-traceb.ads)371195 + Node: GNAT.Traceback.Symbolic (g-trasym.ads)371541 + Node: Interfaces.C.Extensions (i-cexten.ads)371909 + Node: Interfaces.C.Streams (i-cstrea.ads)372326 + Node: Interfaces.CPP (i-cpp.ads)372657 + Node: Interfaces.Os2lib (i-os2lib.ads)373060 + Node: Interfaces.Os2lib.Errors (i-os2err.ads)373454 + Node: Interfaces.Os2lib.Synchronization (i-os2syn.ads)373794 + Node: Interfaces.Os2lib.Threads (i-os2thr.ads)374209 + Node: Interfaces.Packed_Decimal (i-pacdec.ads)374600 + Node: Interfaces.VxWorks (i-vxwork.ads)375014 + Node: Interfaces.VxWorks.IO (i-vxwoio.ads)375411 + Node: System.Address_Image (s-addima.ads)375827 + Node: System.Assertions (s-assert.ads)376212 + Node: System.Partition_Interface (s-parint.ads)376636 + Node: System.Task_Info (s-tasinf.ads)377047 + Node: System.Wch_Cnv (s-wchcnv.ads)377394 + Node: System.Wch_Con (s-wchcon.ads)377854 + Node: Interfacing to Other Languages378235 + Node: Interfacing to C378712 + Node: Interfacing to C++380544 + Node: Interfacing to COBOL381912 + Node: Interfacing to Fortran382195 + Node: Interfacing to non-GNAT Ada code382663 + Node: Machine Code Insertions383798 + Node: GNAT Implementation of Tasking390394 + Node: Mapping Ada Tasks onto the Underlying Kernel Threads390721 + Node: Ensuring Compliance with the Real-Time Annex392839 + Node: Code generation for array aggregates394959 + Node: Static constant aggregates with static bounds396543 + Node: Constant aggregates with an unconstrained nominal types398138 + Node: Aggregates with static bounds398858 + Node: Aggregates with non-static bounds399744 + Node: Aggregates in assignments statements400334 + Node: Specialized Needs Annexes401770 + Node: Compatibility Guide402863 + Node: Compatibility with Ada 83403379 + Node: Compatibility with Other Ada 95 Systems408315 + Node: Representation Clauses409837 + Node: Compatibility with DEC Ada 83414361 + Node: GNU Free Documentation License418222 + Node: Index440640 +  + End Tag Table diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_rm.texi gcc-3.3/gcc/ada/gnat_rm.texi *** gcc-3.2.3/gcc/ada/gnat_rm.texi 2002-04-21 13:59:45.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_rm.texi 2003-02-04 01:55:38.000000000 +0000 *************** *** 8,27 **** @c o @c G N A T _ RM o @c o ! @c $Revision: 1.3.12.2 $ @c o ! @c Copyright (C) 1992-2001 Ada Core Technologies, Inc. o @c o - @c GNAT is free software; you can redistribute it and/or modify it under o - @c terms of the GNU General Public License as published by the Free Soft- o - @c ware Foundation; either version 2, or (at your option) any later ver- o - @c sion. GNAT is distributed in the hope that it will be useful, but WITH- o - @c OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY o - @c or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License o - @c for more details. You should have received a copy of the GNU General o - @c Public License distributed with GNAT; see file COPYING. If not, write o - @c to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, o - @c MA 02111-1307, USA. o @c o @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o @c o --- 8,17 ---- @c o @c G N A T _ RM o @c o ! @c $Revision: 1.8.18.3 $ @c o ! @c Copyright (C) 1995-2002 Free Software Foundation o @c o @c o @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o @c o *************** *** 32,75 **** @setchapternewpage odd @syncodeindex fn cp ! @titlepage ! ! ! @title GNAT Reference Manual ! @subtitle GNAT, The GNU Ada 95 Compiler ! @subtitle Version 3.15w ! @subtitle Document revision level $Revision: 1.3.12.2 $ ! @subtitle Date: $Date: 2002/04/21 13:59:45 $ ! @author Ada Core Technologies, Inc. ! ! @page ! @vskip 0pt plus 1filll ! Copyright @copyright{} 1995-2001, Ada Core Technologies Permission is granted to copy, distribute and/or modify this document ! under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being ``GNU Free Documentation License'', with the Front-Cover Texts being ``GNAT Reference Manual'', and with no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. ! Silicon Graphics and IRIS are registered trademarks ! and IRIX is a trademark of Silicon Graphics, Inc. - IBM PC is a trademark of International - Business Machines Corporation. ! UNIX is a registered trademark of AT&T ! Bell Laboratories. ! DIGITAL ! VADS is a registered trademark of Rational Software Inc. ! The following are trademarks of Digital Equipment Corporation: ! DEC, DEC Ada, DECthreads, Digital, OpenVMS, and VAX@. @end titlepage @ifnottex --- 22,58 ---- @setchapternewpage odd @syncodeindex fn cp ! @include gcc-common.texi + @dircategory GNU Ada tools + @direntry + * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools. + @end direntry ! @copying ! Copyright @copyright{} 1995-2001, Free Software Foundation Permission is granted to copy, distribute and/or modify this document ! under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being ``GNU Free Documentation License'', with the Front-Cover Texts being ``GNAT Reference Manual'', and with no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. + @end copying ! @titlepage ! @title GNAT Reference Manual ! @subtitle GNAT, The GNU Ada 95 Compiler ! @subtitle GNAT Version for GCC @value{version-GCC} ! @author Ada Core Technologies, Inc. ! @page ! @vskip 0pt plus 1filll ! @insertcopying @end titlepage @ifnottex *************** GNAT Reference Manual *** 81,118 **** GNAT, The GNU Ada 95 Compiler ! Version 3.14a ! ! Date: $Date: 2002/04/21 13:59:45 $ Ada Core Technologies, Inc. - Copyright @copyright{} 1995-2001, Ada Core Technologies - - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.1 - or any later version published by the Free Software Foundation; - with the Invariant Sections being "GNU Free Documentation License", with the - Front-Cover Texts being "GNAT Reference Manual", and with no Back-Cover Texts. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - - - Silicon Graphics and IRIS are registered trademarks - and IRIX is a trademark of Silicon Graphics, Inc. - - IBM PC is a trademark of International - Business Machines Corporation. - - UNIX is a registered trademark of AT&T - Bell Laboratories. - DIGITAL - - VADS is a registered trademark of Rational Software Inc. - - The following are trademarks of Digital Equipment Corporation: - DEC, DEC Ada, DECthreads, Digital, OpenVMS, and VAX@. @menu * About This Guide:: --- 64,75 ---- GNAT, The GNU Ada 95 Compiler ! GNAT Version for GCC @value{version-GCC} Ada Core Technologies, Inc. + @insertcopying @menu * About This Guide:: *************** The Implementation of Standard I/O *** 157,163 **** --- 114,122 ---- The GNAT Library + * Ada.Characters.Latin_9 (a-chlat9.ads):: * Ada.Characters.Wide_Latin_1 (a-cwila1.ads):: + * Ada.Characters.Wide_Latin_9 (a-cwila9.ads):: * Ada.Command_Line.Remove (a-colire.ads):: * Ada.Direct_IO.C_Streams (a-diocst.ads):: * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads):: *************** The GNAT Library *** 192,197 **** --- 151,157 ---- * GNAT.IO (g-io.ads):: * GNAT.IO_Aux (g-io_aux.ads):: * GNAT.Lock_Files (g-locfil.ads):: + * GNAT.MD5 (g-md5.ads):: * GNAT.Most_Recent_Exception (g-moreex.ads):: * GNAT.OS_Lib (g-os_lib.ads):: * GNAT.Regexp (g-regexp.ads):: *************** The GNAT Library *** 219,224 **** --- 179,185 ---- * Interfaces.Os2lib.Threads (i-os2thr.ads):: * Interfaces.Packed_Decimal (i-pacdec.ads):: * Interfaces.VxWorks (i-vxwork.ads):: + * Interfaces.VxWorks.IO (i-vxwoio.ads):: * System.Address_Image (s-addima.ads):: * System.Assertions (s-assert.ads):: * System.Partition_Interface (s-parint.ads):: *************** GNAT Implementation of Tasking *** 261,275 **** @noindent This manual contains useful information in writing programs using the ! GNAT compiler. It includes information on implementation dependent characteristics of GNAT, including all the information required by Annex M of the standard. Ada 95 is designed to be highly portable,and guarantees that, for most programs, Ada 95 compilers behave in exactly the same manner on ! different machines. However, since Ada 95 is designed to be used in a wide variety of applications, it also contains a number of system ! dependent features to be used in interfacing to the external world. @c Maybe put the following in platform-specific section @ignore --- 222,236 ---- @noindent This manual contains useful information in writing programs using the ! GNAT compiler. It includes information on implementation dependent characteristics of GNAT, including all the information required by Annex M of the standard. Ada 95 is designed to be highly portable,and guarantees that, for most programs, Ada 95 compilers behave in exactly the same manner on ! different machines. However, since Ada 95 is designed to be used in a wide variety of applications, it also contains a number of system ! dependent features to Functbe used in interfacing to the external world. @c Maybe put the following in platform-specific section @ignore *************** in this guide: *** 371,383 **** and @code{classes}. @item ! @samp{Option flags} @item ! @file{File Names}, @file{button names}, and @file{field names}. @item ! @var{Variables}. @item @emph{Emphasis}. --- 332,344 ---- and @code{classes}. @item ! @code{Option flags} @item ! @file{File Names}, @samp{button names}, and @samp{field names}. @item ! @code{Variables}. @item @emph{Emphasis}. *************** and then shown this way. *** 394,407 **** @noindent Commands that are entered by the user are preceded in this manual by the ! characters "$ " (dollar sign followed by space). If your system uses this sequence as a prompt, then the commands will appear exactly as you see them ! in the manual. If your system uses some other prompt, then the command will ! appear with the $ replaced by whatever prompt character you are using. @node Related Information @unnumberedsec Related Information ! See the following documents for further information on GNAT @itemize @bullet @item --- 355,368 ---- @noindent Commands that are entered by the user are preceded in this manual by the ! characters @samp{$ } (dollar sign followed by space). If your system uses this sequence as a prompt, then the commands will appear exactly as you see them ! in the manual. If your system uses some other prompt, then the command will ! appear with the @samp{$} replaced by whatever prompt character you are using. @node Related Information @unnumberedsec Related Information ! See the following documents for further information on GNAT: @itemize @bullet @item *************** material for the Ada 95 programming lang *** 414,420 **** @item @cite{Ada 95 Annotated Reference Manual}, which is an annotated version ! of the standard reference manual cited above. The annotations describe detailed aspects of the design decision, and in particular contain useful sections on Ada 83 compatibility. --- 375,381 ---- @item @cite{Ada 95 Annotated Reference Manual}, which is an annotated version ! of the standard reference manual cited above. The annotations describe detailed aspects of the design decision, and in particular contain useful sections on Ada 83 compatibility. *************** compiler system. *** 435,453 **** @noindent Ada 95 defines a set of pragmas that can be used to supply additional ! information to the compiler. These language defined pragmas are implemented in GNAT and work as described in the Ada 95 Reference Manual. In addition, Ada 95 allows implementations to define additional pragmas ! whose meaning is defined by the implementation. GNAT provides a number of these implementation-dependent pragmas which can be used to extend ! and enhance the functionality of the compiler. This section of the GNAT Reference Manual describes these additional pragmas. Note that any program using these pragmas may not be portable to other compilers (although GNAT implements this set of pragmas on all ! platforms). Therefore if portability to other compilers is an important consideration, the use of these pragmas should be minimized. @table @code --- 396,414 ---- @noindent Ada 95 defines a set of pragmas that can be used to supply additional ! information to the compiler. These language defined pragmas are implemented in GNAT and work as described in the Ada 95 Reference Manual. In addition, Ada 95 allows implementations to define additional pragmas ! whose meaning is defined by the implementation. GNAT provides a number of these implementation-dependent pragmas which can be used to extend ! and enhance the functionality of the compiler. This section of the GNAT Reference Manual describes these additional pragmas. Note that any program using these pragmas may not be portable to other compilers (although GNAT implements this set of pragmas on all ! platforms). Therefore if portability to other compilers is an important consideration, the use of these pragmas should be minimized. @table @code *************** pragma Abort_Defer; *** 464,470 **** @noindent This pragma must appear at the start of the statement sequence of a ! handled sequence of statements (right after the @code{begin}). It has the effect of deferring aborts for the sequence of statements (but not for the declarations or handlers, if any, associated with this statement sequence). --- 425,431 ---- @noindent This pragma must appear at the start of the statement sequence of a ! handled sequence of statements (right after the @code{begin}). It has the effect of deferring aborts for the sequence of statements (but not for the declarations or handlers, if any, associated with this statement sequence). *************** pragma Ada_83; *** 481,495 **** @noindent A configuration pragma that establishes Ada 83 mode for the unit to which it applies, regardless of the mode set by the command line ! switches. In Ada 83 mode, GNAT attempts to be as compatible with the syntax and semantics of Ada 83, as defined in the original Ada ! 83 Reference Manual as possible. In particular, the new Ada 95 keywords are not recognized, optional package bodies are allowed, and generics may name types with unknown discriminants without using ! the (<>) notation. In addition, some but not all of the additional restrictions of Ada 83 are enforced. ! Ada 83 mode is intended for two purposes. Firstly, it allows existing legacy Ada 83 code to be compiled and adapted to GNAT with less effort. Secondly, it aids in keeping code backwards compatible with Ada 83. However, there is no guarantee that code that is processed correctly --- 442,456 ---- @noindent A configuration pragma that establishes Ada 83 mode for the unit to which it applies, regardless of the mode set by the command line ! switches. In Ada 83 mode, GNAT attempts to be as compatible with the syntax and semantics of Ada 83, as defined in the original Ada ! 83 Reference Manual as possible. In particular, the new Ada 95 keywords are not recognized, optional package bodies are allowed, and generics may name types with unknown discriminants without using ! the @code{(<>)} notation. In addition, some but not all of the additional restrictions of Ada 83 are enforced. ! Ada 83 mode is intended for two purposes. Firstly, it allows existing legacy Ada 83 code to be compiled and adapted to GNAT with less effort. Secondly, it aids in keeping code backwards compatible with Ada 83. However, there is no guarantee that code that is processed correctly *************** A configuration pragma that establishes *** 511,517 **** it applies, regardless of the mode set by the command line switches. This mode is set automatically for the @code{Ada} and @code{System} packages and their children, so you need not specify it in these ! contexts. This pragma is useful when writing a reusable component that itself uses Ada 95 features, but which is intended to be usable from either Ada 83 or Ada 95 programs. --- 472,478 ---- it applies, regardless of the mode set by the command line switches. This mode is set automatically for the @code{Ada} and @code{System} packages and their children, so you need not specify it in these ! contexts. This pragma is useful when writing a reusable component that itself uses Ada 95 features, but which is intended to be usable from either Ada 83 or Ada 95 programs. *************** ARG ::= NAME | EXPRESSION *** 527,543 **** @end smallexample @noindent ! This pragma is used to annotate programs. @var{identifier} identifies ! the type of annotation. GNAT verifies this is an identifier, but does ! not otherwise analyze it. The @var{arg} argument can be either a string literal or an ! expression. String literals are assumed to be of type ! @code{Standard.String}. Names of entities are simply analyzed as entity ! names. All other expressions are analyzed as expressions, and must be unambiguous. The analyzed pragma is retained in the tree, but not otherwise processed ! by any part of the GNAT compiler. This pragma is intended for use by external tools, including ASIS@. @findex Assert --- 488,504 ---- @end smallexample @noindent ! This pragma is used to annotate programs. @var{identifier} identifies ! the type of annotation. GNAT verifies this is an identifier, but does ! not otherwise analyze it. The @var{arg} argument can be either a string literal or an ! expression. String literals are assumed to be of type ! @code{Standard.String}. Names of entities are simply analyzed as entity ! names. All other expressions are analyzed as expressions, and must be unambiguous. The analyzed pragma is retained in the tree, but not otherwise processed ! by any part of the GNAT compiler. This pragma is intended for use by external tools, including ASIS@. @findex Assert *************** pragma Assert ( *** 553,559 **** @noindent The effect of this pragma depends on whether the corresponding command ! line switch is set to activate assertions. The pragma expands into code equivalent to the following: @smallexample --- 514,520 ---- @noindent The effect of this pragma depends on whether the corresponding command ! line switch is set to activate assertions. The pragma expands into code equivalent to the following: @smallexample *************** end if; *** 567,581 **** @noindent The string argument, if given, is the message that will be associated ! with the exception occurrence if the exception is raised. If no second argument is given, the default message is @samp{@var{file}:@var{nnn}}, where @var{file} is the name of the source file containing the assert, ! and @var{nnn} is the line number of the assert. A pragma is not a statement, so if a statement sequence contains nothing but a pragma assert, then a null statement is required in addition, as in: @smallexample ! ... if J > 3 then pragma Assert (K > 3, "Bad value for K"); null; --- 528,542 ---- @noindent The string argument, if given, is the message that will be associated ! with the exception occurrence if the exception is raised. If no second argument is given, the default message is @samp{@var{file}:@var{nnn}}, where @var{file} is the name of the source file containing the assert, ! and @var{nnn} is the line number of the assert. A pragma is not a statement, so if a statement sequence contains nothing but a pragma assert, then a null statement is required in addition, as in: @smallexample ! @dots{} if J > 3 then pragma Assert (K > 3, "Bad value for K"); null; *************** end if; *** 583,606 **** @end smallexample @noindent ! Note that, as with the if statement to which it is equivalent, the ! type of the expression is either Standard.Boolean, or any type derived from this standard type. If assertions are disabled (switch @code{-gnata} not used), then there is no effect (and in particular, any side effects from the expression ! are suppressed). More precisely it is not quite true that the pragma has no effect, since the expression is analyzed, and may cause types to be frozen if they are mentioned here for the first time. If assertions are enabled, then the given expression is tested, and if ! it is @code{False} then System.Assertions.Raise_Assert_Failure is called ! which results in the raising of Assert_Failure with the given message. If the boolean expression has side effects, these side effects will turn on and off with the setting of the assertions mode, resulting in ! assertions that have an effect on the program. You should generally ! avoid side effects in the expression arguments of this pragma. However, the expressions are analyzed for semantic correctness whether or not assertions are enabled, so turning assertions on and off cannot affect the legality of a program. --- 544,567 ---- @end smallexample @noindent ! Note that, as with the @code{if} statement to which it is equivalent, the ! type of the expression is either @code{Standard.Boolean}, or any type derived from this standard type. If assertions are disabled (switch @code{-gnata} not used), then there is no effect (and in particular, any side effects from the expression ! are suppressed). More precisely it is not quite true that the pragma has no effect, since the expression is analyzed, and may cause types to be frozen if they are mentioned here for the first time. If assertions are enabled, then the given expression is tested, and if ! it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called ! which results in the raising of @code{Assert_Failure} with the given message. If the boolean expression has side effects, these side effects will turn on and off with the setting of the assertions mode, resulting in ! assertions that have an effect on the program. You should generally ! avoid side effects in the expression arguments of this pragma. However, the expressions are analyzed for semantic correctness whether or not assertions are enabled, so turning assertions on and off cannot affect the legality of a program. *************** pragma AST_Entry (entry_IDENTIFIER); *** 616,630 **** @end smallexample @noindent ! This pragma is implemented only in the OpenVMS implementation of GNAT@. The argument is the simple name of a single entry; at most one @code{AST_Entry} ! pragma is allowed for any given entry. This pragma must be used in conjunction with the @code{AST_Entry} attribute, and is only allowed after the entry declaration and in the same task type specification or single task ! as the entry to which it applies. This pragma specifies that the given entry may be used to handle an OpenVMS asynchronous system trap (@code{AST}) ! resulting from an OpenVMS system service call. The pragma does not affect ! normal use of the entry. For further details on this pragma, see the DEC Ada Language Reference Manual, section 9.12a. @cindex Passing by copy --- 577,591 ---- @end smallexample @noindent ! This pragma is implemented only in the OpenVMS implementation of GNAT@. The argument is the simple name of a single entry; at most one @code{AST_Entry} ! pragma is allowed for any given entry. This pragma must be used in conjunction with the @code{AST_Entry} attribute, and is only allowed after the entry declaration and in the same task type specification or single task ! as the entry to which it applies. This pragma specifies that the given entry may be used to handle an OpenVMS asynchronous system trap (@code{AST}) ! resulting from an OpenVMS system service call. The pragma does not affect ! normal use of the entry. For further details on this pragma, see the DEC Ada Language Reference Manual, section 9.12a. @cindex Passing by copy *************** pragma C_Pass_By_Copy *** 641,647 **** @noindent Normally the default mechanism for passing C convention records to C convention subprograms is to pass them by reference, as suggested by RM ! B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change this default, by requiring that record formal parameters be passed by copy if all of the following conditions are met: --- 602,608 ---- @noindent Normally the default mechanism for passing C convention records to C convention subprograms is to pass them by reference, as suggested by RM ! B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change this default, by requiring that record formal parameters be passed by copy if all of the following conditions are met: *************** pragma Comment (static_string_EXPRESSION *** 675,684 **** @end smallexample @noindent ! This is almost identical in effect to pragma Ident. It allows the placement of a comment into the object file and hence into the ! executable file if the operating system permits such usage. The ! difference is that Comment, unlike Ident, has no limit on the length of the string argument, and no limitations on placement of the pragma (it can be placed anywhere in the main source unit). --- 636,645 ---- @end smallexample @noindent ! This is almost identical in effect to pragma @code{Ident}. It allows the placement of a comment into the object file and hence into the ! executable file if the operating system permits such usage. The ! difference is that @code{Comment}, unlike @code{Ident}, has no limit on the length of the string argument, and no limitations on placement of the pragma (it can be placed anywhere in the main source unit). *************** in Fortran. The single *** 705,714 **** object @var{local_name} is assigned to the area designated by the @var{External} argument. You may define a record to correspond to a series ! of fields. The @var{size} argument is syntax checked in GNAT, but otherwise ignored. ! @code{Common_Object} is not supported on all platforms. If no support is available, then the code generator will issue a message indicating that the necessary attribute for implementation of this pragma is not available. --- 666,675 ---- object @var{local_name} is assigned to the area designated by the @var{External} argument. You may define a record to correspond to a series ! of fields. The @var{size} argument is syntax checked in GNAT, but otherwise ignored. ! @code{Common_Object} is not supported on all platforms. If no support is available, then the code generator will issue a message indicating that the necessary attribute for implementation of this pragma is not available. *************** pragma Complex_Representation *** 725,735 **** @noindent The @var{Entity} argument must be the name of a record type which has ! two fields of the same floating-point type. The effect of this pragma is to force gcc to use the special internal complex representation form for ! this record, which may be more efficient. Note that this may result in the code for this type not conforming to standard ABI (application ! binary interface) requirements for the handling of record types. For example, in some environments, there is a requirement for passing records by pointer, and the use of this pragma may result in passing this type in floating-point registers. --- 686,696 ---- @noindent The @var{Entity} argument must be the name of a record type which has ! two fields of the same floating-point type. The effect of this pragma is to force gcc to use the special internal complex representation form for ! this record, which may be more efficient. Note that this may result in the code for this type not conforming to standard ABI (application ! binary interface) requirements for the handling of record types. For example, in some environments, there is a requirement for passing records by pointer, and the use of this pragma may result in passing this type in floating-point registers. *************** The meaning of the @var{Form} argument i *** 761,776 **** @item Component_Size Aligns scalar components and subcomponents of the array or record type on boundaries appropriate to their inherent size (naturally ! aligned). For example, 1-byte components are aligned on byte boundaries, 2-byte integer components are aligned on 2-byte boundaries, 4-byte ! integer components are aligned on 4-byte boundaries and so on. These alignment rules correspond to the normal rules for C compilers on all machines except the VAX@. @findex Component_Size_4 @item Component_Size_4 Naturally aligns components with a size of four or fewer ! bytes. Components that are larger than 4 bytes are placed on the next 4-byte boundary. @findex Storage_Unit --- 722,737 ---- @item Component_Size Aligns scalar components and subcomponents of the array or record type on boundaries appropriate to their inherent size (naturally ! aligned). For example, 1-byte components are aligned on byte boundaries, 2-byte integer components are aligned on 2-byte boundaries, 4-byte ! integer components are aligned on 4-byte boundaries and so on. These alignment rules correspond to the normal rules for C compilers on all machines except the VAX@. @findex Component_Size_4 @item Component_Size_4 Naturally aligns components with a size of four or fewer ! bytes. Components that are larger than 4 bytes are placed on the next 4-byte boundary. @findex Storage_Unit *************** aligned on boundaries determined by the *** 783,799 **** @item Default Specifies that array or record components are aligned on default boundaries, appropriate to the underlying hardware or operating system or ! both. For OpenVMS VAX systems, the @code{Default} choice is the same as ! the @code{Storage_Unit} choice (byte alignment). For all other systems, the @code{Default} choice is the same as @code{Component_Size} (natural alignment). @end table If the @code{Name} parameter is present, @var{type_local_name} must refer to a local record or array type, and the specified alignment ! choice applies to the specified type. The use of @code{Component_Alignment} together with a pragma @code{Pack} causes the ! @code{Component_Alignment} pragma to be ignored. The use of @code{Component_Alignment} together with a record representation clause is only effective for fields not specified by the representation clause. --- 744,760 ---- @item Default Specifies that array or record components are aligned on default boundaries, appropriate to the underlying hardware or operating system or ! both. For OpenVMS VAX systems, the @code{Default} choice is the same as ! the @code{Storage_Unit} choice (byte alignment). For all other systems, the @code{Default} choice is the same as @code{Component_Size} (natural alignment). @end table If the @code{Name} parameter is present, @var{type_local_name} must refer to a local record or array type, and the specified alignment ! choice applies to the specified type. The use of @code{Component_Alignment} together with a pragma @code{Pack} causes the ! @code{Component_Alignment} pragma to be ignored. The use of @code{Component_Alignment} together with a record representation clause is only effective for fields not specified by the representation clause. *************** a configuration pragma, in which case it *** 802,814 **** accordance with the normal rules for configuration pragmas, or it can be used within a declarative part, in which case it applies to types that are declared within this declarative part, or within any nested scope ! within this declarative part. In either case it specifies the alignment to be applied to any record or array type which has otherwise standard representation. If the alignment for a record or array type is not specified (using pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep clause), the GNAT uses the default alignment as described previously. @findex CPP_Class @cindex Interfacing with C++ --- 763,809 ---- accordance with the normal rules for configuration pragmas, or it can be used within a declarative part, in which case it applies to types that are declared within this declarative part, or within any nested scope ! within this declarative part. In either case it specifies the alignment to be applied to any record or array type which has otherwise standard representation. If the alignment for a record or array type is not specified (using pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep clause), the GNAT uses the default alignment as described previously. + + @findex Convention_Identifier + @cindex Conventions, synonyms + @item pragma Convention_Identifier + @noindent + Syntax: + + @smallexample + pragma Convention_Identifier ( + [Name =>] IDENTIFIER, + [Convention =>] convention_IDENTIFIER); + @end smallexample + + @noindent + This pragma provides a mechanism for supplying synonyms for existing + convention identifiers. The @code{Name} identifier can subsequently + be used as a synonym for the given convention in other pragmas (including + for example pragma @code{Import} or another @code{Convention_Identifier} + pragma). As an example of the use of this, suppose you had legacy code + which used Fortran77 as the identifier for Fortran. Then the pragma: + + @smallexample + pragma Convention_Indentifier (Fortran77, Fortran); + @end smallexample + + @noindent + would allow the use of the convention identifier @code{Fortran77} in + subsequent code, avoiding the need to modify the sources. As another + example, you could use this to parametrize convention requirements + according to systems. Suppose you needed to use @code{Stdcall} on + windows systems, and @code{C} on some other system, then you could + define a convention identifier @code{Library} and use a single + @code{Convention_Identifier} pragma to specify which convention + would be used system-wide. @findex CPP_Class @cindex Interfacing with C++ *************** pragma CPP_Class ([Entity =>] LOCAL_NAME *** 822,828 **** @noindent The argument denotes an entity in the current declarative region ! that is declared as a tagged or untagged record type. It indicates that the type corresponds to an externally declared C++ class type, and is to be laid out the same way that C++ would lay out the type. --- 817,823 ---- @noindent The argument denotes an entity in the current declarative region ! that is declared as a tagged or untagged record type. It indicates that the type corresponds to an externally declared C++ class type, and is to be laid out the same way that C++ would lay out the type. *************** for dispatching. *** 833,845 **** Types for which @code{CPP_Class} is specified do not have assignment or equality operators defined (such operations can be imported or declared ! as subprograms as required). Initialization is allowed only by constructor functions (see pragma @code{CPP_Constructor}). Pragma @code{CPP_Class} is intended primarily for automatic generation ! using an automatic binding generator tool. Ada Core Technologies does ! not currently supply such a ! tool; See @ref{Interfacing to C++} for more details. @cindex Interfacing with C++ @findex CPP_Constructor --- 828,839 ---- Types for which @code{CPP_Class} is specified do not have assignment or equality operators defined (such operations can be imported or declared ! as subprograms as required). Initialization is allowed only by constructor functions (see pragma @code{CPP_Constructor}). Pragma @code{CPP_Class} is intended primarily for automatic generation ! using an automatic binding generator tool. ! See @ref{Interfacing to C++} for related information. @cindex Interfacing with C++ @findex CPP_Constructor *************** pragma CPP_Constructor ([Entity =>] LOCA *** 853,862 **** @noindent This pragma identifies an imported function (imported in the usual way ! with pragma Import) as corresponding to a C++ ! constructor. The argument is a name that must have been ! previously mentioned in a pragma ! Import with @var{Convention CPP}, and must be of one of the following forms: @itemize @bullet --- 847,856 ---- @noindent This pragma identifies an imported function (imported in the usual way ! with pragma @code{Import}) as corresponding to a C++ ! constructor. The argument is a name that must have been ! previously mentioned in a pragma @code{Import} ! with @code{Convention} = @code{CPP}, and must be of one of the following forms: @itemize @bullet *************** forms: *** 871,877 **** where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies. The first form is the default constructor, used when an object of type ! @var{T} is created on the Ada side with no explicit constructor. Other constructors (including the copy constructor, which is simply a special case of the second form in which the one and only argument is of type @var{T}), can only appear in two contexts: --- 865,871 ---- where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies. The first form is the default constructor, used when an object of type ! @var{T} is created on the Ada side with no explicit constructor. Other constructors (including the copy constructor, which is simply a special case of the second form in which the one and only argument is of type @var{T}), can only appear in two contexts: *************** In an extension aggregate for an object *** 886,892 **** Although the constructor is described as a function that returns a value on the Ada side, it is typically a procedure with an extra implicit argument (the object being initialized) at the implementation ! level. GNAT issues the appropriate call, whatever it is, to get the object properly initialized. In the case of derived objects, you may use one of two possible forms --- 880,886 ---- Although the constructor is described as a function that returns a value on the Ada side, it is typically a procedure with an extra implicit argument (the object being initialized) at the implementation ! level. GNAT issues the appropriate call, whatever it is, to get the object properly initialized. In the case of derived objects, you may use one of two possible forms *************** for declaring and creating an object: *** 899,917 **** In the first case the default constructor is called and extension fields if any are initialized according to the default initialization ! expressions in the Ada declaration. In the second case, the given constructor is called and the extension aggregate indicates the explicit values of the extension fields. If no constructors are imported, it is impossible to create any objects ! on the Ada side. If no default constructor is imported, only the initialization forms using an explicit call to a constructor are permitted. Pragma @code{CPP_Constructor} is intended primarily for automatic generation ! using an automatic binding generator tool. Ada Core Technologies does ! not currently supply such a ! tool; See @ref{Interfacing to C++} for more details. @cindex Interfacing to C++ @findex CPP_Virtual --- 893,910 ---- In the first case the default constructor is called and extension fields if any are initialized according to the default initialization ! expressions in the Ada declaration. In the second case, the given constructor is called and the extension aggregate indicates the explicit values of the extension fields. If no constructors are imported, it is impossible to create any objects ! on the Ada side. If no default constructor is imported, only the initialization forms using an explicit call to a constructor are permitted. Pragma @code{CPP_Constructor} is intended primarily for automatic generation ! using an automatic binding generator tool. ! See @ref{Interfacing to C++} for more related information. @cindex Interfacing to C++ @findex CPP_Virtual *************** pragma CPP_Virtual *** 927,938 **** @end smallexample This pragma serves the same function as pragma @code{Import} in that ! case of a virtual function imported from C++. The @var{Entity} argument must be a primitive subprogram of a tagged type to which pragma @code{CPP_Class} ! applies. The @var{Vtable_Ptr} argument specifies the Vtable_Ptr component which contains the ! entry for this virtual function. The @var{Position} argument is the sequential number counting virtual functions for this Vtable starting at 1. --- 920,931 ---- @end smallexample This pragma serves the same function as pragma @code{Import} in that ! case of a virtual function imported from C++. The @var{Entity} argument must be a primitive subprogram of a tagged type to which pragma @code{CPP_Class} ! applies. The @var{Vtable_Ptr} argument specifies the Vtable_Ptr component which contains the ! entry for this virtual function. The @var{Position} argument is the sequential number counting virtual functions for this Vtable starting at 1. *************** virtual function, since it is always acc *** 946,954 **** appropriate Vtable entry. Pragma @code{CPP_Virtual} is intended primarily for automatic generation ! using an automatic binding generator tool. Ada Core Technologies does ! not currently supply such a ! tool; See @ref{Interfacing to C++} for more details. @cindex Interfacing with C++ @findex CPP_Vtable --- 939,946 ---- appropriate Vtable entry. Pragma @code{CPP_Virtual} is intended primarily for automatic generation ! using an automatic binding generator tool. ! See @ref{Interfacing to C++} for related information. @cindex Interfacing with C++ @findex CPP_Vtable *************** this pragma can be specified for each co *** 969,975 **** @code{CPP.Interfaces.Vtable_Ptr}. @var{Entity} is the tagged type, @var{Vtable_Ptr} is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is ! the number of virtual functions on the C++ side. Not all of these functions need to be imported on the Ada side. You may omit the @code{CPP_Vtable} pragma if there is only one --- 961,967 ---- @code{CPP.Interfaces.Vtable_Ptr}. @var{Entity} is the tagged type, @var{Vtable_Ptr} is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is ! the number of virtual functions on the C++ side. Not all of these functions need to be imported on the Ada side. You may omit the @code{CPP_Vtable} pragma if there is only one *************** imported on the Ada side (the default va *** 978,986 **** case is simply the total number of virtual functions). Pragma @code{CPP_Vtable} is intended primarily for automatic generation ! using an automatic binding generator tool. Ada Core Technologies does ! not currently supply such a ! tool; See @ref{Interfacing to C++} for more details. @findex Debug @item pragma Debug --- 970,977 ---- case is simply the total number of virtual functions). Pragma @code{CPP_Vtable} is intended primarily for automatic generation ! using an automatic binding generator tool. ! See @ref{Interfacing to C++} for related information. @findex Debug @item pragma Debug *************** tool; See @ref{Interfacing to C++} for m *** 988,1000 **** Syntax: @smallexample ! pragma Debug (PROCEDURE_CALL_STATEMENT); @end smallexample @noindent If assertions are not enabled on the command line, this pragma has no ! effect. If asserts are enabled, the semantics of the pragma is exactly ! equivalent to the procedure call. Pragmas are permitted in sequences of declarations, so you can use pragma @code{Debug} to intersperse calls to debug procedures in the middle of declarations. --- 979,999 ---- Syntax: @smallexample ! pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON); ! ! PROCEDURE_CALL_WITHOUT_SEMICOLON ::= ! PROCEDURE_NAME ! | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART @end smallexample @noindent + The argument has the syntactic form of an expression, meeting the + syntactic requirements for pragmas. + If assertions are not enabled on the command line, this pragma has no ! effect. If asserts are enabled, the semantics of the pragma is exactly ! equivalent to the procedure call statement corresponding to the argument ! with a terminating semicolon. Pragmas are permitted in sequences of declarations, so you can use pragma @code{Debug} to intersperse calls to debug procedures in the middle of declarations. *************** pragma Elaboration_Checks (RM | Static); *** 1011,1024 **** @noindent This is a configuration pragma that provides control over the elaboration model used by the compilation affected by the ! pragma. If the parameter is RM, then the dynamic elaboration model described in the Ada Reference Manual is used, as though the @code{-gnatE} switch had been specified on the command ! line. If the parameter is Static, then the default GNAT static ! model is used. This configuration pragma overrides the setting ! of the command line. For full details on the elaboration models ! used by the GNAT compiler, see section "Elaboration Order ! Handling in GNAT" in the GNAT Users Guide. @cindex Elimination of unused subprograms @findex Eliminate --- 1010,1023 ---- @noindent This is a configuration pragma that provides control over the elaboration model used by the compilation affected by the ! pragma. If the parameter is RM, then the dynamic elaboration model described in the Ada Reference Manual is used, as though the @code{-gnatE} switch had been specified on the command ! line. If the parameter is Static, then the default GNAT static ! model is used. This configuration pragma overrides the setting ! of the command line. For full details on the elaboration models ! used by the GNAT compiler, see section ``Elaboration Order ! Handling in GNAT'' in the @cite{GNAT User's Guide}. @cindex Elimination of unused subprograms @findex Eliminate *************** pragma Eliminate ( *** 1033,1044 **** pragma Eliminate ( [Unit_Name =>] IDENTIFIER | ! SELECTED_COMPONENT [Entity =>] IDENTIFIER | SELECTED_COMPONENT | ! STRING_LITERAL] ! [,[Parameter_Types =>] PARAMETER_TYPES] ! [,[Result_Type =>] result_SUBTYPE_NAME]]); PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@}) SUBTYPE_NAME ::= STRING_LITERAL --- 1032,1044 ---- pragma Eliminate ( [Unit_Name =>] IDENTIFIER | ! SELECTED_COMPONENT, [Entity =>] IDENTIFIER | SELECTED_COMPONENT | ! STRING_LITERAL ! [,[Parameter_Types =>] PARAMETER_TYPES] ! [,[Result_Type =>] result_SUBTYPE_NAME] ! [,[Homonym_Number =>] INTEGER_LITERAL]); PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@}) SUBTYPE_NAME ::= STRING_LITERAL *************** SUBTYPE_NAME ::= STRING_LITERAL *** 1046,1052 **** @noindent This pragma indicates that the given entity is not used outside the ! compilation unit it is defined in. The entity may be either a subprogram or a variable. If the entity to be eliminated is a library level subprogram, then --- 1046,1052 ---- @noindent This pragma indicates that the given entity is not used outside the ! compilation unit it is defined in. The entity may be either a subprogram or a variable. If the entity to be eliminated is a library level subprogram, then *************** In this form, the @code{Unit_Name} argum *** 1055,1085 **** library level unit to be eliminated. In all other cases, both @code{Unit_Name} and @code{Entity} arguments ! are required. item is an entity of a library package, then the first argument specifies the unit name, and the second argument specifies ! the particular entity. If the second argument is in string form, it must correspond to the internal manner in which GNAT stores entity names (see compilation unit Namet in the compiler sources for details). ! The third and fourth parameters are optionally used to distinguish ! between overloaded subprograms, in a manner similar to that used for the extended @code{Import} and @code{Export} pragmas, except that the subtype names are always given as string literals, again corresponding to the internal manner in which GNAT stores entity names. The effect of the pragma is to allow the compiler to eliminate the code or data associated with the named entity. Any reference to an eliminated entity outside the compilation unit it is defined in, causes a compile time or link time error. ! The intention of pragma Eliminate is to allow a program to be compiled in a system independent manner, with unused entities eliminated, without ! the requirement of modifying the source text. Normally the required set ! of Eliminate pragmas is constructed automatically using the gnatelim tool. Elimination of unused entities local to a compilation unit is automatic, ! without requiring the use of pragma Eliminate. Note that the reason this pragma takes string literals where names might ! be expected is that a pragma Eliminate can appear in a context where the relevant names are not visible. @cindex OpenVMS --- 1055,1098 ---- library level unit to be eliminated. In all other cases, both @code{Unit_Name} and @code{Entity} arguments ! are required. item is an entity of a library package, then the first argument specifies the unit name, and the second argument specifies ! the particular entity. If the second argument is in string form, it must correspond to the internal manner in which GNAT stores entity names (see compilation unit Namet in the compiler sources for details). ! ! The remaining parameters are optionally used to distinguish ! between overloaded subprograms. There are two ways of doing this. ! ! Use @code{Parameter_Types} and @code{Result_Type} to specify the ! profile of the subprogram to be eliminated in a manner similar to that ! used for the extended @code{Import} and @code{Export} pragmas, except that the subtype names are always given as string literals, again corresponding to the internal manner in which GNAT stores entity names. + Alternatively, the @code{Homonym_Number} parameter is used to specify + which overloaded alternative is to be eliminated. A value of 1 indicates + the first subprogram (in lexical order), 2 indicates the second etc. + The effect of the pragma is to allow the compiler to eliminate the code or data associated with the named entity. Any reference to an eliminated entity outside the compilation unit it is defined in, causes a compile time or link time error. ! The parameters of this pragma may be given in any order, as long as ! the usual rules for use of named parameters and position parameters ! are used. ! ! The intention of pragma @code{Eliminate} is to allow a program to be compiled in a system independent manner, with unused entities eliminated, without ! the requirement of modifying the source text. Normally the required set ! of @code{Eliminate} pragmas is constructed automatically using the gnatelim tool. Elimination of unused entities local to a compilation unit is automatic, ! without requiring the use of pragma @code{Eliminate}. Note that the reason this pragma takes string literals where names might ! be expected is that a pragma @code{Eliminate} can appear in a context where the relevant names are not visible. @cindex OpenVMS *************** EXTERNAL_SYMBOL ::= *** 1101,1111 **** @end smallexample @noindent ! This pragma is implemented only in the OpenVMS implementation of GNAT@. It causes the specified exception to be propagated outside of the Ada program, so that it can be handled by programs written in other OpenVMS languages. This pragma establishes an external name for an Ada exception and makes the ! name available to the OpenVMS Linker as a global symbol. For further details on this pragma, see the DEC Ada Language Reference Manual, section 13.9a3.2. --- 1114,1124 ---- @end smallexample @noindent ! This pragma is implemented only in the OpenVMS implementation of GNAT@. It causes the specified exception to be propagated outside of the Ada program, so that it can be handled by programs written in other OpenVMS languages. This pragma establishes an external name for an Ada exception and makes the ! name available to the OpenVMS Linker as a global symbol. For further details on this pragma, see the DEC Ada Language Reference Manual, section 13.9a3.2. *************** CLASS_NAME ::= ubs | ubsb | uba | s | sb *** 1150,1156 **** Use this pragma to make a function externally callable and optionally provide information on mechanisms to be used for passing parameter and ! result values. We recommend, for the purposes of improving portability, this pragma always be used in conjunction with a separate pragma @code{Export}, which must precede the pragma @code{Export_Function}. GNAT does not require a separate pragma @code{Export}, but if none is --- 1163,1169 ---- Use this pragma to make a function externally callable and optionally provide information on mechanisms to be used for passing parameter and ! result values. We recommend, for the purposes of improving portability, this pragma always be used in conjunction with a separate pragma @code{Export}, which must precede the pragma @code{Export_Function}. GNAT does not require a separate pragma @code{Export}, but if none is *************** Pragma @code{Export_Function} *** 1163,1172 **** region as the function to which they apply. @var{internal_name} must uniquely designate the function to which the ! pragma applies. If more than one function name exists of this name in the declarative part you must use the @code{Parameter_Types} and @code{Result_Type} parameters is mandatory to achieve the required ! unique designation. @var{subtype_ mark}s in these parameters must exactly match the subtypes in the corresponding function specification, using positional notation to match parameters with subtype marks. @cindex OpenVMS --- 1176,1185 ---- region as the function to which they apply. @var{internal_name} must uniquely designate the function to which the ! pragma applies. If more than one function name exists of this name in the declarative part you must use the @code{Parameter_Types} and @code{Result_Type} parameters is mandatory to achieve the required ! unique designation. @var{subtype_ mark}s in these parameters must exactly match the subtypes in the corresponding function specification, using positional notation to match parameters with subtype marks. @cindex OpenVMS *************** EXTERNAL_SYMBOL ::= *** 1191,1197 **** This pragma designates an object as exported, and apart from the extended rules for external symbols, is identical in effect to the use of ! the normal @code{Export} pragma applied to an object. You may use a separate Export pragma (and you probably should from the point of view of portability), but it is not required. @var{Size} is syntax checked, but otherwise ignored by GNAT@. --- 1204,1210 ---- This pragma designates an object as exported, and apart from the extended rules for external symbols, is identical in effect to the use of ! the normal @code{Export} pragma applied to an object. You may use a separate Export pragma (and you probably should from the point of view of portability), but it is not required. @var{Size} is syntax checked, but otherwise ignored by GNAT@. *************** CLASS_NAME ::= ubs | ubsb | uba | s | sb *** 1279,1285 **** This pragma is identical to @code{Export_Procedure} except that the first parameter of @var{local_name}, which must be present, must be of mode @code{OUT}, and externally the subprogram is treated as a function ! with this parameter as the result of the function. GNAT provides for this capability to allow the use of @code{OUT} and @code{IN OUT} parameters in interfacing to external functions (which are not permitted in Ada functions). --- 1292,1298 ---- This pragma is identical to @code{Export_Procedure} except that the first parameter of @var{local_name}, which must be present, must be of mode @code{OUT}, and externally the subprogram is treated as a function ! with this parameter as the result of the function. GNAT provides for this capability to allow the use of @code{OUT} and @code{IN OUT} parameters in interfacing to external functions (which are not permitted in Ada functions). *************** pragma Extend_System ([Name =>] IDENTIFI *** 1303,1328 **** @noindent This pragma is used to provide backwards compatibility with other ! implementations that extend the facilities of package @code{System}. In GNAT, @code{System} contains only the definitions that are present in ! the Ada 95 RM@. However, other implementations, notably the DEC Ada 83 implementation, provide many extensions to package @code{System}. For each such implementation accommodated by this pragma, GNAT provides a package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83 ! implementation, which provides the required additional definitions. You can use this package in two ways. You can @code{with} it in the normal way and access entities either by selection or using a @code{use} ! clause. In this case no special processing is required. However, if existing code contains references such as @code{System.@var{xxx}} where @var{xxx} is an entity in the extended definitions provided in package @code{System}, you may use this pragma to extend visibility in @code{System} in a non-standard way that ! provides greater compatibility with the existing code. Pragma @code{Extend_System} is a configuration pragma whose single argument is the name of the package containing the extended definition ! (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under control of this pragma will be processed using special visibility processing that looks in package @code{System.Aux_@var{xxx}} where @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in --- 1316,1341 ---- @noindent This pragma is used to provide backwards compatibility with other ! implementations that extend the facilities of package @code{System}. In GNAT, @code{System} contains only the definitions that are present in ! the Ada 95 RM@. However, other implementations, notably the DEC Ada 83 implementation, provide many extensions to package @code{System}. For each such implementation accommodated by this pragma, GNAT provides a package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83 ! implementation, which provides the required additional definitions. You can use this package in two ways. You can @code{with} it in the normal way and access entities either by selection or using a @code{use} ! clause. In this case no special processing is required. However, if existing code contains references such as @code{System.@var{xxx}} where @var{xxx} is an entity in the extended definitions provided in package @code{System}, you may use this pragma to extend visibility in @code{System} in a non-standard way that ! provides greater compatibility with the existing code. Pragma @code{Extend_System} is a configuration pragma whose single argument is the name of the package containing the extended definition ! (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under control of this pragma will be processed using special visibility processing that looks in package @code{System.Aux_@var{xxx}} where @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in *************** package @code{System}, but not found in *** 1331,1340 **** You can use this pragma either to access a predefined @code{System} extension supplied with the compiler, for example @code{Aux_DEC} or you can construct your own extension unit following the above ! definition. Note that such a package is a child of @code{System} ! and thus is considered part of the implementation. To compile it you will have to use the appropriate switch for compiling ! system units. See the GNAT User's Guide for details. @findex External @item pragma External --- 1344,1353 ---- You can use this pragma either to access a predefined @code{System} extension supplied with the compiler, for example @code{Aux_DEC} or you can construct your own extension unit following the above ! definition. Note that such a package is a child of @code{System} ! and thus is considered part of the implementation. To compile it you will have to use the appropriate switch for compiling ! system units. See the GNAT User's Guide for details. @findex External @item pragma External *************** pragma External ( *** 1351,1357 **** @noindent This pragma is identical in syntax and semantics to pragma ! @code{Export} as defined in the Ada Reference Manual. It is provided for compatibility with some Ada 83 compilers that used this pragma for exactly the same purposes as pragma @code{Export} before the latter was standardized. --- 1364,1370 ---- @noindent This pragma is identical in syntax and semantics to pragma ! @code{Export} as defined in the Ada Reference Manual. It is provided for compatibility with some Ada 83 compilers that used this pragma for exactly the same purposes as pragma @code{Export} before the latter was standardized. *************** pragma External_Name_Casing ( *** 1372,1382 **** @noindent This pragma provides control over the casing of external names associated ! with Import and Export pragmas. There are two cases to consider: @table @asis @item Implicit external names ! Implicit external names are derived from identifiers. The most common case arises when a standard Ada 95 Import or Export pragma is used with only two arguments, as in: --- 1385,1395 ---- @noindent This pragma provides control over the casing of external names associated ! with Import and Export pragmas. There are two cases to consider: @table @asis @item Implicit external names ! Implicit external names are derived from identifiers. The most common case arises when a standard Ada 95 Import or Export pragma is used with only two arguments, as in: *************** arguments, as in: *** 1387,1398 **** @noindent Since Ada is a case insensitive language, the spelling of the identifier in the Ada source program does not provide any information on the desired ! casing of the external name, and so a convention is needed. In GNAT the default treatment is that such names are converted to all lower case ! letters. This corresponds to the normal C style in many environments. The first argument of pragma @code{External_Name_Casing} can be used to ! control this treatment. If @code{Uppercase} is specified, then the name ! will be forced to all uppercase letters. If @code{Lowercase} is specified, then the normal default of all lower case letters will be used. This same implicit treatment is also used in the case of extended DEC Ada 83 --- 1400,1411 ---- @noindent Since Ada is a case insensitive language, the spelling of the identifier in the Ada source program does not provide any information on the desired ! casing of the external name, and so a convention is needed. In GNAT the default treatment is that such names are converted to all lower case ! letters. This corresponds to the normal C style in many environments. The first argument of pragma @code{External_Name_Casing} can be used to ! control this treatment. If @code{Uppercase} is specified, then the name ! will be forced to all uppercase letters. If @code{Lowercase} is specified, then the normal default of all lower case letters will be used. This same implicit treatment is also used in the case of extended DEC Ada 83 *************** compatible Import and Export pragmas whe *** 1400,1406 **** specified using an identifier rather than a string. @item Explicit external names ! Explicit external names are given as string literals. The most common case arises when a standard Ada 95 Import or Export pragma is used with three arguments, as in: --- 1413,1419 ---- specified using an identifier rather than a string. @item Explicit external names ! Explicit external names are given as string literals. The most common case arises when a standard Ada 95 Import or Export pragma is used with three arguments, as in: *************** pragma Import (C, C_Routine, "C_routine" *** 1410,1433 **** @noindent In this case, the string literal normally provides the exact casing required ! for the external name. The second argument of pragma @code{External_Name_Casing} may be used to modify this behavior. If @code{Uppercase} is specified, then the name ! will be forced to all uppercase letters. If @code{Lowercase} is specified, ! then the name will be forced to all lowercase letters. A specification of @code{As_Is} provides the normal default behavior in which the casing is taken from the string provided. @end table @noindent ! This pragma may appear anywhere that a pragma is valid. in particular, it ! can be used as a configuration pragma in the @code{gnat.adc} file, in which case it applies to all subsequent compilations, or it can be used as a program unit pragma, in which case it only applies to the current unit, or it can be used more locally to control individual Import/Export pragmas. ! It is primarily intended for use with @code{OpenVMS} systems, where many ! compilers convert all symbols to upper case by default. For interfacing to such compilers (e.g.@: the DEC C compiler), it may be convenient to use the pragma: --- 1423,1446 ---- @noindent In this case, the string literal normally provides the exact casing required ! for the external name. The second argument of pragma @code{External_Name_Casing} may be used to modify this behavior. If @code{Uppercase} is specified, then the name ! will be forced to all uppercase letters. If @code{Lowercase} is specified, ! then the name will be forced to all lowercase letters. A specification of @code{As_Is} provides the normal default behavior in which the casing is taken from the string provided. @end table @noindent ! This pragma may appear anywhere that a pragma is valid. In particular, it ! can be used as a configuration pragma in the @file{gnat.adc} file, in which case it applies to all subsequent compilations, or it can be used as a program unit pragma, in which case it only applies to the current unit, or it can be used more locally to control individual Import/Export pragmas. ! It is primarily intended for use with OpenVMS systems, where many ! compilers convert all symbols to upper case by default. For interfacing to such compilers (e.g.@: the DEC C compiler), it may be convenient to use the pragma: *************** pragma Finalize_Storage_Only (first_subt *** 1449,1455 **** @noindent This pragma allows the compiler not to emit a Finalize call for objects ! defined at the library level. This is mostly useful for types where finalization is only used to deal with storage reclamation since in most environments it is not necessary to reclaim memory just before terminating execution, hence the name. --- 1462,1468 ---- @noindent This pragma allows the compiler not to emit a Finalize call for objects ! defined at the library level. This is mostly useful for types where finalization is only used to deal with storage reclamation since in most environments it is not necessary to reclaim memory just before terminating execution, hence the name. *************** FLOAT_REP ::= VAX_Float | IEEE_Float *** 1470,1478 **** This pragma is implemented only in the OpenVMS implementation of GNAT@. It allows control over the internal representation chosen for the predefined floating point types declared in the packages @code{Standard} and ! @code{System}. For further details on this pragma, see the ! DEC Ada Language Reference Manual, section 3.5.7a. Note that to use this ! pragma, the standard runtime libraries must be recompiled. See the description of the @code{GNAT LIBRARY} command in the OpenVMS version of the GNAT Users Guide for details on the use of this command. --- 1483,1491 ---- This pragma is implemented only in the OpenVMS implementation of GNAT@. It allows control over the internal representation chosen for the predefined floating point types declared in the packages @code{Standard} and ! @code{System}. For further details on this pragma, see the ! DEC Ada Language Reference Manual, section 3.5.7a. Note that to use this ! pragma, the standard runtime libraries must be recompiled. See the description of the @code{GNAT LIBRARY} command in the OpenVMS version of the GNAT Users Guide for details on the use of this command. *************** CLASS_NAME ::= ubs | ubsb | uba | s | sb *** 1561,1586 **** @end smallexample This pragma is used in conjunction with a pragma @code{Import} to ! specify additional information for an imported function. The pragma @code{Import} (or equivalent pragma @code{Interface}) must precede the @code{Import_Function} pragma and both must appear in the same declarative part as the function specification. The @var{Internal_Name} argument must uniquely designate the function to which the ! pragma applies. If more than one function name exists of this name in the declarative part you must use the @code{Parameter_Types} and @var{Result_Type} parameters to achieve the required unique ! designation. Subtype marks in these parameters must exactly match the subtypes in the corresponding function specification, using positional notation to match parameters with subtype marks. You may optionally use the @var{Mechanism} and @var{Result_Mechanism} parameters to specify passing mechanisms for the ! parameters and result. If you specify a single mechanism name, it applies to all parameters. Otherwise you may specify a mechanism on a parameter by parameter basis using either positional or named ! notation. If the mechanism is not specified, the default mechanism is used. @cindex OpenVMS --- 1574,1599 ---- @end smallexample This pragma is used in conjunction with a pragma @code{Import} to ! specify additional information for an imported function. The pragma @code{Import} (or equivalent pragma @code{Interface}) must precede the @code{Import_Function} pragma and both must appear in the same declarative part as the function specification. The @var{Internal_Name} argument must uniquely designate the function to which the ! pragma applies. If more than one function name exists of this name in the declarative part you must use the @code{Parameter_Types} and @var{Result_Type} parameters to achieve the required unique ! designation. Subtype marks in these parameters must exactly match the subtypes in the corresponding function specification, using positional notation to match parameters with subtype marks. You may optionally use the @var{Mechanism} and @var{Result_Mechanism} parameters to specify passing mechanisms for the ! parameters and result. If you specify a single mechanism name, it applies to all parameters. Otherwise you may specify a mechanism on a parameter by parameter basis using either positional or named ! notation. If the mechanism is not specified, the default mechanism is used. @cindex OpenVMS *************** It specifies that the designated paramet *** 1592,1598 **** are optional, meaning that they are not passed at the generated code level (this is distinct from the notion of optional parameters in Ada where the parameters are passed anyway with the designated optional ! parameters). All optional parameters must be of mode @code{IN} and have default parameter values that are either known at compile time expressions, or uses of the @code{'Null_Parameter} attribute. --- 1605,1611 ---- are optional, meaning that they are not passed at the generated code level (this is distinct from the notion of optional parameters in Ada where the parameters are passed anyway with the designated optional ! parameters). All optional parameters must be of mode @code{IN} and have default parameter values that are either known at compile time expressions, or uses of the @code{'Null_Parameter} attribute. *************** extended rules for external symbols, is *** 1618,1624 **** the normal @code{Import} pragma applied to an object. Unlike the subprogram case, you need not use a separate @code{Import} pragma, although you may do so (and probably should do so from a portability ! point of view). @var{size} is syntax checked, but otherwise ignored by GNAT@. @findex Import_Procedure --- 1631,1637 ---- the normal @code{Import} pragma applied to an object. Unlike the subprogram case, you need not use a separate @code{Import} pragma, although you may do so (and probably should do so from a portability ! point of view). @var{size} is syntax checked, but otherwise ignored by GNAT@. @findex Import_Procedure *************** CLASS_NAME ::= ubs | ubsb | uba | s | sb *** 1702,1715 **** This pragma is identical to @code{Import_Procedure} except that the first parameter of @var{local_name}, which must be present, must be of mode @code{OUT}, and externally the subprogram is treated as a function ! with this parameter as the result of the function. The purpose of this capability is to allow the use of @code{OUT} and @code{IN OUT} parameters in interfacing to external functions (which are not permitted in Ada functions). You may optionally use the @code{Mechanism} parameters to specify passing mechanisms for the parameters. If you specify a single mechanism name, it applies to all parameters. Otherwise you may specify a mechanism on a parameter by parameter ! basis using either positional or named notation. If the mechanism is not specified, the default mechanism is used. Note that it is important to use this pragma in conjunction with a separate --- 1715,1728 ---- This pragma is identical to @code{Import_Procedure} except that the first parameter of @var{local_name}, which must be present, must be of mode @code{OUT}, and externally the subprogram is treated as a function ! with this parameter as the result of the function. The purpose of this capability is to allow the use of @code{OUT} and @code{IN OUT} parameters in interfacing to external functions (which are not permitted in Ada functions). You may optionally use the @code{Mechanism} parameters to specify passing mechanisms for the parameters. If you specify a single mechanism name, it applies to all parameters. Otherwise you may specify a mechanism on a parameter by parameter ! basis using either positional or named notation. If the mechanism is not specified, the default mechanism is used. Note that it is important to use this pragma in conjunction with a separate *************** pragma Initialize_Scalars; *** 1728,1734 **** @noindent This pragma is similar to @code{Normalize_Scalars} conceptually but has ! two important differences. First, there is no requirement for the pragma to be used uniformly in all units of a partition, in particular, it is fine to use this just for some or all of the application units of a partition, without needing to recompile the run-time library. --- 1741,1747 ---- @noindent This pragma is similar to @code{Normalize_Scalars} conceptually but has ! two important differences. First, there is no requirement for the pragma to be used uniformly in all units of a partition, in particular, it is fine to use this just for some or all of the application units of a partition, without needing to recompile the run-time library. *************** without needing to recompile the run-tim *** 1736,1761 **** In the case where some units are compiled with the pragma, and some without, then a declaration of a variable where the type is defined in package Standard or is locally declared will always be subject to initialization, ! as will any declaration of a scalar variable. For composite variables, whether the variable is initialized may also depend on whether the package in which the type of the variable is declared is compiled with the pragma. The other important difference is that there is control over the value used ! for initializing scalar objects. At bind time, you can select whether to initialize with invalid values (like Normalize_Scalars), or with high or ! low values, or with a specified bit pattern. See the users guide for binder options for specifying these cases. This means that you can compile a program, and then without having to recompile the program, you can run it with different values being used for initializing otherwise uninitialized values, to test if your program ! behavior depends on the choice. Of course the behavior should not change, and if it does, then most likely you have an erroneous reference to an uninitialized value. Note that pragma @code{Initialize_Scalars} is particularly useful in conjunction with the enhanced validity checking that is now provided ! in @code{GNAT}, which checks for invalid values under more conditions. Using this feature (see description of the @code{-gnatv} flag in the users guide) in conjunction with pragma @code{Initialize_Scalars} provides a powerful new tool to assist in the detection of problems --- 1749,1774 ---- In the case where some units are compiled with the pragma, and some without, then a declaration of a variable where the type is defined in package Standard or is locally declared will always be subject to initialization, ! as will any declaration of a scalar variable. For composite variables, whether the variable is initialized may also depend on whether the package in which the type of the variable is declared is compiled with the pragma. The other important difference is that there is control over the value used ! for initializing scalar objects. At bind time, you can select whether to initialize with invalid values (like Normalize_Scalars), or with high or ! low values, or with a specified bit pattern. See the users guide for binder options for specifying these cases. This means that you can compile a program, and then without having to recompile the program, you can run it with different values being used for initializing otherwise uninitialized values, to test if your program ! behavior depends on the choice. Of course the behavior should not change, and if it does, then most likely you have an erroneous reference to an uninitialized value. Note that pragma @code{Initialize_Scalars} is particularly useful in conjunction with the enhanced validity checking that is now provided ! in GNAT, which checks for invalid values under more conditions. Using this feature (see description of the @code{-gnatv} flag in the users guide) in conjunction with pragma @code{Initialize_Scalars} provides a powerful new tool to assist in the detection of problems *************** pragma Inline_Always (NAME [, NAME]); *** 1771,1777 **** @end smallexample @noindent ! Similar to pragma @code{Inline} except that inlining is not subject to the use of option @code{-gnatn} for inter-unit inlining. @findex Inline_Generic --- 1784,1790 ---- @end smallexample @noindent ! Similar to pragma @code{Inline} except that inlining is not subject to the use of option @code{-gnatn} for inter-unit inlining. @findex Inline_Generic *************** pragma Inline_Generic (generic_package_N *** 1785,1791 **** @noindent This is implemented for compatibility with DEC Ada 83 and is recognized, ! but otherwise ignored, by GNAT@. All generic instantiations are inlined by default when using GNAT@. @findex Interface --- 1798,1804 ---- @noindent This is implemented for compatibility with DEC Ada 83 and is recognized, ! but otherwise ignored, by GNAT@. All generic instantiations are inlined by default when using GNAT@. @findex Interface *************** pragma Interface ( *** 1803,1810 **** @noindent This pragma is identical in syntax and semantics to ! the standard Ada 95 pragma @code{Import}. It is provided for compatibility ! with Ada 83. The definition is upwards compatible both with pragma @code{Interface} as defined in the Ada 83 Reference Manual, and also with some extended implementations of this pragma in certain Ada 83 implementations. --- 1816,1823 ---- @noindent This pragma is identical in syntax and semantics to ! the standard Ada 95 pragma @code{Import}. It is provided for compatibility ! with Ada 83. The definition is upwards compatible both with pragma @code{Interface} as defined in the Ada 83 Reference Manual, and also with some extended implementations of this pragma in certain Ada 83 implementations. *************** pragma Interface_Name ( *** 1824,1830 **** @noindent This pragma provides an alternative way of specifying the interface name for an interfaced subprogram, and is provided for compatibility with Ada ! 83 compilers that use the pragma for this purpose. You must provide at least one of @var{External_Name} or @var{Link_Name}. @findex License --- 1837,1843 ---- @noindent This pragma provides an alternative way of specifying the interface name for an interfaced subprogram, and is provided for compatibility with Ada ! 83 compilers that use the pragma for this purpose. You must provide at least one of @var{External_Name} or @var{Link_Name}. @findex License *************** pragma License (Unrestricted | GPL | Mod *** 1839,1845 **** @noindent This pragma is provided to allow automated checking for appropriate license ! conditions with respect to the standard and modified GPL@. A pragma License, which is a configuration pragma that typically appears at the start of a source file or in a separate @file{gnat.adc} file, specifies the licensing conditions of a unit as follows: --- 1852,1858 ---- @noindent This pragma is provided to allow automated checking for appropriate license ! conditions with respect to the standard and modified GPL@. A pragma @code{License}, which is a configuration pragma that typically appears at the start of a source file or in a separate @file{gnat.adc} file, specifies the licensing conditions of a unit as follows: *************** therefore cannot be @code{with}'ed by a *** 1858,1871 **** This is used for a unit licensed under the GNAT modified GPL that includes a special exception paragraph that specifically permits the inclusion of the unit in programs without requiring the entire program to be released ! under the GPL@. This is the license used for the GNAT run-time which ensures that the run-time can be used freely in any program without GPL concerns. @item Restricted This is used for a unit that is restricted in that it is not permitted to ! depend on units that are licensed under the GPL@. Typical examples are proprietary code that is to be released under more restrictive license ! conditions. Note that restricted units are permitted to @code{with} units which are licensed under the modified GPL (this is the whole point of the modified GPL). --- 1871,1884 ---- This is used for a unit licensed under the GNAT modified GPL that includes a special exception paragraph that specifically permits the inclusion of the unit in programs without requiring the entire program to be released ! under the GPL@. This is the license used for the GNAT run-time which ensures that the run-time can be used freely in any program without GPL concerns. @item Restricted This is used for a unit that is restricted in that it is not permitted to ! depend on units that are licensed under the GPL@. Typical examples are proprietary code that is to be released under more restrictive license ! conditions. Note that restricted units are permitted to @code{with} units which are licensed under the modified GPL (this is the whole point of the modified GPL). *************** modified GPL). *** 1873,1906 **** @noindent Normally a unit with no @code{License} pragma is considered to have an ! unknown license, and no checking is done. However, standard GNAT headers are recognized, and license information is derived from them as follows. @itemize @bullet ! A GNAT license header starts with a line containing 78 hyphens. The following comment text is searched for the appearence of any of the following strings. ! If the string "GNU General Public License" is found, then the unit is assumed ! to have GPL license, unless the string "As a special exception" follows, in which case the license is assumed to be modified GPL@. If one of the strings ! "This specification is adapated from the Ada Semantic Interface" or ! "This specification is derived from the Ada Reference Manual" is found then the unit is assumed to be unrestricted. @end itemize @noindent These default actions means that a program with a restricted license pragma will automatically get warnings if a GPL unit is inappropriately ! @code{with}'ed. For example, the program: @smallexample with Sem_Ch3; with GNAT.Sockets; procedure Secret_Stuff is ! ... end Secret_Stuff @end smallexample --- 1886,1919 ---- @noindent Normally a unit with no @code{License} pragma is considered to have an ! unknown license, and no checking is done. However, standard GNAT headers are recognized, and license information is derived from them as follows. @itemize @bullet ! A GNAT license header starts with a line containing 78 hyphens. The following comment text is searched for the appearence of any of the following strings. ! If the string ``GNU General Public License'' is found, then the unit is assumed ! to have GPL license, unless the string ``As a special exception'' follows, in which case the license is assumed to be modified GPL@. If one of the strings ! ``This specification is adapated from the Ada Semantic Interface'' or ! ``This specification is derived from the Ada Reference Manual'' is found then the unit is assumed to be unrestricted. @end itemize @noindent These default actions means that a program with a restricted license pragma will automatically get warnings if a GPL unit is inappropriately ! @code{with}'ed. For example, the program: @smallexample with Sem_Ch3; with GNAT.Sockets; procedure Secret_Stuff is ! @dots{} end Secret_Stuff @end smallexample *************** if compiled with pragma @code{License} ( *** 1909,1920 **** @file{gnat.adc} file will generate the warning: @smallexample ! 1. with Sem_Ch3; | >>> license of withed unit "Sem_Ch3" is incompatible ! 2. with GNAT.Sockets; ! 3. procedure Secret_Stuff is @end smallexample @noindent Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT --- 1922,1933 ---- @file{gnat.adc} file will generate the warning: @smallexample ! 1. with Sem_Ch3; | >>> license of withed unit "Sem_Ch3" is incompatible ! 2. with GNAT.Sockets; ! 3. procedure Secret_Stuff is @end smallexample @noindent Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT *************** pragma Link_With ("-labc -ldef"); *** 1943,1949 **** @noindent results in passing the strings @code{-labc} and @code{-ldef} as two ! separate arguments to the linker. @findex Linker_Alias @item pragma Linker_Alias --- 1956,1963 ---- @noindent results in passing the strings @code{-labc} and @code{-ldef} as two ! separate arguments to the linker. In addition pragma Link_With allows ! multiple arguments, with the same effect as successive pragmas. @findex Linker_Alias @item pragma Linker_Alias *************** pragma Linker_Alias ( *** 1957,1963 **** @end smallexample @noindent ! This pragma establishes a linker alias for the given named entity. For further details on the exact effect, consult the GCC manual. @findex Linker_Section --- 1971,1977 ---- @end smallexample @noindent ! This pragma establishes a linker alias for the given named entity. For further details on the exact effect, consult the GCC manual. @findex Linker_Section *************** pragma No_Run_Time; *** 1986,1994 **** @noindent This is a configuration pragma that makes sure the user code does not ! use nor need anything from the GNAT run time. This is mostly useful in ! context where code certification is required. Please consult the High ! Integrity product documentation for additional information. @findex Normalize_Scalars @item pragma Normalize_Scalars --- 2000,2008 ---- @noindent This is a configuration pragma that makes sure the user code does not ! use nor need anything from the GNAT run time. This is mostly useful in ! context where code certification is required. Please consult the ! @cite{GNAT Pro High-Integrity Edition User's Guide} for additional information. @findex Normalize_Scalars @item pragma Normalize_Scalars *************** pragma Normalize_Scalars; *** 2000,2028 **** @end smallexample @noindent ! This is a language defined pragma which is fully implemented in GNAT@. The effect is to cause all scalar objects that are not otherwise initialized ! to be initialized. The initial values are implementation dependent and are as follows: @table @code @item Standard.Character @noindent Objects whose root type is Standard.Character are initialized to ! Character'Last. This will be out of range of the subtype only if the subtype range excludes this value. @item Standard.Wide_Character @noindent Objects whose root type is Standard.Wide_Character are initialized to ! Wide_Character'Last. This will be out of range of the subtype only if the subtype range excludes this value. @item Integer types @noindent Objects of an integer type are initialized to base_type'First, where ! base_type is the base type of the object type. This will be out of range ! of the subtype only if the subtype range excludes this value. For example, if you declare the subtype: @smallexample --- 2014,2042 ---- @end smallexample @noindent ! This is a language defined pragma which is fully implemented in GNAT@. The effect is to cause all scalar objects that are not otherwise initialized ! to be initialized. The initial values are implementation dependent and are as follows: @table @code @item Standard.Character @noindent Objects whose root type is Standard.Character are initialized to ! Character'Last. This will be out of range of the subtype only if the subtype range excludes this value. @item Standard.Wide_Character @noindent Objects whose root type is Standard.Wide_Character are initialized to ! Wide_Character'Last. This will be out of range of the subtype only if the subtype range excludes this value. @item Integer types @noindent Objects of an integer type are initialized to base_type'First, where ! base_type is the base type of the object type. This will be out of range ! of the subtype only if the subtype range excludes this value. For example, if you declare the subtype: @smallexample *************** This will be out of range of the subtype *** 2040,2053 **** excludes this value. @item Modular types ! Objects of a modular type are initialized to typ'Last. This will be out of range of the subtype only if the subtype excludes this value. @item Enumeration types Objects of an enumeration type are initialized to all one-bits, i.e.@: to ! the value 2 ** typ'Size - 1. This will be out of range of the enumeration subtype in all cases except where the subtype contains exactly ! 2**8, 2**16, or 2**32. @end table --- 2054,2067 ---- excludes this value. @item Modular types ! Objects of a modular type are initialized to typ'Last. This will be out of range of the subtype only if the subtype excludes this value. @item Enumeration types Objects of an enumeration type are initialized to all one-bits, i.e.@: to ! the value @code{2 ** typ'Size - 1}. This will be out of range of the enumeration subtype in all cases except where the subtype contains exactly ! 2**8, 2**16, or 2**32 elements. @end table *************** FLOAT_FORMAT ::= D_Float | G_Float *** 2067,2078 **** This pragma is implemented only in the OpenVMS implementation of GNAT@. It allows control over the internal representation chosen for the predefined type @code{Long_Float} and for floating point type representations with ! @code{digits} specified in the range 7 .. 15. For further details on this pragma, see the ! DEC Ada Language Reference Manual, section 3.5.7b. Note that to use this ! pragma, the standard runtime libraries must be recompiled. See the description of the @code{GNAT LIBRARY} command in the OpenVMS version ! of the GNAT Users Guide for details on the use of this command. @findex Machine_Attribute @item pragma Machine_Attribute @dots{} --- 2081,2092 ---- This pragma is implemented only in the OpenVMS implementation of GNAT@. It allows control over the internal representation chosen for the predefined type @code{Long_Float} and for floating point type representations with ! @code{digits} specified in the range 7 through 15. For further details on this pragma, see the ! @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use this ! pragma, the standard runtime libraries must be recompiled. See the description of the @code{GNAT LIBRARY} command in the OpenVMS version ! of the GNAT User's Guide for details on the use of this command. @findex Machine_Attribute @item pragma Machine_Attribute @dots{} *************** pragma Machine_Attribute ( *** 2086,2094 **** @end smallexample Machine dependent attributes can be specified for types and/or ! declarations. Currently only subprogram entities are supported. This ! pragma is semantically equivalent to @code{__attribute__(( ! @var{string_expression}))} in GNU C, where @code{string_expression}> is recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the configuration header file @file{tm.h} for each machine. See the GCC --- 2100,2109 ---- @end smallexample Machine dependent attributes can be specified for types and/or ! declarations. Currently only subprogram entities are supported. This ! pragma is semantically equivalent to ! @code{__attribute__((@var{string_expression}))} in GNU C, ! where @code{@var{string_expression}} is recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the configuration header file @file{tm.h} for each machine. See the GCC *************** MAIN_STORAGE_OPTION ::= *** 2111,2118 **** @end smallexample @noindent ! This pragma is provided for compatibility with OpenVMS Vax Systems. It has ! no effect in GNAT, other than being syntax checked. Note that the pragma also has no effect in DEC Ada 83 for OpenVMS Alpha Systems. @findex No_Return --- 2126,2133 ---- @end smallexample @noindent ! This pragma is provided for compatibility with OpenVMS Vax Systems. It has ! no effect in GNAT, other than being syntax checked. Note that the pragma also has no effect in DEC Ada 83 for OpenVMS Alpha Systems. @findex No_Return *************** pragma No_Return (procedure_LOCAL_NAME); *** 2126,2135 **** @noindent @var{procedure_local_NAME} must refer to one or more procedure ! declarations in the current declarative part. A procedure to which this pragma is applied may not contain any explicit @code{return} statements, and also may not contain any implicit return statements from falling off ! the end of a statement sequence. One use of this pragma is to identify procedures whose only purpose is to raise an exception. Another use of this pragma is to suppress incorrect warnings about --- 2141,2150 ---- @noindent @var{procedure_local_NAME} must refer to one or more procedure ! declarations in the current declarative part. A procedure to which this pragma is applied may not contain any explicit @code{return} statements, and also may not contain any implicit return statements from falling off ! the end of a statement sequence. One use of this pragma is to identify procedures whose only purpose is to raise an exception. Another use of this pragma is to suppress incorrect warnings about *************** pragma Passive ([Semaphore | No]); *** 2146,2159 **** @end smallexample @noindent ! Syntax checked, but otherwise ignored by GNAT@. This is recognized for compatibility with DEC Ada 83 implementations, where it is used within a task definition to request that a task be made passive. If the argument @code{Semaphore} is present, or no argument is omitted, then DEC Ada 83 treats the pragma as an assertion that the containing task is passive and that optimization of context switch with this task is permitted and desired. If the argument @code{No} is present, the task must not be ! optimized. GNAT does not attempt to optimize any tasks in this manner (since protected objects are available in place of passive tasks). @findex Polling --- 2161,2174 ---- @end smallexample @noindent ! Syntax checked, but otherwise ignored by GNAT@. This is recognized for compatibility with DEC Ada 83 implementations, where it is used within a task definition to request that a task be made passive. If the argument @code{Semaphore} is present, or no argument is omitted, then DEC Ada 83 treats the pragma as an assertion that the containing task is passive and that optimization of context switch with this task is permitted and desired. If the argument @code{No} is present, the task must not be ! optimized. GNAT does not attempt to optimize any tasks in this manner (since protected objects are available in place of passive tasks). @findex Polling *************** pragma Polling (ON | OFF); *** 2166,2200 **** @end smallexample @noindent ! This pragma controls the generation of polling code. This is normally off. If @code{pragma Polling (ON)} is used then periodic calls are generated to ! the routine Ada.Exceptions.Poll. This routine is a separate unit in the ! runtime library, and can be found in file a-excpol.adb. ! Pragma polling can appear as a configuration pragma (for example it can be ! placed in the gnat.adc file) to enable polling globally, or it can be used in the statement or declaration sequence to control polling more locally. A call to the polling routine is generated at the start of every loop and ! at the start of every subprogram call. This guarantees that the Poll routine is called frequently, and places an upper bound (determined by ! the complexity of the code) on the period between two Poll calls. The primary purpose of the polling interface is to enable asynchronous aborts on targets that cannot otherwise support it (for example Windows NT), but it may be used for any other purpose requiring periodic polling. ! The standard version is null, and can be replaced by a user program. This ! will require re-compilation of the Ada.Exceptions package that can be found ! in files a-except.ads/adb. ! A standard alternative unit (called 4wexcpol.adb in the standard GNAT distribution) is used to enable the asynchronous abort capability on ! targets that do not normally support the capability. The version of Poll in this file makes a call to the appropriate runtime routine to test for an abort condition. ! Note that polling can also be enabled by use of the -gnatP switch. See ! the GNAT User's Guide for details. @findex Propagate_Exceptions @cindex Zero Cost Exceptions --- 2181,2215 ---- @end smallexample @noindent ! This pragma controls the generation of polling code. This is normally off. If @code{pragma Polling (ON)} is used then periodic calls are generated to ! the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the ! runtime library, and can be found in file @file{a-excpol.adb}. ! Pragma @code{Polling} can appear as a configuration pragma (for example it can be ! placed in the @file{gnat.adc} file) to enable polling globally, or it can be used in the statement or declaration sequence to control polling more locally. A call to the polling routine is generated at the start of every loop and ! at the start of every subprogram call. This guarantees that the @code{Poll} routine is called frequently, and places an upper bound (determined by ! the complexity of the code) on the period between two @code{Poll} calls. The primary purpose of the polling interface is to enable asynchronous aborts on targets that cannot otherwise support it (for example Windows NT), but it may be used for any other purpose requiring periodic polling. ! The standard version is null, and can be replaced by a user program. This ! will require re-compilation of the @code{Ada.Exceptions} package that can be found ! in files @file{a-except.ads} and @file{a-except.adb}. ! A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT distribution) is used to enable the asynchronous abort capability on ! targets that do not normally support the capability. The version of @code{Poll} in this file makes a call to the appropriate runtime routine to test for an abort condition. ! Note that polling can also be enabled by use of the @code{-gnatP} switch. See ! the @cite{GNAT User's Guide} for details. @findex Propagate_Exceptions @cindex Zero Cost Exceptions *************** pragma Propagate_Exceptions (subprogram_ *** 2209,2236 **** @noindent This pragma indicates that the given entity, which is the name of an imported foreign-language subprogram may receive an Ada exception, ! and that the exception should be propagated. It is relevant only if zero cost exception handling is in use, and is thus never needed if ! the alternative longjmp/setjmp implementation of exceptions is used (although it is harmless to use it in such cases). The implementation of fast exceptions always properly propagates exceptions through Ada code, as described in the Ada Reference Manual. However, this manual is silent about the propagation of exceptions ! through foreign code. For example, consider the situation where @code{P1} calls @code{P2}, and @code{P2} calls @code{P3}, where @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@. ! @code{P3} raises an Ada exception. The question is whether or not it will be propagated through @code{P2} and can be handled in @code{P1}. ! For the longjmp/setjmp implementation of exceptions, the answer is ! always yes. For some targets on which zero cost exception handling ! is implemented, the answer is also always yes. However, there are some targets, notably in the current version all x86 architecture targets, in which the answer is that such propagation does not ! happen automatically. If such propagation is required on these targets, it is mandatory to use @code{Propagate_Exceptions} to name all foreign language routines through which Ada exceptions may be propagated. --- 2224,2251 ---- @noindent This pragma indicates that the given entity, which is the name of an imported foreign-language subprogram may receive an Ada exception, ! and that the exception should be propagated. It is relevant only if zero cost exception handling is in use, and is thus never needed if ! the alternative @code{longjmp} / @code{setjmp} implementation of exceptions is used (although it is harmless to use it in such cases). The implementation of fast exceptions always properly propagates exceptions through Ada code, as described in the Ada Reference Manual. However, this manual is silent about the propagation of exceptions ! through foreign code. For example, consider the situation where @code{P1} calls @code{P2}, and @code{P2} calls @code{P3}, where @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@. ! @code{P3} raises an Ada exception. The question is whether or not it will be propagated through @code{P2} and can be handled in @code{P1}. ! For the @code{longjmp} / @code{setjmp} implementation of exceptions, the answer is ! always yes. For some targets on which zero cost exception handling ! is implemented, the answer is also always yes. However, there are some targets, notably in the current version all x86 architecture targets, in which the answer is that such propagation does not ! happen automatically. If such propagation is required on these targets, it is mandatory to use @code{Propagate_Exceptions} to name all foreign language routines through which Ada exceptions may be propagated. *************** pragma Pure_Function ([Entity =>] functi *** 2266,2301 **** This pragma appears in the same declarative part as a function declaration (or a set of function declarations if more than one overloaded declaration exists, in which case the pragma applies ! to all entities). If specifies that the function @code{Entity} is ! to be considered pure for the purposes of code generation. This means that the compiler can assume that there are no side effects, and in particular that two calls with identical arguments produce the ! same result. It also means that the function can be used in an address clause. Note that, quite deliberately, there are no static checks to try ! to ensure that this promise is met, so @var{Pure_Function} can be used with functions that are conceptually pure, even if they do modify ! global variables. For example, a square root function that is instrumented to count the number of times it is called is still conceptually pure, and can still be optimized, even though it ! modifies a global variable (the count). Memo functions are another example (where a table of previous calls is kept and consulted to avoid re-computation). @findex Pure Note: Most functions in a @code{Pure} package are automatically pure, and ! there is no need to use pragma @code{Pure_Function} for such functions. An exception is any function that has at least one formal of type ! @code{System.Address} or a type derived from it. Such functions are not considered pure by default, since the compiler assumes that the @code{Address} parameter may be functioning as a pointer and that the ! referenced data may change even if the address value does not. The use ! of pragma Pure_Function for such a function will override this default assumption, and cause the compiler to treat such a function as pure. Note: If pragma @code{Pure_Function} is applied to a renamed function, it ! applies to the underlying renamed function. This can be used to disambiguate cases of overloading where some but not all functions in a set of overloaded functions are to be designated as pure. --- 2281,2316 ---- This pragma appears in the same declarative part as a function declaration (or a set of function declarations if more than one overloaded declaration exists, in which case the pragma applies ! to all entities). If specifies that the function @code{Entity} is ! to be considered pure for the purposes of code generation. This means that the compiler can assume that there are no side effects, and in particular that two calls with identical arguments produce the ! same result. It also means that the function can be used in an address clause. Note that, quite deliberately, there are no static checks to try ! to ensure that this promise is met, so @code{Pure_Function} can be used with functions that are conceptually pure, even if they do modify ! global variables. For example, a square root function that is instrumented to count the number of times it is called is still conceptually pure, and can still be optimized, even though it ! modifies a global variable (the count). Memo functions are another example (where a table of previous calls is kept and consulted to avoid re-computation). @findex Pure Note: Most functions in a @code{Pure} package are automatically pure, and ! there is no need to use pragma @code{Pure_Function} for such functions. An exception is any function that has at least one formal of type ! @code{System.Address} or a type derived from it. Such functions are not considered pure by default, since the compiler assumes that the @code{Address} parameter may be functioning as a pointer and that the ! referenced data may change even if the address value does not. The use ! of pragma @code{Pure_Function} for such a function will override this default assumption, and cause the compiler to treat such a function as pure. Note: If pragma @code{Pure_Function} is applied to a renamed function, it ! applies to the underlying renamed function. This can be used to disambiguate cases of overloading where some but not all functions in a set of overloaded functions are to be designated as pure. *************** For the Ravenscar pragma the value if al *** 2395,2416 **** Tasks which terminate are erroneous. @item No_Entry_Queue ! No task can be queued on a protected entry. Note that this restrictions is ! checked at run time. The violation of this restriction generates a Program_Error exception. @end table @noindent ! This set of restrictions corresponds to the definition of the "Ravenscar ! Profile" for limited tasking, devised and published by the International ! Workshop On Real Time Ada", 1997. The above set is a superset of the restrictions provided by pragma @code{Restricted_Run_Time}, it includes six additional restrictions (@code{Boolean_Entry_Barriers}, @code{No_Select_Statements}, @code{No_Calendar}, @code{Static_Storage_Size}, ! @code{No_Relative_Delay} and @code{No_Task_Termination}). This means ! that pragma Ravenscar, like the pragma Restricted_Run_Time, automatically causes the use of a simplified, more efficient version of the tasking run-time system. --- 2410,2431 ---- Tasks which terminate are erroneous. @item No_Entry_Queue ! No task can be queued on a protected entry. Note that this restrictions is ! checked at run time. The violation of this restriction generates a Program_Error exception. @end table @noindent ! This set of restrictions corresponds to the definition of the ``Ravenscar ! Profile'' for limited tasking, devised and published by the @cite{International ! Real-Time Ada Workshop}, 1997. The above set is a superset of the restrictions provided by pragma @code{Restricted_Run_Time}, it includes six additional restrictions (@code{Boolean_Entry_Barriers}, @code{No_Select_Statements}, @code{No_Calendar}, @code{Static_Storage_Size}, ! @code{No_Relative_Delay} and @code{No_Task_Termination}). This means ! that pragma @code{Ravenscar}, like the pragma @code{Restricted_Run_Time}, automatically causes the use of a simplified, more efficient version of the tasking run-time system. *************** pragma Share_Generic (NAME @{, NAME@}); *** 2461,2468 **** @noindent This pragma is recognized for compatibility with other Ada compilers ! but is ignored by GNAT@. GNAT does not provide the capability for ! sharing of generic code. All generic instantiations result in making an inlined copy of the template with appropriate substitutions. @findex Source_File_Name --- 2476,2483 ---- @noindent This pragma is recognized for compatibility with other Ada compilers ! but is ignored by GNAT@. GNAT does not provide the capability for ! sharing of generic code. All generic instantiations result in making an inlined copy of the template with appropriate substitutions. @findex Source_File_Name *************** pragma Source_File_Name ( *** 2481,2491 **** @end smallexample @noindent ! Use this to override the normal naming convention. It is a configuration pragma, and so has the usual applicability of configuration pragmas (i.e.@: it applies to either an entire partition, or to all units in a compilation, or to a single unit, depending on how it is used. ! @var{unit_name} is mapped to @var{file_name_literal}. The identifier for the second argument is required, and indicates whether this is the file name for the spec or for the body. --- 2496,2506 ---- @end smallexample @noindent ! Use this to override the normal naming convention. It is a configuration pragma, and so has the usual applicability of configuration pragmas (i.e.@: it applies to either an entire partition, or to all units in a compilation, or to a single unit, depending on how it is used. ! @var{unit_name} is mapped to @var{file_name_literal}. The identifier for the second argument is required, and indicates whether this is the file name for the spec or for the body. *************** CASING_SPEC ::= Lowercase | Uppercase | *** 2515,2528 **** @noindent The first argument is a pattern that contains a single asterisk indicating the point at which the unit name is to be inserted in the pattern string ! to form the file name. The second argument is optional. If present it specifies the casing of the unit name in the resulting file name string. ! The default is lower case. Finally the third argument allows for systematic replacement of any dots in the unit name by the specified string literal. For more details on the use of the @code{Source_File_Name} pragma, ! see the sections "Using Other File Names", and "Alternative File ! Naming Schemes" in the GNAT User's Guide. @findex Source_Reference @item pragma Source_Reference --- 2530,2543 ---- @noindent The first argument is a pattern that contains a single asterisk indicating the point at which the unit name is to be inserted in the pattern string ! to form the file name. The second argument is optional. If present it specifies the casing of the unit name in the resulting file name string. ! The default is lower case. Finally the third argument allows for systematic replacement of any dots in the unit name by the specified string literal. For more details on the use of the @code{Source_File_Name} pragma, ! see the sections ``Using Other File Names'' and ! ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}. @findex Source_Reference @item pragma Source_Reference *************** pragma Source_Reference (INTEGER_LITERAL *** 2538,2551 **** This pragma must appear as the first line of a source file. @var{integer_literal} is the logical line number of the line following the pragma line (for use in error messages and debugging ! information). @var{string_literal} is a static string constant that specifies the file name to be used in error messages and debugging ! information. This is most notably used for the output of @code{gnatchop} ! with the @samp{-r} switch, to make sure that the original unchopped source file is the one referred to. The second argument must be a string literal, it cannot be a static ! string expression other than a string literal. This is because its value is needed for error messages issued by all phases of the compiler. @findex Stream_Convert --- 2553,2566 ---- This pragma must appear as the first line of a source file. @var{integer_literal} is the logical line number of the line following the pragma line (for use in error messages and debugging ! information). @var{string_literal} is a static string constant that specifies the file name to be used in error messages and debugging ! information. This is most notably used for the output of @code{gnatchop} ! with the @code{-r} switch, to make sure that the original unchopped source file is the one referred to. The second argument must be a string literal, it cannot be a static ! string expression other than a string literal. This is because its value is needed for error messages issued by all phases of the compiler. @findex Stream_Convert *************** pragma Stream_Convert ( *** 2562,2577 **** @noindent This pragma provides an efficient way of providing stream functions for ! types defined in packages. Not only is it simpler to use than declaring the necessary functions with attribute representation clauses, but more significantly, it allows the declaration to made in such a way that the ! stream packages are not loaded unless they are needed. The use of the Stream_Convert pragma adds no overhead at all, unless the stream attributes are actually used on the designated type. The first argument specifies the type for which stream functions are ! provided. The second parameter provides a function used to read values ! of this type. It must name a function whose argument type may be any subtype, and whose returned type must be the type given as the first argument to the pragma. --- 2577,2592 ---- @noindent This pragma provides an efficient way of providing stream functions for ! types defined in packages. Not only is it simpler to use than declaring the necessary functions with attribute representation clauses, but more significantly, it allows the declaration to made in such a way that the ! stream packages are not loaded unless they are needed. The use of the Stream_Convert pragma adds no overhead at all, unless the stream attributes are actually used on the designated type. The first argument specifies the type for which stream functions are ! provided. The second parameter provides a function used to read values ! of this type. It must name a function whose argument type may be any subtype, and whose returned type must be the type given as the first argument to the pragma. *************** and the return type must be the same as *** 2589,2595 **** The effect is to first call the Write function to convert to the given stream type, and then write the result type to the stream. ! The Read and Write functions must not be overloaded subprograms. If necessary renamings can be supplied to meet this requirement. The usage of this attribute is best illustrated by a simple example, taken from the GNAT implementation of package Ada.Strings.Unbounded: --- 2604,2610 ---- The effect is to first call the Write function to convert to the given stream type, and then write the result type to the stream. ! The Read and Write functions must not be overloaded subprograms. If necessary renamings can be supplied to meet this requirement. The usage of this attribute is best illustrated by a simple example, taken from the GNAT implementation of package Ada.Strings.Unbounded: *************** pragma Style_Checks (string_LITERAL | AL *** 2633,2660 **** @noindent This pragma is used in conjunction with compiler switches to control the ! built in style checking provided by GNAT@. The compiler switches, if set provide an initial setting for the switches, and this pragma may be used to modify these settings, or the settings may be provided entirely by ! the use of the pragma. This pragma can be used anywhere that a pragma is legal, including use as a configuration pragma (including use in the @file{gnat.adc} file). The form with a string literal specifies which style options are to be ! activated. These are additive, so they apply in addition to any previously ! set style check options. The codes for the options are the same as those ! used in the @code{-gnaty} switch on the @code{gcc} or @code{gnatmake} ! line. For example the following two methods can be used to enable layout checking: @smallexample pragma Style_Checks ("l"); ! gcc -c -gnatyl ... @end smallexample @noindent The form ALL_CHECKS activates all standard checks (its use is equivalent ! to the use of the @code{gnaty} switch with no options. See GNAT User's Guide for details. The forms with @code{Off} and @code{On} --- 2648,2675 ---- @noindent This pragma is used in conjunction with compiler switches to control the ! built in style checking provided by GNAT@. The compiler switches, if set provide an initial setting for the switches, and this pragma may be used to modify these settings, or the settings may be provided entirely by ! the use of the pragma. This pragma can be used anywhere that a pragma is legal, including use as a configuration pragma (including use in the @file{gnat.adc} file). The form with a string literal specifies which style options are to be ! activated. These are additive, so they apply in addition to any previously ! set style check options. The codes for the options are the same as those ! used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}. ! For example the following two methods can be used to enable layout checking: @smallexample pragma Style_Checks ("l"); ! gcc -c -gnatyl @dots{} @end smallexample @noindent The form ALL_CHECKS activates all standard checks (its use is equivalent ! to the use of the @code{gnaty} switch with no options. See GNAT User's Guide for details. The forms with @code{Off} and @code{On} *************** NULL; -- this will *** 2674,2680 **** @noindent Finally the two argument form is allowed only if the first argument is ! @code{On} or @code{Off}. The effect is to turn of semantic style checks for the specified entity, as shown in the following example: @smallexample --- 2689,2695 ---- @noindent Finally the two argument form is allowed only if the first argument is ! @code{On} or @code{Off}. The effect is to turn of semantic style checks for the specified entity, as shown in the following example: @smallexample *************** pragma Suppress_All; *** 2712,2720 **** @noindent This pragma can only appear immediately following a compilation ! unit. The effect is to apply @code{Suppress (All_Checks)} to the unit ! which it follows. This pragma is implemented for compatibility with DEC ! Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal configuration pragma is the preferred usage in GNAT@. @findex Suppress_Initialization --- 2727,2735 ---- @noindent This pragma can only appear immediately following a compilation ! unit. The effect is to apply @code{Suppress (All_Checks)} to the unit ! which it follows. This pragma is implemented for compatibility with DEC ! Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal configuration pragma is the preferred usage in GNAT@. @findex Suppress_Initialization *************** pragma Task_Info (EXPRESSION); *** 2743,2753 **** @noindent This pragma appears within a task definition (like pragma ! @code{Priority}) and applies to the task in which it appears. The argument must be of type @code{System.Task_Info.Task_Info_Type}. The @code{Task_Info} pragma provides system dependent control over aspect of tasking implementation, for example, the ability to map ! tasks to specific processors. For details on the facilities available for the version of GNAT that you are using, see the documentation in the specification of package System.Task_Info in the runtime library. --- 2758,2768 ---- @noindent This pragma appears within a task definition (like pragma ! @code{Priority}) and applies to the task in which it appears. The argument must be of type @code{System.Task_Info.Task_Info_Type}. The @code{Task_Info} pragma provides system dependent control over aspect of tasking implementation, for example, the ability to map ! tasks to specific processors. For details on the facilities available for the version of GNAT that you are using, see the documentation in the specification of package System.Task_Info in the runtime library. *************** pragma Task_Name (string_EXPRESSION); *** 2763,2778 **** @noindent This pragma appears within a task definition (like pragma ! @code{Priority}) and applies to the task in which it appears. The argument must be of type String, and provides a name to be used for ! the task instance when the task is created. Note that this expression is not required to be static, and in particular, it can contain ! references to task discriminants. This facility can be used to provide different names for different tasks as they are created, as illustrated in the example below. The task name is recorded internally in the run-time structures ! and is accessible to tools like the debugger. In addition the routine @code{Ada.Task_Identification.Image} will return this string, with a unique task address appended. --- 2778,2793 ---- @noindent This pragma appears within a task definition (like pragma ! @code{Priority}) and applies to the task in which it appears. The argument must be of type String, and provides a name to be used for ! the task instance when the task is created. Note that this expression is not required to be static, and in particular, it can contain ! references to task discriminants. This facility can be used to provide different names for different tasks as they are created, as illustrated in the example below. The task name is recorded internally in the run-time structures ! and is accessible to tools like the debugger. In addition the routine @code{Ada.Task_Identification.Image} will return this string, with a unique task address appended. *************** pragma Task_Storage *** 2820,2826 **** This pragma specifies the length of the guard area for tasks. The guard area is an additional storage area allocated to a task. A value of zero means that either no guard area is created or a minimal guard area is ! created, depending on the target. This pragma can appear anywhere a @code{Storage_Size} attribute definition clause is allowed for a task type. --- 2835,2841 ---- This pragma specifies the length of the guard area for tasks. The guard area is an additional storage area allocated to a task. A value of zero means that either no guard area is created or a minimal guard area is ! created, depending on the target. This pragma can appear anywhere a @code{Storage_Size} attribute definition clause is allowed for a task type. *************** TITLING_OPTION ::= *** 2856,2864 **** @end smallexample @noindent ! Syntax checked but otherwise ignored by GNAT@. This is a listing control pragma used in DEC Ada 83 implementations to provide a title and/or ! subtitle for the program listing. The program listing generated by GNAT does not have titles or subtitles. Unlike other pragmas, the full flexibility of named notation is allowed --- 2871,2879 ---- @end smallexample @noindent ! Syntax checked but otherwise ignored by GNAT@. This is a listing control pragma used in DEC Ada 83 implementations to provide a title and/or ! subtitle for the program listing. The program listing generated by GNAT does not have titles or subtitles. Unlike other pragmas, the full flexibility of named notation is allowed *************** pragma Unchecked_Union (first_subtype_LO *** 2880,2886 **** This pragma is used to declare that the specified type should be represented in a manner equivalent to a C union type, and is intended only for use in ! interfacing with C code that uses union types. In Ada terms, the named type must obey the following rules: @itemize @bullet --- 2895,2901 ---- This pragma is used to declare that the specified type should be represented in a manner equivalent to a C union type, and is intended only for use in ! interfacing with C code that uses union types. In Ada terms, the named type must obey the following rules: @itemize @bullet *************** discriminant. *** 2917,2925 **** Equality and inequality operations on @code{unchecked_unions} are not available, since there is no discriminant to compare and the compiler ! does not even know how many bits to compare. It is implementation dependent whether this is detected at compile time as an illegality or ! whether it is undetected and considered to be an erroneous construct. In GNAT, a direct comparison is illegal, but GNAT does not attempt to catch the composite case (where two composites are compared that contain an unchecked union component), so such comparisons are simply considered --- 2932,2940 ---- Equality and inequality operations on @code{unchecked_unions} are not available, since there is no discriminant to compare and the compiler ! does not even know how many bits to compare. It is implementation dependent whether this is detected at compile time as an illegality or ! whether it is undetected and considered to be an erroneous construct. In GNAT, a direct comparison is illegal, but GNAT does not attempt to catch the composite case (where two composites are compared that contain an unchecked union component), so such comparisons are simply considered *************** erroneous. *** 2927,2933 **** The layout of the resulting type corresponds exactly to a C union, where each branch of the union corresponds to a single variant in the Ada ! record. The semantics of the Ada program is not changed in any way by the pragma, i.e.@: provided the above restrictions are followed, and no erroneous incorrect references to fields or erroneous comparisons occur, the semantics is exactly as described by the Ada reference manual. --- 2942,2948 ---- The layout of the resulting type corresponds exactly to a C union, where each branch of the union corresponds to a single variant in the Ada ! record. The semantics of the Ada program is not changed in any way by the pragma, i.e.@: provided the above restrictions are followed, and no erroneous incorrect references to fields or erroneous comparisons occur, the semantics is exactly as described by the Ada reference manual. *************** a clean manner. *** 2953,2958 **** --- 2968,2999 ---- The abort only happens if code is being generated. Thus you can use specs of unimplemented packages in syntax or semantic checking mode. + @findex Unreferenced + @item pragma Unreferenced + @cindex Warnings, unreferenced + @noindent + Syntax: + + @smallexample + pragma Unreferenced (local_Name @{, local_Name@}); + @end smallexample + + @noindent + This pragma signals that the entities whose names are listed are + deliberately not referenced. This suppresses warnings about the + entities being unreferenced, and in addition a warning will be + generated if one of these entities is in fact referenced. + + This is particularly useful for clearly signalling that a particular + parameter is not referenced in some particular subprogram implementation + and that this is deliberate. It can also be useful in the case of + objects declared only for their initialization or finalization side + effects. + + If @code{local_Name} identifies more than one matching homonym in the + current scope, then the entity most recently declared is the one to which + the pragma applies. + @findex Unreserve_All_Interrupts @item pragma Unreserve_All_Interrupts @noindent *************** pragma Unreserve_All_Interrupts; *** 2963,2988 **** @end smallexample @noindent ! Normally certain interrupts are reserved to the implementation. Any attempt to attach an interrupt causes Program_Error to be raised, as described in ! RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in ! many systems for an @code{Ctrl-C} interrupt. Normally this interrupt is ! reserved to the implementation, so that @code{Ctrl-C} can be used to interrupt execution. ! If the pragma Unreserve_All_Interrupts appears anywhere in any unit in ! a program, then all such interrupts are unreserved. This allows the program to handle these interrupts, but disables their standard ! functions. For example, if this pragma is used, then pressing ! @code{Ctrl-C} will not automatically interrupt execution. However, a program can then handle the @code{SIGINT} interrupt as it chooses. For a full list of the interrupts handled in a specific implementation, ! see the source code for the specification of Ada.Interrupts.Names in ! file a-intnam.ads. This is a target dependent file that contains the ! list of interrupts recognized for a given target. The documentation in this file also specifies what interrupts are affected by the use of ! the Unreserve_All_Interrupts pragma. @findex Unsuppress @item pragma Unsuppress --- 3004,3029 ---- @end smallexample @noindent ! Normally certain interrupts are reserved to the implementation. Any attempt to attach an interrupt causes Program_Error to be raised, as described in ! RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in ! many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is ! reserved to the implementation, so that @kbd{Ctrl-C} can be used to interrupt execution. ! If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in ! a program, then all such interrupts are unreserved. This allows the program to handle these interrupts, but disables their standard ! functions. For example, if this pragma is used, then pressing ! @kbd{Ctrl-C} will not automatically interrupt execution. However, a program can then handle the @code{SIGINT} interrupt as it chooses. For a full list of the interrupts handled in a specific implementation, ! see the source code for the specification of @code{Ada.Interrupts.Names} in ! file @file{a-intnam.ads}. This is a target dependent file that contains the ! list of interrupts recognized for a given target. The documentation in this file also specifies what interrupts are affected by the use of ! the @code{Unreserve_All_Interrupts} pragma. @findex Unsuppress @item pragma Unsuppress *************** pragma Unsuppress (IDENTIFIER [, [On =>] *** 2994,3003 **** @end smallexample @noindent ! This pragma undoes the effect of a previous pragma @code{Suppress}. If there is no corresponding pragma @code{Suppress} in effect, it has no ! effect. The range of the effect is the same as for pragma ! @code{Suppress}. The meaning of the arguments is identical to that used in pragma @code{Suppress}. One important application is to ensure that checks are on in cases where --- 3035,3044 ---- @end smallexample @noindent ! This pragma undoes the effect of a previous pragma @code{Suppress}. If there is no corresponding pragma @code{Suppress} in effect, it has no ! effect. The range of the effect is the same as for pragma ! @code{Suppress}. The meaning of the arguments is identical to that used in pragma @code{Suppress}. One important application is to ensure that checks are on in cases where *************** pragma Use_VADS_Size; *** 3016,3027 **** @end smallexample @noindent ! This is a configuration pragma. In a unit to which it applies, any use of the 'Size attribute is automatically interpreted as a use of the ! 'VADS_Size attribute. Note that this may result in incorrect semantic ! processing of valid Ada 95 programs. This is intended to aid in the handling of legacy code which depends on the interpretation of Size ! as implemented in the VADS compiler. See description of the VADS_Size attribute for further details. @findex Validity_Checks --- 3057,3068 ---- @end smallexample @noindent ! This is a configuration pragma. In a unit to which it applies, any use of the 'Size attribute is automatically interpreted as a use of the ! 'VADS_Size attribute. Note that this may result in incorrect semantic ! processing of valid Ada 95 programs. This is intended to aid in the handling of legacy code which depends on the interpretation of Size ! as implemented in the VADS compiler. See description of the VADS_Size attribute for further details. @findex Validity_Checks *************** pragma Validity_Checks (string_LITERAL | *** 3035,3059 **** @noindent This pragma is used in conjunction with compiler switches to control the ! built in validity checking provided by GNAT@. The compiler switches, if set provide an initial setting for the switches, and this pragma may be used to modify these settings, or the settings may be provided entirely by ! the use of the pragma. This pragma can be used anywhere that a pragma is legal, including use as a configuration pragma (including use in the @file{gnat.adc} file). The form with a string literal specifies which validity options are to be ! activated. The validity checks are first set to include only the default reference manual settings, and then a string of letters in the string ! specifies the exact set of options required. The form of this string is exactly as described for the @code{-gnatVx} compiler switch (see the ! GNAT users guide for details). For example the following two methods can be used to enable validity checking for mode @code{in} and @code{in out} subprogram parameters: @smallexample pragma Validity_Checks ("im"); ! gcc -c -gnatVim ... @end smallexample @noindent --- 3076,3100 ---- @noindent This pragma is used in conjunction with compiler switches to control the ! built in validity checking provided by GNAT@. The compiler switches, if set provide an initial setting for the switches, and this pragma may be used to modify these settings, or the settings may be provided entirely by ! the use of the pragma. This pragma can be used anywhere that a pragma is legal, including use as a configuration pragma (including use in the @file{gnat.adc} file). The form with a string literal specifies which validity options are to be ! activated. The validity checks are first set to include only the default reference manual settings, and then a string of letters in the string ! specifies the exact set of options required. The form of this string is exactly as described for the @code{-gnatVx} compiler switch (see the ! GNAT users guide for details). For example the following two methods can be used to enable validity checking for mode @code{in} and @code{in out} subprogram parameters: @smallexample pragma Validity_Checks ("im"); ! gcc -c -gnatVim @dots{} @end smallexample @noindent *************** pragma Volatile (local_NAME) *** 3086,3094 **** @noindent This pragma is defined by the Ada 95 Reference Manual, and the GNAT ! implementation is fully conformant with this definition. The reason it is mentioned in this section is that a pragma of the same name was supplied ! in some Ada 83 compilers, including DEC Ada 83. The Ada 95 implementation of pragma Volatile is upwards compatible with the implementation in Dec Ada 83. --- 3127,3135 ---- @noindent This pragma is defined by the Ada 95 Reference Manual, and the GNAT ! implementation is fully conformant with this definition. The reason it is mentioned in this section is that a pragma of the same name was supplied ! in some Ada 83 compilers, including DEC Ada 83. The Ada 95 implementation of pragma Volatile is upwards compatible with the implementation in Dec Ada 83. *************** pragma Warnings (On | Off [, LOCAL_NAME] *** 3103,3118 **** @noindent Normally warnings are enabled, with the output being controlled by ! the command line switch. Warnings (@code{Off}) turns off generation of warnings until a Warnings (@code{On}) is encountered or the end of the ! current unit. If generation of warnings is turned off using this pragma, then no warning messages are output, regardless of the setting of the command line switches. The form with a single argument is a configuration pragma. If the @var{local_name} parameter is present, warnings are suppressed for ! the specified entity. This suppression is effective from the point where it occurs till the end of the extended scope of the variable (similar to the scope of @code{Suppress}). --- 3144,3159 ---- @noindent Normally warnings are enabled, with the output being controlled by ! the command line switch. Warnings (@code{Off}) turns off generation of warnings until a Warnings (@code{On}) is encountered or the end of the ! current unit. If generation of warnings is turned off using this pragma, then no warning messages are output, regardless of the setting of the command line switches. The form with a single argument is a configuration pragma. If the @var{local_name} parameter is present, warnings are suppressed for ! the specified entity. This suppression is effective from the point where it occurs till the end of the extended scope of the variable (similar to the scope of @code{Suppress}). *************** pragma Weak_External ([Entity =>] LOCAL_ *** 3127,3133 **** @noindent This pragma specifies that the given entity should be marked as a weak ! external (one that does not have to be resolved) for the linker. For further details, consult the GCC manual. @end table --- 3168,3174 ---- @noindent This pragma specifies that the given entity should be marked as a weak ! external (one that does not have to be resolved) for the linker. For further details, consult the GCC manual. @end table *************** further details, consult the GCC manual. *** 3136,3153 **** Ada 95 defines (throughout the Ada 95 reference manual, summarized in annex K), a set of attributes that provide useful additional functionality in all ! areas of the language. These language defined attributes are implemented in GNAT and work as described in the Ada 95 Reference Manual. In addition, Ada 95 allows implementations to define additional ! attributes whose meaning is defined by the implementation. GNAT provides a number of these implementation-dependent attributes which can be used ! to extend and enhance the functionality of the compiler. This section of the GNAT reference manual describes these additional attributes. Note that any program using these attributes may not be portable to other compilers (although GNAT implements this set of attributes on all ! platforms). Therefore if portability to other compilers is an important consideration, you should minimize the use of these attributes. @table @code --- 3177,3194 ---- Ada 95 defines (throughout the Ada 95 reference manual, summarized in annex K), a set of attributes that provide useful additional functionality in all ! areas of the language. These language defined attributes are implemented in GNAT and work as described in the Ada 95 Reference Manual. In addition, Ada 95 allows implementations to define additional ! attributes whose meaning is defined by the implementation. GNAT provides a number of these implementation-dependent attributes which can be used ! to extend and enhance the functionality of the compiler. This section of the GNAT reference manual describes these additional attributes. Note that any program using these attributes may not be portable to other compilers (although GNAT implements this set of attributes on all ! platforms). Therefore if portability to other compilers is an important consideration, you should minimize the use of these attributes. @table @code *************** consideration, you should minimize the u *** 3156,3162 **** @noindent @code{Standard'Abort_Signal} (@code{Standard} is the only allowed prefix) provides the entity for the special exception used to signal ! task abort or asynchronous transfer of control. Normally this attribute should only be used in the tasking runtime (it is highly peculiar, and completely outside the normal semantics of Ada, for a user program to intercept the abort exception). --- 3197,3203 ---- @noindent @code{Standard'Abort_Signal} (@code{Standard} is the only allowed prefix) provides the entity for the special exception used to signal ! task abort or asynchronous transfer of control. Normally this attribute should only be used in the tasking runtime (it is highly peculiar, and completely outside the normal semantics of Ada, for a user program to intercept the abort exception). *************** intercept the abort exception). *** 3167,3173 **** @noindent @code{Standard'Address_Size} (@code{Standard} is the only allowed prefix) is a static constant giving the number of bits in an ! @code{Address}. It is used primarily for constructing the definition of @code{Memory_Size} in package @code{Standard}, but may be freely used in user programs and has the advantage of being static, while a direct reference to System.Address'Size is non-static because Address --- 3208,3214 ---- @noindent @code{Standard'Address_Size} (@code{Standard} is the only allowed prefix) is a static constant giving the number of bits in an ! @code{Address}. It is used primarily for constructing the definition of @code{Memory_Size} in package @code{Standard}, but may be freely used in user programs and has the advantage of being static, while a direct reference to System.Address'Size is non-static because Address *************** is a private type. *** 3178,3187 **** @noindent The @code{Asm_Input} attribute denotes a function that takes two parameters. The first is a string, the second is an expression of the ! type designated by the prefix. The first (string) argument is required to be a static expression, and is the constraint for the parameter, ! (e.g.@: what kind of register is required). The second argument is the ! value to be used as the input argument. The possible values for the constant are the same as those used in the RTL, and are dependent on the configuration file used to built the GCC back end. @ref{Machine Code Insertions} --- 3219,3228 ---- @noindent The @code{Asm_Input} attribute denotes a function that takes two parameters. The first is a string, the second is an expression of the ! type designated by the prefix. The first (string) argument is required to be a static expression, and is the constraint for the parameter, ! (e.g.@: what kind of register is required). The second argument is the ! value to be used as the input argument. The possible values for the constant are the same as those used in the RTL, and are dependent on the configuration file used to built the GCC back end. @ref{Machine Code Insertions} *************** the configuration file used to built the *** 3191,3201 **** @noindent The @code{Asm_Output} attribute denotes a function that takes two parameters. The first is a string, the second is the name of a variable ! of the type designated by the attribute prefix. The first (string) argument is required to be a static expression and designates the constraint for the parameter (e.g.@: what kind of register is ! required). The second argument is the variable to be updated with the ! result. The possible values for constraint are the same as those used in the RTL, and are dependent on the configuration file used to build the GCC back end. If there are no output operands, then this argument may either be omitted, or explicitly given as @code{No_Output_Operands}. --- 3232,3242 ---- @noindent The @code{Asm_Output} attribute denotes a function that takes two parameters. The first is a string, the second is the name of a variable ! of the type designated by the attribute prefix. The first (string) argument is required to be a static expression and designates the constraint for the parameter (e.g.@: what kind of register is ! required). The second argument is the variable to be updated with the ! result. The possible values for constraint are the same as those used in the RTL, and are dependent on the configuration file used to build the GCC back end. If there are no output operands, then this argument may either be omitted, or explicitly given as @code{No_Output_Operands}. *************** either be omitted, or explicitly given a *** 3205,3236 **** @findex AST_Entry @item AST_Entry @noindent ! This attribute is implemented only in OpenVMS versions of GNAT@. Applied to the name of an entry, it yields a value of the predefined type AST_Handler (declared in the predefined package System, as extended by the use of ! pragma Extend_System (Aux_DEC)). This value enables the given entry to ! be called when an AST occurs. For further details, refer to the DEC Ada ! Language Reference Manual, section 9.12a. @findex Bit @item Bit @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit offset within the storage unit (byte) that contains the first bit of ! storage allocated for the object. The value of this attribute is of the type @code{Universal_Integer}, and is always a non-negative number not exceeding the value of @code{System.Storage_Unit}. For an object that is a variable or a constant allocated in a register, ! the value is zero. (The use of this attribute does not force the allocation of a variable to memory). For an object that is a formal parameter, this attribute applies to either the matching actual parameter or to a copy of the matching actual parameter. ! For an access object the value is zero. Note that @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the ! designated object. Similarly for a record component @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit} are subject to index checks. --- 3246,3277 ---- @findex AST_Entry @item AST_Entry @noindent ! This attribute is implemented only in OpenVMS versions of GNAT@. Applied to the name of an entry, it yields a value of the predefined type AST_Handler (declared in the predefined package System, as extended by the use of ! pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to ! be called when an AST occurs. For further details, refer to the @cite{DEC Ada ! Language Reference Manual}, section 9.12a. @findex Bit @item Bit @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit offset within the storage unit (byte) that contains the first bit of ! storage allocated for the object. The value of this attribute is of the type @code{Universal_Integer}, and is always a non-negative number not exceeding the value of @code{System.Storage_Unit}. For an object that is a variable or a constant allocated in a register, ! the value is zero. (The use of this attribute does not force the allocation of a variable to memory). For an object that is a formal parameter, this attribute applies to either the matching actual parameter or to a copy of the matching actual parameter. ! For an access object the value is zero. Note that @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the ! designated object. Similarly for a record component @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit} are subject to index checks. *************** and implementation of the @code{Bit} att *** 3244,3251 **** @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one of the fields of the record type, yields the bit offset within the record contains the first bit of ! storage allocated for the object. The value of this attribute is of the ! type @code{Universal_Integer}. The value depends only on the field @var{C} and is independent of the alignment of the containing record @var{R}. --- 3285,3292 ---- @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one of the fields of the record type, yields the bit offset within the record contains the first bit of ! storage allocated for the object. The value of this attribute is of the ! type @code{Universal_Integer}. The value depends only on the field @var{C} and is independent of the alignment of the containing record @var{R}. *************** an address value which can be used to ca *** 3261,3267 **** an address clause as in the following example: @smallexample ! procedure K is ... procedure L; for L'Address use K'Address; --- 3302,3308 ---- an address clause as in the following example: @smallexample ! procedure K is @dots{} procedure L; for L'Address use K'Address; *************** pragma Import (Ada, L); *** 3269,3284 **** @end smallexample @noindent ! A call to L is then expected to result in a call to K@. In Ada 83, where there were no access-to-subprogram values, this was a common work around for getting the effect of an indirect call. ! GNAT implements the above use of Address and the technique illustrated by the example code works correctly. However, for some purposes, it is useful to have the address of the start ! of the generated code for the subprogram. On some architectures, this is ! not necessarily the same as the Address value described above. For example, ! the Address value may reference a subprogram descriptor rather than the subprogram itself. The @code{'Code_Address} attribute, which can only be applied to --- 3310,3325 ---- @end smallexample @noindent ! A call to @code{L} is then expected to result in a call to @code{K}@. In Ada 83, where there were no access-to-subprogram values, this was a common work around for getting the effect of an indirect call. ! GNAT implements the above use of @code{Address} and the technique illustrated by the example code works correctly. However, for some purposes, it is useful to have the address of the start ! of the generated code for the subprogram. On some architectures, this is ! not necessarily the same as the @code{Address} value described above. For example, ! the @code{Address} value may reference a subprogram descriptor rather than the subprogram itself. The @code{'Code_Address} attribute, which can only be applied to *************** attribute. *** 3295,3319 **** @code{Standard'Default_Bit_Order} (@code{Standard} is the only permissible prefix), provides the value @code{System.Default_Bit_Order} as a @code{Pos} value (0 for @code{High_Order_First}, 1 for ! @code{Low_Order_First}). This is used to construct the definition of @code{Default_Bit_Order} in package @code{System}. @findex Elaborated @item Elaborated @noindent ! The prefix of the @code{'Elaborated} attribute must be a unit name. The value is a Boolean which indicates whether or not the given unit has been ! elaborated. This attribute is primarily intended for internal use by the generated code for dynamic elaboration checking, but it can also be used ! in user programs. The value will always be True once elaboration of all units has been completed. @findex Elab_Body @item Elab_Body @noindent ! This attribute can only be applied to a program unit name. It returns the entity for the corresponding elaboration procedure for elaborating ! the body of the referenced unit. This is used in the main generated elaboration procedure by the binder and is not normally used in any other context. However, there may be specialized situations in which it is useful to be able to call this elaboration procedure from Ada code, --- 3336,3360 ---- @code{Standard'Default_Bit_Order} (@code{Standard} is the only permissible prefix), provides the value @code{System.Default_Bit_Order} as a @code{Pos} value (0 for @code{High_Order_First}, 1 for ! @code{Low_Order_First}). This is used to construct the definition of @code{Default_Bit_Order} in package @code{System}. @findex Elaborated @item Elaborated @noindent ! The prefix of the @code{'Elaborated} attribute must be a unit name. The value is a Boolean which indicates whether or not the given unit has been ! elaborated. This attribute is primarily intended for internal use by the generated code for dynamic elaboration checking, but it can also be used ! in user programs. The value will always be True once elaboration of all units has been completed. @findex Elab_Body @item Elab_Body @noindent ! This attribute can only be applied to a program unit name. It returns the entity for the corresponding elaboration procedure for elaborating ! the body of the referenced unit. This is used in the main generated elaboration procedure by the binder and is not normally used in any other context. However, there may be specialized situations in which it is useful to be able to call this elaboration procedure from Ada code, *************** error. *** 3323,3331 **** @findex Elab_Spec @item Elab_Spec @noindent ! This attribute can only be applied to a program unit name. It returns the entity for the corresponding elaboration procedure for elaborating ! the specification of the referenced unit. This is used in the main generated elaboration procedure by the binder and is not normally used in any other context. However, there may be specialized situations in which it is useful to be able to call this elaboration procedure from --- 3364,3372 ---- @findex Elab_Spec @item Elab_Spec @noindent ! This attribute can only be applied to a program unit name. It returns the entity for the corresponding elaboration procedure for elaborating ! the specification of the referenced unit. This is used in the main generated elaboration procedure by the binder and is not normally used in any other context. However, there may be specialized situations in which it is useful to be able to call this elaboration procedure from *************** some error. *** 3336,3342 **** @findex Emax @item Emax @noindent ! The @code{Emax} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. --- 3377,3383 ---- @findex Emax @item Emax @noindent ! The @code{Emax} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. *************** function @var{S}'Enum_Rep (Arg : @var{S} *** 3353,3374 **** @end smallexample @noindent ! It is also allowable to apply Enum_Rep directly to an object of an enumeration type or to a non-overloaded enumeration ! literal. In this case @code{@var{S}'Enum_Rep} is equivalent to @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the enumeration literal or object. The function returns the representation value for the given enumeration ! value. This will be equal to value of the @code{Pos} attribute in the ! absence of an enumeration representation clause. This is a static attribute (i.e.@: the result is static if the argument is static). ! @var{S}'Enum_Rep can also be used with integer types and objects, in which ! case it simply returns the integer value. The reason for this is to allow ! it to be used for (<>) discrete formal arguments in a generic unit that ! can be instantiated with either enumeration types or integer types. Note ! that if Enum_Rep is used on a modular type whose upper bound exceeds the upper bound of the largest signed integer type, and the argument is a variable, so that the universal integer calculation is done at run-time, then the call to @code{Enum_Rep} may raise @code{Constraint_Error}. --- 3394,3415 ---- @end smallexample @noindent ! It is also allowable to apply @code{Enum_Rep} directly to an object of an enumeration type or to a non-overloaded enumeration ! literal. In this case @code{@var{S}'Enum_Rep} is equivalent to @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the enumeration literal or object. The function returns the representation value for the given enumeration ! value. This will be equal to value of the @code{Pos} attribute in the ! absence of an enumeration representation clause. This is a static attribute (i.e.@: the result is static if the argument is static). ! @code{@var{S}'Enum_Rep} can also be used with integer types and objects, in which ! case it simply returns the integer value. The reason for this is to allow ! it to be used for @code{(<>)} discrete formal arguments in a generic unit that ! can be instantiated with either enumeration types or integer types. Note ! that if @code{Enum_Rep} is used on a modular type whose upper bound exceeds the upper bound of the largest signed integer type, and the argument is a variable, so that the universal integer calculation is done at run-time, then the call to @code{Enum_Rep} may raise @code{Constraint_Error}. *************** then the call to @code{Enum_Rep} may rai *** 3377,3383 **** @findex Epsilon @item Epsilon @noindent ! The @code{Epsilon} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. --- 3418,3424 ---- @findex Epsilon @item Epsilon @noindent ! The @code{Epsilon} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. *************** The value returned is the fixed-point va *** 3402,3408 **** @noindent The effect is thus equivalent to first converting the argument to the integer type used to represent @var{S}, and then doing an unchecked ! conversion to the fixed-point type. This attribute is primarily intended for use in implementation of the input-output functions for fixed-point values. --- 3443,3449 ---- @noindent The effect is thus equivalent to first converting the argument to the integer type used to represent @var{S}, and then doing an unchecked ! conversion to the fixed-point type. This attribute is primarily intended for use in implementation of the input-output functions for fixed-point values. *************** values. *** 3410,3419 **** @findex Has_Discriminants @item Has_Discriminants @noindent ! The prefix of the @code{Has_Discriminants} attribute is a type. The result is a Boolean value which is True if the type has discriminants, and False ! otherwise. The intended use of this attribute is in conjunction with generic ! definitions. If the attribute is applied to a generic private type, it indicates whether or not the corresponding actual type has discriminants. @findex Img --- 3451,3460 ---- @findex Has_Discriminants @item Has_Discriminants @noindent ! The prefix of the @code{Has_Discriminants} attribute is a type. The result is a Boolean value which is True if the type has discriminants, and False ! otherwise. The intended use of this attribute is in conjunction with generic ! definitions. If the attribute is applied to a generic private type, it indicates whether or not the corresponding actual type has discriminants. @findex Img *************** indicates whether or not the correspondi *** 3421,3427 **** @noindent The @code{Img} attribute differs from @code{Image} in that it may be applied to objects as well as types, in which case it gives the ! @code{Image} for the subtype of the object. This is convenient for debugging: @smallexample --- 3462,3468 ---- @noindent The @code{Img} attribute differs from @code{Image} in that it may be applied to objects as well as types, in which case it gives the ! @code{Image} for the subtype of the object. This is convenient for debugging: @smallexample *************** Arg = @var{V} * @var{type}'Small *** 3458,3464 **** @noindent The effect is thus equivalent to first doing an unchecked convert from the fixed-point type to its corresponding implementation type, and then ! converting the result to the target integer type. This attribute is primarily intended for use in implementation of the standard input-output functions for fixed-point values. --- 3499,3505 ---- @noindent The effect is thus equivalent to first doing an unchecked convert from the fixed-point type to its corresponding implementation type, and then ! converting the result to the target integer type. This attribute is primarily intended for use in implementation of the standard input-output functions for fixed-point values. *************** input-output functions for fixed-point v *** 3466,3486 **** @findex Large @item Large @noindent ! The @code{Large} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. @findex Machine_Size @item Machine_Size @noindent ! This attribute is identical to the @code{Object_Size} attribute. It is provided for compatibility with the DEC Ada 83 attribute of this name. @cindex Ada 83 attributes @findex Mantissa @item Mantissa @noindent ! The @code{Mantissa} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. --- 3507,3527 ---- @findex Large @item Large @noindent ! The @code{Large} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. @findex Machine_Size @item Machine_Size @noindent ! This attribute is identical to the @code{Object_Size} attribute. It is provided for compatibility with the DEC Ada 83 attribute of this name. @cindex Ada 83 attributes @findex Mantissa @item Mantissa @noindent ! The @code{Mantissa} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. *************** primarily for constructing this definiti *** 3507,3515 **** @noindent @code{Standard'Maximum_Alignment} (@code{Standard} is the only permissible prefix) provides the maximum useful alignment value for the ! target. This is a static value that can be used to specify the alignment for an object, guaranteeing that it is properly aligned in all ! cases. This is useful when an external object is imported and its alignment requirements are unknown. @cindex Return values, passing mechanism --- 3548,3556 ---- @noindent @code{Standard'Maximum_Alignment} (@code{Standard} is the only permissible prefix) provides the maximum useful alignment value for the ! target. This is a static value that can be used to specify the alignment for an object, guaranteeing that it is properly aligned in all ! cases. This is useful when an external object is imported and its alignment requirements are unknown. @cindex Return values, passing mechanism *************** alignment requirements are unknown. *** 3521,3527 **** mechanism used for the result of function, and @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism used for formal parameter number @var{n} (a static integer value with 1 ! meaning the first parameter) of @var{subprogram}. The code returned is: @table @asis @item 1 --- 3562,3568 ---- mechanism used for the result of function, and @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism used for formal parameter number @var{n} (a static integer value with 1 ! meaning the first parameter) of @var{subprogram}. The code returned is: @table @asis @item 1 *************** by descriptor (NCA: non-contiguous array *** 3547,3562 **** @end table @cindex OpenVMS ! Values from 3-10 are only relevant to Digital OpenVMS implementations. @cindex Zero address, passing @findex Null_Parameter @item Null_Parameter @noindent A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of ! type or subtype @var{T} allocated at machine address zero. The attribute is allowed only as the default expression of a formal parameter, or as ! an actual expression of a subprogram call. In either case, the subprogram must be imported. The identity of the object is represented by the address zero in the --- 3588,3603 ---- @end table @cindex OpenVMS ! Values from 3 through 10 are only relevant to Digital OpenVMS implementations. @cindex Zero address, passing @findex Null_Parameter @item Null_Parameter @noindent A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of ! type or subtype @var{T} allocated at machine address zero. The attribute is allowed only as the default expression of a formal parameter, or as ! an actual expression of a subprogram call. In either case, the subprogram must be imported. The identity of the object is represented by the address zero in the *************** attribute. *** 3573,3580 **** @item Object_Size @noindent The size of an object is not necessarily the same as the size of the type ! of an object. This is because by default object sizes are increased to be ! a multiple of the alignment of the object. For example, @code{Natural'Size} is 31, but by default objects of type @code{Natural} will have a size of 32 bits. Similarly, a record containing an integer and a character: --- 3614,3621 ---- @item Object_Size @noindent The size of an object is not necessarily the same as the size of the type ! of an object. This is because by default object sizes are increased to be ! a multiple of the alignment of the object. For example, @code{Natural'Size} is 31, but by default objects of type @code{Natural} will have a size of 32 bits. Similarly, a record containing an integer and a character: *************** end record; *** 3587,3606 **** @end smallexample @noindent ! will have a size of 40 (that is @code{Rec'Size} will be 40. The alignment will be 4, because of the integer field, and so the default size of record objects for this type will be 64 (8 bytes). The @code{@var{type}'Object_Size} attribute has been added to GNAT to allow the ! default object size of a type to be easily determined. For example, @code{Natural'Object_Size} is 32, and @code{Rec'Object_Size} (for the record type in the above example) will be ! 64. Note also that, unlike the situation with the @code{Size} attribute as defined in the Ada RM, the @code{Object_Size} attribute can be specified individually ! for different subtypes. For example: @smallexample type R is new Integer; --- 3628,3647 ---- @end smallexample @noindent ! will have a size of 40 (that is @code{Rec'Size} will be 40. The alignment will be 4, because of the integer field, and so the default size of record objects for this type will be 64 (8 bytes). The @code{@var{type}'Object_Size} attribute has been added to GNAT to allow the ! default object size of a type to be easily determined. For example, @code{Natural'Object_Size} is 32, and @code{Rec'Object_Size} (for the record type in the above example) will be ! 64. Note also that, unlike the situation with the @code{Size} attribute as defined in the Ada RM, the @code{Object_Size} attribute can be specified individually ! for different subtypes. For example: @smallexample type R is new Integer; *************** for R2'Object_Size use 8; *** 3612,3620 **** @noindent In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both 32 since the default object size for a subtype is the same as the object size ! for the parent subtype. This means that objects of type @code{R} or @code{R1} will ! by default be 32 bits (four bytes). But objects of type @code{R2} will be only 8 bits (one byte), since @code{R2'Object_Size} has been set to 8. --- 3653,3661 ---- @noindent In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both 32 since the default object size for a subtype is the same as the object size ! for the parent subtype. This means that objects of type @code{R} or @code{R1} will ! by default be 32 bits (four bytes). But objects of type @code{R2} will be only 8 bits (one byte), since @code{R2'Object_Size} has been set to 8. *************** by default be 32 bits (four bytes). But *** 3625,3639 **** @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns a value of type @code{Boolean} value that is @code{True} if the type is normally passed by reference and @code{False} if the type is normally ! passed by copy in calls. For scalar types, the result is always @code{False} ! and is static. For non-scalar types, the result is non-static. @findex Range_Length @item Range_Length @noindent @code{@var{type}'Range_Length} for any discrete type @var{type} yields the number of values represented by the subtype (zero for a null ! range). The result is static for static subtypes. @code{Range_Length} applied to the index subtype of a one dimensional array always gives the same result as @code{Range} applied to the array itself. --- 3666,3680 ---- @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns a value of type @code{Boolean} value that is @code{True} if the type is normally passed by reference and @code{False} if the type is normally ! passed by copy in calls. For scalar types, the result is always @code{False} ! and is static. For non-scalar types, the result is non-static. @findex Range_Length @item Range_Length @noindent @code{@var{type}'Range_Length} for any discrete type @var{type} yields the number of values represented by the subtype (zero for a null ! range). The result is static for static subtypes. @code{Range_Length} applied to the index subtype of a one dimensional array always gives the same result as @code{Range} applied to the array itself. *************** same result as @code{Range} applied to t *** 3641,3647 **** @findex Safe_Emax @item Safe_Emax @noindent ! The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. --- 3682,3688 ---- @findex Safe_Emax @item Safe_Emax @noindent ! The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. *************** this attribute. *** 3649,3655 **** @findex Safe_Large @item Safe_Large @noindent ! The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. --- 3690,3696 ---- @findex Safe_Large @item Safe_Large @noindent ! The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. *************** this attribute. *** 3657,3663 **** @findex Safe_Large @item Safe_Large @noindent ! The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. --- 3698,3704 ---- @findex Safe_Large @item Safe_Large @noindent ! The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute. *************** this attribute. *** 3667,3673 **** @noindent The @code{Small} attribute is defined in Ada 95 only for fixed-point types. GNAT also allows this attribute to be applied to floating-point types ! for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute when applied to floating-point types. --- 3708,3714 ---- @noindent The @code{Small} attribute is defined in Ada 95 only for fixed-point types. GNAT also allows this attribute to be applied to floating-point types ! for compatibility with Ada 83. See the Ada 83 reference manual for an exact description of the semantics of this attribute when applied to floating-point types. *************** The @code{System'To_Address} *** 3692,3700 **** (@code{System} is the only permissible prefix) denotes a function identical to @code{System.Storage_Elements.To_Address} except that ! it is a static attribute. This means that if its argument is a static expression, then the result of the attribute is a ! static expression. The result is that such an expression can be used in contexts (e.g.@: preelaborable packages) which require a static expression and where the function call could not be used (since the function call is always non-static, even if its --- 3733,3741 ---- (@code{System} is the only permissible prefix) denotes a function identical to @code{System.Storage_Elements.To_Address} except that ! it is a static attribute. This means that if its argument is a static expression, then the result of the attribute is a ! static expression. The result is that such an expression can be used in contexts (e.g.@: preelaborable packages) which require a static expression and where the function call could not be used (since the function call is always non-static, even if its *************** argument is static). *** 3704,3710 **** @item Type_Class @noindent @code{@var{type}'Type_Class} for any type or subtype @var{type} yields ! the value of the type class for the full type of @var{type}. If @var{type} is a generic formal type, the value is the value for the corresponding actual subtype. The value of this attribute is of type @code{System.Aux_DEC.Type_Class}, which has the following definition: --- 3745,3751 ---- @item Type_Class @noindent @code{@var{type}'Type_Class} for any type or subtype @var{type} yields ! the value of the type class for the full type of @var{type}. If @var{type} is a generic formal type, the value is the value for the corresponding actual subtype. The value of this attribute is of type @code{System.Aux_DEC.Type_Class}, which has the following definition: *************** corresponding actual subtype. The value *** 3724,3740 **** @noindent Protected types yield the value @code{Type_Class_Task}, which thus ! applies to all concurrent types. This attribute is designed to be compatible with the DEC Ada 83 attribute of the same name. @findex UET_Address @item UET_Address @noindent The @code{UET_Address} attribute can only be used for a prefix which ! denotes a library package. It yields the address of the unit exception ! table when zero cost exception handling is used. This attribute is ! intended only for use within the GNAT implementation. See the unit ! @code{Ada.Exceptions} in files @file{a-except.ads,a-except.adb} for details on how this attribute is used in the implementation. @cindex Named numbers, representation of --- 3765,3781 ---- @noindent Protected types yield the value @code{Type_Class_Task}, which thus ! applies to all concurrent types. This attribute is designed to be compatible with the DEC Ada 83 attribute of the same name. @findex UET_Address @item UET_Address @noindent The @code{UET_Address} attribute can only be used for a prefix which ! denotes a library package. It yields the address of the unit exception ! table when zero cost exception handling is used. This attribute is ! intended only for use within the GNAT implementation. See the unit ! @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb} for details on how this attribute is used in the implementation. @cindex Named numbers, representation of *************** for details on how this attribute is use *** 3742,3752 **** @item Universal_Literal_String @noindent The prefix of @code{Universal_Literal_String} must be a named ! number. The static result is the string consisting of the characters of ! the number as defined in the original source. This allows the user program to access the actual text of named numbers without intermediate conversions and without the need to enclose the strings in quotes (which ! would preclude their use as numbers). This is used internally for the construction of values of the floating-point attributes from the file @file{ttypef.ads}, but may also be used by user programs. --- 3783,3793 ---- @item Universal_Literal_String @noindent The prefix of @code{Universal_Literal_String} must be a named ! number. The static result is the string consisting of the characters of ! the number as defined in the original source. This allows the user program to access the actual text of named numbers without intermediate conversions and without the need to enclose the strings in quotes (which ! would preclude their use as numbers). This is used internally for the construction of values of the floating-point attributes from the file @file{ttypef.ads}, but may also be used by user programs. *************** construction of values of the floating-p *** 3755,3766 **** @item Unrestricted_Access @noindent The @code{Unrestricted_Access} attribute is similar to @code{Access} ! except that all accessibility and aliased view checks are omitted. This is a user-beware attribute. It is similar to @code{Address}, for which it is a desirable replacement where the value ! desired is an access type. In other words, its effect is identical to first applying the @code{Address} attribute and then doing an unchecked ! conversion to a desired access type. In GNAT, but not necessarily in other implementations, the use of static chains for inner level subprograms means that @code{Unrestricted_Access} applied to a subprogram yields a value that can be called as long as the subprogram --- 3796,3807 ---- @item Unrestricted_Access @noindent The @code{Unrestricted_Access} attribute is similar to @code{Access} ! except that all accessibility and aliased view checks are omitted. This is a user-beware attribute. It is similar to @code{Address}, for which it is a desirable replacement where the value ! desired is an access type. In other words, its effect is identical to first applying the @code{Address} attribute and then doing an unchecked ! conversion to a desired access type. In GNAT, but not necessarily in other implementations, the use of static chains for inner level subprograms means that @code{Unrestricted_Access} applied to a subprogram yields a value that can be called as long as the subprogram *************** is in scope (normal Ada 95 accessibility *** 3772,3782 **** @noindent The @code{'VADS_Size} attribute is intended to make it easier to port legacy code which relies on the semantics of @code{'Size} as implemented ! by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the ! same semantic interpretation. In particular, @code{'VADS_Size} applied to a predefined or other primitive type with no Size clause yields the Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on ! typical machines). In addition @code{'VADS_Size} applied to an object gives the result that would be obtained by applying the attribute to the corresponding type. --- 3813,3823 ---- @noindent The @code{'VADS_Size} attribute is intended to make it easier to port legacy code which relies on the semantics of @code{'Size} as implemented ! by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the ! same semantic interpretation. In particular, @code{'VADS_Size} applied to a predefined or other primitive type with no Size clause yields the Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on ! typical machines). In addition @code{'VADS_Size} applied to an object gives the result that would be obtained by applying the attribute to the corresponding type. *************** the corresponding type. *** 3784,3790 **** @findex Value_Size @item Value_Size @code{@var{type}'Value_Size} is the number of bits required to represent ! a value of the given subtype. It is the same as @code{@var{type}'Size}, but, unlike @code{Size}, may be set for non-first subtypes. @findex Wchar_T_Size --- 3825,3831 ---- @findex Value_Size @item Value_Size @code{@var{type}'Value_Size} is the number of bits required to represent ! a value of the given subtype. It is the same as @code{@var{type}'Size}, but, unlike @code{Size}, may be set for non-first subtypes. @findex Wchar_T_Size *************** these requirements. *** 3808,3826 **** In addition, there are sections throughout the Ada 95 reference manual headed ! by the phrase ``implementation advice''. These sections are not normative, i.e.@: they do not specify requirements that all compilers must ! follow. Rather they provide advice on generally desirable behavior. You ! may wonder why they are not requirements. The most typical answer is that they describe behavior that seems generally desirable, but cannot be provided on all systems, or which may be undesirable on some systems. As far as practical, GNAT follows the implementation advice sections in ! the Ada 95 Reference Manual. This chapter contains a table giving the reference manual section number, paragraph number and several keywords for each advice. Each entry consists of the text of the advice followed ! by the GNAT interpretation of this advice. Most often, this simply says ! ``followed'', which means that GNAT follows the advice. However, in a number of cases, GNAT deliberately deviates from this advice, in which case the text describes what GNAT does and why. --- 3849,3867 ---- In addition, there are sections throughout the Ada 95 reference manual headed ! by the phrase ``implementation advice''. These sections are not normative, i.e.@: they do not specify requirements that all compilers must ! follow. Rather they provide advice on generally desirable behavior. You ! may wonder why they are not requirements. The most typical answer is that they describe behavior that seems generally desirable, but cannot be provided on all systems, or which may be undesirable on some systems. As far as practical, GNAT follows the implementation advice sections in ! the Ada 95 Reference Manual. This chapter contains a table giving the reference manual section number, paragraph number and several keywords for each advice. Each entry consists of the text of the advice followed ! by the GNAT interpretation of this advice. Most often, this simply says ! ``followed'', which means that GNAT follows the advice. However, in a number of cases, GNAT deliberately deviates from this advice, in which case the text describes what GNAT does and why. *************** If an implementation detects the use of *** 3833,3839 **** Annex feature at run time, it should raise @code{Program_Error} if feasible. @end cartouche ! Not relevant. All specialized needs annex features are either supported, or diagnosed at compile time. @cindex Child Units --- 3874,3880 ---- Annex feature at run time, it should raise @code{Program_Error} if feasible. @end cartouche ! Not relevant. All specialized needs annex features are either supported, or diagnosed at compile time. @cindex Child Units *************** If an implementation detects a bounded e *** 3854,3860 **** execution, it should raise @code{Program_Error}. @end cartouche Followed in all cases in which the implementation detects a bounded ! error or erroneous execution. Not all such situations are detected at runtime. @cindex Pragmas --- 3895,3901 ---- execution, it should raise @code{Program_Error}. @end cartouche Followed in all cases in which the implementation detects a bounded ! error or erroneous execution. Not all such situations are detected at runtime. @cindex Pragmas *************** Affects semantics *** 3897,3903 **** @end table In each of the above cases, it is essential to the purpose of the pragma ! that this advice not be followed. For details see the separate section on implementation defined pragmas. @item 2.8(17-19): Pragmas --- 3938,3944 ---- @end table In each of the above cases, it is essential to the purpose of the pragma ! that this advice not be followed. For details see the separate section on implementation defined pragmas. @item 2.8(17-19): Pragmas *************** See response to paragraph 16 of this sam *** 3925,3934 **** If an implementation supports a mode with alternative interpretations for @code{Character} and @code{Wide_Character}, the set of graphic characters of @code{Character} should nevertheless remain a proper ! subset of the set of graphic characters of @code{Wide_Character}. Any character set ``localizations'' should be reflected in the results of the subprograms defined in the language-defined package ! @code{Characters.Handling} (see A.3) available in such a mode. In a mode with an alternative interpretation of @code{Character}, the implementation should also support a corresponding change in what is a legal @code{identifier_letter}. --- 3966,3975 ---- If an implementation supports a mode with alternative interpretations for @code{Character} and @code{Wide_Character}, the set of graphic characters of @code{Character} should nevertheless remain a proper ! subset of the set of graphic characters of @code{Wide_Character}. Any character set ``localizations'' should be reflected in the results of the subprograms defined in the language-defined package ! @code{Characters.Handling} (see A.3) available in such a mode. In a mode with an alternative interpretation of @code{Character}, the implementation should also support a corresponding change in what is a legal @code{identifier_letter}. *************** Not all wide character modes follow this *** 3937,3943 **** and IEC modes reflect standard usage in Japan, and in these encoding, the upper half of the Latin-1 set is not part of the wide-character subset, since the most significant bit is used for wide character ! encoding. However, this only applies to the external forms. Internally there is no such restriction. @cindex Integer types --- 3978,3984 ---- and IEC modes reflect standard usage in Japan, and in these encoding, the upper half of the Latin-1 set is not part of the wide-character subset, since the most significant bit is used for wide character ! encoding. However, this only applies to the external forms. Internally there is no such restriction. @cindex Integer types *************** there is no such restriction. *** 3947,3958 **** @cartouche An implementation should support @code{Long_Integer} in addition to @code{Integer} if the target machine supports 32-bit (or longer) ! arithmetic. No other named integer subtypes are recommended for package ! @code{Standard}. Instead, appropriate named integer subtypes should be provided in the library package @code{Interfaces} (see B.2). @end cartouche ! @code{Long_Integer} is supported. Other standard integer types are supported ! so this advice is not fully followed. These types are supported for convenient interface to C, and so that all hardware types of the machine are easily available. @item 3.5.4(29): Integer Types --- 3988,3999 ---- @cartouche An implementation should support @code{Long_Integer} in addition to @code{Integer} if the target machine supports 32-bit (or longer) ! arithmetic. No other named integer subtypes are recommended for package ! @code{Standard}. Instead, appropriate named integer subtypes should be provided in the library package @code{Interfaces} (see B.2). @end cartouche ! @code{Long_Integer} is supported. Other standard integer types are supported ! so this advice is not fully followed. These types are supported for convenient interface to C, and so that all hardware types of the machine are easily available. @item 3.5.4(29): Integer Types *************** types of the machine are easily availabl *** 3960,3966 **** @sp 1 @cartouche An implementation for a two's complement machine should support ! modular types with a binary modulus up to @code{System.Max_Int*2+2}. An implementation should support a non-binary modules up to @code{Integer'Last}. @end cartouche Followed. --- 4001,4007 ---- @sp 1 @cartouche An implementation for a two's complement machine should support ! modular types with a binary modulus up to @code{System.Max_Int*2+2}. An implementation should support a non-binary modules up to @code{Integer'Last}. @end cartouche Followed. *************** For the evaluation of a call on @code{@v *** 3973,3979 **** subtype, if the value of the operand does not correspond to the internal code for any enumeration literal of its type (perhaps due to an un-initialized variable), then the implementation should raise ! @code{Program_Error}. This is particularly important for enumeration types with noncontiguous internal codes specified by an enumeration_representation_clause. @end cartouche --- 4014,4020 ---- subtype, if the value of the operand does not correspond to the internal code for any enumeration literal of its type (perhaps due to an un-initialized variable), then the implementation should raise ! @code{Program_Error}. This is particularly important for enumeration types with noncontiguous internal codes specified by an enumeration_representation_clause. @end cartouche *************** Followed. *** 3985,4003 **** @cartouche An implementation should support @code{Long_Float} in addition to @code{Float} if the target machine supports 11 or more digits of ! precision. No other named floating point subtypes are recommended for ! package @code{Standard}. Instead, appropriate named floating point subtypes should be provided in the library package @code{Interfaces} (see B.2). @end cartouche ! @code{Short_Float} and @code{Long_Long_Float} are also provided. The former provides improved compatibility with other implementations ! supporting this type. The latter corresponds to the highest precision ! floating-point type supported by the hardware. On most machines, this will be the same as @code{Long_Float}, but on some machines, it will ! correspond to the IEEE extended form. The notable case is all ia32 (x86) implementations, where @code{Long_Long_Float} corresponds to the 80-bit extended precision format supported in hardware on this ! processor. Note that the 128-bit format on SPARC is not supported, since this is a software rather than a hardware format. @cindex Multidimensional arrays --- 4026,4044 ---- @cartouche An implementation should support @code{Long_Float} in addition to @code{Float} if the target machine supports 11 or more digits of ! precision. No other named floating point subtypes are recommended for ! package @code{Standard}. Instead, appropriate named floating point subtypes should be provided in the library package @code{Interfaces} (see B.2). @end cartouche ! @code{Short_Float} and @code{Long_Long_Float} are also provided. The former provides improved compatibility with other implementations ! supporting this type. The latter corresponds to the highest precision ! floating-point type supported by the hardware. On most machines, this will be the same as @code{Long_Float}, but on some machines, it will ! correspond to the IEEE extended form. The notable case is all ia32 (x86) implementations, where @code{Long_Long_Float} corresponds to the 80-bit extended precision format supported in hardware on this ! processor. Note that the 128-bit format on SPARC is not supported, since this is a software rather than a hardware format. @cindex Multidimensional arrays *************** since this is a software rather than a h *** 4007,4014 **** @cartouche An implementation should normally represent multidimensional arrays in row-major order, consistent with the notation used for multidimensional ! array aggregates (see 4.3.3). However, if a pragma @code{Convention} ! (@code{Fortran}, ...) applies to a multidimensional array type, then column-major order should be used instead (see B.5, ``Interfacing with Fortran''). @end cartouche --- 4048,4055 ---- @cartouche An implementation should normally represent multidimensional arrays in row-major order, consistent with the notation used for multidimensional ! array aggregates (see 4.3.3). However, if a pragma @code{Convention} ! (@code{Fortran}, @dots{}) applies to a multidimensional array type, then column-major order should be used instead (see B.5, ``Interfacing with Fortran''). @end cartouche *************** Followed. *** 4021,4027 **** Whenever possible in an implementation, the value of @code{Duration'Small} should be no greater than 100 microseconds. @end cartouche ! Followed. (@code{Duration'Small} = 10**(-9)). @sp 1 @cartouche --- 4062,4068 ---- Whenever possible in an implementation, the value of @code{Duration'Small} should be no greater than 100 microseconds. @end cartouche ! Followed. (@code{Duration'Small} = 10**(@minus{}9)). @sp 1 @cartouche *************** the package, whether the elaborations oc *** 4039,4048 **** the same program, or in executions of distinct programs or partitions that include the given version. @end cartouche ! Followed, except in the case of tagged types. Tagged types involve implicit pointers to a local copy of a dispatch table, and these pointers have representations which thus depend on a particular elaboration of the ! package. It is not easy to see how it would be possible to follow this advice without severely impacting efficiency of execution. @cindex Exception information --- 4080,4089 ---- the same program, or in executions of distinct programs or partitions that include the given version. @end cartouche ! Followed, except in the case of tagged types. Tagged types involve implicit pointers to a local copy of a dispatch table, and these pointers have representations which thus depend on a particular elaboration of the ! package. It is not easy to see how it would be possible to follow this advice without severely impacting efficiency of execution. @cindex Exception information *************** advice without severely impacting effici *** 4051,4067 **** @cartouche @code{Exception_Message} by default and @code{Exception_Information} should produce information useful for ! debugging. @code{Exception_Message} should be short, about one ! line. @code{Exception_Information} can be long. @code{Exception_Message} should not include the ! @code{Exception_Name}. @code{Exception_Information} should include both the @code{Exception_Name} and the @code{Exception_Message}. @end cartouche ! Followed. For each exception that doesn't have a specified @code{Exception_Message}, the compiler generates one containing the location ! of the raise statement. This location has the form "file:line", where file is the short file name (without path information) and line is the line ! number in the file. Note that in the case of the Zero Cost Exception mechanism, these messages become redundant with the Exception_Information that contains a full backtrace of the calling sequence, so they are disabled. To disable explicitly the generation of the source location message, use the --- 4092,4108 ---- @cartouche @code{Exception_Message} by default and @code{Exception_Information} should produce information useful for ! debugging. @code{Exception_Message} should be short, about one ! line. @code{Exception_Information} can be long. @code{Exception_Message} should not include the ! @code{Exception_Name}. @code{Exception_Information} should include both the @code{Exception_Name} and the @code{Exception_Message}. @end cartouche ! Followed. For each exception that doesn't have a specified @code{Exception_Message}, the compiler generates one containing the location ! of the raise statement. This location has the form ``file:line'', where file is the short file name (without path information) and line is the line ! number in the file. Note that in the case of the Zero Cost Exception mechanism, these messages become redundant with the Exception_Information that contains a full backtrace of the calling sequence, so they are disabled. To disable explicitly the generation of the source location message, use the *************** representation item for a given entity i *** 4092,4099 **** the representation item is a name that statically denotes a constant declared before the entity. @end cartouche ! Followed. GNAT does not support non-static expressions in representation ! clauses unless they are constants declared before the entity. For example: @smallexample --- 4133,4140 ---- the representation item is a name that statically denotes a constant declared before the entity. @end cartouche ! Followed. GNAT does not support non-static expressions in representation ! clauses unless they are constants declared before the entity. For example: @smallexample *************** for X'Address use To_address (16#2000#); *** 4102,4108 **** @end smallexample @noindent ! will be rejected, since the To_Address expression is non-static. Instead write: @smallexample --- 4143,4149 ---- @end smallexample @noindent ! will be rejected, since the To_Address expression is non-static. Instead write: @smallexample *************** object (including a component) of a give *** 4120,4126 **** constraints on the subtype and its composite subcomponents (if any) are all static constraints. @end cartouche ! Followed. Size Clauses are not permitted on non-static components, as described above. @sp 1 --- 4161,4167 ---- constraints on the subtype and its composite subcomponents (if any) are all static constraints. @end cartouche ! Followed. Size Clauses are not permitted on non-static components, as described above. @sp 1 *************** For a packed record type, the components *** 4147,4156 **** possible subject to the Sizes of the component subtypes, and subject to any @code{record_representation_clause} that applies to the type; the implementation may, but need not, reorder components or cross aligned ! word boundaries to improve the packing. A component whose @code{Size} is greater than the word size may be allocated an integral number of words. @end cartouche ! Followed. Tight packing of arrays is supported for all component sizes up to 64-bits. @sp 1 --- 4188,4197 ---- possible subject to the Sizes of the component subtypes, and subject to any @code{record_representation_clause} that applies to the type; the implementation may, but need not, reorder components or cross aligned ! word boundaries to improve the packing. A component whose @code{Size} is greater than the word size may be allocated an integral number of words. @end cartouche ! Followed. Tight packing of arrays is supported for all component sizes up to 64-bits. @sp 1 *************** Followed. *** 4245,4251 **** @cartouche For stand-alone library-level objects of statically constrained subtypes, the implementation should support all @code{Alignment}s ! supported by the target linker. For example, page alignment is likely to be supported for such objects, but not for subtypes. @end cartouche Followed. --- 4286,4292 ---- @cartouche For stand-alone library-level objects of statically constrained subtypes, the implementation should support all @code{Alignment}s ! supported by the target linker. For example, page alignment is likely to be supported for such objects, but not for subtypes. @end cartouche Followed. *************** The recommended level of support for the *** 4292,4298 **** The @code{Size} (if not specified) of a static discrete or fixed point subtype should be the number of bits needed to represent each value belonging to the subtype using an unbiased representation, leaving space ! for a sign bit only if the subtype contains negative values. If such a subtype is a first subtype, then an implementation should support a specified @code{Size} for it that reflects this representation. @end cartouche --- 4333,4339 ---- The @code{Size} (if not specified) of a static discrete or fixed point subtype should be the number of bits needed to represent each value belonging to the subtype using an unbiased representation, leaving space ! for a sign bit only if the subtype contains negative values. If such a subtype is a first subtype, then an implementation should support a specified @code{Size} for it that reflects this representation. @end cartouche *************** Followed. *** 4323,4331 **** @sp 1 @cartouche An implementation should support specified @code{Component_Size}s that ! are factors and multiples of the word size. For such @code{Component_Size}s, the array should contain no gaps between ! components. For other @code{Component_Size}s (if supported), the array should contain no gaps between components when packing is also specified; the implementation should forbid this combination in cases where it cannot support a no-gaps representation. --- 4364,4372 ---- @sp 1 @cartouche An implementation should support specified @code{Component_Size}s that ! are factors and multiples of the word size. For such @code{Component_Size}s, the array should contain no gaps between ! components. For other @code{Component_Size}s (if supported), the array should contain no gaps between components when packing is also specified; the implementation should forbid this combination in cases where it cannot support a no-gaps representation. *************** Followed. *** 4383,4390 **** An implementation may reserve a storage place for the tag field of a tagged type, and disallow other components from overlapping that place. @end cartouche ! Followed. The storage place for the tag field is the beginning of the tagged ! record, and its size is Address'Size. GNAT will reject an explicit component clause for the tag field. @sp 1 --- 4424,4431 ---- An implementation may reserve a storage place for the tag field of a tagged type, and disallow other components from overlapping that place. @end cartouche ! Followed. The storage place for the tag field is the beginning of the tagged ! record, and its size is Address'Size. GNAT will reject an explicit component clause for the tag field. @sp 1 *************** component of an extension part if the st *** 4394,4400 **** storage places of all components of the parent type, whether or not those storage places had been specified. @end cartouche ! Followed. The above advice on record representation clauses is followed, and all mentioned features are implemented. @cindex Storage place attributes --- 4435,4441 ---- storage places of all components of the parent type, whether or not those storage places had been specified. @end cartouche ! Followed. The above advice on record representation clauses is followed, and all mentioned features are implemented. @cindex Storage place attributes *************** and all mentioned features are implement *** 4404,4415 **** If a component is represented using some form of pointer (such as an offset) to the actual data of the component, and this data is contiguous with the rest of the object, then the storage place attributes should ! reflect the place of the actual data, not the pointer. If a component is allocated discontinuously from the rest of the object, then a warning should be generated upon reference to one of its storage place attributes. @end cartouche ! Followed. There are no such components in GNAT@. @cindex Bit ordering @item 13.5.3(7-8): Bit Ordering --- 4445,4456 ---- If a component is represented using some form of pointer (such as an offset) to the actual data of the component, and this data is contiguous with the rest of the object, then the storage place attributes should ! reflect the place of the actual data, not the pointer. If a component is allocated discontinuously from the rest of the object, then a warning should be generated upon reference to one of its storage place attributes. @end cartouche ! Followed. There are no such components in GNAT@. @cindex Bit ordering @item 13.5.3(7-8): Bit Ordering *************** If @code{Word_Size} = @code{Storage_Unit *** 4423,4429 **** should support the non-default bit ordering in addition to the default bit ordering. @end cartouche ! Followed. Word size does not equal storage size in this implementation. Thus non-default bit ordering is not supported. @cindex @code{Address}, as private type --- 4464,4470 ---- should support the non-default bit ordering in addition to the default bit ordering. @end cartouche ! Followed. Word size does not equal storage size in this implementation. Thus non-default bit ordering is not supported. @cindex @code{Address}, as private type *************** Followed. *** 4440,4450 **** @sp 1 @cartouche Operations in @code{System} and its children should reflect the target ! environment semantics as closely as is reasonable. For example, on most ! machines, it makes sense for address arithmetic to ``wrap around.'' Operations that do not make sense should raise @code{Program_Error}. @end cartouche ! Followed. Address arithmetic is modular arithmetic that wraps around. No operation raises @code{Program_Error}, since all operations make sense. @cindex Unchecked conversion --- 4481,4491 ---- @sp 1 @cartouche Operations in @code{System} and its children should reflect the target ! environment semantics as closely as is reasonable. For example, on most ! machines, it makes sense for address arithmetic to ``wrap around''. Operations that do not make sense should raise @code{Program_Error}. @end cartouche ! Followed. Address arithmetic is modular arithmetic that wraps around. No operation raises @code{Program_Error}, since all operations make sense. @cindex Unchecked conversion *************** Followed. *** 4460,4470 **** @cartouche The implementation should not generate unnecessary run-time checks to ensure that the representation of @var{S} is a representation of the ! target type. It should take advantage of the permission to return by ! reference when possible. Restrictions on unchecked conversions should be avoided unless required by the target environment. @end cartouche ! Followed. There are no restrictions on unchecked conversion. A warning is generated if the source and target types do not have the same size since the semantics in this case may be target dependent. --- 4501,4511 ---- @cartouche The implementation should not generate unnecessary run-time checks to ensure that the representation of @var{S} is a representation of the ! target type. It should take advantage of the permission to return by ! reference when possible. Restrictions on unchecked conversions should be avoided unless required by the target environment. @end cartouche ! Followed. There are no restrictions on unchecked conversion. A warning is generated if the source and target types do not have the same size since the semantics in this case may be target dependent. *************** The recommended level of support for unc *** 4475,4481 **** @sp 1 @cartouche Unchecked conversions should be supported and should be reversible in ! the cases where this clause defines the result. To enable meaningful use of unchecked conversion, a contiguous representation should be used for elementary subtypes, for statically constrained array subtypes whose component subtype is one of the subtypes described in this paragraph, --- 4516,4522 ---- @sp 1 @cartouche Unchecked conversions should be supported and should be reversible in ! the cases where this clause defines the result. To enable meaningful use of unchecked conversion, a contiguous representation should be used for elementary subtypes, for statically constrained array subtypes whose component subtype is one of the subtypes described in this paragraph, *************** objects. *** 4504,4517 **** To allocate space for a task when a task is created. @item ! To extend the secondary stack dynamically when needed. The secondary stack is used for returning variable length results. @end itemize @sp 1 @cartouche ! A default (implementation-provided) storage pool for an access-to- ! constant type should not have overhead to support de-allocation of individual objects. @end cartouche Followed. --- 4545,4558 ---- To allocate space for a task when a task is created. @item ! To extend the secondary stack dynamically when needed. The secondary stack is used for returning variable length results. @end itemize @sp 1 @cartouche ! A default (implementation-provided) storage pool for an ! access-to-constant type should not have overhead to support deallocation of individual objects. @end cartouche Followed. *************** Followed. *** 4539,4549 **** @cartouche If a stream element is the same size as a storage element, then the normal in-memory representation should be used by @code{Read} and ! @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write} should use the smallest number of stream elements needed to represent all values in the base range of the scalar type. @end cartouche ! Followed. In particular, the interpretation chosen is that of AI-195, which specifies that the size to be used is that of the first subtype. @item A.1(52): Implementation Advice --- 4580,4590 ---- @cartouche If a stream element is the same size as a storage element, then the normal in-memory representation should be used by @code{Read} and ! @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write} should use the smallest number of stream elements needed to represent all values in the base range of the scalar type. @end cartouche ! Followed. In particular, the interpretation chosen is that of AI-195, which specifies that the size to be used is that of the first subtype. @item A.1(52): Implementation Advice *************** which specifies that the size to be used *** 4551,4557 **** @cartouche If an implementation provides additional named predefined integer types, then the names should end with @samp{Integer} as in ! @samp{Long_Integer}. If an implementation provides additional named predefined floating point types, then the names should end with @samp{Float} as in @samp{Long_Float}. @end cartouche --- 4592,4598 ---- @cartouche If an implementation provides additional named predefined integer types, then the names should end with @samp{Integer} as in ! @samp{Long_Integer}. If an implementation provides additional named predefined floating point types, then the names should end with @samp{Float} as in @samp{Long_Float}. @end cartouche *************** Followed. *** 4563,4572 **** @cartouche If an implementation provides a localized definition of @code{Character} or @code{Wide_Character}, then the effects of the subprograms in ! @code{Characters.Handling} should reflect the localizations. See also 3.5.2. @end cartouche ! Followed. GNAT provides no such localized definitions. @cindex Bounded-length strings @item A.4.4(106): Bounded-Length String Handling --- 4604,4613 ---- @cartouche If an implementation provides a localized definition of @code{Character} or @code{Wide_Character}, then the effects of the subprograms in ! @code{Characters.Handling} should reflect the localizations. See also 3.5.2. @end cartouche ! Followed. GNAT provides no such localized definitions. @cindex Bounded-length strings @item A.4.4(106): Bounded-Length String Handling *************** Followed. GNAT provides no such localize *** 4575,4581 **** Bounded string objects should not be implemented by implicit pointers and dynamic allocation. @end cartouche ! Followed. No implicit pointers or dynamic allocation are used. @cindex Random number generation @item A.5.2(46-47): Random Number Generation --- 4616,4622 ---- Bounded string objects should not be implemented by implicit pointers and dynamic allocation. @end cartouche ! Followed. No implicit pointers or dynamic allocation are used. @cindex Random number generation @item A.5.2(46-47): Random Number Generation *************** If the generator period is sufficiently *** 4592,4602 **** of distinct initiator values, then each possible value of @code{Initiator} passed to @code{Reset} should initiate a sequence of random numbers that does not, in a practical sense, overlap the sequence ! initiated by any other value. If this is not possible, then the mapping between initiator values and generator states should be a rapidly varying function of the initiator value. @end cartouche ! Followed. The generator period is sufficiently long for the first condition here to hold true. @findex Get_Immediate --- 4633,4643 ---- of distinct initiator values, then each possible value of @code{Initiator} passed to @code{Reset} should initiate a sequence of random numbers that does not, in a practical sense, overlap the sequence ! initiated by any other value. If this is not possible, then the mapping between initiator values and generator states should be a rapidly varying function of the initiator value. @end cartouche ! Followed. The generator period is sufficiently long for the first condition here to hold true. @findex Get_Immediate *************** condition here to hold true. *** 4604,4612 **** @sp 1 @cartouche The @code{Get_Immediate} procedures should be implemented with ! unbuffered input. For a device such as a keyboard, input should be @dfn{available} if a key has already been typed, whereas for a disk ! file, input should always be available except at end of file. For a file associated with a keyboard-like device, any line-editing features of the underlying operating system should be disabled during the execution of @code{Get_Immediate}. --- 4645,4653 ---- @sp 1 @cartouche The @code{Get_Immediate} procedures should be implemented with ! unbuffered input. For a device such as a keyboard, input should be @dfn{available} if a key has already been typed, whereas for a disk ! file, input should always be available except at end of file. For a file associated with a keyboard-like device, any line-editing features of the underlying operating system should be disabled during the execution of @code{Get_Immediate}. *************** Followed. *** 4619,4631 **** @cartouche If an implementation supports pragma @code{Export} to a given language, then it should also allow the main subprogram to be written in that ! language. It should support some mechanism for invoking the elaboration of the Ada library units included in the system, and for invoking the ! finalization of the environment task. On typical systems, the recommended mechanism is to provide two subprograms whose link names are ! @code{adainit} and @code{adafinal}. @code{adainit} should contain the ! elaboration code for library units. @code{adafinal} should contain the ! finalization code. These subprograms should have no effect the second and subsequent time they are called. @end cartouche Followed. --- 4660,4672 ---- @cartouche If an implementation supports pragma @code{Export} to a given language, then it should also allow the main subprogram to be written in that ! language. It should support some mechanism for invoking the elaboration of the Ada library units included in the system, and for invoking the ! finalization of the environment task. On typical systems, the recommended mechanism is to provide two subprograms whose link names are ! @code{adainit} and @code{adafinal}. @code{adainit} should contain the ! elaboration code for library units. @code{adafinal} should contain the ! finalization code. These subprograms should have no effect the second and subsequent time they are called. @end cartouche Followed. *************** Followed. *** 4633,4641 **** @sp 1 @cartouche Automatic elaboration of pre-elaborated packages should be ! provided when pragma Export is supported. @end cartouche ! Followed when the main program is in Ada. If the main program is in a foreign language, then @code{adainit} must be called to elaborate pre-elaborated packages. --- 4674,4682 ---- @sp 1 @cartouche Automatic elaboration of pre-elaborated packages should be ! provided when pragma @code{Export} is supported. @end cartouche ! Followed when the main program is in Ada. If the main program is in a foreign language, then @code{adainit} must be called to elaborate pre-elaborated packages. *************** For each supported convention @var{L} ot *** 4646,4652 **** implementation should support @code{Import} and @code{Export} pragmas for objects of @var{L}-compatible types and for subprograms, and pragma @code{Convention} for @var{L}-eligible types and for subprograms, ! presuming the other language has corresponding features. Pragma @code{Convention} need not be supported for scalar types. @end cartouche Followed. --- 4687,4693 ---- implementation should support @code{Import} and @code{Export} pragmas for objects of @var{L}-compatible types and for subprograms, and pragma @code{Convention} for @var{L}-eligible types and for subprograms, ! presuming the other language has corresponding features. Pragma @code{Convention} need not be supported for scalar types. @end cartouche Followed. *************** Followed. *** 4657,4670 **** @sp 1 @cartouche For each implementation-defined convention identifier, there should be a ! child package of package Interfaces with the corresponding name. This package should contain any declarations that would be useful for interfacing to the language (implementation) represented by the ! convention. Any declarations useful for interfacing to any language on the given hardware architecture should be provided directly in @code{Interfaces}. @end cartouche ! Followed. An additional package not defined in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used for interfacing to C++. --- 4698,4711 ---- @sp 1 @cartouche For each implementation-defined convention identifier, there should be a ! child package of package Interfaces with the corresponding name. This package should contain any declarations that would be useful for interfacing to the language (implementation) represented by the ! convention. Any declarations useful for interfacing to any language on the given hardware architecture should be provided directly in @code{Interfaces}. @end cartouche ! Followed. An additional package not defined in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used for interfacing to C++. *************** An implementation supporting an interfac *** 4674,4680 **** provide the corresponding package or packages described in the following clauses. @end cartouche ! Followed. GNAT provides all the packages described in this section. @cindex C, interfacing with @item B.3(63-71): Interfacing with C --- 4715,4721 ---- provide the corresponding package or packages described in the following clauses. @end cartouche ! Followed. GNAT provides all the packages described in this section. @cindex C, interfacing with @item B.3(63-71): Interfacing with C *************** Followed. *** 4717,4723 **** An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out} parameter of an elementary type @var{T}, is passed as a @code{@var{t}*} argument to a C function, where @var{t} is the C type corresponding to ! the Ada type @var{T}. In the case of an elementary @code{out} or @code{in out} parameter, a pointer to a temporary copy is used to preserve by-copy semantics. @end cartouche --- 4758,4764 ---- An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out} parameter of an elementary type @var{T}, is passed as a @code{@var{t}*} argument to a C function, where @var{t} is the C type corresponding to ! the Ada type @var{T}. In the case of an elementary @code{out} or @code{in out} parameter, a pointer to a temporary copy is used to preserve by-copy semantics. @end cartouche *************** An Ada parameter of a record type @var{T *** 4729,4735 **** @code{@var{t}*} argument to a C function, where @var{t} is the C structure corresponding to the Ada type @var{T}. @end cartouche ! Followed. This convention may be overridden by the use of the C_Pass_By_Copy pragma, or Convention, or by explicitly specifying the mechanism for a given call using an extended import or export pragma. --- 4770,4776 ---- @code{@var{t}*} argument to a C function, where @var{t} is the C structure corresponding to the Ada type @var{T}. @end cartouche ! Followed. This convention may be overridden by the use of the C_Pass_By_Copy pragma, or Convention, or by explicitly specifying the mechanism for a given call using an extended import or export pragma. *************** Followed. *** 4760,4780 **** @sp 1 @cartouche ! An Ada access @var{T} parameter is passed as a ``BY REFERENCE'' data item of the COBOL type corresponding to @var{T}. @end cartouche Followed. @sp 1 @cartouche ! An Ada in scalar parameter is passed as a ``BY CONTENT'' data item of the corresponding COBOL type. @end cartouche Followed. @sp 1 @cartouche ! Any other Ada parameter is passed as a ``BY REFERENCE'' data item of the COBOL type corresponding to the Ada parameter type; for scalars, a local copy is used if necessary to ensure by-copy semantics. @end cartouche --- 4801,4821 ---- @sp 1 @cartouche ! An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of the COBOL type corresponding to @var{T}. @end cartouche Followed. @sp 1 @cartouche ! An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of the corresponding COBOL type. @end cartouche Followed. @sp 1 @cartouche ! Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the COBOL type corresponding to the Ada parameter type; for scalars, a local copy is used if necessary to ensure by-copy semantics. @end cartouche *************** passed as a @var{T} argument to a Fortra *** 4808,4814 **** the Fortran type corresponding to the Ada type @var{T}, and where the INTENT attribute of the corresponding dummy argument matches the Ada formal parameter mode; the Fortran implementation's parameter passing ! conventions are used. For elementary types, a local copy is used if necessary to ensure by-copy semantics. @end cartouche Followed. --- 4849,4855 ---- the Fortran type corresponding to the Ada type @var{T}, and where the INTENT attribute of the corresponding dummy argument matches the Ada formal parameter mode; the Fortran implementation's parameter passing ! conventions are used. For elementary types, a local copy is used if necessary to ensure by-copy semantics. @end cartouche Followed. *************** Followed. *** 4844,4850 **** If an entity is exported to assembly language, then the implementation should allocate it at an addressable location, and should ensure that it is retained by the linking process, even if not otherwise referenced ! from the Ada code. The implementation should assume that any call to a machine code or assembler subprogram is allowed to read or update every object that is specified as exported. @end cartouche --- 4885,4891 ---- If an entity is exported to assembly language, then the implementation should allocate it at an addressable location, and should ensure that it is retained by the linking process, even if not otherwise referenced ! from the Ada code. The implementation should assume that any call to a machine code or assembler subprogram is allowed to read or update every object that is specified as exported. @end cartouche *************** access to any machine operations that pr *** 4865,4894 **** efficiency and that are not otherwise available through the language constructs. @end cartouche ! Followed. A full set of machine operation intrinsic subprograms is provided. @sp 1 @cartouche ! Atomic read-modify-write operations -- e.g.@:, test and set, compare and swap, decrement and test, enqueue/dequeue. @end cartouche Followed on any target supporting such operations. @sp 1 @cartouche ! Standard numeric functions -- e.g.@:, sin, log. @end cartouche Followed on any target supporting such operations. @sp 1 @cartouche ! String manipulation operations -- e.g.@:, translate and test. @end cartouche Followed on any target supporting such operations. @sp 1 @cartouche ! Vector operations -- e.g.@:, compare vector against thresholds. @end cartouche Followed on any target supporting such operations. --- 4906,4935 ---- efficiency and that are not otherwise available through the language constructs. @end cartouche ! Followed. A full set of machine operation intrinsic subprograms is provided. @sp 1 @cartouche ! Atomic read-modify-write operations---e.g.@:, test and set, compare and swap, decrement and test, enqueue/dequeue. @end cartouche Followed on any target supporting such operations. @sp 1 @cartouche ! Standard numeric functions---e.g.@:, sin, log. @end cartouche Followed on any target supporting such operations. @sp 1 @cartouche ! String manipulation operations---e.g.@:, translate and test. @end cartouche Followed on any target supporting such operations. @sp 1 @cartouche ! Vector operations---e.g.@:, compare vector against thresholds. @end cartouche Followed on any target supporting such operations. *************** implementation should provide means for *** 4907,4913 **** interrupts are to be blocked during protected actions, if the underlying system allows for a finer-grain control of interrupt blocking. @end cartouche ! Followed. The underlying system does not allow for finer-grain control of interrupt blocking. @cindex Protected procedure handlers --- 4948,4954 ---- interrupts are to be blocked during protected actions, if the underlying system allows for a finer-grain control of interrupt blocking. @end cartouche ! Followed. The underlying system does not allow for finer-grain control of interrupt blocking. @cindex Protected procedure handlers *************** such direct calls. *** 4929,4935 **** Whenever practical, violations of any implementation-defined restrictions should be detected before run time. @end cartouche ! Followed. Compile time warnings are given when possible. @cindex Package @code{Interrupts} @findex Interrupts --- 4970,4976 ---- Whenever practical, violations of any implementation-defined restrictions should be detected before run time. @end cartouche ! Followed. Compile time warnings are given when possible. @cindex Package @code{Interrupts} @findex Interrupts *************** way that there should be little or no co *** 4954,4960 **** elaboration of entities not already covered by the Implementation Requirements. @end cartouche ! Followed. Executable code is generated in some cases, e.g.@: loops to initialize large arrays. @item C.5(8): Pragma @code{Discard_Names} --- 4995,5001 ---- elaboration of entities not already covered by the Implementation Requirements. @end cartouche ! Followed. Executable code is generated in some cases, e.g.@: loops to initialize large arrays. @item C.5(8): Pragma @code{Discard_Names} *************** Followed. *** 4973,4987 **** @sp 1 @cartouche Some implementations are targeted to domains in which memory use at run ! time must be completely deterministic. For such implementations, it is recommended that the storage for task attributes will be pre-allocated ! statically and not from the heap. This can be accomplished by either placing restrictions on the number and the size of the task's attributes, or by using the pre-allocated storage for the first @var{N} ! attribute objects, and the heap for the others. In the latter case, @var{N} should be documented. @end cartouche ! Not followed. This implementation is not targeted to such a domain. @cindex Locking Policies @item D.3(17): Locking Policies --- 5014,5028 ---- @sp 1 @cartouche Some implementations are targeted to domains in which memory use at run ! time must be completely deterministic. For such implementations, it is recommended that the storage for task attributes will be pre-allocated ! statically and not from the heap. This can be accomplished by either placing restrictions on the number and the size of the task's attributes, or by using the pre-allocated storage for the first @var{N} ! attribute objects, and the heap for the others. In the latter case, @var{N} should be documented. @end cartouche ! Not followed. This implementation is not targeted to such a domain. @cindex Locking Policies @item D.3(17): Locking Policies *************** Not followed. This implementation is not *** 4991,4997 **** The implementation should use names that end with @samp{_Locking} for locking policies defined by the implementation. @end cartouche ! Followed. A single implementation-defined locking policy is defined, whose name (@code{Inheritance_Locking}) follows this suggestion. @cindex Entry queuing policies --- 5032,5038 ---- The implementation should use names that end with @samp{_Locking} for locking policies defined by the implementation. @end cartouche ! Followed. A single implementation-defined locking policy is defined, whose name (@code{Inheritance_Locking}) follows this suggestion. @cindex Entry queuing policies *************** whose name (@code{Inheritance_Locking}) *** 5001,5007 **** Names that end with @samp{_Queuing} should be used for all implementation-defined queuing policies. @end cartouche ! Followed. No such implementation-defined queueing policies exist. @cindex Preemptive abort @item D.6(9-10): Preemptive Abort --- 5042,5048 ---- Names that end with @samp{_Queuing} should be used for all implementation-defined queuing policies. @end cartouche ! Followed. No such implementation-defined queueing policies exist. @cindex Preemptive abort @item D.6(9-10): Preemptive Abort *************** restrictions to produce a more efficient *** 5031,5037 **** @end cartouche GNAT currently takes advantage of these restrictions by providing an optimized run time when the Ravenscar profile and the GNAT restricted run time set ! of restrictions are specified. See pragma @code{Ravenscar} and pragma @code{Restricted_Run_Time} for more details. @cindex Time, monotonic --- 5072,5078 ---- @end cartouche GNAT currently takes advantage of these restrictions by providing an optimized run time when the Ravenscar profile and the GNAT restricted run time set ! of restrictions are specified. See pragma @code{Ravenscar} and pragma @code{Restricted_Run_Time} for more details. @cindex Time, monotonic *************** Followed. *** 5055,5061 **** @cartouche It is recommended that the @dfn{best} time base which exists in the underlying system be available to the application through ! @code{Clock}. @dfn{Best} may mean highest accuracy or largest range. @end cartouche Followed. --- 5096,5102 ---- @cartouche It is recommended that the @dfn{best} time base which exists in the underlying system be available to the application through ! @code{Clock}. @dfn{Best} may mean highest accuracy or largest range. @end cartouche Followed. *************** should allow them to block until the cor *** 5070,5076 **** returns. @end cartouche Followed by GLADE, a separately supplied PCS that can be used with ! GNAT. For information on GLADE, contact Ada Core Technologies. @sp 1 @cartouche --- 5111,5117 ---- returns. @end cartouche Followed by GLADE, a separately supplied PCS that can be used with ! GNAT. @sp 1 @cartouche *************** should raise @code{Storage_Error} if it *** 5079,5085 **** write the @code{Item} into the stream. @end cartouche Followed by GLADE, a separately supplied PCS that can be used with ! GNAT@. For information on GLADE, contact Ada Core Technologies. @cindex COBOL support @item F(7): COBOL Support --- 5120,5126 ---- write the @code{Item} into the stream. @end cartouche Followed by GLADE, a separately supplied PCS that can be used with ! GNAT@. @cindex COBOL support @item F(7): COBOL Support *************** Followed. *** 5102,5108 **** Packed decimal should be used as the internal representation for objects of subtype @var{S} when @var{S}'Machine_Radix = 10. @end cartouche ! Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary representations. @cindex Numerics --- 5143,5149 ---- Packed decimal should be used as the internal representation for objects of subtype @var{S} when @var{S}'Machine_Radix = 10. @end cartouche ! Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary representations. @cindex Numerics *************** Because the usual mathematical meaning o *** 5127,5136 **** operand and a real operand is that of the scaling of both components of the former by the latter, an implementation should not perform this operation by first promoting the real operand to complex type and then ! performing a full complex multiplication. In systems that, in the future, support an Ada binding to IEC 559:1989, the latter technique will not generate the required result when one of the components of the ! complex operand is infinite. (Explicit multiplication of the infinite component by the zero component obtained during promotion yields a NaN that propagates into the final result.) Analogous advice applies in the case of multiplication of a complex operand and a pure-imaginary --- 5168,5177 ---- operand and a real operand is that of the scaling of both components of the former by the latter, an implementation should not perform this operation by first promoting the real operand to complex type and then ! performing a full complex multiplication. In systems that, in the future, support an Ada binding to IEC 559:1989, the latter technique will not generate the required result when one of the components of the ! complex operand is infinite. (Explicit multiplication of the infinite component by the zero component obtained during promotion yields a NaN that propagates into the final result.) Analogous advice applies in the case of multiplication of a complex operand and a pure-imaginary *************** Similarly, because the usual mathematica *** 5145,5156 **** complex operand and a real operand is that the imaginary operand remains unchanged, an implementation should not perform this operation by first promoting the real operand to complex type and then performing a full ! complex addition. In implementations in which the @code{Signed_Zeros} attribute of the component type is @code{True} (and which therefore conform to IEC 559:1989 in regard to the handling of the sign of zero in predefined arithmetic operations), the latter technique will not generate the required result when the imaginary component of the complex ! operand is a negatively signed zero. (Explicit addition of the negative zero to the zero obtained during promotion yields a positive zero.) Analogous advice applies in the case of addition of a complex operand and a pure-imaginary operand, and in the case of subtraction of a --- 5186,5197 ---- complex operand and a real operand is that the imaginary operand remains unchanged, an implementation should not perform this operation by first promoting the real operand to complex type and then performing a full ! complex addition. In implementations in which the @code{Signed_Zeros} attribute of the component type is @code{True} (and which therefore conform to IEC 559:1989 in regard to the handling of the sign of zero in predefined arithmetic operations), the latter technique will not generate the required result when the imaginary component of the complex ! operand is a negatively signed zero. (Explicit addition of the negative zero to the zero obtained during promotion yields a positive zero.) Analogous advice applies in the case of addition of a complex operand and a pure-imaginary operand, and in the case of subtraction of a *************** Not followed. *** 5162,5168 **** @cartouche Implementations in which @code{Real'Signed_Zeros} is @code{True} should attempt to provide a rational treatment of the signs of zero results and ! result components. As one example, the result of the @code{Argument} function should have the sign of the imaginary component of the parameter @code{X} when the point represented by that parameter lies on the positive real axis; as another, the sign of the imaginary component --- 5203,5209 ---- @cartouche Implementations in which @code{Real'Signed_Zeros} is @code{True} should attempt to provide a rational treatment of the signs of zero results and ! result components. As one example, the result of the @code{Argument} function should have the sign of the imaginary component of the parameter @code{X} when the point represented by that parameter lies on the positive real axis; as another, the sign of the imaginary component *************** Followed. *** 5179,5188 **** @cartouche Implementations in which @code{Complex_Types.Real'Signed_Zeros} is @code{True} should attempt to provide a rational treatment of the signs ! of zero results and result components. For example, many of the complex elementary functions have components that are odd functions of one of the parameter components; in these cases, the result component should ! have the sign of the parameter component at the origin. Other complex elementary functions have zero components whose sign is opposite that of a parameter component at the origin, or is always positive or always negative. --- 5220,5229 ---- @cartouche Implementations in which @code{Complex_Types.Real'Signed_Zeros} is @code{True} should attempt to provide a rational treatment of the signs ! of zero results and result components. For example, many of the complex elementary functions have components that are odd functions of one of the parameter components; in these cases, the result component should ! have the sign of the parameter component at the origin. Other complex elementary functions have zero components whose sign is opposite that of a parameter component at the origin, or is always positive or always negative. *************** The versions of the forward trigonometri *** 5197,5203 **** @code{Cycle} parameter should not be implemented by calling the corresponding version with a @code{Cycle} parameter of @code{2.0*Numerics.Pi}, since this will not provide the required ! accuracy in some portions of the domain. For the same reason, the version of @code{Log} without a @code{Base} parameter should not be implemented by calling the corresponding version with a @code{Base} parameter of @code{Numerics.e}. --- 5238,5244 ---- @code{Cycle} parameter should not be implemented by calling the corresponding version with a @code{Cycle} parameter of @code{2.0*Numerics.Pi}, since this will not provide the required ! accuracy in some portions of the domain. For the same reason, the version of @code{Log} without a @code{Base} parameter should not be implemented by calling the corresponding version with a @code{Base} parameter of @code{Numerics.e}. *************** Followed. *** 5223,5234 **** @chapter Implementation Defined Characteristics In addition to the implementation dependent pragmas and attributes, and the implementation advice, there are a number of other features of Ada ! 95 that are potentially implementation dependent. These are mentioned throughout the Ada 95 Reference Manual, and are summarized in annex M@. A requirement for conforming Ada compilers is that they provide documentation describing how the implementation deals with each of these ! issues. In this chapter, you will find each point in annex M listed followed by a description in italic font of how GNAT @c SGI info: @ignore --- 5264,5275 ---- @chapter Implementation Defined Characteristics In addition to the implementation dependent pragmas and attributes, and the implementation advice, there are a number of other features of Ada ! 95 that are potentially implementation dependent. These are mentioned throughout the Ada 95 Reference Manual, and are summarized in annex M@. A requirement for conforming Ada compilers is that they provide documentation describing how the implementation deals with each of these ! issues. In this chapter, you will find each point in annex M listed followed by a description in italic font of how GNAT @c SGI info: @ignore *************** Reference Manual. *** 5247,5253 **** @cartouche @noindent @strong{2}. Whether or not each recommendation given in Implementation ! Advice is followed. See 1.1.2(37). @end cartouche @noindent @xref{Implementation Advice}. --- 5288,5294 ---- @cartouche @noindent @strong{2}. Whether or not each recommendation given in Implementation ! Advice is followed. See 1.1.2(37). @end cartouche @noindent @xref{Implementation Advice}. *************** Advice is followed. See 1.1.2(37). *** 5255,5261 **** @sp 1 @cartouche @noindent ! @strong{3}. Capacity limitations of the implementation. See 1.1.3(3). @end cartouche @noindent The complexity of programs that can be processed is limited only by the --- 5296,5302 ---- @sp 1 @cartouche @noindent ! @strong{3}. Capacity limitations of the implementation. See 1.1.3(3). @end cartouche @noindent The complexity of programs that can be processed is limited only by the *************** generated object files. *** 5266,5272 **** @cartouche @noindent @strong{4}. Variations from the standard that are impractical to avoid ! given the implementation's execution environment. See 1.1.3(6). @end cartouche @noindent There are no variations from the standard. --- 5307,5313 ---- @cartouche @noindent @strong{4}. Variations from the standard that are impractical to avoid ! given the implementation's execution environment. See 1.1.3(6). @end cartouche @noindent There are no variations from the standard. *************** There are no variations from the standar *** 5275,5281 **** @cartouche @noindent @strong{5}. Which @code{code_statement}s cause external ! interactions. See 1.1.3(10). @end cartouche @noindent Any @code{code_statement} can potentially cause external interactions. --- 5316,5322 ---- @cartouche @noindent @strong{5}. Which @code{code_statement}s cause external ! interactions. See 1.1.3(10). @end cartouche @noindent Any @code{code_statement} can potentially cause external interactions. *************** Any @code{code_statement} can potentiall *** 5284,5290 **** @cartouche @noindent @strong{6}. The coded representation for the text of an Ada ! program. See 2.1(4). @end cartouche @noindent See separate section on source representation. --- 5325,5331 ---- @cartouche @noindent @strong{6}. The coded representation for the text of an Ada ! program. See 2.1(4). @end cartouche @noindent See separate section on source representation. *************** See separate section on source represent *** 5292,5298 **** @sp 1 @cartouche @noindent ! @strong{7}. The control functions allowed in comments. See 2.1(14). @end cartouche @noindent See separate section on source representation. --- 5333,5339 ---- @sp 1 @cartouche @noindent ! @strong{7}. The control functions allowed in comments. See 2.1(14). @end cartouche @noindent See separate section on source representation. *************** See separate section on source represent *** 5300,5306 **** @sp 1 @cartouche @noindent ! @strong{8}. The representation for an end of line. See 2.2(2). @end cartouche @noindent See separate section on source representation. --- 5341,5347 ---- @sp 1 @cartouche @noindent ! @strong{8}. The representation for an end of line. See 2.2(2). @end cartouche @noindent See separate section on source representation. *************** See separate section on source represent *** 5309,5315 **** @cartouche @noindent @strong{9}. Maximum supported line length and lexical element ! length. See 2.2(15). @end cartouche @noindent The maximum line length is 255 characters an the maximum length of a --- 5350,5356 ---- @cartouche @noindent @strong{9}. Maximum supported line length and lexical element ! length. See 2.2(15). @end cartouche @noindent The maximum line length is 255 characters an the maximum length of a *************** lexical element is also 255 characters. *** 5318,5324 **** @sp 1 @cartouche @noindent ! @strong{10}. Implementation defined pragmas. See 2.8(14). @end cartouche @noindent --- 5359,5365 ---- @sp 1 @cartouche @noindent ! @strong{10}. Implementation defined pragmas. See 2.8(14). @end cartouche @noindent *************** lexical element is also 255 characters. *** 5327,5333 **** @sp 1 @cartouche @noindent ! @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27). @end cartouche @noindent Pragma @code{Optimize}, if given with a @code{Time} or @code{Space} --- 5368,5374 ---- @sp 1 @cartouche @noindent ! @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27). @end cartouche @noindent Pragma @code{Optimize}, if given with a @code{Time} or @code{Space} *************** not. *** 5339,5357 **** @noindent @strong{12}. The sequence of characters of the value returned by @code{@var{S}'Image} when some of the graphic characters of ! @code{@var{S}'Wide_Image} are not defined in @code{Character}. See 3.5(37). @end cartouche @noindent The sequence of characters is as defined by the wide character encoding ! method used for the source. See section on source representation for further details. @sp 1 @cartouche @noindent @strong{13}. The predefined integer types declared in ! @code{Standard}. See 3.5.4(25). @end cartouche @noindent @table @code --- 5380,5398 ---- @noindent @strong{12}. The sequence of characters of the value returned by @code{@var{S}'Image} when some of the graphic characters of ! @code{@var{S}'Wide_Image} are not defined in @code{Character}. See 3.5(37). @end cartouche @noindent The sequence of characters is as defined by the wide character encoding ! method used for the source. See section on source representation for further details. @sp 1 @cartouche @noindent @strong{13}. The predefined integer types declared in ! @code{Standard}. See 3.5.4(25). @end cartouche @noindent @table @code *************** further details. *** 5372,5378 **** @cartouche @noindent @strong{14}. Any nonstandard integer types and the operators defined ! for them. See 3.5.4(26). @end cartouche @noindent There are no nonstandard integer types. --- 5413,5419 ---- @cartouche @noindent @strong{14}. Any nonstandard integer types and the operators defined ! for them. See 3.5.4(26). @end cartouche @noindent There are no nonstandard integer types. *************** There are no nonstandard integer types. *** 5381,5387 **** @cartouche @noindent @strong{15}. Any nonstandard real types and the operators defined for ! them. See 3.5.6(8). @end cartouche @noindent There are no nonstandard real types. --- 5422,5428 ---- @cartouche @noindent @strong{15}. Any nonstandard real types and the operators defined for ! them. See 3.5.6(8). @end cartouche @noindent There are no nonstandard real types. *************** There are no nonstandard real types. *** 5390,5396 **** @cartouche @noindent @strong{16}. What combinations of requested decimal precision and range ! are supported for floating point types. See 3.5.7(7). @end cartouche @noindent The precision and range is as defined by the IEEE standard. --- 5431,5437 ---- @cartouche @noindent @strong{16}. What combinations of requested decimal precision and range ! are supported for floating point types. See 3.5.7(7). @end cartouche @noindent The precision and range is as defined by the IEEE standard. *************** The precision and range is as defined by *** 5399,5405 **** @cartouche @noindent @strong{17}. The predefined floating point types declared in ! @code{Standard}. See 3.5.7(16). @end cartouche @noindent @table @code --- 5440,5446 ---- @cartouche @noindent @strong{17}. The predefined floating point types declared in ! @code{Standard}. See 3.5.7(16). @end cartouche @noindent @table @code *************** The precision and range is as defined by *** 5416,5445 **** @sp 1 @cartouche @noindent ! @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8). @end cartouche @noindent ! @code{Fine_Delta} is 2**(-63) @sp 1 @cartouche @noindent @strong{19}. What combinations of small, range, and digits are ! supported for fixed point types. See 3.5.9(10). @end cartouche @noindent Any combinations are permitted that do not result in a small less than @code{Fine_Delta} and do not result in a mantissa larger than 63 bits. If the mantissa is larger than 53 bits on machines where Long_Long_Float is 64 bits (true of all architectures except ia32), then the output from ! Text_IO is accurate to only 53 bits, rather than the full mantissa. This is because floating-point conversions are used to convert fixed point. @sp 1 @cartouche @noindent @strong{20}. The result of @code{Tags.Expanded_Name} for types declared ! within an unnamed @code{block_statement}. See 3.9(10). @end cartouche @noindent Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a --- 5457,5486 ---- @sp 1 @cartouche @noindent ! @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8). @end cartouche @noindent ! @code{Fine_Delta} is 2**(@minus{}63) @sp 1 @cartouche @noindent @strong{19}. What combinations of small, range, and digits are ! supported for fixed point types. See 3.5.9(10). @end cartouche @noindent Any combinations are permitted that do not result in a small less than @code{Fine_Delta} and do not result in a mantissa larger than 63 bits. If the mantissa is larger than 53 bits on machines where Long_Long_Float is 64 bits (true of all architectures except ia32), then the output from ! Text_IO is accurate to only 53 bits, rather than the full mantissa. This is because floating-point conversions are used to convert fixed point. @sp 1 @cartouche @noindent @strong{20}. The result of @code{Tags.Expanded_Name} for types declared ! within an unnamed @code{block_statement}. See 3.9(10). @end cartouche @noindent Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a *************** decimal integer are allocated. *** 5448,5454 **** @sp 1 @cartouche @noindent ! @strong{21}. Implementation-defined attributes. See 4.1.4(12). @end cartouche @noindent @xref{Implementation Defined Attributes}. --- 5489,5495 ---- @sp 1 @cartouche @noindent ! @strong{21}. Implementation-defined attributes. See 4.1.4(12). @end cartouche @noindent @xref{Implementation Defined Attributes}. *************** decimal integer are allocated. *** 5456,5462 **** @sp 1 @cartouche @noindent ! @strong{22}. Any implementation-defined time types. See 9.6(6). @end cartouche @noindent There are no implementation-defined time types. --- 5497,5503 ---- @sp 1 @cartouche @noindent ! @strong{22}. Any implementation-defined time types. See 9.6(6). @end cartouche @noindent There are no implementation-defined time types. *************** There are no implementation-defined time *** 5467,5479 **** @strong{23}. The time base associated with relative delays. @end cartouche @noindent ! See 9.6(20). The time base used is that provided by the C library function @code{gettimeofday}. @sp 1 @cartouche @noindent ! @strong{24}. The time base of the type @code{Calendar.Time}. See 9.6(23). @end cartouche @noindent --- 5508,5520 ---- @strong{23}. The time base associated with relative delays. @end cartouche @noindent ! See 9.6(20). The time base used is that provided by the C library function @code{gettimeofday}. @sp 1 @cartouche @noindent ! @strong{24}. The time base of the type @code{Calendar.Time}. See 9.6(23). @end cartouche @noindent *************** The time base used is that provided by t *** 5484,5490 **** @cartouche @noindent @strong{25}. The time zone used for package @code{Calendar} ! operations. See 9.6(24). @end cartouche @noindent The time zone used by package @code{Calendar} is the current system time zone --- 5525,5531 ---- @cartouche @noindent @strong{25}. The time zone used for package @code{Calendar} ! operations. See 9.6(24). @end cartouche @noindent The time zone used by package @code{Calendar} is the current system time zone *************** setting for local time, as accessed by t *** 5495,5501 **** @cartouche @noindent @strong{26}. Any limit on @code{delay_until_statements} of ! @code{select_statements}. See 9.6(29). @end cartouche @noindent There are no such limits. --- 5536,5542 ---- @cartouche @noindent @strong{26}. Any limit on @code{delay_until_statements} of ! @code{select_statements}. See 9.6(29). @end cartouche @noindent There are no such limits. *************** There are no such limits. *** 5505,5511 **** @noindent @strong{27}. Whether or not two non overlapping parts of a composite object are independently addressable, in the case where packing, record ! layout, or @code{Component_Size} is specified for the object. See 9.10(1). @end cartouche @noindent --- 5546,5552 ---- @noindent @strong{27}. Whether or not two non overlapping parts of a composite object are independently addressable, in the case where packing, record ! layout, or @code{Component_Size} is specified for the object. See 9.10(1). @end cartouche @noindent *************** overlapping storage units. *** 5515,5531 **** @sp 1 @cartouche @noindent ! @strong{28}. The representation for a compilation. See 10.1(2). @end cartouche @noindent A compilation is represented by a sequence of files presented to the ! compiler in a single invocation of the @file{gcc} command. @sp 1 @cartouche @noindent @strong{29}. Any restrictions on compilations that contain multiple ! compilation_units. See 10.1(4). @end cartouche @noindent No single file can contain more than one compilation unit, but any --- 5556,5572 ---- @sp 1 @cartouche @noindent ! @strong{28}. The representation for a compilation. See 10.1(2). @end cartouche @noindent A compilation is represented by a sequence of files presented to the ! compiler in a single invocation of the @code{gcc} command. @sp 1 @cartouche @noindent @strong{29}. Any restrictions on compilations that contain multiple ! compilation_units. See 10.1(4). @end cartouche @noindent No single file can contain more than one compilation unit, but any *************** compilation. *** 5536,5542 **** @cartouche @noindent @strong{30}. The mechanisms for creating an environment and for adding ! and replacing compilation units. See 10.1.4(3). @end cartouche @noindent See separate section on compilation model. --- 5577,5583 ---- @cartouche @noindent @strong{30}. The mechanisms for creating an environment and for adding ! and replacing compilation units. See 10.1.4(3). @end cartouche @noindent See separate section on compilation model. *************** See separate section on compilation mode *** 5545,5581 **** @cartouche @noindent @strong{31}. The manner of explicitly assigning library units to a ! partition. See 10.2(2). @end cartouche @noindent If a unit contains an Ada main program, then the Ada units for the partition are determined by recursive application of the rules in the Ada Reference ! Manual section 10.2(2-6). In other words, the Ada units will be those that are needed by the main program, and then this definition of need is applied recursively to those units, and the partition contains the transitive ! closure determined by this relationship. In short, all the necessary units ! are included, with no need to explicitly specify the list. If additional units are required, e.g.@: by foreign language units, then all units must be mentioned in the context clause of one of the needed Ada units. If the partition contains no main program, or if the main program is in a language other than Ada, then GNAT ! provides the binder options -z and -n respectively, and in this case a list of units can be explicitly supplied to the binder for inclusion in the partition (all units needed by these units will also be included ! automatically). For full details on the use of these options, refer to ! the User Guide sections on Binding and Linking. @sp 1 @cartouche @noindent @strong{32}. The implementation-defined means, if any, of specifying ! which compilation units are needed by a given compilation unit. See 10.2(2). @end cartouche @noindent The units needed by a given compilation unit are as defined in ! the Ada Reference Manual section 10.2(2-6). There are no implementation-defined pragmas or other implementation-defined means for specifying needed units. --- 5586,5622 ---- @cartouche @noindent @strong{31}. The manner of explicitly assigning library units to a ! partition. See 10.2(2). @end cartouche @noindent If a unit contains an Ada main program, then the Ada units for the partition are determined by recursive application of the rules in the Ada Reference ! Manual section 10.2(2-6). In other words, the Ada units will be those that are needed by the main program, and then this definition of need is applied recursively to those units, and the partition contains the transitive ! closure determined by this relationship. In short, all the necessary units ! are included, with no need to explicitly specify the list. If additional units are required, e.g.@: by foreign language units, then all units must be mentioned in the context clause of one of the needed Ada units. If the partition contains no main program, or if the main program is in a language other than Ada, then GNAT ! provides the binder options @code{-z} and @code{-n} respectively, and in this case a list of units can be explicitly supplied to the binder for inclusion in the partition (all units needed by these units will also be included ! automatically). For full details on the use of these options, refer to ! the @cite{GNAT User's Guide} sections on Binding and Linking. @sp 1 @cartouche @noindent @strong{32}. The implementation-defined means, if any, of specifying ! which compilation units are needed by a given compilation unit. See 10.2(2). @end cartouche @noindent The units needed by a given compilation unit are as defined in ! the Ada Reference Manual section 10.2(2-6). There are no implementation-defined pragmas or other implementation-defined means for specifying needed units. *************** means for specifying needed units. *** 5583,5603 **** @cartouche @noindent @strong{33}. The manner of designating the main subprogram of a ! partition. See 10.2(7). @end cartouche @noindent The main program is designated by providing the name of the ! corresponding ali file as the input parameter to the binder. @sp 1 @cartouche @noindent ! @strong{34}. The order of elaboration of @code{library_items}. See 10.2(18). @end cartouche @noindent The first constraint on ordering is that it meets the requirements of ! chapter 10 of the Ada 95 Reference Manual. This still leaves some implementation dependent choices, which are resolved by first elaborating bodies as early as possible (i.e.@: in preference to specs where there is a choice), and second by evaluating the immediate with --- 5624,5644 ---- @cartouche @noindent @strong{33}. The manner of designating the main subprogram of a ! partition. See 10.2(7). @end cartouche @noindent The main program is designated by providing the name of the ! corresponding @file{ALI} file as the input parameter to the binder. @sp 1 @cartouche @noindent ! @strong{34}. The order of elaboration of @code{library_items}. See 10.2(18). @end cartouche @noindent The first constraint on ordering is that it meets the requirements of ! chapter 10 of the Ada 95 Reference Manual. This still leaves some implementation dependent choices, which are resolved by first elaborating bodies as early as possible (i.e.@: in preference to specs where there is a choice), and second by evaluating the immediate with *************** where a choice still remains. *** 5609,5639 **** @cartouche @noindent @strong{35}. Parameter passing and function return for the main ! subprogram. See 10.2(21). @end cartouche @noindent ! The main program has no parameters. It may be a procedure, or a function ! returning an integer type. In the latter case, the returned integer value is the return code of the program. @sp 1 @cartouche @noindent ! @strong{36}. The mechanisms for building and running partitions. See 10.2(24). @end cartouche @noindent ! GNAT itself supports programs with only a single partition. The GNATDIST tool provided with the GLADE package (which also includes an implementation of the PCS) provides a completely flexible method for building and running ! programs consisting of multiple partitions. See the separate GLADE manual for details. @sp 1 @cartouche @noindent @strong{37}. The details of program execution, including program ! termination. See 10.2(25). @end cartouche @noindent See separate section on compilation model. --- 5650,5680 ---- @cartouche @noindent @strong{35}. Parameter passing and function return for the main ! subprogram. See 10.2(21). @end cartouche @noindent ! The main program has no parameters. It may be a procedure, or a function ! returning an integer type. In the latter case, the returned integer value is the return code of the program. @sp 1 @cartouche @noindent ! @strong{36}. The mechanisms for building and running partitions. See 10.2(24). @end cartouche @noindent ! GNAT itself supports programs with only a single partition. The GNATDIST tool provided with the GLADE package (which also includes an implementation of the PCS) provides a completely flexible method for building and running ! programs consisting of multiple partitions. See the separate GLADE manual for details. @sp 1 @cartouche @noindent @strong{37}. The details of program execution, including program ! termination. See 10.2(25). @end cartouche @noindent See separate section on compilation model. *************** See separate section on compilation mode *** 5642,5658 **** @cartouche @noindent @strong{38}. The semantics of any non-active partitions supported by the ! implementation. See 10.2(28). @end cartouche @noindent Passive partitions are supported on targets where shared memory is ! provided by the operating system. See the GLADE reference manual for further details. @sp 1 @cartouche @noindent ! @strong{39}. The information returned by @code{Exception_Message}. See 11.4.1(10). @end cartouche @noindent --- 5683,5699 ---- @cartouche @noindent @strong{38}. The semantics of any non-active partitions supported by the ! implementation. See 10.2(28). @end cartouche @noindent Passive partitions are supported on targets where shared memory is ! provided by the operating system. See the GLADE reference manual for further details. @sp 1 @cartouche @noindent ! @strong{39}. The information returned by @code{Exception_Message}. See 11.4.1(10). @end cartouche @noindent *************** been passed by the program. *** 5663,5669 **** @cartouche @noindent @strong{40}. The result of @code{Exceptions.Exception_Name} for types ! declared within an unnamed @code{block_statement}. See 11.4.1(12). @end cartouche @noindent Blocks have implementation defined names of the form @code{B@var{nnn}} --- 5704,5710 ---- @cartouche @noindent @strong{40}. The result of @code{Exceptions.Exception_Name} for types ! declared within an unnamed @code{block_statement}. See 11.4.1(12). @end cartouche @noindent Blocks have implementation defined names of the form @code{B@var{nnn}} *************** where @var{nnn} is an integer. *** 5673,5688 **** @cartouche @noindent @strong{41}. The information returned by ! @code{Exception_Information}. See 11.4.1(13). @end cartouche @noindent ! @code{Exception_Information} contains the expanded name of the exception ! in upper case, and no other information. @sp 1 @cartouche @noindent ! @strong{42}. Implementation-defined check names. See 11.5(27). @end cartouche @noindent No implementation-defined check names are supported. --- 5714,5763 ---- @cartouche @noindent @strong{41}. The information returned by ! @code{Exception_Information}. See 11.4.1(13). @end cartouche @noindent ! @code{Exception_Information} returns a string in the following format: ! ! @smallexample ! @emph{Exception_Name:} nnnnn ! @emph{Message:} mmmmm ! @emph{PID:} ppp ! @emph{Call stack traceback locations:} ! 0xhhhh 0xhhhh 0xhhhh ... 0xhhh ! @end smallexample ! ! @noindent ! where ! ! @itemize @bullet ! @item ! @code{nnnn} is the fully qualified name of the exception in all upper ! case letters. This line is always present. ! ! @item ! @code{mmmm} is the message (this line present only if message is non-null) ! ! @item ! @code{ppp} is the Process Id value as a decimal integer (this line is ! present only if the Process Id is non-zero). Currently we are ! not making use of this field. ! ! @item ! The Call stack traceback locations line and the following values ! are present only if at least one traceback location was recorded. ! The values are given in C style format, with lower case letters ! for a-f, and only as many digits present as are necessary. ! @end itemize ! ! @noindent ! The line terminator sequence at the end of each line, including ! the last line is a single @code{LF} character (@code{16#0A#}). @sp 1 @cartouche @noindent ! @strong{42}. Implementation-defined check names. See 11.5(27). @end cartouche @noindent No implementation-defined check names are supported. *************** No implementation-defined check names ar *** 5690,5696 **** @sp 1 @cartouche @noindent ! @strong{43}. The interpretation of each aspect of representation. See 13.1(20). @end cartouche @noindent --- 5765,5771 ---- @sp 1 @cartouche @noindent ! @strong{43}. The interpretation of each aspect of representation. See 13.1(20). @end cartouche @noindent *************** See separate section on data representat *** 5699,5705 **** @sp 1 @cartouche @noindent ! @strong{44}. Any restrictions placed upon representation items. See 13.1(20). @end cartouche @noindent --- 5774,5780 ---- @sp 1 @cartouche @noindent ! @strong{44}. Any restrictions placed upon representation items. See 13.1(20). @end cartouche @noindent *************** See separate section on data representat *** 5708,5714 **** @sp 1 @cartouche @noindent ! @strong{45}. The meaning of @code{Size} for indefinite subtypes. See 13.3(48). @end cartouche @noindent --- 5783,5789 ---- @sp 1 @cartouche @noindent ! @strong{45}. The meaning of @code{Size} for indefinite subtypes. See 13.3(48). @end cartouche @noindent *************** is the actual size. *** 5719,5725 **** @sp 1 @cartouche @noindent ! @strong{46}. The default external representation for a type tag. See 13.3(75). @end cartouche @noindent --- 5794,5800 ---- @sp 1 @cartouche @noindent ! @strong{46}. The default external representation for a type tag. See 13.3(75). @end cartouche @noindent *************** name of the type in upper case letters. *** 5730,5736 **** @cartouche @noindent @strong{47}. What determines whether a compilation unit is the same in ! two different partitions. See 13.3(76). @end cartouche @noindent A compilation unit is the same in two different partitions if and only --- 5805,5811 ---- @cartouche @noindent @strong{47}. What determines whether a compilation unit is the same in ! two different partitions. See 13.3(76). @end cartouche @noindent A compilation unit is the same in two different partitions if and only *************** if it derives from the same source file. *** 5739,5745 **** @sp 1 @cartouche @noindent ! @strong{48}. Implementation-defined components. See 13.5.1(15). @end cartouche @noindent The only implementation defined component is the tag for a tagged type, --- 5814,5820 ---- @sp 1 @cartouche @noindent ! @strong{48}. Implementation-defined components. See 13.5.1(15). @end cartouche @noindent The only implementation defined component is the tag for a tagged type, *************** which contains a pointer to the dispatch *** 5749,5766 **** @cartouche @noindent @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit ! ordering. See 13.5.3(5). @end cartouche @noindent @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this ! implementation, so no non-default bit ordering is supported. The default bit ordering corresponds to the natural endianness of the target architecture. @sp 1 @cartouche @noindent @strong{50}. The contents of the visible part of package @code{System} ! and its language-defined children. See 13.7(2). @end cartouche @noindent See the definition of these packages in files @file{system.ads} and --- 5824,5841 ---- @cartouche @noindent @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit ! ordering. See 13.5.3(5). @end cartouche @noindent @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this ! implementation, so no non-default bit ordering is supported. The default bit ordering corresponds to the natural endianness of the target architecture. @sp 1 @cartouche @noindent @strong{50}. The contents of the visible part of package @code{System} ! and its language-defined children. See 13.7(2). @end cartouche @noindent See the definition of these packages in files @file{system.ads} and *************** See the definition of these packages in *** 5771,5777 **** @noindent @strong{51}. The contents of the visible part of package @code{System.Machine_Code}, and the meaning of ! @code{code_statements}. See 13.8(7). @end cartouche @noindent See the definition and documentation in file @file{s-maccod.ads}. --- 5846,5852 ---- @noindent @strong{51}. The contents of the visible part of package @code{System.Machine_Code}, and the meaning of ! @code{code_statements}. See 13.8(7). @end cartouche @noindent See the definition and documentation in file @file{s-maccod.ads}. *************** See the definition and documentation in *** 5779,5790 **** @sp 1 @cartouche @noindent ! @strong{52}. The effect of unchecked conversion. See 13.9(11). @end cartouche @noindent Unchecked conversion between types of the same size and results in an uninterpreted transmission of the bits from one type ! to the other. If the types are of unequal sizes, then in the case of discrete types, a shorter source is first zero or sign extended as necessary, and a shorter target is simply truncated on the left. For all non-discrete types, the source is first copied if necessary --- 5854,5865 ---- @sp 1 @cartouche @noindent ! @strong{52}. The effect of unchecked conversion. See 13.9(11). @end cartouche @noindent Unchecked conversion between types of the same size and results in an uninterpreted transmission of the bits from one type ! to the other. If the types are of unequal sizes, then in the case of discrete types, a shorter source is first zero or sign extended as necessary, and a shorter target is simply truncated on the left. For all non-discrete types, the source is first copied if necessary *************** target type. *** 5797,5809 **** @cartouche @noindent @strong{53}. The manner of choosing a storage pool for an access type ! when @code{Storage_Pool} is not specified for the type. See 13.11(17). @end cartouche @noindent There are 3 different standard pools used by the compiler when @code{Storage_Pool} is not specified depending whether the type is local to a subprogram or defined at the library level and whether ! @code{Storage_Size}is specified or not. See documentation in the runtime library units @code{System.Pool_Global}, @code{System.Pool_Size} and @code{System.Pool_Local} in files @file{s-poosiz.ads}, @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the --- 5872,5884 ---- @cartouche @noindent @strong{53}. The manner of choosing a storage pool for an access type ! when @code{Storage_Pool} is not specified for the type. See 13.11(17). @end cartouche @noindent There are 3 different standard pools used by the compiler when @code{Storage_Pool} is not specified depending whether the type is local to a subprogram or defined at the library level and whether ! @code{Storage_Size}is specified or not. See documentation in the runtime library units @code{System.Pool_Global}, @code{System.Pool_Size} and @code{System.Pool_Local} in files @file{s-poosiz.ads}, @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the *************** default pools used. *** 5813,5830 **** @cartouche @noindent @strong{54}. Whether or not the implementation provides user-accessible ! names for the standard pool type(s). See 13.11(17). @end cartouche @noindent See documentation in the sources of the run time mentioned in paragraph ! @strong{53} . All these pools are accessible by means of @code{with}'ing these units. @sp 1 @cartouche @noindent ! @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18). @end cartouche @noindent @code{Storage_Size} is measured in storage units, and refers to the --- 5888,5905 ---- @cartouche @noindent @strong{54}. Whether or not the implementation provides user-accessible ! names for the standard pool type(s). See 13.11(17). @end cartouche @noindent See documentation in the sources of the run time mentioned in paragraph ! @strong{53} . All these pools are accessible by means of @code{with}'ing these units. @sp 1 @cartouche @noindent ! @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18). @end cartouche @noindent @code{Storage_Size} is measured in storage units, and refers to the *************** stack space for a task. *** 5834,5840 **** @sp 1 @cartouche @noindent ! @strong{56}. Implementation-defined aspects of storage pools. See 13.11(22). @end cartouche @noindent --- 5909,5915 ---- @sp 1 @cartouche @noindent ! @strong{56}. Implementation-defined aspects of storage pools. See 13.11(22). @end cartouche @noindent *************** See documentation in the sources of the *** 5845,5856 **** @cartouche @noindent @strong{57}. The set of restrictions allowed in a pragma ! @code{Restrictions}. See 13.12(7). @end cartouche @noindent ! All RM defined Restriction identifiers are implemented. The following ! additional restriction identifiers are provided. There are two separate ! lists of implementation dependent restriction identifiers. The first set requires consistency throughout a partition (in other words, if the restriction identifier is used for any compilation unit in the partition, then all compilation units in the partition must obey the restriction. --- 5920,5931 ---- @cartouche @noindent @strong{57}. The set of restrictions allowed in a pragma ! @code{Restrictions}. See 13.12(7). @end cartouche @noindent ! All RM defined Restriction identifiers are implemented. The following ! additional restriction identifiers are provided. There are two separate ! lists of implementation dependent restriction identifiers. The first set requires consistency throughout a partition (in other words, if the restriction identifier is used for any compilation unit in the partition, then all compilation units in the partition must obey the restriction. *************** then all compilation units in the partit *** 5861,5877 **** @findex Boolean_Entry_Barriers This restriction ensures at compile time that barriers in entry declarations for protected types are restricted to references to simple boolean variables ! defined in the private part of the protected type. No other form of entry ! barriers is permitted. This is one of the restrictions of the Ravenscar ! profile for limited tasking (see also pragma Ravenscar). @item Max_Entry_Queue_Depth => Expr @findex Max_Entry_Queue_Depth This restriction is a declaration that any protected entry compiled in the scope of the restriction has at most the specified number of tasks waiting on the entry ! at any one time, and so no queue is required. This restriction is not ! checked at compile time. A program execution is erroneous if an attempt is made to queue more than the specified number of tasks on such an entry. @item No_Calendar --- 5936,5952 ---- @findex Boolean_Entry_Barriers This restriction ensures at compile time that barriers in entry declarations for protected types are restricted to references to simple boolean variables ! defined in the private part of the protected type. No other form of entry ! barriers is permitted. This is one of the restrictions of the Ravenscar ! profile for limited tasking (see also pragma @code{Ravenscar}). @item Max_Entry_Queue_Depth => Expr @findex Max_Entry_Queue_Depth This restriction is a declaration that any protected entry compiled in the scope of the restriction has at most the specified number of tasks waiting on the entry ! at any one time, and so no queue is required. This restriction is not ! checked at compile time. A program execution is erroneous if an attempt is made to queue more than the specified number of tasks on such an entry. @item No_Calendar *************** explicit dependence on the package @code *** 5882,5888 **** @item No_Dynamic_Interrupts @findex No_Dynamic_Interrupts This restriction ensures at compile time that there is no attempt to ! dynamically associate interrupts. Only static association is allowed. @item No_Enumeration_Maps @findex No_Enumeration_Maps --- 5957,5963 ---- @item No_Dynamic_Interrupts @findex No_Dynamic_Interrupts This restriction ensures at compile time that there is no attempt to ! dynamically associate interrupts. Only static association is allowed. @item No_Enumeration_Maps @findex No_Enumeration_Maps *************** to enumeration types). *** 5893,5899 **** @item No_Entry_Calls_In_Elaboration_Code @findex No_Entry_Calls_In_Elaboration_Code This restriction ensures at compile time that no task or protected entry ! calls are made during elaboration code. As a result of the use of this restriction, the compiler can assume that no code past an accept statement in a task can be executed at elaboration time. --- 5968,5974 ---- @item No_Entry_Calls_In_Elaboration_Code @findex No_Entry_Calls_In_Elaboration_Code This restriction ensures at compile time that no task or protected entry ! calls are made during elaboration code. As a result of the use of this restriction, the compiler can assume that no code past an accept statement in a task can be executed at elaboration time. *************** exception handlers. *** 5907,5913 **** This restriction ensures that the generated code does not contain any implicit conditionals, either by modifying the generated code where possible, or by rejecting any construct that would otherwise generate an implicit ! conditional. The details and use of this restriction are described in more detail in the High Integrity product documentation. @item No_Implicit_Loops --- 5982,5988 ---- This restriction ensures that the generated code does not contain any implicit conditionals, either by modifying the generated code where possible, or by rejecting any construct that would otherwise generate an implicit ! conditional. The details and use of this restriction are described in more detail in the High Integrity product documentation. @item No_Implicit_Loops *************** This restriction ensures that the genera *** 5916,5923 **** implicit @code{for} loops, either by modifying the generated code where possible, or by rejecting any construct that would otherwise generate an implicit ! @code{for} loop. The details and use of this restriction are described in ! more detail in the GNORT Reference Manual. @item No_Local_Protected_Objects @findex No_Local_Protected_Objects --- 5991,5998 ---- implicit @code{for} loops, either by modifying the generated code where possible, or by rejecting any construct that would otherwise generate an implicit ! @code{for} loop. The details and use of this restriction are described in ! more detail in the High Integrity product documentation. @item No_Local_Protected_Objects @findex No_Local_Protected_Objects *************** only declared at the library level. *** 5929,5945 **** This restriction ensures at compile time that there are no allocator expressions that attempt to allocate protected objects. @item No_Select_Statements @findex No_Select_Statements This restriction ensures at compile time no select statements of any kind are permitted, that is the keyword @code{select} may not appear. This is one of the restrictions of the Ravenscar ! profile for limited tasking (see also pragma Ravenscar). @item No_Standard_Storage_Pools @findex No_Standard_Storage_Pools This restriction ensures at compile time that no access types ! use the standard default storage pool. Any access type declared must have an explicit Storage_Pool attribute defined specifying a user-defined storage pool. --- 6004,6029 ---- This restriction ensures at compile time that there are no allocator expressions that attempt to allocate protected objects. + @item No_Secondary_Stack + @findex No_Secondary_Stack + This restriction ensures at compile time that the generated code does not + contain any reference to the secondary stack. The secondary stack is used + to implement functions returning unconstrained objects (arrays or records) + on some targets. + The details and use of this restriction are described in + more detail in the High Integrity product documentation. + @item No_Select_Statements @findex No_Select_Statements This restriction ensures at compile time no select statements of any kind are permitted, that is the keyword @code{select} may not appear. This is one of the restrictions of the Ravenscar ! profile for limited tasking (see also pragma @code{Ravenscar}). @item No_Standard_Storage_Pools @findex No_Standard_Storage_Pools This restriction ensures at compile time that no access types ! use the standard default storage pool. Any access type declared must have an explicit Storage_Pool attribute defined specifying a user-defined storage pool. *************** explicit dependencies on the package @co *** 5958,5963 **** --- 6042,6054 ---- This restriction ensures at compile time that no terminate alternatives appear in any task body. + @item No_Tasking + @findex No_Tasking + This restriction prevents the declaration of tasks or task types throughout + the partition. It is similar in effect to the use of @code{Max_Tasks => 0} + except that violations are caught at compile time and cause an error message + to be output either by the compiler or binder. + @item No_Wide_Characters @findex No_Wide_Characters This restriction ensures at compile time that no uses of the types *************** other compilation units in the partition *** 5991,6005 **** @item No_Elaboration_Code @findex No_Elaboration_Code This restriction ensures at compile time that no elaboration code is ! generated. Note that this is not the same condition as is enforced ! by pragma Preelaborate. There are cases in which pragma Preelaborate still permits code to be generated (e.g.@: code to initialize a large array to all zeroes), and there are cases of units which do not meet ! the requirements for pragma Preelaborate, but for which no elaboration ! code is generated. Generally, it is the case that preelaborable units will meet the restrictions, with the exception of large aggregates initialized with an others_clause, and exception declarations (which ! generate calls to a run-time registry procedure). Note that this restriction is enforced on a unit by unit basis, it need not be obeyed consistently throughout a partition. --- 6082,6096 ---- @item No_Elaboration_Code @findex No_Elaboration_Code This restriction ensures at compile time that no elaboration code is ! generated. Note that this is not the same condition as is enforced ! by pragma @code{Preelaborate}. There are cases in which pragma @code{Preelaborate} still permits code to be generated (e.g.@: code to initialize a large array to all zeroes), and there are cases of units which do not meet ! the requirements for pragma @code{Preelaborate}, but for which no elaboration ! code is generated. Generally, it is the case that preelaborable units will meet the restrictions, with the exception of large aggregates initialized with an others_clause, and exception declarations (which ! generate calls to a run-time registry procedure). Note that this restriction is enforced on a unit by unit basis, it need not be obeyed consistently throughout a partition. *************** throughout a partition. *** 6007,6033 **** @findex No_Entry_Queue This restriction is a declaration that any protected entry compiled in the scope of the restriction has at most one task waiting on the entry ! at any one time, and so no queue is required. This restriction is not ! checked at compile time. A program execution is erroneous if an attempt is made to queue a second task on such an entry. @item No_Implementation_Attributes @findex No_Implementation_Attributes This restriction checks at compile time that no GNAT-defined attributes ! are present. With this restriction, the only attributes that can be used are those defined in the Ada 95 Reference Manual. @item No_Implementation_Pragmas @findex No_Implementation_Pragmas This restriction checks at compile time that no GNAT-defined pragmas ! are present. With this restriction, the only pragmas that can be used are those defined in the Ada 95 Reference Manual. @item No_Implementation_Restrictions @findex No_Implementation_Restrictions This restriction checks at compile time that no GNAT-defined restriction identifiers (other than @code{No_Implementation_Restrictions} itself) ! are present. With this restriction, the only other restriction identifiers that can be used are those defined in the Ada 95 Reference Manual. @end table --- 6098,6124 ---- @findex No_Entry_Queue This restriction is a declaration that any protected entry compiled in the scope of the restriction has at most one task waiting on the entry ! at any one time, and so no queue is required. This restriction is not ! checked at compile time. A program execution is erroneous if an attempt is made to queue a second task on such an entry. @item No_Implementation_Attributes @findex No_Implementation_Attributes This restriction checks at compile time that no GNAT-defined attributes ! are present. With this restriction, the only attributes that can be used are those defined in the Ada 95 Reference Manual. @item No_Implementation_Pragmas @findex No_Implementation_Pragmas This restriction checks at compile time that no GNAT-defined pragmas ! are present. With this restriction, the only pragmas that can be used are those defined in the Ada 95 Reference Manual. @item No_Implementation_Restrictions @findex No_Implementation_Restrictions This restriction checks at compile time that no GNAT-defined restriction identifiers (other than @code{No_Implementation_Restrictions} itself) ! are present. With this restriction, the only other restriction identifiers that can be used are those defined in the Ada 95 Reference Manual. @end table *************** that can be used are those defined in th *** 6036,6046 **** @cartouche @noindent @strong{58}. The consequences of violating limitations on ! @code{Restrictions} pragmas. See 13.12(9). @end cartouche @noindent Restrictions that can be checked at compile time result in illegalities ! if violated. Currently there are no other consequences of violating restrictions. @sp 1 --- 6127,6137 ---- @cartouche @noindent @strong{58}. The consequences of violating limitations on ! @code{Restrictions} pragmas. See 13.12(9). @end cartouche @noindent Restrictions that can be checked at compile time result in illegalities ! if violated. Currently there are no other consequences of violating restrictions. @sp 1 *************** restrictions. *** 6048,6054 **** @noindent @strong{59}. The representation used by the @code{Read} and @code{Write} attributes of elementary types in terms of stream ! elements. See 13.13.2(9). @end cartouche @noindent The representation is the in-memory representation of the base type of --- 6139,6145 ---- @noindent @strong{59}. The representation used by the @code{Read} and @code{Write} attributes of elementary types in terms of stream ! elements. See 13.13.2(9). @end cartouche @noindent The representation is the in-memory representation of the base type of *************** the type, using the number of bits corre *** 6059,6065 **** @cartouche @noindent @strong{60}. The names and characteristics of the numeric subtypes ! declared in the visible part of package @code{Standard}. See A.1(3). @end cartouche @noindent See items describing the integer and floating-point types supported. --- 6150,6156 ---- @cartouche @noindent @strong{60}. The names and characteristics of the numeric subtypes ! declared in the visible part of package @code{Standard}. See A.1(3). @end cartouche @noindent See items describing the integer and floating-point types supported. *************** See items describing the integer and flo *** 6068,6085 **** @cartouche @noindent @strong{61}. The accuracy actually achieved by the elementary ! functions. See A.5.1(1). @end cartouche @noindent The elementary functions correspond to the functions available in the C ! library. Only fast math mode is implemented. @sp 1 @cartouche @noindent @strong{62}. The sign of a zero result from some of the operators or functions in @code{Numerics.Generic_Elementary_Functions}, when ! @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46). @end cartouche @noindent The sign of zeroes follows the requirements of the IEEE 754 standard on --- 6159,6176 ---- @cartouche @noindent @strong{61}. The accuracy actually achieved by the elementary ! functions. See A.5.1(1). @end cartouche @noindent The elementary functions correspond to the functions available in the C ! library. Only fast math mode is implemented. @sp 1 @cartouche @noindent @strong{62}. The sign of a zero result from some of the operators or functions in @code{Numerics.Generic_Elementary_Functions}, when ! @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46). @end cartouche @noindent The sign of zeroes follows the requirements of the IEEE 754 standard on *************** floating-point. *** 6089,6095 **** @cartouche @noindent @strong{63}. The value of ! @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27). @end cartouche @noindent Maximum image width is 649, see library file @file{a-numran.ads}. --- 6180,6186 ---- @cartouche @noindent @strong{63}. The value of ! @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27). @end cartouche @noindent Maximum image width is 649, see library file @file{a-numran.ads}. *************** Maximum image width is 649, see library *** 6098,6104 **** @cartouche @noindent @strong{64}. The value of ! @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27). @end cartouche @noindent Maximum image width is 80, see library file @file{a-nudira.ads}. --- 6189,6195 ---- @cartouche @noindent @strong{64}. The value of ! @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27). @end cartouche @noindent Maximum image width is 80, see library file @file{a-nudira.ads}. *************** Maximum image width is 80, see library f *** 6106,6112 **** @sp 1 @cartouche @noindent ! @strong{65}. The algorithms for random number generation. See A.5.2(32). @end cartouche @noindent --- 6197,6203 ---- @sp 1 @cartouche @noindent ! @strong{65}. The algorithms for random number generation. See A.5.2(32). @end cartouche @noindent *************** The algorithm is documented in the sourc *** 6117,6123 **** @cartouche @noindent @strong{66}. The string representation of a random number generator's ! state. See A.5.2(38). @end cartouche @noindent See the documentation contained in the file @file{a-numran.adb}. --- 6208,6214 ---- @cartouche @noindent @strong{66}. The string representation of a random number generator's ! state. See A.5.2(38). @end cartouche @noindent See the documentation contained in the file @file{a-numran.adb}. *************** See the documentation contained in the f *** 6127,6133 **** @noindent @strong{67}. The minimum time interval between calls to the time-dependent Reset procedure that are guaranteed to initiate different ! random number sequences. See A.5.2(45). @end cartouche @noindent The minimum period between reset calls to guarantee distinct series of --- 6218,6224 ---- @noindent @strong{67}. The minimum time interval between calls to the time-dependent Reset procedure that are guaranteed to initiate different ! random number sequences. See A.5.2(45). @end cartouche @noindent The minimum period between reset calls to guarantee distinct series of *************** random numbers is one microsecond. *** 6139,6145 **** @strong{68}. The values of the @code{Model_Mantissa}, @code{Model_Emin}, @code{Model_Epsilon}, @code{Model}, @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics ! Annex is not supported. See A.5.3(72). @end cartouche @noindent See the source file @file{ttypef.ads} for the values of all numeric --- 6230,6236 ---- @strong{68}. The values of the @code{Model_Mantissa}, @code{Model_Emin}, @code{Model_Epsilon}, @code{Model}, @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics ! Annex is not supported. See A.5.3(72). @end cartouche @noindent See the source file @file{ttypef.ads} for the values of all numeric *************** attributes. *** 6149,6155 **** @cartouche @noindent @strong{69}. Any implementation-defined characteristics of the ! input-output packages. See A.7(14). @end cartouche @noindent There are no special implementation defined characteristics for these --- 6240,6246 ---- @cartouche @noindent @strong{69}. Any implementation-defined characteristics of the ! input-output packages. See A.7(14). @end cartouche @noindent There are no special implementation defined characteristics for these *************** packages. *** 6158,6164 **** @sp 1 @cartouche @noindent ! @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See A.9(10). @end cartouche @noindent --- 6249,6255 ---- @sp 1 @cartouche @noindent ! @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See A.9(10). @end cartouche @noindent *************** standard error See A.10(5). *** 6174,6185 **** @end cartouche @noindent These files are mapped onto the files provided by the C streams ! libraries. See source file @file{i-cstrea.ads} for further details. @sp 1 @cartouche @noindent ! @strong{72}. The accuracy of the value produced by @code{Put}. See A.10.9(36). @end cartouche @noindent --- 6265,6276 ---- @end cartouche @noindent These files are mapped onto the files provided by the C streams ! libraries. See source file @file{i-cstrea.ads} for further details. @sp 1 @cartouche @noindent ! @strong{72}. The accuracy of the value produced by @code{Put}. See A.10.9(36). @end cartouche @noindent *************** significant digit positions. *** 6191,6197 **** @cartouche @noindent @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and ! @code{Command_Name}. See A.15(1). @end cartouche @noindent These are mapped onto the @code{argv} and @code{argc} parameters of the --- 6282,6288 ---- @cartouche @noindent @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and ! @code{Command_Name}. See A.15(1). @end cartouche @noindent These are mapped onto the @code{argv} and @code{argc} parameters of the *************** main program in the natural manner. *** 6200,6206 **** @sp 1 @cartouche @noindent ! @strong{74}. Implementation-defined convention names. See B.1(11). @end cartouche @noindent The following convention names are supported --- 6291,6297 ---- @sp 1 @cartouche @noindent ! @strong{74}. Implementation-defined convention names. See B.1(11). @end cartouche @noindent The following convention names are supported *************** The following convention names are suppo *** 6208,6235 **** @table @code @item Ada Ada - @item Asm - Assembly language @item Assembler Assembly language @item C C @item C_Pass_By_Copy ! Treated like C, except for record types @item COBOL COBOL @item CPP C++ @item Default Treated the same as C - @item DLL - DLL (used for Windows implementations only) is handled like the Stdcall - convention. This convention is used to access variables and functions - (with Stdcall convention) in a DLL@. - @item Win32 - Win32 (used for Windows implementations only) is handled like the Stdcall - convention. This convention is used to access variables and functions - (with Stdcall convention) in a DLL@. @item External Treated the same as C @item Fortran --- 6299,6321 ---- @table @code @item Ada Ada @item Assembler Assembly language + @item Asm + Synonym for Assembler + @item Assembly + Synonym for Assembler @item C C @item C_Pass_By_Copy ! Allowed only for record types, like C, but also notes that record ! is to be passed by copy rather than reference. @item COBOL COBOL @item CPP C++ @item Default Treated the same as C @item External Treated the same as C @item Fortran *************** Fortran *** 6238,6265 **** For support of pragma @code{Import} with convention Intrinsic, see separate section on Intrinsic Subprograms. @item Stdcall ! Stdcall (used for Windows implementations only). This convention correspond to the WINAPI (previously called Pascal convention) C/C++ convention under ! Windows. A function with this convention clean the stack before exit. @item Stubbed Stubbed is a special convention used to indicate that the body of the ! subprogram will be entirely ignored. Any call to the subprogram ! is converted into a raise of the @code{Program_Error} exception. If a pragma @code{Import} specifies convention @code{stubbed} then no body need ! be present at all. This convention is useful during development for the inclusion of subprograms whose body has not yet been written. @end table @noindent In addition, all otherwise unrecognized convention names are also ! treated as being synonymous with convention C@. In all implementations ! except for VMS, use of such other names results in a warning. In VMS implementations, these names are accepted silently. @sp 1 @cartouche @noindent ! @strong{75}. The meaning of link names. See B.1(36). @end cartouche @noindent Link names are the actual names used by the linker. --- 6324,6355 ---- For support of pragma @code{Import} with convention Intrinsic, see separate section on Intrinsic Subprograms. @item Stdcall ! Stdcall (used for Windows implementations only). This convention correspond to the WINAPI (previously called Pascal convention) C/C++ convention under ! Windows. A function with this convention cleans the stack before exit. ! @item DLL ! Synonym for Stdcall ! @item Win32 ! Synonym for Stdcall @item Stubbed Stubbed is a special convention used to indicate that the body of the ! subprogram will be entirely ignored. Any call to the subprogram ! is converted into a raise of the @code{Program_Error} exception. If a pragma @code{Import} specifies convention @code{stubbed} then no body need ! be present at all. This convention is useful during development for the inclusion of subprograms whose body has not yet been written. @end table @noindent In addition, all otherwise unrecognized convention names are also ! treated as being synonymous with convention C@. In all implementations ! except for VMS, use of such other names results in a warning. In VMS implementations, these names are accepted silently. @sp 1 @cartouche @noindent ! @strong{75}. The meaning of link names. See B.1(36). @end cartouche @noindent Link names are the actual names used by the linker. *************** Link names are the actual names used by *** 6268,6274 **** @cartouche @noindent @strong{76}. The manner of choosing link names when neither the link ! name nor the address of an imported or exported entity is specified. See B.1(36). @end cartouche @noindent --- 6358,6364 ---- @cartouche @noindent @strong{76}. The manner of choosing link names when neither the link ! name nor the address of an imported or exported entity is specified. See B.1(36). @end cartouche @noindent *************** letters. *** 6279,6285 **** @sp 1 @cartouche @noindent ! @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37). @end cartouche @noindent The string passed to @code{Linker_Options} is presented uninterpreted as --- 6369,6375 ---- @sp 1 @cartouche @noindent ! @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37). @end cartouche @noindent The string passed to @code{Linker_Options} is presented uninterpreted as *************** pragma Linker_Options ("-labc" & ASCII.N *** 6291,6316 **** @end smallexample @noindent ! causes two separate arguments "-labc" and "-ldef" to be passed to the ! linker with a guarantee that the order is preserved (no such guarantee ! exists for the use of separate Linker_Options pragmas). ! ! In addition, GNAT allow multiple arguments to @code{Linker_Options} ! with exactly the same meaning, so the above pragma could also be ! written as: ! ! @smallexample ! pragma Linker_Options ("-labc", "-ldef"); ! @end smallexample ! ! @noindent ! The above multiple argument form is a GNAT extension. @sp 1 @cartouche @noindent @strong{78}. The contents of the visible part of package ! @code{Interfaces} and its language-defined descendants. See B.2(1). @end cartouche @noindent See files with prefix @file{i-} in the distributed library. --- 6381,6397 ---- @end smallexample @noindent ! causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the ! linker. The order of linker options is preserved for a given unit. The final ! list of options passed to the linker is in reverse order of the elaboration ! order. For example, linker options fo a body always appear before the options ! from the corresponding package spec. @sp 1 @cartouche @noindent @strong{78}. The contents of the visible part of package ! @code{Interfaces} and its language-defined descendants. See B.2(1). @end cartouche @noindent See files with prefix @file{i-} in the distributed library. *************** See files with prefix @file{i-} in the d *** 6319,6326 **** @cartouche @noindent @strong{79}. Implementation-defined children of package ! @code{Interfaces}. The contents of the visible part of package ! @code{Interfaces}. See B.2(11). @end cartouche @noindent See files with prefix @file{i-} in the distributed library. --- 6400,6407 ---- @cartouche @noindent @strong{79}. Implementation-defined children of package ! @code{Interfaces}. The contents of the visible part of package ! @code{Interfaces}. See B.2(11). @end cartouche @noindent See files with prefix @file{i-} in the distributed library. *************** See files with prefix @file{i-} in the d *** 6332,6338 **** @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and @code{COBOL_Character}; and the initialization of the variables @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in ! @code{Interfaces.COBOL}. See B.4(50). @end cartouche @noindent @table @code --- 6413,6419 ---- @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and @code{COBOL_Character}; and the initialization of the variables @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in ! @code{Interfaces.COBOL}. See B.4(50). @end cartouche @noindent @table @code *************** For initialization, see the file @file{i *** 6355,6361 **** @sp 1 @cartouche @noindent ! @strong{81}. Support for access to machine instructions. See C.1(1). @end cartouche @noindent See documentation in file @file{s-maccod.ads} in the distributed library. --- 6436,6442 ---- @sp 1 @cartouche @noindent ! @strong{81}. Support for access to machine instructions. See C.1(1). @end cartouche @noindent See documentation in file @file{s-maccod.ads} in the distributed library. *************** See documentation in file @file{s-maccod *** 6364,6370 **** @cartouche @noindent @strong{82}. Implementation-defined aspects of access to machine ! operations. See C.1(9). @end cartouche @noindent See documentation in file @file{s-maccod.ads} in the distributed library. --- 6445,6451 ---- @cartouche @noindent @strong{82}. Implementation-defined aspects of access to machine ! operations. See C.1(9). @end cartouche @noindent See documentation in file @file{s-maccod.ads} in the distributed library. *************** See documentation in file @file{s-maccod *** 6372,6381 **** @sp 1 @cartouche @noindent ! @strong{83}. Implementation-defined aspects of interrupts. See C.3(2). @end cartouche @noindent ! Interrupts are mapped to signals or conditions as appropriate. See definition of unit @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details on the interrupts supported on a particular target. --- 6453,6462 ---- @sp 1 @cartouche @noindent ! @strong{83}. Implementation-defined aspects of interrupts. See C.3(2). @end cartouche @noindent ! Interrupts are mapped to signals or conditions as appropriate. See definition of unit @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details on the interrupts supported on a particular target. *************** on the interrupts supported on a particu *** 6383,6389 **** @sp 1 @cartouche @noindent ! @strong{84}. Implementation-defined aspects of pre-elaboration. See C.4(13). @end cartouche @noindent --- 6464,6470 ---- @sp 1 @cartouche @noindent ! @strong{84}. Implementation-defined aspects of pre-elaboration. See C.4(13). @end cartouche @noindent *************** except under control of the debugger. *** 6393,6403 **** @sp 1 @cartouche @noindent ! @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7). @end cartouche @noindent Pragma @code{Discard_Names} causes names of enumeration literals to ! be suppressed. In the presence of this pragma, the Image attribute provides the image of the Pos of the literal, and Value accepts Pos values. --- 6474,6484 ---- @sp 1 @cartouche @noindent ! @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7). @end cartouche @noindent Pragma @code{Discard_Names} causes names of enumeration literals to ! be suppressed. In the presence of this pragma, the Image attribute provides the image of the Pos of the literal, and Value accepts Pos values. *************** Pos values. *** 6405,6411 **** @cartouche @noindent @strong{86}. The result of the @code{Task_Identification.Image} ! attribute. See C.7.1(7). @end cartouche @noindent The result of this attribute is an 8-digit hexadecimal string --- 6486,6492 ---- @cartouche @noindent @strong{86}. The result of the @code{Task_Identification.Image} ! attribute. See C.7.1(7). @end cartouche @noindent The result of this attribute is an 8-digit hexadecimal string *************** representing the virtual address of the *** 6415,6421 **** @cartouche @noindent @strong{87}. The value of @code{Current_Task} when in a protected entry ! or interrupt handler. See C.7.1(17). @end cartouche @noindent Protected entries or interrupt handlers can be executed by any --- 6496,6502 ---- @cartouche @noindent @strong{87}. The value of @code{Current_Task} when in a protected entry ! or interrupt handler. See C.7.1(17). @end cartouche @noindent Protected entries or interrupt handlers can be executed by any *************** convenient thread, so the value of @code *** 6425,6431 **** @cartouche @noindent @strong{88}. The effect of calling @code{Current_Task} from an entry ! body or interrupt handler. See C.7.1(19). @end cartouche @noindent The effect of calling @code{Current_Task} from an entry body or --- 6506,6512 ---- @cartouche @noindent @strong{88}. The effect of calling @code{Current_Task} from an entry ! body or interrupt handler. See C.7.1(19). @end cartouche @noindent The effect of calling @code{Current_Task} from an entry body or *************** executing the code. *** 6436,6442 **** @cartouche @noindent @strong{89}. Implementation-defined aspects of ! @code{Task_Attributes}. See C.7.2(19). @end cartouche @noindent There are no implementation-defined aspects of @code{Task_Attributes}. --- 6517,6523 ---- @cartouche @noindent @strong{89}. Implementation-defined aspects of ! @code{Task_Attributes}. See C.7.2(19). @end cartouche @noindent There are no implementation-defined aspects of @code{Task_Attributes}. *************** There are no implementation-defined aspe *** 6444,6457 **** @sp 1 @cartouche @noindent ! @strong{90}. Values of all @code{Metrics}. See D(2). @end cartouche @noindent The metrics information for GNAT depends on the performance of the ! underlying operating system. The sources of the run-time for tasking implementation, together with the output from @code{-gnatG} can be used to determine the exact sequence of operating systems calls made ! to implement various tasking constructs. Together with appropriate information on the performance of the underlying operating system, on the exact target in use, this information can be used to determine the required metrics. --- 6525,6538 ---- @sp 1 @cartouche @noindent ! @strong{90}. Values of all @code{Metrics}. See D(2). @end cartouche @noindent The metrics information for GNAT depends on the performance of the ! underlying operating system. The sources of the run-time for tasking implementation, together with the output from @code{-gnatG} can be used to determine the exact sequence of operating systems calls made ! to implement various tasking constructs. Together with appropriate information on the performance of the underlying operating system, on the exact target in use, this information can be used to determine the required metrics. *************** the required metrics. *** 6460,6466 **** @cartouche @noindent @strong{91}. The declarations of @code{Any_Priority} and ! @code{Priority}. See D.1(11). @end cartouche @noindent See declarations in file @file{system.ads}. --- 6541,6547 ---- @cartouche @noindent @strong{91}. The declarations of @code{Any_Priority} and ! @code{Priority}. See D.1(11). @end cartouche @noindent See declarations in file @file{system.ads}. *************** See declarations in file @file{system.ad *** 6468,6474 **** @sp 1 @cartouche @noindent ! @strong{92}. Implementation-defined execution resources. See D.1(15). @end cartouche @noindent There are no implementation-defined execution resources. --- 6549,6555 ---- @sp 1 @cartouche @noindent ! @strong{92}. Implementation-defined execution resources. See D.1(15). @end cartouche @noindent There are no implementation-defined execution resources. *************** There are no implementation-defined exec *** 6477,6483 **** @cartouche @noindent @strong{93}. Whether, on a multiprocessor, a task that is waiting for ! access to a protected object keeps its processor busy. See D.2.1(3). @end cartouche @noindent On a multi-processor, a task that is waiting for access to a protected --- 6558,6564 ---- @cartouche @noindent @strong{93}. Whether, on a multiprocessor, a task that is waiting for ! access to a protected object keeps its processor busy. See D.2.1(3). @end cartouche @noindent On a multi-processor, a task that is waiting for access to a protected *************** object does not keep its processor busy. *** 6487,6493 **** @cartouche @noindent @strong{94}. The affect of implementation defined execution resources ! on task dispatching. See D.2.1(9). @end cartouche @noindent @c SGI info --- 6568,6574 ---- @cartouche @noindent @strong{94}. The affect of implementation defined execution resources ! on task dispatching. See D.2.1(9). @end cartouche @noindent @c SGI info *************** on task dispatching. See D.2.1(9). *** 6495,6501 **** Tasks map to IRIX threads, and the dispatching policy is as defined by the IRIX implementation of threads. @end ignore ! Tasks map to threads in the threads package used by GNAT@. Where possible and appropriate, these threads correspond to native threads of the underlying operating system. --- 6576,6582 ---- Tasks map to IRIX threads, and the dispatching policy is as defined by the IRIX implementation of threads. @end ignore ! Tasks map to threads in the threads package used by GNAT@. Where possible and appropriate, these threads correspond to native threads of the underlying operating system. *************** underlying operating system. *** 6503,6509 **** @cartouche @noindent @strong{95}. Implementation-defined @code{policy_identifiers} allowed ! in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3). @end cartouche @noindent There are no implementation-defined policy-identifiers allowed in this --- 6584,6590 ---- @cartouche @noindent @strong{95}. Implementation-defined @code{policy_identifiers} allowed ! in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3). @end cartouche @noindent There are no implementation-defined policy-identifiers allowed in this *************** pragma. *** 6512,6518 **** @sp 1 @cartouche @noindent ! @strong{96}. Implementation-defined aspects of priority inversion. See D.2.2(16). @end cartouche @noindent --- 6593,6599 ---- @sp 1 @cartouche @noindent ! @strong{96}. Implementation-defined aspects of priority inversion. See D.2.2(16). @end cartouche @noindent *************** of delay expirations for lower priority *** 6522,6528 **** @sp 1 @cartouche @noindent ! @strong{97}. Implementation defined task dispatching. See D.2.2(18). @end cartouche @noindent @c SGI info: --- 6603,6609 ---- @sp 1 @cartouche @noindent ! @strong{97}. Implementation defined task dispatching. See D.2.2(18). @end cartouche @noindent @c SGI info: *************** The policy is the same as that of the un *** 6536,6546 **** @cartouche @noindent @strong{98}. Implementation-defined @code{policy_identifiers} allowed ! in a pragma @code{Locking_Policy}. See D.3(4). @end cartouche @noindent The only implementation defined policy permitted in GNAT is ! @code{Inheritance_Locking}. On targets that support this policy, locking is implemented by inheritance, i.e.@: the task owning the lock operates at a priority equal to the highest priority of any task currently requesting the lock. --- 6617,6627 ---- @cartouche @noindent @strong{98}. Implementation-defined @code{policy_identifiers} allowed ! in a pragma @code{Locking_Policy}. See D.3(4). @end cartouche @noindent The only implementation defined policy permitted in GNAT is ! @code{Inheritance_Locking}. On targets that support this policy, locking is implemented by inheritance, i.e.@: the task owning the lock operates at a priority equal to the highest priority of any task currently requesting the lock. *************** requesting the lock. *** 6548,6554 **** @sp 1 @cartouche @noindent ! @strong{99}. Default ceiling priorities. See D.3(10). @end cartouche @noindent The ceiling priority of protected objects of the type --- 6629,6635 ---- @sp 1 @cartouche @noindent ! @strong{99}. Default ceiling priorities. See D.3(10). @end cartouche @noindent The ceiling priority of protected objects of the type *************** Reference Manual D.3(10), *** 6559,6565 **** @cartouche @noindent @strong{100}. The ceiling of any protected object used internally by ! the implementation. See D.3(16). @end cartouche @noindent The ceiling priority of internal protected objects is --- 6640,6646 ---- @cartouche @noindent @strong{100}. The ceiling of any protected object used internally by ! the implementation. See D.3(16). @end cartouche @noindent The ceiling priority of internal protected objects is *************** The ceiling priority of internal protect *** 6568,6574 **** @sp 1 @cartouche @noindent ! @strong{101}. Implementation-defined queuing policies. See D.4(1). @end cartouche @noindent There are no implementation-defined queueing policies. --- 6649,6655 ---- @sp 1 @cartouche @noindent ! @strong{101}. Implementation-defined queuing policies. See D.4(1). @end cartouche @noindent There are no implementation-defined queueing policies. *************** There are no implementation-defined queu *** 6578,6584 **** @noindent @strong{102}. On a multiprocessor, any conditions that cause the completion of an aborted construct to be delayed later than what is ! specified for a single processor. See D.6(3). @end cartouche @noindent The semantics for abort on a multi-processor is the same as on a single --- 6659,6665 ---- @noindent @strong{102}. On a multiprocessor, any conditions that cause the completion of an aborted construct to be delayed later than what is ! specified for a single processor. See D.6(3). @end cartouche @noindent The semantics for abort on a multi-processor is the same as on a single *************** processor, there are no further delays. *** 6588,6594 **** @cartouche @noindent @strong{103}. Any operations that implicitly require heap storage ! allocation. See D.7(8). @end cartouche @noindent The only operation that implicitly requires heap storage allocation is --- 6669,6675 ---- @cartouche @noindent @strong{103}. Any operations that implicitly require heap storage ! allocation. See D.7(8). @end cartouche @noindent The only operation that implicitly requires heap storage allocation is *************** task creation. *** 6598,6604 **** @cartouche @noindent @strong{104}. Implementation-defined aspects of pragma ! @code{Restrictions}. See D.7(20). @end cartouche @noindent There are no such implementation-defined aspects. --- 6679,6685 ---- @cartouche @noindent @strong{104}. Implementation-defined aspects of pragma ! @code{Restrictions}. See D.7(20). @end cartouche @noindent There are no such implementation-defined aspects. *************** There are no such implementation-defined *** 6607,6613 **** @cartouche @noindent @strong{105}. Implementation-defined aspects of package ! @code{Real_Time}. See D.8(17). @end cartouche @noindent There are no implementation defined aspects of package @code{Real_Time}. --- 6688,6694 ---- @cartouche @noindent @strong{105}. Implementation-defined aspects of package ! @code{Real_Time}. See D.8(17). @end cartouche @noindent There are no implementation defined aspects of package @code{Real_Time}. *************** There are no implementation defined aspe *** 6616,6622 **** @cartouche @noindent @strong{106}. Implementation-defined aspects of ! @code{delay_statements}. See D.9(8). @end cartouche @noindent Any difference greater than one microsecond will cause the task to be --- 6697,6703 ---- @cartouche @noindent @strong{106}. Implementation-defined aspects of ! @code{delay_statements}. See D.9(8). @end cartouche @noindent Any difference greater than one microsecond will cause the task to be *************** delayed (see D.9(7)). *** 6626,6652 **** @cartouche @noindent @strong{107}. The upper bound on the duration of interrupt blocking ! caused by the implementation. See D.12(5). @end cartouche @noindent ! The upper bound is determined by the underlying operating system. In no cases is it more than 10 milliseconds. @sp 1 @cartouche @noindent @strong{108}. The means for creating and executing distributed ! programs. See E(5). @end cartouche @noindent The GLADE package provides a utility GNATDIST for creating and executing ! distributed programs. See the GLADE reference manual for further details. @sp 1 @cartouche @noindent @strong{109}. Any events that can result in a partition becoming ! inaccessible. See E.1(7). @end cartouche @noindent See the GLADE reference manual for full details on such events. --- 6707,6733 ---- @cartouche @noindent @strong{107}. The upper bound on the duration of interrupt blocking ! caused by the implementation. See D.12(5). @end cartouche @noindent ! The upper bound is determined by the underlying operating system. In no cases is it more than 10 milliseconds. @sp 1 @cartouche @noindent @strong{108}. The means for creating and executing distributed ! programs. See E(5). @end cartouche @noindent The GLADE package provides a utility GNATDIST for creating and executing ! distributed programs. See the GLADE reference manual for further details. @sp 1 @cartouche @noindent @strong{109}. Any events that can result in a partition becoming ! inaccessible. See E.1(7). @end cartouche @noindent See the GLADE reference manual for full details on such events. *************** See the GLADE reference manual for full *** 6655,6661 **** @cartouche @noindent @strong{110}. The scheduling policies, treatment of priorities, and ! management of shared resources between partitions in certain cases. See E.1(11). @end cartouche @noindent --- 6736,6742 ---- @cartouche @noindent @strong{110}. The scheduling policies, treatment of priorities, and ! management of shared resources between partitions in certain cases. See E.1(11). @end cartouche @noindent *************** multi-partition execution. *** 6666,6677 **** @cartouche @noindent @strong{111}. Events that cause the version of a compilation unit to ! change. See E.3(5). @end cartouche @noindent Editing the source file of a compilation unit, or the source files of any units on which it is dependent in a significant way cause the version ! to change. No other actions cause the version number to change. All changes are significant except those which affect only layout, capitalization or comments. --- 6747,6758 ---- @cartouche @noindent @strong{111}. Events that cause the version of a compilation unit to ! change. See E.3(5). @end cartouche @noindent Editing the source file of a compilation unit, or the source files of any units on which it is dependent in a significant way cause the version ! to change. No other actions cause the version number to change. All changes are significant except those which affect only layout, capitalization or comments. *************** comments. *** 6679,6685 **** @cartouche @noindent @strong{112}. Whether the execution of the remote subprogram is ! immediately aborted as a result of cancellation. See E.4(13). @end cartouche @noindent See the GLADE reference manual for details on the effect of abort in --- 6760,6766 ---- @cartouche @noindent @strong{112}. Whether the execution of the remote subprogram is ! immediately aborted as a result of cancellation. See E.4(13). @end cartouche @noindent See the GLADE reference manual for details on the effect of abort in *************** a distributed application. *** 6688,6694 **** @sp 1 @cartouche @noindent ! @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25). @end cartouche @noindent See the GLADE reference manual for a full description of all implementation --- 6769,6775 ---- @sp 1 @cartouche @noindent ! @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25). @end cartouche @noindent See the GLADE reference manual for a full description of all implementation *************** defined aspects of the PCS@. *** 6697,6703 **** @sp 1 @cartouche @noindent ! @strong{114}. Implementation-defined interfaces in the PCS@. See E.5(26). @end cartouche @noindent --- 6778,6784 ---- @sp 1 @cartouche @noindent ! @strong{114}. Implementation-defined interfaces in the PCS@. See E.5(26). @end cartouche @noindent *************** implementation defined interfaces. *** 6708,6714 **** @cartouche @noindent @strong{115}. The values of named numbers in the package ! @code{Decimal}. See F.2(7). @end cartouche @noindent @table @code --- 6789,6795 ---- @cartouche @noindent @strong{115}. The values of named numbers in the package ! @code{Decimal}. See F.2(7). @end cartouche @noindent @table @code *************** implementation defined interfaces. *** 6728,6734 **** @cartouche @noindent @strong{116}. The value of @code{Max_Picture_Length} in the package ! @code{Text_IO.Editing}. See F.3.3(16). @end cartouche @noindent 64 --- 6809,6815 ---- @cartouche @noindent @strong{116}. The value of @code{Max_Picture_Length} in the package ! @code{Text_IO.Editing}. See F.3.3(16). @end cartouche @noindent 64 *************** implementation defined interfaces. *** 6737,6743 **** @cartouche @noindent @strong{117}. The value of @code{Max_Picture_Length} in the package ! @code{Wide_Text_IO.Editing}. See F.3.4(5). @end cartouche @noindent 64 --- 6818,6824 ---- @cartouche @noindent @strong{117}. The value of @code{Max_Picture_Length} in the package ! @code{Wide_Text_IO.Editing}. See F.3.4(5). @end cartouche @noindent 64 *************** implementation defined interfaces. *** 6746,6763 **** @cartouche @noindent @strong{118}. The accuracy actually achieved by the complex elementary ! functions and by other complex arithmetic operations. See G.1(1). @end cartouche @noindent Standard library functions are used for the complex arithmetic ! operations. Only fast math mode is currently supported. @sp 1 @cartouche @noindent @strong{119}. The sign of a zero result (or a component thereof) from any operator or function in @code{Numerics.Generic_Complex_Types}, when ! @code{Real'Signed_Zeros} is True. See G.1.1(53). @end cartouche @noindent The signs of zero values are as recommended by the relevant --- 6827,6844 ---- @cartouche @noindent @strong{118}. The accuracy actually achieved by the complex elementary ! functions and by other complex arithmetic operations. See G.1(1). @end cartouche @noindent Standard library functions are used for the complex arithmetic ! operations. Only fast math mode is currently supported. @sp 1 @cartouche @noindent @strong{119}. The sign of a zero result (or a component thereof) from any operator or function in @code{Numerics.Generic_Complex_Types}, when ! @code{Real'Signed_Zeros} is True. See G.1.1(53). @end cartouche @noindent The signs of zero values are as recommended by the relevant *************** implementation advice. *** 6769,6775 **** @strong{120}. The sign of a zero result (or a component thereof) from any operator or function in @code{Numerics.Generic_Complex_Elementary_Functions}, when ! @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45). @end cartouche @noindent The signs of zero values are as recommended by the relevant --- 6850,6856 ---- @strong{120}. The sign of a zero result (or a component thereof) from any operator or function in @code{Numerics.Generic_Complex_Elementary_Functions}, when ! @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45). @end cartouche @noindent The signs of zero values are as recommended by the relevant *************** implementation advice. *** 6779,6795 **** @cartouche @noindent @strong{121}. Whether the strict mode or the relaxed mode is the ! default. See G.2(2). @end cartouche @noindent ! The strict mode is the default. There is no separate relaxed mode. GNAT provides a highly efficient implementation of strict mode. @sp 1 @cartouche @noindent @strong{122}. The result interval in certain cases of fixed-to-float ! conversion. See G.2.1(10). @end cartouche @noindent For cases where the result interval is implementation dependent, the --- 6860,6876 ---- @cartouche @noindent @strong{121}. Whether the strict mode or the relaxed mode is the ! default. See G.2(2). @end cartouche @noindent ! The strict mode is the default. There is no separate relaxed mode. GNAT provides a highly efficient implementation of strict mode. @sp 1 @cartouche @noindent @strong{122}. The result interval in certain cases of fixed-to-float ! conversion. See G.2.1(10). @end cartouche @noindent For cases where the result interval is implementation dependent, the *************** floating-point format. *** 6801,6807 **** @noindent @strong{123}. The result of a floating point arithmetic operation in overflow situations, when the @code{Machine_Overflows} attribute of the ! result type is @code{False}. See G.2.1(13). @end cartouche @noindent Infinite and Nan values are produced as dictated by the IEEE --- 6882,6888 ---- @noindent @strong{123}. The result of a floating point arithmetic operation in overflow situations, when the @code{Machine_Overflows} attribute of the ! result type is @code{False}. See G.2.1(13). @end cartouche @noindent Infinite and Nan values are produced as dictated by the IEEE *************** floating-point standard. *** 6812,6818 **** @noindent @strong{124}. The result interval for division (or exponentiation by a negative exponent), when the floating point hardware implements division ! as multiplication by a reciprocal. See G.2.1(16). @end cartouche @noindent Not relevant, division is IEEE exact. --- 6893,6899 ---- @noindent @strong{124}. The result interval for division (or exponentiation by a negative exponent), when the floating point hardware implements division ! as multiplication by a reciprocal. See G.2.1(16). @end cartouche @noindent Not relevant, division is IEEE exact. *************** Not relevant, division is IEEE exact. *** 6821,6832 **** @cartouche @noindent @strong{125}. The definition of close result set, which determines the ! accuracy of certain fixed point multiplications and divisions. See G.2.3(5). @end cartouche @noindent Operations in the close result set are performed using IEEE long format ! floating-point arithmetic. The input operands are converted to floating-point, the operation is done in floating-point, and the result is converted to the target type. --- 6902,6913 ---- @cartouche @noindent @strong{125}. The definition of close result set, which determines the ! accuracy of certain fixed point multiplications and divisions. See G.2.3(5). @end cartouche @noindent Operations in the close result set are performed using IEEE long format ! floating-point arithmetic. The input operands are converted to floating-point, the operation is done in floating-point, and the result is converted to the target type. *************** is converted to the target type. *** 6835,6841 **** @noindent @strong{126}. Conditions on a @code{universal_real} operand of a fixed point multiplication or division for which the result shall be in the ! perfect result set. See G.2.3(22). @end cartouche @noindent The result is only defined to be in the perfect result set if the result --- 6916,6922 ---- @noindent @strong{126}. Conditions on a @code{universal_real} operand of a fixed point multiplication or division for which the result shall be in the ! perfect result set. See G.2.3(22). @end cartouche @noindent The result is only defined to be in the perfect result set if the result *************** representable in 64-bits. *** 6847,6853 **** @noindent @strong{127}. The result of a fixed point arithmetic operation in overflow situations, when the @code{Machine_Overflows} attribute of the ! result type is @code{False}. See G.2.3(27). @end cartouche @noindent Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point --- 6928,6934 ---- @noindent @strong{127}. The result of a fixed point arithmetic operation in overflow situations, when the @code{Machine_Overflows} attribute of the ! result type is @code{False}. See G.2.3(27). @end cartouche @noindent Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point *************** types. *** 6858,6864 **** @noindent @strong{128}. The result of an elementary function reference in overflow situations, when the @code{Machine_Overflows} attribute of the ! result type is @code{False}. See G.2.4(4). @end cartouche @noindent IEEE infinite and Nan values are produced as appropriate. --- 6939,6945 ---- @noindent @strong{128}. The result of an elementary function reference in overflow situations, when the @code{Machine_Overflows} attribute of the ! result type is @code{False}. See G.2.4(4). @end cartouche @noindent IEEE infinite and Nan values are produced as appropriate. *************** IEEE infinite and Nan values are produce *** 6869,6875 **** @strong{129}. The value of the angle threshold, within which certain elementary functions, complex arithmetic operations, and complex elementary functions yield results conforming to a maximum relative ! error bound. See G.2.4(10). @end cartouche @noindent Information on this subject is not yet available. --- 6950,6956 ---- @strong{129}. The value of the angle threshold, within which certain elementary functions, complex arithmetic operations, and complex elementary functions yield results conforming to a maximum relative ! error bound. See G.2.4(10). @end cartouche @noindent Information on this subject is not yet available. *************** Information on this subject is not yet a *** 6878,6884 **** @cartouche @noindent @strong{130}. The accuracy of certain elementary functions for ! parameters beyond the angle threshold. See G.2.4(10). @end cartouche @noindent Information on this subject is not yet available. --- 6959,6965 ---- @cartouche @noindent @strong{130}. The accuracy of certain elementary functions for ! parameters beyond the angle threshold. See G.2.4(10). @end cartouche @noindent Information on this subject is not yet available. *************** Information on this subject is not yet a *** 6889,6895 **** @strong{131}. The result of a complex arithmetic operation or complex elementary function reference in overflow situations, when the @code{Machine_Overflows} attribute of the corresponding real type is ! @code{False}. See G.2.6(5). @end cartouche @noindent IEEE infinite and Nan values are produced as appropriate. --- 6970,6976 ---- @strong{131}. The result of a complex arithmetic operation or complex elementary function reference in overflow situations, when the @code{Machine_Overflows} attribute of the corresponding real type is ! @code{False}. See G.2.6(5). @end cartouche @noindent IEEE infinite and Nan values are produced as appropriate. *************** IEEE infinite and Nan values are produce *** 6899,6905 **** @noindent @strong{132}. The accuracy of certain complex arithmetic operations and certain complex elementary functions for parameters (or components ! thereof) beyond the angle threshold. See G.2.6(8). @end cartouche @noindent Information on those subjects is not yet available. --- 6980,6986 ---- @noindent @strong{132}. The accuracy of certain complex arithmetic operations and certain complex elementary functions for parameters (or components ! thereof) beyond the angle threshold. See G.2.6(8). @end cartouche @noindent Information on those subjects is not yet available. *************** Information on those subjects is not yet *** 6908,6914 **** @cartouche @noindent @strong{133}. Information regarding bounded errors and erroneous ! execution. See H.2(1). @end cartouche @noindent Information on this subject is not yet available. --- 6989,6995 ---- @cartouche @noindent @strong{133}. Information regarding bounded errors and erroneous ! execution. See H.2(1). @end cartouche @noindent Information on this subject is not yet available. *************** Information on this subject is not yet a *** 6917,6923 **** @cartouche @noindent @strong{134}. Implementation-defined aspects of pragma ! @code{Inspection_Point}. See H.3.2(8). @end cartouche @noindent Pragma @code{Inspection_Point} ensures that the variable is live and can --- 6998,7004 ---- @cartouche @noindent @strong{134}. Implementation-defined aspects of pragma ! @code{Inspection_Point}. See H.3.2(8). @end cartouche @noindent Pragma @code{Inspection_Point} ensures that the variable is live and can *************** be examined by the debugger at the inspe *** 6927,6943 **** @cartouche @noindent @strong{135}. Implementation-defined aspects of pragma ! @code{Restrictions}. See H.4(25). @end cartouche @noindent ! There are no implementation-defined aspects of pragma @code{Restrictions}. The use of pragma @code{Restrictions [No_Exceptions]} has no effect on the ! generated code. Checks must suppressed by use of pragma @code{Suppress}. @sp 1 @cartouche @noindent ! @strong{136}. Any restrictions on pragma @code{Restrictions}. See H.4(27). @end cartouche @noindent --- 7008,7024 ---- @cartouche @noindent @strong{135}. Implementation-defined aspects of pragma ! @code{Restrictions}. See H.4(25). @end cartouche @noindent ! There are no implementation-defined aspects of pragma @code{Restrictions}. The use of pragma @code{Restrictions [No_Exceptions]} has no effect on the ! generated code. Checks must suppressed by use of pragma @code{Suppress}. @sp 1 @cartouche @noindent ! @strong{136}. Any restrictions on pragma @code{Restrictions}. See H.4(27). @end cartouche @noindent *************** GNAT allows a user application program t *** 6972,6981 **** @noindent providing that the name corresponds to one of the implemented intrinsic subprograms in GNAT, and that the parameter profile of the referenced ! subprogram meets the requirements. This chapter describes the set of implemented intrinsic subprograms, and the requirements on parameter profiles. Note that no body is supplied; as with other uses of pragma Import, the ! body is supplied elsewhere (in this case by the compiler itself). Note that any use of this feature is potentially non-portable, since the Ada standard does not require Ada compilers to implement this feature. --- 7053,7062 ---- @noindent providing that the name corresponds to one of the implemented intrinsic subprograms in GNAT, and that the parameter profile of the referenced ! subprogram meets the requirements. This chapter describes the set of implemented intrinsic subprograms, and the requirements on parameter profiles. Note that no body is supplied; as with other uses of pragma Import, the ! body is supplied elsewhere (in this case by the compiler itself). Note that any use of this feature is potentially non-portable, since the Ada standard does not require Ada compilers to implement this feature. *************** Ada standard does not require Ada compil *** 6984,6995 **** @cindex Intrinsic operator @noindent ! All predefined operators can be used in @code{pragma Import (Intrinsic,..)} ! declarations. In the binary operator case, the operands must have the same ! size. The operand or operands must also be appropriate for ! the operator. For example, for addition, the operands must ! both be floating-point or both be fixed-point. You can use an intrinsic ! operator declaration as in the following example: @smallexample type Int1 is new Integer; --- 7065,7079 ---- @cindex Intrinsic operator @noindent ! All the predefined numeric operators in package Standard ! in @code{pragma Import (Intrinsic,..)} ! declarations. In the binary operator case, the operands must have the same ! size. The operand or operands must also be appropriate for ! the operator. For example, for addition, the operands must ! both be floating-point or both be fixed-point, and the ! right operand for @code{"**"} must have a root type of ! @code{Standard.Integer'Base}. ! You can use an intrinsic operator declaration as in the following example: @smallexample type Int1 is new Integer; *************** operator declaration as in the following *** 7001,7015 **** @end smallexample @noindent ! This declaration would permit "mixed mode" arithmetic on items ! of the differing types Int1 and Int2. @node Enclosing_Entity @section Enclosing_Entity @cindex Enclosing_Entity @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Source_Info}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of --- 7085,7101 ---- @end smallexample @noindent ! This declaration would permit ``mixed mode'' arithmetic on items ! of the differing types @code{Int1} and @code{Int2}. ! It is also possible to specify such operators for private types, if the ! full views are appropriate arithmetic types. @node Enclosing_Entity @section Enclosing_Entity @cindex Enclosing_Entity @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Source_Info}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of *************** the current subprogram, package, task, e *** 7020,7026 **** @cindex Exception_Information' @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Current_Exception}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Current_Exception.Exception_Information} to obtain --- 7106,7112 ---- @cindex Exception_Information' @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Current_Exception}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Current_Exception.Exception_Information} to obtain *************** the exception information associated wit *** 7031,7037 **** @cindex Exception_Message @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Current_Exception}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Current_Exception.Exception_Message} to obtain --- 7117,7123 ---- @cindex Exception_Message @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Current_Exception}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Current_Exception.Exception_Message} to obtain *************** the message associated with the current *** 7042,7048 **** @cindex Exception_Name @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Current_Exception}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Current_Exception.Exception_Name} to obtain --- 7128,7134 ---- @cindex Exception_Name @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Current_Exception}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Current_Exception.Exception_Name} to obtain *************** the name of the current exception. *** 7053,7059 **** @cindex File @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Source_Info}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Source_Info.File} to obtain the name of the current --- 7139,7145 ---- @cindex File @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Source_Info}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Source_Info.File} to obtain the name of the current *************** file. *** 7064,7070 **** @cindex Line @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Source_Info}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Source_Info.Line} to obtain the number of the current --- 7150,7156 ---- @cindex Line @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Source_Info}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Source_Info.Line} to obtain the number of the current *************** source line. *** 7075,7081 **** @cindex Rotate_Left @noindent In standard Ada 95, the @code{Rotate_Left} function is available only ! for the predefined modular types in package @code{Interfaces}. However, in GNAT it is possible to define a Rotate_Left function for a user defined modular type or any signed integer type as in this example: --- 7161,7167 ---- @cindex Rotate_Left @noindent In standard Ada 95, the @code{Rotate_Left} function is available only ! for the predefined modular types in package @code{Interfaces}. However, in GNAT it is possible to define a Rotate_Left function for a user defined modular type or any signed integer type as in this example: *************** defined modular type or any signed integ *** 7088,7098 **** @noindent The requirements are that the profile be exactly as in the example ! above. The only modifications allowed are in the formal parameter names, and in the type of @code{Value} and the return type, which must be the same, and must be either a signed integer type, or a modular integer type with a binary modulus, and the size must ! be 8. 16, 32 or 64 bits. @node Rotate_Right @section Rotate_Right --- 7174,7184 ---- @noindent The requirements are that the profile be exactly as in the example ! above. The only modifications allowed are in the formal parameter names, and in the type of @code{Value} and the return type, which must be the same, and must be either a signed integer type, or a modular integer type with a binary modulus, and the size must ! be 8. 16, 32 or 64 bits. @node Rotate_Right @section Rotate_Right *************** above for @code{Rotate_Left}. *** 7131,7137 **** @cindex Source_Location @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Source_Info}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Source_Info.Source_Location} to obtain the current --- 7217,7223 ---- @cindex Source_Location @noindent This intrinsic subprogram is used in the implementation of the ! library routine @code{GNAT.Source_Info}. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function @code{GNAT.Source_Info.Source_Location} to obtain the current *************** source file location. *** 7167,7176 **** This section describes the representation clauses accepted by GNAT, and their effect on the representation of corresponding data objects. ! GNAT fully implements Annex C (Systems Programming). This means that all the implementation advice sections in chapter 13 are fully implemented. However, these sections only require a minimal level of support for ! representation clauses. GNAT provides much more extensive capabilities, and this section describes the additional capabilities provided. @node Alignment Clauses --- 7253,7262 ---- This section describes the representation clauses accepted by GNAT, and their effect on the representation of corresponding data objects. ! GNAT fully implements Annex C (Systems Programming). This means that all the implementation advice sections in chapter 13 are fully implemented. However, these sections only require a minimal level of support for ! representation clauses. GNAT provides much more extensive capabilities, and this section describes the additional capabilities provided. @node Alignment Clauses *************** and this section describes the additiona *** 7179,7185 **** @noindent GNAT requires that all alignment clauses specify a power of 2, and all ! default alignments are always a power of 2. The default alignment values are as follows: @itemize @bullet --- 7265,7271 ---- @noindent GNAT requires that all alignment clauses specify a power of 2, and all ! default alignments are always a power of 2. The default alignment values are as follows: @itemize @bullet *************** aligned. *** 7194,7227 **** @item Arrays For arrays, the alignment is equal to the alignment of the component type ! for the normal case where no packing or component size is given. If the array is packed, and the packing is effective (see separate section on packed arrays), then the alignment will be one for long packed arrays, ! or arrays whose length is not known at compile time. For short packed arrays, which are handled internally as modular types, the alignment will be as described for primitive types, e.g.@: a packed array of length 31 bits will have an object size of four bytes, and an alignment of 4. @item Records For the normal non-packed case, the alignment of a record is equal to ! the maximum alignment of any of its components. For tagged records, this ! includes the implicit access type used for the tag. If a pragma Pack is ! used and all fields are packable (see separate section on pragma Pack), then the resulting alignment is 1. @end itemize @noindent An alignment clause may always specify a larger alignment than the default value, up to some maximum value dependent on the target (obtainable by using the ! attribute reference System'Maximum_Alignment). The only case in which it is permissible to specify a smaller alignment than the default value is in the case of a record for which a record representation clause is ! given. In this case, packable fields for which a component clause is given still result in a default alignment corresponding to the original type, but this may be overridden, since these components in fact only ! require an alignment of one byte. For example, given @smallexample type v is record --- 7280,7330 ---- @item Arrays For arrays, the alignment is equal to the alignment of the component type ! for the normal case where no packing or component size is given. If the array is packed, and the packing is effective (see separate section on packed arrays), then the alignment will be one for long packed arrays, ! or arrays whose length is not known at compile time. For short packed arrays, which are handled internally as modular types, the alignment will be as described for primitive types, e.g.@: a packed array of length 31 bits will have an object size of four bytes, and an alignment of 4. @item Records For the normal non-packed case, the alignment of a record is equal to ! the maximum alignment of any of its components. For tagged records, this ! includes the implicit access type used for the tag. If a pragma @code{Pack} is ! used and all fields are packable (see separate section on pragma @code{Pack}), then the resulting alignment is 1. + A special case is when the size of the record is given explicitly, or a + full record representation clause is given, and the size of the record + is 2, 4, or 8 bytes. In this case, an alignment is chosen to match the + size of the record. For example, if we have: + + @smallexample + type Small is record + A, B : Character; + end record; + @end smallexample + + @noindent + then the default alignment of the record type @code{Small} is 2, not 1. This + leads to more efficient code when the record is treated as a unit, and also + allows the type to specified as @code{Atomic} on architectures requiring + strict alignment. + @end itemize @noindent An alignment clause may always specify a larger alignment than the default value, up to some maximum value dependent on the target (obtainable by using the ! attribute reference System'Maximum_Alignment). The only case in which it is permissible to specify a smaller alignment than the default value is in the case of a record for which a record representation clause is ! given. In this case, packable fields for which a component clause is given still result in a default alignment corresponding to the original type, but this may be overridden, since these components in fact only ! require an alignment of one byte. For example, given @smallexample type v is record *************** alignment of the record to a smaller val *** 7247,7256 **** @cindex Size Clause @noindent ! The default size of types is as specified in the reference manual. For objects, GNAT will generally increase the type size so that the object size is a multiple of storage units, and also a multiple of the ! alignment. For example @smallexample type Smallint is range 1 .. 6; --- 7350,7359 ---- @cindex Size Clause @noindent ! The default size of types is as specified in the reference manual. For objects, GNAT will generally increase the type size so that the object size is a multiple of storage units, and also a multiple of the ! alignment. For example @smallexample type Smallint is range 1 .. 6; *************** In this example, @code{Smallint} *** 7266,7272 **** has a size of 3, as specified by the RM rules, but objects of this type will have a size of 8, since objects by default occupy an integral number ! of storage units. On some targets, notably older versions of the Digital Alpha, the size of stand alone objects of this type may be 32, reflecting the inability of the hardware to do byte load/stores. --- 7369,7375 ---- has a size of 3, as specified by the RM rules, but objects of this type will have a size of 8, since objects by default occupy an integral number ! of storage units. On some targets, notably older versions of the Digital Alpha, the size of stand alone objects of this type may be 32, reflecting the inability of the hardware to do byte load/stores. *************** the inability of the hardware to do byte *** 7274,7280 **** Similarly, the size of type @code{Rec} is 40 bits, but the alignment is 4, so objects of this type will have their size increased to 64 bits so that it is a multiple ! of the alignment. The reason for this decision, which is in accordance with the specific note in RM 13.3(43): @smallexample --- 7377,7383 ---- Similarly, the size of type @code{Rec} is 40 bits, but the alignment is 4, so objects of this type will have their size increased to 64 bits so that it is a multiple ! of the alignment. The reason for this decision, which is in accordance with the specific note in RM 13.3(43): @smallexample *************** Alignment (if the Alignment is nonzero). *** 7286,7292 **** @noindent An explicit size clause may be used to override the default size by ! increasing it. For example, if we have: @smallexample type My_Boolean is new Boolean; --- 7389,7395 ---- @noindent An explicit size clause may be used to override the default size by ! increasing it. For example, if we have: @smallexample type My_Boolean is new Boolean; *************** increasing it. For example, if we have: *** 7294,7313 **** @end smallexample @noindent ! then objects of this type will always be 32 bits long. In the case of discrete types, the size can be increased up to 64 bits, with the effect that the entire specified field is used to hold the value, sign- or ! zero-extended as appropriate. If more than 64 bits is specified, then padding space is allocated after the value, and a warning is issued that there are unused bits. Similarly the size of records and arrays may be increased, and the effect ! is to add padding bits after the value. This also causes a warning message to be generated. ! The largest Size value permitted in GNAT is 2**32-1. Since this is a Size in bits, this corresponds to an object of size 256 megabytes (minus ! one). This limitation is true on all targets. The reason for this limitation is that it improves the quality of the code in many cases if it is known that a Size value can be accommodated in an object of type Integer. --- 7397,7416 ---- @end smallexample @noindent ! then objects of this type will always be 32 bits long. In the case of discrete types, the size can be increased up to 64 bits, with the effect that the entire specified field is used to hold the value, sign- or ! zero-extended as appropriate. If more than 64 bits is specified, then padding space is allocated after the value, and a warning is issued that there are unused bits. Similarly the size of records and arrays may be increased, and the effect ! is to add padding bits after the value. This also causes a warning message to be generated. ! The largest Size value permitted in GNAT is 2**32@minus{}1. Since this is a Size in bits, this corresponds to an object of size 256 megabytes (minus ! one). This limitation is true on all targets. The reason for this limitation is that it improves the quality of the code in many cases if it is known that a Size value can be accommodated in an object of type Integer. *************** type Integer. *** 7318,7329 **** @noindent For tasks, the @code{Storage_Size} clause specifies the amount of space ! to be allocated for the task stack. This cannot be extended, and if the stack is exhausted, then @code{Storage_Error} will be raised if stack ! checking is enabled. If the default size of 20K bytes is insufficient, then you need to use a @code{Storage_Size} attribute definition clause, or a @code{Storage_Size} pragma in the task definition to set the ! appropriate required size. A useful technique is to include in every task definition a pragma of the form: @smallexample --- 7421,7432 ---- @noindent For tasks, the @code{Storage_Size} clause specifies the amount of space ! to be allocated for the task stack. This cannot be extended, and if the stack is exhausted, then @code{Storage_Error} will be raised if stack ! checking is enabled. If the default size of 20K bytes is insufficient, then you need to use a @code{Storage_Size} attribute definition clause, or a @code{Storage_Size} pragma in the task definition to set the ! appropriate required size. A useful technique is to include in every task definition a pragma of the form: @smallexample *************** task definition a pragma of the form: *** 7332,7342 **** @noindent Then Default_Stack_Size can be defined in a global package, and modified ! as required. Any tasks requiring different task stack sizes from the default can have an appropriate alternative reference in the pragma. For access types, the @code{Storage_Size} clause specifies the maximum ! space available for allocation of objects of the type. If this space is exceeded then @code{Storage_Error} will be raised by an allocation attempt. In the case where the access type is declared local to a subprogram, the use of a @code{Storage_Size} clause triggers automatic use of a special --- 7435,7445 ---- @noindent Then Default_Stack_Size can be defined in a global package, and modified ! as required. Any tasks requiring different task stack sizes from the default can have an appropriate alternative reference in the pragma. For access types, the @code{Storage_Size} clause specifies the maximum ! space available for allocation of objects of the type. If this space is exceeded then @code{Storage_Error} will be raised by an allocation attempt. In the case where the access type is declared local to a subprogram, the use of a @code{Storage_Size} clause triggers automatic use of a special *************** space for the pool is automatically recl *** 7345,7354 **** which the type is declared. A special case recognized by the compiler is the specification of a ! @code{Storage_Size} of zero for an access type. This means that no items can be allocated from the pool, and this is recognized at compile time, and all the overhead normally associated with maintaining a fixed ! size storage pool is eliminated. Consider the following example: @smallexample procedure p is --- 7448,7457 ---- which the type is declared. A special case recognized by the compiler is the specification of a ! @code{Storage_Size} of zero for an access type. This means that no items can be allocated from the pool, and this is recognized at compile time, and all the overhead normally associated with maintaining a fixed ! size storage pool is eliminated. Consider the following example: @smallexample procedure p is *************** size storage pool is eliminated. Conside *** 7362,7378 **** procedure g (m : P); pragma Import (C, g); ! -- ... begin ! -- ... y := new R; end; @end smallexample @noindent As indicated in this example, these dummy storage pools are often useful in ! connection with interfacing where no object will ever be allocated. If you compile the above example, you get the warning: @smallexample --- 7465,7481 ---- procedure g (m : P); pragma Import (C, g); ! -- @dots{} begin ! -- @dots{} y := new R; end; @end smallexample @noindent As indicated in this example, these dummy storage pools are often useful in ! connection with interfacing where no object will ever be allocated. If you compile the above example, you get the warning: @smallexample *************** case of such an access declaration. *** 7392,7398 **** @noindent An issue arises in the case of variant record objects of whether Size gives information about a particular variant, or the maximum size required ! for any variant. Consider the following program @smallexample with Text_IO; use Text_IO; --- 7495,7501 ---- @noindent An issue arises in the case of variant record objects of whether Size gives information about a particular variant, or the maximum size required ! for any variant. Consider the following program @smallexample with Text_IO; use Text_IO; *************** end q; *** 7417,7423 **** Here we are dealing with a variant record, where the True variant requires 16 bits, and the False variant requires 8 bits. In the above example, both V1 and V2 contain the False variant, ! which is only 8 bits long. However, the result of running the program is: @smallexample --- 7520,7526 ---- Here we are dealing with a variant record, where the True variant requires 16 bits, and the False variant requires 8 bits. In the above example, both V1 and V2 contain the False variant, ! which is only 8 bits long. However, the result of running the program is: @smallexample *************** program is: *** 7427,7434 **** @noindent The reason for the difference here is that the discriminant value of ! V1 is fixed, and will always be False. It is not possible to assign ! a True variant value to V1, therefore 8 bits is sufficient. On the other hand, in the case of V2, the initial discriminant value is False (from the default), but it is possible to assign a True variant value to V2, therefore 16 bits must be allocated for V2 --- 7530,7537 ---- @noindent The reason for the difference here is that the discriminant value of ! V1 is fixed, and will always be False. It is not possible to assign ! a True variant value to V1, therefore 8 bits is sufficient. On the other hand, in the case of V2, the initial discriminant value is False (from the default), but it is possible to assign a True variant value to V2, therefore 16 bits must be allocated for V2 *************** be made here, but the GNAT behavior seem *** 7443,7449 **** language in the RM@. In some cases, it may be desirable to obtain the size of the current ! variant, rather than the size of the largest variant. This can be achieved in GNAT by making use of the fact that in the case of a subprogram parameter, GNAT does indeed return the size of the current variant (because a subprogram has no way of knowing how much space --- 7546,7552 ---- language in the RM@. In some cases, it may be desirable to obtain the size of the current ! variant, rather than the size of the largest variant. This can be achieved in GNAT by making use of the fact that in the case of a subprogram parameter, GNAT does indeed return the size of the current variant (because a subprogram has no way of knowing how much space *************** variant value. *** 7501,7507 **** @noindent In the case of scalars with a range starting at other than zero, it is possible in some cases to specify a size smaller than the default minimum ! value, and in such cases, @code{GNAT} uses an unsigned biased representation, in which zero is used to represent the lower bound, and successive values represent successive values of the type. --- 7604,7610 ---- @noindent In the case of scalars with a range starting at other than zero, it is possible in some cases to specify a size smaller than the default minimum ! value, and in such cases, GNAT uses an unsigned biased representation, in which zero is used to represent the lower bound, and successive values represent successive values of the type. *************** scheme: *** 7526,7532 **** @noindent Biased representation is only used if the specified @code{Size} clause ! cannot be accepted in any other manner. These reduced sizes that force biased representation can be used for all discrete types except for enumeration types for which a representation clause is given. --- 7629,7635 ---- @noindent Biased representation is only used if the specified @code{Size} clause ! cannot be accepted in any other manner. These reduced sizes that force biased representation can be used for all discrete types except for enumeration types for which a representation clause is given. *************** enumeration types for which a representa *** 7538,7550 **** @noindent In Ada 95, the @code{Size} of a discrete type is the minimum number of bits ! required to hold values of the type. Although this interpretation was allowed in Ada 83, it was not required, and this requirement in practice ! can cause some significant difficulties. For example, in most Ada 83 ! compilers, @code{Natural'Size} was 32. However, in Ada-95, @code{Natural'Size} is ! typically 31. This means that code may change in behavior when moving ! from Ada 83 to Ada 95. For example, consider: @smallexample type Rec is record; --- 7641,7653 ---- @noindent In Ada 95, the @code{Size} of a discrete type is the minimum number of bits ! required to hold values of the type. Although this interpretation was allowed in Ada 83, it was not required, and this requirement in practice ! can cause some significant difficulties. For example, in most Ada 83 ! compilers, @code{Natural'Size} was 32. However, in Ada-95, @code{Natural'Size} is ! typically 31. This means that code may change in behavior when moving ! from Ada 83 to Ada 95. For example, consider: @smallexample type Rec is record; *************** surprising cases where the fact that the *** 7566,7580 **** size of the type causes surprises. To help get around this problem GNAT provides two implementation ! dependent attributes @code{Value_Size} and @code{Object_Size}. When applied to a type, these attributes yield the size of the type (corresponding to the RM defined size attribute), and the size of objects of the type respectively. The @code{Object_Size} is used for determining the default size of ! objects and components. This size value can be referred to using the ! @code{Object_Size} attribute. The phrase "is used" here means that it is ! the basis of the determination of the size. The backend is free to pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone character might be stored in 32 bits on a machine with no efficient byte access instructions such as the Alpha. --- 7669,7683 ---- size of the type causes surprises. To help get around this problem GNAT provides two implementation ! dependent attributes @code{Value_Size} and @code{Object_Size}. When applied to a type, these attributes yield the size of the type (corresponding to the RM defined size attribute), and the size of objects of the type respectively. The @code{Object_Size} is used for determining the default size of ! objects and components. This size value can be referred to using the ! @code{Object_Size} attribute. The phrase ``is used'' here means that it is ! the basis of the determination of the size. The backend is free to pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone character might be stored in 32 bits on a machine with no efficient byte access instructions such as the Alpha. *************** discrete types are as follows: *** 7585,7592 **** @itemize @bullet @item The @code{Object_Size} for base subtypes reflect the natural hardware ! size in bits (run the utility gnatpsta to find those values for numeric types). ! Enumeration types and fixed-point base subtypes have 8. 16. 32 or 64 bits for this size, depending on the range of values to be stored. @item --- 7688,7695 ---- @itemize @bullet @item The @code{Object_Size} for base subtypes reflect the natural hardware ! size in bits (run the utility @code{gnatpsta} to find those values for numeric types). ! Enumeration types and fixed-point base subtypes have 8, 16, 32 or 64 bits for this size, depending on the range of values to be stored. @item *************** from the parent first subtype. *** 7603,7610 **** @noindent The @code{Value_Size} attribute is the number of bits required to store a value ! of the type. This size can be referred to using the @code{Value_Size} ! attribute. This value is used to determine how tightly to pack records or arrays with components of this type, and also affects the semantics of unchecked conversion (unchecked conversions where the @code{Value_Size} values differ generate a warning, and are potentially --- 7706,7713 ---- @noindent The @code{Value_Size} attribute is the number of bits required to store a value ! of the type. This size can be referred to using the @code{Value_Size} ! attribute. This value is used to determine how tightly to pack records or arrays with components of this type, and also affects the semantics of unchecked conversion (unchecked conversions where the @code{Value_Size} values differ generate a warning, and are potentially *************** only if negative values are possible). *** 7620,7632 **** @item If a subtype statically matches the first subtype of a given type, then it has ! by default the same @code{Value_Size} as the first subtype. This is a ! consequence of RM 13.1(14) ("if two subtypes statically match, ! then their subtype-specific aspects are the same".) @item All other subtypes have a @code{Value_Size} corresponding to the minimum ! number of bits required to store all values of the subtype. For dynamic bounds, it is assumed that the value can range down or up to the corresponding bound of the ancestor @end itemize --- 7723,7735 ---- @item If a subtype statically matches the first subtype of a given type, then it has ! by default the same @code{Value_Size} as the first subtype. This is a ! consequence of RM 13.1(14) (``if two subtypes statically match, ! then their subtype-specific aspects are the same''.) @item All other subtypes have a @code{Value_Size} corresponding to the minimum ! number of bits required to store all values of the subtype. For dynamic bounds, it is assumed that the value can range down or up to the corresponding bound of the ancestor @end itemize *************** to the corresponding bound of the ancest *** 7635,7654 **** The RM defined attribute @code{Size} corresponds to the @code{Value_Size} attribute. ! The @code{Size} attribute may be defined for a first-named subtype. This sets the @code{Value_Size} of the first-named subtype to the given value, and the @code{Object_Size} of this first-named subtype to the given value padded up ! to an appropriate boundary. It is a consequence of the default rules ! above that this @code{Object_Size} will apply to all further subtypes. On the other hand, @code{Value_Size} is affected only for the first subtype, any dynamic subtypes obtained from it directly, and any statically matching ! subtypes. The @code{Value_Size} of any other static subtypes is not affected. @code{Value_Size} and @code{Object_Size} may be explicitly set for any subtype using ! an attribute definition clause. Note that the use of these attributes ! can cause the RM 13.1(14) rule to be violated. If two access types reference aliased objects whose subtypes have differing @code{Object_Size} values as a result of explicit attribute definition clauses, then it is erroneous to convert from one access subtype to the other. --- 7738,7757 ---- The RM defined attribute @code{Size} corresponds to the @code{Value_Size} attribute. ! The @code{Size} attribute may be defined for a first-named subtype. This sets the @code{Value_Size} of the first-named subtype to the given value, and the @code{Object_Size} of this first-named subtype to the given value padded up ! to an appropriate boundary. It is a consequence of the default rules ! above that this @code{Object_Size} will apply to all further subtypes. On the other hand, @code{Value_Size} is affected only for the first subtype, any dynamic subtypes obtained from it directly, and any statically matching ! subtypes. The @code{Value_Size} of any other static subtypes is not affected. @code{Value_Size} and @code{Object_Size} may be explicitly set for any subtype using ! an attribute definition clause. Note that the use of these attributes ! can cause the RM 13.1(14) rule to be violated. If two access types reference aliased objects whose subtypes have differing @code{Object_Size} values as a result of explicit attribute definition clauses, then it is erroneous to convert from one access subtype to the other. *************** that in each case the base is short_shor *** 7664,7672 **** @smallexample Object_Size Value_Size ! type x1 is range 0..5; 8 3 ! type x2 is range 0..5; for x2'size use 12; 12 12 subtype x3 is x2 range 0 .. 3; 12 2 --- 7767,7775 ---- @smallexample Object_Size Value_Size ! type x1 is range 0 .. 5; 8 3 ! type x2 is range 0 .. 5; for x2'size use 12; 12 12 subtype x3 is x2 range 0 .. 3; 12 2 *************** In other words, the value specified must *** 7716,7725 **** of this subtype, and must be a multiple of the alignment value. In addition, component size clauses are allowed which cause the array ! to be packed, by specifying a smaller value. The cases in which this ! is allowed are for component size values in the range 1-63. The value ! specified must not be smaller than the Size of the subtype. GNAT will ! accurately honor all packing requests in this range. For example, if we have: @smallexample --- 7819,7828 ---- of this subtype, and must be a multiple of the alignment value. In addition, component size clauses are allowed which cause the array ! to be packed, by specifying a smaller value. The cases in which this ! is allowed are for component size values in the range 1 through 63. The value ! specified must not be smaller than the Size of the subtype. GNAT will ! accurately honor all packing requests in this range. For example, if we have: @smallexample *************** less efficient than if the natural compo *** 7740,7760 **** @noindent For record subtypes, GNAT permits the specification of the @code{Bit_Order} ! attribute. The specification may either correspond to the default bit order for the target, in which case the specification has no effect and places no additional restrictions, or it may be for the non-standard setting (that is the opposite of the default). In the case where the non-standard value is specified, the effect is to renumber bits within each byte, but the ordering of bytes is not ! affected. There are certain restrictions placed on component clauses as follows: @itemize @bullet @item Components fitting within a single storage unit. @noindent ! These are unrestricted, and the effect is merely to renumber bits. For example if we are on a little-endian machine with @code{Low_Order_First} being the default, then the following two declarations have exactly the same effect: --- 7843,7863 ---- @noindent For record subtypes, GNAT permits the specification of the @code{Bit_Order} ! attribute. The specification may either correspond to the default bit order for the target, in which case the specification has no effect and places no additional restrictions, or it may be for the non-standard setting (that is the opposite of the default). In the case where the non-standard value is specified, the effect is to renumber bits within each byte, but the ordering of bytes is not ! affected. There are certain restrictions placed on component clauses as follows: @itemize @bullet @item Components fitting within a single storage unit. @noindent ! These are unrestricted, and the effect is merely to renumber bits. For example if we are on a little-endian machine with @code{Low_Order_First} being the default, then the following two declarations have exactly the same effect: *************** the same, regardless of whether the targ *** 7790,7796 **** @item Components occupying an integral number of bytes. @noindent ! These are components that exactly fit in two or more bytes. Such component declarations are allowed, but have no effect, since it is important to realize that the @code{Bit_Order} specification does not affect the ordering of bytes. In particular, the following attempt at getting an endian-independent integer --- 7893,7899 ---- @item Components occupying an integral number of bytes. @noindent ! These are components that exactly fit in two or more bytes. Such component declarations are allowed, but have no effect, since it is important to realize that the @code{Bit_Order} specification does not affect the ordering of bytes. In particular, the following attempt at getting an endian-independent integer *************** does not work: *** 7812,7825 **** This declaration will result in a little-endian integer on a little-endian machine, and a big-endian integer on a big-endian machine. If byte flipping is required for interoperability between big- and ! little-endian machines, this must be explicitly programmed. This capability is not provided by @code{Bit_Order}. @item Components that are positioned across byte boundaries @noindent ! but do not occupy an integral number of bytes. Given that bytes are not reordered, such fields would occupy a non-contiguous sequence of bits ! in memory, requiring non-trivial code to reassemble. They are for this reason not permitted, and any component clause specifying such a layout will be flagged as illegal by GNAT@. --- 7915,7928 ---- This declaration will result in a little-endian integer on a little-endian machine, and a big-endian integer on a big-endian machine. If byte flipping is required for interoperability between big- and ! little-endian machines, this must be explicitly programmed. This capability is not provided by @code{Bit_Order}. @item Components that are positioned across byte boundaries @noindent ! but do not occupy an integral number of bytes. Given that bytes are not reordered, such fields would occupy a non-contiguous sequence of bits ! in memory, requiring non-trivial code to reassemble. They are for this reason not permitted, and any component clause specifying such a layout will be flagged as illegal by GNAT@. *************** will be flagged as illegal by GNAT@. *** 7829,7836 **** Since the misconception that Bit_Order automatically deals with all endian-related incompatibilities is a common one, the specification of a component field that is an integral number of bytes will always ! generate a warning. This warning may be suppressed using ! @code{pragma Suppress} if desired. The following section contains additional details regarding the issue of byte ordering. @node Effect of Bit_Order on Byte Ordering --- 7932,7939 ---- Since the misconception that Bit_Order automatically deals with all endian-related incompatibilities is a common one, the specification of a component field that is an integral number of bytes will always ! generate a warning. This warning may be suppressed using ! @code{pragma Suppress} if desired. The following section contains additional details regarding the issue of byte ordering. @node Effect of Bit_Order on Byte Ordering *************** details regarding the issue of byte orde *** 7840,7849 **** @noindent In this section we will review the effect of the @code{Bit_Order} attribute ! definition clause on byte ordering. Briefly, it has no effect at all, but ! a detailed example will be helpful. Before giving this example, let us review the precise ! definition of the effect of defining @code{Bit_Order}. The effect of a non-standard bit order is described in section 15.5.3 of the Ada Reference Manual: --- 7943,7952 ---- @noindent In this section we will review the effect of the @code{Bit_Order} attribute ! definition clause on byte ordering. Briefly, it has no effect at all, but ! a detailed example will be helpful. Before giving this example, let us review the precise ! definition of the effect of defining @code{Bit_Order}. The effect of a non-standard bit order is described in section 15.5.3 of the Ada Reference Manual: *************** this context, we visit section 13.5.1 of *** 7858,7864 **** @smallexample 13 A record_representation_clause (without the mod_clause) ! specifies the layout. The storage place attributes (see 13.5.2) are taken from the values of the position, first_bit, and last_bit expressions after normalizing those values so that first_bit is less than Storage_Unit. --- 7961,7967 ---- @smallexample 13 A record_representation_clause (without the mod_clause) ! specifies the layout. The storage place attributes (see 13.5.2) are taken from the values of the position, first_bit, and last_bit expressions after normalizing those values so that first_bit is less than Storage_Unit. *************** less than Storage_Unit. *** 7866,7889 **** @noindent The critical point here is that storage places are taken from ! the values after normalization, not before. So the @code{Bit_Order} ! interpretation applies to normalized values. The interpretation is described in the later part of the 15.5.3 paragraph: @smallexample 2 A bit ordering is a method of interpreting the meaning of the storage place attributes. High_Order_First (known in the ! vernacular as "big endian") means that the first bit of a storage element (bit 0) is the most significant bit (interpreting the sequence of bits that represent a component as an unsigned ! integer value). Low_Order_First (known in the vernacular as ! "little endian") means the opposite: the first bit is the least significant. @end smallexample @noindent Note that the numbering is with respect to the bits of a storage ! unit. In other words, the specification affects only the numbering of bits within a single storage unit. We can make the effect clearer by giving an example. --- 7969,7992 ---- @noindent The critical point here is that storage places are taken from ! the values after normalization, not before. So the @code{Bit_Order} ! interpretation applies to normalized values. The interpretation is described in the later part of the 15.5.3 paragraph: @smallexample 2 A bit ordering is a method of interpreting the meaning of the storage place attributes. High_Order_First (known in the ! vernacular as ``big endian'') means that the first bit of a storage element (bit 0) is the most significant bit (interpreting the sequence of bits that represent a component as an unsigned ! integer value). Low_Order_First (known in the vernacular as ! ``little endian'') means the opposite: the first bit is the least significant. @end smallexample @noindent Note that the numbering is with respect to the bits of a storage ! unit. In other words, the specification affects only the numbering of bits within a single storage unit. We can make the effect clearer by giving an example. *************** byte presented, which is the first (low *** 7893,7900 **** record is called Master, and the second byte is called Slave. The left most (most significant bit is called Control for each byte, and ! the remaing 7 bits are called V1, V2 .. V7, where V7 is the right most ! (least significant bit). On a big-endian machine, we can write the following representation clause --- 7996,8003 ---- record is called Master, and the second byte is called Slave. The left most (most significant bit is called Control for each byte, and ! the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost ! (least significant) bit. On a big-endian machine, we can write the following representation clause *************** the byte is backwards, so we have to rew *** 7964,7974 **** @end smallexample It is a nuisance to have to rewrite the clause, especially if ! the code has to be maintained on both machines. However, this is a case that we can handle with the @code{Bit_Order} attribute if it is implemented. Note that the implementation is not required on byte addressed ! machines, but it is indeed implemented in @code{GNAT}. This means that we can simply use the first record clause, together with the declaration --- 8067,8077 ---- @end smallexample It is a nuisance to have to rewrite the clause, especially if ! the code has to be maintained on both machines. However, this is a case that we can handle with the @code{Bit_Order} attribute if it is implemented. Note that the implementation is not required on byte addressed ! machines, but it is indeed implemented in GNAT. This means that we can simply use the first record clause, together with the declaration *************** first record clause, together with the d *** 7978,7984 **** @noindent and the effect is what is desired, namely the layout is exactly the same, ! independent of whether the code is compiled on a big-endial or little-endian machine. The important point to understand is that byte ordering is not affected. --- 8081,8087 ---- @noindent and the effect is what is desired, namely the layout is exactly the same, ! independent of whether the code is compiled on a big-endian or little-endian machine. The important point to understand is that byte ordering is not affected. *************** example as: *** 7990,8005 **** @smallexample for Data'Bit_Order use High_Order_First; for Data use record ! Master_Control at 0 range 0 .. 0; ! Master_V1 at 0 range 1 .. 1; ! Master_V2 at 0 range 2 .. 2; ! Master_V3 at 0 range 3 .. 3; ! Master_V4 at 0 range 4 .. 4; ! Master_V5 at 0 range 5 .. 5; ! Master_V6 at 0 range 6 .. 6; ! Master_V7 at 0 range 7 .. 7; ! Slave_Control at 0 range 8 .. 8; ! Slave_V1 at 0 range 9 .. 9; Slave_V2 at 0 range 10 .. 10; Slave_V3 at 0 range 11 .. 11; Slave_V4 at 0 range 12 .. 12; --- 8093,8108 ---- @smallexample for Data'Bit_Order use High_Order_First; for Data use record ! Master_Control at 0 range 0 .. 0; ! Master_V1 at 0 range 1 .. 1; ! Master_V2 at 0 range 2 .. 2; ! Master_V3 at 0 range 3 .. 3; ! Master_V4 at 0 range 4 .. 4; ! Master_V5 at 0 range 5 .. 5; ! Master_V6 at 0 range 6 .. 6; ! Master_V7 at 0 range 7 .. 7; ! Slave_Control at 0 range 8 .. 8; ! Slave_V1 at 0 range 9 .. 9; Slave_V2 at 0 range 10 .. 10; Slave_V3 at 0 range 11 .. 11; Slave_V4 at 0 range 12 .. 12; *************** This is exactly equivalent to saying (a *** 8036,8043 **** @noindent Why are they equivalent? Well take a specific field, the @code{Slave_V2} ! field. The storage place attributes are obtained by normalizing the ! values given so that the @code{First_Bit} value is less than 8. After nromalizing the values (0,10,10) we get (1,2,2) which is exactly what we specified in the other case. --- 8139,8146 ---- @noindent Why are they equivalent? Well take a specific field, the @code{Slave_V2} ! field. The storage place attributes are obtained by normalizing the ! values given so that the @code{First_Bit} value is less than 8. After nromalizing the values (0,10,10) we get (1,2,2) which is exactly what we specified in the other case. *************** may be actively confusing to specify suc *** 8054,8064 **** generates a warning for such usage. If you do need to control byte ordering then appropriate conditional ! values must be used. If in our example, the slave byte came first on some machines we might write: @smallexample ! Master_Byte_First constant Boolean := ...; Master_Byte : constant Natural := 1 - Boolean'Pos (Master_Byte_First); --- 8157,8167 ---- generates a warning for such usage. If you do need to control byte ordering then appropriate conditional ! values must be used. If in our example, the slave byte came first on some machines we might write: @smallexample ! Master_Byte_First constant Boolean := @dots{}; Master_Byte : constant Natural := 1 - Boolean'Pos (Master_Byte_First); *************** an appropriate manner. *** 8096,8103 **** @cindex Pragma Pack (for arrays) @noindent ! Pragma Pack applied to an array has no effect unless the component type ! is packable. For a component type to be packable, it must be one of the following cases: @itemize @bullet --- 8199,8206 ---- @cindex Pragma Pack (for arrays) @noindent ! Pragma @code{Pack} applied to an array has no effect unless the component type ! is packable. For a component type to be packable, it must be one of the following cases: @itemize @bullet *************** Any packed array type with a static size *** 8113,8119 **** @noindent For all these cases, if the component subtype size is in the range ! 1- 63, then the effect of the pragma Pack is exactly as though a component size were specified giving the component subtype size. For example if we have: --- 8216,8222 ---- @noindent For all these cases, if the component subtype size is in the range ! 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a component size were specified giving the component subtype size. For example if we have: *************** Then the component size of @code{ar} wil *** 8129,8147 **** and the size of the array @code{ar} will be exactly 40 bits. Note that in some cases this rather fierce approach to packing can produce ! unexpected effects. For example, in Ada 95, type Natural typically has a size of 31, meaning that if you pack an array of Natural, you get 31-bit close packing, which saves a few bits, but results in far less efficient ! access. Since many other Ada compilers will ignore such a packing request, ! GNAT will generate a warning on some uses of pragma Pack that it guesses ! might not be what is intended. You can easily remove this warning by ! using an explicit Component_Size setting instead, which never generates a warning, since the intention of the programmer is clear in this case. ! GNAT treats packed arrays in one of two ways. If the size of the array is known at compile time and is less than 64 bits, then internally the array is represented as a single modular type, of exactly the appropriate number ! of bits. If the length is greater than 63 bits, or is not known at compile time, then the packed array is represented as an array of bytes, and the length is always a multiple of 8 bits. --- 8232,8250 ---- and the size of the array @code{ar} will be exactly 40 bits. Note that in some cases this rather fierce approach to packing can produce ! unexpected effects. For example, in Ada 95, type Natural typically has a size of 31, meaning that if you pack an array of Natural, you get 31-bit close packing, which saves a few bits, but results in far less efficient ! access. Since many other Ada compilers will ignore such a packing request, ! GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses ! might not be what is intended. You can easily remove this warning by ! using an explicit @code{Component_Size} setting instead, which never generates a warning, since the intention of the programmer is clear in this case. ! GNAT treats packed arrays in one of two ways. If the size of the array is known at compile time and is less than 64 bits, then internally the array is represented as a single modular type, of exactly the appropriate number ! of bits. If the length is greater than 63 bits, or is not known at compile time, then the packed array is represented as an array of bytes, and the length is always a multiple of 8 bits. *************** length is always a multiple of 8 bits. *** 8150,8159 **** @cindex Pragma Pack (for records) @noindent ! Pragma Pack applied to a record will pack the components to reduce wasted space from alignment gaps and by reducing the amount of space taken by ! components. We distinguish between package components and non-packable ! components. Components of the following types are considered packable: @itemize @bullet @item --- 8253,8262 ---- @cindex Pragma Pack (for records) @noindent ! Pragma @code{Pack} applied to a record will pack the components to reduce wasted space from alignment gaps and by reducing the amount of space taken by ! components. We distinguish between package components and non-packable ! components. Components of the following types are considered packable: @itemize @bullet @item *************** The representation for the record x2 is *** 8205,8214 **** @smallexample for x2'Size use 224; for x2 use record ! l1 at 0 range 0 .. 0; l2 at 0 range 1 .. 64; l3 at 12 range 0 .. 31; ! l4 at 16 range 0 .. 0; l5 at 16 range 1 .. 13; l6 at 18 range 0 .. 71; end record; --- 8308,8317 ---- @smallexample for x2'Size use 224; for x2 use record ! l1 at 0 range 0 .. 0; l2 at 0 range 1 .. 64; l3 at 12 range 0 .. 31; ! l4 at 16 range 0 .. 0; l5 at 16 range 1 .. 13; l6 at 18 range 0 .. 71; end record; *************** Studying this example, we see that the p *** 8219,8230 **** and @code{l2} are of length equal to their sizes, and placed at specific bit boundaries (and not byte boundaries) to ! eliminate padding. But @code{l3} is of a non-packable float type, so it is on the next appropriate alignment boundary. The next two fields are fully packable, so @code{l4} and @code{l5} are ! minimally packed with no gaps. However, type @code{Rb2} is a packed ! array that is longer than 64 bits, so it is itself non-packable. Thus the @code{l6} field is aligned to the next byte boundary, and takes an integral number of bytes, i.e.@: 72 bits. --- 8322,8333 ---- and @code{l2} are of length equal to their sizes, and placed at specific bit boundaries (and not byte boundaries) to ! eliminate padding. But @code{l3} is of a non-packable float type, so it is on the next appropriate alignment boundary. The next two fields are fully packable, so @code{l4} and @code{l5} are ! minimally packed with no gaps. However, type @code{Rb2} is a packed ! array that is longer than 64 bits, so it is itself non-packable. Thus the @code{l6} field is aligned to the next byte boundary, and takes an integral number of bytes, i.e.@: 72 bits. *************** integral number of bytes, i.e.@: 72 bits *** 8234,8252 **** @noindent Record representation clauses may be given for all record types, including ! types obtained by record extension. Component clauses are allowed for any ! static component. The restrictions on component clauses depend on the type of the component. @cindex Component Clause For all components of an elementary type, the only restriction on component clauses is that the size must be at least the 'Size value of the type ! (actually the Value_Size). There are no restrictions due to alignment, and such components may freely cross storage boundaries. ! Packed arrays with a size up to and including 64-bits are represented internally using a modular type with the appropriate number of bits, and ! thus the same lack of restriction applies. For example, if you declare: @smallexample type R is array (1 .. 49) of Boolean; --- 8337,8355 ---- @noindent Record representation clauses may be given for all record types, including ! types obtained by record extension. Component clauses are allowed for any ! static component. The restrictions on component clauses depend on the type of the component. @cindex Component Clause For all components of an elementary type, the only restriction on component clauses is that the size must be at least the 'Size value of the type ! (actually the Value_Size). There are no restrictions due to alignment, and such components may freely cross storage boundaries. ! Packed arrays with a size up to and including 64 bits are represented internally using a modular type with the appropriate number of bits, and ! thus the same lack of restriction applies. For example, if you declare: @smallexample type R is array (1 .. 49) of Boolean; *************** then a component clause for a component *** 8259,8270 **** specified bit boundary, and may specify a value of 49 bits or greater. For non-primitive types, including packed arrays with a size greater than ! 64-bits, component clauses must respect the alignment requirement of the type, in particular, always starting on a byte boundary, and the length must be a multiple of the storage unit. The tag field of a tagged type always occupies an address sized field at ! the start of the record. No component clause may attempt to overlay this tag. In the case of a record extension T1, of a type T, no component clause applied --- 8362,8373 ---- specified bit boundary, and may specify a value of 49 bits or greater. For non-primitive types, including packed arrays with a size greater than ! 64 bits, component clauses must respect the alignment requirement of the type, in particular, always starting on a byte boundary, and the length must be a multiple of the storage unit. The tag field of a tagged type always occupies an address sized field at ! the start of the record. No component clause may attempt to overlay this tag. In the case of a record extension T1, of a type T, no component clause applied *************** T'Size bytes of the record. *** 8275,8281 **** @section Enumeration Clauses The only restriction on enumeration clauses is that the range of values ! must be representable. For the signed case, if one or more of the representation values are negative, all values must be in the range: @smallexample --- 8378,8384 ---- @section Enumeration Clauses The only restriction on enumeration clauses is that the range of values ! must be representable. For the signed case, if one or more of the representation values are negative, all values must be in the range: @smallexample *************** be in the range: *** 8291,8297 **** @end smallexample @noindent ! A "confirming" representation clause is one in which the values range from 0 in sequence, i.e.@: a clause that confirms the default representation for an enumeration type. Such a confirming representation --- 8394,8400 ---- @end smallexample @noindent ! A @emph{confirming} representation clause is one in which the values range from 0 in sequence, i.e.@: a clause that confirms the default representation for an enumeration type. Such a confirming representation *************** that no extra overhead results from the *** 8300,8306 **** If an array has an index type which is an enumeration type to which an enumeration clause has been applied, then the array is stored in a compact ! manner. Consider the declarations: @smallexample type r is (A, B, C); --- 8403,8409 ---- If an array has an index type which is an enumeration type to which an enumeration clause has been applied, then the array is stored in a compact ! manner. Consider the declarations: @smallexample type r is (A, B, C); *************** manner. Consider the declarations: *** 8310,8319 **** @noindent The array type t corresponds to a vector with exactly three elements and ! has a default size equal to @code{3*Character'Size}. This ensures efficient use of space, but means that accesses to elements of the array will incur the overhead of converting representation values to the corresponding ! positional values, (i.e.@: the value delivered by the @code{Pos} attribute). @node Address Clauses @section Address Clauses --- 8413,8422 ---- @noindent The array type t corresponds to a vector with exactly three elements and ! has a default size equal to @code{3*Character'Size}. This ensures efficient use of space, but means that accesses to elements of the array will incur the overhead of converting representation values to the corresponding ! positional values, (i.e.@: the value delivered by the @code{Pos} attribute). @node Address Clauses @section Address Clauses *************** as found in RM 13.1(22): *** 8333,8359 **** @noindent In practice this is applicable only to address clauses, since this is the ! only case in which a non-static expression is permitted by the syntax. As the AARM notes in sections 13.1 (22.a-22.h): @smallexample 22.a Reason: This is to avoid the following sort of thing: ! 22.b X : Integer := F(...); ! Y : Address := G(...); for X'Address use Y; 22.c In the above, we have to evaluate the initialization expression for X before we ! know where to put the result. This seems like an unreasonable implementation burden. 22.d The above code should instead be written like this: ! 22.e Y : constant Address := G(...); ! X : Integer := F(...); for X'Address use Y; 22.f This allows the expression ``Y'' to be safely --- 8436,8462 ---- @noindent In practice this is applicable only to address clauses, since this is the ! only case in which a non-static expression is permitted by the syntax. As the AARM notes in sections 13.1 (22.a-22.h): @smallexample 22.a Reason: This is to avoid the following sort of thing: ! 22.b X : Integer := F(@dots{}); ! Y : Address := G(@dots{}); for X'Address use Y; 22.c In the above, we have to evaluate the initialization expression for X before we ! know where to put the result. This seems like an unreasonable implementation burden. 22.d The above code should instead be written like this: ! 22.e Y : constant Address := G(@dots{}); ! X : Integer := F(@dots{}); for X'Address use Y; 22.f This allows the expression ``Y'' to be safely *************** the AARM notes in sections 13.1 (22.a-22 *** 8362,8379 **** 22.g The constant could be a formal parameter of mode in. 22.h An implementation can support other nonstatic ! expressions if it wants to. Expressions of type Address are hardly ever static, but their value might be known at compile time anyway in many cases. @end smallexample @noindent ! GNAT does indeed permit many additional cases of non-static expressions. In particular, if the type involved is elementary there are no restrictions (since in this case, holding a temporary copy of the initialization value, ! if one is present, is inexpensive). In addition, if there is no implicit or ! explicit initialization, then there are no restrictions. GNAT will reject only the case where all three of these conditions hold: @itemize @bullet --- 8465,8482 ---- 22.g The constant could be a formal parameter of mode in. 22.h An implementation can support other nonstatic ! expressions if it wants to. Expressions of type Address are hardly ever static, but their value might be known at compile time anyway in many cases. @end smallexample @noindent ! GNAT does indeed permit many additional cases of non-static expressions. In particular, if the type involved is elementary there are no restrictions (since in this case, holding a temporary copy of the initialization value, ! if one is present, is inexpensive). In addition, if there is no implicit or ! explicit initialization, then there are no restrictions. GNAT will reject only the case where all three of these conditions hold: @itemize @bullet *************** The type of the item is non-elementary ( *** 8385,8391 **** There is explicit or implicit initialization required for the object. @item ! The address value is non-static. Here GNAT is more permissive than the RM, and allows the address value to be the address of a previously declared stand-alone variable, as long as it does not itself have an address clause. --- 8488,8494 ---- There is explicit or implicit initialization required for the object. @item ! The address value is non-static. Here GNAT is more permissive than the RM, and allows the address value to be the address of a previously declared stand-alone variable, as long as it does not itself have an address clause. *************** a component of a discriminated record. *** 8401,8412 **** @end itemize @noindent ! As noted above in section 22.h, address values are typically non-static. In particular the To_Address function, even if applied to a literal value, is ! a non-static function call. To avoid this minor annoyance, GNAT provides ! the implementation defined attribute 'To_Address. The following two expressions have identical values: @findex Attribute @findex To_Address @smallexample --- 8504,8529 ---- @end itemize @noindent ! As noted above in section 22.h, address values are typically non-static. In particular the To_Address function, even if applied to a literal value, is ! a non-static function call. To avoid this minor annoyance, GNAT provides ! the implementation defined attribute 'To_Address. The following two expressions have identical values: + Another issue with address clauses is the interaction with alignment + requirements. When an address clause is given for an object, the address + value must be consistent with the alignment of the object (which is usually + the same as the alignment of the type of the object). If an address clause + is given that specifies an inappropriately aligned address value, then the + program execution is erroneous. + + Since this source of erroneous behavior can have unfortunate effects, GNAT + checks (at compile time if possible, generating a warning, or at execution + time with a run-time check) that the alignment is appropriate. If the + run-time check fails, then @code{Program_Error} is raised. This run-time + check is suppressed if range checks are suppressed, or if + @code{pragma Restrictions (No_Elaboration_Code)} is in effect. + @findex Attribute @findex To_Address @smallexample *************** thus when used as an address clause valu *** 8420,8447 **** @noindent Additionally, GNAT treats as static an address clause that is an ! unchecked_conversion of a static integer value. This simplifies the porting of legacy code, and provides a portable equivalent to the GNAT attribute To_Address. @findex Export ! An address clause cannot be given for an exported object. More understandably the real restriction is that objects with an address ! clause cannot be exported. This is because such variables are not defined by the Ada program, so there is no external object so export. @findex Import It is permissible to give an address clause and a pragma Import for the ! same object. In this case, the variable is not really defined by the ! Ada program, so there is no external symbol to be linked. The link name ! and the external name are ignored in this case. The reason that we allow this combination is that it provides a useful idiom to avoid unwanted initializations on objects with address clauses. When an address clause is given for an object that has implicit or ! explicit initialization, then by default initialization takes place. This means that the effect of the object declaration is to overwrite the ! memory at the specified address. This is almost always not what the programmer wants, so GNAT will output a warning: @smallexample --- 8537,8564 ---- @noindent Additionally, GNAT treats as static an address clause that is an ! unchecked_conversion of a static integer value. This simplifies the porting of legacy code, and provides a portable equivalent to the GNAT attribute To_Address. @findex Export ! An address clause cannot be given for an exported object. More understandably the real restriction is that objects with an address ! clause cannot be exported. This is because such variables are not defined by the Ada program, so there is no external object so export. @findex Import It is permissible to give an address clause and a pragma Import for the ! same object. In this case, the variable is not really defined by the ! Ada program, so there is no external symbol to be linked. The link name ! and the external name are ignored in this case. The reason that we allow this combination is that it provides a useful idiom to avoid unwanted initializations on objects with address clauses. When an address clause is given for an object that has implicit or ! explicit initialization, then by default initialization takes place. This means that the effect of the object declaration is to overwrite the ! memory at the specified address. This is almost always not what the programmer wants, so GNAT will output a warning: @smallexample *************** programmer wants, so GNAT will output a *** 8464,8471 **** @noindent As indicated by the warning message, the solution is to use a (dummy) pragma ! Import to suppress this initialization. The pragma tell the compiler that the ! object is declared and initialized elsewhere. The following package compiles without warnings (and the initialization is suppressed): @smallexample --- 8581,8588 ---- @noindent As indicated by the warning message, the solution is to use a (dummy) pragma ! Import to suppress this initialization. The pragma tell the compiler that the ! object is declared and initialized elsewhere. The following package compiles without warnings (and the initialization is suppressed): @smallexample *************** without warnings (and the initialization *** 8487,8496 **** @noindent Normally the specification of a foreign language convention for a type or ! an object has no effect on the chosen representation. In particular, the representation chosen for data in GNAT generally meets the standard system conventions, and for example records are laid out in a manner that is ! consistent with C@. This means that specifying convention C (for example) has no effect. There are three exceptions to this general rule: --- 8604,8613 ---- @noindent Normally the specification of a foreign language convention for a type or ! an object has no effect on the chosen representation. In particular, the representation chosen for data in GNAT generally meets the standard system conventions, and for example records are laid out in a manner that is ! consistent with C@. This means that specifying convention C (for example) has no effect. There are three exceptions to this general rule: *************** column-major manner, instead of the norm *** 8505,8511 **** @item Convention C and enumeration types GNAT normally stores enumeration types in 8, 16, or 32 bits as required ! to accommodate all values of the type. For example, for the enumeration type declared by: @smallexample --- 8622,8628 ---- @item Convention C and enumeration types GNAT normally stores enumeration types in 8, 16, or 32 bits as required ! to accommodate all values of the type. For example, for the enumeration type declared by: @smallexample *************** type declared by: *** 8514,8529 **** @noindent 8 bits is sufficient to store all values of the type, so by default, objects ! of type @code{Color} will be represented using 8 bits. However, normal C ! convention is to use 32-bits for all enum values in C, since enum values ! are essentially of type int. If pragma Convention C is specified for an Ada enumeration type, then the size is modified as necessary (usually to 32 bits) to be consistent with the C convention for enum values. @item Convention C/Fortran and Boolean types In C, the usual convention for boolean values, that is values used for conditions, is that zero represents false, and nonzero values represent ! true. In Ada, the normal convention is that two specific values, typically 0/1, are used to represent false/true respectively. Fortran has a similar convention for @code{LOGICAL} values (any nonzero --- 8631,8646 ---- @noindent 8 bits is sufficient to store all values of the type, so by default, objects ! of type @code{Color} will be represented using 8 bits. However, normal C ! convention is to use 32 bits for all enum values in C, since enum values ! are essentially of type int. If pragma @code{Convention C} is specified for an Ada enumeration type, then the size is modified as necessary (usually to 32 bits) to be consistent with the C convention for enum values. @item Convention C/Fortran and Boolean types In C, the usual convention for boolean values, that is values used for conditions, is that zero represents false, and nonzero values represent ! true. In Ada, the normal convention is that two specific values, typically 0/1, are used to represent false/true respectively. Fortran has a similar convention for @code{LOGICAL} values (any nonzero *************** C or Fortran convention for a derived Bo *** 8538,8544 **** @end smallexample @noindent ! then the GNAT generated code will treat any nonzero value as true. For truth values generated by GNAT, the conventional value 1 will be used for True, but when one of these values is read, any nonzero value is treated as True. --- 8655,8661 ---- @end smallexample @noindent ! then the GNAT generated code will treat any nonzero value as true. For truth values generated by GNAT, the conventional value 1 will be used for True, but when one of these values is read, any nonzero value is treated as True. *************** when one of these values is read, any no *** 8547,8553 **** @node Determining the Representations chosen by GNAT @section Determining the Representations chosen by GNAT @cindex Representation, determination of ! @cindex -gnatR switch @noindent Although the descriptions in this section are intended to be complete, it is --- 8664,8670 ---- @node Determining the Representations chosen by GNAT @section Determining the Representations chosen by GNAT @cindex Representation, determination of ! @cindex @code{-gnatR} switch @noindent Although the descriptions in this section are intended to be complete, it is *************** often easier to simply experiment to see *** 8555,8573 **** effect is on the layout of types and objects. As required by the Ada RM, if a representation clause is not accepted, then ! it must be rejected as illegal by the compiler. However, when a representation clause or pragma is accepted, there can still be questions of what the ! compiler actually does. For example, if a partial record representation clause specifies the location of some components and not others, then where ! are the non-specified components placed? Or if pragma pack is used on a record, then exactly where are the resulting fields placed? The section ! on pragma Pack in this chapter can be used to answer the second question, but it is often easier to just see what the compiler does. ! For this purpose, GNAT provides the option @code{-gnatR}. If you compile with this option, then the compiler will output information on the actual representations chosen, in a format similar to source representation ! clauses. For example, if we compile the package: @smallexample package q is --- 8672,8690 ---- effect is on the layout of types and objects. As required by the Ada RM, if a representation clause is not accepted, then ! it must be rejected as illegal by the compiler. However, when a representation clause or pragma is accepted, there can still be questions of what the ! compiler actually does. For example, if a partial record representation clause specifies the location of some components and not others, then where ! are the non-specified components placed? Or if pragma @code{Pack} is used on a record, then exactly where are the resulting fields placed? The section ! on pragma @code{Pack} in this chapter can be used to answer the second question, but it is often easier to just see what the compiler does. ! For this purpose, GNAT provides the option @code{-gnatR}. If you compile with this option, then the compiler will output information on the actual representations chosen, in a format similar to source representation ! clauses. For example, if we compile the package: @smallexample package q is *************** Representation information for unit q *** 8623,8629 **** for r'Size use ??; for r'Alignment use 4; for r use record ! x at 4 range 0 .. 7; _tag at 0 range 0 .. 31; s at 5 range 0 .. 799; end record; --- 8740,8746 ---- for r'Size use ??; for r'Alignment use 4; for r use record ! x at 4 range 0 .. 7; _tag at 0 range 0 .. 31; s at 5 range 0 .. 799; end record; *************** end record; *** 8631,8637 **** for r2'Size use 160; for r2'Alignment use 4; for r2 use record ! x at 4 range 0 .. 7; _tag at 0 range 0 .. 31; _parent at 0 range 0 .. 63; y2 at 16 range 0 .. 31; --- 8748,8754 ---- for r2'Size use 160; for r2'Alignment use 4; for r2 use record ! x at 4 range 0 .. 7; _tag at 0 range 0 .. 31; _parent at 0 range 0 .. 63; y2 at 16 range 0 .. 31; *************** end record; *** 8640,8646 **** for x'Size use 8; for x'Alignment use 1; for x use record ! y at 0 range 0 .. 7; end record; for x1'Size use 112; --- 8757,8763 ---- for x'Size use 8; for x'Alignment use 1; for x use record ! y at 0 range 0 .. 7; end record; for x1'Size use 112; *************** for rb2'Component_Size use 1; *** 8658,8667 **** for x2'Size use 224; for x2'Alignment use 4; for x2 use record ! l1 at 0 range 0 .. 0; l2 at 0 range 1 .. 64; l3 at 12 range 0 .. 31; ! l4 at 16 range 0 .. 0; l5 at 16 range 1 .. 13; l6 at 18 range 0 .. 71; end record; --- 8775,8784 ---- for x2'Size use 224; for x2'Alignment use 4; for x2 use record ! l1 at 0 range 0 .. 0; l2 at 0 range 1 .. 64; l3 at 12 range 0 .. 31; ! l4 at 16 range 0 .. 0; l5 at 16 range 1 .. 13; l6 at 18 range 0 .. 71; end record; *************** fields present, including the parent fie *** 8685,8692 **** of the parent type of r2, i.e.@: r1. The component size and size clauses for types rb1 and rb2 show ! the exact effect of pragma Pack on these arrays, and the record ! representation clause for type x2 shows how pragma Pack affects this record type. In some cases, it may be useful to cut and paste the representation clauses --- 8802,8809 ---- of the parent type of r2, i.e.@: r1. The component size and size clauses for types rb1 and rb2 show ! the exact effect of pragma @code{Pack} on these arrays, and the record ! representation clause for type x2 shows how pragma @code{Pack} affects this record type. In some cases, it may be useful to cut and paste the representation clauses *************** the actual representation to be used. *** 8699,8705 **** @noindent The Ada 95 Reference Manual contains in Annex A a full description of an extensive set of standard library routines that can be used in any Ada ! program, and which must be provided by all Ada compilers. They are analogous to the standard C library used by C programs. GNAT implements all of the facilities described in annex A, and for most --- 8816,8822 ---- @noindent The Ada 95 Reference Manual contains in Annex A a full description of an extensive set of standard library routines that can be used in any Ada ! program, and which must be provided by all Ada compilers. They are analogous to the standard C library used by C programs. GNAT implements all of the facilities described in annex A, and for most *************** text book, will be sufficient for making *** 8709,8716 **** In the case of the input-output facilities, @xref{The Implementation of Standard I/O}, gives details on exactly how GNAT interfaces to the ! file system. For the remaining packages, the Ada 95 reference manual ! should be sufficient. The following is a list of the packages included, together with a brief description of the functionality that is provided. For completeness, references are included to other predefined library --- 8826,8833 ---- In the case of the input-output facilities, @xref{The Implementation of Standard I/O}, gives details on exactly how GNAT interfaces to the ! file system. For the remaining packages, the Ada 95 reference manual ! should be sufficient. The following is a list of the packages included, together with a brief description of the functionality that is provided. For completeness, references are included to other predefined library *************** cross-indexed from annex A). *** 8719,8725 **** @table @code @item Ada (A.2) ! This is a parent package for all the standard library packages. It is usually included implicitly in your program, and itself contains no useful data or routines. --- 8836,8842 ---- @table @code @item Ada (A.2) ! This is a parent package for all the standard library packages. It is usually included implicitly in your program, and itself contains no useful data or routines. *************** for letters, or digits). *** 8737,8752 **** @item Ada.Characters.Latin_1 (A.3.3) This package includes a complete set of definitions of the characters ! that appear in type CHARACTER@. It is useful for writing programs that ! will run in international environments. For example, if you want an upper case E with an acute accent in a string, it is often better to use ! the definition of @code{UC_E_Acute} in this package. Then your program will print in an understandable manner even if your environment does not support these extended characters. @item Ada.Command_Line (A.15) This package provides access to the command line parameters and the name ! of the current program (analogous to the use of argc and argv in C), and also allows the exit status for the program to be set in a system-independent manner. --- 8854,8869 ---- @item Ada.Characters.Latin_1 (A.3.3) This package includes a complete set of definitions of the characters ! that appear in type CHARACTER@. It is useful for writing programs that ! will run in international environments. For example, if you want an upper case E with an acute accent in a string, it is often better to use ! the definition of @code{UC_E_Acute} in this package. Then your program will print in an understandable manner even if your environment does not support these extended characters. @item Ada.Command_Line (A.15) This package provides access to the command line parameters and the name ! of the current program (analogous to the use of @code{argc} and @code{argv} in C), and also allows the exit status for the program to be set in a system-independent manner. *************** the standard IO packages. *** 8789,8795 **** @item Ada.Numerics This package contains some standard constants and exceptions used ! throughout the numerics packages. Note that the constants pi and e are defined here, and it is better to use these definitions than rolling your own. --- 8906,8912 ---- @item Ada.Numerics This package contains some standard constants and exceptions used ! throughout the numerics packages. Note that the constants pi and e are defined here, and it is better to use these definitions than rolling your own. *************** uniformly distributed floating point val *** 8814,8823 **** @item Ada.Numerics.Generic_Complex_Elementary_Functions This is a generic version of the package that provides the ! implementation of standard elementary functions (such as log an trigonometric functions) for an arbitrary complex type. ! The following predefined instantiations of this package exist @table @code @item Short_Float --- 8931,8940 ---- @item Ada.Numerics.Generic_Complex_Elementary_Functions This is a generic version of the package that provides the ! implementation of standard elementary functions (such as log and trigonometric functions) for an arbitrary complex type. ! The following predefined instantiations of this package are provided: @table @code @item Short_Float *************** The following predefined instantiations *** 8861,8867 **** @item Ada.Real_Time (D.8) This package provides facilities similar to those of @code{Calendar}, but ! operating with a finer clock suitable for real time control. @item Ada.Sequential_IO (A.8.1) This package provides input-output facilities for sequential files, --- 8978,8988 ---- @item Ada.Real_Time (D.8) This package provides facilities similar to those of @code{Calendar}, but ! operating with a finer clock suitable for real time control. Note that ! annex D requires that there be no backward clock jumps, and GNAT generally ! guarantees this behavior, but of course if the external clock on which ! the GNAT runtime depends is deliberately reset by some external event, ! then such a backward jump may occur. @item Ada.Sequential_IO (A.8.1) This package provides input-output facilities for sequential files, *************** any Ada type, including indefinite (unco *** 8870,8876 **** @item Ada.Storage_IO (A.9) This package provides a facility for mapping arbitrary Ada types to and ! from a storage buffer. It is primarily intended for the creation of new IO packages. @item Ada.Streams (13.13.1) --- 8991,8997 ---- @item Ada.Storage_IO (A.9) This package provides a facility for mapping arbitrary Ada types to and ! from a storage buffer. It is primarily intended for the creation of new IO packages. @item Ada.Streams (13.13.1) *************** concept of streams as used by the stream *** 8881,8887 **** @item Ada.Streams.Stream_IO (A.12.1) This package is a specialization of the type @code{Streams} defined in package @code{Streams} together with a set of operations providing ! Stream_IO capability. The Stream_IO model permits both random and sequential access to a file which can contain an arbitrary set of values of one or more Ada types. --- 9002,9008 ---- @item Ada.Streams.Stream_IO (A.12.1) This package is a specialization of the type @code{Streams} defined in package @code{Streams} together with a set of operations providing ! Stream_IO capability. The Stream_IO model permits both random and sequential access to a file which can contain an arbitrary set of values of one or more Ada types. *************** packages. *** 8891,8897 **** @item Ada.Strings.Bounded (A.4.4) This package provides facilities for handling variable length ! strings. The bounded model requires a maximum length. It is thus somewhat more limited than the unbounded model, but avoids the use of dynamic allocation or finalization. --- 9012,9018 ---- @item Ada.Strings.Bounded (A.4.4) This package provides facilities for handling variable length ! strings. The bounded model requires a maximum length. It is thus somewhat more limited than the unbounded model, but avoids the use of dynamic allocation or finalization. *************** This package provides facilities for han *** 8900,8920 **** @item Ada.Strings.Maps (A.4.2) This package provides facilities for handling character mappings and ! arbitrarily defined subsets of characters. For instance it is useful in defining specialized translation tables. @item Ada.Strings.Maps.Constants (A.4.6) This package provides a standard set of predefined mappings and ! predefined character sets. For example, the standard upper to lower case ! conversion table is found in this package. Note that upper to lower case conversion is non-trivial if you want to take the entire set of characters, including extended characters like E with an acute accent, ! into account. You should use the mappings in this package (rather than adding 32 yourself) to do case mappings. @item Ada.Strings.Unbounded (A.4.5) This package provides facilities for handling variable length ! strings. The unbounded model allows arbitrary length strings, but requires the use of dynamic allocation and finalization. @item Ada.Strings.Wide_Bounded (A.4.7) --- 9021,9041 ---- @item Ada.Strings.Maps (A.4.2) This package provides facilities for handling character mappings and ! arbitrarily defined subsets of characters. For instance it is useful in defining specialized translation tables. @item Ada.Strings.Maps.Constants (A.4.6) This package provides a standard set of predefined mappings and ! predefined character sets. For example, the standard upper to lower case ! conversion table is found in this package. Note that upper to lower case conversion is non-trivial if you want to take the entire set of characters, including extended characters like E with an acute accent, ! into account. You should use the mappings in this package (rather than adding 32 yourself) to do case mappings. @item Ada.Strings.Unbounded (A.4.5) This package provides facilities for handling variable length ! strings. The unbounded model allows arbitrary length strings, but requires the use of dynamic allocation and finalization. @item Ada.Strings.Wide_Bounded (A.4.7) *************** task-specific data with separate tasks. *** 8941,8947 **** @item Ada.Text_IO This package provides basic text input-output capabilities for ! character, string and numeric data. The subpackages of this package are listed next. @item Ada.Text_IO.Decimal_IO --- 9062,9068 ---- @item Ada.Text_IO This package provides basic text input-output capabilities for ! character, string and numeric data. The subpackages of this package are listed next. @item Ada.Text_IO.Decimal_IO *************** Provides input-output facilities for enu *** 8954,8960 **** Provides input-output facilities for ordinary fixed-point types. @item Ada.Text_IO.Float_IO ! Provides input-output facilities for float types. The following predefined instantiations of this generic package are available: @table @code --- 9075,9081 ---- Provides input-output facilities for ordinary fixed-point types. @item Ada.Text_IO.Float_IO ! Provides input-output facilities for float types. The following predefined instantiations of this generic package are available: @table @code *************** predefined instantiations of this generi *** 8967,8973 **** @end table @item Ada.Text_IO.Integer_IO ! Provides input-output facilities for integer types. The following predefined instantiations of this generic package are available: @table @code --- 9088,9094 ---- @end table @item Ada.Text_IO.Integer_IO ! Provides input-output facilities for integer types. The following predefined instantiations of this generic package are available: @table @code *************** data. *** 8992,8998 **** @item Ada.Text_IO.Editing (F.3.3) This package contains routines for edited output, analogous to the use ! of pictures in COBOL@. The picture formats used by this package are a close copy of the facility in COBOL@. @item Ada.Text_IO.Text_Streams (A.12.2) --- 9113,9119 ---- @item Ada.Text_IO.Editing (F.3.3) This package contains routines for edited output, analogous to the use ! of pictures in COBOL@. The picture formats used by this package are a close copy of the facility in COBOL@. @item Ada.Text_IO.Text_Streams (A.12.2) *************** special circumstances. *** 9007,9030 **** If the types have the same Size (more accurately the same Value_Size), then the effect is simply to transfer the bits from the source to the ! target type without any modification. This usage is well defined, and for simple types whose representation is typically the same across all implementations, gives a portable method of performing such conversions. If the types do not have the same size, then the result is implementation ! defined, and thus may be non-portable. The following describes how GNAT handles such unchecked conversion cases. If the types are of different sizes, and are both discrete types, then the effect is of a normal type conversion without any constraint checking. In particular if the result type has a larger size, the result will be ! zero or sign extended. If the result type has a smaller size, the result will be truncated by ignoring high order bits. If the types are of different sizes, and are not both discrete types, then the conversion works as though pointers were created to the source ! and target, and the pointer value is converted. The effect is that bits are copied from successive low order storage units and bits of the source up to the length of the target type. --- 9128,9151 ---- If the types have the same Size (more accurately the same Value_Size), then the effect is simply to transfer the bits from the source to the ! target type without any modification. This usage is well defined, and for simple types whose representation is typically the same across all implementations, gives a portable method of performing such conversions. If the types do not have the same size, then the result is implementation ! defined, and thus may be non-portable. The following describes how GNAT handles such unchecked conversion cases. If the types are of different sizes, and are both discrete types, then the effect is of a normal type conversion without any constraint checking. In particular if the result type has a larger size, the result will be ! zero or sign extended. If the result type has a smaller size, the result will be truncated by ignoring high order bits. If the types are of different sizes, and are not both discrete types, then the conversion works as though pointers were created to the source ! and target, and the pointer value is converted. The effect is that bits are copied from successive low order storage units and bits of the source up to the length of the target type. *************** case is implementation dependent, and th *** 9033,9051 **** that of some other compiler. A pointer to one type may be converted to a pointer to another type using ! unchecked conversion. The only case in which the effect is undefined is ! when one or both pointers are pointers to unconstrained array types. In this case, the bounds information may get incorrectly transferred, and in particular, GNAT uses double size pointers for such types, and it is ! meaningless to convert between such pointer types. GNAT will issue a warning if the alignment of the target designated type is more strict than the alignment of the source designated type (since the result may be unaligned in this case). A pointer other than a pointer to an unconstrained array type may be ! converted to and from System.Address. Such usage is common in Ada 83 programs, but note that Ada.Address_To_Access_Conversions is the ! preferred method of performing such conversions in Ada 95. Neither unchecked conversion nor Ada.Address_To_Access_Conversions should be used in conjunction with pointers to unconstrained objects, since the bounds information cannot be handled correctly in this case. --- 9154,9172 ---- that of some other compiler. A pointer to one type may be converted to a pointer to another type using ! unchecked conversion. The only case in which the effect is undefined is ! when one or both pointers are pointers to unconstrained array types. In this case, the bounds information may get incorrectly transferred, and in particular, GNAT uses double size pointers for such types, and it is ! meaningless to convert between such pointer types. GNAT will issue a warning if the alignment of the target designated type is more strict than the alignment of the source designated type (since the result may be unaligned in this case). A pointer other than a pointer to an unconstrained array type may be ! converted to and from System.Address. Such usage is common in Ada 83 programs, but note that Ada.Address_To_Access_Conversions is the ! preferred method of performing such conversions in Ada 95. Neither unchecked conversion nor Ada.Address_To_Access_Conversions should be used in conjunction with pointers to unconstrained objects, since the bounds information cannot be handled correctly in this case. *************** allocated by use of an allocator. *** 9058,9064 **** This package is similar to @code{Ada.Text_IO}, except that the external file supports wide character representations, and the internal types are @code{Wide_Character} and @code{Wide_String} instead of @code{Character} ! and @code{String}. It contains generic subpackages listed next. @item Ada.Wide_Text_IO.Decimal_IO Provides input-output facilities for decimal fixed-point types --- 9179,9185 ---- This package is similar to @code{Ada.Text_IO}, except that the external file supports wide character representations, and the internal types are @code{Wide_Character} and @code{Wide_String} instead of @code{Character} ! and @code{String}. It contains generic subpackages listed next. @item Ada.Wide_Text_IO.Decimal_IO Provides input-output facilities for decimal fixed-point types *************** Provides input-output facilities for enu *** 9070,9076 **** Provides input-output facilities for ordinary fixed-point types. @item Ada.Wide_Text_IO.Float_IO ! Provides input-output facilities for float types. The following predefined instantiations of this generic package are available: @table @code --- 9191,9197 ---- Provides input-output facilities for ordinary fixed-point types. @item Ada.Wide_Text_IO.Float_IO ! Provides input-output facilities for float types. The following predefined instantiations of this generic package are available: @table @code *************** predefined instantiations of this generi *** 9083,9089 **** @end table @item Ada.Wide_Text_IO.Integer_IO ! Provides input-output facilities for integer types. The following predefined instantiations of this generic package are available: @table @code --- 9204,9210 ---- @end table @item Ada.Wide_Text_IO.Integer_IO ! Provides input-output facilities for integer types. The following predefined instantiations of this generic package are available: @table @code *************** types are @code{Wide_Character} and @cod *** 9121,9132 **** @noindent GNAT implements all the required input-output facilities described in ! A.6 through A.14. These sections of the Ada 95 reference manual describe the required behavior of these packages from the Ada point of view, and if you are writing a portable Ada program that does not need to know the exact manner in which Ada maps to the outside world when it comes to reading or writing external files, then you do not need to read this ! chapter. As long as your files are all regular files (not pipes or devices), and as long as you write and read the files only from Ada, the description in the Ada 95 reference manual is sufficient. --- 9242,9253 ---- @noindent GNAT implements all the required input-output facilities described in ! A.6 through A.14. These sections of the Ada 95 reference manual describe the required behavior of these packages from the Ada point of view, and if you are writing a portable Ada program that does not need to know the exact manner in which Ada maps to the outside world when it comes to reading or writing external files, then you do not need to read this ! chapter. As long as your files are all regular files (not pipes or devices), and as long as you write and read the files only from Ada, the description in the Ada 95 reference manual is sufficient. *************** language, then you need to know more abo *** 9137,9150 **** implementation of these input-output facilities behaves. In this chapter we give a detailed description of exactly how GNAT ! interfaces to the file system. As always, the sources of the system are available to you for answering questions at an even more detailed level, but for most purposes the information in this chapter will suffice. Another reason that you may need to know more about how input-output is implemented arises when you have a program written in mixed languages where, for example, files are shared between the C and Ada sections of ! the same program. GNAT provides some additional facilities, in the form of additional child library packages, that facilitate this sharing, and these additional facilities are also described in this chapter. --- 9258,9271 ---- implementation of these input-output facilities behaves. In this chapter we give a detailed description of exactly how GNAT ! interfaces to the file system. As always, the sources of the system are available to you for answering questions at an even more detailed level, but for most purposes the information in this chapter will suffice. Another reason that you may need to know more about how input-output is implemented arises when you have a program written in mixed languages where, for example, files are shared between the C and Ada sections of ! the same program. GNAT provides some additional facilities, in the form of additional child library packages, that facilitate this sharing, and these additional facilities are also described in this chapter. *************** All files are opened using @code{fopen}. *** 9200,9208 **** All input/output operations use @code{fread}/@code{fwrite}. @end itemize ! There is no internal buffering of any kind at the Ada library level. The only buffering is that provided at the system level in the ! implementation of the C library routines that support streams. This facilitates shared use of these streams by mixed language programs. @node FORM Strings --- 9321,9329 ---- All input/output operations use @code{fread}/@code{fwrite}. @end itemize ! There is no internal buffering of any kind at the Ada library level. The only buffering is that provided at the system level in the ! implementation of the C library routines that support streams. This facilitates shared use of these streams by mixed language programs. @node FORM Strings *************** facilitates shared use of these streams *** 9212,9223 **** The format of a FORM string in GNAT is: @smallexample ! "keyword=value,keyword=value,...,keyword=value" @end smallexample @noindent where letters may be in upper or lower case, and there are no spaces ! between values. The order of the entries is not important. Currently there are two keywords defined. @smallexample --- 9333,9344 ---- The format of a FORM string in GNAT is: @smallexample ! "keyword=value,keyword=value,@dots{},keyword=value" @end smallexample @noindent where letters may be in upper or lower case, and there are no spaces ! between values. The order of the entries is not important. Currently there are two keywords defined. @smallexample *************** The use of these parameters is described *** 9231,9247 **** @section Direct_IO @noindent ! Direct_IO can only be instantiated for definite types. This is a restriction of the Ada language, which means that the records are fixed length (the length being determined by @code{@var{type}'Size}, rounded up to the next storage unit boundary if necessary). The records of a Direct_IO file are simply written to the file in index sequence, with the first record starting at offset zero, and subsequent ! records following. There is no control information of any kind. For example, if 32-bit integers are being written, each record takes ! 4-bytes, so the record at index @var{K} starts at offset (@var{K} - ! 1)*4. There is no limit on the size of Direct_IO files, they are expanded as necessary to accommodate whatever records are written to the file. --- 9352,9368 ---- @section Direct_IO @noindent ! Direct_IO can only be instantiated for definite types. This is a restriction of the Ada language, which means that the records are fixed length (the length being determined by @code{@var{type}'Size}, rounded up to the next storage unit boundary if necessary). The records of a Direct_IO file are simply written to the file in index sequence, with the first record starting at offset zero, and subsequent ! records following. There is no control information of any kind. For example, if 32-bit integers are being written, each record takes ! 4-bytes, so the record at index @var{K} starts at offset ! (@var{K}@minus{}1)*4. There is no limit on the size of Direct_IO files, they are expanded as necessary to accommodate whatever records are written to the file. *************** or indefinite (unconstrained) type. *** 9255,9282 **** For the definite type case, the elements written to the file are simply the memory images of the data values with no control information of any ! kind. The resulting file should be read using the same type, no validity checking is performed on input. For the indefinite type case, the elements written consist of two ! parts. First is the size of the data item, written as the memory image of a @code{Interfaces.C.size_t} value, followed by the memory image of ! the data value. The resulting file can only be read using the same ! (unconstrained) type. Normal assignment checks are performed on these read operations, and if these checks fail, @code{Data_Error} is ! raised. In particular, in the array case, the lengths must match, and in the variant record case, if the variable for a particular read operation is constrained, the discriminants must match. Note that it is not possible to use Sequential_IO to write variable length array items, and then read the data back into different length ! arrays. For example, the following will raise @code{Data_Error}: @smallexample package IO is new Sequential_IO (String); F : IO.File_Type; S : String (1..4); ! ... IO.Create (F) IO.Write (F, "hello!") IO.Reset (F, Mode=>In_File); --- 9376,9403 ---- For the definite type case, the elements written to the file are simply the memory images of the data values with no control information of any ! kind. The resulting file should be read using the same type, no validity checking is performed on input. For the indefinite type case, the elements written consist of two ! parts. First is the size of the data item, written as the memory image of a @code{Interfaces.C.size_t} value, followed by the memory image of ! the data value. The resulting file can only be read using the same ! (unconstrained) type. Normal assignment checks are performed on these read operations, and if these checks fail, @code{Data_Error} is ! raised. In particular, in the array case, the lengths must match, and in the variant record case, if the variable for a particular read operation is constrained, the discriminants must match. Note that it is not possible to use Sequential_IO to write variable length array items, and then read the data back into different length ! arrays. For example, the following will raise @code{Data_Error}: @smallexample package IO is new Sequential_IO (String); F : IO.File_Type; S : String (1..4); ! @dots{} IO.Create (F) IO.Write (F, "hello!") IO.Reset (F, Mode=>In_File); *************** clearly incorrect, since there is only o *** 9290,9296 **** element is the string @samp{hello!}. In Ada 95, this kind of behavior can be legitimately achieved using ! Stream_IO, and this is the preferred mechanism. In particular, the above program fragment rewritten to use Stream_IO will work correctly. @node Text_IO --- 9411,9417 ---- element is the string @samp{hello!}. In Ada 95, this kind of behavior can be legitimately achieved using ! Stream_IO, and this is the preferred mechanism. In particular, the above program fragment rewritten to use Stream_IO will work correctly. @node Text_IO *************** end of a page and consequently can appea *** 9320,9337 **** @item The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF} ! (line mark, page mark). In the former case, the page mark is implicitly assumed to be present. @end itemize A file written using Text_IO will be in canonical form provided that no explicit @code{LF} or @code{FF} characters are written using @code{Put} ! or @code{Put_Line}. There will be no @code{FF} character at the end of the file unless an explicit @code{New_Page} operation was performed before closing the file. A canonical Text_IO file that is a regular file, i.e.@: not a device or a ! pipe, can be read using any of the routines in Text_IO@. The semantics in this case will be exactly as defined in the Ada 95 reference manual and all the routines in Text_IO are fully implemented. --- 9441,9458 ---- @item The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF} ! (line mark, page mark). In the former case, the page mark is implicitly assumed to be present. @end itemize A file written using Text_IO will be in canonical form provided that no explicit @code{LF} or @code{FF} characters are written using @code{Put} ! or @code{Put_Line}. There will be no @code{FF} character at the end of the file unless an explicit @code{New_Page} operation was performed before closing the file. A canonical Text_IO file that is a regular file, i.e.@: not a device or a ! pipe, can be read using any of the routines in Text_IO@. The semantics in this case will be exactly as defined in the Ada 95 reference manual and all the routines in Text_IO are fully implemented. *************** i.e.@: there is no explicit line mark or *** 9354,9363 **** @end itemize Text_IO can be used to read such non-standard text files but subprograms ! to do with line or page numbers do not have defined meanings. In particular, a @code{FF} character that does not follow a @code{LF} character may or may not be treated as a page mark from the point of ! view of page and line numbering. Every @code{LF} character is considered to end a line, and there is an implied @code{LF} character at the end of the file. --- 9475,9484 ---- @end itemize Text_IO can be used to read such non-standard text files but subprograms ! to do with line or page numbers do not have defined meanings. In particular, a @code{FF} character that does not follow a @code{LF} character may or may not be treated as a page mark from the point of ! view of page and line numbering. Every @code{LF} character is considered to end a line, and there is an implied @code{LF} character at the end of the file. *************** the file. *** 9375,9389 **** @noindent @code{Ada.Text_IO} has a definition of current position for a file that ! is being read. No internal buffering occurs in Text_IO, and usually the physical position in the stream used to implement the file corresponds ! to this logical position defined by Text_IO@. There are two exceptions: @itemize @bullet @item After a call to @code{End_Of_Page} that returns @code{True}, the stream is positioned past the @code{LF} (line mark) that precedes the page ! mark. Text_IO maintains an internal flag so that subsequent read operations properly handle the logical position which is unchanged by the @code{End_Of_Page} call. --- 9496,9510 ---- @noindent @code{Ada.Text_IO} has a definition of current position for a file that ! is being read. No internal buffering occurs in Text_IO, and usually the physical position in the stream used to implement the file corresponds ! to this logical position defined by Text_IO@. There are two exceptions: @itemize @bullet @item After a call to @code{End_Of_Page} that returns @code{True}, the stream is positioned past the @code{LF} (line mark) that precedes the page ! mark. Text_IO maintains an internal flag so that subsequent read operations properly handle the logical position which is unchanged by the @code{End_Of_Page} call. *************** After a call to @code{End_Of_File} that *** 9392,9398 **** Text_IO file was positioned before the line mark at the end of file before the call, then the logical position is unchanged, but the stream is physically positioned right at the end of file (past the line mark, ! and past a possible page mark following the line mark. Again Text_IO maintains internal flags so that subsequent read operations properly handle the logical position. @end itemize --- 9513,9519 ---- Text_IO file was positioned before the line mark at the end of file before the call, then the logical position is unchanged, but the stream is physically positioned right at the end of file (past the line mark, ! and past a possible page mark following the line mark. Again Text_IO maintains internal flags so that subsequent read operations properly handle the logical position. @end itemize *************** situations. *** 9407,9427 **** @subsection Reading and Writing Non-Regular Files @noindent ! A non-regular file is a device (such as a keyboard), or a pipe. Text_IO ! can be used for reading and writing. Writing is not affected and the sequence of characters output is identical to the normal file case, but for reading, the behavior of Text_IO is modified to avoid undesirable look-ahead as follows: An input file that is not a regular file is considered to have no page ! marks. Any @code{Ascii.FF} characters (the character normally used for a page mark) appearing in the file are considered to be data ! characters. In particular: @itemize @bullet @item @code{Get_Line} and @code{Skip_Line} do not test for a page mark ! following a line mark. If a page mark appears, it will be treated as a data character. @item --- 9528,9548 ---- @subsection Reading and Writing Non-Regular Files @noindent ! A non-regular file is a device (such as a keyboard), or a pipe. Text_IO ! can be used for reading and writing. Writing is not affected and the sequence of characters output is identical to the normal file case, but for reading, the behavior of Text_IO is modified to avoid undesirable look-ahead as follows: An input file that is not a regular file is considered to have no page ! marks. Any @code{Ascii.FF} characters (the character normally used for a page mark) appearing in the file are considered to be data ! characters. In particular: @itemize @bullet @item @code{Get_Line} and @code{Skip_Line} do not test for a page mark ! following a line mark. If a page mark appears, it will be treated as a data character. @item *************** entered from the pipe to complete one of *** 9436,9449 **** the end of the file. @end itemize ! Output to non-regular files is the same as for regular files. Page marks may be written to non-regular files using @code{New_Page}, but as noted above they will not be treated as page marks on input if the output is piped to another Ada program. Another important discrepancy when reading non-regular files is that the end ! of file indication is not "sticky". If an end of file is entered, e.g.@: by ! pressing the @code{EOT} key, then end of file is signalled once (i.e.@: the test @code{End_Of_File} will yield @code{True}, or a read will --- 9557,9570 ---- the end of the file. @end itemize ! Output to non-regular files is the same as for regular files. Page marks may be written to non-regular files using @code{New_Page}, but as noted above they will not be treated as page marks on input if the output is piped to another Ada program. Another important discrepancy when reading non-regular files is that the end ! of file indication is not ``sticky''. If an end of file is entered, e.g.@: by ! pressing the @key{EOT} key, then end of file is signalled once (i.e.@: the test @code{End_Of_File} will yield @code{True}, or a read will *************** file indication, until another end of fi *** 9457,9468 **** @noindent Get_Immediate returns the next character (including control characters) ! from the input file. In particular, Get_Immediate will return LF or FF ! characters used as line marks or page marks. Such operations leave the file positioned past the control character, and it is thus not treated ! as having its normal function. This means that page, line and column counts after this kind of Get_Immediate call are set as though the mark ! did not occur. In the case where a Get_Immediate leaves the file positioned between the line mark and page mark (which is not normally possible), it is undefined whether the FF character will be treated as a page mark. --- 9578,9589 ---- @noindent Get_Immediate returns the next character (including control characters) ! from the input file. In particular, Get_Immediate will return LF or FF ! characters used as line marks or page marks. Such operations leave the file positioned past the control character, and it is thus not treated ! as having its normal function. This means that page, line and column counts after this kind of Get_Immediate call are set as though the mark ! did not occur. In the case where a Get_Immediate leaves the file positioned between the line mark and page mark (which is not normally possible), it is undefined whether the FF character will be treated as a page mark. *************** page mark. *** 9473,9482 **** @noindent The package @code{Text_IO.Streams} allows a Text_IO file to be treated ! as a stream. Data written to a Text_IO file in this stream mode is ! binary data. If this binary data contains bytes 16#0A# (@code{LF}) or 16#0C# (@code{FF}), the resulting file may have non-standard ! format. Similarly if read operations are used to read from a Text_IO file treated as a stream, then @code{LF} and @code{FF} characters may be skipped and the effect is similar to that described above for @code{Get_Immediate}. --- 9594,9603 ---- @noindent The package @code{Text_IO.Streams} allows a Text_IO file to be treated ! as a stream. Data written to a Text_IO file in this stream mode is ! binary data. If this binary data contains bytes 16#0A# (@code{LF}) or 16#0C# (@code{FF}), the resulting file may have non-standard ! format. Similarly if read operations are used to read from a Text_IO file treated as a stream, then @code{LF} and @code{FF} characters may be skipped and the effect is similar to that described above for @code{Get_Immediate}. *************** Determines if a file of the given name e *** 9495,9501 **** opened (without actually performing the open operation). @item function Get_Line return String; ! Reads a string from the standard input file. The value returned is exactly the length of the line that was read. @item function Get_Line (File : Ada.Text_IO.File_Type) return String; --- 9616,9622 ---- opened (without actually performing the open operation). @item function Get_Line return String; ! Reads a string from the standard input file. The value returned is exactly the length of the line that was read. @item function Get_Line (File : Ada.Text_IO.File_Type) return String; *************** that an extra copy is avoided. *** 9534,9544 **** @noindent In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type} ! and is optional. If the parameter is omitted, then the standard input or output file is referenced as appropriate. The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library ! files @code{a-swuwti.ads/adb} provides similar extended @code{Wide_Text_IO} functionality for unbounded wide strings. @node Wide_Text_IO --- 9655,9665 ---- @noindent In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type} ! and is optional. If the parameter is omitted, then the standard input or output file is referenced as appropriate. The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library ! files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended @code{Wide_Text_IO} functionality for unbounded wide strings. @node Wide_Text_IO *************** functionality for unbounded wide strings *** 9547,9553 **** @noindent @code{Wide_Text_IO} is similar in most respects to Text_IO, except that both input and output files may contain special sequences that represent ! wide character values. The encoding scheme for a given file may be specified using a FORM parameter: @smallexample --- 9668,9674 ---- @noindent @code{Wide_Text_IO} is similar in most respects to Text_IO, except that both input and output files may contain special sequences that represent ! wide character values. The encoding scheme for a given file may be specified using a FORM parameter: @smallexample *************** ESC a b c d *** 9594,9624 **** @end smallexample where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal ! characters (using upper case letters) of the wide character code. For example, ESC A345 is used to represent the wide character with code ! 16#A345#. This scheme is compatible with use of the full @code{Wide_Character} set. @item Upper Half Coding The wide character with encoding 16#abcd#, where the upper bit is on (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and ! 16#cd#. The second byte may never be a format control character, but is ! not required to be in the upper half. This method can be also used for shift-JIS or EUC where the internal coding matches the external coding. @item Shift JIS Coding A wide character is represented by a two character sequence 16#ab# and 16#cd#, with the restrictions described for upper half encoding as ! described above. The internal character code is the corresponding JIS character according to the standard algorithm for Shift-JIS ! conversion. Only characters defined in the JIS code set table can be used with this encoding method. @item EUC Coding A wide character is represented by a two character sequence 16#ab# and ! 16#cd#, with both characters being in the upper half. The internal character code is the corresponding JIS character according to the EUC ! encoding algorithm. Only characters defined in the JIS code set table can be used with this encoding method. @item UTF-8 Coding --- 9715,9745 ---- @end smallexample where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal ! characters (using upper case letters) of the wide character code. For example, ESC A345 is used to represent the wide character with code ! 16#A345#. This scheme is compatible with use of the full @code{Wide_Character} set. @item Upper Half Coding The wide character with encoding 16#abcd#, where the upper bit is on (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and ! 16#cd#. The second byte may never be a format control character, but is ! not required to be in the upper half. This method can be also used for shift-JIS or EUC where the internal coding matches the external coding. @item Shift JIS Coding A wide character is represented by a two character sequence 16#ab# and 16#cd#, with the restrictions described for upper half encoding as ! described above. The internal character code is the corresponding JIS character according to the standard algorithm for Shift-JIS ! conversion. Only characters defined in the JIS code set table can be used with this encoding method. @item EUC Coding A wide character is represented by a two character sequence 16#ab# and ! 16#cd#, with both characters being in the upper half. The internal character code is the corresponding JIS character according to the EUC ! encoding algorithm. Only characters defined in the JIS code set table can be used with this encoding method. @item UTF-8 Coding *************** is a one, two, or three byte sequence: *** 9634,9646 **** @end smallexample where the xxx bits correspond to the left-padded bits of the ! 16-bit character value. Note that all lower half ASCII characters are represented as ASCII bytes and all upper half characters and other wide characters are represented as sequences of upper-half (The full UTF-8 scheme allows for encoding 31-bit characters as 6-byte sequences, but in this implementation, all UTF-8 sequences of four or more bytes length will raise a Constraint_Error, as ! will all illegal UTF-8 sequences.) @item Brackets Coding In this encoding, a wide character is represented by the following eight --- 9755,9767 ---- @end smallexample where the xxx bits correspond to the left-padded bits of the ! 16-bit character value. Note that all lower half ASCII characters are represented as ASCII bytes and all upper half characters and other wide characters are represented as sequences of upper-half (The full UTF-8 scheme allows for encoding 31-bit characters as 6-byte sequences, but in this implementation, all UTF-8 sequences of four or more bytes length will raise a Constraint_Error, as ! will all invalid UTF-8 sequences.) @item Brackets Coding In this encoding, a wide character is represented by the following eight *************** character sequence: *** 9651,9671 **** @end smallexample Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal ! characters (using uppercase letters) of the wide character code. For example, @code{["A345"]} is used to represent the wide character with code @code{16#A345#}. This scheme is compatible with use of the full Wide_Character set. On input, brackets coding can also be used for upper half characters, ! e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation is only used for wide characters with a code greater than @code{16#FF#}. @end table For the coding schemes other than Hex and Brackets encoding, not all wide character ! values can be represented. An attempt to output a character that cannot be represented using the encoding scheme for the file causes ! Constraint_Error to be raised. An invalid wide character sequence on input also causes Constraint_Error to be raised. @menu --- 9772,9792 ---- @end smallexample Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal ! characters (using uppercase letters) of the wide character code. For example, @code{["A345"]} is used to represent the wide character with code @code{16#A345#}. This scheme is compatible with use of the full Wide_Character set. On input, brackets coding can also be used for upper half characters, ! e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation is only used for wide characters with a code greater than @code{16#FF#}. @end table For the coding schemes other than Hex and Brackets encoding, not all wide character ! values can be represented. An attempt to output a character that cannot be represented using the encoding scheme for the file causes ! Constraint_Error to be raised. An invalid wide character sequence on input also causes Constraint_Error to be raised. @menu *************** input also causes Constraint_Error to be *** 9678,9684 **** @noindent @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling ! of stream pointer positioning (@pxref{Text_IO}). There is one additional case: If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the --- 9799,9805 ---- @noindent @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling ! of stream pointer positioning (@pxref{Text_IO}). There is one additional case: If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the *************** Wide_Character'Val (16#0080#) .. Wide_Ch *** 9691,9700 **** @noindent then although the logical position of the file pointer is unchanged by the @code{Look_Ahead} call, the stream is physically positioned past the ! wide character sequence. Again this is to avoid the need for buffering or backup, and all @code{Wide_Text_IO} routines check the internal indication that this situation has occurred so that this is not visible ! to a normal program using @code{Wide_Text_IO}. However, this discrepancy can be observed if the wide text file shares a stream with another file. @node Wide_Text_IO Reading and Writing Non-Regular Files --- 9812,9821 ---- @noindent then although the logical position of the file pointer is unchanged by the @code{Look_Ahead} call, the stream is physically positioned past the ! wide character sequence. Again this is to avoid the need for buffering or backup, and all @code{Wide_Text_IO} routines check the internal indication that this situation has occurred so that this is not visible ! to a normal program using @code{Wide_Text_IO}. However, this discrepancy can be observed if the wide text file shares a stream with another file. @node Wide_Text_IO Reading and Writing Non-Regular Files *************** can be observed if the wide text file sh *** 9704,9710 **** As in the case of Text_IO, when a non-regular file is read, it is assumed that the file contains no page marks (any form characters are treated as data characters), and @code{End_Of_Page} always returns ! @code{False}. Similarly, the end of file indication is not sticky, so it is possible to read beyond an end of file. @node Stream_IO --- 9825,9831 ---- As in the case of Text_IO, when a non-regular file is read, it is assumed that the file contains no page marks (any form characters are treated as data characters), and @code{End_Of_Page} always returns ! @code{False}. Similarly, the end of file indication is not sticky, so it is possible to read beyond an end of file. @node Stream_IO *************** it is possible to read beyond an end of *** 9712,9719 **** @noindent A stream file is a sequence of bytes, where individual elements are ! written to the file as described in the Ada 95 reference manual. The type ! @code{Stream_Element} is simply a byte. There are two ways to read or write a stream file. @itemize @bullet --- 9833,9840 ---- @noindent A stream file is a sequence of bytes, where individual elements are ! written to the file as described in the Ada 95 reference manual. The type ! @code{Stream_Element} is simply a byte. There are two ways to read or write a stream file. @itemize @bullet *************** dependence, GNAT handles file sharing as *** 9742,9756 **** @item In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt to open two or more files with the same full name is considered an error ! and is not supported. The exception @code{Use_Error} will be ! raised. Note that a file that is not explicitly closed by the program remains open until the program terminates. @item If the form parameter @samp{shared=no} appears in the form string, the file can be opened or created with its own separate stream identifier, regardless of whether other files sharing the same external file are ! opened. The exact effect depends on how the C stream routines handle multiple accesses to the same external files using separate streams. @item --- 9863,9877 ---- @item In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt to open two or more files with the same full name is considered an error ! and is not supported. The exception @code{Use_Error} will be ! raised. Note that a file that is not explicitly closed by the program remains open until the program terminates. @item If the form parameter @samp{shared=no} appears in the form string, the file can be opened or created with its own separate stream identifier, regardless of whether other files sharing the same external file are ! opened. The exact effect depends on how the C stream routines handle multiple accesses to the same external files using separate streams. @item *************** and @code{Create} calls as required. *** 9771,9788 **** When a program is ported from GNAT to some other Ada compiler, no special attention is required unless the @samp{shared=@var{xxx}} form ! parameter is used in the program. In this case, you must examine the documentation of the new compiler to see if it supports the required ! file sharing semantics, and form strings modified appropriately. Of course it may be the case that the program cannot be ported if the ! target compiler does not support the required functionality. The best approach in writing portable code is to avoid file sharing (and hence the use of the @samp{shared=@var{xxx}} parameter in the form string) completely. One common use of file sharing in Ada 83 is the use of instantiations of Sequential_IO on the same file with different types, to achieve ! heterogeneous input-output. Although this approach will work in GNAT if @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO for this purpose (using the stream attributes) --- 9892,9909 ---- When a program is ported from GNAT to some other Ada compiler, no special attention is required unless the @samp{shared=@var{xxx}} form ! parameter is used in the program. In this case, you must examine the documentation of the new compiler to see if it supports the required ! file sharing semantics, and form strings modified appropriately. Of course it may be the case that the program cannot be ported if the ! target compiler does not support the required functionality. The best approach in writing portable code is to avoid file sharing (and hence the use of the @samp{shared=@var{xxx}} parameter in the form string) completely. One common use of file sharing in Ada 83 is the use of instantiations of Sequential_IO on the same file with different types, to achieve ! heterogeneous input-output. Although this approach will work in GNAT if @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO for this purpose (using the stream attributes) *************** Inout_File "r+" *** 9805,9818 **** @end smallexample If text file translation is required, then either @samp{b} or @samp{t} ! is added to the mode, depending on the setting of Text. Text file translation refers to the mapping of CR/LF sequences in an external file ! to LF characters internally. This mapping only occurs in DOS and DOS-like systems, and is not relevant to other systems. ! A special case occurs with Stream_IO@. As shown in the above table, the file is initially opened in @samp{r} or @samp{w} mode for the ! @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation subsequently requires switching from reading to writing or vice-versa, then the file is reopened in @samp{r+} mode to permit the required operation. --- 9926,9939 ---- @end smallexample If text file translation is required, then either @samp{b} or @samp{t} ! is added to the mode, depending on the setting of Text. Text file translation refers to the mapping of CR/LF sequences in an external file ! to LF characters internally. This mapping only occurs in DOS and DOS-like systems, and is not relevant to other systems. ! A special case occurs with Stream_IO@. As shown in the above table, the file is initially opened in @samp{r} or @samp{w} mode for the ! @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation subsequently requires switching from reading to writing or vice-versa, then the file is reopened in @samp{r+} mode to permit the required operation. *************** package Interfaces.C_Streams is *** 9836,9843 **** subtype long is Long_Integer; -- Note: the above types are subtypes deliberately, and it -- is part of this spec that the above correspondences are ! -- guaranteed. This means that it is legitimate to, for ! -- example, use Integer instead of int. We provide these -- synonyms for clarity, but in some cases it may be -- convenient to use the underlying types (for example to -- avoid an unnecessary dependency of a spec on the spec --- 9957,9964 ---- subtype long is Long_Integer; -- Note: the above types are subtypes deliberately, and it -- is part of this spec that the above correspondences are ! -- guaranteed. This means that it is legitimate to, for ! -- example, use Integer instead of int. We provide these -- synonyms for clarity, but in some cases it may be -- convenient to use the underlying types (for example to -- avoid an unnecessary dependency of a spec on the spec *************** package Interfaces.C_Streams is *** 9869,9876 **** -------------------------- -- The functions selected below are ones that are -- available in DOS, OS/2, UNIX and Xenix (but not ! -- necessarily in ANSI C). These are very thin interfaces ! -- which copy exactly the C headers. For more -- documentation on these functions, see the Microsoft C -- "Run-Time Library Reference" (Microsoft Press, 1990, -- ISBN 1-55615-225-6), which includes useful information --- 9990,9997 ---- -------------------------- -- The functions selected below are ones that are -- available in DOS, OS/2, UNIX and Xenix (but not ! -- necessarily in ANSI C). These are very thin interfaces ! -- which copy exactly the C headers. For more -- documentation on these functions, see the Microsoft C -- "Run-Time Library Reference" (Microsoft Press, 1990, -- ISBN 1-55615-225-6), which includes useful information *************** package Interfaces.C_Streams is *** 9890,9896 **** -- Note: to maintain target independence, use -- text_translation_required, a boolean variable defined in -- a-sysdep.c to deal with the target dependent text ! -- translation requirement. If this variable is set, -- then b/t should be appended to the standard mode -- argument to set the text translation mode off or on -- as required. --- 10011,10017 ---- -- Note: to maintain target independence, use -- text_translation_required, a boolean variable defined in -- a-sysdep.c to deal with the target dependent text ! -- translation requirement. If this variable is set, -- then b/t should be appended to the standard mode -- argument to set the text translation mode off or on -- as required. *************** package Interfaces.C_Streams is *** 9939,9945 **** -- Extra functions -- --------------------- -- These functions supply slightly thicker bindings than ! -- those above. They are derived from functions in the -- C Run-Time Library, but may do a bit more work than -- just directly calling one of the Library functions. function is_regular_file (handle : int) return int; --- 10060,10066 ---- -- Extra functions -- --------------------- -- These functions supply slightly thicker bindings than ! -- those above. They are derived from functions in the -- C Run-Time Library, but may do a bit more work than -- just directly calling one of the Library functions. function is_regular_file (handle : int) return int; *************** package Interfaces.C_Streams is *** 9950,9958 **** --------------------------------- -- If text_translation_required is true, then the following -- functions may be used to dynamically switch a file from ! -- binary to text mode or vice versa. These functions have ! -- no effect if text_translation_required is false (i.e. in ! -- normal UNIX mode). Use fileno to get a stream handle. procedure set_binary_mode (handle : int); procedure set_text_mode (handle : int); ---------------------------- --- 10071,10079 ---- --------------------------------- -- If text_translation_required is true, then the following -- functions may be used to dynamically switch a file from ! -- binary to text mode or vice versa. These functions have ! -- no effect if text_translation_required is false (i.e. in ! -- normal UNIX mode). Use fileno to get a stream handle. procedure set_binary_mode (handle : int); procedure set_text_mode (handle : int); ---------------------------- *************** package Interfaces.C_Streams is *** 9963,9971 **** -- name, returns in buffer a NUL terminated string -- representing the full path name for the file name. -- On systems where it is relevant the drive is also ! -- part of the full path name. It is the responsibility -- of the caller to pass an actual parameter for buffer ! -- that is big enough for any full path name. Use -- max_path_len given below as the size of buffer. max_path_len : integer; -- Maximum length of an allowable full path name on the --- 10084,10092 ---- -- name, returns in buffer a NUL terminated string -- representing the full path name for the file name. -- On systems where it is relevant the drive is also ! -- part of the full path name. It is the responsibility -- of the caller to pass an actual parameter for buffer ! -- that is big enough for any full path name. Use -- max_path_len given below as the size of buffer. max_path_len : integer; -- Maximum length of an allowable full path name on the *************** operations. *** 10038,10056 **** @end smallexample In each of these five packages, the @code{C_Stream} function obtains the ! @code{FILE} pointer from a currently opened Ada file. It is then possible to use the @code{Interfaces.C_Streams} package to operate on this stream, or the stream can be passed to a C program which can ! operate on it directly. Of course the program is responsible for ensuring that only appropriate sequences of operations are executed. One particular use of relevance to an Ada program is that the @code{setvbuf} function can be used to control the buffering of the ! stream used by an Ada file. In the absence of such a call the standard default buffering is used. The @code{Open} procedures in these packages open a file giving an ! existing C Stream instead of a file name. Typically this stream is imported from a C program, allowing an Ada file to operate on an existing C file. --- 10159,10177 ---- @end smallexample In each of these five packages, the @code{C_Stream} function obtains the ! @code{FILE} pointer from a currently opened Ada file. It is then possible to use the @code{Interfaces.C_Streams} package to operate on this stream, or the stream can be passed to a C program which can ! operate on it directly. Of course the program is responsible for ensuring that only appropriate sequences of operations are executed. One particular use of relevance to an Ada program is that the @code{setvbuf} function can be used to control the buffering of the ! stream used by an Ada file. In the absence of such a call the standard default buffering is used. The @code{Open} procedures in these packages open a file giving an ! existing C Stream instead of a file name. Typically this stream is imported from a C program, allowing an Ada file to operate on an existing C file. *************** existing C file. *** 10060,10080 **** @noindent The GNAT library contains a number of general and special purpose packages. It represents functionality that the GNAT developers have found useful, and ! which is made available to GNAT users. The packages described here are fully supported, and upwards compatibility will be maintained in future releases, so you can use these facilities with the confidence that the same functionality will be available in future releases. The chapter here simply gives a brief summary of the facilities available. ! The full documentation is found in the spec file for the package. The full sources of these library packages, including both spec and body, are provided ! with all GNAT releases. For example, to find out the full specifications of the SPITBOL pattern matching capability, including a full tutorial and ! extensive examples, look in the g-spipat.ads file in the library. For each entry here, the package name (as it would appear in a @code{with} clause) is given, followed by the name of the corresponding spec file in ! parentheses. The packages are children in four hierarchies, @code{Ada}, @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a GNAT-specific hierarchy. --- 10181,10201 ---- @noindent The GNAT library contains a number of general and special purpose packages. It represents functionality that the GNAT developers have found useful, and ! which is made available to GNAT users. The packages described here are fully supported, and upwards compatibility will be maintained in future releases, so you can use these facilities with the confidence that the same functionality will be available in future releases. The chapter here simply gives a brief summary of the facilities available. ! The full documentation is found in the spec file for the package. The full sources of these library packages, including both spec and body, are provided ! with all GNAT releases. For example, to find out the full specifications of the SPITBOL pattern matching capability, including a full tutorial and ! extensive examples, look in the @file{g-spipat.ads} file in the library. For each entry here, the package name (as it would appear in a @code{with} clause) is given, followed by the name of the corresponding spec file in ! parentheses. The packages are children in four hierarchies, @code{Ada}, @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a GNAT-specific hierarchy. *************** Note that an application program should *** 10082,10094 **** four hierarchies if the package is defined in the Ada Reference Manual, or is listed in this section of the GNAT Programmers Reference Manual. All other units should be considered internal implementation units and ! should not be directly @code{with}'ed by application code. The use of a @code{with} statement that references one of these internal implementation units makes an application potentially dependent on changes in versions of GNAT, and will generate a warning message. @menu * Ada.Characters.Wide_Latin_1 (a-cwila1.ads):: * Ada.Command_Line.Remove (a-colire.ads):: * Ada.Direct_IO.C_Streams (a-diocst.ads):: * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads):: --- 10203,10217 ---- four hierarchies if the package is defined in the Ada Reference Manual, or is listed in this section of the GNAT Programmers Reference Manual. All other units should be considered internal implementation units and ! should not be directly @code{with}'ed by application code. The use of a @code{with} statement that references one of these internal implementation units makes an application potentially dependent on changes in versions of GNAT, and will generate a warning message. @menu + * Ada.Characters.Latin_9 (a-chlat9.ads):: * Ada.Characters.Wide_Latin_1 (a-cwila1.ads):: + * Ada.Characters.Wide_Latin_9 (a-cwila9.ads):: * Ada.Command_Line.Remove (a-colire.ads):: * Ada.Direct_IO.C_Streams (a-diocst.ads):: * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads):: *************** of GNAT, and will generate a warning mes *** 10123,10128 **** --- 10246,10252 ---- * GNAT.IO (g-io.ads):: * GNAT.IO_Aux (g-io_aux.ads):: * GNAT.Lock_Files (g-locfil.ads):: + * GNAT.MD5 (g-md5.ads):: * GNAT.Most_Recent_Exception (g-moreex.ads):: * GNAT.OS_Lib (g-os_lib.ads):: * GNAT.Regexp (g-regexp.ads):: *************** of GNAT, and will generate a warning mes *** 10150,10155 **** --- 10274,10280 ---- * Interfaces.Os2lib.Threads (i-os2thr.ads):: * Interfaces.Packed_Decimal (i-pacdec.ads):: * Interfaces.VxWorks (i-vxwork.ads):: + * Interfaces.VxWorks.IO (i-vxwoio.ads):: * System.Address_Image (s-addima.ads):: * System.Assertions (s-assert.ads):: * System.Partition_Interface (s-parint.ads):: *************** of GNAT, and will generate a warning mes *** 10158,10205 **** * System.Wch_Con (s-wchcon.ads):: @end menu @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads) ! @section Ada.Characters.Wide_Latin_1 (a-cwila1.ads) ! @cindex Ada.Characters.Wide_Latin_1 (a-cwila1.ads) ! @cindex Latin_1 constants for Wide_Character @noindent This child of @code{Ada.Characters} provides a set of definitions corresponding to those in the RM-defined package @code{Ada.Characters.Latin_1} but with the types of the constants being @code{Wide_Character} ! instead of @code{Character}. The provision of such a package is specifically authorized by the Ada Reference Manual (RM A.3(27)). @node Ada.Command_Line.Remove (a-colire.ads) ! @section Ada.Command_Line.Remove (a-colire.ads) ! @cindex Ada.Command_Line.Remove (a-colire.ads) ! @cindex Removing command line arguments ! @cindex Command line, argument removal @noindent This child of @code{Ada.Command_Line} provides a mechanism for logically removing ! arguments from the argument list. Once removed, an argument is not visible to further calls on the subprograms in @code{Ada.Command_Line} will not see the removed argument. @node Ada.Direct_IO.C_Streams (a-diocst.ads) ! @section Ada.Direct_IO.C_Streams (a-diocst.ads) ! @cindex Ada.Direct_IO.C_Streams (a-diocst.ads) ! @cindex C Streams, Interfacing with Direct_IO @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Direct_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads) ! @section Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads) ! @cindex Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads) ! @cindex Null_Occurrence, testing for @noindent This child subprogram provides a way of testing for the null --- 10283,10358 ---- * System.Wch_Con (s-wchcon.ads):: @end menu + @node Ada.Characters.Latin_9 (a-chlat9.ads) + @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads}) + @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads}) + @cindex Latin_9 constants for Character + + @noindent + This child of @code{Ada.Characters} + provides a set of definitions corresponding to those in the + RM-defined package @code{Ada.Characters.Latin_1} but with the + few modifications required for @code{Latin-9} + The provision of such a package + is specifically authorized by the Ada Reference Manual + (RM A.3(27)). + @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads) ! @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads}) ! @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads}) ! @cindex Latin_1 constants for Wide_Character @noindent This child of @code{Ada.Characters} provides a set of definitions corresponding to those in the RM-defined package @code{Ada.Characters.Latin_1} but with the types of the constants being @code{Wide_Character} ! instead of @code{Character}. The provision of such a package ! is specifically authorized by the Ada Reference Manual ! (RM A.3(27)). ! ! @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads) ! @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads}) ! @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads}) ! @cindex Latin_9 constants for Wide_Character ! ! @noindent ! This child of @code{Ada.Characters} ! provides a set of definitions corresponding to those in the ! GNAT defined package @code{Ada.Characters.Latin_9} but with the ! types of the constants being @code{Wide_Character} ! instead of @code{Character}. The provision of such a package is specifically authorized by the Ada Reference Manual (RM A.3(27)). @node Ada.Command_Line.Remove (a-colire.ads) ! @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads}) ! @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads}) ! @cindex Removing command line arguments ! @cindex Command line, argument removal @noindent This child of @code{Ada.Command_Line} provides a mechanism for logically removing ! arguments from the argument list. Once removed, an argument is not visible to further calls on the subprograms in @code{Ada.Command_Line} will not see the removed argument. @node Ada.Direct_IO.C_Streams (a-diocst.ads) ! @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads}) ! @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads}) ! @cindex C Streams, Interfacing with Direct_IO @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Direct_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads) ! @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads}) ! @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads}) ! @cindex Null_Occurrence, testing for @noindent This child subprogram provides a way of testing for the null *************** exception occurrence (@code{Null_Occurre *** 10207,10238 **** an exception. @node Ada.Sequential_IO.C_Streams (a-siocst.ads) ! @section Ada.Sequential_IO.C_Streams (a-siocst.ads) ! @cindex Ada.Sequential_IO.C_Streams (a-siocst.ads) ! @cindex C Streams, Interfacing with Sequential_IO @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Sequential_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads) ! @section Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads) ! @cindex Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads) ! @cindex C Streams, Interfacing with Stream_IO @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Stream_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads) ! @section Ada.Strings.Unbounded.Text_IO (a-suteio.ads) ! @cindex Ada.Strings.Unbounded.Text_IO (a-suteio.ads) ! @cindex Unbounded_String, IO support ! @cindex Text_IO, extensions for unbounded strings @noindent This package provides subprograms for Text_IO for unbounded --- 10360,10391 ---- an exception. @node Ada.Sequential_IO.C_Streams (a-siocst.ads) ! @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads}) ! @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads}) ! @cindex C Streams, Interfacing with Sequential_IO @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Sequential_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads) ! @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads}) ! @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads}) ! @cindex C Streams, Interfacing with Stream_IO @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Stream_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads) ! @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads}) ! @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads}) ! @cindex @code{Unbounded_String}, IO support ! @cindex @code{Text_IO}, extensions for unbounded strings @noindent This package provides subprograms for Text_IO for unbounded *************** strings, avoiding the necessity for an i *** 10240,10249 **** with ordinary strings. @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads) ! @section Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads) ! @cindex Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads) ! @cindex Unbounded_Wide_String, IO support ! @cindex Text_IO, extensions for unbounded wide strings @noindent This package provides subprograms for Text_IO for unbounded --- 10393,10402 ---- with ordinary strings. @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads) ! @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads}) ! @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads}) ! @cindex @code{Unbounded_Wide_String}, IO support ! @cindex @code{Text_IO}, extensions for unbounded wide strings @noindent This package provides subprograms for Text_IO for unbounded *************** wide strings, avoiding the necessity for *** 10251,10301 **** with ordinary wide strings. @node Ada.Text_IO.C_Streams (a-tiocst.ads) ! @section Ada.Text_IO.C_Streams (a-tiocst.ads) ! @cindex Ada.Text_IO.C_Streams (a-tiocst.ads) ! @cindex C Streams, Interfacing with Text_IO @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Text_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads) ! @section Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads) ! @cindex Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads) ! @cindex C Streams, Interfacing with Wide_Text_IO @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Wide_Text_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node GNAT.AWK (g-awk.ads) ! @section GNAT.AWK (g-awk.ads) ! @cindex GNAT.AWK (g-awk.ads) @cindex Parsing @noindent Provides AWK-like parsing functions, with an easy interface for parsing one ! or more files containing formatted data. The file is viewed as a database where each record is a line and a field is a data element in this line. @node GNAT.Bubble_Sort_A (g-busora.ads) ! @section GNAT.Bubble_Sort_A (g-busora.ads) ! @cindex GNAT.Bubble_Sort_A (g-busora.ads) @cindex Sorting @noindent Provides a general implementation of bubble sort usable for sorting arbitrary ! data items. Move and comparison procedures are provided by passing access-to-procedure values. @node GNAT.Bubble_Sort_G (g-busorg.ads) ! @section GNAT.Bubble_Sort_G (g-busorg.ads) ! @cindex GNAT.Bubble_Sort_G (g-busorg.ads) @cindex Sorting @noindent Similar to @code{Bubble_Sort_A} except that the move and sorting procedures --- 10404,10457 ---- with ordinary wide strings. @node Ada.Text_IO.C_Streams (a-tiocst.ads) ! @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads}) ! @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads}) ! @cindex C Streams, Interfacing with @code{Text_IO} @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Text_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads) ! @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads}) ! @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads}) ! @cindex C Streams, Interfacing with @code{Wide_Text_IO} @noindent This package provides subprograms that allow interfacing between ! C streams and @code{Wide_Text_IO}. The stream identifier can be extracted from a file opened on the Ada side, and an Ada file can be constructed from a stream opened on the C side. @node GNAT.AWK (g-awk.ads) ! @section @code{GNAT.AWK} (@file{g-awk.ads}) ! @cindex @code{GNAT.AWK} (@file{g-awk.ads}) @cindex Parsing + @cindex AWK @noindent Provides AWK-like parsing functions, with an easy interface for parsing one ! or more files containing formatted data. The file is viewed as a database where each record is a line and a field is a data element in this line. @node GNAT.Bubble_Sort_A (g-busora.ads) ! @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads}) ! @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads}) @cindex Sorting + @cindex Bubble sort @noindent Provides a general implementation of bubble sort usable for sorting arbitrary ! data items. Move and comparison procedures are provided by passing access-to-procedure values. @node GNAT.Bubble_Sort_G (g-busorg.ads) ! @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads}) ! @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads}) @cindex Sorting + @cindex Bubble sort @noindent Similar to @code{Bubble_Sort_A} except that the move and sorting procedures *************** if the procedures can be inlined, at the *** 10304,10312 **** multiple instantiations. @node GNAT.Calendar (g-calend.ads) ! @section GNAT.Calendar (g-calend.ads) ! @cindex GNAT.Calendar (g-calend.ads) ! @cindex Calendar @noindent Extends the facilities provided by @code{Ada.Calendar} to include handling --- 10460,10468 ---- multiple instantiations. @node GNAT.Calendar (g-calend.ads) ! @section @code{GNAT.Calendar} (@file{g-calend.ads}) ! @cindex @code{GNAT.Calendar} (@file{g-calend.ads}) ! @cindex @code{Calendar} @noindent Extends the facilities provided by @code{Ada.Calendar} to include handling *************** Also provides conversion of @code{Ada.Ca *** 10315,10344 **** C @code{timeval} format. @node GNAT.Calendar.Time_IO (g-catiio.ads) ! @section GNAT.Calendar.Time_IO (g-catiio.ads) ! @cindex Calendar @cindex Time ! @cindex GNAT.Calendar.Time_IO (g-catiio.ads) @node GNAT.CRC32 (g-crc32.ads) ! @section GNAT.CRC32 (g-crc32.ads) ! @cindex GNAT.CRC32 (g-crc32.ads) @cindex CRC32 @noindent ! This package implements the CRC-32 algorithm. For a full description of this algorithm you should have a look at: ! "Computation of Cyclic Redundancy Checks via Table Look-Up", Communications ! of the ACM, Vol.@: 31 No.@: 8, pp.1008-1013 Aug.@: 1988. Sarwate, D.V@. @noindent Provides an extended capability for formatted output of time values with ! full user control over the format. Modeled on the GNU Date specification. @node GNAT.Case_Util (g-casuti.ads) ! @section GNAT.Case_Util (g-casuti.ads) ! @cindex GNAT.Case_Util (g-casuti.ads) @cindex Casing utilities @noindent A set of simple routines for handling upper and lower casing of strings --- 10471,10502 ---- C @code{timeval} format. @node GNAT.Calendar.Time_IO (g-catiio.ads) ! @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads}) ! @cindex @code{Calendar} @cindex Time ! @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads}) @node GNAT.CRC32 (g-crc32.ads) ! @section @code{GNAT.CRC32} (@file{g-crc32.ads}) ! @cindex @code{GNAT.CRC32} (@file{g-crc32.ads}) @cindex CRC32 + @cindex Cyclic Redundancy Check @noindent ! This package implements the CRC-32 algorithm. For a full description of this algorithm you should have a look at: ! ``Computation of Cyclic Redundancy Checks via Table Look-Up'', @cite{Communications ! of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013, Aug.@: 1988. Sarwate, D.V@. @noindent Provides an extended capability for formatted output of time values with ! full user control over the format. Modeled on the GNU Date specification. @node GNAT.Case_Util (g-casuti.ads) ! @section @code{GNAT.Case_Util} (@file{g-casuti.ads}) ! @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads}) @cindex Casing utilities + @cindex Character handling (@code{GNAT.Case_Util}) @noindent A set of simple routines for handling upper and lower casing of strings *************** without the overhead of the full casing *** 10346,10375 **** in @code{Ada.Characters.Handling}. @node GNAT.CGI (g-cgi.ads) ! @section GNAT.CGI (g-cgi.ads) ! @cindex GNAT.CGI (g-cgi.ads) @cindex CGI (Common Gateway Interface) @noindent This is a package for interfacing a GNAT program with a Web server via the ! Common Gateway Interface (CGI). Basically this package parse the CGI ! parameters which are a set of key/value pairs sent by the Web server. It builds a table whose index is the key and provides some services to deal with this table. @node GNAT.CGI.Cookie (g-cgicoo.ads) ! @section GNAT.CGI.Cookie (g-cgicoo.ads) ! @cindex GNAT.CGI.Cookie (g-cgicoo.ads) ! @cindex CGI (Common Gateway Interface) Cookie support @noindent This is a package to interface a GNAT program with a Web server via the ! Common Gateway Interface (CGI). It exports services to deal with Web cookies (piece of information kept in the Web client software). @node GNAT.CGI.Debug (g-cgideb.ads) ! @section GNAT.CGI.Debug (g-cgideb.ads) ! @cindex GNAT.CGI.Debug (g-cgideb.ads) @cindex CGI (Common Gateway Interface) debugging @noindent --- 10504,10534 ---- in @code{Ada.Characters.Handling}. @node GNAT.CGI (g-cgi.ads) ! @section @code{GNAT.CGI} (@file{g-cgi.ads}) ! @cindex @code{GNAT.CGI} (@file{g-cgi.ads}) @cindex CGI (Common Gateway Interface) @noindent This is a package for interfacing a GNAT program with a Web server via the ! Common Gateway Interface (CGI)@. Basically this package parses the CGI ! parameters, which are a set of key/value pairs sent by the Web server. It builds a table whose index is the key and provides some services to deal with this table. @node GNAT.CGI.Cookie (g-cgicoo.ads) ! @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads}) ! @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads}) ! @cindex CGI (Common Gateway Interface) cookie support ! @cindex Cookie support in CGI @noindent This is a package to interface a GNAT program with a Web server via the ! Common Gateway Interface (CGI). It exports services to deal with Web cookies (piece of information kept in the Web client software). @node GNAT.CGI.Debug (g-cgideb.ads) ! @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads}) ! @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads}) @cindex CGI (Common Gateway Interface) debugging @noindent *************** This is a package to help debugging CGI *** 10377,10384 **** programs written in Ada. @node GNAT.Command_Line (g-comlin.ads) ! @section GNAT.Command_Line (g-comlin.ads) ! @cindex GNAT.Command_Line (g-comlin.ads) @cindex Command line @noindent --- 10536,10543 ---- programs written in Ada. @node GNAT.Command_Line (g-comlin.ads) ! @section @code{GNAT.Command_Line} (@file{g-comlin.ads}) ! @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads}) @cindex Command line @noindent *************** including the ability to scan for named *** 10387,10416 **** and expand file names using wild card notations. @node GNAT.Current_Exception (g-curexc.ads) ! @section GNAT.Current_Exception (g-curexc.ads) ! @cindex GNAT.Current_Exception (g-curexc.ads) @cindex Current exception @cindex Exception retrieval @noindent Provides access to information on the current exception that has been raised without the need for using the Ada-95 exception choice parameter specification ! syntax. This is particularly useful in mimicking typical facilities for obtaining information about exceptions provided by Ada 83 compilers. @node GNAT.Debug_Pools (g-debpoo.ads) ! @section GNAT.Debug_Pools (g-debpoo.ads) ! @cindex GNAT.Debug_Pools (g-debpoo.ads) @cindex Debugging @noindent Provide a debugging storage pools that helps tracking memory corruption ! problems. See section "Finding memory problems with GNAT Debug Pool" in ! the GNAT User's guide. @node GNAT.Debug_Utilities (g-debuti.ads) ! @section GNAT.Debug_Utilities (g-debuti.ads) ! @cindex GNAT.Debug_Utilities (g-debuti.ads) @cindex Debugging @noindent --- 10546,10577 ---- and expand file names using wild card notations. @node GNAT.Current_Exception (g-curexc.ads) ! @section @code{GNAT.Current_Exception} (@file{g-curexc.ads}) ! @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads}) @cindex Current exception @cindex Exception retrieval @noindent Provides access to information on the current exception that has been raised without the need for using the Ada-95 exception choice parameter specification ! syntax. This is particularly useful in simulating typical facilities for obtaining information about exceptions provided by Ada 83 compilers. @node GNAT.Debug_Pools (g-debpoo.ads) ! @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads}) ! @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads}) @cindex Debugging + @cindex Debug pools + @cindex Memory corruption debugging @noindent Provide a debugging storage pools that helps tracking memory corruption ! problems. See section ``Finding memory problems with GNAT Debug Pool'' in ! the @cite{GNAT User's Guide}. @node GNAT.Debug_Utilities (g-debuti.ads) ! @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads}) ! @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads}) @cindex Debugging @noindent *************** Provides a few useful utilities for debu *** 10418,10425 **** to and from string images of address values. @node GNAT.Directory_Operations (g-dirope.ads) ! @section GNAT.Directory_Operations (g-dirope.ads) ! @cindex GNAT.Directory_Operations (g-dirope.ads) @cindex Directory operations @noindent --- 10579,10586 ---- to and from string images of address values. @node GNAT.Directory_Operations (g-dirope.ads) ! @section @code{GNAT.Directory_Operations} (g-dirope.ads) ! @cindex @code{GNAT.Directory_Operations} (g-dirope.ads) @cindex Directory operations @noindent *************** the current directory, making new direct *** 10428,10435 **** directory. @node GNAT.Dynamic_Tables (g-dyntab.ads) ! @section GNAT.Dynamic_Tables (g-dyntab.ads) ! @cindex GNAT.Dynamic_Tables (g-dyntab.ads) @cindex Table implementation @cindex Arrays, extendable --- 10589,10596 ---- directory. @node GNAT.Dynamic_Tables (g-dyntab.ads) ! @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads}) ! @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads}) @cindex Table implementation @cindex Arrays, extendable *************** instances of the table, while an instant *** 10444,10451 **** single instance of the table type. @node GNAT.Exception_Traces (g-exctra.ads) ! @section GNAT.Exception_Traces (g-exctra.ads) ! @cindex GNAT.Exception_Traces (g-exctra.ads) @cindex Exception traces @cindex Debugging --- 10605,10612 ---- single instance of the table type. @node GNAT.Exception_Traces (g-exctra.ads) ! @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads}) ! @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads}) @cindex Exception traces @cindex Debugging *************** Provides an interface allowing to contro *** 10454,10461 **** occurrences. @node GNAT.Expect (g-expect.ads) ! @section GNAT.Expect (g-expect.ads) ! @cindex GNAT.Expect (g-expect.ads) @noindent Provides a set of subprograms similar to what is available --- 10615,10622 ---- occurrences. @node GNAT.Expect (g-expect.ads) ! @section @code{GNAT.Expect} (@file{g-expect.ads}) ! @cindex @code{GNAT.Expect} (@file{g-expect.ads}) @noindent Provides a set of subprograms similar to what is available *************** It allows you to easily spawn and commun *** 10464,10497 **** You can send commands or inputs to the process, and compare the output with some expected regular expression. Currently GNAT.Expect is implemented on all native GNAT ports except for ! OpenVMS@. It is not implemented for cross ports, and in particular is not implemented for VxWorks or LynxOS@. @node GNAT.Float_Control (g-flocon.ads) ! @section GNAT.Float_Control (g-flocon.ads) ! @cindex GNAT.Float_Control (g-flocon.ads) @cindex Floating-Point Processor @noindent Provides an interface for resetting the floating-point processor into the ! mode required for correct semantic operation in Ada. Some third party library calls may cause this mode to be modified, and the Reset procedure in this package can be used to reestablish the required mode. @node GNAT.Heap_Sort_A (g-hesora.ads) ! @section GNAT.Heap_Sort_A (g-hesora.ads) ! @cindex GNAT.Heap_Sort_A (g-hesora.ads) @cindex Sorting @noindent Provides a general implementation of heap sort usable for sorting arbitrary ! data items. Move and comparison procedures are provided by passing ! access-to-procedure values. The algorithm used is a modified heap sort that performs approximately N*log(N) comparisons in the worst case. @node GNAT.Heap_Sort_G (g-hesorg.ads) ! @section GNAT.Heap_Sort_G (g-hesorg.ads) ! @cindex GNAT.Heap_Sort_G (g-hesorg.ads) @cindex Sorting @noindent --- 10625,10658 ---- You can send commands or inputs to the process, and compare the output with some expected regular expression. Currently GNAT.Expect is implemented on all native GNAT ports except for ! OpenVMS@. It is not implemented for cross ports, and in particular is not implemented for VxWorks or LynxOS@. @node GNAT.Float_Control (g-flocon.ads) ! @section @code{GNAT.Float_Control} (@file{g-flocon.ads}) ! @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads}) @cindex Floating-Point Processor @noindent Provides an interface for resetting the floating-point processor into the ! mode required for correct semantic operation in Ada. Some third party library calls may cause this mode to be modified, and the Reset procedure in this package can be used to reestablish the required mode. @node GNAT.Heap_Sort_A (g-hesora.ads) ! @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads}) ! @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads}) @cindex Sorting @noindent Provides a general implementation of heap sort usable for sorting arbitrary ! data items. Move and comparison procedures are provided by passing ! access-to-procedure values. The algorithm used is a modified heap sort that performs approximately N*log(N) comparisons in the worst case. @node GNAT.Heap_Sort_G (g-hesorg.ads) ! @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads}) ! @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads}) @cindex Sorting @noindent *************** if the procedures can be inlined, at the *** 10501,10518 **** multiple instantiations. @node GNAT.HTable (g-htable.ads) ! @section GNAT.HTable (g-htable.ads) ! @cindex GNAT.HTable (g-htable.ads) @cindex Hash tables @noindent A generic implementation of hash tables that can be used to hash arbitrary ! data. Provides two approaches, one a simple static approach, and the other allowing arbitrary dynamic hash tables. @node GNAT.IO (g-io.ads) ! @section GNAT.IO (g-io.ads) ! @cindex GNAT.IO (g-io.ads) @cindex Simple I/O @cindex Input/Output facilities --- 10662,10679 ---- multiple instantiations. @node GNAT.HTable (g-htable.ads) ! @section @code{GNAT.HTable} (@file{g-htable.ads}) ! @cindex @code{GNAT.HTable} (@file{g-htable.ads}) @cindex Hash tables @noindent A generic implementation of hash tables that can be used to hash arbitrary ! data. Provides two approaches, one a simple static approach, and the other allowing arbitrary dynamic hash tables. @node GNAT.IO (g-io.ads) ! @section @code{GNAT.IO} (@file{g-io.ads}) ! @cindex @code{GNAT.IO} (@file{g-io.ads}) @cindex Simple I/O @cindex Input/Output facilities *************** Standard_Input, and writing characters, *** 10523,10530 **** Standard_Output or Standard_Error. @node GNAT.IO_Aux (g-io_aux.ads) ! @section GNAT.IO_Aux (g-io_aux.ads) ! @cindex GNAT.IO_Aux (g-io_aux.ads) @cindex Text_IO @cindex Input/Output facilities --- 10684,10691 ---- Standard_Output or Standard_Error. @node GNAT.IO_Aux (g-io_aux.ads) ! @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads}) ! @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads}) @cindex Text_IO @cindex Input/Output facilities *************** Provides some auxiliary functions for us *** 10532,10559 **** for whether a file exists, and functions for reading a line of text. @node GNAT.Lock_Files (g-locfil.ads) ! @section GNAT.Lock_Files (g-locfil.ads) ! @cindex GNAT.Lock_Files (g-locfil.ads) @cindex File locking @cindex Locking using files @noindent ! Provides a general interface for using files as locks. Can be used for providing program level synchronization. @node GNAT.Most_Recent_Exception (g-moreex.ads) ! @section GNAT.Most_Recent_Exception (g-moreex.ads) ! @cindex GNAT.Most_Recent_Exception (g-moreex.ads) @cindex Exception, obtaining most recent @noindent ! Provides access to the most recently raised exception. Can be used for various logging purposes, including duplicating functionality of some Ada 83 implementation dependent extensions. @node GNAT.OS_Lib (g-os_lib.ads) ! @section GNAT.OS_Lib (g-os_lib.ads) ! @cindex GNAT.OS_Lib (g-os_lib.ads) @cindex Operating System interface @cindex Spawn capability --- 10693,10728 ---- for whether a file exists, and functions for reading a line of text. @node GNAT.Lock_Files (g-locfil.ads) ! @section @code{GNAT.Lock_Files} (@file{g-locfil.ads}) ! @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads}) @cindex File locking @cindex Locking using files @noindent ! Provides a general interface for using files as locks. Can be used for providing program level synchronization. + @node GNAT.MD5 (g-md5.ads) + @section @code{GNAT.MD5} (@file{g-md5.ads}) + @cindex @code{GNAT.MD5} (@file{g-md5.ads}) + @cindex Message Digest MD5 + + @noindent + Implements the MD5 Message-Digest Algorithm as described in RFC 1321. + @node GNAT.Most_Recent_Exception (g-moreex.ads) ! @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads}) ! @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads}) @cindex Exception, obtaining most recent @noindent ! Provides access to the most recently raised exception. Can be used for various logging purposes, including duplicating functionality of some Ada 83 implementation dependent extensions. @node GNAT.OS_Lib (g-os_lib.ads) ! @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads}) ! @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads}) @cindex Operating System interface @cindex Spawn capability *************** including a portable spawn procedure, an *** 10564,10594 **** and error return codes. @node GNAT.Regexp (g-regexp.ads) ! @section GNAT.Regexp (g-regexp.ads) ! @cindex GNAT.Regexp (g-regexp.ads) @cindex Regular expressions @cindex Pattern matching @noindent A simple implementation of regular expressions, using a subset of regular ! expression syntax copied from familiar Unix style utilities. This is the simples of the three pattern matching packages provided, and is particularly ! suitable for "file globbing" applications. @node GNAT.Registry (g-regist.ads) ! @section GNAT.Registry (g-regist.ads) ! @cindex GNAT.Registry (g-regist.ads) @cindex Windows Registry @noindent ! This is a high level binding to the Windows registry. It is possible to ! do simple things like reading a key value, creating a new key. For full registry API, but at a lower level of abstraction, refer to the Win32.Winreg package provided with the Win32Ada binding @node GNAT.Regpat (g-regpat.ads) ! @section GNAT.Regpat (g-regpat.ads) ! @cindex GNAT.Regpat (g-regpat.ads) @cindex Regular expressions @cindex Pattern matching --- 10733,10763 ---- and error return codes. @node GNAT.Regexp (g-regexp.ads) ! @section @code{GNAT.Regexp} (@file{g-regexp.ads}) ! @cindex @code{GNAT.Regexp} (@file{g-regexp.ads}) @cindex Regular expressions @cindex Pattern matching @noindent A simple implementation of regular expressions, using a subset of regular ! expression syntax copied from familiar Unix style utilities. This is the simples of the three pattern matching packages provided, and is particularly ! suitable for ``file globbing'' applications. @node GNAT.Registry (g-regist.ads) ! @section @code{GNAT.Registry} (@file{g-regist.ads}) ! @cindex @code{GNAT.Registry} (@file{g-regist.ads}) @cindex Windows Registry @noindent ! This is a high level binding to the Windows registry. It is possible to ! do simple things like reading a key value, creating a new key. For full registry API, but at a lower level of abstraction, refer to the Win32.Winreg package provided with the Win32Ada binding @node GNAT.Regpat (g-regpat.ads) ! @section @code{GNAT.Regpat} (@file{g-regpat.ads}) ! @cindex @code{GNAT.Regpat} (@file{g-regpat.ads}) @cindex Regular expressions @cindex Pattern matching *************** from the original V7 style regular expre *** 10598,10617 **** Henry Spencer (and binary compatible with this C library). @node GNAT.Sockets (g-socket.ads) ! @section GNAT.Sockets (g-socket.ads) ! @cindex GNAT.Sockets (g-socket.ads) @cindex Sockets @noindent A high level and portable interface to develop sockets based applications. This package is based on the sockets thin binding found in GNAT.Sockets.Thin. Currently GNAT.Sockets is implemented on all native GNAT ports except for ! OpenVMS@. It is not implemented for cross ports, and in particular is not ! implemented for VxWorks or LynxOS@. @node GNAT.Source_Info (g-souinf.ads) ! @section GNAT.Source_Info (g-souinf.ads) ! @cindex GNAT.Source_Info (g-souinf.ads) @cindex Source Information @noindent --- 10767,10785 ---- Henry Spencer (and binary compatible with this C library). @node GNAT.Sockets (g-socket.ads) ! @section @code{GNAT.Sockets} (@file{g-socket.ads}) ! @cindex @code{GNAT.Sockets} (@file{g-socket.ads}) @cindex Sockets @noindent A high level and portable interface to develop sockets based applications. This package is based on the sockets thin binding found in GNAT.Sockets.Thin. Currently GNAT.Sockets is implemented on all native GNAT ports except for ! OpenVMS@. It is not implemented for the LynxOS@ cross port. @node GNAT.Source_Info (g-souinf.ads) ! @section @code{GNAT.Source_Info} (@file{g-souinf.ads}) ! @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads}) @cindex Source Information @noindent *************** Provides subprograms that give access to *** 10619,10626 **** compile time, such as the current file name and line number. @node GNAT.Spell_Checker (g-speche.ads) ! @section GNAT.Spell_Checker (g-speche.ads) ! @cindex GNAT.Spell_Checker (g-speche.ads) @cindex Spell checking @noindent --- 10787,10794 ---- compile time, such as the current file name and line number. @node GNAT.Spell_Checker (g-speche.ads) ! @section @code{GNAT.Spell_Checker} (@file{g-speche.ads}) ! @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads}) @cindex Spell checking @noindent *************** Provides a function for determining whet *** 10628,10647 **** near misspelling of another string. @node GNAT.Spitbol.Patterns (g-spipat.ads) ! @section GNAT.Spitbol.Patterns (g-spipat.ads) ! @cindex GNAT.Spitbol.Patterns (g-spipat.ads) @cindex SPITBOL pattern matching @cindex Pattern matching @noindent ! A complete implementation of SNOBOL4 style pattern matching. This is the ! most elaborate of the pattern matching packages provided. It fully duplicates the SNOBOL4 dynamic pattern construction and matching capabilities, using the efficient algorithm developed by Robert Dewar for the SPITBOL system. @node GNAT.Spitbol (g-spitbo.ads) ! @section GNAT.Spitbol (g-spitbo.ads) ! @cindex GNAT.Spitbol (g-spitbo.ads) @cindex SPITBOL interface @noindent --- 10796,10815 ---- near misspelling of another string. @node GNAT.Spitbol.Patterns (g-spipat.ads) ! @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads}) ! @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads}) @cindex SPITBOL pattern matching @cindex Pattern matching @noindent ! A complete implementation of SNOBOL4 style pattern matching. This is the ! most elaborate of the pattern matching packages provided. It fully duplicates the SNOBOL4 dynamic pattern construction and matching capabilities, using the efficient algorithm developed by Robert Dewar for the SPITBOL system. @node GNAT.Spitbol (g-spitbo.ads) ! @section @code{GNAT.Spitbol} (@file{g-spitbo.ads}) ! @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads}) @cindex SPITBOL interface @noindent *************** useful for constructing arbitrary mappin *** 10652,10659 **** the SNOBOL4 TABLE function. @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads) ! @section GNAT.Spitbol.Table_Boolean (g-sptabo.ads) ! @cindex GNAT.Spitbol.Table_Boolean (g-sptabo.ads) @cindex Sets of strings @cindex SPITBOL Tables --- 10820,10827 ---- the SNOBOL4 TABLE function. @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads) ! @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads}) ! @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads}) @cindex Sets of strings @cindex SPITBOL Tables *************** for type @code{Standard.Boolean}, giving *** 10663,10670 **** string values. @node GNAT.Spitbol.Table_Integer (g-sptain.ads) ! @section GNAT.Spitbol.Table_Integer (g-sptain.ads) ! @cindex GNAT.Spitbol.Table_Integer (g-sptain.ads) @cindex Integer maps @cindex Maps @cindex SPITBOL Tables --- 10831,10838 ---- string values. @node GNAT.Spitbol.Table_Integer (g-sptain.ads) ! @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads}) ! @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads}) @cindex Integer maps @cindex Maps @cindex SPITBOL Tables *************** for type @code{Standard.Integer}, giving *** 10675,10682 **** from string to integer values. @node GNAT.Spitbol.Table_VString (g-sptavs.ads) ! @section GNAT.Spitbol.Table_VString (g-sptavs.ads) ! @cindex GNAT.Spitbol.Table_VString (g-sptavs.ads) @cindex String maps @cindex Maps @cindex SPITBOL Tables --- 10843,10850 ---- from string to integer values. @node GNAT.Spitbol.Table_VString (g-sptavs.ads) ! @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads}) ! @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads}) @cindex String maps @cindex Maps @cindex SPITBOL Tables *************** a variable length string type, giving an *** 10687,10694 **** maps from strings to strings. @node GNAT.Table (g-table.ads) ! @section GNAT.Table (g-table.ads) ! @cindex GNAT.Table (g-table.ads) @cindex Table implementation @cindex Arrays, extendable --- 10855,10862 ---- maps from strings to strings. @node GNAT.Table (g-table.ads) ! @section @code{GNAT.Table} (@file{g-table.ads}) ! @cindex @code{GNAT.Table} (@file{g-table.ads}) @cindex Table implementation @cindex Arrays, extendable *************** while an instantiation of GNAT.Dynamic_T *** 10703,10735 **** used to define dynamic instances of the table. @node GNAT.Task_Lock (g-tasloc.ads) ! @section GNAT.Task_Lock (g-tasloc.ads) ! @cindex GNAT.Task_Lock (g-tasloc.ads) @cindex Task synchronization @cindex Task locking @cindex Locking @noindent A very simple facility for locking and unlocking sections of code using a ! single global task lock. Appropriate for use in situations where contention between tasks is very rarely expected. @node GNAT.Threads (g-thread.ads) ! @section GNAT.Threads (g-thread.ads) ! @cindex GNAT.Threads (g-thread.ads) @cindex Foreign threads @cindex Threads, foreign @noindent Provides facilities for creating and destroying threads with explicit calls. ! These threads are known to the GNAT run-time system. These subprograms are exported C-convention procedures intended to be called from foreign code. By using these primitives rather than directly calling operating systems routines, compatibility with the Ada tasking runt-time is provided. @node GNAT.Traceback (g-traceb.ads) ! @section GNAT.Traceback (g-traceb.ads) ! @cindex GNAT.Traceback (g-traceb.ads) @cindex Trace back facilities @noindent --- 10871,10903 ---- used to define dynamic instances of the table. @node GNAT.Task_Lock (g-tasloc.ads) ! @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads}) ! @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads}) @cindex Task synchronization @cindex Task locking @cindex Locking @noindent A very simple facility for locking and unlocking sections of code using a ! single global task lock. Appropriate for use in situations where contention between tasks is very rarely expected. @node GNAT.Threads (g-thread.ads) ! @section @code{GNAT.Threads} (@file{g-thread.ads}) ! @cindex @code{GNAT.Threads} (@file{g-thread.ads}) @cindex Foreign threads @cindex Threads, foreign @noindent Provides facilities for creating and destroying threads with explicit calls. ! These threads are known to the GNAT run-time system. These subprograms are exported C-convention procedures intended to be called from foreign code. By using these primitives rather than directly calling operating systems routines, compatibility with the Ada tasking runt-time is provided. @node GNAT.Traceback (g-traceb.ads) ! @section @code{GNAT.Traceback} (@file{g-traceb.ads}) ! @cindex @code{GNAT.Traceback} (@file{g-traceb.ads}) @cindex Trace back facilities @noindent *************** Provides a facility for obtaining non-sy *** 10737,10744 **** in various debugging situations. @node GNAT.Traceback.Symbolic (g-trasym.ads) ! @section GNAT.Traceback.Symbolic (g-trasym.ads) ! @cindex GNAT.Traceback.Symbolic (g-trasym.ads) @cindex Trace back facilities @noindent --- 10905,10912 ---- in various debugging situations. @node GNAT.Traceback.Symbolic (g-trasym.ads) ! @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads}) ! @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads}) @cindex Trace back facilities @noindent *************** Provides symbolic traceback information *** 10746,10753 **** name and line number information. @node Interfaces.C.Extensions (i-cexten.ads) ! @section Interfaces.C.Extensions (i-cexten.ads) ! @cindex Interfaces.C.Extensions (i-cexten.ads) @noindent This package contains additional C-related definitions, intended --- 10914,10921 ---- name and line number information. @node Interfaces.C.Extensions (i-cexten.ads) ! @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads}) ! @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads}) @noindent This package contains additional C-related definitions, intended *************** for use with either manually or automati *** 10755,10762 **** to C libraries. @node Interfaces.C.Streams (i-cstrea.ads) ! @section Interfaces.C.Streams (i-cstrea.ads) ! @cindex Interfaces.C.Streams (i-cstrea.ads) @cindex C streams, interfacing @noindent --- 10923,10930 ---- to C libraries. @node Interfaces.C.Streams (i-cstrea.ads) ! @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads}) ! @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads}) @cindex C streams, interfacing @noindent *************** This package is a binding for the most c *** 10764,10782 **** on C streams. @node Interfaces.CPP (i-cpp.ads) ! @section Interfaces.CPP (i-cpp.ads) ! @cindex Interfaces.CPP (i-cpp.ads) @cindex C++ interfacing @cindex Interfacing, to C++ @noindent ! This package provides facilities for use in interfacing to C++. It is primarily intended to be used in connection with automated tools for the generation of C++ interfaces. @node Interfaces.Os2lib (i-os2lib.ads) ! @section Interfaces.Os2lib (i-os2lib.ads) ! @cindex Interfaces.Os2lib (i-os2lib.ads) @cindex Interfacing, to OS/2 @cindex OS/2 interfacing --- 10932,10950 ---- on C streams. @node Interfaces.CPP (i-cpp.ads) ! @section @code{Interfaces.CPP} (@file{i-cpp.ads}) ! @cindex @code{Interfaces.CPP} (@file{i-cpp.ads}) @cindex C++ interfacing @cindex Interfacing, to C++ @noindent ! This package provides facilities for use in interfacing to C++. It is primarily intended to be used in connection with automated tools for the generation of C++ interfaces. @node Interfaces.Os2lib (i-os2lib.ads) ! @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads}) ! @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads}) @cindex Interfacing, to OS/2 @cindex OS/2 interfacing *************** It is a thin binding which is a direct t *** 10786,10793 **** various @file{} files. @node Interfaces.Os2lib.Errors (i-os2err.ads) ! @section Interfaces.Os2lib.Errors (i-os2err.ads) ! @cindex Interfaces.Os2lib.Errors (i-os2err.ads) @cindex OS/2 Error codes @cindex Interfacing, to OS/2 @cindex OS/2 interfacing --- 10954,10961 ---- various @file{} files. @node Interfaces.Os2lib.Errors (i-os2err.ads) ! @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads}) ! @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads}) @cindex OS/2 Error codes @cindex Interfacing, to OS/2 @cindex OS/2 interfacing *************** various @file{} files. *** 10796,10803 **** This package provides definitions of the OS/2 error codes. @node Interfaces.Os2lib.Synchronization (i-os2syn.ads) ! @section Interfaces.Os2lib.Synchronization (i-os2syn.ads) ! @cindex Interfaces.Os2lib.Synchronization (i-os2syn.ads) @cindex Interfacing, to OS/2 @cindex Synchronization, OS/2 @cindex OS/2 synchronization primitives --- 10964,10971 ---- This package provides definitions of the OS/2 error codes. @node Interfaces.Os2lib.Synchronization (i-os2syn.ads) ! @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads}) ! @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads}) @cindex Interfacing, to OS/2 @cindex Synchronization, OS/2 @cindex OS/2 synchronization primitives *************** This is a child package that provides de *** 10807,10814 **** to the @code{OS/2} synchronization primitives. @node Interfaces.Os2lib.Threads (i-os2thr.ads) ! @section Interfaces.Os2lib.Threads (i-os2thr.ads) ! @cindex Interfaces.Os2lib.Threads (i-os2thr.ads) @cindex Interfacing, to OS/2 @cindex Thread control, OS/2 @cindex OS/2 thread interfacing --- 10975,10982 ---- to the @code{OS/2} synchronization primitives. @node Interfaces.Os2lib.Threads (i-os2thr.ads) ! @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads}) ! @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads}) @cindex Interfacing, to OS/2 @cindex Thread control, OS/2 @cindex OS/2 thread interfacing *************** This is a child package that provides de *** 10818,10825 **** to the @code{OS/2} thread primitives. @node Interfaces.Packed_Decimal (i-pacdec.ads) ! @section Interfaces.Packed_Decimal (i-pacdec.ads) ! @cindex Interfaces.Packed_Decimal (i-pacdec.ads) @cindex IBM Packed Format @cindex Packed Decimal --- 10986,10993 ---- to the @code{OS/2} thread primitives. @node Interfaces.Packed_Decimal (i-pacdec.ads) ! @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads}) ! @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads}) @cindex IBM Packed Format @cindex Packed Decimal *************** from a packed decimal format compatible *** 10829,10847 **** mainframes. @node Interfaces.VxWorks (i-vxwork.ads) ! @section Interfaces.VxWorks (i-vxwork.ads) ! @cindex Interfaces.VxWorks (i-vxwork.ads) @cindex Interfacing to VxWorks @cindex VxWorks, interfacing @noindent ! This package provides a limited binding to the VxWorks API In particular, it interfaces with the ! VxWorks hardware interrupt facilities @node System.Address_Image (s-addima.ads) ! @section System.Address_Image (s-addima.ads) ! @cindex System.Address_Image (s-addima.ads) @cindex Address image @cindex Image, of an address --- 10997,11027 ---- mainframes. @node Interfaces.VxWorks (i-vxwork.ads) ! @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads}) ! @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads}) @cindex Interfacing to VxWorks @cindex VxWorks, interfacing @noindent ! This package provides a limited binding to the VxWorks API. In particular, it interfaces with the ! VxWorks hardware interrupt facilities. ! ! @node Interfaces.VxWorks.IO (i-vxwoio.ads) ! @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads}) ! @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads}) ! @cindex Interfacing to VxWorks' I/O ! @cindex VxWorks, I/O interfacing ! @cindex VxWorks, Get_Immediate ! ! @noindent ! This package provides a limited binding to the VxWorks' I/O API. ! In particular, it provides procedures that enable the use of ! Get_Immediate under VxWorks. @node System.Address_Image (s-addima.ads) ! @section @code{System.Address_Image} (@file{s-addima.ads}) ! @cindex @code{System.Address_Image} (@file{s-addima.ads}) @cindex Address image @cindex Image, of an address *************** function that gives an (implementation d *** 10851,10860 **** string which identifies an address. @node System.Assertions (s-assert.ads) ! @section System.Assertions (s-assert.ads) ! @cindex System.Assertions (s-assert.ads) ! @cindex Assertions ! @cindex Assert_Failure, exception @noindent This package provides the declaration of the exception raised --- 11031,11040 ---- string which identifies an address. @node System.Assertions (s-assert.ads) ! @section @code{System.Assertions} (@file{s-assert.ads}) ! @cindex @code{System.Assertions} (@file{s-assert.ads}) ! @cindex Assertions ! @cindex Assert_Failure, exception @noindent This package provides the declaration of the exception raised *************** by an run-time assertion failure, as wel *** 10862,10888 **** is used internally to raise this assertion. @node System.Partition_Interface (s-parint.ads) ! @section System.Partition_Interface (s-parint.ads) ! @cindex System.Partition_Interface (s-parint.ads) @cindex Partition intefacing functions @noindent ! This package provides facilities for partition interfacing. It is used primarily in a distribution context when using Annex E with @code{GLADE}. @node System.Task_Info (s-tasinf.ads) ! @section System.Task_Info (s-tasinf.ads) ! @cindex System.Task_Info (s-tasinf.ads) ! @cindex Task_Info pragma @noindent This package provides target dependent functionality that is used to support the @code{Task_Info} pragma @node System.Wch_Cnv (s-wchcnv.ads) ! @section System.Wch_Cnv (s-wchcnv.ads) ! @cindex System.Wch_Cnv (s-wchcnv.ads) @cindex Wide Character, Representation @cindex Wide String, Conversion @cindex Representation of wide characters --- 11042,11068 ---- is used internally to raise this assertion. @node System.Partition_Interface (s-parint.ads) ! @section @code{System.Partition_Interface} (@file{s-parint.ads}) ! @cindex @code{System.Partition_Interface} (@file{s-parint.ads}) @cindex Partition intefacing functions @noindent ! This package provides facilities for partition interfacing. It is used primarily in a distribution context when using Annex E with @code{GLADE}. @node System.Task_Info (s-tasinf.ads) ! @section @code{System.Task_Info} (@file{s-tasinf.ads}) ! @cindex @code{System.Task_Info} (@file{s-tasinf.ads}) ! @cindex Task_Info pragma @noindent This package provides target dependent functionality that is used to support the @code{Task_Info} pragma @node System.Wch_Cnv (s-wchcnv.ads) ! @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads}) ! @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads}) @cindex Wide Character, Representation @cindex Wide String, Conversion @cindex Representation of wide characters *************** to support the @code{Task_Info} pragma *** 10891,10907 **** This package provides routines for converting between wide characters and a representation as a value of type @code{Standard.String}, using a specified wide character ! encoding method. Uses definitions in ! package @code{System.Wch_Con} @node System.Wch_Con (s-wchcon.ads) ! @section System.Wch_Con (s-wchcon.ads) ! @cindex System.Wch_Con (s-wchcon.ads) @noindent This package provides definitions and descriptions of the various methods used for encoding wide characters ! in ordinary strings. These definitions are used by the package @code{System.Wch_Cnv}. @node Interfacing to Other Languages --- 11071,11087 ---- This package provides routines for converting between wide characters and a representation as a value of type @code{Standard.String}, using a specified wide character ! encoding method. It uses definitions in ! package @code{System.Wch_Con}. @node System.Wch_Con (s-wchcon.ads) ! @section @code{System.Wch_Con} (@file{s-wchcon.ads}) ! @cindex @code{System.Wch_Con} (@file{s-wchcon.ads}) @noindent This package provides definitions and descriptions of the various methods used for encoding wide characters ! in ordinary strings. These definitions are used by the package @code{System.Wch_Cnv}. @node Interfacing to Other Languages *************** Interfacing to C with GNAT can use one o *** 10929,10942 **** @item The types in the package @code{Interfaces.C} may be used. @item ! Standard Ada types may be used directly. This may be less portable to other compilers, but will work on all GNAT compilers, which guarantee correspondence between the C and Ada types. @end enumerate @noindent Pragma @code{Convention C} maybe applied to Ada types, but mostly has no ! effect, since this is the default. The following table shows the correspondence between Ada scalar types and the corresponding C types. @table @code --- 11109,11122 ---- @item The types in the package @code{Interfaces.C} may be used. @item ! Standard Ada types may be used directly. This may be less portable to other compilers, but will work on all GNAT compilers, which guarantee correspondence between the C and Ada types. @end enumerate @noindent Pragma @code{Convention C} maybe applied to Ada types, but mostly has no ! effect, since this is the default. The following table shows the correspondence between Ada scalar types and the corresponding C types. @table @code *************** This is the longest floating-point type *** 10964,10972 **** @item Ada enumeration types map to C enumeration types directly if pragma @code{Convention C} is specified, which causes them to have int ! length. Without pragma @code{Convention C}, Ada enumeration types map to ! 8, 16, or 32 bits (i.e.@: C types signed char, short, int respectively) ! depending on the number of values passed. This is the only case in which pragma @code{Convention C} affects the representation of an Ada type. @item --- 11144,11152 ---- @item Ada enumeration types map to C enumeration types directly if pragma @code{Convention C} is specified, which causes them to have int ! length. Without pragma @code{Convention C}, Ada enumeration types map to ! 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short}, @code{int}, respectively) ! depending on the number of values passed. This is the only case in which pragma @code{Convention C} affects the representation of an Ada type. @item *************** of the length corresponding to the @code *** 10990,10996 **** @noindent The interface to C++ makes use of the following pragmas, which are primarily intended to be constructed automatically using a binding generator ! tool, although it is possible to construct them by hand. Ada Core Technologies does not currently supply a suitable binding generator tool. Using these pragmas it is possible to achieve complete --- 11170,11176 ---- @noindent The interface to C++ makes use of the following pragmas, which are primarily intended to be constructed automatically using a binding generator ! tool, although it is possible to construct them by hand. Ada Core Technologies does not currently supply a suitable binding generator tool. Using these pragmas it is possible to achieve complete *************** See @ref{Implementation Defined Pragmas} *** 11000,11006 **** @table @code @item pragma CPP_Class ([Entity =>] @var{local_name}) The argument denotes an entity in the current declarative region that is ! declared as a tagged or untagged record type. It indicates that the type corresponds to an externally declared C++ class type, and is to be laid out the same way that C++ would lay out the type. --- 11180,11186 ---- @table @code @item pragma CPP_Class ([Entity =>] @var{local_name}) The argument denotes an entity in the current declarative region that is ! declared as a tagged or untagged record type. It indicates that the type corresponds to an externally declared C++ class type, and is to be laid out the same way that C++ would lay out the type. *************** the Ada 95 reference manual. *** 11026,11040 **** @noindent Interfacing to Fortran is achieved as described in section B.5 of the ! reference manual. The pragma @code{Convention Fortran}, applied to a ! multi- dimensional array causes the array to be stored in column-major order as required for convenient interface to Fortran. @node Interfacing to non-GNAT Ada code @section Interfacing to non-GNAT Ada code ! It is possible to specify the convention Ada in a pragma Import or ! pragma Export. However this refers to the calling conventions used by GNAT, which may or may not be similar enough to those used by some other Ada 83 or Ada 95 compiler to allow interoperation. --- 11206,11220 ---- @noindent Interfacing to Fortran is achieved as described in section B.5 of the ! reference manual. The pragma @code{Convention Fortran}, applied to a ! multi-dimensional array causes the array to be stored in column-major order as required for convenient interface to Fortran. @node Interfacing to non-GNAT Ada code @section Interfacing to non-GNAT Ada code ! It is possible to specify the convention @code{Ada} in a pragma @code{Import} or ! pragma @code{Export}. However this refers to the calling conventions used by GNAT, which may or may not be similar enough to those used by some other Ada 83 or Ada 95 compiler to allow interoperation. *************** including machine instructions in a subp *** 11067,11081 **** @end itemize The two features are similar, and both closely related to the mechanism ! provided by the asm instruction in the GNU C compiler. Full understanding and use of the facilities in this package requires understanding the asm ! instruction as described in @cite{Using and Porting GNU CC} by Richard Stallman. Calls to the function @code{Asm} and the procedure @code{Asm} have identical semantic restrictions and effects as described below. Both are provided so that the procedure call can be used as a statement, and the function call can be used to form a code_statement. ! The first example given in the GNU CC documentation is the C @code{asm} instruction: @smallexample asm ("fsinx %1 %0" : "=f" (result) : "f" (angle)); --- 11247,11262 ---- @end itemize The two features are similar, and both closely related to the mechanism ! provided by the asm instruction in the GNU C compiler. Full understanding and use of the facilities in this package requires understanding the asm ! instruction as described in ! @cite{Using and Porting the GNU Compiler Collection (GCC)} by Richard Stallman. Calls to the function @code{Asm} and the procedure @code{Asm} have identical semantic restrictions and effects as described below. Both are provided so that the procedure call can be used as a statement, and the function call can be used to form a code_statement. ! The first example given in the GCC documentation is the C @code{asm} instruction: @smallexample asm ("fsinx %1 %0" : "=f" (result) : "f" (angle)); *************** Asm ("fsinx %1 %0", *** 11091,11109 **** @end smallexample The first argument to @code{Asm} is the assembler template, and is ! identical to what is used in GNU CC@. This string must be a static ! expression. The second argument is the output operand list. It is either a single @code{Asm_Output} attribute reference, or a list of such references enclosed in parentheses (technically an array aggregate of such references). The @code{Asm_Output} attribute denotes a function that takes two parameters. The first is a string, the second is the name of a variable ! of the type designated by the attribute prefix. The first (string) argument is required to be a static expression and designates the constraint for the parameter (e.g.@: what kind of register is ! required). The second argument is the variable to be updated with the ! result. The possible values for constraint are the same as those used in the RTL, and are dependent on the configuration file used to build the GCC back end. If there are no output operands, then this argument may either be omitted, or explicitly given as @code{No_Output_Operands}. --- 11272,11290 ---- @end smallexample The first argument to @code{Asm} is the assembler template, and is ! identical to what is used in GNU C@. This string must be a static ! expression. The second argument is the output operand list. It is either a single @code{Asm_Output} attribute reference, or a list of such references enclosed in parentheses (technically an array aggregate of such references). The @code{Asm_Output} attribute denotes a function that takes two parameters. The first is a string, the second is the name of a variable ! of the type designated by the attribute prefix. The first (string) argument is required to be a static expression and designates the constraint for the parameter (e.g.@: what kind of register is ! required). The second argument is the variable to be updated with the ! result. The possible values for constraint are the same as those used in the RTL, and are dependent on the configuration file used to build the GCC back end. If there are no output operands, then this argument may either be omitted, or explicitly given as @code{No_Output_Operands}. *************** though it were an @code{out} parameter, *** 11113,11151 **** all names have the form of expressions, so there is no syntactic irregularity, even though normally functions would not be permitted @code{out} parameters. The third argument is the list of input ! operands. It is either a single @code{Asm_Input} attribute reference, or a list of such references enclosed in parentheses (technically an array aggregate of such references). The @code{Asm_Input} attribute denotes a function that takes two parameters. The first is a string, the second is an expression of the ! type designated by the prefix. The first (string) argument is required to be a static expression, and is the constraint for the parameter, ! (e.g.@: what kind of register is required). The second argument is the ! value to be used as the input argument. The possible values for the constant are the same as those used in the RTL, and are dependent on the configuration file used to built the GCC back end. If there are no input operands, this argument may either be omitted, or explicitly given as @code{No_Input_Operands}. The fourth argument, not present in the above example, is a list of register names, called the ! @dfn{clobber} argument. This argument, if given, must be a static string expression, and is a space or comma separated list of names of registers ! that must be considered destroyed as a result of the @code{Asm} call. If this argument is the null string (the default value), then the code generator assumes that no additional registers are destroyed. The fifth argument, not present in the above example, called the ! @dfn{volatile} argument, is by default @code{False}. It can be set to the literal value @code{True} to indicate to the code generator that all optimizations with respect to the instruction specified should be suppressed, and that in particular, for an instruction that has outputs, the instruction will still be generated, even if none of the outputs are ! used. See the full description in the GCC manual for further details. ! The @code{Asm} subprograms may be used in two ways. First the procedure forms can be used anywhere a procedure call would be valid, and ! correspond to what the RM calls ``intrinsic'' routines. Such calls can be used to intersperse machine instructions with other Ada statements. Second, the function forms, which return a dummy value of the limited private type @code{Asm_Insn}, can be used in code statements, and indeed --- 11294,11332 ---- all names have the form of expressions, so there is no syntactic irregularity, even though normally functions would not be permitted @code{out} parameters. The third argument is the list of input ! operands. It is either a single @code{Asm_Input} attribute reference, or a list of such references enclosed in parentheses (technically an array aggregate of such references). The @code{Asm_Input} attribute denotes a function that takes two parameters. The first is a string, the second is an expression of the ! type designated by the prefix. The first (string) argument is required to be a static expression, and is the constraint for the parameter, ! (e.g.@: what kind of register is required). The second argument is the ! value to be used as the input argument. The possible values for the constant are the same as those used in the RTL, and are dependent on the configuration file used to built the GCC back end. If there are no input operands, this argument may either be omitted, or explicitly given as @code{No_Input_Operands}. The fourth argument, not present in the above example, is a list of register names, called the ! @dfn{clobber} argument. This argument, if given, must be a static string expression, and is a space or comma separated list of names of registers ! that must be considered destroyed as a result of the @code{Asm} call. If this argument is the null string (the default value), then the code generator assumes that no additional registers are destroyed. The fifth argument, not present in the above example, called the ! @dfn{volatile} argument, is by default @code{False}. It can be set to the literal value @code{True} to indicate to the code generator that all optimizations with respect to the instruction specified should be suppressed, and that in particular, for an instruction that has outputs, the instruction will still be generated, even if none of the outputs are ! used. See the full description in the GCC manual for further details. ! The @code{Asm} subprograms may be used in two ways. First the procedure forms can be used anywhere a procedure call would be valid, and ! correspond to what the RM calls ``intrinsic'' routines. Such calls can be used to intersperse machine instructions with other Ada statements. Second, the function forms, which return a dummy value of the limited private type @code{Asm_Insn}, can be used in code statements, and indeed *************** within subprograms whose entire body con *** 11162,11168 **** not permissible to intermix such statements with other Ada statements. Typically the form using intrinsic procedure calls is more convenient ! and more flexible. The code statement form is provided to meet the RM suggestion that such a facility should be made available. The following is the exact syntax of the call to @code{Asm} (of course if named notation is used, the arguments may be given in arbitrary order, following the --- 11343,11349 ---- not permissible to intermix such statements with other Ada statements. Typically the form using intrinsic procedure calls is more convenient ! and more flexible. The code statement form is provided to meet the RM suggestion that such a facility should be made available. The following is the exact syntax of the call to @code{Asm} (of course if named notation is used, the arguments may be given in arbitrary order, following the *************** GNAT run-time system comprises two layer *** 11207,11233 **** @end itemize In GNAT, Ada's tasking services rely on a platform and OS independent ! layer known as GNARL@. This code is responsible for implementing the correct semantics of Ada's task creation, rendezvous, protected operations etc. GNARL decomposes Ada's tasking semantics into simpler lower level operations such as create a thread, set the priority of a thread, ! yield, create a lock, lock/unlock, etc. The spec for these low-level ! operations constitutes GNULLI, the GNULL Interface. This interface is directly inspired from the POSIX real-time API@. If the underlying executive or OS implements the POSIX standard faithfully, the GNULL Interface maps as is to the services offered by ! the underlying kernel. Otherwise, some target dependent glue code maps the services offered by the underlying kernel to the semantics expected by GNARL@. Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the key point is that each Ada task is mapped on a thread in the underlying ! kernel. For example, in the case of VxWorks ! ! 1 Ada task = 1 VxWorks task In addition Ada task priorities map onto the underlying thread priorities. Mapping Ada tasks onto the underlying kernel threads has several advantages: --- 11388,11412 ---- @end itemize In GNAT, Ada's tasking services rely on a platform and OS independent ! layer known as GNARL@. This code is responsible for implementing the correct semantics of Ada's task creation, rendezvous, protected operations etc. GNARL decomposes Ada's tasking semantics into simpler lower level operations such as create a thread, set the priority of a thread, ! yield, create a lock, lock/unlock, etc. The spec for these low-level ! operations constitutes GNULLI, the GNULL Interface. This interface is directly inspired from the POSIX real-time API@. If the underlying executive or OS implements the POSIX standard faithfully, the GNULL Interface maps as is to the services offered by ! the underlying kernel. Otherwise, some target dependent glue code maps the services offered by the underlying kernel to the semantics expected by GNARL@. Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the key point is that each Ada task is mapped on a thread in the underlying ! kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task. In addition Ada task priorities map onto the underlying thread priorities. Mapping Ada tasks onto the underlying kernel threads has several advantages: *************** Mapping Ada tasks onto the underlying ke *** 11235,11241 **** @enumerate @item ! The underlying scheduler is used to schedule the Ada tasks. This makes Ada tasks as efficient as kernel threads from a scheduling standpoint. --- 11414,11420 ---- @enumerate @item ! The underlying scheduler is used to schedule the Ada tasks. This makes Ada tasks as efficient as kernel threads from a scheduling standpoint. *************** The GNAT run-time, has a nice cooperativ *** 11285,11295 **** which ensures that accurate FIFO_Within_Priorities semantics are respected. ! The principle is as follows. When an Ada task T is about to start running, it checks whether some other Ada task R with the same priority as T has been suspended due to the loss of priority ! inheritance. If this is the case, T yields and is placed at the end of ! its priority queue. When R arrives at the front of the queue it executes. Note that this simple scheme preserves the relative order of the tasks --- 11464,11474 ---- which ensures that accurate FIFO_Within_Priorities semantics are respected. ! The principle is as follows. When an Ada task T is about to start running, it checks whether some other Ada task R with the same priority as T has been suspended due to the loss of priority ! inheritance. If this is the case, T yields and is placed at the end of ! its priority queue. When R arrives at the front of the queue it executes. Note that this simple scheme preserves the relative order of the tasks *************** placed at the end. *** 11308,11327 **** @end menu Aggregate have a rich syntax and allow the user to specify the values of ! complex data structures by means of a single construct. As a result, the code generated for aggregates can be quite complex and involve loops, case ! statements and multiple assignments. In the simplest cases, however, the compiler will recognize aggregates whose components and constraints are fully static, and in those cases the compiler will generate little or no ! executable code. The following is an outline of the code that GNAT generates ! for various aggregate constructs. For further details, the user will find it useful to examine the output produced by the -gnatG flag to see the expanded source that is input to the code generator. The user will also want to examine the assembly code generated at various levels of optimization. The code generated for aggregates depends on the context, the component values, ! and the type. In the context of an object declaration the code generated is ! generally simpler than in the case of an assignment. As a general rule, static component values and static subtypes also lead to simpler code. @node Static constant aggregates with static bounds --- 11487,11506 ---- @end menu Aggregate have a rich syntax and allow the user to specify the values of ! complex data structures by means of a single construct. As a result, the code generated for aggregates can be quite complex and involve loops, case ! statements and multiple assignments. In the simplest cases, however, the compiler will recognize aggregates whose components and constraints are fully static, and in those cases the compiler will generate little or no ! executable code. The following is an outline of the code that GNAT generates ! for various aggregate constructs. For further details, the user will find it useful to examine the output produced by the -gnatG flag to see the expanded source that is input to the code generator. The user will also want to examine the assembly code generated at various levels of optimization. The code generated for aggregates depends on the context, the component values, ! and the type. In the context of an object declaration the code generated is ! generally simpler than in the case of an assignment. As a general rule, static component values and static subtypes also lead to simpler code. @node Static constant aggregates with static bounds *************** None2 : constant ar_ar := (1..3 => None) *** 11359,11365 **** @end smallexample However, for multidimensional aggregates with named associations, GNAT will ! generate assignments and loops, even if all associations are static. The following two declarations generate a loop for the first dimension, and individual component assignments for the second dimension: --- 11538,11544 ---- @end smallexample However, for multidimensional aggregates with named associations, GNAT will ! generate assignments and loops, even if all associations are static. The following two declarations generate a loop for the first dimension, and individual component assignments for the second dimension: *************** Zero2: constant two_dim := (others => (o *** 11372,11379 **** @section Constant aggregates with an unconstrained nominal types In such cases the aggregate itself establishes the subtype, so that associations ! with "others" cannot be used. GNAT determines the bounds for the actual ! subtype of the aggregate, and allocates the aggregate statically as well. No code is generated for the following: @smallexample --- 11551,11558 ---- @section Constant aggregates with an unconstrained nominal types In such cases the aggregate itself establishes the subtype, so that associations ! with @code{others} cannot be used. GNAT determines the bounds for the actual ! subtype of the aggregate, and allocates the aggregate statically as well. No code is generated for the following: @smallexample *************** code is generated for the following: *** 11385,11393 **** @section Aggregates with static bounds In all previous examples the aggregate was the initial (and immutable) value ! of a constant. If the aggregate initializes a variable, then code is generated for it as a combination of individual assignments and loops over the target ! object. The declarations @smallexample Cr_Var1 : One_Dim := (2, 5, 7, 11); --- 11564,11572 ---- @section Aggregates with static bounds In all previous examples the aggregate was the initial (and immutable) value ! of a constant. If the aggregate initializes a variable, then code is generated for it as a combination of individual assignments and loops over the target ! object. The declarations @smallexample Cr_Var1 : One_Dim := (2, 5, 7, 11); *************** generate the equivalent of *** 11412,11418 **** If the bounds of the aggregate are not statically compatible with the bounds of the nominal subtype of the target, then constraint checks have to be ! generated on the bounds. For a multidimensional array, constraint checks may have to be applied to sub-arrays individually, if they do not have statically compatible subtypes. --- 11591,11597 ---- If the bounds of the aggregate are not statically compatible with the bounds of the nominal subtype of the target, then constraint checks have to be ! generated on the bounds. For a multidimensional array, constraint checks may have to be applied to sub-arrays individually, if they do not have statically compatible subtypes. *************** compatible subtypes. *** 11420,11428 **** @section Aggregates in assignments statements In general, aggregate assignment requires the construction of a temporary, ! and a copy from the temporary to the target of the assignment. This is because it is not always possible to convert the assignment into a series of individual ! component assignments. For example, consider the simple case: @smallexample @end smallexample --- 11599,11607 ---- @section Aggregates in assignments statements In general, aggregate assignment requires the construction of a temporary, ! and a copy from the temporary to the target of the assignment. This is because it is not always possible to convert the assignment into a series of individual ! component assignments. For example, consider the simple case: @smallexample @end smallexample *************** This cannot be converted into: *** 11436,11444 **** @end smallexample So the aggregate has to be built first in a separate location, and then ! copied into the target. GNAT recognizes simple cases where this intermediate step is not required, and the assignments can be performed in place, directly ! into the target. The following sufficient criteria are applied: @enumerate @item The bounds of the aggregate are static, and the associations are static. --- 11615,11623 ---- @end smallexample So the aggregate has to be built first in a separate location, and then ! copied into the target. GNAT recognizes simple cases where this intermediate step is not required, and the assignments can be performed in place, directly ! into the target. The following sufficient criteria are applied: @enumerate @item The bounds of the aggregate are static, and the associations are static. *************** that temporary will be copied onto the t *** 11457,11486 **** @noindent Ada 95 defines a number of specialized needs annexes, which are not ! required in all implementations. However, as described in this chapter, GNAT implements all of these special needs annexes: @table @asis @item Systems Programming (Annex C) ! The systems programming annex is fully implemented. @item Real-Time Systems (Annex D) ! The real-time systems annex is fully implemented. @item Distributed Systems (Annex E) ! Stub generation is fully implemented in the @code{GNAT} compiler. In addition, ! a complete compatible PCS is available as part of the @code{GLADE} system, ! a separate product available from Ada Core Technologies. When the two products are used in conjunction, this annex is fully implemented. @item Information Systems (Annex F) ! The information systems annex is fully implemented. @item Numerics (Annex G) ! The numerics annex is fully implemented. @item Safety and Security (Annex H) ! The safety and security annex is fully implemented. @end table --- 11636,11665 ---- @noindent Ada 95 defines a number of specialized needs annexes, which are not ! required in all implementations. However, as described in this chapter, GNAT implements all of these special needs annexes: @table @asis @item Systems Programming (Annex C) ! The Systems Programming Annex is fully implemented. @item Real-Time Systems (Annex D) ! The Real-Time Systems Annex is fully implemented. @item Distributed Systems (Annex E) ! Stub generation is fully implemented in the GNAT compiler. In addition, ! a complete compatible PCS is available as part of the GLADE system, ! a separate product. When the two products are used in conjunction, this annex is fully implemented. @item Information Systems (Annex F) ! The Information Systems annex is fully implemented. @item Numerics (Annex G) ! The Numerics Annex is fully implemented. @item Safety and Security (Annex H) ! The Safety and Security annex is fully implemented. @end table *************** applications developed in other Ada envi *** 11501,11515 **** @node Compatibility with Ada 83 @section Compatibility with Ada 83 @noindent ! Ada 95 is designed to be highly upwards compatible with Ada 83. In particular, the design intention is that the difficulties associated with moving from Ada 83 to Ada 95 should be no greater than those that occur when moving from one Ada 83 system to another. However, there are a number of points at which there are minor ! incompatibilities. The Ada 95 Annotated Reference Manual contains full details of these issues, and should be consulted for a complete treatment. In practice the --- 11680,11695 ---- @node Compatibility with Ada 83 @section Compatibility with Ada 83 + @cindex Compatibility (between Ada 83 and Ada 95) @noindent ! Ada 95 is designed to be highly upwards compatible with Ada 83. In particular, the design intention is that the difficulties associated with moving from Ada 83 to Ada 95 should be no greater than those that occur when moving from one Ada 83 system to another. However, there are a number of points at which there are minor ! incompatibilities. The Ada 95 Annotated Reference Manual contains full details of these issues, and should be consulted for a complete treatment. In practice the *************** following are the most likely issues to *** 11517,11528 **** @table @asis @item Character range ! The range of Standard.Character is now the full 256 characters of Latin-1, whereas in most Ada 83 implementations it was restricted to 128 characters. ! This may show up as compile time or runtime errors. The desirable fix is to adapt the program to accommodate the full character set, but in some cases it may be convenient to define a subtype or derived type of Character that covers only the restricted range. @item New reserved words The identifiers @code{abstract}, @code{aliased}, @code{protected}, --- 11697,11709 ---- @table @asis @item Character range ! The range of @code{Standard.Character} is now the full 256 characters of Latin-1, whereas in most Ada 83 implementations it was restricted to 128 characters. ! This may show up as compile time or runtime errors. The desirable fix is to adapt the program to accommodate the full character set, but in some cases it may be convenient to define a subtype or derived type of Character that covers only the restricted range. + @cindex Latin-1 @item New reserved words The identifiers @code{abstract}, @code{aliased}, @code{protected}, *************** use some alternative name. *** 11533,11587 **** @item Freezing rules The rules in Ada 95 are slightly different with regard to the point at which entities are frozen, and representation pragmas and clauses are ! not permitted past the freeze point. This shows up most typically in the form of an error message complaining that a representation item appears too late, and the appropriate corrective action is to move the item nearer to the declaration of the entity to which it refers. A particular case is that representation pragmas (including the ! extended DEC Ada 83 compatibility pragmas such as Export_Procedure), cannot ! be applied to a subprogram body. If necessary, a separate subprogram declaration must be introduced to which the pragma can be applied. @item Optional bodies for library packages In Ada 83, a package that did not require a package body was nevertheless ! allowed to have one. This lead to certain surprises in compiling large ! systems (situations in which the body could be unexpectedly ignored). In Ada 95, if a package does not require a body then it is not permitted to ! have a body. To fix this problem, simply remove a redundant body if it is empty, or, if it is non-empty, introduce a dummy declaration into the ! spec that makes the body required. One approach is to add a private part to the package declaration (if necessary), and define a parameterless procedure called Requires_Body, which must then be given a dummy procedure body in the package body, which then becomes required. ! @item Numeric_Error is now the same as Constraint_Error ! In Ada 95, the exception Numeric_Error is a renaming of Constraint_Error. This means that it is illegal to have separate exception handlers for ! the two exceptions. The fix is simply to remove the handler for the ! Numeric_Error case (since even in Ada 83, a compiler was free to raise ! Constraint_Error in place of Numeric_Error in all cases). @item Indefinite subtypes in generics ! In Ada 83, it was permissible to pass an indefinite type (e.g.@: String) as the actual for a generic formal private type, but then the instantiation would be illegal if there were any instances of declarations of variables ! of this type in the generic body. In Ada 95, to avoid this clear violation of the contract model, the generic declaration clearly indicates whether ! or not such instantiations are permitted. If a generic formal parameter ! has explicit unknown discriminants, indicated by using (<>) after the type name, then it can be instantiated with indefinite types, but no ! variables can be declared of this type. Any attempt to declare a variable ! will result in an illegality at the time the generic is declared. If the ! (<>) notation is not used, then it is illegal to instantiate the generic ! with an indefinite type. This will show up as a compile time error, and ! the fix is usually simply to add the (<>) to the generic declaration. @end table All implementations of GNAT provide a switch that causes GNAT to operate ! in Ada 83 mode. In this mode, some but not all compatibility problems ! of the type described above are handled automatically. For example, the ! new Ada 95 protected keywords are not recognized in this mode. However, in practice, it is usually advisable to make the necessary modifications to the program to remove the need for using this switch. --- 11714,11768 ---- @item Freezing rules The rules in Ada 95 are slightly different with regard to the point at which entities are frozen, and representation pragmas and clauses are ! not permitted past the freeze point. This shows up most typically in the form of an error message complaining that a representation item appears too late, and the appropriate corrective action is to move the item nearer to the declaration of the entity to which it refers. A particular case is that representation pragmas (including the ! extended DEC Ada 83 compatibility pragmas such as @code{Export_Procedure}), cannot ! be applied to a subprogram body. If necessary, a separate subprogram declaration must be introduced to which the pragma can be applied. @item Optional bodies for library packages In Ada 83, a package that did not require a package body was nevertheless ! allowed to have one. This lead to certain surprises in compiling large ! systems (situations in which the body could be unexpectedly ignored). In Ada 95, if a package does not require a body then it is not permitted to ! have a body. To fix this problem, simply remove a redundant body if it is empty, or, if it is non-empty, introduce a dummy declaration into the ! spec that makes the body required. One approach is to add a private part to the package declaration (if necessary), and define a parameterless procedure called Requires_Body, which must then be given a dummy procedure body in the package body, which then becomes required. ! @item @code{Numeric_Error} is now the same as @code{Constraint_Error} ! In Ada 95, the exception @code{Numeric_Error} is a renaming of @code{Constraint_Error}. This means that it is illegal to have separate exception handlers for ! the two exceptions. The fix is simply to remove the handler for the ! @code{Numeric_Error} case (since even in Ada 83, a compiler was free to raise ! @code{Constraint_Error} in place of @code{Numeric_Error} in all cases). @item Indefinite subtypes in generics ! In Ada 83, it was permissible to pass an indefinite type (e.g.@: @code{String}) as the actual for a generic formal private type, but then the instantiation would be illegal if there were any instances of declarations of variables ! of this type in the generic body. In Ada 95, to avoid this clear violation of the contract model, the generic declaration clearly indicates whether ! or not such instantiations are permitted. If a generic formal parameter ! has explicit unknown discriminants, indicated by using @code{(<>)} after the type name, then it can be instantiated with indefinite types, but no ! variables can be declared of this type. Any attempt to declare a variable ! will result in an illegality at the time the generic is declared. If the ! @code{(<>)} notation is not used, then it is illegal to instantiate the generic ! with an indefinite type. This will show up as a compile time error, and ! the fix is usually simply to add the @code{(<>)} to the generic declaration. @end table All implementations of GNAT provide a switch that causes GNAT to operate ! in Ada 83 mode. In this mode, some but not all compatibility problems ! of the type described above are handled automatically. For example, the ! new Ada 95 protected keywords are not recognized in this mode. However, in practice, it is usually advisable to make the necessary modifications to the program to remove the need for using this switch. *************** to the program to remove the need for us *** 11592,11598 **** Providing that programs avoid the use of implementation dependent and implementation defined features of Ada 95, as documented in the Ada 95 reference manual, there should be a high degree of portability between ! GNAT and other Ada 95 systems. The following are specific items which have proved troublesome in moving GNAT programs to other Ada 95 compilers, but do not affect porting code to GNAT@. --- 11773,11779 ---- Providing that programs avoid the use of implementation dependent and implementation defined features of Ada 95, as documented in the Ada 95 reference manual, there should be a high degree of portability between ! GNAT and other Ada 95 systems. The following are specific items which have proved troublesome in moving GNAT programs to other Ada 95 compilers, but do not affect porting code to GNAT@. *************** a compatibility concern, but some other *** 11605,11618 **** pragmas and attributes. @item Special-needs Annexes ! GNAT implements the full set of special needs annexes. At the ! current time, it is the only Ada 95 compiler to do so. This means that programs making use of these features may not be portable to other Ada 95 compilation systems. @item Representation Clauses Some other Ada 95 compilers implement only the minimal set of ! representation clauses required by the Ada 95 reference manual. GNAT goes far beyond this minimal set, as described in the next section. @end table --- 11786,11799 ---- pragmas and attributes. @item Special-needs Annexes ! GNAT implements the full set of special needs annexes. At the ! current time, it is the only Ada 95 compiler to do so. This means that programs making use of these features may not be portable to other Ada 95 compilation systems. @item Representation Clauses Some other Ada 95 compilers implement only the minimal set of ! representation clauses required by the Ada 95 reference manual. GNAT goes far beyond this minimal set, as described in the next section. @end table *************** far beyond this minimal set, as describe *** 11622,11628 **** @noindent The Ada 83 reference manual was quite vague in describing both the minimal required implementation of representation clauses, and also their precise ! effects. The Ada 95 reference manual is much more explicit, but the minimal set of capabilities required in Ada 95 is quite limited. GNAT implements the full required set of capabilities described in the --- 11803,11809 ---- @noindent The Ada 83 reference manual was quite vague in describing both the minimal required implementation of representation clauses, and also their precise ! effects. The Ada 95 reference manual is much more explicit, but the minimal set of capabilities required in Ada 95 is quite limited. GNAT implements the full required set of capabilities described in the *************** an effort has been made to be compatible *** 11631,11645 **** greatest extent possible. A few cases exist in which Ada 83 compiler behavior is incompatible with ! requirements in the Ada 95 reference manual. These are instances of intentional or accidental dependence on specific implementation dependent ! characteristics of these Ada 83 compilers. The following is a list of the cases most likely to arise in existing legacy Ada 83 code. @table @asis @item Implicit Packing Some Ada 83 compilers allowed a Size specification to cause implicit ! packing of an array or record. This could cause expensive implicit conversions for change of representation in the presence of derived types, and the Ada design intends to avoid this possibility. Subsequent AI's were issued to make it clear that such implicit --- 11812,11826 ---- greatest extent possible. A few cases exist in which Ada 83 compiler behavior is incompatible with ! requirements in the Ada 95 reference manual. These are instances of intentional or accidental dependence on specific implementation dependent ! characteristics of these Ada 83 compilers. The following is a list of the cases most likely to arise in existing legacy Ada 83 code. @table @asis @item Implicit Packing Some Ada 83 compilers allowed a Size specification to cause implicit ! packing of an array or record. This could cause expensive implicit conversions for change of representation in the presence of derived types, and the Ada design intends to avoid this possibility. Subsequent AI's were issued to make it clear that such implicit *************** change of representation in response to *** 11647,11682 **** and this recommendation is represented explicitly in the Ada 95 RM as implementation advice that is followed by GNAT@. The problem will show up as an error ! message rejecting the size clause. The fix is simply to provide ! the explicit pragma Pack, or for more fine tuned control, provide a Component_Size clause. @item Meaning of Size Attribute The Size attribute in Ada 95 for discrete types is defined as being the ! minimal number of bits required to hold values of the type. For example, on a 32-bit machine, the size of Natural will typically be 31 and not ! 32 (since no sign bit is required). Some Ada 83 compilers gave 31, and ! some 32 in this situation. This problem will usually show up as a compile ! time error, but not always. It is a good idea to check all uses of the ! 'Size attribute when porting Ada 83 code. The GNAT specific attribute Object_Size can provide a useful way of duplicating the behavior of some Ada 83 compiler systems. @item Size of Access Types A common assumption in Ada 83 code is that an access type is in fact a pointer, ! and that therefore it will be the same size as a System.Address value. This ! assumption is true for GNAT in most cases with one exception. For the case of a pointer to an unconstrained array type (where the bounds may vary from one ! value of the access type to another), the default is to use a "fat pointer", which is represented as two separate pointers, one to the bounds, and one to ! the array. This representation has a number of advantages, including improved ! efficiency. However, it may cause some difficulties in porting existing Ada 83 code which makes the assumption that, for example, pointers fit in 32 bits on a machine with 32-bit addressing. ! To get around this problem, GNAT also permits the use of "thin pointers" for access types in this case (where the designated type is an unconstrained array ! type). These thin pointers are indeed the same size as a System.Address value. To specify a thin pointer, use a size clause for the type, for example: @smallexample --- 11828,11863 ---- and this recommendation is represented explicitly in the Ada 95 RM as implementation advice that is followed by GNAT@. The problem will show up as an error ! message rejecting the size clause. The fix is simply to provide ! the explicit pragma @code{Pack}, or for more fine tuned control, provide a Component_Size clause. @item Meaning of Size Attribute The Size attribute in Ada 95 for discrete types is defined as being the ! minimal number of bits required to hold values of the type. For example, on a 32-bit machine, the size of Natural will typically be 31 and not ! 32 (since no sign bit is required). Some Ada 83 compilers gave 31, and ! some 32 in this situation. This problem will usually show up as a compile ! time error, but not always. It is a good idea to check all uses of the ! 'Size attribute when porting Ada 83 code. The GNAT specific attribute Object_Size can provide a useful way of duplicating the behavior of some Ada 83 compiler systems. @item Size of Access Types A common assumption in Ada 83 code is that an access type is in fact a pointer, ! and that therefore it will be the same size as a System.Address value. This ! assumption is true for GNAT in most cases with one exception. For the case of a pointer to an unconstrained array type (where the bounds may vary from one ! value of the access type to another), the default is to use a ``fat pointer'', which is represented as two separate pointers, one to the bounds, and one to ! the array. This representation has a number of advantages, including improved ! efficiency. However, it may cause some difficulties in porting existing Ada 83 code which makes the assumption that, for example, pointers fit in 32 bits on a machine with 32-bit addressing. ! To get around this problem, GNAT also permits the use of ``thin pointers'' for access types in this case (where the designated type is an unconstrained array ! type). These thin pointers are indeed the same size as a System.Address value. To specify a thin pointer, use a size clause for the type, for example: @smallexample *************** for X'Size use Standard'Address_Size; *** 11685,11697 **** @end smallexample @noindent ! which will cause the type X to be represented using a single pointer. When using ! this representation, the bounds are right behind the array. This representation is slightly less efficient, and does not allow quite such flexibility in the use of foreign pointers or in using the Unrestricted_Access attribute to create ! pointers to non-aliased objects. But for any standard portable use of the access type it will work in a functionally correct manner and allow porting of existing ! code. Note that another way of forcing a thin pointer representation is to use a component size clause for the element size in an array, or a record representation clause for an access field in a record. @end table --- 11866,11878 ---- @end smallexample @noindent ! which will cause the type X to be represented using a single pointer. When using ! this representation, the bounds are right behind the array. This representation is slightly less efficient, and does not allow quite such flexibility in the use of foreign pointers or in using the Unrestricted_Access attribute to create ! pointers to non-aliased objects. But for any standard portable use of the access type it will work in a functionally correct manner and allow porting of existing ! code. Note that another way of forcing a thin pointer representation is to use a component size clause for the element size in an array, or a record representation clause for an access field in a record. @end table *************** representation clause for an access fiel *** 11702,11730 **** @noindent The VMS version of GNAT fully implements all the pragmas and attributes provided by DEC Ada 83, as well as providing the standard DEC Ada 83 ! libraries, including Starlet. In addition, data layouts and parameter ! passing conventions are highly compatible. This means that porting existing DEC Ada 83 code to GNAT in VMS systems should be easier than ! most other porting efforts. The following are some of the most significant differences between GNAT and DEC Ada 83. @table @asis @item Default floating-point representation In GNAT, the default floating-point format is IEEE, whereas in DEC Ada 83, ! it is VMS format. GNAT does implement the necessary pragmas (Long_Float, Float_Representation) for changing this default. @item System The package System in GNAT exactly corresponds to the definition in the Ada 95 reference manual, which means that it excludes many of the ! DEC Ada 83 extensions. However, a separate package Aux_DEC is provided that contains the additional definitions, and a special pragma, Extend_System allows this package to be treated transparently as an extension of package System. @item To_Address The definitions provided by Aux_DEC are exactly compatible with those ! in the DEC Ada 83 version of System, with one exception. DEC Ada provides the following declarations: @smallexample --- 11883,11911 ---- @noindent The VMS version of GNAT fully implements all the pragmas and attributes provided by DEC Ada 83, as well as providing the standard DEC Ada 83 ! libraries, including Starlet. In addition, data layouts and parameter ! passing conventions are highly compatible. This means that porting existing DEC Ada 83 code to GNAT in VMS systems should be easier than ! most other porting efforts. The following are some of the most significant differences between GNAT and DEC Ada 83. @table @asis @item Default floating-point representation In GNAT, the default floating-point format is IEEE, whereas in DEC Ada 83, ! it is VMS format. GNAT does implement the necessary pragmas (Long_Float, Float_Representation) for changing this default. @item System The package System in GNAT exactly corresponds to the definition in the Ada 95 reference manual, which means that it excludes many of the ! DEC Ada 83 extensions. However, a separate package Aux_DEC is provided that contains the additional definitions, and a special pragma, Extend_System allows this package to be treated transparently as an extension of package System. @item To_Address The definitions provided by Aux_DEC are exactly compatible with those ! in the DEC Ada 83 version of System, with one exception. DEC Ada provides the following declarations: @smallexample *************** TO_ADDRESS(universal_integer) *** 11737,11743 **** The version of TO_ADDRESS taking a universal integer argument is in fact an extension to Ada 83 not strictly compatible with the reference manual. In GNAT, we are constrained to be exactly compatible with the standard, ! and this means we cannot provide this capability. In DEC Ada 83, the point of this definition is to deal with a call like: @smallexample --- 11918,11924 ---- The version of TO_ADDRESS taking a universal integer argument is in fact an extension to Ada 83 not strictly compatible with the reference manual. In GNAT, we are constrained to be exactly compatible with the standard, ! and this means we cannot provide this capability. In DEC Ada 83, the point of this definition is to deal with a call like: @smallexample *************** point of this definition is to deal with *** 11747,11757 **** @noindent Normally, according to the Ada 83 standard, one would expect this to be ambiguous, since it matches both the INTEGER and UNSIGNED_LONGWORD forms ! of TO_ADDRESS@. However, in DEC Ada 83, there is no ambiguity, since the definition using universal_integer takes precedence. In GNAT, since the version with universal_integer cannot be supplied, it is ! not possible to be 100% compatible. Since there are many programs using numeric constants for the argument to TO_ADDRESS, the decision in GNAT was to change the name of the function in the UNSIGNED_LONGWORD case, so the declarations provided in the GNAT version of AUX_Dec are: --- 11928,11938 ---- @noindent Normally, according to the Ada 83 standard, one would expect this to be ambiguous, since it matches both the INTEGER and UNSIGNED_LONGWORD forms ! of TO_ADDRESS@. However, in DEC Ada 83, there is no ambiguity, since the definition using universal_integer takes precedence. In GNAT, since the version with universal_integer cannot be supplied, it is ! not possible to be 100% compatible. Since there are many programs using numeric constants for the argument to TO_ADDRESS, the decision in GNAT was to change the name of the function in the UNSIGNED_LONGWORD case, so the declarations provided in the GNAT version of AUX_Dec are: *************** which in GNAT is treated like any other *** 11776,11787 **** @end table For full details on these and other less significant compatibility issues, ! see appendix E of the Digital publication entitled "DEC Ada, Technical ! Overview and Comparison on DIGITAL Platforms". For GNAT running on other than VMS systems, all the DEC Ada 83 pragmas and attributes are recognized, although only a subset of them can sensibly ! be implemented. The description of pragmas in this reference manual indicates whether or not they are applicable to non-VMS systems. @include fdl.texi --- 11957,11968 ---- @end table For full details on these and other less significant compatibility issues, ! see appendix E of the Digital publication entitled @cite{DEC Ada, Technical ! Overview and Comparison on DIGITAL Platforms}. For GNAT running on other than VMS systems, all the DEC Ada 83 pragmas and attributes are recognized, although only a subset of them can sensibly ! be implemented. The description of pragmas in this reference manual indicates whether or not they are applicable to non-VMS systems. @include fdl.texi diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat-style.info gcc-3.3/gcc/ada/gnat-style.info *** gcc-3.2.3/gcc/ada/gnat-style.info 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat-style.info 2003-05-14 00:31:47.000000000 +0000 *************** *** 0 **** --- 1,483 ---- + This is ada/gnat-style.info, produced by makeinfo version 4.2 from + ada/gnat-style.texi. + + INFO-DIR-SECTION Programming + START-INFO-DIR-ENTRY + * gnat-style: (gnat-style). GNAT Coding Style + END-INFO-DIR-ENTRY + + GNAT Coding Style + A guide for GNAT developers + Copyright (C) + 1992-2001 Ada Core Technologies, Inc. + +  + File: gnat-style.info, Node: Top, Next: General, Up: (dir) + + * Menu: + + * General:: + * Lexical Elements:: + * Declarations and Types:: + * Expressions and Names:: + * Statements:: + * Subprograms:: + * Packages:: + * Program Structure:: + +  + File: gnat-style.info, Node: General, Next: Lexical Elements, Prev: Top, Up: Top + + General + ******* + + Most of GNAT is written in Ada using a consistent style to ensure + readability of the code. This document has been written to help + maintain this consistent style, while having a large group of developers + work on the compiler. + + For the coding style in the C parts of the compiler and run time, see + the GNU Coding Guidelines. + + This document is structured after the Ada Reference manual. Those + familiar with that document should be able to quickly lookup style + rules for particular constructs. + +  + File: gnat-style.info, Node: Lexical Elements, Next: Declarations and Types, Prev: General, Up: Top + + Lexical Elements + **************** + + Character Set and Separators + ============================ + + * The character set used should be plain 7-bit ASCII. The only + separators allowed are space and the end-of-line sequence. No + other control character or format effector (such as HT, VT, FF) + should be used. The normal end-of-line sequence is used, which + may be LF, CR/LF or CR, depending on the host system. An optional + SUB (16#1A#) may be present as the last character in the file on + hosts using that character as file terminator. + + * Files that are checked in or distributed should be in host format. + + * A line should never be longer than 79 characters, not counting the + line separator. + + * Lines must not have trailing blanks. + + * Indentation is 3 characters per level for if statements, loops, + case statements. For exact information on required spacing + between lexical elements, see file `style.adb'. + + + Identifiers + =========== + + * Identifiers will start with an upper case letter, and each letter + following an underscore will be upper case. Short acronyms may be + all upper case. All other letters are lower case. An exception + is for identifiers matching a foreign language. In particular, we + use all lower case where appropriate for C. + + * Use underscores to separate words in an identifier. + + * Try to limit your use of abbreviations in identifiers. It is ok + to make a few abbreviations, explain what they mean, and then use + them frequently, but don't use lots of obscure abbreviations. An + example is the `ALI' word which stands for Ada Library Information + and is by convention always written in upper-case when used in + entity names. + + procedure Find_ALI_Files; + + * Don't use the variable `I', use `J' instead, `I' is too easily + mixed up with `1' in some fonts. Similarly don't use the variable + `O', which is too easily mixed up with `0'. + + Numeric Literals + ================ + + * Numeric literals should include underscores where helpful for + readability. + + 1_000_000 + 16#8000_000# + 3.14159_26535_89793_23846 + + Reserved Words + ============== + + * Reserved words use all lower case. + + return else + + * The words `Access', `Delta' and `Digits' are capitalized when used + as attribute_designator. + + Comments + ======== + + * Comment start with `-- ' (i.e. `--' followed by two spaces). The + only exception to this rule (i.e. one space is tolerated) is when + the comment ends with ` --'. It also accepted to have only one + space between `--' and the start of the comment when the comment + is at the end of a line, after some Ada code. + + * Every sentence in a comment should start with an upper-case letter + (including the first letter of the comment). + + * When declarations are commented with "hanging" comments, i.e. + comments after the declaration, there is no blank line before the + comment, and if it is absolutely necessary to have blank lines + within the comments these blank lines _do_ have a `--' (unlike the + normal rule, which is to use entirely blank lines for separating + comment paragraphs). The comment start at same level of + indentation as code they are commenting. + + z : Integer; + -- Integer value for storing value of z + -- + -- The previous line was a blank line. + + * Comments that are dubious or incomplete or comment on possibly + wrong or incomplete code should be preceded or followed by `???'. + + * Comments in a subprogram body must generally be surrounded by + blank lines, except after a `begin': + + begin + -- Comment for the next statement + + A := 5; + + -- Comment for the B statement + + B := 6; + + * In sequences of statements, comments at the end of the lines + should be aligned. + + My_Identifier := 5; -- First comment + Other_Id := 6; -- Second comment + + * Short comments that fit on a single line are _not_ ended with a + period. Comments taking more than a line are punctuated in the + normal manner. + + * Comments should focus on why instead of what. Descriptions of + what subprograms do go with the specification. + + * Comments describing a subprogram spec should specifically mention + the formal argument names. General rule: write a comment that + does not depend on the names of things. The names are + supplementary, not sufficient, as comments. + + * Do NOT put two spaces after periods in comments. + +  + File: gnat-style.info, Node: Declarations and Types, Next: Expressions and Names, Prev: Lexical Elements, Up: Top + + Declarations and Types + ********************** + + * In entity declarations, colons must be surrounded by spaces. + Colons should be aligned. + + Entity1 : Integer; + My_Entity : Integer; + + * Declarations should be grouped in a logical order. Related groups + of declarations may be preceded by a header comment. + + * All local subprograms in a subprogram or package body should be + declared before the first local subprogram body. + + * Don't declare local entities that hide global entities. + + * Don't declare multiple variables in one declaration that spans + lines. Start a new declaration on each line, instead. + + * The defining_identifiers of global declarations serve as comments + of a sort. So don't choose terse names, but look for names that + give useful information instead. + + * Local names can be shorter, because they are used only within one + context, where comments explain their purpose. + + +  + File: gnat-style.info, Node: Expressions and Names, Next: Statements, Prev: Declarations and Types, Up: Top + + Expressions and Names + ********************* + + * Every operator must be surrounded by spaces, except for the + exponentiation operator. + + E := A * B**2 + 3 * (C - D); + + * When folding a long line, fold before an operator, not after. + + * Use parentheses where they make the intended order of evaluation + clearer: + (A / B) * C + +  + File: gnat-style.info, Node: Statements, Next: Subprograms, Prev: Expressions and Names, Up: Top + + Statements + ********** + + Simple and Compound Statements + ============================== + + * Use only one statement or label per line. + + * A longer sequence_of_statements may be divided in logical groups + or separated from surrounding code using a blank line. + + If Statements + ============= + + * When the `if', `elsif' or `else' keywords fit on the same line + with the condition and the `then' keyword, then the statement is + formatted as follows: + + if CONDITION then + ... + elsif CONDITION then + ... + else + ... + end if; + + When the above layout is not possible, `then' should be aligned + with `if', and conditions should preferably be split before an + `and' or `or' keyword a follows: + + if LONG_CONDITION_THAT_HAS_TO_BE_SPLIT + and then CONTINUED_ON_THE_NEXT_LINE + then + ... + end if; + + The `elsif', `else' and `end if' always line up with the `if' + keyword. The preferred location for splitting the line is before + `and' or `or'. The continuation of a condition is indented with + two spaces or as many as needed to make nesting clear. As + exception, if conditions are closely related either of the + following is allowed: + + if x = lakdsjfhlkashfdlkflkdsalkhfsalkdhflkjdsahf + or else + x = asldkjhalkdsjfhhfd + or else + x = asdfadsfadsf + then + + if x = lakdsjfhlkashfdlkflkdsalkhfsalkdhflkjdsahf or else + x = asldkjhalkdsjfhhfd or else + x = asdfadsfadsf + then + + * Conditions should use short-circuit forms (`and then', `or else'). + + * Complex conditions in if statements are indented two characters: + + if THIS_COMPLEX_CONDITION + and then THAT_OTHER_ONE + and then ONE_LAST_ONE + then + ... + + * Every `if' block is preceded and followed by a blank line, except + where it begins or ends a sequence_of_statements. + + A := 5; + + if A = 5 then + null; + end if; + + A := 6; + + Case Statements + =============== + + * Layout is as below. For long case statements, the extra + indentation can be saved by aligning the when clauses with the + opening case. + + case EXPRESSION is + when CONDITION => + ... + when CONDITION => + ... + end case; + + Loop Statements + =============== + + When possible, have `for' or `while' on one line with the + condition and the `loop' keyword. + + for J in S'Range loop + ... + end loop; + + If the condition is too long, split the condition (see "If + statements" above) and align `loop' with the `for' or `while' + keyword. + + while LONG_CONDITION_THAT_HAS_TO_BE_SPLIT + and then CONTINUED_ON_THE_NEXT_LINE + loop + ... + end loop; + + If the loop_statement has an identifier, it is laid out as follows: + + Outer : while not CONDITION loop + ... + end Outer; + + Block Statements + ================ + + * The `declare' (optional), `begin' and `end' statements are + aligned, except when the block_statement is named. There is a + blank line before the `begin' keyword: + + Some_Block : declare + ... + + begin + ... + end Some_Block; + + +  + File: gnat-style.info, Node: Subprograms, Next: Packages, Prev: Statements, Up: Top + + Subprograms + *********** + + Subprogram Declarations + ======================= + + * Do not write the `in' for parameters, especially in functions: + + function Length (S : String) return Integer; + + * When the declaration line for a procedure or a function is too + long, fold it. In this case, align the colons, and, for + functions, the result type. + + function Head + (Source : String; + Count : Natural; + Pad : Character := Space) + return String; + + * The parameter list for a subprogram is preceded by a space: + + procedure Func (A : Integer); + + + Subprogram Bodies + ================= + + * The functions and procedures should always be sorted + alphabetically in a compilation unit. + + * All subprograms have a header giving the function name, with the + following format: + + ----------------- + -- My_Function -- + ----------------- + + procedure My_Function is + begin + + Note that the name in the header is preceded by a single space, + not two spaces as for other comments. + + * Every subprogram body must have a preceding subprogram_declaration. + + * If there any declarations in a subprogram, the `begin' keyword is + preceded by a blank line. + + * If the declarations in a subprogram contain at least one nested + subprogram body, then just before the of the enclosing subprogram + `begin', there is a line: + + -- Start of processing for ENCLOSING_SUBPROGRAM + + begin + + +  + File: gnat-style.info, Node: Packages, Next: Program Structure, Prev: Subprograms, Up: Top + + Packages and Visibility Rules + ***************************** + + * All program units and subprograms have their name at the end: + + package P is + ... + end P; + + * We will use the style of `use'-ing `with'-ed packages, with the + context clauses looking like: + + with A; use A; + with B; use B; + + * Names declared in the visible part of packages should be unique, + to prevent name clashes when the packages are `use'd. + + package Entity is + type Entity_Kind is ...; + ... + end Entity; + + * After the file header comment, the context clause and unit + specification should be the first thing in a program_unit. + +  + File: gnat-style.info, Node: Program Structure, Prev: Packages, Up: Top + + Program Structure and Compilation Issues + **************************************** + + * Every GNAT source file must be compiled with the `-gnatg' switch + to check the coding style (Note that you should look at + `style.adb' to see the lexical rules enforced by `-gnatg'). + + * Each source file should contain only one compilation unit. + + * Filenames should be 8 characters or less followed by the `.adb' + extension for a body or `.ads' for a spec. + + * Unit names should be distinct when krunched to 8 characters (see + `krunch.ads') and the filenames should match the unit name, except + that they are all lower case. + + +  + Tag Table: + Node: Top369 + Node: General596 + Node: Lexical Elements1194 + Node: Declarations and Types6078 + Node: Expressions and Names7174 + Node: Statements7659 + Node: Subprograms11650 + Node: Packages13383 + Node: Program Structure14236 +  + End Tag Table diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat-style.texi gcc-3.3/gcc/ada/gnat-style.texi *** gcc-3.2.3/gcc/ada/gnat-style.texi 2001-12-23 11:23:14.000000000 +0000 --- gcc-3.3/gcc/ada/gnat-style.texi 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** @c o @c G N A T C O D I N G S T Y L E o @c o - @c $Revision: 1.5 $ @c o @c Copyright (C) 1992-2001 Ada Core Technologies, Inc. o @c o --- 6,11 ---- *************** *** 46,52 **** @sp 10 @title GNAT Coding Style @subtitle A guide for GNAT developers - @subtitle Document revision level $Revision: 1.5 $ @author Ada Core Technologies, Inc. @end titlepage @raisesections --- 45,50 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_ug.texi gcc-3.3/gcc/ada/gnat_ug.texi *** gcc-3.2.3/gcc/ada/gnat_ug.texi 2002-05-04 03:28:06.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_ug.texi 2003-02-04 01:55:39.000000000 +0000 *************** *** 7,14 **** @c o @c G N A T _ U G o @c o - @c $Revision: 1.1.2.2 $ - @c o @c Copyright (C) 1992-2002 Ada Core Technologies, Inc. o @c o @c GNAT is free software; you can redistribute it and/or modify it under o --- 7,12 ---- *************** *** 54,80 **** @c @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo - @setfilename gnat_ug.info @ifset vms @settitle GNAT User's Guide for OpenVMS Alpha @end ifset @ifset wnt @settitle GNAT User's Guide for Windows NT @end ifset @ifset unx @settitle GNAT User's Guide for Unix Platforms @end ifset @ifset vxworks @settitle GNAT User's Guide for Cross Platforms @end ifset @setchapternewpage odd @syncodeindex fn cp @c %**end of header @titlepage @ifset vms --- 52,108 ---- @c @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo @ifset vms + @setfilename gnat_ug_vms.info @settitle GNAT User's Guide for OpenVMS Alpha @end ifset @ifset wnt + @setfilename gnat_ug_wnt.info @settitle GNAT User's Guide for Windows NT @end ifset @ifset unx + @setfilename gnat_ug_unx.info @settitle GNAT User's Guide for Unix Platforms @end ifset @ifset vxworks + @setfilename gnat_ug_vxw.info @settitle GNAT User's Guide for Cross Platforms @end ifset + @include gcc-common.texi + @setchapternewpage odd @syncodeindex fn cp @c %**end of header + @copying + Copyright @copyright{} 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with the Invariant Sections being ``GNU Free Documentation License'', with the + Front-Cover Texts being + @ifset vms + ``GNAT User's Guide for OpenVMS Alpha'', + @end ifset + @ifset wnt + ``GNAT User's Guide for Windows NT'', + @end ifset + @ifset unx + ``GNAT User's Guide for Unix Platforms'', + @end ifset + @ifset vxworks + ``GNAT User's Guide for Cross Platforms'', + @end ifset + and with no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + @end copying + @titlepage @ifset vms *************** *** 98,138 **** @end ifset @subtitle GNAT, The GNU Ada 95 Compiler ! @subtitle Document revision level $Revision: 1.1.2.2 $ ! @subtitle GNAT Version 3.16w ! @subtitle Date: $Date: 2002/05/04 03:28:06 $ @author Ada Core Technologies, Inc. @page @vskip 0pt plus 1filll ! Copyright @copyright{} 1995-2002, Free Software Foundation ! ! Permission is granted to copy, distribute and/or modify this document ! under the terms of the GNU Free Documentation License, Version 1.1 ! or any later version published by the Free Software Foundation; ! with the Invariant Sections being ``GNU Free Documentation License'', with the ! Front-Cover Texts being ! @ifset vms ! ``GNAT User's Guide for OpenVMS Alpha'', ! @end ifset ! @ifset wnt ! ``GNAT User's Guide for Windows NT'', ! @end ifset ! @ifset unx ! ``GNAT User's Guide for Unix Platforms'', ! @end ifset ! @ifset vxworks ! ``GNAT User's Guide for Cross Platforms'', ! @end ifset ! and with no Back-Cover Texts. ! A copy of the license is included in the section entitled ``GNU ! Free Documentation License''. @end titlepage ! @ifinfo @node Top, About This Guide, (dir), (dir) @top GNAT User's Guide --- 126,143 ---- @end ifset @subtitle GNAT, The GNU Ada 95 Compiler ! @subtitle GNAT Version for GCC @value{version-GCC} @author Ada Core Technologies, Inc. @page @vskip 0pt plus 1filll ! @insertcopying @end titlepage ! @ifnottex @node Top, About This Guide, (dir), (dir) @top GNAT User's Guide *************** GNAT User's Guide for Cross Platforms *** 154,187 **** GNAT, The GNU Ada 95 Compiler ! GNAT Version 3.16w ! ! Date: $Date: 2002/05/04 03:28:06 $ Ada Core Technologies, Inc. ! Copyright @copyright{} 1995-2002, Free Software Foundation ! ! Permission is granted to copy, distribute and/or modify this document ! under the terms of the GNU Free Documentation License, Version 1.1 ! or any later version published by the Free Software Foundation; ! with the Invariant Sections being ``GNU Free Documentation License'', with the ! Front-Cover Texts being ! @ifset vms ! ``GNAT User's Guide for OpenVMS Alpha'', ! @end ifset ! @ifset wnt ! ``GNAT User's Guide for Windows NT'', ! @end ifset ! @ifset unx ! ``GNAT User's Guide for Unix Platforms'', ! @end ifset ! @ifset vxworks ! ``GNAT User's Guide for Cross Platforms'', ! @end ifset ! and with no Back-Cover Texts. ! A copy of the license is included in the section entitled ``GNU ! Free Documentation License''. @menu * About This Guide:: --- 159,169 ---- GNAT, The GNU Ada 95 Compiler ! GNAT Version for GCC @value{version-GCC} Ada Core Technologies, Inc. ! @insertcopying @menu * About This Guide:: *************** Performance Considerations *** 623,629 **** * Index:: @end menu ! @end ifinfo @node About This Guide @unnumbered About This Guide --- 605,611 ---- * Index:: @end menu ! @end ifnottex @node About This Guide @unnumbered About This Guide diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_ug_unx.info gcc-3.3/gcc/ada/gnat_ug_unx.info *** gcc-3.2.3/gcc/ada/gnat_ug_unx.info 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_ug_unx.info 2003-05-14 00:31:45.000000000 +0000 *************** *** 0 **** --- 1,17759 ---- + This is ada/gnat_ug_unx.info, produced by makeinfo version 4.2 from + ada/gnat_ug_unx.texi. + + Copyright (C) 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT User's Guide for Unix Platforms", and + with no Back-Cover Texts. A copy of the license is included in the + section entitled "GNU Free Documentation License". +  + File: gnat_ug_unx.info, Node: Top, Next: About This Guide, Prev: (dir), Up: (dir) + + GNAT User's Guide + ***************** + + GNAT User's Guide for Unix Platforms + + GNAT, The GNU Ada 95 Compiler + + GNAT Version for GCC 3.3 + + Ada Core Technologies, Inc. + + Copyright (C) 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT User's Guide for Unix Platforms", and + with no Back-Cover Texts. A copy of the license is included in the + section entitled "GNU Free Documentation License". + * Menu: + + * About This Guide:: + * Getting Started with GNAT:: + * The GNAT Compilation Model:: + * Compiling Using gcc:: + * Binding Using gnatbind:: + * Linking Using gnatlink:: + * The GNAT Make Program gnatmake:: + * Renaming Files Using gnatchop:: + * Configuration Pragmas:: + * Handling Arbitrary File Naming Conventions Using gnatname:: + * GNAT Project Manager:: + * Elaboration Order Handling in GNAT:: + * The Cross-Referencing Tools gnatxref and gnatfind:: + * File Name Krunching Using gnatkr:: + * Preprocessing Using gnatprep:: + * The GNAT Library Browser gnatls:: + * GNAT and Libraries:: + * Using the GNU make Utility:: + * Finding Memory Problems with gnatmem:: + * Finding Memory Problems with GNAT Debug Pool:: + * Creating Sample Bodies Using gnatstub:: + * Reducing the Size of Ada Executables with gnatelim:: + * Other Utility Programs:: + * Running and Debugging Ada Programs:: + * Inline Assembler:: + * Performance Considerations:: + * GNU Free Documentation License:: + * Index:: + + --- The Detailed Node Listing --- + + About This Guide + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + + + Getting Started with GNAT + + * Running GNAT:: + * Running a Simple Ada Program:: + * Running a Program with Multiple Units:: + * Using the gnatmake Utility:: + + The GNAT Compilation Model + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + Foreign Language Representation + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + + Compiling Ada Programs With gcc + + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + + Switches for gcc + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + Binding Ada Programs With gnatbind + + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + + Linking Using gnatlink + + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + + The GNAT Make Program gnatmake + + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + + Renaming Files Using gnatchop + + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + + Configuration Pragmas + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + + Handling Arbitrary File Naming Conventions Using gnatname + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + + GNAT Project Manager + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + + Elaboration Order Handling in GNAT + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + The Cross-Referencing Tools gnatxref and gnatfind + + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + + File Name Krunching Using gnatkr + + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + + Preprocessing Using gnatprep + + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + + + The GNAT Library Browser gnatls + + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + + + GNAT and Libraries + + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + + Using the GNU make Utility + + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + + Finding Memory Problems with gnatmem + + * Running gnatmem (GDB Mode):: + * Running gnatmem (GMEM Mode):: + * Switches for gnatmem:: + * Examples of gnatmem Usage:: + * GDB and GMEM Modes:: + * Implementation Note:: + + + Finding Memory Problems with GNAT Debug Pool + + Creating Sample Bodies Using gnatstub + + * Running gnatstub:: + * Switches for gnatstub:: + + Reducing the Size of Ada Executables with gnatelim + + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + + Other Utility Programs + + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + + + Running and Debugging Ada Programs + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + + Inline Assembler + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + + + + Performance Considerations + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + + * Index:: + +  + File: gnat_ug_unx.info, Node: About This Guide, Next: Getting Started with GNAT, Prev: Top, Up: Top + + About This Guide + **************** + + This guide describes the use of GNAT, a compiler and software + development toolset for the full Ada 95 programming language. It + describes the features of the compiler and tools, and details how to + use them to build Ada 95 applications. + + * Menu: + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + +  + File: gnat_ug_unx.info, Node: What This Guide Contains, Next: What You Should Know before Reading This Guide, Up: About This Guide + + What This Guide Contains + ======================== + + This guide contains the following chapters: + * *Note Getting Started with GNAT::, describes how to get started + compiling and running Ada programs with the GNAT Ada programming + environment. + + * *Note The GNAT Compilation Model::, describes the compilation + model used by GNAT. + + * *Note Compiling Using gcc::, describes how to compile Ada programs + with `gcc', the Ada compiler. + + * *Note Binding Using gnatbind::, describes how to perform binding + of Ada programs with `gnatbind', the GNAT binding utility. + + * *Note Linking Using gnatlink::, describes `gnatlink', a program + that provides for linking using the GNAT run-time library to + construct a program. `gnatlink' can also incorporate foreign + language object units into the executable. + + * *Note The GNAT Make Program gnatmake::, describes `gnatmake', a + utility that automatically determines the set of sources needed by + an Ada compilation unit, and executes the necessary compilations + binding and link. + + * *Note Renaming Files Using gnatchop::, describes `gnatchop', a + utility that allows you to preprocess a file that contains Ada + source code, and split it into one or more new files, one for each + compilation unit. + + * *Note Configuration Pragmas::, describes the configuration pragmas + handled by GNAT. + + * *Note Handling Arbitrary File Naming Conventions Using gnatname::, + shows how to override the default GNAT file naming conventions, + either for an individual unit or globally. + + * *Note GNAT Project Manager::, describes how to use project files + to organize large projects. + + * *Note Elaboration Order Handling in GNAT::, describes how GNAT + helps you deal with elaboration order issues. + + * *Note The Cross-Referencing Tools gnatxref and gnatfind::, + discusses `gnatxref' and `gnatfind', two tools that provide an easy + way to navigate through sources. + + * *Note File Name Krunching Using gnatkr::, describes the `gnatkr' + file name krunching utility, used to handle shortened file names + on operating systems with a limit on the length of names. + + * *Note Preprocessing Using gnatprep::, describes `gnatprep', a + preprocessor utility that allows a single source file to be used to + generate multiple or parameterized source files, by means of macro + substitution. + + * *Note The GNAT Library Browser gnatls::, describes `gnatls', a + utility that displays information about compiled units, including + dependences on the corresponding sources files, and consistency of + compilations. + + * *Note GNAT and Libraries::, describes the process of creating and + using Libraries with GNAT. It also describes how to recompile the + GNAT run-time library. + + * *Note Using the GNU make Utility::, describes some techniques for + using the GNAT toolset in Makefiles. + + * *Note Finding Memory Problems with gnatmem::, describes `gnatmem', + a utility that monitors dynamic allocation and deallocation + activity in a program, and displays information about incorrect + deallocations and sources of possible memory leaks. + + * *Note Finding Memory Problems with GNAT Debug Pool::, describes + how to use the GNAT-specific Debug Pool in order to detect as + early as possible the use of incorrect memory references. + + * *Note Creating Sample Bodies Using gnatstub::, discusses + `gnatstub', a utility that generates empty but compilable bodies + for library units. + + * *Note Reducing the Size of Ada Executables with gnatelim::, + describes `gnatelim', a tool which detects unused subprograms and + helps the compiler to create a smaller executable for the program. + + * *Note Other Utility Programs::, discusses several other GNAT + utilities, including `gnatpsta'. + + * *Note Running and Debugging Ada Programs::, describes how to run + and debug Ada programs. + + * *Note Inline Assembler::, shows how to use the inline assembly + facility in an Ada program. + + * *Note Performance Considerations::, reviews the trade offs between + using defaults or options in program development. + +  + File: gnat_ug_unx.info, Node: What You Should Know before Reading This Guide, Next: Related Information, Prev: What This Guide Contains, Up: About This Guide + + What You Should Know before Reading This Guide + ============================================== + + This user's guide assumes that you are familiar with Ada 95 language, as + described in the International Standard ANSI/ISO/IEC-8652:1995, Jan + 1995. + +  + File: gnat_ug_unx.info, Node: Related Information, Next: Conventions, Prev: What You Should Know before Reading This Guide, Up: About This Guide + + Related Information + =================== + + For further information about related tools, refer to the following + documents: + + * `GNAT Reference Manual', which contains all reference material for + the GNAT implementation of Ada 95. + + * `Ada 95 Language Reference Manual', which contains all reference + material for the Ada 95 programming language. + + * `Debugging with GDB' contains all details on the use of the GNU + source-level debugger. + + * `GNU Emacs Manual' contains full information on the extensible + editor and programming environment Emacs. + + +  + File: gnat_ug_unx.info, Node: Conventions, Prev: Related Information, Up: About This Guide + + Conventions + =========== + + Following are examples of the typographical and graphic conventions used + in this guide: + + * `Functions', `utility program names', `standard names', and + `classes'. + + * `Option flags' + + * `File Names', `button names', and `field names'. + + * VARIABLES. + + * _Emphasis_. + + * [optional information or parameters] + + * Examples are described by text + and then shown this way. + + Commands that are entered by the user are preceded in this manual by the + characters "`$ '" (dollar sign followed by space). If your system uses + this sequence as a prompt, then the commands will appear exactly as you + see them in the manual. If your system uses some other prompt, then the + command will appear with the `$' replaced by whatever prompt character + you are using. + +  + File: gnat_ug_unx.info, Node: Getting Started with GNAT, Next: The GNAT Compilation Model, Prev: About This Guide, Up: Top + + Getting Started with GNAT + ************************* + + This chapter describes some simple ways of using GNAT to build + executable Ada programs. + + * Menu: + + * Running GNAT:: + * Running a Simple Ada Program:: + + * Running a Program with Multiple Units:: + + * Using the gnatmake Utility:: + * Introduction to Glide and GVD:: + +  + File: gnat_ug_unx.info, Node: Running GNAT, Next: Running a Simple Ada Program, Up: Getting Started with GNAT + + Running GNAT + ============ + + Three steps are needed to create an executable file from an Ada source + file: + + 1. The source file(s) must be compiled. + + 2. The file(s) must be bound using the GNAT binder. + + 3. All appropriate object files must be linked to produce an + executable. + + All three steps are most commonly handled by using the `gnatmake' + utility program that, given the name of the main program, automatically + performs the necessary compilation, binding and linking steps. + +  + File: gnat_ug_unx.info, Node: Running a Simple Ada Program, Next: Running a Program with Multiple Units, Prev: Running GNAT, Up: Getting Started with GNAT + + Running a Simple Ada Program + ============================ + + Any text editor may be used to prepare an Ada program. If `Glide' is + used, the optional Ada mode may be helpful in laying out the program. + The program text is a normal text file. We will suppose in our initial + example that you have used your editor to prepare the following + standard format text file: + + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + Put_Line ("Hello WORLD!"); + end Hello; + + This file should be named `hello.adb'. With the normal default file + naming conventions, GNAT requires that each file contain a single + compilation unit whose file name is the unit name, with periods + replaced by hyphens; the extension is `ads' for a spec and `adb' for a + body. You can override this default file naming convention by use of + the special pragma `Source_File_Name' (*note Using Other File Names::). + Alternatively, if you want to rename your files according to this + default convention, which is probably more convenient if you will be + using GNAT for all your compilations, then the `gnatchop' utility can + be used to generate correctly-named source files (*note Renaming Files + Using gnatchop::). + + You can compile the program using the following command (`$' is used + as the command prompt in the examples in this document): + + $ gcc -c hello.adb + + `gcc' is the command used to run the compiler. This compiler is capable + of compiling programs in several languages, including Ada 95 and C. It + assumes that you have given it an Ada program if the file extension is + either `.ads' or `.adb', and it will then call the GNAT compiler to + compile the specified file. + + The `-c' switch is required. It tells `gcc' to only do a + compilation. (For C programs, `gcc' can also do linking, but this + capability is not used directly for Ada programs, so the `-c' switch + must always be present.) + + This compile command generates a file `hello.o', which is the object + file corresponding to your Ada program. It also generates an "Ada + Library Information" file `hello.ali', which contains additional + information used to check that an Ada program is consistent. To build + an executable file, use `gnatbind' to bind the program and `gnatlink' + to link it. The argument to both `gnatbind' and `gnatlink' is the name + of the `ali' file, but the default extension of `.ali' can be omitted. + This means that in the most common case, the argument is simply the + name of the main program: + + $ gnatbind hello + $ gnatlink hello + + A simpler method of carrying out these steps is to use `gnatmake', a + master program that invokes all the required compilation, binding and + linking tools in the correct order. In particular, `gnatmake' + automatically recompiles any sources that have been modified since they + were last compiled, or sources that depend on such modified sources, so + that "version skew" is avoided. + + $ gnatmake hello.adb + + The result is an executable program called `hello', which can be run by + entering: + + $ hello + + assuming that the current directory is on the search path for + executable programs. + + and, if all has gone well, you will see + + Hello WORLD! + + appear in response to this command. + +  + File: gnat_ug_unx.info, Node: Running a Program with Multiple Units, Next: Using the gnatmake Utility, Prev: Running a Simple Ada Program, Up: Getting Started with GNAT + + Running a Program with Multiple Units + ===================================== + + Consider a slightly more complicated example that has three files: a + main program, and the spec and body of a package: + + package Greetings is + procedure Hello; + procedure Goodbye; + end Greetings; + + with Ada.Text_IO; use Ada.Text_IO; + package body Greetings is + procedure Hello is + begin + Put_Line ("Hello WORLD!"); + end Hello; + + procedure Goodbye is + begin + Put_Line ("Goodbye WORLD!"); + end Goodbye; + end Greetings; + + with Greetings; + procedure Gmain is + begin + Greetings.Hello; + Greetings.Goodbye; + end Gmain; + + Following the one-unit-per-file rule, place this program in the + following three separate files: + + `greetings.ads' + spec of package `Greetings' + + `greetings.adb' + body of package `Greetings' + + `gmain.adb' + body of main program + + To build an executable version of this program, we could use four + separate steps to compile, bind, and link the program, as follows: + + $ gcc -c gmain.adb + $ gcc -c greetings.adb + $ gnatbind gmain + $ gnatlink gmain + + Note that there is no required order of compilation when using GNAT. + In particular it is perfectly fine to compile the main program first. + Also, it is not necessary to compile package specs in the case where + there is an accompanying body; you only need to compile the body. If + you want to submit these files to the compiler for semantic checking + and not code generation, then use the `-gnatc' switch: + + $ gcc -c greetings.ads -gnatc + + Although the compilation can be done in separate steps as in the above + example, in practice it is almost always more convenient to use the + `gnatmake' tool. All you need to know in this case is the name of the + main program's source file. The effect of the above four commands can + be achieved with a single one: + + $ gnatmake gmain.adb + + In the next section we discuss the advantages of using `gnatmake' in + more detail. + +  + File: gnat_ug_unx.info, Node: Using the gnatmake Utility, Next: Introduction to Glide and GVD, Prev: Running a Program with Multiple Units, Up: Getting Started with GNAT + + Using the `gnatmake' Utility + ============================ + + If you work on a program by compiling single components at a time using + `gcc', you typically keep track of the units you modify. In order to + build a consistent system, you compile not only these units, but also + any units that depend on the units you have modified. For example, in + the preceding case, if you edit `gmain.adb', you only need to recompile + that file. But if you edit `greetings.ads', you must recompile both + `greetings.adb' and `gmain.adb', because both files contain units that + depend on `greetings.ads'. + + `gnatbind' will warn you if you forget one of these compilation + steps, so that it is impossible to generate an inconsistent program as a + result of forgetting to do a compilation. Nevertheless it is tedious and + error-prone to keep track of dependencies among units. One approach to + handle the dependency-bookkeeping is to use a makefile. However, + makefiles present maintenance problems of their own: if the + dependencies change as you change the program, you must make sure that + the makefile is kept up-to-date manually, which is also an error-prone + process. + + The `gnatmake' utility takes care of these details automatically. + Invoke it using either one of the following forms: + + $ gnatmake gmain.adb + $ gnatmake gmain + + The argument is the name of the file containing the main program; you + may omit the extension. `gnatmake' examines the environment, + automatically recompiles any files that need recompiling, and binds and + links the resulting set of object files, generating the executable + file, `gmain'. In a large program, it can be extremely helpful to use + `gnatmake', because working out by hand what needs to be recompiled can + be difficult. + + Note that `gnatmake' takes into account all the Ada 95 rules that + establish dependencies among units. These include dependencies that + result from inlining subprogram bodies, and from generic instantiation. + Unlike some other Ada make tools, `gnatmake' does not rely on the + dependencies that were found by the compiler on a previous compilation, + which may possibly be wrong when sources change. `gnatmake' determines + the exact set of dependencies from scratch each time it is run. + +  + File: gnat_ug_unx.info, Node: Introduction to Glide and GVD, Prev: Using the gnatmake Utility, Up: Getting Started with GNAT + + Introduction to Glide and GVD + ============================= + + Although it is possible to develop programs using only the command line + interface (`gnatmake', etc.) a graphical Interactive Development + Environment can make it easier for you to compose, navigate, and debug + programs. This section describes the main features of Glide, the GNAT + graphical IDE, and also shows how to use the basic commands in GVD, the + GNU Visual Debugger. Additional information may be found in the + on-line help for these tools. + + * Menu: + + * Building a New Program with Glide:: + * Simple Debugging with GVD:: + * Other Glide Features:: + +  + File: gnat_ug_unx.info, Node: Building a New Program with Glide, Next: Simple Debugging with GVD, Up: Introduction to Glide and GVD + + Building a New Program with Glide + --------------------------------- + + The simplest way to invoke Glide is to enter `glide' at the command + prompt. It will generally be useful to issue this as a background + command, thus allowing you to continue using your command window for + other purposes while Glide is running: + + $ glide& + + Glide will start up with an initial screen displaying the top-level + menu items as well as some other information. The menu selections are + as follows + * `Buffers' + + * `Files' + + * `Tools' + + * `Edit' + + * `Search' + + * `Mule' + + * `Glide' + + * `Help' + + For this introductory example, you will need to create a new Ada source + file. First, select the `Files' menu. This will pop open a menu with + around a dozen or so items. To create a file, select the `Open + file...' choice. Depending on the platform, you may see a pop-up + window where you can browse to an appropriate directory and then enter + the file name, or else simply see a line at the bottom of the Glide + window where you can likewise enter the file name. Note that in Glide, + when you attempt to open a non-existent file, the effect is to create a + file with that name. For this example enter `hello.adb' as the name of + the file. + + A new buffer will now appear, occupying the entire Glide window, + with the file name at the top. The menu selections are slightly + different from the ones you saw on the opening screen; there is an + `Entities' item, and in place of `Glide' there is now an `Ada' item. + Glide uses the file extension to identify the source language, so `adb' + indicates an Ada source file. + + You will enter some of the source program lines explicitly, and use + the syntax-oriented template mechanism to enter other lines. First, + type the following text: + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + + Observe that Glide uses different colors to distinguish reserved words + from identifiers. Also, after the `procedure Hello is' line, the + cursor is automatically indented in anticipation of declarations. When + you enter `begin', Glide recognizes that there are no declarations and + thus places `begin' flush left. But after the `begin' line the cursor + is again indented, where the statement(s) will be placed. + + The main part of the program will be a `for' loop. Instead of + entering the text explicitly, however, use a statement template. + Select the `Ada' item on the top menu bar, move the mouse to the + `Statements' item, and you will see a large selection of alternatives. + Choose `for loop'. You will be prompted (at the bottom of the buffer) + for a loop name; simply press the key since a loop name is not + needed. You should see the beginning of a `for' loop appear in the + source program window. You will now be prompted for the name of the + loop variable; enter a line with the identifier `ind' (lower case). + Note that, by default, Glide capitalizes the name (you can override + such behavior if you wish, although this is outside the scope of this + introduction). Next, Glide prompts you for the loop range; enter a + line containing `1..5' and you will see this also appear in the source + program, together with the remaining elements of the `for' loop syntax. + + Next enter the statement (with an intentional error, a missing + semicolon) that will form the body of the loop: + Put_Line("Hello, World" & Integer'Image(I)) + + Finally, type `end Hello;' as the last line in the program. Now save + the file: choose the `File' menu item, and then the `Save buffer' + selection. You will see a message at the bottom of the buffer + confirming that the file has been saved. + + You are now ready to attempt to build the program. Select the `Ada' + item from the top menu bar. Although we could choose simply to compile + the file, we will instead attempt to do a build (which invokes + `gnatmake') since, if the compile is successful, we want to build an + executable. Thus select `Ada build'. This will fail because of the + compilation error, and you will notice that the Glide window has been + split: the top window contains the source file, and the bottom window + contains the output from the GNAT tools. Glide allows you to navigate + from a compilation error to the source file position corresponding to + the error: click the middle mouse button (or simultaneously press the + left and right buttons, on a two-button mouse) on the diagnostic line + in the tool window. The focus will shift to the source window, and the + cursor will be positioned on the character at which the error was + detected. + + Correct the error: type in a semicolon to terminate the statement. + Although you can again save the file explicitly, you can also simply + invoke `Ada' => `Build' and you will be prompted to save the file. + This time the build will succeed; the tool output window shows you the + options that are supplied by default. The GNAT tools' output (e.g., + object and ALI files, executable) will go in the directory from which + Glide was launched. + + To execute the program, choose `Ada' and then `Run'. You should see + the program's output displayed in the bottom window: + + Hello, world 1 + Hello, world 2 + Hello, world 3 + Hello, world 4 + Hello, world 5 + +  + File: gnat_ug_unx.info, Node: Simple Debugging with GVD, Next: Other Glide Features, Prev: Building a New Program with Glide, Up: Introduction to Glide and GVD + + Simple Debugging with GVD + ------------------------- + + This section describes how to set breakpoints, examine/modify + variables, and step through execution. + + In order to enable debugging, you need to pass the `-g' switch to + both the compiler and to `gnatlink'. If you are using the command + line, passing `-g' to `gnatmake' will have this effect. You can then + launch GVD, e.g. on the `hello' program, by issuing the command: + + $ gvd hello + + If you are using Glide, then `-g' is passed to the relevant tools by + default when you do a build. Start the debugger by selecting the `Ada' + menu item, and then `Debug'. + + GVD comes up in a multi-part window. One pane shows the names of + files comprising your executable; another pane shows the source code of + the current unit (initially your main subprogram), another pane shows + the debugger output and user interactions, and the fourth pane (the + data canvas at the top of the window) displays data objects that you + have selected. + + To the left of the source file pane, you will notice green dots + adjacent to some lines. These are lines for which object code exists + and where breakpoints can thus be set. You set/reset a breakpoint by + clicking the green dot. When a breakpoint is set, the dot is replaced + by an `X' in a red circle. Clicking the circle toggles the breakpoint + off, and the red circle is replaced by the green dot. + + For this example, set a breakpoint at the statement where `Put_Line' + is invoked. + + Start program execution by selecting the `Run' button on the top + menu bar. (The `Start' button will also start your program, but it + will cause program execution to break at the entry to your main + subprogram.) Evidence of reaching the breakpoint will appear: the + source file line will be highlighted, and the debugger interactions + pane will display a relevant message. + + You can examine the values of variables in several ways. Move the + mouse over an occurrence of `Ind' in the `for' loop, and you will see + the value (now `1') displayed. Alternatively, right-click on `Ind' and + select `Display Ind'; a box showing the variable's name and value will + appear in the data canvas. + + Although a loop index is a constant with respect to Ada semantics, + you can change its value in the debugger. Right-click in the box for + `Ind', and select the `Set Value of Ind' item. Enter `2' as the new + value, and press `OK'. The box for `Ind' shows the update. + + Press the `Step' button on the top menu bar; this will step through + one line of program text (the invocation of `Put_Line'), and you can + observe the effect of having modified `Ind' since the value displayed + is `2'. + + Remove the breakpoint, and resume execution by selecting the `Cont' + button. You will see the remaining output lines displayed in the + debugger interaction window, along with a message confirming normal + program termination. + +  + File: gnat_ug_unx.info, Node: Other Glide Features, Prev: Simple Debugging with GVD, Up: Introduction to Glide and GVD + + Other Glide Features + -------------------- + + You may have observed that some of the menu selections contain + abbreviations; e.g., `(C-x C-f)' for `Open file...' in the `Files' + menu. These are _shortcut keys_ that you can use instead of selecting + menu items. The stands for ; thus `(C-x C-f)' means + followed by , and this sequence can be used instead of + selecting `Files' and then `Open file...'. + + To abort a Glide command, type . + + If you want Glide to start with an existing source file, you can + either launch Glide as above and then open the file via `Files' => + `Open file...', or else simply pass the name of the source file on the + command line: + + $ glide hello.adb& + + While you are using Glide, a number of _buffers_ exist. You create + some explicitly; e.g., when you open/create a file. Others arise as an + effect of the commands that you issue; e.g., the buffer containing the + output of the tools invoked during a build. If a buffer is hidden, you + can bring it into a visible window by first opening the `Buffers' menu + and then selecting the desired entry. + + If a buffer occupies only part of the Glide screen and you want to + expand it to fill the entire screen, then click in the buffer and then + select `Files' => `One Window'. + + If a window is occupied by one buffer and you want to split the + window to bring up a second buffer, perform the following steps: + * Select `Files' => `Split Window'; this will produce two windows + each of which holds the original buffer (these are not copies, but + rather different views of the same buffer contents) + + * With the focus in one of the windows, select the desired buffer + from the `Buffers' menu + + To exit from Glide, choose `Files' => `Exit'. + +  + File: gnat_ug_unx.info, Node: The GNAT Compilation Model, Next: Compiling Using gcc, Prev: Getting Started with GNAT, Up: Top + + The GNAT Compilation Model + ************************** + + * Menu: + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + This chapter describes the compilation model used by GNAT. Although + similar to that used by other languages, such as C and C++, this model + is substantially different from the traditional Ada compilation models, + which are based on a library. The model is initially described without + reference to the library-based model. If you have not previously used an + Ada compiler, you need only read the first part of this chapter. The + last section describes and discusses the differences between the GNAT + model and the traditional Ada compiler models. If you have used other + Ada compilers, this section will help you to understand those + differences, and the advantages of the GNAT model. + +  + File: gnat_ug_unx.info, Node: Source Representation, Next: Foreign Language Representation, Up: The GNAT Compilation Model + + Source Representation + ===================== + + Ada source programs are represented in standard text files, using + Latin-1 coding. Latin-1 is an 8-bit code that includes the familiar + 7-bit ASCII set, plus additional characters used for representing + foreign languages (*note Foreign Language Representation:: for support + of non-USA character sets). The format effector characters are + represented using their standard ASCII encodings, as follows: + + `VT' + Vertical tab, `16#0B#' + + `HT' + Horizontal tab, `16#09#' + + `CR' + Carriage return, `16#0D#' + + `LF' + Line feed, `16#0A#' + + `FF' + Form feed, `16#0C#' + + Source files are in standard text file format. In addition, GNAT will + recognize a wide variety of stream formats, in which the end of physical + physical lines is marked by any of the following sequences: `LF', `CR', + `CR-LF', or `LF-CR'. This is useful in accommodating files that are + imported from other operating systems. + + The end of a source file is normally represented by the physical end + of file. However, the control character `16#1A#' (`SUB') is also + recognized as signalling the end of the source file. Again, this is + provided for compatibility with other operating systems where this code + is used to represent the end of file. + + Each file contains a single Ada compilation unit, including any + pragmas associated with the unit. For example, this means you must + place a package declaration (a package "spec") and the corresponding + body in separate files. An Ada "compilation" (which is a sequence of + compilation units) is represented using a sequence of files. Similarly, + you will place each subunit or child unit in a separate file. + +  + File: gnat_ug_unx.info, Node: Foreign Language Representation, Next: File Naming Rules, Prev: Source Representation, Up: The GNAT Compilation Model + + Foreign Language Representation + =============================== + + GNAT supports the standard character sets defined in Ada 95 as well as + several other non-standard character sets for use in localized versions + of the compiler (*note Character Set Control::). + + * Menu: + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + +  + File: gnat_ug_unx.info, Node: Latin-1, Next: Other 8-Bit Codes, Up: Foreign Language Representation + + Latin-1 + ------- + + The basic character set is Latin-1. This character set is defined by ISO + standard 8859, part 1. The lower half (character codes `16#00#' ... + `16#7F#)' is identical to standard ASCII coding, but the upper half is + used to represent additional characters. These include extended letters + used by European languages, such as French accents, the vowels with + umlauts used in German, and the extra letter A-ring used in Swedish. + + For a complete list of Latin-1 codes and their encodings, see the + source file of library unit `Ada.Characters.Latin_1' in file + `a-chlat1.ads'. You may use any of these extended characters freely in + character or string literals. In addition, the extended characters that + represent letters can be used in identifiers. + +  + File: gnat_ug_unx.info, Node: Other 8-Bit Codes, Next: Wide Character Encodings, Prev: Latin-1, Up: Foreign Language Representation + + Other 8-Bit Codes + ----------------- + + GNAT also supports several other 8-bit coding schemes: + + Latin-2 + Latin-2 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-3 + Latin-3 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-4 + Latin-4 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-5 + Latin-4 letters (Cyrillic) allowed in identifiers, with uppercase + and lowercase equivalence. + + IBM PC (code page 437) + This code page is the normal default for PCs in the U.S. It + corresponds to the original IBM PC character set. This set has + some, but not all, of the extended Latin-1 letters, but these + letters do not have the same encoding as Latin-1. In this mode, + these letters are allowed in identifiers with uppercase and + lowercase equivalence. + + IBM PC (code page 850) + This code page is a modification of 437 extended to include all the + Latin-1 letters, but still not with the usual Latin-1 encoding. In + this mode, all these letters are allowed in identifiers with + uppercase and lowercase equivalence. + + Full Upper 8-bit + Any character in the range 80-FF allowed in identifiers, and all + are considered distinct. In other words, there are no uppercase + and lowercase equivalences in this range. This is useful in + conjunction with certain encoding schemes used for some foreign + character sets (e.g. the typical method of representing Chinese + characters on the PC). + + No Upper-Half + No upper-half characters in the range 80-FF are allowed in + identifiers. This gives Ada 83 compatibility for identifier names. + + For precise data on the encodings permitted, and the uppercase and + lowercase equivalences that are recognized, see the file `csets.adb' in + the GNAT compiler sources. You will need to obtain a full source release + of GNAT to obtain this file. + +  + File: gnat_ug_unx.info, Node: Wide Character Encodings, Prev: Other 8-Bit Codes, Up: Foreign Language Representation + + Wide Character Encodings + ------------------------ + + GNAT allows wide character codes to appear in character and string + literals, and also optionally in identifiers, by means of the following + possible encoding schemes: + + Hex Coding + In this encoding, a wide character is represented by the following + five character sequence: + + ESC a b c d + + Where `a', `b', `c', `d' are the four hexadecimal characters + (using uppercase letters) of the wide character code. For example, + ESC A345 is used to represent the wide character with code + `16#A345#'. This scheme is compatible with use of the full + Wide_Character set. + + Upper-Half Coding + The wide character with encoding `16#abcd#' where the upper bit is + on (in other words, "a" is in the range 8-F) is represented as two + bytes, `16#ab#' and `16#cd#'. The second byte cannot be a format + control character, but is not required to be in the upper half. + This method can be also used for shift-JIS or EUC, where the + internal coding matches the external coding. + + Shift JIS Coding + A wide character is represented by a two-character sequence, + `16#ab#' and `16#cd#', with the restrictions described for + upper-half encoding as described above. The internal character + code is the corresponding JIS character according to the standard + algorithm for Shift-JIS conversion. Only characters defined in the + JIS code set table can be used with this encoding method. + + EUC Coding + A wide character is represented by a two-character sequence + `16#ab#' and `16#cd#', with both characters being in the upper + half. The internal character code is the corresponding JIS + character according to the EUC encoding algorithm. Only characters + defined in the JIS code set table can be used with this encoding + method. + + UTF-8 Coding + A wide character is represented using UCS Transformation Format 8 + (UTF-8) as defined in Annex R of ISO 10646-1/Am.2. Depending on + the character value, the representation is a one, two, or three + byte sequence: + 16#0000#-16#007f#: 2#0xxxxxxx# + 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx# + 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx# + + where the xxx bits correspond to the left-padded bits of the + 16-bit character value. Note that all lower half ASCII characters + are represented as ASCII bytes and all upper half characters and + other wide characters are represented as sequences of upper-half + (The full UTF-8 scheme allows for encoding 31-bit characters as + 6-byte sequences, but in this implementation, all UTF-8 sequences + of four or more bytes length will be treated as illegal). + + Brackets Coding + In this encoding, a wide character is represented by the following + eight character sequence: + + [ " a b c d " ] + + Where `a', `b', `c', `d' are the four hexadecimal characters + (using uppercase letters) of the wide character code. For example, + ["A345"] is used to represent the wide character with code + `16#A345#'. It is also possible (though not required) to use the + Brackets coding for upper half characters. For example, the code + `16#A3#' can be represented as `["A3"]'. + + This scheme is compatible with use of the full Wide_Character set, + and is also the method used for wide character encoding in the + standard ACVC (Ada Compiler Validation Capability) test suite + distributions. + + Note: Some of these coding schemes do not permit the full use of the + Ada 95 character set. For example, neither Shift JIS, nor EUC allow the + use of the upper half of the Latin-1 set. + +  + File: gnat_ug_unx.info, Node: File Naming Rules, Next: Using Other File Names, Prev: Foreign Language Representation, Up: The GNAT Compilation Model + + File Naming Rules + ================= + + The default file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + lowercase for all letters. + + An exception arises if the file name generated by the above rules + starts with one of the characters a,g,i, or s, and the second character + is a minus. In this case, the character tilde is used in place of the + minus. The reason for this special rule is to avoid clashes with the + standard names for child units of the packages System, Ada, Interfaces, + and GNAT, which use the prefixes s- a- i- and g- respectively. + + The file extension is `.ads' for a spec and `.adb' for a body. The + following list shows some examples of these rules. + + `main.ads' + Main (spec) + + `main.adb' + Main (body) + + `arith_functions.ads' + Arith_Functions (package spec) + + `arith_functions.adb' + Arith_Functions (package body) + + `func-spec.ads' + Func.Spec (child package spec) + + `func-spec.adb' + Func.Spec (child package body) + + `main-sub.adb' + Sub (subunit of Main) + + `a~bad.adb' + A.Bad (child package body) + + Following these rules can result in excessively long file names if + corresponding unit names are long (for example, if child units or + subunits are heavily nested). An option is available to shorten such + long file names (called file name "krunching"). This may be + particularly useful when programs being developed with GNAT are to be + used on operating systems with limited file name lengths. *Note Using + gnatkr::. + + Of course, no file shortening algorithm can guarantee uniqueness over + all possible unit names; if file name krunching is used, it is your + responsibility to ensure no name clashes occur. Alternatively you can + specify the exact file names that you want used, as described in the + next section. Finally, if your Ada programs are migrating from a + compiler with a different naming convention, you can use the gnatchop + utility to produce source files that follow the GNAT naming conventions. + (For details *note Renaming Files Using gnatchop::.) + +  + File: gnat_ug_unx.info, Node: Using Other File Names, Next: Alternative File Naming Schemes, Prev: File Naming Rules, Up: The GNAT Compilation Model + + Using Other File Names + ====================== + + In the previous section, we have described the default rules used by + GNAT to determine the file name in which a given unit resides. It is + often convenient to follow these default rules, and if you follow them, + the compiler knows without being explicitly told where to find all the + files it needs. + + However, in some cases, particularly when a program is imported from + another Ada compiler environment, it may be more convenient for the + programmer to specify which file names contain which units. GNAT allows + arbitrary file names to be used by means of the Source_File_Name pragma. + The form of this pragma is as shown in the following examples: + + pragma Source_File_Name (My_Utilities.Stacks, + Spec_File_Name => "myutilst_a.ada"); + pragma Source_File_name (My_Utilities.Stacks, + Body_File_Name => "myutilst.ada"); + + As shown in this example, the first argument for the pragma is the unit + name (in this example a child unit). The second argument has the form + of a named association. The identifier indicates whether the file name + is for a spec or a body; the file name itself is given by a string + literal. + + The source file name pragma is a configuration pragma, which means + that normally it will be placed in the `gnat.adc' file used to hold + configuration pragmas that apply to a complete compilation environment. + For more details on how the `gnat.adc' file is created and used *note + Handling of Configuration Pragmas:: + + GNAT allows completely arbitrary file names to be specified using the + source file name pragma. However, if the file name specified has an + extension other than `.ads' or `.adb' it is necessary to use a special + syntax when compiling the file. The name in this case must be preceded + by the special sequence `-x' followed by a space and the name of the + language, here `ada', as in: + + $ gcc -c -x ada peculiar_file_name.sim + + `gnatmake' handles non-standard file names in the usual manner (the + non-standard file name for the main program is simply used as the + argument to gnatmake). Note that if the extension is also non-standard, + then it must be included in the gnatmake command, it may not be omitted. + +  + File: gnat_ug_unx.info, Node: Alternative File Naming Schemes, Next: Generating Object Files, Prev: Using Other File Names, Up: The GNAT Compilation Model + + Alternative File Naming Schemes + =============================== + + In the previous section, we described the use of the + `Source_File_Name' pragma to allow arbitrary names to be assigned to + individual source files. However, this approach requires one pragma + for each file, and especially in large systems can result in very long + `gnat.adc' files, and also create a maintenance problem. + + GNAT also provides a facility for specifying systematic file naming + schemes other than the standard default naming scheme previously + described. An alternative scheme for naming is specified by the use of + `Source_File_Name' pragmas having the following format: + + pragma Source_File_Name ( + Spec_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Body_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Subunit_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + FILE_NAME_PATTERN ::= STRING_LITERAL + CASING_SPEC ::= Lowercase | Uppercase | Mixedcase + + The `FILE_NAME_PATTERN' string shows how the file name is constructed. + It contains a single asterisk character, and the unit name is + substituted systematically for this asterisk. The optional parameter + `Casing' indicates whether the unit name is to be all upper-case + letters, all lower-case letters, or mixed-case. If no `Casing' + parameter is used, then the default is all lower-case. + + The optional `Dot_Replacement' string is used to replace any periods + that occur in subunit or child unit names. If no `Dot_Replacement' + argument is used then separating dots appear unchanged in the resulting + file name. Although the above syntax indicates that the `Casing' + argument must appear before the `Dot_Replacement' argument, but it is + also permissible to write these arguments in the opposite order. + + As indicated, it is possible to specify different naming schemes for + bodies, specs, and subunits. Quite often the rule for subunits is the + same as the rule for bodies, in which case, there is no need to give a + separate `Subunit_File_Name' rule, and in this case the + `Body_File_name' rule is used for subunits as well. + + The separate rule for subunits can also be used to implement the + rather unusual case of a compilation environment (e.g. a single + directory) which contains a subunit and a child unit with the same unit + name. Although both units cannot appear in the same partition, the Ada + Reference Manual allows (but does not require) the possibility of the + two units coexisting in the same environment. + + The file name translation works in the following steps: + + * If there is a specific `Source_File_Name' pragma for the given + unit, then this is always used, and any general pattern rules are + ignored. + + * If there is a pattern type `Source_File_Name' pragma that applies + to the unit, then the resulting file name will be used if the file + exists. If more than one pattern matches, the latest one will be + tried first, and the first attempt resulting in a reference to a + file that exists will be used. + + * If no pattern type `Source_File_Name' pragma that applies to the + unit for which the corresponding file exists, then the standard + GNAT default naming rules are used. + + + As an example of the use of this mechanism, consider a commonly used + scheme in which file names are all lower case, with separating periods + copied unchanged to the resulting file name, and specs end with + ".1.ada", and bodies end with ".2.ada". GNAT will follow this scheme if + the following two pragmas appear: + + pragma Source_File_Name + (Spec_File_Name => "*.1.ada"); + pragma Source_File_Name + (Body_File_Name => "*.2.ada"); + + The default GNAT scheme is actually implemented by providing the + following default pragmas internally: + + pragma Source_File_Name + (Spec_File_Name => "*.ads", Dot_Replacement => "-"); + pragma Source_File_Name + (Body_File_Name => "*.adb", Dot_Replacement => "-"); + + Our final example implements a scheme typically used with one of the + Ada 83 compilers, where the separator character for subunits was "__" + (two underscores), specs were identified by adding `_.ADA', bodies by + adding `.ADA', and subunits by adding `.SEP'. All file names were upper + case. Child units were not present of course since this was an Ada 83 + compiler, but it seems reasonable to extend this scheme to use the same + double underscore separator for child units. + + pragma Source_File_Name + (Spec_File_Name => "*_.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Body_File_Name => "*.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Subunit_File_Name => "*.SEP", + Dot_Replacement => "__", + Casing = Uppercase); + +  + File: gnat_ug_unx.info, Node: Generating Object Files, Next: Source Dependencies, Prev: Alternative File Naming Schemes, Up: The GNAT Compilation Model + + Generating Object Files + ======================= + + An Ada program consists of a set of source files, and the first step in + compiling the program is to generate the corresponding object files. + These are generated by compiling a subset of these source files. The + files you need to compile are the following: + + * If a package spec has no body, compile the package spec to produce + the object file for the package. + + * If a package has both a spec and a body, compile the body to + produce the object file for the package. The source file for the + package spec need not be compiled in this case because there is + only one object file, which contains the code for both the spec + and body of the package. + + * For a subprogram, compile the subprogram body to produce the + object file for the subprogram. The spec, if one is present, is as + usual in a separate file, and need not be compiled. + + * In the case of subunits, only compile the parent unit. A single + object file is generated for the entire subunit tree, which + includes all the subunits. + + * Compile child units independently of their parent units (though, + of course, the spec of all the ancestor unit must be present in + order to compile a child unit). + + * Compile generic units in the same manner as any other units. The + object files in this case are small dummy files that contain at + most the flag used for elaboration checking. This is because GNAT + always handles generic instantiation by means of macro expansion. + However, it is still necessary to compile generic units, for + dependency checking and elaboration purposes. + + The preceding rules describe the set of files that must be compiled to + generate the object files for a program. Each object file has the same + name as the corresponding source file, except that the extension is + `.o' as usual. + + You may wish to compile other files for the purpose of checking their + syntactic and semantic correctness. For example, in the case where a + package has a separate spec and body, you would not normally compile the + spec. However, it is convenient in practice to compile the spec to make + sure it is error-free before compiling clients of this spec, because + such compilations will fail if there is an error in the spec. + + GNAT provides an option for compiling such files purely for the + purposes of checking correctness; such compilations are not required as + part of the process of building a program. To compile a file in this + checking mode, use the `-gnatc' switch. + +  + File: gnat_ug_unx.info, Node: Source Dependencies, Next: The Ada Library Information Files, Prev: Generating Object Files, Up: The GNAT Compilation Model + + Source Dependencies + =================== + + A given object file clearly depends on the source file which is compiled + to produce it. Here we are using "depends" in the sense of a typical + `make' utility; in other words, an object file depends on a source file + if changes to the source file require the object file to be recompiled. + In addition to this basic dependency, a given object may depend on + additional source files as follows: + + * If a file being compiled `with''s a unit X, the object file + depends on the file containing the spec of unit X. This includes + files that are `with''ed implicitly either because they are parents + of `with''ed child units or they are run-time units required by the + language constructs used in a particular unit. + + * If a file being compiled instantiates a library level generic + unit, the object file depends on both the spec and body files for + this generic unit. + + * If a file being compiled instantiates a generic unit defined + within a package, the object file depends on the body file for the + package as well as the spec file. + + * If a file being compiled contains a call to a subprogram for which + pragma `Inline' applies and inlining is activated with the + `-gnatn' switch, the object file depends on the file containing the + body of this subprogram as well as on the file containing the + spec. Note that for inlining to actually occur as a result of the + use of this switch, it is necessary to compile in optimizing mode. + + The use of `-gnatN' activates a more extensive inlining + optimization that is performed by the front end of the compiler. + This inlining does not require that the code generation be + optimized. Like `-gnatn', the use of this switch generates + additional dependencies. + + * If an object file O depends on the proper body of a subunit + through inlining or instantiation, it depends on the parent unit + of the subunit. This means that any modification of the parent + unit or one of its subunits affects the compilation of O. + + * The object file for a parent unit depends on all its subunit body + files. + + * The previous two rules meant that for purposes of computing + dependencies and recompilation, a body and all its subunits are + treated as an indivisible whole. + + These rules are applied transitively: if unit `A' `with''s unit + `B', whose elaboration calls an inlined procedure in package `C', + the object file for unit `A' will depend on the body of `C', in + file `c.adb'. + + The set of dependent files described by these rules includes all + the files on which the unit is semantically dependent, as + described in the Ada 95 Language Reference Manual. However, it is + a superset of what the ARM describes, because it includes generic, + inline, and subunit dependencies. + + An object file must be recreated by recompiling the corresponding + source file if any of the source files on which it depends are + modified. For example, if the `make' utility is used to control + compilation, the rule for an Ada object file must mention all the + source files on which the object file depends, according to the + above definition. The determination of the necessary + recompilations is done automatically when one uses `gnatmake'. + +  + File: gnat_ug_unx.info, Node: The Ada Library Information Files, Next: Binding an Ada Program, Prev: Source Dependencies, Up: The GNAT Compilation Model + + The Ada Library Information Files + ================================= + + Each compilation actually generates two output files. The first of these + is the normal object file that has a `.o' extension. The second is a + text file containing full dependency information. It has the same name + as the source file, but an `.ali' extension. This file is known as the + Ada Library Information (`ali') file. The following information is + contained in the `ali' file. + + * Version information (indicates which version of GNAT was used to + compile the unit(s) in question) + + * Main program information (including priority and time slice + settings, as well as the wide character encoding used during + compilation). + + * List of arguments used in the `gcc' command for the compilation + + * Attributes of the unit, including configuration pragmas used, an + indication of whether the compilation was successful, exception + model used etc. + + * A list of relevant restrictions applying to the unit (used for + consistency) checking. + + * Categorization information (e.g. use of pragma `Pure'). + + * Information on all `with''ed units, including presence of + `Elaborate' or `Elaborate_All' pragmas. + + * Information from any `Linker_Options' pragmas used in the unit + + * Information on the use of `Body_Version' or `Version' attributes + in the unit. + + * Dependency information. This is a list of files, together with + time stamp and checksum information. These are files on which the + unit depends in the sense that recompilation is required if any of + these units are modified. + + * Cross-reference data. Contains information on all entities + referenced in the unit. Used by tools like `gnatxref' and + `gnatfind' to provide cross-reference information. + + + For a full detailed description of the format of the `ali' file, see + the source of the body of unit `Lib.Writ', contained in file + `lib-writ.adb' in the GNAT compiler sources. + +  + File: gnat_ug_unx.info, Node: Binding an Ada Program, Next: Mixed Language Programming, Prev: The Ada Library Information Files, Up: The GNAT Compilation Model + + Binding an Ada Program + ====================== + + When using languages such as C and C++, once the source files have been + compiled the only remaining step in building an executable program is + linking the object modules together. This means that it is possible to + link an inconsistent version of a program, in which two units have + included different versions of the same header. + + The rules of Ada do not permit such an inconsistent program to be + built. For example, if two clients have different versions of the same + package, it is illegal to build a program containing these two clients. + These rules are enforced by the GNAT binder, which also determines an + elaboration order consistent with the Ada rules. + + The GNAT binder is run after all the object files for a program have + been created. It is given the name of the main program unit, and from + this it determines the set of units required by the program, by reading + the corresponding ALI files. It generates error messages if the program + is inconsistent or if no valid order of elaboration exists. + + If no errors are detected, the binder produces a main program, in + Ada by default, that contains calls to the elaboration procedures of + those compilation unit that require them, followed by a call to the + main program. This Ada program is compiled to generate the object file + for the main program. The name of the Ada file is `b~XXX.adb' (with the + corresponding spec `b~XXX.ads') where XXX is the name of the main + program unit. + + Finally, the linker is used to build the resulting executable + program, using the object from the main program from the bind step as + well as the object files for the Ada units of the program. + +  + File: gnat_ug_unx.info, Node: Mixed Language Programming, Next: Building Mixed Ada & C++ Programs, Prev: Binding an Ada Program, Up: The GNAT Compilation Model + + Mixed Language Programming + ========================== + + * Menu: + + * Interfacing to C:: + * Calling Conventions:: + +  + File: gnat_ug_unx.info, Node: Interfacing to C, Next: Calling Conventions, Up: Mixed Language Programming + + Interfacing to C + ---------------- + + There are two ways to build a program that contains some Ada files and + some other language files depending on whether the main program is in + Ada or not. If the main program is in Ada, you should proceed as + follows: + + 1. Compile the other language files to generate object files. For + instance: + gcc -c file1.c + gcc -c file2.c + + 2. Compile the Ada units to produce a set of object files and ALI + files. For instance: + gnatmake -c my_main.adb + + 3. Run the Ada binder on the Ada main program. For instance: + gnatbind my_main.ali + + 4. Link the Ada main program, the Ada objects and the other language + objects. For instance: + gnatlink my_main.ali file1.o file2.o + + The three last steps can be grouped in a single command: + gnatmake my_main.adb -largs file1.o file2.o + + If the main program is in some language other than Ada, Then you may + have more than one entry point in the Ada subsystem. You must use a + special option of the binder to generate callable routines to initialize + and finalize the Ada units (*note Binding with Non-Ada Main Programs::). + Calls to the initialization and finalization routines must be inserted + in the main program, or some other appropriate point in the code. The + call to initialize the Ada units must occur before the first Ada + subprogram is called, and the call to finalize the Ada units must occur + after the last Ada subprogram returns. You use the same procedure for + building the program as described previously. In this case, however, + the binder only places the initialization and finalization subprograms + into file `b~XXX.adb' instead of the main program. So, if the main + program is not in Ada, you should proceed as follows: + + 1. Compile the other language files to generate object files. For + instance: + gcc -c file1.c + gcc -c file2.c + + 2. Compile the Ada units to produce a set of object files and ALI + files. For instance: + gnatmake -c entry_point1.adb + gnatmake -c entry_point2.adb + + 3. Run the Ada binder on the Ada main program. For instance: + gnatbind -n entry_point1.ali entry_point2.ali + + 4. Link the Ada main program, the Ada objects and the other language + objects. You only need to give the last entry point here. For + instance: + gnatlink entry_point2.ali file1.o file2.o + +  + File: gnat_ug_unx.info, Node: Calling Conventions, Prev: Interfacing to C, Up: Mixed Language Programming + + Calling Conventions + ------------------- + + GNAT follows standard calling sequence conventions and will thus + interface to any other language that also follows these conventions. + The following Convention identifiers are recognized by GNAT: + + * Ada. This indicates that the standard Ada calling sequence will be + used and all Ada data items may be passed without any limitations + in the case where GNAT is used to generate both the caller and + callee. It is also possible to mix GNAT generated code and code + generated by another Ada compiler. In this case, the data types + should be restricted to simple cases, including primitive types. + Whether complex data types can be passed depends on the situation. + Probably it is safe to pass simple arrays, such as arrays of + integers or floats. Records may or may not work, depending on + whether both compilers lay them out identically. Complex structures + involving variant records, access parameters, tasks, or protected + types, are unlikely to be able to be passed. + + Note that in the case of GNAT running on a platform that supports + DEC Ada 83, a higher degree of compatibility can be guaranteed, + and in particular records are layed out in an identical manner in + the two compilers. Note also that if output from two different + compilers is mixed, the program is responsible for dealing with + elaboration issues. Probably the safest approach is to write the + main program in the version of Ada other than GNAT, so that it + takes care of its own elaboration requirements, and then call the + GNAT-generated adainit procedure to ensure elaboration of the GNAT + components. Consult the documentation of the other Ada compiler + for further details on elaboration. + + However, it is not possible to mix the tasking run time of GNAT and + DEC Ada 83, All the tasking operations must either be entirely + within GNAT compiled sections of the program, or entirely within + DEC Ada 83 compiled sections of the program. + + * Assembler. Specifies assembler as the convention. In practice this + has the same effect as convention Ada (but is not equivalent in + the sense of being considered the same convention). + + * Asm. Equivalent to Assembler. + + * Asm. Equivalent to Assembly. + + * COBOL. Data will be passed according to the conventions described + in section B.4 of the Ada 95 Reference Manual. + + * C. Data will be passed according to the conventions described in + section B.3 of the Ada 95 Reference Manual. + + * Default. Equivalent to C. + + * External. Equivalent to C. + + * CPP. This stands for C++. For most purposes this is identical to C. + See the separate description of the specialized GNAT pragmas + relating to C++ interfacing for further details. + + * Fortran. Data will be passed according to the conventions described + in section B.5 of the Ada 95 Reference Manual. + + * Intrinsic. This applies to an intrinsic operation, as defined in + the Ada 95 Reference Manual. If a a pragma Import (Intrinsic) + applies to a subprogram, this means that the body of the + subprogram is provided by the compiler itself, usually by means of + an efficient code sequence, and that the user does not supply an + explicit body for it. In an application program, the pragma can + only be applied to the following two sets of names, which the GNAT + compiler recognizes. + * Rotate_Left, Rotate_Right, Shift_Left, Shift_Right, + Shift_Right_- Arithmetic. The corresponding subprogram + declaration must have two formal parameters. The first one + must be a signed integer type or a modular type with a binary + modulus, and the second parameter must be of type Natural. + The return type must be the same as the type of the first + argument. The size of this type can only be 8, 16, 32, or 64. + + * binary arithmetic operators: "+", "-", "*", "/" The + corresponding operator declaration must have parameters and + result type that have the same root numeric type (for + example, all three are long_float types). This simplifies the + definition of operations that use type checking to perform + dimensional checks: + type Distance is new Long_Float; + type Time is new Long_Float; + type Velocity is new Long_Float; + function "/" (D : Distance; T : Time) + return Velocity; + pragma Import (Intrinsic, "/"); + + This common idiom is often programmed with a generic + definition and an explicit body. The pragma makes it simpler + to introduce such declarations. It incurs no overhead in + compilation time or code size, because it is implemented as a + single machine instruction. + + * Stdcall. This is relevant only to NT/Win95 implementations of GNAT, + and specifies that the Stdcall calling sequence will be used, as + defined by the NT API. + + * DLL. This is equivalent to Stdcall. + + * Win32. This is equivalent to Stdcall. + + * Stubbed. This is a special convention that indicates that the + compiler should provide a stub body that raises `Program_Error'. + + GNAT additionally provides a useful pragma `Convention_Identifier' that + can be used to parametrize conventions and allow additional synonyms to + be specified. For example if you have legacy code in which the + convention identifier Fortran77 was used for Fortran, you can use the + configuration pragma: + + pragma Convention_Identifier (Fortran77, Fortran); + + And from now on the identifier Fortran77 may be used as a convention + identifier (for example in an `Import' pragma) with the same meaning as + Fortran. + +  + File: gnat_ug_unx.info, Node: Building Mixed Ada & C++ Programs, Next: Comparison between GNAT and C/C++ Compilation Models, Prev: Mixed Language Programming, Up: The GNAT Compilation Model + + Building Mixed Ada & C++ Programs + ================================= + + Building a mixed application containing both Ada and C++ code may be a + challenge for the unaware programmer. As a matter of fact, this + interfacing has not been standardized in the Ada 95 reference manual due + to the immaturity and lack of standard of C++ at the time. This section + gives a few hints that should make this task easier. In particular the + first section addresses the differences with interfacing with C. The + second section looks into the delicate problem of linking the complete + application from its Ada and C++ parts. The last section give some + hints on how the GNAT run time can be adapted in order to allow + inter-language dispatching with a new C++ compiler. + + * Menu: + + * Interfacing to C++:: + * Linking a Mixed C++ & Ada Program:: + * A Simple Example:: + * Adapting the Run Time to a New C++ Compiler:: + +  + File: gnat_ug_unx.info, Node: Interfacing to C++, Next: Linking a Mixed C++ & Ada Program, Up: Building Mixed Ada & C++ Programs + + Interfacing to C++ + ------------------ + + GNAT supports interfacing with C++ compilers generating code that is + compatible with the standard Application Binary Interface of the given + platform. + + Interfacing can be done at 3 levels: simple data, subprograms and + classes. In the first 2 cases, GNAT offer a specific CONVENTION CPP + that behaves exactly like CONVENTION C. Usually C++ mangle names of + subprograms and currently GNAT does not provide any help to solve the + demangling problem. This problem can be addressed in 2 ways: + * by modifying the C++ code in order to force a C convention using + the EXTERN "C" syntax. + + * by figuring out the mangled name and use it as the Link_Name + argument of the pragma import. + + Interfacing at the class level can be achieved by using the GNAT + specific pragmas such as `CPP_Class' and `CPP_Virtual'. See the GNAT + Reference Manual for additional information. + +  + File: gnat_ug_unx.info, Node: Linking a Mixed C++ & Ada Program, Next: A Simple Example, Prev: Interfacing to C++, Up: Building Mixed Ada & C++ Programs + + Linking a Mixed C++ & Ada Program + --------------------------------- + + Usually the linker of the C++ development system must be used to link + mixed applications because most C++ systems will resolve elaboration + issues (such as calling constructors on global class instances) + transparently during the link phase. GNAT has been adapted to ease the + use of a foreign linker for the last phase. Three cases can be + considered: + 1. 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 `c++'. Note that this setup is not very + common because it may request recompiling the whole GCC tree from + sources and it does not allow to upgrade easily to a new version + of one compiler for one of the two languages without taking the + risk of destabilizing the other. + + $ c++ -c file1.C + $ c++ -c file2.C + $ gnatmake ada_unit -largs file1.o file2.o --LINK=c++ + + 2. Using GNAT and G++ from 2 different GCC installations. If both + compilers are on the PATH, the same method can be used. It is + important to be aware that environment variables such as + C_INCLUDE_PATH, GCC_EXEC_PREFIX, BINUTILS_ROOT or GCC_ROOT will + affect both compilers at the same time and thus may make one of + the 2 compilers operate improperly if they are set for the other. + In particular it is important that the link command has access to + the proper gcc library `libgcc.a', that is to say the one that is + part of the C++ compiler installation. The implicit link command + as suggested in the gnatmake command from the former example can + be replaced by an explicit link command with full verbosity in + order to verify which library is used: + $ gnatbind ada_unit + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=c++ + If there is a problem due to interfering environment variables, it + can be workaround by using an intermediate script. The following + example shows the proper script to use when GNAT has not been + installed at its default location and g++ has been installed at + its default location: + + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + unset BINUTILS_ROOT + unset GCC_ROOT + c++ $* + + 3. Using a non GNU C++ compiler. The same set of command as previously + described can be used to insure that the c++ linker is used. + Nonetheless, you need to add the path to libgcc explicitely, since + some libraries needed by GNAT are located in this directory: + + + $ gnatlink ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + CC $* `gcc -print-libgcc-file-name` + + Where CC is the name of the non GNU C++ compiler. + + +  + File: gnat_ug_unx.info, Node: A Simple Example, Next: Adapting the Run Time to a New C++ Compiler, Prev: Linking a Mixed C++ & Ada Program, Up: Building Mixed Ada & C++ Programs + + A Simple Example + ---------------- + + The following example, provided as part of the GNAT examples, show how + to achieve procedural interfacing between Ada and C++ in both + directions. The C++ class A has 2 methods. The first method is exported + to Ada by the means of an extern C wrapper function. The second method + calls an Ada subprogram. On the Ada side, The C++ calls is modelized by + a limited record with a layout comparable to the C++ class. The Ada + subprogram, in turn, calls the c++ method. So from the C++ main program + the code goes back and forth between the 2 languages. + + Here are the compilation commands for native configurations: + $ gnatmake -c simple_cpp_interface + $ c++ -c cpp_main.C + $ c++ -c ex7.C + $ gnatbind -n simple_cpp_interface + $ gnatlink simple_cpp_interface -o cpp_main --LINK=$(CPLUSPLUS) + -lstdc++ ex7.o cpp_main.o + + Here are the corresponding sources: + + //cpp_main.C + + #include "ex7.h" + + extern "C" { + void adainit (void); + void adafinal (void); + void method1 (A *t); + } + + void method1 (A *t) + { + t->method1 (); + } + + int main () + { + A obj; + adainit (); + obj.method2 (3030); + adafinal (); + } + + //ex7.h + + class Origin { + public: + int o_value; + }; + class A : public Origin { + public: + void method1 (void); + virtual void method2 (int v); + A(); + int a_value; + }; + + //ex7.C + + #include "ex7.h" + #include + + extern "C" { void ada_method2 (A *t, int v);} + + void A::method1 (void) + { + a_value = 2020; + printf ("in A::method1, a_value = %d \n",a_value); + + } + + void A::method2 (int v) + { + ada_method2 (this, v); + printf ("in A::method2, a_value = %d \n",a_value); + + } + + A::A(void) + { + a_value = 1010; + printf ("in A::A, a_value = %d \n",a_value); + } + + -- Ada sources + package body Simple_Cpp_Interface is + + procedure Ada_Method2 (This : in out A; V : Integer) is + begin + Method1 (This); + This.A_Value := V; + end Ada_Method2; + + end Simple_Cpp_Interface; + + package Simple_Cpp_Interface is + type A is limited + record + O_Value : Integer; + A_Value : Integer; + end record; + pragma Convention (C, A); + + procedure Method1 (This : in out A); + pragma Import (C, Method1); + + procedure Ada_Method2 (This : in out A; V : Integer); + pragma Export (C, Ada_Method2); + + end Simple_Cpp_Interface; + +  + File: gnat_ug_unx.info, Node: Adapting the Run Time to a New C++ Compiler, Prev: A Simple Example, Up: Building Mixed Ada & C++ Programs + + Adapting the Run Time to a New C++ Compiler + ------------------------------------------- + + GNAT offers the capability to derive Ada 95 tagged types directly from + preexisting C++ classes and . See "Interfacing with C++" in the GNAT + reference manual. The mechanism used by GNAT for achieving such a goal + has been made user configurable through a GNAT library unit + `Interfaces.CPP'. The default version of this file is adapted to the + GNU c++ compiler. Internal knowledge of the virtual table layout used + by the new C++ compiler is needed to configure properly this unit. The + Interface of this unit is known by the compiler and cannot be changed + except for the value of the constants defining the characteristics of + the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size, + CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source + of this unit for more details. + +  + File: gnat_ug_unx.info, Node: Comparison between GNAT and C/C++ Compilation Models, Next: Comparison between GNAT and Conventional Ada Library Models, Prev: Building Mixed Ada & C++ Programs, Up: The GNAT Compilation Model + + Comparison between GNAT and C/C++ Compilation Models + ==================================================== + + The GNAT model of compilation is close to the C and C++ models. You can + think of Ada specs as corresponding to header files in C. As in C, you + don't need to compile specs; they are compiled when they are used. The + Ada `with' is similar in effect to the `#include' of a C header. + + One notable difference is that, in Ada, you may compile specs + separately to check them for semantic and syntactic accuracy. This is + not always possible with C headers because they are fragments of + programs that have less specific syntactic or semantic rules. + + The other major difference is the requirement for running the binder, + which performs two important functions. First, it checks for + consistency. In C or C++, the only defense against assembling + inconsistent programs lies outside the compiler, in a makefile, for + example. The binder satisfies the Ada requirement that it be impossible + to construct an inconsistent program when the compiler is used in normal + mode. + + The other important function of the binder is to deal with + elaboration issues. There are also elaboration issues in C++ that are + handled automatically. This automatic handling has the advantage of + being simpler to use, but the C++ programmer has no control over + elaboration. Where `gnatbind' might complain there was no valid order + of elaboration, a C++ compiler would simply construct a program that + malfunctioned at run time. + +  + File: gnat_ug_unx.info, Node: Comparison between GNAT and Conventional Ada Library Models, Prev: Comparison between GNAT and C/C++ Compilation Models, Up: The GNAT Compilation Model + + Comparison between GNAT and Conventional Ada Library Models + =========================================================== + + This section is intended to be useful to Ada programmers who have + previously used an Ada compiler implementing the traditional Ada library + model, as described in the Ada 95 Language Reference Manual. If you + have not used such a system, please go on to the next section. + + In GNAT, there is no "library" in the normal sense. Instead, the set + of source files themselves acts as the library. Compiling Ada programs + does not generate any centralized information, but rather an object + file and a ALI file, which are of interest only to the binder and + linker. In a traditional system, the compiler reads information not + only from the source file being compiled, but also from the centralized + library. This means that the effect of a compilation depends on what + has been previously compiled. In particular: + + * When a unit is `with''ed, the unit seen by the compiler corresponds + to the version of the unit most recently compiled into the library. + + * Inlining is effective only if the necessary body has already been + compiled into the library. + + * Compiling a unit may obsolete other units in the library. + + In GNAT, compiling one unit never affects the compilation of any other + units because the compiler reads only source files. Only changes to + source files can affect the results of a compilation. In particular: + + * When a unit is `with''ed, the unit seen by the compiler corresponds + to the source version of the unit that is currently accessible to + the compiler. + + * Inlining requires the appropriate source files for the package or + subprogram bodies to be available to the compiler. Inlining is + always effective, independent of the order in which units are + complied. + + * Compiling a unit never affects any other compilations. The editing + of sources may cause previous compilations to be out of date if + they depended on the source file being modified. + + The most important result of these differences is that order of + compilation is never significant in GNAT. There is no situation in + which one is required to do one compilation before another. What shows + up as order of compilation requirements in the traditional Ada library + becomes, in GNAT, simple source dependencies; in other words, there is + only a set of rules saying what source files must be present when a + file is compiled. + +  + File: gnat_ug_unx.info, Node: Compiling Using gcc, Next: Binding Using gnatbind, Prev: The GNAT Compilation Model, Up: Top + + Compiling Using `gcc' + ********************* + + This chapter discusses how to compile Ada programs using the `gcc' + command. It also describes the set of switches that can be used to + control the behavior of the compiler. + + * Menu: + + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + +  + File: gnat_ug_unx.info, Node: Compiling Programs, Next: Switches for gcc, Up: Compiling Using gcc + + Compiling Programs + ================== + + The first step in creating an executable program is to compile the units + of the program using the `gcc' command. You must compile the following + files: + + * the body file (`.adb') for a library level subprogram or generic + subprogram + + * the spec file (`.ads') for a library level package or generic + package that has no body + + * the body file (`.adb') for a library level package or generic + package that has a body + + + You need _not_ compile the following files + + * the spec of a library unit which has a body + + * subunits + + because they are compiled as part of compiling related units. GNAT + package specs when the corresponding body is compiled, and subunits + when the parent is compiled. If you attempt to compile any of these + files, you will get one of the following error messages (where fff is + the name of the file you compiled): + + No code generated for file FFF (PACKAGE SPEC) + No code generated for file FFF (SUBUNIT) + + The basic command for compiling a file containing an Ada unit is + + $ gcc -c [SWITCHES] `file name' + + where FILE NAME is the name of the Ada file (usually having an extension + `.ads' for a spec or `.adb' for a body). You specify the `-c' switch + to tell `gcc' to compile, but not link, the file. The result of a + successful compilation is an object file, which has the same name as + the source file but an extension of `.o' and an Ada Library Information + (ALI) file, which also has the same name as the source file, but with + `.ali' as the extension. GNAT creates these two output files in the + current directory, but you may specify a source file in any directory + using an absolute or relative path specification containing the + directory information. + + `gcc' is actually a driver program that looks at the extensions of + the file arguments and loads the appropriate compiler. For example, the + GNU C compiler is `cc1', and the Ada compiler is `gnat1'. These + programs are in directories known to the driver program (in some + configurations via environment variables you set), but need not be in + your path. The `gcc' driver also calls the assembler and any other + utilities needed to complete the generation of the required object + files. + + It is possible to supply several file names on the same `gcc' + command. This causes `gcc' to call the appropriate compiler for each + file. For example, the following command lists three separate files to + be compiled: + + $ gcc -c x.adb y.adb z.c + + calls `gnat1' (the Ada compiler) twice to compile `x.adb' and `y.adb', + and `cc1' (the C compiler) once to compile `z.c'. The compiler + generates three object files `x.o', `y.o' and `z.o' and the two ALI + files `x.ali' and `y.ali' from the Ada compilations. Any switches apply + to all the files listed, except for `-gnatX' switches, which apply only + to Ada compilations. + +  + File: gnat_ug_unx.info, Node: Switches for gcc, Next: Search Paths and the Run-Time Library (RTL), Prev: Compiling Programs, Up: Compiling Using gcc + + Switches for `gcc' + ================== + + The `gcc' command accepts switches that control the compilation + process. These switches are fully described in this section. First we + briefly list all the switches, in alphabetical order, then we describe + the switches in more detail in functionally grouped sections. + + * Menu: + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + `-b TARGET' + Compile your program to run on TARGET, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + TARGET is not the same as your host system. + + `-BDIR' + Load compiler executables (for example, `gnat1', the Ada compiler) + from DIR instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + `gcc' manual page for further details. You would normally use the + `-b' or `-V' switch instead. + + `-c' + Compile. Always use this switch when compiling Ada programs. + + Note: for some other languages when using `gcc', notably in the + case of C and C++, it is possible to use use `gcc' without a `-c' + switch to compile and link in one step. In the case of GNAT, you + cannot use this approach, because the binder must be run and `gcc' + cannot be used to run the GNAT binder. + + `-g' + Generate debugging information. This information is stored in the + object file and copied from there to the final executable file by + the linker, where it can be read by the debugger. You must use the + `-g' switch if you plan on using the debugger. + + `-IDIR' + Direct GNAT to search the DIR directory for source files needed by + the current compilation (*note Search Paths and the Run-Time + Library (RTL)::). + + `-I-' + Except for the source file named in the command line, do not look + for source files in the directory containing the source file named + in the command line (*note Search Paths and the Run-Time Library + (RTL)::). + + `-o FILE' + This switch is used in `gcc' to redirect the generated object file + and its associated ALI file. Beware of this switch with GNAT, + because it may cause the object file and ALI file to have + different names which in turn may confuse the binder and the + linker. + + `-O[N]' + N controls the optimization level. + + n = 0 + No optimization, the default setting if no `-O' appears + + n = 1 + Normal optimization, the default if you specify `-O' without + an operand. + + n = 2 + Extensive optimization + + n = 3 + Extensive optimization with automatic inlining. This applies + only to inlining within a unit. For details on control of + inter-unit inlining see *Note Subprogram Inlining Control::. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-S' + Used in place of `-c' to cause the assembler source file to be + generated, using `.s' as the extension, instead of the object file. + This may be useful if you need to examine the generated assembly + code. + + `-v' + Show commands generated by the `gcc' driver. Normally used only for + debugging purposes or if you need to be sure what version of the + compiler you are executing. + + `-V VER' + Execute VER version of the compiler. This is the `gcc' version, + not the GNAT version. + + `-gnata' + Assertions enabled. `Pragma Assert' and `pragma Debug' to be + activated. + + `-gnatA' + Avoid processing `gnat.adc'. If a gnat.adc file is present, it + will be ignored. + + `-gnatb' + Generate brief messages to `stderr' even if verbose mode set. + + `-gnatc' + Check syntax and semantics only (no code generation attempted). + + `-gnatC' + Compress debug information and external symbol name table entries. + + `-gnatD' + Output expanded source files for source level debugging. This + switch also suppress generation of cross-reference information + (see -gnatx). + + `-gnatecPATH' + Specify a configuration pragma file. (see *Note The Configuration + Pragmas Files::) + + `-gnatemPATH' + Specify a mapping file. (see *Note Units to Sources Mapping + Files::) + + `-gnatE' + Full dynamic elaboration checks. + + `-gnatf' + Full errors. Multiple errors per line, all undefined references. + + `-gnatF' + Externals names are folded to all uppercase. + + `-gnatg' + Internal GNAT implementation mode. This should not be used for + applications programs, it is intended only for use by the compiler + and its run-time library. For documentation, see the GNAT sources. + + `-gnatG' + List generated expanded code in source form. + + `-gnatiC' + Identifier character set (C=1/2/3/4/8/9/p/f/n/w). + + `-gnath' + Output usage information. The output is written to `stdout'. + + `-gnatkN' + Limit file names to N (1-999) characters (`k' = krunch). + + `-gnatl' + Output full source listing with embedded error messages. + + `-gnatmN' + Limit number of detected errors to N (1-999). + + `-gnatn' + Activate inlining across unit boundaries for subprograms for which + pragma `inline' is specified. + + `-gnatN' + Activate front end inlining. + + `-fno-inline' + Suppresses all inlining, even if other optimization or inlining + switches are set. + + `-fstack-check' + Activates stack checking. See separate section on stack checking + for details of the use of this option. + + `-gnato' + Enable numeric overflow checking (which is not normally enabled by + default). Not that division by zero is a separate check that is not + controlled by this switch (division by zero checking is on by + default). + + `-gnatp' + Suppress all checks. + + `-gnatq' + Don't quit; try semantics, even if parse errors. + + `-gnatQ' + Don't quit; generate `ali' and tree files even if illegalities. + + `-gnatP' + Enable polling. This is required on some systems (notably Windows + NT) to obtain asynchronous abort and asynchronous transfer of + control capability. See the description of pragma Polling in the + GNAT Reference Manual for full details. + + `-gnatR[0/1/2/3][s]' + Output representation information for declared types and objects. + + `-gnats' + Syntax check only. + + `-gnatt' + Tree output file to be generated. + + `-gnatT nnn' + Set time slice to specified number of microseconds + + `-gnatu' + List units for this compilation. + + `-gnatU' + Tag all error messages with the unique string "error:" + + `-gnatv' + Verbose mode. Full error output with source lines to `stdout'. + + `-gnatV' + Control level of validity checking. See separate section describing + this feature. + + `-gnatwxxxXXX' + Warning mode where XXX is a string of options describing the exact + warnings that are enabled or disabled. See separate section on + warning control. + + `-gnatWE' + Wide character encoding method (E=n/h/u/s/e/8). + + `-gnatx' + Suppress generation of cross-reference information. + + `-gnaty' + Enable built-in style checks. See separate section describing this + feature. + + `-gnatzM' + Distribution stub generation and compilation (M=r/c for + receiver/caller stubs). + + `-gnat83' + Enforce Ada 83 restrictions. + + `-pass-exit-codes' + Catch exit codes from the compiler and use the most meaningful as + exit status. + + You may combine a sequence of GNAT switches into a single switch. For + example, the combined switch + + -gnatofi3 + + is equivalent to specifying the following sequence of switches: + + -gnato -gnatf -gnati3 + + The following restrictions apply to the combination of switches in this + manner: + + * The switch `-gnatc' if combined with other switches must come + first in the string. + + * The switch `-gnats' if combined with other switches must come + first in the string. + + * Once a "y" appears in the string (that is a use of the `-gnaty' + switch), then all further characters in the switch are interpreted + as style modifiers (see description of `-gnaty'). + + * Once a "d" appears in the string (that is a use of the `-gnatd' + switch), then all further characters in the switch are interpreted + as debug flags (see description of `-gnatd'). + + * Once a "w" appears in the string (that is a use of the `-gnatw' + switch), then all further characters in the switch are interpreted + as warning mode modifiers (see description of `-gnatw'). + + * Once a "V" appears in the string (that is a use of the `-gnatV' + switch), then all further characters in the switch are interpreted + as validity checking options (see description of `-gnatV'). + + +  + File: gnat_ug_unx.info, Node: Output and Error Message Control, Next: Debugging and Assertion Control, Up: Switches for gcc + + Output and Error Message Control + -------------------------------- + + The standard default format for error messages is called "brief format." + Brief format messages are written to `stderr' (the standard error file) + and have the following form: + + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:4:20: ";" should be "is" + + The first integer after the file name is the line number in the file, + and the second integer is the column number within the line. `glide' + can parse the error messages and point to the referenced character. + The following switches provide control over the error message format: + + `-gnatv' + The v stands for verbose. The effect of this setting is to write + long-format error messages to `stdout' (the standard output file. + The same program compiled with the `-gnatv' switch would generate: + + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + + The vertical bar indicates the location of the error, and the `>>>' + prefix can be used to search for error messages. When this switch + is used the only source lines output are those with errors. + + `-gnatl' + The `l' stands for list. This switch causes a full listing of the + file to be generated. The output might look as follows: + + 1. procedure E is + 2. V : Integer; + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + 5. begin + 6. return Q + Q; + 7. end; + 8. begin + 9. V := X + X; + 10.end E; + + When you specify the `-gnatv' or `-gnatl' switches and standard + output is redirected, a brief summary is written to `stderr' + (standard error) giving the number of error messages and warning + messages generated. + + `-gnatU' + This switch forces all error messages to be preceded by the unique + string "error:". This means that error messages take a few more + characters in space, but allows easy searching for and + identification of error messages. + + `-gnatb' + The `b' stands for brief. This switch causes GNAT to generate the + brief format error messages to `stderr' (the standard error file) + as well as the verbose format message or full listing (which as + usual is written to `stdout' (the standard output file). + + `-gnatmN' + The `m' stands for maximum. N is a decimal integer in the range + of 1 to 999 and limits the number of error messages to be + generated. For example, using `-gnatm2' might yield + + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:5:35: missing ".." + fatal error: maximum errors reached + compilation abandoned + + `-gnatf' + The `f' stands for full. Normally, the compiler suppresses error + messages that are likely to be redundant. This switch causes all + error messages to be generated. In particular, in the case of + references to undefined variables. If a given variable is + referenced several times, the normal format of messages is + e.adb:7:07: "V" is undefined (more references follow) + + where the parenthetical comment warns that there are additional + references to the variable `V'. Compiling the same program with the + `-gnatf' switch yields + + e.adb:7:07: "V" is undefined + e.adb:8:07: "V" is undefined + e.adb:8:12: "V" is undefined + e.adb:8:16: "V" is undefined + e.adb:9:07: "V" is undefined + e.adb:9:12: "V" is undefined + + `-gnatq' + The `q' stands for quit (really "don't quit"). In normal + operation mode, the compiler first parses the program and + determines if there are any syntax errors. If there are, + appropriate error messages are generated and compilation is + immediately terminated. This switch tells GNAT to continue with + semantic analysis even if syntax errors have been found. This may + enable the detection of more errors in a single run. On the other + hand, the semantic analyzer is more likely to encounter some + internal fatal error when given a syntactically invalid tree. + + `-gnatQ' + In normal operation mode, the `ali' file is not generated if any + illegalities are detected in the program. The use of `-gnatQ' + forces generation of the `ali' file. This file is marked as being + in error, so it cannot be used for binding purposes, but it does + contain reasonably complete cross-reference information, and thus + may be useful for use by tools (e.g. semantic browsing tools or + integrated development environments) that are driven from the + `ali' file. + + In addition, if `-gnatt' is also specified, then the tree file is + generated even if there are illegalities. It may be useful in this + case to also specify `-gnatq' to ensure that full semantic + processing occurs. The resulting tree file can be processed by + ASIS, for the purpose of providing partial information about + illegal units, but if the error causes the tree to be badly + malformed, then ASIS may crash during the analysis. + + In addition to error messages, which correspond to illegalities as + defined in the Ada 95 Reference Manual, the compiler detects two kinds + of warning situations. + + First, the compiler considers some constructs suspicious and + generates a warning message to alert you to a possible error. Second, + if the compiler detects a situation that is sure to raise an exception + at run time, it generates a warning message. The following shows an + example of warning messages: + e.adb:4:24: warning: creation of object may raise Storage_Error + e.adb:10:17: warning: static value out of range + e.adb:10:17: warning: "Constraint_Error" will be raised at run time + + GNAT considers a large number of situations as appropriate for the + generation of warning messages. As always, warnings are not definite + indications of errors. For example, if you do an out-of-range + assignment with the deliberate intention of raising a + `Constraint_Error' exception, then the warning that may be issued does + not indicate an error. Some of the situations for which GNAT issues + warnings (at least some of the time) are given in the following list, + which is not necessarily complete. + + * Possible infinitely recursive calls + + * Out-of-range values being assigned + + * Possible order of elaboration problems + + * Unreachable code + + * Fixed-point type declarations with a null range + + * Variables that are never assigned a value + + * Variables that are referenced before being initialized + + * Task entries with no corresponding accept statement + + * Duplicate accepts for the same task entry in a select + + * Objects that take too much storage + + * Unchecked conversion between types of differing sizes + + * Missing return statements along some execution paths in a function + + * Incorrect (unrecognized) pragmas + + * Incorrect external names + + * Allocation from empty storage pool + + * Potentially blocking operations in protected types + + * Suspicious parenthesization of expressions + + * Mismatching bounds in an aggregate + + * Attempt to return local value by reference + + * Unrecognized pragmas + + * Premature instantiation of a generic body + + * Attempt to pack aliased components + + * Out of bounds array subscripts + + * Wrong length on string assignment + + * Violations of style rules if style checking is enabled + + * Unused with clauses + + * Bit_Order usage that does not have any effect + + * Compile time biased rounding of floating-point constant + + * Standard.Duration used to resolve universal fixed expression + + * Dereference of possibly null value + + * Declaration that is likely to cause storage error + + * Internal GNAT unit with'ed by application unit + + * Values known to be out of range at compile time + + * Unreferenced labels and variables + + * Address overlays that could clobber memory + + * Unexpected initialization when address clause present + + * Bad alignment for address clause + + * Useless type conversions + + * Redundant assignment statements + + * Accidental hiding of name by child unit + + * Unreachable code + + * Access before elaboration detected at compile time + + * A range in a `for' loop that is known to be null or might be null + + + The following switches are available to control the handling of warning + messages: + + `-gnatwa (activate all optional errors)' + This switch activates most optional warning messages, see + remaining list in this section for details on optional warning + messages that can be individually controlled. The warnings that + are not turned on by this switch are `-gnatwb' (biased rounding), + `-gnatwd' (implicit dereferencing), and `-gnatwh' (hiding). All + other optional warnings are turned on. + + `-gnatwA (suppress all optional errors)' + This switch suppresses all optional warning messages, see + remaining list in this section for details on optional warning + messages that can be individually controlled. + + `-gnatwb (activate warnings on biased rounding)' + If a static floating-point expression has a value that is exactly + half way between two adjacent machine numbers, then the rules of + Ada (Ada Reference Manual, section 4.9(38)) require that this + rounding be done away from zero, even if the normal unbiased + rounding rules at run time would require rounding towards zero. + This warning message alerts you to such instances where + compile-time rounding and run-time rounding are not equivalent. If + it is important to get proper run-time rounding, then you can + force this by making one of the operands into a variable. The + default is that such warnings are not generated. Note that + `-gnatwa' does not affect the setting of this warning option. + + `-gnatwB (suppress warnings on biased rounding)' + This switch disables warnings on biased rounding. + + `-gnatwc (activate warnings on conditionals)' + This switch activates warnings for conditional expressions used in + tests that are known to be True or False at compile time. The + default is that such warnings are not generated. This warning can + also be turned on using `-gnatwa'. + + `-gnatwC (suppress warnings on conditionals)' + This switch suppresses warnings for conditional expressions used in + tests that are known to be True or False at compile time. + + `-gnatwd (activate warnings on implicit dereferencing)' + If this switch is set, then the use of a prefix of an access type + in an indexed component, slice, or selected component without an + explicit `.all' will generate a warning. With this warning + enabled, access checks occur only at points where an explicit + `.all' appears in the source code (assuming no warnings are + generated as a result of this switch). The default is that such + warnings are not generated. Note that `-gnatwa' does not affect + the setting of this warning option. + + `-gnatwD (suppress warnings on implicit dereferencing)' + This switch suppresses warnings for implicit deferences in indexed + components, slices, and selected components. + + `-gnatwe (treat warnings as errors)' + This switch causes warning messages to be treated as errors. The + warning string still appears, but the warning messages are counted + as errors, and prevent the generation of an object file. + + `-gnatwf (activate warnings on unreferenced formals)' + This switch causes a warning to be generated if a formal parameter + is not referenced in the body of the subprogram. This warning can + also be turned on using `-gnatwa' or `-gnatwu'. + + `-gnatwF (suppress warnings on unreferenced formals)' + This switch suppresses warnings for unreferenced formal + parameters. Note that the combination `-gnatwu' followed by + `-gnatwF' has the effect of warning on unreferenced entities other + than subprogram formals. + + `-gnatwh (activate warnings on hiding)' + This switch activates warnings on hiding declarations. A + declaration is considered hiding if it is for a non-overloadable + entity, and it declares an entity with the same name as some other + entity that is directly or use-visible. The default is that such + warnings are not generated. Note that `-gnatwa' does not affect + the setting of this warning option. + + `-gnatwH (suppress warnings on hiding)' + This switch suppresses warnings on hiding declarations. + + `-gnatwi (activate warnings on implementation units).' + This switch activates warnings for a `with' of an internal GNAT + implementation unit, defined as any unit from the `Ada', + `Interfaces', `GNAT', or `System' hierarchies that is not + documented in either the Ada Reference Manual or the GNAT + Programmer's Reference Manual. Such units are intended only for + internal implementation purposes and should not be `with''ed by + user programs. The default is that such warnings are generated + This warning can also be turned on using `-gnatwa'. + + `-gnatwI (disable warnings on implementation units).' + This switch disables warnings for a `with' of an internal GNAT + implementation unit. + + `-gnatwl (activate warnings on elaboration pragmas)' + This switch activates warnings on missing pragma Elaborate_All + statements. See the section in this guide on elaboration checking + for details on when such pragma should be used. The default is + that such warnings are not generated. This warning can also be + turned on using `-gnatwa'. + + `-gnatwL (suppress warnings on elaboration pragmas)' + This switch suppresses warnings on missing pragma Elaborate_All + statements. See the section in this guide on elaboration checking + for details on when such pragma should be used. + + `-gnatwo (activate warnings on address clause overlays)' + This switch activates warnings for possibly unintended + initialization effects of defining address clauses that cause one + variable to overlap another. The default is that such warnings are + generated. This warning can also be turned on using `-gnatwa'. + + `-gnatwO (suppress warnings on address clause overlays)' + This switch suppresses warnings on possibly unintended + initialization effects of defining address clauses that cause one + variable to overlap another. + + `-gnatwp (activate warnings on ineffective pragma Inlines)' + This switch activates warnings for failure of front end inlining + (activated by `-gnatN') to inline a particular call. There are + many reasons for not being able to inline a call, including most + commonly that the call is too complex to inline. This warning can + also be turned on using `-gnatwa'. + + `-gnatwP (suppress warnings on ineffective pragma Inlines)' + This switch suppresses warnings on ineffective pragma Inlines. If + the inlining mechanism cannot inline a call, it will simply ignore + the request silently. + + `-gnatwr (activate warnings on redundant constructs)' + This switch activates warnings for redundant constructs. The + following is the current list of constructs regarded as redundant: + This warning can also be turned on using `-gnatwa'. + + * Assignment of an item to itself. + + * Type conversion that converts an expression to its own type. + + * Use of the attribute `Base' where `typ'Base' is the same as + `typ'. + + * Use of pragma `Pack' when all components are placed by a + record representation clause. + + `-gnatwR (suppress warnings on redundant constructs)' + This switch suppresses warnings for redundant constructs. + + `-gnatws (suppress all warnings)' + This switch completely suppresses the output of all warning + messages from the GNAT front end. Note that it does not suppress + warnings from the `gcc' back end. To suppress these back end + warnings as well, use the switch `-w' in addition to `-gnatws'. + + `-gnatwu (activate warnings on unused entities)' + This switch activates warnings to be generated for entities that + are defined but not referenced, and for units that are `with''ed + and not referenced. In the case of packages, a warning is also + generated if no entities in the package are referenced. This means + that if the package is referenced but the only references are in + `use' clauses or `renames' declarations, a warning is still + generated. A warning is also generated for a generic package that + is `with''ed but never instantiated. In the case where a package + or subprogram body is compiled, and there is a `with' on the + corresponding spec that is only referenced in the body, a warning + is also generated, noting that the `with' can be moved to the + body. The default is that such warnings are not generated. This + switch also activates warnings on unreferenced formals (it is + includes the effect of `-gnatwf'). This warning can also be + turned on using `-gnatwa'. + + `-gnatwU (suppress warnings on unused entities)' + This switch suppresses warnings for unused entities and packages. + It also turns off warnings on unreferenced formals (and thus + includes the effect of `-gnatwF'). + + A string of warning parameters can be used in the same parameter. + For example: + + -gnatwaLe + + Would turn on all optional warnings except for elaboration pragma + warnings, and also specify that warnings should be treated as + errors. + + `-w' + This switch suppresses warnings from the `gcc' backend. It may be + used in conjunction with `-gnatws' to ensure that all warnings are + suppressed during the entire compilation process. + +  + File: gnat_ug_unx.info, Node: Debugging and Assertion Control, Next: Run-Time Checks, Prev: Output and Error Message Control, Up: Switches for gcc + + Debugging and Assertion Control + ------------------------------- + + `-gnata' + The pragmas `Assert' and `Debug' normally have no effect and are + ignored. This switch, where `a' stands for assert, causes `Assert' + and `Debug' pragmas to be activated. + + The pragmas have the form: + + pragma Assert (BOOLEAN-EXPRESSION [, + STATIC-STRING-EXPRESSION]) + pragma Debug (PROCEDURE CALL) + + The `Assert' pragma causes BOOLEAN-EXPRESSION to be tested. If + the result is `True', the pragma has no effect (other than + possible side effects from evaluating the expression). If the + result is `False', the exception `Assert_Failure' declared in the + package `System.Assertions' is raised (passing + STATIC-STRING-EXPRESSION, if present, as the message associated + with the exception). If no string expression is given the default + is a string giving the file name and line number of the pragma. + + The `Debug' pragma causes PROCEDURE to be called. Note that + `pragma Debug' may appear within a declaration sequence, allowing + debugging procedures to be called between declarations. + +  + File: gnat_ug_unx.info, Node: Validity Checking, Next: Style Checking, Prev: Run-Time Control, Up: Switches for gcc + + Validity Checking + ----------------- + + The Ada 95 Reference Manual has specific requirements for checking for + invalid values. In particular, RM 13.9.1 requires that the evaluation + of invalid values (for example from unchecked conversions), not result + in erroneous execution. In GNAT, the result of such an evaluation in + normal default mode is to either use the value unmodified, or to raise + Constraint_Error in those cases where use of the unmodified value would + cause erroneous execution. The cases where unmodified values might lead + to erroneous execution are case statements (where a wild jump might + result from an invalid value), and subscripts on the left hand side + (where memory corruption could occur as a result of an invalid value). + + The `-gnatVx' switch allows more control over the validity checking + mode. The `x' argument here is a string of letters which control which + validity checks are performed in addition to the default checks + described above. + + * `-gnatVc' Validity checks for copies + + The right hand side of assignments, and the initializing values of + object declarations are validity checked. + + * `-gnatVd' Default (RM) validity checks + + Some validity checks are done by default following normal Ada + semantics (RM 13.9.1 (9-11)). A check is done in case statements + that the expression is within the range of the subtype. If it is + not, Constraint_Error is raised. For assignments to array + components, a check is done that the expression used as index is + within the range. If it is not, Constraint_Error is raised. Both + these validity checks may be turned off using switch `-gnatVD'. + They are turned on by default. If `-gnatVD' is specified, a + subsequent switch `-gnatVd' will leave the checks turned on. + Switch `-gnatVD' should be used only if you are sure that all such + expressions have valid values. If you use this switch and invalid + values are present, then the program is erroneous, and wild jumps + or memory overwriting may occur. + + * `-gnatVi' Validity checks for `in' mode parameters + + Arguments for parameters of mode `in' are validity checked in + function and procedure calls at the point of call. + + * `-gnatVm' Validity checks for `in out' mode parameters + + Arguments for parameters of mode `in out' are validity checked in + procedure calls at the point of call. The `'m'' here stands for + modify, since this concerns parameters that can be modified by the + call. Note that there is no specific option to test `out' + parameters, but any reference within the subprogram will be tested + in the usual manner, and if an invalid value is copied back, any + reference to it will be subject to validity checking. + + * `-gnatVo' Validity checks for operator and attribute operands + + Arguments for predefined operators and attributes are validity + checked. This includes all operators in package `Standard', the + shift operators defined as intrinsic in package `Interfaces' and + operands for attributes such as `Pos'. + + * `-gnatVr' Validity checks for function returns + + The expression in `return' statements in functions is validity + checked. + + * `-gnatVs' Validity checks for subscripts + + All subscripts expressions are checked for validity, whether they + appear on the right side or left side (in default mode only left + side subscripts are validity checked). + + * `-gnatVt' Validity checks for tests + + Expressions used as conditions in `if', `while' or `exit' + statements are checked, as well as guard expressions in entry + calls. + + * `-gnatVf' Validity checks for floating-point values + + In the absence of this switch, validity checking occurs only for + discrete values. If `-gnatVf' is specified, then validity checking + also applies for floating-point values, and NaN's and infinities + are considered invalid, as well as out of range values for + constrained types. Note that this means that standard `IEEE' + infinity mode is not allowed. The exact contexts in which + floating-point values are checked depends on the setting of other + options. For example `-gnatVif' or `-gnatVfi' (the order does not + matter) specifies that floating-point parameters of mode `in' + should be validity checked. + + * `-gnatVa' All validity checks + + All the above validity checks are turned on. That is `-gnatVa' is + equivalent to `gnatVcdfimorst'. + + * `-gnatVn' No validity checks + + This switch turns off all validity checking, including the default + checking for case statements and left hand side subscripts. Note + that the use of the switch `-gnatp' supresses all run-time checks, + including validity checks, and thus implies `-gnatVn'. + + + The `-gnatV' switch may be followed by a string of letters to turn on + a series of validity checking options. For example, `-gnatVcr' specifies + that in addition to the default validity checking, copies and function + return expressions be validity checked. In order to make it easier to + specify a set of options, the upper case letters `CDFIMORST' may be + used to turn off the corresponding lower case option, so for example + `-gnatVaM' turns on all validity checking options except for checking + of `in out' procedure arguments. + + The specification of additional validity checking generates extra + code (and in the case of `-gnatva' the code expansion can be + substantial. However, these additional checks can be very useful in + smoking out cases of uninitialized variables, incorrect use of + unchecked conversion, and other errors leading to invalid values. The + use of pragma `Initialize_Scalars' is useful in conjunction with the + extra validity checking, since this ensures that wherever possible + uninitialized variables have invalid values. + + See also the pragma `Validity_Checks' which allows modification of + the validity checking mode at the program source level, and also allows + for temporary disabling of validity checks. + +  + File: gnat_ug_unx.info, Node: Style Checking, Next: Using gcc for Syntax Checking, Prev: Validity Checking, Up: Switches for gcc + + Style Checking + -------------- + + The -gnatyX switch causes the compiler to enforce specified style + rules. A limited set of style rules has been used in writing the GNAT + sources themselves. This switch allows user programs to activate all or + some of these checks. If the source program fails a specified style + check, an appropriate warning message is given, preceded by the + character sequence "(style)". The string X is a sequence of letters or + digits indicating the particular style checks to be performed. The + following checks are defined: + + `1-9 (specify indentation level)' + If a digit from 1-9 appears in the string after `-gnaty' then + proper indentation is checked, with the digit indicating the + indentation level required. The general style of required + indentation is as specified by the examples in the Ada Reference + Manual. Full line comments must be aligned with the `--' starting + on a column that is a multiple of the alignment level. + + `a (check attribute casing)' + If the letter a appears in the string after `-gnaty' then + attribute names, including the case of keywords such as `digits' + used as attributes names, must be written in mixed case, that is, + the initial letter and any letter following an underscore must be + uppercase. All other letters must be lowercase. + + `b (blanks not allowed at statement end)' + If the letter b appears in the string after `-gnaty' then trailing + blanks are not allowed at the end of statements. The purpose of + this rule, together with h (no horizontal tabs), is to enforce a + canonical format for the use of blanks to separate source tokens. + + `c (check comments)' + If the letter c appears in the string after `-gnaty' then comments + must meet the following set of rules: + + * The "-" that starts the column must either start in column + one, or else at least one blank must precede this sequence. + + * Comments that follow other tokens on a line must have at + least one blank following the "-" at the start of the comment. + + * Full line comments must have two blanks following the "-" + that starts the comment, with the following exceptions. + + * A line consisting only of the "-" characters, possibly + preceded by blanks is permitted. + + * A comment starting with "-x" where x is a special character + is permitted. This alows proper processing of the output + generated by specialized tools including `gnatprep' (where -! + is used) and the SPARK annnotation language (where -# is + used). For the purposes of this rule, a special character is + defined as being in one of the ASCII ranges 16#21#..16#2F# or + 16#3A#..16#3F#. + + * A line consisting entirely of minus signs, possibly preceded + by blanks, is permitted. This allows the construction of box + comments where lines of minus signs are used to form the top + and bottom of the box. + + * If a comment starts and ends with "-" is permitted as long as + at least one blank follows the initial "-". Together with the + preceding rule, this allows the construction of box comments, + as shown in the following example: + --------------------------- + -- This is a box comment -- + -- with two text lines. -- + --------------------------- + + `e (check end/exit labels)' + If the letter e appears in the string after `-gnaty' then optional + labels on `end' statements ending subprograms and on `exit' + statements exiting named loops, are required to be present. + + `f (no form feeds or vertical tabs)' + If the letter f appears in the string after `-gnaty' then neither + form feeds nor vertical tab characters are not permitted in the + source text. + + `h (no horizontal tabs)' + If the letter h appears in the string after `-gnaty' then + horizontal tab characters are not permitted in the source text. + Together with the b (no blanks at end of line) check, this + enforces a canonical form for the use of blanks to separate source + tokens. + + `i (check if-then layout)' + If the letter i appears in the string after `-gnaty', then the + keyword `then' must appear either on the same line as + corresponding `if', or on a line on its own, lined up under the + `if' with at least one non-blank line in between containing all or + part of the condition to be tested. + + `k (check keyword casing)' + If the letter k appears in the string after `-gnaty' then all + keywords must be in lower case (with the exception of keywords + such as `digits' used as attribute names to which this check does + not apply). + + `l (check layout)' + If the letter l appears in the string after `-gnaty' then layout + of statement and declaration constructs must follow the + recommendations in the Ada Reference Manual, as indicated by the + form of the syntax rules. For example an `else' keyword must be + lined up with the corresponding `if' keyword. + + There are two respects in which the style rule enforced by this + check option are more liberal than those in the Ada Reference + Manual. First in the case of record declarations, it is + permissible to put the `record' keyword on the same line as the + `type' keyword, and then the `end' in `end record' must line up + under `type'. For example, either of the following two layouts is + acceptable: + + type q is record + a : integer; + b : integer; + end record; + + type q is + record + a : integer; + b : integer; + end record; + + Second, in the case of a block statement, a permitted alternative + is to put the block label on the same line as the `declare' or + `begin' keyword, and then line the `end' keyword up under the + block label. For example both the following are permitted: + + Block : declare + A : Integer := 3; + begin + Proc (A, A); + end Block; + + Block : + declare + A : Integer := 3; + begin + Proc (A, A); + end Block; + + The same alternative format is allowed for loops. For example, + both of the following are permitted: + + Clear : while J < 10 loop + A (J) := 0; + end loop Clear; + + Clear : + while J < 10 loop + A (J) := 0; + end loop Clear; + + `m (check maximum line length)' + If the letter m appears in the string after `-gnaty' then the + length of source lines must not exceed 79 characters, including + any trailing blanks. The value of 79 allows convenient display on + an 80 character wide device or window, allowing for possible + special treatment of 80 character lines. + + `Mnnn (set maximum line length)' + If the sequence Mnnn, where nnn is a decimal number, appears in + the string after `-gnaty' then the length of lines must not exceed + the given value. + + `n (check casing of entities in Standard)' + If the letter n appears in the string after `-gnaty' then any + identifier from Standard must be cased to match the presentation + in the Ada Reference Manual (for example, `Integer' and + `ASCII.NUL'). + + `o (check order of subprogram bodies)' + If the letter o appears in the string after `-gnaty' then all + subprogram bodies in a given scope (e.g. a package body) must be + in alphabetical order. The ordering rule uses normal Ada rules for + comparing strings, ignoring casing of letters, except that if + there is a trailing numeric suffix, then the value of this suffix + is used in the ordering (e.g. Junk2 comes before Junk10). + + `p (check pragma casing)' + If the letter p appears in the string after `-gnaty' then pragma + names must be written in mixed case, that is, the initial letter + and any letter following an underscore must be uppercase. All + other letters must be lowercase. + + `r (check references)' + If the letter r appears in the string after `-gnaty' then all + identifier references must be cased in the same way as the + corresponding declaration. No specific casing style is imposed on + identifiers. The only requirement is for consistency of references + with declarations. + + `s (check separate specs)' + If the letter s appears in the string after `-gnaty' then separate + declarations ("specs") are required for subprograms (a body is not + allowed to serve as its own declaration). The only exception is + that parameterless library level procedures are not required to + have a separate declaration. This exception covers the most + frequent form of main program procedures. + + `t (check token spacing)' + If the letter t appears in the string after `-gnaty' then the + following token spacing rules are enforced: + + * The keywords `abs' and `not' must be followed by a space. + + * The token `=>' must be surrounded by spaces. + + * The token `<>' must be preceded by a space or a left + parenthesis. + + * Binary operators other than `**' must be surrounded by spaces. + There is no restriction on the layout of the `**' binary + operator. + + * Colon must be surrounded by spaces. + + * Colon-equal (assignment) must be surrounded by spaces. + + * Comma must be the first non-blank character on the line, or be + immediately preceded by a non-blank character, and must be + followed by a space. + + * If the token preceding a left paren ends with a letter or + digit, then a space must separate the two tokens. + + * A right parenthesis must either be the first non-blank + character on a line, or it must be preceded by a non-blank + character. + + * A semicolon must not be preceded by a space, and must not be + followed by a non-blank character. + + * A unary plus or minus may not be followed by a space. + + * A vertical bar must be surrounded by spaces. + + In the above rules, appearing in column one is always permitted, + that is, counts as meeting either a requirement for a required + preceding space, or as meeting a requirement for no preceding + space. + + Appearing at the end of a line is also always permitted, that is, + counts as meeting either a requirement for a following space, or + as meeting a requirement for no following space. + + If any of these style rules is violated, a message is generated giving + details on the violation. The initial characters of such messages are + always "(style)". Note that these messages are treated as warning + messages, so they normally do not prevent the generation of an object + file. The `-gnatwe' switch can be used to treat warning messages, + including style messages, as fatal errors. + + The switch `-gnaty' on its own (that is not followed by any letters or + digits), is equivalent to `gnaty3abcefhiklmprst', that is all checking + options are enabled with the exception of -gnatyo, with an indentation + level of 3. This is the standard checking option that is used for the + GNAT sources. + +  + File: gnat_ug_unx.info, Node: Run-Time Checks, Next: Stack Overflow Checking, Prev: Debugging and Assertion Control, Up: Switches for gcc + + Run-Time Checks + --------------- + + If you compile with the default options, GNAT will insert many run-time + checks into the compiled code, including code that performs range + checking against constraints, but not arithmetic overflow checking for + integer operations (including division by zero) or checks for access + before elaboration on subprogram calls. All other run-time checks, as + required by the Ada 95 Reference Manual, are generated by default. The + following `gcc' switches refine this default behavior: + + `-gnatp' + Suppress all run-time checks as though `pragma Suppress + (all_checks') had been present in the source. Validity checks are + also suppressed (in other words `-gnatp' also implies `-gnatVn'. + Use this switch to improve the performance of the code at the + expense of safety in the presence of invalid data or program bugs. + + `-gnato' + Enables overflow checking for integer operations. This causes + GNAT to generate slower and larger executable programs by adding + code to check for overflow (resulting in raising + `Constraint_Error' as required by standard Ada semantics). These + overflow checks correspond to situations in which the true value + of the result of an operation may be outside the base range of the + result type. The following example shows the distinction: + + X1 : Integer := Integer'Last; + X2 : Integer range 1 .. 5 := 5; + ... + X1 := X1 + 1; -- `-gnato' required to catch the Constraint_Error + X2 := X2 + 1; -- range check, `-gnato' has no effect here + + Here the first addition results in a value that is outside the + base range of Integer, and hence requires an overflow check for + detection of the constraint error. The second increment operation + results in a violation of the explicit range constraint, and such + range checks are always performed. Basically the compiler can + assume that in the absence of the `-gnato' switch that any value + of type `xxx' is in range of the base type of `xxx'. + + Note that the `-gnato' switch does not affect the code generated + for any floating-point operations; it applies only to integer + semantics). For floating-point, GNAT has the `Machine_Overflows' + attribute set to `False' and the normal mode of operation is to + generate IEEE NaN and infinite values on overflow or invalid + operations (such as dividing 0.0 by 0.0). + + The reason that we distinguish overflow checking from other kinds + of range constraint checking is that a failure of an overflow + check can generate an incorrect value, but cannot cause erroneous + behavior. This is unlike the situation with a constraint check on + an array subscript, where failure to perform the check can result + in random memory description, or the range check on a case + statement, where failure to perform the check can cause a wild + jump. + + Note again that `-gnato' is off by default, so overflow checking is + not performed in default mode. This means that out of the box, + with the default settings, GNAT does not do all the checks + expected from the language description in the Ada Reference + Manual. If you want all constraint checks to be performed, as + described in this Manual, then you must explicitly use the -gnato + switch either on the `gnatmake' or `gcc' command. + + `-gnatE' + Enables dynamic checks for access-before-elaboration on subprogram + calls and generic instantiations. For full details of the effect + and use of this switch, *Note Compiling Using gcc::. + + The setting of these switches only controls the default setting of the + checks. You may modify them using either `Suppress' (to remove checks) + or `Unsuppress' (to add back suppressed checks) pragmas in the program + source. + +  + File: gnat_ug_unx.info, Node: Stack Overflow Checking, Next: Run-Time Control, Prev: Run-Time Checks, Up: Switches for gcc + + Stack Overflow Checking + ----------------------- + + For most operating systems, `gcc' does not perform stack overflow + checking by default. This means that if the main environment task or + some other task exceeds the available stack space, then unpredictable + behavior will occur. + + To activate stack checking, compile all units with the gcc option + `-fstack-check'. For example: + + gcc -c -fstack-check package1.adb + + Units compiled with this option will generate extra instructions to + check that any use of the stack (for procedure calls or for declaring + local variables in declare blocks) do not exceed the available stack + space. If the space is exceeded, then a `Storage_Error' exception is + raised. + + For declared tasks, the stack size is always controlled by the size + given in an applicable `Storage_Size' pragma (or is set to the default + size if no pragma is used. + + For the environment task, the stack size depends on system defaults + and is unknown to the compiler. The stack may even dynamically grow on + some systems, precluding the normal Ada semantics for stack overflow. + In the worst case, unbounded stack usage, causes unbounded stack + expansion resulting in the system running out of virtual memory. + + The stack checking may still work correctly if a fixed size stack is + allocated, but this cannot be guaranteed. To ensure that a clean + exception is signalled for stack overflow, set the environment variable + `GNAT_STACK_LIMIT' to indicate the maximum stack area that can be used, + as in: + + SET GNAT_STACK_LIMIT 1600 + + The limit is given in kilobytes, so the above declaration would set the + stack limit of the environment task to 1.6 megabytes. Note that the + only purpose of this usage is to limit the amount of stack used by the + environment task. If it is necessary to increase the amount of stack + for the environment task, then this is an operating systems issue, and + must be addressed with the appropriate operating systems commands. + +  + File: gnat_ug_unx.info, Node: Run-Time Control, Next: Validity Checking, Prev: Stack Overflow Checking, Up: Switches for gcc + + Run-Time Control + ---------------- + + `-gnatT nnn' + The `gnatT' switch can be used to specify the time-slicing value + to be used for task switching between equal priority tasks. The + value `nnn' is given in microseconds as a decimal integer. + + Setting the time-slicing value is only effective if the underlying + thread control system can accommodate time slicing. Check the + documentation of your operating system for details. Note that the + time-slicing value can also be set by use of pragma `Time_Slice' + or by use of the `t' switch in the gnatbind step. The pragma + overrides a command line argument if both are present, and the `t' + switch for gnatbind overrides both the pragma and the `gcc' + command line switch. + +  + File: gnat_ug_unx.info, Node: Using gcc for Syntax Checking, Next: Using gcc for Semantic Checking, Prev: Style Checking, Up: Switches for gcc + + Using `gcc' for Syntax Checking + ------------------------------- + + `-gnats' + The `s' stands for syntax. + + Run GNAT in syntax checking only mode. For example, the command + + $ gcc -c -gnats x.adb + + compiles file `x.adb' in syntax-check-only mode. You can check a + series of files in a single command , and can use wild cards to + specify such a group of files. Note that you must specify the + `-c' (compile only) flag in addition to the `-gnats' flag. . + + You may use other switches in conjunction with `-gnats'. In + particular, `-gnatl' and `-gnatv' are useful to control the format + of any generated error messages. + + The output is simply the error messages, if any. No object file or + ALI file is generated by a syntax-only compilation. Also, no units + other than the one specified are accessed. For example, if a unit + `X' `with''s a unit `Y', compiling unit `X' in syntax check only + mode does not access the source file containing unit `Y'. + + Normally, GNAT allows only a single unit in a source file. + However, this restriction does not apply in syntax-check-only + mode, and it is possible to check a file containing multiple + compilation units concatenated together. This is primarily used by + the `gnatchop' utility (*note Renaming Files Using gnatchop::). + +  + File: gnat_ug_unx.info, Node: Using gcc for Semantic Checking, Next: Compiling Ada 83 Programs, Prev: Using gcc for Syntax Checking, Up: Switches for gcc + + Using `gcc' for Semantic Checking + --------------------------------- + + `-gnatc' + The `c' stands for check. Causes the compiler to operate in + semantic check mode, with full checking for all illegalities + specified in the Ada 95 Reference Manual, but without generation + of any object code (no object file is generated). + + Because dependent files must be accessed, you must follow the GNAT + semantic restrictions on file structuring to operate in this mode: + + * The needed source files must be accessible (*note Search + Paths and the Run-Time Library (RTL)::). + + * Each file must contain only one compilation unit. + + * The file name and unit name must match (*note File Naming + Rules::). + + The output consists of error messages as appropriate. No object + file is generated. An `ALI' file is generated for use in the + context of cross-reference tools, but this file is marked as not + being suitable for binding (since no object file is generated). + The checking corresponds exactly to the notion of legality in the + Ada 95 Reference Manual. + + Any unit can be compiled in semantics-checking-only mode, including + units that would not normally be compiled (subunits, and + specifications where a separate body is present). + +  + File: gnat_ug_unx.info, Node: Compiling Ada 83 Programs, Next: Character Set Control, Prev: Using gcc for Semantic Checking, Up: Switches for gcc + + Compiling Ada 83 Programs + ------------------------- + + `-gnat83' + Although GNAT is primarily an Ada 95 compiler, it accepts this + switch to specify that an Ada 83 program is to be compiled in + Ada83 mode. If you specify this switch, GNAT rejects most Ada 95 + extensions and applies Ada 83 semantics where this can be done + easily. It is not possible to guarantee this switch does a perfect + job; for example, some subtle tests, such as are found in earlier + ACVC tests (that have been removed from the ACVC suite for Ada + 95), may not compile correctly. However, for most purposes, using + this switch should help to ensure that programs that compile + correctly under the `-gnat83' switch can be ported easily to an + Ada 83 compiler. This is the main use of the switch. + + With few exceptions (most notably the need to use `<>' on + unconstrained generic formal parameters, the use of the new Ada 95 + keywords, and the use of packages with optional bodies), it is not + necessary to use the `-gnat83' switch when compiling Ada 83 + programs, because, with rare exceptions, Ada 95 is upwardly + compatible with Ada 83. This means that a correct Ada 83 program + is usually also a correct Ada 95 program. + +  + File: gnat_ug_unx.info, Node: Character Set Control, Next: File Naming Control, Prev: Compiling Ada 83 Programs, Up: Switches for gcc + + Character Set Control + --------------------- + + `-gnatiC' + Normally GNAT recognizes the Latin-1 character set in source + program identifiers, as described in the Ada 95 Reference Manual. + This switch causes GNAT to recognize alternate character sets in + identifiers. C is a single character indicating the character + set, as follows: + + `1' + Latin-1 identifiers + + `2' + Latin-2 letters allowed in identifiers + + `3' + Latin-3 letters allowed in identifiers + + `4' + Latin-4 letters allowed in identifiers + + `5' + Latin-5 (Cyrillic) letters allowed in identifiers + + `9' + Latin-9 letters allowed in identifiers + + `p' + IBM PC letters (code page 437) allowed in identifiers + + `8' + IBM PC letters (code page 850) allowed in identifiers + + `f' + Full upper-half codes allowed in identifiers + + `n' + No upper-half codes allowed in identifiers + + `w' + Wide-character codes (that is, codes greater than 255) + allowed in identifiers + + *Note Foreign Language Representation::, for full details on the + implementation of these character sets. + + `-gnatWE' + Specify the method of encoding for wide characters. E is one of + the following: + + `h' + Hex encoding (brackets coding also recognized) + + `u' + Upper half encoding (brackets encoding also recognized) + + `s' + Shift/JIS encoding (brackets encoding also recognized) + + `e' + EUC encoding (brackets encoding also recognized) + + `8' + UTF-8 encoding (brackets encoding also recognized) + + `b' + Brackets encoding only (default value) For full details on + the these encoding methods see *Note Wide Character Encodings::. + Note that brackets coding is always accepted, even if one of the + other options is specified, so for example `-gnatW8' specifies + that both brackets and `UTF-8' encodings will be recognized. The + units that are with'ed directly or indirectly will be scanned + using the specified representation scheme, and so if one of the + non-brackets scheme is used, it must be used consistently + throughout the program. However, since brackets encoding is always + recognized, it may be conveniently used in standard libraries, + allowing these libraries to be used with any of the available + coding schemes. scheme. If no `-gnatW?' parameter is present, + then the default representation is Brackets encoding only. + + Note that the wide character representation that is specified + (explicitly or by default) for the main program also acts as the + default encoding used for Wide_Text_IO files if not specifically + overridden by a WCEM form parameter. + +  + File: gnat_ug_unx.info, Node: File Naming Control, Next: Subprogram Inlining Control, Prev: Character Set Control, Up: Switches for gcc + + File Naming Control + ------------------- + + `-gnatkN' + Activates file name "krunching". N, a decimal integer in the range + 1-999, indicates the maximum allowable length of a file name (not + including the `.ads' or `.adb' extension). The default is not to + enable file name krunching. + + For the source file naming rules, *Note File Naming Rules::. + +  + File: gnat_ug_unx.info, Node: Subprogram Inlining Control, Next: Auxiliary Output Control, Prev: File Naming Control, Up: Switches for gcc + + Subprogram Inlining Control + --------------------------- + + `-gnatn' + The `n' here is intended to suggest the first syllable of the word + "inline". GNAT recognizes and processes `Inline' pragmas. + However, for the inlining to actually occur, optimization must be + enabled. To enable inlining across unit boundaries, this is, + inlining a call in one unit of a subprogram declared in a + `with''ed unit, you must also specify this switch. In the absence + of this switch, GNAT does not attempt inlining across units and + does not need to access the bodies of subprograms for which + `pragma Inline' is specified if they are not in the current unit. + + If you specify this switch the compiler will access these bodies, + creating an extra source dependency for the resulting object file, + and where possible, the call will be inlined. For further details + on when inlining is possible see *Note Inlining of Subprograms::. + + `-gnatN' + The front end inlining activated by this switch is generally more + extensive, and quite often more effective than the standard + `-gnatn' inlining mode. It will also generate additional + dependencies. + +  + File: gnat_ug_unx.info, Node: Auxiliary Output Control, Next: Debugging Control, Prev: Subprogram Inlining Control, Up: Switches for gcc + + Auxiliary Output Control + ------------------------ + + `-gnatt' + Causes GNAT to write the internal tree for a unit to a file (with + the extension `.adt'. This not normally required, but is used by + separate analysis tools. Typically these tools do the necessary + compilations automatically, so you should not have to specify this + switch in normal operation. + + `-gnatu' + Print a list of units required by this compilation on `stdout'. + The listing includes all units on which the unit being compiled + depends either directly or indirectly. + + `-pass-exit-codes' + If this switch is not used, the exit code returned by `gcc' when + compiling multiple files indicates whether all source files have + been successfully used to generate object files or not. + + When `-pass-exit-codes' is used, `gcc' exits with an extended exit + status and allows an integrated development environment to better + react to a compilation failure. Those exit status are: + + 5 + There was an error in at least one source file. + + 3 + At least one source file did not generate an object file. + + 2 + The compiler died unexpectedly (internal error for example). + + 0 + An object file has been generated for every source file. + +  + File: gnat_ug_unx.info, Node: Debugging Control, Next: Units to Sources Mapping Files, Prev: Auxiliary Output Control, Up: Switches for gcc + + Debugging Control + ----------------- + + `-gnatdX' + Activate internal debugging switches. X is a letter or digit, or + string of letters or digits, which specifies the type of debugging + outputs desired. Normally these are used only for internal + development or system debugging purposes. You can find full + documentation for these switches in the body of the `Debug' unit + in the compiler source file `debug.adb'. + + `-gnatG' + This switch causes the compiler to generate auxiliary output + containing a pseudo-source listing of the generated expanded code. + Like most Ada compilers, GNAT works by first transforming the high + level Ada code into lower level constructs. For example, tasking + operations are transformed into calls to the tasking run-time + routines. A unique capability of GNAT is to list this expanded + code in a form very close to normal Ada source. This is very + useful in understanding the implications of various Ada usage on + the efficiency of the generated code. There are many cases in Ada + (e.g. the use of controlled types), where simple Ada statements can + generate a lot of run-time code. By using `-gnatG' you can identify + these cases, and consider whether it may be desirable to modify + the coding approach to improve efficiency. + + The format of the output is very similar to standard Ada source, + and is easily understood by an Ada programmer. The following + special syntactic additions correspond to low level features used + in the generated code that do not have any exact analogies in pure + Ada source form. The following is a partial list of these special + constructions. See the specification of package `Sprint' in file + `sprint.ads' for a full list. + + `new XXX [storage_pool = YYY]' + Shows the storage pool being used for an allocator. + + `at end PROCEDURE-NAME;' + Shows the finalization (cleanup) procedure for a scope. + + `(if EXPR then EXPR else EXPR)' + Conditional expression equivalent to the `x?y:z' construction + in C. + + `TARGET^(SOURCE)' + A conversion with floating-point truncation instead of + rounding. + + `TARGET?(SOURCE)' + A conversion that bypasses normal Ada semantic checking. In + particular enumeration types and fixed-point types are + treated simply as integers. + + `TARGET?^(SOURCE)' + Combines the above two cases. + + `X #/ Y' + `X #mod Y' + `X #* Y' + `X #rem Y' + A division or multiplication of fixed-point values which are + treated as integers without any kind of scaling. + + `free EXPR [storage_pool = XXX]' + Shows the storage pool associated with a `free' statement. + + `freeze TYPENAME [ACTIONS]' + Shows the point at which TYPENAME is frozen, with possible + associated actions to be performed at the freeze point. + + `reference ITYPE' + Reference (and hence definition) to internal type ITYPE. + + `FUNCTION-NAME! (ARG, ARG, ARG)' + Intrinsic function call. + + `LABELNAME : label' + Declaration of label LABELNAME. + + `EXPR && EXPR && EXPR ... && EXPR' + A multiple concatenation (same effect as EXPR & EXPR & EXPR, + but handled more efficiently). + + `[constraint_error]' + Raise the `Constraint_Error' exception. + + `EXPRESSION'reference' + A pointer to the result of evaluating EXPRESSION. + + `TARGET-TYPE!(SOURCE-EXPRESSION)' + An unchecked conversion of SOURCE-EXPRESSION to TARGET-TYPE. + + `[NUMERATOR/DENOMINATOR]' + Used to represent internal real literals (that) have no exact + representation in base 2-16 (for example, the result of + compile time evaluation of the expression 1.0/27.0). + + `-gnatD' + This switch is used in conjunction with `-gnatG' to cause the + expanded source, as described above to be written to files + with names `xxx.dg', where `xxx' is the normal file name, for + example, if the source file name is `hello.adb', then a file + `hello.adb.dg' will be written. The debugging information + generated by the `gcc' `-g' switch will refer to the generated + `xxx.dg' file. This allows you to do source level debugging + using the generated code which is sometimes useful for + complex code, for example to find out exactly which part of a + complex construction raised an exception. This switch also + suppress generation of cross-reference information (see + -gnatx). + + `-gnatC' + In the generated debugging information, and also in the case + of long external names, the compiler uses a compression + mechanism if the name is very long. This compression method + uses a checksum, and avoids trouble on some operating systems + which have difficulty with very long names. The `-gnatC' + switch forces this compression approach to be used on all + external names and names in the debugging information tables. + This reduces the size of the generated executable, at the + expense of making the naming scheme more complex. The + compression only affects the qualification of the name. Thus + a name in the source: + + Very_Long_Package.Very_Long_Inner_Package.Var + + would normally appear in these tables as: + + very_long_package__very_long_inner_package__var + + but if the `-gnatC' switch is used, then the name appears as + + XCb7e0c705__var + + Here b7e0c705 is a compressed encoding of the qualification + prefix. The GNAT Ada aware version of GDB understands these + encoded prefixes, so if this debugger is used, the encoding + is largely hidden from the user of the compiler. + + `-gnatR[0|1|2|3][s]' + This switch controls output from the compiler of a listing showing + representation information for declared types and objects. For + `-gnatR0', no information is output (equivalent to omitting the + `-gnatR' switch). For `-gnatR1' (which is the default, so `-gnatR' + with no parameter has the same effect), size and alignment + information is listed for declared array and record types. For + `-gnatR2', size and alignment information is listed for all + expression information for values that are computed at run time for + variant records. These symbolic expressions have a mostly obvious + format with #n being used to represent the value of the n'th + discriminant. See source files `repinfo.ads/adb' in the `GNAT' + sources for full detalis on the format of `-gnatR3' output. If the + switch is followed by an s (e.g. `-gnatR2s'), then the output is + to a file with the name `file.rep' where file is the name of the + corresponding source file. + + `-gnatx' + Normally the compiler generates full cross-referencing information + in the `ALI' file. This information is used by a number of tools, + including `gnatfind' and `gnatxref'. The -gnatx switch suppresses + this information. This saves some space and may slightly speed up + compilation, but means that these tools cannot be used. + +  + File: gnat_ug_unx.info, Node: Units to Sources Mapping Files, Prev: Debugging Control, Up: Switches for gcc + + Units to Sources Mapping Files + ------------------------------ + + `-gnatemPATH' + A mapping file is a way to communicate to the compiler two + mappings: from unit names to file names (without any directory + information) and from file names to path names (with full + directory information). These mappings are used by the compiler to + short-circuit the path search. + + A mapping file is a sequence of sets of three lines. In each set, + the first line is the unit name, in lower case, with "%s" appended + for specifications and "%b" appended for bodies; the second line + is the file name; and the third line is the path name. + + Example: + main%b + main.2.ada + /gnat/project1/sources/main.2.ada + + When the switch `-gnatem' is specified, the compiler will create + in memory the two mappings from the specified file. If there is + any problem (non existent file, truncated file or duplicate + entries), no mapping will be created. + + Several `-gnatem' switches may be specified; however, only the last + one on the command line will be taken into account. + + When using a project file, `gnatmake' create a temporary mapping + file and communicates it to the compiler using this switch. + +  + File: gnat_ug_unx.info, Node: Search Paths and the Run-Time Library (RTL), Next: Order of Compilation Issues, Prev: Switches for gcc, Up: Compiling Using gcc + + Search Paths and the Run-Time Library (RTL) + =========================================== + + With the GNAT source-based library system, the compiler must be able to + find source files for units that are needed by the unit being compiled. + Search paths are used to guide this process. + + The compiler compiles one source file whose name must be given + explicitly on the command line. In other words, no searching is done + for this file. To find all other source files that are needed (the most + common being the specs of units), the compiler examines the following + directories, in the following order: + + 1. The directory containing the source file of the main unit being + compiled (the file name on the command line). + + 2. Each directory named by an `-I' switch given on the `gcc' command + line, in the order given. + + 3. Each of the directories listed in the value of the + `ADA_INCLUDE_PATH' environment variable. Construct this value + exactly as the `PATH' environment variable: a list of directory + names separated by colons (semicolons when working with the NT + version). + + 4. The content of the "ada_source_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as + the GNAT Run Time Library (RTL) source files. *Note Installing an + Ada Library:: + + Specifying the switch `-I-' inhibits the use of the directory + containing the source file named in the command line. You can still + have this directory on your search path, but in this case it must be + explicitly requested with a `-I' switch. + + Specifying the switch `-nostdinc' inhibits the search of the default + location for the GNAT Run Time Library (RTL) source files. + + The compiler outputs its object files and ALI files in the current + working directory. Caution: The object file can be redirected with the + `-o' switch; however, `gcc' and `gnat1' have not been coordinated on + this so the ALI file will not go to the right place. Therefore, you + should avoid using the `-o' switch. + + The packages `Ada', `System', and `Interfaces' and their children + make up the GNAT RTL, together with the simple `System.IO' package used + in the "Hello World" example. The sources for these units are needed by + the compiler and are kept together in one directory. Not all of the + bodies are needed, but all of the sources are kept together anyway. In + a normal installation, you need not specify these directory names when + compiling or binding. Either the environment variables or the built-in + defaults cause these files to be found. + + In addition to the language-defined hierarchies (System, Ada and + Interfaces), the GNAT distribution provides a fourth hierarchy, + consisting of child units of GNAT. This is a collection of generally + useful routines. See the GNAT Reference Manual for further details. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + +  + File: gnat_ug_unx.info, Node: Order of Compilation Issues, Next: Examples, Prev: Search Paths and the Run-Time Library (RTL), Up: Compiling Using gcc + + Order of Compilation Issues + =========================== + + If, in our earlier example, there was a spec for the `hello' procedure, + it would be contained in the file `hello.ads'; yet this file would not + have to be explicitly compiled. This is the result of the model we + chose to implement library management. Some of the consequences of this + model are as follows: + + * There is no point in compiling specs (except for package specs + with no bodies) because these are compiled as needed by clients. If + you attempt a useless compilation, you will receive an error + message. It is also useless to compile subunits because they are + compiled as needed by the parent. + + * There are no order of compilation requirements: performing a + compilation never obsoletes anything. The only way you can obsolete + something and require recompilations is to modify one of the + source files on which it depends. + + * There is no library as such, apart from the ALI files (*note The + Ada Library Information Files::, for information on the format of + these files). For now we find it convenient to create separate ALI + files, but eventually the information therein may be incorporated + into the object file directly. + + * When you compile a unit, the source files for the specs of all + units that it `with''s, all its subunits, and the bodies of any + generics it instantiates must be available (reachable by the + search-paths mechanism described above), or you will receive a + fatal error message. + +  + File: gnat_ug_unx.info, Node: Examples, Prev: Order of Compilation Issues, Up: Compiling Using gcc + + Examples + ======== + + The following are some typical Ada compilation command line examples: + + `$ gcc -c xyz.adb' + Compile body in file `xyz.adb' with all default options. + + `$ gcc -c -O2 -gnata xyz-def.adb' + Compile the child unit package in file `xyz-def.adb' with extensive + optimizations, and pragma `Assert'/`Debug' statements enabled. + + `$ gcc -c -gnatc abc-def.adb' + Compile the subunit in file `abc-def.adb' in semantic-checking-only + mode. + +  + File: gnat_ug_unx.info, Node: Binding Using gnatbind, Next: Linking Using gnatlink, Prev: Compiling Using gcc, Up: Top + + Binding Using `gnatbind' + ************************ + + * Menu: + + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + + This chapter describes the GNAT binder, `gnatbind', which is used to + bind compiled GNAT objects. The `gnatbind' program performs four + separate functions: + + 1. Checks that a program is consistent, in accordance with the rules + in Chapter 10 of the Ada 95 Reference Manual. In particular, error + messages are generated if a program uses inconsistent versions of a + given unit. + + 2. Checks that an acceptable order of elaboration exists for the + program and issues an error message if it cannot find an order of + elaboration that satisfies the rules in Chapter 10 of the Ada 95 + Language Manual. + + 3. Generates a main program incorporating the given elaboration order. + This program is a small Ada package (body and spec) that must be + subsequently compiled using the GNAT compiler. The necessary + compilation step is usually performed automatically by `gnatlink'. + The two most important functions of this program are to call the + elaboration routines of units in an appropriate order and to call + the main program. + + 4. Determines the set of object files required by the given main + program. This information is output in the forms of comments in + the generated program, to be read by the `gnatlink' utility used + to link the Ada application. + +  + File: gnat_ug_unx.info, Node: Running gnatbind, Next: Generating the Binder Program in C, Up: Binding Using gnatbind + + Running `gnatbind' + ================== + + The form of the `gnatbind' command is + + $ gnatbind [SWITCHES] MAINPROG[.ali] [SWITCHES] + + where MAINPROG.adb is the Ada file containing the main program unit + body. If no switches are specified, `gnatbind' constructs an Ada + package in two files which names are `b~ADA_MAIN.ads', and + `b~ADA_MAIN.adb'. For example, if given the parameter `hello.ali', for + a main program contained in file `hello.adb', the binder output files + would be `b~hello.ads' and `b~hello.adb'. + + When doing consistency checking, the binder takes into consideration + any source files it can locate. For example, if the binder determines + that the given main program requires the package `Pack', whose `.ali' + file is `pack.ali' and whose corresponding source spec file is + `pack.ads', it attempts to locate the source file `pack.ads' (using the + same search path conventions as previously described for the `gcc' + command). If it can locate this source file, it checks that the time + stamps or source checksums of the source and its references to in `ali' + files match. In other words, any `ali' files that mentions this spec + must have resulted from compiling this version of the source file (or + in the case where the source checksums match, a version close enough + that the difference does not matter). + + The effect of this consistency checking, which includes source + files, is that the binder ensures that the program is consistent with + the latest version of the source files that can be located at bind + time. Editing a source file without compiling files that depend on the + source file cause error messages to be generated by the binder. + + For example, suppose you have a main program `hello.adb' and a + package `P', from file `p.ads' and you perform the following steps: + + 1. Enter `gcc -c hello.adb' to compile the main program. + + 2. Enter `gcc -c p.ads' to compile package `P'. + + 3. Edit file `p.ads'. + + 4. Enter `gnatbind hello'. + + At this point, the file `p.ali' contains an out-of-date time stamp + because the file `p.ads' has been edited. The attempt at binding fails, + and the binder generates the following error messages: + + error: "hello.adb" must be recompiled ("p.ads" has been modified) + error: "p.ads" has been modified and must be recompiled + + Now both files must be recompiled as indicated, and then the bind can + succeed, generating a main program. You need not normally be concerned + with the contents of this file, but it is similar to the following which + is the binder file generated for a simple "hello world" program. + + -- The package is called Ada_Main unless this name is actually used + -- as a unit name in the partition, in which case some other unique + -- name is used. + + with System; + package ada_main is + + Elab_Final_Code : Integer; + pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code"); + + -- The main program saves the parameters (argument count, + -- argument values, environment pointer) in global variables + -- for later access by other units including + -- Ada.Command_Line. + + gnat_argc : Integer; + gnat_argv : System.Address; + gnat_envp : System.Address; + + -- The actual variables are stored in a library routine. This + -- is useful for some shared library situations, where there + -- are problems if variables are not in the library. + + pragma Import (C, gnat_argc); + pragma Import (C, gnat_argv); + pragma Import (C, gnat_envp); + + -- The exit status is similarly an external location + + gnat_exit_status : Integer; + pragma Import (C, gnat_exit_status); + + GNAT_Version : constant String := + "GNAT Version: 3.15w (20010315)"; + pragma Export (C, GNAT_Version, "__gnat_version"); + + -- This is the generated adafinal routine that performs + -- finalization at the end of execution. In the case where + -- Ada is the main program, this main program makes a call + -- to adafinal at program termination. + + procedure adafinal; + pragma Export (C, adafinal, "adafinal"); + + -- This is the generated adainit routine that performs + -- initialization at the start of execution. In the case + -- where Ada is the main program, this main program makes + -- a call to adainit at program startup. + + procedure adainit; + pragma Export (C, adainit, "adainit"); + + -- This routine is called at the start of execution. It is + -- a dummy routine that is used by the debugger to breakpoint + -- at the start of execution. + + procedure Break_Start; + pragma Import (C, Break_Start, "__gnat_break_start"); + + -- This is the actual generated main program (it would be + -- suppressed if the no main program switch were used). As + -- required by standard system conventions, this program has + -- the external name main. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer; + pragma Export (C, main, "main"); + + -- The following set of constants give the version + -- identification values for every unit in the bound + -- partition. This identification is computed from all + -- dependent semantic units, and corresponds to the + -- string that would be returned by use of the + -- Body_Version or Version attributes. + + type Version_32 is mod 2 ** 32; + u00001 : constant Version_32 := 16#7880BEB3#; + u00002 : constant Version_32 := 16#0D24CBD0#; + u00003 : constant Version_32 := 16#3283DBEB#; + u00004 : constant Version_32 := 16#2359F9ED#; + u00005 : constant Version_32 := 16#664FB847#; + u00006 : constant Version_32 := 16#68E803DF#; + u00007 : constant Version_32 := 16#5572E604#; + u00008 : constant Version_32 := 16#46B173D8#; + u00009 : constant Version_32 := 16#156A40CF#; + u00010 : constant Version_32 := 16#033DABE0#; + u00011 : constant Version_32 := 16#6AB38FEA#; + u00012 : constant Version_32 := 16#22B6217D#; + u00013 : constant Version_32 := 16#68A22947#; + u00014 : constant Version_32 := 16#18CC4A56#; + u00015 : constant Version_32 := 16#08258E1B#; + u00016 : constant Version_32 := 16#367D5222#; + u00017 : constant Version_32 := 16#20C9ECA4#; + u00018 : constant Version_32 := 16#50D32CB6#; + u00019 : constant Version_32 := 16#39A8BB77#; + u00020 : constant Version_32 := 16#5CF8FA2B#; + u00021 : constant Version_32 := 16#2F1EB794#; + u00022 : constant Version_32 := 16#31AB6444#; + u00023 : constant Version_32 := 16#1574B6E9#; + u00024 : constant Version_32 := 16#5109C189#; + u00025 : constant Version_32 := 16#56D770CD#; + u00026 : constant Version_32 := 16#02F9DE3D#; + u00027 : constant Version_32 := 16#08AB6B2C#; + u00028 : constant Version_32 := 16#3FA37670#; + u00029 : constant Version_32 := 16#476457A0#; + u00030 : constant Version_32 := 16#731E1B6E#; + u00031 : constant Version_32 := 16#23C2E789#; + u00032 : constant Version_32 := 16#0F1BD6A1#; + u00033 : constant Version_32 := 16#7C25DE96#; + u00034 : constant Version_32 := 16#39ADFFA2#; + u00035 : constant Version_32 := 16#571DE3E7#; + u00036 : constant Version_32 := 16#5EB646AB#; + u00037 : constant Version_32 := 16#4249379B#; + u00038 : constant Version_32 := 16#0357E00A#; + u00039 : constant Version_32 := 16#3784FB72#; + u00040 : constant Version_32 := 16#2E723019#; + u00041 : constant Version_32 := 16#623358EA#; + u00042 : constant Version_32 := 16#107F9465#; + u00043 : constant Version_32 := 16#6843F68A#; + u00044 : constant Version_32 := 16#63305874#; + u00045 : constant Version_32 := 16#31E56CE1#; + u00046 : constant Version_32 := 16#02917970#; + u00047 : constant Version_32 := 16#6CCBA70E#; + u00048 : constant Version_32 := 16#41CD4204#; + u00049 : constant Version_32 := 16#572E3F58#; + u00050 : constant Version_32 := 16#20729FF5#; + u00051 : constant Version_32 := 16#1D4F93E8#; + u00052 : constant Version_32 := 16#30B2EC3D#; + u00053 : constant Version_32 := 16#34054F96#; + u00054 : constant Version_32 := 16#5A199860#; + u00055 : constant Version_32 := 16#0E7F912B#; + u00056 : constant Version_32 := 16#5760634A#; + u00057 : constant Version_32 := 16#5D851835#; + + -- The following Export pragmas export the version numbers + -- with symbolic names ending in B (for body) or S + -- (for spec) so that they can be located in a link. The + -- information provided here is sufficient to track down + -- the exact versions of units used in a given build. + + pragma Export (C, u00001, "helloB"); + pragma Export (C, u00002, "system__standard_libraryB"); + pragma Export (C, u00003, "system__standard_libraryS"); + pragma Export (C, u00004, "adaS"); + pragma Export (C, u00005, "ada__text_ioB"); + pragma Export (C, u00006, "ada__text_ioS"); + pragma Export (C, u00007, "ada__exceptionsB"); + pragma Export (C, u00008, "ada__exceptionsS"); + pragma Export (C, u00009, "gnatS"); + pragma Export (C, u00010, "gnat__heap_sort_aB"); + pragma Export (C, u00011, "gnat__heap_sort_aS"); + pragma Export (C, u00012, "systemS"); + pragma Export (C, u00013, "system__exception_tableB"); + pragma Export (C, u00014, "system__exception_tableS"); + pragma Export (C, u00015, "gnat__htableB"); + pragma Export (C, u00016, "gnat__htableS"); + pragma Export (C, u00017, "system__exceptionsS"); + pragma Export (C, u00018, "system__machine_state_operationsB"); + pragma Export (C, u00019, "system__machine_state_operationsS"); + pragma Export (C, u00020, "system__machine_codeS"); + pragma Export (C, u00021, "system__storage_elementsB"); + pragma Export (C, u00022, "system__storage_elementsS"); + pragma Export (C, u00023, "system__secondary_stackB"); + pragma Export (C, u00024, "system__secondary_stackS"); + pragma Export (C, u00025, "system__parametersB"); + pragma Export (C, u00026, "system__parametersS"); + pragma Export (C, u00027, "system__soft_linksB"); + pragma Export (C, u00028, "system__soft_linksS"); + pragma Export (C, u00029, "system__stack_checkingB"); + pragma Export (C, u00030, "system__stack_checkingS"); + pragma Export (C, u00031, "system__tracebackB"); + pragma Export (C, u00032, "system__tracebackS"); + pragma Export (C, u00033, "ada__streamsS"); + pragma Export (C, u00034, "ada__tagsB"); + pragma Export (C, u00035, "ada__tagsS"); + pragma Export (C, u00036, "system__string_opsB"); + pragma Export (C, u00037, "system__string_opsS"); + pragma Export (C, u00038, "interfacesS"); + pragma Export (C, u00039, "interfaces__c_streamsB"); + pragma Export (C, u00040, "interfaces__c_streamsS"); + pragma Export (C, u00041, "system__file_ioB"); + pragma Export (C, u00042, "system__file_ioS"); + pragma Export (C, u00043, "ada__finalizationB"); + pragma Export (C, u00044, "ada__finalizationS"); + pragma Export (C, u00045, "system__finalization_rootB"); + pragma Export (C, u00046, "system__finalization_rootS"); + pragma Export (C, u00047, "system__finalization_implementationB"); + pragma Export (C, u00048, "system__finalization_implementationS"); + pragma Export (C, u00049, "system__string_ops_concat_3B"); + pragma Export (C, u00050, "system__string_ops_concat_3S"); + pragma Export (C, u00051, "system__stream_attributesB"); + pragma Export (C, u00052, "system__stream_attributesS"); + pragma Export (C, u00053, "ada__io_exceptionsS"); + pragma Export (C, u00054, "system__unsigned_typesS"); + pragma Export (C, u00055, "system__file_control_blockS"); + pragma Export (C, u00056, "ada__finalization__list_controllerB"); + pragma Export (C, u00057, "ada__finalization__list_controllerS"); + + -- BEGIN ELABORATION ORDER + -- ada (spec) + -- gnat (spec) + -- gnat.heap_sort_a (spec) + -- gnat.heap_sort_a (body) + -- gnat.htable (spec) + -- gnat.htable (body) + -- interfaces (spec) + -- system (spec) + -- system.machine_code (spec) + -- system.parameters (spec) + -- system.parameters (body) + -- interfaces.c_streams (spec) + -- interfaces.c_streams (body) + -- system.standard_library (spec) + -- ada.exceptions (spec) + -- system.exception_table (spec) + -- system.exception_table (body) + -- ada.io_exceptions (spec) + -- system.exceptions (spec) + -- system.storage_elements (spec) + -- system.storage_elements (body) + -- system.machine_state_operations (spec) + -- system.machine_state_operations (body) + -- system.secondary_stack (spec) + -- system.stack_checking (spec) + -- system.soft_links (spec) + -- system.soft_links (body) + -- system.stack_checking (body) + -- system.secondary_stack (body) + -- system.standard_library (body) + -- system.string_ops (spec) + -- system.string_ops (body) + -- ada.tags (spec) + -- ada.tags (body) + -- ada.streams (spec) + -- system.finalization_root (spec) + -- system.finalization_root (body) + -- system.string_ops_concat_3 (spec) + -- system.string_ops_concat_3 (body) + -- system.traceback (spec) + -- system.traceback (body) + -- ada.exceptions (body) + -- system.unsigned_types (spec) + -- system.stream_attributes (spec) + -- system.stream_attributes (body) + -- system.finalization_implementation (spec) + -- system.finalization_implementation (body) + -- ada.finalization (spec) + -- ada.finalization (body) + -- ada.finalization.list_controller (spec) + -- ada.finalization.list_controller (body) + -- system.file_control_block (spec) + -- system.file_io (spec) + -- system.file_io (body) + -- ada.text_io (spec) + -- ada.text_io (body) + -- hello (body) + -- END ELABORATION ORDER + + end ada_main; + + -- The following source file name pragmas allow the generated file + -- names to be unique for different main programs. They are needed + -- since the package name will always be Ada_Main. + + pragma Source_File_Name (ada_main, Spec_File_Name => "b~hello.ads"); + pragma Source_File_Name (ada_main, Body_File_Name => "b~hello.adb"); + + -- Generated package body for Ada_Main starts here + + package body ada_main is + + -- The actual finalization is performed by calling the + -- library routine in System.Standard_Library.Adafinal + + procedure Do_Finalize; + pragma Import (C, Do_Finalize, "system__standard_library__adafinal"); + + ------------- + -- adainit -- + ------------- + + procedure adainit is + + -- These booleans are set to True once the associated unit has + -- been elaborated. It is also used to avoid elaborating the + -- same unit twice. + + E040 : Boolean; pragma Import (Ada, E040, "interfaces__c_streams_E"); + E008 : Boolean; pragma Import (Ada, E008, "ada__exceptions_E"); + E014 : Boolean; pragma Import (Ada, E014, "system__exception_table_E"); + E053 : Boolean; pragma Import (Ada, E053, "ada__io_exceptions_E"); + E017 : Boolean; pragma Import (Ada, E017, "system__exceptions_E"); + E024 : Boolean; pragma Import (Ada, E024, "system__secondary_stack_E"); + E030 : Boolean; pragma Import (Ada, E030, "system__stack_checking_E"); + E028 : Boolean; pragma Import (Ada, E028, "system__soft_links_E"); + E035 : Boolean; pragma Import (Ada, E035, "ada__tags_E"); + E033 : Boolean; pragma Import (Ada, E033, "ada__streams_E"); + E046 : Boolean; pragma Import (Ada, E046, "system__finalization_root_E"); + E048 : Boolean; pragma Import (Ada, E048, "system__finalization_implementation_E"); + E044 : Boolean; pragma Import (Ada, E044, "ada__finalization_E"); + E057 : Boolean; pragma Import (Ada, E057, "ada__finalization__list_controller_E"); + E055 : Boolean; pragma Import (Ada, E055, "system__file_control_block_E"); + E042 : Boolean; pragma Import (Ada, E042, "system__file_io_E"); + E006 : Boolean; pragma Import (Ada, E006, "ada__text_io_E"); + + -- Set_Globals is a library routine that stores away the + -- value of the indicated set of global values in global + -- variables within the library. + + procedure Set_Globals + (Main_Priority : Integer; + Time_Slice_Value : Integer; + WC_Encoding : Character; + Locking_Policy : Character; + Queuing_Policy : Character; + Task_Dispatching_Policy : Character; + Adafinal : System.Address; + Unreserve_All_Interrupts : Integer; + Exception_Tracebacks : Integer); + pragma Import (C, Set_Globals, "__gnat_set_globals"); + + -- SDP_Table_Build is a library routine used to build the + -- exception tables. See unit Ada.Exceptions in files + -- a-except.ads/adb for full details of how zero cost + -- exception handling works. This procedure, the call to + -- it, and the two following tables are all omitted if the + -- build is in longjmp/setjump exception mode. + + procedure SDP_Table_Build + (SDP_Addresses : System.Address; + SDP_Count : Natural; + Elab_Addresses : System.Address; + Elab_Addr_Count : Natural); + pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build"); + + -- Table of Unit_Exception_Table addresses. Used for zero + -- cost exception handling to build the top level table. + + ST : aliased constant array (1 .. 23) of System.Address := ( + Hello'UET_Address, + Ada.Text_Io'UET_Address, + Ada.Exceptions'UET_Address, + Gnat.Heap_Sort_A'UET_Address, + System.Exception_Table'UET_Address, + System.Machine_State_Operations'UET_Address, + System.Secondary_Stack'UET_Address, + System.Parameters'UET_Address, + System.Soft_Links'UET_Address, + System.Stack_Checking'UET_Address, + System.Traceback'UET_Address, + Ada.Streams'UET_Address, + Ada.Tags'UET_Address, + System.String_Ops'UET_Address, + Interfaces.C_Streams'UET_Address, + System.File_Io'UET_Address, + Ada.Finalization'UET_Address, + System.Finalization_Root'UET_Address, + System.Finalization_Implementation'UET_Address, + System.String_Ops_Concat_3'UET_Address, + System.Stream_Attributes'UET_Address, + System.File_Control_Block'UET_Address, + Ada.Finalization.List_Controller'UET_Address); + + -- Table of addresses of elaboration routines. Used for + -- zero cost exception handling to make sure these + -- addresses are included in the top level procedure + -- address table. + + EA : aliased constant array (1 .. 23) of System.Address := ( + adainit'Code_Address, + Do_Finalize'Code_Address, + Ada.Exceptions'Elab_Spec'Address, + System.Exceptions'Elab_Spec'Address, + Interfaces.C_Streams'Elab_Spec'Address, + System.Exception_Table'Elab_Body'Address, + Ada.Io_Exceptions'Elab_Spec'Address, + System.Stack_Checking'Elab_Spec'Address, + System.Soft_Links'Elab_Body'Address, + System.Secondary_Stack'Elab_Body'Address, + Ada.Tags'Elab_Spec'Address, + Ada.Tags'Elab_Body'Address, + Ada.Streams'Elab_Spec'Address, + System.Finalization_Root'Elab_Spec'Address, + Ada.Exceptions'Elab_Body'Address, + System.Finalization_Implementation'Elab_Spec'Address, + System.Finalization_Implementation'Elab_Body'Address, + Ada.Finalization'Elab_Spec'Address, + Ada.Finalization.List_Controller'Elab_Spec'Address, + System.File_Control_Block'Elab_Spec'Address, + System.File_Io'Elab_Body'Address, + Ada.Text_Io'Elab_Spec'Address, + Ada.Text_Io'Elab_Body'Address); + + -- Start of processing for adainit + + begin + + -- Call SDP_Table_Build to build the top level procedure + -- table for zero cost exception handling (omitted in + -- longjmp/setjump mode). + + SDP_Table_Build (ST'Address, 23, EA'Address, 23); + + -- Call Set_Globals to record various information for + -- this partition. The values are derived by the binder + -- from information stored in the ali files by the compiler. + + Set_Globals + (Main_Priority => -1, + -- Priority of main program, -1 if no pragma Priority used + + Time_Slice_Value => -1, + -- Time slice from Time_Slice pragma, -1 if none used + + WC_Encoding => 'b', + -- Wide_Character encoding used, default is brackets + + Locking_Policy => ' ', + -- Locking_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Queuing_Policy => ' ', + -- Queuing_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Task_Dispatching_Policy => ' ', + -- Task_Dispatching_Policy used, default of space means + -- not specified, otherwise first character of the + -- policy name. + + Adafinal => System.Null_Address, + -- Address of Adafinal routine, not used anymore + + Unreserve_All_Interrupts => 0, + -- Set true if pragma Unreserve_All_Interrupts was used + + Exception_Tracebacks => 0); + -- Indicates if exception tracebacks are enabled + + Elab_Final_Code := 1; + + -- Now we have the elaboration calls for all units in the partition. + -- The Elab_Spec and Elab_Body attributes generate references to the + -- implicit elaboration procedures generated by the compiler for + -- each unit that requires elaboration. + + if not E040 then + Interfaces.C_Streams'Elab_Spec; + end if; + E040 := True; + if not E008 then + Ada.Exceptions'Elab_Spec; + end if; + if not E014 then + System.Exception_Table'Elab_Body; + E014 := True; + end if; + if not E053 then + Ada.Io_Exceptions'Elab_Spec; + E053 := True; + end if; + if not E017 then + System.Exceptions'Elab_Spec; + E017 := True; + end if; + if not E030 then + System.Stack_Checking'Elab_Spec; + end if; + if not E028 then + System.Soft_Links'Elab_Body; + E028 := True; + end if; + E030 := True; + if not E024 then + System.Secondary_Stack'Elab_Body; + E024 := True; + end if; + if not E035 then + Ada.Tags'Elab_Spec; + end if; + if not E035 then + Ada.Tags'Elab_Body; + E035 := True; + end if; + if not E033 then + Ada.Streams'Elab_Spec; + E033 := True; + end if; + if not E046 then + System.Finalization_Root'Elab_Spec; + end if; + E046 := True; + if not E008 then + Ada.Exceptions'Elab_Body; + E008 := True; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Spec; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Body; + E048 := True; + end if; + if not E044 then + Ada.Finalization'Elab_Spec; + end if; + E044 := True; + if not E057 then + Ada.Finalization.List_Controller'Elab_Spec; + end if; + E057 := True; + if not E055 then + System.File_Control_Block'Elab_Spec; + E055 := True; + end if; + if not E042 then + System.File_Io'Elab_Body; + E042 := True; + end if; + if not E006 then + Ada.Text_Io'Elab_Spec; + end if; + if not E006 then + Ada.Text_Io'Elab_Body; + E006 := True; + end if; + + Elab_Final_Code := 0; + end adainit; + + -------------- + -- adafinal -- + -------------- + + procedure adafinal is + begin + Do_Finalize; + end adafinal; + + ---------- + -- main -- + ---------- + + -- main is actually a function, as in the ANSI C standard, + -- defined to return the exit status. The three parameters + -- are the argument count, argument values and environment + -- pointer. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer + is + -- The initialize routine performs low level system + -- initialization using a standard library routine which + -- sets up signal handling and performs any other + -- required setup. The routine can be found in file + -- a-init.c. + + procedure initialize; + pragma Import (C, initialize, "__gnat_initialize"); + + -- The finalize routine performs low level system + -- finalization using a standard library routine. The + -- routine is found in file a-final.c and in the standard + -- distribution is a dummy routine that does nothing, so + -- really this is a hook for special user finalization. + + procedure finalize; + pragma Import (C, finalize, "__gnat_finalize"); + + -- We get to the main program of the partition by using + -- pragma Import because if we try to with the unit and + -- call it Ada style, then not only do we waste time + -- recompiling it, but also, we don't really know the right + -- switches (e.g. identifier character set) to be used + -- to compile it. + + procedure Ada_Main_Program; + pragma Import (Ada, Ada_Main_Program, "_ada_hello"); + + -- Start of processing for main + + begin + -- Save global variables + + gnat_argc := argc; + gnat_argv := argv; + gnat_envp := envp; + + -- Call low level system initialization + + Initialize; + + -- Call our generated Ada initialization routine + + adainit; + + -- This is the point at which we want the debugger to get + -- control + + Break_Start; + + -- Now we call the main program of the partition + + Ada_Main_Program; + + -- Perform Ada finalization + + adafinal; + + -- Perform low level system finalization + + Finalize; + + -- Return the proper exit status + return (gnat_exit_status); + end; + + -- This section is entirely comments, so it has no effect on the + -- compilation of the Ada_Main package. It provides the list of + -- object files and linker options, as well as some standard + -- libraries needed for the link. The gnatlink utility parses + -- this b~hello.adb file to read these comment lines to generate + -- the appropriate command line arguments for the call to the + -- system linker. The BEGIN/END lines are used for sentinels for + -- this parsing operation. + + -- The exact file names will of course depend on the environment, + -- host/target and location of files on the host system. + + -- BEGIN Object file/option list + -- ./hello.o + -- -L./ + -- -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/ + -- /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a + -- END Object file/option list + + end ada_main; + + The Ada code in the above example is exactly what is generated by the + binder. We have added comments to more clearly indicate the function of + each part of the generated `Ada_Main' package. + + The code is standard Ada in all respects, and can be processed by any + tools that handle Ada. In particular, it is possible to use the debugger + in Ada mode to debug the generated Ada_Main package. For example, + suppose that for reasons that you do not understand, your program is + blowing up during elaboration of the body of `Ada.Text_IO'. To chase + this bug down, you can place a breakpoint on the call: + + Ada.Text_Io'Elab_Body; + + and trace the elaboration routine for this package to find out where + the problem might be (more usually of course you would be debugging + elaboration code in your own application). + +  + File: gnat_ug_unx.info, Node: Generating the Binder Program in C, Next: Consistency-Checking Modes, Prev: Running gnatbind, Up: Binding Using gnatbind + + Generating the Binder Program in C + ================================== + + In most normal usage, the default mode of `gnatbind' which is to + generate the main package in Ada, as described in the previous section. + In particular, this means that any Ada programmer can read and + understand the generated main program. It can also be debugged just + like any other Ada code provided the `-g' switch is used for `gnatbind' + and `gnatlink'. + + However for some purposes it may be convenient to generate the main + program in C rather than Ada. This may for example be helpful when you + are generating a mixed language program with the main program in C. The + GNAT compiler itself is an example. The use of the `-C' switch for both + `gnatbind' and `gnatlink' will cause the program to be generated in C + (and compiled using the gnu C compiler). The following shows the C code + generated for the same "Hello World" program: + + + #ifdef __STDC__ + #define PARAMS(paramlist) paramlist + #else + #define PARAMS(paramlist) () + #endif + + extern void __gnat_set_globals + PARAMS ((int, int, int, int, int, int, + void (*) PARAMS ((void)), int, int)); + extern void adafinal PARAMS ((void)); + extern void adainit PARAMS ((void)); + extern void system__standard_library__adafinal PARAMS ((void)); + extern int main PARAMS ((int, char **, char **)); + extern void exit PARAMS ((int)); + extern void __gnat_break_start PARAMS ((void)); + extern void _ada_hello PARAMS ((void)); + extern void __gnat_initialize PARAMS ((void)); + extern void __gnat_finalize PARAMS ((void)); + + extern void ada__exceptions___elabs PARAMS ((void)); + extern void system__exceptions___elabs PARAMS ((void)); + extern void interfaces__c_streams___elabs PARAMS ((void)); + extern void system__exception_table___elabb PARAMS ((void)); + extern void ada__io_exceptions___elabs PARAMS ((void)); + extern void system__stack_checking___elabs PARAMS ((void)); + extern void system__soft_links___elabb PARAMS ((void)); + extern void system__secondary_stack___elabb PARAMS ((void)); + extern void ada__tags___elabs PARAMS ((void)); + extern void ada__tags___elabb PARAMS ((void)); + extern void ada__streams___elabs PARAMS ((void)); + extern void system__finalization_root___elabs PARAMS ((void)); + extern void ada__exceptions___elabb PARAMS ((void)); + extern void system__finalization_implementation___elabs PARAMS ((void)); + extern void system__finalization_implementation___elabb PARAMS ((void)); + extern void ada__finalization___elabs PARAMS ((void)); + extern void ada__finalization__list_controller___elabs PARAMS ((void)); + extern void system__file_control_block___elabs PARAMS ((void)); + extern void system__file_io___elabb PARAMS ((void)); + extern void ada__text_io___elabs PARAMS ((void)); + extern void ada__text_io___elabb PARAMS ((void)); + + extern int __gnat_inside_elab_final_code; + + extern int gnat_argc; + extern char **gnat_argv; + extern char **gnat_envp; + extern int gnat_exit_status; + + char __gnat_version[] = "GNAT Version: 3.15w (20010315)"; + void adafinal () { + system__standard_library__adafinal (); + } + + void adainit () + { + extern char ada__exceptions_E; + extern char system__exceptions_E; + extern char interfaces__c_streams_E; + extern char system__exception_table_E; + extern char ada__io_exceptions_E; + extern char system__secondary_stack_E; + extern char system__stack_checking_E; + extern char system__soft_links_E; + extern char ada__tags_E; + extern char ada__streams_E; + extern char system__finalization_root_E; + extern char system__finalization_implementation_E; + extern char ada__finalization_E; + extern char ada__finalization__list_controller_E; + extern char system__file_control_block_E; + extern char system__file_io_E; + extern char ada__text_io_E; + + extern void *__gnat_hello__SDP; + extern void *__gnat_ada__text_io__SDP; + extern void *__gnat_ada__exceptions__SDP; + extern void *__gnat_gnat__heap_sort_a__SDP; + extern void *__gnat_system__exception_table__SDP; + extern void *__gnat_system__machine_state_operations__SDP; + extern void *__gnat_system__secondary_stack__SDP; + extern void *__gnat_system__parameters__SDP; + extern void *__gnat_system__soft_links__SDP; + extern void *__gnat_system__stack_checking__SDP; + extern void *__gnat_system__traceback__SDP; + extern void *__gnat_ada__streams__SDP; + extern void *__gnat_ada__tags__SDP; + extern void *__gnat_system__string_ops__SDP; + extern void *__gnat_interfaces__c_streams__SDP; + extern void *__gnat_system__file_io__SDP; + extern void *__gnat_ada__finalization__SDP; + extern void *__gnat_system__finalization_root__SDP; + extern void *__gnat_system__finalization_implementation__SDP; + extern void *__gnat_system__string_ops_concat_3__SDP; + extern void *__gnat_system__stream_attributes__SDP; + extern void *__gnat_system__file_control_block__SDP; + extern void *__gnat_ada__finalization__list_controller__SDP; + + void **st[23] = { + &__gnat_hello__SDP, + &__gnat_ada__text_io__SDP, + &__gnat_ada__exceptions__SDP, + &__gnat_gnat__heap_sort_a__SDP, + &__gnat_system__exception_table__SDP, + &__gnat_system__machine_state_operations__SDP, + &__gnat_system__secondary_stack__SDP, + &__gnat_system__parameters__SDP, + &__gnat_system__soft_links__SDP, + &__gnat_system__stack_checking__SDP, + &__gnat_system__traceback__SDP, + &__gnat_ada__streams__SDP, + &__gnat_ada__tags__SDP, + &__gnat_system__string_ops__SDP, + &__gnat_interfaces__c_streams__SDP, + &__gnat_system__file_io__SDP, + &__gnat_ada__finalization__SDP, + &__gnat_system__finalization_root__SDP, + &__gnat_system__finalization_implementation__SDP, + &__gnat_system__string_ops_concat_3__SDP, + &__gnat_system__stream_attributes__SDP, + &__gnat_system__file_control_block__SDP, + &__gnat_ada__finalization__list_controller__SDP}; + + extern void ada__exceptions___elabs (); + extern void system__exceptions___elabs (); + extern void interfaces__c_streams___elabs (); + extern void system__exception_table___elabb (); + extern void ada__io_exceptions___elabs (); + extern void system__stack_checking___elabs (); + extern void system__soft_links___elabb (); + extern void system__secondary_stack___elabb (); + extern void ada__tags___elabs (); + extern void ada__tags___elabb (); + extern void ada__streams___elabs (); + extern void system__finalization_root___elabs (); + extern void ada__exceptions___elabb (); + extern void system__finalization_implementation___elabs (); + extern void system__finalization_implementation___elabb (); + extern void ada__finalization___elabs (); + extern void ada__finalization__list_controller___elabs (); + extern void system__file_control_block___elabs (); + extern void system__file_io___elabb (); + extern void ada__text_io___elabs (); + extern void ada__text_io___elabb (); + + void (*ea[23]) () = { + adainit, + system__standard_library__adafinal, + ada__exceptions___elabs, + system__exceptions___elabs, + interfaces__c_streams___elabs, + system__exception_table___elabb, + ada__io_exceptions___elabs, + system__stack_checking___elabs, + system__soft_links___elabb, + system__secondary_stack___elabb, + ada__tags___elabs, + ada__tags___elabb, + ada__streams___elabs, + system__finalization_root___elabs, + ada__exceptions___elabb, + system__finalization_implementation___elabs, + system__finalization_implementation___elabb, + ada__finalization___elabs, + ada__finalization__list_controller___elabs, + system__file_control_block___elabs, + system__file_io___elabb, + ada__text_io___elabs, + ada__text_io___elabb}; + + __gnat_SDP_Table_Build (&st, 23, ea, 23); + __gnat_set_globals ( + -1, /* Main_Priority */ + -1, /* Time_Slice_Value */ + 'b', /* WC_Encoding */ + ' ', /* Locking_Policy */ + ' ', /* Queuing_Policy */ + ' ', /* Tasking_Dispatching_Policy */ + 0, /* Finalization routine address, not used anymore */ + 0, /* Unreserve_All_Interrupts */ + 0); /* Exception_Tracebacks */ + + __gnat_inside_elab_final_code = 1; + + if (ada__exceptions_E == 0) { + ada__exceptions___elabs (); + } + if (system__exceptions_E == 0) { + system__exceptions___elabs (); + system__exceptions_E++; + } + if (interfaces__c_streams_E == 0) { + interfaces__c_streams___elabs (); + } + interfaces__c_streams_E = 1; + if (system__exception_table_E == 0) { + system__exception_table___elabb (); + system__exception_table_E++; + } + if (ada__io_exceptions_E == 0) { + ada__io_exceptions___elabs (); + ada__io_exceptions_E++; + } + if (system__stack_checking_E == 0) { + system__stack_checking___elabs (); + } + if (system__soft_links_E == 0) { + system__soft_links___elabb (); + system__soft_links_E++; + } + system__stack_checking_E = 1; + if (system__secondary_stack_E == 0) { + system__secondary_stack___elabb (); + system__secondary_stack_E++; + } + if (ada__tags_E == 0) { + ada__tags___elabs (); + } + if (ada__tags_E == 0) { + ada__tags___elabb (); + ada__tags_E++; + } + if (ada__streams_E == 0) { + ada__streams___elabs (); + ada__streams_E++; + } + if (system__finalization_root_E == 0) { + system__finalization_root___elabs (); + } + system__finalization_root_E = 1; + if (ada__exceptions_E == 0) { + ada__exceptions___elabb (); + ada__exceptions_E++; + } + if (system__finalization_implementation_E == 0) { + system__finalization_implementation___elabs (); + } + if (system__finalization_implementation_E == 0) { + system__finalization_implementation___elabb (); + system__finalization_implementation_E++; + } + if (ada__finalization_E == 0) { + ada__finalization___elabs (); + } + ada__finalization_E = 1; + if (ada__finalization__list_controller_E == 0) { + ada__finalization__list_controller___elabs (); + } + ada__finalization__list_controller_E = 1; + if (system__file_control_block_E == 0) { + system__file_control_block___elabs (); + system__file_control_block_E++; + } + if (system__file_io_E == 0) { + system__file_io___elabb (); + system__file_io_E++; + } + if (ada__text_io_E == 0) { + ada__text_io___elabs (); + } + if (ada__text_io_E == 0) { + ada__text_io___elabb (); + ada__text_io_E++; + } + + __gnat_inside_elab_final_code = 0; + } + int main (argc, argv, envp) + int argc; + char **argv; + char **envp; + { + gnat_argc = argc; + gnat_argv = argv; + gnat_envp = envp; + + __gnat_initialize (); + adainit (); + __gnat_break_start (); + + _ada_hello (); + + system__standard_library__adafinal (); + __gnat_finalize (); + exit (gnat_exit_status); + } + unsigned helloB = 0x7880BEB3; + unsigned system__standard_libraryB = 0x0D24CBD0; + unsigned system__standard_libraryS = 0x3283DBEB; + unsigned adaS = 0x2359F9ED; + unsigned ada__text_ioB = 0x47C85FC4; + unsigned ada__text_ioS = 0x496FE45C; + unsigned ada__exceptionsB = 0x74F50187; + unsigned ada__exceptionsS = 0x6736945B; + unsigned gnatS = 0x156A40CF; + unsigned gnat__heap_sort_aB = 0x033DABE0; + unsigned gnat__heap_sort_aS = 0x6AB38FEA; + unsigned systemS = 0x0331C6FE; + unsigned system__exceptionsS = 0x20C9ECA4; + unsigned system__exception_tableB = 0x68A22947; + unsigned system__exception_tableS = 0x394BADD5; + unsigned gnat__htableB = 0x08258E1B; + unsigned gnat__htableS = 0x367D5222; + unsigned system__machine_state_operationsB = 0x4F3B7492; + unsigned system__machine_state_operationsS = 0x182F5CF4; + unsigned system__storage_elementsB = 0x2F1EB794; + unsigned system__storage_elementsS = 0x102C83C7; + unsigned system__secondary_stackB = 0x1574B6E9; + unsigned system__secondary_stackS = 0x708E260A; + unsigned system__parametersB = 0x56D770CD; + unsigned system__parametersS = 0x237E39BE; + unsigned system__soft_linksB = 0x08AB6B2C; + unsigned system__soft_linksS = 0x1E2491F3; + unsigned system__stack_checkingB = 0x476457A0; + unsigned system__stack_checkingS = 0x5299FCED; + unsigned system__tracebackB = 0x2971EBDE; + unsigned system__tracebackS = 0x2E9C3122; + unsigned ada__streamsS = 0x7C25DE96; + unsigned ada__tagsB = 0x39ADFFA2; + unsigned ada__tagsS = 0x769A0464; + unsigned system__string_opsB = 0x5EB646AB; + unsigned system__string_opsS = 0x63CED018; + unsigned interfacesS = 0x0357E00A; + unsigned interfaces__c_streamsB = 0x3784FB72; + unsigned interfaces__c_streamsS = 0x2E723019; + unsigned system__file_ioB = 0x623358EA; + unsigned system__file_ioS = 0x31F873E6; + unsigned ada__finalizationB = 0x6843F68A; + unsigned ada__finalizationS = 0x63305874; + unsigned system__finalization_rootB = 0x31E56CE1; + unsigned system__finalization_rootS = 0x23169EF3; + unsigned system__finalization_implementationB = 0x6CCBA70E; + unsigned system__finalization_implementationS = 0x604AA587; + unsigned system__string_ops_concat_3B = 0x572E3F58; + unsigned system__string_ops_concat_3S = 0x01F57876; + unsigned system__stream_attributesB = 0x1D4F93E8; + unsigned system__stream_attributesS = 0x30B2EC3D; + unsigned ada__io_exceptionsS = 0x34054F96; + unsigned system__unsigned_typesS = 0x7B9E7FE3; + unsigned system__file_control_blockS = 0x2FF876A8; + unsigned ada__finalization__list_controllerB = 0x5760634A; + unsigned ada__finalization__list_controllerS = 0x5D851835; + + /* BEGIN ELABORATION ORDER + ada (spec) + gnat (spec) + gnat.heap_sort_a (spec) + gnat.htable (spec) + gnat.htable (body) + interfaces (spec) + system (spec) + system.parameters (spec) + system.standard_library (spec) + ada.exceptions (spec) + system.exceptions (spec) + system.parameters (body) + gnat.heap_sort_a (body) + interfaces.c_streams (spec) + interfaces.c_streams (body) + system.exception_table (spec) + system.exception_table (body) + ada.io_exceptions (spec) + system.storage_elements (spec) + system.storage_elements (body) + system.machine_state_operations (spec) + system.machine_state_operations (body) + system.secondary_stack (spec) + system.stack_checking (spec) + system.soft_links (spec) + system.soft_links (body) + system.stack_checking (body) + system.secondary_stack (body) + system.standard_library (body) + system.string_ops (spec) + system.string_ops (body) + ada.tags (spec) + ada.tags (body) + ada.streams (spec) + system.finalization_root (spec) + system.finalization_root (body) + system.string_ops_concat_3 (spec) + system.string_ops_concat_3 (body) + system.traceback (spec) + system.traceback (body) + ada.exceptions (body) + system.unsigned_types (spec) + system.stream_attributes (spec) + system.stream_attributes (body) + system.finalization_implementation (spec) + system.finalization_implementation (body) + ada.finalization (spec) + ada.finalization (body) + ada.finalization.list_controller (spec) + ada.finalization.list_controller (body) + system.file_control_block (spec) + system.file_io (spec) + system.file_io (body) + ada.text_io (spec) + ada.text_io (body) + hello (body) + END ELABORATION ORDER */ + + /* BEGIN Object file/option list + ./hello.o + -L./ + -L/usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/ + /usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/libgnat.a + -lexc + END Object file/option list */ + + Here again, the C code is exactly what is generated by the binder. The + functions of the various parts of this code correspond in an obvious + manner with the commented Ada code shown in the example in the previous + section. + +  + File: gnat_ug_unx.info, Node: Consistency-Checking Modes, Next: Binder Error Message Control, Prev: Generating the Binder Program in C, Up: Binding Using gnatbind + + Consistency-Checking Modes + ========================== + + As described in the previous section, by default `gnatbind' checks that + object files are consistent with one another and are consistent with + any source files it can locate. The following switches control binder + access to sources. + + `-s' + Require source files to be present. In this mode, the binder must + be able to locate all source files that are referenced, in order + to check their consistency. In normal mode, if a source file + cannot be located it is simply ignored. If you specify this + switch, a missing source file is an error. + + `-x' + Exclude source files. In this mode, the binder only checks that ALI + files are consistent with one another. Source files are not + accessed. The binder runs faster in this mode, and there is still + a guarantee that the resulting program is self-consistent. If a + source file has been edited since it was last compiled, and you + specify this switch, the binder will not detect that the object + file is out of date with respect to the source file. Note that + this is the mode that is automatically used by `gnatmake' because + in this case the checking against sources has already been + performed by `gnatmake' in the course of compilation (i.e. before + binding). + +  + File: gnat_ug_unx.info, Node: Binder Error Message Control, Next: Elaboration Control, Prev: Consistency-Checking Modes, Up: Binding Using gnatbind + + Binder Error Message Control + ============================ + + The following switches provide control over the generation of error + messages from the binder: + + `-v' + Verbose mode. In the normal mode, brief error messages are + generated to `stderr'. If this switch is present, a header is + written to `stdout' and any error messages are directed to + `stdout'. All that is written to `stderr' is a brief summary + message. + + `-b' + Generate brief error messages to `stderr' even if verbose mode is + specified. This is relevant only when used with the `-v' switch. + + `-mN' + Limits the number of error messages to N, a decimal integer in the + range 1-999. The binder terminates immediately if this limit is + reached. + + `-MXXX' + Renames the generated main program from `main' to `xxx'. This is + useful in the case of some cross-building environments, where the + actual main program is separate from the one generated by + `gnatbind'. + + `-ws' + Suppress all warning messages. + + `-we' + Treat any warning messages as fatal errors. + + `-t' + The binder performs a number of consistency checks including: + + * Check that time stamps of a given source unit are consistent + + * Check that checksums of a given source unit are consistent + + * Check that consistent versions of `GNAT' were used for + compilation + + * Check consistency of configuration pragmas as required + + Normally failure of such checks, in accordance with the consistency + requirements of the Ada Reference Manual, causes error messages to + be generated which abort the binder and prevent the output of a + binder file and subsequent link to obtain an executable. + + The `-t' switch converts these error messages into warnings, so + that binding and linking can continue to completion even in the + presence of such errors. The result may be a failed link (due to + missing symbols), or a non-functional executable which has + undefined semantics. _This means that `-t' should be used only in + unusual situations, with extreme care._ + +  + File: gnat_ug_unx.info, Node: Elaboration Control, Next: Output Control, Prev: Binder Error Message Control, Up: Binding Using gnatbind + + Elaboration Control + =================== + + The following switches provide additional control over the elaboration + order. For full details see *Note Elaboration Order Handling in GNAT::. + + `-p' + Normally the binder attempts to choose an elaboration order that is + likely to minimize the likelihood of an elaboration order error + resulting in raising a `Program_Error' exception. This switch + reverses the action of the binder, and requests that it + deliberately choose an order that is likely to maximize the + likelihood of an elaboration error. This is useful in ensuring + portability and avoiding dependence on accidental fortuitous + elaboration ordering. + + Normally it only makes sense to use the `-p' switch if dynamic + elaboration checking is used (`-gnatE' switch used for + compilation). This is because in the default static elaboration + mode, all necessary `Elaborate_All' pragmas are implicitly + inserted. These implicit pragmas are still respected by the binder + in `-p' mode, so a safe elaboration order is assured. + +  + File: gnat_ug_unx.info, Node: Output Control, Next: Binding with Non-Ada Main Programs, Prev: Elaboration Control, Up: Binding Using gnatbind + + Output Control + ============== + + The following switches allow additional control over the output + generated by the binder. + + `-A' + Generate binder program in Ada (default). The binder program is + named `b~MAINPROG.adb' by default. This can be changed with `-o' + `gnatbind' option. + + `-c' + Check only. Do not generate the binder output file. In this mode + the binder performs all error checks but does not generate an + output file. + + `-C' + Generate binder program in C. The binder program is named + `b_MAINPROG.c'. This can be changed with `-o' `gnatbind' option. + + `-e' + Output complete list of elaboration-order dependencies, showing the + reason for each dependency. This output can be rather extensive + but may be useful in diagnosing problems with elaboration order. + The output is written to `stdout'. + + `-h' + Output usage information. The output is written to `stdout'. + + `-K' + Output linker options to `stdout'. Includes library search paths, + contents of pragmas Ident and Linker_Options, and libraries added + by `gnatbind'. + + `-l' + Output chosen elaboration order. The output is written to `stdout'. + + `-O' + Output full names of all the object files that must be linked to + provide the Ada component of the program. The output is written to + `stdout'. This list includes the files explicitly supplied and + referenced by the user as well as implicitly referenced run-time + unit files. The latter are omitted if the corresponding units + reside in shared libraries. The directory names for the run-time + units depend on the system configuration. + + `-o FILE' + Set name of output file to FILE instead of the normal + `b~MAINPROG.adb' default. Note that FILE denote the Ada binder + generated body filename. In C mode you would normally give FILE an + extension of `.c' because it will be a C source program. Note + that if this option is used, then linking must be done manually. + It is not possible to use gnatlink in this case, since it cannot + locate the binder file. + + `-r' + Generate list of `pragma Rerstrictions' that could be applied to + the current unit. This is useful for code audit purposes, and also + may be used to improve code generation in some cases. + +  + File: gnat_ug_unx.info, Node: Binding with Non-Ada Main Programs, Next: Binding Programs with No Main Subprogram, Prev: Output Control, Up: Binding Using gnatbind + + Binding with Non-Ada Main Programs + ================================== + + In our description so far we have assumed that the main program is in + Ada, and that the task of the binder is to generate a corresponding + function `main' that invokes this Ada main program. GNAT also supports + the building of executable programs where the main program is not in + Ada, but some of the called routines are written in Ada and compiled + using GNAT (*note Mixed Language Programming::). The following switch + is used in this situation: + + `-n' + No main program. The main program is not in Ada. + + In this case, most of the functions of the binder are still required, + but instead of generating a main program, the binder generates a file + containing the following callable routines: + + `adainit' + You must call this routine to initialize the Ada part of the + program by calling the necessary elaboration routines. A call to + `adainit' is required before the first call to an Ada subprogram. + + Note that it is assumed that the basic execution environment must + be setup to be appropriate for Ada execution at the point where + the first Ada subprogram is called. In particular, if the Ada code + will do any floating-point operations, then the FPU must be setup + in an appropriate manner. For the case of the x86, for example, + full precision mode is required. The procedure + GNAT.Float_Control.Reset may be used to ensure that the FPU is in + the right state. + + `adafinal' + You must call this routine to perform any library-level + finalization required by the Ada subprograms. A call to `adafinal' + is required after the last call to an Ada subprogram, and before + the program terminates. + + If the `-n' switch is given, more than one ALI file may appear on the + command line for `gnatbind'. The normal "closure" calculation is + performed for each of the specified units. Calculating the closure + means finding out the set of units involved by tracing `with' + references. The reason it is necessary to be able to specify more than + one ALI file is that a given program may invoke two or more quite + separate groups of Ada units. + + The binder takes the name of its output file from the last specified + ALI file, unless overridden by the use of the `-o file'. The output is + an Ada unit in source form that can be compiled with GNAT unless the -C + switch is used in which case the output is a C source file, which must + be compiled using the C compiler. This compilation occurs + automatically as part of the `gnatlink' processing. + + Currently the GNAT run time requires a FPU using 80 bits mode + precision. Under targets where this is not the default it is required to + call GNAT.Float_Control.Reset before using floating point numbers (this + include float computation, float input and output) in the Ada code. A + side effect is that this could be the wrong mode for the foreign code + where floating point computation could be broken after this call. + +  + File: gnat_ug_unx.info, Node: Binding Programs with No Main Subprogram, Next: Summary of Binder Switches, Prev: Binding with Non-Ada Main Programs, Up: Binding Using gnatbind + + Binding Programs with No Main Subprogram + ======================================== + + It is possible to have an Ada program which does not have a main + subprogram. This program will call the elaboration routines of all the + packages, then the finalization routines. + + The following switch is used to bind programs organized in this + manner: + + `-z' + Normally the binder checks that the unit name given on the command + line corresponds to a suitable main subprogram. When this switch + is used, a list of ALI files can be given, and the execution of + the program consists of elaboration of these units in an + appropriate order. + +  + File: gnat_ug_unx.info, Node: Summary of Binder Switches, Next: Command-Line Access, Prev: Binding Programs with No Main Subprogram, Up: Binding Using gnatbind + + Summary of Binder Switches + ========================== + + The following are the switches available with `gnatbind': + + `-aO' + Specify directory to be searched for ALI files. + + `-aI' + Specify directory to be searched for source file. + + `-A' + Generate binder program in Ada (default) + + `-b' + Generate brief messages to `stderr' even if verbose mode set. + + `-c' + Check only, no generation of binder output file. + + `-C' + Generate binder program in C + + `-e' + Output complete list of elaboration-order dependencies. + + `-E' + Store tracebacks in exception occurrences when the target supports + it. This is the default with the zero cost exception mechanism. + This option is currently supported on the following targets: all + x86 ports, Solaris, Windows, HP-UX, AIX, PowerPC VxWorks and Alpha + VxWorks. See also the packages `GNAT.Traceback' and + `GNAT.Traceback.Symbolic' for more information. Note that on x86 + ports, you must not use `-fomit-frame-pointer' `gcc' option. + + `-h' + Output usage (help) information + + `-I' + Specify directory to be searched for source and ALI files. + + `-I-' + Do not look for sources in the current directory where `gnatbind' + was invoked, and do not look for ALI files in the directory + containing the ALI file named in the `gnatbind' command line. + + `-l' + Output chosen elaboration order. + + `-Lxxx' + Binds the units for library building. In this case the adainit and + adafinal procedures (See *note Binding with Non-Ada Main + Programs::) are renamed to xxxinit and xxxfinal. Implies -n. See + *note GNAT and Libraries:: for more details. + + `-Mxyz' + Rename generated main program from main to xyz + + `-mN' + Limit number of detected errors to N (1-999). + + `-n' + No main program. + + `-nostdinc' + Do not look for sources in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-o FILE' + Name the output file FILE (default is `b~XXX.adb'). Note that if + this option is used, then linking must be done manually, gnatlink + cannot be used. + + `-O' + Output object list. + + `-p' + Pessimistic (worst-case) elaboration order + + `-s' + Require all source files to be present. + + `-static' + Link against a static GNAT run time. + + `-shared' + Link against a shared GNAT run time when available. + + `-t' + Tolerate time stamp and other consistency errors + + `-TN' + Set the time slice value to n microseconds. A value of zero means + no time slicing and also indicates to the tasking run time to + match as close as possible to the annex D requirements of the RM. + + `-v' + Verbose mode. Write error messages, header, summary output to + `stdout'. + + `-wX' + Warning mode (X=s/e for suppress/treat as error) + + `-x' + Exclude source files (check object consistency only). + + `-z' + No main subprogram. + + You may obtain this listing by running the program `gnatbind' with + no arguments. + +  + File: gnat_ug_unx.info, Node: Command-Line Access, Next: Search Paths for gnatbind, Prev: Summary of Binder Switches, Up: Binding Using gnatbind + + Command-Line Access + =================== + + The package `Ada.Command_Line' provides access to the command-line + arguments and program name. In order for this interface to operate + correctly, the two variables + + int gnat_argc; + char **gnat_argv; + + are declared in one of the GNAT library routines. These variables must + be set from the actual `argc' and `argv' values passed to the main + program. With no `n' present, `gnatbind' generates the C main program + to automatically set these variables. If the `n' switch is used, there + is no automatic way to set these variables. If they are not set, the + procedures in `Ada.Command_Line' will not be available, and any attempt + to use them will raise `Constraint_Error'. If command line access is + required, your main program must set `gnat_argc' and `gnat_argv' from + the `argc' and `argv' values passed to it. + +  + File: gnat_ug_unx.info, Node: Search Paths for gnatbind, Next: Examples of gnatbind Usage, Prev: Command-Line Access, Up: Binding Using gnatbind + + Search Paths for `gnatbind' + =========================== + + The binder takes the name of an ALI file as its argument and needs to + locate source files as well as other ALI files to verify object + consistency. + + For source files, it follows exactly the same search rules as `gcc' + (*note Search Paths and the Run-Time Library (RTL)::). For ALI files the + directories searched are: + + 1. The directory containing the ALI file named in the command line, + unless the switch `-I-' is specified. + + 2. All directories specified by `-I' switches on the `gnatbind' + command line, in the order given. + + 3. Each of the directories listed in the value of the + `ADA_OBJECTS_PATH' environment variable. Construct this value + exactly as the `PATH' environment variable: a list of directory + names separated by colons (semicolons when working with the NT + version of GNAT). + + 4. The content of the "ada_object_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as + the GNAT Run Time Library (RTL) unless the switch `-nostdlib' is + specified. *Note Installing an Ada Library:: + + In the binder the switch `-I' is used to specify both source and + library file paths. Use `-aI' instead if you want to specify source + paths only, and `-aO' if you want to specify library paths only. This + means that for the binder `-I'DIR is equivalent to `-aI'DIR `-aO'DIR. + The binder generates the bind file (a C language source file) in the + current working directory. + + The packages `Ada', `System', and `Interfaces' and their children + make up the GNAT Run-Time Library, together with the package GNAT and + its children, which contain a set of useful additional library + functions provided by GNAT. The sources for these units are needed by + the compiler and are kept together in one directory. The ALI files and + object files generated by compiling the RTL are needed by the binder + and the linker and are kept together in one directory, typically + different from the directory containing the sources. In a normal + installation, you need not specify these directory names when compiling + or binding. Either the environment variables or the built-in defaults + cause these files to be found. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + +  + File: gnat_ug_unx.info, Node: Examples of gnatbind Usage, Prev: Search Paths for gnatbind, Up: Binding Using gnatbind + + Examples of `gnatbind' Usage + ============================ + + This section contains a number of examples of using the GNAT binding + utility `gnatbind'. + + `gnatbind hello' + The main program `Hello' (source program in `hello.adb') is bound + using the standard switch settings. The generated main program is + `b~hello.adb'. This is the normal, default use of the binder. + + `gnatbind hello -o mainprog.adb' + The main program `Hello' (source program in `hello.adb') is bound + using the standard switch settings. The generated main program is + `mainprog.adb' with the associated spec in `mainprog.ads'. Note + that you must specify the body here not the spec, in the case + where the output is in Ada. Note that if this option is used, then + linking must be done manually, since gnatlink will not be able to + find the generated file. + + `gnatbind main -C -o mainprog.c -x' + The main program `Main' (source program in `main.adb') is bound, + excluding source files from the consistency checking, generating + the file `mainprog.c'. + + `gnatbind -x main_program -C -o mainprog.c' + This command is exactly the same as the previous example. Switches + may appear anywhere in the command line, and single letter + switches may be combined into a single switch. + + `gnatbind -n math dbase -C -o ada-control.c' + The main program is in a language other than Ada, but calls to + subprograms in packages `Math' and `Dbase' appear. This call to + `gnatbind' generates the file `ada-control.c' containing the + `adainit' and `adafinal' routines to be called before and after + accessing the Ada units. + +  + File: gnat_ug_unx.info, Node: Linking Using gnatlink, Next: The GNAT Make Program gnatmake, Prev: Binding Using gnatbind, Up: Top + + Linking Using `gnatlink' + ************************ + + This chapter discusses `gnatlink', a utility program used to link Ada + programs and build an executable file. This is a simple program that + invokes the Unix linker (via the `gcc' command) with a correct list of + object files and library references. `gnatlink' automatically + determines the list of files and references for the Ada part of a + program. It uses the binder file generated by the binder to determine + this list. + + * Menu: + + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + +  + File: gnat_ug_unx.info, Node: Running gnatlink, Next: Switches for gnatlink, Up: Linking Using gnatlink + + Running `gnatlink' + ================== + + The form of the `gnatlink' command is + + $ gnatlink [SWITCHES] MAINPROG[.ali] [NON-ADA OBJECTS] + [LINKER OPTIONS] + + `MAINPROG.ali' references the ALI file of the main program. The `.ali' + extension of this file can be omitted. From this reference, `gnatlink' + locates the corresponding binder file `b~MAINPROG.adb' and, using the + information in this file along with the list of non-Ada objects and + linker options, constructs a Unix linker command file to create the + executable. + + The arguments following `MAINPROG.ali' are passed to the linker + uninterpreted. They typically include the names of object files for + units written in other languages than Ada and any library references + required to resolve references in any of these foreign language units, + or in `pragma Import' statements in any Ada units. + + LINKER OPTIONS is an optional list of linker specific switches. The + default linker called by gnatlink is GCC which in turn calls the + appropriate system linker usually called LD. Standard options for the + linker such as `-lmy_lib' or `-Ldir' can be added as is. For options + that are not recognized by GCC as linker options, the GCC switches + `-Xlinker' or `-Wl,' shall be used. Refer to the GCC documentation for + details. Here is an example showing how to generate a linker map + assuming that the underlying linker is GNU ld: + + $ gnatlink my_prog -Wl,-Map,MAPFILE + + Using LINKER OPTIONS it is possible to set the program stack and + heap size. See *note Setting Stack Size from gnatlink:: and *note + Setting Heap Size from gnatlink::. + + `gnatlink' determines the list of objects required by the Ada + program and prepends them to the list of objects passed to the linker. + `gnatlink' also gathers any arguments set by the use of `pragma + Linker_Options' and adds them to the list of arguments presented to the + linker. + +  + File: gnat_ug_unx.info, Node: Switches for gnatlink, Next: Setting Stack Size from gnatlink, Prev: Running gnatlink, Up: Linking Using gnatlink + + Switches for `gnatlink' + ======================= + + The following switches are available with the `gnatlink' utility: + + `-A' + The binder has generated code in Ada. This is the default. + + `-C' + If instead of generating a file in Ada, the binder has generated + one in C, then the linker needs to know about it. Use this switch + to signal to `gnatlink' that the binder has generated C code + rather than Ada code. + + `-f' + On some targets, the command line length is limited, and `gnatlink' + will generate a separate file for the linker if the list of object + files is too long. The `-f' flag forces this file to be generated + even if the limit is not exceeded. This is useful in some cases to + deal with special situations where the command line length is + exceeded. + + `-g' + The option to include debugging information causes the Ada bind + file (in other words, `b~MAINPROG.adb') to be compiled with `-g'. + In addition, the binder does not delete the `b~MAINPROG.adb', + `b~MAINPROG.o' and `b~MAINPROG.ali' files. Without `-g', the + binder removes these files by default. The same procedure apply if + a C bind file was generated using `-C' `gnatbind' option, in this + case the filenames are `b_MAINPROG.c' and `b_MAINPROG.o'. + + `-n' + Do not compile the file generated by the binder. This may be used + when a link is rerun with different options, but there is no need + to recompile the binder file. + + `-v' + Causes additional information to be output, including a full list + of the included object files. This switch option is most useful + when you want to see what set of object files are being used in + the link step. + + `-v -v' + Very verbose mode. Requests that the compiler operate in verbose + mode when it compiles the binder file, and that the system linker + run in verbose mode. + + `-o EXEC-NAME' + EXEC-NAME specifies an alternate name for the generated executable + program. If this switch is omitted, the executable has the same + name as the main unit. For example, `gnatlink try.ali' creates an + executable called `try'. + + `-b TARGET' + Compile your program to run on TARGET, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + TARGET is not the same as your host system. + + `-BDIR' + Load compiler executables (for example, `gnat1', the Ada compiler) + from DIR instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + `gcc' manual page for further details. You would normally use the + `-b' or `-V' switch instead. + + `--GCC=COMPILER_NAME' + Program used for compiling the binder file. The default is + ``gcc''. You need to use quotes around COMPILER_NAME if + `compiler_name' contains spaces or other separator characters. As + an example `--GCC="foo -x -y"' will instruct `gnatlink' to use + `foo -x -y' as your compiler. Note that switch `-c' is always + inserted after your command name. Thus in the above example the + compiler command that will be used by `gnatlink' will be `foo -c + -x -y'. If several `--GCC=compiler_name' are used, only the last + COMPILER_NAME is taken into account. However, all the additional + switches are also taken into account. Thus, `--GCC="foo -x -y" + --GCC="bar -z -t"' is equivalent to `--GCC="bar -x -y -z -t"'. + + `--LINK=NAME' + NAME is the name of the linker to be invoked. This is especially + useful in mixed language programs since languages such as c++ + require their own linker to be used. When this switch is omitted, + the default name for the linker is (`gcc'). When this switch is + used, the specified linker is called instead of (`gcc') with + exactly the same parameters that would have been passed to (`gcc') + so if the desired linker requires different parameters it is + necessary to use a wrapper script that massages the parameters + before invoking the real linker. It may be useful to control the + exact invocation by using the verbose switch. + +  + File: gnat_ug_unx.info, Node: Setting Stack Size from gnatlink, Next: Setting Heap Size from gnatlink, Prev: Switches for gnatlink, Up: Linking Using gnatlink + + Setting Stack Size from `gnatlink' + ================================== + + It is possible to specify the program stack size from `gnatlink'. + Assuming that the underlying linker is GNU ld there is two ways to do + so: + + * using `-Xlinker' linker option + + $ gnatlink hello -Xlinker --stack=0x10000,0x1000 + + This set the stack reserve size to 0x10000 bytes and the stack + commit size to 0x1000 bytes. + + * using `-Wl' linker option + + $ gnatlink hello -Wl,--stack=0x1000000 + + This set the stack reserve size to 0x1000000 bytes. Note that with + `-Wl' option it is not possible to set the stack commit size + because the coma is a separator for this option. + + +  + File: gnat_ug_unx.info, Node: Setting Heap Size from gnatlink, Prev: Setting Stack Size from gnatlink, Up: Linking Using gnatlink + + Setting Heap Size from `gnatlink' + ================================= + + It is possible to specify the program heap size from `gnatlink'. + Assuming that the underlying linker is GNU ld there is two ways to do + so: + + * using `-Xlinker' linker option + + $ gnatlink hello -Xlinker --heap=0x10000,0x1000 + + This set the heap reserve size to 0x10000 bytes and the heap commit + size to 0x1000 bytes. + + * using `-Wl' linker option + + $ gnatlink hello -Wl,--heap=0x1000000 + + This set the heap reserve size to 0x1000000 bytes. Note that with + `-Wl' option it is not possible to set the heap commit size + because the coma is a separator for this option. + + +  + File: gnat_ug_unx.info, Node: The GNAT Make Program gnatmake, Next: Renaming Files Using gnatchop, Prev: Linking Using gnatlink, Up: Top + + The GNAT Make Program `gnatmake' + ******************************** + + * Menu: + + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + + A typical development cycle when working on an Ada program consists of + the following steps: + + 1. Edit some sources to fix bugs. + + 2. Add enhancements. + + 3. Compile all sources affected. + + 4. Rebind and relink. + + 5. Test. + + The third step can be tricky, because not only do the modified files + have to be compiled, but any files depending on these files must also be + recompiled. The dependency rules in Ada can be quite complex, especially + in the presence of overloading, `use' clauses, generics and inlined + subprograms. + + `gnatmake' automatically takes care of the third and fourth steps of + this process. It determines which sources need to be compiled, compiles + them, and binds and links the resulting object files. + + Unlike some other Ada make programs, the dependencies are always + accurately recomputed from the new sources. The source based approach of + the GNAT compilation model makes this possible. This means that if + changes to the source program cause corresponding changes in + dependencies, they will always be tracked exactly correctly by + `gnatmake'. + +  + File: gnat_ug_unx.info, Node: Running gnatmake, Next: Switches for gnatmake, Up: The GNAT Make Program gnatmake + + Running `gnatmake' + ================== + + The usual form of the `gnatmake' command is + + $ gnatmake [SWITCHES] FILE_NAME [FILE_NAMES] [MODE_SWITCHES] + + The only required argument is one FILE_NAME, which specifies a + compilation unit that is a main program. Several FILE_NAMES can be + specified: this will result in several executables being built. If + `switches' are present, they can be placed before the first FILE_NAME, + between FILE_NAMES or after the last FILE_NAME. If MODE_SWITCHES are + present, they must always be placed after the last FILE_NAME and all + `switches'. + + If you are using standard file extensions (.adb and .ads), then the + extension may be omitted from the FILE_NAME arguments. However, if you + are using non-standard extensions, then it is required that the + extension be given. A relative or absolute directory path can be + specified in a FILE_NAME, in which case, the input source file will be + searched for in the specified directory only. Otherwise, the input + source file will first be searched in the directory where `gnatmake' + was invoked and if it is not found, it will be search on the source + path of the compiler as described in *Note Search Paths and the + Run-Time Library (RTL)::. + + When several FILE_NAMES are specified, if an executable needs to be + rebuilt and relinked, all subsequent executables will be rebuilt and + relinked, even if this would not be absolutely necessary. + + All `gnatmake' output (except when you specify `-M') is to `stderr'. + The output produced by the `-M' switch is send to `stdout'. + +  + File: gnat_ug_unx.info, Node: Switches for gnatmake, Next: Mode Switches for gnatmake, Prev: Running gnatmake, Up: The GNAT Make Program gnatmake + + Switches for `gnatmake' + ======================= + + You may specify any of the following switches to `gnatmake': + + `--GCC=COMPILER_NAME' + Program used for compiling. The default is ``gcc''. You need to use + quotes around COMPILER_NAME if `compiler_name' contains spaces or + other separator characters. As an example `--GCC="foo -x -y"' will + instruct `gnatmake' to use `foo -x -y' as your compiler. Note that + switch `-c' is always inserted after your command name. Thus in + the above example the compiler command that will be used by + `gnatmake' will be `foo -c -x -y'. If several + `--GCC=compiler_name' are used, only the last COMPILER_NAME is + taken into account. However, all the additional switches are also + taken into account. Thus, `--GCC="foo -x -y" --GCC="bar -z -t"' is + equivalent to `--GCC="bar -x -y -z -t"'. + + `--GNATBIND=BINDER_NAME' + Program used for binding. The default is ``gnatbind''. You need to + use quotes around BINDER_NAME if BINDER_NAME contains spaces or + other separator characters. As an example `--GNATBIND="bar -x -y"' + will instruct `gnatmake' to use `bar -x -y' as your binder. Binder + switches that are normally appended by `gnatmake' to ``gnatbind'' + are now appended to the end of `bar -x -y'. + + `--GNATLINK=LINKER_NAME' + Program used for linking. The default is ``gnatlink''. You need to + use quotes around LINKER_NAME if LINKER_NAME contains spaces or + other separator characters. As an example `--GNATLINK="lan -x -y"' + will instruct `gnatmake' to use `lan -x -y' as your linker. Linker + switches that are normally appended by `gnatmake' to ``gnatlink'' + are now appended to the end of `lan -x -y'. + + `-a' + Consider all files in the make process, even the GNAT internal + system files (for example, the predefined Ada library files), as + well as any locked files. Locked files are files whose ALI file is + write-protected. By default, `gnatmake' does not check these + files, because the assumption is that the GNAT internal files are + properly up to date, and also that any write protected ALI files + have been properly installed. Note that if there is an + installation problem, such that one of these files is not up to + date, it will be properly caught by the binder. You may have to + specify this switch if you are working on GNAT itself. `-a' is + also useful in conjunction with `-f' if you need to recompile an + entire application, including run-time files, using special + configuration pragma settings, such as a non-standard + `Float_Representation' pragma. By default `gnatmake -a' compiles + all GNAT internal files with `gcc -c -gnatpg' rather than `gcc -c'. + + `-b' + Bind only. Can be combined with `-c' to do compilation and + binding, but no link. Can be combined with `-l' to do binding and + linking. When not combined with `-c' all the units in the closure + of the main program must have been previously compiled and must be + up to date. The root unit specified by FILE_NAME may be given + without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + `-c' + Compile only. Do not perform binding, except when `-b' is also + specified. Do not perform linking, except if both `-b' and `-l' + are also specified. If the root unit specified by FILE_NAME is + not a main unit, this is the default. Otherwise `gnatmake' will + attempt binding and linking unless all objects are up to date and + the executable is more recent than the objects. + + `-C' + Use a mapping file. A mapping file is a way to communicate to the + compiler two mappings: from unit names to file names (without any + directory information) and from file names to path names (with + full directory information). These mappings are used by the + compiler to short-circuit the path search. When `gnatmake' is + invoked with this switch, it will create a mapping file, initially + populated by the project manager, if `-P' is used, otherwise + initially empty. Each invocation of the compiler will add the newly + accessed sources to the mapping file. This will improve the source + search during the next invocation of the compiler. + + `-f' + Force recompilations. Recompile all sources, even though some + object files may be up to date, but don't recompile predefined or + GNAT internal files or locked files (files with a write-protected + ALI file), unless the `-a' switch is also specified. + + `' + + `-i' + In normal mode, `gnatmake' compiles all object files and ALI files + into the current directory. If the `-i' switch is used, then + instead object files and ALI files that already exist are + overwritten in place. This means that once a large project is + organized into separate directories in the desired manner, then + `gnatmake' will automatically maintain and update this + organization. If no ALI files are found on the Ada object path + (*Note Search Paths and the Run-Time Library (RTL)::), the new + object and ALI files are created in the directory containing the + source being compiled. If another organization is desired, where + objects and sources are kept in different directories, a useful + technique is to create dummy ALI files in the desired directories. + When detecting such a dummy file, `gnatmake' will be forced to + recompile the corresponding source file, and it will be put the + resulting object and ALI files in the directory where it found the + dummy file. + + `-jN' + Use N processes to carry out the (re)compilations. On a + multiprocessor machine compilations will occur in parallel. In the + event of compilation errors, messages from various compilations + might get interspersed (but `gnatmake' will give you the full + ordered list of failing compiles at the end). If this is + problematic, rerun the make process with n set to 1 to get a clean + list of messages. + + `-k' + Keep going. Continue as much as possible after a compilation + error. To ease the programmer's task in case of compilation + errors, the list of sources for which the compile fails is given + when `gnatmake' terminates. + + If `gnatmake' is invoked with several `file_names' and with this + switch, if there are compilation errors when building an + executable, `gnatmake' will not attempt to build the following + executables. + + `-l' + Link only. Can be combined with `-b' to binding and linking. + Linking will not be performed if combined with `-c' but not with + `-b'. When not combined with `-b' all the units in the closure of + the main program must have been previously compiled and must be up + to date, and the main program need to have been bound. The root + unit specified by FILE_NAME may be given without extension, with + the source extension or, if no GNAT Project File is specified, + with the ALI file extension. + + `-m' + Specifies that the minimum necessary amount of recompilations be + performed. In this mode `gnatmake' ignores time stamp differences + when the only modifications to a source file consist in + adding/removing comments, empty lines, spaces or tabs. This means + that if you have changed the comments in a source file or have + simply reformatted it, using this switch will tell gnatmake not to + recompile files that depend on it (provided other sources on which + these files depend have undergone no semantic modifications). Note + that the debugging information may be out of date with respect to + the sources if the `-m' switch causes a compilation to be + switched, so the use of this switch represents a trade-off between + compilation time and accurate debugging information. + + `-M' + Check if all objects are up to date. If they are, output the object + dependences to `stdout' in a form that can be directly exploited in + a `Makefile'. By default, each source file is prefixed with its + (relative or absolute) directory name. This name is whatever you + specified in the various `-aI' and `-I' switches. If you use + `gnatmake -M' `-q' (see below), only the source file names, + without relative paths, are output. If you just specify the `-M' + switch, dependencies of the GNAT internal system files are + omitted. This is typically what you want. If you also specify the + `-a' switch, dependencies of the GNAT internal files are also + listed. Note that dependencies of the objects in external Ada + libraries (see switch `-aL'DIR in the following list) are never + reported. + + `-n' + Don't compile, bind, or link. Checks if all objects are up to date. + If they are not, the full name of the first file that needs to be + recompiled is printed. Repeated use of this option, followed by + compiling the indicated source file, will eventually result in + recompiling all required units. + + `-o EXEC_NAME' + Output executable name. The name of the final executable program + will be EXEC_NAME. If the `-o' switch is omitted the default name + for the executable will be the name of the input file in + appropriate form for an executable file on the host system. + + This switch cannot be used when invoking `gnatmake' with several + `file_names'. + + `-q' + Quiet. When this flag is not set, the commands carried out by + `gnatmake' are displayed. + + `-s' + Recompile if compiler switches have changed since last compilation. + All compiler switches but -I and -o are taken into account in the + following way: orders between different "first letter" switches + are ignored, but orders between same switches are taken into + account. For example, `-O -O2' is different than `-O2 -O', but `-g + -O' is equivalent to `-O -g'. + + `-u' + Unique. Recompile at most the main file. It implies -c. Combined + with -f, it is equivalent to calling the compiler directly. + + `-v' + Verbose. Displays the reason for all recompilations `gnatmake' + decides are necessary. + + `-z' + No main subprogram. Bind and link the program even if the unit name + given on the command line is a package name. The resulting + executable will execute the elaboration routines of the package + and its closure, then the finalization routines. + + ``gcc' switches' + The switch `-g' or any uppercase switch (other than `-A', `-L' or + `-S') or any switch that is more than one character is passed to + `gcc' (e.g. `-O', `-gnato,' etc.) + + Source and library search path switches: + + `-aIDIR' + When looking for source files also look in directory DIR. The + order in which source files search is undertaken is described in + *Note Search Paths and the Run-Time Library (RTL)::. + + `-aLDIR' + Consider DIR as being an externally provided Ada library. + Instructs `gnatmake' to skip compilation units whose `.ali' files + have been located in directory DIR. This allows you to have + missing bodies for the units in DIR and to ignore out of date + bodies for the same units. You still need to specify the location + of the specs for these units by using the switches `-aIDIR' or + `-IDIR'. Note: this switch is provided for compatibility with + previous versions of `gnatmake'. The easier method of causing + standard libraries to be excluded from consideration is to + write-protect the corresponding ALI files. + + `-aODIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is described in + *Note Search Paths for gnatbind::. + + `-ADIR' + Equivalent to `-aLDIR -aIDIR'. + + `-IDIR' + Equivalent to `-aODIR -aIDIR'. + + `-I-' + Do not look for source files in the directory containing the source + file named in the command line. Do not look for ALI or object + files in the directory where `gnatmake' was invoked. + + `-LDIR' + Add directory DIR to the list of directories in which the linker + will search for libraries. This is equivalent to `-largs -L'DIR. + + `-nostdinc' + Do not look for source files in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. We look for + the runtime in the following directories, and stop as soon as a + valid runtime is found ("adainclude" or "ada_source_path", and + "adalib" or "ada_object_path" present): + + * /$rts_path + + * /$rts_path + + * /rts-$rts_path + + The selected path is handled like a normal RTS path. + +  + File: gnat_ug_unx.info, Node: Mode Switches for gnatmake, Next: Notes on the Command Line, Prev: Switches for gnatmake, Up: The GNAT Make Program gnatmake + + Mode Switches for `gnatmake' + ============================ + + The mode switches (referred to as `mode_switches') allow the inclusion + of switches that are to be passed to the compiler itself, the binder or + the linker. The effect of a mode switch is to cause all subsequent + switches up to the end of the switch list, or up to the next mode + switch, to be interpreted as switches to be passed on to the designated + component of GNAT. + + `-cargs SWITCHES' + Compiler switches. Here SWITCHES is a list of switches that are + valid switches for `gcc'. They will be passed on to all compile + steps performed by `gnatmake'. + + `-bargs SWITCHES' + Binder switches. Here SWITCHES is a list of switches that are + valid switches for `gcc'. They will be passed on to all bind steps + performed by `gnatmake'. + + `-largs SWITCHES' + Linker switches. Here SWITCHES is a list of switches that are + valid switches for `gcc'. They will be passed on to all link steps + performed by `gnatmake'. + +  + File: gnat_ug_unx.info, Node: Notes on the Command Line, Next: How gnatmake Works, Prev: Mode Switches for gnatmake, Up: The GNAT Make Program gnatmake + + Notes on the Command Line + ========================= + + This section contains some additional useful notes on the operation of + the `gnatmake' command. + + * If `gnatmake' finds no ALI files, it recompiles the main program + and all other units required by the main program. This means that + `gnatmake' can be used for the initial compile, as well as during + subsequent steps of the development cycle. + + * If you enter `gnatmake FILE.adb', where `FILE.adb' is a subunit or + body of a generic unit, `gnatmake' recompiles `FILE.adb' (because + it finds no ALI) and stops, issuing a warning. + + * In `gnatmake' the switch `-I' is used to specify both source and + library file paths. Use `-aI' instead if you just want to specify + source paths only and `-aO' if you want to specify library paths + only. + + * `gnatmake' examines both an ALI file and its corresponding object + file for consistency. If an ALI is more recent than its + corresponding object, or if the object file is missing, the + corresponding source will be recompiled. Note that `gnatmake' + expects an ALI and the corresponding object file to be in the same + directory. + + * `gnatmake' will ignore any files whose ALI file is write-protected. + This may conveniently be used to exclude standard libraries from + consideration and in particular it means that the use of the `-f' + switch will not recompile these files unless `-a' is also + specified. + + * `gnatmake' has been designed to make the use of Ada libraries + particularly convenient. Assume you have an Ada library organized + as follows: OBJ-DIR contains the objects and ALI files for of your + Ada compilation units, whereas INCLUDE-DIR contains the specs of + these units, but no bodies. Then to compile a unit stored in + `main.adb', which uses this Ada library you would just type + + $ gnatmake -aIINCLUDE-DIR -aLOBJ-DIR main + + * Using `gnatmake' along with the `-m (minimal recompilation)' + switch provides a mechanism for avoiding unnecessary + rcompilations. Using this switch, you can update the + comments/format of your source files without having to recompile + everything. Note, however, that adding or deleting lines in a + source files may render its debugging info obsolete. If the file + in question is a spec, the impact is rather limited, as that + debugging info will only be useful during the elaboration phase of + your program. For bodies the impact can be more significant. In + all events, your debugger will warn you if a source file is more + recent than the corresponding object, and alert you to the fact + that the debugging information may be out of date. + +  + File: gnat_ug_unx.info, Node: How gnatmake Works, Next: Examples of gnatmake Usage, Prev: Notes on the Command Line, Up: The GNAT Make Program gnatmake + + How `gnatmake' Works + ==================== + + Generally `gnatmake' automatically performs all necessary + recompilations and you don't need to worry about how it works. However, + it may be useful to have some basic understanding of the `gnatmake' + approach and in particular to understand how it uses the results of + previous compilations without incorrectly depending on them. + + First a definition: an object file is considered "up to date" if the + corresponding ALI file exists and its time stamp predates that of the + object file and if all the source files listed in the dependency + section of this ALI file have time stamps matching those in the ALI + file. This means that neither the source file itself nor any files that + it depends on have been modified, and hence there is no need to + recompile this file. + + `gnatmake' works by first checking if the specified main unit is up + to date. If so, no compilations are required for the main unit. If not, + `gnatmake' compiles the main program to build a new ALI file that + reflects the latest sources. Then the ALI file of the main unit is + examined to find all the source files on which the main program depends, + and `gnatmake' recursively applies the above procedure on all these + files. + + This process ensures that `gnatmake' only trusts the dependencies in + an existing ALI file if they are known to be correct. Otherwise it + always recompiles to determine a new, guaranteed accurate set of + dependencies. As a result the program is compiled "upside down" from + what may be more familiar as the required order of compilation in some + other Ada systems. In particular, clients are compiled before the units + on which they depend. The ability of GNAT to compile in any order is + critical in allowing an order of compilation to be chosen that + guarantees that `gnatmake' will recompute a correct set of new + dependencies if necessary. + + When invoking `gnatmake' with several FILE_NAMES, if a unit is + imported by several of the executables, it will be recompiled at most + once. + +  + File: gnat_ug_unx.info, Node: Examples of gnatmake Usage, Prev: How gnatmake Works, Up: The GNAT Make Program gnatmake + + Examples of `gnatmake' Usage + ============================ + + `gnatmake hello.adb' + Compile all files necessary to bind and link the main program + `hello.adb' (containing unit `Hello') and bind and link the + resulting object files to generate an executable file `hello'. + + `gnatmake main1 main2 main3' + Compile all files necessary to bind and link the main programs + `main1.adb' (containing unit `Main1'), `main2.adb' (containing + unit `Main2') and `main3.adb' (containing unit `Main3') and bind + and link the resulting object files to generate three executable + files `main1', `main2' and `main3'. + + `gnatmake -q Main_Unit -cargs -O2 -bargs -l' + Compile all files necessary to bind and link the main program unit + `Main_Unit' (from file `main_unit.adb'). All compilations will be + done with optimization level 2 and the order of elaboration will be + listed by the binder. `gnatmake' will operate in quiet mode, not + displaying commands it is executing. + +  + File: gnat_ug_unx.info, Node: Renaming Files Using gnatchop, Next: Configuration Pragmas, Prev: The GNAT Make Program gnatmake, Up: Top + + Renaming Files Using `gnatchop' + ******************************* + + This chapter discusses how to handle files with multiple units by using + the `gnatchop' utility. This utility is also useful in renaming files + to meet the standard GNAT default file naming conventions. + + * Menu: + + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + +  + File: gnat_ug_unx.info, Node: Handling Files with Multiple Units, Next: Operating gnatchop in Compilation Mode, Up: Renaming Files Using gnatchop + + Handling Files with Multiple Units + ================================== + + The basic compilation model of GNAT requires that a file submitted to + the compiler have only one unit and there be a strict correspondence + between the file name and the unit name. + + The `gnatchop' utility allows both of these rules to be relaxed, + allowing GNAT to process files which contain multiple compilation units + and files with arbitrary file names. `gnatchop' reads the specified + file and generates one or more output files, containing one unit per + file. The unit and the file name correspond, as required by GNAT. + + If you want to permanently restructure a set of "foreign" files so + that they match the GNAT rules, and do the remaining development using + the GNAT structure, you can simply use `gnatchop' once, generate the + new set of files and work with them from that point on. + + Alternatively, if you want to keep your files in the "foreign" + format, perhaps to maintain compatibility with some other Ada + compilation system, you can set up a procedure where you use `gnatchop' + each time you compile, regarding the source files that it writes as + temporary files that you throw away. + +  + File: gnat_ug_unx.info, Node: Operating gnatchop in Compilation Mode, Next: Command Line for gnatchop, Prev: Handling Files with Multiple Units, Up: Renaming Files Using gnatchop + + Operating gnatchop in Compilation Mode + ====================================== + + The basic function of `gnatchop' is to take a file with multiple units + and split it into separate files. The boundary between files is + reasonably clear, except for the issue of comments and pragmas. In + default mode, the rule is that any pragmas between units belong to the + previous unit, except that configuration pragmas always belong to the + following unit. Any comments belong to the following unit. These rules + almost always result in the right choice of the split point without + needing to mark it explicitly and most users will find this default to + be what they want. In this default mode it is incorrect to submit a + file containing only configuration pragmas, or one that ends in + configuration pragmas, to `gnatchop'. + + However, using a special option to activate "compilation mode", + `gnatchop' can perform another function, which is to provide exactly + the semantics required by the RM for handling of configuration pragmas + in a compilation. In the absence of configuration pragmas (at the main + file level), this option has no effect, but it causes such + configuration pragmas to be handled in a quite different manner. + + First, in compilation mode, if `gnatchop' is given a file that + consists of only configuration pragmas, then this file is appended to + the `gnat.adc' file in the current directory. This behavior provides + the required behavior described in the RM for the actions to be taken + on submitting such a file to the compiler, namely that these pragmas + should apply to all subsequent compilations in the same compilation + environment. Using GNAT, the current directory, possibly containing a + `gnat.adc' file is the representation of a compilation environment. For + more information on the `gnat.adc' file, see the section on handling of + configuration pragmas *note Handling of Configuration Pragmas::. + + Second, in compilation mode, if `gnatchop' is given a file that + starts with configuration pragmas, and contains one or more units, then + these configuration pragmas are prepended to each of the chopped files. + This behavior provides the required behavior described in the RM for the + actions to be taken on compiling such a file, namely that the pragmas + apply to all units in the compilation, but not to subsequently compiled + units. + + Finally, if configuration pragmas appear between units, they are + appended to the previous unit. This results in the previous unit being + illegal, since the compiler does not accept configuration pragmas that + follow a unit. This provides the required RM behavior that forbids + configuration pragmas other than those preceding the first compilation + unit of a compilation. + + For most purposes, `gnatchop' will be used in default mode. The + compilation mode described above is used only if you need exactly + accurate behavior with respect to compilations, and you have files that + contain multiple units and configuration pragmas. In this circumstance + the use of `gnatchop' with the compilation mode switch provides the + required behavior, and is for example the mode in which GNAT processes + the ACVC tests. + +  + File: gnat_ug_unx.info, Node: Command Line for gnatchop, Next: Switches for gnatchop, Prev: Operating gnatchop in Compilation Mode, Up: Renaming Files Using gnatchop + + Command Line for `gnatchop' + =========================== + + The `gnatchop' command has the form: + + $ gnatchop switches FILE NAME [FILE NAME FILE NAME ...] + [DIRECTORY] + + The only required argument is the file name of the file to be chopped. + There are no restrictions on the form of this file name. The file itself + contains one or more Ada units, in normal GNAT format, concatenated + together. As shown, more than one file may be presented to be chopped. + + When run in default mode, `gnatchop' generates one output file in + the current directory for each unit in each of the files. + + DIRECTORY, if specified, gives the name of the directory to which + the output files will be written. If it is not specified, all files are + written to the current directory. + + For example, given a file called `hellofiles' containing + + procedure hello; + + with Text_IO; use Text_IO; + procedure hello is + begin + Put_Line ("Hello"); + end hello; + + the command + + $ gnatchop hellofiles + + generates two files in the current directory, one called `hello.ads' + containing the single line that is the procedure spec, and the other + called `hello.adb' containing the remaining text. The original file is + not affected. The generated files can be compiled in the normal manner. + +  + File: gnat_ug_unx.info, Node: Switches for gnatchop, Next: Examples of gnatchop Usage, Prev: Command Line for gnatchop, Up: Renaming Files Using gnatchop + + Switches for `gnatchop' + ======================= + + `gnatchop' recognizes the following switches: + + `-c' + Causes `gnatchop' to operate in compilation mode, in which + configuration pragmas are handled according to strict RM rules. See + previous section for a full description of this mode. + + `-gnatxxx' + This passes the given `-gnatxxx' switch to `gnat' which is used to + parse the given file. Not all `xxx' options make sense, but for + example, the use of `-gnati2' allows `gnatchop' to process a + source file that uses Latin-2 coding for identifiers. + + `-h' + Causes `gnatchop' to generate a brief help summary to the standard + output file showing usage information. + + `-kMM' + Limit generated file names to the specified number `mm' of + characters. This is useful if the resulting set of files is + required to be interoperable with systems which limit the length + of file names. No space is allowed between the `-k' and the + numeric value. The numeric value may be omitted in which case a + default of `-k8', suitable for use with DOS-like file systems, is + used. If no `-k' switch is present then there is no limit on the + length of file names. + + `-p' + Causes the file modification time stamp of the input file to be + preserved and used for the time stamp of the output file(s). This + may be useful for preserving coherency of time stamps in an + enviroment where `gnatchop' is used as part of a standard build + process. + + `-q' + Causes output of informational messages indicating the set of + generated files to be suppressed. Warnings and error messages are + unaffected. + + `-r' + Generate `Source_Reference' pragmas. Use this switch if the output + files are regarded as temporary and development is to be done in + terms of the original unchopped file. This switch causes + `Source_Reference' pragmas to be inserted into each of the + generated files to refers back to the original file name and line + number. The result is that all error messages refer back to the + original unchopped file. In addition, the debugging information + placed into the object file (when the `-g' switch of `gcc' or + `gnatmake' is specified) also refers back to this original file so + that tools like profilers and debuggers will give information in + terms of the original unchopped file. + + If the original file to be chopped itself contains a + `Source_Reference' pragma referencing a third file, then gnatchop + respects this pragma, and the generated `Source_Reference' pragmas + in the chopped file refer to the original file, with appropriate + line numbers. This is particularly useful when `gnatchop' is used + in conjunction with `gnatprep' to compile files that contain + preprocessing statements and multiple units. + + `-v' + Causes `gnatchop' to operate in verbose mode. The version number + and copyright notice are output, as well as exact copies of the + gnat1 commands spawned to obtain the chop control information. + + `-w' + Overwrite existing file names. Normally `gnatchop' regards it as a + fatal error if there is already a file with the same name as a + file it would otherwise output, in other words if the files to be + chopped contain duplicated units. This switch bypasses this check, + and causes all but the last instance of such duplicated units to + be skipped. + + `--GCC=xxxx' + Specify the path of the GNAT parser to be used. When this switch + is used, no attempt is made to add the prefix to the GNAT parser + executable. + +  + File: gnat_ug_unx.info, Node: Examples of gnatchop Usage, Prev: Switches for gnatchop, Up: Renaming Files Using gnatchop + + Examples of `gnatchop' Usage + ============================ + + `gnatchop -w hello_s.ada ichbiah/files' + Chops the source file `hello_s.ada'. The output files will be + placed in the directory `ichbiah/files', overwriting any files + with matching names in that directory (no files in the current + directory are modified). + + `gnatchop archive' + Chops the source file `archive' into the current directory. One + useful application of `gnatchop' is in sending sets of sources + around, for example in email messages. The required sources are + simply concatenated (for example, using a Unix `cat' command), and + then `gnatchop' is used at the other end to reconstitute the + original file names. + + `gnatchop file1 file2 file3 direc' + Chops all units in files `file1', `file2', `file3', placing the + resulting files in the directory `direc'. Note that if any units + occur more than once anywhere within this set of files, an error + message is generated, and no files are written. To override this + check, use the `-w' switch, in which case the last occurrence in + the last file will be the one that is output, and earlier + duplicate occurrences for a given unit will be skipped. + +  + File: gnat_ug_unx.info, Node: Configuration Pragmas, Next: Handling Arbitrary File Naming Conventions Using gnatname, Prev: Renaming Files Using gnatchop, Up: Top + + Configuration Pragmas + ********************* + + In Ada 95, configuration pragmas include those pragmas described as + such in the Ada 95 Reference Manual, as well as + implementation-dependent pragmas that are configuration pragmas. See the + individual descriptions of pragmas in the GNAT Reference Manual for + details on these additional GNAT-specific configuration pragmas. Most + notably, the pragma `Source_File_Name', which allows specifying + non-default names for source files, is a configuration pragma. The + following is a complete list of configuration pragmas recognized by + `GNAT': + + Ada_83 + Ada_95 + C_Pass_By_Copy + Component_Alignment + Discard_Names + Elaboration_Checks + Eliminate + Extend_System + Extensions_Allowed + External_Name_Casing + Float_Representation + Initialize_Scalars + License + Locking_Policy + Long_Float + No_Run_Time + Normalize_Scalars + Polling + Propagate_Exceptions + Queuing_Policy + Ravenscar + Restricted_Run_Time + Restrictions + Reviewable + Source_File_Name + Style_Checks + Suppress + Task_Dispatching_Policy + Unsuppress + Use_VADS_Size + Warnings + Validity_Checks + + * Menu: + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + +  + File: gnat_ug_unx.info, Node: Handling of Configuration Pragmas, Next: The Configuration Pragmas Files, Up: Configuration Pragmas + + Handling of Configuration Pragmas + ================================= + + Configuration pragmas may either appear at the start of a compilation + unit, in which case they apply only to that unit, or they may apply to + all compilations performed in a given compilation environment. + + GNAT also provides the `gnatchop' utility to provide an automatic + way to handle configuration pragmas following the semantics for + compilations (that is, files with multiple units), described in the RM. + See section *note Operating gnatchop in Compilation Mode:: for details. + However, for most purposes, it will be more convenient to edit the + `gnat.adc' file that contains configuration pragmas directly, as + described in the following section. + +  + File: gnat_ug_unx.info, Node: The Configuration Pragmas Files, Prev: Handling of Configuration Pragmas, Up: Configuration Pragmas + + The Configuration Pragmas Files + =============================== + + In GNAT a compilation environment is defined by the current directory + at the time that a compile command is given. This current directory is + searched for a file whose name is `gnat.adc'. If this file is present, + it is expected to contain one or more configuration pragmas that will + be applied to the current compilation. However, if the switch `-gnatA' + is used, `gnat.adc' is not considered. + + Configuration pragmas may be entered into the `gnat.adc' file either + by running `gnatchop' on a source file that consists only of + configuration pragmas, or more conveniently by direct editing of the + `gnat.adc' file, which is a standard format source file. + + In addition to `gnat.adc', one additional file containing + configuration pragmas may be applied to the current compilation using + the switch `-gnatec'PATH. PATH must designate an existing file that + contains only configuration pragmas. These configuration pragmas are in + addition to those found in `gnat.adc' (provided `gnat.adc' is present + and switch `-gnatA' is not used). + + It is allowed to specify several switches `-gnatec', however only + the last one on the command line will be taken into account. + +  + File: gnat_ug_unx.info, Node: Handling Arbitrary File Naming Conventions Using gnatname, Next: GNAT Project Manager, Prev: Configuration Pragmas, Up: Top + + Handling Arbitrary File Naming Conventions Using `gnatname' + *********************************************************** + + * Menu: + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + +  + File: gnat_ug_unx.info, Node: Arbitrary File Naming Conventions, Next: Running gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Arbitrary File Naming Conventions + ================================= + + The GNAT compiler must be able to know the source file name of a + compilation unit. When using the standard GNAT default file naming + conventions (`.ads' for specs, `.adb' for bodies), the GNAT compiler + does not need additional information. + + When the source file names do not follow the standard GNAT default file + naming conventions, the GNAT compiler must be given additional + information through a configuration pragmas file (see *Note + Configuration Pragmas::) or a project file. When the non standard file + naming conventions are well-defined, a small number of pragmas + `Source_File_Name' specifying a naming pattern (see *Note Alternative + File Naming Schemes::) may be sufficient. However, if the file naming + conventions are irregular or arbitrary, a number of pragma + `Source_File_Name' for individual compilation units must be defined. + To help maintain the correspondence between compilation unit names and + source file names within the compiler, GNAT provides a tool `gnatname' + to generate the required pragmas for a set of files. + +  + File: gnat_ug_unx.info, Node: Running gnatname, Next: Switches for gnatname, Prev: Arbitrary File Naming Conventions, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Running `gnatname' + ================== + + The usual form of the `gnatname' command is + + $ gnatname [SWITCHES] NAMING_PATTERN [NAMING_PATTERNS] + + All of the arguments are optional. If invoked without any argument, + `gnatname' will display its usage. + + When used with at least one naming pattern, `gnatname' will attempt to + find all the compilation units in files that follow at least one of the + naming patterns. To find these compilation units, `gnatname' will use + the GNAT compiler in syntax-check-only mode on all regular files. + + One or several Naming Patterns may be given as arguments to `gnatname'. + Each Naming Pattern is enclosed between double quotes. A Naming + Pattern is a regular expression similar to the wildcard patterns used + in file names by the Unix shells or the DOS prompt. + + Examples of Naming Patterns are + + "*.[12].ada" + "*.ad[sb]*" + "body_*" "spec_*" + + For a more complete description of the syntax of Naming Patterns, see + the second kind of regular expressions described in `g-regexp.ads' (the + "Glob" regular expressions). + + When invoked with no switches, `gnatname' will create a configuration + pragmas file `gnat.adc' in the current working directory, with pragmas + `Source_File_Name' for each file that contains a valid Ada unit. + +  + File: gnat_ug_unx.info, Node: Switches for gnatname, Next: Examples of gnatname Usage, Prev: Running gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Switches for `gnatname' + ======================= + + Switches for `gnatname' must precede any specified Naming Pattern. + + You may specify any of the following switches to `gnatname': + + `-c`file'' + Create a configuration pragmas file `file' (instead of the default + `gnat.adc'). There may be zero, one or more space between `-c' and + `file'. `file' may include directory information. `file' must be + writeable. There may be only one switch `-c'. When a switch `-c' is + specified, no switch `-P' may be specified (see below). + + `-d`dir'' + Look for source files in directory `dir'. There may be zero, one + or more spaces between `-d' and `dir'. When a switch `-d' is + specified, the current working directory will not be searched for + source files, unless it is explictly specified with a `-d' or `-D' + switch. Several switches `-d' may be specified. If `dir' is a + relative path, it is relative to the directory of the + configuration pragmas file specified with switch `-c', or to the + directory of the project file specified with switch `-P' or, if + neither switch `-c' nor switch `-P' are specified, it is relative + to the current working directory. The directory specified with + switch `-c' must exist and be readable. + + `-D`file'' + Look for source files in all directories listed in text file + `file'. There may be zero, one or more spaces between `-d' and + `dir'. `file' must be an existing, readable text file. Each non + empty line in `file' must be a directory. Specifying switch `-D' + is equivalent to specifying as many switches `-d' as there are non + empty lines in `file'. + + `-h' + Output usage (help) information. The output is written to `stdout'. + + `-P`proj'' + Create or update project file `proj'. There may be zero, one or + more space between `-P' and `proj'. `proj' may include directory + information. `proj' must be writeable. There may be only one + switch `-P'. When a switch `-P' is specified, no switch `-c' may + be specified. + + `-v' + Verbose mode. Output detailed explanation of behavior to `stdout'. + This includes name of the file written, the name of the + directories to search and, for each file in those directories + whose name matches at least one of the Naming Patterns, an + indication of whether the file contains a unit, and if so the name + of the unit. + + `-v -v' + Very Verbose mode. In addition to the output produced in verbose + mode, for each file in the searched directories whose name matches + none of the Naming Patterns, an indication is given that there is + no match. + + `-x`pattern'' + Excluded patterns. Using this switch, it is possible to exclude + some files that would match the name patterns. For example, + `"gnatname -x "*_nt.ada" "*.ada"' will look for Ada units in all + files with the `.ada' extension, except those whose names end with + `_nt.ada'. + +  + File: gnat_ug_unx.info, Node: Examples of gnatname Usage, Prev: Switches for gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Examples of `gnatname' Usage + ============================ + + $ gnatname -c /home/me/names.adc -d sources "[a-z]*.ada*" + + In this example, the directory `/home/me' must already exist and be + writeable. In addition, the directory `/home/me/sources' (specified by + `-d sources') must exist and be readable. Note the optional spaces after + `-c' and `-d'. + + $ gnatname -P/home/me/proj -x "*_nt_body.ada" -dsources -dsources/plus -Dcommon_dirs.txt "body_*" "spec_*" + + Note that several switches `-d' may be used, even in conjunction + with one or several switches `-D'. Several Naming Patterns and one + excluded pattern are used in this example. + +  + File: gnat_ug_unx.info, Node: GNAT Project Manager, Next: Elaboration Order Handling in GNAT, Prev: Handling Arbitrary File Naming Conventions Using gnatname, Up: Top + + GNAT Project Manager + ******************** + + * Menu: + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + +  + File: gnat_ug_unx.info, Node: Introduction, Next: Examples of Project Files, Up: GNAT Project Manager + + Introduction + ============ + + This chapter describes GNAT's _Project Manager_, a facility that lets + you configure various properties for a collection of source files. In + particular, you can specify: + * The directory or set of directories containing the source files, + and/or the names of the specific source files themselves + + * The directory in which the compiler's output (`ALI' files, object + files, tree files) will be placed + + * The directory in which the executable programs will be placed + + * Switch settings for any of the project-enabled tools (`gnatmake', + compiler, binder, linker, `gnatls', `gnatxref', `gnatfind'); you + can apply these settings either globally or to individual units + + * The source files containing the main subprogram(s) to be built + + * The source programming language(s) (currently Ada and/or C) + + * Source file naming conventions; you can specify these either + globally or for individual units + + * Menu: + + * Project Files:: + +  + File: gnat_ug_unx.info, Node: Project Files, Up: Introduction + + Project Files + ------------- + + A "project" is a specific set of values for these properties. You can + define a project's settings in a "project file", a text file with an + Ada-like syntax; a property value is either a string or a list of + strings. Properties that are not explicitly set receive default + values. A project file may interrogate the values of "external + variables" (user-defined command-line switches or environment + variables), and it may specify property settings conditionally, based + on the value of such variables. + + In simple cases, a project's source files depend only on other + source files in the same project, or on the predefined libraries. + ("Dependence" is in the technical sense; for example, one Ada unit + "with"ing another.) However, the Project Manager also allows much more + sophisticated arrangements, with the source files in one project + depending on source files in other projects: + * One project can _import_ other projects containing needed source + files. + + * You can organize GNAT projects in a hierarchy: a _child_ project + can extend a _parent_ project, inheriting the parent's source + files and optionally overriding any of them with alternative + versions + + More generally, the Project Manager lets you structure large development + efforts into hierarchical subsystems, with build decisions deferred to + the subsystem level and thus different compilation environments (switch + settings) used for different subsystems. + + The Project Manager is invoked through the `-P_projectfile_' switch + to `gnatmake' or to the `gnat' front driver. If you want to define (on + the command line) an external variable that is queried by the project + file, additionally use the `-X_vbl_=_value_' switch. The Project + Manager parses and interprets the project file, and drives the invoked + tool based on the project settings. + + The Project Manager supports a wide range of development strategies, + for systems of all sizes. Some typical practices that are easily + handled: + * Using a common set of source files, but generating object files in + different directories via different switch settings + + * Using a mostly-shared set of source files, but with different + versions of some unit or units + + The destination of an executable can be controlled inside a project file + using the `-o' switch. In the absence of such a switch either inside + the project file or on the command line, any executable files generated + by `gnatmake' will be placed in the directory `Exec_Dir' specified in + the project file. If no `Exec_Dir' is specified, they will be placed in + the object directory of the project. + + You can use project files to achieve some of the effects of a source + versioning system (for example, defining separate projects for the + different sets of sources that comprise different releases) but the + Project Manager is independent of any source configuration management + tools that might be used by the developers. + + The next section introduces the main features of GNAT's project + facility through a sequence of examples; subsequent sections will + present the syntax and semantics in more detail. + +  + File: gnat_ug_unx.info, Node: Examples of Project Files, Next: Project File Syntax, Prev: Introduction, Up: GNAT Project Manager + + Examples of Project Files + ========================= + + This section illustrates some of the typical uses of project files and + explains their basic structure and behavior. + + * Menu: + + * Common Sources with Different Switches and Different Output Directories:: + * Using External Variables:: + * Importing Other Projects:: + * Extending a Project:: + +  + File: gnat_ug_unx.info, Node: Common Sources with Different Switches and Different Output Directories, Next: Using External Variables, Up: Examples of Project Files + + Common Sources with Different Switches and Different Output Directories + ----------------------------------------------------------------------- + + * Menu: + + * Source Files:: + * Specifying the Object Directory:: + * Specifying the Exec Directory:: + * Project File Packages:: + * Specifying Switch Settings:: + * Main Subprograms:: + * Source File Naming Conventions:: + * Source Language(s):: + + Assume that the Ada source files `pack.ads', `pack.adb', and `proc.adb' + are in the `/common' directory. The file `proc.adb' contains an Ada + main subprogram `Proc' that "with"s package `Pack'. We want to compile + these source files under two sets of switches: + * When debugging, we want to pass the `-g' switch to `gnatmake', and + the `-gnata', `-gnato', and `-gnatE' switches to the compiler; the + compiler's output is to appear in `/common/debug' + + * When preparing a release version, we want to pass the `-O2' switch + to the compiler; the compiler's output is to appear in + `/common/release' + + The GNAT project files shown below, respectively `debug.gpr' and + `release.gpr' in the `/common' directory, achieve these effects. + + Diagrammatically: + /common + debug.gpr + release.gpr + pack.ads + pack.adb + proc.adb + /common/debug {-g, -gnata, -gnato, -gnatE} + proc.ali, proc.o + pack.ali, pack.o + /common/release {-O2} + proc.ali, proc.o + pack.ali, pack.o + Here are the project files: + project Debug is + for Object_Dir use "debug"; + for Main use ("proc"); + + package Builder is + for Default_Switches ("Ada") use ("-g"); + end Builder; + + package Compiler is + for Default_Switches ("Ada") + use ("-fstack-check", "-gnata", "-gnato", "-gnatE"); + end Compiler; + end Debug; + + project Release is + for Object_Dir use "release"; + for Exec_Dir use "."; + for Main use ("proc"); + + package Compiler is + for Default_Switches ("Ada") use ("-O2"); + end Compiler; + end Release; + + The name of the project defined by `debug.gpr' is `"Debug"' (case + insensitive), and analogously the project defined by `release.gpr' is + `"Release"'. For consistency the file should have the same name as the + project, and the project file's extension should be `"gpr"'. These + conventions are not required, but a warning is issued if they are not + followed. + + If the current directory is `/temp', then the command + gnatmake -P/common/debug.gpr + + generates object and ALI files in `/common/debug', and the `proc' + executable also in `/common/debug', using the switch settings defined in + the project file. + + Likewise, the command + gnatmake -P/common/release.gpr + + generates object and ALI files in `/common/release', and the `proc' + executable in `/common', using the switch settings from the project + file. + +  + File: gnat_ug_unx.info, Node: Source Files, Next: Specifying the Object Directory, Up: Common Sources with Different Switches and Different Output Directories + + Source Files + ............ + + If a project file does not explicitly specify a set of source + directories or a set of source files, then by default the project's + source files are the Ada source files in the project file directory. + Thus `pack.ads', `pack.adb', and `proc.adb' are the source files for + both projects. + +  + File: gnat_ug_unx.info, Node: Specifying the Object Directory, Next: Specifying the Exec Directory, Prev: Source Files, Up: Common Sources with Different Switches and Different Output Directories + + Specifying the Object Directory + ............................... + + Several project properties are modeled by Ada-style _attributes_; you + define the property by supplying the equivalent of an Ada attribute + definition clause in the project file. A project's object directory is + such a property; the corresponding attribute is `Object_Dir', and its + value is a string expression. A directory may be specified either as + absolute or as relative; in the latter case, it is relative to the + project file directory. Thus the compiler's output is directed to + `/common/debug' (for the `Debug' project) and to `/common/release' (for + the `Release' project). If `Object_Dir' is not specified, then the + default is the project file directory. + +  + File: gnat_ug_unx.info, Node: Specifying the Exec Directory, Next: Project File Packages, Prev: Specifying the Object Directory, Up: Common Sources with Different Switches and Different Output Directories + + Specifying the Exec Directory + ............................. + + A project's exec directory is another property; the corresponding + attribute is `Exec_Dir', and its value is also a string expression, + either specified as relative or absolute. If `Exec_Dir' is not + specified, then the default is the object directory (which may also be + the project file directory if attribute `Object_Dir' is not specified). + Thus the executable is placed in `/common/debug' for the `Debug' + project (attribute `Exec_Dir' not specified) and in `/common' for the + `Release' project. + +  + File: gnat_ug_unx.info, Node: Project File Packages, Next: Specifying Switch Settings, Prev: Specifying the Exec Directory, Up: Common Sources with Different Switches and Different Output Directories + + Project File Packages + ..................... + + A GNAT tool integrated with the Project Manager is modeled by a + corresponding package in the project file. The `Debug' project defines + the packages `Builder' (for `gnatmake') and `Compiler'; the `Release' + project defines only the `Compiler' package. + + The Ada package syntax is not to be taken literally. Although + packages in project files bear a surface resemblance to packages in Ada + source code, the notation is simply a way to convey a grouping of + properties for a named entity. Indeed, the package names permitted in + project files are restricted to a predefined set, corresponding to the + project-aware tools, and the contents of packages are limited to a + small set of constructs. The packages in the example above contain + attribute definitions. + +  + File: gnat_ug_unx.info, Node: Specifying Switch Settings, Next: Main Subprograms, Prev: Project File Packages, Up: Common Sources with Different Switches and Different Output Directories + + Specifying Switch Settings + .......................... + + Switch settings for a project-aware tool can be specified through + attributes in the package corresponding to the tool. The example above + illustrates one of the relevant attributes, `Default_Switches', defined + in the packages in both project files. Unlike simple attributes like + `Source_Dirs', `Default_Switches' is known as an _associative array_. + When you define this attribute, you must supply an "index" (a literal + string), and the effect of the attribute definition is to set the value + of the "array" at the specified "index". For the `Default_Switches' + attribute, the index is a programming language (in our case, Ada) , and + the value specified (after `use') must be a list of string expressions. + + The attributes permitted in project files are restricted to a + predefined set. Some may appear at project level, others in packages. + For any attribute that is an associate array, the index must always be a + literal string, but the restrictions on this string (e.g., a file name + or a language name) depend on the individual attribute. Also depending + on the attribute, its specified value will need to be either a string + or a string list. + + In the `Debug' project, we set the switches for two tools, + `gnatmake' and the compiler, and thus we include corresponding + packages, with each package defining the `Default_Switches' attribute + with index `"Ada"'. Note that the package corresponding to `gnatmake' + is named `Builder'. The `Release' project is similar, but with just + the `Compiler' package. + + In project `Debug' above the switches starting with `-gnat' that are + specified in package `Compiler' could have been placed in package + `Builder', since `gnatmake' transmits all such switches to the compiler. + +  + File: gnat_ug_unx.info, Node: Main Subprograms, Next: Source File Naming Conventions, Prev: Specifying Switch Settings, Up: Common Sources with Different Switches and Different Output Directories + + Main Subprograms + ................ + + One of the properties of a project is its list of main subprograms + (actually a list of names of source files containing main subprograms, + with the file extension optional. This property is captured in the + `Main' attribute, whose value is a list of strings. If a project + defines the `Main' attribute, then you do not need to identify the main + subprogram(s) when invoking `gnatmake' (see *Note gnatmake and Project + Files::). + +  + File: gnat_ug_unx.info, Node: Source File Naming Conventions, Next: Source Language(s), Prev: Main Subprograms, Up: Common Sources with Different Switches and Different Output Directories + + Source File Naming Conventions + .............................. + + Since the project files do not specify any source file naming + conventions, the GNAT defaults are used. The mechanism for defining + source file naming conventions - a package named `Naming' - will be + described below (*note Naming Schemes::). + +  + File: gnat_ug_unx.info, Node: Source Language(s), Prev: Source File Naming Conventions, Up: Common Sources with Different Switches and Different Output Directories + + Source Language(s) + .................. + + Since the project files do not specify a `Languages' attribute, by + default the GNAT tools assume that the language of the project file is + Ada. More generally, a project can comprise source files in Ada, C, + and/or other languages. + +  + File: gnat_ug_unx.info, Node: Using External Variables, Next: Importing Other Projects, Prev: Common Sources with Different Switches and Different Output Directories, Up: Examples of Project Files + + Using External Variables + ------------------------ + + Instead of supplying different project files for debug and release, we + can define a single project file that queries an external variable (set + either on the command line or via an environment variable) in order to + conditionally define the appropriate settings. Again, assume that the + source files `pack.ads', `pack.adb', and `proc.adb' are located in + directory `/common'. The following project file, `build.gpr', queries + the external variable named `STYLE' and defines an object directory and + switch settings based on whether the value is `"deb"' (debug) or + `"rel"' (release), where the default is `"deb"'. + + project Build is + for Main use ("proc"); + + type Style_Type is ("deb", "rel"); + Style : Style_Type := external ("STYLE", "deb"); + + case Style is + when "deb" => + for Object_Dir use "debug"; + + when "rel" => + for Object_Dir use "release"; + for Exec_Dir use "."; + end case; + + package Builder is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-g"); + end case; + + end Builder; + + package Compiler is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-gnata", "-gnato", "-gnatE"); + + when "rel" => + for Default_Switches ("Ada") use ("-O2"); + end case; + + end Compiler; + + end Build; + + `Style_Type' is an example of a _string type_, which is the project + file analog of an Ada enumeration type but containing string literals + rather than identifiers. `Style' is declared as a variable of this + type. + + The form `external("STYLE", "deb")' is known as an _external + reference_; its first argument is the name of an _external variable_, + and the second argument is a default value to be used if the external + variable doesn't exist. You can define an external variable on the + command line via the `-X' switch, or you can use an environment + variable as an external variable. + + Each `case' construct is expanded by the Project Manager based on the + value of `Style'. Thus the command + gnatmake -P/common/build.gpr -XSTYLE=deb + + is equivalent to the `gnatmake' invocation using the project file + `debug.gpr' in the earlier example. So is the command + gnatmake -P/common/build.gpr + + since `"deb"' is the default for `STYLE'. + + Analogously, + gnatmake -P/common/build.gpr -XSTYLE=rel + + is equivalent to the `gnatmake' invocation using the project file + `release.gpr' in the earlier example. + +  + File: gnat_ug_unx.info, Node: Importing Other Projects, Next: Extending a Project, Prev: Using External Variables, Up: Examples of Project Files + + Importing Other Projects + ------------------------ + + A compilation unit in a source file in one project may depend on + compilation units in source files in other projects. To obtain this + behavior, the dependent project must _import_ the projects containing + the needed source files. This effect is embodied in syntax similar to + an Ada `with' clause, but the "with"ed entities are strings denoting + project files. + + As an example, suppose that the two projects `GUI_Proj' and + `Comm_Proj' are defined in the project files `gui_proj.gpr' and + `comm_proj.gpr' in directories `/gui' and `/comm', respectively. + Assume that the source files for `GUI_Proj' are `gui.ads' and + `gui.adb', and that the source files for `Comm_Proj' are `comm.ads' and + `comm.adb', with each set of files located in its respective project + file directory. Diagrammatically: + + /gui + gui_proj.gpr + gui.ads + gui.adb + + /comm + comm_proj.gpr + comm.ads + comm.adb + + We want to develop an application in directory `/app' that "with"s the + packages `GUI' and `Comm', using the properties of the corresponding + project files (e.g. the switch settings and object directory). + Skeletal code for a main procedure might be something like the + following: + + with GUI, Comm; + procedure App_Main is + ... + begin + ... + end App_Main; + + Here is a project file, `app_proj.gpr', that achieves the desired + effect: + + with "/gui/gui_proj", "/comm/comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + + Building an executable is achieved through the command: + gnatmake -P/app/app_proj + + which will generate the `app_main' executable in the directory where + `app_proj.gpr' resides. + + If an imported project file uses the standard extension (`gpr') then + (as illustrated above) the `with' clause can omit the extension. + + Our example specified an absolute path for each imported project + file. Alternatively, you can omit the directory if either + * The imported project file is in the same directory as the + importing project file, or + + * You have defined an environment variable `ADA_PROJECT_PATH' that + includes the directory containing the needed project file. + + Thus, if we define `ADA_PROJECT_PATH' to include `/gui' and `/comm', + then our project file `app_proj.gpr' could be written as follows: + + with "gui_proj", "comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + + Importing other projects raises the possibility of ambiguities. For + example, the same unit might be present in different imported projects, + or it might be present in both the importing project and an imported + project. Both of these conditions are errors. Note that in the + current version of the Project Manager, it is illegal to have an + ambiguous unit even if the unit is never referenced by the importing + project. This restriction may be relaxed in a future release. + +  + File: gnat_ug_unx.info, Node: Extending a Project, Prev: Importing Other Projects, Up: Examples of Project Files + + Extending a Project + ------------------- + + A common situation in large software systems is to have multiple + implementations for a common interface; in Ada terms, multiple versions + of a package body for the same specification. For example, one + implementation might be safe for use in tasking programs, while another + might only be used in sequential applications. This can be modeled in + GNAT using the concept of _project extension_. If one project (the + "child") _extends_ another project (the "parent") then by default all + source files of the parent project are inherited by the child, but the + child project can override any of the parent's source files with new + versions, and can also add new files. This facility is the project + analog of extension in Object-Oriented Programming. Project + hierarchies are permitted (a child project may be the parent of yet + another project), and a project that inherits one project can also + import other projects. + + As an example, suppose that directory `/seq' contains the project + file `seq_proj.gpr' and the source files `pack.ads', `pack.adb', and + `proc.adb': + + /seq + pack.ads + pack.adb + proc.adb + seq_proj.gpr + + Note that the project file can simply be empty (that is, no attribute or + package is defined): + + project Seq_Proj is + end Seq_Proj; + + implying that its source files are all the Ada source files in the + project directory. + + Suppose we want to supply an alternate version of `pack.adb', in + directory `/tasking', but use the existing versions of `pack.ads' and + `proc.adb'. We can define a project `Tasking_Proj' that inherits + `Seq_Proj': + + /tasking + pack.adb + tasking_proj.gpr + + project Tasking_Proj extends "/seq/seq_proj" is + end Tasking_Proj; + + The version of `pack.adb' used in a build depends on which project file + is specified. + + Note that we could have designed this using project import rather + than project inheritance; a `base' project would contain the sources for + `pack.ads' and `proc.adb', a sequential project would import `base' and + add `pack.adb', and likewise a tasking project would import `base' and + add a different version of `pack.adb'. The choice depends on whether + other sources in the original project need to be overridden. If they + do, then project extension is necessary, otherwise, importing is + sufficient. + +  + File: gnat_ug_unx.info, Node: Project File Syntax, Next: Objects and Sources in Project Files, Prev: Examples of Project Files, Up: GNAT Project Manager + + Project File Syntax + =================== + + * Menu: + + * Basic Syntax:: + * Packages:: + * Expressions:: + * String Types:: + * Variables:: + * Attributes:: + * Associative Array Attributes:: + * case Constructions:: + + This section describes the structure of project files. + + A project may be an _independent project_, entirely defined by a + single project file. Any Ada source file in an independent project + depends only on the predefined library and other Ada source files in + the same project. + + A project may also "depend on" other projects, in either or both of the + following ways: + * It may import any number of projects + + * It may extend at most one other project + + The dependence relation is a directed acyclic graph (the subgraph + reflecting the "extends" relation is a tree). + + A project's "immediate sources" are the source files directly + defined by that project, either implicitly by residing in the project + file's directory, or explicitly through any of the source-related + attributes described below. More generally, a project PROJ's "sources" + are the immediate sources of PROJ together with the immediate sources + (unless overridden) of any project on which PROJ depends (either + directly or indirectly). + +  + File: gnat_ug_unx.info, Node: Basic Syntax, Next: Packages, Up: Project File Syntax + + Basic Syntax + ------------ + + As seen in the earlier examples, project files have an Ada-like syntax. + The minimal project file is: + project Empty is + + end Empty; + + The identifier `Empty' is the name of the project. This project name + must be present after the reserved word `end' at the end of the project + file, followed by a semi-colon. + + Any name in a project file, such as the project name or a variable + name, has the same syntax as an Ada identifier. + + The reserved words of project files are the Ada reserved words plus + `extends', `external', and `project'. Note that the only Ada reserved + words currently used in project file syntax are: + + * `case' + + * `end' + + * `for' + + * `is' + + * `others' + + * `package' + + * `renames' + + * `type' + + * `use' + + * `when' + + * `with' + + Comments in project files have the same syntax as in Ada, two + consecutives hyphens through the end of the line. + +  + File: gnat_ug_unx.info, Node: Packages, Next: Expressions, Prev: Basic Syntax, Up: Project File Syntax + + Packages + -------- + + A project file may contain _packages_. The name of a package must be one + of the identifiers (case insensitive) from a predefined list, and a + package with a given name may only appear once in a project file. The + predefined list includes the following packages: + + * `Naming' + + * `Builder' + + * `Compiler' + + * `Binder' + + * `Linker' + + * `Finder' + + * `Cross_Reference' + + * `gnatls' + + (The complete list of the package names and their attributes can be + found in file `prj-attr.adb'). + + In its simplest form, a package may be empty: + + project Simple is + package Builder is + end Builder; + end Simple; + + A package may contain _attribute declarations_, _variable declarations_ + and _case constructions_, as will be described below. + + When there is ambiguity between a project name and a package name, + the name always designates the project. To avoid possible confusion, it + is always a good idea to avoid naming a project with one of the names + allowed for packages or any name that starts with `gnat'. + +  + File: gnat_ug_unx.info, Node: Expressions, Next: String Types, Prev: Packages, Up: Project File Syntax + + Expressions + ----------- + + An _expression_ is either a _string expression_ or a _string list + expression_. + + A _string expression_ is either a _simple string expression_ or a + _compound string expression_. + + A _simple string expression_ is one of the following: + * A literal string; e.g.`"comm/my_proj.gpr"' + + * A string-valued variable reference (see *Note Variables::) + + * A string-valued attribute reference (see *Note Attributes::) + + * An external reference (see *Note External References in Project + Files::) + + A _compound string expression_ is a concatenation of string expressions, + using `"&"' + Path & "/" & File_Name & ".ads" + + A _string list expression_ is either a _simple string list expression_ + or a _compound string list expression_. + + A _simple string list expression_ is one of the following: + * A parenthesized list of zero or more string expressions, separated + by commas + File_Names := (File_Name, "gnat.adc", File_Name & ".orig"); + Empty_List := (); + + * A string list-valued variable reference + + * A string list-valued attribute reference + + A _compound string list expression_ is the concatenation (using `"&"') + of a simple string list expression and an expression. Note that each + term in a compound string list expression, except the first, may be + either a string expression or a string list expression. + + File_Name_List := () & File_Name; -- One string in this list + Extended_File_Name_List := File_Name_List & (File_Name & ".orig"); + -- Two strings + Big_List := File_Name_List & Extended_File_Name_List; + -- Concatenation of two string lists: three strings + Illegal_List := "gnat.adc" & Extended_File_Name_List; + -- Illegal: must start with a string list + +  + File: gnat_ug_unx.info, Node: String Types, Next: Variables, Prev: Expressions, Up: Project File Syntax + + String Types + ------------ + + The value of a variable may be restricted to a list of string literals. + The restricted list of string literals is given in a _string type + declaration_. + + Here is an example of a string type declaration: + + type OS is ("NT, "nt", "Unix", "Linux", "other OS"); + + Variables of a string type are called _typed variables_; all other + variables are called _untyped variables_. Typed variables are + particularly useful in `case' constructions (see *Note case + Constructions::). + + A string type declaration starts with the reserved word `type', + followed by the name of the string type (case-insensitive), followed by + the reserved word `is', followed by a parenthesized list of one or more + string literals separated by commas, followed by a semicolon. + + The string literals in the list are case sensitive and must all be + different. They may include any graphic characters allowed in Ada, + including spaces. + + A string type may only be declared at the project level, not inside + a package. + + A string type may be referenced by its name if it has been declared + in the same project file, or by its project name, followed by a dot, + followed by the string type name. + +  + File: gnat_ug_unx.info, Node: Variables, Next: Attributes, Prev: String Types, Up: Project File Syntax + + Variables + --------- + + A variable may be declared at the project file level, or in a package. + Here are some examples of variable declarations: + + This_OS : OS := external ("OS"); -- a typed variable declaration + That_OS := "Linux"; -- an untyped variable declaration + + A _typed variable declaration_ includes the variable name, followed by + a colon, followed by the name of a string type, followed by `:=', + followed by a simple string expression. + + An _untyped variable declaration_ includes the variable name, + followed by `:=', followed by an expression. Note that, despite the + terminology, this form of "declaration" resembles more an assignment + than a declaration in Ada. It is a declaration in several senses: + * The variable name does not need to be defined previously + + * The declaration establishes the _kind_ (string versus string list) + of the variable, and later declarations of the same variable need + to be consistent with this + + A string variable declaration (typed or untyped) declares a variable + whose value is a string. This variable may be used as a string + expression. + File_Name := "readme.txt"; + Saved_File_Name := File_Name & ".saved"; + + A string list variable declaration declares a variable whose value is a + list of strings. The list may contain any number (zero or more) of + strings. + + Empty_List := (); + List_With_One_Element := ("-gnaty"); + List_With_Two_Elements := List_With_One_Element & "-gnatg"; + Long_List := ("main.ada", "pack1_.ada", "pack1.ada", "pack2_.ada" + "pack2.ada", "util_.ada", "util.ada"); + + The same typed variable may not be declared more than once at project + level, and it may not be declared more than once in any package; it is + in effect a constant or a readonly variable. + + The same untyped variable may be declared several times. In this + case, the new value replaces the old one, and any subsequent reference + to the variable uses the new value. However, as noted above, if a + variable has been declared as a string, all subsequent declarations + must give it a string value. Similarly, if a variable has been declared + as a string list, all subsequent declarations must give it a string + list value. + + A _variable reference_ may take several forms: + + * The simple variable name, for a variable in the current package + (if any) or in the current project + + * A context name, followed by a dot, followed by the variable name. + + A _context_ may be one of the following: + + * The name of an existing package in the current project + + * The name of an imported project of the current project + + * The name of an ancestor project (i.e., a project extended by the + current project, either directly or indirectly) + + * An imported/parent project name, followed by a dot, followed by a + package name + + A variable reference may be used in an expression. + +  + File: gnat_ug_unx.info, Node: Attributes, Next: Associative Array Attributes, Prev: Variables, Up: Project File Syntax + + Attributes + ---------- + + A project (and its packages) may have _attributes_ that define the + project's properties. Some attributes have values that are strings; + others have values that are string lists. + + There are two categories of attributes: _simple attributes_ and + _associative arrays_ (see *Note Associative Array Attributes::). + + The names of the attributes are restricted; there is a list of + project attributes, and a list of package attributes for each package. + The names are not case sensitive. + + The project attributes are as follows (all are simple attributes): + + _Attribute Name_ _Value_ + `Source_Files' string list + `Source_Dirs' string list + `Source_List_File' string + `Object_Dir' string + `Exec_Dir' string + `Main' string list + `Languages' string list + `Library_Dir' string + `Library_Name' string + `Library_Kind' string + `Library_Elaboration' string + `Library_Version' string + + The attributes for package `Naming' are as follows (see *Note Naming + Schemes::): + + Attribute Name Category Index Value + `Specification_Suffix' associative language name string + array + `Implementation_Suffix' associative language name string + array + `Separate_Suffix' simple n/a string + attribute + `Casing' simple n/a string + attribute + `Dot_Replacement' simple n/a string + attribute + `Specification' associative Ada unit name string + array + `Implementation' associative Ada unit name string + array + `Specification_Exceptions' associative language name string list + array + `Implementation_Exceptions' associative language name string list + array + + The attributes for package `Builder', `Compiler', `Binder', `Linker', + `Cross_Reference', and `Finder' are as follows (see *Note Switches and + Project Files::). + + Attribute Name Category Index Value + `Default_Switches' associative language name string list + array + `Switches' associative file name string list + array + + In addition, package `Builder' has a single string attribute + `Local_Configuration_Pragmas' and package `Builder' has a single string + attribute `Global_Configuration_Pragmas'. + + The attribute for package `Glide' are not documented: they are for + internal use only. + + Each simple attribute has a default value: the empty string (for + string-valued attributes) and the empty list (for string list-valued + attributes). + + Similar to variable declarations, an attribute declaration defines a + new value for an attribute. + + Examples of simple attribute declarations: + + for Object_Dir use "objects"; + for Source_Dirs use ("units", "test/drivers"); + + A "simple attribute declaration" starts with the reserved word `for', + followed by the name of the attribute, followed by the reserved word + `use', followed by an expression (whose kind depends on the attribute), + followed by a semicolon. + + Attributes may be referenced in expressions. The general form for + such a reference is `'': the entity for which the + attribute is defined, followed by an apostrophe, followed by the name + of the attribute. For associative array attributes, a litteral string + between parentheses need to be supplied as index. + + Examples are: + + project'Object_Dir + Naming'Dot_Replacement + Imported_Project'Source_Dirs + Imported_Project.Naming'Casing + Builder'Default_Switches("Ada") + + The entity may be: + * `project' for an attribute of the current project + + * The name of an existing package of the current project + + * The name of an imported project + + * The name of a parent project (extended by the current project) + + * An imported/parent project name, followed by a dot, followed + by a package name + + Example: + project Prj is + for Source_Dirs use project'Source_Dirs & "units"; + for Source_Dirs use project'Source_Dirs & "test/drivers" + end Prj; + + In the first attribute declaration, initially the attribute + `Source_Dirs' has the default value: an empty string list. After this + declaration, `Source_Dirs' is a string list of one element: "units". + After the second attribute declaration `Source_Dirs' is a string list of + two elements: "units" and "test/drivers". + + Note: this example is for illustration only. In practice, the + project file would contain only one attribute declaration: + + for Source_Dirs use ("units", "test/drivers"); + +  + File: gnat_ug_unx.info, Node: Associative Array Attributes, Next: case Constructions, Prev: Attributes, Up: Project File Syntax + + Associative Array Attributes + ---------------------------- + + Some attributes are defined as _associative arrays_. An associative + array may be regarded as a function that takes a string as a parameter + and delivers a string or string list value as its result. + + Here are some examples of associative array attribute declarations: + + for Implementation ("main") use "Main.ada"; + for Switches ("main.ada") use ("-v", "-gnatv"); + for Switches ("main.ada") use Builder'Switches ("main.ada") & "-g"; + + Like untyped variables and simple attributes, associative array + attributes may be declared several times. Each declaration supplies a + new value for the attribute, replacing the previous setting. + +  + File: gnat_ug_unx.info, Node: case Constructions, Prev: Associative Array Attributes, Up: Project File Syntax + + `case' Constructions + -------------------- + + A `case' construction is used in a project file to effect conditional + behavior. Here is a typical example: + + project MyProj is + type OS_Type is ("Linux", "Unix", "NT", "VMS"); + + OS : OS_Type := external ("OS", "Linux"); + + package Compiler is + case OS is + when "Linux" | "Unix" => + for Default_Switches ("Ada") use ("-gnath"); + when "NT" => + for Default_Switches ("Ada") use ("-gnatP"); + when others => + end case; + end Compiler; + end MyProj; + + The syntax of a `case' construction is based on the Ada case statement + (although there is no `null' construction for empty alternatives). + + Following the reserved word `case' there is the case variable (a + typed string variable), the reserved word `is', and then a sequence of + one or more alternatives. Each alternative comprises the reserved word + `when', either a list of literal strings separated by the `"|"' + character or the reserved word `others', and the `"=>"' token. Each + literal string must belong to the string type that is the type of the + case variable. An `others' alternative, if present, must occur last. + The `end case;' sequence terminates the case construction. + + After each `=>', there are zero or more constructions. The only + constructions allowed in a case construction are other case + constructions and attribute declarations. String type declarations, + variable declarations and package declarations are not allowed. + + The value of the case variable is often given by an external + reference (see *Note External References in Project Files::). + +  + File: gnat_ug_unx.info, Node: Objects and Sources in Project Files, Next: Importing Projects, Prev: Project File Syntax, Up: GNAT Project Manager + + Objects and Sources in Project Files + ==================================== + + * Menu: + + * Object Directory:: + * Exec Directory:: + * Source Directories:: + * Source File Names:: + + Each project has exactly one object directory and one or more source + directories. The source directories must contain at least one source + file, unless the project file explicitly specifies that no source + files are present (see *Note Source File Names::). + +  + File: gnat_ug_unx.info, Node: Object Directory, Next: Exec Directory, Up: Objects and Sources in Project Files + + Object Directory + ---------------- + + The object directory for a project is the directory containing the + compiler's output (such as `ALI' files and object files) for the + project's immediate sources. Note that for inherited sources (when + extending a parent project) the parent project's object directory is + used. + + The object directory is given by the value of the attribute + `Object_Dir' in the project file. + + for Object_Dir use "objects"; + + The attribute OBJECT_DIR has a string value, the path name of the object + directory. The path name may be absolute or relative to the directory + of the project file. This directory must already exist, and be readable + and writable. + + By default, when the attribute `Object_Dir' is not given an explicit + value or when its value is the empty string, the object directory is + the same as the directory containing the project file. + +  + File: gnat_ug_unx.info, Node: Exec Directory, Next: Source Directories, Prev: Object Directory, Up: Objects and Sources in Project Files + + Exec Directory + -------------- + + The exec directory for a project is the directory containing the + executables for the project's main subprograms. + + The exec directory is given by the value of the attribute `Exec_Dir' + in the project file. + + for Exec_Dir use "executables"; + + The attribute EXEC_DIR has a string value, the path name of the exec + directory. The path name may be absolute or relative to the directory + of the project file. This directory must already exist, and be writable. + + By default, when the attribute `Exec_Dir' is not given an explicit + value or when its value is the empty string, the exec directory is the + same as the object directory of the project file. + +  + File: gnat_ug_unx.info, Node: Source Directories, Next: Source File Names, Prev: Exec Directory, Up: Objects and Sources in Project Files + + Source Directories + ------------------ + + The source directories of a project are specified by the project file + attribute `Source_Dirs'. + + This attribute's value is a string list. If the attribute is not + given an explicit value, then there is only one source directory, the + one where the project file resides. + + A `Source_Dirs' attribute that is explicitly defined to be the empty + list, as in + + for Source_Dirs use (); + + indicates that the project contains no source files. + + Otherwise, each string in the string list designates one or more + source directories. + + for Source_Dirs use ("sources", "test/drivers"); + + If a string in the list ends with `"/**"', then the directory whose + path name precedes the two asterisks, as well as all its subdirectories + (recursively), are source directories. + + for Source_Dirs use ("/system/sources/**"); + + Here the directory `/system/sources' and all of its subdirectories + (recursively) are source directories. + + To specify that the source directories are the directory of the + project file and all of its subdirectories, you can declare + `Source_Dirs' as follows: + for Source_Dirs use ("./**"); + + Each of the source directories must exist and be readable. + +  + File: gnat_ug_unx.info, Node: Source File Names, Prev: Source Directories, Up: Objects and Sources in Project Files + + Source File Names + ----------------- + + In a project that contains source files, their names may be specified + by the attributes `Source_Files' (a string list) or `Source_List_File' + (a string). Source file names never include any directory information. + + If the attribute `Source_Files' is given an explicit value, then each + element of the list is a source file name. + + for Source_Files use ("main.adb"); + for Source_Files use ("main.adb", "pack1.ads", "pack2.adb"); + + If the attribute `Source_Files' is not given an explicit value, but the + attribute `Source_List_File' is given a string value, then the source + file names are contained in the text file whose path name (absolute or + relative to the directory of the project file) is the value of the + attribute `Source_List_File'. + + Each line in the file that is not empty or is not a comment contains + a source file name. A comment line starts with two hyphens. + + for Source_List_File use "source_list.txt"; + + By default, if neither the attribute `Source_Files' nor the attribute + `Source_List_File' is given an explicit value, then each file in the + source directories that conforms to the project's naming scheme (see + *Note Naming Schemes::) is an immediate source of the project. + + A warning is issued if both attributes `Source_Files' and + `Source_List_File' are given explicit values. In this case, the + attribute `Source_Files' prevails. + + Each source file name must be the name of one and only one existing + source file in one of the source directories. + + A `Source_Files' attribute defined with an empty list as its value + indicates that there are no source files in the project. + + Except for projects that are clearly specified as containing no Ada + source files (`Source_Dirs' or `Source_Files' specified as an empty + list, or `Languages' specified without `"Ada"' in the list) + for Source_Dirs use (); + for Source_Files use (); + for Languages use ("C", "C++"); + + a project must contain at least one immediate source. + + Projects with no source files are useful as template packages (see + *Note Packages in Project Files::) for other projects; in particular to + define a package `Naming' (see *Note Naming Schemes::). + +  + File: gnat_ug_unx.info, Node: Importing Projects, Next: Project Extension, Prev: Objects and Sources in Project Files, Up: GNAT Project Manager + + Importing Projects + ================== + + An immediate source of a project P may depend on source files that are + neither immediate sources of P nor in the predefined library. To get + this effect, P must _import_ the projects that contain the needed + source files. + + with "project1", "utilities.gpr"; + with "/namings/apex.gpr"; + project Main is + ... + + As can be seen in this example, the syntax for importing projects is + similar to the syntax for importing compilation units in Ada. However, + project files use literal strings instead of names, and the `with' + clause identifies project files rather than packages. + + Each literal string is the file name or path name (absolute or + relative) of a project file. If a string is simply a file name, with no + path, then its location is determined by the _project path_: + + * If the environment variable `ADA_PROJECT_PATH' exists, then the + project path includes all the directories in this environment + variable, plus the directory of the project file. + + * If the environment variable `ADA_PROJECT_PATH' does not exist, + then the project path contains only one directory, namely the one + where the project file is located. + + If a relative pathname is used as in + + with "tests/proj"; + + then the path is relative to the directory where the importing project + file is located. Any symbolic link will be fully resolved in the + directory of the importing project file before the imported project + file is looked up. + + When the `with''ed project file name does not have an extension, the + default is `.gpr'. If a file with this extension is not found, then the + file name as specified in the `with' clause (no extension) will be + used. In the above example, if a file `project1.gpr' is found, then it + will be used; otherwise, if a file `project1' exists then it will be + used; if neither file exists, this is an error. + + A warning is issued if the name of the project file does not match + the name of the project; this check is case insensitive. + + Any source file that is an immediate source of the imported project + can be used by the immediate sources of the importing project, and + recursively. Thus if `A' imports `B', and `B' imports `C', the immediate + sources of `A' may depend on the immediate sources of `C', even if `A' + does not import `C' explicitly. However, this is not recommended, + because if and when `B' ceases to import `C', some sources in `A' will + no longer compile. + + A side effect of this capability is that cyclic dependences are not + permitted: if `A' imports `B' (directly or indirectly) then `B' is not + allowed to import `A'. + +  + File: gnat_ug_unx.info, Node: Project Extension, Next: External References in Project Files, Prev: Importing Projects, Up: GNAT Project Manager + + Project Extension + ================= + + During development of a large system, it is sometimes necessary to use + modified versions of some of the source files without changing the + original sources. This can be achieved through a facility known as + _project extension_. + + project Modified_Utilities extends "/baseline/utilities.gpr" is ... + + The project file for the project being extended (the _parent_) is + identified by the literal string that follows the reserved word + `extends', which itself follows the name of the extending project (the + _child_). + + By default, a child project inherits all the sources of its parent. + However, inherited sources can be overridden: a unit with the same name + as one in the parent will hide the original unit. Inherited sources + are considered to be sources (but not immediate sources) of the child + project; see *Note Project File Syntax::. + + An inherited source file retains any switches specified in the + parent project. + + For example if the project `Utilities' contains the specification + and the body of an Ada package `Util_IO', then the project + `Modified_Utilities' can contain a new body for package `Util_IO'. The + original body of `Util_IO' will not be considered in program builds. + However, the package specification will still be found in the project + `Utilities'. + + A child project can have only one parent but it may import any + number of other projects. + + A project is not allowed to import directly or indirectly at the + same time a child project and any of its ancestors. + +  + File: gnat_ug_unx.info, Node: External References in Project Files, Next: Packages in Project Files, Prev: Project Extension, Up: GNAT Project Manager + + External References in Project Files + ==================================== + + A project file may contain references to external variables; such + references are called _external references_. + + An external variable is either defined as part of the environment (an + environment variable in Unix, for example) or else specified on the + command line via the `-X_vbl_=_value_' switch. If both, then the + command line value is used. + + An external reference is denoted by the built-in function + `external', which returns a string value. This function has two forms: + * `external (external_variable_name)' + + * `external (external_variable_name, default_value)' + + Each parameter must be a string literal. For example: + + external ("USER") + external ("OS", "Linux") + + In the form with one parameter, the function returns the value of the + external variable given as parameter. If this name is not present in the + environment, then the returned value is an empty string. + + In the form with two string parameters, the second parameter is the + value returned when the variable given as the first parameter is not + present in the environment. In the example above, if `"OS"' is not the + name of an environment variable and is not passed on the command line, + then the returned value will be `"Linux"'. + + An external reference may be part of a string expression or of a + string list expression, to define variables or attributes. + + type Mode_Type is ("Debug", "Release"); + Mode : Mode_Type := external ("MODE"); + case Mode is + when "Debug" => + ... + +  + File: gnat_ug_unx.info, Node: Packages in Project Files, Next: Variables from Imported Projects, Prev: External References in Project Files, Up: GNAT Project Manager + + Packages in Project Files + ========================= + + The _package_ is the project file feature that defines the settings for + project-aware tools. For each such tool you can declare a + corresponding package; the names for these packages are preset (see + *Note Packages::) but are not case sensitive. A package may contain + variable declarations, attribute declarations, and case constructions. + + project Proj is + package Builder is -- used by gnatmake + for Default_Switches ("Ada") use ("-v", "-g"); + end Builder; + end Proj; + + A package declaration starts with the reserved word `package', followed + by the package name (case insensitive), followed by the reserved word + `is'. It ends with the reserved word `end', followed by the package + name, finally followed by a semi-colon. + + Most of the packages have an attribute `Default_Switches'. This + attribute is an associative array, and its value is a string list. The + index of the associative array is the name of a programming language + (case insensitive). This attribute indicates the switch or switches to + be used with the corresponding tool. + + Some packages also have another attribute, `Switches', an associative + array whose value is a string list. The index is the name of a source + file. This attribute indicates the switch or switches to be used by + the corresponding tool when dealing with this specific file. + + Further information on these switch-related attributes is found in + *Note Switches and Project Files::. + + A package may be declared as a _renaming_ of another package; e.g., + from the project file for an imported project. + + with "/global/apex.gpr"; + project Example is + package Naming renames Apex.Naming; + ... + end Example; + + Packages that are renamed in other project files often come from + project files that have no sources: they are just used as templates. + Any modification in the template will be reflected automatically in all + the project files that rename a package from the template. + + In addition to the tool-oriented packages, you can also declare a + package named `Naming' to establish specialized source file naming + conventions (see *Note Naming Schemes::). + +  + File: gnat_ug_unx.info, Node: Variables from Imported Projects, Next: Naming Schemes, Prev: Packages in Project Files, Up: GNAT Project Manager + + Variables from Imported Projects + ================================ + + An attribute or variable defined in an imported or parent project can + be used in expressions in the importing / extending project. Such an + attribute or variable is prefixed with the name of the project and (if + relevant) the name of package where it is defined. + + with "imported"; + project Main extends "base" is + Var1 := Imported.Var; + Var2 := Base.Var & ".new"; + + package Builder is + for Default_Switches ("Ada") use Imported.Builder.Ada_Switches & + "-gnatg" & "-v"; + end Builder; + + package Compiler is + for Default_Switches ("Ada") use Base.Compiler.Ada_Switches; + end Compiler; + end Main; + + In this example: + + * `Var1' is a copy of the variable `Var' defined in the project file + `"imported.gpr"' + + * the value of `Var2' is a copy of the value of variable `Var' + defined in the project file `base.gpr', concatenated with `".new"' + + * attribute `Default_Switches ("Ada")' in package `Builder' is a + string list that includes in its value a copy of variable + `Ada_Switches' defined in the `Builder' package in project file + `imported.gpr' plus two new elements: `"-gnatg"' and `"-v"'; + + * attribute `Default_Switches ("Ada")' in package `Compiler' is a + copy of the variable `Ada_Switches' defined in the `Compiler' + package in project file `base.gpr', the project being extended. + +  + File: gnat_ug_unx.info, Node: Naming Schemes, Next: Library Projects, Prev: Variables from Imported Projects, Up: GNAT Project Manager + + Naming Schemes + ============== + + Sometimes an Ada software system is ported from a foreign compilation + environment to GNAT, with file names that do not use the default GNAT + conventions. Instead of changing all the file names (which for a + variety of reasons might not be possible), you can define the relevant + file naming scheme in the `Naming' package in your project file. For + example, the following package models the Apex file naming rules: + + package Naming is + for Casing use "lowercase"; + for Dot_Replacement use "."; + for Specification_Suffix ("Ada") use ".1.ada"; + for Implementation_Suffix ("Ada") use ".2.ada"; + end Naming; + + You can define the following attributes in package `Naming': + + `CASING' + This must be a string with one of the three values `"lowercase"', + `"uppercase"' or `"mixedcase"'; these strings are case insensitive. + + If CASING is not specified, then the default is `"lowercase"'. + + `DOT_REPLACEMENT' + This must be a string whose value satisfies the following + conditions: + + * It must not be empty + + * It cannot start or end with an alphanumeric character + + * It cannot be a single underscore + + * It cannot start with an underscore followed by an alphanumeric + + * It cannot contain a dot `'.'' except if it the entire string + is `"."' + + If `Dot_Replacement' is not specified, then the default is `"-"'. + + `SPECIFICATION_SUFFIX' + This is an associative array (indexed by the programming language + name, case insensitive) whose value is a string that must satisfy + the following conditions: + + * It must not be empty + + * It cannot start with an alphanumeric character + + * It cannot start with an underscore followed by an + alphanumeric character + + If `Specification_Suffix ("Ada")' is not specified, then the + default is `".ads"'. + + `IMPLEMENTATION_SUFFIX' + This is an associative array (indexed by the programming language + name, case insensitive) whose value is a string that must satisfy + the following conditions: + + * It must not be empty + + * It cannot start with an alphanumeric character + + * It cannot start with an underscore followed by an + alphanumeric character + + * It cannot be a suffix of `Specification_Suffix' + + If `Implementation_Suffix ("Ada")' is not specified, then the + default is `".adb"'. + + `SEPARATE_SUFFIX' + This must be a string whose value satisfies the same conditions as + `Implementation_Suffix'. + + If `Separate_Suffix ("Ada")' is not specified, then it defaults to + same value as `Implementation_Suffix ("Ada")'. + + `SPECIFICATION' + You can use the `Specification' attribute, an associative array, + to define the source file name for an individual Ada compilation + unit's spec. The array index must be a string literal that + identifies the Ada unit (case insensitive). The value of this + attribute must be a string that identifies the file that contains + this unit's spec (case sensitive or insensitive depending on the + operating system). + + for Specification ("MyPack.MyChild") use "mypack.mychild.spec"; + + `IMPLEMENTATION' + You can use the `Implementation' attribute, an associative array, + to define the source file name for an individual Ada compilation + unit's body (possibly a subunit). The array index must be a + string literal that identifies the Ada unit (case insensitive). + The value of this attribute must be a string that identifies the + file that contains this unit's body or subunit (case sensitive or + insensitive depending on the operating system). + + for Implementation ("MyPack.MyChild") use "mypack.mychild.body"; + +  + File: gnat_ug_unx.info, Node: Library Projects, Next: Switches Related to Project Files, Prev: Naming Schemes, Up: GNAT Project Manager + + Library Projects + ================ + + _Library projects_ are projects whose object code is placed in a + library. (Note that this facility is not yet supported on all + platforms) + + To create a library project, you need to define in its project file + two project-level attributes: `Library_Name' and `Library_Dir'. + Additionally, you may define the library-related attributes + `Library_Kind', `Library_Version' and `Library_Elaboration'. + + The `Library_Name' attribute has a string value that must start with + a letter and include only letters and digits. + + The `Library_Dir' attribute has a string value that designates the + path (absolute or relative) of the directory where the library will + reside. It must designate an existing directory, and this directory + needs to be different from the project's object directory. It also + needs to be writable. + + If both `Library_Name' and `Library_Dir' are specified and are + legal, then the project file defines a library project. The optional + library-related attributes are checked only for such project files. + + The `Library_Kind' attribute has a string value that must be one of + the following (case insensitive): `"static"', `"dynamic"' or + `"relocatable"'. If this attribute is not specified, the library is a + static library. Otherwise, the library may be dynamic or relocatable. + Depending on the operating system, there may or may not be a distinction + between dynamic and relocatable libraries. For example, on Unix there + is no such distinction. + + The `Library_Version' attribute has a string value whose + interpretation is platform dependent. On Unix, it is used only for + dynamic/relocatable libraries as the internal name of the library (the + `"soname"'). If the library file name (built from the `Library_Name') + is different from the `Library_Version', then the library file will be + a symbolic link to the actual file whose name will be `Library_Version'. + + Example (on Unix): + + project Plib is + + Version := "1"; + + for Library_Dir use "lib_dir"; + for Library_Name use "dummy"; + for Library_Kind use "relocatable"; + for Library_Version use "libdummy.so." & Version; + + end Plib; + + Directory `lib_dir' will contain the internal library file whose name + will be `libdummy.so.1', and `libdummy.so' will be a symbolic link to + `libdummy.so.1'. + + When `gnatmake' detects that a project file (not the main project + file) is a library project file, it will check all immediate sources of + the project and rebuild the library if any of the sources have been + recompiled. All `ALI' files will also be copied from the object + directory to the library directory. To build executables, `gnatmake' + will use the library rather than the individual object files. + +  + File: gnat_ug_unx.info, Node: Switches Related to Project Files, Next: Tools Supporting Project Files, Prev: Library Projects, Up: GNAT Project Manager + + Switches Related to Project Files + ================================= + + The following switches are used by GNAT tools that support project + files: + + ``-PPROJECT'' + Indicates the name of a project file. This project file will be + parsed with the verbosity indicated by `-vP_x_', if any, and using + the external references indicated by `-X' switches, if any. + + There must be only one `-P' switch on the command line. + + Since the Project Manager parses the project file only after all + the switches on the command line are checked, the order of the + switches `-P', `-Vp_x_' or `-X' is not significant. + + ``-XNAME=VALUE'' + Indicates that external variable NAME has the value VALUE. The + Project Manager will use this value for occurrences of + `external(name)' when parsing the project file. + + If NAME or VALUE includes a space, then NAME=VALUE should be put + between quotes. + -XOS=NT + -X"user=John Doe" + + Several `-X' switches can be used simultaneously. If several `-X' + switches specify the same NAME, only the last one is used. + + An external variable specified with a `-X' switch takes precedence + over the value of the same name in the environment. + + ``-vP_x_'' + Indicates the verbosity of the parsing of GNAT project files. + `-vP0' means Default (no output for syntactically correct project + files); `-vP1' means Medium; `-vP2' means High. + + The default is Default. + + If several `-vP_x_' switches are present, only the last one is + used. + +  + File: gnat_ug_unx.info, Node: Tools Supporting Project Files, Next: An Extended Example, Prev: Switches Related to Project Files, Up: GNAT Project Manager + + Tools Supporting Project Files + ============================== + + * Menu: + + * gnatmake and Project Files:: + * The GNAT Driver and Project Files:: + * Glide and Project Files:: + +  + File: gnat_ug_unx.info, Node: gnatmake and Project Files, Next: The GNAT Driver and Project Files, Up: Tools Supporting Project Files + + gnatmake and Project Files + -------------------------- + + This section covers two topics related to `gnatmake' and project files: + defining switches for `gnatmake' and for the tools that it invokes; and + the use of the `Main' attribute. + + * Menu: + + * Switches and Project Files:: + * Project Files and Main Subprograms:: + +  + File: gnat_ug_unx.info, Node: Switches and Project Files, Next: Project Files and Main Subprograms, Up: gnatmake and Project Files + + Switches and Project Files + .......................... + + For each of the packages `Builder', `Compiler', `Binder', and `Linker', + you can specify a `Default_Switches' attribute, a `Switches' attribute, + or both; as their names imply, these switch-related attributes affect + which switches are used for which files when `gnatmake' is invoked. As + will be explained below, these package-contributed switches precede the + switches passed on the `gnatmake' command line. + + The `Default_Switches' attribute is an associative array indexed by + language name (case insensitive) and returning a string list. For + example: + + package Compiler is + for Default_Switches ("Ada") use ("-gnaty", "-v"); + end Compiler; + + The `Switches' attribute is also an associative array, indexed by a file + name (which may or may not be case sensitive, depending on the operating + system) and returning a string list. For example: + + package Builder is + for Switches ("main1.adb") use ("-O2"); + for Switches ("main2.adb") use ("-g"); + end Builder; + + For the `Builder' package, the file names should designate source files + for main subprograms. For the `Binder' and `Linker' packages, the file + names should designate `ALI' or source files for main subprograms. In + each case just the file name (without explicit extension) is acceptable. + + For each tool used in a program build (`gnatmake', the compiler, the + binder, and the linker), its corresponding package "contributes" a set + of switches for each file on which the tool is invoked, based on the + switch-related attributes defined in the package. In particular, the + switches that each of these packages contributes for a given file F + comprise: + + * the value of attribute `Switches (F)', if it is specified in the + package for the given file, + + * otherwise, the value of `Default_Switches ("Ada")', if it is + specified in the package. + + If neither of these attributes is defined in the package, then the + package does not contribute any switches for the given file. + + When `gnatmake' is invoked on a file, the switches comprise two sets, + in the following order: those contributed for the file by the `Builder' + package; and the switches passed on the command line. + + When `gnatmake' invokes a tool (compiler, binder, linker) on a file, + the switches passed to the tool comprise three sets, in the following + order: + + 1. the applicable switches contributed for the file by the `Builder' + package in the project file supplied on the command line; + + 2. those contributed for the file by the package (in the relevant + project file - see below) corresponding to the tool; and + + 3. the applicable switches passed on the command line. + + The term _applicable switches_ reflects the fact that `gnatmake' + switches may or may not be passed to individual tools, depending on the + individual switch. + + `gnatmake' may invoke the compiler on source files from different + projects. The Project Manager will use the appropriate project file to + determine the `Compiler' package for each source file being compiled. + Likewise for the `Binder' and `Linker' packages. + + As an example, consider the following package in a project file: + + project Proj1 is + package Compiler is + for Default_Switches ("Ada") use ("-g"); + for Switches ("a.adb") use ("-O1"); + for Switches ("b.adb") use ("-O2", "-gnaty"); + end Compiler; + end Proj1; + + If `gnatmake' is invoked with this project file, and it needs to + compile, say, the files `a.adb', `b.adb', and `c.adb', then `a.adb' + will be compiled with the switch `-O1', `b.adb' with switches `-O2' and + `-gnaty', and `c.adb' with `-g'. + + Another example illustrates the ordering of the switches contributed + by different packages: + + project Proj2 is + package Builder is + for Switches ("main.adb") use ("-g", "-O1", "-f"); + end Builder; + + package Compiler is + for Switches ("main.adb") use ("-O2"); + end Compiler; + end Proj2; + + If you issue the command: + + gnatmake -PProj2 -O0 main + + then the compiler will be invoked on `main.adb' with the following + sequence of switches + + -g -O1 -O2 -O0 + + with the last `-O' switch having precedence over the earlier ones; + several other switches (such as `-c') are added implicitly. + + The switches `-g' and `-O1' are contributed by package `Builder', + `-O2' is contributed by the package `Compiler' and `-O0' comes from the + command line. + + The `-g' switch will also be passed in the invocation of `gnatlink.' + + A final example illustrates switch contributions from packages in + different project files: + + project Proj3 is + for Source_Files use ("pack.ads", "pack.adb"); + package Compiler is + for Default_Switches ("Ada") use ("-gnata"); + end Compiler; + end Proj3; + + with "Proj3"; + project Proj4 is + for Source_Files use ("foo_main.adb", "bar_main.adb"); + package Builder is + for Switches ("foo_main.adb") use ("-s", "-g"); + end Builder; + end Proj4; + + -- Ada source file: + with Pack; + procedure Foo_Main is + ... + end Foo_Main; + + If the command is + gnatmake -PProj4 foo_main.adb -cargs -gnato + + then the switches passed to the compiler for `foo_main.adb' are `-g' + (contributed by the package `Proj4.Builder') and `-gnato' (passed on + the command line). When the imported package `Pack' is compiled, the + switches used are `-g' from `Proj4.Builder', `-gnata' (contributed from + package `Proj3.Compiler', and `-gnato' from the command line. + +  + File: gnat_ug_unx.info, Node: Project Files and Main Subprograms, Prev: Switches and Project Files, Up: gnatmake and Project Files + + Project Files and Main Subprograms + .................................. + + When using a project file, you can invoke `gnatmake' with several main + subprograms, by specifying their source files on the command line. + Each of these needs to be an immediate source file of the project. + + gnatmake -Pprj main1 main2 main3 + + When using a project file, you can also invoke `gnatmake' without + explicitly specifying any main, and the effect depends on whether you + have defined the `Main' attribute. This attribute has a string list + value, where each element in the list is the name of a source file (the + file extension is optional) containing a main subprogram. + + If the `Main' attribute is defined in a project file as a non-empty + string list and the switch `-u' is not used on the command line, then + invoking `gnatmake' with this project file but without any main on the + command line is equivalent to invoking `gnatmake' with all the file + names in the `Main' attribute on the command line. + + Example: + project Prj is + for Main use ("main1", "main2", "main3"); + end Prj; + + With this project file, `"gnatmake -Pprj"' is equivalent to `"gnatmake + -Pprj main1 main2 main3"'. + + When the project attribute `Main' is not specified, or is specified + as an empty string list, or when the switch `-u' is used on the command + line, then invoking `gnatmake' with no main on the command line will + result in all immediate sources of the project file being checked, and + potentially recompiled. Depending on the presence of the switch `-u', + sources from other project files on which the immediate sources of the + main project file depend are also checked and potentially recompiled. + In other words, the `-u' switch is applied to all of the immediate + sources of themain project file. + +  + File: gnat_ug_unx.info, Node: The GNAT Driver and Project Files, Next: Glide and Project Files, Prev: gnatmake and Project Files, Up: Tools Supporting Project Files + + The GNAT Driver and Project Files + --------------------------------- + + A number of GNAT tools, other than `gnatmake' are project-aware: + `gnatbind', `gnatfind', `gnatlink', `gnatls' and `gnatxref'. However, + none of these tools can be invoked directly with a project file switch + (`-P'). They need to be invoke through the `gnat' driver. + + The `gnat' driver is a front-end that accepts a number of commands + and call the corresponding tool. It has been designed initially for VMS + to convert VMS style qualifiers to Unix style switches, but it is now + available to all the GNAT supported platforms. + + On non VMS platforms, the `gnat' driver accepts the following + commands (case insensitive): + + * BIND to invoke `gnatbind' + + * CHOP to invoke `gnatchop' + + * COMP or COMPILE to invoke the compiler + + * ELIM to invoke `gnatelim' + + * FIND to invoke `gnatfind' + + * KR or KRUNCH to invoke `gnatkr' + + * LINK to invoke `gnatlink' + + * LS or LIST to invoke `gnatls' + + * MAKE to invoke `gnatmake' + + * NAME to invoke `gnatname' + + * PREP or PREPROCESS to invoke `gnatprep' + + * PSTA or STANDARD to invoke `gnatpsta' + + * STUB to invoke `gnatstub' + + * XREF to invoke `gnatxref' + + Note that the compiler is invoked using the command `gnatmake -f -u'. + + Following the command, you may put switches and arguments for the + invoked tool. + + gnat bind -C main.ali + gnat ls -a main + gnat chop foo.txt + + In addition, for command BIND, FIND, LS or LIST, LINK and XREF, the + project file related switches (`-P', `-X' and `-vPx') may be used in + addition to the switches of the invoking tool. + + For each of these command, there is possibly a package in the main + project that corresponds to the invoked tool. + + * package `Binder' for command BIND (invoking `gnatbind') + + * package `Finder' for command FIND (invoking `gnatfind') + + * package `Gnatls' for command LS or LIST (invoking `gnatls') + + * package `Linker' for command LINK (invoking `gnatlink') + + * package `Cross_Reference' for command XREF (invoking `gnatlink') + + + Package `Gnatls' has a unique attribute `Switches', a simple variable + with a string list value. It contains switches for the invocation of + `gnatls'. + + project Proj1 is + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + end Proj1; + + All other packages contains a switch `Default_Switches', an associative + array, indexed by the programming language (case insensitive) and + having a string list value. `Default_Switches ("Ada")' contains the + switches for the invocation of the tool corresponding to the package. + + project Proj is + + for Source_Dirs use ("./**"); + + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + + package Binder is + for Default_Switches ("Ada") use ("-C", "-e"); + end Binder; + + package Linker is + for Default_Switches ("Ada") use ("-C"); + end Linker; + + package Finder is + for Default_Switches ("Ada") use ("-a", "-f"); + end Finder; + + package Cross_Reference is + for Default_Switches ("Ada") use ("-a", "-f", "-d", "-u"); + end Cross_Reference; + end Proj; + + With the above project file, commands such as + + gnat ls -Pproj main + gnat xref -Pproj main + gnat bind -Pproj main.ali + + will set up the environment properly and invoke the tool with the + switches found in the package corresponding to the tool. + +  + File: gnat_ug_unx.info, Node: Glide and Project Files, Prev: The GNAT Driver and Project Files, Up: Tools Supporting Project Files + + Glide and Project Files + ----------------------- + + Glide will automatically recognize the `.gpr' extension for project + files, and will convert them to its own internal format automatically. + However, it doesn't provide a syntax-oriented editor for modifying these + files. The project file will be loaded as text when you select the + menu item `Ada' => `Project' => `Edit'. You can edit this text and + save the `gpr' file; when you next select this project file in Glide it + will be automatically reloaded. + +  + File: gnat_ug_unx.info, Node: An Extended Example, Next: Project File Complete Syntax, Prev: Tools Supporting Project Files, Up: GNAT Project Manager + + An Extended Example + =================== + + Suppose that we have two programs, PROG1 and PROG2, with the sources in + the respective directories. We would like to build them with a single + `gnatmake' command, and we would like to place their object files into + `.build' subdirectories of the source directories. Furthermore, we would + like to have to have two separate subdirectories in `.build' - + `release' and `debug' - which will contain the object files compiled + with different set of compilation flags. + + In other words, we have the following structure: + + main + |- prog1 + | |- .build + | | debug + | | release + |- prog2 + |- .build + | debug + | release + + Here are the project files that we need to create in a directory `main' + to maintain this structure: + + 1. We create a `Common' project with a package `Compiler' that + specifies the compilation switches: + + File "common.gpr": + project Common is + + for Source_Dirs use (); -- No source files + + type Build_Type is ("release", "debug"); + Build : Build_Type := External ("BUILD", "debug"); + package Compiler is + case Build is + when "release" => + for Default_Switches ("Ada") use ("-O2"); + when "debug" => + for Default_Switches ("Ada") use ("-g"); + end case; + end Compiler; + + end Common; + + 2. We create separate projects for the two programs: + + File "prog1.gpr": + + with "common"; + project Prog1 is + + for Source_Dirs use ("prog1"); + for Object_Dir use "prog1/.build/" & Common.Build; + + package Compiler renames Common.Compiler; + + end Prog1; + + File "prog2.gpr": + + with "common"; + project Prog2 is + + for Source_Dirs use ("prog2"); + for Object_Dir use "prog2/.build/" & Common.Build; + + package Compiler renames Common.Compiler; + end Prog2; + + 3. We create a wrapping project MAIN: + + File "main.gpr": + + with "common"; + with "prog1"; + with "prog2"; + project Main is + + package Compiler renames Common.Compiler; + + end Main; + + 4. Finally we need to create a dummy procedure that `with's (either + explicitly or implicitly) all the sources of our two programs. + + + Now we can build the programs using the command + + gnatmake -Pmain dummy + + for the Debug mode, or + + gnatmake -Pmain -XBUILD=release + + for the Release mode. + +  + File: gnat_ug_unx.info, Node: Project File Complete Syntax, Prev: An Extended Example, Up: GNAT Project Manager + + Project File Complete Syntax + ============================ + + project ::= + context_clause project_declaration + + context_clause ::= + {with_clause} + + with_clause ::= + with literal_string { , literal_string } ; + + project_declaration ::= + project simple_name [ extends literal_string ] is + {declarative_item} + end simple_name; + + declarative_item ::= + package_declaration | + typed_string_declaration | + other_declarative_item + + package_declaration ::= + package simple_name package_completion + + package_completion ::= + package_body | package_renaming + + package body ::= + is + {other_declarative_item} + end simple_name ; + + package_renaming ::== + renames simple_name.simple_name ; + + typed_string_declaration ::= + type _simple_name is + ( literal_string {, literal_string} ); + + other_declarative_item ::= + attribute_declaration | + typed_variable_declaration | + variable_declaration | + case_construction + + attribute_declaration ::= + for attribute use expression ; + + attribute ::= + simple_name | + simple_name ( literal_string ) + + typed_variable_declaration ::= + simple_name : name := string_expression ; + + variable_declaration ::= + simple_name := expression; + + expression ::= + term {& term} + + term ::= + literal_string | + string_list | + name | + external_value | + attribute_reference + + literal_string ::= + (same as Ada) + + string_list ::= + ( expression { , expression } ) + + external_value ::= + external ( literal_string [, literal_string] ) + + attribute_reference ::= + attribute_parent ' simple_name [ ( literal_string ) ] + + attribute_parent ::= + project | + simple_name | + simple_name . simple_name + + case_construction ::= + case name is + {case_item} + end case ; + + case_item ::= + when discrete_choice_list => {case_construction | attribute_declaration} + + discrete_choice_list ::= + literal_string {| literal_string} + + name ::= + simple_name {. simple_name} + + simple_name ::= + identifier (same as Ada) + +  + File: gnat_ug_unx.info, Node: Elaboration Order Handling in GNAT, Next: The Cross-Referencing Tools gnatxref and gnatfind, Prev: GNAT Project Manager, Up: Top + + Elaboration Order Handling in GNAT + ********************************** + + * Menu: + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + This chapter describes the handling of elaboration code in Ada 95 and + in GNAT, and discusses how the order of elaboration of program units can + be controlled in GNAT, either automatically or with explicit programming + features. + +  + File: gnat_ug_unx.info, Node: Elaboration Code in Ada 95, Next: Checking the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Elaboration Code in Ada 95 + ========================== + + Ada 95 provides rather general mechanisms for executing code at + elaboration time, that is to say before the main program starts + executing. Such code arises in three contexts: + + Initializers for variables. + Variables declared at the library level, in package specs or + bodies, can require initialization that is performed at + elaboration time, as in: + Sqrt_Half : Float := Sqrt (0.5); + + Package initialization code + Code in a `BEGIN-END' section at the outer level of a package body + is executed as part of the package body elaboration code. + + Library level task allocators + Tasks that are declared using task allocators at the library level + start executing immediately and hence can execute at elaboration + time. + + Subprogram calls are possible in any of these contexts, which means that + any arbitrary part of the program may be executed as part of the + elaboration code. It is even possible to write a program which does all + its work at elaboration time, with a null main program, although + stylistically this would usually be considered an inappropriate way to + structure a program. + + An important concern arises in the context of elaboration code: we + have to be sure that it is executed in an appropriate order. What we + have is a series of elaboration code sections, potentially one section + for each unit in the program. It is important that these execute in the + correct order. Correctness here means that, taking the above example of + the declaration of `Sqrt_Half', if some other piece of elaboration code + references `Sqrt_Half', then it must run after the section of + elaboration code that contains the declaration of `Sqrt_Half'. + + There would never be any order of elaboration problem if we made a + rule that whenever you `with' a unit, you must elaborate both the spec + and body of that unit before elaborating the unit doing the `with''ing: + + with Unit_1; + package Unit_2 is ... + + would require that both the body and spec of `Unit_1' be elaborated + before the spec of `Unit_2'. However, a rule like that would be far too + restrictive. In particular, it would make it impossible to have routines + in separate packages that were mutually recursive. + + You might think that a clever enough compiler could look at the + actual elaboration code and determine an appropriate correct order of + elaboration, but in the general case, this is not possible. Consider + the following example. + + In the body of `Unit_1', we have a procedure `Func_1' that references + the variable `Sqrt_1', which is declared in the elaboration code of the + body of `Unit_1': + + Sqrt_1 : Float := Sqrt (0.1); + + The elaboration code of the body of `Unit_1' also contains: + + if expression_1 = 1 then + Q := Unit_2.Func_2; + end if; + + `Unit_2' is exactly parallel, it has a procedure `Func_2' that + references the variable `Sqrt_2', which is declared in the elaboration + code of the body `Unit_2': + + Sqrt_2 : Float := Sqrt (0.1); + + The elaboration code of the body of `Unit_2' also contains: + + if expression_2 = 2 then + Q := Unit_1.Func_1; + end if; + + Now the question is, which of the following orders of elaboration is + acceptable: + + Spec of Unit_1 + Spec of Unit_2 + Body of Unit_1 + Body of Unit_2 + + or + + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_2 + Body of Unit_1 + + If you carefully analyze the flow here, you will see that you cannot + tell at compile time the answer to this question. If `expression_1' is + not equal to 1, and `expression_2' is not equal to 2, then either order + is acceptable, because neither of the function calls is executed. If + both tests evaluate to true, then neither order is acceptable and in + fact there is no correct order. + + If one of the two expressions is true, and the other is false, then + one of the above orders is correct, and the other is incorrect. For + example, if `expression_1' = 1 and `expression_2' /= 2, then the call + to `Func_2' will occur, but not the call to `Func_1.' This means that + it is essential to elaborate the body of `Unit_1' before the body of + `Unit_2', so the first order of elaboration is correct and the second + is wrong. + + By making `expression_1' and `expression_2' depend on input data, or + perhaps the time of day, we can make it impossible for the compiler or + binder to figure out which of these expressions will be true, and hence + it is impossible to guarantee a safe order of elaboration at run time. + +  + File: gnat_ug_unx.info, Node: Checking the Elaboration Order in Ada 95, Next: Controlling the Elaboration Order in Ada 95, Prev: Elaboration Code in Ada 95, Up: Elaboration Order Handling in GNAT + + Checking the Elaboration Order in Ada 95 + ======================================== + + In some languages that involve the same kind of elaboration problems, + e.g. Java and C++, the programmer is expected to worry about these + ordering problems himself, and it is common to write a program in which + an incorrect elaboration order gives surprising results, because it + references variables before they are initialized. Ada 95 is designed + to be a safe language, and a programmer-beware approach is clearly not + sufficient. Consequently, the language provides three lines of defense: + + Standard rules + Some standard rules restrict the possible choice of elaboration + order. In particular, if you `with' a unit, then its spec is always + elaborated before the unit doing the `with'. Similarly, a parent + spec is always elaborated before the child spec, and finally a + spec is always elaborated before its corresponding body. + + Dynamic elaboration checks + Dynamic checks are made at run time, so that if some entity is + accessed before it is elaborated (typically by means of a + subprogram call) then the exception (`Program_Error') is raised. + + Elaboration control + Facilities are provided for the programmer to specify the desired + order of elaboration. + + Let's look at these facilities in more detail. First, the rules for + dynamic checking. One possible rule would be simply to say that the + exception is raised if you access a variable which has not yet been + elaborated. The trouble with this approach is that it could require + expensive checks on every variable reference. Instead Ada 95 has two + rules which are a little more restrictive, but easier to check, and + easier to state: + + Restrictions on calls + A subprogram can only be called at elaboration time if its body + has been elaborated. The rules for elaboration given above + guarantee that the spec of the subprogram has been elaborated + before the call, but not the body. If this rule is violated, then + the exception `Program_Error' is raised. + + Restrictions on instantiations + A generic unit can only be instantiated if the body of the generic + unit has been elaborated. Again, the rules for elaboration given + above guarantee that the spec of the generic unit has been + elaborated before the instantiation, but not the body. If this + rule is violated, then the exception `Program_Error' is raised. + + The idea is that if the body has been elaborated, then any variables it + references must have been elaborated; by checking for the body being + elaborated we guarantee that none of its references causes any trouble. + As we noted above, this is a little too restrictive, because a + subprogram that has no non-local references in its body may in fact be + safe to call. However, it really would be unsafe to rely on this, + because it would mean that the caller was aware of details of the + implementation in the body. This goes against the basic tenets of Ada. + + A plausible implementation can be described as follows. A Boolean + variable is associated with each subprogram and each generic unit. This + variable is initialized to False, and is set to True at the point body + is elaborated. Every call or instantiation checks the variable, and + raises `Program_Error' if the variable is False. + + Note that one might think that it would be good enough to have one + Boolean variable for each package, but that would not deal with cases + of trying to call a body in the same package as the call that has not + been elaborated yet. Of course a compiler may be able to do enough + analysis to optimize away some of the Boolean variables as unnecessary, + and `GNAT' indeed does such optimizations, but still the easiest + conceptual model is to think of there being one variable per subprogram. + +  + File: gnat_ug_unx.info, Node: Controlling the Elaboration Order in Ada 95, Next: Controlling Elaboration in GNAT - Internal Calls, Prev: Checking the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Controlling the Elaboration Order in Ada 95 + =========================================== + + In the previous section we discussed the rules in Ada 95 which ensure + that `Program_Error' is raised if an incorrect elaboration order is + chosen. This prevents erroneous executions, but we need mechanisms to + specify a correct execution and avoid the exception altogether. To + achieve this, Ada 95 provides a number of features for controlling the + order of elaboration. We discuss these features in this section. + + First, there are several ways of indicating to the compiler that a + given unit has no elaboration problems: + + packages that do not require a body + In Ada 95, a library package that does not require a body does not + permit a body. This means that if we have a such a package, as in: + + package Definitions is + generic + type m is new integer; + package Subp is + type a is array (1 .. 10) of m; + type b is array (1 .. 20) of m; + end Subp; + end Definitions; + + A package that `with''s `Definitions' may safely instantiate + `Definitions.Subp' because the compiler can determine that there + definitely is no package body to worry about in this case + + pragma Pure + Places sufficient restrictions on a unit to guarantee that no call + to any subprogram in the unit can result in an elaboration + problem. This means that the compiler does not need to worry about + the point of elaboration of such units, and in particular, does + not need to check any calls to any subprograms in this unit. + + pragma Preelaborate + This pragma places slightly less stringent restrictions on a unit + than does pragma Pure, but these restrictions are still sufficient + to ensure that there are no elaboration problems with any calls to + the unit. + + pragma Elaborate_Body + This pragma requires that the body of a unit be elaborated + immediately after its spec. Suppose a unit `A' has such a pragma, + and unit `B' does a `with' of unit `A'. Recall that the standard + rules require the spec of unit `A' to be elaborated before the + `with''ing unit; given the pragma in `A', we also know that the + body of `A' will be elaborated before `B', so that calls to `A' + are safe and do not need a check. + + Note that, unlike pragma `Pure' and pragma `Preelaborate', the use of + `Elaborate_Body' does not guarantee that the program is free of + elaboration problems, because it may not be possible to satisfy the + requested elaboration order. Let's go back to the example with + `Unit_1' and `Unit_2'. If a programmer marks `Unit_1' as + `Elaborate_Body', and not `Unit_2,' then the order of elaboration will + be: + + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_1 + Body of Unit_2 + + Now that means that the call to `Func_1' in `Unit_2' need not be + checked, it must be safe. But the call to `Func_2' in `Unit_1' may + still fail if `Expression_1' is equal to 1, and the programmer must + still take responsibility for this not being the case. + + If all units carry a pragma `Elaborate_Body', then all problems are + eliminated, except for calls entirely within a body, which are in any + case fully under programmer control. However, using the pragma + everywhere is not always possible. In particular, for our + `Unit_1'/`Unit_2' example, if we marked both of them as having pragma + `Elaborate_Body', then clearly there would be no possible elaboration + order. + + The above pragmas allow a server to guarantee safe use by clients, + and clearly this is the preferable approach. Consequently a good rule in + Ada 95 is to mark units as `Pure' or `Preelaborate' if possible, and if + this is not possible, mark them as `Elaborate_Body' if possible. As we + have seen, there are situations where neither of these three pragmas + can be used. So we also provide methods for clients to control the + order of elaboration of the servers on which they depend: + + pragma Elaborate (unit) + This pragma is placed in the context clause, after a `with' clause, + and it requires that the body of the named unit be elaborated + before the unit in which the pragma occurs. The idea is to use + this pragma if the current unit calls at elaboration time, + directly or indirectly, some subprogram in the named unit. + + pragma Elaborate_All (unit) + This is a stronger version of the Elaborate pragma. Consider the + following example: + + Unit A `with''s unit B and calls B.Func in elab code + Unit B `with''s unit C, and B.Func calls C.Func + + Now if we put a pragma `Elaborate (B)' in unit `A', this ensures + that the body of `B' is elaborated before the call, but not the + body of `C', so the call to `C.Func' could still cause + `Program_Error' to be raised. + + The effect of a pragma `Elaborate_All' is stronger, it requires + not only that the body of the named unit be elaborated before the + unit doing the `with', but also the bodies of all units that the + named unit uses, following `with' links transitively. For example, + if we put a pragma `Elaborate_All (B)' in unit `A', then it + requires not only that the body of `B' be elaborated before `A', + but also the body of `C', because `B' `with''s `C'. + + We are now in a position to give a usage rule in Ada 95 for avoiding + elaboration problems, at least if dynamic dispatching and access to + subprogram values are not used. We will handle these cases separately + later. + + The rule is simple. If a unit has elaboration code that can directly + or indirectly make a call to a subprogram in a `with''ed unit, or + instantiate a generic unit in a `with''ed unit, then if the `with''ed + unit does not have pragma `Pure' or `Preelaborate', then the client + should have a pragma `Elaborate_All' for the `with''ed unit. By + following this rule a client is assured that calls can be made without + risk of an exception. If this rule is not followed, then a program may + be in one of four states: + + No order exists + No order of elaboration exists which follows the rules, taking into + account any `Elaborate', `Elaborate_All', or `Elaborate_Body' + pragmas. In this case, an Ada 95 compiler must diagnose the + situation at bind time, and refuse to build an executable program. + + One or more orders exist, all incorrect + One or more acceptable elaboration orders exists, and all of them + generate an elaboration order problem. In this case, the binder + can build an executable program, but `Program_Error' will be raised + when the program is run. + + Several orders exist, some right, some incorrect + One or more acceptable elaboration orders exists, and some of them + work, and some do not. The programmer has not controlled the order + of elaboration, so the binder may or may not pick one of the + correct orders, and the program may or may not raise an exception + when it is run. This is the worst case, because it means that the + program may fail when moved to another compiler, or even another + version of the same compiler. + + One or more orders exists, all correct + One ore more acceptable elaboration orders exist, and all of them + work. In this case the program runs successfully. This state of + affairs can be guaranteed by following the rule we gave above, but + may be true even if the rule is not followed. + + Note that one additional advantage of following our Elaborate_All rule + is that the program continues to stay in the ideal (all orders OK) state + even if maintenance changes some bodies of some subprograms. + Conversely, if a program that does not follow this rule happens to be + safe at some point, this state of affairs may deteriorate silently as a + result of maintenance changes. + + You may have noticed that the above discussion did not mention the + use of `Elaborate_Body'. This was a deliberate omission. If you `with' + an `Elaborate_Body' unit, it still may be the case that code in the + body makes calls to some other unit, so it is still necessary to use + `Elaborate_All' on such units. + +  + File: gnat_ug_unx.info, Node: Controlling Elaboration in GNAT - Internal Calls, Next: Controlling Elaboration in GNAT - External Calls, Prev: Controlling the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Controlling Elaboration in GNAT - Internal Calls + ================================================ + + In the case of internal calls, i.e. calls within a single package, the + programmer has full control over the order of elaboration, and it is up + to the programmer to elaborate declarations in an appropriate order. For + example writing: + + function One return Float; + + Q : Float := One; + + function One return Float is + begin + return 1.0; + end One; + + will obviously raise `Program_Error' at run time, because function One + will be called before its body is elaborated. In this case GNAT will + generate a warning that the call will raise `Program_Error': + + 1. procedure y is + 2. function One return Float; + 3. + 4. Q : Float := One; + | + >>> warning: cannot call "One" before body is elaborated + >>> warning: Program_Error will be raised at run time + + 5. + 6. function One return Float is + 7. begin + 8. return 1.0; + 9. end One; + 10. + 11. begin + 12. null; + 13. end; + + Note that in this particular case, it is likely that the call is safe, + because the function `One' does not access any global variables. + Nevertheless in Ada 95, we do not want the validity of the check to + depend on the contents of the body (think about the separate + compilation case), so this is still wrong, as we discussed in the + previous sections. + + The error is easily corrected by rearranging the declarations so + that the body of One appears before the declaration containing the call + (note that in Ada 95, declarations can appear in any order, so there is + no restriction that would prevent this reordering, and if we write: + + function One return Float; + + function One return Float is + begin + return 1.0; + end One; + + Q : Float := One; + + then all is well, no warning is generated, and no `Program_Error' + exception will be raised. Things are more complicated when a chain of + subprograms is executed: + + function A return Integer; + function B return Integer; + function C return Integer; + + function B return Integer is begin return A; end; + function C return Integer is begin return B; end; + + X : Integer := C; + + function A return Integer is begin return 1; end; + + Now the call to `C' at elaboration time in the declaration of `X' is + correct, because the body of `C' is already elaborated, and the call to + `B' within the body of `C' is correct, but the call to `A' within the + body of `B' is incorrect, because the body of `A' has not been + elaborated, so `Program_Error' will be raised on the call to `A'. In + this case GNAT will generate a warning that `Program_Error' may be + raised at the point of the call. Let's look at the warning: + + 1. procedure x is + 2. function A return Integer; + 3. function B return Integer; + 4. function C return Integer; + 5. + 6. function B return Integer is begin return A; end; + | + >>> warning: call to "A" before body is elaborated may + raise Program_Error + >>> warning: "B" called at line 7 + >>> warning: "C" called at line 9 + + 7. function C return Integer is begin return B; end; + 8. + 9. X : Integer := C; + 10. + 11. function A return Integer is begin return 1; end; + 12. + 13. begin + 14. null; + 15. end; + + Note that the message here says "may raise", instead of the direct case, + where the message says "will be raised". That's because whether `A' is + actually called depends in general on run-time flow of control. For + example, if the body of `B' said + + function B return Integer is + begin + if some-condition-depending-on-input-data then + return A; + else + return 1; + end if; + end B; + + then we could not know until run time whether the incorrect call to A + would actually occur, so `Program_Error' might or might not be raised. + It is possible for a compiler to do a better job of analyzing bodies, to + determine whether or not `Program_Error' might be raised, but it + certainly couldn't do a perfect job (that would require solving the + halting problem and is provably impossible), and because this is a + warning anyway, it does not seem worth the effort to do the analysis. + Cases in which it would be relevant are rare. + + In practice, warnings of either of the forms given above will + usually correspond to real errors, and should be examined carefully and + eliminated. In the rare case where a warning is bogus, it can be + suppressed by any of the following methods: + + * Compile with the `-gnatws' switch set + + * Suppress `Elaboration_Checks' for the called subprogram + + * Use pragma `Warnings_Off' to turn warnings off for the call + + For the internal elaboration check case, GNAT by default generates the + necessary run-time checks to ensure that `Program_Error' is raised if + any call fails an elaboration check. Of course this can only happen if a + warning has been issued as described above. The use of pragma `Suppress + (Elaboration_Checks)' may (but is not guaranteed to) suppress some of + these checks, meaning that it may be possible (but is not guaranteed) + for a program to be able to call a subprogram whose body is not yet + elaborated, without raising a `Program_Error' exception. + +  + File: gnat_ug_unx.info, Node: Controlling Elaboration in GNAT - External Calls, Next: Default Behavior in GNAT - Ensuring Safety, Prev: Controlling Elaboration in GNAT - Internal Calls, Up: Elaboration Order Handling in GNAT + + Controlling Elaboration in GNAT - External Calls + ================================================ + + The previous section discussed the case in which the execution of a + particular thread of elaboration code occurred entirely within a single + unit. This is the easy case to handle, because a programmer has direct + and total control over the order of elaboration, and furthermore, + checks need only be generated in cases which are rare and which the + compiler can easily detect. The situation is more complex when + separate compilation is taken into account. Consider the following: + + package Math is + function Sqrt (Arg : Float) return Float; + end Math; + + package body Math is + function Sqrt (Arg : Float) return Float is + begin + ... + end Sqrt; + end Math; + + with Math; + package Stuff is + X : Float := Math.Sqrt (0.5); + end Stuff; + + with Stuff; + procedure Main is + begin + ... + end Main; + + where `Main' is the main program. When this program is executed, the + elaboration code must first be executed, and one of the jobs of the + binder is to determine the order in which the units of a program are to + be elaborated. In this case we have four units: the spec and body of + `Math', the spec of `Stuff' and the body of `Main'). In what order + should the four separate sections of elaboration code be executed? + + There are some restrictions in the order of elaboration that the + binder can choose. In particular, if unit U has a `with' for a package + `X', then you are assured that the spec of `X' is elaborated before U , + but you are not assured that the body of `X' is elaborated before U. + This means that in the above case, the binder is allowed to choose the + order: + + spec of Math + spec of Stuff + body of Math + body of Main + + but that's not good, because now the call to `Math.Sqrt' that happens + during the elaboration of the `Stuff' spec happens before the body of + `Math.Sqrt' is elaborated, and hence causes `Program_Error' exception + to be raised. At first glance, one might say that the binder is + misbehaving, because obviously you want to elaborate the body of + something you `with' first, but that is not a general rule that can be + followed in all cases. Consider + + package X is ... + + package Y is ... + + with X; + package body Y is ... + + with Y; + package body X is ... + + This is a common arrangement, and, apart from the order of elaboration + problems that might arise in connection with elaboration code, this + works fine. A rule that says that you must first elaborate the body of + anything you `with' cannot work in this case: the body of `X' `with''s + `Y', which means you would have to elaborate the body of `Y' first, but + that `with''s `X', which means you have to elaborate the body of `X' + first, but ... and we have a loop that cannot be broken. + + It is true that the binder can in many cases guess an order of + elaboration that is unlikely to cause a `Program_Error' exception to be + raised, and it tries to do so (in the above example of + `Math/Stuff/Spec', the GNAT binder will by default elaborate the body + of `Math' right after its spec, so all will be well). + + However, a program that blindly relies on the binder to be helpful + can get into trouble, as we discussed in the previous sections, so GNAT + provides a number of facilities for assisting the programmer in + developing programs that are robust with respect to elaboration order. + +  + File: gnat_ug_unx.info, Node: Default Behavior in GNAT - Ensuring Safety, Next: Elaboration Issues for Library Tasks, Prev: Controlling Elaboration in GNAT - External Calls, Up: Elaboration Order Handling in GNAT + + Default Behavior in GNAT - Ensuring Safety + ========================================== + + The default behavior in GNAT ensures elaboration safety. In its default + mode GNAT implements the rule we previously described as the right + approach. Let's restate it: + + * _If a unit has elaboration code that can directly or indirectly + make a call to a subprogram in a `with''ed unit, or instantiate a + generic unit in a `with''ed unit, then if the `with''ed unit does + not have pragma `Pure' or `Preelaborate', then the client should + have an `Elaborate_All' for the `with''ed unit._ + + By following this rule a client is assured that calls and + instantiations can be made without risk of an exception. + + In this mode GNAT traces all calls that are potentially made from + elaboration code, and puts in any missing implicit `Elaborate_All' + pragmas. The advantage of this approach is that no elaboration problems + are possible if the binder can find an elaboration order that is + consistent with these implicit `Elaborate_All' pragmas. The + disadvantage of this approach is that no such order may exist. + + If the binder does not generate any diagnostics, then it means that + it has found an elaboration order that is guaranteed to be safe. + However, the binder may still be relying on implicitly generated + `Elaborate_All' pragmas so portability to other compilers than GNAT is + not guaranteed. + + If it is important to guarantee portability, then the compilations + should use the `-gnatwl' (warn on elaboration problems) switch. This + will cause warning messages to be generated indicating the missing + `Elaborate_All' pragmas. Consider the following source program: + + with k; + package j is + m : integer := k.r; + end; + + where it is clear that there should be a pragma `Elaborate_All' for + unit `k'. An implicit pragma will be generated, and it is likely that + the binder will be able to honor it. However, it is safer to include + the pragma explicitly in the source. If this unit is compiled with the + `-gnatwl' switch, then the compiler outputs a warning: + + 1. with k; + 2. package j is + 3. m : integer := k.r; + | + >>> warning: call to "r" may raise Program_Error + >>> warning: missing pragma Elaborate_All for "k" + + 4. end; + + and these warnings can be used as a guide for supplying manually the + missing pragmas. + + This default mode is more restrictive than the Ada Reference Manual, + and it is possible to construct programs which will compile using the + dynamic model described there, but will run into a circularity using + the safer static model we have described. + + Of course any Ada compiler must be able to operate in a mode + consistent with the requirements of the Ada Reference Manual, and in + particular must have the capability of implementing the standard + dynamic model of elaboration with run-time checks. + + In GNAT, this standard mode can be achieved either by the use of the + `-gnatE' switch on the compiler (`gcc' or `gnatmake') command, or by + the use of the configuration pragma: + + pragma Elaboration_Checks (RM); + + Either approach will cause the unit affected to be compiled using the + standard dynamic run-time elaboration checks described in the Ada + Reference Manual. The static model is generally preferable, since it is + clearly safer to rely on compile and link time checks rather than + run-time checks. However, in the case of legacy code, it may be + difficult to meet the requirements of the static model. This issue is + further discussed in *Note What to Do If the Default Elaboration + Behavior Fails::. + + Note that the static model provides a strict subset of the allowed + behavior and programs of the Ada Reference Manual, so if you do adhere + to the static model and no circularities exist, then you are assured + that your program will work using the dynamic model. + +  + File: gnat_ug_unx.info, Node: Elaboration Issues for Library Tasks, Next: Mixing Elaboration Models, Prev: Default Behavior in GNAT - Ensuring Safety, Up: Elaboration Order Handling in GNAT + + Elaboration Issues for Library Tasks + ==================================== + + In this section we examine special elaboration issues that arise for + programs that declare library level tasks. + + Generally the model of execution of an Ada program is that all units + are elaborated, and then execution of the program starts. However, the + declaration of library tasks definitely does not fit this model. The + reason for this is that library tasks start as soon as they are declared + (more precisely, as soon as the statement part of the enclosing package + body is reached), that is to say before elaboration of the program is + complete. This means that if such a task calls a subprogram, or an + entry in another task, the callee may or may not be elaborated yet, and + in the standard Reference Manual model of dynamic elaboration checks, + you can even get timing dependent Program_Error exceptions, since there + can be a race between the elaboration code and the task code. + + The static model of elaboration in GNAT seeks to avoid all such + dynamic behavior, by being conservative, and the conservative approach + in this particular case is to assume that all the code in a task body + is potentially executed at elaboration time if a task is declared at + the library level. + + This can definitely result in unexpected circularities. Consider the + following example + + package Decls is + task Lib_Task is + entry Start; + end Lib_Task; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + procedure Main is + begin + Decls.Lib_Task.Start; + end; + + If the above example is compiled in the default static elaboration + mode, then a circularity occurs. The circularity comes from the call + `Utils.Put_Val' in the task body of `Decls.Lib_Task'. Since this call + occurs in elaboration code, we need an implicit pragma `Elaborate_All' + for `Utils'. This means that not only must the spec and body of `Utils' + be elaborated before the body of `Decls', but also the spec and body of + any unit that is `with'ed' by the body of `Utils' must also be + elaborated before the body of `Decls'. This is the transitive + implication of pragma `Elaborate_All' and it makes sense, because in + general the body of `Put_Val' might have a call to something in a + `with'ed' unit. + + In this case, the body of Utils (actually its spec) `with's' + `Decls'. Unfortunately this means that the body of `Decls' must be + elaborated before itself, in case there is a call from the body of + `Utils'. + + Here is the exact chain of events we are worrying about: + + 1. In the body of `Decls' a call is made from within the body of a + library task to a subprogram in the package `Utils'. Since this + call may occur at elaboration time (given that the task is + activated at elaboration time), we have to assume the worst, i.e. + that the call does happen at elaboration time. + + 2. This means that the body and spec of `Util' must be elaborated + before the body of `Decls' so that this call does not cause an + access before elaboration. + + 3. Within the body of `Util', specifically within the body of + `Util.Put_Val' there may be calls to any unit `with''ed by this + package. + + 4. One such `with''ed package is package `Decls', so there might be a + call to a subprogram in `Decls' in `Put_Val'. In fact there is + such a call in this example, but we would have to assume that + there was such a call even if it were not there, since we are not + supposed to write the body of `Decls' knowing what is in the body + of `Utils'; certainly in the case of the static elaboration model, + the compiler does not know what is in other bodies and must assume + the worst. + + 5. This means that the spec and body of `Decls' must also be + elaborated before we elaborate the unit containing the call, but + that unit is `Decls'! This means that the body of `Decls' must be + elaborated before itself, and that's a circularity. + + Indeed, if you add an explicit pragma Elaborate_All for `Utils' in the + body of `Decls' you will get a true Ada Reference Manual circularity + that makes the program illegal. + + In practice, we have found that problems with the static model of + elaboration in existing code often arise from library tasks, so we must + address this particular situation. + + Note that if we compile and run the program above, using the dynamic + model of elaboration (that is to say use the `-gnatE' switch), then it + compiles, binds, links, and runs, printing the expected result of 2. + Therefore in some sense the circularity here is only apparent, and we + need to capture the properties of this program that distinguish it + from other library-level tasks that have real elaboration problems. + + We have four possible answers to this question: + + * Use the dynamic model of elaboration. + + If we use the `-gnatE' switch, then as noted above, the program + works. Why is this? If we examine the task body, it is apparent + that the task cannot proceed past the `accept' statement until + after elaboration has been completed, because the corresponding + entry call comes from the main program, not earlier. This is why + the dynamic model works here. But that's really giving up on a + precise analysis, and we prefer to take this approach only if we + cannot solve the problem in any other manner. So let us examine + two ways to reorganize the program to avoid the potential + elaboration problem. + + * Split library tasks into separate packages. + + Write separate packages, so that library tasks are isolated from + other declarations as much as possible. Let us look at a variation + on the above program. + + package Decls1 is + task Lib_Task is + entry Start; + end Lib_Task; + end Decls1; + + with Utils; + package body Decls1 is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + end Decls1; + + package Decls2 is + type My_Int is new Integer; + function Ident (M : My_Int) return My_Int; + end Decls2; + + with Utils; + package body Decls2 is + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls2; + + with Decls2; + package Utils is + procedure Put_Val (Arg : Decls2.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls2.My_Int) is + begin + Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls1; + procedure Main is + begin + Decls1.Lib_Task.Start; + end; + + All we have done is to split `Decls' into two packages, one + containing the library task, and one containing everything else. + Now there is no cycle, and the program compiles, binds, links and + executes using the default static model of elaboration. + + * Declare separate task types. + + A significant part of the problem arises because of the use of the + single task declaration form. This means that the elaboration of + the task type, and the elaboration of the task itself (i.e. the + creation of the task) happen at the same time. A good rule of + style in Ada 95 is to always create explicit task types. By + following the additional step of placing task objects in separate + packages from the task type declaration, many elaboration problems + are avoided. Here is another modified example of the example + program: + + package Decls is + task type Lib_Task_Type is + entry Start; + end Lib_Task_Type; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task_Type is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task_Type; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + package Declst is + Lib_Task : Decls.Lib_Task_Type; + end Declst; + + with Declst; + procedure Main is + begin + Declst.Lib_Task.Start; + end; + + What we have done here is to replace the `task' declaration in + package `Decls' with a `task type' declaration. Then we introduce + a separate package `Declst' to contain the actual task object. + This separates the elaboration issues for the `task type' + declaration, which causes no trouble, from the elaboration issues + of the task object, which is also unproblematic, since it is now + independent of the elaboration of `Utils'. This separation of + concerns also corresponds to a generally sound engineering + principle of separating declarations from instances. This version + of the program also compiles, binds, links, and executes, + generating the expected output. + + * Use No_Entry_Calls_In_Elaboration_Code restriction. + + The previous two approaches described how a program can be + restructured to avoid the special problems caused by library task + bodies. in practice, however, such restructuring may be difficult + to apply to existing legacy code, so we must consider solutions + that do not require massive rewriting. + + Let us consider more carefully why our original sample program + works under the dynamic model of elaboration. The reason is that + the code in the task body blocks immediately on the `accept' + statement. Now of course there is nothing to prohibit elaboration + code from making entry calls (for example from another library + level task), so we cannot tell in isolation that the task will not + execute the accept statement during elaboration. + + However, in practice it is very unusual to see elaboration code + make any entry calls, and the pattern of tasks starting at + elaboration time and then immediately blocking on `accept' or + `select' statements is very common. What this means is that the + compiler is being too pessimistic when it analyzes the whole + package body as though it might be executed at elaboration time. + + If we know that the elaboration code contains no entry calls, (a + very safe assumption most of the time, that could almost be made + the default behavior), then we can compile all units of the + program under control of the following configuration pragma: + + pragma Restrictions (No_Entry_Calls_In_Elaboration_Code); + + This pragma can be placed in the `gnat.adc' file in the usual + manner. If we take our original unmodified program and compile it + in the presence of a `gnat.adc' containing the above pragma, then + once again, we can compile, bind, link, and execute, obtaining the + expected result. In the presence of this pragma, the compiler does + not trace calls in a task body, that appear after the first + `accept' or `select' statement, and therefore does not report a + potential circularity in the original program. + + The compiler will check to the extent it can that the above + restriction is not violated, but it is not always possible to do a + complete check at compile time, so it is important to use this + pragma only if the stated restriction is in fact met, that is to + say no task receives an entry call before elaboration of all units + is completed. + + +  + File: gnat_ug_unx.info, Node: Mixing Elaboration Models, Next: What to Do If the Default Elaboration Behavior Fails, Prev: Elaboration Issues for Library Tasks, Up: Elaboration Order Handling in GNAT + + Mixing Elaboration Models + ========================= + + So far, we have assumed that the entire program is either compiled + using the dynamic model or static model, ensuring consistency. It is + possible to mix the two models, but rules have to be followed if this + mixing is done to ensure that elaboration checks are not omitted. + + The basic rule is that _a unit compiled with the static model cannot + be `with'ed' by a unit compiled with the dynamic model_. The reason for + this is that in the static model, a unit assumes that its clients + guarantee to use (the equivalent of) pragma `Elaborate_All' so that no + elaboration checks are required in inner subprograms, and this + assumption is violated if the client is compiled with dynamic checks. + + The precise rule is as follows. A unit that is compiled with dynamic + checks can only `with' a unit that meets at least one of the following + criteria: + + * The `with'ed' unit is itself compiled with dynamic elaboration + checks (that is with the `-gnatE' switch. + + * The `with'ed' unit is an internal GNAT implementation unit from + the System, Interfaces, Ada, or GNAT hierarchies. + + * The `with'ed' unit has pragma Preelaborate or pragma Pure. + + * The `with'ing' unit (that is the client) has an explicit pragma + `Elaborate_All' for the `with'ed' unit. + + + If this rule is violated, that is if a unit with dynamic elaboration + checks `with's' a unit that does not meet one of the above four + criteria, then the binder (`gnatbind') will issue a warning similar to + that in the following example: + + warning: "x.ads" has dynamic elaboration checks and with's + warning: "y.ads" which has static elaboration checks + + These warnings indicate that the rule has been violated, and that as a + result elaboration checks may be missed in the resulting executable + file. This warning may be suppressed using the `-ws' binder switch in + the usual manner. + + One useful application of this mixing rule is in the case of a + subsystem which does not itself `with' units from the remainder of the + application. In this case, the entire subsystem can be compiled with + dynamic checks to resolve a circularity in the subsystem, while + allowing the main application that uses this subsystem to be compiled + using the more reliable default static model. + +  + File: gnat_ug_unx.info, Node: What to Do If the Default Elaboration Behavior Fails, Next: Elaboration for Access-to-Subprogram Values, Prev: Mixing Elaboration Models, Up: Elaboration Order Handling in GNAT + + What to Do If the Default Elaboration Behavior Fails + ==================================================== + + If the binder cannot find an acceptable order, it outputs detailed + diagnostics. For example: + error: elaboration circularity detected + info: "proc (body)" must be elaborated before "pack (body)" + info: reason: Elaborate_All probably needed in unit "pack (body)" + info: recompile "pack (body)" with -gnatwl + info: for full details + info: "proc (body)" + info: is needed by its spec: + info: "proc (spec)" + info: which is withed by: + info: "pack (body)" + info: "pack (body)" must be elaborated before "proc (body)" + info: reason: pragma Elaborate in unit "proc (body)" + + + In this case we have a cycle that the binder cannot break. On the one + hand, there is an explicit pragma Elaborate in `proc' for `pack'. This + means that the body of `pack' must be elaborated before the body of + `proc'. On the other hand, there is elaboration code in `pack' that + calls a subprogram in `proc'. This means that for maximum safety, there + should really be a pragma Elaborate_All in `pack' for `proc' which + would require that the body of `proc' be elaborated before the body of + `pack'. Clearly both requirements cannot be satisfied. Faced with a + circularity of this kind, you have three different options. + + Fix the program + The most desirable option from the point of view of long-term + maintenance is to rearrange the program so that the elaboration + problems are avoided. One useful technique is to place the + elaboration code into separate child packages. Another is to move + some of the initialization code to explicitly called subprograms, + where the program controls the order of initialization explicitly. + Although this is the most desirable option, it may be impractical + and involve too much modification, especially in the case of + complex legacy code. + + Perform dynamic checks + If the compilations are done using the `-gnatE' (dynamic + elaboration check) switch, then GNAT behaves in a quite different + manner. Dynamic checks are generated for all calls that could + possibly result in raising an exception. With this switch, the + compiler does not generate implicit `Elaborate_All' pragmas. The + behavior then is exactly as specified in the Ada 95 Reference + Manual. The binder will generate an executable program that may + or may not raise `Program_Error', and then it is the programmer's + job to ensure that it does not raise an exception. Note that it is + important to compile all units with the switch, it cannot be used + selectively. + + Suppress checks + The drawback of dynamic checks is that they generate a significant + overhead at run time, both in space and time. If you are + absolutely sure that your program cannot raise any elaboration + exceptions, and you still want to use the dynamic elaboration + model, then you can use the configuration pragma `Suppress + (Elaboration_Checks)' to suppress all such checks. For example + this pragma could be placed in the `gnat.adc' file. + + Suppress checks selectively + When you know that certain calls in elaboration code cannot + possibly lead to an elaboration error, and the binder nevertheless + generates warnings on those calls and inserts Elaborate_All + pragmas that lead to elaboration circularities, it is possible to + remove those warnings locally and obtain a program that will bind. + Clearly this can be unsafe, and it is the responsibility of the + programmer to make sure that the resulting program has no + elaboration anomalies. The pragma `Suppress (Elaboration_Check)' + can be used with different granularity to suppress warnings and + break elaboration circularities: + + * Place the pragma that names the called subprogram in the + declarative part that contains the call. + + * Place the pragma in the declarative part, without naming an + entity. This disables warnings on all calls in the + corresponding declarative region. + + * Place the pragma in the package spec that declares the called + subprogram, and name the subprogram. This disables warnings + on all elaboration calls to that subprogram. + + * Place the pragma in the package spec that declares the called + subprogram, without naming any entity. This disables warnings + on all elaboration calls to all subprograms declared in this + spec. + + These four cases are listed in order of decreasing safety, and + therefore require increasing programmer care in their application. + Consider the following program: + + package Pack1 is + function F1 return Integer; + X1 : Integer; + end Pack1; + + package Pack2 is + function F2 return Integer; + function Pure (x : integer) return integer; + -- pragma Suppress (Elaboration_Check, On => Pure); -- (3) + -- pragma Suppress (Elaboration_Check); -- (4) + end Pack2; + + with Pack2; + package body Pack1 is + function F1 return Integer is + begin + return 100; + end F1; + Val : integer := Pack2.Pure (11); -- Elab. call (1) + begin + declare + -- pragma Suppress(Elaboration_Check, Pack2.F2); -- (1) + -- pragma Suppress(Elaboration_Check); -- (2) + begin + X1 := Pack2.F2 + 1; -- Elab. call (2) + end; + end Pack1; + + with Pack1; + package body Pack2 is + function F2 return Integer is + begin + return Pack1.F1; + end F2; + function Pure (x : integer) return integer is + begin + return x ** 3 - 3 * x; + end; + end Pack2; + + with Pack1, Ada.Text_IO; + procedure Proc3 is + begin + Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101 + end Proc3; + In the absence of any pragmas, an attempt to bind this program + produces the following diagnostics: + error: elaboration circularity detected + info: "pack1 (body)" must be elaborated before "pack1 (body)" + info: reason: Elaborate_All probably needed in unit "pack1 (body)" + info: recompile "pack1 (body)" with -gnatwl for full details + info: "pack1 (body)" + info: must be elaborated along with its spec: + info: "pack1 (spec)" + info: which is withed by: + info: "pack2 (body)" + info: which must be elaborated along with its spec: + info: "pack2 (spec)" + info: which is withed by: + info: "pack1 (body)" + The sources of the circularity are the two calls to + `Pack2.Pure' and `Pack2.F2' in the body of `Pack1'. We can see + that the call to F2 is safe, even though F2 calls F1, because the + call appears after the elaboration of the body of F1. Therefore + the pragma (1) is safe, and will remove the warning on the call. + It is also possible to use pragma (2) because there are no other + potentially unsafe calls in the block. + + The call to `Pure' is safe because this function does not depend + on the state of `Pack2'. Therefore any call to this function is + safe, and it is correct to place pragma (3) in the corresponding + package spec. + + Finally, we could place pragma (4) in the spec of `Pack2' to + disable warnings on all calls to functions declared therein. Note + that this is not necessarily safe, and requires more detailed + examination of the subprogram bodies involved. In particular, a + call to `F2' requires that `F1' be already elaborated. + + It is hard to generalize on which of these four approaches should be + taken. Obviously if it is possible to fix the program so that the + default treatment works, this is preferable, but this may not always be + practical. It is certainly simple enough to use `-gnatE' but the + danger in this case is that, even if the GNAT binder finds a correct + elaboration order, it may not always do so, and certainly a binder from + another Ada compiler might not. A combination of testing and analysis + (for which the warnings generated with the `-gnatwl' switch can be + useful) must be used to ensure that the program is free of errors. One + switch that is useful in this testing is the `-p (pessimistic + elaboration order)' switch for `gnatbind'. Normally the binder tries + to find an order that has the best chance of of avoiding elaboration + problems. With this switch, the binder plays a devil's advocate role, + and tries to choose the order that has the best chance of failing. If + your program works even with this switch, then it has a better chance + of being error free, but this is still not a guarantee. + + For an example of this approach in action, consider the C-tests + (executable tests) from the ACVC suite. If these are compiled and run + with the default treatment, then all but one of them succeed without + generating any error diagnostics from the binder. However, there is one + test that fails, and this is not surprising, because the whole point of + this test is to ensure that the compiler can handle cases where it is + impossible to determine a correct order statically, and it checks that + an exception is indeed raised at run time. + + This one test must be compiled and run using the `-gnatE' switch, + and then it passes. Alternatively, the entire suite can be run using + this switch. It is never wrong to run with the dynamic elaboration + switch if your code is correct, and we assume that the C-tests are + indeed correct (it is less efficient, but efficiency is not a factor in + running the ACVC tests.) + +  + File: gnat_ug_unx.info, Node: Elaboration for Access-to-Subprogram Values, Next: Summary of Procedures for Elaboration Control, Prev: What to Do If the Default Elaboration Behavior Fails, Up: Elaboration Order Handling in GNAT + + Elaboration for Access-to-Subprogram Values + =========================================== + + The introduction of access-to-subprogram types in Ada 95 complicates + the handling of elaboration. The trouble is that it becomes impossible + to tell at compile time which procedure is being called. This means + that it is not possible for the binder to analyze the elaboration + requirements in this case. + + If at the point at which the access value is created (i.e., the + evaluation of `P'Access' for a subprogram `P'), the body of the + subprogram is known to have been elaborated, then the access value is + safe, and its use does not require a check. This may be achieved by + appropriate arrangement of the order of declarations if the subprogram + is in the current unit, or, if the subprogram is in another unit, by + using pragma `Pure', `Preelaborate', or `Elaborate_Body' on the + referenced unit. + + If the referenced body is not known to have been elaborated at the + point the access value is created, then any use of the access value + must do a dynamic check, and this dynamic check will fail and raise a + `Program_Error' exception if the body has not been elaborated yet. + GNAT will generate the necessary checks, and in addition, if the + `-gnatwl' switch is set, will generate warnings that such checks are + required. + + The use of dynamic dispatching for tagged types similarly generates + a requirement for dynamic checks, and premature calls to any primitive + operation of a tagged type before the body of the operation has been + elaborated, will result in the raising of `Program_Error'. + +  + File: gnat_ug_unx.info, Node: Summary of Procedures for Elaboration Control, Next: Other Elaboration Order Considerations, Prev: Elaboration for Access-to-Subprogram Values, Up: Elaboration Order Handling in GNAT + + Summary of Procedures for Elaboration Control + ============================================= + + First, compile your program with the default options, using none of the + special elaboration control switches. If the binder successfully binds + your program, then you can be confident that, apart from issues raised + by the use of access-to-subprogram types and dynamic dispatching, the + program is free of elaboration errors. If it is important that the + program be portable, then use the `-gnatwl' switch to generate warnings + about missing `Elaborate_All' pragmas, and supply the missing pragmas. + + If the program fails to bind using the default static elaboration + handling, then you can fix the program to eliminate the binder message, + or recompile the entire program with the `-gnatE' switch to generate + dynamic elaboration checks, and, if you are sure there really are no + elaboration problems, use a global pragma `Suppress + (Elaboration_Checks)'. + +  + File: gnat_ug_unx.info, Node: Other Elaboration Order Considerations, Prev: Summary of Procedures for Elaboration Control, Up: Elaboration Order Handling in GNAT + + Other Elaboration Order Considerations + ====================================== + + This section has been entirely concerned with the issue of finding a + valid elaboration order, as defined by the Ada Reference Manual. In a + case where several elaboration orders are valid, the task is to find one + of the possible valid elaboration orders (and the static model in GNAT + will ensure that this is achieved). + + The purpose of the elaboration rules in the Ada Reference Manual is + to make sure that no entity is accessed before it has been elaborated. + For a subprogram, this means that the spec and body must have been + elaborated before the subprogram is called. For an object, this means + that the object must have been elaborated before its value is read or + written. A violation of either of these two requirements is an access + before elaboration order, and this section has been all about avoiding + such errors. + + In the case where more than one order of elaboration is possible, in + the sense that access before elaboration errors are avoided, then any + one of the orders is "correct" in the sense that it meets the + requirements of the Ada Reference Manual, and no such error occurs. + + However, it may be the case for a given program, that there are + constraints on the order of elaboration that come not from consideration + of avoiding elaboration errors, but rather from extra-lingual logic + requirements. Consider this example: + + with Init_Constants; + package Constants is + X : Integer := 0; + Y : Integer := 0; + end Constants; + + package Init_Constants is + procedure Calc; + end Init_Constants; + + with Constants; + package body Init_Constants is + procedure Calc is begin null; end; + begin + Constants.X := 3; + Constants.Y := 4; + end Init_Constants; + + with Constants; + package Calc is + Z : Integer := Constants.X + Constants.Y; + end Calc; + + with Calc; + with Text_IO; use Text_IO; + procedure Main is + begin + Put_Line (Calc.Z'Img); + end Main; + + In this example, there is more than one valid order of elaboration. For + example both the following are correct orders: + + Init_Constants spec + Constants spec + Calc spec + Main body + Init_Constants body + + and + + Init_Constants spec + Init_Constants body + Constants spec + Calc spec + Main body + + There is no language rule to prefer one or the other, both are correct + from an order of elaboration point of view. But the programmatic effects + of the two orders are very different. In the first, the elaboration + routine of `Calc' initializes `Z' to zero, and then the main program + runs with this value of zero. But in the second order, the elaboration + routine of `Calc' runs after the body of Init_Constants has set `X' and + `Y' and thus `Z' is set to 7 before `Main' runs. + + One could perhaps by applying pretty clever non-artificial + intelligence to the situation guess that it is more likely that the + second order of elaboration is the one desired, but there is no formal + linguistic reason to prefer one over the other. In fact in this + particular case, GNAT will prefer the second order, because of the rule + that bodies are elaborated as soon as possible, but it's just luck that + this is what was wanted (if indeed the second order was preferred). + + If the program cares about the order of elaboration routines in a + case like this, it is important to specify the order required. In this + particular case, that could have been achieved by adding to the spec of + Calc: + + pragma Elaborate_All (Constants); + + which requires that the body (if any) and spec of `Constants', as well + as the body and spec of any unit `with''ed by `Constants' be elaborated + before `Calc' is elaborated. + + Clearly no automatic method can always guess which alternative you + require, and if you are working with legacy code that had constraints + of this kind which were not properly specified by adding `Elaborate' or + `Elaborate_All' pragmas, then indeed it is possible that two different + compilers can choose different orders. + + The `gnatbind' `-p' switch may be useful in smoking out problems. + This switch causes bodies to be elaborated as late as possible instead + of as early as possible. In the example above, it would have forced the + choice of the first elaboration order. If you get different results + when using this switch, and particularly if one set of results is right, + and one is wrong as far as you are concerned, it shows that you have + some missing `Elaborate' pragmas. For the example above, we have the + following output: + + gnatmake -f -q main + main + 7 + gnatmake -f -q main -bargs -p + main + 0 + + It is of course quite unlikely that both these results are correct, so + it is up to you in a case like this to investigate the source of the + difference, by looking at the two elaboration orders that are chosen, + and figuring out which is correct, and then adding the necessary + `Elaborate_All' pragmas to ensure the desired order. + +  + File: gnat_ug_unx.info, Node: The Cross-Referencing Tools gnatxref and gnatfind, Next: File Name Krunching Using gnatkr, Prev: Elaboration Order Handling in GNAT, Up: Top + + The Cross-Referencing Tools `gnatxref' and `gnatfind' + ***************************************************** + + The compiler generates cross-referencing information (unless you set + the `-gnatx' switch), which are saved in the `.ali' files. This + information indicates where in the source each entity is declared and + referenced. Note that entities in package Standard are not included, but + entities in all other predefined units are included in the output. + + Before using any of these two tools, you need to compile + successfully your application, so that GNAT gets a chance to generate + the cross-referencing information. + + The two tools `gnatxref' and `gnatfind' take advantage of this + information to provide the user with the capability to easily locate the + declaration and references to an entity. These tools are quite similar, + the difference being that `gnatfind' is intended for locating + definitions and/or references to a specified entity or entities, whereas + `gnatxref' is oriented to generating a full report of all + cross-references. + + To use these tools, you must not compile your application using the + `-gnatx' switch on the `gnatmake' command line (*note (gnat_ug)The GNAT + Make Program gnatmake::). Otherwise, cross-referencing information will + not be generated. + + * Menu: + + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + +  + File: gnat_ug_unx.info, Node: gnatxref Switches, Next: gnatfind Switches, Up: The Cross-Referencing Tools gnatxref and gnatfind + + `gnatxref' Switches + =================== + + The command lines for `gnatxref' is: + $ gnatxref [switches] sourcefile1 [sourcefile2 ...] + + where + + `sourcefile1, sourcefile2' + identifies the source files for which a report is to be generated. + The 'with'ed units will be processed too. You must provide at + least one file. + + These file names are considered to be regular expressions, so for + instance specifying 'source*.adb' is the same as giving every file + in the current directory whose name starts with 'source' and whose + extension is 'adb'. + + The switches can be : + `-a' + If this switch is present, `gnatfind' and `gnatxref' will parse + the read-only files found in the library search path. Otherwise, + these files will be ignored. This option can be used to protect + Gnat sources or your own libraries from being parsed, thus making + `gnatfind' and `gnatxref' much faster, and their output much + smaller. + + `-aIDIR' + When looking for source files also look in directory DIR. The + order in which source file search is undertaken is the same as for + `gnatmake'. + + `-aODIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as + for `gnatmake'. + + `-nostdinc' + Do not look for sources in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-d' + If this switch is set `gnatxref' will output the parent type + reference for each matching derived types. + + `-f' + If this switch is set, the output file names will be preceded by + their directory (if the file was found in the search path). If + this switch is not set, the directory will not be printed. + + `-g' + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may + accelerate `gnatfind' and `gnatxref'. + + `-IDIR' + Equivalent to `-aODIR -aIDIR'. + + `-pFILE' + Specify a project file to use *Note Project Files::. By default, + `gnatxref' and `gnatfind' will try to locate a project file in the + current directory. + + If a project file is either specified or found by the tools, then + the content of the source directory and object directory lines are + added as if they had been specified respectively by `-aI' and + `-aO'. + + `-u' + Output only unused symbols. This may be really useful if you give + your main compilation unit on the command line, as `gnatxref' will + then display every unused entity and 'with'ed package. + + `-v' + Instead of producing the default output, `gnatxref' will generate a + `tags' file that can be used by vi. For examples how to use this + feature, see *Note Examples of gnatxref Usage::. The tags file is + output to the standard output, thus you will have to redirect it + to a file. + + All these switches may be in any order on the command line, and may + even appear after the file names. They need not be separated by spaces, + thus you can say `gnatxref -ag' instead of `gnatxref -a -g'. + +  + File: gnat_ug_unx.info, Node: gnatfind Switches, Next: Project Files for gnatxref and gnatfind, Prev: gnatxref Switches, Up: The Cross-Referencing Tools gnatxref and gnatfind + + `gnatfind' Switches + =================== + + The command line for `gnatfind' is: + + $ gnatfind [switches] pattern[:sourcefile[:line[:column]]] + [file1 file2 ...] + + where + + `pattern' + An entity will be output only if it matches the regular expression + found in `pattern', see *Note Regular Expressions in gnatfind and + gnatxref::. + + Omitting the pattern is equivalent to specifying `*', which will + match any entity. Note that if you do not provide a pattern, you + have to provide both a sourcefile and a line. + + Entity names are given in Latin-1, with uppercase/lowercase + equivalence for matching purposes. At the current time there is no + support for 8-bit codes other than Latin-1, or for wide characters + in identifiers. + + `sourcefile' + `gnatfind' will look for references, bodies or declarations of + symbols referenced in `sourcefile', at line `line' and column + `column'. See *note Examples of gnatfind Usage:: for syntax + examples. + + `line' + is a decimal integer identifying the line number containing the + reference to the entity (or entities) to be located. + + `column' + is a decimal integer identifying the exact location on the line of + the first character of the identifier for the entity reference. + Columns are numbered from 1. + + `file1 file2 ...' + The search will be restricted to these files. If none are given, + then the search will be done for every library file in the search + path. These file must appear only after the pattern or sourcefile. + + These file names are considered to be regular expressions, so for + instance specifying 'source*.adb' is the same as giving every file + in the current directory whose name starts with 'source' and whose + extension is 'adb'. + + Not that if you specify at least one file in this part, `gnatfind' + may sometimes not be able to find the body of the subprograms... + + At least one of 'sourcefile' or 'pattern' has to be present on the + command line. + + The following switches are available: + `-a' + If this switch is present, `gnatfind' and `gnatxref' will parse + the read-only files found in the library search path. Otherwise, + these files will be ignored. This option can be used to protect + Gnat sources or your own libraries from being parsed, thus making + `gnatfind' and `gnatxref' much faster, and their output much + smaller. + + `-aIDIR' + When looking for source files also look in directory DIR. The + order in which source file search is undertaken is the same as for + `gnatmake'. + + `-aODIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as + for `gnatmake'. + + `-nostdinc' + Do not look for sources in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-d' + If this switch is set, then `gnatfind' will output the parent type + reference for each matching derived types. + + `-e' + By default, `gnatfind' accept the simple regular expression set for + `pattern'. If this switch is set, then the pattern will be + considered as full Unix-style regular expression. + + `-f' + If this switch is set, the output file names will be preceded by + their directory (if the file was found in the search path). If + this switch is not set, the directory will not be printed. + + `-g' + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may + accelerate `gnatfind' and `gnatxref'. + + `-IDIR' + Equivalent to `-aODIR -aIDIR'. + + `-pFILE' + Specify a project file (*note Project Files::) to use. By + default, `gnatxref' and `gnatfind' will try to locate a project + file in the current directory. + + If a project file is either specified or found by the tools, then + the content of the source directory and object directory lines are + added as if they had been specified respectively by `-aI' and + `-aO'. + + `-r' + By default, `gnatfind' will output only the information about the + declaration, body or type completion of the entities. If this + switch is set, the `gnatfind' will locate every reference to the + entities in the files specified on the command line (or in every + file in the search path if no file is given on the command line). + + `-s' + If this switch is set, then `gnatfind' will output the content of + the Ada source file lines were the entity was found. + + `-t' + If this switch is set, then `gnatfind' will output the type + hierarchy for the specified type. It act like -d option but + recursively from parent type to parent type. When this switch is + set it is not possible to specify more than one file. + + All these switches may be in any order on the command line, and may + even appear after the file names. They need not be separated by spaces, + thus you can say `gnatxref -ag' instead of `gnatxref -a -g'. + + As stated previously, gnatfind will search in every directory in the + search path. You can force it to look only in the current directory if + you specify `*' at the end of the command line. + +  + File: gnat_ug_unx.info, Node: Project Files for gnatxref and gnatfind, Next: Regular Expressions in gnatfind and gnatxref, Prev: gnatfind Switches, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Project Files for `gnatxref' and `gnatfind' + =========================================== + + Project files allow a programmer to specify how to compile its + application, where to find sources,... These files are used primarily by + the Glide Ada mode, but they can also be used by the two tools + `gnatxref' and `gnatfind'. + + A project file name must end with `.adp'. If a single one is present + in the current directory, then `gnatxref' and `gnatfind' will extract + the information from it. If multiple project files are found, none of + them is read, and you have to use the `-p' switch to specify the one + you want to use. + + The following lines can be included, even though most of them have + default values which can be used in most cases. The lines can be + entered in any order in the file. Except for `src_dir' and `obj_dir', + you can only have one instance of each line. If you have multiple + instances, only the last one is taken into account. + + `src_dir=DIR [default: "./"]' + specifies a directory where to look for source files. Multiple + src_dir lines can be specified and they will be searched in the + order they are specified. + + `obj_dir=DIR [default: "./"]' + specifies a directory where to look for object and library files. + Multiple obj_dir lines can be specified and they will be searched + in the order they are specified + + `comp_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${comp_opt}' notation. This is intended to store the default + switches given to `gnatmake' and `gcc'. + + `bind_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${bind_opt}' notation. This is intended to store the default + switches given to `gnatbind'. + + `link_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${link_opt}' notation. This is intended to store the default + switches given to `gnatlink'. + + `main=EXECUTABLE [default: ""]' + specifies the name of the executable for the application. This + variable can be referred to in the following lines by using the + `${main}' notation. + + `comp_cmd=COMMAND [default: "gcc -c -I${src_dir} -g -gnatq"]' + specifies the command used to compile a single file in the + application. + + `make_cmd=COMMAND [default: "gnatmake ${main} -aI${src_dir} -aO${obj_dir} -g -gnatq -cargs ${comp_opt} -bargs ${bind_opt} -largs ${link_opt}"]' + specifies the command used to recompile the whole application. + + `run_cmd=COMMAND [default: "${main}"]' + specifies the command used to run the application. + + `debug_cmd=COMMAND [default: "gdb ${main}"]' + specifies the command used to debug the application + + `gnatxref' and `gnatfind' only take into account the `src_dir' and + `obj_dir' lines, and ignore the others. + +  + File: gnat_ug_unx.info, Node: Regular Expressions in gnatfind and gnatxref, Next: Examples of gnatxref Usage, Prev: Project Files for gnatxref and gnatfind, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Regular Expressions in `gnatfind' and `gnatxref' + ================================================ + + As specified in the section about `gnatfind', the pattern can be a + regular expression. Actually, there are to set of regular expressions + which are recognized by the program : + + `globbing patterns' + These are the most usual regular expression. They are the same + that you generally used in a Unix shell command line, or in a DOS + session. + + Here is a more formal grammar : + regexp ::= term + term ::= elmt -- matches elmt + term ::= elmt elmt -- concatenation (elmt then elmt) + term ::= * -- any string of 0 or more characters + term ::= ? -- matches any character + term ::= [char {char}] -- matches any character listed + term ::= [char - char] -- matches any character in range + + `full regular expression' + The second set of regular expressions is much more powerful. This + is the type of regular expressions recognized by utilities such a + `grep'. + + The following is the form of a regular expression, expressed in Ada + reference manual style BNF is as follows + + regexp ::= term {| term} -- alternation (term or term ...) + + term ::= item {item} -- concatenation (item then item) + + item ::= elmt -- match elmt + item ::= elmt * -- zero or more elmt's + item ::= elmt + -- one or more elmt's + item ::= elmt ? -- matches elmt or nothing + elmt ::= nschar -- matches given character + elmt ::= [nschar {nschar}] -- matches any character listed + elmt ::= [^ nschar {nschar}] -- matches any character not listed + elmt ::= [char - char] -- matches chars in given range + elmt ::= \ char -- matches given character + elmt ::= . -- matches any single character + elmt ::= ( regexp ) -- parens used for grouping + + char ::= any character, including special characters + nschar ::= any character except ()[].*+?^ + + Following are a few examples : + + `abcde|fghi' + will match any of the two strings 'abcde' and 'fghi'. + + `abc*d' + will match any string like 'abd', 'abcd', 'abccd', 'abcccd', + and so on + + `[a-z]+' + will match any string which has only lowercase characters in + it (and at least one character + +  + File: gnat_ug_unx.info, Node: Examples of gnatxref Usage, Next: Examples of gnatfind Usage, Prev: Regular Expressions in gnatfind and gnatxref, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Examples of `gnatxref' Usage + ============================ + + General Usage + ------------- + + For the following examples, we will consider the following units : + + main.ads: + 1: with Bar; + 2: package Main is + 3: procedure Foo (B : in Integer); + 4: C : Integer; + 5: private + 6: D : Integer; + 7: end Main; + + main.adb: + 1: package body Main is + 2: procedure Foo (B : in Integer) is + 3: begin + 4: C := B; + 5: D := B; + 6: Bar.Print (B); + 7: Bar.Print (C); + 8: end Foo; + 9: end Main; + + bar.ads: + 1: package Bar is + 2: procedure Print (B : Integer); + 3: end bar; + + The first thing to do is to recompile your application (for + instance, in that case just by doing a `gnatmake main', so that + GNAT generates the cross-referencing information. You can then + issue any of the following commands: + + `gnatxref main.adb' + `gnatxref' generates cross-reference information for main.adb and + every unit 'with'ed by main.adb. + + The output would be: + B Type: Integer + Decl: bar.ads 2:22 + B Type: Integer + Decl: main.ads 3:20 + Body: main.adb 2:20 + Ref: main.adb 4:13 5:13 6:19 + Bar Type: Unit + Decl: bar.ads 1:9 + Ref: main.adb 6:8 7:8 + main.ads 1:6 + C Type: Integer + Decl: main.ads 4:5 + Modi: main.adb 4:8 + Ref: main.adb 7:19 + D Type: Integer + Decl: main.ads 6:5 + Modi: main.adb 5:8 + Foo Type: Unit + Decl: main.ads 3:15 + Body: main.adb 2:15 + Main Type: Unit + Decl: main.ads 2:9 + Body: main.adb 1:14 + Print Type: Unit + Decl: bar.ads 2:15 + Ref: main.adb 6:12 7:12 + + that is the entity `Main' is declared in main.ads, line 2, column + 9, its body is in main.adb, line 1, column 14 and is not + referenced any where. + + The entity `Print' is declared in bar.ads, line 2, column 15 and it + it referenced in main.adb, line 6 column 12 and line 7 column 12. + + `gnatxref package1.adb package2.ads' + `gnatxref' will generates cross-reference information for + package1.adb, package2.ads and any other package 'with'ed by any + of these. + + Using gnatxref with vi + ---------------------- + + `gnatxref' can generate a tags file output, which can be used + directly from `vi'. Note that the standard version of `vi' will not + work properly with overloaded symbols. Consider using another free + implementation of `vi', such as `vim'. + + $ gnatxref -v gnatfind.adb > tags + + will generate the tags file for `gnatfind' itself (if the sources are + in the search path!). + + From `vi', you can then use the command `:tag entity' (replacing + entity by whatever you are looking for), and vi will display a new file + with the corresponding declaration of entity. + +  + File: gnat_ug_unx.info, Node: Examples of gnatfind Usage, Prev: Examples of gnatxref Usage, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Examples of `gnatfind' Usage + ============================ + + `gnatfind -f xyz:main.adb' + Find declarations for all entities xyz referenced at least once in + main.adb. The references are search in every library file in the + search path. + + The directories will be printed as well (as the `-f' switch is set) + + The output will look like: + directory/main.ads:106:14: xyz <= declaration + directory/main.adb:24:10: xyz <= body + directory/foo.ads:45:23: xyz <= declaration + + that is to say, one of the entities xyz found in main.adb is + declared at line 12 of main.ads (and its body is in main.adb), and + another one is declared at line 45 of foo.ads + + `gnatfind -fs xyz:main.adb' + This is the same command as the previous one, instead `gnatfind' + will display the content of the Ada source file lines. + + The output will look like: + + directory/main.ads:106:14: xyz <= declaration + procedure xyz; + directory/main.adb:24:10: xyz <= body + procedure xyz is + directory/foo.ads:45:23: xyz <= declaration + xyz : Integer; + + This can make it easier to find exactly the location your are + looking for. + + `gnatfind -r "*x*":main.ads:123 foo.adb' + Find references to all entities containing an x that are + referenced on line 123 of main.ads. The references will be + searched only in main.adb and foo.adb. + + `gnatfind main.ads:123' + Find declarations and bodies for all entities that are referenced + on line 123 of main.ads. + + This is the same as `gnatfind "*":main.adb:123'. + + `gnatfind mydir/main.adb:123:45' + Find the declaration for the entity referenced at column 45 in + line 123 of file main.adb in directory mydir. Note that it is + usual to omit the identifier name when the column is given, since + the column position identifies a unique reference. + + The column has to be the beginning of the identifier, and should + not point to any character in the middle of the identifier. + +  + File: gnat_ug_unx.info, Node: File Name Krunching Using gnatkr, Next: Preprocessing Using gnatprep, Prev: The Cross-Referencing Tools gnatxref and gnatfind, Up: Top + + File Name Krunching Using `gnatkr' + ********************************** + + This chapter discusses the method used by the compiler to shorten the + default file names chosen for Ada units so that they do not exceed the + maximum length permitted. It also describes the `gnatkr' utility that + can be used to determine the result of applying this shortening. + + * Menu: + + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + +  + File: gnat_ug_unx.info, Node: About gnatkr, Next: Using gnatkr, Up: File Name Krunching Using gnatkr + + About `gnatkr' + ============== + + The default file naming rule in GNAT is that the file name must be + derived from the unit name. The exact default rule is as follows: + * Take the unit name and replace all dots by hyphens. + + * If such a replacement occurs in the second character position of a + name, and the first character is a, g, s, or i then replace the + dot by the character ~ (tilde) instead of a minus. + The reason for this exception is to avoid clashes with the standard + names for children of System, Ada, Interfaces, and GNAT, which use the + prefixes s- a- i- and g- respectively. + + The `-gnatkNN' switch of the compiler activates a "krunching" + circuit that limits file names to nn characters (where nn is a decimal + integer). For example, using OpenVMS, where the maximum file name + length is 39, the value of nn is usually set to 39, but if you want to + generate a set of files that would be usable if ported to a system with + some different maximum file length, then a different value can be + specified. The default value of 39 for OpenVMS need not be specified. + + The `gnatkr' utility can be used to determine the krunched name for + a given file, when krunched to a specified maximum length. + +  + File: gnat_ug_unx.info, Node: Using gnatkr, Next: Krunching Method, Prev: About gnatkr, Up: File Name Krunching Using gnatkr + + Using `gnatkr' + ============== + + The `gnatkr' command has the form + + $ gnatkr NAME [LENGTH] + + NAME can be an Ada name with dots or the GNAT name of the unit, where + the dots representing child units or subunit are replaced by hyphens. + The only confusion arises if a name ends in `.ads' or `.adb'. `gnatkr' + takes this to be an extension if there are no other dots in the name + and the whole name is in lowercase. + + LENGTH represents the length of the krunched name. The default when + no argument is given is 8 characters. A length of zero stands for + unlimited, in other words do not chop except for system files which are + always 8. + + The output is the krunched name. The output has an extension only if the + original argument was a file name with an extension. + +  + File: gnat_ug_unx.info, Node: Krunching Method, Next: Examples of gnatkr Usage, Prev: Using gnatkr, Up: File Name Krunching Using gnatkr + + Krunching Method + ================ + + The initial file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + lowercase for all letters, except that a hyphen in the second character + position is replaced by a tilde if the first character is a, i, g, or s. + The extension is `.ads' for a specification and `.adb' for a body. + Krunching does not affect the extension, but the file name is shortened + to the specified length by following these rules: + + * The name is divided into segments separated by hyphens, tildes or + underscores and all hyphens, tildes, and underscores are + eliminated. If this leaves the name short enough, we are done. + + * If the name is too long, the longest segment is located (left-most + if there are two of equal length), and shortened by dropping its + last character. This is repeated until the name is short enough. + + As an example, consider the krunching of + `our-strings-wide_fixed.adb' to fit the name into 8 characters as + required by some operating systems. + + our-strings-wide_fixed 22 + our strings wide fixed 19 + our string wide fixed 18 + our strin wide fixed 17 + our stri wide fixed 16 + our stri wide fixe 15 + our str wide fixe 14 + our str wid fixe 13 + our str wid fix 12 + ou str wid fix 11 + ou st wid fix 10 + ou st wi fix 9 + ou st wi fi 8 + Final file name: oustwifi.adb + + * The file names for all predefined units are always krunched to + eight characters. The krunching of these predefined units uses the + following special prefix replacements: + + `ada-' + replaced by `a-' + + `gnat-' + replaced by `g-' + + `interfaces-' + replaced by `i-' + + `system-' + replaced by `s-' + + These system files have a hyphen in the second character position. + That is why normal user files replace such a character with a + tilde, to avoid confusion with system file names. + + As an example of this special rule, consider + `ada-strings-wide_fixed.adb', which gets krunched as follows: + + ada-strings-wide_fixed 22 + a- strings wide fixed 18 + a- string wide fixed 17 + a- strin wide fixed 16 + a- stri wide fixed 15 + a- stri wide fixe 14 + a- str wide fixe 13 + a- str wid fixe 12 + a- str wid fix 11 + a- st wid fix 10 + a- st wi fix 9 + a- st wi fi 8 + Final file name: a-stwifi.adb + + Of course no file shortening algorithm can guarantee uniqueness over + all possible unit names, and if file name krunching is used then it is + your responsibility to ensure that no name clashes occur. The utility + program `gnatkr' is supplied for conveniently determining the krunched + name of a file. + +  + File: gnat_ug_unx.info, Node: Examples of gnatkr Usage, Prev: Krunching Method, Up: File Name Krunching Using gnatkr + + Examples of `gnatkr' Usage + ========================== + + $ gnatkr very_long_unit_name.ads --> velounna.ads + $ gnatkr grandparent-parent-child.ads --> grparchi.ads + $ gnatkr Grandparent.Parent.Child --> grparchi + $ gnatkr very_long_unit_name.ads/count=6 --> vlunna.ads + $ gnatkr very_long_unit_name.ads/count=0 --> very_long_unit_name.ads + +  + File: gnat_ug_unx.info, Node: Preprocessing Using gnatprep, Next: The GNAT Library Browser gnatls, Prev: File Name Krunching Using gnatkr, Up: Top + + Preprocessing Using `gnatprep' + ****************************** + + The `gnatprep' utility provides a simple preprocessing capability for + Ada programs. It is designed for use with GNAT, but is not dependent + on any special features of GNAT. + + * Menu: + + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + +  + File: gnat_ug_unx.info, Node: Using gnatprep, Next: Switches for gnatprep, Up: Preprocessing Using gnatprep + + Using `gnatprep' + ================ + + To call `gnatprep' use + + $ gnatprep [-bcrsu] [-Dsymbol=value] infile outfile [deffile] + + where + `infile' + is the full name of the input file, which is an Ada source file + containing preprocessor directives. + + `outfile' + is the full name of the output file, which is an Ada source in + standard Ada form. When used with GNAT, this file name will + normally have an ads or adb suffix. + + `deffile' + is the full name of a text file containing definitions of symbols + to be referenced by the preprocessor. This argument is optional, + and can be replaced by the use of the `-D' switch. + + `switches' + is an optional sequence of switches as described in the next + section. + +  + File: gnat_ug_unx.info, Node: Switches for gnatprep, Next: Form of Definitions File, Prev: Using gnatprep, Up: Preprocessing Using gnatprep + + Switches for `gnatprep' + ======================= + + `-b' + Causes both preprocessor lines and the lines deleted by + preprocessing to be replaced by blank lines in the output source + file, preserving line numbers in the output file. + + `-c' + Causes both preprocessor lines and the lines deleted by + preprocessing to be retained in the output source as comments + marked with the special string "-! ". This option will result in + line numbers being preserved in the output file. + + `-Dsymbol=value' + Defines a new symbol, associated with value. If no value is given + on the command line, then symbol is considered to be `True'. This + switch can be used in place of a definition file. + + `-r' + Causes a `Source_Reference' pragma to be generated that references + the original input file, so that error messages will use the file + name of this original file. The use of this switch implies that + preprocessor lines are not to be removed from the file, so its use + will force `-b' mode if `-c' has not been specified explicitly. + + Note that if the file to be preprocessed contains multiple units, + then it will be necessary to `gnatchop' the output file from + `gnatprep'. If a `Source_Reference' pragma is present in the + preprocessed file, it will be respected by `gnatchop -r' so that + the final chopped files will correctly refer to the original input + source file for `gnatprep'. + + `-s' + Causes a sorted list of symbol names and values to be listed on + the standard output file. + + `-u' + Causes undefined symbols to be treated as having the value FALSE + in the context of a preprocessor test. In the absence of this + option, an undefined symbol in a `#if' or `#elsif' test will be + treated as an error. + + Note: if neither `-b' nor `-c' is present, then preprocessor lines and + deleted lines are completely removed from the output, unless -r is + specified, in which case -b is assumed. + +  + File: gnat_ug_unx.info, Node: Form of Definitions File, Next: Form of Input Text for gnatprep, Prev: Switches for gnatprep, Up: Preprocessing Using gnatprep + + Form of Definitions File + ======================== + + The definitions file contains lines of the form + + symbol := value + + where symbol is an identifier, following normal Ada (case-insensitive) + rules for its syntax, and value is one of the following: + + * Empty, corresponding to a null substitution + + * A string literal using normal Ada syntax + + * Any sequence of characters from the set (letters, digits, period, + underline). + + Comment lines may also appear in the definitions file, starting with + the usual `--', and comments may be added to the definitions lines. + +  + File: gnat_ug_unx.info, Node: Form of Input Text for gnatprep, Prev: Form of Definitions File, Up: Preprocessing Using gnatprep + + Form of Input Text for `gnatprep' + ================================= + + The input text may contain preprocessor conditional inclusion lines, as + well as general symbol substitution sequences. + + The preprocessor conditional inclusion commands have the form + + #if expression [then] + lines + #elsif expression [then] + lines + #elsif expression [then] + lines + ... + #else + lines + #end if; + + In this example, expression is defined by the following grammar: + expression ::= + expression ::= = "" + expression ::= = + expression ::= 'Defined + expression ::= not expression + expression ::= expression and expression + expression ::= expression or expression + expression ::= expression and then expression + expression ::= expression or else expression + expression ::= ( expression ) + + For the first test (expression ::= ) the symbol must have + either the value true or false, that is to say the right-hand of the + symbol definition must be one of the (case-insensitive) literals `True' + or `False'. If the value is true, then the corresponding lines are + included, and if the value is false, they are excluded. + + The test (expression ::= `'Defined') is true only if the + symbol has been defined in the definition file or by a `-D' switch on + the command line. Otherwise, the test is false. + + The equality tests are case insensitive, as are all the preprocessor + lines. + + If the symbol referenced is not defined in the symbol definitions + file, then the effect depends on whether or not switch `-u' is + specified. If so, then the symbol is treated as if it had the value + false and the test fails. If this switch is not specified, then it is + an error to reference an undefined symbol. It is also an error to + reference a symbol that is defined with a value other than `True' or + `False'. + + The use of the `not' operator inverts the sense of this logical + test, so that the lines are included only if the symbol is not defined. + The `then' keyword is optional as shown + + The `#' must be the first non-blank character on a line, but + otherwise the format is free form. Spaces or tabs may appear between + the `#' and the keyword. The keywords and the symbols are case + insensitive as in normal Ada code. Comments may be used on a + preprocessor line, but other than that, no other tokens may appear on a + preprocessor line. Any number of `elsif' clauses can be present, + including none at all. The `else' is optional, as in Ada. + + The `#' marking the start of a preprocessor line must be the first + non-blank character on the line, i.e. it must be preceded only by + spaces or horizontal tabs. + + Symbol substitution outside of preprocessor lines is obtained by + using the sequence + + $symbol + + anywhere within a source line, except in a comment or within a string + literal. The identifier following the `$' must match one of the symbols + defined in the symbol definition file, and the result is to substitute + the value of the symbol in place of `$symbol' in the output file. + + Note that although the substitution of strings within a string + literal is not possible, it is possible to have a symbol whose defined + value is a string literal. So instead of setting XYZ to `hello' and + writing: + + Header : String := "$XYZ"; + + you should set XYZ to `"hello"' and write: + + Header : String := $XYZ; + + and then the substitution will occur as desired. + +  + File: gnat_ug_unx.info, Node: The GNAT Library Browser gnatls, Next: GNAT and Libraries, Prev: Preprocessing Using gnatprep, Up: Top + + The GNAT Library Browser `gnatls' + ********************************* + + `gnatls' is a tool that outputs information about compiled units. It + gives the relationship between objects, unit names and source files. It + can also be used to check the source dependencies of a unit as well as + various characteristics. + + * Menu: + + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + +  + File: gnat_ug_unx.info, Node: Running gnatls, Next: Switches for gnatls, Up: The GNAT Library Browser gnatls + + Running `gnatls' + ================ + + The `gnatls' command has the form + + $ gnatls switches OBJECT_OR_ALI_FILE + + The main argument is the list of object or `ali' files (*note The Ada + Library Information Files::) for which information is requested. + + In normal mode, without additional option, `gnatls' produces a + four-column listing. Each line represents information for a specific + object. The first column gives the full path of the object, the second + column gives the name of the principal unit in this object, the third + column gives the status of the source and the fourth column gives the + full path of the source representing this unit. Here is a simple + example of use: + + $ gnatls *.o + ./demo1.o demo1 DIF demo1.adb + ./demo2.o demo2 OK demo2.adb + ./hello.o h1 OK hello.adb + ./instr-child.o instr.child MOK instr-child.adb + ./instr.o instr OK instr.adb + ./tef.o tef DIF tef.adb + ./text_io_example.o text_io_example OK text_io_example.adb + ./tgef.o tgef DIF tgef.adb + + The first line can be interpreted as follows: the main unit which is + contained in object file `demo1.o' is demo1, whose main source is in + `demo1.adb'. Furthermore, the version of the source used for the + compilation of demo1 has been modified (DIF). Each source file has a + status qualifier which can be: + + `OK (unchanged)' + The version of the source file used for the compilation of the + specified unit corresponds exactly to the actual source file. + + `MOK (slightly modified)' + The version of the source file used for the compilation of the + specified unit differs from the actual source file but not enough + to require recompilation. If you use gnatmake with the qualifier + `-m (minimal recompilation)', a file marked MOK will not be + recompiled. + + `DIF (modified)' + No version of the source found on the path corresponds to the + source used to build this object. + + `??? (file not found)' + No source file was found for this unit. + + `HID (hidden, unchanged version not first on PATH)' + The version of the source that corresponds exactly to the source + used for compilation has been found on the path but it is hidden + by another version of the same source that has been modified. + +  + File: gnat_ug_unx.info, Node: Switches for gnatls, Next: Examples of gnatls Usage, Prev: Running gnatls, Up: The GNAT Library Browser gnatls + + Switches for `gnatls' + ===================== + + `gnatls' recognizes the following switches: + + `-a' + Consider all units, including those of the predefined Ada library. + Especially useful with `-d'. + + `-d' + List sources from which specified units depend on. + + `-h' + Output the list of options. + + `-o' + Only output information about object files. + + `-s' + Only output information about source files. + + `-u' + Only output information about compilation units. + + `-aODIR' + `-aIDIR' + `-IDIR' + `-I-' + `-nostdinc' + Source path manipulation. Same meaning as the equivalent + `gnatmake' flags (see *Note Switches for gnatmake::). + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-v' + Verbose mode. Output the complete source and object paths. Do not + use the default column layout but instead use long format giving + as much as information possible on each requested units, including + special characteristics such as: + + `Preelaborable' + The unit is preelaborable in the Ada 95 sense. + + `No_Elab_Code' + No elaboration code has been produced by the compiler for + this unit. + + `Pure' + The unit is pure in the Ada 95 sense. + + `Elaborate_Body' + The unit contains a pragma Elaborate_Body. + + `Remote_Types' + The unit contains a pragma Remote_Types. + + `Shared_Passive' + The unit contains a pragma Shared_Passive. + + `Predefined' + This unit is part of the predefined environment and cannot be + modified by the user. + + `Remote_Call_Interface' + The unit contains a pragma Remote_Call_Interface. + +  + File: gnat_ug_unx.info, Node: Examples of gnatls Usage, Prev: Switches for gnatls, Up: The GNAT Library Browser gnatls + + Example of `gnatls' Usage + ========================= + + Example of using the verbose switch. Note how the source and object + paths are affected by the -I switch. + + $ gnatls -v -I.. demo1.o + + GNATLS 3.10w (970212) Copyright 1999 Free Software Foundation, Inc. + + Source Search Path: + + ../ + /home/comar/local/adainclude/ + + Object Search Path: + + ../ + /home/comar/local/lib/gcc-lib/mips-sni-sysv4/2.7.2/adalib/ + + ./demo1.o + Unit => + Name => demo1 + Kind => subprogram body + Flags => No_Elab_Code + Source => demo1.adb modified + + The following is an example of use of the dependency list. Note the + use of the -s switch which gives a straight list of source files. This + can be useful for building specialized scripts. + + $ gnatls -d demo2.o + ./demo2.o demo2 OK demo2.adb + OK gen_list.ads + OK gen_list.adb + OK instr.ads + OK instr-child.ads + + $ gnatls -d -s -a demo1.o + demo1.adb + /home/comar/local/adainclude/ada.ads + /home/comar/local/adainclude/a-finali.ads + /home/comar/local/adainclude/a-filico.ads + /home/comar/local/adainclude/a-stream.ads + /home/comar/local/adainclude/a-tags.ads + gen_list.ads + gen_list.adb + /home/comar/local/adainclude/gnat.ads + /home/comar/local/adainclude/g-io.ads + instr.ads + /home/comar/local/adainclude/system.ads + /home/comar/local/adainclude/s-exctab.ads + /home/comar/local/adainclude/s-finimp.ads + /home/comar/local/adainclude/s-finroo.ads + /home/comar/local/adainclude/s-secsta.ads + /home/comar/local/adainclude/s-stalib.ads + /home/comar/local/adainclude/s-stoele.ads + /home/comar/local/adainclude/s-stratt.ads + /home/comar/local/adainclude/s-tasoli.ads + /home/comar/local/adainclude/s-unstyp.ads + /home/comar/local/adainclude/unchconv.ads + +  + File: gnat_ug_unx.info, Node: GNAT and Libraries, Next: Using the GNU make Utility, Prev: The GNAT Library Browser gnatls, Up: Top + + GNAT and Libraries + ****************** + + This chapter addresses some of the issues related to building and using + a library with GNAT. It also shows how the GNAT run-time library can be + recompiled. + + * Menu: + + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + +  + File: gnat_ug_unx.info, Node: Creating an Ada Library, Next: Installing an Ada Library, Up: GNAT and Libraries + + Creating an Ada Library + ======================= + + In the GNAT environment, a library has two components: + * Source files. + + * Compiled code and Ali files. See *Note The Ada Library Information + Files::. + + In order to use other packages *Note The GNAT Compilation Model:: + requires a certain number of sources to be available to the compiler. + The minimal set of sources required includes the specs of all the + packages that make up the visible part of the library as well as all + the sources upon which they depend. The bodies of all visible generic + units must also be provided. + + Although it is not strictly mandatory, it is recommended that all + sources needed to recompile the library be provided, so that the user + can make full use of inter-unit inlining and source-level debugging. + This can also make the situation easier for users that need to upgrade + their compilation toolchain and thus need to recompile the library from + sources. + + The compiled code can be provided in different ways. The simplest way is + to provide directly the set of objects produced by the compiler during + the compilation of the library. It is also possible to group the objects + into an archive using whatever commands are provided by the operating + system. Finally, it is also possible to create a shared library (see + option -shared in the GCC manual). + + There are various possibilities for compiling the units that make up the + library: for example with a Makefile *Note Using the GNU make Utility::, + or with a conventional script. For simple libraries, it is also + possible to create a dummy main program which depends upon all the + packages that comprise the interface of the library. This dummy main + program can then be given to gnatmake, in order to build all the + necessary objects. Here is an example of such a dummy program and the + generic commands used to build an archive or a shared library. + + with My_Lib.Service1; + with My_Lib.Service2; + with My_Lib.Service3; + procedure My_Lib_Dummy is + begin + null; + end; + + # compiling the library + $ gnatmake -c my_lib_dummy.adb + + # we don't need the dummy object itself + $ rm my_lib_dummy.o my_lib_dummy.ali + + # create an archive with the remaining objects + $ ar rc libmy_lib.a *.o + # some systems may require "ranlib" to be run as well + + # or create a shared library + $ gcc -shared -o libmy_lib.so *.o + # some systems may require the code to have been compiled with -fPIC + + When the objects are grouped in an archive or a shared library, the user + needs to specify the desired library at link time, unless a pragma + linker_options has been used in one of the sources: + pragma Linker_Options ("-lmy_lib"); + +  + File: gnat_ug_unx.info, Node: Installing an Ada Library, Next: Using an Ada Library, Prev: Creating an Ada Library, Up: GNAT and Libraries + + Installing an Ada Library + ========================= + + In the GNAT model, installing a library consists in copying into a + specific location the files that make up this library. It is possible + to install the sources in a different directory from the other files + (ALI, objects, archives) since the source path and the object path can + easily be specified separately. + + For general purpose libraries, it is possible for the system + administrator to put those libraries in the default compiler paths. To + achieve this, he must specify their location in the configuration files + "ada_source_path" and "ada_object_path" that must be located in the GNAT + installation tree at the same place as the gcc spec file. The location + of the gcc spec file can be determined as follows: + $ gcc -v + + The configuration files mentioned above have simple format: each line + in them must contain one unique directory name. Those names are added + to the corresponding path in their order of appearance in the file. The + names can be either absolute or relative, in the latter case, they are + relative to where theses files are located. + + "ada_source_path" and "ada_object_path" might actually not be present + in a GNAT installation, in which case, GNAT will look for its run-time + library in the directories "adainclude" for the sources and "adalib" + for the objects and ALI files. When the files exist, the compiler does + not look in "adainclude" and "adalib" at all, and thus the + "ada_source_path" file must contain the location for the GNAT run-time + sources (which can simply be "adainclude"). In the same way, the + "ada_object_path" file must contain the location for the GNAT run-time + objects (which can simply be "adalib"). + + You can also specify a new default path to the runtime library at + compilation time with the switch "-RTS=RTS-PATH". You can easily choose + and change the runtime you want your program to be compiled with. This + switch is recognized by gcc, gnatmake, gnatbind, gnatls, gnatfind and + gnatxref. + + It is possible to install a library before or after the standard GNAT + library, by reordering the lines in the configuration files. In + general, a library must be installed before the GNAT library if it + redefines any part of it. + +  + File: gnat_ug_unx.info, Node: Using an Ada Library, Next: Creating an Ada Library to be Used in a Non-Ada Context, Prev: Installing an Ada Library, Up: GNAT and Libraries + + Using an Ada Library + ==================== + + In order to use a Ada library, you need to make sure that this library + is on both your source and object path *Note Search Paths and the + Run-Time Library (RTL):: and *Note Search Paths for gnatbind::. For + instance, you can use the library "mylib" installed in "/dir/my_lib_src" + and "/dir/my_lib_obj" with the following commands: + + $ gnatmake -aI/dir/my_lib_src -aO/dir/my_lib_obj my_appl \ + -largs -lmy_lib + + This can be simplified down to the following: + $ gnatmake my_appl + when the following conditions are met: + * "/dir/my_lib_src" has been added by the user to the environment + variable "ADA_INCLUDE_PATH", or by the administrator to the file + "ada_source_path" + + * "/dir/my_lib_obj" has been added by the user to the environment + variable "ADA_OBJECTS_PATH", or by the administrator to the file + "ada_object_path" + + * a pragma linker_options, as mentioned in *Note Creating an Ada + Library:: as been added to the sources. + +  + File: gnat_ug_unx.info, Node: Creating an Ada Library to be Used in a Non-Ada Context, Next: Rebuilding the GNAT Run-Time Library, Prev: Using an Ada Library, Up: GNAT and Libraries + + Creating an Ada Library to be Used in a Non-Ada Context + ======================================================= + + The previous sections detailed how to create and install a library that + was usable from an Ada main program. Using this library in a non-Ada + context is not possible, because the elaboration of the library is + automatically done as part of the main program elaboration. + + GNAT also provides the ability to build libraries that can be used + both in an Ada and non-Ada context. This section describes how to + build such a library, and then how to use it from a C program. The + method for interfacing with the library from other languages such as + Fortran for instance remains the same. + + Creating the Library + -------------------- + + * Identify the units representing the interface of the library. + + Here is an example of simple library interface: + + package Interface is + + procedure Do_Something; + + procedure Do_Something_Else; + + end Interface; + + * Use `pragma Export' or `pragma Convention' for the exported + entities. + + Our package `Interface' is then updated as follow: + package Interface is + + procedure Do_Something; + pragma Export (C, Do_Something, "do_something"); + + procedure Do_Something_Else; + pragma Export (C, Do_Something_Else, "do_something_else"); + + end Interface; + + * Compile all the units composing the library. + + * Bind the library objects. + + This step is performed by invoking gnatbind with the `-L' + switch. `gnatbind' will then generate the library elaboration + procedure (named `init') and the run-time finalization + procedure (named `final'). + + # generate the binder file in Ada + $ gnatbind -Lmylib interface + + # generate the binder file in C + $ gnatbind -C -Lmylib interface + + * Compile the files generated by the binder + + $ gcc -c b~interface.adb + + * Create the library; + + The procedure is identical to the procedure explained in *Note + Creating an Ada Library::, except that `b~interface.o' needs to be + added to the list of objects. + + # create an archive file + $ ar cr libmylib.a b~interface.o + + # create a shared library + $ gcc -shared -o libmylib.so b~interface.o + + * Provide a "foreign" view of the library interface; + + The example below shows the content of `mylib_interface.h' (note + that there is no rule for the naming of this file, any name can be + used) + /* the library elaboration procedure */ + extern void mylibinit (void); + + /* the library finalization procedure */ + extern void mylibfinal (void); + + /* the interface exported by the library */ + extern void do_something (void); + extern void do_something_else (void); + + Using the Library + ----------------- + + Libraries built as explained above can be used from any program, + provided that the elaboration procedures (named `mylibinit' in the + previous example) are called before the library services are used. Any + number of libraries can be used simultaneously, as long as the + elaboration procedure of each library is called. + + Below is an example of C program that uses our `mylib' library. + + #include "mylib_interface.h" + + int + main (void) + { + /* First, elaborate the library before using it */ + mylibinit (); + + /* Main program, using the library exported entities */ + do_something (); + do_something_else (); + + /* Library finalization at the end of the program */ + mylibfinal (); + return 0; + } + + Note that this same library can be used from an equivalent Ada main + program. In addition, if the libraries are installed as detailed in + *Note Installing an Ada Library::, it is not necessary to invoke the + library elaboration and finalization routines. The binder will ensure + that this is done as part of the main program elaboration and + finalization phases. + + The Finalization Phase + ---------------------- + + Invoking any library finalization procedure generated by `gnatbind' + shuts down the Ada run time permanently. Consequently, the finalization + of all Ada libraries must be performed at the end of the program. No + call to these libraries nor the Ada run time should be made past the + finalization phase. + + Restrictions in Libraries + ------------------------- + + The pragmas listed below should be used with caution inside libraries, + as they can create incompatibilities with other Ada libraries: + * pragma `Locking_Policy' + + * pragma `Queuing_Policy' + + * pragma `Task_Dispatching_Policy' + + * pragma `Unreserve_All_Interrupts' + When using a library that contains such pragmas, the user must make + sure that all libraries use the same pragmas with the same values. + Otherwise, a `Program_Error' will be raised during the elaboration of + the conflicting libraries. The usage of these pragmas and its + consequences for the user should therefore be well documented. + + Similarly, the traceback in exception occurrences mechanism should be + enabled or disabled in a consistent manner across all libraries. + Otherwise, a Program_Error will be raised during the elaboration of the + conflicting libraries. + + If the `'Version' and `'Body_Version' attributes are used inside a + library, then it is necessary to perform a `gnatbind' step that + mentions all ali files in all libraries, so that version identifiers + can be properly computed. In practice these attributes are rarely + used, so this is unlikely to be a consideration. + +  + File: gnat_ug_unx.info, Node: Rebuilding the GNAT Run-Time Library, Prev: Creating an Ada Library to be Used in a Non-Ada Context, Up: GNAT and Libraries + + Rebuilding the GNAT Run-Time Library + ==================================== + + It may be useful to recompile the GNAT library in various contexts, the + most important one being the use of partition-wide configuration pragmas + such as Normalize_Scalar. A special Makefile called `Makefile.adalib' + is provided to that effect and can be found in the directory containing + the GNAT library. The location of this directory depends on the way the + GNAT environment has been installed and can be determined by means of + the command: + + $ gnatls -v + + The last entry in the object search path usually contains the gnat + library. This Makefile contains its own documentation and in particular + the set of instructions needed to rebuild a new library and to use it. + +  + File: gnat_ug_unx.info, Node: Using the GNU make Utility, Next: Finding Memory Problems with gnatmem, Prev: GNAT and Libraries, Up: Top + + Using the GNU `make' Utility + **************************** + + This chapter offers some examples of makefiles that solve specific + problems. It does not explain how to write a makefile (see the GNU make + documentation), nor does it try to replace the `gnatmake' utility + (*note The GNAT Make Program gnatmake::). + + All the examples in this section are specific to the GNU version of + make. Although `make' is a standard utility, and the basic language is + the same, these examples use some advanced features found only in `GNU + make'. + + * Menu: + + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + +  + File: gnat_ug_unx.info, Node: Using gnatmake in a Makefile, Next: Automatically Creating a List of Directories, Up: Using the GNU make Utility + + Using gnatmake in a Makefile + ============================ + + Complex project organizations can be handled in a very powerful way by + using GNU make combined with gnatmake. For instance, here is a Makefile + which allows you to build each subsystem of a big project into a + separate shared library. Such a makefile allows you to significantly + reduce the link time of very big applications while maintaining full + coherence at each step of the build process. + + The list of dependencies are handled automatically by `gnatmake'. + The Makefile is simply used to call gnatmake in each of the appropriate + directories. + + Note that you should also read the example on how to automatically + create the list of directories (*note Automatically Creating a List of + Directories::) which might help you in case your project has a lot of + subdirectories. + + ## This Makefile is intended to be used with the following directory + ## configuration: + ## - The sources are split into a series of csc (computer software components) + ## Each of these csc is put in its own directory. + ## Their name are referenced by the directory names. + ## They will be compiled into shared library (although this would also work + ## with static libraries + ## - The main program (and possibly other packages that do not belong to any + ## csc is put in the top level directory (where the Makefile is). + ## toplevel_dir __ first_csc (sources) __ lib (will contain the library) + ## \_ second_csc (sources) __ lib (will contain the library) + ## \_ ... + ## Although this Makefile is build for shared library, it is easy to modify + ## to build partial link objects instead (modify the lines with -shared and + ## gnatlink below) + ## + ## With this makefile, you can change any file in the system or add any new + ## file, and everything will be recompiled correctly (only the relevant shared + ## objects will be recompiled, and the main program will be re-linked). + + # The list of computer software component for your project. This might be + # generated automatically. + CSC_LIST=aa bb cc + + # Name of the main program (no extension) + MAIN=main + + # If we need to build objects with -fPIC, uncomment the following line + #NEED_FPIC=-fPIC + + # The following variable should give the directory containing libgnat.so + # You can get this directory through 'gnatls -v'. This is usually the last + # directory in the Object_Path. + GLIB=... + + # The directories for the libraries + # (This macro expands the list of CSC to the list of shared libraries, you + # could simply use the expanded form : + # LIB_DIR=aa/lib/libaa.so bb/lib/libbb.so cc/lib/libcc.so + LIB_DIR=${foreach dir,${CSC_LIST},${dir}/lib/lib${dir}.so} + + ${MAIN}: objects ${LIB_DIR} + gnatbind ${MAIN} ${CSC_LIST:%=-aO%/lib} -shared + gnatlink ${MAIN} ${CSC_LIST:%=-l%} + + objects:: + # recompile the sources + gnatmake -c -i ${MAIN}.adb ${NEED_FPIC} ${CSC_LIST:%=-I%} + + # Note: In a future version of GNAT, the following commands will be simplified + # by a new tool, gnatmlib + ${LIB_DIR}: + mkdir -p ${dir $@ } + cd ${dir $@ }; gcc -shared -o ${notdir $@ } ../*.o -L${GLIB} -lgnat + cd ${dir $@ }; cp -f ../*.ali . + + # The dependencies for the modules + # Note that we have to force the expansion of *.o, since in some cases make won't + # be able to do it itself. + aa/lib/libaa.so: ${wildcard aa/*.o} + bb/lib/libbb.so: ${wildcard bb/*.o} + cc/lib/libcc.so: ${wildcard cc/*.o} + + # Make sure all of the shared libraries are in the path before starting the + # program + run:: + LD_LIBRARY_PATH=`pwd`/aa/lib:`pwd`/bb/lib:`pwd`/cc/lib ./${MAIN} + + clean:: + ${RM} -rf ${CSC_LIST:%=%/lib} + ${RM} ${CSC_LIST:%=%/*.ali} + ${RM} ${CSC_LIST:%=%/*.o} + ${RM} *.o *.ali ${MAIN} + +  + File: gnat_ug_unx.info, Node: Automatically Creating a List of Directories, Next: Generating the Command Line Switches, Prev: Using gnatmake in a Makefile, Up: Using the GNU make Utility + + Automatically Creating a List of Directories + ============================================ + + In most makefiles, you will have to specify a list of directories, and + store it in a variable. For small projects, it is often easier to + specify each of them by hand, since you then have full control over what + is the proper order for these directories, which ones should be + included... + + However, in larger projects, which might involve hundreds of + subdirectories, it might be more convenient to generate this list + automatically. + + The example below presents two methods. The first one, although less + general, gives you more control over the list. It involves wildcard + characters, that are automatically expanded by `make'. Its shortcoming + is that you need to explicitly specify some of the organization of your + project, such as for instance the directory tree depth, whether some + directories are found in a separate tree,... + + The second method is the most general one. It requires an external + program, called `find', which is standard on all Unix systems. All the + directories found under a given root directory will be added to the + list. + + # The examples below are based on the following directory hierarchy: + # All the directories can contain any number of files + # ROOT_DIRECTORY -> a -> aa -> aaa + # -> ab + # -> ac + # -> b -> ba -> baa + # -> bb + # -> bc + # This Makefile creates a variable called DIRS, that can be reused any time + # you need this list (see the other examples in this section) + + # The root of your project's directory hierarchy + ROOT_DIRECTORY=. + + #### + # First method: specify explicitly the list of directories + # This allows you to specify any subset of all the directories you need. + #### + + DIRS := a/aa/ a/ab/ b/ba/ + + #### + # Second method: use wildcards + # Note that the argument(s) to wildcard below should end with a '/'. + # Since wildcards also return file names, we have to filter them out + # to avoid duplicate directory names. + # We thus use make's `dir' and `sort' functions. + # It sets DIRs to the following value (note that the directories aaa and baa + # are not given, unless you change the arguments to wildcard). + # DIRS= ./a/a/ ./b/ ./a/aa/ ./a/ab/ ./a/ac/ ./b/ba/ ./b/bb/ ./b/bc/ + #### + + DIRS := ${sort ${dir ${wildcard ${ROOT_DIRECTORY}/*/ ${ROOT_DIRECTORY}/*/*/}}} + + #### + # Third method: use an external program + # This command is much faster if run on local disks, avoiding NFS slowdowns. + # This is the most complete command: it sets DIRs to the following value: + # DIRS= ./a ./a/aa ./a/aa/aaa ./a/ab ./a/ac ./b ./b/ba ./b/ba/baa ./b/bb ./b/bc + #### + + DIRS := ${shell find ${ROOT_DIRECTORY} -type d -print} + +  + File: gnat_ug_unx.info, Node: Generating the Command Line Switches, Next: Overcoming Command Line Length Limits, Prev: Automatically Creating a List of Directories, Up: Using the GNU make Utility + + Generating the Command Line Switches + ==================================== + + Once you have created the list of directories as explained in the + previous section (*note Automatically Creating a List of Directories::), + you can easily generate the command line arguments to pass to gnatmake. + + For the sake of completeness, this example assumes that the source + path is not the same as the object path, and that you have two separate + lists of directories. + + # see "Automatically creating a list of directories" to create + # these variables + SOURCE_DIRS= + OBJECT_DIRS= + + GNATMAKE_SWITCHES := ${patsubst %,-aI%,${SOURCE_DIRS}} + GNATMAKE_SWITCHES += ${patsubst %,-aO%,${OBJECT_DIRS}} + + all: + gnatmake ${GNATMAKE_SWITCHES} main_unit + +  + File: gnat_ug_unx.info, Node: Overcoming Command Line Length Limits, Prev: Generating the Command Line Switches, Up: Using the GNU make Utility + + Overcoming Command Line Length Limits + ===================================== + + One problem that might be encountered on big projects is that many + operating systems limit the length of the command line. It is thus hard + to give gnatmake the list of source and object directories. + + This example shows how you can set up environment variables, which + will make `gnatmake' behave exactly as if the directories had been + specified on the command line, but have a much higher length limit (or + even none on most systems). + + It assumes that you have created a list of directories in your + Makefile, using one of the methods presented in *Note Automatically + Creating a List of Directories::. For the sake of completeness, we + assume that the object path (where the ALI files are found) is + different from the sources patch. + + Note a small trick in the Makefile below: for efficiency reasons, we + create two temporary variables (SOURCE_LIST and OBJECT_LIST), that are + expanded immediately by `make'. This way we overcome the standard make + behavior which is to expand the variables only when they are actually + used. + + # In this example, we create both ADA_INCLUDE_PATH and ADA_OBJECT_PATH. + # This is the same thing as putting the -I arguments on the command line. + # (the equivalent of using -aI on the command line would be to define + # only ADA_INCLUDE_PATH, the equivalent of -aO is ADA_OBJECT_PATH). + # You can of course have different values for these variables. + # + # Note also that we need to keep the previous values of these variables, since + # they might have been set before running 'make' to specify where the GNAT + # library is installed. + + # see "Automatically creating a list of directories" to create these + # variables + SOURCE_DIRS= + OBJECT_DIRS= + + empty:= + space:=${empty} ${empty} + SOURCE_LIST := ${subst ${space},:,${SOURCE_DIRS}} + OBJECT_LIST := ${subst ${space},:,${OBJECT_DIRS}} + ADA_INCLUDE_PATH += ${SOURCE_LIST} + ADA_OBJECT_PATH += ${OBJECT_LIST} + export ADA_INCLUDE_PATH + export ADA_OBJECT_PATH + + all: + gnatmake main_unit + +  + File: gnat_ug_unx.info, Node: Finding Memory Problems with gnatmem, Next: Finding Memory Problems with GNAT Debug Pool, Prev: Using the GNU make Utility, Up: Top + + Finding Memory Problems with `gnatmem' + ************************************** + + `gnatmem', is a tool that monitors dynamic allocation and deallocation + activity in a program, and displays information about incorrect + deallocations and possible sources of memory leaks. Gnatmem provides + three type of information: + * General information concerning memory management, such as the total + number of allocations and deallocations, the amount of allocated + memory and the high water mark, i.e. the largest amount of + allocated memory in the course of program execution. + + * Backtraces for all incorrect deallocations, that is to say + deallocations which do not correspond to a valid allocation. + + * Information on each allocation that is potentially the origin of a + memory leak. + + The `gnatmem' command has two modes. It can be used with `gdb' or + with instrumented allocation and deallocation routines. The later mode + is called the `GMEM' mode. Both modes produce the very same output. + + * Menu: + + * Running gnatmem (GDB Mode):: + * Running gnatmem (GMEM Mode):: + * Switches for gnatmem:: + * Examples of gnatmem Usage:: + * GDB and GMEM Modes:: + * Implementation Note:: + +  + File: gnat_ug_unx.info, Node: Running gnatmem (GDB Mode), Next: Running gnatmem (GMEM Mode), Up: Finding Memory Problems with gnatmem + + Running `gnatmem' (GDB Mode) + ============================ + + The `gnatmem' command has the form + + $ gnatmem [-q] [n] [-o file] user_program [program_arg]* + or + $ gnatmem [-q] [n] -i file + + Gnatmem must be supplied with the executable to examine, followed by its + run-time inputs. For example, if a program is executed with the command: + $ my_program arg1 arg2 + then it can be run under `gnatmem' control using the command: + $ gnatmem my_program arg1 arg2 + + The program is transparently executed under the control of the + debugger *Note The GNAT Debugger GDB::. This does not affect the + behavior of the program, except for sensitive real-time programs. When + the program has completed execution, `gnatmem' outputs a report + containing general allocation/deallocation information and potential + memory leak. For better results, the user program should be compiled + with debugging options *Note Switches for gcc::. + + Here is a simple example of use: + + *************** debut cc + $ gnatmem test_gm + + Global information + ------------------ + Total number of allocations : 45 + Total number of deallocations : 6 + Final Water Mark (non freed mem) : 11.29 Kilobytes + High Water Mark : 11.40 Kilobytes + + . + . + . + Allocation Root # 2 + ------------------- + Number of non freed allocations : 11 + Final Water Mark (non freed mem) : 1.16 Kilobytes + High Water Mark : 1.27 Kilobytes + Backtrace : + test_gm.adb:23 test_gm.alloc + . + . + . + + The first block of output give general information. In this case, the + Ada construct "new" was executed 45 times, and only 6 calls to an + unchecked deallocation routine occurred. + + Subsequent paragraphs display information on all allocation roots. + An allocation root is a specific point in the execution of the program + that generates some dynamic allocation, such as a "new" construct. This + root is represented by an execution backtrace (or subprogram call + stack). By default the backtrace depth for allocations roots is 1, so + that a root corresponds exactly to a source location. The backtrace can + be made deeper, to make the root more specific. + +  + File: gnat_ug_unx.info, Node: Running gnatmem (GMEM Mode), Next: Switches for gnatmem, Prev: Running gnatmem (GDB Mode), Up: Finding Memory Problems with gnatmem + + Running `gnatmem' (GMEM Mode) + ============================= + + The `gnatmem' command has the form + + $ gnatmem [-q] [n] -i gmem.out user_program [program_arg]* + + The program must have been linked with the instrumented version of + the allocation and deallocation routines. This is done with linking + with the `libgmem.a' library. For better results, the user program + should be compiled with debugging options *Note Switches for gcc::. For + example to build `my_program': + + $ gnatmake -g my_program -largs -lgmem + + When running `my_program' the file `gmem.out' is produced. This file + contains information about all allocations and deallocations done by the + program. It is produced by the instrumented allocations and + deallocations routines and will be used by `gnatmem'. + + Gnatmem must be supplied with the `gmem.out' file and the executable to + examine followed by its run-time inputs. For example, if a program is + executed with the command: + $ my_program arg1 arg2 + then `gmem.out' can be analysed by `gnatmem' using the command: + $ gnatmem -i gmem.out my_program arg1 arg2 + +  + File: gnat_ug_unx.info, Node: Switches for gnatmem, Next: Examples of gnatmem Usage, Prev: Running gnatmem (GMEM Mode), Up: Finding Memory Problems with gnatmem + + Switches for `gnatmem' + ====================== + + `gnatmem' recognizes the following switches: + + ``-q'' + Quiet. Gives the minimum output needed to identify the origin of + the memory leaks. Omit statistical information. + + ``n'' + N is an integer literal (usually between 1 and 10) which controls + the depth of the backtraces defining allocation root. The default + value for N is 1. The deeper the backtrace, the more precise the + localization of the root. Note that the total number of roots can + depend on this parameter. + + ``-o file'' + Direct the gdb output to the specified file. The `gdb' script used + to generate this output is also saved in the file `gnatmem.tmp'. + + ``-i file'' + Do the `gnatmem' processing starting from `file' which has been + generated by a previous call to `gnatmem' with the -o switch or + `gmem.out' produced by `GMEM' mode. This is useful for post mortem + processing. + +  + File: gnat_ug_unx.info, Node: Examples of gnatmem Usage, Next: GDB and GMEM Modes, Prev: Switches for gnatmem, Up: Finding Memory Problems with gnatmem + + Example of `gnatmem' Usage + ========================== + + This section is based on the `GDB' mode of `gnatmem'. The same results + can be achieved using `GMEM' mode. See section *Note Running gnatmem + (GMEM Mode)::. + + The first example shows the use of `gnatmem' on a simple leaking + program. Suppose that we have the following Ada program: + + with Unchecked_Deallocation; + procedure Test_Gm is + + type T is array (1..1000) of Integer; + type Ptr is access T; + procedure Free is new Unchecked_Deallocation (T, Ptr); + A : Ptr; + + procedure My_Alloc is + begin + A := new T; + end My_Alloc; + + procedure My_DeAlloc is + B : Ptr := A; + begin + Free (B); + end My_DeAlloc; + + begin + My_Alloc; + for I in 1 .. 5 loop + for J in I .. 5 loop + My_Alloc; + end loop; + My_Dealloc; + end loop; + end; + + The program needs to be compiled with debugging option: + + $ gnatmake -g test_gm + + `gnatmem' is invoked simply with + $ gnatmem test_gm + + which produces the following output: + + Global information + ------------------ + Total number of allocations : 18 + Total number of deallocations : 5 + Final Water Mark (non freed mem) : 53.00 Kilobytes + High Water Mark : 56.90 Kilobytes + + Allocation Root # 1 + ------------------- + Number of non freed allocations : 11 + Final Water Mark (non freed mem) : 42.97 Kilobytes + High Water Mark : 46.88 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + + Allocation Root # 2 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 10.02 Kilobytes + High Water Mark : 10.02 Kilobytes + Backtrace : + s-secsta.adb:81 system.secondary_stack.ss_init + + Allocation Root # 3 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 12 Bytes + High Water Mark : 12 Bytes + Backtrace : + s-secsta.adb:181 system.secondary_stack.ss_init + + Note that the GNAT run time contains itself a certain number of + allocations that have no corresponding deallocation, as shown here for + root #2 and root #1. This is a normal behavior when the number of non + freed allocations is one, it locates dynamic data structures that the + run time needs for the complete lifetime of the program. Note also that + there is only one allocation root in the user program with a single + line back trace: test_gm.adb:11 test_gm.my_alloc, whereas a careful + analysis of the program shows that 'My_Alloc' is called at 2 different + points in the source (line 21 and line 24). If those two allocation + roots need to be distinguished, the backtrace depth parameter can be + used: + + $ gnatmem 3 test_gm + + which will give the following output: + + Global information + ------------------ + Total number of allocations : 18 + Total number of deallocations : 5 + Final Water Mark (non freed mem) : 53.00 Kilobytes + High Water Mark : 56.90 Kilobytes + + Allocation Root # 1 + ------------------- + Number of non freed allocations : 10 + Final Water Mark (non freed mem) : 39.06 Kilobytes + High Water Mark : 42.97 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + test_gm.adb:24 test_gm + b_test_gm.c:52 main + + Allocation Root # 2 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 10.02 Kilobytes + High Water Mark : 10.02 Kilobytes + Backtrace : + s-secsta.adb:81 system.secondary_stack.ss_init + s-secsta.adb:283 + b_test_gm.c:33 adainit + + Allocation Root # 3 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 3.91 Kilobytes + High Water Mark : 3.91 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + test_gm.adb:21 test_gm + b_test_gm.c:52 main + + Allocation Root # 4 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 12 Bytes + High Water Mark : 12 Bytes + Backtrace : + s-secsta.adb:181 system.secondary_stack.ss_init + s-secsta.adb:283 + b_test_gm.c:33 adainit + + The allocation root #1 of the first example has been split in 2 roots #1 + and #3 thanks to the more precise associated backtrace. + +  + File: gnat_ug_unx.info, Node: GDB and GMEM Modes, Next: Implementation Note, Prev: Examples of gnatmem Usage, Up: Finding Memory Problems with gnatmem + + GDB and GMEM Modes + ================== + + The main advantage of the `GMEM' mode is that it is a lot faster than + the `GDB' mode where the application must be monitored by a `GDB' + script. But the `GMEM' mode is available only for DEC Unix, Linux x86, + Solaris (sparc and x86) and Windows 95/98/NT/2000 (x86). + + The main advantage of the `GDB' mode is that it is available on all + supported platforms. But it can be very slow if the application does a + lot of allocations and deallocations. + +  + File: gnat_ug_unx.info, Node: Implementation Note, Prev: GDB and GMEM Modes, Up: Finding Memory Problems with gnatmem + + Implementation Note + =================== + + * Menu: + + * gnatmem Using GDB Mode:: + * gnatmem Using GMEM Mode:: + +  + File: gnat_ug_unx.info, Node: gnatmem Using GDB Mode, Next: gnatmem Using GMEM Mode, Up: Implementation Note + + `gnatmem' Using `GDB' Mode + -------------------------- + + `gnatmem' executes the user program under the control of `GDB' using a + script that sets breakpoints and gathers information on each dynamic + allocation and deallocation. The output of the script is then analyzed + by `gnatmem' in order to locate memory leaks and their origin in the + program. Gnatmem works by recording each address returned by the + allocation procedure (`__gnat_malloc') along with the backtrace at the + allocation point. On each deallocation, the deallocated address is + matched with the corresponding allocation. At the end of the processing, + the unmatched allocations are considered potential leaks. All the + allocations associated with the same backtrace are grouped together and + form an allocation root. The allocation roots are then sorted so that + those with the biggest number of unmatched allocation are printed + first. A delicate aspect of this technique is to distinguish between the + data produced by the user program and the data produced by the gdb + script. Currently, on systems that allow probing the terminal, the gdb + command "tty" is used to force the program output to be redirected to + the current terminal while the `gdb' output is directed to a file or to + a pipe in order to be processed subsequently by `gnatmem'. + +  + File: gnat_ug_unx.info, Node: gnatmem Using GMEM Mode, Prev: gnatmem Using GDB Mode, Up: Implementation Note + + `gnatmem' Using `GMEM' Mode + --------------------------- + + This mode use the same algorithm to detect memory leak as the `GDB' + mode of `gnatmem', the only difference is in the way data are gathered. + In `GMEM' mode the program is linked with instrumented version of + `__gnat_malloc' and `__gnat_free' routines. Information needed to find + memory leak are recorded by these routines in file `gmem.out'. This + mode also require that the stack traceback be available, this is only + implemented on some platforms *Note GDB and GMEM Modes::. + +  + File: gnat_ug_unx.info, Node: Finding Memory Problems with GNAT Debug Pool, Next: Creating Sample Bodies Using gnatstub, Prev: Finding Memory Problems with gnatmem, Up: Top + + Finding Memory Problems with GNAT Debug Pool + ******************************************** + + The use of unchecked deallocation and unchecked conversion can easily + lead to incorrect memory references. The problems generated by such + references are usually difficult to tackle because the symptoms can be + very remote from the origin of the problem. In such cases, it is very + helpful to detect the problem as early as possible. This is the purpose + of the Storage Pool provided by `GNAT.Debug_Pools'. + + In order to use the GNAT specific debugging pool, the user must + associate a debug pool object with each of the access types that may be + related to suspected memory problems. See Ada Reference Manual 13.11. + type Ptr is access Some_Type; + Pool : GNAT.Debug_Pools.Debug_Pool; + for Ptr'Storage_Pool use Pool; + + `GNAT.Debug_Pools' is derived from of a GNAT-specific kind of pool: + the Checked_Pool. Such pools, like standard Ada storage pools, allow + the user to redefine allocation and deallocation strategies. They also + provide a checkpoint for each dereference, through the use of the + primitive operation `Dereference' which is implicitly called at each + dereference of an access value. + + Once an access type has been associated with a debug pool, + operations on values of the type may raise four distinct exceptions, + which correspond to four potential kinds of memory corruption: + * `GNAT.Debug_Pools.Accessing_Not_Allocated_Storage' + + * `GNAT.Debug_Pools.Accessing_Deallocated_Storage' + + * `GNAT.Debug_Pools.Freeing_Not_Allocated_Storage' + + * `GNAT.Debug_Pools.Freeing_Deallocated_Storage ' + + For types associated with a Debug_Pool, dynamic allocation is performed + using the standard GNAT allocation routine. References to all allocated + chunks of memory are kept in an internal dictionary. The deallocation + strategy consists in not releasing the memory to the underlying system + but rather to fill it with a memory pattern easily recognizable during + debugging sessions: The memory pattern is the old IBM hexadecimal + convention: 16#DEADBEEF#. Upon each dereference, a check is made that + the access value denotes a properly allocated memory location. Here is + a complete example of use of `Debug_Pools', that includes typical + instances of memory corruption: + with Gnat.Io; use Gnat.Io; + with Unchecked_Deallocation; + with Unchecked_Conversion; + with GNAT.Debug_Pools; + with System.Storage_Elements; + with Ada.Exceptions; use Ada.Exceptions; + procedure Debug_Pool_Test is + + type T is access Integer; + type U is access all T; + + P : GNAT.Debug_Pools.Debug_Pool; + for T'Storage_Pool use P; + + procedure Free is new Unchecked_Deallocation (Integer, T); + function UC is new Unchecked_Conversion (U, T); + A, B : aliased T; + + procedure Info is new GNAT.Debug_Pools.Print_Info(Put_Line); + + begin + Info (P); + A := new Integer; + B := new Integer; + B := A; + Info (P); + Free (A); + begin + Put_Line (Integer'Image(B.all)); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + begin + Free (B); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + B := UC(A'Access); + begin + Put_Line (Integer'Image(B.all)); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + begin + Free (B); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + Info (P); + end Debug_Pool_Test; + + The debug pool mechanism provides the following precise diagnostics on + the execution of this erroneous program: + Debug Pool info: + Total allocated bytes : 0 + Total deallocated bytes : 0 + Current Water Mark: 0 + High Water Mark: 0 + + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 0 + Current Water Mark: 8 + High Water Mark: 8 + + raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 4 + Current Water Mark: 4 + High Water Mark: 8 + +  + File: gnat_ug_unx.info, Node: Creating Sample Bodies Using gnatstub, Next: Reducing the Size of Ada Executables with gnatelim, Prev: Finding Memory Problems with GNAT Debug Pool, Up: Top + + Creating Sample Bodies Using `gnatstub' + *************************************** + + `gnatstub' creates body stubs, that is, empty but compilable bodies for + library unit declarations. + + To create a body stub, `gnatstub' has to compile the library unit + declaration. Therefore, bodies can be created only for legal library + units. Moreover, if a library unit depends semantically upon units + located outside the current directory, you have to provide the source + search path when calling `gnatstub', see the description of `gnatstub' + switches below. + + * Menu: + + * Running gnatstub:: + * Switches for gnatstub:: + +  + File: gnat_ug_unx.info, Node: Running gnatstub, Next: Switches for gnatstub, Up: Creating Sample Bodies Using gnatstub + + Running `gnatstub' + ================== + + `gnatstub' has the command-line interface of the form + + $ gnatstub [switches] filename [directory] + + where + `filename' + is the name of the source file that contains a library unit + declaration for which a body must be created. This name should + follow the GNAT file name conventions. No crunching is allowed for + this file name. The file name may contain the path information. + + `directory' + indicates the directory to place a body stub (default is the + current directory) + + `switches' + is an optional sequence of switches as described in the next + section + +  + File: gnat_ug_unx.info, Node: Switches for gnatstub, Prev: Running gnatstub, Up: Creating Sample Bodies Using gnatstub + + Switches for `gnatstub' + ======================= + + `-f' + If the destination directory already contains a file with a name + of the body file for the argument spec file, replace it with the + generated body stub. + + `-hs' + Put the comment header (i.e. all the comments preceding the + compilation unit) from the source of the library unit declaration + into the body stub. + + `-hg' + Put a sample comment header into the body stub. + + `-IDIR' + `-I-' + These switches have the same meaning as in calls to gcc. They + define the source search path in the call to gcc issued by + `gnatstub' to compile an argument source file. + + `-iN' + (N is a decimal natural number). Set the indentation level in the + generated body sample to n, '-i0' means "no indentation", the + default indentation is 3. + + `-k' + Do not remove the tree file (i.e. the snapshot of the compiler + internal structures used by `gnatstub') after creating the body + stub. + + `-lN' + (N is a decimal positive number) Set the maximum line length in the + body stub to n, the default is 78. + + `-q' + Quiet mode: do not generate a confirmation when a body is + successfully created or a message when a body is not required for + an argument unit. + + `-r' + Reuse the tree file (if it exists) instead of creating it: instead + of creating the tree file for the library unit declaration, + gnatstub tries to find it in the current directory and use it for + creating a body. If the tree file is not found, no body is + created. `-r' also implies `-k', whether or not `-k' is set + explicitly. + + `-t' + Overwrite the existing tree file: if the current directory already + contains the file which, according to the GNAT file name rules + should be considered as a tree file for the argument source file, + gnatstub will refuse to create the tree file needed to create a + body sampler, unless `-t' option is set + + `-v' + Verbose mode: generate version information. + +  + File: gnat_ug_unx.info, Node: Reducing the Size of Ada Executables with gnatelim, Next: Other Utility Programs, Prev: Creating Sample Bodies Using gnatstub, Up: Top + + Reducing the Size of Ada Executables with `gnatelim' + **************************************************** + + * Menu: + + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + +  + File: gnat_ug_unx.info, Node: About gnatelim, Next: Eliminate Pragma, Up: Reducing the Size of Ada Executables with gnatelim + + About `gnatelim' + ================ + + When a program shares a set of Ada packages with other programs, it may + happen that this program uses only a fraction of the subprograms + defined in these packages. The code created for these unused + subprograms increases the size of the executable. + + `gnatelim' tracks unused subprograms in an Ada program and outputs a + list of GNAT-specific `Eliminate' pragmas (see next section) marking + all the subprograms that are declared but never called. By placing the + list of `Eliminate' pragmas in the GNAT configuration file `gnat.adc' + and recompiling your program, you may decrease the size of its + executable, because the compiler will not generate the code for + 'eliminated' subprograms. + + `gnatelim' needs as its input data a set of tree files (see *Note + Tree Files::) representing all the components of a program to process + and a bind file for a main subprogram (see *Note Preparing Tree and + Bind Files for gnatelim::). + +  + File: gnat_ug_unx.info, Node: Eliminate Pragma, Next: Tree Files, Prev: About gnatelim, Up: Reducing the Size of Ada Executables with gnatelim + + `Eliminate' Pragma + ================== + + The simplified syntax of the Eliminate pragma used by `gnatelim' is: + + pragma Eliminate (Library_Unit_Name, Subprogram_Name); + + where + `Library_Unit_Name' + full expanded Ada name of a library unit + + `Subprogram_Name' + a simple or expanded name of a subprogram declared within this + compilation unit + + The effect of an `Eliminate' pragma placed in the GNAT configuration + file `gnat.adc' is: + + * If the subprogram `Subprogram_Name' is declared within the library + unit `Library_Unit_Name', the compiler will not generate code for + this subprogram. This applies to all overloaded subprograms denoted + by `Subprogram_Name'. + + * If a subprogram marked by the pragma `Eliminate' is used (called) + in a program, the compiler will produce an error message in the + place where it is called. + +  + File: gnat_ug_unx.info, Node: Tree Files, Next: Preparing Tree and Bind Files for gnatelim, Prev: Eliminate Pragma, Up: Reducing the Size of Ada Executables with gnatelim + + Tree Files + ========== + + A tree file stores a snapshot of the compiler internal data structures + at the very end of a successful compilation. It contains all the + syntactic and semantic information for the compiled unit and all the + units upon which it depends semantically. To use tools that make use + of tree files, you need to first produce the right set of tree files. + + GNAT produces correct tree files when -gnatt -gnatc options are set + in a gcc call. The tree files have an .adt extension. Therefore, to + produce a tree file for the compilation unit contained in a file named + `foo.adb', you must use the command + + $ gcc -c -gnatc -gnatt foo.adb + + and you will get the tree file `foo.adt'. compilation. + +  + File: gnat_ug_unx.info, Node: Preparing Tree and Bind Files for gnatelim, Next: Running gnatelim, Prev: Tree Files, Up: Reducing the Size of Ada Executables with gnatelim + + Preparing Tree and Bind Files for `gnatelim' + ============================================ + + A set of tree files covering the program to be analyzed with `gnatelim' + and the bind file for the main subprogram does not have to be in the + current directory. '-T' gnatelim option may be used to provide the + search path for tree files, and '-b' option may be used to point to the + bind file to process (see *Note Running gnatelim::) + + If you do not have the appropriate set of tree files and the right + bind file, you may create them in the current directory using the + following procedure. + + Let `Main_Prog' be the name of a main subprogram, and suppose this + subprogram is in a file named `main_prog.adb'. + + To create a bind file for `gnatelim', run `gnatbind' for the main + subprogram. `gnatelim' can work with both Ada and C bind files; when + both are present, it uses the Ada bind file. The following commands + will build the program and create the bind file: + + $ gnatmake -c Main_Prog + $ gnatbind main_prog + + To create a minimal set of tree files covering the whole program, call + `gnatmake' for this program as follows: + + $ gnatmake -f -c -gnatc -gnatt Main_Prog + + The `-c' gnatmake option turns off the bind and link steps, that are + useless anyway because the sources are compiled with `-gnatc' option + which turns off code generation. + + The `-f' gnatmake option forces recompilation of all the needed + sources. + + This sequence of actions will create all the data needed by + `gnatelim' from scratch and therefore guarantee its consistency. If you + would like to use some existing set of files as `gnatelim' output, you + must make sure that the set of files is complete and consistent. You + can use the `-m' switch to check if there are missed tree files + + Note, that `gnatelim' needs neither object nor ALI files. + +  + File: gnat_ug_unx.info, Node: Running gnatelim, Next: Correcting the List of Eliminate Pragmas, Prev: Preparing Tree and Bind Files for gnatelim, Up: Reducing the Size of Ada Executables with gnatelim + + Running `gnatelim' + ================== + + `gnatelim' has the following command-line interface: + + $ gnatelim [options] name + + `name' should be a full expanded Ada name of a main subprogram of a + program (partition). + + `gnatelim' options: + + `-q' + Quiet mode: by default `gnatelim' generates to the standard error + stream a trace of the source file names of the compilation units + being processed. This option turns this trace off. + + `-v' + Verbose mode: `gnatelim' version information is printed as Ada + comments to the standard output stream. + + `-a' + Also look for subprograms from the GNAT run time that can be + eliminated. + + `-m' + Check if any tree files are missing for an accurate result. + + `-TDIR' + When looking for tree files also look in directory DIR + + `-bBIND_FILE' + Specifies BIND_FILE as the bind file to process. If not set, the + name of the bind file is computed from the full expanded Ada name + of a main subprogram. + + `-dX' + Activate internal debugging switches. X is a letter or digit, or + string of letters or digits, which specifies the type of debugging + mode desired. Normally these are used only for internal + development or system debugging purposes. You can find full + documentation for these switches in the body of the + `Gnatelim.Options' unit in the compiler source file + `gnatelim-options.adb'. + + `gnatelim' sends its output to the standard output stream, and all the + tracing and debug information is sent to the standard error stream. In + order to produce a proper GNAT configuration file `gnat.adc', + redirection must be used: + + $ gnatelim Main_Prog > gnat.adc + + or + + $ gnatelim Main_Prog >> gnat.adc + + In order to append the `gnatelim' output to the existing contents of + `gnat.adc'. + +  + File: gnat_ug_unx.info, Node: Correcting the List of Eliminate Pragmas, Next: Making Your Executables Smaller, Prev: Running gnatelim, Up: Reducing the Size of Ada Executables with gnatelim + + Correcting the List of Eliminate Pragmas + ======================================== + + In some rare cases it may happen that `gnatelim' will try to eliminate + subprograms which are actually called in the program. In this case, the + compiler will generate an error message of the form: + + file.adb:106:07: cannot call eliminated subprogram "My_Prog" + + You will need to manually remove the wrong `Eliminate' pragmas from the + `gnat.adc' file. It is advised that you recompile your program from + scratch after that because you need a consistent `gnat.adc' file during + the entire compilation. + +  + File: gnat_ug_unx.info, Node: Making Your Executables Smaller, Next: Summary of the gnatelim Usage Cycle, Prev: Correcting the List of Eliminate Pragmas, Up: Reducing the Size of Ada Executables with gnatelim + + Making Your Executables Smaller + =============================== + + In order to get a smaller executable for your program you now have to + recompile the program completely with the new `gnat.adc' file created + by `gnatelim' in your current directory: + + $ gnatmake -f Main_Prog + + (you will need `-f' option for gnatmake to recompile everything with + the set of pragmas `Eliminate' you have obtained with `gnatelim'). + + Be aware that the set of `Eliminate' pragmas is specific to each + program. It is not recommended to merge sets of `Eliminate' pragmas + created for different programs in one `gnat.adc' file. + +  + File: gnat_ug_unx.info, Node: Summary of the gnatelim Usage Cycle, Prev: Making Your Executables Smaller, Up: Reducing the Size of Ada Executables with gnatelim + + Summary of the gnatelim Usage Cycle + =================================== + + Here is a quick summary of the steps to be taken in order to reduce the + size of your executables with `gnatelim'. You may use other GNAT + options to control the optimization level, to produce the debugging + information, to set search path, etc. + + 1. Produce a bind file and a set of tree files + + $ gnatmake -c Main_Prog + $ gnatbind main_prog + $ gnatmake -f -c -gnatc -gnatt Main_Prog + + 2. Generate a list of `Eliminate' pragmas + $ gnatelim Main_Prog >[>] gnat.adc + + 3. Recompile the application + + $ gnatmake -f Main_Prog + + +  + File: gnat_ug_unx.info, Node: Other Utility Programs, Next: Running and Debugging Ada Programs, Prev: Reducing the Size of Ada Executables with gnatelim, Up: Top + + Other Utility Programs + ********************** + + This chapter discusses some other utility programs available in the Ada + environment. + + * Menu: + + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * Installing gnathtml:: + +  + File: gnat_ug_unx.info, Node: Using Other Utility Programs with GNAT, Next: The gnatpsta Utility Program, Up: Other Utility Programs + + Using Other Utility Programs with GNAT + ====================================== + + The object files generated by GNAT are in standard system format and in + particular the debugging information uses this format. This means + programs generated by GNAT can be used with existing utilities that + depend on these formats. + + In general, any utility program that works with C will also often + work with Ada programs generated by GNAT. This includes software + utilities such as gprof (a profiling program), `gdb' (the FSF + debugger), and utilities such as Purify. + +  + File: gnat_ug_unx.info, Node: The gnatpsta Utility Program, Next: The External Symbol Naming Scheme of GNAT, Prev: Using Other Utility Programs with GNAT, Up: Other Utility Programs + + The `gnatpsta' Utility Program + ============================== + + Many of the definitions in package Standard are + implementation-dependent. However, the source of this package does not + exist as an Ada source file, so these values cannot be determined by + inspecting the source. They can be determined by examining in detail + the coding of `cstand.adb' which creates the image of Standard in the + compiler, but this is awkward and requires a great deal of internal + knowledge about the system. + + The `gnatpsta' utility is designed to deal with this situation. It + is an Ada program that dynamically determines the values of all the + relevant parameters in Standard, and prints them out in the form of an + Ada source listing for Standard, displaying all the values of interest. + This output is generated to `stdout'. + + To determine the value of any parameter in package Standard, simply + run `gnatpsta' with no qualifiers or arguments, and examine the output. + This is preferable to consulting documentation, because you know that + the values you are getting are the actual ones provided by the + executing system. + +  + File: gnat_ug_unx.info, Node: The External Symbol Naming Scheme of GNAT, Next: Ada Mode for Glide, Prev: The gnatpsta Utility Program, Up: Other Utility Programs + + The External Symbol Naming Scheme of GNAT + ========================================= + + In order to interpret the output from GNAT, when using tools that are + originally intended for use with other languages, it is useful to + understand the conventions used to generate link names from the Ada + entity names. + + All link names are in all lowercase letters. With the exception of + library procedure names, the mechanism used is simply to use the full + expanded Ada name with dots replaced by double underscores. For + example, suppose we have the following package spec: + + package QRS is + MN : Integer; + end QRS; + + The variable `MN' has a full expanded Ada name of `QRS.MN', so the + corresponding link name is `qrs__mn'. Of course if a `pragma Export' + is used this may be overridden: + + package Exports is + Var1 : Integer; + pragma Export (Var1, C, External_Name => "var1_name"); + Var2 : Integer; + pragma Export (Var2, C, Link_Name => "var2_link_name"); + end Exports; + + In this case, the link name for VAR1 is whatever link name the C + compiler would assign for the C function VAR1_NAME. This typically + would be either VAR1_NAME or _VAR1_NAME, depending on operating system + conventions, but other possibilities exist. The link name for VAR2 is + VAR2_LINK_NAME, and this is not operating system dependent. + + One exception occurs for library level procedures. A potential + ambiguity arises between the required name `_main' for the C main + program, and the name we would otherwise assign to an Ada library level + procedure called `Main' (which might well not be the main program). + + To avoid this ambiguity, we attach the prefix `_ada_' to such names. + So if we have a library level procedure such as + + procedure Hello (S : String); + + the external name of this procedure will be _ADA_HELLO. + +  + File: gnat_ug_unx.info, Node: Ada Mode for Glide, Next: Converting Ada Files to html with gnathtml, Prev: The External Symbol Naming Scheme of GNAT, Up: Other Utility Programs + + Ada Mode for `Glide' + ==================== + + The Glide mode for programming in Ada (both, Ada83 and Ada95) helps the + user in understanding existing code and facilitates writing new code. It + furthermore provides some utility functions for easier integration of + standard Emacs features when programming in Ada. + + General Features: + ----------------- + + * Full Integrated Development Environment : + + * support of 'project files' for the configuration (directories, + compilation options,...) + + * compiling and stepping through error messages. + + * running and debugging your applications within Glide. + + * easy to use for beginners by pull-down menus, + + * user configurable by many user-option variables. + + Ada Mode Features That Help Understanding Code: + ----------------------------------------------- + + * functions for easy and quick stepping through Ada code, + + * getting cross reference information for identifiers (e.g. find the + defining place by a keystroke), + + * displaying an index menu of types and subprograms and move point to + the chosen one, + + * automatic color highlighting of the various entities in Ada code. + + Glide Support for Writing Ada Code: + ----------------------------------- + + * switching between spec and body files with possible autogeneration + of body files, + + * automatic formating of subprograms parameter lists. + + * automatic smart indentation according to Ada syntax, + + * automatic completion of identifiers, + + * automatic casing of identifiers, keywords, and attributes, + + * insertion of statement templates, + + * filling comment paragraphs like filling normal text, + + For more information, please refer to the online Glide documentation + available in the Glide -> Help Menu. + +  + File: gnat_ug_unx.info, Node: Converting Ada Files to html with gnathtml, Next: Installing gnathtml, Prev: Ada Mode for Glide, Up: Other Utility Programs + + Converting Ada Files to html with `gnathtml' + ============================================ + + This `Perl' script allows Ada source files to be browsed using standard + Web browsers. For installation procedure, see the section *Note + Installing gnathtml::. + + Ada reserved keywords are highlighted in a bold font and Ada + comments in a blue font. Unless your program was compiled with the gcc + `-gnatx' switch to suppress the generation of cross-referencing + information, user defined variables and types will appear in a + different color; you will be able to click on any identifier and go to + its declaration. + + The command line is as follow: + $ perl gnathtml.pl [switches] ada-files + + You can pass it as many Ada files as you want. `gnathtml' will + generate an html file for every ada file, and a global file called + `index.htm'. This file is an index of every identifier defined in the + files. + + The available switches are the following ones : + + `-83' + Only the subset on the Ada 83 keywords will be highlighted, not + the full Ada 95 keywords set. + + `-cc COLOR' + This option allows you to change the color used for comments. The + default value is green. The color argument can be any name + accepted by html. + + `-d' + If the ada files depend on some other files (using for instance the + `with' command, the latter will also be converted to html. Only + the files in the user project will be converted to html, not the + files in the run-time library itself. + + `-D' + This command is the same as -d above, but `gnathtml' will also look + for files in the run-time library, and generate html files for + them. + + `-f' + By default, gnathtml will generate html links only for global + entities ('with'ed units, global variables and types,...). If you + specify the `-f' on the command line, then links will be generated + for local entities too. + + `-l NUMBER' + If this switch is provided and NUMBER is not 0, then `gnathtml' + will number the html files every NUMBER line. + + `-I DIR' + Specify a directory to search for library files (`.ali' files) and + source files. You can provide several -I switches on the command + line, and the directories will be parsed in the order of the + command line. + + `-o DIR' + Specify the output directory for html files. By default, gnathtml + will saved the generated html files in a subdirectory named + `html/'. + + `-p FILE' + If you are using Emacs and the most recent Emacs Ada mode, which + provides a full Integrated Development Environment for compiling, + checking, running and debugging applications, you may be using + `.adp' files to give the directories where Emacs can find sources + and object files. + + Using this switch, you can tell gnathtml to use these files. This + allows you to get an html version of your application, even if it + is spread over multiple directories. + + `-sc COLOR' + This option allows you to change the color used for symbol + definitions. The default value is red. The color argument can be + any name accepted by html. + + `-t FILE' + This switch provides the name of a file. This file contains a list + of file names to be converted, and the effect is exactly as though + they had appeared explicitly on the command line. This is the + recommended way to work around the command line length limit on + some systems. + +  + File: gnat_ug_unx.info, Node: Installing gnathtml, Prev: Converting Ada Files to html with gnathtml, Up: Other Utility Programs + + Installing `gnathtml' + ===================== + + `Perl' needs to be installed on your machine to run this script. + `Perl' is freely available for almost every architecture and Operating + System via the Internet. + + On Unix systems, you may want to modify the first line of the + script `gnathtml', to explicitly tell the Operating system where + Perl is. The syntax of this line is : + #!full_path_name_to_perl + + Alternatively, you may run the script using the following command line: + + $ perl gnathtml.pl [switches] files + +  + File: gnat_ug_unx.info, Node: Running and Debugging Ada Programs, Next: Inline Assembler, Prev: Other Utility Programs, Up: Top + + Running and Debugging Ada Programs + ********************************** + + This chapter discusses how to debug Ada programs. An incorrect Ada + program may be handled in three ways by the GNAT compiler: + + 1. The illegality may be a violation of the static semantics of Ada. + In that case GNAT diagnoses the constructs in the program that are + illegal. It is then a straightforward matter for the user to + modify those parts of the program. + + 2. The illegality may be a violation of the dynamic semantics of Ada. + In that case the program compiles and executes, but may generate + incorrect results, or may terminate abnormally with some exception. + + 3. When presented with a program that contains convoluted errors, GNAT + itself may terminate abnormally without providing full diagnostics + on the incorrect user program. + + * Menu: + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + +  + File: gnat_ug_unx.info, Node: The GNAT Debugger GDB, Next: Running GDB, Up: Running and Debugging Ada Programs + + The GNAT Debugger GDB + ===================== + + `GDB' is a general purpose, platform-independent debugger that can be + used to debug mixed-language programs compiled with `GCC', and in + particular is capable of debugging Ada programs compiled with GNAT. The + latest versions of `GDB' are Ada-aware and can handle complex Ada data + structures. + + The manual `Debugging with GDB' contains full details on the usage + of `GDB', including a section on its usage on programs. This manual + should be consulted for full details. The section that follows is a + brief introduction to the philosophy and use of `GDB'. + + When GNAT programs are compiled, the compiler optionally writes + debugging information into the generated object file, including + information on line numbers, and on declared types and variables. This + information is separate from the generated code. It makes the object + files considerably larger, but it does not add to the size of the + actual executable that will be loaded into memory, and has no impact on + run-time performance. The generation of debug information is triggered + by the use of the -g switch in the gcc or gnatmake command used to + carry out the compilations. It is important to emphasize that the use + of these options does not change the generated code. + + The debugging information is written in standard system formats that + are used by many tools, including debuggers and profilers. The format + of the information is typically designed to describe C types and + semantics, but GNAT implements a translation scheme which allows full + details about Ada types and variables to be encoded into these standard + C formats. Details of this encoding scheme may be found in the file + exp_dbug.ads in the GNAT source distribution. However, the details of + this encoding are, in general, of no interest to a user, since `GDB' + automatically performs the necessary decoding. + + When a program is bound and linked, the debugging information is + collected from the object files, and stored in the executable image of + the program. Again, this process significantly increases the size of + the generated executable file, but it does not increase the size of the + executable program itself. Furthermore, if this program is run in the + normal manner, it runs exactly as if the debug information were not + present, and takes no more actual memory. + + However, if the program is run under control of `GDB', the debugger + is activated. The image of the program is loaded, at which point it is + ready to run. If a run command is given, then the program will run + exactly as it would have if `GDB' were not present. This is a crucial + part of the `GDB' design philosophy. `GDB' is entirely non-intrusive + until a breakpoint is encountered. If no breakpoint is ever hit, the + program will run exactly as it would if no debugger were present. When + a breakpoint is hit, `GDB' accesses the debugging information and can + respond to user commands to inspect variables, and more generally to + report on the state of execution. + +  + File: gnat_ug_unx.info, Node: Running GDB, Next: Introduction to GDB Commands, Prev: The GNAT Debugger GDB, Up: Running and Debugging Ada Programs + + Running GDB + =========== + + The debugger can be launched directly and simply from `glide' or + through its graphical interface: `gvd'. It can also be used directly in + text mode. Here is described the basic use of `GDB' in text mode. All + the commands described below can be used in the `gvd' console window + eventhough there is usually other more graphical ways to achieve the + same goals. + + The command to run de graphical interface of the debugger is + $ gvd program + + The command to run `GDB' in text mode is + + $ gdb program + + where `program' is the name of the executable file. This activates the + debugger and results in a prompt for debugger commands. The simplest + command is simply `run', which causes the program to run exactly as if + the debugger were not present. The following section describes some of + the additional commands that can be given to `GDB'. + +  + File: gnat_ug_unx.info, Node: Introduction to GDB Commands, Next: Using Ada Expressions, Prev: Running GDB, Up: Running and Debugging Ada Programs + + Introduction to GDB Commands + ============================ + + `GDB' contains a large repertoire of commands. The manual `Debugging + with GDB' includes extensive documentation on the use of these + commands, together with examples of their use. Furthermore, the command + HELP invoked from within `GDB' activates a simple help facility which + summarizes the available commands and their options. In this section + we summarize a few of the most commonly used commands to give an idea + of what `GDB' is about. You should create a simple program with + debugging information and experiment with the use of these `GDB' + commands on the program as you read through the following section. + + `set args ARGUMENTS' + The ARGUMENTS list above is a list of arguments to be passed to + the program on a subsequent run command, just as though the + arguments had been entered on a normal invocation of the program. + The `set args' command is not needed if the program does not + require arguments. + + `run' + The `run' command causes execution of the program to start from + the beginning. If the program is already running, that is to say if + you are currently positioned at a breakpoint, then a prompt will + ask for confirmation that you want to abandon the current + execution and restart. + + `breakpoint LOCATION' + The breakpoint command sets a breakpoint, that is to say a point + at which execution will halt and `GDB' will await further + commands. LOCATION is either a line number within a file, given in + the format `file:linenumber', or it is the name of a subprogram. + If you request that a breakpoint be set on a subprogram that is + overloaded, a prompt will ask you to specify on which of those + subprograms you want to breakpoint. You can also specify that all + of them should be breakpointed. If the program is run and + execution encounters the breakpoint, then the program stops and + `GDB' signals that the breakpoint was encountered by printing the + line of code before which the program is halted. + + `breakpoint exception NAME' + A special form of the breakpoint command which breakpoints whenever + exception NAME is raised. If NAME is omitted, then a breakpoint + will occur when any exception is raised. + + `print EXPRESSION' + This will print the value of the given expression. Most simple Ada + expression formats are properly handled by `GDB', so the expression + can contain function calls, variables, operators, and attribute + references. + + `continue' + Continues execution following a breakpoint, until the next + breakpoint or the termination of the program. + + `step' + Executes a single line after a breakpoint. If the next statement + is a subprogram call, execution continues into (the first + statement of) the called subprogram. + + `next' + Executes a single line. If this line is a subprogram call, + executes and returns from the call. + + `list' + Lists a few lines around the current source location. In practice, + it is usually more convenient to have a separate edit window open + with the relevant source file displayed. Successive applications + of this command print subsequent lines. The command can be given + an argument which is a line number, in which case it displays a + few lines around the specified one. + + `backtrace' + Displays a backtrace of the call chain. This command is typically + used after a breakpoint has occurred, to examine the sequence of + calls that leads to the current breakpoint. The display includes + one line for each activation record (frame) corresponding to an + active subprogram. + + `up' + At a breakpoint, `GDB' can display the values of variables local + to the current frame. The command `up' can be used to examine the + contents of other active frames, by moving the focus up the stack, + that is to say from callee to caller, one frame at a time. + + `down' + Moves the focus of `GDB' down from the frame currently being + examined to the frame of its callee (the reverse of the previous + command), + + `frame N' + Inspect the frame with the given number. The value 0 denotes the + frame of the current breakpoint, that is to say the top of the + call stack. + + The above list is a very short introduction to the commands that + `GDB' provides. Important additional capabilities, including conditional + breakpoints, the ability to execute command sequences on a breakpoint, + the ability to debug at the machine instruction level and many other + features are described in detail in `Debugging with GDB'. Note that + most commands can be abbreviated (for example, c for continue, bt for + backtrace). + +  + File: gnat_ug_unx.info, Node: Using Ada Expressions, Next: Calling User-Defined Subprograms, Prev: Introduction to GDB Commands, Up: Running and Debugging Ada Programs + + Using Ada Expressions + ===================== + + `GDB' supports a fairly large subset of Ada expression syntax, with some + extensions. The philosophy behind the design of this subset is + + * That `GDB' should provide basic literals and access to operations + for arithmetic, dereferencing, field selection, indexing, and + subprogram calls, leaving more sophisticated computations to + subprograms written into the program (which therefore may be + called from `GDB'). + + * That type safety and strict adherence to Ada language restrictions + are not particularly important to the `GDB' user. + + * That brevity is important to the `GDB' user. + + Thus, for brevity, the debugger acts as if there were implicit + `with' and `use' clauses in effect for all user-written packages, thus + making it unnecessary to fully qualify most names with their packages, + regardless of context. Where this causes ambiguity, `GDB' asks the + user's intent. + + For details on the supported Ada syntax, see `Debugging with GDB'. + +  + File: gnat_ug_unx.info, Node: Calling User-Defined Subprograms, Next: Using the Next Command in a Function, Prev: Using Ada Expressions, Up: Running and Debugging Ada Programs + + Calling User-Defined Subprograms + ================================ + + An important capability of `GDB' is the ability to call user-defined + subprograms while debugging. This is achieved simply by entering a + subprogram call statement in the form: + + call subprogram-name (parameters) + + The keyword `call' can be omitted in the normal case where the + `subprogram-name' does not coincide with any of the predefined `GDB' + commands. + + The effect is to invoke the given subprogram, passing it the list of + parameters that is supplied. The parameters can be expressions and can + include variables from the program being debugged. The subprogram must + be defined at the library level within your program, and `GDB' will + call the subprogram within the environment of your program execution + (which means that the subprogram is free to access or even modify + variables within your program). + + The most important use of this facility is in allowing the inclusion + of debugging routines that are tailored to particular data structures + in your program. Such debugging routines can be written to provide a + suitably high-level description of an abstract type, rather than a + low-level dump of its physical layout. After all, the standard `GDB + print' command only knows the physical layout of your types, not their + abstract meaning. Debugging routines can provide information at the + desired semantic level and are thus enormously useful. + + For example, when debugging GNAT itself, it is crucial to have + access to the contents of the tree nodes used to represent the program + internally. But tree nodes are represented simply by an integer value + (which in turn is an index into a table of nodes). Using the `print' + command on a tree node would simply print this integer value, which is + not very useful. But the PN routine (defined in file treepr.adb in the + GNAT sources) takes a tree node as input, and displays a useful high + level representation of the tree node, which includes the syntactic + category of the node, its position in the source, the integers that + denote descendant nodes and parent node, as well as varied semantic + information. To study this example in more detail, you might want to + look at the body of the PN procedure in the stated file. + +  + File: gnat_ug_unx.info, Node: Using the Next Command in a Function, Next: Ada Exceptions, Prev: Calling User-Defined Subprograms, Up: Running and Debugging Ada Programs + + Using the Next Command in a Function + ==================================== + + When you use the `next' command in a function, the current source + location will advance to the next statement as usual. A special case + arises in the case of a `return' statement. + + Part of the code for a return statement is the "epilog" of the + function. This is the code that returns to the caller. There is only + one copy of this epilog code, and it is typically associated with the + last return statement in the function if there is more than one return. + In some implementations, this epilog is associated with the first + statement of the function. + + The result is that if you use the `next' command from a return + statement that is not the last return statement of the function you may + see a strange apparent jump to the last return statement or to the + start of the function. You should simply ignore this odd jump. The + value returned is always that from the first return statement that was + stepped through. + +  + File: gnat_ug_unx.info, Node: Ada Exceptions, Next: Ada Tasks, Prev: Using the Next Command in a Function, Up: Running and Debugging Ada Programs + + Breaking on Ada Exceptions + ========================== + + You can set breakpoints that trip when your program raises selected + exceptions. + + `break exception' + Set a breakpoint that trips whenever (any task in the) program + raises any exception. + + `break exception NAME' + Set a breakpoint that trips whenever (any task in the) program + raises the exception NAME. + + `break exception unhandled' + Set a breakpoint that trips whenever (any task in the) program + raises an exception for which there is no handler. + + `info exceptions' + `info exceptions REGEXP' + The `info exceptions' command permits the user to examine all + defined exceptions within Ada programs. With a regular expression, + REGEXP, as argument, prints out only those exceptions whose name + matches REGEXP. + +  + File: gnat_ug_unx.info, Node: Ada Tasks, Next: Debugging Generic Units, Prev: Ada Exceptions, Up: Running and Debugging Ada Programs + + Ada Tasks + ========= + + `GDB' allows the following task-related commands: + + `info tasks' + This command shows a list of current Ada tasks, as in the + following example: + + (gdb) info tasks + ID TID P-ID Thread Pri State Name + 1 8088000 0 807e000 15 Child Activation Wait main_task + 2 80a4000 1 80ae000 15 Accept/Select Wait b + 3 809a800 1 80a4800 15 Child Activation Wait a + * 4 80ae800 3 80b8000 15 Running c + + In this listing, the asterisk before the first task indicates it + to be the currently running task. The first column lists the task + ID that is used to refer to tasks in the following commands. + + `break LINESPEC task TASKID' + `break LINESPEC task TASKID if ...' + These commands are like the `break ... thread ...'. LINESPEC + specifies source lines. + + Use the qualifier `task TASKID' with a breakpoint command to + specify that you only want `GDB' to stop the program when a + particular Ada task reaches this breakpoint. TASKID is one of the + numeric task identifiers assigned by `GDB', shown in the first + column of the `info tasks' display. + + If you do not specify `task TASKID' when you set a breakpoint, the + breakpoint applies to _all_ tasks of your program. + + You can use the `task' qualifier on conditional breakpoints as + well; in this case, place `task TASKID' before the breakpoint + condition (before the `if'). + + `task TASKNO' + This command allows to switch to the task referred by TASKNO. In + particular, This allows to browse the backtrace of the specified + task. It is advised to switch back to the original task before + continuing execution otherwise the scheduling of the program may be + perturbated. + + For more detailed information on the tasking support, see `Debugging + with GDB'. + +  + File: gnat_ug_unx.info, Node: Debugging Generic Units, Next: GNAT Abnormal Termination or Failure to Terminate, Prev: Ada Tasks, Up: Running and Debugging Ada Programs + + Debugging Generic Units + ======================= + + GNAT always uses code expansion for generic instantiation. This means + that each time an instantiation occurs, a complete copy of the original + code is made, with appropriate substitutions of formals by actuals. + + It is not possible to refer to the original generic entities in + `GDB', but it is always possible to debug a particular instance of a + generic, by using the appropriate expanded names. For example, if we + have + + procedure g is + + generic package k is + procedure kp (v1 : in out integer); + end k; + + package body k is + procedure kp (v1 : in out integer) is + begin + v1 := v1 + 1; + end kp; + end k; + + package k1 is new k; + package k2 is new k; + + var : integer := 1; + + begin + k1.kp (var); + k2.kp (var); + k1.kp (var); + k2.kp (var); + end; + + Then to break on a call to procedure kp in the k2 instance, simply use + the command: + + (gdb) break g.k2.kp + + When the breakpoint occurs, you can step through the code of the + instance in the normal manner and examine the values of local + variables, as for other units. + +  + File: gnat_ug_unx.info, Node: GNAT Abnormal Termination or Failure to Terminate, Next: Naming Conventions for GNAT Source Files, Prev: Debugging Generic Units, Up: Running and Debugging Ada Programs + + GNAT Abnormal Termination or Failure to Terminate + ================================================= + + When presented with programs that contain serious errors in syntax or + semantics, GNAT may on rare occasions experience problems in + operation, such as aborting with a segmentation fault or illegal memory + access, raising an internal exception, terminating abnormally, or + failing to terminate at all. In such cases, you can activate various + features of GNAT that can help you pinpoint the construct in your + program that is the likely source of the problem. + + The following strategies are presented in increasing order of + difficulty, corresponding to your experience in using GNAT and your + familiarity with compiler internals. + + 1. Run `gcc' with the `-gnatf'. This first switch causes all errors + on a given line to be reported. In its absence, only the first + error on a line is displayed. + + The `-gnatdO' switch causes errors to be displayed as soon as they + are encountered, rather than after compilation is terminated. If + GNAT terminates prematurely or goes into an infinite loop, the + last error message displayed may help to pinpoint the culprit. + + 2. Run `gcc' with the `-v (verbose)' switch. In this mode, `gcc' + produces ongoing information about the progress of the compilation + and provides the name of each procedure as code is generated. This + switch allows you to find which Ada procedure was being compiled + when it encountered a code generation problem. + + 3. Run `gcc' with the `-gnatdc' switch. This is a GNAT specific + switch that does for the front-end what `-v' does for the back end. + The system prints the name of each unit, either a compilation unit + or nested unit, as it is being analyzed. + + 4. Finally, you can start `gdb' directly on the `gnat1' executable. + `gnat1' is the front-end of GNAT, and can be run independently + (normally it is just called from `gcc'). You can use `gdb' on + `gnat1' as you would on a C program (but *note The GNAT Debugger + GDB:: for caveats). The `where' command is the first line of + attack; the variable `lineno' (seen by `print lineno'), used by + the second phase of `gnat1' and by the `gcc' backend, indicates + the source line at which the execution stopped, and `input_file + name' indicates the name of the source file. + +  + File: gnat_ug_unx.info, Node: Naming Conventions for GNAT Source Files, Next: Getting Internal Debugging Information, Prev: GNAT Abnormal Termination or Failure to Terminate, Up: Running and Debugging Ada Programs + + Naming Conventions for GNAT Source Files + ======================================== + + In order to examine the workings of the GNAT system, the following + brief description of its organization may be helpful: + + * Files with prefix `sc' contain the lexical scanner. + + * All files prefixed with `par' are components of the parser. The + numbers correspond to chapters of the Ada 95 Reference Manual. For + example, parsing of select statements can be found in + `par-ch9.adb'. + + * All files prefixed with `sem' perform semantic analysis. The + numbers correspond to chapters of the Ada standard. For example, + all issues involving context clauses can be found in + `sem_ch10.adb'. In addition, some features of the language require + sufficient special processing to justify their own semantic files: + sem_aggr for aggregates, sem_disp for dynamic dispatching, etc. + + * All files prefixed with `exp' perform normalization and expansion + of the intermediate representation (abstract syntax tree, or AST). + these files use the same numbering scheme as the parser and + semantics files. For example, the construction of record + initialization procedures is done in `exp_ch3.adb'. + + * The files prefixed with `bind' implement the binder, which + verifies the consistency of the compilation, determines an order of + elaboration, and generates the bind file. + + * The files `atree.ads' and `atree.adb' detail the low-level data + structures used by the front-end. + + * The files `sinfo.ads' and `sinfo.adb' detail the structure of the + abstract syntax tree as produced by the parser. + + * The files `einfo.ads' and `einfo.adb' detail the attributes of all + entities, computed during semantic analysis. + + * Library management issues are dealt with in files with prefix + `lib'. + + * Ada files with the prefix `a-' are children of `Ada', as defined + in Annex A. + + * Files with prefix `i-' are children of `Interfaces', as defined in + Annex B. + + * Files with prefix `s-' are children of `System'. This includes + both language-defined children and GNAT run-time routines. + + * Files with prefix `g-' are children of `GNAT'. These are useful + general-purpose packages, fully documented in their + specifications. All the other `.c' files are modifications of + common `gcc' files. + +  + File: gnat_ug_unx.info, Node: Getting Internal Debugging Information, Next: Stack Traceback, Prev: Naming Conventions for GNAT Source Files, Up: Running and Debugging Ada Programs + + Getting Internal Debugging Information + ====================================== + + Most compilers have internal debugging switches and modes. GNAT does + also, except GNAT internal debugging switches and modes are not secret. + A summary and full description of all the compiler and binder debug + flags are in the file `debug.adb'. You must obtain the sources of the + compiler to see the full detailed effects of these flags. + + The switches that print the source of the program (reconstructed from + the internal tree) are of general interest for user programs, as are the + options to print the full internal tree, and the entity table (the + symbol table information). The reconstructed source provides a readable + version of the program after the front-end has completed analysis and + expansion, and is useful when studying the performance of specific + constructs. For example, constraint checks are indicated, complex + aggregates are replaced with loops and assignments, and tasking + primitives are replaced with run-time calls. + +  + File: gnat_ug_unx.info, Node: Stack Traceback, Prev: Getting Internal Debugging Information, Up: Running and Debugging Ada Programs + + Stack Traceback + =============== + + Traceback is a mechanism to display the sequence of subprogram calls + that leads to a specified execution point in a program. Often (but not + always) the execution point is an instruction at which an exception has + been raised. This mechanism is also known as stack unwinding because + it obtains its information by scanning the run-time stack and + recovering the activation records of all active subprograms. Stack + unwinding is one of the most important tools for program debugging. + + The first entry stored in traceback corresponds to the deepest calling + level, that is to say the subprogram currently executing the instruction + from which we want to obtain the traceback. + + Note that there is no runtime performance penalty when stack traceback + is enabled and no exception are raised during program execution. + + * Menu: + + * Non-Symbolic Traceback:: + * Symbolic Traceback:: + +  + File: gnat_ug_unx.info, Node: Non-Symbolic Traceback, Next: Symbolic Traceback, Up: Stack Traceback + + Non-Symbolic Traceback + ---------------------- + + Note: this feature is not supported on all platforms. See + `GNAT.Traceback spec in g-traceb.ads' for a complete list of supported + platforms. + + * Menu: + + * Tracebacks From an Unhandled Exception:: + * Tracebacks From Exception Occurrences (non-symbolic):: + * Tracebacks From Anywhere in a Program (non-symbolic):: + +  + File: gnat_ug_unx.info, Node: Tracebacks From an Unhandled Exception, Next: Tracebacks From Exception Occurrences (non-symbolic), Up: Non-Symbolic Traceback + + Tracebacks From an Unhandled Exception + ...................................... + + A runtime non-symbolic traceback is a list of addresses of call + instructions. To enable this feature you must use the `-E' + `gnatbind''s option. With this option a stack traceback is stored as + part of exception information. It is possible to retrieve this + information using the standard `Ada.Exception.Exception_Information' + routine. + + Let's have a look at a simple example: + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + $ gnatmake stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + As we see the traceback lists a sequence of addresses for the unhandled + exception `CONSTAINT_ERROR' raised in procedure P1. It is easy to guess + that this exception come from procedure P1. To translate these + addresses into the source lines where the calls appear, the `addr2line' + tool, described below, is invaluable. The use of this tool requires the + program to be compiled with debug information. + + $ gnatmake -g stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + $ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 + 0x4011f1 0x77e892a4 + + 00401373 at d:/stb/stb.adb:5 + 0040138B at d:/stb/stb.adb:10 + 0040139C at d:/stb/stb.adb:14 + 00401335 at d:/stb/b~stb.adb:104 + 004011C4 at /build/.../crt1.c:200 + 004011F1 at /build/.../crt1.c:222 + 77E892A4 in ?? at ??:0 + + `addr2line' has a number of other useful options: + + `--functions' + to get the function name corresponding to any location + + `--demangle=gnat' + to use the gnat decoding mode for the function names. Note that + for binutils version 2.9.x the option is simply `--demangle'. + + $ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b + 0x40139c 0x401335 0x4011c4 0x4011f1 + + 00401373 in stb.p1 at d:/stb/stb.adb:5 + 0040138B in stb.p2 at d:/stb/stb.adb:10 + 0040139C in stb at d:/stb/stb.adb:14 + 00401335 in main at d:/stb/b~stb.adb:104 + 004011C4 in <__mingw_CRTStartup> at /build/.../crt1.c:200 + 004011F1 in at /build/.../crt1.c:222 + + From this traceback we can see that the exception was raised in + `stb.adb' at line 5, which was reached from a procedure call in + `stb.adb' at line 10, and so on. The `b~std.adb' is the binder file, + which contains the call to the main program. *note Running gnatbind::. + The remaining entries are assorted runtime routines, and the output + will vary from platform to platform. + + It is also possible to use `GDB' with these traceback addresses to debug + the program. For example, we can break at a given code location, as + reported in the stack traceback: + + $ gdb -nw stb + + (gdb) break *0x401373 + Breakpoint 1 at 0x401373: file stb.adb, line 5. + + It is important to note that the stack traceback addresses do not + change when debug information is included. This is particularly useful + because it makes it possible to release software without debug + information (to minimize object size), get a field report that includes + a stack traceback whenever an internal bug occurs, and then be able to + retrieve the sequence of calls with the same program compiled with + debug information. + +  + File: gnat_ug_unx.info, Node: Tracebacks From Exception Occurrences (non-symbolic), Next: Tracebacks From Anywhere in a Program (non-symbolic), Prev: Tracebacks From an Unhandled Exception, Up: Non-Symbolic Traceback + + Tracebacks From Exception Occurrences + ..................................... + + Non-symbolic tracebacks are obtained by using the `-E' binder argument. + The stack traceback is attached to the exception information string, + and can be retrieved in an exception handler within the Ada program, by + means of the Ada95 facilities defined in `Ada.Exceptions'. Here is a + simple example: + + with Ada.Text_IO; + with Ada.Exceptions; + + procedure STB is + + use Ada; + use Ada.Exceptions; + + procedure P1 is + K : Positive := 1; + begin + K := K - 1; + exception + when E : others => + Text_IO.Put_Line (Exception_Information (E)); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + This program will output: + + $ stb + + Exception name: CONSTRAINT_ERROR + Message: stb.adb:12 + Call stack traceback locations: + 0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4 + +  + File: gnat_ug_unx.info, Node: Tracebacks From Anywhere in a Program (non-symbolic), Prev: Tracebacks From Exception Occurrences (non-symbolic), Up: Non-Symbolic Traceback + + Tracebacks From Anywhere in a Program + ..................................... + + It is also possible to retrieve a stack traceback from anywhere in a + program. For this you need to use the `GNAT.Traceback' API. This + package includes a procedure called `Call_Chain' that computes a + complete stack traceback, as well as useful display procedures + described below. It is not necessary to use the `-E gnatbind' option in + this case, because the stack traceback mechanism is invoked explicitly. + + In the following example we compute a traceback at a specific location + in the program, and we display it using `GNAT.Debug_Utilities.Image' to + convert addresses to strings: + + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Debug_Utilities; + + procedure STB is + + use Ada; + use GNAT; + use GNAT.Traceback; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + + Text_IO.Put ("In STB.P1 : "); + + for K in 1 .. Len loop + Text_IO.Put (Debug_Utilities.Image (TB (K))); + Text_IO.Put (' '); + end loop; + + Text_IO.New_Line; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + $ gnatmake stb + $ stb + + In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C# + 16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4# + +  + File: gnat_ug_unx.info, Node: Symbolic Traceback, Prev: Non-Symbolic Traceback, Up: Stack Traceback + + Symbolic Traceback + ------------------ + + A symbolic traceback is a stack traceback in which procedure names are + associated with each code location. + + Note that this feature is not supported on all platforms. See + `GNAT.Traceback.Symbolic spec in g-trasym.ads' for a complete list of + currently supported platforms. + + Note that the symbolic traceback requires that the program be compiled + with debug information. If it is not compiled with debug information + only the non-symbolic information will be valid. + + * Menu: + + * Tracebacks From Exception Occurrences (symbolic):: + * Tracebacks From Anywhere in a Program (symbolic):: + +  + File: gnat_ug_unx.info, Node: Tracebacks From Exception Occurrences (symbolic), Next: Tracebacks From Anywhere in a Program (symbolic), Up: Symbolic Traceback + + Tracebacks From Exception Occurrences + ..................................... + + with Ada.Text_IO; + with GNAT.Traceback.Symbolic; + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + procedure P3 is + begin + P2; + end P3; + + begin + P3; + exception + when E : others => + Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); + end STB; + + $ gnatmake -g stb -bargs -E -largs -lgnat -laddr2line -lintl + $ stb + + 0040149F in stb.p1 at stb.adb:8 + 004014B7 in stb.p2 at stb.adb:13 + 004014CF in stb.p3 at stb.adb:18 + 004015DD in ada.stb at stb.adb:22 + 00401461 in main at b~stb.adb:168 + 004011C4 in __mingw_CRTStartup at crt1.c:200 + 004011F1 in mainCRTStartup at crt1.c:222 + 77E892A4 in ?? at ??:0 + + The exact sequence of linker options may vary from platform to platform. + The above `-largs' section is for Windows platforms. By contrast, under + Unix there is no need for the `-largs' section. Differences across + platforms are due to details of linker implementation. + +  + File: gnat_ug_unx.info, Node: Tracebacks From Anywhere in a Program (symbolic), Prev: Tracebacks From Exception Occurrences (symbolic), Up: Symbolic Traceback + + Tracebacks From Anywhere in a Program + ..................................... + + It is possible to get a symbolic stack traceback from anywhere in a + program, just as for non-symbolic tracebacks. The first step is to + obtain a non-symbolic traceback, and then call `Symbolic_Traceback' to + compute the symbolic information. Here is an example: + + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Traceback.Symbolic; + + procedure STB is + + use Ada; + use GNAT.Traceback; + use GNAT.Traceback.Symbolic; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len))); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + +  + File: gnat_ug_unx.info, Node: Inline Assembler, Next: Performance Considerations, Prev: Running and Debugging Ada Programs, Up: Top + + Inline Assembler + **************** + + If you need to write low-level software that interacts directly with + the hardware, Ada provides two ways to incorporate assembly language + code into your program. First, you can import and invoke external + routines written in assembly language, an Ada feature fully supported + by GNAT. However, for small sections of code it may be simpler or more + efficient to include assembly language statements directly in your Ada + source program, using the facilities of the implementation-defined + package `System.Machine_Code', which incorporates the gcc Inline + Assembler. The Inline Assembler approach offers a number of + advantages, including the following: + + * No need to use non-Ada tools + + * Consistent interface over different targets + + * Automatic usage of the proper calling conventions + + * Access to Ada constants and variables + + * Definition of intrinsic routines + + * Possibility of inlining a subprogram comprising assembler code + + * Code optimizer can take Inline Assembler code into account + + This chapter presents a series of examples to show you how to use + the Inline Assembler. Although it focuses on the Intel x86, the + general approach applies also to other processors. It is assumed that + you are familiar with Ada and with assembly language programming. + + * Menu: + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + +  + File: gnat_ug_unx.info, Node: Basic Assembler Syntax, Next: A Simple Example of Inline Assembler, Up: Inline Assembler + + Basic Assembler Syntax + ====================== + + The assembler used by GNAT and gcc is based not on the Intel assembly + language, but rather on a language that descends from the AT&T Unix + assembler _as_ (and which is often referred to as "AT&T syntax"). The + following table summarizes the main features of _as_ syntax and points + out the differences from the Intel conventions. See the gcc _as_ and + _gas_ (an _as_ macro pre-processor) documentation for further + information. + + Register names + gcc / _as_: Prefix with "%"; for example `%eax' + Intel: No extra punctuation; for example `eax' + + Immediate operand + gcc / _as_: Prefix with "$"; for example `$4' + Intel: No extra punctuation; for example `4' + + Address + gcc / _as_: Prefix with "$"; for example `$loc' + Intel: No extra punctuation; for example `loc' + + Memory contents + gcc / _as_: No extra punctuation; for example `loc' + Intel: Square brackets; for example `[loc]' + + Register contents + gcc / _as_: Parentheses; for example `(%eax)' + Intel: Square brackets; for example `[eax]' + + Hexadecimal numbers + gcc / _as_: Leading "0x" (C language syntax); for example `0xA0' + Intel: Trailing "h"; for example `A0h' + + Operand size + gcc / _as_: Explicit in op code; for example `movw' to move a + 16-bit word + Intel: Implicit, deduced by assembler; for example `mov' + + Instruction repetition + gcc / _as_: Split into two lines; for example + `rep' + `stosl' + Intel: Keep on one line; for example `rep stosl' + + Order of operands + gcc / _as_: Source first; for example `movw $4, %eax' + Intel: Destination first; for example `mov eax, 4' + +  + File: gnat_ug_unx.info, Node: A Simple Example of Inline Assembler, Next: Output Variables in Inline Assembler, Prev: Basic Assembler Syntax, Up: Inline Assembler + + A Simple Example of Inline Assembler + ==================================== + + The following example will generate a single assembly language + statement, `nop', which does nothing. Despite its lack of run-time + effect, the example will be useful in illustrating the basics of the + Inline Assembler facility. + + with System.Machine_Code; use System.Machine_Code; + procedure Nothing is + begin + Asm ("nop"); + end Nothing; + + `Asm' is a procedure declared in package `System.Machine_Code'; here + it takes one parameter, a _template string_ that must be a static + expression and that will form the generated instruction. `Asm' may be + regarded as a compile-time procedure that parses the template string + and additional parameters (none here), from which it generates a + sequence of assembly language instructions. + + The examples in this chapter will illustrate several of the forms + for invoking `Asm'; a complete specification of the syntax is found in + the `GNAT Reference Manual'. + + Under the standard GNAT conventions, the `Nothing' procedure should + be in a file named `nothing.adb'. You can build the executable in the + usual way: + gnatmake nothing + However, the interesting aspect of this example is not its run-time + behavior but rather the generated assembly code. To see this output, + invoke the compiler as follows: + gcc -c -S -fomit-frame-pointer -gnatp `nothing.adb' + where the options are: + + `-c' + compile only (no bind or link) + + `-S' + generate assembler listing + + `-fomit-frame-pointer' + do not set up separate stack frames + + `-gnatp' + do not add runtime checks + + This gives a human-readable assembler version of the code. The + resulting file will have the same name as the Ada source file, but with + a `.s' extension. In our example, the file `nothing.s' has the + following contents: + + .file "nothing.adb" + gcc2_compiled.: + ___gnu_compiled_ada: + .text + .align 4 + .globl __ada_nothing + __ada_nothing: + #APP + nop + #NO_APP + jmp L1 + .align 2,0x90 + L1: + ret + + The assembly code you included is clearly indicated by the compiler, + between the `#APP' and `#NO_APP' delimiters. The character before the + 'APP' and 'NOAPP' can differ on different targets. For example, Linux + uses '#APP' while on NT you will see '/APP'. + + If you make a mistake in your assembler code (such as using the + wrong size modifier, or using a wrong operand for the instruction) GNAT + will report this error in a temporary file, which will be deleted when + the compilation is finished. Generating an assembler file will help in + such cases, since you can assemble this file separately using the _as_ + assembler that comes with gcc. + + Assembling the file using the command + + as `nothing.s' + + will give you error messages whose lines correspond to the assembler + input file, so you can easily find and correct any mistakes you made. + If there are no errors, _as_ will generate an object file `nothing.out'. + +  + File: gnat_ug_unx.info, Node: Output Variables in Inline Assembler, Next: Input Variables in Inline Assembler, Prev: A Simple Example of Inline Assembler, Up: Inline Assembler + + Output Variables in Inline Assembler + ==================================== + + The examples in this section, showing how to access the processor + flags, illustrate how to specify the destination operands for assembly + language statements. + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags; + + In order to have a nicely aligned assembly listing, we have separated + multiple assembler statements in the Asm template string with linefeed + (ASCII.LF) and horizontal tab (ASCII.HT) characters. The resulting + section of the assembly output file is: + + #APP + pushfl + popl %eax + movl %eax, -40(%ebp) + #NO_APP + + It would have been legal to write the Asm invocation as: + + Asm ("pushfl popl %%eax movl %%eax, %0") + + but in the generated assembler file, this would come out as: + + #APP + pushfl popl %eax movl %eax, -40(%ebp) + #NO_APP + + which is not so convenient for the human reader. + + We use Ada comments at the end of each line to explain what the + assembler instructions actually do. This is a useful convention. + + When writing Inline Assembler instructions, you need to precede each + register and variable name with a percent sign. Since the assembler + already requires a percent sign at the beginning of a register name, + you need two consecutive percent signs for such names in the Asm + template string, thus `%%eax'. In the generated assembly code, one of + the percent signs will be stripped off. + + Names such as `%0', `%1', `%2', etc., denote input or output + variables: operands you later define using `Input' or `Output' + parameters to `Asm'. An output variable is illustrated in the third + statement in the Asm template string: + movl %%eax, %0 + The intent is to store the contents of the eax register in a + variable that can be accessed in Ada. Simply writing `movl %%eax, + Flags' would not necessarily work, since the compiler might optimize by + using a register to hold Flags, and the expansion of the `movl' + instruction would not be aware of this optimization. The solution is + not to store the result directly but rather to advise the compiler to + choose the correct operand form; that is the purpose of the `%0' output + variable. + + Information about the output variable is supplied in the `Outputs' + parameter to `Asm': + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + + The output is defined by the `Asm_Output' attribute of the target + type; the general format is + Type'Asm_Output (constraint_string, variable_name) + + The constraint string directs the compiler how to store/access the + associated variable. In the example + Unsigned_32'Asm_Output ("=m", Flags); + the `"m"' (memory) constraint tells the compiler that the variable + `Flags' should be stored in a memory variable, thus preventing the + optimizer from keeping it in a register. In contrast, + Unsigned_32'Asm_Output ("=r", Flags); + uses the `"r"' (register) constraint, telling the compiler to store + the variable in a register. + + If the constraint is preceded by the equal character (*=*), it tells + the compiler that the variable will be used to store data into it. + + In the `Get_Flags' example, we used the "g" (global) constraint, + allowing the optimizer to choose whatever it deems best. + + There are a fairly large number of constraints, but the ones that + are most useful (for the Intel x86 processor) are the following: + + `=' + output constraint + + `g' + global (i.e. can be stored anywhere) + + `m' + in memory + + `I' + a constant + + `a' + use eax + + `b' + use ebx + + `c' + use ecx + + `d' + use edx + + `S' + use esi + + `D' + use edi + + `r' + use one of eax, ebx, ecx or edx + + `q' + use one of eax, ebx, ecx, edx, esi or edi + + The full set of constraints is described in the gcc and _as_ + documentation; note that it is possible to combine certain constraints + in one constraint string. + + You specify the association of an output variable with an assembler + operand through the `%'_n_ notation, where _n_ is a non-negative + integer. Thus in + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + + `%0' will be replaced in the expanded code by the appropriate operand, + whatever the compiler decided for the `Flags' variable. + + In general, you may have any number of output variables: + * Count the operands starting at 0; thus `%0', `%1', etc. + + * Specify the `Outputs' parameter as a parenthesized comma-separated + list of `Asm_Output' attributes + + For example: + Asm ("movl %%eax, %0" & LF & HT & + "movl %%ebx, %1" & LF & HT & + "movl %%ecx, %2", + Outputs => (Unsigned_32'Asm_Output ("=g", Var_A), -- %0 = Var_A + Unsigned_32'Asm_Output ("=g", Var_B), -- %1 = Var_B + Unsigned_32'Asm_Output ("=g", Var_C))); -- %2 = Var_C + + where `Var_A', `Var_B', and `Var_C' are variables in the Ada program. + + As a variation on the `Get_Flags' example, we can use the + constraints string to direct the compiler to store the eax register + into the `Flags' variable, instead of including the store instruction + explicitly in the `Asm' template string: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_2 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax", -- save flags in eax + Outputs => Unsigned_32'Asm_Output ("=a", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_2; + + The `"a"' constraint tells the compiler that the `Flags' variable will + come from the eax register. Here is the resulting code: + + #APP + pushfl + popl %eax + #NO_APP + movl %eax,-40(%ebp) + + The compiler generated the store of eax into Flags after expanding the + assembler code. + + Actually, there was no need to pop the flags into the eax register; + more simply, we could just pop the flags directly into the program + variable: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_3 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "pop %0", -- save flags in Flags + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_3; + +  + File: gnat_ug_unx.info, Node: Input Variables in Inline Assembler, Next: Inlining Inline Assembler Code, Prev: Output Variables in Inline Assembler, Up: Inline Assembler + + Input Variables in Inline Assembler + =================================== + + The example in this section illustrates how to specify the source + operands for assembly language statements. The program simply + increments its input value by 1: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Incr (Value); + Put_Line ("Value after is" & Value'Img); + end Increment; + + The `Outputs' parameter to `Asm' specifies that the result will be + in the eax register and that it is to be stored in the `Result' + variable. + + The `Inputs' parameter looks much like the `Outputs' parameter, but + with an `Asm_Input' attribute. The `"="' constraint, indicating an + output value, is not present. + + You can have multiple input variables, in the same way that you can + have more than one output variable. + + The parameter count (%0, %1) etc, now starts at the first input + statement, and continues with the output statements. When both + parameters use the same variable, the compiler will treat them as the + same %n operand, which is the case here. + + Just as the `Outputs' parameter causes the register to be stored + into the target variable after execution of the assembler statements, + so does the `Inputs' parameter cause its variable to be loaded into the + register before execution of the assembler statements. + + Thus the effect of the `Asm' invocation is: + 1. load the 32-bit value of `Value' into eax + + 2. execute the `incl %eax' instruction + + 3. store the contents of eax into the `Result' variable + + The resulting assembler file (with `-O2' optimization) contains: + _increment__incr.1: + subl $4,%esp + movl 8(%esp),%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + movl %ecx,(%esp) + addl $4,%esp + ret + +  + File: gnat_ug_unx.info, Node: Inlining Inline Assembler Code, Next: Other Asm Functionality, Prev: Input Variables in Inline Assembler, Up: Inline Assembler + + Inlining Inline Assembler Code + ============================== + + For a short subprogram such as the `Incr' function in the previous + section, the overhead of the call and return (creating / deleting the + stack frame) can be significant, compared to the amount of code in the + subprogram body. A solution is to apply Ada's `Inline' pragma to the + subprogram, which directs the compiler to expand invocations of the + subprogram at the point(s) of call, instead of setting up a stack frame + for out-of-line calls. Here is the resulting program: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment_2 is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + pragma Inline (Increment); + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Increment (Value); + Put_Line ("Value after is" & Value'Img); + end Increment_2; + + Compile the program with both optimization (`-O2') and inlining + enabled (`-gnatpn' instead of `-gnatp'). + + The `Incr' function is still compiled as usual, but at the point in + `Increment' where our function used to be called: + + pushl %edi + call _increment__incr.1 + + the code for the function body directly appears: + + movl %esi,%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + + thus saving the overhead of stack frame setup and an out-of-line call. + +  + File: gnat_ug_unx.info, Node: Other Asm Functionality, Next: A Complete Example, Prev: Inlining Inline Assembler Code, Up: Inline Assembler + + Other `Asm' Functionality + ========================= + + This section describes two important parameters to the `Asm' procedure: + `Clobber', which identifies register usage; and `Volatile', which + inhibits unwanted optimizations. + + * Menu: + + * The Clobber Parameter:: + * The Volatile Parameter:: + +  + File: gnat_ug_unx.info, Node: The Clobber Parameter, Next: The Volatile Parameter, Up: Other Asm Functionality + + The `Clobber' Parameter + ----------------------- + + One of the dangers of intermixing assembly language and a compiled + language such as Ada is that the compiler needs to be aware of which + registers are being used by the assembly code. In some cases, such as + the earlier examples, the constraint string is sufficient to indicate + register usage (e.g. "a" for the eax register). But more generally, the + compiler needs an explicit identification of the registers that are + used by the Inline Assembly statements. + + Using a register that the compiler doesn't know about could be a + side effect of an instruction (like `mull' storing its result in both + eax and edx). It can also arise from explicit register usage in your + assembly code; for example: + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out)); + + where the compiler (since it does not analyze the `Asm' template string) + does not know you are using the ebx register. + + In such cases you need to supply the `Clobber' parameter to `Asm', + to identify the registers that will be used by your assembly code: + + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx"); + + The Clobber parameter is a static string expression specifying the + register(s) you are using. Note that register names are _not_ prefixed + by a percent sign. Also, if more than one register is used then their + names are separated by commas; e.g., `"eax, ebx"' + + The `Clobber' parameter has several additional uses: + 1. Use the "register" name `cc' to indicate that flags might have + changed + + 2. Use the "register" name `memory' if you changed a memory location + +  + File: gnat_ug_unx.info, Node: The Volatile Parameter, Prev: The Clobber Parameter, Up: Other Asm Functionality + + The `Volatile' Parameter + ------------------------ + + Compiler optimizations in the presence of Inline Assembler may + sometimes have unwanted effects. For example, when an `Asm' invocation + with an input variable is inside a loop, the compiler might move the + loading of the input variable outside the loop, regarding it as a + one-time initialization. + + If this effect is not desired, you can disable such optimizations by + setting the `Volatile' parameter to `True'; for example: + + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx", + Volatile => True); + + By default, `Volatile' is set to `False' unless there is no `Outputs' + parameter. + + Although setting `Volatile' to `True' prevents unwanted + optimizations, it will also disable other optimizations that might be + important for efficiency. In general, you should set `Volatile' to + `True' only if the compiler's optimizations have created problems. + +  + File: gnat_ug_unx.info, Node: A Complete Example, Prev: Other Asm Functionality, Up: Inline Assembler + + A Complete Example + ================== + + This section contains a complete program illustrating a realistic usage + of GNAT's Inline Assembler capabilities. It comprises a main procedure + `Check_CPU' and a package `Intel_CPU'. The package declares a + collection of functions that detect the properties of the 32-bit x86 + processor that is running the program. The main procedure invokes + these functions and displays the information. + + The Intel_CPU package could be enhanced by adding functions to + detect the type of x386 co-processor, the processor caching options and + special operations such as the SIMD extensions. + + Although the Intel_CPU package has been written for 32-bit Intel + compatible CPUs, it is OS neutral. It has been tested on DOS, + Windows/NT and Linux. + + * Menu: + + * Check_CPU Procedure:: + * Intel_CPU Package Specification:: + * Intel_CPU Package Body:: + +  + File: gnat_ug_unx.info, Node: Check_CPU Procedure, Next: Intel_CPU Package Specification, Up: A Complete Example + + `Check_CPU' Procedure + --------------------- + + --------------------------------------------------------------------- + -- -- + -- Uses the Intel_CPU package to identify the CPU the program is -- + -- running on, and some of the features it supports. -- + -- -- + --------------------------------------------------------------------- + + with Intel_CPU; -- Intel CPU detection functions + with Ada.Text_IO; -- Standard text I/O + with Ada.Command_Line; -- To set the exit status + + procedure Check_CPU is + + Type_Found : Boolean := False; + -- Flag to indicate that processor was identified + + Features : Intel_CPU.Processor_Features; + -- The processor features + + Signature : Intel_CPU.Processor_Signature; + -- The processor type signature + + begin + + ----------------------------------- + -- Display the program banner. -- + ----------------------------------- + + Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name & + ": check Intel CPU version and features, v1.0"); + Ada.Text_IO.Put_Line ("distribute freely, but no warranty whatsoever"); + Ada.Text_IO.New_Line; + + ----------------------------------------------------------------------- + -- We can safely start with the assumption that we are on at least -- + -- a x386 processor. If the CPUID instruction is present, then we -- + -- have a later processor type. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Has_CPUID = False then + + -- No CPUID instruction, so we assume this is indeed a x386 + -- processor. We can still check if it has a FP co-processor. + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line + ("x386-type processor with a FP co-processor"); + else + Ada.Text_IO.Put_Line + ("x386-type processor without a FP co-processor"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check for CPUID + + ----------------------------------------------------------------------- + -- If CPUID is supported, check if this is a true Intel processor, -- + -- if it is not, display a warning. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Vendor_ID /= Intel_CPU.Intel_Processor then + Ada.Text_IO.Put_Line ("*** This is a Intel compatible processor"); + Ada.Text_IO.Put_Line ("*** Some information may be incorrect"); + end if; -- check if Intel + + ---------------------------------------------------------------------- + -- With the CPUID instruction present, we can assume at least a -- + -- x486 processor. If the CPUID support level is < 1 then we have -- + -- to leave it at that. -- + ---------------------------------------------------------------------- + + if Intel_CPU.CPUID_Level < 1 then + + -- Ok, this is a x486 processor. we still can get the Vendor ID + Ada.Text_IO.Put_Line ("x486-type processor"); + Ada.Text_IO.Put_Line ("Vendor ID is " & Intel_CPU.Vendor_ID); + + -- We can also check if there is a FPU present + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line ("Floating-Point support"); + else + Ada.Text_IO.Put_Line ("No Floating-Point support"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check CPUID level + + --------------------------------------------------------------------- + -- With a CPUID level of 1 we can use the processor signature to -- + -- determine it's exact type. -- + --------------------------------------------------------------------- + + Signature := Intel_CPU.Signature; + + ---------------------------------------------------------------------- + -- Ok, now we go into a lot of messy comparisons to get the -- + -- processor type. For clarity, no attememt to try to optimize the -- + -- comparisons has been made. Note that since Intel_CPU does not -- + -- support getting cache info, we cannot distinguish between P5 -- + -- and Celeron types yet. -- + ---------------------------------------------------------------------- + + -- x486SL + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486SL processor"); + end if; + + -- x486DX2 Write-Back + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0111# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Write-Back Enhanced x486DX2 processor"); + end if; + + -- x486DX4 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 processor"); + end if; + + -- x486DX4 Overdrive + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 OverDrive processor"); + end if; + + -- Pentium (60, 66) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium processor (60, 66)"); + end if; + + -- Pentium (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive (60, 66) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium OverDrive processor (60, 66)"); + end if; + + -- Pentium OverDrive (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive cpu (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive processor for x486 processor-based systems + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor for x486 processor-based systems"); + end if; + + -- Pentium processor with MMX technology (166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor with MMX technology (166, 200)"); + end if; + + -- Pentium OverDrive with MMX for Pentium (75, 90, 100, 120, 133) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor with MMX " & + "technology for Pentium processor (75, 90, 100, 120, 133)"); + end if; + + -- Pentium Pro processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro processor"); + end if; + + -- Pentium II processor, model 3 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium II processor, model 3"); + end if; + + -- Pentium II processor, model 5 or Celeron processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0101# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium II processor, model 5 or Celeron processor"); + end if; + + -- Pentium Pro OverDrive processor + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro OverDrive processor"); + end if; + + -- If no type recognized, we have an unknown. Display what + -- we _do_ know + if Type_Found = False then + Ada.Text_IO.Put_Line ("Unknown processor"); + end if; + + ----------------------------------------- + -- Display processor stepping level. -- + ----------------------------------------- + + Ada.Text_IO.Put_Line ("Stepping level:" & Signature.Stepping'Img); + + --------------------------------- + -- Display vendor ID string. -- + --------------------------------- + + Ada.Text_IO.Put_Line ("Vendor ID: " & Intel_CPU.Vendor_ID); + + ------------------------------------ + -- Get the processors features. -- + ------------------------------------ + + Features := Intel_CPU.Features; + + ----------------------------- + -- Check for a FPU unit. -- + ----------------------------- + + if Features.FPU = True then + Ada.Text_IO.Put_Line ("Floating-Point unit available"); + else + Ada.Text_IO.Put_Line ("no Floating-Point unit"); + end if; -- check for FPU + + -------------------------------- + -- List processor features. -- + -------------------------------- + + Ada.Text_IO.Put_Line ("Supported features: "); + + -- Virtual Mode Extension + if Features.VME = True then + Ada.Text_IO.Put_Line (" VME - Virtual Mode Extension"); + end if; + + -- Debugging Extension + if Features.DE = True then + Ada.Text_IO.Put_Line (" DE - Debugging Extension"); + end if; + + -- Page Size Extension + if Features.PSE = True then + Ada.Text_IO.Put_Line (" PSE - Page Size Extension"); + end if; + + -- Time Stamp Counter + if Features.TSC = True then + Ada.Text_IO.Put_Line (" TSC - Time Stamp Counter"); + end if; + + -- Model Specific Registers + if Features.MSR = True then + Ada.Text_IO.Put_Line (" MSR - Model Specific Registers"); + end if; + + -- Physical Address Extension + if Features.PAE = True then + Ada.Text_IO.Put_Line (" PAE - Physical Address Extension"); + end if; + + -- Machine Check Extension + if Features.MCE = True then + Ada.Text_IO.Put_Line (" MCE - Machine Check Extension"); + end if; + + -- CMPXCHG8 instruction supported + if Features.CX8 = True then + Ada.Text_IO.Put_Line (" CX8 - CMPXCHG8 instruction"); + end if; + + -- on-chip APIC hardware support + if Features.APIC = True then + Ada.Text_IO.Put_Line (" APIC - on-chip APIC hardware support"); + end if; + + -- Fast System Call + if Features.SEP = True then + Ada.Text_IO.Put_Line (" SEP - Fast System Call"); + end if; + + -- Memory Type Range Registers + if Features.MTRR = True then + Ada.Text_IO.Put_Line (" MTTR - Memory Type Range Registers"); + end if; + + -- Page Global Enable + if Features.PGE = True then + Ada.Text_IO.Put_Line (" PGE - Page Global Enable"); + end if; + + -- Machine Check Architecture + if Features.MCA = True then + Ada.Text_IO.Put_Line (" MCA - Machine Check Architecture"); + end if; + + -- Conditional Move Instruction Supported + if Features.CMOV = True then + Ada.Text_IO.Put_Line + (" CMOV - Conditional Move Instruction Supported"); + end if; + + -- Page Attribute Table + if Features.PAT = True then + Ada.Text_IO.Put_Line (" PAT - Page Attribute Table"); + end if; + + -- 36-bit Page Size Extension + if Features.PSE_36 = True then + Ada.Text_IO.Put_Line (" PSE_36 - 36-bit Page Size Extension"); + end if; + + -- MMX technology supported + if Features.MMX = True then + Ada.Text_IO.Put_Line (" MMX - MMX technology supported"); + end if; + + -- Fast FP Save and Restore + if Features.FXSR = True then + Ada.Text_IO.Put_Line (" FXSR - Fast FP Save and Restore"); + end if; + + --------------------- + -- Program done. -- + --------------------- + + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + + exception + + when others => + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); + raise; + + end Check_CPU; + +  + File: gnat_ug_unx.info, Node: Intel_CPU Package Specification, Next: Intel_CPU Package Body, Prev: Check_CPU Procedure, Up: A Complete Example + + `Intel_CPU' Package Specification + --------------------------------- + + ------------------------------------------------------------------------- + -- -- + -- file: intel_cpu.ads -- + -- -- + -- ********************************************* -- + -- * WARNING: for 32-bit Intel processors only * -- + -- ********************************************* -- + -- -- + -- This package contains a number of subprograms that are useful in -- + -- determining the Intel x86 CPU (and the features it supports) on -- + -- which the program is running. -- + -- -- + -- The package is based upon the information given in the Intel -- + -- Application Note AP-485: "Intel Processor Identification and the -- + -- CPUID Instruction" as of April 1998. This application note can be -- + -- found on www.intel.com. -- + -- -- + -- It currently deals with 32-bit processors only, will not detect -- + -- features added after april 1998, and does not guarantee proper -- + -- results on Intel-compatible processors. -- + -- -- + -- Cache info and x386 fpu type detection are not supported. -- + -- -- + -- This package does not use any privileged instructions, so should -- + -- work on any OS running on a 32-bit Intel processor. -- + -- -- + ------------------------------------------------------------------------- + + with Interfaces; use Interfaces; + -- for using unsigned types + + with System.Machine_Code; use System.Machine_Code; + -- for using inline assembler code + + with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; + -- for inserting control characters + + package Intel_CPU is + + ---------------------- + -- Processor bits -- + ---------------------- + + subtype Num_Bits is Natural range 0 .. 31; + -- the number of processor bits (32) + + -------------------------- + -- Processor register -- + -------------------------- + + -- define a processor register type for easy access to + -- the individual bits + + type Processor_Register is array (Num_Bits) of Boolean; + pragma Pack (Processor_Register); + for Processor_Register'Size use 32; + + ------------------------- + -- Unsigned register -- + ------------------------- + + -- define a processor register type for easy access to + -- the individual bytes + + type Unsigned_Register is + record + L1 : Unsigned_8; + H1 : Unsigned_8; + L2 : Unsigned_8; + H2 : Unsigned_8; + end record; + + for Unsigned_Register use + record + L1 at 0 range 0 .. 7; + H1 at 0 range 8 .. 15; + L2 at 0 range 16 .. 23; + H2 at 0 range 24 .. 31; + end record; + + for Unsigned_Register'Size use 32; + + --------------------------------- + -- Intel processor vendor ID -- + --------------------------------- + + Intel_Processor : constant String (1 .. 12) := "GenuineIntel"; + -- indicates an Intel manufactured processor + + ------------------------------------ + -- Processor signature register -- + ------------------------------------ + + -- a register type to hold the processor signature + + type Processor_Signature is + record + Stepping : Natural range 0 .. 15; + Model : Natural range 0 .. 15; + Family : Natural range 0 .. 15; + Processor_Type : Natural range 0 .. 3; + Reserved : Natural range 0 .. 262143; + end record; + + for Processor_Signature use + record + Stepping at 0 range 0 .. 3; + Model at 0 range 4 .. 7; + Family at 0 range 8 .. 11; + Processor_Type at 0 range 12 .. 13; + Reserved at 0 range 14 .. 31; + end record; + + for Processor_Signature'Size use 32; + + ----------------------------------- + -- Processor features register -- + ----------------------------------- + + -- a processor register to hold the processor feature flags + + type Processor_Features is + record + FPU : Boolean; -- floating point unit on chip + VME : Boolean; -- virtual mode extension + DE : Boolean; -- debugging extension + PSE : Boolean; -- page size extension + TSC : Boolean; -- time stamp counter + MSR : Boolean; -- model specific registers + PAE : Boolean; -- physical address extension + MCE : Boolean; -- machine check extension + CX8 : Boolean; -- cmpxchg8 instruction + APIC : Boolean; -- on-chip apic hardware + Res_1 : Boolean; -- reserved for extensions + SEP : Boolean; -- fast system call + MTRR : Boolean; -- memory type range registers + PGE : Boolean; -- page global enable + MCA : Boolean; -- machine check architecture + CMOV : Boolean; -- conditional move supported + PAT : Boolean; -- page attribute table + PSE_36 : Boolean; -- 36-bit page size extension + Res_2 : Natural range 0 .. 31; -- reserved for extensions + MMX : Boolean; -- MMX technology supported + FXSR : Boolean; -- fast FP save and restore + Res_3 : Natural range 0 .. 127; -- reserved for extensions + end record; + + for Processor_Features use + record + FPU at 0 range 0 .. 0; + VME at 0 range 1 .. 1; + DE at 0 range 2 .. 2; + PSE at 0 range 3 .. 3; + TSC at 0 range 4 .. 4; + MSR at 0 range 5 .. 5; + PAE at 0 range 6 .. 6; + MCE at 0 range 7 .. 7; + CX8 at 0 range 8 .. 8; + APIC at 0 range 9 .. 9; + Res_1 at 0 range 10 .. 10; + SEP at 0 range 11 .. 11; + MTRR at 0 range 12 .. 12; + PGE at 0 range 13 .. 13; + MCA at 0 range 14 .. 14; + CMOV at 0 range 15 .. 15; + PAT at 0 range 16 .. 16; + PSE_36 at 0 range 17 .. 17; + Res_2 at 0 range 18 .. 22; + MMX at 0 range 23 .. 23; + FXSR at 0 range 24 .. 24; + Res_3 at 0 range 25 .. 31; + end record; + + for Processor_Features'Size use 32; + + ------------------- + -- Subprograms -- + ------------------- + + function Has_FPU return Boolean; + -- return True if a FPU is found + -- use only if CPUID is not supported + + function Has_CPUID return Boolean; + -- return True if the processor supports the CPUID instruction + + function CPUID_Level return Natural; + -- return the CPUID support level (0, 1 or 2) + -- can only be called if the CPUID instruction is supported + + function Vendor_ID return String; + -- return the processor vendor identification string + -- can only be called if the CPUID instruction is supported + + function Signature return Processor_Signature; + -- return the processor signature + -- can only be called if the CPUID instruction is supported + + function Features return Processor_Features; + -- return the processors features + -- can only be called if the CPUID instruction is supported + + private + + ------------------------ + -- EFLAGS bit names -- + ------------------------ + + ID_Flag : constant Num_Bits := 21; + -- ID flag bit + + end Intel_CPU; + +  + File: gnat_ug_unx.info, Node: Intel_CPU Package Body, Prev: Intel_CPU Package Specification, Up: A Complete Example + + `Intel_CPU' Package Body + ------------------------ + + package body Intel_CPU is + + --------------------------- + -- Detect FPU presence -- + --------------------------- + + -- There is a FPU present if we can set values to the FPU Status + -- and Control Words. + + function Has_FPU return Boolean is + + Register : Unsigned_16; + -- processor register to store a word + + begin + + -- check if we can change the status word + Asm ( + + -- the assembler code + "finit" & LF & HT & -- reset status word + "movw $0x5A5A, %%ax" & LF & HT & -- set value status word + "fnstsw %0" & LF & HT & -- save status word + "movw %%ax, %0", -- store status word + + -- output stored in Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register), + + -- tell compiler that we used eax + Clobber => "eax"); + + -- if the status word is zero, there is no FPU + if Register = 0 then + return False; -- no status word + end if; -- check status word value + + -- check if we can get the control word + Asm ( + + -- the assembler code + "fnstcw %0", -- save the control word + + -- output into Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register)); + + -- check the relevant bits + if (Register and 16#103F#) /= 16#003F# then + return False; -- no control word + end if; -- check control word value + + -- FPU found + return True; + + end Has_FPU; + + -------------------------------- + -- Detect CPUID instruction -- + -------------------------------- + + -- The processor supports the CPUID instruction if it is possible + -- to change the value of ID flag bit in the EFLAGS register. + + function Has_CPUID return Boolean is + + Original_Flags, Modified_Flags : Processor_Register; + -- EFLAG contents before and after changing the ID flag + + begin + + -- try flipping the ID flag in the EFLAGS register + Asm ( + + -- the assembler code + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %%eax" & LF & HT & -- pop EFLAGS into eax + "movl %%eax, %0" & LF & HT & -- save EFLAGS content + "xor $0x200000, %%eax" & LF & HT & -- flip ID flag + "push %%eax" & LF & HT & -- push EFLAGS on stack + "popfl" & LF & HT & -- load EFLAGS register + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %1", -- save EFLAGS content + + -- output values, may be anything + -- Original_Flags is %0 + -- Modified_Flags is %1 + Outputs => + (Processor_Register'Asm_output ("=g", Original_Flags), + Processor_Register'Asm_output ("=g", Modified_Flags)), + + -- tell compiler eax is destroyed + Clobber => "eax"); + + -- check if CPUID is supported + if Original_Flags(ID_Flag) /= Modified_Flags(ID_Flag) then + return True; -- ID flag was modified + else + return False; -- ID flag unchanged + end if; -- check for CPUID + + end Has_CPUID; + + ------------------------------- + -- Get CPUID support level -- + ------------------------------- + + function CPUID_Level return Natural is + + Level : Unsigned_32; + -- returned support level + + begin + + -- execute CPUID, storing the results in the Level register + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero is stored in eax + -- returning the support level in eax + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- eax is stored in Level + Outputs => Unsigned_32'Asm_output ("=a", Level), + + -- tell compiler ebx, ecx and edx registers are destroyed + Clobber => "ebx, ecx, edx"); + + -- return the support level + return Natural (Level); + + end CPUID_Level; + + -------------------------------- + -- Get CPU Vendor ID String -- + -------------------------------- + + -- The vendor ID string is returned in the ebx, ecx and edx register + -- after executing the CPUID instruction with eax set to zero. + -- In case of a true Intel processor the string returned is + -- "GenuineIntel" + + function Vendor_ID return String is + + Ebx, Ecx, Edx : Unsigned_Register; + -- registers containing the vendor ID string + + Vendor_ID : String (1 .. 12); + -- the vendor ID string + + begin + + -- execute CPUID, storing the results in the processor registers + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero stored in eax + -- vendor ID string returned in ebx, ecx and edx + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- ebx is stored in Ebx + -- ecx is stored in Ecx + -- edx is stored in Edx + Outputs => (Unsigned_Register'Asm_output ("=b", Ebx), + Unsigned_Register'Asm_output ("=c", Ecx), + Unsigned_Register'Asm_output ("=d", Edx))); + + -- now build the vendor ID string + Vendor_ID( 1) := Character'Val (Ebx.L1); + Vendor_ID( 2) := Character'Val (Ebx.H1); + Vendor_ID( 3) := Character'Val (Ebx.L2); + Vendor_ID( 4) := Character'Val (Ebx.H2); + Vendor_ID( 5) := Character'Val (Edx.L1); + Vendor_ID( 6) := Character'Val (Edx.H1); + Vendor_ID( 7) := Character'Val (Edx.L2); + Vendor_ID( 8) := Character'Val (Edx.H2); + Vendor_ID( 9) := Character'Val (Ecx.L1); + Vendor_ID(10) := Character'Val (Ecx.H1); + Vendor_ID(11) := Character'Val (Ecx.L2); + Vendor_ID(12) := Character'Val (Ecx.H2); + + -- return string + return Vendor_ID; + + end Vendor_ID; + + ------------------------------- + -- Get processor signature -- + ------------------------------- + + function Signature return Processor_Signature is + + Result : Processor_Signature; + -- processor signature returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one is stored in eax + -- processor signature returned in eax + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- eax is stored in Result + Outputs => Processor_Signature'Asm_output ("=a", Result), + + -- tell compiler that ebx, ecx and edx are also destroyed + Clobber => "ebx, ecx, edx"); + + -- return processor signature + return Result; + + end Signature; + + ------------------------------ + -- Get processor features -- + ------------------------------ + + function Features return Processor_Features is + + Result : Processor_Features; + -- processor features returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one stored in eax + -- processor features returned in edx + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- edx is stored in Result + Outputs => Processor_Features'Asm_output ("=d", Result), + + -- tell compiler that ebx and ecx are also destroyed + Clobber => "ebx, ecx"); + + -- return processor signature + return Result; + + end Features; + + end Intel_CPU; + +  + File: gnat_ug_unx.info, Node: Performance Considerations, Next: GNU Free Documentation License, Prev: Inline Assembler, Up: Top + + Performance Considerations + ************************** + + The GNAT system provides a number of options that allow a trade-off + between + + * performance of the generated code + + * speed of compilation + + * minimization of dependences and recompilation + + * the degree of run-time checking. + + The defaults (if no options are selected) aim at improving the speed of + compilation and minimizing dependences, at the expense of performance + of the generated code: + + * no optimization + + * no inlining of subprogram calls + + * all run-time checks enabled except overflow and elaboration checks + + These options are suitable for most program development purposes. This + chapter describes how you can modify these choices, and also provides + some guidelines on debugging optimized code. + + * Menu: + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + +  + File: gnat_ug_unx.info, Node: Controlling Run-Time Checks, Next: Optimization Levels, Up: Performance Considerations + + Controlling Run-Time Checks + =========================== + + By default, GNAT generates all run-time checks, except arithmetic + overflow checking for integer operations and checks for access before + elaboration on subprogram calls. The latter are not required in default + mode, because all necessary checking is done at compile time. Two gnat + switches, `-gnatp' and `-gnato' allow this default to be modified. + *Note Run-Time Checks::. + + Our experience is that the default is suitable for most development + purposes. + + We treat integer overflow specially because these are quite + expensive and in our experience are not as important as other run-time + checks in the development process. Note that division by zero is not + considered an overflow check, and divide by zero checks are generated + where required by default. + + Elaboration checks are off by default, and also not needed by + default, since GNAT uses a static elaboration analysis approach that + avoids the need for run-time checking. This manual contains a full + chapter discussing the issue of elaboration checks, and if the default + is not satisfactory for your use, you should read this chapter. + + For validity checks, the minimal checks required by the Ada Reference + Manual (for case statements and assignments to array elements) are on + by default. These can be suppressed by use of the `-gnatVn' switch. + Note that in Ada 83, there were no validity checks, so if the Ada 83 + mode is acceptable (or when comparing GNAT performance with an Ada 83 + compiler), it may be reasonable to routinely use `-gnatVn'. Validity + checks are also suppressed entirely if `-gnatp' is used. + + Note that the setting of the switches controls the default setting of + the checks. They may be modified using either `pragma Suppress' (to + remove checks) or `pragma Unsuppress' (to add back suppressed checks) + in the program source. + +  + File: gnat_ug_unx.info, Node: Optimization Levels, Next: Debugging Optimized Code, Prev: Controlling Run-Time Checks, Up: Performance Considerations + + Optimization Levels + =================== + + The default is optimization off. This results in the fastest compile + times, but GNAT makes absolutely no attempt to optimize, and the + generated programs are considerably larger and slower than when + optimization is enabled. You can use the `-ON' switch, where N is an + integer from 0 to 3, on the `gcc' command line to control the + optimization level: + + `-O0' + no optimization (the default) + + `-O1' + medium level optimization + + `-O2' + full optimization + + `-O3' + full optimization, and also attempt automatic inlining of small + subprograms within a unit (*note Inlining of Subprograms::). + + Higher optimization levels perform more global transformations on the + program and apply more expensive analysis algorithms in order to + generate faster and more compact code. The price in compilation time, + and the resulting improvement in execution time, both depend on the + particular application and the hardware environment. You should + experiment to find the best level for your application. + + Note: Unlike some other compilation systems, `gcc' has been tested + extensively at all optimization levels. There are some bugs which + appear only with optimization turned on, but there have also been bugs + which show up only in _unoptimized_ code. Selecting a lower level of + optimization does not improve the reliability of the code generator, + which in practice is highly reliable at all optimization levels. + + Note regarding the use of `-O3': The use of this optimization level + is generally discouraged with GNAT, since it often results in larger + executables which run more slowly. See further discussion of this point + in *note Inlining of Subprograms::. + +  + File: gnat_ug_unx.info, Node: Debugging Optimized Code, Next: Inlining of Subprograms, Prev: Optimization Levels, Up: Performance Considerations + + Debugging Optimized Code + ======================== + + Since the compiler generates debugging tables for a compilation unit + before it performs optimizations, the optimizing transformations may + invalidate some of the debugging data. You therefore need to + anticipate certain anomalous situations that may arise while debugging + optimized code. This section describes the most common cases. + + 1. The "hopping Program Counter": Repeated 'step' or 'next' commands + show the PC bouncing back and forth in the code. This may result + from any of the following optimizations: + + * Common subexpression elimination: using a single instance of + code for a quantity that the source computes several times. + As a result you may not be able to stop on what looks like a + statement. + + * Invariant code motion: moving an expression that does not + change within a loop, to the beginning of the loop. + + * Instruction scheduling: moving instructions so as to overlap + loads and stores (typically) with other code, or in general + to move computations of values closer to their uses. Often + this causes you to pass an assignment statement without the + assignment happening and then later bounce back to the + statement when the value is actually needed. Placing a + breakpoint on a line of code and then stepping over it may, + therefore, not always cause all the expected side-effects. + + 2. The "big leap": More commonly known as cross-jumping, in which two + identical pieces of code are merged and the program counter + suddenly jumps to a statement that is not supposed to be executed, + simply because it (and the code following) translates to the same + thing as the code that _was_ supposed to be executed. This effect + is typically seen in sequences that end in a jump, such as a + `goto', a `return', or a `break' in a C `switch' statement. + + 3. The "roving variable": The symptom is an unexpected value in a + variable. There are various reasons for this effect: + + * In a subprogram prologue, a parameter may not yet have been + moved to its "home". + + * A variable may be dead, and its register re-used. This is + probably the most common cause. + + * As mentioned above, the assignment of a value to a variable + may have been moved. + + * A variable may be eliminated entirely by value propagation or + other means. In this case, GCC may incorrectly generate + debugging information for the variable + + In general, when an unexpected value appears for a local variable + or parameter you should first ascertain if that value was actually + computed by your program, as opposed to being incorrectly reported + by the debugger. Record fields or array elements in an object + designated by an access value are generally less of a problem, + once you have ascertained that the access value is sensible. + Typically, this means checking variables in the preceding code and + in the calling subprogram to verify that the value observed is + explainable from other values (one must apply the procedure + recursively to those other values); or re-running the code and + stopping a little earlier (perhaps before the call) and stepping + to better see how the variable obtained the value in question; or + continuing to step _from_ the point of the strange value to see if + code motion had simply moved the variable's assignments later. + +  + File: gnat_ug_unx.info, Node: Inlining of Subprograms, Prev: Debugging Optimized Code, Up: Performance Considerations + + Inlining of Subprograms + ======================= + + A call to a subprogram in the current unit is inlined if all the + following conditions are met: + + * The optimization level is at least `-O1'. + + * The called subprogram is suitable for inlining: It must be small + enough and not contain nested subprograms or anything else that + `gcc' cannot support in inlined subprograms. + + * The call occurs after the definition of the body of the subprogram. + + * Either `pragma Inline' applies to the subprogram or it is small + and automatic inlining (optimization level `-O3') is specified. + + Calls to subprograms in `with''ed units are normally not inlined. To + achieve this level of inlining, the following conditions must all be + true: + + * The optimization level is at least `-O1'. + + * The called subprogram is suitable for inlining: It must be small + enough and not contain nested subprograms or anything else `gcc' + cannot support in inlined subprograms. + + * The call appears in a body (not in a package spec). + + * There is a `pragma Inline' for the subprogram. + + * The `-gnatn' switch is used in the `gcc' command line + + Note that specifying the `-gnatn' switch causes additional + compilation dependencies. Consider the following: + + package R is + procedure Q; + pragma Inline (Q); + end R; + package body R is + ... + end R; + + with R; + procedure Main is + begin + ... + R.Q; + end Main; + + With the default behavior (no `-gnatn' switch specified), the + compilation of the `Main' procedure depends only on its own source, + `main.adb', and the spec of the package in file `r.ads'. This means + that editing the body of `R' does not require recompiling `Main'. + + On the other hand, the call `R.Q' is not inlined under these + circumstances. If the `-gnatn' switch is present when `Main' is + compiled, the call will be inlined if the body of `Q' is small enough, + but now `Main' depends on the body of `R' in `r.adb' as well as on the + spec. This means that if this body is edited, the main program must be + recompiled. Note that this extra dependency occurs whether or not the + call is in fact inlined by `gcc'. + + The use of front end inlining with `-gnatN' generates similar + additional dependencies. + + Note: The `-fno-inline' switch can be used to prevent all inlining. + This switch overrides all other conditions and ensures that no inlining + occurs. The extra dependences resulting from `-gnatn' will still be + active, even if this switch is used to suppress the resulting inlining + actions. + + Note regarding the use of `-O3': There is no difference in inlining + behavior between `-O2' and `-O3' for subprograms with an explicit + pragma `Inline' assuming the use of `-gnatn' or `-gnatN' (the switches + that activate inlining). If you have used pragma `Inline' in + appropriate cases, then it is usually much better to use `-O2' and + `-gnatn' and avoid the use of `-O3' which in this case only has the + effect of inlining subprograms you did not think should be inlined. We + often find that the use of `-O3' slows down code by performing + excessive inlining, leading to increased instruction cache pressure + from the increased code size. So the bottom line here is that you + should not automatically assume that `-O3' is better than `-O2', and + indeed you should use `-O3' only if tests show that it actually + improves performance. + +  + File: gnat_ug_unx.info, Node: GNU Free Documentation License, Next: Index, Prev: Performance Considerations, Up: Top + + GNU Free Documentation License + ****************************** + + Version 1.2, November 2002 + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. + We recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it + can be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You + accept the license if you copy, modify or distribute the work in a + way requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in + the notice that says that the Document is released under this + License. If a section does not fit the above definition of + Secondary then it is not allowed to be designated as Invariant. + The Document may contain zero Invariant Sections. If the Document + does not identify any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images + composed of pixels) generic paint programs or (for drawings) some + widely available drawing editor, and that is suitable for input to + text formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in an + otherwise Transparent file format whose markup, or absence of + markup, has been arranged to thwart or discourage subsequent + modification by readers is not Transparent. An image format is + not Transparent if used for any substantial amount of text. A + copy that is not "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and + standard-conforming simple HTML, PostScript or PDF designed for + human modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats that + can be read and edited only by proprietary word processors, SGML or + XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML, PostScript or PDF + produced by some word processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow + the conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the + title equally prominent and visible. You may add other material + on the covers in addition. Copying with changes limited to the + covers, as long as they preserve the title of the Document and + satisfy these conditions, can be treated as verbatim copying in + other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a computer-network location from + which the general network-using public has access to download + using public-standard network protocols a complete Transparent + copy of the Document, free of added material. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of + copies, to give them a chance to provide you with an updated + version of the Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with + the Modified Version filling the role of the Document, thus + licensing distribution and modification of the Modified Version to + whoever possesses a copy of it. In addition, you must do these + things in the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of + previous versions (which should, if there were any, be listed + in the History section of the Document). You may use the + same title as a previous version if the original publisher of + that version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on + the Title Page. If there is no section Entitled "History" in + the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, + then add an item describing the Modified Version as stated in + the previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in + the "History" section. You may omit a network location for a + work that was published at least four years before the + Document itself, or if the original publisher of the version + it refers to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the + section all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section + titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end + of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the + documents in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow + this License in all other respects regarding verbatim copying of + that document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warrany Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided for under this License. Any other + attempt to copy, modify, sublicense or distribute the Document is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + `http://www.gnu.org/copyleft/'. + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If + the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. + + ADDENDUM: How to use this License for your documents + ==================================================== + + To use this License in a document you have written, include a copy of + the License in the document and put the following copyright and license + notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover + Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other + combination of the three, merge those two alternatives to suit the + situation. + + If your document contains nontrivial examples of program code, we + recommend releasing these examples in parallel under your choice of + free software license, such as the GNU General Public License, to + permit their use in free software. + +  + File: gnat_ug_unx.info, Node: Index, Prev: GNU Free Documentation License, Up: Top + + Index + ***** + + * Menu: + + * --GCC= (gnatchop): Switches for gnatchop. + * --GCC=compiler_name (gnatlink): Switches for gnatlink. + * --GCC=compiler_name (gnatmake): Switches for gnatmake. + * --GNATBIND=binder_name (gnatmake): Switches for gnatmake. + * --GNATLINK=linker_name (gnatmake): Switches for gnatmake. + * --LINK= (gnatlink): Switches for gnatlink. + * --RTS (gcc): Switches for gcc. + * --RTS (gnatbind): Summary of Binder Switches. + * --RTS (gnatfind): gnatfind Switches. + * --RTS (gnatls): Switches for gnatls. + * --RTS (gnatmake): Switches for gnatmake. + * --RTS (gnatxref): gnatxref Switches. + * -83 (gnathtml): Converting Ada Files to html with gnathtml. + * -A (gnatbind): Output Control. + * -A (gnatlink): Switches for gnatlink. + * -a (gnatls): Switches for gnatls. + * -A (gnatmake): Switches for gnatmake. + * -a (gnatmake): Switches for gnatmake. + * -aI (gnatmake): Switches for gnatmake. + * -aL (gnatmake): Switches for gnatmake. + * -aO (gnatmake): Switches for gnatmake. + * -B (gcc): Switches for gcc. + * -b (gcc): Switches for gcc. + * -b (gnatbind): Binder Error Message Control. + * -B (gnatlink): Switches for gnatlink. + * -b (gnatlink): Switches for gnatlink. + * -b (gnatmake): Switches for gnatmake. + * -bargs (gnatmake): Mode Switches for gnatmake. + * -c (gcc): Switches for gcc. + * -C (gnatbind): Output Control. + * -c (gnatbind): Output Control. + * -c (gnatchop): Switches for gnatchop. + * -C (gnatlink): Switches for gnatlink. + * -C (gnatmake): Switches for gnatmake. + * -c (gnatmake): Switches for gnatmake. + * -c (gnatname): Switches for gnatname. + * -cargs (gnatmake): Mode Switches for gnatmake. + * -d (gnathtml): Converting Ada Files to html with gnathtml. + * -d (gnatls): Switches for gnatls. + * -D (gnatname): Switches for gnatname. + * -d (gnatname): Switches for gnatname. + * -e (gnatbind): Output Control. + * -f (gnathtml): Converting Ada Files to html with gnathtml. + * -f (gnatlink): Switches for gnatlink. + * -f (gnatmake): Switches for gnatmake. + * -fno-inline (gcc): Inlining of Subprograms. + * -fstack-check: Stack Overflow Checking. + * -g (gcc): Switches for gcc. + * -g (gnatlink): Switches for gnatlink. + * -gnat83 (gcc): Compiling Ada 83 Programs. + * -gnata (gcc): Debugging and Assertion Control. + * -gnatb (gcc): Output and Error Message Control. + * -gnatc (gcc): Using gcc for Semantic Checking. + * -gnatD (gcc): Debugging Control. + * -gnatdc switch: GNAT Abnormal Termination or Failure to Terminate. + * -gnatE (gcc) <1>: Debugging Control. + * -gnatE (gcc): Run-Time Checks. + * -gnatem (gcc): Units to Sources Mapping Files. + * -gnatf (gcc): Output and Error Message Control. + * -gnatG (gcc): Debugging Control. + * -gnati (gcc): Character Set Control. + * -gnatk (gcc): File Naming Control. + * -gnatl (gcc): Output and Error Message Control. + * -gnatm (gcc): Output and Error Message Control. + * -gnatn (gcc): Inlining of Subprograms. + * -gnatN (gcc): Subprogram Inlining Control. + * -gnatn (gcc): Subprogram Inlining Control. + * -gnatN switch: Source Dependencies. + * -gnatn switch: Source Dependencies. + * -gnato (gcc) <1>: Controlling Run-Time Checks. + * -gnato (gcc): Run-Time Checks. + * -gnatp (gcc) <1>: Controlling Run-Time Checks. + * -gnatp (gcc): Run-Time Checks. + * -gnatq (gcc): Output and Error Message Control. + * -gnatR (gcc): Debugging Control. + * -gnats (gcc): Using gcc for Syntax Checking. + * -gnatt (gcc): Auxiliary Output Control. + * -gnatT (gcc): Run-Time Control. + * -gnatu (gcc): Auxiliary Output Control. + * -gnatU (gcc): Output and Error Message Control. + * -gnatv (gcc): Output and Error Message Control. + * -gnatW (gcc): Character Set Control. + * -gnatwA (gcc): Output and Error Message Control. + * -gnatwa (gcc): Output and Error Message Control. + * -gnatwB (gcc): Output and Error Message Control. + * -gnatwb (gcc): Output and Error Message Control. + * -gnatwC (gcc): Output and Error Message Control. + * -gnatwc (gcc): Output and Error Message Control. + * -gnatwD (gcc): Output and Error Message Control. + * -gnatwd (gcc): Output and Error Message Control. + * -gnatwe (gcc): Output and Error Message Control. + * -gnatwF (gcc): Output and Error Message Control. + * -gnatwf (gcc): Output and Error Message Control. + * -gnatwH (gcc): Output and Error Message Control. + * -gnatwh (gcc): Output and Error Message Control. + * -gnatwI (gcc): Output and Error Message Control. + * -gnatwi (gcc): Output and Error Message Control. + * -gnatwL (gcc): Output and Error Message Control. + * -gnatwl (gcc): Output and Error Message Control. + * -gnatwO (gcc): Output and Error Message Control. + * -gnatwo (gcc): Output and Error Message Control. + * -gnatwP (gcc): Output and Error Message Control. + * -gnatwp (gcc): Output and Error Message Control. + * -gnatwR (gcc): Output and Error Message Control. + * -gnatwr (gcc): Output and Error Message Control. + * -gnatws (gcc): Output and Error Message Control. + * -gnatwU (gcc): Output and Error Message Control. + * -gnatwu (gcc): Output and Error Message Control. + * -gnatx (gcc): Debugging Control. + * -h (gnatbind) <1>: Output Control. + * -h (gnatbind): Elaboration Control. + * -h (gnatls): Switches for gnatls. + * -h (gnatname): Switches for gnatname. + * -I (gcc): Switches for gcc. + * -I (gnathtml): Converting Ada Files to html with gnathtml. + * -I (gnatmake): Switches for gnatmake. + * -i (gnatmake): Switches for gnatmake. + * -i (gnatmem): Switches for gnatmem. + * -I- (gcc): Switches for gcc. + * -I- (gnatmake): Switches for gnatmake. + * -j (gnatmake): Switches for gnatmake. + * -K (gnatbind): Output Control. + * -k (gnatchop): Switches for gnatchop. + * -k (gnatmake): Switches for gnatmake. + * -l (gnatbind): Output Control. + * -l (gnathtml): Converting Ada Files to html with gnathtml. + * -L (gnatmake): Switches for gnatmake. + * -l (gnatmake): Switches for gnatmake. + * -largs (gnatmake): Mode Switches for gnatmake. + * -M (gnatbind): Binder Error Message Control. + * -m (gnatbind): Binder Error Message Control. + * -M (gnatmake): Switches for gnatmake. + * -m (gnatmake): Switches for gnatmake. + * -n (gnatbind): Binding with Non-Ada Main Programs. + * -n (gnatlink): Switches for gnatlink. + * -n (gnatmake): Switches for gnatmake. + * -nostdinc (gnatmake): Switches for gnatmake. + * -nostdlib (gnatmake): Switches for gnatmake. + * -O (gcc) <1>: Optimization Levels. + * -O (gcc): Switches for gcc. + * -o (gcc): Switches for gcc. + * -o (gnatbind): Output Control. + * -O (gnatbind): Output Control. + * -o (gnathtml): Converting Ada Files to html with gnathtml. + * -o (gnatlink): Switches for gnatlink. + * -o (gnatls): Switches for gnatls. + * -o (gnatmake): Switches for gnatmake. + * -o (gnatmem): Switches for gnatmem. + * -p (gnatchop): Switches for gnatchop. + * -p (gnathtml): Converting Ada Files to html with gnathtml. + * -P (gnatname): Switches for gnatname. + * -pass-exit-codes (gcc): Auxiliary Output Control. + * -q (gnatchop): Switches for gnatchop. + * -q (gnatmake): Switches for gnatmake. + * -q (gnatmem): Switches for gnatmem. + * -r (gnatbind): Output Control. + * -r (gnatchop): Switches for gnatchop. + * -S (gcc): Switches for gcc. + * -s (gnatbind): Consistency-Checking Modes. + * -s (gnatls): Switches for gnatls. + * -s (gnatmake): Switches for gnatmake. + * -sc (gnathtml): Converting Ada Files to html with gnathtml. + * -t (gnatbind): Binder Error Message Control. + * -t (gnathtml): Converting Ada Files to html with gnathtml. + * -u (gnatls): Switches for gnatls. + * -u (gnatmake): Switches for gnatmake. + * -V (gcc): Switches for gcc. + * -v (gcc): Switches for gcc. + * -v (gnatbind): Binder Error Message Control. + * -v (gnatchop): Switches for gnatchop. + * -v (gnatlink): Switches for gnatlink. + * -v (gnatmake): Switches for gnatmake. + * -v (gnatname): Switches for gnatname. + * -v -v (gnatlink): Switches for gnatlink. + * -w: Output and Error Message Control. + * -w (gnatchop): Switches for gnatchop. + * -we (gnatbind): Binder Error Message Control. + * -ws (gnatbind): Binder Error Message Control. + * -x (gnatbind): Consistency-Checking Modes. + * -z (gnatbind): Binding Programs with No Main Subprogram. + * -z (gnatmake): Switches for gnatmake. + * __gnat_finalize: Running gnatbind. + * __gnat_initialize: Running gnatbind. + * __gnat_set_globals: Running gnatbind. + * _main: The External Symbol Naming Scheme of GNAT. + * Access before elaboration: Run-Time Checks. + * Access-to-subprogram: Elaboration for Access-to-Subprogram Values. + * ACVC, Ada 83 tests: Compiling Ada 83 Programs. + * Ada <1>: Naming Conventions for GNAT Source Files. + * Ada: Search Paths for gnatbind. + * Ada 83 compatibility: Compiling Ada 83 Programs. + * Ada 95 Language Reference Manual: What You Should Know before Reading This Guide. + * Ada expressions: Using Ada Expressions. + * Ada Library Information files: The Ada Library Information Files. + * Ada.Characters.Latin_1: Latin-1. + * ADA_INCLUDE_PATH: Search Paths and the Run-Time Library (RTL). + * ADA_OBJECTS_PATH: Search Paths for gnatbind. + * adafinal <1>: Binding with Non-Ada Main Programs. + * adafinal: Running gnatbind. + * adainit <1>: Binding with Non-Ada Main Programs. + * adainit: Running gnatbind. + * Address Clauses, warnings: Output and Error Message Control. + * ali files: The Ada Library Information Files. + * Annex A: Naming Conventions for GNAT Source Files. + * Annex B: Naming Conventions for GNAT Source Files. + * Arbitrary File Naming Conventions: Handling Arbitrary File Naming Conventions Using gnatname. + * Asm: Calling Conventions. + * Assert: Debugging and Assertion Control. + * Assertions: Debugging and Assertion Control. + * Biased rounding: Output and Error Message Control. + * Binder consistency checks: Binder Error Message Control. + * Binder output file: Interfacing to C. + * Binder, multiple input files: Binding with Non-Ada Main Programs. + * Breakpoints and tasks: Ada Tasks. + * C: Calling Conventions. + * C++: Calling Conventions. + * Calling Conventions: Calling Conventions. + * Check, elaboration: Run-Time Checks. + * Check, overflow: Run-Time Checks. + * Check_CPU procedure: Check_CPU Procedure. + * Checks, access before elaboration: Run-Time Checks. + * Checks, division by zero: Run-Time Checks. + * Checks, elaboration: Checking the Elaboration Order in Ada 95. + * Checks, overflow: Controlling Run-Time Checks. + * Checks, suppressing: Run-Time Checks. + * COBOL: Calling Conventions. + * code page 437: Other 8-Bit Codes. + * code page 850: Other 8-Bit Codes. + * Combining GNAT switches: Switches for gcc. + * Command line length: Switches for gnatlink. + * Compilation model: The GNAT Compilation Model. + * Conditionals, constant: Output and Error Message Control. + * Configuration pragmas: Configuration Pragmas. + * Consistency checks, in binder: Binder Error Message Control. + * Convention Ada: Calling Conventions. + * Convention Asm: Calling Conventions. + * Convention Assembler: Calling Conventions. + * Convention C: Calling Conventions. + * Convention C++: Calling Conventions. + * Convention COBOL: Calling Conventions. + * Convention Default: Calling Conventions. + * Convention DLL: Calling Conventions. + * Convention External: Calling Conventions. + * Convention Fortran: Calling Conventions. + * Convention Stdcall: Calling Conventions. + * Convention Stubbed: Calling Conventions. + * Convention Win32: Calling Conventions. + * Conventions: Conventions. + * CR: Source Representation. + * Cyrillic: Other 8-Bit Codes. + * Debug: Debugging and Assertion Control. + * Debug Pool: Finding Memory Problems with GNAT Debug Pool. + * Debugger: Running and Debugging Ada Programs. + * Debugging: Running and Debugging Ada Programs. + * Debugging Generic Units: Debugging Generic Units. + * Debugging information, including: Switches for gnatlink. + * Debugging options: Debugging Control. + * Default: Calling Conventions. + * Dependencies, producing list: Switches for gnatmake. + * Dependency rules: The GNAT Make Program gnatmake. + * Dereferencing, implicit: Output and Error Message Control. + * Division by zero: Run-Time Checks. + * DLL: Calling Conventions. + * Elaborate: Controlling the Elaboration Order in Ada 95. + * Elaborate_All: Controlling the Elaboration Order in Ada 95. + * Elaborate_Body: Controlling the Elaboration Order in Ada 95. + * Elaboration checks <1>: Checking the Elaboration Order in Ada 95. + * Elaboration checks: Run-Time Checks. + * Elaboration control <1>: Summary of Procedures for Elaboration Control. + * Elaboration control: Elaboration Order Handling in GNAT. + * Elaboration of library tasks: Elaboration Issues for Library Tasks. + * Elaboration order control: Comparison between GNAT and C/C++ Compilation Models. + * Elaboration, warnings: Output and Error Message Control. + * Eliminate: Eliminate Pragma. + * End of source file: Source Representation. + * Error messages, suppressing: Output and Error Message Control. + * EUC Coding: Wide Character Encodings. + * Exceptions: Ada Exceptions. + * Export: The External Symbol Naming Scheme of GNAT. + * External: Calling Conventions. + * FDL, GNU Free Documentation License: GNU Free Documentation License. + * FF: Source Representation. + * File names <1>: Alternative File Naming Schemes. + * File names: Using Other File Names. + * File naming schemes, alternative: Alternative File Naming Schemes. + * Foreign Languages: Calling Conventions. + * Formals, unreferenced: Output and Error Message Control. + * Fortran: Calling Conventions. + * gdb: Running and Debugging Ada Programs. + * Generic formal parameters: Compiling Ada 83 Programs. + * Generics <1>: Debugging Generic Units. + * Generics: Generating Object Files. + * Glide: Introduction to Glide and GVD. + * GMEM (gnatmem): Running gnatmem (GMEM Mode). + * GNAT <1>: Naming Conventions for GNAT Source Files. + * GNAT: Search Paths for gnatbind. + * GNAT Abnormal Termination or Failure to Terminate: GNAT Abnormal Termination or Failure to Terminate. + * GNAT compilation model: The GNAT Compilation Model. + * GNAT library: Comparison between GNAT and Conventional Ada Library Models. + * gnat.adc <1>: The Configuration Pragmas Files. + * gnat.adc: Using Other File Names. + * gnat1: Compiling Programs. + * gnat_argc: Command-Line Access. + * gnat_argv: Command-Line Access. + * GNAT_STACK_LIMIT: Stack Overflow Checking. + * gnatbind: Binding Using gnatbind. + * gnatchop: Renaming Files Using gnatchop. + * gnatelim: Reducing the Size of Ada Executables with gnatelim. + * gnatfind: The Cross-Referencing Tools gnatxref and gnatfind. + * gnatkr: File Name Krunching Using gnatkr. + * gnatlink: Linking Using gnatlink. + * gnatls: The GNAT Library Browser gnatls. + * gnatmake: The GNAT Make Program gnatmake. + * gnatmem: Finding Memory Problems with gnatmem. + * gnatprep: Preprocessing Using gnatprep. + * gnatstub: Creating Sample Bodies Using gnatstub. + * gnatxref: The Cross-Referencing Tools gnatxref and gnatfind. + * GNU make: Using gnatmake in a Makefile. + * GVD: Introduction to Glide and GVD. + * Hiding of Declarations: Output and Error Message Control. + * HT: Source Representation. + * Implicit dereferencing: Output and Error Message Control. + * Inline <1>: Inlining of Subprograms. + * Inline: Source Dependencies. + * Inlining: Comparison between GNAT and Conventional Ada Library Models. + * Inlining, warnings: Output and Error Message Control. + * Intel_CPU package body: Intel_CPU Package Body. + * Intel_CPU package specification: Intel_CPU Package Specification. + * Interfaces <1>: Naming Conventions for GNAT Source Files. + * Interfaces: Search Paths for gnatbind. + * Interfacing to Ada: Calling Conventions. + * Interfacing to Assembly: Calling Conventions. + * Interfacing to C: Calling Conventions. + * Interfacing to C++: Calling Conventions. + * Interfacing to COBOL: Calling Conventions. + * Interfacing to Fortran: Calling Conventions. + * Internal trees, writing to file: Auxiliary Output Control. + * Latin-1 <1>: Latin-1. + * Latin-1: Source Representation. + * Latin-2: Other 8-Bit Codes. + * Latin-3: Other 8-Bit Codes. + * Latin-4: Other 8-Bit Codes. + * Latin-5: Other 8-Bit Codes. + * LF: Source Representation. + * Library browser: The GNAT Library Browser gnatls. + * Library tasks, elaboration issues: Elaboration Issues for Library Tasks. + * Library, building, installing: GNAT and Libraries. + * Linker libraries: Switches for gnatmake. + * Machine_Overflows: Run-Time Checks. + * Main Program: Running gnatbind. + * make: Using the GNU make Utility. + * makefile: Using gnatmake in a Makefile. + * Mixed Language Programming: Mixed Language Programming. + * Multiple units, syntax checking: Using gcc for Syntax Checking. + * n (gnatmem): Switches for gnatmem. + * No code generated: Compiling Programs. + * No_Entry_Calls_In_Elaboration_Code: Elaboration Issues for Library Tasks. + * Object file list: Running gnatbind. + * Order of elaboration: Elaboration Order Handling in GNAT. + * Other Ada compilers: Calling Conventions. + * Overflow checks <1>: Controlling Run-Time Checks. + * Overflow checks: Run-Time Checks. + * Parallel make: Switches for gnatmake. + * Performance: Performance Considerations. + * pragma Elaborate: Controlling the Elaboration Order in Ada 95. + * pragma Elaborate_All: Controlling the Elaboration Order in Ada 95. + * pragma Elaborate_Body: Controlling the Elaboration Order in Ada 95. + * pragma Inline: Inlining of Subprograms. + * pragma Preelaborate: Controlling the Elaboration Order in Ada 95. + * pragma Pure: Controlling the Elaboration Order in Ada 95. + * pragma Suppress: Controlling Run-Time Checks. + * pragma Unsuppress: Controlling Run-Time Checks. + * Pragmas, configuration: Configuration Pragmas. + * Preelaborate: Controlling the Elaboration Order in Ada 95. + * Pure: Controlling the Elaboration Order in Ada 95. + * Recompilation, by gnatmake: Notes on the Command Line. + * Rounding, biased: Output and Error Message Control. + * RTL: Switches for gcc. + * SDP_Table_Build: Running gnatbind. + * Search paths, for gnatmake: Switches for gnatmake. + * Shift JIS Coding: Wide Character Encodings. + * Source file, end: Source Representation. + * Source files, suppressing search: Switches for gnatmake. + * Source files, use by binder: Running gnatbind. + * Source_File_Name pragma <1>: Alternative File Naming Schemes. + * Source_File_Name pragma: Using Other File Names. + * Source_Reference: Switches for gnatchop. + * Stack Overflow Checking: Stack Overflow Checking. + * stack traceback: Stack Traceback. + * stack unwinding: Stack Traceback. + * Stdcall: Calling Conventions. + * stderr: Output and Error Message Control. + * stdout: Output and Error Message Control. + * storage, pool, memory corruption: Finding Memory Problems with GNAT Debug Pool. + * Stubbed: Calling Conventions. + * Style checking: Style Checking. + * SUB: Source Representation. + * Subunits: Generating Object Files. + * Suppress <1>: Controlling Run-Time Checks. + * Suppress: Run-Time Checks. + * Suppressing checks: Run-Time Checks. + * System <1>: Naming Conventions for GNAT Source Files. + * System: Search Paths for gnatbind. + * System.IO: Search Paths and the Run-Time Library (RTL). + * Task switching: Ada Tasks. + * Tasks: Ada Tasks. + * Time Slicing: Run-Time Control. + * Time stamp checks, in binder: Binder Error Message Control. + * traceback: Stack Traceback. + * traceback, non-symbolic: Non-Symbolic Traceback. + * traceback, symbolic: Symbolic Traceback. + * Tree file: Tree Files. + * Typographical conventions: Conventions. + * Unsuppress <1>: Controlling Run-Time Checks. + * Unsuppress: Run-Time Checks. + * Upper-Half Coding: Wide Character Encodings. + * Validity Checking: Validity Checking. + * Version skew (avoided by gnatmake): Running a Simple Ada Program. + * Volatile parameter: The Volatile Parameter. + * VT: Source Representation. + * Warning messages: Output and Error Message Control. + * Warnings: Binder Error Message Control. + * Warnings, treat as error: Output and Error Message Control. + * Win32: Calling Conventions. + * Writing internal trees: Auxiliary Output Control. + * Zero Cost Exceptions: Running gnatbind. + + +  + Tag Table: + Node: Top91 + Node: About This Guide8873 + Node: What This Guide Contains9382 + Node: What You Should Know before Reading This Guide13727 + Node: Related Information14135 + Node: Conventions14858 + Node: Getting Started with GNAT15752 + Node: Running GNAT16193 + Node: Running a Simple Ada Program16795 + Node: Running a Program with Multiple Units20149 + Node: Using the gnatmake Utility22380 + Node: Introduction to Glide and GVD24780 + Node: Building a New Program with Glide25522 + Node: Simple Debugging with GVD30860 + Node: Other Glide Features33897 + Node: The GNAT Compilation Model35780 + Node: Source Representation37110 + Node: Foreign Language Representation38896 + Node: Latin-139382 + Node: Other 8-Bit Codes40248 + Node: Wide Character Encodings42341 + Node: File Naming Rules46147 + Node: Using Other File Names48436 + Node: Alternative File Naming Schemes50789 + Node: Generating Object Files56021 + Node: Source Dependencies58735 + Node: The Ada Library Information Files62258 + Node: Binding an Ada Program64391 + Node: Mixed Language Programming66239 + Node: Interfacing to C66516 + Node: Calling Conventions69022 + Node: Building Mixed Ada & C++ Programs74946 + Node: Interfacing to C++76027 + Node: Linking a Mixed C++ & Ada Program77067 + Node: A Simple Example80101 + Node: Adapting the Run Time to a New C++ Compiler83013 + Node: Comparison between GNAT and C/C++ Compilation Models84029 + Node: Comparison between GNAT and Conventional Ada Library Models85758 + Node: Compiling Using gcc88409 + Node: Compiling Programs88904 + Node: Switches for gcc91854 + Node: Output and Error Message Control101038 + Node: Debugging and Assertion Control119124 + Node: Validity Checking120454 + Node: Style Checking126601 + Node: Run-Time Checks138074 + Node: Stack Overflow Checking142058 + Node: Run-Time Control144145 + Node: Using gcc for Syntax Checking145039 + Node: Using gcc for Semantic Checking146538 + Node: Compiling Ada 83 Programs148016 + Node: Character Set Control149437 + Node: File Naming Control152364 + Node: Subprogram Inlining Control152872 + Node: Auxiliary Output Control154213 + Node: Debugging Control155644 + Node: Units to Sources Mapping Files163084 + Node: Search Paths and the Run-Time Library (RTL)164474 + Node: Order of Compilation Issues167645 + Node: Examples169346 + Node: Binding Using gnatbind169914 + Node: Running gnatbind171776 + Node: Generating the Binder Program in C202537 + Node: Consistency-Checking Modes219982 + Node: Binder Error Message Control221477 + Node: Elaboration Control223743 + Node: Output Control224968 + Node: Binding with Non-Ada Main Programs227409 + Node: Binding Programs with No Main Subprogram230549 + Node: Summary of Binder Switches231372 + Node: Command-Line Access234695 + Node: Search Paths for gnatbind235700 + Node: Examples of gnatbind Usage238266 + Node: Linking Using gnatlink240037 + Node: Running gnatlink240776 + Node: Switches for gnatlink242761 + Node: Setting Stack Size from gnatlink247034 + Node: Setting Heap Size from gnatlink247888 + Node: The GNAT Make Program gnatmake248703 + Node: Running gnatmake250154 + Node: Switches for gnatmake251813 + Node: Mode Switches for gnatmake264777 + Node: Notes on the Command Line265935 + Node: How gnatmake Works268831 + Node: Examples of gnatmake Usage271001 + Node: Renaming Files Using gnatchop272128 + Node: Handling Files with Multiple Units272717 + Node: Operating gnatchop in Compilation Mode274038 + Node: Command Line for gnatchop277361 + Node: Switches for gnatchop278826 + Node: Examples of gnatchop Usage282607 + Node: Configuration Pragmas283966 + Node: Handling of Configuration Pragmas285518 + Node: The Configuration Pragmas Files286377 + Node: Handling Arbitrary File Naming Conventions Using gnatname287740 + Node: Arbitrary File Naming Conventions288148 + Node: Running gnatname289409 + Node: Switches for gnatname290868 + Node: Examples of gnatname Usage294002 + Node: GNAT Project Manager294803 + Node: Introduction295465 + Node: Project Files296561 + Node: Examples of Project Files299764 + Node: Common Sources with Different Switches and Different Output Directories300238 + Node: Source Files303269 + Node: Specifying the Object Directory303745 + Node: Specifying the Exec Directory304677 + Node: Project File Packages305445 + Node: Specifying Switch Settings306454 + Node: Main Subprograms308422 + Node: Source File Naming Conventions309086 + Node: Source Language(s)309586 + Node: Using External Variables310027 + Node: Importing Other Projects312868 + Node: Extending a Project315976 + Node: Project File Syntax318447 + Node: Basic Syntax319809 + Node: Packages320817 + Node: Expressions321971 + Node: String Types323869 + Node: Variables325172 + Node: Attributes328200 + Node: Associative Array Attributes333633 + Node: case Constructions334478 + Node: Objects and Sources in Project Files336275 + Node: Object Directory336855 + Node: Exec Directory337846 + Node: Source Directories338675 + Node: Source File Names340042 + Node: Importing Projects342379 + Node: Project Extension345158 + Node: External References in Project Files346837 + Node: Packages in Project Files348580 + Node: Variables from Imported Projects350976 + Node: Naming Schemes352648 + Node: Library Projects356621 + Node: Switches Related to Project Files359515 + Node: Tools Supporting Project Files361219 + Node: gnatmake and Project Files361551 + Node: Switches and Project Files362004 + Node: Project Files and Main Subprograms367748 + Node: The GNAT Driver and Project Files369673 + Node: Glide and Project Files373341 + Node: An Extended Example373980 + Node: Project File Complete Syntax376975 + Node: Elaboration Order Handling in GNAT379767 + Node: Elaboration Code in Ada 95380787 + Node: Checking the Elaboration Order in Ada 95385433 + Node: Controlling the Elaboration Order in Ada 95389434 + Node: Controlling Elaboration in GNAT - Internal Calls397751 + Node: Controlling Elaboration in GNAT - External Calls403458 + Node: Default Behavior in GNAT - Ensuring Safety407192 + Node: Elaboration Issues for Library Tasks411275 + Node: Mixing Elaboration Models424480 + Node: What to Do If the Default Elaboration Behavior Fails426981 + Node: Elaboration for Access-to-Subprogram Values437296 + Node: Summary of Procedures for Elaboration Control439103 + Node: Other Elaboration Order Considerations440266 + Node: The Cross-Referencing Tools gnatxref and gnatfind445495 + Node: gnatxref Switches447159 + Node: gnatfind Switches450598 + Node: Project Files for gnatxref and gnatfind456194 + Node: Regular Expressions in gnatfind and gnatxref459300 + Node: Examples of gnatxref Usage462079 + Node: Examples of gnatfind Usage465878 + Node: File Name Krunching Using gnatkr468081 + Node: About gnatkr468695 + Node: Using gnatkr470017 + Node: Krunching Method470908 + Node: Examples of gnatkr Usage474145 + Node: Preprocessing Using gnatprep474635 + Node: Using gnatprep475146 + Node: Switches for gnatprep475998 + Node: Form of Definitions File478120 + Node: Form of Input Text for gnatprep478859 + Node: The GNAT Library Browser gnatls482478 + Node: Running gnatls483007 + Node: Switches for gnatls485517 + Node: Examples of gnatls Usage487412 + Node: GNAT and Libraries489601 + Node: Creating an Ada Library490129 + Node: Installing an Ada Library492969 + Node: Using an Ada Library495326 + Node: Creating an Ada Library to be Used in a Non-Ada Context496517 + Node: Rebuilding the GNAT Run-Time Library502485 + Node: Using the GNU make Utility503392 + Node: Using gnatmake in a Makefile504238 + Node: Automatically Creating a List of Directories508446 + Node: Generating the Command Line Switches511584 + Node: Overcoming Command Line Length Limits512562 + Node: Finding Memory Problems with gnatmem514867 + Node: Running gnatmem (GDB Mode)516218 + Node: Running gnatmem (GMEM Mode)518655 + Node: Switches for gnatmem519913 + Node: Examples of gnatmem Usage521021 + Node: GDB and GMEM Modes526245 + Node: Implementation Note526886 + Node: gnatmem Using GDB Mode527116 + Node: gnatmem Using GMEM Mode528529 + Node: Finding Memory Problems with GNAT Debug Pool529175 + Node: Creating Sample Bodies Using gnatstub533879 + Node: Running gnatstub534674 + Node: Switches for gnatstub535428 + Node: Reducing the Size of Ada Executables with gnatelim537560 + Node: About gnatelim538093 + Node: Eliminate Pragma539181 + Node: Tree Files540189 + Node: Preparing Tree and Bind Files for gnatelim541078 + Node: Running gnatelim543080 + Node: Correcting the List of Eliminate Pragmas545075 + Node: Making Your Executables Smaller545856 + Node: Summary of the gnatelim Usage Cycle546678 + Node: Other Utility Programs547487 + Node: Using Other Utility Programs with GNAT548015 + Node: The gnatpsta Utility Program548703 + Node: The External Symbol Naming Scheme of GNAT549997 + Node: Ada Mode for Glide551994 + Node: Converting Ada Files to html with gnathtml553945 + Node: Installing gnathtml557518 + Node: Running and Debugging Ada Programs558182 + Node: The GNAT Debugger GDB559576 + Node: Running GDB562694 + Node: Introduction to GDB Commands563710 + Node: Using Ada Expressions568575 + Node: Calling User-Defined Subprograms569769 + Node: Using the Next Command in a Function572189 + Node: Ada Exceptions573354 + Node: Ada Tasks574308 + Node: Debugging Generic Units576371 + Node: GNAT Abnormal Termination or Failure to Terminate577774 + Node: Naming Conventions for GNAT Source Files580353 + Node: Getting Internal Debugging Information582944 + Node: Stack Traceback584146 + Node: Non-Symbolic Traceback585183 + Node: Tracebacks From an Unhandled Exception585644 + Node: Tracebacks From Exception Occurrences (non-symbolic)589581 + Node: Tracebacks From Anywhere in a Program (non-symbolic)590864 + Node: Symbolic Traceback592707 + Node: Tracebacks From Exception Occurrences (symbolic)593430 + Node: Tracebacks From Anywhere in a Program (symbolic)594839 + Node: Inline Assembler596031 + Node: Basic Assembler Syntax597729 + Node: A Simple Example of Inline Assembler599506 + Node: Output Variables in Inline Assembler602673 + Node: Input Variables in Inline Assembler610053 + Node: Inlining Inline Assembler Code612561 + Node: Other Asm Functionality614495 + Node: The Clobber Parameter614930 + Node: The Volatile Parameter616929 + Node: A Complete Example618121 + Node: Check_CPU Procedure619095 + Node: Intel_CPU Package Specification634142 + Node: Intel_CPU Package Body643570 + Node: Performance Considerations652728 + Node: Controlling Run-Time Checks653762 + Node: Optimization Levels655747 + Node: Debugging Optimized Code657604 + Node: Inlining of Subprograms661337 + Node: GNU Free Documentation License664861 + Node: Index687290 +  + End Tag Table diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_ug_unx.texi gcc-3.3/gcc/ada/gnat_ug_unx.texi *** gcc-3.2.3/gcc/ada/gnat_ug_unx.texi 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_ug_unx.texi 2003-05-14 00:31:45.000000000 +0000 *************** *** 0 **** --- 1,18798 ---- + \input texinfo @c -*-texinfo-*- + @c %**start of header + + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + @c o + @c GNAT DOCUMENTATION o + @c o + @c G N A T _ U G o + @c o + @c Copyright (C) 1992-2002 Ada Core Technologies, Inc. o + @c o + @c GNAT is free software; you can redistribute it and/or modify it under o + @c terms of the GNU General Public License as published by the Free Soft- o + @c ware Foundation; either version 2, or (at your option) any later ver- o + @c sion. GNAT is distributed in the hope that it will be useful, but WITH- o + @c OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY o + @c or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License o + @c for more details. You should have received a copy of the GNU General o + @c Public License distributed with GNAT; see file COPYING. If not, write o + @c to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, o + @c MA 02111-1307, USA. o + @c o + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + @c + @c GNAT_UG Style Guide + @c + @c 1. Always put a @noindent on the line before the first paragraph + @c after any of these commands: + @c + @c @chapter + @c @section + @c @subsection + @c @subsubsection + @c @subsubsubsection + @c + @c @end smallexample + @c @end itemize + @c @end enumerate + @c + @c 2. DO NOT use @example. Use @smallexample instead. + @c + @c 3. Each @chapter, @section, @subsection, @subsubsection, etc. + @c command must be preceded by two empty lines + @c + @c 4. The @item command must be on a line of its own if it is in an + @c @itemize or @enumerate command. + @c + @c 5. When talking about ALI files use "ALI" (all uppercase), not "Ali" + @c or "ali". + @c + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + + + + @setfilename gnat_ug_unx.info + @settitle GNAT User's Guide for Unix Platforms + + + @include gcc-common.texi + + @setchapternewpage odd + @syncodeindex fn cp + @c %**end of header + + @copying + Copyright @copyright{} 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with the Invariant Sections being ``GNU Free Documentation License'', with the + Front-Cover Texts being + ``GNAT User's Guide for Unix Platforms'', + and with no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + @end copying + + @titlepage + + + + @title GNAT User's Guide + @center @titlefont{for Unix Platforms} + + + @subtitle GNAT, The GNU Ada 95 Compiler + @subtitle GNAT Version for GCC @value{version-GCC} + + @author Ada Core Technologies, Inc. + + @page + @vskip 0pt plus 1filll + + @insertcopying + + @end titlepage + + @ifnottex + @node Top, About This Guide, (dir), (dir) + @top GNAT User's Guide + + + + GNAT User's Guide for Unix Platforms + + + GNAT, The GNU Ada 95 Compiler + + GNAT Version for GCC @value{version-GCC} + + Ada Core Technologies, Inc. + + @insertcopying + + @menu + * About This Guide:: + * Getting Started with GNAT:: + * The GNAT Compilation Model:: + * Compiling Using gcc:: + * Binding Using gnatbind:: + * Linking Using gnatlink:: + * The GNAT Make Program gnatmake:: + * Renaming Files Using gnatchop:: + * Configuration Pragmas:: + * Handling Arbitrary File Naming Conventions Using gnatname:: + * GNAT Project Manager:: + * Elaboration Order Handling in GNAT:: + * The Cross-Referencing Tools gnatxref and gnatfind:: + * File Name Krunching Using gnatkr:: + * Preprocessing Using gnatprep:: + * The GNAT Library Browser gnatls:: + * GNAT and Libraries:: + * Using the GNU make Utility:: + * Finding Memory Problems with gnatmem:: + * Finding Memory Problems with GNAT Debug Pool:: + * Creating Sample Bodies Using gnatstub:: + * Reducing the Size of Ada Executables with gnatelim:: + * Other Utility Programs:: + * Running and Debugging Ada Programs:: + * Inline Assembler:: + * Performance Considerations:: + * GNU Free Documentation License:: + * Index:: + + --- The Detailed Node Listing --- + + About This Guide + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + + + Getting Started with GNAT + + * Running GNAT:: + * Running a Simple Ada Program:: + * Running a Program with Multiple Units:: + * Using the gnatmake Utility:: + + The GNAT Compilation Model + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + Foreign Language Representation + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + + Compiling Ada Programs With gcc + + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + + Switches for gcc + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + Binding Ada Programs With gnatbind + + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + + Linking Using gnatlink + + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + + The GNAT Make Program gnatmake + + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + + Renaming Files Using gnatchop + + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + + Configuration Pragmas + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + + Handling Arbitrary File Naming Conventions Using gnatname + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + + GNAT Project Manager + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + + Elaboration Order Handling in GNAT + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + The Cross-Referencing Tools gnatxref and gnatfind + + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + + File Name Krunching Using gnatkr + + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + + Preprocessing Using gnatprep + + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + + + The GNAT Library Browser gnatls + + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + + + GNAT and Libraries + + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + + Using the GNU make Utility + + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + + Finding Memory Problems with gnatmem + + * Running gnatmem (GDB Mode):: + * Running gnatmem (GMEM Mode):: + * Switches for gnatmem:: + * Examples of gnatmem Usage:: + * GDB and GMEM Modes:: + * Implementation Note:: + + + Finding Memory Problems with GNAT Debug Pool + + Creating Sample Bodies Using gnatstub + + * Running gnatstub:: + * Switches for gnatstub:: + + Reducing the Size of Ada Executables with gnatelim + + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + + Other Utility Programs + + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + + + Running and Debugging Ada Programs + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + + Inline Assembler + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + + + + Performance Considerations + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + + * Index:: + @end menu + @end ifnottex + + @node About This Guide + @unnumbered About This Guide + + @noindent + This guide describes the use of GNAT, a compiler and software development + toolset for the full Ada 95 programming language. + It describes the features of the compiler and tools, and details + how to use them to build Ada 95 applications. + + @menu + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + @end menu + + @node What This Guide Contains + @unnumberedsec What This Guide Contains + + @noindent + This guide contains the following chapters: + @itemize @bullet + @item + @ref{Getting Started with GNAT}, describes how to get started compiling + and running Ada programs with the GNAT Ada programming environment. + @item + @ref{The GNAT Compilation Model}, describes the compilation model used + by GNAT. + @item + @ref{Compiling Using gcc}, describes how to compile + Ada programs with @code{gcc}, the Ada compiler. + @item + @ref{Binding Using gnatbind}, describes how to + perform binding of Ada programs with @code{gnatbind}, the GNAT binding + utility. + @item + @ref{Linking Using gnatlink}, + describes @code{gnatlink}, a + program that provides for linking using the GNAT run-time library to + construct a program. @code{gnatlink} can also incorporate foreign language + object units into the executable. + @item + @ref{The GNAT Make Program gnatmake}, describes @code{gnatmake}, a + utility that automatically determines the set of sources + needed by an Ada compilation unit, and executes the necessary compilations + binding and link. + @item + @ref{Renaming Files Using gnatchop}, describes + @code{gnatchop}, a utility that allows you to preprocess a file that + contains Ada source code, and split it into one or more new files, one + for each compilation unit. + @item + @ref{Configuration Pragmas}, describes the configuration pragmas handled by GNAT. + @item + @ref{Handling Arbitrary File Naming Conventions Using gnatname}, shows how to override + the default GNAT file naming conventions, either for an individual unit or globally. + @item + @ref{GNAT Project Manager}, describes how to use project files to organize large projects. + @item + @ref{Elaboration Order Handling in GNAT}, describes how GNAT helps you deal with + elaboration order issues. + @item + @ref{The Cross-Referencing Tools gnatxref and gnatfind}, discusses + @code{gnatxref} and @code{gnatfind}, two tools that provide an easy + way to navigate through sources. + @item + @ref{File Name Krunching Using gnatkr}, describes the @code{gnatkr} + file name krunching utility, used to handle shortened + file names on operating systems with a limit on the length of names. + @item + @ref{Preprocessing Using gnatprep}, describes @code{gnatprep}, a + preprocessor utility that allows a single source file to be used to + generate multiple or parameterized source files, by means of macro + substitution. + @item + @ref{The GNAT Library Browser gnatls}, describes @code{gnatls}, a + utility that displays information about compiled units, including dependences + on the corresponding sources files, and consistency of compilations. + @item + @ref{GNAT and Libraries}, describes the process of creating and using + Libraries with GNAT. It also describes how to recompile the GNAT run-time + library. + + @item + @ref{Using the GNU make Utility}, describes some techniques for using + the GNAT toolset in Makefiles. + + @item + @ref{Finding Memory Problems with gnatmem}, describes @code{gnatmem}, a + utility that monitors dynamic allocation and deallocation activity in a + program, and displays information about incorrect deallocations and sources + of possible memory leaks. + @item + @ref{Finding Memory Problems with GNAT Debug Pool}, describes how to + use the GNAT-specific Debug Pool in order to detect as early as possible + the use of incorrect memory references. + + @item + @ref{Creating Sample Bodies Using gnatstub}, discusses @code{gnatstub}, + a utility that generates empty but compilable bodies for library units. + + @item + @ref{Reducing the Size of Ada Executables with gnatelim}, describes + @code{gnatelim}, a tool which detects unused subprograms and helps + the compiler to create a smaller executable for the program. + + @item + @ref{Other Utility Programs}, discusses several other GNAT utilities, + including @code{gnatpsta}. + + @item + @ref{Running and Debugging Ada Programs}, describes how to run and debug + Ada programs. + + @item + @ref{Inline Assembler}, shows how to use the inline assembly facility in an Ada program. + + + @item + @ref{Performance Considerations}, reviews the trade offs between using + defaults or options in program development. + @end itemize + + @node What You Should Know before Reading This Guide + @unnumberedsec What You Should Know before Reading This Guide + + @cindex Ada 95 Language Reference Manual + @noindent + This user's guide assumes that you are familiar with Ada 95 language, as + described in the International Standard ANSI/ISO/IEC-8652:1995, Jan + 1995. + + @node Related Information + @unnumberedsec Related Information + + @noindent + For further information about related tools, refer to the following + documents: + + @itemize @bullet + @item + @cite{GNAT Reference Manual}, which contains all reference + material for the GNAT implementation of Ada 95. + + @item + @cite{Ada 95 Language Reference Manual}, which contains all reference + material for the Ada 95 programming language. + + @item + @cite{Debugging with GDB} + contains all details on the use of the GNU source-level debugger. + + @item + @cite{GNU Emacs Manual} + contains full information on the extensible editor and programming + environment Emacs. + + @end itemize + + @node Conventions + @unnumberedsec Conventions + @cindex Conventions + @cindex Typographical conventions + + @noindent + Following are examples of the typographical and graphic conventions used + in this guide: + + @itemize @bullet + @item + @code{Functions}, @code{utility program names}, @code{standard names}, + and @code{classes}. + + @item + @samp{Option flags} + + @item + @file{File Names}, @file{button names}, and @file{field names}. + + @item + @var{Variables}. + + @item + @emph{Emphasis}. + + @item + [optional information or parameters] + + @item + Examples are described by text + @smallexample + and then shown this way. + @end smallexample + @end itemize + + @noindent + Commands that are entered by the user are preceded in this manual by the + characters @w{"@code{$ }"} (dollar sign followed by space). If your system + uses this sequence as a prompt, then the commands will appear exactly as + you see them in the manual. If your system uses some other prompt, then + the command will appear with the @code{$} replaced by whatever prompt + character you are using. + + + @node Getting Started with GNAT + @chapter Getting Started with GNAT + + @noindent + This chapter describes some simple ways of using GNAT to build + executable Ada programs. + + @menu + * Running GNAT:: + * Running a Simple Ada Program:: + + * Running a Program with Multiple Units:: + + * Using the gnatmake Utility:: + * Introduction to Glide and GVD:: + @end menu + + @node Running GNAT + @section Running GNAT + + @noindent + Three steps are needed to create an executable file from an Ada source + file: + + @enumerate + @item + The source file(s) must be compiled. + @item + The file(s) must be bound using the GNAT binder. + @item + All appropriate object files must be linked to produce an executable. + @end enumerate + + @noindent + All three steps are most commonly handled by using the @code{gnatmake} + utility program that, given the name of the main program, automatically + performs the necessary compilation, binding and linking steps. + + @node Running a Simple Ada Program + @section Running a Simple Ada Program + + @noindent + Any text editor may be used to prepare an Ada program. If @code{Glide} is + used, the optional Ada mode may be helpful in laying out the program. The + program text is a normal text file. We will suppose in our initial + example that you have used your editor to prepare the following + standard format text file: + + @smallexample + @group + @cartouche + @b{with} Ada.Text_IO; @b{use} Ada.Text_IO; + @b{procedure} Hello @b{is} + @b{begin} + Put_Line ("Hello WORLD!"); + @b{end} Hello; + @end cartouche + @end group + @end smallexample + + @noindent + This file should be named @file{hello.adb}. + With the normal default file naming conventions, GNAT requires + that each file + contain a single compilation unit whose file name is the + unit name, + with periods replaced by hyphens; the + extension is @file{ads} for a + spec and @file{adb} for a body. + You can override this default file naming convention by use of the + special pragma @code{Source_File_Name} (@pxref{Using Other File Names}). + Alternatively, if you want to rename your files according to this default + convention, which is probably more convenient if you will be using GNAT + for all your compilations, then the @code{gnatchop} utility + can be used to generate correctly-named source files + (@pxref{Renaming Files Using gnatchop}). + + You can compile the program using the following command (@code{$} is used + as the command prompt in the examples in this document): + + @smallexample + $ gcc -c hello.adb + @end smallexample + + + @noindent + @code{gcc} is the command used to run the compiler. This compiler is + capable of compiling programs in several languages, including Ada 95 and + C. It assumes that you have given it an Ada program if the file extension is + either @file{.ads} or @file{.adb}, and it will then call the GNAT compiler to compile + the specified file. + + The @option{-c} switch is required. It tells @command{gcc} to only do a + compilation. (For C programs, @command{gcc} can also do linking, but this + capability is not used directly for Ada programs, so the @option{-c} + switch must always be present.) + + This compile command generates a file + @file{hello.o}, which is the object + file corresponding to your Ada program. It also generates an "Ada Library Information" file + @file{hello.ali}, + which contains additional information used to check + that an Ada program is consistent. + To build an executable file, + use @code{gnatbind} to bind the program + and @code{gnatlink} to link it. The + argument to both @code{gnatbind} and @code{gnatlink} is the name of the + @file{ali} file, but the default extension of @file{.ali} can + be omitted. This means that in the most common case, the argument + is simply the name of the main program: + + @smallexample + $ gnatbind hello + $ gnatlink hello + @end smallexample + + + @noindent + A simpler method of carrying out these steps is to use + @command{gnatmake}, + a master program that invokes all the required + compilation, binding and linking tools in the correct order. In particular, + @command{gnatmake} automatically recompiles any sources that have been modified + since they were last compiled, or sources that depend + on such modified sources, so that "version skew" is avoided. + @cindex Version skew (avoided by @command{gnatmake}) + + @smallexample + $ gnatmake hello.adb + @end smallexample + + + @noindent + The result is an executable program called @file{hello}, which can be + run by entering: + + @c The following should be removed (BMB 2001-01-23) + @c @smallexample + @c $ ./hello + @c @end smallexample + + @smallexample + $ hello + @end smallexample + + @noindent + assuming that the current directory is on the search path for executable programs. + + @noindent + and, if all has gone well, you will see + + @smallexample + Hello WORLD! + @end smallexample + + @noindent + appear in response to this command. + + + + + @node Running a Program with Multiple Units + @section Running a Program with Multiple Units + + @noindent + Consider a slightly more complicated example that has three files: a + main program, and the spec and body of a package: + + @smallexample + @cartouche + @group + @b{package} Greetings @b{is} + @b{procedure} Hello; + @b{procedure} Goodbye; + @b{end} Greetings; + + @b{with} Ada.Text_IO; @b{use} Ada.Text_IO; + @b{package} @b{body} Greetings @b{is} + @b{procedure} Hello @b{is} + @b{begin} + Put_Line ("Hello WORLD!"); + @b{end} Hello; + + @b{procedure} Goodbye @b{is} + @b{begin} + Put_Line ("Goodbye WORLD!"); + @b{end} Goodbye; + @b{end} Greetings; + @end group + + @group + @b{with} Greetings; + @b{procedure} Gmain @b{is} + @b{begin} + Greetings.Hello; + Greetings.Goodbye; + @b{end} Gmain; + @end group + @end cartouche + @end smallexample + + @noindent + Following the one-unit-per-file rule, place this program in the + following three separate files: + + @table @file + @item greetings.ads + spec of package @code{Greetings} + + @item greetings.adb + body of package @code{Greetings} + + @item gmain.adb + body of main program + @end table + + @noindent + To build an executable version of + this program, we could use four separate steps to compile, bind, and link + the program, as follows: + + @smallexample + $ gcc -c gmain.adb + $ gcc -c greetings.adb + $ gnatbind gmain + $ gnatlink gmain + @end smallexample + + + @noindent + Note that there is no required order of compilation when using GNAT. + In particular it is perfectly fine to compile the main program first. + Also, it is not necessary to compile package specs in the case where + there is an accompanying body; you only need to compile the body. If you want + to submit these files to the compiler for semantic checking and not code generation, + then use the + @option{-gnatc} switch: + + @smallexample + $ gcc -c greetings.ads -gnatc + @end smallexample + + + @noindent + Although the compilation can be done in separate steps as in the + above example, in practice it is almost always more convenient + to use the @code{gnatmake} tool. All you need to know in this case + is the name of the main program's source file. The effect of the above four + commands can be achieved with a single one: + + @smallexample + $ gnatmake gmain.adb + @end smallexample + + + @noindent + In the next section we discuss the advantages of using @code{gnatmake} in + more detail. + + @node Using the gnatmake Utility + @section Using the @command{gnatmake} Utility + + @noindent + If you work on a program by compiling single components at a time using + @code{gcc}, you typically keep track of the units you modify. In order to + build a consistent system, you compile not only these units, but also any + units that depend on the units you have modified. + For example, in the preceding case, + if you edit @file{gmain.adb}, you only need to recompile that file. But if + you edit @file{greetings.ads}, you must recompile both + @file{greetings.adb} and @file{gmain.adb}, because both files contain + units that depend on @file{greetings.ads}. + + @code{gnatbind} will warn you if you forget one of these compilation + steps, so that it is impossible to generate an inconsistent program as a + result of forgetting to do a compilation. Nevertheless it is tedious and + error-prone to keep track of dependencies among units. + One approach to handle the dependency-bookkeeping is to use a + makefile. However, makefiles present maintenance problems of their own: + if the dependencies change as you change the program, you must make + sure that the makefile is kept up-to-date manually, which is also an + error-prone process. + + The @code{gnatmake} utility takes care of these details automatically. + Invoke it using either one of the following forms: + + @smallexample + $ gnatmake gmain.adb + $ gnatmake gmain + @end smallexample + + + @noindent + The argument is the name of the file containing the main program; + you may omit the extension. @code{gnatmake} + examines the environment, automatically recompiles any files that need + recompiling, and binds and links the resulting set of object files, + generating the executable file, @file{gmain}. + In a large program, it + can be extremely helpful to use @code{gnatmake}, because working out by hand + what needs to be recompiled can be difficult. + + Note that @code{gnatmake} + takes into account all the Ada 95 rules that + establish dependencies among units. These include dependencies that result + from inlining subprogram bodies, and from + generic instantiation. Unlike some other + Ada make tools, @code{gnatmake} does not rely on the dependencies that were + found by the compiler on a previous compilation, which may possibly + be wrong when sources change. @code{gnatmake} determines the exact set of + dependencies from scratch each time it is run. + + + @node Introduction to Glide and GVD + @section Introduction to Glide and GVD + @cindex Glide + @cindex GVD + @noindent + Although it is possible to develop programs using only the command line interface (@command{gnatmake}, etc.) a graphical Interactive Development Environment can make it easier for you to compose, navigate, and debug programs. This section describes the main features of Glide, the GNAT graphical IDE, and also shows how to use the basic commands in GVD, the GNU Visual Debugger. Additional information may be found in the on-line help for these tools. + + @menu + * Building a New Program with Glide:: + * Simple Debugging with GVD:: + * Other Glide Features:: + @end menu + + @node Building a New Program with Glide + @subsection Building a New Program with Glide + @noindent + The simplest way to invoke Glide is to enter @command{glide} at the command prompt. It will generally be useful to issue this as a background command, thus allowing you to continue using your command window for other purposes while Glide is running: + + @smallexample + $ glide& + @end smallexample + + @noindent + Glide will start up with an initial screen displaying the top-level menu items as well as some other information. The menu selections are as follows + @itemize @bullet + @item @code{Buffers} + @item @code{Files} + @item @code{Tools} + @item @code{Edit} + @item @code{Search} + @item @code{Mule} + @item @code{Glide} + @item @code{Help} + @end itemize + + @noindent + For this introductory example, you will need to create a new Ada source file. First, select the @code{Files} menu. This will pop open a menu with around a dozen or so items. To create a file, select the @code{Open file...} choice. Depending on the platform, you may see a pop-up window where you can browse to an appropriate directory and then enter the file name, or else simply see a line at the bottom of the Glide window where you can likewise enter the file name. Note that in Glide, when you attempt to open a non-existent file, the effect is to create a file with that name. For this example enter @file{hello.adb} as the name of the file. + + A new buffer will now appear, occupying the entire Glide window, with the file name at the top. The menu selections are slightly different from the ones you saw on the opening screen; there is an @code{Entities} item, and in place of @code{Glide} there is now an @code{Ada} item. Glide uses the file extension to identify the source language, so @file{adb} indicates an Ada source file. + + You will enter some of the source program lines explicitly, and use the syntax-oriented template mechanism to enter other lines. First, type the following text: + @smallexample + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + @end smallexample + + @noindent + Observe that Glide uses different colors to distinguish reserved words from identifiers. Also, after the @code{procedure Hello is} line, the cursor is automatically indented in anticipation of declarations. When you enter @code{begin}, Glide recognizes that there are no declarations and thus places @code{begin} flush left. But after the @code{begin} line the cursor is again indented, where the statement(s) will be placed. + + The main part of the program will be a @code{for} loop. Instead of entering the text explicitly, however, use a statement template. Select the @code{Ada} item on the top menu bar, move the mouse to the @code{Statements} item, and you will see a large selection of alternatives. Choose @code{for loop}. You will be prompted (at the bottom of the buffer) for a loop name; simply press the @key{Enter} key since a loop name is not needed. You should see the beginning of a @code{for} loop appear in the source program window. You will now be prompted for the name of the loop variable; enter a line with the identifier @code{ind} (lower case). Note that, by default, Glide capitalizes the name (you can override such behavior if you wish, although this is outside the scope of this introduction). Next, Glide prompts you for the loop range; enter a line containing @code{1..5} and you will see this also appear in the source program, together with the remaining elements of the @code{for} loop syntax. + + Next enter the statement (with an intentional error, a missing semicolon) that will form the body of the loop: + @smallexample + Put_Line("Hello, World" & Integer'Image(I)) + @end smallexample + + @noindent + Finally, type @code{end Hello;} as the last line in the program. Now save the file: choose the @code{File} menu item, and then the @code{Save buffer} selection. You will see a message at the bottom of the buffer confirming that the file has been saved. + + You are now ready to attempt to build the program. Select the @code{Ada} item from the top menu bar. Although we could choose simply to compile the file, we will instead attempt to do a build (which invokes @command{gnatmake}) since, if the compile is successful, we want to build an executable. Thus select @code{Ada build}. This will fail because of the compilation error, and you will notice that the Glide window has been split: the top window contains the source file, and the bottom window contains the output from the GNAT tools. Glide allows you to navigate from a compilation error to the source file position corresponding to the error: click the middle mouse button (or simultaneously press the left and right buttons, on a two-button mouse) on the diagnostic line in the tool window. The focus will shift to the source window, and the cursor will be positioned on the character at which the error was detected. + + Correct the error: type in a semicolon to terminate the statement. Although you can again save the file explicitly, you can also simply invoke @code{Ada} @result{} @code{Build} and you will be prompted to save the file. This time the build will succeed; the tool output window shows you the options that are supplied by default. The GNAT tools' output (e.g., object and ALI files, executable) will go in the directory from which Glide was launched. + + To execute the program, choose @code{Ada} and then @code{Run}. You should see the program's output displayed in the bottom window: + + @smallexample + Hello, world 1 + Hello, world 2 + Hello, world 3 + Hello, world 4 + Hello, world 5 + @end smallexample + + @node Simple Debugging with GVD + @subsection Simple Debugging with GVD + + @noindent + This section describes how to set breakpoints, examine/modify variables, and step through execution. + + In order to enable debugging, you need to pass the @option{-g} switch to both the compiler and to @command{gnatlink}. If you are using the command line, passing @option{-g} to @command{gnatmake} will have this effect. You can then launch GVD, e.g. on the @code{hello} program, by issuing the command: + + @smallexample + $ gvd hello + @end smallexample + + @noindent + If you are using Glide, then @option{-g} is passed to the relevant tools by default when you do a build. Start the debugger by selecting the @code{Ada} menu item, and then @code{Debug}. + + GVD comes up in a multi-part window. One pane shows the names of files comprising your executable; another pane shows the source code of the current unit (initially your main subprogram), another pane shows the debugger output and user interactions, and the fourth pane (the data canvas at the top of the window) displays data objects that you have selected. + + To the left of the source file pane, you will notice green dots adjacent to some lines. These are lines for which object code exists and where breakpoints can thus be set. You set/reset a breakpoint by clicking the green dot. When a breakpoint is set, the dot is replaced by an @code{X} in a red circle. Clicking the circle toggles the breakpoint off, and the red circle is replaced by the green dot. + + For this example, set a breakpoint at the statement where @code{Put_Line} is invoked. + + Start program execution by selecting the @code{Run} button on the top menu bar. (The @code{Start} button will also start your program, but it will cause program execution to break at the entry to your main subprogram.) Evidence of reaching the breakpoint will appear: the source file line will be highlighted, and the debugger interactions pane will display a relevant message. + + You can examine the values of variables in several ways. Move the mouse over an occurrence of @code{Ind} in the @code{for} loop, and you will see the value (now @code{1}) displayed. Alternatively, right-click on @code{Ind} and select @code{Display Ind}; a box showing the variable's name and value will appear in the data canvas. + + Although a loop index is a constant with respect to Ada semantics, you can change its value in the debugger. Right-click in the box for @code{Ind}, and select the @code{Set Value of Ind} item. Enter @code{2} as the new value, and press @command{OK}. The box for @code{Ind} shows the update. + + Press the @code{Step} button on the top menu bar; this will step through one line of program text (the invocation of @code{Put_Line}), and you can observe the effect of having modified @code{Ind} since the value displayed is @code{2}. + + Remove the breakpoint, and resume execution by selecting the @code{Cont} button. You will see the remaining output lines displayed in the debugger interaction window, along with a message confirming normal program termination. + + + @node Other Glide Features + @subsection Other Glide Features + + @noindent + You may have observed that some of the menu selections contain abbreviations; e.g., @code{(C-x C-f)} for @code{Open file...} in the @code{Files} menu. These are @emph{shortcut keys} that you can use instead of selecting menu items. The @key{C} stands for @key{Ctrl}; thus @code{(C-x C-f)} means @key{Ctrl-x} followed by @key{Ctrl-f}, and this sequence can be used instead of selecting @code{Files} and then @code{Open file...}. + + To abort a Glide command, type @key{Ctrl-g}. + + If you want Glide to start with an existing source file, you can either launch Glide as above and then open the file via @code{Files} @result{} @code{Open file...}, or else simply pass the name of the source file on the command line: + + @smallexample + $ glide hello.adb& + @end smallexample + + @noindent + While you are using Glide, a number of @emph{buffers} exist. You create some explicitly; e.g., when you open/create a file. Others arise as an effect of the commands that you issue; e.g., the buffer containing the output of the tools invoked during a build. If a buffer is hidden, you can bring it into a visible window by first opening the @code{Buffers} menu and then selecting the desired entry. + + If a buffer occupies only part of the Glide screen and you want to expand it to fill the entire screen, then click in the buffer and then select @code{Files} @result{} @code{One Window}. + + If a window is occupied by one buffer and you want to split the window to bring up a second buffer, perform the following steps: + @itemize @bullet + @item Select @code{Files} @result{} @code{Split Window}; this will produce two windows each of which holds the original buffer (these are not copies, but rather different views of the same buffer contents) + @item With the focus in one of the windows, select the desired buffer from the @code{Buffers} menu + @end itemize + + @noindent + To exit from Glide, choose @code{Files} @result{} @code{Exit}. + + @node The GNAT Compilation Model + @chapter The GNAT Compilation Model + @cindex GNAT compilation model + @cindex Compilation model + + @menu + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + @end menu + + @noindent + This chapter describes the compilation model used by GNAT. Although + similar to that used by other languages, such as C and C++, this model + is substantially different from the traditional Ada compilation models, + which are based on a library. The model is initially described without + reference to the library-based model. If you have not previously used an + Ada compiler, you need only read the first part of this chapter. The + last section describes and discusses the differences between the GNAT + model and the traditional Ada compiler models. If you have used other + Ada compilers, this section will help you to understand those + differences, and the advantages of the GNAT model. + + @node Source Representation + @section Source Representation + @cindex Latin-1 + + @noindent + Ada source programs are represented in standard text files, using + Latin-1 coding. Latin-1 is an 8-bit code that includes the familiar + 7-bit ASCII set, plus additional characters used for + representing foreign languages (@pxref{Foreign Language Representation} + for support of non-USA character sets). The format effector characters + are represented using their standard ASCII encodings, as follows: + + @table @code + @item VT + @findex VT + Vertical tab, @code{16#0B#} + + @item HT + @findex HT + Horizontal tab, @code{16#09#} + + @item CR + @findex CR + Carriage return, @code{16#0D#} + + @item LF + @findex LF + Line feed, @code{16#0A#} + + @item FF + @findex FF + Form feed, @code{16#0C#} + @end table + + @noindent + Source files are in standard text file format. In addition, GNAT will + recognize a wide variety of stream formats, in which the end of physical + physical lines is marked by any of the following sequences: + @code{LF}, @code{CR}, @code{CR-LF}, or @code{LF-CR}. This is useful + in accommodating files that are imported from other operating systems. + + @cindex End of source file + @cindex Source file, end + @findex SUB + The end of a source file is normally represented by the physical end of + file. However, the control character @code{16#1A#} (@code{SUB}) is also + recognized as signalling the end of the source file. Again, this is + provided for compatibility with other operating systems where this + code is used to represent the end of file. + + Each file contains a single Ada compilation unit, including any pragmas + associated with the unit. For example, this means you must place a + package declaration (a package @dfn{spec}) and the corresponding body in + separate files. An Ada @dfn{compilation} (which is a sequence of + compilation units) is represented using a sequence of files. Similarly, + you will place each subunit or child unit in a separate file. + + @node Foreign Language Representation + @section Foreign Language Representation + + @noindent + GNAT supports the standard character sets defined in Ada 95 as well as + several other non-standard character sets for use in localized versions + of the compiler (@pxref{Character Set Control}). + @menu + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + @end menu + + @node Latin-1 + @subsection Latin-1 + @cindex Latin-1 + + @noindent + The basic character set is Latin-1. This character set is defined by ISO + standard 8859, part 1. The lower half (character codes @code{16#00#} + ... @code{16#7F#)} is identical to standard ASCII coding, but the upper half is + used to represent additional characters. These include extended letters + used by European languages, such as French accents, the vowels with umlauts + used in German, and the extra letter A-ring used in Swedish. + + @findex Ada.Characters.Latin_1 + For a complete list of Latin-1 codes and their encodings, see the source + file of library unit @code{Ada.Characters.Latin_1} in file + @file{a-chlat1.ads}. + You may use any of these extended characters freely in character or + string literals. In addition, the extended characters that represent + letters can be used in identifiers. + + @node Other 8-Bit Codes + @subsection Other 8-Bit Codes + + @noindent + GNAT also supports several other 8-bit coding schemes: + + @table @asis + @cindex Latin-2 + @item Latin-2 + Latin-2 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-3 + @cindex Latin-3 + Latin-3 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-4 + @cindex Latin-4 + Latin-4 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-5 + @cindex Latin-5 + @cindex Cyrillic + Latin-4 letters (Cyrillic) allowed in identifiers, with uppercase and lowercase + equivalence. + + @item IBM PC (code page 437) + @cindex code page 437 + This code page is the normal default for PCs in the U.S. It corresponds + to the original IBM PC character set. This set has some, but not all, of + the extended Latin-1 letters, but these letters do not have the same + encoding as Latin-1. In this mode, these letters are allowed in + identifiers with uppercase and lowercase equivalence. + + @item IBM PC (code page 850) + @cindex code page 850 + This code page is a modification of 437 extended to include all the + Latin-1 letters, but still not with the usual Latin-1 encoding. In this + mode, all these letters are allowed in identifiers with uppercase and + lowercase equivalence. + + @item Full Upper 8-bit + Any character in the range 80-FF allowed in identifiers, and all are + considered distinct. In other words, there are no uppercase and lowercase + equivalences in this range. This is useful in conjunction with + certain encoding schemes used for some foreign character sets (e.g. + the typical method of representing Chinese characters on the PC). + + @item No Upper-Half + No upper-half characters in the range 80-FF are allowed in identifiers. + This gives Ada 83 compatibility for identifier names. + @end table + + @noindent + For precise data on the encodings permitted, and the uppercase and lowercase + equivalences that are recognized, see the file @file{csets.adb} in + the GNAT compiler sources. You will need to obtain a full source release + of GNAT to obtain this file. + + @node Wide Character Encodings + @subsection Wide Character Encodings + + @noindent + GNAT allows wide character codes to appear in character and string + literals, and also optionally in identifiers, by means of the following + possible encoding schemes: + + @table @asis + + @item Hex Coding + In this encoding, a wide character is represented by the following five + character sequence: + + @smallexample + ESC a b c d + @end smallexample + + @noindent + Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal + characters (using uppercase letters) of the wide character code. For + example, ESC A345 is used to represent the wide character with code + @code{16#A345#}. + This scheme is compatible with use of the full Wide_Character set. + + @item Upper-Half Coding + @cindex Upper-Half Coding + The wide character with encoding @code{16#abcd#} where the upper bit is on (in + other words, "a" is in the range 8-F) is represented as two bytes, + @code{16#ab#} and @code{16#cd#}. The second byte cannot be a format control + character, but is not required to be in the upper half. This method can + be also used for shift-JIS or EUC, where the internal coding matches the + external coding. + + @item Shift JIS Coding + @cindex Shift JIS Coding + A wide character is represented by a two-character sequence, + @code{16#ab#} and + @code{16#cd#}, with the restrictions described for upper-half encoding as + described above. The internal character code is the corresponding JIS + character according to the standard algorithm for Shift-JIS + conversion. Only characters defined in the JIS code set table can be + used with this encoding method. + + @item EUC Coding + @cindex EUC Coding + A wide character is represented by a two-character sequence + @code{16#ab#} and + @code{16#cd#}, with both characters being in the upper half. The internal + character code is the corresponding JIS character according to the EUC + encoding algorithm. Only characters defined in the JIS code set table + can be used with this encoding method. + + @item UTF-8 Coding + A wide character is represented using + UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO + 10646-1/Am.2. Depending on the character value, the representation + is a one, two, or three byte sequence: + @smallexample + @iftex + @leftskip=.7cm + @end iftex + 16#0000#-16#007f#: 2#0xxxxxxx# + 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx# + 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx# + + @end smallexample + + @noindent + where the xxx bits correspond to the left-padded bits of the + 16-bit character value. Note that all lower half ASCII characters + are represented as ASCII bytes and all upper half characters and + other wide characters are represented as sequences of upper-half + (The full UTF-8 scheme allows for encoding 31-bit characters as + 6-byte sequences, but in this implementation, all UTF-8 sequences + of four or more bytes length will be treated as illegal). + @item Brackets Coding + In this encoding, a wide character is represented by the following eight + character sequence: + + @smallexample + [ " a b c d " ] + @end smallexample + + @noindent + Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal + characters (using uppercase letters) of the wide character code. For + example, ["A345"] is used to represent the wide character with code + @code{16#A345#}. It is also possible (though not required) to use the + Brackets coding for upper half characters. For example, the code + @code{16#A3#} can be represented as @code{["A3"]}. + + This scheme is compatible with use of the full Wide_Character set, + and is also the method used for wide character encoding in the standard + ACVC (Ada Compiler Validation Capability) test suite distributions. + + @end table + + @noindent + Note: Some of these coding schemes do not permit the full use of the + Ada 95 character set. For example, neither Shift JIS, nor EUC allow the + use of the upper half of the Latin-1 set. + + @node File Naming Rules + @section File Naming Rules + + @noindent + The default file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + lowercase for all letters. + + An exception arises if the file name generated by the above rules starts + with one of the characters + a,g,i, or s, + and the second character is a + minus. In this case, the character tilde is used in place + of the minus. The reason for this special rule is to avoid clashes with + the standard names for child units of the packages System, Ada, + Interfaces, and GNAT, which use the prefixes + s- a- i- and g- + respectively. + + The file extension is @file{.ads} for a spec and + @file{.adb} for a body. The following list shows some + examples of these rules. + + @table @file + @item main.ads + Main (spec) + @item main.adb + Main (body) + @item arith_functions.ads + Arith_Functions (package spec) + @item arith_functions.adb + Arith_Functions (package body) + @item func-spec.ads + Func.Spec (child package spec) + @item func-spec.adb + Func.Spec (child package body) + @item main-sub.adb + Sub (subunit of Main) + @item a~bad.adb + A.Bad (child package body) + @end table + + @noindent + Following these rules can result in excessively long + file names if corresponding + unit names are long (for example, if child units or subunits are + heavily nested). An option is available to shorten such long file names + (called file name "krunching"). This may be particularly useful when + programs being developed with GNAT are to be used on operating systems + with limited file name lengths. @xref{Using gnatkr}. + + Of course, no file shortening algorithm can guarantee uniqueness over + all possible unit names; if file name krunching is used, it is your + responsibility to ensure no name clashes occur. Alternatively you + can specify the exact file names that you want used, as described + in the next section. Finally, if your Ada programs are migrating from a + compiler with a different naming convention, you can use the gnatchop + utility to produce source files that follow the GNAT naming conventions. + (For details @pxref{Renaming Files Using gnatchop}.) + + @node Using Other File Names + @section Using Other File Names + @cindex File names + + @noindent + In the previous section, we have described the default rules used by + GNAT to determine the file name in which a given unit resides. It is + often convenient to follow these default rules, and if you follow them, + the compiler knows without being explicitly told where to find all + the files it needs. + + However, in some cases, particularly when a program is imported from + another Ada compiler environment, it may be more convenient for the + programmer to specify which file names contain which units. GNAT allows + arbitrary file names to be used by means of the Source_File_Name pragma. + The form of this pragma is as shown in the following examples: + @cindex Source_File_Name pragma + + @smallexample + @group + @cartouche + @b{pragma} Source_File_Name (My_Utilities.Stacks, + Spec_File_Name => "myutilst_a.ada"); + @b{pragma} Source_File_name (My_Utilities.Stacks, + Body_File_Name => "myutilst.ada"); + @end cartouche + @end group + @end smallexample + + @noindent + As shown in this example, the first argument for the pragma is the unit + name (in this example a child unit). The second argument has the form + of a named association. The identifier + indicates whether the file name is for a spec or a body; + the file name itself is given by a string literal. + + The source file name pragma is a configuration pragma, which means that + normally it will be placed in the @file{gnat.adc} + file used to hold configuration + pragmas that apply to a complete compilation environment. + For more details on how the @file{gnat.adc} file is created and used + @pxref{Handling of Configuration Pragmas} + @cindex @file{gnat.adc} + + GNAT allows completely arbitrary file names to be specified using the + source file name pragma. However, if the file name specified has an + extension other than @file{.ads} or @file{.adb} it is necessary to use a special + syntax when compiling the file. The name in this case must be preceded + by the special sequence @code{-x} followed by a space and the name of the + language, here @code{ada}, as in: + + @smallexample + $ gcc -c -x ada peculiar_file_name.sim + @end smallexample + + @noindent + @code{gnatmake} handles non-standard file names in the usual manner (the + non-standard file name for the main program is simply used as the + argument to gnatmake). Note that if the extension is also non-standard, + then it must be included in the gnatmake command, it may not be omitted. + + @node Alternative File Naming Schemes + @section Alternative File Naming Schemes + @cindex File naming schemes, alternative + @cindex File names + + In the previous section, we described the use of the @code{Source_File_Name} + pragma to allow arbitrary names to be assigned to individual source files. + However, this approach requires one pragma for each file, and especially in + large systems can result in very long @file{gnat.adc} files, and also create + a maintenance problem. + + GNAT also provides a facility for specifying systematic file naming schemes + other than the standard default naming scheme previously described. An + alternative scheme for naming is specified by the use of + @code{Source_File_Name} pragmas having the following format: + @cindex Source_File_Name pragma + + @smallexample + pragma Source_File_Name ( + Spec_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Body_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Subunit_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + FILE_NAME_PATTERN ::= STRING_LITERAL + CASING_SPEC ::= Lowercase | Uppercase | Mixedcase + + @end smallexample + + @noindent + The @code{FILE_NAME_PATTERN} string shows how the file name is constructed. + It contains a single asterisk character, and the unit name is substituted + systematically for this asterisk. The optional parameter + @code{Casing} indicates + whether the unit name is to be all upper-case letters, all lower-case letters, + or mixed-case. If no + @code{Casing} parameter is used, then the default is all + lower-case. + + The optional @code{Dot_Replacement} string is used to replace any periods + that occur in subunit or child unit names. If no @code{Dot_Replacement} + argument is used then separating dots appear unchanged in the resulting + file name. + Although the above syntax indicates that the + @code{Casing} argument must appear + before the @code{Dot_Replacement} argument, but it + is also permissible to write these arguments in the opposite order. + + As indicated, it is possible to specify different naming schemes for + bodies, specs, and subunits. Quite often the rule for subunits is the + same as the rule for bodies, in which case, there is no need to give + a separate @code{Subunit_File_Name} rule, and in this case the + @code{Body_File_name} rule is used for subunits as well. + + The separate rule for subunits can also be used to implement the rather + unusual case of a compilation environment (e.g. a single directory) which + contains a subunit and a child unit with the same unit name. Although + both units cannot appear in the same partition, the Ada Reference Manual + allows (but does not require) the possibility of the two units coexisting + in the same environment. + + The file name translation works in the following steps: + + @itemize @bullet + + @item + If there is a specific @code{Source_File_Name} pragma for the given unit, + then this is always used, and any general pattern rules are ignored. + + @item + If there is a pattern type @code{Source_File_Name} pragma that applies to + the unit, then the resulting file name will be used if the file exists. If + more than one pattern matches, the latest one will be tried first, and the + first attempt resulting in a reference to a file that exists will be used. + + @item + If no pattern type @code{Source_File_Name} pragma that applies to the unit + for which the corresponding file exists, then the standard GNAT default + naming rules are used. + + @end itemize + + @noindent + As an example of the use of this mechanism, consider a commonly used scheme + in which file names are all lower case, with separating periods copied + unchanged to the resulting file name, and specs end with ".1.ada", and + bodies end with ".2.ada". GNAT will follow this scheme if the following + two pragmas appear: + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*.1.ada"); + pragma Source_File_Name + (Body_File_Name => "*.2.ada"); + @end smallexample + + @noindent + The default GNAT scheme is actually implemented by providing the following + default pragmas internally: + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*.ads", Dot_Replacement => "-"); + pragma Source_File_Name + (Body_File_Name => "*.adb", Dot_Replacement => "-"); + @end smallexample + + @noindent + Our final example implements a scheme typically used with one of the + Ada 83 compilers, where the separator character for subunits was "__" + (two underscores), specs were identified by adding @file{_.ADA}, bodies + by adding @file{.ADA}, and subunits by + adding @file{.SEP}. All file names were + upper case. Child units were not present of course since this was an + Ada 83 compiler, but it seems reasonable to extend this scheme to use + the same double underscore separator for child units. + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*_.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Body_File_Name => "*.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Subunit_File_Name => "*.SEP", + Dot_Replacement => "__", + Casing = Uppercase); + @end smallexample + + @node Generating Object Files + @section Generating Object Files + + @noindent + An Ada program consists of a set of source files, and the first step in + compiling the program is to generate the corresponding object files. + These are generated by compiling a subset of these source files. + The files you need to compile are the following: + + @itemize @bullet + @item + If a package spec has no body, compile the package spec to produce the + object file for the package. + + @item + If a package has both a spec and a body, compile the body to produce the + object file for the package. The source file for the package spec need + not be compiled in this case because there is only one object file, which + contains the code for both the spec and body of the package. + + @item + For a subprogram, compile the subprogram body to produce the object file + for the subprogram. The spec, if one is present, is as usual in a + separate file, and need not be compiled. + + @item + @cindex Subunits + In the case of subunits, only compile the parent unit. A single object + file is generated for the entire subunit tree, which includes all the + subunits. + + @item + Compile child units independently of their parent units + (though, of course, the spec of all the ancestor unit must be present in order + to compile a child unit). + + @item + @cindex Generics + Compile generic units in the same manner as any other units. The object + files in this case are small dummy files that contain at most the + flag used for elaboration checking. This is because GNAT always handles generic + instantiation by means of macro expansion. However, it is still necessary to + compile generic units, for dependency checking and elaboration purposes. + @end itemize + + @noindent + The preceding rules describe the set of files that must be compiled to + generate the object files for a program. Each object file has the same + name as the corresponding source file, except that the extension is + @file{.o} as usual. + + You may wish to compile other files for the purpose of checking their + syntactic and semantic correctness. For example, in the case where a + package has a separate spec and body, you would not normally compile the + spec. However, it is convenient in practice to compile the spec to make + sure it is error-free before compiling clients of this spec, because such + compilations will fail if there is an error in the spec. + + GNAT provides an option for compiling such files purely for the + purposes of checking correctness; such compilations are not required as + part of the process of building a program. To compile a file in this + checking mode, use the @option{-gnatc} switch. + + @node Source Dependencies + @section Source Dependencies + + @noindent + A given object file clearly depends on the source file which is compiled + to produce it. Here we are using @dfn{depends} in the sense of a typical + @code{make} utility; in other words, an object file depends on a source + file if changes to the source file require the object file to be + recompiled. + In addition to this basic dependency, a given object may depend on + additional source files as follows: + + @itemize @bullet + @item + If a file being compiled @code{with}'s a unit @var{X}, the object file + depends on the file containing the spec of unit @var{X}. This includes + files that are @code{with}'ed implicitly either because they are parents + of @code{with}'ed child units or they are run-time units required by the + language constructs used in a particular unit. + + @item + If a file being compiled instantiates a library level generic unit, the + object file depends on both the spec and body files for this generic + unit. + + @item + If a file being compiled instantiates a generic unit defined within a + package, the object file depends on the body file for the package as + well as the spec file. + + @item + @findex Inline + @cindex @option{-gnatn} switch + If a file being compiled contains a call to a subprogram for which + pragma @code{Inline} applies and inlining is activated with the + @option{-gnatn} switch, the object file depends on the file containing the + body of this subprogram as well as on the file containing the spec. Note + that for inlining to actually occur as a result of the use of this switch, + it is necessary to compile in optimizing mode. + + @cindex @option{-gnatN} switch + The use of @option{-gnatN} activates a more extensive inlining optimization + that is performed by the front end of the compiler. This inlining does + not require that the code generation be optimized. Like @option{-gnatn}, + the use of this switch generates additional dependencies. + + @item + If an object file O depends on the proper body of a subunit through inlining + or instantiation, it depends on the parent unit of the subunit. This means that + any modification of the parent unit or one of its subunits affects the + compilation of O. + + @item + The object file for a parent unit depends on all its subunit body files. + + @item + The previous two rules meant that for purposes of computing dependencies and + recompilation, a body and all its subunits are treated as an indivisible whole. + + @noindent + These rules are applied transitively: if unit @code{A} @code{with}'s + unit @code{B}, whose elaboration calls an inlined procedure in package + @code{C}, the object file for unit @code{A} will depend on the body of + @code{C}, in file @file{c.adb}. + + The set of dependent files described by these rules includes all the + files on which the unit is semantically dependent, as described in the + Ada 95 Language Reference Manual. However, it is a superset of what the + ARM describes, because it includes generic, inline, and subunit dependencies. + + An object file must be recreated by recompiling the corresponding source + file if any of the source files on which it depends are modified. For + example, if the @code{make} utility is used to control compilation, + the rule for an Ada object file must mention all the source files on + which the object file depends, according to the above definition. + The determination of the necessary + recompilations is done automatically when one uses @code{gnatmake}. + @end itemize + + @node The Ada Library Information Files + @section The Ada Library Information Files + @cindex Ada Library Information files + @cindex @file{ali} files + + @noindent + Each compilation actually generates two output files. The first of these + is the normal object file that has a @file{.o} extension. The second is a + text file containing full dependency information. It has the same + name as the source file, but an @file{.ali} extension. + This file is known as the Ada Library Information (@file{ali}) file. + The following information is contained in the @file{ali} file. + + @itemize @bullet + @item + Version information (indicates which version of GNAT was used to compile + the unit(s) in question) + + @item + Main program information (including priority and time slice settings, + as well as the wide character encoding used during compilation). + + @item + List of arguments used in the @code{gcc} command for the compilation + + @item + Attributes of the unit, including configuration pragmas used, an indication + of whether the compilation was successful, exception model used etc. + + @item + A list of relevant restrictions applying to the unit (used for consistency) + checking. + + @item + Categorization information (e.g. use of pragma @code{Pure}). + + @item + Information on all @code{with}'ed units, including presence of + @code{Elaborate} or @code{Elaborate_All} pragmas. + + @item + Information from any @code{Linker_Options} pragmas used in the unit + + @item + Information on the use of @code{Body_Version} or @code{Version} + attributes in the unit. + + @item + Dependency information. This is a list of files, together with + time stamp and checksum information. These are files on which + the unit depends in the sense that recompilation is required + if any of these units are modified. + + @item + Cross-reference data. Contains information on all entities referenced + in the unit. Used by tools like @code{gnatxref} and @code{gnatfind} to + provide cross-reference information. + + @end itemize + + @noindent + For a full detailed description of the format of the @file{ali} file, + see the source of the body of unit @code{Lib.Writ}, contained in file + @file{lib-writ.adb} in the GNAT compiler sources. + + @node Binding an Ada Program + @section Binding an Ada Program + + @noindent + When using languages such as C and C++, once the source files have been + compiled the only remaining step in building an executable program + is linking the object modules together. This means that it is possible to + link an inconsistent version of a program, in which two units have + included different versions of the same header. + + The rules of Ada do not permit such an inconsistent program to be built. + For example, if two clients have different versions of the same package, + it is illegal to build a program containing these two clients. + These rules are enforced by the GNAT binder, which also determines an + elaboration order consistent with the Ada rules. + + The GNAT binder is run after all the object files for a program have + been created. It is given the name of the main program unit, and from + this it determines the set of units required by the program, by reading the + corresponding ALI files. It generates error messages if the program is + inconsistent or if no valid order of elaboration exists. + + If no errors are detected, the binder produces a main program, in Ada by + default, that contains calls to the elaboration procedures of those + compilation unit that require them, followed by + a call to the main program. This Ada program is compiled to generate the + object file for the main program. The name of + the Ada file is @file{b~@var{xxx}.adb} (with the corresponding spec + @file{b~@var{xxx}.ads}) where @var{xxx} is the name of the + main program unit. + + Finally, the linker is used to build the resulting executable program, + using the object from the main program from the bind step as well as the + object files for the Ada units of the program. + + @node Mixed Language Programming + @section Mixed Language Programming + @cindex Mixed Language Programming + + @menu + * Interfacing to C:: + * Calling Conventions:: + @end menu + + @node Interfacing to C + @subsection Interfacing to C + @noindent + There are two ways to + build a program that contains some Ada files and some other language + files depending on whether the main program is in Ada or not. + If the main program is in Ada, you should proceed as follows: + + @enumerate + @item + Compile the other language files to generate object files. For instance: + @smallexample + gcc -c file1.c + gcc -c file2.c + @end smallexample + + @item + Compile the Ada units to produce a set of object files and ALI + files. For instance: + @smallexample + gnatmake -c my_main.adb + @end smallexample + + @item + Run the Ada binder on the Ada main program. For instance: + @smallexample + gnatbind my_main.ali + @end smallexample + + @item + Link the Ada main program, the Ada objects and the other language + objects. For instance: + @smallexample + gnatlink my_main.ali file1.o file2.o + @end smallexample + @end enumerate + + The three last steps can be grouped in a single command: + @smallexample + gnatmake my_main.adb -largs file1.o file2.o + @end smallexample + + @cindex Binder output file + @noindent + If the main program is in some language other than Ada, Then you may + have more than one entry point in the Ada subsystem. You must use a + special option of the binder to generate callable routines to initialize + and finalize the Ada units (@pxref{Binding with Non-Ada Main Programs}). + Calls to the initialization and finalization routines must be inserted in + the main program, or some other appropriate point in the code. The call to + initialize the Ada units must occur before the first Ada subprogram is + called, and the call to finalize the Ada units must occur after the last + Ada subprogram returns. You use the same procedure for building the + program as described previously. In this case, however, the binder + only places the initialization and finalization subprograms into file + @file{b~@var{xxx}.adb} instead of the main program. + So, if the main program is not in Ada, you should proceed as follows: + + @enumerate + @item + Compile the other language files to generate object files. For instance: + @smallexample + gcc -c file1.c + gcc -c file2.c + @end smallexample + + @item + Compile the Ada units to produce a set of object files and ALI + files. For instance: + @smallexample + gnatmake -c entry_point1.adb + gnatmake -c entry_point2.adb + @end smallexample + + @item + Run the Ada binder on the Ada main program. For instance: + @smallexample + gnatbind -n entry_point1.ali entry_point2.ali + @end smallexample + + @item + Link the Ada main program, the Ada objects and the other language + objects. You only need to give the last entry point here. For instance: + @smallexample + gnatlink entry_point2.ali file1.o file2.o + @end smallexample + @end enumerate + + @node Calling Conventions + @subsection Calling Conventions + @cindex Foreign Languages + @cindex Calling Conventions + GNAT follows standard calling sequence conventions and will thus interface + to any other language that also follows these conventions. The following + Convention identifiers are recognized by GNAT: + + @itemize @bullet + @cindex Interfacing to Ada + @cindex Other Ada compilers + @cindex Convention Ada + @item + Ada. This indicates that the standard Ada calling sequence will be + used and all Ada data items may be passed without any limitations in the + case where GNAT is used to generate both the caller and callee. It is also + possible to mix GNAT generated code and code generated by another Ada + compiler. In this case, the data types should be restricted to simple + cases, including primitive types. Whether complex data types can be passed + depends on the situation. Probably it is safe to pass simple arrays, such + as arrays of integers or floats. Records may or may not work, depending + on whether both compilers lay them out identically. Complex structures + involving variant records, access parameters, tasks, or protected types, + are unlikely to be able to be passed. + + Note that in the case of GNAT running + on a platform that supports DEC Ada 83, a higher degree of compatibility + can be guaranteed, and in particular records are layed out in an identical + manner in the two compilers. Note also that if output from two different + compilers is mixed, the program is responsible for dealing with elaboration + issues. Probably the safest approach is to write the main program in the + version of Ada other than GNAT, so that it takes care of its own elaboration + requirements, and then call the GNAT-generated adainit procedure to ensure + elaboration of the GNAT components. Consult the documentation of the other + Ada compiler for further details on elaboration. + + However, it is not possible to mix the tasking run time of GNAT and + DEC Ada 83, All the tasking operations must either be entirely within + GNAT compiled sections of the program, or entirely within DEC Ada 83 + compiled sections of the program. + + @cindex Interfacing to Assembly + @cindex Convention Assembler + @item + Assembler. Specifies assembler as the convention. In practice this has the + same effect as convention Ada (but is not equivalent in the sense of being + considered the same convention). + + @cindex Convention Asm + @findex Asm + @item + Asm. Equivalent to Assembler. + + @cindex Convention Asm + @findex Asm + @item + Asm. Equivalent to Assembly. + + @cindex Interfacing to COBOL + @cindex Convention COBOL + @findex COBOL + @item + COBOL. Data will be passed according to the conventions described + in section B.4 of the Ada 95 Reference Manual. + + @findex C + @cindex Interfacing to C + @cindex Convention C + @item + C. Data will be passed according to the conventions described + in section B.3 of the Ada 95 Reference Manual. + + @cindex Convention Default + @findex Default + @item + Default. Equivalent to C. + + @cindex Convention External + @findex External + @item + External. Equivalent to C. + + @findex C++ + @cindex Interfacing to C++ + @cindex Convention C++ + @item + CPP. This stands for C++. For most purposes this is identical to C. + See the separate description of the specialized GNAT pragmas relating to + C++ interfacing for further details. + + @findex Fortran + @cindex Interfacing to Fortran + @cindex Convention Fortran + @item + Fortran. Data will be passed according to the conventions described + in section B.5 of the Ada 95 Reference Manual. + + @item + Intrinsic. This applies to an intrinsic operation, as defined in the Ada 95 + Reference Manual. If a a pragma Import (Intrinsic) applies to a subprogram, + this means that the body of the subprogram is provided by the compiler itself, + usually by means of an efficient code sequence, and that the user does not + supply an explicit body for it. In an application program, the pragma can only + be applied to the following two sets of names, which the GNAT compiler + recognizes. + @itemize @bullet + @item + Rotate_Left, Rotate_Right, Shift_Left, Shift_Right, Shift_Right_- + Arithmetic. The corresponding subprogram declaration must have + two formal parameters. The + first one must be a signed integer type or a modular type with a binary + modulus, and the second parameter must be of type Natural. + The return type must be the same as the type of the first argument. The size + of this type can only be 8, 16, 32, or 64. + @item binary arithmetic operators: "+", "-", "*", "/" + The corresponding operator declaration must have parameters and result type + that have the same root numeric type (for example, all three are long_float + types). This simplifies the definition of operations that use type checking + to perform dimensional checks: + @smallexample + type Distance is new Long_Float; + type Time is new Long_Float; + type Velocity is new Long_Float; + function "/" (D : Distance; T : Time) + return Velocity; + pragma Import (Intrinsic, "/"); + @end smallexample + @noindent + This common idiom is often programmed with a generic definition and an explicit + body. The pragma makes it simpler to introduce such declarations. It incurs + no overhead in compilation time or code size, because it is implemented as a + single machine instruction. + @end itemize + @noindent + + @findex Stdcall + @cindex Convention Stdcall + @item + Stdcall. This is relevant only to NT/Win95 implementations of GNAT, + and specifies that the Stdcall calling sequence will be used, as defined + by the NT API. + + @findex DLL + @cindex Convention DLL + @item + DLL. This is equivalent to Stdcall. + + @findex Win32 + @cindex Convention Win32 + @item + Win32. This is equivalent to Stdcall. + + @findex Stubbed + @cindex Convention Stubbed + @item + Stubbed. This is a special convention that indicates that the compiler + should provide a stub body that raises @code{Program_Error}. + @end itemize + + @noindent + GNAT additionally provides a useful pragma @code{Convention_Identifier} + that can be used to parametrize conventions and allow additional synonyms + to be specified. For example if you have legacy code in which the convention + identifier Fortran77 was used for Fortran, you can use the configuration + pragma: + + @smallexample + pragma Convention_Identifier (Fortran77, Fortran); + @end smallexample + + @noindent + And from now on the identifier Fortran77 may be used as a convention + identifier (for example in an @code{Import} pragma) with the same + meaning as Fortran. + + @node Building Mixed Ada & C++ Programs + @section Building Mixed Ada & C++ Programs + + @noindent + Building a mixed application containing both Ada and C++ code may be a + challenge for the unaware programmer. As a matter of fact, this + interfacing has not been standardized in the Ada 95 reference manual due + to the immaturity and lack of standard of C++ at the time. This + section gives a few hints that should make this task easier. In + particular the first section addresses the differences with + interfacing with C. The second section looks into the delicate problem + of linking the complete application from its Ada and C++ parts. The last + section give some hints on how the GNAT run time can be adapted in order + to allow inter-language dispatching with a new C++ compiler. + + @menu + * Interfacing to C++:: + * Linking a Mixed C++ & Ada Program:: + * A Simple Example:: + * Adapting the Run Time to a New C++ Compiler:: + @end menu + + @node Interfacing to C++ + @subsection Interfacing to C++ + + @noindent + GNAT supports interfacing with C++ compilers generating code that is + compatible with the standard Application Binary Interface of the given + platform. + + @noindent + Interfacing can be done at 3 levels: simple data, subprograms and + classes. In the first 2 cases, GNAT offer a specific @var{Convention + CPP} that behaves exactly like @var{Convention C}. Usually C++ mangle + names of subprograms and currently GNAT does not provide any help to + solve the demangling problem. This problem can be addressed in 2 ways: + @itemize @bullet + @item + by modifying the C++ code in order to force a C convention using + the @var{extern "C"} syntax. + + @item + by figuring out the mangled name and use it as the Link_Name argument of + the pragma import. + @end itemize + + @noindent + Interfacing at the class level can be achieved by using the GNAT specific + pragmas such as @code{CPP_Class} and @code{CPP_Virtual}. See the GNAT + Reference Manual for additional information. + + @node Linking a Mixed C++ & Ada Program + @subsection Linking a Mixed C++ & Ada Program + + @noindent + Usually the linker of the C++ development system must be used to link + mixed applications because most C++ systems will resolve elaboration + issues (such as calling constructors on global class instances) + transparently during the link phase. GNAT has been adapted to ease the + use of a foreign linker for the last phase. Three cases can be + considered: + @enumerate + + @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 request recompiling the whole GCC + tree from sources and it does not allow to upgrade easily to a new + version of one compiler for one of the two languages without taking the + risk of destabilizing the other. + + @smallexample + $ c++ -c file1.C + $ c++ -c file2.C + $ gnatmake ada_unit -largs file1.o file2.o --LINK=c++ + @end smallexample + + @item + Using GNAT and G++ from 2 different GCC installations. If both compilers + are on the PATH, the same method can be used. It is important to be + aware that environment variables such as C_INCLUDE_PATH, + GCC_EXEC_PREFIX, BINUTILS_ROOT or GCC_ROOT will affect both compilers at + the same time and thus may make one of the 2 compilers operate + improperly if they are set for the other. In particular it is important + that the link command has access to the proper gcc library @file{libgcc.a}, + that is to say the one that is part of the C++ compiler + installation. The implicit link command as suggested in the gnatmake + command from the former example can be replaced by an explicit link + command with full verbosity in order to verify which library is used: + @smallexample + $ gnatbind ada_unit + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=c++ + @end smallexample + If there is a problem due to interfering environment variables, it can + be workaround by using an intermediate script. The following example + shows the proper script to use when GNAT has not been installed at its + default location and g++ has been installed at its default location: + + @smallexample + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + unset BINUTILS_ROOT + unset GCC_ROOT + c++ $* + @end smallexample + + @item + Using a non GNU C++ compiler. The same set of command as previously + described can be used to insure that the c++ linker is + used. Nonetheless, you need to add the path to libgcc explicitely, since some + libraries needed by GNAT are located in this directory: + + @smallexample + + $ gnatlink ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + CC $* `gcc -print-libgcc-file-name` + + @end smallexample + + Where CC is the name of the non GNU C++ compiler. + + @end enumerate + + @node A Simple Example + @subsection A Simple Example + @noindent + The following example, provided as part of the GNAT examples, show how + to achieve procedural interfacing between Ada and C++ in both + directions. The C++ class A has 2 methods. The first method is exported + to Ada by the means of an extern C wrapper function. The second method + calls an Ada subprogram. On the Ada side, The C++ calls is modelized by + a limited record with a layout comparable to the C++ class. The Ada + subprogram, in turn, calls the c++ method. So from the C++ main program + the code goes back and forth between the 2 languages. + + @noindent + Here are the compilation commands + for native configurations: + @smallexample + $ gnatmake -c simple_cpp_interface + $ c++ -c cpp_main.C + $ c++ -c ex7.C + $ gnatbind -n simple_cpp_interface + $ gnatlink simple_cpp_interface -o cpp_main --LINK=$(CPLUSPLUS) + -lstdc++ ex7.o cpp_main.o + @end smallexample + @noindent + Here are the corresponding sources: + @smallexample + + //cpp_main.C + + #include "ex7.h" + + extern "C" @{ + void adainit (void); + void adafinal (void); + void method1 (A *t); + @} + + void method1 (A *t) + @{ + t->method1 (); + @} + + int main () + @{ + A obj; + adainit (); + obj.method2 (3030); + adafinal (); + @} + + //ex7.h + + class Origin @{ + public: + int o_value; + @}; + class A : public Origin @{ + public: + void method1 (void); + virtual void method2 (int v); + A(); + int a_value; + @}; + + //ex7.C + + #include "ex7.h" + #include + + extern "C" @{ void ada_method2 (A *t, int v);@} + + void A::method1 (void) + @{ + a_value = 2020; + printf ("in A::method1, a_value = %d \n",a_value); + + @} + + void A::method2 (int v) + @{ + ada_method2 (this, v); + printf ("in A::method2, a_value = %d \n",a_value); + + @} + + A::A(void) + @{ + a_value = 1010; + printf ("in A::A, a_value = %d \n",a_value); + @} + + -- Ada sources + @b{package} @b{body} Simple_Cpp_Interface @b{is} + + @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer) @b{is} + @b{begin} + Method1 (This); + This.A_Value := V; + @b{end} Ada_Method2; + + @b{end} Simple_Cpp_Interface; + + @b{package} Simple_Cpp_Interface @b{is} + @b{type} A @b{is} @b{limited} + @b{record} + O_Value : Integer; + A_Value : Integer; + @b{end} @b{record}; + @b{pragma} Convention (C, A); + + @b{procedure} Method1 (This : @b{in} @b{out} A); + @b{pragma} Import (C, Method1); + + @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer); + @b{pragma} Export (C, Ada_Method2); + + @b{end} Simple_Cpp_Interface; + @end smallexample + + @node Adapting the Run Time to a New C++ Compiler + @subsection Adapting the Run Time to a New C++ Compiler + @noindent + GNAT offers the capability to derive Ada 95 tagged types directly from + preexisting C++ classes and . See "Interfacing with C++" in the GNAT + reference manual. The mechanism used by GNAT for achieving such a goal + has been made user configurable through a GNAT library unit + @code{Interfaces.CPP}. The default version of this file is adapted to + the GNU c++ compiler. Internal knowledge of the virtual + table layout used by the new C++ compiler is needed to configure + properly this unit. The Interface of this unit is known by the compiler + and cannot be changed except for the value of the constants defining the + characteristics of the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size, + CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source + of this unit for more details. + + @node Comparison between GNAT and C/C++ Compilation Models + @section Comparison between GNAT and C/C++ Compilation Models + + @noindent + The GNAT model of compilation is close to the C and C++ models. You can + think of Ada specs as corresponding to header files in C. As in C, you + don't need to compile specs; they are compiled when they are used. The + Ada @code{with} is similar in effect to the @code{#include} of a C + header. + + One notable difference is that, in Ada, you may compile specs separately + to check them for semantic and syntactic accuracy. This is not always + possible with C headers because they are fragments of programs that have + less specific syntactic or semantic rules. + + The other major difference is the requirement for running the binder, + which performs two important functions. First, it checks for + consistency. In C or C++, the only defense against assembling + inconsistent programs lies outside the compiler, in a makefile, for + example. The binder satisfies the Ada requirement that it be impossible + to construct an inconsistent program when the compiler is used in normal + mode. + + @cindex Elaboration order control + The other important function of the binder is to deal with elaboration + issues. There are also elaboration issues in C++ that are handled + automatically. This automatic handling has the advantage of being + simpler to use, but the C++ programmer has no control over elaboration. + Where @code{gnatbind} might complain there was no valid order of + elaboration, a C++ compiler would simply construct a program that + malfunctioned at run time. + + @node Comparison between GNAT and Conventional Ada Library Models + @section Comparison between GNAT and Conventional Ada Library Models + + @noindent + This section is intended to be useful to Ada programmers who have + previously used an Ada compiler implementing the traditional Ada library + model, as described in the Ada 95 Language Reference Manual. If you + have not used such a system, please go on to the next section. + + @cindex GNAT library + In GNAT, there is no @dfn{library} in the normal sense. Instead, the set of + source files themselves acts as the library. Compiling Ada programs does + not generate any centralized information, but rather an object file and + a ALI file, which are of interest only to the binder and linker. + In a traditional system, the compiler reads information not only from + the source file being compiled, but also from the centralized library. + This means that the effect of a compilation depends on what has been + previously compiled. In particular: + + @itemize @bullet + @item + When a unit is @code{with}'ed, the unit seen by the compiler corresponds + to the version of the unit most recently compiled into the library. + + @item + Inlining is effective only if the necessary body has already been + compiled into the library. + + @item + Compiling a unit may obsolete other units in the library. + @end itemize + + @noindent + In GNAT, compiling one unit never affects the compilation of any other + units because the compiler reads only source files. Only changes to source + files can affect the results of a compilation. In particular: + + @itemize @bullet + @item + When a unit is @code{with}'ed, the unit seen by the compiler corresponds + to the source version of the unit that is currently accessible to the + compiler. + + @item + @cindex Inlining + Inlining requires the appropriate source files for the package or + subprogram bodies to be available to the compiler. Inlining is always + effective, independent of the order in which units are complied. + + @item + Compiling a unit never affects any other compilations. The editing of + sources may cause previous compilations to be out of date if they + depended on the source file being modified. + @end itemize + + @noindent + The most important result of these differences is that order of compilation + is never significant in GNAT. There is no situation in which one is + required to do one compilation before another. What shows up as order of + compilation requirements in the traditional Ada library becomes, in + GNAT, simple source dependencies; in other words, there is only a set + of rules saying what source files must be present when a file is + compiled. + + @node Compiling Using gcc + @chapter Compiling Using @code{gcc} + + @noindent + This chapter discusses how to compile Ada programs using the @code{gcc} + command. It also describes the set of switches + that can be used to control the behavior of the compiler. + @menu + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + @end menu + + @node Compiling Programs + @section Compiling Programs + + @noindent + The first step in creating an executable program is to compile the units + of the program using the @code{gcc} command. You must compile the + following files: + + @itemize @bullet + @item + the body file (@file{.adb}) for a library level subprogram or generic + subprogram + + @item + the spec file (@file{.ads}) for a library level package or generic + package that has no body + + @item + the body file (@file{.adb}) for a library level package + or generic package that has a body + + @end itemize + + @noindent + You need @emph{not} compile the following files + + @itemize @bullet + + @item + the spec of a library unit which has a body + + @item + subunits + @end itemize + + @noindent + because they are compiled as part of compiling related units. GNAT + package specs + when the corresponding body is compiled, and subunits when the parent is + compiled. + @cindex No code generated + If you attempt to compile any of these files, you will get one of the + following error messages (where fff is the name of the file you compiled): + + @smallexample + No code generated for file @var{fff} (@var{package spec}) + No code generated for file @var{fff} (@var{subunit}) + @end smallexample + + @noindent + The basic command for compiling a file containing an Ada unit is + + @smallexample + $ gcc -c [@var{switches}] @file{file name} + @end smallexample + + @noindent + where @var{file name} is the name of the Ada file (usually + having an extension + @file{.ads} for a spec or @file{.adb} for a body). + You specify the + @code{-c} switch to tell @code{gcc} to compile, but not link, the file. + The result of a successful compilation is an object file, which has the + same name as the source file but an extension of @file{.o} and an Ada + Library Information (ALI) file, which also has the same name as the + source file, but with @file{.ali} as the extension. GNAT creates these + two output files in the current directory, but you may specify a source + file in any directory using an absolute or relative path specification + containing the directory information. + + @findex gnat1 + @code{gcc} is actually a driver program that looks at the extensions of + the file arguments and loads the appropriate compiler. For example, the + GNU C compiler is @file{cc1}, and the Ada compiler is @file{gnat1}. + These programs are in directories known to the driver program (in some + configurations via environment variables you set), but need not be in + your path. The @code{gcc} driver also calls the assembler and any other + utilities needed to complete the generation of the required object + files. + + It is possible to supply several file names on the same @code{gcc} + command. This causes @code{gcc} to call the appropriate compiler for + each file. For example, the following command lists three separate + files to be compiled: + + @smallexample + $ gcc -c x.adb y.adb z.c + @end smallexample + + @noindent + calls @code{gnat1} (the Ada compiler) twice to compile @file{x.adb} and + @file{y.adb}, and @code{cc1} (the C compiler) once to compile @file{z.c}. + The compiler generates three object files @file{x.o}, @file{y.o} and + @file{z.o} and the two ALI files @file{x.ali} and @file{y.ali} from the + Ada compilations. Any switches apply to all the files listed, + except for + @option{-gnat@var{x}} switches, which apply only to Ada compilations. + + @node Switches for gcc + @section Switches for @code{gcc} + + @noindent + The @code{gcc} command accepts switches that control the + compilation process. These switches are fully described in this section. + First we briefly list all the switches, in alphabetical order, then we + describe the switches in more detail in functionally grouped sections. + + @menu + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + @end menu + + @table @code + @cindex @code{-b} (@code{gcc}) + @item -b @var{target} + Compile your program to run on @var{target}, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + @var{target} is not the same as your host system. + + @item -B@var{dir} + @cindex @code{-B} (@code{gcc}) + Load compiler executables (for example, @code{gnat1}, the Ada compiler) + from @var{dir} instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + @code{gcc} manual page for further details. You would normally use the + @code{-b} or @code{-V} switch instead. + + @item -c + @cindex @code{-c} (@code{gcc}) + Compile. Always use this switch when compiling Ada programs. + + Note: for some other languages when using @code{gcc}, notably in + the case of C and C++, it is possible to use + use @code{gcc} without a @code{-c} switch to + compile and link in one step. In the case of GNAT, you + cannot use this approach, because the binder must be run + and @code{gcc} cannot be used to run the GNAT binder. + + @item -g + @cindex @code{-g} (@code{gcc}) + Generate debugging information. This information is stored in the object + file and copied from there to the final executable file by the linker, + where it can be read by the debugger. You must use the + @code{-g} switch if you plan on using the debugger. + + @item -I@var{dir} + @cindex @code{-I} (@code{gcc}) + @cindex RTL + Direct GNAT to search the @var{dir} directory for source files needed by + the current compilation + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item -I- + @cindex @code{-I-} (@code{gcc}) + @cindex RTL + Except for the source file named in the command line, do not look for source files + in the directory containing the source file named in the command line + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item -o @var{file} + @cindex @code{-o} (@code{gcc}) + This switch is used in @code{gcc} to redirect the generated object file + and its associated ALI file. Beware of this switch with GNAT, because it may + cause the object file and ALI file to have different names which in turn + may confuse the binder and the linker. + + @item -O[@var{n}] + @cindex @code{-O} (@code{gcc}) + @var{n} controls the optimization level. + + @table @asis + @item n = 0 + No optimization, the default setting if no @code{-O} appears + + @item n = 1 + Normal optimization, the default if you specify @code{-O} without + an operand. + + @item n = 2 + Extensive optimization + + @item n = 3 + Extensive optimization with automatic inlining. This applies only to + inlining within a unit. For details on control of inter-unit inlining + see @xref{Subprogram Inlining Control}. + @end table + + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gcc}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -S + @cindex @code{-S} (@code{gcc}) + Used in place of @code{-c} to + cause the assembler source file to be + generated, using @file{.s} as the extension, + instead of the object file. + This may be useful if you need to examine the generated assembly code. + + @item -v + @cindex @code{-v} (@code{gcc}) + Show commands generated by the @code{gcc} driver. Normally used only for + debugging purposes or if you need to be sure what version of the + compiler you are executing. + + @item -V @var{ver} + @cindex @code{-V} (@code{gcc}) + Execute @var{ver} version of the compiler. This is the @code{gcc} + version, not the GNAT version. + + @item -gnata + Assertions enabled. @code{Pragma Assert} and @code{pragma Debug} to be + activated. + + @item -gnatA + Avoid processing @file{gnat.adc}. If a gnat.adc file is present, it will be ignored. + + @item -gnatb + Generate brief messages to @file{stderr} even if verbose mode set. + + @item -gnatc + Check syntax and semantics only (no code generation attempted). + + @item -gnatC + Compress debug information and external symbol name table entries. + + @item -gnatD + Output expanded source files for source level debugging. This switch + also suppress generation of cross-reference information (see -gnatx). + + @item -gnatec@var{path} + Specify a configuration pragma file. (see @ref{The Configuration Pragmas Files}) + + @item -gnatem@var{path} + Specify a mapping file. (see @ref{Units to Sources Mapping Files}) + + @item -gnatE + Full dynamic elaboration checks. + + @item -gnatf + Full errors. Multiple errors per line, all undefined references. + + @item -gnatF + Externals names are folded to all uppercase. + + @item -gnatg + Internal GNAT implementation mode. This should not be used for + applications programs, it is intended only for use by the compiler + and its run-time library. For documentation, see the GNAT sources. + + @item -gnatG + List generated expanded code in source form. + + @item -gnati@var{c} + Identifier character set + (@var{c}=1/2/3/4/8/9/p/f/n/w). + + @item -gnath + Output usage information. The output is written to @file{stdout}. + + @item -gnatk@var{n} + Limit file names to @var{n} (1-999) characters (@code{k} = krunch). + + @item -gnatl + Output full source listing with embedded error messages. + + @item -gnatm@var{n} + Limit number of detected errors to @var{n} (1-999). + + @item -gnatn + Activate inlining across unit boundaries for subprograms for which + pragma @code{inline} is specified. + + @item -gnatN + Activate front end inlining. + + @item -fno-inline + Suppresses all inlining, even if other optimization or inlining switches + are set. + + @item -fstack-check + Activates stack checking. See separate section on stack checking for + details of the use of this option. + + @item -gnato + Enable numeric overflow checking (which is not normally enabled by + default). Not that division by zero is a separate check that is not + controlled by this switch (division by zero checking is on by default). + + @item -gnatp + Suppress all checks. + + @item -gnatq + Don't quit; try semantics, even if parse errors. + + @item -gnatQ + Don't quit; generate @file{ali} and tree files even if illegalities. + + @item -gnatP + Enable polling. This is required on some systems (notably Windows NT) to + obtain asynchronous abort and asynchronous transfer of control capability. + See the description of pragma Polling in the GNAT Reference Manual for + full details. + + @item -gnatR[0/1/2/3][s] + Output representation information for declared types and objects. + + @item -gnats + Syntax check only. + + @item -gnatt + Tree output file to be generated. + + @item -gnatT nnn + Set time slice to specified number of microseconds + + @item -gnatu + List units for this compilation. + + @item -gnatU + Tag all error messages with the unique string "error:" + + @item -gnatv + Verbose mode. Full error output with source lines to @file{stdout}. + + @item -gnatV + Control level of validity checking. See separate section describing + this feature. + + @item -gnatwxxx@var{xxx} + Warning mode where + @var{xxx} is a string of options describing the exact warnings that + are enabled or disabled. See separate section on warning control. + + @item -gnatW@var{e} + Wide character encoding method + (@var{e}=n/h/u/s/e/8). + + @item -gnatx + Suppress generation of cross-reference information. + + @item -gnaty + Enable built-in style checks. See separate section describing this feature. + + @item -gnatz@var{m} + Distribution stub generation and compilation + (@var{m}=r/c for receiver/caller stubs). + + @item -gnat83 + Enforce Ada 83 restrictions. + + @item -pass-exit-codes + Catch exit codes from the compiler and use the most meaningful as + exit status. + @end table + + You may combine a sequence of GNAT switches into a single switch. For + example, the combined switch + + @cindex Combining GNAT switches + @smallexample + -gnatofi3 + @end smallexample + + @noindent + is equivalent to specifying the following sequence of switches: + + @smallexample + -gnato -gnatf -gnati3 + @end smallexample + + @noindent + The following restrictions apply to the combination of switches + in this manner: + + @itemize @bullet + @item + The switch @option{-gnatc} if combined with other switches must come + first in the string. + + @item + The switch @option{-gnats} if combined with other switches must come + first in the string. + + @item + Once a "y" appears in the string (that is a use of the @option{-gnaty} + switch), then all further characters in the switch are interpreted + as style modifiers (see description of @option{-gnaty}). + + @item + Once a "d" appears in the string (that is a use of the @option{-gnatd} + switch), then all further characters in the switch are interpreted + as debug flags (see description of @option{-gnatd}). + + @item + Once a "w" appears in the string (that is a use of the @option{-gnatw} + switch), then all further characters in the switch are interpreted + as warning mode modifiers (see description of @option{-gnatw}). + + @item + 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 + as validity checking options (see description of @option{-gnatV}). + + @end itemize + + @node Output and Error Message Control + @subsection Output and Error Message Control + @findex stderr + + @noindent + The standard default format for error messages is called "brief format." + Brief format messages are written to @file{stderr} (the standard error + file) and have the following form: + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:4:20: ";" should be "is" + @end smallexample + + @noindent + The first integer after the file name is the line number in the file, + and the second integer is the column number within the line. + @code{glide} can parse the error messages + and point to the referenced character. + The following switches provide control over the error message + format: + + @table @code + @item -gnatv + @cindex @option{-gnatv} (@code{gcc}) + @findex stdout + The v stands for verbose. + The effect of this setting is to write long-format error + messages to @file{stdout} (the standard output file. + The same program compiled with the + @option{-gnatv} switch would generate: + + @smallexample + @group + @cartouche + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + @end cartouche + @end group + @end smallexample + + @noindent + The vertical bar indicates the location of the error, and the @samp{>>>} + prefix can be used to search for error messages. When this switch is + used the only source lines output are those with errors. + + @item -gnatl + @cindex @option{-gnatl} (@code{gcc}) + The @code{l} stands for list. + This switch causes a full listing of + the file to be generated. The output might look as follows: + + @smallexample + @group + @cartouche + 1. procedure E is + 2. V : Integer; + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + 5. begin + 6. return Q + Q; + 7. end; + 8. begin + 9. V := X + X; + 10.end E; + @end cartouche + @end group + @end smallexample + + @noindent + @findex stderr + When you specify the @option{-gnatv} or @option{-gnatl} switches and + standard output is redirected, a brief summary is written to + @file{stderr} (standard error) giving the number of error messages and + warning messages generated. + + @item -gnatU + @cindex @option{-gnatU} (@code{gcc}) + This switch forces all error messages to be preceded by the unique + string "error:". This means that error messages take a few more + characters in space, but allows easy searching for and identification + of error messages. + + @item -gnatb + @cindex @option{-gnatb} (@code{gcc}) + The @code{b} stands for brief. + This switch causes GNAT to generate the + brief format error messages to @file{stderr} (the standard error + file) as well as the verbose + format message or full listing (which as usual is written to + @file{stdout} (the standard output file). + + @item -gnatm@var{n} + @cindex @option{-gnatm} (@code{gcc}) + The @code{m} stands for maximum. + @var{n} is a decimal integer in the + range of 1 to 999 and limits the number of error messages to be + generated. For example, using @option{-gnatm2} might yield + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:5:35: missing ".." + fatal error: maximum errors reached + compilation abandoned + @end smallexample + + @item -gnatf + @cindex @option{-gnatf} (@code{gcc}) + @cindex Error messages, suppressing + The @code{f} stands for full. + Normally, the compiler suppresses error messages that are likely to be + redundant. This switch causes all error + messages to be generated. In particular, in the case of + references to undefined variables. If a given variable is referenced + several times, the normal format of messages is + @smallexample + @iftex + @leftskip=.7cm + @end iftex + e.adb:7:07: "V" is undefined (more references follow) + @end smallexample + + @noindent + where the parenthetical comment warns that there are additional + references to the variable @code{V}. Compiling the same program with the + @option{-gnatf} switch yields + + @smallexample + e.adb:7:07: "V" is undefined + e.adb:8:07: "V" is undefined + e.adb:8:12: "V" is undefined + e.adb:8:16: "V" is undefined + e.adb:9:07: "V" is undefined + e.adb:9:12: "V" is undefined + @end smallexample + + @item -gnatq + @cindex @option{-gnatq} (@code{gcc}) + The @code{q} stands for quit (really "don't quit"). + In normal operation mode, the compiler first parses the program and + determines if there are any syntax errors. If there are, appropriate + error messages are generated and compilation is immediately terminated. + This switch tells + GNAT to continue with semantic analysis even if syntax errors have been + found. This may enable the detection of more errors in a single run. On + the other hand, the semantic analyzer is more likely to encounter some + internal fatal error when given a syntactically invalid tree. + + @item -gnatQ + In normal operation mode, the @file{ali} file is not generated if any + illegalities are detected in the program. The use of @option{-gnatQ} forces + generation of the @file{ali} file. This file is marked as being in + error, so it cannot be used for binding purposes, but it does contain + reasonably complete cross-reference information, and thus may be useful + for use by tools (e.g. semantic browsing tools or integrated development + environments) that are driven from the @file{ali} file. + + In addition, if @option{-gnatt} is also specified, then the tree file is + generated even if there are illegalities. It may be useful in this case + to also specify @option{-gnatq} to ensure that full semantic processing + occurs. The resulting tree file can be processed by ASIS, for the purpose + of providing partial information about illegal units, but if the error + causes the tree to be badly malformed, then ASIS may crash during the + analysis. + + @end table + + @noindent + In addition to error messages, which correspond to illegalities as defined + in the Ada 95 Reference Manual, the compiler detects two kinds of warning + situations. + + @cindex Warning messages + First, the compiler considers some constructs suspicious and generates a + warning message to alert you to a possible error. Second, if the + compiler detects a situation that is sure to raise an exception at + run time, it generates a warning message. The following shows an example + of warning messages: + @smallexample + @iftex + @leftskip=.2cm + @end iftex + e.adb:4:24: warning: creation of object may raise Storage_Error + e.adb:10:17: warning: static value out of range + e.adb:10:17: warning: "Constraint_Error" will be raised at run time + + @end smallexample + + @noindent + GNAT considers a large number of situations as appropriate + for the generation of warning messages. As always, warnings are not + definite indications of errors. For example, if you do an out-of-range + assignment with the deliberate intention of raising a + @code{Constraint_Error} exception, then the warning that may be + issued does not indicate an error. Some of the situations for which GNAT + issues warnings (at least some of the time) are given in the following + list, which is not necessarily complete. + + @itemize @bullet + @item + Possible infinitely recursive calls + + @item + Out-of-range values being assigned + + @item + Possible order of elaboration problems + + @item + Unreachable code + + @item + Fixed-point type declarations with a null range + + @item + Variables that are never assigned a value + + @item + Variables that are referenced before being initialized + + @item + Task entries with no corresponding accept statement + + @item + Duplicate accepts for the same task entry in a select + + @item + Objects that take too much storage + + @item + Unchecked conversion between types of differing sizes + + @item + Missing return statements along some execution paths in a function + + @item + Incorrect (unrecognized) pragmas + + @item + Incorrect external names + + @item + Allocation from empty storage pool + + @item + Potentially blocking operations in protected types + + @item + Suspicious parenthesization of expressions + + @item + Mismatching bounds in an aggregate + + @item + Attempt to return local value by reference + + @item + Unrecognized pragmas + + @item + Premature instantiation of a generic body + + @item + Attempt to pack aliased components + + @item + Out of bounds array subscripts + + @item + Wrong length on string assignment + + @item + Violations of style rules if style checking is enabled + + @item + Unused with clauses + + @item + Bit_Order usage that does not have any effect + + @item + Compile time biased rounding of floating-point constant + + @item + Standard.Duration used to resolve universal fixed expression + + @item + Dereference of possibly null value + + @item + Declaration that is likely to cause storage error + + @item + Internal GNAT unit with'ed by application unit + + @item + Values known to be out of range at compile time + + @item + Unreferenced labels and variables + + @item + Address overlays that could clobber memory + + @item + Unexpected initialization when address clause present + + @item + Bad alignment for address clause + + @item + Useless type conversions + + @item + Redundant assignment statements + + @item + Accidental hiding of name by child unit + + @item + Unreachable code + + @item + Access before elaboration detected at compile time + + @item + A range in a @code{for} loop that is known to be null or might be null + + @end itemize + + @noindent + The following switches are available to control the handling of + warning messages: + + @table @code + @item -gnatwa (activate all optional errors) + @cindex @option{-gnatwa} (@code{gcc}) + This switch activates most optional warning messages, see remaining list + in this section for details on optional warning messages that can be + individually controlled. The warnings that are not turned on by this + switch are @option{-gnatwb} (biased rounding), + @option{-gnatwd} (implicit dereferencing), + and @option{-gnatwh} (hiding). All other optional warnings are + turned on. + + @item -gnatwA (suppress all optional errors) + @cindex @option{-gnatwA} (@code{gcc}) + This switch suppresses all optional warning messages, see remaining list + in this section for details on optional warning messages that can be + individually controlled. + + @item -gnatwb (activate warnings on biased rounding) + @cindex @option{-gnatwb} (@code{gcc}) + @cindex Rounding, biased + @cindex Biased rounding + If a static floating-point expression has a value that is exactly half + way between two adjacent machine numbers, then the rules of Ada + (Ada Reference Manual, section 4.9(38)) require that this rounding + be done away from zero, even if the normal unbiased rounding rules + at run time would require rounding towards zero. This warning message + alerts you to such instances where compile-time rounding and run-time + rounding are not equivalent. If it is important to get proper run-time + rounding, then you can force this by making one of the operands into + a variable. The default is that such warnings are not generated. + Note that @option{-gnatwa} does not affect the setting of + this warning option. + + @item -gnatwB (suppress warnings on biased rounding) + @cindex @option{-gnatwB} (@code{gcc}) + This switch disables warnings on biased rounding. + + @item -gnatwc (activate warnings on conditionals) + @cindex @option{-gnatwc} (@code{gcc}) + @cindex Conditionals, constant + This switch activates warnings for conditional expressions used in + tests that are known to be True or False at compile time. The default + is that such warnings are not generated. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwC (suppress warnings on conditionals) + @cindex @option{-gnatwC} (@code{gcc}) + This switch suppresses warnings for conditional expressions used in + tests that are known to be True or False at compile time. + + @item -gnatwd (activate warnings on implicit dereferencing) + @cindex @option{-gnatwd} (@code{gcc}) + If this switch is set, then the use of a prefix of an access type + in an indexed component, slice, or selected component without an + explicit @code{.all} will generate a warning. With this warning + enabled, access checks occur only at points where an explicit + @code{.all} appears in the source code (assuming no warnings are + generated as a result of this switch). The default is that such + warnings are not generated. + Note that @option{-gnatwa} does not affect the setting of + this warning option. + + @item -gnatwD (suppress warnings on implicit dereferencing) + @cindex @option{-gnatwD} (@code{gcc}) + @cindex Implicit dereferencing + @cindex Dereferencing, implicit + This switch suppresses warnings for implicit deferences in + indexed components, slices, and selected components. + + @item -gnatwe (treat warnings as errors) + @cindex @option{-gnatwe} (@code{gcc}) + @cindex Warnings, treat as error + This switch causes warning messages to be treated as errors. + The warning string still appears, but the warning messages are counted + as errors, and prevent the generation of an object file. + + @item -gnatwf (activate warnings on unreferenced formals) + @cindex @option{-gnatwf} (@code{gcc}) + @cindex Formals, unreferenced + This switch causes a warning to be generated if a formal parameter + is not referenced in the body of the subprogram. This warning can + also be turned on using @option{-gnatwa} or @option{-gnatwu}. + + @item -gnatwF (suppress warnings on unreferenced formals) + @cindex @option{-gnatwF} (@code{gcc}) + This switch suppresses warnings for unreferenced formal + parameters. Note that the + combination @option{-gnatwu} followed by @option{-gnatwF} has the + effect of warning on unreferenced entities other than subprogram + formals. + + @item -gnatwh (activate warnings on hiding) + @cindex @option{-gnatwh} (@code{gcc}) + @cindex Hiding of Declarations + This switch activates warnings on hiding declarations. + A declaration is considered hiding + if it is for a non-overloadable entity, and it declares an entity with the + same name as some other entity that is directly or use-visible. The default + is that such warnings are not generated. + Note that @option{-gnatwa} does not affect the setting of this warning option. + + @item -gnatwH (suppress warnings on hiding) + @cindex @option{-gnatwH} (@code{gcc}) + This switch suppresses warnings on hiding declarations. + + @item -gnatwi (activate warnings on implementation units). + @cindex @option{-gnatwi} (@code{gcc}) + This switch activates warnings for a @code{with} of an internal GNAT + implementation unit, defined as any unit from the @code{Ada}, + @code{Interfaces}, @code{GNAT}, + or @code{System} + hierarchies that is not + documented in either the Ada Reference Manual or the GNAT + Programmer's Reference Manual. Such units are intended only + for internal implementation purposes and should not be @code{with}'ed + by user programs. The default is that such warnings are generated + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwI (disable warnings on implementation units). + @cindex @option{-gnatwI} (@code{gcc}) + This switch disables warnings for a @code{with} of an internal GNAT + implementation unit. + + @item -gnatwl (activate warnings on elaboration pragmas) + @cindex @option{-gnatwl} (@code{gcc}) + @cindex Elaboration, warnings + This switch activates warnings on missing pragma Elaborate_All statements. + See the section in this guide on elaboration checking for details on + when such pragma should be used. The default is that such warnings + are not generated. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwL (suppress warnings on elaboration pragmas) + @cindex @option{-gnatwL} (@code{gcc}) + This switch suppresses warnings on missing pragma Elaborate_All statements. + See the section in this guide on elaboration checking for details on + when such pragma should be used. + + @item -gnatwo (activate warnings on address clause overlays) + @cindex @option{-gnatwo} (@code{gcc}) + @cindex Address Clauses, warnings + This switch activates warnings for possibly unintended initialization + effects of defining address clauses that cause one variable to overlap + another. The default is that such warnings are generated. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwO (suppress warnings on address clause overlays) + @cindex @option{-gnatwO} (@code{gcc}) + This switch suppresses warnings on possibly unintended initialization + effects of defining address clauses that cause one variable to overlap + another. + + @item -gnatwp (activate warnings on ineffective pragma Inlines) + @cindex @option{-gnatwp} (@code{gcc}) + @cindex Inlining, warnings + This switch activates warnings for failure of front end inlining + (activated by @option{-gnatN}) to inline a particular call. There are + many reasons for not being able to inline a call, including most + commonly that the call is too complex to inline. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwP (suppress warnings on ineffective pragma Inlines) + @cindex @option{-gnatwP} (@code{gcc}) + This switch suppresses warnings on ineffective pragma Inlines. If the + inlining mechanism cannot inline a call, it will simply ignore the + request silently. + + @item -gnatwr (activate warnings on redundant constructs) + @cindex @option{-gnatwr} (@code{gcc}) + This switch activates warnings for redundant constructs. The following + is the current list of constructs regarded as redundant: + This warning can also be turned on using @option{-gnatwa}. + + @itemize @bullet + @item + Assignment of an item to itself. + @item + Type conversion that converts an expression to its own type. + @item + Use of the attribute @code{Base} where @code{typ'Base} is the same + as @code{typ}. + @item + Use of pragma @code{Pack} when all components are placed by a record + representation clause. + @end itemize + + @item -gnatwR (suppress warnings on redundant constructs) + @cindex @option{-gnatwR} (@code{gcc}) + This switch suppresses warnings for redundant constructs. + + @item -gnatws (suppress all warnings) + @cindex @option{-gnatws} (@code{gcc}) + This switch completely suppresses the + output of all warning messages from the GNAT front end. + Note that it does not suppress warnings from the @code{gcc} back end. + To suppress these back end warnings as well, use the switch @code{-w} + in addition to @option{-gnatws}. + + @item -gnatwu (activate warnings on unused entities) + @cindex @option{-gnatwu} (@code{gcc}) + This switch activates warnings to be generated for entities that + are defined but not referenced, and for units that are @code{with}'ed + and not + referenced. In the case of packages, a warning is also generated if + no entities in the package are referenced. This means that if the package + is referenced but the only references are in @code{use} + clauses or @code{renames} + declarations, a warning is still generated. A warning is also generated + for a generic package that is @code{with}'ed but never instantiated. + In the case where a package or subprogram body is compiled, and there + is a @code{with} on the corresponding spec + that is only referenced in the body, + a warning is also generated, noting that the + @code{with} can be moved to the body. The default is that + such warnings are not generated. + This switch also activates warnings on unreferenced formals + (it is includes the effect of @option{-gnatwf}). + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwU (suppress warnings on unused entities) + @cindex @option{-gnatwU} (@code{gcc}) + This switch suppresses warnings for unused entities and packages. + It also turns off warnings on unreferenced formals (and thus includes + the effect of @option{-gnatwF}). + + @noindent + A string of warning parameters can be used in the same parameter. For example: + + @smallexample + -gnatwaLe + @end smallexample + + @noindent + Would turn on all optional warnings except for elaboration pragma warnings, + and also specify that warnings should be treated as errors. + + @item -w + @cindex @code{-w} + This switch suppresses warnings from the @code{gcc} backend. It may be + used in conjunction with @option{-gnatws} to ensure that all warnings + are suppressed during the entire compilation process. + + @end table + + @node Debugging and Assertion Control + @subsection Debugging and Assertion Control + + @table @code + @item -gnata + @cindex @option{-gnata} (@code{gcc}) + @findex Assert + @findex Debug + @cindex Assertions + + @noindent + The pragmas @code{Assert} and @code{Debug} normally have no effect and + are ignored. This switch, where @samp{a} stands for assert, causes + @code{Assert} and @code{Debug} pragmas to be activated. + + The pragmas have the form: + + @smallexample + @group + @cartouche + @b{pragma} Assert (@var{Boolean-expression} [, + @var{static-string-expression}]) + @b{pragma} Debug (@var{procedure call}) + @end cartouche + @end group + @end smallexample + + @noindent + The @code{Assert} pragma causes @var{Boolean-expression} to be tested. + If the result is @code{True}, the pragma has no effect (other than + possible side effects from evaluating the expression). If the result is + @code{False}, the exception @code{Assert_Failure} declared in the package + @code{System.Assertions} is + raised (passing @var{static-string-expression}, if present, as the + message associated with the exception). If no string expression is + given the default is a string giving the file name and line number + of the pragma. + + The @code{Debug} pragma causes @var{procedure} to be called. Note that + @code{pragma Debug} may appear within a declaration sequence, allowing + debugging procedures to be called between declarations. + + @end table + + @node Validity Checking + @subsection Validity Checking + @findex Validity Checking + + @noindent + The Ada 95 Reference Manual has specific requirements for checking + for invalid values. In particular, RM 13.9.1 requires that the + evaluation of invalid values (for example from unchecked conversions), + not result in erroneous execution. In GNAT, the result of such an + evaluation in normal default mode is to either use the value + unmodified, or to raise Constraint_Error in those cases where use + of the unmodified value would cause erroneous execution. The cases + where unmodified values might lead to erroneous execution are case + statements (where a wild jump might result from an invalid value), + and subscripts on the left hand side (where memory corruption could + occur as a result of an invalid value). + + The @option{-gnatVx} switch allows more control over the validity checking + mode. The @code{x} argument here is a string of letters which control which + validity checks are performed in addition to the default checks described + above. + + @itemize @bullet + @item + @option{-gnatVc} Validity checks for copies + + The right hand side of assignments, and the initializing values of + object declarations are validity checked. + + @item + @option{-gnatVd} Default (RM) validity checks + + Some validity checks are done by default following normal Ada semantics + (RM 13.9.1 (9-11)). + A check is done in case statements that the expression is within the range + of the subtype. If it is not, Constraint_Error is raised. + For assignments to array components, a check is done that the expression used + as index is within the range. If it is not, Constraint_Error is raised. + Both these validity checks may be turned off using switch @option{-gnatVD}. + They are turned on by default. If @option{-gnatVD} is specified, a subsequent + switch @option{-gnatVd} will leave the checks turned on. + Switch @option{-gnatVD} should be used only if you are sure that all such + expressions have valid values. If you use this switch and invalid values + are present, then the program is erroneous, and wild jumps or memory + overwriting may occur. + + @item + @option{-gnatVi} Validity checks for @code{in} mode parameters + + Arguments for parameters of mode @code{in} are validity checked in function + and procedure calls at the point of call. + + @item + @option{-gnatVm} Validity checks for @code{in out} mode parameters + + Arguments for parameters of mode @code{in out} are validity checked in + procedure calls at the point of call. The @code{'m'} here stands for + modify, since this concerns parameters that can be modified by the call. + Note that there is no specific option to test @code{out} parameters, + but any reference within the subprogram will be tested in the usual + manner, and if an invalid value is copied back, any reference to it + will be subject to validity checking. + + @item + @option{-gnatVo} Validity checks for operator and attribute operands + + Arguments for predefined operators and attributes are validity checked. + This includes all operators in package @code{Standard}, + the shift operators defined as intrinsic in package @code{Interfaces} + and operands for attributes such as @code{Pos}. + + @item + @option{-gnatVr} Validity checks for function returns + + The expression in @code{return} statements in functions is validity + checked. + + @item + @option{-gnatVs} Validity checks for subscripts + + All subscripts expressions are checked for validity, whether they appear + on the right side or left side (in default mode only left side subscripts + are validity checked). + + @item + @option{-gnatVt} Validity checks for tests + + Expressions used as conditions in @code{if}, @code{while} or @code{exit} + statements are checked, as well as guard expressions in entry calls. + + @item + @option{-gnatVf} Validity checks for floating-point values + + In the absence of this switch, validity checking occurs only for discrete + values. If @option{-gnatVf} is specified, then validity checking also applies + for floating-point values, and NaN's and infinities are considered invalid, + as well as out of range values for constrained types. Note that this means + that standard @code{IEEE} infinity mode is not allowed. The exact contexts + in which floating-point values are checked depends on the setting of other + options. For example @option{-gnatVif} or @option{-gnatVfi} (the order does + not matter) specifies that floating-point parameters of mode @code{in} should + be validity checked. + + @item + @option{-gnatVa} All validity checks + + All the above validity checks are turned on. That is @option{-gnatVa} is + equivalent to @code{gnatVcdfimorst}. + + @item + @option{-gnatVn} No validity checks + + This switch turns off all validity checking, including the default checking + for case statements and left hand side subscripts. Note that the use of + the switch @option{-gnatp} supresses all run-time checks, including + validity checks, and thus implies @option{-gnatVn}. + + @end itemize + + The @option{-gnatV} switch may be followed by a string of letters to turn on + a series of validity checking options. For example, @option{-gnatVcr} specifies + that in addition to the default validity checking, copies and function + return expressions be validity checked. In order to make it easier to specify + a set of options, the upper case letters @code{CDFIMORST} may be used to turn + off the corresponding lower case option, so for example @option{-gnatVaM} turns + on all validity checking options except for checking of @code{in out} + procedure arguments. + + The specification of additional validity checking generates extra code (and + in the case of @option{-gnatva} the code expansion can be substantial. However, + these additional checks can be very useful in smoking out cases of + uninitialized variables, incorrect use of unchecked conversion, and other + errors leading to invalid values. The use of pragma @code{Initialize_Scalars} + is useful in conjunction with the extra validity checking, since this + ensures that wherever possible uninitialized variables have invalid values. + + See also the pragma @code{Validity_Checks} which allows modification of + the validity checking mode at the program source level, and also allows for + temporary disabling of validity checks. + + @node Style Checking + @subsection Style Checking + @findex Style checking + + @noindent + The -gnaty@var{x} switch causes the compiler to + enforce specified style rules. A limited set of style rules has been used + in writing the GNAT sources themselves. This switch allows user programs + to activate all or some of these checks. If the source program fails a + specified style check, an appropriate warning message is given, preceded by + the character sequence "(style)". + The string @var{x} is a sequence of letters or digits + indicating the particular style + checks to be performed. The following checks are defined: + + @table @code + @item 1-9 (specify indentation level) + If a digit from 1-9 appears in the string after @option{-gnaty} then proper + indentation is checked, with the digit indicating the indentation level + required. The general style of required indentation is as specified by + the examples in the Ada Reference Manual. Full line comments must be + aligned with the @code{--} starting on a column that is a multiple of + the alignment level. + + @item a (check attribute casing) + If the letter a appears in the string after @option{-gnaty} then + attribute names, including the case of keywords such as @code{digits} + used as attributes names, must be written in mixed case, that is, the + initial letter and any letter following an underscore must be uppercase. + All other letters must be lowercase. + + @item b (blanks not allowed at statement end) + If the letter b appears in the string after @option{-gnaty} then + trailing blanks are not allowed at the end of statements. The purpose of this + rule, together with h (no horizontal tabs), is to enforce a canonical format + for the use of blanks to separate source tokens. + + @item c (check comments) + If the letter c appears in the string after @option{-gnaty} then + comments must meet the following set of rules: + + @itemize @bullet + + @item + The "--" that starts the column must either start in column one, or else + at least one blank must precede this sequence. + + @item + Comments that follow other tokens on a line must have at least one blank + following the "--" at the start of the comment. + + @item + Full line comments must have two blanks following the "--" that starts + the comment, with the following exceptions. + + @item + A line consisting only of the "--" characters, possibly preceded by blanks + is permitted. + + @item + A comment starting with "--x" where x is a special character is permitted. + This alows proper processing of the output generated by specialized tools + including @code{gnatprep} (where --! is used) and the SPARK annnotation + language (where --# is used). For the purposes of this rule, a special + character is defined as being in one of the ASCII ranges + 16#21#..16#2F# or 16#3A#..16#3F#. + + @item + A line consisting entirely of minus signs, possibly preceded by blanks, is + permitted. This allows the construction of box comments where lines of minus + signs are used to form the top and bottom of the box. + + @item + If a comment starts and ends with "--" is permitted as long as at least + one blank follows the initial "--". Together with the preceding rule, + this allows the construction of box comments, as shown in the following + example: + @smallexample + --------------------------- + -- This is a box comment -- + -- with two text lines. -- + --------------------------- + @end smallexample + @end itemize + + @item e (check end/exit labels) + If the letter e appears in the string after @option{-gnaty} then + optional labels on @code{end} statements ending subprograms and on + @code{exit} statements exiting named loops, are required to be present. + + @item f (no form feeds or vertical tabs) + If the letter f appears in the string after @option{-gnaty} then + neither form feeds nor vertical tab characters are not permitted + in the source text. + + @item h (no horizontal tabs) + If the letter h appears in the string after @option{-gnaty} then + horizontal tab characters are not permitted in the source text. + Together with the b (no blanks at end of line) check, this + enforces a canonical form for the use of blanks to separate + source tokens. + + @item i (check if-then layout) + If the letter i appears in the string after @option{-gnaty}, + then the keyword @code{then} must appear either on the same + line as corresponding @code{if}, or on a line on its own, lined + up under the @code{if} with at least one non-blank line in between + containing all or part of the condition to be tested. + + @item k (check keyword casing) + If the letter k appears in the string after @option{-gnaty} then + all keywords must be in lower case (with the exception of keywords + such as @code{digits} used as attribute names to which this check + does not apply). + + @item l (check layout) + If the letter l appears in the string after @option{-gnaty} then + layout of statement and declaration constructs must follow the + recommendations in the Ada Reference Manual, as indicated by the + form of the syntax rules. For example an @code{else} keyword must + be lined up with the corresponding @code{if} keyword. + + There are two respects in which the style rule enforced by this check + option are more liberal than those in the Ada Reference Manual. First + in the case of record declarations, it is permissible to put the + @code{record} keyword on the same line as the @code{type} keyword, and + then the @code{end} in @code{end record} must line up under @code{type}. + For example, either of the following two layouts is acceptable: + + @smallexample + @group + @cartouche + @b{type} q @b{is record} + a : integer; + b : integer; + @b{end record}; + + @b{type} q @b{is} + @b{record} + a : integer; + b : integer; + @b{end record}; + @end cartouche + @end group + @end smallexample + + @noindent + Second, in the case of a block statement, a permitted alternative + is to put the block label on the same line as the @code{declare} or + @code{begin} keyword, and then line the @code{end} keyword up under + the block label. For example both the following are permitted: + + @smallexample + @group + @cartouche + Block : @b{declare} + A : Integer := 3; + @b{begin} + Proc (A, A); + @b{end} Block; + + Block : + @b{declare} + A : Integer := 3; + @b{begin} + Proc (A, A); + @b{end} Block; + @end cartouche + @end group + @end smallexample + + @noindent + The same alternative format is allowed for loops. For example, both of + the following are permitted: + + @smallexample + @group + @cartouche + Clear : @b{while} J < 10 @b{loop} + A (J) := 0; + @b{end loop} Clear; + + Clear : + @b{while} J < 10 @b{loop} + A (J) := 0; + @b{end loop} Clear; + @end cartouche + @end group + @end smallexample + + @item m (check maximum line length) + If the letter m appears in the string after @option{-gnaty} + then the length of source lines must not exceed 79 characters, including + any trailing blanks. The value of 79 allows convenient display on an + 80 character wide device or window, allowing for possible special + treatment of 80 character lines. + + @item Mnnn (set maximum line length) + If the sequence Mnnn, where nnn is a decimal number, appears in + the string after @option{-gnaty} then the length of lines must not exceed the + given value. + + @item n (check casing of entities in Standard) + If the letter n appears in the string + after @option{-gnaty} then any identifier from Standard must be cased + to match the presentation in the Ada Reference Manual (for example, + @code{Integer} and @code{ASCII.NUL}). + + @item o (check order of subprogram bodies) + If the letter o appears in the string + after @option{-gnaty} then all subprogram bodies in a given scope + (e.g. a package body) must be in alphabetical order. The ordering + rule uses normal Ada rules for comparing strings, ignoring casing + of letters, except that if there is a trailing numeric suffix, then + the value of this suffix is used in the ordering (e.g. Junk2 comes + before Junk10). + + @item p (check pragma casing) + If the letter p appears in the string after @option{-gnaty} then + pragma names must be written in mixed case, that is, the + initial letter and any letter following an underscore must be uppercase. + All other letters must be lowercase. + + @item r (check references) + If the letter r appears in the string after @option{-gnaty} + then all identifier references must be cased in the same way as the + corresponding declaration. No specific casing style is imposed on + identifiers. The only requirement is for consistency of references + with declarations. + + @item s (check separate specs) + If the letter s appears in the string after @option{-gnaty} then + separate declarations ("specs") are required for subprograms (a + body is not allowed to serve as its own declaration). The only + exception is that parameterless library level procedures are + not required to have a separate declaration. This exception covers + the most frequent form of main program procedures. + + @item t (check token spacing) + If the letter t appears in the string after @option{-gnaty} then + the following token spacing rules are enforced: + + @itemize @bullet + + @item + The keywords @code{abs} and @code{not} must be followed by a space. + + @item + The token @code{=>} must be surrounded by spaces. + + @item + The token @code{<>} must be preceded by a space or a left parenthesis. + + @item + Binary operators other than @code{**} must be surrounded by spaces. + There is no restriction on the layout of the @code{**} binary operator. + + @item + Colon must be surrounded by spaces. + + @item + Colon-equal (assignment) must be surrounded by spaces. + + @item + Comma must be the first non-blank character on the line, or be + immediately preceded by a non-blank character, and must be followed + by a space. + + @item + If the token preceding a left paren ends with a letter or digit, then + a space must separate the two tokens. + + @item + A right parenthesis must either be the first non-blank character on + a line, or it must be preceded by a non-blank character. + + @item + A semicolon must not be preceded by a space, and must not be followed by + a non-blank character. + + @item + A unary plus or minus may not be followed by a space. + + @item + A vertical bar must be surrounded by spaces. + @end itemize + + @noindent + In the above rules, appearing in column one is always permitted, that is, + counts as meeting either a requirement for a required preceding space, + or as meeting a requirement for no preceding space. + + Appearing at the end of a line is also always permitted, that is, counts + as meeting either a requirement for a following space, or as meeting + a requirement for no following space. + + @end table + + @noindent + If any of these style rules is violated, a message is generated giving + details on the violation. The initial characters of such messages are + always "(style)". Note that these messages are treated as warning + messages, so they normally do not prevent the generation of an object + file. The @option{-gnatwe} switch can be used to treat warning messages, + including style messages, as fatal errors. + + @noindent + The switch + @option{-gnaty} on its own (that is not followed by any letters or digits), + is equivalent to @code{gnaty3abcefhiklmprst}, that is all checking + options are enabled with + the exception of -gnatyo, + with an indentation level of 3. This is the standard + checking option that is used for the GNAT sources. + + @node Run-Time Checks + @subsection Run-Time Checks + @cindex Division by zero + @cindex Access before elaboration + @cindex Checks, division by zero + @cindex Checks, access before elaboration + + @noindent + If you compile with the default options, GNAT will insert many run-time + checks into the compiled code, including code that performs range + checking against constraints, but not arithmetic overflow checking for + integer operations (including division by zero) or checks for access + before elaboration on subprogram calls. All other run-time checks, as + required by the Ada 95 Reference Manual, are generated by default. + The following @code{gcc} switches refine this default behavior: + + @table @code + @item -gnatp + @cindex @option{-gnatp} (@code{gcc}) + @cindex Suppressing checks + @cindex Checks, suppressing + @findex Suppress + Suppress all run-time checks as though @code{pragma Suppress (all_checks}) + had been present in the source. Validity checks are also suppressed (in + other words @option{-gnatp} also implies @option{-gnatVn}. + Use this switch to improve the performance + of the code at the expense of safety in the presence of invalid data or + program bugs. + + @item -gnato + @cindex @option{-gnato} (@code{gcc}) + @cindex Overflow checks + @cindex Check, overflow + Enables overflow checking for integer operations. + This causes GNAT to generate slower and larger executable + programs by adding code to check for overflow (resulting in raising + @code{Constraint_Error} as required by standard Ada + semantics). These overflow checks correspond to situations in which + the true value of the result of an operation may be outside the base + range of the result type. The following example shows the distinction: + + @smallexample + X1 : Integer := Integer'Last; + X2 : Integer range 1 .. 5 := 5; + ... + X1 := X1 + 1; -- @option{-gnato} required to catch the Constraint_Error + X2 := X2 + 1; -- range check, @option{-gnato} has no effect here + @end smallexample + + @noindent + Here the first addition results in a value that is outside the base range + of Integer, and hence requires an overflow check for detection of the + constraint error. The second increment operation results in a violation + of the explicit range constraint, and such range checks are always + performed. Basically the compiler can assume that in the absence of + the @option{-gnato} switch that any value of type @code{xxx} is + in range of the base type of @code{xxx}. + + @findex Machine_Overflows + Note that the @option{-gnato} switch does not affect the code generated + for any floating-point operations; it applies only to integer + semantics). + For floating-point, GNAT has the @code{Machine_Overflows} + attribute set to @code{False} and the normal mode of operation is to + generate IEEE NaN and infinite values on overflow or invalid operations + (such as dividing 0.0 by 0.0). + + The reason that we distinguish overflow checking from other kinds of + range constraint checking is that a failure of an overflow check can + generate an incorrect value, but cannot cause erroneous behavior. This + is unlike the situation with a constraint check on an array subscript, + where failure to perform the check can result in random memory description, + or the range check on a case statement, where failure to perform the check + can cause a wild jump. + + Note again that @option{-gnato} is off by default, so overflow checking is + not performed in default mode. This means that out of the box, with the + default settings, GNAT does not do all the checks expected from the + language description in the Ada Reference Manual. If you want all constraint + checks to be performed, as described in this Manual, then you must + explicitly use the -gnato switch either on the @code{gnatmake} or + @code{gcc} command. + + @item -gnatE + @cindex @option{-gnatE} (@code{gcc}) + @cindex Elaboration checks + @cindex Check, elaboration + Enables dynamic checks for access-before-elaboration + on subprogram calls and generic instantiations. + For full details of the effect and use of this switch, + @xref{Compiling Using gcc}. + @end table + + @findex Unsuppress + @noindent + The setting of these switches only controls the default setting of the + checks. You may modify them using either @code{Suppress} (to remove + checks) or @code{Unsuppress} (to add back suppressed checks) pragmas in + the program source. + + @node Stack Overflow Checking + @subsection Stack Overflow Checking + @cindex Stack Overflow Checking + @cindex -fstack-check + + @noindent + For most operating systems, @code{gcc} does not perform stack overflow + checking by default. This means that if the main environment task or + some other task exceeds the available stack space, then unpredictable + behavior will occur. + + To activate stack checking, compile all units with the gcc option + @code{-fstack-check}. For example: + + @smallexample + gcc -c -fstack-check package1.adb + @end smallexample + + @noindent + Units compiled with this option will generate extra instructions to check + that any use of the stack (for procedure calls or for declaring local + variables in declare blocks) do not exceed the available stack space. + If the space is exceeded, then a @code{Storage_Error} exception is raised. + + For declared tasks, the stack size is always controlled by the size + given in an applicable @code{Storage_Size} pragma (or is set to + the default size if no pragma is used. + + For the environment task, the stack size depends on + system defaults and is unknown to the compiler. The stack + may even dynamically grow on some systems, precluding the + normal Ada semantics for stack overflow. In the worst case, + unbounded stack usage, causes unbounded stack expansion + resulting in the system running out of virtual memory. + + The stack checking may still work correctly if a fixed + size stack is allocated, but this cannot be guaranteed. + To ensure that a clean exception is signalled for stack + overflow, set the environment variable + @code{GNAT_STACK_LIMIT} to indicate the maximum + stack area that can be used, as in: + @cindex GNAT_STACK_LIMIT + + @smallexample + SET GNAT_STACK_LIMIT 1600 + @end smallexample + + @noindent + The limit is given in kilobytes, so the above declaration would + set the stack limit of the environment task to 1.6 megabytes. + Note that the only purpose of this usage is to limit the amount + of stack used by the environment task. If it is necessary to + increase the amount of stack for the environment task, then this + is an operating systems issue, and must be addressed with the + appropriate operating systems commands. + + @node Run-Time Control + @subsection Run-Time Control + + @table @code + @item -gnatT nnn + @cindex @option{-gnatT} (@code{gcc}) + @cindex Time Slicing + + @noindent + The @code{gnatT} switch can be used to specify the time-slicing value + to be used for task switching between equal priority tasks. The value + @code{nnn} is given in microseconds as a decimal integer. + + Setting the time-slicing value is only effective if the underlying thread + control system can accommodate time slicing. Check the documentation of + your operating system for details. Note that the time-slicing value can + also be set by use of pragma @code{Time_Slice} or by use of the + @code{t} switch in the gnatbind step. The pragma overrides a command + line argument if both are present, and the @code{t} switch for gnatbind + overrides both the pragma and the @code{gcc} command line switch. + @end table + + @node Using gcc for Syntax Checking + @subsection Using @code{gcc} for Syntax Checking + @table @code + @item -gnats + @cindex @option{-gnats} (@code{gcc}) + + @noindent + The @code{s} stands for syntax. + + Run GNAT in syntax checking only mode. For + example, the command + + @smallexample + $ gcc -c -gnats x.adb + @end smallexample + + @noindent + compiles file @file{x.adb} in syntax-check-only mode. You can check a + series of files in a single command + , and can use wild cards to specify such a group of files. + Note that you must specify the @code{-c} (compile + only) flag in addition to the @option{-gnats} flag. + . + + You may use other switches in conjunction with @option{-gnats}. In + particular, @option{-gnatl} and @option{-gnatv} are useful to control the + format of any generated error messages. + + The output is simply the error messages, if any. No object file or ALI + file is generated by a syntax-only compilation. Also, no units other + than the one specified are accessed. For example, if a unit @code{X} + @code{with}'s a unit @code{Y}, compiling unit @code{X} in syntax + check only mode does not access the source file containing unit + @code{Y}. + + @cindex Multiple units, syntax checking + Normally, GNAT allows only a single unit in a source file. However, this + restriction does not apply in syntax-check-only mode, and it is possible + to check a file containing multiple compilation units concatenated + together. This is primarily used by the @code{gnatchop} utility + (@pxref{Renaming Files Using gnatchop}). + @end table + + @node Using gcc for Semantic Checking + @subsection Using @code{gcc} for Semantic Checking + @table @code + @item -gnatc + @cindex @option{-gnatc} (@code{gcc}) + + @noindent + The @code{c} stands for check. + Causes the compiler to operate in semantic check mode, + with full checking for all illegalities specified in the + Ada 95 Reference Manual, but without generation of any object code + (no object file is generated). + + Because dependent files must be accessed, you must follow the GNAT + semantic restrictions on file structuring to operate in this mode: + + @itemize @bullet + @item + The needed source files must be accessible + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item + Each file must contain only one compilation unit. + + @item + The file name and unit name must match (@pxref{File Naming Rules}). + @end itemize + + The output consists of error messages as appropriate. No object file is + generated. An @file{ALI} file is generated for use in the context of + cross-reference tools, but this file is marked as not being suitable + for binding (since no object file is generated). + The checking corresponds exactly to the notion of + legality in the Ada 95 Reference Manual. + + Any unit can be compiled in semantics-checking-only mode, including + units that would not normally be compiled (subunits, + and specifications where a separate body is present). + @end table + + @node Compiling Ada 83 Programs + @subsection Compiling Ada 83 Programs + @table @code + @cindex Ada 83 compatibility + @item -gnat83 + @cindex @option{-gnat83} (@code{gcc}) + @cindex ACVC, Ada 83 tests + + @noindent + Although GNAT is primarily an Ada 95 compiler, it accepts this switch to + specify that an Ada 83 program is to be compiled in Ada83 mode. If you specify + this switch, GNAT rejects most Ada 95 extensions and applies Ada 83 semantics + where this can be done easily. + It is not possible to guarantee this switch does a perfect + job; for example, some subtle tests, such as are + found in earlier ACVC tests (that have been removed from the ACVC suite for Ada + 95), may not compile correctly. However, for most purposes, using + this switch should help to ensure that programs that compile correctly + under the @option{-gnat83} switch can be ported easily to an Ada 83 + compiler. This is the main use of the switch. + + With few exceptions (most notably the need to use @code{<>} on + @cindex Generic formal parameters + unconstrained generic formal parameters, the use of the new Ada 95 + keywords, and the use of packages + with optional bodies), it is not necessary to use the + @option{-gnat83} switch when compiling Ada 83 programs, because, with rare + exceptions, Ada 95 is upwardly compatible with Ada 83. This + means that a correct Ada 83 program is usually also a correct Ada 95 + program. + + @end table + + @node Character Set Control + @subsection Character Set Control + @table @code + @item -gnati@var{c} + @cindex @code{-gnati} (@code{gcc}) + + @noindent + Normally GNAT recognizes the Latin-1 character set in source program + identifiers, as described in the Ada 95 Reference Manual. + This switch causes + GNAT to recognize alternate character sets in identifiers. @var{c} is a + single character indicating the character set, as follows: + + @table @code + @item 1 + Latin-1 identifiers + + @item 2 + Latin-2 letters allowed in identifiers + + @item 3 + Latin-3 letters allowed in identifiers + + @item 4 + Latin-4 letters allowed in identifiers + + @item 5 + Latin-5 (Cyrillic) letters allowed in identifiers + + @item 9 + Latin-9 letters allowed in identifiers + + @item p + IBM PC letters (code page 437) allowed in identifiers + + @item 8 + IBM PC letters (code page 850) allowed in identifiers + + @item f + Full upper-half codes allowed in identifiers + + @item n + No upper-half codes allowed in identifiers + + @item w + Wide-character codes (that is, codes greater than 255) + allowed in identifiers + @end table + + @xref{Foreign Language Representation}, for full details on the + implementation of these character sets. + + @item -gnatW@var{e} + @cindex @code{-gnatW} (@code{gcc}) + Specify the method of encoding for wide characters. + @var{e} is one of the following: + + @table @code + + @item h + Hex encoding (brackets coding also recognized) + + @item u + Upper half encoding (brackets encoding also recognized) + + @item s + Shift/JIS encoding (brackets encoding also recognized) + + @item e + EUC encoding (brackets encoding also recognized) + + @item 8 + UTF-8 encoding (brackets encoding also recognized) + + @item b + Brackets encoding only (default value) + @end table + For full details on the these encoding + methods see @xref{Wide Character Encodings}. + Note that brackets coding is always accepted, even if one of the other + options is specified, so for example @option{-gnatW8} specifies that both + brackets and @code{UTF-8} encodings will be recognized. The units that are + with'ed directly or indirectly will be scanned using the specified + representation scheme, and so if one of the non-brackets scheme is + used, it must be used consistently throughout the program. However, + since brackets encoding is always recognized, it may be conveniently + used in standard libraries, allowing these libraries to be used with + any of the available coding schemes. + scheme. If no @option{-gnatW?} parameter is present, then the default + representation is Brackets encoding only. + + Note that the wide character representation that is specified (explicitly + or by default) for the main program also acts as the default encoding used + for Wide_Text_IO files if not specifically overridden by a WCEM form + parameter. + + @end table + @node File Naming Control + @subsection File Naming Control + + @table @code + @item -gnatk@var{n} + @cindex @option{-gnatk} (@code{gcc}) + Activates file name "krunching". @var{n}, a decimal integer in the range + 1-999, indicates the maximum allowable length of a file name (not + including the @file{.ads} or @file{.adb} extension). The default is not + to enable file name krunching. + + For the source file naming rules, @xref{File Naming Rules}. + @end table + + @node Subprogram Inlining Control + @subsection Subprogram Inlining Control + + @table @code + @item -gnatn + @cindex @option{-gnatn} (@code{gcc}) + The @code{n} here is intended to suggest the first syllable of the + word "inline". + GNAT recognizes and processes @code{Inline} pragmas. However, for the + inlining to actually occur, optimization must be enabled. To enable + inlining across unit boundaries, this is, inlining a call in one unit of + a subprogram declared in a @code{with}'ed unit, you must also specify + this switch. + In the absence of this switch, GNAT does not attempt + inlining across units and does not need to access the bodies of + subprograms for which @code{pragma Inline} is specified if they are not + in the current unit. + + If you specify this switch the compiler will access these bodies, + creating an extra source dependency for the resulting object file, and + where possible, the call will be inlined. + For further details on when inlining is possible + see @xref{Inlining of Subprograms}. + + @item -gnatN + @cindex @option{-gnatN} (@code{gcc}) + The front end inlining activated by this switch is generally more extensive, + and quite often more effective than the standard @option{-gnatn} inlining mode. + It will also generate additional dependencies. + + @end table + + @node Auxiliary Output Control + @subsection Auxiliary Output Control + + @table @code + @item -gnatt + @cindex @option{-gnatt} (@code{gcc}) + @cindex Writing internal trees + @cindex Internal trees, writing to file + Causes GNAT to write the internal tree for a unit to a file (with the + extension @file{.adt}. + This not normally required, but is used by separate analysis tools. + Typically + these tools do the necessary compilations automatically, so you should + not have to specify this switch in normal operation. + + @item -gnatu + @cindex @option{-gnatu} (@code{gcc}) + Print a list of units required by this compilation on @file{stdout}. + The listing includes all units on which the unit being compiled depends + either directly or indirectly. + + @item -pass-exit-codes + @cindex @code{-pass-exit-codes} (@code{gcc}) + If this switch is not used, the exit code returned by @code{gcc} when + compiling multiple files indicates whether all source files have + been successfully used to generate object files or not. + + When @code{-pass-exit-codes} is used, @code{gcc} exits with an extended + exit status and allows an integrated development environment to better + react to a compilation failure. Those exit status are: + + @table @asis + @item 5 + There was an error in at least one source file. + @item 3 + At least one source file did not generate an object file. + @item 2 + The compiler died unexpectedly (internal error for example). + @item 0 + An object file has been generated for every source file. + @end table + @end table + + @node Debugging Control + @subsection Debugging Control + + @table @code + @cindex Debugging options + @item -gnatd@var{x} + Activate internal debugging switches. @var{x} is a letter or digit, or + string of letters or digits, which specifies the type of debugging + outputs desired. Normally these are used only for internal development + or system debugging purposes. You can find full documentation for these + switches in the body of the @code{Debug} unit in the compiler source + file @file{debug.adb}. + + @item -gnatG + @cindex @option{-gnatG} (@code{gcc}) + This switch causes the compiler to generate auxiliary output containing + a pseudo-source listing of the generated expanded code. Like most Ada + compilers, GNAT works by first transforming the high level Ada code into + lower level constructs. For example, tasking operations are transformed + into calls to the tasking run-time routines. A unique capability of GNAT + is to list this expanded code in a form very close to normal Ada source. + This is very useful in understanding the implications of various Ada + usage on the efficiency of the generated code. There are many cases in + Ada (e.g. the use of controlled types), where simple Ada statements can + generate a lot of run-time code. By using @option{-gnatG} you can identify + these cases, and consider whether it may be desirable to modify the coding + approach to improve efficiency. + + The format of the output is very similar to standard Ada source, and is + easily understood by an Ada programmer. The following special syntactic + additions correspond to low level features used in the generated code that + do not have any exact analogies in pure Ada source form. The following + is a partial list of these special constructions. See the specification + of package @code{Sprint} in file @file{sprint.ads} for a full list. + + @table @code + @item new @var{xxx} [storage_pool = @var{yyy}] + Shows the storage pool being used for an allocator. + + @item at end @var{procedure-name}; + Shows the finalization (cleanup) procedure for a scope. + + @item (if @var{expr} then @var{expr} else @var{expr}) + Conditional expression equivalent to the @code{x?y:z} construction in C. + + @item @var{target}^(@var{source}) + A conversion with floating-point truncation instead of rounding. + + @item @var{target}?(@var{source}) + A conversion that bypasses normal Ada semantic checking. In particular + enumeration types and fixed-point types are treated simply as integers. + + @item @var{target}?^(@var{source}) + Combines the above two cases. + + @item @var{x} #/ @var{y} + @itemx @var{x} #mod @var{y} + @itemx @var{x} #* @var{y} + @itemx @var{x} #rem @var{y} + A division or multiplication of fixed-point values which are treated as + integers without any kind of scaling. + + @item free @var{expr} [storage_pool = @var{xxx}] + Shows the storage pool associated with a @code{free} statement. + + @item freeze @var{typename} [@var{actions}] + Shows the point at which @var{typename} is frozen, with possible + associated actions to be performed at the freeze point. + + @item reference @var{itype} + Reference (and hence definition) to internal type @var{itype}. + + @item @var{function-name}! (@var{arg}, @var{arg}, @var{arg}) + Intrinsic function call. + + @item @var{labelname} : label + Declaration of label @var{labelname}. + + @item @var{expr} && @var{expr} && @var{expr} ... && @var{expr} + A multiple concatenation (same effect as @var{expr} & @var{expr} & + @var{expr}, but handled more efficiently). + + @item [constraint_error] + Raise the @code{Constraint_Error} exception. + + @item @var{expression}'reference + A pointer to the result of evaluating @var{expression}. + + @item @var{target-type}!(@var{source-expression}) + An unchecked conversion of @var{source-expression} to @var{target-type}. + + @item [@var{numerator}/@var{denominator}] + Used to represent internal real literals (that) have no exact + representation in base 2-16 (for example, the result of compile time + evaluation of the expression 1.0/27.0). + + @item -gnatD + @cindex @option{-gnatD} (@code{gcc}) + This switch is used in conjunction with @option{-gnatG} to cause the expanded + source, as described above to be written to files with names + @file{xxx.dg}, where @file{xxx} is the normal file name, + for example, if the source file name is @file{hello.adb}, + then a file @file{hello.adb.dg} will be written. + The debugging information generated + by the @code{gcc} @code{-g} switch will refer to the generated + @file{xxx.dg} file. This allows you to do source level debugging using + the generated code which is sometimes useful for complex code, for example + to find out exactly which part of a complex construction raised an + exception. This switch also suppress generation of cross-reference + information (see -gnatx). + + @item -gnatC + @cindex @option{-gnatE} (@code{gcc}) + In the generated debugging information, and also in the case of long external + names, the compiler uses a compression mechanism if the name is very long. + This compression method uses a checksum, and avoids trouble on some operating + systems which have difficulty with very long names. The @option{-gnatC} switch + forces this compression approach to be used on all external names and names + in the debugging information tables. This reduces the size of the generated + executable, at the expense of making the naming scheme more complex. The + compression only affects the qualification of the name. Thus a name in + the source: + + @smallexample + Very_Long_Package.Very_Long_Inner_Package.Var + @end smallexample + + @noindent + would normally appear in these tables as: + + @smallexample + very_long_package__very_long_inner_package__var + @end smallexample + + @noindent + but if the @option{-gnatC} switch is used, then the name appears as + + @smallexample + XCb7e0c705__var + @end smallexample + + @noindent + Here b7e0c705 is a compressed encoding of the qualification prefix. + The GNAT Ada aware version of GDB understands these encoded prefixes, so if this + debugger is used, the encoding is largely hidden from the user of the compiler. + + @end table + + @item -gnatR[0|1|2|3][s] + @cindex @option{-gnatR} (@code{gcc}) + This switch controls output from the compiler of a listing showing + representation information for declared types and objects. For + @option{-gnatR0}, no information is output (equivalent to omitting + the @option{-gnatR} switch). For @option{-gnatR1} (which is the default, + so @option{-gnatR} with no parameter has the same effect), size and alignment + information is listed for declared array and record types. For + @option{-gnatR2}, size and alignment information is listed for all + expression information for values that are computed at run time for + variant records. These symbolic expressions have a mostly obvious + format with #n being used to represent the value of the n'th + discriminant. See source files @file{repinfo.ads/adb} in the + @code{GNAT} sources for full detalis on the format of @option{-gnatR3} + output. If the switch is followed by an s (e.g. @option{-gnatR2s}), then + the output is to a file with the name @file{file.rep} where + file is the name of the corresponding source file. + + @item -gnatx + @cindex @option{-gnatx} (@code{gcc}) + Normally the compiler generates full cross-referencing information in + the @file{ALI} file. This information is used by a number of tools, + including @code{gnatfind} and @code{gnatxref}. The -gnatx switch + suppresses this information. This saves some space and may slightly + speed up compilation, but means that these tools cannot be used. + @end table + + @node Units to Sources Mapping Files + @subsection Units to Sources Mapping Files + + @table @code + + @item -gnatem@var{path} + @cindex @option{-gnatem} (@code{gcc}) + A mapping file is a way to communicate to the compiler two mappings: + from unit names to file names (without any directory information) and from + file names to path names (with full directory information). These mappings + are used by the compiler to short-circuit the path search. + + A mapping file is a sequence of sets of three lines. In each set, + the first line is the unit name, in lower case, with "%s" appended for + specifications and "%b" appended for bodies; the second line is the file + name; and the third line is the path name. + + Example: + @smallexample + main%b + main.2.ada + /gnat/project1/sources/main.2.ada + @end smallexample + + When the switch @option{-gnatem} is specified, the compiler will create + in memory the two mappings from the specified file. If there is any problem + (non existent file, truncated file or duplicate entries), no mapping + will be created. + + Several @option{-gnatem} switches may be specified; however, only the last + one on the command line will be taken into account. + + When using a project file, @code{gnatmake} create a temporary mapping file + and communicates it to the compiler using this switch. + + @end table + + @node Search Paths and the Run-Time Library (RTL) + @section Search Paths and the Run-Time Library (RTL) + + @noindent + With the GNAT source-based library system, the compiler must be able to + find source files for units that are needed by the unit being compiled. + Search paths are used to guide this process. + + The compiler compiles one source file whose name must be given + explicitly on the command line. In other words, no searching is done + for this file. To find all other source files that are needed (the most + common being the specs of units), the compiler examines the following + directories, in the following order: + + @enumerate + @item + The directory containing the source file of the main unit being compiled + (the file name on the command line). + + @item + Each directory named by an @code{-I} switch given on the @code{gcc} + command line, in the order given. + + @item + @findex ADA_INCLUDE_PATH + Each of the directories listed in the value of the + @code{ADA_INCLUDE_PATH} environment variable. + Construct this value + exactly as the @code{PATH} environment variable: a list of directory + names separated by colons (semicolons when working with the NT version). + @item + The content of the "ada_source_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as the + GNAT Run Time Library (RTL) source files. + @ref{Installing an Ada Library} + @end enumerate + + @noindent + Specifying the switch @code{-I-} + inhibits the use of the directory + containing the source file named in the command line. You can still + have this directory on your search path, but in this case it must be + explicitly requested with a @code{-I} switch. + + Specifying the switch @code{-nostdinc} + inhibits the search of the default location for the GNAT Run Time + Library (RTL) source files. + + The compiler outputs its object files and ALI files in the current + working directory. + Caution: The object file can be redirected with the @code{-o} switch; + however, @code{gcc} and @code{gnat1} have not been coordinated on this + so the ALI file will not go to the right place. Therefore, you should + avoid using the @code{-o} switch. + + @findex System.IO + The packages @code{Ada}, @code{System}, and @code{Interfaces} and their + children make up the GNAT RTL, together with the simple @code{System.IO} + package used in the "Hello World" example. The sources for these units + are needed by the compiler and are kept together in one directory. Not + all of the bodies are needed, but all of the sources are kept together + anyway. In a normal installation, you need not specify these directory + names when compiling or binding. Either the environment variables or + the built-in defaults cause these files to be found. + + In addition to the language-defined hierarchies (System, Ada and + Interfaces), the GNAT distribution provides a fourth hierarchy, + consisting of child units of GNAT. This is a collection of generally + useful routines. See the GNAT Reference Manual for further details. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + + @node Order of Compilation Issues + @section Order of Compilation Issues + + @noindent + If, in our earlier example, there was a spec for the @code{hello} + procedure, it would be contained in the file @file{hello.ads}; yet this + file would not have to be explicitly compiled. This is the result of the + model we chose to implement library management. Some of the consequences + of this model are as follows: + + @itemize @bullet + @item + There is no point in compiling specs (except for package + specs with no bodies) because these are compiled as needed by clients. If + you attempt a useless compilation, you will receive an error message. + It is also useless to compile subunits because they are compiled as needed + by the parent. + + @item + There are no order of compilation requirements: performing a + compilation never obsoletes anything. The only way you can obsolete + something and require recompilations is to modify one of the + source files on which it depends. + + @item + There is no library as such, apart from the ALI files + (@pxref{The Ada Library Information Files}, for information on the format of these + files). For now we find it convenient to create separate ALI files, but + eventually the information therein may be incorporated into the object + file directly. + + @item + When you compile a unit, the source files for the specs of all units + that it @code{with}'s, all its subunits, and the bodies of any generics it + instantiates must be available (reachable by the search-paths mechanism + described above), or you will receive a fatal error message. + @end itemize + + @node Examples + @section Examples + + @noindent + The following are some typical Ada compilation command line examples: + + @table @code + @item $ gcc -c xyz.adb + Compile body in file @file{xyz.adb} with all default options. + + @item $ gcc -c -O2 -gnata xyz-def.adb + + Compile the child unit package in file @file{xyz-def.adb} with extensive + optimizations, and pragma @code{Assert}/@code{Debug} statements + enabled. + + @item $ gcc -c -gnatc abc-def.adb + Compile the subunit in file @file{abc-def.adb} in semantic-checking-only + mode. + @end table + + @node Binding Using gnatbind + @chapter Binding Using @code{gnatbind} + @findex gnatbind + + @menu + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + @end menu + + @noindent + This chapter describes the GNAT binder, @code{gnatbind}, which is used + to bind compiled GNAT objects. The @code{gnatbind} program performs + four separate functions: + + @enumerate + @item + Checks that a program is consistent, in accordance with the rules in + Chapter 10 of the Ada 95 Reference Manual. In particular, error + messages are generated if a program uses inconsistent versions of a + given unit. + + @item + Checks that an acceptable order of elaboration exists for the program + and issues an error message if it cannot find an order of elaboration + that satisfies the rules in Chapter 10 of the Ada 95 Language Manual. + + @item + Generates a main program incorporating the given elaboration order. + This program is a small Ada package (body and spec) that + must be subsequently compiled + using the GNAT compiler. The necessary compilation step is usually + performed automatically by @code{gnatlink}. The two most important + functions of this program + are to call the elaboration routines of units in an appropriate order + and to call the main program. + + @item + Determines the set of object files required by the given main program. + This information is output in the forms of comments in the generated program, + to be read by the @code{gnatlink} utility used to link the Ada application. + @end enumerate + + @node Running gnatbind + @section Running @code{gnatbind} + + @noindent + The form of the @code{gnatbind} command is + + @smallexample + $ gnatbind [@var{switches}] @var{mainprog}[.ali] [@var{switches}] + @end smallexample + + @noindent + where @var{mainprog}.adb is the Ada file containing the main program + unit body. If no switches are specified, @code{gnatbind} constructs an Ada + package in two files which names are + @file{b~@var{ada_main}.ads}, and @file{b~@var{ada_main}.adb}. + For example, if given the + parameter @samp{hello.ali}, for a main program contained in file + @file{hello.adb}, the binder output files would be @file{b~hello.ads} + and @file{b~hello.adb}. + + When doing consistency checking, the binder takes into consideration + any source files it can locate. For example, if the binder determines + that the given main program requires the package @code{Pack}, whose + @file{.ali} + file is @file{pack.ali} and whose corresponding source spec file is + @file{pack.ads}, it attempts to locate the source file @file{pack.ads} + (using the same search path conventions as previously described for the + @code{gcc} command). If it can locate this source file, it checks that + the time stamps + or source checksums of the source and its references to in @file{ali} files + match. In other words, any @file{ali} files that mentions this spec must have + resulted from compiling this version of the source file (or in the case + where the source checksums match, a version close enough that the + difference does not matter). + + @cindex Source files, use by binder + The effect of this consistency checking, which includes source files, is + that the binder ensures that the program is consistent with the latest + version of the source files that can be located at bind time. Editing a + source file without compiling files that depend on the source file cause + error messages to be generated by the binder. + + For example, suppose you have a main program @file{hello.adb} and a + package @code{P}, from file @file{p.ads} and you perform the following + steps: + + @enumerate + @item + Enter @code{gcc -c hello.adb} to compile the main program. + + @item + Enter @code{gcc -c p.ads} to compile package @code{P}. + + @item + Edit file @file{p.ads}. + + @item + Enter @code{gnatbind hello}. + @end enumerate + + At this point, the file @file{p.ali} contains an out-of-date time stamp + because the file @file{p.ads} has been edited. The attempt at binding + fails, and the binder generates the following error messages: + + @smallexample + error: "hello.adb" must be recompiled ("p.ads" has been modified) + error: "p.ads" has been modified and must be recompiled + @end smallexample + + @noindent + Now both files must be recompiled as indicated, and then the bind can + succeed, generating a main program. You need not normally be concerned + with the contents of this file, but it is similar to the following which + is the binder file generated for a simple "hello world" program. + + @smallexample + @iftex + @leftskip=0cm + @end iftex + -- The package is called Ada_Main unless this name is actually used + -- as a unit name in the partition, in which case some other unique + -- name is used. + + with System; + package ada_main is + + Elab_Final_Code : Integer; + pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code"); + + -- The main program saves the parameters (argument count, + -- argument values, environment pointer) in global variables + -- for later access by other units including + -- Ada.Command_Line. + + gnat_argc : Integer; + gnat_argv : System.Address; + gnat_envp : System.Address; + + -- The actual variables are stored in a library routine. This + -- is useful for some shared library situations, where there + -- are problems if variables are not in the library. + + pragma Import (C, gnat_argc); + pragma Import (C, gnat_argv); + pragma Import (C, gnat_envp); + + -- The exit status is similarly an external location + + gnat_exit_status : Integer; + pragma Import (C, gnat_exit_status); + + GNAT_Version : constant String := + "GNAT Version: 3.15w (20010315)"; + pragma Export (C, GNAT_Version, "__gnat_version"); + + -- This is the generated adafinal routine that performs + -- finalization at the end of execution. In the case where + -- Ada is the main program, this main program makes a call + -- to adafinal at program termination. + + procedure adafinal; + pragma Export (C, adafinal, "adafinal"); + + -- This is the generated adainit routine that performs + -- initialization at the start of execution. In the case + -- where Ada is the main program, this main program makes + -- a call to adainit at program startup. + + procedure adainit; + pragma Export (C, adainit, "adainit"); + + -- This routine is called at the start of execution. It is + -- a dummy routine that is used by the debugger to breakpoint + -- at the start of execution. + + procedure Break_Start; + pragma Import (C, Break_Start, "__gnat_break_start"); + + -- This is the actual generated main program (it would be + -- suppressed if the no main program switch were used). As + -- required by standard system conventions, this program has + -- the external name main. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer; + pragma Export (C, main, "main"); + + -- The following set of constants give the version + -- identification values for every unit in the bound + -- partition. This identification is computed from all + -- dependent semantic units, and corresponds to the + -- string that would be returned by use of the + -- Body_Version or Version attributes. + + type Version_32 is mod 2 ** 32; + u00001 : constant Version_32 := 16#7880BEB3#; + u00002 : constant Version_32 := 16#0D24CBD0#; + u00003 : constant Version_32 := 16#3283DBEB#; + u00004 : constant Version_32 := 16#2359F9ED#; + u00005 : constant Version_32 := 16#664FB847#; + u00006 : constant Version_32 := 16#68E803DF#; + u00007 : constant Version_32 := 16#5572E604#; + u00008 : constant Version_32 := 16#46B173D8#; + u00009 : constant Version_32 := 16#156A40CF#; + u00010 : constant Version_32 := 16#033DABE0#; + u00011 : constant Version_32 := 16#6AB38FEA#; + u00012 : constant Version_32 := 16#22B6217D#; + u00013 : constant Version_32 := 16#68A22947#; + u00014 : constant Version_32 := 16#18CC4A56#; + u00015 : constant Version_32 := 16#08258E1B#; + u00016 : constant Version_32 := 16#367D5222#; + u00017 : constant Version_32 := 16#20C9ECA4#; + u00018 : constant Version_32 := 16#50D32CB6#; + u00019 : constant Version_32 := 16#39A8BB77#; + u00020 : constant Version_32 := 16#5CF8FA2B#; + u00021 : constant Version_32 := 16#2F1EB794#; + u00022 : constant Version_32 := 16#31AB6444#; + u00023 : constant Version_32 := 16#1574B6E9#; + u00024 : constant Version_32 := 16#5109C189#; + u00025 : constant Version_32 := 16#56D770CD#; + u00026 : constant Version_32 := 16#02F9DE3D#; + u00027 : constant Version_32 := 16#08AB6B2C#; + u00028 : constant Version_32 := 16#3FA37670#; + u00029 : constant Version_32 := 16#476457A0#; + u00030 : constant Version_32 := 16#731E1B6E#; + u00031 : constant Version_32 := 16#23C2E789#; + u00032 : constant Version_32 := 16#0F1BD6A1#; + u00033 : constant Version_32 := 16#7C25DE96#; + u00034 : constant Version_32 := 16#39ADFFA2#; + u00035 : constant Version_32 := 16#571DE3E7#; + u00036 : constant Version_32 := 16#5EB646AB#; + u00037 : constant Version_32 := 16#4249379B#; + u00038 : constant Version_32 := 16#0357E00A#; + u00039 : constant Version_32 := 16#3784FB72#; + u00040 : constant Version_32 := 16#2E723019#; + u00041 : constant Version_32 := 16#623358EA#; + u00042 : constant Version_32 := 16#107F9465#; + u00043 : constant Version_32 := 16#6843F68A#; + u00044 : constant Version_32 := 16#63305874#; + u00045 : constant Version_32 := 16#31E56CE1#; + u00046 : constant Version_32 := 16#02917970#; + u00047 : constant Version_32 := 16#6CCBA70E#; + u00048 : constant Version_32 := 16#41CD4204#; + u00049 : constant Version_32 := 16#572E3F58#; + u00050 : constant Version_32 := 16#20729FF5#; + u00051 : constant Version_32 := 16#1D4F93E8#; + u00052 : constant Version_32 := 16#30B2EC3D#; + u00053 : constant Version_32 := 16#34054F96#; + u00054 : constant Version_32 := 16#5A199860#; + u00055 : constant Version_32 := 16#0E7F912B#; + u00056 : constant Version_32 := 16#5760634A#; + u00057 : constant Version_32 := 16#5D851835#; + + -- The following Export pragmas export the version numbers + -- with symbolic names ending in B (for body) or S + -- (for spec) so that they can be located in a link. The + -- information provided here is sufficient to track down + -- the exact versions of units used in a given build. + + pragma Export (C, u00001, "helloB"); + pragma Export (C, u00002, "system__standard_libraryB"); + pragma Export (C, u00003, "system__standard_libraryS"); + pragma Export (C, u00004, "adaS"); + pragma Export (C, u00005, "ada__text_ioB"); + pragma Export (C, u00006, "ada__text_ioS"); + pragma Export (C, u00007, "ada__exceptionsB"); + pragma Export (C, u00008, "ada__exceptionsS"); + pragma Export (C, u00009, "gnatS"); + pragma Export (C, u00010, "gnat__heap_sort_aB"); + pragma Export (C, u00011, "gnat__heap_sort_aS"); + pragma Export (C, u00012, "systemS"); + pragma Export (C, u00013, "system__exception_tableB"); + pragma Export (C, u00014, "system__exception_tableS"); + pragma Export (C, u00015, "gnat__htableB"); + pragma Export (C, u00016, "gnat__htableS"); + pragma Export (C, u00017, "system__exceptionsS"); + pragma Export (C, u00018, "system__machine_state_operationsB"); + pragma Export (C, u00019, "system__machine_state_operationsS"); + pragma Export (C, u00020, "system__machine_codeS"); + pragma Export (C, u00021, "system__storage_elementsB"); + pragma Export (C, u00022, "system__storage_elementsS"); + pragma Export (C, u00023, "system__secondary_stackB"); + pragma Export (C, u00024, "system__secondary_stackS"); + pragma Export (C, u00025, "system__parametersB"); + pragma Export (C, u00026, "system__parametersS"); + pragma Export (C, u00027, "system__soft_linksB"); + pragma Export (C, u00028, "system__soft_linksS"); + pragma Export (C, u00029, "system__stack_checkingB"); + pragma Export (C, u00030, "system__stack_checkingS"); + pragma Export (C, u00031, "system__tracebackB"); + pragma Export (C, u00032, "system__tracebackS"); + pragma Export (C, u00033, "ada__streamsS"); + pragma Export (C, u00034, "ada__tagsB"); + pragma Export (C, u00035, "ada__tagsS"); + pragma Export (C, u00036, "system__string_opsB"); + pragma Export (C, u00037, "system__string_opsS"); + pragma Export (C, u00038, "interfacesS"); + pragma Export (C, u00039, "interfaces__c_streamsB"); + pragma Export (C, u00040, "interfaces__c_streamsS"); + pragma Export (C, u00041, "system__file_ioB"); + pragma Export (C, u00042, "system__file_ioS"); + pragma Export (C, u00043, "ada__finalizationB"); + pragma Export (C, u00044, "ada__finalizationS"); + pragma Export (C, u00045, "system__finalization_rootB"); + pragma Export (C, u00046, "system__finalization_rootS"); + pragma Export (C, u00047, "system__finalization_implementationB"); + pragma Export (C, u00048, "system__finalization_implementationS"); + pragma Export (C, u00049, "system__string_ops_concat_3B"); + pragma Export (C, u00050, "system__string_ops_concat_3S"); + pragma Export (C, u00051, "system__stream_attributesB"); + pragma Export (C, u00052, "system__stream_attributesS"); + pragma Export (C, u00053, "ada__io_exceptionsS"); + pragma Export (C, u00054, "system__unsigned_typesS"); + pragma Export (C, u00055, "system__file_control_blockS"); + pragma Export (C, u00056, "ada__finalization__list_controllerB"); + pragma Export (C, u00057, "ada__finalization__list_controllerS"); + + -- BEGIN ELABORATION ORDER + -- ada (spec) + -- gnat (spec) + -- gnat.heap_sort_a (spec) + -- gnat.heap_sort_a (body) + -- gnat.htable (spec) + -- gnat.htable (body) + -- interfaces (spec) + -- system (spec) + -- system.machine_code (spec) + -- system.parameters (spec) + -- system.parameters (body) + -- interfaces.c_streams (spec) + -- interfaces.c_streams (body) + -- system.standard_library (spec) + -- ada.exceptions (spec) + -- system.exception_table (spec) + -- system.exception_table (body) + -- ada.io_exceptions (spec) + -- system.exceptions (spec) + -- system.storage_elements (spec) + -- system.storage_elements (body) + -- system.machine_state_operations (spec) + -- system.machine_state_operations (body) + -- system.secondary_stack (spec) + -- system.stack_checking (spec) + -- system.soft_links (spec) + -- system.soft_links (body) + -- system.stack_checking (body) + -- system.secondary_stack (body) + -- system.standard_library (body) + -- system.string_ops (spec) + -- system.string_ops (body) + -- ada.tags (spec) + -- ada.tags (body) + -- ada.streams (spec) + -- system.finalization_root (spec) + -- system.finalization_root (body) + -- system.string_ops_concat_3 (spec) + -- system.string_ops_concat_3 (body) + -- system.traceback (spec) + -- system.traceback (body) + -- ada.exceptions (body) + -- system.unsigned_types (spec) + -- system.stream_attributes (spec) + -- system.stream_attributes (body) + -- system.finalization_implementation (spec) + -- system.finalization_implementation (body) + -- ada.finalization (spec) + -- ada.finalization (body) + -- ada.finalization.list_controller (spec) + -- ada.finalization.list_controller (body) + -- system.file_control_block (spec) + -- system.file_io (spec) + -- system.file_io (body) + -- ada.text_io (spec) + -- ada.text_io (body) + -- hello (body) + -- END ELABORATION ORDER + + end ada_main; + + -- The following source file name pragmas allow the generated file + -- names to be unique for different main programs. They are needed + -- since the package name will always be Ada_Main. + + pragma Source_File_Name (ada_main, Spec_File_Name => "b~hello.ads"); + pragma Source_File_Name (ada_main, Body_File_Name => "b~hello.adb"); + + -- Generated package body for Ada_Main starts here + + package body ada_main is + + -- The actual finalization is performed by calling the + -- library routine in System.Standard_Library.Adafinal + + procedure Do_Finalize; + pragma Import (C, Do_Finalize, "system__standard_library__adafinal"); + + ------------- + -- adainit -- + ------------- + + @findex adainit + procedure adainit is + + -- These booleans are set to True once the associated unit has + -- been elaborated. It is also used to avoid elaborating the + -- same unit twice. + + E040 : Boolean; pragma Import (Ada, E040, "interfaces__c_streams_E"); + E008 : Boolean; pragma Import (Ada, E008, "ada__exceptions_E"); + E014 : Boolean; pragma Import (Ada, E014, "system__exception_table_E"); + E053 : Boolean; pragma Import (Ada, E053, "ada__io_exceptions_E"); + E017 : Boolean; pragma Import (Ada, E017, "system__exceptions_E"); + E024 : Boolean; pragma Import (Ada, E024, "system__secondary_stack_E"); + E030 : Boolean; pragma Import (Ada, E030, "system__stack_checking_E"); + E028 : Boolean; pragma Import (Ada, E028, "system__soft_links_E"); + E035 : Boolean; pragma Import (Ada, E035, "ada__tags_E"); + E033 : Boolean; pragma Import (Ada, E033, "ada__streams_E"); + E046 : Boolean; pragma Import (Ada, E046, "system__finalization_root_E"); + E048 : Boolean; pragma Import (Ada, E048, "system__finalization_implementation_E"); + E044 : Boolean; pragma Import (Ada, E044, "ada__finalization_E"); + E057 : Boolean; pragma Import (Ada, E057, "ada__finalization__list_controller_E"); + E055 : Boolean; pragma Import (Ada, E055, "system__file_control_block_E"); + E042 : Boolean; pragma Import (Ada, E042, "system__file_io_E"); + E006 : Boolean; pragma Import (Ada, E006, "ada__text_io_E"); + + -- Set_Globals is a library routine that stores away the + -- value of the indicated set of global values in global + -- variables within the library. + + procedure Set_Globals + (Main_Priority : Integer; + Time_Slice_Value : Integer; + WC_Encoding : Character; + Locking_Policy : Character; + Queuing_Policy : Character; + Task_Dispatching_Policy : Character; + Adafinal : System.Address; + Unreserve_All_Interrupts : Integer; + Exception_Tracebacks : Integer); + @findex __gnat_set_globals + pragma Import (C, Set_Globals, "__gnat_set_globals"); + + -- SDP_Table_Build is a library routine used to build the + -- exception tables. See unit Ada.Exceptions in files + -- a-except.ads/adb for full details of how zero cost + -- exception handling works. This procedure, the call to + -- it, and the two following tables are all omitted if the + -- build is in longjmp/setjump exception mode. + + @findex SDP_Table_Build + @findex Zero Cost Exceptions + procedure SDP_Table_Build + (SDP_Addresses : System.Address; + SDP_Count : Natural; + Elab_Addresses : System.Address; + Elab_Addr_Count : Natural); + pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build"); + + -- Table of Unit_Exception_Table addresses. Used for zero + -- cost exception handling to build the top level table. + + ST : aliased constant array (1 .. 23) of System.Address := ( + Hello'UET_Address, + Ada.Text_Io'UET_Address, + Ada.Exceptions'UET_Address, + Gnat.Heap_Sort_A'UET_Address, + System.Exception_Table'UET_Address, + System.Machine_State_Operations'UET_Address, + System.Secondary_Stack'UET_Address, + System.Parameters'UET_Address, + System.Soft_Links'UET_Address, + System.Stack_Checking'UET_Address, + System.Traceback'UET_Address, + Ada.Streams'UET_Address, + Ada.Tags'UET_Address, + System.String_Ops'UET_Address, + Interfaces.C_Streams'UET_Address, + System.File_Io'UET_Address, + Ada.Finalization'UET_Address, + System.Finalization_Root'UET_Address, + System.Finalization_Implementation'UET_Address, + System.String_Ops_Concat_3'UET_Address, + System.Stream_Attributes'UET_Address, + System.File_Control_Block'UET_Address, + Ada.Finalization.List_Controller'UET_Address); + + -- Table of addresses of elaboration routines. Used for + -- zero cost exception handling to make sure these + -- addresses are included in the top level procedure + -- address table. + + EA : aliased constant array (1 .. 23) of System.Address := ( + adainit'Code_Address, + Do_Finalize'Code_Address, + Ada.Exceptions'Elab_Spec'Address, + System.Exceptions'Elab_Spec'Address, + Interfaces.C_Streams'Elab_Spec'Address, + System.Exception_Table'Elab_Body'Address, + Ada.Io_Exceptions'Elab_Spec'Address, + System.Stack_Checking'Elab_Spec'Address, + System.Soft_Links'Elab_Body'Address, + System.Secondary_Stack'Elab_Body'Address, + Ada.Tags'Elab_Spec'Address, + Ada.Tags'Elab_Body'Address, + Ada.Streams'Elab_Spec'Address, + System.Finalization_Root'Elab_Spec'Address, + Ada.Exceptions'Elab_Body'Address, + System.Finalization_Implementation'Elab_Spec'Address, + System.Finalization_Implementation'Elab_Body'Address, + Ada.Finalization'Elab_Spec'Address, + Ada.Finalization.List_Controller'Elab_Spec'Address, + System.File_Control_Block'Elab_Spec'Address, + System.File_Io'Elab_Body'Address, + Ada.Text_Io'Elab_Spec'Address, + Ada.Text_Io'Elab_Body'Address); + + -- Start of processing for adainit + + begin + + -- Call SDP_Table_Build to build the top level procedure + -- table for zero cost exception handling (omitted in + -- longjmp/setjump mode). + + SDP_Table_Build (ST'Address, 23, EA'Address, 23); + + -- Call Set_Globals to record various information for + -- this partition. The values are derived by the binder + -- from information stored in the ali files by the compiler. + + @findex __gnat_set_globals + Set_Globals + (Main_Priority => -1, + -- Priority of main program, -1 if no pragma Priority used + + Time_Slice_Value => -1, + -- Time slice from Time_Slice pragma, -1 if none used + + WC_Encoding => 'b', + -- Wide_Character encoding used, default is brackets + + Locking_Policy => ' ', + -- Locking_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Queuing_Policy => ' ', + -- Queuing_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Task_Dispatching_Policy => ' ', + -- Task_Dispatching_Policy used, default of space means + -- not specified, otherwise first character of the + -- policy name. + + Adafinal => System.Null_Address, + -- Address of Adafinal routine, not used anymore + + Unreserve_All_Interrupts => 0, + -- Set true if pragma Unreserve_All_Interrupts was used + + Exception_Tracebacks => 0); + -- Indicates if exception tracebacks are enabled + + Elab_Final_Code := 1; + + -- Now we have the elaboration calls for all units in the partition. + -- The Elab_Spec and Elab_Body attributes generate references to the + -- implicit elaboration procedures generated by the compiler for + -- each unit that requires elaboration. + + if not E040 then + Interfaces.C_Streams'Elab_Spec; + end if; + E040 := True; + if not E008 then + Ada.Exceptions'Elab_Spec; + end if; + if not E014 then + System.Exception_Table'Elab_Body; + E014 := True; + end if; + if not E053 then + Ada.Io_Exceptions'Elab_Spec; + E053 := True; + end if; + if not E017 then + System.Exceptions'Elab_Spec; + E017 := True; + end if; + if not E030 then + System.Stack_Checking'Elab_Spec; + end if; + if not E028 then + System.Soft_Links'Elab_Body; + E028 := True; + end if; + E030 := True; + if not E024 then + System.Secondary_Stack'Elab_Body; + E024 := True; + end if; + if not E035 then + Ada.Tags'Elab_Spec; + end if; + if not E035 then + Ada.Tags'Elab_Body; + E035 := True; + end if; + if not E033 then + Ada.Streams'Elab_Spec; + E033 := True; + end if; + if not E046 then + System.Finalization_Root'Elab_Spec; + end if; + E046 := True; + if not E008 then + Ada.Exceptions'Elab_Body; + E008 := True; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Spec; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Body; + E048 := True; + end if; + if not E044 then + Ada.Finalization'Elab_Spec; + end if; + E044 := True; + if not E057 then + Ada.Finalization.List_Controller'Elab_Spec; + end if; + E057 := True; + if not E055 then + System.File_Control_Block'Elab_Spec; + E055 := True; + end if; + if not E042 then + System.File_Io'Elab_Body; + E042 := True; + end if; + if not E006 then + Ada.Text_Io'Elab_Spec; + end if; + if not E006 then + Ada.Text_Io'Elab_Body; + E006 := True; + end if; + + Elab_Final_Code := 0; + end adainit; + + -------------- + -- adafinal -- + -------------- + + @findex adafinal + procedure adafinal is + begin + Do_Finalize; + end adafinal; + + ---------- + -- main -- + ---------- + + -- main is actually a function, as in the ANSI C standard, + -- defined to return the exit status. The three parameters + -- are the argument count, argument values and environment + -- pointer. + + @findex Main Program + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer + is + -- The initialize routine performs low level system + -- initialization using a standard library routine which + -- sets up signal handling and performs any other + -- required setup. The routine can be found in file + -- a-init.c. + + @findex __gnat_initialize + procedure initialize; + pragma Import (C, initialize, "__gnat_initialize"); + + -- The finalize routine performs low level system + -- finalization using a standard library routine. The + -- routine is found in file a-final.c and in the standard + -- distribution is a dummy routine that does nothing, so + -- really this is a hook for special user finalization. + + @findex __gnat_finalize + procedure finalize; + pragma Import (C, finalize, "__gnat_finalize"); + + -- We get to the main program of the partition by using + -- pragma Import because if we try to with the unit and + -- call it Ada style, then not only do we waste time + -- recompiling it, but also, we don't really know the right + -- switches (e.g. identifier character set) to be used + -- to compile it. + + procedure Ada_Main_Program; + pragma Import (Ada, Ada_Main_Program, "_ada_hello"); + + -- Start of processing for main + + begin + -- Save global variables + + gnat_argc := argc; + gnat_argv := argv; + gnat_envp := envp; + + -- Call low level system initialization + + Initialize; + + -- Call our generated Ada initialization routine + + adainit; + + -- This is the point at which we want the debugger to get + -- control + + Break_Start; + + -- Now we call the main program of the partition + + Ada_Main_Program; + + -- Perform Ada finalization + + adafinal; + + -- Perform low level system finalization + + Finalize; + + -- Return the proper exit status + return (gnat_exit_status); + end; + + -- This section is entirely comments, so it has no effect on the + -- compilation of the Ada_Main package. It provides the list of + -- object files and linker options, as well as some standard + -- libraries needed for the link. The gnatlink utility parses + -- this b~hello.adb file to read these comment lines to generate + -- the appropriate command line arguments for the call to the + -- system linker. The BEGIN/END lines are used for sentinels for + -- this parsing operation. + + -- The exact file names will of course depend on the environment, + -- host/target and location of files on the host system. + + @findex Object file list + -- BEGIN Object file/option list + -- ./hello.o + -- -L./ + -- -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/ + -- /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a + -- END Object file/option list + + end ada_main; + + @end smallexample + + @noindent + The Ada code in the above example is exactly what is generated by the + binder. We have added comments to more clearly indicate the function + of each part of the generated @code{Ada_Main} package. + + The code is standard Ada in all respects, and can be processed by any + tools that handle Ada. In particular, it is possible to use the debugger + in Ada mode to debug the generated Ada_Main package. For example, suppose + that for reasons that you do not understand, your program is blowing up + during elaboration of the body of @code{Ada.Text_IO}. To chase this bug + down, you can place a breakpoint on the call: + + @smallexample + Ada.Text_Io'Elab_Body; + @end smallexample + + @noindent + and trace the elaboration routine for this package to find out where + the problem might be (more usually of course you would be debugging + elaboration code in your own application). + + @node Generating the Binder Program in C + @section Generating the Binder Program in C + @noindent + In most normal usage, the default mode of @code{gnatbind} which is to + generate the main package in Ada, as described in the previous section. + In particular, this means that any Ada programmer can read and understand + the generated main program. It can also be debugged just like any other + Ada code provided the @code{-g} switch is used for @code{gnatbind} + and @code{gnatlink}. + + However for some purposes it may be convenient to generate the main + program in C rather than Ada. This may for example be helpful when you + are generating a mixed language program with the main program in C. The + GNAT compiler itself is an example. The use of the @code{-C} switch + for both @code{gnatbind} and @code{gnatlink} will cause the program to + be generated in C (and compiled using the gnu C compiler). The + following shows the C code generated for the same "Hello World" + program: + + @smallexample + + #ifdef __STDC__ + #define PARAMS(paramlist) paramlist + #else + #define PARAMS(paramlist) () + #endif + + extern void __gnat_set_globals + PARAMS ((int, int, int, int, int, int, + void (*) PARAMS ((void)), int, int)); + extern void adafinal PARAMS ((void)); + extern void adainit PARAMS ((void)); + extern void system__standard_library__adafinal PARAMS ((void)); + extern int main PARAMS ((int, char **, char **)); + extern void exit PARAMS ((int)); + extern void __gnat_break_start PARAMS ((void)); + extern void _ada_hello PARAMS ((void)); + extern void __gnat_initialize PARAMS ((void)); + extern void __gnat_finalize PARAMS ((void)); + + extern void ada__exceptions___elabs PARAMS ((void)); + extern void system__exceptions___elabs PARAMS ((void)); + extern void interfaces__c_streams___elabs PARAMS ((void)); + extern void system__exception_table___elabb PARAMS ((void)); + extern void ada__io_exceptions___elabs PARAMS ((void)); + extern void system__stack_checking___elabs PARAMS ((void)); + extern void system__soft_links___elabb PARAMS ((void)); + extern void system__secondary_stack___elabb PARAMS ((void)); + extern void ada__tags___elabs PARAMS ((void)); + extern void ada__tags___elabb PARAMS ((void)); + extern void ada__streams___elabs PARAMS ((void)); + extern void system__finalization_root___elabs PARAMS ((void)); + extern void ada__exceptions___elabb PARAMS ((void)); + extern void system__finalization_implementation___elabs PARAMS ((void)); + extern void system__finalization_implementation___elabb PARAMS ((void)); + extern void ada__finalization___elabs PARAMS ((void)); + extern void ada__finalization__list_controller___elabs PARAMS ((void)); + extern void system__file_control_block___elabs PARAMS ((void)); + extern void system__file_io___elabb PARAMS ((void)); + extern void ada__text_io___elabs PARAMS ((void)); + extern void ada__text_io___elabb PARAMS ((void)); + + extern int __gnat_inside_elab_final_code; + + extern int gnat_argc; + extern char **gnat_argv; + extern char **gnat_envp; + extern int gnat_exit_status; + + char __gnat_version[] = "GNAT Version: 3.15w (20010315)"; + void adafinal () @{ + system__standard_library__adafinal (); + @} + + void adainit () + @{ + extern char ada__exceptions_E; + extern char system__exceptions_E; + extern char interfaces__c_streams_E; + extern char system__exception_table_E; + extern char ada__io_exceptions_E; + extern char system__secondary_stack_E; + extern char system__stack_checking_E; + extern char system__soft_links_E; + extern char ada__tags_E; + extern char ada__streams_E; + extern char system__finalization_root_E; + extern char system__finalization_implementation_E; + extern char ada__finalization_E; + extern char ada__finalization__list_controller_E; + extern char system__file_control_block_E; + extern char system__file_io_E; + extern char ada__text_io_E; + + extern void *__gnat_hello__SDP; + extern void *__gnat_ada__text_io__SDP; + extern void *__gnat_ada__exceptions__SDP; + extern void *__gnat_gnat__heap_sort_a__SDP; + extern void *__gnat_system__exception_table__SDP; + extern void *__gnat_system__machine_state_operations__SDP; + extern void *__gnat_system__secondary_stack__SDP; + extern void *__gnat_system__parameters__SDP; + extern void *__gnat_system__soft_links__SDP; + extern void *__gnat_system__stack_checking__SDP; + extern void *__gnat_system__traceback__SDP; + extern void *__gnat_ada__streams__SDP; + extern void *__gnat_ada__tags__SDP; + extern void *__gnat_system__string_ops__SDP; + extern void *__gnat_interfaces__c_streams__SDP; + extern void *__gnat_system__file_io__SDP; + extern void *__gnat_ada__finalization__SDP; + extern void *__gnat_system__finalization_root__SDP; + extern void *__gnat_system__finalization_implementation__SDP; + extern void *__gnat_system__string_ops_concat_3__SDP; + extern void *__gnat_system__stream_attributes__SDP; + extern void *__gnat_system__file_control_block__SDP; + extern void *__gnat_ada__finalization__list_controller__SDP; + + void **st[23] = @{ + &__gnat_hello__SDP, + &__gnat_ada__text_io__SDP, + &__gnat_ada__exceptions__SDP, + &__gnat_gnat__heap_sort_a__SDP, + &__gnat_system__exception_table__SDP, + &__gnat_system__machine_state_operations__SDP, + &__gnat_system__secondary_stack__SDP, + &__gnat_system__parameters__SDP, + &__gnat_system__soft_links__SDP, + &__gnat_system__stack_checking__SDP, + &__gnat_system__traceback__SDP, + &__gnat_ada__streams__SDP, + &__gnat_ada__tags__SDP, + &__gnat_system__string_ops__SDP, + &__gnat_interfaces__c_streams__SDP, + &__gnat_system__file_io__SDP, + &__gnat_ada__finalization__SDP, + &__gnat_system__finalization_root__SDP, + &__gnat_system__finalization_implementation__SDP, + &__gnat_system__string_ops_concat_3__SDP, + &__gnat_system__stream_attributes__SDP, + &__gnat_system__file_control_block__SDP, + &__gnat_ada__finalization__list_controller__SDP@}; + + extern void ada__exceptions___elabs (); + extern void system__exceptions___elabs (); + extern void interfaces__c_streams___elabs (); + extern void system__exception_table___elabb (); + extern void ada__io_exceptions___elabs (); + extern void system__stack_checking___elabs (); + extern void system__soft_links___elabb (); + extern void system__secondary_stack___elabb (); + extern void ada__tags___elabs (); + extern void ada__tags___elabb (); + extern void ada__streams___elabs (); + extern void system__finalization_root___elabs (); + extern void ada__exceptions___elabb (); + extern void system__finalization_implementation___elabs (); + extern void system__finalization_implementation___elabb (); + extern void ada__finalization___elabs (); + extern void ada__finalization__list_controller___elabs (); + extern void system__file_control_block___elabs (); + extern void system__file_io___elabb (); + extern void ada__text_io___elabs (); + extern void ada__text_io___elabb (); + + void (*ea[23]) () = @{ + adainit, + system__standard_library__adafinal, + ada__exceptions___elabs, + system__exceptions___elabs, + interfaces__c_streams___elabs, + system__exception_table___elabb, + ada__io_exceptions___elabs, + system__stack_checking___elabs, + system__soft_links___elabb, + system__secondary_stack___elabb, + ada__tags___elabs, + ada__tags___elabb, + ada__streams___elabs, + system__finalization_root___elabs, + ada__exceptions___elabb, + system__finalization_implementation___elabs, + system__finalization_implementation___elabb, + ada__finalization___elabs, + ada__finalization__list_controller___elabs, + system__file_control_block___elabs, + system__file_io___elabb, + ada__text_io___elabs, + ada__text_io___elabb@}; + + __gnat_SDP_Table_Build (&st, 23, ea, 23); + __gnat_set_globals ( + -1, /* Main_Priority */ + -1, /* Time_Slice_Value */ + 'b', /* WC_Encoding */ + ' ', /* Locking_Policy */ + ' ', /* Queuing_Policy */ + ' ', /* Tasking_Dispatching_Policy */ + 0, /* Finalization routine address, not used anymore */ + 0, /* Unreserve_All_Interrupts */ + 0); /* Exception_Tracebacks */ + + __gnat_inside_elab_final_code = 1; + + if (ada__exceptions_E == 0) @{ + ada__exceptions___elabs (); + @} + if (system__exceptions_E == 0) @{ + system__exceptions___elabs (); + system__exceptions_E++; + @} + if (interfaces__c_streams_E == 0) @{ + interfaces__c_streams___elabs (); + @} + interfaces__c_streams_E = 1; + if (system__exception_table_E == 0) @{ + system__exception_table___elabb (); + system__exception_table_E++; + @} + if (ada__io_exceptions_E == 0) @{ + ada__io_exceptions___elabs (); + ada__io_exceptions_E++; + @} + if (system__stack_checking_E == 0) @{ + system__stack_checking___elabs (); + @} + if (system__soft_links_E == 0) @{ + system__soft_links___elabb (); + system__soft_links_E++; + @} + system__stack_checking_E = 1; + if (system__secondary_stack_E == 0) @{ + system__secondary_stack___elabb (); + system__secondary_stack_E++; + @} + if (ada__tags_E == 0) @{ + ada__tags___elabs (); + @} + if (ada__tags_E == 0) @{ + ada__tags___elabb (); + ada__tags_E++; + @} + if (ada__streams_E == 0) @{ + ada__streams___elabs (); + ada__streams_E++; + @} + if (system__finalization_root_E == 0) @{ + system__finalization_root___elabs (); + @} + system__finalization_root_E = 1; + if (ada__exceptions_E == 0) @{ + ada__exceptions___elabb (); + ada__exceptions_E++; + @} + if (system__finalization_implementation_E == 0) @{ + system__finalization_implementation___elabs (); + @} + if (system__finalization_implementation_E == 0) @{ + system__finalization_implementation___elabb (); + system__finalization_implementation_E++; + @} + if (ada__finalization_E == 0) @{ + ada__finalization___elabs (); + @} + ada__finalization_E = 1; + if (ada__finalization__list_controller_E == 0) @{ + ada__finalization__list_controller___elabs (); + @} + ada__finalization__list_controller_E = 1; + if (system__file_control_block_E == 0) @{ + system__file_control_block___elabs (); + system__file_control_block_E++; + @} + if (system__file_io_E == 0) @{ + system__file_io___elabb (); + system__file_io_E++; + @} + if (ada__text_io_E == 0) @{ + ada__text_io___elabs (); + @} + if (ada__text_io_E == 0) @{ + ada__text_io___elabb (); + ada__text_io_E++; + @} + + __gnat_inside_elab_final_code = 0; + @} + int main (argc, argv, envp) + int argc; + char **argv; + char **envp; + @{ + gnat_argc = argc; + gnat_argv = argv; + gnat_envp = envp; + + __gnat_initialize (); + adainit (); + __gnat_break_start (); + + _ada_hello (); + + system__standard_library__adafinal (); + __gnat_finalize (); + exit (gnat_exit_status); + @} + unsigned helloB = 0x7880BEB3; + unsigned system__standard_libraryB = 0x0D24CBD0; + unsigned system__standard_libraryS = 0x3283DBEB; + unsigned adaS = 0x2359F9ED; + unsigned ada__text_ioB = 0x47C85FC4; + unsigned ada__text_ioS = 0x496FE45C; + unsigned ada__exceptionsB = 0x74F50187; + unsigned ada__exceptionsS = 0x6736945B; + unsigned gnatS = 0x156A40CF; + unsigned gnat__heap_sort_aB = 0x033DABE0; + unsigned gnat__heap_sort_aS = 0x6AB38FEA; + unsigned systemS = 0x0331C6FE; + unsigned system__exceptionsS = 0x20C9ECA4; + unsigned system__exception_tableB = 0x68A22947; + unsigned system__exception_tableS = 0x394BADD5; + unsigned gnat__htableB = 0x08258E1B; + unsigned gnat__htableS = 0x367D5222; + unsigned system__machine_state_operationsB = 0x4F3B7492; + unsigned system__machine_state_operationsS = 0x182F5CF4; + unsigned system__storage_elementsB = 0x2F1EB794; + unsigned system__storage_elementsS = 0x102C83C7; + unsigned system__secondary_stackB = 0x1574B6E9; + unsigned system__secondary_stackS = 0x708E260A; + unsigned system__parametersB = 0x56D770CD; + unsigned system__parametersS = 0x237E39BE; + unsigned system__soft_linksB = 0x08AB6B2C; + unsigned system__soft_linksS = 0x1E2491F3; + unsigned system__stack_checkingB = 0x476457A0; + unsigned system__stack_checkingS = 0x5299FCED; + unsigned system__tracebackB = 0x2971EBDE; + unsigned system__tracebackS = 0x2E9C3122; + unsigned ada__streamsS = 0x7C25DE96; + unsigned ada__tagsB = 0x39ADFFA2; + unsigned ada__tagsS = 0x769A0464; + unsigned system__string_opsB = 0x5EB646AB; + unsigned system__string_opsS = 0x63CED018; + unsigned interfacesS = 0x0357E00A; + unsigned interfaces__c_streamsB = 0x3784FB72; + unsigned interfaces__c_streamsS = 0x2E723019; + unsigned system__file_ioB = 0x623358EA; + unsigned system__file_ioS = 0x31F873E6; + unsigned ada__finalizationB = 0x6843F68A; + unsigned ada__finalizationS = 0x63305874; + unsigned system__finalization_rootB = 0x31E56CE1; + unsigned system__finalization_rootS = 0x23169EF3; + unsigned system__finalization_implementationB = 0x6CCBA70E; + unsigned system__finalization_implementationS = 0x604AA587; + unsigned system__string_ops_concat_3B = 0x572E3F58; + unsigned system__string_ops_concat_3S = 0x01F57876; + unsigned system__stream_attributesB = 0x1D4F93E8; + unsigned system__stream_attributesS = 0x30B2EC3D; + unsigned ada__io_exceptionsS = 0x34054F96; + unsigned system__unsigned_typesS = 0x7B9E7FE3; + unsigned system__file_control_blockS = 0x2FF876A8; + unsigned ada__finalization__list_controllerB = 0x5760634A; + unsigned ada__finalization__list_controllerS = 0x5D851835; + + /* BEGIN ELABORATION ORDER + ada (spec) + gnat (spec) + gnat.heap_sort_a (spec) + gnat.htable (spec) + gnat.htable (body) + interfaces (spec) + system (spec) + system.parameters (spec) + system.standard_library (spec) + ada.exceptions (spec) + system.exceptions (spec) + system.parameters (body) + gnat.heap_sort_a (body) + interfaces.c_streams (spec) + interfaces.c_streams (body) + system.exception_table (spec) + system.exception_table (body) + ada.io_exceptions (spec) + system.storage_elements (spec) + system.storage_elements (body) + system.machine_state_operations (spec) + system.machine_state_operations (body) + system.secondary_stack (spec) + system.stack_checking (spec) + system.soft_links (spec) + system.soft_links (body) + system.stack_checking (body) + system.secondary_stack (body) + system.standard_library (body) + system.string_ops (spec) + system.string_ops (body) + ada.tags (spec) + ada.tags (body) + ada.streams (spec) + system.finalization_root (spec) + system.finalization_root (body) + system.string_ops_concat_3 (spec) + system.string_ops_concat_3 (body) + system.traceback (spec) + system.traceback (body) + ada.exceptions (body) + system.unsigned_types (spec) + system.stream_attributes (spec) + system.stream_attributes (body) + system.finalization_implementation (spec) + system.finalization_implementation (body) + ada.finalization (spec) + ada.finalization (body) + ada.finalization.list_controller (spec) + ada.finalization.list_controller (body) + system.file_control_block (spec) + system.file_io (spec) + system.file_io (body) + ada.text_io (spec) + ada.text_io (body) + hello (body) + END ELABORATION ORDER */ + + /* BEGIN Object file/option list + ./hello.o + -L./ + -L/usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/ + /usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/libgnat.a + -lexc + END Object file/option list */ + + @end smallexample + + @noindent + Here again, the C code is exactly what is generated by the binder. The + functions of the various parts of this code correspond in an obvious + manner with the commented Ada code shown in the example in the previous + section. + + @node Consistency-Checking Modes + @section Consistency-Checking Modes + + @noindent + As described in the previous section, by default @code{gnatbind} checks + that object files are consistent with one another and are consistent + with any source files it can locate. The following switches control binder + access to sources. + + @table @code + @item -s + @cindex @code{-s} (@code{gnatbind}) + Require source files to be present. In this mode, the binder must be + able to locate all source files that are referenced, in order to check + their consistency. In normal mode, if a source file cannot be located it + is simply ignored. If you specify this switch, a missing source + file is an error. + + @item -x + @cindex @code{-x} (@code{gnatbind}) + Exclude source files. In this mode, the binder only checks that ALI + files are consistent with one another. Source files are not accessed. + The binder runs faster in this mode, and there is still a guarantee that + the resulting program is self-consistent. + If a source file has been edited since it was last compiled, and you + specify this switch, the binder will not detect that the object + file is out of date with respect to the source file. Note that this is the + mode that is automatically used by @code{gnatmake} because in this + case the checking against sources has already been performed by + @code{gnatmake} in the course of compilation (i.e. before binding). + + @end table + + @node Binder Error Message Control + @section Binder Error Message Control + + @noindent + The following switches provide control over the generation of error + messages from the binder: + + @table @code + @item -v + @cindex @code{-v} (@code{gnatbind}) + Verbose mode. In the normal mode, brief error messages are generated to + @file{stderr}. If this switch is present, a header is written + to @file{stdout} and any error messages are directed to @file{stdout}. + All that is written to @file{stderr} is a brief summary message. + + @item -b + @cindex @code{-b} (@code{gnatbind}) + Generate brief error messages to @file{stderr} even if verbose mode is + specified. This is relevant only when used with the + @code{-v} switch. + + @item -m@var{n} + @cindex @code{-m} (@code{gnatbind}) + Limits the number of error messages to @var{n}, a decimal integer in the + range 1-999. The binder terminates immediately if this limit is reached. + + @item -M@var{xxx} + @cindex @code{-M} (@code{gnatbind}) + Renames the generated main program from @code{main} to @code{xxx}. + This is useful in the case of some cross-building environments, where + the actual main program is separate from the one generated + by @code{gnatbind}. + + @item -ws + @cindex @code{-ws} (@code{gnatbind}) + @cindex Warnings + Suppress all warning messages. + + @item -we + @cindex @code{-we} (@code{gnatbind}) + Treat any warning messages as fatal errors. + + + @item -t + @cindex @code{-t} (@code{gnatbind}) + @cindex Time stamp checks, in binder + @cindex Binder consistency checks + @cindex Consistency checks, in binder + The binder performs a number of consistency checks including: + + @itemize @bullet + @item + Check that time stamps of a given source unit are consistent + @item + Check that checksums of a given source unit are consistent + @item + Check that consistent versions of @code{GNAT} were used for compilation + @item + Check consistency of configuration pragmas as required + @end itemize + + @noindent + Normally failure of such checks, in accordance with the consistency + requirements of the Ada Reference Manual, causes error messages to be + generated which abort the binder and prevent the output of a binder + file and subsequent link to obtain an executable. + + The @code{-t} switch converts these error messages + into warnings, so that + binding and linking can continue to completion even in the presence of such + errors. The result may be a failed link (due to missing symbols), or a + non-functional executable which has undefined semantics. + @emph{This means that + @code{-t} should be used only in unusual situations, + with extreme care.} + @end table + + @node Elaboration Control + @section Elaboration Control + + @noindent + The following switches provide additional control over the elaboration + order. For full details see @xref{Elaboration Order Handling in GNAT}. + + @table @code + @item -p + @cindex @code{-h} (@code{gnatbind}) + Normally the binder attempts to choose an elaboration order that is + likely to minimize the likelihood of an elaboration order error resulting + in raising a @code{Program_Error} exception. This switch reverses the + action of the binder, and requests that it deliberately choose an order + that is likely to maximize the likelihood of an elaboration error. + This is useful in ensuring portability and avoiding dependence on + accidental fortuitous elaboration ordering. + + Normally it only makes sense to use the @code{-p} switch if dynamic + elaboration checking is used (@option{-gnatE} switch used for compilation). + This is because in the default static elaboration mode, all necessary + @code{Elaborate_All} pragmas are implicitly inserted. These implicit + pragmas are still respected by the binder in @code{-p} mode, so a + safe elaboration order is assured. + @end table + + @node Output Control + @section Output Control + + @noindent + The following switches allow additional control over the output + generated by the binder. + + @table @code + + @item -A + @cindex @code{-A} (@code{gnatbind}) + Generate binder program in Ada (default). The binder program is named + @file{b~@var{mainprog}.adb} by default. This can be changed with + @code{-o} @code{gnatbind} option. + + @item -c + @cindex @code{-c} (@code{gnatbind}) + Check only. Do not generate the binder output file. In this mode the + binder performs all error checks but does not generate an output file. + + @item -C + @cindex @code{-C} (@code{gnatbind}) + Generate binder program in C. The binder program is named + @file{b_@var{mainprog}.c}. This can be changed with @code{-o} @code{gnatbind} + option. + + @item -e + @cindex @code{-e} (@code{gnatbind}) + Output complete list of elaboration-order dependencies, showing the + reason for each dependency. This output can be rather extensive but may + be useful in diagnosing problems with elaboration order. The output is + written to @file{stdout}. + + @item -h + @cindex @code{-h} (@code{gnatbind}) + Output usage information. The output is written to @file{stdout}. + + @item -K + @cindex @code{-K} (@code{gnatbind}) + Output linker options to @file{stdout}. Includes library search paths, + contents of pragmas Ident and Linker_Options, and libraries added + by @code{gnatbind}. + + @item -l + @cindex @code{-l} (@code{gnatbind}) + Output chosen elaboration order. The output is written to @file{stdout}. + + @item -O + @cindex @code{-O} (@code{gnatbind}) + Output full names of all the object files that must be linked to provide + the Ada component of the program. The output is written to @file{stdout}. + This list includes the files explicitly supplied and referenced by the user + as well as implicitly referenced run-time unit files. The latter are + omitted if the corresponding units reside in shared libraries. The + directory names for the run-time units depend on the system configuration. + + @item -o @var{file} + @cindex @code{-o} (@code{gnatbind}) + Set name of output file to @var{file} instead of the normal + @file{b~@var{mainprog}.adb} default. Note that @var{file} denote the Ada + binder generated body filename. In C mode you would normally give + @var{file} an extension of @file{.c} because it will be a C source program. + Note that if this option is used, then linking must be done manually. + It is not possible to use gnatlink in this case, since it cannot locate + the binder file. + + @item -r + @cindex @code{-r} (@code{gnatbind}) + Generate list of @code{pragma Rerstrictions} that could be applied to + the current unit. This is useful for code audit purposes, and also may + be used to improve code generation in some cases. + + @end table + + @node Binding with Non-Ada Main Programs + @section Binding with Non-Ada Main Programs + + @noindent + In our description so far we have assumed that the main + program is in Ada, and that the task of the binder is to generate a + corresponding function @code{main} that invokes this Ada main + program. GNAT also supports the building of executable programs where + the main program is not in Ada, but some of the called routines are + written in Ada and compiled using GNAT (@pxref{Mixed Language Programming}). + The following switch is used in this situation: + + @table @code + @item -n + @cindex @code{-n} (@code{gnatbind}) + No main program. The main program is not in Ada. + @end table + + @noindent + In this case, most of the functions of the binder are still required, + but instead of generating a main program, the binder generates a file + containing the following callable routines: + + @table @code + @item adainit + @findex adainit + You must call this routine to initialize the Ada part of the program by + calling the necessary elaboration routines. A call to @code{adainit} is + required before the first call to an Ada subprogram. + + Note that it is assumed that the basic execution environment must be setup + to be appropriate for Ada execution at the point where the first Ada + subprogram is called. In particular, if the Ada code will do any + floating-point operations, then the FPU must be setup in an appropriate + manner. For the case of the x86, for example, full precision mode is + required. The procedure GNAT.Float_Control.Reset may be used to ensure + that the FPU is in the right state. + + @item adafinal + @findex adafinal + You must call this routine to perform any library-level finalization + required by the Ada subprograms. A call to @code{adafinal} is required + after the last call to an Ada subprogram, and before the program + terminates. + @end table + + @noindent + If the @code{-n} switch + @cindex Binder, multiple input files + is given, more than one ALI file may appear on + the command line for @code{gnatbind}. The normal @dfn{closure} + calculation is performed for each of the specified units. Calculating + the closure means finding out the set of units involved by tracing + @code{with} references. The reason it is necessary to be able to + specify more than one ALI file is that a given program may invoke two or + more quite separate groups of Ada units. + + The binder takes the name of its output file from the last specified ALI + file, unless overridden by the use of the @code{-o file}. + The output is an Ada unit in source form that can + be compiled with GNAT unless the -C switch is used in which case the + output is a C source file, which must be compiled using the C compiler. + This compilation occurs automatically as part of the @code{gnatlink} + processing. + + Currently the GNAT run time requires a FPU using 80 bits mode + precision. Under targets where this is not the default it is required to + call GNAT.Float_Control.Reset before using floating point numbers (this + include float computation, float input and output) in the Ada code. A + side effect is that this could be the wrong mode for the foreign code + where floating point computation could be broken after this call. + + @node Binding Programs with No Main Subprogram + @section Binding Programs with No Main Subprogram + + @noindent + It is possible to have an Ada program which does not have a main + subprogram. This program will call the elaboration routines of all the + packages, then the finalization routines. + + The following switch is used to bind programs organized in this manner: + + @table @code + @item -z + @cindex @code{-z} (@code{gnatbind}) + Normally the binder checks that the unit name given on the command line + corresponds to a suitable main subprogram. When this switch is used, + a list of ALI files can be given, and the execution of the program + consists of elaboration of these units in an appropriate order. + @end table + + @node Summary of Binder Switches + @section Summary of Binder Switches + + @noindent + The following are the switches available with @code{gnatbind}: + + @table @code + @item -aO + Specify directory to be searched for ALI files. + + @item -aI + Specify directory to be searched for source file. + + @item -A + Generate binder program in Ada (default) + + @item -b + Generate brief messages to @file{stderr} even if verbose mode set. + + @item -c + Check only, no generation of binder output file. + + @item -C + Generate binder program in C + + @item -e + Output complete list of elaboration-order dependencies. + + @item -E + Store tracebacks in exception occurrences when the target supports it. + This is the default with the zero cost exception mechanism. + This option is currently supported on the following targets: + all x86 ports, Solaris, Windows, HP-UX, AIX, PowerPC VxWorks and Alpha VxWorks. + See also the packages @code{GNAT.Traceback} and + @code{GNAT.Traceback.Symbolic} for more information. + Note that on x86 ports, you must not use @code{-fomit-frame-pointer} + @code{gcc} option. + + @item -h + Output usage (help) information + + @item -I + Specify directory to be searched for source and ALI files. + + @item -I- + Do not look for sources in the current directory where @code{gnatbind} was + invoked, and do not look for ALI files in the directory containing the + ALI file named in the @code{gnatbind} command line. + + @item -l + Output chosen elaboration order. + + @item -Lxxx + Binds the units for library building. In this case the adainit and + adafinal procedures (See @pxref{Binding with Non-Ada Main Programs}) + are renamed to xxxinit and xxxfinal. Implies -n. + See @pxref{GNAT and Libraries} for more details. + + @item -Mxyz + Rename generated main program from main to xyz + + @item -m@var{n} + Limit number of detected errors to @var{n} (1-999). + + @item -n + No main program. + + @item -nostdinc + Do not look for sources in the system default directory. + + @item -nostdlib + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatbind}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -o @var{file} + Name the output file @var{file} (default is @file{b~@var{xxx}.adb}). + Note that if this option is used, then linking must be done manually, + gnatlink cannot be used. + + @item -O + Output object list. + + @item -p + Pessimistic (worst-case) elaboration order + + @item -s + Require all source files to be present. + + @item -static + Link against a static GNAT run time. + + @item -shared + Link against a shared GNAT run time when available. + + @item -t + Tolerate time stamp and other consistency errors + + @item -T@var{n} + Set the time slice value to n microseconds. A value of zero means no time + slicing and also indicates to the tasking run time to match as close as + possible to the annex D requirements of the RM. + + @item -v + Verbose mode. Write error messages, header, summary output to + @file{stdout}. + + @item -w@var{x} + Warning mode (@var{x}=s/e for suppress/treat as error) + + + @item -x + Exclude source files (check object consistency only). + + + @item -z + No main subprogram. + + @end table + + You may obtain this listing by running the program @code{gnatbind} with + no arguments. + + @node Command-Line Access + @section Command-Line Access + + @noindent + The package @code{Ada.Command_Line} provides access to the command-line + arguments and program name. In order for this interface to operate + correctly, the two variables + + @smallexample + @group + @cartouche + int gnat_argc; + char **gnat_argv; + @end cartouche + @end group + @end smallexample + + @noindent + @findex gnat_argv + @findex gnat_argc + are declared in one of the GNAT library routines. These variables must + be set from the actual @code{argc} and @code{argv} values passed to the + main program. With no @code{n} present, @code{gnatbind} + generates the C main program to automatically set these variables. + If the @code{n} switch is used, there is no automatic way to + set these variables. If they are not set, the procedures in + @code{Ada.Command_Line} will not be available, and any attempt to use + them will raise @code{Constraint_Error}. If command line access is + required, your main program must set @code{gnat_argc} and + @code{gnat_argv} from the @code{argc} and @code{argv} values passed to + it. + + @node Search Paths for gnatbind + @section Search Paths for @code{gnatbind} + + @noindent + The binder takes the name of an ALI file as its argument and needs to + locate source files as well as other ALI files to verify object consistency. + + For source files, it follows exactly the same search rules as @code{gcc} + (@pxref{Search Paths and the Run-Time Library (RTL)}). For ALI files the + directories searched are: + + @enumerate + @item + The directory containing the ALI file named in the command line, unless + the switch @code{-I-} is specified. + + @item + All directories specified by @code{-I} + switches on the @code{gnatbind} + command line, in the order given. + + @item + @findex ADA_OBJECTS_PATH + Each of the directories listed in the value of the + @code{ADA_OBJECTS_PATH} environment variable. + Construct this value + exactly as the @code{PATH} environment variable: a list of directory + names separated by colons (semicolons when working with the NT version + of GNAT). + + @item + The content of the "ada_object_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as the + GNAT Run Time Library (RTL) unless the switch @code{-nostdlib} is + specified. + @ref{Installing an Ada Library} + @end enumerate + + @noindent + In the binder the switch @code{-I} + is used to specify both source and + library file paths. Use @code{-aI} + instead if you want to specify + source paths only, and @code{-aO} + if you want to specify library paths + only. This means that for the binder + @code{-I}@var{dir} is equivalent to + @code{-aI}@var{dir} + @code{-aO}@var{dir}. + The binder generates the bind file (a C language source file) in the + current working directory. + + @findex Ada + @findex System + @findex Interfaces + @findex GNAT + The packages @code{Ada}, @code{System}, and @code{Interfaces} and their + children make up the GNAT Run-Time Library, together with the package + GNAT and its children, which contain a set of useful additional + library functions provided by GNAT. The sources for these units are + needed by the compiler and are kept together in one directory. The ALI + files and object files generated by compiling the RTL are needed by the + binder and the linker and are kept together in one directory, typically + different from the directory containing the sources. In a normal + installation, you need not specify these directory names when compiling + or binding. Either the environment variables or the built-in defaults + cause these files to be found. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + + @node Examples of gnatbind Usage + @section Examples of @code{gnatbind} Usage + + @noindent + This section contains a number of examples of using the GNAT binding + utility @code{gnatbind}. + + @table @code + @item gnatbind hello + The main program @code{Hello} (source program in @file{hello.adb}) is + bound using the standard switch settings. The generated main program is + @file{b~hello.adb}. This is the normal, default use of the binder. + + @item gnatbind hello -o mainprog.adb + The main program @code{Hello} (source program in @file{hello.adb}) is + bound using the standard switch settings. The generated main program is + @file{mainprog.adb} with the associated spec in + @file{mainprog.ads}. Note that you must specify the body here not the + spec, in the case where the output is in Ada. Note that if this option + is used, then linking must be done manually, since gnatlink will not + be able to find the generated file. + + @item gnatbind main -C -o mainprog.c -x + The main program @code{Main} (source program in + @file{main.adb}) is bound, excluding source files from the + consistency checking, generating + the file @file{mainprog.c}. + + @item gnatbind -x main_program -C -o mainprog.c + This command is exactly the same as the previous example. Switches may + appear anywhere in the command line, and single letter switches may be + combined into a single switch. + + @item gnatbind -n math dbase -C -o ada-control.c + The main program is in a language other than Ada, but calls to + subprograms in packages @code{Math} and @code{Dbase} appear. This call + to @code{gnatbind} generates the file @file{ada-control.c} containing + the @code{adainit} and @code{adafinal} routines to be called before and + after accessing the Ada units. + @end table + + @node Linking Using gnatlink + @chapter Linking Using @code{gnatlink} + @findex gnatlink + + @noindent + This chapter discusses @code{gnatlink}, a utility program used to link + Ada programs and build an executable file. This is a simple program + that invokes the Unix linker (via the @code{gcc} + command) with a correct list of object files and library references. + @code{gnatlink} automatically determines the list of files and + references for the Ada part of a program. It uses the binder file + generated by the binder to determine this list. + + @menu + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + @end menu + + @node Running gnatlink + @section Running @code{gnatlink} + + @noindent + The form of the @code{gnatlink} command is + + @smallexample + $ gnatlink [@var{switches}] @var{mainprog}[.ali] [@var{non-Ada objects}] + [@var{linker options}] + @end smallexample + + @noindent + @file{@var{mainprog}.ali} references the ALI file of the main program. + The @file{.ali} extension of this file can be omitted. From this + reference, @code{gnatlink} locates the corresponding binder file + @file{b~@var{mainprog}.adb} and, using the information in this file along + with the list of non-Ada objects and linker options, constructs a Unix + linker command file to create the executable. + + The arguments following @file{@var{mainprog}.ali} are passed to the + linker uninterpreted. They typically include the names of object files + for units written in other languages than Ada and any library references + required to resolve references in any of these foreign language units, + or in @code{pragma Import} statements in any Ada units. + + @var{linker options} is an optional list of linker specific + switches. The default linker called by gnatlink is @var{gcc} which in + turn calls the appropriate system linker usually called + @var{ld}. Standard options for the linker such as @code{-lmy_lib} or + @code{-Ldir} can be added as is. For options that are not recognized by + @var{gcc} as linker options, the @var{gcc} switches @code{-Xlinker} or + @code{-Wl,} shall be used. Refer to the GCC documentation for + details. Here is an example showing how to generate a linker map + assuming that the underlying linker is GNU ld: + + @smallexample + $ gnatlink my_prog -Wl,-Map,MAPFILE + @end smallexample + + Using @var{linker options} it is possible to set the program stack and + heap size. See @pxref{Setting Stack Size from gnatlink} and + @pxref{Setting Heap Size from gnatlink}. + + @code{gnatlink} determines the list of objects required by the Ada + program and prepends them to the list of objects passed to the linker. + @code{gnatlink} also gathers any arguments set by the use of + @code{pragma Linker_Options} and adds them to the list of arguments + presented to the linker. + + + @node Switches for gnatlink + @section Switches for @code{gnatlink} + + @noindent + The following switches are available with the @code{gnatlink} utility: + + @table @code + + @item -A + @cindex @code{-A} (@code{gnatlink}) + The binder has generated code in Ada. This is the default. + + @item -C + @cindex @code{-C} (@code{gnatlink}) + If instead of generating a file in Ada, the binder has generated one in + C, then the linker needs to know about it. Use this switch to signal + to @code{gnatlink} that the binder has generated C code rather than + Ada code. + + @item -f + @cindex Command line length + @cindex @code{-f} (@code{gnatlink}) + On some targets, the command line length is limited, and @code{gnatlink} + will generate a separate file for the linker if the list of object files + is too long. The @code{-f} flag forces this file to be generated even if + the limit is not exceeded. This is useful in some cases to deal with + special situations where the command line length is exceeded. + + @item -g + @cindex Debugging information, including + @cindex @code{-g} (@code{gnatlink}) + The option to include debugging information causes the Ada bind file (in + other words, @file{b~@var{mainprog}.adb}) to be compiled with + @code{-g}. + In addition, the binder does not delete the @file{b~@var{mainprog}.adb}, + @file{b~@var{mainprog}.o} and @file{b~@var{mainprog}.ali} files. + Without @code{-g}, the binder removes these files by + default. The same procedure apply if a C bind file was generated using + @code{-C} @code{gnatbind} option, in this case the filenames are + @file{b_@var{mainprog}.c} and @file{b_@var{mainprog}.o}. + + @item -n + @cindex @code{-n} (@code{gnatlink}) + Do not compile the file generated by the binder. This may be used when + a link is rerun with different options, but there is no need to recompile + the binder file. + + @item -v + @cindex @code{-v} (@code{gnatlink}) + Causes additional information to be output, including a full list of the + included object files. This switch option is most useful when you want + to see what set of object files are being used in the link step. + + @item -v -v + @cindex @code{-v -v} (@code{gnatlink}) + Very verbose mode. Requests that the compiler operate in verbose mode when + it compiles the binder file, and that the system linker run in verbose mode. + + @item -o @var{exec-name} + @cindex @code{-o} (@code{gnatlink}) + @var{exec-name} specifies an alternate name for the generated + executable program. If this switch is omitted, the executable has the same + name as the main unit. For example, @code{gnatlink try.ali} creates + an executable called @file{try}. + + @item -b @var{target} + @cindex @code{-b} (@code{gnatlink}) + Compile your program to run on @var{target}, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + @var{target} is not the same as your host system. + + @item -B@var{dir} + @cindex @code{-B} (@code{gnatlink}) + Load compiler executables (for example, @code{gnat1}, the Ada compiler) + from @var{dir} instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + @code{gcc} manual page for further details. You would normally use the + @code{-b} or @code{-V} switch instead. + + @item --GCC=@var{compiler_name} + @cindex @code{--GCC=compiler_name} (@code{gnatlink}) + Program used for compiling the binder file. The default is + `@code{gcc}'. You need to use quotes around @var{compiler_name} if + @code{compiler_name} contains spaces or other separator characters. As + an example @code{--GCC="foo -x -y"} will instruct @code{gnatlink} to use + @code{foo -x -y} as your compiler. Note that switch @code{-c} is always + inserted after your command name. Thus in the above example the compiler + command that will be used by @code{gnatlink} will be @code{foo -c -x -y}. + If several @code{--GCC=compiler_name} are used, only the last + @var{compiler_name} is taken into account. However, all the additional + switches are also taken into account. Thus, + @code{--GCC="foo -x -y" --GCC="bar -z -t"} is equivalent to + @code{--GCC="bar -x -y -z -t"}. + + @item --LINK=@var{name} + @cindex @code{--LINK=} (@code{gnatlink}) + @var{name} is the name of the linker to be invoked. This is especially + useful in mixed language programs since languages such as c++ require + their own linker to be used. When this switch is omitted, the default + name for the linker is (@file{gcc}). When this switch is used, the + specified linker is called instead of (@file{gcc}) with exactly the same + parameters that would have been passed to (@file{gcc}) so if the desired + linker requires different parameters it is necessary to use a wrapper + script that massages the parameters before invoking the real linker. It + may be useful to control the exact invocation by using the verbose + switch. + + + + @end table + + @node Setting Stack Size from gnatlink + @section Setting Stack Size from @code{gnatlink} + + @noindent + It is possible to specify the program stack size from @code{gnatlink}. + Assuming that the underlying linker is GNU ld there is two ways to do so: + + @itemize @bullet + + @item using @code{-Xlinker} linker option + + @smallexample + $ gnatlink hello -Xlinker --stack=0x10000,0x1000 + @end smallexample + + This set the stack reserve size to 0x10000 bytes and the stack commit + size to 0x1000 bytes. + + @item using @code{-Wl} linker option + + @smallexample + $ gnatlink hello -Wl,--stack=0x1000000 + @end smallexample + + This set the stack reserve size to 0x1000000 bytes. Note that with + @code{-Wl} option it is not possible to set the stack commit size + because the coma is a separator for this option. + + @end itemize + + @node Setting Heap Size from gnatlink + @section Setting Heap Size from @code{gnatlink} + + @noindent + It is possible to specify the program heap size from @code{gnatlink}. + Assuming that the underlying linker is GNU ld there is two ways to do so: + + @itemize @bullet + + @item using @code{-Xlinker} linker option + + @smallexample + $ gnatlink hello -Xlinker --heap=0x10000,0x1000 + @end smallexample + + This set the heap reserve size to 0x10000 bytes and the heap commit + size to 0x1000 bytes. + + @item using @code{-Wl} linker option + + @smallexample + $ gnatlink hello -Wl,--heap=0x1000000 + @end smallexample + + This set the heap reserve size to 0x1000000 bytes. Note that with + @code{-Wl} option it is not possible to set the heap commit size + because the coma is a separator for this option. + + @end itemize + + @node The GNAT Make Program gnatmake + @chapter The GNAT Make Program @code{gnatmake} + @findex gnatmake + + @menu + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + @end menu + @noindent + A typical development cycle when working on an Ada program consists of + the following steps: + + @enumerate + @item + Edit some sources to fix bugs. + + @item + Add enhancements. + + @item + Compile all sources affected. + + @item + Rebind and relink. + + @item + Test. + @end enumerate + + @noindent + The third step can be tricky, because not only do the modified files + @cindex Dependency rules + have to be compiled, but any files depending on these files must also be + recompiled. The dependency rules in Ada can be quite complex, especially + in the presence of overloading, @code{use} clauses, generics and inlined + subprograms. + + @code{gnatmake} automatically takes care of the third and fourth steps + of this process. It determines which sources need to be compiled, + compiles them, and binds and links the resulting object files. + + Unlike some other Ada make programs, the dependencies are always + accurately recomputed from the new sources. The source based approach of + the GNAT compilation model makes this possible. This means that if + changes to the source program cause corresponding changes in + dependencies, they will always be tracked exactly correctly by + @code{gnatmake}. + + @node Running gnatmake + @section Running @code{gnatmake} + + @noindent + The usual form of the @code{gnatmake} command is + + @smallexample + $ gnatmake [@var{switches}] @var{file_name} [@var{file_names}] [@var{mode_switches}] + @end smallexample + + @noindent + The only required argument is one @var{file_name}, which specifies + a compilation unit that is a main program. Several @var{file_names} can be + specified: this will result in several executables being built. + If @code{switches} are present, they can be placed before the first + @var{file_name}, between @var{file_names} or after the last @var{file_name}. + If @var{mode_switches} are present, they must always be placed after + the last @var{file_name} and all @code{switches}. + + If you are using standard file extensions (.adb and .ads), then the + extension may be omitted from the @var{file_name} arguments. However, if + you are using non-standard extensions, then it is required that the + extension be given. A relative or absolute directory path can be + specified in a @var{file_name}, in which case, the input source file will + be searched for in the specified directory only. Otherwise, the input + source file will first be searched in the directory where + @code{gnatmake} was invoked and if it is not found, it will be search on + the source path of the compiler as described in + @ref{Search Paths and the Run-Time Library (RTL)}. + + When several @var{file_names} are specified, if an executable needs to be + rebuilt and relinked, all subsequent executables will be rebuilt and + relinked, even if this would not be absolutely necessary. + + All @code{gnatmake} output (except when you specify + @code{-M}) is to + @file{stderr}. The output produced by the + @code{-M} switch is send to + @file{stdout}. + + @node Switches for gnatmake + @section Switches for @code{gnatmake} + + @noindent + You may specify any of the following switches to @code{gnatmake}: + + @table @code + @item --GCC=@var{compiler_name} + @cindex @code{--GCC=compiler_name} (@code{gnatmake}) + Program used for compiling. The default is `@code{gcc}'. You need to use + quotes around @var{compiler_name} if @code{compiler_name} contains + spaces or other separator characters. As an example @code{--GCC="foo -x + -y"} will instruct @code{gnatmake} to use @code{foo -x -y} as your + compiler. Note that switch @code{-c} is always inserted after your + command name. Thus in the above example the compiler command that will + be used by @code{gnatmake} will be @code{foo -c -x -y}. + If several @code{--GCC=compiler_name} are used, only the last + @var{compiler_name} is taken into account. However, all the additional + switches are also taken into account. Thus, + @code{--GCC="foo -x -y" --GCC="bar -z -t"} is equivalent to + @code{--GCC="bar -x -y -z -t"}. + + @item --GNATBIND=@var{binder_name} + @cindex @code{--GNATBIND=binder_name} (@code{gnatmake}) + Program used for binding. The default is `@code{gnatbind}'. You need to + use quotes around @var{binder_name} if @var{binder_name} contains spaces + or other separator characters. As an example @code{--GNATBIND="bar -x + -y"} will instruct @code{gnatmake} to use @code{bar -x -y} as your + binder. Binder switches that are normally appended by @code{gnatmake} to + `@code{gnatbind}' are now appended to the end of @code{bar -x -y}. + + @item --GNATLINK=@var{linker_name} + @cindex @code{--GNATLINK=linker_name} (@code{gnatmake}) + Program used for linking. The default is `@code{gnatlink}'. You need to + use quotes around @var{linker_name} if @var{linker_name} contains spaces + or other separator characters. As an example @code{--GNATLINK="lan -x + -y"} will instruct @code{gnatmake} to use @code{lan -x -y} as your + linker. Linker switches that are normally appended by @code{gnatmake} to + `@code{gnatlink}' are now appended to the end of @code{lan -x -y}. + + + @item -a + @cindex @code{-a} (@code{gnatmake}) + Consider all files in the make process, even the GNAT internal system + files (for example, the predefined Ada library files), as well as any + locked files. Locked files are files whose ALI file is write-protected. + By default, + @code{gnatmake} does not check these files, + because the assumption is that the GNAT internal files are properly up + to date, and also that any write protected ALI files have been properly + installed. Note that if there is an installation problem, such that one + of these files is not up to date, it will be properly caught by the + binder. + You may have to specify this switch if you are working on GNAT + itself. @code{-a} is also useful in conjunction with + @code{-f} + if you need to recompile an entire application, + including run-time files, using special configuration pragma settings, + such as a non-standard @code{Float_Representation} pragma. + By default + @code{gnatmake -a} compiles all GNAT + internal files with + @code{gcc -c -gnatpg} rather than @code{gcc -c}. + + @item -b + @cindex @code{-b} (@code{gnatmake}) + Bind only. Can be combined with @code{-c} to do compilation + and binding, but no link. Can be combined with @code{-l} + to do binding and linking. When not combined with @code{-c} + all the units in the closure of the main program must have been previously + compiled and must be up to date. The root unit specified by @var{file_name} + may be given without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + @item -c + @cindex @code{-c} (@code{gnatmake}) + Compile only. Do not perform binding, except when @code{-b} + is also specified. Do not perform linking, except if both + @code{-b} and + @code{-l} are also specified. + If the root unit specified by @var{file_name} is not a main unit, this is the + default. Otherwise @code{gnatmake} will attempt binding and linking + unless all objects are up to date and the executable is more recent than + the objects. + + @item -C + @cindex @code{-C} (@code{gnatmake}) + Use a mapping file. A mapping file is a way to communicate to the compiler + two mappings: from unit names to file names (without any directory information) + and from file names to path names (with full directory information). + These mappings are used by the compiler to short-circuit the path search. + When @code{gnatmake} is invoked with this switch, it will create a mapping + file, initially populated by the project manager, if @code{-P} is used, + otherwise initially empty. Each invocation of the compiler will add the newly + accessed sources to the mapping file. This will improve the source search + during the next invocation of the compiler. + + @item -f + @cindex @code{-f} (@code{gnatmake}) + Force recompilations. Recompile all sources, even though some object + files may be up to date, but don't recompile predefined or GNAT internal + files or locked files (files with a write-protected ALI file), + unless the @code{-a} switch is also specified. + + @item + @item -i + @cindex @code{-i} (@code{gnatmake}) + In normal mode, @code{gnatmake} compiles all object files and ALI files + into the current directory. If the @code{-i} switch is used, + then instead object files and ALI files that already exist are overwritten + in place. This means that once a large project is organized into separate + directories in the desired manner, then @code{gnatmake} will automatically + maintain and update this organization. If no ALI files are found on the + Ada object path (@ref{Search Paths and the Run-Time Library (RTL)}), + the new object and ALI files are created in the + directory containing the source being compiled. If another organization + is desired, where objects and sources are kept in different directories, + a useful technique is to create dummy ALI files in the desired directories. + When detecting such a dummy file, @code{gnatmake} will be forced to recompile + the corresponding source file, and it will be put the resulting object + and ALI files in the directory where it found the dummy file. + + @item -j@var{n} + @cindex @code{-j} (@code{gnatmake}) + @cindex Parallel make + Use @var{n} processes to carry out the (re)compilations. On a + multiprocessor machine compilations will occur in parallel. In the + event of compilation errors, messages from various compilations might + get interspersed (but @code{gnatmake} will give you the full ordered + list of failing compiles at the end). If this is problematic, rerun + the make process with n set to 1 to get a clean list of messages. + + @item -k + @cindex @code{-k} (@code{gnatmake}) + Keep going. Continue as much as possible after a compilation error. To + ease the programmer's task in case of compilation errors, the list of + sources for which the compile fails is given when @code{gnatmake} + terminates. + + If @code{gnatmake} is invoked with several @file{file_names} and with this + switch, if there are compilation errors when building an executable, + @code{gnatmake} will not attempt to build the following executables. + + @item -l + @cindex @code{-l} (@code{gnatmake}) + Link only. Can be combined with @code{-b} to binding + and linking. Linking will not be performed if combined with + @code{-c} + but not with @code{-b}. + When not combined with @code{-b} + all the units in the closure of the main program must have been previously + compiled and must be up to date, and the main program need to have been bound. + The root unit specified by @var{file_name} + may be given without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + @item -m + @cindex @code{-m} (@code{gnatmake}) + Specifies that the minimum necessary amount of recompilations + be performed. In this mode @code{gnatmake} ignores time + stamp differences when the only + modifications to a source file consist in adding/removing comments, + empty lines, spaces or tabs. This means that if you have changed the + comments in a source file or have simply reformatted it, using this + switch will tell gnatmake not to recompile files that depend on it + (provided other sources on which these files depend have undergone no + semantic modifications). Note that the debugging information may be + out of date with respect to the sources if the @code{-m} switch causes + a compilation to be switched, so the use of this switch represents a + trade-off between compilation time and accurate debugging information. + + @item -M + @cindex Dependencies, producing list + @cindex @code{-M} (@code{gnatmake}) + Check if all objects are up to date. If they are, output the object + dependences to @file{stdout} in a form that can be directly exploited in + a @file{Makefile}. By default, each source file is prefixed with its + (relative or absolute) directory name. This name is whatever you + specified in the various @code{-aI} + and @code{-I} switches. If you use + @code{gnatmake -M} + @code{-q} + (see below), only the source file names, + without relative paths, are output. If you just specify the + @code{-M} + switch, dependencies of the GNAT internal system files are omitted. This + is typically what you want. If you also specify + the @code{-a} switch, + dependencies of the GNAT internal files are also listed. Note that + dependencies of the objects in external Ada libraries (see switch + @code{-aL}@var{dir} in the following list) are never reported. + + @item -n + @cindex @code{-n} (@code{gnatmake}) + Don't compile, bind, or link. Checks if all objects are up to date. + If they are not, the full name of the first file that needs to be + recompiled is printed. + Repeated use of this option, followed by compiling the indicated source + file, will eventually result in recompiling all required units. + + @item -o @var{exec_name} + @cindex @code{-o} (@code{gnatmake}) + Output executable name. The name of the final executable program will be + @var{exec_name}. If the @code{-o} switch is omitted the default + name for the executable will be the name of the input file in appropriate form + for an executable file on the host system. + + This switch cannot be used when invoking @code{gnatmake} with several + @file{file_names}. + + @item -q + @cindex @code{-q} (@code{gnatmake}) + Quiet. When this flag is not set, the commands carried out by + @code{gnatmake} are displayed. + + @item -s + @cindex @code{-s} (@code{gnatmake}) + Recompile if compiler switches have changed since last compilation. + All compiler switches but -I and -o are taken into account in the + following way: + orders between different ``first letter'' switches are ignored, but + orders between same switches are taken into account. For example, + @code{-O -O2} is different than @code{-O2 -O}, but @code{-g -O} is equivalent + to @code{-O -g}. + + @item -u + @cindex @code{-u} (@code{gnatmake}) + Unique. Recompile at most the main file. It implies -c. Combined with + -f, it is equivalent to calling the compiler directly. + + @item -v + @cindex @code{-v} (@code{gnatmake}) + Verbose. Displays the reason for all recompilations @code{gnatmake} + decides are necessary. + + @item -z + @cindex @code{-z} (@code{gnatmake}) + No main subprogram. Bind and link the program even if the unit name + given on the command line is a package name. The resulting executable + will execute the elaboration routines of the package and its closure, + then the finalization routines. + + @item @code{gcc} @asis{switches} + The switch @code{-g} or any uppercase switch (other than @code{-A}, + @code{-L} or + @code{-S}) or any switch that is more than one character is passed to + @code{gcc} (e.g. @code{-O}, @option{-gnato,} etc.) + @end table + + @noindent + Source and library search path switches: + + @table @code + @item -aI@var{dir} + @cindex @code{-aI} (@code{gnatmake}) + When looking for source files also look in directory @var{dir}. + The order in which source files search is undertaken is + described in @ref{Search Paths and the Run-Time Library (RTL)}. + + @item -aL@var{dir} + @cindex @code{-aL} (@code{gnatmake}) + Consider @var{dir} as being an externally provided Ada library. + Instructs @code{gnatmake} to skip compilation units whose @file{.ali} + files have been located in directory @var{dir}. This allows you to have + missing bodies for the units in @var{dir} and to ignore out of date bodies + for the same units. You still need to specify + the location of the specs for these units by using the switches + @code{-aI@var{dir}} + or @code{-I@var{dir}}. + Note: this switch is provided for compatibility with previous versions + of @code{gnatmake}. The easier method of causing standard libraries + to be excluded from consideration is to write-protect the corresponding + ALI files. + + @item -aO@var{dir} + @cindex @code{-aO} (@code{gnatmake}) + When searching for library and object files, look in directory + @var{dir}. The order in which library files are searched is described in + @ref{Search Paths for gnatbind}. + + @item -A@var{dir} + @cindex Search paths, for @code{gnatmake} + @cindex @code{-A} (@code{gnatmake}) + Equivalent to @code{-aL@var{dir} + -aI@var{dir}}. + + @item -I@var{dir} + @cindex @code{-I} (@code{gnatmake}) + Equivalent to @code{-aO@var{dir} + -aI@var{dir}}. + + @item -I- + @cindex @code{-I-} (@code{gnatmake}) + @cindex Source files, suppressing search + Do not look for source files in the directory containing the source + file named in the command line. + Do not look for ALI or object files in the directory + where @code{gnatmake} was invoked. + + @item -L@var{dir} + @cindex @code{-L} (@code{gnatmake}) + @cindex Linker libraries + Add directory @var{dir} to the list of directories in which the linker + will search for libraries. This is equivalent to + @code{-largs -L}@var{dir}. + + @item -nostdinc + @cindex @code{-nostdinc} (@code{gnatmake}) + Do not look for source files in the system default directory. + + @item -nostdlib + @cindex @code{-nostdlib} (@code{gnatmake}) + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatmake}) + Specifies the default location of the runtime library. We look for the runtime + in the following directories, and stop as soon as a valid runtime is found + ("adainclude" or "ada_source_path", and "adalib" or "ada_object_path" present): + + @itemize @bullet + @item /$rts_path + + @item /$rts_path + + @item /rts-$rts_path + @end itemize + + @noindent + The selected path is handled like a normal RTS path. + + @end table + + @node Mode Switches for gnatmake + @section Mode Switches for @code{gnatmake} + + @noindent + The mode switches (referred to as @code{mode_switches}) allow the + inclusion of switches that are to be passed to the compiler itself, the + binder or the linker. The effect of a mode switch is to cause all + subsequent switches up to the end of the switch list, or up to the next + mode switch, to be interpreted as switches to be passed on to the + designated component of GNAT. + + @table @code + @item -cargs @var{switches} + @cindex @code{-cargs} (@code{gnatmake}) + Compiler switches. Here @var{switches} is a list of switches + that are valid switches for @code{gcc}. They will be passed on to + all compile steps performed by @code{gnatmake}. + + @item -bargs @var{switches} + @cindex @code{-bargs} (@code{gnatmake}) + Binder switches. Here @var{switches} is a list of switches + that are valid switches for @code{gcc}. They will be passed on to + all bind steps performed by @code{gnatmake}. + + @item -largs @var{switches} + @cindex @code{-largs} (@code{gnatmake}) + Linker switches. Here @var{switches} is a list of switches + that are valid switches for @code{gcc}. They will be passed on to + all link steps performed by @code{gnatmake}. + @end table + + @node Notes on the Command Line + @section Notes on the Command Line + + @noindent + This section contains some additional useful notes on the operation + of the @code{gnatmake} command. + + @itemize @bullet + @item + @cindex Recompilation, by @code{gnatmake} + If @code{gnatmake} finds no ALI files, it recompiles the main program + and all other units required by the main program. + This means that @code{gnatmake} + can be used for the initial compile, as well as during subsequent steps of + the development cycle. + + @item + If you enter @code{gnatmake @var{file}.adb}, where @file{@var{file}.adb} + is a subunit or body of a generic unit, @code{gnatmake} recompiles + @file{@var{file}.adb} (because it finds no ALI) and stops, issuing a + warning. + + @item + In @code{gnatmake} the switch @code{-I} + is used to specify both source and + library file paths. Use @code{-aI} + instead if you just want to specify + source paths only and @code{-aO} + if you want to specify library paths + only. + + @item + @code{gnatmake} examines both an ALI file and its corresponding object file + for consistency. If an ALI is more recent than its corresponding object, + or if the object file is missing, the corresponding source will be recompiled. + Note that @code{gnatmake} expects an ALI and the corresponding object file + to be in the same directory. + + @item + @code{gnatmake} will ignore any files whose ALI file is write-protected. + This may conveniently be used to exclude standard libraries from + consideration and in particular it means that the use of the + @code{-f} switch will not recompile these files + unless @code{-a} is also specified. + + @item + @code{gnatmake} has been designed to make the use of Ada libraries + particularly convenient. Assume you have an Ada library organized + as follows: @var{obj-dir} contains the objects and ALI files for + of your Ada compilation units, + whereas @var{include-dir} contains the + specs of these units, but no bodies. Then to compile a unit + stored in @code{main.adb}, which uses this Ada library you would just type + + @smallexample + $ gnatmake -aI@var{include-dir} -aL@var{obj-dir} main + @end smallexample + + @item + Using @code{gnatmake} along with the + @code{-m (minimal recompilation)} + switch provides a mechanism for avoiding unnecessary rcompilations. Using + this switch, + you can update the comments/format of your + source files without having to recompile everything. Note, however, that + adding or deleting lines in a source files may render its debugging + info obsolete. If the file in question is a spec, the impact is rather + limited, as that debugging info will only be useful during the + elaboration phase of your program. For bodies the impact can be more + significant. In all events, your debugger will warn you if a source file + is more recent than the corresponding object, and alert you to the fact + that the debugging information may be out of date. + @end itemize + + @node How gnatmake Works + @section How @code{gnatmake} Works + + @noindent + Generally @code{gnatmake} automatically performs all necessary + recompilations and you don't need to worry about how it works. However, + it may be useful to have some basic understanding of the @code{gnatmake} + approach and in particular to understand how it uses the results of + previous compilations without incorrectly depending on them. + + First a definition: an object file is considered @dfn{up to date} if the + corresponding ALI file exists and its time stamp predates that of the + object file and if all the source files listed in the + dependency section of this ALI file have time stamps matching those in + the ALI file. This means that neither the source file itself nor any + files that it depends on have been modified, and hence there is no need + to recompile this file. + + @code{gnatmake} works by first checking if the specified main unit is up + to date. If so, no compilations are required for the main unit. If not, + @code{gnatmake} compiles the main program to build a new ALI file that + reflects the latest sources. Then the ALI file of the main unit is + examined to find all the source files on which the main program depends, + and @code{gnatmake} recursively applies the above procedure on all these files. + + This process ensures that @code{gnatmake} only trusts the dependencies + in an existing ALI file if they are known to be correct. Otherwise it + always recompiles to determine a new, guaranteed accurate set of + dependencies. As a result the program is compiled "upside down" from what may + be more familiar as the required order of compilation in some other Ada + systems. In particular, clients are compiled before the units on which + they depend. The ability of GNAT to compile in any order is critical in + allowing an order of compilation to be chosen that guarantees that + @code{gnatmake} will recompute a correct set of new dependencies if + necessary. + + When invoking @code{gnatmake} with several @var{file_names}, if a unit is + imported by several of the executables, it will be recompiled at most once. + + @node Examples of gnatmake Usage + @section Examples of @code{gnatmake} Usage + + @table @code + @item gnatmake hello.adb + Compile all files necessary to bind and link the main program + @file{hello.adb} (containing unit @code{Hello}) and bind and link the + resulting object files to generate an executable file @file{hello}. + + @item gnatmake main1 main2 main3 + Compile all files necessary to bind and link the main programs + @file{main1.adb} (containing unit @code{Main1}), @file{main2.adb} + (containing unit @code{Main2}) and @file{main3.adb} + (containing unit @code{Main3}) and bind and link the resulting object files + to generate three executable files @file{main1}, + @file{main2} + and @file{main3}. + + @item gnatmake -q Main_Unit -cargs -O2 -bargs -l + + Compile all files necessary to bind and link the main program unit + @code{Main_Unit} (from file @file{main_unit.adb}). All compilations will + be done with optimization level 2 and the order of elaboration will be + listed by the binder. @code{gnatmake} will operate in quiet mode, not + displaying commands it is executing. + @end table + + @node Renaming Files Using gnatchop + @chapter Renaming Files Using @code{gnatchop} + @findex gnatchop + + @noindent + This chapter discusses how to handle files with multiple units by using + the @code{gnatchop} utility. This utility is also useful in renaming + files to meet the standard GNAT default file naming conventions. + + @menu + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + @end menu + + @node Handling Files with Multiple Units + @section Handling Files with Multiple Units + + @noindent + The basic compilation model of GNAT requires that a file submitted to the + compiler have only one unit and there be a strict correspondence + between the file name and the unit name. + + The @code{gnatchop} utility allows both of these rules to be relaxed, + allowing GNAT to process files which contain multiple compilation units + and files with arbitrary file names. @code{gnatchop} + reads the specified file and generates one or more output files, + containing one unit per file. The unit and the file name correspond, + as required by GNAT. + + If you want to permanently restructure a set of "foreign" files so that + they match the GNAT rules, and do the remaining development using the + GNAT structure, you can simply use @code{gnatchop} once, generate the + new set of files and work with them from that point on. + + Alternatively, if you want to keep your files in the "foreign" format, + perhaps to maintain compatibility with some other Ada compilation + system, you can set up a procedure where you use @code{gnatchop} each + time you compile, regarding the source files that it writes as temporary + files that you throw away. + + @node Operating gnatchop in Compilation Mode + @section Operating gnatchop in Compilation Mode + + @noindent + The basic function of @code{gnatchop} is to take a file with multiple units + and split it into separate files. The boundary between files is reasonably + clear, except for the issue of comments and pragmas. In default mode, the + rule is that any pragmas between units belong to the previous unit, except + that configuration pragmas always belong to the following unit. Any comments + belong to the following unit. These rules + almost always result in the right choice of + the split point without needing to mark it explicitly and most users will + find this default to be what they want. In this default mode it is incorrect to + submit a file containing only configuration pragmas, or one that ends in + configuration pragmas, to @code{gnatchop}. + + However, using a special option to activate "compilation mode", + @code{gnatchop} + can perform another function, which is to provide exactly the semantics + required by the RM for handling of configuration pragmas in a compilation. + In the absence of configuration pragmas (at the main file level), this + option has no effect, but it causes such configuration pragmas to be handled + in a quite different manner. + + First, in compilation mode, if @code{gnatchop} is given a file that consists of + only configuration pragmas, then this file is appended to the + @file{gnat.adc} file in the current directory. This behavior provides + the required behavior described in the RM for the actions to be taken + on submitting such a file to the compiler, namely that these pragmas + should apply to all subsequent compilations in the same compilation + environment. Using GNAT, the current directory, possibly containing a + @file{gnat.adc} file is the representation + of a compilation environment. For more information on the + @file{gnat.adc} file, see the section on handling of configuration + pragmas @pxref{Handling of Configuration Pragmas}. + + Second, in compilation mode, if @code{gnatchop} + is given a file that starts with + configuration pragmas, and contains one or more units, then these + configuration pragmas are prepended to each of the chopped files. This + behavior provides the required behavior described in the RM for the + actions to be taken on compiling such a file, namely that the pragmas + apply to all units in the compilation, but not to subsequently compiled + units. + + Finally, if configuration pragmas appear between units, they are appended + to the previous unit. This results in the previous unit being illegal, + since the compiler does not accept configuration pragmas that follow + a unit. This provides the required RM behavior that forbids configuration + pragmas other than those preceding the first compilation unit of a + compilation. + + For most purposes, @code{gnatchop} will be used in default mode. The + compilation mode described above is used only if you need exactly + accurate behavior with respect to compilations, and you have files + that contain multiple units and configuration pragmas. In this + circumstance the use of @code{gnatchop} with the compilation mode + switch provides the required behavior, and is for example the mode + in which GNAT processes the ACVC tests. + + @node Command Line for gnatchop + @section Command Line for @code{gnatchop} + + @noindent + The @code{gnatchop} command has the form: + + @smallexample + $ gnatchop switches @var{file name} [@var{file name} @var{file name} ...] + [@var{directory}] + @end smallexample + + @noindent + The only required argument is the file name of the file to be chopped. + There are no restrictions on the form of this file name. The file itself + contains one or more Ada units, in normal GNAT format, concatenated + together. As shown, more than one file may be presented to be chopped. + + When run in default mode, @code{gnatchop} generates one output file in + the current directory for each unit in each of the files. + + @var{directory}, if specified, gives the name of the directory to which + the output files will be written. If it is not specified, all files are + written to the current directory. + + For example, given a + file called @file{hellofiles} containing + + @smallexample + @group + @cartouche + @b{procedure} hello; + + @b{with} Text_IO; @b{use} Text_IO; + @b{procedure} hello @b{is} + @b{begin} + Put_Line ("Hello"); + @b{end} hello; + @end cartouche + @end group + @end smallexample + + @noindent + the command + + @smallexample + $ gnatchop hellofiles + @end smallexample + + @noindent + generates two files in the current directory, one called + @file{hello.ads} containing the single line that is the procedure spec, + and the other called @file{hello.adb} containing the remaining text. The + original file is not affected. The generated files can be compiled in + the normal manner. + + @node Switches for gnatchop + @section Switches for @code{gnatchop} + + @noindent + @code{gnatchop} recognizes the following switches: + + @table @code + + @item -c + @cindex @code{-c} (@code{gnatchop}) + Causes @code{gnatchop} to operate in compilation mode, in which + configuration pragmas are handled according to strict RM rules. See + previous section for a full description of this mode. + + @item -gnatxxx + This passes the given @option{-gnatxxx} switch to @code{gnat} which is + used to parse the given file. Not all @code{xxx} options make sense, + but for example, the use of @option{-gnati2} allows @code{gnatchop} to + process a source file that uses Latin-2 coding for identifiers. + + @item -h + Causes @code{gnatchop} to generate a brief help summary to the standard + output file showing usage information. + + @item -k@var{mm} + @cindex @code{-k} (@code{gnatchop}) + Limit generated file names to the specified number @code{mm} + of characters. + This is useful if the + resulting set of files is required to be interoperable with systems + which limit the length of file names. + No space is allowed between the @code{-k} and the numeric value. The numeric + value may be omitted in which case a default of @code{-k8}, + suitable for use + with DOS-like file systems, is used. If no @code{-k} switch + is present then + there is no limit on the length of file names. + + @item -p + @cindex @code{-p} (@code{gnatchop}) + Causes the file modification time stamp of the input file to be + preserved and used for the time stamp of the output file(s). This may be + useful for preserving coherency of time stamps in an enviroment where + @code{gnatchop} is used as part of a standard build process. + + @item -q + @cindex @code{-q} (@code{gnatchop}) + Causes output of informational messages indicating the set of generated + files to be suppressed. Warnings and error messages are unaffected. + + @item -r + @cindex @code{-r} (@code{gnatchop}) + @findex Source_Reference + Generate @code{Source_Reference} pragmas. Use this switch if the output + files are regarded as temporary and development is to be done in terms + of the original unchopped file. This switch causes + @code{Source_Reference} pragmas to be inserted into each of the + generated files to refers back to the original file name and line number. + The result is that all error messages refer back to the original + unchopped file. + In addition, the debugging information placed into the object file (when + the @code{-g} switch of @code{gcc} or @code{gnatmake} is specified) also + refers back to this original file so that tools like profilers and + debuggers will give information in terms of the original unchopped file. + + If the original file to be chopped itself contains + a @code{Source_Reference} + pragma referencing a third file, then gnatchop respects + this pragma, and the generated @code{Source_Reference} pragmas + in the chopped file refer to the original file, with appropriate + line numbers. This is particularly useful when @code{gnatchop} + is used in conjunction with @code{gnatprep} to compile files that + contain preprocessing statements and multiple units. + + @item -v + @cindex @code{-v} (@code{gnatchop}) + Causes @code{gnatchop} to operate in verbose mode. The version + number and copyright notice are output, as well as exact copies of + the gnat1 commands spawned to obtain the chop control information. + + @item -w + @cindex @code{-w} (@code{gnatchop}) + Overwrite existing file names. Normally @code{gnatchop} regards it as a + fatal error if there is already a file with the same name as a + file it would otherwise output, in other words if the files to be + chopped contain duplicated units. This switch bypasses this + check, and causes all but the last instance of such duplicated + units to be skipped. + + @item --GCC=xxxx + @cindex @code{--GCC=} (@code{gnatchop}) + Specify the path of the GNAT parser to be used. When this switch is used, + no attempt is made to add the prefix to the GNAT parser executable. + @end table + + @node Examples of gnatchop Usage + @section Examples of @code{gnatchop} Usage + + @table @code + @item gnatchop -w hello_s.ada ichbiah/files + + Chops the source file @file{hello_s.ada}. The output files will be + placed in the directory @file{ichbiah/files}, + overwriting any + files with matching names in that directory (no files in the current + directory are modified). + + @item gnatchop archive + Chops the source file @file{archive} + into the current directory. One + useful application of @code{gnatchop} is in sending sets of sources + around, for example in email messages. The required sources are simply + concatenated (for example, using a Unix @code{cat} + command), and then + @code{gnatchop} is used at the other end to reconstitute the original + file names. + + @item gnatchop file1 file2 file3 direc + Chops all units in files @file{file1}, @file{file2}, @file{file3}, placing + the resulting files in the directory @file{direc}. Note that if any units + occur more than once anywhere within this set of files, an error message + is generated, and no files are written. To override this check, use the + @code{-w} switch, + in which case the last occurrence in the last file will + be the one that is output, and earlier duplicate occurrences for a given + unit will be skipped. + @end table + + @node Configuration Pragmas + @chapter Configuration Pragmas + @cindex Configuration pragmas + @cindex Pragmas, configuration + + @noindent + In Ada 95, configuration pragmas include those pragmas described as + such in the Ada 95 Reference Manual, as well as + implementation-dependent pragmas that are configuration pragmas. See the + individual descriptions of pragmas in the GNAT Reference Manual for + details on these additional GNAT-specific configuration pragmas. Most + notably, the pragma @code{Source_File_Name}, which allows + specifying non-default names for source files, is a configuration + pragma. The following is a complete list of configuration pragmas + recognized by @code{GNAT}: + + @smallexample + Ada_83 + Ada_95 + C_Pass_By_Copy + Component_Alignment + Discard_Names + Elaboration_Checks + Eliminate + Extend_System + Extensions_Allowed + External_Name_Casing + Float_Representation + Initialize_Scalars + License + Locking_Policy + Long_Float + No_Run_Time + Normalize_Scalars + Polling + Propagate_Exceptions + Queuing_Policy + Ravenscar + Restricted_Run_Time + Restrictions + Reviewable + Source_File_Name + Style_Checks + Suppress + Task_Dispatching_Policy + Unsuppress + Use_VADS_Size + Warnings + Validity_Checks + @end smallexample + + @menu + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + @end menu + + @node Handling of Configuration Pragmas + @section Handling of Configuration Pragmas + + Configuration pragmas may either appear at the start of a compilation + unit, in which case they apply only to that unit, or they may apply to + all compilations performed in a given compilation environment. + + GNAT also provides the @code{gnatchop} utility to provide an automatic + way to handle configuration pragmas following the semantics for + compilations (that is, files with multiple units), described in the RM. + See section @pxref{Operating gnatchop in Compilation Mode} for details. + However, for most purposes, it will be more convenient to edit the + @file{gnat.adc} file that contains configuration pragmas directly, + as described in the following section. + + @node The Configuration Pragmas Files + @section The Configuration Pragmas Files + @cindex @file{gnat.adc} + + @noindent + In GNAT a compilation environment is defined by the current + directory at the time that a compile command is given. This current + directory is searched for a file whose name is @file{gnat.adc}. If + this file is present, it is expected to contain one or more + configuration pragmas that will be applied to the current compilation. + However, if the switch @option{-gnatA} is used, @file{gnat.adc} is not + considered. + + Configuration pragmas may be entered into the @file{gnat.adc} file + either by running @code{gnatchop} on a source file that consists only of + configuration pragmas, or more conveniently by + direct editing of the @file{gnat.adc} file, which is a standard format + source file. + + In addition to @file{gnat.adc}, one additional file containing configuration + pragmas may be applied to the current compilation using the switch + @option{-gnatec}@var{path}. @var{path} must designate an existing file that + contains only configuration pragmas. These configuration pragmas are + in addition to those found in @file{gnat.adc} (provided @file{gnat.adc} + is present and switch @option{-gnatA} is not used). + + It is allowed to specify several switches @option{-gnatec}, however only + the last one on the command line will be taken into account. + + + @node Handling Arbitrary File Naming Conventions Using gnatname + @chapter Handling Arbitrary File Naming Conventions Using @code{gnatname} + @cindex Arbitrary File Naming Conventions + + @menu + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + @end menu + + @node Arbitrary File Naming Conventions + @section Arbitrary File Naming Conventions + + @noindent + The GNAT compiler must be able to know the source file name of a compilation unit. + When using the standard GNAT default file naming conventions (@code{.ads} for specs, + @code{.adb} for bodies), the GNAT compiler does not need additional information. + + @noindent + When the source file names do not follow the standard GNAT default file naming + conventions, the GNAT compiler must be given additional information through + a configuration pragmas file (see @ref{Configuration Pragmas}) or a project file. + When the non standard file naming conventions are well-defined, a small number of + pragmas @code{Source_File_Name} specifying a naming pattern + (see @ref{Alternative File Naming Schemes}) may be sufficient. However, + if the file naming conventions are irregular or arbitrary, a number + of pragma @code{Source_File_Name} for individual compilation units must be defined. + To help maintain the correspondence between compilation unit names and + source file names within the compiler, + GNAT provides a tool @code{gnatname} to generate the required pragmas for a + set of files. + + @node Running gnatname + @section Running @code{gnatname} + + @noindent + The usual form of the @code{gnatname} command is + + @smallexample + $ gnatname [@var{switches}] @var{naming_pattern} [@var{naming_patterns}] + @end smallexample + + @noindent + All of the arguments are optional. If invoked without any argument, + @code{gnatname} will display its usage. + + @noindent + When used with at least one naming pattern, @code{gnatname} will attempt to + find all the compilation units in files that follow at least one of the + naming patterns. To find these compilation units, + @code{gnatname} will use the GNAT compiler in syntax-check-only mode on all + regular files. + + @noindent + One or several Naming Patterns may be given as arguments to @code{gnatname}. + Each Naming Pattern is enclosed between double quotes. + A Naming Pattern is a regular expression similar to the wildcard patterns + used in file names by the Unix shells or the DOS prompt. + + @noindent + Examples of Naming Patterns are + + @smallexample + "*.[12].ada" + "*.ad[sb]*" + "body_*" "spec_*" + @end smallexample + + @noindent + For a more complete description of the syntax of Naming Patterns, see the second kind + of regular expressions described in @file{g-regexp.ads} (the "Glob" regular + expressions). + + @noindent + When invoked with no switches, @code{gnatname} will create a configuration + pragmas file @file{gnat.adc} in the current working directory, with pragmas + @code{Source_File_Name} for each file that contains a valid Ada unit. + + @node Switches for gnatname + @section Switches for @code{gnatname} + + @noindent + Switches for @code{gnatname} must precede any specified Naming Pattern. + + @noindent + You may specify any of the following switches to @code{gnatname}: + + @table @code + + @item -c@file{file} + @cindex @code{-c} (@code{gnatname}) + Create a configuration pragmas file @file{file} (instead of the default + @file{gnat.adc}). There may be zero, one or more space between @code{-c} and + @file{file}. @file{file} may include directory information. @file{file} must be + writeable. There may be only one switch @code{-c}. When a switch @code{-c} is + specified, no switch @code{-P} may be specified (see below). + + @item -d@file{dir} + @cindex @code{-d} (@code{gnatname}) + Look for source files in directory @file{dir}. There may be zero, one or more spaces + between @code{-d} and @file{dir}. When a switch @code{-d} is specified, + the current working directory will not be searched for source files, unless it + is explictly + specified with a @code{-d} or @code{-D} switch. Several switches @code{-d} may be + specified. If @file{dir} is a relative path, it is relative to the directory of + the configuration pragmas file specified with switch @code{-c}, or to the directory + of the project file specified with switch @code{-P} or, if neither switch @code{-c} + nor switch @code{-P} are specified, it is relative to the current working + directory. The directory + specified with switch @code{-c} must exist and be readable. + + @item -D@file{file} + @cindex @code{-D} (@code{gnatname}) + Look for source files in all directories listed in text file @file{file}. There may be + zero, one or more spaces between @code{-d} and @file{dir}. @file{file} + must be an existing, readable text file. Each non empty line in @file{file} must be + a directory. Specifying switch @code{-D} is equivalent to specifying as many switches + @code{-d} as there are non empty lines in @file{file}. + + @item -h + @cindex @code{-h} (@code{gnatname}) + Output usage (help) information. The output is written to @file{stdout}. + + @item -P@file{proj} + @cindex @code{-P} (@code{gnatname}) + Create or update project file @file{proj}. There may be zero, one or more space + between @code{-P} and @file{proj}. @file{proj} may include directory information. + @file{proj} must be writeable. There may be only one switch @code{-P}. + When a switch @code{-P} is specified, no switch @code{-c} may be specified. + + @item -v + @cindex @code{-v} (@code{gnatname}) + Verbose mode. Output detailed explanation of behavior to @file{stdout}. This includes + name of the file written, the name of the directories to search and, for each file + in those directories whose name matches at least one of the Naming Patterns, an + indication of whether the file contains a unit, and if so the name of the unit. + + @item -v -v + Very Verbose mode. In addition to the output produced in verbose mode, for each file + in the searched directories whose name matches none of the Naming Patterns, an + indication is given that there is no match. + + @item -x@file{pattern} + Excluded patterns. Using this switch, it is possible to exclude some files + that would match the name patterns. For example, + @code{"gnatname -x "*_nt.ada" "*.ada"} will look for Ada units in all files + with the @file{.ada} extension, except those whose names end with + @file{_nt.ada}. + + @end table + + @node Examples of gnatname Usage + @section Examples of @code{gnatname} Usage + + @smallexample + $ gnatname -c /home/me/names.adc -d sources "[a-z]*.ada*" + @end smallexample + + In this example, the directory @file{/home/me} must already exist and be + writeable. In addition, the directory @file{/home/me/sources} (specified by + @code{-d sources}) must exist and be readable. Note the optional spaces after + @code{-c} and @code{-d}. + + @smallexample + $ gnatname -P/home/me/proj -x "*_nt_body.ada" -dsources -dsources/plus -Dcommon_dirs.txt "body_*" "spec_*" + @end smallexample + + Note that several switches @code{-d} may be used, even in conjunction with one + or several switches @code{-D}. Several Naming Patterns and one excluded pattern + are used in this example. + + + @c ***************************************** + @c * G N A T P r o j e c t M a n a g e r * + @c ***************************************** + @node GNAT Project Manager + @chapter GNAT Project Manager + + @menu + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + @end menu + + + @c **************** + @c * Introduction * + @c **************** + + @node Introduction + @section Introduction + + @noindent + This chapter describes GNAT's @emph{Project Manager}, a facility that + lets you configure various properties for a collection of source files. In + particular, you can specify: + @itemize @bullet + @item + The directory or set of directories containing the source files, and/or the + names of the specific source files themselves + @item + The directory in which the compiler's output + (@file{ALI} files, object files, tree files) will be placed + @item + The directory in which the executable programs will be placed + @item + Switch settings for any of the project-enabled tools (@command{gnatmake}, + compiler, binder, linker, @code{gnatls}, @code{gnatxref}, @code{gnatfind}); + you can apply these settings either globally or to individual units + @item + The source files containing the main subprogram(s) to be built + @item + The source programming language(s) (currently Ada and/or C) + @item + Source file naming conventions; you can specify these either globally or for + individual units + @end itemize + + @menu + * Project Files:: + @end menu + + @node Project Files + @subsection Project Files + + @noindent + A @dfn{project} is a specific set of values for these properties. You can + define a project's settings in a @dfn{project file}, a text file with an + Ada-like syntax; a property value is either a string or a list of strings. + Properties that are not explicitly set receive default values. A project + file may interrogate the values of @dfn{external variables} (user-defined + command-line switches or environment variables), and it may specify property + settings conditionally, based on the value of such variables. + + In simple cases, a project's source files depend only on other source files + in the same project, or on the predefined libraries. ("Dependence" is in + the technical sense; for example, one Ada unit "with"ing another.) However, + the Project Manager also allows much more sophisticated arrangements, + with the source files in one project depending on source files in other + projects: + @itemize @bullet + @item + One project can @emph{import} other projects containing needed source files. + @item + You can organize GNAT projects in a hierarchy: a @emph{child} project + can extend a @emph{parent} project, inheriting the parent's source files and + optionally overriding any of them with alternative versions + @end itemize + + @noindent + More generally, the Project Manager lets you structure large development + efforts into hierarchical subsystems, with build decisions deferred to the + subsystem level and thus different compilation environments (switch settings) + used for different subsystems. + + The Project Manager is invoked through the @option{-P@emph{projectfile}} + switch to @command{gnatmake} or to the @command{gnat} front driver. + If you want to define (on the command line) an external variable that is + queried by the project file, additionally use the + @option{-X@emph{vbl}=@emph{value}} switch. + The Project Manager parses and interprets the project file, and drives the + invoked tool based on the project settings. + + The Project Manager supports a wide range of development strategies, + for systems of all sizes. Some typical practices that are easily handled: + @itemize @bullet + @item + Using a common set of source files, but generating object files in different + directories via different switch settings + @item + Using a mostly-shared set of source files, but with different versions of + some unit or units + @end itemize + + @noindent + The destination of an executable can be controlled inside a project file + using the @option{-o} switch. In the absence of such a switch either inside + the project file or on the command line, any executable files generated by + @command{gnatmake} will be placed in the directory @code{Exec_Dir} specified + in the project file. If no @code{Exec_Dir} is specified, they will be placed + in the object directory of the project. + + You can use project files to achieve some of the effects of a source + versioning system (for example, defining separate projects for + the different sets of sources that comprise different releases) but the + Project Manager is independent of any source configuration management tools + that might be used by the developers. + + The next section introduces the main features of GNAT's project facility + through a sequence of examples; subsequent sections will present the syntax + and semantics in more detail. + + + @c ***************************** + @c * Examples of Project Files * + @c ***************************** + + @node Examples of Project Files + @section Examples of Project Files + @noindent + This section illustrates some of the typical uses of project files and + explains their basic structure and behavior. + + @menu + * Common Sources with Different Switches and Different Output Directories:: + * Using External Variables:: + * Importing Other Projects:: + * Extending a Project:: + @end menu + + @node Common Sources with Different Switches and Different Output Directories + @subsection Common Sources with Different Switches and Different Output Directories + + @menu + * Source Files:: + * Specifying the Object Directory:: + * Specifying the Exec Directory:: + * Project File Packages:: + * Specifying Switch Settings:: + * Main Subprograms:: + * Source File Naming Conventions:: + * Source Language(s):: + @end menu + + @noindent + Assume that the Ada source files @file{pack.ads}, @file{pack.adb}, and + @file{proc.adb} are in the @file{/common} directory. The file + @file{proc.adb} contains an Ada main subprogram @code{Proc} that "with"s + package @code{Pack}. We want to compile these source files under two sets + of switches: + @itemize @bullet + @item + When debugging, we want to pass the @option{-g} switch to @command{gnatmake}, + and the @option{-gnata}, @option{-gnato}, and @option{-gnatE} switches to the + compiler; the compiler's output is to appear in @file{/common/debug} + @item + When preparing a release version, we want to pass the @option{-O2} switch to + the compiler; the compiler's output is to appear in @file{/common/release} + @end itemize + + @noindent + The GNAT project files shown below, respectively @file{debug.gpr} and + @file{release.gpr} in the @file{/common} directory, achieve these effects. + + Diagrammatically: + @smallexample + @group + /common + debug.gpr + release.gpr + pack.ads + pack.adb + proc.adb + @end group + @group + /common/debug @{-g, -gnata, -gnato, -gnatE@} + proc.ali, proc.o + pack.ali, pack.o + @end group + @group + /common/release @{-O2@} + proc.ali, proc.o + pack.ali, pack.o + @end group + @end smallexample + Here are the project files: + @smallexample + @group + project Debug is + for Object_Dir use "debug"; + for Main use ("proc"); + + package Builder is + for Default_Switches ("Ada") use ("-g"); + end Builder; + @end group + + @group + package Compiler is + for Default_Switches ("Ada") + use ("-fstack-check", "-gnata", "-gnato", "-gnatE"); + end Compiler; + end Debug; + @end group + @end smallexample + + @smallexample + @group + project Release is + for Object_Dir use "release"; + for Exec_Dir use "."; + for Main use ("proc"); + + package Compiler is + for Default_Switches ("Ada") use ("-O2"); + end Compiler; + end Release; + @end group + @end smallexample + + @noindent + The name of the project defined by @file{debug.gpr} is @code{"Debug"} (case + insensitive), and analogously the project defined by @file{release.gpr} is + @code{"Release"}. For consistency the file should have the same name as the + project, and the project file's extension should be @code{"gpr"}. These + conventions are not required, but a warning is issued if they are not followed. + + If the current directory is @file{/temp}, then the command + @smallexample + gnatmake -P/common/debug.gpr + @end smallexample + + @noindent + generates object and ALI files in @file{/common/debug}, and the @code{proc} + executable also in @file{/common/debug}, using the switch settings defined in + the project file. + + Likewise, the command + @smallexample + gnatmake -P/common/release.gpr + @end smallexample + + @noindent + generates object and ALI files in @file{/common/release}, and the @code{proc} + executable in @file{/common}, using the switch settings from the project file. + + @node Source Files + @unnumberedsubsubsec Source Files + + @noindent + If a project file does not explicitly specify a set of source directories or + a set of source files, then by default the project's source files are the + Ada source files in the project file directory. Thus @file{pack.ads}, + @file{pack.adb}, and @file{proc.adb} are the source files for both projects. + + @node Specifying the Object Directory + @unnumberedsubsubsec Specifying the Object Directory + + @noindent + Several project properties are modeled by Ada-style @emph{attributes}; + you define the property by supplying the equivalent of an Ada attribute + definition clause in the project file. + A project's object directory is such a property; the corresponding + attribute is @code{Object_Dir}, and its value is a string expression. A + directory may be specified either as absolute or as relative; in the latter + case, it is relative to the project file directory. Thus the compiler's + output is directed to @file{/common/debug} (for the @code{Debug} project) + and to @file{/common/release} (for the @code{Release} project). If + @code{Object_Dir} is not specified, then the default is the project file + directory. + + @node Specifying the Exec Directory + @unnumberedsubsubsec Specifying the Exec Directory + + @noindent + A project's exec directory is another property; the corresponding + attribute is @code{Exec_Dir}, and its value is also a string expression, + either specified as relative or absolute. If @code{Exec_Dir} is not specified, + then the default is the object directory (which may also be the project file + directory if attribute @code{Object_Dir} is not specified). Thus the executable + is placed in @file{/common/debug} for the @code{Debug} project (attribute + @code{Exec_Dir} not specified) and in @file{/common} for the @code{Release} + project. + + @node Project File Packages + @unnumberedsubsubsec Project File Packages + + @noindent + A GNAT tool integrated with the Project Manager is modeled by a + corresponding package in the project file. + The @code{Debug} project defines the packages @code{Builder} + (for @command{gnatmake}) and @code{Compiler}; + the @code{Release} project defines only the @code{Compiler} package. + + The Ada package syntax is not to be taken literally. Although packages in + project files bear a surface resemblance to packages in Ada source code, the + notation is simply a way to convey a grouping of properties for a named + entity. Indeed, the package names permitted in project files are restricted + to a predefined set, corresponding to the project-aware tools, and the contents + of packages are limited to a small set of constructs. + The packages in the example above contain attribute definitions. + + + @node Specifying Switch Settings + @unnumberedsubsubsec Specifying Switch Settings + + @noindent + Switch settings for a project-aware tool can be specified through attributes + in the package corresponding to the tool. + The example above illustrates one of the relevant attributes, + @code{Default_Switches}, defined in the packages in both project files. + Unlike simple attributes like @code{Source_Dirs}, @code{Default_Switches} is + known as an @emph{associative array}. When you define this attribute, you must + supply an "index" (a literal string), and the effect of the attribute + definition is to set the value of the "array" at the specified "index". + For the @code{Default_Switches} attribute, the index is a programming + language (in our case, Ada) , and the value specified (after @code{use}) + must be a list of string expressions. + + The attributes permitted in project files are restricted to a predefined set. + Some may appear at project level, others in packages. + For any attribute that is an associate array, the index must always be a + literal string, but the restrictions on this string (e.g., a file name or a + language name) depend on the individual attribute. + Also depending on the attribute, its specified value will need to be either a + string or a string list. + + In the @code{Debug} project, we set the switches for two tools, + @command{gnatmake} and the compiler, and thus we include corresponding + packages, with each package defining the @code{Default_Switches} attribute + with index @code{"Ada"}. + Note that the package corresponding to + @command{gnatmake} is named @code{Builder}. The @code{Release} project is + similar, but with just the @code{Compiler} package. + + In project @code{Debug} above the switches starting with @option{-gnat} that + are specified in package @code{Compiler} could have been placed in package + @code{Builder}, since @command{gnatmake} transmits all such switches to the + compiler. + + @node Main Subprograms + @unnumberedsubsubsec Main Subprograms + + @noindent + One of the properties of a project is its list of main subprograms (actually + a list of names of source files containing main subprograms, with the file + extension optional. This property is captured in the @code{Main} attribute, + whose value is a list of strings. If a project defines the @code{Main} + attribute, then you do not need to identify the main subprogram(s) when + invoking @command{gnatmake} (see @ref{gnatmake and Project Files}). + + @node Source File Naming Conventions + @unnumberedsubsubsec Source File Naming Conventions + + @noindent + Since the project files do not specify any source file naming conventions, + the GNAT defaults are used. The mechanism for defining source file naming + conventions -- a package named @code{Naming} -- will be described below + (@pxref{Naming Schemes}). + + @node Source Language(s) + @unnumberedsubsubsec Source Language(s) + + @noindent + Since the project files do not specify a @code{Languages} attribute, by + default the GNAT tools assume that the language of the project file is Ada. + More generally, a project can comprise source files + in Ada, C, and/or other languages. + + @node Using External Variables + @subsection Using External Variables + + @noindent + Instead of supplying different project files for debug and release, we can + define a single project file that queries an external variable (set either + on the command line or via an environment variable) in order to + conditionally define the appropriate settings. Again, assume that the + source files @file{pack.ads}, @file{pack.adb}, and @file{proc.adb} are + located in directory @file{/common}. The following project file, + @file{build.gpr}, queries the external variable named @code{STYLE} and + defines an object directory and switch settings based on whether the value + is @code{"deb"} (debug) or @code{"rel"} (release), where the default is + @code{"deb"}. + + @smallexample + @group + project Build is + for Main use ("proc"); + + type Style_Type is ("deb", "rel"); + Style : Style_Type := external ("STYLE", "deb"); + + case Style is + when "deb" => + for Object_Dir use "debug"; + + when "rel" => + for Object_Dir use "release"; + for Exec_Dir use "."; + end case; + @end group + + @group + package Builder is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-g"); + end case; + + end Builder; + @end group + + @group + package Compiler is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-gnata", "-gnato", "-gnatE"); + + when "rel" => + for Default_Switches ("Ada") use ("-O2"); + end case; + + end Compiler; + + end Build; + @end group + @end smallexample + + @noindent + @code{Style_Type} is an example of a @emph{string type}, which is the project + file analog of an Ada enumeration type but containing string literals rather + than identifiers. @code{Style} is declared as a variable of this type. + + The form @code{external("STYLE", "deb")} is known as an + @emph{external reference}; its first argument is the name of an + @emph{external variable}, and the second argument is a default value to be + used if the external variable doesn't exist. You can define an external + variable on the command line via the @option{-X} switch, or you can use an + environment variable as an external variable. + + Each @code{case} construct is expanded by the Project Manager based on the + value of @code{Style}. Thus the command + @smallexample + gnatmake -P/common/build.gpr -XSTYLE=deb + @end smallexample + + @noindent + is equivalent to the @command{gnatmake} invocation using the project file + @file{debug.gpr} in the earlier example. So is the command + @smallexample + gnatmake -P/common/build.gpr + @end smallexample + + @noindent + since @code{"deb"} is the default for @code{STYLE}. + + Analogously, + @smallexample + gnatmake -P/common/build.gpr -XSTYLE=rel + @end smallexample + + @noindent + is equivalent to the @command{gnatmake} invocation using the project file + @file{release.gpr} in the earlier example. + + + @node Importing Other Projects + @subsection Importing Other Projects + + @noindent + A compilation unit in a source file in one project may depend on compilation + units in source files in other projects. To obtain this behavior, the + dependent project must @emph{import} the projects containing the needed source + files. This effect is embodied in syntax similar to an Ada @code{with} clause, + but the "with"ed entities are strings denoting project files. + + As an example, suppose that the two projects @code{GUI_Proj} and + @code{Comm_Proj} are defined in the project files @file{gui_proj.gpr} and + @file{comm_proj.gpr} in directories @file{/gui} and @file{/comm}, + respectively. Assume that the source files for @code{GUI_Proj} are + @file{gui.ads} and @file{gui.adb}, and that the source files for + @code{Comm_Proj} are @file{comm.ads} and @file{comm.adb}, with each set of + files located in its respective project file directory. Diagrammatically: + + @smallexample + @group + /gui + gui_proj.gpr + gui.ads + gui.adb + @end group + + @group + /comm + comm_proj.gpr + comm.ads + comm.adb + @end group + @end smallexample + + @noindent + We want to develop an application in directory @file{/app} that "with"s the + packages @code{GUI} and @code{Comm}, using the properties of the + corresponding project files (e.g. the switch settings and object directory). + Skeletal code for a main procedure might be something like the following: + + @smallexample + @group + with GUI, Comm; + procedure App_Main is + ... + begin + ... + end App_Main; + @end group + @end smallexample + + @noindent + Here is a project file, @file{app_proj.gpr}, that achieves the desired + effect: + + @smallexample + @group + with "/gui/gui_proj", "/comm/comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + @end group + @end smallexample + + @noindent + Building an executable is achieved through the command: + @smallexample + gnatmake -P/app/app_proj + @end smallexample + @noindent + which will generate the @code{app_main} executable in the directory where + @file{app_proj.gpr} resides. + + If an imported project file uses the standard extension (@code{gpr}) then + (as illustrated above) the @code{with} clause can omit the extension. + + Our example specified an absolute path for each imported project file. + Alternatively, you can omit the directory if either + @itemize @bullet + @item + The imported project file is in the same directory as the importing project + file, or + @item + You have defined an environment variable @code{ADA_PROJECT_PATH} that + includes the directory containing the needed project file. + @end itemize + + @noindent + Thus, if we define @code{ADA_PROJECT_PATH} to include @file{/gui} and + @file{/comm}, then our project file @file{app_proj.gpr} could be written as + follows: + + @smallexample + @group + with "gui_proj", "comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + @end group + @end smallexample + + @noindent + Importing other projects raises the possibility of ambiguities. For + example, the same unit might be present in different imported projects, or + it might be present in both the importing project and an imported project. + Both of these conditions are errors. Note that in the current version of + the Project Manager, it is illegal to have an ambiguous unit even if the + unit is never referenced by the importing project. This restriction may be + relaxed in a future release. + + @node Extending a Project + @subsection Extending a Project + + @noindent + A common situation in large software systems is to have multiple + implementations for a common interface; in Ada terms, multiple versions of a + package body for the same specification. For example, one implementation + might be safe for use in tasking programs, while another might only be used + in sequential applications. This can be modeled in GNAT using the concept + of @emph{project extension}. If one project (the "child") @emph{extends} + another project (the "parent") then by default all source files of the + parent project are inherited by the child, but the child project can + override any of the parent's source files with new versions, and can also + add new files. This facility is the project analog of extension in + Object-Oriented Programming. Project hierarchies are permitted (a child + project may be the parent of yet another project), and a project that + inherits one project can also import other projects. + + As an example, suppose that directory @file{/seq} contains the project file + @file{seq_proj.gpr} and the source files @file{pack.ads}, @file{pack.adb}, + and @file{proc.adb}: + + @smallexample + @group + /seq + pack.ads + pack.adb + proc.adb + seq_proj.gpr + @end group + @end smallexample + + @noindent + Note that the project file can simply be empty (that is, no attribute or + package is defined): + + @smallexample + @group + project Seq_Proj is + end Seq_Proj; + @end group + @end smallexample + + @noindent + implying that its source files are all the Ada source files in the project + directory. + + Suppose we want to supply an alternate version of @file{pack.adb}, in + directory @file{/tasking}, but use the existing versions of @file{pack.ads} + and @file{proc.adb}. We can define a project @code{Tasking_Proj} that + inherits @code{Seq_Proj}: + + @smallexample + @group + /tasking + pack.adb + tasking_proj.gpr + @end group + + @group + project Tasking_Proj extends "/seq/seq_proj" is + end Tasking_Proj; + @end group + @end smallexample + + @noindent + The version of @file{pack.adb} used in a build depends on which project file + is specified. + + Note that we could have designed this using project import rather than + project inheritance; a @code{base} project would contain the sources for + @file{pack.ads} and @file{proc.adb}, a sequential project would import + @code{base} and add @file{pack.adb}, and likewise a tasking project would + import @code{base} and add a different version of @file{pack.adb}. The + choice depends on whether other sources in the original project need to be + overridden. If they do, then project extension is necessary, otherwise, + importing is sufficient. + + + @c *********************** + @c * Project File Syntax * + @c *********************** + + @node Project File Syntax + @section Project File Syntax + + @menu + * Basic Syntax:: + * Packages:: + * Expressions:: + * String Types:: + * Variables:: + * Attributes:: + * Associative Array Attributes:: + * case Constructions:: + @end menu + + @noindent + This section describes the structure of project files. + + A project may be an @emph{independent project}, entirely defined by a single + project file. Any Ada source file in an independent project depends only + on the predefined library and other Ada source files in the same project. + + @noindent + A project may also @dfn{depend on} other projects, in either or both of the following ways: + @itemize @bullet + @item It may import any number of projects + @item It may extend at most one other project + @end itemize + + @noindent + The dependence relation is a directed acyclic graph (the subgraph reflecting + the "extends" relation is a tree). + + A project's @dfn{immediate sources} are the source files directly defined by + that project, either implicitly by residing in the project file's directory, + or explicitly through any of the source-related attributes described below. + More generally, a project @var{proj}'s @dfn{sources} are the immediate sources + of @var{proj} together with the immediate sources (unless overridden) of any + project on which @var{proj} depends (either directly or indirectly). + + @node Basic Syntax + @subsection Basic Syntax + + @noindent + As seen in the earlier examples, project files have an Ada-like syntax. + The minimal project file is: + @smallexample + @group + project Empty is + + end Empty; + @end group + @end smallexample + + @noindent + The identifier @code{Empty} is the name of the project. + This project name must be present after the reserved + word @code{end} at the end of the project file, followed by a semi-colon. + + Any name in a project file, such as the project name or a variable name, + has the same syntax as an Ada identifier. + + The reserved words of project files are the Ada reserved words plus + @code{extends}, @code{external}, and @code{project}. Note that the only Ada + reserved words currently used in project file syntax are: + + @itemize @bullet + @item + @code{case} + @item + @code{end} + @item + @code{for} + @item + @code{is} + @item + @code{others} + @item + @code{package} + @item + @code{renames} + @item + @code{type} + @item + @code{use} + @item + @code{when} + @item + @code{with} + @end itemize + + @noindent + Comments in project files have the same syntax as in Ada, two consecutives + hyphens through the end of the line. + + @node Packages + @subsection Packages + + @noindent + A project file may contain @emph{packages}. The name of a package must be one + of the identifiers (case insensitive) from a predefined list, and a package + with a given name may only appear once in a project file. The predefined list + includes the following packages: + + @itemize @bullet + @item + @code{Naming} + @item + @code{Builder} + @item + @code{Compiler} + @item + @code{Binder} + @item + @code{Linker} + @item + @code{Finder} + @item + @code{Cross_Reference} + @item + @code{gnatls} + @end itemize + + @noindent + (The complete list of the package names and their attributes can be found + in file @file{prj-attr.adb}). + + @noindent + In its simplest form, a package may be empty: + + @smallexample + @group + project Simple is + package Builder is + end Builder; + end Simple; + @end group + @end smallexample + + @noindent + A package may contain @emph{attribute declarations}, + @emph{variable declarations} and @emph{case constructions}, as will be + described below. + + When there is ambiguity between a project name and a package name, + the name always designates the project. To avoid possible confusion, it is + always a good idea to avoid naming a project with one of the + names allowed for packages or any name that starts with @code{gnat}. + + + @node Expressions + @subsection Expressions + + @noindent + An @emph{expression} is either a @emph{string expression} or a + @emph{string list expression}. + + A @emph{string expression} is either a @emph{simple string expression} or a + @emph{compound string expression}. + + A @emph{simple string expression} is one of the following: + @itemize @bullet + @item A literal string; e.g.@code{"comm/my_proj.gpr"} + @item A string-valued variable reference (see @ref{Variables}) + @item A string-valued attribute reference (see @ref{Attributes}) + @item An external reference (see @ref{External References in Project Files}) + @end itemize + + @noindent + A @emph{compound string expression} is a concatenation of string expressions, + using @code{"&"} + @smallexample + Path & "/" & File_Name & ".ads" + @end smallexample + + @noindent + A @emph{string list expression} is either a + @emph{simple string list expression} or a + @emph{compound string list expression}. + + A @emph{simple string list expression} is one of the following: + @itemize @bullet + @item A parenthesized list of zero or more string expressions, separated by commas + @smallexample + File_Names := (File_Name, "gnat.adc", File_Name & ".orig"); + Empty_List := (); + @end smallexample + @item A string list-valued variable reference + @item A string list-valued attribute reference + @end itemize + + @noindent + A @emph{compound string list expression} is the concatenation (using + @code{"&"}) of a simple string list expression and an expression. Note that + each term in a compound string list expression, except the first, may be + either a string expression or a string list expression. + + @smallexample + @group + File_Name_List := () & File_Name; -- One string in this list + Extended_File_Name_List := File_Name_List & (File_Name & ".orig"); + -- Two strings + Big_List := File_Name_List & Extended_File_Name_List; + -- Concatenation of two string lists: three strings + Illegal_List := "gnat.adc" & Extended_File_Name_List; + -- Illegal: must start with a string list + @end group + @end smallexample + + + @node String Types + @subsection String Types + + @noindent + The value of a variable may be restricted to a list of string literals. + The restricted list of string literals is given in a + @emph{string type declaration}. + + Here is an example of a string type declaration: + + @smallexample + type OS is ("NT, "nt", "Unix", "Linux", "other OS"); + @end smallexample + + @noindent + Variables of a string type are called @emph{typed variables}; all other + variables are called @emph{untyped variables}. Typed variables are + particularly useful in @code{case} constructions + (see @ref{case Constructions}). + + A string type declaration starts with the reserved word @code{type}, followed + by the name of the string type (case-insensitive), followed by the reserved + word @code{is}, followed by a parenthesized list of one or more string literals + separated by commas, followed by a semicolon. + + The string literals in the list are case sensitive and must all be different. + They may include any graphic characters allowed in Ada, including spaces. + + A string type may only be declared at the project level, not inside a package. + + A string type may be referenced by its name if it has been declared in the same + project file, or by its project name, followed by a dot, + followed by the string type name. + + + @node Variables + @subsection Variables + + @noindent + A variable may be declared at the project file level, or in a package. + Here are some examples of variable declarations: + + @smallexample + @group + This_OS : OS := external ("OS"); -- a typed variable declaration + That_OS := "Linux"; -- an untyped variable declaration + @end group + @end smallexample + + @noindent + A @emph{typed variable declaration} includes the variable name, followed by a colon, + followed by the name of a string type, followed by @code{:=}, followed by + a simple string expression. + + An @emph{untyped variable declaration} includes the variable name, + followed by @code{:=}, followed by an expression. Note that, despite the + terminology, this form of "declaration" resembles more an assignment + than a declaration in Ada. It is a declaration in several senses: + @itemize @bullet + @item + The variable name does not need to be defined previously + @item + The declaration establishes the @emph{kind} (string versus string list) of the + variable, and later declarations of the same variable need to be consistent + with this + @end itemize + + @noindent + A string variable declaration (typed or untyped) declares a variable + whose value is a string. This variable may be used as a string expression. + @smallexample + File_Name := "readme.txt"; + Saved_File_Name := File_Name & ".saved"; + @end smallexample + + @noindent + A string list variable declaration declares a variable whose value is a list + of strings. The list may contain any number (zero or more) of strings. + + @smallexample + Empty_List := (); + List_With_One_Element := ("-gnaty"); + List_With_Two_Elements := List_With_One_Element & "-gnatg"; + Long_List := ("main.ada", "pack1_.ada", "pack1.ada", "pack2_.ada" + "pack2.ada", "util_.ada", "util.ada"); + @end smallexample + + @noindent + The same typed variable may not be declared more than once at project level, and it may not be declared more than once in any package; it is in effect a constant or a readonly variable. + + The same untyped variable may be declared several times. + In this case, the new value replaces the old one, + and any subsequent reference to the variable uses the new value. + However, as noted above, if a variable has been declared as a string, all subsequent + declarations must give it a string value. Similarly, if a variable has + been declared as a string list, all subsequent declarations + must give it a string list value. + + A @emph{variable reference} may take several forms: + + @itemize @bullet + @item The simple variable name, for a variable in the current package (if any) or in the current project + @item A context name, followed by a dot, followed by the variable name. + @end itemize + + @noindent + A @emph{context} may be one of the following: + + @itemize @bullet + @item The name of an existing package in the current project + @item The name of an imported project of the current project + @item The name of an ancestor project (i.e., a project extended by the current project, either directly or indirectly) + @item An imported/parent project name, followed by a dot, followed by a package name + @end itemize + + @noindent + A variable reference may be used in an expression. + + + @node Attributes + @subsection Attributes + + @noindent + A project (and its packages) may have @emph{attributes} that define the project's properties. + Some attributes have values that are strings; + others have values that are string lists. + + There are two categories of attributes: @emph{simple attributes} and @emph{associative arrays} + (see @ref{Associative Array Attributes}). + + The names of the attributes are restricted; there is a list of project + attributes, and a list of package attributes for each package. + The names are not case sensitive. + + The project attributes are as follows (all are simple attributes): + + @multitable @columnfractions .4 .3 + @item @emph{Attribute Name} + @tab @emph{Value} + @item @code{Source_Files} + @tab string list + @item @code{Source_Dirs} + @tab string list + @item @code{Source_List_File} + @tab string + @item @code{Object_Dir} + @tab string + @item @code{Exec_Dir} + @tab string + @item @code{Main} + @tab string list + @item @code{Languages} + @tab string list + @item @code{Library_Dir} + @tab string + @item @code{Library_Name} + @tab string + @item @code{Library_Kind} + @tab string + @item @code{Library_Elaboration} + @tab string + @item @code{Library_Version} + @tab string + @end multitable + + @noindent + The attributes for package @code{Naming} are as follows + (see @ref{Naming Schemes}): + + @multitable @columnfractions .4 .2 .2 .2 + @item Attribute Name @tab Category @tab Index @tab Value + @item @code{Specification_Suffix} + @tab associative array + @tab language name + @tab string + @item @code{Implementation_Suffix} + @tab associative array + @tab language name + @tab string + @item @code{Separate_Suffix} + @tab simple attribute + @tab n/a + @tab string + @item @code{Casing} + @tab simple attribute + @tab n/a + @tab string + @item @code{Dot_Replacement} + @tab simple attribute + @tab n/a + @tab string + @item @code{Specification} + @tab associative array + @tab Ada unit name + @tab string + @item @code{Implementation} + @tab associative array + @tab Ada unit name + @tab string + @item @code{Specification_Exceptions} + @tab associative array + @tab language name + @tab string list + @item @code{Implementation_Exceptions} + @tab associative array + @tab language name + @tab string list + @end multitable + + @noindent + The attributes for package @code{Builder}, @code{Compiler}, @code{Binder}, + @code{Linker}, @code{Cross_Reference}, and @code{Finder} + are as follows (see @ref{Switches and Project Files}). + + @multitable @columnfractions .4 .2 .2 .2 + @item Attribute Name @tab Category @tab Index @tab Value + @item @code{Default_Switches} + @tab associative array + @tab language name + @tab string list + @item @code{Switches} + @tab associative array + @tab file name + @tab string list + @end multitable + + @noindent + In addition, package @code{Builder} has a single string attribute + @code{Local_Configuration_Pragmas} and package @code{Builder} has a single + string attribute @code{Global_Configuration_Pragmas}. + + @noindent + The attribute for package @code{Glide} are not documented: they are for + internal use only. + + @noindent + Each simple attribute has a default value: the empty string (for string-valued + attributes) and the empty list (for string list-valued attributes). + + Similar to variable declarations, an attribute declaration defines a new value + for an attribute. + + Examples of simple attribute declarations: + + @smallexample + for Object_Dir use "objects"; + for Source_Dirs use ("units", "test/drivers"); + @end smallexample + + @noindent + A @dfn{simple attribute declaration} starts with the reserved word @code{for}, + followed by the name of the attribute, followed by the reserved word + @code{use}, followed by an expression (whose kind depends on the attribute), + followed by a semicolon. + + Attributes may be referenced in expressions. + The general form for such a reference is @code{'}: + the entity for which the attribute is defined, + followed by an apostrophe, followed by the name of the attribute. + For associative array attributes, a litteral string between parentheses + need to be supplied as index. + + Examples are: + + @smallexample + project'Object_Dir + Naming'Dot_Replacement + Imported_Project'Source_Dirs + Imported_Project.Naming'Casing + Builder'Default_Switches("Ada") + @end smallexample + + @noindent + The entity may be: + @itemize @bullet + @item @code{project} for an attribute of the current project + @item The name of an existing package of the current project + @item The name of an imported project + @item The name of a parent project (extended by the current project) + @item An imported/parent project name, followed by a dot, + followed by a package name + @end itemize + + @noindent + Example: + @smallexample + @group + project Prj is + for Source_Dirs use project'Source_Dirs & "units"; + for Source_Dirs use project'Source_Dirs & "test/drivers" + end Prj; + @end group + @end smallexample + + @noindent + In the first attribute declaration, initially the attribute @code{Source_Dirs} + has the default value: an empty string list. After this declaration, + @code{Source_Dirs} is a string list of one element: "units". + After the second attribute declaration @code{Source_Dirs} is a string list of + two elements: "units" and "test/drivers". + + Note: this example is for illustration only. In practice, + the project file would contain only one attribute declaration: + + @smallexample + for Source_Dirs use ("units", "test/drivers"); + @end smallexample + + + @node Associative Array Attributes + @subsection Associative Array Attributes + + @noindent + Some attributes are defined as @emph{associative arrays}. An associative + array may be regarded as a function that takes a string as a parameter + and delivers a string or string list value as its result. + + Here are some examples of associative array attribute declarations: + + @smallexample + for Implementation ("main") use "Main.ada"; + for Switches ("main.ada") use ("-v", "-gnatv"); + for Switches ("main.ada") use Builder'Switches ("main.ada") & "-g"; + @end smallexample + + @noindent + Like untyped variables and simple attributes, associative array attributes may be declared several times. Each declaration supplies a new value for the + attribute, replacing the previous setting. + + + @node case Constructions + @subsection @code{case} Constructions + + @noindent + A @code{case} construction is used in a project file to effect conditional + behavior. + Here is a typical example: + + @smallexample + @group + project MyProj is + type OS_Type is ("Linux", "Unix", "NT", "VMS"); + + OS : OS_Type := external ("OS", "Linux"); + @end group + + @group + package Compiler is + case OS is + when "Linux" | "Unix" => + for Default_Switches ("Ada") use ("-gnath"); + when "NT" => + for Default_Switches ("Ada") use ("-gnatP"); + when others => + end case; + end Compiler; + end MyProj; + @end group + @end smallexample + + @noindent + The syntax of a @code{case} construction is based on the Ada case statement + (although there is no @code{null} construction for empty alternatives). + + Following the reserved word @code{case} there is the case variable (a typed + string variable), the reserved word @code{is}, and then a sequence of one or + more alternatives. + Each alternative comprises the reserved word @code{when}, either a list of + literal strings separated by the @code{"|"} character or the reserved word + @code{others}, and the @code{"=>"} token. + Each literal string must belong to the string type that is the type of the + case variable. + An @code{others} alternative, if present, must occur last. + The @code{end case;} sequence terminates the case construction. + + After each @code{=>}, there are zero or more constructions. The only + constructions allowed in a case construction are other case constructions and + attribute declarations. String type declarations, variable declarations and + package declarations are not allowed. + + The value of the case variable is often given by an external reference + (see @ref{External References in Project Files}). + + + @c **************************************** + @c * Objects and Sources in Project Files * + @c **************************************** + + @node Objects and Sources in Project Files + @section Objects and Sources in Project Files + + @menu + * Object Directory:: + * Exec Directory:: + * Source Directories:: + * Source File Names:: + @end menu + + @noindent + Each project has exactly one object directory and one or more source + directories. The source directories must contain at least one source file, + unless the project file explicitly specifies that no source files are present + (see @ref{Source File Names}). + + + @node Object Directory + @subsection Object Directory + + @noindent + The object directory for a project is the directory containing the compiler's + output (such as @file{ALI} files and object files) for the project's immediate + sources. Note that for inherited sources (when extending a parent project) the + parent project's object directory is used. + + The object directory is given by the value of the attribute @code{Object_Dir} + in the project file. + + @smallexample + for Object_Dir use "objects"; + @end smallexample + + @noindent + The attribute @var{Object_Dir} has a string value, the path name of the object + directory. The path name may be absolute or relative to the directory of the + project file. This directory must already exist, and be readable and writable. + + By default, when the attribute @code{Object_Dir} is not given an explicit value + or when its value is the empty string, the object directory is the same as the + directory containing the project file. + + + @node Exec Directory + @subsection Exec Directory + + @noindent + The exec directory for a project is the directory containing the executables + for the project's main subprograms. + + The exec directory is given by the value of the attribute @code{Exec_Dir} + in the project file. + + @smallexample + for Exec_Dir use "executables"; + @end smallexample + + @noindent + The attribute @var{Exec_Dir} has a string value, the path name of the exec + directory. The path name may be absolute or relative to the directory of the + project file. This directory must already exist, and be writable. + + By default, when the attribute @code{Exec_Dir} is not given an explicit value + or when its value is the empty string, the exec directory is the same as the + object directory of the project file. + + + @node Source Directories + @subsection Source Directories + + @noindent + The source directories of a project are specified by the project file + attribute @code{Source_Dirs}. + + This attribute's value is a string list. If the attribute is not given an + explicit value, then there is only one source directory, the one where the + project file resides. + + A @code{Source_Dirs} attribute that is explicitly defined to be the empty list, + as in + + @smallexample + for Source_Dirs use (); + @end smallexample + + @noindent + indicates that the project contains no source files. + + Otherwise, each string in the string list designates one or more + source directories. + + @smallexample + for Source_Dirs use ("sources", "test/drivers"); + @end smallexample + + @noindent + If a string in the list ends with @code{"/**"}, then the directory whose path + name precedes the two asterisks, as well as all its subdirectories + (recursively), are source directories. + + @smallexample + for Source_Dirs use ("/system/sources/**"); + @end smallexample + + @noindent + Here the directory @code{/system/sources} and all of its subdirectories + (recursively) are source directories. + + To specify that the source directories are the directory of the project file + and all of its subdirectories, you can declare @code{Source_Dirs} as follows: + @smallexample + for Source_Dirs use ("./**"); + @end smallexample + + @noindent + Each of the source directories must exist and be readable. + + + @node Source File Names + @subsection Source File Names + + @noindent + In a project that contains source files, their names may be specified by the + attributes @code{Source_Files} (a string list) or @code{Source_List_File} + (a string). Source file names never include any directory information. + + If the attribute @code{Source_Files} is given an explicit value, then each + element of the list is a source file name. + + @smallexample + for Source_Files use ("main.adb"); + for Source_Files use ("main.adb", "pack1.ads", "pack2.adb"); + @end smallexample + + @noindent + If the attribute @code{Source_Files} is not given an explicit value, + but the attribute @code{Source_List_File} is given a string value, + then the source file names are contained in the text file whose path name + (absolute or relative to the directory of the project file) is the + value of the attribute @code{Source_List_File}. + + Each line in the file that is not empty or is not a comment + contains a source file name. A comment line starts with two hyphens. + + @smallexample + for Source_List_File use "source_list.txt"; + @end smallexample + + @noindent + By default, if neither the attribute @code{Source_Files} nor the attribute + @code{Source_List_File} is given an explicit value, then each file in the + source directories that conforms to the project's naming scheme + (see @ref{Naming Schemes}) is an immediate source of the project. + + A warning is issued if both attributes @code{Source_Files} and + @code{Source_List_File} are given explicit values. In this case, the attribute + @code{Source_Files} prevails. + + Each source file name must be the name of one and only one existing source file + in one of the source directories. + + A @code{Source_Files} attribute defined with an empty list as its value + indicates that there are no source files in the project. + + Except for projects that are clearly specified as containing no Ada source + files (@code{Source_Dirs} or @code{Source_Files} specified as an empty list, + or @code{Languages} specified without @code{"Ada"} in the list) + @smallexample + for Source_Dirs use (); + for Source_Files use (); + for Languages use ("C", "C++"); + @end smallexample + + @noindent + a project must contain at least one immediate source. + + Projects with no source files are useful as template packages + (see @ref{Packages in Project Files}) for other projects; in particular to + define a package @code{Naming} (see @ref{Naming Schemes}). + + + @c **************************** + @c * Importing Projects * + @c **************************** + + @node Importing Projects + @section Importing Projects + + @noindent + An immediate source of a project P may depend on source files that + are neither immediate sources of P nor in the predefined library. + To get this effect, P must @emph{import} the projects that contain the needed + source files. + + @smallexample + @group + with "project1", "utilities.gpr"; + with "/namings/apex.gpr"; + project Main is + ... + @end group + @end smallexample + + @noindent + As can be seen in this example, the syntax for importing projects is similar + to the syntax for importing compilation units in Ada. However, project files + use literal strings instead of names, and the @code{with} clause identifies + project files rather than packages. + + Each literal string is the file name or path name (absolute or relative) of a + project file. If a string is simply a file name, with no path, then its + location is determined by the @emph{project path}: + + @itemize @bullet + @item + If the environment variable @env{ADA_PROJECT_PATH} exists, then the project + path includes all the directories in this environment variable, plus the + directory of the project file. + + @item + If the environment variable @env{ADA_PROJECT_PATH} does not exist, + then the project path contains only one directory, namely the one where + the project file is located. + @end itemize + + @noindent + If a relative pathname is used as in + + @smallexample + with "tests/proj"; + @end smallexample + + @noindent + then the path is relative to the directory where the importing project file is + located. Any symbolic link will be fully resolved in the directory + of the importing project file before the imported project file is looked up. + + When the @code{with}'ed project file name does not have an extension, + the default is @file{.gpr}. If a file with this extension is not found, then + the file name as specified in the @code{with} clause (no extension) will be + used. In the above example, if a file @code{project1.gpr} is found, then it + will be used; otherwise, if a file @code{project1} exists then it will be used; + if neither file exists, this is an error. + + A warning is issued if the name of the project file does not match the + name of the project; this check is case insensitive. + + Any source file that is an immediate source of the imported project can be + used by the immediate sources of the importing project, and recursively. Thus + if @code{A} imports @code{B}, and @code{B} imports @code{C}, the immediate + sources of @code{A} may depend on the immediate sources of @code{C}, even if + @code{A} does not import @code{C} explicitly. However, this is not recommended, + because if and when @code{B} ceases to import @code{C}, some sources in + @code{A} will no longer compile. + + A side effect of this capability is that cyclic dependences are not permitted: + if @code{A} imports @code{B} (directly or indirectly) then @code{B} is not + allowed to import @code{A}. + + + @c ********************* + @c * Project Extension * + @c ********************* + + @node Project Extension + @section Project Extension + + @noindent + During development of a large system, it is sometimes necessary to use + modified versions of some of the source files without changing the original + sources. This can be achieved through a facility known as + @emph{project extension}. + + @smallexample + project Modified_Utilities extends "/baseline/utilities.gpr" is ... + @end smallexample + + @noindent + The project file for the project being extended (the @emph{parent}) is + identified by the literal string that follows the reserved word @code{extends}, + which itself follows the name of the extending project (the @emph{child}). + + By default, a child project inherits all the sources of its parent. + However, inherited sources can be overridden: a unit with the same name as one + in the parent will hide the original unit. + Inherited sources are considered to be sources (but not immediate sources) + of the child project; see @ref{Project File Syntax}. + + An inherited source file retains any switches specified in the parent project. + + For example if the project @code{Utilities} contains the specification and the + body of an Ada package @code{Util_IO}, then the project + @code{Modified_Utilities} can contain a new body for package @code{Util_IO}. + The original body of @code{Util_IO} will not be considered in program builds. + However, the package specification will still be found in the project + @code{Utilities}. + + A child project can have only one parent but it may import any number of other + projects. + + A project is not allowed to import directly or indirectly at the same time a + child project and any of its ancestors. + + + @c **************************************** + @c * External References in Project Files * + @c **************************************** + + @node External References in Project Files + @section External References in Project Files + + @noindent + A project file may contain references to external variables; such references + are called @emph{external references}. + + An external variable is either defined as part of the environment (an + environment variable in Unix, for example) or else specified on the command + line via the @option{-X@emph{vbl}=@emph{value}} switch. If both, then the + command line value is used. + + An external reference is denoted by the built-in function + @code{external}, which returns a string value. This function has two forms: + @itemize @bullet + @item @code{external (external_variable_name)} + @item @code{external (external_variable_name, default_value)} + @end itemize + + @noindent + Each parameter must be a string literal. For example: + + @smallexample + external ("USER") + external ("OS", "Linux") + @end smallexample + + @noindent + In the form with one parameter, the function returns the value of + the external variable given as parameter. If this name is not present in the + environment, then the returned value is an empty string. + + In the form with two string parameters, the second parameter is + the value returned when the variable given as the first parameter is not + present in the environment. In the example above, if @code{"OS"} is not + the name of an environment variable and is not passed on the command line, + then the returned value will be @code{"Linux"}. + + An external reference may be part of a string expression or of a string + list expression, to define variables or attributes. + + @smallexample + @group + type Mode_Type is ("Debug", "Release"); + Mode : Mode_Type := external ("MODE"); + case Mode is + when "Debug" => + ... + @end group + @end smallexample + + + @c ***************************** + @c * Packages in Project Files * + @c ***************************** + + @node Packages in Project Files + @section Packages in Project Files + + @noindent + The @emph{package} is the project file feature that defines the settings for + project-aware tools. + For each such tool you can declare a corresponding package; the names for these + packages are preset (see @ref{Packages}) but are not case sensitive. + A package may contain variable declarations, attribute declarations, and case + constructions. + + @smallexample + @group + project Proj is + package Builder is -- used by gnatmake + for Default_Switches ("Ada") use ("-v", "-g"); + end Builder; + end Proj; + @end group + @end smallexample + + @noindent + A package declaration starts with the reserved word @code{package}, + followed by the package name (case insensitive), followed by the reserved word + @code{is}. It ends with the reserved word @code{end}, followed by the package + name, finally followed by a semi-colon. + + Most of the packages have an attribute @code{Default_Switches}. + This attribute is an associative array, and its value is a string list. + The index of the associative array is the name of a programming language (case + insensitive). This attribute indicates the switch or switches to be used + with the corresponding tool. + + Some packages also have another attribute, @code{Switches}, an associative + array whose value is a string list. The index is the name of a source file. + This attribute indicates the switch or switches to be used by the corresponding + tool when dealing with this specific file. + + Further information on these switch-related attributes is found in + @ref{Switches and Project Files}. + + A package may be declared as a @emph{renaming} of another package; e.g., from + the project file for an imported project. + + @smallexample + @group + with "/global/apex.gpr"; + project Example is + package Naming renames Apex.Naming; + ... + end Example; + @end group + @end smallexample + + @noindent + Packages that are renamed in other project files often come from project files + that have no sources: they are just used as templates. Any modification in the + template will be reflected automatically in all the project files that rename + a package from the template. + + In addition to the tool-oriented packages, you can also declare a package + named @code{Naming} to establish specialized source file naming conventions + (see @ref{Naming Schemes}). + + + @c ************************************ + @c * Variables from Imported Projects * + @c ************************************ + + @node Variables from Imported Projects + @section Variables from Imported Projects + + @noindent + An attribute or variable defined in an imported or parent project can + be used in expressions in the importing / extending project. + Such an attribute or variable is prefixed with the name of the project + and (if relevant) the name of package where it is defined. + + @smallexample + @group + with "imported"; + project Main extends "base" is + Var1 := Imported.Var; + Var2 := Base.Var & ".new"; + @end group + + @group + package Builder is + for Default_Switches ("Ada") use Imported.Builder.Ada_Switches & + "-gnatg" & "-v"; + end Builder; + @end group + + @group + package Compiler is + for Default_Switches ("Ada") use Base.Compiler.Ada_Switches; + end Compiler; + end Main; + @end group + @end smallexample + + @noindent + In this example: + + @itemize @bullet + @item + @code{Var1} is a copy of the variable @code{Var} defined in the project file + @file{"imported.gpr"} + @item + the value of @code{Var2} is a copy of the value of variable @code{Var} + defined in the project file @file{base.gpr}, concatenated with @code{".new"} + @item + attribute @code{Default_Switches ("Ada")} in package @code{Builder} + is a string list that includes in its value a copy of variable + @code{Ada_Switches} defined in the @code{Builder} package in project file + @file{imported.gpr} plus two new elements: @option{"-gnatg"} and @option{"-v"}; + @item + attribute @code{Default_Switches ("Ada")} in package @code{Compiler} + is a copy of the variable @code{Ada_Switches} defined in the @code{Compiler} + package in project file @file{base.gpr}, the project being extended. + @end itemize + + + @c ****************** + @c * Naming Schemes * + @c ****************** + + @node Naming Schemes + @section Naming Schemes + + @noindent + Sometimes an Ada software system is ported from a foreign compilation + environment to GNAT, with file names that do not use the default GNAT + conventions. Instead of changing all the file names (which for a variety of + reasons might not be possible), you can define the relevant file naming scheme + in the @code{Naming} package in your project file. For example, the following + package models the Apex file naming rules: + + @smallexample + @group + package Naming is + for Casing use "lowercase"; + for Dot_Replacement use "."; + for Specification_Suffix ("Ada") use ".1.ada"; + for Implementation_Suffix ("Ada") use ".2.ada"; + end Naming; + @end group + @end smallexample + + @noindent + You can define the following attributes in package @code{Naming}: + + @table @code + + @item @var{Casing} + This must be a string with one of the three values @code{"lowercase"}, + @code{"uppercase"} or @code{"mixedcase"}; these strings are case insensitive. + + @noindent + If @var{Casing} is not specified, then the default is @code{"lowercase"}. + + @item @var{Dot_Replacement} + This must be a string whose value satisfies the following conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start or end with an alphanumeric character + @item It cannot be a single underscore + @item It cannot start with an underscore followed by an alphanumeric + @item It cannot contain a dot @code{'.'} except if it the entire string is @code{"."} + @end itemize + + @noindent + If @code{Dot_Replacement} is not specified, then the default is @code{"-"}. + + @item @var{Specification_Suffix} + This is an associative array (indexed by the programming language name, case + insensitive) whose value is a string that must satisfy the following + conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start with an alphanumeric character + @item It cannot start with an underscore followed by an alphanumeric character + @end itemize + @noindent + If @code{Specification_Suffix ("Ada")} is not specified, then the default is + @code{".ads"}. + + @item @var{Implementation_Suffix} + This is an associative array (indexed by the programming language name, case + insensitive) whose value is a string that must satisfy the following + conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start with an alphanumeric character + @item It cannot start with an underscore followed by an alphanumeric character + @item It cannot be a suffix of @code{Specification_Suffix} + @end itemize + @noindent + If @code{Implementation_Suffix ("Ada")} is not specified, then the default is + @code{".adb"}. + + @item @var{Separate_Suffix} + This must be a string whose value satisfies the same conditions as + @code{Implementation_Suffix}. + + @noindent + If @code{Separate_Suffix ("Ada")} is not specified, then it defaults to same + value as @code{Implementation_Suffix ("Ada")}. + + @item @var{Specification} + @noindent + You can use the @code{Specification} attribute, an associative array, to define + the source file name for an individual Ada compilation unit's spec. The array + index must be a string literal that identifies the Ada unit (case insensitive). + The value of this attribute must be a string that identifies the file that + contains this unit's spec (case sensitive or insensitive depending on the + operating system). + + @smallexample + for Specification ("MyPack.MyChild") use "mypack.mychild.spec"; + @end smallexample + + @item @var{Implementation} + + You can use the @code{Implementation} attribute, an associative array, to + define the source file name for an individual Ada compilation unit's body + (possibly a subunit). The array index must be a string literal that identifies + the Ada unit (case insensitive). The value of this attribute must be a string + that identifies the file that contains this unit's body or subunit (case + sensitive or insensitive depending on the operating system). + + @smallexample + for Implementation ("MyPack.MyChild") use "mypack.mychild.body"; + @end smallexample + @end table + + + @c ******************** + @c * Library Projects * + @c ******************** + + @node Library Projects + @section Library Projects + + @noindent + @emph{Library projects} are projects whose object code is placed in a library. + (Note that this facility is not yet supported on all platforms) + + To create a library project, you need to define in its project file + two project-level attributes: @code{Library_Name} and @code{Library_Dir}. + Additionally, you may define the library-related attributes + @code{Library_Kind}, @code{Library_Version} and @code{Library_Elaboration}. + + The @code{Library_Name} attribute has a string value that must start with a + letter and include only letters and digits. + + The @code{Library_Dir} attribute has a string value that designates the path + (absolute or relative) of the directory where the library will reside. + It must designate an existing directory, and this directory needs to be + different from the project's object directory. It also needs to be writable. + + If both @code{Library_Name} and @code{Library_Dir} are specified and + are legal, then the project file defines a library project. The optional + library-related attributes are checked only for such project files. + + The @code{Library_Kind} attribute has a string value that must be one of the + following (case insensitive): @code{"static"}, @code{"dynamic"} or + @code{"relocatable"}. If this attribute is not specified, the library is a + static library. Otherwise, the library may be dynamic or relocatable. + Depending on the operating system, there may or may not be a distinction + between dynamic and relocatable libraries. For example, on Unix there is no + such distinction. + + The @code{Library_Version} attribute has a string value whose interpretation + is platform dependent. On Unix, it is used only for dynamic/relocatable + libraries as the internal name of the library (the @code{"soname"}). If the + library file name (built from the @code{Library_Name}) is different from the + @code{Library_Version}, then the library file will be a symbolic link to the + actual file whose name will be @code{Library_Version}. + + Example (on Unix): + + @smallexample + @group + project Plib is + + Version := "1"; + + for Library_Dir use "lib_dir"; + for Library_Name use "dummy"; + for Library_Kind use "relocatable"; + for Library_Version use "libdummy.so." & Version; + + end Plib; + @end group + @end smallexample + + @noindent + Directory @file{lib_dir} will contain the internal library file whose name + will be @file{libdummy.so.1}, and @file{libdummy.so} will be a symbolic link to + @file{libdummy.so.1}. + + When @command{gnatmake} detects that a project file (not the main project file) + is a library project file, it will check all immediate sources of the project + and rebuild the library if any of the sources have been recompiled. + All @file{ALI} files will also be copied from the object directory to the + library directory. To build executables, @command{gnatmake} will use the + library rather than the individual object files. + + + @c ************************************* + @c * Switches Related to Project Files * + @c ************************************* + @node Switches Related to Project Files + @section Switches Related to Project Files + + @noindent + The following switches are used by GNAT tools that support project files: + + @table @code + + @item @option{-P@var{project}} + Indicates the name of a project file. This project file will be parsed with + the verbosity indicated by @option{-vP@emph{x}}, if any, and using the external + references indicated by @option{-X} switches, if any. + + @noindent + There must be only one @option{-P} switch on the command line. + + @noindent + Since the Project Manager parses the project file only after all the switches + on the command line are checked, the order of the switches @option{-P}, + @option{-Vp@emph{x}} or @option{-X} is not significant. + + @item @option{-X@var{name=value}} + Indicates that external variable @var{name} has the value @var{value}. + The Project Manager will use this value for occurrences of + @code{external(name)} when parsing the project file. + + @noindent + If @var{name} or @var{value} includes a space, then @var{name=value} should be + put between quotes. + @smallexample + -XOS=NT + -X"user=John Doe" + @end smallexample + + @noindent + Several @option{-X} switches can be used simultaneously. + If several @option{-X} switches specify the same @var{name}, only the last one + is used. + + @noindent + An external variable specified with a @option{-X} switch takes precedence + over the value of the same name in the environment. + + @item @option{-vP@emph{x}} + Indicates the verbosity of the parsing of GNAT project files. + @option{-vP0} means Default (no output for syntactically correct project + files); + @option{-vP1} means Medium; + @option{-vP2} means High. + @noindent + The default is Default. + @noindent + If several @option{-vP@emph{x}} switches are present, only the last one is + used. + + @end table + + + @c ********************************** + @c * Tools Supporting Project Files * + @c ********************************** + + @node Tools Supporting Project Files + @section Tools Supporting Project Files + + @menu + * gnatmake and Project Files:: + * The GNAT Driver and Project Files:: + * Glide and Project Files:: + @end menu + + @node gnatmake and Project Files + @subsection gnatmake and Project Files + + @noindent + This section covers two topics related to @command{gnatmake} and project files: + defining switches for @command{gnatmake} and for the tools that it invokes; + and the use of the @code{Main} attribute. + + @menu + * Switches and Project Files:: + * Project Files and Main Subprograms:: + @end menu + + @node Switches and Project Files + @subsubsection Switches and Project Files + + @noindent + For each of the packages @code{Builder}, @code{Compiler}, @code{Binder}, and + @code{Linker}, you can specify a @code{Default_Switches} attribute, a + @code{Switches} attribute, or both; as their names imply, these switch-related + attributes affect which switches are used for which files when + @command{gnatmake} is invoked. As will be explained below, these + package-contributed switches precede the switches passed on the + @command{gnatmake} command line. + + The @code{Default_Switches} attribute is an associative array indexed by + language name (case insensitive) and returning a string list. For example: + + @smallexample + @group + package Compiler is + for Default_Switches ("Ada") use ("-gnaty", "-v"); + end Compiler; + @end group + @end smallexample + + @noindent + The @code{Switches} attribute is also an associative array, indexed by a file + name (which may or may not be case sensitive, depending on the operating + system) and returning a string list. For example: + + @smallexample + @group + package Builder is + for Switches ("main1.adb") use ("-O2"); + for Switches ("main2.adb") use ("-g"); + end Builder; + @end group + @end smallexample + + @noindent + For the @code{Builder} package, the file names should designate source files + for main subprograms. For the @code{Binder} and @code{Linker} packages, the + file names should designate @file{ALI} or source files for main subprograms. + In each case just the file name (without explicit extension) is acceptable. + + For each tool used in a program build (@command{gnatmake}, the compiler, the + binder, and the linker), its corresponding package @dfn{contributes} a set of + switches for each file on which the tool is invoked, based on the + switch-related attributes defined in the package. In particular, the switches + that each of these packages contributes for a given file @var{f} comprise: + + @itemize @bullet + @item + the value of attribute @code{Switches (@var{f})}, if it is specified in the + package for the given file, + @item + otherwise, the value of @code{Default_Switches ("Ada")}, if it is specified in + the package. + @end itemize + + @noindent + If neither of these attributes is defined in the package, then the package does + not contribute any switches for the given file. + + When @command{gnatmake} is invoked on a file, the switches comprise two sets, + in the following order: those contributed for the file by the @code{Builder} + package; and the switches passed on the command line. + + When @command{gnatmake} invokes a tool (compiler, binder, linker) on a file, + the switches passed to the tool comprise three sets, in the following order: + + @enumerate + @item + the applicable switches contributed for the file by the @code{Builder} package + in the project file supplied on the command line; + + @item + those contributed for the file by the package (in the relevant project file -- + see below) corresponding to the tool; and + + @item + the applicable switches passed on the command line. + @end enumerate + + @noindent + The term @emph{applicable switches} reflects the fact that @command{gnatmake} + switches may or may not be passed to individual tools, depending on the + individual switch. + + @command{gnatmake} may invoke the compiler on source files from different + projects. The Project Manager will use the appropriate project file to + determine the @code{Compiler} package for each source file being compiled. + Likewise for the @code{Binder} and @code{Linker} packages. + + As an example, consider the following package in a project file: + + @smallexample + @group + project Proj1 is + package Compiler is + for Default_Switches ("Ada") use ("-g"); + for Switches ("a.adb") use ("-O1"); + for Switches ("b.adb") use ("-O2", "-gnaty"); + end Compiler; + end Proj1; + @end group + @end smallexample + + @noindent + If @command{gnatmake} is invoked with this project file, and it needs to + compile, say, the files @file{a.adb}, @file{b.adb}, and @file{c.adb}, then + @file{a.adb} will be compiled with the switch @option{-O1}, @file{b.adb} + with switches @option{-O2} and @option{-gnaty}, and @file{c.adb} with + @option{-g}. + + Another example illustrates the ordering of the switches contributed by + different packages: + + @smallexample + @group + project Proj2 is + package Builder is + for Switches ("main.adb") use ("-g", "-O1", "-f"); + end Builder; + @end group + + @group + package Compiler is + for Switches ("main.adb") use ("-O2"); + end Compiler; + end Proj2; + @end group + @end smallexample + + @noindent + If you issue the command: + + @smallexample + gnatmake -PProj2 -O0 main + @end smallexample + + @noindent + then the compiler will be invoked on @file{main.adb} with the following sequence of switches + + @smallexample + -g -O1 -O2 -O0 + @end smallexample + + with the last @option{-O} switch having precedence over the earlier ones; + several other switches (such as @option{-c}) are added implicitly. + + The switches @option{-g} and @option{-O1} are contributed by package + @code{Builder}, @option{-O2} is contributed by the package @code{Compiler} + and @option{-O0} comes from the command line. + + The @option{-g} switch will also be passed in the invocation of + @command{gnatlink.} + + A final example illustrates switch contributions from packages in different + project files: + + @smallexample + @group + project Proj3 is + for Source_Files use ("pack.ads", "pack.adb"); + package Compiler is + for Default_Switches ("Ada") use ("-gnata"); + end Compiler; + end Proj3; + @end group + + @group + with "Proj3"; + project Proj4 is + for Source_Files use ("foo_main.adb", "bar_main.adb"); + package Builder is + for Switches ("foo_main.adb") use ("-s", "-g"); + end Builder; + end Proj4; + @end group + + @group + -- Ada source file: + with Pack; + procedure Foo_Main is + ... + end Foo_Main; + @end group + @end smallexample + + If the command is + @smallexample + gnatmake -PProj4 foo_main.adb -cargs -gnato + @end smallexample + + @noindent + then the switches passed to the compiler for @file{foo_main.adb} are + @option{-g} (contributed by the package @code{Proj4.Builder}) and + @option{-gnato} (passed on the command line). + When the imported package @code{Pack} is compiled, the switches used are + @option{-g} from @code{Proj4.Builder}, @option{-gnata} (contributed from + package @code{Proj3.Compiler}, and @option{-gnato} from the command line. + + + @node Project Files and Main Subprograms + @subsubsection Project Files and Main Subprograms + + @noindent + When using a project file, you can invoke @command{gnatmake} + with several main subprograms, by specifying their source files on the command + line. Each of these needs to be an immediate source file of the project. + + @smallexample + gnatmake -Pprj main1 main2 main3 + @end smallexample + + @noindent + When using a project file, you can also invoke @command{gnatmake} without + explicitly specifying any main, and the effect depends on whether you have + defined the @code{Main} attribute. This attribute has a string list value, + where each element in the list is the name of a source file (the file + extension is optional) containing a main subprogram. + + If the @code{Main} attribute is defined in a project file as a non-empty + string list and the switch @option{-u} is not used on the command line, then + invoking @command{gnatmake} with this project file but without any main on the + command line is equivalent to invoking @command{gnatmake} with all the file + names in the @code{Main} attribute on the command line. + + Example: + @smallexample + @group + project Prj is + for Main use ("main1", "main2", "main3"); + end Prj; + @end group + @end smallexample + + @noindent + With this project file, @code{"gnatmake -Pprj"} is equivalent to + @code{"gnatmake -Pprj main1 main2 main3"}. + + When the project attribute @code{Main} is not specified, or is specified + as an empty string list, or when the switch @option{-u} is used on the command + line, then invoking @command{gnatmake} with no main on the command line will + result in all immediate sources of the project file being checked, and + potentially recompiled. Depending on the presence of the switch @option{-u}, + sources from other project files on which the immediate sources of the main + project file depend are also checked and potentially recompiled. In other + words, the @option{-u} switch is applied to all of the immediate sources of themain project file. + + + @node The GNAT Driver and Project Files + @subsection The GNAT Driver and Project Files + + @noindent + A number of GNAT tools, other than @command{gnatmake} are project-aware: + @command{gnatbind}, @command{gnatfind}, @command{gnatlink}, @command{gnatls} + and @command{gnatxref}. However, none of these tools can be invoked directly + with a project file switch (@code{-P}). They need to be invoke through the + @command{gnat} driver. + + The @command{gnat} driver is a front-end that accepts a number of commands and + call the corresponding tool. It has been designed initially for VMS to convert + VMS style qualifiers to Unix style switches, but it is now available to all + the GNAT supported platforms. + + On non VMS platforms, the @command{gnat} driver accepts the following commands + (case insensitive): + + @itemize @bullet + @item + BIND to invoke @command{gnatbind} + @item + CHOP to invoke @command{gnatchop} + @item + COMP or COMPILE to invoke the compiler + @item + ELIM to invoke @command{gnatelim} + @item + FIND to invoke @command{gnatfind} + @item + KR or KRUNCH to invoke @command{gnatkr} + @item + LINK to invoke @command{gnatlink} + @item + LS or LIST to invoke @command{gnatls} + @item + MAKE to invoke @command{gnatmake} + @item + NAME to invoke @command{gnatname} + @item + PREP or PREPROCESS to invoke @command{gnatprep} + @item + PSTA or STANDARD to invoke @command{gnatpsta} + @item + STUB to invoke @command{gnatstub} + @item + XREF to invoke @command{gnatxref} + @end itemize + + @noindent + Note that the compiler is invoked using the command @command{gnatmake -f -u}. + + @noindent + Following the command, you may put switches and arguments for the invoked + tool. + + @smallexample + gnat bind -C main.ali + gnat ls -a main + gnat chop foo.txt + @end smallexample + + @noindent + In addition, for command BIND, FIND, LS or LIST, LINK and XREF, the project + file related switches (@code{-P}, @code{-X} and @code{-vPx}) may be used in + addition to the switches of the invoking tool. + + @noindent + For each of these command, there is possibly a package in the main project that + corresponds to the invoked tool. + + @itemize @bullet + @item + package @code{Binder} for command BIND (invoking @code{gnatbind}) + + @item + package @code{Finder} for command FIND (invoking @code{gnatfind}) + + @item + package @code{Gnatls} for command LS or LIST (invoking @code{gnatls}) + + @item + package @code{Linker} for command LINK (invoking @code{gnatlink}) + + @item + package @code{Cross_Reference} for command XREF (invoking @code{gnatlink}) + + @end itemize + + @noindent + Package @code{Gnatls} has a unique attribute @code{Switches}, a simple variable + with a string list value. It contains switches for the invocation of + @code{gnatls}. + + @smallexample + @group + project Proj1 is + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + end Proj1; + @end group + @end smallexample + + @noindent + All other packages contains a switch @code{Default_Switches}, an associative + array, indexed by the programming language (case insensitive) and having a + string list value. @code{Default_Switches ("Ada")} contains the switches for + the invocation of the tool corresponding to the package. + + @smallexample + @group + project Proj is + + for Source_Dirs use ("./**"); + + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + @end group + @group + + package Binder is + for Default_Switches ("Ada") use ("-C", "-e"); + end Binder; + @end group + @group + + package Linker is + for Default_Switches ("Ada") use ("-C"); + end Linker; + @end group + @group + + package Finder is + for Default_Switches ("Ada") use ("-a", "-f"); + end Finder; + @end group + @group + + package Cross_Reference is + for Default_Switches ("Ada") use ("-a", "-f", "-d", "-u"); + end Cross_Reference; + end Proj; + @end group + @end smallexample + + @noindent + With the above project file, commands such as + + @smallexample + gnat ls -Pproj main + gnat xref -Pproj main + gnat bind -Pproj main.ali + @end smallexample + + @noindent + will set up the environment properly and invoke the tool with the switches + found in the package corresponding to the tool. + + + @node Glide and Project Files + @subsection Glide and Project Files + + @noindent + Glide will automatically recognize the @file{.gpr} extension for + project files, and will + convert them to its own internal format automatically. However, it + doesn't provide a syntax-oriented editor for modifying these + files. + The project file will be loaded as text when you select the menu item + @code{Ada} @result{} @code{Project} @result{} @code{Edit}. + You can edit this text and save the @file{gpr} file; + when you next select this project file in Glide it + will be automatically reloaded. + + + + @node An Extended Example + @section An Extended Example + + @noindent + Suppose that we have two programs, @var{prog1} and @var{prog2}, with the sources + in the respective directories. We would like to build them with a single + @command{gnatmake} command, and we would like to place their object files into + @file{.build} subdirectories of the source directories. Furthermore, we would + like to have to have two separate subdirectories in @file{.build} -- + @file{release} and @file{debug} -- which will contain the object files compiled with + different set of compilation flags. + + In other words, we have the following structure: + + @smallexample + @group + main + |- prog1 + | |- .build + | | debug + | | release + |- prog2 + |- .build + | debug + | release + @end group + @end smallexample + + @noindent + Here are the project files that we need to create in a directory @file{main} + to maintain this structure: + + @enumerate + + @item We create a @code{Common} project with a package @code{Compiler} that + specifies the compilation switches: + + @smallexample + File "common.gpr": + @group + @b{project} Common @b{is} + + @b{for} Source_Dirs @b{use} (); -- No source files + @end group + + @group + @b{type} Build_Type @b{is} ("release", "debug"); + Build : Build_Type := External ("BUILD", "debug"); + @end group + @group + @b{package} Compiler @b{is} + @b{case} Build @b{is} + @b{when} "release" => + @b{for} Default_Switches ("Ada") @b{use} ("-O2"); + @b{when} "debug" => + @b{for} Default_Switches ("Ada") @b{use} ("-g"); + @b{end case}; + @b{end} Compiler; + + @b{end} Common; + @end group + @end smallexample + + @item We create separate projects for the two programs: + + @smallexample + @group + File "prog1.gpr": + + @b{with} "common"; + @b{project} Prog1 @b{is} + + @b{for} Source_Dirs @b{use} ("prog1"); + @b{for} Object_Dir @b{use} "prog1/.build/" & Common.Build; + + @b{package} Compiler @b{renames} Common.Compiler; + + @b{end} Prog1; + @end group + @end smallexample + + @smallexample + @group + File "prog2.gpr": + + @b{with} "common"; + @b{project} Prog2 @b{is} + + @b{for} Source_Dirs @b{use} ("prog2"); + @b{for} Object_Dir @b{use} "prog2/.build/" & Common.Build; + + @b{package} Compiler @b{renames} Common.Compiler; + + @end group + @b{end} Prog2; + @end smallexample + + @item We create a wrapping project @var{Main}: + + @smallexample + @group + File "main.gpr": + + @b{with} "common"; + @b{with} "prog1"; + @b{with} "prog2"; + @b{project} Main @b{is} + + @b{package} Compiler @b{renames} Common.Compiler; + + @b{end} Main; + @end group + @end smallexample + + @item Finally we need to create a dummy procedure that @code{with}s (either + explicitly or implicitly) all the sources of our two programs. + + @end enumerate + + @noindent + Now we can build the programs using the command + + @smallexample + gnatmake -Pmain dummy + @end smallexample + + @noindent + for the Debug mode, or + + @smallexample + gnatmake -Pmain -XBUILD=release + @end smallexample + + @noindent + for the Release mode. + + + @c ******************************** + @c * Project File Complete Syntax * + @c ******************************** + + @node Project File Complete Syntax + @section Project File Complete Syntax + + @smallexample + project ::= + context_clause project_declaration + + context_clause ::= + @{with_clause@} + + with_clause ::= + @b{with} literal_string @{ , literal_string @} ; + + project_declaration ::= + @b{project} simple_name [ @b{extends} literal_string ] @b{is} + @{declarative_item@} + @b{end} simple_name; + + declarative_item ::= + package_declaration | + typed_string_declaration | + other_declarative_item + + package_declaration ::= + @b{package} simple_name package_completion + + package_completion ::= + package_body | package_renaming + + package body ::= + @b{is} + @{other_declarative_item@} + @b{end} simple_name ; + + package_renaming ::== + @b{renames} simple_name.simple_name ; + + typed_string_declaration ::= + @b{type} _simple_name @b{is} + ( literal_string @{, literal_string@} ); + + other_declarative_item ::= + attribute_declaration | + typed_variable_declaration | + variable_declaration | + case_construction + + attribute_declaration ::= + @b{for} attribute @b{use} expression ; + + attribute ::= + simple_name | + simple_name ( literal_string ) + + typed_variable_declaration ::= + simple_name : name := string_expression ; + + variable_declaration ::= + simple_name := expression; + + expression ::= + term @{& term@} + + term ::= + literal_string | + string_list | + name | + external_value | + attribute_reference + + literal_string ::= + (same as Ada) + + string_list ::= + ( expression @{ , expression @} ) + + external_value ::= + @b{external} ( literal_string [, literal_string] ) + + attribute_reference ::= + attribute_parent ' simple_name [ ( literal_string ) ] + + attribute_parent ::= + @b{project} | + simple_name | + simple_name . simple_name + + case_construction ::= + @b{case} name @b{is} + @{case_item@} + @b{end case} ; + + case_item ::= + @b{when} discrete_choice_list => @{case_construction | attribute_declaration@} + + discrete_choice_list ::= + literal_string @{| literal_string@} + + name ::= + simple_name @{. simple_name@} + + simple_name ::= + identifier (same as Ada) + + @end smallexample + + + @node Elaboration Order Handling in GNAT + @chapter Elaboration Order Handling in GNAT + @cindex Order of elaboration + @cindex Elaboration control + + @menu + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + @end menu + + @noindent + This chapter describes the handling of elaboration code in Ada 95 and + in GNAT, and discusses how the order of elaboration of program units can + be controlled in GNAT, either automatically or with explicit programming + features. + + @node Elaboration Code in Ada 95 + @section Elaboration Code in Ada 95 + + @noindent + Ada 95 provides rather general mechanisms for executing code at elaboration + time, that is to say before the main program starts executing. Such code arises + in three contexts: + + @table @asis + @item Initializers for variables. + Variables declared at the library level, in package specs or bodies, can + require initialization that is performed at elaboration time, as in: + @smallexample + @cartouche + Sqrt_Half : Float := Sqrt (0.5); + @end cartouche + @end smallexample + + @item Package initialization code + Code in a @code{BEGIN-END} section at the outer level of a package body is + executed as part of the package body elaboration code. + + @item Library level task allocators + Tasks that are declared using task allocators at the library level + start executing immediately and hence can execute at elaboration time. + @end table + + @noindent + Subprogram calls are possible in any of these contexts, which means that + any arbitrary part of the program may be executed as part of the elaboration + code. It is even possible to write a program which does all its work at + elaboration time, with a null main program, although stylistically this + would usually be considered an inappropriate way to structure + a program. + + An important concern arises in the context of elaboration code: + we have to be sure that it is executed in an appropriate order. What we + have is a series of elaboration code sections, potentially one section + for each unit in the program. It is important that these execute + in the correct order. Correctness here means that, taking the above + example of the declaration of @code{Sqrt_Half}, + if some other piece of + elaboration code references @code{Sqrt_Half}, + then it must run after the + section of elaboration code that contains the declaration of + @code{Sqrt_Half}. + + There would never be any order of elaboration problem if we made a rule + that whenever you @code{with} a unit, you must elaborate both the spec and body + of that unit before elaborating the unit doing the @code{with}'ing: + + @smallexample + @group + @cartouche + @b{with} Unit_1; + @b{package} Unit_2 @b{is} ... + @end cartouche + @end group + @end smallexample + + @noindent + would require that both the body and spec of @code{Unit_1} be elaborated + before the spec of @code{Unit_2}. However, a rule like that would be far too + restrictive. In particular, it would make it impossible to have routines + in separate packages that were mutually recursive. + + You might think that a clever enough compiler could look at the actual + elaboration code and determine an appropriate correct order of elaboration, + but in the general case, this is not possible. Consider the following + example. + + In the body of @code{Unit_1}, we have a procedure @code{Func_1} + that references + the variable @code{Sqrt_1}, which is declared in the elaboration code + of the body of @code{Unit_1}: + + @smallexample + @cartouche + Sqrt_1 : Float := Sqrt (0.1); + @end cartouche + @end smallexample + + @noindent + The elaboration code of the body of @code{Unit_1} also contains: + + @smallexample + @group + @cartouche + @b{if} expression_1 = 1 @b{then} + Q := Unit_2.Func_2; + @b{end if}; + @end cartouche + @end group + @end smallexample + + @noindent + @code{Unit_2} is exactly parallel, + it has a procedure @code{Func_2} that references + the variable @code{Sqrt_2}, which is declared in the elaboration code of + the body @code{Unit_2}: + + @smallexample + @cartouche + Sqrt_2 : Float := Sqrt (0.1); + @end cartouche + @end smallexample + + @noindent + The elaboration code of the body of @code{Unit_2} also contains: + + @smallexample + @group + @cartouche + @b{if} expression_2 = 2 @b{then} + Q := Unit_1.Func_1; + @b{end if}; + @end cartouche + @end group + @end smallexample + + @noindent + Now the question is, which of the following orders of elaboration is + acceptable: + + @smallexample + @group + Spec of Unit_1 + Spec of Unit_2 + Body of Unit_1 + Body of Unit_2 + @end group + @end smallexample + + @noindent + or + + @smallexample + @group + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_2 + Body of Unit_1 + @end group + @end smallexample + + @noindent + If you carefully analyze the flow here, you will see that you cannot tell + at compile time the answer to this question. + If @code{expression_1} is not equal to 1, + and @code{expression_2} is not equal to 2, + then either order is acceptable, because neither of the function calls is + executed. If both tests evaluate to true, then neither order is acceptable + and in fact there is no correct order. + + If one of the two expressions is true, and the other is false, then one + of the above orders is correct, and the other is incorrect. For example, + if @code{expression_1} = 1 and @code{expression_2} /= 2, + then the call to @code{Func_2} + will occur, but not the call to @code{Func_1.} + This means that it is essential + to elaborate the body of @code{Unit_1} before + the body of @code{Unit_2}, so the first + order of elaboration is correct and the second is wrong. + + By making @code{expression_1} and @code{expression_2} + depend on input data, or perhaps + the time of day, we can make it impossible for the compiler or binder + to figure out which of these expressions will be true, and hence it + is impossible to guarantee a safe order of elaboration at run time. + + @node Checking the Elaboration Order in Ada 95 + @section Checking the Elaboration Order in Ada 95 + + @noindent + In some languages that involve the same kind of elaboration problems, + e.g. Java and C++, the programmer is expected to worry about these + ordering problems himself, and it is common to + write a program in which an incorrect elaboration order gives + surprising results, because it references variables before they + are initialized. + Ada 95 is designed to be a safe language, and a programmer-beware approach is + clearly not sufficient. Consequently, the language provides three lines + of defense: + + @table @asis + @item Standard rules + Some standard rules restrict the possible choice of elaboration + order. In particular, if you @code{with} a unit, then its spec is always + elaborated before the unit doing the @code{with}. Similarly, a parent + spec is always elaborated before the child spec, and finally + a spec is always elaborated before its corresponding body. + + @item Dynamic elaboration checks + @cindex Elaboration checks + @cindex Checks, elaboration + Dynamic checks are made at run time, so that if some entity is accessed + before it is elaborated (typically by means of a subprogram call) + then the exception (@code{Program_Error}) is raised. + + @item Elaboration control + Facilities are provided for the programmer to specify the desired order + of elaboration. + @end table + + Let's look at these facilities in more detail. First, the rules for + dynamic checking. One possible rule would be simply to say that the + exception is raised if you access a variable which has not yet been + elaborated. The trouble with this approach is that it could require + expensive checks on every variable reference. Instead Ada 95 has two + rules which are a little more restrictive, but easier to check, and + easier to state: + + @table @asis + @item Restrictions on calls + A subprogram can only be called at elaboration time if its body + has been elaborated. The rules for elaboration given above guarantee + that the spec of the subprogram has been elaborated before the + call, but not the body. If this rule is violated, then the + exception @code{Program_Error} is raised. + + @item Restrictions on instantiations + A generic unit can only be instantiated if the body of the generic + unit has been elaborated. Again, the rules for elaboration given above + guarantee that the spec of the generic unit has been elaborated + before the instantiation, but not the body. If this rule is + violated, then the exception @code{Program_Error} is raised. + @end table + + @noindent + The idea is that if the body has been elaborated, then any variables + it references must have been elaborated; by checking for the body being + elaborated we guarantee that none of its references causes any + trouble. As we noted above, this is a little too restrictive, because a + subprogram that has no non-local references in its body may in fact be safe + to call. However, it really would be unsafe to rely on this, because + it would mean that the caller was aware of details of the implementation + in the body. This goes against the basic tenets of Ada. + + A plausible implementation can be described as follows. + A Boolean variable is associated with each subprogram + and each generic unit. This variable is initialized to False, and is set to + True at the point body is elaborated. Every call or instantiation checks the + variable, and raises @code{Program_Error} if the variable is False. + + Note that one might think that it would be good enough to have one Boolean + variable for each package, but that would not deal with cases of trying + to call a body in the same package as the call + that has not been elaborated yet. + Of course a compiler may be able to do enough analysis to optimize away + some of the Boolean variables as unnecessary, and @code{GNAT} indeed + does such optimizations, but still the easiest conceptual model is to + think of there being one variable per subprogram. + + @node Controlling the Elaboration Order in Ada 95 + @section Controlling the Elaboration Order in Ada 95 + + @noindent + In the previous section we discussed the rules in Ada 95 which ensure + that @code{Program_Error} is raised if an incorrect elaboration order is + chosen. This prevents erroneous executions, but we need mechanisms to + specify a correct execution and avoid the exception altogether. + To achieve this, Ada 95 provides a number of features for controlling + the order of elaboration. We discuss these features in this section. + + First, there are several ways of indicating to the compiler that a given + unit has no elaboration problems: + + @table @asis + @item packages that do not require a body + In Ada 95, a library package that does not require a body does not permit + a body. This means that if we have a such a package, as in: + + @smallexample + @group + @cartouche + @b{package} Definitions @b{is} + @b{generic} + @b{type} m @b{is new} integer; + @b{package} Subp @b{is} + @b{type} a @b{is array} (1 .. 10) @b{of} m; + @b{type} b @b{is array} (1 .. 20) @b{of} m; + @b{end} Subp; + @b{end} Definitions; + @end cartouche + @end group + @end smallexample + + @noindent + A package that @code{with}'s @code{Definitions} may safely instantiate + @code{Definitions.Subp} because the compiler can determine that there + definitely is no package body to worry about in this case + + @item pragma Pure + @cindex pragma Pure + @findex Pure + Places sufficient restrictions on a unit to guarantee that + no call to any subprogram in the unit can result in an + elaboration problem. This means that the compiler does not need + to worry about the point of elaboration of such units, and in + particular, does not need to check any calls to any subprograms + in this unit. + + @item pragma Preelaborate + @findex Preelaborate + @cindex pragma Preelaborate + This pragma places slightly less stringent restrictions on a unit than + does pragma Pure, + but these restrictions are still sufficient to ensure that there + are no elaboration problems with any calls to the unit. + + @item pragma Elaborate_Body + @findex Elaborate_Body + @cindex pragma Elaborate_Body + This pragma requires that the body of a unit be elaborated immediately + after its spec. Suppose a unit @code{A} has such a pragma, + and unit @code{B} does + a @code{with} of unit @code{A}. Recall that the standard rules require + the spec of unit @code{A} + to be elaborated before the @code{with}'ing unit; given the pragma in + @code{A}, we also know that the body of @code{A} + will be elaborated before @code{B}, so + that calls to @code{A} are safe and do not need a check. + @end table + + @noindent + Note that, + unlike pragma @code{Pure} and pragma @code{Preelaborate}, + the use of + @code{Elaborate_Body} does not guarantee that the program is + free of elaboration problems, because it may not be possible + to satisfy the requested elaboration order. + Let's go back to the example with @code{Unit_1} and @code{Unit_2}. + If a programmer + marks @code{Unit_1} as @code{Elaborate_Body}, + and not @code{Unit_2,} then the order of + elaboration will be: + + @smallexample + @group + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_1 + Body of Unit_2 + @end group + @end smallexample + + @noindent + Now that means that the call to @code{Func_1} in @code{Unit_2} + need not be checked, + it must be safe. But the call to @code{Func_2} in + @code{Unit_1} may still fail if + @code{Expression_1} is equal to 1, + and the programmer must still take + responsibility for this not being the case. + + If all units carry a pragma @code{Elaborate_Body}, then all problems are + eliminated, except for calls entirely within a body, which are + in any case fully under programmer control. However, using the pragma + everywhere is not always possible. + In particular, for our @code{Unit_1}/@code{Unit_2} example, if + we marked both of them as having pragma @code{Elaborate_Body}, then + clearly there would be no possible elaboration order. + + The above pragmas allow a server to guarantee safe use by clients, and + clearly this is the preferable approach. Consequently a good rule in + Ada 95 is to mark units as @code{Pure} or @code{Preelaborate} if possible, + and if this is not possible, + mark them as @code{Elaborate_Body} if possible. + As we have seen, there are situations where neither of these + three pragmas can be used. + So we also provide methods for clients to control the + order of elaboration of the servers on which they depend: + + @table @asis + @item pragma Elaborate (unit) + @findex Elaborate + @cindex pragma Elaborate + This pragma is placed in the context clause, after a @code{with} clause, + and it requires that the body of the named unit be elaborated before + the unit in which the pragma occurs. The idea is to use this pragma + if the current unit calls at elaboration time, directly or indirectly, + some subprogram in the named unit. + + @item pragma Elaborate_All (unit) + @findex Elaborate_All + @cindex pragma Elaborate_All + This is a stronger version of the Elaborate pragma. Consider the + following example: + + @smallexample + Unit A @code{with}'s unit B and calls B.Func in elab code + Unit B @code{with}'s unit C, and B.Func calls C.Func + @end smallexample + + @noindent + Now if we put a pragma @code{Elaborate (B)} + in unit @code{A}, this ensures that the + body of @code{B} is elaborated before the call, but not the + body of @code{C}, so + the call to @code{C.Func} could still cause @code{Program_Error} to + be raised. + + The effect of a pragma @code{Elaborate_All} is stronger, it requires + not only that the body of the named unit be elaborated before the + unit doing the @code{with}, but also the bodies of all units that the + named unit uses, following @code{with} links transitively. For example, + if we put a pragma @code{Elaborate_All (B)} in unit @code{A}, + then it requires + not only that the body of @code{B} be elaborated before @code{A}, + but also the + body of @code{C}, because @code{B} @code{with}'s @code{C}. + @end table + + @noindent + We are now in a position to give a usage rule in Ada 95 for avoiding + elaboration problems, at least if dynamic dispatching and access to + subprogram values are not used. We will handle these cases separately + later. + + The rule is simple. If a unit has elaboration code that can directly or + indirectly make a call to a subprogram in a @code{with}'ed unit, or instantiate + a generic unit in a @code{with}'ed unit, + then if the @code{with}'ed unit does not have + pragma @code{Pure} or @code{Preelaborate}, then the client should have + a pragma @code{Elaborate_All} + for the @code{with}'ed unit. By following this rule a client is + assured that calls can be made without risk of an exception. + If this rule is not followed, then a program may be in one of four + states: + + @table @asis + @item No order exists + No order of elaboration exists which follows the rules, taking into + account any @code{Elaborate}, @code{Elaborate_All}, + or @code{Elaborate_Body} pragmas. In + this case, an Ada 95 compiler must diagnose the situation at bind + time, and refuse to build an executable program. + + @item One or more orders exist, all incorrect + One or more acceptable elaboration orders exists, and all of them + generate an elaboration order problem. In this case, the binder + can build an executable program, but @code{Program_Error} will be raised + when the program is run. + + @item Several orders exist, some right, some incorrect + One or more acceptable elaboration orders exists, and some of them + work, and some do not. The programmer has not controlled + the order of elaboration, so the binder may or may not pick one of + the correct orders, and the program may or may not raise an + exception when it is run. This is the worst case, because it means + that the program may fail when moved to another compiler, or even + another version of the same compiler. + + @item One or more orders exists, all correct + One ore more acceptable elaboration orders exist, and all of them + work. In this case the program runs successfully. This state of + affairs can be guaranteed by following the rule we gave above, but + may be true even if the rule is not followed. + @end table + + @noindent + Note that one additional advantage of following our Elaborate_All rule + is that the program continues to stay in the ideal (all orders OK) state + even if maintenance + changes some bodies of some subprograms. Conversely, if a program that does + not follow this rule happens to be safe at some point, this state of affairs + may deteriorate silently as a result of maintenance changes. + + You may have noticed that the above discussion did not mention + the use of @code{Elaborate_Body}. This was a deliberate omission. If you + @code{with} an @code{Elaborate_Body} unit, it still may be the case that + code in the body makes calls to some other unit, so it is still necessary + to use @code{Elaborate_All} on such units. + + @node Controlling Elaboration in GNAT - Internal Calls + @section Controlling Elaboration in GNAT - Internal Calls + + @noindent + In the case of internal calls, i.e. calls within a single package, the + programmer has full control over the order of elaboration, and it is up + to the programmer to elaborate declarations in an appropriate order. For + example writing: + + @smallexample + @group + @cartouche + @b{function} One @b{return} Float; + + Q : Float := One; + + @b{function} One @b{return} Float @b{is} + @b{begin} + return 1.0; + @b{end} One; + @end cartouche + @end group + @end smallexample + + @noindent + will obviously raise @code{Program_Error} at run time, because function + One will be called before its body is elaborated. In this case GNAT will + generate a warning that the call will raise @code{Program_Error}: + + @smallexample + @group + @cartouche + 1. procedure y is + 2. function One return Float; + 3. + 4. Q : Float := One; + | + >>> warning: cannot call "One" before body is elaborated + >>> warning: Program_Error will be raised at run time + + 5. + 6. function One return Float is + 7. begin + 8. return 1.0; + 9. end One; + 10. + 11. begin + 12. null; + 13. end; + @end cartouche + @end group + @end smallexample + + @noindent + Note that in this particular case, it is likely that the call is safe, because + the function @code{One} does not access any global variables. + Nevertheless in Ada 95, we do not want the validity of the check to depend on + the contents of the body (think about the separate compilation case), so this + is still wrong, as we discussed in the previous sections. + + The error is easily corrected by rearranging the declarations so that the + body of One appears before the declaration containing the call + (note that in Ada 95, + declarations can appear in any order, so there is no restriction that + would prevent this reordering, and if we write: + + @smallexample + @group + @cartouche + @b{function} One @b{return} Float; + + @b{function} One @b{return} Float @b{is} + @b{begin} + return 1.0; + @b{end} One; + + Q : Float := One; + @end cartouche + @end group + @end smallexample + + @noindent + then all is well, no warning is generated, and no + @code{Program_Error} exception + will be raised. + Things are more complicated when a chain of subprograms is executed: + + @smallexample + @group + @cartouche + @b{function} A @b{return} Integer; + @b{function} B @b{return} Integer; + @b{function} C @b{return} Integer; + + @b{function} B @b{return} Integer @b{is begin return} A; @b{end}; + @b{function} C @b{return} Integer @b{is begin return} B; @b{end}; + + X : Integer := C; + + @b{function} A @b{return} Integer @b{is begin return} 1; @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + Now the call to @code{C} + at elaboration time in the declaration of @code{X} is correct, because + the body of @code{C} is already elaborated, + and the call to @code{B} within the body of + @code{C} is correct, but the call + to @code{A} within the body of @code{B} is incorrect, because the body + of @code{A} has not been elaborated, so @code{Program_Error} + will be raised on the call to @code{A}. + In this case GNAT will generate a + warning that @code{Program_Error} may be + raised at the point of the call. Let's look at the warning: + + @smallexample + @group + @cartouche + 1. procedure x is + 2. function A return Integer; + 3. function B return Integer; + 4. function C return Integer; + 5. + 6. function B return Integer is begin return A; end; + | + >>> warning: call to "A" before body is elaborated may + raise Program_Error + >>> warning: "B" called at line 7 + >>> warning: "C" called at line 9 + + 7. function C return Integer is begin return B; end; + 8. + 9. X : Integer := C; + 10. + 11. function A return Integer is begin return 1; end; + 12. + 13. begin + 14. null; + 15. end; + @end cartouche + @end group + @end smallexample + + @noindent + Note that the message here says "may raise", instead of the direct case, + where the message says "will be raised". That's because whether + @code{A} is + actually called depends in general on run-time flow of control. + For example, if the body of @code{B} said + + @smallexample + @group + @cartouche + @b{function} B @b{return} Integer @b{is} + @b{begin} + @b{if} some-condition-depending-on-input-data @b{then} + @b{return} A; + @b{else} + @b{return} 1; + @b{end if}; + @b{end} B; + @end cartouche + @end group + @end smallexample + + @noindent + then we could not know until run time whether the incorrect call to A would + actually occur, so @code{Program_Error} might + or might not be raised. It is possible for a compiler to + do a better job of analyzing bodies, to + determine whether or not @code{Program_Error} + might be raised, but it certainly + couldn't do a perfect job (that would require solving the halting problem + and is provably impossible), and because this is a warning anyway, it does + not seem worth the effort to do the analysis. Cases in which it + would be relevant are rare. + + In practice, warnings of either of the forms given + above will usually correspond to + real errors, and should be examined carefully and eliminated. + In the rare case where a warning is bogus, it can be suppressed by any of + the following methods: + + @itemize @bullet + @item + Compile with the @option{-gnatws} switch set + + @item + Suppress @code{Elaboration_Checks} for the called subprogram + + @item + Use pragma @code{Warnings_Off} to turn warnings off for the call + @end itemize + + @noindent + For the internal elaboration check case, + GNAT by default generates the + necessary run-time checks to ensure + that @code{Program_Error} is raised if any + call fails an elaboration check. Of course this can only happen if a + warning has been issued as described above. The use of pragma + @code{Suppress (Elaboration_Checks)} may (but is not guaranteed to) suppress + some of these checks, meaning that it may be possible (but is not + guaranteed) for a program to be able to call a subprogram whose body + is not yet elaborated, without raising a @code{Program_Error} exception. + + @node Controlling Elaboration in GNAT - External Calls + @section Controlling Elaboration in GNAT - External Calls + + @noindent + The previous section discussed the case in which the execution of a + particular thread of elaboration code occurred entirely within a + single unit. This is the easy case to handle, because a programmer + has direct and total control over the order of elaboration, and + furthermore, checks need only be generated in cases which are rare + and which the compiler can easily detect. + The situation is more complex when separate compilation is taken into account. + Consider the following: + + @smallexample + @cartouche + @group + @b{package} Math @b{is} + @b{function} Sqrt (Arg : Float) @b{return} Float; + @b{end} Math; + + @b{package body} Math @b{is} + @b{function} Sqrt (Arg : Float) @b{return} Float @b{is} + @b{begin} + ... + @b{end} Sqrt; + @b{end} Math; + @end group + @group + @b{with} Math; + @b{package} Stuff @b{is} + X : Float := Math.Sqrt (0.5); + @b{end} Stuff; + + @b{with} Stuff; + @b{procedure} Main @b{is} + @b{begin} + ... + @b{end} Main; + @end group + @end cartouche + @end smallexample + + @noindent + where @code{Main} is the main program. When this program is executed, the + elaboration code must first be executed, and one of the jobs of the + binder is to determine the order in which the units of a program are + to be elaborated. In this case we have four units: the spec and body + of @code{Math}, + the spec of @code{Stuff} and the body of @code{Main}). + In what order should the four separate sections of elaboration code + be executed? + + There are some restrictions in the order of elaboration that the binder + can choose. In particular, if unit U has a @code{with} + for a package @code{X}, then you + are assured that the spec of @code{X} + is elaborated before U , but you are + not assured that the body of @code{X} + is elaborated before U. + This means that in the above case, the binder is allowed to choose the + order: + + @smallexample + spec of Math + spec of Stuff + body of Math + body of Main + @end smallexample + + @noindent + but that's not good, because now the call to @code{Math.Sqrt} + that happens during + the elaboration of the @code{Stuff} + spec happens before the body of @code{Math.Sqrt} is + elaborated, and hence causes @code{Program_Error} exception to be raised. + At first glance, one might say that the binder is misbehaving, because + obviously you want to elaborate the body of something you @code{with} + first, but + that is not a general rule that can be followed in all cases. Consider + + @smallexample + @group + @cartouche + @b{package} X @b{is} ... + + @b{package} Y @b{is} ... + + @b{with} X; + @b{package body} Y @b{is} ... + + @b{with} Y; + @b{package body} X @b{is} ... + @end cartouche + @end group + @end smallexample + + @noindent + This is a common arrangement, and, apart from the order of elaboration + problems that might arise in connection with elaboration code, this works fine. + A rule that says that you must first elaborate the body of anything you + @code{with} cannot work in this case: + the body of @code{X} @code{with}'s @code{Y}, + which means you would have to + elaborate the body of @code{Y} first, but that @code{with}'s @code{X}, + which means + you have to elaborate the body of @code{X} first, but ... and we have a + loop that cannot be broken. + + It is true that the binder can in many cases guess an order of elaboration + that is unlikely to cause a @code{Program_Error} + exception to be raised, and it tries to do so (in the + above example of @code{Math/Stuff/Spec}, the GNAT binder will + by default + elaborate the body of @code{Math} right after its spec, so all will be well). + + However, a program that blindly relies on the binder to be helpful can + get into trouble, as we discussed in the previous sections, so + GNAT + provides a number of facilities for assisting the programmer in + developing programs that are robust with respect to elaboration order. + + @node Default Behavior in GNAT - Ensuring Safety + @section Default Behavior in GNAT - Ensuring Safety + + @noindent + The default behavior in GNAT ensures elaboration safety. In its + default mode GNAT implements the + rule we previously described as the right approach. Let's restate it: + + @itemize + @item + @emph{If a unit has elaboration code that can directly or indirectly make a + call to a subprogram in a @code{with}'ed unit, or instantiate a generic unit + in a @code{with}'ed unit, then if the @code{with}'ed unit + does not have pragma @code{Pure} or + @code{Preelaborate}, then the client should have an + @code{Elaborate_All} for the @code{with}'ed unit.} + @end itemize + + @noindent + By following this rule a client + is assured that calls and instantiations can be made without risk of an exception. + + In this mode GNAT traces all calls that are potentially made from + elaboration code, and puts in any missing implicit @code{Elaborate_All} + pragmas. + The advantage of this approach is that no elaboration problems + are possible if the binder can find an elaboration order that is + consistent with these implicit @code{Elaborate_All} pragmas. The + disadvantage of this approach is that no such order may exist. + + If the binder does not generate any diagnostics, then it means that it + has found an elaboration order that is guaranteed to be safe. However, + the binder may still be relying on implicitly generated + @code{Elaborate_All} pragmas so portability to other compilers than + GNAT is not guaranteed. + + If it is important to guarantee portability, then the compilations should + use the + @option{-gnatwl} + (warn on elaboration problems) switch. This will cause warning messages + to be generated indicating the missing @code{Elaborate_All} pragmas. + Consider the following source program: + + @smallexample + @group + @cartouche + @b{with} k; + @b{package} j @b{is} + m : integer := k.r; + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + where it is clear that there + should be a pragma @code{Elaborate_All} + for unit @code{k}. An implicit pragma will be generated, and it is + likely that the binder will be able to honor it. However, + it is safer to include the pragma explicitly in the source. If this + unit is compiled with the + @option{-gnatwl} + switch, then the compiler outputs a warning: + + @smallexample + @group + @cartouche + 1. with k; + 2. package j is + 3. m : integer := k.r; + | + >>> warning: call to "r" may raise Program_Error + >>> warning: missing pragma Elaborate_All for "k" + + 4. end; + @end cartouche + @end group + @end smallexample + + @noindent + and these warnings can be used as a guide for supplying manually + the missing pragmas. + + This default mode is more restrictive than the Ada Reference + Manual, and it is possible to construct programs which will compile + using the dynamic model described there, but will run into a + circularity using the safer static model we have described. + + Of course any Ada compiler must be able to operate in a mode + consistent with the requirements of the Ada Reference Manual, + and in particular must have the capability of implementing the + standard dynamic model of elaboration with run-time checks. + + In GNAT, this standard mode can be achieved either by the use of + the @option{-gnatE} switch on the compiler (@code{gcc} or @code{gnatmake}) + command, or by the use of the configuration pragma: + + @smallexample + pragma Elaboration_Checks (RM); + @end smallexample + + @noindent + Either approach will cause the unit affected to be compiled using the + standard dynamic run-time elaboration checks described in the Ada + Reference Manual. The static model is generally preferable, since it + is clearly safer to rely on compile and link time checks rather than + run-time checks. However, in the case of legacy code, it may be + difficult to meet the requirements of the static model. This + issue is further discussed in + @ref{What to Do If the Default Elaboration Behavior Fails}. + + Note that the static model provides a strict subset of the allowed + behavior and programs of the Ada Reference Manual, so if you do + adhere to the static model and no circularities exist, + then you are assured that your program will + work using the dynamic model. + + @node Elaboration Issues for Library Tasks + @section Elaboration Issues for Library Tasks + @cindex Library tasks, elaboration issues + @cindex Elaboration of library tasks + + @noindent + In this section we examine special elaboration issues that arise for + programs that declare library level tasks. + + Generally the model of execution of an Ada program is that all units are + elaborated, and then execution of the program starts. However, the + declaration of library tasks definitely does not fit this model. The + reason for this is that library tasks start as soon as they are declared + (more precisely, as soon as the statement part of the enclosing package + body is reached), that is to say before elaboration + of the program is complete. This means that if such a task calls a + subprogram, or an entry in another task, the callee may or may not be + elaborated yet, and in the standard + Reference Manual model of dynamic elaboration checks, you can even + get timing dependent Program_Error exceptions, since there can be + a race between the elaboration code and the task code. + + The static model of elaboration in GNAT seeks to avoid all such + dynamic behavior, by being conservative, and the conservative + approach in this particular case is to assume that all the code + in a task body is potentially executed at elaboration time if + a task is declared at the library level. + + This can definitely result in unexpected circularities. Consider + the following example + + @smallexample + package Decls is + task Lib_Task is + entry Start; + end Lib_Task; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + procedure Main is + begin + Decls.Lib_Task.Start; + end; + @end smallexample + + @noindent + If the above example is compiled in the default static elaboration + mode, then a circularity occurs. The circularity comes from the call + @code{Utils.Put_Val} in the task body of @code{Decls.Lib_Task}. Since + this call occurs in elaboration code, we need an implicit pragma + @code{Elaborate_All} for @code{Utils}. This means that not only must + the spec and body of @code{Utils} be elaborated before the body + of @code{Decls}, but also the spec and body of any unit that is + @code{with'ed} by the body of @code{Utils} must also be elaborated before + the body of @code{Decls}. This is the transitive implication of + pragma @code{Elaborate_All} and it makes sense, because in general + the body of @code{Put_Val} might have a call to something in a + @code{with'ed} unit. + + In this case, the body of Utils (actually its spec) @code{with's} + @code{Decls}. Unfortunately this means that the body of @code{Decls} + must be elaborated before itself, in case there is a call from the + body of @code{Utils}. + + Here is the exact chain of events we are worrying about: + + @enumerate + @item + In the body of @code{Decls} a call is made from within the body of a library + task to a subprogram in the package @code{Utils}. Since this call may + occur at elaboration time (given that the task is activated at elaboration + time), we have to assume the worst, i.e. that the + call does happen at elaboration time. + + @item + This means that the body and spec of @code{Util} must be elaborated before + the body of @code{Decls} so that this call does not cause an access before + elaboration. + + @item + Within the body of @code{Util}, specifically within the body of + @code{Util.Put_Val} there may be calls to any unit @code{with}'ed + by this package. + + @item + One such @code{with}'ed package is package @code{Decls}, so there + might be a call to a subprogram in @code{Decls} in @code{Put_Val}. + In fact there is such a call in this example, but we would have to + assume that there was such a call even if it were not there, since + we are not supposed to write the body of @code{Decls} knowing what + is in the body of @code{Utils}; certainly in the case of the + static elaboration model, the compiler does not know what is in + other bodies and must assume the worst. + + @item + This means that the spec and body of @code{Decls} must also be + elaborated before we elaborate the unit containing the call, but + that unit is @code{Decls}! This means that the body of @code{Decls} + must be elaborated before itself, and that's a circularity. + @end enumerate + + @noindent + Indeed, if you add an explicit pragma Elaborate_All for @code{Utils} in + the body of @code{Decls} you will get a true Ada Reference Manual + circularity that makes the program illegal. + + In practice, we have found that problems with the static model of + elaboration in existing code often arise from library tasks, so + we must address this particular situation. + + Note that if we compile and run the program above, using the dynamic model of + elaboration (that is to say use the @option{-gnatE} switch), + then it compiles, binds, + links, and runs, printing the expected result of 2. Therefore in some sense + the circularity here is only apparent, and we need to capture + the properties of this program that distinguish it from other library-level + tasks that have real elaboration problems. + + We have four possible answers to this question: + + @itemize @bullet + + @item + Use the dynamic model of elaboration. + + If we use the @option{-gnatE} switch, then as noted above, the program works. + Why is this? If we examine the task body, it is apparent that the task cannot + proceed past the + @code{accept} statement until after elaboration has been completed, because + the corresponding entry call comes from the main program, not earlier. + This is why the dynamic model works here. But that's really giving + up on a precise analysis, and we prefer to take this approach only if we cannot + solve the + problem in any other manner. So let us examine two ways to reorganize + the program to avoid the potential elaboration problem. + + @item + Split library tasks into separate packages. + + Write separate packages, so that library tasks are isolated from + other declarations as much as possible. Let us look at a variation on + the above program. + + @smallexample + package Decls1 is + task Lib_Task is + entry Start; + end Lib_Task; + end Decls1; + + with Utils; + package body Decls1 is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + end Decls1; + + package Decls2 is + type My_Int is new Integer; + function Ident (M : My_Int) return My_Int; + end Decls2; + + with Utils; + package body Decls2 is + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls2; + + with Decls2; + package Utils is + procedure Put_Val (Arg : Decls2.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls2.My_Int) is + begin + Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls1; + procedure Main is + begin + Decls1.Lib_Task.Start; + end; + @end smallexample + + @noindent + All we have done is to split @code{Decls} into two packages, one + containing the library task, and one containing everything else. Now + there is no cycle, and the program compiles, binds, links and executes + using the default static model of elaboration. + + @item + Declare separate task types. + + A significant part of the problem arises because of the use of the + single task declaration form. This means that the elaboration of + the task type, and the elaboration of the task itself (i.e. the + creation of the task) happen at the same time. A good rule + of style in Ada 95 is to always create explicit task types. By + following the additional step of placing task objects in separate + packages from the task type declaration, many elaboration problems + are avoided. Here is another modified example of the example program: + + @smallexample + package Decls is + task type Lib_Task_Type is + entry Start; + end Lib_Task_Type; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task_Type is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task_Type; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + package Declst is + Lib_Task : Decls.Lib_Task_Type; + end Declst; + + with Declst; + procedure Main is + begin + Declst.Lib_Task.Start; + end; + @end smallexample + + @noindent + What we have done here is to replace the @code{task} declaration in + package @code{Decls} with a @code{task type} declaration. Then we + introduce a separate package @code{Declst} to contain the actual + task object. This separates the elaboration issues for + the @code{task type} + declaration, which causes no trouble, from the elaboration issues + of the task object, which is also unproblematic, since it is now independent + of the elaboration of @code{Utils}. + This separation of concerns also corresponds to + a generally sound engineering principle of separating declarations + from instances. This version of the program also compiles, binds, links, + and executes, generating the expected output. + + @item + Use No_Entry_Calls_In_Elaboration_Code restriction. + @cindex No_Entry_Calls_In_Elaboration_Code + + The previous two approaches described how a program can be restructured + to avoid the special problems caused by library task bodies. in practice, + however, such restructuring may be difficult to apply to existing legacy code, + so we must consider solutions that do not require massive rewriting. + + Let us consider more carefully why our original sample program works + under the dynamic model of elaboration. The reason is that the code + in the task body blocks immediately on the @code{accept} + statement. Now of course there is nothing to prohibit elaboration + code from making entry calls (for example from another library level task), + so we cannot tell in isolation that + the task will not execute the accept statement during elaboration. + + However, in practice it is very unusual to see elaboration code + make any entry calls, and the pattern of tasks starting + at elaboration time and then immediately blocking on @code{accept} or + @code{select} statements is very common. What this means is that + the compiler is being too pessimistic when it analyzes the + whole package body as though it might be executed at elaboration + time. + + If we know that the elaboration code contains no entry calls, (a very safe + assumption most of the time, that could almost be made the default + behavior), then we can compile all units of the program under control + of the following configuration pragma: + + @smallexample + pragma Restrictions (No_Entry_Calls_In_Elaboration_Code); + @end smallexample + + @noindent + This pragma can be placed in the @file{gnat.adc} file in the usual + manner. If we take our original unmodified program and compile it + in the presence of a @file{gnat.adc} containing the above pragma, + then once again, we can compile, bind, link, and execute, obtaining + the expected result. In the presence of this pragma, the compiler does + not trace calls in a task body, that appear after the first @code{accept} + or @code{select} statement, and therefore does not report a potential + circularity in the original program. + + The compiler will check to the extent it can that the above + restriction is not violated, but it is not always possible to do a + complete check at compile time, so it is important to use this + pragma only if the stated restriction is in fact met, that is to say + no task receives an entry call before elaboration of all units is completed. + + @end itemize + + @node Mixing Elaboration Models + @section Mixing Elaboration Models + @noindent + So far, we have assumed that the entire program is either compiled + using the dynamic model or static model, ensuring consistency. It + is possible to mix the two models, but rules have to be followed + if this mixing is done to ensure that elaboration checks are not + omitted. + + The basic rule is that @emph{a unit compiled with the static model cannot + be @code{with'ed} by a unit compiled with the dynamic model}. The + reason for this is that in the static model, a unit assumes that + its clients guarantee to use (the equivalent of) pragma + @code{Elaborate_All} so that no elaboration checks are required + in inner subprograms, and this assumption is violated if the + client is compiled with dynamic checks. + + The precise rule is as follows. A unit that is compiled with dynamic + checks can only @code{with} a unit that meets at least one of the + following criteria: + + @itemize @bullet + + @item + The @code{with'ed} unit is itself compiled with dynamic elaboration + checks (that is with the @option{-gnatE} switch. + + @item + The @code{with'ed} unit is an internal GNAT implementation unit from + the System, Interfaces, Ada, or GNAT hierarchies. + + @item + The @code{with'ed} unit has pragma Preelaborate or pragma Pure. + + @item + The @code{with'ing} unit (that is the client) has an explicit pragma + @code{Elaborate_All} for the @code{with'ed} unit. + + @end itemize + + @noindent + If this rule is violated, that is if a unit with dynamic elaboration + checks @code{with's} a unit that does not meet one of the above four + criteria, then the binder (@code{gnatbind}) will issue a warning + similar to that in the following example: + + @smallexample + warning: "x.ads" has dynamic elaboration checks and with's + warning: "y.ads" which has static elaboration checks + @end smallexample + + @noindent + These warnings indicate that the rule has been violated, and that as a result + elaboration checks may be missed in the resulting executable file. + This warning may be suppressed using the @code{-ws} binder switch + in the usual manner. + + One useful application of this mixing rule is in the case of a subsystem + which does not itself @code{with} units from the remainder of the + application. In this case, the entire subsystem can be compiled with + dynamic checks to resolve a circularity in the subsystem, while + allowing the main application that uses this subsystem to be compiled + using the more reliable default static model. + + @node What to Do If the Default Elaboration Behavior Fails + @section What to Do If the Default Elaboration Behavior Fails + + @noindent + If the binder cannot find an acceptable order, it outputs detailed + diagnostics. For example: + @smallexample + @group + @iftex + @leftskip=0cm + @end iftex + error: elaboration circularity detected + info: "proc (body)" must be elaborated before "pack (body)" + info: reason: Elaborate_All probably needed in unit "pack (body)" + info: recompile "pack (body)" with -gnatwl + info: for full details + info: "proc (body)" + info: is needed by its spec: + info: "proc (spec)" + info: which is withed by: + info: "pack (body)" + info: "pack (body)" must be elaborated before "proc (body)" + info: reason: pragma Elaborate in unit "proc (body)" + @end group + + @end smallexample + + @noindent + In this case we have a cycle that the binder cannot break. On the one + hand, there is an explicit pragma Elaborate in @code{proc} for + @code{pack}. This means that the body of @code{pack} must be elaborated + before the body of @code{proc}. On the other hand, there is elaboration + code in @code{pack} that calls a subprogram in @code{proc}. This means + that for maximum safety, there should really be a pragma + Elaborate_All in @code{pack} for @code{proc} which would require that + the body of @code{proc} be elaborated before the body of + @code{pack}. Clearly both requirements cannot be satisfied. + Faced with a circularity of this kind, you have three different options. + + @table @asis + @item Fix the program + The most desirable option from the point of view of long-term maintenance + is to rearrange the program so that the elaboration problems are avoided. + One useful technique is to place the elaboration code into separate + child packages. Another is to move some of the initialization code to + explicitly called subprograms, where the program controls the order + of initialization explicitly. Although this is the most desirable option, + it may be impractical and involve too much modification, especially in + the case of complex legacy code. + + @item Perform dynamic checks + If the compilations are done using the + @option{-gnatE} + (dynamic elaboration check) switch, then GNAT behaves in + a quite different manner. Dynamic checks are generated for all calls + that could possibly result in raising an exception. With this switch, + the compiler does not generate implicit @code{Elaborate_All} pragmas. + The behavior then is exactly as specified in the Ada 95 Reference Manual. + The binder will generate an executable program that may or may not + raise @code{Program_Error}, and then it is the programmer's job to ensure + that it does not raise an exception. Note that it is important to + compile all units with the switch, it cannot be used selectively. + + @item Suppress checks + The drawback of dynamic checks is that they generate a + significant overhead at run time, both in space and time. If you + are absolutely sure that your program cannot raise any elaboration + exceptions, and you still want to use the dynamic elaboration model, + then you can use the configuration pragma + @code{Suppress (Elaboration_Checks)} to suppress all such checks. For + example this pragma could be placed in the @file{gnat.adc} file. + + @item Suppress checks selectively + When you know that certain calls in elaboration code cannot possibly + lead to an elaboration error, and the binder nevertheless generates warnings + on those calls and inserts Elaborate_All pragmas that lead to elaboration + circularities, it is possible to remove those warnings locally and obtain + a program that will bind. Clearly this can be unsafe, and it is the + responsibility of the programmer to make sure that the resulting program has + no elaboration anomalies. The pragma @code{Suppress (Elaboration_Check)} can + be used with different granularity to suppress warnings and break + elaboration circularities: + + @itemize @bullet + @item + Place the pragma that names the called subprogram in the declarative part + that contains the call. + + @item + Place the pragma in the declarative part, without naming an entity. This + disables warnings on all calls in the corresponding declarative region. + + @item + Place the pragma in the package spec that declares the called subprogram, + and name the subprogram. This disables warnings on all elaboration calls to + that subprogram. + + @item + Place the pragma in the package spec that declares the called subprogram, + without naming any entity. This disables warnings on all elaboration calls to + all subprograms declared in this spec. + @end itemize + + @noindent + These four cases are listed in order of decreasing safety, and therefore + require increasing programmer care in their application. Consider the + following program: + @smallexample + + package Pack1 is + function F1 return Integer; + X1 : Integer; + end Pack1; + + package Pack2 is + function F2 return Integer; + function Pure (x : integer) return integer; + -- pragma Suppress (Elaboration_Check, On => Pure); -- (3) + -- pragma Suppress (Elaboration_Check); -- (4) + end Pack2; + + with Pack2; + package body Pack1 is + function F1 return Integer is + begin + return 100; + end F1; + Val : integer := Pack2.Pure (11); -- Elab. call (1) + begin + declare + -- pragma Suppress(Elaboration_Check, Pack2.F2); -- (1) + -- pragma Suppress(Elaboration_Check); -- (2) + begin + X1 := Pack2.F2 + 1; -- Elab. call (2) + end; + end Pack1; + + with Pack1; + package body Pack2 is + function F2 return Integer is + begin + return Pack1.F1; + end F2; + function Pure (x : integer) return integer is + begin + return x ** 3 - 3 * x; + end; + end Pack2; + + with Pack1, Ada.Text_IO; + procedure Proc3 is + begin + Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101 + end Proc3; + @end smallexample + In the absence of any pragmas, an attempt to bind this program produces + the following diagnostics: + @smallexample + @group + @iftex + @leftskip=.5cm + @end iftex + error: elaboration circularity detected + info: "pack1 (body)" must be elaborated before "pack1 (body)" + info: reason: Elaborate_All probably needed in unit "pack1 (body)" + info: recompile "pack1 (body)" with -gnatwl for full details + info: "pack1 (body)" + info: must be elaborated along with its spec: + info: "pack1 (spec)" + info: which is withed by: + info: "pack2 (body)" + info: which must be elaborated along with its spec: + info: "pack2 (spec)" + info: which is withed by: + info: "pack1 (body)" + @end group + @end smallexample + The sources of the circularity are the two calls to @code{Pack2.Pure} and + @code{Pack2.F2} in the body of @code{Pack1}. We can see that the call to + F2 is safe, even though F2 calls F1, because the call appears after the + elaboration of the body of F1. Therefore the pragma (1) is safe, and will + remove the warning on the call. It is also possible to use pragma (2) + because there are no other potentially unsafe calls in the block. + + @noindent + The call to @code{Pure} is safe because this function does not depend on the + state of @code{Pack2}. Therefore any call to this function is safe, and it + is correct to place pragma (3) in the corresponding package spec. + + @noindent + Finally, we could place pragma (4) in the spec of @code{Pack2} to disable + warnings on all calls to functions declared therein. Note that this is not + necessarily safe, and requires more detailed examination of the subprogram + bodies involved. In particular, a call to @code{F2} requires that @code{F1} + be already elaborated. + @end table + + @noindent + It is hard to generalize on which of these four approaches should be + taken. Obviously if it is possible to fix the program so that the default + treatment works, this is preferable, but this may not always be practical. + It is certainly simple enough to use + @option{-gnatE} + but the danger in this case is that, even if the GNAT binder + finds a correct elaboration order, it may not always do so, + and certainly a binder from another Ada compiler might not. A + combination of testing and analysis (for which the warnings generated + with the + @option{-gnatwl} + switch can be useful) must be used to ensure that the program is free + of errors. One switch that is useful in this testing is the + @code{-p (pessimistic elaboration order)} + switch for + @code{gnatbind}. + Normally the binder tries to find an order that has the best chance of + of avoiding elaboration problems. With this switch, the binder + plays a devil's advocate role, and tries to choose the order that + has the best chance of failing. If your program works even with this + switch, then it has a better chance of being error free, but this is still + not a guarantee. + + For an example of this approach in action, consider the C-tests (executable + tests) from the ACVC suite. If these are compiled and run with the default + treatment, then all but one of them succeed without generating any error + diagnostics from the binder. However, there is one test that fails, and + this is not surprising, because the whole point of this test is to ensure + that the compiler can handle cases where it is impossible to determine + a correct order statically, and it checks that an exception is indeed + raised at run time. + + This one test must be compiled and run using the + @option{-gnatE} + switch, and then it passes. Alternatively, the entire suite can + be run using this switch. It is never wrong to run with the dynamic + elaboration switch if your code is correct, and we assume that the + C-tests are indeed correct (it is less efficient, but efficiency is + not a factor in running the ACVC tests.) + + @node Elaboration for Access-to-Subprogram Values + @section Elaboration for Access-to-Subprogram Values + @cindex Access-to-subprogram + + @noindent + The introduction of access-to-subprogram types in Ada 95 complicates + the handling of elaboration. The trouble is that it becomes + impossible to tell at compile time which procedure + is being called. This means that it is not possible for the binder + to analyze the elaboration requirements in this case. + + If at the point at which the access value is created + (i.e., the evaluation of @code{P'Access} for a subprogram @code{P}), + the body of the subprogram is + known to have been elaborated, then the access value is safe, and its use + does not require a check. This may be achieved by appropriate arrangement + of the order of declarations if the subprogram is in the current unit, + or, if the subprogram is in another unit, by using pragma + @code{Pure}, @code{Preelaborate}, or @code{Elaborate_Body} + on the referenced unit. + + If the referenced body is not known to have been elaborated at the point + the access value is created, then any use of the access value must do a + dynamic check, and this dynamic check will fail and raise a + @code{Program_Error} exception if the body has not been elaborated yet. + GNAT will generate the necessary checks, and in addition, if the + @option{-gnatwl} + switch is set, will generate warnings that such checks are required. + + The use of dynamic dispatching for tagged types similarly generates + a requirement for dynamic checks, and premature calls to any primitive + operation of a tagged type before the body of the operation has been elaborated, + will result in the raising of @code{Program_Error}. + + @node Summary of Procedures for Elaboration Control + @section Summary of Procedures for Elaboration Control + @cindex Elaboration control + + @noindent + First, compile your program with the default options, using none of + the special elaboration control switches. If the binder successfully + binds your program, then you can be confident that, apart from issues + raised by the use of access-to-subprogram types and dynamic dispatching, + the program is free of elaboration errors. If it is important that the + program be portable, then use the + @option{-gnatwl} + switch to generate warnings about missing @code{Elaborate_All} + pragmas, and supply the missing pragmas. + + If the program fails to bind using the default static elaboration + handling, then you can fix the program to eliminate the binder + message, or recompile the entire program with the + @option{-gnatE} switch to generate dynamic elaboration checks, + and, if you are sure there really are no elaboration problems, + use a global pragma @code{Suppress (Elaboration_Checks)}. + + @node Other Elaboration Order Considerations + @section Other Elaboration Order Considerations + @noindent + This section has been entirely concerned with the issue of finding a valid + elaboration order, as defined by the Ada Reference Manual. In a case + where several elaboration orders are valid, the task is to find one + of the possible valid elaboration orders (and the static model in GNAT + will ensure that this is achieved). + + The purpose of the elaboration rules in the Ada Reference Manual is to + make sure that no entity is accessed before it has been elaborated. For + a subprogram, this means that the spec and body must have been elaborated + before the subprogram is called. For an object, this means that the object + must have been elaborated before its value is read or written. A violation + of either of these two requirements is an access before elaboration order, + and this section has been all about avoiding such errors. + + In the case where more than one order of elaboration is possible, in the + sense that access before elaboration errors are avoided, then any one of + the orders is "correct" in the sense that it meets the requirements of + the Ada Reference Manual, and no such error occurs. + + However, it may be the case for a given program, that there are + constraints on the order of elaboration that come not from consideration + of avoiding elaboration errors, but rather from extra-lingual logic + requirements. Consider this example: + + @smallexample + with Init_Constants; + package Constants is + X : Integer := 0; + Y : Integer := 0; + end Constants; + + package Init_Constants is + procedure Calc; + end Init_Constants; + + with Constants; + package body Init_Constants is + procedure Calc is begin null; end; + begin + Constants.X := 3; + Constants.Y := 4; + end Init_Constants; + + with Constants; + package Calc is + Z : Integer := Constants.X + Constants.Y; + end Calc; + + with Calc; + with Text_IO; use Text_IO; + procedure Main is + begin + Put_Line (Calc.Z'Img); + end Main; + @end smallexample + + @noindent + In this example, there is more than one valid order of elaboration. For + example both the following are correct orders: + + @smallexample + Init_Constants spec + Constants spec + Calc spec + Main body + Init_Constants body + + and + + Init_Constants spec + Init_Constants body + Constants spec + Calc spec + Main body + @end smallexample + + @noindent + There is no language rule to prefer one or the other, both are correct + from an order of elaboration point of view. But the programmatic effects + of the two orders are very different. In the first, the elaboration routine + of @code{Calc} initializes @code{Z} to zero, and then the main program + runs with this value of zero. But in the second order, the elaboration + routine of @code{Calc} runs after the body of Init_Constants has set + @code{X} and @code{Y} and thus @code{Z} is set to 7 before @code{Main} + runs. + + One could perhaps by applying pretty clever non-artificial intelligence + to the situation guess that it is more likely that the second order of + elaboration is the one desired, but there is no formal linguistic reason + to prefer one over the other. In fact in this particular case, GNAT will + prefer the second order, because of the rule that bodies are elaborated + as soon as possible, but it's just luck that this is what was wanted + (if indeed the second order was preferred). + + If the program cares about the order of elaboration routines in a case like + this, it is important to specify the order required. In this particular + case, that could have been achieved by adding to the spec of Calc: + + @smallexample + pragma Elaborate_All (Constants); + @end smallexample + + @noindent + which requires that the body (if any) and spec of @code{Constants}, + as well as the body and spec of any unit @code{with}'ed by + @code{Constants} be elaborated before @code{Calc} is elaborated. + + Clearly no automatic method can always guess which alternative you require, + and if you are working with legacy code that had constraints of this kind + which were not properly specified by adding @code{Elaborate} or + @code{Elaborate_All} pragmas, then indeed it is possible that two different + compilers can choose different orders. + + The @code{gnatbind} + @code{-p} switch may be useful in smoking + out problems. This switch causes bodies to be elaborated as late as possible + instead of as early as possible. In the example above, it would have forced + the choice of the first elaboration order. If you get different results + when using this switch, and particularly if one set of results is right, + and one is wrong as far as you are concerned, it shows that you have some + missing @code{Elaborate} pragmas. For the example above, we have the + following output: + + @smallexample + gnatmake -f -q main + main + 7 + gnatmake -f -q main -bargs -p + main + 0 + @end smallexample + + @noindent + It is of course quite unlikely that both these results are correct, so + it is up to you in a case like this to investigate the source of the + difference, by looking at the two elaboration orders that are chosen, + and figuring out which is correct, and then adding the necessary + @code{Elaborate_All} pragmas to ensure the desired order. + + @node The Cross-Referencing Tools gnatxref and gnatfind + @chapter The Cross-Referencing Tools @code{gnatxref} and @code{gnatfind} + @findex gnatxref + @findex gnatfind + + @noindent + The compiler generates cross-referencing information (unless + you set the @samp{-gnatx} switch), which are saved in the @file{.ali} files. + This information indicates where in the source each entity is declared and + referenced. Note that entities in package Standard are not included, but + entities in all other predefined units are included in the output. + + Before using any of these two tools, you need to compile successfully your + application, so that GNAT gets a chance to generate the cross-referencing + information. + + The two tools @code{gnatxref} and @code{gnatfind} take advantage of this + information to provide the user with the capability to easily locate the + declaration and references to an entity. These tools are quite similar, + the difference being that @code{gnatfind} is intended for locating + definitions and/or references to a specified entity or entities, whereas + @code{gnatxref} is oriented to generating a full report of all + cross-references. + + To use these tools, you must not compile your application using the + @option{-gnatx} switch on the @file{gnatmake} command line (@inforef{The + GNAT Make Program gnatmake,,gnat_ug}). Otherwise, cross-referencing + information will not be generated. + + @menu + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + @end menu + + @node gnatxref Switches + @section @code{gnatxref} Switches + + @noindent + The command lines for @code{gnatxref} is: + @smallexample + $ gnatxref [switches] sourcefile1 [sourcefile2 ...] + @end smallexample + + @noindent + where + + @table @code + @item sourcefile1, sourcefile2 + identifies the source files for which a report is to be generated. The + 'with'ed units will be processed too. You must provide at least one file. + + These file names are considered to be regular expressions, so for instance + specifying 'source*.adb' is the same as giving every file in the current + directory whose name starts with 'source' and whose extension is 'adb'. + + @end table + + @noindent + The switches can be : + @table @code + @item -a + If this switch is present, @code{gnatfind} and @code{gnatxref} will parse + the read-only files found in the library search path. Otherwise, these files + will be ignored. This option can be used to protect Gnat sources or your own + libraries from being parsed, thus making @code{gnatfind} and @code{gnatxref} + much faster, and their output much smaller. + + @item -aIDIR + When looking for source files also look in directory DIR. The order in which + source file search is undertaken is the same as for @file{gnatmake}. + + @item -aODIR + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as for + @file{gnatmake}. + + @item -nostdinc + Do not look for sources in the system default directory. + + @item -nostdlib + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatxref}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -d + If this switch is set @code{gnatxref} will output the parent type + reference for each matching derived types. + + @item -f + If this switch is set, the output file names will be preceded by their + directory (if the file was found in the search path). If this switch is + not set, the directory will not be printed. + + @item -g + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may accelerate + @code{gnatfind} and @code{gnatxref}. + + @item -IDIR + Equivalent to @samp{-aODIR -aIDIR}. + + @item -pFILE + Specify a project file to use @xref{Project Files}. + By default, @code{gnatxref} and @code{gnatfind} will try to locate a + project file in the current directory. + + If a project file is either specified or found by the tools, then the content + of the source directory and object directory lines are added as if they + had been specified respectively by @samp{-aI} + and @samp{-aO}. + @item -u + Output only unused symbols. This may be really useful if you give your + main compilation unit on the command line, as @code{gnatxref} will then + display every unused entity and 'with'ed package. + + @item -v + Instead of producing the default output, @code{gnatxref} will generate a + @file{tags} file that can be used by vi. For examples how to use this + feature, see @xref{Examples of gnatxref Usage}. The tags file is output + to the standard output, thus you will have to redirect it to a file. + + @end table + + All these switches may be in any order on the command line, and may even + appear after the file names. They need not be separated by spaces, thus + you can say @samp{gnatxref -ag} instead of + @samp{gnatxref -a -g}. + + @node gnatfind Switches + @section @code{gnatfind} Switches + + @noindent + The command line for @code{gnatfind} is: + + @smallexample + $ gnatfind [switches] pattern[:sourcefile[:line[:column]]] + [file1 file2 ...] + @end smallexample + + @noindent + where + + @table @code + @item pattern + An entity will be output only if it matches the regular expression found + in @samp{pattern}, see @xref{Regular Expressions in gnatfind and gnatxref}. + + Omitting the pattern is equivalent to specifying @samp{*}, which + will match any entity. Note that if you do not provide a pattern, you + have to provide both a sourcefile and a line. + + Entity names are given in Latin-1, with uppercase/lowercase equivalence + for matching purposes. At the current time there is no support for + 8-bit codes other than Latin-1, or for wide characters in identifiers. + + @item sourcefile + @code{gnatfind} will look for references, bodies or declarations + of symbols referenced in @file{sourcefile}, at line @samp{line} + and column @samp{column}. See @pxref{Examples of gnatfind Usage} + for syntax examples. + + @item line + is a decimal integer identifying the line number containing + the reference to the entity (or entities) to be located. + + @item column + is a decimal integer identifying the exact location on the + line of the first character of the identifier for the + entity reference. Columns are numbered from 1. + + @item file1 file2 ... + The search will be restricted to these files. If none are given, then + the search will be done for every library file in the search path. + These file must appear only after the pattern or sourcefile. + + These file names are considered to be regular expressions, so for instance + specifying 'source*.adb' is the same as giving every file in the current + directory whose name starts with 'source' and whose extension is 'adb'. + + Not that if you specify at least one file in this part, @code{gnatfind} may + sometimes not be able to find the body of the subprograms... + + @end table + + At least one of 'sourcefile' or 'pattern' has to be present on + the command line. + + The following switches are available: + @table @code + + @item -a + If this switch is present, @code{gnatfind} and @code{gnatxref} will parse + the read-only files found in the library search path. Otherwise, these files + will be ignored. This option can be used to protect Gnat sources or your own + libraries from being parsed, thus making @code{gnatfind} and @code{gnatxref} + much faster, and their output much smaller. + + @item -aIDIR + When looking for source files also look in directory DIR. The order in which + source file search is undertaken is the same as for @file{gnatmake}. + + @item -aODIR + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as for + @file{gnatmake}. + + @item -nostdinc + Do not look for sources in the system default directory. + + @item -nostdlib + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatfind}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -d + If this switch is set, then @code{gnatfind} will output the parent type + reference for each matching derived types. + + @item -e + By default, @code{gnatfind} accept the simple regular expression set for + @samp{pattern}. If this switch is set, then the pattern will be + considered as full Unix-style regular expression. + + @item -f + If this switch is set, the output file names will be preceded by their + directory (if the file was found in the search path). If this switch is + not set, the directory will not be printed. + + @item -g + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may accelerate + @code{gnatfind} and @code{gnatxref}. + + @item -IDIR + Equivalent to @samp{-aODIR -aIDIR}. + + @item -pFILE + Specify a project file (@pxref{Project Files}) to use. + By default, @code{gnatxref} and @code{gnatfind} will try to locate a + project file in the current directory. + + If a project file is either specified or found by the tools, then the content + of the source directory and object directory lines are added as if they + had been specified respectively by @samp{-aI} and + @samp{-aO}. + + @item -r + By default, @code{gnatfind} will output only the information about the + declaration, body or type completion of the entities. If this switch is + set, the @code{gnatfind} will locate every reference to the entities in + the files specified on the command line (or in every file in the search + path if no file is given on the command line). + + @item -s + If this switch is set, then @code{gnatfind} will output the content + of the Ada source file lines were the entity was found. + + @item -t + If this switch is set, then @code{gnatfind} will output the type hierarchy for + the specified type. It act like -d option but recursively from parent + type to parent type. When this switch is set it is not possible to + specify more than one file. + + @end table + + All these switches may be in any order on the command line, and may even + appear after the file names. They need not be separated by spaces, thus + you can say @samp{gnatxref -ag} instead of + @samp{gnatxref -a -g}. + + As stated previously, gnatfind will search in every directory in the + search path. You can force it to look only in the current directory if + you specify @code{*} at the end of the command line. + + + @node Project Files for gnatxref and gnatfind + @section Project Files for @command{gnatxref} and @command{gnatfind} + + @noindent + Project files allow a programmer to specify how to compile its + application, where to find sources,... These files are used primarily by + the Glide Ada mode, but they can also be used by the two tools + @code{gnatxref} and @code{gnatfind}. + + A project file name must end with @file{.adp}. If a single one is + present in the current directory, then @code{gnatxref} and @code{gnatfind} will + extract the information from it. If multiple project files are found, none of + them is read, and you have to use the @samp{-p} switch to specify the one + you want to use. + + The following lines can be included, even though most of them have default + values which can be used in most cases. + The lines can be entered in any order in the file. + Except for @samp{src_dir} and @samp{obj_dir}, you can only have one instance of + each line. If you have multiple instances, only the last one is taken into + account. + + @table @code + @item src_dir=DIR [default: "./"] + specifies a directory where to look for source files. Multiple src_dir lines + can be specified and they will be searched in the order they + are specified. + + @item obj_dir=DIR [default: "./"] + specifies a directory where to look for object and library files. Multiple + obj_dir lines can be specified and they will be searched in the order they + are specified + + @item comp_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{comp_opt@}} notation. This is intended to store the default + switches given to @file{gnatmake} and @file{gcc}. + + @item bind_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{bind_opt@}} notation. This is intended to store the default + switches given to @file{gnatbind}. + + @item link_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{link_opt@}} notation. This is intended to store the default + switches given to @file{gnatlink}. + + @item main=EXECUTABLE [default: ""] + specifies the name of the executable for the application. This variable can + be referred to in the following lines by using the @samp{$@{main@}} notation. + + @item comp_cmd=COMMAND [default: "gcc -c -I$@{src_dir@} -g -gnatq"] + specifies the command used to compile a single file in the application. + + @item make_cmd=COMMAND [default: "gnatmake $@{main@} -aI$@{src_dir@} -aO$@{obj_dir@} -g -gnatq -cargs $@{comp_opt@} -bargs $@{bind_opt@} -largs $@{link_opt@}"] + specifies the command used to recompile the whole application. + + @item run_cmd=COMMAND [default: "$@{main@}"] + specifies the command used to run the application. + + @item debug_cmd=COMMAND [default: "gdb $@{main@}"] + specifies the command used to debug the application + + @end table + + @code{gnatxref} and @code{gnatfind} only take into account the @samp{src_dir} + and @samp{obj_dir} lines, and ignore the others. + + @node Regular Expressions in gnatfind and gnatxref + @section Regular Expressions in @code{gnatfind} and @code{gnatxref} + + @noindent + As specified in the section about @code{gnatfind}, the pattern can be a + regular expression. Actually, there are to set of regular expressions + which are recognized by the program : + + @table @code + @item globbing patterns + These are the most usual regular expression. They are the same that you + generally used in a Unix shell command line, or in a DOS session. + + Here is a more formal grammar : + @smallexample + @group + @iftex + @leftskip=.5cm + @end iftex + regexp ::= term + term ::= elmt -- matches elmt + term ::= elmt elmt -- concatenation (elmt then elmt) + term ::= * -- any string of 0 or more characters + term ::= ? -- matches any character + term ::= [char @{char@}] -- matches any character listed + term ::= [char - char] -- matches any character in range + @end group + @end smallexample + + @item full regular expression + The second set of regular expressions is much more powerful. This is the + type of regular expressions recognized by utilities such a @file{grep}. + + The following is the form of a regular expression, expressed in Ada + reference manual style BNF is as follows + + @smallexample + @iftex + @leftskip=.5cm + @end iftex + @group + regexp ::= term @{| term@} -- alternation (term or term ...) + + term ::= item @{item@} -- concatenation (item then item) + + item ::= elmt -- match elmt + item ::= elmt * -- zero or more elmt's + item ::= elmt + -- one or more elmt's + item ::= elmt ? -- matches elmt or nothing + @end group + @group + elmt ::= nschar -- matches given character + elmt ::= [nschar @{nschar@}] -- matches any character listed + elmt ::= [^ nschar @{nschar@}] -- matches any character not listed + elmt ::= [char - char] -- matches chars in given range + elmt ::= \ char -- matches given character + elmt ::= . -- matches any single character + elmt ::= ( regexp ) -- parens used for grouping + + char ::= any character, including special characters + nschar ::= any character except ()[].*+?^ + @end group + @end smallexample + + Following are a few examples : + + @table @samp + @item abcde|fghi + will match any of the two strings 'abcde' and 'fghi'. + + @item abc*d + will match any string like 'abd', 'abcd', 'abccd', 'abcccd', and so on + + @item [a-z]+ + will match any string which has only lowercase characters in it (and at + least one character + + @end table + @end table + + @node Examples of gnatxref Usage + @section Examples of @code{gnatxref} Usage + + @subsection General Usage + + @noindent + For the following examples, we will consider the following units : + + @smallexample + @group + @cartouche + main.ads: + 1: @b{with} Bar; + 2: @b{package} Main @b{is} + 3: @b{procedure} Foo (B : @b{in} Integer); + 4: C : Integer; + 5: @b{private} + 6: D : Integer; + 7: @b{end} Main; + + main.adb: + 1: @b{package body} Main @b{is} + 2: @b{procedure} Foo (B : @b{in} Integer) @b{is} + 3: @b{begin} + 4: C := B; + 5: D := B; + 6: Bar.Print (B); + 7: Bar.Print (C); + 8: @b{end} Foo; + 9: @b{end} Main; + + bar.ads: + 1: @b{package} Bar @b{is} + 2: @b{procedure} Print (B : Integer); + 3: @b{end} bar; + @end cartouche + @end group + @end smallexample + + @table @code + + @noindent + The first thing to do is to recompile your application (for instance, in + that case just by doing a @samp{gnatmake main}, so that GNAT generates + the cross-referencing information. + You can then issue any of the following commands: + + @item gnatxref main.adb + @code{gnatxref} generates cross-reference information for main.adb + and every unit 'with'ed by main.adb. + + The output would be: + @smallexample + @iftex + @leftskip=0cm + @end iftex + B Type: Integer + Decl: bar.ads 2:22 + B Type: Integer + Decl: main.ads 3:20 + Body: main.adb 2:20 + Ref: main.adb 4:13 5:13 6:19 + Bar Type: Unit + Decl: bar.ads 1:9 + Ref: main.adb 6:8 7:8 + main.ads 1:6 + C Type: Integer + Decl: main.ads 4:5 + Modi: main.adb 4:8 + Ref: main.adb 7:19 + D Type: Integer + Decl: main.ads 6:5 + Modi: main.adb 5:8 + Foo Type: Unit + Decl: main.ads 3:15 + Body: main.adb 2:15 + Main Type: Unit + Decl: main.ads 2:9 + Body: main.adb 1:14 + Print Type: Unit + Decl: bar.ads 2:15 + Ref: main.adb 6:12 7:12 + @end smallexample + + @noindent + that is the entity @code{Main} is declared in main.ads, line 2, column 9, + its body is in main.adb, line 1, column 14 and is not referenced any where. + + The entity @code{Print} is declared in bar.ads, line 2, column 15 and it + it referenced in main.adb, line 6 column 12 and line 7 column 12. + + @item gnatxref package1.adb package2.ads + @code{gnatxref} will generates cross-reference information for + package1.adb, package2.ads and any other package 'with'ed by any + of these. + + @end table + + @subsection Using gnatxref with vi + + @code{gnatxref} can generate a tags file output, which can be used + directly from @file{vi}. Note that the standard version of @file{vi} + will not work properly with overloaded symbols. Consider using another + free implementation of @file{vi}, such as @file{vim}. + + @smallexample + $ gnatxref -v gnatfind.adb > tags + @end smallexample + + @noindent + will generate the tags file for @code{gnatfind} itself (if the sources + are in the search path!). + + From @file{vi}, you can then use the command @samp{:tag @i{entity}} + (replacing @i{entity} by whatever you are looking for), and vi will + display a new file with the corresponding declaration of entity. + + @node Examples of gnatfind Usage + @section Examples of @code{gnatfind} Usage + + @table @code + + @item gnatfind -f xyz:main.adb + Find declarations for all entities xyz referenced at least once in + main.adb. The references are search in every library file in the search + path. + + The directories will be printed as well (as the @samp{-f} + switch is set) + + The output will look like: + @smallexample + directory/main.ads:106:14: xyz <= declaration + directory/main.adb:24:10: xyz <= body + directory/foo.ads:45:23: xyz <= declaration + @end smallexample + + @noindent + that is to say, one of the entities xyz found in main.adb is declared at + line 12 of main.ads (and its body is in main.adb), and another one is + declared at line 45 of foo.ads + + @item gnatfind -fs xyz:main.adb + This is the same command as the previous one, instead @code{gnatfind} will + display the content of the Ada source file lines. + + The output will look like: + + @smallexample + directory/main.ads:106:14: xyz <= declaration + procedure xyz; + directory/main.adb:24:10: xyz <= body + procedure xyz is + directory/foo.ads:45:23: xyz <= declaration + xyz : Integer; + @end smallexample + + @noindent + This can make it easier to find exactly the location your are looking + for. + + @item gnatfind -r "*x*":main.ads:123 foo.adb + Find references to all entities containing an x that are + referenced on line 123 of main.ads. + The references will be searched only in main.adb and foo.adb. + + @item gnatfind main.ads:123 + Find declarations and bodies for all entities that are referenced on + line 123 of main.ads. + + This is the same as @code{gnatfind "*":main.adb:123}. + + @item gnatfind mydir/main.adb:123:45 + Find the declaration for the entity referenced at column 45 in + line 123 of file main.adb in directory mydir. Note that it + is usual to omit the identifier name when the column is given, + since the column position identifies a unique reference. + + The column has to be the beginning of the identifier, and should not + point to any character in the middle of the identifier. + + @end table + + @node File Name Krunching Using gnatkr + @chapter File Name Krunching Using @code{gnatkr} + @findex gnatkr + + @noindent + This chapter discusses the method used by the compiler to shorten + the default file names chosen for Ada units so that they do not + exceed the maximum length permitted. It also describes the + @code{gnatkr} utility that can be used to determine the result of + applying this shortening. + @menu + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + @end menu + + @node About gnatkr + @section About @code{gnatkr} + + @noindent + The default file naming rule in GNAT + is that the file name must be derived from + the unit name. The exact default rule is as follows: + @itemize @bullet + @item + Take the unit name and replace all dots by hyphens. + @item + If such a replacement occurs in the + second character position of a name, and the first character is + a, g, s, or i then replace the dot by the character + ~ (tilde) + instead of a minus. + @end itemize + The reason for this exception is to avoid clashes + with the standard names for children of System, Ada, Interfaces, + and GNAT, which use the prefixes s- a- i- and g- + respectively. + + The @code{-gnatk@var{nn}} + switch of the compiler activates a "krunching" + circuit that limits file names to nn characters (where nn is a decimal + integer). For example, using OpenVMS, + where the maximum file name length is + 39, the value of nn is usually set to 39, but if you want to generate + a set of files that would be usable if ported to a system with some + different maximum file length, then a different value can be specified. + The default value of 39 for OpenVMS need not be specified. + + The @code{gnatkr} utility can be used to determine the krunched name for + a given file, when krunched to a specified maximum length. + + @node Using gnatkr + @section Using @code{gnatkr} + + @noindent + The @code{gnatkr} command has the form + + @smallexample + $ gnatkr @var{name} [@var{length}] + @end smallexample + + + @noindent + @var{name} can be an Ada name with dots or the GNAT name of the unit, + where the dots representing child units or subunit are replaced by + hyphens. The only confusion arises if a name ends in @code{.ads} or + @code{.adb}. @code{gnatkr} takes this to be an extension if there are + no other dots in the name and the whole name is in lowercase. + + @var{length} represents the length of the krunched name. The default + when no argument is given is 8 characters. A length of zero stands for + unlimited, in other words do not chop except for system files which are + always 8. + + @noindent + The output is the krunched name. The output has an extension only if the + original argument was a file name with an extension. + + @node Krunching Method + @section Krunching Method + + @noindent + The initial file name is determined by the name of the unit that the file + contains. The name is formed by taking the full expanded name of the + unit and replacing the separating dots with hyphens and + using lowercase + for all letters, except that a hyphen in the second character position is + replaced by a tilde if the first character is + a, i, g, or s. + The extension is @code{.ads} for a + specification and @code{.adb} for a body. + Krunching does not affect the extension, but the file name is shortened to + the specified length by following these rules: + + @itemize @bullet + @item + The name is divided into segments separated by hyphens, tildes or + underscores and all hyphens, tildes, and underscores are + eliminated. If this leaves the name short enough, we are done. + + @item + If the name is too long, the longest segment is located (left-most if there are two + of equal length), and shortened by dropping its last character. This is + repeated until the name is short enough. + + As an example, consider the krunching of @*@file{our-strings-wide_fixed.adb} + to fit the name into 8 characters as required by some operating systems. + + @smallexample + our-strings-wide_fixed 22 + our strings wide fixed 19 + our string wide fixed 18 + our strin wide fixed 17 + our stri wide fixed 16 + our stri wide fixe 15 + our str wide fixe 14 + our str wid fixe 13 + our str wid fix 12 + ou str wid fix 11 + ou st wid fix 10 + ou st wi fix 9 + ou st wi fi 8 + Final file name: oustwifi.adb + @end smallexample + + @item + The file names for all predefined units are always krunched to eight + characters. The krunching of these predefined units uses the following + special prefix replacements: + + @table @file + @item ada- + replaced by @file{a-} + + @item gnat- + replaced by @file{g-} + + @item interfaces- + replaced by @file{i-} + + @item system- + replaced by @file{s-} + @end table + + These system files have a hyphen in the second character position. That + is why normal user files replace such a character with a + tilde, to + avoid confusion with system file names. + + As an example of this special rule, consider + @*@file{ada-strings-wide_fixed.adb}, which gets krunched as follows: + + @smallexample + ada-strings-wide_fixed 22 + a- strings wide fixed 18 + a- string wide fixed 17 + a- strin wide fixed 16 + a- stri wide fixed 15 + a- stri wide fixe 14 + a- str wide fixe 13 + a- str wid fixe 12 + a- str wid fix 11 + a- st wid fix 10 + a- st wi fix 9 + a- st wi fi 8 + Final file name: a-stwifi.adb + @end smallexample + @end itemize + + Of course no file shortening algorithm can guarantee uniqueness over all + possible unit names, and if file name krunching is used then it is your + responsibility to ensure that no name clashes occur. The utility + program @code{gnatkr} is supplied for conveniently determining the + krunched name of a file. + + @node Examples of gnatkr Usage + @section Examples of @code{gnatkr} Usage + + @smallexample + @iftex + @leftskip=0cm + @end iftex + $ gnatkr very_long_unit_name.ads --> velounna.ads + $ gnatkr grandparent-parent-child.ads --> grparchi.ads + $ gnatkr Grandparent.Parent.Child --> grparchi + $ gnatkr very_long_unit_name.ads/count=6 --> vlunna.ads + $ gnatkr very_long_unit_name.ads/count=0 --> very_long_unit_name.ads + @end smallexample + + @node Preprocessing Using gnatprep + @chapter Preprocessing Using @code{gnatprep} + @findex gnatprep + + @noindent + The @code{gnatprep} utility provides + a simple preprocessing capability for Ada programs. + It is designed for use with GNAT, but is not dependent on any special + features of GNAT. + + @menu + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + @end menu + + @node Using gnatprep + @section Using @code{gnatprep} + + @noindent + To call @code{gnatprep} use + + @smallexample + $ gnatprep [-bcrsu] [-Dsymbol=value] infile outfile [deffile] + @end smallexample + + @noindent + where + @table @code + @item infile + is the full name of the input file, which is an Ada source + file containing preprocessor directives. + + @item outfile + is the full name of the output file, which is an Ada source + in standard Ada form. When used with GNAT, this file name will + normally have an ads or adb suffix. + + @item deffile + is the full name of a text file containing definitions of + symbols to be referenced by the preprocessor. This argument is + optional, and can be replaced by the use of the @code{-D} switch. + + @item switches + is an optional sequence of switches as described in the next section. + @end table + + @node Switches for gnatprep + @section Switches for @code{gnatprep} + + @table @code + + @item -b + Causes both preprocessor lines and the lines deleted by + preprocessing to be replaced by blank lines in the output source file, + preserving line numbers in the output file. + + @item -c + Causes both preprocessor lines and the lines deleted + by preprocessing to be retained in the output source as comments marked + with the special string "--! ". This option will result in line numbers + being preserved in the output file. + + @item -Dsymbol=value + Defines a new symbol, associated with value. If no value is given on the + command line, then symbol is considered to be @code{True}. This switch + can be used in place of a definition file. + + + @item -r + Causes a @code{Source_Reference} pragma to be generated that + references the original input file, so that error messages will use + the file name of this original file. The use of this switch implies + that preprocessor lines are not to be removed from the file, so its + use will force @code{-b} mode if + @code{-c} + has not been specified explicitly. + + Note that if the file to be preprocessed contains multiple units, then + it will be necessary to @code{gnatchop} the output file from + @code{gnatprep}. If a @code{Source_Reference} pragma is present + in the preprocessed file, it will be respected by + @code{gnatchop -r} + so that the final chopped files will correctly refer to the original + input source file for @code{gnatprep}. + + @item -s + Causes a sorted list of symbol names and values to be + listed on the standard output file. + + @item -u + Causes undefined symbols to be treated as having the value FALSE in the context + of a preprocessor test. In the absence of this option, an undefined symbol in + a @code{#if} or @code{#elsif} test will be treated as an error. + + @end table + + @noindent + Note: if neither @code{-b} nor @code{-c} is present, + then preprocessor lines and + deleted lines are completely removed from the output, unless -r is + specified, in which case -b is assumed. + + @node Form of Definitions File + @section Form of Definitions File + + @noindent + The definitions file contains lines of the form + + @smallexample + symbol := value + @end smallexample + + @noindent + where symbol is an identifier, following normal Ada (case-insensitive) + rules for its syntax, and value is one of the following: + + @itemize @bullet + @item + Empty, corresponding to a null substitution + @item + A string literal using normal Ada syntax + @item + Any sequence of characters from the set + (letters, digits, period, underline). + @end itemize + + @noindent + Comment lines may also appear in the definitions file, starting with + the usual @code{--}, + and comments may be added to the definitions lines. + + @node Form of Input Text for gnatprep + @section Form of Input Text for @code{gnatprep} + + @noindent + The input text may contain preprocessor conditional inclusion lines, + as well as general symbol substitution sequences. + + The preprocessor conditional inclusion commands have the form + + @smallexample + @group + @cartouche + #if @i{expression} [then] + lines + #elsif @i{expression} [then] + lines + #elsif @i{expression} [then] + lines + ... + #else + lines + #end if; + @end cartouche + @end group + @end smallexample + + @noindent + In this example, @i{expression} is defined by the following grammar: + @smallexample + @i{expression} ::= + @i{expression} ::= = "" + @i{expression} ::= = + @i{expression} ::= 'Defined + @i{expression} ::= not @i{expression} + @i{expression} ::= @i{expression} and @i{expression} + @i{expression} ::= @i{expression} or @i{expression} + @i{expression} ::= @i{expression} and then @i{expression} + @i{expression} ::= @i{expression} or else @i{expression} + @i{expression} ::= ( @i{expression} ) + @end smallexample + + @noindent + For the first test (@i{expression} ::= ) the symbol must have + either the value true or false, that is to say the right-hand of the + symbol definition must be one of the (case-insensitive) literals + @code{True} or @code{False}. If the value is true, then the + corresponding lines are included, and if the value is false, they are + excluded. + + The test (@i{expression} ::= @code{'Defined}) is true only if + the symbol has been defined in the definition file or by a @code{-D} + switch on the command line. Otherwise, the test is false. + + The equality tests are case insensitive, as are all the preprocessor lines. + + If the symbol referenced is not defined in the symbol definitions file, + then the effect depends on whether or not switch @code{-u} + is specified. If so, then the symbol is treated as if it had the value + false and the test fails. If this switch is not specified, then + it is an error to reference an undefined symbol. It is also an error to + reference a symbol that is defined with a value other than @code{True} + or @code{False}. + + The use of the @code{not} operator inverts the sense of this logical test, so + that the lines are included only if the symbol is not defined. + The @code{then} keyword is optional as shown + + The @code{#} must be the first non-blank character on a line, but + otherwise the format is free form. Spaces or tabs may appear between + the @code{#} and the keyword. The keywords and the symbols are case + insensitive as in normal Ada code. Comments may be used on a + preprocessor line, but other than that, no other tokens may appear on a + preprocessor line. Any number of @code{elsif} clauses can be present, + including none at all. The @code{else} is optional, as in Ada. + + The @code{#} marking the start of a preprocessor line must be the first + non-blank character on the line, i.e. it must be preceded only by + spaces or horizontal tabs. + + Symbol substitution outside of preprocessor lines is obtained by using + the sequence + + @smallexample + $symbol + @end smallexample + + @noindent + anywhere within a source line, except in a comment or within a + string literal. The identifier + following the @code{$} must match one of the symbols defined in the symbol + definition file, and the result is to substitute the value of the + symbol in place of @code{$symbol} in the output file. + + Note that although the substitution of strings within a string literal + is not possible, it is possible to have a symbol whose defined value is + a string literal. So instead of setting XYZ to @code{hello} and writing: + + @smallexample + Header : String := "$XYZ"; + @end smallexample + + @noindent + you should set XYZ to @code{"hello"} and write: + + @smallexample + Header : String := $XYZ; + @end smallexample + + @noindent + and then the substitution will occur as desired. + + + @node The GNAT Library Browser gnatls + @chapter The GNAT Library Browser @code{gnatls} + @findex gnatls + @cindex Library browser + + @noindent + @code{gnatls} is a tool that outputs information about compiled + units. It gives the relationship between objects, unit names and source + files. It can also be used to check the source dependencies of a unit + as well as various characteristics. + + @menu + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + @end menu + + @node Running gnatls + @section Running @code{gnatls} + + @noindent + The @code{gnatls} command has the form + + @smallexample + $ gnatls switches @var{object_or_ali_file} + @end smallexample + + @noindent + The main argument is the list of object or @file{ali} files + (@pxref{The Ada Library Information Files}) + for which information is requested. + + In normal mode, without additional option, @code{gnatls} produces a + four-column listing. Each line represents information for a specific + object. The first column gives the full path of the object, the second + column gives the name of the principal unit in this object, the third + column gives the status of the source and the fourth column gives the + full path of the source representing this unit. + Here is a simple example of use: + + @smallexample + $ gnatls *.o + ./demo1.o demo1 DIF demo1.adb + ./demo2.o demo2 OK demo2.adb + ./hello.o h1 OK hello.adb + ./instr-child.o instr.child MOK instr-child.adb + ./instr.o instr OK instr.adb + ./tef.o tef DIF tef.adb + ./text_io_example.o text_io_example OK text_io_example.adb + ./tgef.o tgef DIF tgef.adb + @end smallexample + + @noindent + The first line can be interpreted as follows: the main unit which is + contained in + object file @file{demo1.o} is demo1, whose main source is in + @file{demo1.adb}. Furthermore, the version of the source used for the + compilation of demo1 has been modified (DIF). Each source file has a status + qualifier which can be: + + @table @code + @item OK (unchanged) + The version of the source file used for the compilation of the + specified unit corresponds exactly to the actual source file. + + @item MOK (slightly modified) + The version of the source file used for the compilation of the + specified unit differs from the actual source file but not enough to + require recompilation. If you use gnatmake with the qualifier + @code{-m (minimal recompilation)}, a file marked + MOK will not be recompiled. + + @item DIF (modified) + No version of the source found on the path corresponds to the source + used to build this object. + + @item ??? (file not found) + No source file was found for this unit. + + @item HID (hidden, unchanged version not first on PATH) + The version of the source that corresponds exactly to the source used + for compilation has been found on the path but it is hidden by another + version of the same source that has been modified. + + @end table + + @node Switches for gnatls + @section Switches for @code{gnatls} + + @noindent + @code{gnatls} recognizes the following switches: + + @table @code + @item -a + @cindex @code{-a} (@code{gnatls}) + Consider all units, including those of the predefined Ada library. + Especially useful with @code{-d}. + + @item -d + @cindex @code{-d} (@code{gnatls}) + List sources from which specified units depend on. + + @item -h + @cindex @code{-h} (@code{gnatls}) + Output the list of options. + + @item -o + @cindex @code{-o} (@code{gnatls}) + Only output information about object files. + + @item -s + @cindex @code{-s} (@code{gnatls}) + Only output information about source files. + + @item -u + @cindex @code{-u} (@code{gnatls}) + Only output information about compilation units. + + @item -aO@var{dir} + @itemx -aI@var{dir} + @itemx -I@var{dir} + @itemx -I- + @itemx -nostdinc + Source path manipulation. Same meaning as the equivalent @code{gnatmake} flags + (see @ref{Switches for gnatmake}). + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatls}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -v + @cindex @code{-s} (@code{gnatls}) + Verbose mode. Output the complete source and object paths. Do not use + the default column layout but instead use long format giving as much as + information possible on each requested units, including special + characteristics such as: + + @table @code + @item Preelaborable + The unit is preelaborable in the Ada 95 sense. + + @item No_Elab_Code + No elaboration code has been produced by the compiler for this unit. + + @item Pure + The unit is pure in the Ada 95 sense. + + @item Elaborate_Body + The unit contains a pragma Elaborate_Body. + + @item Remote_Types + The unit contains a pragma Remote_Types. + + @item Shared_Passive + The unit contains a pragma Shared_Passive. + + @item Predefined + This unit is part of the predefined environment and cannot be modified + by the user. + + @item Remote_Call_Interface + The unit contains a pragma Remote_Call_Interface. + + @end table + + @end table + + @node Examples of gnatls Usage + @section Example of @code{gnatls} Usage + + @noindent + Example of using the verbose switch. Note how the source and + object paths are affected by the -I switch. + + @smallexample + $ gnatls -v -I.. demo1.o + + GNATLS 3.10w (970212) Copyright 1999 Free Software Foundation, Inc. + + Source Search Path: + + ../ + /home/comar/local/adainclude/ + + Object Search Path: + + ../ + /home/comar/local/lib/gcc-lib/mips-sni-sysv4/2.7.2/adalib/ + + ./demo1.o + Unit => + Name => demo1 + Kind => subprogram body + Flags => No_Elab_Code + Source => demo1.adb modified + @end smallexample + + @noindent + The following is an example of use of the dependency list. + Note the use of the -s switch + which gives a straight list of source files. This can be useful for + building specialized scripts. + + @smallexample + $ gnatls -d demo2.o + ./demo2.o demo2 OK demo2.adb + OK gen_list.ads + OK gen_list.adb + OK instr.ads + OK instr-child.ads + + $ gnatls -d -s -a demo1.o + demo1.adb + /home/comar/local/adainclude/ada.ads + /home/comar/local/adainclude/a-finali.ads + /home/comar/local/adainclude/a-filico.ads + /home/comar/local/adainclude/a-stream.ads + /home/comar/local/adainclude/a-tags.ads + gen_list.ads + gen_list.adb + /home/comar/local/adainclude/gnat.ads + /home/comar/local/adainclude/g-io.ads + instr.ads + /home/comar/local/adainclude/system.ads + /home/comar/local/adainclude/s-exctab.ads + /home/comar/local/adainclude/s-finimp.ads + /home/comar/local/adainclude/s-finroo.ads + /home/comar/local/adainclude/s-secsta.ads + /home/comar/local/adainclude/s-stalib.ads + /home/comar/local/adainclude/s-stoele.ads + /home/comar/local/adainclude/s-stratt.ads + /home/comar/local/adainclude/s-tasoli.ads + /home/comar/local/adainclude/s-unstyp.ads + /home/comar/local/adainclude/unchconv.ads + @end smallexample + + + @node GNAT and Libraries + @chapter GNAT and Libraries + @cindex Library, building, installing + + @noindent + This chapter addresses some of the issues related to building and using + a library with GNAT. It also shows how the GNAT run-time library can be + recompiled. + + @menu + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + @end menu + + @node Creating an Ada Library + @section Creating an Ada Library + + @noindent + In the GNAT environment, a library has two components: + @itemize @bullet + @item + Source files. + @item + Compiled code and Ali files. See @ref{The Ada Library Information Files}. + @end itemize + + @noindent + In order to use other packages @ref{The GNAT Compilation Model} + requires a certain number of sources to be available to the compiler. + The minimal set of + sources required includes the specs of all the packages that make up the + visible part of the library as well as all the sources upon which they + depend. The bodies of all visible generic units must also be provided. + @noindent + Although it is not strictly mandatory, it is recommended that all sources + needed to recompile the library be provided, so that the user can make + full use of inter-unit inlining and source-level debugging. This can also + make the situation easier for users that need to upgrade their compilation + toolchain and thus need to recompile the library from sources. + + @noindent + The compiled code can be provided in different ways. The simplest way is + to provide directly the set of objects produced by the compiler during + the compilation of the library. It is also possible to group the objects + into an archive using whatever commands are provided by the operating + system. Finally, it is also possible to create a shared library (see + option -shared in the GCC manual). + + @noindent + There are various possibilities for compiling the units that make up the + library: for example with a Makefile @ref{Using the GNU make Utility}, + or with a conventional script. + For simple libraries, it is also possible to create a + dummy main program which depends upon all the packages that comprise the + interface of the library. This dummy main program can then be given to + gnatmake, in order to build all the necessary objects. Here is an example + of such a dummy program and the generic commands used to build an + archive or a shared library. + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + @b{with} My_Lib.Service1; + @b{with} My_Lib.Service2; + @b{with} My_Lib.Service3; + @b{procedure} My_Lib_Dummy @b{is} + @b{begin} + @b{null}; + @b{end}; + + # compiling the library + $ gnatmake -c my_lib_dummy.adb + + # we don't need the dummy object itself + $ rm my_lib_dummy.o my_lib_dummy.ali + + # create an archive with the remaining objects + $ ar rc libmy_lib.a *.o + # some systems may require "ranlib" to be run as well + + # or create a shared library + $ gcc -shared -o libmy_lib.so *.o + # some systems may require the code to have been compiled with -fPIC + @end smallexample + + @noindent + When the objects are grouped in an archive or a shared library, the user + needs to specify the desired library at link time, unless a pragma + linker_options has been used in one of the sources: + @smallexample + @b{pragma} Linker_Options ("-lmy_lib"); + @end smallexample + + @node Installing an Ada Library + @section Installing an Ada Library + + @noindent + In the GNAT model, installing a library consists in copying into a specific + location the files that make up this library. It is possible to install + the sources in a different directory from the other files (ALI, objects, + archives) since the source path and the object path can easily be + specified separately. + + @noindent + For general purpose libraries, it is possible for the system + administrator to put those libraries in the default compiler paths. To + achieve this, he must specify their location in the configuration files + "ada_source_path" and "ada_object_path" that must be located in the GNAT + installation tree at the same place as the gcc spec file. The location of + the gcc spec file can be determined as follows: + @smallexample + $ gcc -v + @end smallexample + + @noindent + The configuration files mentioned above have simple format: each line in them + must contain one unique + directory name. Those names are added to the corresponding path + in their order of appearance in the file. The names can be either absolute + or relative, in the latter case, they are relative to where theses files + are located. + + @noindent + "ada_source_path" and "ada_object_path" might actually not be present in a + GNAT installation, in which case, GNAT will look for its run-time library in + the directories "adainclude" for the sources and "adalib" for the + objects and ALI files. When the files exist, the compiler does not + look in "adainclude" and "adalib" at all, and thus the "ada_source_path" file + must contain the location for the GNAT run-time sources (which can simply + be "adainclude"). In the same way, the "ada_object_path" file must contain + the location for the GNAT run-time objects (which can simply + be "adalib"). + + @noindent + You can also specify a new default path to the runtime library at compilation + time with the switch "--RTS=@var{rts-path}". You can easily choose and change + the runtime you want your program to be compiled with. This switch is + recognized by gcc, gnatmake, gnatbind, gnatls, gnatfind and gnatxref. + + @noindent + It is possible to install a library before or after the standard GNAT + library, by reordering the lines in the configuration files. In general, a + library must be installed before the GNAT library if it redefines any part of it. + + @node Using an Ada Library + @section Using an Ada Library + + @noindent + In order to use a Ada library, you need to make sure that this + library is on both your source and object path + @ref{Search Paths and the Run-Time Library (RTL)} + and @ref{Search Paths for gnatbind}. For + instance, you can use the library "mylib" installed in "/dir/my_lib_src" + and "/dir/my_lib_obj" with the following commands: + + @smallexample + $ gnatmake -aI/dir/my_lib_src -aO/dir/my_lib_obj my_appl \ + -largs -lmy_lib + @end smallexample + + @noindent + This can be simplified down to the following: + @smallexample + $ gnatmake my_appl + @end smallexample + when the following conditions are met: + @itemize @bullet + @item + "/dir/my_lib_src" has been added by the user to the environment + variable "ADA_INCLUDE_PATH", or by the administrator to the file + "ada_source_path" + @item + "/dir/my_lib_obj" has been added by the user to the environment + variable "ADA_OBJECTS_PATH", or by the administrator to the file + "ada_object_path" + @item + a pragma linker_options, as mentioned in @ref{Creating an Ada Library} + as been added to the sources. + @end itemize + @noindent + + @node Creating an Ada Library to be Used in a Non-Ada Context + @section Creating an Ada Library to be Used in a Non-Ada Context + + @noindent + The previous sections detailed how to create and install a library that + was usable from an Ada main program. Using this library in a non-Ada + context is not possible, because the elaboration of the library is + automatically done as part of the main program elaboration. + + GNAT also provides the ability to build libraries that can be used both + in an Ada and non-Ada context. This section describes how to build such + a library, and then how to use it from a C program. The method for + interfacing with the library from other languages such as Fortran for + instance remains the same. + + @subsection Creating the Library + + @itemize @bullet + @item Identify the units representing the interface of the library. + + Here is an example of simple library interface: + + @smallexample + package Interface is + + procedure Do_Something; + + procedure Do_Something_Else; + + end Interface; + @end smallexample + + @item Use @code{pragma Export} or @code{pragma Convention} for the + exported entities. + + Our package @code{Interface} is then updated as follow: + @smallexample + package Interface is + + procedure Do_Something; + pragma Export (C, Do_Something, "do_something"); + + procedure Do_Something_Else; + pragma Export (C, Do_Something_Else, "do_something_else"); + + end Interface; + @end smallexample + + @item Compile all the units composing the library. + + @item Bind the library objects. + + This step is performed by invoking gnatbind with the @code{-L} + switch. @code{gnatbind} will then generate the library elaboration + procedure (named @code{init}) and the run-time finalization + procedure (named @code{final}). + + @smallexample + # generate the binder file in Ada + $ gnatbind -Lmylib interface + + # generate the binder file in C + $ gnatbind -C -Lmylib interface + @end smallexample + + @item Compile the files generated by the binder + + @smallexample + $ gcc -c b~interface.adb + @end smallexample + + @item Create the library; + + The procedure is identical to the procedure explained in + @ref{Creating an Ada Library}, + except that @file{b~interface.o} needs to be added to + the list of objects. + + @smallexample + # create an archive file + $ ar cr libmylib.a b~interface.o + + # create a shared library + $ gcc -shared -o libmylib.so b~interface.o + @end smallexample + + @item Provide a "foreign" view of the library interface; + + The example below shows the content of @code{mylib_interface.h} (note + that there is no rule for the naming of this file, any name can be used) + @smallexample + /* the library elaboration procedure */ + extern void mylibinit (void); + + /* the library finalization procedure */ + extern void mylibfinal (void); + + /* the interface exported by the library */ + extern void do_something (void); + extern void do_something_else (void); + @end smallexample + @end itemize + + @subsection Using the Library + + @noindent + Libraries built as explained above can be used from any program, provided + that the elaboration procedures (named @code{mylibinit} in the previous + example) are called before the library services are used. Any number of + libraries can be used simultaneously, as long as the elaboration + procedure of each library is called. + + Below is an example of C program that uses our @code{mylib} library. + + @smallexample + #include "mylib_interface.h" + + int + main (void) + @{ + /* First, elaborate the library before using it */ + mylibinit (); + + /* Main program, using the library exported entities */ + do_something (); + do_something_else (); + + /* Library finalization at the end of the program */ + mylibfinal (); + return 0; + @} + @end smallexample + + @noindent + Note that this same library can be used from an equivalent Ada main + program. In addition, if the libraries are installed as detailed in + @ref{Installing an Ada Library}, it is not necessary to invoke the + library elaboration and finalization routines. The binder will ensure + that this is done as part of the main program elaboration and + finalization phases. + + @subsection The Finalization Phase + + @noindent + Invoking any library finalization procedure generated by @code{gnatbind} + shuts down the Ada run time permanently. Consequently, the finalization + of all Ada libraries must be performed at the end of the program. No + call to these libraries nor the Ada run time should be made past the + finalization phase. + + @subsection Restrictions in Libraries + + @noindent + The pragmas listed below should be used with caution inside libraries, + as they can create incompatibilities with other Ada libraries: + @itemize @bullet + @item pragma @code{Locking_Policy} + @item pragma @code{Queuing_Policy} + @item pragma @code{Task_Dispatching_Policy} + @item pragma @code{Unreserve_All_Interrupts} + @end itemize + When using a library that contains such pragmas, the user must make sure + that all libraries use the same pragmas with the same values. Otherwise, + a @code{Program_Error} will + be raised during the elaboration of the conflicting + libraries. The usage of these pragmas and its consequences for the user + should therefore be well documented. + + Similarly, the traceback in exception occurrences mechanism should be + enabled or disabled in a consistent manner across all libraries. + Otherwise, a Program_Error will be raised during the elaboration of the + conflicting libraries. + + If the @code{'Version} and @code{'Body_Version} + attributes are used inside a library, then it is necessary to + perform a @code{gnatbind} step that mentions all ali files in all + libraries, so that version identifiers can be properly computed. + In practice these attributes are rarely used, so this is unlikely + to be a consideration. + + @node Rebuilding the GNAT Run-Time Library + @section Rebuilding the GNAT Run-Time Library + + @noindent + It may be useful to recompile the GNAT library in various contexts, the + most important one being the use of partition-wide configuration pragmas + such as Normalize_Scalar. A special Makefile called + @code{Makefile.adalib} is provided to that effect and can be found in + the directory containing the GNAT library. The location of this + directory depends on the way the GNAT environment has been installed and can + be determined by means of the command: + + @smallexample + $ gnatls -v + @end smallexample + + @noindent + The last entry in the object search path usually contains the + gnat library. This Makefile contains its own documentation and in + particular the set of instructions needed to rebuild a new library and + to use it. + + @node Using the GNU make Utility + @chapter Using the GNU @code{make} Utility + @findex make + + @noindent + This chapter offers some examples of makefiles that solve specific + problems. It does not explain how to write a makefile (see the GNU make + documentation), nor does it try to replace the @code{gnatmake} utility + (@pxref{The GNAT Make Program gnatmake}). + + All the examples in this section are specific to the GNU version of + make. Although @code{make} is a standard utility, and the basic language + is the same, these examples use some advanced features found only in + @code{GNU make}. + + @menu + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + @end menu + + @node Using gnatmake in a Makefile + @section Using gnatmake in a Makefile + @findex makefile + @cindex GNU make + + @noindent + Complex project organizations can be handled in a very powerful way by + using GNU make combined with gnatmake. For instance, here is a Makefile + which allows you to build each subsystem of a big project into a separate + shared library. Such a makefile allows you to significantly reduce the link + time of very big applications while maintaining full coherence at + each step of the build process. + + The list of dependencies are handled automatically by + @code{gnatmake}. The Makefile is simply used to call gnatmake in each of + the appropriate directories. + + Note that you should also read the example on how to automatically + create the list of directories (@pxref{Automatically Creating a List of Directories}) + which might help you in case your project has a lot of + subdirectories. + + @smallexample + @iftex + @leftskip=0cm + @font@heightrm=cmr8 + @heightrm + @end iftex + ## This Makefile is intended to be used with the following directory + ## configuration: + ## - The sources are split into a series of csc (computer software components) + ## Each of these csc is put in its own directory. + ## Their name are referenced by the directory names. + ## They will be compiled into shared library (although this would also work + ## with static libraries + ## - The main program (and possibly other packages that do not belong to any + ## csc is put in the top level directory (where the Makefile is). + ## toplevel_dir __ first_csc (sources) __ lib (will contain the library) + ## \_ second_csc (sources) __ lib (will contain the library) + ## \_ ... + ## Although this Makefile is build for shared library, it is easy to modify + ## to build partial link objects instead (modify the lines with -shared and + ## gnatlink below) + ## + ## With this makefile, you can change any file in the system or add any new + ## file, and everything will be recompiled correctly (only the relevant shared + ## objects will be recompiled, and the main program will be re-linked). + + # The list of computer software component for your project. This might be + # generated automatically. + CSC_LIST=aa bb cc + + # Name of the main program (no extension) + MAIN=main + + # If we need to build objects with -fPIC, uncomment the following line + #NEED_FPIC=-fPIC + + # The following variable should give the directory containing libgnat.so + # You can get this directory through 'gnatls -v'. This is usually the last + # directory in the Object_Path. + GLIB=... + + # The directories for the libraries + # (This macro expands the list of CSC to the list of shared libraries, you + # could simply use the expanded form : + # LIB_DIR=aa/lib/libaa.so bb/lib/libbb.so cc/lib/libcc.so + LIB_DIR=$@{foreach dir,$@{CSC_LIST@},$@{dir@}/lib/lib$@{dir@}.so@} + + $@{MAIN@}: objects $@{LIB_DIR@} + gnatbind $@{MAIN@} $@{CSC_LIST:%=-aO%/lib@} -shared + gnatlink $@{MAIN@} $@{CSC_LIST:%=-l%@} + + objects:: + # recompile the sources + gnatmake -c -i $@{MAIN@}.adb $@{NEED_FPIC@} $@{CSC_LIST:%=-I%@} + + # Note: In a future version of GNAT, the following commands will be simplified + # by a new tool, gnatmlib + $@{LIB_DIR@}: + mkdir -p $@{dir $@@ @} + cd $@{dir $@@ @}; gcc -shared -o $@{notdir $@@ @} ../*.o -L$@{GLIB@} -lgnat + cd $@{dir $@@ @}; cp -f ../*.ali . + + # The dependencies for the modules + # Note that we have to force the expansion of *.o, since in some cases make won't + # be able to do it itself. + aa/lib/libaa.so: $@{wildcard aa/*.o@} + bb/lib/libbb.so: $@{wildcard bb/*.o@} + cc/lib/libcc.so: $@{wildcard cc/*.o@} + + # Make sure all of the shared libraries are in the path before starting the + # program + run:: + LD_LIBRARY_PATH=`pwd`/aa/lib:`pwd`/bb/lib:`pwd`/cc/lib ./$@{MAIN@} + + clean:: + $@{RM@} -rf $@{CSC_LIST:%=%/lib@} + $@{RM@} $@{CSC_LIST:%=%/*.ali@} + $@{RM@} $@{CSC_LIST:%=%/*.o@} + $@{RM@} *.o *.ali $@{MAIN@} + @end smallexample + + @node Automatically Creating a List of Directories + @section Automatically Creating a List of Directories + + @noindent + In most makefiles, you will have to specify a list of directories, and + store it in a variable. For small projects, it is often easier to + specify each of them by hand, since you then have full control over what + is the proper order for these directories, which ones should be + included... + + However, in larger projects, which might involve hundreds of + subdirectories, it might be more convenient to generate this list + automatically. + + The example below presents two methods. The first one, although less + general, gives you more control over the list. It involves wildcard + characters, that are automatically expanded by @code{make}. Its + shortcoming is that you need to explicitly specify some of the + organization of your project, such as for instance the directory tree + depth, whether some directories are found in a separate tree,... + + The second method is the most general one. It requires an external + program, called @code{find}, which is standard on all Unix systems. All + the directories found under a given root directory will be added to the + list. + + @smallexample + @iftex + @leftskip=0cm + @font@heightrm=cmr8 + @heightrm + @end iftex + # The examples below are based on the following directory hierarchy: + # All the directories can contain any number of files + # ROOT_DIRECTORY -> a -> aa -> aaa + # -> ab + # -> ac + # -> b -> ba -> baa + # -> bb + # -> bc + # This Makefile creates a variable called DIRS, that can be reused any time + # you need this list (see the other examples in this section) + + # The root of your project's directory hierarchy + ROOT_DIRECTORY=. + + #### + # First method: specify explicitly the list of directories + # This allows you to specify any subset of all the directories you need. + #### + + DIRS := a/aa/ a/ab/ b/ba/ + + #### + # Second method: use wildcards + # Note that the argument(s) to wildcard below should end with a '/'. + # Since wildcards also return file names, we have to filter them out + # to avoid duplicate directory names. + # We thus use make's @code{dir} and @code{sort} functions. + # It sets DIRs to the following value (note that the directories aaa and baa + # are not given, unless you change the arguments to wildcard). + # DIRS= ./a/a/ ./b/ ./a/aa/ ./a/ab/ ./a/ac/ ./b/ba/ ./b/bb/ ./b/bc/ + #### + + DIRS := $@{sort $@{dir $@{wildcard $@{ROOT_DIRECTORY@}/*/ $@{ROOT_DIRECTORY@}/*/*/@}@}@} + + #### + # Third method: use an external program + # This command is much faster if run on local disks, avoiding NFS slowdowns. + # This is the most complete command: it sets DIRs to the following value: + # DIRS= ./a ./a/aa ./a/aa/aaa ./a/ab ./a/ac ./b ./b/ba ./b/ba/baa ./b/bb ./b/bc + #### + + DIRS := $@{shell find $@{ROOT_DIRECTORY@} -type d -print@} + + @end smallexample + + @node Generating the Command Line Switches + @section Generating the Command Line Switches + + @noindent + Once you have created the list of directories as explained in the + previous section (@pxref{Automatically Creating a List of Directories}), + you can easily generate the command line arguments to pass to gnatmake. + + For the sake of completeness, this example assumes that the source path + is not the same as the object path, and that you have two separate lists + of directories. + + @smallexample + # see "Automatically creating a list of directories" to create + # these variables + SOURCE_DIRS= + OBJECT_DIRS= + + GNATMAKE_SWITCHES := $@{patsubst %,-aI%,$@{SOURCE_DIRS@}@} + GNATMAKE_SWITCHES += $@{patsubst %,-aO%,$@{OBJECT_DIRS@}@} + + all: + gnatmake $@{GNATMAKE_SWITCHES@} main_unit + @end smallexample + + @node Overcoming Command Line Length Limits + @section Overcoming Command Line Length Limits + + @noindent + One problem that might be encountered on big projects is that many + operating systems limit the length of the command line. It is thus hard to give + gnatmake the list of source and object directories. + + This example shows how you can set up environment variables, which will + make @code{gnatmake} behave exactly as if the directories had been + specified on the command line, but have a much higher length limit (or + even none on most systems). + + It assumes that you have created a list of directories in your Makefile, + using one of the methods presented in + @ref{Automatically Creating a List of Directories}. + For the sake of completeness, we assume that the object + path (where the ALI files are found) is different from the sources patch. + + Note a small trick in the Makefile below: for efficiency reasons, we + create two temporary variables (SOURCE_LIST and OBJECT_LIST), that are + expanded immediately by @code{make}. This way we overcome the standard + make behavior which is to expand the variables only when they are + actually used. + + @smallexample + @iftex + @leftskip=0cm + @font@heightrm=cmr8 + @heightrm + @end iftex + # In this example, we create both ADA_INCLUDE_PATH and ADA_OBJECT_PATH. + # This is the same thing as putting the -I arguments on the command line. + # (the equivalent of using -aI on the command line would be to define + # only ADA_INCLUDE_PATH, the equivalent of -aO is ADA_OBJECT_PATH). + # You can of course have different values for these variables. + # + # Note also that we need to keep the previous values of these variables, since + # they might have been set before running 'make' to specify where the GNAT + # library is installed. + + # see "Automatically creating a list of directories" to create these + # variables + SOURCE_DIRS= + OBJECT_DIRS= + + empty:= + space:=$@{empty@} $@{empty@} + SOURCE_LIST := $@{subst $@{space@},:,$@{SOURCE_DIRS@}@} + OBJECT_LIST := $@{subst $@{space@},:,$@{OBJECT_DIRS@}@} + ADA_INCLUDE_PATH += $@{SOURCE_LIST@} + ADA_OBJECT_PATH += $@{OBJECT_LIST@} + export ADA_INCLUDE_PATH + export ADA_OBJECT_PATH + + all: + gnatmake main_unit + @end smallexample + + @node Finding Memory Problems with gnatmem + @chapter Finding Memory Problems with @code{gnatmem} + @findex gnatmem + + @noindent + @code{gnatmem}, is a tool that monitors dynamic allocation and + deallocation activity in a program, and displays information about + incorrect deallocations and possible sources of memory leaks. Gnatmem + provides three type of information: + @itemize @bullet + @item + General information concerning memory management, such as the total + number of allocations and deallocations, the amount of allocated + memory and the high water mark, i.e. the largest amount of allocated + memory in the course of program execution. + + @item + Backtraces for all incorrect deallocations, that is to say deallocations + which do not correspond to a valid allocation. + + @item + Information on each allocation that is potentially the origin of a memory + leak. + @end itemize + + The @code{gnatmem} command has two modes. It can be used with @code{gdb} + or with instrumented allocation and deallocation routines. The later + mode is called the @code{GMEM} mode. Both modes produce the very same + output. + + @menu + * Running gnatmem (GDB Mode):: + * Running gnatmem (GMEM Mode):: + * Switches for gnatmem:: + * Examples of gnatmem Usage:: + * GDB and GMEM Modes:: + * Implementation Note:: + @end menu + + @node Running gnatmem (GDB Mode) + @section Running @code{gnatmem} (GDB Mode) + + @noindent + The @code{gnatmem} command has the form + + @smallexample + $ gnatmem [-q] [n] [-o file] user_program [program_arg]* + or + $ gnatmem [-q] [n] -i file + @end smallexample + + @noindent + Gnatmem must be supplied with the executable to examine, followed by its + run-time inputs. For example, if a program is executed with the command: + @smallexample + $ my_program arg1 arg2 + @end smallexample + then it can be run under @code{gnatmem} control using the command: + @smallexample + $ gnatmem my_program arg1 arg2 + @end smallexample + + The program is transparently executed under the control of the debugger + @ref{The GNAT Debugger GDB}. This does not affect the behavior + of the program, except for sensitive real-time programs. When the program + has completed execution, @code{gnatmem} outputs a report containing general + allocation/deallocation information and potential memory leak. + For better results, the user program should be compiled with + debugging options @ref{Switches for gcc}. + + Here is a simple example of use: + + *************** debut cc + @smallexample + $ gnatmem test_gm + + Global information + ------------------ + Total number of allocations : 45 + Total number of deallocations : 6 + Final Water Mark (non freed mem) : 11.29 Kilobytes + High Water Mark : 11.40 Kilobytes + + . + . + . + Allocation Root # 2 + ------------------- + Number of non freed allocations : 11 + Final Water Mark (non freed mem) : 1.16 Kilobytes + High Water Mark : 1.27 Kilobytes + Backtrace : + test_gm.adb:23 test_gm.alloc + . + . + . + @end smallexample + + The first block of output give general information. In this case, the + Ada construct "@b{new}" was executed 45 times, and only 6 calls to an + unchecked deallocation routine occurred. + + Subsequent paragraphs display information on all allocation roots. + An allocation root is a specific point in the execution of the program + that generates some dynamic allocation, such as a "@b{new}" construct. This + root is represented by an execution backtrace (or subprogram call + stack). By default the backtrace depth for allocations roots is 1, so + that a root corresponds exactly to a source location. The backtrace can + be made deeper, to make the root more specific. + + @node Running gnatmem (GMEM Mode) + @section Running @code{gnatmem} (GMEM Mode) + @cindex @code{GMEM} (@code{gnatmem}) + + @noindent + The @code{gnatmem} command has the form + + @smallexample + $ gnatmem [-q] [n] -i gmem.out user_program [program_arg]* + @end smallexample + + The program must have been linked with the instrumented version of the + allocation and deallocation routines. This is done with linking with the + @file{libgmem.a} library. For better results, the user program should be + compiled with debugging options @ref{Switches for gcc}. For example to + build @file{my_program}: + + @smallexample + $ gnatmake -g my_program -largs -lgmem + @end smallexample + + @noindent + When running @file{my_program} the file @file{gmem.out} is produced. This file + contains information about all allocations and deallocations done by the + program. It is produced by the instrumented allocations and + deallocations routines and will be used by @code{gnatmem}. + + @noindent + Gnatmem must be supplied with the @file{gmem.out} file and the executable to + examine followed by its run-time inputs. For example, if a program is + executed with the command: + @smallexample + $ my_program arg1 arg2 + @end smallexample + then @file{gmem.out} can be analysed by @code{gnatmem} using the command: + @smallexample + $ gnatmem -i gmem.out my_program arg1 arg2 + @end smallexample + + @node Switches for gnatmem + @section Switches for @code{gnatmem} + + @noindent + @code{gnatmem} recognizes the following switches: + + @table @code + + @item @code{-q} + @cindex @code{-q} (@code{gnatmem}) + Quiet. Gives the minimum output needed to identify the origin of the + memory leaks. Omit statistical information. + + @item @code{n} + @cindex @code{n} (@code{gnatmem}) + N is an integer literal (usually between 1 and 10) which controls the + depth of the backtraces defining allocation root. The default value for + N is 1. The deeper the backtrace, the more precise the localization of + the root. Note that the total number of roots can depend on this + parameter. + + @item @code{-o file} + @cindex @code{-o} (@code{gnatmem}) + Direct the gdb output to the specified file. The @code{gdb} script used + to generate this output is also saved in the file @file{gnatmem.tmp}. + + @item @code{-i file} + @cindex @code{-i} (@code{gnatmem}) + Do the @code{gnatmem} processing starting from @file{file} which has + been generated by a previous call to @code{gnatmem} with the -o + switch or @file{gmem.out} produced by @code{GMEM} mode. This is useful + for post mortem processing. + + @end table + + @node Examples of gnatmem Usage + @section Example of @code{gnatmem} Usage + + @noindent + This section is based on the @code{GDB} mode of @code{gnatmem}. The same + results can be achieved using @code{GMEM} mode. See section + @ref{Running gnatmem (GMEM Mode)}. + + @noindent + The first example shows the use of @code{gnatmem} + on a simple leaking program. + Suppose that we have the following Ada program: + + @smallexample + @group + @cartouche + @b{with} Unchecked_Deallocation; + @b{procedure} Test_Gm @b{is} + + @b{type} T @b{is array} (1..1000) @b{of} Integer; + @b{type} Ptr @b{is access} T; + @b{procedure} Free @b{is new} Unchecked_Deallocation (T, Ptr); + A : Ptr; + + @b{procedure} My_Alloc @b{is} + @b{begin} + A := @b{new} T; + @b{end} My_Alloc; + + @b{procedure} My_DeAlloc @b{is} + B : Ptr := A; + @b{begin} + Free (B); + @b{end} My_DeAlloc; + + @b{begin} + My_Alloc; + @b{for} I @b{in} 1 .. 5 @b{loop} + @b{for} J @b{in} I .. 5 @b{loop} + My_Alloc; + @b{end loop}; + My_Dealloc; + @b{end loop}; + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + The program needs to be compiled with debugging option: + + @smallexample + $ gnatmake -g test_gm + @end smallexample + + @code{gnatmem} is invoked simply with + @smallexample + $ gnatmem test_gm + @end smallexample + + @noindent + which produces the following output: + + @smallexample + Global information + ------------------ + Total number of allocations : 18 + Total number of deallocations : 5 + Final Water Mark (non freed mem) : 53.00 Kilobytes + High Water Mark : 56.90 Kilobytes + + Allocation Root # 1 + ------------------- + Number of non freed allocations : 11 + Final Water Mark (non freed mem) : 42.97 Kilobytes + High Water Mark : 46.88 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + + Allocation Root # 2 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 10.02 Kilobytes + High Water Mark : 10.02 Kilobytes + Backtrace : + s-secsta.adb:81 system.secondary_stack.ss_init + + Allocation Root # 3 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 12 Bytes + High Water Mark : 12 Bytes + Backtrace : + s-secsta.adb:181 system.secondary_stack.ss_init + @end smallexample + + @noindent + Note that the GNAT run time contains itself a certain number of + allocations that have no corresponding deallocation, + as shown here for root #2 and root + #1. This is a normal behavior when the number of non freed allocations + is one, it locates dynamic data structures that the run time needs for + the complete lifetime of the program. Note also that there is only one + allocation root in the user program with a single line back trace: + test_gm.adb:11 test_gm.my_alloc, whereas a careful analysis of the + program shows that 'My_Alloc' is called at 2 different points in the + source (line 21 and line 24). If those two allocation roots need to be + distinguished, the backtrace depth parameter can be used: + + @smallexample + $ gnatmem 3 test_gm + @end smallexample + + @noindent + which will give the following output: + + @smallexample + Global information + ------------------ + Total number of allocations : 18 + Total number of deallocations : 5 + Final Water Mark (non freed mem) : 53.00 Kilobytes + High Water Mark : 56.90 Kilobytes + + Allocation Root # 1 + ------------------- + Number of non freed allocations : 10 + Final Water Mark (non freed mem) : 39.06 Kilobytes + High Water Mark : 42.97 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + test_gm.adb:24 test_gm + b_test_gm.c:52 main + + Allocation Root # 2 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 10.02 Kilobytes + High Water Mark : 10.02 Kilobytes + Backtrace : + s-secsta.adb:81 system.secondary_stack.ss_init + s-secsta.adb:283 + b_test_gm.c:33 adainit + + Allocation Root # 3 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 3.91 Kilobytes + High Water Mark : 3.91 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + test_gm.adb:21 test_gm + b_test_gm.c:52 main + + Allocation Root # 4 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 12 Bytes + High Water Mark : 12 Bytes + Backtrace : + s-secsta.adb:181 system.secondary_stack.ss_init + s-secsta.adb:283 + b_test_gm.c:33 adainit + @end smallexample + + @noindent + The allocation root #1 of the first example has been split in 2 roots #1 + and #3 thanks to the more precise associated backtrace. + + @node GDB and GMEM Modes + @section GDB and GMEM Modes + + @noindent + The main advantage of the @code{GMEM} mode is that it is a lot faster than the + @code{GDB} mode where the application must be monitored by a @code{GDB} script. + But the @code{GMEM} mode is available only for DEC Unix, Linux x86, + Solaris (sparc and x86) and Windows 95/98/NT/2000 (x86). + + @noindent + The main advantage of the @code{GDB} mode is that it is available on all + supported platforms. But it can be very slow if the application does a + lot of allocations and deallocations. + + @node Implementation Note + @section Implementation Note + + @menu + * gnatmem Using GDB Mode:: + * gnatmem Using GMEM Mode:: + @end menu + + @node gnatmem Using GDB Mode + @subsection @code{gnatmem} Using @code{GDB} Mode + + @noindent + @code{gnatmem} executes the user program under the control of @code{GDB} using + a script that sets breakpoints and gathers information on each dynamic + allocation and deallocation. The output of the script is then analyzed + by @code{gnatmem} + in order to locate memory leaks and their origin in the + program. Gnatmem works by recording each address returned by the + allocation procedure (@code{__gnat_malloc}) + along with the backtrace at the + allocation point. On each deallocation, the deallocated address is + matched with the corresponding allocation. At the end of the processing, + the unmatched allocations are considered potential leaks. All the + allocations associated with the same backtrace are grouped together and + form an allocation root. The allocation roots are then sorted so that + those with the biggest number of unmatched allocation are printed + first. A delicate aspect of this technique is to distinguish between the + data produced by the user program and the data produced by the gdb + script. Currently, on systems that allow probing the terminal, the gdb + command "tty" is used to force the program output to be redirected to the + current terminal while the @code{gdb} output is directed to a file or to a + pipe in order to be processed subsequently by @code{gnatmem}. + + @node gnatmem Using GMEM Mode + @subsection @code{gnatmem} Using @code{GMEM} Mode + + @noindent + This mode use the same algorithm to detect memory leak as the @code{GDB} + mode of @code{gnatmem}, the only difference is in the way data are + gathered. In @code{GMEM} mode the program is linked with instrumented + version of @code{__gnat_malloc} and @code{__gnat_free} + routines. Information needed to find memory leak are recorded by these + routines in file @file{gmem.out}. This mode also require that the stack + traceback be available, this is only implemented on some platforms + @ref{GDB and GMEM Modes}. + + + @node Finding Memory Problems with GNAT Debug Pool + @chapter Finding Memory Problems with GNAT Debug Pool + @findex Debug Pool + @cindex storage, pool, memory corruption + + @noindent + The use of unchecked deallocation and unchecked conversion can easily + lead to incorrect memory references. The problems generated by such + references are usually difficult to tackle because the symptoms can be + very remote from the origin of the problem. In such cases, it is + very helpful to detect the problem as early as possible. This is the + purpose of the Storage Pool provided by @code{GNAT.Debug_Pools}. + + @noindent + In order to use the GNAT specific debugging pool, the user must + associate a debug pool object with each of the access types that may be + related to suspected memory problems. See Ada Reference Manual + 13.11. + @smallexample + @b{type} Ptr @b{is} @b{access} Some_Type; + Pool : GNAT.Debug_Pools.Debug_Pool; + @b{for} Ptr'Storage_Pool @b{use} Pool; + @end smallexample + + @code{GNAT.Debug_Pools} is derived from of a GNAT-specific kind of + pool: the Checked_Pool. Such pools, like standard Ada storage pools, + allow the user to redefine allocation and deallocation strategies. They + also provide a checkpoint for each dereference, through the use of + the primitive operation @code{Dereference} which is implicitly called at + each dereference of an access value. + + Once an access type has been associated with a debug pool, operations on + values of the type may raise four distinct exceptions, + which correspond to four potential kinds of memory corruption: + @itemize @bullet + @item + @code{GNAT.Debug_Pools.Accessing_Not_Allocated_Storage} + @item + @code{GNAT.Debug_Pools.Accessing_Deallocated_Storage} + @item + @code{GNAT.Debug_Pools.Freeing_Not_Allocated_Storage} + @item + @code{GNAT.Debug_Pools.Freeing_Deallocated_Storage } + @end itemize + + @noindent + For types associated with a Debug_Pool, dynamic allocation is performed using + the standard + GNAT allocation routine. References to all allocated chunks of memory + are kept in an internal dictionary. The deallocation strategy consists + in not releasing the memory to the underlying system but rather to fill + it with a memory pattern easily recognizable during debugging sessions: + The memory pattern is the old IBM hexadecimal convention: 16#DEADBEEF#. + Upon each dereference, a check is made that the access value denotes a properly + allocated memory location. Here is a complete example of use of + @code{Debug_Pools}, that includes typical instances of memory corruption: + @smallexample + @iftex + @leftskip=0cm + @end iftex + @b{with} Gnat.Io; @b{use} Gnat.Io; + @b{with} Unchecked_Deallocation; + @b{with} Unchecked_Conversion; + @b{with} GNAT.Debug_Pools; + @b{with} System.Storage_Elements; + @b{with} Ada.Exceptions; @b{use} Ada.Exceptions; + @b{procedure} Debug_Pool_Test @b{is} + + @b{type} T @b{is} @b{access} Integer; + @b{type} U @b{is} @b{access} @b{all} T; + + P : GNAT.Debug_Pools.Debug_Pool; + @b{for} T'Storage_Pool @b{use} P; + + @b{procedure} Free @b{is} @b{new} Unchecked_Deallocation (Integer, T); + @b{function} UC @b{is} @b{new} Unchecked_Conversion (U, T); + A, B : @b{aliased} T; + + @b{procedure} Info @b{is} @b{new} GNAT.Debug_Pools.Print_Info(Put_Line); + + @b{begin} + Info (P); + A := @b{new} Integer; + B := @b{new} Integer; + B := A; + Info (P); + Free (A); + @b{begin} + Put_Line (Integer'Image(B.@b{all})); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + @b{begin} + Free (B); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + B := UC(A'Access); + @b{begin} + Put_Line (Integer'Image(B.@b{all})); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + @b{begin} + Free (B); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + Info (P); + @b{end} Debug_Pool_Test; + @end smallexample + @noindent + The debug pool mechanism provides the following precise diagnostics on the + execution of this erroneous program: + @smallexample + Debug Pool info: + Total allocated bytes : 0 + Total deallocated bytes : 0 + Current Water Mark: 0 + High Water Mark: 0 + + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 0 + Current Water Mark: 8 + High Water Mark: 8 + + raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 4 + Current Water Mark: 4 + High Water Mark: 8 + + @end smallexample + + @node Creating Sample Bodies Using gnatstub + @chapter Creating Sample Bodies Using @code{gnatstub} + @findex gnatstub + + @noindent + @code{gnatstub} creates body stubs, that is, empty but compilable bodies + for library unit declarations. + + To create a body stub, @code{gnatstub} has to compile the library + unit declaration. Therefore, bodies can be created only for legal + library units. Moreover, if a library unit depends semantically upon + units located outside the current directory, you have to provide + the source search path when calling @code{gnatstub}, see the description + of @code{gnatstub} switches below. + + @menu + * Running gnatstub:: + * Switches for gnatstub:: + @end menu + + @node Running gnatstub + @section Running @code{gnatstub} + + @noindent + @code{gnatstub} has the command-line interface of the form + + @smallexample + $ gnatstub [switches] filename [directory] + @end smallexample + + @noindent + where + @table @code + @item filename + is the name of the source file that contains a library unit declaration + for which a body must be created. This name should follow the GNAT file name + conventions. No crunching is allowed for this file name. The file + name may contain the path information. + + @item directory + indicates the directory to place a body stub (default is the + current directory) + + @item switches + is an optional sequence of switches as described in the next section + @end table + + @node Switches for gnatstub + @section Switches for @code{gnatstub} + + @table @code + + @item -f + If the destination directory already contains a file with a name of the body file + for the argument spec file, replace it with the generated body stub. + + @item -hs + Put the comment header (i.e. all the comments preceding the + compilation unit) from the source of the library unit declaration + into the body stub. + + @item -hg + Put a sample comment header into the body stub. + + @item -IDIR + @itemx -I- + These switches have the same meaning as in calls to gcc. + They define the source search path in the call to gcc issued + by @code{gnatstub} to compile an argument source file. + + @item -i@var{n} + (@var{n} is a decimal natural number). Set the indentation level in the + generated body sample to n, '-i0' means "no indentation", + the default indentation is 3. + + @item -k + Do not remove the tree file (i.e. the snapshot of the compiler internal + structures used by @code{gnatstub}) after creating the body stub. + + @item -l@var{n} + (@var{n} is a decimal positive number) Set the maximum line length in the + body stub to n, the default is 78. + + @item -q + Quiet mode: do not generate a confirmation when a body is + successfully created or a message when a body is not required for an + argument unit. + + @item -r + Reuse the tree file (if it exists) instead of creating it: instead of + creating the tree file for the library unit declaration, gnatstub + tries to find it in the current directory and use it for creating + a body. If the tree file is not found, no body is created. @code{-r} + also implies @code{-k}, whether or not + @code{-k} is set explicitly. + + @item -t + Overwrite the existing tree file: if the current directory already + contains the file which, according to the GNAT file name rules should + be considered as a tree file for the argument source file, gnatstub + will refuse to create the tree file needed to create a body sampler, + unless @code{-t} option is set + + @item -v + Verbose mode: generate version information. + + @end table + + @node Reducing the Size of Ada Executables with gnatelim + @chapter Reducing the Size of Ada Executables with @code{gnatelim} + @findex gnatelim + + @menu + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + @end menu + + @node About gnatelim + @section About @code{gnatelim} + + @noindent + When a program shares a set of Ada + packages with other programs, it may happen that this program uses + only a fraction of the subprograms defined in these packages. The code + created for these unused subprograms increases the size of the executable. + + @code{gnatelim} tracks unused subprograms in an Ada program and + outputs a list of GNAT-specific @code{Eliminate} pragmas (see next + section) marking all the subprograms that are declared but never called. + By placing the list of @code{Eliminate} pragmas in the GNAT configuration + file @file{gnat.adc} and recompiling your program, you may decrease the + size of its executable, because the compiler will not generate the code + for 'eliminated' subprograms. + + @code{gnatelim} needs as its input data a set of tree files + (see @ref{Tree Files}) representing all the components of a program to + process and a bind file for a main subprogram (see + @ref{Preparing Tree and Bind Files for gnatelim}). + + @node Eliminate Pragma + @section @code{Eliminate} Pragma + @findex Eliminate + + @noindent + The simplified syntax of the Eliminate pragma used by @code{gnatelim} is: + + @smallexample + @cartouche + @b{pragma} Eliminate (Library_Unit_Name, Subprogram_Name); + @end cartouche + @end smallexample + + @noindent + where + @table @code + @item Library_Unit_Name + full expanded Ada name of a library unit + + @item Subprogram_Name + a simple or expanded name of a subprogram declared within this + compilation unit + + @end table + + @noindent + The effect of an @code{Eliminate} pragma placed in the GNAT configuration + file @file{gnat.adc} is: + + @itemize @bullet + + @item + If the subprogram @code{Subprogram_Name} is declared within + the library unit @code{Library_Unit_Name}, the compiler will not generate + code for this subprogram. This applies to all overloaded subprograms denoted + by @code{Subprogram_Name}. + + @item + If a subprogram marked by the pragma @code{Eliminate} is used (called) + in a program, the compiler will produce an error message in the place where + it is called. + @end itemize + + @node Tree Files + @section Tree Files + @cindex Tree file + + @noindent + A tree file stores a snapshot of the compiler internal data + structures at the very end of a successful compilation. It contains all the + syntactic and semantic information for the compiled unit and all the + units upon which it depends semantically. + To use tools that make use of tree files, you + need to first produce the right set of tree files. + + GNAT produces correct tree files when -gnatt -gnatc options are set + in a gcc call. The tree files have an .adt extension. + Therefore, to produce a tree file for the compilation unit contained in a file + named @file{foo.adb}, you must use the command + + @smallexample + $ gcc -c -gnatc -gnatt foo.adb + @end smallexample + + @noindent + and you will get the tree file @file{foo.adt}. + compilation. + + @node Preparing Tree and Bind Files for gnatelim + @section Preparing Tree and Bind Files for @code{gnatelim} + + @noindent + A set of tree files covering the program to be analyzed with + @code{gnatelim} and + the bind file for the main subprogram does not have to + be in the current directory. + '-T' gnatelim option may be used to provide + the search path for tree files, and '-b' + option may be used to point to the bind + file to process (see @ref{Running gnatelim}) + + If you do not have the appropriate set of tree + files and the right bind file, you + may create them in the current directory using the following procedure. + + Let @code{Main_Prog} be the name of a main subprogram, and suppose + this subprogram is in a file named @file{main_prog.adb}. + + To create a bind file for @code{gnatelim}, run @code{gnatbind} for + the main subprogram. @code{gnatelim} can work with both Ada and C + bind files; when both are present, it uses the Ada bind file. + The following commands will build the program and create the bind file: + + @smallexample + $ gnatmake -c Main_Prog + $ gnatbind main_prog + @end smallexample + + @noindent + To create a minimal set of tree files covering the whole program, call + @code{gnatmake} for this program as follows: + + @smallexample + $ gnatmake -f -c -gnatc -gnatt Main_Prog + @end smallexample + + @noindent + The @code{-c} gnatmake option turns off the bind and link + steps, that are useless anyway because the sources are compiled with + @option{-gnatc} option which turns off code generation. + + The @code{-f} gnatmake option forces + recompilation of all the needed sources. + + This sequence of actions will create all the data needed by @code{gnatelim} + from scratch and therefore guarantee its consistency. If you would like to + use some existing set of files as @code{gnatelim} output, you must make + sure that the set of files is complete and consistent. You can use the + @code{-m} switch to check if there are missed tree files + + Note, that @code{gnatelim} needs neither object nor ALI files. + + @node Running gnatelim + @section Running @code{gnatelim} + + @noindent + @code{gnatelim} has the following command-line interface: + + @smallexample + $ gnatelim [options] name + @end smallexample + + @noindent + @code{name} should be a full expanded Ada name of a main subprogram + of a program (partition). + + @code{gnatelim} options: + + @table @code + @item -q + Quiet mode: by default @code{gnatelim} generates to the standard error + stream a trace of the source file names of the compilation units being + processed. This option turns this trace off. + + @item -v + Verbose mode: @code{gnatelim} version information is printed as Ada + comments to the standard output stream. + + @item -a + Also look for subprograms from the GNAT run time that can be eliminated. + + @item -m + Check if any tree files are missing for an accurate result. + + @item -T@var{dir} + When looking for tree files also look in directory @var{dir} + + @item -b@var{bind_file} + Specifies @var{bind_file} as the bind file to process. If not set, the name + of the bind file is computed from the full expanded Ada name of a main subprogram. + + @item -d@var{x} + Activate internal debugging switches. @var{x} is a letter or digit, or + string of letters or digits, which specifies the type of debugging + mode desired. Normally these are used only for internal development + or system debugging purposes. You can find full documentation for these + switches in the body of the @code{Gnatelim.Options} unit in the compiler + source file @file{gnatelim-options.adb}. + @end table + + @noindent + @code{gnatelim} sends its output to the standard output stream, and all the + tracing and debug information is sent to the standard error stream. + In order to produce a proper GNAT configuration file + @file{gnat.adc}, redirection must be used: + + @smallexample + $ gnatelim Main_Prog > gnat.adc + @end smallexample + + @noindent + or + + @smallexample + $ gnatelim Main_Prog >> gnat.adc + @end smallexample + + @noindent + In order to append the @code{gnatelim} output to the existing contents of + @file{gnat.adc}. + + @node Correcting the List of Eliminate Pragmas + @section Correcting the List of Eliminate Pragmas + + @noindent + In some rare cases it may happen that @code{gnatelim} will try to eliminate + subprograms which are actually called in the program. In this case, the + compiler will generate an error message of the form: + + @smallexample + file.adb:106:07: cannot call eliminated subprogram "My_Prog" + @end smallexample + + @noindent + You will need to manually remove the wrong @code{Eliminate} pragmas from + the @file{gnat.adc} file. It is advised that you recompile your program + from scratch after that because you need a consistent @file{gnat.adc} file + during the entire compilation. + + @node Making Your Executables Smaller + @section Making Your Executables Smaller + + @noindent + In order to get a smaller executable for your program you now have to + recompile the program completely with the new @file{gnat.adc} file + created by @code{gnatelim} in your current directory: + + @smallexample + $ gnatmake -f Main_Prog + @end smallexample + + @noindent + (you will need @code{-f} option for gnatmake to + recompile everything + with the set of pragmas @code{Eliminate} you have obtained with + @code{gnatelim}). + + Be aware that the set of @code{Eliminate} pragmas is specific to each + program. It is not recommended to merge sets of @code{Eliminate} + pragmas created for different programs in one @file{gnat.adc} file. + + @node Summary of the gnatelim Usage Cycle + @section Summary of the gnatelim Usage Cycle + + @noindent + Here is a quick summary of the steps to be taken in order to reduce + the size of your executables with @code{gnatelim}. You may use + other GNAT options to control the optimization level, + to produce the debugging information, to set search path, etc. + + @enumerate + @item + Produce a bind file and a set of tree files + + @smallexample + $ gnatmake -c Main_Prog + $ gnatbind main_prog + $ gnatmake -f -c -gnatc -gnatt Main_Prog + @end smallexample + + @item + Generate a list of @code{Eliminate} pragmas + @smallexample + $ gnatelim Main_Prog >[>] gnat.adc + @end smallexample + + @item + Recompile the application + + @smallexample + $ gnatmake -f Main_Prog + @end smallexample + + @end enumerate + + @node Other Utility Programs + @chapter Other Utility Programs + + @noindent + This chapter discusses some other utility programs available in the Ada + environment. + + @menu + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * Installing gnathtml:: + @end menu + + @node Using Other Utility Programs with GNAT + @section Using Other Utility Programs with GNAT + + @noindent + The object files generated by GNAT are in standard system format and in + particular the debugging information uses this format. This means + programs generated by GNAT can be used with existing utilities that + depend on these formats. + + In general, any utility program that works with C will also often work with + Ada programs generated by GNAT. This includes software utilities such as + gprof (a profiling program), @code{gdb} (the FSF debugger), and utilities such + as Purify. + + @node The gnatpsta Utility Program + @section The @code{gnatpsta} Utility Program + + @noindent + Many of the definitions in package Standard are implementation-dependent. + However, the source of this package does not exist as an Ada source + file, so these values cannot be determined by inspecting the source. + They can be determined by examining in detail the coding of + @file{cstand.adb} which creates the image of Standard in the compiler, + but this is awkward and requires a great deal of internal knowledge + about the system. + + The @code{gnatpsta} utility is designed to deal with this situation. + It is an Ada program that dynamically determines the + values of all the relevant parameters in Standard, and prints them + out in the form of an Ada source listing for Standard, displaying all + the values of interest. This output is generated to + @file{stdout}. + + To determine the value of any parameter in package Standard, simply + run @code{gnatpsta} with no qualifiers or arguments, and examine + the output. This is preferable to consulting documentation, because + you know that the values you are getting are the actual ones provided + by the executing system. + + @node The External Symbol Naming Scheme of GNAT + @section The External Symbol Naming Scheme of GNAT + + @noindent + In order to interpret the output from GNAT, when using tools that are + originally intended for use with other languages, it is useful to + understand the conventions used to generate link names from the Ada + entity names. + + All link names are in all lowercase letters. With the exception of library + procedure names, the mechanism used is simply to use the full expanded + Ada name with dots replaced by double underscores. For example, suppose + we have the following package spec: + + @smallexample + @group + @cartouche + @b{package} QRS @b{is} + MN : Integer; + @b{end} QRS; + @end cartouche + @end group + @end smallexample + + @noindent + The variable @code{MN} has a full expanded Ada name of @code{QRS.MN}, so + the corresponding link name is @code{qrs__mn}. + @findex Export + Of course if a @code{pragma Export} is used this may be overridden: + + @smallexample + @group + @cartouche + @b{package} Exports @b{is} + Var1 : Integer; + @b{pragma} Export (Var1, C, External_Name => "var1_name"); + Var2 : Integer; + @b{pragma} Export (Var2, C, Link_Name => "var2_link_name"); + @b{end} Exports; + @end cartouche + @end group + @end smallexample + + @noindent + In this case, the link name for @var{Var1} is whatever link name the + C compiler would assign for the C function @var{var1_name}. This typically + would be either @var{var1_name} or @var{_var1_name}, depending on operating + system conventions, but other possibilities exist. The link name for + @var{Var2} is @var{var2_link_name}, and this is not operating system + dependent. + + @findex _main + One exception occurs for library level procedures. A potential ambiguity + arises between the required name @code{_main} for the C main program, + and the name we would otherwise assign to an Ada library level procedure + called @code{Main} (which might well not be the main program). + + To avoid this ambiguity, we attach the prefix @code{_ada_} to such + names. So if we have a library level procedure such as + + @smallexample + @group + @cartouche + @b{procedure} Hello (S : String); + @end cartouche + @end group + @end smallexample + + @noindent + the external name of this procedure will be @var{_ada_hello}. + + @node Ada Mode for Glide + @section Ada Mode for @code{Glide} + + @noindent + The Glide mode for programming in Ada (both, Ada83 and Ada95) helps the + user in understanding existing code and facilitates writing new code. It + furthermore provides some utility functions for easier integration of + standard Emacs features when programming in Ada. + + @subsection General Features: + + @itemize @bullet + @item + Full Integrated Development Environment : + + @itemize @bullet + @item + support of 'project files' for the configuration (directories, + compilation options,...) + + @item + compiling and stepping through error messages. + + @item + running and debugging your applications within Glide. + @end itemize + + @item + easy to use for beginners by pull-down menus, + + @item + user configurable by many user-option variables. + @end itemize + + @subsection Ada Mode Features That Help Understanding Code: + + @itemize @bullet + @item + functions for easy and quick stepping through Ada code, + + @item + getting cross reference information for identifiers (e.g. find the + defining place by a keystroke), + + @item + displaying an index menu of types and subprograms and move point to + the chosen one, + + @item + automatic color highlighting of the various entities in Ada code. + @end itemize + + @subsection Glide Support for Writing Ada Code: + + @itemize @bullet + @item + switching between spec and body files with possible + autogeneration of body files, + + @item + automatic formating of subprograms parameter lists. + + @item + automatic smart indentation according to Ada syntax, + + @item + automatic completion of identifiers, + + @item + automatic casing of identifiers, keywords, and attributes, + + @item + insertion of statement templates, + + @item + filling comment paragraphs like filling normal text, + @end itemize + + For more information, please refer to the online Glide documentation + available in the Glide --> Help Menu. + + @node Converting Ada Files to html with gnathtml + @section Converting Ada Files to html with @code{gnathtml} + + @noindent + This @code{Perl} script allows Ada source files to be browsed using + standard Web browsers. For installation procedure, see the section + @xref{Installing gnathtml}. + + Ada reserved keywords are highlighted in a bold font and Ada comments in + a blue font. Unless your program was compiled with the gcc @option{-gnatx} + switch to suppress the generation of cross-referencing information, user + defined variables and types will appear in a different color; you will + be able to click on any identifier and go to its declaration. + + The command line is as follow: + @smallexample + $ perl gnathtml.pl [switches] ada-files + @end smallexample + + You can pass it as many Ada files as you want. @code{gnathtml} will generate + an html file for every ada file, and a global file called @file{index.htm}. + This file is an index of every identifier defined in the files. + + The available switches are the following ones : + + @table @code + @item -83 + @cindex @code{-83} (@code{gnathtml}) + Only the subset on the Ada 83 keywords will be highlighted, not the full + Ada 95 keywords set. + + @item -cc @var{color} + This option allows you to change the color used for comments. The default + value is green. The color argument can be any name accepted by html. + + @item -d + @cindex @code{-d} (@code{gnathtml}) + If the ada files depend on some other files (using for instance the + @code{with} command, the latter will also be converted to html. + Only the files in the user project will be converted to html, not the files + in the run-time library itself. + + @item -D + This command is the same as -d above, but @code{gnathtml} will also look + for files in the run-time library, and generate html files for them. + + @item -f + @cindex @code{-f} (@code{gnathtml}) + By default, gnathtml will generate html links only for global entities + ('with'ed units, global variables and types,...). If you specify the + @code{-f} on the command line, then links will be generated for local + entities too. + + @item -l @var{number} + @cindex @code{-l} (@code{gnathtml}) + If this switch is provided and @var{number} is not 0, then @code{gnathtml} + will number the html files every @var{number} line. + + @item -I @var{dir} + @cindex @code{-I} (@code{gnathtml}) + Specify a directory to search for library files (@file{.ali} files) and + source files. You can provide several -I switches on the command line, + and the directories will be parsed in the order of the command line. + + @item -o @var{dir} + @cindex @code{-o} (@code{gnathtml}) + Specify the output directory for html files. By default, gnathtml will + saved the generated html files in a subdirectory named @file{html/}. + + @item -p @var{file} + @cindex @code{-p} (@code{gnathtml}) + If you are using Emacs and the most recent Emacs Ada mode, which provides + a full Integrated Development Environment for compiling, checking, + running and debugging applications, you may be using @file{.adp} files + to give the directories where Emacs can find sources and object files. + + Using this switch, you can tell gnathtml to use these files. This allows + you to get an html version of your application, even if it is spread + over multiple directories. + + @item -sc @var{color} + @cindex @code{-sc} (@code{gnathtml}) + This option allows you to change the color used for symbol definitions. + The default value is red. The color argument can be any name accepted by html. + + @item -t @var{file} + @cindex @code{-t} (@code{gnathtml}) + This switch provides the name of a file. This file contains a list of + file names to be converted, and the effect is exactly as though they had + appeared explicitly on the command line. This + is the recommended way to work around the command line length limit on some + systems. + + @end table + + @node Installing gnathtml + @section Installing @code{gnathtml} + + @noindent + @code{Perl} needs to be installed on your machine to run this script. + @code{Perl} is freely available for almost every architecture and + Operating System via the Internet. + + On Unix systems, you may want to modify the first line of the script + @code{gnathtml}, to explicitly tell the Operating system where Perl + is. The syntax of this line is : + @smallexample + #!full_path_name_to_perl + @end smallexample + + @noindent + Alternatively, you may run the script using the following command line: + + @smallexample + $ perl gnathtml.pl [switches] files + @end smallexample + + + @node Running and Debugging Ada Programs + @chapter Running and Debugging Ada Programs + @cindex Debugging + + @noindent + This chapter discusses how to debug Ada programs. An incorrect Ada program + may be handled in three ways by the GNAT compiler: + + @enumerate + @item + The illegality may be a violation of the static semantics of Ada. In + that case GNAT diagnoses the constructs in the program that are illegal. + It is then a straightforward matter for the user to modify those parts of + the program. + + @item + The illegality may be a violation of the dynamic semantics of Ada. In + that case the program compiles and executes, but may generate incorrect + results, or may terminate abnormally with some exception. + + @item + When presented with a program that contains convoluted errors, GNAT + itself may terminate abnormally without providing full diagnostics on + the incorrect user program. + @end enumerate + + @menu + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + @end menu + + @cindex Debugger + @findex gdb + + @node The GNAT Debugger GDB + @section The GNAT Debugger GDB + + @noindent + @code{GDB} is a general purpose, platform-independent debugger that + can be used to debug mixed-language programs compiled with @code{GCC}, + and in particular is capable of debugging Ada programs compiled with + GNAT. The latest versions of @code{GDB} are Ada-aware and can handle + complex Ada data structures. + + The manual @cite{Debugging with GDB} + contains full details on the usage of @code{GDB}, including a section on + its usage on programs. This manual should be consulted for full + details. The section that follows is a brief introduction to the + philosophy and use of @code{GDB}. + + When GNAT programs are compiled, the compiler optionally writes debugging + information into the generated object file, including information on + line numbers, and on declared types and variables. This information is + separate from the generated code. It makes the object files considerably + larger, but it does not add to the size of the actual executable that + will be loaded into memory, and has no impact on run-time performance. The + generation of debug information is triggered by the use of the + -g switch in the gcc or gnatmake command used to carry out + the compilations. It is important to emphasize that the use of these + options does not change the generated code. + + The debugging information is written in standard system formats that + are used by many tools, including debuggers and profilers. The format + of the information is typically designed to describe C types and + semantics, but GNAT implements a translation scheme which allows full + details about Ada types and variables to be encoded into these + standard C formats. Details of this encoding scheme may be found in + the file exp_dbug.ads in the GNAT source distribution. However, the + details of this encoding are, in general, of no interest to a user, + since @code{GDB} automatically performs the necessary decoding. + + When a program is bound and linked, the debugging information is + collected from the object files, and stored in the executable image of + the program. Again, this process significantly increases the size of + the generated executable file, but it does not increase the size of + the executable program itself. Furthermore, if this program is run in + the normal manner, it runs exactly as if the debug information were + not present, and takes no more actual memory. + + However, if the program is run under control of @code{GDB}, the + debugger is activated. The image of the program is loaded, at which + point it is ready to run. If a run command is given, then the program + will run exactly as it would have if @code{GDB} were not present. This + is a crucial part of the @code{GDB} design philosophy. @code{GDB} is + entirely non-intrusive until a breakpoint is encountered. If no + breakpoint is ever hit, the program will run exactly as it would if no + debugger were present. When a breakpoint is hit, @code{GDB} accesses + the debugging information and can respond to user commands to inspect + variables, and more generally to report on the state of execution. + + @node Running GDB + @section Running GDB + + @noindent + The debugger can be launched directly and simply from @code{glide} or + through its graphical interface: @code{gvd}. It can also be used + directly in text mode. Here is described the basic use of @code{GDB} + in text mode. All the commands described below can be used in the + @code{gvd} console window eventhough there is usually other more + graphical ways to achieve the same goals. + + @noindent + The command to run de graphical interface of the debugger is + @smallexample + $ gvd program + @end smallexample + + @noindent + The command to run @code{GDB} in text mode is + + @smallexample + $ gdb program + @end smallexample + + @noindent + where @code{program} is the name of the executable file. This + activates the debugger and results in a prompt for debugger commands. + The simplest command is simply @code{run}, which causes the program to run + exactly as if the debugger were not present. The following section + describes some of the additional commands that can be given to @code{GDB}. + + + @node Introduction to GDB Commands + @section Introduction to GDB Commands + + @noindent + @code{GDB} contains a large repertoire of commands. The manual + @cite{Debugging with GDB} + includes extensive documentation on the use + of these commands, together with examples of their use. Furthermore, + the command @var{help} invoked from within @code{GDB} activates a simple help + facility which summarizes the available commands and their options. + In this section we summarize a few of the most commonly + used commands to give an idea of what @code{GDB} is about. You should create + a simple program with debugging information and experiment with the use of + these @code{GDB} commands on the program as you read through the + following section. + + @table @code + @item set args @var{arguments} + The @var{arguments} list above is a list of arguments to be passed to + the program on a subsequent run command, just as though the arguments + had been entered on a normal invocation of the program. The @code{set args} + command is not needed if the program does not require arguments. + + @item run + The @code{run} command causes execution of the program to start from + the beginning. If the program is already running, that is to say if + you are currently positioned at a breakpoint, then a prompt will ask + for confirmation that you want to abandon the current execution and + restart. + + @item breakpoint @var{location} + The breakpoint command sets a breakpoint, that is to say a point at which + execution will halt and @code{GDB} will await further + commands. @var{location} is + either a line number within a file, given in the format @code{file:linenumber}, + or it is the name of a subprogram. If you request that a breakpoint be set on + a subprogram that is overloaded, a prompt will ask you to specify on which of + those subprograms you want to breakpoint. You can also + specify that all of them should be breakpointed. If the program is run + and execution encounters the breakpoint, then the program + stops and @code{GDB} signals that the breakpoint was encountered by + printing the line of code before which the program is halted. + + @item breakpoint exception @var{name} + A special form of the breakpoint command which breakpoints whenever + exception @var{name} is raised. + If @var{name} is omitted, + then a breakpoint will occur when any exception is raised. + + @item print @var{expression} + This will print the value of the given expression. Most simple + Ada expression formats are properly handled by @code{GDB}, so the expression + can contain function calls, variables, operators, and attribute references. + + @item continue + Continues execution following a breakpoint, until the next breakpoint or the + termination of the program. + + @item step + Executes a single line after a breakpoint. If the next statement is a subprogram + call, execution continues into (the first statement of) the + called subprogram. + + @item next + Executes a single line. If this line is a subprogram call, executes and + returns from the call. + + @item list + Lists a few lines around the current source location. In practice, it + is usually more convenient to have a separate edit window open with the + relevant source file displayed. Successive applications of this command + print subsequent lines. The command can be given an argument which is a + line number, in which case it displays a few lines around the specified one. + + @item backtrace + Displays a backtrace of the call chain. This command is typically + used after a breakpoint has occurred, to examine the sequence of calls that + leads to the current breakpoint. The display includes one line for each + activation record (frame) corresponding to an active subprogram. + + @item up + At a breakpoint, @code{GDB} can display the values of variables local + to the current frame. The command @code{up} can be used to + examine the contents of other active frames, by moving the focus up + the stack, that is to say from callee to caller, one frame at a time. + + @item down + Moves the focus of @code{GDB} down from the frame currently being + examined to the frame of its callee (the reverse of the previous command), + + @item frame @var{n} + Inspect the frame with the given number. The value 0 denotes the frame + of the current breakpoint, that is to say the top of the call stack. + + @end table + + The above list is a very short introduction to the commands that + @code{GDB} provides. Important additional capabilities, including conditional + breakpoints, the ability to execute command sequences on a breakpoint, + the ability to debug at the machine instruction level and many other + features are described in detail in @cite{Debugging with GDB}. + Note that most commands can be abbreviated + (for example, c for continue, bt for backtrace). + + @node Using Ada Expressions + @section Using Ada Expressions + @cindex Ada expressions + + @noindent + @code{GDB} supports a fairly large subset of Ada expression syntax, with some + extensions. The philosophy behind the design of this subset is + + @itemize @bullet + @item + That @code{GDB} should provide basic literals and access to operations for + arithmetic, dereferencing, field selection, indexing, and subprogram calls, + leaving more sophisticated computations to subprograms written into the + program (which therefore may be called from @code{GDB}). + + @item + That type safety and strict adherence to Ada language restrictions + are not particularly important to the @code{GDB} user. + + @item + That brevity is important to the @code{GDB} user. + @end itemize + + Thus, for brevity, the debugger acts as if there were + implicit @code{with} and @code{use} clauses in effect for all user-written + packages, thus making it unnecessary to fully qualify most names with + their packages, regardless of context. Where this causes ambiguity, + @code{GDB} asks the user's intent. + + For details on the supported Ada syntax, see @cite{Debugging with GDB}. + + @node Calling User-Defined Subprograms + @section Calling User-Defined Subprograms + + @noindent + An important capability of @code{GDB} is the ability to call user-defined + subprograms while debugging. This is achieved simply by entering + a subprogram call statement in the form: + + @smallexample + call subprogram-name (parameters) + @end smallexample + + @noindent + The keyword @code{call} can be omitted in the normal case where the + @code{subprogram-name} does not coincide with any of the predefined + @code{GDB} commands. + + The effect is to invoke the given subprogram, passing it the + list of parameters that is supplied. The parameters can be expressions and + can include variables from the program being debugged. The + subprogram must be defined + at the library level within your program, and @code{GDB} will call the + subprogram within the environment of your program execution (which + means that the subprogram is free to access or even modify variables + within your program). + + The most important use of this facility is in allowing the inclusion of + debugging routines that are tailored to particular data structures + in your program. Such debugging routines can be written to provide a suitably + high-level description of an abstract type, rather than a low-level dump + of its physical layout. After all, the standard + @code{GDB print} command only knows the physical layout of your + types, not their abstract meaning. Debugging routines can provide information + at the desired semantic level and are thus enormously useful. + + For example, when debugging GNAT itself, it is crucial to have access to + the contents of the tree nodes used to represent the program internally. + But tree nodes are represented simply by an integer value (which in turn + is an index into a table of nodes). + Using the @code{print} command on a tree node would simply print this integer + value, which is not very useful. But the PN routine (defined in file + treepr.adb in the GNAT sources) takes a tree node as input, and displays + a useful high level representation of the tree node, which includes the + syntactic category of the node, its position in the source, the integers + that denote descendant nodes and parent node, as well as varied + semantic information. To study this example in more detail, you might want to + look at the body of the PN procedure in the stated file. + + @node Using the Next Command in a Function + @section Using the Next Command in a Function + + @noindent + When you use the @code{next} command in a function, the current source + location will advance to the next statement as usual. A special case + arises in the case of a @code{return} statement. + + Part of the code for a return statement is the "epilog" of the function. + This is the code that returns to the caller. There is only one copy of + this epilog code, and it is typically associated with the last return + statement in the function if there is more than one return. In some + implementations, this epilog is associated with the first statement + of the function. + + The result is that if you use the @code{next} command from a return + statement that is not the last return statement of the function you + may see a strange apparent jump to the last return statement or to + the start of the function. You should simply ignore this odd jump. + The value returned is always that from the first return statement + that was stepped through. + + @node Ada Exceptions + @section Breaking on Ada Exceptions + @cindex Exceptions + + @noindent + You can set breakpoints that trip when your program raises + selected exceptions. + + @table @code + @item break exception + Set a breakpoint that trips whenever (any task in the) program raises + any exception. + + @item break exception @var{name} + Set a breakpoint that trips whenever (any task in the) program raises + the exception @var{name}. + + @item break exception unhandled + Set a breakpoint that trips whenever (any task in the) program raises an + exception for which there is no handler. + + @item info exceptions + @itemx info exceptions @var{regexp} + The @code{info exceptions} command permits the user to examine all defined + exceptions within Ada programs. With a regular expression, @var{regexp}, as + argument, prints out only those exceptions whose name matches @var{regexp}. + @end table + + @node Ada Tasks + @section Ada Tasks + @cindex Tasks + + @noindent + @code{GDB} allows the following task-related commands: + + @table @code + @item info tasks + This command shows a list of current Ada tasks, as in the following example: + + @smallexample + @iftex + @leftskip=0cm + @end iftex + (gdb) info tasks + ID TID P-ID Thread Pri State Name + 1 8088000 0 807e000 15 Child Activation Wait main_task + 2 80a4000 1 80ae000 15 Accept/Select Wait b + 3 809a800 1 80a4800 15 Child Activation Wait a + * 4 80ae800 3 80b8000 15 Running c + @end smallexample + + @noindent + In this listing, the asterisk before the first task indicates it to be the + currently running task. The first column lists the task ID that is used + to refer to tasks in the following commands. + + @item break @var{linespec} task @var{taskid} + @itemx break @var{linespec} task @var{taskid} if @dots{} + @cindex Breakpoints and tasks + These commands are like the @code{break @dots{} thread @dots{}}. + @var{linespec} specifies source lines. + + Use the qualifier @samp{task @var{taskid}} with a breakpoint command + to specify that you only want @code{GDB} to stop the program when a + particular Ada task reaches this breakpoint. @var{taskid} is one of the + numeric task identifiers assigned by @code{GDB}, shown in the first + column of the @samp{info tasks} display. + + If you do not specify @samp{task @var{taskid}} when you set a + breakpoint, the breakpoint applies to @emph{all} tasks of your + program. + + You can use the @code{task} qualifier on conditional breakpoints as + well; in this case, place @samp{task @var{taskid}} before the + breakpoint condition (before the @code{if}). + + @item task @var{taskno} + @cindex Task switching + + This command allows to switch to the task referred by @var{taskno}. In + particular, This allows to browse the backtrace of the specified + task. It is advised to switch back to the original task before + continuing execution otherwise the scheduling of the program may be + perturbated. + @end table + + @noindent + For more detailed information on the tasking support, see @cite{Debugging with GDB}. + + @node Debugging Generic Units + @section Debugging Generic Units + @cindex Debugging Generic Units + @cindex Generics + + @noindent + GNAT always uses code expansion for generic instantiation. This means that + each time an instantiation occurs, a complete copy of the original code is + made, with appropriate substitutions of formals by actuals. + + It is not possible to refer to the original generic entities in + @code{GDB}, but it is always possible to debug a particular instance of + a generic, by using the appropriate expanded names. For example, if we have + + @smallexample + @group + @cartouche + @b{procedure} g @b{is} + + @b{generic package} k @b{is} + @b{procedure} kp (v1 : @b{in out} integer); + @b{end} k; + + @b{package body} k @b{is} + @b{procedure} kp (v1 : @b{in out} integer) @b{is} + @b{begin} + v1 := v1 + 1; + @b{end} kp; + @b{end} k; + + @b{package} k1 @b{is new} k; + @b{package} k2 @b{is new} k; + + var : integer := 1; + + @b{begin} + k1.kp (var); + k2.kp (var); + k1.kp (var); + k2.kp (var); + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + Then to break on a call to procedure kp in the k2 instance, simply + use the command: + + @smallexample + (gdb) break g.k2.kp + @end smallexample + + @noindent + When the breakpoint occurs, you can step through the code of the + instance in the normal manner and examine the values of local variables, as for + other units. + + @node GNAT Abnormal Termination or Failure to Terminate + @section GNAT Abnormal Termination or Failure to Terminate + @cindex GNAT Abnormal Termination or Failure to Terminate + + @noindent + When presented with programs that contain serious errors in syntax + or semantics, + GNAT may on rare occasions experience problems in operation, such + as aborting with a + segmentation fault or illegal memory access, raising an internal + exception, terminating abnormally, or failing to terminate at all. + In such cases, you can activate + various features of GNAT that can help you pinpoint the construct in your + program that is the likely source of the problem. + + The following strategies are presented in increasing order of + difficulty, corresponding to your experience in using GNAT and your + familiarity with compiler internals. + + @enumerate + @item + Run @code{gcc} with the @option{-gnatf}. This first + switch causes all errors on a given line to be reported. In its absence, + only the first error on a line is displayed. + + The @option{-gnatdO} switch causes errors to be displayed as soon as they + are encountered, rather than after compilation is terminated. If GNAT + terminates prematurely or goes into an infinite loop, the last error + message displayed may help to pinpoint the culprit. + + @item + Run @code{gcc} with the @code{-v (verbose)} switch. In this mode, + @code{gcc} produces ongoing information about the progress of the + compilation and provides the name of each procedure as code is + generated. This switch allows you to find which Ada procedure was being + compiled when it encountered a code generation problem. + + @item + @cindex @option{-gnatdc} switch + Run @code{gcc} with the @option{-gnatdc} switch. This is a GNAT specific + switch that does for the front-end what @code{-v} does for the back end. + The system prints the name of each unit, either a compilation unit or + nested unit, as it is being analyzed. + @item + Finally, you can start + @code{gdb} directly on the @code{gnat1} executable. @code{gnat1} is the + front-end of GNAT, and can be run independently (normally it is just + called from @code{gcc}). You can use @code{gdb} on @code{gnat1} as you + would on a C program (but @pxref{The GNAT Debugger GDB} for caveats). The + @code{where} command is the first line of attack; the variable + @code{lineno} (seen by @code{print lineno}), used by the second phase of + @code{gnat1} and by the @code{gcc} backend, indicates the source line at + which the execution stopped, and @code{input_file name} indicates the name of + the source file. + @end enumerate + + @node Naming Conventions for GNAT Source Files + @section Naming Conventions for GNAT Source Files + + @noindent + In order to examine the workings of the GNAT system, the following + brief description of its organization may be helpful: + + @itemize @bullet + @item + Files with prefix @file{sc} contain the lexical scanner. + + @item + All files prefixed with @file{par} are components of the parser. The + numbers correspond to chapters of the Ada 95 Reference Manual. For example, + parsing of select statements can be found in @file{par-ch9.adb}. + + @item + All files prefixed with @file{sem} perform semantic analysis. The + numbers correspond to chapters of the Ada standard. For example, all + issues involving context clauses can be found in @file{sem_ch10.adb}. In + addition, some features of the language require sufficient special processing + to justify their own semantic files: sem_aggr for aggregates, sem_disp for + dynamic dispatching, etc. + + @item + All files prefixed with @file{exp} perform normalization and + expansion of the intermediate representation (abstract syntax tree, or AST). + these files use the same numbering scheme as the parser and semantics files. + For example, the construction of record initialization procedures is done in + @file{exp_ch3.adb}. + + @item + The files prefixed with @file{bind} implement the binder, which + verifies the consistency of the compilation, determines an order of + elaboration, and generates the bind file. + + @item + The files @file{atree.ads} and @file{atree.adb} detail the low-level + data structures used by the front-end. + + @item + The files @file{sinfo.ads} and @file{sinfo.adb} detail the structure of + the abstract syntax tree as produced by the parser. + + @item + The files @file{einfo.ads} and @file{einfo.adb} detail the attributes of + all entities, computed during semantic analysis. + + @item + Library management issues are dealt with in files with prefix + @file{lib}. + + @item + @findex Ada + @cindex Annex A + Ada files with the prefix @file{a-} are children of @code{Ada}, as + defined in Annex A. + + @item + @findex Interfaces + @cindex Annex B + Files with prefix @file{i-} are children of @code{Interfaces}, as + defined in Annex B. + + @item + @findex System + Files with prefix @file{s-} are children of @code{System}. This includes + both language-defined children and GNAT run-time routines. + + @item + @findex GNAT + Files with prefix @file{g-} are children of @code{GNAT}. These are useful + general-purpose packages, fully documented in their specifications. All + the other @file{.c} files are modifications of common @code{gcc} files. + @end itemize + + @node Getting Internal Debugging Information + @section Getting Internal Debugging Information + + @noindent + Most compilers have internal debugging switches and modes. GNAT + does also, except GNAT internal debugging switches and modes are not + secret. A summary and full description of all the compiler and binder + debug flags are in the file @file{debug.adb}. You must obtain the + sources of the compiler to see the full detailed effects of these flags. + + The switches that print the source of the program (reconstructed from + the internal tree) are of general interest for user programs, as are the + options to print + the full internal tree, and the entity table (the symbol table + information). The reconstructed source provides a readable version of the + program after the front-end has completed analysis and expansion, and is useful + when studying the performance of specific constructs. For example, constraint + checks are indicated, complex aggregates are replaced with loops and + assignments, and tasking primitives are replaced with run-time calls. + + @node Stack Traceback + @section Stack Traceback + @cindex traceback + @cindex stack traceback + @cindex stack unwinding + + @noindent + Traceback is a mechanism to display the sequence of subprogram calls that + leads to a specified execution point in a program. Often (but not always) + the execution point is an instruction at which an exception has been raised. + This mechanism is also known as @i{stack unwinding} because it obtains + its information by scanning the run-time stack and recovering the activation + records of all active subprograms. Stack unwinding is one of the most + important tools for program debugging. + + @noindent + The first entry stored in traceback corresponds to the deepest calling level, + that is to say the subprogram currently executing the instruction + from which we want to obtain the traceback. + + @noindent + Note that there is no runtime performance penalty when stack traceback + is enabled and no exception are raised during program execution. + + @menu + * Non-Symbolic Traceback:: + * Symbolic Traceback:: + @end menu + + @node Non-Symbolic Traceback + @subsection Non-Symbolic Traceback + @cindex traceback, non-symbolic + + @noindent + Note: this feature is not supported on all platforms. See + @file{GNAT.Traceback spec in g-traceb.ads} for a complete list of supported + platforms. + + @menu + * Tracebacks From an Unhandled Exception:: + * Tracebacks From Exception Occurrences (non-symbolic):: + * Tracebacks From Anywhere in a Program (non-symbolic):: + @end menu + + @node Tracebacks From an Unhandled Exception + @subsubsection Tracebacks From an Unhandled Exception + + @noindent + A runtime non-symbolic traceback is a list of addresses of call instructions. + To enable this feature you must use the @code{-E} + @code{gnatbind}'s option. With this option a stack traceback is stored as part + of exception information. It is possible to retrieve this information using the + standard @code{Ada.Exception.Exception_Information} routine. + + @noindent + Let's have a look at a simple example: + + @smallexample + @cartouche + @group + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ gnatmake stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + @end smallexample + + @noindent + As we see the traceback lists a sequence of addresses for the unhandled + exception @code{CONSTAINT_ERROR} raised in procedure P1. It is easy to + guess that this exception come from procedure P1. To translate these + addresses into the source lines where the calls appear, the + @code{addr2line} tool, described below, is invaluable. The use of this tool + requires the program to be compiled with debug information. + + @smallexample + $ gnatmake -g stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + $ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 + 0x4011f1 0x77e892a4 + + 00401373 at d:/stb/stb.adb:5 + 0040138B at d:/stb/stb.adb:10 + 0040139C at d:/stb/stb.adb:14 + 00401335 at d:/stb/b~stb.adb:104 + 004011C4 at /build/.../crt1.c:200 + 004011F1 at /build/.../crt1.c:222 + 77E892A4 in ?? at ??:0 + @end smallexample + + @noindent + @code{addr2line} has a number of other useful options: + + @table @code + @item --functions + to get the function name corresponding to any location + + @item --demangle=gnat + to use the @b{gnat} decoding mode for the function names. Note that + for binutils version 2.9.x the option is simply @code{--demangle}. + @end table + + @smallexample + $ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b + 0x40139c 0x401335 0x4011c4 0x4011f1 + + 00401373 in stb.p1 at d:/stb/stb.adb:5 + 0040138B in stb.p2 at d:/stb/stb.adb:10 + 0040139C in stb at d:/stb/stb.adb:14 + 00401335 in main at d:/stb/b~stb.adb:104 + 004011C4 in <__mingw_CRTStartup> at /build/.../crt1.c:200 + 004011F1 in at /build/.../crt1.c:222 + @end smallexample + + @noindent + From this traceback we can see that the exception was raised in + @file{stb.adb} at line 5, which was reached from a procedure call in + @file{stb.adb} at line 10, and so on. The @file{b~std.adb} is the binder file, + which contains the call to the main program. + @pxref{Running gnatbind}. The remaining entries are assorted runtime routines, + and the output will vary from platform to platform. + + @noindent + It is also possible to use @code{GDB} with these traceback addresses to debug + the program. For example, we can break at a given code location, as reported + in the stack traceback: + + @smallexample + $ gdb -nw stb + + (gdb) break *0x401373 + Breakpoint 1 at 0x401373: file stb.adb, line 5. + @end smallexample + + @noindent + It is important to note that the stack traceback addresses + do not change when debug information is included. This is particularly useful + because it makes it possible to release software without debug information (to + minimize object size), get a field report that includes a stack traceback + whenever an internal bug occurs, and then be able to retrieve the sequence + of calls with the same program compiled with debug information. + + @node Tracebacks From Exception Occurrences (non-symbolic) + @subsubsection Tracebacks From Exception Occurrences + + @noindent + Non-symbolic tracebacks are obtained by using the @code{-E} binder argument. + The stack traceback is attached to the exception information string, and can + be retrieved in an exception handler within the Ada program, by means of the + Ada95 facilities defined in @code{Ada.Exceptions}. Here is a simple example: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with Ada.Exceptions; + + procedure STB is + + use Ada; + use Ada.Exceptions; + + procedure P1 is + K : Positive := 1; + begin + K := K - 1; + exception + when E : others => + Text_IO.Put_Line (Exception_Information (E)); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @noindent + This program will output: + + @smallexample + $ stb + + Exception name: CONSTRAINT_ERROR + Message: stb.adb:12 + Call stack traceback locations: + 0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4 + @end smallexample + + @node Tracebacks From Anywhere in a Program (non-symbolic) + @subsubsection Tracebacks From Anywhere in a Program + + @noindent + It is also possible to retrieve a stack traceback from anywhere in a + program. For this you need to + use the @code{GNAT.Traceback} API. This package includes a procedure called + @code{Call_Chain} that computes a complete stack traceback, as well as useful + display procedures described below. It is not necessary to use the + @code{-E gnatbind} option in this case, because the stack traceback mechanism + is invoked explicitly. + + @noindent + In the following example we compute a traceback at a specific location in + the program, and we display it using @code{GNAT.Debug_Utilities.Image} to + convert addresses to strings: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Debug_Utilities; + + procedure STB is + + use Ada; + use GNAT; + use GNAT.Traceback; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + + Text_IO.Put ("In STB.P1 : "); + + for K in 1 .. Len loop + Text_IO.Put (Debug_Utilities.Image (TB (K))); + Text_IO.Put (' '); + end loop; + + Text_IO.New_Line; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ gnatmake stb + $ stb + + In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C# + 16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4# + @end smallexample + + @node Symbolic Traceback + @subsection Symbolic Traceback + @cindex traceback, symbolic + + @noindent + A symbolic traceback is a stack traceback in which procedure names are + associated with each code location. + + @noindent + Note that this feature is not supported on all platforms. See + @file{GNAT.Traceback.Symbolic spec in g-trasym.ads} for a complete + list of currently supported platforms. + + @noindent + Note that the symbolic traceback requires that the program be compiled + with debug information. If it is not compiled with debug information + only the non-symbolic information will be valid. + + @menu + * Tracebacks From Exception Occurrences (symbolic):: + * Tracebacks From Anywhere in a Program (symbolic):: + @end menu + + @node Tracebacks From Exception Occurrences (symbolic) + @subsubsection Tracebacks From Exception Occurrences + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback.Symbolic; + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + procedure P3 is + begin + P2; + end P3; + + begin + P3; + exception + when E : others => + Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ gnatmake -g stb -bargs -E -largs -lgnat -laddr2line -lintl + $ stb + + 0040149F in stb.p1 at stb.adb:8 + 004014B7 in stb.p2 at stb.adb:13 + 004014CF in stb.p3 at stb.adb:18 + 004015DD in ada.stb at stb.adb:22 + 00401461 in main at b~stb.adb:168 + 004011C4 in __mingw_CRTStartup at crt1.c:200 + 004011F1 in mainCRTStartup at crt1.c:222 + 77E892A4 in ?? at ??:0 + @end smallexample + + @noindent + The exact sequence of linker options may vary from platform to platform. + The above @code{-largs} section is for Windows platforms. By contrast, + under Unix there is no need for the @code{-largs} section. + Differences across platforms are due to details of linker implementation. + + @node Tracebacks From Anywhere in a Program (symbolic) + @subsubsection Tracebacks From Anywhere in a Program + + @noindent + It is possible to get a symbolic stack traceback + from anywhere in a program, just as for non-symbolic tracebacks. + The first step is to obtain a non-symbolic + traceback, and then call @code{Symbolic_Traceback} to compute the symbolic + information. Here is an example: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Traceback.Symbolic; + + procedure STB is + + use Ada; + use GNAT.Traceback; + use GNAT.Traceback.Symbolic; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len))); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + + @node Inline Assembler + @chapter Inline Assembler + + @noindent + If you need to write low-level software that interacts directly with the hardware, Ada provides two ways to incorporate assembly language code into your program. First, you can import and invoke external routines written in assembly language, an Ada feature fully supported by GNAT. However, for small sections of code it may be simpler or more efficient to include assembly language statements directly in your Ada source program, using the facilities of the implementation-defined package @code{System.Machine_Code}, which incorporates the gcc Inline Assembler. The Inline Assembler approach offers a number of advantages, including the following: + + @itemize @bullet + @item No need to use non-Ada tools + @item Consistent interface over different targets + @item Automatic usage of the proper calling conventions + @item Access to Ada constants and variables + @item Definition of intrinsic routines + @item Possibility of inlining a subprogram comprising assembler code + @item Code optimizer can take Inline Assembler code into account + @end itemize + + This chapter presents a series of examples to show you how to use the Inline Assembler. Although it focuses on the Intel x86, the general approach applies also to other processors. It is assumed that you are familiar with Ada and with assembly language programming. + + @menu + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + @end menu + + @c --------------------------------------------------------------------------- + @node Basic Assembler Syntax + @section Basic Assembler Syntax + + @noindent + The assembler used by GNAT and gcc is based not on the Intel assembly language, but rather on a + language that descends from the AT&T Unix assembler @emph{as} (and which is often + referred to as ``AT&T syntax''). + The following table summarizes the main features of @emph{as} syntax and points out the differences from the Intel conventions. + See the gcc @emph{as} and @emph{gas} (an @emph{as} macro + pre-processor) documentation for further information. + + @table @asis + @item Register names + gcc / @emph{as}: Prefix with ``%''; for example @code{%eax} + @* + Intel: No extra punctuation; for example @code{eax} + + @item Immediate operand + gcc / @emph{as}: Prefix with ``$''; for example @code{$4} + @* + Intel: No extra punctuation; for example @code{4} + + @item Address + gcc / @emph{as}: Prefix with ``$''; for example @code{$loc} + @* + Intel: No extra punctuation; for example @code{loc} + + @item Memory contents + gcc / @emph{as}: No extra punctuation; for example @code{loc} + @* + Intel: Square brackets; for example @code{[loc]} + + @item Register contents + gcc / @emph{as}: Parentheses; for example @code{(%eax)} + @* + Intel: Square brackets; for example @code{[eax]} + + @item Hexadecimal numbers + gcc / @emph{as}: Leading ``0x'' (C language syntax); for example @code{0xA0} + @* + Intel: Trailing ``h''; for example @code{A0h} + + @item Operand size + gcc / @emph{as}: Explicit in op code; for example @code{movw} to move a 16-bit word + @* + Intel: Implicit, deduced by assembler; for example @code{mov} + + @item Instruction repetition + gcc / @emph{as}: Split into two lines; for example + @* + @code{rep} + @* + @code{stosl} + @* + Intel: Keep on one line; for example @code{rep stosl} + + @item Order of operands + gcc / @emph{as}: Source first; for example @code{movw $4, %eax} + @* + Intel: Destination first; for example @code{mov eax, 4} + @end table + + @c --------------------------------------------------------------------------- + @node A Simple Example of Inline Assembler + @section A Simple Example of Inline Assembler + + @noindent + The following example will generate a single assembly language statement, @code{nop}, which does nothing. Despite its lack of run-time effect, the example will be useful in illustrating the basics of the Inline Assembler facility. + + @smallexample + @group + with System.Machine_Code; use System.Machine_Code; + procedure Nothing is + begin + Asm ("nop"); + end Nothing; + @end group + @end smallexample + + @code{Asm} is a procedure declared in package @code{System.Machine_Code}; here it takes one parameter, a @emph{template string} that must be a static expression and that will form the generated instruction. + @code{Asm} may be regarded as a compile-time procedure that parses the template string and additional parameters (none here), from which it generates a sequence of assembly language instructions. + + The examples in this chapter will illustrate several of the forms for invoking @code{Asm}; a complete specification of the syntax is found in the @cite{GNAT Reference Manual}. + + Under the standard GNAT conventions, the @code{Nothing} procedure should be in a file named @file{nothing.adb}. You can build the executable in the usual way: + @smallexample + gnatmake nothing + @end smallexample + However, the interesting aspect of this example is not its run-time behavior but rather the + generated assembly code. To see this output, invoke the compiler as follows: + @smallexample + gcc -c -S -fomit-frame-pointer -gnatp @file{nothing.adb} + @end smallexample + where the options are: + + @table @code + @item -c + compile only (no bind or link) + @item -S + generate assembler listing + @item -fomit-frame-pointer + do not set up separate stack frames + @item -gnatp + do not add runtime checks + @end table + + This gives a human-readable assembler version of the code. The resulting + file will have the same name as the Ada source file, but with a @code{.s} extension. + In our example, the file @file{nothing.s} has the following contents: + + @smallexample + @group + .file "nothing.adb" + gcc2_compiled.: + ___gnu_compiled_ada: + .text + .align 4 + .globl __ada_nothing + __ada_nothing: + #APP + nop + #NO_APP + jmp L1 + .align 2,0x90 + L1: + ret + @end group + @end smallexample + + The assembly code you included is clearly indicated by + the compiler, between the @code{#APP} and @code{#NO_APP} + delimiters. The character before the 'APP' and 'NOAPP' + can differ on different targets. For example, Linux uses '#APP' while + on NT you will see '/APP'. + + If you make a mistake in your assembler code (such as using the + wrong size modifier, or using a wrong operand for the instruction) GNAT + will report this error in a temporary file, which will be deleted when + the compilation is finished. Generating an assembler file will help + in such cases, since you can assemble this file separately using the + @emph{as} assembler that comes with gcc. + + Assembling the file using the command + + @smallexample + as @file{nothing.s} + @end smallexample + @noindent + will give you error messages whose lines correspond to the assembler + input file, so you can easily find and correct any mistakes you made. + If there are no errors, @emph{as} will generate an object file @file{nothing.out}. + + @c --------------------------------------------------------------------------- + @node Output Variables in Inline Assembler + @section Output Variables in Inline Assembler + + @noindent + The examples in this section, showing how to access the processor flags, illustrate how to specify the destination operands for assembly language statements. + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags; + @end group + @end smallexample + + In order to have a nicely aligned assembly listing, we have separated + multiple assembler statements in the Asm template string with linefeed (ASCII.LF) + and horizontal tab (ASCII.HT) characters. The resulting section of the + assembly output file is: + + @smallexample + @group + #APP + pushfl + popl %eax + movl %eax, -40(%ebp) + #NO_APP + @end group + @end smallexample + + It would have been legal to write the Asm invocation as: + + @smallexample + Asm ("pushfl popl %%eax movl %%eax, %0") + @end smallexample + + but in the generated assembler file, this would come out as: + + @smallexample + #APP + pushfl popl %eax movl %eax, -40(%ebp) + #NO_APP + @end smallexample + + which is not so convenient for the human reader. + + We use Ada comments + at the end of each line to explain what the assembler instructions + actually do. This is a useful convention. + + When writing Inline Assembler instructions, you need to precede each register and variable name with a percent sign. Since the assembler already requires a percent sign at the beginning of a register name, you need two consecutive percent signs for such names in the Asm template string, thus @code{%%eax}. In the generated assembly code, one of the percent signs will be stripped off. + + Names such as @code{%0}, @code{%1}, @code{%2}, etc., denote input or output variables: operands you later define using @code{Input} or @code{Output} parameters to @code{Asm}. + An output variable is illustrated in + the third statement in the Asm template string: + @smallexample + movl %%eax, %0 + @end smallexample + The intent is to store the contents of the eax register in a variable that can be accessed in Ada. Simply writing @code{movl %%eax, Flags} would not necessarily work, since the compiler might optimize by using a register to hold Flags, and the expansion of the @code{movl} instruction would not be aware of this optimization. The solution is not to store the result directly but rather to advise the compiler to choose the correct operand form; that is the purpose of the @code{%0} output variable. + + Information about the output variable is supplied in the @code{Outputs} parameter to @code{Asm}: + @smallexample + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + @end smallexample + + The output is defined by the @code{Asm_Output} attribute of the target type; the general format is + @smallexample + Type'Asm_Output (constraint_string, variable_name) + @end smallexample + + The constraint string directs the compiler how + to store/access the associated variable. In the example + @smallexample + Unsigned_32'Asm_Output ("=m", Flags); + @end smallexample + the @code{"m"} (memory) constraint tells the compiler that the variable + @code{Flags} should be stored in a memory variable, thus preventing + the optimizer from keeping it in a register. In contrast, + @smallexample + Unsigned_32'Asm_Output ("=r", Flags); + @end smallexample + uses the @code{"r"} (register) constraint, telling the compiler to + store the variable in a register. + + If the constraint is preceded by the equal character (@strong{=}), it tells the + compiler that the variable will be used to store data into it. + + In the @code{Get_Flags} example, we used the "g" (global) constraint, allowing the optimizer + to choose whatever it deems best. + + There are a fairly large number of constraints, but the ones that are most useful (for the Intel x86 processor) are the following: + + @table @code + @item = + output constraint + @item g + global (i.e. can be stored anywhere) + @item m + in memory + @item I + a constant + @item a + use eax + @item b + use ebx + @item c + use ecx + @item d + use edx + @item S + use esi + @item D + use edi + @item r + use one of eax, ebx, ecx or edx + @item q + use one of eax, ebx, ecx, edx, esi or edi + @end table + + The full set of constraints is described in the gcc and @emph{as} documentation; note that it is possible to combine certain constraints in one constraint string. + + You specify the association of an output variable with an assembler operand through the @code{%}@emph{n} notation, where @emph{n} is a non-negative integer. Thus in + @smallexample + @group + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + @end group + @end smallexample + @noindent + @code{%0} will be replaced in the expanded code by the appropriate operand, + whatever + the compiler decided for the @code{Flags} variable. + + In general, you may have any number of output variables: + @itemize @bullet + @item + Count the operands starting at 0; thus @code{%0}, @code{%1}, etc. + @item + Specify the @code{Outputs} parameter as a parenthesized comma-separated list of @code{Asm_Output} attributes + @end itemize + + For example: + @smallexample + @group + Asm ("movl %%eax, %0" & LF & HT & + "movl %%ebx, %1" & LF & HT & + "movl %%ecx, %2", + Outputs => (Unsigned_32'Asm_Output ("=g", Var_A), -- %0 = Var_A + Unsigned_32'Asm_Output ("=g", Var_B), -- %1 = Var_B + Unsigned_32'Asm_Output ("=g", Var_C))); -- %2 = Var_C + @end group + @end smallexample + @noindent + where @code{Var_A}, @code{Var_B}, and @code{Var_C} are variables in the Ada program. + + As a variation on the @code{Get_Flags} example, we can use the constraints string to direct the compiler to store the eax register into the @code{Flags} variable, instead of including the store instruction explicitly in the @code{Asm} template string: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_2 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax", -- save flags in eax + Outputs => Unsigned_32'Asm_Output ("=a", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_2; + @end group + @end smallexample + + @noindent + The @code{"a"} constraint tells the compiler that the @code{Flags} + variable will come from the eax register. Here is the resulting code: + + @smallexample + @group + #APP + pushfl + popl %eax + #NO_APP + movl %eax,-40(%ebp) + @end group + @end smallexample + + @noindent + The compiler generated the store of eax into Flags after + expanding the assembler code. + + Actually, there was no need to pop the flags into the eax register; more simply, we could just pop the flags directly into the program variable: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_3 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "pop %0", -- save flags in Flags + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_3; + @end group + @end smallexample + + @c --------------------------------------------------------------------------- + @node Input Variables in Inline Assembler + @section Input Variables in Inline Assembler + + @noindent + The example in this section illustrates how to specify the source operands for assembly language statements. The program simply increments its input value by 1: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Incr (Value); + Put_Line ("Value after is" & Value'Img); + end Increment; + @end group + @end smallexample + + The @code{Outputs} parameter to @code{Asm} specifies + that the result will be in the eax register and that it is to be stored in the @code{Result} + variable. + + The @code{Inputs} parameter looks much like the @code{Outputs} parameter, but with an + @code{Asm_Input} attribute. The + @code{"="} constraint, indicating an output value, is not present. + + You can have multiple input variables, in the same way that you can have more + than one output variable. + + The parameter count (%0, %1) etc, now starts at the first input + statement, and continues with the output statements. + When both parameters use the same variable, the + compiler will treat them as the same %n operand, which is the case here. + + Just as the @code{Outputs} parameter causes the register to be stored into the + target variable after execution of the assembler statements, so does the + @code{Inputs} parameter cause its variable to be loaded into the register before execution + of the + assembler statements. + + Thus the effect of the @code{Asm} invocation is: + @enumerate + @item load the 32-bit value of @code{Value} into eax + @item execute the @code{incl %eax} instruction + @item store the contents of eax into the @code{Result} variable + @end enumerate + + The resulting assembler file (with @code{-O2} optimization) contains: + @smallexample + @group + _increment__incr.1: + subl $4,%esp + movl 8(%esp),%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + movl %ecx,(%esp) + addl $4,%esp + ret + @end group + @end smallexample + + @c --------------------------------------------------------------------------- + @node Inlining Inline Assembler Code + @section Inlining Inline Assembler Code + + @noindent + For a short subprogram such as the @code{Incr} function in the previous section, the overhead of the call and return (creating / deleting the stack frame) + can be significant, compared to the amount of code in the subprogram body. + A solution is to apply Ada's @code{Inline} pragma to the subprogram, + which directs the compiler to expand invocations of the subprogram at the point(s) + of call, instead of setting up a stack frame for out-of-line calls. + Here is the resulting program: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment_2 is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + pragma Inline (Increment); + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Increment (Value); + Put_Line ("Value after is" & Value'Img); + end Increment_2; + @end group + @end smallexample + + Compile the program with both optimization (@code{-O2}) and inlining + enabled (@option{-gnatpn} instead of @option{-gnatp}). + + The @code{Incr} function is still compiled as usual, but at the + point in @code{Increment} where our function used to be called: + + @smallexample + @group + pushl %edi + call _increment__incr.1 + @end group + @end smallexample + + @noindent + the code for the function body directly appears: + + @smallexample + @group + movl %esi,%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + @end group + @end smallexample + + @noindent + thus saving the overhead of stack frame setup and an out-of-line call. + + @c --------------------------------------------------------------------------- + @node Other Asm Functionality + @section Other @code{Asm} Functionality + + @noindent + This section describes two important parameters to the @code{Asm} procedure: @code{Clobber}, which identifies register usage; and @code{Volatile}, which inhibits unwanted optimizations. + + @menu + * The Clobber Parameter:: + * The Volatile Parameter:: + @end menu + + @c --------------------------------------------------------------------------- + @node The Clobber Parameter + @subsection The @code{Clobber} Parameter + + @noindent + One of the dangers of intermixing assembly language and a compiled language such as Ada is + that the compiler needs to be aware of which registers are being used by the assembly code. + In some cases, such as the earlier examples, the constraint string is sufficient to + indicate register usage (e.g. "a" for the eax register). But more generally, the + compiler needs an explicit identification of the registers that are used by the Inline + Assembly statements. + + Using a register that the compiler doesn't know about + could be a side effect of an instruction (like @code{mull} + storing its result in both eax and edx). + It can also arise from explicit register usage in your + assembly code; for example: + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out)); + @end group + @end smallexample + @noindent + where the compiler (since it does not analyze the @code{Asm} template string) + does not know you are using the ebx register. + + In such cases you need to supply the @code{Clobber} parameter to @code{Asm}, + to identify the registers that will be used by your assembly code: + + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx"); + @end group + @end smallexample + + The Clobber parameter is a static string expression specifying the + register(s) you are using. Note that register names are @emph{not} prefixed by a percent sign. + Also, if more than one register is used then their names are separated by commas; e.g., @code{"eax, ebx"} + + The @code{Clobber} parameter has several additional uses: + @enumerate + @item Use the "register" name @code{cc} to indicate that flags might have changed + @item Use the "register" name @code{memory} if you changed a memory location + @end enumerate + + @c --------------------------------------------------------------------------- + @node The Volatile Parameter + @subsection The @code{Volatile} Parameter + @cindex Volatile parameter + + @noindent + Compiler optimizations in the presence of Inline Assembler may sometimes have unwanted effects. + For example, when + an @code{Asm} invocation with an input variable is inside a loop, the compiler might move + the loading of the input variable outside the loop, regarding it as a + one-time initialization. + + If this effect is not desired, you can disable such optimizations by setting the + @code{Volatile} parameter to @code{True}; for example: + + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx", + Volatile => True); + @end group + @end smallexample + + By default, @code{Volatile} is set to @code{False} unless there is no @code{Outputs} + parameter. + + Although setting @code{Volatile} to @code{True} prevents unwanted optimizations, + it will also disable other optimizations that might be important for efficiency. + In general, you should set @code{Volatile} to @code{True} only if the compiler's + optimizations have created problems. + + @c --------------------------------------------------------------------------- + @node A Complete Example + @section A Complete Example + + @noindent + This section contains a complete program illustrating a realistic usage of GNAT's Inline Assembler + capabilities. It comprises a main procedure @code{Check_CPU} and a package @code{Intel_CPU}. + The package declares a collection of functions that detect the properties of the 32-bit + x86 processor that is running the program. The main procedure invokes these functions + and displays the information. + + The Intel_CPU package could be enhanced by adding functions to + detect the type of x386 co-processor, the processor caching options and + special operations such as the SIMD extensions. + + Although the Intel_CPU package has been written for 32-bit Intel + compatible CPUs, it is OS neutral. It has been tested on DOS, + Windows/NT and Linux. + + @menu + * Check_CPU Procedure:: + * Intel_CPU Package Specification:: + * Intel_CPU Package Body:: + @end menu + + @c --------------------------------------------------------------------------- + @node Check_CPU Procedure + @subsection @code{Check_CPU} Procedure + @cindex Check_CPU procedure + + @smallexample + --------------------------------------------------------------------- + -- -- + -- Uses the Intel_CPU package to identify the CPU the program is -- + -- running on, and some of the features it supports. -- + -- -- + --------------------------------------------------------------------- + + with Intel_CPU; -- Intel CPU detection functions + with Ada.Text_IO; -- Standard text I/O + with Ada.Command_Line; -- To set the exit status + + procedure Check_CPU is + + Type_Found : Boolean := False; + -- Flag to indicate that processor was identified + + Features : Intel_CPU.Processor_Features; + -- The processor features + + Signature : Intel_CPU.Processor_Signature; + -- The processor type signature + + begin + + ----------------------------------- + -- Display the program banner. -- + ----------------------------------- + + Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name & + ": check Intel CPU version and features, v1.0"); + Ada.Text_IO.Put_Line ("distribute freely, but no warranty whatsoever"); + Ada.Text_IO.New_Line; + + ----------------------------------------------------------------------- + -- We can safely start with the assumption that we are on at least -- + -- a x386 processor. If the CPUID instruction is present, then we -- + -- have a later processor type. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Has_CPUID = False then + + -- No CPUID instruction, so we assume this is indeed a x386 + -- processor. We can still check if it has a FP co-processor. + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line + ("x386-type processor with a FP co-processor"); + else + Ada.Text_IO.Put_Line + ("x386-type processor without a FP co-processor"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check for CPUID + + ----------------------------------------------------------------------- + -- If CPUID is supported, check if this is a true Intel processor, -- + -- if it is not, display a warning. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Vendor_ID /= Intel_CPU.Intel_Processor then + Ada.Text_IO.Put_Line ("*** This is a Intel compatible processor"); + Ada.Text_IO.Put_Line ("*** Some information may be incorrect"); + end if; -- check if Intel + + ---------------------------------------------------------------------- + -- With the CPUID instruction present, we can assume at least a -- + -- x486 processor. If the CPUID support level is < 1 then we have -- + -- to leave it at that. -- + ---------------------------------------------------------------------- + + if Intel_CPU.CPUID_Level < 1 then + + -- Ok, this is a x486 processor. we still can get the Vendor ID + Ada.Text_IO.Put_Line ("x486-type processor"); + Ada.Text_IO.Put_Line ("Vendor ID is " & Intel_CPU.Vendor_ID); + + -- We can also check if there is a FPU present + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line ("Floating-Point support"); + else + Ada.Text_IO.Put_Line ("No Floating-Point support"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check CPUID level + + --------------------------------------------------------------------- + -- With a CPUID level of 1 we can use the processor signature to -- + -- determine it's exact type. -- + --------------------------------------------------------------------- + + Signature := Intel_CPU.Signature; + + ---------------------------------------------------------------------- + -- Ok, now we go into a lot of messy comparisons to get the -- + -- processor type. For clarity, no attememt to try to optimize the -- + -- comparisons has been made. Note that since Intel_CPU does not -- + -- support getting cache info, we cannot distinguish between P5 -- + -- and Celeron types yet. -- + ---------------------------------------------------------------------- + + -- x486SL + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486SL processor"); + end if; + + -- x486DX2 Write-Back + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0111# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Write-Back Enhanced x486DX2 processor"); + end if; + + -- x486DX4 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 processor"); + end if; + + -- x486DX4 Overdrive + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 OverDrive processor"); + end if; + + -- Pentium (60, 66) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium processor (60, 66)"); + end if; + + -- Pentium (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive (60, 66) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium OverDrive processor (60, 66)"); + end if; + + -- Pentium OverDrive (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive cpu (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive processor for x486 processor-based systems + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor for x486 processor-based systems"); + end if; + + -- Pentium processor with MMX technology (166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor with MMX technology (166, 200)"); + end if; + + -- Pentium OverDrive with MMX for Pentium (75, 90, 100, 120, 133) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor with MMX " & + "technology for Pentium processor (75, 90, 100, 120, 133)"); + end if; + + -- Pentium Pro processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro processor"); + end if; + + -- Pentium II processor, model 3 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium II processor, model 3"); + end if; + + -- Pentium II processor, model 5 or Celeron processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0101# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium II processor, model 5 or Celeron processor"); + end if; + + -- Pentium Pro OverDrive processor + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro OverDrive processor"); + end if; + + -- If no type recognized, we have an unknown. Display what + -- we _do_ know + if Type_Found = False then + Ada.Text_IO.Put_Line ("Unknown processor"); + end if; + + ----------------------------------------- + -- Display processor stepping level. -- + ----------------------------------------- + + Ada.Text_IO.Put_Line ("Stepping level:" & Signature.Stepping'Img); + + --------------------------------- + -- Display vendor ID string. -- + --------------------------------- + + Ada.Text_IO.Put_Line ("Vendor ID: " & Intel_CPU.Vendor_ID); + + ------------------------------------ + -- Get the processors features. -- + ------------------------------------ + + Features := Intel_CPU.Features; + + ----------------------------- + -- Check for a FPU unit. -- + ----------------------------- + + if Features.FPU = True then + Ada.Text_IO.Put_Line ("Floating-Point unit available"); + else + Ada.Text_IO.Put_Line ("no Floating-Point unit"); + end if; -- check for FPU + + -------------------------------- + -- List processor features. -- + -------------------------------- + + Ada.Text_IO.Put_Line ("Supported features: "); + + -- Virtual Mode Extension + if Features.VME = True then + Ada.Text_IO.Put_Line (" VME - Virtual Mode Extension"); + end if; + + -- Debugging Extension + if Features.DE = True then + Ada.Text_IO.Put_Line (" DE - Debugging Extension"); + end if; + + -- Page Size Extension + if Features.PSE = True then + Ada.Text_IO.Put_Line (" PSE - Page Size Extension"); + end if; + + -- Time Stamp Counter + if Features.TSC = True then + Ada.Text_IO.Put_Line (" TSC - Time Stamp Counter"); + end if; + + -- Model Specific Registers + if Features.MSR = True then + Ada.Text_IO.Put_Line (" MSR - Model Specific Registers"); + end if; + + -- Physical Address Extension + if Features.PAE = True then + Ada.Text_IO.Put_Line (" PAE - Physical Address Extension"); + end if; + + -- Machine Check Extension + if Features.MCE = True then + Ada.Text_IO.Put_Line (" MCE - Machine Check Extension"); + end if; + + -- CMPXCHG8 instruction supported + if Features.CX8 = True then + Ada.Text_IO.Put_Line (" CX8 - CMPXCHG8 instruction"); + end if; + + -- on-chip APIC hardware support + if Features.APIC = True then + Ada.Text_IO.Put_Line (" APIC - on-chip APIC hardware support"); + end if; + + -- Fast System Call + if Features.SEP = True then + Ada.Text_IO.Put_Line (" SEP - Fast System Call"); + end if; + + -- Memory Type Range Registers + if Features.MTRR = True then + Ada.Text_IO.Put_Line (" MTTR - Memory Type Range Registers"); + end if; + + -- Page Global Enable + if Features.PGE = True then + Ada.Text_IO.Put_Line (" PGE - Page Global Enable"); + end if; + + -- Machine Check Architecture + if Features.MCA = True then + Ada.Text_IO.Put_Line (" MCA - Machine Check Architecture"); + end if; + + -- Conditional Move Instruction Supported + if Features.CMOV = True then + Ada.Text_IO.Put_Line + (" CMOV - Conditional Move Instruction Supported"); + end if; + + -- Page Attribute Table + if Features.PAT = True then + Ada.Text_IO.Put_Line (" PAT - Page Attribute Table"); + end if; + + -- 36-bit Page Size Extension + if Features.PSE_36 = True then + Ada.Text_IO.Put_Line (" PSE_36 - 36-bit Page Size Extension"); + end if; + + -- MMX technology supported + if Features.MMX = True then + Ada.Text_IO.Put_Line (" MMX - MMX technology supported"); + end if; + + -- Fast FP Save and Restore + if Features.FXSR = True then + Ada.Text_IO.Put_Line (" FXSR - Fast FP Save and Restore"); + end if; + + --------------------- + -- Program done. -- + --------------------- + + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + + exception + + when others => + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); + raise; + + end Check_CPU; + @end smallexample + + @c --------------------------------------------------------------------------- + @node Intel_CPU Package Specification + @subsection @code{Intel_CPU} Package Specification + @cindex Intel_CPU package specification + + @smallexample + ------------------------------------------------------------------------- + -- -- + -- file: intel_cpu.ads -- + -- -- + -- ********************************************* -- + -- * WARNING: for 32-bit Intel processors only * -- + -- ********************************************* -- + -- -- + -- This package contains a number of subprograms that are useful in -- + -- determining the Intel x86 CPU (and the features it supports) on -- + -- which the program is running. -- + -- -- + -- The package is based upon the information given in the Intel -- + -- Application Note AP-485: "Intel Processor Identification and the -- + -- CPUID Instruction" as of April 1998. This application note can be -- + -- found on www.intel.com. -- + -- -- + -- It currently deals with 32-bit processors only, will not detect -- + -- features added after april 1998, and does not guarantee proper -- + -- results on Intel-compatible processors. -- + -- -- + -- Cache info and x386 fpu type detection are not supported. -- + -- -- + -- This package does not use any privileged instructions, so should -- + -- work on any OS running on a 32-bit Intel processor. -- + -- -- + ------------------------------------------------------------------------- + + with Interfaces; use Interfaces; + -- for using unsigned types + + with System.Machine_Code; use System.Machine_Code; + -- for using inline assembler code + + with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; + -- for inserting control characters + + package Intel_CPU is + + ---------------------- + -- Processor bits -- + ---------------------- + + subtype Num_Bits is Natural range 0 .. 31; + -- the number of processor bits (32) + + -------------------------- + -- Processor register -- + -------------------------- + + -- define a processor register type for easy access to + -- the individual bits + + type Processor_Register is array (Num_Bits) of Boolean; + pragma Pack (Processor_Register); + for Processor_Register'Size use 32; + + ------------------------- + -- Unsigned register -- + ------------------------- + + -- define a processor register type for easy access to + -- the individual bytes + + type Unsigned_Register is + record + L1 : Unsigned_8; + H1 : Unsigned_8; + L2 : Unsigned_8; + H2 : Unsigned_8; + end record; + + for Unsigned_Register use + record + L1 at 0 range 0 .. 7; + H1 at 0 range 8 .. 15; + L2 at 0 range 16 .. 23; + H2 at 0 range 24 .. 31; + end record; + + for Unsigned_Register'Size use 32; + + --------------------------------- + -- Intel processor vendor ID -- + --------------------------------- + + Intel_Processor : constant String (1 .. 12) := "GenuineIntel"; + -- indicates an Intel manufactured processor + + ------------------------------------ + -- Processor signature register -- + ------------------------------------ + + -- a register type to hold the processor signature + + type Processor_Signature is + record + Stepping : Natural range 0 .. 15; + Model : Natural range 0 .. 15; + Family : Natural range 0 .. 15; + Processor_Type : Natural range 0 .. 3; + Reserved : Natural range 0 .. 262143; + end record; + + for Processor_Signature use + record + Stepping at 0 range 0 .. 3; + Model at 0 range 4 .. 7; + Family at 0 range 8 .. 11; + Processor_Type at 0 range 12 .. 13; + Reserved at 0 range 14 .. 31; + end record; + + for Processor_Signature'Size use 32; + + ----------------------------------- + -- Processor features register -- + ----------------------------------- + + -- a processor register to hold the processor feature flags + + type Processor_Features is + record + FPU : Boolean; -- floating point unit on chip + VME : Boolean; -- virtual mode extension + DE : Boolean; -- debugging extension + PSE : Boolean; -- page size extension + TSC : Boolean; -- time stamp counter + MSR : Boolean; -- model specific registers + PAE : Boolean; -- physical address extension + MCE : Boolean; -- machine check extension + CX8 : Boolean; -- cmpxchg8 instruction + APIC : Boolean; -- on-chip apic hardware + Res_1 : Boolean; -- reserved for extensions + SEP : Boolean; -- fast system call + MTRR : Boolean; -- memory type range registers + PGE : Boolean; -- page global enable + MCA : Boolean; -- machine check architecture + CMOV : Boolean; -- conditional move supported + PAT : Boolean; -- page attribute table + PSE_36 : Boolean; -- 36-bit page size extension + Res_2 : Natural range 0 .. 31; -- reserved for extensions + MMX : Boolean; -- MMX technology supported + FXSR : Boolean; -- fast FP save and restore + Res_3 : Natural range 0 .. 127; -- reserved for extensions + end record; + + for Processor_Features use + record + FPU at 0 range 0 .. 0; + VME at 0 range 1 .. 1; + DE at 0 range 2 .. 2; + PSE at 0 range 3 .. 3; + TSC at 0 range 4 .. 4; + MSR at 0 range 5 .. 5; + PAE at 0 range 6 .. 6; + MCE at 0 range 7 .. 7; + CX8 at 0 range 8 .. 8; + APIC at 0 range 9 .. 9; + Res_1 at 0 range 10 .. 10; + SEP at 0 range 11 .. 11; + MTRR at 0 range 12 .. 12; + PGE at 0 range 13 .. 13; + MCA at 0 range 14 .. 14; + CMOV at 0 range 15 .. 15; + PAT at 0 range 16 .. 16; + PSE_36 at 0 range 17 .. 17; + Res_2 at 0 range 18 .. 22; + MMX at 0 range 23 .. 23; + FXSR at 0 range 24 .. 24; + Res_3 at 0 range 25 .. 31; + end record; + + for Processor_Features'Size use 32; + + ------------------- + -- Subprograms -- + ------------------- + + function Has_FPU return Boolean; + -- return True if a FPU is found + -- use only if CPUID is not supported + + function Has_CPUID return Boolean; + -- return True if the processor supports the CPUID instruction + + function CPUID_Level return Natural; + -- return the CPUID support level (0, 1 or 2) + -- can only be called if the CPUID instruction is supported + + function Vendor_ID return String; + -- return the processor vendor identification string + -- can only be called if the CPUID instruction is supported + + function Signature return Processor_Signature; + -- return the processor signature + -- can only be called if the CPUID instruction is supported + + function Features return Processor_Features; + -- return the processors features + -- can only be called if the CPUID instruction is supported + + private + + ------------------------ + -- EFLAGS bit names -- + ------------------------ + + ID_Flag : constant Num_Bits := 21; + -- ID flag bit + + end Intel_CPU; + @end smallexample + + @c --------------------------------------------------------------------------- + @node Intel_CPU Package Body + @subsection @code{Intel_CPU} Package Body + @cindex Intel_CPU package body + + @smallexample + package body Intel_CPU is + + --------------------------- + -- Detect FPU presence -- + --------------------------- + + -- There is a FPU present if we can set values to the FPU Status + -- and Control Words. + + function Has_FPU return Boolean is + + Register : Unsigned_16; + -- processor register to store a word + + begin + + -- check if we can change the status word + Asm ( + + -- the assembler code + "finit" & LF & HT & -- reset status word + "movw $0x5A5A, %%ax" & LF & HT & -- set value status word + "fnstsw %0" & LF & HT & -- save status word + "movw %%ax, %0", -- store status word + + -- output stored in Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register), + + -- tell compiler that we used eax + Clobber => "eax"); + + -- if the status word is zero, there is no FPU + if Register = 0 then + return False; -- no status word + end if; -- check status word value + + -- check if we can get the control word + Asm ( + + -- the assembler code + "fnstcw %0", -- save the control word + + -- output into Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register)); + + -- check the relevant bits + if (Register and 16#103F#) /= 16#003F# then + return False; -- no control word + end if; -- check control word value + + -- FPU found + return True; + + end Has_FPU; + + -------------------------------- + -- Detect CPUID instruction -- + -------------------------------- + + -- The processor supports the CPUID instruction if it is possible + -- to change the value of ID flag bit in the EFLAGS register. + + function Has_CPUID return Boolean is + + Original_Flags, Modified_Flags : Processor_Register; + -- EFLAG contents before and after changing the ID flag + + begin + + -- try flipping the ID flag in the EFLAGS register + Asm ( + + -- the assembler code + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %%eax" & LF & HT & -- pop EFLAGS into eax + "movl %%eax, %0" & LF & HT & -- save EFLAGS content + "xor $0x200000, %%eax" & LF & HT & -- flip ID flag + "push %%eax" & LF & HT & -- push EFLAGS on stack + "popfl" & LF & HT & -- load EFLAGS register + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %1", -- save EFLAGS content + + -- output values, may be anything + -- Original_Flags is %0 + -- Modified_Flags is %1 + Outputs => + (Processor_Register'Asm_output ("=g", Original_Flags), + Processor_Register'Asm_output ("=g", Modified_Flags)), + + -- tell compiler eax is destroyed + Clobber => "eax"); + + -- check if CPUID is supported + if Original_Flags(ID_Flag) /= Modified_Flags(ID_Flag) then + return True; -- ID flag was modified + else + return False; -- ID flag unchanged + end if; -- check for CPUID + + end Has_CPUID; + + ------------------------------- + -- Get CPUID support level -- + ------------------------------- + + function CPUID_Level return Natural is + + Level : Unsigned_32; + -- returned support level + + begin + + -- execute CPUID, storing the results in the Level register + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero is stored in eax + -- returning the support level in eax + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- eax is stored in Level + Outputs => Unsigned_32'Asm_output ("=a", Level), + + -- tell compiler ebx, ecx and edx registers are destroyed + Clobber => "ebx, ecx, edx"); + + -- return the support level + return Natural (Level); + + end CPUID_Level; + + -------------------------------- + -- Get CPU Vendor ID String -- + -------------------------------- + + -- The vendor ID string is returned in the ebx, ecx and edx register + -- after executing the CPUID instruction with eax set to zero. + -- In case of a true Intel processor the string returned is + -- "GenuineIntel" + + function Vendor_ID return String is + + Ebx, Ecx, Edx : Unsigned_Register; + -- registers containing the vendor ID string + + Vendor_ID : String (1 .. 12); + -- the vendor ID string + + begin + + -- execute CPUID, storing the results in the processor registers + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero stored in eax + -- vendor ID string returned in ebx, ecx and edx + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- ebx is stored in Ebx + -- ecx is stored in Ecx + -- edx is stored in Edx + Outputs => (Unsigned_Register'Asm_output ("=b", Ebx), + Unsigned_Register'Asm_output ("=c", Ecx), + Unsigned_Register'Asm_output ("=d", Edx))); + + -- now build the vendor ID string + Vendor_ID( 1) := Character'Val (Ebx.L1); + Vendor_ID( 2) := Character'Val (Ebx.H1); + Vendor_ID( 3) := Character'Val (Ebx.L2); + Vendor_ID( 4) := Character'Val (Ebx.H2); + Vendor_ID( 5) := Character'Val (Edx.L1); + Vendor_ID( 6) := Character'Val (Edx.H1); + Vendor_ID( 7) := Character'Val (Edx.L2); + Vendor_ID( 8) := Character'Val (Edx.H2); + Vendor_ID( 9) := Character'Val (Ecx.L1); + Vendor_ID(10) := Character'Val (Ecx.H1); + Vendor_ID(11) := Character'Val (Ecx.L2); + Vendor_ID(12) := Character'Val (Ecx.H2); + + -- return string + return Vendor_ID; + + end Vendor_ID; + + ------------------------------- + -- Get processor signature -- + ------------------------------- + + function Signature return Processor_Signature is + + Result : Processor_Signature; + -- processor signature returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one is stored in eax + -- processor signature returned in eax + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- eax is stored in Result + Outputs => Processor_Signature'Asm_output ("=a", Result), + + -- tell compiler that ebx, ecx and edx are also destroyed + Clobber => "ebx, ecx, edx"); + + -- return processor signature + return Result; + + end Signature; + + ------------------------------ + -- Get processor features -- + ------------------------------ + + function Features return Processor_Features is + + Result : Processor_Features; + -- processor features returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one stored in eax + -- processor features returned in edx + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- edx is stored in Result + Outputs => Processor_Features'Asm_output ("=d", Result), + + -- tell compiler that ebx and ecx are also destroyed + Clobber => "ebx, ecx"); + + -- return processor signature + return Result; + + end Features; + + end Intel_CPU; + @end smallexample + @c END OF INLINE ASSEMBLER CHAPTER + @c =============================== + + + + + @node Performance Considerations + @chapter Performance Considerations + @cindex Performance + + @noindent + The GNAT system provides a number of options that allow a trade-off + between + + @itemize @bullet + @item + performance of the generated code + + @item + speed of compilation + + @item + minimization of dependences and recompilation + + @item + the degree of run-time checking. + @end itemize + + @noindent + The defaults (if no options are selected) aim at improving the speed + of compilation and minimizing dependences, at the expense of performance + of the generated code: + + @itemize @bullet + @item + no optimization + + @item + no inlining of subprogram calls + + @item + all run-time checks enabled except overflow and elaboration checks + @end itemize + + @noindent + These options are suitable for most program development purposes. This + chapter describes how you can modify these choices, and also provides + some guidelines on debugging optimized code. + + @menu + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + @end menu + + @node Controlling Run-Time Checks + @section Controlling Run-Time Checks + + @noindent + By default, GNAT generates all run-time checks, except arithmetic overflow + checking for integer operations and checks for access before elaboration on + subprogram calls. The latter are not required in default mode, because all + necessary checking is done at compile time. + @cindex @option{-gnatp} (@code{gcc}) + @cindex @option{-gnato} (@code{gcc}) + Two gnat switches, @option{-gnatp} and @option{-gnato} allow this default to + be modified. @xref{Run-Time Checks}. + + Our experience is that the default is suitable for most development + purposes. + + We treat integer overflow specially because these + are quite expensive and in our experience are not as important as other + run-time checks in the development process. Note that division by zero + is not considered an overflow check, and divide by zero checks are + generated where required by default. + + Elaboration checks are off by default, and also not needed by default, since + GNAT uses a static elaboration analysis approach that avoids the need for + run-time checking. This manual contains a full chapter discussing the issue + of elaboration checks, and if the default is not satisfactory for your use, + you should read this chapter. + + For validity checks, the minimal checks required by the Ada Reference + Manual (for case statements and assignments to array elements) are on + by default. These can be suppressed by use of the @option{-gnatVn} switch. + Note that in Ada 83, there were no validity checks, so if the Ada 83 mode + is acceptable (or when comparing GNAT performance with an Ada 83 compiler), + it may be reasonable to routinely use @option{-gnatVn}. Validity checks + are also suppressed entirely if @option{-gnatp} is used. + + @cindex Overflow checks + @cindex Checks, overflow + @findex Suppress + @findex Unsuppress + @cindex pragma Suppress + @cindex pragma Unsuppress + Note that the setting of the switches controls the default setting of + the checks. They may be modified using either @code{pragma Suppress} (to + remove checks) or @code{pragma Unsuppress} (to add back suppressed + checks) in the program source. + + @node Optimization Levels + @section Optimization Levels + @cindex @code{-O} (@code{gcc}) + + @noindent + The default is optimization off. This results in the fastest compile + times, but GNAT makes absolutely no attempt to optimize, and the + generated programs are considerably larger and slower than when + optimization is enabled. You can use the + @code{-O@var{n}} switch, where @var{n} is an integer from 0 to 3, + on the @code{gcc} command line to control the optimization level: + + @table @code + @item -O0 + no optimization (the default) + + @item -O1 + medium level optimization + + @item -O2 + full optimization + + @item -O3 + full optimization, and also attempt automatic inlining of small + subprograms within a unit (@pxref{Inlining of Subprograms}). + @end table + + Higher optimization levels perform more global transformations on the + program and apply more expensive analysis algorithms in order to generate + faster and more compact code. The price in compilation time, and the + resulting improvement in execution time, + both depend on the particular application and the hardware environment. + You should experiment to find the best level for your application. + + Note: Unlike some other compilation systems, @code{gcc} has + been tested extensively at all optimization levels. There are some bugs + which appear only with optimization turned on, but there have also been + bugs which show up only in @emph{unoptimized} code. Selecting a lower + level of optimization does not improve the reliability of the code + generator, which in practice is highly reliable at all optimization + levels. + + Note regarding the use of @code{-O3}: The use of this optimization level + is generally discouraged with GNAT, since it often results in larger + executables which run more slowly. See further discussion of this point + in @pxref{Inlining of Subprograms}. + + @node Debugging Optimized Code + @section Debugging Optimized Code + + @noindent + Since the compiler generates debugging tables for a compilation unit before + it performs optimizations, the optimizing transformations may invalidate some + of the debugging data. You therefore need to anticipate certain + anomalous situations that may arise while debugging optimized code. This + section describes the most common cases. + + @enumerate + @item + @i{The "hopping Program Counter":} Repeated 'step' or 'next' commands show the PC + bouncing back and forth in the code. This may result from any of the following + optimizations: + + @itemize @bullet + @item + @i{Common subexpression elimination:} using a single instance of code for a + quantity that the source computes several times. As a result you + may not be able to stop on what looks like a statement. + + @item + @i{Invariant code motion:} moving an expression that does not change within a + loop, to the beginning of the loop. + + @item + @i{Instruction scheduling:} moving instructions so as to + overlap loads and stores (typically) with other code, or in + general to move computations of values closer to their uses. Often + this causes you to pass an assignment statement without the assignment + happening and then later bounce back to the statement when the + value is actually needed. Placing a breakpoint on a line of code + and then stepping over it may, therefore, not always cause all the + expected side-effects. + @end itemize + + @item + @i{The "big leap":} More commonly known as @i{cross-jumping}, in which two + identical pieces of code are merged and the program counter suddenly + jumps to a statement that is not supposed to be executed, simply because + it (and the code following) translates to the same thing as the code + that @emph{was} supposed to be executed. This effect is typically seen in + sequences that end in a jump, such as a @code{goto}, a @code{return}, or + a @code{break} in a C @code{switch} statement. + + @item + @i{The "roving variable":} The symptom is an unexpected value in a variable. + There are various reasons for this effect: + + @itemize @bullet + @item + In a subprogram prologue, a parameter may not yet have been moved to its + "home". + + @item + A variable may be dead, and its register re-used. This is + probably the most common cause. + + @item + As mentioned above, the assignment of a value to a variable may + have been moved. + + @item + A variable may be eliminated entirely by value propagation or + other means. In this case, GCC may incorrectly generate debugging + information for the variable + @end itemize + + @noindent + In general, when an unexpected value appears for a local variable or parameter + you should first ascertain if that value was actually computed by + your program, as opposed to being incorrectly reported by the debugger. + Record fields or + array elements in an object designated by an access value + are generally less of a problem, once you have ascertained that the access value + is sensible. + Typically, this means checking variables in the preceding code and in the + calling subprogram to verify that the value observed is explainable from other + values (one must apply the procedure recursively to those + other values); or re-running the code and stopping a little earlier + (perhaps before the call) and stepping to better see how the variable obtained + the value in question; or continuing to step @emph{from} the point of the + strange value to see if code motion had simply moved the variable's + assignments later. + @end enumerate + + @node Inlining of Subprograms + @section Inlining of Subprograms + + @noindent + A call to a subprogram in the current unit is inlined if all the + following conditions are met: + + @itemize @bullet + @item + The optimization level is at least @code{-O1}. + + @item + The called subprogram is suitable for inlining: It must be small enough + and not contain nested subprograms or anything else that @code{gcc} + cannot support in inlined subprograms. + + @item + The call occurs after the definition of the body of the subprogram. + + @item + @cindex pragma Inline + @findex Inline + Either @code{pragma Inline} applies to the subprogram or it is + small and automatic inlining (optimization level @code{-O3}) is + specified. + @end itemize + + @noindent + Calls to subprograms in @code{with}'ed units are normally not inlined. + To achieve this level of inlining, the following conditions must all be + true: + + @itemize @bullet + @item + The optimization level is at least @code{-O1}. + + @item + The called subprogram is suitable for inlining: It must be small enough + and not contain nested subprograms or anything else @code{gcc} cannot + support in inlined subprograms. + + @item + The call appears in a body (not in a package spec). + + @item + There is a @code{pragma Inline} for the subprogram. + + @item + @cindex @option{-gnatn} (@code{gcc}) + The @code{-gnatn} switch + is used in the @code{gcc} command line + @end itemize + + Note that specifying the @option{-gnatn} switch causes additional + compilation dependencies. Consider the following: + + @smallexample + @group + @cartouche + @b{package} R @b{is} + @b{procedure} Q; + @b{pragma} Inline (Q); + @b{end} R; + @b{package body} R @b{is} + ... + @b{end} R; + + @b{with} R; + @b{procedure} Main @b{is} + @b{begin} + ... + R.Q; + @b{end} Main; + @end cartouche + @end group + @end smallexample + + @noindent + With the default behavior (no @option{-gnatn} switch specified), the + compilation of the @code{Main} procedure depends only on its own source, + @file{main.adb}, and the spec of the package in file @file{r.ads}. This + means that editing the body of @code{R} does not require recompiling + @code{Main}. + + On the other hand, the call @code{R.Q} is not inlined under these + circumstances. If the @option{-gnatn} switch is present when @code{Main} + is compiled, the call will be inlined if the body of @code{Q} is small + enough, but now @code{Main} depends on the body of @code{R} in + @file{r.adb} as well as on the spec. This means that if this body is edited, + the main program must be recompiled. Note that this extra dependency + occurs whether or not the call is in fact inlined by @code{gcc}. + + The use of front end inlining with @option{-gnatN} generates similar + additional dependencies. + + @cindex @code{-fno-inline} (@code{gcc}) + Note: The @code{-fno-inline} switch + can be used to prevent + all inlining. This switch overrides all other conditions and ensures + that no inlining occurs. The extra dependences resulting from + @option{-gnatn} will still be active, even if + this switch is used to suppress the resulting inlining actions. + + Note regarding the use of @code{-O3}: There is no difference in inlining + behavior between @code{-O2} and @code{-O3} for subprograms with an explicit + pragma @code{Inline} assuming the use of @option{-gnatn} + or @option{-gnatN} (the switches that activate inlining). If you have used + pragma @code{Inline} in appropriate cases, then it is usually much better + to use @code{-O2} and @option{-gnatn} and avoid the use of @code{-O3} which + in this case only has the effect of inlining subprograms you did not + think should be inlined. We often find that the use of @code{-O3} slows + down code by performing excessive inlining, leading to increased instruction + cache pressure from the increased code size. So the bottom line here is + that you should not automatically assume that @code{-O3} is better than + @code{-O2}, and indeed you should use @code{-O3} only if tests show that + it actually improves performance. + + + @include fdl.texi + @c GNU Free Documentation License + + @node Index,,GNU Free Documentation License, Top + @unnumbered Index + + @printindex cp + + @contents + + @bye diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_ug_vms.info gcc-3.3/gcc/ada/gnat_ug_vms.info *** gcc-3.2.3/gcc/ada/gnat_ug_vms.info 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_ug_vms.info 2003-05-14 00:31:41.000000000 +0000 *************** *** 0 **** --- 1,17933 ---- + This is ada/gnat_ug_vms.info, produced by makeinfo version 4.2 from + ada/gnat_ug_vms.texi. + + Copyright (C) 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT User's Guide for OpenVMS Alpha", and with + no Back-Cover Texts. A copy of the license is included in the section + entitled "GNU Free Documentation License". +  + File: gnat_ug_vms.info, Node: Top, Next: About This Guide, Prev: (dir), Up: (dir) + + GNAT User's Guide + ***************** + + GNAT User's Guide for OpenVMS Alpha + + GNAT, The GNU Ada 95 Compiler + + GNAT Version for GCC 3.3 + + Ada Core Technologies, Inc. + + Copyright (C) 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT User's Guide for OpenVMS Alpha", and with + no Back-Cover Texts. A copy of the license is included in the section + entitled "GNU Free Documentation License". + * Menu: + + * About This Guide:: + * Getting Started with GNAT:: + * The GNAT Compilation Model:: + * Compiling Using GNAT COMPILE:: + * Binding Using GNAT BIND:: + * Linking Using GNAT LINK:: + * The GNAT Make Program GNAT MAKE:: + * Renaming Files Using GNAT CHOP:: + * Configuration Pragmas:: + * Handling Arbitrary File Naming Conventions Using gnatname:: + * GNAT Project Manager:: + * Elaboration Order Handling in GNAT:: + * The Cross-Referencing Tools GNAT XREF and GNAT FIND:: + * File Name Krunching Using GNAT KRUNCH:: + * Preprocessing Using GNAT PREPROCESS:: + * The GNAT Run-Time Library Builder GNAT LIBRARY:: + * The GNAT Library Browser GNAT LIST:: + * Finding Memory Problems with GNAT Debug Pool:: + * Creating Sample Bodies Using GNAT STUB:: + * Reducing the Size of Ada Executables with GNAT ELIM:: + * Other Utility Programs:: + * Compatibility with DEC Ada:: + * Running and Debugging Ada Programs:: + * Inline Assembler:: + * Performance Considerations:: + * GNU Free Documentation License:: + * Index:: + + --- The Detailed Node Listing --- + + About This Guide + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + + + Getting Started with GNAT + + * Running GNAT:: + * Running a Simple Ada Program:: + * Running a Program with Multiple Units:: + * Using the GNAT MAKE Utility:: + * Editing with EMACS:: + + The GNAT Compilation Model + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + Foreign Language Representation + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + + Compiling Ada Programs With GNAT COMPILE + + * Compiling Programs:: + * Qualifiers for GNAT COMPILE:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + + Qualifiers for GNAT COMPILE + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using GNAT COMPILE for Syntax Checking:: + * Using GNAT COMPILE for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + Binding Ada Programs With GNAT BIND + + * Running GNAT BIND:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Qualifiers:: + * Command-Line Access:: + * Search Paths for GNAT BIND:: + * Examples of GNAT BIND Usage:: + + Linking Using GNAT LINK + + * Running GNAT LINK:: + * Qualifiers for GNAT LINK:: + * Setting Stack Size from GNAT LINK:: + * Setting Heap Size from GNAT LINK:: + + The GNAT Make Program GNAT MAKE + + * Running GNAT MAKE:: + * Qualifiers for GNAT MAKE:: + * Mode Qualifiers for GNAT MAKE:: + * Notes on the Command Line:: + * How GNAT MAKE Works:: + * Examples of GNAT MAKE Usage:: + + Renaming Files Using GNAT CHOP + + * Handling Files with Multiple Units:: + * Operating GNAT CHOP in Compilation Mode:: + * Command Line for GNAT CHOP:: + * Qualifiers for GNAT CHOP:: + * Examples of GNAT CHOP Usage:: + + Configuration Pragmas + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + + Handling Arbitrary File Naming Conventions Using gnatname + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Qualifiers for gnatname:: + * Examples of gnatname Usage:: + + GNAT Project Manager + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Qualifiers Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + + Elaboration Order Handling in GNAT + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + The Cross-Referencing Tools GNAT XREF and GNAT FIND + + * GNAT XREF Qualifiers:: + * GNAT FIND Qualifiers:: + * Project Files for GNAT XREF and GNAT FIND:: + * Regular Expressions in GNAT FIND and GNAT XREF:: + * Examples of GNAT XREF Usage:: + * Examples of GNAT FIND Usage:: + + File Name Krunching Using GNAT KRUNCH + + * About GNAT KRUNCH:: + * Using GNAT KRUNCH:: + * Krunching Method:: + * Examples of GNAT KRUNCH Usage:: + + Preprocessing Using GNAT PREPROCESS + + * Using GNAT PREPROCESS:: + * Qualifiers for GNAT PREPROCESS:: + * Form of Definitions File:: + * Form of Input Text for GNAT PREPROCESS:: + + The GNAT Run-Time Library Builder GNAT LIBRARY + + * Running GNAT LIBRARY:: + * Qualifiers for GNAT LIBRARY:: + * Examples of GNAT LIBRARY Usage:: + + The GNAT Library Browser GNAT LIST + + * Running GNAT LIST:: + * Qualifiers for GNAT LIST:: + * Examples of GNAT LIST Usage:: + + + Finding Memory Problems with GNAT Debug Pool + + Creating Sample Bodies Using GNAT STUB + + * Running GNAT STUB:: + * Qualifiers for GNAT STUB:: + + Reducing the Size of Ada Executables with GNAT ELIM + + * About GNAT ELIM:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for GNAT ELIM:: + * Running GNAT ELIM:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the GNAT ELIM Usage Cycle:: + + Other Utility Programs + + * Using Other Utility Programs with GNAT:: + * The GNAT STANDARD Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * LSE:: + + Compatibility with DEC Ada + + * Ada 95 Compatibility:: + * Differences in the Definition of Package System:: + * Language-Related Features:: + * The Package STANDARD:: + * The Package SYSTEM:: + * Tasking and Task-Related Features:: + * Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems:: + * Pragmas and Pragma-Related Features:: + * Library of Predefined Units:: + * Bindings:: + * Main Program Definition:: + * Implementation-Defined Attributes:: + * Compiler and Run-Time Interfacing:: + * Program Compilation and Library Management:: + * Input-Output:: + * Implementation Limits:: + * Tools:: + + Language-Related Features + + * Integer Types and Representations:: + * Floating-Point Types and Representations:: + * Pragmas Float_Representation and Long_Float:: + * Fixed-Point Types and Representations:: + * Record and Array Component Alignment:: + * Address Clauses:: + * Other Representation Clauses:: + + Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + + * Assigning Task IDs:: + * Task IDs and Delays:: + * Task-Related Pragmas:: + * Scheduling and Task Priority:: + * The Task Stack:: + * External Interrupts:: + + Pragmas and Pragma-Related Features + + * Restrictions on the Pragma INLINE:: + * Restrictions on the Pragma INTERFACE:: + * Restrictions on the Pragma SYSTEM_NAME:: + + Library of Predefined Units + + * Changes to DECLIB:: + + Bindings + + * Shared Libraries and Options Files:: + * Interfaces to C:: + + Running and Debugging Ada Programs + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + + Inline Assembler + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + + + + Performance Considerations + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + * Coverage Analysis:: + + * Index:: + +  + File: gnat_ug_vms.info, Node: About This Guide, Next: Getting Started with GNAT, Prev: Top, Up: Top + + About This Guide + **************** + + This guide describes the use of of GNAT, a full language compiler for + the Ada 95 programming language, implemented on DIGITAL OpenVMS Alpha + Systems. It describes the features of the compiler and tools, and + details how to use them to build Ada 95 applications. + + * Menu: + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + +  + File: gnat_ug_vms.info, Node: What This Guide Contains, Next: What You Should Know before Reading This Guide, Up: About This Guide + + What This Guide Contains + ======================== + + This guide contains the following chapters: + * *Note Getting Started with GNAT::, describes how to get started + compiling and running Ada programs with the GNAT Ada programming + environment. + + * *Note The GNAT Compilation Model::, describes the compilation + model used by GNAT. + + * *Note Compiling Using GNAT COMPILE::, describes how to compile Ada + programs with `GNAT COMPILE', the Ada compiler. + + * *Note Binding Using GNAT BIND::, describes how to perform binding + of Ada programs with `GNAT BIND', the GNAT binding utility. + + * *Note Linking Using GNAT LINK::, describes `GNAT LINK', a program + that provides for linking using the GNAT run-time library to + construct a program. `GNAT LINK' can also incorporate foreign + language object units into the executable. + + * *Note The GNAT Make Program GNAT MAKE::, describes `GNAT MAKE', a + utility that automatically determines the set of sources needed by + an Ada compilation unit, and executes the necessary compilations + binding and link. + + * *Note Renaming Files Using GNAT CHOP::, describes `GNAT CHOP', a + utility that allows you to preprocess a file that contains Ada + source code, and split it into one or more new files, one for each + compilation unit. + + * *Note Configuration Pragmas::, describes the configuration pragmas + handled by GNAT. + + * *Note Handling Arbitrary File Naming Conventions Using gnatname::, + shows how to override the default GNAT file naming conventions, + either for an individual unit or globally. + + * *Note GNAT Project Manager::, describes how to use project files + to organize large projects. + + * *Note Elaboration Order Handling in GNAT::, describes how GNAT + helps you deal with elaboration order issues. + + * *Note The Cross-Referencing Tools GNAT XREF and GNAT FIND::, + discusses `GNAT XREF' and `GNAT FIND', two tools that provide an + easy way to navigate through sources. + + * *Note File Name Krunching Using GNAT KRUNCH::, describes the `GNAT + KRUNCH' file name krunching utility, used to handle shortened file + names on operating systems with a limit on the length of names. + + * *Note Preprocessing Using GNAT PREPROCESS::, describes `GNAT + PREPROCESS', a preprocessor utility that allows a single source + file to be used to generate multiple or parameterized source + files, by means of macro substitution. + + * *Note The GNAT Library Browser GNAT LIST::, describes `GNAT LIST', + a utility that displays information about compiled units, + including dependences on the corresponding sources files, and + consistency of compilations. + + * *Note Finding Memory Problems with GNAT Debug Pool::, describes + how to use the GNAT-specific Debug Pool in order to detect as + early as possible the use of incorrect memory references. + + * *Note Creating Sample Bodies Using GNAT STUB::, discusses `GNAT + STUB', a utility that generates empty but compilable bodies for + library units. + + * *Note Reducing the Size of Ada Executables with GNAT ELIM::, + describes `GNAT ELIM', a tool which detects unused subprograms and + helps the compiler to create a smaller executable for the program. + + * *Note Other Utility Programs::, discusses several other GNAT + utilities, including `GNAT STANDARD'. + + * *Note Running and Debugging Ada Programs::, describes how to run + and debug Ada programs. + + * *Note Inline Assembler::, shows how to use the inline assembly + facility in an Ada program. + + * *Note Performance Considerations::, reviews the trade offs between + using defaults or options in program development. + + * *Note Compatibility with DEC Ada::, details the compatibility of + GNAT with DEC Ada 83 for OpenVMS Alpha. + +  + File: gnat_ug_vms.info, Node: What You Should Know before Reading This Guide, Next: Related Information, Prev: What This Guide Contains, Up: About This Guide + + What You Should Know before Reading This Guide + ============================================== + + This user's guide assumes that you are familiar with Ada 95 language, as + described in the International Standard ANSI/ISO/IEC-8652:1995, Jan + 1995. + +  + File: gnat_ug_vms.info, Node: Related Information, Next: Conventions, Prev: What You Should Know before Reading This Guide, Up: About This Guide + + Related Information + =================== + + For further information about related tools, refer to the following + documents: + + * `GNAT Reference Manual', which contains all reference material for + the GNAT implementation of Ada 95. + + * `Ada 95 Language Reference Manual', which contains all reference + material for the Ada 95 programming language. + + * `Debugging with GDB' , located in the GNU:[DOCS] directory, + contains all details on the use of the GNU source-level debugger. + + * `GNU EMACS Manual' , located in the GNU:[DOCS] directory if the + EMACS kit is installed, contains full information on the + extensible editor and programming environment EMACS. + + +  + File: gnat_ug_vms.info, Node: Conventions, Prev: Related Information, Up: About This Guide + + Conventions + =========== + + Following are examples of the typographical and graphic conventions used + in this guide: + + * `Functions', `utility program names', `standard names', and + `classes'. + + * `Option flags' + + * `File Names', `button names', and `field names'. + + * VARIABLES. + + * _Emphasis_. + + * [optional information or parameters] + + * Examples are described by text + and then shown this way. + + Commands that are entered by the user are preceded in this manual by the + characters "`$ '" (dollar sign followed by space). If your system uses + this sequence as a prompt, then the commands will appear exactly as you + see them in the manual. If your system uses some other prompt, then the + command will appear with the `$' replaced by whatever prompt character + you are using. + +  + File: gnat_ug_vms.info, Node: Getting Started with GNAT, Next: The GNAT Compilation Model, Prev: About This Guide, Up: Top + + Getting Started with GNAT + ************************* + + This chapter describes some simple ways of using GNAT to build + executable Ada programs. + + * Menu: + + * Running GNAT:: + * Running a Simple Ada Program:: + + * Running a Program with Multiple Units:: + + * Using the GNAT MAKE Utility:: + * Editing with EMACS:: + +  + File: gnat_ug_vms.info, Node: Running GNAT, Next: Running a Simple Ada Program, Up: Getting Started with GNAT + + Running GNAT + ============ + + Three steps are needed to create an executable file from an Ada source + file: + + 1. The source file(s) must be compiled. + + 2. The file(s) must be bound using the GNAT binder. + + 3. All appropriate object files must be linked to produce an + executable. + + All three steps are most commonly handled by using the `GNAT MAKE' + utility program that, given the name of the main program, automatically + performs the necessary compilation, binding and linking steps. + +  + File: gnat_ug_vms.info, Node: Running a Simple Ada Program, Next: Running a Program with Multiple Units, Prev: Running GNAT, Up: Getting Started with GNAT + + Running a Simple Ada Program + ============================ + + Any text editor may be used to prepare an Ada program. If `Glide' is + used, the optional Ada mode may be helpful in laying out the program. + The program text is a normal text file. We will suppose in our initial + example that you have used your editor to prepare the following + standard format text file: + + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + Put_Line ("Hello WORLD!"); + end Hello; + + This file should be named `HELLO.ADB'. With the normal default file + naming conventions, GNAT requires that each file contain a single + compilation unit whose file name is the unit name, with periods + replaced by hyphens; the extension is `ads' for a spec and `adb' for a + body. You can override this default file naming convention by use of + the special pragma `Source_File_Name' (*note Using Other File Names::). + Alternatively, if you want to rename your files according to this + default convention, which is probably more convenient if you will be + using GNAT for all your compilations, then the `GNAT CHOP' utility can + be used to generate correctly-named source files (*note Renaming Files + Using GNAT CHOP::). + + You can compile the program using the following command (`$' is used + as the command prompt in the examples in this document): + + $ GNAT COMPILE HELLO.ADB + + `GNAT COMPILE' is the command used to run the compiler. This compiler is + capable of compiling programs in several languages, including Ada 95 and + C. It assumes that you have given it an Ada program if the file + extension is either `.ADS' or `.ADB', and it will then call the GNAT + compiler to compile the specified file. + + This compile command generates a file `HELLO.OBJ', which is the + object file corresponding to your Ada program. It also generates an + "Ada Library Information" file `HELLO.ALI', which contains additional + information used to check that an Ada program is consistent. To build + an executable file, use `GNAT BIND' to bind the program and `GNAT LINK' + to link it. The argument to both `GNAT BIND' and `GNAT LINK' is the + name of the `ali' file, but the default extension of `.ALI' can be + omitted. This means that in the most common case, the argument is + simply the name of the main program: + + $ GNAT BIND hello + $ GNAT LINK hello + + A simpler method of carrying out these steps is to use `GNAT MAKE', a + master program that invokes all the required compilation, binding and + linking tools in the correct order. In particular, `GNAT MAKE' + automatically recompiles any sources that have been modified since they + were last compiled, or sources that depend on such modified sources, so + that "version skew" is avoided. + + $ GNAT MAKE HELLO.ADB + + The result is an executable program called `hello', which can be run by + entering: + + $ hello + + assuming that the current directory is on the search path for + executable programs. + + and, if all has gone well, you will see + + Hello WORLD! + + appear in response to this command. + +  + File: gnat_ug_vms.info, Node: Running a Program with Multiple Units, Next: Using the GNAT MAKE Utility, Prev: Running a Simple Ada Program, Up: Getting Started with GNAT + + Running a Program with Multiple Units + ===================================== + + Consider a slightly more complicated example that has three files: a + main program, and the spec and body of a package: + + package Greetings is + procedure Hello; + procedure Goodbye; + end Greetings; + + with Ada.Text_IO; use Ada.Text_IO; + package body Greetings is + procedure Hello is + begin + Put_Line ("Hello WORLD!"); + end Hello; + + procedure Goodbye is + begin + Put_Line ("Goodbye WORLD!"); + end Goodbye; + end Greetings; + + with Greetings; + procedure Gmain is + begin + Greetings.Hello; + Greetings.Goodbye; + end Gmain; + + Following the one-unit-per-file rule, place this program in the + following three separate files: + + `GREETINGS.ADS' + spec of package `Greetings' + + `GREETINGS.ADB' + body of package `Greetings' + + `GMAIN.ADB' + body of main program + + To build an executable version of this program, we could use four + separate steps to compile, bind, and link the program, as follows: + + $ GNAT COMPILE GMAIN.ADB + $ GNAT COMPILE GREETINGS.ADB + $ GNAT BIND gmain + $ GNAT LINK gmain + + Note that there is no required order of compilation when using GNAT. + In particular it is perfectly fine to compile the main program first. + Also, it is not necessary to compile package specs in the case where + there is an accompanying body; you only need to compile the body. If + you want to submit these files to the compiler for semantic checking + and not code generation, then use the `/NOLOAD' qualifier: + + $ GNAT COMPILE GREETINGS.ADS /NOLOAD + + Although the compilation can be done in separate steps as in the above + example, in practice it is almost always more convenient to use the + `GNAT MAKE' tool. All you need to know in this case is the name of the + main program's source file. The effect of the above four commands can + be achieved with a single one: + + $ GNAT MAKE GMAIN.ADB + + In the next section we discuss the advantages of using `GNAT MAKE' in + more detail. + +  + File: gnat_ug_vms.info, Node: Using the GNAT MAKE Utility, Next: Editing with EMACS, Prev: Running a Program with Multiple Units, Up: Getting Started with GNAT + + Using the `GNAT MAKE' Utility + ============================= + + If you work on a program by compiling single components at a time using + `GNAT COMPILE', you typically keep track of the units you modify. In + order to build a consistent system, you compile not only these units, + but also any units that depend on the units you have modified. For + example, in the preceding case, if you edit `GMAIN.ADB', you only need + to recompile that file. But if you edit `GREETINGS.ADS', you must + recompile both `GREETINGS.ADB' and `GMAIN.ADB', because both files + contain units that depend on `GREETINGS.ADS'. + + `GNAT BIND' will warn you if you forget one of these compilation + steps, so that it is impossible to generate an inconsistent program as a + result of forgetting to do a compilation. Nevertheless it is tedious and + error-prone to keep track of dependencies among units. One approach to + handle the dependency-bookkeeping is to use a makefile. However, + makefiles present maintenance problems of their own: if the + dependencies change as you change the program, you must make sure that + the makefile is kept up-to-date manually, which is also an error-prone + process. + + The `GNAT MAKE' utility takes care of these details automatically. + Invoke it using either one of the following forms: + + $ GNAT MAKE GMAIN.ADB + $ GNAT MAKE GMAIN + + The argument is the name of the file containing the main program; you + may omit the extension. `GNAT MAKE' examines the environment, + automatically recompiles any files that need recompiling, and binds and + links the resulting set of object files, generating the executable + file, `GMAIN.EXE'. In a large program, it can be extremely helpful to + use `GNAT MAKE', because working out by hand what needs to be + recompiled can be difficult. + + Note that `GNAT MAKE' takes into account all the Ada 95 rules that + establish dependencies among units. These include dependencies that + result from inlining subprogram bodies, and from generic instantiation. + Unlike some other Ada make tools, `GNAT MAKE' does not rely on the + dependencies that were found by the compiler on a previous compilation, + which may possibly be wrong when sources change. `GNAT MAKE' determines + the exact set of dependencies from scratch each time it is run. + +  + File: gnat_ug_vms.info, Node: Editing with EMACS, Prev: Using the GNAT MAKE Utility, Up: Getting Started with GNAT + + Editing with EMACS + ================== + + EMACS is an extensible self-documenting text editor that is available + in a separate VMSINSTAL kit. + + Invoke EMACS by typing "EMACS" at the command prompt. To get started, + click on the EMACS Help menu and run the EMACS Tutorial. In a + character cell terminal, EMACS help is invoked with "Ctrl-h" (also + written as "C-h"), and the tutorial by "C-h t". + + Documentation on EMACS and other tools is available in EMACS under + the pull-down menu button: Help - Info. After selecting Info, use the + middle mouse button to select a topic (e.g. EMACS). + + In a character cell terminal, do "C-h i" to invoke info, and then "m" + (stands for menu) followed by the menu item desired, as in "m EMACS", + to get to the EMACS manual. Help on EMACS is also available by typing + "HELP EMACS" at the DCL command prompt. + + The tutorial is highly recommended in order to learn the intricacies + of EMACS, which is sufficiently extensible to provide for a complete + programming environment and shell for the sophisticated user. + +  + File: gnat_ug_vms.info, Node: The GNAT Compilation Model, Next: Compiling Using GNAT COMPILE, Prev: Getting Started with GNAT, Up: Top + + The GNAT Compilation Model + ************************** + + * Menu: + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + This chapter describes the compilation model used by GNAT. Although + similar to that used by other languages, such as C and C++, this model + is substantially different from the traditional Ada compilation models, + which are based on a library. The model is initially described without + reference to the library-based model. If you have not previously used an + Ada compiler, you need only read the first part of this chapter. The + last section describes and discusses the differences between the GNAT + model and the traditional Ada compiler models. If you have used other + Ada compilers, this section will help you to understand those + differences, and the advantages of the GNAT model. + +  + File: gnat_ug_vms.info, Node: Source Representation, Next: Foreign Language Representation, Up: The GNAT Compilation Model + + Source Representation + ===================== + + Ada source programs are represented in standard text files, using + Latin-1 coding. Latin-1 is an 8-bit code that includes the familiar + 7-bit ASCII set, plus additional characters used for representing + foreign languages (*note Foreign Language Representation:: for support + of non-USA character sets). The format effector characters are + represented using their standard ASCII encodings, as follows: + + `VT' + Vertical tab, `16#0B#' + + `HT' + Horizontal tab, `16#09#' + + `CR' + Carriage return, `16#0D#' + + `LF' + Line feed, `16#0A#' + + `FF' + Form feed, `16#0C#' + + Source files are in standard text file format. In addition, GNAT will + recognize a wide variety of stream formats, in which the end of physical + physical lines is marked by any of the following sequences: `LF', `CR', + `CR-LF', or `LF-CR'. This is useful in accommodating files that are + imported from other operating systems. + + The end of a source file is normally represented by the physical end + of file. However, the control character `16#1A#' (`SUB') is also + recognized as signalling the end of the source file. Again, this is + provided for compatibility with other operating systems where this code + is used to represent the end of file. + + Each file contains a single Ada compilation unit, including any + pragmas associated with the unit. For example, this means you must + place a package declaration (a package "spec") and the corresponding + body in separate files. An Ada "compilation" (which is a sequence of + compilation units) is represented using a sequence of files. Similarly, + you will place each subunit or child unit in a separate file. + +  + File: gnat_ug_vms.info, Node: Foreign Language Representation, Next: File Naming Rules, Prev: Source Representation, Up: The GNAT Compilation Model + + Foreign Language Representation + =============================== + + GNAT supports the standard character sets defined in Ada 95 as well as + several other non-standard character sets for use in localized versions + of the compiler (*note Character Set Control::). + + * Menu: + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + +  + File: gnat_ug_vms.info, Node: Latin-1, Next: Other 8-Bit Codes, Up: Foreign Language Representation + + Latin-1 + ------- + + The basic character set is Latin-1. This character set is defined by ISO + standard 8859, part 1. The lower half (character codes `16#00#' ... + `16#7F#)' is identical to standard ASCII coding, but the upper half is + used to represent additional characters. These include extended letters + used by European languages, such as French accents, the vowels with + umlauts used in German, and the extra letter A-ring used in Swedish. + + For a complete list of Latin-1 codes and their encodings, see the + source file of library unit `Ada.Characters.Latin_1' in file + `A-CHLAT1.ADS'. You may use any of these extended characters freely in + character or string literals. In addition, the extended characters that + represent letters can be used in identifiers. + +  + File: gnat_ug_vms.info, Node: Other 8-Bit Codes, Next: Wide Character Encodings, Prev: Latin-1, Up: Foreign Language Representation + + Other 8-Bit Codes + ----------------- + + GNAT also supports several other 8-bit coding schemes: + + Latin-2 + Latin-2 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-3 + Latin-3 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-4 + Latin-4 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-5 + Latin-4 letters (Cyrillic) allowed in identifiers, with uppercase + and lowercase equivalence. + + IBM PC (code page 437) + This code page is the normal default for PCs in the U.S. It + corresponds to the original IBM PC character set. This set has + some, but not all, of the extended Latin-1 letters, but these + letters do not have the same encoding as Latin-1. In this mode, + these letters are allowed in identifiers with uppercase and + lowercase equivalence. + + IBM PC (code page 850) + This code page is a modification of 437 extended to include all the + Latin-1 letters, but still not with the usual Latin-1 encoding. In + this mode, all these letters are allowed in identifiers with + uppercase and lowercase equivalence. + + Full Upper 8-bit + Any character in the range 80-FF allowed in identifiers, and all + are considered distinct. In other words, there are no uppercase + and lowercase equivalences in this range. This is useful in + conjunction with certain encoding schemes used for some foreign + character sets (e.g. the typical method of representing Chinese + characters on the PC). + + No Upper-Half + No upper-half characters in the range 80-FF are allowed in + identifiers. This gives Ada 83 compatibility for identifier names. + + For precise data on the encodings permitted, and the uppercase and + lowercase equivalences that are recognized, see the file `CSETS.ADB' in + the GNAT compiler sources. You will need to obtain a full source release + of GNAT to obtain this file. + +  + File: gnat_ug_vms.info, Node: Wide Character Encodings, Prev: Other 8-Bit Codes, Up: Foreign Language Representation + + Wide Character Encodings + ------------------------ + + GNAT allows wide character codes to appear in character and string + literals, and also optionally in identifiers, by means of the following + possible encoding schemes: + + Hex Coding + In this encoding, a wide character is represented by the following + five character sequence: + + ESC a b c d + + Where `a', `b', `c', `d' are the four hexadecimal characters + (using uppercase letters) of the wide character code. For example, + ESC A345 is used to represent the wide character with code + `16#A345#'. This scheme is compatible with use of the full + Wide_Character set. + + Upper-Half Coding + The wide character with encoding `16#abcd#' where the upper bit is + on (in other words, "a" is in the range 8-F) is represented as two + bytes, `16#ab#' and `16#cd#'. The second byte cannot be a format + control character, but is not required to be in the upper half. + This method can be also used for shift-JIS or EUC, where the + internal coding matches the external coding. + + Shift JIS Coding + A wide character is represented by a two-character sequence, + `16#ab#' and `16#cd#', with the restrictions described for + upper-half encoding as described above. The internal character + code is the corresponding JIS character according to the standard + algorithm for Shift-JIS conversion. Only characters defined in the + JIS code set table can be used with this encoding method. + + EUC Coding + A wide character is represented by a two-character sequence + `16#ab#' and `16#cd#', with both characters being in the upper + half. The internal character code is the corresponding JIS + character according to the EUC encoding algorithm. Only characters + defined in the JIS code set table can be used with this encoding + method. + + UTF-8 Coding + A wide character is represented using UCS Transformation Format 8 + (UTF-8) as defined in Annex R of ISO 10646-1/Am.2. Depending on + the character value, the representation is a one, two, or three + byte sequence: + 16#0000#-16#007f#: 2#0xxxxxxx# + 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx# + 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx# + + where the xxx bits correspond to the left-padded bits of the + 16-bit character value. Note that all lower half ASCII characters + are represented as ASCII bytes and all upper half characters and + other wide characters are represented as sequences of upper-half + (The full UTF-8 scheme allows for encoding 31-bit characters as + 6-byte sequences, but in this implementation, all UTF-8 sequences + of four or more bytes length will be treated as illegal). + + Brackets Coding + In this encoding, a wide character is represented by the following + eight character sequence: + + [ " a b c d " ] + + Where `a', `b', `c', `d' are the four hexadecimal characters + (using uppercase letters) of the wide character code. For example, + ["A345"] is used to represent the wide character with code + `16#A345#'. It is also possible (though not required) to use the + Brackets coding for upper half characters. For example, the code + `16#A3#' can be represented as `["A3"]'. + + This scheme is compatible with use of the full Wide_Character set, + and is also the method used for wide character encoding in the + standard ACVC (Ada Compiler Validation Capability) test suite + distributions. + + Note: Some of these coding schemes do not permit the full use of the + Ada 95 character set. For example, neither Shift JIS, nor EUC allow the + use of the upper half of the Latin-1 set. + +  + File: gnat_ug_vms.info, Node: File Naming Rules, Next: Using Other File Names, Prev: Foreign Language Representation, Up: The GNAT Compilation Model + + File Naming Rules + ================= + + The default file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + uppercase for all letters. + + An exception arises if the file name generated by the above rules + starts with one of the characters A,G,I, or S, and the second character + is a minus. In this case, the character dollar sign is used in place of + the minus. The reason for this special rule is to avoid clashes with + the standard names for child units of the packages System, Ada, + Interfaces, and GNAT, which use the prefixes S- A- I- and G- + respectively. + + The file extension is `.ADS' for a spec and `.ADB' for a body. The + following list shows some examples of these rules. + + `MAIN.ADS' + Main (spec) + + `MAIN.ADB' + Main (body) + + `ARITH_FUNCTIONS.ADS' + Arith_Functions (package spec) + + `ARITH_FUNCTIONS.ADB' + Arith_Functions (package body) + + `FUNC-SPEC.ADS' + Func.Spec (child package spec) + + `FUNC-SPEC.ADB' + Func.Spec (child package body) + + `MAIN-SUB.ADB' + Sub (subunit of Main) + + `A$BAD.ADB' + A.Bad (child package body) + + Following these rules can result in excessively long file names if + corresponding unit names are long (for example, if child units or + subunits are heavily nested). An option is available to shorten such + long file names (called file name "krunching"). This may be + particularly useful when programs being developed with GNAT are to be + used on operating systems with limited file name lengths. *Note Using + GNAT KRUNCH::. + + Of course, no file shortening algorithm can guarantee uniqueness over + all possible unit names; if file name krunching is used, it is your + responsibility to ensure no name clashes occur. Alternatively you can + specify the exact file names that you want used, as described in the + next section. Finally, if your Ada programs are migrating from a + compiler with a different naming convention, you can use the GNAT CHOP + utility to produce source files that follow the GNAT naming conventions. + (For details *note Renaming Files Using GNAT CHOP::.) + +  + File: gnat_ug_vms.info, Node: Using Other File Names, Next: Alternative File Naming Schemes, Prev: File Naming Rules, Up: The GNAT Compilation Model + + Using Other File Names + ====================== + + In the previous section, we have described the default rules used by + GNAT to determine the file name in which a given unit resides. It is + often convenient to follow these default rules, and if you follow them, + the compiler knows without being explicitly told where to find all the + files it needs. + + However, in some cases, particularly when a program is imported from + another Ada compiler environment, it may be more convenient for the + programmer to specify which file names contain which units. GNAT allows + arbitrary file names to be used by means of the Source_File_Name pragma. + The form of this pragma is as shown in the following examples: + + pragma Source_File_Name (My_Utilities.Stacks, + Spec_File_Name => "MYUTILST_A.ADA"); + pragma Source_File_name (My_Utilities.Stacks, + Body_File_Name => "MYUTILST.ADA"); + + As shown in this example, the first argument for the pragma is the unit + name (in this example a child unit). The second argument has the form + of a named association. The identifier indicates whether the file name + is for a spec or a body; the file name itself is given by a string + literal. + + The source file name pragma is a configuration pragma, which means + that normally it will be placed in the `GNAT.ADC' file used to hold + configuration pragmas that apply to a complete compilation environment. + For more details on how the `GNAT.ADC' file is created and used *note + Handling of Configuration Pragmas:: + + `GNAT MAKE' handles non-standard file names in the usual manner (the + non-standard file name for the main program is simply used as the + argument to GNAT MAKE). Note that if the extension is also non-standard, + then it must be included in the GNAT MAKE command, it may not be + omitted. + +  + File: gnat_ug_vms.info, Node: Alternative File Naming Schemes, Next: Generating Object Files, Prev: Using Other File Names, Up: The GNAT Compilation Model + + Alternative File Naming Schemes + =============================== + + In the previous section, we described the use of the + `Source_File_Name' pragma to allow arbitrary names to be assigned to + individual source files. However, this approach requires one pragma + for each file, and especially in large systems can result in very long + `GNAT.ADC' files, and also create a maintenance problem. + + GNAT also provides a facility for specifying systematic file naming + schemes other than the standard default naming scheme previously + described. An alternative scheme for naming is specified by the use of + `Source_File_Name' pragmas having the following format: + + pragma Source_File_Name ( + Spec_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Body_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Subunit_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + FILE_NAME_PATTERN ::= STRING_LITERAL + CASING_SPEC ::= Lowercase | Uppercase | Mixedcase + + The `FILE_NAME_PATTERN' string shows how the file name is constructed. + It contains a single asterisk character, and the unit name is + substituted systematically for this asterisk. The optional parameter + `Casing' indicates whether the unit name is to be all upper-case + letters, all lower-case letters, or mixed-case. If no `Casing' + parameter is used, then the default is all upper-case. + + The optional `Dot_Replacement' string is used to replace any periods + that occur in subunit or child unit names. If no `Dot_Replacement' + argument is used then separating dots appear unchanged in the resulting + file name. Although the above syntax indicates that the `Casing' + argument must appear before the `Dot_Replacement' argument, but it is + also permissible to write these arguments in the opposite order. + + As indicated, it is possible to specify different naming schemes for + bodies, specs, and subunits. Quite often the rule for subunits is the + same as the rule for bodies, in which case, there is no need to give a + separate `Subunit_File_Name' rule, and in this case the + `Body_File_name' rule is used for subunits as well. + + The separate rule for subunits can also be used to implement the + rather unusual case of a compilation environment (e.g. a single + directory) which contains a subunit and a child unit with the same unit + name. Although both units cannot appear in the same partition, the Ada + Reference Manual allows (but does not require) the possibility of the + two units coexisting in the same environment. + + The file name translation works in the following steps: + + * If there is a specific `Source_File_Name' pragma for the given + unit, then this is always used, and any general pattern rules are + ignored. + + * If there is a pattern type `Source_File_Name' pragma that applies + to the unit, then the resulting file name will be used if the file + exists. If more than one pattern matches, the latest one will be + tried first, and the first attempt resulting in a reference to a + file that exists will be used. + + * If no pattern type `Source_File_Name' pragma that applies to the + unit for which the corresponding file exists, then the standard + GNAT default naming rules are used. + + + As an example of the use of this mechanism, consider a commonly used + scheme in which file names are all lower case, with separating periods + copied unchanged to the resulting file name, and specs end with + ".1.ADA", and bodies end with ".2.ADA". GNAT will follow this scheme if + the following two pragmas appear: + + pragma Source_File_Name + (Spec_File_Name => "*.1.ADA"); + pragma Source_File_Name + (Body_File_Name => "*.2.ADA"); + + The default GNAT scheme is actually implemented by providing the + following default pragmas internally: + + pragma Source_File_Name + (Spec_File_Name => "*.ADS", Dot_Replacement => "-"); + pragma Source_File_Name + (Body_File_Name => "*.ADB", Dot_Replacement => "-"); + + Our final example implements a scheme typically used with one of the + Ada 83 compilers, where the separator character for subunits was "__" + (two underscores), specs were identified by adding `_.ADA', bodies by + adding `.ADA', and subunits by adding `.SEP'. All file names were upper + case. Child units were not present of course since this was an Ada 83 + compiler, but it seems reasonable to extend this scheme to use the same + double underscore separator for child units. + + pragma Source_File_Name + (Spec_File_Name => "*_.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Body_File_Name => "*.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Subunit_File_Name => "*.SEP", + Dot_Replacement => "__", + Casing = Uppercase); + +  + File: gnat_ug_vms.info, Node: Generating Object Files, Next: Source Dependencies, Prev: Alternative File Naming Schemes, Up: The GNAT Compilation Model + + Generating Object Files + ======================= + + An Ada program consists of a set of source files, and the first step in + compiling the program is to generate the corresponding object files. + These are generated by compiling a subset of these source files. The + files you need to compile are the following: + + * If a package spec has no body, compile the package spec to produce + the object file for the package. + + * If a package has both a spec and a body, compile the body to + produce the object file for the package. The source file for the + package spec need not be compiled in this case because there is + only one object file, which contains the code for both the spec + and body of the package. + + * For a subprogram, compile the subprogram body to produce the + object file for the subprogram. The spec, if one is present, is as + usual in a separate file, and need not be compiled. + + * In the case of subunits, only compile the parent unit. A single + object file is generated for the entire subunit tree, which + includes all the subunits. + + * Compile child units independently of their parent units (though, + of course, the spec of all the ancestor unit must be present in + order to compile a child unit). + + * Compile generic units in the same manner as any other units. The + object files in this case are small dummy files that contain at + most the flag used for elaboration checking. This is because GNAT + always handles generic instantiation by means of macro expansion. + However, it is still necessary to compile generic units, for + dependency checking and elaboration purposes. + + The preceding rules describe the set of files that must be compiled to + generate the object files for a program. Each object file has the same + name as the corresponding source file, except that the extension is + `.OBJ' as usual. + + You may wish to compile other files for the purpose of checking their + syntactic and semantic correctness. For example, in the case where a + package has a separate spec and body, you would not normally compile the + spec. However, it is convenient in practice to compile the spec to make + sure it is error-free before compiling clients of this spec, because + such compilations will fail if there is an error in the spec. + + GNAT provides an option for compiling such files purely for the + purposes of checking correctness; such compilations are not required as + part of the process of building a program. To compile a file in this + checking mode, use the `/NOLOAD' qualifier. + +  + File: gnat_ug_vms.info, Node: Source Dependencies, Next: The Ada Library Information Files, Prev: Generating Object Files, Up: The GNAT Compilation Model + + Source Dependencies + =================== + + A given object file clearly depends on the source file which is compiled + to produce it. Here we are using "depends" in the sense of a typical + `make' utility; in other words, an object file depends on a source file + if changes to the source file require the object file to be recompiled. + In addition to this basic dependency, a given object may depend on + additional source files as follows: + + * If a file being compiled `with''s a unit X, the object file + depends on the file containing the spec of unit X. This includes + files that are `with''ed implicitly either because they are parents + of `with''ed child units or they are run-time units required by the + language constructs used in a particular unit. + + * If a file being compiled instantiates a library level generic + unit, the object file depends on both the spec and body files for + this generic unit. + + * If a file being compiled instantiates a generic unit defined + within a package, the object file depends on the body file for the + package as well as the spec file. + + * If a file being compiled contains a call to a subprogram for which + pragma `Inline' applies and inlining is activated with the + `/INLINE=PRAGMA' qualifier, the object file depends on the file + containing the body of this subprogram as well as on the file + containing the spec. Note that for inlining to actually occur as a + result of the use of this qualifier, it is necessary to compile in + optimizing mode. + + The use of `-gnatN' activates a more extensive inlining + optimization that is performed by the front end of the compiler. + This inlining does not require that the code generation be + optimized. Like `/INLINE=PRAGMA', the use of this qualifier + generates additional dependencies. + + * If an object file O depends on the proper body of a subunit + through inlining or instantiation, it depends on the parent unit + of the subunit. This means that any modification of the parent + unit or one of its subunits affects the compilation of O. + + * The object file for a parent unit depends on all its subunit body + files. + + * The previous two rules meant that for purposes of computing + dependencies and recompilation, a body and all its subunits are + treated as an indivisible whole. + + These rules are applied transitively: if unit `A' `with''s unit + `B', whose elaboration calls an inlined procedure in package `C', + the object file for unit `A' will depend on the body of `C', in + file `C.ADB'. + + The set of dependent files described by these rules includes all + the files on which the unit is semantically dependent, as + described in the Ada 95 Language Reference Manual. However, it is + a superset of what the ARM describes, because it includes generic, + inline, and subunit dependencies. + + An object file must be recreated by recompiling the corresponding + source file if any of the source files on which it depends are + modified. For example, if the `make' utility is used to control + compilation, the rule for an Ada object file must mention all the + source files on which the object file depends, according to the + above definition. The determination of the necessary + recompilations is done automatically when one uses `GNAT MAKE'. + +  + File: gnat_ug_vms.info, Node: The Ada Library Information Files, Next: Binding an Ada Program, Prev: Source Dependencies, Up: The GNAT Compilation Model + + The Ada Library Information Files + ================================= + + Each compilation actually generates two output files. The first of these + is the normal object file that has a `.OBJ' extension. The second is a + text file containing full dependency information. It has the same name + as the source file, but an `.ALI' extension. This file is known as the + Ada Library Information (`ali') file. The following information is + contained in the `ali' file. + + * Version information (indicates which version of GNAT was used to + compile the unit(s) in question) + + * Main program information (including priority and time slice + settings, as well as the wide character encoding used during + compilation). + + * List of arguments used in the `GNAT COMPILE' command for the + compilation + + * Attributes of the unit, including configuration pragmas used, an + indication of whether the compilation was successful, exception + model used etc. + + * A list of relevant restrictions applying to the unit (used for + consistency) checking. + + * Categorization information (e.g. use of pragma `Pure'). + + * Information on all `with''ed units, including presence of + `Elaborate' or `Elaborate_All' pragmas. + + * Information from any `Linker_Options' pragmas used in the unit + + * Information on the use of `Body_Version' or `Version' attributes + in the unit. + + * Dependency information. This is a list of files, together with + time stamp and checksum information. These are files on which the + unit depends in the sense that recompilation is required if any of + these units are modified. + + * Cross-reference data. Contains information on all entities + referenced in the unit. Used by tools like `GNAT XREF' and `GNAT + FIND' to provide cross-reference information. + + + For a full detailed description of the format of the `ali' file, see + the source of the body of unit `Lib.Writ', contained in file + `LIB-WRIT.ADB' in the GNAT compiler sources. + +  + File: gnat_ug_vms.info, Node: Binding an Ada Program, Next: Mixed Language Programming, Prev: The Ada Library Information Files, Up: The GNAT Compilation Model + + Binding an Ada Program + ====================== + + When using languages such as C and C++, once the source files have been + compiled the only remaining step in building an executable program is + linking the object modules together. This means that it is possible to + link an inconsistent version of a program, in which two units have + included different versions of the same header. + + The rules of Ada do not permit such an inconsistent program to be + built. For example, if two clients have different versions of the same + package, it is illegal to build a program containing these two clients. + These rules are enforced by the GNAT binder, which also determines an + elaboration order consistent with the Ada rules. + + The GNAT binder is run after all the object files for a program have + been created. It is given the name of the main program unit, and from + this it determines the set of units required by the program, by reading + the corresponding ALI files. It generates error messages if the program + is inconsistent or if no valid order of elaboration exists. + + If no errors are detected, the binder produces a main program, in + Ada by default, that contains calls to the elaboration procedures of + those compilation unit that require them, followed by a call to the + main program. This Ada program is compiled to generate the object file + for the main program. The name of the Ada file is `B$XXX.ADB' (with the + corresponding spec `B$XXX.ADS') where XXX is the name of the main + program unit. + + Finally, the linker is used to build the resulting executable + program, using the object from the main program from the bind step as + well as the object files for the Ada units of the program. + +  + File: gnat_ug_vms.info, Node: Mixed Language Programming, Next: Building Mixed Ada & C++ Programs, Prev: Binding an Ada Program, Up: The GNAT Compilation Model + + Mixed Language Programming + ========================== + + * Menu: + + * Interfacing to C:: + * Calling Conventions:: + +  + File: gnat_ug_vms.info, Node: Interfacing to C, Next: Calling Conventions, Up: Mixed Language Programming + + Interfacing to C + ---------------- + + There are two ways to build a program that contains some Ada files and + some other language files depending on whether the main program is in + Ada or not. If the main program is in Ada, you should proceed as + follows: + + 1. Compile the other language files to generate object files. For + instance: + GNAT COMPILE FILE1.C + GNAT COMPILE FILE2.C + + 2. Compile the Ada units to produce a set of object files and ALI + files. For instance: + GNAT MAKE /ACTIONS=COMPILE MY_MAIN.ADB + + 3. Run the Ada binder on the Ada main program. For instance: + GNAT BIND MY_MAIN.ALI + + 4. Link the Ada main program, the Ada objects and the other language + objects. For instance: + GNAT LINK MY_MAIN.ALI FILE1.OBJ FILE2.OBJ + + The three last steps can be grouped in a single command: + GNAT MAKE MY_MAIN.ADB /LINKER_QUALIFIERS FILE1.OBJ FILE2.OBJ + + If the main program is in some language other than Ada, Then you may + have more than one entry point in the Ada subsystem. You must use a + special option of the binder to generate callable routines to initialize + and finalize the Ada units (*note Binding with Non-Ada Main Programs::). + Calls to the initialization and finalization routines must be inserted + in the main program, or some other appropriate point in the code. The + call to initialize the Ada units must occur before the first Ada + subprogram is called, and the call to finalize the Ada units must occur + after the last Ada subprogram returns. You use the same procedure for + building the program as described previously. In this case, however, + the binder only places the initialization and finalization subprograms + into file `B$XXX.ADB' instead of the main program. So, if the main + program is not in Ada, you should proceed as follows: + + 1. Compile the other language files to generate object files. For + instance: + GNAT COMPILE FILE1.C + GNAT COMPILE FILE2.C + + 2. Compile the Ada units to produce a set of object files and ALI + files. For instance: + GNAT MAKE /ACTIONS=COMPILE ENTRY_POINT1.ADB + GNAT MAKE /ACTIONS=COMPILE ENTRY_POINT2.ADB + + 3. Run the Ada binder on the Ada main program. For instance: + GNAT BIND /NOMAIN ENTRY_POINT1.ALI ENTRY_POINT2.ALI + + 4. Link the Ada main program, the Ada objects and the other language + objects. You only need to give the last entry point here. For + instance: + GNAT LINK ENTRY_POINT2.ALI FILE1.OBJ FILE2.OBJ + +  + File: gnat_ug_vms.info, Node: Calling Conventions, Prev: Interfacing to C, Up: Mixed Language Programming + + Calling Conventions + ------------------- + + GNAT follows standard calling sequence conventions and will thus + interface to any other language that also follows these conventions. + The following Convention identifiers are recognized by GNAT: + + * Ada. This indicates that the standard Ada calling sequence will be + used and all Ada data items may be passed without any limitations + in the case where GNAT is used to generate both the caller and + callee. It is also possible to mix GNAT generated code and code + generated by another Ada compiler. In this case, the data types + should be restricted to simple cases, including primitive types. + Whether complex data types can be passed depends on the situation. + Probably it is safe to pass simple arrays, such as arrays of + integers or floats. Records may or may not work, depending on + whether both compilers lay them out identically. Complex structures + involving variant records, access parameters, tasks, or protected + types, are unlikely to be able to be passed. + + Note that in the case of GNAT running on a platform that supports + DEC Ada 83, a higher degree of compatibility can be guaranteed, + and in particular records are layed out in an identical manner in + the two compilers. Note also that if output from two different + compilers is mixed, the program is responsible for dealing with + elaboration issues. Probably the safest approach is to write the + main program in the version of Ada other than GNAT, so that it + takes care of its own elaboration requirements, and then call the + GNAT-generated adainit procedure to ensure elaboration of the GNAT + components. Consult the documentation of the other Ada compiler + for further details on elaboration. + + However, it is not possible to mix the tasking run time of GNAT and + DEC Ada 83, All the tasking operations must either be entirely + within GNAT compiled sections of the program, or entirely within + DEC Ada 83 compiled sections of the program. + + * Assembler. Specifies assembler as the convention. In practice this + has the same effect as convention Ada (but is not equivalent in + the sense of being considered the same convention). + + * Asm. Equivalent to Assembler. + + * Asm. Equivalent to Assembly. + + * COBOL. Data will be passed according to the conventions described + in section B.4 of the Ada 95 Reference Manual. + + * C. Data will be passed according to the conventions described in + section B.3 of the Ada 95 Reference Manual. + + * Default. Equivalent to C. + + * External. Equivalent to C. + + * CPP. This stands for C++. For most purposes this is identical to C. + See the separate description of the specialized GNAT pragmas + relating to C++ interfacing for further details. + + * Fortran. Data will be passed according to the conventions described + in section B.5 of the Ada 95 Reference Manual. + + * Intrinsic. This applies to an intrinsic operation, as defined in + the Ada 95 Reference Manual. If a a pragma Import (Intrinsic) + applies to a subprogram, this means that the body of the + subprogram is provided by the compiler itself, usually by means of + an efficient code sequence, and that the user does not supply an + explicit body for it. In an application program, the pragma can + only be applied to the following two sets of names, which the GNAT + compiler recognizes. + * Rotate_Left, Rotate_Right, Shift_Left, Shift_Right, + Shift_Right_- Arithmetic. The corresponding subprogram + declaration must have two formal parameters. The first one + must be a signed integer type or a modular type with a binary + modulus, and the second parameter must be of type Natural. + The return type must be the same as the type of the first + argument. The size of this type can only be 8, 16, 32, or 64. + + * binary arithmetic operators: "+", "-", "*", "/" The + corresponding operator declaration must have parameters and + result type that have the same root numeric type (for + example, all three are long_float types). This simplifies the + definition of operations that use type checking to perform + dimensional checks: + type Distance is new Long_Float; + type Time is new Long_Float; + type Velocity is new Long_Float; + function "/" (D : Distance; T : Time) + return Velocity; + pragma Import (Intrinsic, "/"); + + This common idiom is often programmed with a generic + definition and an explicit body. The pragma makes it simpler + to introduce such declarations. It incurs no overhead in + compilation time or code size, because it is implemented as a + single machine instruction. + + * Stdcall. This is relevant only to NT/Win95 implementations of GNAT, + and specifies that the Stdcall calling sequence will be used, as + defined by the NT API. + + * DLL. This is equivalent to Stdcall. + + * Win32. This is equivalent to Stdcall. + + * Stubbed. This is a special convention that indicates that the + compiler should provide a stub body that raises `Program_Error'. + + GNAT additionally provides a useful pragma `Convention_Identifier' that + can be used to parametrize conventions and allow additional synonyms to + be specified. For example if you have legacy code in which the + convention identifier Fortran77 was used for Fortran, you can use the + configuration pragma: + + pragma Convention_Identifier (Fortran77, Fortran); + + And from now on the identifier Fortran77 may be used as a convention + identifier (for example in an `Import' pragma) with the same meaning as + Fortran. + +  + File: gnat_ug_vms.info, Node: Building Mixed Ada & C++ Programs, Next: Comparison between GNAT and C/C++ Compilation Models, Prev: Mixed Language Programming, Up: The GNAT Compilation Model + + Building Mixed Ada & C++ Programs + ================================= + + Building a mixed application containing both Ada and C++ code may be a + challenge for the unaware programmer. As a matter of fact, this + interfacing has not been standardized in the Ada 95 reference manual due + to the immaturity and lack of standard of C++ at the time. This section + gives a few hints that should make this task easier. In particular the + first section addresses the differences with interfacing with C. The + second section looks into the delicate problem of linking the complete + application from its Ada and C++ parts. The last section give some + hints on how the GNAT run time can be adapted in order to allow + inter-language dispatching with a new C++ compiler. + + * Menu: + + * Interfacing to C++:: + * Linking a Mixed C++ & Ada Program:: + * A Simple Example:: + * Adapting the Run Time to a New C++ Compiler:: + +  + File: gnat_ug_vms.info, Node: Interfacing to C++, Next: Linking a Mixed C++ & Ada Program, Up: Building Mixed Ada & C++ Programs + + Interfacing to C++ + ------------------ + + GNAT supports interfacing with C++ compilers generating code that is + compatible with the standard Application Binary Interface of the given + platform. + + Interfacing can be done at 3 levels: simple data, subprograms and + classes. In the first 2 cases, GNAT offer a specific CONVENTION CPP + that behaves exactly like CONVENTION C. Usually C++ mangle names of + subprograms and currently GNAT does not provide any help to solve the + demangling problem. This problem can be addressed in 2 ways: + * by modifying the C++ code in order to force a C convention using + the EXTERN "C" syntax. + + * by figuring out the mangled name and use it as the Link_Name + argument of the pragma import. + + Interfacing at the class level can be achieved by using the GNAT + specific pragmas such as `CPP_Class' and `CPP_Virtual'. See the GNAT + Reference Manual for additional information. + +  + File: gnat_ug_vms.info, Node: Linking a Mixed C++ & Ada Program, Next: A Simple Example, Prev: Interfacing to C++, Up: Building Mixed Ada & C++ Programs + + Linking a Mixed C++ & Ada Program + --------------------------------- + + Usually the linker of the C++ development system must be used to link + mixed applications because most C++ systems will resolve elaboration + issues (such as calling constructors on global class instances) + transparently during the link phase. GNAT has been adapted to ease the + use of a foreign linker for the last phase. Three cases can be + considered: + 1. 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 `c++'. Note that this setup is not very + common because it may request recompiling the whole GCC tree from + sources and it does not allow to upgrade easily to a new version + of one compiler for one of the two languages without taking the + risk of destabilizing the other. + + $ c++ -c file1.C + $ c++ -c file2.C + $ GNAT MAKE ada_unit /LINKER_QUALIFIERS FILE1.OBJ FILE2.OBJ --LINK=c++ + + 2. Using GNAT and G++ from 2 different GCC installations. If both + compilers are on the PATH, the same method can be used. It is + important to be aware that environment variables such as + C_INCLUDE_PATH, GCC_EXEC_PREFIX, BINUTILS_ROOT or GCC_ROOT will + affect both compilers at the same time and thus may make one of + the 2 compilers operate improperly if they are set for the other. + In particular it is important that the link command has access to + the proper GNAT COMPILE library `libgcc.a', that is to say the one + that is part of the C++ compiler installation. The implicit link + command as suggested in the GNAT MAKE command from the former + example can be replaced by an explicit link command with full + verbosity in order to verify which library is used: + $ GNAT BIND ada_unit + $ GNAT LINK -v -v ada_unit FILE1.OBJ FILE2.OBJ --LINK=c++ + If there is a problem due to interfering environment variables, it + can be workaround by using an intermediate script. The following + example shows the proper script to use when GNAT has not been + installed at its default location and g++ has been installed at + its default location: + + $ GNAT LINK -v -v ada_unit FILE1.OBJ FILE2.OBJ --LINK=./my_script + $ cat ./my_script + #!/bin/sh + unset BINUTILS_ROOT + unset GCC_ROOT + c++ $* + + 3. Using a non GNU C++ compiler. The same set of command as previously + described can be used to insure that the c++ linker is used. + Nonetheless, you need to add the path to libgcc explicitely, since + some libraries needed by GNAT are located in this directory: + + + $ GNAT LINK ada_unit FILE1.OBJ FILE2.OBJ --LINK=./my_script + $ cat ./my_script + #!/bin/sh + CC $* `GNAT COMPILE -print-libgcc-file-name` + + Where CC is the name of the non GNU C++ compiler. + + +  + File: gnat_ug_vms.info, Node: A Simple Example, Next: Adapting the Run Time to a New C++ Compiler, Prev: Linking a Mixed C++ & Ada Program, Up: Building Mixed Ada & C++ Programs + + A Simple Example + ---------------- + + The following example, provided as part of the GNAT examples, show how + to achieve procedural interfacing between Ada and C++ in both + directions. The C++ class A has 2 methods. The first method is exported + to Ada by the means of an extern C wrapper function. The second method + calls an Ada subprogram. On the Ada side, The C++ calls is modelized by + a limited record with a layout comparable to the C++ class. The Ada + subprogram, in turn, calls the c++ method. So from the C++ main program + the code goes back and forth between the 2 languages. + + Here are the compilation commands for native configurations: + $ GNAT MAKE -c simple_cpp_interface + $ c++ -c cpp_main.C + $ c++ -c ex7.C + $ GNAT BIND -n simple_cpp_interface + $ GNAT LINK simple_cpp_interface -o cpp_main --LINK=$(CPLUSPLUS) + -lstdc++ EX7.OBJ CPP_MAIN.OBJ + + Here are the corresponding sources: + + //cpp_main.C + + #include "ex7.h" + + extern "C" { + void adainit (void); + void adafinal (void); + void method1 (A *t); + } + + void method1 (A *t) + { + t->method1 (); + } + + int main () + { + A obj; + adainit (); + obj.method2 (3030); + adafinal (); + } + + //ex7.h + + class Origin { + public: + int o_value; + }; + class A : public Origin { + public: + void method1 (void); + virtual void method2 (int v); + A(); + int a_value; + }; + + //ex7.C + + #include "ex7.h" + #include + + extern "C" { void ada_method2 (A *t, int v);} + + void A::method1 (void) + { + a_value = 2020; + printf ("in A::method1, a_value = %d \n",a_value); + + } + + void A::method2 (int v) + { + ada_method2 (this, v); + printf ("in A::method2, a_value = %d \n",a_value); + + } + + A::A(void) + { + a_value = 1010; + printf ("in A::A, a_value = %d \n",a_value); + } + + -- Ada sources + package body Simple_Cpp_Interface is + + procedure Ada_Method2 (This : in out A; V : Integer) is + begin + Method1 (This); + This.A_Value := V; + end Ada_Method2; + + end Simple_Cpp_Interface; + + package Simple_Cpp_Interface is + type A is limited + record + O_Value : Integer; + A_Value : Integer; + end record; + pragma Convention (C, A); + + procedure Method1 (This : in out A); + pragma Import (C, Method1); + + procedure Ada_Method2 (This : in out A; V : Integer); + pragma Export (C, Ada_Method2); + + end Simple_Cpp_Interface; + +  + File: gnat_ug_vms.info, Node: Adapting the Run Time to a New C++ Compiler, Prev: A Simple Example, Up: Building Mixed Ada & C++ Programs + + Adapting the Run Time to a New C++ Compiler + ------------------------------------------- + + GNAT offers the capability to derive Ada 95 tagged types directly from + preexisting C++ classes and . See "Interfacing with C++" in the GNAT + reference manual. The mechanism used by GNAT for achieving such a goal + has been made user configurable through a GNAT library unit + `Interfaces.CPP'. The default version of this file is adapted to the + GNU c++ compiler. Internal knowledge of the virtual table layout used + by the new C++ compiler is needed to configure properly this unit. The + Interface of this unit is known by the compiler and cannot be changed + except for the value of the constants defining the characteristics of + the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size, + CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source + of this unit for more details. + +  + File: gnat_ug_vms.info, Node: Comparison between GNAT and C/C++ Compilation Models, Next: Comparison between GNAT and Conventional Ada Library Models, Prev: Building Mixed Ada & C++ Programs, Up: The GNAT Compilation Model + + Comparison between GNAT and C/C++ Compilation Models + ==================================================== + + The GNAT model of compilation is close to the C and C++ models. You can + think of Ada specs as corresponding to header files in C. As in C, you + don't need to compile specs; they are compiled when they are used. The + Ada `with' is similar in effect to the `#include' of a C header. + + One notable difference is that, in Ada, you may compile specs + separately to check them for semantic and syntactic accuracy. This is + not always possible with C headers because they are fragments of + programs that have less specific syntactic or semantic rules. + + The other major difference is the requirement for running the binder, + which performs two important functions. First, it checks for + consistency. In C or C++, the only defense against assembling + inconsistent programs lies outside the compiler, in a makefile, for + example. The binder satisfies the Ada requirement that it be impossible + to construct an inconsistent program when the compiler is used in normal + mode. + + The other important function of the binder is to deal with + elaboration issues. There are also elaboration issues in C++ that are + handled automatically. This automatic handling has the advantage of + being simpler to use, but the C++ programmer has no control over + elaboration. Where `GNAT BIND' might complain there was no valid order + of elaboration, a C++ compiler would simply construct a program that + malfunctioned at run time. + +  + File: gnat_ug_vms.info, Node: Comparison between GNAT and Conventional Ada Library Models, Prev: Comparison between GNAT and C/C++ Compilation Models, Up: The GNAT Compilation Model + + Comparison between GNAT and Conventional Ada Library Models + =========================================================== + + This section is intended to be useful to Ada programmers who have + previously used an Ada compiler implementing the traditional Ada library + model, as described in the Ada 95 Language Reference Manual. If you + have not used such a system, please go on to the next section. + + In GNAT, there is no "library" in the normal sense. Instead, the set + of source files themselves acts as the library. Compiling Ada programs + does not generate any centralized information, but rather an object + file and a ALI file, which are of interest only to the binder and + linker. In a traditional system, the compiler reads information not + only from the source file being compiled, but also from the centralized + library. This means that the effect of a compilation depends on what + has been previously compiled. In particular: + + * When a unit is `with''ed, the unit seen by the compiler corresponds + to the version of the unit most recently compiled into the library. + + * Inlining is effective only if the necessary body has already been + compiled into the library. + + * Compiling a unit may obsolete other units in the library. + + In GNAT, compiling one unit never affects the compilation of any other + units because the compiler reads only source files. Only changes to + source files can affect the results of a compilation. In particular: + + * When a unit is `with''ed, the unit seen by the compiler corresponds + to the source version of the unit that is currently accessible to + the compiler. + + * Inlining requires the appropriate source files for the package or + subprogram bodies to be available to the compiler. Inlining is + always effective, independent of the order in which units are + complied. + + * Compiling a unit never affects any other compilations. The editing + of sources may cause previous compilations to be out of date if + they depended on the source file being modified. + + The most important result of these differences is that order of + compilation is never significant in GNAT. There is no situation in + which one is required to do one compilation before another. What shows + up as order of compilation requirements in the traditional Ada library + becomes, in GNAT, simple source dependencies; in other words, there is + only a set of rules saying what source files must be present when a + file is compiled. + +  + File: gnat_ug_vms.info, Node: Compiling Using GNAT COMPILE, Next: Binding Using GNAT BIND, Prev: The GNAT Compilation Model, Up: Top + + Compiling Using `GNAT COMPILE' + ****************************** + + This chapter discusses how to compile Ada programs using the `GNAT + COMPILE' command. It also describes the set of qualifiers that can be + used to control the behavior of the compiler. + + * Menu: + + * Compiling Programs:: + * Qualifiers for GNAT COMPILE:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + +  + File: gnat_ug_vms.info, Node: Compiling Programs, Next: Qualifiers for GNAT COMPILE, Up: Compiling Using GNAT COMPILE + + Compiling Programs + ================== + + The first step in creating an executable program is to compile the units + of the program using the `GNAT COMPILE' command. You must compile the + following files: + + * the body file (`.ADB') for a library level subprogram or generic + subprogram + + * the spec file (`.ADS') for a library level package or generic + package that has no body + + * the body file (`.ADB') for a library level package or generic + package that has a body + + + You need _not_ compile the following files + + * the spec of a library unit which has a body + + * subunits + + because they are compiled as part of compiling related units. GNAT + package specs when the corresponding body is compiled, and subunits + when the parent is compiled. If you attempt to compile any of these + files, you will get one of the following error messages (where fff is + the name of the file you compiled): + + No code generated for file FFF (PACKAGE SPEC) + No code generated for file FFF (SUBUNIT) + + The basic command for compiling a file containing an Ada unit is + + $ GNAT COMPILE [QUALIFIERS] `file name' + + where FILE NAME is the name of the Ada file (usually having an extension + `.ADS' for a spec or `.ADB' for a body). The result of a successful + compilation is an object file, which has the same name as the source + file but an extension of `.OBJ' and an Ada Library Information (ALI) + file, which also has the same name as the source file, but with `.ALI' + as the extension. GNAT creates these two output files in the current + directory, but you may specify a source file in any directory using an + absolute or relative path specification containing the directory + information. + + `GNAT COMPILE' is actually a driver program that looks at the + extensions of the file arguments and loads the appropriate compiler. + For example, the GNU C compiler is `CC1', and the Ada compiler is + `GNAT1'. These programs are in directories known to the driver program + (in some configurations via environment variables you set), but need + not be in your path. The `GNAT COMPILE' driver also calls the assembler + and any other utilities needed to complete the generation of the + required object files. + + It is possible to supply several file names on the same `GNAT + COMPILE' command. This causes `GNAT COMPILE' to call the appropriate + compiler for each file. For example, the following command lists three + separate files to be compiled: + + $ GNAT COMPILE X.ADB Y.ADB Z.C + + calls `GNAT1' (the Ada compiler) twice to compile `X.ADB' and `Y.ADB', + and `CC1' (the C compiler) once to compile `Z.C'. The compiler + generates three object files `X.OBJ', `Y.OBJ' and `Z.OBJ' and the two + ALI files `X.ALI' and `Y.ALI' from the Ada compilations. Any qualifiers + apply to all the files listed. + +  + File: gnat_ug_vms.info, Node: Qualifiers for GNAT COMPILE, Next: Search Paths and the Run-Time Library (RTL), Prev: Compiling Programs, Up: Compiling Using GNAT COMPILE + + Qualifiers for `GNAT COMPILE' + ============================= + + The `GNAT COMPILE' command accepts qualifiers that control the + compilation process. These qualifiers are fully described in this + section. First we briefly list all the qualifiers, in alphabetical + order, then we describe the qualifiers in more detail in functionally + grouped sections. + + * Menu: + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using GNAT COMPILE for Syntax Checking:: + * Using GNAT COMPILE for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + `/DEBUG' + Generate debugging information. This information is stored in the + object file and copied from there to the final executable file by + the linker, where it can be read by the debugger. You must use the + `/DEBUG' qualifier if you plan on using the debugger. + + `/SEARCH=DIR' + Direct GNAT to search the DIR directory for source files needed by + the current compilation (*note Search Paths and the Run-Time + Library (RTL)::). + + `/NOCURRENT_DIRECTORY' + Except for the source file named in the command line, do not look + for source files in the directory containing the source file named + in the command line (*note Search Paths and the Run-Time Library + (RTL)::). + + `/NOOPTIMIZE (default)' + `/OPTIMIZE[=(keyword[,...])]' + Selects the level of optimization for your program. The supported + keywords are as follows: + `ALL (default)' + Perform most optimizations, including those that be expensive. + + `NONE' + Do not do any optimizations. Same as `/NOOPTIMIZE'. + + `SOME' + Perform some optimizations, but omit ones that are costly. + + `DEVELOPMENT' + Same as `SOME'. + + `INLINING' + Full optimization, and also attempt automatic inlining of + small subprograms within a unit (*note Inlining of + Subprograms::). + + `UNROLL_LOOPS' + Try to unroll loops. This keyword may be specified together + with any keyword above other than `NONE'. Loop unrolling + usually, but not always, improves the performance of programs. + + `/RUNTIME_SYSTEM=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `GNAT MAKE' flag (see *Note Qualifiers + for GNAT MAKE::). + + `/ASM' + Used to cause the assembler source file to be generated, using + `.S' as the extension, instead of the object file. This may be + useful if you need to examine the generated assembly code. + + `/VERBOSE' + Show commands generated by the `GNAT COMPILE' driver. Normally + used only for debugging purposes or if you need to be sure what + version of the compiler you are executing. + + `/CHECKS=ASSERTIONS' + Assertions enabled. `Pragma Assert' and `pragma Debug' to be + activated. + + `-gnatA' + Avoid processing `GNAT.ADC'. If a GNAT.ADC file is present, it + will be ignored. + + `/WARNINGS=BRIEF' + Generate brief messages to `SYS$ERROR' even if verbose mode set. + + `/NOLOAD' + Check syntax and semantics only (no code generation attempted). + + `/COMPRESS_NAMES' + Compress debug information and external symbol name table entries. + + `/XDEBUG' + Output expanded source files for source level debugging. This + qualifier also suppress generation of cross-reference information + (see /XREF=SUPPRESS). + + `-gnatecPATH' + Specify a configuration pragma file. (see *Note The Configuration + Pragmas Files::) + + `-gnatemPATH' + Specify a mapping file. (see *Note Units to Sources Mapping + Files::) + + `/CHECKS=ELABORATION' + Full dynamic elaboration checks. + + `/REPORT_ERRORS=FULL' + Full errors. Multiple errors per line, all undefined references. + + `/UPPERCASE_EXTERNALS' + Externals names are folded to all uppercase. + + `/STYLE=GNAT' + Internal GNAT implementation mode. This should not be used for + applications programs, it is intended only for use by the compiler + and its run-time library. For documentation, see the GNAT sources. + + `/EXPAND_SOURCE' + List generated expanded code in source form. + + `/IDENTIFIER_CHARACTER_SET=C' + Identifier character set For details of the possible selections + for C, see *Note Character Set Control::. + + `/HELP' + Output usage information. The output is written to `SYS$OUTPUT'. + + `/FILE_NAME_MAX_LENGTH=N' + Limit file names to N (1-999) characters . + + `/LIST' + Output full source listing with embedded error messages. + + `/ERROR_LIMIT=N' + Limit number of detected errors to N (1-999). + + `/INLINE=PRAGMA' + Activate inlining across unit boundaries for subprograms for which + pragma `inline' is specified. + + `-gnatN' + Activate front end inlining. + + `/INLINE=SUPPRESS' + Suppresses all inlining, even if other optimization or inlining + qualifiers are set. + + `/CHECKS=OVERFLOW' + Enable numeric overflow checking (which is not normally enabled by + default). Not that division by zero is a separate check that is not + controlled by this qualifier (division by zero checking is on by + default). + + `/CHECKS=SUPPRESS_ALL' + Suppress all checks. + + `/TRY_SEMANTICS' + Don't quit; try semantics, even if parse errors. + + `/FORCE_ALI' + Don't quit; generate `ali' and tree files even if illegalities. + + `/POLLING_ENABLE' + Enable polling. This is required on some systems (notably Windows + NT) to obtain asynchronous abort and asynchronous transfer of + control capability. See the description of pragma Polling in the + GNAT Reference Manual for full details. + + `/REPRESENTATION_INFO[0/1/2/3][s]' + Output representation information for declared types and objects. + + `/SYNTAX_ONLY' + Syntax check only. + + `/TREE_OUTPUT' + Tree output file to be generated. + + `-gnatT nnn' + Set time slice to specified number of microseconds + + `/UNITS_LIST' + List units for this compilation. + + `/UNIQUE_ERROR_TAG' + Tag all error messages with the unique string "error:" + + `/REPORT_ERRORS=VERBOSE' + Verbose mode. Full error output with source lines to `SYS$OUTPUT'. + + `/VALIDITY_CHECKING' + Control level of validity checking. See separate section describing + this feature. + + `/WARNINGS=XXX' + Warning mode where XXX is a string of options describing the exact + warnings that are enabled or disabled. See separate section on + warning control. + + `/WIDE_CHARACTER_ENCODING=E' + Wide character encoding method (E=`BRACKETS, NONE, HEX, UPPER, + SHIFT_JIS, EUC, UTF8') + + `/XREF=SUPPRESS' + Suppress generation of cross-reference information. + + `/STYLE_CHECKS=(option,option..)' + Enable built-in style checks. See separate section describing this + feature. + + `/DISTRIBUTION_STUBS=M' + Distribution stub generation and compilation (M=`RECEIVER' or + `CALLER' to specify the type of stubs to be generated and + compiled). + + `/83' + Enforce Ada 83 restrictions. + + The following restrictions apply to the combination of qualifiers in + this manner: + + * The qualifier `/NOLOAD' if combined with other qualifiers must come + first in the string. + + * The qualifier `/SYNTAX_ONLY' if combined with other qualifiers + must come first in the string. + + * Once a "y" appears in the string (that is a use of the `/STYLE=' + qualifier), then all further characters in the qualifier are + interpreted as style modifiers (see description of `/STYLE='). + + * Once a "d" appears in the string (that is a use of the `-gnatd' + qualifier), then all further characters in the qualifier are + interpreted as debug flags (see description of `-gnatd'). + + * Once a "w" appears in the string (that is a use of the `-gnatw' + qualifier), then all further characters in the qualifier are + interpreted as warning mode modifiers (see description of + `-gnatw'). + + * Once a "V" appears in the string (that is a use of the + `/VALIDITY_CHECKING' qualifier), then all further characters in + the qualifier are interpreted as validity checking options (see + description of `/VALIDITY_CHECKING'). + + +  + File: gnat_ug_vms.info, Node: Output and Error Message Control, Next: Debugging and Assertion Control, Up: Qualifiers for GNAT COMPILE + + Output and Error Message Control + -------------------------------- + + The standard default format for error messages is called "brief format." + Brief format messages are written to `SYS$ERROR' (the standard error + file) and have the following form: + + E.ADB:3:04: Incorrect spelling of keyword "function" + E.ADB:4:20: ";" should be "is" + + The first integer after the file name is the line number in the file, + and the second integer is the column number within the line. `glide' + can parse the error messages and point to the referenced character. + The following qualifiers provide control over the error message format: + + `/REPORT_ERRORS=VERBOSE' + The effect of this setting is to write long-format error messages + to `SYS$OUTPUT' (the standard output file. The same program + compiled with the `/REPORT_ERRORS=VERBOSE' qualifier would + generate: + + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + + The vertical bar indicates the location of the error, and the `>>>' + prefix can be used to search for error messages. When this + qualifier is used the only source lines output are those with + errors. + + `/LIST' + This qualifier causes a full listing of the file to be generated. + The output might look as follows: + + 1. procedure E is + 2. V : Integer; + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + 5. begin + 6. return Q + Q; + 7. end; + 8. begin + 9. V := X + X; + 10.end E; + + When you specify the `/REPORT_ERRORS=VERBOSE' or `/LIST' + qualifiers and standard output is redirected, a brief summary is + written to `SYS$ERROR' (standard error) giving the number of error + messages and warning messages generated. + + `/UNIQUE_ERROR_TAG' + This qualifier forces all error messages to be preceded by the + unique string "error:". This means that error messages take a few + more characters in space, but allows easy searching for and + identification of error messages. + + `/WARNINGS=BRIEF' + This qualifier causes GNAT to generate the brief format error + messages to `SYS$ERROR' (the standard error file) as well as the + verbose format message or full listing (which as usual is written + to `SYS$OUTPUT' (the standard output file). + + `/ERROR_LIMIT=N' + N is a decimal integer in the range of 1 to 999 and limits the + number of error messages to be generated. For example, using + `/ERROR_LIMIT=2' might yield + + E.ADB:3:04: Incorrect spelling of keyword "function" + E.ADB:5:35: missing ".." + fatal error: maximum errors reached + compilation abandoned + + `/REPORT_ERRORS=FULL' + Normally, the compiler suppresses error messages that are likely + to be redundant. This qualifier causes all error messages to be + generated. In particular, in the case of references to undefined + variables. If a given variable is referenced several times, the + normal format of messages is + E.ADB:7:07: "V" is undefined (more references follow) + + where the parenthetical comment warns that there are additional + references to the variable `V'. Compiling the same program with the + `/REPORT_ERRORS=FULL' qualifier yields + + E.ADB:7:07: "V" is undefined + E.ADB:8:07: "V" is undefined + E.ADB:8:12: "V" is undefined + E.ADB:8:16: "V" is undefined + E.ADB:9:07: "V" is undefined + E.ADB:9:12: "V" is undefined + + `/TRY_SEMANTICS' + In normal operation mode, the compiler first parses the program and + determines if there are any syntax errors. If there are, + appropriate error messages are generated and compilation is + immediately terminated. This qualifier tells GNAT to continue + with semantic analysis even if syntax errors have been found. This + may enable the detection of more errors in a single run. On the + other hand, the semantic analyzer is more likely to encounter some + internal fatal error when given a syntactically invalid tree. + + `/FORCE_ALI' + In normal operation mode, the `ali' file is not generated if any + illegalities are detected in the program. The use of `/FORCE_ALI' + forces generation of the `ali' file. This file is marked as being + in error, so it cannot be used for binding purposes, but it does + contain reasonably complete cross-reference information, and thus + may be useful for use by tools (e.g. semantic browsing tools or + integrated development environments) that are driven from the + `ali' file. + + In addition, if `/TREE_OUTPUT' is also specified, then the tree + file is generated even if there are illegalities. It may be useful + in this case to also specify `/TRY_SEMANTICS' to ensure that full + semantic processing occurs. The resulting tree file can be + processed by ASIS, for the purpose of providing partial + information about illegal units, but if the error causes the tree + to be badly malformed, then ASIS may crash during the analysis. + + In addition to error messages, which correspond to illegalities as + defined in the Ada 95 Reference Manual, the compiler detects two kinds + of warning situations. + + First, the compiler considers some constructs suspicious and + generates a warning message to alert you to a possible error. Second, + if the compiler detects a situation that is sure to raise an exception + at run time, it generates a warning message. The following shows an + example of warning messages: + E.ADB:4:24: warning: creation of object may raise Storage_Error + E.ADB:10:17: warning: static value out of range + E.ADB:10:17: warning: "Constraint_Error" will be raised at run time + + GNAT considers a large number of situations as appropriate for the + generation of warning messages. As always, warnings are not definite + indications of errors. For example, if you do an out-of-range + assignment with the deliberate intention of raising a + `Constraint_Error' exception, then the warning that may be issued does + not indicate an error. Some of the situations for which GNAT issues + warnings (at least some of the time) are given in the following list, + which is not necessarily complete. + + * Possible infinitely recursive calls + + * Out-of-range values being assigned + + * Possible order of elaboration problems + + * Unreachable code + + * Fixed-point type declarations with a null range + + * Variables that are never assigned a value + + * Variables that are referenced before being initialized + + * Task entries with no corresponding accept statement + + * Duplicate accepts for the same task entry in a select + + * Objects that take too much storage + + * Unchecked conversion between types of differing sizes + + * Missing return statements along some execution paths in a function + + * Incorrect (unrecognized) pragmas + + * Incorrect external names + + * Allocation from empty storage pool + + * Potentially blocking operations in protected types + + * Suspicious parenthesization of expressions + + * Mismatching bounds in an aggregate + + * Attempt to return local value by reference + + * Unrecognized pragmas + + * Premature instantiation of a generic body + + * Attempt to pack aliased components + + * Out of bounds array subscripts + + * Wrong length on string assignment + + * Violations of style rules if style checking is enabled + + * Unused with clauses + + * Bit_Order usage that does not have any effect + + * Compile time biased rounding of floating-point constant + + * Standard.Duration used to resolve universal fixed expression + + * Dereference of possibly null value + + * Declaration that is likely to cause storage error + + * Internal GNAT unit with'ed by application unit + + * Values known to be out of range at compile time + + * Unreferenced labels and variables + + * Address overlays that could clobber memory + + * Unexpected initialization when address clause present + + * Bad alignment for address clause + + * Useless type conversions + + * Redundant assignment statements + + * Accidental hiding of name by child unit + + * Unreachable code + + * Access before elaboration detected at compile time + + * A range in a `for' loop that is known to be null or might be null + + + The following qualifiers are available to control the handling of + warning messages: + + `/WARNINGS=OPTIONAL (activate all optional errors)' + This qualifier activates most optional warning messages, see + remaining list in this section for details on optional warning + messages that can be individually controlled. The warnings that + are not turned on by this qualifier are + `/WARNINGS=BIASED_ROUNDING' (biased rounding), + `/WARNINGS=IMPLICIT_DEREFERENCE' (implicit dereferencing), and + `/WARNINGS=HIDING' (hiding). All other optional warnings are + turned on. + + `/WARNINGS=NOOPTIONAL (suppress all optional errors)' + This qualifier suppresses all optional warning messages, see + remaining list in this section for details on optional warning + messages that can be individually controlled. + + `/WARNINGS=BIASED_ROUNDING (activate warnings on biased rounding)' + If a static floating-point expression has a value that is exactly + half way between two adjacent machine numbers, then the rules of + Ada (Ada Reference Manual, section 4.9(38)) require that this + rounding be done away from zero, even if the normal unbiased + rounding rules at run time would require rounding towards zero. + This warning message alerts you to such instances where + compile-time rounding and run-time rounding are not equivalent. If + it is important to get proper run-time rounding, then you can + force this by making one of the operands into a variable. The + default is that such warnings are not generated. Note that + `/WARNINGS=OPTIONAL' does not affect the setting of this warning + option. + + `/WARNINGS=NOBIASED_ROUNDING (suppress warnings on biased rounding)' + This qualifier disables warnings on biased rounding. + + `/WARNINGS=CONDITIONALS (activate warnings on conditionals)' + This qualifier activates warnings for conditional expressions used + in tests that are known to be True or False at compile time. The + default is that such warnings are not generated. This warning can + also be turned on using `/WARNINGS=OPTIONAL'. + + `/WARNINGS=NOCONDITIONALS (suppress warnings on conditionals)' + This qualifier suppresses warnings for conditional expressions + used in tests that are known to be True or False at compile time. + + `/WARNINGS=IMPLICIT_DEREFERENCE (activate warnings on implicit dereferencing)' + If this qualifier is set, then the use of a prefix of an access + type in an indexed component, slice, or selected component without + an explicit `.all' will generate a warning. With this warning + enabled, access checks occur only at points where an explicit + `.all' appears in the source code (assuming no warnings are + generated as a result of this qualifier). The default is that such + warnings are not generated. Note that `/WARNINGS=OPTIONAL' does + not affect the setting of this warning option. + + `/WARNINGS=NOIMPLICIT_DEREFERENCE (suppress warnings on implicit dereferencing)' + This qualifier suppresses warnings for implicit deferences in + indexed components, slices, and selected components. + + `/WARNINGS=ERROR (treat warnings as errors)' + This qualifier causes warning messages to be treated as errors. + The warning string still appears, but the warning messages are + counted as errors, and prevent the generation of an object file. + + `/WARNINGS=UNREFERENCED_FORMALS (activate warnings on unreferenced formals)' + This qualifier causes a warning to be generated if a formal + parameter is not referenced in the body of the subprogram. This + warning can also be turned on using `/WARNINGS=OPTIONAL' or + `/WARNINGS=UNUSED'. + + `/WARNINGS=NOUNREFERENCED_FORMALS (suppress warnings on unreferenced formals)' + This qualifier suppresses warnings for unreferenced formal + parameters. Note that the combination `/WARNINGS=UNUSED' followed + by `/WARNINGS=NOUNREFERENCED_FORMALS' has the effect of warning on + unreferenced entities other than subprogram formals. + + `/WARNINGS=HIDING (activate warnings on hiding)' + This qualifier activates warnings on hiding declarations. A + declaration is considered hiding if it is for a non-overloadable + entity, and it declares an entity with the same name as some other + entity that is directly or use-visible. The default is that such + warnings are not generated. Note that `/WARNINGS=OPTIONAL' does + not affect the setting of this warning option. + + `/WARNINGS=NOHIDING (suppress warnings on hiding)' + This qualifier suppresses warnings on hiding declarations. + + `/WARNINGS=IMPLEMENTATION (activate warnings on implementation units).' + This qualifier activates warnings for a `with' of an internal GNAT + implementation unit, defined as any unit from the `Ada', + `Interfaces', `GNAT', `DEC', or `System' hierarchies that is not + documented in either the Ada Reference Manual or the GNAT + Programmer's Reference Manual. Such units are intended only for + internal implementation purposes and should not be `with''ed by + user programs. The default is that such warnings are generated + This warning can also be turned on using `/WARNINGS=OPTIONAL'. + + `/WARNINGS=NOIMPLEMENTATION (disable warnings on implementation units).' + This qualifier disables warnings for a `with' of an internal GNAT + implementation unit. + + `/WARNINGS=ELABORATION (activate warnings on elaboration pragmas)' + This qualifier activates warnings on missing pragma Elaborate_All + statements. See the section in this guide on elaboration checking + for details on when such pragma should be used. The default is + that such warnings are not generated. This warning can also be + turned on using `/WARNINGS=OPTIONAL'. + + `/WARNINGS=NOELABORATION (suppress warnings on elaboration pragmas)' + This qualifier suppresses warnings on missing pragma Elaborate_All + statements. See the section in this guide on elaboration checking + for details on when such pragma should be used. + + `/WARNINGS=OVERLAYS (activate warnings on address clause overlays)' + This qualifier activates warnings for possibly unintended + initialization effects of defining address clauses that cause one + variable to overlap another. The default is that such warnings are + generated. This warning can also be turned on using + `/WARNINGS=OPTIONAL'. + + `/WARNINGS=NOOVERLAYS (suppress warnings on address clause overlays)' + This qualifier suppresses warnings on possibly unintended + initialization effects of defining address clauses that cause one + variable to overlap another. + + `-gnatwp (activate warnings on ineffective pragma Inlines)' + This qualifier activates warnings for failure of front end inlining + (activated by `-gnatN') to inline a particular call. There are + many reasons for not being able to inline a call, including most + commonly that the call is too complex to inline. This warning can + also be turned on using `/WARNINGS=OPTIONAL'. + + `-gnatwP (suppress warnings on ineffective pragma Inlines)' + This qualifier suppresses warnings on ineffective pragma Inlines. + If the inlining mechanism cannot inline a call, it will simply + ignore the request silently. + + `/WARNINGS=REDUNDANT (activate warnings on redundant constructs)' + This qualifier activates warnings for redundant constructs. The + following is the current list of constructs regarded as redundant: + This warning can also be turned on using `/WARNINGS=OPTIONAL'. + + * Assignment of an item to itself. + + * Type conversion that converts an expression to its own type. + + * Use of the attribute `Base' where `typ'Base' is the same as + `typ'. + + * Use of pragma `Pack' when all components are placed by a + record representation clause. + + `/WARNINGS=NOREDUNDANT (suppress warnings on redundant constructs)' + This qualifier suppresses warnings for redundant constructs. + + `/WARNINGS=SUPPRESS (suppress all warnings)' + This qualifier completely suppresses the output of all warning + messages from the GNAT front end. Note that it does not suppress + warnings from the `GNAT COMPILE' back end. To suppress these back + end warnings as well, use the qualifier `-w' in addition to + `/WARNINGS=SUPPRESS'. + + `/WARNINGS=UNUSED (activate warnings on unused entities)' + This qualifier activates warnings to be generated for entities that + are defined but not referenced, and for units that are `with''ed + and not referenced. In the case of packages, a warning is also + generated if no entities in the package are referenced. This means + that if the package is referenced but the only references are in + `use' clauses or `renames' declarations, a warning is still + generated. A warning is also generated for a generic package that + is `with''ed but never instantiated. In the case where a package + or subprogram body is compiled, and there is a `with' on the + corresponding spec that is only referenced in the body, a warning + is also generated, noting that the `with' can be moved to the + body. The default is that such warnings are not generated. This + qualifier also activates warnings on unreferenced formals (it is + includes the effect of `/WARNINGS=UNREFERENCED_FORMALS'). This + warning can also be turned on using `/WARNINGS=OPTIONAL'. + + `/WARNINGS=NOUNUSED (suppress warnings on unused entities)' + This qualifier suppresses warnings for unused entities and + packages. It also turns off warnings on unreferenced formals (and + thus includes the effect of `/WARNINGS=NOUNREFERENCED_FORMALS'). + + A string of warning parameters can be used in the same parameter. + For example: + + -gnatwaLe + + Would turn on all optional warnings except for elaboration pragma + warnings, and also specify that warnings should be treated as + errors. + + `-w' + This qualifier suppresses warnings from the `GNAT COMPILE' + backend. It may be used in conjunction with `/WARNINGS=SUPPRESS' + to ensure that all warnings are suppressed during the entire + compilation process. + +  + File: gnat_ug_vms.info, Node: Debugging and Assertion Control, Next: Run-Time Checks, Prev: Output and Error Message Control, Up: Qualifiers for GNAT COMPILE + + Debugging and Assertion Control + ------------------------------- + + `/CHECKS=ASSERTIONS' + The pragmas `Assert' and `Debug' normally have no effect and are + ignored. This qualifier, where `a' stands for assert, causes + `Assert' and `Debug' pragmas to be activated. + + The pragmas have the form: + + pragma Assert (BOOLEAN-EXPRESSION [, + STATIC-STRING-EXPRESSION]) + pragma Debug (PROCEDURE CALL) + + The `Assert' pragma causes BOOLEAN-EXPRESSION to be tested. If + the result is `True', the pragma has no effect (other than + possible side effects from evaluating the expression). If the + result is `False', the exception `Assert_Failure' declared in the + package `System.Assertions' is raised (passing + STATIC-STRING-EXPRESSION, if present, as the message associated + with the exception). If no string expression is given the default + is a string giving the file name and line number of the pragma. + + The `Debug' pragma causes PROCEDURE to be called. Note that + `pragma Debug' may appear within a declaration sequence, allowing + debugging procedures to be called between declarations. + + `/DEBUG[=debug-level]' + `/NODEBUG' + Specifies how much debugging information is to be included in the + resulting object file where 'debug-level' is one of the following: + `TRACEBACK (default)' + Include both debugger symbol records and traceback the object + file. + + `ALL' + Include both debugger symbol records and traceback in object + file. + + `NONE' + Excludes both debugger symbol records and traceback the + object file. Same as /NODEBUG. + + `SYMBOLS' + Includes only debugger symbol records in the object file. + Note that this doesn't include traceback information. + +  + File: gnat_ug_vms.info, Node: Validity Checking, Next: Style Checking, Prev: Run-Time Control, Up: Qualifiers for GNAT COMPILE + + Validity Checking + ----------------- + + The Ada 95 Reference Manual has specific requirements for checking for + invalid values. In particular, RM 13.9.1 requires that the evaluation + of invalid values (for example from unchecked conversions), not result + in erroneous execution. In GNAT, the result of such an evaluation in + normal default mode is to either use the value unmodified, or to raise + Constraint_Error in those cases where use of the unmodified value would + cause erroneous execution. The cases where unmodified values might lead + to erroneous execution are case statements (where a wild jump might + result from an invalid value), and subscripts on the left hand side + (where memory corruption could occur as a result of an invalid value). + + The `-gnatVx' qualifier allows more control over the validity + checking mode. The `x' argument here is a string of letters which + control which validity checks are performed in addition to the default + checks described above. + + * `-gnatVc' Validity checks for copies + + The right hand side of assignments, and the initializing values of + object declarations are validity checked. + + * `/VALIDITY_CHECKING=RM' Default (RM) validity checks + + Some validity checks are done by default following normal Ada + semantics (RM 13.9.1 (9-11)). A check is done in case statements + that the expression is within the range of the subtype. If it is + not, Constraint_Error is raised. For assignments to array + components, a check is done that the expression used as index is + within the range. If it is not, Constraint_Error is raised. Both + these validity checks may be turned off using qualifier `-gnatVD'. + They are turned on by default. If `-gnatVD' is specified, a + subsequent qualifier `/VALIDITY_CHECKING=RM' will leave the checks + turned on. Qualifier `-gnatVD' should be used only if you are + sure that all such expressions have valid values. If you use this + qualifier and invalid values are present, then the program is + erroneous, and wild jumps or memory overwriting may occur. + + * `-gnatVi' Validity checks for `in' mode parameters + + Arguments for parameters of mode `in' are validity checked in + function and procedure calls at the point of call. + + * `-gnatVm' Validity checks for `in out' mode parameters + + Arguments for parameters of mode `in out' are validity checked in + procedure calls at the point of call. The `'m'' here stands for + modify, since this concerns parameters that can be modified by the + call. Note that there is no specific option to test `out' + parameters, but any reference within the subprogram will be tested + in the usual manner, and if an invalid value is copied back, any + reference to it will be subject to validity checking. + + * `-gnatVo' Validity checks for operator and attribute operands + + Arguments for predefined operators and attributes are validity + checked. This includes all operators in package `Standard', the + shift operators defined as intrinsic in package `Interfaces' and + operands for attributes such as `Pos'. + + * `-gnatVr' Validity checks for function returns + + The expression in `return' statements in functions is validity + checked. + + * `-gnatVs' Validity checks for subscripts + + All subscripts expressions are checked for validity, whether they + appear on the right side or left side (in default mode only left + side subscripts are validity checked). + + * `-gnatVt' Validity checks for tests + + Expressions used as conditions in `if', `while' or `exit' + statements are checked, as well as guard expressions in entry + calls. + + * `/VALIDITY_CHECKING=FULL' Validity checks for floating-point values + + In the absence of this qualifier, validity checking occurs only + for discrete values. If `/VALIDITY_CHECKING=FULL' is specified, + then validity checking also applies for floating-point values, and + NaN's and infinities are considered invalid, as well as out of + range values for constrained types. Note that this means that + standard `IEEE' infinity mode is not allowed. The exact contexts + in which floating-point values are checked depends on the setting + of other options. For example `-gnatVif' or `-gnatVfi' (the order + does not matter) specifies that floating-point parameters of mode + `in' should be validity checked. + + * `-gnatVa' All validity checks + + All the above validity checks are turned on. That is `-gnatVa' is + equivalent to `gnatVcdfimorst'. + + * `-gnatVn' No validity checks + + This qualifier turns off all validity checking, including the + default checking for case statements and left hand side + subscripts. Note that the use of the qualifier + `/CHECKS=SUPPRESS_ALL' supresses all run-time checks, including + validity checks, and thus implies `-gnatVn'. + + + The `/VALIDITY_CHECKING' qualifier may be followed by a string of + letters to turn on a series of validity checking options. For example, + `-gnatVcr' specifies that in addition to the default validity checking, + copies and function return expressions be validity checked. In order to + make it easier to specify a set of options, the upper case letters + `CDFIMORST' may be used to turn off the corresponding lower case + option, so for example `-gnatVaM' turns on all validity checking + options except for checking of `in out' procedure arguments. + + The specification of additional validity checking generates extra + code (and in the case of `-gnatva' the code expansion can be + substantial. However, these additional checks can be very useful in + smoking out cases of uninitialized variables, incorrect use of + unchecked conversion, and other errors leading to invalid values. The + use of pragma `Initialize_Scalars' is useful in conjunction with the + extra validity checking, since this ensures that wherever possible + uninitialized variables have invalid values. + + See also the pragma `Validity_Checks' which allows modification of + the validity checking mode at the program source level, and also allows + for temporary disabling of validity checks. + +  + File: gnat_ug_vms.info, Node: Style Checking, Next: Using GNAT COMPILE for Syntax Checking, Prev: Validity Checking, Up: Qualifiers for GNAT COMPILE + + Style Checking + -------------- + + The /STYLE=(OPTION,OPTION,..) qualifier causes the compiler to enforce + specified style rules. A limited set of style rules has been used in + writing the GNAT sources themselves. This qualifier allows user programs + to activate all or some of these checks. If the source program fails a + specified style check, an appropriate warning message is given, + preceded by the character sequence "(style)". (OPTION,OPTION,..) is a + sequence of keywords indicating the particular style checks to be + performed. The following checks are defined: + + `1-9 (specify indentation level)' + If a digit from 1-9 appears in the string after `/STYLE=' then + proper indentation is checked, with the digit indicating the + indentation level required. The general style of required + indentation is as specified by the examples in the Ada Reference + Manual. Full line comments must be aligned with the `--' starting + on a column that is a multiple of the alignment level. + + `ATTRIBUTE (check attribute casing)' + If the word ATTRIBUTE appears in the string after `/STYLE=' then + attribute names, including the case of keywords such as `digits' + used as attributes names, must be written in mixed case, that is, + the initial letter and any letter following an underscore must be + uppercase. All other letters must be lowercase. + + `BLANKS (blanks not allowed at statement end)' + If the word BLANKS appears in the string after `/STYLE=' then + trailing blanks are not allowed at the end of statements. The + purpose of this rule, together with h (no horizontal tabs), is to + enforce a canonical format for the use of blanks to separate + source tokens. + + `COMMENTS (check comments)' + If the word COMMENTS appears in the string after `/STYLE=' then + comments must meet the following set of rules: + + * The "-" that starts the column must either start in column + one, or else at least one blank must precede this sequence. + + * Comments that follow other tokens on a line must have at + least one blank following the "-" at the start of the comment. + + * Full line comments must have two blanks following the "-" + that starts the comment, with the following exceptions. + + * A line consisting only of the "-" characters, possibly + preceded by blanks is permitted. + + * A comment starting with "-x" where x is a special character + is permitted. This alows proper processing of the output + generated by specialized tools including `GNAT PREPROCESS' + (where -! is used) and the SPARK annnotation language (where + -# is used). For the purposes of this rule, a special + character is defined as being in one of the ASCII ranges + 16#21#..16#2F# or 16#3A#..16#3F#. + + * A line consisting entirely of minus signs, possibly preceded + by blanks, is permitted. This allows the construction of box + comments where lines of minus signs are used to form the top + and bottom of the box. + + * If a comment starts and ends with "-" is permitted as long as + at least one blank follows the initial "-". Together with the + preceding rule, this allows the construction of box comments, + as shown in the following example: + --------------------------- + -- This is a box comment -- + -- with two text lines. -- + --------------------------- + + `END (check end/exit labels)' + If the word END appears in the string after `/STYLE=' then + optional labels on `end' statements ending subprograms and on + `exit' statements exiting named loops, are required to be present. + + `VTABS (no form feeds or vertical tabs)' + If the word VTABS appears in the string after `/STYLE=' then + neither form feeds nor vertical tab characters are not permitted + in the source text. + + `HTABS (no horizontal tabs)' + If the word HTABS appears in the string after `/STYLE=' then + horizontal tab characters are not permitted in the source text. + Together with the b (no blanks at end of line) check, this + enforces a canonical form for the use of blanks to separate source + tokens. + + `IF_THEN (check if-then layout)' + If the word IF_THEN appears in the string after `/STYLE=', then + the keyword `then' must appear either on the same line as + corresponding `if', or on a line on its own, lined up under the + `if' with at least one non-blank line in between containing all or + part of the condition to be tested. + + `KEYWORD (check keyword casing)' + If the word KEYWORD appears in the string after `/STYLE=' then all + keywords must be in lower case (with the exception of keywords + such as `digits' used as attribute names to which this check does + not apply). + + `LAYOUT (check layout)' + If the word LAYOUT appears in the string after `/STYLE=' then + layout of statement and declaration constructs must follow the + recommendations in the Ada Reference Manual, as indicated by the + form of the syntax rules. For example an `else' keyword must be + lined up with the corresponding `if' keyword. + + There are two respects in which the style rule enforced by this + check option are more liberal than those in the Ada Reference + Manual. First in the case of record declarations, it is + permissible to put the `record' keyword on the same line as the + `type' keyword, and then the `end' in `end record' must line up + under `type'. For example, either of the following two layouts is + acceptable: + + type q is record + a : integer; + b : integer; + end record; + + type q is + record + a : integer; + b : integer; + end record; + + Second, in the case of a block statement, a permitted alternative + is to put the block label on the same line as the `declare' or + `begin' keyword, and then line the `end' keyword up under the + block label. For example both the following are permitted: + + Block : declare + A : Integer := 3; + begin + Proc (A, A); + end Block; + + Block : + declare + A : Integer := 3; + begin + Proc (A, A); + end Block; + + The same alternative format is allowed for loops. For example, + both of the following are permitted: + + Clear : while J < 10 loop + A (J) := 0; + end loop Clear; + + Clear : + while J < 10 loop + A (J) := 0; + end loop Clear; + + `LINE_LENGTH (check maximum line length)' + If the word LINE_LENGTH appears in the string after `/STYLE=' then + the length of source lines must not exceed 79 characters, including + any trailing blanks. The value of 79 allows convenient display on + an 80 character wide device or window, allowing for possible + special treatment of 80 character lines. + + `MAX_LENGTH=nnn (set maximum line length)' + If the sequence MAX_LENGTH=nnn, where nnn is a decimal number, + appears in the string after `/STYLE=' then the length of lines + must not exceed the given value. + + `STANDARD_CASING (check casing of entities in Standard)' + If the word STANDARD_CASING appears in the string after `/STYLE=' + then any identifier from Standard must be cased to match the + presentation in the Ada Reference Manual (for example, `Integer' + and `ASCII.NUL'). + + `ORDERED_SUBPROGRAMS (check order of subprogram bodies)' + If the word ORDERED_SUBPROGRAMS appears in the string after + `/STYLE=' then all subprogram bodies in a given scope (e.g. a + package body) must be in alphabetical order. The ordering rule + uses normal Ada rules for comparing strings, ignoring casing of + letters, except that if there is a trailing numeric suffix, then + the value of this suffix is used in the ordering (e.g. Junk2 comes + before Junk10). + + `PRAGMA (check pragma casing)' + If the word PRAGMA appears in the string after `/STYLE=' then + pragma names must be written in mixed case, that is, the initial + letter and any letter following an underscore must be uppercase. + All other letters must be lowercase. + + `REFERENCES (check references)' + If the word REFERENCES appears in the string after `/STYLE=' then + all identifier references must be cased in the same way as the + corresponding declaration. No specific casing style is imposed on + identifiers. The only requirement is for consistency of references + with declarations. + + `SPECS (check separate specs)' + If the word SPECS appears in the string after `/STYLE=' then + separate declarations ("specs") are required for subprograms (a + body is not allowed to serve as its own declaration). The only + exception is that parameterless library level procedures are not + required to have a separate declaration. This exception covers the + most frequent form of main program procedures. + + `TOKEN (check token spacing)' + If the word TOKEN appears in the string after `/STYLE=' then the + following token spacing rules are enforced: + + * The keywords `abs' and `not' must be followed by a space. + + * The token `=>' must be surrounded by spaces. + + * The token `<>' must be preceded by a space or a left + parenthesis. + + * Binary operators other than `**' must be surrounded by spaces. + There is no restriction on the layout of the `**' binary + operator. + + * Colon must be surrounded by spaces. + + * Colon-equal (assignment) must be surrounded by spaces. + + * Comma must be the first non-blank character on the line, or be + immediately preceded by a non-blank character, and must be + followed by a space. + + * If the token preceding a left paren ends with a letter or + digit, then a space must separate the two tokens. + + * A right parenthesis must either be the first non-blank + character on a line, or it must be preceded by a non-blank + character. + + * A semicolon must not be preceded by a space, and must not be + followed by a non-blank character. + + * A unary plus or minus may not be followed by a space. + + * A vertical bar must be surrounded by spaces. + + In the above rules, appearing in column one is always permitted, + that is, counts as meeting either a requirement for a required + preceding space, or as meeting a requirement for no preceding + space. + + Appearing at the end of a line is also always permitted, that is, + counts as meeting either a requirement for a following space, or + as meeting a requirement for no following space. + + If any of these style rules is violated, a message is generated giving + details on the violation. The initial characters of such messages are + always "(style)". Note that these messages are treated as warning + messages, so they normally do not prevent the generation of an object + file. The `/WARNINGS=ERROR' qualifier can be used to treat warning + messages, including style messages, as fatal errors. + + The qualifier /STYLE_CHECKS=ALL_BUILTIN is equivalent to all checking + options enabled with the exception of ORDERED_SUBPROGRAMS, with an + indentation level of 3. This is the standard checking option that is + used for the GNAT sources. + +  + File: gnat_ug_vms.info, Node: Run-Time Checks, Next: Stack Overflow Checking, Prev: Debugging and Assertion Control, Up: Qualifiers for GNAT COMPILE + + Run-Time Checks + --------------- + + If you compile with the default options, GNAT will insert many run-time + checks into the compiled code, including code that performs range + checking against constraints, but not arithmetic overflow checking for + integer operations (including division by zero) or checks for access + before elaboration on subprogram calls. All other run-time checks, as + required by the Ada 95 Reference Manual, are generated by default. The + following `GNAT COMPILE' qualifiers refine this default behavior: + + `/CHECKS=SUPPRESS_ALL' + Suppress all run-time checks as though `pragma Suppress + (all_checks') had been present in the source. Validity checks are + also suppressed (in other words `/CHECKS=SUPPRESS_ALL' also + implies `-gnatVn'. Use this qualifier to improve the performance + of the code at the expense of safety in the presence of invalid + data or program bugs. + + `/CHECKS=OVERFLOW' + Enables overflow checking for integer operations. This causes + GNAT to generate slower and larger executable programs by adding + code to check for overflow (resulting in raising + `Constraint_Error' as required by standard Ada semantics). These + overflow checks correspond to situations in which the true value + of the result of an operation may be outside the base range of the + result type. The following example shows the distinction: + + X1 : Integer := Integer'Last; + X2 : Integer range 1 .. 5 := 5; + ... + X1 := X1 + 1; -- `/CHECKS=OVERFLOW' required to catch the Constraint_Error + X2 := X2 + 1; -- range check, `/CHECKS=OVERFLOW' has no effect here + + Here the first addition results in a value that is outside the + base range of Integer, and hence requires an overflow check for + detection of the constraint error. The second increment operation + results in a violation of the explicit range constraint, and such + range checks are always performed. Basically the compiler can + assume that in the absence of the `/CHECKS=OVERFLOW' qualifier + that any value of type `xxx' is in range of the base type of `xxx'. + + Note that the `/CHECKS=OVERFLOW' qualifier does not affect the + code generated for any floating-point operations; it applies only + to integer semantics). For floating-point, GNAT has the + `Machine_Overflows' attribute set to `False' and the normal mode + of operation is to generate IEEE NaN and infinite values on + overflow or invalid operations (such as dividing 0.0 by 0.0). + + The reason that we distinguish overflow checking from other kinds + of range constraint checking is that a failure of an overflow + check can generate an incorrect value, but cannot cause erroneous + behavior. This is unlike the situation with a constraint check on + an array subscript, where failure to perform the check can result + in random memory description, or the range check on a case + statement, where failure to perform the check can cause a wild + jump. + + Note again that `/CHECKS=OVERFLOW' is off by default, so overflow + checking is not performed in default mode. This means that out of + the box, with the default settings, GNAT does not do all the + checks expected from the language description in the Ada Reference + Manual. If you want all constraint checks to be performed, as + described in this Manual, then you must explicitly use the + /CHECKS=OVERFLOW qualifier either on the `GNAT MAKE' or `GNAT + COMPILE' command. + + `/CHECKS=ELABORATION' + Enables dynamic checks for access-before-elaboration on subprogram + calls and generic instantiations. For full details of the effect + and use of this qualifier, *Note Compiling Using GNAT COMPILE::. + + The setting of these qualifiers only controls the default setting of the + checks. You may modify them using either `Suppress' (to remove checks) + or `Unsuppress' (to add back suppressed checks) pragmas in the program + source. + +  + File: gnat_ug_vms.info, Node: Stack Overflow Checking, Next: Run-Time Control, Prev: Run-Time Checks, Up: Qualifiers for GNAT COMPILE + + Stack Overflow Checking + ----------------------- + + For most operating systems, `GNAT COMPILE' does not perform stack + overflow checking by default. This means that if the main environment + task or some other task exceeds the available stack space, then + unpredictable behavior will occur. + + To activate stack checking, compile all units with the GNAT COMPILE + option `-fstack-check'. For example: + + GNAT COMPILE -fstack-check PACKAGE1.ADB + + Units compiled with this option will generate extra instructions to + check that any use of the stack (for procedure calls or for declaring + local variables in declare blocks) do not exceed the available stack + space. If the space is exceeded, then a `Storage_Error' exception is + raised. + + For declared tasks, the stack size is always controlled by the size + given in an applicable `Storage_Size' pragma (or is set to the default + size if no pragma is used. + + For the environment task, the stack size depends on system defaults + and is unknown to the compiler. The stack may even dynamically grow on + some systems, precluding the normal Ada semantics for stack overflow. + In the worst case, unbounded stack usage, causes unbounded stack + expansion resulting in the system running out of virtual memory. + + The stack checking may still work correctly if a fixed size stack is + allocated, but this cannot be guaranteed. To ensure that a clean + exception is signalled for stack overflow, set the environment variable + `GNAT_STACK_LIMIT' to indicate the maximum stack area that can be used, + as in: + + SET GNAT_STACK_LIMIT 1600 + + The limit is given in kilobytes, so the above declaration would set the + stack limit of the environment task to 1.6 megabytes. Note that the + only purpose of this usage is to limit the amount of stack used by the + environment task. If it is necessary to increase the amount of stack + for the environment task, then this is an operating systems issue, and + must be addressed with the appropriate operating systems commands. + +  + File: gnat_ug_vms.info, Node: Run-Time Control, Next: Validity Checking, Prev: Stack Overflow Checking, Up: Qualifiers for GNAT COMPILE + + Run-Time Control + ---------------- + + `-gnatT nnn' + The `gnatT' qualifier can be used to specify the time-slicing value + to be used for task switching between equal priority tasks. The + value `nnn' is given in microseconds as a decimal integer. + + Setting the time-slicing value is only effective if the underlying + thread control system can accommodate time slicing. Check the + documentation of your operating system for details. Note that the + time-slicing value can also be set by use of pragma `Time_Slice' + or by use of the `t' qualifier in the GNAT BIND step. The pragma + overrides a command line argument if both are present, and the `t' + qualifier for GNAT BIND overrides both the pragma and the `GNAT + COMPILE' command line qualifier. + +  + File: gnat_ug_vms.info, Node: Using GNAT COMPILE for Syntax Checking, Next: Using GNAT COMPILE for Semantic Checking, Prev: Style Checking, Up: Qualifiers for GNAT COMPILE + + Using `GNAT COMPILE' for Syntax Checking + ---------------------------------------- + + `/SYNTAX_ONLY' + Run GNAT in syntax checking only mode. For example, the command + + $ GNAT COMPILE /SYNTAX_ONLY X.ADB + + compiles file `X.ADB' in syntax-check-only mode. You can check a + series of files in a single command . + + You may use other qualifiers in conjunction with `/SYNTAX_ONLY'. In + particular, `/LIST' and `/REPORT_ERRORS=VERBOSE' are useful to + control the format of any generated error messages. + + The output is simply the error messages, if any. No object file or + ALI file is generated by a syntax-only compilation. Also, no units + other than the one specified are accessed. For example, if a unit + `X' `with''s a unit `Y', compiling unit `X' in syntax check only + mode does not access the source file containing unit `Y'. + + Normally, GNAT allows only a single unit in a source file. + However, this restriction does not apply in syntax-check-only + mode, and it is possible to check a file containing multiple + compilation units concatenated together. This is primarily used by + the `GNAT CHOP' utility (*note Renaming Files Using GNAT CHOP::). + +  + File: gnat_ug_vms.info, Node: Using GNAT COMPILE for Semantic Checking, Next: Compiling Ada 83 Programs, Prev: Using GNAT COMPILE for Syntax Checking, Up: Qualifiers for GNAT COMPILE + + Using `GNAT COMPILE' for Semantic Checking + ------------------------------------------ + + `/NOLOAD' + Causes the compiler to operate in semantic check mode, with full + checking for all illegalities specified in the Ada 95 Reference + Manual, but without generation of any object code (no object file + is generated). + + Because dependent files must be accessed, you must follow the GNAT + semantic restrictions on file structuring to operate in this mode: + + * The needed source files must be accessible (*note Search + Paths and the Run-Time Library (RTL)::). + + * Each file must contain only one compilation unit. + + * The file name and unit name must match (*note File Naming + Rules::). + + The output consists of error messages as appropriate. No object + file is generated. An `ALI' file is generated for use in the + context of cross-reference tools, but this file is marked as not + being suitable for binding (since no object file is generated). + The checking corresponds exactly to the notion of legality in the + Ada 95 Reference Manual. + + Any unit can be compiled in semantics-checking-only mode, including + units that would not normally be compiled (subunits, and + specifications where a separate body is present). + +  + File: gnat_ug_vms.info, Node: Compiling Ada 83 Programs, Next: Character Set Control, Prev: Using GNAT COMPILE for Semantic Checking, Up: Qualifiers for GNAT COMPILE + + Compiling Ada 83 Programs + ------------------------- + + `/83' + Although GNAT is primarily an Ada 95 compiler, it accepts this + qualifier to specify that an Ada 83 program is to be compiled in + Ada83 mode. If you specify this qualifier, GNAT rejects most Ada + 95 extensions and applies Ada 83 semantics where this can be done + easily. It is not possible to guarantee this qualifier does a + perfect job; for example, some subtle tests, such as are found in + earlier ACVC tests (that have been removed from the ACVC suite for + Ada 95), may not compile correctly. However, for most purposes, + using this qualifier should help to ensure that programs that + compile correctly under the `/83' qualifier can be ported easily + to an Ada 83 compiler. This is the main use of the qualifier. + + With few exceptions (most notably the need to use `<>' on + unconstrained generic formal parameters, the use of the new Ada 95 + keywords, and the use of packages with optional bodies), it is not + necessary to use the `/83' qualifier when compiling Ada 83 + programs, because, with rare exceptions, Ada 95 is upwardly + compatible with Ada 83. This means that a correct Ada 83 program + is usually also a correct Ada 95 program. + +  + File: gnat_ug_vms.info, Node: Character Set Control, Next: File Naming Control, Prev: Compiling Ada 83 Programs, Up: Qualifiers for GNAT COMPILE + + Character Set Control + --------------------- + + `/IDENTIFIER_CHARACTER_SET=C' + Normally GNAT recognizes the Latin-1 character set in source + program identifiers, as described in the Ada 95 Reference Manual. + This qualifier causes GNAT to recognize alternate character sets + in identifiers. C is a single character or word indicating the + character set, as follows: + + `1' + Latin-1 identifiers + + `2' + Latin-2 letters allowed in identifiers + + `3' + Latin-3 letters allowed in identifiers + + `4' + Latin-4 letters allowed in identifiers + + `5' + Latin-5 (Cyrillic) letters allowed in identifiers + + `9' + Latin-9 letters allowed in identifiers + + `PC' + IBM PC letters (code page 437) allowed in identifiers + + `PC850' + IBM PC letters (code page 850) allowed in identifiers + + `FULL_UPPER' + Full upper-half codes allowed in identifiers + + `NO_UPPER' + No upper-half codes allowed in identifiers + + `WIDE' + Wide-character codes (that is, codes greater than 255) + allowed in identifiers + + *Note Foreign Language Representation::, for full details on the + implementation of these character sets. + + `/WIDE_CHARACTER_ENCODING=E' + Specify the method of encoding for wide characters. E is one of + the following: + + `HEX' + Hex encoding (brackets coding also recognized) + + `UPPER' + Upper half encoding (brackets encoding also recognized) + + `SHIFT_JIS' + Shift/JIS encoding (brackets encoding also recognized) + + `EUC' + EUC encoding (brackets encoding also recognized) + + `UTF8' + UTF-8 encoding (brackets encoding also recognized) + + `BRACKETS' + Brackets encoding only (default value) For full details on + the these encoding methods see *Note Wide Character Encodings::. + Note that brackets coding is always accepted, even if one of the + other options is specified, so for example + `/WIDE_CHARACTER_ENCODING=UTF8' specifies that both brackets and + `UTF-8' encodings will be recognized. The units that are with'ed + directly or indirectly will be scanned using the specified + representation scheme, and so if one of the non-brackets scheme is + used, it must be used consistently throughout the program. However, + since brackets encoding is always recognized, it may be + conveniently used in standard libraries, allowing these libraries + to be used with any of the available coding schemes. scheme. If + no `/WIDE_CHARACTER_ENCODING=?' parameter is present, then the + default representation is Brackets encoding only. + + Note that the wide character representation that is specified + (explicitly or by default) for the main program also acts as the + default encoding used for Wide_Text_IO files if not specifically + overridden by a WCEM form parameter. + +  + File: gnat_ug_vms.info, Node: File Naming Control, Next: Subprogram Inlining Control, Prev: Character Set Control, Up: Qualifiers for GNAT COMPILE + + File Naming Control + ------------------- + + `/FILE_NAME_MAX_LENGTH=N' + Activates file name "krunching". N, a decimal integer in the range + 1-999, indicates the maximum allowable length of a file name (not + including the `.ADS' or `.ADB' extension). The default is not to + enable file name krunching. + + For the source file naming rules, *Note File Naming Rules::. + +  + File: gnat_ug_vms.info, Node: Subprogram Inlining Control, Next: Auxiliary Output Control, Prev: File Naming Control, Up: Qualifiers for GNAT COMPILE + + Subprogram Inlining Control + --------------------------- + + `/INLINE=PRAGMA' + GNAT recognizes and processes `Inline' pragmas. However, for the + inlining to actually occur, optimization must be enabled. To enable + inlining across unit boundaries, this is, inlining a call in one + unit of a subprogram declared in a `with''ed unit, you must also + specify this qualifier. In the absence of this qualifier, GNAT + does not attempt inlining across units and does not need to access + the bodies of subprograms for which `pragma Inline' is specified + if they are not in the current unit. + + If you specify this qualifier the compiler will access these + bodies, creating an extra source dependency for the resulting + object file, and where possible, the call will be inlined. For + further details on when inlining is possible see *Note Inlining of + Subprograms::. + + `-gnatN' + The front end inlining activated by this qualifier is generally + more extensive, and quite often more effective than the standard + `/INLINE=PRAGMA' inlining mode. It will also generate additional + dependencies. + +  + File: gnat_ug_vms.info, Node: Auxiliary Output Control, Next: Debugging Control, Prev: Subprogram Inlining Control, Up: Qualifiers for GNAT COMPILE + + Auxiliary Output Control + ------------------------ + + `/TREE_OUTPUT' + Causes GNAT to write the internal tree for a unit to a file (with + the extension `.adt'. This not normally required, but is used by + separate analysis tools. Typically these tools do the necessary + compilations automatically, so you should not have to specify this + qualifier in normal operation. + + `/UNITS_LIST' + Print a list of units required by this compilation on `SYS$OUTPUT'. + The listing includes all units on which the unit being compiled + depends either directly or indirectly. + +  + File: gnat_ug_vms.info, Node: Debugging Control, Next: Units to Sources Mapping Files, Prev: Auxiliary Output Control, Up: Qualifiers for GNAT COMPILE + + Debugging Control + ----------------- + + `/EXPAND_SOURCE' + This qualifier causes the compiler to generate auxiliary output + containing a pseudo-source listing of the generated expanded code. + Like most Ada compilers, GNAT works by first transforming the high + level Ada code into lower level constructs. For example, tasking + operations are transformed into calls to the tasking run-time + routines. A unique capability of GNAT is to list this expanded + code in a form very close to normal Ada source. This is very + useful in understanding the implications of various Ada usage on + the efficiency of the generated code. There are many cases in Ada + (e.g. the use of controlled types), where simple Ada statements can + generate a lot of run-time code. By using `/EXPAND_SOURCE' you can + identify these cases, and consider whether it may be desirable to + modify the coding approach to improve efficiency. + + The format of the output is very similar to standard Ada source, + and is easily understood by an Ada programmer. The following + special syntactic additions correspond to low level features used + in the generated code that do not have any exact analogies in pure + Ada source form. The following is a partial list of these special + constructions. See the specification of package `Sprint' in file + `SPRINT.ADS' for a full list. + + `new XXX [storage_pool = YYY]' + Shows the storage pool being used for an allocator. + + `at end PROCEDURE-NAME;' + Shows the finalization (cleanup) procedure for a scope. + + `(if EXPR then EXPR else EXPR)' + Conditional expression equivalent to the `x?y:z' construction + in C. + + `TARGET^(SOURCE)' + A conversion with floating-point truncation instead of + rounding. + + `TARGET?(SOURCE)' + A conversion that bypasses normal Ada semantic checking. In + particular enumeration types and fixed-point types are + treated simply as integers. + + `TARGET?^(SOURCE)' + Combines the above two cases. + + `X #/ Y' + `X #mod Y' + `X #* Y' + `X #rem Y' + A division or multiplication of fixed-point values which are + treated as integers without any kind of scaling. + + `free EXPR [storage_pool = XXX]' + Shows the storage pool associated with a `free' statement. + + `freeze TYPENAME [ACTIONS]' + Shows the point at which TYPENAME is frozen, with possible + associated actions to be performed at the freeze point. + + `reference ITYPE' + Reference (and hence definition) to internal type ITYPE. + + `FUNCTION-NAME! (ARG, ARG, ARG)' + Intrinsic function call. + + `LABELNAME : label' + Declaration of label LABELNAME. + + `EXPR && EXPR && EXPR ... && EXPR' + A multiple concatenation (same effect as EXPR & EXPR & EXPR, + but handled more efficiently). + + `[constraint_error]' + Raise the `Constraint_Error' exception. + + `EXPRESSION'reference' + A pointer to the result of evaluating EXPRESSION. + + `TARGET-TYPE!(SOURCE-EXPRESSION)' + An unchecked conversion of SOURCE-EXPRESSION to TARGET-TYPE. + + `[NUMERATOR/DENOMINATOR]' + Used to represent internal real literals (that) have no exact + representation in base 2-16 (for example, the result of + compile time evaluation of the expression 1.0/27.0). + + `/XDEBUG' + This qualifier is used in conjunction with `/EXPAND_SOURCE' + to cause the expanded source, as described above to be + written to files with names `XXX_DG', where `xxx' is the + normal file name, for example, if the source file name is + `HELLO.ADB', then a file `HELLO.ADB_DG' will be written. The + debugging information generated by the `GNAT COMPILE' + `/DEBUG' qualifier will refer to the generated `XXX_DG' file. + This allows you to do source level debugging using the + generated code which is sometimes useful for complex code, + for example to find out exactly which part of a complex + construction raised an exception. This qualifier also + suppress generation of cross-reference information (see + /XREF=SUPPRESS). + + `/COMPRESS_NAMES' + In the generated debugging information, and also in the case + of long external names, the compiler uses a compression + mechanism if the name is very long. This compression method + uses a checksum, and avoids trouble on some operating systems + which have difficulty with very long names. The + `/COMPRESS_NAMES' qualifier forces this compression approach + to be used on all external names and names in the debugging + information tables. This reduces the size of the generated + executable, at the expense of making the naming scheme more + complex. The compression only affects the qualification of + the name. Thus a name in the source: + + Very_Long_Package.Very_Long_Inner_Package.Var + + would normally appear in these tables as: + + very_long_package__very_long_inner_package__var + + but if the `/COMPRESS_NAMES' qualifier is used, then the name + appears as + + XCb7e0c705__var + + Here b7e0c705 is a compressed encoding of the qualification + prefix. The GNAT Ada aware version of GDB understands these + encoded prefixes, so if this debugger is used, the encoding + is largely hidden from the user of the compiler. + + `/REPRESENTATION_INFO[0|1|2|3][s]' + This qualifier controls output from the compiler of a listing + showing representation information for declared types and objects. + For `/REPRESENTATION_INFO=NONE', no information is output + (equivalent to omitting the `/REPRESENTATION_INFO' qualifier). For + `/REPRESENTATION_INFO=ARRAYS' (which is the default, so + `/REPRESENTATION_INFO' with no parameter has the same effect), + size and alignment information is listed for declared array and + record types. For `/REPRESENTATION_INFO=OBJECTS', size and + alignment information is listed for all expression information for + values that are computed at run time for variant records. These + symbolic expressions have a mostly obvious format with #n being + used to represent the value of the n'th discriminant. See source + files `REPINFO.ADS/adb' in the `GNAT' sources for full detalis on + the format of `/REPRESENTATION_INFO=SYMBOLIC' output. If the + qualifier is followed by an s (e.g. `-gnatR2s'), then the output + is to a file with the name `file_REP' where file is the name of + the corresponding source file. + + `/XREF=SUPPRESS' + Normally the compiler generates full cross-referencing information + in the `ALI' file. This information is used by a number of tools, + including `GNAT FIND' and `GNAT XREF'. The /XREF=SUPPRESS qualifier + suppresses this information. This saves some space and may slightly + speed up compilation, but means that these tools cannot be used. + +  + File: gnat_ug_vms.info, Node: Units to Sources Mapping Files, Prev: Debugging Control, Up: Qualifiers for GNAT COMPILE + + Units to Sources Mapping Files + ------------------------------ + + `-gnatemPATH' + A mapping file is a way to communicate to the compiler two + mappings: from unit names to file names (without any directory + information) and from file names to path names (with full + directory information). These mappings are used by the compiler to + short-circuit the path search. + + A mapping file is a sequence of sets of three lines. In each set, + the first line is the unit name, in lower case, with "%s" appended + for specifications and "%b" appended for bodies; the second line + is the file name; and the third line is the path name. + + Example: + main%b + main.2.ADA + /gnat/project1/sources/main.2.ADA + + When the qualifier `-gnatem' is specified, the compiler will create + in memory the two mappings from the specified file. If there is + any problem (non existent file, truncated file or duplicate + entries), no mapping will be created. + + Several `-gnatem' qualifiers may be specified; however, only the + last one on the command line will be taken into account. + + When using a project file, `GNAT MAKE' create a temporary mapping + file and communicates it to the compiler using this qualifier. + +  + File: gnat_ug_vms.info, Node: Search Paths and the Run-Time Library (RTL), Next: Order of Compilation Issues, Prev: Qualifiers for GNAT COMPILE, Up: Compiling Using GNAT COMPILE + + Search Paths and the Run-Time Library (RTL) + =========================================== + + With the GNAT source-based library system, the compiler must be able to + find source files for units that are needed by the unit being compiled. + Search paths are used to guide this process. + + The compiler compiles one source file whose name must be given + explicitly on the command line. In other words, no searching is done + for this file. To find all other source files that are needed (the most + common being the specs of units), the compiler examines the following + directories, in the following order: + + 1. The directory containing the source file of the main unit being + compiled (the file name on the command line). + + 2. Each directory named by an `/SOURCE_SEARCH' qualifier given on the + `GNAT COMPILE' command line, in the order given. + + 3. Each of the directories listed in the value of the + `ADA_INCLUDE_PATH' logical name. Normally, define this value as a + logical name containing a comma separated list of directory names. + + This variable can also be defined by means of an environment string + (an argument to the DEC C exec* set of functions). + + Logical Name: + DEFINE ANOTHER_PATH FOO:[BAG] + DEFINE ADA_INCLUDE_PATH ANOTHER_PATH,FOO:[BAM],FOO:[BAR] + + By default, the path includes GNU:[LIB.OPENVMS7_x.2_8_x.DECLIB] + first, followed by the standard Ada 95 libraries in + GNU:[LIB.OPENVMS7_x.2_8_x.ADAINCLUDE]. If this is not redefined, + the user will obtain the DEC Ada83 IO packages (Text_IO, + Sequential_IO, etc) instead of the Ada95 packages. Thus, in order + to get the Ada 95 packages by default, ADA_INCLUDE_PATH must be + redefined. + + 4. The content of the "ada_source_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as + the GNAT Run Time Library (RTL) source files. + + Specifying the qualifier `/NOCURRENT_DIRECTORY' inhibits the use of the + directory containing the source file named in the command line. You can + still have this directory on your search path, but in this case it must + be explicitly requested with a `/SOURCE_SEARCH' qualifier. + + Specifying the qualifier `/NOSTD_INCLUDES' inhibits the search of + the default location for the GNAT Run Time Library (RTL) source files. + + The compiler outputs its object files and ALI files in the current + working directory. + + The packages `Ada', `System', and `Interfaces' and their children + make up the GNAT RTL, together with the simple `System.IO' package used + in the "Hello World" example. The sources for these units are needed by + the compiler and are kept together in one directory. Not all of the + bodies are needed, but all of the sources are kept together anyway. In + a normal installation, you need not specify these directory names when + compiling or binding. Either the environment variables or the built-in + defaults cause these files to be found. + + In addition to the language-defined hierarchies (System, Ada and + Interfaces), the GNAT distribution provides a fourth hierarchy, + consisting of child units of GNAT. This is a collection of generally + useful routines. See the GNAT Reference Manual for further details. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + +  + File: gnat_ug_vms.info, Node: Order of Compilation Issues, Next: Examples, Prev: Search Paths and the Run-Time Library (RTL), Up: Compiling Using GNAT COMPILE + + Order of Compilation Issues + =========================== + + If, in our earlier example, there was a spec for the `hello' procedure, + it would be contained in the file `HELLO.ADS'; yet this file would not + have to be explicitly compiled. This is the result of the model we + chose to implement library management. Some of the consequences of this + model are as follows: + + * There is no point in compiling specs (except for package specs + with no bodies) because these are compiled as needed by clients. If + you attempt a useless compilation, you will receive an error + message. It is also useless to compile subunits because they are + compiled as needed by the parent. + + * There are no order of compilation requirements: performing a + compilation never obsoletes anything. The only way you can obsolete + something and require recompilations is to modify one of the + source files on which it depends. + + * There is no library as such, apart from the ALI files (*note The + Ada Library Information Files::, for information on the format of + these files). For now we find it convenient to create separate ALI + files, but eventually the information therein may be incorporated + into the object file directly. + + * When you compile a unit, the source files for the specs of all + units that it `with''s, all its subunits, and the bodies of any + generics it instantiates must be available (reachable by the + search-paths mechanism described above), or you will receive a + fatal error message. + +  + File: gnat_ug_vms.info, Node: Examples, Prev: Order of Compilation Issues, Up: Compiling Using GNAT COMPILE + + Examples + ======== + + The following are some typical Ada compilation command line examples: + + `$ GNAT COMPILE XYZ.ADB' + Compile body in file `XYZ.ADB' with all default options. + + `$ GNAT COMPILE /OPTIMIZE=ALL /CHECKS=ASSERTIONS XYZ-DEF.ADB' + Compile the child unit package in file `XYZ-DEF.ADB' with extensive + optimizations, and pragma `Assert'/`Debug' statements enabled. + + `$ GNAT COMPILE /NOLOAD ABC-DEF.ADB' + Compile the subunit in file `ABC-DEF.ADB' in semantic-checking-only + mode. + +  + File: gnat_ug_vms.info, Node: Binding Using GNAT BIND, Next: Linking Using GNAT LINK, Prev: Compiling Using GNAT COMPILE, Up: Top + + Binding Using `GNAT BIND' + ************************* + + * Menu: + + * Running GNAT BIND:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Qualifiers:: + * Command-Line Access:: + * Search Paths for GNAT BIND:: + * Examples of GNAT BIND Usage:: + + This chapter describes the GNAT binder, `GNAT BIND', which is used to + bind compiled GNAT objects. The `GNAT BIND' program performs four + separate functions: + + 1. Checks that a program is consistent, in accordance with the rules + in Chapter 10 of the Ada 95 Reference Manual. In particular, error + messages are generated if a program uses inconsistent versions of a + given unit. + + 2. Checks that an acceptable order of elaboration exists for the + program and issues an error message if it cannot find an order of + elaboration that satisfies the rules in Chapter 10 of the Ada 95 + Language Manual. + + 3. Generates a main program incorporating the given elaboration order. + This program is a small Ada package (body and spec) that must be + subsequently compiled using the GNAT compiler. The necessary + compilation step is usually performed automatically by `GNAT + LINK'. The two most important functions of this program are to + call the elaboration routines of units in an appropriate order and + to call the main program. + + 4. Determines the set of object files required by the given main + program. This information is output in the forms of comments in + the generated program, to be read by the `GNAT LINK' utility used + to link the Ada application. + +  + File: gnat_ug_vms.info, Node: Running GNAT BIND, Next: Generating the Binder Program in C, Up: Binding Using GNAT BIND + + Running `GNAT BIND' + =================== + + The form of the `GNAT BIND' command is + + $ GNAT BIND [QUALIFIERS] MAINPROG[.ALI] [QUALIFIERS] + + where MAINPROG.ADB is the Ada file containing the main program unit + body. If no qualifiers are specified, `GNAT BIND' constructs an Ada + package in two files which names are `B$ADA_MAIN.ADS', and + `B$ADA_MAIN.ADB'. For example, if given the parameter `HELLO.ALI', for + a main program contained in file `HELLO.ADB', the binder output files + would be `B~HELLO.ADS' and `B~HELLO.ADB'. + + When doing consistency checking, the binder takes into consideration + any source files it can locate. For example, if the binder determines + that the given main program requires the package `Pack', whose `.ALI' + file is `PACK.ALI' and whose corresponding source spec file is + `PACK.ADS', it attempts to locate the source file `PACK.ADS' (using the + same search path conventions as previously described for the `GNAT + COMPILE' command). If it can locate this source file, it checks that + the time stamps or source checksums of the source and its references to + in `ali' files match. In other words, any `ali' files that mentions + this spec must have resulted from compiling this version of the source + file (or in the case where the source checksums match, a version close + enough that the difference does not matter). + + The effect of this consistency checking, which includes source + files, is that the binder ensures that the program is consistent with + the latest version of the source files that can be located at bind + time. Editing a source file without compiling files that depend on the + source file cause error messages to be generated by the binder. + + For example, suppose you have a main program `HELLO.ADB' and a + package `P', from file `P.ADS' and you perform the following steps: + + 1. Enter `GNAT COMPILE HELLO.ADB' to compile the main program. + + 2. Enter `GNAT COMPILE P.ADS' to compile package `P'. + + 3. Edit file `P.ADS'. + + 4. Enter `GNAT BIND hello'. + + At this point, the file `P.ALI' contains an out-of-date time stamp + because the file `P.ADS' has been edited. The attempt at binding fails, + and the binder generates the following error messages: + + error: "HELLO.ADB" must be recompiled ("P.ADS" has been modified) + error: "P.ADS" has been modified and must be recompiled + + Now both files must be recompiled as indicated, and then the bind can + succeed, generating a main program. You need not normally be concerned + with the contents of this file, but it is similar to the following which + is the binder file generated for a simple "hello world" program. + + -- The package is called Ada_Main unless this name is actually used + -- as a unit name in the partition, in which case some other unique + -- name is used. + + with System; + package ada_main is + + Elab_Final_Code : Integer; + pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code"); + + -- The main program saves the parameters (argument count, + -- argument values, environment pointer) in global variables + -- for later access by other units including + -- Ada.Command_Line. + + gnat_argc : Integer; + gnat_argv : System.Address; + gnat_envp : System.Address; + + -- The actual variables are stored in a library routine. This + -- is useful for some shared library situations, where there + -- are problems if variables are not in the library. + + pragma Import (C, gnat_argc); + pragma Import (C, gnat_argv); + pragma Import (C, gnat_envp); + + -- The exit status is similarly an external location + + gnat_exit_status : Integer; + pragma Import (C, gnat_exit_status); + + GNAT_Version : constant String := + "GNAT Version: 3.15w (20010315)"; + pragma Export (C, GNAT_Version, "__gnat_version"); + + -- This is the generated adafinal routine that performs + -- finalization at the end of execution. In the case where + -- Ada is the main program, this main program makes a call + -- to adafinal at program termination. + + procedure adafinal; + pragma Export (C, adafinal, "adafinal"); + + -- This is the generated adainit routine that performs + -- initialization at the start of execution. In the case + -- where Ada is the main program, this main program makes + -- a call to adainit at program startup. + + procedure adainit; + pragma Export (C, adainit, "adainit"); + + -- This routine is called at the start of execution. It is + -- a dummy routine that is used by the debugger to breakpoint + -- at the start of execution. + + procedure Break_Start; + pragma Import (C, Break_Start, "__gnat_break_start"); + + -- This is the actual generated main program (it would be + -- suppressed if the no main program qualifier were used). As + -- required by standard system conventions, this program has + -- the external name main. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer; + pragma Export (C, main, "main"); + + -- The following set of constants give the version + -- identification values for every unit in the bound + -- partition. This identification is computed from all + -- dependent semantic units, and corresponds to the + -- string that would be returned by use of the + -- Body_Version or Version attributes. + + type Version_32 is mod 2 ** 32; + u00001 : constant Version_32 := 16#7880BEB3#; + u00002 : constant Version_32 := 16#0D24CBD0#; + u00003 : constant Version_32 := 16#3283DBEB#; + u00004 : constant Version_32 := 16#2359F9ED#; + u00005 : constant Version_32 := 16#664FB847#; + u00006 : constant Version_32 := 16#68E803DF#; + u00007 : constant Version_32 := 16#5572E604#; + u00008 : constant Version_32 := 16#46B173D8#; + u00009 : constant Version_32 := 16#156A40CF#; + u00010 : constant Version_32 := 16#033DABE0#; + u00011 : constant Version_32 := 16#6AB38FEA#; + u00012 : constant Version_32 := 16#22B6217D#; + u00013 : constant Version_32 := 16#68A22947#; + u00014 : constant Version_32 := 16#18CC4A56#; + u00015 : constant Version_32 := 16#08258E1B#; + u00016 : constant Version_32 := 16#367D5222#; + u00017 : constant Version_32 := 16#20C9ECA4#; + u00018 : constant Version_32 := 16#50D32CB6#; + u00019 : constant Version_32 := 16#39A8BB77#; + u00020 : constant Version_32 := 16#5CF8FA2B#; + u00021 : constant Version_32 := 16#2F1EB794#; + u00022 : constant Version_32 := 16#31AB6444#; + u00023 : constant Version_32 := 16#1574B6E9#; + u00024 : constant Version_32 := 16#5109C189#; + u00025 : constant Version_32 := 16#56D770CD#; + u00026 : constant Version_32 := 16#02F9DE3D#; + u00027 : constant Version_32 := 16#08AB6B2C#; + u00028 : constant Version_32 := 16#3FA37670#; + u00029 : constant Version_32 := 16#476457A0#; + u00030 : constant Version_32 := 16#731E1B6E#; + u00031 : constant Version_32 := 16#23C2E789#; + u00032 : constant Version_32 := 16#0F1BD6A1#; + u00033 : constant Version_32 := 16#7C25DE96#; + u00034 : constant Version_32 := 16#39ADFFA2#; + u00035 : constant Version_32 := 16#571DE3E7#; + u00036 : constant Version_32 := 16#5EB646AB#; + u00037 : constant Version_32 := 16#4249379B#; + u00038 : constant Version_32 := 16#0357E00A#; + u00039 : constant Version_32 := 16#3784FB72#; + u00040 : constant Version_32 := 16#2E723019#; + u00041 : constant Version_32 := 16#623358EA#; + u00042 : constant Version_32 := 16#107F9465#; + u00043 : constant Version_32 := 16#6843F68A#; + u00044 : constant Version_32 := 16#63305874#; + u00045 : constant Version_32 := 16#31E56CE1#; + u00046 : constant Version_32 := 16#02917970#; + u00047 : constant Version_32 := 16#6CCBA70E#; + u00048 : constant Version_32 := 16#41CD4204#; + u00049 : constant Version_32 := 16#572E3F58#; + u00050 : constant Version_32 := 16#20729FF5#; + u00051 : constant Version_32 := 16#1D4F93E8#; + u00052 : constant Version_32 := 16#30B2EC3D#; + u00053 : constant Version_32 := 16#34054F96#; + u00054 : constant Version_32 := 16#5A199860#; + u00055 : constant Version_32 := 16#0E7F912B#; + u00056 : constant Version_32 := 16#5760634A#; + u00057 : constant Version_32 := 16#5D851835#; + + -- The following Export pragmas export the version numbers + -- with symbolic names ending in B (for body) or S + -- (for spec) so that they can be located in a link. The + -- information provided here is sufficient to track down + -- the exact versions of units used in a given build. + + pragma Export (C, u00001, "helloB"); + pragma Export (C, u00002, "system__standard_libraryB"); + pragma Export (C, u00003, "system__standard_libraryS"); + pragma Export (C, u00004, "adaS"); + pragma Export (C, u00005, "ada__text_ioB"); + pragma Export (C, u00006, "ada__text_ioS"); + pragma Export (C, u00007, "ada__exceptionsB"); + pragma Export (C, u00008, "ada__exceptionsS"); + pragma Export (C, u00009, "gnatS"); + pragma Export (C, u00010, "gnat__heap_sort_aB"); + pragma Export (C, u00011, "gnat__heap_sort_aS"); + pragma Export (C, u00012, "systemS"); + pragma Export (C, u00013, "system__exception_tableB"); + pragma Export (C, u00014, "system__exception_tableS"); + pragma Export (C, u00015, "gnat__htableB"); + pragma Export (C, u00016, "gnat__htableS"); + pragma Export (C, u00017, "system__exceptionsS"); + pragma Export (C, u00018, "system__machine_state_operationsB"); + pragma Export (C, u00019, "system__machine_state_operationsS"); + pragma Export (C, u00020, "system__machine_codeS"); + pragma Export (C, u00021, "system__storage_elementsB"); + pragma Export (C, u00022, "system__storage_elementsS"); + pragma Export (C, u00023, "system__secondary_stackB"); + pragma Export (C, u00024, "system__secondary_stackS"); + pragma Export (C, u00025, "system__parametersB"); + pragma Export (C, u00026, "system__parametersS"); + pragma Export (C, u00027, "system__soft_linksB"); + pragma Export (C, u00028, "system__soft_linksS"); + pragma Export (C, u00029, "system__stack_checkingB"); + pragma Export (C, u00030, "system__stack_checkingS"); + pragma Export (C, u00031, "system__tracebackB"); + pragma Export (C, u00032, "system__tracebackS"); + pragma Export (C, u00033, "ada__streamsS"); + pragma Export (C, u00034, "ada__tagsB"); + pragma Export (C, u00035, "ada__tagsS"); + pragma Export (C, u00036, "system__string_opsB"); + pragma Export (C, u00037, "system__string_opsS"); + pragma Export (C, u00038, "interfacesS"); + pragma Export (C, u00039, "interfaces__c_streamsB"); + pragma Export (C, u00040, "interfaces__c_streamsS"); + pragma Export (C, u00041, "system__file_ioB"); + pragma Export (C, u00042, "system__file_ioS"); + pragma Export (C, u00043, "ada__finalizationB"); + pragma Export (C, u00044, "ada__finalizationS"); + pragma Export (C, u00045, "system__finalization_rootB"); + pragma Export (C, u00046, "system__finalization_rootS"); + pragma Export (C, u00047, "system__finalization_implementationB"); + pragma Export (C, u00048, "system__finalization_implementationS"); + pragma Export (C, u00049, "system__string_ops_concat_3B"); + pragma Export (C, u00050, "system__string_ops_concat_3S"); + pragma Export (C, u00051, "system__stream_attributesB"); + pragma Export (C, u00052, "system__stream_attributesS"); + pragma Export (C, u00053, "ada__io_exceptionsS"); + pragma Export (C, u00054, "system__unsigned_typesS"); + pragma Export (C, u00055, "system__file_control_blockS"); + pragma Export (C, u00056, "ada__finalization__list_controllerB"); + pragma Export (C, u00057, "ada__finalization__list_controllerS"); + + -- BEGIN ELABORATION ORDER + -- ada (spec) + -- gnat (spec) + -- gnat.heap_sort_a (spec) + -- gnat.heap_sort_a (body) + -- gnat.htable (spec) + -- gnat.htable (body) + -- interfaces (spec) + -- system (spec) + -- system.machine_code (spec) + -- system.parameters (spec) + -- system.parameters (body) + -- interfaces.c_streams (spec) + -- interfaces.c_streams (body) + -- system.standard_library (spec) + -- ada.exceptions (spec) + -- system.exception_table (spec) + -- system.exception_table (body) + -- ada.io_exceptions (spec) + -- system.exceptions (spec) + -- system.storage_elements (spec) + -- system.storage_elements (body) + -- system.machine_state_operations (spec) + -- system.machine_state_operations (body) + -- system.secondary_stack (spec) + -- system.stack_checking (spec) + -- system.soft_links (spec) + -- system.soft_links (body) + -- system.stack_checking (body) + -- system.secondary_stack (body) + -- system.standard_library (body) + -- system.string_ops (spec) + -- system.string_ops (body) + -- ada.tags (spec) + -- ada.tags (body) + -- ada.streams (spec) + -- system.finalization_root (spec) + -- system.finalization_root (body) + -- system.string_ops_concat_3 (spec) + -- system.string_ops_concat_3 (body) + -- system.traceback (spec) + -- system.traceback (body) + -- ada.exceptions (body) + -- system.unsigned_types (spec) + -- system.stream_attributes (spec) + -- system.stream_attributes (body) + -- system.finalization_implementation (spec) + -- system.finalization_implementation (body) + -- ada.finalization (spec) + -- ada.finalization (body) + -- ada.finalization.list_controller (spec) + -- ada.finalization.list_controller (body) + -- system.file_control_block (spec) + -- system.file_io (spec) + -- system.file_io (body) + -- ada.text_io (spec) + -- ada.text_io (body) + -- hello (body) + -- END ELABORATION ORDER + + end ada_main; + + -- The following source file name pragmas allow the generated file + -- names to be unique for different main programs. They are needed + -- since the package name will always be Ada_Main. + + pragma Source_File_Name (ada_main, Spec_File_Name => "B~HELLO.ADS"); + pragma Source_File_Name (ada_main, Body_File_Name => "B~HELLO.ADB"); + + -- Generated package body for Ada_Main starts here + + package body ada_main is + + -- The actual finalization is performed by calling the + -- library routine in System.Standard_Library.Adafinal + + procedure Do_Finalize; + pragma Import (C, Do_Finalize, "system__standard_library__adafinal"); + + ------------- + -- adainit -- + ------------- + + procedure adainit is + + -- These booleans are set to True once the associated unit has + -- been elaborated. It is also used to avoid elaborating the + -- same unit twice. + + E040 : Boolean; pragma Import (Ada, E040, "interfaces__c_streams_E"); + E008 : Boolean; pragma Import (Ada, E008, "ada__exceptions_E"); + E014 : Boolean; pragma Import (Ada, E014, "system__exception_table_E"); + E053 : Boolean; pragma Import (Ada, E053, "ada__io_exceptions_E"); + E017 : Boolean; pragma Import (Ada, E017, "system__exceptions_E"); + E024 : Boolean; pragma Import (Ada, E024, "system__secondary_stack_E"); + E030 : Boolean; pragma Import (Ada, E030, "system__stack_checking_E"); + E028 : Boolean; pragma Import (Ada, E028, "system__soft_links_E"); + E035 : Boolean; pragma Import (Ada, E035, "ada__tags_E"); + E033 : Boolean; pragma Import (Ada, E033, "ada__streams_E"); + E046 : Boolean; pragma Import (Ada, E046, "system__finalization_root_E"); + E048 : Boolean; pragma Import (Ada, E048, "system__finalization_implementation_E"); + E044 : Boolean; pragma Import (Ada, E044, "ada__finalization_E"); + E057 : Boolean; pragma Import (Ada, E057, "ada__finalization__list_controller_E"); + E055 : Boolean; pragma Import (Ada, E055, "system__file_control_block_E"); + E042 : Boolean; pragma Import (Ada, E042, "system__file_io_E"); + E006 : Boolean; pragma Import (Ada, E006, "ada__text_io_E"); + + -- Set_Globals is a library routine that stores away the + -- value of the indicated set of global values in global + -- variables within the library. + + procedure Set_Globals + (Main_Priority : Integer; + Time_Slice_Value : Integer; + WC_Encoding : Character; + Locking_Policy : Character; + Queuing_Policy : Character; + Task_Dispatching_Policy : Character; + Adafinal : System.Address; + Unreserve_All_Interrupts : Integer; + Exception_Tracebacks : Integer); + pragma Import (C, Set_Globals, "__gnat_set_globals"); + + -- SDP_Table_Build is a library routine used to build the + -- exception tables. See unit Ada.Exceptions in files + -- A-EXCEPT.ADS/adb for full details of how zero cost + -- exception handling works. This procedure, the call to + -- it, and the two following tables are all omitted if the + -- build is in longjmp/setjump exception mode. + + procedure SDP_Table_Build + (SDP_Addresses : System.Address; + SDP_Count : Natural; + Elab_Addresses : System.Address; + Elab_Addr_Count : Natural); + pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build"); + + -- Table of Unit_Exception_Table addresses. Used for zero + -- cost exception handling to build the top level table. + + ST : aliased constant array (1 .. 23) of System.Address := ( + Hello'UET_Address, + Ada.Text_Io'UET_Address, + Ada.Exceptions'UET_Address, + Gnat.Heap_Sort_A'UET_Address, + System.Exception_Table'UET_Address, + System.Machine_State_Operations'UET_Address, + System.Secondary_Stack'UET_Address, + System.Parameters'UET_Address, + System.Soft_Links'UET_Address, + System.Stack_Checking'UET_Address, + System.Traceback'UET_Address, + Ada.Streams'UET_Address, + Ada.Tags'UET_Address, + System.String_Ops'UET_Address, + Interfaces.C_Streams'UET_Address, + System.File_Io'UET_Address, + Ada.Finalization'UET_Address, + System.Finalization_Root'UET_Address, + System.Finalization_Implementation'UET_Address, + System.String_Ops_Concat_3'UET_Address, + System.Stream_Attributes'UET_Address, + System.File_Control_Block'UET_Address, + Ada.Finalization.List_Controller'UET_Address); + + -- Table of addresses of elaboration routines. Used for + -- zero cost exception handling to make sure these + -- addresses are included in the top level procedure + -- address table. + + EA : aliased constant array (1 .. 23) of System.Address := ( + adainit'Code_Address, + Do_Finalize'Code_Address, + Ada.Exceptions'Elab_Spec'Address, + System.Exceptions'Elab_Spec'Address, + Interfaces.C_Streams'Elab_Spec'Address, + System.Exception_Table'Elab_Body'Address, + Ada.Io_Exceptions'Elab_Spec'Address, + System.Stack_Checking'Elab_Spec'Address, + System.Soft_Links'Elab_Body'Address, + System.Secondary_Stack'Elab_Body'Address, + Ada.Tags'Elab_Spec'Address, + Ada.Tags'Elab_Body'Address, + Ada.Streams'Elab_Spec'Address, + System.Finalization_Root'Elab_Spec'Address, + Ada.Exceptions'Elab_Body'Address, + System.Finalization_Implementation'Elab_Spec'Address, + System.Finalization_Implementation'Elab_Body'Address, + Ada.Finalization'Elab_Spec'Address, + Ada.Finalization.List_Controller'Elab_Spec'Address, + System.File_Control_Block'Elab_Spec'Address, + System.File_Io'Elab_Body'Address, + Ada.Text_Io'Elab_Spec'Address, + Ada.Text_Io'Elab_Body'Address); + + -- Start of processing for adainit + + begin + + -- Call SDP_Table_Build to build the top level procedure + -- table for zero cost exception handling (omitted in + -- longjmp/setjump mode). + + SDP_Table_Build (ST'Address, 23, EA'Address, 23); + + -- Call Set_Globals to record various information for + -- this partition. The values are derived by the binder + -- from information stored in the ali files by the compiler. + + Set_Globals + (Main_Priority => -1, + -- Priority of main program, -1 if no pragma Priority used + + Time_Slice_Value => -1, + -- Time slice from Time_Slice pragma, -1 if none used + + WC_Encoding => 'b', + -- Wide_Character encoding used, default is brackets + + Locking_Policy => ' ', + -- Locking_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Queuing_Policy => ' ', + -- Queuing_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Task_Dispatching_Policy => ' ', + -- Task_Dispatching_Policy used, default of space means + -- not specified, otherwise first character of the + -- policy name. + + Adafinal => System.Null_Address, + -- Address of Adafinal routine, not used anymore + + Unreserve_All_Interrupts => 0, + -- Set true if pragma Unreserve_All_Interrupts was used + + Exception_Tracebacks => 0); + -- Indicates if exception tracebacks are enabled + + Elab_Final_Code := 1; + + -- Now we have the elaboration calls for all units in the partition. + -- The Elab_Spec and Elab_Body attributes generate references to the + -- implicit elaboration procedures generated by the compiler for + -- each unit that requires elaboration. + + if not E040 then + Interfaces.C_Streams'Elab_Spec; + end if; + E040 := True; + if not E008 then + Ada.Exceptions'Elab_Spec; + end if; + if not E014 then + System.Exception_Table'Elab_Body; + E014 := True; + end if; + if not E053 then + Ada.Io_Exceptions'Elab_Spec; + E053 := True; + end if; + if not E017 then + System.Exceptions'Elab_Spec; + E017 := True; + end if; + if not E030 then + System.Stack_Checking'Elab_Spec; + end if; + if not E028 then + System.Soft_Links'Elab_Body; + E028 := True; + end if; + E030 := True; + if not E024 then + System.Secondary_Stack'Elab_Body; + E024 := True; + end if; + if not E035 then + Ada.Tags'Elab_Spec; + end if; + if not E035 then + Ada.Tags'Elab_Body; + E035 := True; + end if; + if not E033 then + Ada.Streams'Elab_Spec; + E033 := True; + end if; + if not E046 then + System.Finalization_Root'Elab_Spec; + end if; + E046 := True; + if not E008 then + Ada.Exceptions'Elab_Body; + E008 := True; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Spec; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Body; + E048 := True; + end if; + if not E044 then + Ada.Finalization'Elab_Spec; + end if; + E044 := True; + if not E057 then + Ada.Finalization.List_Controller'Elab_Spec; + end if; + E057 := True; + if not E055 then + System.File_Control_Block'Elab_Spec; + E055 := True; + end if; + if not E042 then + System.File_Io'Elab_Body; + E042 := True; + end if; + if not E006 then + Ada.Text_Io'Elab_Spec; + end if; + if not E006 then + Ada.Text_Io'Elab_Body; + E006 := True; + end if; + + Elab_Final_Code := 0; + end adainit; + + -------------- + -- adafinal -- + -------------- + + procedure adafinal is + begin + Do_Finalize; + end adafinal; + + ---------- + -- main -- + ---------- + + -- main is actually a function, as in the ANSI C standard, + -- defined to return the exit status. The three parameters + -- are the argument count, argument values and environment + -- pointer. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer + is + -- The initialize routine performs low level system + -- initialization using a standard library routine which + -- sets up signal handling and performs any other + -- required setup. The routine can be found in file + -- A-INIT.C. + + procedure initialize; + pragma Import (C, initialize, "__gnat_initialize"); + + -- The finalize routine performs low level system + -- finalization using a standard library routine. The + -- routine is found in file A-FINAL.C and in the standard + -- distribution is a dummy routine that does nothing, so + -- really this is a hook for special user finalization. + + procedure finalize; + pragma Import (C, finalize, "__gnat_finalize"); + + -- We get to the main program of the partition by using + -- pragma Import because if we try to with the unit and + -- call it Ada style, then not only do we waste time + -- recompiling it, but also, we don't really know the right + -- qualifiers (e.g. identifier character set) to be used + -- to compile it. + + procedure Ada_Main_Program; + pragma Import (Ada, Ada_Main_Program, "_ada_hello"); + + -- Start of processing for main + + begin + -- Save global variables + + gnat_argc := argc; + gnat_argv := argv; + gnat_envp := envp; + + -- Call low level system initialization + + Initialize; + + -- Call our generated Ada initialization routine + + adainit; + + -- This is the point at which we want the debugger to get + -- control + + Break_Start; + + -- Now we call the main program of the partition + + Ada_Main_Program; + + -- Perform Ada finalization + + adafinal; + + -- Perform low level system finalization + + Finalize; + + -- Return the proper exit status + return (gnat_exit_status); + end; + + -- This section is entirely comments, so it has no effect on the + -- compilation of the Ada_Main package. It provides the list of + -- object files and linker options, as well as some standard + -- libraries needed for the link. The GNAT LINK utility parses + -- this B~HELLO.ADB file to read these comment lines to generate + -- the appropriate command line arguments for the call to the + -- system linker. The BEGIN/END lines are used for sentinels for + -- this parsing operation. + + -- The exact file names will of course depend on the environment, + -- host/target and location of files on the host system. + + -- BEGIN Object file/option list + -- ./HELLO.OBJ + -- -L./ + -- -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/ + -- /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a + -- END Object file/option list + + end ada_main; + + The Ada code in the above example is exactly what is generated by the + binder. We have added comments to more clearly indicate the function of + each part of the generated `Ada_Main' package. + + The code is standard Ada in all respects, and can be processed by any + tools that handle Ada. In particular, it is possible to use the debugger + in Ada mode to debug the generated Ada_Main package. For example, + suppose that for reasons that you do not understand, your program is + blowing up during elaboration of the body of `Ada.Text_IO'. To chase + this bug down, you can place a breakpoint on the call: + + Ada.Text_Io'Elab_Body; + + and trace the elaboration routine for this package to find out where + the problem might be (more usually of course you would be debugging + elaboration code in your own application). + +  + File: gnat_ug_vms.info, Node: Generating the Binder Program in C, Next: Consistency-Checking Modes, Prev: Running GNAT BIND, Up: Binding Using GNAT BIND + + Generating the Binder Program in C + ================================== + + In most normal usage, the default mode of `GNAT BIND' which is to + generate the main package in Ada, as described in the previous section. + In particular, this means that any Ada programmer can read and + understand the generated main program. It can also be debugged just + like any other Ada code provided the `-g' qualifier is used for `GNAT + BIND' and `GNAT LINK'. + + However for some purposes it may be convenient to generate the main + program in C rather than Ada. This may for example be helpful when you + are generating a mixed language program with the main program in C. The + GNAT compiler itself is an example. The use of the `-C' qualifier for + both `GNAT BIND' and `GNAT LINK' will cause the program to be generated + in C (and compiled using the gnu C compiler). The following shows the C + code generated for the same "Hello World" program: + + + #ifdef __STDC__ + #define PARAMS(paramlist) paramlist + #else + #define PARAMS(paramlist) () + #endif + + extern void __gnat_set_globals + PARAMS ((int, int, int, int, int, int, + void (*) PARAMS ((void)), int, int)); + extern void adafinal PARAMS ((void)); + extern void adainit PARAMS ((void)); + extern void system__standard_library__adafinal PARAMS ((void)); + extern int main PARAMS ((int, char **, char **)); + extern void exit PARAMS ((int)); + extern void __gnat_break_start PARAMS ((void)); + extern void _ada_hello PARAMS ((void)); + extern void __gnat_initialize PARAMS ((void)); + extern void __gnat_finalize PARAMS ((void)); + + extern void ada__exceptions___elabs PARAMS ((void)); + extern void system__exceptions___elabs PARAMS ((void)); + extern void interfaces__c_streams___elabs PARAMS ((void)); + extern void system__exception_table___elabb PARAMS ((void)); + extern void ada__io_exceptions___elabs PARAMS ((void)); + extern void system__stack_checking___elabs PARAMS ((void)); + extern void system__soft_links___elabb PARAMS ((void)); + extern void system__secondary_stack___elabb PARAMS ((void)); + extern void ada__tags___elabs PARAMS ((void)); + extern void ada__tags___elabb PARAMS ((void)); + extern void ada__streams___elabs PARAMS ((void)); + extern void system__finalization_root___elabs PARAMS ((void)); + extern void ada__exceptions___elabb PARAMS ((void)); + extern void system__finalization_implementation___elabs PARAMS ((void)); + extern void system__finalization_implementation___elabb PARAMS ((void)); + extern void ada__finalization___elabs PARAMS ((void)); + extern void ada__finalization__list_controller___elabs PARAMS ((void)); + extern void system__file_control_block___elabs PARAMS ((void)); + extern void system__file_io___elabb PARAMS ((void)); + extern void ada__text_io___elabs PARAMS ((void)); + extern void ada__text_io___elabb PARAMS ((void)); + + extern int __gnat_inside_elab_final_code; + + extern int gnat_argc; + extern char **gnat_argv; + extern char **gnat_envp; + extern int gnat_exit_status; + + char __gnat_version[] = "GNAT Version: 3.15w (20010315)"; + void adafinal () { + system__standard_library__adafinal (); + } + + void adainit () + { + extern char ada__exceptions_E; + extern char system__exceptions_E; + extern char interfaces__c_streams_E; + extern char system__exception_table_E; + extern char ada__io_exceptions_E; + extern char system__secondary_stack_E; + extern char system__stack_checking_E; + extern char system__soft_links_E; + extern char ada__tags_E; + extern char ada__streams_E; + extern char system__finalization_root_E; + extern char system__finalization_implementation_E; + extern char ada__finalization_E; + extern char ada__finalization__list_controller_E; + extern char system__file_control_block_E; + extern char system__file_io_E; + extern char ada__text_io_E; + + extern void *__gnat_hello__SDP; + extern void *__gnat_ada__text_io__SDP; + extern void *__gnat_ada__exceptions__SDP; + extern void *__gnat_gnat__heap_sort_a__SDP; + extern void *__gnat_system__exception_table__SDP; + extern void *__gnat_system__machine_state_operations__SDP; + extern void *__gnat_system__secondary_stack__SDP; + extern void *__gnat_system__parameters__SDP; + extern void *__gnat_system__soft_links__SDP; + extern void *__gnat_system__stack_checking__SDP; + extern void *__gnat_system__traceback__SDP; + extern void *__gnat_ada__streams__SDP; + extern void *__gnat_ada__tags__SDP; + extern void *__gnat_system__string_ops__SDP; + extern void *__gnat_interfaces__c_streams__SDP; + extern void *__gnat_system__file_io__SDP; + extern void *__gnat_ada__finalization__SDP; + extern void *__gnat_system__finalization_root__SDP; + extern void *__gnat_system__finalization_implementation__SDP; + extern void *__gnat_system__string_ops_concat_3__SDP; + extern void *__gnat_system__stream_attributes__SDP; + extern void *__gnat_system__file_control_block__SDP; + extern void *__gnat_ada__finalization__list_controller__SDP; + + void **st[23] = { + &__gnat_hello__SDP, + &__gnat_ada__text_io__SDP, + &__gnat_ada__exceptions__SDP, + &__gnat_gnat__heap_sort_a__SDP, + &__gnat_system__exception_table__SDP, + &__gnat_system__machine_state_operations__SDP, + &__gnat_system__secondary_stack__SDP, + &__gnat_system__parameters__SDP, + &__gnat_system__soft_links__SDP, + &__gnat_system__stack_checking__SDP, + &__gnat_system__traceback__SDP, + &__gnat_ada__streams__SDP, + &__gnat_ada__tags__SDP, + &__gnat_system__string_ops__SDP, + &__gnat_interfaces__c_streams__SDP, + &__gnat_system__file_io__SDP, + &__gnat_ada__finalization__SDP, + &__gnat_system__finalization_root__SDP, + &__gnat_system__finalization_implementation__SDP, + &__gnat_system__string_ops_concat_3__SDP, + &__gnat_system__stream_attributes__SDP, + &__gnat_system__file_control_block__SDP, + &__gnat_ada__finalization__list_controller__SDP}; + + extern void ada__exceptions___elabs (); + extern void system__exceptions___elabs (); + extern void interfaces__c_streams___elabs (); + extern void system__exception_table___elabb (); + extern void ada__io_exceptions___elabs (); + extern void system__stack_checking___elabs (); + extern void system__soft_links___elabb (); + extern void system__secondary_stack___elabb (); + extern void ada__tags___elabs (); + extern void ada__tags___elabb (); + extern void ada__streams___elabs (); + extern void system__finalization_root___elabs (); + extern void ada__exceptions___elabb (); + extern void system__finalization_implementation___elabs (); + extern void system__finalization_implementation___elabb (); + extern void ada__finalization___elabs (); + extern void ada__finalization__list_controller___elabs (); + extern void system__file_control_block___elabs (); + extern void system__file_io___elabb (); + extern void ada__text_io___elabs (); + extern void ada__text_io___elabb (); + + void (*ea[23]) () = { + adainit, + system__standard_library__adafinal, + ada__exceptions___elabs, + system__exceptions___elabs, + interfaces__c_streams___elabs, + system__exception_table___elabb, + ada__io_exceptions___elabs, + system__stack_checking___elabs, + system__soft_links___elabb, + system__secondary_stack___elabb, + ada__tags___elabs, + ada__tags___elabb, + ada__streams___elabs, + system__finalization_root___elabs, + ada__exceptions___elabb, + system__finalization_implementation___elabs, + system__finalization_implementation___elabb, + ada__finalization___elabs, + ada__finalization__list_controller___elabs, + system__file_control_block___elabs, + system__file_io___elabb, + ada__text_io___elabs, + ada__text_io___elabb}; + + __gnat_SDP_Table_Build (&st, 23, ea, 23); + __gnat_set_globals ( + -1, /* Main_Priority */ + -1, /* Time_Slice_Value */ + 'b', /* WC_Encoding */ + ' ', /* Locking_Policy */ + ' ', /* Queuing_Policy */ + ' ', /* Tasking_Dispatching_Policy */ + 0, /* Finalization routine address, not used anymore */ + 0, /* Unreserve_All_Interrupts */ + 0); /* Exception_Tracebacks */ + + __gnat_inside_elab_final_code = 1; + + if (ada__exceptions_E == 0) { + ada__exceptions___elabs (); + } + if (system__exceptions_E == 0) { + system__exceptions___elabs (); + system__exceptions_E++; + } + if (interfaces__c_streams_E == 0) { + interfaces__c_streams___elabs (); + } + interfaces__c_streams_E = 1; + if (system__exception_table_E == 0) { + system__exception_table___elabb (); + system__exception_table_E++; + } + if (ada__io_exceptions_E == 0) { + ada__io_exceptions___elabs (); + ada__io_exceptions_E++; + } + if (system__stack_checking_E == 0) { + system__stack_checking___elabs (); + } + if (system__soft_links_E == 0) { + system__soft_links___elabb (); + system__soft_links_E++; + } + system__stack_checking_E = 1; + if (system__secondary_stack_E == 0) { + system__secondary_stack___elabb (); + system__secondary_stack_E++; + } + if (ada__tags_E == 0) { + ada__tags___elabs (); + } + if (ada__tags_E == 0) { + ada__tags___elabb (); + ada__tags_E++; + } + if (ada__streams_E == 0) { + ada__streams___elabs (); + ada__streams_E++; + } + if (system__finalization_root_E == 0) { + system__finalization_root___elabs (); + } + system__finalization_root_E = 1; + if (ada__exceptions_E == 0) { + ada__exceptions___elabb (); + ada__exceptions_E++; + } + if (system__finalization_implementation_E == 0) { + system__finalization_implementation___elabs (); + } + if (system__finalization_implementation_E == 0) { + system__finalization_implementation___elabb (); + system__finalization_implementation_E++; + } + if (ada__finalization_E == 0) { + ada__finalization___elabs (); + } + ada__finalization_E = 1; + if (ada__finalization__list_controller_E == 0) { + ada__finalization__list_controller___elabs (); + } + ada__finalization__list_controller_E = 1; + if (system__file_control_block_E == 0) { + system__file_control_block___elabs (); + system__file_control_block_E++; + } + if (system__file_io_E == 0) { + system__file_io___elabb (); + system__file_io_E++; + } + if (ada__text_io_E == 0) { + ada__text_io___elabs (); + } + if (ada__text_io_E == 0) { + ada__text_io___elabb (); + ada__text_io_E++; + } + + __gnat_inside_elab_final_code = 0; + } + int main (argc, argv, envp) + int argc; + char **argv; + char **envp; + { + gnat_argc = argc; + gnat_argv = argv; + gnat_envp = envp; + + __gnat_initialize (); + adainit (); + __gnat_break_start (); + + _ada_hello (); + + system__standard_library__adafinal (); + __gnat_finalize (); + exit (gnat_exit_status); + } + unsigned helloB = 0x7880BEB3; + unsigned system__standard_libraryB = 0x0D24CBD0; + unsigned system__standard_libraryS = 0x3283DBEB; + unsigned adaS = 0x2359F9ED; + unsigned ada__text_ioB = 0x47C85FC4; + unsigned ada__text_ioS = 0x496FE45C; + unsigned ada__exceptionsB = 0x74F50187; + unsigned ada__exceptionsS = 0x6736945B; + unsigned gnatS = 0x156A40CF; + unsigned gnat__heap_sort_aB = 0x033DABE0; + unsigned gnat__heap_sort_aS = 0x6AB38FEA; + unsigned systemS = 0x0331C6FE; + unsigned system__exceptionsS = 0x20C9ECA4; + unsigned system__exception_tableB = 0x68A22947; + unsigned system__exception_tableS = 0x394BADD5; + unsigned gnat__htableB = 0x08258E1B; + unsigned gnat__htableS = 0x367D5222; + unsigned system__machine_state_operationsB = 0x4F3B7492; + unsigned system__machine_state_operationsS = 0x182F5CF4; + unsigned system__storage_elementsB = 0x2F1EB794; + unsigned system__storage_elementsS = 0x102C83C7; + unsigned system__secondary_stackB = 0x1574B6E9; + unsigned system__secondary_stackS = 0x708E260A; + unsigned system__parametersB = 0x56D770CD; + unsigned system__parametersS = 0x237E39BE; + unsigned system__soft_linksB = 0x08AB6B2C; + unsigned system__soft_linksS = 0x1E2491F3; + unsigned system__stack_checkingB = 0x476457A0; + unsigned system__stack_checkingS = 0x5299FCED; + unsigned system__tracebackB = 0x2971EBDE; + unsigned system__tracebackS = 0x2E9C3122; + unsigned ada__streamsS = 0x7C25DE96; + unsigned ada__tagsB = 0x39ADFFA2; + unsigned ada__tagsS = 0x769A0464; + unsigned system__string_opsB = 0x5EB646AB; + unsigned system__string_opsS = 0x63CED018; + unsigned interfacesS = 0x0357E00A; + unsigned interfaces__c_streamsB = 0x3784FB72; + unsigned interfaces__c_streamsS = 0x2E723019; + unsigned system__file_ioB = 0x623358EA; + unsigned system__file_ioS = 0x31F873E6; + unsigned ada__finalizationB = 0x6843F68A; + unsigned ada__finalizationS = 0x63305874; + unsigned system__finalization_rootB = 0x31E56CE1; + unsigned system__finalization_rootS = 0x23169EF3; + unsigned system__finalization_implementationB = 0x6CCBA70E; + unsigned system__finalization_implementationS = 0x604AA587; + unsigned system__string_ops_concat_3B = 0x572E3F58; + unsigned system__string_ops_concat_3S = 0x01F57876; + unsigned system__stream_attributesB = 0x1D4F93E8; + unsigned system__stream_attributesS = 0x30B2EC3D; + unsigned ada__io_exceptionsS = 0x34054F96; + unsigned system__unsigned_typesS = 0x7B9E7FE3; + unsigned system__file_control_blockS = 0x2FF876A8; + unsigned ada__finalization__list_controllerB = 0x5760634A; + unsigned ada__finalization__list_controllerS = 0x5D851835; + + /* BEGIN ELABORATION ORDER + ada (spec) + gnat (spec) + gnat.heap_sort_a (spec) + gnat.htable (spec) + gnat.htable (body) + interfaces (spec) + system (spec) + system.parameters (spec) + system.standard_library (spec) + ada.exceptions (spec) + system.exceptions (spec) + system.parameters (body) + gnat.heap_sort_a (body) + interfaces.c_streams (spec) + interfaces.c_streams (body) + system.exception_table (spec) + system.exception_table (body) + ada.io_exceptions (spec) + system.storage_elements (spec) + system.storage_elements (body) + system.machine_state_operations (spec) + system.machine_state_operations (body) + system.secondary_stack (spec) + system.stack_checking (spec) + system.soft_links (spec) + system.soft_links (body) + system.stack_checking (body) + system.secondary_stack (body) + system.standard_library (body) + system.string_ops (spec) + system.string_ops (body) + ada.tags (spec) + ada.tags (body) + ada.streams (spec) + system.finalization_root (spec) + system.finalization_root (body) + system.string_ops_concat_3 (spec) + system.string_ops_concat_3 (body) + system.traceback (spec) + system.traceback (body) + ada.exceptions (body) + system.unsigned_types (spec) + system.stream_attributes (spec) + system.stream_attributes (body) + system.finalization_implementation (spec) + system.finalization_implementation (body) + ada.finalization (spec) + ada.finalization (body) + ada.finalization.list_controller (spec) + ada.finalization.list_controller (body) + system.file_control_block (spec) + system.file_io (spec) + system.file_io (body) + ada.text_io (spec) + ada.text_io (body) + hello (body) + END ELABORATION ORDER */ + + /* BEGIN Object file/option list + ./HELLO.OBJ + -L./ + -L/usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/ + /usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/libgnat.a + -lexc + END Object file/option list */ + + Here again, the C code is exactly what is generated by the binder. The + functions of the various parts of this code correspond in an obvious + manner with the commented Ada code shown in the example in the previous + section. + +  + File: gnat_ug_vms.info, Node: Consistency-Checking Modes, Next: Binder Error Message Control, Prev: Generating the Binder Program in C, Up: Binding Using GNAT BIND + + Consistency-Checking Modes + ========================== + + As described in the previous section, by default `GNAT BIND' checks + that object files are consistent with one another and are consistent + with any source files it can locate. The following qualifiers control + binder access to sources. + + `/READ_SOURCES=ALL' + Require source files to be present. In this mode, the binder must + be able to locate all source files that are referenced, in order + to check their consistency. In normal mode, if a source file + cannot be located it is simply ignored. If you specify this + qualifier, a missing source file is an error. + + `/READ_SOURCES=NONE' + Exclude source files. In this mode, the binder only checks that ALI + files are consistent with one another. Source files are not + accessed. The binder runs faster in this mode, and there is still + a guarantee that the resulting program is self-consistent. If a + source file has been edited since it was last compiled, and you + specify this qualifier, the binder will not detect that the object + file is out of date with respect to the source file. Note that + this is the mode that is automatically used by `GNAT MAKE' because + in this case the checking against sources has already been + performed by `GNAT MAKE' in the course of compilation (i.e. before + binding). + + `/READ_SOURCES=AVAILABLE' + This is the default mode in which source files are checked if they + are available, and ignored if they are not available. + +  + File: gnat_ug_vms.info, Node: Binder Error Message Control, Next: Elaboration Control, Prev: Consistency-Checking Modes, Up: Binding Using GNAT BIND + + Binder Error Message Control + ============================ + + The following qualifiers provide control over the generation of error + messages from the binder: + + `/REPORT_ERRORS=VERBOSE' + Verbose mode. In the normal mode, brief error messages are + generated to `SYS$ERROR'. If this qualifier is present, a header + is written to `SYS$OUTPUT' and any error messages are directed to + `SYS$OUTPUT'. All that is written to `SYS$ERROR' is a brief + summary message. + + `/REPORT_ERRORS=BRIEF' + Generate brief error messages to `SYS$ERROR' even if verbose mode + is specified. This is relevant only when used with the + `/REPORT_ERRORS=VERBOSE' qualifier. + + `/WARNINGS=SUPPRESS' + Suppress all warning messages. + + `/WARNINGS=ERROR' + Treat any warning messages as fatal errors. + + `/WARNINGS=NORMAL' + Standard mode with warnings generated, but warnings do not get + treated as errors. + + `/NOTIME_STAMP_CHECK' + The binder performs a number of consistency checks including: + + * Check that time stamps of a given source unit are consistent + + * Check that checksums of a given source unit are consistent + + * Check that consistent versions of `GNAT' were used for + compilation + + * Check consistency of configuration pragmas as required + + Normally failure of such checks, in accordance with the consistency + requirements of the Ada Reference Manual, causes error messages to + be generated which abort the binder and prevent the output of a + binder file and subsequent link to obtain an executable. + + The `/NOTIME_STAMP_CHECK' qualifier converts these error messages + into warnings, so that binding and linking can continue to + completion even in the presence of such errors. The result may be + a failed link (due to missing symbols), or a non-functional + executable which has undefined semantics. _This means that + `/NOTIME_STAMP_CHECK' should be used only in unusual situations, + with extreme care._ + +  + File: gnat_ug_vms.info, Node: Elaboration Control, Next: Output Control, Prev: Binder Error Message Control, Up: Binding Using GNAT BIND + + Elaboration Control + =================== + + The following qualifiers provide additional control over the elaboration + order. For full details see *Note Elaboration Order Handling in GNAT::. + + `/PESSIMISTIC_ELABORATION' + Normally the binder attempts to choose an elaboration order that is + likely to minimize the likelihood of an elaboration order error + resulting in raising a `Program_Error' exception. This qualifier + reverses the action of the binder, and requests that it + deliberately choose an order that is likely to maximize the + likelihood of an elaboration error. This is useful in ensuring + portability and avoiding dependence on accidental fortuitous + elaboration ordering. + + Normally it only makes sense to use the `-p' qualifier if dynamic + elaboration checking is used (`/CHECKS=ELABORATION' qualifier used + for compilation). This is because in the default static + elaboration mode, all necessary `Elaborate_All' pragmas are + implicitly inserted. These implicit pragmas are still respected by + the binder in `-p' mode, so a safe elaboration order is assured. + +  + File: gnat_ug_vms.info, Node: Output Control, Next: Binding with Non-Ada Main Programs, Prev: Elaboration Control, Up: Binding Using GNAT BIND + + Output Control + ============== + + The following qualifiers allow additional control over the output + generated by the binder. + + `/BIND_FILE=ADA' + Generate binder program in Ada (default). The binder program is + named `B$MAINPROG.ADB' by default. This can be changed with `-o' + `GNAT BIND' option. + + `/NOOUTPUT' + Check only. Do not generate the binder output file. In this mode + the binder performs all error checks but does not generate an + output file. + + `/BIND_FILE=C' + Generate binder program in C. The binder program is named + `B_MAINPROG.C'. This can be changed with `-o' `GNAT BIND' option. + + `/ELABORATION_DEPENDENCIES' + Output complete list of elaboration-order dependencies, showing the + reason for each dependency. This output can be rather extensive + but may be useful in diagnosing problems with elaboration order. + The output is written to `SYS$OUTPUT'. + + `/HELP' + Output usage information. The output is written to `SYS$OUTPUT'. + + `/LINKER_OPTION_LIST' + Output linker options to `SYS$OUTPUT'. Includes library search + paths, contents of pragmas Ident and Linker_Options, and libraries + added by `GNAT BIND'. + + `/ORDER_OF_ELABORATION' + Output chosen elaboration order. The output is written to + `SYS$OUTPUT'. + + `/OBJECT_LIST' + Output full names of all the object files that must be linked to + provide the Ada component of the program. The output is written to + `SYS$OUTPUT'. This list includes the files explicitly supplied + and referenced by the user as well as implicitly referenced + run-time unit files. The latter are omitted if the corresponding + units reside in shared libraries. The directory names for the + run-time units depend on the system configuration. + + `/OUTPUT=FILE' + Set name of output file to FILE instead of the normal + `B$MAINPROG.ADB' default. Note that FILE denote the Ada binder + generated body filename. In C mode you would normally give FILE an + extension of `.C' because it will be a C source program. Note + that if this option is used, then linking must be done manually. + It is not possible to use GNAT LINK in this case, since it cannot + locate the binder file. + + `/RESTRICTION_LIST' + Generate list of `pragma Rerstrictions' that could be applied to + the current unit. This is useful for code audit purposes, and also + may be used to improve code generation in some cases. + +  + File: gnat_ug_vms.info, Node: Binding with Non-Ada Main Programs, Next: Binding Programs with No Main Subprogram, Prev: Output Control, Up: Binding Using GNAT BIND + + Binding with Non-Ada Main Programs + ================================== + + In our description so far we have assumed that the main program is in + Ada, and that the task of the binder is to generate a corresponding + function `main' that invokes this Ada main program. GNAT also supports + the building of executable programs where the main program is not in + Ada, but some of the called routines are written in Ada and compiled + using GNAT (*note Mixed Language Programming::). The following + qualifier is used in this situation: + + `/NOMAIN' + No main program. The main program is not in Ada. + + In this case, most of the functions of the binder are still required, + but instead of generating a main program, the binder generates a file + containing the following callable routines: + + `adainit' + You must call this routine to initialize the Ada part of the + program by calling the necessary elaboration routines. A call to + `adainit' is required before the first call to an Ada subprogram. + + Note that it is assumed that the basic execution environment must + be setup to be appropriate for Ada execution at the point where + the first Ada subprogram is called. In particular, if the Ada code + will do any floating-point operations, then the FPU must be setup + in an appropriate manner. For the case of the x86, for example, + full precision mode is required. The procedure + GNAT.Float_Control.Reset may be used to ensure that the FPU is in + the right state. + + `adafinal' + You must call this routine to perform any library-level + finalization required by the Ada subprograms. A call to `adafinal' + is required after the last call to an Ada subprogram, and before + the program terminates. + + If the `/NOMAIN' qualifier is given, more than one ALI file may appear + on the command line for `GNAT BIND'. The normal "closure" calculation + is performed for each of the specified units. Calculating the closure + means finding out the set of units involved by tracing `with' + references. The reason it is necessary to be able to specify more than + one ALI file is that a given program may invoke two or more quite + separate groups of Ada units. + + The binder takes the name of its output file from the last specified + ALI file, unless overridden by the use of the `/OUTPUT=file'. The + output is an Ada unit in source form that can be compiled with GNAT + unless the -C qualifier is used in which case the output is a C source + file, which must be compiled using the C compiler. This compilation + occurs automatically as part of the `GNAT LINK' processing. + + Currently the GNAT run time requires a FPU using 80 bits mode + precision. Under targets where this is not the default it is required to + call GNAT.Float_Control.Reset before using floating point numbers (this + include float computation, float input and output) in the Ada code. A + side effect is that this could be the wrong mode for the foreign code + where floating point computation could be broken after this call. + +  + File: gnat_ug_vms.info, Node: Binding Programs with No Main Subprogram, Next: Summary of Binder Qualifiers, Prev: Binding with Non-Ada Main Programs, Up: Binding Using GNAT BIND + + Binding Programs with No Main Subprogram + ======================================== + + It is possible to have an Ada program which does not have a main + subprogram. This program will call the elaboration routines of all the + packages, then the finalization routines. + + The following qualifier is used to bind programs organized in this + manner: + + `/ZERO_MAIN' + Normally the binder checks that the unit name given on the command + line corresponds to a suitable main subprogram. When this + qualifier is used, a list of ALI files can be given, and the + execution of the program consists of elaboration of these units in + an appropriate order. + +  + File: gnat_ug_vms.info, Node: Summary of Binder Qualifiers, Next: Command-Line Access, Prev: Binding Programs with No Main Subprogram, Up: Binding Using GNAT BIND + + Summary of Binder Qualifiers + ============================ + + The following are the qualifiers available with `GNAT BIND': + + `/OBJECT_SEARCH' + Specify directory to be searched for ALI files. + + `/SOURCE_SEARCH' + Specify directory to be searched for source file. + + `/BIND_FILE=ADA' + Generate binder program in Ada (default) + + `/REPORT_ERRORS=BRIEF' + Generate brief messages to `SYS$ERROR' even if verbose mode set. + + `/NOOUTPUT' + Check only, no generation of binder output file. + + `/BIND_FILE=C' + Generate binder program in C + + `/ELABORATION_DEPENDENCIES' + Output complete list of elaboration-order dependencies. + + `-E' + Store tracebacks in exception occurrences when the target supports + it. This is the default with the zero cost exception mechanism. + This option is currently supported on the following targets: all + x86 ports, Solaris, Windows, HP-UX, AIX, PowerPC VxWorks and Alpha + VxWorks. See also the packages `GNAT.Traceback' and + `GNAT.Traceback.Symbolic' for more information. Note that on x86 + ports, you must not use `-fomit-frame-pointer' `GNAT COMPILE' + option. + + `-h' + Output usage (help) information + + `/SEARCH' + Specify directory to be searched for source and ALI files. + + `/NOCURRENT_DIRECTORY' + Do not look for sources in the current directory where `GNAT BIND' + was invoked, and do not look for ALI files in the directory + containing the ALI file named in the `GNAT BIND' command line. + + `/ORDER_OF_ELABORATION' + Output chosen elaboration order. + + `-Lxxx' + Binds the units for library building. In this case the adainit and + adafinal procedures (See *note Binding with Non-Ada Main + Programs::) are renamed to xxxinit and xxxfinal. Implies -n. + + `-Mxyz' + Rename generated main program from main to xyz + + `/ERROR_LIMIT=N' + Limit number of detected errors to N (1-999). + + `/NOMAIN' + No main program. + + `/NOSTD_INCLUDES' + Do not look for sources in the system default directory. + + `/NOSTD_LIBRARIES' + Do not look for library files in the system default directory. + + `/RUNTIME_SYSTEM=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `GNAT MAKE' flag (see *Note Qualifiers + for GNAT MAKE::). + + `/OUTPUT=FILE' + Name the output file FILE (default is `B$XXX.ADB'). Note that if + this option is used, then linking must be done manually, GNAT LINK + cannot be used. + + `/OBJECT_LIST' + Output object list. + + `-p' + Pessimistic (worst-case) elaboration order + + `/READ_SOURCES=ALL' + Require all source files to be present. + + `/NOTIME_STAMP_CHECK' + Tolerate time stamp and other consistency errors + + `-TN' + Set the time slice value to n microseconds. A value of zero means + no time slicing and also indicates to the tasking run time to + match as close as possible to the annex D requirements of the RM. + + `/REPORT_ERRORS=VERBOSE' + Verbose mode. Write error messages, header, summary output to + `SYS$OUTPUT'. + + `/WARNINGS=NORMAL' + Normal warnings mode. Warnings are issued but ignored + + `/WARNINGS=SUPPRESS' + All warning messages are suppressed + + `/WARNINGS=ERROR' + Warning messages are treated as fatal errors + + `/READ_SOURCES=NONE' + Exclude source files (check object consistency only). + + `/READ_SOURCES=AVAILABLE' + Default mode, in which sources are checked for consistency only if + they are available. + + `/ZERO_MAIN' + No main subprogram. + +  + File: gnat_ug_vms.info, Node: Command-Line Access, Next: Search Paths for GNAT BIND, Prev: Summary of Binder Qualifiers, Up: Binding Using GNAT BIND + + Command-Line Access + =================== + + The package `Ada.Command_Line' provides access to the command-line + arguments and program name. In order for this interface to operate + correctly, the two variables + + int gnat_argc; + char **gnat_argv; + + are declared in one of the GNAT library routines. These variables must + be set from the actual `argc' and `argv' values passed to the main + program. With no `/NOMAIN' present, `GNAT BIND' generates the C main + program to automatically set these variables. If the `/NOMAIN' + qualifier is used, there is no automatic way to set these variables. If + they are not set, the procedures in `Ada.Command_Line' will not be + available, and any attempt to use them will raise `Constraint_Error'. + If command line access is required, your main program must set + `gnat_argc' and `gnat_argv' from the `argc' and `argv' values passed to + it. + +  + File: gnat_ug_vms.info, Node: Search Paths for GNAT BIND, Next: Examples of GNAT BIND Usage, Prev: Command-Line Access, Up: Binding Using GNAT BIND + + Search Paths for `GNAT BIND' + ============================ + + The binder takes the name of an ALI file as its argument and needs to + locate source files as well as other ALI files to verify object + consistency. + + For source files, it follows exactly the same search rules as `GNAT + COMPILE' (*note Search Paths and the Run-Time Library (RTL)::). For ALI + files the directories searched are: + + 1. The directory containing the ALI file named in the command line, + unless the qualifier `/NOCURRENT_DIRECTORY' is specified. + + 2. All directories specified by `/SEARCH' qualifiers on the `GNAT + BIND' command line, in the order given. + + 3. Each of the directories listed in the value of the + `ADA_OBJECTS_PATH' logical name. Normally, define this value as a + logical name containing a comma separated list of directory names. + + This variable can also be defined by means of an environment string + (an argument to the DEC C exec* set of functions). + + Logical Name: + DEFINE ANOTHER_PATH FOO:[BAG] + DEFINE ADA_OBJECTS_PATH ANOTHER_PATH,FOO:[BAM],FOO:[BAR] + + By default, the path includes GNU:[LIB.OPENVMS7_x.2_8_x.DECLIB] + first, followed by the standard Ada 95 libraries in + GNU:[LIB.OPENVMS7_x.2_8_x.ADALIB]. If this is not redefined, the + user will obtain the DEC Ada83 IO packages (Text_IO, + Sequential_IO, etc) instead of the Ada95 packages. Thus, in order + to get the Ada 95 packages by default, ADA_OBJECTS_PATH must be + redefined. + + 4. The content of the "ada_object_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as + the GNAT Run Time Library (RTL) unless the qualifier + `/NOSTD_LIBRARIES' is specified. + + In the binder the qualifier `/SEARCH' is used to specify both source and + library file paths. Use `/SOURCE_SEARCH' instead if you want to specify + source paths only, and `/LIBRARY_SEARCH' if you want to specify library + paths only. This means that for the binder `/SEARCH='DIR is equivalent + to `/SOURCE_SEARCH='DIR `/OBJECT_SEARCH='DIR. The binder generates the + bind file (a C language source file) in the current working directory. + + The packages `Ada', `System', and `Interfaces' and their children + make up the GNAT Run-Time Library, together with the package GNAT and + its children, which contain a set of useful additional library + functions provided by GNAT. The sources for these units are needed by + the compiler and are kept together in one directory. The ALI files and + object files generated by compiling the RTL are needed by the binder + and the linker and are kept together in one directory, typically + different from the directory containing the sources. In a normal + installation, you need not specify these directory names when compiling + or binding. Either the environment variables or the built-in defaults + cause these files to be found. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + +  + File: gnat_ug_vms.info, Node: Examples of GNAT BIND Usage, Prev: Search Paths for GNAT BIND, Up: Binding Using GNAT BIND + + Examples of `GNAT BIND' Usage + ============================= + + This section contains a number of examples of using the GNAT binding + utility `GNAT BIND'. + + `GNAT BIND hello' + The main program `Hello' (source program in `HELLO.ADB') is bound + using the standard qualifier settings. The generated main program + is `B~HELLO.ADB'. This is the normal, default use of the binder. + + `GNAT BIND HELLO.ALI /OUTPUT=Mainprog.ADB' + The main program `Hello' (source program in `HELLO.ADB') is bound + using the standard qualifier settings. The generated main program + is `MAINPROG.ADB' with the associated spec in `MAINPROG.ADS'. Note + that you must specify the body here not the spec, in the case + where the output is in Ada. Note that if this option is used, then + linking must be done manually, since GNAT LINK will not be able to + find the generated file. + + `GNAT BIND MAIN.ALI /BIND_FILE=C /OUTPUT=Mainprog.C /READ_SOURCES=NONE' + The main program `Main' (source program in `MAIN.ADB') is bound, + excluding source files from the consistency checking, generating + the file `MAINPROG.C'. + + `GNAT BIND /NOMAIN math dbase /BIND_FILE=C /OUTPUT=ADA-CONTROL.C' + The main program is in a language other than Ada, but calls to + subprograms in packages `Math' and `Dbase' appear. This call to + `GNAT BIND' generates the file `ADA-CONTROL.C' containing the + `adainit' and `adafinal' routines to be called before and after + accessing the Ada units. + +  + File: gnat_ug_vms.info, Node: Linking Using GNAT LINK, Next: The GNAT Make Program GNAT MAKE, Prev: Binding Using GNAT BIND, Up: Top + + Linking Using `GNAT LINK' + ************************* + + This chapter discusses `GNAT LINK', a utility program used to link Ada + programs and build an executable file. This is a simple program that + invokes the Unix linker (via the `GNAT COMPILE' command) with a correct + list of object files and library references. `GNAT LINK' automatically + determines the list of files and references for the Ada part of a + program. It uses the binder file generated by the binder to determine + this list. + + * Menu: + + * Running GNAT LINK:: + * Qualifiers for GNAT LINK:: + * Setting Stack Size from GNAT LINK:: + * Setting Heap Size from GNAT LINK:: + +  + File: gnat_ug_vms.info, Node: Running GNAT LINK, Next: Qualifiers for GNAT LINK, Up: Linking Using GNAT LINK + + Running `GNAT LINK' + =================== + + The form of the `GNAT LINK' command is + + $ GNAT LINK [QUALIFIERS] MAINPROG[.ALI] [NON-ADA OBJECTS] + [LINKER OPTIONS] + + `MAINPROG.ALI' references the ALI file of the main program. The `.ALI' + extension of this file can be omitted. From this reference, `GNAT LINK' + locates the corresponding binder file `B$MAINPROG.ADB' and, using the + information in this file along with the list of non-Ada objects and + linker options, constructs a Unix linker command file to create the + executable. + + The arguments following `MAINPROG.ALI' are passed to the linker + uninterpreted. They typically include the names of object files for + units written in other languages than Ada and any library references + required to resolve references in any of these foreign language units, + or in `pragma Import' statements in any Ada units. + + LINKER OPTIONS is an optional list of linker specific qualifiers. + The default linker called by GNAT LINK is GNAT COMPILE which in turn + calls the appropriate system linker usually called LD. Standard options + for the linker such as `-lmy_lib' or `-Ldir' can be added as is. For + options that are not recognized by GNAT COMPILE as linker options, the + GNAT COMPILE qualifiers `-Xlinker' or `-Wl,' shall be used. Refer to + the GCC documentation for details. Here is an example showing how to + generate a linker map assuming that the underlying linker is GNU ld: + + $ GNAT LINK my_prog -Wl,-Map,MAPFILE + + Using LINKER OPTIONS it is possible to set the program stack and + heap size. See *note Setting Stack Size from GNAT LINK:: and *note + Setting Heap Size from GNAT LINK::. + + `GNAT LINK' determines the list of objects required by the Ada + program and prepends them to the list of objects passed to the linker. + `GNAT LINK' also gathers any arguments set by the use of `pragma + Linker_Options' and adds them to the list of arguments presented to the + linker. + + `GNAT LINK' accepts the following types of extra files on the command + line: objects (.OBJ), libraries (.OLB), shareable images (.EXE), and + options files (.OPT). These are recognized and handled according to + their extension. + +  + File: gnat_ug_vms.info, Node: Qualifiers for GNAT LINK, Next: Setting Stack Size from GNAT LINK, Prev: Running GNAT LINK, Up: Linking Using GNAT LINK + + Qualifiers for `GNAT LINK' + ========================== + + The following qualifiers are available with the `GNAT LINK' utility: + + `/BIND_FILE=ADA' + The binder has generated code in Ada. This is the default. + + `/BIND_FILE=C' + If instead of generating a file in Ada, the binder has generated + one in C, then the linker needs to know about it. Use this + qualifier to signal to `GNAT LINK' that the binder has generated C + code rather than Ada code. + + `-f' + On some targets, the command line length is limited, and `GNAT + LINK' will generate a separate file for the linker if the list of + object files is too long. The `-f' flag forces this file to be + generated even if the limit is not exceeded. This is useful in + some cases to deal with special situations where the command line + length is exceeded. + + `/DEBUG' + The option to include debugging information causes the Ada bind + file (in other words, `B$MAINPROG.ADB') to be compiled with + `/DEBUG'. In addition, the binder does not delete the + `B$MAINPROG.ADB', `B$MAINPROG.OBJ' and `B$MAINPROG.ALI' files. + Without `/DEBUG', the binder removes these files by default. The + same procedure apply if a C bind file was generated using + `/BIND_FILE=C' `GNAT BIND' option, in this case the filenames are + `B_MAINPROG.C' and `B_MAINPROG.OBJ'. + + `/VERBOSE' + Causes additional information to be output, including a full list + of the included object files. This qualifier option is most useful + when you want to see what set of object files are being used in + the link step. + + `/EXECUTABLE=EXEC-NAME' + EXEC-NAME specifies an alternate name for the generated executable + program. If this qualifier is omitted, the executable has the same + name as the main unit. For example, `GNAT LINK TRY.ALI' creates an + executable called `TRY.EXE'. + + `/DEBUG=TRACEBACK' + This qualifier causes sufficient information to be included in the + executable file to allow a traceback, but does not include the full + symbol information needed by the debugger. + + `/IDENTIFICATION=""' + "" specifies the string to be stored in the image file + identification field in the image header. It overrides any pragma + Ident specified string. + + `/NOINHIBIT-EXEC' + Generate the executable file even if there are linker warnings. + + `/NOSTART_FILES' + Don't link in the object file containing the "main" transfer + address. Used when linking with a foreign language main program + compiled with a Digital compiler. + + `/STATIC' + Prefer linking with object libraries over shareable images, even + without /DEBUG. + +  + File: gnat_ug_vms.info, Node: Setting Stack Size from GNAT LINK, Next: Setting Heap Size from GNAT LINK, Prev: Qualifiers for GNAT LINK, Up: Linking Using GNAT LINK + + Setting Stack Size from `GNAT LINK' + =================================== + + It is possible to specify the program stack size from `GNAT LINK'. + Assuming that the underlying linker is GNU ld there is two ways to do + so: + + * using `-Xlinker' linker option + + $ GNAT LINK hello -Xlinker --stack=0x10000,0x1000 + + This set the stack reserve size to 0x10000 bytes and the stack + commit size to 0x1000 bytes. + + * using `-Wl' linker option + + $ GNAT LINK hello -Wl,--stack=0x1000000 + + This set the stack reserve size to 0x1000000 bytes. Note that with + `-Wl' option it is not possible to set the stack commit size + because the coma is a separator for this option. + + +  + File: gnat_ug_vms.info, Node: Setting Heap Size from GNAT LINK, Prev: Setting Stack Size from GNAT LINK, Up: Linking Using GNAT LINK + + Setting Heap Size from `GNAT LINK' + ================================== + + It is possible to specify the program heap size from `GNAT LINK'. + Assuming that the underlying linker is GNU ld there is two ways to do + so: + + * using `-Xlinker' linker option + + $ GNAT LINK hello -Xlinker --heap=0x10000,0x1000 + + This set the heap reserve size to 0x10000 bytes and the heap commit + size to 0x1000 bytes. + + * using `-Wl' linker option + + $ GNAT LINK hello -Wl,--heap=0x1000000 + + This set the heap reserve size to 0x1000000 bytes. Note that with + `-Wl' option it is not possible to set the heap commit size + because the coma is a separator for this option. + + +  + File: gnat_ug_vms.info, Node: The GNAT Make Program GNAT MAKE, Next: Renaming Files Using GNAT CHOP, Prev: Linking Using GNAT LINK, Up: Top + + The GNAT Make Program `GNAT MAKE' + ********************************* + + * Menu: + + * Running GNAT MAKE:: + * Qualifiers for GNAT MAKE:: + * Mode Qualifiers for GNAT MAKE:: + * Notes on the Command Line:: + * How GNAT MAKE Works:: + * Examples of GNAT MAKE Usage:: + + A typical development cycle when working on an Ada program consists of + the following steps: + + 1. Edit some sources to fix bugs. + + 2. Add enhancements. + + 3. Compile all sources affected. + + 4. Rebind and relink. + + 5. Test. + + The third step can be tricky, because not only do the modified files + have to be compiled, but any files depending on these files must also be + recompiled. The dependency rules in Ada can be quite complex, especially + in the presence of overloading, `use' clauses, generics and inlined + subprograms. + + `GNAT MAKE' automatically takes care of the third and fourth steps + of this process. It determines which sources need to be compiled, + compiles them, and binds and links the resulting object files. + + Unlike some other Ada make programs, the dependencies are always + accurately recomputed from the new sources. The source based approach of + the GNAT compilation model makes this possible. This means that if + changes to the source program cause corresponding changes in + dependencies, they will always be tracked exactly correctly by `GNAT + MAKE'. + +  + File: gnat_ug_vms.info, Node: Running GNAT MAKE, Next: Qualifiers for GNAT MAKE, Up: The GNAT Make Program GNAT MAKE + + Running `GNAT MAKE' + =================== + + The usual form of the `GNAT MAKE' command is + + $ GNAT MAKE [QUALIFIERS] FILE_NAME [FILE_NAMES] [MODE_QUALIFIERS] + + The only required argument is one FILE_NAME, which specifies a + compilation unit that is a main program. Several FILE_NAMES can be + specified: this will result in several executables being built. If + `qualifiers' are present, they can be placed before the first + FILE_NAME, between FILE_NAMES or after the last FILE_NAME. If + MODE_QUALIFIERS are present, they must always be placed after the last + FILE_NAME and all `qualifiers'. + + If you are using standard file extensions (.ADB and .ADS), then the + extension may be omitted from the FILE_NAME arguments. However, if you + are using non-standard extensions, then it is required that the + extension be given. A relative or absolute directory path can be + specified in a FILE_NAME, in which case, the input source file will be + searched for in the specified directory only. Otherwise, the input + source file will first be searched in the directory where `GNAT MAKE' + was invoked and if it is not found, it will be search on the source + path of the compiler as described in *Note Search Paths and the + Run-Time Library (RTL)::. + + When several FILE_NAMES are specified, if an executable needs to be + rebuilt and relinked, all subsequent executables will be rebuilt and + relinked, even if this would not be absolutely necessary. + + All `GNAT MAKE' output (except when you specify + `/DEPENDENCIES_LIST') is to `SYS$ERROR'. The output produced by the + `/DEPENDENCIES_LIST' qualifier is send to `SYS$OUTPUT'. + +  + File: gnat_ug_vms.info, Node: Qualifiers for GNAT MAKE, Next: Mode Qualifiers for GNAT MAKE, Prev: Running GNAT MAKE, Up: The GNAT Make Program GNAT MAKE + + Qualifiers for `GNAT MAKE' + ========================== + + You may specify any of the following qualifiers to `GNAT MAKE': + + `/ALL_FILES' + Consider all files in the make process, even the GNAT internal + system files (for example, the predefined Ada library files), as + well as any locked files. Locked files are files whose ALI file is + write-protected. By default, `GNAT MAKE' does not check these + files, because the assumption is that the GNAT internal files are + properly up to date, and also that any write protected ALI files + have been properly installed. Note that if there is an + installation problem, such that one of these files is not up to + date, it will be properly caught by the binder. You may have to + specify this qualifier if you are working on GNAT itself. + `/ALL_FILES' is also useful in conjunction with `/FORCE_COMPILE' + if you need to recompile an entire application, including run-time + files, using special configuration pragma settings, such as a + non-standard `Float_Representation' pragma. By default `GNAT MAKE + /ALL_FILES' compiles all GNAT internal files with the + `/CHECKS=SUPPRESS_ALL /STYLE_CHECKS=GNAT' qualifier. + + `/ACTIONS=BIND' + Bind only. Can be combined with `/ACTIONS=COMPILE' to do + compilation and binding, but no link. Can be combined with + `/ACTIONS=LINK' to do binding and linking. When not combined with + `/ACTIONS=COMPILE' all the units in the closure of the main + program must have been previously compiled and must be up to date. + The root unit specified by FILE_NAME may be given without + extension, with the source extension or, if no GNAT Project File + is specified, with the ALI file extension. + + `/ACTIONS=COMPILE' + Compile only. Do not perform binding, except when `/ACTIONS=BIND' + is also specified. Do not perform linking, except if both + `/ACTIONS=BIND' and `/ACTIONS=LINK' are also specified. If the + root unit specified by FILE_NAME is not a main unit, this is the + default. Otherwise `GNAT MAKE' will attempt binding and linking + unless all objects are up to date and the executable is more + recent than the objects. + + `/MAPPING' + Use a mapping file. A mapping file is a way to communicate to the + compiler two mappings: from unit names to file names (without any + directory information) and from file names to path names (with + full directory information). These mappings are used by the + compiler to short-circuit the path search. When `GNAT MAKE' is + invoked with this qualifier, it will create a mapping file, + initially populated by the project manager, if `-P' is used, + otherwise initially empty. Each invocation of the compiler will + add the newly accessed sources to the mapping file. This will + improve the source search during the next invocation of the + compiler. + + `/FORCE_COMPILE' + Force recompilations. Recompile all sources, even though some + object files may be up to date, but don't recompile predefined or + GNAT internal files or locked files (files with a write-protected + ALI file), unless the `/ALL_FILES' qualifier is also specified. + + `' + + `/IN_PLACE' + In normal mode, `GNAT MAKE' compiles all object files and ALI files + into the current directory. If the `/IN_PLACE' qualifier is used, + then instead object files and ALI files that already exist are + overwritten in place. This means that once a large project is + organized into separate directories in the desired manner, then + `GNAT MAKE' will automatically maintain and update this + organization. If no ALI files are found on the Ada object path + (*Note Search Paths and the Run-Time Library (RTL)::), the new + object and ALI files are created in the directory containing the + source being compiled. If another organization is desired, where + objects and sources are kept in different directories, a useful + technique is to create dummy ALI files in the desired directories. + When detecting such a dummy file, `GNAT MAKE' will be forced to + recompile the corresponding source file, and it will be put the + resulting object and ALI files in the directory where it found the + dummy file. + + `/PROCESSES=N' + Use N processes to carry out the (re)compilations. On a + multiprocessor machine compilations will occur in parallel. In the + event of compilation errors, messages from various compilations + might get interspersed (but `GNAT MAKE' will give you the full + ordered list of failing compiles at the end). If this is + problematic, rerun the make process with n set to 1 to get a clean + list of messages. + + `/CONTINUE_ON_ERROR' + Keep going. Continue as much as possible after a compilation + error. To ease the programmer's task in case of compilation + errors, the list of sources for which the compile fails is given + when `GNAT MAKE' terminates. + + If `GNAT MAKE' is invoked with several `file_names' and with this + qualifier, if there are compilation errors when building an + executable, `GNAT MAKE' will not attempt to build the following + executables. + + `/ACTIONS=LINK' + Link only. Can be combined with `/ACTIONS=BIND' to binding and + linking. Linking will not be performed if combined with + `/ACTIONS=COMPILE' but not with `/ACTIONS=BIND'. When not + combined with `/ACTIONS=BIND' all the units in the closure of the + main program must have been previously compiled and must be up to + date, and the main program need to have been bound. The root unit + specified by FILE_NAME may be given without extension, with the + source extension or, if no GNAT Project File is specified, with + the ALI file extension. + + `/MINIMAL_RECOMPILATION' + Specifies that the minimum necessary amount of recompilations be + performed. In this mode `GNAT MAKE' ignores time stamp differences + when the only modifications to a source file consist in + adding/removing comments, empty lines, spaces or tabs. This means + that if you have changed the comments in a source file or have + simply reformatted it, using this qualifier will tell GNAT MAKE + not to recompile files that depend on it (provided other sources + on which these files depend have undergone no semantic + modifications). Note that the debugging information may be out of + date with respect to the sources if the `-m' qualifier causes a + compilation to be switched, so the use of this qualifier + represents a trade-off between compilation time and accurate + debugging information. + + `/DEPENDENCIES_LIST' + Check if all objects are up to date. If they are, output the object + dependences to `SYS$OUTPUT' in a form that can be directly + exploited in a `Makefile'. By default, each source file is + prefixed with its (relative or absolute) directory name. This name + is whatever you specified in the various `/SOURCE_SEARCH' and + `/SEARCH' qualifiers. If you use `GNAT MAKE /DEPENDENCIES_LIST' + `/QUIET' (see below), only the source file names, without relative + paths, are output. If you just specify the `/DEPENDENCIES_LIST' + qualifier, dependencies of the GNAT internal system files are + omitted. This is typically what you want. If you also specify the + `/ALL_FILES' qualifier, dependencies of the GNAT internal files + are also listed. Note that dependencies of the objects in external + Ada libraries (see qualifier `/SKIP_MISSING='DIR in the following + list) are never reported. + + `/DO_OBJECT_CHECK' + Don't compile, bind, or link. Checks if all objects are up to date. + If they are not, the full name of the first file that needs to be + recompiled is printed. Repeated use of this option, followed by + compiling the indicated source file, will eventually result in + recompiling all required units. + + `/EXECUTABLE=EXEC_NAME' + Output executable name. The name of the final executable program + will be EXEC_NAME. If the `/EXECUTABLE' qualifier is omitted the + default name for the executable will be the name of the input file + in appropriate form for an executable file on the host system. + + This qualifier cannot be used when invoking `GNAT MAKE' with + several `file_names'. + + `/QUIET' + Quiet. When this flag is not set, the commands carried out by + `GNAT MAKE' are displayed. + + `/SWITCH_CHECK/' + Recompile if compiler qualifiers have changed since last + compilation. All compiler qualifiers but -I and -o are taken into + account in the following way: orders between different "first + letter" qualifiers are ignored, but orders between same qualifiers + are taken into account. For example, `-O /OPTIMIZE=ALL' is + different than `/OPTIMIZE=ALL -O', but `-g -O' is equivalent to + `-O -g'. + + `/UNIQUE' + Unique. Recompile at most the main file. It implies -c. Combined + with -f, it is equivalent to calling the compiler directly. + + `/REASONS' + Verbose. Displays the reason for all recompilations `GNAT MAKE' + decides are necessary. + + `/NOMAIN' + No main subprogram. Bind and link the program even if the unit name + given on the command line is a package name. The resulting + executable will execute the elaboration routines of the package + and its closure, then the finalization routines. + + ``GNAT COMPILE' qualifiers' + Any qualifier that cannot be recognized as a qualifier for `GNAT + MAKE' but is recognizable as a valid qualifier for `GNAT COMPILE' + is automatically treated as a compiler qualifier, and passed on to + all compilations that are carried out. + + Source and library search path qualifiers: + + `/SOURCE_SEARCH=DIR' + When looking for source files also look in directory DIR. The + order in which source files search is undertaken is described in + *Note Search Paths and the Run-Time Library (RTL)::. + + `/SKIP_MISSING=DIR' + Consider DIR as being an externally provided Ada library. + Instructs `GNAT MAKE' to skip compilation units whose `.ALI' files + have been located in directory DIR. This allows you to have + missing bodies for the units in DIR and to ignore out of date + bodies for the same units. You still need to specify the location + of the specs for these units by using the qualifiers + `/SOURCE_SEARCH=DIR' or `/SEARCH=DIR'. Note: this qualifier is + provided for compatibility with previous versions of `GNAT MAKE'. + The easier method of causing standard libraries to be excluded + from consideration is to write-protect the corresponding ALI files. + + `/OBJECT_SEARCH=DIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is described in + *Note Search Paths for GNAT BIND::. + + `/CONDITIONAL_SOURCE_SEARCH=DIR' + Equivalent to `/SKIP_MISSING=DIR /SOURCE_SEARCH=DIR'. + + `/SEARCH=DIR' + Equivalent to `/OBJECT_SEARCH=DIR /SOURCE_SEARCH=DIR'. + + `/NOCURRENT_DIRECTORY' + Do not look for source files in the directory containing the source + file named in the command line. Do not look for ALI or object + files in the directory where `GNAT MAKE' was invoked. + + `/LIBRARY_SEARCH=DIR' + Add directory DIR to the list of directories in which the linker + will search for libraries. This is equivalent to + `/LINKER_QUALIFIERS /LIBRARY_SEARCH='DIR. + + `/NOSTD_INCLUDES' + Do not look for source files in the system default directory. + + `/NOSTD_LIBRARIES' + Do not look for library files in the system default directory. + + `/RUNTIME_SYSTEM=RTS-PATH' + Specifies the default location of the runtime library. We look for + the runtime in the following directories, and stop as soon as a + valid runtime is found ("adainclude" or "ada_source_path", and + "adalib" or "ada_object_path" present): + + * /$rts_path + + * /$rts_path + + * /rts-$rts_path + + The selected path is handled like a normal RTS path. + +  + File: gnat_ug_vms.info, Node: Mode Qualifiers for GNAT MAKE, Next: Notes on the Command Line, Prev: Qualifiers for GNAT MAKE, Up: The GNAT Make Program GNAT MAKE + + Mode Qualifiers for `GNAT MAKE' + =============================== + + The mode qualifiers (referred to as `mode_qualifiers') allow the + inclusion of qualifiers that are to be passed to the compiler itself, + the binder or the linker. The effect of a mode qualifier is to cause all + subsequent qualifiers up to the end of the qualifier list, or up to the + next mode qualifier, to be interpreted as qualifiers to be passed on to + the designated component of GNAT. + + `/COMPILER_QUALIFIERS QUALIFIERS' + Compiler qualifiers. Here QUALIFIERS is a list of qualifiers that + are valid qualifiers for `GNAT COMPILE'. They will be passed on to + all compile steps performed by `GNAT MAKE'. + + `/BINDER_QUALIFIERS QUALIFIERS' + Binder qualifiers. Here QUALIFIERS is a list of qualifiers that + are valid qualifiers for `GNAT COMPILE'. They will be passed on to + all bind steps performed by `GNAT MAKE'. + + `/LINKER_QUALIFIERS QUALIFIERS' + Linker qualifiers. Here QUALIFIERS is a list of qualifiers that + are valid qualifiers for `GNAT COMPILE'. They will be passed on to + all link steps performed by `GNAT MAKE'. + +  + File: gnat_ug_vms.info, Node: Notes on the Command Line, Next: How GNAT MAKE Works, Prev: Mode Qualifiers for GNAT MAKE, Up: The GNAT Make Program GNAT MAKE + + Notes on the Command Line + ========================= + + This section contains some additional useful notes on the operation of + the `GNAT MAKE' command. + + * If `GNAT MAKE' finds no ALI files, it recompiles the main program + and all other units required by the main program. This means that + `GNAT MAKE' can be used for the initial compile, as well as during + subsequent steps of the development cycle. + + * If you enter `GNAT MAKE FILE.ADB', where `FILE.ADB' is a subunit + or body of a generic unit, `GNAT MAKE' recompiles `FILE.ADB' + (because it finds no ALI) and stops, issuing a warning. + + * In `GNAT MAKE' the qualifier `/SEARCH' is used to specify both + source and library file paths. Use `/SOURCE_SEARCH' instead if you + just want to specify source paths only and `/OBJECT_SEARCH' if you + want to specify library paths only. + + * `GNAT MAKE' examines both an ALI file and its corresponding object + file for consistency. If an ALI is more recent than its + corresponding object, or if the object file is missing, the + corresponding source will be recompiled. Note that `GNAT MAKE' + expects an ALI and the corresponding object file to be in the same + directory. + + * `GNAT MAKE' will ignore any files whose ALI file is + write-protected. This may conveniently be used to exclude + standard libraries from consideration and in particular it means + that the use of the `/FORCE_COMPILE' qualifier will not recompile + these files unless `/ALL_FILES' is also specified. + + * `GNAT MAKE' has been designed to make the use of Ada libraries + particularly convenient. Assume you have an Ada library organized + as follows: [OBJ_DIR] contains the objects and ALI files for of + your Ada compilation units, whereas [INCLUDE_DIR] contains the + specs of these units, but no bodies. Then to compile a unit stored + in `MAIN.ADB', which uses this Ada library you would just type + + $ GNAT MAKE /SOURCE_SEARCH=[INCLUDE_DIR] + /SKIP_MISSING=[OBJ_DIR] main + + * Using `GNAT MAKE' along with the `/MINIMAL_RECOMPILATION' + qualifier provides a mechanism for avoiding unnecessary + rcompilations. Using this qualifier, you can update the + comments/format of your source files without having to recompile + everything. Note, however, that adding or deleting lines in a + source files may render its debugging info obsolete. If the file + in question is a spec, the impact is rather limited, as that + debugging info will only be useful during the elaboration phase of + your program. For bodies the impact can be more significant. In + all events, your debugger will warn you if a source file is more + recent than the corresponding object, and alert you to the fact + that the debugging information may be out of date. + +  + File: gnat_ug_vms.info, Node: How GNAT MAKE Works, Next: Examples of GNAT MAKE Usage, Prev: Notes on the Command Line, Up: The GNAT Make Program GNAT MAKE + + How `GNAT MAKE' Works + ===================== + + Generally `GNAT MAKE' automatically performs all necessary + recompilations and you don't need to worry about how it works. However, + it may be useful to have some basic understanding of the `GNAT MAKE' + approach and in particular to understand how it uses the results of + previous compilations without incorrectly depending on them. + + First a definition: an object file is considered "up to date" if the + corresponding ALI file exists and its time stamp predates that of the + object file and if all the source files listed in the dependency + section of this ALI file have time stamps matching those in the ALI + file. This means that neither the source file itself nor any files that + it depends on have been modified, and hence there is no need to + recompile this file. + + `GNAT MAKE' works by first checking if the specified main unit is up + to date. If so, no compilations are required for the main unit. If not, + `GNAT MAKE' compiles the main program to build a new ALI file that + reflects the latest sources. Then the ALI file of the main unit is + examined to find all the source files on which the main program depends, + and `GNAT MAKE' recursively applies the above procedure on all these + files. + + This process ensures that `GNAT MAKE' only trusts the dependencies + in an existing ALI file if they are known to be correct. Otherwise it + always recompiles to determine a new, guaranteed accurate set of + dependencies. As a result the program is compiled "upside down" from + what may be more familiar as the required order of compilation in some + other Ada systems. In particular, clients are compiled before the units + on which they depend. The ability of GNAT to compile in any order is + critical in allowing an order of compilation to be chosen that + guarantees that `GNAT MAKE' will recompute a correct set of new + dependencies if necessary. + + When invoking `GNAT MAKE' with several FILE_NAMES, if a unit is + imported by several of the executables, it will be recompiled at most + once. + +  + File: gnat_ug_vms.info, Node: Examples of GNAT MAKE Usage, Prev: How GNAT MAKE Works, Up: The GNAT Make Program GNAT MAKE + + Examples of `GNAT MAKE' Usage + ============================= + + `GNAT MAKE HELLO.ADB' + Compile all files necessary to bind and link the main program + `HELLO.ADB' (containing unit `Hello') and bind and link the + resulting object files to generate an executable file `HELLO.EXE'. + + `GNAT MAKE main1 main2 main3' + Compile all files necessary to bind and link the main programs + `MAIN1.ADB' (containing unit `Main1'), `MAIN2.ADB' (containing + unit `Main2') and `MAIN3.ADB' (containing unit `Main3') and bind + and link the resulting object files to generate three executable + files `MAIN1.EXE', `MAIN2.EXE' and `MAIN3.EXE'. + + `GNAT MAKE Main_Unit /QUIET /COMPILER_QUALIFIERS /OPTIMIZE=ALL /BINDER_QUALIFIERS /ORDER_OF_ELABORATION' + Compile all files necessary to bind and link the main program unit + `Main_Unit' (from file `MAIN_UNIT.ADB'). All compilations will be + done with optimization level 2 and the order of elaboration will be + listed by the binder. `GNAT MAKE' will operate in quiet mode, not + displaying commands it is executing. + +  + File: gnat_ug_vms.info, Node: Renaming Files Using GNAT CHOP, Next: Configuration Pragmas, Prev: The GNAT Make Program GNAT MAKE, Up: Top + + Renaming Files Using `GNAT CHOP' + ******************************** + + This chapter discusses how to handle files with multiple units by using + the `GNAT CHOP' utility. This utility is also useful in renaming files + to meet the standard GNAT default file naming conventions. + + * Menu: + + * Handling Files with Multiple Units:: + * Operating GNAT CHOP in Compilation Mode:: + * Command Line for GNAT CHOP:: + * Qualifiers for GNAT CHOP:: + * Examples of GNAT CHOP Usage:: + +  + File: gnat_ug_vms.info, Node: Handling Files with Multiple Units, Next: Operating GNAT CHOP in Compilation Mode, Up: Renaming Files Using GNAT CHOP + + Handling Files with Multiple Units + ================================== + + The basic compilation model of GNAT requires that a file submitted to + the compiler have only one unit and there be a strict correspondence + between the file name and the unit name. + + The `GNAT CHOP' utility allows both of these rules to be relaxed, + allowing GNAT to process files which contain multiple compilation units + and files with arbitrary file names. `GNAT CHOP' reads the specified + file and generates one or more output files, containing one unit per + file. The unit and the file name correspond, as required by GNAT. + + If you want to permanently restructure a set of "foreign" files so + that they match the GNAT rules, and do the remaining development using + the GNAT structure, you can simply use `GNAT CHOP' once, generate the + new set of files and work with them from that point on. + + Alternatively, if you want to keep your files in the "foreign" + format, perhaps to maintain compatibility with some other Ada + compilation system, you can set up a procedure where you use `GNAT + CHOP' each time you compile, regarding the source files that it writes + as temporary files that you throw away. + +  + File: gnat_ug_vms.info, Node: Operating GNAT CHOP in Compilation Mode, Next: Command Line for GNAT CHOP, Prev: Handling Files with Multiple Units, Up: Renaming Files Using GNAT CHOP + + Operating GNAT CHOP in Compilation Mode + ======================================= + + The basic function of `GNAT CHOP' is to take a file with multiple units + and split it into separate files. The boundary between files is + reasonably clear, except for the issue of comments and pragmas. In + default mode, the rule is that any pragmas between units belong to the + previous unit, except that configuration pragmas always belong to the + following unit. Any comments belong to the following unit. These rules + almost always result in the right choice of the split point without + needing to mark it explicitly and most users will find this default to + be what they want. In this default mode it is incorrect to submit a + file containing only configuration pragmas, or one that ends in + configuration pragmas, to `GNAT CHOP'. + + However, using a special option to activate "compilation mode", + `GNAT CHOP' can perform another function, which is to provide exactly + the semantics required by the RM for handling of configuration pragmas + in a compilation. In the absence of configuration pragmas (at the main + file level), this option has no effect, but it causes such + configuration pragmas to be handled in a quite different manner. + + First, in compilation mode, if `GNAT CHOP' is given a file that + consists of only configuration pragmas, then this file is appended to + the `GNAT.ADC' file in the current directory. This behavior provides + the required behavior described in the RM for the actions to be taken + on submitting such a file to the compiler, namely that these pragmas + should apply to all subsequent compilations in the same compilation + environment. Using GNAT, the current directory, possibly containing a + `GNAT.ADC' file is the representation of a compilation environment. For + more information on the `GNAT.ADC' file, see the section on handling of + configuration pragmas *note Handling of Configuration Pragmas::. + + Second, in compilation mode, if `GNAT CHOP' is given a file that + starts with configuration pragmas, and contains one or more units, then + these configuration pragmas are prepended to each of the chopped files. + This behavior provides the required behavior described in the RM for the + actions to be taken on compiling such a file, namely that the pragmas + apply to all units in the compilation, but not to subsequently compiled + units. + + Finally, if configuration pragmas appear between units, they are + appended to the previous unit. This results in the previous unit being + illegal, since the compiler does not accept configuration pragmas that + follow a unit. This provides the required RM behavior that forbids + configuration pragmas other than those preceding the first compilation + unit of a compilation. + + For most purposes, `GNAT CHOP' will be used in default mode. The + compilation mode described above is used only if you need exactly + accurate behavior with respect to compilations, and you have files that + contain multiple units and configuration pragmas. In this circumstance + the use of `GNAT CHOP' with the compilation mode qualifier provides the + required behavior, and is for example the mode in which GNAT processes + the ACVC tests. + +  + File: gnat_ug_vms.info, Node: Command Line for GNAT CHOP, Next: Qualifiers for GNAT CHOP, Prev: Operating GNAT CHOP in Compilation Mode, Up: Renaming Files Using GNAT CHOP + + Command Line for `GNAT CHOP' + ============================ + + The `GNAT CHOP' command has the form: + + $ GNAT CHOP qualifiers FILE NAME [FILE NAME FILE NAME ...] + [DIRECTORY] + + The only required argument is the file name of the file to be chopped. + There are no restrictions on the form of this file name. The file itself + contains one or more Ada units, in normal GNAT format, concatenated + together. As shown, more than one file may be presented to be chopped. + + When run in default mode, `GNAT CHOP' generates one output file in + the current directory for each unit in each of the files. + + DIRECTORY, if specified, gives the name of the directory to which + the output files will be written. If it is not specified, all files are + written to the current directory. + + For example, given a file called `hellofiles' containing + + procedure hello; + + with Text_IO; use Text_IO; + procedure hello is + begin + Put_Line ("Hello"); + end hello; + + the command + + $ GNAT CHOP HELLOFILES. + + generates two files in the current directory, one called `HELLO.ADS' + containing the single line that is the procedure spec, and the other + called `HELLO.ADB' containing the remaining text. The original file is + not affected. The generated files can be compiled in the normal manner. + +  + File: gnat_ug_vms.info, Node: Qualifiers for GNAT CHOP, Next: Examples of GNAT CHOP Usage, Prev: Command Line for GNAT CHOP, Up: Renaming Files Using GNAT CHOP + + Qualifiers for `GNAT CHOP' + ========================== + + `GNAT CHOP' recognizes the following qualifiers: + + `/COMPILATION' + Causes `GNAT CHOP' to operate in compilation mode, in which + configuration pragmas are handled according to strict RM rules. See + previous section for a full description of this mode. + + `/HELP' + Causes `GNAT CHOP' to generate a brief help summary to the standard + output file showing usage information. + + `/FILE_NAME_MAX_LENGTH=MM' + Limit generated file names to the specified number `mm' of + characters. This is useful if the resulting set of files is + required to be interoperable with systems which limit the length + of file names. If no value is given, or if no + `/FILE_NAME_MAX_LENGTH' qualifier is given, a default of 39, + suitable for OpenVMS Alpha Systems, is assumed + + `/PRESERVE' + Causes the file creation time stamp of the input file to be + preserved and used for the time stamp of the output file(s). This + may be useful for preserving coherency of time stamps in an + enviroment where `GNAT CHOP' is used as part of a standard build + process. + + `/QUIET' + Causes output of informational messages indicating the set of + generated files to be suppressed. Warnings and error messages are + unaffected. + + `/REFERENCE' + Generate `Source_Reference' pragmas. Use this qualifier if the + output files are regarded as temporary and development is to be + done in terms of the original unchopped file. This qualifier causes + `Source_Reference' pragmas to be inserted into each of the + generated files to refers back to the original file name and line + number. The result is that all error messages refer back to the + original unchopped file. In addition, the debugging information + placed into the object file (when the `/DEBUG' qualifier of `GNAT + COMPILE' or `GNAT MAKE' is specified) also refers back to this + original file so that tools like profilers and debuggers will give + information in terms of the original unchopped file. + + If the original file to be chopped itself contains a + `Source_Reference' pragma referencing a third file, then GNAT CHOP + respects this pragma, and the generated `Source_Reference' pragmas + in the chopped file refer to the original file, with appropriate + line numbers. This is particularly useful when `GNAT CHOP' is used + in conjunction with `GNAT PREPROCESS' to compile files that + contain preprocessing statements and multiple units. + + `/VERBOSE' + Causes `GNAT CHOP' to operate in verbose mode. The version number + and copyright notice are output, as well as exact copies of the + GNAT1 commands spawned to obtain the chop control information. + + `/OVERWRITE' + Overwrite existing file names. Normally `GNAT CHOP' regards it as a + fatal error if there is already a file with the same name as a + file it would otherwise output, in other words if the files to be + chopped contain duplicated units. This qualifier bypasses this + check, and causes all but the last instance of such duplicated + units to be skipped. + +  + File: gnat_ug_vms.info, Node: Examples of GNAT CHOP Usage, Prev: Qualifiers for GNAT CHOP, Up: Renaming Files Using GNAT CHOP + + Examples of `GNAT CHOP' Usage + ============================= + + `GNAT CHOP /OVERWRITE HELLO_S.ADA [ICHBIAH.FILES]' + Chops the source file `HELLO_S.ADA'. The output files will be + placed in the directory `[ICHBIAH.FILES]', overwriting any files + with matching names in that directory (no files in the current + directory are modified). + + `GNAT CHOP ARCHIVE.' + Chops the source file `ARCHIVE.' into the current directory. One + useful application of `GNAT CHOP' is in sending sets of sources + around, for example in email messages. The required sources are + simply concatenated (for example, using a VMS `APPEND/NEW' + command), and then `GNAT CHOP' is used at the other end to + reconstitute the original file names. + + `GNAT CHOP file1 file2 file3 direc' + Chops all units in files `file1', `file2', `file3', placing the + resulting files in the directory `direc'. Note that if any units + occur more than once anywhere within this set of files, an error + message is generated, and no files are written. To override this + check, use the `/OVERWRITE' qualifier, in which case the last + occurrence in the last file will be the one that is output, and + earlier duplicate occurrences for a given unit will be skipped. + +  + File: gnat_ug_vms.info, Node: Configuration Pragmas, Next: Handling Arbitrary File Naming Conventions Using gnatname, Prev: Renaming Files Using GNAT CHOP, Up: Top + + Configuration Pragmas + ********************* + + In Ada 95, configuration pragmas include those pragmas described as + such in the Ada 95 Reference Manual, as well as + implementation-dependent pragmas that are configuration pragmas. See the + individual descriptions of pragmas in the GNAT Reference Manual for + details on these additional GNAT-specific configuration pragmas. Most + notably, the pragma `Source_File_Name', which allows specifying + non-default names for source files, is a configuration pragma. The + following is a complete list of configuration pragmas recognized by + `GNAT': + + Ada_83 + Ada_95 + C_Pass_By_Copy + Component_Alignment + Discard_Names + Elaboration_Checks + Eliminate + Extend_System + Extensions_Allowed + External_Name_Casing + Float_Representation + Initialize_Scalars + License + Locking_Policy + Long_Float + No_Run_Time + Normalize_Scalars + Polling + Propagate_Exceptions + Queuing_Policy + Ravenscar + Restricted_Run_Time + Restrictions + Reviewable + Source_File_Name + Style_Checks + Suppress + Task_Dispatching_Policy + Unsuppress + Use_VADS_Size + Warnings + Validity_Checks + + * Menu: + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + +  + File: gnat_ug_vms.info, Node: Handling of Configuration Pragmas, Next: The Configuration Pragmas Files, Up: Configuration Pragmas + + Handling of Configuration Pragmas + ================================= + + Configuration pragmas may either appear at the start of a compilation + unit, in which case they apply only to that unit, or they may apply to + all compilations performed in a given compilation environment. + + GNAT also provides the `GNAT CHOP' utility to provide an automatic + way to handle configuration pragmas following the semantics for + compilations (that is, files with multiple units), described in the RM. + See section *note Operating GNAT CHOP in Compilation Mode:: for details. + However, for most purposes, it will be more convenient to edit the + `GNAT.ADC' file that contains configuration pragmas directly, as + described in the following section. + +  + File: gnat_ug_vms.info, Node: The Configuration Pragmas Files, Prev: Handling of Configuration Pragmas, Up: Configuration Pragmas + + The Configuration Pragmas Files + =============================== + + In GNAT a compilation environment is defined by the current directory + at the time that a compile command is given. This current directory is + searched for a file whose name is `GNAT.ADC'. If this file is present, + it is expected to contain one or more configuration pragmas that will + be applied to the current compilation. However, if the qualifier + `-gnatA' is used, `GNAT.ADC' is not considered. + + Configuration pragmas may be entered into the `GNAT.ADC' file either + by running `GNAT CHOP' on a source file that consists only of + configuration pragmas, or more conveniently by direct editing of the + `GNAT.ADC' file, which is a standard format source file. + + In addition to `GNAT.ADC', one additional file containing + configuration pragmas may be applied to the current compilation using + the qualifier `-gnatec'PATH. PATH must designate an existing file that + contains only configuration pragmas. These configuration pragmas are in + addition to those found in `GNAT.ADC' (provided `GNAT.ADC' is present + and qualifier `-gnatA' is not used). + + It is allowed to specify several qualifiers `-gnatec', however only + the last one on the command line will be taken into account. + + Of special interest to GNAT OpenVMS Alpha is the following + configuration pragma: + + pragma Extend_System (Aux_DEC); + + In the presence of this pragma, GNAT adds to the definition of the + predefined package SYSTEM all the additional types and subprograms that + are defined in DEC Ada. See *note Compatibility with DEC Ada:: for + details. + +  + File: gnat_ug_vms.info, Node: Handling Arbitrary File Naming Conventions Using gnatname, Next: GNAT Project Manager, Prev: Configuration Pragmas, Up: Top + + Handling Arbitrary File Naming Conventions Using `gnatname' + *********************************************************** + + * Menu: + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Qualifiers for gnatname:: + * Examples of gnatname Usage:: + +  + File: gnat_ug_vms.info, Node: Arbitrary File Naming Conventions, Next: Running gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Arbitrary File Naming Conventions + ================================= + + The GNAT compiler must be able to know the source file name of a + compilation unit. When using the standard GNAT default file naming + conventions (`.ADS' for specs, `.ADB' for bodies), the GNAT compiler + does not need additional information. + + When the source file names do not follow the standard GNAT default file + naming conventions, the GNAT compiler must be given additional + information through a configuration pragmas file (see *Note + Configuration Pragmas::) or a project file. When the non standard file + naming conventions are well-defined, a small number of pragmas + `Source_File_Name' specifying a naming pattern (see *Note Alternative + File Naming Schemes::) may be sufficient. However, if the file naming + conventions are irregular or arbitrary, a number of pragma + `Source_File_Name' for individual compilation units must be defined. + To help maintain the correspondence between compilation unit names and + source file names within the compiler, GNAT provides a tool `gnatname' + to generate the required pragmas for a set of files. + +  + File: gnat_ug_vms.info, Node: Running gnatname, Next: Qualifiers for gnatname, Prev: Arbitrary File Naming Conventions, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Running `gnatname' + ================== + + The usual form of the `gnatname' command is + + $ gnatname [QUALIFIERS] NAMING_PATTERN [NAMING_PATTERNS] + + All of the arguments are optional. If invoked without any argument, + `gnatname' will display its usage. + + When used with at least one naming pattern, `gnatname' will attempt to + find all the compilation units in files that follow at least one of the + naming patterns. To find these compilation units, `gnatname' will use + the GNAT compiler in syntax-check-only mode on all regular files. + + One or several Naming Patterns may be given as arguments to `gnatname'. + Each Naming Pattern is enclosed between double quotes. A Naming + Pattern is a regular expression similar to the wildcard patterns used + in file names by the Unix shells or the DOS prompt. + + Examples of Naming Patterns are + + "*.[12].ADA" + "*.ad[sb]*" + "body_*" "spec_*" + + For a more complete description of the syntax of Naming Patterns, see + the second kind of regular expressions described in `G-REGEXP.ADS' (the + "Glob" regular expressions). + + When invoked with no qualifiers, `gnatname' will create a configuration + pragmas file `GNAT.ADC' in the current working directory, with pragmas + `Source_File_Name' for each file that contains a valid Ada unit. + +  + File: gnat_ug_vms.info, Node: Qualifiers for gnatname, Next: Examples of gnatname Usage, Prev: Running gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Qualifiers for `gnatname' + ========================= + + Qualifiers for `gnatname' must precede any specified Naming Pattern. + + You may specify any of the following qualifiers to `gnatname': + + `-c`file'' + Create a configuration pragmas file `file' (instead of the default + `GNAT.ADC'). There may be zero, one or more space between `-c' and + `file'. `file' may include directory information. `file' must be + writeable. There may be only one qualifier `-c'. When a qualifier + `-c' is specified, no qualifier `-P' may be specified (see below). + + `-d`dir'' + Look for source files in directory `dir'. There may be zero, one + or more spaces between `-d' and `dir'. When a qualifier `-d' is + specified, the current working directory will not be searched for + source files, unless it is explictly specified with a `-d' or `-D' + qualifier. Several qualifiers `-d' may be specified. If `dir' is a + relative path, it is relative to the directory of the + configuration pragmas file specified with qualifier `-c', or to + the directory of the project file specified with qualifier `-P' + or, if neither qualifier `-c' nor qualifier `-P' are specified, it + is relative to the current working directory. The directory + specified with qualifier `-c' must exist and be readable. + + `-D`file'' + Look for source files in all directories listed in text file + `file'. There may be zero, one or more spaces between `-d' and + `dir'. `file' must be an existing, readable text file. Each non + empty line in `file' must be a directory. Specifying qualifier + `-D' is equivalent to specifying as many qualifiers `-d' as there + are non empty lines in `file'. + + `-h' + Output usage (help) information. The output is written to + `SYS$OUTPUT'. + + `-P`proj'' + Create or update project file `proj'. There may be zero, one or + more space between `-P' and `proj'. `proj' may include directory + information. `proj' must be writeable. There may be only one + qualifier `-P'. When a qualifier `-P' is specified, no qualifier + `-c' may be specified. + + `-v' + Verbose mode. Output detailed explanation of behavior to + `SYS$OUTPUT'. This includes name of the file written, the name of + the directories to search and, for each file in those directories + whose name matches at least one of the Naming Patterns, an + indication of whether the file contains a unit, and if so the name + of the unit. + + `-v -v' + Very Verbose mode. In addition to the output produced in verbose + mode, for each file in the searched directories whose name matches + none of the Naming Patterns, an indication is given that there is + no match. + + `-x`pattern'' + Excluded patterns. Using this qualifier, it is possible to exclude + some files that would match the name patterns. For example, + `"gnatname -x "*_NT.ADA" "*.ADA"' will look for Ada units in all + files with the `.ADA' extension, except those whose names end with + `_NT.ADA'. + +  + File: gnat_ug_vms.info, Node: Examples of gnatname Usage, Prev: Qualifiers for gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Examples of `gnatname' Usage + ============================ + + $ gnatname -c /home/me/NAMES.ADC -d sources "[a-z]*.ADA*" + + In this example, the directory `/home/me' must already exist and be + writeable. In addition, the directory `/home/me/sources' (specified by + `-d sources') must exist and be readable. Note the optional spaces after + `-c' and `-d'. + + $ gnatname -P/home/me/proj -x "*_NT_BODY.ADA" -dsources -dsources/plus -Dcommon_dirs.txt "body_*" "spec_*" + + Note that several qualifiers `-d' may be used, even in conjunction + with one or several qualifiers `-D'. Several Naming Patterns and one + excluded pattern are used in this example. + +  + File: gnat_ug_vms.info, Node: GNAT Project Manager, Next: Elaboration Order Handling in GNAT, Prev: Handling Arbitrary File Naming Conventions Using gnatname, Up: Top + + GNAT Project Manager + ******************** + + * Menu: + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Qualifiers Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + +  + File: gnat_ug_vms.info, Node: Introduction, Next: Examples of Project Files, Up: GNAT Project Manager + + Introduction + ============ + + This chapter describes GNAT's _Project Manager_, a facility that lets + you configure various properties for a collection of source files. In + particular, you can specify: + * The directory or set of directories containing the source files, + and/or the names of the specific source files themselves + + * The directory in which the compiler's output (`ALI' files, object + files, tree files) will be placed + + * The directory in which the executable programs will be placed + + * Qualifier settings for any of the project-enabled tools (`GNAT + MAKE', compiler, binder, linker, `GNAT LIST', `GNAT XREF', `GNAT + FIND'); you can apply these settings either globally or to + individual units + + * The source files containing the main subprogram(s) to be built + + * The source programming language(s) (currently Ada and/or C) + + * Source file naming conventions; you can specify these either + globally or for individual units + + * Menu: + + * Project Files:: + +  + File: gnat_ug_vms.info, Node: Project Files, Up: Introduction + + Project Files + ------------- + + A "project" is a specific set of values for these properties. You can + define a project's settings in a "project file", a text file with an + Ada-like syntax; a property value is either a string or a list of + strings. Properties that are not explicitly set receive default + values. A project file may interrogate the values of "external + variables" (user-defined command-line qualifiers or environment + variables), and it may specify property settings conditionally, based + on the value of such variables. + + In simple cases, a project's source files depend only on other + source files in the same project, or on the predefined libraries. + ("Dependence" is in the technical sense; for example, one Ada unit + "with"ing another.) However, the Project Manager also allows much more + sophisticated arrangements, with the source files in one project + depending on source files in other projects: + * One project can _import_ other projects containing needed source + files. + + * You can organize GNAT projects in a hierarchy: a _child_ project + can extend a _parent_ project, inheriting the parent's source + files and optionally overriding any of them with alternative + versions + + More generally, the Project Manager lets you structure large development + efforts into hierarchical subsystems, with build decisions deferred to + the subsystem level and thus different compilation environments + (qualifier settings) used for different subsystems. + + The Project Manager is invoked through the `-P_projectfile_' + qualifier to `GNAT MAKE' or to the `gnat' front driver. If you want to + define (on the command line) an external variable that is queried by + the project file, additionally use the `-X_vbl_=_value_' qualifier. + The Project Manager parses and interprets the project file, and drives + the invoked tool based on the project settings. + + The Project Manager supports a wide range of development strategies, + for systems of all sizes. Some typical practices that are easily + handled: + * Using a common set of source files, but generating object files in + different directories via different qualifier settings + + * Using a mostly-shared set of source files, but with different + versions of some unit or units + + The destination of an executable can be controlled inside a project file + using the `-o' qualifier. In the absence of such a qualifier either + inside the project file or on the command line, any executable files + generated by `GNAT MAKE' will be placed in the directory `Exec_Dir' + specified in the project file. If no `Exec_Dir' is specified, they will + be placed in the object directory of the project. + + You can use project files to achieve some of the effects of a source + versioning system (for example, defining separate projects for the + different sets of sources that comprise different releases) but the + Project Manager is independent of any source configuration management + tools that might be used by the developers. + + The next section introduces the main features of GNAT's project + facility through a sequence of examples; subsequent sections will + present the syntax and semantics in more detail. + +  + File: gnat_ug_vms.info, Node: Examples of Project Files, Next: Project File Syntax, Prev: Introduction, Up: GNAT Project Manager + + Examples of Project Files + ========================= + + This section illustrates some of the typical uses of project files and + explains their basic structure and behavior. + + * Menu: + + * Common Sources with Different Qualifiers and Different Output Directories:: + * Using External Variables:: + * Importing Other Projects:: + * Extending a Project:: + +  + File: gnat_ug_vms.info, Node: Common Sources with Different Qualifiers and Different Output Directories, Next: Using External Variables, Up: Examples of Project Files + + Common Sources with Different Qualifiers and Different Output Directories + ------------------------------------------------------------------------- + + * Menu: + + * Source Files:: + * Specifying the Object Directory:: + * Specifying the Exec Directory:: + * Project File Packages:: + * Specifying Qualifier Settings:: + * Main Subprograms:: + * Source File Naming Conventions:: + * Source Language(s):: + + Assume that the Ada source files `PACK.ADS', `PACK.ADB', and `PROC.ADB' + are in the `/common' directory. The file `PROC.ADB' contains an Ada + main subprogram `Proc' that "with"s package `Pack'. We want to compile + these source files under two sets of qualifiers: + * When debugging, we want to pass the `-g' qualifier to `GNAT MAKE', + and the `/CHECKS=ASSERTIONS', `/CHECKS=OVERFLOW', and + `/CHECKS=ELABORATION' qualifiers to the compiler; the compiler's + output is to appear in `/common/debug' + + * When preparing a release version, we want to pass the + `/OPTIMIZE=ALL' qualifier to the compiler; the compiler's output + is to appear in `/common/release' + + The GNAT project files shown below, respectively `debug.gpr' and + `release.gpr' in the `/common' directory, achieve these effects. + + Diagrammatically: + /common + debug.gpr + release.gpr + PACK.ADS + PACK.ADB + PROC.ADB + /common/debug {-g, /CHECKS=ASSERTIONS, /CHECKS=OVERFLOW, /CHECKS=ELABORATION} + PROC.ALI, PROC.OBJ + PACK.ALI, PACK.OBJ + /common/release {/OPTIMIZE=ALL} + PROC.ALI, PROC.OBJ + PACK.ALI, PACK.OBJ + Here are the project files: + project Debug is + for Object_Dir use "debug"; + for Main use ("proc"); + + package Builder is + for Default_Qualifiers ("Ada") use ("-g"); + end Builder; + + package Compiler is + for Default_Qualifiers ("Ada") + use ("-fstack-check", "/CHECKS=ASSERTIONS", "/CHECKS=OVERFLOW", "/CHECKS=ELABORATION"); + end Compiler; + end Debug; + + project Release is + for Object_Dir use "release"; + for Exec_Dir use "."; + for Main use ("proc"); + + package Compiler is + for Default_Qualifiers ("Ada") use ("/OPTIMIZE=ALL"); + end Compiler; + end Release; + + The name of the project defined by `debug.gpr' is `"Debug"' (case + insensitive), and analogously the project defined by `release.gpr' is + `"Release"'. For consistency the file should have the same name as the + project, and the project file's extension should be `"gpr"'. These + conventions are not required, but a warning is issued if they are not + followed. + + If the current directory is `/temp', then the command + GNAT MAKE -P/common/debug.gpr + + generates object and ALI files in `/common/debug', and the `proc' + executable also in `/common/debug', using the qualifier settings + defined in the project file. + + Likewise, the command + GNAT MAKE -P/common/release.gpr + + generates object and ALI files in `/common/release', and the `proc' + executable in `/common', using the qualifier settings from the project + file. + +  + File: gnat_ug_vms.info, Node: Source Files, Next: Specifying the Object Directory, Up: Common Sources with Different Qualifiers and Different Output Directories + + Source Files + ............ + + If a project file does not explicitly specify a set of source + directories or a set of source files, then by default the project's + source files are the Ada source files in the project file directory. + Thus `PACK.ADS', `PACK.ADB', and `PROC.ADB' are the source files for + both projects. + +  + File: gnat_ug_vms.info, Node: Specifying the Object Directory, Next: Specifying the Exec Directory, Prev: Source Files, Up: Common Sources with Different Qualifiers and Different Output Directories + + Specifying the Object Directory + ............................... + + Several project properties are modeled by Ada-style _attributes_; you + define the property by supplying the equivalent of an Ada attribute + definition clause in the project file. A project's object directory is + such a property; the corresponding attribute is `Object_Dir', and its + value is a string expression. A directory may be specified either as + absolute or as relative; in the latter case, it is relative to the + project file directory. Thus the compiler's output is directed to + `/common/debug' (for the `Debug' project) and to `/common/release' (for + the `Release' project). If `Object_Dir' is not specified, then the + default is the project file directory. + +  + File: gnat_ug_vms.info, Node: Specifying the Exec Directory, Next: Project File Packages, Prev: Specifying the Object Directory, Up: Common Sources with Different Qualifiers and Different Output Directories + + Specifying the Exec Directory + ............................. + + A project's exec directory is another property; the corresponding + attribute is `Exec_Dir', and its value is also a string expression, + either specified as relative or absolute. If `Exec_Dir' is not + specified, then the default is the object directory (which may also be + the project file directory if attribute `Object_Dir' is not specified). + Thus the executable is placed in `/common/debug' for the `Debug' + project (attribute `Exec_Dir' not specified) and in `/common' for the + `Release' project. + +  + File: gnat_ug_vms.info, Node: Project File Packages, Next: Specifying Qualifier Settings, Prev: Specifying the Exec Directory, Up: Common Sources with Different Qualifiers and Different Output Directories + + Project File Packages + ..................... + + A GNAT tool integrated with the Project Manager is modeled by a + corresponding package in the project file. The `Debug' project defines + the packages `Builder' (for `GNAT MAKE') and `Compiler'; the `Release' + project defines only the `Compiler' package. + + The Ada package syntax is not to be taken literally. Although + packages in project files bear a surface resemblance to packages in Ada + source code, the notation is simply a way to convey a grouping of + properties for a named entity. Indeed, the package names permitted in + project files are restricted to a predefined set, corresponding to the + project-aware tools, and the contents of packages are limited to a + small set of constructs. The packages in the example above contain + attribute definitions. + +  + File: gnat_ug_vms.info, Node: Specifying Qualifier Settings, Next: Main Subprograms, Prev: Project File Packages, Up: Common Sources with Different Qualifiers and Different Output Directories + + Specifying Qualifier Settings + ............................. + + Qualifier settings for a project-aware tool can be specified through + attributes in the package corresponding to the tool. The example above + illustrates one of the relevant attributes, `Default_Qualifiers', + defined in the packages in both project files. Unlike simple + attributes like `Source_Dirs', `Default_Qualifiers' is known as an + _associative array_. When you define this attribute, you must supply + an "index" (a literal string), and the effect of the attribute + definition is to set the value of the "array" at the specified "index". + For the `Default_Qualifiers' attribute, the index is a programming + language (in our case, Ada) , and the value specified (after `use') + must be a list of string expressions. + + The attributes permitted in project files are restricted to a + predefined set. Some may appear at project level, others in packages. + For any attribute that is an associate array, the index must always be a + literal string, but the restrictions on this string (e.g., a file name + or a language name) depend on the individual attribute. Also depending + on the attribute, its specified value will need to be either a string + or a string list. + + In the `Debug' project, we set the qualifiers for two tools, `GNAT + MAKE' and the compiler, and thus we include corresponding packages, + with each package defining the `Default_Qualifiers' attribute with + index `"Ada"'. Note that the package corresponding to `GNAT MAKE' is + named `Builder'. The `Release' project is similar, but with just the + `Compiler' package. + + In project `Debug' above the qualifiers starting with `-gnat' that + are specified in package `Compiler' could have been placed in package + `Builder', since `GNAT MAKE' transmits all such qualifiers to the + compiler. + +  + File: gnat_ug_vms.info, Node: Main Subprograms, Next: Source File Naming Conventions, Prev: Specifying Qualifier Settings, Up: Common Sources with Different Qualifiers and Different Output Directories + + Main Subprograms + ................ + + One of the properties of a project is its list of main subprograms + (actually a list of names of source files containing main subprograms, + with the file extension optional. This property is captured in the + `Main' attribute, whose value is a list of strings. If a project + defines the `Main' attribute, then you do not need to identify the main + subprogram(s) when invoking `GNAT MAKE' (see *Note GNAT MAKE and + Project Files::). + +  + File: gnat_ug_vms.info, Node: Source File Naming Conventions, Next: Source Language(s), Prev: Main Subprograms, Up: Common Sources with Different Qualifiers and Different Output Directories + + Source File Naming Conventions + .............................. + + Since the project files do not specify any source file naming + conventions, the GNAT defaults are used. The mechanism for defining + source file naming conventions - a package named `Naming' - will be + described below (*note Naming Schemes::). + +  + File: gnat_ug_vms.info, Node: Source Language(s), Prev: Source File Naming Conventions, Up: Common Sources with Different Qualifiers and Different Output Directories + + Source Language(s) + .................. + + Since the project files do not specify a `Languages' attribute, by + default the GNAT tools assume that the language of the project file is + Ada. More generally, a project can comprise source files in Ada, C, + and/or other languages. + +  + File: gnat_ug_vms.info, Node: Using External Variables, Next: Importing Other Projects, Prev: Common Sources with Different Qualifiers and Different Output Directories, Up: Examples of Project Files + + Using External Variables + ------------------------ + + Instead of supplying different project files for debug and release, we + can define a single project file that queries an external variable (set + either on the command line or via an environment variable) in order to + conditionally define the appropriate settings. Again, assume that the + source files `PACK.ADS', `PACK.ADB', and `PROC.ADB' are located in + directory `/common'. The following project file, `build.gpr', queries + the external variable named `STYLE' and defines an object directory and + qualifier settings based on whether the value is `"deb"' (debug) or + `"rel"' (release), where the default is `"deb"'. + + project Build is + for Main use ("proc"); + + type Style_Type is ("deb", "rel"); + Style : Style_Type := external ("STYLE", "deb"); + + case Style is + when "deb" => + for Object_Dir use "debug"; + + when "rel" => + for Object_Dir use "release"; + for Exec_Dir use "."; + end case; + + package Builder is + + case Style is + when "deb" => + for Default_Qualifiers ("Ada") use ("-g"); + end case; + + end Builder; + + package Compiler is + + case Style is + when "deb" => + for Default_Qualifiers ("Ada") use ("/CHECKS=ASSERTIONS", "/CHECKS=OVERFLOW", "/CHECKS=ELABORATION"); + + when "rel" => + for Default_Qualifiers ("Ada") use ("/OPTIMIZE=ALL"); + end case; + + end Compiler; + + end Build; + + `Style_Type' is an example of a _string type_, which is the project + file analog of an Ada enumeration type but containing string literals + rather than identifiers. `Style' is declared as a variable of this + type. + + The form `external("STYLE", "deb")' is known as an _external + reference_; its first argument is the name of an _external variable_, + and the second argument is a default value to be used if the external + variable doesn't exist. You can define an external variable on the + command line via the `-X' qualifier, or you can use an environment + variable as an external variable. + + Each `case' construct is expanded by the Project Manager based on the + value of `Style'. Thus the command + GNAT MAKE -P/common/build.gpr -XSTYLE=deb + + is equivalent to the `GNAT MAKE' invocation using the project file + `debug.gpr' in the earlier example. So is the command + GNAT MAKE -P/common/build.gpr + + since `"deb"' is the default for `STYLE'. + + Analogously, + GNAT MAKE -P/common/build.gpr -XSTYLE=rel + + is equivalent to the `GNAT MAKE' invocation using the project file + `release.gpr' in the earlier example. + +  + File: gnat_ug_vms.info, Node: Importing Other Projects, Next: Extending a Project, Prev: Using External Variables, Up: Examples of Project Files + + Importing Other Projects + ------------------------ + + A compilation unit in a source file in one project may depend on + compilation units in source files in other projects. To obtain this + behavior, the dependent project must _import_ the projects containing + the needed source files. This effect is embodied in syntax similar to + an Ada `with' clause, but the "with"ed entities are strings denoting + project files. + + As an example, suppose that the two projects `GUI_Proj' and + `Comm_Proj' are defined in the project files `gui_proj.gpr' and + `comm_proj.gpr' in directories `/gui' and `/comm', respectively. + Assume that the source files for `GUI_Proj' are `GUI.ADS' and + `GUI.ADB', and that the source files for `Comm_Proj' are `COMM.ADS' and + `COMM.ADB', with each set of files located in its respective project + file directory. Diagrammatically: + + /gui + gui_proj.gpr + GUI.ADS + GUI.ADB + + /comm + comm_proj.gpr + COMM.ADS + COMM.ADB + + We want to develop an application in directory `/app' that "with"s the + packages `GUI' and `Comm', using the properties of the corresponding + project files (e.g. the qualifier settings and object directory). + Skeletal code for a main procedure might be something like the + following: + + with GUI, Comm; + procedure App_Main is + ... + begin + ... + end App_Main; + + Here is a project file, `app_proj.gpr', that achieves the desired + effect: + + with "/gui/gui_proj", "/comm/comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + + Building an executable is achieved through the command: + GNAT MAKE -P/app/app_proj + + which will generate the `app_main' executable in the directory where + `app_proj.gpr' resides. + + If an imported project file uses the standard extension (`gpr') then + (as illustrated above) the `with' clause can omit the extension. + + Our example specified an absolute path for each imported project + file. Alternatively, you can omit the directory if either + * The imported project file is in the same directory as the + importing project file, or + + * You have defined an environment variable `ADA_PROJECT_PATH' that + includes the directory containing the needed project file. + + Thus, if we define `ADA_PROJECT_PATH' to include `/gui' and `/comm', + then our project file `app_proj.gpr' could be written as follows: + + with "gui_proj", "comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + + Importing other projects raises the possibility of ambiguities. For + example, the same unit might be present in different imported projects, + or it might be present in both the importing project and an imported + project. Both of these conditions are errors. Note that in the + current version of the Project Manager, it is illegal to have an + ambiguous unit even if the unit is never referenced by the importing + project. This restriction may be relaxed in a future release. + +  + File: gnat_ug_vms.info, Node: Extending a Project, Prev: Importing Other Projects, Up: Examples of Project Files + + Extending a Project + ------------------- + + A common situation in large software systems is to have multiple + implementations for a common interface; in Ada terms, multiple versions + of a package body for the same specification. For example, one + implementation might be safe for use in tasking programs, while another + might only be used in sequential applications. This can be modeled in + GNAT using the concept of _project extension_. If one project (the + "child") _extends_ another project (the "parent") then by default all + source files of the parent project are inherited by the child, but the + child project can override any of the parent's source files with new + versions, and can also add new files. This facility is the project + analog of extension in Object-Oriented Programming. Project + hierarchies are permitted (a child project may be the parent of yet + another project), and a project that inherits one project can also + import other projects. + + As an example, suppose that directory `/seq' contains the project + file `seq_proj.gpr' and the source files `PACK.ADS', `PACK.ADB', and + `PROC.ADB': + + /seq + PACK.ADS + PACK.ADB + PROC.ADB + seq_proj.gpr + + Note that the project file can simply be empty (that is, no attribute or + package is defined): + + project Seq_Proj is + end Seq_Proj; + + implying that its source files are all the Ada source files in the + project directory. + + Suppose we want to supply an alternate version of `PACK.ADB', in + directory `/tasking', but use the existing versions of `PACK.ADS' and + `PROC.ADB'. We can define a project `Tasking_Proj' that inherits + `Seq_Proj': + + /tasking + PACK.ADB + tasking_proj.gpr + + project Tasking_Proj extends "/seq/seq_proj" is + end Tasking_Proj; + + The version of `PACK.ADB' used in a build depends on which project file + is specified. + + Note that we could have designed this using project import rather + than project inheritance; a `base' project would contain the sources for + `PACK.ADS' and `PROC.ADB', a sequential project would import `base' and + add `PACK.ADB', and likewise a tasking project would import `base' and + add a different version of `PACK.ADB'. The choice depends on whether + other sources in the original project need to be overridden. If they + do, then project extension is necessary, otherwise, importing is + sufficient. + +  + File: gnat_ug_vms.info, Node: Project File Syntax, Next: Objects and Sources in Project Files, Prev: Examples of Project Files, Up: GNAT Project Manager + + Project File Syntax + =================== + + * Menu: + + * Basic Syntax:: + * Packages:: + * Expressions:: + * String Types:: + * Variables:: + * Attributes:: + * Associative Array Attributes:: + * case Constructions:: + + This section describes the structure of project files. + + A project may be an _independent project_, entirely defined by a + single project file. Any Ada source file in an independent project + depends only on the predefined library and other Ada source files in + the same project. + + A project may also "depend on" other projects, in either or both of the + following ways: + * It may import any number of projects + + * It may extend at most one other project + + The dependence relation is a directed acyclic graph (the subgraph + reflecting the "extends" relation is a tree). + + A project's "immediate sources" are the source files directly + defined by that project, either implicitly by residing in the project + file's directory, or explicitly through any of the source-related + attributes described below. More generally, a project PROJ's "sources" + are the immediate sources of PROJ together with the immediate sources + (unless overridden) of any project on which PROJ depends (either + directly or indirectly). + +  + File: gnat_ug_vms.info, Node: Basic Syntax, Next: Packages, Up: Project File Syntax + + Basic Syntax + ------------ + + As seen in the earlier examples, project files have an Ada-like syntax. + The minimal project file is: + project Empty is + + end Empty; + + The identifier `Empty' is the name of the project. This project name + must be present after the reserved word `end' at the end of the project + file, followed by a semi-colon. + + Any name in a project file, such as the project name or a variable + name, has the same syntax as an Ada identifier. + + The reserved words of project files are the Ada reserved words plus + `extends', `external', and `project'. Note that the only Ada reserved + words currently used in project file syntax are: + + * `case' + + * `end' + + * `for' + + * `is' + + * `others' + + * `package' + + * `renames' + + * `type' + + * `use' + + * `when' + + * `with' + + Comments in project files have the same syntax as in Ada, two + consecutives hyphens through the end of the line. + +  + File: gnat_ug_vms.info, Node: Packages, Next: Expressions, Prev: Basic Syntax, Up: Project File Syntax + + Packages + -------- + + A project file may contain _packages_. The name of a package must be one + of the identifiers (case insensitive) from a predefined list, and a + package with a given name may only appear once in a project file. The + predefined list includes the following packages: + + * `Naming' + + * `Builder' + + * `Compiler' + + * `Binder' + + * `Linker' + + * `Finder' + + * `Cross_Reference' + + * `GNAT LIST' + + (The complete list of the package names and their attributes can be + found in file `PRJ-ATTR.ADB'). + + In its simplest form, a package may be empty: + + project Simple is + package Builder is + end Builder; + end Simple; + + A package may contain _attribute declarations_, _variable declarations_ + and _case constructions_, as will be described below. + + When there is ambiguity between a project name and a package name, + the name always designates the project. To avoid possible confusion, it + is always a good idea to avoid naming a project with one of the names + allowed for packages or any name that starts with `gnat'. + +  + File: gnat_ug_vms.info, Node: Expressions, Next: String Types, Prev: Packages, Up: Project File Syntax + + Expressions + ----------- + + An _expression_ is either a _string expression_ or a _string list + expression_. + + A _string expression_ is either a _simple string expression_ or a + _compound string expression_. + + A _simple string expression_ is one of the following: + * A literal string; e.g.`"comm/my_proj.gpr"' + + * A string-valued variable reference (see *Note Variables::) + + * A string-valued attribute reference (see *Note Attributes::) + + * An external reference (see *Note External References in Project + Files::) + + A _compound string expression_ is a concatenation of string expressions, + using `"&"' + Path & "/" & File_Name & ".ADS" + + A _string list expression_ is either a _simple string list expression_ + or a _compound string list expression_. + + A _simple string list expression_ is one of the following: + * A parenthesized list of zero or more string expressions, separated + by commas + File_Names := (File_Name, "GNAT.ADC", File_Name & ".orig"); + Empty_List := (); + + * A string list-valued variable reference + + * A string list-valued attribute reference + + A _compound string list expression_ is the concatenation (using `"&"') + of a simple string list expression and an expression. Note that each + term in a compound string list expression, except the first, may be + either a string expression or a string list expression. + + File_Name_List := () & File_Name; -- One string in this list + Extended_File_Name_List := File_Name_List & (File_Name & ".orig"); + -- Two strings + Big_List := File_Name_List & Extended_File_Name_List; + -- Concatenation of two string lists: three strings + Illegal_List := "GNAT.ADC" & Extended_File_Name_List; + -- Illegal: must start with a string list + +  + File: gnat_ug_vms.info, Node: String Types, Next: Variables, Prev: Expressions, Up: Project File Syntax + + String Types + ------------ + + The value of a variable may be restricted to a list of string literals. + The restricted list of string literals is given in a _string type + declaration_. + + Here is an example of a string type declaration: + + type OS is ("NT, "nt", "Unix", "Linux", "other OS"); + + Variables of a string type are called _typed variables_; all other + variables are called _untyped variables_. Typed variables are + particularly useful in `case' constructions (see *Note case + Constructions::). + + A string type declaration starts with the reserved word `type', + followed by the name of the string type (case-insensitive), followed by + the reserved word `is', followed by a parenthesized list of one or more + string literals separated by commas, followed by a semicolon. + + The string literals in the list are case sensitive and must all be + different. They may include any graphic characters allowed in Ada, + including spaces. + + A string type may only be declared at the project level, not inside + a package. + + A string type may be referenced by its name if it has been declared + in the same project file, or by its project name, followed by a dot, + followed by the string type name. + +  + File: gnat_ug_vms.info, Node: Variables, Next: Attributes, Prev: String Types, Up: Project File Syntax + + Variables + --------- + + A variable may be declared at the project file level, or in a package. + Here are some examples of variable declarations: + + This_OS : OS := external ("OS"); -- a typed variable declaration + That_OS := "Linux"; -- an untyped variable declaration + + A _typed variable declaration_ includes the variable name, followed by + a colon, followed by the name of a string type, followed by `:=', + followed by a simple string expression. + + An _untyped variable declaration_ includes the variable name, + followed by `:=', followed by an expression. Note that, despite the + terminology, this form of "declaration" resembles more an assignment + than a declaration in Ada. It is a declaration in several senses: + * The variable name does not need to be defined previously + + * The declaration establishes the _kind_ (string versus string list) + of the variable, and later declarations of the same variable need + to be consistent with this + + A string variable declaration (typed or untyped) declares a variable + whose value is a string. This variable may be used as a string + expression. + File_Name := "readme.txt"; + Saved_File_Name := File_Name & ".saved"; + + A string list variable declaration declares a variable whose value is a + list of strings. The list may contain any number (zero or more) of + strings. + + Empty_List := (); + List_With_One_Element := ("/STYLE="); + List_With_Two_Elements := List_With_One_Element & "/STYLE=GNAT"; + Long_List := ("MAIN.ADA", "PACK1_.ADA", "PACK1.ADA", "PACK2_.ADA" + "PACK2.ADA", "UTIL_.ADA", "UTIL.ADA"); + + The same typed variable may not be declared more than once at project + level, and it may not be declared more than once in any package; it is + in effect a constant or a readonly variable. + + The same untyped variable may be declared several times. In this + case, the new value replaces the old one, and any subsequent reference + to the variable uses the new value. However, as noted above, if a + variable has been declared as a string, all subsequent declarations + must give it a string value. Similarly, if a variable has been declared + as a string list, all subsequent declarations must give it a string + list value. + + A _variable reference_ may take several forms: + + * The simple variable name, for a variable in the current package + (if any) or in the current project + + * A context name, followed by a dot, followed by the variable name. + + A _context_ may be one of the following: + + * The name of an existing package in the current project + + * The name of an imported project of the current project + + * The name of an ancestor project (i.e., a project extended by the + current project, either directly or indirectly) + + * An imported/parent project name, followed by a dot, followed by a + package name + + A variable reference may be used in an expression. + +  + File: gnat_ug_vms.info, Node: Attributes, Next: Associative Array Attributes, Prev: Variables, Up: Project File Syntax + + Attributes + ---------- + + A project (and its packages) may have _attributes_ that define the + project's properties. Some attributes have values that are strings; + others have values that are string lists. + + There are two categories of attributes: _simple attributes_ and + _associative arrays_ (see *Note Associative Array Attributes::). + + The names of the attributes are restricted; there is a list of + project attributes, and a list of package attributes for each package. + The names are not case sensitive. + + The project attributes are as follows (all are simple attributes): + + _Attribute Name_ _Value_ + `Source_Files' string list + `Source_Dirs' string list + `Source_List_File' string + `Object_Dir' string + `Exec_Dir' string + `Main' string list + `Languages' string list + `Library_Dir' string + `Library_Name' string + `Library_Kind' string + `Library_Elaboration' string + `Library_Version' string + + The attributes for package `Naming' are as follows (see *Note Naming + Schemes::): + + Attribute Name Category Index Value + `Specification_Suffix' associative language name string + array + `Implementation_Suffix' associative language name string + array + `Separate_Suffix' simple n/a string + attribute + `Casing' simple n/a string + attribute + `Dot_Replacement' simple n/a string + attribute + `Specification' associative Ada unit name string + array + `Implementation' associative Ada unit name string + array + `Specification_Exceptions' associative language name string list + array + `Implementation_Exceptions' associative language name string list + array + + The attributes for package `Builder', `Compiler', `Binder', `Linker', + `Cross_Reference', and `Finder' are as follows (see *Note Qualifiers + and Project Files::). + + Attribute Name Category Index Value + `Default_Qualifiers' associative language name string list + array + `Qualifiers' associative file name string list + array + + In addition, package `Builder' has a single string attribute + `Local_Configuration_Pragmas' and package `Builder' has a single string + attribute `Global_Configuration_Pragmas'. + + The attribute for package `Glide' are not documented: they are for + internal use only. + + Each simple attribute has a default value: the empty string (for + string-valued attributes) and the empty list (for string list-valued + attributes). + + Similar to variable declarations, an attribute declaration defines a + new value for an attribute. + + Examples of simple attribute declarations: + + for Object_Dir use "objects"; + for Source_Dirs use ("units", "test/drivers"); + + A "simple attribute declaration" starts with the reserved word `for', + followed by the name of the attribute, followed by the reserved word + `use', followed by an expression (whose kind depends on the attribute), + followed by a semicolon. + + Attributes may be referenced in expressions. The general form for + such a reference is `'': the entity for which the + attribute is defined, followed by an apostrophe, followed by the name + of the attribute. For associative array attributes, a litteral string + between parentheses need to be supplied as index. + + Examples are: + + project'Object_Dir + Naming'Dot_Replacement + Imported_Project'Source_Dirs + Imported_Project.Naming'Casing + Builder'Default_Qualifiers("Ada") + + The entity may be: + * `project' for an attribute of the current project + + * The name of an existing package of the current project + + * The name of an imported project + + * The name of a parent project (extended by the current project) + + * An imported/parent project name, followed by a dot, followed + by a package name + + Example: + project Prj is + for Source_Dirs use project'Source_Dirs & "units"; + for Source_Dirs use project'Source_Dirs & "test/drivers" + end Prj; + + In the first attribute declaration, initially the attribute + `Source_Dirs' has the default value: an empty string list. After this + declaration, `Source_Dirs' is a string list of one element: "units". + After the second attribute declaration `Source_Dirs' is a string list of + two elements: "units" and "test/drivers". + + Note: this example is for illustration only. In practice, the + project file would contain only one attribute declaration: + + for Source_Dirs use ("units", "test/drivers"); + +  + File: gnat_ug_vms.info, Node: Associative Array Attributes, Next: case Constructions, Prev: Attributes, Up: Project File Syntax + + Associative Array Attributes + ---------------------------- + + Some attributes are defined as _associative arrays_. An associative + array may be regarded as a function that takes a string as a parameter + and delivers a string or string list value as its result. + + Here are some examples of associative array attribute declarations: + + for Implementation ("main") use "MAIN.ADA"; + for Qualifiers ("MAIN.ADA") use ("-v", "/REPORT_ERRORS=VERBOSE"); + for Qualifiers ("MAIN.ADA") use Builder'Qualifiers ("MAIN.ADA") & "-g"; + + Like untyped variables and simple attributes, associative array + attributes may be declared several times. Each declaration supplies a + new value for the attribute, replacing the previous setting. + +  + File: gnat_ug_vms.info, Node: case Constructions, Prev: Associative Array Attributes, Up: Project File Syntax + + `case' Constructions + -------------------- + + A `case' construction is used in a project file to effect conditional + behavior. Here is a typical example: + + project MyProj is + type OS_Type is ("Linux", "Unix", "NT", "VMS"); + + OS : OS_Type := external ("OS", "Linux"); + + package Compiler is + case OS is + when "Linux" | "Unix" => + for Default_Qualifiers ("Ada") use ("-gnath"); + when "NT" => + for Default_Qualifiers ("Ada") use ("/POLLING_ENABLE"); + when others => + end case; + end Compiler; + end MyProj; + + The syntax of a `case' construction is based on the Ada case statement + (although there is no `null' construction for empty alternatives). + + Following the reserved word `case' there is the case variable (a + typed string variable), the reserved word `is', and then a sequence of + one or more alternatives. Each alternative comprises the reserved word + `when', either a list of literal strings separated by the `"|"' + character or the reserved word `others', and the `"=>"' token. Each + literal string must belong to the string type that is the type of the + case variable. An `others' alternative, if present, must occur last. + The `end case;' sequence terminates the case construction. + + After each `=>', there are zero or more constructions. The only + constructions allowed in a case construction are other case + constructions and attribute declarations. String type declarations, + variable declarations and package declarations are not allowed. + + The value of the case variable is often given by an external + reference (see *Note External References in Project Files::). + +  + File: gnat_ug_vms.info, Node: Objects and Sources in Project Files, Next: Importing Projects, Prev: Project File Syntax, Up: GNAT Project Manager + + Objects and Sources in Project Files + ==================================== + + * Menu: + + * Object Directory:: + * Exec Directory:: + * Source Directories:: + * Source File Names:: + + Each project has exactly one object directory and one or more source + directories. The source directories must contain at least one source + file, unless the project file explicitly specifies that no source + files are present (see *Note Source File Names::). + +  + File: gnat_ug_vms.info, Node: Object Directory, Next: Exec Directory, Up: Objects and Sources in Project Files + + Object Directory + ---------------- + + The object directory for a project is the directory containing the + compiler's output (such as `ALI' files and object files) for the + project's immediate sources. Note that for inherited sources (when + extending a parent project) the parent project's object directory is + used. + + The object directory is given by the value of the attribute + `Object_Dir' in the project file. + + for Object_Dir use "objects"; + + The attribute OBJECT_DIR has a string value, the path name of the object + directory. The path name may be absolute or relative to the directory + of the project file. This directory must already exist, and be readable + and writable. + + By default, when the attribute `Object_Dir' is not given an explicit + value or when its value is the empty string, the object directory is + the same as the directory containing the project file. + +  + File: gnat_ug_vms.info, Node: Exec Directory, Next: Source Directories, Prev: Object Directory, Up: Objects and Sources in Project Files + + Exec Directory + -------------- + + The exec directory for a project is the directory containing the + executables for the project's main subprograms. + + The exec directory is given by the value of the attribute `Exec_Dir' + in the project file. + + for Exec_Dir use "executables"; + + The attribute EXEC_DIR has a string value, the path name of the exec + directory. The path name may be absolute or relative to the directory + of the project file. This directory must already exist, and be writable. + + By default, when the attribute `Exec_Dir' is not given an explicit + value or when its value is the empty string, the exec directory is the + same as the object directory of the project file. + +  + File: gnat_ug_vms.info, Node: Source Directories, Next: Source File Names, Prev: Exec Directory, Up: Objects and Sources in Project Files + + Source Directories + ------------------ + + The source directories of a project are specified by the project file + attribute `Source_Dirs'. + + This attribute's value is a string list. If the attribute is not + given an explicit value, then there is only one source directory, the + one where the project file resides. + + A `Source_Dirs' attribute that is explicitly defined to be the empty + list, as in + + for Source_Dirs use (); + + indicates that the project contains no source files. + + Otherwise, each string in the string list designates one or more + source directories. + + for Source_Dirs use ("sources", "test/drivers"); + + If a string in the list ends with `"/**"', then the directory whose + path name precedes the two asterisks, as well as all its subdirectories + (recursively), are source directories. + + for Source_Dirs use ("/system/sources/**"); + + Here the directory `/system/sources' and all of its subdirectories + (recursively) are source directories. + + To specify that the source directories are the directory of the + project file and all of its subdirectories, you can declare + `Source_Dirs' as follows: + for Source_Dirs use ("./**"); + + Each of the source directories must exist and be readable. + +  + File: gnat_ug_vms.info, Node: Source File Names, Prev: Source Directories, Up: Objects and Sources in Project Files + + Source File Names + ----------------- + + In a project that contains source files, their names may be specified + by the attributes `Source_Files' (a string list) or `Source_List_File' + (a string). Source file names never include any directory information. + + If the attribute `Source_Files' is given an explicit value, then each + element of the list is a source file name. + + for Source_Files use ("MAIN.ADB"); + for Source_Files use ("MAIN.ADB", "PACK1.ADS", "PACK2.ADB"); + + If the attribute `Source_Files' is not given an explicit value, but the + attribute `Source_List_File' is given a string value, then the source + file names are contained in the text file whose path name (absolute or + relative to the directory of the project file) is the value of the + attribute `Source_List_File'. + + Each line in the file that is not empty or is not a comment contains + a source file name. A comment line starts with two hyphens. + + for Source_List_File use "source_list.txt"; + + By default, if neither the attribute `Source_Files' nor the attribute + `Source_List_File' is given an explicit value, then each file in the + source directories that conforms to the project's naming scheme (see + *Note Naming Schemes::) is an immediate source of the project. + + A warning is issued if both attributes `Source_Files' and + `Source_List_File' are given explicit values. In this case, the + attribute `Source_Files' prevails. + + Each source file name must be the name of one and only one existing + source file in one of the source directories. + + A `Source_Files' attribute defined with an empty list as its value + indicates that there are no source files in the project. + + Except for projects that are clearly specified as containing no Ada + source files (`Source_Dirs' or `Source_Files' specified as an empty + list, or `Languages' specified without `"Ada"' in the list) + for Source_Dirs use (); + for Source_Files use (); + for Languages use ("C", "C++"); + + a project must contain at least one immediate source. + + Projects with no source files are useful as template packages (see + *Note Packages in Project Files::) for other projects; in particular to + define a package `Naming' (see *Note Naming Schemes::). + +  + File: gnat_ug_vms.info, Node: Importing Projects, Next: Project Extension, Prev: Objects and Sources in Project Files, Up: GNAT Project Manager + + Importing Projects + ================== + + An immediate source of a project P may depend on source files that are + neither immediate sources of P nor in the predefined library. To get + this effect, P must _import_ the projects that contain the needed + source files. + + with "project1", "utilities.gpr"; + with "/namings/apex.gpr"; + project Main is + ... + + As can be seen in this example, the syntax for importing projects is + similar to the syntax for importing compilation units in Ada. However, + project files use literal strings instead of names, and the `with' + clause identifies project files rather than packages. + + Each literal string is the file name or path name (absolute or + relative) of a project file. If a string is simply a file name, with no + path, then its location is determined by the _project path_: + + * If the environment variable `ADA_PROJECT_PATH' exists, then the + project path includes all the directories in this environment + variable, plus the directory of the project file. + + * If the environment variable `ADA_PROJECT_PATH' does not exist, + then the project path contains only one directory, namely the one + where the project file is located. + + If a relative pathname is used as in + + with "tests/proj"; + + then the path is relative to the directory where the importing project + file is located. Any symbolic link will be fully resolved in the + directory of the importing project file before the imported project + file is looked up. + + When the `with''ed project file name does not have an extension, the + default is `.gpr'. If a file with this extension is not found, then the + file name as specified in the `with' clause (no extension) will be + used. In the above example, if a file `project1.gpr' is found, then it + will be used; otherwise, if a file `project1' exists then it will be + used; if neither file exists, this is an error. + + A warning is issued if the name of the project file does not match + the name of the project; this check is case insensitive. + + Any source file that is an immediate source of the imported project + can be used by the immediate sources of the importing project, and + recursively. Thus if `A' imports `B', and `B' imports `C', the immediate + sources of `A' may depend on the immediate sources of `C', even if `A' + does not import `C' explicitly. However, this is not recommended, + because if and when `B' ceases to import `C', some sources in `A' will + no longer compile. + + A side effect of this capability is that cyclic dependences are not + permitted: if `A' imports `B' (directly or indirectly) then `B' is not + allowed to import `A'. + +  + File: gnat_ug_vms.info, Node: Project Extension, Next: External References in Project Files, Prev: Importing Projects, Up: GNAT Project Manager + + Project Extension + ================= + + During development of a large system, it is sometimes necessary to use + modified versions of some of the source files without changing the + original sources. This can be achieved through a facility known as + _project extension_. + + project Modified_Utilities extends "/baseline/utilities.gpr" is ... + + The project file for the project being extended (the _parent_) is + identified by the literal string that follows the reserved word + `extends', which itself follows the name of the extending project (the + _child_). + + By default, a child project inherits all the sources of its parent. + However, inherited sources can be overridden: a unit with the same name + as one in the parent will hide the original unit. Inherited sources + are considered to be sources (but not immediate sources) of the child + project; see *Note Project File Syntax::. + + An inherited source file retains any qualifiers specified in the + parent project. + + For example if the project `Utilities' contains the specification + and the body of an Ada package `Util_IO', then the project + `Modified_Utilities' can contain a new body for package `Util_IO'. The + original body of `Util_IO' will not be considered in program builds. + However, the package specification will still be found in the project + `Utilities'. + + A child project can have only one parent but it may import any + number of other projects. + + A project is not allowed to import directly or indirectly at the + same time a child project and any of its ancestors. + +  + File: gnat_ug_vms.info, Node: External References in Project Files, Next: Packages in Project Files, Prev: Project Extension, Up: GNAT Project Manager + + External References in Project Files + ==================================== + + A project file may contain references to external variables; such + references are called _external references_. + + An external variable is either defined as part of the environment (an + environment variable in Unix, for example) or else specified on the + command line via the `-X_vbl_=_value_' qualifier. If both, then the + command line value is used. + + An external reference is denoted by the built-in function + `external', which returns a string value. This function has two forms: + * `external (external_variable_name)' + + * `external (external_variable_name, default_value)' + + Each parameter must be a string literal. For example: + + external ("USER") + external ("OS", "Linux") + + In the form with one parameter, the function returns the value of the + external variable given as parameter. If this name is not present in the + environment, then the returned value is an empty string. + + In the form with two string parameters, the second parameter is the + value returned when the variable given as the first parameter is not + present in the environment. In the example above, if `"OS"' is not the + name of an environment variable and is not passed on the command line, + then the returned value will be `"Linux"'. + + An external reference may be part of a string expression or of a + string list expression, to define variables or attributes. + + type Mode_Type is ("Debug", "Release"); + Mode : Mode_Type := external ("MODE"); + case Mode is + when "Debug" => + ... + +  + File: gnat_ug_vms.info, Node: Packages in Project Files, Next: Variables from Imported Projects, Prev: External References in Project Files, Up: GNAT Project Manager + + Packages in Project Files + ========================= + + The _package_ is the project file feature that defines the settings for + project-aware tools. For each such tool you can declare a + corresponding package; the names for these packages are preset (see + *Note Packages::) but are not case sensitive. A package may contain + variable declarations, attribute declarations, and case constructions. + + project Proj is + package Builder is -- used by GNAT MAKE + for Default_Qualifiers ("Ada") use ("-v", "-g"); + end Builder; + end Proj; + + A package declaration starts with the reserved word `package', followed + by the package name (case insensitive), followed by the reserved word + `is'. It ends with the reserved word `end', followed by the package + name, finally followed by a semi-colon. + + Most of the packages have an attribute `Default_Qualifiers'. This + attribute is an associative array, and its value is a string list. The + index of the associative array is the name of a programming language + (case insensitive). This attribute indicates the qualifier or + qualifiers to be used with the corresponding tool. + + Some packages also have another attribute, `Qualifiers', an + associative array whose value is a string list. The index is the name + of a source file. This attribute indicates the qualifier or qualifiers + to be used by the corresponding tool when dealing with this specific + file. + + Further information on these qualifier-related attributes is found in + *Note Qualifiers and Project Files::. + + A package may be declared as a _renaming_ of another package; e.g., + from the project file for an imported project. + + with "/global/apex.gpr"; + project Example is + package Naming renames Apex.Naming; + ... + end Example; + + Packages that are renamed in other project files often come from + project files that have no sources: they are just used as templates. + Any modification in the template will be reflected automatically in all + the project files that rename a package from the template. + + In addition to the tool-oriented packages, you can also declare a + package named `Naming' to establish specialized source file naming + conventions (see *Note Naming Schemes::). + +  + File: gnat_ug_vms.info, Node: Variables from Imported Projects, Next: Naming Schemes, Prev: Packages in Project Files, Up: GNAT Project Manager + + Variables from Imported Projects + ================================ + + An attribute or variable defined in an imported or parent project can + be used in expressions in the importing / extending project. Such an + attribute or variable is prefixed with the name of the project and (if + relevant) the name of package where it is defined. + + with "imported"; + project Main extends "base" is + Var1 := Imported.Var; + Var2 := Base.Var & ".new"; + + package Builder is + for Default_Qualifiers ("Ada") use Imported.Builder.Ada_Qualifiers & + "/STYLE=GNAT" & "-v"; + end Builder; + + package Compiler is + for Default_Qualifiers ("Ada") use Base.Compiler.Ada_Qualifiers; + end Compiler; + end Main; + + In this example: + + * `Var1' is a copy of the variable `Var' defined in the project file + `"imported.gpr"' + + * the value of `Var2' is a copy of the value of variable `Var' + defined in the project file `base.gpr', concatenated with `".new"' + + * attribute `Default_Qualifiers ("Ada")' in package `Builder' is a + string list that includes in its value a copy of variable + `Ada_Qualifiers' defined in the `Builder' package in project file + `imported.gpr' plus two new elements: `"/STYLE=GNAT"' and `"-v"'; + + * attribute `Default_Qualifiers ("Ada")' in package `Compiler' is a + copy of the variable `Ada_Qualifiers' defined in the `Compiler' + package in project file `base.gpr', the project being extended. + +  + File: gnat_ug_vms.info, Node: Naming Schemes, Next: Library Projects, Prev: Variables from Imported Projects, Up: GNAT Project Manager + + Naming Schemes + ============== + + Sometimes an Ada software system is ported from a foreign compilation + environment to GNAT, with file names that do not use the default GNAT + conventions. Instead of changing all the file names (which for a + variety of reasons might not be possible), you can define the relevant + file naming scheme in the `Naming' package in your project file. For + example, the following package models the Apex file naming rules: + + package Naming is + for Casing use "lowercase"; + for Dot_Replacement use "."; + for Specification_Suffix ("Ada") use ".1.ADA"; + for Implementation_Suffix ("Ada") use ".2.ADA"; + end Naming; + + You can define the following attributes in package `Naming': + + `CASING' + This must be a string with one of the three values `"lowercase"', + `"uppercase"' or `"mixedcase"'; these strings are case insensitive. + + If CASING is not specified, then the default is `"lowercase"'. + + `DOT_REPLACEMENT' + This must be a string whose value satisfies the following + conditions: + + * It must not be empty + + * It cannot start or end with an alphanumeric character + + * It cannot be a single underscore + + * It cannot start with an underscore followed by an alphanumeric + + * It cannot contain a dot `'.'' except if it the entire string + is `"."' + + If `Dot_Replacement' is not specified, then the default is `"-"'. + + `SPECIFICATION_SUFFIX' + This is an associative array (indexed by the programming language + name, case insensitive) whose value is a string that must satisfy + the following conditions: + + * It must not be empty + + * It cannot start with an alphanumeric character + + * It cannot start with an underscore followed by an + alphanumeric character + + If `Specification_Suffix ("Ada")' is not specified, then the + default is `".ADS"'. + + `IMPLEMENTATION_SUFFIX' + This is an associative array (indexed by the programming language + name, case insensitive) whose value is a string that must satisfy + the following conditions: + + * It must not be empty + + * It cannot start with an alphanumeric character + + * It cannot start with an underscore followed by an + alphanumeric character + + * It cannot be a suffix of `Specification_Suffix' + + If `Implementation_Suffix ("Ada")' is not specified, then the + default is `".ADB"'. + + `SEPARATE_SUFFIX' + This must be a string whose value satisfies the same conditions as + `Implementation_Suffix'. + + If `Separate_Suffix ("Ada")' is not specified, then it defaults to + same value as `Implementation_Suffix ("Ada")'. + + `SPECIFICATION' + You can use the `Specification' attribute, an associative array, + to define the source file name for an individual Ada compilation + unit's spec. The array index must be a string literal that + identifies the Ada unit (case insensitive). The value of this + attribute must be a string that identifies the file that contains + this unit's spec (case sensitive or insensitive depending on the + operating system). + + for Specification ("MyPack.MyChild") use "mypack.mychild.spec"; + + `IMPLEMENTATION' + You can use the `Implementation' attribute, an associative array, + to define the source file name for an individual Ada compilation + unit's body (possibly a subunit). The array index must be a + string literal that identifies the Ada unit (case insensitive). + The value of this attribute must be a string that identifies the + file that contains this unit's body or subunit (case sensitive or + insensitive depending on the operating system). + + for Implementation ("MyPack.MyChild") use "mypack.mychild.body"; + +  + File: gnat_ug_vms.info, Node: Library Projects, Next: Qualifiers Related to Project Files, Prev: Naming Schemes, Up: GNAT Project Manager + + Library Projects + ================ + + _Library projects_ are projects whose object code is placed in a + library. (Note that this facility is not yet supported on all + platforms) + + To create a library project, you need to define in its project file + two project-level attributes: `Library_Name' and `Library_Dir'. + Additionally, you may define the library-related attributes + `Library_Kind', `Library_Version' and `Library_Elaboration'. + + The `Library_Name' attribute has a string value that must start with + a letter and include only letters and digits. + + The `Library_Dir' attribute has a string value that designates the + path (absolute or relative) of the directory where the library will + reside. It must designate an existing directory, and this directory + needs to be different from the project's object directory. It also + needs to be writable. + + If both `Library_Name' and `Library_Dir' are specified and are + legal, then the project file defines a library project. The optional + library-related attributes are checked only for such project files. + + The `Library_Kind' attribute has a string value that must be one of + the following (case insensitive): `"static"', `"dynamic"' or + `"relocatable"'. If this attribute is not specified, the library is a + static library. Otherwise, the library may be dynamic or relocatable. + Depending on the operating system, there may or may not be a distinction + between dynamic and relocatable libraries. For example, on Unix there + is no such distinction. + + The `Library_Version' attribute has a string value whose + interpretation is platform dependent. On Unix, it is used only for + dynamic/relocatable libraries as the internal name of the library (the + `"soname"'). If the library file name (built from the `Library_Name') + is different from the `Library_Version', then the library file will be + a symbolic link to the actual file whose name will be `Library_Version'. + + Example (on Unix): + + project Plib is + + Version := "1"; + + for Library_Dir use "lib_dir"; + for Library_Name use "dummy"; + for Library_Kind use "relocatable"; + for Library_Version use "libdummy.so." & Version; + + end Plib; + + Directory `lib_dir' will contain the internal library file whose name + will be `libdummy.so.1', and `libdummy.so' will be a symbolic link to + `libdummy.so.1'. + + When `GNAT MAKE' detects that a project file (not the main project + file) is a library project file, it will check all immediate sources of + the project and rebuild the library if any of the sources have been + recompiled. All `ALI' files will also be copied from the object + directory to the library directory. To build executables, `GNAT MAKE' + will use the library rather than the individual object files. + +  + File: gnat_ug_vms.info, Node: Qualifiers Related to Project Files, Next: Tools Supporting Project Files, Prev: Library Projects, Up: GNAT Project Manager + + Qualifiers Related to Project Files + =================================== + + The following qualifiers are used by GNAT tools that support project + files: + + ``-PPROJECT'' + Indicates the name of a project file. This project file will be + parsed with the verbosity indicated by `-vP_x_', if any, and using + the external references indicated by `-X' qualifiers, if any. + + There must be only one `-P' qualifier on the command line. + + Since the Project Manager parses the project file only after all + the qualifiers on the command line are checked, the order of the + qualifiers `-P', `-Vp_x_' or `-X' is not significant. + + ``-XNAME=VALUE'' + Indicates that external variable NAME has the value VALUE. The + Project Manager will use this value for occurrences of + `external(name)' when parsing the project file. + + If NAME or VALUE includes a space, then NAME=VALUE should be put + between quotes. + -XOS=NT + -X"user=John Doe" + + Several `-X' qualifiers can be used simultaneously. If several + `-X' qualifiers specify the same NAME, only the last one is used. + + An external variable specified with a `-X' qualifier takes + precedence over the value of the same name in the environment. + + ``-vP_x_'' + Indicates the verbosity of the parsing of GNAT project files. + `-vP0' means Default (no output for syntactically correct project + files); `-vP1' means Medium; `-vP2' means High. + + The default is Default. + + If several `-vP_x_' qualifiers are present, only the last one is + used. + +  + File: gnat_ug_vms.info, Node: Tools Supporting Project Files, Next: An Extended Example, Prev: Qualifiers Related to Project Files, Up: GNAT Project Manager + + Tools Supporting Project Files + ============================== + + * Menu: + + * GNAT MAKE and Project Files:: + * The GNAT Driver and Project Files:: + +  + File: gnat_ug_vms.info, Node: GNAT MAKE and Project Files, Next: The GNAT Driver and Project Files, Up: Tools Supporting Project Files + + GNAT MAKE and Project Files + --------------------------- + + This section covers two topics related to `GNAT MAKE' and project files: + defining qualifiers for `GNAT MAKE' and for the tools that it invokes; + and the use of the `Main' attribute. + + * Menu: + + * Qualifiers and Project Files:: + * Project Files and Main Subprograms:: + +  + File: gnat_ug_vms.info, Node: Qualifiers and Project Files, Next: Project Files and Main Subprograms, Up: GNAT MAKE and Project Files + + Qualifiers and Project Files + ............................ + + For each of the packages `Builder', `Compiler', `Binder', and `Linker', + you can specify a `Default_Qualifiers' attribute, a `Qualifiers' + attribute, or both; as their names imply, these qualifier-related + attributes affect which qualifiers are used for which files when `GNAT + MAKE' is invoked. As will be explained below, these + package-contributed qualifiers precede the qualifiers passed on the + `GNAT MAKE' command line. + + The `Default_Qualifiers' attribute is an associative array indexed by + language name (case insensitive) and returning a string list. For + example: + + package Compiler is + for Default_Qualifiers ("Ada") use ("/STYLE=", "-v"); + end Compiler; + + The `Qualifiers' attribute is also an associative array, indexed by a + file name (which may or may not be case sensitive, depending on the + operating system) and returning a string list. For example: + + package Builder is + for Qualifiers ("MAIN1.ADB") use ("/OPTIMIZE=ALL"); + for Qualifiers ("MAIN2.ADB") use ("-g"); + end Builder; + + For the `Builder' package, the file names should designate source files + for main subprograms. For the `Binder' and `Linker' packages, the file + names should designate `ALI' or source files for main subprograms. In + each case just the file name (without explicit extension) is acceptable. + + For each tool used in a program build (`GNAT MAKE', the compiler, the + binder, and the linker), its corresponding package "contributes" a set + of qualifiers for each file on which the tool is invoked, based on the + qualifier-related attributes defined in the package. In particular, the + qualifiers that each of these packages contributes for a given file F + comprise: + + * the value of attribute `Qualifiers (F)', if it is specified in the + package for the given file, + + * otherwise, the value of `Default_Qualifiers ("Ada")', if it is + specified in the package. + + If neither of these attributes is defined in the package, then the + package does not contribute any qualifiers for the given file. + + When `GNAT MAKE' is invoked on a file, the qualifiers comprise two + sets, in the following order: those contributed for the file by the + `Builder' package; and the qualifiers passed on the command line. + + When `GNAT MAKE' invokes a tool (compiler, binder, linker) on a file, + the qualifiers passed to the tool comprise three sets, in the following + order: + + 1. the applicable qualifiers contributed for the file by the + `Builder' package in the project file supplied on the command line; + + 2. those contributed for the file by the package (in the relevant + project file - see below) corresponding to the tool; and + + 3. the applicable qualifiers passed on the command line. + + The term _applicable qualifiers_ reflects the fact that `GNAT MAKE' + qualifiers may or may not be passed to individual tools, depending on + the individual qualifier. + + `GNAT MAKE' may invoke the compiler on source files from different + projects. The Project Manager will use the appropriate project file to + determine the `Compiler' package for each source file being compiled. + Likewise for the `Binder' and `Linker' packages. + + As an example, consider the following package in a project file: + + project Proj1 is + package Compiler is + for Default_Qualifiers ("Ada") use ("-g"); + for Qualifiers ("A.ADB") use ("/OPTIMIZE=SOME"); + for Qualifiers ("B.ADB") use ("/OPTIMIZE=ALL", "/STYLE="); + end Compiler; + end Proj1; + + If `GNAT MAKE' is invoked with this project file, and it needs to + compile, say, the files `A.ADB', `B.ADB', and `C.ADB', then `A.ADB' + will be compiled with the qualifier `/OPTIMIZE=SOME', `B.ADB' with + qualifiers `/OPTIMIZE=ALL' and `/STYLE=', and `C.ADB' with `-g'. + + Another example illustrates the ordering of the qualifiers + contributed by different packages: + + project Proj2 is + package Builder is + for Qualifiers ("MAIN.ADB") use ("-g", "/OPTIMIZE=SOME", "-f"); + end Builder; + + package Compiler is + for Qualifiers ("MAIN.ADB") use ("/OPTIMIZE=ALL"); + end Compiler; + end Proj2; + + If you issue the command: + + GNAT MAKE -PProj2 /OPTIMIZE=NONE main + + then the compiler will be invoked on `MAIN.ADB' with the following + sequence of qualifiers + + -g /OPTIMIZE=SOME /OPTIMIZE=ALL /OPTIMIZE=NONE + + with the last `-O' qualifier having precedence over the earlier ones; + several other qualifiers (such as `-c') are added implicitly. + + The qualifiers `-g' and `/OPTIMIZE=SOME' are contributed by package + `Builder', `/OPTIMIZE=ALL' is contributed by the package `Compiler' + and `/OPTIMIZE=NONE' comes from the command line. + + The `-g' qualifier will also be passed in the invocation of `GNAT + LINK.' + + A final example illustrates qualifier contributions from packages in + different project files: + + project Proj3 is + for Source_Files use ("PACK.ADS", "PACK.ADB"); + package Compiler is + for Default_Qualifiers ("Ada") use ("/CHECKS=ASSERTIONS"); + end Compiler; + end Proj3; + + with "Proj3"; + project Proj4 is + for Source_Files use ("FOO_MAIN.ADB", "BAR_MAIN.ADB"); + package Builder is + for Qualifiers ("FOO_MAIN.ADB") use ("-s", "-g"); + end Builder; + end Proj4; + + -- Ada source file: + with Pack; + procedure Foo_Main is + ... + end Foo_Main; + + If the command is + GNAT MAKE -PProj4 FOO_MAIN.ADB /COMPILER_QUALIFIERS /CHECKS=OVERFLOW + + then the qualifiers passed to the compiler for `FOO_MAIN.ADB' are `-g' + (contributed by the package `Proj4.Builder') and `/CHECKS=OVERFLOW' + (passed on the command line). When the imported package `Pack' is + compiled, the qualifiers used are `-g' from `Proj4.Builder', + `/CHECKS=ASSERTIONS' (contributed from package `Proj3.Compiler', and + `/CHECKS=OVERFLOW' from the command line. + +  + File: gnat_ug_vms.info, Node: Project Files and Main Subprograms, Prev: Qualifiers and Project Files, Up: GNAT MAKE and Project Files + + Project Files and Main Subprograms + .................................. + + When using a project file, you can invoke `GNAT MAKE' with several main + subprograms, by specifying their source files on the command line. + Each of these needs to be an immediate source file of the project. + + GNAT MAKE -Pprj main1 main2 main3 + + When using a project file, you can also invoke `GNAT MAKE' without + explicitly specifying any main, and the effect depends on whether you + have defined the `Main' attribute. This attribute has a string list + value, where each element in the list is the name of a source file (the + file extension is optional) containing a main subprogram. + + If the `Main' attribute is defined in a project file as a non-empty + string list and the qualifier `-u' is not used on the command line, then + invoking `GNAT MAKE' with this project file but without any main on the + command line is equivalent to invoking `GNAT MAKE' with all the file + names in the `Main' attribute on the command line. + + Example: + project Prj is + for Main use ("main1", "main2", "main3"); + end Prj; + + With this project file, `"GNAT MAKE -Pprj"' is equivalent to `"GNAT + MAKE -Pprj main1 main2 main3"'. + + When the project attribute `Main' is not specified, or is specified + as an empty string list, or when the qualifier `-u' is used on the + command line, then invoking `GNAT MAKE' with no main on the command + line will result in all immediate sources of the project file being + checked, and potentially recompiled. Depending on the presence of the + qualifier `-u', sources from other project files on which the immediate + sources of the main project file depend are also checked and + potentially recompiled. In other words, the `-u' qualifier is applied + to all of the immediate sources of themain project file. + +  + File: gnat_ug_vms.info, Node: The GNAT Driver and Project Files, Prev: GNAT MAKE and Project Files, Up: Tools Supporting Project Files + + The GNAT Driver and Project Files + --------------------------------- + + A number of GNAT tools, other than `GNAT MAKE' are project-aware: `GNAT + BIND', `GNAT FIND', `GNAT LINK', `GNAT LIST' and `GNAT XREF'. However, + none of these tools can be invoked directly with a project file + qualifier (`-P'). They need to be invoke through the `gnat' driver. + + The `gnat' driver is a front-end that accepts a number of commands + and call the corresponding tool. It has been designed initially for VMS + to convert VMS style qualifiers to Unix style qualifiers, but it is now + available to all the GNAT supported platforms. + + On non VMS platforms, the `gnat' driver accepts the following + commands (case insensitive): + + * BIND to invoke `GNAT BIND' + + * CHOP to invoke `GNAT CHOP' + + * COMP or COMPILE to invoke the compiler + + * ELIM to invoke `GNAT ELIM' + + * FIND to invoke `GNAT FIND' + + * KR or KRUNCH to invoke `GNAT KRUNCH' + + * LINK to invoke `GNAT LINK' + + * LS or LIST to invoke `GNAT LIST' + + * MAKE to invoke `GNAT MAKE' + + * NAME to invoke `gnatname' + + * PREP or PREPROCESS to invoke `GNAT PREPROCESS' + + * PSTA or STANDARD to invoke `GNAT STANDARD' + + * STUB to invoke `GNAT STUB' + + * XREF to invoke `GNAT XREF' + + Note that the compiler is invoked using the command `GNAT MAKE -f -u'. + + Following the command, you may put qualifiers and arguments for the + invoked tool. + + gnat bind -C MAIN.ALI + gnat ls -a main + gnat chop foo.txt + + In addition, for command BIND, FIND, LS or LIST, LINK and XREF, the + project file related qualifiers (`-P', `-X' and `-vPx') may be used in + addition to the qualifiers of the invoking tool. + + For each of these command, there is possibly a package in the main + project that corresponds to the invoked tool. + + * package `Binder' for command BIND (invoking `GNAT BIND') + + * package `Finder' for command FIND (invoking `GNAT FIND') + + * package `GNAT LIST' for command LS or LIST (invoking `GNAT LIST') + + * package `Linker' for command LINK (invoking `GNAT LINK') + + * package `Cross_Reference' for command XREF (invoking `GNAT LINK') + + + Package `GNAT LIST' has a unique attribute `Qualifiers', a simple + variable with a string list value. It contains qualifiers for the + invocation of `GNAT LIST'. + + project Proj1 is + package GNAT LIST is + for Qualifiers use ("-a", "-v"); + end GNAT LIST; + end Proj1; + + All other packages contains a qualifier `Default_Qualifiers', an + associative array, indexed by the programming language (case + insensitive) and having a string list value. `Default_Qualifiers + ("Ada")' contains the qualifiers for the invocation of the tool + corresponding to the package. + + project Proj is + + for Source_Dirs use ("./**"); + + package GNAT LIST is + for Qualifiers use ("-a", "-v"); + end GNAT LIST; + + package Binder is + for Default_Qualifiers ("Ada") use ("-C", "-e"); + end Binder; + + package Linker is + for Default_Qualifiers ("Ada") use ("-C"); + end Linker; + + package Finder is + for Default_Qualifiers ("Ada") use ("-a", "-f"); + end Finder; + + package Cross_Reference is + for Default_Qualifiers ("Ada") use ("-a", "-f", "-d", "-u"); + end Cross_Reference; + end Proj; + + With the above project file, commands such as + + gnat ls -Pproj main + gnat xref -Pproj main + gnat bind -Pproj MAIN.ALI + + will set up the environment properly and invoke the tool with the + qualifiers found in the package corresponding to the tool. + +  + File: gnat_ug_vms.info, Node: An Extended Example, Next: Project File Complete Syntax, Prev: Tools Supporting Project Files, Up: GNAT Project Manager + + An Extended Example + =================== + + Suppose that we have two programs, PROG1 and PROG2, with the sources in + the respective directories. We would like to build them with a single + `GNAT MAKE' command, and we would like to place their object files into + `.build' subdirectories of the source directories. Furthermore, we would + like to have to have two separate subdirectories in `.build' - + `release' and `debug' - which will contain the object files compiled + with different set of compilation flags. + + In other words, we have the following structure: + + main + |- prog1 + | |- .build + | | debug + | | release + |- prog2 + |- .build + | debug + | release + + Here are the project files that we need to create in a directory `main' + to maintain this structure: + + 1. We create a `Common' project with a package `Compiler' that + specifies the compilation qualifiers: + + File "common.gpr": + project Common is + + for Source_Dirs use (); -- No source files + + type Build_Type is ("release", "debug"); + Build : Build_Type := External ("BUILD", "debug"); + package Compiler is + case Build is + when "release" => + for Default_Qualifiers ("Ada") use ("/OPTIMIZE=ALL"); + when "debug" => + for Default_Qualifiers ("Ada") use ("-g"); + end case; + end Compiler; + + end Common; + + 2. We create separate projects for the two programs: + + File "prog1.gpr": + + with "common"; + project Prog1 is + + for Source_Dirs use ("prog1"); + for Object_Dir use "prog1/.build/" & Common.Build; + + package Compiler renames Common.Compiler; + + end Prog1; + + File "prog2.gpr": + + with "common"; + project Prog2 is + + for Source_Dirs use ("prog2"); + for Object_Dir use "prog2/.build/" & Common.Build; + + package Compiler renames Common.Compiler; + end Prog2; + + 3. We create a wrapping project MAIN: + + File "main.gpr": + + with "common"; + with "prog1"; + with "prog2"; + project Main is + + package Compiler renames Common.Compiler; + + end Main; + + 4. Finally we need to create a dummy procedure that `with's (either + explicitly or implicitly) all the sources of our two programs. + + + Now we can build the programs using the command + + GNAT MAKE -Pmain dummy + + for the Debug mode, or + + GNAT MAKE -Pmain -XBUILD=release + + for the Release mode. + +  + File: gnat_ug_vms.info, Node: Project File Complete Syntax, Prev: An Extended Example, Up: GNAT Project Manager + + Project File Complete Syntax + ============================ + + project ::= + context_clause project_declaration + + context_clause ::= + {with_clause} + + with_clause ::= + with literal_string { , literal_string } ; + + project_declaration ::= + project simple_name [ extends literal_string ] is + {declarative_item} + end simple_name; + + declarative_item ::= + package_declaration | + typed_string_declaration | + other_declarative_item + + package_declaration ::= + package simple_name package_completion + + package_completion ::= + package_body | package_renaming + + package body ::= + is + {other_declarative_item} + end simple_name ; + + package_renaming ::== + renames simple_name.simple_name ; + + typed_string_declaration ::= + type _simple_name is + ( literal_string {, literal_string} ); + + other_declarative_item ::= + attribute_declaration | + typed_variable_declaration | + variable_declaration | + case_construction + + attribute_declaration ::= + for attribute use expression ; + + attribute ::= + simple_name | + simple_name ( literal_string ) + + typed_variable_declaration ::= + simple_name : name := string_expression ; + + variable_declaration ::= + simple_name := expression; + + expression ::= + term {& term} + + term ::= + literal_string | + string_list | + name | + external_value | + attribute_reference + + literal_string ::= + (same as Ada) + + string_list ::= + ( expression { , expression } ) + + external_value ::= + external ( literal_string [, literal_string] ) + + attribute_reference ::= + attribute_parent ' simple_name [ ( literal_string ) ] + + attribute_parent ::= + project | + simple_name | + simple_name . simple_name + + case_construction ::= + case name is + {case_item} + end case ; + + case_item ::= + when discrete_choice_list => {case_construction | attribute_declaration} + + discrete_choice_list ::= + literal_string {| literal_string} + + name ::= + simple_name {. simple_name} + + simple_name ::= + identifier (same as Ada) + +  + File: gnat_ug_vms.info, Node: Elaboration Order Handling in GNAT, Next: The Cross-Referencing Tools GNAT XREF and GNAT FIND, Prev: GNAT Project Manager, Up: Top + + Elaboration Order Handling in GNAT + ********************************** + + * Menu: + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + This chapter describes the handling of elaboration code in Ada 95 and + in GNAT, and discusses how the order of elaboration of program units can + be controlled in GNAT, either automatically or with explicit programming + features. + +  + File: gnat_ug_vms.info, Node: Elaboration Code in Ada 95, Next: Checking the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Elaboration Code in Ada 95 + ========================== + + Ada 95 provides rather general mechanisms for executing code at + elaboration time, that is to say before the main program starts + executing. Such code arises in three contexts: + + Initializers for variables. + Variables declared at the library level, in package specs or + bodies, can require initialization that is performed at + elaboration time, as in: + Sqrt_Half : Float := Sqrt (0.5); + + Package initialization code + Code in a `BEGIN-END' section at the outer level of a package body + is executed as part of the package body elaboration code. + + Library level task allocators + Tasks that are declared using task allocators at the library level + start executing immediately and hence can execute at elaboration + time. + + Subprogram calls are possible in any of these contexts, which means that + any arbitrary part of the program may be executed as part of the + elaboration code. It is even possible to write a program which does all + its work at elaboration time, with a null main program, although + stylistically this would usually be considered an inappropriate way to + structure a program. + + An important concern arises in the context of elaboration code: we + have to be sure that it is executed in an appropriate order. What we + have is a series of elaboration code sections, potentially one section + for each unit in the program. It is important that these execute in the + correct order. Correctness here means that, taking the above example of + the declaration of `Sqrt_Half', if some other piece of elaboration code + references `Sqrt_Half', then it must run after the section of + elaboration code that contains the declaration of `Sqrt_Half'. + + There would never be any order of elaboration problem if we made a + rule that whenever you `with' a unit, you must elaborate both the spec + and body of that unit before elaborating the unit doing the `with''ing: + + with Unit_1; + package Unit_2 is ... + + would require that both the body and spec of `Unit_1' be elaborated + before the spec of `Unit_2'. However, a rule like that would be far too + restrictive. In particular, it would make it impossible to have routines + in separate packages that were mutually recursive. + + You might think that a clever enough compiler could look at the + actual elaboration code and determine an appropriate correct order of + elaboration, but in the general case, this is not possible. Consider + the following example. + + In the body of `Unit_1', we have a procedure `Func_1' that references + the variable `Sqrt_1', which is declared in the elaboration code of the + body of `Unit_1': + + Sqrt_1 : Float := Sqrt (0.1); + + The elaboration code of the body of `Unit_1' also contains: + + if expression_1 = 1 then + Q := Unit_2.Func_2; + end if; + + `Unit_2' is exactly parallel, it has a procedure `Func_2' that + references the variable `Sqrt_2', which is declared in the elaboration + code of the body `Unit_2': + + Sqrt_2 : Float := Sqrt (0.1); + + The elaboration code of the body of `Unit_2' also contains: + + if expression_2 = 2 then + Q := Unit_1.Func_1; + end if; + + Now the question is, which of the following orders of elaboration is + acceptable: + + Spec of Unit_1 + Spec of Unit_2 + Body of Unit_1 + Body of Unit_2 + + or + + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_2 + Body of Unit_1 + + If you carefully analyze the flow here, you will see that you cannot + tell at compile time the answer to this question. If `expression_1' is + not equal to 1, and `expression_2' is not equal to 2, then either order + is acceptable, because neither of the function calls is executed. If + both tests evaluate to true, then neither order is acceptable and in + fact there is no correct order. + + If one of the two expressions is true, and the other is false, then + one of the above orders is correct, and the other is incorrect. For + example, if `expression_1' = 1 and `expression_2' /= 2, then the call + to `Func_2' will occur, but not the call to `Func_1.' This means that + it is essential to elaborate the body of `Unit_1' before the body of + `Unit_2', so the first order of elaboration is correct and the second + is wrong. + + By making `expression_1' and `expression_2' depend on input data, or + perhaps the time of day, we can make it impossible for the compiler or + binder to figure out which of these expressions will be true, and hence + it is impossible to guarantee a safe order of elaboration at run time. + +  + File: gnat_ug_vms.info, Node: Checking the Elaboration Order in Ada 95, Next: Controlling the Elaboration Order in Ada 95, Prev: Elaboration Code in Ada 95, Up: Elaboration Order Handling in GNAT + + Checking the Elaboration Order in Ada 95 + ======================================== + + In some languages that involve the same kind of elaboration problems, + e.g. Java and C++, the programmer is expected to worry about these + ordering problems himself, and it is common to write a program in which + an incorrect elaboration order gives surprising results, because it + references variables before they are initialized. Ada 95 is designed + to be a safe language, and a programmer-beware approach is clearly not + sufficient. Consequently, the language provides three lines of defense: + + Standard rules + Some standard rules restrict the possible choice of elaboration + order. In particular, if you `with' a unit, then its spec is always + elaborated before the unit doing the `with'. Similarly, a parent + spec is always elaborated before the child spec, and finally a + spec is always elaborated before its corresponding body. + + Dynamic elaboration checks + Dynamic checks are made at run time, so that if some entity is + accessed before it is elaborated (typically by means of a + subprogram call) then the exception (`Program_Error') is raised. + + Elaboration control + Facilities are provided for the programmer to specify the desired + order of elaboration. + + Let's look at these facilities in more detail. First, the rules for + dynamic checking. One possible rule would be simply to say that the + exception is raised if you access a variable which has not yet been + elaborated. The trouble with this approach is that it could require + expensive checks on every variable reference. Instead Ada 95 has two + rules which are a little more restrictive, but easier to check, and + easier to state: + + Restrictions on calls + A subprogram can only be called at elaboration time if its body + has been elaborated. The rules for elaboration given above + guarantee that the spec of the subprogram has been elaborated + before the call, but not the body. If this rule is violated, then + the exception `Program_Error' is raised. + + Restrictions on instantiations + A generic unit can only be instantiated if the body of the generic + unit has been elaborated. Again, the rules for elaboration given + above guarantee that the spec of the generic unit has been + elaborated before the instantiation, but not the body. If this + rule is violated, then the exception `Program_Error' is raised. + + The idea is that if the body has been elaborated, then any variables it + references must have been elaborated; by checking for the body being + elaborated we guarantee that none of its references causes any trouble. + As we noted above, this is a little too restrictive, because a + subprogram that has no non-local references in its body may in fact be + safe to call. However, it really would be unsafe to rely on this, + because it would mean that the caller was aware of details of the + implementation in the body. This goes against the basic tenets of Ada. + + A plausible implementation can be described as follows. A Boolean + variable is associated with each subprogram and each generic unit. This + variable is initialized to False, and is set to True at the point body + is elaborated. Every call or instantiation checks the variable, and + raises `Program_Error' if the variable is False. + + Note that one might think that it would be good enough to have one + Boolean variable for each package, but that would not deal with cases + of trying to call a body in the same package as the call that has not + been elaborated yet. Of course a compiler may be able to do enough + analysis to optimize away some of the Boolean variables as unnecessary, + and `GNAT' indeed does such optimizations, but still the easiest + conceptual model is to think of there being one variable per subprogram. + +  + File: gnat_ug_vms.info, Node: Controlling the Elaboration Order in Ada 95, Next: Controlling Elaboration in GNAT - Internal Calls, Prev: Checking the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Controlling the Elaboration Order in Ada 95 + =========================================== + + In the previous section we discussed the rules in Ada 95 which ensure + that `Program_Error' is raised if an incorrect elaboration order is + chosen. This prevents erroneous executions, but we need mechanisms to + specify a correct execution and avoid the exception altogether. To + achieve this, Ada 95 provides a number of features for controlling the + order of elaboration. We discuss these features in this section. + + First, there are several ways of indicating to the compiler that a + given unit has no elaboration problems: + + packages that do not require a body + In Ada 95, a library package that does not require a body does not + permit a body. This means that if we have a such a package, as in: + + package Definitions is + generic + type m is new integer; + package Subp is + type a is array (1 .. 10) of m; + type b is array (1 .. 20) of m; + end Subp; + end Definitions; + + A package that `with''s `Definitions' may safely instantiate + `Definitions.Subp' because the compiler can determine that there + definitely is no package body to worry about in this case + + pragma Pure + Places sufficient restrictions on a unit to guarantee that no call + to any subprogram in the unit can result in an elaboration + problem. This means that the compiler does not need to worry about + the point of elaboration of such units, and in particular, does + not need to check any calls to any subprograms in this unit. + + pragma Preelaborate + This pragma places slightly less stringent restrictions on a unit + than does pragma Pure, but these restrictions are still sufficient + to ensure that there are no elaboration problems with any calls to + the unit. + + pragma Elaborate_Body + This pragma requires that the body of a unit be elaborated + immediately after its spec. Suppose a unit `A' has such a pragma, + and unit `B' does a `with' of unit `A'. Recall that the standard + rules require the spec of unit `A' to be elaborated before the + `with''ing unit; given the pragma in `A', we also know that the + body of `A' will be elaborated before `B', so that calls to `A' + are safe and do not need a check. + + Note that, unlike pragma `Pure' and pragma `Preelaborate', the use of + `Elaborate_Body' does not guarantee that the program is free of + elaboration problems, because it may not be possible to satisfy the + requested elaboration order. Let's go back to the example with + `Unit_1' and `Unit_2'. If a programmer marks `Unit_1' as + `Elaborate_Body', and not `Unit_2,' then the order of elaboration will + be: + + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_1 + Body of Unit_2 + + Now that means that the call to `Func_1' in `Unit_2' need not be + checked, it must be safe. But the call to `Func_2' in `Unit_1' may + still fail if `Expression_1' is equal to 1, and the programmer must + still take responsibility for this not being the case. + + If all units carry a pragma `Elaborate_Body', then all problems are + eliminated, except for calls entirely within a body, which are in any + case fully under programmer control. However, using the pragma + everywhere is not always possible. In particular, for our + `Unit_1'/`Unit_2' example, if we marked both of them as having pragma + `Elaborate_Body', then clearly there would be no possible elaboration + order. + + The above pragmas allow a server to guarantee safe use by clients, + and clearly this is the preferable approach. Consequently a good rule in + Ada 95 is to mark units as `Pure' or `Preelaborate' if possible, and if + this is not possible, mark them as `Elaborate_Body' if possible. As we + have seen, there are situations where neither of these three pragmas + can be used. So we also provide methods for clients to control the + order of elaboration of the servers on which they depend: + + pragma Elaborate (unit) + This pragma is placed in the context clause, after a `with' clause, + and it requires that the body of the named unit be elaborated + before the unit in which the pragma occurs. The idea is to use + this pragma if the current unit calls at elaboration time, + directly or indirectly, some subprogram in the named unit. + + pragma Elaborate_All (unit) + This is a stronger version of the Elaborate pragma. Consider the + following example: + + Unit A `with''s unit B and calls B.Func in elab code + Unit B `with''s unit C, and B.Func calls C.Func + + Now if we put a pragma `Elaborate (B)' in unit `A', this ensures + that the body of `B' is elaborated before the call, but not the + body of `C', so the call to `C.Func' could still cause + `Program_Error' to be raised. + + The effect of a pragma `Elaborate_All' is stronger, it requires + not only that the body of the named unit be elaborated before the + unit doing the `with', but also the bodies of all units that the + named unit uses, following `with' links transitively. For example, + if we put a pragma `Elaborate_All (B)' in unit `A', then it + requires not only that the body of `B' be elaborated before `A', + but also the body of `C', because `B' `with''s `C'. + + We are now in a position to give a usage rule in Ada 95 for avoiding + elaboration problems, at least if dynamic dispatching and access to + subprogram values are not used. We will handle these cases separately + later. + + The rule is simple. If a unit has elaboration code that can directly + or indirectly make a call to a subprogram in a `with''ed unit, or + instantiate a generic unit in a `with''ed unit, then if the `with''ed + unit does not have pragma `Pure' or `Preelaborate', then the client + should have a pragma `Elaborate_All' for the `with''ed unit. By + following this rule a client is assured that calls can be made without + risk of an exception. If this rule is not followed, then a program may + be in one of four states: + + No order exists + No order of elaboration exists which follows the rules, taking into + account any `Elaborate', `Elaborate_All', or `Elaborate_Body' + pragmas. In this case, an Ada 95 compiler must diagnose the + situation at bind time, and refuse to build an executable program. + + One or more orders exist, all incorrect + One or more acceptable elaboration orders exists, and all of them + generate an elaboration order problem. In this case, the binder + can build an executable program, but `Program_Error' will be raised + when the program is run. + + Several orders exist, some right, some incorrect + One or more acceptable elaboration orders exists, and some of them + work, and some do not. The programmer has not controlled the order + of elaboration, so the binder may or may not pick one of the + correct orders, and the program may or may not raise an exception + when it is run. This is the worst case, because it means that the + program may fail when moved to another compiler, or even another + version of the same compiler. + + One or more orders exists, all correct + One ore more acceptable elaboration orders exist, and all of them + work. In this case the program runs successfully. This state of + affairs can be guaranteed by following the rule we gave above, but + may be true even if the rule is not followed. + + Note that one additional advantage of following our Elaborate_All rule + is that the program continues to stay in the ideal (all orders OK) state + even if maintenance changes some bodies of some subprograms. + Conversely, if a program that does not follow this rule happens to be + safe at some point, this state of affairs may deteriorate silently as a + result of maintenance changes. + + You may have noticed that the above discussion did not mention the + use of `Elaborate_Body'. This was a deliberate omission. If you `with' + an `Elaborate_Body' unit, it still may be the case that code in the + body makes calls to some other unit, so it is still necessary to use + `Elaborate_All' on such units. + +  + File: gnat_ug_vms.info, Node: Controlling Elaboration in GNAT - Internal Calls, Next: Controlling Elaboration in GNAT - External Calls, Prev: Controlling the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Controlling Elaboration in GNAT - Internal Calls + ================================================ + + In the case of internal calls, i.e. calls within a single package, the + programmer has full control over the order of elaboration, and it is up + to the programmer to elaborate declarations in an appropriate order. For + example writing: + + function One return Float; + + Q : Float := One; + + function One return Float is + begin + return 1.0; + end One; + + will obviously raise `Program_Error' at run time, because function One + will be called before its body is elaborated. In this case GNAT will + generate a warning that the call will raise `Program_Error': + + 1. procedure y is + 2. function One return Float; + 3. + 4. Q : Float := One; + | + >>> warning: cannot call "One" before body is elaborated + >>> warning: Program_Error will be raised at run time + + 5. + 6. function One return Float is + 7. begin + 8. return 1.0; + 9. end One; + 10. + 11. begin + 12. null; + 13. end; + + Note that in this particular case, it is likely that the call is safe, + because the function `One' does not access any global variables. + Nevertheless in Ada 95, we do not want the validity of the check to + depend on the contents of the body (think about the separate + compilation case), so this is still wrong, as we discussed in the + previous sections. + + The error is easily corrected by rearranging the declarations so + that the body of One appears before the declaration containing the call + (note that in Ada 95, declarations can appear in any order, so there is + no restriction that would prevent this reordering, and if we write: + + function One return Float; + + function One return Float is + begin + return 1.0; + end One; + + Q : Float := One; + + then all is well, no warning is generated, and no `Program_Error' + exception will be raised. Things are more complicated when a chain of + subprograms is executed: + + function A return Integer; + function B return Integer; + function C return Integer; + + function B return Integer is begin return A; end; + function C return Integer is begin return B; end; + + X : Integer := C; + + function A return Integer is begin return 1; end; + + Now the call to `C' at elaboration time in the declaration of `X' is + correct, because the body of `C' is already elaborated, and the call to + `B' within the body of `C' is correct, but the call to `A' within the + body of `B' is incorrect, because the body of `A' has not been + elaborated, so `Program_Error' will be raised on the call to `A'. In + this case GNAT will generate a warning that `Program_Error' may be + raised at the point of the call. Let's look at the warning: + + 1. procedure x is + 2. function A return Integer; + 3. function B return Integer; + 4. function C return Integer; + 5. + 6. function B return Integer is begin return A; end; + | + >>> warning: call to "A" before body is elaborated may + raise Program_Error + >>> warning: "B" called at line 7 + >>> warning: "C" called at line 9 + + 7. function C return Integer is begin return B; end; + 8. + 9. X : Integer := C; + 10. + 11. function A return Integer is begin return 1; end; + 12. + 13. begin + 14. null; + 15. end; + + Note that the message here says "may raise", instead of the direct case, + where the message says "will be raised". That's because whether `A' is + actually called depends in general on run-time flow of control. For + example, if the body of `B' said + + function B return Integer is + begin + if some-condition-depending-on-input-data then + return A; + else + return 1; + end if; + end B; + + then we could not know until run time whether the incorrect call to A + would actually occur, so `Program_Error' might or might not be raised. + It is possible for a compiler to do a better job of analyzing bodies, to + determine whether or not `Program_Error' might be raised, but it + certainly couldn't do a perfect job (that would require solving the + halting problem and is provably impossible), and because this is a + warning anyway, it does not seem worth the effort to do the analysis. + Cases in which it would be relevant are rare. + + In practice, warnings of either of the forms given above will + usually correspond to real errors, and should be examined carefully and + eliminated. In the rare case where a warning is bogus, it can be + suppressed by any of the following methods: + + * Compile with the `/WARNINGS=SUPPRESS' qualifier set + + * Suppress `Elaboration_Checks' for the called subprogram + + * Use pragma `Warnings_Off' to turn warnings off for the call + + For the internal elaboration check case, GNAT by default generates the + necessary run-time checks to ensure that `Program_Error' is raised if + any call fails an elaboration check. Of course this can only happen if a + warning has been issued as described above. The use of pragma `Suppress + (Elaboration_Checks)' may (but is not guaranteed to) suppress some of + these checks, meaning that it may be possible (but is not guaranteed) + for a program to be able to call a subprogram whose body is not yet + elaborated, without raising a `Program_Error' exception. + +  + File: gnat_ug_vms.info, Node: Controlling Elaboration in GNAT - External Calls, Next: Default Behavior in GNAT - Ensuring Safety, Prev: Controlling Elaboration in GNAT - Internal Calls, Up: Elaboration Order Handling in GNAT + + Controlling Elaboration in GNAT - External Calls + ================================================ + + The previous section discussed the case in which the execution of a + particular thread of elaboration code occurred entirely within a single + unit. This is the easy case to handle, because a programmer has direct + and total control over the order of elaboration, and furthermore, + checks need only be generated in cases which are rare and which the + compiler can easily detect. The situation is more complex when + separate compilation is taken into account. Consider the following: + + package Math is + function Sqrt (Arg : Float) return Float; + end Math; + + package body Math is + function Sqrt (Arg : Float) return Float is + begin + ... + end Sqrt; + end Math; + + with Math; + package Stuff is + X : Float := Math.Sqrt (0.5); + end Stuff; + + with Stuff; + procedure Main is + begin + ... + end Main; + + where `Main' is the main program. When this program is executed, the + elaboration code must first be executed, and one of the jobs of the + binder is to determine the order in which the units of a program are to + be elaborated. In this case we have four units: the spec and body of + `Math', the spec of `Stuff' and the body of `Main'). In what order + should the four separate sections of elaboration code be executed? + + There are some restrictions in the order of elaboration that the + binder can choose. In particular, if unit U has a `with' for a package + `X', then you are assured that the spec of `X' is elaborated before U , + but you are not assured that the body of `X' is elaborated before U. + This means that in the above case, the binder is allowed to choose the + order: + + spec of Math + spec of Stuff + body of Math + body of Main + + but that's not good, because now the call to `Math.Sqrt' that happens + during the elaboration of the `Stuff' spec happens before the body of + `Math.Sqrt' is elaborated, and hence causes `Program_Error' exception + to be raised. At first glance, one might say that the binder is + misbehaving, because obviously you want to elaborate the body of + something you `with' first, but that is not a general rule that can be + followed in all cases. Consider + + package X is ... + + package Y is ... + + with X; + package body Y is ... + + with Y; + package body X is ... + + This is a common arrangement, and, apart from the order of elaboration + problems that might arise in connection with elaboration code, this + works fine. A rule that says that you must first elaborate the body of + anything you `with' cannot work in this case: the body of `X' `with''s + `Y', which means you would have to elaborate the body of `Y' first, but + that `with''s `X', which means you have to elaborate the body of `X' + first, but ... and we have a loop that cannot be broken. + + It is true that the binder can in many cases guess an order of + elaboration that is unlikely to cause a `Program_Error' exception to be + raised, and it tries to do so (in the above example of + `Math/Stuff/Spec', the GNAT binder will by default elaborate the body + of `Math' right after its spec, so all will be well). + + However, a program that blindly relies on the binder to be helpful + can get into trouble, as we discussed in the previous sections, so GNAT + provides a number of facilities for assisting the programmer in + developing programs that are robust with respect to elaboration order. + +  + File: gnat_ug_vms.info, Node: Default Behavior in GNAT - Ensuring Safety, Next: Elaboration Issues for Library Tasks, Prev: Controlling Elaboration in GNAT - External Calls, Up: Elaboration Order Handling in GNAT + + Default Behavior in GNAT - Ensuring Safety + ========================================== + + The default behavior in GNAT ensures elaboration safety. In its default + mode GNAT implements the rule we previously described as the right + approach. Let's restate it: + + * _If a unit has elaboration code that can directly or indirectly + make a call to a subprogram in a `with''ed unit, or instantiate a + generic unit in a `with''ed unit, then if the `with''ed unit does + not have pragma `Pure' or `Preelaborate', then the client should + have an `Elaborate_All' for the `with''ed unit._ + + By following this rule a client is assured that calls and + instantiations can be made without risk of an exception. + + In this mode GNAT traces all calls that are potentially made from + elaboration code, and puts in any missing implicit `Elaborate_All' + pragmas. The advantage of this approach is that no elaboration problems + are possible if the binder can find an elaboration order that is + consistent with these implicit `Elaborate_All' pragmas. The + disadvantage of this approach is that no such order may exist. + + If the binder does not generate any diagnostics, then it means that + it has found an elaboration order that is guaranteed to be safe. + However, the binder may still be relying on implicitly generated + `Elaborate_All' pragmas so portability to other compilers than GNAT is + not guaranteed. + + If it is important to guarantee portability, then the compilations + should use the `/WARNINGS=ELABORATION' (warn on elaboration problems) + qualifier. This will cause warning messages to be generated indicating + the missing `Elaborate_All' pragmas. Consider the following source + program: + + with k; + package j is + m : integer := k.r; + end; + + where it is clear that there should be a pragma `Elaborate_All' for + unit `k'. An implicit pragma will be generated, and it is likely that + the binder will be able to honor it. However, it is safer to include + the pragma explicitly in the source. If this unit is compiled with the + `/WARNINGS=ELABORATION' qualifier, then the compiler outputs a warning: + + 1. with k; + 2. package j is + 3. m : integer := k.r; + | + >>> warning: call to "r" may raise Program_Error + >>> warning: missing pragma Elaborate_All for "k" + + 4. end; + + and these warnings can be used as a guide for supplying manually the + missing pragmas. + + This default mode is more restrictive than the Ada Reference Manual, + and it is possible to construct programs which will compile using the + dynamic model described there, but will run into a circularity using + the safer static model we have described. + + Of course any Ada compiler must be able to operate in a mode + consistent with the requirements of the Ada Reference Manual, and in + particular must have the capability of implementing the standard + dynamic model of elaboration with run-time checks. + + In GNAT, this standard mode can be achieved either by the use of the + `/CHECKS=ELABORATION' qualifier on the compiler (`GNAT COMPILE' or + `GNAT MAKE') command, or by the use of the configuration pragma: + + pragma Elaboration_Checks (RM); + + Either approach will cause the unit affected to be compiled using the + standard dynamic run-time elaboration checks described in the Ada + Reference Manual. The static model is generally preferable, since it is + clearly safer to rely on compile and link time checks rather than + run-time checks. However, in the case of legacy code, it may be + difficult to meet the requirements of the static model. This issue is + further discussed in *Note What to Do If the Default Elaboration + Behavior Fails::. + + Note that the static model provides a strict subset of the allowed + behavior and programs of the Ada Reference Manual, so if you do adhere + to the static model and no circularities exist, then you are assured + that your program will work using the dynamic model. + +  + File: gnat_ug_vms.info, Node: Elaboration Issues for Library Tasks, Next: Mixing Elaboration Models, Prev: Default Behavior in GNAT - Ensuring Safety, Up: Elaboration Order Handling in GNAT + + Elaboration Issues for Library Tasks + ==================================== + + In this section we examine special elaboration issues that arise for + programs that declare library level tasks. + + Generally the model of execution of an Ada program is that all units + are elaborated, and then execution of the program starts. However, the + declaration of library tasks definitely does not fit this model. The + reason for this is that library tasks start as soon as they are declared + (more precisely, as soon as the statement part of the enclosing package + body is reached), that is to say before elaboration of the program is + complete. This means that if such a task calls a subprogram, or an + entry in another task, the callee may or may not be elaborated yet, and + in the standard Reference Manual model of dynamic elaboration checks, + you can even get timing dependent Program_Error exceptions, since there + can be a race between the elaboration code and the task code. + + The static model of elaboration in GNAT seeks to avoid all such + dynamic behavior, by being conservative, and the conservative approach + in this particular case is to assume that all the code in a task body + is potentially executed at elaboration time if a task is declared at + the library level. + + This can definitely result in unexpected circularities. Consider the + following example + + package Decls is + task Lib_Task is + entry Start; + end Lib_Task; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + procedure Main is + begin + Decls.Lib_Task.Start; + end; + + If the above example is compiled in the default static elaboration + mode, then a circularity occurs. The circularity comes from the call + `Utils.Put_Val' in the task body of `Decls.Lib_Task'. Since this call + occurs in elaboration code, we need an implicit pragma `Elaborate_All' + for `Utils'. This means that not only must the spec and body of `Utils' + be elaborated before the body of `Decls', but also the spec and body of + any unit that is `with'ed' by the body of `Utils' must also be + elaborated before the body of `Decls'. This is the transitive + implication of pragma `Elaborate_All' and it makes sense, because in + general the body of `Put_Val' might have a call to something in a + `with'ed' unit. + + In this case, the body of Utils (actually its spec) `with's' + `Decls'. Unfortunately this means that the body of `Decls' must be + elaborated before itself, in case there is a call from the body of + `Utils'. + + Here is the exact chain of events we are worrying about: + + 1. In the body of `Decls' a call is made from within the body of a + library task to a subprogram in the package `Utils'. Since this + call may occur at elaboration time (given that the task is + activated at elaboration time), we have to assume the worst, i.e. + that the call does happen at elaboration time. + + 2. This means that the body and spec of `Util' must be elaborated + before the body of `Decls' so that this call does not cause an + access before elaboration. + + 3. Within the body of `Util', specifically within the body of + `Util.Put_Val' there may be calls to any unit `with''ed by this + package. + + 4. One such `with''ed package is package `Decls', so there might be a + call to a subprogram in `Decls' in `Put_Val'. In fact there is + such a call in this example, but we would have to assume that + there was such a call even if it were not there, since we are not + supposed to write the body of `Decls' knowing what is in the body + of `Utils'; certainly in the case of the static elaboration model, + the compiler does not know what is in other bodies and must assume + the worst. + + 5. This means that the spec and body of `Decls' must also be + elaborated before we elaborate the unit containing the call, but + that unit is `Decls'! This means that the body of `Decls' must be + elaborated before itself, and that's a circularity. + + Indeed, if you add an explicit pragma Elaborate_All for `Utils' in the + body of `Decls' you will get a true Ada Reference Manual circularity + that makes the program illegal. + + In practice, we have found that problems with the static model of + elaboration in existing code often arise from library tasks, so we must + address this particular situation. + + Note that if we compile and run the program above, using the dynamic + model of elaboration (that is to say use the `/CHECKS=ELABORATION' + qualifier), then it compiles, binds, links, and runs, printing the + expected result of 2. Therefore in some sense the circularity here is + only apparent, and we need to capture the properties of this program + that distinguish it from other library-level tasks that have real + elaboration problems. + + We have four possible answers to this question: + + * Use the dynamic model of elaboration. + + If we use the `/CHECKS=ELABORATION' qualifier, then as noted + above, the program works. Why is this? If we examine the task + body, it is apparent that the task cannot proceed past the + `accept' statement until after elaboration has been completed, + because the corresponding entry call comes from the main program, + not earlier. This is why the dynamic model works here. But that's + really giving up on a precise analysis, and we prefer to take this + approach only if we cannot solve the problem in any other manner. + So let us examine two ways to reorganize the program to avoid the + potential elaboration problem. + + * Split library tasks into separate packages. + + Write separate packages, so that library tasks are isolated from + other declarations as much as possible. Let us look at a variation + on the above program. + + package Decls1 is + task Lib_Task is + entry Start; + end Lib_Task; + end Decls1; + + with Utils; + package body Decls1 is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + end Decls1; + + package Decls2 is + type My_Int is new Integer; + function Ident (M : My_Int) return My_Int; + end Decls2; + + with Utils; + package body Decls2 is + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls2; + + with Decls2; + package Utils is + procedure Put_Val (Arg : Decls2.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls2.My_Int) is + begin + Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls1; + procedure Main is + begin + Decls1.Lib_Task.Start; + end; + + All we have done is to split `Decls' into two packages, one + containing the library task, and one containing everything else. + Now there is no cycle, and the program compiles, binds, links and + executes using the default static model of elaboration. + + * Declare separate task types. + + A significant part of the problem arises because of the use of the + single task declaration form. This means that the elaboration of + the task type, and the elaboration of the task itself (i.e. the + creation of the task) happen at the same time. A good rule of + style in Ada 95 is to always create explicit task types. By + following the additional step of placing task objects in separate + packages from the task type declaration, many elaboration problems + are avoided. Here is another modified example of the example + program: + + package Decls is + task type Lib_Task_Type is + entry Start; + end Lib_Task_Type; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task_Type is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task_Type; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + package Declst is + Lib_Task : Decls.Lib_Task_Type; + end Declst; + + with Declst; + procedure Main is + begin + Declst.Lib_Task.Start; + end; + + What we have done here is to replace the `task' declaration in + package `Decls' with a `task type' declaration. Then we introduce + a separate package `Declst' to contain the actual task object. + This separates the elaboration issues for the `task type' + declaration, which causes no trouble, from the elaboration issues + of the task object, which is also unproblematic, since it is now + independent of the elaboration of `Utils'. This separation of + concerns also corresponds to a generally sound engineering + principle of separating declarations from instances. This version + of the program also compiles, binds, links, and executes, + generating the expected output. + + * Use No_Entry_Calls_In_Elaboration_Code restriction. + + The previous two approaches described how a program can be + restructured to avoid the special problems caused by library task + bodies. in practice, however, such restructuring may be difficult + to apply to existing legacy code, so we must consider solutions + that do not require massive rewriting. + + Let us consider more carefully why our original sample program + works under the dynamic model of elaboration. The reason is that + the code in the task body blocks immediately on the `accept' + statement. Now of course there is nothing to prohibit elaboration + code from making entry calls (for example from another library + level task), so we cannot tell in isolation that the task will not + execute the accept statement during elaboration. + + However, in practice it is very unusual to see elaboration code + make any entry calls, and the pattern of tasks starting at + elaboration time and then immediately blocking on `accept' or + `select' statements is very common. What this means is that the + compiler is being too pessimistic when it analyzes the whole + package body as though it might be executed at elaboration time. + + If we know that the elaboration code contains no entry calls, (a + very safe assumption most of the time, that could almost be made + the default behavior), then we can compile all units of the + program under control of the following configuration pragma: + + pragma Restrictions (No_Entry_Calls_In_Elaboration_Code); + + This pragma can be placed in the `GNAT.ADC' file in the usual + manner. If we take our original unmodified program and compile it + in the presence of a `GNAT.ADC' containing the above pragma, then + once again, we can compile, bind, link, and execute, obtaining the + expected result. In the presence of this pragma, the compiler does + not trace calls in a task body, that appear after the first + `accept' or `select' statement, and therefore does not report a + potential circularity in the original program. + + The compiler will check to the extent it can that the above + restriction is not violated, but it is not always possible to do a + complete check at compile time, so it is important to use this + pragma only if the stated restriction is in fact met, that is to + say no task receives an entry call before elaboration of all units + is completed. + + +  + File: gnat_ug_vms.info, Node: Mixing Elaboration Models, Next: What to Do If the Default Elaboration Behavior Fails, Prev: Elaboration Issues for Library Tasks, Up: Elaboration Order Handling in GNAT + + Mixing Elaboration Models + ========================= + + So far, we have assumed that the entire program is either compiled + using the dynamic model or static model, ensuring consistency. It is + possible to mix the two models, but rules have to be followed if this + mixing is done to ensure that elaboration checks are not omitted. + + The basic rule is that _a unit compiled with the static model cannot + be `with'ed' by a unit compiled with the dynamic model_. The reason for + this is that in the static model, a unit assumes that its clients + guarantee to use (the equivalent of) pragma `Elaborate_All' so that no + elaboration checks are required in inner subprograms, and this + assumption is violated if the client is compiled with dynamic checks. + + The precise rule is as follows. A unit that is compiled with dynamic + checks can only `with' a unit that meets at least one of the following + criteria: + + * The `with'ed' unit is itself compiled with dynamic elaboration + checks (that is with the `/CHECKS=ELABORATION' qualifier. + + * The `with'ed' unit is an internal GNAT implementation unit from + the System, Interfaces, Ada, or GNAT hierarchies. + + * The `with'ed' unit has pragma Preelaborate or pragma Pure. + + * The `with'ing' unit (that is the client) has an explicit pragma + `Elaborate_All' for the `with'ed' unit. + + + If this rule is violated, that is if a unit with dynamic elaboration + checks `with's' a unit that does not meet one of the above four + criteria, then the binder (`GNAT BIND') will issue a warning similar to + that in the following example: + + warning: "X.ADS" has dynamic elaboration checks and with's + warning: "Y.ADS" which has static elaboration checks + + These warnings indicate that the rule has been violated, and that as a + result elaboration checks may be missed in the resulting executable + file. This warning may be suppressed using the `-ws' binder qualifier + in the usual manner. + + One useful application of this mixing rule is in the case of a + subsystem which does not itself `with' units from the remainder of the + application. In this case, the entire subsystem can be compiled with + dynamic checks to resolve a circularity in the subsystem, while + allowing the main application that uses this subsystem to be compiled + using the more reliable default static model. + +  + File: gnat_ug_vms.info, Node: What to Do If the Default Elaboration Behavior Fails, Next: Elaboration for Access-to-Subprogram Values, Prev: Mixing Elaboration Models, Up: Elaboration Order Handling in GNAT + + What to Do If the Default Elaboration Behavior Fails + ==================================================== + + If the binder cannot find an acceptable order, it outputs detailed + diagnostics. For example: + error: elaboration circularity detected + info: "proc (body)" must be elaborated before "pack (body)" + info: reason: Elaborate_All probably needed in unit "pack (body)" + info: recompile "pack (body)" with /WARNINGS=ELABORATION + info: for full details + info: "proc (body)" + info: is needed by its spec: + info: "proc (spec)" + info: which is withed by: + info: "pack (body)" + info: "pack (body)" must be elaborated before "proc (body)" + info: reason: pragma Elaborate in unit "proc (body)" + + + In this case we have a cycle that the binder cannot break. On the one + hand, there is an explicit pragma Elaborate in `proc' for `pack'. This + means that the body of `pack' must be elaborated before the body of + `proc'. On the other hand, there is elaboration code in `pack' that + calls a subprogram in `proc'. This means that for maximum safety, there + should really be a pragma Elaborate_All in `pack' for `proc' which + would require that the body of `proc' be elaborated before the body of + `pack'. Clearly both requirements cannot be satisfied. Faced with a + circularity of this kind, you have three different options. + + Fix the program + The most desirable option from the point of view of long-term + maintenance is to rearrange the program so that the elaboration + problems are avoided. One useful technique is to place the + elaboration code into separate child packages. Another is to move + some of the initialization code to explicitly called subprograms, + where the program controls the order of initialization explicitly. + Although this is the most desirable option, it may be impractical + and involve too much modification, especially in the case of + complex legacy code. + + Perform dynamic checks + If the compilations are done using the `/CHECKS=ELABORATION' + (dynamic elaboration check) qualifier, then GNAT behaves in a + quite different manner. Dynamic checks are generated for all calls + that could possibly result in raising an exception. With this + qualifier, the compiler does not generate implicit `Elaborate_All' + pragmas. The behavior then is exactly as specified in the Ada 95 + Reference Manual. The binder will generate an executable program + that may or may not raise `Program_Error', and then it is the + programmer's job to ensure that it does not raise an exception. + Note that it is important to compile all units with the qualifier, + it cannot be used selectively. + + Suppress checks + The drawback of dynamic checks is that they generate a significant + overhead at run time, both in space and time. If you are + absolutely sure that your program cannot raise any elaboration + exceptions, and you still want to use the dynamic elaboration + model, then you can use the configuration pragma `Suppress + (Elaboration_Checks)' to suppress all such checks. For example + this pragma could be placed in the `GNAT.ADC' file. + + Suppress checks selectively + When you know that certain calls in elaboration code cannot + possibly lead to an elaboration error, and the binder nevertheless + generates warnings on those calls and inserts Elaborate_All + pragmas that lead to elaboration circularities, it is possible to + remove those warnings locally and obtain a program that will bind. + Clearly this can be unsafe, and it is the responsibility of the + programmer to make sure that the resulting program has no + elaboration anomalies. The pragma `Suppress (Elaboration_Check)' + can be used with different granularity to suppress warnings and + break elaboration circularities: + + * Place the pragma that names the called subprogram in the + declarative part that contains the call. + + * Place the pragma in the declarative part, without naming an + entity. This disables warnings on all calls in the + corresponding declarative region. + + * Place the pragma in the package spec that declares the called + subprogram, and name the subprogram. This disables warnings + on all elaboration calls to that subprogram. + + * Place the pragma in the package spec that declares the called + subprogram, without naming any entity. This disables warnings + on all elaboration calls to all subprograms declared in this + spec. + + These four cases are listed in order of decreasing safety, and + therefore require increasing programmer care in their application. + Consider the following program: + + package Pack1 is + function F1 return Integer; + X1 : Integer; + end Pack1; + + package Pack2 is + function F2 return Integer; + function Pure (x : integer) return integer; + -- pragma Suppress (Elaboration_Check, On => Pure); -- (3) + -- pragma Suppress (Elaboration_Check); -- (4) + end Pack2; + + with Pack2; + package body Pack1 is + function F1 return Integer is + begin + return 100; + end F1; + Val : integer := Pack2.Pure (11); -- Elab. call (1) + begin + declare + -- pragma Suppress(Elaboration_Check, Pack2.F2); -- (1) + -- pragma Suppress(Elaboration_Check); -- (2) + begin + X1 := Pack2.F2 + 1; -- Elab. call (2) + end; + end Pack1; + + with Pack1; + package body Pack2 is + function F2 return Integer is + begin + return Pack1.F1; + end F2; + function Pure (x : integer) return integer is + begin + return x ** 3 - 3 * x; + end; + end Pack2; + + with Pack1, Ada.Text_IO; + procedure Proc3 is + begin + Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101 + end Proc3; + In the absence of any pragmas, an attempt to bind this program + produces the following diagnostics: + error: elaboration circularity detected + info: "pack1 (body)" must be elaborated before "pack1 (body)" + info: reason: Elaborate_All probably needed in unit "pack1 (body)" + info: recompile "pack1 (body)" with /WARNINGS=ELABORATION for full details + info: "pack1 (body)" + info: must be elaborated along with its spec: + info: "pack1 (spec)" + info: which is withed by: + info: "pack2 (body)" + info: which must be elaborated along with its spec: + info: "pack2 (spec)" + info: which is withed by: + info: "pack1 (body)" + The sources of the circularity are the two calls to + `Pack2.Pure' and `Pack2.F2' in the body of `Pack1'. We can see + that the call to F2 is safe, even though F2 calls F1, because the + call appears after the elaboration of the body of F1. Therefore + the pragma (1) is safe, and will remove the warning on the call. + It is also possible to use pragma (2) because there are no other + potentially unsafe calls in the block. + + The call to `Pure' is safe because this function does not depend + on the state of `Pack2'. Therefore any call to this function is + safe, and it is correct to place pragma (3) in the corresponding + package spec. + + Finally, we could place pragma (4) in the spec of `Pack2' to + disable warnings on all calls to functions declared therein. Note + that this is not necessarily safe, and requires more detailed + examination of the subprogram bodies involved. In particular, a + call to `F2' requires that `F1' be already elaborated. + + It is hard to generalize on which of these four approaches should be + taken. Obviously if it is possible to fix the program so that the + default treatment works, this is preferable, but this may not always be + practical. It is certainly simple enough to use `/CHECKS=ELABORATION' + but the danger in this case is that, even if the GNAT binder finds a + correct elaboration order, it may not always do so, and certainly a + binder from another Ada compiler might not. A combination of testing + and analysis (for which the warnings generated with the + `/WARNINGS=ELABORATION' qualifier can be useful) must be used to ensure + that the program is free of errors. One qualifier that is useful in + this testing is the `/PESSIMISTIC_ELABORATION_ORDER' qualifier for + `GNAT BIND'. Normally the binder tries to find an order that has the + best chance of of avoiding elaboration problems. With this qualifier, + the binder plays a devil's advocate role, and tries to choose the order + that has the best chance of failing. If your program works even with + this qualifier, then it has a better chance of being error free, but + this is still not a guarantee. + + For an example of this approach in action, consider the C-tests + (executable tests) from the ACVC suite. If these are compiled and run + with the default treatment, then all but one of them succeed without + generating any error diagnostics from the binder. However, there is one + test that fails, and this is not surprising, because the whole point of + this test is to ensure that the compiler can handle cases where it is + impossible to determine a correct order statically, and it checks that + an exception is indeed raised at run time. + + This one test must be compiled and run using the + `/CHECKS=ELABORATION' qualifier, and then it passes. Alternatively, the + entire suite can be run using this qualifier. It is never wrong to run + with the dynamic elaboration qualifier if your code is correct, and we + assume that the C-tests are indeed correct (it is less efficient, but + efficiency is not a factor in running the ACVC tests.) + +  + File: gnat_ug_vms.info, Node: Elaboration for Access-to-Subprogram Values, Next: Summary of Procedures for Elaboration Control, Prev: What to Do If the Default Elaboration Behavior Fails, Up: Elaboration Order Handling in GNAT + + Elaboration for Access-to-Subprogram Values + =========================================== + + The introduction of access-to-subprogram types in Ada 95 complicates + the handling of elaboration. The trouble is that it becomes impossible + to tell at compile time which procedure is being called. This means + that it is not possible for the binder to analyze the elaboration + requirements in this case. + + If at the point at which the access value is created (i.e., the + evaluation of `P'Access' for a subprogram `P'), the body of the + subprogram is known to have been elaborated, then the access value is + safe, and its use does not require a check. This may be achieved by + appropriate arrangement of the order of declarations if the subprogram + is in the current unit, or, if the subprogram is in another unit, by + using pragma `Pure', `Preelaborate', or `Elaborate_Body' on the + referenced unit. + + If the referenced body is not known to have been elaborated at the + point the access value is created, then any use of the access value + must do a dynamic check, and this dynamic check will fail and raise a + `Program_Error' exception if the body has not been elaborated yet. + GNAT will generate the necessary checks, and in addition, if the + `/WARNINGS=ELABORATION' qualifier is set, will generate warnings that + such checks are required. + + The use of dynamic dispatching for tagged types similarly generates + a requirement for dynamic checks, and premature calls to any primitive + operation of a tagged type before the body of the operation has been + elaborated, will result in the raising of `Program_Error'. + +  + File: gnat_ug_vms.info, Node: Summary of Procedures for Elaboration Control, Next: Other Elaboration Order Considerations, Prev: Elaboration for Access-to-Subprogram Values, Up: Elaboration Order Handling in GNAT + + Summary of Procedures for Elaboration Control + ============================================= + + First, compile your program with the default options, using none of the + special elaboration control qualifiers. If the binder successfully + binds your program, then you can be confident that, apart from issues + raised by the use of access-to-subprogram types and dynamic dispatching, + the program is free of elaboration errors. If it is important that the + program be portable, then use the `/WARNINGS=ELABORATION' qualifier to + generate warnings about missing `Elaborate_All' pragmas, and supply the + missing pragmas. + + If the program fails to bind using the default static elaboration + handling, then you can fix the program to eliminate the binder message, + or recompile the entire program with the `/CHECKS=ELABORATION' + qualifier to generate dynamic elaboration checks, and, if you are sure + there really are no elaboration problems, use a global pragma `Suppress + (Elaboration_Checks)'. + +  + File: gnat_ug_vms.info, Node: Other Elaboration Order Considerations, Prev: Summary of Procedures for Elaboration Control, Up: Elaboration Order Handling in GNAT + + Other Elaboration Order Considerations + ====================================== + + This section has been entirely concerned with the issue of finding a + valid elaboration order, as defined by the Ada Reference Manual. In a + case where several elaboration orders are valid, the task is to find one + of the possible valid elaboration orders (and the static model in GNAT + will ensure that this is achieved). + + The purpose of the elaboration rules in the Ada Reference Manual is + to make sure that no entity is accessed before it has been elaborated. + For a subprogram, this means that the spec and body must have been + elaborated before the subprogram is called. For an object, this means + that the object must have been elaborated before its value is read or + written. A violation of either of these two requirements is an access + before elaboration order, and this section has been all about avoiding + such errors. + + In the case where more than one order of elaboration is possible, in + the sense that access before elaboration errors are avoided, then any + one of the orders is "correct" in the sense that it meets the + requirements of the Ada Reference Manual, and no such error occurs. + + However, it may be the case for a given program, that there are + constraints on the order of elaboration that come not from consideration + of avoiding elaboration errors, but rather from extra-lingual logic + requirements. Consider this example: + + with Init_Constants; + package Constants is + X : Integer := 0; + Y : Integer := 0; + end Constants; + + package Init_Constants is + procedure Calc; + end Init_Constants; + + with Constants; + package body Init_Constants is + procedure Calc is begin null; end; + begin + Constants.X := 3; + Constants.Y := 4; + end Init_Constants; + + with Constants; + package Calc is + Z : Integer := Constants.X + Constants.Y; + end Calc; + + with Calc; + with Text_IO; use Text_IO; + procedure Main is + begin + Put_Line (Calc.Z'Img); + end Main; + + In this example, there is more than one valid order of elaboration. For + example both the following are correct orders: + + Init_Constants spec + Constants spec + Calc spec + Main body + Init_Constants body + + and + + Init_Constants spec + Init_Constants body + Constants spec + Calc spec + Main body + + There is no language rule to prefer one or the other, both are correct + from an order of elaboration point of view. But the programmatic effects + of the two orders are very different. In the first, the elaboration + routine of `Calc' initializes `Z' to zero, and then the main program + runs with this value of zero. But in the second order, the elaboration + routine of `Calc' runs after the body of Init_Constants has set `X' and + `Y' and thus `Z' is set to 7 before `Main' runs. + + One could perhaps by applying pretty clever non-artificial + intelligence to the situation guess that it is more likely that the + second order of elaboration is the one desired, but there is no formal + linguistic reason to prefer one over the other. In fact in this + particular case, GNAT will prefer the second order, because of the rule + that bodies are elaborated as soon as possible, but it's just luck that + this is what was wanted (if indeed the second order was preferred). + + If the program cares about the order of elaboration routines in a + case like this, it is important to specify the order required. In this + particular case, that could have been achieved by adding to the spec of + Calc: + + pragma Elaborate_All (Constants); + + which requires that the body (if any) and spec of `Constants', as well + as the body and spec of any unit `with''ed by `Constants' be elaborated + before `Calc' is elaborated. + + Clearly no automatic method can always guess which alternative you + require, and if you are working with legacy code that had constraints + of this kind which were not properly specified by adding `Elaborate' or + `Elaborate_All' pragmas, then indeed it is possible that two different + compilers can choose different orders. + + The `GNAT BIND' `/PESSIMISTIC_ELABORATION' qualifier may be useful + in smoking out problems. This qualifier causes bodies to be elaborated + as late as possible instead of as early as possible. In the example + above, it would have forced the choice of the first elaboration order. + If you get different results when using this qualifier, and + particularly if one set of results is right, and one is wrong as far as + you are concerned, it shows that you have some missing `Elaborate' + pragmas. For the example above, we have the following output: + + GNAT MAKE -f -q main + main + 7 + GNAT MAKE -f -q main /BINDER_QUALIFIERS -p + main + 0 + + It is of course quite unlikely that both these results are correct, so + it is up to you in a case like this to investigate the source of the + difference, by looking at the two elaboration orders that are chosen, + and figuring out which is correct, and then adding the necessary + `Elaborate_All' pragmas to ensure the desired order. + +  + File: gnat_ug_vms.info, Node: The Cross-Referencing Tools GNAT XREF and GNAT FIND, Next: File Name Krunching Using GNAT KRUNCH, Prev: Elaboration Order Handling in GNAT, Up: Top + + The Cross-Referencing Tools `GNAT XREF' and `GNAT FIND' + ******************************************************* + + The compiler generates cross-referencing information (unless you set + the `/XREF=SUPPRESS' qualifier), which are saved in the `.ALI' files. + This information indicates where in the source each entity is declared + and referenced. Note that entities in package Standard are not + included, but entities in all other predefined units are included in + the output. + + Before using any of these two tools, you need to compile + successfully your application, so that GNAT gets a chance to generate + the cross-referencing information. + + The two tools `GNAT XREF' and `GNAT FIND' take advantage of this + information to provide the user with the capability to easily locate the + declaration and references to an entity. These tools are quite similar, + the difference being that `GNAT FIND' is intended for locating + definitions and/or references to a specified entity or entities, whereas + `GNAT XREF' is oriented to generating a full report of all + cross-references. + + To use these tools, you must not compile your application using the + `/XREF=SUPPRESS' qualifier on the `GNAT MAKE' command line (*note + (gnat_ug)The GNAT Make Program GNAT MAKE::). Otherwise, + cross-referencing information will not be generated. + + * Menu: + + * GNAT XREF Qualifiers:: + * GNAT FIND Qualifiers:: + * Project Files for GNAT XREF and GNAT FIND:: + * Regular Expressions in GNAT FIND and GNAT XREF:: + * Examples of GNAT XREF Usage:: + * Examples of GNAT FIND Usage:: + +  + File: gnat_ug_vms.info, Node: GNAT XREF Qualifiers, Next: GNAT FIND Qualifiers, Up: The Cross-Referencing Tools GNAT XREF and GNAT FIND + + `GNAT XREF' Qualifiers + ====================== + + The command lines for `GNAT XREF' is: + $ GNAT XREF [qualifiers] sourcefile1 [sourcefile2 ...] + + where + + `sourcefile1, sourcefile2' + identifies the source files for which a report is to be generated. + The 'with'ed units will be processed too. You must provide at + least one file. + + These file names are considered to be regular expressions, so for + instance specifying 'source*.ADB' is the same as giving every file + in the current directory whose name starts with 'source' and whose + extension is 'adb'. + + The qualifiers can be : + `/ALL_FILES' + If this qualifier is present, `GNAT FIND' and `GNAT XREF' will + parse the read-only files found in the library search path. + Otherwise, these files will be ignored. This option can be used to + protect Gnat sources or your own libraries from being parsed, thus + making `GNAT FIND' and `GNAT XREF' much faster, and their output + much smaller. + + `/SOURCE_SEARCH=direc' + When looking for source files also look in directory DIR. The + order in which source file search is undertaken is the same as for + `GNAT MAKE'. + + `/OBJECT_SEARCH=direc' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as + for `GNAT MAKE'. + + `/NOSTD_INCLUDES' + Do not look for sources in the system default directory. + + `/NOSTD_LIBRARIES' + Do not look for library files in the system default directory. + + `/RUNTIME_SYSTEM=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `GNAT MAKE' flag (see *Note Qualifiers + for GNAT MAKE::). + + `-d' + If this qualifier is set `GNAT XREF' will output the parent type + reference for each matching derived types. + + `/FULL_PATHNAME' + If this qualifier is set, the output file names will be preceded + by their directory (if the file was found in the search path). If + this qualifier is not set, the directory will not be printed. + + `/IGNORE_LOCALS' + If this qualifier is set, information is output only for + library-level entities, ignoring local entities. The use of this + qualifier may accelerate `GNAT FIND' and `GNAT XREF'. + + `/SEARCH=direc' + Equivalent to `/OBJECT_SEARCH=direc /SOURCE_SEARCH=direc'. + + `/PROJECT=file' + Specify a project file to use *Note Project Files::. By default, + `GNAT XREF' and `GNAT FIND' will try to locate a project file in + the current directory. + + If a project file is either specified or found by the tools, then + the content of the source directory and object directory lines are + added as if they had been specified respectively by + `/SOURCE_SEARCH' and `OBJECT_SEARCH'. + + `/UNUSED' + Output only unused symbols. This may be really useful if you give + your main compilation unit on the command line, as `GNAT XREF' + will then display every unused entity and 'with'ed package. + + All these qualifiers may be in any order on the command line, and + may even appear after the file names. They need not be separated by + spaces, thus you can say `GNAT XREF /ALL_FILES/IGNORE_LOCALS' instead of + `GNAT XREF /ALL_FILES /IGNORE_LOCALS'. + +  + File: gnat_ug_vms.info, Node: GNAT FIND Qualifiers, Next: Project Files for GNAT XREF and GNAT FIND, Prev: GNAT XREF Qualifiers, Up: The Cross-Referencing Tools GNAT XREF and GNAT FIND + + `GNAT FIND' Qualifiers + ====================== + + The command line for `GNAT FIND' is: + + $ GNAT FIND [qualifiers] pattern[:sourcefile[:line[:column]]] + [file1 file2 ...] + + where + + `pattern' + An entity will be output only if it matches the regular expression + found in `pattern', see *Note Regular Expressions in GNAT FIND and + GNAT XREF::. + + Omitting the pattern is equivalent to specifying `*', which will + match any entity. Note that if you do not provide a pattern, you + have to provide both a sourcefile and a line. + + Entity names are given in Latin-1, with uppercase/lowercase + equivalence for matching purposes. At the current time there is no + support for 8-bit codes other than Latin-1, or for wide characters + in identifiers. + + `sourcefile' + `GNAT FIND' will look for references, bodies or declarations of + symbols referenced in `sourcefile', at line `line' and column + `column'. See *note Examples of GNAT FIND Usage:: for syntax + examples. + + `line' + is a decimal integer identifying the line number containing the + reference to the entity (or entities) to be located. + + `column' + is a decimal integer identifying the exact location on the line of + the first character of the identifier for the entity reference. + Columns are numbered from 1. + + `file1 file2 ...' + The search will be restricted to these files. If none are given, + then the search will be done for every library file in the search + path. These file must appear only after the pattern or sourcefile. + + These file names are considered to be regular expressions, so for + instance specifying 'source*.ADB' is the same as giving every file + in the current directory whose name starts with 'source' and whose + extension is 'adb'. + + Not that if you specify at least one file in this part, `GNAT + FIND' may sometimes not be able to find the body of the + subprograms... + + At least one of 'sourcefile' or 'pattern' has to be present on the + command line. + + The following qualifiers are available: + `/ALL_FILES' + If this qualifier is present, `GNAT FIND' and `GNAT XREF' will + parse the read-only files found in the library search path. + Otherwise, these files will be ignored. This option can be used to + protect Gnat sources or your own libraries from being parsed, thus + making `GNAT FIND' and `GNAT XREF' much faster, and their output + much smaller. + + `/SOURCE_SEARCH=direc' + When looking for source files also look in directory DIR. The + order in which source file search is undertaken is the same as for + `GNAT MAKE'. + + `/OBJECT_SEARCH=direc' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as + for `GNAT MAKE'. + + `/NOSTD_INCLUDES' + Do not look for sources in the system default directory. + + `/NOSTD_LIBRARIES' + Do not look for library files in the system default directory. + + `/RUNTIME_SYSTEM=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `GNAT MAKE' flag (see *Note Qualifiers + for GNAT MAKE::). + + `-d' + If this qualifier is set, then `GNAT FIND' will output the parent + type reference for each matching derived types. + + `/EXPRESSIONS' + By default, `GNAT FIND' accept the simple regular expression set + for `pattern'. If this qualifier is set, then the pattern will be + considered as full Unix-style regular expression. + + `/FULL_PATHNAME' + If this qualifier is set, the output file names will be preceded + by their directory (if the file was found in the search path). If + this qualifier is not set, the directory will not be printed. + + `/IGNORE_LOCALS' + If this qualifier is set, information is output only for + library-level entities, ignoring local entities. The use of this + qualifier may accelerate `GNAT FIND' and `GNAT XREF'. + + `/SEARCH=direc' + Equivalent to `/OBJECT_SEARCH=direc /SOURCE_SEARCH=direc'. + + `/PROJECT=file' + Specify a project file (*note Project Files::) to use. By + default, `GNAT XREF' and `GNAT FIND' will try to locate a project + file in the current directory. + + If a project file is either specified or found by the tools, then + the content of the source directory and object directory lines are + added as if they had been specified respectively by + `/SOURCE_SEARCH' and `/OBJECT_SEARCH'. + + `/REFERENCES' + By default, `GNAT FIND' will output only the information about the + declaration, body or type completion of the entities. If this + qualifier is set, the `GNAT FIND' will locate every reference to + the entities in the files specified on the command line (or in + every file in the search path if no file is given on the command + line). + + `/PRINT_LINES' + If this qualifier is set, then `GNAT FIND' will output the content + of the Ada source file lines were the entity was found. + + `-t' + If this qualifier is set, then `GNAT FIND' will output the type + hierarchy for the specified type. It act like -d option but + recursively from parent type to parent type. When this qualifier + is set it is not possible to specify more than one file. + + All these qualifiers may be in any order on the command line, and + may even appear after the file names. They need not be separated by + spaces, thus you can say `GNAT XREF /ALL_FILES/IGNORE_LOCALS' instead of + `GNAT XREF /ALL_FILES /IGNORE_LOCALS'. + + As stated previously, GNAT FIND will search in every directory in the + search path. You can force it to look only in the current directory if + you specify `*' at the end of the command line. + +  + File: gnat_ug_vms.info, Node: Project Files for GNAT XREF and GNAT FIND, Next: Regular Expressions in GNAT FIND and GNAT XREF, Prev: GNAT FIND Qualifiers, Up: The Cross-Referencing Tools GNAT XREF and GNAT FIND + + Project Files for `GNAT XREF' and `GNAT FIND' + ============================================= + + Project files allow a programmer to specify how to compile its + application, where to find sources,... These files are used primarily by + the Glide Ada mode, but they can also be used by the two tools `GNAT + XREF' and `GNAT FIND'. + + A project file name must end with `.adp'. If a single one is present + in the current directory, then `GNAT XREF' and `GNAT FIND' will extract + the information from it. If multiple project files are found, none of + them is read, and you have to use the `-p' qualifier to specify the one + you want to use. + + The following lines can be included, even though most of them have + default values which can be used in most cases. The lines can be + entered in any order in the file. Except for `src_dir' and `obj_dir', + you can only have one instance of each line. If you have multiple + instances, only the last one is taken into account. + + `src_dir=DIR [default: "[]"]' + specifies a directory where to look for source files. Multiple + src_dir lines can be specified and they will be searched in the + order they are specified. + + `obj_dir=DIR [default: "[]"]' + specifies a directory where to look for object and library files. + Multiple obj_dir lines can be specified and they will be searched + in the order they are specified + + `comp_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${comp_opt}' notation. This is intended to store the default + qualifiers given to `GNAT MAKE' and `GNAT COMPILE'. + + `bind_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${bind_opt}' notation. This is intended to store the default + qualifiers given to `GNAT BIND'. + + `link_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${link_opt}' notation. This is intended to store the default + qualifiers given to `GNAT LINK'. + + `main=EXECUTABLE [default: ""]' + specifies the name of the executable for the application. This + variable can be referred to in the following lines by using the + `${main}' notation. + + `comp_cmd=COMMAND [default: "GNAT COMPILE /SEARCH=${src_dir} /DEBUG /TRY_SEMANTICS"]' + specifies the command used to compile a single file in the + application. + + `make_cmd=COMMAND [default: "GNAT MAKE ${main} /SOURCE_SEARCH=${src_dir} /OBJECT_SEARCH=${obj_dir} /DEBUG /TRY_SEMANTICS /COMPILER_QUALIFIERS ${comp_opt} /BINDER_QUALIFIERS ${bind_opt} /LINKER_QUALIFIERS ${link_opt}"]' + specifies the command used to recompile the whole application. + + `run_cmd=COMMAND [default: "${main}"]' + specifies the command used to run the application. + + `debug_cmd=COMMAND [default: "GDB ${main}"]' + specifies the command used to debug the application + + `GNAT XREF' and `GNAT FIND' only take into account the `src_dir' and + `obj_dir' lines, and ignore the others. + +  + File: gnat_ug_vms.info, Node: Regular Expressions in GNAT FIND and GNAT XREF, Next: Examples of GNAT XREF Usage, Prev: Project Files for GNAT XREF and GNAT FIND, Up: The Cross-Referencing Tools GNAT XREF and GNAT FIND + + Regular Expressions in `GNAT FIND' and `GNAT XREF' + ================================================== + + As specified in the section about `GNAT FIND', the pattern can be a + regular expression. Actually, there are to set of regular expressions + which are recognized by the program : + + `globbing patterns' + These are the most usual regular expression. They are the same + that you generally used in a Unix shell command line, or in a DOS + session. + + Here is a more formal grammar : + regexp ::= term + term ::= elmt -- matches elmt + term ::= elmt elmt -- concatenation (elmt then elmt) + term ::= * -- any string of 0 or more characters + term ::= ? -- matches any character + term ::= [char {char}] -- matches any character listed + term ::= [char - char] -- matches any character in range + + `full regular expression' + The second set of regular expressions is much more powerful. This + is the type of regular expressions recognized by utilities such a + `grep'. + + The following is the form of a regular expression, expressed in Ada + reference manual style BNF is as follows + + regexp ::= term {| term} -- alternation (term or term ...) + + term ::= item {item} -- concatenation (item then item) + + item ::= elmt -- match elmt + item ::= elmt * -- zero or more elmt's + item ::= elmt + -- one or more elmt's + item ::= elmt ? -- matches elmt or nothing + elmt ::= nschar -- matches given character + elmt ::= [nschar {nschar}] -- matches any character listed + elmt ::= [^ nschar {nschar}] -- matches any character not listed + elmt ::= [char - char] -- matches chars in given range + elmt ::= \ char -- matches given character + elmt ::= . -- matches any single character + elmt ::= ( regexp ) -- parens used for grouping + + char ::= any character, including special characters + nschar ::= any character except ()[].*+?^ + + Following are a few examples : + + `abcde|fghi' + will match any of the two strings 'abcde' and 'fghi'. + + `abc*d' + will match any string like 'abd', 'abcd', 'abccd', 'abcccd', + and so on + + `[a-z]+' + will match any string which has only lowercase characters in + it (and at least one character + +  + File: gnat_ug_vms.info, Node: Examples of GNAT XREF Usage, Next: Examples of GNAT FIND Usage, Prev: Regular Expressions in GNAT FIND and GNAT XREF, Up: The Cross-Referencing Tools GNAT XREF and GNAT FIND + + Examples of `GNAT XREF' Usage + ============================= + + General Usage + ------------- + + For the following examples, we will consider the following units : + + MAIN.ADS: + 1: with Bar; + 2: package Main is + 3: procedure Foo (B : in Integer); + 4: C : Integer; + 5: private + 6: D : Integer; + 7: end Main; + + MAIN.ADB: + 1: package body Main is + 2: procedure Foo (B : in Integer) is + 3: begin + 4: C := B; + 5: D := B; + 6: Bar.Print (B); + 7: Bar.Print (C); + 8: end Foo; + 9: end Main; + + BAR.ADS: + 1: package Bar is + 2: procedure Print (B : Integer); + 3: end bar; + + The first thing to do is to recompile your application (for + instance, in that case just by doing a `GNAT MAKE main', so that + GNAT generates the cross-referencing information. You can then + issue any of the following commands: + + `GNAT XREF MAIN.ADB' + `GNAT XREF' generates cross-reference information for MAIN.ADB and + every unit 'with'ed by MAIN.ADB. + + The output would be: + B Type: Integer + Decl: BAR.ADS 2:22 + B Type: Integer + Decl: MAIN.ADS 3:20 + Body: MAIN.ADB 2:20 + Ref: MAIN.ADB 4:13 5:13 6:19 + Bar Type: Unit + Decl: BAR.ADS 1:9 + Ref: MAIN.ADB 6:8 7:8 + MAIN.ADS 1:6 + C Type: Integer + Decl: MAIN.ADS 4:5 + Modi: MAIN.ADB 4:8 + Ref: MAIN.ADB 7:19 + D Type: Integer + Decl: MAIN.ADS 6:5 + Modi: MAIN.ADB 5:8 + Foo Type: Unit + Decl: MAIN.ADS 3:15 + Body: MAIN.ADB 2:15 + Main Type: Unit + Decl: MAIN.ADS 2:9 + Body: MAIN.ADB 1:14 + Print Type: Unit + Decl: BAR.ADS 2:15 + Ref: MAIN.ADB 6:12 7:12 + + that is the entity `Main' is declared in MAIN.ADS, line 2, column + 9, its body is in MAIN.ADB, line 1, column 14 and is not + referenced any where. + + The entity `Print' is declared in BAR.ADS, line 2, column 15 and it + it referenced in MAIN.ADB, line 6 column 12 and line 7 column 12. + + `GNAT XREF PACKAGE1.ADB PACKAGE2.ADS' + `GNAT XREF' will generates cross-reference information for + PACKAGE1.ADB, PACKAGE2.ADS and any other package 'with'ed by any + of these. + +  + File: gnat_ug_vms.info, Node: Examples of GNAT FIND Usage, Prev: Examples of GNAT XREF Usage, Up: The Cross-Referencing Tools GNAT XREF and GNAT FIND + + Examples of `GNAT FIND' Usage + ============================= + + `GNAT FIND /FULL_PATHNAME xyz:MAIN.ADB' + Find declarations for all entities xyz referenced at least once in + MAIN.ADB. The references are search in every library file in the + search path. + + The directories will be printed as well (as the `/FULL_PATHNAME' + qualifier is set) + + The output will look like: + [directory]MAIN.ADS:106:14: xyz <= declaration + [directory]MAIN.ADB:24:10: xyz <= body + [directory]FOO.ADS:45:23: xyz <= declaration + + that is to say, one of the entities xyz found in MAIN.ADB is + declared at line 12 of MAIN.ADS (and its body is in MAIN.ADB), and + another one is declared at line 45 of FOO.ADS + + `GNAT FIND /FULL_PATHNAME/SOURCE_LINE xyz:MAIN.ADB' + This is the same command as the previous one, instead `GNAT FIND' + will display the content of the Ada source file lines. + + The output will look like: + + [directory]MAIN.ADS:106:14: xyz <= declaration + procedure xyz; + [directory]MAIN.ADB:24:10: xyz <= body + procedure xyz is + [directory]FOO.ADS:45:23: xyz <= declaration + xyz : Integer; + + This can make it easier to find exactly the location your are + looking for. + + `GNAT FIND /REFERENCES "*x*":MAIN.ADS:123 FOO.ADB' + Find references to all entities containing an x that are + referenced on line 123 of MAIN.ADS. The references will be + searched only in MAIN.ADB and FOO.ADB. + + `GNAT FIND MAIN.ADS:123' + Find declarations and bodies for all entities that are referenced + on line 123 of MAIN.ADS. + + This is the same as `GNAT FIND "*":MAIN.ADB:123'. + + `GNAT FIND [mydir]MAIN.ADB:123:45' + Find the declaration for the entity referenced at column 45 in + line 123 of file MAIN.ADB in directory mydir. Note that it is + usual to omit the identifier name when the column is given, since + the column position identifies a unique reference. + + The column has to be the beginning of the identifier, and should + not point to any character in the middle of the identifier. + +  + File: gnat_ug_vms.info, Node: File Name Krunching Using GNAT KRUNCH, Next: Preprocessing Using GNAT PREPROCESS, Prev: The Cross-Referencing Tools GNAT XREF and GNAT FIND, Up: Top + + File Name Krunching Using `GNAT KRUNCH' + *************************************** + + This chapter discusses the method used by the compiler to shorten the + default file names chosen for Ada units so that they do not exceed the + maximum length permitted. It also describes the `GNAT KRUNCH' utility + that can be used to determine the result of applying this shortening. + + * Menu: + + * About GNAT KRUNCH:: + * Using GNAT KRUNCH:: + * Krunching Method:: + * Examples of GNAT KRUNCH Usage:: + +  + File: gnat_ug_vms.info, Node: About GNAT KRUNCH, Next: Using GNAT KRUNCH, Up: File Name Krunching Using GNAT KRUNCH + + About `GNAT KRUNCH' + =================== + + The default file naming rule in GNAT is that the file name must be + derived from the unit name. The exact default rule is as follows: + * Take the unit name and replace all dots by hyphens. + + * If such a replacement occurs in the second character position of a + name, and the first character is A, G, S, or I then replace the + dot by the character $ (dollar sign) instead of a minus. + The reason for this exception is to avoid clashes with the standard + names for children of System, Ada, Interfaces, and GNAT, which use the + prefixes S- A- I- and G- respectively. + + The `/FILE_NAME_MAX_LENGTH=NN' qualifier of the compiler activates a + "krunching" circuit that limits file names to nn characters (where nn + is a decimal integer). For example, using OpenVMS, where the maximum + file name length is 39, the value of nn is usually set to 39, but if + you want to generate a set of files that would be usable if ported to a + system with some different maximum file length, then a different value + can be specified. The default value of 39 for OpenVMS need not be + specified. + + The `GNAT KRUNCH' utility can be used to determine the krunched name + for a given file, when krunched to a specified maximum length. + +  + File: gnat_ug_vms.info, Node: Using GNAT KRUNCH, Next: Krunching Method, Prev: About GNAT KRUNCH, Up: File Name Krunching Using GNAT KRUNCH + + Using `GNAT KRUNCH' + =================== + + The `GNAT KRUNCH' command has the form + + $ GNAT KRUNCH NAME /COUNT=nn + + NAME can be an Ada name with dots or the GNAT name of the unit, where + the dots representing child units or subunit are replaced by hyphens. + The only confusion arises if a name ends in `.ADS' or `.ADB'. `GNAT + KRUNCH' takes this to be an extension if there are no other dots in the + name. + + LENGTH represents the length of the krunched name. The default when + no argument is given is 39 characters. A length of zero stands for + unlimited, in other words do not chop except for system files which are + always 39. + + The output is the krunched name. The output has an extension only if the + original argument was a file name with an extension. + +  + File: gnat_ug_vms.info, Node: Krunching Method, Next: Examples of GNAT KRUNCH Usage, Prev: Using GNAT KRUNCH, Up: File Name Krunching Using GNAT KRUNCH + + Krunching Method + ================ + + The initial file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + uppercase for all letters, except that a hyphen in the second character + position is replaced by a dollar sign if the first character is A, I, + G, or S. The extension is `.ADS' for a specification and `.ADB' for a + body. Krunching does not affect the extension, but the file name is + shortened to the specified length by following these rules: + + * The name is divided into segments separated by hyphens, tildes or + underscores and all hyphens, tildes, and underscores are + eliminated. If this leaves the name short enough, we are done. + + * If the name is too long, the longest segment is located (left-most + if there are two of equal length), and shortened by dropping its + last character. This is repeated until the name is short enough. + + As an example, consider the krunching of + `OUR-STRINGS-WIDE_FIXED.ADB' to fit the name into 8 characters as + required by some operating systems. + + our-strings-wide_fixed 22 + our strings wide fixed 19 + our string wide fixed 18 + our strin wide fixed 17 + our stri wide fixed 16 + our stri wide fixe 15 + our str wide fixe 14 + our str wid fixe 13 + our str wid fix 12 + ou str wid fix 11 + ou st wid fix 10 + ou st wi fix 9 + ou st wi fi 8 + Final file name: OUSTWIFI.ADB + + * The file names for all predefined units are always krunched to + eight characters. The krunching of these predefined units uses the + following special prefix replacements: + + `ada-' + replaced by `A-' + + `gnat-' + replaced by `G-' + + `interfaces-' + replaced by `I-' + + `system-' + replaced by `S-' + + These system files have a hyphen in the second character position. + That is why normal user files replace such a character with a + dollar sign, to avoid confusion with system file names. + + As an example of this special rule, consider + `ADA-STRINGS-WIDE_FIXED.ADB', which gets krunched as follows: + + ada-strings-wide_fixed 22 + a- strings wide fixed 18 + a- string wide fixed 17 + a- strin wide fixed 16 + a- stri wide fixed 15 + a- stri wide fixe 14 + a- str wide fixe 13 + a- str wid fixe 12 + a- str wid fix 11 + a- st wid fix 10 + a- st wi fix 9 + a- st wi fi 8 + Final file name: A-STWIFI.ADB + + Of course no file shortening algorithm can guarantee uniqueness over + all possible unit names, and if file name krunching is used then it is + your responsibility to ensure that no name clashes occur. The utility + program `GNAT KRUNCH' is supplied for conveniently determining the + krunched name of a file. + +  + File: gnat_ug_vms.info, Node: Examples of GNAT KRUNCH Usage, Prev: Krunching Method, Up: File Name Krunching Using GNAT KRUNCH + + Examples of `GNAT KRUNCH' Usage + =============================== + + $ GNAT KRUNCH VERY_LONG_UNIT_NAME.ADS/count=6 --> VLUNNA.ADS + $ GNAT KRUNCH VERY_LONG_UNIT_NAME.ADS/count=0 --> VERY_LONG_UNIT_NAME.ADS + +  + File: gnat_ug_vms.info, Node: Preprocessing Using GNAT PREPROCESS, Next: The GNAT Run-Time Library Builder GNAT LIBRARY, Prev: File Name Krunching Using GNAT KRUNCH, Up: Top + + Preprocessing Using `GNAT PREPROCESS' + ************************************* + + The `GNAT PREPROCESS' utility provides a simple preprocessing + capability for Ada programs. It is designed for use with GNAT, but is + not dependent on any special features of GNAT. + + * Menu: + + * Using GNAT PREPROCESS:: + * Qualifiers for GNAT PREPROCESS:: + * Form of Definitions File:: + * Form of Input Text for GNAT PREPROCESS:: + +  + File: gnat_ug_vms.info, Node: Using GNAT PREPROCESS, Next: Qualifiers for GNAT PREPROCESS, Up: Preprocessing Using GNAT PREPROCESS + + Using `GNAT PREPROCESS' + ======================= + + To call `GNAT PREPROCESS' use + + $ GNAT PREPROCESS [-bcrsu] [-Dsymbol=value] infile outfile [deffile] + + where + `infile' + is the full name of the input file, which is an Ada source file + containing preprocessor directives. + + `outfile' + is the full name of the output file, which is an Ada source in + standard Ada form. When used with GNAT, this file name will + normally have an ads or adb suffix. + + `deffile' + is the full name of a text file containing definitions of symbols + to be referenced by the preprocessor. This argument is optional, + and can be replaced by the use of the `-D' qualifier. + + `qualifiers' + is an optional sequence of qualifiers as described in the next + section. + +  + File: gnat_ug_vms.info, Node: Qualifiers for GNAT PREPROCESS, Next: Form of Definitions File, Prev: Using GNAT PREPROCESS, Up: Preprocessing Using GNAT PREPROCESS + + Qualifiers for `GNAT PREPROCESS' + ================================ + + `/BLANK_LINES' + Causes both preprocessor lines and the lines deleted by + preprocessing to be replaced by blank lines in the output source + file, preserving line numbers in the output file. + + `/COMMENTS' + Causes both preprocessor lines and the lines deleted by + preprocessing to be retained in the output source as comments + marked with the special string "-! ". This option will result in + line numbers being preserved in the output file. + + `-Dsymbol=value' + Defines a new symbol, associated with value. If no value is given + on the command line, then symbol is considered to be `True'. This + qualifier can be used in place of a definition file. + + `/REMOVE (default)' + This is the default setting which causes lines deleted by + preprocessing to be entirely removed from the output file. + + `/REFERENCE' + Causes a `Source_Reference' pragma to be generated that references + the original input file, so that error messages will use the file + name of this original file. The use of this qualifier implies that + preprocessor lines are not to be removed from the file, so its use + will force `/BLANK_LINES' mode if `/COMMENTS' has not been + specified explicitly. + + Note that if the file to be preprocessed contains multiple units, + then it will be necessary to `GNAT CHOP' the output file from + `GNAT PREPROCESS'. If a `Source_Reference' pragma is present in + the preprocessed file, it will be respected by `GNAT CHOP + /REFERENCE' so that the final chopped files will correctly refer + to the original input source file for `GNAT PREPROCESS'. + + `/SYMBOLS' + Causes a sorted list of symbol names and values to be listed on + the standard output file. + + `/UNDEFINED' + Causes undefined symbols to be treated as having the value FALSE + in the context of a preprocessor test. In the absence of this + option, an undefined symbol in a `#if' or `#elsif' test will be + treated as an error. + +  + File: gnat_ug_vms.info, Node: Form of Definitions File, Next: Form of Input Text for GNAT PREPROCESS, Prev: Qualifiers for GNAT PREPROCESS, Up: Preprocessing Using GNAT PREPROCESS + + Form of Definitions File + ======================== + + The definitions file contains lines of the form + + symbol := value + + where symbol is an identifier, following normal Ada (case-insensitive) + rules for its syntax, and value is one of the following: + + * Empty, corresponding to a null substitution + + * A string literal using normal Ada syntax + + * Any sequence of characters from the set (letters, digits, period, + underline). + + Comment lines may also appear in the definitions file, starting with + the usual `--', and comments may be added to the definitions lines. + +  + File: gnat_ug_vms.info, Node: Form of Input Text for GNAT PREPROCESS, Prev: Form of Definitions File, Up: Preprocessing Using GNAT PREPROCESS + + Form of Input Text for `GNAT PREPROCESS' + ======================================== + + The input text may contain preprocessor conditional inclusion lines, as + well as general symbol substitution sequences. + + The preprocessor conditional inclusion commands have the form + + #if expression [then] + lines + #elsif expression [then] + lines + #elsif expression [then] + lines + ... + #else + lines + #end if; + + In this example, expression is defined by the following grammar: + expression ::= + expression ::= = "" + expression ::= = + expression ::= 'Defined + expression ::= not expression + expression ::= expression and expression + expression ::= expression or expression + expression ::= expression and then expression + expression ::= expression or else expression + expression ::= ( expression ) + + For the first test (expression ::= ) the symbol must have + either the value true or false, that is to say the right-hand of the + symbol definition must be one of the (case-insensitive) literals `True' + or `False'. If the value is true, then the corresponding lines are + included, and if the value is false, they are excluded. + + The test (expression ::= `'Defined') is true only if the + symbol has been defined in the definition file or by a `-D' qualifier + on the command line. Otherwise, the test is false. + + The equality tests are case insensitive, as are all the preprocessor + lines. + + If the symbol referenced is not defined in the symbol definitions + file, then the effect depends on whether or not qualifier `-u' is + specified. If so, then the symbol is treated as if it had the value + false and the test fails. If this qualifier is not specified, then it + is an error to reference an undefined symbol. It is also an error to + reference a symbol that is defined with a value other than `True' or + `False'. + + The use of the `not' operator inverts the sense of this logical + test, so that the lines are included only if the symbol is not defined. + The `then' keyword is optional as shown + + The `#' must be the first non-blank character on a line, but + otherwise the format is free form. Spaces or tabs may appear between + the `#' and the keyword. The keywords and the symbols are case + insensitive as in normal Ada code. Comments may be used on a + preprocessor line, but other than that, no other tokens may appear on a + preprocessor line. Any number of `elsif' clauses can be present, + including none at all. The `else' is optional, as in Ada. + + The `#' marking the start of a preprocessor line must be the first + non-blank character on the line, i.e. it must be preceded only by + spaces or horizontal tabs. + + Symbol substitution outside of preprocessor lines is obtained by + using the sequence + + $symbol + + anywhere within a source line, except in a comment or within a string + literal. The identifier following the `$' must match one of the symbols + defined in the symbol definition file, and the result is to substitute + the value of the symbol in place of `$symbol' in the output file. + + Note that although the substitution of strings within a string + literal is not possible, it is possible to have a symbol whose defined + value is a string literal. So instead of setting XYZ to `hello' and + writing: + + Header : String := "$XYZ"; + + you should set XYZ to `"hello"' and write: + + Header : String := $XYZ; + + and then the substitution will occur as desired. + +  + File: gnat_ug_vms.info, Node: The GNAT Run-Time Library Builder GNAT LIBRARY, Next: The GNAT Library Browser GNAT LIST, Prev: Preprocessing Using GNAT PREPROCESS, Up: Top + + The GNAT Run-Time Library Builder `GNAT LIBRARY' + ************************************************ + + `GNAT LIBRARY' is a tool for rebuilding the GNAT run time with user + supplied configuration pragmas. + + * Menu: + + * Running GNAT LIBRARY:: + * Qualifiers for GNAT LIBRARY:: + * Examples of GNAT LIBRARY Usage:: + +  + File: gnat_ug_vms.info, Node: Running GNAT LIBRARY, Next: Qualifiers for GNAT LIBRARY, Up: The GNAT Run-Time Library Builder GNAT LIBRARY + + Running `GNAT LIBRARY' + ====================== + + The `GNAT LIBRARY' command has the form + + $ GNAT LIBRARY /[CREATE | SET | DELETE]=directory [/CONFIG=file] + +  + File: gnat_ug_vms.info, Node: Qualifiers for GNAT LIBRARY, Next: Examples of GNAT LIBRARY Usage, Prev: Running GNAT LIBRARY, Up: The GNAT Run-Time Library Builder GNAT LIBRARY + + Qualifiers for `GNAT LIBRARY' + ============================= + + `GNAT LIBRARY' recognizes the following qualifiers: + + `/CREATE=directory' + Create the new run-time library in the specified directory. + + `/SET=directory' + Make the library in the specified directory the current run-time + library. + + `/DELETE=directory' + Delete the run-time library in the specified directory. + + `/CONFIG=file' + With /CREATE: Use the configuration pragmas in the specified + file when building the library. + + With /SET: Use the configuration pragmas in the specified + file when compiling. + +  + File: gnat_ug_vms.info, Node: Examples of GNAT LIBRARY Usage, Prev: Qualifiers for GNAT LIBRARY, Up: The GNAT Run-Time Library Builder GNAT LIBRARY + + Example of `GNAT LIBRARY' Usage + =============================== + + Contents of VAXFLOAT.ADC: + pragma Float_Representation (VAX_Float); + + $ GNAT LIBRARY /CREATE=[.VAXFLOAT] /CONFIG=VAXFLOAT.ADC + + GNAT LIBRARY rebuilds the run-time library in directory [.VAXFLOAT] + +  + File: gnat_ug_vms.info, Node: The GNAT Library Browser GNAT LIST, Next: Finding Memory Problems with GNAT Debug Pool, Prev: The GNAT Run-Time Library Builder GNAT LIBRARY, Up: Top + + The GNAT Library Browser `GNAT LIST' + ************************************ + + `GNAT LIST' is a tool that outputs information about compiled units. It + gives the relationship between objects, unit names and source files. It + can also be used to check the source dependencies of a unit as well as + various characteristics. + + * Menu: + + * Running GNAT LIST:: + * Qualifiers for GNAT LIST:: + * Examples of GNAT LIST Usage:: + +  + File: gnat_ug_vms.info, Node: Running GNAT LIST, Next: Qualifiers for GNAT LIST, Up: The GNAT Library Browser GNAT LIST + + Running `GNAT LIST' + =================== + + The `GNAT LIST' command has the form + + $ GNAT LIST qualifiers OBJECT_OR_ALI_FILE + + The main argument is the list of object or `ali' files (*note The Ada + Library Information Files::) for which information is requested. + + In normal mode, without additional option, `GNAT LIST' produces a + four-column listing. Each line represents information for a specific + object. The first column gives the full path of the object, the second + column gives the name of the principal unit in this object, the third + column gives the status of the source and the fourth column gives the + full path of the source representing this unit. Here is a simple + example of use: + + $ GNAT LIST *.OBJ + []DEMO1.OBJ demo1 DIF DEMO1.ADB + []DEMO2.OBJ demo2 OK DEMO2.ADB + []HELLO.OBJ h1 OK HELLO.ADB + []INSTR-CHILD.OBJ instr.child MOK INSTR-CHILD.ADB + []INSTR.OBJ instr OK INSTR.ADB + []TEF.OBJ tef DIF TEF.ADB + []TEXT_IO_EXAMPLE.OBJ text_io_example OK TEXT_IO_EXAMPLE.ADB + []TGEF.OBJ tgef DIF TGEF.ADB + + The first line can be interpreted as follows: the main unit which is + contained in object file `DEMO1.OBJ' is demo1, whose main source is in + `DEMO1.ADB'. Furthermore, the version of the source used for the + compilation of demo1 has been modified (DIF). Each source file has a + status qualifier which can be: + + `OK (unchanged)' + The version of the source file used for the compilation of the + specified unit corresponds exactly to the actual source file. + + `MOK (slightly modified)' + The version of the source file used for the compilation of the + specified unit differs from the actual source file but not enough + to require recompilation. If you use GNAT MAKE with the qualifier + `/MINIMAL_RECOMPILATION', a file marked MOK will not be recompiled. + + `DIF (modified)' + No version of the source found on the path corresponds to the + source used to build this object. + + `??? (file not found)' + No source file was found for this unit. + + `HID (hidden, unchanged version not first on PATH)' + The version of the source that corresponds exactly to the source + used for compilation has been found on the path but it is hidden + by another version of the same source that has been modified. + +  + File: gnat_ug_vms.info, Node: Qualifiers for GNAT LIST, Next: Examples of GNAT LIST Usage, Prev: Running GNAT LIST, Up: The GNAT Library Browser GNAT LIST + + Qualifiers for `GNAT LIST' + ========================== + + `GNAT LIST' recognizes the following qualifiers: + + `/ALL_UNITS' + Consider all units, including those of the predefined Ada library. + Especially useful with `/DEPENDENCIES'. + + `/DEPENDENCIES' + List sources from which specified units depend on. + + `/OUTPUT=OPTIONS' + Output the list of options. + + `/OUTPUT=OBJECTS' + Only output information about object files. + + `/OUTPUT=SOURCES' + Only output information about source files. + + `/OUTPUT=UNITS' + Only output information about compilation units. + + `/OBJECT_SEARCH=DIR' + `/SOURCE_SEARCH=DIR' + `/SEARCH=DIR' + `/NOCURRENT_DIRECTORY' + `/NOSTD_INCLUDES' + Source path manipulation. Same meaning as the equivalent `GNAT + MAKE' flags (see *Note Qualifiers for GNAT MAKE::). + + `/RUNTIME_SYSTEM=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `GNAT MAKE' flag (see *Note Qualifiers + for GNAT MAKE::). + + `/OUTPUT=VERBOSE' + Verbose mode. Output the complete source and object paths. Do not + use the default column layout but instead use long format giving + as much as information possible on each requested units, including + special characteristics such as: + + `Preelaborable' + The unit is preelaborable in the Ada 95 sense. + + `No_Elab_Code' + No elaboration code has been produced by the compiler for + this unit. + + `Pure' + The unit is pure in the Ada 95 sense. + + `Elaborate_Body' + The unit contains a pragma Elaborate_Body. + + `Remote_Types' + The unit contains a pragma Remote_Types. + + `Shared_Passive' + The unit contains a pragma Shared_Passive. + + `Predefined' + This unit is part of the predefined environment and cannot be + modified by the user. + + `Remote_Call_Interface' + The unit contains a pragma Remote_Call_Interface. + +  + File: gnat_ug_vms.info, Node: Examples of GNAT LIST Usage, Prev: Qualifiers for GNAT LIST, Up: The GNAT Library Browser GNAT LIST + + Example of `GNAT LIST' Usage + ============================ + + GNAT LIST /DEPENDENCIES /OUTPUT=SOURCES /ALL_UNITS DEMO1.ADB + + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]ADA.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]A-FINALI.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]A-FILICO.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]A-STREAM.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]A-TAGS.ADS + DEMO1.ADB + GEN_LIST.ADS + GEN_LIST.ADB + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]GNAT.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]G-IO.ADS + INSTR.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]SYSTEM.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-EXCTAB.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-FINIMP.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-FINROO.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-SECSTA.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-STALIB.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-STOELE.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-STRATT.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-TASOLI.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-UNSTYP.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]UNCHCONV.ADS + +  + File: gnat_ug_vms.info, Node: Finding Memory Problems with GNAT Debug Pool, Next: Creating Sample Bodies Using GNAT STUB, Prev: The GNAT Library Browser GNAT LIST, Up: Top + + Finding Memory Problems with GNAT Debug Pool + ******************************************** + + The use of unchecked deallocation and unchecked conversion can easily + lead to incorrect memory references. The problems generated by such + references are usually difficult to tackle because the symptoms can be + very remote from the origin of the problem. In such cases, it is very + helpful to detect the problem as early as possible. This is the purpose + of the Storage Pool provided by `GNAT.Debug_Pools'. + + In order to use the GNAT specific debugging pool, the user must + associate a debug pool object with each of the access types that may be + related to suspected memory problems. See Ada Reference Manual 13.11. + type Ptr is access Some_Type; + Pool : GNAT.Debug_Pools.Debug_Pool; + for Ptr'Storage_Pool use Pool; + + `GNAT.Debug_Pools' is derived from of a GNAT-specific kind of pool: + the Checked_Pool. Such pools, like standard Ada storage pools, allow + the user to redefine allocation and deallocation strategies. They also + provide a checkpoint for each dereference, through the use of the + primitive operation `Dereference' which is implicitly called at each + dereference of an access value. + + Once an access type has been associated with a debug pool, + operations on values of the type may raise four distinct exceptions, + which correspond to four potential kinds of memory corruption: + * `GNAT.Debug_Pools.Accessing_Not_Allocated_Storage' + + * `GNAT.Debug_Pools.Accessing_Deallocated_Storage' + + * `GNAT.Debug_Pools.Freeing_Not_Allocated_Storage' + + * `GNAT.Debug_Pools.Freeing_Deallocated_Storage ' + + For types associated with a Debug_Pool, dynamic allocation is performed + using the standard GNAT allocation routine. References to all allocated + chunks of memory are kept in an internal dictionary. The deallocation + strategy consists in not releasing the memory to the underlying system + but rather to fill it with a memory pattern easily recognizable during + debugging sessions: The memory pattern is the old IBM hexadecimal + convention: 16#DEADBEEF#. Upon each dereference, a check is made that + the access value denotes a properly allocated memory location. Here is + a complete example of use of `Debug_Pools', that includes typical + instances of memory corruption: + with Gnat.Io; use Gnat.Io; + with Unchecked_Deallocation; + with Unchecked_Conversion; + with GNAT.Debug_Pools; + with System.Storage_Elements; + with Ada.Exceptions; use Ada.Exceptions; + procedure Debug_Pool_Test is + + type T is access Integer; + type U is access all T; + + P : GNAT.Debug_Pools.Debug_Pool; + for T'Storage_Pool use P; + + procedure Free is new Unchecked_Deallocation (Integer, T); + function UC is new Unchecked_Conversion (U, T); + A, B : aliased T; + + procedure Info is new GNAT.Debug_Pools.Print_Info(Put_Line); + + begin + Info (P); + A := new Integer; + B := new Integer; + B := A; + Info (P); + Free (A); + begin + Put_Line (Integer'Image(B.all)); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + begin + Free (B); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + B := UC(A'Access); + begin + Put_Line (Integer'Image(B.all)); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + begin + Free (B); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + Info (P); + end Debug_Pool_Test; + + The debug pool mechanism provides the following precise diagnostics on + the execution of this erroneous program: + Debug Pool info: + Total allocated bytes : 0 + Total deallocated bytes : 0 + Current Water Mark: 0 + High Water Mark: 0 + + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 0 + Current Water Mark: 8 + High Water Mark: 8 + + raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 4 + Current Water Mark: 4 + High Water Mark: 8 + +  + File: gnat_ug_vms.info, Node: Creating Sample Bodies Using GNAT STUB, Next: Reducing the Size of Ada Executables with GNAT ELIM, Prev: Finding Memory Problems with GNAT Debug Pool, Up: Top + + Creating Sample Bodies Using `GNAT STUB' + **************************************** + + `GNAT STUB' creates body stubs, that is, empty but compilable bodies + for library unit declarations. + + To create a body stub, `GNAT STUB' has to compile the library unit + declaration. Therefore, bodies can be created only for legal library + units. Moreover, if a library unit depends semantically upon units + located outside the current directory, you have to provide the source + search path when calling `GNAT STUB', see the description of `GNAT + STUB' qualifiers below. + + * Menu: + + * Running GNAT STUB:: + * Qualifiers for GNAT STUB:: + +  + File: gnat_ug_vms.info, Node: Running GNAT STUB, Next: Qualifiers for GNAT STUB, Up: Creating Sample Bodies Using GNAT STUB + + Running `GNAT STUB' + =================== + + `GNAT STUB' has the command-line interface of the form + + $ GNAT STUB [qualifiers] filename [directory] + + where + `filename' + is the name of the source file that contains a library unit + declaration for which a body must be created. This name should + follow the GNAT file name conventions. No crunching is allowed for + this file name. The file name may contain the path information. + + `directory' + indicates the directory to place a body stub (default is the + current directory) + + `qualifiers' + is an optional sequence of qualifiers as described in the next + section + +  + File: gnat_ug_vms.info, Node: Qualifiers for GNAT STUB, Prev: Running GNAT STUB, Up: Creating Sample Bodies Using GNAT STUB + + Qualifiers for `GNAT STUB' + ========================== + + `/FULL' + If the destination directory already contains a file with a name + of the body file for the argument spec file, replace it with the + generated body stub. + + `/HEADER=SPEC' + Put the comment header (i.e. all the comments preceding the + compilation unit) from the source of the library unit declaration + into the body stub. + + `/HEADER=GENERAL' + Put a sample comment header into the body stub. + + `/SEARCH=direc' + `/NOCURRENT_DIRECTORY' + These qualifiers have the same meaning as in calls to GNAT COMPILE. + They define the source search path in the call to GNAT COMPILE + issued by `GNAT STUB' to compile an argument source file. + + `/INDENTATION=N' + (N is a decimal natural number). Set the indentation level in the + generated body sample to n, '/INDENTATION=0' means "no + indentation", the default indentation is 3. + + `/TREE_FILE=SAVE' + Do not remove the tree file (i.e. the snapshot of the compiler + internal structures used by `GNAT STUB') after creating the body + stub. + + `/LINE_LENGTH=N' + (N is a decimal positive number) Set the maximum line length in the + body stub to n, the default is 78. + + `/QUIET' + Quiet mode: do not generate a confirmation when a body is + successfully created or a message when a body is not required for + an argument unit. + + `/TREE_FILE=REUSE' + Reuse the tree file (if it exists) instead of creating it: instead + of creating the tree file for the library unit declaration, GNAT + STUB tries to find it in the current directory and use it for + creating a body. If the tree file is not found, no body is + created. `/REUSE' also implies `/SAVE', whether or not `/SAVE' is + set explicitly. + + `/TREE_FILE=OVERWRITE' + Overwrite the existing tree file: if the current directory already + contains the file which, according to the GNAT file name rules + should be considered as a tree file for the argument source file, + GNAT STUB will refuse to create the tree file needed to create a + body sampler, unless `-t' option is set + + `/VERBOSE' + Verbose mode: generate version information. + +  + File: gnat_ug_vms.info, Node: Reducing the Size of Ada Executables with GNAT ELIM, Next: Other Utility Programs, Prev: Creating Sample Bodies Using GNAT STUB, Up: Top + + Reducing the Size of Ada Executables with `GNAT ELIM' + ***************************************************** + + * Menu: + + * About GNAT ELIM:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for GNAT ELIM:: + * Running GNAT ELIM:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the GNAT ELIM Usage Cycle:: + +  + File: gnat_ug_vms.info, Node: About GNAT ELIM, Next: Eliminate Pragma, Up: Reducing the Size of Ada Executables with GNAT ELIM + + About `GNAT ELIM' + ================= + + When a program shares a set of Ada packages with other programs, it may + happen that this program uses only a fraction of the subprograms + defined in these packages. The code created for these unused + subprograms increases the size of the executable. + + `GNAT ELIM' tracks unused subprograms in an Ada program and outputs + a list of GNAT-specific `Eliminate' pragmas (see next section) marking + all the subprograms that are declared but never called. By placing the + list of `Eliminate' pragmas in the GNAT configuration file `GNAT.ADC' + and recompiling your program, you may decrease the size of its + executable, because the compiler will not generate the code for + 'eliminated' subprograms. + + `GNAT ELIM' needs as its input data a set of tree files (see *Note + Tree Files::) representing all the components of a program to process + and a bind file for a main subprogram (see *Note Preparing Tree and + Bind Files for GNAT ELIM::). + +  + File: gnat_ug_vms.info, Node: Eliminate Pragma, Next: Tree Files, Prev: About GNAT ELIM, Up: Reducing the Size of Ada Executables with GNAT ELIM + + `Eliminate' Pragma + ================== + + The simplified syntax of the Eliminate pragma used by `GNAT ELIM' is: + + pragma Eliminate (Library_Unit_Name, Subprogram_Name); + + where + `Library_Unit_Name' + full expanded Ada name of a library unit + + `Subprogram_Name' + a simple or expanded name of a subprogram declared within this + compilation unit + + The effect of an `Eliminate' pragma placed in the GNAT configuration + file `GNAT.ADC' is: + + * If the subprogram `Subprogram_Name' is declared within the library + unit `Library_Unit_Name', the compiler will not generate code for + this subprogram. This applies to all overloaded subprograms denoted + by `Subprogram_Name'. + + * If a subprogram marked by the pragma `Eliminate' is used (called) + in a program, the compiler will produce an error message in the + place where it is called. + +  + File: gnat_ug_vms.info, Node: Tree Files, Next: Preparing Tree and Bind Files for GNAT ELIM, Prev: Eliminate Pragma, Up: Reducing the Size of Ada Executables with GNAT ELIM + + Tree Files + ========== + + A tree file stores a snapshot of the compiler internal data structures + at the very end of a successful compilation. It contains all the + syntactic and semantic information for the compiled unit and all the + units upon which it depends semantically. To use tools that make use + of tree files, you need to first produce the right set of tree files. + + GNAT produces correct tree files when /TREE_OUTPUT /NOLOAD options + are set in a GNAT COMPILE call. The tree files have an .adt extension. + Therefore, to produce a tree file for the compilation unit contained in + a file named `FOO.ADB', you must use the command + + $ GNAT COMPILE /NOLOAD /TREE_OUTPUT FOO.ADB + + and you will get the tree file `foo.adt'. compilation. + +  + File: gnat_ug_vms.info, Node: Preparing Tree and Bind Files for GNAT ELIM, Next: Running GNAT ELIM, Prev: Tree Files, Up: Reducing the Size of Ada Executables with GNAT ELIM + + Preparing Tree and Bind Files for `GNAT ELIM' + ============================================= + + A set of tree files covering the program to be analyzed with `GNAT + ELIM' and the bind file for the main subprogram does not have to be in + the current directory. '-T' GNAT ELIM option may be used to provide + the search path for tree files, and '-b' option may be used to point to + the bind file to process (see *Note Running GNAT ELIM::) + + If you do not have the appropriate set of tree files and the right + bind file, you may create them in the current directory using the + following procedure. + + Let `Main_Prog' be the name of a main subprogram, and suppose this + subprogram is in a file named `MAIN_PROG.ADB'. + + To create a bind file for `GNAT ELIM', run `GNAT BIND' for the main + subprogram. `GNAT ELIM' can work with both Ada and C bind files; when + both are present, it uses the Ada bind file. The following commands + will build the program and create the bind file: + + $ GNAT MAKE /ACTIONS=COMPILE MAIN_PROG + $ GNAT BIND main_prog + + To create a minimal set of tree files covering the whole program, call + `GNAT MAKE' for this program as follows: + + $ GNAT MAKE /FORCE_COMPILE /ACTIONS=COMPILE /NOLOAD /TREE_OUTPUT MAIN_PROG + + The `/ACTIONS=COMPILE' GNAT MAKE option turns off the bind and link + steps, that are useless anyway because the sources are compiled with + `/NOLOAD' option which turns off code generation. + + The `/FORCE_COMPILE' GNAT MAKE option forces recompilation of all + the needed sources. + + This sequence of actions will create all the data needed by `GNAT + ELIM' from scratch and therefore guarantee its consistency. If you + would like to use some existing set of files as `GNAT ELIM' output, you + must make sure that the set of files is complete and consistent. You + can use the `-m' qualifier to check if there are missed tree files + + Note, that `GNAT ELIM' needs neither object nor ALI files. + +  + File: gnat_ug_vms.info, Node: Running GNAT ELIM, Next: Correcting the List of Eliminate Pragmas, Prev: Preparing Tree and Bind Files for GNAT ELIM, Up: Reducing the Size of Ada Executables with GNAT ELIM + + Running `GNAT ELIM' + =================== + + `GNAT ELIM' has the following command-line interface: + + $ GNAT ELIM [options] name + + `name' should be a full expanded Ada name of a main subprogram of a + program (partition). + + `GNAT ELIM' options: + + `/QUIET' + Quiet mode: by default `GNAT ELIM' generates to the standard error + stream a trace of the source file names of the compilation units + being processed. This option turns this trace off. + + `/VERBOSE' + Verbose mode: `GNAT ELIM' version information is printed as Ada + comments to the standard output stream. + + `/ALL' + Also look for subprograms from the GNAT run time that can be + eliminated. + + `/MISSED' + Check if any tree files are missing for an accurate result. + + `/TREE_DIRS=DIR' + When looking for tree files also look in directory DIR + + `/BIND_FILE=BIND_FILE' + Specifies BIND_FILE as the bind file to process. If not set, the + name of the bind file is computed from the full expanded Ada name + of a main subprogram. + + `-dX' + Activate internal debugging qualifiers. X is a letter or digit, or + string of letters or digits, which specifies the type of debugging + mode desired. Normally these are used only for internal + development or system debugging purposes. You can find full + documentation for these qualifiers in the body of the `GNAT + ELIM.Options' unit in the compiler source file + `GNATELIM-OPTIONS.ADB'. + + `GNAT ELIM' sends its output to the standard output stream, and all the + tracing and debug information is sent to the standard error stream. In + order to produce a proper GNAT configuration file `GNAT.ADC', + redirection must be used: + + $ PIPE GNAT ELIM MAIN_PROG > GNAT.ADC + + In order to append the `GNAT ELIM' output to the existing contents of + `GNAT.ADC'. + +  + File: gnat_ug_vms.info, Node: Correcting the List of Eliminate Pragmas, Next: Making Your Executables Smaller, Prev: Running GNAT ELIM, Up: Reducing the Size of Ada Executables with GNAT ELIM + + Correcting the List of Eliminate Pragmas + ======================================== + + In some rare cases it may happen that `GNAT ELIM' will try to eliminate + subprograms which are actually called in the program. In this case, the + compiler will generate an error message of the form: + + FILE.ADB:106:07: cannot call eliminated subprogram "My_Prog" + + You will need to manually remove the wrong `Eliminate' pragmas from the + `GNAT.ADC' file. It is advised that you recompile your program from + scratch after that because you need a consistent `GNAT.ADC' file during + the entire compilation. + +  + File: gnat_ug_vms.info, Node: Making Your Executables Smaller, Next: Summary of the GNAT ELIM Usage Cycle, Prev: Correcting the List of Eliminate Pragmas, Up: Reducing the Size of Ada Executables with GNAT ELIM + + Making Your Executables Smaller + =============================== + + In order to get a smaller executable for your program you now have to + recompile the program completely with the new `GNAT.ADC' file created + by `GNAT ELIM' in your current directory: + + $ GNAT MAKE /FORCE_COMPILE MAIN_PROG + + (you will need `/FORCE_COMPILE' option for GNAT MAKE to recompile + everything with the set of pragmas `Eliminate' you have obtained with + `GNAT ELIM'). + + Be aware that the set of `Eliminate' pragmas is specific to each + program. It is not recommended to merge sets of `Eliminate' pragmas + created for different programs in one `GNAT.ADC' file. + +  + File: gnat_ug_vms.info, Node: Summary of the GNAT ELIM Usage Cycle, Prev: Making Your Executables Smaller, Up: Reducing the Size of Ada Executables with GNAT ELIM + + Summary of the GNAT ELIM Usage Cycle + ==================================== + + Here is a quick summary of the steps to be taken in order to reduce the + size of your executables with `GNAT ELIM'. You may use other GNAT + options to control the optimization level, to produce the debugging + information, to set search path, etc. + + 1. Produce a bind file and a set of tree files + + $ GNAT MAKE /ACTIONS=COMPILE MAIN_PROG + $ GNAT BIND main_prog + $ GNAT MAKE /FORCE_COMPILE /NO_LINK /NOLOAD /TREE_OUTPUT MAIN_PROG + + 2. Generate a list of `Eliminate' pragmas + $ PIPE GNAT ELIM MAIN_PROG > GNAT.ADC + + 3. Recompile the application + + $ GNAT MAKE /FORCE_COMPILE MAIN_PROG + + +  + File: gnat_ug_vms.info, Node: Other Utility Programs, Next: Compatibility with DEC Ada, Prev: Reducing the Size of Ada Executables with GNAT ELIM, Up: Top + + Other Utility Programs + ********************** + + This chapter discusses some other utility programs available in the Ada + environment. + + * Menu: + + * Using Other Utility Programs with GNAT:: + * The GNAT STANDARD Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * Installing gnathtml:: + * LSE:: + * Profiling:: + +  + File: gnat_ug_vms.info, Node: Using Other Utility Programs with GNAT, Next: The GNAT STANDARD Utility Program, Up: Other Utility Programs + + Using Other Utility Programs with GNAT + ====================================== + + The object files generated by GNAT are in standard system format and in + particular the debugging information uses this format. This means + programs generated by GNAT can be used with existing utilities that + depend on these formats. + +  + File: gnat_ug_vms.info, Node: The GNAT STANDARD Utility Program, Next: The External Symbol Naming Scheme of GNAT, Prev: Using Other Utility Programs with GNAT, Up: Other Utility Programs + + The `GNAT STANDARD' Utility Program + =================================== + + Many of the definitions in package Standard are + implementation-dependent. However, the source of this package does not + exist as an Ada source file, so these values cannot be determined by + inspecting the source. They can be determined by examining in detail + the coding of `CSTAND.ADB' which creates the image of Standard in the + compiler, but this is awkward and requires a great deal of internal + knowledge about the system. + + The `GNAT STANDARD' utility is designed to deal with this situation. + It is an Ada program that dynamically determines the values of all the + relevant parameters in Standard, and prints them out in the form of an + Ada source listing for Standard, displaying all the values of interest. + This output is generated to `SYS$OUTPUT'. + + To determine the value of any parameter in package Standard, simply + run `GNAT STANDARD' with no qualifiers or arguments, and examine the + output. This is preferable to consulting documentation, because you + know that the values you are getting are the actual ones provided by + the executing system. + +  + File: gnat_ug_vms.info, Node: The External Symbol Naming Scheme of GNAT, Next: Ada Mode for Glide, Prev: The GNAT STANDARD Utility Program, Up: Other Utility Programs + + The External Symbol Naming Scheme of GNAT + ========================================= + + In order to interpret the output from GNAT, when using tools that are + originally intended for use with other languages, it is useful to + understand the conventions used to generate link names from the Ada + entity names. + + All link names are in all lowercase letters. With the exception of + library procedure names, the mechanism used is simply to use the full + expanded Ada name with dots replaced by double underscores. For + example, suppose we have the following package spec: + + package QRS is + MN : Integer; + end QRS; + + The variable `MN' has a full expanded Ada name of `QRS.MN', so the + corresponding link name is `qrs__mn'. Of course if a `pragma Export' + is used this may be overridden: + + package Exports is + Var1 : Integer; + pragma Export (Var1, C, External_Name => "var1_name"); + Var2 : Integer; + pragma Export (Var2, C, Link_Name => "var2_link_name"); + end Exports; + + In this case, the link name for VAR1 is whatever link name the C + compiler would assign for the C function VAR1_NAME. This typically + would be either VAR1_NAME or _VAR1_NAME, depending on operating system + conventions, but other possibilities exist. The link name for VAR2 is + VAR2_LINK_NAME, and this is not operating system dependent. + + One exception occurs for library level procedures. A potential + ambiguity arises between the required name `_main' for the C main + program, and the name we would otherwise assign to an Ada library level + procedure called `Main' (which might well not be the main program). + + To avoid this ambiguity, we attach the prefix `_ada_' to such names. + So if we have a library level procedure such as + + procedure Hello (S : String); + + the external name of this procedure will be _ADA_HELLO. + +  + File: gnat_ug_vms.info, Node: Ada Mode for Glide, Next: Converting Ada Files to html with gnathtml, Prev: The External Symbol Naming Scheme of GNAT, Up: Other Utility Programs + + Ada Mode for `Glide' + ==================== + + The Glide mode for programming in Ada (both, Ada83 and Ada95) helps the + user in understanding existing code and facilitates writing new code. It + furthermore provides some utility functions for easier integration of + standard EMACS features when programming in Ada. + + General Features: + ----------------- + + * Full Integrated Development Environment : + + * support of 'project files' for the configuration (directories, + compilation options,...) + + * compiling and stepping through error messages. + + * running and debugging your applications within Glide. + + * easy to use for beginners by pull-down menus, + + * user configurable by many user-option variables. + + Ada Mode Features That Help Understanding Code: + ----------------------------------------------- + + * functions for easy and quick stepping through Ada code, + + * getting cross reference information for identifiers (e.g. find the + defining place by a keystroke), + + * displaying an index menu of types and subprograms and move point to + the chosen one, + + * automatic color highlighting of the various entities in Ada code. + + Glide Support for Writing Ada Code: + ----------------------------------- + + * switching between spec and body files with possible autogeneration + of body files, + + * automatic formating of subprograms parameter lists. + + * automatic smart indentation according to Ada syntax, + + * automatic completion of identifiers, + + * automatic casing of identifiers, keywords, and attributes, + + * insertion of statement templates, + + * filling comment paragraphs like filling normal text, + + For more information, please refer to the online Glide documentation + available in the Glide -> Help Menu. + +  + File: gnat_ug_vms.info, Node: Converting Ada Files to html with gnathtml, Next: Installing gnathtml, Prev: Ada Mode for Glide, Up: Other Utility Programs + + Converting Ada Files to html with `gnathtml' + ============================================ + + This `Perl' script allows Ada source files to be browsed using standard + Web browsers. For installation procedure, see the section *Note + Installing gnathtml::. + + Ada reserved keywords are highlighted in a bold font and Ada + comments in a blue font. Unless your program was compiled with the GNAT + COMPILE `/XREF=SUPPRESS' qualifier to suppress the generation of + cross-referencing information, user defined variables and types will + appear in a different color; you will be able to click on any + identifier and go to its declaration. + + The command line is as follow: + $ perl gnathtml.pl [qualifiers] ada-files + + You can pass it as many Ada files as you want. `gnathtml' will + generate an html file for every ada file, and a global file called + `index.htm'. This file is an index of every identifier defined in the + files. + + The available qualifiers are the following ones : + + `-83' + Only the subset on the Ada 83 keywords will be highlighted, not + the full Ada 95 keywords set. + + `-cc COLOR' + This option allows you to change the color used for comments. The + default value is green. The color argument can be any name + accepted by html. + + `-d' + If the ada files depend on some other files (using for instance the + `with' command, the latter will also be converted to html. Only + the files in the user project will be converted to html, not the + files in the run-time library itself. + + `-D' + This command is the same as -d above, but `gnathtml' will also look + for files in the run-time library, and generate html files for + them. + + `-f' + By default, gnathtml will generate html links only for global + entities ('with'ed units, global variables and types,...). If you + specify the `-f' on the command line, then links will be generated + for local entities too. + + `-l NUMBER' + If this qualifier is provided and NUMBER is not 0, then `gnathtml' + will number the html files every NUMBER line. + + `-I DIR' + Specify a directory to search for library files (`.ALI' files) and + source files. You can provide several -I qualifiers on the command + line, and the directories will be parsed in the order of the + command line. + + `-o DIR' + Specify the output directory for html files. By default, gnathtml + will saved the generated html files in a subdirectory named + `html/'. + + `-p FILE' + If you are using EMACS and the most recent EMACS Ada mode, which + provides a full Integrated Development Environment for compiling, + checking, running and debugging applications, you may be using + `.adp' files to give the directories where EMACS can find sources + and object files. + + Using this qualifier, you can tell gnathtml to use these files. + This allows you to get an html version of your application, even + if it is spread over multiple directories. + + `-sc COLOR' + This option allows you to change the color used for symbol + definitions. The default value is red. The color argument can be + any name accepted by html. + + `-t FILE' + This qualifier provides the name of a file. This file contains a + list of file names to be converted, and the effect is exactly as + though they had appeared explicitly on the command line. This is + the recommended way to work around the command line length limit + on some systems. + +  + File: gnat_ug_vms.info, Node: Installing gnathtml, Next: LSE, Prev: Converting Ada Files to html with gnathtml, Up: Other Utility Programs + + Installing `gnathtml' + ===================== + + `Perl' needs to be installed on your machine to run this script. + `Perl' is freely available for almost every architecture and Operating + System via the Internet. + + On Unix systems, you may want to modify the first line of the + script `gnathtml', to explicitly tell the Operating system where + Perl is. The syntax of this line is : + #!full_path_name_to_perl + + Alternatively, you may run the script using the following command line: + + $ perl gnathtml.pl [qualifiers] files + +  + File: gnat_ug_vms.info, Node: LSE, Next: Profiling, Prev: Installing gnathtml, Up: Other Utility Programs + + LSE + === + + The GNAT distribution provides an Ada 95 template for the Digital + Language Sensitive Editor (LSE), a component of DECset. In order to + access it, invoke LSE with the qualifier + /ENVIRONMENT=GNU:[LIB]ADA95.ENV. + +  + File: gnat_ug_vms.info, Node: Profiling, Prev: LSE, Up: Other Utility Programs + + Profiling + ========= + + GNAT supports The Digital Performance Coverage Analyzer (PCA), a + component of DECset. To use it proceed as outlined under "HELP PCA", + except for running the collection phase with the /DEBUG qualifier. + + $ GNAT MAKE /DEBUG + $ DEFINE LIB$DEBUG PCA$COLLECTOR + $ RUN/DEBUG + +  + File: gnat_ug_vms.info, Node: Running and Debugging Ada Programs, Next: Inline Assembler, Prev: Compatibility with DEC Ada, Up: Top + + Running and Debugging Ada Programs + ********************************** + + This chapter discusses how to debug Ada programs. An incorrect Ada + program may be handled in three ways by the GNAT compiler: + + 1. The illegality may be a violation of the static semantics of Ada. + In that case GNAT diagnoses the constructs in the program that are + illegal. It is then a straightforward matter for the user to + modify those parts of the program. + + 2. The illegality may be a violation of the dynamic semantics of Ada. + In that case the program compiles and executes, but may generate + incorrect results, or may terminate abnormally with some exception. + + 3. When presented with a program that contains convoluted errors, GNAT + itself may terminate abnormally without providing full diagnostics + on the incorrect user program. + + * Menu: + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + +  + File: gnat_ug_vms.info, Node: The GNAT Debugger GDB, Next: Running GDB, Up: Running and Debugging Ada Programs + + The GNAT Debugger GDB + ===================== + + `GDB' is a general purpose, platform-independent debugger that can be + used to debug mixed-language programs compiled with `GCC', and in + particular is capable of debugging Ada programs compiled with GNAT. The + latest versions of `GDB' are Ada-aware and can handle complex Ada data + structures. + + The manual `Debugging with GDB' , located in the GNU:[DOCS] + directory, contains full details on the usage of `GDB', including a + section on its usage on programs. This manual should be consulted for + full details. The section that follows is a brief introduction to the + philosophy and use of `GDB'. + + When GNAT programs are compiled, the compiler optionally writes + debugging information into the generated object file, including + information on line numbers, and on declared types and variables. This + information is separate from the generated code. It makes the object + files considerably larger, but it does not add to the size of the + actual executable that will be loaded into memory, and has no impact on + run-time performance. The generation of debug information is triggered + by the use of the /DEBUG qualifier in the GNAT COMPILE or GNAT MAKE + command used to carry out the compilations. It is important to + emphasize that the use of these options does not change the generated + code. + + The debugging information is written in standard system formats that + are used by many tools, including debuggers and profilers. The format + of the information is typically designed to describe C types and + semantics, but GNAT implements a translation scheme which allows full + details about Ada types and variables to be encoded into these standard + C formats. Details of this encoding scheme may be found in the file + EXP_DBUG.ADS in the GNAT source distribution. However, the details of + this encoding are, in general, of no interest to a user, since `GDB' + automatically performs the necessary decoding. + + When a program is bound and linked, the debugging information is + collected from the object files, and stored in the executable image of + the program. Again, this process significantly increases the size of + the generated executable file, but it does not increase the size of the + executable program itself. Furthermore, if this program is run in the + normal manner, it runs exactly as if the debug information were not + present, and takes no more actual memory. + + However, if the program is run under control of `GDB', the debugger + is activated. The image of the program is loaded, at which point it is + ready to run. If a run command is given, then the program will run + exactly as it would have if `GDB' were not present. This is a crucial + part of the `GDB' design philosophy. `GDB' is entirely non-intrusive + until a breakpoint is encountered. If no breakpoint is ever hit, the + program will run exactly as it would if no debugger were present. When + a breakpoint is hit, `GDB' accesses the debugging information and can + respond to user commands to inspect variables, and more generally to + report on the state of execution. + +  + File: gnat_ug_vms.info, Node: Running GDB, Next: Introduction to GDB Commands, Prev: The GNAT Debugger GDB, Up: Running and Debugging Ada Programs + + Running GDB + =========== + + The debugger can be launched directly and simply from `glide' or + through its graphical interface: `gvd'. It can also be used directly in + text mode. Here is described the basic use of `GDB' in text mode. All + the commands described below can be used in the `gvd' console window + eventhough there is usually other more graphical ways to achieve the + same goals. + + The command to run `GDB' in text mode is + + $ $ GDB PROGRAM + + where `PROGRAM' is the name of the executable file. This activates the + debugger and results in a prompt for debugger commands. The simplest + command is simply `run', which causes the program to run exactly as if + the debugger were not present. The following section describes some of + the additional commands that can be given to `GDB'. + +  + File: gnat_ug_vms.info, Node: Introduction to GDB Commands, Next: Using Ada Expressions, Prev: Running GDB, Up: Running and Debugging Ada Programs + + Introduction to GDB Commands + ============================ + + `GDB' contains a large repertoire of commands. The manual `Debugging + with GDB' , located in the GNU:[DOCS] directory, includes extensive + documentation on the use of these commands, together with examples of + their use. Furthermore, the command HELP invoked from within `GDB' + activates a simple help facility which summarizes the available + commands and their options. In this section we summarize a few of the + most commonly used commands to give an idea of what `GDB' is about. You + should create a simple program with debugging information and + experiment with the use of these `GDB' commands on the program as you + read through the following section. + + `set args ARGUMENTS' + The ARGUMENTS list above is a list of arguments to be passed to + the program on a subsequent run command, just as though the + arguments had been entered on a normal invocation of the program. + The `set args' command is not needed if the program does not + require arguments. + + `run' + The `run' command causes execution of the program to start from + the beginning. If the program is already running, that is to say if + you are currently positioned at a breakpoint, then a prompt will + ask for confirmation that you want to abandon the current + execution and restart. + + `breakpoint LOCATION' + The breakpoint command sets a breakpoint, that is to say a point + at which execution will halt and `GDB' will await further + commands. LOCATION is either a line number within a file, given in + the format `file:linenumber', or it is the name of a subprogram. + If you request that a breakpoint be set on a subprogram that is + overloaded, a prompt will ask you to specify on which of those + subprograms you want to breakpoint. You can also specify that all + of them should be breakpointed. If the program is run and + execution encounters the breakpoint, then the program stops and + `GDB' signals that the breakpoint was encountered by printing the + line of code before which the program is halted. + + `breakpoint exception NAME' + A special form of the breakpoint command which breakpoints whenever + exception NAME is raised. If NAME is omitted, then a breakpoint + will occur when any exception is raised. + + `print EXPRESSION' + This will print the value of the given expression. Most simple Ada + expression formats are properly handled by `GDB', so the expression + can contain function calls, variables, operators, and attribute + references. + + `continue' + Continues execution following a breakpoint, until the next + breakpoint or the termination of the program. + + `step' + Executes a single line after a breakpoint. If the next statement + is a subprogram call, execution continues into (the first + statement of) the called subprogram. + + `next' + Executes a single line. If this line is a subprogram call, + executes and returns from the call. + + `list' + Lists a few lines around the current source location. In practice, + it is usually more convenient to have a separate edit window open + with the relevant source file displayed. Successive applications + of this command print subsequent lines. The command can be given + an argument which is a line number, in which case it displays a + few lines around the specified one. + + `backtrace' + Displays a backtrace of the call chain. This command is typically + used after a breakpoint has occurred, to examine the sequence of + calls that leads to the current breakpoint. The display includes + one line for each activation record (frame) corresponding to an + active subprogram. + + `up' + At a breakpoint, `GDB' can display the values of variables local + to the current frame. The command `up' can be used to examine the + contents of other active frames, by moving the focus up the stack, + that is to say from callee to caller, one frame at a time. + + `down' + Moves the focus of `GDB' down from the frame currently being + examined to the frame of its callee (the reverse of the previous + command), + + `frame N' + Inspect the frame with the given number. The value 0 denotes the + frame of the current breakpoint, that is to say the top of the + call stack. + + The above list is a very short introduction to the commands that + `GDB' provides. Important additional capabilities, including conditional + breakpoints, the ability to execute command sequences on a breakpoint, + the ability to debug at the machine instruction level and many other + features are described in detail in `Debugging with GDB'. Note that + most commands can be abbreviated (for example, c for continue, bt for + backtrace). + +  + File: gnat_ug_vms.info, Node: Using Ada Expressions, Next: Calling User-Defined Subprograms, Prev: Introduction to GDB Commands, Up: Running and Debugging Ada Programs + + Using Ada Expressions + ===================== + + `GDB' supports a fairly large subset of Ada expression syntax, with some + extensions. The philosophy behind the design of this subset is + + * That `GDB' should provide basic literals and access to operations + for arithmetic, dereferencing, field selection, indexing, and + subprogram calls, leaving more sophisticated computations to + subprograms written into the program (which therefore may be + called from `GDB'). + + * That type safety and strict adherence to Ada language restrictions + are not particularly important to the `GDB' user. + + * That brevity is important to the `GDB' user. + + Thus, for brevity, the debugger acts as if there were implicit + `with' and `use' clauses in effect for all user-written packages, thus + making it unnecessary to fully qualify most names with their packages, + regardless of context. Where this causes ambiguity, `GDB' asks the + user's intent. + + For details on the supported Ada syntax, see `Debugging with GDB'. + +  + File: gnat_ug_vms.info, Node: Calling User-Defined Subprograms, Next: Using the Next Command in a Function, Prev: Using Ada Expressions, Up: Running and Debugging Ada Programs + + Calling User-Defined Subprograms + ================================ + + An important capability of `GDB' is the ability to call user-defined + subprograms while debugging. This is achieved simply by entering a + subprogram call statement in the form: + + call subprogram-name (parameters) + + The keyword `call' can be omitted in the normal case where the + `subprogram-name' does not coincide with any of the predefined `GDB' + commands. + + The effect is to invoke the given subprogram, passing it the list of + parameters that is supplied. The parameters can be expressions and can + include variables from the program being debugged. The subprogram must + be defined at the library level within your program, and `GDB' will + call the subprogram within the environment of your program execution + (which means that the subprogram is free to access or even modify + variables within your program). + + The most important use of this facility is in allowing the inclusion + of debugging routines that are tailored to particular data structures + in your program. Such debugging routines can be written to provide a + suitably high-level description of an abstract type, rather than a + low-level dump of its physical layout. After all, the standard `GDB + print' command only knows the physical layout of your types, not their + abstract meaning. Debugging routines can provide information at the + desired semantic level and are thus enormously useful. + + For example, when debugging GNAT itself, it is crucial to have + access to the contents of the tree nodes used to represent the program + internally. But tree nodes are represented simply by an integer value + (which in turn is an index into a table of nodes). Using the `print' + command on a tree node would simply print this integer value, which is + not very useful. But the PN routine (defined in file TREEPR.ADB in the + GNAT sources) takes a tree node as input, and displays a useful high + level representation of the tree node, which includes the syntactic + category of the node, its position in the source, the integers that + denote descendant nodes and parent node, as well as varied semantic + information. To study this example in more detail, you might want to + look at the body of the PN procedure in the stated file. + +  + File: gnat_ug_vms.info, Node: Using the Next Command in a Function, Next: Ada Exceptions, Prev: Calling User-Defined Subprograms, Up: Running and Debugging Ada Programs + + Using the Next Command in a Function + ==================================== + + When you use the `next' command in a function, the current source + location will advance to the next statement as usual. A special case + arises in the case of a `return' statement. + + Part of the code for a return statement is the "epilog" of the + function. This is the code that returns to the caller. There is only + one copy of this epilog code, and it is typically associated with the + last return statement in the function if there is more than one return. + In some implementations, this epilog is associated with the first + statement of the function. + + The result is that if you use the `next' command from a return + statement that is not the last return statement of the function you may + see a strange apparent jump to the last return statement or to the + start of the function. You should simply ignore this odd jump. The + value returned is always that from the first return statement that was + stepped through. + +  + File: gnat_ug_vms.info, Node: Ada Exceptions, Next: Ada Tasks, Prev: Using the Next Command in a Function, Up: Running and Debugging Ada Programs + + Breaking on Ada Exceptions + ========================== + + You can set breakpoints that trip when your program raises selected + exceptions. + + `break exception' + Set a breakpoint that trips whenever (any task in the) program + raises any exception. + + `break exception NAME' + Set a breakpoint that trips whenever (any task in the) program + raises the exception NAME. + + `break exception unhandled' + Set a breakpoint that trips whenever (any task in the) program + raises an exception for which there is no handler. + + `info exceptions' + `info exceptions REGEXP' + The `info exceptions' command permits the user to examine all + defined exceptions within Ada programs. With a regular expression, + REGEXP, as argument, prints out only those exceptions whose name + matches REGEXP. + +  + File: gnat_ug_vms.info, Node: Ada Tasks, Next: Debugging Generic Units, Prev: Ada Exceptions, Up: Running and Debugging Ada Programs + + Ada Tasks + ========= + + `GDB' allows the following task-related commands: + + `info tasks' + This command shows a list of current Ada tasks, as in the + following example: + + (GDB) info tasks + ID TID P-ID Thread Pri State Name + 1 8088000 0 807e000 15 Child Activation Wait main_task + 2 80a4000 1 80ae000 15 Accept/Select Wait b + 3 809a800 1 80a4800 15 Child Activation Wait a + * 4 80ae800 3 80b8000 15 Running c + + In this listing, the asterisk before the first task indicates it + to be the currently running task. The first column lists the task + ID that is used to refer to tasks in the following commands. + + `break LINESPEC task TASKID' + `break LINESPEC task TASKID if ...' + These commands are like the `break ... thread ...'. LINESPEC + specifies source lines. + + Use the qualifier `task TASKID' with a breakpoint command to + specify that you only want `GDB' to stop the program when a + particular Ada task reaches this breakpoint. TASKID is one of the + numeric task identifiers assigned by `GDB', shown in the first + column of the `info tasks' display. + + If you do not specify `task TASKID' when you set a breakpoint, the + breakpoint applies to _all_ tasks of your program. + + You can use the `task' qualifier on conditional breakpoints as + well; in this case, place `task TASKID' before the breakpoint + condition (before the `if'). + + `task TASKNO' + This command allows to qualifier to the task referred by TASKNO. In + particular, This allows to browse the backtrace of the specified + task. It is advised to qualifier back to the original task before + continuing execution otherwise the scheduling of the program may be + perturbated. + + For more detailed information on the tasking support, see `Debugging + with GDB'. + +  + File: gnat_ug_vms.info, Node: Debugging Generic Units, Next: GNAT Abnormal Termination or Failure to Terminate, Prev: Ada Tasks, Up: Running and Debugging Ada Programs + + Debugging Generic Units + ======================= + + GNAT always uses code expansion for generic instantiation. This means + that each time an instantiation occurs, a complete copy of the original + code is made, with appropriate substitutions of formals by actuals. + + It is not possible to refer to the original generic entities in + `GDB', but it is always possible to debug a particular instance of a + generic, by using the appropriate expanded names. For example, if we + have + + procedure g is + + generic package k is + procedure kp (v1 : in out integer); + end k; + + package body k is + procedure kp (v1 : in out integer) is + begin + v1 := v1 + 1; + end kp; + end k; + + package k1 is new k; + package k2 is new k; + + var : integer := 1; + + begin + k1.kp (var); + k2.kp (var); + k1.kp (var); + k2.kp (var); + end; + + Then to break on a call to procedure kp in the k2 instance, simply use + the command: + + (GDB) break g.k2.kp + + When the breakpoint occurs, you can step through the code of the + instance in the normal manner and examine the values of local + variables, as for other units. + +  + File: gnat_ug_vms.info, Node: GNAT Abnormal Termination or Failure to Terminate, Next: Naming Conventions for GNAT Source Files, Prev: Debugging Generic Units, Up: Running and Debugging Ada Programs + + GNAT Abnormal Termination or Failure to Terminate + ================================================= + + When presented with programs that contain serious errors in syntax or + semantics, GNAT may on rare occasions experience problems in + operation, such as aborting with a segmentation fault or illegal memory + access, raising an internal exception, terminating abnormally, or + failing to terminate at all. In such cases, you can activate various + features of GNAT that can help you pinpoint the construct in your + program that is the likely source of the problem. + + The following strategies are presented in increasing order of + difficulty, corresponding to your experience in using GNAT and your + familiarity with compiler internals. + + 1. Run `GNAT COMPILE' with the `/REPORT_ERRORS=FULL'. This first + qualifier causes all errors on a given line to be reported. In its + absence, only the first error on a line is displayed. + + The `/REPORT_ERRORS=IMMEDIATE' qualifier causes errors to be + displayed as soon as they are encountered, rather than after + compilation is terminated. If GNAT terminates prematurely or goes + into an infinite loop, the last error message displayed may help + to pinpoint the culprit. + + 2. Run `GNAT COMPILE' with the `/VERBOSE' qualifier. In this mode, + `GNAT COMPILE' produces ongoing information about the progress of + the compilation and provides the name of each procedure as code is + generated. This qualifier allows you to find which Ada procedure + was being compiled when it encountered a code generation problem. + + 3. Run `GNAT COMPILE' with the `/TRACE_UNITS' qualifier. This is a + GNAT specific qualifier that does for the front-end what `VERBOSE' + does for the back end. The system prints the name of each unit, + either a compilation unit or nested unit, as it is being analyzed. + + 4. Finally, you can start `GDB' directly on the `GNAT1' executable. + `GNAT1' is the front-end of GNAT, and can be run independently + (normally it is just called from `GNAT COMPILE'). You can use + `GDB' on `GNAT1' as you would on a C program (but *note The GNAT + Debugger GDB:: for caveats). The `where' command is the first line + of attack; the variable `lineno' (seen by `print lineno'), used by + the second phase of `GNAT1' and by the `GNAT COMPILE' backend, + indicates the source line at which the execution stopped, and + `input_file name' indicates the name of the source file. + +  + File: gnat_ug_vms.info, Node: Naming Conventions for GNAT Source Files, Next: Getting Internal Debugging Information, Prev: GNAT Abnormal Termination or Failure to Terminate, Up: Running and Debugging Ada Programs + + Naming Conventions for GNAT Source Files + ======================================== + + In order to examine the workings of the GNAT system, the following + brief description of its organization may be helpful: + + * Files with prefix `SC' contain the lexical scanner. + + * All files prefixed with `PAR' are components of the parser. The + numbers correspond to chapters of the Ada 95 Reference Manual. For + example, parsing of select statements can be found in + `PAR-CH9.ADB'. + + * All files prefixed with `SEM' perform semantic analysis. The + numbers correspond to chapters of the Ada standard. For example, + all issues involving context clauses can be found in + `SEM_CH10.ADB'. In addition, some features of the language require + sufficient special processing to justify their own semantic files: + sem_aggr for aggregates, sem_disp for dynamic dispatching, etc. + + * All files prefixed with `EXP' perform normalization and expansion + of the intermediate representation (abstract syntax tree, or AST). + these files use the same numbering scheme as the parser and + semantics files. For example, the construction of record + initialization procedures is done in `EXP_CH3.ADB'. + + * The files prefixed with `BIND' implement the binder, which + verifies the consistency of the compilation, determines an order of + elaboration, and generates the bind file. + + * The files `ATREE.ADS' and `ATREE.ADB' detail the low-level data + structures used by the front-end. + + * The files `SINFO.ADS' and `SINFO.ADB' detail the structure of the + abstract syntax tree as produced by the parser. + + * The files `EINFO.ADS' and `EINFO.ADB' detail the attributes of all + entities, computed during semantic analysis. + + * Library management issues are dealt with in files with prefix + `LIB'. + + * Ada files with the prefix `A-' are children of `Ada', as defined + in Annex A. + + * Files with prefix `I-' are children of `Interfaces', as defined in + Annex B. + + * Files with prefix `S-' are children of `System'. This includes + both language-defined children and GNAT run-time routines. + + * Files with prefix `G-' are children of `GNAT'. These are useful + general-purpose packages, fully documented in their + specifications. All the other `.C' files are modifications of + common `GNAT COMPILE' files. + +  + File: gnat_ug_vms.info, Node: Getting Internal Debugging Information, Next: Stack Traceback, Prev: Naming Conventions for GNAT Source Files, Up: Running and Debugging Ada Programs + + Getting Internal Debugging Information + ====================================== + + Most compilers have internal debugging qualifiers and modes. GNAT does + also, except GNAT internal debugging qualifiers and modes are not + secret. A summary and full description of all the compiler and binder + debug flags are in the file `DEBUG.ADB'. You must obtain the sources of + the compiler to see the full detailed effects of these flags. + + The qualifiers that print the source of the program (reconstructed + from the internal tree) are of general interest for user programs, as + are the options to print the full internal tree, and the entity table + (the symbol table information). The reconstructed source provides a + readable version of the program after the front-end has completed + analysis and expansion, and is useful when studying the performance of + specific constructs. For example, constraint checks are indicated, + complex aggregates are replaced with loops and assignments, and tasking + primitives are replaced with run-time calls. + +  + File: gnat_ug_vms.info, Node: Stack Traceback, Prev: Getting Internal Debugging Information, Up: Running and Debugging Ada Programs + + Stack Traceback + =============== + + Traceback is a mechanism to display the sequence of subprogram calls + that leads to a specified execution point in a program. Often (but not + always) the execution point is an instruction at which an exception has + been raised. This mechanism is also known as stack unwinding because + it obtains its information by scanning the run-time stack and + recovering the activation records of all active subprograms. Stack + unwinding is one of the most important tools for program debugging. + + The first entry stored in traceback corresponds to the deepest calling + level, that is to say the subprogram currently executing the instruction + from which we want to obtain the traceback. + + Note that there is no runtime performance penalty when stack traceback + is enabled and no exception are raised during program execution. + + * Menu: + + * Non-Symbolic Traceback:: + * Symbolic Traceback:: + +  + File: gnat_ug_vms.info, Node: Non-Symbolic Traceback, Next: Symbolic Traceback, Up: Stack Traceback + + Non-Symbolic Traceback + ---------------------- + + Note: this feature is not supported on all platforms. See + `GNAT.Traceback spec in G-TRACEB.ADS' for a complete list of supported + platforms. + + * Menu: + + * Tracebacks From an Unhandled Exception:: + * Tracebacks From Exception Occurrences (non-symbolic):: + * Tracebacks From Anywhere in a Program (non-symbolic):: + +  + File: gnat_ug_vms.info, Node: Tracebacks From an Unhandled Exception, Next: Tracebacks From Exception Occurrences (non-symbolic), Up: Non-Symbolic Traceback + + Tracebacks From an Unhandled Exception + ...................................... + + A runtime non-symbolic traceback is a list of addresses of call + instructions. To enable this feature you must use the `-E' `GNAT + BIND''s option. With this option a stack traceback is stored as part of + exception information. It is possible to retrieve this information + using the standard `Ada.Exception.Exception_Information' routine. + + Let's have a look at a simple example: + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + $ GNAT MAKE stb /BINDER_QUALIFIERS -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: STB.ADB:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + As we see the traceback lists a sequence of addresses for the unhandled + exception `CONSTAINT_ERROR' raised in procedure P1. It is easy to guess + that this exception come from procedure P1. To translate these + addresses into the source lines where the calls appear, the `addr2line' + tool, described below, is invaluable. The use of this tool requires the + program to be compiled with debug information. + + $ GNAT MAKE -g stb /BINDER_QUALIFIERS -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: STB.ADB:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + $ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 + 0x4011f1 0x77e892a4 + + 00401373 at d:/stb/STB.ADB:5 + 0040138B at d:/stb/STB.ADB:10 + 0040139C at d:/stb/STB.ADB:14 + 00401335 at d:/stb/B~STB.ADB:104 + 004011C4 at /build/.../CRT1.C:200 + 004011F1 at /build/.../CRT1.C:222 + 77E892A4 in ?? at ??:0 + + `addr2line' has a number of other useful options: + + `--functions' + to get the function name corresponding to any location + + `--demangle=gnat' + to use the gnat decoding mode for the function names. Note that + for binutils version 2.9.x the option is simply `--demangle'. + + $ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b + 0x40139c 0x401335 0x4011c4 0x4011f1 + + 00401373 in stb.p1 at d:/stb/STB.ADB:5 + 0040138B in stb.p2 at d:/stb/STB.ADB:10 + 0040139C in stb at d:/stb/STB.ADB:14 + 00401335 in main at d:/stb/B~STB.ADB:104 + 004011C4 in <__mingw_CRTStartup> at /build/.../CRT1.C:200 + 004011F1 in at /build/.../CRT1.C:222 + + From this traceback we can see that the exception was raised in + `STB.ADB' at line 5, which was reached from a procedure call in + `STB.ADB' at line 10, and so on. The `B~STD.ADB' is the binder file, + which contains the call to the main program. *note Running GNAT + BIND::. The remaining entries are assorted runtime routines, and the + output will vary from platform to platform. + + It is also possible to use `GDB' with these traceback addresses to debug + the program. For example, we can break at a given code location, as + reported in the stack traceback: + + $ GDB -nw stb + + (GDB) break *0x401373 + Breakpoint 1 at 0x401373: file STB.ADB, line 5. + + It is important to note that the stack traceback addresses do not + change when debug information is included. This is particularly useful + because it makes it possible to release software without debug + information (to minimize object size), get a field report that includes + a stack traceback whenever an internal bug occurs, and then be able to + retrieve the sequence of calls with the same program compiled with + debug information. + +  + File: gnat_ug_vms.info, Node: Tracebacks From Exception Occurrences (non-symbolic), Next: Tracebacks From Anywhere in a Program (non-symbolic), Prev: Tracebacks From an Unhandled Exception, Up: Non-Symbolic Traceback + + Tracebacks From Exception Occurrences + ..................................... + + Non-symbolic tracebacks are obtained by using the `-E' binder argument. + The stack traceback is attached to the exception information string, + and can be retrieved in an exception handler within the Ada program, by + means of the Ada95 facilities defined in `Ada.Exceptions'. Here is a + simple example: + + with Ada.Text_IO; + with Ada.Exceptions; + + procedure STB is + + use Ada; + use Ada.Exceptions; + + procedure P1 is + K : Positive := 1; + begin + K := K - 1; + exception + when E : others => + Text_IO.Put_Line (Exception_Information (E)); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + This program will output: + + $ stb + + Exception name: CONSTRAINT_ERROR + Message: STB.ADB:12 + Call stack traceback locations: + 0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4 + +  + File: gnat_ug_vms.info, Node: Tracebacks From Anywhere in a Program (non-symbolic), Prev: Tracebacks From Exception Occurrences (non-symbolic), Up: Non-Symbolic Traceback + + Tracebacks From Anywhere in a Program + ..................................... + + It is also possible to retrieve a stack traceback from anywhere in a + program. For this you need to use the `GNAT.Traceback' API. This + package includes a procedure called `Call_Chain' that computes a + complete stack traceback, as well as useful display procedures + described below. It is not necessary to use the `-E GNAT BIND' option + in this case, because the stack traceback mechanism is invoked + explicitly. + + In the following example we compute a traceback at a specific location + in the program, and we display it using `GNAT.Debug_Utilities.Image' to + convert addresses to strings: + + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Debug_Utilities; + + procedure STB is + + use Ada; + use GNAT; + use GNAT.Traceback; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + + Text_IO.Put ("In STB.P1 : "); + + for K in 1 .. Len loop + Text_IO.Put (Debug_Utilities.Image (TB (K))); + Text_IO.Put (' '); + end loop; + + Text_IO.New_Line; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + $ GNAT MAKE stb + $ stb + + In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C# + 16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4# + +  + File: gnat_ug_vms.info, Node: Symbolic Traceback, Prev: Non-Symbolic Traceback, Up: Stack Traceback + + Symbolic Traceback + ------------------ + + A symbolic traceback is a stack traceback in which procedure names are + associated with each code location. + + Note that this feature is not supported on all platforms. See + `GNAT.Traceback.Symbolic spec in G-TRASYM.ADS' for a complete list of + currently supported platforms. + + Note that the symbolic traceback requires that the program be compiled + with debug information. If it is not compiled with debug information + only the non-symbolic information will be valid. + + * Menu: + + * Tracebacks From Exception Occurrences (symbolic):: + * Tracebacks From Anywhere in a Program (symbolic):: + +  + File: gnat_ug_vms.info, Node: Tracebacks From Exception Occurrences (symbolic), Next: Tracebacks From Anywhere in a Program (symbolic), Up: Symbolic Traceback + + Tracebacks From Exception Occurrences + ..................................... + + with Ada.Text_IO; + with GNAT.Traceback.Symbolic; + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + procedure P3 is + begin + P2; + end P3; + + begin + P3; + exception + when E : others => + Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); + end STB; + + $ GNAT MAKE -g stb /BINDER_QUALIFIERS -E /LINKER_QUALIFIERS -lgnat -laddr2line -lintl + $ stb + + 0040149F in stb.p1 at STB.ADB:8 + 004014B7 in stb.p2 at STB.ADB:13 + 004014CF in stb.p3 at STB.ADB:18 + 004015DD in ada.stb at STB.ADB:22 + 00401461 in main at B~STB.ADB:168 + 004011C4 in __mingw_CRTStartup at CRT1.C:200 + 004011F1 in mainCRTStartup at CRT1.C:222 + 77E892A4 in ?? at ??:0 + + The exact sequence of linker options may vary from platform to platform. + The above `/LINKER_QUALIFIERS' section is for Windows platforms. By + contrast, under Unix there is no need for the `/LINKER_QUALIFIERS' + section. Differences across platforms are due to details of linker + implementation. + +  + File: gnat_ug_vms.info, Node: Tracebacks From Anywhere in a Program (symbolic), Prev: Tracebacks From Exception Occurrences (symbolic), Up: Symbolic Traceback + + Tracebacks From Anywhere in a Program + ..................................... + + It is possible to get a symbolic stack traceback from anywhere in a + program, just as for non-symbolic tracebacks. The first step is to + obtain a non-symbolic traceback, and then call `Symbolic_Traceback' to + compute the symbolic information. Here is an example: + + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Traceback.Symbolic; + + procedure STB is + + use Ada; + use GNAT.Traceback; + use GNAT.Traceback.Symbolic; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len))); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + +  + File: gnat_ug_vms.info, Node: Compatibility with DEC Ada, Next: Running and Debugging Ada Programs, Prev: Other Utility Programs, Up: Top + + Compatibility with DEC Ada + ************************** + + This section of the manual compares DEC Ada for OpenVMS Alpha and GNAT + OpenVMS Alpha. GNAT achieves a high level of compatibility with DEC + Ada, and it should generally be straightforward to port code from the + DEC Ada environment to GNAT. However, there are a few language and + implementation differences of which the user must be aware. These + differences are discussed in this section. In addition, the operating + environment and command structure for the compiler are different, and + these differences are also discussed. + + Note that this discussion addresses specifically the implementation + of Ada 83 for DIGITAL OpenVMS Alpha Systems. In cases where the + implementation of DEC Ada differs between OpenVMS Alpha Systems and + OpenVMS VAX Systems, GNAT always follows the Alpha implementation. + + * Menu: + + * Ada 95 Compatibility:: + * Differences in the Definition of Package System:: + * Language-Related Features:: + * The Package STANDARD:: + * The Package SYSTEM:: + * Tasking and Task-Related Features:: + * Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems:: + * Pragmas and Pragma-Related Features:: + * Library of Predefined Units:: + * Bindings:: + * Main Program Definition:: + * Implementation-Defined Attributes:: + * Compiler and Run-Time Interfacing:: + * Program Compilation and Library Management:: + * Input-Output:: + * Implementation Limits:: + * Tools:: + +  + File: gnat_ug_vms.info, Node: Ada 95 Compatibility, Next: Differences in the Definition of Package System, Up: Compatibility with DEC Ada + + Ada 95 Compatibility + ==================== + + GNAT is an Ada 95 compiler, and DEC Ada is an Ada 83 compiler. Ada 95 + is almost completely upwards compatible with Ada 83, and therefore Ada + 83 programs will compile and run under GNAT with no changes or only + minor changes. The Ada 95 Reference Manual (ANSI/ISO/IEC-8652:1995) + provides details on specific incompatibilities. + + GNAT provides the qualifier /83 on the GNAT COMPILE command, as well + as the pragma ADA_83, to force the compiler to operate in Ada 83 mode. + This mode does not guarantee complete conformance to Ada 83, but in + practice is sufficient to eliminate most sources of incompatibilities. + In particular, it eliminates the recognition of the additional Ada 95 + keywords, so that their use as identifiers in Ada83 program is legal, + and handles the cases of packages with optional bodies, and generics + that instantiate unconstrained types without the use of `(<>)'. + +  + File: gnat_ug_vms.info, Node: Differences in the Definition of Package System, Next: Language-Related Features, Prev: Ada 95 Compatibility, Up: Compatibility with DEC Ada + + Differences in the Definition of Package System + =============================================== + + Both the Ada 95 and Ada 83 reference manuals permit a compiler to add + implementation-dependent declarations to package System. In normal mode, + GNAT does not take advantage of this permission, and the version of + System provided by GNAT exactly matches that in the Ada 95 Reference + Manual. + + However, DEC Ada adds an extensive set of declarations to package + System, as fully documented in the DEC Ada manuals. To minimize changes + required for programs that make use of these extensions, GNAT provides + the pragma Extend_System for extending the definition of package + System. By using: + + pragma Extend_System (Aux_DEC); + + The set of definitions in System is extended to include those in package + `System.Aux_DEC'. These definitions are incorporated directly into + package System, as though they had been declared there in the first + place. For a list of the declarations added, see the specification of + this package, which can be found in the file `S-AUXDEC.ADS' in the GNAT + library. The pragma Extend_System is a configuration pragma, which + means that it can be placed in the file `GNAT.ADC', so that it will + automatically apply to all subsequent compilations. See the section on + Configuration Pragmas for further details. + + An alternative approach that avoids the use of the non-standard + Extend_System pragma is to add a context clause to the unit that + references these facilities: + + with System.Aux_DEC; + use System.Aux_DEC; + + The effect is not quite semantically identical to incorporating the + declarations directly into package `System', but most programs will not + notice a difference unless they use prefix notation (e.g. + `System.Integer_8') to reference the entities directly in package + `System'. For units containing such references, the prefixes must + either be removed, or the pragma `Extend_System' must be used. + +  + File: gnat_ug_vms.info, Node: Language-Related Features, Next: The Package STANDARD, Prev: Differences in the Definition of Package System, Up: Compatibility with DEC Ada + + Language-Related Features + ========================= + + The following sections highlight differences in types, representations + of types, operations, alignment, and related topics. + + * Menu: + + * Integer Types and Representations:: + * Floating-Point Types and Representations:: + * Pragmas Float_Representation and Long_Float:: + * Fixed-Point Types and Representations:: + * Record and Array Component Alignment:: + * Address Clauses:: + * Other Representation Clauses:: + +  + File: gnat_ug_vms.info, Node: Integer Types and Representations, Next: Floating-Point Types and Representations, Up: Language-Related Features + + Integer Types and Representations + --------------------------------- + + The set of predefined integer types is identical in DEC Ada and GNAT. + Furthermore the representation of these integer types is also identical, + including the capability of size clauses forcing biased representation. + + In addition, DEC Ada for OpenVMS Alpha systems has defined the + following additional integer types in package System: + + * INTEGER_8 + + * INTEGER_16 + + * INTEGER_32 + + * INTEGER_64 + + * LARGEST_INTEGER + + When using GNAT, the first four of these types may be obtained from the + standard Ada 95 package `Interfaces'. Alternatively, by use of the + pragma `Extend_System', identical declarations can be referenced + directly in package `System'. On both GNAT and DEC Ada, the maximum + integer size is 64 bits. + +  + File: gnat_ug_vms.info, Node: Floating-Point Types and Representations, Next: Pragmas Float_Representation and Long_Float, Prev: Integer Types and Representations, Up: Language-Related Features + + Floating-Point Types and Representations + ---------------------------------------- + + The set of predefined floating-point types is identical in DEC Ada and + GNAT. Furthermore the representation of these floating-point types is + also identical. One important difference is that the default + representation for DEC Ada is VAX_Float, but the default representation + for GNAT is IEEE. + + Specific types may be declared to be VAX_Float or IEEE, using the + pragma `Float_Representation' as described in the DEC Ada documentation. + For example, the declarations: + + type F_Float is digits 6; + pragma Float_Representation (VAX_Float, F_Float); + + declare a type F_Float that will be represented in VAX_Float format. + This set of declarations actually appears in System.Aux_DEC, which + provides the full set of additional floating-point declarations + provided in the DEC Ada version of package System. This and similar + declarations may be accessed in a user program by using pragma + `Extend_System'. The use of this pragma, and the related pragma + `Long_Float' is described in further detail in the following section. + +  + File: gnat_ug_vms.info, Node: Pragmas Float_Representation and Long_Float, Next: Fixed-Point Types and Representations, Prev: Floating-Point Types and Representations, Up: Language-Related Features + + Pragmas Float_Representation and Long_Float + ------------------------------------------- + + DEC Ada provides the pragma `Float_Representation', which acts as a + program library qualifier to allow control over the internal + representation chosen for the predefined floating-point types declared + in the package `Standard'. The format of this pragma is as follows: + + pragma `Float_Representation'(VAX_Float | IEEE_Float); + + This pragma controls the representation of floating-point types as + follows: + + * `VAX_Float' specifies that floating-point types are represented by + default with the VAX hardware types F-floating, D-floating, + G-floating. Note that the H-floating type is available only on + DIGITAL Vax systems, and is not available in either DEC Ada or + GNAT for Alpha systems. + + * `IEEE_Float' specifies that floating-point types are represented + by default with the IEEE single and double floating-point types. + + GNAT provides an identical implementation of the pragma + `Float_Representation', except that it functions as a configuration + pragma, as defined by Ada 95. Note that the notion of configuration + pragma corresponds closely to the DEC Ada notion of a program library + qualifier. + + When no pragma is used in GNAT, the default is IEEE_Float, which is + different from DEC Ada 83, where the default is VAX_Float. In addition, + the predefined libraries in GNAT are built using IEEE_Float, so it is + not advisable to change the format of numbers passed to standard library + routines, and if necessary explicit type conversions may be needed. + + The use of IEEE_Float is recommended in GNAT since it is more + efficient, and (given that it conforms to an international standard) + potentially more portable. The situation in which VAX_Float may be + useful is in interfacing to existing code and data that expects the use + of VAX_Float. There are two possibilities here. If the requirement for + the use of VAX_Float is localized, then the best approach is to use the + predefined VAX_Float types in package `System', as extended by + `Extend_System'. For example, use `System.F_Float' to specify the + 32-bit `F-Float' format. + + Alternatively, if an entire program depends heavily on the use of + the `VAX_Float' and in particular assumes that the types in package + `Standard' are in `Vax_Float' format, then it may be desirable to + reconfigure GNAT to assume Vax_Float by default. This is done by using + the GNAT LIBRARY command to rebuild the library, and then using the + general form of the `Float_Representation' pragma to ensure that this + default format is used throughout. The form of the GNAT LIBRARY + command is: + + GNAT LIBRARY /CONFIG=file /CREATE=directory + + where file contains the new configuration pragmas and directory is the + directory to be created to contain the new library. + + On OpenVMS systems, DEC Ada provides the pragma `Long_Float' to allow + control over the internal representation chosen for the predefined type + `Long_Float' and for floating-point type declarations with digits + specified in the range 7 .. 15. The format of this pragma is as + follows: + + pragma Long_Float (D_FLOAT | G_FLOAT); + +  + File: gnat_ug_vms.info, Node: Fixed-Point Types and Representations, Next: Record and Array Component Alignment, Prev: Pragmas Float_Representation and Long_Float, Up: Language-Related Features + + Fixed-Point Types and Representations + ------------------------------------- + + On DEC Ada for OpenVMS Alpha systems, rounding is away from zero for + both positive and negative numbers. Therefore, +0.5 rounds to 1 and + -0.5 rounds to -1. + + On GNAT for OpenVMS Alpha, the results of operations on fixed-point + types are in accordance with the Ada 95 rules. In particular, results + of operations on decimal fixed-point types are truncated. + +  + File: gnat_ug_vms.info, Node: Record and Array Component Alignment, Next: Address Clauses, Prev: Fixed-Point Types and Representations, Up: Language-Related Features + + Record and Array Component Alignment + ------------------------------------ + + On DEC Ada for OpenVMS Alpha, all non composite components are aligned + on natural boundaries. For example, 1-byte components are aligned on + byte boundaries, 2-byte components on 2-byte boundaries, 4-byte + components on 4-byte byte boundaries, and so on. The OpenVMS Alpha + hardware runs more efficiently with naturally aligned data. + + ON GNAT for OpenVMS Alpha, alignment rules are compatible with DEC + Ada for OpenVMS Alpha. + +  + File: gnat_ug_vms.info, Node: Address Clauses, Next: Other Representation Clauses, Prev: Record and Array Component Alignment, Up: Language-Related Features + + Address Clauses + --------------- + + In DEC Ada and GNAT, address clauses are supported for objects and + imported subprograms. The predefined type `System.Address' is a + private type in both compilers, with the same representation (it is + simply a machine pointer). Addition, subtraction, and comparison + operations are available in the standard Ada 95 package + `System.Storage_Elements', or in package `System' if it is extended to + include `System.Aux_DEC' using a pragma `Extend_System' as previously + described. + + Note that code that with's both this extended package `System' and + the package `System.Storage_Elements' should not `use' both packages, + or ambiguities will result. In general it is better not to mix these + two sets of facilities. The Ada 95 package was designed specifically to + provide the kind of features that DEC Ada adds directly to package + `System'. + + GNAT is compatible with DEC Ada in its handling of address clauses, + except for some limitations in the form of address clauses for + composite objects with initialization. Such address clauses are easily + replaced by the use of an explicitly-defined constant as described in + the Ada 95 Reference Manual (13.1(22)). For example, the sequence of + declarations: + + X, Y : Integer := Init_Func; + Q : String (X .. Y) := "abc"; + ... + for Q'Address use Compute_Address; + + will be rejected by GNAT, since the address cannot be computed at the + time that Q is declared. To achieve the intended effect, write instead: + + X, Y : Integer := Init_Func; + Q_Address : constant Address := Compute_Address; + Q : String (X .. Y) := "abc"; + ... + for Q'Address use Q_Address; + + which will be accepted by GNAT (and other Ada 95 compilers), and is also + backwards compatible with Ada 83. A fuller description of the + restrictions on address specifications is found in the GNAT Reference + Manual. + +  + File: gnat_ug_vms.info, Node: Other Representation Clauses, Prev: Address Clauses, Up: Language-Related Features + + Other Representation Clauses + ---------------------------- + + GNAT supports in a compatible manner all the representation clauses + supported by DEC Ada. In addition, it supports representation clause + forms that are new in Ada 95 including COMPONENT_SIZE and SIZE clauses + for objects. + +  + File: gnat_ug_vms.info, Node: The Package STANDARD, Next: The Package SYSTEM, Prev: Language-Related Features, Up: Compatibility with DEC Ada + + The Package STANDARD + ==================== + + The package STANDARD, as implemented by DEC Ada, is fully described in + the Reference Manual for the Ada Programming Language + (ANSI/MIL-STD-1815A-1983) and in the DEC Ada Language Reference Manual. + As implemented by GNAT, the package STANDARD is described in the Ada 95 + Reference Manual. + + In addition, DEC Ada supports the Latin-1 character set in the type + CHARACTER. GNAT supports the Latin-1 character set in the type + CHARACTER and also Unicode (ISO 10646 BMP) in the type WIDE_CHARACTER. + + The floating-point types supported by GNAT are those supported by + DEC Ada, but defaults are different, and are controlled by pragmas. See + *note Floating-Point Types and Representations:: for details. + +  + File: gnat_ug_vms.info, Node: The Package SYSTEM, Next: Tasking and Task-Related Features, Prev: The Package STANDARD, Up: Compatibility with DEC Ada + + The Package SYSTEM + ================== + + DEC Ada provides a system-specific version of the package SYSTEM for + each platform on which the language ships. For the complete + specification of the package SYSTEM, see Appendix F of the DEC Ada + Language Reference Manual. + + On DEC Ada, the package SYSTEM includes the following conversion + functions: + * TO_ADDRESS(INTEGER) + + * TO_ADDRESS(UNSIGNED_LONGWORD) + + * TO_ADDRESS(universal_integer) + + * TO_INTEGER(ADDRESS) + + * TO_UNSIGNED_LONGWORD(ADDRESS) + + * Function IMPORT_VALUE return UNSIGNED_LONGWORD and the + functions IMPORT_ADDRESS and IMPORT_LARGEST_VALUE + + By default, GNAT supplies a version of SYSTEM that matches the + definition given in the Ada 95 Reference Manual. This is a subset of + the DIGITAL system definitions, which is as close as possible to the + original definitions. The only difference is that the definition of + SYSTEM_NAME is different: + + type Name is (SYSTEM_NAME_GNAT); + System_Name : constant Name := SYSTEM_NAME_GNAT; + + Also, GNAT adds the new Ada 95 declarations for BIT_ORDER and + DEFAULT_BIT_ORDER. + + However, the use of the following pragma causes GNAT to extend the + definition of package SYSTEM so that it encompasses the full set of + DIGITAL-specific extensions, including the functions listed above: + + pragma Extend_System (Aux_DEC); + + The pragma Extend_System is a configuration pragma that is most + conveniently placed in the `GNAT.ADC' file. See the GNAT Reference + Manual for further details. + + DEC Ada does not allow the recompilation of the package SYSTEM. + Instead DEC Ada provides several pragmas (SYSTEM_ NAME, STORAGE_UNIT, + and MEMORY_SIZE) to modify values in the package SYSTEM. On OpenVMS + Alpha systems, the pragma SYSTEM_NAME takes the enumeration literal + OPENVMS_AXP as its single argument. + + GNAT does permit the recompilation of package SYSTEM using a special + qualifier (/STYLE=GNAT) and this qualifier can be used if it is + necessary to change constants in SYSTEM. GNAT does not permit the + specification of SYSTEM_NAME, STORAGE_UNIT or MEMORY_SIZE by any other + means. + + On GNAT systems, the pragma SYSTEM_NAME takes the enumeration + literal SYSTEM_NAME_GNAT. + + The definitions provided by the use of + + pragma Extend_System (AUX_Dec); + + are virtually identical to those provided by the DEC Ada 83 package + System. One important difference is that the name of the TO_ADDRESS + function for type UNSIGNED_LONGWORD is changed to TO_ADDRESS_LONG. See + the GNAT Reference manual for a discussion of why this change was + necessary. + + The version of TO_ADDRESS taking a universal integer argument is in fact + an extension to Ada 83 not strictly compatible with the reference + manual. In GNAT, we are constrained to be exactly compatible with the + standard, and this means we cannot provide this capability. In DEC Ada + 83, the point of this definition is to deal with a call like: + + TO_ADDRESS (16#12777#); + + Normally, according to the Ada 83 standard, one would expect this to be + ambiguous, since it matches both the INTEGER and UNSIGNED_LONGWORD forms + of TO_ADDRESS. However, in DEC Ada 83, there is no ambiguity, since the + definition using universal_integer takes precedence. + + In GNAT, since the version with universal_integer cannot be + supplied, it is not possible to be 100% compatible. Since there are + many programs using numeric constants for the argument to TO_ADDRESS, + the decision in GNAT was to change the name of the function in the + UNSIGNED_LONGWORD case, so the declarations provided in the GNAT + version of AUX_Dec are: + + function To_Address (X : Integer) return Address; + pragma Pure_Function (To_Address); + + function To_Address_Long (X : Unsigned_Longword) return Address; + pragma Pure_Function (To_Address_Long); + + This means that programs using TO_ADDRESS for UNSIGNED_LONGWORD must + change the name to TO_ADDRESS_LONG. + +  + File: gnat_ug_vms.info, Node: Tasking and Task-Related Features, Next: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems, Prev: The Package SYSTEM, Up: Compatibility with DEC Ada + + Tasking and Task-Related Features + ================================= + + The concepts relevant to a comparison of tasking on GNAT and on DEC Ada + for OpenVMS Alpha systems are discussed in the following sections. + + For detailed information on concepts related to tasking in DEC Ada, + see the DEC Ada Language Reference Manual and the relevant run-time + reference manual. + +  + File: gnat_ug_vms.info, Node: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems, Next: Pragmas and Pragma-Related Features, Prev: Tasking and Task-Related Features, Up: Compatibility with DEC Ada + + Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + ============================================================ + + On OpenVMS Alpha systems, each Ada task (except a passive task) is + implemented as a single stream of execution that is created and managed + by the kernel. On these systems, DEC Ada tasking support is based on + DECthreads, an implementation of the POSIX standard for threads. + + Although tasks are implemented as threads, all tasks in an Ada + program are part of the same process. As a result, resources such as + open files and virtual memory can be shared easily among tasks. Having + all tasks in one process allows better integration with the programming + environment (the shell and the debugger, for example). + + Also, on OpenVMS Alpha systems, DEC Ada tasks and foreign code that + calls DECthreads routines can be used together. The interaction + between Ada tasks and DECthreads routines can have some benefits. For + example when on OpenVMS Alpha, DEC Ada can call C code that is already + threaded. GNAT on OpenVMS Alpha uses the facilities of DECthreads, and + Ada tasks are mapped to threads. + + * Menu: + + * Assigning Task IDs:: + * Task IDs and Delays:: + * Task-Related Pragmas:: + * Scheduling and Task Priority:: + * The Task Stack:: + * External Interrupts:: + +  + File: gnat_ug_vms.info, Node: Assigning Task IDs, Next: Task IDs and Delays, Up: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + + Assigning Task IDs + ------------------ + + The DEC Ada Run-Time Library always assigns %TASK 1 to the environment + task that executes the main program. On OpenVMS Alpha systems, %TASK 0 + is often used for tasks that have been created but are not yet + activated. + + On OpenVMS Alpha systems, task IDs are assigned at activation. On + GNAT systems, task IDs are also assigned at task creation but do not + have the same form or values as task ID values in DEC Ada. There is no + null task, and the environment task does not have a specific task ID + value. + +  + File: gnat_ug_vms.info, Node: Task IDs and Delays, Next: Task-Related Pragmas, Prev: Assigning Task IDs, Up: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + + Task IDs and Delays + ------------------- + + On OpenVMS Alpha systems, tasking delays are implemented using Timer + System Services. The Task ID is used for the identification of the + timer request (the REQIDT parameter). If Timers are used in the + application take care not to use 0 for the identification, because + cancelling such a timer will cancel all timers and may lead to + unpredictable results. + +  + File: gnat_ug_vms.info, Node: Task-Related Pragmas, Next: Scheduling and Task Priority, Prev: Task IDs and Delays, Up: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + + Task-Related Pragmas + -------------------- + + Ada supplies the pragma TASK_STORAGE, which allows specification of the + size of the guard area for a task stack. (The guard area forms an area + of memory that has no read or write access and thus helps in the + detection of stack overflow.) On OpenVMS Alpha systems, if the pragma + TASK_STORAGE specifies a value of zero, a minimal guard area is + created. In the absence of a pragma TASK_STORAGE, a default guard area + is created. + + GNAT supplies the following task-related pragmas: + + * TASK_INFO + + This pragma appears within a task definition and + applies to the task in which it appears. The argument + must be of type SYSTEM.TASK_INFO.TASK_INFO_TYPE. + + * TASK_STORAGE + + GNAT implements pragma TASK_STORAGE in the same way as + DEC Ada. Both DEC Ada and GNAT supply the pragmas + PASSIVE, SUPPRESS, and VOLATILE. + +  + File: gnat_ug_vms.info, Node: Scheduling and Task Priority, Next: The Task Stack, Prev: Task-Related Pragmas, Up: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + + Scheduling and Task Priority + ---------------------------- + + DEC Ada implements the Ada language requirement that when two tasks are + eligible for execution and they have different priorities, the lower + priority task does not execute while the higher priority task is + waiting. The DEC Ada Run-Time Library keeps a task running until either + the task is suspended or a higher priority task becomes ready. + + On OpenVMS Alpha systems, the default strategy is round- robin with + preemption. Tasks of equal priority take turns at the processor. A task + is run for a certain period of time and then placed at the rear of the + ready queue for its priority level. + + DEC Ada provides the implementation-defined pragma TIME_SLICE, which + can be used to enable or disable round-robin scheduling of tasks with + the same priority. See the relevant DEC Ada run-time reference manual + for information on using the pragmas to control DEC Ada task scheduling. + + GNAT follows the scheduling rules of Annex D (real-time Annex) of + the Ada 95 Reference Manual. In general, this scheduling strategy is + fully compatible with DEC Ada although it provides some additional + constraints (as fully documented in Annex D). GNAT implements time + slicing control in a manner compatible with DEC Ada 83, by means of the + pragma Time_Slice, whose semantics are identical to the DEC Ada 83 + pragma of the same name. Note that it is not possible to mix GNAT + tasking and DEC Ada 83 tasking in the same program, since the two run + times are not compatible. + +  + File: gnat_ug_vms.info, Node: The Task Stack, Next: External Interrupts, Prev: Scheduling and Task Priority, Up: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + + The Task Stack + -------------- + + In DEC Ada, a task stack is allocated each time a non passive task is + activated. As soon as the task is terminated, the storage for the task + stack is deallocated. If you specify a size of zero (bytes) with + T'STORAGE_SIZE, a default stack size is used. Also, regardless of the + size specified, some additional space is allocated for task management + purposes. On OpenVMS Alpha systems, at least one page is allocated. + + GNAT handles task stacks in a similar manner. According to the Ada + 95 rules, it provides the pragma STORAGE_SIZE as an alternative method + for controlling the task stack size. The specification of the + attribute T'STORAGE_SIZE is also supported in a manner compatible with + DEC Ada. + +  + File: gnat_ug_vms.info, Node: External Interrupts, Prev: The Task Stack, Up: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + + External Interrupts + ------------------- + + On DEC Ada, external interrupts can be associated with task entries. + GNAT is compatible with DEC Ada in its handling of external interrupts. + +  + File: gnat_ug_vms.info, Node: Pragmas and Pragma-Related Features, Next: Library of Predefined Units, Prev: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems, Up: Compatibility with DEC Ada + + Pragmas and Pragma-Related Features + =================================== + + Both DEC Ada and GNAT supply all language-defined pragmas as specified + by the Ada 83 standard. GNAT also supplies all language-defined pragmas + specified in the Ada 95 Reference Manual. In addition, GNAT implements + the implementation-defined pragmas from DEC Ada 83. + + * AST_ENTRY + + * COMMON_OBJECT + + * COMPONENT_ALIGNMENT + + * EXPORT_EXCEPTION + + * EXPORT_FUNCTION + + * EXPORT_OBJECT + + * EXPORT_PROCEDURE + + * EXPORT_VALUED_PROCEDURE + + * FLOAT_REPRESENTATION + + * IDENT + + * IMPORT_EXCEPTION + + * IMPORT_FUNCTION + + * IMPORT_OBJECT + + * IMPORT_PROCEDURE + + * IMPORT_VALUED_PROCEDURE + + * INLINE_GENERIC + + * INTERFACE_NAME + + * LONG_FLOAT + + * MAIN_STORAGE + + * PASSIVE + + * PSET_OBJECT + + * SHARE_GENERIC + + * SUPPRESS_ALL + + * TASK_STORAGE + + * TIME_SLICE + + * TITLE + + These pragmas are all fully implemented, with the exception of `Title', + `Passive', and `Share_Generic', which are recognized, but which have no + effect in GNAT. The effect of `Passive' may be obtained by the use of + protected objects in Ada 95. In GNAT, all generics are inlined. + + Unlike DEC Ada, the GNAT 'EXPORT_subprogram' pragmas require a + separate subprogram specification which must appear before the + subprogram body. + + GNAT also supplies a number of implementation-defined pragmas as + follows: + * C_PASS_BY_COPY + + * EXTEND_SYSTEM + + * SOURCE_FILE_NAME + + * UNSUPPRESS + + * WARNINGS + + * ABORT_DEFER + + * ADA_83 + + * ADA_95 + + * ANNOTATE + + * ASSERT + + * CPP_CLASS + + * CPP_CONSTRUCTOR + + * CPP_DESTRUCTOR + + * CPP_VIRTUAL + + * CP_VTABLE + + * DEBUG + + * LINKER_ALIAS + + * LINKER_SECTION + + * MACHINE_ATTRIBUTE + + * NO_RETURN + + * PURE_FUNCTION + + * SOURCE_REFERENCE + + * TASK_INFO + + * UNCHECKED_UNION + + * UNIMPLEMENTED_UNIT + + * WEAK_EXTERNAL + + For full details on these GNAT implementation-defined pragmas, see the + GNAT Reference Manual. + + * Menu: + + * Restrictions on the Pragma INLINE:: + * Restrictions on the Pragma INTERFACE:: + * Restrictions on the Pragma SYSTEM_NAME:: + +  + File: gnat_ug_vms.info, Node: Restrictions on the Pragma INLINE, Next: Restrictions on the Pragma INTERFACE, Up: Pragmas and Pragma-Related Features + + Restrictions on the Pragma INLINE + --------------------------------- + + DEC Ada applies the following restrictions to the pragma INLINE: + * Parameters cannot be a task type. + + * Function results cannot be task types, unconstrained array types, + or unconstrained types with discriminants. + + * Bodies cannot declare the following: + * Subprogram body or stub (imported subprogram is allowed) + + * Tasks + + * Generic declarations + + * Instantiations + + * Exceptions + + * Access types (types derived from access types allowed) + + * Array or record types + + * Dependent tasks + + * Direct recursive calls of subprogram or containing + subprogram, directly or via a renaming + + + In GNAT, the only restriction on pragma INLINE is that the body must + occur before the call if both are in the same unit, and the size must + be appropriately small. There are no other specific restrictions which + cause subprograms to be incapable of being inlined. + +  + File: gnat_ug_vms.info, Node: Restrictions on the Pragma INTERFACE, Next: Restrictions on the Pragma SYSTEM_NAME, Prev: Restrictions on the Pragma INLINE, Up: Pragmas and Pragma-Related Features + + Restrictions on the Pragma INTERFACE + ------------------------------------ + + The following lists and describes the restrictions on the pragma + INTERFACE on DEC Ada and GNAT: + * Languages accepted: Ada, Bliss, C, Fortran, Default. Default is + the default on OpenVMS Alpha systems. + + * Parameter passing: Language specifies default mechanisms but can + be overridden with an EXPORT pragma. + + * Ada: Use internal Ada rules. + + * Bliss, C: Parameters must be mode `in'; cannot be record or + task type. Result cannot be a string, an array, or a record. + + * Fortran: Parameters cannot be a task. Result cannot be a + string, an array, or a record. + + GNAT is entirely upwards compatible with DEC Ada, and in addition allows + record parameters for all languages. + +  + File: gnat_ug_vms.info, Node: Restrictions on the Pragma SYSTEM_NAME, Prev: Restrictions on the Pragma INTERFACE, Up: Pragmas and Pragma-Related Features + + Restrictions on the Pragma SYSTEM_NAME + -------------------------------------- + + For DEC Ada for OpenVMS Alpha, the enumeration literal for the type + NAME is OPENVMS_AXP. In GNAT, the enumeration literal for the type NAME + is SYSTEM_NAME_GNAT. + +  + File: gnat_ug_vms.info, Node: Library of Predefined Units, Next: Bindings, Prev: Pragmas and Pragma-Related Features, Up: Compatibility with DEC Ada + + Library of Predefined Units + =========================== + + A library of predefined units is provided as part of the DEC Ada and + GNAT implementations. DEC Ada does not provide the package MACHINE_CODE + but instead recommends importing assembler code. + + The GNAT versions of the DEC Ada Run-Time Library (ADA$PREDEFINED:) + units are taken from the OpenVMS Alpha version, not the OpenVMS VAX + version. During GNAT installation, the DEC Ada Predefined Library units + are copied into the GNU:[LIB.OPENVMS7_x.2_8_x.DECLIB] (aka DECLIB) + directory and patched to remove Ada 95 incompatibilities and to make + them interoperable with GNAT, *note Changes to DECLIB:: for details. + + The GNAT RTL is contained in the GNU:[LIB.OPENVMS7_x.2_8_x.ADALIB] + (aka ADALIB) directory and the default search path is set up to find + DECLIB units in preference to ADALIB units with the same name (TEXT_IO, + SEQUENTIAL_IO, and DIRECT_IO, for example). + + However, it is possible to change the default so that the reverse is + true, or even to mix them using child package notation. The DEC Ada 83 + units are available as DEC.xxx where xxx is the package name, and the + Ada units are available in the standard manner defined for Ada 95, that + is to say as Ada.xxx. To change the default, set ADA_INCLUDE_PATH and + ADA_OBJECTS_PATH appropriately. For example, to change the default to + use the Ada95 versions do: + + $ DEFINE ADA_INCLUDE_PATH GNU:[LIB.OPENVMS7_1.2_8_1.ADAINCLUDE],- + GNU:[LIB.OPENVMS7_1.2_8_1.DECLIB] + $ DEFINE ADA_OBJECTS_PATH GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB],- + GNU:[LIB.OPENVMS7_1.2_8_1.DECLIB] + + * Menu: + + * Changes to DECLIB:: + +  + File: gnat_ug_vms.info, Node: Changes to DECLIB, Up: Library of Predefined Units + + Changes to DECLIB + ----------------- + + The changes made to the DEC Ada predefined library for GNAT and Ada 95 + compatibility are minor and include the following: + + * Adjusting the location of pragmas and record representation + clauses to obey Ada 95 rules + + * Adding the proper notation to generic formal parameters that take + unconstrained types in instantiation + + * Adding pragma ELABORATE_BODY to package specifications that have + package bodies not otherwise allowed + + * Occurrences of the identifier "PROTECTED" are renamed to + "PROTECTD". Currently these are found only in the STARLET package + spec. + + None of the above changes is visible to users. + +  + File: gnat_ug_vms.info, Node: Bindings, Next: Main Program Definition, Prev: Library of Predefined Units, Up: Compatibility with DEC Ada + + Bindings + ======== + + On OpenVMS Alpha, DEC Ada provides the following strongly-typed + bindings: + * Command Language Interpreter (CLI interface) + + * DECtalk Run-Time Library (DTK interface) + + * Librarian utility routines (LBR interface) + + * General Purpose Run-Time Library (LIB interface) + + * Math Run-Time Library (MTH interface) + + * National Character Set Run-Time Library (NCS interface) + + * Compiled Code Support Run-Time Library (OTS interface) + + * Parallel Processing Run-Time Library (PPL interface) + + * Screen Management Run-Time Library (SMG interface) + + * Sort Run-Time Library (SOR interface) + + * String Run-Time Library (STR interface) + + * STARLET System Library + + * X Window System Version 11R4 and 11R5 (X, XLIB interface) + + * X Windows Toolkit (XT interface) + + * X/Motif Version 1.1.3 and 1.2 (XM interface) + + GNAT provides implementations of these DEC bindings in the DECLIB + directory. + + The X/Motif bindings used to build DECLIB are whatever versions are + in the DEC Ada ADA$PREDEFINED directory with extension .ADC. The build + script will automatically add a pragma Linker_Options to packages Xm, + Xt, and X_Lib causing the default X/Motif shareable image libraries to + be linked in. This is done via options files named xm.opt, xt.opt, and + x_lib.opt (also located in the DECLIB directory). + + It may be necessary to edit these options files to update or correct + the library names if, for example, the newer X/Motif bindings from + ADA$EXAMPLES had been (previous to installing GNAT) copied and renamed + to superseded the default ADA$PREDEFINED versions. + + * Menu: + + * Shared Libraries and Options Files:: + * Interfaces to C:: + +  + File: gnat_ug_vms.info, Node: Shared Libraries and Options Files, Next: Interfaces to C, Up: Bindings + + Shared Libraries and Options Files + ---------------------------------- + + When using the DEC Ada predefined X and Motif bindings, the linking + with their shareable images is done automatically by GNAT LINK. When + using other X and Motif bindings, it is necessary to add the + corresponding shareable images to the command line for GNAT LINK. When + linking with shared libraries, or with .OPT files, it is also necessary + to add them to the command line for GNAT LINK. + + A shared library to be used with GNAT is built in the same way as + other libraries under VMS. The VMS Link command can be used in standard + fashion. + +  + File: gnat_ug_vms.info, Node: Interfaces to C, Prev: Shared Libraries and Options Files, Up: Bindings + + Interfaces to C + --------------- + + DEC Ada provides the following Ada types and operations: + + * C types package (C_TYPES) + + * C strings (C_TYPES.NULL_TERMINATED) + + * Other_types (SHORT_INT) + + Interfacing to C with GNAT, one can use the above approach described + for DEC Ada or the facilities of Annex B of the Ada 95 Reference Manual + (packages INTERFACES.C, INTERFACES.C.STRINGS and + INTERFACES.C.POINTERS). For more information, see the section + "Interfacing to C" in the GNAT Reference Manual. + + The `/UPPERCASE_EXTERNALS' qualifier forces default and explicit + `External_Name' parameters in pragmas Import and Export to be + uppercased for compatibility with the default behavior of DEC C. The + qualifier has no effect on `Link_Name' parameters. + +  + File: gnat_ug_vms.info, Node: Main Program Definition, Next: Implementation-Defined Attributes, Prev: Bindings, Up: Compatibility with DEC Ada + + Main Program Definition + ======================= + + The following section discusses differences in the definition of main + programs on DEC Ada and GNAT. On DEC Ada, main programs are defined to + meet the following conditions: + * Procedure with no formal parameters (returns 0 upon normal + completion) + + * Procedure with no formal parameters (returns 42 when + unhandled exceptions are raised) + + * Function with no formal parameters whose returned value is + of a discrete type + + * Procedure with one OUT formal of a discrete type for which + a specification of pragma EXPORT_VALUED_PROCEDURE is given. + + + When declared with the pragma EXPORT_VALUED_PROCEDURE, a main function + or main procedure returns a discrete value whose size is less than 64 + bits (32 on VAX systems), the value is zero- or sign-extended as + appropriate. On GNAT, main programs are defined as follows: + * Must be a non-generic, parameter-less subprogram that is either a + procedure or function returning an Ada STANDARD.INTEGER (the + predefined type) + + * Cannot be a generic subprogram or an instantiation of a generic + subprogram + +  + File: gnat_ug_vms.info, Node: Implementation-Defined Attributes, Next: Compiler and Run-Time Interfacing, Prev: Main Program Definition, Up: Compatibility with DEC Ada + + Implementation-Defined Attributes + ================================= + + GNAT provides all DEC Ada implementation-defined attributes. + +  + File: gnat_ug_vms.info, Node: Compiler and Run-Time Interfacing, Next: Program Compilation and Library Management, Prev: Implementation-Defined Attributes, Up: Compatibility with DEC Ada + + Compiler and Run-Time Interfacing + ================================= + + DEC Ada provides the following ways to pass options to the linker (ACS + LINK): + * /WAIT and /SUBMIT qualifiers + + * /COMMAND qualifier + + * /[NO]MAP qualifier + + * /OUTPUT=file-spec + + * /[NO]DEBUG and /[NO]TRACEBACK qualifiers + + To pass options to the linker, GNAT provides the following qualifiers: + + * /EXECUTABLE=exec-name + + * /VERBOSE qualifier + + * /[NO]DEBUG and /[NO]TRACEBACK qualifiers + + For more information on these qualifiers, see the section "Qualifiers + for GNAT LINK" in the corresponding section of this Guide. In DEC Ada, + the command-line qualifier /OPTIMIZE is available to control + optimization. DEC Ada also supplies the following pragmas: + * OPTIMIZE + + * INLINE + + * INLINE_GENERIC + + * SUPPRESS_ALL + + * PASSIVE + + In GNAT, optimization is controlled strictly by command line + parameters, as described in the corresponding section of this guide. + The DIGITAL pragmas for control of optimization are recognized but + ignored. + + Note that in GNAT, the default is optimization off, whereas in DEC + Ada 83, the default is that optimization is turned on. + +  + File: gnat_ug_vms.info, Node: Program Compilation and Library Management, Next: Input-Output, Prev: Compiler and Run-Time Interfacing, Up: Compatibility with DEC Ada + + Program Compilation and Library Management + ========================================== + + DEC Ada and GNAT provide a comparable set of commands to build + programs. DEC Ada also provides a program library, which is a concept + that does not exist on GNAT. Instead, GNAT provides directories of + sources that are compiled as needed. + + The following table summarizes the DEC Ada commands and provides + equivalent GNAT commands. In this table, some GNAT equivalents reflect + the fact that GNAT does not use the concept of a program library. + Instead, it uses a model in which collections of source and object + files are used in a manner consistent with other languages like C and + Fortran. Therefore, standard system file commands are used to + manipulate these elements. Those GNAT commands are marked with an + asterisk in the table that follows. Note that, unlike DEC Ada, none + of the GNAT commands accepts wild cards. + + *DEC_Ada_Command* *GNAT_Equivalent* *Description* + ADA GNAT COMPILE Invokes the compiler to + compile one or more Ada + source files. + ACS ATTACH No equivalent Qualifiers control of + terminal from current + process running the program + library + manager. + ACS CHECK GNAT MAKE Forms the execution closure + /DEPENDENCY_LIST of one or more + compiled units and checks + completeness and currency. + ACS COMPILE GNAT MAKE Forms the execution closure + /ACTIONS=COMPILE of one or more + specified units, checks + completeness and currency, + identifies units + that have revised source + files, compiles same, + and recompiles units + that are or will become + obsolete. Also + completes incomplete + generic instantiations. + ACS COPY FOREIGN Copy (*) Copies a foreign object + file into the program + library as a + library unit body. + ACS COPY UNIT Copy (*) Copies a compiled unit from + one program library to + another. + ACS CREATE LIBRARY Create /directory (*) Creates a program library. + ACS CREATE SUBLIBRARY Create /directory (*) Creates a program + sublibrary. + ACS DELETE LIBRARY Deletes a program library + and its contents. + ACS DELETE SUBLIBRARY Deletes a program + sublibrary and its contents. + ACS DELETE UNIT Delete file (*) On OpenVMS systems, deletes + one or more compiled units + from the current + program library. + ACS DIRECTORY Directory (*) On OpenVMS systems, lists + units contained in the + current program + library. + ACS ENTER FOREIGN Copy (*) Allows the import of a + foreign body as an Ada + library + specification and enters a + reference to a pointer. + ACS ENTER UNIT Copy (*) Enters a reference + (pointer) from the current + program library to + a unit compiled into + another program library. + ACS EXIT No equivalent Exits from the program + library manager. + ACS EXPORT Copy (*) Creates an object file that + contains system-specific + object code for + one or more units. With + GNAT, object files can + simply be copied + into the desired directory. + ACS EXTRACT SOURCE Copy (*) Allows access to the copied + source file for each Ada + compilation unit + ACS HELP HELP GNAT Provides online help. + ACS LINK GNAT LINK Links an object file + containing Ada units into + an executable + file. + ACS LOAD Copy (*) Loads (partially compiles) + Ada units into the program + library. Allows + loading a program from a + collection of files into a + library without + knowing the relationship + among units. + ACS MERGE Copy (*) Merges into the current + program library, one or + more units from + another library where they + were modified. + ACS RECOMPILE GNAT MAKE Recompiles from external + /ACTIONS=COMPILE or copied source files any + obsolete unit in + the closure. Also, + completes any incomplete + generic + instantiations. + ACS REENTER GNAT MAKE Reenters current references + to units compiled after + last entered + with the ACS ENTER UNIT + command. + ACS SET LIBRARY Set default (*) Defines a program library + to be the compilation + context as well + as the target library for + compiler output and + commands in general. + ACS SET PRAGMA Edit GNAT.ADC (*) Redefines specified values + of the library + characteristics + LONG_ FLOAT, MEMORY_SIZE, + SYSTEM_NAME, and + `Float_Representation'. + ACS SET SOURCE define Defines the source file + ADA_INCLUDE_PATH path search list for the ACS + (*) COMPILE command. + ACS SHOW LIBRARY Directory (*) Lists information about one + or more program libraries. + ACS SHOW PROGRAM No equivalent Lists information about the + execution closure of one or + more units in + the program library. + ACS SHOW SOURCE Show logical Shows the source file + ADA_INCLUDE_PATH search used when compiling + units. + ACS SHOW VERSION Compile with VERBOSE Displays the version number + option of the compiler and program + library manager + used. + ACS SPAWN No equivalent Creates a subprocess of the + current process (same as + DCL SPAWN + command). + ACS VERIFY No equivalent Performs a series of + consistency checks on a + program library to + determine whether the + library structure and + library files are in + valid_form. + +  + File: gnat_ug_vms.info, Node: Input-Output, Next: Implementation Limits, Prev: Program Compilation and Library Management, Up: Compatibility with DEC Ada + + Input-Output + ============ + + On OpenVMS Alpha systems, DEC Ada uses OpenVMS Record Management + Services (RMS) to perform operations on external files. + + DEC Ada and GNAT predefine an identical set of input- output packages. + To make the use of the generic TEXT_IO operations more convenient, DEC + Ada provides predefined library packages that instantiate the integer + and floating-point operations for the predefined integer and + floating-point types as shown in the following table. + + `Package_Name' + Instantiation + + `INTEGER_TEXT_IO' + INTEGER_IO(INTEGER) + + `SHORT_INTEGER_TEXT_IO' + INTEGER_IO(SHORT_INTEGER) + + `SHORT_SHORT_INTEGER_TEXT_IO' + INTEGER_IO(SHORT_SHORT_ INTEGER) + + `FLOAT_TEXT_IO' + FLOAT_IO(FLOAT) + + `LONG_FLOAT_TEXT_IO' + FLOAT_IO(LONG_FLOAT) + + The DEC Ada predefined packages and their operations are implemented + using OpenVMS Alpha files and input- output facilities. DEC Ada + supports asynchronous input- output on OpenVMS Alpha. Familiarity with + the following is recommended: + * RMS file organizations and access methods + + * OpenVMS file specifications and directories + + * OpenVMS File Definition Language (FDL) + + GNAT provides I/O facilities that are completely compatible with DEC + Ada. The distribution includes the standard DEC Ada versions of all I/O + packages, operating in a manner compatible with DEC Ada. In particular, + the following packages are by default the DEC Ada (Ada 83) versions of + these packages rather than the renamings suggested in annex J of the + Ada 95 Reference Manual: + * TEXT_IO + + * SEQUENTIAL_IO + + * DIRECT_IO + + The use of the standard Ada 95 syntax for child packages (for example, + ADA.TEXT_IO) retrieves the Ada 95 versions of these packages, as + defined in the Ada 95 Reference Manual. GNAT provides + DIGITAL-compatible predefined instantiations of the TEXT_IO packages, + and also provides the standard predefined instantiations required by + the Ada 95 Reference Manual. + + For further information on how GNAT interfaces to the file system or + how I/O is implemented in programs written in mixed languages, see the + chapter "Implementation of the Standard I/O" in the GNAT Reference + Manual. This chapter covers the following: + * Standard I/O packages + + * FORM strings + + * DIRECT_IO + + * SEQUENTIAL_IO + + * TEXT_IO + + * Stream pointer positioning + + * Reading and writing non-regular files + + * GET_IMMEDIATE + + * Treating TEXT_IO files as streams + + * Shared files + + * Open modes + +  + File: gnat_ug_vms.info, Node: Implementation Limits, Next: Tools, Prev: Input-Output, Up: Compatibility with DEC Ada + + Implementation Limits + ===================== + + The following table lists implementation limits for DEC Ada and GNAT + systems. + Compilation Parameter DEC Ada GNAT + In a subprogram or entry declaration, 32 No set limit + maximum number of formal parameters + that are of an unconstrained record type + Maximum identifier length (number of 255 255 + characters) + Maximum number of characters in a source 255 255 + line + Maximum collection size (number of bytes) 2**31-1 2**31-1 + Maximum number of discriminants for a 245 No set limit + record type + Maximum number of formal parameters in an 246 No set limit + entry or subprogram declaration + Maximum number of dimensions in an array 255 No set limit + type + Maximum number of library units and 4095 No set limit + subunits in a compilation. + Maximum number of library units and 16383 No set limit + subunits in an execution. + Maximum number of objects declared with 32757 No set limit + the pragma COMMON_OBJECT or + PSECT_OBJECT + Maximum number of enumeration literals in 65535 No set limit + an enumeration type definition + Maximum number of lines in a source file 65534 No set limit + Maximum number of bits in any object 2**31-1 2**31-1 + Maximum size of the static portion of a 2**31-1 2**31-1 + stack frame (approximate) + +  + File: gnat_ug_vms.info, Node: Tools, Prev: Implementation Limits, Up: Compatibility with DEC Ada + + Tools + ===== + +  + File: gnat_ug_vms.info, Node: Inline Assembler, Next: Performance Considerations, Prev: Running and Debugging Ada Programs, Up: Top + + Inline Assembler + **************** + + If you need to write low-level software that interacts directly with + the hardware, Ada provides two ways to incorporate assembly language + code into your program. First, you can import and invoke external + routines written in assembly language, an Ada feature fully supported + by GNAT. However, for small sections of code it may be simpler or more + efficient to include assembly language statements directly in your Ada + source program, using the facilities of the implementation-defined + package `System.Machine_Code', which incorporates the GNAT COMPILE + Inline Assembler. The Inline Assembler approach offers a number of + advantages, including the following: + + * No need to use non-Ada tools + + * Consistent interface over different targets + + * Automatic usage of the proper calling conventions + + * Access to Ada constants and variables + + * Definition of intrinsic routines + + * Possibility of inlining a subprogram comprising assembler code + + * Code optimizer can take Inline Assembler code into account + + This chapter presents a series of examples to show you how to use + the Inline Assembler. Although it focuses on the Intel x86, the + general approach applies also to other processors. It is assumed that + you are familiar with Ada and with assembly language programming. + + * Menu: + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + +  + File: gnat_ug_vms.info, Node: Basic Assembler Syntax, Next: A Simple Example of Inline Assembler, Up: Inline Assembler + + Basic Assembler Syntax + ====================== + + The assembler used by GNAT and GNAT COMPILE is based not on the Intel + assembly language, but rather on a language that descends from the AT&T + Unix assembler _as_ (and which is often referred to as "AT&T syntax"). + The following table summarizes the main features of _as_ syntax and + points out the differences from the Intel conventions. See the GNAT + COMPILE _as_ and _gas_ (an _as_ macro pre-processor) documentation for + further information. + + Register names + GNAT COMPILE / _as_: Prefix with "%"; for example `%eax' + Intel: No extra punctuation; for example `eax' + + Immediate operand + GNAT COMPILE / _as_: Prefix with "$"; for example `$4' + Intel: No extra punctuation; for example `4' + + Address + GNAT COMPILE / _as_: Prefix with "$"; for example `$loc' + Intel: No extra punctuation; for example `loc' + + Memory contents + GNAT COMPILE / _as_: No extra punctuation; for example `loc' + Intel: Square brackets; for example `[loc]' + + Register contents + GNAT COMPILE / _as_: Parentheses; for example `(%eax)' + Intel: Square brackets; for example `[eax]' + + Hexadecimal numbers + GNAT COMPILE / _as_: Leading "0x" (C language syntax); for example + `0xA0' + Intel: Trailing "h"; for example `A0h' + + Operand size + GNAT COMPILE / _as_: Explicit in op code; for example `movw' to + move a 16-bit word + Intel: Implicit, deduced by assembler; for example `mov' + + Instruction repetition + GNAT COMPILE / _as_: Split into two lines; for example + `rep' + `stosl' + Intel: Keep on one line; for example `rep stosl' + + Order of operands + GNAT COMPILE / _as_: Source first; for example `movw $4, %eax' + Intel: Destination first; for example `mov eax, 4' + +  + File: gnat_ug_vms.info, Node: A Simple Example of Inline Assembler, Next: Output Variables in Inline Assembler, Prev: Basic Assembler Syntax, Up: Inline Assembler + + A Simple Example of Inline Assembler + ==================================== + + The following example will generate a single assembly language + statement, `nop', which does nothing. Despite its lack of run-time + effect, the example will be useful in illustrating the basics of the + Inline Assembler facility. + + with System.Machine_Code; use System.Machine_Code; + procedure Nothing is + begin + Asm ("nop"); + end Nothing; + + `Asm' is a procedure declared in package `System.Machine_Code'; here + it takes one parameter, a _template string_ that must be a static + expression and that will form the generated instruction. `Asm' may be + regarded as a compile-time procedure that parses the template string + and additional parameters (none here), from which it generates a + sequence of assembly language instructions. + + The examples in this chapter will illustrate several of the forms + for invoking `Asm'; a complete specification of the syntax is found in + the `GNAT Reference Manual'. + + Under the standard GNAT conventions, the `Nothing' procedure should + be in a file named `NOTHING.ADB'. You can build the executable in the + usual way: + GNAT MAKE nothing + However, the interesting aspect of this example is not its run-time + behavior but rather the generated assembly code. To see this output, + invoke the compiler as follows: + GNAT COMPILE -S -fomit-frame-pointer /CHECKS=SUPPRESS_ALL `NOTHING.ADB' + where the options are: + + `-c' + compile only (no bind or link) + + `-S' + generate assembler listing + + `-fomit-frame-pointer' + do not set up separate stack frames + + `/CHECKS=SUPPRESS_ALL' + do not add runtime checks + + This gives a human-readable assembler version of the code. The + resulting file will have the same name as the Ada source file, but with + a `.s' extension. In our example, the file `nothing.s' has the + following contents: + + .file "NOTHING.ADB" + gcc2_compiled.: + ___gnu_compiled_ada: + .text + .align 4 + .globl __ada_nothing + __ada_nothing: + #APP + nop + #NO_APP + jmp L1 + .align 2,0x90 + L1: + ret + + The assembly code you included is clearly indicated by the compiler, + between the `#APP' and `#NO_APP' delimiters. The character before the + 'APP' and 'NOAPP' can differ on different targets. For example, Linux + uses '#APP' while on NT you will see '/APP'. + + If you make a mistake in your assembler code (such as using the + wrong size modifier, or using a wrong operand for the instruction) GNAT + will report this error in a temporary file, which will be deleted when + the compilation is finished. Generating an assembler file will help in + such cases, since you can assemble this file separately using the _as_ + assembler that comes with GNAT COMPILE. + + Assembling the file using the command + + as `nothing.s' + + will give you error messages whose lines correspond to the assembler + input file, so you can easily find and correct any mistakes you made. + If there are no errors, _as_ will generate an object file `nothing.out'. + +  + File: gnat_ug_vms.info, Node: Output Variables in Inline Assembler, Next: Input Variables in Inline Assembler, Prev: A Simple Example of Inline Assembler, Up: Inline Assembler + + Output Variables in Inline Assembler + ==================================== + + The examples in this section, showing how to access the processor + flags, illustrate how to specify the destination operands for assembly + language statements. + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags; + + In order to have a nicely aligned assembly listing, we have separated + multiple assembler statements in the Asm template string with linefeed + (ASCII.LF) and horizontal tab (ASCII.HT) characters. The resulting + section of the assembly output file is: + + #APP + pushfl + popl %eax + movl %eax, -40(%ebp) + #NO_APP + + It would have been legal to write the Asm invocation as: + + Asm ("pushfl popl %%eax movl %%eax, %0") + + but in the generated assembler file, this would come out as: + + #APP + pushfl popl %eax movl %eax, -40(%ebp) + #NO_APP + + which is not so convenient for the human reader. + + We use Ada comments at the end of each line to explain what the + assembler instructions actually do. This is a useful convention. + + When writing Inline Assembler instructions, you need to precede each + register and variable name with a percent sign. Since the assembler + already requires a percent sign at the beginning of a register name, + you need two consecutive percent signs for such names in the Asm + template string, thus `%%eax'. In the generated assembly code, one of + the percent signs will be stripped off. + + Names such as `%0', `%1', `%2', etc., denote input or output + variables: operands you later define using `Input' or `Output' + parameters to `Asm'. An output variable is illustrated in the third + statement in the Asm template string: + movl %%eax, %0 + The intent is to store the contents of the eax register in a + variable that can be accessed in Ada. Simply writing `movl %%eax, + Flags' would not necessarily work, since the compiler might optimize by + using a register to hold Flags, and the expansion of the `movl' + instruction would not be aware of this optimization. The solution is + not to store the result directly but rather to advise the compiler to + choose the correct operand form; that is the purpose of the `%0' output + variable. + + Information about the output variable is supplied in the `Outputs' + parameter to `Asm': + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + + The output is defined by the `Asm_Output' attribute of the target + type; the general format is + Type'Asm_Output (constraint_string, variable_name) + + The constraint string directs the compiler how to store/access the + associated variable. In the example + Unsigned_32'Asm_Output ("=m", Flags); + the `"m"' (memory) constraint tells the compiler that the variable + `Flags' should be stored in a memory variable, thus preventing the + optimizer from keeping it in a register. In contrast, + Unsigned_32'Asm_Output ("=r", Flags); + uses the `"r"' (register) constraint, telling the compiler to store + the variable in a register. + + If the constraint is preceded by the equal character (*=*), it tells + the compiler that the variable will be used to store data into it. + + In the `Get_Flags' example, we used the "g" (global) constraint, + allowing the optimizer to choose whatever it deems best. + + There are a fairly large number of constraints, but the ones that + are most useful (for the Intel x86 processor) are the following: + + `=' + output constraint + + `g' + global (i.e. can be stored anywhere) + + `m' + in memory + + `I' + a constant + + `a' + use eax + + `b' + use ebx + + `c' + use ecx + + `d' + use edx + + `S' + use esi + + `D' + use edi + + `r' + use one of eax, ebx, ecx or edx + + `q' + use one of eax, ebx, ecx, edx, esi or edi + + The full set of constraints is described in the GNAT COMPILE and + _as_ documentation; note that it is possible to combine certain + constraints in one constraint string. + + You specify the association of an output variable with an assembler + operand through the `%'_n_ notation, where _n_ is a non-negative + integer. Thus in + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + + `%0' will be replaced in the expanded code by the appropriate operand, + whatever the compiler decided for the `Flags' variable. + + In general, you may have any number of output variables: + * Count the operands starting at 0; thus `%0', `%1', etc. + + * Specify the `Outputs' parameter as a parenthesized comma-separated + list of `Asm_Output' attributes + + For example: + Asm ("movl %%eax, %0" & LF & HT & + "movl %%ebx, %1" & LF & HT & + "movl %%ecx, %2", + Outputs => (Unsigned_32'Asm_Output ("=g", Var_A), -- %0 = Var_A + Unsigned_32'Asm_Output ("=g", Var_B), -- %1 = Var_B + Unsigned_32'Asm_Output ("=g", Var_C))); -- %2 = Var_C + + where `Var_A', `Var_B', and `Var_C' are variables in the Ada program. + + As a variation on the `Get_Flags' example, we can use the + constraints string to direct the compiler to store the eax register + into the `Flags' variable, instead of including the store instruction + explicitly in the `Asm' template string: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_2 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax", -- save flags in eax + Outputs => Unsigned_32'Asm_Output ("=a", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_2; + + The `"a"' constraint tells the compiler that the `Flags' variable will + come from the eax register. Here is the resulting code: + + #APP + pushfl + popl %eax + #NO_APP + movl %eax,-40(%ebp) + + The compiler generated the store of eax into Flags after expanding the + assembler code. + + Actually, there was no need to pop the flags into the eax register; + more simply, we could just pop the flags directly into the program + variable: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_3 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "pop %0", -- save flags in Flags + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_3; + +  + File: gnat_ug_vms.info, Node: Input Variables in Inline Assembler, Next: Inlining Inline Assembler Code, Prev: Output Variables in Inline Assembler, Up: Inline Assembler + + Input Variables in Inline Assembler + =================================== + + The example in this section illustrates how to specify the source + operands for assembly language statements. The program simply + increments its input value by 1: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Incr (Value); + Put_Line ("Value after is" & Value'Img); + end Increment; + + The `Outputs' parameter to `Asm' specifies that the result will be + in the eax register and that it is to be stored in the `Result' + variable. + + The `Inputs' parameter looks much like the `Outputs' parameter, but + with an `Asm_Input' attribute. The `"="' constraint, indicating an + output value, is not present. + + You can have multiple input variables, in the same way that you can + have more than one output variable. + + The parameter count (%0, %1) etc, now starts at the first input + statement, and continues with the output statements. When both + parameters use the same variable, the compiler will treat them as the + same %n operand, which is the case here. + + Just as the `Outputs' parameter causes the register to be stored + into the target variable after execution of the assembler statements, + so does the `Inputs' parameter cause its variable to be loaded into the + register before execution of the assembler statements. + + Thus the effect of the `Asm' invocation is: + 1. load the 32-bit value of `Value' into eax + + 2. execute the `incl %eax' instruction + + 3. store the contents of eax into the `Result' variable + + The resulting assembler file (with `/OPTIMIZE=ALL' optimization) + contains: + _increment__incr.1: + subl $4,%esp + movl 8(%esp),%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + movl %ecx,(%esp) + addl $4,%esp + ret + +  + File: gnat_ug_vms.info, Node: Inlining Inline Assembler Code, Next: Other Asm Functionality, Prev: Input Variables in Inline Assembler, Up: Inline Assembler + + Inlining Inline Assembler Code + ============================== + + For a short subprogram such as the `Incr' function in the previous + section, the overhead of the call and return (creating / deleting the + stack frame) can be significant, compared to the amount of code in the + subprogram body. A solution is to apply Ada's `Inline' pragma to the + subprogram, which directs the compiler to expand invocations of the + subprogram at the point(s) of call, instead of setting up a stack frame + for out-of-line calls. Here is the resulting program: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment_2 is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + pragma Inline (Increment); + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Increment (Value); + Put_Line ("Value after is" & Value'Img); + end Increment_2; + + Compile the program with both optimization (`/OPTIMIZE=ALL') and + inlining enabled (`-gnatpn' instead of `/CHECKS=SUPPRESS_ALL'). + + The `Incr' function is still compiled as usual, but at the point in + `Increment' where our function used to be called: + + pushl %edi + call _increment__incr.1 + + the code for the function body directly appears: + + movl %esi,%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + + thus saving the overhead of stack frame setup and an out-of-line call. + +  + File: gnat_ug_vms.info, Node: Other Asm Functionality, Next: A Complete Example, Prev: Inlining Inline Assembler Code, Up: Inline Assembler + + Other `Asm' Functionality + ========================= + + This section describes two important parameters to the `Asm' procedure: + `Clobber', which identifies register usage; and `Volatile', which + inhibits unwanted optimizations. + + * Menu: + + * The Clobber Parameter:: + * The Volatile Parameter:: + +  + File: gnat_ug_vms.info, Node: The Clobber Parameter, Next: The Volatile Parameter, Up: Other Asm Functionality + + The `Clobber' Parameter + ----------------------- + + One of the dangers of intermixing assembly language and a compiled + language such as Ada is that the compiler needs to be aware of which + registers are being used by the assembly code. In some cases, such as + the earlier examples, the constraint string is sufficient to indicate + register usage (e.g. "a" for the eax register). But more generally, the + compiler needs an explicit identification of the registers that are + used by the Inline Assembly statements. + + Using a register that the compiler doesn't know about could be a + side effect of an instruction (like `mull' storing its result in both + eax and edx). It can also arise from explicit register usage in your + assembly code; for example: + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out)); + + where the compiler (since it does not analyze the `Asm' template string) + does not know you are using the ebx register. + + In such cases you need to supply the `Clobber' parameter to `Asm', + to identify the registers that will be used by your assembly code: + + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx"); + + The Clobber parameter is a static string expression specifying the + register(s) you are using. Note that register names are _not_ prefixed + by a percent sign. Also, if more than one register is used then their + names are separated by commas; e.g., `"eax, ebx"' + + The `Clobber' parameter has several additional uses: + 1. Use the "register" name `cc' to indicate that flags might have + changed + + 2. Use the "register" name `memory' if you changed a memory location + +  + File: gnat_ug_vms.info, Node: The Volatile Parameter, Prev: The Clobber Parameter, Up: Other Asm Functionality + + The `Volatile' Parameter + ------------------------ + + Compiler optimizations in the presence of Inline Assembler may + sometimes have unwanted effects. For example, when an `Asm' invocation + with an input variable is inside a loop, the compiler might move the + loading of the input variable outside the loop, regarding it as a + one-time initialization. + + If this effect is not desired, you can disable such optimizations by + setting the `Volatile' parameter to `True'; for example: + + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx", + Volatile => True); + + By default, `Volatile' is set to `False' unless there is no `Outputs' + parameter. + + Although setting `Volatile' to `True' prevents unwanted + optimizations, it will also disable other optimizations that might be + important for efficiency. In general, you should set `Volatile' to + `True' only if the compiler's optimizations have created problems. + +  + File: gnat_ug_vms.info, Node: A Complete Example, Prev: Other Asm Functionality, Up: Inline Assembler + + A Complete Example + ================== + + This section contains a complete program illustrating a realistic usage + of GNAT's Inline Assembler capabilities. It comprises a main procedure + `Check_CPU' and a package `Intel_CPU'. The package declares a + collection of functions that detect the properties of the 32-bit x86 + processor that is running the program. The main procedure invokes + these functions and displays the information. + + The Intel_CPU package could be enhanced by adding functions to + detect the type of x386 co-processor, the processor caching options and + special operations such as the SIMD extensions. + + Although the Intel_CPU package has been written for 32-bit Intel + compatible CPUs, it is OS neutral. It has been tested on DOS, + Windows/NT and Linux. + + * Menu: + + * Check_CPU Procedure:: + * Intel_CPU Package Specification:: + * Intel_CPU Package Body:: + +  + File: gnat_ug_vms.info, Node: Check_CPU Procedure, Next: Intel_CPU Package Specification, Up: A Complete Example + + `Check_CPU' Procedure + --------------------- + + --------------------------------------------------------------------- + -- -- + -- Uses the Intel_CPU package to identify the CPU the program is -- + -- running on, and some of the features it supports. -- + -- -- + --------------------------------------------------------------------- + + with Intel_CPU; -- Intel CPU detection functions + with Ada.Text_IO; -- Standard text I/O + with Ada.Command_Line; -- To set the exit status + + procedure Check_CPU is + + Type_Found : Boolean := False; + -- Flag to indicate that processor was identified + + Features : Intel_CPU.Processor_Features; + -- The processor features + + Signature : Intel_CPU.Processor_Signature; + -- The processor type signature + + begin + + ----------------------------------- + -- Display the program banner. -- + ----------------------------------- + + Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name & + ": check Intel CPU version and features, v1.0"); + Ada.Text_IO.Put_Line ("distribute freely, but no warranty whatsoever"); + Ada.Text_IO.New_Line; + + ----------------------------------------------------------------------- + -- We can safely start with the assumption that we are on at least -- + -- a x386 processor. If the CPUID instruction is present, then we -- + -- have a later processor type. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Has_CPUID = False then + + -- No CPUID instruction, so we assume this is indeed a x386 + -- processor. We can still check if it has a FP co-processor. + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line + ("x386-type processor with a FP co-processor"); + else + Ada.Text_IO.Put_Line + ("x386-type processor without a FP co-processor"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check for CPUID + + ----------------------------------------------------------------------- + -- If CPUID is supported, check if this is a true Intel processor, -- + -- if it is not, display a warning. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Vendor_ID /= Intel_CPU.Intel_Processor then + Ada.Text_IO.Put_Line ("*** This is a Intel compatible processor"); + Ada.Text_IO.Put_Line ("*** Some information may be incorrect"); + end if; -- check if Intel + + ---------------------------------------------------------------------- + -- With the CPUID instruction present, we can assume at least a -- + -- x486 processor. If the CPUID support level is < 1 then we have -- + -- to leave it at that. -- + ---------------------------------------------------------------------- + + if Intel_CPU.CPUID_Level < 1 then + + -- Ok, this is a x486 processor. we still can get the Vendor ID + Ada.Text_IO.Put_Line ("x486-type processor"); + Ada.Text_IO.Put_Line ("Vendor ID is " & Intel_CPU.Vendor_ID); + + -- We can also check if there is a FPU present + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line ("Floating-Point support"); + else + Ada.Text_IO.Put_Line ("No Floating-Point support"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check CPUID level + + --------------------------------------------------------------------- + -- With a CPUID level of 1 we can use the processor signature to -- + -- determine it's exact type. -- + --------------------------------------------------------------------- + + Signature := Intel_CPU.Signature; + + ---------------------------------------------------------------------- + -- Ok, now we go into a lot of messy comparisons to get the -- + -- processor type. For clarity, no attememt to try to optimize the -- + -- comparisons has been made. Note that since Intel_CPU does not -- + -- support getting cache info, we cannot distinguish between P5 -- + -- and Celeron types yet. -- + ---------------------------------------------------------------------- + + -- x486SL + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486SL processor"); + end if; + + -- x486DX2 Write-Back + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0111# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Write-Back Enhanced x486DX2 processor"); + end if; + + -- x486DX4 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 processor"); + end if; + + -- x486DX4 Overdrive + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 OverDrive processor"); + end if; + + -- Pentium (60, 66) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium processor (60, 66)"); + end if; + + -- Pentium (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive (60, 66) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium OverDrive processor (60, 66)"); + end if; + + -- Pentium OverDrive (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive cpu (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive processor for x486 processor-based systems + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor for x486 processor-based systems"); + end if; + + -- Pentium processor with MMX technology (166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor with MMX technology (166, 200)"); + end if; + + -- Pentium OverDrive with MMX for Pentium (75, 90, 100, 120, 133) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor with MMX " & + "technology for Pentium processor (75, 90, 100, 120, 133)"); + end if; + + -- Pentium Pro processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro processor"); + end if; + + -- Pentium II processor, model 3 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium II processor, model 3"); + end if; + + -- Pentium II processor, model 5 or Celeron processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0101# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium II processor, model 5 or Celeron processor"); + end if; + + -- Pentium Pro OverDrive processor + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro OverDrive processor"); + end if; + + -- If no type recognized, we have an unknown. Display what + -- we _do_ know + if Type_Found = False then + Ada.Text_IO.Put_Line ("Unknown processor"); + end if; + + ----------------------------------------- + -- Display processor stepping level. -- + ----------------------------------------- + + Ada.Text_IO.Put_Line ("Stepping level:" & Signature.Stepping'Img); + + --------------------------------- + -- Display vendor ID string. -- + --------------------------------- + + Ada.Text_IO.Put_Line ("Vendor ID: " & Intel_CPU.Vendor_ID); + + ------------------------------------ + -- Get the processors features. -- + ------------------------------------ + + Features := Intel_CPU.Features; + + ----------------------------- + -- Check for a FPU unit. -- + ----------------------------- + + if Features.FPU = True then + Ada.Text_IO.Put_Line ("Floating-Point unit available"); + else + Ada.Text_IO.Put_Line ("no Floating-Point unit"); + end if; -- check for FPU + + -------------------------------- + -- List processor features. -- + -------------------------------- + + Ada.Text_IO.Put_Line ("Supported features: "); + + -- Virtual Mode Extension + if Features.VME = True then + Ada.Text_IO.Put_Line (" VME - Virtual Mode Extension"); + end if; + + -- Debugging Extension + if Features.DE = True then + Ada.Text_IO.Put_Line (" DE - Debugging Extension"); + end if; + + -- Page Size Extension + if Features.PSE = True then + Ada.Text_IO.Put_Line (" PSE - Page Size Extension"); + end if; + + -- Time Stamp Counter + if Features.TSC = True then + Ada.Text_IO.Put_Line (" TSC - Time Stamp Counter"); + end if; + + -- Model Specific Registers + if Features.MSR = True then + Ada.Text_IO.Put_Line (" MSR - Model Specific Registers"); + end if; + + -- Physical Address Extension + if Features.PAE = True then + Ada.Text_IO.Put_Line (" PAE - Physical Address Extension"); + end if; + + -- Machine Check Extension + if Features.MCE = True then + Ada.Text_IO.Put_Line (" MCE - Machine Check Extension"); + end if; + + -- CMPXCHG8 instruction supported + if Features.CX8 = True then + Ada.Text_IO.Put_Line (" CX8 - CMPXCHG8 instruction"); + end if; + + -- on-chip APIC hardware support + if Features.APIC = True then + Ada.Text_IO.Put_Line (" APIC - on-chip APIC hardware support"); + end if; + + -- Fast System Call + if Features.SEP = True then + Ada.Text_IO.Put_Line (" SEP - Fast System Call"); + end if; + + -- Memory Type Range Registers + if Features.MTRR = True then + Ada.Text_IO.Put_Line (" MTTR - Memory Type Range Registers"); + end if; + + -- Page Global Enable + if Features.PGE = True then + Ada.Text_IO.Put_Line (" PGE - Page Global Enable"); + end if; + + -- Machine Check Architecture + if Features.MCA = True then + Ada.Text_IO.Put_Line (" MCA - Machine Check Architecture"); + end if; + + -- Conditional Move Instruction Supported + if Features.CMOV = True then + Ada.Text_IO.Put_Line + (" CMOV - Conditional Move Instruction Supported"); + end if; + + -- Page Attribute Table + if Features.PAT = True then + Ada.Text_IO.Put_Line (" PAT - Page Attribute Table"); + end if; + + -- 36-bit Page Size Extension + if Features.PSE_36 = True then + Ada.Text_IO.Put_Line (" PSE_36 - 36-bit Page Size Extension"); + end if; + + -- MMX technology supported + if Features.MMX = True then + Ada.Text_IO.Put_Line (" MMX - MMX technology supported"); + end if; + + -- Fast FP Save and Restore + if Features.FXSR = True then + Ada.Text_IO.Put_Line (" FXSR - Fast FP Save and Restore"); + end if; + + --------------------- + -- Program done. -- + --------------------- + + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + + exception + + when others => + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); + raise; + + end Check_CPU; + +  + File: gnat_ug_vms.info, Node: Intel_CPU Package Specification, Next: Intel_CPU Package Body, Prev: Check_CPU Procedure, Up: A Complete Example + + `Intel_CPU' Package Specification + --------------------------------- + + ------------------------------------------------------------------------- + -- -- + -- file: INTEL_CPU.ADS -- + -- -- + -- ********************************************* -- + -- * WARNING: for 32-bit Intel processors only * -- + -- ********************************************* -- + -- -- + -- This package contains a number of subprograms that are useful in -- + -- determining the Intel x86 CPU (and the features it supports) on -- + -- which the program is running. -- + -- -- + -- The package is based upon the information given in the Intel -- + -- Application Note AP-485: "Intel Processor Identification and the -- + -- CPUID Instruction" as of April 1998. This application note can be -- + -- found on www.intel.com. -- + -- -- + -- It currently deals with 32-bit processors only, will not detect -- + -- features added after april 1998, and does not guarantee proper -- + -- results on Intel-compatible processors. -- + -- -- + -- Cache info and x386 fpu type detection are not supported. -- + -- -- + -- This package does not use any privileged instructions, so should -- + -- work on any OS running on a 32-bit Intel processor. -- + -- -- + ------------------------------------------------------------------------- + + with Interfaces; use Interfaces; + -- for using unsigned types + + with System.Machine_Code; use System.Machine_Code; + -- for using inline assembler code + + with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; + -- for inserting control characters + + package Intel_CPU is + + ---------------------- + -- Processor bits -- + ---------------------- + + subtype Num_Bits is Natural range 0 .. 31; + -- the number of processor bits (32) + + -------------------------- + -- Processor register -- + -------------------------- + + -- define a processor register type for easy access to + -- the individual bits + + type Processor_Register is array (Num_Bits) of Boolean; + pragma Pack (Processor_Register); + for Processor_Register'Size use 32; + + ------------------------- + -- Unsigned register -- + ------------------------- + + -- define a processor register type for easy access to + -- the individual bytes + + type Unsigned_Register is + record + L1 : Unsigned_8; + H1 : Unsigned_8; + L2 : Unsigned_8; + H2 : Unsigned_8; + end record; + + for Unsigned_Register use + record + L1 at 0 range 0 .. 7; + H1 at 0 range 8 .. 15; + L2 at 0 range 16 .. 23; + H2 at 0 range 24 .. 31; + end record; + + for Unsigned_Register'Size use 32; + + --------------------------------- + -- Intel processor vendor ID -- + --------------------------------- + + Intel_Processor : constant String (1 .. 12) := "GenuineIntel"; + -- indicates an Intel manufactured processor + + ------------------------------------ + -- Processor signature register -- + ------------------------------------ + + -- a register type to hold the processor signature + + type Processor_Signature is + record + Stepping : Natural range 0 .. 15; + Model : Natural range 0 .. 15; + Family : Natural range 0 .. 15; + Processor_Type : Natural range 0 .. 3; + Reserved : Natural range 0 .. 262143; + end record; + + for Processor_Signature use + record + Stepping at 0 range 0 .. 3; + Model at 0 range 4 .. 7; + Family at 0 range 8 .. 11; + Processor_Type at 0 range 12 .. 13; + Reserved at 0 range 14 .. 31; + end record; + + for Processor_Signature'Size use 32; + + ----------------------------------- + -- Processor features register -- + ----------------------------------- + + -- a processor register to hold the processor feature flags + + type Processor_Features is + record + FPU : Boolean; -- floating point unit on chip + VME : Boolean; -- virtual mode extension + DE : Boolean; -- debugging extension + PSE : Boolean; -- page size extension + TSC : Boolean; -- time stamp counter + MSR : Boolean; -- model specific registers + PAE : Boolean; -- physical address extension + MCE : Boolean; -- machine check extension + CX8 : Boolean; -- cmpxchg8 instruction + APIC : Boolean; -- on-chip apic hardware + Res_1 : Boolean; -- reserved for extensions + SEP : Boolean; -- fast system call + MTRR : Boolean; -- memory type range registers + PGE : Boolean; -- page global enable + MCA : Boolean; -- machine check architecture + CMOV : Boolean; -- conditional move supported + PAT : Boolean; -- page attribute table + PSE_36 : Boolean; -- 36-bit page size extension + Res_2 : Natural range 0 .. 31; -- reserved for extensions + MMX : Boolean; -- MMX technology supported + FXSR : Boolean; -- fast FP save and restore + Res_3 : Natural range 0 .. 127; -- reserved for extensions + end record; + + for Processor_Features use + record + FPU at 0 range 0 .. 0; + VME at 0 range 1 .. 1; + DE at 0 range 2 .. 2; + PSE at 0 range 3 .. 3; + TSC at 0 range 4 .. 4; + MSR at 0 range 5 .. 5; + PAE at 0 range 6 .. 6; + MCE at 0 range 7 .. 7; + CX8 at 0 range 8 .. 8; + APIC at 0 range 9 .. 9; + Res_1 at 0 range 10 .. 10; + SEP at 0 range 11 .. 11; + MTRR at 0 range 12 .. 12; + PGE at 0 range 13 .. 13; + MCA at 0 range 14 .. 14; + CMOV at 0 range 15 .. 15; + PAT at 0 range 16 .. 16; + PSE_36 at 0 range 17 .. 17; + Res_2 at 0 range 18 .. 22; + MMX at 0 range 23 .. 23; + FXSR at 0 range 24 .. 24; + Res_3 at 0 range 25 .. 31; + end record; + + for Processor_Features'Size use 32; + + ------------------- + -- Subprograms -- + ------------------- + + function Has_FPU return Boolean; + -- return True if a FPU is found + -- use only if CPUID is not supported + + function Has_CPUID return Boolean; + -- return True if the processor supports the CPUID instruction + + function CPUID_Level return Natural; + -- return the CPUID support level (0, 1 or 2) + -- can only be called if the CPUID instruction is supported + + function Vendor_ID return String; + -- return the processor vendor identification string + -- can only be called if the CPUID instruction is supported + + function Signature return Processor_Signature; + -- return the processor signature + -- can only be called if the CPUID instruction is supported + + function Features return Processor_Features; + -- return the processors features + -- can only be called if the CPUID instruction is supported + + private + + ------------------------ + -- EFLAGS bit names -- + ------------------------ + + ID_Flag : constant Num_Bits := 21; + -- ID flag bit + + end Intel_CPU; + +  + File: gnat_ug_vms.info, Node: Intel_CPU Package Body, Prev: Intel_CPU Package Specification, Up: A Complete Example + + `Intel_CPU' Package Body + ------------------------ + + package body Intel_CPU is + + --------------------------- + -- Detect FPU presence -- + --------------------------- + + -- There is a FPU present if we can set values to the FPU Status + -- and Control Words. + + function Has_FPU return Boolean is + + Register : Unsigned_16; + -- processor register to store a word + + begin + + -- check if we can change the status word + Asm ( + + -- the assembler code + "finit" & LF & HT & -- reset status word + "movw $0x5A5A, %%ax" & LF & HT & -- set value status word + "fnstsw %0" & LF & HT & -- save status word + "movw %%ax, %0", -- store status word + + -- output stored in Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register), + + -- tell compiler that we used eax + Clobber => "eax"); + + -- if the status word is zero, there is no FPU + if Register = 0 then + return False; -- no status word + end if; -- check status word value + + -- check if we can get the control word + Asm ( + + -- the assembler code + "fnstcw %0", -- save the control word + + -- output into Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register)); + + -- check the relevant bits + if (Register and 16#103F#) /= 16#003F# then + return False; -- no control word + end if; -- check control word value + + -- FPU found + return True; + + end Has_FPU; + + -------------------------------- + -- Detect CPUID instruction -- + -------------------------------- + + -- The processor supports the CPUID instruction if it is possible + -- to change the value of ID flag bit in the EFLAGS register. + + function Has_CPUID return Boolean is + + Original_Flags, Modified_Flags : Processor_Register; + -- EFLAG contents before and after changing the ID flag + + begin + + -- try flipping the ID flag in the EFLAGS register + Asm ( + + -- the assembler code + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %%eax" & LF & HT & -- pop EFLAGS into eax + "movl %%eax, %0" & LF & HT & -- save EFLAGS content + "xor $0x200000, %%eax" & LF & HT & -- flip ID flag + "push %%eax" & LF & HT & -- push EFLAGS on stack + "popfl" & LF & HT & -- load EFLAGS register + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %1", -- save EFLAGS content + + -- output values, may be anything + -- Original_Flags is %0 + -- Modified_Flags is %1 + Outputs => + (Processor_Register'Asm_output ("=g", Original_Flags), + Processor_Register'Asm_output ("=g", Modified_Flags)), + + -- tell compiler eax is destroyed + Clobber => "eax"); + + -- check if CPUID is supported + if Original_Flags(ID_Flag) /= Modified_Flags(ID_Flag) then + return True; -- ID flag was modified + else + return False; -- ID flag unchanged + end if; -- check for CPUID + + end Has_CPUID; + + ------------------------------- + -- Get CPUID support level -- + ------------------------------- + + function CPUID_Level return Natural is + + Level : Unsigned_32; + -- returned support level + + begin + + -- execute CPUID, storing the results in the Level register + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero is stored in eax + -- returning the support level in eax + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- eax is stored in Level + Outputs => Unsigned_32'Asm_output ("=a", Level), + + -- tell compiler ebx, ecx and edx registers are destroyed + Clobber => "ebx, ecx, edx"); + + -- return the support level + return Natural (Level); + + end CPUID_Level; + + -------------------------------- + -- Get CPU Vendor ID String -- + -------------------------------- + + -- The vendor ID string is returned in the ebx, ecx and edx register + -- after executing the CPUID instruction with eax set to zero. + -- In case of a true Intel processor the string returned is + -- "GenuineIntel" + + function Vendor_ID return String is + + Ebx, Ecx, Edx : Unsigned_Register; + -- registers containing the vendor ID string + + Vendor_ID : String (1 .. 12); + -- the vendor ID string + + begin + + -- execute CPUID, storing the results in the processor registers + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero stored in eax + -- vendor ID string returned in ebx, ecx and edx + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- ebx is stored in Ebx + -- ecx is stored in Ecx + -- edx is stored in Edx + Outputs => (Unsigned_Register'Asm_output ("=b", Ebx), + Unsigned_Register'Asm_output ("=c", Ecx), + Unsigned_Register'Asm_output ("=d", Edx))); + + -- now build the vendor ID string + Vendor_ID( 1) := Character'Val (Ebx.L1); + Vendor_ID( 2) := Character'Val (Ebx.H1); + Vendor_ID( 3) := Character'Val (Ebx.L2); + Vendor_ID( 4) := Character'Val (Ebx.H2); + Vendor_ID( 5) := Character'Val (Edx.L1); + Vendor_ID( 6) := Character'Val (Edx.H1); + Vendor_ID( 7) := Character'Val (Edx.L2); + Vendor_ID( 8) := Character'Val (Edx.H2); + Vendor_ID( 9) := Character'Val (Ecx.L1); + Vendor_ID(10) := Character'Val (Ecx.H1); + Vendor_ID(11) := Character'Val (Ecx.L2); + Vendor_ID(12) := Character'Val (Ecx.H2); + + -- return string + return Vendor_ID; + + end Vendor_ID; + + ------------------------------- + -- Get processor signature -- + ------------------------------- + + function Signature return Processor_Signature is + + Result : Processor_Signature; + -- processor signature returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one is stored in eax + -- processor signature returned in eax + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- eax is stored in Result + Outputs => Processor_Signature'Asm_output ("=a", Result), + + -- tell compiler that ebx, ecx and edx are also destroyed + Clobber => "ebx, ecx, edx"); + + -- return processor signature + return Result; + + end Signature; + + ------------------------------ + -- Get processor features -- + ------------------------------ + + function Features return Processor_Features is + + Result : Processor_Features; + -- processor features returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one stored in eax + -- processor features returned in edx + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- edx is stored in Result + Outputs => Processor_Features'Asm_output ("=d", Result), + + -- tell compiler that ebx and ecx are also destroyed + Clobber => "ebx, ecx"); + + -- return processor signature + return Result; + + end Features; + + end Intel_CPU; + +  + File: gnat_ug_vms.info, Node: Performance Considerations, Next: GNU Free Documentation License, Prev: Inline Assembler, Up: Top + + Performance Considerations + ************************** + + The GNAT system provides a number of options that allow a trade-off + between + + * performance of the generated code + + * speed of compilation + + * minimization of dependences and recompilation + + * the degree of run-time checking. + + The defaults (if no options are selected) aim at improving the speed of + compilation and minimizing dependences, at the expense of performance + of the generated code: + + * no optimization + + * no inlining of subprogram calls + + * all run-time checks enabled except overflow and elaboration checks + + These options are suitable for most program development purposes. This + chapter describes how you can modify these choices, and also provides + some guidelines on debugging optimized code. + + * Menu: + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + * Coverage Analysis:: + +  + File: gnat_ug_vms.info, Node: Controlling Run-Time Checks, Next: Optimization Levels, Up: Performance Considerations + + Controlling Run-Time Checks + =========================== + + By default, GNAT generates all run-time checks, except arithmetic + overflow checking for integer operations and checks for access before + elaboration on subprogram calls. The latter are not required in default + mode, because all necessary checking is done at compile time. Two gnat + qualifiers, `/CHECKS=SUPPRESS_ALL' and `/CHECKS=OVERFLOW' allow this + default to be modified. *Note Run-Time Checks::. + + Our experience is that the default is suitable for most development + purposes. + + We treat integer overflow specially because these are quite + expensive and in our experience are not as important as other run-time + checks in the development process. Note that division by zero is not + considered an overflow check, and divide by zero checks are generated + where required by default. + + Elaboration checks are off by default, and also not needed by + default, since GNAT uses a static elaboration analysis approach that + avoids the need for run-time checking. This manual contains a full + chapter discussing the issue of elaboration checks, and if the default + is not satisfactory for your use, you should read this chapter. + + For validity checks, the minimal checks required by the Ada Reference + Manual (for case statements and assignments to array elements) are on + by default. These can be suppressed by use of the `-gnatVn' qualifier. + Note that in Ada 83, there were no validity checks, so if the Ada 83 + mode is acceptable (or when comparing GNAT performance with an Ada 83 + compiler), it may be reasonable to routinely use `-gnatVn'. Validity + checks are also suppressed entirely if `/CHECKS=SUPPRESS_ALL' is used. + + Note that the setting of the qualifiers controls the default setting + of the checks. They may be modified using either `pragma Suppress' (to + remove checks) or `pragma Unsuppress' (to add back suppressed checks) + in the program source. + +  + File: gnat_ug_vms.info, Node: Optimization Levels, Next: Debugging Optimized Code, Prev: Controlling Run-Time Checks, Up: Performance Considerations + + Optimization Levels + =================== + + The default is optimization off. This results in the fastest compile + times, but GNAT makes absolutely no attempt to optimize, and the + generated programs are considerably larger and slower than when + optimization is enabled. You can use the `/OPTIMIZE' on the `GNAT + COMPILE' command line to control the optimization level: + + `/OPTIMIZE=NONE' + no optimization (the default) + + `/OPTIMIZE=SOME' + medium level optimization + + `/OPTIMIZE=ALL' + full optimization + + `/OPTIMIZE=INLINING' + full optimization, and also attempt automatic inlining of small + subprograms within a unit (*note Inlining of Subprograms::). + + Higher optimization levels perform more global transformations on the + program and apply more expensive analysis algorithms in order to + generate faster and more compact code. The price in compilation time, + and the resulting improvement in execution time, both depend on the + particular application and the hardware environment. You should + experiment to find the best level for your application. + + Note: Unlike some other compilation systems, `GNAT COMPILE' has been + tested extensively at all optimization levels. There are some bugs + which appear only with optimization turned on, but there have also been + bugs which show up only in _unoptimized_ code. Selecting a lower level + of optimization does not improve the reliability of the code generator, + which in practice is highly reliable at all optimization levels. + + Note regarding the use of `/OPTIMIZE=INLINING': The use of this + optimization level is generally discouraged with GNAT, since it often + results in larger executables which run more slowly. See further + discussion of this point in *note Inlining of Subprograms::. + +  + File: gnat_ug_vms.info, Node: Debugging Optimized Code, Next: Inlining of Subprograms, Prev: Optimization Levels, Up: Performance Considerations + + Debugging Optimized Code + ======================== + + Since the compiler generates debugging tables for a compilation unit + before it performs optimizations, the optimizing transformations may + invalidate some of the debugging data. You therefore need to + anticipate certain anomalous situations that may arise while debugging + optimized code. This section describes the most common cases. + + 1. The "hopping Program Counter": Repeated 'step' or 'next' commands + show the PC bouncing back and forth in the code. This may result + from any of the following optimizations: + + * Common subexpression elimination: using a single instance of + code for a quantity that the source computes several times. + As a result you may not be able to stop on what looks like a + statement. + + * Invariant code motion: moving an expression that does not + change within a loop, to the beginning of the loop. + + * Instruction scheduling: moving instructions so as to overlap + loads and stores (typically) with other code, or in general + to move computations of values closer to their uses. Often + this causes you to pass an assignment statement without the + assignment happening and then later bounce back to the + statement when the value is actually needed. Placing a + breakpoint on a line of code and then stepping over it may, + therefore, not always cause all the expected side-effects. + + 2. The "big leap": More commonly known as cross-jumping, in which two + identical pieces of code are merged and the program counter + suddenly jumps to a statement that is not supposed to be executed, + simply because it (and the code following) translates to the same + thing as the code that _was_ supposed to be executed. This effect + is typically seen in sequences that end in a jump, such as a + `goto', a `return', or a `break' in a C `qualifier' statement. + + 3. The "roving variable": The symptom is an unexpected value in a + variable. There are various reasons for this effect: + + * In a subprogram prologue, a parameter may not yet have been + moved to its "home". + + * A variable may be dead, and its register re-used. This is + probably the most common cause. + + * As mentioned above, the assignment of a value to a variable + may have been moved. + + * A variable may be eliminated entirely by value propagation or + other means. In this case, GCC may incorrectly generate + debugging information for the variable + + In general, when an unexpected value appears for a local variable + or parameter you should first ascertain if that value was actually + computed by your program, as opposed to being incorrectly reported + by the debugger. Record fields or array elements in an object + designated by an access value are generally less of a problem, + once you have ascertained that the access value is sensible. + Typically, this means checking variables in the preceding code and + in the calling subprogram to verify that the value observed is + explainable from other values (one must apply the procedure + recursively to those other values); or re-running the code and + stopping a little earlier (perhaps before the call) and stepping + to better see how the variable obtained the value in question; or + continuing to step _from_ the point of the strange value to see if + code motion had simply moved the variable's assignments later. + +  + File: gnat_ug_vms.info, Node: Inlining of Subprograms, Next: Coverage Analysis, Prev: Debugging Optimized Code, Up: Performance Considerations + + Inlining of Subprograms + ======================= + + A call to a subprogram in the current unit is inlined if all the + following conditions are met: + + * The optimization level is at least `/OPTIMIZE=SOME'. + + * The called subprogram is suitable for inlining: It must be small + enough and not contain nested subprograms or anything else that + `GNAT COMPILE' cannot support in inlined subprograms. + + * The call occurs after the definition of the body of the subprogram. + + * Either `pragma Inline' applies to the subprogram or it is small + and automatic inlining (optimization level `/OPTIMIZE=INLINING') is + specified. + + Calls to subprograms in `with''ed units are normally not inlined. To + achieve this level of inlining, the following conditions must all be + true: + + * The optimization level is at least `/OPTIMIZE=SOME'. + + * The called subprogram is suitable for inlining: It must be small + enough and not contain nested subprograms or anything else `GNAT + COMPILE' cannot support in inlined subprograms. + + * The call appears in a body (not in a package spec). + + * There is a `pragma Inline' for the subprogram. + + * The `/INLINE' qualifier is used in the `GNAT COMPILE' command line + + Note that specifying the `/INLINE=PRAGMA' qualifier causes additional + compilation dependencies. Consider the following: + + package R is + procedure Q; + pragma Inline (Q); + end R; + package body R is + ... + end R; + + with R; + procedure Main is + begin + ... + R.Q; + end Main; + + With the default behavior (no `/INLINE=PRAGMA' qualifier specified), the + compilation of the `Main' procedure depends only on its own source, + `MAIN.ADB', and the spec of the package in file `R.ADS'. This means + that editing the body of `R' does not require recompiling `Main'. + + On the other hand, the call `R.Q' is not inlined under these + circumstances. If the `/INLINE=PRAGMA' qualifier is present when `Main' + is compiled, the call will be inlined if the body of `Q' is small + enough, but now `Main' depends on the body of `R' in `R.ADB' as well as + on the spec. This means that if this body is edited, the main program + must be recompiled. Note that this extra dependency occurs whether or + not the call is in fact inlined by `GNAT COMPILE'. + + The use of front end inlining with `-gnatN' generates similar + additional dependencies. + + Note: The `/INLINE=SUPPRESS' qualifier can be used to prevent all + inlining. This qualifier overrides all other conditions and ensures + that no inlining occurs. The extra dependences resulting from + `/INLINE=PRAGMA' will still be active, even if this qualifier is used + to suppress the resulting inlining actions. + + Note regarding the use of `/OPTIMIZE=INLINING': There is no + difference in inlining behavior between `/OPTIMIZE=ALL' and + `/OPTIMIZE=INLINING' for subprograms with an explicit pragma `Inline' + assuming the use of `/INLINE=PRAGMA' or `-gnatN' (the qualifiers that + activate inlining). If you have used pragma `Inline' in appropriate + cases, then it is usually much better to use `/OPTIMIZE=ALL' and + `/INLINE=PRAGMA' and avoid the use of `/OPTIMIZE=INLINING' which in + this case only has the effect of inlining subprograms you did not think + should be inlined. We often find that the use of `/OPTIMIZE=INLINING' + slows down code by performing excessive inlining, leading to increased + instruction cache pressure from the increased code size. So the bottom + line here is that you should not automatically assume that + `/OPTIMIZE=INLINING' is better than `/OPTIMIZE=ALL', and indeed you + should use `/OPTIMIZE=INLINING' only if tests show that it actually + improves performance. + +  + File: gnat_ug_vms.info, Node: Coverage Analysis, Prev: Inlining of Subprograms, Up: Performance Considerations + + Coverage Analysis + ================= + + GNAT supports the Digital Performance Coverage Analyzer (PCA), which + allows the user to determine the distribution of execution time across + a program, *note Profiling:: for details of usage. + +  + File: gnat_ug_vms.info, Node: GNU Free Documentation License, Next: Index, Prev: Performance Considerations, Up: Top + + GNU Free Documentation License + ****************************** + + Version 1.2, November 2002 + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. + We recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it + can be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You + accept the license if you copy, modify or distribute the work in a + way requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in + the notice that says that the Document is released under this + License. If a section does not fit the above definition of + Secondary then it is not allowed to be designated as Invariant. + The Document may contain zero Invariant Sections. If the Document + does not identify any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images + composed of pixels) generic paint programs or (for drawings) some + widely available drawing editor, and that is suitable for input to + text formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in an + otherwise Transparent file format whose markup, or absence of + markup, has been arranged to thwart or discourage subsequent + modification by readers is not Transparent. An image format is + not Transparent if used for any substantial amount of text. A + copy that is not "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and + standard-conforming simple HTML, PostScript or PDF designed for + human modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats that + can be read and edited only by proprietary word processors, SGML or + XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML, PostScript or PDF + produced by some word processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow + the conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the + title equally prominent and visible. You may add other material + on the covers in addition. Copying with changes limited to the + covers, as long as they preserve the title of the Document and + satisfy these conditions, can be treated as verbatim copying in + other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a computer-network location from + which the general network-using public has access to download + using public-standard network protocols a complete Transparent + copy of the Document, free of added material. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of + copies, to give them a chance to provide you with an updated + version of the Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with + the Modified Version filling the role of the Document, thus + licensing distribution and modification of the Modified Version to + whoever possesses a copy of it. In addition, you must do these + things in the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of + previous versions (which should, if there were any, be listed + in the History section of the Document). You may use the + same title as a previous version if the original publisher of + that version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on + the Title Page. If there is no section Entitled "History" in + the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, + then add an item describing the Modified Version as stated in + the previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in + the "History" section. You may omit a network location for a + work that was published at least four years before the + Document itself, or if the original publisher of the version + it refers to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the + section all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section + titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end + of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the + documents in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow + this License in all other respects regarding verbatim copying of + that document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warrany Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided for under this License. Any other + attempt to copy, modify, sublicense or distribute the Document is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + `http://www.gnu.org/copyleft/'. + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If + the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. + + ADDENDUM: How to use this License for your documents + ==================================================== + + To use this License in a document you have written, include a copy of + the License in the document and put the following copyright and license + notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover + Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other + combination of the three, merge those two alternatives to suit the + situation. + + If your document contains nontrivial examples of program code, we + recommend releasing these examples in parallel under your choice of + free software license, such as the GNU General Public License, to + permit their use in free software. + +  + File: gnat_ug_vms.info, Node: Index, Prev: GNU Free Documentation License, Up: Top + + Index + ***** + + * Menu: + + * -83 (gnathtml): Converting Ada Files to html with gnathtml. + * -c (gnatname): Qualifiers for gnatname. + * -d (gnathtml): Converting Ada Files to html with gnathtml. + * -D (gnatname): Qualifiers for gnatname. + * -d (gnatname): Qualifiers for gnatname. + * -f (GNAT LINK): Qualifiers for GNAT LINK. + * -f (gnathtml): Converting Ada Files to html with gnathtml. + * -fstack-check: Stack Overflow Checking. + * -gnatem (GNAT COMPILE): Units to Sources Mapping Files. + * -gnatN (GNAT COMPILE): Subprogram Inlining Control. + * -gnatN qualifier: Source Dependencies. + * -gnatT (GNAT COMPILE): Run-Time Control. + * -gnatwP (GNAT COMPILE): Output and Error Message Control. + * -gnatwp (GNAT COMPILE): Output and Error Message Control. + * -h (gnatname): Qualifiers for gnatname. + * -I (gnathtml): Converting Ada Files to html with gnathtml. + * -l (gnathtml): Converting Ada Files to html with gnathtml. + * -o (gnathtml): Converting Ada Files to html with gnathtml. + * -p (gnathtml): Converting Ada Files to html with gnathtml. + * -P (gnatname): Qualifiers for gnatname. + * -sc (gnathtml): Converting Ada Files to html with gnathtml. + * -t (gnathtml): Converting Ada Files to html with gnathtml. + * -v (gnatname): Qualifiers for gnatname. + * -w: Output and Error Message Control. + * /83 (GNAT COMPILE): Compiling Ada 83 Programs. + * /ACTIONS=BIND (GNAT MAKE): Qualifiers for GNAT MAKE. + * /ACTIONS=COMPILE (GNAT MAKE): Qualifiers for GNAT MAKE. + * /ACTIONS=LINK (GNAT MAKE): Qualifiers for GNAT MAKE. + * /ALL_FILES (GNAT MAKE): Qualifiers for GNAT MAKE. + * /ALL_UNITS (GNAT LIST): Qualifiers for GNAT LIST. + * /ASM (GNAT COMPILE): Qualifiers for GNAT COMPILE. + * /BIND_FILE=ADA (GNAT BIND): Output Control. + * /BIND_FILE=ADA (GNAT LINK): Qualifiers for GNAT LINK. + * /BIND_FILE=C (GNAT BIND): Output Control. + * /BIND_FILE=C (GNAT LINK): Qualifiers for GNAT LINK. + * /BINDER_QUALIFIERS (GNAT MAKE): Mode Qualifiers for GNAT MAKE. + * /CHECKS=ASSERTIONS (GNAT COMPILE): Debugging and Assertion Control. + * /CHECKS=ELABORATION (GNAT COMPILE) <1>: Debugging Control. + * /CHECKS=ELABORATION (GNAT COMPILE): Run-Time Checks. + * /CHECKS=OVERFLOW (GNAT COMPILE) <1>: Controlling Run-Time Checks. + * /CHECKS=OVERFLOW (GNAT COMPILE): Run-Time Checks. + * /CHECKS=SUPPRESS_ALL (GNAT COMPILE) <1>: Controlling Run-Time Checks. + * /CHECKS=SUPPRESS_ALL (GNAT COMPILE): Run-Time Checks. + * /COMPILATION (GNAT CHOP): Qualifiers for GNAT CHOP. + * /COMPILER_QUALIFIERS (GNAT MAKE): Mode Qualifiers for GNAT MAKE. + * /CONDITIONAL_SOURCE_SEARCH (GNAT MAKE): Qualifiers for GNAT MAKE. + * /CONFIG=file (GNAT LIBRARY): Qualifiers for GNAT LIBRARY. + * /CONTINUE_ON_ERROR (GNAT MAKE): Qualifiers for GNAT MAKE. + * /CREATE=directory (GNAT LIBRARY): Qualifiers for GNAT LIBRARY. + * /DEBUG (GNAT COMPILE): Qualifiers for GNAT COMPILE. + * /DEBUG (GNAT LINK): Qualifiers for GNAT LINK. + * /DEBUG=TRACEBACK (GNAT LINK): Qualifiers for GNAT LINK. + * /DELETE=directory (GNAT LIBRARY): Qualifiers for GNAT LIBRARY. + * /DEPENDENCIES (GNAT LIST): Qualifiers for GNAT LIST. + * /DEPENDENCIES_LIST (GNAT MAKE): Qualifiers for GNAT MAKE. + * /DO_OBJECT_CHECK (GNAT MAKE): Qualifiers for GNAT MAKE. + * /ELABORATION_DEPENDENCIES (GNAT BIND): Output Control. + * /ERROR_LIMIT (GNAT COMPILE): Output and Error Message Control. + * /EXECUTABLE (GNAT LINK): Qualifiers for GNAT LINK. + * /EXECUTABLE (GNAT MAKE): Qualifiers for GNAT MAKE. + * /EXPAND_SOURCE (GNAT COMPILE): Debugging Control. + * /FILE_NAME_MAX_LENGTH (GNAT CHOP): Qualifiers for GNAT CHOP. + * /FILE_NAME_MAX_LENGTH (GNAT COMPILE): File Naming Control. + * /FORCE_COMPILE (GNAT MAKE): Qualifiers for GNAT MAKE. + * /HELP (GNAT BIND): Output Control. + * /IDENTIFIER_CHARACTER_SET (GNAT COMPILE): Character Set Control. + * /IN_PLACE (GNAT MAKE): Qualifiers for GNAT MAKE. + * /INLINE=PRAGMA (GNAT COMPILE) <1>: Inlining of Subprograms. + * /INLINE=PRAGMA (GNAT COMPILE): Subprogram Inlining Control. + * /INLINE=PRAGMA qualifier: Source Dependencies. + * /INLINE=SUPPRESS (GNAT COMPILE): Inlining of Subprograms. + * /LIBRARY_SEARCH (GNAT MAKE): Qualifiers for GNAT MAKE. + * /LINKER_OPTION_LIST (GNAT BIND): Output Control. + * /LINKER_QUALIFIERS (GNAT MAKE): Mode Qualifiers for GNAT MAKE. + * /LIST (GNAT COMPILE): Output and Error Message Control. + * /MAPPING (GNAT MAKE): Qualifiers for GNAT MAKE. + * /MINIMAL_RECOMPILATION (GNAT MAKE): Qualifiers for GNAT MAKE. + * /NOCURRENT_DIRECTORY (GNAT COMPILE): Qualifiers for GNAT COMPILE. + * /NOCURRENT_DIRECTORY (GNAT MAKE): Qualifiers for GNAT MAKE. + * /NOLOAD (GNAT COMPILE): Using GNAT COMPILE for Semantic Checking. + * /NOMAIN (GNAT BIND): Binding with Non-Ada Main Programs. + * /NOMAIN (GNAT MAKE): Qualifiers for GNAT MAKE. + * /NOOUTPUT (GNAT BIND): Output Control. + * /NOSTD_INCLUDES (GNAT MAKE): Qualifiers for GNAT MAKE. + * /NOSTD_LIBRARIES (GNAT MAKE): Qualifiers for GNAT MAKE. + * /NOTIME_STAMP_CHECK (GNAT BIND): Binder Error Message Control. + * /OBJECT_LIST (GNAT BIND): Output Control. + * /OBJECT_SEARCH (GNAT MAKE): Qualifiers for GNAT MAKE. + * /OPTIMIZE (GNAT COMPILE): Optimization Levels. + * /ORDER_OF_ELABORATION (GNAT BIND): Output Control. + * /OUTPUT (GNAT BIND): Output Control. + * /OUTPUT=OBJECTS (GNAT LIST): Qualifiers for GNAT LIST. + * /OUTPUT=OPTIONS (GNAT LIST): Qualifiers for GNAT LIST. + * /OUTPUT=SOURCES (GNAT LIST): Qualifiers for GNAT LIST. + * /OUTPUT=UNITS (GNAT LIST): Qualifiers for GNAT LIST. + * /OUTPUT=VERBOSE (GNAT LIST): Qualifiers for GNAT LIST. + * /OVERWRITE (GNAT CHOP): Qualifiers for GNAT CHOP. + * /PESSIMISTIC_ELABORATION (GNAT BIND): Elaboration Control. + * /PRESERVE (GNAT CHOP): Qualifiers for GNAT CHOP. + * /PROCESSES (GNAT MAKE): Qualifiers for GNAT MAKE. + * /QUIET (GNAT CHOP): Qualifiers for GNAT CHOP. + * /QUIET (GNAT MAKE): Qualifiers for GNAT MAKE. + * /READ_SOURCES=ALL (GNAT BIND): Consistency-Checking Modes. + * /READ_SOURCES=NONE (GNAT BIND): Consistency-Checking Modes. + * /REASONS (GNAT MAKE): Qualifiers for GNAT MAKE. + * /REFERENCE (GNAT CHOP): Qualifiers for GNAT CHOP. + * /REPORT_ERRORS=BRIEF (GNAT BIND): Binder Error Message Control. + * /REPORT_ERRORS=FULL (GNAT COMPILE): Output and Error Message Control. + * /REPORT_ERRORS=VERBOSE (GNAT BIND): Binder Error Message Control. + * /REPORT_ERRORS=VERBOSE (GNAT COMPILE): Output and Error Message Control. + * /REPRESENTATION_INFO (GNAT COMPILE): Debugging Control. + * /RESTRICTION_LIST (GNAT BIND): Output Control. + * /RUNTIME_SYSTEM (GNAT BIND): Summary of Binder Qualifiers. + * /RUNTIME_SYSTEM (GNAT COMPILE): Qualifiers for GNAT COMPILE. + * /RUNTIME_SYSTEM (GNAT FIND): GNAT FIND Qualifiers. + * /RUNTIME_SYSTEM (GNAT LIST): Qualifiers for GNAT LIST. + * /RUNTIME_SYSTEM (GNAT MAKE): Qualifiers for GNAT MAKE. + * /RUNTIME_SYSTEM (GNAT XREF): GNAT XREF Qualifiers. + * /SEARCH (GNAT COMPILE): Qualifiers for GNAT COMPILE. + * /SEARCH (GNAT MAKE): Qualifiers for GNAT MAKE. + * /SET=directory (GNAT LIBRARY): Qualifiers for GNAT LIBRARY. + * /SKIP_MISSING (GNAT MAKE): Qualifiers for GNAT MAKE. + * /SOURCE_SEARCH (GNAT MAKE): Qualifiers for GNAT MAKE. + * /SWITCH_CHECK (GNAT MAKE): Qualifiers for GNAT MAKE. + * /SYNTAX_ONLY (GNAT COMPILE): Using GNAT COMPILE for Syntax Checking. + * /TRACE_UNITS qualifier: GNAT Abnormal Termination or Failure to Terminate. + * /TREE_OUTPUT (GNAT COMPILE): Auxiliary Output Control. + * /TRY_SEMANTICS (GNAT COMPILE): Output and Error Message Control. + * /UNIQUE (GNAT MAKE): Qualifiers for GNAT MAKE. + * /UNIQUE_ERROR_TAG (GNAT COMPILE): Output and Error Message Control. + * /UNITS_LIST (GNAT COMPILE): Auxiliary Output Control. + * /VERBOSE (GNAT CHOP): Qualifiers for GNAT CHOP. + * /VERBOSE (GNAT COMPILE): Qualifiers for GNAT COMPILE. + * /VERBOSE (GNAT LINK): Qualifiers for GNAT LINK. + * /WARNINGS=BIASED_ROUNDING (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=BRIEF (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=CONDITIONALS (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=ELABORATION (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=ERROR (GNAT BIND): Binder Error Message Control. + * /WARNINGS=ERROR (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=HIDING (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=IMPLEMENTATION (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=IMPLICIT_DEREFERENCE (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOBIASED_ROUNDING (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOCONDITIONALS (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOELABORATION (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOHIDING (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOIMPLEMENTATION (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOIMPLICIT_DEREFERENCE (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOOPTIONAL (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOOVERLAYS (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOREDUNDANT (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOUNREFERENCED_FORMALS (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=NOUNUSED (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=OPTIONAL (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=OVERLAYS (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=REDUNDANT (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=SUPPRESS (GNAT BIND): Binder Error Message Control. + * /WARNINGS=SUPPRESS (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=UNREFERENCED_FORMALS (GNAT COMPILE): Output and Error Message Control. + * /WARNINGS=UNUSED (GNAT COMPILE): Output and Error Message Control. + * /WIDE_CHARACTER_ENCODING (GNAT COMPILE): Character Set Control. + * /XDEBUG (GNAT COMPILE): Debugging Control. + * /XREF=SUPPRESS (GNAT COMPILE): Debugging Control. + * /ZERO_MAIN (GNAT BIND): Binding Programs with No Main Subprogram. + * __gnat_finalize: Running GNAT BIND. + * __gnat_initialize: Running GNAT BIND. + * __gnat_set_globals: Running GNAT BIND. + * _main: The External Symbol Naming Scheme of GNAT. + * Access before elaboration: Run-Time Checks. + * Access-to-subprogram: Elaboration for Access-to-Subprogram Values. + * ACVC, Ada 83 tests: Compiling Ada 83 Programs. + * Ada <1>: Naming Conventions for GNAT Source Files. + * Ada: Search Paths for GNAT BIND. + * Ada 83 compatibility: Compiling Ada 83 Programs. + * Ada 95 Language Reference Manual: What You Should Know before Reading This Guide. + * Ada expressions: Using Ada Expressions. + * Ada Library Information files: The Ada Library Information Files. + * Ada.Characters.Latin_1: Latin-1. + * ADA_INCLUDE_PATH: Search Paths and the Run-Time Library (RTL). + * ADA_OBJECTS_PATH: Search Paths for GNAT BIND. + * adafinal <1>: Binding with Non-Ada Main Programs. + * adafinal: Running GNAT BIND. + * adainit <1>: Binding with Non-Ada Main Programs. + * adainit: Running GNAT BIND. + * Address Clauses, warnings: Output and Error Message Control. + * ali files: The Ada Library Information Files. + * Annex A: Naming Conventions for GNAT Source Files. + * Annex B: Naming Conventions for GNAT Source Files. + * Arbitrary File Naming Conventions: Handling Arbitrary File Naming Conventions Using gnatname. + * Asm: Calling Conventions. + * Assert: Debugging and Assertion Control. + * Assertions: Debugging and Assertion Control. + * Biased rounding: Output and Error Message Control. + * Binder consistency checks: Binder Error Message Control. + * Binder output file: Interfacing to C. + * Binder, multiple input files: Binding with Non-Ada Main Programs. + * Breakpoints and tasks: Ada Tasks. + * C: Calling Conventions. + * C++: Calling Conventions. + * Calling Conventions: Calling Conventions. + * Check, elaboration: Run-Time Checks. + * Check, overflow: Run-Time Checks. + * Check_CPU procedure: Check_CPU Procedure. + * Checks, access before elaboration: Run-Time Checks. + * Checks, division by zero: Run-Time Checks. + * Checks, elaboration: Checking the Elaboration Order in Ada 95. + * Checks, overflow: Controlling Run-Time Checks. + * Checks, suppressing: Run-Time Checks. + * COBOL: Calling Conventions. + * code page 437: Other 8-Bit Codes. + * code page 850: Other 8-Bit Codes. + * Command line length: Qualifiers for GNAT LINK. + * Compatibility: Compatibility with DEC Ada. + * Compilation model: The GNAT Compilation Model. + * Conditionals, constant: Output and Error Message Control. + * Configuration pragmas: Configuration Pragmas. + * Consistency checks, in binder: Binder Error Message Control. + * Convention Ada: Calling Conventions. + * Convention Asm: Calling Conventions. + * Convention Assembler: Calling Conventions. + * Convention C: Calling Conventions. + * Convention C++: Calling Conventions. + * Convention COBOL: Calling Conventions. + * Convention Default: Calling Conventions. + * Convention DLL: Calling Conventions. + * Convention External: Calling Conventions. + * Convention Fortran: Calling Conventions. + * Convention Stdcall: Calling Conventions. + * Convention Stubbed: Calling Conventions. + * Convention Win32: Calling Conventions. + * Conventions: Conventions. + * CR: Source Representation. + * Cyrillic: Other 8-Bit Codes. + * Debug: Debugging and Assertion Control. + * Debug Pool: Finding Memory Problems with GNAT Debug Pool. + * Debugger: Running and Debugging Ada Programs. + * Debugging: Running and Debugging Ada Programs. + * Debugging Generic Units: Debugging Generic Units. + * Debugging information, including: Qualifiers for GNAT LINK. + * Debugging options: Debugging Control. + * Default: Calling Conventions. + * Dependencies, producing list: Qualifiers for GNAT MAKE. + * Dependency rules: The GNAT Make Program GNAT MAKE. + * Dereferencing, implicit: Output and Error Message Control. + * Division by zero: Run-Time Checks. + * DLL: Calling Conventions. + * Elaborate: Controlling the Elaboration Order in Ada 95. + * Elaborate_All: Controlling the Elaboration Order in Ada 95. + * Elaborate_Body: Controlling the Elaboration Order in Ada 95. + * Elaboration checks <1>: Checking the Elaboration Order in Ada 95. + * Elaboration checks: Run-Time Checks. + * Elaboration control <1>: Summary of Procedures for Elaboration Control. + * Elaboration control: Elaboration Order Handling in GNAT. + * Elaboration of library tasks: Elaboration Issues for Library Tasks. + * Elaboration order control: Comparison between GNAT and C/C++ Compilation Models. + * Elaboration, warnings: Output and Error Message Control. + * Eliminate: Eliminate Pragma. + * EMACS: Editing with EMACS. + * End of source file: Source Representation. + * Error messages, suppressing: Output and Error Message Control. + * EUC Coding: Wide Character Encodings. + * Exceptions: Ada Exceptions. + * Export: The External Symbol Naming Scheme of GNAT. + * External: Calling Conventions. + * FDL, GNU Free Documentation License: GNU Free Documentation License. + * FF: Source Representation. + * File names <1>: Alternative File Naming Schemes. + * File names: Using Other File Names. + * File naming schemes, alternative: Alternative File Naming Schemes. + * Floating-Point types: Floating-Point Types and Representations. + * Foreign Languages: Calling Conventions. + * Formals, unreferenced: Output and Error Message Control. + * Fortran: Calling Conventions. + * GDB: Running and Debugging Ada Programs. + * Generic formal parameters: Compiling Ada 83 Programs. + * Generics <1>: Debugging Generic Units. + * Generics: Generating Object Files. + * GNAT <1>: Naming Conventions for GNAT Source Files. + * GNAT: Search Paths for GNAT BIND. + * GNAT Abnormal Termination or Failure to Terminate: GNAT Abnormal Termination or Failure to Terminate. + * GNAT BIND: Binding Using GNAT BIND. + * GNAT CHOP: Renaming Files Using GNAT CHOP. + * GNAT compilation model: The GNAT Compilation Model. + * GNAT ELIM: Reducing the Size of Ada Executables with GNAT ELIM. + * GNAT FIND: The Cross-Referencing Tools GNAT XREF and GNAT FIND. + * GNAT KRUNCH: File Name Krunching Using GNAT KRUNCH. + * GNAT LIBRARY: The GNAT Run-Time Library Builder GNAT LIBRARY. + * GNAT library: Comparison between GNAT and Conventional Ada Library Models. + * GNAT LINK: Linking Using GNAT LINK. + * GNAT LIST: The GNAT Library Browser GNAT LIST. + * GNAT MAKE: The GNAT Make Program GNAT MAKE. + * GNAT PREPROCESS: Preprocessing Using GNAT PREPROCESS. + * GNAT STUB: Creating Sample Bodies Using GNAT STUB. + * GNAT XREF: The Cross-Referencing Tools GNAT XREF and GNAT FIND. + * GNAT.ADC <1>: The Configuration Pragmas Files. + * GNAT.ADC: Using Other File Names. + * GNAT1: Compiling Programs. + * gnat_argc: Command-Line Access. + * gnat_argv: Command-Line Access. + * GNAT_STACK_LIMIT: Stack Overflow Checking. + * Hiding of Declarations: Output and Error Message Control. + * HT: Source Representation. + * Implicit dereferencing: Output and Error Message Control. + * Inline <1>: Inlining of Subprograms. + * Inline: Source Dependencies. + * Inlining: Comparison between GNAT and Conventional Ada Library Models. + * Inlining, warnings: Output and Error Message Control. + * Intel_CPU package body: Intel_CPU Package Body. + * Intel_CPU package specification: Intel_CPU Package Specification. + * Interfaces <1>: Naming Conventions for GNAT Source Files. + * Interfaces: Search Paths for GNAT BIND. + * Interfacing to Ada: Calling Conventions. + * Interfacing to Assembly: Calling Conventions. + * Interfacing to C: Calling Conventions. + * Interfacing to C++: Calling Conventions. + * Interfacing to COBOL: Calling Conventions. + * Interfacing to Fortran: Calling Conventions. + * Internal trees, writing to file: Auxiliary Output Control. + * Latin-1 <1>: Latin-1. + * Latin-1: Source Representation. + * Latin-2: Other 8-Bit Codes. + * Latin-3: Other 8-Bit Codes. + * Latin-4: Other 8-Bit Codes. + * Latin-5: Other 8-Bit Codes. + * LF: Source Representation. + * Library browser: The GNAT Library Browser GNAT LIST. + * Library builder: The GNAT Run-Time Library Builder GNAT LIBRARY. + * Library tasks, elaboration issues: Elaboration Issues for Library Tasks. + * Linker libraries: Qualifiers for GNAT MAKE. + * LSE: LSE. + * Machine_Overflows: Run-Time Checks. + * Main Program: Running GNAT BIND. + * Mixed Language Programming: Mixed Language Programming. + * Multiple units, syntax checking: Using GNAT COMPILE for Syntax Checking. + * No code generated: Compiling Programs. + * No_Entry_Calls_In_Elaboration_Code: Elaboration Issues for Library Tasks. + * Object file list: Running GNAT BIND. + * Order of elaboration: Elaboration Order Handling in GNAT. + * Other Ada compilers: Calling Conventions. + * Overflow checks <1>: Controlling Run-Time Checks. + * Overflow checks: Run-Time Checks. + * Parallel make: Qualifiers for GNAT MAKE. + * PCA: Profiling. + * Performance: Performance Considerations. + * pragma Elaborate: Controlling the Elaboration Order in Ada 95. + * pragma Elaborate_All: Controlling the Elaboration Order in Ada 95. + * pragma Elaborate_Body: Controlling the Elaboration Order in Ada 95. + * pragma Inline: Inlining of Subprograms. + * pragma Preelaborate: Controlling the Elaboration Order in Ada 95. + * pragma Pure: Controlling the Elaboration Order in Ada 95. + * pragma Suppress: Controlling Run-Time Checks. + * pragma Unsuppress: Controlling Run-Time Checks. + * Pragmas, configuration: Configuration Pragmas. + * Preelaborate: Controlling the Elaboration Order in Ada 95. + * Pure: Controlling the Elaboration Order in Ada 95. + * Recompilation, by GNAT MAKE: Notes on the Command Line. + * Rounding, biased: Output and Error Message Control. + * RTL: Qualifiers for GNAT COMPILE. + * SDP_Table_Build: Running GNAT BIND. + * Search paths, for GNAT MAKE: Qualifiers for GNAT MAKE. + * Shift JIS Coding: Wide Character Encodings. + * Source file, end: Source Representation. + * Source files, suppressing search: Qualifiers for GNAT MAKE. + * Source files, use by binder: Running GNAT BIND. + * Source_File_Name pragma <1>: Alternative File Naming Schemes. + * Source_File_Name pragma: Using Other File Names. + * Source_Reference: Qualifiers for GNAT CHOP. + * Stack Overflow Checking: Stack Overflow Checking. + * stack traceback: Stack Traceback. + * stack unwinding: Stack Traceback. + * Starlet: Bindings. + * Stdcall: Calling Conventions. + * storage, pool, memory corruption: Finding Memory Problems with GNAT Debug Pool. + * Stubbed: Calling Conventions. + * Style checking: Style Checking. + * SUB: Source Representation. + * Subunits: Generating Object Files. + * Suppress <1>: Controlling Run-Time Checks. + * Suppress: Run-Time Checks. + * Suppressing checks: Run-Time Checks. + * SYS$ERROR: Output and Error Message Control. + * SYS$OUTPUT: Output and Error Message Control. + * System <1>: Naming Conventions for GNAT Source Files. + * System: Search Paths for GNAT BIND. + * System.IO: Search Paths and the Run-Time Library (RTL). + * Task switching: Ada Tasks. + * Tasks: Ada Tasks. + * Time Slicing: Run-Time Control. + * Time stamp checks, in binder: Binder Error Message Control. + * traceback: Stack Traceback. + * traceback, non-symbolic: Non-Symbolic Traceback. + * traceback, symbolic: Symbolic Traceback. + * Tree file: Tree Files. + * Typographical conventions: Conventions. + * Unsuppress <1>: Controlling Run-Time Checks. + * Unsuppress: Run-Time Checks. + * Upper-Half Coding: Wide Character Encodings. + * Validity Checking: Validity Checking. + * Version skew (avoided by GNAT MAKE): Running a Simple Ada Program. + * Volatile parameter: The Volatile Parameter. + * VT: Source Representation. + * Warning messages: Output and Error Message Control. + * Warnings: Binder Error Message Control. + * Warnings, treat as error: Output and Error Message Control. + * Win32: Calling Conventions. + * Writing internal trees: Auxiliary Output Control. + * Zero Cost Exceptions: Running GNAT BIND. + + +  + Tag Table: + Node: Top91 + Node: About This Guide10018 + Node: What This Guide Contains10552 + Node: What You Should Know before Reading This Guide14534 + Node: Related Information14942 + Node: Conventions15778 + Node: Getting Started with GNAT16672 + Node: Running GNAT17103 + Node: Running a Simple Ada Program17706 + Node: Running a Program with Multiple Units20867 + Node: Using the GNAT MAKE Utility23127 + Node: Editing with EMACS25541 + Node: The GNAT Compilation Model26705 + Node: Source Representation28044 + Node: Foreign Language Representation29830 + Node: Latin-130316 + Node: Other 8-Bit Codes31182 + Node: Wide Character Encodings33275 + Node: File Naming Rules37081 + Node: Using Other File Names39383 + Node: Alternative File Naming Schemes41312 + Node: Generating Object Files46544 + Node: Source Dependencies49264 + Node: The Ada Library Information Files52818 + Node: Binding an Ada Program54969 + Node: Mixed Language Programming56817 + Node: Interfacing to C57094 + Node: Calling Conventions59703 + Node: Building Mixed Ada & C++ Programs65627 + Node: Interfacing to C++66708 + Node: Linking a Mixed C++ & Ada Program67748 + Node: A Simple Example70834 + Node: Adapting the Run Time to a New C++ Compiler73753 + Node: Comparison between GNAT and C/C++ Compilation Models74769 + Node: Comparison between GNAT and Conventional Ada Library Models76499 + Node: Compiling Using GNAT COMPILE79150 + Node: Compiling Programs79695 + Node: Qualifiers for GNAT COMPILE82587 + Node: Output and Error Message Control91040 + Node: Debugging and Assertion Control109941 + Node: Validity Checking111953 + Node: Style Checking118230 + Node: Run-Time Checks129937 + Node: Stack Overflow Checking134101 + Node: Run-Time Control136223 + Node: Using GNAT COMPILE for Syntax Checking137151 + Node: Using GNAT COMPILE for Semantic Checking138546 + Node: Compiling Ada 83 Programs140045 + Node: Character Set Control141495 + Node: File Naming Control144578 + Node: Subprogram Inlining Control145113 + Node: Auxiliary Output Control146415 + Node: Debugging Control147158 + Node: Units to Sources Mapping Files154485 + Node: Search Paths and the Run-Time Library (RTL)155895 + Node: Order of Compilation Issues159485 + Node: Examples161195 + Node: Binding Using GNAT BIND161813 + Node: Running GNAT BIND163697 + Node: Generating the Binder Program in C194501 + Node: Consistency-Checking Modes211961 + Node: Binder Error Message Control213657 + Node: Elaboration Control215817 + Node: Output Control217089 + Node: Binding with Non-Ada Main Programs219683 + Node: Binding Programs with No Main Subprogram222850 + Node: Summary of Binder Qualifiers223690 + Node: Command-Line Access227327 + Node: Search Paths for GNAT BIND228352 + Node: Examples of GNAT BIND Usage231582 + Node: Linking Using GNAT LINK233202 + Node: Running GNAT LINK233963 + Node: Qualifiers for GNAT LINK236225 + Node: Setting Stack Size from GNAT LINK239051 + Node: Setting Heap Size from GNAT LINK239916 + Node: The GNAT Make Program GNAT MAKE240739 + Node: Running GNAT MAKE242206 + Node: Qualifiers for GNAT MAKE243928 + Node: Mode Qualifiers for GNAT MAKE256184 + Node: Notes on the Command Line257472 + Node: How GNAT MAKE Works260491 + Node: Examples of GNAT MAKE Usage262674 + Node: Renaming Files Using GNAT CHOP263885 + Node: Handling Files with Multiple Units264485 + Node: Operating GNAT CHOP in Compilation Mode265812 + Node: Command Line for GNAT CHOP269150 + Node: Qualifiers for GNAT CHOP270630 + Node: Examples of GNAT CHOP Usage273946 + Node: Configuration Pragmas275348 + Node: Handling of Configuration Pragmas276901 + Node: The Configuration Pragmas Files277762 + Node: Handling Arbitrary File Naming Conventions Using gnatname279476 + Node: Arbitrary File Naming Conventions279886 + Node: Running gnatname281147 + Node: Qualifiers for gnatname282612 + Node: Examples of gnatname Usage285818 + Node: GNAT Project Manager286625 + Node: Introduction287289 + Node: Project Files288399 + Node: Examples of Project Files291623 + Node: Common Sources with Different Qualifiers and Different Output Directories292099 + Node: Source Files295312 + Node: Specifying the Object Directory295790 + Node: Specifying the Exec Directory296724 + Node: Project File Packages297494 + Node: Specifying Qualifier Settings298509 + Node: Main Subprograms300508 + Node: Source File Naming Conventions301179 + Node: Source Language(s)301681 + Node: Using External Variables302124 + Node: Importing Other Projects305029 + Node: Extending a Project308141 + Node: Project File Syntax310612 + Node: Basic Syntax311974 + Node: Packages312982 + Node: Expressions314139 + Node: String Types316037 + Node: Variables317340 + Node: Attributes320374 + Node: Associative Array Attributes325811 + Node: case Constructions326678 + Node: Objects and Sources in Project Files328488 + Node: Object Directory329068 + Node: Exec Directory330059 + Node: Source Directories330888 + Node: Source File Names332255 + Node: Importing Projects334592 + Node: Project Extension337371 + Node: External References in Project Files339052 + Node: Packages in Project Files340798 + Node: Variables from Imported Projects343216 + Node: Naming Schemes344914 + Node: Library Projects348887 + Node: Qualifiers Related to Project Files351785 + Node: Tools Supporting Project Files353515 + Node: GNAT MAKE and Project Files353822 + Node: Qualifiers and Project Files354284 + Node: Project Files and Main Subprograms360359 + Node: The GNAT Driver and Project Files362307 + Node: An Extended Example366047 + Node: Project File Complete Syntax369061 + Node: Elaboration Order Handling in GNAT371853 + Node: Elaboration Code in Ada 95372875 + Node: Checking the Elaboration Order in Ada 95377521 + Node: Controlling the Elaboration Order in Ada 95381522 + Node: Controlling Elaboration in GNAT - Internal Calls389839 + Node: Controlling Elaboration in GNAT - External Calls395560 + Node: Default Behavior in GNAT - Ensuring Safety399294 + Node: Elaboration Issues for Library Tasks403437 + Node: Mixing Elaboration Models416674 + Node: What to Do If the Default Elaboration Behavior Fails419195 + Node: Elaboration for Access-to-Subprogram Values429621 + Node: Summary of Procedures for Elaboration Control431445 + Node: Other Elaboration Order Considerations432643 + Node: The Cross-Referencing Tools GNAT XREF and GNAT FIND437918 + Node: GNAT XREF Qualifiers439632 + Node: GNAT FIND Qualifiers443016 + Node: Project Files for GNAT XREF and GNAT FIND448925 + Node: Regular Expressions in GNAT FIND and GNAT XREF452170 + Node: Examples of GNAT XREF Usage454961 + Node: Examples of GNAT FIND Usage458166 + Node: File Name Krunching Using GNAT KRUNCH460453 + Node: About GNAT KRUNCH461111 + Node: Using GNAT KRUNCH462488 + Node: Krunching Method463387 + Node: Examples of GNAT KRUNCH Usage466658 + Node: Preprocessing Using GNAT PREPROCESS467002 + Node: Using GNAT PREPROCESS467584 + Node: Qualifiers for GNAT PREPROCESS468494 + Node: Form of Definitions File470717 + Node: Form of Input Text for GNAT PREPROCESS471479 + Node: The GNAT Run-Time Library Builder GNAT LIBRARY475135 + Node: Running GNAT LIBRARY475615 + Node: Qualifiers for GNAT LIBRARY475918 + Node: Examples of GNAT LIBRARY Usage476711 + Node: The GNAT Library Browser GNAT LIST477154 + Node: Running GNAT LIST477750 + Node: Qualifiers for GNAT LIST480303 + Node: Examples of GNAT LIST Usage482391 + Node: Finding Memory Problems with GNAT Debug Pool483626 + Node: Creating Sample Bodies Using GNAT STUB488329 + Node: Running GNAT STUB489138 + Node: Qualifiers for GNAT STUB489907 + Node: Reducing the Size of Ada Executables with GNAT ELIM492220 + Node: About GNAT ELIM492761 + Node: Eliminate Pragma493856 + Node: Tree Files494867 + Node: Preparing Tree and Bind Files for GNAT ELIM495786 + Node: Running GNAT ELIM497885 + Node: Correcting the List of Eliminate Pragmas499895 + Node: Making Your Executables Smaller500679 + Node: Summary of the GNAT ELIM Usage Cycle501531 + Node: Other Utility Programs502403 + Node: Using Other Utility Programs with GNAT502951 + Node: The GNAT STANDARD Utility Program503406 + Node: The External Symbol Naming Scheme of GNAT504728 + Node: Ada Mode for Glide506730 + Node: Converting Ada Files to html with gnathtml508681 + Node: Installing gnathtml512289 + Node: LSE512967 + Node: Profiling513298 + Node: Running and Debugging Ada Programs513716 + Node: The GNAT Debugger GDB515114 + Node: Running GDB518288 + Node: Introduction to GDB Commands519225 + Node: Using Ada Expressions524129 + Node: Calling User-Defined Subprograms525323 + Node: Using the Next Command in a Function527743 + Node: Ada Exceptions528908 + Node: Ada Tasks529862 + Node: Debugging Generic Units531931 + Node: GNAT Abnormal Termination or Failure to Terminate533334 + Node: Naming Conventions for GNAT Source Files536027 + Node: Getting Internal Debugging Information538627 + Node: Stack Traceback539836 + Node: Non-Symbolic Traceback540873 + Node: Tracebacks From an Unhandled Exception541334 + Node: Tracebacks From Exception Occurrences (non-symbolic)545299 + Node: Tracebacks From Anywhere in a Program (non-symbolic)546582 + Node: Symbolic Traceback548427 + Node: Tracebacks From Exception Occurrences (symbolic)549150 + Node: Tracebacks From Anywhere in a Program (symbolic)550608 + Node: Compatibility with DEC Ada551800 + Node: Ada 95 Compatibility553349 + Node: Differences in the Definition of Package System554418 + Node: Language-Related Features556528 + Node: Integer Types and Representations557161 + Node: Floating-Point Types and Representations558105 + Node: Pragmas Float_Representation and Long_Float559410 + Node: Fixed-Point Types and Representations562749 + Node: Record and Array Component Alignment563385 + Node: Address Clauses564059 + Node: Other Representation Clauses566091 + Node: The Package STANDARD566491 + Node: The Package SYSTEM567381 + Node: Tasking and Task-Related Features571413 + Node: Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems571977 + Node: Assigning Task IDs573463 + Node: Task IDs and Delays574153 + Node: Task-Related Pragmas574726 + Node: Scheduling and Task Priority575823 + Node: The Task Stack577520 + Node: External Interrupts578434 + Node: Pragmas and Pragma-Related Features578761 + Node: Restrictions on the Pragma INLINE581053 + Node: Restrictions on the Pragma INTERFACE582210 + Node: Restrictions on the Pragma SYSTEM_NAME583212 + Node: Library of Predefined Units583613 + Node: Changes to DECLIB585444 + Node: Bindings586211 + Node: Shared Libraries and Options Files588020 + Node: Interfaces to C588739 + Node: Main Program Definition589595 + Node: Implementation-Defined Attributes590900 + Node: Compiler and Run-Time Interfacing591206 + Node: Program Compilation and Library Management592552 + Node: Input-Output603017 + Node: Implementation Limits605634 + Node: Tools607701 + Node: Inline Assembler607817 + Node: Basic Assembler Syntax609524 + Node: A Simple Example of Inline Assembler611404 + Node: Output Variables in Inline Assembler614615 + Node: Input Variables in Inline Assembler622004 + Node: Inlining Inline Assembler Code624522 + Node: Other Asm Functionality626480 + Node: The Clobber Parameter626915 + Node: The Volatile Parameter628914 + Node: A Complete Example630106 + Node: Check_CPU Procedure631080 + Node: Intel_CPU Package Specification646127 + Node: Intel_CPU Package Body655555 + Node: Performance Considerations664713 + Node: Controlling Run-Time Checks665769 + Node: Optimization Levels667799 + Node: Debugging Optimized Code669699 + Node: Inlining of Subprograms673435 + Node: Coverage Analysis677260 + Node: GNU Free Documentation License677606 + Node: Index700035 +  + End Tag Table diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_ug_vms.texi gcc-3.3/gcc/ada/gnat_ug_vms.texi *** gcc-3.2.3/gcc/ada/gnat_ug_vms.texi 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_ug_vms.texi 2003-05-14 00:31:41.000000000 +0000 *************** *** 0 **** --- 1,19069 ---- + \input texinfo @c -*-texinfo-*- + @c %**start of header + + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + @c o + @c GNAT DOCUMENTATION o + @c o + @c G N A T _ U G o + @c o + @c Copyright (C) 1992-2002 Ada Core Technologies, Inc. o + @c o + @c GNAT is free software; you can redistribute it and/or modify it under o + @c terms of the GNU General Public License as published by the Free Soft- o + @c ware Foundation; either version 2, or (at your option) any later ver- o + @c sion. GNAT is distributed in the hope that it will be useful, but WITH- o + @c OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY o + @c or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License o + @c for more details. You should have received a copy of the GNU General o + @c Public License distributed with GNAT; see file COPYING. If not, write o + @c to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, o + @c MA 02111-1307, USA. o + @c o + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + @c + @c GNAT_UG Style Guide + @c + @c 1. Always put a @noindent on the line before the first paragraph + @c after any of these commands: + @c + @c @chapter + @c @section + @c @subsection + @c @subsubsection + @c @subsubsubsection + @c + @c @end smallexample + @c @end itemize + @c @end enumerate + @c + @c 2. DO NOT use @example. Use @smallexample instead. + @c + @c 3. Each @chapter, @section, @subsection, @subsubsection, etc. + @c command must be preceded by two empty lines + @c + @c 4. The @item command must be on a line of its own if it is in an + @c @itemize or @enumerate command. + @c + @c 5. When talking about ALI files use "ALI" (all uppercase), not "Ali" + @c or "ali". + @c + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + + @setfilename gnat_ug_vms.info + @settitle GNAT User's Guide for OpenVMS Alpha + + + + + @include gcc-common.texi + + @setchapternewpage odd + @syncodeindex fn cp + @c %**end of header + + @copying + Copyright @copyright{} 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with the Invariant Sections being ``GNU Free Documentation License'', with the + Front-Cover Texts being + ``GNAT User's Guide for OpenVMS Alpha'', + and with no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + @end copying + + @titlepage + + @title GNAT User's Guide + @center @titlefont{for OpenVMS Alpha} + + + + + @subtitle GNAT, The GNU Ada 95 Compiler + @subtitle GNAT Version for GCC @value{version-GCC} + + @author Ada Core Technologies, Inc. + + @page + @vskip 0pt plus 1filll + + @insertcopying + + @end titlepage + + @ifnottex + @node Top, About This Guide, (dir), (dir) + @top GNAT User's Guide + + GNAT User's Guide for OpenVMS Alpha + + + + + GNAT, The GNU Ada 95 Compiler + + GNAT Version for GCC @value{version-GCC} + + Ada Core Technologies, Inc. + + @insertcopying + + @menu + * About This Guide:: + * Getting Started with GNAT:: + * The GNAT Compilation Model:: + * Compiling Using GNAT COMPILE:: + * Binding Using GNAT BIND:: + * Linking Using GNAT LINK:: + * The GNAT Make Program GNAT MAKE:: + * Renaming Files Using GNAT CHOP:: + * Configuration Pragmas:: + * Handling Arbitrary File Naming Conventions Using gnatname:: + * GNAT Project Manager:: + * Elaboration Order Handling in GNAT:: + * The Cross-Referencing Tools GNAT XREF and GNAT FIND:: + * File Name Krunching Using GNAT KRUNCH:: + * Preprocessing Using GNAT PREPROCESS:: + * The GNAT Run-Time Library Builder GNAT LIBRARY:: + * The GNAT Library Browser GNAT LIST:: + * Finding Memory Problems with GNAT Debug Pool:: + * Creating Sample Bodies Using GNAT STUB:: + * Reducing the Size of Ada Executables with GNAT ELIM:: + * Other Utility Programs:: + * Compatibility with DEC Ada:: + * Running and Debugging Ada Programs:: + * Inline Assembler:: + * Performance Considerations:: + * GNU Free Documentation License:: + * Index:: + + --- The Detailed Node Listing --- + + About This Guide + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + + + Getting Started with GNAT + + * Running GNAT:: + * Running a Simple Ada Program:: + * Running a Program with Multiple Units:: + * Using the GNAT MAKE Utility:: + * Editing with EMACS:: + + The GNAT Compilation Model + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + Foreign Language Representation + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + + Compiling Ada Programs With GNAT COMPILE + + * Compiling Programs:: + * Qualifiers for GNAT COMPILE:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + + Qualifiers for GNAT COMPILE + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using GNAT COMPILE for Syntax Checking:: + * Using GNAT COMPILE for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + Binding Ada Programs With GNAT BIND + + * Running GNAT BIND:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Qualifiers:: + * Command-Line Access:: + * Search Paths for GNAT BIND:: + * Examples of GNAT BIND Usage:: + + Linking Using GNAT LINK + + * Running GNAT LINK:: + * Qualifiers for GNAT LINK:: + * Setting Stack Size from GNAT LINK:: + * Setting Heap Size from GNAT LINK:: + + The GNAT Make Program GNAT MAKE + + * Running GNAT MAKE:: + * Qualifiers for GNAT MAKE:: + * Mode Qualifiers for GNAT MAKE:: + * Notes on the Command Line:: + * How GNAT MAKE Works:: + * Examples of GNAT MAKE Usage:: + + Renaming Files Using GNAT CHOP + + * Handling Files with Multiple Units:: + * Operating GNAT CHOP in Compilation Mode:: + * Command Line for GNAT CHOP:: + * Qualifiers for GNAT CHOP:: + * Examples of GNAT CHOP Usage:: + + Configuration Pragmas + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + + Handling Arbitrary File Naming Conventions Using gnatname + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Qualifiers for gnatname:: + * Examples of gnatname Usage:: + + GNAT Project Manager + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Qualifiers Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + + Elaboration Order Handling in GNAT + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + The Cross-Referencing Tools GNAT XREF and GNAT FIND + + * GNAT XREF Qualifiers:: + * GNAT FIND Qualifiers:: + * Project Files for GNAT XREF and GNAT FIND:: + * Regular Expressions in GNAT FIND and GNAT XREF:: + * Examples of GNAT XREF Usage:: + * Examples of GNAT FIND Usage:: + + File Name Krunching Using GNAT KRUNCH + + * About GNAT KRUNCH:: + * Using GNAT KRUNCH:: + * Krunching Method:: + * Examples of GNAT KRUNCH Usage:: + + Preprocessing Using GNAT PREPROCESS + + * Using GNAT PREPROCESS:: + * Qualifiers for GNAT PREPROCESS:: + * Form of Definitions File:: + * Form of Input Text for GNAT PREPROCESS:: + + The GNAT Run-Time Library Builder GNAT LIBRARY + + * Running GNAT LIBRARY:: + * Qualifiers for GNAT LIBRARY:: + * Examples of GNAT LIBRARY Usage:: + + The GNAT Library Browser GNAT LIST + + * Running GNAT LIST:: + * Qualifiers for GNAT LIST:: + * Examples of GNAT LIST Usage:: + + + Finding Memory Problems with GNAT Debug Pool + + Creating Sample Bodies Using GNAT STUB + + * Running GNAT STUB:: + * Qualifiers for GNAT STUB:: + + Reducing the Size of Ada Executables with GNAT ELIM + + * About GNAT ELIM:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for GNAT ELIM:: + * Running GNAT ELIM:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the GNAT ELIM Usage Cycle:: + + Other Utility Programs + + * Using Other Utility Programs with GNAT:: + * The GNAT STANDARD Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * LSE:: + + Compatibility with DEC Ada + + * Ada 95 Compatibility:: + * Differences in the Definition of Package System:: + * Language-Related Features:: + * The Package STANDARD:: + * The Package SYSTEM:: + * Tasking and Task-Related Features:: + * Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems:: + * Pragmas and Pragma-Related Features:: + * Library of Predefined Units:: + * Bindings:: + * Main Program Definition:: + * Implementation-Defined Attributes:: + * Compiler and Run-Time Interfacing:: + * Program Compilation and Library Management:: + * Input-Output:: + * Implementation Limits:: + * Tools:: + + Language-Related Features + + * Integer Types and Representations:: + * Floating-Point Types and Representations:: + * Pragmas Float_Representation and Long_Float:: + * Fixed-Point Types and Representations:: + * Record and Array Component Alignment:: + * Address Clauses:: + * Other Representation Clauses:: + + Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + + * Assigning Task IDs:: + * Task IDs and Delays:: + * Task-Related Pragmas:: + * Scheduling and Task Priority:: + * The Task Stack:: + * External Interrupts:: + + Pragmas and Pragma-Related Features + + * Restrictions on the Pragma INLINE:: + * Restrictions on the Pragma INTERFACE:: + * Restrictions on the Pragma SYSTEM_NAME:: + + Library of Predefined Units + + * Changes to DECLIB:: + + Bindings + + * Shared Libraries and Options Files:: + * Interfaces to C:: + + Running and Debugging Ada Programs + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + + Inline Assembler + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + + + + Performance Considerations + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + * Coverage Analysis:: + + * Index:: + @end menu + @end ifnottex + + @node About This Guide + @unnumbered About This Guide + + @noindent + This guide describes the use of of GNAT, a full language compiler for the Ada + 95 programming language, implemented on DIGITAL OpenVMS Alpha Systems. + It describes the features of the compiler and tools, and details + how to use them to build Ada 95 applications. + + @menu + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + @end menu + + @node What This Guide Contains + @unnumberedsec What This Guide Contains + + @noindent + This guide contains the following chapters: + @itemize @bullet + @item + @ref{Getting Started with GNAT}, describes how to get started compiling + and running Ada programs with the GNAT Ada programming environment. + @item + @ref{The GNAT Compilation Model}, describes the compilation model used + by GNAT. + @item + @ref{Compiling Using GNAT COMPILE}, describes how to compile + Ada programs with @code{GNAT COMPILE}, the Ada compiler. + @item + @ref{Binding Using GNAT BIND}, describes how to + perform binding of Ada programs with @code{GNAT BIND}, the GNAT binding + utility. + @item + @ref{Linking Using GNAT LINK}, + describes @code{GNAT LINK}, a + program that provides for linking using the GNAT run-time library to + construct a program. @code{GNAT LINK} can also incorporate foreign language + object units into the executable. + @item + @ref{The GNAT Make Program GNAT MAKE}, describes @code{GNAT MAKE}, a + utility that automatically determines the set of sources + needed by an Ada compilation unit, and executes the necessary compilations + binding and link. + @item + @ref{Renaming Files Using GNAT CHOP}, describes + @code{GNAT CHOP}, a utility that allows you to preprocess a file that + contains Ada source code, and split it into one or more new files, one + for each compilation unit. + @item + @ref{Configuration Pragmas}, describes the configuration pragmas handled by GNAT. + @item + @ref{Handling Arbitrary File Naming Conventions Using gnatname}, shows how to override + the default GNAT file naming conventions, either for an individual unit or globally. + @item + @ref{GNAT Project Manager}, describes how to use project files to organize large projects. + @item + @ref{Elaboration Order Handling in GNAT}, describes how GNAT helps you deal with + elaboration order issues. + @item + @ref{The Cross-Referencing Tools GNAT XREF and GNAT FIND}, discusses + @code{GNAT XREF} and @code{GNAT FIND}, two tools that provide an easy + way to navigate through sources. + @item + @ref{File Name Krunching Using GNAT KRUNCH}, describes the @code{GNAT KRUNCH} + file name krunching utility, used to handle shortened + file names on operating systems with a limit on the length of names. + @item + @ref{Preprocessing Using GNAT PREPROCESS}, describes @code{GNAT PREPROCESS}, a + preprocessor utility that allows a single source file to be used to + generate multiple or parameterized source files, by means of macro + substitution. + @item + @ref{The GNAT Library Browser GNAT LIST}, describes @code{GNAT LIST}, a + utility that displays information about compiled units, including dependences + on the corresponding sources files, and consistency of compilations. + @item + @ref{Finding Memory Problems with GNAT Debug Pool}, describes how to + use the GNAT-specific Debug Pool in order to detect as early as possible + the use of incorrect memory references. + + @item + @ref{Creating Sample Bodies Using GNAT STUB}, discusses @code{GNAT STUB}, + a utility that generates empty but compilable bodies for library units. + + @item + @ref{Reducing the Size of Ada Executables with GNAT ELIM}, describes + @code{GNAT ELIM}, a tool which detects unused subprograms and helps + the compiler to create a smaller executable for the program. + + @item + @ref{Other Utility Programs}, discusses several other GNAT utilities, + including @code{GNAT STANDARD}. + + @item + @ref{Running and Debugging Ada Programs}, describes how to run and debug + Ada programs. + + @item + @ref{Inline Assembler}, shows how to use the inline assembly facility in an Ada program. + + + @item + @ref{Performance Considerations}, reviews the trade offs between using + defaults or options in program development. + @item + @ref{Compatibility with DEC Ada}, details the compatibility of GNAT with + DEC Ada 83 for OpenVMS Alpha. + @end itemize + + @node What You Should Know before Reading This Guide + @unnumberedsec What You Should Know before Reading This Guide + + @cindex Ada 95 Language Reference Manual + @noindent + This user's guide assumes that you are familiar with Ada 95 language, as + described in the International Standard ANSI/ISO/IEC-8652:1995, Jan + 1995. + + @node Related Information + @unnumberedsec Related Information + + @noindent + For further information about related tools, refer to the following + documents: + + @itemize @bullet + @item + @cite{GNAT Reference Manual}, which contains all reference + material for the GNAT implementation of Ada 95. + + @item + @cite{Ada 95 Language Reference Manual}, which contains all reference + material for the Ada 95 programming language. + + @item + @cite{Debugging with GDB} + , located in the GNU:[DOCS] directory, + contains all details on the use of the GNU source-level debugger. + + @item + @cite{GNU EMACS Manual} + , located in the GNU:[DOCS] directory if the EMACS kit is installed, + contains full information on the extensible editor and programming + environment EMACS. + + @end itemize + + @node Conventions + @unnumberedsec Conventions + @cindex Conventions + @cindex Typographical conventions + + @noindent + Following are examples of the typographical and graphic conventions used + in this guide: + + @itemize @bullet + @item + @code{Functions}, @code{utility program names}, @code{standard names}, + and @code{classes}. + + @item + @samp{Option flags} + + @item + @file{File Names}, @file{button names}, and @file{field names}. + + @item + @var{Variables}. + + @item + @emph{Emphasis}. + + @item + [optional information or parameters] + + @item + Examples are described by text + @smallexample + and then shown this way. + @end smallexample + @end itemize + + @noindent + Commands that are entered by the user are preceded in this manual by the + characters @w{"@code{$ }"} (dollar sign followed by space). If your system + uses this sequence as a prompt, then the commands will appear exactly as + you see them in the manual. If your system uses some other prompt, then + the command will appear with the @code{$} replaced by whatever prompt + character you are using. + + + @node Getting Started with GNAT + @chapter Getting Started with GNAT + + @noindent + This chapter describes some simple ways of using GNAT to build + executable Ada programs. + + @menu + * Running GNAT:: + * Running a Simple Ada Program:: + + * Running a Program with Multiple Units:: + + * Using the GNAT MAKE Utility:: + * Editing with EMACS:: + @end menu + + @node Running GNAT + @section Running GNAT + + @noindent + Three steps are needed to create an executable file from an Ada source + file: + + @enumerate + @item + The source file(s) must be compiled. + @item + The file(s) must be bound using the GNAT binder. + @item + All appropriate object files must be linked to produce an executable. + @end enumerate + + @noindent + All three steps are most commonly handled by using the @code{GNAT MAKE} + utility program that, given the name of the main program, automatically + performs the necessary compilation, binding and linking steps. + + @node Running a Simple Ada Program + @section Running a Simple Ada Program + + @noindent + Any text editor may be used to prepare an Ada program. If @code{Glide} is + used, the optional Ada mode may be helpful in laying out the program. The + program text is a normal text file. We will suppose in our initial + example that you have used your editor to prepare the following + standard format text file: + + @smallexample + @group + @cartouche + @b{with} Ada.Text_IO; @b{use} Ada.Text_IO; + @b{procedure} Hello @b{is} + @b{begin} + Put_Line ("Hello WORLD!"); + @b{end} Hello; + @end cartouche + @end group + @end smallexample + + @noindent + This file should be named @file{HELLO.ADB}. + With the normal default file naming conventions, GNAT requires + that each file + contain a single compilation unit whose file name is the + unit name, + with periods replaced by hyphens; the + extension is @file{ads} for a + spec and @file{adb} for a body. + You can override this default file naming convention by use of the + special pragma @code{Source_File_Name} (@pxref{Using Other File Names}). + Alternatively, if you want to rename your files according to this default + convention, which is probably more convenient if you will be using GNAT + for all your compilations, then the @code{GNAT CHOP} utility + can be used to generate correctly-named source files + (@pxref{Renaming Files Using GNAT CHOP}). + + You can compile the program using the following command (@code{$} is used + as the command prompt in the examples in this document): + + @smallexample + $ GNAT COMPILE HELLO.ADB + @end smallexample + + + @noindent + @code{GNAT COMPILE} is the command used to run the compiler. This compiler is + capable of compiling programs in several languages, including Ada 95 and + C. It assumes that you have given it an Ada program if the file extension is + either @file{.ADS} or @file{.ADB}, and it will then call the GNAT compiler to compile + the specified file. + + + This compile command generates a file + @file{HELLO.OBJ}, which is the object + file corresponding to your Ada program. It also generates an "Ada Library Information" file + @file{HELLO.ALI}, + which contains additional information used to check + that an Ada program is consistent. + To build an executable file, + use @code{GNAT BIND} to bind the program + and @code{GNAT LINK} to link it. The + argument to both @code{GNAT BIND} and @code{GNAT LINK} is the name of the + @file{ali} file, but the default extension of @file{.ALI} can + be omitted. This means that in the most common case, the argument + is simply the name of the main program: + + @smallexample + $ GNAT BIND hello + $ GNAT LINK hello + @end smallexample + + + @noindent + A simpler method of carrying out these steps is to use + @command{GNAT MAKE}, + a master program that invokes all the required + compilation, binding and linking tools in the correct order. In particular, + @command{GNAT MAKE} automatically recompiles any sources that have been modified + since they were last compiled, or sources that depend + on such modified sources, so that "version skew" is avoided. + @cindex Version skew (avoided by @command{GNAT MAKE}) + + @smallexample + $ GNAT MAKE HELLO.ADB + @end smallexample + + + @noindent + The result is an executable program called @file{hello}, which can be + run by entering: + + @c The following should be removed (BMB 2001-01-23) + @c @smallexample + @c $ $ RUN HELLO + @c @end smallexample + + @smallexample + $ hello + @end smallexample + + @noindent + assuming that the current directory is on the search path for executable programs. + + @noindent + and, if all has gone well, you will see + + @smallexample + Hello WORLD! + @end smallexample + + @noindent + appear in response to this command. + + + + + @node Running a Program with Multiple Units + @section Running a Program with Multiple Units + + @noindent + Consider a slightly more complicated example that has three files: a + main program, and the spec and body of a package: + + @smallexample + @cartouche + @group + @b{package} Greetings @b{is} + @b{procedure} Hello; + @b{procedure} Goodbye; + @b{end} Greetings; + + @b{with} Ada.Text_IO; @b{use} Ada.Text_IO; + @b{package} @b{body} Greetings @b{is} + @b{procedure} Hello @b{is} + @b{begin} + Put_Line ("Hello WORLD!"); + @b{end} Hello; + + @b{procedure} Goodbye @b{is} + @b{begin} + Put_Line ("Goodbye WORLD!"); + @b{end} Goodbye; + @b{end} Greetings; + @end group + + @group + @b{with} Greetings; + @b{procedure} Gmain @b{is} + @b{begin} + Greetings.Hello; + Greetings.Goodbye; + @b{end} Gmain; + @end group + @end cartouche + @end smallexample + + @noindent + Following the one-unit-per-file rule, place this program in the + following three separate files: + + @table @file + @item GREETINGS.ADS + spec of package @code{Greetings} + + @item GREETINGS.ADB + body of package @code{Greetings} + + @item GMAIN.ADB + body of main program + @end table + + @noindent + To build an executable version of + this program, we could use four separate steps to compile, bind, and link + the program, as follows: + + @smallexample + $ GNAT COMPILE GMAIN.ADB + $ GNAT COMPILE GREETINGS.ADB + $ GNAT BIND gmain + $ GNAT LINK gmain + @end smallexample + + + @noindent + Note that there is no required order of compilation when using GNAT. + In particular it is perfectly fine to compile the main program first. + Also, it is not necessary to compile package specs in the case where + there is an accompanying body; you only need to compile the body. If you want + to submit these files to the compiler for semantic checking and not code generation, + then use the + @option{/NOLOAD} qualifier: + + @smallexample + $ GNAT COMPILE GREETINGS.ADS /NOLOAD + @end smallexample + + + @noindent + Although the compilation can be done in separate steps as in the + above example, in practice it is almost always more convenient + to use the @code{GNAT MAKE} tool. All you need to know in this case + is the name of the main program's source file. The effect of the above four + commands can be achieved with a single one: + + @smallexample + $ GNAT MAKE GMAIN.ADB + @end smallexample + + + @noindent + In the next section we discuss the advantages of using @code{GNAT MAKE} in + more detail. + + @node Using the GNAT MAKE Utility + @section Using the @command{GNAT MAKE} Utility + + @noindent + If you work on a program by compiling single components at a time using + @code{GNAT COMPILE}, you typically keep track of the units you modify. In order to + build a consistent system, you compile not only these units, but also any + units that depend on the units you have modified. + For example, in the preceding case, + if you edit @file{GMAIN.ADB}, you only need to recompile that file. But if + you edit @file{GREETINGS.ADS}, you must recompile both + @file{GREETINGS.ADB} and @file{GMAIN.ADB}, because both files contain + units that depend on @file{GREETINGS.ADS}. + + @code{GNAT BIND} will warn you if you forget one of these compilation + steps, so that it is impossible to generate an inconsistent program as a + result of forgetting to do a compilation. Nevertheless it is tedious and + error-prone to keep track of dependencies among units. + One approach to handle the dependency-bookkeeping is to use a + makefile. However, makefiles present maintenance problems of their own: + if the dependencies change as you change the program, you must make + sure that the makefile is kept up-to-date manually, which is also an + error-prone process. + + The @code{GNAT MAKE} utility takes care of these details automatically. + Invoke it using either one of the following forms: + + @smallexample + $ GNAT MAKE GMAIN.ADB + $ GNAT MAKE GMAIN + @end smallexample + + + @noindent + The argument is the name of the file containing the main program; + you may omit the extension. @code{GNAT MAKE} + examines the environment, automatically recompiles any files that need + recompiling, and binds and links the resulting set of object files, + generating the executable file, @file{GMAIN.EXE}. + In a large program, it + can be extremely helpful to use @code{GNAT MAKE}, because working out by hand + what needs to be recompiled can be difficult. + + Note that @code{GNAT MAKE} + takes into account all the Ada 95 rules that + establish dependencies among units. These include dependencies that result + from inlining subprogram bodies, and from + generic instantiation. Unlike some other + Ada make tools, @code{GNAT MAKE} does not rely on the dependencies that were + found by the compiler on a previous compilation, which may possibly + be wrong when sources change. @code{GNAT MAKE} determines the exact set of + dependencies from scratch each time it is run. + + @node Editing with EMACS + @section Editing with EMACS + @cindex EMACS + + @noindent + EMACS is an extensible self-documenting text editor that is available in a + separate VMSINSTAL kit. + + Invoke EMACS by typing "EMACS" at the command prompt. To get started, + click on the EMACS Help menu and run the EMACS Tutorial. + In a character cell terminal, EMACS help is invoked with "Ctrl-h" (also written + as "C-h"), and the tutorial by "C-h t". + + Documentation on EMACS and other tools is available in EMACS under the + pull-down menu button: Help - Info. After selecting Info, use the middle + mouse button to select a topic (e.g. EMACS). + + In a character cell terminal, do "C-h i" to invoke info, and then "m" + (stands for menu) followed by the menu item desired, as in "m EMACS", to get + to the EMACS manual. + Help on EMACS is also available by typing "HELP EMACS" at the DCL command + prompt. + + The tutorial is highly recommended in order to learn the intricacies of EMACS, + which is sufficiently extensible to provide for a complete programming + environment and shell for the sophisticated user. + + + @node The GNAT Compilation Model + @chapter The GNAT Compilation Model + @cindex GNAT compilation model + @cindex Compilation model + + @menu + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + @end menu + + @noindent + This chapter describes the compilation model used by GNAT. Although + similar to that used by other languages, such as C and C++, this model + is substantially different from the traditional Ada compilation models, + which are based on a library. The model is initially described without + reference to the library-based model. If you have not previously used an + Ada compiler, you need only read the first part of this chapter. The + last section describes and discusses the differences between the GNAT + model and the traditional Ada compiler models. If you have used other + Ada compilers, this section will help you to understand those + differences, and the advantages of the GNAT model. + + @node Source Representation + @section Source Representation + @cindex Latin-1 + + @noindent + Ada source programs are represented in standard text files, using + Latin-1 coding. Latin-1 is an 8-bit code that includes the familiar + 7-bit ASCII set, plus additional characters used for + representing foreign languages (@pxref{Foreign Language Representation} + for support of non-USA character sets). The format effector characters + are represented using their standard ASCII encodings, as follows: + + @table @code + @item VT + @findex VT + Vertical tab, @code{16#0B#} + + @item HT + @findex HT + Horizontal tab, @code{16#09#} + + @item CR + @findex CR + Carriage return, @code{16#0D#} + + @item LF + @findex LF + Line feed, @code{16#0A#} + + @item FF + @findex FF + Form feed, @code{16#0C#} + @end table + + @noindent + Source files are in standard text file format. In addition, GNAT will + recognize a wide variety of stream formats, in which the end of physical + physical lines is marked by any of the following sequences: + @code{LF}, @code{CR}, @code{CR-LF}, or @code{LF-CR}. This is useful + in accommodating files that are imported from other operating systems. + + @cindex End of source file + @cindex Source file, end + @findex SUB + The end of a source file is normally represented by the physical end of + file. However, the control character @code{16#1A#} (@code{SUB}) is also + recognized as signalling the end of the source file. Again, this is + provided for compatibility with other operating systems where this + code is used to represent the end of file. + + Each file contains a single Ada compilation unit, including any pragmas + associated with the unit. For example, this means you must place a + package declaration (a package @dfn{spec}) and the corresponding body in + separate files. An Ada @dfn{compilation} (which is a sequence of + compilation units) is represented using a sequence of files. Similarly, + you will place each subunit or child unit in a separate file. + + @node Foreign Language Representation + @section Foreign Language Representation + + @noindent + GNAT supports the standard character sets defined in Ada 95 as well as + several other non-standard character sets for use in localized versions + of the compiler (@pxref{Character Set Control}). + @menu + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + @end menu + + @node Latin-1 + @subsection Latin-1 + @cindex Latin-1 + + @noindent + The basic character set is Latin-1. This character set is defined by ISO + standard 8859, part 1. The lower half (character codes @code{16#00#} + ... @code{16#7F#)} is identical to standard ASCII coding, but the upper half is + used to represent additional characters. These include extended letters + used by European languages, such as French accents, the vowels with umlauts + used in German, and the extra letter A-ring used in Swedish. + + @findex Ada.Characters.Latin_1 + For a complete list of Latin-1 codes and their encodings, see the source + file of library unit @code{Ada.Characters.Latin_1} in file + @file{A-CHLAT1.ADS}. + You may use any of these extended characters freely in character or + string literals. In addition, the extended characters that represent + letters can be used in identifiers. + + @node Other 8-Bit Codes + @subsection Other 8-Bit Codes + + @noindent + GNAT also supports several other 8-bit coding schemes: + + @table @asis + @cindex Latin-2 + @item Latin-2 + Latin-2 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-3 + @cindex Latin-3 + Latin-3 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-4 + @cindex Latin-4 + Latin-4 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-5 + @cindex Latin-5 + @cindex Cyrillic + Latin-4 letters (Cyrillic) allowed in identifiers, with uppercase and lowercase + equivalence. + + @item IBM PC (code page 437) + @cindex code page 437 + This code page is the normal default for PCs in the U.S. It corresponds + to the original IBM PC character set. This set has some, but not all, of + the extended Latin-1 letters, but these letters do not have the same + encoding as Latin-1. In this mode, these letters are allowed in + identifiers with uppercase and lowercase equivalence. + + @item IBM PC (code page 850) + @cindex code page 850 + This code page is a modification of 437 extended to include all the + Latin-1 letters, but still not with the usual Latin-1 encoding. In this + mode, all these letters are allowed in identifiers with uppercase and + lowercase equivalence. + + @item Full Upper 8-bit + Any character in the range 80-FF allowed in identifiers, and all are + considered distinct. In other words, there are no uppercase and lowercase + equivalences in this range. This is useful in conjunction with + certain encoding schemes used for some foreign character sets (e.g. + the typical method of representing Chinese characters on the PC). + + @item No Upper-Half + No upper-half characters in the range 80-FF are allowed in identifiers. + This gives Ada 83 compatibility for identifier names. + @end table + + @noindent + For precise data on the encodings permitted, and the uppercase and lowercase + equivalences that are recognized, see the file @file{CSETS.ADB} in + the GNAT compiler sources. You will need to obtain a full source release + of GNAT to obtain this file. + + @node Wide Character Encodings + @subsection Wide Character Encodings + + @noindent + GNAT allows wide character codes to appear in character and string + literals, and also optionally in identifiers, by means of the following + possible encoding schemes: + + @table @asis + + @item Hex Coding + In this encoding, a wide character is represented by the following five + character sequence: + + @smallexample + ESC a b c d + @end smallexample + + @noindent + Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal + characters (using uppercase letters) of the wide character code. For + example, ESC A345 is used to represent the wide character with code + @code{16#A345#}. + This scheme is compatible with use of the full Wide_Character set. + + @item Upper-Half Coding + @cindex Upper-Half Coding + The wide character with encoding @code{16#abcd#} where the upper bit is on (in + other words, "a" is in the range 8-F) is represented as two bytes, + @code{16#ab#} and @code{16#cd#}. The second byte cannot be a format control + character, but is not required to be in the upper half. This method can + be also used for shift-JIS or EUC, where the internal coding matches the + external coding. + + @item Shift JIS Coding + @cindex Shift JIS Coding + A wide character is represented by a two-character sequence, + @code{16#ab#} and + @code{16#cd#}, with the restrictions described for upper-half encoding as + described above. The internal character code is the corresponding JIS + character according to the standard algorithm for Shift-JIS + conversion. Only characters defined in the JIS code set table can be + used with this encoding method. + + @item EUC Coding + @cindex EUC Coding + A wide character is represented by a two-character sequence + @code{16#ab#} and + @code{16#cd#}, with both characters being in the upper half. The internal + character code is the corresponding JIS character according to the EUC + encoding algorithm. Only characters defined in the JIS code set table + can be used with this encoding method. + + @item UTF-8 Coding + A wide character is represented using + UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO + 10646-1/Am.2. Depending on the character value, the representation + is a one, two, or three byte sequence: + @smallexample + @iftex + @leftskip=.7cm + @end iftex + 16#0000#-16#007f#: 2#0xxxxxxx# + 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx# + 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx# + + @end smallexample + + @noindent + where the xxx bits correspond to the left-padded bits of the + 16-bit character value. Note that all lower half ASCII characters + are represented as ASCII bytes and all upper half characters and + other wide characters are represented as sequences of upper-half + (The full UTF-8 scheme allows for encoding 31-bit characters as + 6-byte sequences, but in this implementation, all UTF-8 sequences + of four or more bytes length will be treated as illegal). + @item Brackets Coding + In this encoding, a wide character is represented by the following eight + character sequence: + + @smallexample + [ " a b c d " ] + @end smallexample + + @noindent + Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal + characters (using uppercase letters) of the wide character code. For + example, ["A345"] is used to represent the wide character with code + @code{16#A345#}. It is also possible (though not required) to use the + Brackets coding for upper half characters. For example, the code + @code{16#A3#} can be represented as @code{["A3"]}. + + This scheme is compatible with use of the full Wide_Character set, + and is also the method used for wide character encoding in the standard + ACVC (Ada Compiler Validation Capability) test suite distributions. + + @end table + + @noindent + Note: Some of these coding schemes do not permit the full use of the + Ada 95 character set. For example, neither Shift JIS, nor EUC allow the + use of the upper half of the Latin-1 set. + + @node File Naming Rules + @section File Naming Rules + + @noindent + The default file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + uppercase for all letters. + + An exception arises if the file name generated by the above rules starts + with one of the characters + A,G,I, or S, + and the second character is a + minus. In this case, the character dollar sign is used in place + of the minus. The reason for this special rule is to avoid clashes with + the standard names for child units of the packages System, Ada, + Interfaces, and GNAT, which use the prefixes + S- A- I- and G- + respectively. + + The file extension is @file{.ADS} for a spec and + @file{.ADB} for a body. The following list shows some + examples of these rules. + + @table @file + @item MAIN.ADS + Main (spec) + @item MAIN.ADB + Main (body) + @item ARITH_FUNCTIONS.ADS + Arith_Functions (package spec) + @item ARITH_FUNCTIONS.ADB + Arith_Functions (package body) + @item FUNC-SPEC.ADS + Func.Spec (child package spec) + @item FUNC-SPEC.ADB + Func.Spec (child package body) + @item MAIN-SUB.ADB + Sub (subunit of Main) + @item A$BAD.ADB + A.Bad (child package body) + @end table + + @noindent + Following these rules can result in excessively long + file names if corresponding + unit names are long (for example, if child units or subunits are + heavily nested). An option is available to shorten such long file names + (called file name "krunching"). This may be particularly useful when + programs being developed with GNAT are to be used on operating systems + with limited file name lengths. @xref{Using GNAT KRUNCH}. + + Of course, no file shortening algorithm can guarantee uniqueness over + all possible unit names; if file name krunching is used, it is your + responsibility to ensure no name clashes occur. Alternatively you + can specify the exact file names that you want used, as described + in the next section. Finally, if your Ada programs are migrating from a + compiler with a different naming convention, you can use the GNAT CHOP + utility to produce source files that follow the GNAT naming conventions. + (For details @pxref{Renaming Files Using GNAT CHOP}.) + + @node Using Other File Names + @section Using Other File Names + @cindex File names + + @noindent + In the previous section, we have described the default rules used by + GNAT to determine the file name in which a given unit resides. It is + often convenient to follow these default rules, and if you follow them, + the compiler knows without being explicitly told where to find all + the files it needs. + + However, in some cases, particularly when a program is imported from + another Ada compiler environment, it may be more convenient for the + programmer to specify which file names contain which units. GNAT allows + arbitrary file names to be used by means of the Source_File_Name pragma. + The form of this pragma is as shown in the following examples: + @cindex Source_File_Name pragma + + @smallexample + @group + @cartouche + @b{pragma} Source_File_Name (My_Utilities.Stacks, + Spec_File_Name => "MYUTILST_A.ADA"); + @b{pragma} Source_File_name (My_Utilities.Stacks, + Body_File_Name => "MYUTILST.ADA"); + @end cartouche + @end group + @end smallexample + + @noindent + As shown in this example, the first argument for the pragma is the unit + name (in this example a child unit). The second argument has the form + of a named association. The identifier + indicates whether the file name is for a spec or a body; + the file name itself is given by a string literal. + + The source file name pragma is a configuration pragma, which means that + normally it will be placed in the @file{GNAT.ADC} + file used to hold configuration + pragmas that apply to a complete compilation environment. + For more details on how the @file{GNAT.ADC} file is created and used + @pxref{Handling of Configuration Pragmas} + @cindex @file{GNAT.ADC} + + + @noindent + @code{GNAT MAKE} handles non-standard file names in the usual manner (the + non-standard file name for the main program is simply used as the + argument to GNAT MAKE). Note that if the extension is also non-standard, + then it must be included in the GNAT MAKE command, it may not be omitted. + + @node Alternative File Naming Schemes + @section Alternative File Naming Schemes + @cindex File naming schemes, alternative + @cindex File names + + In the previous section, we described the use of the @code{Source_File_Name} + pragma to allow arbitrary names to be assigned to individual source files. + However, this approach requires one pragma for each file, and especially in + large systems can result in very long @file{GNAT.ADC} files, and also create + a maintenance problem. + + GNAT also provides a facility for specifying systematic file naming schemes + other than the standard default naming scheme previously described. An + alternative scheme for naming is specified by the use of + @code{Source_File_Name} pragmas having the following format: + @cindex Source_File_Name pragma + + @smallexample + pragma Source_File_Name ( + Spec_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Body_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Subunit_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + FILE_NAME_PATTERN ::= STRING_LITERAL + CASING_SPEC ::= Lowercase | Uppercase | Mixedcase + + @end smallexample + + @noindent + The @code{FILE_NAME_PATTERN} string shows how the file name is constructed. + It contains a single asterisk character, and the unit name is substituted + systematically for this asterisk. The optional parameter + @code{Casing} indicates + whether the unit name is to be all upper-case letters, all lower-case letters, + or mixed-case. If no + @code{Casing} parameter is used, then the default is all + upper-case. + + The optional @code{Dot_Replacement} string is used to replace any periods + that occur in subunit or child unit names. If no @code{Dot_Replacement} + argument is used then separating dots appear unchanged in the resulting + file name. + Although the above syntax indicates that the + @code{Casing} argument must appear + before the @code{Dot_Replacement} argument, but it + is also permissible to write these arguments in the opposite order. + + As indicated, it is possible to specify different naming schemes for + bodies, specs, and subunits. Quite often the rule for subunits is the + same as the rule for bodies, in which case, there is no need to give + a separate @code{Subunit_File_Name} rule, and in this case the + @code{Body_File_name} rule is used for subunits as well. + + The separate rule for subunits can also be used to implement the rather + unusual case of a compilation environment (e.g. a single directory) which + contains a subunit and a child unit with the same unit name. Although + both units cannot appear in the same partition, the Ada Reference Manual + allows (but does not require) the possibility of the two units coexisting + in the same environment. + + The file name translation works in the following steps: + + @itemize @bullet + + @item + If there is a specific @code{Source_File_Name} pragma for the given unit, + then this is always used, and any general pattern rules are ignored. + + @item + If there is a pattern type @code{Source_File_Name} pragma that applies to + the unit, then the resulting file name will be used if the file exists. If + more than one pattern matches, the latest one will be tried first, and the + first attempt resulting in a reference to a file that exists will be used. + + @item + If no pattern type @code{Source_File_Name} pragma that applies to the unit + for which the corresponding file exists, then the standard GNAT default + naming rules are used. + + @end itemize + + @noindent + As an example of the use of this mechanism, consider a commonly used scheme + in which file names are all lower case, with separating periods copied + unchanged to the resulting file name, and specs end with ".1.ADA", and + bodies end with ".2.ADA". GNAT will follow this scheme if the following + two pragmas appear: + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*.1.ADA"); + pragma Source_File_Name + (Body_File_Name => "*.2.ADA"); + @end smallexample + + @noindent + The default GNAT scheme is actually implemented by providing the following + default pragmas internally: + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*.ADS", Dot_Replacement => "-"); + pragma Source_File_Name + (Body_File_Name => "*.ADB", Dot_Replacement => "-"); + @end smallexample + + @noindent + Our final example implements a scheme typically used with one of the + Ada 83 compilers, where the separator character for subunits was "__" + (two underscores), specs were identified by adding @file{_.ADA}, bodies + by adding @file{.ADA}, and subunits by + adding @file{.SEP}. All file names were + upper case. Child units were not present of course since this was an + Ada 83 compiler, but it seems reasonable to extend this scheme to use + the same double underscore separator for child units. + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*_.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Body_File_Name => "*.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Subunit_File_Name => "*.SEP", + Dot_Replacement => "__", + Casing = Uppercase); + @end smallexample + + @node Generating Object Files + @section Generating Object Files + + @noindent + An Ada program consists of a set of source files, and the first step in + compiling the program is to generate the corresponding object files. + These are generated by compiling a subset of these source files. + The files you need to compile are the following: + + @itemize @bullet + @item + If a package spec has no body, compile the package spec to produce the + object file for the package. + + @item + If a package has both a spec and a body, compile the body to produce the + object file for the package. The source file for the package spec need + not be compiled in this case because there is only one object file, which + contains the code for both the spec and body of the package. + + @item + For a subprogram, compile the subprogram body to produce the object file + for the subprogram. The spec, if one is present, is as usual in a + separate file, and need not be compiled. + + @item + @cindex Subunits + In the case of subunits, only compile the parent unit. A single object + file is generated for the entire subunit tree, which includes all the + subunits. + + @item + Compile child units independently of their parent units + (though, of course, the spec of all the ancestor unit must be present in order + to compile a child unit). + + @item + @cindex Generics + Compile generic units in the same manner as any other units. The object + files in this case are small dummy files that contain at most the + flag used for elaboration checking. This is because GNAT always handles generic + instantiation by means of macro expansion. However, it is still necessary to + compile generic units, for dependency checking and elaboration purposes. + @end itemize + + @noindent + The preceding rules describe the set of files that must be compiled to + generate the object files for a program. Each object file has the same + name as the corresponding source file, except that the extension is + @file{.OBJ} as usual. + + You may wish to compile other files for the purpose of checking their + syntactic and semantic correctness. For example, in the case where a + package has a separate spec and body, you would not normally compile the + spec. However, it is convenient in practice to compile the spec to make + sure it is error-free before compiling clients of this spec, because such + compilations will fail if there is an error in the spec. + + GNAT provides an option for compiling such files purely for the + purposes of checking correctness; such compilations are not required as + part of the process of building a program. To compile a file in this + checking mode, use the @option{/NOLOAD} qualifier. + + @node Source Dependencies + @section Source Dependencies + + @noindent + A given object file clearly depends on the source file which is compiled + to produce it. Here we are using @dfn{depends} in the sense of a typical + @code{make} utility; in other words, an object file depends on a source + file if changes to the source file require the object file to be + recompiled. + In addition to this basic dependency, a given object may depend on + additional source files as follows: + + @itemize @bullet + @item + If a file being compiled @code{with}'s a unit @var{X}, the object file + depends on the file containing the spec of unit @var{X}. This includes + files that are @code{with}'ed implicitly either because they are parents + of @code{with}'ed child units or they are run-time units required by the + language constructs used in a particular unit. + + @item + If a file being compiled instantiates a library level generic unit, the + object file depends on both the spec and body files for this generic + unit. + + @item + If a file being compiled instantiates a generic unit defined within a + package, the object file depends on the body file for the package as + well as the spec file. + + @item + @findex Inline + @cindex @option{/INLINE=PRAGMA} qualifier + If a file being compiled contains a call to a subprogram for which + pragma @code{Inline} applies and inlining is activated with the + @option{/INLINE=PRAGMA} qualifier, the object file depends on the file containing the + body of this subprogram as well as on the file containing the spec. Note + that for inlining to actually occur as a result of the use of this qualifier, + it is necessary to compile in optimizing mode. + + @cindex @option{-gnatN} qualifier + The use of @option{-gnatN} activates a more extensive inlining optimization + that is performed by the front end of the compiler. This inlining does + not require that the code generation be optimized. Like @option{/INLINE=PRAGMA}, + the use of this qualifier generates additional dependencies. + + @item + If an object file O depends on the proper body of a subunit through inlining + or instantiation, it depends on the parent unit of the subunit. This means that + any modification of the parent unit or one of its subunits affects the + compilation of O. + + @item + The object file for a parent unit depends on all its subunit body files. + + @item + The previous two rules meant that for purposes of computing dependencies and + recompilation, a body and all its subunits are treated as an indivisible whole. + + @noindent + These rules are applied transitively: if unit @code{A} @code{with}'s + unit @code{B}, whose elaboration calls an inlined procedure in package + @code{C}, the object file for unit @code{A} will depend on the body of + @code{C}, in file @file{C.ADB}. + + The set of dependent files described by these rules includes all the + files on which the unit is semantically dependent, as described in the + Ada 95 Language Reference Manual. However, it is a superset of what the + ARM describes, because it includes generic, inline, and subunit dependencies. + + An object file must be recreated by recompiling the corresponding source + file if any of the source files on which it depends are modified. For + example, if the @code{make} utility is used to control compilation, + the rule for an Ada object file must mention all the source files on + which the object file depends, according to the above definition. + The determination of the necessary + recompilations is done automatically when one uses @code{GNAT MAKE}. + @end itemize + + @node The Ada Library Information Files + @section The Ada Library Information Files + @cindex Ada Library Information files + @cindex @file{ali} files + + @noindent + Each compilation actually generates two output files. The first of these + is the normal object file that has a @file{.OBJ} extension. The second is a + text file containing full dependency information. It has the same + name as the source file, but an @file{.ALI} extension. + This file is known as the Ada Library Information (@file{ali}) file. + The following information is contained in the @file{ali} file. + + @itemize @bullet + @item + Version information (indicates which version of GNAT was used to compile + the unit(s) in question) + + @item + Main program information (including priority and time slice settings, + as well as the wide character encoding used during compilation). + + @item + List of arguments used in the @code{GNAT COMPILE} command for the compilation + + @item + Attributes of the unit, including configuration pragmas used, an indication + of whether the compilation was successful, exception model used etc. + + @item + A list of relevant restrictions applying to the unit (used for consistency) + checking. + + @item + Categorization information (e.g. use of pragma @code{Pure}). + + @item + Information on all @code{with}'ed units, including presence of + @code{Elaborate} or @code{Elaborate_All} pragmas. + + @item + Information from any @code{Linker_Options} pragmas used in the unit + + @item + Information on the use of @code{Body_Version} or @code{Version} + attributes in the unit. + + @item + Dependency information. This is a list of files, together with + time stamp and checksum information. These are files on which + the unit depends in the sense that recompilation is required + if any of these units are modified. + + @item + Cross-reference data. Contains information on all entities referenced + in the unit. Used by tools like @code{GNAT XREF} and @code{GNAT FIND} to + provide cross-reference information. + + @end itemize + + @noindent + For a full detailed description of the format of the @file{ali} file, + see the source of the body of unit @code{Lib.Writ}, contained in file + @file{LIB-WRIT.ADB} in the GNAT compiler sources. + + @node Binding an Ada Program + @section Binding an Ada Program + + @noindent + When using languages such as C and C++, once the source files have been + compiled the only remaining step in building an executable program + is linking the object modules together. This means that it is possible to + link an inconsistent version of a program, in which two units have + included different versions of the same header. + + The rules of Ada do not permit such an inconsistent program to be built. + For example, if two clients have different versions of the same package, + it is illegal to build a program containing these two clients. + These rules are enforced by the GNAT binder, which also determines an + elaboration order consistent with the Ada rules. + + The GNAT binder is run after all the object files for a program have + been created. It is given the name of the main program unit, and from + this it determines the set of units required by the program, by reading the + corresponding ALI files. It generates error messages if the program is + inconsistent or if no valid order of elaboration exists. + + If no errors are detected, the binder produces a main program, in Ada by + default, that contains calls to the elaboration procedures of those + compilation unit that require them, followed by + a call to the main program. This Ada program is compiled to generate the + object file for the main program. The name of + the Ada file is @file{B$@var{xxx}.ADB} (with the corresponding spec + @file{B$@var{xxx}.ADS}) where @var{xxx} is the name of the + main program unit. + + Finally, the linker is used to build the resulting executable program, + using the object from the main program from the bind step as well as the + object files for the Ada units of the program. + + @node Mixed Language Programming + @section Mixed Language Programming + @cindex Mixed Language Programming + + @menu + * Interfacing to C:: + * Calling Conventions:: + @end menu + + @node Interfacing to C + @subsection Interfacing to C + @noindent + There are two ways to + build a program that contains some Ada files and some other language + files depending on whether the main program is in Ada or not. + If the main program is in Ada, you should proceed as follows: + + @enumerate + @item + Compile the other language files to generate object files. For instance: + @smallexample + GNAT COMPILE FILE1.C + GNAT COMPILE FILE2.C + @end smallexample + + @item + Compile the Ada units to produce a set of object files and ALI + files. For instance: + @smallexample + GNAT MAKE /ACTIONS=COMPILE MY_MAIN.ADB + @end smallexample + + @item + Run the Ada binder on the Ada main program. For instance: + @smallexample + GNAT BIND MY_MAIN.ALI + @end smallexample + + @item + Link the Ada main program, the Ada objects and the other language + objects. For instance: + @smallexample + GNAT LINK MY_MAIN.ALI FILE1.OBJ FILE2.OBJ + @end smallexample + @end enumerate + + The three last steps can be grouped in a single command: + @smallexample + GNAT MAKE MY_MAIN.ADB /LINKER_QUALIFIERS FILE1.OBJ FILE2.OBJ + @end smallexample + + @cindex Binder output file + @noindent + If the main program is in some language other than Ada, Then you may + have more than one entry point in the Ada subsystem. You must use a + special option of the binder to generate callable routines to initialize + and finalize the Ada units (@pxref{Binding with Non-Ada Main Programs}). + Calls to the initialization and finalization routines must be inserted in + the main program, or some other appropriate point in the code. The call to + initialize the Ada units must occur before the first Ada subprogram is + called, and the call to finalize the Ada units must occur after the last + Ada subprogram returns. You use the same procedure for building the + program as described previously. In this case, however, the binder + only places the initialization and finalization subprograms into file + @file{B$@var{xxx}.ADB} instead of the main program. + So, if the main program is not in Ada, you should proceed as follows: + + @enumerate + @item + Compile the other language files to generate object files. For instance: + @smallexample + GNAT COMPILE FILE1.C + GNAT COMPILE FILE2.C + @end smallexample + + @item + Compile the Ada units to produce a set of object files and ALI + files. For instance: + @smallexample + GNAT MAKE /ACTIONS=COMPILE ENTRY_POINT1.ADB + GNAT MAKE /ACTIONS=COMPILE ENTRY_POINT2.ADB + @end smallexample + + @item + Run the Ada binder on the Ada main program. For instance: + @smallexample + GNAT BIND /NOMAIN ENTRY_POINT1.ALI ENTRY_POINT2.ALI + @end smallexample + + @item + Link the Ada main program, the Ada objects and the other language + objects. You only need to give the last entry point here. For instance: + @smallexample + GNAT LINK ENTRY_POINT2.ALI FILE1.OBJ FILE2.OBJ + @end smallexample + @end enumerate + + @node Calling Conventions + @subsection Calling Conventions + @cindex Foreign Languages + @cindex Calling Conventions + GNAT follows standard calling sequence conventions and will thus interface + to any other language that also follows these conventions. The following + Convention identifiers are recognized by GNAT: + + @itemize @bullet + @cindex Interfacing to Ada + @cindex Other Ada compilers + @cindex Convention Ada + @item + Ada. This indicates that the standard Ada calling sequence will be + used and all Ada data items may be passed without any limitations in the + case where GNAT is used to generate both the caller and callee. It is also + possible to mix GNAT generated code and code generated by another Ada + compiler. In this case, the data types should be restricted to simple + cases, including primitive types. Whether complex data types can be passed + depends on the situation. Probably it is safe to pass simple arrays, such + as arrays of integers or floats. Records may or may not work, depending + on whether both compilers lay them out identically. Complex structures + involving variant records, access parameters, tasks, or protected types, + are unlikely to be able to be passed. + + Note that in the case of GNAT running + on a platform that supports DEC Ada 83, a higher degree of compatibility + can be guaranteed, and in particular records are layed out in an identical + manner in the two compilers. Note also that if output from two different + compilers is mixed, the program is responsible for dealing with elaboration + issues. Probably the safest approach is to write the main program in the + version of Ada other than GNAT, so that it takes care of its own elaboration + requirements, and then call the GNAT-generated adainit procedure to ensure + elaboration of the GNAT components. Consult the documentation of the other + Ada compiler for further details on elaboration. + + However, it is not possible to mix the tasking run time of GNAT and + DEC Ada 83, All the tasking operations must either be entirely within + GNAT compiled sections of the program, or entirely within DEC Ada 83 + compiled sections of the program. + + @cindex Interfacing to Assembly + @cindex Convention Assembler + @item + Assembler. Specifies assembler as the convention. In practice this has the + same effect as convention Ada (but is not equivalent in the sense of being + considered the same convention). + + @cindex Convention Asm + @findex Asm + @item + Asm. Equivalent to Assembler. + + @cindex Convention Asm + @findex Asm + @item + Asm. Equivalent to Assembly. + + @cindex Interfacing to COBOL + @cindex Convention COBOL + @findex COBOL + @item + COBOL. Data will be passed according to the conventions described + in section B.4 of the Ada 95 Reference Manual. + + @findex C + @cindex Interfacing to C + @cindex Convention C + @item + C. Data will be passed according to the conventions described + in section B.3 of the Ada 95 Reference Manual. + + @cindex Convention Default + @findex Default + @item + Default. Equivalent to C. + + @cindex Convention External + @findex External + @item + External. Equivalent to C. + + @findex C++ + @cindex Interfacing to C++ + @cindex Convention C++ + @item + CPP. This stands for C++. For most purposes this is identical to C. + See the separate description of the specialized GNAT pragmas relating to + C++ interfacing for further details. + + @findex Fortran + @cindex Interfacing to Fortran + @cindex Convention Fortran + @item + Fortran. Data will be passed according to the conventions described + in section B.5 of the Ada 95 Reference Manual. + + @item + Intrinsic. This applies to an intrinsic operation, as defined in the Ada 95 + Reference Manual. If a a pragma Import (Intrinsic) applies to a subprogram, + this means that the body of the subprogram is provided by the compiler itself, + usually by means of an efficient code sequence, and that the user does not + supply an explicit body for it. In an application program, the pragma can only + be applied to the following two sets of names, which the GNAT compiler + recognizes. + @itemize @bullet + @item + Rotate_Left, Rotate_Right, Shift_Left, Shift_Right, Shift_Right_- + Arithmetic. The corresponding subprogram declaration must have + two formal parameters. The + first one must be a signed integer type or a modular type with a binary + modulus, and the second parameter must be of type Natural. + The return type must be the same as the type of the first argument. The size + of this type can only be 8, 16, 32, or 64. + @item binary arithmetic operators: "+", "-", "*", "/" + The corresponding operator declaration must have parameters and result type + that have the same root numeric type (for example, all three are long_float + types). This simplifies the definition of operations that use type checking + to perform dimensional checks: + @smallexample + type Distance is new Long_Float; + type Time is new Long_Float; + type Velocity is new Long_Float; + function "/" (D : Distance; T : Time) + return Velocity; + pragma Import (Intrinsic, "/"); + @end smallexample + @noindent + This common idiom is often programmed with a generic definition and an explicit + body. The pragma makes it simpler to introduce such declarations. It incurs + no overhead in compilation time or code size, because it is implemented as a + single machine instruction. + @end itemize + @noindent + + @findex Stdcall + @cindex Convention Stdcall + @item + Stdcall. This is relevant only to NT/Win95 implementations of GNAT, + and specifies that the Stdcall calling sequence will be used, as defined + by the NT API. + + @findex DLL + @cindex Convention DLL + @item + DLL. This is equivalent to Stdcall. + + @findex Win32 + @cindex Convention Win32 + @item + Win32. This is equivalent to Stdcall. + + @findex Stubbed + @cindex Convention Stubbed + @item + Stubbed. This is a special convention that indicates that the compiler + should provide a stub body that raises @code{Program_Error}. + @end itemize + + @noindent + GNAT additionally provides a useful pragma @code{Convention_Identifier} + that can be used to parametrize conventions and allow additional synonyms + to be specified. For example if you have legacy code in which the convention + identifier Fortran77 was used for Fortran, you can use the configuration + pragma: + + @smallexample + pragma Convention_Identifier (Fortran77, Fortran); + @end smallexample + + @noindent + And from now on the identifier Fortran77 may be used as a convention + identifier (for example in an @code{Import} pragma) with the same + meaning as Fortran. + + @node Building Mixed Ada & C++ Programs + @section Building Mixed Ada & C++ Programs + + @noindent + Building a mixed application containing both Ada and C++ code may be a + challenge for the unaware programmer. As a matter of fact, this + interfacing has not been standardized in the Ada 95 reference manual due + to the immaturity and lack of standard of C++ at the time. This + section gives a few hints that should make this task easier. In + particular the first section addresses the differences with + interfacing with C. The second section looks into the delicate problem + of linking the complete application from its Ada and C++ parts. The last + section give some hints on how the GNAT run time can be adapted in order + to allow inter-language dispatching with a new C++ compiler. + + @menu + * Interfacing to C++:: + * Linking a Mixed C++ & Ada Program:: + * A Simple Example:: + * Adapting the Run Time to a New C++ Compiler:: + @end menu + + @node Interfacing to C++ + @subsection Interfacing to C++ + + @noindent + GNAT supports interfacing with C++ compilers generating code that is + compatible with the standard Application Binary Interface of the given + platform. + + @noindent + Interfacing can be done at 3 levels: simple data, subprograms and + classes. In the first 2 cases, GNAT offer a specific @var{Convention + CPP} that behaves exactly like @var{Convention C}. Usually C++ mangle + names of subprograms and currently GNAT does not provide any help to + solve the demangling problem. This problem can be addressed in 2 ways: + @itemize @bullet + @item + by modifying the C++ code in order to force a C convention using + the @var{extern "C"} syntax. + + @item + by figuring out the mangled name and use it as the Link_Name argument of + the pragma import. + @end itemize + + @noindent + Interfacing at the class level can be achieved by using the GNAT specific + pragmas such as @code{CPP_Class} and @code{CPP_Virtual}. See the GNAT + Reference Manual for additional information. + + @node Linking a Mixed C++ & Ada Program + @subsection Linking a Mixed C++ & Ada Program + + @noindent + Usually the linker of the C++ development system must be used to link + mixed applications because most C++ systems will resolve elaboration + issues (such as calling constructors on global class instances) + transparently during the link phase. GNAT has been adapted to ease the + use of a foreign linker for the last phase. Three cases can be + considered: + @enumerate + + @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 request recompiling the whole GCC + tree from sources and it does not allow to upgrade easily to a new + version of one compiler for one of the two languages without taking the + risk of destabilizing the other. + + @smallexample + $ c++ -c file1.C + $ c++ -c file2.C + $ GNAT MAKE ada_unit /LINKER_QUALIFIERS FILE1.OBJ FILE2.OBJ --LINK=c++ + @end smallexample + + @item + Using GNAT and G++ from 2 different GCC installations. If both compilers + are on the PATH, the same method can be used. It is important to be + aware that environment variables such as C_INCLUDE_PATH, + GCC_EXEC_PREFIX, BINUTILS_ROOT or GCC_ROOT will affect both compilers at + the same time and thus may make one of the 2 compilers operate + improperly if they are set for the other. In particular it is important + that the link command has access to the proper GNAT COMPILE library @file{libgcc.a}, + that is to say the one that is part of the C++ compiler + installation. The implicit link command as suggested in the GNAT MAKE + command from the former example can be replaced by an explicit link + command with full verbosity in order to verify which library is used: + @smallexample + $ GNAT BIND ada_unit + $ GNAT LINK -v -v ada_unit FILE1.OBJ FILE2.OBJ --LINK=c++ + @end smallexample + If there is a problem due to interfering environment variables, it can + be workaround by using an intermediate script. The following example + shows the proper script to use when GNAT has not been installed at its + default location and g++ has been installed at its default location: + + @smallexample + $ GNAT LINK -v -v ada_unit FILE1.OBJ FILE2.OBJ --LINK=./my_script + $ cat ./my_script + #!/bin/sh + unset BINUTILS_ROOT + unset GCC_ROOT + c++ $* + @end smallexample + + @item + Using a non GNU C++ compiler. The same set of command as previously + described can be used to insure that the c++ linker is + used. Nonetheless, you need to add the path to libgcc explicitely, since some + libraries needed by GNAT are located in this directory: + + @smallexample + + $ GNAT LINK ada_unit FILE1.OBJ FILE2.OBJ --LINK=./my_script + $ cat ./my_script + #!/bin/sh + CC $* `GNAT COMPILE -print-libgcc-file-name` + + @end smallexample + + Where CC is the name of the non GNU C++ compiler. + + @end enumerate + + @node A Simple Example + @subsection A Simple Example + @noindent + The following example, provided as part of the GNAT examples, show how + to achieve procedural interfacing between Ada and C++ in both + directions. The C++ class A has 2 methods. The first method is exported + to Ada by the means of an extern C wrapper function. The second method + calls an Ada subprogram. On the Ada side, The C++ calls is modelized by + a limited record with a layout comparable to the C++ class. The Ada + subprogram, in turn, calls the c++ method. So from the C++ main program + the code goes back and forth between the 2 languages. + + @noindent + Here are the compilation commands + for native configurations: + @smallexample + $ GNAT MAKE -c simple_cpp_interface + $ c++ -c cpp_main.C + $ c++ -c ex7.C + $ GNAT BIND -n simple_cpp_interface + $ GNAT LINK simple_cpp_interface -o cpp_main --LINK=$(CPLUSPLUS) + -lstdc++ EX7.OBJ CPP_MAIN.OBJ + @end smallexample + @noindent + Here are the corresponding sources: + @smallexample + + //cpp_main.C + + #include "ex7.h" + + extern "C" @{ + void adainit (void); + void adafinal (void); + void method1 (A *t); + @} + + void method1 (A *t) + @{ + t->method1 (); + @} + + int main () + @{ + A obj; + adainit (); + obj.method2 (3030); + adafinal (); + @} + + //ex7.h + + class Origin @{ + public: + int o_value; + @}; + class A : public Origin @{ + public: + void method1 (void); + virtual void method2 (int v); + A(); + int a_value; + @}; + + //ex7.C + + #include "ex7.h" + #include + + extern "C" @{ void ada_method2 (A *t, int v);@} + + void A::method1 (void) + @{ + a_value = 2020; + printf ("in A::method1, a_value = %d \n",a_value); + + @} + + void A::method2 (int v) + @{ + ada_method2 (this, v); + printf ("in A::method2, a_value = %d \n",a_value); + + @} + + A::A(void) + @{ + a_value = 1010; + printf ("in A::A, a_value = %d \n",a_value); + @} + + -- Ada sources + @b{package} @b{body} Simple_Cpp_Interface @b{is} + + @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer) @b{is} + @b{begin} + Method1 (This); + This.A_Value := V; + @b{end} Ada_Method2; + + @b{end} Simple_Cpp_Interface; + + @b{package} Simple_Cpp_Interface @b{is} + @b{type} A @b{is} @b{limited} + @b{record} + O_Value : Integer; + A_Value : Integer; + @b{end} @b{record}; + @b{pragma} Convention (C, A); + + @b{procedure} Method1 (This : @b{in} @b{out} A); + @b{pragma} Import (C, Method1); + + @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer); + @b{pragma} Export (C, Ada_Method2); + + @b{end} Simple_Cpp_Interface; + @end smallexample + + @node Adapting the Run Time to a New C++ Compiler + @subsection Adapting the Run Time to a New C++ Compiler + @noindent + GNAT offers the capability to derive Ada 95 tagged types directly from + preexisting C++ classes and . See "Interfacing with C++" in the GNAT + reference manual. The mechanism used by GNAT for achieving such a goal + has been made user configurable through a GNAT library unit + @code{Interfaces.CPP}. The default version of this file is adapted to + the GNU c++ compiler. Internal knowledge of the virtual + table layout used by the new C++ compiler is needed to configure + properly this unit. The Interface of this unit is known by the compiler + and cannot be changed except for the value of the constants defining the + characteristics of the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size, + CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source + of this unit for more details. + + @node Comparison between GNAT and C/C++ Compilation Models + @section Comparison between GNAT and C/C++ Compilation Models + + @noindent + The GNAT model of compilation is close to the C and C++ models. You can + think of Ada specs as corresponding to header files in C. As in C, you + don't need to compile specs; they are compiled when they are used. The + Ada @code{with} is similar in effect to the @code{#include} of a C + header. + + One notable difference is that, in Ada, you may compile specs separately + to check them for semantic and syntactic accuracy. This is not always + possible with C headers because they are fragments of programs that have + less specific syntactic or semantic rules. + + The other major difference is the requirement for running the binder, + which performs two important functions. First, it checks for + consistency. In C or C++, the only defense against assembling + inconsistent programs lies outside the compiler, in a makefile, for + example. The binder satisfies the Ada requirement that it be impossible + to construct an inconsistent program when the compiler is used in normal + mode. + + @cindex Elaboration order control + The other important function of the binder is to deal with elaboration + issues. There are also elaboration issues in C++ that are handled + automatically. This automatic handling has the advantage of being + simpler to use, but the C++ programmer has no control over elaboration. + Where @code{GNAT BIND} might complain there was no valid order of + elaboration, a C++ compiler would simply construct a program that + malfunctioned at run time. + + @node Comparison between GNAT and Conventional Ada Library Models + @section Comparison between GNAT and Conventional Ada Library Models + + @noindent + This section is intended to be useful to Ada programmers who have + previously used an Ada compiler implementing the traditional Ada library + model, as described in the Ada 95 Language Reference Manual. If you + have not used such a system, please go on to the next section. + + @cindex GNAT library + In GNAT, there is no @dfn{library} in the normal sense. Instead, the set of + source files themselves acts as the library. Compiling Ada programs does + not generate any centralized information, but rather an object file and + a ALI file, which are of interest only to the binder and linker. + In a traditional system, the compiler reads information not only from + the source file being compiled, but also from the centralized library. + This means that the effect of a compilation depends on what has been + previously compiled. In particular: + + @itemize @bullet + @item + When a unit is @code{with}'ed, the unit seen by the compiler corresponds + to the version of the unit most recently compiled into the library. + + @item + Inlining is effective only if the necessary body has already been + compiled into the library. + + @item + Compiling a unit may obsolete other units in the library. + @end itemize + + @noindent + In GNAT, compiling one unit never affects the compilation of any other + units because the compiler reads only source files. Only changes to source + files can affect the results of a compilation. In particular: + + @itemize @bullet + @item + When a unit is @code{with}'ed, the unit seen by the compiler corresponds + to the source version of the unit that is currently accessible to the + compiler. + + @item + @cindex Inlining + Inlining requires the appropriate source files for the package or + subprogram bodies to be available to the compiler. Inlining is always + effective, independent of the order in which units are complied. + + @item + Compiling a unit never affects any other compilations. The editing of + sources may cause previous compilations to be out of date if they + depended on the source file being modified. + @end itemize + + @noindent + The most important result of these differences is that order of compilation + is never significant in GNAT. There is no situation in which one is + required to do one compilation before another. What shows up as order of + compilation requirements in the traditional Ada library becomes, in + GNAT, simple source dependencies; in other words, there is only a set + of rules saying what source files must be present when a file is + compiled. + + @node Compiling Using GNAT COMPILE + @chapter Compiling Using @code{GNAT COMPILE} + + @noindent + This chapter discusses how to compile Ada programs using the @code{GNAT COMPILE} + command. It also describes the set of qualifiers + that can be used to control the behavior of the compiler. + @menu + * Compiling Programs:: + * Qualifiers for GNAT COMPILE:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + @end menu + + @node Compiling Programs + @section Compiling Programs + + @noindent + The first step in creating an executable program is to compile the units + of the program using the @code{GNAT COMPILE} command. You must compile the + following files: + + @itemize @bullet + @item + the body file (@file{.ADB}) for a library level subprogram or generic + subprogram + + @item + the spec file (@file{.ADS}) for a library level package or generic + package that has no body + + @item + the body file (@file{.ADB}) for a library level package + or generic package that has a body + + @end itemize + + @noindent + You need @emph{not} compile the following files + + @itemize @bullet + + @item + the spec of a library unit which has a body + + @item + subunits + @end itemize + + @noindent + because they are compiled as part of compiling related units. GNAT + package specs + when the corresponding body is compiled, and subunits when the parent is + compiled. + @cindex No code generated + If you attempt to compile any of these files, you will get one of the + following error messages (where fff is the name of the file you compiled): + + @smallexample + No code generated for file @var{fff} (@var{package spec}) + No code generated for file @var{fff} (@var{subunit}) + @end smallexample + + @noindent + The basic command for compiling a file containing an Ada unit is + + @smallexample + $ GNAT COMPILE [@var{qualifiers}] @file{file name} + @end smallexample + + @noindent + where @var{file name} is the name of the Ada file (usually + having an extension + @file{.ADS} for a spec or @file{.ADB} for a body). + The result of a successful compilation is an object file, which has the + same name as the source file but an extension of @file{.OBJ} and an Ada + Library Information (ALI) file, which also has the same name as the + source file, but with @file{.ALI} as the extension. GNAT creates these + two output files in the current directory, but you may specify a source + file in any directory using an absolute or relative path specification + containing the directory information. + + @findex GNAT1 + @code{GNAT COMPILE} is actually a driver program that looks at the extensions of + the file arguments and loads the appropriate compiler. For example, the + GNU C compiler is @file{CC1}, and the Ada compiler is @file{GNAT1}. + These programs are in directories known to the driver program (in some + configurations via environment variables you set), but need not be in + your path. The @code{GNAT COMPILE} driver also calls the assembler and any other + utilities needed to complete the generation of the required object + files. + + It is possible to supply several file names on the same @code{GNAT COMPILE} + command. This causes @code{GNAT COMPILE} to call the appropriate compiler for + each file. For example, the following command lists three separate + files to be compiled: + + @smallexample + $ GNAT COMPILE X.ADB Y.ADB Z.C + @end smallexample + + @noindent + calls @code{GNAT1} (the Ada compiler) twice to compile @file{X.ADB} and + @file{Y.ADB}, and @code{CC1} (the C compiler) once to compile @file{Z.C}. + The compiler generates three object files @file{X.OBJ}, @file{Y.OBJ} and + @file{Z.OBJ} and the two ALI files @file{X.ALI} and @file{Y.ALI} from the + Ada compilations. Any qualifiers apply to all the files listed. + + @node Qualifiers for GNAT COMPILE + @section Qualifiers for @code{GNAT COMPILE} + + @noindent + The @code{GNAT COMPILE} command accepts qualifiers that control the + compilation process. These qualifiers are fully described in this section. + First we briefly list all the qualifiers, in alphabetical order, then we + describe the qualifiers in more detail in functionally grouped sections. + + @menu + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using GNAT COMPILE for Syntax Checking:: + * Using GNAT COMPILE for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + @end menu + + @table @code + + @item /DEBUG + @cindex @code{/DEBUG} (@code{GNAT COMPILE}) + Generate debugging information. This information is stored in the object + file and copied from there to the final executable file by the linker, + where it can be read by the debugger. You must use the + @code{/DEBUG} qualifier if you plan on using the debugger. + + @item /SEARCH=@var{dir} + @cindex @code{/SEARCH} (@code{GNAT COMPILE}) + @cindex RTL + Direct GNAT to search the @var{dir} directory for source files needed by + the current compilation + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item /NOCURRENT_DIRECTORY + @cindex @code{/NOCURRENT_DIRECTORY} (@code{GNAT COMPILE}) + @cindex RTL + Except for the source file named in the command line, do not look for source files + in the directory containing the source file named in the command line + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + + + @item /NOOPTIMIZE (default) + @itemx /OPTIMIZE[=(keyword[,...])] + Selects the level of optimization for your program. The supported + keywords are as follows: + @table @code + @item ALL (default) + Perform most optimizations, including those that + be expensive. + + @item NONE + Do not do any optimizations. Same as @code{/NOOPTIMIZE}. + + @item SOME + Perform some optimizations, but omit ones that are costly. + + @item DEVELOPMENT + Same as @code{SOME}. + + @item INLINING + Full optimization, and also attempt automatic inlining of small + subprograms within a unit (@pxref{Inlining of Subprograms}). + + @item UNROLL_LOOPS + Try to unroll loops. This keyword may be specified together with + any keyword above other than @code{NONE}. Loop unrolling + usually, but not always, improves the performance of programs. + @end table + + @item /RUNTIME_SYSTEM=@var{rts-path} + @cindex @code{/RUNTIME_SYSTEM} (@code{GNAT COMPILE}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{GNAT MAKE} flag (see @ref{Qualifiers for GNAT MAKE}). + + @item /ASM + @cindex @code{/ASM} (@code{GNAT COMPILE}) + Used to + cause the assembler source file to be + generated, using @file{.S} as the extension, + instead of the object file. + This may be useful if you need to examine the generated assembly code. + + @item /VERBOSE + @cindex @code{/VERBOSE} (@code{GNAT COMPILE}) + Show commands generated by the @code{GNAT COMPILE} driver. Normally used only for + debugging purposes or if you need to be sure what version of the + compiler you are executing. + + + @item /CHECKS=ASSERTIONS + Assertions enabled. @code{Pragma Assert} and @code{pragma Debug} to be + activated. + + @item -gnatA + Avoid processing @file{GNAT.ADC}. If a GNAT.ADC file is present, it will be ignored. + + @item /WARNINGS=BRIEF + Generate brief messages to @file{SYS$ERROR} even if verbose mode set. + + @item /NOLOAD + Check syntax and semantics only (no code generation attempted). + + @item /COMPRESS_NAMES + Compress debug information and external symbol name table entries. + + @item /XDEBUG + Output expanded source files for source level debugging. This qualifier + also suppress generation of cross-reference information (see /XREF=SUPPRESS). + + @item -gnatec@var{path} + Specify a configuration pragma file. (see @ref{The Configuration Pragmas Files}) + + @item -gnatem@var{path} + Specify a mapping file. (see @ref{Units to Sources Mapping Files}) + + @item /CHECKS=ELABORATION + Full dynamic elaboration checks. + + @item /REPORT_ERRORS=FULL + Full errors. Multiple errors per line, all undefined references. + + @item /UPPERCASE_EXTERNALS + Externals names are folded to all uppercase. + + @item /STYLE=GNAT + Internal GNAT implementation mode. This should not be used for + applications programs, it is intended only for use by the compiler + and its run-time library. For documentation, see the GNAT sources. + + @item /EXPAND_SOURCE + List generated expanded code in source form. + + @item /IDENTIFIER_CHARACTER_SET=@var{c} + Identifier character set + For details of the possible selections for @var{c}, + see @xref{Character Set Control}. + + @item /HELP + Output usage information. The output is written to @file{SYS$OUTPUT}. + + @item /FILE_NAME_MAX_LENGTH=@var{n} + Limit file names to @var{n} (1-999) characters . + + @item /LIST + Output full source listing with embedded error messages. + + @item /ERROR_LIMIT=@var{n} + Limit number of detected errors to @var{n} (1-999). + + @item /INLINE=PRAGMA + Activate inlining across unit boundaries for subprograms for which + pragma @code{inline} is specified. + + @item -gnatN + Activate front end inlining. + + @item /INLINE=SUPPRESS + Suppresses all inlining, even if other optimization or inlining qualifiers + are set. + + + @item /CHECKS=OVERFLOW + Enable numeric overflow checking (which is not normally enabled by + default). Not that division by zero is a separate check that is not + controlled by this qualifier (division by zero checking is on by default). + + @item /CHECKS=SUPPRESS_ALL + Suppress all checks. + + @item /TRY_SEMANTICS + Don't quit; try semantics, even if parse errors. + + @item /FORCE_ALI + Don't quit; generate @file{ali} and tree files even if illegalities. + + @item /POLLING_ENABLE + Enable polling. This is required on some systems (notably Windows NT) to + obtain asynchronous abort and asynchronous transfer of control capability. + See the description of pragma Polling in the GNAT Reference Manual for + full details. + + @item /REPRESENTATION_INFO[0/1/2/3][s] + Output representation information for declared types and objects. + + @item /SYNTAX_ONLY + Syntax check only. + + @item /TREE_OUTPUT + Tree output file to be generated. + + @item -gnatT nnn + Set time slice to specified number of microseconds + + @item /UNITS_LIST + List units for this compilation. + + @item /UNIQUE_ERROR_TAG + Tag all error messages with the unique string "error:" + + @item /REPORT_ERRORS=VERBOSE + Verbose mode. Full error output with source lines to @file{SYS$OUTPUT}. + + @item /VALIDITY_CHECKING + Control level of validity checking. See separate section describing + this feature. + + @item /WARNINGS=@var{xxx} + Warning mode where + @var{xxx} is a string of options describing the exact warnings that + are enabled or disabled. See separate section on warning control. + + @item /WIDE_CHARACTER_ENCODING=@var{e} + Wide character encoding method + (@var{e}=@code{BRACKETS, NONE, HEX, UPPER, SHIFT_JIS, EUC, UTF8}) + + @item /XREF=SUPPRESS + Suppress generation of cross-reference information. + + @item /STYLE_CHECKS=(option,option..) + Enable built-in style checks. See separate section describing this feature. + + @item /DISTRIBUTION_STUBS=@var{m} + Distribution stub generation and compilation + (@var{m}=@code{RECEIVER} or @code{CALLER} to specify the type of stubs + to be generated and compiled). + + @item /83 + Enforce Ada 83 restrictions. + + @end table + + + @noindent + The following restrictions apply to the combination of qualifiers + in this manner: + + @itemize @bullet + @item + The qualifier @option{/NOLOAD} if combined with other qualifiers must come + first in the string. + + @item + The qualifier @option{/SYNTAX_ONLY} if combined with other qualifiers must come + first in the string. + + @item + Once a "y" appears in the string (that is a use of the @option{/STYLE=} + qualifier), then all further characters in the qualifier are interpreted + as style modifiers (see description of @option{/STYLE=}). + + @item + Once a "d" appears in the string (that is a use of the @option{-gnatd} + qualifier), then all further characters in the qualifier are interpreted + as debug flags (see description of @option{-gnatd}). + + @item + Once a "w" appears in the string (that is a use of the @option{-gnatw} + qualifier), then all further characters in the qualifier are interpreted + as warning mode modifiers (see description of @option{-gnatw}). + + @item + Once a "V" appears in the string (that is a use of the @option{/VALIDITY_CHECKING} + qualifier), then all further characters in the qualifier are interpreted + as validity checking options (see description of @option{/VALIDITY_CHECKING}). + + @end itemize + + @node Output and Error Message Control + @subsection Output and Error Message Control + @findex SYS$ERROR + + @noindent + The standard default format for error messages is called "brief format." + Brief format messages are written to @file{SYS$ERROR} (the standard error + file) and have the following form: + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + E.ADB:3:04: Incorrect spelling of keyword "function" + E.ADB:4:20: ";" should be "is" + @end smallexample + + @noindent + The first integer after the file name is the line number in the file, + and the second integer is the column number within the line. + @code{glide} can parse the error messages + and point to the referenced character. + The following qualifiers provide control over the error message + format: + + @table @code + @item /REPORT_ERRORS=VERBOSE + @cindex @option{/REPORT_ERRORS=VERBOSE} (@code{GNAT COMPILE}) + @findex SYS$OUTPUT + The effect of this setting is to write long-format error + messages to @file{SYS$OUTPUT} (the standard output file. + The same program compiled with the + @option{/REPORT_ERRORS=VERBOSE} qualifier would generate: + + @smallexample + @group + @cartouche + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + @end cartouche + @end group + @end smallexample + + @noindent + The vertical bar indicates the location of the error, and the @samp{>>>} + prefix can be used to search for error messages. When this qualifier is + used the only source lines output are those with errors. + + @item /LIST + @cindex @option{/LIST} (@code{GNAT COMPILE}) + This qualifier causes a full listing of + the file to be generated. The output might look as follows: + + @smallexample + @group + @cartouche + 1. procedure E is + 2. V : Integer; + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + 5. begin + 6. return Q + Q; + 7. end; + 8. begin + 9. V := X + X; + 10.end E; + @end cartouche + @end group + @end smallexample + + @noindent + @findex SYS$ERROR + When you specify the @option{/REPORT_ERRORS=VERBOSE} or @option{/LIST} qualifiers and + standard output is redirected, a brief summary is written to + @file{SYS$ERROR} (standard error) giving the number of error messages and + warning messages generated. + + @item /UNIQUE_ERROR_TAG + @cindex @option{/UNIQUE_ERROR_TAG} (@code{GNAT COMPILE}) + This qualifier forces all error messages to be preceded by the unique + string "error:". This means that error messages take a few more + characters in space, but allows easy searching for and identification + of error messages. + + @item /WARNINGS=BRIEF + @cindex @option{/WARNINGS=BRIEF} (@code{GNAT COMPILE}) + This qualifier causes GNAT to generate the + brief format error messages to @file{SYS$ERROR} (the standard error + file) as well as the verbose + format message or full listing (which as usual is written to + @file{SYS$OUTPUT} (the standard output file). + + @item /ERROR_LIMIT=@var{n} + @cindex @option{/ERROR_LIMIT} (@code{GNAT COMPILE}) + @var{n} is a decimal integer in the + range of 1 to 999 and limits the number of error messages to be + generated. For example, using @option{/ERROR_LIMIT=2} might yield + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + E.ADB:3:04: Incorrect spelling of keyword "function" + E.ADB:5:35: missing ".." + fatal error: maximum errors reached + compilation abandoned + @end smallexample + + @item /REPORT_ERRORS=FULL + @cindex @option{/REPORT_ERRORS=FULL} (@code{GNAT COMPILE}) + @cindex Error messages, suppressing + Normally, the compiler suppresses error messages that are likely to be + redundant. This qualifier causes all error + messages to be generated. In particular, in the case of + references to undefined variables. If a given variable is referenced + several times, the normal format of messages is + @smallexample + @iftex + @leftskip=.7cm + @end iftex + E.ADB:7:07: "V" is undefined (more references follow) + @end smallexample + + @noindent + where the parenthetical comment warns that there are additional + references to the variable @code{V}. Compiling the same program with the + @option{/REPORT_ERRORS=FULL} qualifier yields + + @smallexample + E.ADB:7:07: "V" is undefined + E.ADB:8:07: "V" is undefined + E.ADB:8:12: "V" is undefined + E.ADB:8:16: "V" is undefined + E.ADB:9:07: "V" is undefined + E.ADB:9:12: "V" is undefined + @end smallexample + + @item /TRY_SEMANTICS + @cindex @option{/TRY_SEMANTICS} (@code{GNAT COMPILE}) + In normal operation mode, the compiler first parses the program and + determines if there are any syntax errors. If there are, appropriate + error messages are generated and compilation is immediately terminated. + This qualifier tells + GNAT to continue with semantic analysis even if syntax errors have been + found. This may enable the detection of more errors in a single run. On + the other hand, the semantic analyzer is more likely to encounter some + internal fatal error when given a syntactically invalid tree. + + @item /FORCE_ALI + In normal operation mode, the @file{ali} file is not generated if any + illegalities are detected in the program. The use of @option{/FORCE_ALI} forces + generation of the @file{ali} file. This file is marked as being in + error, so it cannot be used for binding purposes, but it does contain + reasonably complete cross-reference information, and thus may be useful + for use by tools (e.g. semantic browsing tools or integrated development + environments) that are driven from the @file{ali} file. + + In addition, if @option{/TREE_OUTPUT} is also specified, then the tree file is + generated even if there are illegalities. It may be useful in this case + to also specify @option{/TRY_SEMANTICS} to ensure that full semantic processing + occurs. The resulting tree file can be processed by ASIS, for the purpose + of providing partial information about illegal units, but if the error + causes the tree to be badly malformed, then ASIS may crash during the + analysis. + + @end table + + @noindent + In addition to error messages, which correspond to illegalities as defined + in the Ada 95 Reference Manual, the compiler detects two kinds of warning + situations. + + @cindex Warning messages + First, the compiler considers some constructs suspicious and generates a + warning message to alert you to a possible error. Second, if the + compiler detects a situation that is sure to raise an exception at + run time, it generates a warning message. The following shows an example + of warning messages: + @smallexample + @iftex + @leftskip=.2cm + @end iftex + E.ADB:4:24: warning: creation of object may raise Storage_Error + E.ADB:10:17: warning: static value out of range + E.ADB:10:17: warning: "Constraint_Error" will be raised at run time + + @end smallexample + + @noindent + GNAT considers a large number of situations as appropriate + for the generation of warning messages. As always, warnings are not + definite indications of errors. For example, if you do an out-of-range + assignment with the deliberate intention of raising a + @code{Constraint_Error} exception, then the warning that may be + issued does not indicate an error. Some of the situations for which GNAT + issues warnings (at least some of the time) are given in the following + list, which is not necessarily complete. + + @itemize @bullet + @item + Possible infinitely recursive calls + + @item + Out-of-range values being assigned + + @item + Possible order of elaboration problems + + @item + Unreachable code + + @item + Fixed-point type declarations with a null range + + @item + Variables that are never assigned a value + + @item + Variables that are referenced before being initialized + + @item + Task entries with no corresponding accept statement + + @item + Duplicate accepts for the same task entry in a select + + @item + Objects that take too much storage + + @item + Unchecked conversion between types of differing sizes + + @item + Missing return statements along some execution paths in a function + + @item + Incorrect (unrecognized) pragmas + + @item + Incorrect external names + + @item + Allocation from empty storage pool + + @item + Potentially blocking operations in protected types + + @item + Suspicious parenthesization of expressions + + @item + Mismatching bounds in an aggregate + + @item + Attempt to return local value by reference + + @item + Unrecognized pragmas + + @item + Premature instantiation of a generic body + + @item + Attempt to pack aliased components + + @item + Out of bounds array subscripts + + @item + Wrong length on string assignment + + @item + Violations of style rules if style checking is enabled + + @item + Unused with clauses + + @item + Bit_Order usage that does not have any effect + + @item + Compile time biased rounding of floating-point constant + + @item + Standard.Duration used to resolve universal fixed expression + + @item + Dereference of possibly null value + + @item + Declaration that is likely to cause storage error + + @item + Internal GNAT unit with'ed by application unit + + @item + Values known to be out of range at compile time + + @item + Unreferenced labels and variables + + @item + Address overlays that could clobber memory + + @item + Unexpected initialization when address clause present + + @item + Bad alignment for address clause + + @item + Useless type conversions + + @item + Redundant assignment statements + + @item + Accidental hiding of name by child unit + + @item + Unreachable code + + @item + Access before elaboration detected at compile time + + @item + A range in a @code{for} loop that is known to be null or might be null + + @end itemize + + @noindent + The following qualifiers are available to control the handling of + warning messages: + + @table @code + @item /WARNINGS=OPTIONAL (activate all optional errors) + @cindex @option{/WARNINGS=OPTIONAL} (@code{GNAT COMPILE}) + This qualifier activates most optional warning messages, see remaining list + in this section for details on optional warning messages that can be + individually controlled. The warnings that are not turned on by this + qualifier are @option{/WARNINGS=BIASED_ROUNDING} (biased rounding), + @option{/WARNINGS=IMPLICIT_DEREFERENCE} (implicit dereferencing), + and @option{/WARNINGS=HIDING} (hiding). All other optional warnings are + turned on. + + @item /WARNINGS=NOOPTIONAL (suppress all optional errors) + @cindex @option{/WARNINGS=NOOPTIONAL} (@code{GNAT COMPILE}) + This qualifier suppresses all optional warning messages, see remaining list + in this section for details on optional warning messages that can be + individually controlled. + + @item /WARNINGS=BIASED_ROUNDING (activate warnings on biased rounding) + @cindex @option{/WARNINGS=BIASED_ROUNDING} (@code{GNAT COMPILE}) + @cindex Rounding, biased + @cindex Biased rounding + If a static floating-point expression has a value that is exactly half + way between two adjacent machine numbers, then the rules of Ada + (Ada Reference Manual, section 4.9(38)) require that this rounding + be done away from zero, even if the normal unbiased rounding rules + at run time would require rounding towards zero. This warning message + alerts you to such instances where compile-time rounding and run-time + rounding are not equivalent. If it is important to get proper run-time + rounding, then you can force this by making one of the operands into + a variable. The default is that such warnings are not generated. + Note that @option{/WARNINGS=OPTIONAL} does not affect the setting of + this warning option. + + @item /WARNINGS=NOBIASED_ROUNDING (suppress warnings on biased rounding) + @cindex @option{/WARNINGS=NOBIASED_ROUNDING} (@code{GNAT COMPILE}) + This qualifier disables warnings on biased rounding. + + @item /WARNINGS=CONDITIONALS (activate warnings on conditionals) + @cindex @option{/WARNINGS=CONDITIONALS} (@code{GNAT COMPILE}) + @cindex Conditionals, constant + This qualifier activates warnings for conditional expressions used in + tests that are known to be True or False at compile time. The default + is that such warnings are not generated. + This warning can also be turned on using @option{/WARNINGS=OPTIONAL}. + + @item /WARNINGS=NOCONDITIONALS (suppress warnings on conditionals) + @cindex @option{/WARNINGS=NOCONDITIONALS} (@code{GNAT COMPILE}) + This qualifier suppresses warnings for conditional expressions used in + tests that are known to be True or False at compile time. + + @item /WARNINGS=IMPLICIT_DEREFERENCE (activate warnings on implicit dereferencing) + @cindex @option{/WARNINGS=IMPLICIT_DEREFERENCE} (@code{GNAT COMPILE}) + If this qualifier is set, then the use of a prefix of an access type + in an indexed component, slice, or selected component without an + explicit @code{.all} will generate a warning. With this warning + enabled, access checks occur only at points where an explicit + @code{.all} appears in the source code (assuming no warnings are + generated as a result of this qualifier). The default is that such + warnings are not generated. + Note that @option{/WARNINGS=OPTIONAL} does not affect the setting of + this warning option. + + @item /WARNINGS=NOIMPLICIT_DEREFERENCE (suppress warnings on implicit dereferencing) + @cindex @option{/WARNINGS=NOIMPLICIT_DEREFERENCE} (@code{GNAT COMPILE}) + @cindex Implicit dereferencing + @cindex Dereferencing, implicit + This qualifier suppresses warnings for implicit deferences in + indexed components, slices, and selected components. + + @item /WARNINGS=ERROR (treat warnings as errors) + @cindex @option{/WARNINGS=ERROR} (@code{GNAT COMPILE}) + @cindex Warnings, treat as error + This qualifier causes warning messages to be treated as errors. + The warning string still appears, but the warning messages are counted + as errors, and prevent the generation of an object file. + + @item /WARNINGS=UNREFERENCED_FORMALS (activate warnings on unreferenced formals) + @cindex @option{/WARNINGS=UNREFERENCED_FORMALS} (@code{GNAT COMPILE}) + @cindex Formals, unreferenced + This qualifier causes a warning to be generated if a formal parameter + is not referenced in the body of the subprogram. This warning can + also be turned on using @option{/WARNINGS=OPTIONAL} or @option{/WARNINGS=UNUSED}. + + @item /WARNINGS=NOUNREFERENCED_FORMALS (suppress warnings on unreferenced formals) + @cindex @option{/WARNINGS=NOUNREFERENCED_FORMALS} (@code{GNAT COMPILE}) + This qualifier suppresses warnings for unreferenced formal + parameters. Note that the + combination @option{/WARNINGS=UNUSED} followed by @option{/WARNINGS=NOUNREFERENCED_FORMALS} has the + effect of warning on unreferenced entities other than subprogram + formals. + + @item /WARNINGS=HIDING (activate warnings on hiding) + @cindex @option{/WARNINGS=HIDING} (@code{GNAT COMPILE}) + @cindex Hiding of Declarations + This qualifier activates warnings on hiding declarations. + A declaration is considered hiding + if it is for a non-overloadable entity, and it declares an entity with the + same name as some other entity that is directly or use-visible. The default + is that such warnings are not generated. + Note that @option{/WARNINGS=OPTIONAL} does not affect the setting of this warning option. + + @item /WARNINGS=NOHIDING (suppress warnings on hiding) + @cindex @option{/WARNINGS=NOHIDING} (@code{GNAT COMPILE}) + This qualifier suppresses warnings on hiding declarations. + + @item /WARNINGS=IMPLEMENTATION (activate warnings on implementation units). + @cindex @option{/WARNINGS=IMPLEMENTATION} (@code{GNAT COMPILE}) + This qualifier activates warnings for a @code{with} of an internal GNAT + implementation unit, defined as any unit from the @code{Ada}, + @code{Interfaces}, @code{GNAT}, + @code{DEC}, or @code{System} + hierarchies that is not + documented in either the Ada Reference Manual or the GNAT + Programmer's Reference Manual. Such units are intended only + for internal implementation purposes and should not be @code{with}'ed + by user programs. The default is that such warnings are generated + This warning can also be turned on using @option{/WARNINGS=OPTIONAL}. + + @item /WARNINGS=NOIMPLEMENTATION (disable warnings on implementation units). + @cindex @option{/WARNINGS=NOIMPLEMENTATION} (@code{GNAT COMPILE}) + This qualifier disables warnings for a @code{with} of an internal GNAT + implementation unit. + + @item /WARNINGS=ELABORATION (activate warnings on elaboration pragmas) + @cindex @option{/WARNINGS=ELABORATION} (@code{GNAT COMPILE}) + @cindex Elaboration, warnings + This qualifier activates warnings on missing pragma Elaborate_All statements. + See the section in this guide on elaboration checking for details on + when such pragma should be used. The default is that such warnings + are not generated. + This warning can also be turned on using @option{/WARNINGS=OPTIONAL}. + + @item /WARNINGS=NOELABORATION (suppress warnings on elaboration pragmas) + @cindex @option{/WARNINGS=NOELABORATION} (@code{GNAT COMPILE}) + This qualifier suppresses warnings on missing pragma Elaborate_All statements. + See the section in this guide on elaboration checking for details on + when such pragma should be used. + + @item /WARNINGS=OVERLAYS (activate warnings on address clause overlays) + @cindex @option{/WARNINGS=OVERLAYS} (@code{GNAT COMPILE}) + @cindex Address Clauses, warnings + This qualifier activates warnings for possibly unintended initialization + effects of defining address clauses that cause one variable to overlap + another. The default is that such warnings are generated. + This warning can also be turned on using @option{/WARNINGS=OPTIONAL}. + + @item /WARNINGS=NOOVERLAYS (suppress warnings on address clause overlays) + @cindex @option{/WARNINGS=NOOVERLAYS} (@code{GNAT COMPILE}) + This qualifier suppresses warnings on possibly unintended initialization + effects of defining address clauses that cause one variable to overlap + another. + + @item -gnatwp (activate warnings on ineffective pragma Inlines) + @cindex @option{-gnatwp} (@code{GNAT COMPILE}) + @cindex Inlining, warnings + This qualifier activates warnings for failure of front end inlining + (activated by @option{-gnatN}) to inline a particular call. There are + many reasons for not being able to inline a call, including most + commonly that the call is too complex to inline. + This warning can also be turned on using @option{/WARNINGS=OPTIONAL}. + + @item -gnatwP (suppress warnings on ineffective pragma Inlines) + @cindex @option{-gnatwP} (@code{GNAT COMPILE}) + This qualifier suppresses warnings on ineffective pragma Inlines. If the + inlining mechanism cannot inline a call, it will simply ignore the + request silently. + + @item /WARNINGS=REDUNDANT (activate warnings on redundant constructs) + @cindex @option{/WARNINGS=REDUNDANT} (@code{GNAT COMPILE}) + This qualifier activates warnings for redundant constructs. The following + is the current list of constructs regarded as redundant: + This warning can also be turned on using @option{/WARNINGS=OPTIONAL}. + + @itemize @bullet + @item + Assignment of an item to itself. + @item + Type conversion that converts an expression to its own type. + @item + Use of the attribute @code{Base} where @code{typ'Base} is the same + as @code{typ}. + @item + Use of pragma @code{Pack} when all components are placed by a record + representation clause. + @end itemize + + @item /WARNINGS=NOREDUNDANT (suppress warnings on redundant constructs) + @cindex @option{/WARNINGS=NOREDUNDANT} (@code{GNAT COMPILE}) + This qualifier suppresses warnings for redundant constructs. + + @item /WARNINGS=SUPPRESS (suppress all warnings) + @cindex @option{/WARNINGS=SUPPRESS} (@code{GNAT COMPILE}) + This qualifier completely suppresses the + output of all warning messages from the GNAT front end. + Note that it does not suppress warnings from the @code{GNAT COMPILE} back end. + To suppress these back end warnings as well, use the qualifier @code{-w} + in addition to @option{/WARNINGS=SUPPRESS}. + + @item /WARNINGS=UNUSED (activate warnings on unused entities) + @cindex @option{/WARNINGS=UNUSED} (@code{GNAT COMPILE}) + This qualifier activates warnings to be generated for entities that + are defined but not referenced, and for units that are @code{with}'ed + and not + referenced. In the case of packages, a warning is also generated if + no entities in the package are referenced. This means that if the package + is referenced but the only references are in @code{use} + clauses or @code{renames} + declarations, a warning is still generated. A warning is also generated + for a generic package that is @code{with}'ed but never instantiated. + In the case where a package or subprogram body is compiled, and there + is a @code{with} on the corresponding spec + that is only referenced in the body, + a warning is also generated, noting that the + @code{with} can be moved to the body. The default is that + such warnings are not generated. + This qualifier also activates warnings on unreferenced formals + (it is includes the effect of @option{/WARNINGS=UNREFERENCED_FORMALS}). + This warning can also be turned on using @option{/WARNINGS=OPTIONAL}. + + @item /WARNINGS=NOUNUSED (suppress warnings on unused entities) + @cindex @option{/WARNINGS=NOUNUSED} (@code{GNAT COMPILE}) + This qualifier suppresses warnings for unused entities and packages. + It also turns off warnings on unreferenced formals (and thus includes + the effect of @option{/WARNINGS=NOUNREFERENCED_FORMALS}). + + @noindent + A string of warning parameters can be used in the same parameter. For example: + + @smallexample + -gnatwaLe + @end smallexample + + @noindent + Would turn on all optional warnings except for elaboration pragma warnings, + and also specify that warnings should be treated as errors. + + @item -w + @cindex @code{-w} + This qualifier suppresses warnings from the @code{GNAT COMPILE} backend. It may be + used in conjunction with @option{/WARNINGS=SUPPRESS} to ensure that all warnings + are suppressed during the entire compilation process. + + @end table + + @node Debugging and Assertion Control + @subsection Debugging and Assertion Control + + @table @code + @item /CHECKS=ASSERTIONS + @cindex @option{/CHECKS=ASSERTIONS} (@code{GNAT COMPILE}) + @findex Assert + @findex Debug + @cindex Assertions + + @noindent + The pragmas @code{Assert} and @code{Debug} normally have no effect and + are ignored. This qualifier, where @samp{a} stands for assert, causes + @code{Assert} and @code{Debug} pragmas to be activated. + + The pragmas have the form: + + @smallexample + @group + @cartouche + @b{pragma} Assert (@var{Boolean-expression} [, + @var{static-string-expression}]) + @b{pragma} Debug (@var{procedure call}) + @end cartouche + @end group + @end smallexample + + @noindent + The @code{Assert} pragma causes @var{Boolean-expression} to be tested. + If the result is @code{True}, the pragma has no effect (other than + possible side effects from evaluating the expression). If the result is + @code{False}, the exception @code{Assert_Failure} declared in the package + @code{System.Assertions} is + raised (passing @var{static-string-expression}, if present, as the + message associated with the exception). If no string expression is + given the default is a string giving the file name and line number + of the pragma. + + The @code{Debug} pragma causes @var{procedure} to be called. Note that + @code{pragma Debug} may appear within a declaration sequence, allowing + debugging procedures to be called between declarations. + + @item /DEBUG[=debug-level] + @itemx /NODEBUG + Specifies how much debugging information is to be included in + the resulting object file where 'debug-level' is one of the following: + @table @code + @item TRACEBACK (default) + Include both debugger symbol records and traceback + the object file. + @item ALL + Include both debugger symbol records and traceback in + object file. + @item NONE + Excludes both debugger symbol records and traceback + the object file. Same as /NODEBUG. + @item SYMBOLS + Includes only debugger symbol records in the object + file. Note that this doesn't include traceback information. + @end table + @end table + + @node Validity Checking + @subsection Validity Checking + @findex Validity Checking + + @noindent + The Ada 95 Reference Manual has specific requirements for checking + for invalid values. In particular, RM 13.9.1 requires that the + evaluation of invalid values (for example from unchecked conversions), + not result in erroneous execution. In GNAT, the result of such an + evaluation in normal default mode is to either use the value + unmodified, or to raise Constraint_Error in those cases where use + of the unmodified value would cause erroneous execution. The cases + where unmodified values might lead to erroneous execution are case + statements (where a wild jump might result from an invalid value), + and subscripts on the left hand side (where memory corruption could + occur as a result of an invalid value). + + The @option{-gnatVx} qualifier allows more control over the validity checking + mode. The @code{x} argument here is a string of letters which control which + validity checks are performed in addition to the default checks described + above. + + @itemize @bullet + @item + @option{-gnatVc} Validity checks for copies + + The right hand side of assignments, and the initializing values of + object declarations are validity checked. + + @item + @option{/VALIDITY_CHECKING=RM} Default (RM) validity checks + + Some validity checks are done by default following normal Ada semantics + (RM 13.9.1 (9-11)). + A check is done in case statements that the expression is within the range + of the subtype. If it is not, Constraint_Error is raised. + For assignments to array components, a check is done that the expression used + as index is within the range. If it is not, Constraint_Error is raised. + Both these validity checks may be turned off using qualifier @option{-gnatVD}. + They are turned on by default. If @option{-gnatVD} is specified, a subsequent + qualifier @option{/VALIDITY_CHECKING=RM} will leave the checks turned on. + Qualifier @option{-gnatVD} should be used only if you are sure that all such + expressions have valid values. If you use this qualifier and invalid values + are present, then the program is erroneous, and wild jumps or memory + overwriting may occur. + + @item + @option{-gnatVi} Validity checks for @code{in} mode parameters + + Arguments for parameters of mode @code{in} are validity checked in function + and procedure calls at the point of call. + + @item + @option{-gnatVm} Validity checks for @code{in out} mode parameters + + Arguments for parameters of mode @code{in out} are validity checked in + procedure calls at the point of call. The @code{'m'} here stands for + modify, since this concerns parameters that can be modified by the call. + Note that there is no specific option to test @code{out} parameters, + but any reference within the subprogram will be tested in the usual + manner, and if an invalid value is copied back, any reference to it + will be subject to validity checking. + + @item + @option{-gnatVo} Validity checks for operator and attribute operands + + Arguments for predefined operators and attributes are validity checked. + This includes all operators in package @code{Standard}, + the shift operators defined as intrinsic in package @code{Interfaces} + and operands for attributes such as @code{Pos}. + + @item + @option{-gnatVr} Validity checks for function returns + + The expression in @code{return} statements in functions is validity + checked. + + @item + @option{-gnatVs} Validity checks for subscripts + + All subscripts expressions are checked for validity, whether they appear + on the right side or left side (in default mode only left side subscripts + are validity checked). + + @item + @option{-gnatVt} Validity checks for tests + + Expressions used as conditions in @code{if}, @code{while} or @code{exit} + statements are checked, as well as guard expressions in entry calls. + + @item + @option{/VALIDITY_CHECKING=FULL} Validity checks for floating-point values + + In the absence of this qualifier, validity checking occurs only for discrete + values. If @option{/VALIDITY_CHECKING=FULL} is specified, then validity checking also applies + for floating-point values, and NaN's and infinities are considered invalid, + as well as out of range values for constrained types. Note that this means + that standard @code{IEEE} infinity mode is not allowed. The exact contexts + in which floating-point values are checked depends on the setting of other + options. For example @option{-gnatVif} or @option{-gnatVfi} (the order does + not matter) specifies that floating-point parameters of mode @code{in} should + be validity checked. + + @item + @option{-gnatVa} All validity checks + + All the above validity checks are turned on. That is @option{-gnatVa} is + equivalent to @code{gnatVcdfimorst}. + + @item + @option{-gnatVn} No validity checks + + This qualifier turns off all validity checking, including the default checking + for case statements and left hand side subscripts. Note that the use of + the qualifier @option{/CHECKS=SUPPRESS_ALL} supresses all run-time checks, including + validity checks, and thus implies @option{-gnatVn}. + + @end itemize + + The @option{/VALIDITY_CHECKING} qualifier may be followed by a string of letters to turn on + a series of validity checking options. For example, @option{-gnatVcr} specifies + that in addition to the default validity checking, copies and function + return expressions be validity checked. In order to make it easier to specify + a set of options, the upper case letters @code{CDFIMORST} may be used to turn + off the corresponding lower case option, so for example @option{-gnatVaM} turns + on all validity checking options except for checking of @code{in out} + procedure arguments. + + The specification of additional validity checking generates extra code (and + in the case of @option{-gnatva} the code expansion can be substantial. However, + these additional checks can be very useful in smoking out cases of + uninitialized variables, incorrect use of unchecked conversion, and other + errors leading to invalid values. The use of pragma @code{Initialize_Scalars} + is useful in conjunction with the extra validity checking, since this + ensures that wherever possible uninitialized variables have invalid values. + + See also the pragma @code{Validity_Checks} which allows modification of + the validity checking mode at the program source level, and also allows for + temporary disabling of validity checks. + + @node Style Checking + @subsection Style Checking + @findex Style checking + + @noindent + The /STYLE=@var{(option,option,..)} qualifier causes the compiler to + enforce specified style rules. A limited set of style rules has been used + in writing the GNAT sources themselves. This qualifier allows user programs + to activate all or some of these checks. If the source program fails a + specified style check, an appropriate warning message is given, preceded by + the character sequence "(style)". + (OPTION,OPTION,..) is a sequence of keywords + indicating the particular style + checks to be performed. The following checks are defined: + + @table @code + @item 1-9 (specify indentation level) + If a digit from 1-9 appears in the string after @option{/STYLE=} then proper + indentation is checked, with the digit indicating the indentation level + required. The general style of required indentation is as specified by + the examples in the Ada Reference Manual. Full line comments must be + aligned with the @code{--} starting on a column that is a multiple of + the alignment level. + + @item ATTRIBUTE (check attribute casing) + If the word ATTRIBUTE appears in the string after @option{/STYLE=} then + attribute names, including the case of keywords such as @code{digits} + used as attributes names, must be written in mixed case, that is, the + initial letter and any letter following an underscore must be uppercase. + All other letters must be lowercase. + + @item BLANKS (blanks not allowed at statement end) + If the word BLANKS appears in the string after @option{/STYLE=} then + trailing blanks are not allowed at the end of statements. The purpose of this + rule, together with h (no horizontal tabs), is to enforce a canonical format + for the use of blanks to separate source tokens. + + @item COMMENTS (check comments) + If the word COMMENTS appears in the string after @option{/STYLE=} then + comments must meet the following set of rules: + + @itemize @bullet + + @item + The "--" that starts the column must either start in column one, or else + at least one blank must precede this sequence. + + @item + Comments that follow other tokens on a line must have at least one blank + following the "--" at the start of the comment. + + @item + Full line comments must have two blanks following the "--" that starts + the comment, with the following exceptions. + + @item + A line consisting only of the "--" characters, possibly preceded by blanks + is permitted. + + @item + A comment starting with "--x" where x is a special character is permitted. + This alows proper processing of the output generated by specialized tools + including @code{GNAT PREPROCESS} (where --! is used) and the SPARK annnotation + language (where --# is used). For the purposes of this rule, a special + character is defined as being in one of the ASCII ranges + 16#21#..16#2F# or 16#3A#..16#3F#. + + @item + A line consisting entirely of minus signs, possibly preceded by blanks, is + permitted. This allows the construction of box comments where lines of minus + signs are used to form the top and bottom of the box. + + @item + If a comment starts and ends with "--" is permitted as long as at least + one blank follows the initial "--". Together with the preceding rule, + this allows the construction of box comments, as shown in the following + example: + @smallexample + --------------------------- + -- This is a box comment -- + -- with two text lines. -- + --------------------------- + @end smallexample + @end itemize + + @item END (check end/exit labels) + If the word END appears in the string after @option{/STYLE=} then + optional labels on @code{end} statements ending subprograms and on + @code{exit} statements exiting named loops, are required to be present. + + @item VTABS (no form feeds or vertical tabs) + If the word VTABS appears in the string after @option{/STYLE=} then + neither form feeds nor vertical tab characters are not permitted + in the source text. + + @item HTABS (no horizontal tabs) + If the word HTABS appears in the string after @option{/STYLE=} then + horizontal tab characters are not permitted in the source text. + Together with the b (no blanks at end of line) check, this + enforces a canonical form for the use of blanks to separate + source tokens. + + @item IF_THEN (check if-then layout) + If the word IF_THEN appears in the string after @option{/STYLE=}, + then the keyword @code{then} must appear either on the same + line as corresponding @code{if}, or on a line on its own, lined + up under the @code{if} with at least one non-blank line in between + containing all or part of the condition to be tested. + + @item KEYWORD (check keyword casing) + If the word KEYWORD appears in the string after @option{/STYLE=} then + all keywords must be in lower case (with the exception of keywords + such as @code{digits} used as attribute names to which this check + does not apply). + + @item LAYOUT (check layout) + If the word LAYOUT appears in the string after @option{/STYLE=} then + layout of statement and declaration constructs must follow the + recommendations in the Ada Reference Manual, as indicated by the + form of the syntax rules. For example an @code{else} keyword must + be lined up with the corresponding @code{if} keyword. + + There are two respects in which the style rule enforced by this check + option are more liberal than those in the Ada Reference Manual. First + in the case of record declarations, it is permissible to put the + @code{record} keyword on the same line as the @code{type} keyword, and + then the @code{end} in @code{end record} must line up under @code{type}. + For example, either of the following two layouts is acceptable: + + @smallexample + @group + @cartouche + @b{type} q @b{is record} + a : integer; + b : integer; + @b{end record}; + + @b{type} q @b{is} + @b{record} + a : integer; + b : integer; + @b{end record}; + @end cartouche + @end group + @end smallexample + + @noindent + Second, in the case of a block statement, a permitted alternative + is to put the block label on the same line as the @code{declare} or + @code{begin} keyword, and then line the @code{end} keyword up under + the block label. For example both the following are permitted: + + @smallexample + @group + @cartouche + Block : @b{declare} + A : Integer := 3; + @b{begin} + Proc (A, A); + @b{end} Block; + + Block : + @b{declare} + A : Integer := 3; + @b{begin} + Proc (A, A); + @b{end} Block; + @end cartouche + @end group + @end smallexample + + @noindent + The same alternative format is allowed for loops. For example, both of + the following are permitted: + + @smallexample + @group + @cartouche + Clear : @b{while} J < 10 @b{loop} + A (J) := 0; + @b{end loop} Clear; + + Clear : + @b{while} J < 10 @b{loop} + A (J) := 0; + @b{end loop} Clear; + @end cartouche + @end group + @end smallexample + + @item LINE_LENGTH (check maximum line length) + If the word LINE_LENGTH appears in the string after @option{/STYLE=} + then the length of source lines must not exceed 79 characters, including + any trailing blanks. The value of 79 allows convenient display on an + 80 character wide device or window, allowing for possible special + treatment of 80 character lines. + + @item MAX_LENGTH=nnn (set maximum line length) + If the sequence MAX_LENGTH=nnn, where nnn is a decimal number, appears in + the string after @option{/STYLE=} then the length of lines must not exceed the + given value. + + @item STANDARD_CASING (check casing of entities in Standard) + If the word STANDARD_CASING appears in the string + after @option{/STYLE=} then any identifier from Standard must be cased + to match the presentation in the Ada Reference Manual (for example, + @code{Integer} and @code{ASCII.NUL}). + + @item ORDERED_SUBPROGRAMS (check order of subprogram bodies) + If the word ORDERED_SUBPROGRAMS appears in the string + after @option{/STYLE=} then all subprogram bodies in a given scope + (e.g. a package body) must be in alphabetical order. The ordering + rule uses normal Ada rules for comparing strings, ignoring casing + of letters, except that if there is a trailing numeric suffix, then + the value of this suffix is used in the ordering (e.g. Junk2 comes + before Junk10). + + @item PRAGMA (check pragma casing) + If the word PRAGMA appears in the string after @option{/STYLE=} then + pragma names must be written in mixed case, that is, the + initial letter and any letter following an underscore must be uppercase. + All other letters must be lowercase. + + @item REFERENCES (check references) + If the word REFERENCES appears in the string after @option{/STYLE=} + then all identifier references must be cased in the same way as the + corresponding declaration. No specific casing style is imposed on + identifiers. The only requirement is for consistency of references + with declarations. + + @item SPECS (check separate specs) + If the word SPECS appears in the string after @option{/STYLE=} then + separate declarations ("specs") are required for subprograms (a + body is not allowed to serve as its own declaration). The only + exception is that parameterless library level procedures are + not required to have a separate declaration. This exception covers + the most frequent form of main program procedures. + + @item TOKEN (check token spacing) + If the word TOKEN appears in the string after @option{/STYLE=} then + the following token spacing rules are enforced: + + @itemize @bullet + + @item + The keywords @code{abs} and @code{not} must be followed by a space. + + @item + The token @code{=>} must be surrounded by spaces. + + @item + The token @code{<>} must be preceded by a space or a left parenthesis. + + @item + Binary operators other than @code{**} must be surrounded by spaces. + There is no restriction on the layout of the @code{**} binary operator. + + @item + Colon must be surrounded by spaces. + + @item + Colon-equal (assignment) must be surrounded by spaces. + + @item + Comma must be the first non-blank character on the line, or be + immediately preceded by a non-blank character, and must be followed + by a space. + + @item + If the token preceding a left paren ends with a letter or digit, then + a space must separate the two tokens. + + @item + A right parenthesis must either be the first non-blank character on + a line, or it must be preceded by a non-blank character. + + @item + A semicolon must not be preceded by a space, and must not be followed by + a non-blank character. + + @item + A unary plus or minus may not be followed by a space. + + @item + A vertical bar must be surrounded by spaces. + @end itemize + + @noindent + In the above rules, appearing in column one is always permitted, that is, + counts as meeting either a requirement for a required preceding space, + or as meeting a requirement for no preceding space. + + Appearing at the end of a line is also always permitted, that is, counts + as meeting either a requirement for a following space, or as meeting + a requirement for no following space. + + @end table + + @noindent + If any of these style rules is violated, a message is generated giving + details on the violation. The initial characters of such messages are + always "(style)". Note that these messages are treated as warning + messages, so they normally do not prevent the generation of an object + file. The @option{/WARNINGS=ERROR} qualifier can be used to treat warning messages, + including style messages, as fatal errors. + + @noindent + The qualifier + /STYLE_CHECKS=ALL_BUILTIN + is equivalent to all checking + options enabled with + the exception of ORDERED_SUBPROGRAMS, + with an indentation level of 3. This is the standard + checking option that is used for the GNAT sources. + + @node Run-Time Checks + @subsection Run-Time Checks + @cindex Division by zero + @cindex Access before elaboration + @cindex Checks, division by zero + @cindex Checks, access before elaboration + + @noindent + If you compile with the default options, GNAT will insert many run-time + checks into the compiled code, including code that performs range + checking against constraints, but not arithmetic overflow checking for + integer operations (including division by zero) or checks for access + before elaboration on subprogram calls. All other run-time checks, as + required by the Ada 95 Reference Manual, are generated by default. + The following @code{GNAT COMPILE} qualifiers refine this default behavior: + + @table @code + @item /CHECKS=SUPPRESS_ALL + @cindex @option{/CHECKS=SUPPRESS_ALL} (@code{GNAT COMPILE}) + @cindex Suppressing checks + @cindex Checks, suppressing + @findex Suppress + Suppress all run-time checks as though @code{pragma Suppress (all_checks}) + had been present in the source. Validity checks are also suppressed (in + other words @option{/CHECKS=SUPPRESS_ALL} also implies @option{-gnatVn}. + Use this qualifier to improve the performance + of the code at the expense of safety in the presence of invalid data or + program bugs. + + @item /CHECKS=OVERFLOW + @cindex @option{/CHECKS=OVERFLOW} (@code{GNAT COMPILE}) + @cindex Overflow checks + @cindex Check, overflow + Enables overflow checking for integer operations. + This causes GNAT to generate slower and larger executable + programs by adding code to check for overflow (resulting in raising + @code{Constraint_Error} as required by standard Ada + semantics). These overflow checks correspond to situations in which + the true value of the result of an operation may be outside the base + range of the result type. The following example shows the distinction: + + @smallexample + X1 : Integer := Integer'Last; + X2 : Integer range 1 .. 5 := 5; + ... + X1 := X1 + 1; -- @option{/CHECKS=OVERFLOW} required to catch the Constraint_Error + X2 := X2 + 1; -- range check, @option{/CHECKS=OVERFLOW} has no effect here + @end smallexample + + @noindent + Here the first addition results in a value that is outside the base range + of Integer, and hence requires an overflow check for detection of the + constraint error. The second increment operation results in a violation + of the explicit range constraint, and such range checks are always + performed. Basically the compiler can assume that in the absence of + the @option{/CHECKS=OVERFLOW} qualifier that any value of type @code{xxx} is + in range of the base type of @code{xxx}. + + @findex Machine_Overflows + Note that the @option{/CHECKS=OVERFLOW} qualifier does not affect the code generated + for any floating-point operations; it applies only to integer + semantics). + For floating-point, GNAT has the @code{Machine_Overflows} + attribute set to @code{False} and the normal mode of operation is to + generate IEEE NaN and infinite values on overflow or invalid operations + (such as dividing 0.0 by 0.0). + + The reason that we distinguish overflow checking from other kinds of + range constraint checking is that a failure of an overflow check can + generate an incorrect value, but cannot cause erroneous behavior. This + is unlike the situation with a constraint check on an array subscript, + where failure to perform the check can result in random memory description, + or the range check on a case statement, where failure to perform the check + can cause a wild jump. + + Note again that @option{/CHECKS=OVERFLOW} is off by default, so overflow checking is + not performed in default mode. This means that out of the box, with the + default settings, GNAT does not do all the checks expected from the + language description in the Ada Reference Manual. If you want all constraint + checks to be performed, as described in this Manual, then you must + explicitly use the /CHECKS=OVERFLOW qualifier either on the @code{GNAT MAKE} or + @code{GNAT COMPILE} command. + + @item /CHECKS=ELABORATION + @cindex @option{/CHECKS=ELABORATION} (@code{GNAT COMPILE}) + @cindex Elaboration checks + @cindex Check, elaboration + Enables dynamic checks for access-before-elaboration + on subprogram calls and generic instantiations. + For full details of the effect and use of this qualifier, + @xref{Compiling Using GNAT COMPILE}. + @end table + + @findex Unsuppress + @noindent + The setting of these qualifiers only controls the default setting of the + checks. You may modify them using either @code{Suppress} (to remove + checks) or @code{Unsuppress} (to add back suppressed checks) pragmas in + the program source. + + @node Stack Overflow Checking + @subsection Stack Overflow Checking + @cindex Stack Overflow Checking + @cindex -fstack-check + + @noindent + For most operating systems, @code{GNAT COMPILE} does not perform stack overflow + checking by default. This means that if the main environment task or + some other task exceeds the available stack space, then unpredictable + behavior will occur. + + To activate stack checking, compile all units with the GNAT COMPILE option + @code{-fstack-check}. For example: + + @smallexample + GNAT COMPILE -fstack-check PACKAGE1.ADB + @end smallexample + + @noindent + Units compiled with this option will generate extra instructions to check + that any use of the stack (for procedure calls or for declaring local + variables in declare blocks) do not exceed the available stack space. + If the space is exceeded, then a @code{Storage_Error} exception is raised. + + For declared tasks, the stack size is always controlled by the size + given in an applicable @code{Storage_Size} pragma (or is set to + the default size if no pragma is used. + + For the environment task, the stack size depends on + system defaults and is unknown to the compiler. The stack + may even dynamically grow on some systems, precluding the + normal Ada semantics for stack overflow. In the worst case, + unbounded stack usage, causes unbounded stack expansion + resulting in the system running out of virtual memory. + + The stack checking may still work correctly if a fixed + size stack is allocated, but this cannot be guaranteed. + To ensure that a clean exception is signalled for stack + overflow, set the environment variable + @code{GNAT_STACK_LIMIT} to indicate the maximum + stack area that can be used, as in: + @cindex GNAT_STACK_LIMIT + + @smallexample + SET GNAT_STACK_LIMIT 1600 + @end smallexample + + @noindent + The limit is given in kilobytes, so the above declaration would + set the stack limit of the environment task to 1.6 megabytes. + Note that the only purpose of this usage is to limit the amount + of stack used by the environment task. If it is necessary to + increase the amount of stack for the environment task, then this + is an operating systems issue, and must be addressed with the + appropriate operating systems commands. + + @node Run-Time Control + @subsection Run-Time Control + + @table @code + @item -gnatT nnn + @cindex @option{-gnatT} (@code{GNAT COMPILE}) + @cindex Time Slicing + + @noindent + The @code{gnatT} qualifier can be used to specify the time-slicing value + to be used for task switching between equal priority tasks. The value + @code{nnn} is given in microseconds as a decimal integer. + + Setting the time-slicing value is only effective if the underlying thread + control system can accommodate time slicing. Check the documentation of + your operating system for details. Note that the time-slicing value can + also be set by use of pragma @code{Time_Slice} or by use of the + @code{t} qualifier in the GNAT BIND step. The pragma overrides a command + line argument if both are present, and the @code{t} qualifier for GNAT BIND + overrides both the pragma and the @code{GNAT COMPILE} command line qualifier. + @end table + + @node Using GNAT COMPILE for Syntax Checking + @subsection Using @code{GNAT COMPILE} for Syntax Checking + @table @code + @item /SYNTAX_ONLY + @cindex @option{/SYNTAX_ONLY} (@code{GNAT COMPILE}) + + Run GNAT in syntax checking only mode. For + example, the command + + @smallexample + $ GNAT COMPILE /SYNTAX_ONLY X.ADB + @end smallexample + + @noindent + compiles file @file{X.ADB} in syntax-check-only mode. You can check a + series of files in a single command + . + + You may use other qualifiers in conjunction with @option{/SYNTAX_ONLY}. In + particular, @option{/LIST} and @option{/REPORT_ERRORS=VERBOSE} are useful to control the + format of any generated error messages. + + The output is simply the error messages, if any. No object file or ALI + file is generated by a syntax-only compilation. Also, no units other + than the one specified are accessed. For example, if a unit @code{X} + @code{with}'s a unit @code{Y}, compiling unit @code{X} in syntax + check only mode does not access the source file containing unit + @code{Y}. + + @cindex Multiple units, syntax checking + Normally, GNAT allows only a single unit in a source file. However, this + restriction does not apply in syntax-check-only mode, and it is possible + to check a file containing multiple compilation units concatenated + together. This is primarily used by the @code{GNAT CHOP} utility + (@pxref{Renaming Files Using GNAT CHOP}). + @end table + + @node Using GNAT COMPILE for Semantic Checking + @subsection Using @code{GNAT COMPILE} for Semantic Checking + @table @code + @item /NOLOAD + @cindex @option{/NOLOAD} (@code{GNAT COMPILE}) + + Causes the compiler to operate in semantic check mode, + with full checking for all illegalities specified in the + Ada 95 Reference Manual, but without generation of any object code + (no object file is generated). + + Because dependent files must be accessed, you must follow the GNAT + semantic restrictions on file structuring to operate in this mode: + + @itemize @bullet + @item + The needed source files must be accessible + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item + Each file must contain only one compilation unit. + + @item + The file name and unit name must match (@pxref{File Naming Rules}). + @end itemize + + The output consists of error messages as appropriate. No object file is + generated. An @file{ALI} file is generated for use in the context of + cross-reference tools, but this file is marked as not being suitable + for binding (since no object file is generated). + The checking corresponds exactly to the notion of + legality in the Ada 95 Reference Manual. + + Any unit can be compiled in semantics-checking-only mode, including + units that would not normally be compiled (subunits, + and specifications where a separate body is present). + @end table + + @node Compiling Ada 83 Programs + @subsection Compiling Ada 83 Programs + @table @code + @cindex Ada 83 compatibility + @item /83 + @cindex @option{/83} (@code{GNAT COMPILE}) + @cindex ACVC, Ada 83 tests + + @noindent + Although GNAT is primarily an Ada 95 compiler, it accepts this qualifier to + specify that an Ada 83 program is to be compiled in Ada83 mode. If you specify + this qualifier, GNAT rejects most Ada 95 extensions and applies Ada 83 semantics + where this can be done easily. + It is not possible to guarantee this qualifier does a perfect + job; for example, some subtle tests, such as are + found in earlier ACVC tests (that have been removed from the ACVC suite for Ada + 95), may not compile correctly. However, for most purposes, using + this qualifier should help to ensure that programs that compile correctly + under the @option{/83} qualifier can be ported easily to an Ada 83 + compiler. This is the main use of the qualifier. + + With few exceptions (most notably the need to use @code{<>} on + @cindex Generic formal parameters + unconstrained generic formal parameters, the use of the new Ada 95 + keywords, and the use of packages + with optional bodies), it is not necessary to use the + @option{/83} qualifier when compiling Ada 83 programs, because, with rare + exceptions, Ada 95 is upwardly compatible with Ada 83. This + means that a correct Ada 83 program is usually also a correct Ada 95 + program. + + @end table + + @node Character Set Control + @subsection Character Set Control + @table @code + @item /IDENTIFIER_CHARACTER_SET=@var{c} + @cindex @code{/IDENTIFIER_CHARACTER_SET} (@code{GNAT COMPILE}) + + @noindent + Normally GNAT recognizes the Latin-1 character set in source program + identifiers, as described in the Ada 95 Reference Manual. + This qualifier causes + GNAT to recognize alternate character sets in identifiers. @var{c} is a + single character or word indicating the character set, as follows: + + @table @code + @item 1 + Latin-1 identifiers + + @item 2 + Latin-2 letters allowed in identifiers + + @item 3 + Latin-3 letters allowed in identifiers + + @item 4 + Latin-4 letters allowed in identifiers + + @item 5 + Latin-5 (Cyrillic) letters allowed in identifiers + + @item 9 + Latin-9 letters allowed in identifiers + + @item PC + IBM PC letters (code page 437) allowed in identifiers + + @item PC850 + IBM PC letters (code page 850) allowed in identifiers + + @item FULL_UPPER + Full upper-half codes allowed in identifiers + + @item NO_UPPER + No upper-half codes allowed in identifiers + + @item WIDE + Wide-character codes (that is, codes greater than 255) + allowed in identifiers + @end table + + @xref{Foreign Language Representation}, for full details on the + implementation of these character sets. + + @item /WIDE_CHARACTER_ENCODING=@var{e} + @cindex @code{/WIDE_CHARACTER_ENCODING} (@code{GNAT COMPILE}) + Specify the method of encoding for wide characters. + @var{e} is one of the following: + + @table @code + + @item HEX + Hex encoding (brackets coding also recognized) + + @item UPPER + Upper half encoding (brackets encoding also recognized) + + @item SHIFT_JIS + Shift/JIS encoding (brackets encoding also recognized) + + @item EUC + EUC encoding (brackets encoding also recognized) + + @item UTF8 + UTF-8 encoding (brackets encoding also recognized) + + @item BRACKETS + Brackets encoding only (default value) + @end table + For full details on the these encoding + methods see @xref{Wide Character Encodings}. + Note that brackets coding is always accepted, even if one of the other + options is specified, so for example @option{/WIDE_CHARACTER_ENCODING=UTF8} specifies that both + brackets and @code{UTF-8} encodings will be recognized. The units that are + with'ed directly or indirectly will be scanned using the specified + representation scheme, and so if one of the non-brackets scheme is + used, it must be used consistently throughout the program. However, + since brackets encoding is always recognized, it may be conveniently + used in standard libraries, allowing these libraries to be used with + any of the available coding schemes. + scheme. If no @option{/WIDE_CHARACTER_ENCODING=?} parameter is present, then the default + representation is Brackets encoding only. + + Note that the wide character representation that is specified (explicitly + or by default) for the main program also acts as the default encoding used + for Wide_Text_IO files if not specifically overridden by a WCEM form + parameter. + + @end table + @node File Naming Control + @subsection File Naming Control + + @table @code + @item /FILE_NAME_MAX_LENGTH=@var{n} + @cindex @option{/FILE_NAME_MAX_LENGTH} (@code{GNAT COMPILE}) + Activates file name "krunching". @var{n}, a decimal integer in the range + 1-999, indicates the maximum allowable length of a file name (not + including the @file{.ADS} or @file{.ADB} extension). The default is not + to enable file name krunching. + + For the source file naming rules, @xref{File Naming Rules}. + @end table + + @node Subprogram Inlining Control + @subsection Subprogram Inlining Control + + @table @code + @item /INLINE=PRAGMA + @cindex @option{/INLINE=PRAGMA} (@code{GNAT COMPILE}) + GNAT recognizes and processes @code{Inline} pragmas. However, for the + inlining to actually occur, optimization must be enabled. To enable + inlining across unit boundaries, this is, inlining a call in one unit of + a subprogram declared in a @code{with}'ed unit, you must also specify + this qualifier. + In the absence of this qualifier, GNAT does not attempt + inlining across units and does not need to access the bodies of + subprograms for which @code{pragma Inline} is specified if they are not + in the current unit. + + If you specify this qualifier the compiler will access these bodies, + creating an extra source dependency for the resulting object file, and + where possible, the call will be inlined. + For further details on when inlining is possible + see @xref{Inlining of Subprograms}. + + @item -gnatN + @cindex @option{-gnatN} (@code{GNAT COMPILE}) + The front end inlining activated by this qualifier is generally more extensive, + and quite often more effective than the standard @option{/INLINE=PRAGMA} inlining mode. + It will also generate additional dependencies. + + @end table + + @node Auxiliary Output Control + @subsection Auxiliary Output Control + + @table @code + @item /TREE_OUTPUT + @cindex @option{/TREE_OUTPUT} (@code{GNAT COMPILE}) + @cindex Writing internal trees + @cindex Internal trees, writing to file + Causes GNAT to write the internal tree for a unit to a file (with the + extension @file{.adt}. + This not normally required, but is used by separate analysis tools. + Typically + these tools do the necessary compilations automatically, so you should + not have to specify this qualifier in normal operation. + + @item /UNITS_LIST + @cindex @option{/UNITS_LIST} (@code{GNAT COMPILE}) + Print a list of units required by this compilation on @file{SYS$OUTPUT}. + The listing includes all units on which the unit being compiled depends + either directly or indirectly. + + @end table + + @node Debugging Control + @subsection Debugging Control + + @table @code + @cindex Debugging options + + @item /EXPAND_SOURCE + @cindex @option{/EXPAND_SOURCE} (@code{GNAT COMPILE}) + This qualifier causes the compiler to generate auxiliary output containing + a pseudo-source listing of the generated expanded code. Like most Ada + compilers, GNAT works by first transforming the high level Ada code into + lower level constructs. For example, tasking operations are transformed + into calls to the tasking run-time routines. A unique capability of GNAT + is to list this expanded code in a form very close to normal Ada source. + This is very useful in understanding the implications of various Ada + usage on the efficiency of the generated code. There are many cases in + Ada (e.g. the use of controlled types), where simple Ada statements can + generate a lot of run-time code. By using @option{/EXPAND_SOURCE} you can identify + these cases, and consider whether it may be desirable to modify the coding + approach to improve efficiency. + + The format of the output is very similar to standard Ada source, and is + easily understood by an Ada programmer. The following special syntactic + additions correspond to low level features used in the generated code that + do not have any exact analogies in pure Ada source form. The following + is a partial list of these special constructions. See the specification + of package @code{Sprint} in file @file{SPRINT.ADS} for a full list. + + @table @code + @item new @var{xxx} [storage_pool = @var{yyy}] + Shows the storage pool being used for an allocator. + + @item at end @var{procedure-name}; + Shows the finalization (cleanup) procedure for a scope. + + @item (if @var{expr} then @var{expr} else @var{expr}) + Conditional expression equivalent to the @code{x?y:z} construction in C. + + @item @var{target}^(@var{source}) + A conversion with floating-point truncation instead of rounding. + + @item @var{target}?(@var{source}) + A conversion that bypasses normal Ada semantic checking. In particular + enumeration types and fixed-point types are treated simply as integers. + + @item @var{target}?^(@var{source}) + Combines the above two cases. + + @item @var{x} #/ @var{y} + @itemx @var{x} #mod @var{y} + @itemx @var{x} #* @var{y} + @itemx @var{x} #rem @var{y} + A division or multiplication of fixed-point values which are treated as + integers without any kind of scaling. + + @item free @var{expr} [storage_pool = @var{xxx}] + Shows the storage pool associated with a @code{free} statement. + + @item freeze @var{typename} [@var{actions}] + Shows the point at which @var{typename} is frozen, with possible + associated actions to be performed at the freeze point. + + @item reference @var{itype} + Reference (and hence definition) to internal type @var{itype}. + + @item @var{function-name}! (@var{arg}, @var{arg}, @var{arg}) + Intrinsic function call. + + @item @var{labelname} : label + Declaration of label @var{labelname}. + + @item @var{expr} && @var{expr} && @var{expr} ... && @var{expr} + A multiple concatenation (same effect as @var{expr} & @var{expr} & + @var{expr}, but handled more efficiently). + + @item [constraint_error] + Raise the @code{Constraint_Error} exception. + + @item @var{expression}'reference + A pointer to the result of evaluating @var{expression}. + + @item @var{target-type}!(@var{source-expression}) + An unchecked conversion of @var{source-expression} to @var{target-type}. + + @item [@var{numerator}/@var{denominator}] + Used to represent internal real literals (that) have no exact + representation in base 2-16 (for example, the result of compile time + evaluation of the expression 1.0/27.0). + + @item /XDEBUG + @cindex @option{/XDEBUG} (@code{GNAT COMPILE}) + This qualifier is used in conjunction with @option{/EXPAND_SOURCE} to cause the expanded + source, as described above to be written to files with names + @file{XXX_DG}, where @file{xxx} is the normal file name, + for example, if the source file name is @file{HELLO.ADB}, + then a file @file{HELLO.ADB_DG} will be written. + The debugging information generated + by the @code{GNAT COMPILE} @code{/DEBUG} qualifier will refer to the generated + @file{XXX_DG} file. This allows you to do source level debugging using + the generated code which is sometimes useful for complex code, for example + to find out exactly which part of a complex construction raised an + exception. This qualifier also suppress generation of cross-reference + information (see /XREF=SUPPRESS). + + @item /COMPRESS_NAMES + @cindex @option{/CHECKS=ELABORATION} (@code{GNAT COMPILE}) + In the generated debugging information, and also in the case of long external + names, the compiler uses a compression mechanism if the name is very long. + This compression method uses a checksum, and avoids trouble on some operating + systems which have difficulty with very long names. The @option{/COMPRESS_NAMES} qualifier + forces this compression approach to be used on all external names and names + in the debugging information tables. This reduces the size of the generated + executable, at the expense of making the naming scheme more complex. The + compression only affects the qualification of the name. Thus a name in + the source: + + @smallexample + Very_Long_Package.Very_Long_Inner_Package.Var + @end smallexample + + @noindent + would normally appear in these tables as: + + @smallexample + very_long_package__very_long_inner_package__var + @end smallexample + + @noindent + but if the @option{/COMPRESS_NAMES} qualifier is used, then the name appears as + + @smallexample + XCb7e0c705__var + @end smallexample + + @noindent + Here b7e0c705 is a compressed encoding of the qualification prefix. + The GNAT Ada aware version of GDB understands these encoded prefixes, so if this + debugger is used, the encoding is largely hidden from the user of the compiler. + + @end table + + @item /REPRESENTATION_INFO[0|1|2|3][s] + @cindex @option{/REPRESENTATION_INFO} (@code{GNAT COMPILE}) + This qualifier controls output from the compiler of a listing showing + representation information for declared types and objects. For + @option{/REPRESENTATION_INFO=NONE}, no information is output (equivalent to omitting + the @option{/REPRESENTATION_INFO} qualifier). For @option{/REPRESENTATION_INFO=ARRAYS} (which is the default, + so @option{/REPRESENTATION_INFO} with no parameter has the same effect), size and alignment + information is listed for declared array and record types. For + @option{/REPRESENTATION_INFO=OBJECTS}, size and alignment information is listed for all + expression information for values that are computed at run time for + variant records. These symbolic expressions have a mostly obvious + format with #n being used to represent the value of the n'th + discriminant. See source files @file{REPINFO.ADS/adb} in the + @code{GNAT} sources for full detalis on the format of @option{/REPRESENTATION_INFO=SYMBOLIC} + output. If the qualifier is followed by an s (e.g. @option{-gnatR2s}), then + the output is to a file with the name @file{file_REP} where + file is the name of the corresponding source file. + + @item /XREF=SUPPRESS + @cindex @option{/XREF=SUPPRESS} (@code{GNAT COMPILE}) + Normally the compiler generates full cross-referencing information in + the @file{ALI} file. This information is used by a number of tools, + including @code{GNAT FIND} and @code{GNAT XREF}. The /XREF=SUPPRESS qualifier + suppresses this information. This saves some space and may slightly + speed up compilation, but means that these tools cannot be used. + @end table + + @node Units to Sources Mapping Files + @subsection Units to Sources Mapping Files + + @table @code + + @item -gnatem@var{path} + @cindex @option{-gnatem} (@code{GNAT COMPILE}) + A mapping file is a way to communicate to the compiler two mappings: + from unit names to file names (without any directory information) and from + file names to path names (with full directory information). These mappings + are used by the compiler to short-circuit the path search. + + A mapping file is a sequence of sets of three lines. In each set, + the first line is the unit name, in lower case, with "%s" appended for + specifications and "%b" appended for bodies; the second line is the file + name; and the third line is the path name. + + Example: + @smallexample + main%b + main.2.ADA + /gnat/project1/sources/main.2.ADA + @end smallexample + + When the qualifier @option{-gnatem} is specified, the compiler will create + in memory the two mappings from the specified file. If there is any problem + (non existent file, truncated file or duplicate entries), no mapping + will be created. + + Several @option{-gnatem} qualifiers may be specified; however, only the last + one on the command line will be taken into account. + + When using a project file, @code{GNAT MAKE} create a temporary mapping file + and communicates it to the compiler using this qualifier. + + @end table + + @node Search Paths and the Run-Time Library (RTL) + @section Search Paths and the Run-Time Library (RTL) + + @noindent + With the GNAT source-based library system, the compiler must be able to + find source files for units that are needed by the unit being compiled. + Search paths are used to guide this process. + + The compiler compiles one source file whose name must be given + explicitly on the command line. In other words, no searching is done + for this file. To find all other source files that are needed (the most + common being the specs of units), the compiler examines the following + directories, in the following order: + + @enumerate + @item + The directory containing the source file of the main unit being compiled + (the file name on the command line). + + @item + Each directory named by an @code{/SOURCE_SEARCH} qualifier given on the @code{GNAT COMPILE} + command line, in the order given. + + @item + @findex ADA_INCLUDE_PATH + Each of the directories listed in the value of the + @code{ADA_INCLUDE_PATH} logical name. + Normally, define this value as a logical name containing a comma separated + list of directory names. + + This variable can also be defined by means of an environment string + (an argument to the DEC C exec* set of functions). + + Logical Name: + @smallexample + DEFINE ANOTHER_PATH FOO:[BAG] + DEFINE ADA_INCLUDE_PATH ANOTHER_PATH,FOO:[BAM],FOO:[BAR] + @end smallexample + + By default, the path includes GNU:[LIB.OPENVMS7_x.2_8_x.DECLIB] + first, followed by the standard Ada 95 + libraries in GNU:[LIB.OPENVMS7_x.2_8_x.ADAINCLUDE]. + If this is not redefined, the user will obtain the DEC Ada83 IO packages + (Text_IO, Sequential_IO, etc) + instead of the Ada95 packages. Thus, in order to get the Ada 95 + packages by default, ADA_INCLUDE_PATH must be redefined. + @item + The content of the "ada_source_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as the + GNAT Run Time Library (RTL) source files. + @end enumerate + + @noindent + Specifying the qualifier @code{/NOCURRENT_DIRECTORY} + inhibits the use of the directory + containing the source file named in the command line. You can still + have this directory on your search path, but in this case it must be + explicitly requested with a @code{/SOURCE_SEARCH} qualifier. + + Specifying the qualifier @code{/NOSTD_INCLUDES} + inhibits the search of the default location for the GNAT Run Time + Library (RTL) source files. + + The compiler outputs its object files and ALI files in the current + working directory. + + @findex System.IO + The packages @code{Ada}, @code{System}, and @code{Interfaces} and their + children make up the GNAT RTL, together with the simple @code{System.IO} + package used in the "Hello World" example. The sources for these units + are needed by the compiler and are kept together in one directory. Not + all of the bodies are needed, but all of the sources are kept together + anyway. In a normal installation, you need not specify these directory + names when compiling or binding. Either the environment variables or + the built-in defaults cause these files to be found. + + In addition to the language-defined hierarchies (System, Ada and + Interfaces), the GNAT distribution provides a fourth hierarchy, + consisting of child units of GNAT. This is a collection of generally + useful routines. See the GNAT Reference Manual for further details. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + + @node Order of Compilation Issues + @section Order of Compilation Issues + + @noindent + If, in our earlier example, there was a spec for the @code{hello} + procedure, it would be contained in the file @file{HELLO.ADS}; yet this + file would not have to be explicitly compiled. This is the result of the + model we chose to implement library management. Some of the consequences + of this model are as follows: + + @itemize @bullet + @item + There is no point in compiling specs (except for package + specs with no bodies) because these are compiled as needed by clients. If + you attempt a useless compilation, you will receive an error message. + It is also useless to compile subunits because they are compiled as needed + by the parent. + + @item + There are no order of compilation requirements: performing a + compilation never obsoletes anything. The only way you can obsolete + something and require recompilations is to modify one of the + source files on which it depends. + + @item + There is no library as such, apart from the ALI files + (@pxref{The Ada Library Information Files}, for information on the format of these + files). For now we find it convenient to create separate ALI files, but + eventually the information therein may be incorporated into the object + file directly. + + @item + When you compile a unit, the source files for the specs of all units + that it @code{with}'s, all its subunits, and the bodies of any generics it + instantiates must be available (reachable by the search-paths mechanism + described above), or you will receive a fatal error message. + @end itemize + + @node Examples + @section Examples + + @noindent + The following are some typical Ada compilation command line examples: + + @table @code + @item $ GNAT COMPILE XYZ.ADB + Compile body in file @file{XYZ.ADB} with all default options. + + @item $ GNAT COMPILE /OPTIMIZE=ALL /CHECKS=ASSERTIONS XYZ-DEF.ADB + + Compile the child unit package in file @file{XYZ-DEF.ADB} with extensive + optimizations, and pragma @code{Assert}/@code{Debug} statements + enabled. + + @item $ GNAT COMPILE /NOLOAD ABC-DEF.ADB + Compile the subunit in file @file{ABC-DEF.ADB} in semantic-checking-only + mode. + @end table + + @node Binding Using GNAT BIND + @chapter Binding Using @code{GNAT BIND} + @findex GNAT BIND + + @menu + * Running GNAT BIND:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Qualifiers:: + * Command-Line Access:: + * Search Paths for GNAT BIND:: + * Examples of GNAT BIND Usage:: + @end menu + + @noindent + This chapter describes the GNAT binder, @code{GNAT BIND}, which is used + to bind compiled GNAT objects. The @code{GNAT BIND} program performs + four separate functions: + + @enumerate + @item + Checks that a program is consistent, in accordance with the rules in + Chapter 10 of the Ada 95 Reference Manual. In particular, error + messages are generated if a program uses inconsistent versions of a + given unit. + + @item + Checks that an acceptable order of elaboration exists for the program + and issues an error message if it cannot find an order of elaboration + that satisfies the rules in Chapter 10 of the Ada 95 Language Manual. + + @item + Generates a main program incorporating the given elaboration order. + This program is a small Ada package (body and spec) that + must be subsequently compiled + using the GNAT compiler. The necessary compilation step is usually + performed automatically by @code{GNAT LINK}. The two most important + functions of this program + are to call the elaboration routines of units in an appropriate order + and to call the main program. + + @item + Determines the set of object files required by the given main program. + This information is output in the forms of comments in the generated program, + to be read by the @code{GNAT LINK} utility used to link the Ada application. + @end enumerate + + @node Running GNAT BIND + @section Running @code{GNAT BIND} + + @noindent + The form of the @code{GNAT BIND} command is + + @smallexample + $ GNAT BIND [@var{qualifiers}] @var{mainprog}[.ALI] [@var{qualifiers}] + @end smallexample + + @noindent + where @var{mainprog}.ADB is the Ada file containing the main program + unit body. If no qualifiers are specified, @code{GNAT BIND} constructs an Ada + package in two files which names are + @file{B$@var{ada_main}.ADS}, and @file{B$@var{ada_main}.ADB}. + For example, if given the + parameter @samp{HELLO.ALI}, for a main program contained in file + @file{HELLO.ADB}, the binder output files would be @file{B~HELLO.ADS} + and @file{B~HELLO.ADB}. + + When doing consistency checking, the binder takes into consideration + any source files it can locate. For example, if the binder determines + that the given main program requires the package @code{Pack}, whose + @file{.ALI} + file is @file{PACK.ALI} and whose corresponding source spec file is + @file{PACK.ADS}, it attempts to locate the source file @file{PACK.ADS} + (using the same search path conventions as previously described for the + @code{GNAT COMPILE} command). If it can locate this source file, it checks that + the time stamps + or source checksums of the source and its references to in @file{ali} files + match. In other words, any @file{ali} files that mentions this spec must have + resulted from compiling this version of the source file (or in the case + where the source checksums match, a version close enough that the + difference does not matter). + + @cindex Source files, use by binder + The effect of this consistency checking, which includes source files, is + that the binder ensures that the program is consistent with the latest + version of the source files that can be located at bind time. Editing a + source file without compiling files that depend on the source file cause + error messages to be generated by the binder. + + For example, suppose you have a main program @file{HELLO.ADB} and a + package @code{P}, from file @file{P.ADS} and you perform the following + steps: + + @enumerate + @item + Enter @code{GNAT COMPILE HELLO.ADB} to compile the main program. + + @item + Enter @code{GNAT COMPILE P.ADS} to compile package @code{P}. + + @item + Edit file @file{P.ADS}. + + @item + Enter @code{GNAT BIND hello}. + @end enumerate + + At this point, the file @file{P.ALI} contains an out-of-date time stamp + because the file @file{P.ADS} has been edited. The attempt at binding + fails, and the binder generates the following error messages: + + @smallexample + error: "HELLO.ADB" must be recompiled ("P.ADS" has been modified) + error: "P.ADS" has been modified and must be recompiled + @end smallexample + + @noindent + Now both files must be recompiled as indicated, and then the bind can + succeed, generating a main program. You need not normally be concerned + with the contents of this file, but it is similar to the following which + is the binder file generated for a simple "hello world" program. + + @smallexample + @iftex + @leftskip=0cm + @end iftex + -- The package is called Ada_Main unless this name is actually used + -- as a unit name in the partition, in which case some other unique + -- name is used. + + with System; + package ada_main is + + Elab_Final_Code : Integer; + pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code"); + + -- The main program saves the parameters (argument count, + -- argument values, environment pointer) in global variables + -- for later access by other units including + -- Ada.Command_Line. + + gnat_argc : Integer; + gnat_argv : System.Address; + gnat_envp : System.Address; + + -- The actual variables are stored in a library routine. This + -- is useful for some shared library situations, where there + -- are problems if variables are not in the library. + + pragma Import (C, gnat_argc); + pragma Import (C, gnat_argv); + pragma Import (C, gnat_envp); + + -- The exit status is similarly an external location + + gnat_exit_status : Integer; + pragma Import (C, gnat_exit_status); + + GNAT_Version : constant String := + "GNAT Version: 3.15w (20010315)"; + pragma Export (C, GNAT_Version, "__gnat_version"); + + -- This is the generated adafinal routine that performs + -- finalization at the end of execution. In the case where + -- Ada is the main program, this main program makes a call + -- to adafinal at program termination. + + procedure adafinal; + pragma Export (C, adafinal, "adafinal"); + + -- This is the generated adainit routine that performs + -- initialization at the start of execution. In the case + -- where Ada is the main program, this main program makes + -- a call to adainit at program startup. + + procedure adainit; + pragma Export (C, adainit, "adainit"); + + -- This routine is called at the start of execution. It is + -- a dummy routine that is used by the debugger to breakpoint + -- at the start of execution. + + procedure Break_Start; + pragma Import (C, Break_Start, "__gnat_break_start"); + + -- This is the actual generated main program (it would be + -- suppressed if the no main program qualifier were used). As + -- required by standard system conventions, this program has + -- the external name main. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer; + pragma Export (C, main, "main"); + + -- The following set of constants give the version + -- identification values for every unit in the bound + -- partition. This identification is computed from all + -- dependent semantic units, and corresponds to the + -- string that would be returned by use of the + -- Body_Version or Version attributes. + + type Version_32 is mod 2 ** 32; + u00001 : constant Version_32 := 16#7880BEB3#; + u00002 : constant Version_32 := 16#0D24CBD0#; + u00003 : constant Version_32 := 16#3283DBEB#; + u00004 : constant Version_32 := 16#2359F9ED#; + u00005 : constant Version_32 := 16#664FB847#; + u00006 : constant Version_32 := 16#68E803DF#; + u00007 : constant Version_32 := 16#5572E604#; + u00008 : constant Version_32 := 16#46B173D8#; + u00009 : constant Version_32 := 16#156A40CF#; + u00010 : constant Version_32 := 16#033DABE0#; + u00011 : constant Version_32 := 16#6AB38FEA#; + u00012 : constant Version_32 := 16#22B6217D#; + u00013 : constant Version_32 := 16#68A22947#; + u00014 : constant Version_32 := 16#18CC4A56#; + u00015 : constant Version_32 := 16#08258E1B#; + u00016 : constant Version_32 := 16#367D5222#; + u00017 : constant Version_32 := 16#20C9ECA4#; + u00018 : constant Version_32 := 16#50D32CB6#; + u00019 : constant Version_32 := 16#39A8BB77#; + u00020 : constant Version_32 := 16#5CF8FA2B#; + u00021 : constant Version_32 := 16#2F1EB794#; + u00022 : constant Version_32 := 16#31AB6444#; + u00023 : constant Version_32 := 16#1574B6E9#; + u00024 : constant Version_32 := 16#5109C189#; + u00025 : constant Version_32 := 16#56D770CD#; + u00026 : constant Version_32 := 16#02F9DE3D#; + u00027 : constant Version_32 := 16#08AB6B2C#; + u00028 : constant Version_32 := 16#3FA37670#; + u00029 : constant Version_32 := 16#476457A0#; + u00030 : constant Version_32 := 16#731E1B6E#; + u00031 : constant Version_32 := 16#23C2E789#; + u00032 : constant Version_32 := 16#0F1BD6A1#; + u00033 : constant Version_32 := 16#7C25DE96#; + u00034 : constant Version_32 := 16#39ADFFA2#; + u00035 : constant Version_32 := 16#571DE3E7#; + u00036 : constant Version_32 := 16#5EB646AB#; + u00037 : constant Version_32 := 16#4249379B#; + u00038 : constant Version_32 := 16#0357E00A#; + u00039 : constant Version_32 := 16#3784FB72#; + u00040 : constant Version_32 := 16#2E723019#; + u00041 : constant Version_32 := 16#623358EA#; + u00042 : constant Version_32 := 16#107F9465#; + u00043 : constant Version_32 := 16#6843F68A#; + u00044 : constant Version_32 := 16#63305874#; + u00045 : constant Version_32 := 16#31E56CE1#; + u00046 : constant Version_32 := 16#02917970#; + u00047 : constant Version_32 := 16#6CCBA70E#; + u00048 : constant Version_32 := 16#41CD4204#; + u00049 : constant Version_32 := 16#572E3F58#; + u00050 : constant Version_32 := 16#20729FF5#; + u00051 : constant Version_32 := 16#1D4F93E8#; + u00052 : constant Version_32 := 16#30B2EC3D#; + u00053 : constant Version_32 := 16#34054F96#; + u00054 : constant Version_32 := 16#5A199860#; + u00055 : constant Version_32 := 16#0E7F912B#; + u00056 : constant Version_32 := 16#5760634A#; + u00057 : constant Version_32 := 16#5D851835#; + + -- The following Export pragmas export the version numbers + -- with symbolic names ending in B (for body) or S + -- (for spec) so that they can be located in a link. The + -- information provided here is sufficient to track down + -- the exact versions of units used in a given build. + + pragma Export (C, u00001, "helloB"); + pragma Export (C, u00002, "system__standard_libraryB"); + pragma Export (C, u00003, "system__standard_libraryS"); + pragma Export (C, u00004, "adaS"); + pragma Export (C, u00005, "ada__text_ioB"); + pragma Export (C, u00006, "ada__text_ioS"); + pragma Export (C, u00007, "ada__exceptionsB"); + pragma Export (C, u00008, "ada__exceptionsS"); + pragma Export (C, u00009, "gnatS"); + pragma Export (C, u00010, "gnat__heap_sort_aB"); + pragma Export (C, u00011, "gnat__heap_sort_aS"); + pragma Export (C, u00012, "systemS"); + pragma Export (C, u00013, "system__exception_tableB"); + pragma Export (C, u00014, "system__exception_tableS"); + pragma Export (C, u00015, "gnat__htableB"); + pragma Export (C, u00016, "gnat__htableS"); + pragma Export (C, u00017, "system__exceptionsS"); + pragma Export (C, u00018, "system__machine_state_operationsB"); + pragma Export (C, u00019, "system__machine_state_operationsS"); + pragma Export (C, u00020, "system__machine_codeS"); + pragma Export (C, u00021, "system__storage_elementsB"); + pragma Export (C, u00022, "system__storage_elementsS"); + pragma Export (C, u00023, "system__secondary_stackB"); + pragma Export (C, u00024, "system__secondary_stackS"); + pragma Export (C, u00025, "system__parametersB"); + pragma Export (C, u00026, "system__parametersS"); + pragma Export (C, u00027, "system__soft_linksB"); + pragma Export (C, u00028, "system__soft_linksS"); + pragma Export (C, u00029, "system__stack_checkingB"); + pragma Export (C, u00030, "system__stack_checkingS"); + pragma Export (C, u00031, "system__tracebackB"); + pragma Export (C, u00032, "system__tracebackS"); + pragma Export (C, u00033, "ada__streamsS"); + pragma Export (C, u00034, "ada__tagsB"); + pragma Export (C, u00035, "ada__tagsS"); + pragma Export (C, u00036, "system__string_opsB"); + pragma Export (C, u00037, "system__string_opsS"); + pragma Export (C, u00038, "interfacesS"); + pragma Export (C, u00039, "interfaces__c_streamsB"); + pragma Export (C, u00040, "interfaces__c_streamsS"); + pragma Export (C, u00041, "system__file_ioB"); + pragma Export (C, u00042, "system__file_ioS"); + pragma Export (C, u00043, "ada__finalizationB"); + pragma Export (C, u00044, "ada__finalizationS"); + pragma Export (C, u00045, "system__finalization_rootB"); + pragma Export (C, u00046, "system__finalization_rootS"); + pragma Export (C, u00047, "system__finalization_implementationB"); + pragma Export (C, u00048, "system__finalization_implementationS"); + pragma Export (C, u00049, "system__string_ops_concat_3B"); + pragma Export (C, u00050, "system__string_ops_concat_3S"); + pragma Export (C, u00051, "system__stream_attributesB"); + pragma Export (C, u00052, "system__stream_attributesS"); + pragma Export (C, u00053, "ada__io_exceptionsS"); + pragma Export (C, u00054, "system__unsigned_typesS"); + pragma Export (C, u00055, "system__file_control_blockS"); + pragma Export (C, u00056, "ada__finalization__list_controllerB"); + pragma Export (C, u00057, "ada__finalization__list_controllerS"); + + -- BEGIN ELABORATION ORDER + -- ada (spec) + -- gnat (spec) + -- gnat.heap_sort_a (spec) + -- gnat.heap_sort_a (body) + -- gnat.htable (spec) + -- gnat.htable (body) + -- interfaces (spec) + -- system (spec) + -- system.machine_code (spec) + -- system.parameters (spec) + -- system.parameters (body) + -- interfaces.c_streams (spec) + -- interfaces.c_streams (body) + -- system.standard_library (spec) + -- ada.exceptions (spec) + -- system.exception_table (spec) + -- system.exception_table (body) + -- ada.io_exceptions (spec) + -- system.exceptions (spec) + -- system.storage_elements (spec) + -- system.storage_elements (body) + -- system.machine_state_operations (spec) + -- system.machine_state_operations (body) + -- system.secondary_stack (spec) + -- system.stack_checking (spec) + -- system.soft_links (spec) + -- system.soft_links (body) + -- system.stack_checking (body) + -- system.secondary_stack (body) + -- system.standard_library (body) + -- system.string_ops (spec) + -- system.string_ops (body) + -- ada.tags (spec) + -- ada.tags (body) + -- ada.streams (spec) + -- system.finalization_root (spec) + -- system.finalization_root (body) + -- system.string_ops_concat_3 (spec) + -- system.string_ops_concat_3 (body) + -- system.traceback (spec) + -- system.traceback (body) + -- ada.exceptions (body) + -- system.unsigned_types (spec) + -- system.stream_attributes (spec) + -- system.stream_attributes (body) + -- system.finalization_implementation (spec) + -- system.finalization_implementation (body) + -- ada.finalization (spec) + -- ada.finalization (body) + -- ada.finalization.list_controller (spec) + -- ada.finalization.list_controller (body) + -- system.file_control_block (spec) + -- system.file_io (spec) + -- system.file_io (body) + -- ada.text_io (spec) + -- ada.text_io (body) + -- hello (body) + -- END ELABORATION ORDER + + end ada_main; + + -- The following source file name pragmas allow the generated file + -- names to be unique for different main programs. They are needed + -- since the package name will always be Ada_Main. + + pragma Source_File_Name (ada_main, Spec_File_Name => "B~HELLO.ADS"); + pragma Source_File_Name (ada_main, Body_File_Name => "B~HELLO.ADB"); + + -- Generated package body for Ada_Main starts here + + package body ada_main is + + -- The actual finalization is performed by calling the + -- library routine in System.Standard_Library.Adafinal + + procedure Do_Finalize; + pragma Import (C, Do_Finalize, "system__standard_library__adafinal"); + + ------------- + -- adainit -- + ------------- + + @findex adainit + procedure adainit is + + -- These booleans are set to True once the associated unit has + -- been elaborated. It is also used to avoid elaborating the + -- same unit twice. + + E040 : Boolean; pragma Import (Ada, E040, "interfaces__c_streams_E"); + E008 : Boolean; pragma Import (Ada, E008, "ada__exceptions_E"); + E014 : Boolean; pragma Import (Ada, E014, "system__exception_table_E"); + E053 : Boolean; pragma Import (Ada, E053, "ada__io_exceptions_E"); + E017 : Boolean; pragma Import (Ada, E017, "system__exceptions_E"); + E024 : Boolean; pragma Import (Ada, E024, "system__secondary_stack_E"); + E030 : Boolean; pragma Import (Ada, E030, "system__stack_checking_E"); + E028 : Boolean; pragma Import (Ada, E028, "system__soft_links_E"); + E035 : Boolean; pragma Import (Ada, E035, "ada__tags_E"); + E033 : Boolean; pragma Import (Ada, E033, "ada__streams_E"); + E046 : Boolean; pragma Import (Ada, E046, "system__finalization_root_E"); + E048 : Boolean; pragma Import (Ada, E048, "system__finalization_implementation_E"); + E044 : Boolean; pragma Import (Ada, E044, "ada__finalization_E"); + E057 : Boolean; pragma Import (Ada, E057, "ada__finalization__list_controller_E"); + E055 : Boolean; pragma Import (Ada, E055, "system__file_control_block_E"); + E042 : Boolean; pragma Import (Ada, E042, "system__file_io_E"); + E006 : Boolean; pragma Import (Ada, E006, "ada__text_io_E"); + + -- Set_Globals is a library routine that stores away the + -- value of the indicated set of global values in global + -- variables within the library. + + procedure Set_Globals + (Main_Priority : Integer; + Time_Slice_Value : Integer; + WC_Encoding : Character; + Locking_Policy : Character; + Queuing_Policy : Character; + Task_Dispatching_Policy : Character; + Adafinal : System.Address; + Unreserve_All_Interrupts : Integer; + Exception_Tracebacks : Integer); + @findex __gnat_set_globals + pragma Import (C, Set_Globals, "__gnat_set_globals"); + + -- SDP_Table_Build is a library routine used to build the + -- exception tables. See unit Ada.Exceptions in files + -- A-EXCEPT.ADS/adb for full details of how zero cost + -- exception handling works. This procedure, the call to + -- it, and the two following tables are all omitted if the + -- build is in longjmp/setjump exception mode. + + @findex SDP_Table_Build + @findex Zero Cost Exceptions + procedure SDP_Table_Build + (SDP_Addresses : System.Address; + SDP_Count : Natural; + Elab_Addresses : System.Address; + Elab_Addr_Count : Natural); + pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build"); + + -- Table of Unit_Exception_Table addresses. Used for zero + -- cost exception handling to build the top level table. + + ST : aliased constant array (1 .. 23) of System.Address := ( + Hello'UET_Address, + Ada.Text_Io'UET_Address, + Ada.Exceptions'UET_Address, + Gnat.Heap_Sort_A'UET_Address, + System.Exception_Table'UET_Address, + System.Machine_State_Operations'UET_Address, + System.Secondary_Stack'UET_Address, + System.Parameters'UET_Address, + System.Soft_Links'UET_Address, + System.Stack_Checking'UET_Address, + System.Traceback'UET_Address, + Ada.Streams'UET_Address, + Ada.Tags'UET_Address, + System.String_Ops'UET_Address, + Interfaces.C_Streams'UET_Address, + System.File_Io'UET_Address, + Ada.Finalization'UET_Address, + System.Finalization_Root'UET_Address, + System.Finalization_Implementation'UET_Address, + System.String_Ops_Concat_3'UET_Address, + System.Stream_Attributes'UET_Address, + System.File_Control_Block'UET_Address, + Ada.Finalization.List_Controller'UET_Address); + + -- Table of addresses of elaboration routines. Used for + -- zero cost exception handling to make sure these + -- addresses are included in the top level procedure + -- address table. + + EA : aliased constant array (1 .. 23) of System.Address := ( + adainit'Code_Address, + Do_Finalize'Code_Address, + Ada.Exceptions'Elab_Spec'Address, + System.Exceptions'Elab_Spec'Address, + Interfaces.C_Streams'Elab_Spec'Address, + System.Exception_Table'Elab_Body'Address, + Ada.Io_Exceptions'Elab_Spec'Address, + System.Stack_Checking'Elab_Spec'Address, + System.Soft_Links'Elab_Body'Address, + System.Secondary_Stack'Elab_Body'Address, + Ada.Tags'Elab_Spec'Address, + Ada.Tags'Elab_Body'Address, + Ada.Streams'Elab_Spec'Address, + System.Finalization_Root'Elab_Spec'Address, + Ada.Exceptions'Elab_Body'Address, + System.Finalization_Implementation'Elab_Spec'Address, + System.Finalization_Implementation'Elab_Body'Address, + Ada.Finalization'Elab_Spec'Address, + Ada.Finalization.List_Controller'Elab_Spec'Address, + System.File_Control_Block'Elab_Spec'Address, + System.File_Io'Elab_Body'Address, + Ada.Text_Io'Elab_Spec'Address, + Ada.Text_Io'Elab_Body'Address); + + -- Start of processing for adainit + + begin + + -- Call SDP_Table_Build to build the top level procedure + -- table for zero cost exception handling (omitted in + -- longjmp/setjump mode). + + SDP_Table_Build (ST'Address, 23, EA'Address, 23); + + -- Call Set_Globals to record various information for + -- this partition. The values are derived by the binder + -- from information stored in the ali files by the compiler. + + @findex __gnat_set_globals + Set_Globals + (Main_Priority => -1, + -- Priority of main program, -1 if no pragma Priority used + + Time_Slice_Value => -1, + -- Time slice from Time_Slice pragma, -1 if none used + + WC_Encoding => 'b', + -- Wide_Character encoding used, default is brackets + + Locking_Policy => ' ', + -- Locking_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Queuing_Policy => ' ', + -- Queuing_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Task_Dispatching_Policy => ' ', + -- Task_Dispatching_Policy used, default of space means + -- not specified, otherwise first character of the + -- policy name. + + Adafinal => System.Null_Address, + -- Address of Adafinal routine, not used anymore + + Unreserve_All_Interrupts => 0, + -- Set true if pragma Unreserve_All_Interrupts was used + + Exception_Tracebacks => 0); + -- Indicates if exception tracebacks are enabled + + Elab_Final_Code := 1; + + -- Now we have the elaboration calls for all units in the partition. + -- The Elab_Spec and Elab_Body attributes generate references to the + -- implicit elaboration procedures generated by the compiler for + -- each unit that requires elaboration. + + if not E040 then + Interfaces.C_Streams'Elab_Spec; + end if; + E040 := True; + if not E008 then + Ada.Exceptions'Elab_Spec; + end if; + if not E014 then + System.Exception_Table'Elab_Body; + E014 := True; + end if; + if not E053 then + Ada.Io_Exceptions'Elab_Spec; + E053 := True; + end if; + if not E017 then + System.Exceptions'Elab_Spec; + E017 := True; + end if; + if not E030 then + System.Stack_Checking'Elab_Spec; + end if; + if not E028 then + System.Soft_Links'Elab_Body; + E028 := True; + end if; + E030 := True; + if not E024 then + System.Secondary_Stack'Elab_Body; + E024 := True; + end if; + if not E035 then + Ada.Tags'Elab_Spec; + end if; + if not E035 then + Ada.Tags'Elab_Body; + E035 := True; + end if; + if not E033 then + Ada.Streams'Elab_Spec; + E033 := True; + end if; + if not E046 then + System.Finalization_Root'Elab_Spec; + end if; + E046 := True; + if not E008 then + Ada.Exceptions'Elab_Body; + E008 := True; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Spec; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Body; + E048 := True; + end if; + if not E044 then + Ada.Finalization'Elab_Spec; + end if; + E044 := True; + if not E057 then + Ada.Finalization.List_Controller'Elab_Spec; + end if; + E057 := True; + if not E055 then + System.File_Control_Block'Elab_Spec; + E055 := True; + end if; + if not E042 then + System.File_Io'Elab_Body; + E042 := True; + end if; + if not E006 then + Ada.Text_Io'Elab_Spec; + end if; + if not E006 then + Ada.Text_Io'Elab_Body; + E006 := True; + end if; + + Elab_Final_Code := 0; + end adainit; + + -------------- + -- adafinal -- + -------------- + + @findex adafinal + procedure adafinal is + begin + Do_Finalize; + end adafinal; + + ---------- + -- main -- + ---------- + + -- main is actually a function, as in the ANSI C standard, + -- defined to return the exit status. The three parameters + -- are the argument count, argument values and environment + -- pointer. + + @findex Main Program + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer + is + -- The initialize routine performs low level system + -- initialization using a standard library routine which + -- sets up signal handling and performs any other + -- required setup. The routine can be found in file + -- A-INIT.C. + + @findex __gnat_initialize + procedure initialize; + pragma Import (C, initialize, "__gnat_initialize"); + + -- The finalize routine performs low level system + -- finalization using a standard library routine. The + -- routine is found in file A-FINAL.C and in the standard + -- distribution is a dummy routine that does nothing, so + -- really this is a hook for special user finalization. + + @findex __gnat_finalize + procedure finalize; + pragma Import (C, finalize, "__gnat_finalize"); + + -- We get to the main program of the partition by using + -- pragma Import because if we try to with the unit and + -- call it Ada style, then not only do we waste time + -- recompiling it, but also, we don't really know the right + -- qualifiers (e.g. identifier character set) to be used + -- to compile it. + + procedure Ada_Main_Program; + pragma Import (Ada, Ada_Main_Program, "_ada_hello"); + + -- Start of processing for main + + begin + -- Save global variables + + gnat_argc := argc; + gnat_argv := argv; + gnat_envp := envp; + + -- Call low level system initialization + + Initialize; + + -- Call our generated Ada initialization routine + + adainit; + + -- This is the point at which we want the debugger to get + -- control + + Break_Start; + + -- Now we call the main program of the partition + + Ada_Main_Program; + + -- Perform Ada finalization + + adafinal; + + -- Perform low level system finalization + + Finalize; + + -- Return the proper exit status + return (gnat_exit_status); + end; + + -- This section is entirely comments, so it has no effect on the + -- compilation of the Ada_Main package. It provides the list of + -- object files and linker options, as well as some standard + -- libraries needed for the link. The GNAT LINK utility parses + -- this B~HELLO.ADB file to read these comment lines to generate + -- the appropriate command line arguments for the call to the + -- system linker. The BEGIN/END lines are used for sentinels for + -- this parsing operation. + + -- The exact file names will of course depend on the environment, + -- host/target and location of files on the host system. + + @findex Object file list + -- BEGIN Object file/option list + -- ./HELLO.OBJ + -- -L./ + -- -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/ + -- /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a + -- END Object file/option list + + end ada_main; + + @end smallexample + + @noindent + The Ada code in the above example is exactly what is generated by the + binder. We have added comments to more clearly indicate the function + of each part of the generated @code{Ada_Main} package. + + The code is standard Ada in all respects, and can be processed by any + tools that handle Ada. In particular, it is possible to use the debugger + in Ada mode to debug the generated Ada_Main package. For example, suppose + that for reasons that you do not understand, your program is blowing up + during elaboration of the body of @code{Ada.Text_IO}. To chase this bug + down, you can place a breakpoint on the call: + + @smallexample + Ada.Text_Io'Elab_Body; + @end smallexample + + @noindent + and trace the elaboration routine for this package to find out where + the problem might be (more usually of course you would be debugging + elaboration code in your own application). + + @node Generating the Binder Program in C + @section Generating the Binder Program in C + @noindent + In most normal usage, the default mode of @code{GNAT BIND} which is to + generate the main package in Ada, as described in the previous section. + In particular, this means that any Ada programmer can read and understand + the generated main program. It can also be debugged just like any other + Ada code provided the @code{-g} qualifier is used for @code{GNAT BIND} + and @code{GNAT LINK}. + + However for some purposes it may be convenient to generate the main + program in C rather than Ada. This may for example be helpful when you + are generating a mixed language program with the main program in C. The + GNAT compiler itself is an example. The use of the @code{-C} qualifier + for both @code{GNAT BIND} and @code{GNAT LINK} will cause the program to + be generated in C (and compiled using the gnu C compiler). The + following shows the C code generated for the same "Hello World" + program: + + @smallexample + + #ifdef __STDC__ + #define PARAMS(paramlist) paramlist + #else + #define PARAMS(paramlist) () + #endif + + extern void __gnat_set_globals + PARAMS ((int, int, int, int, int, int, + void (*) PARAMS ((void)), int, int)); + extern void adafinal PARAMS ((void)); + extern void adainit PARAMS ((void)); + extern void system__standard_library__adafinal PARAMS ((void)); + extern int main PARAMS ((int, char **, char **)); + extern void exit PARAMS ((int)); + extern void __gnat_break_start PARAMS ((void)); + extern void _ada_hello PARAMS ((void)); + extern void __gnat_initialize PARAMS ((void)); + extern void __gnat_finalize PARAMS ((void)); + + extern void ada__exceptions___elabs PARAMS ((void)); + extern void system__exceptions___elabs PARAMS ((void)); + extern void interfaces__c_streams___elabs PARAMS ((void)); + extern void system__exception_table___elabb PARAMS ((void)); + extern void ada__io_exceptions___elabs PARAMS ((void)); + extern void system__stack_checking___elabs PARAMS ((void)); + extern void system__soft_links___elabb PARAMS ((void)); + extern void system__secondary_stack___elabb PARAMS ((void)); + extern void ada__tags___elabs PARAMS ((void)); + extern void ada__tags___elabb PARAMS ((void)); + extern void ada__streams___elabs PARAMS ((void)); + extern void system__finalization_root___elabs PARAMS ((void)); + extern void ada__exceptions___elabb PARAMS ((void)); + extern void system__finalization_implementation___elabs PARAMS ((void)); + extern void system__finalization_implementation___elabb PARAMS ((void)); + extern void ada__finalization___elabs PARAMS ((void)); + extern void ada__finalization__list_controller___elabs PARAMS ((void)); + extern void system__file_control_block___elabs PARAMS ((void)); + extern void system__file_io___elabb PARAMS ((void)); + extern void ada__text_io___elabs PARAMS ((void)); + extern void ada__text_io___elabb PARAMS ((void)); + + extern int __gnat_inside_elab_final_code; + + extern int gnat_argc; + extern char **gnat_argv; + extern char **gnat_envp; + extern int gnat_exit_status; + + char __gnat_version[] = "GNAT Version: 3.15w (20010315)"; + void adafinal () @{ + system__standard_library__adafinal (); + @} + + void adainit () + @{ + extern char ada__exceptions_E; + extern char system__exceptions_E; + extern char interfaces__c_streams_E; + extern char system__exception_table_E; + extern char ada__io_exceptions_E; + extern char system__secondary_stack_E; + extern char system__stack_checking_E; + extern char system__soft_links_E; + extern char ada__tags_E; + extern char ada__streams_E; + extern char system__finalization_root_E; + extern char system__finalization_implementation_E; + extern char ada__finalization_E; + extern char ada__finalization__list_controller_E; + extern char system__file_control_block_E; + extern char system__file_io_E; + extern char ada__text_io_E; + + extern void *__gnat_hello__SDP; + extern void *__gnat_ada__text_io__SDP; + extern void *__gnat_ada__exceptions__SDP; + extern void *__gnat_gnat__heap_sort_a__SDP; + extern void *__gnat_system__exception_table__SDP; + extern void *__gnat_system__machine_state_operations__SDP; + extern void *__gnat_system__secondary_stack__SDP; + extern void *__gnat_system__parameters__SDP; + extern void *__gnat_system__soft_links__SDP; + extern void *__gnat_system__stack_checking__SDP; + extern void *__gnat_system__traceback__SDP; + extern void *__gnat_ada__streams__SDP; + extern void *__gnat_ada__tags__SDP; + extern void *__gnat_system__string_ops__SDP; + extern void *__gnat_interfaces__c_streams__SDP; + extern void *__gnat_system__file_io__SDP; + extern void *__gnat_ada__finalization__SDP; + extern void *__gnat_system__finalization_root__SDP; + extern void *__gnat_system__finalization_implementation__SDP; + extern void *__gnat_system__string_ops_concat_3__SDP; + extern void *__gnat_system__stream_attributes__SDP; + extern void *__gnat_system__file_control_block__SDP; + extern void *__gnat_ada__finalization__list_controller__SDP; + + void **st[23] = @{ + &__gnat_hello__SDP, + &__gnat_ada__text_io__SDP, + &__gnat_ada__exceptions__SDP, + &__gnat_gnat__heap_sort_a__SDP, + &__gnat_system__exception_table__SDP, + &__gnat_system__machine_state_operations__SDP, + &__gnat_system__secondary_stack__SDP, + &__gnat_system__parameters__SDP, + &__gnat_system__soft_links__SDP, + &__gnat_system__stack_checking__SDP, + &__gnat_system__traceback__SDP, + &__gnat_ada__streams__SDP, + &__gnat_ada__tags__SDP, + &__gnat_system__string_ops__SDP, + &__gnat_interfaces__c_streams__SDP, + &__gnat_system__file_io__SDP, + &__gnat_ada__finalization__SDP, + &__gnat_system__finalization_root__SDP, + &__gnat_system__finalization_implementation__SDP, + &__gnat_system__string_ops_concat_3__SDP, + &__gnat_system__stream_attributes__SDP, + &__gnat_system__file_control_block__SDP, + &__gnat_ada__finalization__list_controller__SDP@}; + + extern void ada__exceptions___elabs (); + extern void system__exceptions___elabs (); + extern void interfaces__c_streams___elabs (); + extern void system__exception_table___elabb (); + extern void ada__io_exceptions___elabs (); + extern void system__stack_checking___elabs (); + extern void system__soft_links___elabb (); + extern void system__secondary_stack___elabb (); + extern void ada__tags___elabs (); + extern void ada__tags___elabb (); + extern void ada__streams___elabs (); + extern void system__finalization_root___elabs (); + extern void ada__exceptions___elabb (); + extern void system__finalization_implementation___elabs (); + extern void system__finalization_implementation___elabb (); + extern void ada__finalization___elabs (); + extern void ada__finalization__list_controller___elabs (); + extern void system__file_control_block___elabs (); + extern void system__file_io___elabb (); + extern void ada__text_io___elabs (); + extern void ada__text_io___elabb (); + + void (*ea[23]) () = @{ + adainit, + system__standard_library__adafinal, + ada__exceptions___elabs, + system__exceptions___elabs, + interfaces__c_streams___elabs, + system__exception_table___elabb, + ada__io_exceptions___elabs, + system__stack_checking___elabs, + system__soft_links___elabb, + system__secondary_stack___elabb, + ada__tags___elabs, + ada__tags___elabb, + ada__streams___elabs, + system__finalization_root___elabs, + ada__exceptions___elabb, + system__finalization_implementation___elabs, + system__finalization_implementation___elabb, + ada__finalization___elabs, + ada__finalization__list_controller___elabs, + system__file_control_block___elabs, + system__file_io___elabb, + ada__text_io___elabs, + ada__text_io___elabb@}; + + __gnat_SDP_Table_Build (&st, 23, ea, 23); + __gnat_set_globals ( + -1, /* Main_Priority */ + -1, /* Time_Slice_Value */ + 'b', /* WC_Encoding */ + ' ', /* Locking_Policy */ + ' ', /* Queuing_Policy */ + ' ', /* Tasking_Dispatching_Policy */ + 0, /* Finalization routine address, not used anymore */ + 0, /* Unreserve_All_Interrupts */ + 0); /* Exception_Tracebacks */ + + __gnat_inside_elab_final_code = 1; + + if (ada__exceptions_E == 0) @{ + ada__exceptions___elabs (); + @} + if (system__exceptions_E == 0) @{ + system__exceptions___elabs (); + system__exceptions_E++; + @} + if (interfaces__c_streams_E == 0) @{ + interfaces__c_streams___elabs (); + @} + interfaces__c_streams_E = 1; + if (system__exception_table_E == 0) @{ + system__exception_table___elabb (); + system__exception_table_E++; + @} + if (ada__io_exceptions_E == 0) @{ + ada__io_exceptions___elabs (); + ada__io_exceptions_E++; + @} + if (system__stack_checking_E == 0) @{ + system__stack_checking___elabs (); + @} + if (system__soft_links_E == 0) @{ + system__soft_links___elabb (); + system__soft_links_E++; + @} + system__stack_checking_E = 1; + if (system__secondary_stack_E == 0) @{ + system__secondary_stack___elabb (); + system__secondary_stack_E++; + @} + if (ada__tags_E == 0) @{ + ada__tags___elabs (); + @} + if (ada__tags_E == 0) @{ + ada__tags___elabb (); + ada__tags_E++; + @} + if (ada__streams_E == 0) @{ + ada__streams___elabs (); + ada__streams_E++; + @} + if (system__finalization_root_E == 0) @{ + system__finalization_root___elabs (); + @} + system__finalization_root_E = 1; + if (ada__exceptions_E == 0) @{ + ada__exceptions___elabb (); + ada__exceptions_E++; + @} + if (system__finalization_implementation_E == 0) @{ + system__finalization_implementation___elabs (); + @} + if (system__finalization_implementation_E == 0) @{ + system__finalization_implementation___elabb (); + system__finalization_implementation_E++; + @} + if (ada__finalization_E == 0) @{ + ada__finalization___elabs (); + @} + ada__finalization_E = 1; + if (ada__finalization__list_controller_E == 0) @{ + ada__finalization__list_controller___elabs (); + @} + ada__finalization__list_controller_E = 1; + if (system__file_control_block_E == 0) @{ + system__file_control_block___elabs (); + system__file_control_block_E++; + @} + if (system__file_io_E == 0) @{ + system__file_io___elabb (); + system__file_io_E++; + @} + if (ada__text_io_E == 0) @{ + ada__text_io___elabs (); + @} + if (ada__text_io_E == 0) @{ + ada__text_io___elabb (); + ada__text_io_E++; + @} + + __gnat_inside_elab_final_code = 0; + @} + int main (argc, argv, envp) + int argc; + char **argv; + char **envp; + @{ + gnat_argc = argc; + gnat_argv = argv; + gnat_envp = envp; + + __gnat_initialize (); + adainit (); + __gnat_break_start (); + + _ada_hello (); + + system__standard_library__adafinal (); + __gnat_finalize (); + exit (gnat_exit_status); + @} + unsigned helloB = 0x7880BEB3; + unsigned system__standard_libraryB = 0x0D24CBD0; + unsigned system__standard_libraryS = 0x3283DBEB; + unsigned adaS = 0x2359F9ED; + unsigned ada__text_ioB = 0x47C85FC4; + unsigned ada__text_ioS = 0x496FE45C; + unsigned ada__exceptionsB = 0x74F50187; + unsigned ada__exceptionsS = 0x6736945B; + unsigned gnatS = 0x156A40CF; + unsigned gnat__heap_sort_aB = 0x033DABE0; + unsigned gnat__heap_sort_aS = 0x6AB38FEA; + unsigned systemS = 0x0331C6FE; + unsigned system__exceptionsS = 0x20C9ECA4; + unsigned system__exception_tableB = 0x68A22947; + unsigned system__exception_tableS = 0x394BADD5; + unsigned gnat__htableB = 0x08258E1B; + unsigned gnat__htableS = 0x367D5222; + unsigned system__machine_state_operationsB = 0x4F3B7492; + unsigned system__machine_state_operationsS = 0x182F5CF4; + unsigned system__storage_elementsB = 0x2F1EB794; + unsigned system__storage_elementsS = 0x102C83C7; + unsigned system__secondary_stackB = 0x1574B6E9; + unsigned system__secondary_stackS = 0x708E260A; + unsigned system__parametersB = 0x56D770CD; + unsigned system__parametersS = 0x237E39BE; + unsigned system__soft_linksB = 0x08AB6B2C; + unsigned system__soft_linksS = 0x1E2491F3; + unsigned system__stack_checkingB = 0x476457A0; + unsigned system__stack_checkingS = 0x5299FCED; + unsigned system__tracebackB = 0x2971EBDE; + unsigned system__tracebackS = 0x2E9C3122; + unsigned ada__streamsS = 0x7C25DE96; + unsigned ada__tagsB = 0x39ADFFA2; + unsigned ada__tagsS = 0x769A0464; + unsigned system__string_opsB = 0x5EB646AB; + unsigned system__string_opsS = 0x63CED018; + unsigned interfacesS = 0x0357E00A; + unsigned interfaces__c_streamsB = 0x3784FB72; + unsigned interfaces__c_streamsS = 0x2E723019; + unsigned system__file_ioB = 0x623358EA; + unsigned system__file_ioS = 0x31F873E6; + unsigned ada__finalizationB = 0x6843F68A; + unsigned ada__finalizationS = 0x63305874; + unsigned system__finalization_rootB = 0x31E56CE1; + unsigned system__finalization_rootS = 0x23169EF3; + unsigned system__finalization_implementationB = 0x6CCBA70E; + unsigned system__finalization_implementationS = 0x604AA587; + unsigned system__string_ops_concat_3B = 0x572E3F58; + unsigned system__string_ops_concat_3S = 0x01F57876; + unsigned system__stream_attributesB = 0x1D4F93E8; + unsigned system__stream_attributesS = 0x30B2EC3D; + unsigned ada__io_exceptionsS = 0x34054F96; + unsigned system__unsigned_typesS = 0x7B9E7FE3; + unsigned system__file_control_blockS = 0x2FF876A8; + unsigned ada__finalization__list_controllerB = 0x5760634A; + unsigned ada__finalization__list_controllerS = 0x5D851835; + + /* BEGIN ELABORATION ORDER + ada (spec) + gnat (spec) + gnat.heap_sort_a (spec) + gnat.htable (spec) + gnat.htable (body) + interfaces (spec) + system (spec) + system.parameters (spec) + system.standard_library (spec) + ada.exceptions (spec) + system.exceptions (spec) + system.parameters (body) + gnat.heap_sort_a (body) + interfaces.c_streams (spec) + interfaces.c_streams (body) + system.exception_table (spec) + system.exception_table (body) + ada.io_exceptions (spec) + system.storage_elements (spec) + system.storage_elements (body) + system.machine_state_operations (spec) + system.machine_state_operations (body) + system.secondary_stack (spec) + system.stack_checking (spec) + system.soft_links (spec) + system.soft_links (body) + system.stack_checking (body) + system.secondary_stack (body) + system.standard_library (body) + system.string_ops (spec) + system.string_ops (body) + ada.tags (spec) + ada.tags (body) + ada.streams (spec) + system.finalization_root (spec) + system.finalization_root (body) + system.string_ops_concat_3 (spec) + system.string_ops_concat_3 (body) + system.traceback (spec) + system.traceback (body) + ada.exceptions (body) + system.unsigned_types (spec) + system.stream_attributes (spec) + system.stream_attributes (body) + system.finalization_implementation (spec) + system.finalization_implementation (body) + ada.finalization (spec) + ada.finalization (body) + ada.finalization.list_controller (spec) + ada.finalization.list_controller (body) + system.file_control_block (spec) + system.file_io (spec) + system.file_io (body) + ada.text_io (spec) + ada.text_io (body) + hello (body) + END ELABORATION ORDER */ + + /* BEGIN Object file/option list + ./HELLO.OBJ + -L./ + -L/usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/ + /usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/libgnat.a + -lexc + END Object file/option list */ + + @end smallexample + + @noindent + Here again, the C code is exactly what is generated by the binder. The + functions of the various parts of this code correspond in an obvious + manner with the commented Ada code shown in the example in the previous + section. + + @node Consistency-Checking Modes + @section Consistency-Checking Modes + + @noindent + As described in the previous section, by default @code{GNAT BIND} checks + that object files are consistent with one another and are consistent + with any source files it can locate. The following qualifiers control binder + access to sources. + + @table @code + @item /READ_SOURCES=ALL + @cindex @code{/READ_SOURCES=ALL} (@code{GNAT BIND}) + Require source files to be present. In this mode, the binder must be + able to locate all source files that are referenced, in order to check + their consistency. In normal mode, if a source file cannot be located it + is simply ignored. If you specify this qualifier, a missing source + file is an error. + + @item /READ_SOURCES=NONE + @cindex @code{/READ_SOURCES=NONE} (@code{GNAT BIND}) + Exclude source files. In this mode, the binder only checks that ALI + files are consistent with one another. Source files are not accessed. + The binder runs faster in this mode, and there is still a guarantee that + the resulting program is self-consistent. + If a source file has been edited since it was last compiled, and you + specify this qualifier, the binder will not detect that the object + file is out of date with respect to the source file. Note that this is the + mode that is automatically used by @code{GNAT MAKE} because in this + case the checking against sources has already been performed by + @code{GNAT MAKE} in the course of compilation (i.e. before binding). + + @item /READ_SOURCES=AVAILABLE + This is the default mode in which source files are checked if they are + available, and ignored if they are not available. + @end table + + @node Binder Error Message Control + @section Binder Error Message Control + + @noindent + The following qualifiers provide control over the generation of error + messages from the binder: + + @table @code + @item /REPORT_ERRORS=VERBOSE + @cindex @code{/REPORT_ERRORS=VERBOSE} (@code{GNAT BIND}) + Verbose mode. In the normal mode, brief error messages are generated to + @file{SYS$ERROR}. If this qualifier is present, a header is written + to @file{SYS$OUTPUT} and any error messages are directed to @file{SYS$OUTPUT}. + All that is written to @file{SYS$ERROR} is a brief summary message. + + @item /REPORT_ERRORS=BRIEF + @cindex @code{/REPORT_ERRORS=BRIEF} (@code{GNAT BIND}) + Generate brief error messages to @file{SYS$ERROR} even if verbose mode is + specified. This is relevant only when used with the + @code{/REPORT_ERRORS=VERBOSE} qualifier. + + + @item /WARNINGS=SUPPRESS + @cindex @code{/WARNINGS=SUPPRESS} (@code{GNAT BIND}) + @cindex Warnings + Suppress all warning messages. + + @item /WARNINGS=ERROR + @cindex @code{/WARNINGS=ERROR} (@code{GNAT BIND}) + Treat any warning messages as fatal errors. + + @item /WARNINGS=NORMAL + Standard mode with warnings generated, but warnings do not get treated + as errors. + + @item /NOTIME_STAMP_CHECK + @cindex @code{/NOTIME_STAMP_CHECK} (@code{GNAT BIND}) + @cindex Time stamp checks, in binder + @cindex Binder consistency checks + @cindex Consistency checks, in binder + The binder performs a number of consistency checks including: + + @itemize @bullet + @item + Check that time stamps of a given source unit are consistent + @item + Check that checksums of a given source unit are consistent + @item + Check that consistent versions of @code{GNAT} were used for compilation + @item + Check consistency of configuration pragmas as required + @end itemize + + @noindent + Normally failure of such checks, in accordance with the consistency + requirements of the Ada Reference Manual, causes error messages to be + generated which abort the binder and prevent the output of a binder + file and subsequent link to obtain an executable. + + The @code{/NOTIME_STAMP_CHECK} qualifier converts these error messages + into warnings, so that + binding and linking can continue to completion even in the presence of such + errors. The result may be a failed link (due to missing symbols), or a + non-functional executable which has undefined semantics. + @emph{This means that + @code{/NOTIME_STAMP_CHECK} should be used only in unusual situations, + with extreme care.} + @end table + + @node Elaboration Control + @section Elaboration Control + + @noindent + The following qualifiers provide additional control over the elaboration + order. For full details see @xref{Elaboration Order Handling in GNAT}. + + @table @code + @item /PESSIMISTIC_ELABORATION + @cindex @code{/PESSIMISTIC_ELABORATION} (@code{GNAT BIND}) + Normally the binder attempts to choose an elaboration order that is + likely to minimize the likelihood of an elaboration order error resulting + in raising a @code{Program_Error} exception. This qualifier reverses the + action of the binder, and requests that it deliberately choose an order + that is likely to maximize the likelihood of an elaboration error. + This is useful in ensuring portability and avoiding dependence on + accidental fortuitous elaboration ordering. + + Normally it only makes sense to use the @code{-p} qualifier if dynamic + elaboration checking is used (@option{/CHECKS=ELABORATION} qualifier used for compilation). + This is because in the default static elaboration mode, all necessary + @code{Elaborate_All} pragmas are implicitly inserted. These implicit + pragmas are still respected by the binder in @code{-p} mode, so a + safe elaboration order is assured. + @end table + + @node Output Control + @section Output Control + + @noindent + The following qualifiers allow additional control over the output + generated by the binder. + + @table @code + + @item /BIND_FILE=ADA + @cindex @code{/BIND_FILE=ADA} (@code{GNAT BIND}) + Generate binder program in Ada (default). The binder program is named + @file{B$@var{mainprog}.ADB} by default. This can be changed with + @code{-o} @code{GNAT BIND} option. + + @item /NOOUTPUT + @cindex @code{/NOOUTPUT} (@code{GNAT BIND}) + Check only. Do not generate the binder output file. In this mode the + binder performs all error checks but does not generate an output file. + + @item /BIND_FILE=C + @cindex @code{/BIND_FILE=C} (@code{GNAT BIND}) + Generate binder program in C. The binder program is named + @file{B_@var{mainprog}.C}. This can be changed with @code{-o} @code{GNAT BIND} + option. + + @item /ELABORATION_DEPENDENCIES + @cindex @code{/ELABORATION_DEPENDENCIES} (@code{GNAT BIND}) + Output complete list of elaboration-order dependencies, showing the + reason for each dependency. This output can be rather extensive but may + be useful in diagnosing problems with elaboration order. The output is + written to @file{SYS$OUTPUT}. + + @item /HELP + @cindex @code{/HELP} (@code{GNAT BIND}) + Output usage information. The output is written to @file{SYS$OUTPUT}. + + @item /LINKER_OPTION_LIST + @cindex @code{/LINKER_OPTION_LIST} (@code{GNAT BIND}) + Output linker options to @file{SYS$OUTPUT}. Includes library search paths, + contents of pragmas Ident and Linker_Options, and libraries added + by @code{GNAT BIND}. + + @item /ORDER_OF_ELABORATION + @cindex @code{/ORDER_OF_ELABORATION} (@code{GNAT BIND}) + Output chosen elaboration order. The output is written to @file{SYS$OUTPUT}. + + @item /OBJECT_LIST + @cindex @code{/OBJECT_LIST} (@code{GNAT BIND}) + Output full names of all the object files that must be linked to provide + the Ada component of the program. The output is written to @file{SYS$OUTPUT}. + This list includes the files explicitly supplied and referenced by the user + as well as implicitly referenced run-time unit files. The latter are + omitted if the corresponding units reside in shared libraries. The + directory names for the run-time units depend on the system configuration. + + @item /OUTPUT=@var{file} + @cindex @code{/OUTPUT} (@code{GNAT BIND}) + Set name of output file to @var{file} instead of the normal + @file{B$@var{mainprog}.ADB} default. Note that @var{file} denote the Ada + binder generated body filename. In C mode you would normally give + @var{file} an extension of @file{.C} because it will be a C source program. + Note that if this option is used, then linking must be done manually. + It is not possible to use GNAT LINK in this case, since it cannot locate + the binder file. + + @item /RESTRICTION_LIST + @cindex @code{/RESTRICTION_LIST} (@code{GNAT BIND}) + Generate list of @code{pragma Rerstrictions} that could be applied to + the current unit. This is useful for code audit purposes, and also may + be used to improve code generation in some cases. + + @end table + + @node Binding with Non-Ada Main Programs + @section Binding with Non-Ada Main Programs + + @noindent + In our description so far we have assumed that the main + program is in Ada, and that the task of the binder is to generate a + corresponding function @code{main} that invokes this Ada main + program. GNAT also supports the building of executable programs where + the main program is not in Ada, but some of the called routines are + written in Ada and compiled using GNAT (@pxref{Mixed Language Programming}). + The following qualifier is used in this situation: + + @table @code + @item /NOMAIN + @cindex @code{/NOMAIN} (@code{GNAT BIND}) + No main program. The main program is not in Ada. + @end table + + @noindent + In this case, most of the functions of the binder are still required, + but instead of generating a main program, the binder generates a file + containing the following callable routines: + + @table @code + @item adainit + @findex adainit + You must call this routine to initialize the Ada part of the program by + calling the necessary elaboration routines. A call to @code{adainit} is + required before the first call to an Ada subprogram. + + Note that it is assumed that the basic execution environment must be setup + to be appropriate for Ada execution at the point where the first Ada + subprogram is called. In particular, if the Ada code will do any + floating-point operations, then the FPU must be setup in an appropriate + manner. For the case of the x86, for example, full precision mode is + required. The procedure GNAT.Float_Control.Reset may be used to ensure + that the FPU is in the right state. + + @item adafinal + @findex adafinal + You must call this routine to perform any library-level finalization + required by the Ada subprograms. A call to @code{adafinal} is required + after the last call to an Ada subprogram, and before the program + terminates. + @end table + + @noindent + If the @code{/NOMAIN} qualifier + @cindex Binder, multiple input files + is given, more than one ALI file may appear on + the command line for @code{GNAT BIND}. The normal @dfn{closure} + calculation is performed for each of the specified units. Calculating + the closure means finding out the set of units involved by tracing + @code{with} references. The reason it is necessary to be able to + specify more than one ALI file is that a given program may invoke two or + more quite separate groups of Ada units. + + The binder takes the name of its output file from the last specified ALI + file, unless overridden by the use of the @code{/OUTPUT=file}. + The output is an Ada unit in source form that can + be compiled with GNAT unless the -C qualifier is used in which case the + output is a C source file, which must be compiled using the C compiler. + This compilation occurs automatically as part of the @code{GNAT LINK} + processing. + + Currently the GNAT run time requires a FPU using 80 bits mode + precision. Under targets where this is not the default it is required to + call GNAT.Float_Control.Reset before using floating point numbers (this + include float computation, float input and output) in the Ada code. A + side effect is that this could be the wrong mode for the foreign code + where floating point computation could be broken after this call. + + @node Binding Programs with No Main Subprogram + @section Binding Programs with No Main Subprogram + + @noindent + It is possible to have an Ada program which does not have a main + subprogram. This program will call the elaboration routines of all the + packages, then the finalization routines. + + The following qualifier is used to bind programs organized in this manner: + + @table @code + @item /ZERO_MAIN + @cindex @code{/ZERO_MAIN} (@code{GNAT BIND}) + Normally the binder checks that the unit name given on the command line + corresponds to a suitable main subprogram. When this qualifier is used, + a list of ALI files can be given, and the execution of the program + consists of elaboration of these units in an appropriate order. + @end table + + @node Summary of Binder Qualifiers + @section Summary of Binder Qualifiers + + @noindent + The following are the qualifiers available with @code{GNAT BIND}: + + @table @code + @item /OBJECT_SEARCH + Specify directory to be searched for ALI files. + + @item /SOURCE_SEARCH + Specify directory to be searched for source file. + + @item /BIND_FILE=ADA + Generate binder program in Ada (default) + + @item /REPORT_ERRORS=BRIEF + Generate brief messages to @file{SYS$ERROR} even if verbose mode set. + + @item /NOOUTPUT + Check only, no generation of binder output file. + + @item /BIND_FILE=C + Generate binder program in C + + @item /ELABORATION_DEPENDENCIES + Output complete list of elaboration-order dependencies. + + @item -E + Store tracebacks in exception occurrences when the target supports it. + This is the default with the zero cost exception mechanism. + This option is currently supported on the following targets: + all x86 ports, Solaris, Windows, HP-UX, AIX, PowerPC VxWorks and Alpha VxWorks. + See also the packages @code{GNAT.Traceback} and + @code{GNAT.Traceback.Symbolic} for more information. + Note that on x86 ports, you must not use @code{-fomit-frame-pointer} + @code{GNAT COMPILE} option. + + @item -h + Output usage (help) information + + @item /SEARCH + Specify directory to be searched for source and ALI files. + + @item /NOCURRENT_DIRECTORY + Do not look for sources in the current directory where @code{GNAT BIND} was + invoked, and do not look for ALI files in the directory containing the + ALI file named in the @code{GNAT BIND} command line. + + @item /ORDER_OF_ELABORATION + Output chosen elaboration order. + + @item -Lxxx + Binds the units for library building. In this case the adainit and + adafinal procedures (See @pxref{Binding with Non-Ada Main Programs}) + are renamed to xxxinit and xxxfinal. Implies -n. + + @item -Mxyz + Rename generated main program from main to xyz + + @item /ERROR_LIMIT=@var{n} + Limit number of detected errors to @var{n} (1-999). + + @item /NOMAIN + No main program. + + @item /NOSTD_INCLUDES + Do not look for sources in the system default directory. + + @item /NOSTD_LIBRARIES + Do not look for library files in the system default directory. + + @item /RUNTIME_SYSTEM=@var{rts-path} + @cindex @code{/RUNTIME_SYSTEM} (@code{GNAT BIND}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{GNAT MAKE} flag (see @ref{Qualifiers for GNAT MAKE}). + + @item /OUTPUT=@var{file} + Name the output file @var{file} (default is @file{B$@var{xxx}.ADB}). + Note that if this option is used, then linking must be done manually, + GNAT LINK cannot be used. + + @item /OBJECT_LIST + Output object list. + + @item -p + Pessimistic (worst-case) elaboration order + + @item /READ_SOURCES=ALL + Require all source files to be present. + + + @item /NOTIME_STAMP_CHECK + Tolerate time stamp and other consistency errors + + @item -T@var{n} + Set the time slice value to n microseconds. A value of zero means no time + slicing and also indicates to the tasking run time to match as close as + possible to the annex D requirements of the RM. + + @item /REPORT_ERRORS=VERBOSE + Verbose mode. Write error messages, header, summary output to + @file{SYS$OUTPUT}. + + + @item /WARNINGS=NORMAL + Normal warnings mode. Warnings are issued but ignored + + @item /WARNINGS=SUPPRESS + All warning messages are suppressed + + @item /WARNINGS=ERROR + Warning messages are treated as fatal errors + + @item /READ_SOURCES=NONE + Exclude source files (check object consistency only). + + @item /READ_SOURCES=AVAILABLE + Default mode, in which sources are checked for consistency only if + they are available. + + @item /ZERO_MAIN + No main subprogram. + + @end table + + + @node Command-Line Access + @section Command-Line Access + + @noindent + The package @code{Ada.Command_Line} provides access to the command-line + arguments and program name. In order for this interface to operate + correctly, the two variables + + @smallexample + @group + @cartouche + int gnat_argc; + char **gnat_argv; + @end cartouche + @end group + @end smallexample + + @noindent + @findex gnat_argv + @findex gnat_argc + are declared in one of the GNAT library routines. These variables must + be set from the actual @code{argc} and @code{argv} values passed to the + main program. With no @code{/NOMAIN} present, @code{GNAT BIND} + generates the C main program to automatically set these variables. + If the @code{/NOMAIN} qualifier is used, there is no automatic way to + set these variables. If they are not set, the procedures in + @code{Ada.Command_Line} will not be available, and any attempt to use + them will raise @code{Constraint_Error}. If command line access is + required, your main program must set @code{gnat_argc} and + @code{gnat_argv} from the @code{argc} and @code{argv} values passed to + it. + + @node Search Paths for GNAT BIND + @section Search Paths for @code{GNAT BIND} + + @noindent + The binder takes the name of an ALI file as its argument and needs to + locate source files as well as other ALI files to verify object consistency. + + For source files, it follows exactly the same search rules as @code{GNAT COMPILE} + (@pxref{Search Paths and the Run-Time Library (RTL)}). For ALI files the + directories searched are: + + @enumerate + @item + The directory containing the ALI file named in the command line, unless + the qualifier @code{/NOCURRENT_DIRECTORY} is specified. + + @item + All directories specified by @code{/SEARCH} + qualifiers on the @code{GNAT BIND} + command line, in the order given. + + @item + @findex ADA_OBJECTS_PATH + Each of the directories listed in the value of the + @code{ADA_OBJECTS_PATH} logical name. + Normally, define this value as a logical name containing a comma separated + list of directory names. + + This variable can also be defined by means of an environment string + (an argument to the DEC C exec* set of functions). + + Logical Name: + @smallexample + DEFINE ANOTHER_PATH FOO:[BAG] + DEFINE ADA_OBJECTS_PATH ANOTHER_PATH,FOO:[BAM],FOO:[BAR] + @end smallexample + + By default, the path includes GNU:[LIB.OPENVMS7_x.2_8_x.DECLIB] + first, followed by the standard Ada 95 + libraries in GNU:[LIB.OPENVMS7_x.2_8_x.ADALIB]. + If this is not redefined, the user will obtain the DEC Ada83 IO packages + (Text_IO, Sequential_IO, etc) + instead of the Ada95 packages. Thus, in order to get the Ada 95 + packages by default, ADA_OBJECTS_PATH must be redefined. + + @item + The content of the "ada_object_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as the + GNAT Run Time Library (RTL) unless the qualifier @code{/NOSTD_LIBRARIES} is + specified. + @end enumerate + + @noindent + In the binder the qualifier @code{/SEARCH} + is used to specify both source and + library file paths. Use @code{/SOURCE_SEARCH} + instead if you want to specify + source paths only, and @code{/LIBRARY_SEARCH} + if you want to specify library paths + only. This means that for the binder + @code{/SEARCH=}@var{dir} is equivalent to + @code{/SOURCE_SEARCH=}@var{dir} + @code{/OBJECT_SEARCH=}@var{dir}. + The binder generates the bind file (a C language source file) in the + current working directory. + + @findex Ada + @findex System + @findex Interfaces + @findex GNAT + The packages @code{Ada}, @code{System}, and @code{Interfaces} and their + children make up the GNAT Run-Time Library, together with the package + GNAT and its children, which contain a set of useful additional + library functions provided by GNAT. The sources for these units are + needed by the compiler and are kept together in one directory. The ALI + files and object files generated by compiling the RTL are needed by the + binder and the linker and are kept together in one directory, typically + different from the directory containing the sources. In a normal + installation, you need not specify these directory names when compiling + or binding. Either the environment variables or the built-in defaults + cause these files to be found. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + + @node Examples of GNAT BIND Usage + @section Examples of @code{GNAT BIND} Usage + + @noindent + This section contains a number of examples of using the GNAT binding + utility @code{GNAT BIND}. + + @table @code + @item GNAT BIND hello + The main program @code{Hello} (source program in @file{HELLO.ADB}) is + bound using the standard qualifier settings. The generated main program is + @file{B~HELLO.ADB}. This is the normal, default use of the binder. + + @item GNAT BIND HELLO.ALI /OUTPUT=Mainprog.ADB + The main program @code{Hello} (source program in @file{HELLO.ADB}) is + bound using the standard qualifier settings. The generated main program is + @file{MAINPROG.ADB} with the associated spec in + @file{MAINPROG.ADS}. Note that you must specify the body here not the + spec, in the case where the output is in Ada. Note that if this option + is used, then linking must be done manually, since GNAT LINK will not + be able to find the generated file. + + @item GNAT BIND MAIN.ALI /BIND_FILE=C /OUTPUT=Mainprog.C /READ_SOURCES=NONE + The main program @code{Main} (source program in + @file{MAIN.ADB}) is bound, excluding source files from the + consistency checking, generating + the file @file{MAINPROG.C}. + + + @item GNAT BIND /NOMAIN math dbase /BIND_FILE=C /OUTPUT=ADA-CONTROL.C + The main program is in a language other than Ada, but calls to + subprograms in packages @code{Math} and @code{Dbase} appear. This call + to @code{GNAT BIND} generates the file @file{ADA-CONTROL.C} containing + the @code{adainit} and @code{adafinal} routines to be called before and + after accessing the Ada units. + @end table + + @node Linking Using GNAT LINK + @chapter Linking Using @code{GNAT LINK} + @findex GNAT LINK + + @noindent + This chapter discusses @code{GNAT LINK}, a utility program used to link + Ada programs and build an executable file. This is a simple program + that invokes the Unix linker (via the @code{GNAT COMPILE} + command) with a correct list of object files and library references. + @code{GNAT LINK} automatically determines the list of files and + references for the Ada part of a program. It uses the binder file + generated by the binder to determine this list. + + @menu + * Running GNAT LINK:: + * Qualifiers for GNAT LINK:: + * Setting Stack Size from GNAT LINK:: + * Setting Heap Size from GNAT LINK:: + @end menu + + @node Running GNAT LINK + @section Running @code{GNAT LINK} + + @noindent + The form of the @code{GNAT LINK} command is + + @smallexample + $ GNAT LINK [@var{qualifiers}] @var{mainprog}[.ALI] [@var{non-Ada objects}] + [@var{linker options}] + @end smallexample + + @noindent + @file{@var{mainprog}.ALI} references the ALI file of the main program. + The @file{.ALI} extension of this file can be omitted. From this + reference, @code{GNAT LINK} locates the corresponding binder file + @file{B$@var{mainprog}.ADB} and, using the information in this file along + with the list of non-Ada objects and linker options, constructs a Unix + linker command file to create the executable. + + The arguments following @file{@var{mainprog}.ALI} are passed to the + linker uninterpreted. They typically include the names of object files + for units written in other languages than Ada and any library references + required to resolve references in any of these foreign language units, + or in @code{pragma Import} statements in any Ada units. + + @var{linker options} is an optional list of linker specific + qualifiers. The default linker called by GNAT LINK is @var{GNAT COMPILE} which in + turn calls the appropriate system linker usually called + @var{ld}. Standard options for the linker such as @code{-lmy_lib} or + @code{-Ldir} can be added as is. For options that are not recognized by + @var{GNAT COMPILE} as linker options, the @var{GNAT COMPILE} qualifiers @code{-Xlinker} or + @code{-Wl,} shall be used. Refer to the GCC documentation for + details. Here is an example showing how to generate a linker map + assuming that the underlying linker is GNU ld: + + @smallexample + $ GNAT LINK my_prog -Wl,-Map,MAPFILE + @end smallexample + + Using @var{linker options} it is possible to set the program stack and + heap size. See @pxref{Setting Stack Size from GNAT LINK} and + @pxref{Setting Heap Size from GNAT LINK}. + + @code{GNAT LINK} determines the list of objects required by the Ada + program and prepends them to the list of objects passed to the linker. + @code{GNAT LINK} also gathers any arguments set by the use of + @code{pragma Linker_Options} and adds them to the list of arguments + presented to the linker. + + @code{GNAT LINK} accepts the following types of extra files on the command + line: objects (.OBJ), libraries (.OLB), shareable images (.EXE), and + options files (.OPT). These are recognized and handled according to their + extension. + + @node Qualifiers for GNAT LINK + @section Qualifiers for @code{GNAT LINK} + + @noindent + The following qualifiers are available with the @code{GNAT LINK} utility: + + @table @code + + @item /BIND_FILE=ADA + @cindex @code{/BIND_FILE=ADA} (@code{GNAT LINK}) + The binder has generated code in Ada. This is the default. + + @item /BIND_FILE=C + @cindex @code{/BIND_FILE=C} (@code{GNAT LINK}) + If instead of generating a file in Ada, the binder has generated one in + C, then the linker needs to know about it. Use this qualifier to signal + to @code{GNAT LINK} that the binder has generated C code rather than + Ada code. + + @item -f + @cindex Command line length + @cindex @code{-f} (@code{GNAT LINK}) + On some targets, the command line length is limited, and @code{GNAT LINK} + will generate a separate file for the linker if the list of object files + is too long. The @code{-f} flag forces this file to be generated even if + the limit is not exceeded. This is useful in some cases to deal with + special situations where the command line length is exceeded. + + @item /DEBUG + @cindex Debugging information, including + @cindex @code{/DEBUG} (@code{GNAT LINK}) + The option to include debugging information causes the Ada bind file (in + other words, @file{B$@var{mainprog}.ADB}) to be compiled with + @code{/DEBUG}. + In addition, the binder does not delete the @file{B$@var{mainprog}.ADB}, + @file{B$@var{mainprog}.OBJ} and @file{B$@var{mainprog}.ALI} files. + Without @code{/DEBUG}, the binder removes these files by + default. The same procedure apply if a C bind file was generated using + @code{/BIND_FILE=C} @code{GNAT BIND} option, in this case the filenames are + @file{B_@var{mainprog}.C} and @file{B_@var{mainprog}.OBJ}. + + + @item /VERBOSE + @cindex @code{/VERBOSE} (@code{GNAT LINK}) + Causes additional information to be output, including a full list of the + included object files. This qualifier option is most useful when you want + to see what set of object files are being used in the link step. + + + @item /EXECUTABLE=@var{exec-name} + @cindex @code{/EXECUTABLE} (@code{GNAT LINK}) + @var{exec-name} specifies an alternate name for the generated + executable program. If this qualifier is omitted, the executable has the same + name as the main unit. For example, @code{GNAT LINK TRY.ALI} creates + an executable called @file{TRY.EXE}. + + + @item /DEBUG=TRACEBACK + @cindex @code{/DEBUG=TRACEBACK} (@code{GNAT LINK}) + This qualifier causes sufficient information to be included in the + executable file to allow a traceback, but does not include the full + symbol information needed by the debugger. + + @item /IDENTIFICATION="" + "" specifies the string to be stored in the image file identification + field in the image header. It overrides any pragma Ident specified string. + + @item /NOINHIBIT-EXEC + Generate the executable file even if there are linker warnings. + + @item /NOSTART_FILES + Don't link in the object file containing the "main" transfer address. + Used when linking with a foreign language main program compiled with a + Digital compiler. + + @item /STATIC + Prefer linking with object libraries over shareable images, even without + /DEBUG. + + @end table + + @node Setting Stack Size from GNAT LINK + @section Setting Stack Size from @code{GNAT LINK} + + @noindent + It is possible to specify the program stack size from @code{GNAT LINK}. + Assuming that the underlying linker is GNU ld there is two ways to do so: + + @itemize @bullet + + @item using @code{-Xlinker} linker option + + @smallexample + $ GNAT LINK hello -Xlinker --stack=0x10000,0x1000 + @end smallexample + + This set the stack reserve size to 0x10000 bytes and the stack commit + size to 0x1000 bytes. + + @item using @code{-Wl} linker option + + @smallexample + $ GNAT LINK hello -Wl,--stack=0x1000000 + @end smallexample + + This set the stack reserve size to 0x1000000 bytes. Note that with + @code{-Wl} option it is not possible to set the stack commit size + because the coma is a separator for this option. + + @end itemize + + @node Setting Heap Size from GNAT LINK + @section Setting Heap Size from @code{GNAT LINK} + + @noindent + It is possible to specify the program heap size from @code{GNAT LINK}. + Assuming that the underlying linker is GNU ld there is two ways to do so: + + @itemize @bullet + + @item using @code{-Xlinker} linker option + + @smallexample + $ GNAT LINK hello -Xlinker --heap=0x10000,0x1000 + @end smallexample + + This set the heap reserve size to 0x10000 bytes and the heap commit + size to 0x1000 bytes. + + @item using @code{-Wl} linker option + + @smallexample + $ GNAT LINK hello -Wl,--heap=0x1000000 + @end smallexample + + This set the heap reserve size to 0x1000000 bytes. Note that with + @code{-Wl} option it is not possible to set the heap commit size + because the coma is a separator for this option. + + @end itemize + + @node The GNAT Make Program GNAT MAKE + @chapter The GNAT Make Program @code{GNAT MAKE} + @findex GNAT MAKE + + @menu + * Running GNAT MAKE:: + * Qualifiers for GNAT MAKE:: + * Mode Qualifiers for GNAT MAKE:: + * Notes on the Command Line:: + * How GNAT MAKE Works:: + * Examples of GNAT MAKE Usage:: + @end menu + @noindent + A typical development cycle when working on an Ada program consists of + the following steps: + + @enumerate + @item + Edit some sources to fix bugs. + + @item + Add enhancements. + + @item + Compile all sources affected. + + @item + Rebind and relink. + + @item + Test. + @end enumerate + + @noindent + The third step can be tricky, because not only do the modified files + @cindex Dependency rules + have to be compiled, but any files depending on these files must also be + recompiled. The dependency rules in Ada can be quite complex, especially + in the presence of overloading, @code{use} clauses, generics and inlined + subprograms. + + @code{GNAT MAKE} automatically takes care of the third and fourth steps + of this process. It determines which sources need to be compiled, + compiles them, and binds and links the resulting object files. + + Unlike some other Ada make programs, the dependencies are always + accurately recomputed from the new sources. The source based approach of + the GNAT compilation model makes this possible. This means that if + changes to the source program cause corresponding changes in + dependencies, they will always be tracked exactly correctly by + @code{GNAT MAKE}. + + @node Running GNAT MAKE + @section Running @code{GNAT MAKE} + + @noindent + The usual form of the @code{GNAT MAKE} command is + + @smallexample + $ GNAT MAKE [@var{qualifiers}] @var{file_name} [@var{file_names}] [@var{mode_qualifiers}] + @end smallexample + + @noindent + The only required argument is one @var{file_name}, which specifies + a compilation unit that is a main program. Several @var{file_names} can be + specified: this will result in several executables being built. + If @code{qualifiers} are present, they can be placed before the first + @var{file_name}, between @var{file_names} or after the last @var{file_name}. + If @var{mode_qualifiers} are present, they must always be placed after + the last @var{file_name} and all @code{qualifiers}. + + If you are using standard file extensions (.ADB and .ADS), then the + extension may be omitted from the @var{file_name} arguments. However, if + you are using non-standard extensions, then it is required that the + extension be given. A relative or absolute directory path can be + specified in a @var{file_name}, in which case, the input source file will + be searched for in the specified directory only. Otherwise, the input + source file will first be searched in the directory where + @code{GNAT MAKE} was invoked and if it is not found, it will be search on + the source path of the compiler as described in + @ref{Search Paths and the Run-Time Library (RTL)}. + + When several @var{file_names} are specified, if an executable needs to be + rebuilt and relinked, all subsequent executables will be rebuilt and + relinked, even if this would not be absolutely necessary. + + All @code{GNAT MAKE} output (except when you specify + @code{/DEPENDENCIES_LIST}) is to + @file{SYS$ERROR}. The output produced by the + @code{/DEPENDENCIES_LIST} qualifier is send to + @file{SYS$OUTPUT}. + + @node Qualifiers for GNAT MAKE + @section Qualifiers for @code{GNAT MAKE} + + @noindent + You may specify any of the following qualifiers to @code{GNAT MAKE}: + + @table @code + + @item /ALL_FILES + @cindex @code{/ALL_FILES} (@code{GNAT MAKE}) + Consider all files in the make process, even the GNAT internal system + files (for example, the predefined Ada library files), as well as any + locked files. Locked files are files whose ALI file is write-protected. + By default, + @code{GNAT MAKE} does not check these files, + because the assumption is that the GNAT internal files are properly up + to date, and also that any write protected ALI files have been properly + installed. Note that if there is an installation problem, such that one + of these files is not up to date, it will be properly caught by the + binder. + You may have to specify this qualifier if you are working on GNAT + itself. @code{/ALL_FILES} is also useful in conjunction with + @code{/FORCE_COMPILE} + if you need to recompile an entire application, + including run-time files, using special configuration pragma settings, + such as a non-standard @code{Float_Representation} pragma. + By default + @code{GNAT MAKE /ALL_FILES} compiles all GNAT + internal files with + the @code{/CHECKS=SUPPRESS_ALL /STYLE_CHECKS=GNAT} qualifier. + + @item /ACTIONS=BIND + @cindex @code{/ACTIONS=BIND} (@code{GNAT MAKE}) + Bind only. Can be combined with @code{/ACTIONS=COMPILE} to do compilation + and binding, but no link. Can be combined with @code{/ACTIONS=LINK} + to do binding and linking. When not combined with @code{/ACTIONS=COMPILE} + all the units in the closure of the main program must have been previously + compiled and must be up to date. The root unit specified by @var{file_name} + may be given without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + @item /ACTIONS=COMPILE + @cindex @code{/ACTIONS=COMPILE} (@code{GNAT MAKE}) + Compile only. Do not perform binding, except when @code{/ACTIONS=BIND} + is also specified. Do not perform linking, except if both + @code{/ACTIONS=BIND} and + @code{/ACTIONS=LINK} are also specified. + If the root unit specified by @var{file_name} is not a main unit, this is the + default. Otherwise @code{GNAT MAKE} will attempt binding and linking + unless all objects are up to date and the executable is more recent than + the objects. + + @item /MAPPING + @cindex @code{/MAPPING} (@code{GNAT MAKE}) + Use a mapping file. A mapping file is a way to communicate to the compiler + two mappings: from unit names to file names (without any directory information) + and from file names to path names (with full directory information). + These mappings are used by the compiler to short-circuit the path search. + When @code{GNAT MAKE} is invoked with this qualifier, it will create a mapping + file, initially populated by the project manager, if @code{-P} is used, + otherwise initially empty. Each invocation of the compiler will add the newly + accessed sources to the mapping file. This will improve the source search + during the next invocation of the compiler. + + @item /FORCE_COMPILE + @cindex @code{/FORCE_COMPILE} (@code{GNAT MAKE}) + Force recompilations. Recompile all sources, even though some object + files may be up to date, but don't recompile predefined or GNAT internal + files or locked files (files with a write-protected ALI file), + unless the @code{/ALL_FILES} qualifier is also specified. + + @item + @item /IN_PLACE + @cindex @code{/IN_PLACE} (@code{GNAT MAKE}) + In normal mode, @code{GNAT MAKE} compiles all object files and ALI files + into the current directory. If the @code{/IN_PLACE} qualifier is used, + then instead object files and ALI files that already exist are overwritten + in place. This means that once a large project is organized into separate + directories in the desired manner, then @code{GNAT MAKE} will automatically + maintain and update this organization. If no ALI files are found on the + Ada object path (@ref{Search Paths and the Run-Time Library (RTL)}), + the new object and ALI files are created in the + directory containing the source being compiled. If another organization + is desired, where objects and sources are kept in different directories, + a useful technique is to create dummy ALI files in the desired directories. + When detecting such a dummy file, @code{GNAT MAKE} will be forced to recompile + the corresponding source file, and it will be put the resulting object + and ALI files in the directory where it found the dummy file. + + @item /PROCESSES=@var{n} + @cindex @code{/PROCESSES} (@code{GNAT MAKE}) + @cindex Parallel make + Use @var{n} processes to carry out the (re)compilations. On a + multiprocessor machine compilations will occur in parallel. In the + event of compilation errors, messages from various compilations might + get interspersed (but @code{GNAT MAKE} will give you the full ordered + list of failing compiles at the end). If this is problematic, rerun + the make process with n set to 1 to get a clean list of messages. + + @item /CONTINUE_ON_ERROR + @cindex @code{/CONTINUE_ON_ERROR} (@code{GNAT MAKE}) + Keep going. Continue as much as possible after a compilation error. To + ease the programmer's task in case of compilation errors, the list of + sources for which the compile fails is given when @code{GNAT MAKE} + terminates. + + If @code{GNAT MAKE} is invoked with several @file{file_names} and with this + qualifier, if there are compilation errors when building an executable, + @code{GNAT MAKE} will not attempt to build the following executables. + + @item /ACTIONS=LINK + @cindex @code{/ACTIONS=LINK} (@code{GNAT MAKE}) + Link only. Can be combined with @code{/ACTIONS=BIND} to binding + and linking. Linking will not be performed if combined with + @code{/ACTIONS=COMPILE} + but not with @code{/ACTIONS=BIND}. + When not combined with @code{/ACTIONS=BIND} + all the units in the closure of the main program must have been previously + compiled and must be up to date, and the main program need to have been bound. + The root unit specified by @var{file_name} + may be given without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + @item /MINIMAL_RECOMPILATION + @cindex @code{/MINIMAL_RECOMPILATION} (@code{GNAT MAKE}) + Specifies that the minimum necessary amount of recompilations + be performed. In this mode @code{GNAT MAKE} ignores time + stamp differences when the only + modifications to a source file consist in adding/removing comments, + empty lines, spaces or tabs. This means that if you have changed the + comments in a source file or have simply reformatted it, using this + qualifier will tell GNAT MAKE not to recompile files that depend on it + (provided other sources on which these files depend have undergone no + semantic modifications). Note that the debugging information may be + out of date with respect to the sources if the @code{-m} qualifier causes + a compilation to be switched, so the use of this qualifier represents a + trade-off between compilation time and accurate debugging information. + + @item /DEPENDENCIES_LIST + @cindex Dependencies, producing list + @cindex @code{/DEPENDENCIES_LIST} (@code{GNAT MAKE}) + Check if all objects are up to date. If they are, output the object + dependences to @file{SYS$OUTPUT} in a form that can be directly exploited in + a @file{Makefile}. By default, each source file is prefixed with its + (relative or absolute) directory name. This name is whatever you + specified in the various @code{/SOURCE_SEARCH} + and @code{/SEARCH} qualifiers. If you use + @code{GNAT MAKE /DEPENDENCIES_LIST} + @code{/QUIET} + (see below), only the source file names, + without relative paths, are output. If you just specify the + @code{/DEPENDENCIES_LIST} + qualifier, dependencies of the GNAT internal system files are omitted. This + is typically what you want. If you also specify + the @code{/ALL_FILES} qualifier, + dependencies of the GNAT internal files are also listed. Note that + dependencies of the objects in external Ada libraries (see qualifier + @code{/SKIP_MISSING=}@var{dir} in the following list) are never reported. + + @item /DO_OBJECT_CHECK + @cindex @code{/DO_OBJECT_CHECK} (@code{GNAT MAKE}) + Don't compile, bind, or link. Checks if all objects are up to date. + If they are not, the full name of the first file that needs to be + recompiled is printed. + Repeated use of this option, followed by compiling the indicated source + file, will eventually result in recompiling all required units. + + @item /EXECUTABLE=@var{exec_name} + @cindex @code{/EXECUTABLE} (@code{GNAT MAKE}) + Output executable name. The name of the final executable program will be + @var{exec_name}. If the @code{/EXECUTABLE} qualifier is omitted the default + name for the executable will be the name of the input file in appropriate form + for an executable file on the host system. + + This qualifier cannot be used when invoking @code{GNAT MAKE} with several + @file{file_names}. + + @item /QUIET + @cindex @code{/QUIET} (@code{GNAT MAKE}) + Quiet. When this flag is not set, the commands carried out by + @code{GNAT MAKE} are displayed. + + @item /SWITCH_CHECK/ + @cindex @code{/SWITCH_CHECK} (@code{GNAT MAKE}) + Recompile if compiler qualifiers have changed since last compilation. + All compiler qualifiers but -I and -o are taken into account in the + following way: + orders between different ``first letter'' qualifiers are ignored, but + orders between same qualifiers are taken into account. For example, + @code{-O /OPTIMIZE=ALL} is different than @code{/OPTIMIZE=ALL -O}, but @code{-g -O} is equivalent + to @code{-O -g}. + + @item /UNIQUE + @cindex @code{/UNIQUE} (@code{GNAT MAKE}) + Unique. Recompile at most the main file. It implies -c. Combined with + -f, it is equivalent to calling the compiler directly. + + @item /REASONS + @cindex @code{/REASONS} (@code{GNAT MAKE}) + Verbose. Displays the reason for all recompilations @code{GNAT MAKE} + decides are necessary. + + @item /NOMAIN + @cindex @code{/NOMAIN} (@code{GNAT MAKE}) + No main subprogram. Bind and link the program even if the unit name + given on the command line is a package name. The resulting executable + will execute the elaboration routines of the package and its closure, + then the finalization routines. + + @item @code{GNAT COMPILE} @asis{qualifiers} + Any qualifier that cannot be recognized as a qualifier for @code{GNAT MAKE} + but is recognizable as a valid qualifier for @code{GNAT COMPILE} is + automatically treated as a compiler qualifier, and passed on to all + compilations that are carried out. + @end table + + @noindent + Source and library search path qualifiers: + + @table @code + @item /SOURCE_SEARCH=@var{dir} + @cindex @code{/SOURCE_SEARCH} (@code{GNAT MAKE}) + When looking for source files also look in directory @var{dir}. + The order in which source files search is undertaken is + described in @ref{Search Paths and the Run-Time Library (RTL)}. + + @item /SKIP_MISSING=@var{dir} + @cindex @code{/SKIP_MISSING} (@code{GNAT MAKE}) + Consider @var{dir} as being an externally provided Ada library. + Instructs @code{GNAT MAKE} to skip compilation units whose @file{.ALI} + files have been located in directory @var{dir}. This allows you to have + missing bodies for the units in @var{dir} and to ignore out of date bodies + for the same units. You still need to specify + the location of the specs for these units by using the qualifiers + @code{/SOURCE_SEARCH=@var{dir}} + or @code{/SEARCH=@var{dir}}. + Note: this qualifier is provided for compatibility with previous versions + of @code{GNAT MAKE}. The easier method of causing standard libraries + to be excluded from consideration is to write-protect the corresponding + ALI files. + + @item /OBJECT_SEARCH=@var{dir} + @cindex @code{/OBJECT_SEARCH} (@code{GNAT MAKE}) + When searching for library and object files, look in directory + @var{dir}. The order in which library files are searched is described in + @ref{Search Paths for GNAT BIND}. + + @item /CONDITIONAL_SOURCE_SEARCH=@var{dir} + @cindex Search paths, for @code{GNAT MAKE} + @cindex @code{/CONDITIONAL_SOURCE_SEARCH} (@code{GNAT MAKE}) + Equivalent to @code{/SKIP_MISSING=@var{dir} + /SOURCE_SEARCH=@var{dir}}. + + @item /SEARCH=@var{dir} + @cindex @code{/SEARCH} (@code{GNAT MAKE}) + Equivalent to @code{/OBJECT_SEARCH=@var{dir} + /SOURCE_SEARCH=@var{dir}}. + + @item /NOCURRENT_DIRECTORY + @cindex @code{/NOCURRENT_DIRECTORY} (@code{GNAT MAKE}) + @cindex Source files, suppressing search + Do not look for source files in the directory containing the source + file named in the command line. + Do not look for ALI or object files in the directory + where @code{GNAT MAKE} was invoked. + + @item /LIBRARY_SEARCH=@var{dir} + @cindex @code{/LIBRARY_SEARCH} (@code{GNAT MAKE}) + @cindex Linker libraries + Add directory @var{dir} to the list of directories in which the linker + will search for libraries. This is equivalent to + @code{/LINKER_QUALIFIERS /LIBRARY_SEARCH=}@var{dir}. + + @item /NOSTD_INCLUDES + @cindex @code{/NOSTD_INCLUDES} (@code{GNAT MAKE}) + Do not look for source files in the system default directory. + + @item /NOSTD_LIBRARIES + @cindex @code{/NOSTD_LIBRARIES} (@code{GNAT MAKE}) + Do not look for library files in the system default directory. + + @item /RUNTIME_SYSTEM=@var{rts-path} + @cindex @code{/RUNTIME_SYSTEM} (@code{GNAT MAKE}) + Specifies the default location of the runtime library. We look for the runtime + in the following directories, and stop as soon as a valid runtime is found + ("adainclude" or "ada_source_path", and "adalib" or "ada_object_path" present): + + @itemize @bullet + @item /$rts_path + + @item /$rts_path + + @item /rts-$rts_path + @end itemize + + @noindent + The selected path is handled like a normal RTS path. + + @end table + + @node Mode Qualifiers for GNAT MAKE + @section Mode Qualifiers for @code{GNAT MAKE} + + @noindent + The mode qualifiers (referred to as @code{mode_qualifiers}) allow the + inclusion of qualifiers that are to be passed to the compiler itself, the + binder or the linker. The effect of a mode qualifier is to cause all + subsequent qualifiers up to the end of the qualifier list, or up to the next + mode qualifier, to be interpreted as qualifiers to be passed on to the + designated component of GNAT. + + @table @code + @item /COMPILER_QUALIFIERS @var{qualifiers} + @cindex @code{/COMPILER_QUALIFIERS} (@code{GNAT MAKE}) + Compiler qualifiers. Here @var{qualifiers} is a list of qualifiers + that are valid qualifiers for @code{GNAT COMPILE}. They will be passed on to + all compile steps performed by @code{GNAT MAKE}. + + @item /BINDER_QUALIFIERS @var{qualifiers} + @cindex @code{/BINDER_QUALIFIERS} (@code{GNAT MAKE}) + Binder qualifiers. Here @var{qualifiers} is a list of qualifiers + that are valid qualifiers for @code{GNAT COMPILE}. They will be passed on to + all bind steps performed by @code{GNAT MAKE}. + + @item /LINKER_QUALIFIERS @var{qualifiers} + @cindex @code{/LINKER_QUALIFIERS} (@code{GNAT MAKE}) + Linker qualifiers. Here @var{qualifiers} is a list of qualifiers + that are valid qualifiers for @code{GNAT COMPILE}. They will be passed on to + all link steps performed by @code{GNAT MAKE}. + @end table + + @node Notes on the Command Line + @section Notes on the Command Line + + @noindent + This section contains some additional useful notes on the operation + of the @code{GNAT MAKE} command. + + @itemize @bullet + @item + @cindex Recompilation, by @code{GNAT MAKE} + If @code{GNAT MAKE} finds no ALI files, it recompiles the main program + and all other units required by the main program. + This means that @code{GNAT MAKE} + can be used for the initial compile, as well as during subsequent steps of + the development cycle. + + @item + If you enter @code{GNAT MAKE @var{file}.ADB}, where @file{@var{file}.ADB} + is a subunit or body of a generic unit, @code{GNAT MAKE} recompiles + @file{@var{file}.ADB} (because it finds no ALI) and stops, issuing a + warning. + + @item + In @code{GNAT MAKE} the qualifier @code{/SEARCH} + is used to specify both source and + library file paths. Use @code{/SOURCE_SEARCH} + instead if you just want to specify + source paths only and @code{/OBJECT_SEARCH} + if you want to specify library paths + only. + + @item + @code{GNAT MAKE} examines both an ALI file and its corresponding object file + for consistency. If an ALI is more recent than its corresponding object, + or if the object file is missing, the corresponding source will be recompiled. + Note that @code{GNAT MAKE} expects an ALI and the corresponding object file + to be in the same directory. + + @item + @code{GNAT MAKE} will ignore any files whose ALI file is write-protected. + This may conveniently be used to exclude standard libraries from + consideration and in particular it means that the use of the + @code{/FORCE_COMPILE} qualifier will not recompile these files + unless @code{/ALL_FILES} is also specified. + + @item + @code{GNAT MAKE} has been designed to make the use of Ada libraries + particularly convenient. Assume you have an Ada library organized + as follows: @var{[OBJ_DIR]} contains the objects and ALI files for + of your Ada compilation units, + whereas @var{[INCLUDE_DIR]} contains the + specs of these units, but no bodies. Then to compile a unit + stored in @code{MAIN.ADB}, which uses this Ada library you would just type + + @smallexample + $ GNAT MAKE /SOURCE_SEARCH=@var{[INCLUDE_DIR]} + /SKIP_MISSING=@var{[OBJ_DIR]} main + @end smallexample + + @item + Using @code{GNAT MAKE} along with the + @code{/MINIMAL_RECOMPILATION} + qualifier provides a mechanism for avoiding unnecessary rcompilations. Using + this qualifier, + you can update the comments/format of your + source files without having to recompile everything. Note, however, that + adding or deleting lines in a source files may render its debugging + info obsolete. If the file in question is a spec, the impact is rather + limited, as that debugging info will only be useful during the + elaboration phase of your program. For bodies the impact can be more + significant. In all events, your debugger will warn you if a source file + is more recent than the corresponding object, and alert you to the fact + that the debugging information may be out of date. + @end itemize + + @node How GNAT MAKE Works + @section How @code{GNAT MAKE} Works + + @noindent + Generally @code{GNAT MAKE} automatically performs all necessary + recompilations and you don't need to worry about how it works. However, + it may be useful to have some basic understanding of the @code{GNAT MAKE} + approach and in particular to understand how it uses the results of + previous compilations without incorrectly depending on them. + + First a definition: an object file is considered @dfn{up to date} if the + corresponding ALI file exists and its time stamp predates that of the + object file and if all the source files listed in the + dependency section of this ALI file have time stamps matching those in + the ALI file. This means that neither the source file itself nor any + files that it depends on have been modified, and hence there is no need + to recompile this file. + + @code{GNAT MAKE} works by first checking if the specified main unit is up + to date. If so, no compilations are required for the main unit. If not, + @code{GNAT MAKE} compiles the main program to build a new ALI file that + reflects the latest sources. Then the ALI file of the main unit is + examined to find all the source files on which the main program depends, + and @code{GNAT MAKE} recursively applies the above procedure on all these files. + + This process ensures that @code{GNAT MAKE} only trusts the dependencies + in an existing ALI file if they are known to be correct. Otherwise it + always recompiles to determine a new, guaranteed accurate set of + dependencies. As a result the program is compiled "upside down" from what may + be more familiar as the required order of compilation in some other Ada + systems. In particular, clients are compiled before the units on which + they depend. The ability of GNAT to compile in any order is critical in + allowing an order of compilation to be chosen that guarantees that + @code{GNAT MAKE} will recompute a correct set of new dependencies if + necessary. + + When invoking @code{GNAT MAKE} with several @var{file_names}, if a unit is + imported by several of the executables, it will be recompiled at most once. + + @node Examples of GNAT MAKE Usage + @section Examples of @code{GNAT MAKE} Usage + + @table @code + @item GNAT MAKE HELLO.ADB + Compile all files necessary to bind and link the main program + @file{HELLO.ADB} (containing unit @code{Hello}) and bind and link the + resulting object files to generate an executable file @file{HELLO.EXE}. + + @item GNAT MAKE main1 main2 main3 + Compile all files necessary to bind and link the main programs + @file{MAIN1.ADB} (containing unit @code{Main1}), @file{MAIN2.ADB} + (containing unit @code{Main2}) and @file{MAIN3.ADB} + (containing unit @code{Main3}) and bind and link the resulting object files + to generate three executable files @file{MAIN1.EXE}, + @file{MAIN2.EXE} + and @file{MAIN3.EXE}. + + + @item GNAT MAKE Main_Unit /QUIET /COMPILER_QUALIFIERS /OPTIMIZE=ALL /BINDER_QUALIFIERS /ORDER_OF_ELABORATION + Compile all files necessary to bind and link the main program unit + @code{Main_Unit} (from file @file{MAIN_UNIT.ADB}). All compilations will + be done with optimization level 2 and the order of elaboration will be + listed by the binder. @code{GNAT MAKE} will operate in quiet mode, not + displaying commands it is executing. + @end table + + @node Renaming Files Using GNAT CHOP + @chapter Renaming Files Using @code{GNAT CHOP} + @findex GNAT CHOP + + @noindent + This chapter discusses how to handle files with multiple units by using + the @code{GNAT CHOP} utility. This utility is also useful in renaming + files to meet the standard GNAT default file naming conventions. + + @menu + * Handling Files with Multiple Units:: + * Operating GNAT CHOP in Compilation Mode:: + * Command Line for GNAT CHOP:: + * Qualifiers for GNAT CHOP:: + * Examples of GNAT CHOP Usage:: + @end menu + + @node Handling Files with Multiple Units + @section Handling Files with Multiple Units + + @noindent + The basic compilation model of GNAT requires that a file submitted to the + compiler have only one unit and there be a strict correspondence + between the file name and the unit name. + + The @code{GNAT CHOP} utility allows both of these rules to be relaxed, + allowing GNAT to process files which contain multiple compilation units + and files with arbitrary file names. @code{GNAT CHOP} + reads the specified file and generates one or more output files, + containing one unit per file. The unit and the file name correspond, + as required by GNAT. + + If you want to permanently restructure a set of "foreign" files so that + they match the GNAT rules, and do the remaining development using the + GNAT structure, you can simply use @code{GNAT CHOP} once, generate the + new set of files and work with them from that point on. + + Alternatively, if you want to keep your files in the "foreign" format, + perhaps to maintain compatibility with some other Ada compilation + system, you can set up a procedure where you use @code{GNAT CHOP} each + time you compile, regarding the source files that it writes as temporary + files that you throw away. + + @node Operating GNAT CHOP in Compilation Mode + @section Operating GNAT CHOP in Compilation Mode + + @noindent + The basic function of @code{GNAT CHOP} is to take a file with multiple units + and split it into separate files. The boundary between files is reasonably + clear, except for the issue of comments and pragmas. In default mode, the + rule is that any pragmas between units belong to the previous unit, except + that configuration pragmas always belong to the following unit. Any comments + belong to the following unit. These rules + almost always result in the right choice of + the split point without needing to mark it explicitly and most users will + find this default to be what they want. In this default mode it is incorrect to + submit a file containing only configuration pragmas, or one that ends in + configuration pragmas, to @code{GNAT CHOP}. + + However, using a special option to activate "compilation mode", + @code{GNAT CHOP} + can perform another function, which is to provide exactly the semantics + required by the RM for handling of configuration pragmas in a compilation. + In the absence of configuration pragmas (at the main file level), this + option has no effect, but it causes such configuration pragmas to be handled + in a quite different manner. + + First, in compilation mode, if @code{GNAT CHOP} is given a file that consists of + only configuration pragmas, then this file is appended to the + @file{GNAT.ADC} file in the current directory. This behavior provides + the required behavior described in the RM for the actions to be taken + on submitting such a file to the compiler, namely that these pragmas + should apply to all subsequent compilations in the same compilation + environment. Using GNAT, the current directory, possibly containing a + @file{GNAT.ADC} file is the representation + of a compilation environment. For more information on the + @file{GNAT.ADC} file, see the section on handling of configuration + pragmas @pxref{Handling of Configuration Pragmas}. + + Second, in compilation mode, if @code{GNAT CHOP} + is given a file that starts with + configuration pragmas, and contains one or more units, then these + configuration pragmas are prepended to each of the chopped files. This + behavior provides the required behavior described in the RM for the + actions to be taken on compiling such a file, namely that the pragmas + apply to all units in the compilation, but not to subsequently compiled + units. + + Finally, if configuration pragmas appear between units, they are appended + to the previous unit. This results in the previous unit being illegal, + since the compiler does not accept configuration pragmas that follow + a unit. This provides the required RM behavior that forbids configuration + pragmas other than those preceding the first compilation unit of a + compilation. + + For most purposes, @code{GNAT CHOP} will be used in default mode. The + compilation mode described above is used only if you need exactly + accurate behavior with respect to compilations, and you have files + that contain multiple units and configuration pragmas. In this + circumstance the use of @code{GNAT CHOP} with the compilation mode + qualifier provides the required behavior, and is for example the mode + in which GNAT processes the ACVC tests. + + @node Command Line for GNAT CHOP + @section Command Line for @code{GNAT CHOP} + + @noindent + The @code{GNAT CHOP} command has the form: + + @smallexample + $ GNAT CHOP qualifiers @var{file name} [@var{file name} @var{file name} ...] + [@var{directory}] + @end smallexample + + @noindent + The only required argument is the file name of the file to be chopped. + There are no restrictions on the form of this file name. The file itself + contains one or more Ada units, in normal GNAT format, concatenated + together. As shown, more than one file may be presented to be chopped. + + When run in default mode, @code{GNAT CHOP} generates one output file in + the current directory for each unit in each of the files. + + @var{directory}, if specified, gives the name of the directory to which + the output files will be written. If it is not specified, all files are + written to the current directory. + + For example, given a + file called @file{hellofiles} containing + + @smallexample + @group + @cartouche + @b{procedure} hello; + + @b{with} Text_IO; @b{use} Text_IO; + @b{procedure} hello @b{is} + @b{begin} + Put_Line ("Hello"); + @b{end} hello; + @end cartouche + @end group + @end smallexample + + @noindent + the command + + @smallexample + $ GNAT CHOP HELLOFILES. + @end smallexample + + @noindent + generates two files in the current directory, one called + @file{HELLO.ADS} containing the single line that is the procedure spec, + and the other called @file{HELLO.ADB} containing the remaining text. The + original file is not affected. The generated files can be compiled in + the normal manner. + + @node Qualifiers for GNAT CHOP + @section Qualifiers for @code{GNAT CHOP} + + @noindent + @code{GNAT CHOP} recognizes the following qualifiers: + + @table @code + + @item /COMPILATION + @cindex @code{/COMPILATION} (@code{GNAT CHOP}) + Causes @code{GNAT CHOP} to operate in compilation mode, in which + configuration pragmas are handled according to strict RM rules. See + previous section for a full description of this mode. + + + @item /HELP + Causes @code{GNAT CHOP} to generate a brief help summary to the standard + output file showing usage information. + + @item /FILE_NAME_MAX_LENGTH=@var{mm} + @cindex @code{/FILE_NAME_MAX_LENGTH} (@code{GNAT CHOP}) + Limit generated file names to the specified number @code{mm} + of characters. + This is useful if the + resulting set of files is required to be interoperable with systems + which limit the length of file names. + If no value is given, or + if no @code{/FILE_NAME_MAX_LENGTH} qualifier is given, + a default of 39, suitable for OpenVMS Alpha + Systems, is assumed + + @item /PRESERVE + @cindex @code{/PRESERVE} (@code{GNAT CHOP}) + Causes the file creation time stamp of the input file to be + preserved and used for the time stamp of the output file(s). This may be + useful for preserving coherency of time stamps in an enviroment where + @code{GNAT CHOP} is used as part of a standard build process. + + @item /QUIET + @cindex @code{/QUIET} (@code{GNAT CHOP}) + Causes output of informational messages indicating the set of generated + files to be suppressed. Warnings and error messages are unaffected. + + @item /REFERENCE + @cindex @code{/REFERENCE} (@code{GNAT CHOP}) + @findex Source_Reference + Generate @code{Source_Reference} pragmas. Use this qualifier if the output + files are regarded as temporary and development is to be done in terms + of the original unchopped file. This qualifier causes + @code{Source_Reference} pragmas to be inserted into each of the + generated files to refers back to the original file name and line number. + The result is that all error messages refer back to the original + unchopped file. + In addition, the debugging information placed into the object file (when + the @code{/DEBUG} qualifier of @code{GNAT COMPILE} or @code{GNAT MAKE} is specified) also + refers back to this original file so that tools like profilers and + debuggers will give information in terms of the original unchopped file. + + If the original file to be chopped itself contains + a @code{Source_Reference} + pragma referencing a third file, then GNAT CHOP respects + this pragma, and the generated @code{Source_Reference} pragmas + in the chopped file refer to the original file, with appropriate + line numbers. This is particularly useful when @code{GNAT CHOP} + is used in conjunction with @code{GNAT PREPROCESS} to compile files that + contain preprocessing statements and multiple units. + + @item /VERBOSE + @cindex @code{/VERBOSE} (@code{GNAT CHOP}) + Causes @code{GNAT CHOP} to operate in verbose mode. The version + number and copyright notice are output, as well as exact copies of + the GNAT1 commands spawned to obtain the chop control information. + + @item /OVERWRITE + @cindex @code{/OVERWRITE} (@code{GNAT CHOP}) + Overwrite existing file names. Normally @code{GNAT CHOP} regards it as a + fatal error if there is already a file with the same name as a + file it would otherwise output, in other words if the files to be + chopped contain duplicated units. This qualifier bypasses this + check, and causes all but the last instance of such duplicated + units to be skipped. + + @end table + + @node Examples of GNAT CHOP Usage + @section Examples of @code{GNAT CHOP} Usage + + @table @code + @item GNAT CHOP /OVERWRITE HELLO_S.ADA [ICHBIAH.FILES] + + Chops the source file @file{HELLO_S.ADA}. The output files will be + placed in the directory @file{[ICHBIAH.FILES]}, + overwriting any + files with matching names in that directory (no files in the current + directory are modified). + + @item GNAT CHOP ARCHIVE. + Chops the source file @file{ARCHIVE.} + into the current directory. One + useful application of @code{GNAT CHOP} is in sending sets of sources + around, for example in email messages. The required sources are simply + concatenated (for example, using a VMS @code{APPEND/NEW} + command), and then + @code{GNAT CHOP} is used at the other end to reconstitute the original + file names. + + @item GNAT CHOP file1 file2 file3 direc + Chops all units in files @file{file1}, @file{file2}, @file{file3}, placing + the resulting files in the directory @file{direc}. Note that if any units + occur more than once anywhere within this set of files, an error message + is generated, and no files are written. To override this check, use the + @code{/OVERWRITE} qualifier, + in which case the last occurrence in the last file will + be the one that is output, and earlier duplicate occurrences for a given + unit will be skipped. + @end table + + @node Configuration Pragmas + @chapter Configuration Pragmas + @cindex Configuration pragmas + @cindex Pragmas, configuration + + @noindent + In Ada 95, configuration pragmas include those pragmas described as + such in the Ada 95 Reference Manual, as well as + implementation-dependent pragmas that are configuration pragmas. See the + individual descriptions of pragmas in the GNAT Reference Manual for + details on these additional GNAT-specific configuration pragmas. Most + notably, the pragma @code{Source_File_Name}, which allows + specifying non-default names for source files, is a configuration + pragma. The following is a complete list of configuration pragmas + recognized by @code{GNAT}: + + @smallexample + Ada_83 + Ada_95 + C_Pass_By_Copy + Component_Alignment + Discard_Names + Elaboration_Checks + Eliminate + Extend_System + Extensions_Allowed + External_Name_Casing + Float_Representation + Initialize_Scalars + License + Locking_Policy + Long_Float + No_Run_Time + Normalize_Scalars + Polling + Propagate_Exceptions + Queuing_Policy + Ravenscar + Restricted_Run_Time + Restrictions + Reviewable + Source_File_Name + Style_Checks + Suppress + Task_Dispatching_Policy + Unsuppress + Use_VADS_Size + Warnings + Validity_Checks + @end smallexample + + @menu + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + @end menu + + @node Handling of Configuration Pragmas + @section Handling of Configuration Pragmas + + Configuration pragmas may either appear at the start of a compilation + unit, in which case they apply only to that unit, or they may apply to + all compilations performed in a given compilation environment. + + GNAT also provides the @code{GNAT CHOP} utility to provide an automatic + way to handle configuration pragmas following the semantics for + compilations (that is, files with multiple units), described in the RM. + See section @pxref{Operating GNAT CHOP in Compilation Mode} for details. + However, for most purposes, it will be more convenient to edit the + @file{GNAT.ADC} file that contains configuration pragmas directly, + as described in the following section. + + @node The Configuration Pragmas Files + @section The Configuration Pragmas Files + @cindex @file{GNAT.ADC} + + @noindent + In GNAT a compilation environment is defined by the current + directory at the time that a compile command is given. This current + directory is searched for a file whose name is @file{GNAT.ADC}. If + this file is present, it is expected to contain one or more + configuration pragmas that will be applied to the current compilation. + However, if the qualifier @option{-gnatA} is used, @file{GNAT.ADC} is not + considered. + + Configuration pragmas may be entered into the @file{GNAT.ADC} file + either by running @code{GNAT CHOP} on a source file that consists only of + configuration pragmas, or more conveniently by + direct editing of the @file{GNAT.ADC} file, which is a standard format + source file. + + In addition to @file{GNAT.ADC}, one additional file containing configuration + pragmas may be applied to the current compilation using the qualifier + @option{-gnatec}@var{path}. @var{path} must designate an existing file that + contains only configuration pragmas. These configuration pragmas are + in addition to those found in @file{GNAT.ADC} (provided @file{GNAT.ADC} + is present and qualifier @option{-gnatA} is not used). + + It is allowed to specify several qualifiers @option{-gnatec}, however only + the last one on the command line will be taken into account. + + Of special interest to GNAT OpenVMS Alpha is the following configuration pragma: + + @smallexample + @cartouche + @b{pragma} Extend_System (Aux_DEC); + @end cartouche + @end smallexample + + @noindent + In the presence of this pragma, GNAT adds to the definition of the + predefined package SYSTEM all the additional types and subprograms that are + defined in DEC Ada. See @pxref{Compatibility with DEC Ada} for details. + + @node Handling Arbitrary File Naming Conventions Using gnatname + @chapter Handling Arbitrary File Naming Conventions Using @code{gnatname} + @cindex Arbitrary File Naming Conventions + + @menu + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Qualifiers for gnatname:: + * Examples of gnatname Usage:: + @end menu + + @node Arbitrary File Naming Conventions + @section Arbitrary File Naming Conventions + + @noindent + The GNAT compiler must be able to know the source file name of a compilation unit. + When using the standard GNAT default file naming conventions (@code{.ADS} for specs, + @code{.ADB} for bodies), the GNAT compiler does not need additional information. + + @noindent + When the source file names do not follow the standard GNAT default file naming + conventions, the GNAT compiler must be given additional information through + a configuration pragmas file (see @ref{Configuration Pragmas}) or a project file. + When the non standard file naming conventions are well-defined, a small number of + pragmas @code{Source_File_Name} specifying a naming pattern + (see @ref{Alternative File Naming Schemes}) may be sufficient. However, + if the file naming conventions are irregular or arbitrary, a number + of pragma @code{Source_File_Name} for individual compilation units must be defined. + To help maintain the correspondence between compilation unit names and + source file names within the compiler, + GNAT provides a tool @code{gnatname} to generate the required pragmas for a + set of files. + + @node Running gnatname + @section Running @code{gnatname} + + @noindent + The usual form of the @code{gnatname} command is + + @smallexample + $ gnatname [@var{qualifiers}] @var{naming_pattern} [@var{naming_patterns}] + @end smallexample + + @noindent + All of the arguments are optional. If invoked without any argument, + @code{gnatname} will display its usage. + + @noindent + When used with at least one naming pattern, @code{gnatname} will attempt to + find all the compilation units in files that follow at least one of the + naming patterns. To find these compilation units, + @code{gnatname} will use the GNAT compiler in syntax-check-only mode on all + regular files. + + @noindent + One or several Naming Patterns may be given as arguments to @code{gnatname}. + Each Naming Pattern is enclosed between double quotes. + A Naming Pattern is a regular expression similar to the wildcard patterns + used in file names by the Unix shells or the DOS prompt. + + @noindent + Examples of Naming Patterns are + + @smallexample + "*.[12].ADA" + "*.ad[sb]*" + "body_*" "spec_*" + @end smallexample + + @noindent + For a more complete description of the syntax of Naming Patterns, see the second kind + of regular expressions described in @file{G-REGEXP.ADS} (the "Glob" regular + expressions). + + @noindent + When invoked with no qualifiers, @code{gnatname} will create a configuration + pragmas file @file{GNAT.ADC} in the current working directory, with pragmas + @code{Source_File_Name} for each file that contains a valid Ada unit. + + @node Qualifiers for gnatname + @section Qualifiers for @code{gnatname} + + @noindent + Qualifiers for @code{gnatname} must precede any specified Naming Pattern. + + @noindent + You may specify any of the following qualifiers to @code{gnatname}: + + @table @code + + @item -c@file{file} + @cindex @code{-c} (@code{gnatname}) + Create a configuration pragmas file @file{file} (instead of the default + @file{GNAT.ADC}). There may be zero, one or more space between @code{-c} and + @file{file}. @file{file} may include directory information. @file{file} must be + writeable. There may be only one qualifier @code{-c}. When a qualifier @code{-c} is + specified, no qualifier @code{-P} may be specified (see below). + + @item -d@file{dir} + @cindex @code{-d} (@code{gnatname}) + Look for source files in directory @file{dir}. There may be zero, one or more spaces + between @code{-d} and @file{dir}. When a qualifier @code{-d} is specified, + the current working directory will not be searched for source files, unless it + is explictly + specified with a @code{-d} or @code{-D} qualifier. Several qualifiers @code{-d} may be + specified. If @file{dir} is a relative path, it is relative to the directory of + the configuration pragmas file specified with qualifier @code{-c}, or to the directory + of the project file specified with qualifier @code{-P} or, if neither qualifier @code{-c} + nor qualifier @code{-P} are specified, it is relative to the current working + directory. The directory + specified with qualifier @code{-c} must exist and be readable. + + @item -D@file{file} + @cindex @code{-D} (@code{gnatname}) + Look for source files in all directories listed in text file @file{file}. There may be + zero, one or more spaces between @code{-d} and @file{dir}. @file{file} + must be an existing, readable text file. Each non empty line in @file{file} must be + a directory. Specifying qualifier @code{-D} is equivalent to specifying as many qualifiers + @code{-d} as there are non empty lines in @file{file}. + + @item -h + @cindex @code{-h} (@code{gnatname}) + Output usage (help) information. The output is written to @file{SYS$OUTPUT}. + + @item -P@file{proj} + @cindex @code{-P} (@code{gnatname}) + Create or update project file @file{proj}. There may be zero, one or more space + between @code{-P} and @file{proj}. @file{proj} may include directory information. + @file{proj} must be writeable. There may be only one qualifier @code{-P}. + When a qualifier @code{-P} is specified, no qualifier @code{-c} may be specified. + + @item -v + @cindex @code{-v} (@code{gnatname}) + Verbose mode. Output detailed explanation of behavior to @file{SYS$OUTPUT}. This includes + name of the file written, the name of the directories to search and, for each file + in those directories whose name matches at least one of the Naming Patterns, an + indication of whether the file contains a unit, and if so the name of the unit. + + @item -v -v + Very Verbose mode. In addition to the output produced in verbose mode, for each file + in the searched directories whose name matches none of the Naming Patterns, an + indication is given that there is no match. + + @item -x@file{pattern} + Excluded patterns. Using this qualifier, it is possible to exclude some files + that would match the name patterns. For example, + @code{"gnatname -x "*_NT.ADA" "*.ADA"} will look for Ada units in all files + with the @file{.ADA} extension, except those whose names end with + @file{_NT.ADA}. + + @end table + + @node Examples of gnatname Usage + @section Examples of @code{gnatname} Usage + + @smallexample + $ gnatname -c /home/me/NAMES.ADC -d sources "[a-z]*.ADA*" + @end smallexample + + In this example, the directory @file{/home/me} must already exist and be + writeable. In addition, the directory @file{/home/me/sources} (specified by + @code{-d sources}) must exist and be readable. Note the optional spaces after + @code{-c} and @code{-d}. + + @smallexample + $ gnatname -P/home/me/proj -x "*_NT_BODY.ADA" -dsources -dsources/plus -Dcommon_dirs.txt "body_*" "spec_*" + @end smallexample + + Note that several qualifiers @code{-d} may be used, even in conjunction with one + or several qualifiers @code{-D}. Several Naming Patterns and one excluded pattern + are used in this example. + + + @c ***************************************** + @c * G N A T P r o j e c t M a n a g e r * + @c ***************************************** + @node GNAT Project Manager + @chapter GNAT Project Manager + + @menu + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Qualifiers Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + @end menu + + + @c **************** + @c * Introduction * + @c **************** + + @node Introduction + @section Introduction + + @noindent + This chapter describes GNAT's @emph{Project Manager}, a facility that + lets you configure various properties for a collection of source files. In + particular, you can specify: + @itemize @bullet + @item + The directory or set of directories containing the source files, and/or the + names of the specific source files themselves + @item + The directory in which the compiler's output + (@file{ALI} files, object files, tree files) will be placed + @item + The directory in which the executable programs will be placed + @item + Qualifier settings for any of the project-enabled tools (@command{GNAT MAKE}, + compiler, binder, linker, @code{GNAT LIST}, @code{GNAT XREF}, @code{GNAT FIND}); + you can apply these settings either globally or to individual units + @item + The source files containing the main subprogram(s) to be built + @item + The source programming language(s) (currently Ada and/or C) + @item + Source file naming conventions; you can specify these either globally or for + individual units + @end itemize + + @menu + * Project Files:: + @end menu + + @node Project Files + @subsection Project Files + + @noindent + A @dfn{project} is a specific set of values for these properties. You can + define a project's settings in a @dfn{project file}, a text file with an + Ada-like syntax; a property value is either a string or a list of strings. + Properties that are not explicitly set receive default values. A project + file may interrogate the values of @dfn{external variables} (user-defined + command-line qualifiers or environment variables), and it may specify property + settings conditionally, based on the value of such variables. + + In simple cases, a project's source files depend only on other source files + in the same project, or on the predefined libraries. ("Dependence" is in + the technical sense; for example, one Ada unit "with"ing another.) However, + the Project Manager also allows much more sophisticated arrangements, + with the source files in one project depending on source files in other + projects: + @itemize @bullet + @item + One project can @emph{import} other projects containing needed source files. + @item + You can organize GNAT projects in a hierarchy: a @emph{child} project + can extend a @emph{parent} project, inheriting the parent's source files and + optionally overriding any of them with alternative versions + @end itemize + + @noindent + More generally, the Project Manager lets you structure large development + efforts into hierarchical subsystems, with build decisions deferred to the + subsystem level and thus different compilation environments (qualifier settings) + used for different subsystems. + + The Project Manager is invoked through the @option{-P@emph{projectfile}} + qualifier to @command{GNAT MAKE} or to the @command{gnat} front driver. + If you want to define (on the command line) an external variable that is + queried by the project file, additionally use the + @option{-X@emph{vbl}=@emph{value}} qualifier. + The Project Manager parses and interprets the project file, and drives the + invoked tool based on the project settings. + + The Project Manager supports a wide range of development strategies, + for systems of all sizes. Some typical practices that are easily handled: + @itemize @bullet + @item + Using a common set of source files, but generating object files in different + directories via different qualifier settings + @item + Using a mostly-shared set of source files, but with different versions of + some unit or units + @end itemize + + @noindent + The destination of an executable can be controlled inside a project file + using the @option{-o} qualifier. In the absence of such a qualifier either inside + the project file or on the command line, any executable files generated by + @command{GNAT MAKE} will be placed in the directory @code{Exec_Dir} specified + in the project file. If no @code{Exec_Dir} is specified, they will be placed + in the object directory of the project. + + You can use project files to achieve some of the effects of a source + versioning system (for example, defining separate projects for + the different sets of sources that comprise different releases) but the + Project Manager is independent of any source configuration management tools + that might be used by the developers. + + The next section introduces the main features of GNAT's project facility + through a sequence of examples; subsequent sections will present the syntax + and semantics in more detail. + + + @c ***************************** + @c * Examples of Project Files * + @c ***************************** + + @node Examples of Project Files + @section Examples of Project Files + @noindent + This section illustrates some of the typical uses of project files and + explains their basic structure and behavior. + + @menu + * Common Sources with Different Qualifiers and Different Output Directories:: + * Using External Variables:: + * Importing Other Projects:: + * Extending a Project:: + @end menu + + @node Common Sources with Different Qualifiers and Different Output Directories + @subsection Common Sources with Different Qualifiers and Different Output Directories + + @menu + * Source Files:: + * Specifying the Object Directory:: + * Specifying the Exec Directory:: + * Project File Packages:: + * Specifying Qualifier Settings:: + * Main Subprograms:: + * Source File Naming Conventions:: + * Source Language(s):: + @end menu + + @noindent + Assume that the Ada source files @file{PACK.ADS}, @file{PACK.ADB}, and + @file{PROC.ADB} are in the @file{/common} directory. The file + @file{PROC.ADB} contains an Ada main subprogram @code{Proc} that "with"s + package @code{Pack}. We want to compile these source files under two sets + of qualifiers: + @itemize @bullet + @item + When debugging, we want to pass the @option{-g} qualifier to @command{GNAT MAKE}, + and the @option{/CHECKS=ASSERTIONS}, @option{/CHECKS=OVERFLOW}, and @option{/CHECKS=ELABORATION} qualifiers to the + compiler; the compiler's output is to appear in @file{/common/debug} + @item + When preparing a release version, we want to pass the @option{/OPTIMIZE=ALL} qualifier to + the compiler; the compiler's output is to appear in @file{/common/release} + @end itemize + + @noindent + The GNAT project files shown below, respectively @file{debug.gpr} and + @file{release.gpr} in the @file{/common} directory, achieve these effects. + + Diagrammatically: + @smallexample + @group + /common + debug.gpr + release.gpr + PACK.ADS + PACK.ADB + PROC.ADB + @end group + @group + /common/debug @{-g, /CHECKS=ASSERTIONS, /CHECKS=OVERFLOW, /CHECKS=ELABORATION@} + PROC.ALI, PROC.OBJ + PACK.ALI, PACK.OBJ + @end group + @group + /common/release @{/OPTIMIZE=ALL@} + PROC.ALI, PROC.OBJ + PACK.ALI, PACK.OBJ + @end group + @end smallexample + Here are the project files: + @smallexample + @group + project Debug is + for Object_Dir use "debug"; + for Main use ("proc"); + + package Builder is + for Default_Qualifiers ("Ada") use ("-g"); + end Builder; + @end group + + @group + package Compiler is + for Default_Qualifiers ("Ada") + use ("-fstack-check", "/CHECKS=ASSERTIONS", "/CHECKS=OVERFLOW", "/CHECKS=ELABORATION"); + end Compiler; + end Debug; + @end group + @end smallexample + + @smallexample + @group + project Release is + for Object_Dir use "release"; + for Exec_Dir use "."; + for Main use ("proc"); + + package Compiler is + for Default_Qualifiers ("Ada") use ("/OPTIMIZE=ALL"); + end Compiler; + end Release; + @end group + @end smallexample + + @noindent + The name of the project defined by @file{debug.gpr} is @code{"Debug"} (case + insensitive), and analogously the project defined by @file{release.gpr} is + @code{"Release"}. For consistency the file should have the same name as the + project, and the project file's extension should be @code{"gpr"}. These + conventions are not required, but a warning is issued if they are not followed. + + If the current directory is @file{/temp}, then the command + @smallexample + GNAT MAKE -P/common/debug.gpr + @end smallexample + + @noindent + generates object and ALI files in @file{/common/debug}, and the @code{proc} + executable also in @file{/common/debug}, using the qualifier settings defined in + the project file. + + Likewise, the command + @smallexample + GNAT MAKE -P/common/release.gpr + @end smallexample + + @noindent + generates object and ALI files in @file{/common/release}, and the @code{proc} + executable in @file{/common}, using the qualifier settings from the project file. + + @node Source Files + @unnumberedsubsubsec Source Files + + @noindent + If a project file does not explicitly specify a set of source directories or + a set of source files, then by default the project's source files are the + Ada source files in the project file directory. Thus @file{PACK.ADS}, + @file{PACK.ADB}, and @file{PROC.ADB} are the source files for both projects. + + @node Specifying the Object Directory + @unnumberedsubsubsec Specifying the Object Directory + + @noindent + Several project properties are modeled by Ada-style @emph{attributes}; + you define the property by supplying the equivalent of an Ada attribute + definition clause in the project file. + A project's object directory is such a property; the corresponding + attribute is @code{Object_Dir}, and its value is a string expression. A + directory may be specified either as absolute or as relative; in the latter + case, it is relative to the project file directory. Thus the compiler's + output is directed to @file{/common/debug} (for the @code{Debug} project) + and to @file{/common/release} (for the @code{Release} project). If + @code{Object_Dir} is not specified, then the default is the project file + directory. + + @node Specifying the Exec Directory + @unnumberedsubsubsec Specifying the Exec Directory + + @noindent + A project's exec directory is another property; the corresponding + attribute is @code{Exec_Dir}, and its value is also a string expression, + either specified as relative or absolute. If @code{Exec_Dir} is not specified, + then the default is the object directory (which may also be the project file + directory if attribute @code{Object_Dir} is not specified). Thus the executable + is placed in @file{/common/debug} for the @code{Debug} project (attribute + @code{Exec_Dir} not specified) and in @file{/common} for the @code{Release} + project. + + @node Project File Packages + @unnumberedsubsubsec Project File Packages + + @noindent + A GNAT tool integrated with the Project Manager is modeled by a + corresponding package in the project file. + The @code{Debug} project defines the packages @code{Builder} + (for @command{GNAT MAKE}) and @code{Compiler}; + the @code{Release} project defines only the @code{Compiler} package. + + The Ada package syntax is not to be taken literally. Although packages in + project files bear a surface resemblance to packages in Ada source code, the + notation is simply a way to convey a grouping of properties for a named + entity. Indeed, the package names permitted in project files are restricted + to a predefined set, corresponding to the project-aware tools, and the contents + of packages are limited to a small set of constructs. + The packages in the example above contain attribute definitions. + + + @node Specifying Qualifier Settings + @unnumberedsubsubsec Specifying Qualifier Settings + + @noindent + Qualifier settings for a project-aware tool can be specified through attributes + in the package corresponding to the tool. + The example above illustrates one of the relevant attributes, + @code{Default_Qualifiers}, defined in the packages in both project files. + Unlike simple attributes like @code{Source_Dirs}, @code{Default_Qualifiers} is + known as an @emph{associative array}. When you define this attribute, you must + supply an "index" (a literal string), and the effect of the attribute + definition is to set the value of the "array" at the specified "index". + For the @code{Default_Qualifiers} attribute, the index is a programming + language (in our case, Ada) , and the value specified (after @code{use}) + must be a list of string expressions. + + The attributes permitted in project files are restricted to a predefined set. + Some may appear at project level, others in packages. + For any attribute that is an associate array, the index must always be a + literal string, but the restrictions on this string (e.g., a file name or a + language name) depend on the individual attribute. + Also depending on the attribute, its specified value will need to be either a + string or a string list. + + In the @code{Debug} project, we set the qualifiers for two tools, + @command{GNAT MAKE} and the compiler, and thus we include corresponding + packages, with each package defining the @code{Default_Qualifiers} attribute + with index @code{"Ada"}. + Note that the package corresponding to + @command{GNAT MAKE} is named @code{Builder}. The @code{Release} project is + similar, but with just the @code{Compiler} package. + + In project @code{Debug} above the qualifiers starting with @option{-gnat} that + are specified in package @code{Compiler} could have been placed in package + @code{Builder}, since @command{GNAT MAKE} transmits all such qualifiers to the + compiler. + + @node Main Subprograms + @unnumberedsubsubsec Main Subprograms + + @noindent + One of the properties of a project is its list of main subprograms (actually + a list of names of source files containing main subprograms, with the file + extension optional. This property is captured in the @code{Main} attribute, + whose value is a list of strings. If a project defines the @code{Main} + attribute, then you do not need to identify the main subprogram(s) when + invoking @command{GNAT MAKE} (see @ref{GNAT MAKE and Project Files}). + + @node Source File Naming Conventions + @unnumberedsubsubsec Source File Naming Conventions + + @noindent + Since the project files do not specify any source file naming conventions, + the GNAT defaults are used. The mechanism for defining source file naming + conventions -- a package named @code{Naming} -- will be described below + (@pxref{Naming Schemes}). + + @node Source Language(s) + @unnumberedsubsubsec Source Language(s) + + @noindent + Since the project files do not specify a @code{Languages} attribute, by + default the GNAT tools assume that the language of the project file is Ada. + More generally, a project can comprise source files + in Ada, C, and/or other languages. + + @node Using External Variables + @subsection Using External Variables + + @noindent + Instead of supplying different project files for debug and release, we can + define a single project file that queries an external variable (set either + on the command line or via an environment variable) in order to + conditionally define the appropriate settings. Again, assume that the + source files @file{PACK.ADS}, @file{PACK.ADB}, and @file{PROC.ADB} are + located in directory @file{/common}. The following project file, + @file{build.gpr}, queries the external variable named @code{STYLE} and + defines an object directory and qualifier settings based on whether the value + is @code{"deb"} (debug) or @code{"rel"} (release), where the default is + @code{"deb"}. + + @smallexample + @group + project Build is + for Main use ("proc"); + + type Style_Type is ("deb", "rel"); + Style : Style_Type := external ("STYLE", "deb"); + + case Style is + when "deb" => + for Object_Dir use "debug"; + + when "rel" => + for Object_Dir use "release"; + for Exec_Dir use "."; + end case; + @end group + + @group + package Builder is + + case Style is + when "deb" => + for Default_Qualifiers ("Ada") use ("-g"); + end case; + + end Builder; + @end group + + @group + package Compiler is + + case Style is + when "deb" => + for Default_Qualifiers ("Ada") use ("/CHECKS=ASSERTIONS", "/CHECKS=OVERFLOW", "/CHECKS=ELABORATION"); + + when "rel" => + for Default_Qualifiers ("Ada") use ("/OPTIMIZE=ALL"); + end case; + + end Compiler; + + end Build; + @end group + @end smallexample + + @noindent + @code{Style_Type} is an example of a @emph{string type}, which is the project + file analog of an Ada enumeration type but containing string literals rather + than identifiers. @code{Style} is declared as a variable of this type. + + The form @code{external("STYLE", "deb")} is known as an + @emph{external reference}; its first argument is the name of an + @emph{external variable}, and the second argument is a default value to be + used if the external variable doesn't exist. You can define an external + variable on the command line via the @option{-X} qualifier, or you can use an + environment variable as an external variable. + + Each @code{case} construct is expanded by the Project Manager based on the + value of @code{Style}. Thus the command + @smallexample + GNAT MAKE -P/common/build.gpr -XSTYLE=deb + @end smallexample + + @noindent + is equivalent to the @command{GNAT MAKE} invocation using the project file + @file{debug.gpr} in the earlier example. So is the command + @smallexample + GNAT MAKE -P/common/build.gpr + @end smallexample + + @noindent + since @code{"deb"} is the default for @code{STYLE}. + + Analogously, + @smallexample + GNAT MAKE -P/common/build.gpr -XSTYLE=rel + @end smallexample + + @noindent + is equivalent to the @command{GNAT MAKE} invocation using the project file + @file{release.gpr} in the earlier example. + + + @node Importing Other Projects + @subsection Importing Other Projects + + @noindent + A compilation unit in a source file in one project may depend on compilation + units in source files in other projects. To obtain this behavior, the + dependent project must @emph{import} the projects containing the needed source + files. This effect is embodied in syntax similar to an Ada @code{with} clause, + but the "with"ed entities are strings denoting project files. + + As an example, suppose that the two projects @code{GUI_Proj} and + @code{Comm_Proj} are defined in the project files @file{gui_proj.gpr} and + @file{comm_proj.gpr} in directories @file{/gui} and @file{/comm}, + respectively. Assume that the source files for @code{GUI_Proj} are + @file{GUI.ADS} and @file{GUI.ADB}, and that the source files for + @code{Comm_Proj} are @file{COMM.ADS} and @file{COMM.ADB}, with each set of + files located in its respective project file directory. Diagrammatically: + + @smallexample + @group + /gui + gui_proj.gpr + GUI.ADS + GUI.ADB + @end group + + @group + /comm + comm_proj.gpr + COMM.ADS + COMM.ADB + @end group + @end smallexample + + @noindent + We want to develop an application in directory @file{/app} that "with"s the + packages @code{GUI} and @code{Comm}, using the properties of the + corresponding project files (e.g. the qualifier settings and object directory). + Skeletal code for a main procedure might be something like the following: + + @smallexample + @group + with GUI, Comm; + procedure App_Main is + ... + begin + ... + end App_Main; + @end group + @end smallexample + + @noindent + Here is a project file, @file{app_proj.gpr}, that achieves the desired + effect: + + @smallexample + @group + with "/gui/gui_proj", "/comm/comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + @end group + @end smallexample + + @noindent + Building an executable is achieved through the command: + @smallexample + GNAT MAKE -P/app/app_proj + @end smallexample + @noindent + which will generate the @code{app_main} executable in the directory where + @file{app_proj.gpr} resides. + + If an imported project file uses the standard extension (@code{gpr}) then + (as illustrated above) the @code{with} clause can omit the extension. + + Our example specified an absolute path for each imported project file. + Alternatively, you can omit the directory if either + @itemize @bullet + @item + The imported project file is in the same directory as the importing project + file, or + @item + You have defined an environment variable @code{ADA_PROJECT_PATH} that + includes the directory containing the needed project file. + @end itemize + + @noindent + Thus, if we define @code{ADA_PROJECT_PATH} to include @file{/gui} and + @file{/comm}, then our project file @file{app_proj.gpr} could be written as + follows: + + @smallexample + @group + with "gui_proj", "comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + @end group + @end smallexample + + @noindent + Importing other projects raises the possibility of ambiguities. For + example, the same unit might be present in different imported projects, or + it might be present in both the importing project and an imported project. + Both of these conditions are errors. Note that in the current version of + the Project Manager, it is illegal to have an ambiguous unit even if the + unit is never referenced by the importing project. This restriction may be + relaxed in a future release. + + @node Extending a Project + @subsection Extending a Project + + @noindent + A common situation in large software systems is to have multiple + implementations for a common interface; in Ada terms, multiple versions of a + package body for the same specification. For example, one implementation + might be safe for use in tasking programs, while another might only be used + in sequential applications. This can be modeled in GNAT using the concept + of @emph{project extension}. If one project (the "child") @emph{extends} + another project (the "parent") then by default all source files of the + parent project are inherited by the child, but the child project can + override any of the parent's source files with new versions, and can also + add new files. This facility is the project analog of extension in + Object-Oriented Programming. Project hierarchies are permitted (a child + project may be the parent of yet another project), and a project that + inherits one project can also import other projects. + + As an example, suppose that directory @file{/seq} contains the project file + @file{seq_proj.gpr} and the source files @file{PACK.ADS}, @file{PACK.ADB}, + and @file{PROC.ADB}: + + @smallexample + @group + /seq + PACK.ADS + PACK.ADB + PROC.ADB + seq_proj.gpr + @end group + @end smallexample + + @noindent + Note that the project file can simply be empty (that is, no attribute or + package is defined): + + @smallexample + @group + project Seq_Proj is + end Seq_Proj; + @end group + @end smallexample + + @noindent + implying that its source files are all the Ada source files in the project + directory. + + Suppose we want to supply an alternate version of @file{PACK.ADB}, in + directory @file{/tasking}, but use the existing versions of @file{PACK.ADS} + and @file{PROC.ADB}. We can define a project @code{Tasking_Proj} that + inherits @code{Seq_Proj}: + + @smallexample + @group + /tasking + PACK.ADB + tasking_proj.gpr + @end group + + @group + project Tasking_Proj extends "/seq/seq_proj" is + end Tasking_Proj; + @end group + @end smallexample + + @noindent + The version of @file{PACK.ADB} used in a build depends on which project file + is specified. + + Note that we could have designed this using project import rather than + project inheritance; a @code{base} project would contain the sources for + @file{PACK.ADS} and @file{PROC.ADB}, a sequential project would import + @code{base} and add @file{PACK.ADB}, and likewise a tasking project would + import @code{base} and add a different version of @file{PACK.ADB}. The + choice depends on whether other sources in the original project need to be + overridden. If they do, then project extension is necessary, otherwise, + importing is sufficient. + + + @c *********************** + @c * Project File Syntax * + @c *********************** + + @node Project File Syntax + @section Project File Syntax + + @menu + * Basic Syntax:: + * Packages:: + * Expressions:: + * String Types:: + * Variables:: + * Attributes:: + * Associative Array Attributes:: + * case Constructions:: + @end menu + + @noindent + This section describes the structure of project files. + + A project may be an @emph{independent project}, entirely defined by a single + project file. Any Ada source file in an independent project depends only + on the predefined library and other Ada source files in the same project. + + @noindent + A project may also @dfn{depend on} other projects, in either or both of the following ways: + @itemize @bullet + @item It may import any number of projects + @item It may extend at most one other project + @end itemize + + @noindent + The dependence relation is a directed acyclic graph (the subgraph reflecting + the "extends" relation is a tree). + + A project's @dfn{immediate sources} are the source files directly defined by + that project, either implicitly by residing in the project file's directory, + or explicitly through any of the source-related attributes described below. + More generally, a project @var{proj}'s @dfn{sources} are the immediate sources + of @var{proj} together with the immediate sources (unless overridden) of any + project on which @var{proj} depends (either directly or indirectly). + + @node Basic Syntax + @subsection Basic Syntax + + @noindent + As seen in the earlier examples, project files have an Ada-like syntax. + The minimal project file is: + @smallexample + @group + project Empty is + + end Empty; + @end group + @end smallexample + + @noindent + The identifier @code{Empty} is the name of the project. + This project name must be present after the reserved + word @code{end} at the end of the project file, followed by a semi-colon. + + Any name in a project file, such as the project name or a variable name, + has the same syntax as an Ada identifier. + + The reserved words of project files are the Ada reserved words plus + @code{extends}, @code{external}, and @code{project}. Note that the only Ada + reserved words currently used in project file syntax are: + + @itemize @bullet + @item + @code{case} + @item + @code{end} + @item + @code{for} + @item + @code{is} + @item + @code{others} + @item + @code{package} + @item + @code{renames} + @item + @code{type} + @item + @code{use} + @item + @code{when} + @item + @code{with} + @end itemize + + @noindent + Comments in project files have the same syntax as in Ada, two consecutives + hyphens through the end of the line. + + @node Packages + @subsection Packages + + @noindent + A project file may contain @emph{packages}. The name of a package must be one + of the identifiers (case insensitive) from a predefined list, and a package + with a given name may only appear once in a project file. The predefined list + includes the following packages: + + @itemize @bullet + @item + @code{Naming} + @item + @code{Builder} + @item + @code{Compiler} + @item + @code{Binder} + @item + @code{Linker} + @item + @code{Finder} + @item + @code{Cross_Reference} + @item + @code{GNAT LIST} + @end itemize + + @noindent + (The complete list of the package names and their attributes can be found + in file @file{PRJ-ATTR.ADB}). + + @noindent + In its simplest form, a package may be empty: + + @smallexample + @group + project Simple is + package Builder is + end Builder; + end Simple; + @end group + @end smallexample + + @noindent + A package may contain @emph{attribute declarations}, + @emph{variable declarations} and @emph{case constructions}, as will be + described below. + + When there is ambiguity between a project name and a package name, + the name always designates the project. To avoid possible confusion, it is + always a good idea to avoid naming a project with one of the + names allowed for packages or any name that starts with @code{gnat}. + + + @node Expressions + @subsection Expressions + + @noindent + An @emph{expression} is either a @emph{string expression} or a + @emph{string list expression}. + + A @emph{string expression} is either a @emph{simple string expression} or a + @emph{compound string expression}. + + A @emph{simple string expression} is one of the following: + @itemize @bullet + @item A literal string; e.g.@code{"comm/my_proj.gpr"} + @item A string-valued variable reference (see @ref{Variables}) + @item A string-valued attribute reference (see @ref{Attributes}) + @item An external reference (see @ref{External References in Project Files}) + @end itemize + + @noindent + A @emph{compound string expression} is a concatenation of string expressions, + using @code{"&"} + @smallexample + Path & "/" & File_Name & ".ADS" + @end smallexample + + @noindent + A @emph{string list expression} is either a + @emph{simple string list expression} or a + @emph{compound string list expression}. + + A @emph{simple string list expression} is one of the following: + @itemize @bullet + @item A parenthesized list of zero or more string expressions, separated by commas + @smallexample + File_Names := (File_Name, "GNAT.ADC", File_Name & ".orig"); + Empty_List := (); + @end smallexample + @item A string list-valued variable reference + @item A string list-valued attribute reference + @end itemize + + @noindent + A @emph{compound string list expression} is the concatenation (using + @code{"&"}) of a simple string list expression and an expression. Note that + each term in a compound string list expression, except the first, may be + either a string expression or a string list expression. + + @smallexample + @group + File_Name_List := () & File_Name; -- One string in this list + Extended_File_Name_List := File_Name_List & (File_Name & ".orig"); + -- Two strings + Big_List := File_Name_List & Extended_File_Name_List; + -- Concatenation of two string lists: three strings + Illegal_List := "GNAT.ADC" & Extended_File_Name_List; + -- Illegal: must start with a string list + @end group + @end smallexample + + + @node String Types + @subsection String Types + + @noindent + The value of a variable may be restricted to a list of string literals. + The restricted list of string literals is given in a + @emph{string type declaration}. + + Here is an example of a string type declaration: + + @smallexample + type OS is ("NT, "nt", "Unix", "Linux", "other OS"); + @end smallexample + + @noindent + Variables of a string type are called @emph{typed variables}; all other + variables are called @emph{untyped variables}. Typed variables are + particularly useful in @code{case} constructions + (see @ref{case Constructions}). + + A string type declaration starts with the reserved word @code{type}, followed + by the name of the string type (case-insensitive), followed by the reserved + word @code{is}, followed by a parenthesized list of one or more string literals + separated by commas, followed by a semicolon. + + The string literals in the list are case sensitive and must all be different. + They may include any graphic characters allowed in Ada, including spaces. + + A string type may only be declared at the project level, not inside a package. + + A string type may be referenced by its name if it has been declared in the same + project file, or by its project name, followed by a dot, + followed by the string type name. + + + @node Variables + @subsection Variables + + @noindent + A variable may be declared at the project file level, or in a package. + Here are some examples of variable declarations: + + @smallexample + @group + This_OS : OS := external ("OS"); -- a typed variable declaration + That_OS := "Linux"; -- an untyped variable declaration + @end group + @end smallexample + + @noindent + A @emph{typed variable declaration} includes the variable name, followed by a colon, + followed by the name of a string type, followed by @code{:=}, followed by + a simple string expression. + + An @emph{untyped variable declaration} includes the variable name, + followed by @code{:=}, followed by an expression. Note that, despite the + terminology, this form of "declaration" resembles more an assignment + than a declaration in Ada. It is a declaration in several senses: + @itemize @bullet + @item + The variable name does not need to be defined previously + @item + The declaration establishes the @emph{kind} (string versus string list) of the + variable, and later declarations of the same variable need to be consistent + with this + @end itemize + + @noindent + A string variable declaration (typed or untyped) declares a variable + whose value is a string. This variable may be used as a string expression. + @smallexample + File_Name := "readme.txt"; + Saved_File_Name := File_Name & ".saved"; + @end smallexample + + @noindent + A string list variable declaration declares a variable whose value is a list + of strings. The list may contain any number (zero or more) of strings. + + @smallexample + Empty_List := (); + List_With_One_Element := ("/STYLE="); + List_With_Two_Elements := List_With_One_Element & "/STYLE=GNAT"; + Long_List := ("MAIN.ADA", "PACK1_.ADA", "PACK1.ADA", "PACK2_.ADA" + "PACK2.ADA", "UTIL_.ADA", "UTIL.ADA"); + @end smallexample + + @noindent + The same typed variable may not be declared more than once at project level, and it may not be declared more than once in any package; it is in effect a constant or a readonly variable. + + The same untyped variable may be declared several times. + In this case, the new value replaces the old one, + and any subsequent reference to the variable uses the new value. + However, as noted above, if a variable has been declared as a string, all subsequent + declarations must give it a string value. Similarly, if a variable has + been declared as a string list, all subsequent declarations + must give it a string list value. + + A @emph{variable reference} may take several forms: + + @itemize @bullet + @item The simple variable name, for a variable in the current package (if any) or in the current project + @item A context name, followed by a dot, followed by the variable name. + @end itemize + + @noindent + A @emph{context} may be one of the following: + + @itemize @bullet + @item The name of an existing package in the current project + @item The name of an imported project of the current project + @item The name of an ancestor project (i.e., a project extended by the current project, either directly or indirectly) + @item An imported/parent project name, followed by a dot, followed by a package name + @end itemize + + @noindent + A variable reference may be used in an expression. + + + @node Attributes + @subsection Attributes + + @noindent + A project (and its packages) may have @emph{attributes} that define the project's properties. + Some attributes have values that are strings; + others have values that are string lists. + + There are two categories of attributes: @emph{simple attributes} and @emph{associative arrays} + (see @ref{Associative Array Attributes}). + + The names of the attributes are restricted; there is a list of project + attributes, and a list of package attributes for each package. + The names are not case sensitive. + + The project attributes are as follows (all are simple attributes): + + @multitable @columnfractions .4 .3 + @item @emph{Attribute Name} + @tab @emph{Value} + @item @code{Source_Files} + @tab string list + @item @code{Source_Dirs} + @tab string list + @item @code{Source_List_File} + @tab string + @item @code{Object_Dir} + @tab string + @item @code{Exec_Dir} + @tab string + @item @code{Main} + @tab string list + @item @code{Languages} + @tab string list + @item @code{Library_Dir} + @tab string + @item @code{Library_Name} + @tab string + @item @code{Library_Kind} + @tab string + @item @code{Library_Elaboration} + @tab string + @item @code{Library_Version} + @tab string + @end multitable + + @noindent + The attributes for package @code{Naming} are as follows + (see @ref{Naming Schemes}): + + @multitable @columnfractions .4 .2 .2 .2 + @item Attribute Name @tab Category @tab Index @tab Value + @item @code{Specification_Suffix} + @tab associative array + @tab language name + @tab string + @item @code{Implementation_Suffix} + @tab associative array + @tab language name + @tab string + @item @code{Separate_Suffix} + @tab simple attribute + @tab n/a + @tab string + @item @code{Casing} + @tab simple attribute + @tab n/a + @tab string + @item @code{Dot_Replacement} + @tab simple attribute + @tab n/a + @tab string + @item @code{Specification} + @tab associative array + @tab Ada unit name + @tab string + @item @code{Implementation} + @tab associative array + @tab Ada unit name + @tab string + @item @code{Specification_Exceptions} + @tab associative array + @tab language name + @tab string list + @item @code{Implementation_Exceptions} + @tab associative array + @tab language name + @tab string list + @end multitable + + @noindent + The attributes for package @code{Builder}, @code{Compiler}, @code{Binder}, + @code{Linker}, @code{Cross_Reference}, and @code{Finder} + are as follows (see @ref{Qualifiers and Project Files}). + + @multitable @columnfractions .4 .2 .2 .2 + @item Attribute Name @tab Category @tab Index @tab Value + @item @code{Default_Qualifiers} + @tab associative array + @tab language name + @tab string list + @item @code{Qualifiers} + @tab associative array + @tab file name + @tab string list + @end multitable + + @noindent + In addition, package @code{Builder} has a single string attribute + @code{Local_Configuration_Pragmas} and package @code{Builder} has a single + string attribute @code{Global_Configuration_Pragmas}. + + @noindent + The attribute for package @code{Glide} are not documented: they are for + internal use only. + + @noindent + Each simple attribute has a default value: the empty string (for string-valued + attributes) and the empty list (for string list-valued attributes). + + Similar to variable declarations, an attribute declaration defines a new value + for an attribute. + + Examples of simple attribute declarations: + + @smallexample + for Object_Dir use "objects"; + for Source_Dirs use ("units", "test/drivers"); + @end smallexample + + @noindent + A @dfn{simple attribute declaration} starts with the reserved word @code{for}, + followed by the name of the attribute, followed by the reserved word + @code{use}, followed by an expression (whose kind depends on the attribute), + followed by a semicolon. + + Attributes may be referenced in expressions. + The general form for such a reference is @code{'}: + the entity for which the attribute is defined, + followed by an apostrophe, followed by the name of the attribute. + For associative array attributes, a litteral string between parentheses + need to be supplied as index. + + Examples are: + + @smallexample + project'Object_Dir + Naming'Dot_Replacement + Imported_Project'Source_Dirs + Imported_Project.Naming'Casing + Builder'Default_Qualifiers("Ada") + @end smallexample + + @noindent + The entity may be: + @itemize @bullet + @item @code{project} for an attribute of the current project + @item The name of an existing package of the current project + @item The name of an imported project + @item The name of a parent project (extended by the current project) + @item An imported/parent project name, followed by a dot, + followed by a package name + @end itemize + + @noindent + Example: + @smallexample + @group + project Prj is + for Source_Dirs use project'Source_Dirs & "units"; + for Source_Dirs use project'Source_Dirs & "test/drivers" + end Prj; + @end group + @end smallexample + + @noindent + In the first attribute declaration, initially the attribute @code{Source_Dirs} + has the default value: an empty string list. After this declaration, + @code{Source_Dirs} is a string list of one element: "units". + After the second attribute declaration @code{Source_Dirs} is a string list of + two elements: "units" and "test/drivers". + + Note: this example is for illustration only. In practice, + the project file would contain only one attribute declaration: + + @smallexample + for Source_Dirs use ("units", "test/drivers"); + @end smallexample + + + @node Associative Array Attributes + @subsection Associative Array Attributes + + @noindent + Some attributes are defined as @emph{associative arrays}. An associative + array may be regarded as a function that takes a string as a parameter + and delivers a string or string list value as its result. + + Here are some examples of associative array attribute declarations: + + @smallexample + for Implementation ("main") use "MAIN.ADA"; + for Qualifiers ("MAIN.ADA") use ("-v", "/REPORT_ERRORS=VERBOSE"); + for Qualifiers ("MAIN.ADA") use Builder'Qualifiers ("MAIN.ADA") & "-g"; + @end smallexample + + @noindent + Like untyped variables and simple attributes, associative array attributes may be declared several times. Each declaration supplies a new value for the + attribute, replacing the previous setting. + + + @node case Constructions + @subsection @code{case} Constructions + + @noindent + A @code{case} construction is used in a project file to effect conditional + behavior. + Here is a typical example: + + @smallexample + @group + project MyProj is + type OS_Type is ("Linux", "Unix", "NT", "VMS"); + + OS : OS_Type := external ("OS", "Linux"); + @end group + + @group + package Compiler is + case OS is + when "Linux" | "Unix" => + for Default_Qualifiers ("Ada") use ("-gnath"); + when "NT" => + for Default_Qualifiers ("Ada") use ("/POLLING_ENABLE"); + when others => + end case; + end Compiler; + end MyProj; + @end group + @end smallexample + + @noindent + The syntax of a @code{case} construction is based on the Ada case statement + (although there is no @code{null} construction for empty alternatives). + + Following the reserved word @code{case} there is the case variable (a typed + string variable), the reserved word @code{is}, and then a sequence of one or + more alternatives. + Each alternative comprises the reserved word @code{when}, either a list of + literal strings separated by the @code{"|"} character or the reserved word + @code{others}, and the @code{"=>"} token. + Each literal string must belong to the string type that is the type of the + case variable. + An @code{others} alternative, if present, must occur last. + The @code{end case;} sequence terminates the case construction. + + After each @code{=>}, there are zero or more constructions. The only + constructions allowed in a case construction are other case constructions and + attribute declarations. String type declarations, variable declarations and + package declarations are not allowed. + + The value of the case variable is often given by an external reference + (see @ref{External References in Project Files}). + + + @c **************************************** + @c * Objects and Sources in Project Files * + @c **************************************** + + @node Objects and Sources in Project Files + @section Objects and Sources in Project Files + + @menu + * Object Directory:: + * Exec Directory:: + * Source Directories:: + * Source File Names:: + @end menu + + @noindent + Each project has exactly one object directory and one or more source + directories. The source directories must contain at least one source file, + unless the project file explicitly specifies that no source files are present + (see @ref{Source File Names}). + + + @node Object Directory + @subsection Object Directory + + @noindent + The object directory for a project is the directory containing the compiler's + output (such as @file{ALI} files and object files) for the project's immediate + sources. Note that for inherited sources (when extending a parent project) the + parent project's object directory is used. + + The object directory is given by the value of the attribute @code{Object_Dir} + in the project file. + + @smallexample + for Object_Dir use "objects"; + @end smallexample + + @noindent + The attribute @var{Object_Dir} has a string value, the path name of the object + directory. The path name may be absolute or relative to the directory of the + project file. This directory must already exist, and be readable and writable. + + By default, when the attribute @code{Object_Dir} is not given an explicit value + or when its value is the empty string, the object directory is the same as the + directory containing the project file. + + + @node Exec Directory + @subsection Exec Directory + + @noindent + The exec directory for a project is the directory containing the executables + for the project's main subprograms. + + The exec directory is given by the value of the attribute @code{Exec_Dir} + in the project file. + + @smallexample + for Exec_Dir use "executables"; + @end smallexample + + @noindent + The attribute @var{Exec_Dir} has a string value, the path name of the exec + directory. The path name may be absolute or relative to the directory of the + project file. This directory must already exist, and be writable. + + By default, when the attribute @code{Exec_Dir} is not given an explicit value + or when its value is the empty string, the exec directory is the same as the + object directory of the project file. + + + @node Source Directories + @subsection Source Directories + + @noindent + The source directories of a project are specified by the project file + attribute @code{Source_Dirs}. + + This attribute's value is a string list. If the attribute is not given an + explicit value, then there is only one source directory, the one where the + project file resides. + + A @code{Source_Dirs} attribute that is explicitly defined to be the empty list, + as in + + @smallexample + for Source_Dirs use (); + @end smallexample + + @noindent + indicates that the project contains no source files. + + Otherwise, each string in the string list designates one or more + source directories. + + @smallexample + for Source_Dirs use ("sources", "test/drivers"); + @end smallexample + + @noindent + If a string in the list ends with @code{"/**"}, then the directory whose path + name precedes the two asterisks, as well as all its subdirectories + (recursively), are source directories. + + @smallexample + for Source_Dirs use ("/system/sources/**"); + @end smallexample + + @noindent + Here the directory @code{/system/sources} and all of its subdirectories + (recursively) are source directories. + + To specify that the source directories are the directory of the project file + and all of its subdirectories, you can declare @code{Source_Dirs} as follows: + @smallexample + for Source_Dirs use ("./**"); + @end smallexample + + @noindent + Each of the source directories must exist and be readable. + + + @node Source File Names + @subsection Source File Names + + @noindent + In a project that contains source files, their names may be specified by the + attributes @code{Source_Files} (a string list) or @code{Source_List_File} + (a string). Source file names never include any directory information. + + If the attribute @code{Source_Files} is given an explicit value, then each + element of the list is a source file name. + + @smallexample + for Source_Files use ("MAIN.ADB"); + for Source_Files use ("MAIN.ADB", "PACK1.ADS", "PACK2.ADB"); + @end smallexample + + @noindent + If the attribute @code{Source_Files} is not given an explicit value, + but the attribute @code{Source_List_File} is given a string value, + then the source file names are contained in the text file whose path name + (absolute or relative to the directory of the project file) is the + value of the attribute @code{Source_List_File}. + + Each line in the file that is not empty or is not a comment + contains a source file name. A comment line starts with two hyphens. + + @smallexample + for Source_List_File use "source_list.txt"; + @end smallexample + + @noindent + By default, if neither the attribute @code{Source_Files} nor the attribute + @code{Source_List_File} is given an explicit value, then each file in the + source directories that conforms to the project's naming scheme + (see @ref{Naming Schemes}) is an immediate source of the project. + + A warning is issued if both attributes @code{Source_Files} and + @code{Source_List_File} are given explicit values. In this case, the attribute + @code{Source_Files} prevails. + + Each source file name must be the name of one and only one existing source file + in one of the source directories. + + A @code{Source_Files} attribute defined with an empty list as its value + indicates that there are no source files in the project. + + Except for projects that are clearly specified as containing no Ada source + files (@code{Source_Dirs} or @code{Source_Files} specified as an empty list, + or @code{Languages} specified without @code{"Ada"} in the list) + @smallexample + for Source_Dirs use (); + for Source_Files use (); + for Languages use ("C", "C++"); + @end smallexample + + @noindent + a project must contain at least one immediate source. + + Projects with no source files are useful as template packages + (see @ref{Packages in Project Files}) for other projects; in particular to + define a package @code{Naming} (see @ref{Naming Schemes}). + + + @c **************************** + @c * Importing Projects * + @c **************************** + + @node Importing Projects + @section Importing Projects + + @noindent + An immediate source of a project P may depend on source files that + are neither immediate sources of P nor in the predefined library. + To get this effect, P must @emph{import} the projects that contain the needed + source files. + + @smallexample + @group + with "project1", "utilities.gpr"; + with "/namings/apex.gpr"; + project Main is + ... + @end group + @end smallexample + + @noindent + As can be seen in this example, the syntax for importing projects is similar + to the syntax for importing compilation units in Ada. However, project files + use literal strings instead of names, and the @code{with} clause identifies + project files rather than packages. + + Each literal string is the file name or path name (absolute or relative) of a + project file. If a string is simply a file name, with no path, then its + location is determined by the @emph{project path}: + + @itemize @bullet + @item + If the environment variable @env{ADA_PROJECT_PATH} exists, then the project + path includes all the directories in this environment variable, plus the + directory of the project file. + + @item + If the environment variable @env{ADA_PROJECT_PATH} does not exist, + then the project path contains only one directory, namely the one where + the project file is located. + @end itemize + + @noindent + If a relative pathname is used as in + + @smallexample + with "tests/proj"; + @end smallexample + + @noindent + then the path is relative to the directory where the importing project file is + located. Any symbolic link will be fully resolved in the directory + of the importing project file before the imported project file is looked up. + + When the @code{with}'ed project file name does not have an extension, + the default is @file{.gpr}. If a file with this extension is not found, then + the file name as specified in the @code{with} clause (no extension) will be + used. In the above example, if a file @code{project1.gpr} is found, then it + will be used; otherwise, if a file @code{project1} exists then it will be used; + if neither file exists, this is an error. + + A warning is issued if the name of the project file does not match the + name of the project; this check is case insensitive. + + Any source file that is an immediate source of the imported project can be + used by the immediate sources of the importing project, and recursively. Thus + if @code{A} imports @code{B}, and @code{B} imports @code{C}, the immediate + sources of @code{A} may depend on the immediate sources of @code{C}, even if + @code{A} does not import @code{C} explicitly. However, this is not recommended, + because if and when @code{B} ceases to import @code{C}, some sources in + @code{A} will no longer compile. + + A side effect of this capability is that cyclic dependences are not permitted: + if @code{A} imports @code{B} (directly or indirectly) then @code{B} is not + allowed to import @code{A}. + + + @c ********************* + @c * Project Extension * + @c ********************* + + @node Project Extension + @section Project Extension + + @noindent + During development of a large system, it is sometimes necessary to use + modified versions of some of the source files without changing the original + sources. This can be achieved through a facility known as + @emph{project extension}. + + @smallexample + project Modified_Utilities extends "/baseline/utilities.gpr" is ... + @end smallexample + + @noindent + The project file for the project being extended (the @emph{parent}) is + identified by the literal string that follows the reserved word @code{extends}, + which itself follows the name of the extending project (the @emph{child}). + + By default, a child project inherits all the sources of its parent. + However, inherited sources can be overridden: a unit with the same name as one + in the parent will hide the original unit. + Inherited sources are considered to be sources (but not immediate sources) + of the child project; see @ref{Project File Syntax}. + + An inherited source file retains any qualifiers specified in the parent project. + + For example if the project @code{Utilities} contains the specification and the + body of an Ada package @code{Util_IO}, then the project + @code{Modified_Utilities} can contain a new body for package @code{Util_IO}. + The original body of @code{Util_IO} will not be considered in program builds. + However, the package specification will still be found in the project + @code{Utilities}. + + A child project can have only one parent but it may import any number of other + projects. + + A project is not allowed to import directly or indirectly at the same time a + child project and any of its ancestors. + + + @c **************************************** + @c * External References in Project Files * + @c **************************************** + + @node External References in Project Files + @section External References in Project Files + + @noindent + A project file may contain references to external variables; such references + are called @emph{external references}. + + An external variable is either defined as part of the environment (an + environment variable in Unix, for example) or else specified on the command + line via the @option{-X@emph{vbl}=@emph{value}} qualifier. If both, then the + command line value is used. + + An external reference is denoted by the built-in function + @code{external}, which returns a string value. This function has two forms: + @itemize @bullet + @item @code{external (external_variable_name)} + @item @code{external (external_variable_name, default_value)} + @end itemize + + @noindent + Each parameter must be a string literal. For example: + + @smallexample + external ("USER") + external ("OS", "Linux") + @end smallexample + + @noindent + In the form with one parameter, the function returns the value of + the external variable given as parameter. If this name is not present in the + environment, then the returned value is an empty string. + + In the form with two string parameters, the second parameter is + the value returned when the variable given as the first parameter is not + present in the environment. In the example above, if @code{"OS"} is not + the name of an environment variable and is not passed on the command line, + then the returned value will be @code{"Linux"}. + + An external reference may be part of a string expression or of a string + list expression, to define variables or attributes. + + @smallexample + @group + type Mode_Type is ("Debug", "Release"); + Mode : Mode_Type := external ("MODE"); + case Mode is + when "Debug" => + ... + @end group + @end smallexample + + + @c ***************************** + @c * Packages in Project Files * + @c ***************************** + + @node Packages in Project Files + @section Packages in Project Files + + @noindent + The @emph{package} is the project file feature that defines the settings for + project-aware tools. + For each such tool you can declare a corresponding package; the names for these + packages are preset (see @ref{Packages}) but are not case sensitive. + A package may contain variable declarations, attribute declarations, and case + constructions. + + @smallexample + @group + project Proj is + package Builder is -- used by GNAT MAKE + for Default_Qualifiers ("Ada") use ("-v", "-g"); + end Builder; + end Proj; + @end group + @end smallexample + + @noindent + A package declaration starts with the reserved word @code{package}, + followed by the package name (case insensitive), followed by the reserved word + @code{is}. It ends with the reserved word @code{end}, followed by the package + name, finally followed by a semi-colon. + + Most of the packages have an attribute @code{Default_Qualifiers}. + This attribute is an associative array, and its value is a string list. + The index of the associative array is the name of a programming language (case + insensitive). This attribute indicates the qualifier or qualifiers to be used + with the corresponding tool. + + Some packages also have another attribute, @code{Qualifiers}, an associative + array whose value is a string list. The index is the name of a source file. + This attribute indicates the qualifier or qualifiers to be used by the corresponding + tool when dealing with this specific file. + + Further information on these qualifier-related attributes is found in + @ref{Qualifiers and Project Files}. + + A package may be declared as a @emph{renaming} of another package; e.g., from + the project file for an imported project. + + @smallexample + @group + with "/global/apex.gpr"; + project Example is + package Naming renames Apex.Naming; + ... + end Example; + @end group + @end smallexample + + @noindent + Packages that are renamed in other project files often come from project files + that have no sources: they are just used as templates. Any modification in the + template will be reflected automatically in all the project files that rename + a package from the template. + + In addition to the tool-oriented packages, you can also declare a package + named @code{Naming} to establish specialized source file naming conventions + (see @ref{Naming Schemes}). + + + @c ************************************ + @c * Variables from Imported Projects * + @c ************************************ + + @node Variables from Imported Projects + @section Variables from Imported Projects + + @noindent + An attribute or variable defined in an imported or parent project can + be used in expressions in the importing / extending project. + Such an attribute or variable is prefixed with the name of the project + and (if relevant) the name of package where it is defined. + + @smallexample + @group + with "imported"; + project Main extends "base" is + Var1 := Imported.Var; + Var2 := Base.Var & ".new"; + @end group + + @group + package Builder is + for Default_Qualifiers ("Ada") use Imported.Builder.Ada_Qualifiers & + "/STYLE=GNAT" & "-v"; + end Builder; + @end group + + @group + package Compiler is + for Default_Qualifiers ("Ada") use Base.Compiler.Ada_Qualifiers; + end Compiler; + end Main; + @end group + @end smallexample + + @noindent + In this example: + + @itemize @bullet + @item + @code{Var1} is a copy of the variable @code{Var} defined in the project file + @file{"imported.gpr"} + @item + the value of @code{Var2} is a copy of the value of variable @code{Var} + defined in the project file @file{base.gpr}, concatenated with @code{".new"} + @item + attribute @code{Default_Qualifiers ("Ada")} in package @code{Builder} + is a string list that includes in its value a copy of variable + @code{Ada_Qualifiers} defined in the @code{Builder} package in project file + @file{imported.gpr} plus two new elements: @option{"/STYLE=GNAT"} and @option{"-v"}; + @item + attribute @code{Default_Qualifiers ("Ada")} in package @code{Compiler} + is a copy of the variable @code{Ada_Qualifiers} defined in the @code{Compiler} + package in project file @file{base.gpr}, the project being extended. + @end itemize + + + @c ****************** + @c * Naming Schemes * + @c ****************** + + @node Naming Schemes + @section Naming Schemes + + @noindent + Sometimes an Ada software system is ported from a foreign compilation + environment to GNAT, with file names that do not use the default GNAT + conventions. Instead of changing all the file names (which for a variety of + reasons might not be possible), you can define the relevant file naming scheme + in the @code{Naming} package in your project file. For example, the following + package models the Apex file naming rules: + + @smallexample + @group + package Naming is + for Casing use "lowercase"; + for Dot_Replacement use "."; + for Specification_Suffix ("Ada") use ".1.ADA"; + for Implementation_Suffix ("Ada") use ".2.ADA"; + end Naming; + @end group + @end smallexample + + @noindent + You can define the following attributes in package @code{Naming}: + + @table @code + + @item @var{Casing} + This must be a string with one of the three values @code{"lowercase"}, + @code{"uppercase"} or @code{"mixedcase"}; these strings are case insensitive. + + @noindent + If @var{Casing} is not specified, then the default is @code{"lowercase"}. + + @item @var{Dot_Replacement} + This must be a string whose value satisfies the following conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start or end with an alphanumeric character + @item It cannot be a single underscore + @item It cannot start with an underscore followed by an alphanumeric + @item It cannot contain a dot @code{'.'} except if it the entire string is @code{"."} + @end itemize + + @noindent + If @code{Dot_Replacement} is not specified, then the default is @code{"-"}. + + @item @var{Specification_Suffix} + This is an associative array (indexed by the programming language name, case + insensitive) whose value is a string that must satisfy the following + conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start with an alphanumeric character + @item It cannot start with an underscore followed by an alphanumeric character + @end itemize + @noindent + If @code{Specification_Suffix ("Ada")} is not specified, then the default is + @code{".ADS"}. + + @item @var{Implementation_Suffix} + This is an associative array (indexed by the programming language name, case + insensitive) whose value is a string that must satisfy the following + conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start with an alphanumeric character + @item It cannot start with an underscore followed by an alphanumeric character + @item It cannot be a suffix of @code{Specification_Suffix} + @end itemize + @noindent + If @code{Implementation_Suffix ("Ada")} is not specified, then the default is + @code{".ADB"}. + + @item @var{Separate_Suffix} + This must be a string whose value satisfies the same conditions as + @code{Implementation_Suffix}. + + @noindent + If @code{Separate_Suffix ("Ada")} is not specified, then it defaults to same + value as @code{Implementation_Suffix ("Ada")}. + + @item @var{Specification} + @noindent + You can use the @code{Specification} attribute, an associative array, to define + the source file name for an individual Ada compilation unit's spec. The array + index must be a string literal that identifies the Ada unit (case insensitive). + The value of this attribute must be a string that identifies the file that + contains this unit's spec (case sensitive or insensitive depending on the + operating system). + + @smallexample + for Specification ("MyPack.MyChild") use "mypack.mychild.spec"; + @end smallexample + + @item @var{Implementation} + + You can use the @code{Implementation} attribute, an associative array, to + define the source file name for an individual Ada compilation unit's body + (possibly a subunit). The array index must be a string literal that identifies + the Ada unit (case insensitive). The value of this attribute must be a string + that identifies the file that contains this unit's body or subunit (case + sensitive or insensitive depending on the operating system). + + @smallexample + for Implementation ("MyPack.MyChild") use "mypack.mychild.body"; + @end smallexample + @end table + + + @c ******************** + @c * Library Projects * + @c ******************** + + @node Library Projects + @section Library Projects + + @noindent + @emph{Library projects} are projects whose object code is placed in a library. + (Note that this facility is not yet supported on all platforms) + + To create a library project, you need to define in its project file + two project-level attributes: @code{Library_Name} and @code{Library_Dir}. + Additionally, you may define the library-related attributes + @code{Library_Kind}, @code{Library_Version} and @code{Library_Elaboration}. + + The @code{Library_Name} attribute has a string value that must start with a + letter and include only letters and digits. + + The @code{Library_Dir} attribute has a string value that designates the path + (absolute or relative) of the directory where the library will reside. + It must designate an existing directory, and this directory needs to be + different from the project's object directory. It also needs to be writable. + + If both @code{Library_Name} and @code{Library_Dir} are specified and + are legal, then the project file defines a library project. The optional + library-related attributes are checked only for such project files. + + The @code{Library_Kind} attribute has a string value that must be one of the + following (case insensitive): @code{"static"}, @code{"dynamic"} or + @code{"relocatable"}. If this attribute is not specified, the library is a + static library. Otherwise, the library may be dynamic or relocatable. + Depending on the operating system, there may or may not be a distinction + between dynamic and relocatable libraries. For example, on Unix there is no + such distinction. + + The @code{Library_Version} attribute has a string value whose interpretation + is platform dependent. On Unix, it is used only for dynamic/relocatable + libraries as the internal name of the library (the @code{"soname"}). If the + library file name (built from the @code{Library_Name}) is different from the + @code{Library_Version}, then the library file will be a symbolic link to the + actual file whose name will be @code{Library_Version}. + + Example (on Unix): + + @smallexample + @group + project Plib is + + Version := "1"; + + for Library_Dir use "lib_dir"; + for Library_Name use "dummy"; + for Library_Kind use "relocatable"; + for Library_Version use "libdummy.so." & Version; + + end Plib; + @end group + @end smallexample + + @noindent + Directory @file{lib_dir} will contain the internal library file whose name + will be @file{libdummy.so.1}, and @file{libdummy.so} will be a symbolic link to + @file{libdummy.so.1}. + + When @command{GNAT MAKE} detects that a project file (not the main project file) + is a library project file, it will check all immediate sources of the project + and rebuild the library if any of the sources have been recompiled. + All @file{ALI} files will also be copied from the object directory to the + library directory. To build executables, @command{GNAT MAKE} will use the + library rather than the individual object files. + + + @c ************************************* + @c * Qualifiers Related to Project Files * + @c ************************************* + @node Qualifiers Related to Project Files + @section Qualifiers Related to Project Files + + @noindent + The following qualifiers are used by GNAT tools that support project files: + + @table @code + + @item @option{-P@var{project}} + Indicates the name of a project file. This project file will be parsed with + the verbosity indicated by @option{-vP@emph{x}}, if any, and using the external + references indicated by @option{-X} qualifiers, if any. + + @noindent + There must be only one @option{-P} qualifier on the command line. + + @noindent + Since the Project Manager parses the project file only after all the qualifiers + on the command line are checked, the order of the qualifiers @option{-P}, + @option{-Vp@emph{x}} or @option{-X} is not significant. + + @item @option{-X@var{name=value}} + Indicates that external variable @var{name} has the value @var{value}. + The Project Manager will use this value for occurrences of + @code{external(name)} when parsing the project file. + + @noindent + If @var{name} or @var{value} includes a space, then @var{name=value} should be + put between quotes. + @smallexample + -XOS=NT + -X"user=John Doe" + @end smallexample + + @noindent + Several @option{-X} qualifiers can be used simultaneously. + If several @option{-X} qualifiers specify the same @var{name}, only the last one + is used. + + @noindent + An external variable specified with a @option{-X} qualifier takes precedence + over the value of the same name in the environment. + + @item @option{-vP@emph{x}} + Indicates the verbosity of the parsing of GNAT project files. + @option{-vP0} means Default (no output for syntactically correct project + files); + @option{-vP1} means Medium; + @option{-vP2} means High. + @noindent + The default is Default. + @noindent + If several @option{-vP@emph{x}} qualifiers are present, only the last one is + used. + + @end table + + + @c ********************************** + @c * Tools Supporting Project Files * + @c ********************************** + + @node Tools Supporting Project Files + @section Tools Supporting Project Files + + @menu + * GNAT MAKE and Project Files:: + * The GNAT Driver and Project Files:: + @end menu + + @node GNAT MAKE and Project Files + @subsection GNAT MAKE and Project Files + + @noindent + This section covers two topics related to @command{GNAT MAKE} and project files: + defining qualifiers for @command{GNAT MAKE} and for the tools that it invokes; + and the use of the @code{Main} attribute. + + @menu + * Qualifiers and Project Files:: + * Project Files and Main Subprograms:: + @end menu + + @node Qualifiers and Project Files + @subsubsection Qualifiers and Project Files + + @noindent + For each of the packages @code{Builder}, @code{Compiler}, @code{Binder}, and + @code{Linker}, you can specify a @code{Default_Qualifiers} attribute, a + @code{Qualifiers} attribute, or both; as their names imply, these qualifier-related + attributes affect which qualifiers are used for which files when + @command{GNAT MAKE} is invoked. As will be explained below, these + package-contributed qualifiers precede the qualifiers passed on the + @command{GNAT MAKE} command line. + + The @code{Default_Qualifiers} attribute is an associative array indexed by + language name (case insensitive) and returning a string list. For example: + + @smallexample + @group + package Compiler is + for Default_Qualifiers ("Ada") use ("/STYLE=", "-v"); + end Compiler; + @end group + @end smallexample + + @noindent + The @code{Qualifiers} attribute is also an associative array, indexed by a file + name (which may or may not be case sensitive, depending on the operating + system) and returning a string list. For example: + + @smallexample + @group + package Builder is + for Qualifiers ("MAIN1.ADB") use ("/OPTIMIZE=ALL"); + for Qualifiers ("MAIN2.ADB") use ("-g"); + end Builder; + @end group + @end smallexample + + @noindent + For the @code{Builder} package, the file names should designate source files + for main subprograms. For the @code{Binder} and @code{Linker} packages, the + file names should designate @file{ALI} or source files for main subprograms. + In each case just the file name (without explicit extension) is acceptable. + + For each tool used in a program build (@command{GNAT MAKE}, the compiler, the + binder, and the linker), its corresponding package @dfn{contributes} a set of + qualifiers for each file on which the tool is invoked, based on the + qualifier-related attributes defined in the package. In particular, the qualifiers + that each of these packages contributes for a given file @var{f} comprise: + + @itemize @bullet + @item + the value of attribute @code{Qualifiers (@var{f})}, if it is specified in the + package for the given file, + @item + otherwise, the value of @code{Default_Qualifiers ("Ada")}, if it is specified in + the package. + @end itemize + + @noindent + If neither of these attributes is defined in the package, then the package does + not contribute any qualifiers for the given file. + + When @command{GNAT MAKE} is invoked on a file, the qualifiers comprise two sets, + in the following order: those contributed for the file by the @code{Builder} + package; and the qualifiers passed on the command line. + + When @command{GNAT MAKE} invokes a tool (compiler, binder, linker) on a file, + the qualifiers passed to the tool comprise three sets, in the following order: + + @enumerate + @item + the applicable qualifiers contributed for the file by the @code{Builder} package + in the project file supplied on the command line; + + @item + those contributed for the file by the package (in the relevant project file -- + see below) corresponding to the tool; and + + @item + the applicable qualifiers passed on the command line. + @end enumerate + + @noindent + The term @emph{applicable qualifiers} reflects the fact that @command{GNAT MAKE} + qualifiers may or may not be passed to individual tools, depending on the + individual qualifier. + + @command{GNAT MAKE} may invoke the compiler on source files from different + projects. The Project Manager will use the appropriate project file to + determine the @code{Compiler} package for each source file being compiled. + Likewise for the @code{Binder} and @code{Linker} packages. + + As an example, consider the following package in a project file: + + @smallexample + @group + project Proj1 is + package Compiler is + for Default_Qualifiers ("Ada") use ("-g"); + for Qualifiers ("A.ADB") use ("/OPTIMIZE=SOME"); + for Qualifiers ("B.ADB") use ("/OPTIMIZE=ALL", "/STYLE="); + end Compiler; + end Proj1; + @end group + @end smallexample + + @noindent + If @command{GNAT MAKE} is invoked with this project file, and it needs to + compile, say, the files @file{A.ADB}, @file{B.ADB}, and @file{C.ADB}, then + @file{A.ADB} will be compiled with the qualifier @option{/OPTIMIZE=SOME}, @file{B.ADB} + with qualifiers @option{/OPTIMIZE=ALL} and @option{/STYLE=}, and @file{C.ADB} with + @option{-g}. + + Another example illustrates the ordering of the qualifiers contributed by + different packages: + + @smallexample + @group + project Proj2 is + package Builder is + for Qualifiers ("MAIN.ADB") use ("-g", "/OPTIMIZE=SOME", "-f"); + end Builder; + @end group + + @group + package Compiler is + for Qualifiers ("MAIN.ADB") use ("/OPTIMIZE=ALL"); + end Compiler; + end Proj2; + @end group + @end smallexample + + @noindent + If you issue the command: + + @smallexample + GNAT MAKE -PProj2 /OPTIMIZE=NONE main + @end smallexample + + @noindent + then the compiler will be invoked on @file{MAIN.ADB} with the following sequence of qualifiers + + @smallexample + -g /OPTIMIZE=SOME /OPTIMIZE=ALL /OPTIMIZE=NONE + @end smallexample + + with the last @option{-O} qualifier having precedence over the earlier ones; + several other qualifiers (such as @option{-c}) are added implicitly. + + The qualifiers @option{-g} and @option{/OPTIMIZE=SOME} are contributed by package + @code{Builder}, @option{/OPTIMIZE=ALL} is contributed by the package @code{Compiler} + and @option{/OPTIMIZE=NONE} comes from the command line. + + The @option{-g} qualifier will also be passed in the invocation of + @command{GNAT LINK.} + + A final example illustrates qualifier contributions from packages in different + project files: + + @smallexample + @group + project Proj3 is + for Source_Files use ("PACK.ADS", "PACK.ADB"); + package Compiler is + for Default_Qualifiers ("Ada") use ("/CHECKS=ASSERTIONS"); + end Compiler; + end Proj3; + @end group + + @group + with "Proj3"; + project Proj4 is + for Source_Files use ("FOO_MAIN.ADB", "BAR_MAIN.ADB"); + package Builder is + for Qualifiers ("FOO_MAIN.ADB") use ("-s", "-g"); + end Builder; + end Proj4; + @end group + + @group + -- Ada source file: + with Pack; + procedure Foo_Main is + ... + end Foo_Main; + @end group + @end smallexample + + If the command is + @smallexample + GNAT MAKE -PProj4 FOO_MAIN.ADB /COMPILER_QUALIFIERS /CHECKS=OVERFLOW + @end smallexample + + @noindent + then the qualifiers passed to the compiler for @file{FOO_MAIN.ADB} are + @option{-g} (contributed by the package @code{Proj4.Builder}) and + @option{/CHECKS=OVERFLOW} (passed on the command line). + When the imported package @code{Pack} is compiled, the qualifiers used are + @option{-g} from @code{Proj4.Builder}, @option{/CHECKS=ASSERTIONS} (contributed from + package @code{Proj3.Compiler}, and @option{/CHECKS=OVERFLOW} from the command line. + + + @node Project Files and Main Subprograms + @subsubsection Project Files and Main Subprograms + + @noindent + When using a project file, you can invoke @command{GNAT MAKE} + with several main subprograms, by specifying their source files on the command + line. Each of these needs to be an immediate source file of the project. + + @smallexample + GNAT MAKE -Pprj main1 main2 main3 + @end smallexample + + @noindent + When using a project file, you can also invoke @command{GNAT MAKE} without + explicitly specifying any main, and the effect depends on whether you have + defined the @code{Main} attribute. This attribute has a string list value, + where each element in the list is the name of a source file (the file + extension is optional) containing a main subprogram. + + If the @code{Main} attribute is defined in a project file as a non-empty + string list and the qualifier @option{-u} is not used on the command line, then + invoking @command{GNAT MAKE} with this project file but without any main on the + command line is equivalent to invoking @command{GNAT MAKE} with all the file + names in the @code{Main} attribute on the command line. + + Example: + @smallexample + @group + project Prj is + for Main use ("main1", "main2", "main3"); + end Prj; + @end group + @end smallexample + + @noindent + With this project file, @code{"GNAT MAKE -Pprj"} is equivalent to + @code{"GNAT MAKE -Pprj main1 main2 main3"}. + + When the project attribute @code{Main} is not specified, or is specified + as an empty string list, or when the qualifier @option{-u} is used on the command + line, then invoking @command{GNAT MAKE} with no main on the command line will + result in all immediate sources of the project file being checked, and + potentially recompiled. Depending on the presence of the qualifier @option{-u}, + sources from other project files on which the immediate sources of the main + project file depend are also checked and potentially recompiled. In other + words, the @option{-u} qualifier is applied to all of the immediate sources of themain project file. + + + @node The GNAT Driver and Project Files + @subsection The GNAT Driver and Project Files + + @noindent + A number of GNAT tools, other than @command{GNAT MAKE} are project-aware: + @command{GNAT BIND}, @command{GNAT FIND}, @command{GNAT LINK}, @command{GNAT LIST} + and @command{GNAT XREF}. However, none of these tools can be invoked directly + with a project file qualifier (@code{-P}). They need to be invoke through the + @command{gnat} driver. + + The @command{gnat} driver is a front-end that accepts a number of commands and + call the corresponding tool. It has been designed initially for VMS to convert + VMS style qualifiers to Unix style qualifiers, but it is now available to all + the GNAT supported platforms. + + On non VMS platforms, the @command{gnat} driver accepts the following commands + (case insensitive): + + @itemize @bullet + @item + BIND to invoke @command{GNAT BIND} + @item + CHOP to invoke @command{GNAT CHOP} + @item + COMP or COMPILE to invoke the compiler + @item + ELIM to invoke @command{GNAT ELIM} + @item + FIND to invoke @command{GNAT FIND} + @item + KR or KRUNCH to invoke @command{GNAT KRUNCH} + @item + LINK to invoke @command{GNAT LINK} + @item + LS or LIST to invoke @command{GNAT LIST} + @item + MAKE to invoke @command{GNAT MAKE} + @item + NAME to invoke @command{gnatname} + @item + PREP or PREPROCESS to invoke @command{GNAT PREPROCESS} + @item + PSTA or STANDARD to invoke @command{GNAT STANDARD} + @item + STUB to invoke @command{GNAT STUB} + @item + XREF to invoke @command{GNAT XREF} + @end itemize + + @noindent + Note that the compiler is invoked using the command @command{GNAT MAKE -f -u}. + + @noindent + Following the command, you may put qualifiers and arguments for the invoked + tool. + + @smallexample + gnat bind -C MAIN.ALI + gnat ls -a main + gnat chop foo.txt + @end smallexample + + @noindent + In addition, for command BIND, FIND, LS or LIST, LINK and XREF, the project + file related qualifiers (@code{-P}, @code{-X} and @code{-vPx}) may be used in + addition to the qualifiers of the invoking tool. + + @noindent + For each of these command, there is possibly a package in the main project that + corresponds to the invoked tool. + + @itemize @bullet + @item + package @code{Binder} for command BIND (invoking @code{GNAT BIND}) + + @item + package @code{Finder} for command FIND (invoking @code{GNAT FIND}) + + @item + package @code{GNAT LIST} for command LS or LIST (invoking @code{GNAT LIST}) + + @item + package @code{Linker} for command LINK (invoking @code{GNAT LINK}) + + @item + package @code{Cross_Reference} for command XREF (invoking @code{GNAT LINK}) + + @end itemize + + @noindent + Package @code{GNAT LIST} has a unique attribute @code{Qualifiers}, a simple variable + with a string list value. It contains qualifiers for the invocation of + @code{GNAT LIST}. + + @smallexample + @group + project Proj1 is + package GNAT LIST is + for Qualifiers use ("-a", "-v"); + end GNAT LIST; + end Proj1; + @end group + @end smallexample + + @noindent + All other packages contains a qualifier @code{Default_Qualifiers}, an associative + array, indexed by the programming language (case insensitive) and having a + string list value. @code{Default_Qualifiers ("Ada")} contains the qualifiers for + the invocation of the tool corresponding to the package. + + @smallexample + @group + project Proj is + + for Source_Dirs use ("./**"); + + package GNAT LIST is + for Qualifiers use ("-a", "-v"); + end GNAT LIST; + @end group + @group + + package Binder is + for Default_Qualifiers ("Ada") use ("-C", "-e"); + end Binder; + @end group + @group + + package Linker is + for Default_Qualifiers ("Ada") use ("-C"); + end Linker; + @end group + @group + + package Finder is + for Default_Qualifiers ("Ada") use ("-a", "-f"); + end Finder; + @end group + @group + + package Cross_Reference is + for Default_Qualifiers ("Ada") use ("-a", "-f", "-d", "-u"); + end Cross_Reference; + end Proj; + @end group + @end smallexample + + @noindent + With the above project file, commands such as + + @smallexample + gnat ls -Pproj main + gnat xref -Pproj main + gnat bind -Pproj MAIN.ALI + @end smallexample + + @noindent + will set up the environment properly and invoke the tool with the qualifiers + found in the package corresponding to the tool. + + + + + @node An Extended Example + @section An Extended Example + + @noindent + Suppose that we have two programs, @var{prog1} and @var{prog2}, with the sources + in the respective directories. We would like to build them with a single + @command{GNAT MAKE} command, and we would like to place their object files into + @file{.build} subdirectories of the source directories. Furthermore, we would + like to have to have two separate subdirectories in @file{.build} -- + @file{release} and @file{debug} -- which will contain the object files compiled with + different set of compilation flags. + + In other words, we have the following structure: + + @smallexample + @group + main + |- prog1 + | |- .build + | | debug + | | release + |- prog2 + |- .build + | debug + | release + @end group + @end smallexample + + @noindent + Here are the project files that we need to create in a directory @file{main} + to maintain this structure: + + @enumerate + + @item We create a @code{Common} project with a package @code{Compiler} that + specifies the compilation qualifiers: + + @smallexample + File "common.gpr": + @group + @b{project} Common @b{is} + + @b{for} Source_Dirs @b{use} (); -- No source files + @end group + + @group + @b{type} Build_Type @b{is} ("release", "debug"); + Build : Build_Type := External ("BUILD", "debug"); + @end group + @group + @b{package} Compiler @b{is} + @b{case} Build @b{is} + @b{when} "release" => + @b{for} Default_Qualifiers ("Ada") @b{use} ("/OPTIMIZE=ALL"); + @b{when} "debug" => + @b{for} Default_Qualifiers ("Ada") @b{use} ("-g"); + @b{end case}; + @b{end} Compiler; + + @b{end} Common; + @end group + @end smallexample + + @item We create separate projects for the two programs: + + @smallexample + @group + File "prog1.gpr": + + @b{with} "common"; + @b{project} Prog1 @b{is} + + @b{for} Source_Dirs @b{use} ("prog1"); + @b{for} Object_Dir @b{use} "prog1/.build/" & Common.Build; + + @b{package} Compiler @b{renames} Common.Compiler; + + @b{end} Prog1; + @end group + @end smallexample + + @smallexample + @group + File "prog2.gpr": + + @b{with} "common"; + @b{project} Prog2 @b{is} + + @b{for} Source_Dirs @b{use} ("prog2"); + @b{for} Object_Dir @b{use} "prog2/.build/" & Common.Build; + + @b{package} Compiler @b{renames} Common.Compiler; + + @end group + @b{end} Prog2; + @end smallexample + + @item We create a wrapping project @var{Main}: + + @smallexample + @group + File "main.gpr": + + @b{with} "common"; + @b{with} "prog1"; + @b{with} "prog2"; + @b{project} Main @b{is} + + @b{package} Compiler @b{renames} Common.Compiler; + + @b{end} Main; + @end group + @end smallexample + + @item Finally we need to create a dummy procedure that @code{with}s (either + explicitly or implicitly) all the sources of our two programs. + + @end enumerate + + @noindent + Now we can build the programs using the command + + @smallexample + GNAT MAKE -Pmain dummy + @end smallexample + + @noindent + for the Debug mode, or + + @smallexample + GNAT MAKE -Pmain -XBUILD=release + @end smallexample + + @noindent + for the Release mode. + + + @c ******************************** + @c * Project File Complete Syntax * + @c ******************************** + + @node Project File Complete Syntax + @section Project File Complete Syntax + + @smallexample + project ::= + context_clause project_declaration + + context_clause ::= + @{with_clause@} + + with_clause ::= + @b{with} literal_string @{ , literal_string @} ; + + project_declaration ::= + @b{project} simple_name [ @b{extends} literal_string ] @b{is} + @{declarative_item@} + @b{end} simple_name; + + declarative_item ::= + package_declaration | + typed_string_declaration | + other_declarative_item + + package_declaration ::= + @b{package} simple_name package_completion + + package_completion ::= + package_body | package_renaming + + package body ::= + @b{is} + @{other_declarative_item@} + @b{end} simple_name ; + + package_renaming ::== + @b{renames} simple_name.simple_name ; + + typed_string_declaration ::= + @b{type} _simple_name @b{is} + ( literal_string @{, literal_string@} ); + + other_declarative_item ::= + attribute_declaration | + typed_variable_declaration | + variable_declaration | + case_construction + + attribute_declaration ::= + @b{for} attribute @b{use} expression ; + + attribute ::= + simple_name | + simple_name ( literal_string ) + + typed_variable_declaration ::= + simple_name : name := string_expression ; + + variable_declaration ::= + simple_name := expression; + + expression ::= + term @{& term@} + + term ::= + literal_string | + string_list | + name | + external_value | + attribute_reference + + literal_string ::= + (same as Ada) + + string_list ::= + ( expression @{ , expression @} ) + + external_value ::= + @b{external} ( literal_string [, literal_string] ) + + attribute_reference ::= + attribute_parent ' simple_name [ ( literal_string ) ] + + attribute_parent ::= + @b{project} | + simple_name | + simple_name . simple_name + + case_construction ::= + @b{case} name @b{is} + @{case_item@} + @b{end case} ; + + case_item ::= + @b{when} discrete_choice_list => @{case_construction | attribute_declaration@} + + discrete_choice_list ::= + literal_string @{| literal_string@} + + name ::= + simple_name @{. simple_name@} + + simple_name ::= + identifier (same as Ada) + + @end smallexample + + + @node Elaboration Order Handling in GNAT + @chapter Elaboration Order Handling in GNAT + @cindex Order of elaboration + @cindex Elaboration control + + @menu + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + @end menu + + @noindent + This chapter describes the handling of elaboration code in Ada 95 and + in GNAT, and discusses how the order of elaboration of program units can + be controlled in GNAT, either automatically or with explicit programming + features. + + @node Elaboration Code in Ada 95 + @section Elaboration Code in Ada 95 + + @noindent + Ada 95 provides rather general mechanisms for executing code at elaboration + time, that is to say before the main program starts executing. Such code arises + in three contexts: + + @table @asis + @item Initializers for variables. + Variables declared at the library level, in package specs or bodies, can + require initialization that is performed at elaboration time, as in: + @smallexample + @cartouche + Sqrt_Half : Float := Sqrt (0.5); + @end cartouche + @end smallexample + + @item Package initialization code + Code in a @code{BEGIN-END} section at the outer level of a package body is + executed as part of the package body elaboration code. + + @item Library level task allocators + Tasks that are declared using task allocators at the library level + start executing immediately and hence can execute at elaboration time. + @end table + + @noindent + Subprogram calls are possible in any of these contexts, which means that + any arbitrary part of the program may be executed as part of the elaboration + code. It is even possible to write a program which does all its work at + elaboration time, with a null main program, although stylistically this + would usually be considered an inappropriate way to structure + a program. + + An important concern arises in the context of elaboration code: + we have to be sure that it is executed in an appropriate order. What we + have is a series of elaboration code sections, potentially one section + for each unit in the program. It is important that these execute + in the correct order. Correctness here means that, taking the above + example of the declaration of @code{Sqrt_Half}, + if some other piece of + elaboration code references @code{Sqrt_Half}, + then it must run after the + section of elaboration code that contains the declaration of + @code{Sqrt_Half}. + + There would never be any order of elaboration problem if we made a rule + that whenever you @code{with} a unit, you must elaborate both the spec and body + of that unit before elaborating the unit doing the @code{with}'ing: + + @smallexample + @group + @cartouche + @b{with} Unit_1; + @b{package} Unit_2 @b{is} ... + @end cartouche + @end group + @end smallexample + + @noindent + would require that both the body and spec of @code{Unit_1} be elaborated + before the spec of @code{Unit_2}. However, a rule like that would be far too + restrictive. In particular, it would make it impossible to have routines + in separate packages that were mutually recursive. + + You might think that a clever enough compiler could look at the actual + elaboration code and determine an appropriate correct order of elaboration, + but in the general case, this is not possible. Consider the following + example. + + In the body of @code{Unit_1}, we have a procedure @code{Func_1} + that references + the variable @code{Sqrt_1}, which is declared in the elaboration code + of the body of @code{Unit_1}: + + @smallexample + @cartouche + Sqrt_1 : Float := Sqrt (0.1); + @end cartouche + @end smallexample + + @noindent + The elaboration code of the body of @code{Unit_1} also contains: + + @smallexample + @group + @cartouche + @b{if} expression_1 = 1 @b{then} + Q := Unit_2.Func_2; + @b{end if}; + @end cartouche + @end group + @end smallexample + + @noindent + @code{Unit_2} is exactly parallel, + it has a procedure @code{Func_2} that references + the variable @code{Sqrt_2}, which is declared in the elaboration code of + the body @code{Unit_2}: + + @smallexample + @cartouche + Sqrt_2 : Float := Sqrt (0.1); + @end cartouche + @end smallexample + + @noindent + The elaboration code of the body of @code{Unit_2} also contains: + + @smallexample + @group + @cartouche + @b{if} expression_2 = 2 @b{then} + Q := Unit_1.Func_1; + @b{end if}; + @end cartouche + @end group + @end smallexample + + @noindent + Now the question is, which of the following orders of elaboration is + acceptable: + + @smallexample + @group + Spec of Unit_1 + Spec of Unit_2 + Body of Unit_1 + Body of Unit_2 + @end group + @end smallexample + + @noindent + or + + @smallexample + @group + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_2 + Body of Unit_1 + @end group + @end smallexample + + @noindent + If you carefully analyze the flow here, you will see that you cannot tell + at compile time the answer to this question. + If @code{expression_1} is not equal to 1, + and @code{expression_2} is not equal to 2, + then either order is acceptable, because neither of the function calls is + executed. If both tests evaluate to true, then neither order is acceptable + and in fact there is no correct order. + + If one of the two expressions is true, and the other is false, then one + of the above orders is correct, and the other is incorrect. For example, + if @code{expression_1} = 1 and @code{expression_2} /= 2, + then the call to @code{Func_2} + will occur, but not the call to @code{Func_1.} + This means that it is essential + to elaborate the body of @code{Unit_1} before + the body of @code{Unit_2}, so the first + order of elaboration is correct and the second is wrong. + + By making @code{expression_1} and @code{expression_2} + depend on input data, or perhaps + the time of day, we can make it impossible for the compiler or binder + to figure out which of these expressions will be true, and hence it + is impossible to guarantee a safe order of elaboration at run time. + + @node Checking the Elaboration Order in Ada 95 + @section Checking the Elaboration Order in Ada 95 + + @noindent + In some languages that involve the same kind of elaboration problems, + e.g. Java and C++, the programmer is expected to worry about these + ordering problems himself, and it is common to + write a program in which an incorrect elaboration order gives + surprising results, because it references variables before they + are initialized. + Ada 95 is designed to be a safe language, and a programmer-beware approach is + clearly not sufficient. Consequently, the language provides three lines + of defense: + + @table @asis + @item Standard rules + Some standard rules restrict the possible choice of elaboration + order. In particular, if you @code{with} a unit, then its spec is always + elaborated before the unit doing the @code{with}. Similarly, a parent + spec is always elaborated before the child spec, and finally + a spec is always elaborated before its corresponding body. + + @item Dynamic elaboration checks + @cindex Elaboration checks + @cindex Checks, elaboration + Dynamic checks are made at run time, so that if some entity is accessed + before it is elaborated (typically by means of a subprogram call) + then the exception (@code{Program_Error}) is raised. + + @item Elaboration control + Facilities are provided for the programmer to specify the desired order + of elaboration. + @end table + + Let's look at these facilities in more detail. First, the rules for + dynamic checking. One possible rule would be simply to say that the + exception is raised if you access a variable which has not yet been + elaborated. The trouble with this approach is that it could require + expensive checks on every variable reference. Instead Ada 95 has two + rules which are a little more restrictive, but easier to check, and + easier to state: + + @table @asis + @item Restrictions on calls + A subprogram can only be called at elaboration time if its body + has been elaborated. The rules for elaboration given above guarantee + that the spec of the subprogram has been elaborated before the + call, but not the body. If this rule is violated, then the + exception @code{Program_Error} is raised. + + @item Restrictions on instantiations + A generic unit can only be instantiated if the body of the generic + unit has been elaborated. Again, the rules for elaboration given above + guarantee that the spec of the generic unit has been elaborated + before the instantiation, but not the body. If this rule is + violated, then the exception @code{Program_Error} is raised. + @end table + + @noindent + The idea is that if the body has been elaborated, then any variables + it references must have been elaborated; by checking for the body being + elaborated we guarantee that none of its references causes any + trouble. As we noted above, this is a little too restrictive, because a + subprogram that has no non-local references in its body may in fact be safe + to call. However, it really would be unsafe to rely on this, because + it would mean that the caller was aware of details of the implementation + in the body. This goes against the basic tenets of Ada. + + A plausible implementation can be described as follows. + A Boolean variable is associated with each subprogram + and each generic unit. This variable is initialized to False, and is set to + True at the point body is elaborated. Every call or instantiation checks the + variable, and raises @code{Program_Error} if the variable is False. + + Note that one might think that it would be good enough to have one Boolean + variable for each package, but that would not deal with cases of trying + to call a body in the same package as the call + that has not been elaborated yet. + Of course a compiler may be able to do enough analysis to optimize away + some of the Boolean variables as unnecessary, and @code{GNAT} indeed + does such optimizations, but still the easiest conceptual model is to + think of there being one variable per subprogram. + + @node Controlling the Elaboration Order in Ada 95 + @section Controlling the Elaboration Order in Ada 95 + + @noindent + In the previous section we discussed the rules in Ada 95 which ensure + that @code{Program_Error} is raised if an incorrect elaboration order is + chosen. This prevents erroneous executions, but we need mechanisms to + specify a correct execution and avoid the exception altogether. + To achieve this, Ada 95 provides a number of features for controlling + the order of elaboration. We discuss these features in this section. + + First, there are several ways of indicating to the compiler that a given + unit has no elaboration problems: + + @table @asis + @item packages that do not require a body + In Ada 95, a library package that does not require a body does not permit + a body. This means that if we have a such a package, as in: + + @smallexample + @group + @cartouche + @b{package} Definitions @b{is} + @b{generic} + @b{type} m @b{is new} integer; + @b{package} Subp @b{is} + @b{type} a @b{is array} (1 .. 10) @b{of} m; + @b{type} b @b{is array} (1 .. 20) @b{of} m; + @b{end} Subp; + @b{end} Definitions; + @end cartouche + @end group + @end smallexample + + @noindent + A package that @code{with}'s @code{Definitions} may safely instantiate + @code{Definitions.Subp} because the compiler can determine that there + definitely is no package body to worry about in this case + + @item pragma Pure + @cindex pragma Pure + @findex Pure + Places sufficient restrictions on a unit to guarantee that + no call to any subprogram in the unit can result in an + elaboration problem. This means that the compiler does not need + to worry about the point of elaboration of such units, and in + particular, does not need to check any calls to any subprograms + in this unit. + + @item pragma Preelaborate + @findex Preelaborate + @cindex pragma Preelaborate + This pragma places slightly less stringent restrictions on a unit than + does pragma Pure, + but these restrictions are still sufficient to ensure that there + are no elaboration problems with any calls to the unit. + + @item pragma Elaborate_Body + @findex Elaborate_Body + @cindex pragma Elaborate_Body + This pragma requires that the body of a unit be elaborated immediately + after its spec. Suppose a unit @code{A} has such a pragma, + and unit @code{B} does + a @code{with} of unit @code{A}. Recall that the standard rules require + the spec of unit @code{A} + to be elaborated before the @code{with}'ing unit; given the pragma in + @code{A}, we also know that the body of @code{A} + will be elaborated before @code{B}, so + that calls to @code{A} are safe and do not need a check. + @end table + + @noindent + Note that, + unlike pragma @code{Pure} and pragma @code{Preelaborate}, + the use of + @code{Elaborate_Body} does not guarantee that the program is + free of elaboration problems, because it may not be possible + to satisfy the requested elaboration order. + Let's go back to the example with @code{Unit_1} and @code{Unit_2}. + If a programmer + marks @code{Unit_1} as @code{Elaborate_Body}, + and not @code{Unit_2,} then the order of + elaboration will be: + + @smallexample + @group + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_1 + Body of Unit_2 + @end group + @end smallexample + + @noindent + Now that means that the call to @code{Func_1} in @code{Unit_2} + need not be checked, + it must be safe. But the call to @code{Func_2} in + @code{Unit_1} may still fail if + @code{Expression_1} is equal to 1, + and the programmer must still take + responsibility for this not being the case. + + If all units carry a pragma @code{Elaborate_Body}, then all problems are + eliminated, except for calls entirely within a body, which are + in any case fully under programmer control. However, using the pragma + everywhere is not always possible. + In particular, for our @code{Unit_1}/@code{Unit_2} example, if + we marked both of them as having pragma @code{Elaborate_Body}, then + clearly there would be no possible elaboration order. + + The above pragmas allow a server to guarantee safe use by clients, and + clearly this is the preferable approach. Consequently a good rule in + Ada 95 is to mark units as @code{Pure} or @code{Preelaborate} if possible, + and if this is not possible, + mark them as @code{Elaborate_Body} if possible. + As we have seen, there are situations where neither of these + three pragmas can be used. + So we also provide methods for clients to control the + order of elaboration of the servers on which they depend: + + @table @asis + @item pragma Elaborate (unit) + @findex Elaborate + @cindex pragma Elaborate + This pragma is placed in the context clause, after a @code{with} clause, + and it requires that the body of the named unit be elaborated before + the unit in which the pragma occurs. The idea is to use this pragma + if the current unit calls at elaboration time, directly or indirectly, + some subprogram in the named unit. + + @item pragma Elaborate_All (unit) + @findex Elaborate_All + @cindex pragma Elaborate_All + This is a stronger version of the Elaborate pragma. Consider the + following example: + + @smallexample + Unit A @code{with}'s unit B and calls B.Func in elab code + Unit B @code{with}'s unit C, and B.Func calls C.Func + @end smallexample + + @noindent + Now if we put a pragma @code{Elaborate (B)} + in unit @code{A}, this ensures that the + body of @code{B} is elaborated before the call, but not the + body of @code{C}, so + the call to @code{C.Func} could still cause @code{Program_Error} to + be raised. + + The effect of a pragma @code{Elaborate_All} is stronger, it requires + not only that the body of the named unit be elaborated before the + unit doing the @code{with}, but also the bodies of all units that the + named unit uses, following @code{with} links transitively. For example, + if we put a pragma @code{Elaborate_All (B)} in unit @code{A}, + then it requires + not only that the body of @code{B} be elaborated before @code{A}, + but also the + body of @code{C}, because @code{B} @code{with}'s @code{C}. + @end table + + @noindent + We are now in a position to give a usage rule in Ada 95 for avoiding + elaboration problems, at least if dynamic dispatching and access to + subprogram values are not used. We will handle these cases separately + later. + + The rule is simple. If a unit has elaboration code that can directly or + indirectly make a call to a subprogram in a @code{with}'ed unit, or instantiate + a generic unit in a @code{with}'ed unit, + then if the @code{with}'ed unit does not have + pragma @code{Pure} or @code{Preelaborate}, then the client should have + a pragma @code{Elaborate_All} + for the @code{with}'ed unit. By following this rule a client is + assured that calls can be made without risk of an exception. + If this rule is not followed, then a program may be in one of four + states: + + @table @asis + @item No order exists + No order of elaboration exists which follows the rules, taking into + account any @code{Elaborate}, @code{Elaborate_All}, + or @code{Elaborate_Body} pragmas. In + this case, an Ada 95 compiler must diagnose the situation at bind + time, and refuse to build an executable program. + + @item One or more orders exist, all incorrect + One or more acceptable elaboration orders exists, and all of them + generate an elaboration order problem. In this case, the binder + can build an executable program, but @code{Program_Error} will be raised + when the program is run. + + @item Several orders exist, some right, some incorrect + One or more acceptable elaboration orders exists, and some of them + work, and some do not. The programmer has not controlled + the order of elaboration, so the binder may or may not pick one of + the correct orders, and the program may or may not raise an + exception when it is run. This is the worst case, because it means + that the program may fail when moved to another compiler, or even + another version of the same compiler. + + @item One or more orders exists, all correct + One ore more acceptable elaboration orders exist, and all of them + work. In this case the program runs successfully. This state of + affairs can be guaranteed by following the rule we gave above, but + may be true even if the rule is not followed. + @end table + + @noindent + Note that one additional advantage of following our Elaborate_All rule + is that the program continues to stay in the ideal (all orders OK) state + even if maintenance + changes some bodies of some subprograms. Conversely, if a program that does + not follow this rule happens to be safe at some point, this state of affairs + may deteriorate silently as a result of maintenance changes. + + You may have noticed that the above discussion did not mention + the use of @code{Elaborate_Body}. This was a deliberate omission. If you + @code{with} an @code{Elaborate_Body} unit, it still may be the case that + code in the body makes calls to some other unit, so it is still necessary + to use @code{Elaborate_All} on such units. + + @node Controlling Elaboration in GNAT - Internal Calls + @section Controlling Elaboration in GNAT - Internal Calls + + @noindent + In the case of internal calls, i.e. calls within a single package, the + programmer has full control over the order of elaboration, and it is up + to the programmer to elaborate declarations in an appropriate order. For + example writing: + + @smallexample + @group + @cartouche + @b{function} One @b{return} Float; + + Q : Float := One; + + @b{function} One @b{return} Float @b{is} + @b{begin} + return 1.0; + @b{end} One; + @end cartouche + @end group + @end smallexample + + @noindent + will obviously raise @code{Program_Error} at run time, because function + One will be called before its body is elaborated. In this case GNAT will + generate a warning that the call will raise @code{Program_Error}: + + @smallexample + @group + @cartouche + 1. procedure y is + 2. function One return Float; + 3. + 4. Q : Float := One; + | + >>> warning: cannot call "One" before body is elaborated + >>> warning: Program_Error will be raised at run time + + 5. + 6. function One return Float is + 7. begin + 8. return 1.0; + 9. end One; + 10. + 11. begin + 12. null; + 13. end; + @end cartouche + @end group + @end smallexample + + @noindent + Note that in this particular case, it is likely that the call is safe, because + the function @code{One} does not access any global variables. + Nevertheless in Ada 95, we do not want the validity of the check to depend on + the contents of the body (think about the separate compilation case), so this + is still wrong, as we discussed in the previous sections. + + The error is easily corrected by rearranging the declarations so that the + body of One appears before the declaration containing the call + (note that in Ada 95, + declarations can appear in any order, so there is no restriction that + would prevent this reordering, and if we write: + + @smallexample + @group + @cartouche + @b{function} One @b{return} Float; + + @b{function} One @b{return} Float @b{is} + @b{begin} + return 1.0; + @b{end} One; + + Q : Float := One; + @end cartouche + @end group + @end smallexample + + @noindent + then all is well, no warning is generated, and no + @code{Program_Error} exception + will be raised. + Things are more complicated when a chain of subprograms is executed: + + @smallexample + @group + @cartouche + @b{function} A @b{return} Integer; + @b{function} B @b{return} Integer; + @b{function} C @b{return} Integer; + + @b{function} B @b{return} Integer @b{is begin return} A; @b{end}; + @b{function} C @b{return} Integer @b{is begin return} B; @b{end}; + + X : Integer := C; + + @b{function} A @b{return} Integer @b{is begin return} 1; @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + Now the call to @code{C} + at elaboration time in the declaration of @code{X} is correct, because + the body of @code{C} is already elaborated, + and the call to @code{B} within the body of + @code{C} is correct, but the call + to @code{A} within the body of @code{B} is incorrect, because the body + of @code{A} has not been elaborated, so @code{Program_Error} + will be raised on the call to @code{A}. + In this case GNAT will generate a + warning that @code{Program_Error} may be + raised at the point of the call. Let's look at the warning: + + @smallexample + @group + @cartouche + 1. procedure x is + 2. function A return Integer; + 3. function B return Integer; + 4. function C return Integer; + 5. + 6. function B return Integer is begin return A; end; + | + >>> warning: call to "A" before body is elaborated may + raise Program_Error + >>> warning: "B" called at line 7 + >>> warning: "C" called at line 9 + + 7. function C return Integer is begin return B; end; + 8. + 9. X : Integer := C; + 10. + 11. function A return Integer is begin return 1; end; + 12. + 13. begin + 14. null; + 15. end; + @end cartouche + @end group + @end smallexample + + @noindent + Note that the message here says "may raise", instead of the direct case, + where the message says "will be raised". That's because whether + @code{A} is + actually called depends in general on run-time flow of control. + For example, if the body of @code{B} said + + @smallexample + @group + @cartouche + @b{function} B @b{return} Integer @b{is} + @b{begin} + @b{if} some-condition-depending-on-input-data @b{then} + @b{return} A; + @b{else} + @b{return} 1; + @b{end if}; + @b{end} B; + @end cartouche + @end group + @end smallexample + + @noindent + then we could not know until run time whether the incorrect call to A would + actually occur, so @code{Program_Error} might + or might not be raised. It is possible for a compiler to + do a better job of analyzing bodies, to + determine whether or not @code{Program_Error} + might be raised, but it certainly + couldn't do a perfect job (that would require solving the halting problem + and is provably impossible), and because this is a warning anyway, it does + not seem worth the effort to do the analysis. Cases in which it + would be relevant are rare. + + In practice, warnings of either of the forms given + above will usually correspond to + real errors, and should be examined carefully and eliminated. + In the rare case where a warning is bogus, it can be suppressed by any of + the following methods: + + @itemize @bullet + @item + Compile with the @option{/WARNINGS=SUPPRESS} qualifier set + + @item + Suppress @code{Elaboration_Checks} for the called subprogram + + @item + Use pragma @code{Warnings_Off} to turn warnings off for the call + @end itemize + + @noindent + For the internal elaboration check case, + GNAT by default generates the + necessary run-time checks to ensure + that @code{Program_Error} is raised if any + call fails an elaboration check. Of course this can only happen if a + warning has been issued as described above. The use of pragma + @code{Suppress (Elaboration_Checks)} may (but is not guaranteed to) suppress + some of these checks, meaning that it may be possible (but is not + guaranteed) for a program to be able to call a subprogram whose body + is not yet elaborated, without raising a @code{Program_Error} exception. + + @node Controlling Elaboration in GNAT - External Calls + @section Controlling Elaboration in GNAT - External Calls + + @noindent + The previous section discussed the case in which the execution of a + particular thread of elaboration code occurred entirely within a + single unit. This is the easy case to handle, because a programmer + has direct and total control over the order of elaboration, and + furthermore, checks need only be generated in cases which are rare + and which the compiler can easily detect. + The situation is more complex when separate compilation is taken into account. + Consider the following: + + @smallexample + @cartouche + @group + @b{package} Math @b{is} + @b{function} Sqrt (Arg : Float) @b{return} Float; + @b{end} Math; + + @b{package body} Math @b{is} + @b{function} Sqrt (Arg : Float) @b{return} Float @b{is} + @b{begin} + ... + @b{end} Sqrt; + @b{end} Math; + @end group + @group + @b{with} Math; + @b{package} Stuff @b{is} + X : Float := Math.Sqrt (0.5); + @b{end} Stuff; + + @b{with} Stuff; + @b{procedure} Main @b{is} + @b{begin} + ... + @b{end} Main; + @end group + @end cartouche + @end smallexample + + @noindent + where @code{Main} is the main program. When this program is executed, the + elaboration code must first be executed, and one of the jobs of the + binder is to determine the order in which the units of a program are + to be elaborated. In this case we have four units: the spec and body + of @code{Math}, + the spec of @code{Stuff} and the body of @code{Main}). + In what order should the four separate sections of elaboration code + be executed? + + There are some restrictions in the order of elaboration that the binder + can choose. In particular, if unit U has a @code{with} + for a package @code{X}, then you + are assured that the spec of @code{X} + is elaborated before U , but you are + not assured that the body of @code{X} + is elaborated before U. + This means that in the above case, the binder is allowed to choose the + order: + + @smallexample + spec of Math + spec of Stuff + body of Math + body of Main + @end smallexample + + @noindent + but that's not good, because now the call to @code{Math.Sqrt} + that happens during + the elaboration of the @code{Stuff} + spec happens before the body of @code{Math.Sqrt} is + elaborated, and hence causes @code{Program_Error} exception to be raised. + At first glance, one might say that the binder is misbehaving, because + obviously you want to elaborate the body of something you @code{with} + first, but + that is not a general rule that can be followed in all cases. Consider + + @smallexample + @group + @cartouche + @b{package} X @b{is} ... + + @b{package} Y @b{is} ... + + @b{with} X; + @b{package body} Y @b{is} ... + + @b{with} Y; + @b{package body} X @b{is} ... + @end cartouche + @end group + @end smallexample + + @noindent + This is a common arrangement, and, apart from the order of elaboration + problems that might arise in connection with elaboration code, this works fine. + A rule that says that you must first elaborate the body of anything you + @code{with} cannot work in this case: + the body of @code{X} @code{with}'s @code{Y}, + which means you would have to + elaborate the body of @code{Y} first, but that @code{with}'s @code{X}, + which means + you have to elaborate the body of @code{X} first, but ... and we have a + loop that cannot be broken. + + It is true that the binder can in many cases guess an order of elaboration + that is unlikely to cause a @code{Program_Error} + exception to be raised, and it tries to do so (in the + above example of @code{Math/Stuff/Spec}, the GNAT binder will + by default + elaborate the body of @code{Math} right after its spec, so all will be well). + + However, a program that blindly relies on the binder to be helpful can + get into trouble, as we discussed in the previous sections, so + GNAT + provides a number of facilities for assisting the programmer in + developing programs that are robust with respect to elaboration order. + + @node Default Behavior in GNAT - Ensuring Safety + @section Default Behavior in GNAT - Ensuring Safety + + @noindent + The default behavior in GNAT ensures elaboration safety. In its + default mode GNAT implements the + rule we previously described as the right approach. Let's restate it: + + @itemize + @item + @emph{If a unit has elaboration code that can directly or indirectly make a + call to a subprogram in a @code{with}'ed unit, or instantiate a generic unit + in a @code{with}'ed unit, then if the @code{with}'ed unit + does not have pragma @code{Pure} or + @code{Preelaborate}, then the client should have an + @code{Elaborate_All} for the @code{with}'ed unit.} + @end itemize + + @noindent + By following this rule a client + is assured that calls and instantiations can be made without risk of an exception. + + In this mode GNAT traces all calls that are potentially made from + elaboration code, and puts in any missing implicit @code{Elaborate_All} + pragmas. + The advantage of this approach is that no elaboration problems + are possible if the binder can find an elaboration order that is + consistent with these implicit @code{Elaborate_All} pragmas. The + disadvantage of this approach is that no such order may exist. + + If the binder does not generate any diagnostics, then it means that it + has found an elaboration order that is guaranteed to be safe. However, + the binder may still be relying on implicitly generated + @code{Elaborate_All} pragmas so portability to other compilers than + GNAT is not guaranteed. + + If it is important to guarantee portability, then the compilations should + use the + @option{/WARNINGS=ELABORATION} + (warn on elaboration problems) qualifier. This will cause warning messages + to be generated indicating the missing @code{Elaborate_All} pragmas. + Consider the following source program: + + @smallexample + @group + @cartouche + @b{with} k; + @b{package} j @b{is} + m : integer := k.r; + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + where it is clear that there + should be a pragma @code{Elaborate_All} + for unit @code{k}. An implicit pragma will be generated, and it is + likely that the binder will be able to honor it. However, + it is safer to include the pragma explicitly in the source. If this + unit is compiled with the + @option{/WARNINGS=ELABORATION} + qualifier, then the compiler outputs a warning: + + @smallexample + @group + @cartouche + 1. with k; + 2. package j is + 3. m : integer := k.r; + | + >>> warning: call to "r" may raise Program_Error + >>> warning: missing pragma Elaborate_All for "k" + + 4. end; + @end cartouche + @end group + @end smallexample + + @noindent + and these warnings can be used as a guide for supplying manually + the missing pragmas. + + This default mode is more restrictive than the Ada Reference + Manual, and it is possible to construct programs which will compile + using the dynamic model described there, but will run into a + circularity using the safer static model we have described. + + Of course any Ada compiler must be able to operate in a mode + consistent with the requirements of the Ada Reference Manual, + and in particular must have the capability of implementing the + standard dynamic model of elaboration with run-time checks. + + In GNAT, this standard mode can be achieved either by the use of + the @option{/CHECKS=ELABORATION} qualifier on the compiler (@code{GNAT COMPILE} or @code{GNAT MAKE}) + command, or by the use of the configuration pragma: + + @smallexample + pragma Elaboration_Checks (RM); + @end smallexample + + @noindent + Either approach will cause the unit affected to be compiled using the + standard dynamic run-time elaboration checks described in the Ada + Reference Manual. The static model is generally preferable, since it + is clearly safer to rely on compile and link time checks rather than + run-time checks. However, in the case of legacy code, it may be + difficult to meet the requirements of the static model. This + issue is further discussed in + @ref{What to Do If the Default Elaboration Behavior Fails}. + + Note that the static model provides a strict subset of the allowed + behavior and programs of the Ada Reference Manual, so if you do + adhere to the static model and no circularities exist, + then you are assured that your program will + work using the dynamic model. + + @node Elaboration Issues for Library Tasks + @section Elaboration Issues for Library Tasks + @cindex Library tasks, elaboration issues + @cindex Elaboration of library tasks + + @noindent + In this section we examine special elaboration issues that arise for + programs that declare library level tasks. + + Generally the model of execution of an Ada program is that all units are + elaborated, and then execution of the program starts. However, the + declaration of library tasks definitely does not fit this model. The + reason for this is that library tasks start as soon as they are declared + (more precisely, as soon as the statement part of the enclosing package + body is reached), that is to say before elaboration + of the program is complete. This means that if such a task calls a + subprogram, or an entry in another task, the callee may or may not be + elaborated yet, and in the standard + Reference Manual model of dynamic elaboration checks, you can even + get timing dependent Program_Error exceptions, since there can be + a race between the elaboration code and the task code. + + The static model of elaboration in GNAT seeks to avoid all such + dynamic behavior, by being conservative, and the conservative + approach in this particular case is to assume that all the code + in a task body is potentially executed at elaboration time if + a task is declared at the library level. + + This can definitely result in unexpected circularities. Consider + the following example + + @smallexample + package Decls is + task Lib_Task is + entry Start; + end Lib_Task; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + procedure Main is + begin + Decls.Lib_Task.Start; + end; + @end smallexample + + @noindent + If the above example is compiled in the default static elaboration + mode, then a circularity occurs. The circularity comes from the call + @code{Utils.Put_Val} in the task body of @code{Decls.Lib_Task}. Since + this call occurs in elaboration code, we need an implicit pragma + @code{Elaborate_All} for @code{Utils}. This means that not only must + the spec and body of @code{Utils} be elaborated before the body + of @code{Decls}, but also the spec and body of any unit that is + @code{with'ed} by the body of @code{Utils} must also be elaborated before + the body of @code{Decls}. This is the transitive implication of + pragma @code{Elaborate_All} and it makes sense, because in general + the body of @code{Put_Val} might have a call to something in a + @code{with'ed} unit. + + In this case, the body of Utils (actually its spec) @code{with's} + @code{Decls}. Unfortunately this means that the body of @code{Decls} + must be elaborated before itself, in case there is a call from the + body of @code{Utils}. + + Here is the exact chain of events we are worrying about: + + @enumerate + @item + In the body of @code{Decls} a call is made from within the body of a library + task to a subprogram in the package @code{Utils}. Since this call may + occur at elaboration time (given that the task is activated at elaboration + time), we have to assume the worst, i.e. that the + call does happen at elaboration time. + + @item + This means that the body and spec of @code{Util} must be elaborated before + the body of @code{Decls} so that this call does not cause an access before + elaboration. + + @item + Within the body of @code{Util}, specifically within the body of + @code{Util.Put_Val} there may be calls to any unit @code{with}'ed + by this package. + + @item + One such @code{with}'ed package is package @code{Decls}, so there + might be a call to a subprogram in @code{Decls} in @code{Put_Val}. + In fact there is such a call in this example, but we would have to + assume that there was such a call even if it were not there, since + we are not supposed to write the body of @code{Decls} knowing what + is in the body of @code{Utils}; certainly in the case of the + static elaboration model, the compiler does not know what is in + other bodies and must assume the worst. + + @item + This means that the spec and body of @code{Decls} must also be + elaborated before we elaborate the unit containing the call, but + that unit is @code{Decls}! This means that the body of @code{Decls} + must be elaborated before itself, and that's a circularity. + @end enumerate + + @noindent + Indeed, if you add an explicit pragma Elaborate_All for @code{Utils} in + the body of @code{Decls} you will get a true Ada Reference Manual + circularity that makes the program illegal. + + In practice, we have found that problems with the static model of + elaboration in existing code often arise from library tasks, so + we must address this particular situation. + + Note that if we compile and run the program above, using the dynamic model of + elaboration (that is to say use the @option{/CHECKS=ELABORATION} qualifier), + then it compiles, binds, + links, and runs, printing the expected result of 2. Therefore in some sense + the circularity here is only apparent, and we need to capture + the properties of this program that distinguish it from other library-level + tasks that have real elaboration problems. + + We have four possible answers to this question: + + @itemize @bullet + + @item + Use the dynamic model of elaboration. + + If we use the @option{/CHECKS=ELABORATION} qualifier, then as noted above, the program works. + Why is this? If we examine the task body, it is apparent that the task cannot + proceed past the + @code{accept} statement until after elaboration has been completed, because + the corresponding entry call comes from the main program, not earlier. + This is why the dynamic model works here. But that's really giving + up on a precise analysis, and we prefer to take this approach only if we cannot + solve the + problem in any other manner. So let us examine two ways to reorganize + the program to avoid the potential elaboration problem. + + @item + Split library tasks into separate packages. + + Write separate packages, so that library tasks are isolated from + other declarations as much as possible. Let us look at a variation on + the above program. + + @smallexample + package Decls1 is + task Lib_Task is + entry Start; + end Lib_Task; + end Decls1; + + with Utils; + package body Decls1 is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + end Decls1; + + package Decls2 is + type My_Int is new Integer; + function Ident (M : My_Int) return My_Int; + end Decls2; + + with Utils; + package body Decls2 is + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls2; + + with Decls2; + package Utils is + procedure Put_Val (Arg : Decls2.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls2.My_Int) is + begin + Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls1; + procedure Main is + begin + Decls1.Lib_Task.Start; + end; + @end smallexample + + @noindent + All we have done is to split @code{Decls} into two packages, one + containing the library task, and one containing everything else. Now + there is no cycle, and the program compiles, binds, links and executes + using the default static model of elaboration. + + @item + Declare separate task types. + + A significant part of the problem arises because of the use of the + single task declaration form. This means that the elaboration of + the task type, and the elaboration of the task itself (i.e. the + creation of the task) happen at the same time. A good rule + of style in Ada 95 is to always create explicit task types. By + following the additional step of placing task objects in separate + packages from the task type declaration, many elaboration problems + are avoided. Here is another modified example of the example program: + + @smallexample + package Decls is + task type Lib_Task_Type is + entry Start; + end Lib_Task_Type; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task_Type is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task_Type; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + package Declst is + Lib_Task : Decls.Lib_Task_Type; + end Declst; + + with Declst; + procedure Main is + begin + Declst.Lib_Task.Start; + end; + @end smallexample + + @noindent + What we have done here is to replace the @code{task} declaration in + package @code{Decls} with a @code{task type} declaration. Then we + introduce a separate package @code{Declst} to contain the actual + task object. This separates the elaboration issues for + the @code{task type} + declaration, which causes no trouble, from the elaboration issues + of the task object, which is also unproblematic, since it is now independent + of the elaboration of @code{Utils}. + This separation of concerns also corresponds to + a generally sound engineering principle of separating declarations + from instances. This version of the program also compiles, binds, links, + and executes, generating the expected output. + + @item + Use No_Entry_Calls_In_Elaboration_Code restriction. + @cindex No_Entry_Calls_In_Elaboration_Code + + The previous two approaches described how a program can be restructured + to avoid the special problems caused by library task bodies. in practice, + however, such restructuring may be difficult to apply to existing legacy code, + so we must consider solutions that do not require massive rewriting. + + Let us consider more carefully why our original sample program works + under the dynamic model of elaboration. The reason is that the code + in the task body blocks immediately on the @code{accept} + statement. Now of course there is nothing to prohibit elaboration + code from making entry calls (for example from another library level task), + so we cannot tell in isolation that + the task will not execute the accept statement during elaboration. + + However, in practice it is very unusual to see elaboration code + make any entry calls, and the pattern of tasks starting + at elaboration time and then immediately blocking on @code{accept} or + @code{select} statements is very common. What this means is that + the compiler is being too pessimistic when it analyzes the + whole package body as though it might be executed at elaboration + time. + + If we know that the elaboration code contains no entry calls, (a very safe + assumption most of the time, that could almost be made the default + behavior), then we can compile all units of the program under control + of the following configuration pragma: + + @smallexample + pragma Restrictions (No_Entry_Calls_In_Elaboration_Code); + @end smallexample + + @noindent + This pragma can be placed in the @file{GNAT.ADC} file in the usual + manner. If we take our original unmodified program and compile it + in the presence of a @file{GNAT.ADC} containing the above pragma, + then once again, we can compile, bind, link, and execute, obtaining + the expected result. In the presence of this pragma, the compiler does + not trace calls in a task body, that appear after the first @code{accept} + or @code{select} statement, and therefore does not report a potential + circularity in the original program. + + The compiler will check to the extent it can that the above + restriction is not violated, but it is not always possible to do a + complete check at compile time, so it is important to use this + pragma only if the stated restriction is in fact met, that is to say + no task receives an entry call before elaboration of all units is completed. + + @end itemize + + @node Mixing Elaboration Models + @section Mixing Elaboration Models + @noindent + So far, we have assumed that the entire program is either compiled + using the dynamic model or static model, ensuring consistency. It + is possible to mix the two models, but rules have to be followed + if this mixing is done to ensure that elaboration checks are not + omitted. + + The basic rule is that @emph{a unit compiled with the static model cannot + be @code{with'ed} by a unit compiled with the dynamic model}. The + reason for this is that in the static model, a unit assumes that + its clients guarantee to use (the equivalent of) pragma + @code{Elaborate_All} so that no elaboration checks are required + in inner subprograms, and this assumption is violated if the + client is compiled with dynamic checks. + + The precise rule is as follows. A unit that is compiled with dynamic + checks can only @code{with} a unit that meets at least one of the + following criteria: + + @itemize @bullet + + @item + The @code{with'ed} unit is itself compiled with dynamic elaboration + checks (that is with the @option{/CHECKS=ELABORATION} qualifier. + + @item + The @code{with'ed} unit is an internal GNAT implementation unit from + the System, Interfaces, Ada, or GNAT hierarchies. + + @item + The @code{with'ed} unit has pragma Preelaborate or pragma Pure. + + @item + The @code{with'ing} unit (that is the client) has an explicit pragma + @code{Elaborate_All} for the @code{with'ed} unit. + + @end itemize + + @noindent + If this rule is violated, that is if a unit with dynamic elaboration + checks @code{with's} a unit that does not meet one of the above four + criteria, then the binder (@code{GNAT BIND}) will issue a warning + similar to that in the following example: + + @smallexample + warning: "X.ADS" has dynamic elaboration checks and with's + warning: "Y.ADS" which has static elaboration checks + @end smallexample + + @noindent + These warnings indicate that the rule has been violated, and that as a result + elaboration checks may be missed in the resulting executable file. + This warning may be suppressed using the @code{-ws} binder qualifier + in the usual manner. + + One useful application of this mixing rule is in the case of a subsystem + which does not itself @code{with} units from the remainder of the + application. In this case, the entire subsystem can be compiled with + dynamic checks to resolve a circularity in the subsystem, while + allowing the main application that uses this subsystem to be compiled + using the more reliable default static model. + + @node What to Do If the Default Elaboration Behavior Fails + @section What to Do If the Default Elaboration Behavior Fails + + @noindent + If the binder cannot find an acceptable order, it outputs detailed + diagnostics. For example: + @smallexample + @group + @iftex + @leftskip=0cm + @end iftex + error: elaboration circularity detected + info: "proc (body)" must be elaborated before "pack (body)" + info: reason: Elaborate_All probably needed in unit "pack (body)" + info: recompile "pack (body)" with /WARNINGS=ELABORATION + info: for full details + info: "proc (body)" + info: is needed by its spec: + info: "proc (spec)" + info: which is withed by: + info: "pack (body)" + info: "pack (body)" must be elaborated before "proc (body)" + info: reason: pragma Elaborate in unit "proc (body)" + @end group + + @end smallexample + + @noindent + In this case we have a cycle that the binder cannot break. On the one + hand, there is an explicit pragma Elaborate in @code{proc} for + @code{pack}. This means that the body of @code{pack} must be elaborated + before the body of @code{proc}. On the other hand, there is elaboration + code in @code{pack} that calls a subprogram in @code{proc}. This means + that for maximum safety, there should really be a pragma + Elaborate_All in @code{pack} for @code{proc} which would require that + the body of @code{proc} be elaborated before the body of + @code{pack}. Clearly both requirements cannot be satisfied. + Faced with a circularity of this kind, you have three different options. + + @table @asis + @item Fix the program + The most desirable option from the point of view of long-term maintenance + is to rearrange the program so that the elaboration problems are avoided. + One useful technique is to place the elaboration code into separate + child packages. Another is to move some of the initialization code to + explicitly called subprograms, where the program controls the order + of initialization explicitly. Although this is the most desirable option, + it may be impractical and involve too much modification, especially in + the case of complex legacy code. + + @item Perform dynamic checks + If the compilations are done using the + @option{/CHECKS=ELABORATION} + (dynamic elaboration check) qualifier, then GNAT behaves in + a quite different manner. Dynamic checks are generated for all calls + that could possibly result in raising an exception. With this qualifier, + the compiler does not generate implicit @code{Elaborate_All} pragmas. + The behavior then is exactly as specified in the Ada 95 Reference Manual. + The binder will generate an executable program that may or may not + raise @code{Program_Error}, and then it is the programmer's job to ensure + that it does not raise an exception. Note that it is important to + compile all units with the qualifier, it cannot be used selectively. + + @item Suppress checks + The drawback of dynamic checks is that they generate a + significant overhead at run time, both in space and time. If you + are absolutely sure that your program cannot raise any elaboration + exceptions, and you still want to use the dynamic elaboration model, + then you can use the configuration pragma + @code{Suppress (Elaboration_Checks)} to suppress all such checks. For + example this pragma could be placed in the @file{GNAT.ADC} file. + + @item Suppress checks selectively + When you know that certain calls in elaboration code cannot possibly + lead to an elaboration error, and the binder nevertheless generates warnings + on those calls and inserts Elaborate_All pragmas that lead to elaboration + circularities, it is possible to remove those warnings locally and obtain + a program that will bind. Clearly this can be unsafe, and it is the + responsibility of the programmer to make sure that the resulting program has + no elaboration anomalies. The pragma @code{Suppress (Elaboration_Check)} can + be used with different granularity to suppress warnings and break + elaboration circularities: + + @itemize @bullet + @item + Place the pragma that names the called subprogram in the declarative part + that contains the call. + + @item + Place the pragma in the declarative part, without naming an entity. This + disables warnings on all calls in the corresponding declarative region. + + @item + Place the pragma in the package spec that declares the called subprogram, + and name the subprogram. This disables warnings on all elaboration calls to + that subprogram. + + @item + Place the pragma in the package spec that declares the called subprogram, + without naming any entity. This disables warnings on all elaboration calls to + all subprograms declared in this spec. + @end itemize + + @noindent + These four cases are listed in order of decreasing safety, and therefore + require increasing programmer care in their application. Consider the + following program: + @smallexample + + package Pack1 is + function F1 return Integer; + X1 : Integer; + end Pack1; + + package Pack2 is + function F2 return Integer; + function Pure (x : integer) return integer; + -- pragma Suppress (Elaboration_Check, On => Pure); -- (3) + -- pragma Suppress (Elaboration_Check); -- (4) + end Pack2; + + with Pack2; + package body Pack1 is + function F1 return Integer is + begin + return 100; + end F1; + Val : integer := Pack2.Pure (11); -- Elab. call (1) + begin + declare + -- pragma Suppress(Elaboration_Check, Pack2.F2); -- (1) + -- pragma Suppress(Elaboration_Check); -- (2) + begin + X1 := Pack2.F2 + 1; -- Elab. call (2) + end; + end Pack1; + + with Pack1; + package body Pack2 is + function F2 return Integer is + begin + return Pack1.F1; + end F2; + function Pure (x : integer) return integer is + begin + return x ** 3 - 3 * x; + end; + end Pack2; + + with Pack1, Ada.Text_IO; + procedure Proc3 is + begin + Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101 + end Proc3; + @end smallexample + In the absence of any pragmas, an attempt to bind this program produces + the following diagnostics: + @smallexample + @group + @iftex + @leftskip=.5cm + @end iftex + error: elaboration circularity detected + info: "pack1 (body)" must be elaborated before "pack1 (body)" + info: reason: Elaborate_All probably needed in unit "pack1 (body)" + info: recompile "pack1 (body)" with /WARNINGS=ELABORATION for full details + info: "pack1 (body)" + info: must be elaborated along with its spec: + info: "pack1 (spec)" + info: which is withed by: + info: "pack2 (body)" + info: which must be elaborated along with its spec: + info: "pack2 (spec)" + info: which is withed by: + info: "pack1 (body)" + @end group + @end smallexample + The sources of the circularity are the two calls to @code{Pack2.Pure} and + @code{Pack2.F2} in the body of @code{Pack1}. We can see that the call to + F2 is safe, even though F2 calls F1, because the call appears after the + elaboration of the body of F1. Therefore the pragma (1) is safe, and will + remove the warning on the call. It is also possible to use pragma (2) + because there are no other potentially unsafe calls in the block. + + @noindent + The call to @code{Pure} is safe because this function does not depend on the + state of @code{Pack2}. Therefore any call to this function is safe, and it + is correct to place pragma (3) in the corresponding package spec. + + @noindent + Finally, we could place pragma (4) in the spec of @code{Pack2} to disable + warnings on all calls to functions declared therein. Note that this is not + necessarily safe, and requires more detailed examination of the subprogram + bodies involved. In particular, a call to @code{F2} requires that @code{F1} + be already elaborated. + @end table + + @noindent + It is hard to generalize on which of these four approaches should be + taken. Obviously if it is possible to fix the program so that the default + treatment works, this is preferable, but this may not always be practical. + It is certainly simple enough to use + @option{/CHECKS=ELABORATION} + but the danger in this case is that, even if the GNAT binder + finds a correct elaboration order, it may not always do so, + and certainly a binder from another Ada compiler might not. A + combination of testing and analysis (for which the warnings generated + with the + @option{/WARNINGS=ELABORATION} + qualifier can be useful) must be used to ensure that the program is free + of errors. One qualifier that is useful in this testing is the + @code{/PESSIMISTIC_ELABORATION_ORDER} + qualifier for + @code{GNAT BIND}. + Normally the binder tries to find an order that has the best chance of + of avoiding elaboration problems. With this qualifier, the binder + plays a devil's advocate role, and tries to choose the order that + has the best chance of failing. If your program works even with this + qualifier, then it has a better chance of being error free, but this is still + not a guarantee. + + For an example of this approach in action, consider the C-tests (executable + tests) from the ACVC suite. If these are compiled and run with the default + treatment, then all but one of them succeed without generating any error + diagnostics from the binder. However, there is one test that fails, and + this is not surprising, because the whole point of this test is to ensure + that the compiler can handle cases where it is impossible to determine + a correct order statically, and it checks that an exception is indeed + raised at run time. + + This one test must be compiled and run using the + @option{/CHECKS=ELABORATION} + qualifier, and then it passes. Alternatively, the entire suite can + be run using this qualifier. It is never wrong to run with the dynamic + elaboration qualifier if your code is correct, and we assume that the + C-tests are indeed correct (it is less efficient, but efficiency is + not a factor in running the ACVC tests.) + + @node Elaboration for Access-to-Subprogram Values + @section Elaboration for Access-to-Subprogram Values + @cindex Access-to-subprogram + + @noindent + The introduction of access-to-subprogram types in Ada 95 complicates + the handling of elaboration. The trouble is that it becomes + impossible to tell at compile time which procedure + is being called. This means that it is not possible for the binder + to analyze the elaboration requirements in this case. + + If at the point at which the access value is created + (i.e., the evaluation of @code{P'Access} for a subprogram @code{P}), + the body of the subprogram is + known to have been elaborated, then the access value is safe, and its use + does not require a check. This may be achieved by appropriate arrangement + of the order of declarations if the subprogram is in the current unit, + or, if the subprogram is in another unit, by using pragma + @code{Pure}, @code{Preelaborate}, or @code{Elaborate_Body} + on the referenced unit. + + If the referenced body is not known to have been elaborated at the point + the access value is created, then any use of the access value must do a + dynamic check, and this dynamic check will fail and raise a + @code{Program_Error} exception if the body has not been elaborated yet. + GNAT will generate the necessary checks, and in addition, if the + @option{/WARNINGS=ELABORATION} + qualifier is set, will generate warnings that such checks are required. + + The use of dynamic dispatching for tagged types similarly generates + a requirement for dynamic checks, and premature calls to any primitive + operation of a tagged type before the body of the operation has been elaborated, + will result in the raising of @code{Program_Error}. + + @node Summary of Procedures for Elaboration Control + @section Summary of Procedures for Elaboration Control + @cindex Elaboration control + + @noindent + First, compile your program with the default options, using none of + the special elaboration control qualifiers. If the binder successfully + binds your program, then you can be confident that, apart from issues + raised by the use of access-to-subprogram types and dynamic dispatching, + the program is free of elaboration errors. If it is important that the + program be portable, then use the + @option{/WARNINGS=ELABORATION} + qualifier to generate warnings about missing @code{Elaborate_All} + pragmas, and supply the missing pragmas. + + If the program fails to bind using the default static elaboration + handling, then you can fix the program to eliminate the binder + message, or recompile the entire program with the + @option{/CHECKS=ELABORATION} qualifier to generate dynamic elaboration checks, + and, if you are sure there really are no elaboration problems, + use a global pragma @code{Suppress (Elaboration_Checks)}. + + @node Other Elaboration Order Considerations + @section Other Elaboration Order Considerations + @noindent + This section has been entirely concerned with the issue of finding a valid + elaboration order, as defined by the Ada Reference Manual. In a case + where several elaboration orders are valid, the task is to find one + of the possible valid elaboration orders (and the static model in GNAT + will ensure that this is achieved). + + The purpose of the elaboration rules in the Ada Reference Manual is to + make sure that no entity is accessed before it has been elaborated. For + a subprogram, this means that the spec and body must have been elaborated + before the subprogram is called. For an object, this means that the object + must have been elaborated before its value is read or written. A violation + of either of these two requirements is an access before elaboration order, + and this section has been all about avoiding such errors. + + In the case where more than one order of elaboration is possible, in the + sense that access before elaboration errors are avoided, then any one of + the orders is "correct" in the sense that it meets the requirements of + the Ada Reference Manual, and no such error occurs. + + However, it may be the case for a given program, that there are + constraints on the order of elaboration that come not from consideration + of avoiding elaboration errors, but rather from extra-lingual logic + requirements. Consider this example: + + @smallexample + with Init_Constants; + package Constants is + X : Integer := 0; + Y : Integer := 0; + end Constants; + + package Init_Constants is + procedure Calc; + end Init_Constants; + + with Constants; + package body Init_Constants is + procedure Calc is begin null; end; + begin + Constants.X := 3; + Constants.Y := 4; + end Init_Constants; + + with Constants; + package Calc is + Z : Integer := Constants.X + Constants.Y; + end Calc; + + with Calc; + with Text_IO; use Text_IO; + procedure Main is + begin + Put_Line (Calc.Z'Img); + end Main; + @end smallexample + + @noindent + In this example, there is more than one valid order of elaboration. For + example both the following are correct orders: + + @smallexample + Init_Constants spec + Constants spec + Calc spec + Main body + Init_Constants body + + and + + Init_Constants spec + Init_Constants body + Constants spec + Calc spec + Main body + @end smallexample + + @noindent + There is no language rule to prefer one or the other, both are correct + from an order of elaboration point of view. But the programmatic effects + of the two orders are very different. In the first, the elaboration routine + of @code{Calc} initializes @code{Z} to zero, and then the main program + runs with this value of zero. But in the second order, the elaboration + routine of @code{Calc} runs after the body of Init_Constants has set + @code{X} and @code{Y} and thus @code{Z} is set to 7 before @code{Main} + runs. + + One could perhaps by applying pretty clever non-artificial intelligence + to the situation guess that it is more likely that the second order of + elaboration is the one desired, but there is no formal linguistic reason + to prefer one over the other. In fact in this particular case, GNAT will + prefer the second order, because of the rule that bodies are elaborated + as soon as possible, but it's just luck that this is what was wanted + (if indeed the second order was preferred). + + If the program cares about the order of elaboration routines in a case like + this, it is important to specify the order required. In this particular + case, that could have been achieved by adding to the spec of Calc: + + @smallexample + pragma Elaborate_All (Constants); + @end smallexample + + @noindent + which requires that the body (if any) and spec of @code{Constants}, + as well as the body and spec of any unit @code{with}'ed by + @code{Constants} be elaborated before @code{Calc} is elaborated. + + Clearly no automatic method can always guess which alternative you require, + and if you are working with legacy code that had constraints of this kind + which were not properly specified by adding @code{Elaborate} or + @code{Elaborate_All} pragmas, then indeed it is possible that two different + compilers can choose different orders. + + The @code{GNAT BIND} + @code{/PESSIMISTIC_ELABORATION} qualifier may be useful in smoking + out problems. This qualifier causes bodies to be elaborated as late as possible + instead of as early as possible. In the example above, it would have forced + the choice of the first elaboration order. If you get different results + when using this qualifier, and particularly if one set of results is right, + and one is wrong as far as you are concerned, it shows that you have some + missing @code{Elaborate} pragmas. For the example above, we have the + following output: + + @smallexample + GNAT MAKE -f -q main + main + 7 + GNAT MAKE -f -q main /BINDER_QUALIFIERS -p + main + 0 + @end smallexample + + @noindent + It is of course quite unlikely that both these results are correct, so + it is up to you in a case like this to investigate the source of the + difference, by looking at the two elaboration orders that are chosen, + and figuring out which is correct, and then adding the necessary + @code{Elaborate_All} pragmas to ensure the desired order. + + @node The Cross-Referencing Tools GNAT XREF and GNAT FIND + @chapter The Cross-Referencing Tools @code{GNAT XREF} and @code{GNAT FIND} + @findex GNAT XREF + @findex GNAT FIND + + @noindent + The compiler generates cross-referencing information (unless + you set the @samp{/XREF=SUPPRESS} qualifier), which are saved in the @file{.ALI} files. + This information indicates where in the source each entity is declared and + referenced. Note that entities in package Standard are not included, but + entities in all other predefined units are included in the output. + + Before using any of these two tools, you need to compile successfully your + application, so that GNAT gets a chance to generate the cross-referencing + information. + + The two tools @code{GNAT XREF} and @code{GNAT FIND} take advantage of this + information to provide the user with the capability to easily locate the + declaration and references to an entity. These tools are quite similar, + the difference being that @code{GNAT FIND} is intended for locating + definitions and/or references to a specified entity or entities, whereas + @code{GNAT XREF} is oriented to generating a full report of all + cross-references. + + To use these tools, you must not compile your application using the + @option{/XREF=SUPPRESS} qualifier on the @file{GNAT MAKE} command line (@inforef{The + GNAT Make Program GNAT MAKE,,gnat_ug}). Otherwise, cross-referencing + information will not be generated. + + @menu + * GNAT XREF Qualifiers:: + * GNAT FIND Qualifiers:: + * Project Files for GNAT XREF and GNAT FIND:: + * Regular Expressions in GNAT FIND and GNAT XREF:: + * Examples of GNAT XREF Usage:: + * Examples of GNAT FIND Usage:: + @end menu + + @node GNAT XREF Qualifiers + @section @code{GNAT XREF} Qualifiers + + @noindent + The command lines for @code{GNAT XREF} is: + @smallexample + $ GNAT XREF [qualifiers] sourcefile1 [sourcefile2 ...] + @end smallexample + + @noindent + where + + @table @code + @item sourcefile1, sourcefile2 + identifies the source files for which a report is to be generated. The + 'with'ed units will be processed too. You must provide at least one file. + + These file names are considered to be regular expressions, so for instance + specifying 'source*.ADB' is the same as giving every file in the current + directory whose name starts with 'source' and whose extension is 'adb'. + + @end table + + @noindent + The qualifiers can be : + @table @code + @item /ALL_FILES + If this qualifier is present, @code{GNAT FIND} and @code{GNAT XREF} will parse + the read-only files found in the library search path. Otherwise, these files + will be ignored. This option can be used to protect Gnat sources or your own + libraries from being parsed, thus making @code{GNAT FIND} and @code{GNAT XREF} + much faster, and their output much smaller. + + @item /SOURCE_SEARCH=direc + When looking for source files also look in directory DIR. The order in which + source file search is undertaken is the same as for @file{GNAT MAKE}. + + @item /OBJECT_SEARCH=direc + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as for + @file{GNAT MAKE}. + + @item /NOSTD_INCLUDES + Do not look for sources in the system default directory. + + @item /NOSTD_LIBRARIES + Do not look for library files in the system default directory. + + @item /RUNTIME_SYSTEM=@var{rts-path} + @cindex @code{/RUNTIME_SYSTEM} (@code{GNAT XREF}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{GNAT MAKE} flag (see @ref{Qualifiers for GNAT MAKE}). + + @item -d + If this qualifier is set @code{GNAT XREF} will output the parent type + reference for each matching derived types. + + @item /FULL_PATHNAME + If this qualifier is set, the output file names will be preceded by their + directory (if the file was found in the search path). If this qualifier is + not set, the directory will not be printed. + + @item /IGNORE_LOCALS + If this qualifier is set, information is output only for library-level + entities, ignoring local entities. The use of this qualifier may accelerate + @code{GNAT FIND} and @code{GNAT XREF}. + + @item /SEARCH=direc + Equivalent to @samp{/OBJECT_SEARCH=direc /SOURCE_SEARCH=direc}. + + @item /PROJECT=file + Specify a project file to use @xref{Project Files}. + By default, @code{GNAT XREF} and @code{GNAT FIND} will try to locate a + project file in the current directory. + + If a project file is either specified or found by the tools, then the content + of the source directory and object directory lines are added as if they + had been specified respectively by @samp{/SOURCE_SEARCH} + and @samp{OBJECT_SEARCH}. + @item /UNUSED + Output only unused symbols. This may be really useful if you give your + main compilation unit on the command line, as @code{GNAT XREF} will then + display every unused entity and 'with'ed package. + + + @end table + + All these qualifiers may be in any order on the command line, and may even + appear after the file names. They need not be separated by spaces, thus + you can say @samp{GNAT XREF /ALL_FILES/IGNORE_LOCALS} instead of + @samp{GNAT XREF /ALL_FILES /IGNORE_LOCALS}. + + @node GNAT FIND Qualifiers + @section @code{GNAT FIND} Qualifiers + + @noindent + The command line for @code{GNAT FIND} is: + + @smallexample + $ GNAT FIND [qualifiers] pattern[:sourcefile[:line[:column]]] + [file1 file2 ...] + @end smallexample + + @noindent + where + + @table @code + @item pattern + An entity will be output only if it matches the regular expression found + in @samp{pattern}, see @xref{Regular Expressions in GNAT FIND and GNAT XREF}. + + Omitting the pattern is equivalent to specifying @samp{*}, which + will match any entity. Note that if you do not provide a pattern, you + have to provide both a sourcefile and a line. + + Entity names are given in Latin-1, with uppercase/lowercase equivalence + for matching purposes. At the current time there is no support for + 8-bit codes other than Latin-1, or for wide characters in identifiers. + + @item sourcefile + @code{GNAT FIND} will look for references, bodies or declarations + of symbols referenced in @file{sourcefile}, at line @samp{line} + and column @samp{column}. See @pxref{Examples of GNAT FIND Usage} + for syntax examples. + + @item line + is a decimal integer identifying the line number containing + the reference to the entity (or entities) to be located. + + @item column + is a decimal integer identifying the exact location on the + line of the first character of the identifier for the + entity reference. Columns are numbered from 1. + + @item file1 file2 ... + The search will be restricted to these files. If none are given, then + the search will be done for every library file in the search path. + These file must appear only after the pattern or sourcefile. + + These file names are considered to be regular expressions, so for instance + specifying 'source*.ADB' is the same as giving every file in the current + directory whose name starts with 'source' and whose extension is 'adb'. + + Not that if you specify at least one file in this part, @code{GNAT FIND} may + sometimes not be able to find the body of the subprograms... + + @end table + + At least one of 'sourcefile' or 'pattern' has to be present on + the command line. + + The following qualifiers are available: + @table @code + + @item /ALL_FILES + If this qualifier is present, @code{GNAT FIND} and @code{GNAT XREF} will parse + the read-only files found in the library search path. Otherwise, these files + will be ignored. This option can be used to protect Gnat sources or your own + libraries from being parsed, thus making @code{GNAT FIND} and @code{GNAT XREF} + much faster, and their output much smaller. + + @item /SOURCE_SEARCH=direc + When looking for source files also look in directory DIR. The order in which + source file search is undertaken is the same as for @file{GNAT MAKE}. + + @item /OBJECT_SEARCH=direc + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as for + @file{GNAT MAKE}. + + @item /NOSTD_INCLUDES + Do not look for sources in the system default directory. + + @item /NOSTD_LIBRARIES + Do not look for library files in the system default directory. + + @item /RUNTIME_SYSTEM=@var{rts-path} + @cindex @code{/RUNTIME_SYSTEM} (@code{GNAT FIND}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{GNAT MAKE} flag (see @ref{Qualifiers for GNAT MAKE}). + + @item -d + If this qualifier is set, then @code{GNAT FIND} will output the parent type + reference for each matching derived types. + + @item /EXPRESSIONS + By default, @code{GNAT FIND} accept the simple regular expression set for + @samp{pattern}. If this qualifier is set, then the pattern will be + considered as full Unix-style regular expression. + + @item /FULL_PATHNAME + If this qualifier is set, the output file names will be preceded by their + directory (if the file was found in the search path). If this qualifier is + not set, the directory will not be printed. + + @item /IGNORE_LOCALS + If this qualifier is set, information is output only for library-level + entities, ignoring local entities. The use of this qualifier may accelerate + @code{GNAT FIND} and @code{GNAT XREF}. + + @item /SEARCH=direc + Equivalent to @samp{/OBJECT_SEARCH=direc /SOURCE_SEARCH=direc}. + + @item /PROJECT=file + Specify a project file (@pxref{Project Files}) to use. + By default, @code{GNAT XREF} and @code{GNAT FIND} will try to locate a + project file in the current directory. + + If a project file is either specified or found by the tools, then the content + of the source directory and object directory lines are added as if they + had been specified respectively by @samp{/SOURCE_SEARCH} and + @samp{/OBJECT_SEARCH}. + + @item /REFERENCES + By default, @code{GNAT FIND} will output only the information about the + declaration, body or type completion of the entities. If this qualifier is + set, the @code{GNAT FIND} will locate every reference to the entities in + the files specified on the command line (or in every file in the search + path if no file is given on the command line). + + @item /PRINT_LINES + If this qualifier is set, then @code{GNAT FIND} will output the content + of the Ada source file lines were the entity was found. + + @item -t + If this qualifier is set, then @code{GNAT FIND} will output the type hierarchy for + the specified type. It act like -d option but recursively from parent + type to parent type. When this qualifier is set it is not possible to + specify more than one file. + + @end table + + All these qualifiers may be in any order on the command line, and may even + appear after the file names. They need not be separated by spaces, thus + you can say @samp{GNAT XREF /ALL_FILES/IGNORE_LOCALS} instead of + @samp{GNAT XREF /ALL_FILES /IGNORE_LOCALS}. + + As stated previously, GNAT FIND will search in every directory in the + search path. You can force it to look only in the current directory if + you specify @code{*} at the end of the command line. + + + @node Project Files for GNAT XREF and GNAT FIND + @section Project Files for @command{GNAT XREF} and @command{GNAT FIND} + + @noindent + Project files allow a programmer to specify how to compile its + application, where to find sources,... These files are used primarily by + the Glide Ada mode, but they can also be used by the two tools + @code{GNAT XREF} and @code{GNAT FIND}. + + A project file name must end with @file{.adp}. If a single one is + present in the current directory, then @code{GNAT XREF} and @code{GNAT FIND} will + extract the information from it. If multiple project files are found, none of + them is read, and you have to use the @samp{-p} qualifier to specify the one + you want to use. + + The following lines can be included, even though most of them have default + values which can be used in most cases. + The lines can be entered in any order in the file. + Except for @samp{src_dir} and @samp{obj_dir}, you can only have one instance of + each line. If you have multiple instances, only the last one is taken into + account. + + @table @code + @item src_dir=DIR [default: "[]"] + specifies a directory where to look for source files. Multiple src_dir lines + can be specified and they will be searched in the order they + are specified. + + @item obj_dir=DIR [default: "[]"] + specifies a directory where to look for object and library files. Multiple + obj_dir lines can be specified and they will be searched in the order they + are specified + + @item comp_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{comp_opt@}} notation. This is intended to store the default + qualifiers given to @file{GNAT MAKE} and @file{GNAT COMPILE}. + + @item bind_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{bind_opt@}} notation. This is intended to store the default + qualifiers given to @file{GNAT BIND}. + + @item link_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{link_opt@}} notation. This is intended to store the default + qualifiers given to @file{GNAT LINK}. + + @item main=EXECUTABLE [default: ""] + specifies the name of the executable for the application. This variable can + be referred to in the following lines by using the @samp{$@{main@}} notation. + + @item comp_cmd=COMMAND [default: "GNAT COMPILE /SEARCH=$@{src_dir@} /DEBUG /TRY_SEMANTICS"] + specifies the command used to compile a single file in the application. + + @item make_cmd=COMMAND [default: "GNAT MAKE $@{main@} /SOURCE_SEARCH=$@{src_dir@} /OBJECT_SEARCH=$@{obj_dir@} /DEBUG /TRY_SEMANTICS /COMPILER_QUALIFIERS $@{comp_opt@} /BINDER_QUALIFIERS $@{bind_opt@} /LINKER_QUALIFIERS $@{link_opt@}"] + specifies the command used to recompile the whole application. + + @item run_cmd=COMMAND [default: "$@{main@}"] + specifies the command used to run the application. + + @item debug_cmd=COMMAND [default: "GDB $@{main@}"] + specifies the command used to debug the application + + @end table + + @code{GNAT XREF} and @code{GNAT FIND} only take into account the @samp{src_dir} + and @samp{obj_dir} lines, and ignore the others. + + @node Regular Expressions in GNAT FIND and GNAT XREF + @section Regular Expressions in @code{GNAT FIND} and @code{GNAT XREF} + + @noindent + As specified in the section about @code{GNAT FIND}, the pattern can be a + regular expression. Actually, there are to set of regular expressions + which are recognized by the program : + + @table @code + @item globbing patterns + These are the most usual regular expression. They are the same that you + generally used in a Unix shell command line, or in a DOS session. + + Here is a more formal grammar : + @smallexample + @group + @iftex + @leftskip=.5cm + @end iftex + regexp ::= term + term ::= elmt -- matches elmt + term ::= elmt elmt -- concatenation (elmt then elmt) + term ::= * -- any string of 0 or more characters + term ::= ? -- matches any character + term ::= [char @{char@}] -- matches any character listed + term ::= [char - char] -- matches any character in range + @end group + @end smallexample + + @item full regular expression + The second set of regular expressions is much more powerful. This is the + type of regular expressions recognized by utilities such a @file{grep}. + + The following is the form of a regular expression, expressed in Ada + reference manual style BNF is as follows + + @smallexample + @iftex + @leftskip=.5cm + @end iftex + @group + regexp ::= term @{| term@} -- alternation (term or term ...) + + term ::= item @{item@} -- concatenation (item then item) + + item ::= elmt -- match elmt + item ::= elmt * -- zero or more elmt's + item ::= elmt + -- one or more elmt's + item ::= elmt ? -- matches elmt or nothing + @end group + @group + elmt ::= nschar -- matches given character + elmt ::= [nschar @{nschar@}] -- matches any character listed + elmt ::= [^ nschar @{nschar@}] -- matches any character not listed + elmt ::= [char - char] -- matches chars in given range + elmt ::= \ char -- matches given character + elmt ::= . -- matches any single character + elmt ::= ( regexp ) -- parens used for grouping + + char ::= any character, including special characters + nschar ::= any character except ()[].*+?^ + @end group + @end smallexample + + Following are a few examples : + + @table @samp + @item abcde|fghi + will match any of the two strings 'abcde' and 'fghi'. + + @item abc*d + will match any string like 'abd', 'abcd', 'abccd', 'abcccd', and so on + + @item [a-z]+ + will match any string which has only lowercase characters in it (and at + least one character + + @end table + @end table + + @node Examples of GNAT XREF Usage + @section Examples of @code{GNAT XREF} Usage + + @subsection General Usage + + @noindent + For the following examples, we will consider the following units : + + @smallexample + @group + @cartouche + MAIN.ADS: + 1: @b{with} Bar; + 2: @b{package} Main @b{is} + 3: @b{procedure} Foo (B : @b{in} Integer); + 4: C : Integer; + 5: @b{private} + 6: D : Integer; + 7: @b{end} Main; + + MAIN.ADB: + 1: @b{package body} Main @b{is} + 2: @b{procedure} Foo (B : @b{in} Integer) @b{is} + 3: @b{begin} + 4: C := B; + 5: D := B; + 6: Bar.Print (B); + 7: Bar.Print (C); + 8: @b{end} Foo; + 9: @b{end} Main; + + BAR.ADS: + 1: @b{package} Bar @b{is} + 2: @b{procedure} Print (B : Integer); + 3: @b{end} bar; + @end cartouche + @end group + @end smallexample + + @table @code + + @noindent + The first thing to do is to recompile your application (for instance, in + that case just by doing a @samp{GNAT MAKE main}, so that GNAT generates + the cross-referencing information. + You can then issue any of the following commands: + + @item GNAT XREF MAIN.ADB + @code{GNAT XREF} generates cross-reference information for MAIN.ADB + and every unit 'with'ed by MAIN.ADB. + + The output would be: + @smallexample + @iftex + @leftskip=0cm + @end iftex + B Type: Integer + Decl: BAR.ADS 2:22 + B Type: Integer + Decl: MAIN.ADS 3:20 + Body: MAIN.ADB 2:20 + Ref: MAIN.ADB 4:13 5:13 6:19 + Bar Type: Unit + Decl: BAR.ADS 1:9 + Ref: MAIN.ADB 6:8 7:8 + MAIN.ADS 1:6 + C Type: Integer + Decl: MAIN.ADS 4:5 + Modi: MAIN.ADB 4:8 + Ref: MAIN.ADB 7:19 + D Type: Integer + Decl: MAIN.ADS 6:5 + Modi: MAIN.ADB 5:8 + Foo Type: Unit + Decl: MAIN.ADS 3:15 + Body: MAIN.ADB 2:15 + Main Type: Unit + Decl: MAIN.ADS 2:9 + Body: MAIN.ADB 1:14 + Print Type: Unit + Decl: BAR.ADS 2:15 + Ref: MAIN.ADB 6:12 7:12 + @end smallexample + + @noindent + that is the entity @code{Main} is declared in MAIN.ADS, line 2, column 9, + its body is in MAIN.ADB, line 1, column 14 and is not referenced any where. + + The entity @code{Print} is declared in BAR.ADS, line 2, column 15 and it + it referenced in MAIN.ADB, line 6 column 12 and line 7 column 12. + + @item GNAT XREF PACKAGE1.ADB PACKAGE2.ADS + @code{GNAT XREF} will generates cross-reference information for + PACKAGE1.ADB, PACKAGE2.ADS and any other package 'with'ed by any + of these. + + @end table + + + @node Examples of GNAT FIND Usage + @section Examples of @code{GNAT FIND} Usage + + @table @code + + @item GNAT FIND /FULL_PATHNAME xyz:MAIN.ADB + Find declarations for all entities xyz referenced at least once in + MAIN.ADB. The references are search in every library file in the search + path. + + The directories will be printed as well (as the @samp{/FULL_PATHNAME} + qualifier is set) + + The output will look like: + @smallexample + [directory]MAIN.ADS:106:14: xyz <= declaration + [directory]MAIN.ADB:24:10: xyz <= body + [directory]FOO.ADS:45:23: xyz <= declaration + @end smallexample + + @noindent + that is to say, one of the entities xyz found in MAIN.ADB is declared at + line 12 of MAIN.ADS (and its body is in MAIN.ADB), and another one is + declared at line 45 of FOO.ADS + + @item GNAT FIND /FULL_PATHNAME/SOURCE_LINE xyz:MAIN.ADB + This is the same command as the previous one, instead @code{GNAT FIND} will + display the content of the Ada source file lines. + + The output will look like: + + @smallexample + [directory]MAIN.ADS:106:14: xyz <= declaration + procedure xyz; + [directory]MAIN.ADB:24:10: xyz <= body + procedure xyz is + [directory]FOO.ADS:45:23: xyz <= declaration + xyz : Integer; + @end smallexample + + @noindent + This can make it easier to find exactly the location your are looking + for. + + @item GNAT FIND /REFERENCES "*x*":MAIN.ADS:123 FOO.ADB + Find references to all entities containing an x that are + referenced on line 123 of MAIN.ADS. + The references will be searched only in MAIN.ADB and FOO.ADB. + + @item GNAT FIND MAIN.ADS:123 + Find declarations and bodies for all entities that are referenced on + line 123 of MAIN.ADS. + + This is the same as @code{GNAT FIND "*":MAIN.ADB:123}. + + @item GNAT FIND [mydir]MAIN.ADB:123:45 + Find the declaration for the entity referenced at column 45 in + line 123 of file MAIN.ADB in directory mydir. Note that it + is usual to omit the identifier name when the column is given, + since the column position identifies a unique reference. + + The column has to be the beginning of the identifier, and should not + point to any character in the middle of the identifier. + + @end table + + @node File Name Krunching Using GNAT KRUNCH + @chapter File Name Krunching Using @code{GNAT KRUNCH} + @findex GNAT KRUNCH + + @noindent + This chapter discusses the method used by the compiler to shorten + the default file names chosen for Ada units so that they do not + exceed the maximum length permitted. It also describes the + @code{GNAT KRUNCH} utility that can be used to determine the result of + applying this shortening. + @menu + * About GNAT KRUNCH:: + * Using GNAT KRUNCH:: + * Krunching Method:: + * Examples of GNAT KRUNCH Usage:: + @end menu + + @node About GNAT KRUNCH + @section About @code{GNAT KRUNCH} + + @noindent + The default file naming rule in GNAT + is that the file name must be derived from + the unit name. The exact default rule is as follows: + @itemize @bullet + @item + Take the unit name and replace all dots by hyphens. + @item + If such a replacement occurs in the + second character position of a name, and the first character is + A, G, S, or I then replace the dot by the character + $ (dollar sign) + instead of a minus. + @end itemize + The reason for this exception is to avoid clashes + with the standard names for children of System, Ada, Interfaces, + and GNAT, which use the prefixes S- A- I- and G- + respectively. + + The @code{/FILE_NAME_MAX_LENGTH=@var{nn}} + qualifier of the compiler activates a "krunching" + circuit that limits file names to nn characters (where nn is a decimal + integer). For example, using OpenVMS, + where the maximum file name length is + 39, the value of nn is usually set to 39, but if you want to generate + a set of files that would be usable if ported to a system with some + different maximum file length, then a different value can be specified. + The default value of 39 for OpenVMS need not be specified. + + The @code{GNAT KRUNCH} utility can be used to determine the krunched name for + a given file, when krunched to a specified maximum length. + + @node Using GNAT KRUNCH + @section Using @code{GNAT KRUNCH} + + @noindent + The @code{GNAT KRUNCH} command has the form + + + @smallexample + $ GNAT KRUNCH @var{name} /COUNT=nn + @end smallexample + + @noindent + @var{name} can be an Ada name with dots or the GNAT name of the unit, + where the dots representing child units or subunit are replaced by + hyphens. The only confusion arises if a name ends in @code{.ADS} or + @code{.ADB}. @code{GNAT KRUNCH} takes this to be an extension if there are + no other dots in the name. + + @var{length} represents the length of the krunched name. The default + when no argument is given is 39 characters. A length of zero stands for + unlimited, in other words do not chop except for system files which are + always 39. + + @noindent + The output is the krunched name. The output has an extension only if the + original argument was a file name with an extension. + + @node Krunching Method + @section Krunching Method + + @noindent + The initial file name is determined by the name of the unit that the file + contains. The name is formed by taking the full expanded name of the + unit and replacing the separating dots with hyphens and + using uppercase + for all letters, except that a hyphen in the second character position is + replaced by a dollar sign if the first character is + A, I, G, or S. + The extension is @code{.ADS} for a + specification and @code{.ADB} for a body. + Krunching does not affect the extension, but the file name is shortened to + the specified length by following these rules: + + @itemize @bullet + @item + The name is divided into segments separated by hyphens, tildes or + underscores and all hyphens, tildes, and underscores are + eliminated. If this leaves the name short enough, we are done. + + @item + If the name is too long, the longest segment is located (left-most if there are two + of equal length), and shortened by dropping its last character. This is + repeated until the name is short enough. + + As an example, consider the krunching of @*@file{OUR-STRINGS-WIDE_FIXED.ADB} + to fit the name into 8 characters as required by some operating systems. + + @smallexample + our-strings-wide_fixed 22 + our strings wide fixed 19 + our string wide fixed 18 + our strin wide fixed 17 + our stri wide fixed 16 + our stri wide fixe 15 + our str wide fixe 14 + our str wid fixe 13 + our str wid fix 12 + ou str wid fix 11 + ou st wid fix 10 + ou st wi fix 9 + ou st wi fi 8 + Final file name: OUSTWIFI.ADB + @end smallexample + + @item + The file names for all predefined units are always krunched to eight + characters. The krunching of these predefined units uses the following + special prefix replacements: + + @table @file + @item ada- + replaced by @file{A-} + + @item gnat- + replaced by @file{G-} + + @item interfaces- + replaced by @file{I-} + + @item system- + replaced by @file{S-} + @end table + + These system files have a hyphen in the second character position. That + is why normal user files replace such a character with a + dollar sign, to + avoid confusion with system file names. + + As an example of this special rule, consider + @*@file{ADA-STRINGS-WIDE_FIXED.ADB}, which gets krunched as follows: + + @smallexample + ada-strings-wide_fixed 22 + a- strings wide fixed 18 + a- string wide fixed 17 + a- strin wide fixed 16 + a- stri wide fixed 15 + a- stri wide fixe 14 + a- str wide fixe 13 + a- str wid fixe 12 + a- str wid fix 11 + a- st wid fix 10 + a- st wi fix 9 + a- st wi fi 8 + Final file name: A-STWIFI.ADB + @end smallexample + @end itemize + + Of course no file shortening algorithm can guarantee uniqueness over all + possible unit names, and if file name krunching is used then it is your + responsibility to ensure that no name clashes occur. The utility + program @code{GNAT KRUNCH} is supplied for conveniently determining the + krunched name of a file. + + @node Examples of GNAT KRUNCH Usage + @section Examples of @code{GNAT KRUNCH} Usage + + @smallexample + @iftex + @leftskip=0cm + @end iftex + $ GNAT KRUNCH VERY_LONG_UNIT_NAME.ADS/count=6 --> VLUNNA.ADS + $ GNAT KRUNCH VERY_LONG_UNIT_NAME.ADS/count=0 --> VERY_LONG_UNIT_NAME.ADS + @end smallexample + + @node Preprocessing Using GNAT PREPROCESS + @chapter Preprocessing Using @code{GNAT PREPROCESS} + @findex GNAT PREPROCESS + + @noindent + The @code{GNAT PREPROCESS} utility provides + a simple preprocessing capability for Ada programs. + It is designed for use with GNAT, but is not dependent on any special + features of GNAT. + + @menu + * Using GNAT PREPROCESS:: + * Qualifiers for GNAT PREPROCESS:: + * Form of Definitions File:: + * Form of Input Text for GNAT PREPROCESS:: + @end menu + + @node Using GNAT PREPROCESS + @section Using @code{GNAT PREPROCESS} + + @noindent + To call @code{GNAT PREPROCESS} use + + @smallexample + $ GNAT PREPROCESS [-bcrsu] [-Dsymbol=value] infile outfile [deffile] + @end smallexample + + @noindent + where + @table @code + @item infile + is the full name of the input file, which is an Ada source + file containing preprocessor directives. + + @item outfile + is the full name of the output file, which is an Ada source + in standard Ada form. When used with GNAT, this file name will + normally have an ads or adb suffix. + + @item deffile + is the full name of a text file containing definitions of + symbols to be referenced by the preprocessor. This argument is + optional, and can be replaced by the use of the @code{-D} qualifier. + + @item qualifiers + is an optional sequence of qualifiers as described in the next section. + @end table + + @node Qualifiers for GNAT PREPROCESS + @section Qualifiers for @code{GNAT PREPROCESS} + + @table @code + + @item /BLANK_LINES + Causes both preprocessor lines and the lines deleted by + preprocessing to be replaced by blank lines in the output source file, + preserving line numbers in the output file. + + @item /COMMENTS + Causes both preprocessor lines and the lines deleted + by preprocessing to be retained in the output source as comments marked + with the special string "--! ". This option will result in line numbers + being preserved in the output file. + + @item -Dsymbol=value + Defines a new symbol, associated with value. If no value is given on the + command line, then symbol is considered to be @code{True}. This qualifier + can be used in place of a definition file. + + @item /REMOVE (default) + This is the default setting which causes lines deleted by preprocessing + to be entirely removed from the output file. + + @item /REFERENCE + Causes a @code{Source_Reference} pragma to be generated that + references the original input file, so that error messages will use + the file name of this original file. The use of this qualifier implies + that preprocessor lines are not to be removed from the file, so its + use will force @code{/BLANK_LINES} mode if + @code{/COMMENTS} + has not been specified explicitly. + + Note that if the file to be preprocessed contains multiple units, then + it will be necessary to @code{GNAT CHOP} the output file from + @code{GNAT PREPROCESS}. If a @code{Source_Reference} pragma is present + in the preprocessed file, it will be respected by + @code{GNAT CHOP /REFERENCE} + so that the final chopped files will correctly refer to the original + input source file for @code{GNAT PREPROCESS}. + + @item /SYMBOLS + Causes a sorted list of symbol names and values to be + listed on the standard output file. + + @item /UNDEFINED + Causes undefined symbols to be treated as having the value FALSE in the context + of a preprocessor test. In the absence of this option, an undefined symbol in + a @code{#if} or @code{#elsif} test will be treated as an error. + + @end table + + + @node Form of Definitions File + @section Form of Definitions File + + @noindent + The definitions file contains lines of the form + + @smallexample + symbol := value + @end smallexample + + @noindent + where symbol is an identifier, following normal Ada (case-insensitive) + rules for its syntax, and value is one of the following: + + @itemize @bullet + @item + Empty, corresponding to a null substitution + @item + A string literal using normal Ada syntax + @item + Any sequence of characters from the set + (letters, digits, period, underline). + @end itemize + + @noindent + Comment lines may also appear in the definitions file, starting with + the usual @code{--}, + and comments may be added to the definitions lines. + + @node Form of Input Text for GNAT PREPROCESS + @section Form of Input Text for @code{GNAT PREPROCESS} + + @noindent + The input text may contain preprocessor conditional inclusion lines, + as well as general symbol substitution sequences. + + The preprocessor conditional inclusion commands have the form + + @smallexample + @group + @cartouche + #if @i{expression} [then] + lines + #elsif @i{expression} [then] + lines + #elsif @i{expression} [then] + lines + ... + #else + lines + #end if; + @end cartouche + @end group + @end smallexample + + @noindent + In this example, @i{expression} is defined by the following grammar: + @smallexample + @i{expression} ::= + @i{expression} ::= = "" + @i{expression} ::= = + @i{expression} ::= 'Defined + @i{expression} ::= not @i{expression} + @i{expression} ::= @i{expression} and @i{expression} + @i{expression} ::= @i{expression} or @i{expression} + @i{expression} ::= @i{expression} and then @i{expression} + @i{expression} ::= @i{expression} or else @i{expression} + @i{expression} ::= ( @i{expression} ) + @end smallexample + + @noindent + For the first test (@i{expression} ::= ) the symbol must have + either the value true or false, that is to say the right-hand of the + symbol definition must be one of the (case-insensitive) literals + @code{True} or @code{False}. If the value is true, then the + corresponding lines are included, and if the value is false, they are + excluded. + + The test (@i{expression} ::= @code{'Defined}) is true only if + the symbol has been defined in the definition file or by a @code{-D} + qualifier on the command line. Otherwise, the test is false. + + The equality tests are case insensitive, as are all the preprocessor lines. + + If the symbol referenced is not defined in the symbol definitions file, + then the effect depends on whether or not qualifier @code{-u} + is specified. If so, then the symbol is treated as if it had the value + false and the test fails. If this qualifier is not specified, then + it is an error to reference an undefined symbol. It is also an error to + reference a symbol that is defined with a value other than @code{True} + or @code{False}. + + The use of the @code{not} operator inverts the sense of this logical test, so + that the lines are included only if the symbol is not defined. + The @code{then} keyword is optional as shown + + The @code{#} must be the first non-blank character on a line, but + otherwise the format is free form. Spaces or tabs may appear between + the @code{#} and the keyword. The keywords and the symbols are case + insensitive as in normal Ada code. Comments may be used on a + preprocessor line, but other than that, no other tokens may appear on a + preprocessor line. Any number of @code{elsif} clauses can be present, + including none at all. The @code{else} is optional, as in Ada. + + The @code{#} marking the start of a preprocessor line must be the first + non-blank character on the line, i.e. it must be preceded only by + spaces or horizontal tabs. + + Symbol substitution outside of preprocessor lines is obtained by using + the sequence + + @smallexample + $symbol + @end smallexample + + @noindent + anywhere within a source line, except in a comment or within a + string literal. The identifier + following the @code{$} must match one of the symbols defined in the symbol + definition file, and the result is to substitute the value of the + symbol in place of @code{$symbol} in the output file. + + Note that although the substitution of strings within a string literal + is not possible, it is possible to have a symbol whose defined value is + a string literal. So instead of setting XYZ to @code{hello} and writing: + + @smallexample + Header : String := "$XYZ"; + @end smallexample + + @noindent + you should set XYZ to @code{"hello"} and write: + + @smallexample + Header : String := $XYZ; + @end smallexample + + @noindent + and then the substitution will occur as desired. + + @node The GNAT Run-Time Library Builder GNAT LIBRARY + @chapter The GNAT Run-Time Library Builder @code{GNAT LIBRARY} + @findex GNAT LIBRARY + @cindex Library builder + + @noindent + @code{GNAT LIBRARY} is a tool for rebuilding the GNAT run time with user + supplied configuration pragmas. + + @menu + * Running GNAT LIBRARY:: + * Qualifiers for GNAT LIBRARY:: + * Examples of GNAT LIBRARY Usage:: + @end menu + + @node Running GNAT LIBRARY + @section Running @code{GNAT LIBRARY} + + @noindent + The @code{GNAT LIBRARY} command has the form + + @smallexample + $ GNAT LIBRARY /[CREATE | SET | DELETE]=directory [/CONFIG=file] + @end smallexample + + @node Qualifiers for GNAT LIBRARY + @section Qualifiers for @code{GNAT LIBRARY} + + @noindent + @code{GNAT LIBRARY} recognizes the following qualifiers: + + @table @code + @item /CREATE=directory + @cindex @code{/CREATE=directory} (@code{GNAT LIBRARY}) + Create the new run-time library in the specified directory. + + @item /SET=directory + @cindex @code{/SET=directory} (@code{GNAT LIBRARY}) + Make the library in the specified directory the current run-time + library. + + @item /DELETE=directory + @cindex @code{/DELETE=directory} (@code{GNAT LIBRARY}) + Delete the run-time library in the specified directory. + + @item /CONFIG=file + @cindex @code{/CONFIG=file} (@code{GNAT LIBRARY}) + With /CREATE: + Use the configuration pragmas in the specified file when building + the library. + + With /SET: + Use the configuration pragmas in the specified file when compiling. + + @end table + + @node Examples of GNAT LIBRARY Usage + @section Example of @code{GNAT LIBRARY} Usage + + @smallexample + Contents of VAXFLOAT.ADC: + pragma Float_Representation (VAX_Float); + + $ GNAT LIBRARY /CREATE=[.VAXFLOAT] /CONFIG=VAXFLOAT.ADC + + GNAT LIBRARY rebuilds the run-time library in directory [.VAXFLOAT] + + @end smallexample + + @node The GNAT Library Browser GNAT LIST + @chapter The GNAT Library Browser @code{GNAT LIST} + @findex GNAT LIST + @cindex Library browser + + @noindent + @code{GNAT LIST} is a tool that outputs information about compiled + units. It gives the relationship between objects, unit names and source + files. It can also be used to check the source dependencies of a unit + as well as various characteristics. + + @menu + * Running GNAT LIST:: + * Qualifiers for GNAT LIST:: + * Examples of GNAT LIST Usage:: + @end menu + + @node Running GNAT LIST + @section Running @code{GNAT LIST} + + @noindent + The @code{GNAT LIST} command has the form + + @smallexample + $ GNAT LIST qualifiers @var{object_or_ali_file} + @end smallexample + + @noindent + The main argument is the list of object or @file{ali} files + (@pxref{The Ada Library Information Files}) + for which information is requested. + + In normal mode, without additional option, @code{GNAT LIST} produces a + four-column listing. Each line represents information for a specific + object. The first column gives the full path of the object, the second + column gives the name of the principal unit in this object, the third + column gives the status of the source and the fourth column gives the + full path of the source representing this unit. + Here is a simple example of use: + + @smallexample + $ GNAT LIST *.OBJ + []DEMO1.OBJ demo1 DIF DEMO1.ADB + []DEMO2.OBJ demo2 OK DEMO2.ADB + []HELLO.OBJ h1 OK HELLO.ADB + []INSTR-CHILD.OBJ instr.child MOK INSTR-CHILD.ADB + []INSTR.OBJ instr OK INSTR.ADB + []TEF.OBJ tef DIF TEF.ADB + []TEXT_IO_EXAMPLE.OBJ text_io_example OK TEXT_IO_EXAMPLE.ADB + []TGEF.OBJ tgef DIF TGEF.ADB + @end smallexample + + @noindent + The first line can be interpreted as follows: the main unit which is + contained in + object file @file{DEMO1.OBJ} is demo1, whose main source is in + @file{DEMO1.ADB}. Furthermore, the version of the source used for the + compilation of demo1 has been modified (DIF). Each source file has a status + qualifier which can be: + + @table @code + @item OK (unchanged) + The version of the source file used for the compilation of the + specified unit corresponds exactly to the actual source file. + + @item MOK (slightly modified) + The version of the source file used for the compilation of the + specified unit differs from the actual source file but not enough to + require recompilation. If you use GNAT MAKE with the qualifier + @code{/MINIMAL_RECOMPILATION}, a file marked + MOK will not be recompiled. + + @item DIF (modified) + No version of the source found on the path corresponds to the source + used to build this object. + + @item ??? (file not found) + No source file was found for this unit. + + @item HID (hidden, unchanged version not first on PATH) + The version of the source that corresponds exactly to the source used + for compilation has been found on the path but it is hidden by another + version of the same source that has been modified. + + @end table + + @node Qualifiers for GNAT LIST + @section Qualifiers for @code{GNAT LIST} + + @noindent + @code{GNAT LIST} recognizes the following qualifiers: + + @table @code + @item /ALL_UNITS + @cindex @code{/ALL_UNITS} (@code{GNAT LIST}) + Consider all units, including those of the predefined Ada library. + Especially useful with @code{/DEPENDENCIES}. + + @item /DEPENDENCIES + @cindex @code{/DEPENDENCIES} (@code{GNAT LIST}) + List sources from which specified units depend on. + + @item /OUTPUT=OPTIONS + @cindex @code{/OUTPUT=OPTIONS} (@code{GNAT LIST}) + Output the list of options. + + @item /OUTPUT=OBJECTS + @cindex @code{/OUTPUT=OBJECTS} (@code{GNAT LIST}) + Only output information about object files. + + @item /OUTPUT=SOURCES + @cindex @code{/OUTPUT=SOURCES} (@code{GNAT LIST}) + Only output information about source files. + + @item /OUTPUT=UNITS + @cindex @code{/OUTPUT=UNITS} (@code{GNAT LIST}) + Only output information about compilation units. + + @item /OBJECT_SEARCH=@var{dir} + @itemx /SOURCE_SEARCH=@var{dir} + @itemx /SEARCH=@var{dir} + @itemx /NOCURRENT_DIRECTORY + @itemx /NOSTD_INCLUDES + Source path manipulation. Same meaning as the equivalent @code{GNAT MAKE} flags + (see @ref{Qualifiers for GNAT MAKE}). + + @item /RUNTIME_SYSTEM=@var{rts-path} + @cindex @code{/RUNTIME_SYSTEM} (@code{GNAT LIST}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{GNAT MAKE} flag (see @ref{Qualifiers for GNAT MAKE}). + + @item /OUTPUT=VERBOSE + @cindex @code{/OUTPUT=VERBOSE} (@code{GNAT LIST}) + Verbose mode. Output the complete source and object paths. Do not use + the default column layout but instead use long format giving as much as + information possible on each requested units, including special + characteristics such as: + + @table @code + @item Preelaborable + The unit is preelaborable in the Ada 95 sense. + + @item No_Elab_Code + No elaboration code has been produced by the compiler for this unit. + + @item Pure + The unit is pure in the Ada 95 sense. + + @item Elaborate_Body + The unit contains a pragma Elaborate_Body. + + @item Remote_Types + The unit contains a pragma Remote_Types. + + @item Shared_Passive + The unit contains a pragma Shared_Passive. + + @item Predefined + This unit is part of the predefined environment and cannot be modified + by the user. + + @item Remote_Call_Interface + The unit contains a pragma Remote_Call_Interface. + + @end table + + @end table + + @node Examples of GNAT LIST Usage + @section Example of @code{GNAT LIST} Usage + + @smallexample + GNAT LIST /DEPENDENCIES /OUTPUT=SOURCES /ALL_UNITS DEMO1.ADB + + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]ADA.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]A-FINALI.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]A-FILICO.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]A-STREAM.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]A-TAGS.ADS + DEMO1.ADB + GEN_LIST.ADS + GEN_LIST.ADB + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]GNAT.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]G-IO.ADS + INSTR.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]SYSTEM.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-EXCTAB.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-FINIMP.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-FINROO.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-SECSTA.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-STALIB.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-STOELE.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-STRATT.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-TASOLI.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]S-UNSTYP.ADS + GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB]UNCHCONV.ADS + @end smallexample + + + @node Finding Memory Problems with GNAT Debug Pool + @chapter Finding Memory Problems with GNAT Debug Pool + @findex Debug Pool + @cindex storage, pool, memory corruption + + @noindent + The use of unchecked deallocation and unchecked conversion can easily + lead to incorrect memory references. The problems generated by such + references are usually difficult to tackle because the symptoms can be + very remote from the origin of the problem. In such cases, it is + very helpful to detect the problem as early as possible. This is the + purpose of the Storage Pool provided by @code{GNAT.Debug_Pools}. + + @noindent + In order to use the GNAT specific debugging pool, the user must + associate a debug pool object with each of the access types that may be + related to suspected memory problems. See Ada Reference Manual + 13.11. + @smallexample + @b{type} Ptr @b{is} @b{access} Some_Type; + Pool : GNAT.Debug_Pools.Debug_Pool; + @b{for} Ptr'Storage_Pool @b{use} Pool; + @end smallexample + + @code{GNAT.Debug_Pools} is derived from of a GNAT-specific kind of + pool: the Checked_Pool. Such pools, like standard Ada storage pools, + allow the user to redefine allocation and deallocation strategies. They + also provide a checkpoint for each dereference, through the use of + the primitive operation @code{Dereference} which is implicitly called at + each dereference of an access value. + + Once an access type has been associated with a debug pool, operations on + values of the type may raise four distinct exceptions, + which correspond to four potential kinds of memory corruption: + @itemize @bullet + @item + @code{GNAT.Debug_Pools.Accessing_Not_Allocated_Storage} + @item + @code{GNAT.Debug_Pools.Accessing_Deallocated_Storage} + @item + @code{GNAT.Debug_Pools.Freeing_Not_Allocated_Storage} + @item + @code{GNAT.Debug_Pools.Freeing_Deallocated_Storage } + @end itemize + + @noindent + For types associated with a Debug_Pool, dynamic allocation is performed using + the standard + GNAT allocation routine. References to all allocated chunks of memory + are kept in an internal dictionary. The deallocation strategy consists + in not releasing the memory to the underlying system but rather to fill + it with a memory pattern easily recognizable during debugging sessions: + The memory pattern is the old IBM hexadecimal convention: 16#DEADBEEF#. + Upon each dereference, a check is made that the access value denotes a properly + allocated memory location. Here is a complete example of use of + @code{Debug_Pools}, that includes typical instances of memory corruption: + @smallexample + @iftex + @leftskip=0cm + @end iftex + @b{with} Gnat.Io; @b{use} Gnat.Io; + @b{with} Unchecked_Deallocation; + @b{with} Unchecked_Conversion; + @b{with} GNAT.Debug_Pools; + @b{with} System.Storage_Elements; + @b{with} Ada.Exceptions; @b{use} Ada.Exceptions; + @b{procedure} Debug_Pool_Test @b{is} + + @b{type} T @b{is} @b{access} Integer; + @b{type} U @b{is} @b{access} @b{all} T; + + P : GNAT.Debug_Pools.Debug_Pool; + @b{for} T'Storage_Pool @b{use} P; + + @b{procedure} Free @b{is} @b{new} Unchecked_Deallocation (Integer, T); + @b{function} UC @b{is} @b{new} Unchecked_Conversion (U, T); + A, B : @b{aliased} T; + + @b{procedure} Info @b{is} @b{new} GNAT.Debug_Pools.Print_Info(Put_Line); + + @b{begin} + Info (P); + A := @b{new} Integer; + B := @b{new} Integer; + B := A; + Info (P); + Free (A); + @b{begin} + Put_Line (Integer'Image(B.@b{all})); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + @b{begin} + Free (B); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + B := UC(A'Access); + @b{begin} + Put_Line (Integer'Image(B.@b{all})); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + @b{begin} + Free (B); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + Info (P); + @b{end} Debug_Pool_Test; + @end smallexample + @noindent + The debug pool mechanism provides the following precise diagnostics on the + execution of this erroneous program: + @smallexample + Debug Pool info: + Total allocated bytes : 0 + Total deallocated bytes : 0 + Current Water Mark: 0 + High Water Mark: 0 + + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 0 + Current Water Mark: 8 + High Water Mark: 8 + + raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 4 + Current Water Mark: 4 + High Water Mark: 8 + + @end smallexample + + @node Creating Sample Bodies Using GNAT STUB + @chapter Creating Sample Bodies Using @code{GNAT STUB} + @findex GNAT STUB + + @noindent + @code{GNAT STUB} creates body stubs, that is, empty but compilable bodies + for library unit declarations. + + To create a body stub, @code{GNAT STUB} has to compile the library + unit declaration. Therefore, bodies can be created only for legal + library units. Moreover, if a library unit depends semantically upon + units located outside the current directory, you have to provide + the source search path when calling @code{GNAT STUB}, see the description + of @code{GNAT STUB} qualifiers below. + + @menu + * Running GNAT STUB:: + * Qualifiers for GNAT STUB:: + @end menu + + @node Running GNAT STUB + @section Running @code{GNAT STUB} + + @noindent + @code{GNAT STUB} has the command-line interface of the form + + @smallexample + $ GNAT STUB [qualifiers] filename [directory] + @end smallexample + + @noindent + where + @table @code + @item filename + is the name of the source file that contains a library unit declaration + for which a body must be created. This name should follow the GNAT file name + conventions. No crunching is allowed for this file name. The file + name may contain the path information. + + @item directory + indicates the directory to place a body stub (default is the + current directory) + + @item qualifiers + is an optional sequence of qualifiers as described in the next section + @end table + + @node Qualifiers for GNAT STUB + @section Qualifiers for @code{GNAT STUB} + + @table @code + + @item /FULL + If the destination directory already contains a file with a name of the body file + for the argument spec file, replace it with the generated body stub. + + @item /HEADER=SPEC + Put the comment header (i.e. all the comments preceding the + compilation unit) from the source of the library unit declaration + into the body stub. + + @item /HEADER=GENERAL + Put a sample comment header into the body stub. + + @item /SEARCH=direc + @itemx /NOCURRENT_DIRECTORY + These qualifiers have the same meaning as in calls to GNAT COMPILE. + They define the source search path in the call to GNAT COMPILE issued + by @code{GNAT STUB} to compile an argument source file. + + @item /INDENTATION=@var{n} + (@var{n} is a decimal natural number). Set the indentation level in the + generated body sample to n, '/INDENTATION=0' means "no indentation", + the default indentation is 3. + + @item /TREE_FILE=SAVE + Do not remove the tree file (i.e. the snapshot of the compiler internal + structures used by @code{GNAT STUB}) after creating the body stub. + + @item /LINE_LENGTH=@var{n} + (@var{n} is a decimal positive number) Set the maximum line length in the + body stub to n, the default is 78. + + @item /QUIET + Quiet mode: do not generate a confirmation when a body is + successfully created or a message when a body is not required for an + argument unit. + + @item /TREE_FILE=REUSE + Reuse the tree file (if it exists) instead of creating it: instead of + creating the tree file for the library unit declaration, GNAT STUB + tries to find it in the current directory and use it for creating + a body. If the tree file is not found, no body is created. @code{/REUSE} + also implies @code{/SAVE}, whether or not + @code{/SAVE} is set explicitly. + + @item /TREE_FILE=OVERWRITE + Overwrite the existing tree file: if the current directory already + contains the file which, according to the GNAT file name rules should + be considered as a tree file for the argument source file, GNAT STUB + will refuse to create the tree file needed to create a body sampler, + unless @code{-t} option is set + + @item /VERBOSE + Verbose mode: generate version information. + + @end table + + @node Reducing the Size of Ada Executables with GNAT ELIM + @chapter Reducing the Size of Ada Executables with @code{GNAT ELIM} + @findex GNAT ELIM + + @menu + * About GNAT ELIM:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for GNAT ELIM:: + * Running GNAT ELIM:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the GNAT ELIM Usage Cycle:: + @end menu + + @node About GNAT ELIM + @section About @code{GNAT ELIM} + + @noindent + When a program shares a set of Ada + packages with other programs, it may happen that this program uses + only a fraction of the subprograms defined in these packages. The code + created for these unused subprograms increases the size of the executable. + + @code{GNAT ELIM} tracks unused subprograms in an Ada program and + outputs a list of GNAT-specific @code{Eliminate} pragmas (see next + section) marking all the subprograms that are declared but never called. + By placing the list of @code{Eliminate} pragmas in the GNAT configuration + file @file{GNAT.ADC} and recompiling your program, you may decrease the + size of its executable, because the compiler will not generate the code + for 'eliminated' subprograms. + + @code{GNAT ELIM} needs as its input data a set of tree files + (see @ref{Tree Files}) representing all the components of a program to + process and a bind file for a main subprogram (see + @ref{Preparing Tree and Bind Files for GNAT ELIM}). + + @node Eliminate Pragma + @section @code{Eliminate} Pragma + @findex Eliminate + + @noindent + The simplified syntax of the Eliminate pragma used by @code{GNAT ELIM} is: + + @smallexample + @cartouche + @b{pragma} Eliminate (Library_Unit_Name, Subprogram_Name); + @end cartouche + @end smallexample + + @noindent + where + @table @code + @item Library_Unit_Name + full expanded Ada name of a library unit + + @item Subprogram_Name + a simple or expanded name of a subprogram declared within this + compilation unit + + @end table + + @noindent + The effect of an @code{Eliminate} pragma placed in the GNAT configuration + file @file{GNAT.ADC} is: + + @itemize @bullet + + @item + If the subprogram @code{Subprogram_Name} is declared within + the library unit @code{Library_Unit_Name}, the compiler will not generate + code for this subprogram. This applies to all overloaded subprograms denoted + by @code{Subprogram_Name}. + + @item + If a subprogram marked by the pragma @code{Eliminate} is used (called) + in a program, the compiler will produce an error message in the place where + it is called. + @end itemize + + @node Tree Files + @section Tree Files + @cindex Tree file + + @noindent + A tree file stores a snapshot of the compiler internal data + structures at the very end of a successful compilation. It contains all the + syntactic and semantic information for the compiled unit and all the + units upon which it depends semantically. + To use tools that make use of tree files, you + need to first produce the right set of tree files. + + GNAT produces correct tree files when /TREE_OUTPUT /NOLOAD options are set + in a GNAT COMPILE call. The tree files have an .adt extension. + Therefore, to produce a tree file for the compilation unit contained in a file + named @file{FOO.ADB}, you must use the command + + @smallexample + $ GNAT COMPILE /NOLOAD /TREE_OUTPUT FOO.ADB + @end smallexample + + @noindent + and you will get the tree file @file{foo.adt}. + compilation. + + @node Preparing Tree and Bind Files for GNAT ELIM + @section Preparing Tree and Bind Files for @code{GNAT ELIM} + + @noindent + A set of tree files covering the program to be analyzed with + @code{GNAT ELIM} and + the bind file for the main subprogram does not have to + be in the current directory. + '-T' GNAT ELIM option may be used to provide + the search path for tree files, and '-b' + option may be used to point to the bind + file to process (see @ref{Running GNAT ELIM}) + + If you do not have the appropriate set of tree + files and the right bind file, you + may create them in the current directory using the following procedure. + + Let @code{Main_Prog} be the name of a main subprogram, and suppose + this subprogram is in a file named @file{MAIN_PROG.ADB}. + + To create a bind file for @code{GNAT ELIM}, run @code{GNAT BIND} for + the main subprogram. @code{GNAT ELIM} can work with both Ada and C + bind files; when both are present, it uses the Ada bind file. + The following commands will build the program and create the bind file: + + @smallexample + $ GNAT MAKE /ACTIONS=COMPILE MAIN_PROG + $ GNAT BIND main_prog + @end smallexample + + @noindent + To create a minimal set of tree files covering the whole program, call + @code{GNAT MAKE} for this program as follows: + + @smallexample + $ GNAT MAKE /FORCE_COMPILE /ACTIONS=COMPILE /NOLOAD /TREE_OUTPUT MAIN_PROG + @end smallexample + + @noindent + The @code{/ACTIONS=COMPILE} GNAT MAKE option turns off the bind and link + steps, that are useless anyway because the sources are compiled with + @option{/NOLOAD} option which turns off code generation. + + The @code{/FORCE_COMPILE} GNAT MAKE option forces + recompilation of all the needed sources. + + This sequence of actions will create all the data needed by @code{GNAT ELIM} + from scratch and therefore guarantee its consistency. If you would like to + use some existing set of files as @code{GNAT ELIM} output, you must make + sure that the set of files is complete and consistent. You can use the + @code{-m} qualifier to check if there are missed tree files + + Note, that @code{GNAT ELIM} needs neither object nor ALI files. + + @node Running GNAT ELIM + @section Running @code{GNAT ELIM} + + @noindent + @code{GNAT ELIM} has the following command-line interface: + + @smallexample + $ GNAT ELIM [options] name + @end smallexample + + @noindent + @code{name} should be a full expanded Ada name of a main subprogram + of a program (partition). + + @code{GNAT ELIM} options: + + @table @code + @item /QUIET + Quiet mode: by default @code{GNAT ELIM} generates to the standard error + stream a trace of the source file names of the compilation units being + processed. This option turns this trace off. + + @item /VERBOSE + Verbose mode: @code{GNAT ELIM} version information is printed as Ada + comments to the standard output stream. + + @item /ALL + Also look for subprograms from the GNAT run time that can be eliminated. + + @item /MISSED + Check if any tree files are missing for an accurate result. + + @item /TREE_DIRS=@var{dir} + When looking for tree files also look in directory @var{dir} + + @item /BIND_FILE=@var{bind_file} + Specifies @var{bind_file} as the bind file to process. If not set, the name + of the bind file is computed from the full expanded Ada name of a main subprogram. + + @item -d@var{x} + Activate internal debugging qualifiers. @var{x} is a letter or digit, or + string of letters or digits, which specifies the type of debugging + mode desired. Normally these are used only for internal development + or system debugging purposes. You can find full documentation for these + qualifiers in the body of the @code{GNAT ELIM.Options} unit in the compiler + source file @file{GNATELIM-OPTIONS.ADB}. + @end table + + @noindent + @code{GNAT ELIM} sends its output to the standard output stream, and all the + tracing and debug information is sent to the standard error stream. + In order to produce a proper GNAT configuration file + @file{GNAT.ADC}, redirection must be used: + + @smallexample + $ PIPE GNAT ELIM MAIN_PROG > GNAT.ADC + @end smallexample + + + @noindent + In order to append the @code{GNAT ELIM} output to the existing contents of + @file{GNAT.ADC}. + + @node Correcting the List of Eliminate Pragmas + @section Correcting the List of Eliminate Pragmas + + @noindent + In some rare cases it may happen that @code{GNAT ELIM} will try to eliminate + subprograms which are actually called in the program. In this case, the + compiler will generate an error message of the form: + + @smallexample + FILE.ADB:106:07: cannot call eliminated subprogram "My_Prog" + @end smallexample + + @noindent + You will need to manually remove the wrong @code{Eliminate} pragmas from + the @file{GNAT.ADC} file. It is advised that you recompile your program + from scratch after that because you need a consistent @file{GNAT.ADC} file + during the entire compilation. + + @node Making Your Executables Smaller + @section Making Your Executables Smaller + + @noindent + In order to get a smaller executable for your program you now have to + recompile the program completely with the new @file{GNAT.ADC} file + created by @code{GNAT ELIM} in your current directory: + + @smallexample + $ GNAT MAKE /FORCE_COMPILE MAIN_PROG + @end smallexample + + @noindent + (you will need @code{/FORCE_COMPILE} option for GNAT MAKE to + recompile everything + with the set of pragmas @code{Eliminate} you have obtained with + @code{GNAT ELIM}). + + Be aware that the set of @code{Eliminate} pragmas is specific to each + program. It is not recommended to merge sets of @code{Eliminate} + pragmas created for different programs in one @file{GNAT.ADC} file. + + @node Summary of the GNAT ELIM Usage Cycle + @section Summary of the GNAT ELIM Usage Cycle + + @noindent + Here is a quick summary of the steps to be taken in order to reduce + the size of your executables with @code{GNAT ELIM}. You may use + other GNAT options to control the optimization level, + to produce the debugging information, to set search path, etc. + + @enumerate + @item + Produce a bind file and a set of tree files + + @smallexample + $ GNAT MAKE /ACTIONS=COMPILE MAIN_PROG + $ GNAT BIND main_prog + $ GNAT MAKE /FORCE_COMPILE /NO_LINK /NOLOAD /TREE_OUTPUT MAIN_PROG + @end smallexample + + @item + Generate a list of @code{Eliminate} pragmas + @smallexample + $ PIPE GNAT ELIM MAIN_PROG > GNAT.ADC + @end smallexample + + @item + Recompile the application + + @smallexample + $ GNAT MAKE /FORCE_COMPILE MAIN_PROG + @end smallexample + + @end enumerate + + @node Other Utility Programs + @chapter Other Utility Programs + + @noindent + This chapter discusses some other utility programs available in the Ada + environment. + + @menu + * Using Other Utility Programs with GNAT:: + * The GNAT STANDARD Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * Installing gnathtml:: + * LSE:: + * Profiling:: + @end menu + + @node Using Other Utility Programs with GNAT + @section Using Other Utility Programs with GNAT + + @noindent + The object files generated by GNAT are in standard system format and in + particular the debugging information uses this format. This means + programs generated by GNAT can be used with existing utilities that + depend on these formats. + + + @node The GNAT STANDARD Utility Program + @section The @code{GNAT STANDARD} Utility Program + + @noindent + Many of the definitions in package Standard are implementation-dependent. + However, the source of this package does not exist as an Ada source + file, so these values cannot be determined by inspecting the source. + They can be determined by examining in detail the coding of + @file{CSTAND.ADB} which creates the image of Standard in the compiler, + but this is awkward and requires a great deal of internal knowledge + about the system. + + The @code{GNAT STANDARD} utility is designed to deal with this situation. + It is an Ada program that dynamically determines the + values of all the relevant parameters in Standard, and prints them + out in the form of an Ada source listing for Standard, displaying all + the values of interest. This output is generated to + @file{SYS$OUTPUT}. + + To determine the value of any parameter in package Standard, simply + run @code{GNAT STANDARD} with no qualifiers or arguments, and examine + the output. This is preferable to consulting documentation, because + you know that the values you are getting are the actual ones provided + by the executing system. + + @node The External Symbol Naming Scheme of GNAT + @section The External Symbol Naming Scheme of GNAT + + @noindent + In order to interpret the output from GNAT, when using tools that are + originally intended for use with other languages, it is useful to + understand the conventions used to generate link names from the Ada + entity names. + + All link names are in all lowercase letters. With the exception of library + procedure names, the mechanism used is simply to use the full expanded + Ada name with dots replaced by double underscores. For example, suppose + we have the following package spec: + + @smallexample + @group + @cartouche + @b{package} QRS @b{is} + MN : Integer; + @b{end} QRS; + @end cartouche + @end group + @end smallexample + + @noindent + The variable @code{MN} has a full expanded Ada name of @code{QRS.MN}, so + the corresponding link name is @code{qrs__mn}. + @findex Export + Of course if a @code{pragma Export} is used this may be overridden: + + @smallexample + @group + @cartouche + @b{package} Exports @b{is} + Var1 : Integer; + @b{pragma} Export (Var1, C, External_Name => "var1_name"); + Var2 : Integer; + @b{pragma} Export (Var2, C, Link_Name => "var2_link_name"); + @b{end} Exports; + @end cartouche + @end group + @end smallexample + + @noindent + In this case, the link name for @var{Var1} is whatever link name the + C compiler would assign for the C function @var{var1_name}. This typically + would be either @var{var1_name} or @var{_var1_name}, depending on operating + system conventions, but other possibilities exist. The link name for + @var{Var2} is @var{var2_link_name}, and this is not operating system + dependent. + + @findex _main + One exception occurs for library level procedures. A potential ambiguity + arises between the required name @code{_main} for the C main program, + and the name we would otherwise assign to an Ada library level procedure + called @code{Main} (which might well not be the main program). + + To avoid this ambiguity, we attach the prefix @code{_ada_} to such + names. So if we have a library level procedure such as + + @smallexample + @group + @cartouche + @b{procedure} Hello (S : String); + @end cartouche + @end group + @end smallexample + + @noindent + the external name of this procedure will be @var{_ada_hello}. + + @node Ada Mode for Glide + @section Ada Mode for @code{Glide} + + @noindent + The Glide mode for programming in Ada (both, Ada83 and Ada95) helps the + user in understanding existing code and facilitates writing new code. It + furthermore provides some utility functions for easier integration of + standard EMACS features when programming in Ada. + + @subsection General Features: + + @itemize @bullet + @item + Full Integrated Development Environment : + + @itemize @bullet + @item + support of 'project files' for the configuration (directories, + compilation options,...) + + @item + compiling and stepping through error messages. + + @item + running and debugging your applications within Glide. + @end itemize + + @item + easy to use for beginners by pull-down menus, + + @item + user configurable by many user-option variables. + @end itemize + + @subsection Ada Mode Features That Help Understanding Code: + + @itemize @bullet + @item + functions for easy and quick stepping through Ada code, + + @item + getting cross reference information for identifiers (e.g. find the + defining place by a keystroke), + + @item + displaying an index menu of types and subprograms and move point to + the chosen one, + + @item + automatic color highlighting of the various entities in Ada code. + @end itemize + + @subsection Glide Support for Writing Ada Code: + + @itemize @bullet + @item + switching between spec and body files with possible + autogeneration of body files, + + @item + automatic formating of subprograms parameter lists. + + @item + automatic smart indentation according to Ada syntax, + + @item + automatic completion of identifiers, + + @item + automatic casing of identifiers, keywords, and attributes, + + @item + insertion of statement templates, + + @item + filling comment paragraphs like filling normal text, + @end itemize + + For more information, please refer to the online Glide documentation + available in the Glide --> Help Menu. + + @node Converting Ada Files to html with gnathtml + @section Converting Ada Files to html with @code{gnathtml} + + @noindent + This @code{Perl} script allows Ada source files to be browsed using + standard Web browsers. For installation procedure, see the section + @xref{Installing gnathtml}. + + Ada reserved keywords are highlighted in a bold font and Ada comments in + a blue font. Unless your program was compiled with the GNAT COMPILE @option{/XREF=SUPPRESS} + qualifier to suppress the generation of cross-referencing information, user + defined variables and types will appear in a different color; you will + be able to click on any identifier and go to its declaration. + + The command line is as follow: + @smallexample + $ perl gnathtml.pl [qualifiers] ada-files + @end smallexample + + You can pass it as many Ada files as you want. @code{gnathtml} will generate + an html file for every ada file, and a global file called @file{index.htm}. + This file is an index of every identifier defined in the files. + + The available qualifiers are the following ones : + + @table @code + @item -83 + @cindex @code{-83} (@code{gnathtml}) + Only the subset on the Ada 83 keywords will be highlighted, not the full + Ada 95 keywords set. + + @item -cc @var{color} + This option allows you to change the color used for comments. The default + value is green. The color argument can be any name accepted by html. + + @item -d + @cindex @code{-d} (@code{gnathtml}) + If the ada files depend on some other files (using for instance the + @code{with} command, the latter will also be converted to html. + Only the files in the user project will be converted to html, not the files + in the run-time library itself. + + @item -D + This command is the same as -d above, but @code{gnathtml} will also look + for files in the run-time library, and generate html files for them. + + @item -f + @cindex @code{-f} (@code{gnathtml}) + By default, gnathtml will generate html links only for global entities + ('with'ed units, global variables and types,...). If you specify the + @code{-f} on the command line, then links will be generated for local + entities too. + + @item -l @var{number} + @cindex @code{-l} (@code{gnathtml}) + If this qualifier is provided and @var{number} is not 0, then @code{gnathtml} + will number the html files every @var{number} line. + + @item -I @var{dir} + @cindex @code{-I} (@code{gnathtml}) + Specify a directory to search for library files (@file{.ALI} files) and + source files. You can provide several -I qualifiers on the command line, + and the directories will be parsed in the order of the command line. + + @item -o @var{dir} + @cindex @code{-o} (@code{gnathtml}) + Specify the output directory for html files. By default, gnathtml will + saved the generated html files in a subdirectory named @file{html/}. + + @item -p @var{file} + @cindex @code{-p} (@code{gnathtml}) + If you are using EMACS and the most recent EMACS Ada mode, which provides + a full Integrated Development Environment for compiling, checking, + running and debugging applications, you may be using @file{.adp} files + to give the directories where EMACS can find sources and object files. + + Using this qualifier, you can tell gnathtml to use these files. This allows + you to get an html version of your application, even if it is spread + over multiple directories. + + @item -sc @var{color} + @cindex @code{-sc} (@code{gnathtml}) + This option allows you to change the color used for symbol definitions. + The default value is red. The color argument can be any name accepted by html. + + @item -t @var{file} + @cindex @code{-t} (@code{gnathtml}) + This qualifier provides the name of a file. This file contains a list of + file names to be converted, and the effect is exactly as though they had + appeared explicitly on the command line. This + is the recommended way to work around the command line length limit on some + systems. + + @end table + + @node Installing gnathtml + @section Installing @code{gnathtml} + + @noindent + @code{Perl} needs to be installed on your machine to run this script. + @code{Perl} is freely available for almost every architecture and + Operating System via the Internet. + + On Unix systems, you may want to modify the first line of the script + @code{gnathtml}, to explicitly tell the Operating system where Perl + is. The syntax of this line is : + @smallexample + #!full_path_name_to_perl + @end smallexample + + @noindent + Alternatively, you may run the script using the following command line: + + @smallexample + $ perl gnathtml.pl [qualifiers] files + @end smallexample + + @node LSE + @section LSE + @findex LSE + + @noindent + The GNAT distribution provides an Ada 95 template for the Digital Language + Sensitive Editor (LSE), a component of DECset. In order to + access it, invoke LSE with the qualifier /ENVIRONMENT=GNU:[LIB]ADA95.ENV. + + @node Profiling + @section Profiling + @findex PCA + + @noindent + GNAT supports The Digital Performance Coverage Analyzer (PCA), a component + of DECset. To use it proceed as outlined under "HELP PCA", except for running + the collection phase with the /DEBUG qualifier. + + @smallexample + $ GNAT MAKE /DEBUG + $ DEFINE LIB$DEBUG PCA$COLLECTOR + $ RUN/DEBUG + @end smallexample + @noindent + + @node Running and Debugging Ada Programs + @chapter Running and Debugging Ada Programs + @cindex Debugging + + @noindent + This chapter discusses how to debug Ada programs. An incorrect Ada program + may be handled in three ways by the GNAT compiler: + + @enumerate + @item + The illegality may be a violation of the static semantics of Ada. In + that case GNAT diagnoses the constructs in the program that are illegal. + It is then a straightforward matter for the user to modify those parts of + the program. + + @item + The illegality may be a violation of the dynamic semantics of Ada. In + that case the program compiles and executes, but may generate incorrect + results, or may terminate abnormally with some exception. + + @item + When presented with a program that contains convoluted errors, GNAT + itself may terminate abnormally without providing full diagnostics on + the incorrect user program. + @end enumerate + + @menu + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + @end menu + + @cindex Debugger + @findex GDB + + @node The GNAT Debugger GDB + @section The GNAT Debugger GDB + + @noindent + @code{GDB} is a general purpose, platform-independent debugger that + can be used to debug mixed-language programs compiled with @code{GCC}, + and in particular is capable of debugging Ada programs compiled with + GNAT. The latest versions of @code{GDB} are Ada-aware and can handle + complex Ada data structures. + + The manual @cite{Debugging with GDB} + , located in the GNU:[DOCS] directory, + contains full details on the usage of @code{GDB}, including a section on + its usage on programs. This manual should be consulted for full + details. The section that follows is a brief introduction to the + philosophy and use of @code{GDB}. + + When GNAT programs are compiled, the compiler optionally writes debugging + information into the generated object file, including information on + line numbers, and on declared types and variables. This information is + separate from the generated code. It makes the object files considerably + larger, but it does not add to the size of the actual executable that + will be loaded into memory, and has no impact on run-time performance. The + generation of debug information is triggered by the use of the + /DEBUG qualifier in the GNAT COMPILE or GNAT MAKE command used to carry out + the compilations. It is important to emphasize that the use of these + options does not change the generated code. + + The debugging information is written in standard system formats that + are used by many tools, including debuggers and profilers. The format + of the information is typically designed to describe C types and + semantics, but GNAT implements a translation scheme which allows full + details about Ada types and variables to be encoded into these + standard C formats. Details of this encoding scheme may be found in + the file EXP_DBUG.ADS in the GNAT source distribution. However, the + details of this encoding are, in general, of no interest to a user, + since @code{GDB} automatically performs the necessary decoding. + + When a program is bound and linked, the debugging information is + collected from the object files, and stored in the executable image of + the program. Again, this process significantly increases the size of + the generated executable file, but it does not increase the size of + the executable program itself. Furthermore, if this program is run in + the normal manner, it runs exactly as if the debug information were + not present, and takes no more actual memory. + + However, if the program is run under control of @code{GDB}, the + debugger is activated. The image of the program is loaded, at which + point it is ready to run. If a run command is given, then the program + will run exactly as it would have if @code{GDB} were not present. This + is a crucial part of the @code{GDB} design philosophy. @code{GDB} is + entirely non-intrusive until a breakpoint is encountered. If no + breakpoint is ever hit, the program will run exactly as it would if no + debugger were present. When a breakpoint is hit, @code{GDB} accesses + the debugging information and can respond to user commands to inspect + variables, and more generally to report on the state of execution. + + @node Running GDB + @section Running GDB + + @noindent + The debugger can be launched directly and simply from @code{glide} or + through its graphical interface: @code{gvd}. It can also be used + directly in text mode. Here is described the basic use of @code{GDB} + in text mode. All the commands described below can be used in the + @code{gvd} console window eventhough there is usually other more + graphical ways to achieve the same goals. + + + @noindent + The command to run @code{GDB} in text mode is + + @smallexample + $ $ GDB PROGRAM + @end smallexample + + @noindent + where @code{PROGRAM} is the name of the executable file. This + activates the debugger and results in a prompt for debugger commands. + The simplest command is simply @code{run}, which causes the program to run + exactly as if the debugger were not present. The following section + describes some of the additional commands that can be given to @code{GDB}. + + + @node Introduction to GDB Commands + @section Introduction to GDB Commands + + @noindent + @code{GDB} contains a large repertoire of commands. The manual + @cite{Debugging with GDB} + , located in the GNU:[DOCS] directory, + includes extensive documentation on the use + of these commands, together with examples of their use. Furthermore, + the command @var{help} invoked from within @code{GDB} activates a simple help + facility which summarizes the available commands and their options. + In this section we summarize a few of the most commonly + used commands to give an idea of what @code{GDB} is about. You should create + a simple program with debugging information and experiment with the use of + these @code{GDB} commands on the program as you read through the + following section. + + @table @code + @item set args @var{arguments} + The @var{arguments} list above is a list of arguments to be passed to + the program on a subsequent run command, just as though the arguments + had been entered on a normal invocation of the program. The @code{set args} + command is not needed if the program does not require arguments. + + @item run + The @code{run} command causes execution of the program to start from + the beginning. If the program is already running, that is to say if + you are currently positioned at a breakpoint, then a prompt will ask + for confirmation that you want to abandon the current execution and + restart. + + @item breakpoint @var{location} + The breakpoint command sets a breakpoint, that is to say a point at which + execution will halt and @code{GDB} will await further + commands. @var{location} is + either a line number within a file, given in the format @code{file:linenumber}, + or it is the name of a subprogram. If you request that a breakpoint be set on + a subprogram that is overloaded, a prompt will ask you to specify on which of + those subprograms you want to breakpoint. You can also + specify that all of them should be breakpointed. If the program is run + and execution encounters the breakpoint, then the program + stops and @code{GDB} signals that the breakpoint was encountered by + printing the line of code before which the program is halted. + + @item breakpoint exception @var{name} + A special form of the breakpoint command which breakpoints whenever + exception @var{name} is raised. + If @var{name} is omitted, + then a breakpoint will occur when any exception is raised. + + @item print @var{expression} + This will print the value of the given expression. Most simple + Ada expression formats are properly handled by @code{GDB}, so the expression + can contain function calls, variables, operators, and attribute references. + + @item continue + Continues execution following a breakpoint, until the next breakpoint or the + termination of the program. + + @item step + Executes a single line after a breakpoint. If the next statement is a subprogram + call, execution continues into (the first statement of) the + called subprogram. + + @item next + Executes a single line. If this line is a subprogram call, executes and + returns from the call. + + @item list + Lists a few lines around the current source location. In practice, it + is usually more convenient to have a separate edit window open with the + relevant source file displayed. Successive applications of this command + print subsequent lines. The command can be given an argument which is a + line number, in which case it displays a few lines around the specified one. + + @item backtrace + Displays a backtrace of the call chain. This command is typically + used after a breakpoint has occurred, to examine the sequence of calls that + leads to the current breakpoint. The display includes one line for each + activation record (frame) corresponding to an active subprogram. + + @item up + At a breakpoint, @code{GDB} can display the values of variables local + to the current frame. The command @code{up} can be used to + examine the contents of other active frames, by moving the focus up + the stack, that is to say from callee to caller, one frame at a time. + + @item down + Moves the focus of @code{GDB} down from the frame currently being + examined to the frame of its callee (the reverse of the previous command), + + @item frame @var{n} + Inspect the frame with the given number. The value 0 denotes the frame + of the current breakpoint, that is to say the top of the call stack. + + @end table + + The above list is a very short introduction to the commands that + @code{GDB} provides. Important additional capabilities, including conditional + breakpoints, the ability to execute command sequences on a breakpoint, + the ability to debug at the machine instruction level and many other + features are described in detail in @cite{Debugging with GDB}. + Note that most commands can be abbreviated + (for example, c for continue, bt for backtrace). + + @node Using Ada Expressions + @section Using Ada Expressions + @cindex Ada expressions + + @noindent + @code{GDB} supports a fairly large subset of Ada expression syntax, with some + extensions. The philosophy behind the design of this subset is + + @itemize @bullet + @item + That @code{GDB} should provide basic literals and access to operations for + arithmetic, dereferencing, field selection, indexing, and subprogram calls, + leaving more sophisticated computations to subprograms written into the + program (which therefore may be called from @code{GDB}). + + @item + That type safety and strict adherence to Ada language restrictions + are not particularly important to the @code{GDB} user. + + @item + That brevity is important to the @code{GDB} user. + @end itemize + + Thus, for brevity, the debugger acts as if there were + implicit @code{with} and @code{use} clauses in effect for all user-written + packages, thus making it unnecessary to fully qualify most names with + their packages, regardless of context. Where this causes ambiguity, + @code{GDB} asks the user's intent. + + For details on the supported Ada syntax, see @cite{Debugging with GDB}. + + @node Calling User-Defined Subprograms + @section Calling User-Defined Subprograms + + @noindent + An important capability of @code{GDB} is the ability to call user-defined + subprograms while debugging. This is achieved simply by entering + a subprogram call statement in the form: + + @smallexample + call subprogram-name (parameters) + @end smallexample + + @noindent + The keyword @code{call} can be omitted in the normal case where the + @code{subprogram-name} does not coincide with any of the predefined + @code{GDB} commands. + + The effect is to invoke the given subprogram, passing it the + list of parameters that is supplied. The parameters can be expressions and + can include variables from the program being debugged. The + subprogram must be defined + at the library level within your program, and @code{GDB} will call the + subprogram within the environment of your program execution (which + means that the subprogram is free to access or even modify variables + within your program). + + The most important use of this facility is in allowing the inclusion of + debugging routines that are tailored to particular data structures + in your program. Such debugging routines can be written to provide a suitably + high-level description of an abstract type, rather than a low-level dump + of its physical layout. After all, the standard + @code{GDB print} command only knows the physical layout of your + types, not their abstract meaning. Debugging routines can provide information + at the desired semantic level and are thus enormously useful. + + For example, when debugging GNAT itself, it is crucial to have access to + the contents of the tree nodes used to represent the program internally. + But tree nodes are represented simply by an integer value (which in turn + is an index into a table of nodes). + Using the @code{print} command on a tree node would simply print this integer + value, which is not very useful. But the PN routine (defined in file + TREEPR.ADB in the GNAT sources) takes a tree node as input, and displays + a useful high level representation of the tree node, which includes the + syntactic category of the node, its position in the source, the integers + that denote descendant nodes and parent node, as well as varied + semantic information. To study this example in more detail, you might want to + look at the body of the PN procedure in the stated file. + + @node Using the Next Command in a Function + @section Using the Next Command in a Function + + @noindent + When you use the @code{next} command in a function, the current source + location will advance to the next statement as usual. A special case + arises in the case of a @code{return} statement. + + Part of the code for a return statement is the "epilog" of the function. + This is the code that returns to the caller. There is only one copy of + this epilog code, and it is typically associated with the last return + statement in the function if there is more than one return. In some + implementations, this epilog is associated with the first statement + of the function. + + The result is that if you use the @code{next} command from a return + statement that is not the last return statement of the function you + may see a strange apparent jump to the last return statement or to + the start of the function. You should simply ignore this odd jump. + The value returned is always that from the first return statement + that was stepped through. + + @node Ada Exceptions + @section Breaking on Ada Exceptions + @cindex Exceptions + + @noindent + You can set breakpoints that trip when your program raises + selected exceptions. + + @table @code + @item break exception + Set a breakpoint that trips whenever (any task in the) program raises + any exception. + + @item break exception @var{name} + Set a breakpoint that trips whenever (any task in the) program raises + the exception @var{name}. + + @item break exception unhandled + Set a breakpoint that trips whenever (any task in the) program raises an + exception for which there is no handler. + + @item info exceptions + @itemx info exceptions @var{regexp} + The @code{info exceptions} command permits the user to examine all defined + exceptions within Ada programs. With a regular expression, @var{regexp}, as + argument, prints out only those exceptions whose name matches @var{regexp}. + @end table + + @node Ada Tasks + @section Ada Tasks + @cindex Tasks + + @noindent + @code{GDB} allows the following task-related commands: + + @table @code + @item info tasks + This command shows a list of current Ada tasks, as in the following example: + + @smallexample + @iftex + @leftskip=0cm + @end iftex + (GDB) info tasks + ID TID P-ID Thread Pri State Name + 1 8088000 0 807e000 15 Child Activation Wait main_task + 2 80a4000 1 80ae000 15 Accept/Select Wait b + 3 809a800 1 80a4800 15 Child Activation Wait a + * 4 80ae800 3 80b8000 15 Running c + @end smallexample + + @noindent + In this listing, the asterisk before the first task indicates it to be the + currently running task. The first column lists the task ID that is used + to refer to tasks in the following commands. + + @item break @var{linespec} task @var{taskid} + @itemx break @var{linespec} task @var{taskid} if @dots{} + @cindex Breakpoints and tasks + These commands are like the @code{break @dots{} thread @dots{}}. + @var{linespec} specifies source lines. + + Use the qualifier @samp{task @var{taskid}} with a breakpoint command + to specify that you only want @code{GDB} to stop the program when a + particular Ada task reaches this breakpoint. @var{taskid} is one of the + numeric task identifiers assigned by @code{GDB}, shown in the first + column of the @samp{info tasks} display. + + If you do not specify @samp{task @var{taskid}} when you set a + breakpoint, the breakpoint applies to @emph{all} tasks of your + program. + + You can use the @code{task} qualifier on conditional breakpoints as + well; in this case, place @samp{task @var{taskid}} before the + breakpoint condition (before the @code{if}). + + @item task @var{taskno} + @cindex Task switching + + This command allows to qualifier to the task referred by @var{taskno}. In + particular, This allows to browse the backtrace of the specified + task. It is advised to qualifier back to the original task before + continuing execution otherwise the scheduling of the program may be + perturbated. + @end table + + @noindent + For more detailed information on the tasking support, see @cite{Debugging with GDB}. + + @node Debugging Generic Units + @section Debugging Generic Units + @cindex Debugging Generic Units + @cindex Generics + + @noindent + GNAT always uses code expansion for generic instantiation. This means that + each time an instantiation occurs, a complete copy of the original code is + made, with appropriate substitutions of formals by actuals. + + It is not possible to refer to the original generic entities in + @code{GDB}, but it is always possible to debug a particular instance of + a generic, by using the appropriate expanded names. For example, if we have + + @smallexample + @group + @cartouche + @b{procedure} g @b{is} + + @b{generic package} k @b{is} + @b{procedure} kp (v1 : @b{in out} integer); + @b{end} k; + + @b{package body} k @b{is} + @b{procedure} kp (v1 : @b{in out} integer) @b{is} + @b{begin} + v1 := v1 + 1; + @b{end} kp; + @b{end} k; + + @b{package} k1 @b{is new} k; + @b{package} k2 @b{is new} k; + + var : integer := 1; + + @b{begin} + k1.kp (var); + k2.kp (var); + k1.kp (var); + k2.kp (var); + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + Then to break on a call to procedure kp in the k2 instance, simply + use the command: + + @smallexample + (GDB) break g.k2.kp + @end smallexample + + @noindent + When the breakpoint occurs, you can step through the code of the + instance in the normal manner and examine the values of local variables, as for + other units. + + @node GNAT Abnormal Termination or Failure to Terminate + @section GNAT Abnormal Termination or Failure to Terminate + @cindex GNAT Abnormal Termination or Failure to Terminate + + @noindent + When presented with programs that contain serious errors in syntax + or semantics, + GNAT may on rare occasions experience problems in operation, such + as aborting with a + segmentation fault or illegal memory access, raising an internal + exception, terminating abnormally, or failing to terminate at all. + In such cases, you can activate + various features of GNAT that can help you pinpoint the construct in your + program that is the likely source of the problem. + + The following strategies are presented in increasing order of + difficulty, corresponding to your experience in using GNAT and your + familiarity with compiler internals. + + @enumerate + @item + Run @code{GNAT COMPILE} with the @option{/REPORT_ERRORS=FULL}. This first + qualifier causes all errors on a given line to be reported. In its absence, + only the first error on a line is displayed. + + The @option{/REPORT_ERRORS=IMMEDIATE} qualifier causes errors to be displayed as soon as they + are encountered, rather than after compilation is terminated. If GNAT + terminates prematurely or goes into an infinite loop, the last error + message displayed may help to pinpoint the culprit. + + @item + Run @code{GNAT COMPILE} with the @code{/VERBOSE} qualifier. In this mode, + @code{GNAT COMPILE} produces ongoing information about the progress of the + compilation and provides the name of each procedure as code is + generated. This qualifier allows you to find which Ada procedure was being + compiled when it encountered a code generation problem. + + @item + @cindex @option{/TRACE_UNITS} qualifier + Run @code{GNAT COMPILE} with the @option{/TRACE_UNITS} qualifier. This is a GNAT specific + qualifier that does for the front-end what @code{VERBOSE} does for the back end. + The system prints the name of each unit, either a compilation unit or + nested unit, as it is being analyzed. + @item + Finally, you can start + @code{GDB} directly on the @code{GNAT1} executable. @code{GNAT1} is the + front-end of GNAT, and can be run independently (normally it is just + called from @code{GNAT COMPILE}). You can use @code{GDB} on @code{GNAT1} as you + would on a C program (but @pxref{The GNAT Debugger GDB} for caveats). The + @code{where} command is the first line of attack; the variable + @code{lineno} (seen by @code{print lineno}), used by the second phase of + @code{GNAT1} and by the @code{GNAT COMPILE} backend, indicates the source line at + which the execution stopped, and @code{input_file name} indicates the name of + the source file. + @end enumerate + + @node Naming Conventions for GNAT Source Files + @section Naming Conventions for GNAT Source Files + + @noindent + In order to examine the workings of the GNAT system, the following + brief description of its organization may be helpful: + + @itemize @bullet + @item + Files with prefix @file{SC} contain the lexical scanner. + + @item + All files prefixed with @file{PAR} are components of the parser. The + numbers correspond to chapters of the Ada 95 Reference Manual. For example, + parsing of select statements can be found in @file{PAR-CH9.ADB}. + + @item + All files prefixed with @file{SEM} perform semantic analysis. The + numbers correspond to chapters of the Ada standard. For example, all + issues involving context clauses can be found in @file{SEM_CH10.ADB}. In + addition, some features of the language require sufficient special processing + to justify their own semantic files: sem_aggr for aggregates, sem_disp for + dynamic dispatching, etc. + + @item + All files prefixed with @file{EXP} perform normalization and + expansion of the intermediate representation (abstract syntax tree, or AST). + these files use the same numbering scheme as the parser and semantics files. + For example, the construction of record initialization procedures is done in + @file{EXP_CH3.ADB}. + + @item + The files prefixed with @file{BIND} implement the binder, which + verifies the consistency of the compilation, determines an order of + elaboration, and generates the bind file. + + @item + The files @file{ATREE.ADS} and @file{ATREE.ADB} detail the low-level + data structures used by the front-end. + + @item + The files @file{SINFO.ADS} and @file{SINFO.ADB} detail the structure of + the abstract syntax tree as produced by the parser. + + @item + The files @file{EINFO.ADS} and @file{EINFO.ADB} detail the attributes of + all entities, computed during semantic analysis. + + @item + Library management issues are dealt with in files with prefix + @file{LIB}. + + @item + @findex Ada + @cindex Annex A + Ada files with the prefix @file{A-} are children of @code{Ada}, as + defined in Annex A. + + @item + @findex Interfaces + @cindex Annex B + Files with prefix @file{I-} are children of @code{Interfaces}, as + defined in Annex B. + + @item + @findex System + Files with prefix @file{S-} are children of @code{System}. This includes + both language-defined children and GNAT run-time routines. + + @item + @findex GNAT + Files with prefix @file{G-} are children of @code{GNAT}. These are useful + general-purpose packages, fully documented in their specifications. All + the other @file{.C} files are modifications of common @code{GNAT COMPILE} files. + @end itemize + + @node Getting Internal Debugging Information + @section Getting Internal Debugging Information + + @noindent + Most compilers have internal debugging qualifiers and modes. GNAT + does also, except GNAT internal debugging qualifiers and modes are not + secret. A summary and full description of all the compiler and binder + debug flags are in the file @file{DEBUG.ADB}. You must obtain the + sources of the compiler to see the full detailed effects of these flags. + + The qualifiers that print the source of the program (reconstructed from + the internal tree) are of general interest for user programs, as are the + options to print + the full internal tree, and the entity table (the symbol table + information). The reconstructed source provides a readable version of the + program after the front-end has completed analysis and expansion, and is useful + when studying the performance of specific constructs. For example, constraint + checks are indicated, complex aggregates are replaced with loops and + assignments, and tasking primitives are replaced with run-time calls. + + @node Stack Traceback + @section Stack Traceback + @cindex traceback + @cindex stack traceback + @cindex stack unwinding + + @noindent + Traceback is a mechanism to display the sequence of subprogram calls that + leads to a specified execution point in a program. Often (but not always) + the execution point is an instruction at which an exception has been raised. + This mechanism is also known as @i{stack unwinding} because it obtains + its information by scanning the run-time stack and recovering the activation + records of all active subprograms. Stack unwinding is one of the most + important tools for program debugging. + + @noindent + The first entry stored in traceback corresponds to the deepest calling level, + that is to say the subprogram currently executing the instruction + from which we want to obtain the traceback. + + @noindent + Note that there is no runtime performance penalty when stack traceback + is enabled and no exception are raised during program execution. + + @menu + * Non-Symbolic Traceback:: + * Symbolic Traceback:: + @end menu + + @node Non-Symbolic Traceback + @subsection Non-Symbolic Traceback + @cindex traceback, non-symbolic + + @noindent + Note: this feature is not supported on all platforms. See + @file{GNAT.Traceback spec in G-TRACEB.ADS} for a complete list of supported + platforms. + + @menu + * Tracebacks From an Unhandled Exception:: + * Tracebacks From Exception Occurrences (non-symbolic):: + * Tracebacks From Anywhere in a Program (non-symbolic):: + @end menu + + @node Tracebacks From an Unhandled Exception + @subsubsection Tracebacks From an Unhandled Exception + + @noindent + A runtime non-symbolic traceback is a list of addresses of call instructions. + To enable this feature you must use the @code{-E} + @code{GNAT BIND}'s option. With this option a stack traceback is stored as part + of exception information. It is possible to retrieve this information using the + standard @code{Ada.Exception.Exception_Information} routine. + + @noindent + Let's have a look at a simple example: + + @smallexample + @cartouche + @group + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ GNAT MAKE stb /BINDER_QUALIFIERS -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: STB.ADB:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + @end smallexample + + @noindent + As we see the traceback lists a sequence of addresses for the unhandled + exception @code{CONSTAINT_ERROR} raised in procedure P1. It is easy to + guess that this exception come from procedure P1. To translate these + addresses into the source lines where the calls appear, the + @code{addr2line} tool, described below, is invaluable. The use of this tool + requires the program to be compiled with debug information. + + @smallexample + $ GNAT MAKE -g stb /BINDER_QUALIFIERS -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: STB.ADB:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + $ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 + 0x4011f1 0x77e892a4 + + 00401373 at d:/stb/STB.ADB:5 + 0040138B at d:/stb/STB.ADB:10 + 0040139C at d:/stb/STB.ADB:14 + 00401335 at d:/stb/B~STB.ADB:104 + 004011C4 at /build/.../CRT1.C:200 + 004011F1 at /build/.../CRT1.C:222 + 77E892A4 in ?? at ??:0 + @end smallexample + + @noindent + @code{addr2line} has a number of other useful options: + + @table @code + @item --functions + to get the function name corresponding to any location + + @item --demangle=gnat + to use the @b{gnat} decoding mode for the function names. Note that + for binutils version 2.9.x the option is simply @code{--demangle}. + @end table + + @smallexample + $ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b + 0x40139c 0x401335 0x4011c4 0x4011f1 + + 00401373 in stb.p1 at d:/stb/STB.ADB:5 + 0040138B in stb.p2 at d:/stb/STB.ADB:10 + 0040139C in stb at d:/stb/STB.ADB:14 + 00401335 in main at d:/stb/B~STB.ADB:104 + 004011C4 in <__mingw_CRTStartup> at /build/.../CRT1.C:200 + 004011F1 in at /build/.../CRT1.C:222 + @end smallexample + + @noindent + From this traceback we can see that the exception was raised in + @file{STB.ADB} at line 5, which was reached from a procedure call in + @file{STB.ADB} at line 10, and so on. The @file{B~STD.ADB} is the binder file, + which contains the call to the main program. + @pxref{Running GNAT BIND}. The remaining entries are assorted runtime routines, + and the output will vary from platform to platform. + + @noindent + It is also possible to use @code{GDB} with these traceback addresses to debug + the program. For example, we can break at a given code location, as reported + in the stack traceback: + + @smallexample + $ GDB -nw stb + + (GDB) break *0x401373 + Breakpoint 1 at 0x401373: file STB.ADB, line 5. + @end smallexample + + @noindent + It is important to note that the stack traceback addresses + do not change when debug information is included. This is particularly useful + because it makes it possible to release software without debug information (to + minimize object size), get a field report that includes a stack traceback + whenever an internal bug occurs, and then be able to retrieve the sequence + of calls with the same program compiled with debug information. + + @node Tracebacks From Exception Occurrences (non-symbolic) + @subsubsection Tracebacks From Exception Occurrences + + @noindent + Non-symbolic tracebacks are obtained by using the @code{-E} binder argument. + The stack traceback is attached to the exception information string, and can + be retrieved in an exception handler within the Ada program, by means of the + Ada95 facilities defined in @code{Ada.Exceptions}. Here is a simple example: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with Ada.Exceptions; + + procedure STB is + + use Ada; + use Ada.Exceptions; + + procedure P1 is + K : Positive := 1; + begin + K := K - 1; + exception + when E : others => + Text_IO.Put_Line (Exception_Information (E)); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @noindent + This program will output: + + @smallexample + $ stb + + Exception name: CONSTRAINT_ERROR + Message: STB.ADB:12 + Call stack traceback locations: + 0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4 + @end smallexample + + @node Tracebacks From Anywhere in a Program (non-symbolic) + @subsubsection Tracebacks From Anywhere in a Program + + @noindent + It is also possible to retrieve a stack traceback from anywhere in a + program. For this you need to + use the @code{GNAT.Traceback} API. This package includes a procedure called + @code{Call_Chain} that computes a complete stack traceback, as well as useful + display procedures described below. It is not necessary to use the + @code{-E GNAT BIND} option in this case, because the stack traceback mechanism + is invoked explicitly. + + @noindent + In the following example we compute a traceback at a specific location in + the program, and we display it using @code{GNAT.Debug_Utilities.Image} to + convert addresses to strings: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Debug_Utilities; + + procedure STB is + + use Ada; + use GNAT; + use GNAT.Traceback; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + + Text_IO.Put ("In STB.P1 : "); + + for K in 1 .. Len loop + Text_IO.Put (Debug_Utilities.Image (TB (K))); + Text_IO.Put (' '); + end loop; + + Text_IO.New_Line; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ GNAT MAKE stb + $ stb + + In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C# + 16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4# + @end smallexample + + @node Symbolic Traceback + @subsection Symbolic Traceback + @cindex traceback, symbolic + + @noindent + A symbolic traceback is a stack traceback in which procedure names are + associated with each code location. + + @noindent + Note that this feature is not supported on all platforms. See + @file{GNAT.Traceback.Symbolic spec in G-TRASYM.ADS} for a complete + list of currently supported platforms. + + @noindent + Note that the symbolic traceback requires that the program be compiled + with debug information. If it is not compiled with debug information + only the non-symbolic information will be valid. + + @menu + * Tracebacks From Exception Occurrences (symbolic):: + * Tracebacks From Anywhere in a Program (symbolic):: + @end menu + + @node Tracebacks From Exception Occurrences (symbolic) + @subsubsection Tracebacks From Exception Occurrences + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback.Symbolic; + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + procedure P3 is + begin + P2; + end P3; + + begin + P3; + exception + when E : others => + Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ GNAT MAKE -g stb /BINDER_QUALIFIERS -E /LINKER_QUALIFIERS -lgnat -laddr2line -lintl + $ stb + + 0040149F in stb.p1 at STB.ADB:8 + 004014B7 in stb.p2 at STB.ADB:13 + 004014CF in stb.p3 at STB.ADB:18 + 004015DD in ada.stb at STB.ADB:22 + 00401461 in main at B~STB.ADB:168 + 004011C4 in __mingw_CRTStartup at CRT1.C:200 + 004011F1 in mainCRTStartup at CRT1.C:222 + 77E892A4 in ?? at ??:0 + @end smallexample + + @noindent + The exact sequence of linker options may vary from platform to platform. + The above @code{/LINKER_QUALIFIERS} section is for Windows platforms. By contrast, + under Unix there is no need for the @code{/LINKER_QUALIFIERS} section. + Differences across platforms are due to details of linker implementation. + + @node Tracebacks From Anywhere in a Program (symbolic) + @subsubsection Tracebacks From Anywhere in a Program + + @noindent + It is possible to get a symbolic stack traceback + from anywhere in a program, just as for non-symbolic tracebacks. + The first step is to obtain a non-symbolic + traceback, and then call @code{Symbolic_Traceback} to compute the symbolic + information. Here is an example: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Traceback.Symbolic; + + procedure STB is + + use Ada; + use GNAT.Traceback; + use GNAT.Traceback.Symbolic; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len))); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @node Compatibility with DEC Ada + @chapter Compatibility with DEC Ada + @cindex Compatibility + + @noindent + This section of the manual compares DEC Ada for OpenVMS Alpha and GNAT + OpenVMS Alpha. GNAT achieves a high level of compatibility + with DEC Ada, and it should generally be straightforward to port code + from the DEC Ada environment to GNAT. However, there are a few language + and implementation differences of which the user must be aware. These + differences are discussed in this section. In + addition, the operating environment and command structure for the + compiler are different, and these differences are also discussed. + + Note that this discussion addresses specifically the implementation + of Ada 83 for DIGITAL OpenVMS Alpha Systems. In cases where the implementation + of DEC Ada differs between OpenVMS Alpha Systems and OpenVMS VAX Systems, GNAT + always follows the Alpha implementation. + + @menu + * Ada 95 Compatibility:: + * Differences in the Definition of Package System:: + * Language-Related Features:: + * The Package STANDARD:: + * The Package SYSTEM:: + * Tasking and Task-Related Features:: + * Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems:: + * Pragmas and Pragma-Related Features:: + * Library of Predefined Units:: + * Bindings:: + * Main Program Definition:: + * Implementation-Defined Attributes:: + * Compiler and Run-Time Interfacing:: + * Program Compilation and Library Management:: + * Input-Output:: + * Implementation Limits:: + * Tools:: + @end menu + + @node Ada 95 Compatibility + @section Ada 95 Compatibility + + @noindent + GNAT is an Ada 95 compiler, and DEC Ada is an Ada 83 + compiler. Ada 95 is almost completely upwards compatible + with Ada 83, and therefore Ada 83 programs will compile + and run under GNAT with + no changes or only minor changes. The Ada 95 Reference + Manual (ANSI/ISO/IEC-8652:1995) provides details on specific + incompatibilities. + + GNAT provides the qualifier /83 on the GNAT COMPILE command, + as well as the pragma ADA_83, to force the compiler to + operate in Ada 83 mode. This mode does not guarantee complete + conformance to Ada 83, but in practice is sufficient to + eliminate most sources of incompatibilities. + In particular, it eliminates the recognition of the + additional Ada 95 keywords, so that their use as identifiers + in Ada83 program is legal, and handles the cases of packages + with optional bodies, and generics that instantiate unconstrained + types without the use of @code{(<>)}. + + @node Differences in the Definition of Package System + @section Differences in the Definition of Package System + + @noindent + Both the Ada 95 and Ada 83 reference manuals permit a compiler to add + implementation-dependent declarations to package System. In normal mode, + GNAT does not take advantage of this permission, and the version of System + provided by GNAT exactly matches that in the Ada 95 Reference Manual. + + However, DEC Ada adds an extensive set of declarations to package System, + as fully documented in the DEC Ada manuals. To minimize changes required + for programs that make use of these extensions, GNAT provides the pragma + Extend_System for extending the definition of package System. By using: + + @smallexample + @group + @cartouche + @b{pragma} Extend_System (Aux_DEC); + @end cartouche + @end group + @end smallexample + + @noindent + The set of definitions in System is extended to include those in package + @code{System.Aux_DEC}. + These definitions are incorporated directly into package + System, as though they had been declared there in the first place. For a + list of the declarations added, see the specification of this package, + which can be found in the file @code{S-AUXDEC.ADS} in the GNAT library. + The pragma Extend_System is a configuration pragma, which means that + it can be placed in the file @file{GNAT.ADC}, so that it will automatically + apply to all subsequent compilations. See the section on Configuration + Pragmas for further details. + + An alternative approach that avoids the use of the non-standard + Extend_System pragma is to add a context clause to the unit that + references these facilities: + + @smallexample + @group + @cartouche + @b{with} System.Aux_DEC; + @b{use} System.Aux_DEC; + @end cartouche + @end group + @end smallexample + + @noindent + The effect is not quite semantically identical to incorporating the declarations + directly into package @code{System}, + but most programs will not notice a difference + unless they use prefix notation (e.g. @code{System.Integer_8}) + to reference the + entities directly in package @code{System}. + For units containing such references, + the prefixes must either be removed, or the pragma @code{Extend_System} + must be used. + + @node Language-Related Features + @section Language-Related Features + + @noindent + The following sections highlight differences in types, + representations of types, operations, alignment, and + related topics. + + @menu + * Integer Types and Representations:: + * Floating-Point Types and Representations:: + * Pragmas Float_Representation and Long_Float:: + * Fixed-Point Types and Representations:: + * Record and Array Component Alignment:: + * Address Clauses:: + * Other Representation Clauses:: + @end menu + + @node Integer Types and Representations + @subsection Integer Types and Representations + + @noindent + The set of predefined integer types is identical in DEC Ada and GNAT. + Furthermore the representation of these integer types is also identical, + including the capability of size clauses forcing biased representation. + + In addition, + DEC Ada for OpenVMS Alpha systems has defined the + following additional integer types in package System: + + @itemize @bullet + + @item + INTEGER_8 + + @item + INTEGER_16 + + @item + INTEGER_32 + + @item + INTEGER_64 + + @item + LARGEST_INTEGER + @end itemize + + @noindent + When using GNAT, the first four of these types may be obtained from the + standard Ada 95 package @code{Interfaces}. + Alternatively, by use of the pragma + @code{Extend_System}, identical + declarations can be referenced directly in package @code{System}. + On both GNAT and DEC Ada, the maximum integer size is 64 bits. + + @node Floating-Point Types and Representations + @subsection Floating-Point Types and Representations + @cindex Floating-Point types + + @noindent + The set of predefined floating-point types is identical in DEC Ada and GNAT. + Furthermore the representation of these floating-point + types is also identical. One important difference is that the default + representation for DEC Ada is VAX_Float, but the default representation + for GNAT is IEEE. + + Specific types may be declared to be VAX_Float or IEEE, using the pragma + @code{Float_Representation} as described in the DEC Ada documentation. + For example, the declarations: + + @smallexample + @group + @cartouche + @b{type} F_Float @b{is digits} 6; + @b{pragma} Float_Representation (VAX_Float, F_Float); + @end cartouche + @end group + @end smallexample + + @noindent + declare a type F_Float that will be represented in VAX_Float format. + This set of declarations actually appears in System.Aux_DEC, which provides + the full set of additional floating-point declarations provided in + the DEC Ada version of package + System. This and similar declarations may be accessed in a user program by using + pragma @code{Extend_System}. The use of this + pragma, and the related pragma @code{Long_Float} is described in further + detail in the following section. + + @node Pragmas Float_Representation and Long_Float + @subsection Pragmas Float_Representation and Long_Float + + @noindent + DEC Ada provides the pragma @code{Float_Representation}, which + acts as a program library qualifier to allow control over + the internal representation chosen for the predefined + floating-point types declared in the package @code{Standard}. + The format of this pragma is as follows: + + @smallexample + @group + @cartouche + @b{pragma} @code{Float_Representation}(VAX_Float | IEEE_Float); + @end cartouche + @end group + @end smallexample + + @noindent + This pragma controls the representation of floating-point + types as follows: + + @itemize @bullet + @item + @code{VAX_Float} specifies that floating-point + types are represented by default with the VAX hardware types + F-floating, D-floating, G-floating. Note that the H-floating + type is available only on DIGITAL Vax systems, and is not available + in either DEC Ada or GNAT for Alpha systems. + + @item + @code{IEEE_Float} specifies that floating-point + types are represented by default with the IEEE single and + double floating-point types. + @end itemize + + @noindent + GNAT provides an identical implementation of the pragma + @code{Float_Representation}, except that it functions as a + configuration pragma, as defined by Ada 95. Note that the + notion of configuration pragma corresponds closely to the + DEC Ada notion of a program library qualifier. + + When no pragma is used in GNAT, the default is IEEE_Float, which is different + from DEC Ada 83, where the default is VAX_Float. In addition, the + predefined libraries in GNAT are built using IEEE_Float, so it is not + advisable to change the format of numbers passed to standard library + routines, and if necessary explicit type conversions may be needed. + + The use of IEEE_Float is recommended in GNAT since it is more efficient, + and (given that it conforms to an international standard) potentially more + portable. The situation in which VAX_Float may be useful is in interfacing + to existing code and data that expects the use of VAX_Float. There are + two possibilities here. If the requirement for the use of VAX_Float is + localized, then the best approach is to use the predefined VAX_Float + types in package @code{System}, as extended by + @code{Extend_System}. For example, use @code{System.F_Float} + to specify the 32-bit @code{F-Float} format. + + Alternatively, if an entire program depends heavily on the use of + the @code{VAX_Float} and in particular assumes that the types in + package @code{Standard} are in @code{Vax_Float} format, then it + may be desirable to reconfigure GNAT to assume Vax_Float by default. + This is done by using the GNAT LIBRARY command to rebuild the library, and + then using the general form of the @code{Float_Representation} + pragma to ensure that this default format is used throughout. + The form of the GNAT LIBRARY command is: + + @smallexample + GNAT LIBRARY /CONFIG=@i{file} /CREATE=@i{directory} + @end smallexample + + @noindent + where @i{file} contains the new configuration pragmas + and @i{directory} is the directory to be created to contain + the new library. + + @noindent + On OpenVMS systems, DEC Ada provides the pragma @code{Long_Float} + to allow control over the internal representation chosen + for the predefined type @code{Long_Float} and for floating-point + type declarations with digits specified in the range 7 .. 15. + The format of this pragma is as follows: + + @smallexample + @cartouche + @b{pragma} Long_Float (D_FLOAT | G_FLOAT); + @end cartouche + @end smallexample + + @node Fixed-Point Types and Representations + @subsection Fixed-Point Types and Representations + + @noindent + On DEC Ada for OpenVMS Alpha systems, rounding is + away from zero for both positive and negative numbers. + Therefore, +0.5 rounds to 1 and -0.5 rounds to -1. + + On GNAT for OpenVMS Alpha, the results of operations + on fixed-point types are in accordance with the Ada 95 + rules. In particular, results of operations on decimal + fixed-point types are truncated. + + @node Record and Array Component Alignment + @subsection Record and Array Component Alignment + + @noindent + On DEC Ada for OpenVMS Alpha, all non composite components + are aligned on natural boundaries. For example, 1-byte + components are aligned on byte boundaries, 2-byte + components on 2-byte boundaries, 4-byte components on 4-byte + byte boundaries, and so on. The OpenVMS Alpha hardware + runs more efficiently with naturally aligned data. + + ON GNAT for OpenVMS Alpha, alignment rules are compatible + with DEC Ada for OpenVMS Alpha. + + @node Address Clauses + @subsection Address Clauses + + @noindent + In DEC Ada and GNAT, address clauses are supported for + objects and imported subprograms. + The predefined type @code{System.Address} is a private type + in both compilers, with the same representation (it is simply + a machine pointer). Addition, subtraction, and comparison + operations are available in the standard Ada 95 package + @code{System.Storage_Elements}, or in package @code{System} + if it is extended to include @code{System.Aux_DEC} using a + pragma @code{Extend_System} as previously described. + + Note that code that with's both this extended package @code{System} + and the package @code{System.Storage_Elements} should not @code{use} + both packages, or ambiguities will result. In general it is better + not to mix these two sets of facilities. The Ada 95 package was + designed specifically to provide the kind of features that DEC Ada + adds directly to package @code{System}. + + GNAT is compatible with DEC Ada in its handling of address + clauses, except for some limitations in + the form of address clauses for composite objects with + initialization. Such address clauses are easily replaced + by the use of an explicitly-defined constant as described + in the Ada 95 Reference Manual (13.1(22)). For example, the sequence + of declarations: + + @smallexample + @group + @cartouche + X, Y : Integer := Init_Func; + Q : String (X .. Y) := "abc"; + ... + @b{for} Q'Address @b{use} Compute_Address; + @end cartouche + @end group + @end smallexample + + @noindent + will be rejected by GNAT, since the address cannot be computed at the time + that Q is declared. To achieve the intended effect, write instead: + + @smallexample + @group + @cartouche + X, Y : Integer := Init_Func; + Q_Address : @b{constant} Address := Compute_Address; + Q : String (X .. Y) := "abc"; + ... + @b{for} Q'Address @b{use} Q_Address; + @end cartouche + @end group + @end smallexample + + @noindent + which will be accepted by GNAT (and other Ada 95 compilers), and is also + backwards compatible with Ada 83. A fuller description of the restrictions + on address specifications is found in the GNAT Reference Manual. + + @node Other Representation Clauses + @subsection Other Representation Clauses + + @noindent + GNAT supports in a compatible manner all the representation + clauses supported by DEC Ada. In addition, it + supports representation clause forms that are new in Ada 95 + including COMPONENT_SIZE and SIZE clauses for objects. + + @node The Package STANDARD + @section The Package STANDARD + + @noindent + The package STANDARD, as implemented by DEC Ada, is fully + described in the Reference Manual for the Ada Programming + Language (ANSI/MIL-STD-1815A-1983) and in the DEC Ada + Language Reference Manual. As implemented by GNAT, the + package STANDARD is described in the Ada 95 Reference + Manual. + + In addition, DEC Ada supports the Latin-1 character set in + the type CHARACTER. GNAT supports the Latin-1 character set + in the type CHARACTER and also Unicode (ISO 10646 BMP) in + the type WIDE_CHARACTER. + + The floating-point types supported by GNAT are those + supported by DEC Ada, but defaults are different, and are controlled by + pragmas. See @pxref{Floating-Point Types and Representations} for details. + + @node The Package SYSTEM + @section The Package SYSTEM + + @noindent + DEC Ada provides a system-specific version of the package + SYSTEM for each platform on which the language ships. + For the complete specification of the package SYSTEM, see + Appendix F of the DEC Ada Language Reference Manual. + + On DEC Ada, the package SYSTEM includes the following conversion functions: + @itemize @bullet + @item TO_ADDRESS(INTEGER) + + @item TO_ADDRESS(UNSIGNED_LONGWORD) + + @item TO_ADDRESS(universal_integer) + + @item TO_INTEGER(ADDRESS) + + @item TO_UNSIGNED_LONGWORD(ADDRESS) + + @item Function IMPORT_VALUE return UNSIGNED_LONGWORD and the + functions IMPORT_ADDRESS and IMPORT_LARGEST_VALUE + @end itemize + + @noindent + By default, GNAT supplies a version of SYSTEM that matches + the definition given in the Ada 95 Reference Manual. + This + is a subset of the DIGITAL system definitions, which is as + close as possible to the original definitions. The only difference + is that the definition of SYSTEM_NAME is different: + + @smallexample + @group + @cartouche + @b{type} Name @b{is} (SYSTEM_NAME_GNAT); + System_Name : @b{constant} Name := SYSTEM_NAME_GNAT; + @end cartouche + @end group + @end smallexample + + @noindent + Also, GNAT adds the new Ada 95 declarations for + BIT_ORDER and DEFAULT_BIT_ORDER. + + However, the use of the following pragma causes GNAT + to extend the definition of package SYSTEM so that it + encompasses the full set of DIGITAL-specific extensions, + including the functions listed above: + + @smallexample + @cartouche + @b{pragma} Extend_System (Aux_DEC); + @end cartouche + @end smallexample + + @noindent + The pragma Extend_System is a configuration pragma that + is most conveniently placed in the @file{GNAT.ADC} file. See the + GNAT Reference Manual for further details. + + DEC Ada does not allow the recompilation of the package + SYSTEM. Instead DEC Ada provides several pragmas (SYSTEM_ + NAME, STORAGE_UNIT, and MEMORY_SIZE) to modify values in + the package SYSTEM. On OpenVMS Alpha systems, the pragma + SYSTEM_NAME takes the enumeration literal OPENVMS_AXP as + its single argument. + + GNAT does permit the recompilation of package SYSTEM using + a special qualifier (/STYLE=GNAT) and this qualifier can be used if + it is necessary to change constants in SYSTEM. GNAT does + not permit the specification of SYSTEM_NAME, STORAGE_UNIT + or MEMORY_SIZE by any other means. + + On GNAT systems, the pragma SYSTEM_NAME takes the + enumeration literal SYSTEM_NAME_GNAT. + + The definitions provided by the use of + + @smallexample + pragma Extend_System (AUX_Dec); + @end smallexample + + @noindent + are virtually identical to those provided by the DEC Ada 83 package + System. One important difference is that the name of the TO_ADDRESS + function for type UNSIGNED_LONGWORD is changed to TO_ADDRESS_LONG. + See the GNAT Reference manual for a discussion of why this change was + necessary. + + @noindent + The version of TO_ADDRESS taking a universal integer argument is in fact + an extension to Ada 83 not strictly compatible with the reference manual. + In GNAT, we are constrained to be exactly compatible with the standard, + and this means we cannot provide this capability. In DEC Ada 83, the + point of this definition is to deal with a call like: + + @smallexample + TO_ADDRESS (16#12777#); + @end smallexample + + @noindent + Normally, according to the Ada 83 standard, one would expect this to be + ambiguous, since it matches both the INTEGER and UNSIGNED_LONGWORD forms + of TO_ADDRESS. However, in DEC Ada 83, there is no ambiguity, since the + definition using universal_integer takes precedence. + + In GNAT, since the version with universal_integer cannot be supplied, it is + not possible to be 100% compatible. Since there are many programs using + numeric constants for the argument to TO_ADDRESS, the decision in GNAT was + to change the name of the function in the UNSIGNED_LONGWORD case, so the + declarations provided in the GNAT version of AUX_Dec are: + + @smallexample + function To_Address (X : Integer) return Address; + pragma Pure_Function (To_Address); + + function To_Address_Long (X : Unsigned_Longword) return Address; + pragma Pure_Function (To_Address_Long); + @end smallexample + + @noindent + This means that programs using TO_ADDRESS for UNSIGNED_LONGWORD must + change the name to TO_ADDRESS_LONG. + + @node Tasking and Task-Related Features + @section Tasking and Task-Related Features + + @noindent + The concepts relevant to a comparison of tasking on GNAT + and on DEC Ada for OpenVMS Alpha systems are discussed in + the following sections. + + For detailed information on concepts related to tasking in + DEC Ada, see the DEC Ada Language Reference Manual and the + relevant run-time reference manual. + + @node Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + @section Implementation of Tasks in DEC Ada for OpenVMS Alpha Systems + + @noindent + On OpenVMS Alpha systems, each Ada task (except a passive + task) is implemented as a single stream of execution + that is created and managed by the kernel. On these + systems, DEC Ada tasking support is based on DECthreads, + an implementation of the POSIX standard for threads. + + Although tasks are implemented as threads, all tasks in + an Ada program are part of the same process. As a result, + resources such as open files and virtual memory can be + shared easily among tasks. Having all tasks in one process + allows better integration with the programming environment + (the shell and the debugger, for example). + + Also, on OpenVMS Alpha systems, DEC Ada tasks and foreign + code that calls DECthreads routines can be used together. + The interaction between Ada tasks and DECthreads routines + can have some benefits. For example when on OpenVMS Alpha, + DEC Ada can call C code that is already threaded. + GNAT on OpenVMS Alpha uses the facilities of DECthreads, + and Ada tasks are mapped to threads. + + @menu + * Assigning Task IDs:: + * Task IDs and Delays:: + * Task-Related Pragmas:: + * Scheduling and Task Priority:: + * The Task Stack:: + * External Interrupts:: + @end menu + + @node Assigning Task IDs + @subsection Assigning Task IDs + + @noindent + The DEC Ada Run-Time Library always assigns %TASK 1 to + the environment task that executes the main program. On + OpenVMS Alpha systems, %TASK 0 is often used for tasks + that have been created but are not yet activated. + + On OpenVMS Alpha systems, task IDs are assigned at + activation. On GNAT systems, task IDs are also assigned at + task creation but do not have the same form or values as + task ID values in DEC Ada. There is no null task, and the + environment task does not have a specific task ID value. + + @node Task IDs and Delays + @subsection Task IDs and Delays + + @noindent + On OpenVMS Alpha systems, tasking delays are implemented + using Timer System Services. The Task ID is used for the + identification of the timer request (the REQIDT parameter). + If Timers are used in the application take care not to use + 0 for the identification, because cancelling such a timer + will cancel all timers and may lead to unpredictable results. + + @node Task-Related Pragmas + @subsection Task-Related Pragmas + + @noindent + Ada supplies the pragma TASK_STORAGE, which allows + specification of the size of the guard area for a task + stack. (The guard area forms an area of memory that has no + read or write access and thus helps in the detection of + stack overflow.) On OpenVMS Alpha systems, if the pragma + TASK_STORAGE specifies a value of zero, a minimal guard + area is created. In the absence of a pragma TASK_STORAGE, a default guard + area is created. + + GNAT supplies the following task-related pragmas: + + @itemize @bullet + @item TASK_INFO + + This pragma appears within a task definition and + applies to the task in which it appears. The argument + must be of type SYSTEM.TASK_INFO.TASK_INFO_TYPE. + + @item TASK_STORAGE + + GNAT implements pragma TASK_STORAGE in the same way as + DEC Ada. + Both DEC Ada and GNAT supply the pragmas PASSIVE, + SUPPRESS, and VOLATILE. + @end itemize + @node Scheduling and Task Priority + @subsection Scheduling and Task Priority + + @noindent + DEC Ada implements the Ada language requirement that + when two tasks are eligible for execution and they have + different priorities, the lower priority task does not + execute while the higher priority task is waiting. The DEC + Ada Run-Time Library keeps a task running until either the + task is suspended or a higher priority task becomes ready. + + On OpenVMS Alpha systems, the default strategy is round- + robin with preemption. Tasks of equal priority take turns + at the processor. A task is run for a certain period of + time and then placed at the rear of the ready queue for + its priority level. + + DEC Ada provides the implementation-defined pragma TIME_SLICE, + which can be used to enable or disable round-robin + scheduling of tasks with the same priority. + See the relevant DEC Ada run-time reference manual for + information on using the pragmas to control DEC Ada task + scheduling. + + GNAT follows the scheduling rules of Annex D (real-time + Annex) of the Ada 95 Reference Manual. In general, this + scheduling strategy is fully compatible with DEC Ada + although it provides some additional constraints (as + fully documented in Annex D). + GNAT implements time slicing control in a manner compatible with + DEC Ada 83, by means of the pragma Time_Slice, whose semantics are identical + to the DEC Ada 83 pragma of the same name. + Note that it is not possible to mix GNAT tasking and + DEC Ada 83 tasking in the same program, since the two run times are + not compatible. + + @node The Task Stack + @subsection The Task Stack + + @noindent + In DEC Ada, a task stack is allocated each time a + non passive task is activated. As soon as the task is + terminated, the storage for the task stack is deallocated. + If you specify a size of zero (bytes) with T'STORAGE_SIZE, + a default stack size is used. Also, regardless of the size + specified, some additional space is allocated for task + management purposes. On OpenVMS Alpha systems, at least + one page is allocated. + + GNAT handles task stacks in a similar manner. According to + the Ada 95 rules, it provides the pragma STORAGE_SIZE as + an alternative method for controlling the task stack size. + The specification of the attribute T'STORAGE_SIZE is also + supported in a manner compatible with DEC Ada. + + @node External Interrupts + @subsection External Interrupts + + @noindent + On DEC Ada, external interrupts can be associated with task entries. + GNAT is compatible with DEC Ada in its handling of external interrupts. + + @node Pragmas and Pragma-Related Features + @section Pragmas and Pragma-Related Features + + @noindent + Both DEC Ada and GNAT supply all language-defined pragmas + as specified by the Ada 83 standard. GNAT also supplies all + language-defined pragmas specified in the Ada 95 Reference Manual. + In addition, GNAT implements the implementation-defined pragmas + from DEC Ada 83. + + @itemize @bullet + @item AST_ENTRY + + @item COMMON_OBJECT + + @item COMPONENT_ALIGNMENT + + @item EXPORT_EXCEPTION + + @item EXPORT_FUNCTION + + @item EXPORT_OBJECT + + @item EXPORT_PROCEDURE + + @item EXPORT_VALUED_PROCEDURE + + @item FLOAT_REPRESENTATION + + @item IDENT + + @item IMPORT_EXCEPTION + + @item IMPORT_FUNCTION + + @item IMPORT_OBJECT + + @item IMPORT_PROCEDURE + + @item IMPORT_VALUED_PROCEDURE + + @item INLINE_GENERIC + + @item INTERFACE_NAME + + @item LONG_FLOAT + + @item MAIN_STORAGE + + @item PASSIVE + + @item PSET_OBJECT + + @item SHARE_GENERIC + + @item SUPPRESS_ALL + + @item TASK_STORAGE + + @item TIME_SLICE + + @item TITLE + @end itemize + + @noindent + These pragmas are all fully implemented, with the exception of @code{Title}, + @code{Passive}, and @code{Share_Generic}, which are + recognized, but which have no + effect in GNAT. The effect of @code{Passive} may be obtained by the + use of protected objects in Ada 95. In GNAT, all generics are inlined. + + Unlike DEC Ada, the GNAT 'EXPORT_@i{subprogram}' pragmas require + a separate subprogram specification which must appear before the + subprogram body. + + GNAT also supplies a number of implementation-defined pragmas as follows: + @itemize @bullet + @item C_PASS_BY_COPY + + @item EXTEND_SYSTEM + + @item SOURCE_FILE_NAME + + @item UNSUPPRESS + + @item WARNINGS + + @item ABORT_DEFER + + @item ADA_83 + + @item ADA_95 + + @item ANNOTATE + + @item ASSERT + + @item CPP_CLASS + + @item CPP_CONSTRUCTOR + + @item CPP_DESTRUCTOR + + @item CPP_VIRTUAL + + @item CP_VTABLE + + @item DEBUG + + @item LINKER_ALIAS + + @item LINKER_SECTION + + @item MACHINE_ATTRIBUTE + + @item NO_RETURN + + @item PURE_FUNCTION + + @item SOURCE_REFERENCE + + @item TASK_INFO + + @item UNCHECKED_UNION + + @item UNIMPLEMENTED_UNIT + + @item WEAK_EXTERNAL + @end itemize + + @noindent + For full details on these GNAT implementation-defined pragmas, see + the GNAT Reference Manual. + + @menu + * Restrictions on the Pragma INLINE:: + * Restrictions on the Pragma INTERFACE:: + * Restrictions on the Pragma SYSTEM_NAME:: + @end menu + + @node Restrictions on the Pragma INLINE + @subsection Restrictions on the Pragma INLINE + + @noindent + DEC Ada applies the following restrictions to the pragma INLINE: + @itemize @bullet + @item Parameters cannot be a task type. + + @item Function results cannot be task types, unconstrained + array types, or unconstrained types with discriminants. + + @item Bodies cannot declare the following: + @itemize @bullet + @item Subprogram body or stub (imported subprogram is allowed) + + @item Tasks + + @item Generic declarations + + @item Instantiations + + @item Exceptions + + @item Access types (types derived from access types allowed) + + @item Array or record types + + @item Dependent tasks + + @item Direct recursive calls of subprogram or containing + subprogram, directly or via a renaming + + @end itemize + @end itemize + + @noindent + In GNAT, the only restriction on pragma INLINE is that the + body must occur before the call if both are in the same + unit, and the size must be appropriately small. There are + no other specific restrictions which cause subprograms to + be incapable of being inlined. + + @node Restrictions on the Pragma INTERFACE + @subsection Restrictions on the Pragma INTERFACE + + @noindent + The following lists and describes the restrictions on the + pragma INTERFACE on DEC Ada and GNAT: + @itemize @bullet + @item Languages accepted: Ada, Bliss, C, Fortran, Default. + Default is the default on OpenVMS Alpha systems. + + @item Parameter passing: Language specifies default + mechanisms but can be overridden with an EXPORT pragma. + + @itemize @bullet + @item Ada: Use internal Ada rules. + + @item Bliss, C: Parameters must be mode @code{in}; cannot be + record or task type. Result cannot be a string, an + array, or a record. + + @item Fortran: Parameters cannot be a task. Result cannot + be a string, an array, or a record. + @end itemize + @end itemize + + @noindent + GNAT is entirely upwards compatible with DEC Ada, and in addition allows + record parameters for all languages. + + @node Restrictions on the Pragma SYSTEM_NAME + @subsection Restrictions on the Pragma SYSTEM_NAME + + @noindent + For DEC Ada for OpenVMS Alpha, the enumeration literal + for the type NAME is OPENVMS_AXP. In GNAT, the enumeration + literal for the type NAME is SYSTEM_NAME_GNAT. + + @node Library of Predefined Units + @section Library of Predefined Units + + @noindent + A library of predefined units is provided as part of the + DEC Ada and GNAT implementations. DEC Ada does not provide + the package MACHINE_CODE but instead recommends importing + assembler code. + + The GNAT versions of the DEC Ada Run-Time Library (ADA$PREDEFINED:) + units are taken from the OpenVMS Alpha version, not the OpenVMS VAX + version. During GNAT installation, the DEC Ada Predefined + Library units are copied into the GNU:[LIB.OPENVMS7_x.2_8_x.DECLIB] + (aka DECLIB) directory and patched to remove Ada 95 incompatibilities + and to make them interoperable with GNAT, @pxref{Changes to DECLIB} + for details. + + The GNAT RTL is contained in + the GNU:[LIB.OPENVMS7_x.2_8_x.ADALIB] (aka ADALIB) directory and + the default search path is set up to find DECLIB units in preference + to ADALIB units with the same name (TEXT_IO, SEQUENTIAL_IO, and DIRECT_IO, + for example). + + However, it is possible to change the default so that the + reverse is true, or even to mix them using child package + notation. The DEC Ada 83 units are available as DEC.xxx where xxx + is the package name, and the Ada units are available in the + standard manner defined for Ada 95, that is to say as Ada.xxx. To + change the default, set ADA_INCLUDE_PATH and ADA_OBJECTS_PATH + appropriately. For example, to change the default to use the Ada95 + versions do: + + @smallexample + $ DEFINE ADA_INCLUDE_PATH GNU:[LIB.OPENVMS7_1.2_8_1.ADAINCLUDE],- + GNU:[LIB.OPENVMS7_1.2_8_1.DECLIB] + $ DEFINE ADA_OBJECTS_PATH GNU:[LIB.OPENVMS7_1.2_8_1.ADALIB],- + GNU:[LIB.OPENVMS7_1.2_8_1.DECLIB] + @end smallexample + + @menu + * Changes to DECLIB:: + @end menu + + @node Changes to DECLIB + @subsection Changes to DECLIB + + @noindent + The changes made to the DEC Ada predefined library for GNAT and Ada 95 + compatibility are minor and include the following: + + @itemize @bullet + @item Adjusting the location of pragmas and record representation + clauses to obey Ada 95 rules + + @item Adding the proper notation to generic formal parameters + that take unconstrained types in instantiation + + @item Adding pragma ELABORATE_BODY to package specifications + that have package bodies not otherwise allowed + + @item Occurrences of the identifier "PROTECTED" are renamed to "PROTECTD". + Currently these are found only in the STARLET package spec. + @end itemize + + @noindent + None of the above changes is visible to users. + + @node Bindings + @section Bindings + + @noindent + On OpenVMS Alpha, DEC Ada provides the following strongly-typed bindings: + @itemize @bullet + + @item Command Language Interpreter (CLI interface) + + @item DECtalk Run-Time Library (DTK interface) + + @item Librarian utility routines (LBR interface) + + @item General Purpose Run-Time Library (LIB interface) + + @item Math Run-Time Library (MTH interface) + + @item National Character Set Run-Time Library (NCS interface) + + @item Compiled Code Support Run-Time Library (OTS interface) + + @item Parallel Processing Run-Time Library (PPL interface) + + @item Screen Management Run-Time Library (SMG interface) + + @item Sort Run-Time Library (SOR interface) + + @item String Run-Time Library (STR interface) + + @item STARLET System Library + @findex Starlet + + @item X Window System Version 11R4 and 11R5 (X, XLIB interface) + + @item X Windows Toolkit (XT interface) + + @item X/Motif Version 1.1.3 and 1.2 (XM interface) + @end itemize + + @noindent + GNAT provides implementations of these DEC bindings in the DECLIB directory. + + The X/Motif bindings used to build DECLIB are whatever versions are in the + DEC Ada ADA$PREDEFINED directory with extension .ADC. The build script will + automatically add a pragma Linker_Options to packages Xm, Xt, and X_Lib + causing the default X/Motif shareable image libraries to be linked in. This + is done via options files named xm.opt, xt.opt, and x_lib.opt (also located + in the DECLIB directory). + + It may be necessary to edit these options files to update or correct the + library names if, for example, the newer X/Motif bindings from ADA$EXAMPLES + had been (previous to installing GNAT) copied and renamed to superseded the + default ADA$PREDEFINED versions. + + @menu + * Shared Libraries and Options Files:: + * Interfaces to C:: + @end menu + + @node Shared Libraries and Options Files + @subsection Shared Libraries and Options Files + + @noindent + When using the DEC Ada + predefined X and Motif bindings, the linking with their shareable images is + done automatically by GNAT LINK. When using other X and Motif bindings, it + is necessary to add the corresponding shareable images to the command line for + GNAT LINK. When linking with shared libraries, or with .OPT files, it is + also necessary to add them to the command line for GNAT LINK. + + A shared library to be used with GNAT is built in the same way as other + libraries under VMS. The VMS Link command can be used in standard fashion. + + @node Interfaces to C + @subsection Interfaces to C + + @noindent + DEC Ada + provides the following Ada types and operations: + + @itemize @bullet + @item C types package (C_TYPES) + + @item C strings (C_TYPES.NULL_TERMINATED) + + @item Other_types (SHORT_INT) + @end itemize + + @noindent + Interfacing to C with GNAT, one can use the above approach + described for DEC Ada or the facilities of Annex B of + the Ada 95 Reference Manual (packages INTERFACES.C, + INTERFACES.C.STRINGS and INTERFACES.C.POINTERS). For more + information, see the section "Interfacing to C" in the + GNAT Reference Manual. + + The @option{/UPPERCASE_EXTERNALS} qualifier forces default and explicit + @code{External_Name} parameters in pragmas Import and Export + to be uppercased for compatibility with the default behavior + of DEC C. The qualifier has no effect on @code{Link_Name} parameters. + + @node Main Program Definition + @section Main Program Definition + + @noindent + The following section discusses differences in the + definition of main programs on DEC Ada and GNAT. + On DEC Ada, main programs are defined to meet the + following conditions: + @itemize @bullet + @item Procedure with no formal parameters (returns 0 upon + normal completion) + + @item Procedure with no formal parameters (returns 42 when + unhandled exceptions are raised) + + @item Function with no formal parameters whose returned value + is of a discrete type + + @item Procedure with one OUT formal of a discrete type for + which a specification of pragma EXPORT_VALUED_PROCEDURE is given. + + @end itemize + + @noindent + When declared with the pragma EXPORT_VALUED_PROCEDURE, + a main function or main procedure returns a discrete + value whose size is less than 64 bits (32 on VAX systems), + the value is zero- or sign-extended as appropriate. + On GNAT, main programs are defined as follows: + @itemize @bullet + @item Must be a non-generic, parameter-less subprogram that + is either a procedure or function returning an Ada + STANDARD.INTEGER (the predefined type) + + @item Cannot be a generic subprogram or an instantiation of a + generic subprogram + @end itemize + + @node Implementation-Defined Attributes + @section Implementation-Defined Attributes + + @noindent + GNAT provides all DEC Ada implementation-defined + attributes. + + @node Compiler and Run-Time Interfacing + @section Compiler and Run-Time Interfacing + + @noindent + DEC Ada provides the following ways to pass options to the linker (ACS LINK): + @itemize @bullet + @item /WAIT and /SUBMIT qualifiers + + @item /COMMAND qualifier + + @item /[NO]MAP qualifier + + @item /OUTPUT=file-spec + + @item /[NO]DEBUG and /[NO]TRACEBACK qualifiers + @end itemize + + @noindent + To pass options to the linker, GNAT provides the following + qualifiers: + + @itemize @bullet + @item /EXECUTABLE=exec-name + + @item /VERBOSE qualifier + + @item /[NO]DEBUG and /[NO]TRACEBACK qualifiers + @end itemize + + @noindent + For more information on these qualifiers, see the section + "Qualifiers for GNAT LINK" in the corresponding section of this Guide. + In DEC Ada, the command-line qualifier /OPTIMIZE is available + to control optimization. DEC Ada also supplies the + following pragmas: + @itemize @bullet + @item OPTIMIZE + + @item INLINE + + @item INLINE_GENERIC + + @item SUPPRESS_ALL + + @item PASSIVE + @end itemize + + @noindent + In GNAT, optimization is controlled strictly by command + line parameters, as described in the corresponding section of this guide. + The DIGITAL pragmas for control of optimization are + recognized but ignored. + + Note that in GNAT, the default is optimization off, whereas in DEC Ada 83, + the default is that optimization is turned on. + + @node Program Compilation and Library Management + @section Program Compilation and Library Management + + @noindent + DEC Ada and GNAT provide a comparable set of commands to + build programs. DEC Ada also provides a program library, + which is a concept that does not exist on GNAT. Instead, + GNAT provides directories of sources that are compiled as + needed. + + The following table summarizes + the DEC Ada commands and provides + equivalent GNAT commands. In this table, some GNAT + equivalents reflect the fact that GNAT does not use the + concept of a program library. Instead, it uses a model + in which collections of source and object files are used + in a manner consistent with other languages like C and + Fortran. Therefore, standard system file commands are used + to manipulate these elements. Those GNAT commands are marked with + an asterisk in the table that follows. + Note that, unlike DEC Ada, none of the GNAT commands accepts wild cards. + + @need 1500 + @multitable @columnfractions .31 .30 .39 + + @item @strong{DEC_Ada_Command} + @tab @strong{GNAT_Equivalent} + @tab @strong{Description} + + @item ADA + @tab GNAT COMPILE + @tab Invokes the compiler to compile one or more Ada source files. + + @item ACS ATTACH + @tab No equivalent + @tab Qualifiers control of terminal from current process running the program + library manager. + + @item ACS CHECK + @tab GNAT MAKE /DEPENDENCY_LIST + @tab Forms the execution closure of one + or more compiled units and checks completeness and currency. + + @item ACS COMPILE + @tab GNAT MAKE /ACTIONS=COMPILE + @tab Forms the execution closure of one or + more specified units, checks completeness and currency, + identifies units that have revised source files, compiles same, + and recompiles units that are or will become obsolete. + Also completes incomplete generic instantiations. + + @item ACS COPY FOREIGN + @tab Copy (*) + @tab Copies a foreign object file into the program library as a + library unit body. + + @item ACS COPY UNIT + @tab Copy (*) + @tab Copies a compiled unit from one program library to another. + + @item ACS CREATE LIBRARY + @tab Create /directory (*) + @tab Creates a program library. + + @item ACS CREATE SUBLIBRARY + @tab Create /directory (*) + @tab Creates a program sublibrary. + + @item ACS DELETE LIBRARY + @tab + @tab Deletes a program library and its contents. + + @item ACS DELETE SUBLIBRARY + @tab + @tab Deletes a program sublibrary and its contents. + + @item ACS DELETE UNIT + @tab Delete @i{file} (*) + @tab On OpenVMS systems, deletes one or more compiled units from + the current program library. + + @item ACS DIRECTORY + @tab Directory (*) + @tab On OpenVMS systems, lists units contained in the current + program library. + + @item ACS ENTER FOREIGN + @tab Copy (*) + @tab Allows the import of a foreign body as an Ada library + specification and enters a reference to a pointer. + + @item ACS ENTER UNIT + @tab Copy (*) + @tab Enters a reference (pointer) from the current program library to + a unit compiled into another program library. + + @item ACS EXIT + @tab No equivalent + @tab Exits from the program library manager. + + @item ACS EXPORT + @tab Copy (*) + @tab Creates an object file that contains system-specific object code + for one or more units. With GNAT, object files can simply be copied + into the desired directory. + + @item ACS EXTRACT SOURCE + @tab Copy (*) + @tab Allows access to the copied source file for each Ada compilation unit + + @item ACS HELP + @tab HELP GNAT + @tab Provides online help. + + @item ACS LINK + @tab GNAT LINK + @tab Links an object file containing Ada units into an executable + file. + + @item ACS LOAD + @tab Copy (*) + @tab Loads (partially compiles) Ada units into the program library. + Allows loading a program from a collection of files into a library + without knowing the relationship among units. + + @item ACS MERGE + @tab Copy (*) + @tab Merges into the current program library, one or more units from + another library where they were modified. + + @item ACS RECOMPILE + @tab GNAT MAKE /ACTIONS=COMPILE + @tab Recompiles from external or copied source files any obsolete + unit in the closure. Also, completes any incomplete generic + instantiations. + + @item ACS REENTER + @tab GNAT MAKE + @tab Reenters current references to units compiled after last entered + with the ACS ENTER UNIT command. + + @item ACS SET LIBRARY + @tab Set default (*) + @tab Defines a program library to be the compilation context as well + as the target library for compiler output and commands in general. + + @item ACS SET PRAGMA + @tab Edit GNAT.ADC (*) + @tab Redefines specified values of the library characteristics + LONG_ FLOAT, MEMORY_SIZE, SYSTEM_NAME, and @code{Float_Representation}. + + @item ACS SET SOURCE + @tab define @* ADA_INCLUDE_PATH @i{path} (*) + @tab Defines the source file search list for the ACS COMPILE command. + + @item ACS SHOW LIBRARY + @tab Directory (*) + @tab Lists information about one or more program libraries. + + @item ACS SHOW PROGRAM + @tab No equivalent + @tab Lists information about the execution closure of one or + more units in the program library. + + @item ACS SHOW SOURCE + @tab Show logical @* ADA_INCLUDE_PATH + @tab Shows the source file search used when compiling units. + + @item ACS SHOW VERSION + @tab Compile with VERBOSE option + @tab Displays the version number of the compiler and program library + manager used. + + @item ACS SPAWN + @tab No equivalent + @tab Creates a subprocess of the current process (same as DCL SPAWN + command). + + @item ACS VERIFY + @tab No equivalent + @tab Performs a series of consistency checks on a program library to + determine whether the library structure and library files are in + valid_form. + + @end multitable + + @noindent + + @node Input-Output + @section Input-Output + + @noindent + On OpenVMS Alpha systems, DEC Ada uses OpenVMS Record + Management Services (RMS) to perform operations on + external files. + + @noindent + DEC Ada and GNAT predefine an identical set of input- + output packages. To make the use of the + generic TEXT_IO operations more convenient, DEC Ada + provides predefined library packages that instantiate the + integer and floating-point operations for the predefined + integer and floating-point types as shown in the following table. + + @table @code + + @item Package_Name + Instantiation + + @item INTEGER_TEXT_IO + INTEGER_IO(INTEGER) + + @item SHORT_INTEGER_TEXT_IO + INTEGER_IO(SHORT_INTEGER) + + @item SHORT_SHORT_INTEGER_TEXT_IO + INTEGER_IO(SHORT_SHORT_ INTEGER) + + @item FLOAT_TEXT_IO + FLOAT_IO(FLOAT) + + @item LONG_FLOAT_TEXT_IO + FLOAT_IO(LONG_FLOAT) + @end table + + @noindent + The DEC Ada predefined packages and their operations + are implemented using OpenVMS Alpha files and input- + output facilities. DEC Ada supports asynchronous input- + output on OpenVMS Alpha. Familiarity with the following is + recommended: + @itemize @bullet + @item RMS file organizations and access methods + + @item OpenVMS file specifications and directories + + @item OpenVMS File Definition Language (FDL) + @end itemize + + @noindent + GNAT provides I/O facilities that are completely + compatible with DEC Ada. The distribution includes the + standard DEC Ada versions of all I/O packages, operating + in a manner compatible with DEC Ada. In particular, the + following packages are by default the DEC Ada (Ada 83) + versions of these packages rather than the renamings + suggested in annex J of the Ada 95 Reference Manual: + @itemize @bullet + @item TEXT_IO + + @item SEQUENTIAL_IO + + @item DIRECT_IO + @end itemize + + @noindent + The use of the standard Ada 95 syntax for child packages (for + example, ADA.TEXT_IO) retrieves the Ada 95 versions of these + packages, as defined in the Ada 95 Reference Manual. + GNAT provides DIGITAL-compatible predefined instantiations + of the TEXT_IO packages, and also + provides the standard predefined instantiations required + by the Ada 95 Reference Manual. + + For further information on how GNAT interfaces to the file + system or how I/O is implemented in programs written in + mixed languages, see the chapter "Implementation of the + Standard I/O" in the GNAT Reference Manual. + This chapter covers the following: + @itemize @bullet + @item Standard I/O packages + + @item FORM strings + + @item DIRECT_IO + + @item SEQUENTIAL_IO + + @item TEXT_IO + + @item Stream pointer positioning + + @item Reading and writing non-regular files + + @item GET_IMMEDIATE + + @item Treating TEXT_IO files as streams + + @item Shared files + + @item Open modes + @end itemize + + @node Implementation Limits + @section Implementation Limits + + @noindent + The following table lists implementation limits for DEC Ada and GNAT systems. + @multitable @columnfractions .60 .20 .20 + @item Compilation Parameter + @tab DEC Ada + @tab GNAT + + @item In a subprogram or entry declaration, maximum number of + formal parameters that are of an unconstrained record type + @tab 32 + @tab No set limit + + @item Maximum identifier length (number of characters) + @tab 255 + @tab 255 + + @item Maximum number of characters in a source line + @tab 255 + @tab 255 + + @item Maximum collection size (number of bytes) + @tab 2**31-1 + @tab 2**31-1 + + @item Maximum number of discriminants for a record type + @tab 245 + @tab No set limit + + @item Maximum number of formal parameters in an entry or + subprogram declaration + @tab 246 + @tab No set limit + + @item Maximum number of dimensions in an array type + @tab 255 + @tab No set limit + + @item Maximum number of library units and subunits in a compilation. + @tab 4095 + @tab No set limit + + @item Maximum number of library units and subunits in an execution. + @tab 16383 + @tab No set limit + + @item Maximum number of objects declared with the pragma COMMON_OBJECT + or PSECT_OBJECT + @tab 32757 + @tab No set limit + + @item Maximum number of enumeration literals in an enumeration type + definition + @tab 65535 + @tab No set limit + + @item Maximum number of lines in a source file + @tab 65534 + @tab No set limit + + @item Maximum number of bits in any object + @tab 2**31-1 + @tab 2**31-1 + + @item Maximum size of the static portion of a stack frame (approximate) + @tab 2**31-1 + @tab 2**31-1 + @end multitable + + @node Tools + @section Tools + + + @node Inline Assembler + @chapter Inline Assembler + + @noindent + If you need to write low-level software that interacts directly with the hardware, Ada provides two ways to incorporate assembly language code into your program. First, you can import and invoke external routines written in assembly language, an Ada feature fully supported by GNAT. However, for small sections of code it may be simpler or more efficient to include assembly language statements directly in your Ada source program, using the facilities of the implementation-defined package @code{System.Machine_Code}, which incorporates the GNAT COMPILE Inline Assembler. The Inline Assembler approach offers a number of advantages, including the following: + + @itemize @bullet + @item No need to use non-Ada tools + @item Consistent interface over different targets + @item Automatic usage of the proper calling conventions + @item Access to Ada constants and variables + @item Definition of intrinsic routines + @item Possibility of inlining a subprogram comprising assembler code + @item Code optimizer can take Inline Assembler code into account + @end itemize + + This chapter presents a series of examples to show you how to use the Inline Assembler. Although it focuses on the Intel x86, the general approach applies also to other processors. It is assumed that you are familiar with Ada and with assembly language programming. + + @menu + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + @end menu + + @c --------------------------------------------------------------------------- + @node Basic Assembler Syntax + @section Basic Assembler Syntax + + @noindent + The assembler used by GNAT and GNAT COMPILE is based not on the Intel assembly language, but rather on a + language that descends from the AT&T Unix assembler @emph{as} (and which is often + referred to as ``AT&T syntax''). + The following table summarizes the main features of @emph{as} syntax and points out the differences from the Intel conventions. + See the GNAT COMPILE @emph{as} and @emph{gas} (an @emph{as} macro + pre-processor) documentation for further information. + + @table @asis + @item Register names + GNAT COMPILE / @emph{as}: Prefix with ``%''; for example @code{%eax} + @* + Intel: No extra punctuation; for example @code{eax} + + @item Immediate operand + GNAT COMPILE / @emph{as}: Prefix with ``$''; for example @code{$4} + @* + Intel: No extra punctuation; for example @code{4} + + @item Address + GNAT COMPILE / @emph{as}: Prefix with ``$''; for example @code{$loc} + @* + Intel: No extra punctuation; for example @code{loc} + + @item Memory contents + GNAT COMPILE / @emph{as}: No extra punctuation; for example @code{loc} + @* + Intel: Square brackets; for example @code{[loc]} + + @item Register contents + GNAT COMPILE / @emph{as}: Parentheses; for example @code{(%eax)} + @* + Intel: Square brackets; for example @code{[eax]} + + @item Hexadecimal numbers + GNAT COMPILE / @emph{as}: Leading ``0x'' (C language syntax); for example @code{0xA0} + @* + Intel: Trailing ``h''; for example @code{A0h} + + @item Operand size + GNAT COMPILE / @emph{as}: Explicit in op code; for example @code{movw} to move a 16-bit word + @* + Intel: Implicit, deduced by assembler; for example @code{mov} + + @item Instruction repetition + GNAT COMPILE / @emph{as}: Split into two lines; for example + @* + @code{rep} + @* + @code{stosl} + @* + Intel: Keep on one line; for example @code{rep stosl} + + @item Order of operands + GNAT COMPILE / @emph{as}: Source first; for example @code{movw $4, %eax} + @* + Intel: Destination first; for example @code{mov eax, 4} + @end table + + @c --------------------------------------------------------------------------- + @node A Simple Example of Inline Assembler + @section A Simple Example of Inline Assembler + + @noindent + The following example will generate a single assembly language statement, @code{nop}, which does nothing. Despite its lack of run-time effect, the example will be useful in illustrating the basics of the Inline Assembler facility. + + @smallexample + @group + with System.Machine_Code; use System.Machine_Code; + procedure Nothing is + begin + Asm ("nop"); + end Nothing; + @end group + @end smallexample + + @code{Asm} is a procedure declared in package @code{System.Machine_Code}; here it takes one parameter, a @emph{template string} that must be a static expression and that will form the generated instruction. + @code{Asm} may be regarded as a compile-time procedure that parses the template string and additional parameters (none here), from which it generates a sequence of assembly language instructions. + + The examples in this chapter will illustrate several of the forms for invoking @code{Asm}; a complete specification of the syntax is found in the @cite{GNAT Reference Manual}. + + Under the standard GNAT conventions, the @code{Nothing} procedure should be in a file named @file{NOTHING.ADB}. You can build the executable in the usual way: + @smallexample + GNAT MAKE nothing + @end smallexample + However, the interesting aspect of this example is not its run-time behavior but rather the + generated assembly code. To see this output, invoke the compiler as follows: + @smallexample + GNAT COMPILE -S -fomit-frame-pointer /CHECKS=SUPPRESS_ALL @file{NOTHING.ADB} + @end smallexample + where the options are: + + @table @code + @item -c + compile only (no bind or link) + @item -S + generate assembler listing + @item -fomit-frame-pointer + do not set up separate stack frames + @item /CHECKS=SUPPRESS_ALL + do not add runtime checks + @end table + + This gives a human-readable assembler version of the code. The resulting + file will have the same name as the Ada source file, but with a @code{.s} extension. + In our example, the file @file{nothing.s} has the following contents: + + @smallexample + @group + .file "NOTHING.ADB" + gcc2_compiled.: + ___gnu_compiled_ada: + .text + .align 4 + .globl __ada_nothing + __ada_nothing: + #APP + nop + #NO_APP + jmp L1 + .align 2,0x90 + L1: + ret + @end group + @end smallexample + + The assembly code you included is clearly indicated by + the compiler, between the @code{#APP} and @code{#NO_APP} + delimiters. The character before the 'APP' and 'NOAPP' + can differ on different targets. For example, Linux uses '#APP' while + on NT you will see '/APP'. + + If you make a mistake in your assembler code (such as using the + wrong size modifier, or using a wrong operand for the instruction) GNAT + will report this error in a temporary file, which will be deleted when + the compilation is finished. Generating an assembler file will help + in such cases, since you can assemble this file separately using the + @emph{as} assembler that comes with GNAT COMPILE. + + Assembling the file using the command + + @smallexample + as @file{nothing.s} + @end smallexample + @noindent + will give you error messages whose lines correspond to the assembler + input file, so you can easily find and correct any mistakes you made. + If there are no errors, @emph{as} will generate an object file @file{nothing.out}. + + @c --------------------------------------------------------------------------- + @node Output Variables in Inline Assembler + @section Output Variables in Inline Assembler + + @noindent + The examples in this section, showing how to access the processor flags, illustrate how to specify the destination operands for assembly language statements. + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags; + @end group + @end smallexample + + In order to have a nicely aligned assembly listing, we have separated + multiple assembler statements in the Asm template string with linefeed (ASCII.LF) + and horizontal tab (ASCII.HT) characters. The resulting section of the + assembly output file is: + + @smallexample + @group + #APP + pushfl + popl %eax + movl %eax, -40(%ebp) + #NO_APP + @end group + @end smallexample + + It would have been legal to write the Asm invocation as: + + @smallexample + Asm ("pushfl popl %%eax movl %%eax, %0") + @end smallexample + + but in the generated assembler file, this would come out as: + + @smallexample + #APP + pushfl popl %eax movl %eax, -40(%ebp) + #NO_APP + @end smallexample + + which is not so convenient for the human reader. + + We use Ada comments + at the end of each line to explain what the assembler instructions + actually do. This is a useful convention. + + When writing Inline Assembler instructions, you need to precede each register and variable name with a percent sign. Since the assembler already requires a percent sign at the beginning of a register name, you need two consecutive percent signs for such names in the Asm template string, thus @code{%%eax}. In the generated assembly code, one of the percent signs will be stripped off. + + Names such as @code{%0}, @code{%1}, @code{%2}, etc., denote input or output variables: operands you later define using @code{Input} or @code{Output} parameters to @code{Asm}. + An output variable is illustrated in + the third statement in the Asm template string: + @smallexample + movl %%eax, %0 + @end smallexample + The intent is to store the contents of the eax register in a variable that can be accessed in Ada. Simply writing @code{movl %%eax, Flags} would not necessarily work, since the compiler might optimize by using a register to hold Flags, and the expansion of the @code{movl} instruction would not be aware of this optimization. The solution is not to store the result directly but rather to advise the compiler to choose the correct operand form; that is the purpose of the @code{%0} output variable. + + Information about the output variable is supplied in the @code{Outputs} parameter to @code{Asm}: + @smallexample + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + @end smallexample + + The output is defined by the @code{Asm_Output} attribute of the target type; the general format is + @smallexample + Type'Asm_Output (constraint_string, variable_name) + @end smallexample + + The constraint string directs the compiler how + to store/access the associated variable. In the example + @smallexample + Unsigned_32'Asm_Output ("=m", Flags); + @end smallexample + the @code{"m"} (memory) constraint tells the compiler that the variable + @code{Flags} should be stored in a memory variable, thus preventing + the optimizer from keeping it in a register. In contrast, + @smallexample + Unsigned_32'Asm_Output ("=r", Flags); + @end smallexample + uses the @code{"r"} (register) constraint, telling the compiler to + store the variable in a register. + + If the constraint is preceded by the equal character (@strong{=}), it tells the + compiler that the variable will be used to store data into it. + + In the @code{Get_Flags} example, we used the "g" (global) constraint, allowing the optimizer + to choose whatever it deems best. + + There are a fairly large number of constraints, but the ones that are most useful (for the Intel x86 processor) are the following: + + @table @code + @item = + output constraint + @item g + global (i.e. can be stored anywhere) + @item m + in memory + @item I + a constant + @item a + use eax + @item b + use ebx + @item c + use ecx + @item d + use edx + @item S + use esi + @item D + use edi + @item r + use one of eax, ebx, ecx or edx + @item q + use one of eax, ebx, ecx, edx, esi or edi + @end table + + The full set of constraints is described in the GNAT COMPILE and @emph{as} documentation; note that it is possible to combine certain constraints in one constraint string. + + You specify the association of an output variable with an assembler operand through the @code{%}@emph{n} notation, where @emph{n} is a non-negative integer. Thus in + @smallexample + @group + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + @end group + @end smallexample + @noindent + @code{%0} will be replaced in the expanded code by the appropriate operand, + whatever + the compiler decided for the @code{Flags} variable. + + In general, you may have any number of output variables: + @itemize @bullet + @item + Count the operands starting at 0; thus @code{%0}, @code{%1}, etc. + @item + Specify the @code{Outputs} parameter as a parenthesized comma-separated list of @code{Asm_Output} attributes + @end itemize + + For example: + @smallexample + @group + Asm ("movl %%eax, %0" & LF & HT & + "movl %%ebx, %1" & LF & HT & + "movl %%ecx, %2", + Outputs => (Unsigned_32'Asm_Output ("=g", Var_A), -- %0 = Var_A + Unsigned_32'Asm_Output ("=g", Var_B), -- %1 = Var_B + Unsigned_32'Asm_Output ("=g", Var_C))); -- %2 = Var_C + @end group + @end smallexample + @noindent + where @code{Var_A}, @code{Var_B}, and @code{Var_C} are variables in the Ada program. + + As a variation on the @code{Get_Flags} example, we can use the constraints string to direct the compiler to store the eax register into the @code{Flags} variable, instead of including the store instruction explicitly in the @code{Asm} template string: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_2 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax", -- save flags in eax + Outputs => Unsigned_32'Asm_Output ("=a", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_2; + @end group + @end smallexample + + @noindent + The @code{"a"} constraint tells the compiler that the @code{Flags} + variable will come from the eax register. Here is the resulting code: + + @smallexample + @group + #APP + pushfl + popl %eax + #NO_APP + movl %eax,-40(%ebp) + @end group + @end smallexample + + @noindent + The compiler generated the store of eax into Flags after + expanding the assembler code. + + Actually, there was no need to pop the flags into the eax register; more simply, we could just pop the flags directly into the program variable: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_3 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "pop %0", -- save flags in Flags + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_3; + @end group + @end smallexample + + @c --------------------------------------------------------------------------- + @node Input Variables in Inline Assembler + @section Input Variables in Inline Assembler + + @noindent + The example in this section illustrates how to specify the source operands for assembly language statements. The program simply increments its input value by 1: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Incr (Value); + Put_Line ("Value after is" & Value'Img); + end Increment; + @end group + @end smallexample + + The @code{Outputs} parameter to @code{Asm} specifies + that the result will be in the eax register and that it is to be stored in the @code{Result} + variable. + + The @code{Inputs} parameter looks much like the @code{Outputs} parameter, but with an + @code{Asm_Input} attribute. The + @code{"="} constraint, indicating an output value, is not present. + + You can have multiple input variables, in the same way that you can have more + than one output variable. + + The parameter count (%0, %1) etc, now starts at the first input + statement, and continues with the output statements. + When both parameters use the same variable, the + compiler will treat them as the same %n operand, which is the case here. + + Just as the @code{Outputs} parameter causes the register to be stored into the + target variable after execution of the assembler statements, so does the + @code{Inputs} parameter cause its variable to be loaded into the register before execution + of the + assembler statements. + + Thus the effect of the @code{Asm} invocation is: + @enumerate + @item load the 32-bit value of @code{Value} into eax + @item execute the @code{incl %eax} instruction + @item store the contents of eax into the @code{Result} variable + @end enumerate + + The resulting assembler file (with @code{/OPTIMIZE=ALL} optimization) contains: + @smallexample + @group + _increment__incr.1: + subl $4,%esp + movl 8(%esp),%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + movl %ecx,(%esp) + addl $4,%esp + ret + @end group + @end smallexample + + @c --------------------------------------------------------------------------- + @node Inlining Inline Assembler Code + @section Inlining Inline Assembler Code + + @noindent + For a short subprogram such as the @code{Incr} function in the previous section, the overhead of the call and return (creating / deleting the stack frame) + can be significant, compared to the amount of code in the subprogram body. + A solution is to apply Ada's @code{Inline} pragma to the subprogram, + which directs the compiler to expand invocations of the subprogram at the point(s) + of call, instead of setting up a stack frame for out-of-line calls. + Here is the resulting program: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment_2 is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + pragma Inline (Increment); + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Increment (Value); + Put_Line ("Value after is" & Value'Img); + end Increment_2; + @end group + @end smallexample + + Compile the program with both optimization (@code{/OPTIMIZE=ALL}) and inlining + enabled (@option{-gnatpn} instead of @option{/CHECKS=SUPPRESS_ALL}). + + The @code{Incr} function is still compiled as usual, but at the + point in @code{Increment} where our function used to be called: + + @smallexample + @group + pushl %edi + call _increment__incr.1 + @end group + @end smallexample + + @noindent + the code for the function body directly appears: + + @smallexample + @group + movl %esi,%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + @end group + @end smallexample + + @noindent + thus saving the overhead of stack frame setup and an out-of-line call. + + @c --------------------------------------------------------------------------- + @node Other Asm Functionality + @section Other @code{Asm} Functionality + + @noindent + This section describes two important parameters to the @code{Asm} procedure: @code{Clobber}, which identifies register usage; and @code{Volatile}, which inhibits unwanted optimizations. + + @menu + * The Clobber Parameter:: + * The Volatile Parameter:: + @end menu + + @c --------------------------------------------------------------------------- + @node The Clobber Parameter + @subsection The @code{Clobber} Parameter + + @noindent + One of the dangers of intermixing assembly language and a compiled language such as Ada is + that the compiler needs to be aware of which registers are being used by the assembly code. + In some cases, such as the earlier examples, the constraint string is sufficient to + indicate register usage (e.g. "a" for the eax register). But more generally, the + compiler needs an explicit identification of the registers that are used by the Inline + Assembly statements. + + Using a register that the compiler doesn't know about + could be a side effect of an instruction (like @code{mull} + storing its result in both eax and edx). + It can also arise from explicit register usage in your + assembly code; for example: + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out)); + @end group + @end smallexample + @noindent + where the compiler (since it does not analyze the @code{Asm} template string) + does not know you are using the ebx register. + + In such cases you need to supply the @code{Clobber} parameter to @code{Asm}, + to identify the registers that will be used by your assembly code: + + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx"); + @end group + @end smallexample + + The Clobber parameter is a static string expression specifying the + register(s) you are using. Note that register names are @emph{not} prefixed by a percent sign. + Also, if more than one register is used then their names are separated by commas; e.g., @code{"eax, ebx"} + + The @code{Clobber} parameter has several additional uses: + @enumerate + @item Use the "register" name @code{cc} to indicate that flags might have changed + @item Use the "register" name @code{memory} if you changed a memory location + @end enumerate + + @c --------------------------------------------------------------------------- + @node The Volatile Parameter + @subsection The @code{Volatile} Parameter + @cindex Volatile parameter + + @noindent + Compiler optimizations in the presence of Inline Assembler may sometimes have unwanted effects. + For example, when + an @code{Asm} invocation with an input variable is inside a loop, the compiler might move + the loading of the input variable outside the loop, regarding it as a + one-time initialization. + + If this effect is not desired, you can disable such optimizations by setting the + @code{Volatile} parameter to @code{True}; for example: + + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx", + Volatile => True); + @end group + @end smallexample + + By default, @code{Volatile} is set to @code{False} unless there is no @code{Outputs} + parameter. + + Although setting @code{Volatile} to @code{True} prevents unwanted optimizations, + it will also disable other optimizations that might be important for efficiency. + In general, you should set @code{Volatile} to @code{True} only if the compiler's + optimizations have created problems. + + @c --------------------------------------------------------------------------- + @node A Complete Example + @section A Complete Example + + @noindent + This section contains a complete program illustrating a realistic usage of GNAT's Inline Assembler + capabilities. It comprises a main procedure @code{Check_CPU} and a package @code{Intel_CPU}. + The package declares a collection of functions that detect the properties of the 32-bit + x86 processor that is running the program. The main procedure invokes these functions + and displays the information. + + The Intel_CPU package could be enhanced by adding functions to + detect the type of x386 co-processor, the processor caching options and + special operations such as the SIMD extensions. + + Although the Intel_CPU package has been written for 32-bit Intel + compatible CPUs, it is OS neutral. It has been tested on DOS, + Windows/NT and Linux. + + @menu + * Check_CPU Procedure:: + * Intel_CPU Package Specification:: + * Intel_CPU Package Body:: + @end menu + + @c --------------------------------------------------------------------------- + @node Check_CPU Procedure + @subsection @code{Check_CPU} Procedure + @cindex Check_CPU procedure + + @smallexample + --------------------------------------------------------------------- + -- -- + -- Uses the Intel_CPU package to identify the CPU the program is -- + -- running on, and some of the features it supports. -- + -- -- + --------------------------------------------------------------------- + + with Intel_CPU; -- Intel CPU detection functions + with Ada.Text_IO; -- Standard text I/O + with Ada.Command_Line; -- To set the exit status + + procedure Check_CPU is + + Type_Found : Boolean := False; + -- Flag to indicate that processor was identified + + Features : Intel_CPU.Processor_Features; + -- The processor features + + Signature : Intel_CPU.Processor_Signature; + -- The processor type signature + + begin + + ----------------------------------- + -- Display the program banner. -- + ----------------------------------- + + Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name & + ": check Intel CPU version and features, v1.0"); + Ada.Text_IO.Put_Line ("distribute freely, but no warranty whatsoever"); + Ada.Text_IO.New_Line; + + ----------------------------------------------------------------------- + -- We can safely start with the assumption that we are on at least -- + -- a x386 processor. If the CPUID instruction is present, then we -- + -- have a later processor type. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Has_CPUID = False then + + -- No CPUID instruction, so we assume this is indeed a x386 + -- processor. We can still check if it has a FP co-processor. + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line + ("x386-type processor with a FP co-processor"); + else + Ada.Text_IO.Put_Line + ("x386-type processor without a FP co-processor"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check for CPUID + + ----------------------------------------------------------------------- + -- If CPUID is supported, check if this is a true Intel processor, -- + -- if it is not, display a warning. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Vendor_ID /= Intel_CPU.Intel_Processor then + Ada.Text_IO.Put_Line ("*** This is a Intel compatible processor"); + Ada.Text_IO.Put_Line ("*** Some information may be incorrect"); + end if; -- check if Intel + + ---------------------------------------------------------------------- + -- With the CPUID instruction present, we can assume at least a -- + -- x486 processor. If the CPUID support level is < 1 then we have -- + -- to leave it at that. -- + ---------------------------------------------------------------------- + + if Intel_CPU.CPUID_Level < 1 then + + -- Ok, this is a x486 processor. we still can get the Vendor ID + Ada.Text_IO.Put_Line ("x486-type processor"); + Ada.Text_IO.Put_Line ("Vendor ID is " & Intel_CPU.Vendor_ID); + + -- We can also check if there is a FPU present + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line ("Floating-Point support"); + else + Ada.Text_IO.Put_Line ("No Floating-Point support"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check CPUID level + + --------------------------------------------------------------------- + -- With a CPUID level of 1 we can use the processor signature to -- + -- determine it's exact type. -- + --------------------------------------------------------------------- + + Signature := Intel_CPU.Signature; + + ---------------------------------------------------------------------- + -- Ok, now we go into a lot of messy comparisons to get the -- + -- processor type. For clarity, no attememt to try to optimize the -- + -- comparisons has been made. Note that since Intel_CPU does not -- + -- support getting cache info, we cannot distinguish between P5 -- + -- and Celeron types yet. -- + ---------------------------------------------------------------------- + + -- x486SL + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486SL processor"); + end if; + + -- x486DX2 Write-Back + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0111# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Write-Back Enhanced x486DX2 processor"); + end if; + + -- x486DX4 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 processor"); + end if; + + -- x486DX4 Overdrive + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 OverDrive processor"); + end if; + + -- Pentium (60, 66) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium processor (60, 66)"); + end if; + + -- Pentium (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive (60, 66) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium OverDrive processor (60, 66)"); + end if; + + -- Pentium OverDrive (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive cpu (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive processor for x486 processor-based systems + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor for x486 processor-based systems"); + end if; + + -- Pentium processor with MMX technology (166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor with MMX technology (166, 200)"); + end if; + + -- Pentium OverDrive with MMX for Pentium (75, 90, 100, 120, 133) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor with MMX " & + "technology for Pentium processor (75, 90, 100, 120, 133)"); + end if; + + -- Pentium Pro processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro processor"); + end if; + + -- Pentium II processor, model 3 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium II processor, model 3"); + end if; + + -- Pentium II processor, model 5 or Celeron processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0101# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium II processor, model 5 or Celeron processor"); + end if; + + -- Pentium Pro OverDrive processor + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro OverDrive processor"); + end if; + + -- If no type recognized, we have an unknown. Display what + -- we _do_ know + if Type_Found = False then + Ada.Text_IO.Put_Line ("Unknown processor"); + end if; + + ----------------------------------------- + -- Display processor stepping level. -- + ----------------------------------------- + + Ada.Text_IO.Put_Line ("Stepping level:" & Signature.Stepping'Img); + + --------------------------------- + -- Display vendor ID string. -- + --------------------------------- + + Ada.Text_IO.Put_Line ("Vendor ID: " & Intel_CPU.Vendor_ID); + + ------------------------------------ + -- Get the processors features. -- + ------------------------------------ + + Features := Intel_CPU.Features; + + ----------------------------- + -- Check for a FPU unit. -- + ----------------------------- + + if Features.FPU = True then + Ada.Text_IO.Put_Line ("Floating-Point unit available"); + else + Ada.Text_IO.Put_Line ("no Floating-Point unit"); + end if; -- check for FPU + + -------------------------------- + -- List processor features. -- + -------------------------------- + + Ada.Text_IO.Put_Line ("Supported features: "); + + -- Virtual Mode Extension + if Features.VME = True then + Ada.Text_IO.Put_Line (" VME - Virtual Mode Extension"); + end if; + + -- Debugging Extension + if Features.DE = True then + Ada.Text_IO.Put_Line (" DE - Debugging Extension"); + end if; + + -- Page Size Extension + if Features.PSE = True then + Ada.Text_IO.Put_Line (" PSE - Page Size Extension"); + end if; + + -- Time Stamp Counter + if Features.TSC = True then + Ada.Text_IO.Put_Line (" TSC - Time Stamp Counter"); + end if; + + -- Model Specific Registers + if Features.MSR = True then + Ada.Text_IO.Put_Line (" MSR - Model Specific Registers"); + end if; + + -- Physical Address Extension + if Features.PAE = True then + Ada.Text_IO.Put_Line (" PAE - Physical Address Extension"); + end if; + + -- Machine Check Extension + if Features.MCE = True then + Ada.Text_IO.Put_Line (" MCE - Machine Check Extension"); + end if; + + -- CMPXCHG8 instruction supported + if Features.CX8 = True then + Ada.Text_IO.Put_Line (" CX8 - CMPXCHG8 instruction"); + end if; + + -- on-chip APIC hardware support + if Features.APIC = True then + Ada.Text_IO.Put_Line (" APIC - on-chip APIC hardware support"); + end if; + + -- Fast System Call + if Features.SEP = True then + Ada.Text_IO.Put_Line (" SEP - Fast System Call"); + end if; + + -- Memory Type Range Registers + if Features.MTRR = True then + Ada.Text_IO.Put_Line (" MTTR - Memory Type Range Registers"); + end if; + + -- Page Global Enable + if Features.PGE = True then + Ada.Text_IO.Put_Line (" PGE - Page Global Enable"); + end if; + + -- Machine Check Architecture + if Features.MCA = True then + Ada.Text_IO.Put_Line (" MCA - Machine Check Architecture"); + end if; + + -- Conditional Move Instruction Supported + if Features.CMOV = True then + Ada.Text_IO.Put_Line + (" CMOV - Conditional Move Instruction Supported"); + end if; + + -- Page Attribute Table + if Features.PAT = True then + Ada.Text_IO.Put_Line (" PAT - Page Attribute Table"); + end if; + + -- 36-bit Page Size Extension + if Features.PSE_36 = True then + Ada.Text_IO.Put_Line (" PSE_36 - 36-bit Page Size Extension"); + end if; + + -- MMX technology supported + if Features.MMX = True then + Ada.Text_IO.Put_Line (" MMX - MMX technology supported"); + end if; + + -- Fast FP Save and Restore + if Features.FXSR = True then + Ada.Text_IO.Put_Line (" FXSR - Fast FP Save and Restore"); + end if; + + --------------------- + -- Program done. -- + --------------------- + + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + + exception + + when others => + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); + raise; + + end Check_CPU; + @end smallexample + + @c --------------------------------------------------------------------------- + @node Intel_CPU Package Specification + @subsection @code{Intel_CPU} Package Specification + @cindex Intel_CPU package specification + + @smallexample + ------------------------------------------------------------------------- + -- -- + -- file: INTEL_CPU.ADS -- + -- -- + -- ********************************************* -- + -- * WARNING: for 32-bit Intel processors only * -- + -- ********************************************* -- + -- -- + -- This package contains a number of subprograms that are useful in -- + -- determining the Intel x86 CPU (and the features it supports) on -- + -- which the program is running. -- + -- -- + -- The package is based upon the information given in the Intel -- + -- Application Note AP-485: "Intel Processor Identification and the -- + -- CPUID Instruction" as of April 1998. This application note can be -- + -- found on www.intel.com. -- + -- -- + -- It currently deals with 32-bit processors only, will not detect -- + -- features added after april 1998, and does not guarantee proper -- + -- results on Intel-compatible processors. -- + -- -- + -- Cache info and x386 fpu type detection are not supported. -- + -- -- + -- This package does not use any privileged instructions, so should -- + -- work on any OS running on a 32-bit Intel processor. -- + -- -- + ------------------------------------------------------------------------- + + with Interfaces; use Interfaces; + -- for using unsigned types + + with System.Machine_Code; use System.Machine_Code; + -- for using inline assembler code + + with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; + -- for inserting control characters + + package Intel_CPU is + + ---------------------- + -- Processor bits -- + ---------------------- + + subtype Num_Bits is Natural range 0 .. 31; + -- the number of processor bits (32) + + -------------------------- + -- Processor register -- + -------------------------- + + -- define a processor register type for easy access to + -- the individual bits + + type Processor_Register is array (Num_Bits) of Boolean; + pragma Pack (Processor_Register); + for Processor_Register'Size use 32; + + ------------------------- + -- Unsigned register -- + ------------------------- + + -- define a processor register type for easy access to + -- the individual bytes + + type Unsigned_Register is + record + L1 : Unsigned_8; + H1 : Unsigned_8; + L2 : Unsigned_8; + H2 : Unsigned_8; + end record; + + for Unsigned_Register use + record + L1 at 0 range 0 .. 7; + H1 at 0 range 8 .. 15; + L2 at 0 range 16 .. 23; + H2 at 0 range 24 .. 31; + end record; + + for Unsigned_Register'Size use 32; + + --------------------------------- + -- Intel processor vendor ID -- + --------------------------------- + + Intel_Processor : constant String (1 .. 12) := "GenuineIntel"; + -- indicates an Intel manufactured processor + + ------------------------------------ + -- Processor signature register -- + ------------------------------------ + + -- a register type to hold the processor signature + + type Processor_Signature is + record + Stepping : Natural range 0 .. 15; + Model : Natural range 0 .. 15; + Family : Natural range 0 .. 15; + Processor_Type : Natural range 0 .. 3; + Reserved : Natural range 0 .. 262143; + end record; + + for Processor_Signature use + record + Stepping at 0 range 0 .. 3; + Model at 0 range 4 .. 7; + Family at 0 range 8 .. 11; + Processor_Type at 0 range 12 .. 13; + Reserved at 0 range 14 .. 31; + end record; + + for Processor_Signature'Size use 32; + + ----------------------------------- + -- Processor features register -- + ----------------------------------- + + -- a processor register to hold the processor feature flags + + type Processor_Features is + record + FPU : Boolean; -- floating point unit on chip + VME : Boolean; -- virtual mode extension + DE : Boolean; -- debugging extension + PSE : Boolean; -- page size extension + TSC : Boolean; -- time stamp counter + MSR : Boolean; -- model specific registers + PAE : Boolean; -- physical address extension + MCE : Boolean; -- machine check extension + CX8 : Boolean; -- cmpxchg8 instruction + APIC : Boolean; -- on-chip apic hardware + Res_1 : Boolean; -- reserved for extensions + SEP : Boolean; -- fast system call + MTRR : Boolean; -- memory type range registers + PGE : Boolean; -- page global enable + MCA : Boolean; -- machine check architecture + CMOV : Boolean; -- conditional move supported + PAT : Boolean; -- page attribute table + PSE_36 : Boolean; -- 36-bit page size extension + Res_2 : Natural range 0 .. 31; -- reserved for extensions + MMX : Boolean; -- MMX technology supported + FXSR : Boolean; -- fast FP save and restore + Res_3 : Natural range 0 .. 127; -- reserved for extensions + end record; + + for Processor_Features use + record + FPU at 0 range 0 .. 0; + VME at 0 range 1 .. 1; + DE at 0 range 2 .. 2; + PSE at 0 range 3 .. 3; + TSC at 0 range 4 .. 4; + MSR at 0 range 5 .. 5; + PAE at 0 range 6 .. 6; + MCE at 0 range 7 .. 7; + CX8 at 0 range 8 .. 8; + APIC at 0 range 9 .. 9; + Res_1 at 0 range 10 .. 10; + SEP at 0 range 11 .. 11; + MTRR at 0 range 12 .. 12; + PGE at 0 range 13 .. 13; + MCA at 0 range 14 .. 14; + CMOV at 0 range 15 .. 15; + PAT at 0 range 16 .. 16; + PSE_36 at 0 range 17 .. 17; + Res_2 at 0 range 18 .. 22; + MMX at 0 range 23 .. 23; + FXSR at 0 range 24 .. 24; + Res_3 at 0 range 25 .. 31; + end record; + + for Processor_Features'Size use 32; + + ------------------- + -- Subprograms -- + ------------------- + + function Has_FPU return Boolean; + -- return True if a FPU is found + -- use only if CPUID is not supported + + function Has_CPUID return Boolean; + -- return True if the processor supports the CPUID instruction + + function CPUID_Level return Natural; + -- return the CPUID support level (0, 1 or 2) + -- can only be called if the CPUID instruction is supported + + function Vendor_ID return String; + -- return the processor vendor identification string + -- can only be called if the CPUID instruction is supported + + function Signature return Processor_Signature; + -- return the processor signature + -- can only be called if the CPUID instruction is supported + + function Features return Processor_Features; + -- return the processors features + -- can only be called if the CPUID instruction is supported + + private + + ------------------------ + -- EFLAGS bit names -- + ------------------------ + + ID_Flag : constant Num_Bits := 21; + -- ID flag bit + + end Intel_CPU; + @end smallexample + + @c --------------------------------------------------------------------------- + @node Intel_CPU Package Body + @subsection @code{Intel_CPU} Package Body + @cindex Intel_CPU package body + + @smallexample + package body Intel_CPU is + + --------------------------- + -- Detect FPU presence -- + --------------------------- + + -- There is a FPU present if we can set values to the FPU Status + -- and Control Words. + + function Has_FPU return Boolean is + + Register : Unsigned_16; + -- processor register to store a word + + begin + + -- check if we can change the status word + Asm ( + + -- the assembler code + "finit" & LF & HT & -- reset status word + "movw $0x5A5A, %%ax" & LF & HT & -- set value status word + "fnstsw %0" & LF & HT & -- save status word + "movw %%ax, %0", -- store status word + + -- output stored in Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register), + + -- tell compiler that we used eax + Clobber => "eax"); + + -- if the status word is zero, there is no FPU + if Register = 0 then + return False; -- no status word + end if; -- check status word value + + -- check if we can get the control word + Asm ( + + -- the assembler code + "fnstcw %0", -- save the control word + + -- output into Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register)); + + -- check the relevant bits + if (Register and 16#103F#) /= 16#003F# then + return False; -- no control word + end if; -- check control word value + + -- FPU found + return True; + + end Has_FPU; + + -------------------------------- + -- Detect CPUID instruction -- + -------------------------------- + + -- The processor supports the CPUID instruction if it is possible + -- to change the value of ID flag bit in the EFLAGS register. + + function Has_CPUID return Boolean is + + Original_Flags, Modified_Flags : Processor_Register; + -- EFLAG contents before and after changing the ID flag + + begin + + -- try flipping the ID flag in the EFLAGS register + Asm ( + + -- the assembler code + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %%eax" & LF & HT & -- pop EFLAGS into eax + "movl %%eax, %0" & LF & HT & -- save EFLAGS content + "xor $0x200000, %%eax" & LF & HT & -- flip ID flag + "push %%eax" & LF & HT & -- push EFLAGS on stack + "popfl" & LF & HT & -- load EFLAGS register + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %1", -- save EFLAGS content + + -- output values, may be anything + -- Original_Flags is %0 + -- Modified_Flags is %1 + Outputs => + (Processor_Register'Asm_output ("=g", Original_Flags), + Processor_Register'Asm_output ("=g", Modified_Flags)), + + -- tell compiler eax is destroyed + Clobber => "eax"); + + -- check if CPUID is supported + if Original_Flags(ID_Flag) /= Modified_Flags(ID_Flag) then + return True; -- ID flag was modified + else + return False; -- ID flag unchanged + end if; -- check for CPUID + + end Has_CPUID; + + ------------------------------- + -- Get CPUID support level -- + ------------------------------- + + function CPUID_Level return Natural is + + Level : Unsigned_32; + -- returned support level + + begin + + -- execute CPUID, storing the results in the Level register + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero is stored in eax + -- returning the support level in eax + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- eax is stored in Level + Outputs => Unsigned_32'Asm_output ("=a", Level), + + -- tell compiler ebx, ecx and edx registers are destroyed + Clobber => "ebx, ecx, edx"); + + -- return the support level + return Natural (Level); + + end CPUID_Level; + + -------------------------------- + -- Get CPU Vendor ID String -- + -------------------------------- + + -- The vendor ID string is returned in the ebx, ecx and edx register + -- after executing the CPUID instruction with eax set to zero. + -- In case of a true Intel processor the string returned is + -- "GenuineIntel" + + function Vendor_ID return String is + + Ebx, Ecx, Edx : Unsigned_Register; + -- registers containing the vendor ID string + + Vendor_ID : String (1 .. 12); + -- the vendor ID string + + begin + + -- execute CPUID, storing the results in the processor registers + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero stored in eax + -- vendor ID string returned in ebx, ecx and edx + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- ebx is stored in Ebx + -- ecx is stored in Ecx + -- edx is stored in Edx + Outputs => (Unsigned_Register'Asm_output ("=b", Ebx), + Unsigned_Register'Asm_output ("=c", Ecx), + Unsigned_Register'Asm_output ("=d", Edx))); + + -- now build the vendor ID string + Vendor_ID( 1) := Character'Val (Ebx.L1); + Vendor_ID( 2) := Character'Val (Ebx.H1); + Vendor_ID( 3) := Character'Val (Ebx.L2); + Vendor_ID( 4) := Character'Val (Ebx.H2); + Vendor_ID( 5) := Character'Val (Edx.L1); + Vendor_ID( 6) := Character'Val (Edx.H1); + Vendor_ID( 7) := Character'Val (Edx.L2); + Vendor_ID( 8) := Character'Val (Edx.H2); + Vendor_ID( 9) := Character'Val (Ecx.L1); + Vendor_ID(10) := Character'Val (Ecx.H1); + Vendor_ID(11) := Character'Val (Ecx.L2); + Vendor_ID(12) := Character'Val (Ecx.H2); + + -- return string + return Vendor_ID; + + end Vendor_ID; + + ------------------------------- + -- Get processor signature -- + ------------------------------- + + function Signature return Processor_Signature is + + Result : Processor_Signature; + -- processor signature returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one is stored in eax + -- processor signature returned in eax + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- eax is stored in Result + Outputs => Processor_Signature'Asm_output ("=a", Result), + + -- tell compiler that ebx, ecx and edx are also destroyed + Clobber => "ebx, ecx, edx"); + + -- return processor signature + return Result; + + end Signature; + + ------------------------------ + -- Get processor features -- + ------------------------------ + + function Features return Processor_Features is + + Result : Processor_Features; + -- processor features returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one stored in eax + -- processor features returned in edx + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- edx is stored in Result + Outputs => Processor_Features'Asm_output ("=d", Result), + + -- tell compiler that ebx and ecx are also destroyed + Clobber => "ebx, ecx"); + + -- return processor signature + return Result; + + end Features; + + end Intel_CPU; + @end smallexample + @c END OF INLINE ASSEMBLER CHAPTER + @c =============================== + + + + + @node Performance Considerations + @chapter Performance Considerations + @cindex Performance + + @noindent + The GNAT system provides a number of options that allow a trade-off + between + + @itemize @bullet + @item + performance of the generated code + + @item + speed of compilation + + @item + minimization of dependences and recompilation + + @item + the degree of run-time checking. + @end itemize + + @noindent + The defaults (if no options are selected) aim at improving the speed + of compilation and minimizing dependences, at the expense of performance + of the generated code: + + @itemize @bullet + @item + no optimization + + @item + no inlining of subprogram calls + + @item + all run-time checks enabled except overflow and elaboration checks + @end itemize + + @noindent + These options are suitable for most program development purposes. This + chapter describes how you can modify these choices, and also provides + some guidelines on debugging optimized code. + + @menu + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + * Coverage Analysis:: + @end menu + + @node Controlling Run-Time Checks + @section Controlling Run-Time Checks + + @noindent + By default, GNAT generates all run-time checks, except arithmetic overflow + checking for integer operations and checks for access before elaboration on + subprogram calls. The latter are not required in default mode, because all + necessary checking is done at compile time. + @cindex @option{/CHECKS=SUPPRESS_ALL} (@code{GNAT COMPILE}) + @cindex @option{/CHECKS=OVERFLOW} (@code{GNAT COMPILE}) + Two gnat qualifiers, @option{/CHECKS=SUPPRESS_ALL} and @option{/CHECKS=OVERFLOW} allow this default to + be modified. @xref{Run-Time Checks}. + + Our experience is that the default is suitable for most development + purposes. + + We treat integer overflow specially because these + are quite expensive and in our experience are not as important as other + run-time checks in the development process. Note that division by zero + is not considered an overflow check, and divide by zero checks are + generated where required by default. + + Elaboration checks are off by default, and also not needed by default, since + GNAT uses a static elaboration analysis approach that avoids the need for + run-time checking. This manual contains a full chapter discussing the issue + of elaboration checks, and if the default is not satisfactory for your use, + you should read this chapter. + + For validity checks, the minimal checks required by the Ada Reference + Manual (for case statements and assignments to array elements) are on + by default. These can be suppressed by use of the @option{-gnatVn} qualifier. + Note that in Ada 83, there were no validity checks, so if the Ada 83 mode + is acceptable (or when comparing GNAT performance with an Ada 83 compiler), + it may be reasonable to routinely use @option{-gnatVn}. Validity checks + are also suppressed entirely if @option{/CHECKS=SUPPRESS_ALL} is used. + + @cindex Overflow checks + @cindex Checks, overflow + @findex Suppress + @findex Unsuppress + @cindex pragma Suppress + @cindex pragma Unsuppress + Note that the setting of the qualifiers controls the default setting of + the checks. They may be modified using either @code{pragma Suppress} (to + remove checks) or @code{pragma Unsuppress} (to add back suppressed + checks) in the program source. + + @node Optimization Levels + @section Optimization Levels + @cindex @code{/OPTIMIZE} (@code{GNAT COMPILE}) + + @noindent + The default is optimization off. This results in the fastest compile + times, but GNAT makes absolutely no attempt to optimize, and the + generated programs are considerably larger and slower than when + optimization is enabled. You can use the + @code{/OPTIMIZE} + on the @code{GNAT COMPILE} command line to control the optimization level: + + @table @code + @item /OPTIMIZE=NONE + no optimization (the default) + + @item /OPTIMIZE=SOME + medium level optimization + + @item /OPTIMIZE=ALL + full optimization + + @item /OPTIMIZE=INLINING + full optimization, and also attempt automatic inlining of small + subprograms within a unit (@pxref{Inlining of Subprograms}). + @end table + + Higher optimization levels perform more global transformations on the + program and apply more expensive analysis algorithms in order to generate + faster and more compact code. The price in compilation time, and the + resulting improvement in execution time, + both depend on the particular application and the hardware environment. + You should experiment to find the best level for your application. + + Note: Unlike some other compilation systems, @code{GNAT COMPILE} has + been tested extensively at all optimization levels. There are some bugs + which appear only with optimization turned on, but there have also been + bugs which show up only in @emph{unoptimized} code. Selecting a lower + level of optimization does not improve the reliability of the code + generator, which in practice is highly reliable at all optimization + levels. + + Note regarding the use of @code{/OPTIMIZE=INLINING}: The use of this optimization level + is generally discouraged with GNAT, since it often results in larger + executables which run more slowly. See further discussion of this point + in @pxref{Inlining of Subprograms}. + + @node Debugging Optimized Code + @section Debugging Optimized Code + + @noindent + Since the compiler generates debugging tables for a compilation unit before + it performs optimizations, the optimizing transformations may invalidate some + of the debugging data. You therefore need to anticipate certain + anomalous situations that may arise while debugging optimized code. This + section describes the most common cases. + + @enumerate + @item + @i{The "hopping Program Counter":} Repeated 'step' or 'next' commands show the PC + bouncing back and forth in the code. This may result from any of the following + optimizations: + + @itemize @bullet + @item + @i{Common subexpression elimination:} using a single instance of code for a + quantity that the source computes several times. As a result you + may not be able to stop on what looks like a statement. + + @item + @i{Invariant code motion:} moving an expression that does not change within a + loop, to the beginning of the loop. + + @item + @i{Instruction scheduling:} moving instructions so as to + overlap loads and stores (typically) with other code, or in + general to move computations of values closer to their uses. Often + this causes you to pass an assignment statement without the assignment + happening and then later bounce back to the statement when the + value is actually needed. Placing a breakpoint on a line of code + and then stepping over it may, therefore, not always cause all the + expected side-effects. + @end itemize + + @item + @i{The "big leap":} More commonly known as @i{cross-jumping}, in which two + identical pieces of code are merged and the program counter suddenly + jumps to a statement that is not supposed to be executed, simply because + it (and the code following) translates to the same thing as the code + that @emph{was} supposed to be executed. This effect is typically seen in + sequences that end in a jump, such as a @code{goto}, a @code{return}, or + a @code{break} in a C @code{qualifier} statement. + + @item + @i{The "roving variable":} The symptom is an unexpected value in a variable. + There are various reasons for this effect: + + @itemize @bullet + @item + In a subprogram prologue, a parameter may not yet have been moved to its + "home". + + @item + A variable may be dead, and its register re-used. This is + probably the most common cause. + + @item + As mentioned above, the assignment of a value to a variable may + have been moved. + + @item + A variable may be eliminated entirely by value propagation or + other means. In this case, GCC may incorrectly generate debugging + information for the variable + @end itemize + + @noindent + In general, when an unexpected value appears for a local variable or parameter + you should first ascertain if that value was actually computed by + your program, as opposed to being incorrectly reported by the debugger. + Record fields or + array elements in an object designated by an access value + are generally less of a problem, once you have ascertained that the access value + is sensible. + Typically, this means checking variables in the preceding code and in the + calling subprogram to verify that the value observed is explainable from other + values (one must apply the procedure recursively to those + other values); or re-running the code and stopping a little earlier + (perhaps before the call) and stepping to better see how the variable obtained + the value in question; or continuing to step @emph{from} the point of the + strange value to see if code motion had simply moved the variable's + assignments later. + @end enumerate + + @node Inlining of Subprograms + @section Inlining of Subprograms + + @noindent + A call to a subprogram in the current unit is inlined if all the + following conditions are met: + + @itemize @bullet + @item + The optimization level is at least @code{/OPTIMIZE=SOME}. + + @item + The called subprogram is suitable for inlining: It must be small enough + and not contain nested subprograms or anything else that @code{GNAT COMPILE} + cannot support in inlined subprograms. + + @item + The call occurs after the definition of the body of the subprogram. + + @item + @cindex pragma Inline + @findex Inline + Either @code{pragma Inline} applies to the subprogram or it is + small and automatic inlining (optimization level @code{/OPTIMIZE=INLINING}) is + specified. + @end itemize + + @noindent + Calls to subprograms in @code{with}'ed units are normally not inlined. + To achieve this level of inlining, the following conditions must all be + true: + + @itemize @bullet + @item + The optimization level is at least @code{/OPTIMIZE=SOME}. + + @item + The called subprogram is suitable for inlining: It must be small enough + and not contain nested subprograms or anything else @code{GNAT COMPILE} cannot + support in inlined subprograms. + + @item + The call appears in a body (not in a package spec). + + @item + There is a @code{pragma Inline} for the subprogram. + + @item + @cindex @option{/INLINE=PRAGMA} (@code{GNAT COMPILE}) + The @code{/INLINE} qualifier + is used in the @code{GNAT COMPILE} command line + @end itemize + + Note that specifying the @option{/INLINE=PRAGMA} qualifier causes additional + compilation dependencies. Consider the following: + + @smallexample + @group + @cartouche + @b{package} R @b{is} + @b{procedure} Q; + @b{pragma} Inline (Q); + @b{end} R; + @b{package body} R @b{is} + ... + @b{end} R; + + @b{with} R; + @b{procedure} Main @b{is} + @b{begin} + ... + R.Q; + @b{end} Main; + @end cartouche + @end group + @end smallexample + + @noindent + With the default behavior (no @option{/INLINE=PRAGMA} qualifier specified), the + compilation of the @code{Main} procedure depends only on its own source, + @file{MAIN.ADB}, and the spec of the package in file @file{R.ADS}. This + means that editing the body of @code{R} does not require recompiling + @code{Main}. + + On the other hand, the call @code{R.Q} is not inlined under these + circumstances. If the @option{/INLINE=PRAGMA} qualifier is present when @code{Main} + is compiled, the call will be inlined if the body of @code{Q} is small + enough, but now @code{Main} depends on the body of @code{R} in + @file{R.ADB} as well as on the spec. This means that if this body is edited, + the main program must be recompiled. Note that this extra dependency + occurs whether or not the call is in fact inlined by @code{GNAT COMPILE}. + + The use of front end inlining with @option{-gnatN} generates similar + additional dependencies. + + @cindex @code{/INLINE=SUPPRESS} (@code{GNAT COMPILE}) + Note: The @code{/INLINE=SUPPRESS} qualifier + can be used to prevent + all inlining. This qualifier overrides all other conditions and ensures + that no inlining occurs. The extra dependences resulting from + @option{/INLINE=PRAGMA} will still be active, even if + this qualifier is used to suppress the resulting inlining actions. + + Note regarding the use of @code{/OPTIMIZE=INLINING}: There is no difference in inlining + behavior between @code{/OPTIMIZE=ALL} and @code{/OPTIMIZE=INLINING} for subprograms with an explicit + pragma @code{Inline} assuming the use of @option{/INLINE=PRAGMA} + or @option{-gnatN} (the qualifiers that activate inlining). If you have used + pragma @code{Inline} in appropriate cases, then it is usually much better + to use @code{/OPTIMIZE=ALL} and @option{/INLINE=PRAGMA} and avoid the use of @code{/OPTIMIZE=INLINING} which + in this case only has the effect of inlining subprograms you did not + think should be inlined. We often find that the use of @code{/OPTIMIZE=INLINING} slows + down code by performing excessive inlining, leading to increased instruction + cache pressure from the increased code size. So the bottom line here is + that you should not automatically assume that @code{/OPTIMIZE=INLINING} is better than + @code{/OPTIMIZE=ALL}, and indeed you should use @code{/OPTIMIZE=INLINING} only if tests show that + it actually improves performance. + + @node Coverage Analysis + @section Coverage Analysis + + @noindent + GNAT supports the Digital Performance Coverage Analyzer (PCA), which allows + the user to determine the distribution of execution time across a program, + @pxref{Profiling} for details of usage. + + @include fdl.texi + @c GNU Free Documentation License + + @node Index,,GNU Free Documentation License, Top + @unnumbered Index + + @printindex cp + + @contents + + @bye diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_ug_vxw.info gcc-3.3/gcc/ada/gnat_ug_vxw.info *** gcc-3.2.3/gcc/ada/gnat_ug_vxw.info 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_ug_vxw.info 2003-05-14 00:31:47.000000000 +0000 *************** *** 0 **** --- 1,18960 ---- + This is ada/gnat_ug_vxw.info, produced by makeinfo version 4.2 from + ada/gnat_ug_vxw.texi. + + Copyright (C) 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT User's Guide for Cross Platforms", and + with no Back-Cover Texts. A copy of the license is included in the + section entitled "GNU Free Documentation License". +  + File: gnat_ug_vxw.info, Node: Top, Next: About This Guide, Prev: (dir), Up: (dir) + + GNAT User's Guide + ***************** + + GNAT User's Guide for Cross Platforms + + GNAT, The GNU Ada 95 Compiler + + GNAT Version for GCC 3.3 + + Ada Core Technologies, Inc. + + Copyright (C) 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT User's Guide for Cross Platforms", and + with no Back-Cover Texts. A copy of the license is included in the + section entitled "GNU Free Documentation License". + * Menu: + + * About This Guide:: + * Preliminary Note for Cross Platform Users:: + * Getting Started with GNAT:: + * The GNAT Compilation Model:: + * Compiling Using gcc:: + * Binding Using gnatbind:: + * Linking Using gnatlink:: + * The GNAT Make Program gnatmake:: + * Renaming Files Using gnatchop:: + * Configuration Pragmas:: + * Handling Arbitrary File Naming Conventions Using gnatname:: + * GNAT Project Manager:: + * Elaboration Order Handling in GNAT:: + * The Cross-Referencing Tools gnatxref and gnatfind:: + * File Name Krunching Using gnatkr:: + * Preprocessing Using gnatprep:: + * The GNAT Library Browser gnatls:: + * GNAT and Libraries:: + * Using the GNU make Utility:: + * Finding Memory Problems with GNAT Debug Pool:: + * Creating Sample Bodies Using gnatstub:: + * Reducing the Size of Ada Executables with gnatelim:: + * Other Utility Programs:: + * Running and Debugging Ada Programs:: + * Inline Assembler:: + * VxWorks Topics:: + * LynxOS Topics:: + * Performance Considerations:: + * GNU Free Documentation License:: + * Index:: + + --- The Detailed Node Listing --- + + About This Guide + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + + Preliminary Note for Cross Platform Users:: + + Getting Started with GNAT + + * Running GNAT:: + * Building a Simple Ada Program:: + * Executing a Program on VxWorks:: + * Running a Program with Multiple Units:: + * Using the gnatmake Utility:: + + The GNAT Compilation Model + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + Foreign Language Representation + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + + Compiling Ada Programs With gcc + + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + + Switches for gcc + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + Binding Ada Programs With gnatbind + + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + + Linking Using gnatlink + + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + + The GNAT Make Program gnatmake + + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + + Renaming Files Using gnatchop + + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + + Configuration Pragmas + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + + Handling Arbitrary File Naming Conventions Using gnatname + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + + GNAT Project Manager + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + + Elaboration Order Handling in GNAT + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + The Cross-Referencing Tools gnatxref and gnatfind + + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + + File Name Krunching Using gnatkr + + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + + Preprocessing Using gnatprep + + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + + + The GNAT Library Browser gnatls + + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + + + GNAT and Libraries + + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + + Using the GNU make Utility + + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + + + Finding Memory Problems with GNAT Debug Pool + + Creating Sample Bodies Using gnatstub + + * Running gnatstub:: + * Switches for gnatstub:: + + Reducing the Size of Ada Executables with gnatelim + + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + + Other Utility Programs + + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + + + Running and Debugging Ada Programs + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + + Inline Assembler + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + + + VxWorks Topics + + * Kernel Configuration for VxWorks:: + * Kernel Compilation Issues for VxWorks:: + * Handling Relocation Issues for PowerPc Targets:: + * Support for Software Floating Point on PowerPC Processors:: + * Interrupt Handling for VxWorks:: + * Simulating Command Line Arguments for VxWorks:: + * Debugging Issues for VxWorks:: + * Using GNAT from the Tornado 2 Project Facility:: + * Frequently Asked Questions for VxWorks:: + + LynxOS Topics + + * Getting Started with GNAT on LynxOS:: + * Kernel Configuration for LynxOS:: + * Patch Level Issues for LynxOS:: + * Debugging Issues for LynxOS:: + * An Example Debugging Session for LynxOS:: + + Performance Considerations + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + + * Index:: + +  + File: gnat_ug_vxw.info, Node: About This Guide, Next: Preliminary Note for Cross Platform Users, Prev: Top, Up: Top + + About This Guide + **************** + + This guide describes the use of GNAT, a compiler and software + development toolset for the full Ada 95 programming language. It + describes the features of the compiler and tools, and details how to + use them to build Ada 95 applications. + + * Menu: + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + +  + File: gnat_ug_vxw.info, Node: What This Guide Contains, Next: What You Should Know before Reading This Guide, Up: About This Guide + + What This Guide Contains + ======================== + + This guide contains the following chapters: + * *Note Preliminary Note for Cross Platform Users::, describes the + basic differences between the cross and native versions of GNAT. + + * *Note Getting Started with GNAT::, describes how to get started + compiling and running Ada programs with the GNAT Ada programming + environment. + + * *Note The GNAT Compilation Model::, describes the compilation + model used by GNAT. + + * *Note Compiling Using gcc::, describes how to compile Ada programs + with `gcc', the Ada compiler. + + * *Note Binding Using gnatbind::, describes how to perform binding + of Ada programs with `gnatbind', the GNAT binding utility. + + * *Note Linking Using gnatlink::, describes `gnatlink', a program + that provides for linking using the GNAT run-time library to + construct a program. `gnatlink' can also incorporate foreign + language object units into the executable. + + * *Note The GNAT Make Program gnatmake::, describes `gnatmake', a + utility that automatically determines the set of sources needed by + an Ada compilation unit, and executes the necessary compilations + binding and link. + + * *Note Renaming Files Using gnatchop::, describes `gnatchop', a + utility that allows you to preprocess a file that contains Ada + source code, and split it into one or more new files, one for each + compilation unit. + + * *Note Configuration Pragmas::, describes the configuration pragmas + handled by GNAT. + + * *Note Handling Arbitrary File Naming Conventions Using gnatname::, + shows how to override the default GNAT file naming conventions, + either for an individual unit or globally. + + * *Note GNAT Project Manager::, describes how to use project files + to organize large projects. + + * *Note Elaboration Order Handling in GNAT::, describes how GNAT + helps you deal with elaboration order issues. + + * *Note The Cross-Referencing Tools gnatxref and gnatfind::, + discusses `gnatxref' and `gnatfind', two tools that provide an easy + way to navigate through sources. + + * *Note File Name Krunching Using gnatkr::, describes the `gnatkr' + file name krunching utility, used to handle shortened file names + on operating systems with a limit on the length of names. + + * *Note Preprocessing Using gnatprep::, describes `gnatprep', a + preprocessor utility that allows a single source file to be used to + generate multiple or parameterized source files, by means of macro + substitution. + + * *Note The GNAT Library Browser gnatls::, describes `gnatls', a + utility that displays information about compiled units, including + dependences on the corresponding sources files, and consistency of + compilations. + + * *Note GNAT and Libraries::, describes the process of creating and + using Libraries with GNAT. It also describes how to recompile the + GNAT run-time library. + + * *Note Using the GNU make Utility::, describes some techniques for + using the GNAT toolset in Makefiles. + + * *Note Finding Memory Problems with GNAT Debug Pool::, describes + how to use the GNAT-specific Debug Pool in order to detect as + early as possible the use of incorrect memory references. + + * *Note Creating Sample Bodies Using gnatstub::, discusses + `gnatstub', a utility that generates empty but compilable bodies + for library units. + + * *Note Reducing the Size of Ada Executables with gnatelim::, + describes `gnatelim', a tool which detects unused subprograms and + helps the compiler to create a smaller executable for the program. + + * *Note Other Utility Programs::, discusses several other GNAT + utilities, including `gnatpsta'. + + * *Note Running and Debugging Ada Programs::, describes how to run + and debug Ada programs. + + * *Note Inline Assembler::, shows how to use the inline assembly + facility in an Ada program. + + * *Note VxWorks Topics::, presents information relevant to the + VxWorks target for cross-compilation configurations. + + * *Note LynxOS Topics::, presents information relevant to the LynxOS + target for cross-compilation configurations. + + * *Note Performance Considerations::, reviews the trade offs between + using defaults or options in program development. + +  + File: gnat_ug_vxw.info, Node: What You Should Know before Reading This Guide, Next: Related Information, Prev: What This Guide Contains, Up: About This Guide + + What You Should Know before Reading This Guide + ============================================== + + This user's guide assumes that you are familiar with Ada 95 language, as + described in the International Standard ANSI/ISO/IEC-8652:1995, Jan + 1995. + +  + File: gnat_ug_vxw.info, Node: Related Information, Next: Conventions, Prev: What You Should Know before Reading This Guide, Up: About This Guide + + Related Information + =================== + + For further information about related tools, refer to the following + documents: + + * `GNAT Reference Manual', which contains all reference material for + the GNAT implementation of Ada 95. + + * `Ada 95 Language Reference Manual', which contains all reference + material for the Ada 95 programming language. + + * `Debugging with GDB' contains all details on the use of the GNU + source-level debugger. + + * `GNU Emacs Manual' contains full information on the extensible + editor and programming environment Emacs. + + +  + File: gnat_ug_vxw.info, Node: Conventions, Prev: Related Information, Up: About This Guide + + Conventions + =========== + + Following are examples of the typographical and graphic conventions used + in this guide: + + * `Functions', `utility program names', `standard names', and + `classes'. + + * `Option flags' + + * `File Names', `button names', and `field names'. + + * VARIABLES. + + * _Emphasis_. + + * [optional information or parameters] + + * Examples are described by text + and then shown this way. + + Commands that are entered by the user are preceded in this manual by the + characters "`$ '" (dollar sign followed by space). If your system uses + this sequence as a prompt, then the commands will appear exactly as you + see them in the manual. If your system uses some other prompt, then the + command will appear with the `$' replaced by whatever prompt character + you are using. + +  + File: gnat_ug_vxw.info, Node: Preliminary Note for Cross Platform Users, Next: Getting Started with GNAT, Prev: About This Guide, Up: Top + + Preliminary Note for Cross Platform Users + ***************************************** + + The use of GNAT in a cross environment is very similar to its use in a + native environment. Most of the tools described in this manual have + similar functions and options in both modes. The major difference is + that the name of the cross tools includes the target for which the + cross compiler is configured. For instance, the cross `gnatmake' tool + is called `target-gnatmake' where `target' stands for the name of the + cross target. Thus, in an environment configured for the target + `powerpc-wrs-vxworks', the `gnatmake' command is + `powerpc-wrs-vxworks-gnatmake'. This convention allows the installation + of a native and one or several cross development environments at the + same location. + + The tools that are most relevant in a cross environment are: + `target-gcc', `target-gnatmake', `target-gnatbind', `target-gnatlink' + to build cross applications and `target-gnatls' for cross library + browsing. `target-gdb' is also usually available for cross debugging in + text mode. The graphical debugger interface `gvd' is always a native + tool but it can be configured to drive the above mentioned cross + debugger, thus allowing graphical cross debugging sessions. Some other + tools such as `target-gnatchop', `target-gnatkr', `target-gnatprep', + `target-gnatpsta', `target-gnatxref', `target-gnatfind' and + `target-gnatname' are also provided for completeness even though they + do not differ greatly from their native counterpart. + + In the rest of this manual, the tools are sometimes designated with + their full cross name, and sometimes with their simplified native name. + +  + File: gnat_ug_vxw.info, Node: Getting Started with GNAT, Next: The GNAT Compilation Model, Prev: Preliminary Note for Cross Platform Users, Up: Top + + Getting Started with GNAT + ************************* + + This introduction is a starting point for using GNAT to develop and + execute Ada 95 programs in a cross environment. It provides some + specifics about the GNAT toolchain targeted to the Wind River Sytems' + VxWorks/Tornado platform; for other targets please refer to the + corresponding chapter later in this manual. + + Basic familiarity with use of GNAT in a native environment is + presumed. For the VxWorks specific part, a knowledge of how to start + Tornado's `windsh' tool is also presumed. + + * Menu: + + * Running GNAT:: + * Building a Simple Ada Program:: + * Executing a Program on VxWorks:: + + * Running a Program with Multiple Units:: + + * Using the gnatmake Utility:: + * Introduction to Glide and GVD:: + +  + File: gnat_ug_vxw.info, Node: Running GNAT, Next: Building a Simple Ada Program, Up: Getting Started with GNAT + + Running GNAT + ============ + + Three steps are needed to create an executable file from an Ada source + file: + + 1. The source file(s) must be compiled. + + 2. The file(s) must be bound using the GNAT binder. + + 3. All appropriate object files must be linked to produce a loadable + module. + + All three steps are most commonly handled by using the `gnatmake' + utility program that, given the name of the main program, automatically + performs the necessary compilation, binding and linking steps. + +  + File: gnat_ug_vxw.info, Node: Building a Simple Ada Program, Next: Executing a Program on VxWorks, Prev: Running GNAT, Up: Getting Started with GNAT + + Building a Simple Ada Program + ============================= + + Any text editor may be used to prepare an Ada program. If `Glide' is + used, the optional Ada mode may be helpful in laying out the program. + The program text is a normal text file. We will suppose in our initial + example that you have used your editor to prepare the following + standard format text file: + + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + Put_Line ("Hello WORLD!"); + end Hello; + + This file should be named `hello.adb'. With the normal default file + naming conventions, GNAT requires that each file contain a single + compilation unit whose file name is the unit name, with periods + replaced by hyphens; the extension is `ads' for a spec and `adb' for a + body. You can override this default file naming convention by use of + the special pragma `Source_File_Name' (*note Using Other File Names::). + Alternatively, if you want to rename your files according to this + default convention, which is probably more convenient if you will be + using GNAT for all your compilations, then the `gnatchop' utility can + be used to generate correctly-named source files (*note Renaming Files + Using gnatchop::). + + You can compile the program using the following command (`$' is used + as the command prompt in the examples in this document): + + $ target-gcc -c hello.adb + + `gcc' is the command used to run the compiler. This compiler is capable + of compiling programs in several languages, including Ada 95 and C. It + assumes that you have given it an Ada program if the file extension is + either `.ads' or `.adb', and it will then call the GNAT compiler to + compile the specified file. + + The `-c' switch is required. It tells `gcc' to only do a + compilation. (For C programs, `gcc' can also do linking, but this + capability is not used directly for Ada programs, so the `-c' switch + must always be present.) + + This compile command generates a file `hello.o', which is the object + file corresponding to your Ada program. It also generates an "Ada + Library Information" file `hello.ali', which contains additional + information used to check that an Ada program is consistent. To build + a downloadable module, use `gnatbind' to bind the program and + `gnatlink' to link it. The argument to both `gnatbind' and `gnatlink' + is the name of the `ali' file, but the default extension of `.ali' can + be omitted. This means that in the most common case, the argument is + simply the name of the main program: + + $ target-gnatbind hello + $ target-gnatlink hello + + A simpler method of carrying out these steps is to use `gnatmake', a + master program that invokes all the required compilation, binding and + linking tools in the correct order. In particular, `gnatmake' + automatically recompiles any sources that have been modified since they + were last compiled, or sources that depend on such modified sources, so + that "version skew" is avoided. + + $ target-gnatmake hello.adb + + The result is a relocatable object called `hello'. + + _Technical note:_ the result of the linking stage is a relocatable + partially-linked object containing all the relevant GNAT run-time + units, in contrast with the executable-format object file found in + native environments. + +  + File: gnat_ug_vxw.info, Node: Executing a Program on VxWorks, Next: Running a Program with Multiple Units, Prev: Building a Simple Ada Program, Up: Getting Started with GNAT + + Executing a Program on VxWorks + ============================== + + Getting a program to execute involves loading it onto the target, + running it, and then (if re-execution is needed) unloading it. + + * Menu: + + * Loading and Running the Program:: + * Unloading the Program:: + +  + File: gnat_ug_vxw.info, Node: Loading and Running the Program, Next: Unloading the Program, Up: Executing a Program on VxWorks + + Loading and Running the Program + ------------------------------- + + An Ada program is loaded and run in the same way as a C program. + Details may be found in the `Tornado User's Guide'. + + In order to load and run our simple "Hello World" example, we assume + that the target has access to the disk of the host containing this + object and that its working directory has been set to the directory + containing this object. The commands are typed in Tornado's Windshell. + The `windsh' prompt is the `->' sequence. + + -> vf0=open("/vio/0",2,0) + new symbol "vf0" added to symbol table. + vf0 = 0x2cab48: value = 12 = 0xc + -> ioGlobalStdSet(1,vf0) + value = 1 = 0x1 + -> ld < hello + value = 665408 = 0xa2740 + -> hello + Hello World + value = 0 = 0x0 + -> + + The first two commands redirect output to the shell window. They are + only needed if the target server was started without the `-C' option. + The third command loads the module, which is the file `hello' created + previously by the `target-gnatmake' command. Note that for Tornado AE, + the `ml' command replaces `ld'." + + The "Hello World" program comprises a procedure named `hello', and + this is the name entered for the procedure in the target server's + symbol table when the module is loaded. To execute the procedure, type + the symbol name `hello' into `windsh' as shown in the last command + above. + + Note that by default the entry point of an Ada program is the name + of the main Ada subprogram in a VxWorks environment. It is possible to + use an alternative name; see the description of `gnatbind' options for + details. + +  + File: gnat_ug_vxw.info, Node: Unloading the Program, Prev: Loading and Running the Program, Up: Executing a Program on VxWorks + + Unloading the Program + --------------------- + + It is important to remember that you must unload a program once you + have run it. You cannot load it once and run it several times. If you + don't follow this rule, your program's behavior can be unpredictable, + and will most probably crash. + + This effect is due to the implementation of Ada 95's _elaboration_ + semantics. The unit elaboration phase comprises a _static_ elaboration + and a _dynamic_ elaboration. On a native platform they both take place + when the program is run. Thus rerunning the program will repeat the + complete elaboration phase, and the program will run correctly. + + On VxWorks, the process is a bit different. The static elaboration + phase is handled by the loader (typically when you type `ld < + program_name' in `windsh'). The dynamic phase takes place when the + program is run. If the program is run twice and has not been unloaded + and then reloaded, the second time it is run, the static elaboration + phase is skipped. Variables initialized during the static elaboration + phase may have been modified during the first execution of the program. + Thus the second execution isn't performed on a completely initialized + environment. + + Note that in C programs, elaboration isn't systematic. Multiple runs + without reload might work, but, even with C programs, if there is an + elaboration phase, you will have to unload your program before + re-running it. + +  + File: gnat_ug_vxw.info, Node: Running a Program with Multiple Units, Next: Using the gnatmake Utility, Prev: Executing a Program on VxWorks, Up: Getting Started with GNAT + + Running a Program with Multiple Units + ===================================== + + Consider a slightly more complicated example that has three files: a + main program, and the spec and body of a package: + + package Greetings is + procedure Hello; + procedure Goodbye; + end Greetings; + + with Ada.Text_IO; use Ada.Text_IO; + package body Greetings is + procedure Hello is + begin + Put_Line ("Hello WORLD!"); + end Hello; + + procedure Goodbye is + begin + Put_Line ("Goodbye WORLD!"); + end Goodbye; + end Greetings; + + with Greetings; + procedure Gmain is + begin + Greetings.Hello; + Greetings.Goodbye; + end Gmain; + + Following the one-unit-per-file rule, place this program in the + following three separate files: + + `greetings.ads' + spec of package `Greetings' + + `greetings.adb' + body of package `Greetings' + + `gmain.adb' + body of main program + + To build an executable version of this program, we could use four + separate steps to compile, bind, and link the program, as follows: + + $ target-gcc -c gmain.adb + $ target-gcc -c greetings.adb + $ target-gnatbind gmain + $ target-gnatlink gmain + + Note that there is no required order of compilation when using GNAT. + In particular it is perfectly fine to compile the main program first. + Also, it is not necessary to compile package specs in the case where + there is an accompanying body; you only need to compile the body. If + you want to submit these files to the compiler for semantic checking + and not code generation, then use the `-gnatc' switch: + + $ target-gcc -c greetings.ads -gnatc + + Although the compilation can be done in separate steps as in the above + example, in practice it is almost always more convenient to use the + `gnatmake' tool. All you need to know in this case is the name of the + main program's source file. The effect of the above four commands can + be achieved with a single one: + + $ target-gnatmake gmain.adb + + In the next section we discuss the advantages of using `gnatmake' in + more detail. + +  + File: gnat_ug_vxw.info, Node: Using the gnatmake Utility, Next: Introduction to Glide and GVD, Prev: Running a Program with Multiple Units, Up: Getting Started with GNAT + + Using the `gnatmake' Utility + ============================ + + If you work on a program by compiling single components at a time using + `gcc', you typically keep track of the units you modify. In order to + build a consistent system, you compile not only these units, but also + any units that depend on the units you have modified. For example, in + the preceding case, if you edit `gmain.adb', you only need to recompile + that file. But if you edit `greetings.ads', you must recompile both + `greetings.adb' and `gmain.adb', because both files contain units that + depend on `greetings.ads'. + + `gnatbind' will warn you if you forget one of these compilation + steps, so that it is impossible to generate an inconsistent program as a + result of forgetting to do a compilation. Nevertheless it is tedious and + error-prone to keep track of dependencies among units. One approach to + handle the dependency-bookkeeping is to use a makefile. However, + makefiles present maintenance problems of their own: if the + dependencies change as you change the program, you must make sure that + the makefile is kept up-to-date manually, which is also an error-prone + process. + + The `gnatmake' utility takes care of these details automatically. + Invoke it using either one of the following forms: + + $ target-gnatmake gmain.adb + $ target-gnatmake gmain + + The argument is the name of the file containing the main program; you + may omit the extension. `gnatmake' examines the environment, + automatically recompiles any files that need recompiling, and binds and + links the resulting set of object files, generating the executable + file, `gmain'. In a large program, it can be extremely helpful to use + `gnatmake', because working out by hand what needs to be recompiled can + be difficult. + + Note that `gnatmake' takes into account all the Ada 95 rules that + establish dependencies among units. These include dependencies that + result from inlining subprogram bodies, and from generic instantiation. + Unlike some other Ada make tools, `gnatmake' does not rely on the + dependencies that were found by the compiler on a previous compilation, + which may possibly be wrong when sources change. `gnatmake' determines + the exact set of dependencies from scratch each time it is run. + +  + File: gnat_ug_vxw.info, Node: Introduction to Glide and GVD, Prev: Using the gnatmake Utility, Up: Getting Started with GNAT + + Introduction to Glide and GVD + ============================= + + Although it is possible to develop programs using only the command line + interface (`gnatmake', etc.) a graphical Interactive Development + Environment can make it easier for you to compose, navigate, and debug + programs. This section describes the main features of Glide, the GNAT + graphical IDE, and also shows how to use the basic commands in GVD, the + GNU Visual Debugger. Additional information may be found in the + on-line help for these tools. + + * Menu: + + * Building a New Program with Glide:: + * Simple Debugging with GVD:: + * Other Glide Features:: + +  + File: gnat_ug_vxw.info, Node: Building a New Program with Glide, Next: Simple Debugging with GVD, Up: Introduction to Glide and GVD + + Building a New Program with Glide + --------------------------------- + + The simplest way to invoke Glide is to enter `glide' at the command + prompt. It will generally be useful to issue this as a background + command, thus allowing you to continue using your command window for + other purposes while Glide is running: + + $ glide& + + Glide will start up with an initial screen displaying the top-level + menu items as well as some other information. The menu selections are + as follows + * `Buffers' + + * `Files' + + * `Tools' + + * `Edit' + + * `Search' + + * `Mule' + + * `Glide' + + * `Help' + + For this introductory example, you will need to create a new Ada source + file. First, select the `Files' menu. This will pop open a menu with + around a dozen or so items. To create a file, select the `Open + file...' choice. Depending on the platform, you may see a pop-up + window where you can browse to an appropriate directory and then enter + the file name, or else simply see a line at the bottom of the Glide + window where you can likewise enter the file name. Note that in Glide, + when you attempt to open a non-existent file, the effect is to create a + file with that name. For this example enter `hello.adb' as the name of + the file. + + A new buffer will now appear, occupying the entire Glide window, + with the file name at the top. The menu selections are slightly + different from the ones you saw on the opening screen; there is an + `Entities' item, and in place of `Glide' there is now an `Ada' item. + Glide uses the file extension to identify the source language, so `adb' + indicates an Ada source file. + + You will enter some of the source program lines explicitly, and use + the syntax-oriented template mechanism to enter other lines. First, + type the following text: + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + + Observe that Glide uses different colors to distinguish reserved words + from identifiers. Also, after the `procedure Hello is' line, the + cursor is automatically indented in anticipation of declarations. When + you enter `begin', Glide recognizes that there are no declarations and + thus places `begin' flush left. But after the `begin' line the cursor + is again indented, where the statement(s) will be placed. + + The main part of the program will be a `for' loop. Instead of + entering the text explicitly, however, use a statement template. + Select the `Ada' item on the top menu bar, move the mouse to the + `Statements' item, and you will see a large selection of alternatives. + Choose `for loop'. You will be prompted (at the bottom of the buffer) + for a loop name; simply press the key since a loop name is not + needed. You should see the beginning of a `for' loop appear in the + source program window. You will now be prompted for the name of the + loop variable; enter a line with the identifier `ind' (lower case). + Note that, by default, Glide capitalizes the name (you can override + such behavior if you wish, although this is outside the scope of this + introduction). Next, Glide prompts you for the loop range; enter a + line containing `1..5' and you will see this also appear in the source + program, together with the remaining elements of the `for' loop syntax. + + Next enter the statement (with an intentional error, a missing + semicolon) that will form the body of the loop: + Put_Line("Hello, World" & Integer'Image(I)) + + Finally, type `end Hello;' as the last line in the program. Now save + the file: choose the `File' menu item, and then the `Save buffer' + selection. You will see a message at the bottom of the buffer + confirming that the file has been saved. + + You are now ready to attempt to build the program. Select the `Ada' + item from the top menu bar. Although we could choose simply to compile + the file, we will instead attempt to do a build (which invokes + `gnatmake') since, if the compile is successful, we want to build an + executable. Thus select `Ada build'. This will fail because of the + compilation error, and you will notice that the Glide window has been + split: the top window contains the source file, and the bottom window + contains the output from the GNAT tools. Glide allows you to navigate + from a compilation error to the source file position corresponding to + the error: click the middle mouse button (or simultaneously press the + left and right buttons, on a two-button mouse) on the diagnostic line + in the tool window. The focus will shift to the source window, and the + cursor will be positioned on the character at which the error was + detected. + + Correct the error: type in a semicolon to terminate the statement. + Although you can again save the file explicitly, you can also simply + invoke `Ada' => `Build' and you will be prompted to save the file. + This time the build will succeed; the tool output window shows you the + options that are supplied by default. The GNAT tools' output (e.g., + object and ALI files, executable) will go in the directory from which + Glide was launched. + + To execute the program, choose `Ada' and then `Run'. You should see + the program's output displayed in the bottom window: + + Hello, world 1 + Hello, world 2 + Hello, world 3 + Hello, world 4 + Hello, world 5 + +  + File: gnat_ug_vxw.info, Node: Simple Debugging with GVD, Next: Other Glide Features, Prev: Building a New Program with Glide, Up: Introduction to Glide and GVD + + Simple Debugging with GVD + ------------------------- + + This section describes how to set breakpoints, examine/modify + variables, and step through execution. + + In order to enable debugging, you need to pass the `-g' switch to + both the compiler and to `gnatlink'. If you are using the command + line, passing `-g' to `gnatmake' will have this effect. You can then + launch GVD, e.g. on the `hello' program, by issuing the command: + + $ gvd hello + + If you are using Glide, then `-g' is passed to the relevant tools by + default when you do a build. Start the debugger by selecting the `Ada' + menu item, and then `Debug'. + + GVD comes up in a multi-part window. One pane shows the names of + files comprising your executable; another pane shows the source code of + the current unit (initially your main subprogram), another pane shows + the debugger output and user interactions, and the fourth pane (the + data canvas at the top of the window) displays data objects that you + have selected. + + To the left of the source file pane, you will notice green dots + adjacent to some lines. These are lines for which object code exists + and where breakpoints can thus be set. You set/reset a breakpoint by + clicking the green dot. When a breakpoint is set, the dot is replaced + by an `X' in a red circle. Clicking the circle toggles the breakpoint + off, and the red circle is replaced by the green dot. + + For this example, set a breakpoint at the statement where `Put_Line' + is invoked. + + Start program execution by selecting the `Run' button on the top + menu bar. (The `Start' button will also start your program, but it + will cause program execution to break at the entry to your main + subprogram.) Evidence of reaching the breakpoint will appear: the + source file line will be highlighted, and the debugger interactions + pane will display a relevant message. + + You can examine the values of variables in several ways. Move the + mouse over an occurrence of `Ind' in the `for' loop, and you will see + the value (now `1') displayed. Alternatively, right-click on `Ind' and + select `Display Ind'; a box showing the variable's name and value will + appear in the data canvas. + + Although a loop index is a constant with respect to Ada semantics, + you can change its value in the debugger. Right-click in the box for + `Ind', and select the `Set Value of Ind' item. Enter `2' as the new + value, and press `OK'. The box for `Ind' shows the update. + + Press the `Step' button on the top menu bar; this will step through + one line of program text (the invocation of `Put_Line'), and you can + observe the effect of having modified `Ind' since the value displayed + is `2'. + + Remove the breakpoint, and resume execution by selecting the `Cont' + button. You will see the remaining output lines displayed in the + debugger interaction window, along with a message confirming normal + program termination. + +  + File: gnat_ug_vxw.info, Node: Other Glide Features, Prev: Simple Debugging with GVD, Up: Introduction to Glide and GVD + + Other Glide Features + -------------------- + + You may have observed that some of the menu selections contain + abbreviations; e.g., `(C-x C-f)' for `Open file...' in the `Files' + menu. These are _shortcut keys_ that you can use instead of selecting + menu items. The stands for ; thus `(C-x C-f)' means + followed by , and this sequence can be used instead of + selecting `Files' and then `Open file...'. + + To abort a Glide command, type . + + If you want Glide to start with an existing source file, you can + either launch Glide as above and then open the file via `Files' => + `Open file...', or else simply pass the name of the source file on the + command line: + + $ glide hello.adb& + + While you are using Glide, a number of _buffers_ exist. You create + some explicitly; e.g., when you open/create a file. Others arise as an + effect of the commands that you issue; e.g., the buffer containing the + output of the tools invoked during a build. If a buffer is hidden, you + can bring it into a visible window by first opening the `Buffers' menu + and then selecting the desired entry. + + If a buffer occupies only part of the Glide screen and you want to + expand it to fill the entire screen, then click in the buffer and then + select `Files' => `One Window'. + + If a window is occupied by one buffer and you want to split the + window to bring up a second buffer, perform the following steps: + * Select `Files' => `Split Window'; this will produce two windows + each of which holds the original buffer (these are not copies, but + rather different views of the same buffer contents) + + * With the focus in one of the windows, select the desired buffer + from the `Buffers' menu + + To exit from Glide, choose `Files' => `Exit'. + +  + File: gnat_ug_vxw.info, Node: The GNAT Compilation Model, Next: Compiling Using gcc, Prev: Getting Started with GNAT, Up: Top + + The GNAT Compilation Model + ************************** + + * Menu: + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + This chapter describes the compilation model used by GNAT. Although + similar to that used by other languages, such as C and C++, this model + is substantially different from the traditional Ada compilation models, + which are based on a library. The model is initially described without + reference to the library-based model. If you have not previously used an + Ada compiler, you need only read the first part of this chapter. The + last section describes and discusses the differences between the GNAT + model and the traditional Ada compiler models. If you have used other + Ada compilers, this section will help you to understand those + differences, and the advantages of the GNAT model. + +  + File: gnat_ug_vxw.info, Node: Source Representation, Next: Foreign Language Representation, Up: The GNAT Compilation Model + + Source Representation + ===================== + + Ada source programs are represented in standard text files, using + Latin-1 coding. Latin-1 is an 8-bit code that includes the familiar + 7-bit ASCII set, plus additional characters used for representing + foreign languages (*note Foreign Language Representation:: for support + of non-USA character sets). The format effector characters are + represented using their standard ASCII encodings, as follows: + + `VT' + Vertical tab, `16#0B#' + + `HT' + Horizontal tab, `16#09#' + + `CR' + Carriage return, `16#0D#' + + `LF' + Line feed, `16#0A#' + + `FF' + Form feed, `16#0C#' + + Source files are in standard text file format. In addition, GNAT will + recognize a wide variety of stream formats, in which the end of physical + physical lines is marked by any of the following sequences: `LF', `CR', + `CR-LF', or `LF-CR'. This is useful in accommodating files that are + imported from other operating systems. + + The end of a source file is normally represented by the physical end + of file. However, the control character `16#1A#' (`SUB') is also + recognized as signalling the end of the source file. Again, this is + provided for compatibility with other operating systems where this code + is used to represent the end of file. + + Each file contains a single Ada compilation unit, including any + pragmas associated with the unit. For example, this means you must + place a package declaration (a package "spec") and the corresponding + body in separate files. An Ada "compilation" (which is a sequence of + compilation units) is represented using a sequence of files. Similarly, + you will place each subunit or child unit in a separate file. + +  + File: gnat_ug_vxw.info, Node: Foreign Language Representation, Next: File Naming Rules, Prev: Source Representation, Up: The GNAT Compilation Model + + Foreign Language Representation + =============================== + + GNAT supports the standard character sets defined in Ada 95 as well as + several other non-standard character sets for use in localized versions + of the compiler (*note Character Set Control::). + + * Menu: + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + +  + File: gnat_ug_vxw.info, Node: Latin-1, Next: Other 8-Bit Codes, Up: Foreign Language Representation + + Latin-1 + ------- + + The basic character set is Latin-1. This character set is defined by ISO + standard 8859, part 1. The lower half (character codes `16#00#' ... + `16#7F#)' is identical to standard ASCII coding, but the upper half is + used to represent additional characters. These include extended letters + used by European languages, such as French accents, the vowels with + umlauts used in German, and the extra letter A-ring used in Swedish. + + For a complete list of Latin-1 codes and their encodings, see the + source file of library unit `Ada.Characters.Latin_1' in file + `a-chlat1.ads'. You may use any of these extended characters freely in + character or string literals. In addition, the extended characters that + represent letters can be used in identifiers. + +  + File: gnat_ug_vxw.info, Node: Other 8-Bit Codes, Next: Wide Character Encodings, Prev: Latin-1, Up: Foreign Language Representation + + Other 8-Bit Codes + ----------------- + + GNAT also supports several other 8-bit coding schemes: + + Latin-2 + Latin-2 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-3 + Latin-3 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-4 + Latin-4 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-5 + Latin-4 letters (Cyrillic) allowed in identifiers, with uppercase + and lowercase equivalence. + + IBM PC (code page 437) + This code page is the normal default for PCs in the U.S. It + corresponds to the original IBM PC character set. This set has + some, but not all, of the extended Latin-1 letters, but these + letters do not have the same encoding as Latin-1. In this mode, + these letters are allowed in identifiers with uppercase and + lowercase equivalence. + + IBM PC (code page 850) + This code page is a modification of 437 extended to include all the + Latin-1 letters, but still not with the usual Latin-1 encoding. In + this mode, all these letters are allowed in identifiers with + uppercase and lowercase equivalence. + + Full Upper 8-bit + Any character in the range 80-FF allowed in identifiers, and all + are considered distinct. In other words, there are no uppercase + and lowercase equivalences in this range. This is useful in + conjunction with certain encoding schemes used for some foreign + character sets (e.g. the typical method of representing Chinese + characters on the PC). + + No Upper-Half + No upper-half characters in the range 80-FF are allowed in + identifiers. This gives Ada 83 compatibility for identifier names. + + For precise data on the encodings permitted, and the uppercase and + lowercase equivalences that are recognized, see the file `csets.adb' in + the GNAT compiler sources. You will need to obtain a full source release + of GNAT to obtain this file. + +  + File: gnat_ug_vxw.info, Node: Wide Character Encodings, Prev: Other 8-Bit Codes, Up: Foreign Language Representation + + Wide Character Encodings + ------------------------ + + GNAT allows wide character codes to appear in character and string + literals, and also optionally in identifiers, by means of the following + possible encoding schemes: + + Hex Coding + In this encoding, a wide character is represented by the following + five character sequence: + + ESC a b c d + + Where `a', `b', `c', `d' are the four hexadecimal characters + (using uppercase letters) of the wide character code. For example, + ESC A345 is used to represent the wide character with code + `16#A345#'. This scheme is compatible with use of the full + Wide_Character set. + + Upper-Half Coding + The wide character with encoding `16#abcd#' where the upper bit is + on (in other words, "a" is in the range 8-F) is represented as two + bytes, `16#ab#' and `16#cd#'. The second byte cannot be a format + control character, but is not required to be in the upper half. + This method can be also used for shift-JIS or EUC, where the + internal coding matches the external coding. + + Shift JIS Coding + A wide character is represented by a two-character sequence, + `16#ab#' and `16#cd#', with the restrictions described for + upper-half encoding as described above. The internal character + code is the corresponding JIS character according to the standard + algorithm for Shift-JIS conversion. Only characters defined in the + JIS code set table can be used with this encoding method. + + EUC Coding + A wide character is represented by a two-character sequence + `16#ab#' and `16#cd#', with both characters being in the upper + half. The internal character code is the corresponding JIS + character according to the EUC encoding algorithm. Only characters + defined in the JIS code set table can be used with this encoding + method. + + UTF-8 Coding + A wide character is represented using UCS Transformation Format 8 + (UTF-8) as defined in Annex R of ISO 10646-1/Am.2. Depending on + the character value, the representation is a one, two, or three + byte sequence: + 16#0000#-16#007f#: 2#0xxxxxxx# + 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx# + 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx# + + where the xxx bits correspond to the left-padded bits of the + 16-bit character value. Note that all lower half ASCII characters + are represented as ASCII bytes and all upper half characters and + other wide characters are represented as sequences of upper-half + (The full UTF-8 scheme allows for encoding 31-bit characters as + 6-byte sequences, but in this implementation, all UTF-8 sequences + of four or more bytes length will be treated as illegal). + + Brackets Coding + In this encoding, a wide character is represented by the following + eight character sequence: + + [ " a b c d " ] + + Where `a', `b', `c', `d' are the four hexadecimal characters + (using uppercase letters) of the wide character code. For example, + ["A345"] is used to represent the wide character with code + `16#A345#'. It is also possible (though not required) to use the + Brackets coding for upper half characters. For example, the code + `16#A3#' can be represented as `["A3"]'. + + This scheme is compatible with use of the full Wide_Character set, + and is also the method used for wide character encoding in the + standard ACVC (Ada Compiler Validation Capability) test suite + distributions. + + Note: Some of these coding schemes do not permit the full use of the + Ada 95 character set. For example, neither Shift JIS, nor EUC allow the + use of the upper half of the Latin-1 set. + +  + File: gnat_ug_vxw.info, Node: File Naming Rules, Next: Using Other File Names, Prev: Foreign Language Representation, Up: The GNAT Compilation Model + + File Naming Rules + ================= + + The default file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + lowercase for all letters. + + An exception arises if the file name generated by the above rules + starts with one of the characters a,g,i, or s, and the second character + is a minus. In this case, the character tilde is used in place of the + minus. The reason for this special rule is to avoid clashes with the + standard names for child units of the packages System, Ada, Interfaces, + and GNAT, which use the prefixes s- a- i- and g- respectively. + + The file extension is `.ads' for a spec and `.adb' for a body. The + following list shows some examples of these rules. + + `main.ads' + Main (spec) + + `main.adb' + Main (body) + + `arith_functions.ads' + Arith_Functions (package spec) + + `arith_functions.adb' + Arith_Functions (package body) + + `func-spec.ads' + Func.Spec (child package spec) + + `func-spec.adb' + Func.Spec (child package body) + + `main-sub.adb' + Sub (subunit of Main) + + `a~bad.adb' + A.Bad (child package body) + + Following these rules can result in excessively long file names if + corresponding unit names are long (for example, if child units or + subunits are heavily nested). An option is available to shorten such + long file names (called file name "krunching"). This may be + particularly useful when programs being developed with GNAT are to be + used on operating systems with limited file name lengths. *Note Using + gnatkr::. + + Of course, no file shortening algorithm can guarantee uniqueness over + all possible unit names; if file name krunching is used, it is your + responsibility to ensure no name clashes occur. Alternatively you can + specify the exact file names that you want used, as described in the + next section. Finally, if your Ada programs are migrating from a + compiler with a different naming convention, you can use the gnatchop + utility to produce source files that follow the GNAT naming conventions. + (For details *note Renaming Files Using gnatchop::.) + +  + File: gnat_ug_vxw.info, Node: Using Other File Names, Next: Alternative File Naming Schemes, Prev: File Naming Rules, Up: The GNAT Compilation Model + + Using Other File Names + ====================== + + In the previous section, we have described the default rules used by + GNAT to determine the file name in which a given unit resides. It is + often convenient to follow these default rules, and if you follow them, + the compiler knows without being explicitly told where to find all the + files it needs. + + However, in some cases, particularly when a program is imported from + another Ada compiler environment, it may be more convenient for the + programmer to specify which file names contain which units. GNAT allows + arbitrary file names to be used by means of the Source_File_Name pragma. + The form of this pragma is as shown in the following examples: + + pragma Source_File_Name (My_Utilities.Stacks, + Spec_File_Name => "myutilst_a.ada"); + pragma Source_File_name (My_Utilities.Stacks, + Body_File_Name => "myutilst.ada"); + + As shown in this example, the first argument for the pragma is the unit + name (in this example a child unit). The second argument has the form + of a named association. The identifier indicates whether the file name + is for a spec or a body; the file name itself is given by a string + literal. + + The source file name pragma is a configuration pragma, which means + that normally it will be placed in the `gnat.adc' file used to hold + configuration pragmas that apply to a complete compilation environment. + For more details on how the `gnat.adc' file is created and used *note + Handling of Configuration Pragmas:: + + GNAT allows completely arbitrary file names to be specified using the + source file name pragma. However, if the file name specified has an + extension other than `.ads' or `.adb' it is necessary to use a special + syntax when compiling the file. The name in this case must be preceded + by the special sequence `-x' followed by a space and the name of the + language, here `ada', as in: + + $ gcc -c -x ada peculiar_file_name.sim + + `gnatmake' handles non-standard file names in the usual manner (the + non-standard file name for the main program is simply used as the + argument to gnatmake). Note that if the extension is also non-standard, + then it must be included in the gnatmake command, it may not be omitted. + +  + File: gnat_ug_vxw.info, Node: Alternative File Naming Schemes, Next: Generating Object Files, Prev: Using Other File Names, Up: The GNAT Compilation Model + + Alternative File Naming Schemes + =============================== + + In the previous section, we described the use of the + `Source_File_Name' pragma to allow arbitrary names to be assigned to + individual source files. However, this approach requires one pragma + for each file, and especially in large systems can result in very long + `gnat.adc' files, and also create a maintenance problem. + + GNAT also provides a facility for specifying systematic file naming + schemes other than the standard default naming scheme previously + described. An alternative scheme for naming is specified by the use of + `Source_File_Name' pragmas having the following format: + + pragma Source_File_Name ( + Spec_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Body_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Subunit_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + FILE_NAME_PATTERN ::= STRING_LITERAL + CASING_SPEC ::= Lowercase | Uppercase | Mixedcase + + The `FILE_NAME_PATTERN' string shows how the file name is constructed. + It contains a single asterisk character, and the unit name is + substituted systematically for this asterisk. The optional parameter + `Casing' indicates whether the unit name is to be all upper-case + letters, all lower-case letters, or mixed-case. If no `Casing' + parameter is used, then the default is all lower-case. + + The optional `Dot_Replacement' string is used to replace any periods + that occur in subunit or child unit names. If no `Dot_Replacement' + argument is used then separating dots appear unchanged in the resulting + file name. Although the above syntax indicates that the `Casing' + argument must appear before the `Dot_Replacement' argument, but it is + also permissible to write these arguments in the opposite order. + + As indicated, it is possible to specify different naming schemes for + bodies, specs, and subunits. Quite often the rule for subunits is the + same as the rule for bodies, in which case, there is no need to give a + separate `Subunit_File_Name' rule, and in this case the + `Body_File_name' rule is used for subunits as well. + + The separate rule for subunits can also be used to implement the + rather unusual case of a compilation environment (e.g. a single + directory) which contains a subunit and a child unit with the same unit + name. Although both units cannot appear in the same partition, the Ada + Reference Manual allows (but does not require) the possibility of the + two units coexisting in the same environment. + + The file name translation works in the following steps: + + * If there is a specific `Source_File_Name' pragma for the given + unit, then this is always used, and any general pattern rules are + ignored. + + * If there is a pattern type `Source_File_Name' pragma that applies + to the unit, then the resulting file name will be used if the file + exists. If more than one pattern matches, the latest one will be + tried first, and the first attempt resulting in a reference to a + file that exists will be used. + + * If no pattern type `Source_File_Name' pragma that applies to the + unit for which the corresponding file exists, then the standard + GNAT default naming rules are used. + + + As an example of the use of this mechanism, consider a commonly used + scheme in which file names are all lower case, with separating periods + copied unchanged to the resulting file name, and specs end with + ".1.ada", and bodies end with ".2.ada". GNAT will follow this scheme if + the following two pragmas appear: + + pragma Source_File_Name + (Spec_File_Name => "*.1.ada"); + pragma Source_File_Name + (Body_File_Name => "*.2.ada"); + + The default GNAT scheme is actually implemented by providing the + following default pragmas internally: + + pragma Source_File_Name + (Spec_File_Name => "*.ads", Dot_Replacement => "-"); + pragma Source_File_Name + (Body_File_Name => "*.adb", Dot_Replacement => "-"); + + Our final example implements a scheme typically used with one of the + Ada 83 compilers, where the separator character for subunits was "__" + (two underscores), specs were identified by adding `_.ADA', bodies by + adding `.ADA', and subunits by adding `.SEP'. All file names were upper + case. Child units were not present of course since this was an Ada 83 + compiler, but it seems reasonable to extend this scheme to use the same + double underscore separator for child units. + + pragma Source_File_Name + (Spec_File_Name => "*_.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Body_File_Name => "*.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Subunit_File_Name => "*.SEP", + Dot_Replacement => "__", + Casing = Uppercase); + +  + File: gnat_ug_vxw.info, Node: Generating Object Files, Next: Source Dependencies, Prev: Alternative File Naming Schemes, Up: The GNAT Compilation Model + + Generating Object Files + ======================= + + An Ada program consists of a set of source files, and the first step in + compiling the program is to generate the corresponding object files. + These are generated by compiling a subset of these source files. The + files you need to compile are the following: + + * If a package spec has no body, compile the package spec to produce + the object file for the package. + + * If a package has both a spec and a body, compile the body to + produce the object file for the package. The source file for the + package spec need not be compiled in this case because there is + only one object file, which contains the code for both the spec + and body of the package. + + * For a subprogram, compile the subprogram body to produce the + object file for the subprogram. The spec, if one is present, is as + usual in a separate file, and need not be compiled. + + * In the case of subunits, only compile the parent unit. A single + object file is generated for the entire subunit tree, which + includes all the subunits. + + * Compile child units independently of their parent units (though, + of course, the spec of all the ancestor unit must be present in + order to compile a child unit). + + * Compile generic units in the same manner as any other units. The + object files in this case are small dummy files that contain at + most the flag used for elaboration checking. This is because GNAT + always handles generic instantiation by means of macro expansion. + However, it is still necessary to compile generic units, for + dependency checking and elaboration purposes. + + The preceding rules describe the set of files that must be compiled to + generate the object files for a program. Each object file has the same + name as the corresponding source file, except that the extension is + `.o' as usual. + + You may wish to compile other files for the purpose of checking their + syntactic and semantic correctness. For example, in the case where a + package has a separate spec and body, you would not normally compile the + spec. However, it is convenient in practice to compile the spec to make + sure it is error-free before compiling clients of this spec, because + such compilations will fail if there is an error in the spec. + + GNAT provides an option for compiling such files purely for the + purposes of checking correctness; such compilations are not required as + part of the process of building a program. To compile a file in this + checking mode, use the `-gnatc' switch. + +  + File: gnat_ug_vxw.info, Node: Source Dependencies, Next: The Ada Library Information Files, Prev: Generating Object Files, Up: The GNAT Compilation Model + + Source Dependencies + =================== + + A given object file clearly depends on the source file which is compiled + to produce it. Here we are using "depends" in the sense of a typical + `make' utility; in other words, an object file depends on a source file + if changes to the source file require the object file to be recompiled. + In addition to this basic dependency, a given object may depend on + additional source files as follows: + + * If a file being compiled `with''s a unit X, the object file + depends on the file containing the spec of unit X. This includes + files that are `with''ed implicitly either because they are parents + of `with''ed child units or they are run-time units required by the + language constructs used in a particular unit. + + * If a file being compiled instantiates a library level generic + unit, the object file depends on both the spec and body files for + this generic unit. + + * If a file being compiled instantiates a generic unit defined + within a package, the object file depends on the body file for the + package as well as the spec file. + + * If a file being compiled contains a call to a subprogram for which + pragma `Inline' applies and inlining is activated with the + `-gnatn' switch, the object file depends on the file containing the + body of this subprogram as well as on the file containing the + spec. Note that for inlining to actually occur as a result of the + use of this switch, it is necessary to compile in optimizing mode. + + The use of `-gnatN' activates a more extensive inlining + optimization that is performed by the front end of the compiler. + This inlining does not require that the code generation be + optimized. Like `-gnatn', the use of this switch generates + additional dependencies. + + * If an object file O depends on the proper body of a subunit + through inlining or instantiation, it depends on the parent unit + of the subunit. This means that any modification of the parent + unit or one of its subunits affects the compilation of O. + + * The object file for a parent unit depends on all its subunit body + files. + + * The previous two rules meant that for purposes of computing + dependencies and recompilation, a body and all its subunits are + treated as an indivisible whole. + + These rules are applied transitively: if unit `A' `with''s unit + `B', whose elaboration calls an inlined procedure in package `C', + the object file for unit `A' will depend on the body of `C', in + file `c.adb'. + + The set of dependent files described by these rules includes all + the files on which the unit is semantically dependent, as + described in the Ada 95 Language Reference Manual. However, it is + a superset of what the ARM describes, because it includes generic, + inline, and subunit dependencies. + + An object file must be recreated by recompiling the corresponding + source file if any of the source files on which it depends are + modified. For example, if the `make' utility is used to control + compilation, the rule for an Ada object file must mention all the + source files on which the object file depends, according to the + above definition. The determination of the necessary + recompilations is done automatically when one uses `gnatmake'. + +  + File: gnat_ug_vxw.info, Node: The Ada Library Information Files, Next: Binding an Ada Program, Prev: Source Dependencies, Up: The GNAT Compilation Model + + The Ada Library Information Files + ================================= + + Each compilation actually generates two output files. The first of these + is the normal object file that has a `.o' extension. The second is a + text file containing full dependency information. It has the same name + as the source file, but an `.ali' extension. This file is known as the + Ada Library Information (`ali') file. The following information is + contained in the `ali' file. + + * Version information (indicates which version of GNAT was used to + compile the unit(s) in question) + + * Main program information (including priority and time slice + settings, as well as the wide character encoding used during + compilation). + + * List of arguments used in the `gcc' command for the compilation + + * Attributes of the unit, including configuration pragmas used, an + indication of whether the compilation was successful, exception + model used etc. + + * A list of relevant restrictions applying to the unit (used for + consistency) checking. + + * Categorization information (e.g. use of pragma `Pure'). + + * Information on all `with''ed units, including presence of + `Elaborate' or `Elaborate_All' pragmas. + + * Information from any `Linker_Options' pragmas used in the unit + + * Information on the use of `Body_Version' or `Version' attributes + in the unit. + + * Dependency information. This is a list of files, together with + time stamp and checksum information. These are files on which the + unit depends in the sense that recompilation is required if any of + these units are modified. + + * Cross-reference data. Contains information on all entities + referenced in the unit. Used by tools like `gnatxref' and + `gnatfind' to provide cross-reference information. + + + For a full detailed description of the format of the `ali' file, see + the source of the body of unit `Lib.Writ', contained in file + `lib-writ.adb' in the GNAT compiler sources. + +  + File: gnat_ug_vxw.info, Node: Binding an Ada Program, Next: Mixed Language Programming, Prev: The Ada Library Information Files, Up: The GNAT Compilation Model + + Binding an Ada Program + ====================== + + When using languages such as C and C++, once the source files have been + compiled the only remaining step in building an executable program is + linking the object modules together. This means that it is possible to + link an inconsistent version of a program, in which two units have + included different versions of the same header. + + The rules of Ada do not permit such an inconsistent program to be + built. For example, if two clients have different versions of the same + package, it is illegal to build a program containing these two clients. + These rules are enforced by the GNAT binder, which also determines an + elaboration order consistent with the Ada rules. + + The GNAT binder is run after all the object files for a program have + been created. It is given the name of the main program unit, and from + this it determines the set of units required by the program, by reading + the corresponding ALI files. It generates error messages if the program + is inconsistent or if no valid order of elaboration exists. + + If no errors are detected, the binder produces a main program, in + Ada by default, that contains calls to the elaboration procedures of + those compilation unit that require them, followed by a call to the + main program. This Ada program is compiled to generate the object file + for the main program. The name of the Ada file is `b~XXX.adb' (with the + corresponding spec `b~XXX.ads') where XXX is the name of the main + program unit. + + Finally, the linker is used to build the resulting executable + program, using the object from the main program from the bind step as + well as the object files for the Ada units of the program. + +  + File: gnat_ug_vxw.info, Node: Mixed Language Programming, Next: Building Mixed Ada & C++ Programs, Prev: Binding an Ada Program, Up: The GNAT Compilation Model + + Mixed Language Programming + ========================== + + * Menu: + + * Interfacing to C:: + * Calling Conventions:: + +  + File: gnat_ug_vxw.info, Node: Interfacing to C, Next: Calling Conventions, Up: Mixed Language Programming + + Interfacing to C + ---------------- + + There are two ways to build a program that contains some Ada files and + some other language files depending on whether the main program is in + Ada or not. If the main program is in Ada, you should proceed as + follows: + + 1. Compile the other language files to generate object files. For + instance: + gcc -c file1.c + gcc -c file2.c + + 2. Compile the Ada units to produce a set of object files and ALI + files. For instance: + gnatmake -c my_main.adb + + 3. Run the Ada binder on the Ada main program. For instance: + gnatbind my_main.ali + + 4. Link the Ada main program, the Ada objects and the other language + objects. For instance: + gnatlink my_main.ali file1.o file2.o + + The three last steps can be grouped in a single command: + gnatmake my_main.adb -largs file1.o file2.o + + If the main program is in some language other than Ada, Then you may + have more than one entry point in the Ada subsystem. You must use a + special option of the binder to generate callable routines to initialize + and finalize the Ada units (*note Binding with Non-Ada Main Programs::). + Calls to the initialization and finalization routines must be inserted + in the main program, or some other appropriate point in the code. The + call to initialize the Ada units must occur before the first Ada + subprogram is called, and the call to finalize the Ada units must occur + after the last Ada subprogram returns. You use the same procedure for + building the program as described previously. In this case, however, + the binder only places the initialization and finalization subprograms + into file `b~XXX.adb' instead of the main program. So, if the main + program is not in Ada, you should proceed as follows: + + 1. Compile the other language files to generate object files. For + instance: + gcc -c file1.c + gcc -c file2.c + + 2. Compile the Ada units to produce a set of object files and ALI + files. For instance: + gnatmake -c entry_point1.adb + gnatmake -c entry_point2.adb + + 3. Run the Ada binder on the Ada main program. For instance: + gnatbind -n entry_point1.ali entry_point2.ali + + 4. Link the Ada main program, the Ada objects and the other language + objects. You only need to give the last entry point here. For + instance: + gnatlink entry_point2.ali file1.o file2.o + +  + File: gnat_ug_vxw.info, Node: Calling Conventions, Prev: Interfacing to C, Up: Mixed Language Programming + + Calling Conventions + ------------------- + + GNAT follows standard calling sequence conventions and will thus + interface to any other language that also follows these conventions. + The following Convention identifiers are recognized by GNAT: + + * Ada. This indicates that the standard Ada calling sequence will be + used and all Ada data items may be passed without any limitations + in the case where GNAT is used to generate both the caller and + callee. It is also possible to mix GNAT generated code and code + generated by another Ada compiler. In this case, the data types + should be restricted to simple cases, including primitive types. + Whether complex data types can be passed depends on the situation. + Probably it is safe to pass simple arrays, such as arrays of + integers or floats. Records may or may not work, depending on + whether both compilers lay them out identically. Complex structures + involving variant records, access parameters, tasks, or protected + types, are unlikely to be able to be passed. + + Note that in the case of GNAT running on a platform that supports + DEC Ada 83, a higher degree of compatibility can be guaranteed, + and in particular records are layed out in an identical manner in + the two compilers. Note also that if output from two different + compilers is mixed, the program is responsible for dealing with + elaboration issues. Probably the safest approach is to write the + main program in the version of Ada other than GNAT, so that it + takes care of its own elaboration requirements, and then call the + GNAT-generated adainit procedure to ensure elaboration of the GNAT + components. Consult the documentation of the other Ada compiler + for further details on elaboration. + + However, it is not possible to mix the tasking run time of GNAT and + DEC Ada 83, All the tasking operations must either be entirely + within GNAT compiled sections of the program, or entirely within + DEC Ada 83 compiled sections of the program. + + * Assembler. Specifies assembler as the convention. In practice this + has the same effect as convention Ada (but is not equivalent in + the sense of being considered the same convention). + + * Asm. Equivalent to Assembler. + + * Asm. Equivalent to Assembly. + + * COBOL. Data will be passed according to the conventions described + in section B.4 of the Ada 95 Reference Manual. + + * C. Data will be passed according to the conventions described in + section B.3 of the Ada 95 Reference Manual. + + * Default. Equivalent to C. + + * External. Equivalent to C. + + * CPP. This stands for C++. For most purposes this is identical to C. + See the separate description of the specialized GNAT pragmas + relating to C++ interfacing for further details. + + * Fortran. Data will be passed according to the conventions described + in section B.5 of the Ada 95 Reference Manual. + + * Intrinsic. This applies to an intrinsic operation, as defined in + the Ada 95 Reference Manual. If a a pragma Import (Intrinsic) + applies to a subprogram, this means that the body of the + subprogram is provided by the compiler itself, usually by means of + an efficient code sequence, and that the user does not supply an + explicit body for it. In an application program, the pragma can + only be applied to the following two sets of names, which the GNAT + compiler recognizes. + * Rotate_Left, Rotate_Right, Shift_Left, Shift_Right, + Shift_Right_- Arithmetic. The corresponding subprogram + declaration must have two formal parameters. The first one + must be a signed integer type or a modular type with a binary + modulus, and the second parameter must be of type Natural. + The return type must be the same as the type of the first + argument. The size of this type can only be 8, 16, 32, or 64. + + * binary arithmetic operators: "+", "-", "*", "/" The + corresponding operator declaration must have parameters and + result type that have the same root numeric type (for + example, all three are long_float types). This simplifies the + definition of operations that use type checking to perform + dimensional checks: + type Distance is new Long_Float; + type Time is new Long_Float; + type Velocity is new Long_Float; + function "/" (D : Distance; T : Time) + return Velocity; + pragma Import (Intrinsic, "/"); + + This common idiom is often programmed with a generic + definition and an explicit body. The pragma makes it simpler + to introduce such declarations. It incurs no overhead in + compilation time or code size, because it is implemented as a + single machine instruction. + + * Stdcall. This is relevant only to NT/Win95 implementations of GNAT, + and specifies that the Stdcall calling sequence will be used, as + defined by the NT API. + + * DLL. This is equivalent to Stdcall. + + * Win32. This is equivalent to Stdcall. + + * Stubbed. This is a special convention that indicates that the + compiler should provide a stub body that raises `Program_Error'. + + GNAT additionally provides a useful pragma `Convention_Identifier' that + can be used to parametrize conventions and allow additional synonyms to + be specified. For example if you have legacy code in which the + convention identifier Fortran77 was used for Fortran, you can use the + configuration pragma: + + pragma Convention_Identifier (Fortran77, Fortran); + + And from now on the identifier Fortran77 may be used as a convention + identifier (for example in an `Import' pragma) with the same meaning as + Fortran. + +  + File: gnat_ug_vxw.info, Node: Building Mixed Ada & C++ Programs, Next: Comparison between GNAT and C/C++ Compilation Models, Prev: Mixed Language Programming, Up: The GNAT Compilation Model + + Building Mixed Ada & C++ Programs + ================================= + + Building a mixed application containing both Ada and C++ code may be a + challenge for the unaware programmer. As a matter of fact, this + interfacing has not been standardized in the Ada 95 reference manual due + to the immaturity and lack of standard of C++ at the time. This section + gives a few hints that should make this task easier. In particular the + first section addresses the differences with interfacing with C. The + second section looks into the delicate problem of linking the complete + application from its Ada and C++ parts. The last section give some + hints on how the GNAT run time can be adapted in order to allow + inter-language dispatching with a new C++ compiler. + + * Menu: + + * Interfacing to C++:: + * Linking a Mixed C++ & Ada Program:: + * A Simple Example:: + * Adapting the Run Time to a New C++ Compiler:: + +  + File: gnat_ug_vxw.info, Node: Interfacing to C++, Next: Linking a Mixed C++ & Ada Program, Up: Building Mixed Ada & C++ Programs + + Interfacing to C++ + ------------------ + + GNAT supports interfacing with C++ compilers generating code that is + compatible with the standard Application Binary Interface of the given + platform. + + Interfacing can be done at 3 levels: simple data, subprograms and + classes. In the first 2 cases, GNAT offer a specific CONVENTION CPP + that behaves exactly like CONVENTION C. Usually C++ mangle names of + subprograms and currently GNAT does not provide any help to solve the + demangling problem. This problem can be addressed in 2 ways: + * by modifying the C++ code in order to force a C convention using + the EXTERN "C" syntax. + + * by figuring out the mangled name and use it as the Link_Name + argument of the pragma import. + + Interfacing at the class level can be achieved by using the GNAT + specific pragmas such as `CPP_Class' and `CPP_Virtual'. See the GNAT + Reference Manual for additional information. + +  + File: gnat_ug_vxw.info, Node: Linking a Mixed C++ & Ada Program, Next: A Simple Example, Prev: Interfacing to C++, Up: Building Mixed Ada & C++ Programs + + Linking a Mixed C++ & Ada Program + --------------------------------- + + Usually the linker of the C++ development system must be used to link + mixed applications because most C++ systems will resolve elaboration + issues (such as calling constructors on global class instances) + transparently during the link phase. GNAT has been adapted to ease the + use of a foreign linker for the last phase. Three cases can be + considered: + 1. 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 `c++'. Note that this setup is not very + common because it may request recompiling the whole GCC tree from + sources and it does not allow to upgrade easily to a new version + of one compiler for one of the two languages without taking the + risk of destabilizing the other. + + $ c++ -c file1.C + $ c++ -c file2.C + $ gnatmake ada_unit -largs file1.o file2.o --LINK=c++ + + 2. Using GNAT and G++ from 2 different GCC installations. If both + compilers are on the PATH, the same method can be used. It is + important to be aware that environment variables such as + C_INCLUDE_PATH, GCC_EXEC_PREFIX, BINUTILS_ROOT or GCC_ROOT will + affect both compilers at the same time and thus may make one of + the 2 compilers operate improperly if they are set for the other. + In particular it is important that the link command has access to + the proper gcc library `libgcc.a', that is to say the one that is + part of the C++ compiler installation. The implicit link command + as suggested in the gnatmake command from the former example can + be replaced by an explicit link command with full verbosity in + order to verify which library is used: + $ gnatbind ada_unit + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=c++ + If there is a problem due to interfering environment variables, it + can be workaround by using an intermediate script. The following + example shows the proper script to use when GNAT has not been + installed at its default location and g++ has been installed at + its default location: + + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + unset BINUTILS_ROOT + unset GCC_ROOT + c++ $* + + 3. Using a non GNU C++ compiler. The same set of command as previously + described can be used to insure that the c++ linker is used. + Nonetheless, you need to add the path to libgcc explicitely, since + some libraries needed by GNAT are located in this directory: + + + $ gnatlink ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + CC $* `gcc -print-libgcc-file-name` + + Where CC is the name of the non GNU C++ compiler. + + +  + File: gnat_ug_vxw.info, Node: A Simple Example, Next: Adapting the Run Time to a New C++ Compiler, Prev: Linking a Mixed C++ & Ada Program, Up: Building Mixed Ada & C++ Programs + + A Simple Example + ---------------- + + The following example, provided as part of the GNAT examples, show how + to achieve procedural interfacing between Ada and C++ in both + directions. The C++ class A has 2 methods. The first method is exported + to Ada by the means of an extern C wrapper function. The second method + calls an Ada subprogram. On the Ada side, The C++ calls is modelized by + a limited record with a layout comparable to the C++ class. The Ada + subprogram, in turn, calls the c++ method. So from the C++ main program + the code goes back and forth between the 2 languages. + + Here are the compilation commands for a GNAT VxWorks/PowerPC + configuration: + $ powerpc-wrs-vxworks-gnatmake -c simple_cpp_interface + $ powerpc-wrs-vxworks-gnatbind -n simple_cpp_interface + $ gnatlink simple_cpp_interface -o ada_part + $ c++ppc -c -DCPU=PPC604 -I/usr/windppc/target/h cpp_main.C + $ c++ppc -c -DCPU=PPC604 -I/usr/windppc/target/h ex7.C + $ ldppc -r -o my_main my_main.o ex7.o ada_part + + Here are the corresponding sources: + + //cpp_main.C + + #include "ex7.h" + + extern "C" { + void adainit (void); + void adafinal (void); + void method1 (A *t); + } + + void method1 (A *t) + { + t->method1 (); + } + + int main () + { + A obj; + adainit (); + obj.method2 (3030); + adafinal (); + } + + //ex7.h + + class Origin { + public: + int o_value; + }; + class A : public Origin { + public: + void method1 (void); + virtual void method2 (int v); + A(); + int a_value; + }; + + //ex7.C + + #include "ex7.h" + #include + + extern "C" { void ada_method2 (A *t, int v);} + + void A::method1 (void) + { + a_value = 2020; + printf ("in A::method1, a_value = %d \n",a_value); + + } + + void A::method2 (int v) + { + ada_method2 (this, v); + printf ("in A::method2, a_value = %d \n",a_value); + + } + + A::A(void) + { + a_value = 1010; + printf ("in A::A, a_value = %d \n",a_value); + } + + -- Ada sources + package body Simple_Cpp_Interface is + + procedure Ada_Method2 (This : in out A; V : Integer) is + begin + Method1 (This); + This.A_Value := V; + end Ada_Method2; + + end Simple_Cpp_Interface; + + package Simple_Cpp_Interface is + type A is limited + record + O_Value : Integer; + A_Value : Integer; + end record; + pragma Convention (C, A); + + procedure Method1 (This : in out A); + pragma Import (C, Method1); + + procedure Ada_Method2 (This : in out A; V : Integer); + pragma Export (C, Ada_Method2); + + end Simple_Cpp_Interface; + +  + File: gnat_ug_vxw.info, Node: Adapting the Run Time to a New C++ Compiler, Prev: A Simple Example, Up: Building Mixed Ada & C++ Programs + + Adapting the Run Time to a New C++ Compiler + ------------------------------------------- + + GNAT offers the capability to derive Ada 95 tagged types directly from + preexisting C++ classes and . See "Interfacing with C++" in the GNAT + reference manual. The mechanism used by GNAT for achieving such a goal + has been made user configurable through a GNAT library unit + `Interfaces.CPP'. The default version of this file is adapted to the + GNU c++ compiler. Internal knowledge of the virtual table layout used + by the new C++ compiler is needed to configure properly this unit. The + Interface of this unit is known by the compiler and cannot be changed + except for the value of the constants defining the characteristics of + the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size, + CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source + of this unit for more details. + +  + File: gnat_ug_vxw.info, Node: Comparison between GNAT and C/C++ Compilation Models, Next: Comparison between GNAT and Conventional Ada Library Models, Prev: Building Mixed Ada & C++ Programs, Up: The GNAT Compilation Model + + Comparison between GNAT and C/C++ Compilation Models + ==================================================== + + The GNAT model of compilation is close to the C and C++ models. You can + think of Ada specs as corresponding to header files in C. As in C, you + don't need to compile specs; they are compiled when they are used. The + Ada `with' is similar in effect to the `#include' of a C header. + + One notable difference is that, in Ada, you may compile specs + separately to check them for semantic and syntactic accuracy. This is + not always possible with C headers because they are fragments of + programs that have less specific syntactic or semantic rules. + + The other major difference is the requirement for running the binder, + which performs two important functions. First, it checks for + consistency. In C or C++, the only defense against assembling + inconsistent programs lies outside the compiler, in a makefile, for + example. The binder satisfies the Ada requirement that it be impossible + to construct an inconsistent program when the compiler is used in normal + mode. + + The other important function of the binder is to deal with + elaboration issues. There are also elaboration issues in C++ that are + handled automatically. This automatic handling has the advantage of + being simpler to use, but the C++ programmer has no control over + elaboration. Where `gnatbind' might complain there was no valid order + of elaboration, a C++ compiler would simply construct a program that + malfunctioned at run time. + +  + File: gnat_ug_vxw.info, Node: Comparison between GNAT and Conventional Ada Library Models, Prev: Comparison between GNAT and C/C++ Compilation Models, Up: The GNAT Compilation Model + + Comparison between GNAT and Conventional Ada Library Models + =========================================================== + + This section is intended to be useful to Ada programmers who have + previously used an Ada compiler implementing the traditional Ada library + model, as described in the Ada 95 Language Reference Manual. If you + have not used such a system, please go on to the next section. + + In GNAT, there is no "library" in the normal sense. Instead, the set + of source files themselves acts as the library. Compiling Ada programs + does not generate any centralized information, but rather an object + file and a ALI file, which are of interest only to the binder and + linker. In a traditional system, the compiler reads information not + only from the source file being compiled, but also from the centralized + library. This means that the effect of a compilation depends on what + has been previously compiled. In particular: + + * When a unit is `with''ed, the unit seen by the compiler corresponds + to the version of the unit most recently compiled into the library. + + * Inlining is effective only if the necessary body has already been + compiled into the library. + + * Compiling a unit may obsolete other units in the library. + + In GNAT, compiling one unit never affects the compilation of any other + units because the compiler reads only source files. Only changes to + source files can affect the results of a compilation. In particular: + + * When a unit is `with''ed, the unit seen by the compiler corresponds + to the source version of the unit that is currently accessible to + the compiler. + + * Inlining requires the appropriate source files for the package or + subprogram bodies to be available to the compiler. Inlining is + always effective, independent of the order in which units are + complied. + + * Compiling a unit never affects any other compilations. The editing + of sources may cause previous compilations to be out of date if + they depended on the source file being modified. + + The most important result of these differences is that order of + compilation is never significant in GNAT. There is no situation in + which one is required to do one compilation before another. What shows + up as order of compilation requirements in the traditional Ada library + becomes, in GNAT, simple source dependencies; in other words, there is + only a set of rules saying what source files must be present when a + file is compiled. + +  + File: gnat_ug_vxw.info, Node: Compiling Using gcc, Next: Binding Using gnatbind, Prev: The GNAT Compilation Model, Up: Top + + Compiling Using `gcc' + ********************* + + This chapter discusses how to compile Ada programs using the `gcc' + command. It also describes the set of switches that can be used to + control the behavior of the compiler. + + * Menu: + + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + +  + File: gnat_ug_vxw.info, Node: Compiling Programs, Next: Switches for gcc, Up: Compiling Using gcc + + Compiling Programs + ================== + + The first step in creating an executable program is to compile the units + of the program using the `gcc' command. You must compile the following + files: + + * the body file (`.adb') for a library level subprogram or generic + subprogram + + * the spec file (`.ads') for a library level package or generic + package that has no body + + * the body file (`.adb') for a library level package or generic + package that has a body + + + You need _not_ compile the following files + + * the spec of a library unit which has a body + + * subunits + + because they are compiled as part of compiling related units. GNAT + package specs when the corresponding body is compiled, and subunits + when the parent is compiled. If you attempt to compile any of these + files, you will get one of the following error messages (where fff is + the name of the file you compiled): + + No code generated for file FFF (PACKAGE SPEC) + No code generated for file FFF (SUBUNIT) + + The basic command for compiling a file containing an Ada unit is + + $ gcc -c [SWITCHES] `file name' + + where FILE NAME is the name of the Ada file (usually having an extension + `.ads' for a spec or `.adb' for a body). You specify the `-c' switch + to tell `gcc' to compile, but not link, the file. The result of a + successful compilation is an object file, which has the same name as + the source file but an extension of `.o' and an Ada Library Information + (ALI) file, which also has the same name as the source file, but with + `.ali' as the extension. GNAT creates these two output files in the + current directory, but you may specify a source file in any directory + using an absolute or relative path specification containing the + directory information. + + `gcc' is actually a driver program that looks at the extensions of + the file arguments and loads the appropriate compiler. For example, the + GNU C compiler is `cc1', and the Ada compiler is `gnat1'. These + programs are in directories known to the driver program (in some + configurations via environment variables you set), but need not be in + your path. The `gcc' driver also calls the assembler and any other + utilities needed to complete the generation of the required object + files. + + It is possible to supply several file names on the same `gcc' + command. This causes `gcc' to call the appropriate compiler for each + file. For example, the following command lists three separate files to + be compiled: + + $ gcc -c x.adb y.adb z.c + + calls `gnat1' (the Ada compiler) twice to compile `x.adb' and `y.adb', + and `cc1' (the C compiler) once to compile `z.c'. The compiler + generates three object files `x.o', `y.o' and `z.o' and the two ALI + files `x.ali' and `y.ali' from the Ada compilations. Any switches apply + to all the files listed, except for `-gnatX' switches, which apply only + to Ada compilations. + +  + File: gnat_ug_vxw.info, Node: Switches for gcc, Next: Search Paths and the Run-Time Library (RTL), Prev: Compiling Programs, Up: Compiling Using gcc + + Switches for `gcc' + ================== + + The `gcc' command accepts switches that control the compilation + process. These switches are fully described in this section. First we + briefly list all the switches, in alphabetical order, then we describe + the switches in more detail in functionally grouped sections. + + * Menu: + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + `-b TARGET' + Compile your program to run on TARGET, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + TARGET is not the same as your host system. + + `-BDIR' + Load compiler executables (for example, `gnat1', the Ada compiler) + from DIR instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + `gcc' manual page for further details. You would normally use the + `-b' or `-V' switch instead. + + `-c' + Compile. Always use this switch when compiling Ada programs. + + Note: for some other languages when using `gcc', notably in the + case of C and C++, it is possible to use use `gcc' without a `-c' + switch to compile and link in one step. In the case of GNAT, you + cannot use this approach, because the binder must be run and `gcc' + cannot be used to run the GNAT binder. + + `-g' + Generate debugging information. This information is stored in the + object file and copied from there to the final executable file by + the linker, where it can be read by the debugger. You must use the + `-g' switch if you plan on using the debugger. + + `-IDIR' + Direct GNAT to search the DIR directory for source files needed by + the current compilation (*note Search Paths and the Run-Time + Library (RTL)::). + + `-I-' + Except for the source file named in the command line, do not look + for source files in the directory containing the source file named + in the command line (*note Search Paths and the Run-Time Library + (RTL)::). + + `-o FILE' + This switch is used in `gcc' to redirect the generated object file + and its associated ALI file. Beware of this switch with GNAT, + because it may cause the object file and ALI file to have + different names which in turn may confuse the binder and the + linker. + + `-O[N]' + N controls the optimization level. + + n = 0 + No optimization, the default setting if no `-O' appears + + n = 1 + Normal optimization, the default if you specify `-O' without + an operand. + + n = 2 + Extensive optimization + + n = 3 + Extensive optimization with automatic inlining. This applies + only to inlining within a unit. For details on control of + inter-unit inlining see *Note Subprogram Inlining Control::. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-S' + Used in place of `-c' to cause the assembler source file to be + generated, using `.s' as the extension, instead of the object file. + This may be useful if you need to examine the generated assembly + code. + + `-v' + Show commands generated by the `gcc' driver. Normally used only for + debugging purposes or if you need to be sure what version of the + compiler you are executing. + + `-V VER' + Execute VER version of the compiler. This is the `gcc' version, + not the GNAT version. + + `-gnata' + Assertions enabled. `Pragma Assert' and `pragma Debug' to be + activated. + + `-gnatA' + Avoid processing `gnat.adc'. If a gnat.adc file is present, it + will be ignored. + + `-gnatb' + Generate brief messages to `stderr' even if verbose mode set. + + `-gnatc' + Check syntax and semantics only (no code generation attempted). + + `-gnatC' + Compress debug information and external symbol name table entries. + + `-gnatD' + Output expanded source files for source level debugging. This + switch also suppress generation of cross-reference information + (see -gnatx). + + `-gnatecPATH' + Specify a configuration pragma file. (see *Note The Configuration + Pragmas Files::) + + `-gnatemPATH' + Specify a mapping file. (see *Note Units to Sources Mapping + Files::) + + `-gnatE' + Full dynamic elaboration checks. + + `-gnatf' + Full errors. Multiple errors per line, all undefined references. + + `-gnatF' + Externals names are folded to all uppercase. + + `-gnatg' + Internal GNAT implementation mode. This should not be used for + applications programs, it is intended only for use by the compiler + and its run-time library. For documentation, see the GNAT sources. + + `-gnatG' + List generated expanded code in source form. + + `-gnatiC' + Identifier character set (C=1/2/3/4/8/9/p/f/n/w). + + `-gnath' + Output usage information. The output is written to `stdout'. + + `-gnatkN' + Limit file names to N (1-999) characters (`k' = krunch). + + `-gnatl' + Output full source listing with embedded error messages. + + `-gnatmN' + Limit number of detected errors to N (1-999). + + `-gnatn' + Activate inlining across unit boundaries for subprograms for which + pragma `inline' is specified. + + `-gnatN' + Activate front end inlining. + + `-fno-inline' + Suppresses all inlining, even if other optimization or inlining + switches are set. + + `-fstack-check' + Activates stack checking. See separate section on stack checking + for details of the use of this option. + + `-gnato' + Enable numeric overflow checking (which is not normally enabled by + default). Not that division by zero is a separate check that is not + controlled by this switch (division by zero checking is on by + default). + + `-gnatp' + Suppress all checks. + + `-gnatq' + Don't quit; try semantics, even if parse errors. + + `-gnatQ' + Don't quit; generate `ali' and tree files even if illegalities. + + `-gnatP' + Enable polling. This is required on some systems (notably Windows + NT) to obtain asynchronous abort and asynchronous transfer of + control capability. See the description of pragma Polling in the + GNAT Reference Manual for full details. + + `-gnatR[0/1/2/3][s]' + Output representation information for declared types and objects. + + `-gnats' + Syntax check only. + + `-gnatt' + Tree output file to be generated. + + `-gnatT nnn' + Set time slice to specified number of microseconds + + `-gnatu' + List units for this compilation. + + `-gnatU' + Tag all error messages with the unique string "error:" + + `-gnatv' + Verbose mode. Full error output with source lines to `stdout'. + + `-gnatV' + Control level of validity checking. See separate section describing + this feature. + + `-gnatwxxxXXX' + Warning mode where XXX is a string of options describing the exact + warnings that are enabled or disabled. See separate section on + warning control. + + `-gnatWE' + Wide character encoding method (E=n/h/u/s/e/8). + + `-gnatx' + Suppress generation of cross-reference information. + + `-gnaty' + Enable built-in style checks. See separate section describing this + feature. + + `-gnatzM' + Distribution stub generation and compilation (M=r/c for + receiver/caller stubs). + + `-gnat83' + Enforce Ada 83 restrictions. + + `-pass-exit-codes' + Catch exit codes from the compiler and use the most meaningful as + exit status. + + You may combine a sequence of GNAT switches into a single switch. For + example, the combined switch + + -gnatofi3 + + is equivalent to specifying the following sequence of switches: + + -gnato -gnatf -gnati3 + + The following restrictions apply to the combination of switches in this + manner: + + * The switch `-gnatc' if combined with other switches must come + first in the string. + + * The switch `-gnats' if combined with other switches must come + first in the string. + + * Once a "y" appears in the string (that is a use of the `-gnaty' + switch), then all further characters in the switch are interpreted + as style modifiers (see description of `-gnaty'). + + * Once a "d" appears in the string (that is a use of the `-gnatd' + switch), then all further characters in the switch are interpreted + as debug flags (see description of `-gnatd'). + + * Once a "w" appears in the string (that is a use of the `-gnatw' + switch), then all further characters in the switch are interpreted + as warning mode modifiers (see description of `-gnatw'). + + * Once a "V" appears in the string (that is a use of the `-gnatV' + switch), then all further characters in the switch are interpreted + as validity checking options (see description of `-gnatV'). + + +  + File: gnat_ug_vxw.info, Node: Output and Error Message Control, Next: Debugging and Assertion Control, Up: Switches for gcc + + Output and Error Message Control + -------------------------------- + + The standard default format for error messages is called "brief format." + Brief format messages are written to `stderr' (the standard error file) + and have the following form: + + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:4:20: ";" should be "is" + + The first integer after the file name is the line number in the file, + and the second integer is the column number within the line. `glide' + can parse the error messages and point to the referenced character. + The following switches provide control over the error message format: + + `-gnatv' + The v stands for verbose. The effect of this setting is to write + long-format error messages to `stdout' (the standard output file. + The same program compiled with the `-gnatv' switch would generate: + + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + + The vertical bar indicates the location of the error, and the `>>>' + prefix can be used to search for error messages. When this switch + is used the only source lines output are those with errors. + + `-gnatl' + The `l' stands for list. This switch causes a full listing of the + file to be generated. The output might look as follows: + + 1. procedure E is + 2. V : Integer; + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + 5. begin + 6. return Q + Q; + 7. end; + 8. begin + 9. V := X + X; + 10.end E; + + When you specify the `-gnatv' or `-gnatl' switches and standard + output is redirected, a brief summary is written to `stderr' + (standard error) giving the number of error messages and warning + messages generated. + + `-gnatU' + This switch forces all error messages to be preceded by the unique + string "error:". This means that error messages take a few more + characters in space, but allows easy searching for and + identification of error messages. + + `-gnatb' + The `b' stands for brief. This switch causes GNAT to generate the + brief format error messages to `stderr' (the standard error file) + as well as the verbose format message or full listing (which as + usual is written to `stdout' (the standard output file). + + `-gnatmN' + The `m' stands for maximum. N is a decimal integer in the range + of 1 to 999 and limits the number of error messages to be + generated. For example, using `-gnatm2' might yield + + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:5:35: missing ".." + fatal error: maximum errors reached + compilation abandoned + + `-gnatf' + The `f' stands for full. Normally, the compiler suppresses error + messages that are likely to be redundant. This switch causes all + error messages to be generated. In particular, in the case of + references to undefined variables. If a given variable is + referenced several times, the normal format of messages is + e.adb:7:07: "V" is undefined (more references follow) + + where the parenthetical comment warns that there are additional + references to the variable `V'. Compiling the same program with the + `-gnatf' switch yields + + e.adb:7:07: "V" is undefined + e.adb:8:07: "V" is undefined + e.adb:8:12: "V" is undefined + e.adb:8:16: "V" is undefined + e.adb:9:07: "V" is undefined + e.adb:9:12: "V" is undefined + + `-gnatq' + The `q' stands for quit (really "don't quit"). In normal + operation mode, the compiler first parses the program and + determines if there are any syntax errors. If there are, + appropriate error messages are generated and compilation is + immediately terminated. This switch tells GNAT to continue with + semantic analysis even if syntax errors have been found. This may + enable the detection of more errors in a single run. On the other + hand, the semantic analyzer is more likely to encounter some + internal fatal error when given a syntactically invalid tree. + + `-gnatQ' + In normal operation mode, the `ali' file is not generated if any + illegalities are detected in the program. The use of `-gnatQ' + forces generation of the `ali' file. This file is marked as being + in error, so it cannot be used for binding purposes, but it does + contain reasonably complete cross-reference information, and thus + may be useful for use by tools (e.g. semantic browsing tools or + integrated development environments) that are driven from the + `ali' file. + + In addition, if `-gnatt' is also specified, then the tree file is + generated even if there are illegalities. It may be useful in this + case to also specify `-gnatq' to ensure that full semantic + processing occurs. The resulting tree file can be processed by + ASIS, for the purpose of providing partial information about + illegal units, but if the error causes the tree to be badly + malformed, then ASIS may crash during the analysis. + + In addition to error messages, which correspond to illegalities as + defined in the Ada 95 Reference Manual, the compiler detects two kinds + of warning situations. + + First, the compiler considers some constructs suspicious and + generates a warning message to alert you to a possible error. Second, + if the compiler detects a situation that is sure to raise an exception + at run time, it generates a warning message. The following shows an + example of warning messages: + e.adb:4:24: warning: creation of object may raise Storage_Error + e.adb:10:17: warning: static value out of range + e.adb:10:17: warning: "Constraint_Error" will be raised at run time + + GNAT considers a large number of situations as appropriate for the + generation of warning messages. As always, warnings are not definite + indications of errors. For example, if you do an out-of-range + assignment with the deliberate intention of raising a + `Constraint_Error' exception, then the warning that may be issued does + not indicate an error. Some of the situations for which GNAT issues + warnings (at least some of the time) are given in the following list, + which is not necessarily complete. + + * Possible infinitely recursive calls + + * Out-of-range values being assigned + + * Possible order of elaboration problems + + * Unreachable code + + * Fixed-point type declarations with a null range + + * Variables that are never assigned a value + + * Variables that are referenced before being initialized + + * Task entries with no corresponding accept statement + + * Duplicate accepts for the same task entry in a select + + * Objects that take too much storage + + * Unchecked conversion between types of differing sizes + + * Missing return statements along some execution paths in a function + + * Incorrect (unrecognized) pragmas + + * Incorrect external names + + * Allocation from empty storage pool + + * Potentially blocking operations in protected types + + * Suspicious parenthesization of expressions + + * Mismatching bounds in an aggregate + + * Attempt to return local value by reference + + * Unrecognized pragmas + + * Premature instantiation of a generic body + + * Attempt to pack aliased components + + * Out of bounds array subscripts + + * Wrong length on string assignment + + * Violations of style rules if style checking is enabled + + * Unused with clauses + + * Bit_Order usage that does not have any effect + + * Compile time biased rounding of floating-point constant + + * Standard.Duration used to resolve universal fixed expression + + * Dereference of possibly null value + + * Declaration that is likely to cause storage error + + * Internal GNAT unit with'ed by application unit + + * Values known to be out of range at compile time + + * Unreferenced labels and variables + + * Address overlays that could clobber memory + + * Unexpected initialization when address clause present + + * Bad alignment for address clause + + * Useless type conversions + + * Redundant assignment statements + + * Accidental hiding of name by child unit + + * Unreachable code + + * Access before elaboration detected at compile time + + * A range in a `for' loop that is known to be null or might be null + + + The following switches are available to control the handling of warning + messages: + + `-gnatwa (activate all optional errors)' + This switch activates most optional warning messages, see + remaining list in this section for details on optional warning + messages that can be individually controlled. The warnings that + are not turned on by this switch are `-gnatwb' (biased rounding), + `-gnatwd' (implicit dereferencing), and `-gnatwh' (hiding). All + other optional warnings are turned on. + + `-gnatwA (suppress all optional errors)' + This switch suppresses all optional warning messages, see + remaining list in this section for details on optional warning + messages that can be individually controlled. + + `-gnatwb (activate warnings on biased rounding)' + If a static floating-point expression has a value that is exactly + half way between two adjacent machine numbers, then the rules of + Ada (Ada Reference Manual, section 4.9(38)) require that this + rounding be done away from zero, even if the normal unbiased + rounding rules at run time would require rounding towards zero. + This warning message alerts you to such instances where + compile-time rounding and run-time rounding are not equivalent. If + it is important to get proper run-time rounding, then you can + force this by making one of the operands into a variable. The + default is that such warnings are not generated. Note that + `-gnatwa' does not affect the setting of this warning option. + + `-gnatwB (suppress warnings on biased rounding)' + This switch disables warnings on biased rounding. + + `-gnatwc (activate warnings on conditionals)' + This switch activates warnings for conditional expressions used in + tests that are known to be True or False at compile time. The + default is that such warnings are not generated. This warning can + also be turned on using `-gnatwa'. + + `-gnatwC (suppress warnings on conditionals)' + This switch suppresses warnings for conditional expressions used in + tests that are known to be True or False at compile time. + + `-gnatwd (activate warnings on implicit dereferencing)' + If this switch is set, then the use of a prefix of an access type + in an indexed component, slice, or selected component without an + explicit `.all' will generate a warning. With this warning + enabled, access checks occur only at points where an explicit + `.all' appears in the source code (assuming no warnings are + generated as a result of this switch). The default is that such + warnings are not generated. Note that `-gnatwa' does not affect + the setting of this warning option. + + `-gnatwD (suppress warnings on implicit dereferencing)' + This switch suppresses warnings for implicit deferences in indexed + components, slices, and selected components. + + `-gnatwe (treat warnings as errors)' + This switch causes warning messages to be treated as errors. The + warning string still appears, but the warning messages are counted + as errors, and prevent the generation of an object file. + + `-gnatwf (activate warnings on unreferenced formals)' + This switch causes a warning to be generated if a formal parameter + is not referenced in the body of the subprogram. This warning can + also be turned on using `-gnatwa' or `-gnatwu'. + + `-gnatwF (suppress warnings on unreferenced formals)' + This switch suppresses warnings for unreferenced formal + parameters. Note that the combination `-gnatwu' followed by + `-gnatwF' has the effect of warning on unreferenced entities other + than subprogram formals. + + `-gnatwh (activate warnings on hiding)' + This switch activates warnings on hiding declarations. A + declaration is considered hiding if it is for a non-overloadable + entity, and it declares an entity with the same name as some other + entity that is directly or use-visible. The default is that such + warnings are not generated. Note that `-gnatwa' does not affect + the setting of this warning option. + + `-gnatwH (suppress warnings on hiding)' + This switch suppresses warnings on hiding declarations. + + `-gnatwi (activate warnings on implementation units).' + This switch activates warnings for a `with' of an internal GNAT + implementation unit, defined as any unit from the `Ada', + `Interfaces', `GNAT', or `System' hierarchies that is not + documented in either the Ada Reference Manual or the GNAT + Programmer's Reference Manual. Such units are intended only for + internal implementation purposes and should not be `with''ed by + user programs. The default is that such warnings are generated + This warning can also be turned on using `-gnatwa'. + + `-gnatwI (disable warnings on implementation units).' + This switch disables warnings for a `with' of an internal GNAT + implementation unit. + + `-gnatwl (activate warnings on elaboration pragmas)' + This switch activates warnings on missing pragma Elaborate_All + statements. See the section in this guide on elaboration checking + for details on when such pragma should be used. The default is + that such warnings are not generated. This warning can also be + turned on using `-gnatwa'. + + `-gnatwL (suppress warnings on elaboration pragmas)' + This switch suppresses warnings on missing pragma Elaborate_All + statements. See the section in this guide on elaboration checking + for details on when such pragma should be used. + + `-gnatwo (activate warnings on address clause overlays)' + This switch activates warnings for possibly unintended + initialization effects of defining address clauses that cause one + variable to overlap another. The default is that such warnings are + generated. This warning can also be turned on using `-gnatwa'. + + `-gnatwO (suppress warnings on address clause overlays)' + This switch suppresses warnings on possibly unintended + initialization effects of defining address clauses that cause one + variable to overlap another. + + `-gnatwp (activate warnings on ineffective pragma Inlines)' + This switch activates warnings for failure of front end inlining + (activated by `-gnatN') to inline a particular call. There are + many reasons for not being able to inline a call, including most + commonly that the call is too complex to inline. This warning can + also be turned on using `-gnatwa'. + + `-gnatwP (suppress warnings on ineffective pragma Inlines)' + This switch suppresses warnings on ineffective pragma Inlines. If + the inlining mechanism cannot inline a call, it will simply ignore + the request silently. + + `-gnatwr (activate warnings on redundant constructs)' + This switch activates warnings for redundant constructs. The + following is the current list of constructs regarded as redundant: + This warning can also be turned on using `-gnatwa'. + + * Assignment of an item to itself. + + * Type conversion that converts an expression to its own type. + + * Use of the attribute `Base' where `typ'Base' is the same as + `typ'. + + * Use of pragma `Pack' when all components are placed by a + record representation clause. + + `-gnatwR (suppress warnings on redundant constructs)' + This switch suppresses warnings for redundant constructs. + + `-gnatws (suppress all warnings)' + This switch completely suppresses the output of all warning + messages from the GNAT front end. Note that it does not suppress + warnings from the `gcc' back end. To suppress these back end + warnings as well, use the switch `-w' in addition to `-gnatws'. + + `-gnatwu (activate warnings on unused entities)' + This switch activates warnings to be generated for entities that + are defined but not referenced, and for units that are `with''ed + and not referenced. In the case of packages, a warning is also + generated if no entities in the package are referenced. This means + that if the package is referenced but the only references are in + `use' clauses or `renames' declarations, a warning is still + generated. A warning is also generated for a generic package that + is `with''ed but never instantiated. In the case where a package + or subprogram body is compiled, and there is a `with' on the + corresponding spec that is only referenced in the body, a warning + is also generated, noting that the `with' can be moved to the + body. The default is that such warnings are not generated. This + switch also activates warnings on unreferenced formals (it is + includes the effect of `-gnatwf'). This warning can also be + turned on using `-gnatwa'. + + `-gnatwU (suppress warnings on unused entities)' + This switch suppresses warnings for unused entities and packages. + It also turns off warnings on unreferenced formals (and thus + includes the effect of `-gnatwF'). + + A string of warning parameters can be used in the same parameter. + For example: + + -gnatwaLe + + Would turn on all optional warnings except for elaboration pragma + warnings, and also specify that warnings should be treated as + errors. + + `-w' + This switch suppresses warnings from the `gcc' backend. It may be + used in conjunction with `-gnatws' to ensure that all warnings are + suppressed during the entire compilation process. + +  + File: gnat_ug_vxw.info, Node: Debugging and Assertion Control, Next: Run-Time Checks, Prev: Output and Error Message Control, Up: Switches for gcc + + Debugging and Assertion Control + ------------------------------- + + `-gnata' + The pragmas `Assert' and `Debug' normally have no effect and are + ignored. This switch, where `a' stands for assert, causes `Assert' + and `Debug' pragmas to be activated. + + The pragmas have the form: + + pragma Assert (BOOLEAN-EXPRESSION [, + STATIC-STRING-EXPRESSION]) + pragma Debug (PROCEDURE CALL) + + The `Assert' pragma causes BOOLEAN-EXPRESSION to be tested. If + the result is `True', the pragma has no effect (other than + possible side effects from evaluating the expression). If the + result is `False', the exception `Assert_Failure' declared in the + package `System.Assertions' is raised (passing + STATIC-STRING-EXPRESSION, if present, as the message associated + with the exception). If no string expression is given the default + is a string giving the file name and line number of the pragma. + + The `Debug' pragma causes PROCEDURE to be called. Note that + `pragma Debug' may appear within a declaration sequence, allowing + debugging procedures to be called between declarations. + +  + File: gnat_ug_vxw.info, Node: Validity Checking, Next: Style Checking, Prev: Run-Time Control, Up: Switches for gcc + + Validity Checking + ----------------- + + The Ada 95 Reference Manual has specific requirements for checking for + invalid values. In particular, RM 13.9.1 requires that the evaluation + of invalid values (for example from unchecked conversions), not result + in erroneous execution. In GNAT, the result of such an evaluation in + normal default mode is to either use the value unmodified, or to raise + Constraint_Error in those cases where use of the unmodified value would + cause erroneous execution. The cases where unmodified values might lead + to erroneous execution are case statements (where a wild jump might + result from an invalid value), and subscripts on the left hand side + (where memory corruption could occur as a result of an invalid value). + + The `-gnatVx' switch allows more control over the validity checking + mode. The `x' argument here is a string of letters which control which + validity checks are performed in addition to the default checks + described above. + + * `-gnatVc' Validity checks for copies + + The right hand side of assignments, and the initializing values of + object declarations are validity checked. + + * `-gnatVd' Default (RM) validity checks + + Some validity checks are done by default following normal Ada + semantics (RM 13.9.1 (9-11)). A check is done in case statements + that the expression is within the range of the subtype. If it is + not, Constraint_Error is raised. For assignments to array + components, a check is done that the expression used as index is + within the range. If it is not, Constraint_Error is raised. Both + these validity checks may be turned off using switch `-gnatVD'. + They are turned on by default. If `-gnatVD' is specified, a + subsequent switch `-gnatVd' will leave the checks turned on. + Switch `-gnatVD' should be used only if you are sure that all such + expressions have valid values. If you use this switch and invalid + values are present, then the program is erroneous, and wild jumps + or memory overwriting may occur. + + * `-gnatVi' Validity checks for `in' mode parameters + + Arguments for parameters of mode `in' are validity checked in + function and procedure calls at the point of call. + + * `-gnatVm' Validity checks for `in out' mode parameters + + Arguments for parameters of mode `in out' are validity checked in + procedure calls at the point of call. The `'m'' here stands for + modify, since this concerns parameters that can be modified by the + call. Note that there is no specific option to test `out' + parameters, but any reference within the subprogram will be tested + in the usual manner, and if an invalid value is copied back, any + reference to it will be subject to validity checking. + + * `-gnatVo' Validity checks for operator and attribute operands + + Arguments for predefined operators and attributes are validity + checked. This includes all operators in package `Standard', the + shift operators defined as intrinsic in package `Interfaces' and + operands for attributes such as `Pos'. + + * `-gnatVr' Validity checks for function returns + + The expression in `return' statements in functions is validity + checked. + + * `-gnatVs' Validity checks for subscripts + + All subscripts expressions are checked for validity, whether they + appear on the right side or left side (in default mode only left + side subscripts are validity checked). + + * `-gnatVt' Validity checks for tests + + Expressions used as conditions in `if', `while' or `exit' + statements are checked, as well as guard expressions in entry + calls. + + * `-gnatVf' Validity checks for floating-point values + + In the absence of this switch, validity checking occurs only for + discrete values. If `-gnatVf' is specified, then validity checking + also applies for floating-point values, and NaN's and infinities + are considered invalid, as well as out of range values for + constrained types. Note that this means that standard `IEEE' + infinity mode is not allowed. The exact contexts in which + floating-point values are checked depends on the setting of other + options. For example `-gnatVif' or `-gnatVfi' (the order does not + matter) specifies that floating-point parameters of mode `in' + should be validity checked. + + * `-gnatVa' All validity checks + + All the above validity checks are turned on. That is `-gnatVa' is + equivalent to `gnatVcdfimorst'. + + * `-gnatVn' No validity checks + + This switch turns off all validity checking, including the default + checking for case statements and left hand side subscripts. Note + that the use of the switch `-gnatp' supresses all run-time checks, + including validity checks, and thus implies `-gnatVn'. + + + The `-gnatV' switch may be followed by a string of letters to turn on + a series of validity checking options. For example, `-gnatVcr' specifies + that in addition to the default validity checking, copies and function + return expressions be validity checked. In order to make it easier to + specify a set of options, the upper case letters `CDFIMORST' may be + used to turn off the corresponding lower case option, so for example + `-gnatVaM' turns on all validity checking options except for checking + of `in out' procedure arguments. + + The specification of additional validity checking generates extra + code (and in the case of `-gnatva' the code expansion can be + substantial. However, these additional checks can be very useful in + smoking out cases of uninitialized variables, incorrect use of + unchecked conversion, and other errors leading to invalid values. The + use of pragma `Initialize_Scalars' is useful in conjunction with the + extra validity checking, since this ensures that wherever possible + uninitialized variables have invalid values. + + See also the pragma `Validity_Checks' which allows modification of + the validity checking mode at the program source level, and also allows + for temporary disabling of validity checks. + +  + File: gnat_ug_vxw.info, Node: Style Checking, Next: Using gcc for Syntax Checking, Prev: Validity Checking, Up: Switches for gcc + + Style Checking + -------------- + + The -gnatyX switch causes the compiler to enforce specified style + rules. A limited set of style rules has been used in writing the GNAT + sources themselves. This switch allows user programs to activate all or + some of these checks. If the source program fails a specified style + check, an appropriate warning message is given, preceded by the + character sequence "(style)". The string X is a sequence of letters or + digits indicating the particular style checks to be performed. The + following checks are defined: + + `1-9 (specify indentation level)' + If a digit from 1-9 appears in the string after `-gnaty' then + proper indentation is checked, with the digit indicating the + indentation level required. The general style of required + indentation is as specified by the examples in the Ada Reference + Manual. Full line comments must be aligned with the `--' starting + on a column that is a multiple of the alignment level. + + `a (check attribute casing)' + If the letter a appears in the string after `-gnaty' then + attribute names, including the case of keywords such as `digits' + used as attributes names, must be written in mixed case, that is, + the initial letter and any letter following an underscore must be + uppercase. All other letters must be lowercase. + + `b (blanks not allowed at statement end)' + If the letter b appears in the string after `-gnaty' then trailing + blanks are not allowed at the end of statements. The purpose of + this rule, together with h (no horizontal tabs), is to enforce a + canonical format for the use of blanks to separate source tokens. + + `c (check comments)' + If the letter c appears in the string after `-gnaty' then comments + must meet the following set of rules: + + * The "-" that starts the column must either start in column + one, or else at least one blank must precede this sequence. + + * Comments that follow other tokens on a line must have at + least one blank following the "-" at the start of the comment. + + * Full line comments must have two blanks following the "-" + that starts the comment, with the following exceptions. + + * A line consisting only of the "-" characters, possibly + preceded by blanks is permitted. + + * A comment starting with "-x" where x is a special character + is permitted. This alows proper processing of the output + generated by specialized tools including `gnatprep' (where -! + is used) and the SPARK annnotation language (where -# is + used). For the purposes of this rule, a special character is + defined as being in one of the ASCII ranges 16#21#..16#2F# or + 16#3A#..16#3F#. + + * A line consisting entirely of minus signs, possibly preceded + by blanks, is permitted. This allows the construction of box + comments where lines of minus signs are used to form the top + and bottom of the box. + + * If a comment starts and ends with "-" is permitted as long as + at least one blank follows the initial "-". Together with the + preceding rule, this allows the construction of box comments, + as shown in the following example: + --------------------------- + -- This is a box comment -- + -- with two text lines. -- + --------------------------- + + `e (check end/exit labels)' + If the letter e appears in the string after `-gnaty' then optional + labels on `end' statements ending subprograms and on `exit' + statements exiting named loops, are required to be present. + + `f (no form feeds or vertical tabs)' + If the letter f appears in the string after `-gnaty' then neither + form feeds nor vertical tab characters are not permitted in the + source text. + + `h (no horizontal tabs)' + If the letter h appears in the string after `-gnaty' then + horizontal tab characters are not permitted in the source text. + Together with the b (no blanks at end of line) check, this + enforces a canonical form for the use of blanks to separate source + tokens. + + `i (check if-then layout)' + If the letter i appears in the string after `-gnaty', then the + keyword `then' must appear either on the same line as + corresponding `if', or on a line on its own, lined up under the + `if' with at least one non-blank line in between containing all or + part of the condition to be tested. + + `k (check keyword casing)' + If the letter k appears in the string after `-gnaty' then all + keywords must be in lower case (with the exception of keywords + such as `digits' used as attribute names to which this check does + not apply). + + `l (check layout)' + If the letter l appears in the string after `-gnaty' then layout + of statement and declaration constructs must follow the + recommendations in the Ada Reference Manual, as indicated by the + form of the syntax rules. For example an `else' keyword must be + lined up with the corresponding `if' keyword. + + There are two respects in which the style rule enforced by this + check option are more liberal than those in the Ada Reference + Manual. First in the case of record declarations, it is + permissible to put the `record' keyword on the same line as the + `type' keyword, and then the `end' in `end record' must line up + under `type'. For example, either of the following two layouts is + acceptable: + + type q is record + a : integer; + b : integer; + end record; + + type q is + record + a : integer; + b : integer; + end record; + + Second, in the case of a block statement, a permitted alternative + is to put the block label on the same line as the `declare' or + `begin' keyword, and then line the `end' keyword up under the + block label. For example both the following are permitted: + + Block : declare + A : Integer := 3; + begin + Proc (A, A); + end Block; + + Block : + declare + A : Integer := 3; + begin + Proc (A, A); + end Block; + + The same alternative format is allowed for loops. For example, + both of the following are permitted: + + Clear : while J < 10 loop + A (J) := 0; + end loop Clear; + + Clear : + while J < 10 loop + A (J) := 0; + end loop Clear; + + `m (check maximum line length)' + If the letter m appears in the string after `-gnaty' then the + length of source lines must not exceed 79 characters, including + any trailing blanks. The value of 79 allows convenient display on + an 80 character wide device or window, allowing for possible + special treatment of 80 character lines. + + `Mnnn (set maximum line length)' + If the sequence Mnnn, where nnn is a decimal number, appears in + the string after `-gnaty' then the length of lines must not exceed + the given value. + + `n (check casing of entities in Standard)' + If the letter n appears in the string after `-gnaty' then any + identifier from Standard must be cased to match the presentation + in the Ada Reference Manual (for example, `Integer' and + `ASCII.NUL'). + + `o (check order of subprogram bodies)' + If the letter o appears in the string after `-gnaty' then all + subprogram bodies in a given scope (e.g. a package body) must be + in alphabetical order. The ordering rule uses normal Ada rules for + comparing strings, ignoring casing of letters, except that if + there is a trailing numeric suffix, then the value of this suffix + is used in the ordering (e.g. Junk2 comes before Junk10). + + `p (check pragma casing)' + If the letter p appears in the string after `-gnaty' then pragma + names must be written in mixed case, that is, the initial letter + and any letter following an underscore must be uppercase. All + other letters must be lowercase. + + `r (check references)' + If the letter r appears in the string after `-gnaty' then all + identifier references must be cased in the same way as the + corresponding declaration. No specific casing style is imposed on + identifiers. The only requirement is for consistency of references + with declarations. + + `s (check separate specs)' + If the letter s appears in the string after `-gnaty' then separate + declarations ("specs") are required for subprograms (a body is not + allowed to serve as its own declaration). The only exception is + that parameterless library level procedures are not required to + have a separate declaration. This exception covers the most + frequent form of main program procedures. + + `t (check token spacing)' + If the letter t appears in the string after `-gnaty' then the + following token spacing rules are enforced: + + * The keywords `abs' and `not' must be followed by a space. + + * The token `=>' must be surrounded by spaces. + + * The token `<>' must be preceded by a space or a left + parenthesis. + + * Binary operators other than `**' must be surrounded by spaces. + There is no restriction on the layout of the `**' binary + operator. + + * Colon must be surrounded by spaces. + + * Colon-equal (assignment) must be surrounded by spaces. + + * Comma must be the first non-blank character on the line, or be + immediately preceded by a non-blank character, and must be + followed by a space. + + * If the token preceding a left paren ends with a letter or + digit, then a space must separate the two tokens. + + * A right parenthesis must either be the first non-blank + character on a line, or it must be preceded by a non-blank + character. + + * A semicolon must not be preceded by a space, and must not be + followed by a non-blank character. + + * A unary plus or minus may not be followed by a space. + + * A vertical bar must be surrounded by spaces. + + In the above rules, appearing in column one is always permitted, + that is, counts as meeting either a requirement for a required + preceding space, or as meeting a requirement for no preceding + space. + + Appearing at the end of a line is also always permitted, that is, + counts as meeting either a requirement for a following space, or + as meeting a requirement for no following space. + + If any of these style rules is violated, a message is generated giving + details on the violation. The initial characters of such messages are + always "(style)". Note that these messages are treated as warning + messages, so they normally do not prevent the generation of an object + file. The `-gnatwe' switch can be used to treat warning messages, + including style messages, as fatal errors. + + The switch `-gnaty' on its own (that is not followed by any letters or + digits), is equivalent to `gnaty3abcefhiklmprst', that is all checking + options are enabled with the exception of -gnatyo, with an indentation + level of 3. This is the standard checking option that is used for the + GNAT sources. + +  + File: gnat_ug_vxw.info, Node: Run-Time Checks, Next: Stack Overflow Checking, Prev: Debugging and Assertion Control, Up: Switches for gcc + + Run-Time Checks + --------------- + + If you compile with the default options, GNAT will insert many run-time + checks into the compiled code, including code that performs range + checking against constraints, but not arithmetic overflow checking for + integer operations (including division by zero) or checks for access + before elaboration on subprogram calls. All other run-time checks, as + required by the Ada 95 Reference Manual, are generated by default. The + following `gcc' switches refine this default behavior: + + `-gnatp' + Suppress all run-time checks as though `pragma Suppress + (all_checks') had been present in the source. Validity checks are + also suppressed (in other words `-gnatp' also implies `-gnatVn'. + Use this switch to improve the performance of the code at the + expense of safety in the presence of invalid data or program bugs. + + `-gnato' + Enables overflow checking for integer operations. This causes + GNAT to generate slower and larger executable programs by adding + code to check for overflow (resulting in raising + `Constraint_Error' as required by standard Ada semantics). These + overflow checks correspond to situations in which the true value + of the result of an operation may be outside the base range of the + result type. The following example shows the distinction: + + X1 : Integer := Integer'Last; + X2 : Integer range 1 .. 5 := 5; + ... + X1 := X1 + 1; -- `-gnato' required to catch the Constraint_Error + X2 := X2 + 1; -- range check, `-gnato' has no effect here + + Here the first addition results in a value that is outside the + base range of Integer, and hence requires an overflow check for + detection of the constraint error. The second increment operation + results in a violation of the explicit range constraint, and such + range checks are always performed. Basically the compiler can + assume that in the absence of the `-gnato' switch that any value + of type `xxx' is in range of the base type of `xxx'. + + Note that the `-gnato' switch does not affect the code generated + for any floating-point operations; it applies only to integer + semantics). For floating-point, GNAT has the `Machine_Overflows' + attribute set to `False' and the normal mode of operation is to + generate IEEE NaN and infinite values on overflow or invalid + operations (such as dividing 0.0 by 0.0). + + The reason that we distinguish overflow checking from other kinds + of range constraint checking is that a failure of an overflow + check can generate an incorrect value, but cannot cause erroneous + behavior. This is unlike the situation with a constraint check on + an array subscript, where failure to perform the check can result + in random memory description, or the range check on a case + statement, where failure to perform the check can cause a wild + jump. + + Note again that `-gnato' is off by default, so overflow checking is + not performed in default mode. This means that out of the box, + with the default settings, GNAT does not do all the checks + expected from the language description in the Ada Reference + Manual. If you want all constraint checks to be performed, as + described in this Manual, then you must explicitly use the -gnato + switch either on the `gnatmake' or `gcc' command. + + `-gnatE' + Enables dynamic checks for access-before-elaboration on subprogram + calls and generic instantiations. For full details of the effect + and use of this switch, *Note Compiling Using gcc::. + + The setting of these switches only controls the default setting of the + checks. You may modify them using either `Suppress' (to remove checks) + or `Unsuppress' (to add back suppressed checks) pragmas in the program + source. + +  + File: gnat_ug_vxw.info, Node: Stack Overflow Checking, Next: Run-Time Control, Prev: Run-Time Checks, Up: Switches for gcc + + Stack Overflow Checking + ----------------------- + + For most operating systems, `gcc' does not perform stack overflow + checking by default. This means that if the main environment task or + some other task exceeds the available stack space, then unpredictable + behavior will occur. + + To activate stack checking, compile all units with the gcc option + `-fstack-check'. For example: + + gcc -c -fstack-check package1.adb + + Units compiled with this option will generate extra instructions to + check that any use of the stack (for procedure calls or for declaring + local variables in declare blocks) do not exceed the available stack + space. If the space is exceeded, then a `Storage_Error' exception is + raised. + + For declared tasks, the stack size is always controlled by the size + given in an applicable `Storage_Size' pragma (or is set to the default + size if no pragma is used. + + For the environment task, the stack size depends on system defaults + and is unknown to the compiler. The stack may even dynamically grow on + some systems, precluding the normal Ada semantics for stack overflow. + In the worst case, unbounded stack usage, causes unbounded stack + expansion resulting in the system running out of virtual memory. + + The stack checking may still work correctly if a fixed size stack is + allocated, but this cannot be guaranteed. To ensure that a clean + exception is signalled for stack overflow, set the environment variable + `GNAT_STACK_LIMIT' to indicate the maximum stack area that can be used, + as in: + + SET GNAT_STACK_LIMIT 1600 + + The limit is given in kilobytes, so the above declaration would set the + stack limit of the environment task to 1.6 megabytes. Note that the + only purpose of this usage is to limit the amount of stack used by the + environment task. If it is necessary to increase the amount of stack + for the environment task, then this is an operating systems issue, and + must be addressed with the appropriate operating systems commands. + +  + File: gnat_ug_vxw.info, Node: Run-Time Control, Next: Validity Checking, Prev: Stack Overflow Checking, Up: Switches for gcc + + Run-Time Control + ---------------- + + `-gnatT nnn' + The `gnatT' switch can be used to specify the time-slicing value + to be used for task switching between equal priority tasks. The + value `nnn' is given in microseconds as a decimal integer. + + Setting the time-slicing value is only effective if the underlying + thread control system can accommodate time slicing. Check the + documentation of your operating system for details. Note that the + time-slicing value can also be set by use of pragma `Time_Slice' + or by use of the `t' switch in the gnatbind step. The pragma + overrides a command line argument if both are present, and the `t' + switch for gnatbind overrides both the pragma and the `gcc' + command line switch. + +  + File: gnat_ug_vxw.info, Node: Using gcc for Syntax Checking, Next: Using gcc for Semantic Checking, Prev: Style Checking, Up: Switches for gcc + + Using `gcc' for Syntax Checking + ------------------------------- + + `-gnats' + The `s' stands for syntax. + + Run GNAT in syntax checking only mode. For example, the command + + $ gcc -c -gnats x.adb + + compiles file `x.adb' in syntax-check-only mode. You can check a + series of files in a single command , and can use wild cards to + specify such a group of files. Note that you must specify the + `-c' (compile only) flag in addition to the `-gnats' flag. . + + You may use other switches in conjunction with `-gnats'. In + particular, `-gnatl' and `-gnatv' are useful to control the format + of any generated error messages. + + The output is simply the error messages, if any. No object file or + ALI file is generated by a syntax-only compilation. Also, no units + other than the one specified are accessed. For example, if a unit + `X' `with''s a unit `Y', compiling unit `X' in syntax check only + mode does not access the source file containing unit `Y'. + + Normally, GNAT allows only a single unit in a source file. + However, this restriction does not apply in syntax-check-only + mode, and it is possible to check a file containing multiple + compilation units concatenated together. This is primarily used by + the `gnatchop' utility (*note Renaming Files Using gnatchop::). + +  + File: gnat_ug_vxw.info, Node: Using gcc for Semantic Checking, Next: Compiling Ada 83 Programs, Prev: Using gcc for Syntax Checking, Up: Switches for gcc + + Using `gcc' for Semantic Checking + --------------------------------- + + `-gnatc' + The `c' stands for check. Causes the compiler to operate in + semantic check mode, with full checking for all illegalities + specified in the Ada 95 Reference Manual, but without generation + of any object code (no object file is generated). + + Because dependent files must be accessed, you must follow the GNAT + semantic restrictions on file structuring to operate in this mode: + + * The needed source files must be accessible (*note Search + Paths and the Run-Time Library (RTL)::). + + * Each file must contain only one compilation unit. + + * The file name and unit name must match (*note File Naming + Rules::). + + The output consists of error messages as appropriate. No object + file is generated. An `ALI' file is generated for use in the + context of cross-reference tools, but this file is marked as not + being suitable for binding (since no object file is generated). + The checking corresponds exactly to the notion of legality in the + Ada 95 Reference Manual. + + Any unit can be compiled in semantics-checking-only mode, including + units that would not normally be compiled (subunits, and + specifications where a separate body is present). + +  + File: gnat_ug_vxw.info, Node: Compiling Ada 83 Programs, Next: Character Set Control, Prev: Using gcc for Semantic Checking, Up: Switches for gcc + + Compiling Ada 83 Programs + ------------------------- + + `-gnat83' + Although GNAT is primarily an Ada 95 compiler, it accepts this + switch to specify that an Ada 83 program is to be compiled in + Ada83 mode. If you specify this switch, GNAT rejects most Ada 95 + extensions and applies Ada 83 semantics where this can be done + easily. It is not possible to guarantee this switch does a perfect + job; for example, some subtle tests, such as are found in earlier + ACVC tests (that have been removed from the ACVC suite for Ada + 95), may not compile correctly. However, for most purposes, using + this switch should help to ensure that programs that compile + correctly under the `-gnat83' switch can be ported easily to an + Ada 83 compiler. This is the main use of the switch. + + With few exceptions (most notably the need to use `<>' on + unconstrained generic formal parameters, the use of the new Ada 95 + keywords, and the use of packages with optional bodies), it is not + necessary to use the `-gnat83' switch when compiling Ada 83 + programs, because, with rare exceptions, Ada 95 is upwardly + compatible with Ada 83. This means that a correct Ada 83 program + is usually also a correct Ada 95 program. + +  + File: gnat_ug_vxw.info, Node: Character Set Control, Next: File Naming Control, Prev: Compiling Ada 83 Programs, Up: Switches for gcc + + Character Set Control + --------------------- + + `-gnatiC' + Normally GNAT recognizes the Latin-1 character set in source + program identifiers, as described in the Ada 95 Reference Manual. + This switch causes GNAT to recognize alternate character sets in + identifiers. C is a single character indicating the character + set, as follows: + + `1' + Latin-1 identifiers + + `2' + Latin-2 letters allowed in identifiers + + `3' + Latin-3 letters allowed in identifiers + + `4' + Latin-4 letters allowed in identifiers + + `5' + Latin-5 (Cyrillic) letters allowed in identifiers + + `9' + Latin-9 letters allowed in identifiers + + `p' + IBM PC letters (code page 437) allowed in identifiers + + `8' + IBM PC letters (code page 850) allowed in identifiers + + `f' + Full upper-half codes allowed in identifiers + + `n' + No upper-half codes allowed in identifiers + + `w' + Wide-character codes (that is, codes greater than 255) + allowed in identifiers + + *Note Foreign Language Representation::, for full details on the + implementation of these character sets. + + `-gnatWE' + Specify the method of encoding for wide characters. E is one of + the following: + + `h' + Hex encoding (brackets coding also recognized) + + `u' + Upper half encoding (brackets encoding also recognized) + + `s' + Shift/JIS encoding (brackets encoding also recognized) + + `e' + EUC encoding (brackets encoding also recognized) + + `8' + UTF-8 encoding (brackets encoding also recognized) + + `b' + Brackets encoding only (default value) For full details on + the these encoding methods see *Note Wide Character Encodings::. + Note that brackets coding is always accepted, even if one of the + other options is specified, so for example `-gnatW8' specifies + that both brackets and `UTF-8' encodings will be recognized. The + units that are with'ed directly or indirectly will be scanned + using the specified representation scheme, and so if one of the + non-brackets scheme is used, it must be used consistently + throughout the program. However, since brackets encoding is always + recognized, it may be conveniently used in standard libraries, + allowing these libraries to be used with any of the available + coding schemes. scheme. If no `-gnatW?' parameter is present, + then the default representation is Brackets encoding only. + + Note that the wide character representation that is specified + (explicitly or by default) for the main program also acts as the + default encoding used for Wide_Text_IO files if not specifically + overridden by a WCEM form parameter. + +  + File: gnat_ug_vxw.info, Node: File Naming Control, Next: Subprogram Inlining Control, Prev: Character Set Control, Up: Switches for gcc + + File Naming Control + ------------------- + + `-gnatkN' + Activates file name "krunching". N, a decimal integer in the range + 1-999, indicates the maximum allowable length of a file name (not + including the `.ads' or `.adb' extension). The default is not to + enable file name krunching. + + For the source file naming rules, *Note File Naming Rules::. + +  + File: gnat_ug_vxw.info, Node: Subprogram Inlining Control, Next: Auxiliary Output Control, Prev: File Naming Control, Up: Switches for gcc + + Subprogram Inlining Control + --------------------------- + + `-gnatn' + The `n' here is intended to suggest the first syllable of the word + "inline". GNAT recognizes and processes `Inline' pragmas. + However, for the inlining to actually occur, optimization must be + enabled. To enable inlining across unit boundaries, this is, + inlining a call in one unit of a subprogram declared in a + `with''ed unit, you must also specify this switch. In the absence + of this switch, GNAT does not attempt inlining across units and + does not need to access the bodies of subprograms for which + `pragma Inline' is specified if they are not in the current unit. + + If you specify this switch the compiler will access these bodies, + creating an extra source dependency for the resulting object file, + and where possible, the call will be inlined. For further details + on when inlining is possible see *Note Inlining of Subprograms::. + + `-gnatN' + The front end inlining activated by this switch is generally more + extensive, and quite often more effective than the standard + `-gnatn' inlining mode. It will also generate additional + dependencies. + +  + File: gnat_ug_vxw.info, Node: Auxiliary Output Control, Next: Debugging Control, Prev: Subprogram Inlining Control, Up: Switches for gcc + + Auxiliary Output Control + ------------------------ + + `-gnatt' + Causes GNAT to write the internal tree for a unit to a file (with + the extension `.adt'. This not normally required, but is used by + separate analysis tools. Typically these tools do the necessary + compilations automatically, so you should not have to specify this + switch in normal operation. + + `-gnatu' + Print a list of units required by this compilation on `stdout'. + The listing includes all units on which the unit being compiled + depends either directly or indirectly. + + `-pass-exit-codes' + If this switch is not used, the exit code returned by `gcc' when + compiling multiple files indicates whether all source files have + been successfully used to generate object files or not. + + When `-pass-exit-codes' is used, `gcc' exits with an extended exit + status and allows an integrated development environment to better + react to a compilation failure. Those exit status are: + + 5 + There was an error in at least one source file. + + 3 + At least one source file did not generate an object file. + + 2 + The compiler died unexpectedly (internal error for example). + + 0 + An object file has been generated for every source file. + +  + File: gnat_ug_vxw.info, Node: Debugging Control, Next: Units to Sources Mapping Files, Prev: Auxiliary Output Control, Up: Switches for gcc + + Debugging Control + ----------------- + + `-gnatdX' + Activate internal debugging switches. X is a letter or digit, or + string of letters or digits, which specifies the type of debugging + outputs desired. Normally these are used only for internal + development or system debugging purposes. You can find full + documentation for these switches in the body of the `Debug' unit + in the compiler source file `debug.adb'. + + `-gnatG' + This switch causes the compiler to generate auxiliary output + containing a pseudo-source listing of the generated expanded code. + Like most Ada compilers, GNAT works by first transforming the high + level Ada code into lower level constructs. For example, tasking + operations are transformed into calls to the tasking run-time + routines. A unique capability of GNAT is to list this expanded + code in a form very close to normal Ada source. This is very + useful in understanding the implications of various Ada usage on + the efficiency of the generated code. There are many cases in Ada + (e.g. the use of controlled types), where simple Ada statements can + generate a lot of run-time code. By using `-gnatG' you can identify + these cases, and consider whether it may be desirable to modify + the coding approach to improve efficiency. + + The format of the output is very similar to standard Ada source, + and is easily understood by an Ada programmer. The following + special syntactic additions correspond to low level features used + in the generated code that do not have any exact analogies in pure + Ada source form. The following is a partial list of these special + constructions. See the specification of package `Sprint' in file + `sprint.ads' for a full list. + + `new XXX [storage_pool = YYY]' + Shows the storage pool being used for an allocator. + + `at end PROCEDURE-NAME;' + Shows the finalization (cleanup) procedure for a scope. + + `(if EXPR then EXPR else EXPR)' + Conditional expression equivalent to the `x?y:z' construction + in C. + + `TARGET^(SOURCE)' + A conversion with floating-point truncation instead of + rounding. + + `TARGET?(SOURCE)' + A conversion that bypasses normal Ada semantic checking. In + particular enumeration types and fixed-point types are + treated simply as integers. + + `TARGET?^(SOURCE)' + Combines the above two cases. + + `X #/ Y' + `X #mod Y' + `X #* Y' + `X #rem Y' + A division or multiplication of fixed-point values which are + treated as integers without any kind of scaling. + + `free EXPR [storage_pool = XXX]' + Shows the storage pool associated with a `free' statement. + + `freeze TYPENAME [ACTIONS]' + Shows the point at which TYPENAME is frozen, with possible + associated actions to be performed at the freeze point. + + `reference ITYPE' + Reference (and hence definition) to internal type ITYPE. + + `FUNCTION-NAME! (ARG, ARG, ARG)' + Intrinsic function call. + + `LABELNAME : label' + Declaration of label LABELNAME. + + `EXPR && EXPR && EXPR ... && EXPR' + A multiple concatenation (same effect as EXPR & EXPR & EXPR, + but handled more efficiently). + + `[constraint_error]' + Raise the `Constraint_Error' exception. + + `EXPRESSION'reference' + A pointer to the result of evaluating EXPRESSION. + + `TARGET-TYPE!(SOURCE-EXPRESSION)' + An unchecked conversion of SOURCE-EXPRESSION to TARGET-TYPE. + + `[NUMERATOR/DENOMINATOR]' + Used to represent internal real literals (that) have no exact + representation in base 2-16 (for example, the result of + compile time evaluation of the expression 1.0/27.0). + + `-gnatD' + This switch is used in conjunction with `-gnatG' to cause the + expanded source, as described above to be written to files + with names `xxx.dg', where `xxx' is the normal file name, for + example, if the source file name is `hello.adb', then a file + `hello.adb.dg' will be written. The debugging information + generated by the `gcc' `-g' switch will refer to the generated + `xxx.dg' file. This allows you to do source level debugging + using the generated code which is sometimes useful for + complex code, for example to find out exactly which part of a + complex construction raised an exception. This switch also + suppress generation of cross-reference information (see + -gnatx). + + `-gnatC' + In the generated debugging information, and also in the case + of long external names, the compiler uses a compression + mechanism if the name is very long. This compression method + uses a checksum, and avoids trouble on some operating systems + which have difficulty with very long names. The `-gnatC' + switch forces this compression approach to be used on all + external names and names in the debugging information tables. + This reduces the size of the generated executable, at the + expense of making the naming scheme more complex. The + compression only affects the qualification of the name. Thus + a name in the source: + + Very_Long_Package.Very_Long_Inner_Package.Var + + would normally appear in these tables as: + + very_long_package__very_long_inner_package__var + + but if the `-gnatC' switch is used, then the name appears as + + XCb7e0c705__var + + Here b7e0c705 is a compressed encoding of the qualification + prefix. The GNAT Ada aware version of GDB understands these + encoded prefixes, so if this debugger is used, the encoding + is largely hidden from the user of the compiler. + + `-gnatR[0|1|2|3][s]' + This switch controls output from the compiler of a listing showing + representation information for declared types and objects. For + `-gnatR0', no information is output (equivalent to omitting the + `-gnatR' switch). For `-gnatR1' (which is the default, so `-gnatR' + with no parameter has the same effect), size and alignment + information is listed for declared array and record types. For + `-gnatR2', size and alignment information is listed for all + expression information for values that are computed at run time for + variant records. These symbolic expressions have a mostly obvious + format with #n being used to represent the value of the n'th + discriminant. See source files `repinfo.ads/adb' in the `GNAT' + sources for full detalis on the format of `-gnatR3' output. If the + switch is followed by an s (e.g. `-gnatR2s'), then the output is + to a file with the name `file.rep' where file is the name of the + corresponding source file. + + `-gnatx' + Normally the compiler generates full cross-referencing information + in the `ALI' file. This information is used by a number of tools, + including `gnatfind' and `gnatxref'. The -gnatx switch suppresses + this information. This saves some space and may slightly speed up + compilation, but means that these tools cannot be used. + +  + File: gnat_ug_vxw.info, Node: Units to Sources Mapping Files, Prev: Debugging Control, Up: Switches for gcc + + Units to Sources Mapping Files + ------------------------------ + + `-gnatemPATH' + A mapping file is a way to communicate to the compiler two + mappings: from unit names to file names (without any directory + information) and from file names to path names (with full + directory information). These mappings are used by the compiler to + short-circuit the path search. + + A mapping file is a sequence of sets of three lines. In each set, + the first line is the unit name, in lower case, with "%s" appended + for specifications and "%b" appended for bodies; the second line + is the file name; and the third line is the path name. + + Example: + main%b + main.2.ada + /gnat/project1/sources/main.2.ada + + When the switch `-gnatem' is specified, the compiler will create + in memory the two mappings from the specified file. If there is + any problem (non existent file, truncated file or duplicate + entries), no mapping will be created. + + Several `-gnatem' switches may be specified; however, only the last + one on the command line will be taken into account. + + When using a project file, `gnatmake' create a temporary mapping + file and communicates it to the compiler using this switch. + +  + File: gnat_ug_vxw.info, Node: Search Paths and the Run-Time Library (RTL), Next: Order of Compilation Issues, Prev: Switches for gcc, Up: Compiling Using gcc + + Search Paths and the Run-Time Library (RTL) + =========================================== + + With the GNAT source-based library system, the compiler must be able to + find source files for units that are needed by the unit being compiled. + Search paths are used to guide this process. + + The compiler compiles one source file whose name must be given + explicitly on the command line. In other words, no searching is done + for this file. To find all other source files that are needed (the most + common being the specs of units), the compiler examines the following + directories, in the following order: + + 1. The directory containing the source file of the main unit being + compiled (the file name on the command line). + + 2. Each directory named by an `-I' switch given on the `gcc' command + line, in the order given. + + 3. Each of the directories listed in the value of the + `ADA_INCLUDE_PATH' environment variable. Construct this value + exactly as the `PATH' environment variable: a list of directory + names separated by colons (semicolons when working with the NT + version). + + 4. The content of the "ada_source_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as + the GNAT Run Time Library (RTL) source files. *Note Installing an + Ada Library:: + + Specifying the switch `-I-' inhibits the use of the directory + containing the source file named in the command line. You can still + have this directory on your search path, but in this case it must be + explicitly requested with a `-I' switch. + + Specifying the switch `-nostdinc' inhibits the search of the default + location for the GNAT Run Time Library (RTL) source files. + + The compiler outputs its object files and ALI files in the current + working directory. Caution: The object file can be redirected with the + `-o' switch; however, `gcc' and `gnat1' have not been coordinated on + this so the ALI file will not go to the right place. Therefore, you + should avoid using the `-o' switch. + + The packages `Ada', `System', and `Interfaces' and their children + make up the GNAT RTL, together with the simple `System.IO' package used + in the "Hello World" example. The sources for these units are needed by + the compiler and are kept together in one directory. Not all of the + bodies are needed, but all of the sources are kept together anyway. In + a normal installation, you need not specify these directory names when + compiling or binding. Either the environment variables or the built-in + defaults cause these files to be found. + + In addition to the language-defined hierarchies (System, Ada and + Interfaces), the GNAT distribution provides a fourth hierarchy, + consisting of child units of GNAT. This is a collection of generally + useful routines. See the GNAT Reference Manual for further details. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + +  + File: gnat_ug_vxw.info, Node: Order of Compilation Issues, Next: Examples, Prev: Search Paths and the Run-Time Library (RTL), Up: Compiling Using gcc + + Order of Compilation Issues + =========================== + + If, in our earlier example, there was a spec for the `hello' procedure, + it would be contained in the file `hello.ads'; yet this file would not + have to be explicitly compiled. This is the result of the model we + chose to implement library management. Some of the consequences of this + model are as follows: + + * There is no point in compiling specs (except for package specs + with no bodies) because these are compiled as needed by clients. If + you attempt a useless compilation, you will receive an error + message. It is also useless to compile subunits because they are + compiled as needed by the parent. + + * There are no order of compilation requirements: performing a + compilation never obsoletes anything. The only way you can obsolete + something and require recompilations is to modify one of the + source files on which it depends. + + * There is no library as such, apart from the ALI files (*note The + Ada Library Information Files::, for information on the format of + these files). For now we find it convenient to create separate ALI + files, but eventually the information therein may be incorporated + into the object file directly. + + * When you compile a unit, the source files for the specs of all + units that it `with''s, all its subunits, and the bodies of any + generics it instantiates must be available (reachable by the + search-paths mechanism described above), or you will receive a + fatal error message. + +  + File: gnat_ug_vxw.info, Node: Examples, Prev: Order of Compilation Issues, Up: Compiling Using gcc + + Examples + ======== + + The following are some typical Ada compilation command line examples: + + `$ gcc -c xyz.adb' + Compile body in file `xyz.adb' with all default options. + + `$ gcc -c -O2 -gnata xyz-def.adb' + Compile the child unit package in file `xyz-def.adb' with extensive + optimizations, and pragma `Assert'/`Debug' statements enabled. + + `$ gcc -c -gnatc abc-def.adb' + Compile the subunit in file `abc-def.adb' in semantic-checking-only + mode. + +  + File: gnat_ug_vxw.info, Node: Binding Using gnatbind, Next: Linking Using gnatlink, Prev: Compiling Using gcc, Up: Top + + Binding Using `gnatbind' + ************************ + + * Menu: + + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + + This chapter describes the GNAT binder, `gnatbind', which is used to + bind compiled GNAT objects. The `gnatbind' program performs four + separate functions: + + 1. Checks that a program is consistent, in accordance with the rules + in Chapter 10 of the Ada 95 Reference Manual. In particular, error + messages are generated if a program uses inconsistent versions of a + given unit. + + 2. Checks that an acceptable order of elaboration exists for the + program and issues an error message if it cannot find an order of + elaboration that satisfies the rules in Chapter 10 of the Ada 95 + Language Manual. + + 3. Generates a main program incorporating the given elaboration order. + This program is a small Ada package (body and spec) that must be + subsequently compiled using the GNAT compiler. The necessary + compilation step is usually performed automatically by `gnatlink'. + The two most important functions of this program are to call the + elaboration routines of units in an appropriate order and to call + the main program. + + 4. Determines the set of object files required by the given main + program. This information is output in the forms of comments in + the generated program, to be read by the `gnatlink' utility used + to link the Ada application. + +  + File: gnat_ug_vxw.info, Node: Running gnatbind, Next: Generating the Binder Program in C, Up: Binding Using gnatbind + + Running `gnatbind' + ================== + + The form of the `gnatbind' command is + + $ gnatbind [SWITCHES] MAINPROG[.ali] [SWITCHES] + + where MAINPROG.adb is the Ada file containing the main program unit + body. If no switches are specified, `gnatbind' constructs an Ada + package in two files which names are `b~ADA_MAIN.ads', and + `b~ADA_MAIN.adb'. For example, if given the parameter `hello.ali', for + a main program contained in file `hello.adb', the binder output files + would be `b~hello.ads' and `b~hello.adb'. + + When doing consistency checking, the binder takes into consideration + any source files it can locate. For example, if the binder determines + that the given main program requires the package `Pack', whose `.ali' + file is `pack.ali' and whose corresponding source spec file is + `pack.ads', it attempts to locate the source file `pack.ads' (using the + same search path conventions as previously described for the `gcc' + command). If it can locate this source file, it checks that the time + stamps or source checksums of the source and its references to in `ali' + files match. In other words, any `ali' files that mentions this spec + must have resulted from compiling this version of the source file (or + in the case where the source checksums match, a version close enough + that the difference does not matter). + + The effect of this consistency checking, which includes source + files, is that the binder ensures that the program is consistent with + the latest version of the source files that can be located at bind + time. Editing a source file without compiling files that depend on the + source file cause error messages to be generated by the binder. + + For example, suppose you have a main program `hello.adb' and a + package `P', from file `p.ads' and you perform the following steps: + + 1. Enter `gcc -c hello.adb' to compile the main program. + + 2. Enter `gcc -c p.ads' to compile package `P'. + + 3. Edit file `p.ads'. + + 4. Enter `gnatbind hello'. + + At this point, the file `p.ali' contains an out-of-date time stamp + because the file `p.ads' has been edited. The attempt at binding fails, + and the binder generates the following error messages: + + error: "hello.adb" must be recompiled ("p.ads" has been modified) + error: "p.ads" has been modified and must be recompiled + + Now both files must be recompiled as indicated, and then the bind can + succeed, generating a main program. You need not normally be concerned + with the contents of this file, but it is similar to the following which + is the binder file generated for a simple "hello world" program. + + -- The package is called Ada_Main unless this name is actually used + -- as a unit name in the partition, in which case some other unique + -- name is used. + + with System; + package ada_main is + + Elab_Final_Code : Integer; + pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code"); + + -- The main program saves the parameters (argument count, + -- argument values, environment pointer) in global variables + -- for later access by other units including + -- Ada.Command_Line. + + gnat_argc : Integer; + gnat_argv : System.Address; + gnat_envp : System.Address; + + -- The actual variables are stored in a library routine. This + -- is useful for some shared library situations, where there + -- are problems if variables are not in the library. + + pragma Import (C, gnat_argc); + pragma Import (C, gnat_argv); + pragma Import (C, gnat_envp); + + -- The exit status is similarly an external location + + gnat_exit_status : Integer; + pragma Import (C, gnat_exit_status); + + GNAT_Version : constant String := + "GNAT Version: 3.15w (20010315)"; + pragma Export (C, GNAT_Version, "__gnat_version"); + + -- This is the generated adafinal routine that performs + -- finalization at the end of execution. In the case where + -- Ada is the main program, this main program makes a call + -- to adafinal at program termination. + + procedure adafinal; + pragma Export (C, adafinal, "adafinal"); + + -- This is the generated adainit routine that performs + -- initialization at the start of execution. In the case + -- where Ada is the main program, this main program makes + -- a call to adainit at program startup. + + procedure adainit; + pragma Export (C, adainit, "adainit"); + + -- This routine is called at the start of execution. It is + -- a dummy routine that is used by the debugger to breakpoint + -- at the start of execution. + + procedure Break_Start; + pragma Import (C, Break_Start, "__gnat_break_start"); + + -- This is the actual generated main program (it would be + -- suppressed if the no main program switch were used). As + -- required by standard system conventions, this program has + -- the external name main. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer; + pragma Export (C, main, "main"); + + -- The following set of constants give the version + -- identification values for every unit in the bound + -- partition. This identification is computed from all + -- dependent semantic units, and corresponds to the + -- string that would be returned by use of the + -- Body_Version or Version attributes. + + type Version_32 is mod 2 ** 32; + u00001 : constant Version_32 := 16#7880BEB3#; + u00002 : constant Version_32 := 16#0D24CBD0#; + u00003 : constant Version_32 := 16#3283DBEB#; + u00004 : constant Version_32 := 16#2359F9ED#; + u00005 : constant Version_32 := 16#664FB847#; + u00006 : constant Version_32 := 16#68E803DF#; + u00007 : constant Version_32 := 16#5572E604#; + u00008 : constant Version_32 := 16#46B173D8#; + u00009 : constant Version_32 := 16#156A40CF#; + u00010 : constant Version_32 := 16#033DABE0#; + u00011 : constant Version_32 := 16#6AB38FEA#; + u00012 : constant Version_32 := 16#22B6217D#; + u00013 : constant Version_32 := 16#68A22947#; + u00014 : constant Version_32 := 16#18CC4A56#; + u00015 : constant Version_32 := 16#08258E1B#; + u00016 : constant Version_32 := 16#367D5222#; + u00017 : constant Version_32 := 16#20C9ECA4#; + u00018 : constant Version_32 := 16#50D32CB6#; + u00019 : constant Version_32 := 16#39A8BB77#; + u00020 : constant Version_32 := 16#5CF8FA2B#; + u00021 : constant Version_32 := 16#2F1EB794#; + u00022 : constant Version_32 := 16#31AB6444#; + u00023 : constant Version_32 := 16#1574B6E9#; + u00024 : constant Version_32 := 16#5109C189#; + u00025 : constant Version_32 := 16#56D770CD#; + u00026 : constant Version_32 := 16#02F9DE3D#; + u00027 : constant Version_32 := 16#08AB6B2C#; + u00028 : constant Version_32 := 16#3FA37670#; + u00029 : constant Version_32 := 16#476457A0#; + u00030 : constant Version_32 := 16#731E1B6E#; + u00031 : constant Version_32 := 16#23C2E789#; + u00032 : constant Version_32 := 16#0F1BD6A1#; + u00033 : constant Version_32 := 16#7C25DE96#; + u00034 : constant Version_32 := 16#39ADFFA2#; + u00035 : constant Version_32 := 16#571DE3E7#; + u00036 : constant Version_32 := 16#5EB646AB#; + u00037 : constant Version_32 := 16#4249379B#; + u00038 : constant Version_32 := 16#0357E00A#; + u00039 : constant Version_32 := 16#3784FB72#; + u00040 : constant Version_32 := 16#2E723019#; + u00041 : constant Version_32 := 16#623358EA#; + u00042 : constant Version_32 := 16#107F9465#; + u00043 : constant Version_32 := 16#6843F68A#; + u00044 : constant Version_32 := 16#63305874#; + u00045 : constant Version_32 := 16#31E56CE1#; + u00046 : constant Version_32 := 16#02917970#; + u00047 : constant Version_32 := 16#6CCBA70E#; + u00048 : constant Version_32 := 16#41CD4204#; + u00049 : constant Version_32 := 16#572E3F58#; + u00050 : constant Version_32 := 16#20729FF5#; + u00051 : constant Version_32 := 16#1D4F93E8#; + u00052 : constant Version_32 := 16#30B2EC3D#; + u00053 : constant Version_32 := 16#34054F96#; + u00054 : constant Version_32 := 16#5A199860#; + u00055 : constant Version_32 := 16#0E7F912B#; + u00056 : constant Version_32 := 16#5760634A#; + u00057 : constant Version_32 := 16#5D851835#; + + -- The following Export pragmas export the version numbers + -- with symbolic names ending in B (for body) or S + -- (for spec) so that they can be located in a link. The + -- information provided here is sufficient to track down + -- the exact versions of units used in a given build. + + pragma Export (C, u00001, "helloB"); + pragma Export (C, u00002, "system__standard_libraryB"); + pragma Export (C, u00003, "system__standard_libraryS"); + pragma Export (C, u00004, "adaS"); + pragma Export (C, u00005, "ada__text_ioB"); + pragma Export (C, u00006, "ada__text_ioS"); + pragma Export (C, u00007, "ada__exceptionsB"); + pragma Export (C, u00008, "ada__exceptionsS"); + pragma Export (C, u00009, "gnatS"); + pragma Export (C, u00010, "gnat__heap_sort_aB"); + pragma Export (C, u00011, "gnat__heap_sort_aS"); + pragma Export (C, u00012, "systemS"); + pragma Export (C, u00013, "system__exception_tableB"); + pragma Export (C, u00014, "system__exception_tableS"); + pragma Export (C, u00015, "gnat__htableB"); + pragma Export (C, u00016, "gnat__htableS"); + pragma Export (C, u00017, "system__exceptionsS"); + pragma Export (C, u00018, "system__machine_state_operationsB"); + pragma Export (C, u00019, "system__machine_state_operationsS"); + pragma Export (C, u00020, "system__machine_codeS"); + pragma Export (C, u00021, "system__storage_elementsB"); + pragma Export (C, u00022, "system__storage_elementsS"); + pragma Export (C, u00023, "system__secondary_stackB"); + pragma Export (C, u00024, "system__secondary_stackS"); + pragma Export (C, u00025, "system__parametersB"); + pragma Export (C, u00026, "system__parametersS"); + pragma Export (C, u00027, "system__soft_linksB"); + pragma Export (C, u00028, "system__soft_linksS"); + pragma Export (C, u00029, "system__stack_checkingB"); + pragma Export (C, u00030, "system__stack_checkingS"); + pragma Export (C, u00031, "system__tracebackB"); + pragma Export (C, u00032, "system__tracebackS"); + pragma Export (C, u00033, "ada__streamsS"); + pragma Export (C, u00034, "ada__tagsB"); + pragma Export (C, u00035, "ada__tagsS"); + pragma Export (C, u00036, "system__string_opsB"); + pragma Export (C, u00037, "system__string_opsS"); + pragma Export (C, u00038, "interfacesS"); + pragma Export (C, u00039, "interfaces__c_streamsB"); + pragma Export (C, u00040, "interfaces__c_streamsS"); + pragma Export (C, u00041, "system__file_ioB"); + pragma Export (C, u00042, "system__file_ioS"); + pragma Export (C, u00043, "ada__finalizationB"); + pragma Export (C, u00044, "ada__finalizationS"); + pragma Export (C, u00045, "system__finalization_rootB"); + pragma Export (C, u00046, "system__finalization_rootS"); + pragma Export (C, u00047, "system__finalization_implementationB"); + pragma Export (C, u00048, "system__finalization_implementationS"); + pragma Export (C, u00049, "system__string_ops_concat_3B"); + pragma Export (C, u00050, "system__string_ops_concat_3S"); + pragma Export (C, u00051, "system__stream_attributesB"); + pragma Export (C, u00052, "system__stream_attributesS"); + pragma Export (C, u00053, "ada__io_exceptionsS"); + pragma Export (C, u00054, "system__unsigned_typesS"); + pragma Export (C, u00055, "system__file_control_blockS"); + pragma Export (C, u00056, "ada__finalization__list_controllerB"); + pragma Export (C, u00057, "ada__finalization__list_controllerS"); + + -- BEGIN ELABORATION ORDER + -- ada (spec) + -- gnat (spec) + -- gnat.heap_sort_a (spec) + -- gnat.heap_sort_a (body) + -- gnat.htable (spec) + -- gnat.htable (body) + -- interfaces (spec) + -- system (spec) + -- system.machine_code (spec) + -- system.parameters (spec) + -- system.parameters (body) + -- interfaces.c_streams (spec) + -- interfaces.c_streams (body) + -- system.standard_library (spec) + -- ada.exceptions (spec) + -- system.exception_table (spec) + -- system.exception_table (body) + -- ada.io_exceptions (spec) + -- system.exceptions (spec) + -- system.storage_elements (spec) + -- system.storage_elements (body) + -- system.machine_state_operations (spec) + -- system.machine_state_operations (body) + -- system.secondary_stack (spec) + -- system.stack_checking (spec) + -- system.soft_links (spec) + -- system.soft_links (body) + -- system.stack_checking (body) + -- system.secondary_stack (body) + -- system.standard_library (body) + -- system.string_ops (spec) + -- system.string_ops (body) + -- ada.tags (spec) + -- ada.tags (body) + -- ada.streams (spec) + -- system.finalization_root (spec) + -- system.finalization_root (body) + -- system.string_ops_concat_3 (spec) + -- system.string_ops_concat_3 (body) + -- system.traceback (spec) + -- system.traceback (body) + -- ada.exceptions (body) + -- system.unsigned_types (spec) + -- system.stream_attributes (spec) + -- system.stream_attributes (body) + -- system.finalization_implementation (spec) + -- system.finalization_implementation (body) + -- ada.finalization (spec) + -- ada.finalization (body) + -- ada.finalization.list_controller (spec) + -- ada.finalization.list_controller (body) + -- system.file_control_block (spec) + -- system.file_io (spec) + -- system.file_io (body) + -- ada.text_io (spec) + -- ada.text_io (body) + -- hello (body) + -- END ELABORATION ORDER + + end ada_main; + + -- The following source file name pragmas allow the generated file + -- names to be unique for different main programs. They are needed + -- since the package name will always be Ada_Main. + + pragma Source_File_Name (ada_main, Spec_File_Name => "b~hello.ads"); + pragma Source_File_Name (ada_main, Body_File_Name => "b~hello.adb"); + + -- Generated package body for Ada_Main starts here + + package body ada_main is + + -- The actual finalization is performed by calling the + -- library routine in System.Standard_Library.Adafinal + + procedure Do_Finalize; + pragma Import (C, Do_Finalize, "system__standard_library__adafinal"); + + ------------- + -- adainit -- + ------------- + + procedure adainit is + + -- These booleans are set to True once the associated unit has + -- been elaborated. It is also used to avoid elaborating the + -- same unit twice. + + E040 : Boolean; pragma Import (Ada, E040, "interfaces__c_streams_E"); + E008 : Boolean; pragma Import (Ada, E008, "ada__exceptions_E"); + E014 : Boolean; pragma Import (Ada, E014, "system__exception_table_E"); + E053 : Boolean; pragma Import (Ada, E053, "ada__io_exceptions_E"); + E017 : Boolean; pragma Import (Ada, E017, "system__exceptions_E"); + E024 : Boolean; pragma Import (Ada, E024, "system__secondary_stack_E"); + E030 : Boolean; pragma Import (Ada, E030, "system__stack_checking_E"); + E028 : Boolean; pragma Import (Ada, E028, "system__soft_links_E"); + E035 : Boolean; pragma Import (Ada, E035, "ada__tags_E"); + E033 : Boolean; pragma Import (Ada, E033, "ada__streams_E"); + E046 : Boolean; pragma Import (Ada, E046, "system__finalization_root_E"); + E048 : Boolean; pragma Import (Ada, E048, "system__finalization_implementation_E"); + E044 : Boolean; pragma Import (Ada, E044, "ada__finalization_E"); + E057 : Boolean; pragma Import (Ada, E057, "ada__finalization__list_controller_E"); + E055 : Boolean; pragma Import (Ada, E055, "system__file_control_block_E"); + E042 : Boolean; pragma Import (Ada, E042, "system__file_io_E"); + E006 : Boolean; pragma Import (Ada, E006, "ada__text_io_E"); + + -- Set_Globals is a library routine that stores away the + -- value of the indicated set of global values in global + -- variables within the library. + + procedure Set_Globals + (Main_Priority : Integer; + Time_Slice_Value : Integer; + WC_Encoding : Character; + Locking_Policy : Character; + Queuing_Policy : Character; + Task_Dispatching_Policy : Character; + Adafinal : System.Address; + Unreserve_All_Interrupts : Integer; + Exception_Tracebacks : Integer); + pragma Import (C, Set_Globals, "__gnat_set_globals"); + + -- SDP_Table_Build is a library routine used to build the + -- exception tables. See unit Ada.Exceptions in files + -- a-except.ads/adb for full details of how zero cost + -- exception handling works. This procedure, the call to + -- it, and the two following tables are all omitted if the + -- build is in longjmp/setjump exception mode. + + procedure SDP_Table_Build + (SDP_Addresses : System.Address; + SDP_Count : Natural; + Elab_Addresses : System.Address; + Elab_Addr_Count : Natural); + pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build"); + + -- Table of Unit_Exception_Table addresses. Used for zero + -- cost exception handling to build the top level table. + + ST : aliased constant array (1 .. 23) of System.Address := ( + Hello'UET_Address, + Ada.Text_Io'UET_Address, + Ada.Exceptions'UET_Address, + Gnat.Heap_Sort_A'UET_Address, + System.Exception_Table'UET_Address, + System.Machine_State_Operations'UET_Address, + System.Secondary_Stack'UET_Address, + System.Parameters'UET_Address, + System.Soft_Links'UET_Address, + System.Stack_Checking'UET_Address, + System.Traceback'UET_Address, + Ada.Streams'UET_Address, + Ada.Tags'UET_Address, + System.String_Ops'UET_Address, + Interfaces.C_Streams'UET_Address, + System.File_Io'UET_Address, + Ada.Finalization'UET_Address, + System.Finalization_Root'UET_Address, + System.Finalization_Implementation'UET_Address, + System.String_Ops_Concat_3'UET_Address, + System.Stream_Attributes'UET_Address, + System.File_Control_Block'UET_Address, + Ada.Finalization.List_Controller'UET_Address); + + -- Table of addresses of elaboration routines. Used for + -- zero cost exception handling to make sure these + -- addresses are included in the top level procedure + -- address table. + + EA : aliased constant array (1 .. 23) of System.Address := ( + adainit'Code_Address, + Do_Finalize'Code_Address, + Ada.Exceptions'Elab_Spec'Address, + System.Exceptions'Elab_Spec'Address, + Interfaces.C_Streams'Elab_Spec'Address, + System.Exception_Table'Elab_Body'Address, + Ada.Io_Exceptions'Elab_Spec'Address, + System.Stack_Checking'Elab_Spec'Address, + System.Soft_Links'Elab_Body'Address, + System.Secondary_Stack'Elab_Body'Address, + Ada.Tags'Elab_Spec'Address, + Ada.Tags'Elab_Body'Address, + Ada.Streams'Elab_Spec'Address, + System.Finalization_Root'Elab_Spec'Address, + Ada.Exceptions'Elab_Body'Address, + System.Finalization_Implementation'Elab_Spec'Address, + System.Finalization_Implementation'Elab_Body'Address, + Ada.Finalization'Elab_Spec'Address, + Ada.Finalization.List_Controller'Elab_Spec'Address, + System.File_Control_Block'Elab_Spec'Address, + System.File_Io'Elab_Body'Address, + Ada.Text_Io'Elab_Spec'Address, + Ada.Text_Io'Elab_Body'Address); + + -- Start of processing for adainit + + begin + + -- Call SDP_Table_Build to build the top level procedure + -- table for zero cost exception handling (omitted in + -- longjmp/setjump mode). + + SDP_Table_Build (ST'Address, 23, EA'Address, 23); + + -- Call Set_Globals to record various information for + -- this partition. The values are derived by the binder + -- from information stored in the ali files by the compiler. + + Set_Globals + (Main_Priority => -1, + -- Priority of main program, -1 if no pragma Priority used + + Time_Slice_Value => -1, + -- Time slice from Time_Slice pragma, -1 if none used + + WC_Encoding => 'b', + -- Wide_Character encoding used, default is brackets + + Locking_Policy => ' ', + -- Locking_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Queuing_Policy => ' ', + -- Queuing_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Task_Dispatching_Policy => ' ', + -- Task_Dispatching_Policy used, default of space means + -- not specified, otherwise first character of the + -- policy name. + + Adafinal => System.Null_Address, + -- Address of Adafinal routine, not used anymore + + Unreserve_All_Interrupts => 0, + -- Set true if pragma Unreserve_All_Interrupts was used + + Exception_Tracebacks => 0); + -- Indicates if exception tracebacks are enabled + + Elab_Final_Code := 1; + + -- Now we have the elaboration calls for all units in the partition. + -- The Elab_Spec and Elab_Body attributes generate references to the + -- implicit elaboration procedures generated by the compiler for + -- each unit that requires elaboration. + + if not E040 then + Interfaces.C_Streams'Elab_Spec; + end if; + E040 := True; + if not E008 then + Ada.Exceptions'Elab_Spec; + end if; + if not E014 then + System.Exception_Table'Elab_Body; + E014 := True; + end if; + if not E053 then + Ada.Io_Exceptions'Elab_Spec; + E053 := True; + end if; + if not E017 then + System.Exceptions'Elab_Spec; + E017 := True; + end if; + if not E030 then + System.Stack_Checking'Elab_Spec; + end if; + if not E028 then + System.Soft_Links'Elab_Body; + E028 := True; + end if; + E030 := True; + if not E024 then + System.Secondary_Stack'Elab_Body; + E024 := True; + end if; + if not E035 then + Ada.Tags'Elab_Spec; + end if; + if not E035 then + Ada.Tags'Elab_Body; + E035 := True; + end if; + if not E033 then + Ada.Streams'Elab_Spec; + E033 := True; + end if; + if not E046 then + System.Finalization_Root'Elab_Spec; + end if; + E046 := True; + if not E008 then + Ada.Exceptions'Elab_Body; + E008 := True; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Spec; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Body; + E048 := True; + end if; + if not E044 then + Ada.Finalization'Elab_Spec; + end if; + E044 := True; + if not E057 then + Ada.Finalization.List_Controller'Elab_Spec; + end if; + E057 := True; + if not E055 then + System.File_Control_Block'Elab_Spec; + E055 := True; + end if; + if not E042 then + System.File_Io'Elab_Body; + E042 := True; + end if; + if not E006 then + Ada.Text_Io'Elab_Spec; + end if; + if not E006 then + Ada.Text_Io'Elab_Body; + E006 := True; + end if; + + Elab_Final_Code := 0; + end adainit; + + -------------- + -- adafinal -- + -------------- + + procedure adafinal is + begin + Do_Finalize; + end adafinal; + + ---------- + -- main -- + ---------- + + -- main is actually a function, as in the ANSI C standard, + -- defined to return the exit status. The three parameters + -- are the argument count, argument values and environment + -- pointer. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer + is + -- The initialize routine performs low level system + -- initialization using a standard library routine which + -- sets up signal handling and performs any other + -- required setup. The routine can be found in file + -- a-init.c. + + procedure initialize; + pragma Import (C, initialize, "__gnat_initialize"); + + -- The finalize routine performs low level system + -- finalization using a standard library routine. The + -- routine is found in file a-final.c and in the standard + -- distribution is a dummy routine that does nothing, so + -- really this is a hook for special user finalization. + + procedure finalize; + pragma Import (C, finalize, "__gnat_finalize"); + + -- We get to the main program of the partition by using + -- pragma Import because if we try to with the unit and + -- call it Ada style, then not only do we waste time + -- recompiling it, but also, we don't really know the right + -- switches (e.g. identifier character set) to be used + -- to compile it. + + procedure Ada_Main_Program; + pragma Import (Ada, Ada_Main_Program, "_ada_hello"); + + -- Start of processing for main + + begin + -- Save global variables + + gnat_argc := argc; + gnat_argv := argv; + gnat_envp := envp; + + -- Call low level system initialization + + Initialize; + + -- Call our generated Ada initialization routine + + adainit; + + -- This is the point at which we want the debugger to get + -- control + + Break_Start; + + -- Now we call the main program of the partition + + Ada_Main_Program; + + -- Perform Ada finalization + + adafinal; + + -- Perform low level system finalization + + Finalize; + + -- Return the proper exit status + return (gnat_exit_status); + end; + + -- This section is entirely comments, so it has no effect on the + -- compilation of the Ada_Main package. It provides the list of + -- object files and linker options, as well as some standard + -- libraries needed for the link. The gnatlink utility parses + -- this b~hello.adb file to read these comment lines to generate + -- the appropriate command line arguments for the call to the + -- system linker. The BEGIN/END lines are used for sentinels for + -- this parsing operation. + + -- The exact file names will of course depend on the environment, + -- host/target and location of files on the host system. + + -- BEGIN Object file/option list + -- ./hello.o + -- -L./ + -- -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/ + -- /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a + -- END Object file/option list + + end ada_main; + + The Ada code in the above example is exactly what is generated by the + binder. We have added comments to more clearly indicate the function of + each part of the generated `Ada_Main' package. + + The code is standard Ada in all respects, and can be processed by any + tools that handle Ada. In particular, it is possible to use the debugger + in Ada mode to debug the generated Ada_Main package. For example, + suppose that for reasons that you do not understand, your program is + blowing up during elaboration of the body of `Ada.Text_IO'. To chase + this bug down, you can place a breakpoint on the call: + + Ada.Text_Io'Elab_Body; + + and trace the elaboration routine for this package to find out where + the problem might be (more usually of course you would be debugging + elaboration code in your own application). + +  + File: gnat_ug_vxw.info, Node: Generating the Binder Program in C, Next: Consistency-Checking Modes, Prev: Running gnatbind, Up: Binding Using gnatbind + + Generating the Binder Program in C + ================================== + + In most normal usage, the default mode of `gnatbind' which is to + generate the main package in Ada, as described in the previous section. + In particular, this means that any Ada programmer can read and + understand the generated main program. It can also be debugged just + like any other Ada code provided the `-g' switch is used for `gnatbind' + and `gnatlink'. + + However for some purposes it may be convenient to generate the main + program in C rather than Ada. This may for example be helpful when you + are generating a mixed language program with the main program in C. The + GNAT compiler itself is an example. The use of the `-C' switch for both + `gnatbind' and `gnatlink' will cause the program to be generated in C + (and compiled using the gnu C compiler). The following shows the C code + generated for the same "Hello World" program: + + + #ifdef __STDC__ + #define PARAMS(paramlist) paramlist + #else + #define PARAMS(paramlist) () + #endif + + extern void __gnat_set_globals + PARAMS ((int, int, int, int, int, int, + void (*) PARAMS ((void)), int, int)); + extern void adafinal PARAMS ((void)); + extern void adainit PARAMS ((void)); + extern void system__standard_library__adafinal PARAMS ((void)); + extern int main PARAMS ((int, char **, char **)); + extern void exit PARAMS ((int)); + extern void __gnat_break_start PARAMS ((void)); + extern void _ada_hello PARAMS ((void)); + extern void __gnat_initialize PARAMS ((void)); + extern void __gnat_finalize PARAMS ((void)); + + extern void ada__exceptions___elabs PARAMS ((void)); + extern void system__exceptions___elabs PARAMS ((void)); + extern void interfaces__c_streams___elabs PARAMS ((void)); + extern void system__exception_table___elabb PARAMS ((void)); + extern void ada__io_exceptions___elabs PARAMS ((void)); + extern void system__stack_checking___elabs PARAMS ((void)); + extern void system__soft_links___elabb PARAMS ((void)); + extern void system__secondary_stack___elabb PARAMS ((void)); + extern void ada__tags___elabs PARAMS ((void)); + extern void ada__tags___elabb PARAMS ((void)); + extern void ada__streams___elabs PARAMS ((void)); + extern void system__finalization_root___elabs PARAMS ((void)); + extern void ada__exceptions___elabb PARAMS ((void)); + extern void system__finalization_implementation___elabs PARAMS ((void)); + extern void system__finalization_implementation___elabb PARAMS ((void)); + extern void ada__finalization___elabs PARAMS ((void)); + extern void ada__finalization__list_controller___elabs PARAMS ((void)); + extern void system__file_control_block___elabs PARAMS ((void)); + extern void system__file_io___elabb PARAMS ((void)); + extern void ada__text_io___elabs PARAMS ((void)); + extern void ada__text_io___elabb PARAMS ((void)); + + extern int __gnat_inside_elab_final_code; + + extern int gnat_argc; + extern char **gnat_argv; + extern char **gnat_envp; + extern int gnat_exit_status; + + char __gnat_version[] = "GNAT Version: 3.15w (20010315)"; + void adafinal () { + system__standard_library__adafinal (); + } + + void adainit () + { + extern char ada__exceptions_E; + extern char system__exceptions_E; + extern char interfaces__c_streams_E; + extern char system__exception_table_E; + extern char ada__io_exceptions_E; + extern char system__secondary_stack_E; + extern char system__stack_checking_E; + extern char system__soft_links_E; + extern char ada__tags_E; + extern char ada__streams_E; + extern char system__finalization_root_E; + extern char system__finalization_implementation_E; + extern char ada__finalization_E; + extern char ada__finalization__list_controller_E; + extern char system__file_control_block_E; + extern char system__file_io_E; + extern char ada__text_io_E; + + extern void *__gnat_hello__SDP; + extern void *__gnat_ada__text_io__SDP; + extern void *__gnat_ada__exceptions__SDP; + extern void *__gnat_gnat__heap_sort_a__SDP; + extern void *__gnat_system__exception_table__SDP; + extern void *__gnat_system__machine_state_operations__SDP; + extern void *__gnat_system__secondary_stack__SDP; + extern void *__gnat_system__parameters__SDP; + extern void *__gnat_system__soft_links__SDP; + extern void *__gnat_system__stack_checking__SDP; + extern void *__gnat_system__traceback__SDP; + extern void *__gnat_ada__streams__SDP; + extern void *__gnat_ada__tags__SDP; + extern void *__gnat_system__string_ops__SDP; + extern void *__gnat_interfaces__c_streams__SDP; + extern void *__gnat_system__file_io__SDP; + extern void *__gnat_ada__finalization__SDP; + extern void *__gnat_system__finalization_root__SDP; + extern void *__gnat_system__finalization_implementation__SDP; + extern void *__gnat_system__string_ops_concat_3__SDP; + extern void *__gnat_system__stream_attributes__SDP; + extern void *__gnat_system__file_control_block__SDP; + extern void *__gnat_ada__finalization__list_controller__SDP; + + void **st[23] = { + &__gnat_hello__SDP, + &__gnat_ada__text_io__SDP, + &__gnat_ada__exceptions__SDP, + &__gnat_gnat__heap_sort_a__SDP, + &__gnat_system__exception_table__SDP, + &__gnat_system__machine_state_operations__SDP, + &__gnat_system__secondary_stack__SDP, + &__gnat_system__parameters__SDP, + &__gnat_system__soft_links__SDP, + &__gnat_system__stack_checking__SDP, + &__gnat_system__traceback__SDP, + &__gnat_ada__streams__SDP, + &__gnat_ada__tags__SDP, + &__gnat_system__string_ops__SDP, + &__gnat_interfaces__c_streams__SDP, + &__gnat_system__file_io__SDP, + &__gnat_ada__finalization__SDP, + &__gnat_system__finalization_root__SDP, + &__gnat_system__finalization_implementation__SDP, + &__gnat_system__string_ops_concat_3__SDP, + &__gnat_system__stream_attributes__SDP, + &__gnat_system__file_control_block__SDP, + &__gnat_ada__finalization__list_controller__SDP}; + + extern void ada__exceptions___elabs (); + extern void system__exceptions___elabs (); + extern void interfaces__c_streams___elabs (); + extern void system__exception_table___elabb (); + extern void ada__io_exceptions___elabs (); + extern void system__stack_checking___elabs (); + extern void system__soft_links___elabb (); + extern void system__secondary_stack___elabb (); + extern void ada__tags___elabs (); + extern void ada__tags___elabb (); + extern void ada__streams___elabs (); + extern void system__finalization_root___elabs (); + extern void ada__exceptions___elabb (); + extern void system__finalization_implementation___elabs (); + extern void system__finalization_implementation___elabb (); + extern void ada__finalization___elabs (); + extern void ada__finalization__list_controller___elabs (); + extern void system__file_control_block___elabs (); + extern void system__file_io___elabb (); + extern void ada__text_io___elabs (); + extern void ada__text_io___elabb (); + + void (*ea[23]) () = { + adainit, + system__standard_library__adafinal, + ada__exceptions___elabs, + system__exceptions___elabs, + interfaces__c_streams___elabs, + system__exception_table___elabb, + ada__io_exceptions___elabs, + system__stack_checking___elabs, + system__soft_links___elabb, + system__secondary_stack___elabb, + ada__tags___elabs, + ada__tags___elabb, + ada__streams___elabs, + system__finalization_root___elabs, + ada__exceptions___elabb, + system__finalization_implementation___elabs, + system__finalization_implementation___elabb, + ada__finalization___elabs, + ada__finalization__list_controller___elabs, + system__file_control_block___elabs, + system__file_io___elabb, + ada__text_io___elabs, + ada__text_io___elabb}; + + __gnat_SDP_Table_Build (&st, 23, ea, 23); + __gnat_set_globals ( + -1, /* Main_Priority */ + -1, /* Time_Slice_Value */ + 'b', /* WC_Encoding */ + ' ', /* Locking_Policy */ + ' ', /* Queuing_Policy */ + ' ', /* Tasking_Dispatching_Policy */ + 0, /* Finalization routine address, not used anymore */ + 0, /* Unreserve_All_Interrupts */ + 0); /* Exception_Tracebacks */ + + __gnat_inside_elab_final_code = 1; + + if (ada__exceptions_E == 0) { + ada__exceptions___elabs (); + } + if (system__exceptions_E == 0) { + system__exceptions___elabs (); + system__exceptions_E++; + } + if (interfaces__c_streams_E == 0) { + interfaces__c_streams___elabs (); + } + interfaces__c_streams_E = 1; + if (system__exception_table_E == 0) { + system__exception_table___elabb (); + system__exception_table_E++; + } + if (ada__io_exceptions_E == 0) { + ada__io_exceptions___elabs (); + ada__io_exceptions_E++; + } + if (system__stack_checking_E == 0) { + system__stack_checking___elabs (); + } + if (system__soft_links_E == 0) { + system__soft_links___elabb (); + system__soft_links_E++; + } + system__stack_checking_E = 1; + if (system__secondary_stack_E == 0) { + system__secondary_stack___elabb (); + system__secondary_stack_E++; + } + if (ada__tags_E == 0) { + ada__tags___elabs (); + } + if (ada__tags_E == 0) { + ada__tags___elabb (); + ada__tags_E++; + } + if (ada__streams_E == 0) { + ada__streams___elabs (); + ada__streams_E++; + } + if (system__finalization_root_E == 0) { + system__finalization_root___elabs (); + } + system__finalization_root_E = 1; + if (ada__exceptions_E == 0) { + ada__exceptions___elabb (); + ada__exceptions_E++; + } + if (system__finalization_implementation_E == 0) { + system__finalization_implementation___elabs (); + } + if (system__finalization_implementation_E == 0) { + system__finalization_implementation___elabb (); + system__finalization_implementation_E++; + } + if (ada__finalization_E == 0) { + ada__finalization___elabs (); + } + ada__finalization_E = 1; + if (ada__finalization__list_controller_E == 0) { + ada__finalization__list_controller___elabs (); + } + ada__finalization__list_controller_E = 1; + if (system__file_control_block_E == 0) { + system__file_control_block___elabs (); + system__file_control_block_E++; + } + if (system__file_io_E == 0) { + system__file_io___elabb (); + system__file_io_E++; + } + if (ada__text_io_E == 0) { + ada__text_io___elabs (); + } + if (ada__text_io_E == 0) { + ada__text_io___elabb (); + ada__text_io_E++; + } + + __gnat_inside_elab_final_code = 0; + } + int main (argc, argv, envp) + int argc; + char **argv; + char **envp; + { + gnat_argc = argc; + gnat_argv = argv; + gnat_envp = envp; + + __gnat_initialize (); + adainit (); + __gnat_break_start (); + + _ada_hello (); + + system__standard_library__adafinal (); + __gnat_finalize (); + exit (gnat_exit_status); + } + unsigned helloB = 0x7880BEB3; + unsigned system__standard_libraryB = 0x0D24CBD0; + unsigned system__standard_libraryS = 0x3283DBEB; + unsigned adaS = 0x2359F9ED; + unsigned ada__text_ioB = 0x47C85FC4; + unsigned ada__text_ioS = 0x496FE45C; + unsigned ada__exceptionsB = 0x74F50187; + unsigned ada__exceptionsS = 0x6736945B; + unsigned gnatS = 0x156A40CF; + unsigned gnat__heap_sort_aB = 0x033DABE0; + unsigned gnat__heap_sort_aS = 0x6AB38FEA; + unsigned systemS = 0x0331C6FE; + unsigned system__exceptionsS = 0x20C9ECA4; + unsigned system__exception_tableB = 0x68A22947; + unsigned system__exception_tableS = 0x394BADD5; + unsigned gnat__htableB = 0x08258E1B; + unsigned gnat__htableS = 0x367D5222; + unsigned system__machine_state_operationsB = 0x4F3B7492; + unsigned system__machine_state_operationsS = 0x182F5CF4; + unsigned system__storage_elementsB = 0x2F1EB794; + unsigned system__storage_elementsS = 0x102C83C7; + unsigned system__secondary_stackB = 0x1574B6E9; + unsigned system__secondary_stackS = 0x708E260A; + unsigned system__parametersB = 0x56D770CD; + unsigned system__parametersS = 0x237E39BE; + unsigned system__soft_linksB = 0x08AB6B2C; + unsigned system__soft_linksS = 0x1E2491F3; + unsigned system__stack_checkingB = 0x476457A0; + unsigned system__stack_checkingS = 0x5299FCED; + unsigned system__tracebackB = 0x2971EBDE; + unsigned system__tracebackS = 0x2E9C3122; + unsigned ada__streamsS = 0x7C25DE96; + unsigned ada__tagsB = 0x39ADFFA2; + unsigned ada__tagsS = 0x769A0464; + unsigned system__string_opsB = 0x5EB646AB; + unsigned system__string_opsS = 0x63CED018; + unsigned interfacesS = 0x0357E00A; + unsigned interfaces__c_streamsB = 0x3784FB72; + unsigned interfaces__c_streamsS = 0x2E723019; + unsigned system__file_ioB = 0x623358EA; + unsigned system__file_ioS = 0x31F873E6; + unsigned ada__finalizationB = 0x6843F68A; + unsigned ada__finalizationS = 0x63305874; + unsigned system__finalization_rootB = 0x31E56CE1; + unsigned system__finalization_rootS = 0x23169EF3; + unsigned system__finalization_implementationB = 0x6CCBA70E; + unsigned system__finalization_implementationS = 0x604AA587; + unsigned system__string_ops_concat_3B = 0x572E3F58; + unsigned system__string_ops_concat_3S = 0x01F57876; + unsigned system__stream_attributesB = 0x1D4F93E8; + unsigned system__stream_attributesS = 0x30B2EC3D; + unsigned ada__io_exceptionsS = 0x34054F96; + unsigned system__unsigned_typesS = 0x7B9E7FE3; + unsigned system__file_control_blockS = 0x2FF876A8; + unsigned ada__finalization__list_controllerB = 0x5760634A; + unsigned ada__finalization__list_controllerS = 0x5D851835; + + /* BEGIN ELABORATION ORDER + ada (spec) + gnat (spec) + gnat.heap_sort_a (spec) + gnat.htable (spec) + gnat.htable (body) + interfaces (spec) + system (spec) + system.parameters (spec) + system.standard_library (spec) + ada.exceptions (spec) + system.exceptions (spec) + system.parameters (body) + gnat.heap_sort_a (body) + interfaces.c_streams (spec) + interfaces.c_streams (body) + system.exception_table (spec) + system.exception_table (body) + ada.io_exceptions (spec) + system.storage_elements (spec) + system.storage_elements (body) + system.machine_state_operations (spec) + system.machine_state_operations (body) + system.secondary_stack (spec) + system.stack_checking (spec) + system.soft_links (spec) + system.soft_links (body) + system.stack_checking (body) + system.secondary_stack (body) + system.standard_library (body) + system.string_ops (spec) + system.string_ops (body) + ada.tags (spec) + ada.tags (body) + ada.streams (spec) + system.finalization_root (spec) + system.finalization_root (body) + system.string_ops_concat_3 (spec) + system.string_ops_concat_3 (body) + system.traceback (spec) + system.traceback (body) + ada.exceptions (body) + system.unsigned_types (spec) + system.stream_attributes (spec) + system.stream_attributes (body) + system.finalization_implementation (spec) + system.finalization_implementation (body) + ada.finalization (spec) + ada.finalization (body) + ada.finalization.list_controller (spec) + ada.finalization.list_controller (body) + system.file_control_block (spec) + system.file_io (spec) + system.file_io (body) + ada.text_io (spec) + ada.text_io (body) + hello (body) + END ELABORATION ORDER */ + + /* BEGIN Object file/option list + ./hello.o + -L./ + -L/usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/ + /usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/libgnat.a + -lexc + END Object file/option list */ + + Here again, the C code is exactly what is generated by the binder. The + functions of the various parts of this code correspond in an obvious + manner with the commented Ada code shown in the example in the previous + section. + +  + File: gnat_ug_vxw.info, Node: Consistency-Checking Modes, Next: Binder Error Message Control, Prev: Generating the Binder Program in C, Up: Binding Using gnatbind + + Consistency-Checking Modes + ========================== + + As described in the previous section, by default `gnatbind' checks that + object files are consistent with one another and are consistent with + any source files it can locate. The following switches control binder + access to sources. + + `-s' + Require source files to be present. In this mode, the binder must + be able to locate all source files that are referenced, in order + to check their consistency. In normal mode, if a source file + cannot be located it is simply ignored. If you specify this + switch, a missing source file is an error. + + `-x' + Exclude source files. In this mode, the binder only checks that ALI + files are consistent with one another. Source files are not + accessed. The binder runs faster in this mode, and there is still + a guarantee that the resulting program is self-consistent. If a + source file has been edited since it was last compiled, and you + specify this switch, the binder will not detect that the object + file is out of date with respect to the source file. Note that + this is the mode that is automatically used by `gnatmake' because + in this case the checking against sources has already been + performed by `gnatmake' in the course of compilation (i.e. before + binding). + +  + File: gnat_ug_vxw.info, Node: Binder Error Message Control, Next: Elaboration Control, Prev: Consistency-Checking Modes, Up: Binding Using gnatbind + + Binder Error Message Control + ============================ + + The following switches provide control over the generation of error + messages from the binder: + + `-v' + Verbose mode. In the normal mode, brief error messages are + generated to `stderr'. If this switch is present, a header is + written to `stdout' and any error messages are directed to + `stdout'. All that is written to `stderr' is a brief summary + message. + + `-b' + Generate brief error messages to `stderr' even if verbose mode is + specified. This is relevant only when used with the `-v' switch. + + `-mN' + Limits the number of error messages to N, a decimal integer in the + range 1-999. The binder terminates immediately if this limit is + reached. + + `-MXXX' + Renames the generated main program from `main' to `xxx'. This is + useful in the case of some cross-building environments, where the + actual main program is separate from the one generated by + `gnatbind'. + + `-ws' + Suppress all warning messages. + + `-we' + Treat any warning messages as fatal errors. + + `-t' + The binder performs a number of consistency checks including: + + * Check that time stamps of a given source unit are consistent + + * Check that checksums of a given source unit are consistent + + * Check that consistent versions of `GNAT' were used for + compilation + + * Check consistency of configuration pragmas as required + + Normally failure of such checks, in accordance with the consistency + requirements of the Ada Reference Manual, causes error messages to + be generated which abort the binder and prevent the output of a + binder file and subsequent link to obtain an executable. + + The `-t' switch converts these error messages into warnings, so + that binding and linking can continue to completion even in the + presence of such errors. The result may be a failed link (due to + missing symbols), or a non-functional executable which has + undefined semantics. _This means that `-t' should be used only in + unusual situations, with extreme care._ + +  + File: gnat_ug_vxw.info, Node: Elaboration Control, Next: Output Control, Prev: Binder Error Message Control, Up: Binding Using gnatbind + + Elaboration Control + =================== + + The following switches provide additional control over the elaboration + order. For full details see *Note Elaboration Order Handling in GNAT::. + + `-p' + Normally the binder attempts to choose an elaboration order that is + likely to minimize the likelihood of an elaboration order error + resulting in raising a `Program_Error' exception. This switch + reverses the action of the binder, and requests that it + deliberately choose an order that is likely to maximize the + likelihood of an elaboration error. This is useful in ensuring + portability and avoiding dependence on accidental fortuitous + elaboration ordering. + + Normally it only makes sense to use the `-p' switch if dynamic + elaboration checking is used (`-gnatE' switch used for + compilation). This is because in the default static elaboration + mode, all necessary `Elaborate_All' pragmas are implicitly + inserted. These implicit pragmas are still respected by the binder + in `-p' mode, so a safe elaboration order is assured. + +  + File: gnat_ug_vxw.info, Node: Output Control, Next: Binding with Non-Ada Main Programs, Prev: Elaboration Control, Up: Binding Using gnatbind + + Output Control + ============== + + The following switches allow additional control over the output + generated by the binder. + + `-A' + Generate binder program in Ada (default). The binder program is + named `b~MAINPROG.adb' by default. This can be changed with `-o' + `gnatbind' option. + + `-c' + Check only. Do not generate the binder output file. In this mode + the binder performs all error checks but does not generate an + output file. + + `-C' + Generate binder program in C. The binder program is named + `b_MAINPROG.c'. This can be changed with `-o' `gnatbind' option. + + `-e' + Output complete list of elaboration-order dependencies, showing the + reason for each dependency. This output can be rather extensive + but may be useful in diagnosing problems with elaboration order. + The output is written to `stdout'. + + `-h' + Output usage information. The output is written to `stdout'. + + `-K' + Output linker options to `stdout'. Includes library search paths, + contents of pragmas Ident and Linker_Options, and libraries added + by `gnatbind'. + + `-l' + Output chosen elaboration order. The output is written to `stdout'. + + `-O' + Output full names of all the object files that must be linked to + provide the Ada component of the program. The output is written to + `stdout'. This list includes the files explicitly supplied and + referenced by the user as well as implicitly referenced run-time + unit files. The latter are omitted if the corresponding units + reside in shared libraries. The directory names for the run-time + units depend on the system configuration. + + `-o FILE' + Set name of output file to FILE instead of the normal + `b~MAINPROG.adb' default. Note that FILE denote the Ada binder + generated body filename. In C mode you would normally give FILE an + extension of `.c' because it will be a C source program. Note + that if this option is used, then linking must be done manually. + It is not possible to use gnatlink in this case, since it cannot + locate the binder file. + + `-r' + Generate list of `pragma Rerstrictions' that could be applied to + the current unit. This is useful for code audit purposes, and also + may be used to improve code generation in some cases. + +  + File: gnat_ug_vxw.info, Node: Binding with Non-Ada Main Programs, Next: Binding Programs with No Main Subprogram, Prev: Output Control, Up: Binding Using gnatbind + + Binding with Non-Ada Main Programs + ================================== + + In our description so far we have assumed that the main program is in + Ada, and that the task of the binder is to generate a corresponding + function `main' that invokes this Ada main program. GNAT also supports + the building of executable programs where the main program is not in + Ada, but some of the called routines are written in Ada and compiled + using GNAT (*note Mixed Language Programming::). The following switch + is used in this situation: + + `-n' + No main program. The main program is not in Ada. + + In this case, most of the functions of the binder are still required, + but instead of generating a main program, the binder generates a file + containing the following callable routines: + + `adainit' + You must call this routine to initialize the Ada part of the + program by calling the necessary elaboration routines. A call to + `adainit' is required before the first call to an Ada subprogram. + + Note that it is assumed that the basic execution environment must + be setup to be appropriate for Ada execution at the point where + the first Ada subprogram is called. In particular, if the Ada code + will do any floating-point operations, then the FPU must be setup + in an appropriate manner. For the case of the x86, for example, + full precision mode is required. The procedure + GNAT.Float_Control.Reset may be used to ensure that the FPU is in + the right state. + + `adafinal' + You must call this routine to perform any library-level + finalization required by the Ada subprograms. A call to `adafinal' + is required after the last call to an Ada subprogram, and before + the program terminates. + + If the `-n' switch is given, more than one ALI file may appear on the + command line for `gnatbind'. The normal "closure" calculation is + performed for each of the specified units. Calculating the closure + means finding out the set of units involved by tracing `with' + references. The reason it is necessary to be able to specify more than + one ALI file is that a given program may invoke two or more quite + separate groups of Ada units. + + The binder takes the name of its output file from the last specified + ALI file, unless overridden by the use of the `-o file'. The output is + an Ada unit in source form that can be compiled with GNAT unless the -C + switch is used in which case the output is a C source file, which must + be compiled using the C compiler. This compilation occurs + automatically as part of the `gnatlink' processing. + + Currently the GNAT run time requires a FPU using 80 bits mode + precision. Under targets where this is not the default it is required to + call GNAT.Float_Control.Reset before using floating point numbers (this + include float computation, float input and output) in the Ada code. A + side effect is that this could be the wrong mode for the foreign code + where floating point computation could be broken after this call. + +  + File: gnat_ug_vxw.info, Node: Binding Programs with No Main Subprogram, Next: Summary of Binder Switches, Prev: Binding with Non-Ada Main Programs, Up: Binding Using gnatbind + + Binding Programs with No Main Subprogram + ======================================== + + It is possible to have an Ada program which does not have a main + subprogram. This program will call the elaboration routines of all the + packages, then the finalization routines. + + The following switch is used to bind programs organized in this + manner: + + `-z' + Normally the binder checks that the unit name given on the command + line corresponds to a suitable main subprogram. When this switch + is used, a list of ALI files can be given, and the execution of + the program consists of elaboration of these units in an + appropriate order. + +  + File: gnat_ug_vxw.info, Node: Summary of Binder Switches, Next: Command-Line Access, Prev: Binding Programs with No Main Subprogram, Up: Binding Using gnatbind + + Summary of Binder Switches + ========================== + + The following are the switches available with `gnatbind': + + `-aO' + Specify directory to be searched for ALI files. + + `-aI' + Specify directory to be searched for source file. + + `-A' + Generate binder program in Ada (default) + + `-b' + Generate brief messages to `stderr' even if verbose mode set. + + `-c' + Check only, no generation of binder output file. + + `-C' + Generate binder program in C + + `-e' + Output complete list of elaboration-order dependencies. + + `-E' + Store tracebacks in exception occurrences when the target supports + it. This is the default with the zero cost exception mechanism. + This option is currently supported on the following targets: all + x86 ports, Solaris, Windows, HP-UX, AIX, PowerPC VxWorks and Alpha + VxWorks. See also the packages `GNAT.Traceback' and + `GNAT.Traceback.Symbolic' for more information. Note that on x86 + ports, you must not use `-fomit-frame-pointer' `gcc' option. + + `-h' + Output usage (help) information + + `-I' + Specify directory to be searched for source and ALI files. + + `-I-' + Do not look for sources in the current directory where `gnatbind' + was invoked, and do not look for ALI files in the directory + containing the ALI file named in the `gnatbind' command line. + + `-l' + Output chosen elaboration order. + + `-Lxxx' + Binds the units for library building. In this case the adainit and + adafinal procedures (See *note Binding with Non-Ada Main + Programs::) are renamed to xxxinit and xxxfinal. Implies -n. See + *note GNAT and Libraries:: for more details. + + `-Mxyz' + Rename generated main program from main to xyz + + `-mN' + Limit number of detected errors to N (1-999). + + `-n' + No main program. + + `-nostdinc' + Do not look for sources in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-o FILE' + Name the output file FILE (default is `b~XXX.adb'). Note that if + this option is used, then linking must be done manually, gnatlink + cannot be used. + + `-O' + Output object list. + + `-p' + Pessimistic (worst-case) elaboration order + + `-s' + Require all source files to be present. + + `-static' + Link against a static GNAT run time. + + `-shared' + Link against a shared GNAT run time when available. + + `-t' + Tolerate time stamp and other consistency errors + + `-TN' + Set the time slice value to n microseconds. A value of zero means + no time slicing and also indicates to the tasking run time to + match as close as possible to the annex D requirements of the RM. + + `-v' + Verbose mode. Write error messages, header, summary output to + `stdout'. + + `-wX' + Warning mode (X=s/e for suppress/treat as error) + + `-x' + Exclude source files (check object consistency only). + + `-z' + No main subprogram. + + You may obtain this listing by running the program `gnatbind' with + no arguments. + +  + File: gnat_ug_vxw.info, Node: Command-Line Access, Next: Search Paths for gnatbind, Prev: Summary of Binder Switches, Up: Binding Using gnatbind + + Command-Line Access + =================== + + The package `Ada.Command_Line' provides access to the command-line + arguments and program name. In order for this interface to operate + correctly, the two variables + + int gnat_argc; + char **gnat_argv; + + are declared in one of the GNAT library routines. These variables must + be set from the actual `argc' and `argv' values passed to the main + program. With no `n' present, `gnatbind' generates the C main program + to automatically set these variables. If the `n' switch is used, there + is no automatic way to set these variables. If they are not set, the + procedures in `Ada.Command_Line' will not be available, and any attempt + to use them will raise `Constraint_Error'. If command line access is + required, your main program must set `gnat_argc' and `gnat_argv' from + the `argc' and `argv' values passed to it. + +  + File: gnat_ug_vxw.info, Node: Search Paths for gnatbind, Next: Examples of gnatbind Usage, Prev: Command-Line Access, Up: Binding Using gnatbind + + Search Paths for `gnatbind' + =========================== + + The binder takes the name of an ALI file as its argument and needs to + locate source files as well as other ALI files to verify object + consistency. + + For source files, it follows exactly the same search rules as `gcc' + (*note Search Paths and the Run-Time Library (RTL)::). For ALI files the + directories searched are: + + 1. The directory containing the ALI file named in the command line, + unless the switch `-I-' is specified. + + 2. All directories specified by `-I' switches on the `gnatbind' + command line, in the order given. + + 3. Each of the directories listed in the value of the + `ADA_OBJECTS_PATH' environment variable. Construct this value + exactly as the `PATH' environment variable: a list of directory + names separated by colons (semicolons when working with the NT + version of GNAT). + + 4. The content of the "ada_object_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as + the GNAT Run Time Library (RTL) unless the switch `-nostdlib' is + specified. *Note Installing an Ada Library:: + + In the binder the switch `-I' is used to specify both source and + library file paths. Use `-aI' instead if you want to specify source + paths only, and `-aO' if you want to specify library paths only. This + means that for the binder `-I'DIR is equivalent to `-aI'DIR `-aO'DIR. + The binder generates the bind file (a C language source file) in the + current working directory. + + The packages `Ada', `System', and `Interfaces' and their children + make up the GNAT Run-Time Library, together with the package GNAT and + its children, which contain a set of useful additional library + functions provided by GNAT. The sources for these units are needed by + the compiler and are kept together in one directory. The ALI files and + object files generated by compiling the RTL are needed by the binder + and the linker and are kept together in one directory, typically + different from the directory containing the sources. In a normal + installation, you need not specify these directory names when compiling + or binding. Either the environment variables or the built-in defaults + cause these files to be found. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + +  + File: gnat_ug_vxw.info, Node: Examples of gnatbind Usage, Prev: Search Paths for gnatbind, Up: Binding Using gnatbind + + Examples of `gnatbind' Usage + ============================ + + This section contains a number of examples of using the GNAT binding + utility `gnatbind'. + + `gnatbind hello' + The main program `Hello' (source program in `hello.adb') is bound + using the standard switch settings. The generated main program is + `b~hello.adb'. This is the normal, default use of the binder. + + `gnatbind hello -o mainprog.adb' + The main program `Hello' (source program in `hello.adb') is bound + using the standard switch settings. The generated main program is + `mainprog.adb' with the associated spec in `mainprog.ads'. Note + that you must specify the body here not the spec, in the case + where the output is in Ada. Note that if this option is used, then + linking must be done manually, since gnatlink will not be able to + find the generated file. + + `gnatbind main -C -o mainprog.c -x' + The main program `Main' (source program in `main.adb') is bound, + excluding source files from the consistency checking, generating + the file `mainprog.c'. + + `gnatbind -x main_program -C -o mainprog.c' + This command is exactly the same as the previous example. Switches + may appear anywhere in the command line, and single letter + switches may be combined into a single switch. + + `gnatbind -n math dbase -C -o ada-control.c' + The main program is in a language other than Ada, but calls to + subprograms in packages `Math' and `Dbase' appear. This call to + `gnatbind' generates the file `ada-control.c' containing the + `adainit' and `adafinal' routines to be called before and after + accessing the Ada units. + +  + File: gnat_ug_vxw.info, Node: Linking Using gnatlink, Next: The GNAT Make Program gnatmake, Prev: Binding Using gnatbind, Up: Top + + Linking Using `gnatlink' + ************************ + + This chapter discusses `gnatlink', a utility program used to link Ada + programs and build an executable file. This is a simple program that + invokes the Unix linker (via the `gcc' command) with a correct list of + object files and library references. `gnatlink' automatically + determines the list of files and references for the Ada part of a + program. It uses the binder file generated by the binder to determine + this list. + + * Menu: + + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + +  + File: gnat_ug_vxw.info, Node: Running gnatlink, Next: Switches for gnatlink, Up: Linking Using gnatlink + + Running `gnatlink' + ================== + + The form of the `gnatlink' command is + + $ gnatlink [SWITCHES] MAINPROG[.ali] [NON-ADA OBJECTS] + [LINKER OPTIONS] + + `MAINPROG.ali' references the ALI file of the main program. The `.ali' + extension of this file can be omitted. From this reference, `gnatlink' + locates the corresponding binder file `b~MAINPROG.adb' and, using the + information in this file along with the list of non-Ada objects and + linker options, constructs a Unix linker command file to create the + executable. + + The arguments following `MAINPROG.ali' are passed to the linker + uninterpreted. They typically include the names of object files for + units written in other languages than Ada and any library references + required to resolve references in any of these foreign language units, + or in `pragma Import' statements in any Ada units. + + LINKER OPTIONS is an optional list of linker specific switches. The + default linker called by gnatlink is GCC which in turn calls the + appropriate system linker usually called LD. Standard options for the + linker such as `-lmy_lib' or `-Ldir' can be added as is. For options + that are not recognized by GCC as linker options, the GCC switches + `-Xlinker' or `-Wl,' shall be used. Refer to the GCC documentation for + details. Here is an example showing how to generate a linker map + assuming that the underlying linker is GNU ld: + + $ gnatlink my_prog -Wl,-Map,MAPFILE + + Using LINKER OPTIONS it is possible to set the program stack and + heap size. See *note Setting Stack Size from gnatlink:: and *note + Setting Heap Size from gnatlink::. + + `gnatlink' determines the list of objects required by the Ada + program and prepends them to the list of objects passed to the linker. + `gnatlink' also gathers any arguments set by the use of `pragma + Linker_Options' and adds them to the list of arguments presented to the + linker. + +  + File: gnat_ug_vxw.info, Node: Switches for gnatlink, Next: Setting Stack Size from gnatlink, Prev: Running gnatlink, Up: Linking Using gnatlink + + Switches for `gnatlink' + ======================= + + The following switches are available with the `gnatlink' utility: + + `-A' + The binder has generated code in Ada. This is the default. + + `-C' + If instead of generating a file in Ada, the binder has generated + one in C, then the linker needs to know about it. Use this switch + to signal to `gnatlink' that the binder has generated C code + rather than Ada code. + + `-f' + On some targets, the command line length is limited, and `gnatlink' + will generate a separate file for the linker if the list of object + files is too long. The `-f' flag forces this file to be generated + even if the limit is not exceeded. This is useful in some cases to + deal with special situations where the command line length is + exceeded. + + `-g' + The option to include debugging information causes the Ada bind + file (in other words, `b~MAINPROG.adb') to be compiled with `-g'. + In addition, the binder does not delete the `b~MAINPROG.adb', + `b~MAINPROG.o' and `b~MAINPROG.ali' files. Without `-g', the + binder removes these files by default. The same procedure apply if + a C bind file was generated using `-C' `gnatbind' option, in this + case the filenames are `b_MAINPROG.c' and `b_MAINPROG.o'. + + `-n' + Do not compile the file generated by the binder. This may be used + when a link is rerun with different options, but there is no need + to recompile the binder file. + + `-v' + Causes additional information to be output, including a full list + of the included object files. This switch option is most useful + when you want to see what set of object files are being used in + the link step. + + `-v -v' + Very verbose mode. Requests that the compiler operate in verbose + mode when it compiles the binder file, and that the system linker + run in verbose mode. + + `-o EXEC-NAME' + EXEC-NAME specifies an alternate name for the generated executable + program. If this switch is omitted, the executable has the same + name as the main unit. For example, `gnatlink try.ali' creates an + executable called `try'. + + `-b TARGET' + Compile your program to run on TARGET, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + TARGET is not the same as your host system. + + `-BDIR' + Load compiler executables (for example, `gnat1', the Ada compiler) + from DIR instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + `gcc' manual page for further details. You would normally use the + `-b' or `-V' switch instead. + + `--GCC=COMPILER_NAME' + Program used for compiling the binder file. The default is + ``gcc''. You need to use quotes around COMPILER_NAME if + `compiler_name' contains spaces or other separator characters. As + an example `--GCC="foo -x -y"' will instruct `gnatlink' to use + `foo -x -y' as your compiler. Note that switch `-c' is always + inserted after your command name. Thus in the above example the + compiler command that will be used by `gnatlink' will be `foo -c + -x -y'. If several `--GCC=compiler_name' are used, only the last + COMPILER_NAME is taken into account. However, all the additional + switches are also taken into account. Thus, `--GCC="foo -x -y" + --GCC="bar -z -t"' is equivalent to `--GCC="bar -x -y -z -t"'. + + `--LINK=NAME' + NAME is the name of the linker to be invoked. This is especially + useful in mixed language programs since languages such as c++ + require their own linker to be used. When this switch is omitted, + the default name for the linker is (`gcc'). When this switch is + used, the specified linker is called instead of (`gcc') with + exactly the same parameters that would have been passed to (`gcc') + so if the desired linker requires different parameters it is + necessary to use a wrapper script that massages the parameters + before invoking the real linker. It may be useful to control the + exact invocation by using the verbose switch. + +  + File: gnat_ug_vxw.info, Node: Setting Stack Size from gnatlink, Next: Setting Heap Size from gnatlink, Prev: Switches for gnatlink, Up: Linking Using gnatlink + + Setting Stack Size from `gnatlink' + ================================== + + It is possible to specify the program stack size from `gnatlink'. + Assuming that the underlying linker is GNU ld there is two ways to do + so: + + * using `-Xlinker' linker option + + $ gnatlink hello -Xlinker --stack=0x10000,0x1000 + + This set the stack reserve size to 0x10000 bytes and the stack + commit size to 0x1000 bytes. + + * using `-Wl' linker option + + $ gnatlink hello -Wl,--stack=0x1000000 + + This set the stack reserve size to 0x1000000 bytes. Note that with + `-Wl' option it is not possible to set the stack commit size + because the coma is a separator for this option. + + +  + File: gnat_ug_vxw.info, Node: Setting Heap Size from gnatlink, Prev: Setting Stack Size from gnatlink, Up: Linking Using gnatlink + + Setting Heap Size from `gnatlink' + ================================= + + It is possible to specify the program heap size from `gnatlink'. + Assuming that the underlying linker is GNU ld there is two ways to do + so: + + * using `-Xlinker' linker option + + $ gnatlink hello -Xlinker --heap=0x10000,0x1000 + + This set the heap reserve size to 0x10000 bytes and the heap commit + size to 0x1000 bytes. + + * using `-Wl' linker option + + $ gnatlink hello -Wl,--heap=0x1000000 + + This set the heap reserve size to 0x1000000 bytes. Note that with + `-Wl' option it is not possible to set the heap commit size + because the coma is a separator for this option. + + +  + File: gnat_ug_vxw.info, Node: The GNAT Make Program gnatmake, Next: Renaming Files Using gnatchop, Prev: Linking Using gnatlink, Up: Top + + The GNAT Make Program `gnatmake' + ******************************** + + * Menu: + + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + + A typical development cycle when working on an Ada program consists of + the following steps: + + 1. Edit some sources to fix bugs. + + 2. Add enhancements. + + 3. Compile all sources affected. + + 4. Rebind and relink. + + 5. Test. + + The third step can be tricky, because not only do the modified files + have to be compiled, but any files depending on these files must also be + recompiled. The dependency rules in Ada can be quite complex, especially + in the presence of overloading, `use' clauses, generics and inlined + subprograms. + + `gnatmake' automatically takes care of the third and fourth steps of + this process. It determines which sources need to be compiled, compiles + them, and binds and links the resulting object files. + + Unlike some other Ada make programs, the dependencies are always + accurately recomputed from the new sources. The source based approach of + the GNAT compilation model makes this possible. This means that if + changes to the source program cause corresponding changes in + dependencies, they will always be tracked exactly correctly by + `gnatmake'. + +  + File: gnat_ug_vxw.info, Node: Running gnatmake, Next: Switches for gnatmake, Up: The GNAT Make Program gnatmake + + Running `gnatmake' + ================== + + The usual form of the `gnatmake' command is + + $ gnatmake [SWITCHES] FILE_NAME [FILE_NAMES] [MODE_SWITCHES] + + The only required argument is one FILE_NAME, which specifies a + compilation unit that is a main program. Several FILE_NAMES can be + specified: this will result in several executables being built. If + `switches' are present, they can be placed before the first FILE_NAME, + between FILE_NAMES or after the last FILE_NAME. If MODE_SWITCHES are + present, they must always be placed after the last FILE_NAME and all + `switches'. + + If you are using standard file extensions (.adb and .ads), then the + extension may be omitted from the FILE_NAME arguments. However, if you + are using non-standard extensions, then it is required that the + extension be given. A relative or absolute directory path can be + specified in a FILE_NAME, in which case, the input source file will be + searched for in the specified directory only. Otherwise, the input + source file will first be searched in the directory where `gnatmake' + was invoked and if it is not found, it will be search on the source + path of the compiler as described in *Note Search Paths and the + Run-Time Library (RTL)::. + + When several FILE_NAMES are specified, if an executable needs to be + rebuilt and relinked, all subsequent executables will be rebuilt and + relinked, even if this would not be absolutely necessary. + + All `gnatmake' output (except when you specify `-M') is to `stderr'. + The output produced by the `-M' switch is send to `stdout'. + +  + File: gnat_ug_vxw.info, Node: Switches for gnatmake, Next: Mode Switches for gnatmake, Prev: Running gnatmake, Up: The GNAT Make Program gnatmake + + Switches for `gnatmake' + ======================= + + You may specify any of the following switches to `gnatmake': + + `--GCC=COMPILER_NAME' + Program used for compiling. The default is ``gcc''. You need to use + quotes around COMPILER_NAME if `compiler_name' contains spaces or + other separator characters. As an example `--GCC="foo -x -y"' will + instruct `gnatmake' to use `foo -x -y' as your compiler. Note that + switch `-c' is always inserted after your command name. Thus in + the above example the compiler command that will be used by + `gnatmake' will be `foo -c -x -y'. If several + `--GCC=compiler_name' are used, only the last COMPILER_NAME is + taken into account. However, all the additional switches are also + taken into account. Thus, `--GCC="foo -x -y" --GCC="bar -z -t"' is + equivalent to `--GCC="bar -x -y -z -t"'. + + `--GNATBIND=BINDER_NAME' + Program used for binding. The default is ``gnatbind''. You need to + use quotes around BINDER_NAME if BINDER_NAME contains spaces or + other separator characters. As an example `--GNATBIND="bar -x -y"' + will instruct `gnatmake' to use `bar -x -y' as your binder. Binder + switches that are normally appended by `gnatmake' to ``gnatbind'' + are now appended to the end of `bar -x -y'. + + `--GNATLINK=LINKER_NAME' + Program used for linking. The default is ``gnatlink''. You need to + use quotes around LINKER_NAME if LINKER_NAME contains spaces or + other separator characters. As an example `--GNATLINK="lan -x -y"' + will instruct `gnatmake' to use `lan -x -y' as your linker. Linker + switches that are normally appended by `gnatmake' to ``gnatlink'' + are now appended to the end of `lan -x -y'. + + `-a' + Consider all files in the make process, even the GNAT internal + system files (for example, the predefined Ada library files), as + well as any locked files. Locked files are files whose ALI file is + write-protected. By default, `gnatmake' does not check these + files, because the assumption is that the GNAT internal files are + properly up to date, and also that any write protected ALI files + have been properly installed. Note that if there is an + installation problem, such that one of these files is not up to + date, it will be properly caught by the binder. You may have to + specify this switch if you are working on GNAT itself. `-a' is + also useful in conjunction with `-f' if you need to recompile an + entire application, including run-time files, using special + configuration pragma settings, such as a non-standard + `Float_Representation' pragma. By default `gnatmake -a' compiles + all GNAT internal files with `gcc -c -gnatpg' rather than `gcc -c'. + + `-b' + Bind only. Can be combined with `-c' to do compilation and + binding, but no link. Can be combined with `-l' to do binding and + linking. When not combined with `-c' all the units in the closure + of the main program must have been previously compiled and must be + up to date. The root unit specified by FILE_NAME may be given + without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + `-c' + Compile only. Do not perform binding, except when `-b' is also + specified. Do not perform linking, except if both `-b' and `-l' + are also specified. If the root unit specified by FILE_NAME is + not a main unit, this is the default. Otherwise `gnatmake' will + attempt binding and linking unless all objects are up to date and + the executable is more recent than the objects. + + `-C' + Use a mapping file. A mapping file is a way to communicate to the + compiler two mappings: from unit names to file names (without any + directory information) and from file names to path names (with + full directory information). These mappings are used by the + compiler to short-circuit the path search. When `gnatmake' is + invoked with this switch, it will create a mapping file, initially + populated by the project manager, if `-P' is used, otherwise + initially empty. Each invocation of the compiler will add the newly + accessed sources to the mapping file. This will improve the source + search during the next invocation of the compiler. + + `-f' + Force recompilations. Recompile all sources, even though some + object files may be up to date, but don't recompile predefined or + GNAT internal files or locked files (files with a write-protected + ALI file), unless the `-a' switch is also specified. + + `' + + `-i' + In normal mode, `gnatmake' compiles all object files and ALI files + into the current directory. If the `-i' switch is used, then + instead object files and ALI files that already exist are + overwritten in place. This means that once a large project is + organized into separate directories in the desired manner, then + `gnatmake' will automatically maintain and update this + organization. If no ALI files are found on the Ada object path + (*Note Search Paths and the Run-Time Library (RTL)::), the new + object and ALI files are created in the directory containing the + source being compiled. If another organization is desired, where + objects and sources are kept in different directories, a useful + technique is to create dummy ALI files in the desired directories. + When detecting such a dummy file, `gnatmake' will be forced to + recompile the corresponding source file, and it will be put the + resulting object and ALI files in the directory where it found the + dummy file. + + `-jN' + Use N processes to carry out the (re)compilations. On a + multiprocessor machine compilations will occur in parallel. In the + event of compilation errors, messages from various compilations + might get interspersed (but `gnatmake' will give you the full + ordered list of failing compiles at the end). If this is + problematic, rerun the make process with n set to 1 to get a clean + list of messages. + + `-k' + Keep going. Continue as much as possible after a compilation + error. To ease the programmer's task in case of compilation + errors, the list of sources for which the compile fails is given + when `gnatmake' terminates. + + If `gnatmake' is invoked with several `file_names' and with this + switch, if there are compilation errors when building an + executable, `gnatmake' will not attempt to build the following + executables. + + `-l' + Link only. Can be combined with `-b' to binding and linking. + Linking will not be performed if combined with `-c' but not with + `-b'. When not combined with `-b' all the units in the closure of + the main program must have been previously compiled and must be up + to date, and the main program need to have been bound. The root + unit specified by FILE_NAME may be given without extension, with + the source extension or, if no GNAT Project File is specified, + with the ALI file extension. + + `-m' + Specifies that the minimum necessary amount of recompilations be + performed. In this mode `gnatmake' ignores time stamp differences + when the only modifications to a source file consist in + adding/removing comments, empty lines, spaces or tabs. This means + that if you have changed the comments in a source file or have + simply reformatted it, using this switch will tell gnatmake not to + recompile files that depend on it (provided other sources on which + these files depend have undergone no semantic modifications). Note + that the debugging information may be out of date with respect to + the sources if the `-m' switch causes a compilation to be + switched, so the use of this switch represents a trade-off between + compilation time and accurate debugging information. + + `-M' + Check if all objects are up to date. If they are, output the object + dependences to `stdout' in a form that can be directly exploited in + a `Makefile'. By default, each source file is prefixed with its + (relative or absolute) directory name. This name is whatever you + specified in the various `-aI' and `-I' switches. If you use + `gnatmake -M' `-q' (see below), only the source file names, + without relative paths, are output. If you just specify the `-M' + switch, dependencies of the GNAT internal system files are + omitted. This is typically what you want. If you also specify the + `-a' switch, dependencies of the GNAT internal files are also + listed. Note that dependencies of the objects in external Ada + libraries (see switch `-aL'DIR in the following list) are never + reported. + + `-n' + Don't compile, bind, or link. Checks if all objects are up to date. + If they are not, the full name of the first file that needs to be + recompiled is printed. Repeated use of this option, followed by + compiling the indicated source file, will eventually result in + recompiling all required units. + + `-o EXEC_NAME' + Output executable name. The name of the final executable program + will be EXEC_NAME. If the `-o' switch is omitted the default name + for the executable will be the name of the input file in + appropriate form for an executable file on the host system. + + This switch cannot be used when invoking `gnatmake' with several + `file_names'. + + `-q' + Quiet. When this flag is not set, the commands carried out by + `gnatmake' are displayed. + + `-s' + Recompile if compiler switches have changed since last compilation. + All compiler switches but -I and -o are taken into account in the + following way: orders between different "first letter" switches + are ignored, but orders between same switches are taken into + account. For example, `-O -O2' is different than `-O2 -O', but `-g + -O' is equivalent to `-O -g'. + + `-u' + Unique. Recompile at most the main file. It implies -c. Combined + with -f, it is equivalent to calling the compiler directly. + + `-v' + Verbose. Displays the reason for all recompilations `gnatmake' + decides are necessary. + + `-z' + No main subprogram. Bind and link the program even if the unit name + given on the command line is a package name. The resulting + executable will execute the elaboration routines of the package + and its closure, then the finalization routines. + + ``gcc' switches' + The switch `-g' or any uppercase switch (other than `-A', `-L' or + `-S') or any switch that is more than one character is passed to + `gcc' (e.g. `-O', `-gnato,' etc.) + + Source and library search path switches: + + `-aIDIR' + When looking for source files also look in directory DIR. The + order in which source files search is undertaken is described in + *Note Search Paths and the Run-Time Library (RTL)::. + + `-aLDIR' + Consider DIR as being an externally provided Ada library. + Instructs `gnatmake' to skip compilation units whose `.ali' files + have been located in directory DIR. This allows you to have + missing bodies for the units in DIR and to ignore out of date + bodies for the same units. You still need to specify the location + of the specs for these units by using the switches `-aIDIR' or + `-IDIR'. Note: this switch is provided for compatibility with + previous versions of `gnatmake'. The easier method of causing + standard libraries to be excluded from consideration is to + write-protect the corresponding ALI files. + + `-aODIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is described in + *Note Search Paths for gnatbind::. + + `-ADIR' + Equivalent to `-aLDIR -aIDIR'. + + `-IDIR' + Equivalent to `-aODIR -aIDIR'. + + `-I-' + Do not look for source files in the directory containing the source + file named in the command line. Do not look for ALI or object + files in the directory where `gnatmake' was invoked. + + `-LDIR' + Add directory DIR to the list of directories in which the linker + will search for libraries. This is equivalent to `-largs -L'DIR. + + `-nostdinc' + Do not look for source files in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. We look for + the runtime in the following directories, and stop as soon as a + valid runtime is found ("adainclude" or "ada_source_path", and + "adalib" or "ada_object_path" present): + + * /$rts_path + + * /$rts_path + + * /rts-$rts_path + + The selected path is handled like a normal RTS path. + +  + File: gnat_ug_vxw.info, Node: Mode Switches for gnatmake, Next: Notes on the Command Line, Prev: Switches for gnatmake, Up: The GNAT Make Program gnatmake + + Mode Switches for `gnatmake' + ============================ + + The mode switches (referred to as `mode_switches') allow the inclusion + of switches that are to be passed to the compiler itself, the binder or + the linker. The effect of a mode switch is to cause all subsequent + switches up to the end of the switch list, or up to the next mode + switch, to be interpreted as switches to be passed on to the designated + component of GNAT. + + `-cargs SWITCHES' + Compiler switches. Here SWITCHES is a list of switches that are + valid switches for `gcc'. They will be passed on to all compile + steps performed by `gnatmake'. + + `-bargs SWITCHES' + Binder switches. Here SWITCHES is a list of switches that are + valid switches for `gcc'. They will be passed on to all bind steps + performed by `gnatmake'. + + `-largs SWITCHES' + Linker switches. Here SWITCHES is a list of switches that are + valid switches for `gcc'. They will be passed on to all link steps + performed by `gnatmake'. + +  + File: gnat_ug_vxw.info, Node: Notes on the Command Line, Next: How gnatmake Works, Prev: Mode Switches for gnatmake, Up: The GNAT Make Program gnatmake + + Notes on the Command Line + ========================= + + This section contains some additional useful notes on the operation of + the `gnatmake' command. + + * If `gnatmake' finds no ALI files, it recompiles the main program + and all other units required by the main program. This means that + `gnatmake' can be used for the initial compile, as well as during + subsequent steps of the development cycle. + + * If you enter `gnatmake FILE.adb', where `FILE.adb' is a subunit or + body of a generic unit, `gnatmake' recompiles `FILE.adb' (because + it finds no ALI) and stops, issuing a warning. + + * In `gnatmake' the switch `-I' is used to specify both source and + library file paths. Use `-aI' instead if you just want to specify + source paths only and `-aO' if you want to specify library paths + only. + + * `gnatmake' examines both an ALI file and its corresponding object + file for consistency. If an ALI is more recent than its + corresponding object, or if the object file is missing, the + corresponding source will be recompiled. Note that `gnatmake' + expects an ALI and the corresponding object file to be in the same + directory. + + * `gnatmake' will ignore any files whose ALI file is write-protected. + This may conveniently be used to exclude standard libraries from + consideration and in particular it means that the use of the `-f' + switch will not recompile these files unless `-a' is also + specified. + + * `gnatmake' has been designed to make the use of Ada libraries + particularly convenient. Assume you have an Ada library organized + as follows: OBJ-DIR contains the objects and ALI files for of your + Ada compilation units, whereas INCLUDE-DIR contains the specs of + these units, but no bodies. Then to compile a unit stored in + `main.adb', which uses this Ada library you would just type + + $ gnatmake -aIINCLUDE-DIR -aLOBJ-DIR main + + * Using `gnatmake' along with the `-m (minimal recompilation)' + switch provides a mechanism for avoiding unnecessary + rcompilations. Using this switch, you can update the + comments/format of your source files without having to recompile + everything. Note, however, that adding or deleting lines in a + source files may render its debugging info obsolete. If the file + in question is a spec, the impact is rather limited, as that + debugging info will only be useful during the elaboration phase of + your program. For bodies the impact can be more significant. In + all events, your debugger will warn you if a source file is more + recent than the corresponding object, and alert you to the fact + that the debugging information may be out of date. + +  + File: gnat_ug_vxw.info, Node: How gnatmake Works, Next: Examples of gnatmake Usage, Prev: Notes on the Command Line, Up: The GNAT Make Program gnatmake + + How `gnatmake' Works + ==================== + + Generally `gnatmake' automatically performs all necessary + recompilations and you don't need to worry about how it works. However, + it may be useful to have some basic understanding of the `gnatmake' + approach and in particular to understand how it uses the results of + previous compilations without incorrectly depending on them. + + First a definition: an object file is considered "up to date" if the + corresponding ALI file exists and its time stamp predates that of the + object file and if all the source files listed in the dependency + section of this ALI file have time stamps matching those in the ALI + file. This means that neither the source file itself nor any files that + it depends on have been modified, and hence there is no need to + recompile this file. + + `gnatmake' works by first checking if the specified main unit is up + to date. If so, no compilations are required for the main unit. If not, + `gnatmake' compiles the main program to build a new ALI file that + reflects the latest sources. Then the ALI file of the main unit is + examined to find all the source files on which the main program depends, + and `gnatmake' recursively applies the above procedure on all these + files. + + This process ensures that `gnatmake' only trusts the dependencies in + an existing ALI file if they are known to be correct. Otherwise it + always recompiles to determine a new, guaranteed accurate set of + dependencies. As a result the program is compiled "upside down" from + what may be more familiar as the required order of compilation in some + other Ada systems. In particular, clients are compiled before the units + on which they depend. The ability of GNAT to compile in any order is + critical in allowing an order of compilation to be chosen that + guarantees that `gnatmake' will recompute a correct set of new + dependencies if necessary. + + When invoking `gnatmake' with several FILE_NAMES, if a unit is + imported by several of the executables, it will be recompiled at most + once. + +  + File: gnat_ug_vxw.info, Node: Examples of gnatmake Usage, Prev: How gnatmake Works, Up: The GNAT Make Program gnatmake + + Examples of `gnatmake' Usage + ============================ + + `gnatmake hello.adb' + Compile all files necessary to bind and link the main program + `hello.adb' (containing unit `Hello') and bind and link the + resulting object files to generate an executable file `hello'. + + `gnatmake main1 main2 main3' + Compile all files necessary to bind and link the main programs + `main1.adb' (containing unit `Main1'), `main2.adb' (containing + unit `Main2') and `main3.adb' (containing unit `Main3') and bind + and link the resulting object files to generate three executable + files `main1', `main2' and `main3'. + + `gnatmake -q Main_Unit -cargs -O2 -bargs -l' + Compile all files necessary to bind and link the main program unit + `Main_Unit' (from file `main_unit.adb'). All compilations will be + done with optimization level 2 and the order of elaboration will be + listed by the binder. `gnatmake' will operate in quiet mode, not + displaying commands it is executing. + +  + File: gnat_ug_vxw.info, Node: Renaming Files Using gnatchop, Next: Configuration Pragmas, Prev: The GNAT Make Program gnatmake, Up: Top + + Renaming Files Using `gnatchop' + ******************************* + + This chapter discusses how to handle files with multiple units by using + the `gnatchop' utility. This utility is also useful in renaming files + to meet the standard GNAT default file naming conventions. + + * Menu: + + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + +  + File: gnat_ug_vxw.info, Node: Handling Files with Multiple Units, Next: Operating gnatchop in Compilation Mode, Up: Renaming Files Using gnatchop + + Handling Files with Multiple Units + ================================== + + The basic compilation model of GNAT requires that a file submitted to + the compiler have only one unit and there be a strict correspondence + between the file name and the unit name. + + The `gnatchop' utility allows both of these rules to be relaxed, + allowing GNAT to process files which contain multiple compilation units + and files with arbitrary file names. `gnatchop' reads the specified + file and generates one or more output files, containing one unit per + file. The unit and the file name correspond, as required by GNAT. + + If you want to permanently restructure a set of "foreign" files so + that they match the GNAT rules, and do the remaining development using + the GNAT structure, you can simply use `gnatchop' once, generate the + new set of files and work with them from that point on. + + Alternatively, if you want to keep your files in the "foreign" + format, perhaps to maintain compatibility with some other Ada + compilation system, you can set up a procedure where you use `gnatchop' + each time you compile, regarding the source files that it writes as + temporary files that you throw away. + +  + File: gnat_ug_vxw.info, Node: Operating gnatchop in Compilation Mode, Next: Command Line for gnatchop, Prev: Handling Files with Multiple Units, Up: Renaming Files Using gnatchop + + Operating gnatchop in Compilation Mode + ====================================== + + The basic function of `gnatchop' is to take a file with multiple units + and split it into separate files. The boundary between files is + reasonably clear, except for the issue of comments and pragmas. In + default mode, the rule is that any pragmas between units belong to the + previous unit, except that configuration pragmas always belong to the + following unit. Any comments belong to the following unit. These rules + almost always result in the right choice of the split point without + needing to mark it explicitly and most users will find this default to + be what they want. In this default mode it is incorrect to submit a + file containing only configuration pragmas, or one that ends in + configuration pragmas, to `gnatchop'. + + However, using a special option to activate "compilation mode", + `gnatchop' can perform another function, which is to provide exactly + the semantics required by the RM for handling of configuration pragmas + in a compilation. In the absence of configuration pragmas (at the main + file level), this option has no effect, but it causes such + configuration pragmas to be handled in a quite different manner. + + First, in compilation mode, if `gnatchop' is given a file that + consists of only configuration pragmas, then this file is appended to + the `gnat.adc' file in the current directory. This behavior provides + the required behavior described in the RM for the actions to be taken + on submitting such a file to the compiler, namely that these pragmas + should apply to all subsequent compilations in the same compilation + environment. Using GNAT, the current directory, possibly containing a + `gnat.adc' file is the representation of a compilation environment. For + more information on the `gnat.adc' file, see the section on handling of + configuration pragmas *note Handling of Configuration Pragmas::. + + Second, in compilation mode, if `gnatchop' is given a file that + starts with configuration pragmas, and contains one or more units, then + these configuration pragmas are prepended to each of the chopped files. + This behavior provides the required behavior described in the RM for the + actions to be taken on compiling such a file, namely that the pragmas + apply to all units in the compilation, but not to subsequently compiled + units. + + Finally, if configuration pragmas appear between units, they are + appended to the previous unit. This results in the previous unit being + illegal, since the compiler does not accept configuration pragmas that + follow a unit. This provides the required RM behavior that forbids + configuration pragmas other than those preceding the first compilation + unit of a compilation. + + For most purposes, `gnatchop' will be used in default mode. The + compilation mode described above is used only if you need exactly + accurate behavior with respect to compilations, and you have files that + contain multiple units and configuration pragmas. In this circumstance + the use of `gnatchop' with the compilation mode switch provides the + required behavior, and is for example the mode in which GNAT processes + the ACVC tests. + +  + File: gnat_ug_vxw.info, Node: Command Line for gnatchop, Next: Switches for gnatchop, Prev: Operating gnatchop in Compilation Mode, Up: Renaming Files Using gnatchop + + Command Line for `gnatchop' + =========================== + + The `gnatchop' command has the form: + + $ gnatchop switches FILE NAME [FILE NAME FILE NAME ...] + [DIRECTORY] + + The only required argument is the file name of the file to be chopped. + There are no restrictions on the form of this file name. The file itself + contains one or more Ada units, in normal GNAT format, concatenated + together. As shown, more than one file may be presented to be chopped. + + When run in default mode, `gnatchop' generates one output file in + the current directory for each unit in each of the files. + + DIRECTORY, if specified, gives the name of the directory to which + the output files will be written. If it is not specified, all files are + written to the current directory. + + For example, given a file called `hellofiles' containing + + procedure hello; + + with Text_IO; use Text_IO; + procedure hello is + begin + Put_Line ("Hello"); + end hello; + + the command + + $ gnatchop hellofiles + + generates two files in the current directory, one called `hello.ads' + containing the single line that is the procedure spec, and the other + called `hello.adb' containing the remaining text. The original file is + not affected. The generated files can be compiled in the normal manner. + +  + File: gnat_ug_vxw.info, Node: Switches for gnatchop, Next: Examples of gnatchop Usage, Prev: Command Line for gnatchop, Up: Renaming Files Using gnatchop + + Switches for `gnatchop' + ======================= + + `gnatchop' recognizes the following switches: + + `-c' + Causes `gnatchop' to operate in compilation mode, in which + configuration pragmas are handled according to strict RM rules. See + previous section for a full description of this mode. + + `-gnatxxx' + This passes the given `-gnatxxx' switch to `gnat' which is used to + parse the given file. Not all `xxx' options make sense, but for + example, the use of `-gnati2' allows `gnatchop' to process a + source file that uses Latin-2 coding for identifiers. + + `-h' + Causes `gnatchop' to generate a brief help summary to the standard + output file showing usage information. + + `-kMM' + Limit generated file names to the specified number `mm' of + characters. This is useful if the resulting set of files is + required to be interoperable with systems which limit the length + of file names. No space is allowed between the `-k' and the + numeric value. The numeric value may be omitted in which case a + default of `-k8', suitable for use with DOS-like file systems, is + used. If no `-k' switch is present then there is no limit on the + length of file names. + + `-p' + Causes the file modification time stamp of the input file to be + preserved and used for the time stamp of the output file(s). This + may be useful for preserving coherency of time stamps in an + enviroment where `gnatchop' is used as part of a standard build + process. + + `-q' + Causes output of informational messages indicating the set of + generated files to be suppressed. Warnings and error messages are + unaffected. + + `-r' + Generate `Source_Reference' pragmas. Use this switch if the output + files are regarded as temporary and development is to be done in + terms of the original unchopped file. This switch causes + `Source_Reference' pragmas to be inserted into each of the + generated files to refers back to the original file name and line + number. The result is that all error messages refer back to the + original unchopped file. In addition, the debugging information + placed into the object file (when the `-g' switch of `gcc' or + `gnatmake' is specified) also refers back to this original file so + that tools like profilers and debuggers will give information in + terms of the original unchopped file. + + If the original file to be chopped itself contains a + `Source_Reference' pragma referencing a third file, then gnatchop + respects this pragma, and the generated `Source_Reference' pragmas + in the chopped file refer to the original file, with appropriate + line numbers. This is particularly useful when `gnatchop' is used + in conjunction with `gnatprep' to compile files that contain + preprocessing statements and multiple units. + + `-v' + Causes `gnatchop' to operate in verbose mode. The version number + and copyright notice are output, as well as exact copies of the + gnat1 commands spawned to obtain the chop control information. + + `-w' + Overwrite existing file names. Normally `gnatchop' regards it as a + fatal error if there is already a file with the same name as a + file it would otherwise output, in other words if the files to be + chopped contain duplicated units. This switch bypasses this check, + and causes all but the last instance of such duplicated units to + be skipped. + + `--GCC=xxxx' + Specify the path of the GNAT parser to be used. When this switch + is used, no attempt is made to add the prefix to the GNAT parser + executable. + +  + File: gnat_ug_vxw.info, Node: Examples of gnatchop Usage, Prev: Switches for gnatchop, Up: Renaming Files Using gnatchop + + Examples of `gnatchop' Usage + ============================ + + `gnatchop -w hello_s.ada ichbiah/files' + Chops the source file `hello_s.ada'. The output files will be + placed in the directory `ichbiah/files', overwriting any files + with matching names in that directory (no files in the current + directory are modified). + + `gnatchop archive' + Chops the source file `archive' into the current directory. One + useful application of `gnatchop' is in sending sets of sources + around, for example in email messages. The required sources are + simply concatenated (for example, using a Unix `cat' command), and + then `gnatchop' is used at the other end to reconstitute the + original file names. + + `gnatchop file1 file2 file3 direc' + Chops all units in files `file1', `file2', `file3', placing the + resulting files in the directory `direc'. Note that if any units + occur more than once anywhere within this set of files, an error + message is generated, and no files are written. To override this + check, use the `-w' switch, in which case the last occurrence in + the last file will be the one that is output, and earlier + duplicate occurrences for a given unit will be skipped. + +  + File: gnat_ug_vxw.info, Node: Configuration Pragmas, Next: Handling Arbitrary File Naming Conventions Using gnatname, Prev: Renaming Files Using gnatchop, Up: Top + + Configuration Pragmas + ********************* + + In Ada 95, configuration pragmas include those pragmas described as + such in the Ada 95 Reference Manual, as well as + implementation-dependent pragmas that are configuration pragmas. See the + individual descriptions of pragmas in the GNAT Reference Manual for + details on these additional GNAT-specific configuration pragmas. Most + notably, the pragma `Source_File_Name', which allows specifying + non-default names for source files, is a configuration pragma. The + following is a complete list of configuration pragmas recognized by + `GNAT': + + Ada_83 + Ada_95 + C_Pass_By_Copy + Component_Alignment + Discard_Names + Elaboration_Checks + Eliminate + Extend_System + Extensions_Allowed + External_Name_Casing + Float_Representation + Initialize_Scalars + License + Locking_Policy + Long_Float + No_Run_Time + Normalize_Scalars + Polling + Propagate_Exceptions + Queuing_Policy + Ravenscar + Restricted_Run_Time + Restrictions + Reviewable + Source_File_Name + Style_Checks + Suppress + Task_Dispatching_Policy + Unsuppress + Use_VADS_Size + Warnings + Validity_Checks + + * Menu: + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + +  + File: gnat_ug_vxw.info, Node: Handling of Configuration Pragmas, Next: The Configuration Pragmas Files, Up: Configuration Pragmas + + Handling of Configuration Pragmas + ================================= + + Configuration pragmas may either appear at the start of a compilation + unit, in which case they apply only to that unit, or they may apply to + all compilations performed in a given compilation environment. + + GNAT also provides the `gnatchop' utility to provide an automatic + way to handle configuration pragmas following the semantics for + compilations (that is, files with multiple units), described in the RM. + See section *note Operating gnatchop in Compilation Mode:: for details. + However, for most purposes, it will be more convenient to edit the + `gnat.adc' file that contains configuration pragmas directly, as + described in the following section. + +  + File: gnat_ug_vxw.info, Node: The Configuration Pragmas Files, Prev: Handling of Configuration Pragmas, Up: Configuration Pragmas + + The Configuration Pragmas Files + =============================== + + In GNAT a compilation environment is defined by the current directory + at the time that a compile command is given. This current directory is + searched for a file whose name is `gnat.adc'. If this file is present, + it is expected to contain one or more configuration pragmas that will + be applied to the current compilation. However, if the switch `-gnatA' + is used, `gnat.adc' is not considered. + + Configuration pragmas may be entered into the `gnat.adc' file either + by running `gnatchop' on a source file that consists only of + configuration pragmas, or more conveniently by direct editing of the + `gnat.adc' file, which is a standard format source file. + + In addition to `gnat.adc', one additional file containing + configuration pragmas may be applied to the current compilation using + the switch `-gnatec'PATH. PATH must designate an existing file that + contains only configuration pragmas. These configuration pragmas are in + addition to those found in `gnat.adc' (provided `gnat.adc' is present + and switch `-gnatA' is not used). + + It is allowed to specify several switches `-gnatec', however only + the last one on the command line will be taken into account. + +  + File: gnat_ug_vxw.info, Node: Handling Arbitrary File Naming Conventions Using gnatname, Next: GNAT Project Manager, Prev: Configuration Pragmas, Up: Top + + Handling Arbitrary File Naming Conventions Using `gnatname' + *********************************************************** + + * Menu: + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + +  + File: gnat_ug_vxw.info, Node: Arbitrary File Naming Conventions, Next: Running gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Arbitrary File Naming Conventions + ================================= + + The GNAT compiler must be able to know the source file name of a + compilation unit. When using the standard GNAT default file naming + conventions (`.ads' for specs, `.adb' for bodies), the GNAT compiler + does not need additional information. + + When the source file names do not follow the standard GNAT default file + naming conventions, the GNAT compiler must be given additional + information through a configuration pragmas file (see *Note + Configuration Pragmas::) or a project file. When the non standard file + naming conventions are well-defined, a small number of pragmas + `Source_File_Name' specifying a naming pattern (see *Note Alternative + File Naming Schemes::) may be sufficient. However, if the file naming + conventions are irregular or arbitrary, a number of pragma + `Source_File_Name' for individual compilation units must be defined. + To help maintain the correspondence between compilation unit names and + source file names within the compiler, GNAT provides a tool `gnatname' + to generate the required pragmas for a set of files. + +  + File: gnat_ug_vxw.info, Node: Running gnatname, Next: Switches for gnatname, Prev: Arbitrary File Naming Conventions, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Running `gnatname' + ================== + + The usual form of the `gnatname' command is + + $ gnatname [SWITCHES] NAMING_PATTERN [NAMING_PATTERNS] + + All of the arguments are optional. If invoked without any argument, + `gnatname' will display its usage. + + When used with at least one naming pattern, `gnatname' will attempt to + find all the compilation units in files that follow at least one of the + naming patterns. To find these compilation units, `gnatname' will use + the GNAT compiler in syntax-check-only mode on all regular files. + + One or several Naming Patterns may be given as arguments to `gnatname'. + Each Naming Pattern is enclosed between double quotes. A Naming + Pattern is a regular expression similar to the wildcard patterns used + in file names by the Unix shells or the DOS prompt. + + Examples of Naming Patterns are + + "*.[12].ada" + "*.ad[sb]*" + "body_*" "spec_*" + + For a more complete description of the syntax of Naming Patterns, see + the second kind of regular expressions described in `g-regexp.ads' (the + "Glob" regular expressions). + + When invoked with no switches, `gnatname' will create a configuration + pragmas file `gnat.adc' in the current working directory, with pragmas + `Source_File_Name' for each file that contains a valid Ada unit. + +  + File: gnat_ug_vxw.info, Node: Switches for gnatname, Next: Examples of gnatname Usage, Prev: Running gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Switches for `gnatname' + ======================= + + Switches for `gnatname' must precede any specified Naming Pattern. + + You may specify any of the following switches to `gnatname': + + `-c`file'' + Create a configuration pragmas file `file' (instead of the default + `gnat.adc'). There may be zero, one or more space between `-c' and + `file'. `file' may include directory information. `file' must be + writeable. There may be only one switch `-c'. When a switch `-c' is + specified, no switch `-P' may be specified (see below). + + `-d`dir'' + Look for source files in directory `dir'. There may be zero, one + or more spaces between `-d' and `dir'. When a switch `-d' is + specified, the current working directory will not be searched for + source files, unless it is explictly specified with a `-d' or `-D' + switch. Several switches `-d' may be specified. If `dir' is a + relative path, it is relative to the directory of the + configuration pragmas file specified with switch `-c', or to the + directory of the project file specified with switch `-P' or, if + neither switch `-c' nor switch `-P' are specified, it is relative + to the current working directory. The directory specified with + switch `-c' must exist and be readable. + + `-D`file'' + Look for source files in all directories listed in text file + `file'. There may be zero, one or more spaces between `-d' and + `dir'. `file' must be an existing, readable text file. Each non + empty line in `file' must be a directory. Specifying switch `-D' + is equivalent to specifying as many switches `-d' as there are non + empty lines in `file'. + + `-h' + Output usage (help) information. The output is written to `stdout'. + + `-P`proj'' + Create or update project file `proj'. There may be zero, one or + more space between `-P' and `proj'. `proj' may include directory + information. `proj' must be writeable. There may be only one + switch `-P'. When a switch `-P' is specified, no switch `-c' may + be specified. + + `-v' + Verbose mode. Output detailed explanation of behavior to `stdout'. + This includes name of the file written, the name of the + directories to search and, for each file in those directories + whose name matches at least one of the Naming Patterns, an + indication of whether the file contains a unit, and if so the name + of the unit. + + `-v -v' + Very Verbose mode. In addition to the output produced in verbose + mode, for each file in the searched directories whose name matches + none of the Naming Patterns, an indication is given that there is + no match. + + `-x`pattern'' + Excluded patterns. Using this switch, it is possible to exclude + some files that would match the name patterns. For example, + `"gnatname -x "*_nt.ada" "*.ada"' will look for Ada units in all + files with the `.ada' extension, except those whose names end with + `_nt.ada'. + +  + File: gnat_ug_vxw.info, Node: Examples of gnatname Usage, Prev: Switches for gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Examples of `gnatname' Usage + ============================ + + $ gnatname -c /home/me/names.adc -d sources "[a-z]*.ada*" + + In this example, the directory `/home/me' must already exist and be + writeable. In addition, the directory `/home/me/sources' (specified by + `-d sources') must exist and be readable. Note the optional spaces after + `-c' and `-d'. + + $ gnatname -P/home/me/proj -x "*_nt_body.ada" -dsources -dsources/plus -Dcommon_dirs.txt "body_*" "spec_*" + + Note that several switches `-d' may be used, even in conjunction + with one or several switches `-D'. Several Naming Patterns and one + excluded pattern are used in this example. + +  + File: gnat_ug_vxw.info, Node: GNAT Project Manager, Next: Elaboration Order Handling in GNAT, Prev: Handling Arbitrary File Naming Conventions Using gnatname, Up: Top + + GNAT Project Manager + ******************** + + * Menu: + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + +  + File: gnat_ug_vxw.info, Node: Introduction, Next: Examples of Project Files, Up: GNAT Project Manager + + Introduction + ============ + + This chapter describes GNAT's _Project Manager_, a facility that lets + you configure various properties for a collection of source files. In + particular, you can specify: + * The directory or set of directories containing the source files, + and/or the names of the specific source files themselves + + * The directory in which the compiler's output (`ALI' files, object + files, tree files) will be placed + + * The directory in which the executable programs will be placed + + * Switch settings for any of the project-enabled tools (`gnatmake', + compiler, binder, linker, `gnatls', `gnatxref', `gnatfind'); you + can apply these settings either globally or to individual units + + * The source files containing the main subprogram(s) to be built + + * The source programming language(s) (currently Ada and/or C) + + * Source file naming conventions; you can specify these either + globally or for individual units + + * Menu: + + * Project Files:: + +  + File: gnat_ug_vxw.info, Node: Project Files, Up: Introduction + + Project Files + ------------- + + A "project" is a specific set of values for these properties. You can + define a project's settings in a "project file", a text file with an + Ada-like syntax; a property value is either a string or a list of + strings. Properties that are not explicitly set receive default + values. A project file may interrogate the values of "external + variables" (user-defined command-line switches or environment + variables), and it may specify property settings conditionally, based + on the value of such variables. + + In simple cases, a project's source files depend only on other + source files in the same project, or on the predefined libraries. + ("Dependence" is in the technical sense; for example, one Ada unit + "with"ing another.) However, the Project Manager also allows much more + sophisticated arrangements, with the source files in one project + depending on source files in other projects: + * One project can _import_ other projects containing needed source + files. + + * You can organize GNAT projects in a hierarchy: a _child_ project + can extend a _parent_ project, inheriting the parent's source + files and optionally overriding any of them with alternative + versions + + More generally, the Project Manager lets you structure large development + efforts into hierarchical subsystems, with build decisions deferred to + the subsystem level and thus different compilation environments (switch + settings) used for different subsystems. + + The Project Manager is invoked through the `-P_projectfile_' switch + to `gnatmake' or to the `gnat' front driver. If you want to define (on + the command line) an external variable that is queried by the project + file, additionally use the `-X_vbl_=_value_' switch. The Project + Manager parses and interprets the project file, and drives the invoked + tool based on the project settings. + + The Project Manager supports a wide range of development strategies, + for systems of all sizes. Some typical practices that are easily + handled: + * Using a common set of source files, but generating object files in + different directories via different switch settings + + * Using a mostly-shared set of source files, but with different + versions of some unit or units + + The destination of an executable can be controlled inside a project file + using the `-o' switch. In the absence of such a switch either inside + the project file or on the command line, any executable files generated + by `gnatmake' will be placed in the directory `Exec_Dir' specified in + the project file. If no `Exec_Dir' is specified, they will be placed in + the object directory of the project. + + You can use project files to achieve some of the effects of a source + versioning system (for example, defining separate projects for the + different sets of sources that comprise different releases) but the + Project Manager is independent of any source configuration management + tools that might be used by the developers. + + The next section introduces the main features of GNAT's project + facility through a sequence of examples; subsequent sections will + present the syntax and semantics in more detail. + +  + File: gnat_ug_vxw.info, Node: Examples of Project Files, Next: Project File Syntax, Prev: Introduction, Up: GNAT Project Manager + + Examples of Project Files + ========================= + + This section illustrates some of the typical uses of project files and + explains their basic structure and behavior. + + * Menu: + + * Common Sources with Different Switches and Different Output Directories:: + * Using External Variables:: + * Importing Other Projects:: + * Extending a Project:: + +  + File: gnat_ug_vxw.info, Node: Common Sources with Different Switches and Different Output Directories, Next: Using External Variables, Up: Examples of Project Files + + Common Sources with Different Switches and Different Output Directories + ----------------------------------------------------------------------- + + * Menu: + + * Source Files:: + * Specifying the Object Directory:: + * Specifying the Exec Directory:: + * Project File Packages:: + * Specifying Switch Settings:: + * Main Subprograms:: + * Source File Naming Conventions:: + * Source Language(s):: + + Assume that the Ada source files `pack.ads', `pack.adb', and `proc.adb' + are in the `/common' directory. The file `proc.adb' contains an Ada + main subprogram `Proc' that "with"s package `Pack'. We want to compile + these source files under two sets of switches: + * When debugging, we want to pass the `-g' switch to `gnatmake', and + the `-gnata', `-gnato', and `-gnatE' switches to the compiler; the + compiler's output is to appear in `/common/debug' + + * When preparing a release version, we want to pass the `-O2' switch + to the compiler; the compiler's output is to appear in + `/common/release' + + The GNAT project files shown below, respectively `debug.gpr' and + `release.gpr' in the `/common' directory, achieve these effects. + + Diagrammatically: + /common + debug.gpr + release.gpr + pack.ads + pack.adb + proc.adb + /common/debug {-g, -gnata, -gnato, -gnatE} + proc.ali, proc.o + pack.ali, pack.o + /common/release {-O2} + proc.ali, proc.o + pack.ali, pack.o + Here are the project files: + project Debug is + for Object_Dir use "debug"; + for Main use ("proc"); + + package Builder is + for Default_Switches ("Ada") use ("-g"); + end Builder; + + package Compiler is + for Default_Switches ("Ada") + use ("-fstack-check", "-gnata", "-gnato", "-gnatE"); + end Compiler; + end Debug; + + project Release is + for Object_Dir use "release"; + for Exec_Dir use "."; + for Main use ("proc"); + + package Compiler is + for Default_Switches ("Ada") use ("-O2"); + end Compiler; + end Release; + + The name of the project defined by `debug.gpr' is `"Debug"' (case + insensitive), and analogously the project defined by `release.gpr' is + `"Release"'. For consistency the file should have the same name as the + project, and the project file's extension should be `"gpr"'. These + conventions are not required, but a warning is issued if they are not + followed. + + If the current directory is `/temp', then the command + gnatmake -P/common/debug.gpr + + generates object and ALI files in `/common/debug', and the `proc' + executable also in `/common/debug', using the switch settings defined in + the project file. + + Likewise, the command + gnatmake -P/common/release.gpr + + generates object and ALI files in `/common/release', and the `proc' + executable in `/common', using the switch settings from the project + file. + +  + File: gnat_ug_vxw.info, Node: Source Files, Next: Specifying the Object Directory, Up: Common Sources with Different Switches and Different Output Directories + + Source Files + ............ + + If a project file does not explicitly specify a set of source + directories or a set of source files, then by default the project's + source files are the Ada source files in the project file directory. + Thus `pack.ads', `pack.adb', and `proc.adb' are the source files for + both projects. + +  + File: gnat_ug_vxw.info, Node: Specifying the Object Directory, Next: Specifying the Exec Directory, Prev: Source Files, Up: Common Sources with Different Switches and Different Output Directories + + Specifying the Object Directory + ............................... + + Several project properties are modeled by Ada-style _attributes_; you + define the property by supplying the equivalent of an Ada attribute + definition clause in the project file. A project's object directory is + such a property; the corresponding attribute is `Object_Dir', and its + value is a string expression. A directory may be specified either as + absolute or as relative; in the latter case, it is relative to the + project file directory. Thus the compiler's output is directed to + `/common/debug' (for the `Debug' project) and to `/common/release' (for + the `Release' project). If `Object_Dir' is not specified, then the + default is the project file directory. + +  + File: gnat_ug_vxw.info, Node: Specifying the Exec Directory, Next: Project File Packages, Prev: Specifying the Object Directory, Up: Common Sources with Different Switches and Different Output Directories + + Specifying the Exec Directory + ............................. + + A project's exec directory is another property; the corresponding + attribute is `Exec_Dir', and its value is also a string expression, + either specified as relative or absolute. If `Exec_Dir' is not + specified, then the default is the object directory (which may also be + the project file directory if attribute `Object_Dir' is not specified). + Thus the executable is placed in `/common/debug' for the `Debug' + project (attribute `Exec_Dir' not specified) and in `/common' for the + `Release' project. + +  + File: gnat_ug_vxw.info, Node: Project File Packages, Next: Specifying Switch Settings, Prev: Specifying the Exec Directory, Up: Common Sources with Different Switches and Different Output Directories + + Project File Packages + ..................... + + A GNAT tool integrated with the Project Manager is modeled by a + corresponding package in the project file. The `Debug' project defines + the packages `Builder' (for `gnatmake') and `Compiler'; the `Release' + project defines only the `Compiler' package. + + The Ada package syntax is not to be taken literally. Although + packages in project files bear a surface resemblance to packages in Ada + source code, the notation is simply a way to convey a grouping of + properties for a named entity. Indeed, the package names permitted in + project files are restricted to a predefined set, corresponding to the + project-aware tools, and the contents of packages are limited to a + small set of constructs. The packages in the example above contain + attribute definitions. + +  + File: gnat_ug_vxw.info, Node: Specifying Switch Settings, Next: Main Subprograms, Prev: Project File Packages, Up: Common Sources with Different Switches and Different Output Directories + + Specifying Switch Settings + .......................... + + Switch settings for a project-aware tool can be specified through + attributes in the package corresponding to the tool. The example above + illustrates one of the relevant attributes, `Default_Switches', defined + in the packages in both project files. Unlike simple attributes like + `Source_Dirs', `Default_Switches' is known as an _associative array_. + When you define this attribute, you must supply an "index" (a literal + string), and the effect of the attribute definition is to set the value + of the "array" at the specified "index". For the `Default_Switches' + attribute, the index is a programming language (in our case, Ada) , and + the value specified (after `use') must be a list of string expressions. + + The attributes permitted in project files are restricted to a + predefined set. Some may appear at project level, others in packages. + For any attribute that is an associate array, the index must always be a + literal string, but the restrictions on this string (e.g., a file name + or a language name) depend on the individual attribute. Also depending + on the attribute, its specified value will need to be either a string + or a string list. + + In the `Debug' project, we set the switches for two tools, + `gnatmake' and the compiler, and thus we include corresponding + packages, with each package defining the `Default_Switches' attribute + with index `"Ada"'. Note that the package corresponding to `gnatmake' + is named `Builder'. The `Release' project is similar, but with just + the `Compiler' package. + + In project `Debug' above the switches starting with `-gnat' that are + specified in package `Compiler' could have been placed in package + `Builder', since `gnatmake' transmits all such switches to the compiler. + +  + File: gnat_ug_vxw.info, Node: Main Subprograms, Next: Source File Naming Conventions, Prev: Specifying Switch Settings, Up: Common Sources with Different Switches and Different Output Directories + + Main Subprograms + ................ + + One of the properties of a project is its list of main subprograms + (actually a list of names of source files containing main subprograms, + with the file extension optional. This property is captured in the + `Main' attribute, whose value is a list of strings. If a project + defines the `Main' attribute, then you do not need to identify the main + subprogram(s) when invoking `gnatmake' (see *Note gnatmake and Project + Files::). + +  + File: gnat_ug_vxw.info, Node: Source File Naming Conventions, Next: Source Language(s), Prev: Main Subprograms, Up: Common Sources with Different Switches and Different Output Directories + + Source File Naming Conventions + .............................. + + Since the project files do not specify any source file naming + conventions, the GNAT defaults are used. The mechanism for defining + source file naming conventions - a package named `Naming' - will be + described below (*note Naming Schemes::). + +  + File: gnat_ug_vxw.info, Node: Source Language(s), Prev: Source File Naming Conventions, Up: Common Sources with Different Switches and Different Output Directories + + Source Language(s) + .................. + + Since the project files do not specify a `Languages' attribute, by + default the GNAT tools assume that the language of the project file is + Ada. More generally, a project can comprise source files in Ada, C, + and/or other languages. + +  + File: gnat_ug_vxw.info, Node: Using External Variables, Next: Importing Other Projects, Prev: Common Sources with Different Switches and Different Output Directories, Up: Examples of Project Files + + Using External Variables + ------------------------ + + Instead of supplying different project files for debug and release, we + can define a single project file that queries an external variable (set + either on the command line or via an environment variable) in order to + conditionally define the appropriate settings. Again, assume that the + source files `pack.ads', `pack.adb', and `proc.adb' are located in + directory `/common'. The following project file, `build.gpr', queries + the external variable named `STYLE' and defines an object directory and + switch settings based on whether the value is `"deb"' (debug) or + `"rel"' (release), where the default is `"deb"'. + + project Build is + for Main use ("proc"); + + type Style_Type is ("deb", "rel"); + Style : Style_Type := external ("STYLE", "deb"); + + case Style is + when "deb" => + for Object_Dir use "debug"; + + when "rel" => + for Object_Dir use "release"; + for Exec_Dir use "."; + end case; + + package Builder is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-g"); + end case; + + end Builder; + + package Compiler is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-gnata", "-gnato", "-gnatE"); + + when "rel" => + for Default_Switches ("Ada") use ("-O2"); + end case; + + end Compiler; + + end Build; + + `Style_Type' is an example of a _string type_, which is the project + file analog of an Ada enumeration type but containing string literals + rather than identifiers. `Style' is declared as a variable of this + type. + + The form `external("STYLE", "deb")' is known as an _external + reference_; its first argument is the name of an _external variable_, + and the second argument is a default value to be used if the external + variable doesn't exist. You can define an external variable on the + command line via the `-X' switch, or you can use an environment + variable as an external variable. + + Each `case' construct is expanded by the Project Manager based on the + value of `Style'. Thus the command + gnatmake -P/common/build.gpr -XSTYLE=deb + + is equivalent to the `gnatmake' invocation using the project file + `debug.gpr' in the earlier example. So is the command + gnatmake -P/common/build.gpr + + since `"deb"' is the default for `STYLE'. + + Analogously, + gnatmake -P/common/build.gpr -XSTYLE=rel + + is equivalent to the `gnatmake' invocation using the project file + `release.gpr' in the earlier example. + +  + File: gnat_ug_vxw.info, Node: Importing Other Projects, Next: Extending a Project, Prev: Using External Variables, Up: Examples of Project Files + + Importing Other Projects + ------------------------ + + A compilation unit in a source file in one project may depend on + compilation units in source files in other projects. To obtain this + behavior, the dependent project must _import_ the projects containing + the needed source files. This effect is embodied in syntax similar to + an Ada `with' clause, but the "with"ed entities are strings denoting + project files. + + As an example, suppose that the two projects `GUI_Proj' and + `Comm_Proj' are defined in the project files `gui_proj.gpr' and + `comm_proj.gpr' in directories `/gui' and `/comm', respectively. + Assume that the source files for `GUI_Proj' are `gui.ads' and + `gui.adb', and that the source files for `Comm_Proj' are `comm.ads' and + `comm.adb', with each set of files located in its respective project + file directory. Diagrammatically: + + /gui + gui_proj.gpr + gui.ads + gui.adb + + /comm + comm_proj.gpr + comm.ads + comm.adb + + We want to develop an application in directory `/app' that "with"s the + packages `GUI' and `Comm', using the properties of the corresponding + project files (e.g. the switch settings and object directory). + Skeletal code for a main procedure might be something like the + following: + + with GUI, Comm; + procedure App_Main is + ... + begin + ... + end App_Main; + + Here is a project file, `app_proj.gpr', that achieves the desired + effect: + + with "/gui/gui_proj", "/comm/comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + + Building an executable is achieved through the command: + gnatmake -P/app/app_proj + + which will generate the `app_main' executable in the directory where + `app_proj.gpr' resides. + + If an imported project file uses the standard extension (`gpr') then + (as illustrated above) the `with' clause can omit the extension. + + Our example specified an absolute path for each imported project + file. Alternatively, you can omit the directory if either + * The imported project file is in the same directory as the + importing project file, or + + * You have defined an environment variable `ADA_PROJECT_PATH' that + includes the directory containing the needed project file. + + Thus, if we define `ADA_PROJECT_PATH' to include `/gui' and `/comm', + then our project file `app_proj.gpr' could be written as follows: + + with "gui_proj", "comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + + Importing other projects raises the possibility of ambiguities. For + example, the same unit might be present in different imported projects, + or it might be present in both the importing project and an imported + project. Both of these conditions are errors. Note that in the + current version of the Project Manager, it is illegal to have an + ambiguous unit even if the unit is never referenced by the importing + project. This restriction may be relaxed in a future release. + +  + File: gnat_ug_vxw.info, Node: Extending a Project, Prev: Importing Other Projects, Up: Examples of Project Files + + Extending a Project + ------------------- + + A common situation in large software systems is to have multiple + implementations for a common interface; in Ada terms, multiple versions + of a package body for the same specification. For example, one + implementation might be safe for use in tasking programs, while another + might only be used in sequential applications. This can be modeled in + GNAT using the concept of _project extension_. If one project (the + "child") _extends_ another project (the "parent") then by default all + source files of the parent project are inherited by the child, but the + child project can override any of the parent's source files with new + versions, and can also add new files. This facility is the project + analog of extension in Object-Oriented Programming. Project + hierarchies are permitted (a child project may be the parent of yet + another project), and a project that inherits one project can also + import other projects. + + As an example, suppose that directory `/seq' contains the project + file `seq_proj.gpr' and the source files `pack.ads', `pack.adb', and + `proc.adb': + + /seq + pack.ads + pack.adb + proc.adb + seq_proj.gpr + + Note that the project file can simply be empty (that is, no attribute or + package is defined): + + project Seq_Proj is + end Seq_Proj; + + implying that its source files are all the Ada source files in the + project directory. + + Suppose we want to supply an alternate version of `pack.adb', in + directory `/tasking', but use the existing versions of `pack.ads' and + `proc.adb'. We can define a project `Tasking_Proj' that inherits + `Seq_Proj': + + /tasking + pack.adb + tasking_proj.gpr + + project Tasking_Proj extends "/seq/seq_proj" is + end Tasking_Proj; + + The version of `pack.adb' used in a build depends on which project file + is specified. + + Note that we could have designed this using project import rather + than project inheritance; a `base' project would contain the sources for + `pack.ads' and `proc.adb', a sequential project would import `base' and + add `pack.adb', and likewise a tasking project would import `base' and + add a different version of `pack.adb'. The choice depends on whether + other sources in the original project need to be overridden. If they + do, then project extension is necessary, otherwise, importing is + sufficient. + +  + File: gnat_ug_vxw.info, Node: Project File Syntax, Next: Objects and Sources in Project Files, Prev: Examples of Project Files, Up: GNAT Project Manager + + Project File Syntax + =================== + + * Menu: + + * Basic Syntax:: + * Packages:: + * Expressions:: + * String Types:: + * Variables:: + * Attributes:: + * Associative Array Attributes:: + * case Constructions:: + + This section describes the structure of project files. + + A project may be an _independent project_, entirely defined by a + single project file. Any Ada source file in an independent project + depends only on the predefined library and other Ada source files in + the same project. + + A project may also "depend on" other projects, in either or both of the + following ways: + * It may import any number of projects + + * It may extend at most one other project + + The dependence relation is a directed acyclic graph (the subgraph + reflecting the "extends" relation is a tree). + + A project's "immediate sources" are the source files directly + defined by that project, either implicitly by residing in the project + file's directory, or explicitly through any of the source-related + attributes described below. More generally, a project PROJ's "sources" + are the immediate sources of PROJ together with the immediate sources + (unless overridden) of any project on which PROJ depends (either + directly or indirectly). + +  + File: gnat_ug_vxw.info, Node: Basic Syntax, Next: Packages, Up: Project File Syntax + + Basic Syntax + ------------ + + As seen in the earlier examples, project files have an Ada-like syntax. + The minimal project file is: + project Empty is + + end Empty; + + The identifier `Empty' is the name of the project. This project name + must be present after the reserved word `end' at the end of the project + file, followed by a semi-colon. + + Any name in a project file, such as the project name or a variable + name, has the same syntax as an Ada identifier. + + The reserved words of project files are the Ada reserved words plus + `extends', `external', and `project'. Note that the only Ada reserved + words currently used in project file syntax are: + + * `case' + + * `end' + + * `for' + + * `is' + + * `others' + + * `package' + + * `renames' + + * `type' + + * `use' + + * `when' + + * `with' + + Comments in project files have the same syntax as in Ada, two + consecutives hyphens through the end of the line. + +  + File: gnat_ug_vxw.info, Node: Packages, Next: Expressions, Prev: Basic Syntax, Up: Project File Syntax + + Packages + -------- + + A project file may contain _packages_. The name of a package must be one + of the identifiers (case insensitive) from a predefined list, and a + package with a given name may only appear once in a project file. The + predefined list includes the following packages: + + * `Naming' + + * `Builder' + + * `Compiler' + + * `Binder' + + * `Linker' + + * `Finder' + + * `Cross_Reference' + + * `gnatls' + + (The complete list of the package names and their attributes can be + found in file `prj-attr.adb'). + + In its simplest form, a package may be empty: + + project Simple is + package Builder is + end Builder; + end Simple; + + A package may contain _attribute declarations_, _variable declarations_ + and _case constructions_, as will be described below. + + When there is ambiguity between a project name and a package name, + the name always designates the project. To avoid possible confusion, it + is always a good idea to avoid naming a project with one of the names + allowed for packages or any name that starts with `gnat'. + +  + File: gnat_ug_vxw.info, Node: Expressions, Next: String Types, Prev: Packages, Up: Project File Syntax + + Expressions + ----------- + + An _expression_ is either a _string expression_ or a _string list + expression_. + + A _string expression_ is either a _simple string expression_ or a + _compound string expression_. + + A _simple string expression_ is one of the following: + * A literal string; e.g.`"comm/my_proj.gpr"' + + * A string-valued variable reference (see *Note Variables::) + + * A string-valued attribute reference (see *Note Attributes::) + + * An external reference (see *Note External References in Project + Files::) + + A _compound string expression_ is a concatenation of string expressions, + using `"&"' + Path & "/" & File_Name & ".ads" + + A _string list expression_ is either a _simple string list expression_ + or a _compound string list expression_. + + A _simple string list expression_ is one of the following: + * A parenthesized list of zero or more string expressions, separated + by commas + File_Names := (File_Name, "gnat.adc", File_Name & ".orig"); + Empty_List := (); + + * A string list-valued variable reference + + * A string list-valued attribute reference + + A _compound string list expression_ is the concatenation (using `"&"') + of a simple string list expression and an expression. Note that each + term in a compound string list expression, except the first, may be + either a string expression or a string list expression. + + File_Name_List := () & File_Name; -- One string in this list + Extended_File_Name_List := File_Name_List & (File_Name & ".orig"); + -- Two strings + Big_List := File_Name_List & Extended_File_Name_List; + -- Concatenation of two string lists: three strings + Illegal_List := "gnat.adc" & Extended_File_Name_List; + -- Illegal: must start with a string list + +  + File: gnat_ug_vxw.info, Node: String Types, Next: Variables, Prev: Expressions, Up: Project File Syntax + + String Types + ------------ + + The value of a variable may be restricted to a list of string literals. + The restricted list of string literals is given in a _string type + declaration_. + + Here is an example of a string type declaration: + + type OS is ("NT, "nt", "Unix", "Linux", "other OS"); + + Variables of a string type are called _typed variables_; all other + variables are called _untyped variables_. Typed variables are + particularly useful in `case' constructions (see *Note case + Constructions::). + + A string type declaration starts with the reserved word `type', + followed by the name of the string type (case-insensitive), followed by + the reserved word `is', followed by a parenthesized list of one or more + string literals separated by commas, followed by a semicolon. + + The string literals in the list are case sensitive and must all be + different. They may include any graphic characters allowed in Ada, + including spaces. + + A string type may only be declared at the project level, not inside + a package. + + A string type may be referenced by its name if it has been declared + in the same project file, or by its project name, followed by a dot, + followed by the string type name. + +  + File: gnat_ug_vxw.info, Node: Variables, Next: Attributes, Prev: String Types, Up: Project File Syntax + + Variables + --------- + + A variable may be declared at the project file level, or in a package. + Here are some examples of variable declarations: + + This_OS : OS := external ("OS"); -- a typed variable declaration + That_OS := "Linux"; -- an untyped variable declaration + + A _typed variable declaration_ includes the variable name, followed by + a colon, followed by the name of a string type, followed by `:=', + followed by a simple string expression. + + An _untyped variable declaration_ includes the variable name, + followed by `:=', followed by an expression. Note that, despite the + terminology, this form of "declaration" resembles more an assignment + than a declaration in Ada. It is a declaration in several senses: + * The variable name does not need to be defined previously + + * The declaration establishes the _kind_ (string versus string list) + of the variable, and later declarations of the same variable need + to be consistent with this + + A string variable declaration (typed or untyped) declares a variable + whose value is a string. This variable may be used as a string + expression. + File_Name := "readme.txt"; + Saved_File_Name := File_Name & ".saved"; + + A string list variable declaration declares a variable whose value is a + list of strings. The list may contain any number (zero or more) of + strings. + + Empty_List := (); + List_With_One_Element := ("-gnaty"); + List_With_Two_Elements := List_With_One_Element & "-gnatg"; + Long_List := ("main.ada", "pack1_.ada", "pack1.ada", "pack2_.ada" + "pack2.ada", "util_.ada", "util.ada"); + + The same typed variable may not be declared more than once at project + level, and it may not be declared more than once in any package; it is + in effect a constant or a readonly variable. + + The same untyped variable may be declared several times. In this + case, the new value replaces the old one, and any subsequent reference + to the variable uses the new value. However, as noted above, if a + variable has been declared as a string, all subsequent declarations + must give it a string value. Similarly, if a variable has been declared + as a string list, all subsequent declarations must give it a string + list value. + + A _variable reference_ may take several forms: + + * The simple variable name, for a variable in the current package + (if any) or in the current project + + * A context name, followed by a dot, followed by the variable name. + + A _context_ may be one of the following: + + * The name of an existing package in the current project + + * The name of an imported project of the current project + + * The name of an ancestor project (i.e., a project extended by the + current project, either directly or indirectly) + + * An imported/parent project name, followed by a dot, followed by a + package name + + A variable reference may be used in an expression. + +  + File: gnat_ug_vxw.info, Node: Attributes, Next: Associative Array Attributes, Prev: Variables, Up: Project File Syntax + + Attributes + ---------- + + A project (and its packages) may have _attributes_ that define the + project's properties. Some attributes have values that are strings; + others have values that are string lists. + + There are two categories of attributes: _simple attributes_ and + _associative arrays_ (see *Note Associative Array Attributes::). + + The names of the attributes are restricted; there is a list of + project attributes, and a list of package attributes for each package. + The names are not case sensitive. + + The project attributes are as follows (all are simple attributes): + + _Attribute Name_ _Value_ + `Source_Files' string list + `Source_Dirs' string list + `Source_List_File' string + `Object_Dir' string + `Exec_Dir' string + `Main' string list + `Languages' string list + `Library_Dir' string + `Library_Name' string + `Library_Kind' string + `Library_Elaboration' string + `Library_Version' string + + The attributes for package `Naming' are as follows (see *Note Naming + Schemes::): + + Attribute Name Category Index Value + `Specification_Suffix' associative language name string + array + `Implementation_Suffix' associative language name string + array + `Separate_Suffix' simple n/a string + attribute + `Casing' simple n/a string + attribute + `Dot_Replacement' simple n/a string + attribute + `Specification' associative Ada unit name string + array + `Implementation' associative Ada unit name string + array + `Specification_Exceptions' associative language name string list + array + `Implementation_Exceptions' associative language name string list + array + + The attributes for package `Builder', `Compiler', `Binder', `Linker', + `Cross_Reference', and `Finder' are as follows (see *Note Switches and + Project Files::). + + Attribute Name Category Index Value + `Default_Switches' associative language name string list + array + `Switches' associative file name string list + array + + In addition, package `Builder' has a single string attribute + `Local_Configuration_Pragmas' and package `Builder' has a single string + attribute `Global_Configuration_Pragmas'. + + The attribute for package `Glide' are not documented: they are for + internal use only. + + Each simple attribute has a default value: the empty string (for + string-valued attributes) and the empty list (for string list-valued + attributes). + + Similar to variable declarations, an attribute declaration defines a + new value for an attribute. + + Examples of simple attribute declarations: + + for Object_Dir use "objects"; + for Source_Dirs use ("units", "test/drivers"); + + A "simple attribute declaration" starts with the reserved word `for', + followed by the name of the attribute, followed by the reserved word + `use', followed by an expression (whose kind depends on the attribute), + followed by a semicolon. + + Attributes may be referenced in expressions. The general form for + such a reference is `'': the entity for which the + attribute is defined, followed by an apostrophe, followed by the name + of the attribute. For associative array attributes, a litteral string + between parentheses need to be supplied as index. + + Examples are: + + project'Object_Dir + Naming'Dot_Replacement + Imported_Project'Source_Dirs + Imported_Project.Naming'Casing + Builder'Default_Switches("Ada") + + The entity may be: + * `project' for an attribute of the current project + + * The name of an existing package of the current project + + * The name of an imported project + + * The name of a parent project (extended by the current project) + + * An imported/parent project name, followed by a dot, followed + by a package name + + Example: + project Prj is + for Source_Dirs use project'Source_Dirs & "units"; + for Source_Dirs use project'Source_Dirs & "test/drivers" + end Prj; + + In the first attribute declaration, initially the attribute + `Source_Dirs' has the default value: an empty string list. After this + declaration, `Source_Dirs' is a string list of one element: "units". + After the second attribute declaration `Source_Dirs' is a string list of + two elements: "units" and "test/drivers". + + Note: this example is for illustration only. In practice, the + project file would contain only one attribute declaration: + + for Source_Dirs use ("units", "test/drivers"); + +  + File: gnat_ug_vxw.info, Node: Associative Array Attributes, Next: case Constructions, Prev: Attributes, Up: Project File Syntax + + Associative Array Attributes + ---------------------------- + + Some attributes are defined as _associative arrays_. An associative + array may be regarded as a function that takes a string as a parameter + and delivers a string or string list value as its result. + + Here are some examples of associative array attribute declarations: + + for Implementation ("main") use "Main.ada"; + for Switches ("main.ada") use ("-v", "-gnatv"); + for Switches ("main.ada") use Builder'Switches ("main.ada") & "-g"; + + Like untyped variables and simple attributes, associative array + attributes may be declared several times. Each declaration supplies a + new value for the attribute, replacing the previous setting. + +  + File: gnat_ug_vxw.info, Node: case Constructions, Prev: Associative Array Attributes, Up: Project File Syntax + + `case' Constructions + -------------------- + + A `case' construction is used in a project file to effect conditional + behavior. Here is a typical example: + + project MyProj is + type OS_Type is ("Linux", "Unix", "NT", "VMS"); + + OS : OS_Type := external ("OS", "Linux"); + + package Compiler is + case OS is + when "Linux" | "Unix" => + for Default_Switches ("Ada") use ("-gnath"); + when "NT" => + for Default_Switches ("Ada") use ("-gnatP"); + when others => + end case; + end Compiler; + end MyProj; + + The syntax of a `case' construction is based on the Ada case statement + (although there is no `null' construction for empty alternatives). + + Following the reserved word `case' there is the case variable (a + typed string variable), the reserved word `is', and then a sequence of + one or more alternatives. Each alternative comprises the reserved word + `when', either a list of literal strings separated by the `"|"' + character or the reserved word `others', and the `"=>"' token. Each + literal string must belong to the string type that is the type of the + case variable. An `others' alternative, if present, must occur last. + The `end case;' sequence terminates the case construction. + + After each `=>', there are zero or more constructions. The only + constructions allowed in a case construction are other case + constructions and attribute declarations. String type declarations, + variable declarations and package declarations are not allowed. + + The value of the case variable is often given by an external + reference (see *Note External References in Project Files::). + +  + File: gnat_ug_vxw.info, Node: Objects and Sources in Project Files, Next: Importing Projects, Prev: Project File Syntax, Up: GNAT Project Manager + + Objects and Sources in Project Files + ==================================== + + * Menu: + + * Object Directory:: + * Exec Directory:: + * Source Directories:: + * Source File Names:: + + Each project has exactly one object directory and one or more source + directories. The source directories must contain at least one source + file, unless the project file explicitly specifies that no source + files are present (see *Note Source File Names::). + +  + File: gnat_ug_vxw.info, Node: Object Directory, Next: Exec Directory, Up: Objects and Sources in Project Files + + Object Directory + ---------------- + + The object directory for a project is the directory containing the + compiler's output (such as `ALI' files and object files) for the + project's immediate sources. Note that for inherited sources (when + extending a parent project) the parent project's object directory is + used. + + The object directory is given by the value of the attribute + `Object_Dir' in the project file. + + for Object_Dir use "objects"; + + The attribute OBJECT_DIR has a string value, the path name of the object + directory. The path name may be absolute or relative to the directory + of the project file. This directory must already exist, and be readable + and writable. + + By default, when the attribute `Object_Dir' is not given an explicit + value or when its value is the empty string, the object directory is + the same as the directory containing the project file. + +  + File: gnat_ug_vxw.info, Node: Exec Directory, Next: Source Directories, Prev: Object Directory, Up: Objects and Sources in Project Files + + Exec Directory + -------------- + + The exec directory for a project is the directory containing the + executables for the project's main subprograms. + + The exec directory is given by the value of the attribute `Exec_Dir' + in the project file. + + for Exec_Dir use "executables"; + + The attribute EXEC_DIR has a string value, the path name of the exec + directory. The path name may be absolute or relative to the directory + of the project file. This directory must already exist, and be writable. + + By default, when the attribute `Exec_Dir' is not given an explicit + value or when its value is the empty string, the exec directory is the + same as the object directory of the project file. + +  + File: gnat_ug_vxw.info, Node: Source Directories, Next: Source File Names, Prev: Exec Directory, Up: Objects and Sources in Project Files + + Source Directories + ------------------ + + The source directories of a project are specified by the project file + attribute `Source_Dirs'. + + This attribute's value is a string list. If the attribute is not + given an explicit value, then there is only one source directory, the + one where the project file resides. + + A `Source_Dirs' attribute that is explicitly defined to be the empty + list, as in + + for Source_Dirs use (); + + indicates that the project contains no source files. + + Otherwise, each string in the string list designates one or more + source directories. + + for Source_Dirs use ("sources", "test/drivers"); + + If a string in the list ends with `"/**"', then the directory whose + path name precedes the two asterisks, as well as all its subdirectories + (recursively), are source directories. + + for Source_Dirs use ("/system/sources/**"); + + Here the directory `/system/sources' and all of its subdirectories + (recursively) are source directories. + + To specify that the source directories are the directory of the + project file and all of its subdirectories, you can declare + `Source_Dirs' as follows: + for Source_Dirs use ("./**"); + + Each of the source directories must exist and be readable. + +  + File: gnat_ug_vxw.info, Node: Source File Names, Prev: Source Directories, Up: Objects and Sources in Project Files + + Source File Names + ----------------- + + In a project that contains source files, their names may be specified + by the attributes `Source_Files' (a string list) or `Source_List_File' + (a string). Source file names never include any directory information. + + If the attribute `Source_Files' is given an explicit value, then each + element of the list is a source file name. + + for Source_Files use ("main.adb"); + for Source_Files use ("main.adb", "pack1.ads", "pack2.adb"); + + If the attribute `Source_Files' is not given an explicit value, but the + attribute `Source_List_File' is given a string value, then the source + file names are contained in the text file whose path name (absolute or + relative to the directory of the project file) is the value of the + attribute `Source_List_File'. + + Each line in the file that is not empty or is not a comment contains + a source file name. A comment line starts with two hyphens. + + for Source_List_File use "source_list.txt"; + + By default, if neither the attribute `Source_Files' nor the attribute + `Source_List_File' is given an explicit value, then each file in the + source directories that conforms to the project's naming scheme (see + *Note Naming Schemes::) is an immediate source of the project. + + A warning is issued if both attributes `Source_Files' and + `Source_List_File' are given explicit values. In this case, the + attribute `Source_Files' prevails. + + Each source file name must be the name of one and only one existing + source file in one of the source directories. + + A `Source_Files' attribute defined with an empty list as its value + indicates that there are no source files in the project. + + Except for projects that are clearly specified as containing no Ada + source files (`Source_Dirs' or `Source_Files' specified as an empty + list, or `Languages' specified without `"Ada"' in the list) + for Source_Dirs use (); + for Source_Files use (); + for Languages use ("C", "C++"); + + a project must contain at least one immediate source. + + Projects with no source files are useful as template packages (see + *Note Packages in Project Files::) for other projects; in particular to + define a package `Naming' (see *Note Naming Schemes::). + +  + File: gnat_ug_vxw.info, Node: Importing Projects, Next: Project Extension, Prev: Objects and Sources in Project Files, Up: GNAT Project Manager + + Importing Projects + ================== + + An immediate source of a project P may depend on source files that are + neither immediate sources of P nor in the predefined library. To get + this effect, P must _import_ the projects that contain the needed + source files. + + with "project1", "utilities.gpr"; + with "/namings/apex.gpr"; + project Main is + ... + + As can be seen in this example, the syntax for importing projects is + similar to the syntax for importing compilation units in Ada. However, + project files use literal strings instead of names, and the `with' + clause identifies project files rather than packages. + + Each literal string is the file name or path name (absolute or + relative) of a project file. If a string is simply a file name, with no + path, then its location is determined by the _project path_: + + * If the environment variable `ADA_PROJECT_PATH' exists, then the + project path includes all the directories in this environment + variable, plus the directory of the project file. + + * If the environment variable `ADA_PROJECT_PATH' does not exist, + then the project path contains only one directory, namely the one + where the project file is located. + + If a relative pathname is used as in + + with "tests/proj"; + + then the path is relative to the directory where the importing project + file is located. Any symbolic link will be fully resolved in the + directory of the importing project file before the imported project + file is looked up. + + When the `with''ed project file name does not have an extension, the + default is `.gpr'. If a file with this extension is not found, then the + file name as specified in the `with' clause (no extension) will be + used. In the above example, if a file `project1.gpr' is found, then it + will be used; otherwise, if a file `project1' exists then it will be + used; if neither file exists, this is an error. + + A warning is issued if the name of the project file does not match + the name of the project; this check is case insensitive. + + Any source file that is an immediate source of the imported project + can be used by the immediate sources of the importing project, and + recursively. Thus if `A' imports `B', and `B' imports `C', the immediate + sources of `A' may depend on the immediate sources of `C', even if `A' + does not import `C' explicitly. However, this is not recommended, + because if and when `B' ceases to import `C', some sources in `A' will + no longer compile. + + A side effect of this capability is that cyclic dependences are not + permitted: if `A' imports `B' (directly or indirectly) then `B' is not + allowed to import `A'. + +  + File: gnat_ug_vxw.info, Node: Project Extension, Next: External References in Project Files, Prev: Importing Projects, Up: GNAT Project Manager + + Project Extension + ================= + + During development of a large system, it is sometimes necessary to use + modified versions of some of the source files without changing the + original sources. This can be achieved through a facility known as + _project extension_. + + project Modified_Utilities extends "/baseline/utilities.gpr" is ... + + The project file for the project being extended (the _parent_) is + identified by the literal string that follows the reserved word + `extends', which itself follows the name of the extending project (the + _child_). + + By default, a child project inherits all the sources of its parent. + However, inherited sources can be overridden: a unit with the same name + as one in the parent will hide the original unit. Inherited sources + are considered to be sources (but not immediate sources) of the child + project; see *Note Project File Syntax::. + + An inherited source file retains any switches specified in the + parent project. + + For example if the project `Utilities' contains the specification + and the body of an Ada package `Util_IO', then the project + `Modified_Utilities' can contain a new body for package `Util_IO'. The + original body of `Util_IO' will not be considered in program builds. + However, the package specification will still be found in the project + `Utilities'. + + A child project can have only one parent but it may import any + number of other projects. + + A project is not allowed to import directly or indirectly at the + same time a child project and any of its ancestors. + +  + File: gnat_ug_vxw.info, Node: External References in Project Files, Next: Packages in Project Files, Prev: Project Extension, Up: GNAT Project Manager + + External References in Project Files + ==================================== + + A project file may contain references to external variables; such + references are called _external references_. + + An external variable is either defined as part of the environment (an + environment variable in Unix, for example) or else specified on the + command line via the `-X_vbl_=_value_' switch. If both, then the + command line value is used. + + An external reference is denoted by the built-in function + `external', which returns a string value. This function has two forms: + * `external (external_variable_name)' + + * `external (external_variable_name, default_value)' + + Each parameter must be a string literal. For example: + + external ("USER") + external ("OS", "Linux") + + In the form with one parameter, the function returns the value of the + external variable given as parameter. If this name is not present in the + environment, then the returned value is an empty string. + + In the form with two string parameters, the second parameter is the + value returned when the variable given as the first parameter is not + present in the environment. In the example above, if `"OS"' is not the + name of an environment variable and is not passed on the command line, + then the returned value will be `"Linux"'. + + An external reference may be part of a string expression or of a + string list expression, to define variables or attributes. + + type Mode_Type is ("Debug", "Release"); + Mode : Mode_Type := external ("MODE"); + case Mode is + when "Debug" => + ... + +  + File: gnat_ug_vxw.info, Node: Packages in Project Files, Next: Variables from Imported Projects, Prev: External References in Project Files, Up: GNAT Project Manager + + Packages in Project Files + ========================= + + The _package_ is the project file feature that defines the settings for + project-aware tools. For each such tool you can declare a + corresponding package; the names for these packages are preset (see + *Note Packages::) but are not case sensitive. A package may contain + variable declarations, attribute declarations, and case constructions. + + project Proj is + package Builder is -- used by gnatmake + for Default_Switches ("Ada") use ("-v", "-g"); + end Builder; + end Proj; + + A package declaration starts with the reserved word `package', followed + by the package name (case insensitive), followed by the reserved word + `is'. It ends with the reserved word `end', followed by the package + name, finally followed by a semi-colon. + + Most of the packages have an attribute `Default_Switches'. This + attribute is an associative array, and its value is a string list. The + index of the associative array is the name of a programming language + (case insensitive). This attribute indicates the switch or switches to + be used with the corresponding tool. + + Some packages also have another attribute, `Switches', an associative + array whose value is a string list. The index is the name of a source + file. This attribute indicates the switch or switches to be used by + the corresponding tool when dealing with this specific file. + + Further information on these switch-related attributes is found in + *Note Switches and Project Files::. + + A package may be declared as a _renaming_ of another package; e.g., + from the project file for an imported project. + + with "/global/apex.gpr"; + project Example is + package Naming renames Apex.Naming; + ... + end Example; + + Packages that are renamed in other project files often come from + project files that have no sources: they are just used as templates. + Any modification in the template will be reflected automatically in all + the project files that rename a package from the template. + + In addition to the tool-oriented packages, you can also declare a + package named `Naming' to establish specialized source file naming + conventions (see *Note Naming Schemes::). + +  + File: gnat_ug_vxw.info, Node: Variables from Imported Projects, Next: Naming Schemes, Prev: Packages in Project Files, Up: GNAT Project Manager + + Variables from Imported Projects + ================================ + + An attribute or variable defined in an imported or parent project can + be used in expressions in the importing / extending project. Such an + attribute or variable is prefixed with the name of the project and (if + relevant) the name of package where it is defined. + + with "imported"; + project Main extends "base" is + Var1 := Imported.Var; + Var2 := Base.Var & ".new"; + + package Builder is + for Default_Switches ("Ada") use Imported.Builder.Ada_Switches & + "-gnatg" & "-v"; + end Builder; + + package Compiler is + for Default_Switches ("Ada") use Base.Compiler.Ada_Switches; + end Compiler; + end Main; + + In this example: + + * `Var1' is a copy of the variable `Var' defined in the project file + `"imported.gpr"' + + * the value of `Var2' is a copy of the value of variable `Var' + defined in the project file `base.gpr', concatenated with `".new"' + + * attribute `Default_Switches ("Ada")' in package `Builder' is a + string list that includes in its value a copy of variable + `Ada_Switches' defined in the `Builder' package in project file + `imported.gpr' plus two new elements: `"-gnatg"' and `"-v"'; + + * attribute `Default_Switches ("Ada")' in package `Compiler' is a + copy of the variable `Ada_Switches' defined in the `Compiler' + package in project file `base.gpr', the project being extended. + +  + File: gnat_ug_vxw.info, Node: Naming Schemes, Next: Library Projects, Prev: Variables from Imported Projects, Up: GNAT Project Manager + + Naming Schemes + ============== + + Sometimes an Ada software system is ported from a foreign compilation + environment to GNAT, with file names that do not use the default GNAT + conventions. Instead of changing all the file names (which for a + variety of reasons might not be possible), you can define the relevant + file naming scheme in the `Naming' package in your project file. For + example, the following package models the Apex file naming rules: + + package Naming is + for Casing use "lowercase"; + for Dot_Replacement use "."; + for Specification_Suffix ("Ada") use ".1.ada"; + for Implementation_Suffix ("Ada") use ".2.ada"; + end Naming; + + You can define the following attributes in package `Naming': + + `CASING' + This must be a string with one of the three values `"lowercase"', + `"uppercase"' or `"mixedcase"'; these strings are case insensitive. + + If CASING is not specified, then the default is `"lowercase"'. + + `DOT_REPLACEMENT' + This must be a string whose value satisfies the following + conditions: + + * It must not be empty + + * It cannot start or end with an alphanumeric character + + * It cannot be a single underscore + + * It cannot start with an underscore followed by an alphanumeric + + * It cannot contain a dot `'.'' except if it the entire string + is `"."' + + If `Dot_Replacement' is not specified, then the default is `"-"'. + + `SPECIFICATION_SUFFIX' + This is an associative array (indexed by the programming language + name, case insensitive) whose value is a string that must satisfy + the following conditions: + + * It must not be empty + + * It cannot start with an alphanumeric character + + * It cannot start with an underscore followed by an + alphanumeric character + + If `Specification_Suffix ("Ada")' is not specified, then the + default is `".ads"'. + + `IMPLEMENTATION_SUFFIX' + This is an associative array (indexed by the programming language + name, case insensitive) whose value is a string that must satisfy + the following conditions: + + * It must not be empty + + * It cannot start with an alphanumeric character + + * It cannot start with an underscore followed by an + alphanumeric character + + * It cannot be a suffix of `Specification_Suffix' + + If `Implementation_Suffix ("Ada")' is not specified, then the + default is `".adb"'. + + `SEPARATE_SUFFIX' + This must be a string whose value satisfies the same conditions as + `Implementation_Suffix'. + + If `Separate_Suffix ("Ada")' is not specified, then it defaults to + same value as `Implementation_Suffix ("Ada")'. + + `SPECIFICATION' + You can use the `Specification' attribute, an associative array, + to define the source file name for an individual Ada compilation + unit's spec. The array index must be a string literal that + identifies the Ada unit (case insensitive). The value of this + attribute must be a string that identifies the file that contains + this unit's spec (case sensitive or insensitive depending on the + operating system). + + for Specification ("MyPack.MyChild") use "mypack.mychild.spec"; + + `IMPLEMENTATION' + You can use the `Implementation' attribute, an associative array, + to define the source file name for an individual Ada compilation + unit's body (possibly a subunit). The array index must be a + string literal that identifies the Ada unit (case insensitive). + The value of this attribute must be a string that identifies the + file that contains this unit's body or subunit (case sensitive or + insensitive depending on the operating system). + + for Implementation ("MyPack.MyChild") use "mypack.mychild.body"; + +  + File: gnat_ug_vxw.info, Node: Library Projects, Next: Switches Related to Project Files, Prev: Naming Schemes, Up: GNAT Project Manager + + Library Projects + ================ + + _Library projects_ are projects whose object code is placed in a + library. (Note that this facility is not yet supported on all + platforms) + + To create a library project, you need to define in its project file + two project-level attributes: `Library_Name' and `Library_Dir'. + Additionally, you may define the library-related attributes + `Library_Kind', `Library_Version' and `Library_Elaboration'. + + The `Library_Name' attribute has a string value that must start with + a letter and include only letters and digits. + + The `Library_Dir' attribute has a string value that designates the + path (absolute or relative) of the directory where the library will + reside. It must designate an existing directory, and this directory + needs to be different from the project's object directory. It also + needs to be writable. + + If both `Library_Name' and `Library_Dir' are specified and are + legal, then the project file defines a library project. The optional + library-related attributes are checked only for such project files. + + The `Library_Kind' attribute has a string value that must be one of + the following (case insensitive): `"static"', `"dynamic"' or + `"relocatable"'. If this attribute is not specified, the library is a + static library. Otherwise, the library may be dynamic or relocatable. + Depending on the operating system, there may or may not be a distinction + between dynamic and relocatable libraries. For example, on Unix there + is no such distinction. + + The `Library_Version' attribute has a string value whose + interpretation is platform dependent. On Unix, it is used only for + dynamic/relocatable libraries as the internal name of the library (the + `"soname"'). If the library file name (built from the `Library_Name') + is different from the `Library_Version', then the library file will be + a symbolic link to the actual file whose name will be `Library_Version'. + + Example (on Unix): + + project Plib is + + Version := "1"; + + for Library_Dir use "lib_dir"; + for Library_Name use "dummy"; + for Library_Kind use "relocatable"; + for Library_Version use "libdummy.so." & Version; + + end Plib; + + Directory `lib_dir' will contain the internal library file whose name + will be `libdummy.so.1', and `libdummy.so' will be a symbolic link to + `libdummy.so.1'. + + When `gnatmake' detects that a project file (not the main project + file) is a library project file, it will check all immediate sources of + the project and rebuild the library if any of the sources have been + recompiled. All `ALI' files will also be copied from the object + directory to the library directory. To build executables, `gnatmake' + will use the library rather than the individual object files. + +  + File: gnat_ug_vxw.info, Node: Switches Related to Project Files, Next: Tools Supporting Project Files, Prev: Library Projects, Up: GNAT Project Manager + + Switches Related to Project Files + ================================= + + The following switches are used by GNAT tools that support project + files: + + ``-PPROJECT'' + Indicates the name of a project file. This project file will be + parsed with the verbosity indicated by `-vP_x_', if any, and using + the external references indicated by `-X' switches, if any. + + There must be only one `-P' switch on the command line. + + Since the Project Manager parses the project file only after all + the switches on the command line are checked, the order of the + switches `-P', `-Vp_x_' or `-X' is not significant. + + ``-XNAME=VALUE'' + Indicates that external variable NAME has the value VALUE. The + Project Manager will use this value for occurrences of + `external(name)' when parsing the project file. + + If NAME or VALUE includes a space, then NAME=VALUE should be put + between quotes. + -XOS=NT + -X"user=John Doe" + + Several `-X' switches can be used simultaneously. If several `-X' + switches specify the same NAME, only the last one is used. + + An external variable specified with a `-X' switch takes precedence + over the value of the same name in the environment. + + ``-vP_x_'' + Indicates the verbosity of the parsing of GNAT project files. + `-vP0' means Default (no output for syntactically correct project + files); `-vP1' means Medium; `-vP2' means High. + + The default is Default. + + If several `-vP_x_' switches are present, only the last one is + used. + +  + File: gnat_ug_vxw.info, Node: Tools Supporting Project Files, Next: An Extended Example, Prev: Switches Related to Project Files, Up: GNAT Project Manager + + Tools Supporting Project Files + ============================== + + * Menu: + + * gnatmake and Project Files:: + * The GNAT Driver and Project Files:: + * Glide and Project Files:: + +  + File: gnat_ug_vxw.info, Node: gnatmake and Project Files, Next: The GNAT Driver and Project Files, Up: Tools Supporting Project Files + + gnatmake and Project Files + -------------------------- + + This section covers two topics related to `gnatmake' and project files: + defining switches for `gnatmake' and for the tools that it invokes; and + the use of the `Main' attribute. + + * Menu: + + * Switches and Project Files:: + * Project Files and Main Subprograms:: + +  + File: gnat_ug_vxw.info, Node: Switches and Project Files, Next: Project Files and Main Subprograms, Up: gnatmake and Project Files + + Switches and Project Files + .......................... + + For each of the packages `Builder', `Compiler', `Binder', and `Linker', + you can specify a `Default_Switches' attribute, a `Switches' attribute, + or both; as their names imply, these switch-related attributes affect + which switches are used for which files when `gnatmake' is invoked. As + will be explained below, these package-contributed switches precede the + switches passed on the `gnatmake' command line. + + The `Default_Switches' attribute is an associative array indexed by + language name (case insensitive) and returning a string list. For + example: + + package Compiler is + for Default_Switches ("Ada") use ("-gnaty", "-v"); + end Compiler; + + The `Switches' attribute is also an associative array, indexed by a file + name (which may or may not be case sensitive, depending on the operating + system) and returning a string list. For example: + + package Builder is + for Switches ("main1.adb") use ("-O2"); + for Switches ("main2.adb") use ("-g"); + end Builder; + + For the `Builder' package, the file names should designate source files + for main subprograms. For the `Binder' and `Linker' packages, the file + names should designate `ALI' or source files for main subprograms. In + each case just the file name (without explicit extension) is acceptable. + + For each tool used in a program build (`gnatmake', the compiler, the + binder, and the linker), its corresponding package "contributes" a set + of switches for each file on which the tool is invoked, based on the + switch-related attributes defined in the package. In particular, the + switches that each of these packages contributes for a given file F + comprise: + + * the value of attribute `Switches (F)', if it is specified in the + package for the given file, + + * otherwise, the value of `Default_Switches ("Ada")', if it is + specified in the package. + + If neither of these attributes is defined in the package, then the + package does not contribute any switches for the given file. + + When `gnatmake' is invoked on a file, the switches comprise two sets, + in the following order: those contributed for the file by the `Builder' + package; and the switches passed on the command line. + + When `gnatmake' invokes a tool (compiler, binder, linker) on a file, + the switches passed to the tool comprise three sets, in the following + order: + + 1. the applicable switches contributed for the file by the `Builder' + package in the project file supplied on the command line; + + 2. those contributed for the file by the package (in the relevant + project file - see below) corresponding to the tool; and + + 3. the applicable switches passed on the command line. + + The term _applicable switches_ reflects the fact that `gnatmake' + switches may or may not be passed to individual tools, depending on the + individual switch. + + `gnatmake' may invoke the compiler on source files from different + projects. The Project Manager will use the appropriate project file to + determine the `Compiler' package for each source file being compiled. + Likewise for the `Binder' and `Linker' packages. + + As an example, consider the following package in a project file: + + project Proj1 is + package Compiler is + for Default_Switches ("Ada") use ("-g"); + for Switches ("a.adb") use ("-O1"); + for Switches ("b.adb") use ("-O2", "-gnaty"); + end Compiler; + end Proj1; + + If `gnatmake' is invoked with this project file, and it needs to + compile, say, the files `a.adb', `b.adb', and `c.adb', then `a.adb' + will be compiled with the switch `-O1', `b.adb' with switches `-O2' and + `-gnaty', and `c.adb' with `-g'. + + Another example illustrates the ordering of the switches contributed + by different packages: + + project Proj2 is + package Builder is + for Switches ("main.adb") use ("-g", "-O1", "-f"); + end Builder; + + package Compiler is + for Switches ("main.adb") use ("-O2"); + end Compiler; + end Proj2; + + If you issue the command: + + gnatmake -PProj2 -O0 main + + then the compiler will be invoked on `main.adb' with the following + sequence of switches + + -g -O1 -O2 -O0 + + with the last `-O' switch having precedence over the earlier ones; + several other switches (such as `-c') are added implicitly. + + The switches `-g' and `-O1' are contributed by package `Builder', + `-O2' is contributed by the package `Compiler' and `-O0' comes from the + command line. + + The `-g' switch will also be passed in the invocation of `gnatlink.' + + A final example illustrates switch contributions from packages in + different project files: + + project Proj3 is + for Source_Files use ("pack.ads", "pack.adb"); + package Compiler is + for Default_Switches ("Ada") use ("-gnata"); + end Compiler; + end Proj3; + + with "Proj3"; + project Proj4 is + for Source_Files use ("foo_main.adb", "bar_main.adb"); + package Builder is + for Switches ("foo_main.adb") use ("-s", "-g"); + end Builder; + end Proj4; + + -- Ada source file: + with Pack; + procedure Foo_Main is + ... + end Foo_Main; + + If the command is + gnatmake -PProj4 foo_main.adb -cargs -gnato + + then the switches passed to the compiler for `foo_main.adb' are `-g' + (contributed by the package `Proj4.Builder') and `-gnato' (passed on + the command line). When the imported package `Pack' is compiled, the + switches used are `-g' from `Proj4.Builder', `-gnata' (contributed from + package `Proj3.Compiler', and `-gnato' from the command line. + +  + File: gnat_ug_vxw.info, Node: Project Files and Main Subprograms, Prev: Switches and Project Files, Up: gnatmake and Project Files + + Project Files and Main Subprograms + .................................. + + When using a project file, you can invoke `gnatmake' with several main + subprograms, by specifying their source files on the command line. + Each of these needs to be an immediate source file of the project. + + gnatmake -Pprj main1 main2 main3 + + When using a project file, you can also invoke `gnatmake' without + explicitly specifying any main, and the effect depends on whether you + have defined the `Main' attribute. This attribute has a string list + value, where each element in the list is the name of a source file (the + file extension is optional) containing a main subprogram. + + If the `Main' attribute is defined in a project file as a non-empty + string list and the switch `-u' is not used on the command line, then + invoking `gnatmake' with this project file but without any main on the + command line is equivalent to invoking `gnatmake' with all the file + names in the `Main' attribute on the command line. + + Example: + project Prj is + for Main use ("main1", "main2", "main3"); + end Prj; + + With this project file, `"gnatmake -Pprj"' is equivalent to `"gnatmake + -Pprj main1 main2 main3"'. + + When the project attribute `Main' is not specified, or is specified + as an empty string list, or when the switch `-u' is used on the command + line, then invoking `gnatmake' with no main on the command line will + result in all immediate sources of the project file being checked, and + potentially recompiled. Depending on the presence of the switch `-u', + sources from other project files on which the immediate sources of the + main project file depend are also checked and potentially recompiled. + In other words, the `-u' switch is applied to all of the immediate + sources of themain project file. + +  + File: gnat_ug_vxw.info, Node: The GNAT Driver and Project Files, Next: Glide and Project Files, Prev: gnatmake and Project Files, Up: Tools Supporting Project Files + + The GNAT Driver and Project Files + --------------------------------- + + A number of GNAT tools, other than `gnatmake' are project-aware: + `gnatbind', `gnatfind', `gnatlink', `gnatls' and `gnatxref'. However, + none of these tools can be invoked directly with a project file switch + (`-P'). They need to be invoke through the `gnat' driver. + + The `gnat' driver is a front-end that accepts a number of commands + and call the corresponding tool. It has been designed initially for VMS + to convert VMS style qualifiers to Unix style switches, but it is now + available to all the GNAT supported platforms. + + On non VMS platforms, the `gnat' driver accepts the following + commands (case insensitive): + + * BIND to invoke `gnatbind' + + * CHOP to invoke `gnatchop' + + * COMP or COMPILE to invoke the compiler + + * ELIM to invoke `gnatelim' + + * FIND to invoke `gnatfind' + + * KR or KRUNCH to invoke `gnatkr' + + * LINK to invoke `gnatlink' + + * LS or LIST to invoke `gnatls' + + * MAKE to invoke `gnatmake' + + * NAME to invoke `gnatname' + + * PREP or PREPROCESS to invoke `gnatprep' + + * PSTA or STANDARD to invoke `gnatpsta' + + * STUB to invoke `gnatstub' + + * XREF to invoke `gnatxref' + + Note that the compiler is invoked using the command `gnatmake -f -u'. + + Following the command, you may put switches and arguments for the + invoked tool. + + gnat bind -C main.ali + gnat ls -a main + gnat chop foo.txt + + In addition, for command BIND, FIND, LS or LIST, LINK and XREF, the + project file related switches (`-P', `-X' and `-vPx') may be used in + addition to the switches of the invoking tool. + + For each of these command, there is possibly a package in the main + project that corresponds to the invoked tool. + + * package `Binder' for command BIND (invoking `gnatbind') + + * package `Finder' for command FIND (invoking `gnatfind') + + * package `Gnatls' for command LS or LIST (invoking `gnatls') + + * package `Linker' for command LINK (invoking `gnatlink') + + * package `Cross_Reference' for command XREF (invoking `gnatlink') + + + Package `Gnatls' has a unique attribute `Switches', a simple variable + with a string list value. It contains switches for the invocation of + `gnatls'. + + project Proj1 is + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + end Proj1; + + All other packages contains a switch `Default_Switches', an associative + array, indexed by the programming language (case insensitive) and + having a string list value. `Default_Switches ("Ada")' contains the + switches for the invocation of the tool corresponding to the package. + + project Proj is + + for Source_Dirs use ("./**"); + + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + + package Binder is + for Default_Switches ("Ada") use ("-C", "-e"); + end Binder; + + package Linker is + for Default_Switches ("Ada") use ("-C"); + end Linker; + + package Finder is + for Default_Switches ("Ada") use ("-a", "-f"); + end Finder; + + package Cross_Reference is + for Default_Switches ("Ada") use ("-a", "-f", "-d", "-u"); + end Cross_Reference; + end Proj; + + With the above project file, commands such as + + gnat ls -Pproj main + gnat xref -Pproj main + gnat bind -Pproj main.ali + + will set up the environment properly and invoke the tool with the + switches found in the package corresponding to the tool. + +  + File: gnat_ug_vxw.info, Node: Glide and Project Files, Prev: The GNAT Driver and Project Files, Up: Tools Supporting Project Files + + Glide and Project Files + ----------------------- + + Glide will automatically recognize the `.gpr' extension for project + files, and will convert them to its own internal format automatically. + However, it doesn't provide a syntax-oriented editor for modifying these + files. The project file will be loaded as text when you select the + menu item `Ada' => `Project' => `Edit'. You can edit this text and + save the `gpr' file; when you next select this project file in Glide it + will be automatically reloaded. + + Glide uses the `gnatlist' attribute in the `Ide' package, whose value + is something like `powerpc-wrs-vxworks-gnatls', to compute the + cross-prefix. From this information the correct location for the GNAT + runtime, and thus also the correct cross-references, can be determined. + +  + File: gnat_ug_vxw.info, Node: An Extended Example, Next: Project File Complete Syntax, Prev: Tools Supporting Project Files, Up: GNAT Project Manager + + An Extended Example + =================== + + Suppose that we have two programs, PROG1 and PROG2, with the sources in + the respective directories. We would like to build them with a single + `gnatmake' command, and we would like to place their object files into + `.build' subdirectories of the source directories. Furthermore, we would + like to have to have two separate subdirectories in `.build' - + `release' and `debug' - which will contain the object files compiled + with different set of compilation flags. + + In other words, we have the following structure: + + main + |- prog1 + | |- .build + | | debug + | | release + |- prog2 + |- .build + | debug + | release + + Here are the project files that we need to create in a directory `main' + to maintain this structure: + + 1. We create a `Common' project with a package `Compiler' that + specifies the compilation switches: + + File "common.gpr": + project Common is + + for Source_Dirs use (); -- No source files + + type Build_Type is ("release", "debug"); + Build : Build_Type := External ("BUILD", "debug"); + package Compiler is + case Build is + when "release" => + for Default_Switches ("Ada") use ("-O2"); + when "debug" => + for Default_Switches ("Ada") use ("-g"); + end case; + end Compiler; + + end Common; + + 2. We create separate projects for the two programs: + + File "prog1.gpr": + + with "common"; + project Prog1 is + + for Source_Dirs use ("prog1"); + for Object_Dir use "prog1/.build/" & Common.Build; + + package Compiler renames Common.Compiler; + + end Prog1; + + File "prog2.gpr": + + with "common"; + project Prog2 is + + for Source_Dirs use ("prog2"); + for Object_Dir use "prog2/.build/" & Common.Build; + + package Compiler renames Common.Compiler; + end Prog2; + + 3. We create a wrapping project MAIN: + + File "main.gpr": + + with "common"; + with "prog1"; + with "prog2"; + project Main is + + package Compiler renames Common.Compiler; + + end Main; + + 4. Finally we need to create a dummy procedure that `with's (either + explicitly or implicitly) all the sources of our two programs. + + + Now we can build the programs using the command + + gnatmake -Pmain dummy + + for the Debug mode, or + + gnatmake -Pmain -XBUILD=release + + for the Release mode. + +  + File: gnat_ug_vxw.info, Node: Project File Complete Syntax, Prev: An Extended Example, Up: GNAT Project Manager + + Project File Complete Syntax + ============================ + + project ::= + context_clause project_declaration + + context_clause ::= + {with_clause} + + with_clause ::= + with literal_string { , literal_string } ; + + project_declaration ::= + project simple_name [ extends literal_string ] is + {declarative_item} + end simple_name; + + declarative_item ::= + package_declaration | + typed_string_declaration | + other_declarative_item + + package_declaration ::= + package simple_name package_completion + + package_completion ::= + package_body | package_renaming + + package body ::= + is + {other_declarative_item} + end simple_name ; + + package_renaming ::== + renames simple_name.simple_name ; + + typed_string_declaration ::= + type _simple_name is + ( literal_string {, literal_string} ); + + other_declarative_item ::= + attribute_declaration | + typed_variable_declaration | + variable_declaration | + case_construction + + attribute_declaration ::= + for attribute use expression ; + + attribute ::= + simple_name | + simple_name ( literal_string ) + + typed_variable_declaration ::= + simple_name : name := string_expression ; + + variable_declaration ::= + simple_name := expression; + + expression ::= + term {& term} + + term ::= + literal_string | + string_list | + name | + external_value | + attribute_reference + + literal_string ::= + (same as Ada) + + string_list ::= + ( expression { , expression } ) + + external_value ::= + external ( literal_string [, literal_string] ) + + attribute_reference ::= + attribute_parent ' simple_name [ ( literal_string ) ] + + attribute_parent ::= + project | + simple_name | + simple_name . simple_name + + case_construction ::= + case name is + {case_item} + end case ; + + case_item ::= + when discrete_choice_list => {case_construction | attribute_declaration} + + discrete_choice_list ::= + literal_string {| literal_string} + + name ::= + simple_name {. simple_name} + + simple_name ::= + identifier (same as Ada) + +  + File: gnat_ug_vxw.info, Node: Elaboration Order Handling in GNAT, Next: The Cross-Referencing Tools gnatxref and gnatfind, Prev: GNAT Project Manager, Up: Top + + Elaboration Order Handling in GNAT + ********************************** + + * Menu: + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + This chapter describes the handling of elaboration code in Ada 95 and + in GNAT, and discusses how the order of elaboration of program units can + be controlled in GNAT, either automatically or with explicit programming + features. + +  + File: gnat_ug_vxw.info, Node: Elaboration Code in Ada 95, Next: Checking the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Elaboration Code in Ada 95 + ========================== + + Ada 95 provides rather general mechanisms for executing code at + elaboration time, that is to say before the main program starts + executing. Such code arises in three contexts: + + Initializers for variables. + Variables declared at the library level, in package specs or + bodies, can require initialization that is performed at + elaboration time, as in: + Sqrt_Half : Float := Sqrt (0.5); + + Package initialization code + Code in a `BEGIN-END' section at the outer level of a package body + is executed as part of the package body elaboration code. + + Library level task allocators + Tasks that are declared using task allocators at the library level + start executing immediately and hence can execute at elaboration + time. + + Subprogram calls are possible in any of these contexts, which means that + any arbitrary part of the program may be executed as part of the + elaboration code. It is even possible to write a program which does all + its work at elaboration time, with a null main program, although + stylistically this would usually be considered an inappropriate way to + structure a program. + + An important concern arises in the context of elaboration code: we + have to be sure that it is executed in an appropriate order. What we + have is a series of elaboration code sections, potentially one section + for each unit in the program. It is important that these execute in the + correct order. Correctness here means that, taking the above example of + the declaration of `Sqrt_Half', if some other piece of elaboration code + references `Sqrt_Half', then it must run after the section of + elaboration code that contains the declaration of `Sqrt_Half'. + + There would never be any order of elaboration problem if we made a + rule that whenever you `with' a unit, you must elaborate both the spec + and body of that unit before elaborating the unit doing the `with''ing: + + with Unit_1; + package Unit_2 is ... + + would require that both the body and spec of `Unit_1' be elaborated + before the spec of `Unit_2'. However, a rule like that would be far too + restrictive. In particular, it would make it impossible to have routines + in separate packages that were mutually recursive. + + You might think that a clever enough compiler could look at the + actual elaboration code and determine an appropriate correct order of + elaboration, but in the general case, this is not possible. Consider + the following example. + + In the body of `Unit_1', we have a procedure `Func_1' that references + the variable `Sqrt_1', which is declared in the elaboration code of the + body of `Unit_1': + + Sqrt_1 : Float := Sqrt (0.1); + + The elaboration code of the body of `Unit_1' also contains: + + if expression_1 = 1 then + Q := Unit_2.Func_2; + end if; + + `Unit_2' is exactly parallel, it has a procedure `Func_2' that + references the variable `Sqrt_2', which is declared in the elaboration + code of the body `Unit_2': + + Sqrt_2 : Float := Sqrt (0.1); + + The elaboration code of the body of `Unit_2' also contains: + + if expression_2 = 2 then + Q := Unit_1.Func_1; + end if; + + Now the question is, which of the following orders of elaboration is + acceptable: + + Spec of Unit_1 + Spec of Unit_2 + Body of Unit_1 + Body of Unit_2 + + or + + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_2 + Body of Unit_1 + + If you carefully analyze the flow here, you will see that you cannot + tell at compile time the answer to this question. If `expression_1' is + not equal to 1, and `expression_2' is not equal to 2, then either order + is acceptable, because neither of the function calls is executed. If + both tests evaluate to true, then neither order is acceptable and in + fact there is no correct order. + + If one of the two expressions is true, and the other is false, then + one of the above orders is correct, and the other is incorrect. For + example, if `expression_1' = 1 and `expression_2' /= 2, then the call + to `Func_2' will occur, but not the call to `Func_1.' This means that + it is essential to elaborate the body of `Unit_1' before the body of + `Unit_2', so the first order of elaboration is correct and the second + is wrong. + + By making `expression_1' and `expression_2' depend on input data, or + perhaps the time of day, we can make it impossible for the compiler or + binder to figure out which of these expressions will be true, and hence + it is impossible to guarantee a safe order of elaboration at run time. + +  + File: gnat_ug_vxw.info, Node: Checking the Elaboration Order in Ada 95, Next: Controlling the Elaboration Order in Ada 95, Prev: Elaboration Code in Ada 95, Up: Elaboration Order Handling in GNAT + + Checking the Elaboration Order in Ada 95 + ======================================== + + In some languages that involve the same kind of elaboration problems, + e.g. Java and C++, the programmer is expected to worry about these + ordering problems himself, and it is common to write a program in which + an incorrect elaboration order gives surprising results, because it + references variables before they are initialized. Ada 95 is designed + to be a safe language, and a programmer-beware approach is clearly not + sufficient. Consequently, the language provides three lines of defense: + + Standard rules + Some standard rules restrict the possible choice of elaboration + order. In particular, if you `with' a unit, then its spec is always + elaborated before the unit doing the `with'. Similarly, a parent + spec is always elaborated before the child spec, and finally a + spec is always elaborated before its corresponding body. + + Dynamic elaboration checks + Dynamic checks are made at run time, so that if some entity is + accessed before it is elaborated (typically by means of a + subprogram call) then the exception (`Program_Error') is raised. + + Elaboration control + Facilities are provided for the programmer to specify the desired + order of elaboration. + + Let's look at these facilities in more detail. First, the rules for + dynamic checking. One possible rule would be simply to say that the + exception is raised if you access a variable which has not yet been + elaborated. The trouble with this approach is that it could require + expensive checks on every variable reference. Instead Ada 95 has two + rules which are a little more restrictive, but easier to check, and + easier to state: + + Restrictions on calls + A subprogram can only be called at elaboration time if its body + has been elaborated. The rules for elaboration given above + guarantee that the spec of the subprogram has been elaborated + before the call, but not the body. If this rule is violated, then + the exception `Program_Error' is raised. + + Restrictions on instantiations + A generic unit can only be instantiated if the body of the generic + unit has been elaborated. Again, the rules for elaboration given + above guarantee that the spec of the generic unit has been + elaborated before the instantiation, but not the body. If this + rule is violated, then the exception `Program_Error' is raised. + + The idea is that if the body has been elaborated, then any variables it + references must have been elaborated; by checking for the body being + elaborated we guarantee that none of its references causes any trouble. + As we noted above, this is a little too restrictive, because a + subprogram that has no non-local references in its body may in fact be + safe to call. However, it really would be unsafe to rely on this, + because it would mean that the caller was aware of details of the + implementation in the body. This goes against the basic tenets of Ada. + + A plausible implementation can be described as follows. A Boolean + variable is associated with each subprogram and each generic unit. This + variable is initialized to False, and is set to True at the point body + is elaborated. Every call or instantiation checks the variable, and + raises `Program_Error' if the variable is False. + + Note that one might think that it would be good enough to have one + Boolean variable for each package, but that would not deal with cases + of trying to call a body in the same package as the call that has not + been elaborated yet. Of course a compiler may be able to do enough + analysis to optimize away some of the Boolean variables as unnecessary, + and `GNAT' indeed does such optimizations, but still the easiest + conceptual model is to think of there being one variable per subprogram. + +  + File: gnat_ug_vxw.info, Node: Controlling the Elaboration Order in Ada 95, Next: Controlling Elaboration in GNAT - Internal Calls, Prev: Checking the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Controlling the Elaboration Order in Ada 95 + =========================================== + + In the previous section we discussed the rules in Ada 95 which ensure + that `Program_Error' is raised if an incorrect elaboration order is + chosen. This prevents erroneous executions, but we need mechanisms to + specify a correct execution and avoid the exception altogether. To + achieve this, Ada 95 provides a number of features for controlling the + order of elaboration. We discuss these features in this section. + + First, there are several ways of indicating to the compiler that a + given unit has no elaboration problems: + + packages that do not require a body + In Ada 95, a library package that does not require a body does not + permit a body. This means that if we have a such a package, as in: + + package Definitions is + generic + type m is new integer; + package Subp is + type a is array (1 .. 10) of m; + type b is array (1 .. 20) of m; + end Subp; + end Definitions; + + A package that `with''s `Definitions' may safely instantiate + `Definitions.Subp' because the compiler can determine that there + definitely is no package body to worry about in this case + + pragma Pure + Places sufficient restrictions on a unit to guarantee that no call + to any subprogram in the unit can result in an elaboration + problem. This means that the compiler does not need to worry about + the point of elaboration of such units, and in particular, does + not need to check any calls to any subprograms in this unit. + + pragma Preelaborate + This pragma places slightly less stringent restrictions on a unit + than does pragma Pure, but these restrictions are still sufficient + to ensure that there are no elaboration problems with any calls to + the unit. + + pragma Elaborate_Body + This pragma requires that the body of a unit be elaborated + immediately after its spec. Suppose a unit `A' has such a pragma, + and unit `B' does a `with' of unit `A'. Recall that the standard + rules require the spec of unit `A' to be elaborated before the + `with''ing unit; given the pragma in `A', we also know that the + body of `A' will be elaborated before `B', so that calls to `A' + are safe and do not need a check. + + Note that, unlike pragma `Pure' and pragma `Preelaborate', the use of + `Elaborate_Body' does not guarantee that the program is free of + elaboration problems, because it may not be possible to satisfy the + requested elaboration order. Let's go back to the example with + `Unit_1' and `Unit_2'. If a programmer marks `Unit_1' as + `Elaborate_Body', and not `Unit_2,' then the order of elaboration will + be: + + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_1 + Body of Unit_2 + + Now that means that the call to `Func_1' in `Unit_2' need not be + checked, it must be safe. But the call to `Func_2' in `Unit_1' may + still fail if `Expression_1' is equal to 1, and the programmer must + still take responsibility for this not being the case. + + If all units carry a pragma `Elaborate_Body', then all problems are + eliminated, except for calls entirely within a body, which are in any + case fully under programmer control. However, using the pragma + everywhere is not always possible. In particular, for our + `Unit_1'/`Unit_2' example, if we marked both of them as having pragma + `Elaborate_Body', then clearly there would be no possible elaboration + order. + + The above pragmas allow a server to guarantee safe use by clients, + and clearly this is the preferable approach. Consequently a good rule in + Ada 95 is to mark units as `Pure' or `Preelaborate' if possible, and if + this is not possible, mark them as `Elaborate_Body' if possible. As we + have seen, there are situations where neither of these three pragmas + can be used. So we also provide methods for clients to control the + order of elaboration of the servers on which they depend: + + pragma Elaborate (unit) + This pragma is placed in the context clause, after a `with' clause, + and it requires that the body of the named unit be elaborated + before the unit in which the pragma occurs. The idea is to use + this pragma if the current unit calls at elaboration time, + directly or indirectly, some subprogram in the named unit. + + pragma Elaborate_All (unit) + This is a stronger version of the Elaborate pragma. Consider the + following example: + + Unit A `with''s unit B and calls B.Func in elab code + Unit B `with''s unit C, and B.Func calls C.Func + + Now if we put a pragma `Elaborate (B)' in unit `A', this ensures + that the body of `B' is elaborated before the call, but not the + body of `C', so the call to `C.Func' could still cause + `Program_Error' to be raised. + + The effect of a pragma `Elaborate_All' is stronger, it requires + not only that the body of the named unit be elaborated before the + unit doing the `with', but also the bodies of all units that the + named unit uses, following `with' links transitively. For example, + if we put a pragma `Elaborate_All (B)' in unit `A', then it + requires not only that the body of `B' be elaborated before `A', + but also the body of `C', because `B' `with''s `C'. + + We are now in a position to give a usage rule in Ada 95 for avoiding + elaboration problems, at least if dynamic dispatching and access to + subprogram values are not used. We will handle these cases separately + later. + + The rule is simple. If a unit has elaboration code that can directly + or indirectly make a call to a subprogram in a `with''ed unit, or + instantiate a generic unit in a `with''ed unit, then if the `with''ed + unit does not have pragma `Pure' or `Preelaborate', then the client + should have a pragma `Elaborate_All' for the `with''ed unit. By + following this rule a client is assured that calls can be made without + risk of an exception. If this rule is not followed, then a program may + be in one of four states: + + No order exists + No order of elaboration exists which follows the rules, taking into + account any `Elaborate', `Elaborate_All', or `Elaborate_Body' + pragmas. In this case, an Ada 95 compiler must diagnose the + situation at bind time, and refuse to build an executable program. + + One or more orders exist, all incorrect + One or more acceptable elaboration orders exists, and all of them + generate an elaboration order problem. In this case, the binder + can build an executable program, but `Program_Error' will be raised + when the program is run. + + Several orders exist, some right, some incorrect + One or more acceptable elaboration orders exists, and some of them + work, and some do not. The programmer has not controlled the order + of elaboration, so the binder may or may not pick one of the + correct orders, and the program may or may not raise an exception + when it is run. This is the worst case, because it means that the + program may fail when moved to another compiler, or even another + version of the same compiler. + + One or more orders exists, all correct + One ore more acceptable elaboration orders exist, and all of them + work. In this case the program runs successfully. This state of + affairs can be guaranteed by following the rule we gave above, but + may be true even if the rule is not followed. + + Note that one additional advantage of following our Elaborate_All rule + is that the program continues to stay in the ideal (all orders OK) state + even if maintenance changes some bodies of some subprograms. + Conversely, if a program that does not follow this rule happens to be + safe at some point, this state of affairs may deteriorate silently as a + result of maintenance changes. + + You may have noticed that the above discussion did not mention the + use of `Elaborate_Body'. This was a deliberate omission. If you `with' + an `Elaborate_Body' unit, it still may be the case that code in the + body makes calls to some other unit, so it is still necessary to use + `Elaborate_All' on such units. + +  + File: gnat_ug_vxw.info, Node: Controlling Elaboration in GNAT - Internal Calls, Next: Controlling Elaboration in GNAT - External Calls, Prev: Controlling the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Controlling Elaboration in GNAT - Internal Calls + ================================================ + + In the case of internal calls, i.e. calls within a single package, the + programmer has full control over the order of elaboration, and it is up + to the programmer to elaborate declarations in an appropriate order. For + example writing: + + function One return Float; + + Q : Float := One; + + function One return Float is + begin + return 1.0; + end One; + + will obviously raise `Program_Error' at run time, because function One + will be called before its body is elaborated. In this case GNAT will + generate a warning that the call will raise `Program_Error': + + 1. procedure y is + 2. function One return Float; + 3. + 4. Q : Float := One; + | + >>> warning: cannot call "One" before body is elaborated + >>> warning: Program_Error will be raised at run time + + 5. + 6. function One return Float is + 7. begin + 8. return 1.0; + 9. end One; + 10. + 11. begin + 12. null; + 13. end; + + Note that in this particular case, it is likely that the call is safe, + because the function `One' does not access any global variables. + Nevertheless in Ada 95, we do not want the validity of the check to + depend on the contents of the body (think about the separate + compilation case), so this is still wrong, as we discussed in the + previous sections. + + The error is easily corrected by rearranging the declarations so + that the body of One appears before the declaration containing the call + (note that in Ada 95, declarations can appear in any order, so there is + no restriction that would prevent this reordering, and if we write: + + function One return Float; + + function One return Float is + begin + return 1.0; + end One; + + Q : Float := One; + + then all is well, no warning is generated, and no `Program_Error' + exception will be raised. Things are more complicated when a chain of + subprograms is executed: + + function A return Integer; + function B return Integer; + function C return Integer; + + function B return Integer is begin return A; end; + function C return Integer is begin return B; end; + + X : Integer := C; + + function A return Integer is begin return 1; end; + + Now the call to `C' at elaboration time in the declaration of `X' is + correct, because the body of `C' is already elaborated, and the call to + `B' within the body of `C' is correct, but the call to `A' within the + body of `B' is incorrect, because the body of `A' has not been + elaborated, so `Program_Error' will be raised on the call to `A'. In + this case GNAT will generate a warning that `Program_Error' may be + raised at the point of the call. Let's look at the warning: + + 1. procedure x is + 2. function A return Integer; + 3. function B return Integer; + 4. function C return Integer; + 5. + 6. function B return Integer is begin return A; end; + | + >>> warning: call to "A" before body is elaborated may + raise Program_Error + >>> warning: "B" called at line 7 + >>> warning: "C" called at line 9 + + 7. function C return Integer is begin return B; end; + 8. + 9. X : Integer := C; + 10. + 11. function A return Integer is begin return 1; end; + 12. + 13. begin + 14. null; + 15. end; + + Note that the message here says "may raise", instead of the direct case, + where the message says "will be raised". That's because whether `A' is + actually called depends in general on run-time flow of control. For + example, if the body of `B' said + + function B return Integer is + begin + if some-condition-depending-on-input-data then + return A; + else + return 1; + end if; + end B; + + then we could not know until run time whether the incorrect call to A + would actually occur, so `Program_Error' might or might not be raised. + It is possible for a compiler to do a better job of analyzing bodies, to + determine whether or not `Program_Error' might be raised, but it + certainly couldn't do a perfect job (that would require solving the + halting problem and is provably impossible), and because this is a + warning anyway, it does not seem worth the effort to do the analysis. + Cases in which it would be relevant are rare. + + In practice, warnings of either of the forms given above will + usually correspond to real errors, and should be examined carefully and + eliminated. In the rare case where a warning is bogus, it can be + suppressed by any of the following methods: + + * Compile with the `-gnatws' switch set + + * Suppress `Elaboration_Checks' for the called subprogram + + * Use pragma `Warnings_Off' to turn warnings off for the call + + For the internal elaboration check case, GNAT by default generates the + necessary run-time checks to ensure that `Program_Error' is raised if + any call fails an elaboration check. Of course this can only happen if a + warning has been issued as described above. The use of pragma `Suppress + (Elaboration_Checks)' may (but is not guaranteed to) suppress some of + these checks, meaning that it may be possible (but is not guaranteed) + for a program to be able to call a subprogram whose body is not yet + elaborated, without raising a `Program_Error' exception. + +  + File: gnat_ug_vxw.info, Node: Controlling Elaboration in GNAT - External Calls, Next: Default Behavior in GNAT - Ensuring Safety, Prev: Controlling Elaboration in GNAT - Internal Calls, Up: Elaboration Order Handling in GNAT + + Controlling Elaboration in GNAT - External Calls + ================================================ + + The previous section discussed the case in which the execution of a + particular thread of elaboration code occurred entirely within a single + unit. This is the easy case to handle, because a programmer has direct + and total control over the order of elaboration, and furthermore, + checks need only be generated in cases which are rare and which the + compiler can easily detect. The situation is more complex when + separate compilation is taken into account. Consider the following: + + package Math is + function Sqrt (Arg : Float) return Float; + end Math; + + package body Math is + function Sqrt (Arg : Float) return Float is + begin + ... + end Sqrt; + end Math; + + with Math; + package Stuff is + X : Float := Math.Sqrt (0.5); + end Stuff; + + with Stuff; + procedure Main is + begin + ... + end Main; + + where `Main' is the main program. When this program is executed, the + elaboration code must first be executed, and one of the jobs of the + binder is to determine the order in which the units of a program are to + be elaborated. In this case we have four units: the spec and body of + `Math', the spec of `Stuff' and the body of `Main'). In what order + should the four separate sections of elaboration code be executed? + + There are some restrictions in the order of elaboration that the + binder can choose. In particular, if unit U has a `with' for a package + `X', then you are assured that the spec of `X' is elaborated before U , + but you are not assured that the body of `X' is elaborated before U. + This means that in the above case, the binder is allowed to choose the + order: + + spec of Math + spec of Stuff + body of Math + body of Main + + but that's not good, because now the call to `Math.Sqrt' that happens + during the elaboration of the `Stuff' spec happens before the body of + `Math.Sqrt' is elaborated, and hence causes `Program_Error' exception + to be raised. At first glance, one might say that the binder is + misbehaving, because obviously you want to elaborate the body of + something you `with' first, but that is not a general rule that can be + followed in all cases. Consider + + package X is ... + + package Y is ... + + with X; + package body Y is ... + + with Y; + package body X is ... + + This is a common arrangement, and, apart from the order of elaboration + problems that might arise in connection with elaboration code, this + works fine. A rule that says that you must first elaborate the body of + anything you `with' cannot work in this case: the body of `X' `with''s + `Y', which means you would have to elaborate the body of `Y' first, but + that `with''s `X', which means you have to elaborate the body of `X' + first, but ... and we have a loop that cannot be broken. + + It is true that the binder can in many cases guess an order of + elaboration that is unlikely to cause a `Program_Error' exception to be + raised, and it tries to do so (in the above example of + `Math/Stuff/Spec', the GNAT binder will by default elaborate the body + of `Math' right after its spec, so all will be well). + + However, a program that blindly relies on the binder to be helpful + can get into trouble, as we discussed in the previous sections, so GNAT + provides a number of facilities for assisting the programmer in + developing programs that are robust with respect to elaboration order. + +  + File: gnat_ug_vxw.info, Node: Default Behavior in GNAT - Ensuring Safety, Next: Elaboration Issues for Library Tasks, Prev: Controlling Elaboration in GNAT - External Calls, Up: Elaboration Order Handling in GNAT + + Default Behavior in GNAT - Ensuring Safety + ========================================== + + The default behavior in GNAT ensures elaboration safety. In its default + mode GNAT implements the rule we previously described as the right + approach. Let's restate it: + + * _If a unit has elaboration code that can directly or indirectly + make a call to a subprogram in a `with''ed unit, or instantiate a + generic unit in a `with''ed unit, then if the `with''ed unit does + not have pragma `Pure' or `Preelaborate', then the client should + have an `Elaborate_All' for the `with''ed unit._ + + By following this rule a client is assured that calls and + instantiations can be made without risk of an exception. + + In this mode GNAT traces all calls that are potentially made from + elaboration code, and puts in any missing implicit `Elaborate_All' + pragmas. The advantage of this approach is that no elaboration problems + are possible if the binder can find an elaboration order that is + consistent with these implicit `Elaborate_All' pragmas. The + disadvantage of this approach is that no such order may exist. + + If the binder does not generate any diagnostics, then it means that + it has found an elaboration order that is guaranteed to be safe. + However, the binder may still be relying on implicitly generated + `Elaborate_All' pragmas so portability to other compilers than GNAT is + not guaranteed. + + If it is important to guarantee portability, then the compilations + should use the `-gnatwl' (warn on elaboration problems) switch. This + will cause warning messages to be generated indicating the missing + `Elaborate_All' pragmas. Consider the following source program: + + with k; + package j is + m : integer := k.r; + end; + + where it is clear that there should be a pragma `Elaborate_All' for + unit `k'. An implicit pragma will be generated, and it is likely that + the binder will be able to honor it. However, it is safer to include + the pragma explicitly in the source. If this unit is compiled with the + `-gnatwl' switch, then the compiler outputs a warning: + + 1. with k; + 2. package j is + 3. m : integer := k.r; + | + >>> warning: call to "r" may raise Program_Error + >>> warning: missing pragma Elaborate_All for "k" + + 4. end; + + and these warnings can be used as a guide for supplying manually the + missing pragmas. + + This default mode is more restrictive than the Ada Reference Manual, + and it is possible to construct programs which will compile using the + dynamic model described there, but will run into a circularity using + the safer static model we have described. + + Of course any Ada compiler must be able to operate in a mode + consistent with the requirements of the Ada Reference Manual, and in + particular must have the capability of implementing the standard + dynamic model of elaboration with run-time checks. + + In GNAT, this standard mode can be achieved either by the use of the + `-gnatE' switch on the compiler (`gcc' or `gnatmake') command, or by + the use of the configuration pragma: + + pragma Elaboration_Checks (RM); + + Either approach will cause the unit affected to be compiled using the + standard dynamic run-time elaboration checks described in the Ada + Reference Manual. The static model is generally preferable, since it is + clearly safer to rely on compile and link time checks rather than + run-time checks. However, in the case of legacy code, it may be + difficult to meet the requirements of the static model. This issue is + further discussed in *Note What to Do If the Default Elaboration + Behavior Fails::. + + Note that the static model provides a strict subset of the allowed + behavior and programs of the Ada Reference Manual, so if you do adhere + to the static model and no circularities exist, then you are assured + that your program will work using the dynamic model. + +  + File: gnat_ug_vxw.info, Node: Elaboration Issues for Library Tasks, Next: Mixing Elaboration Models, Prev: Default Behavior in GNAT - Ensuring Safety, Up: Elaboration Order Handling in GNAT + + Elaboration Issues for Library Tasks + ==================================== + + In this section we examine special elaboration issues that arise for + programs that declare library level tasks. + + Generally the model of execution of an Ada program is that all units + are elaborated, and then execution of the program starts. However, the + declaration of library tasks definitely does not fit this model. The + reason for this is that library tasks start as soon as they are declared + (more precisely, as soon as the statement part of the enclosing package + body is reached), that is to say before elaboration of the program is + complete. This means that if such a task calls a subprogram, or an + entry in another task, the callee may or may not be elaborated yet, and + in the standard Reference Manual model of dynamic elaboration checks, + you can even get timing dependent Program_Error exceptions, since there + can be a race between the elaboration code and the task code. + + The static model of elaboration in GNAT seeks to avoid all such + dynamic behavior, by being conservative, and the conservative approach + in this particular case is to assume that all the code in a task body + is potentially executed at elaboration time if a task is declared at + the library level. + + This can definitely result in unexpected circularities. Consider the + following example + + package Decls is + task Lib_Task is + entry Start; + end Lib_Task; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + procedure Main is + begin + Decls.Lib_Task.Start; + end; + + If the above example is compiled in the default static elaboration + mode, then a circularity occurs. The circularity comes from the call + `Utils.Put_Val' in the task body of `Decls.Lib_Task'. Since this call + occurs in elaboration code, we need an implicit pragma `Elaborate_All' + for `Utils'. This means that not only must the spec and body of `Utils' + be elaborated before the body of `Decls', but also the spec and body of + any unit that is `with'ed' by the body of `Utils' must also be + elaborated before the body of `Decls'. This is the transitive + implication of pragma `Elaborate_All' and it makes sense, because in + general the body of `Put_Val' might have a call to something in a + `with'ed' unit. + + In this case, the body of Utils (actually its spec) `with's' + `Decls'. Unfortunately this means that the body of `Decls' must be + elaborated before itself, in case there is a call from the body of + `Utils'. + + Here is the exact chain of events we are worrying about: + + 1. In the body of `Decls' a call is made from within the body of a + library task to a subprogram in the package `Utils'. Since this + call may occur at elaboration time (given that the task is + activated at elaboration time), we have to assume the worst, i.e. + that the call does happen at elaboration time. + + 2. This means that the body and spec of `Util' must be elaborated + before the body of `Decls' so that this call does not cause an + access before elaboration. + + 3. Within the body of `Util', specifically within the body of + `Util.Put_Val' there may be calls to any unit `with''ed by this + package. + + 4. One such `with''ed package is package `Decls', so there might be a + call to a subprogram in `Decls' in `Put_Val'. In fact there is + such a call in this example, but we would have to assume that + there was such a call even if it were not there, since we are not + supposed to write the body of `Decls' knowing what is in the body + of `Utils'; certainly in the case of the static elaboration model, + the compiler does not know what is in other bodies and must assume + the worst. + + 5. This means that the spec and body of `Decls' must also be + elaborated before we elaborate the unit containing the call, but + that unit is `Decls'! This means that the body of `Decls' must be + elaborated before itself, and that's a circularity. + + Indeed, if you add an explicit pragma Elaborate_All for `Utils' in the + body of `Decls' you will get a true Ada Reference Manual circularity + that makes the program illegal. + + In practice, we have found that problems with the static model of + elaboration in existing code often arise from library tasks, so we must + address this particular situation. + + Note that if we compile and run the program above, using the dynamic + model of elaboration (that is to say use the `-gnatE' switch), then it + compiles, binds, links, and runs, printing the expected result of 2. + Therefore in some sense the circularity here is only apparent, and we + need to capture the properties of this program that distinguish it + from other library-level tasks that have real elaboration problems. + + We have four possible answers to this question: + + * Use the dynamic model of elaboration. + + If we use the `-gnatE' switch, then as noted above, the program + works. Why is this? If we examine the task body, it is apparent + that the task cannot proceed past the `accept' statement until + after elaboration has been completed, because the corresponding + entry call comes from the main program, not earlier. This is why + the dynamic model works here. But that's really giving up on a + precise analysis, and we prefer to take this approach only if we + cannot solve the problem in any other manner. So let us examine + two ways to reorganize the program to avoid the potential + elaboration problem. + + * Split library tasks into separate packages. + + Write separate packages, so that library tasks are isolated from + other declarations as much as possible. Let us look at a variation + on the above program. + + package Decls1 is + task Lib_Task is + entry Start; + end Lib_Task; + end Decls1; + + with Utils; + package body Decls1 is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + end Decls1; + + package Decls2 is + type My_Int is new Integer; + function Ident (M : My_Int) return My_Int; + end Decls2; + + with Utils; + package body Decls2 is + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls2; + + with Decls2; + package Utils is + procedure Put_Val (Arg : Decls2.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls2.My_Int) is + begin + Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls1; + procedure Main is + begin + Decls1.Lib_Task.Start; + end; + + All we have done is to split `Decls' into two packages, one + containing the library task, and one containing everything else. + Now there is no cycle, and the program compiles, binds, links and + executes using the default static model of elaboration. + + * Declare separate task types. + + A significant part of the problem arises because of the use of the + single task declaration form. This means that the elaboration of + the task type, and the elaboration of the task itself (i.e. the + creation of the task) happen at the same time. A good rule of + style in Ada 95 is to always create explicit task types. By + following the additional step of placing task objects in separate + packages from the task type declaration, many elaboration problems + are avoided. Here is another modified example of the example + program: + + package Decls is + task type Lib_Task_Type is + entry Start; + end Lib_Task_Type; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task_Type is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task_Type; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + package Declst is + Lib_Task : Decls.Lib_Task_Type; + end Declst; + + with Declst; + procedure Main is + begin + Declst.Lib_Task.Start; + end; + + What we have done here is to replace the `task' declaration in + package `Decls' with a `task type' declaration. Then we introduce + a separate package `Declst' to contain the actual task object. + This separates the elaboration issues for the `task type' + declaration, which causes no trouble, from the elaboration issues + of the task object, which is also unproblematic, since it is now + independent of the elaboration of `Utils'. This separation of + concerns also corresponds to a generally sound engineering + principle of separating declarations from instances. This version + of the program also compiles, binds, links, and executes, + generating the expected output. + + * Use No_Entry_Calls_In_Elaboration_Code restriction. + + The previous two approaches described how a program can be + restructured to avoid the special problems caused by library task + bodies. in practice, however, such restructuring may be difficult + to apply to existing legacy code, so we must consider solutions + that do not require massive rewriting. + + Let us consider more carefully why our original sample program + works under the dynamic model of elaboration. The reason is that + the code in the task body blocks immediately on the `accept' + statement. Now of course there is nothing to prohibit elaboration + code from making entry calls (for example from another library + level task), so we cannot tell in isolation that the task will not + execute the accept statement during elaboration. + + However, in practice it is very unusual to see elaboration code + make any entry calls, and the pattern of tasks starting at + elaboration time and then immediately blocking on `accept' or + `select' statements is very common. What this means is that the + compiler is being too pessimistic when it analyzes the whole + package body as though it might be executed at elaboration time. + + If we know that the elaboration code contains no entry calls, (a + very safe assumption most of the time, that could almost be made + the default behavior), then we can compile all units of the + program under control of the following configuration pragma: + + pragma Restrictions (No_Entry_Calls_In_Elaboration_Code); + + This pragma can be placed in the `gnat.adc' file in the usual + manner. If we take our original unmodified program and compile it + in the presence of a `gnat.adc' containing the above pragma, then + once again, we can compile, bind, link, and execute, obtaining the + expected result. In the presence of this pragma, the compiler does + not trace calls in a task body, that appear after the first + `accept' or `select' statement, and therefore does not report a + potential circularity in the original program. + + The compiler will check to the extent it can that the above + restriction is not violated, but it is not always possible to do a + complete check at compile time, so it is important to use this + pragma only if the stated restriction is in fact met, that is to + say no task receives an entry call before elaboration of all units + is completed. + + +  + File: gnat_ug_vxw.info, Node: Mixing Elaboration Models, Next: What to Do If the Default Elaboration Behavior Fails, Prev: Elaboration Issues for Library Tasks, Up: Elaboration Order Handling in GNAT + + Mixing Elaboration Models + ========================= + + So far, we have assumed that the entire program is either compiled + using the dynamic model or static model, ensuring consistency. It is + possible to mix the two models, but rules have to be followed if this + mixing is done to ensure that elaboration checks are not omitted. + + The basic rule is that _a unit compiled with the static model cannot + be `with'ed' by a unit compiled with the dynamic model_. The reason for + this is that in the static model, a unit assumes that its clients + guarantee to use (the equivalent of) pragma `Elaborate_All' so that no + elaboration checks are required in inner subprograms, and this + assumption is violated if the client is compiled with dynamic checks. + + The precise rule is as follows. A unit that is compiled with dynamic + checks can only `with' a unit that meets at least one of the following + criteria: + + * The `with'ed' unit is itself compiled with dynamic elaboration + checks (that is with the `-gnatE' switch. + + * The `with'ed' unit is an internal GNAT implementation unit from + the System, Interfaces, Ada, or GNAT hierarchies. + + * The `with'ed' unit has pragma Preelaborate or pragma Pure. + + * The `with'ing' unit (that is the client) has an explicit pragma + `Elaborate_All' for the `with'ed' unit. + + + If this rule is violated, that is if a unit with dynamic elaboration + checks `with's' a unit that does not meet one of the above four + criteria, then the binder (`gnatbind') will issue a warning similar to + that in the following example: + + warning: "x.ads" has dynamic elaboration checks and with's + warning: "y.ads" which has static elaboration checks + + These warnings indicate that the rule has been violated, and that as a + result elaboration checks may be missed in the resulting executable + file. This warning may be suppressed using the `-ws' binder switch in + the usual manner. + + One useful application of this mixing rule is in the case of a + subsystem which does not itself `with' units from the remainder of the + application. In this case, the entire subsystem can be compiled with + dynamic checks to resolve a circularity in the subsystem, while + allowing the main application that uses this subsystem to be compiled + using the more reliable default static model. + +  + File: gnat_ug_vxw.info, Node: What to Do If the Default Elaboration Behavior Fails, Next: Elaboration for Access-to-Subprogram Values, Prev: Mixing Elaboration Models, Up: Elaboration Order Handling in GNAT + + What to Do If the Default Elaboration Behavior Fails + ==================================================== + + If the binder cannot find an acceptable order, it outputs detailed + diagnostics. For example: + error: elaboration circularity detected + info: "proc (body)" must be elaborated before "pack (body)" + info: reason: Elaborate_All probably needed in unit "pack (body)" + info: recompile "pack (body)" with -gnatwl + info: for full details + info: "proc (body)" + info: is needed by its spec: + info: "proc (spec)" + info: which is withed by: + info: "pack (body)" + info: "pack (body)" must be elaborated before "proc (body)" + info: reason: pragma Elaborate in unit "proc (body)" + + + In this case we have a cycle that the binder cannot break. On the one + hand, there is an explicit pragma Elaborate in `proc' for `pack'. This + means that the body of `pack' must be elaborated before the body of + `proc'. On the other hand, there is elaboration code in `pack' that + calls a subprogram in `proc'. This means that for maximum safety, there + should really be a pragma Elaborate_All in `pack' for `proc' which + would require that the body of `proc' be elaborated before the body of + `pack'. Clearly both requirements cannot be satisfied. Faced with a + circularity of this kind, you have three different options. + + Fix the program + The most desirable option from the point of view of long-term + maintenance is to rearrange the program so that the elaboration + problems are avoided. One useful technique is to place the + elaboration code into separate child packages. Another is to move + some of the initialization code to explicitly called subprograms, + where the program controls the order of initialization explicitly. + Although this is the most desirable option, it may be impractical + and involve too much modification, especially in the case of + complex legacy code. + + Perform dynamic checks + If the compilations are done using the `-gnatE' (dynamic + elaboration check) switch, then GNAT behaves in a quite different + manner. Dynamic checks are generated for all calls that could + possibly result in raising an exception. With this switch, the + compiler does not generate implicit `Elaborate_All' pragmas. The + behavior then is exactly as specified in the Ada 95 Reference + Manual. The binder will generate an executable program that may + or may not raise `Program_Error', and then it is the programmer's + job to ensure that it does not raise an exception. Note that it is + important to compile all units with the switch, it cannot be used + selectively. + + Suppress checks + The drawback of dynamic checks is that they generate a significant + overhead at run time, both in space and time. If you are + absolutely sure that your program cannot raise any elaboration + exceptions, and you still want to use the dynamic elaboration + model, then you can use the configuration pragma `Suppress + (Elaboration_Checks)' to suppress all such checks. For example + this pragma could be placed in the `gnat.adc' file. + + Suppress checks selectively + When you know that certain calls in elaboration code cannot + possibly lead to an elaboration error, and the binder nevertheless + generates warnings on those calls and inserts Elaborate_All + pragmas that lead to elaboration circularities, it is possible to + remove those warnings locally and obtain a program that will bind. + Clearly this can be unsafe, and it is the responsibility of the + programmer to make sure that the resulting program has no + elaboration anomalies. The pragma `Suppress (Elaboration_Check)' + can be used with different granularity to suppress warnings and + break elaboration circularities: + + * Place the pragma that names the called subprogram in the + declarative part that contains the call. + + * Place the pragma in the declarative part, without naming an + entity. This disables warnings on all calls in the + corresponding declarative region. + + * Place the pragma in the package spec that declares the called + subprogram, and name the subprogram. This disables warnings + on all elaboration calls to that subprogram. + + * Place the pragma in the package spec that declares the called + subprogram, without naming any entity. This disables warnings + on all elaboration calls to all subprograms declared in this + spec. + + These four cases are listed in order of decreasing safety, and + therefore require increasing programmer care in their application. + Consider the following program: + + package Pack1 is + function F1 return Integer; + X1 : Integer; + end Pack1; + + package Pack2 is + function F2 return Integer; + function Pure (x : integer) return integer; + -- pragma Suppress (Elaboration_Check, On => Pure); -- (3) + -- pragma Suppress (Elaboration_Check); -- (4) + end Pack2; + + with Pack2; + package body Pack1 is + function F1 return Integer is + begin + return 100; + end F1; + Val : integer := Pack2.Pure (11); -- Elab. call (1) + begin + declare + -- pragma Suppress(Elaboration_Check, Pack2.F2); -- (1) + -- pragma Suppress(Elaboration_Check); -- (2) + begin + X1 := Pack2.F2 + 1; -- Elab. call (2) + end; + end Pack1; + + with Pack1; + package body Pack2 is + function F2 return Integer is + begin + return Pack1.F1; + end F2; + function Pure (x : integer) return integer is + begin + return x ** 3 - 3 * x; + end; + end Pack2; + + with Pack1, Ada.Text_IO; + procedure Proc3 is + begin + Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101 + end Proc3; + In the absence of any pragmas, an attempt to bind this program + produces the following diagnostics: + error: elaboration circularity detected + info: "pack1 (body)" must be elaborated before "pack1 (body)" + info: reason: Elaborate_All probably needed in unit "pack1 (body)" + info: recompile "pack1 (body)" with -gnatwl for full details + info: "pack1 (body)" + info: must be elaborated along with its spec: + info: "pack1 (spec)" + info: which is withed by: + info: "pack2 (body)" + info: which must be elaborated along with its spec: + info: "pack2 (spec)" + info: which is withed by: + info: "pack1 (body)" + The sources of the circularity are the two calls to + `Pack2.Pure' and `Pack2.F2' in the body of `Pack1'. We can see + that the call to F2 is safe, even though F2 calls F1, because the + call appears after the elaboration of the body of F1. Therefore + the pragma (1) is safe, and will remove the warning on the call. + It is also possible to use pragma (2) because there are no other + potentially unsafe calls in the block. + + The call to `Pure' is safe because this function does not depend + on the state of `Pack2'. Therefore any call to this function is + safe, and it is correct to place pragma (3) in the corresponding + package spec. + + Finally, we could place pragma (4) in the spec of `Pack2' to + disable warnings on all calls to functions declared therein. Note + that this is not necessarily safe, and requires more detailed + examination of the subprogram bodies involved. In particular, a + call to `F2' requires that `F1' be already elaborated. + + It is hard to generalize on which of these four approaches should be + taken. Obviously if it is possible to fix the program so that the + default treatment works, this is preferable, but this may not always be + practical. It is certainly simple enough to use `-gnatE' but the + danger in this case is that, even if the GNAT binder finds a correct + elaboration order, it may not always do so, and certainly a binder from + another Ada compiler might not. A combination of testing and analysis + (for which the warnings generated with the `-gnatwl' switch can be + useful) must be used to ensure that the program is free of errors. One + switch that is useful in this testing is the `-p (pessimistic + elaboration order)' switch for `gnatbind'. Normally the binder tries + to find an order that has the best chance of of avoiding elaboration + problems. With this switch, the binder plays a devil's advocate role, + and tries to choose the order that has the best chance of failing. If + your program works even with this switch, then it has a better chance + of being error free, but this is still not a guarantee. + + For an example of this approach in action, consider the C-tests + (executable tests) from the ACVC suite. If these are compiled and run + with the default treatment, then all but one of them succeed without + generating any error diagnostics from the binder. However, there is one + test that fails, and this is not surprising, because the whole point of + this test is to ensure that the compiler can handle cases where it is + impossible to determine a correct order statically, and it checks that + an exception is indeed raised at run time. + + This one test must be compiled and run using the `-gnatE' switch, + and then it passes. Alternatively, the entire suite can be run using + this switch. It is never wrong to run with the dynamic elaboration + switch if your code is correct, and we assume that the C-tests are + indeed correct (it is less efficient, but efficiency is not a factor in + running the ACVC tests.) + +  + File: gnat_ug_vxw.info, Node: Elaboration for Access-to-Subprogram Values, Next: Summary of Procedures for Elaboration Control, Prev: What to Do If the Default Elaboration Behavior Fails, Up: Elaboration Order Handling in GNAT + + Elaboration for Access-to-Subprogram Values + =========================================== + + The introduction of access-to-subprogram types in Ada 95 complicates + the handling of elaboration. The trouble is that it becomes impossible + to tell at compile time which procedure is being called. This means + that it is not possible for the binder to analyze the elaboration + requirements in this case. + + If at the point at which the access value is created (i.e., the + evaluation of `P'Access' for a subprogram `P'), the body of the + subprogram is known to have been elaborated, then the access value is + safe, and its use does not require a check. This may be achieved by + appropriate arrangement of the order of declarations if the subprogram + is in the current unit, or, if the subprogram is in another unit, by + using pragma `Pure', `Preelaborate', or `Elaborate_Body' on the + referenced unit. + + If the referenced body is not known to have been elaborated at the + point the access value is created, then any use of the access value + must do a dynamic check, and this dynamic check will fail and raise a + `Program_Error' exception if the body has not been elaborated yet. + GNAT will generate the necessary checks, and in addition, if the + `-gnatwl' switch is set, will generate warnings that such checks are + required. + + The use of dynamic dispatching for tagged types similarly generates + a requirement for dynamic checks, and premature calls to any primitive + operation of a tagged type before the body of the operation has been + elaborated, will result in the raising of `Program_Error'. + +  + File: gnat_ug_vxw.info, Node: Summary of Procedures for Elaboration Control, Next: Other Elaboration Order Considerations, Prev: Elaboration for Access-to-Subprogram Values, Up: Elaboration Order Handling in GNAT + + Summary of Procedures for Elaboration Control + ============================================= + + First, compile your program with the default options, using none of the + special elaboration control switches. If the binder successfully binds + your program, then you can be confident that, apart from issues raised + by the use of access-to-subprogram types and dynamic dispatching, the + program is free of elaboration errors. If it is important that the + program be portable, then use the `-gnatwl' switch to generate warnings + about missing `Elaborate_All' pragmas, and supply the missing pragmas. + + If the program fails to bind using the default static elaboration + handling, then you can fix the program to eliminate the binder message, + or recompile the entire program with the `-gnatE' switch to generate + dynamic elaboration checks, and, if you are sure there really are no + elaboration problems, use a global pragma `Suppress + (Elaboration_Checks)'. + +  + File: gnat_ug_vxw.info, Node: Other Elaboration Order Considerations, Prev: Summary of Procedures for Elaboration Control, Up: Elaboration Order Handling in GNAT + + Other Elaboration Order Considerations + ====================================== + + This section has been entirely concerned with the issue of finding a + valid elaboration order, as defined by the Ada Reference Manual. In a + case where several elaboration orders are valid, the task is to find one + of the possible valid elaboration orders (and the static model in GNAT + will ensure that this is achieved). + + The purpose of the elaboration rules in the Ada Reference Manual is + to make sure that no entity is accessed before it has been elaborated. + For a subprogram, this means that the spec and body must have been + elaborated before the subprogram is called. For an object, this means + that the object must have been elaborated before its value is read or + written. A violation of either of these two requirements is an access + before elaboration order, and this section has been all about avoiding + such errors. + + In the case where more than one order of elaboration is possible, in + the sense that access before elaboration errors are avoided, then any + one of the orders is "correct" in the sense that it meets the + requirements of the Ada Reference Manual, and no such error occurs. + + However, it may be the case for a given program, that there are + constraints on the order of elaboration that come not from consideration + of avoiding elaboration errors, but rather from extra-lingual logic + requirements. Consider this example: + + with Init_Constants; + package Constants is + X : Integer := 0; + Y : Integer := 0; + end Constants; + + package Init_Constants is + procedure Calc; + end Init_Constants; + + with Constants; + package body Init_Constants is + procedure Calc is begin null; end; + begin + Constants.X := 3; + Constants.Y := 4; + end Init_Constants; + + with Constants; + package Calc is + Z : Integer := Constants.X + Constants.Y; + end Calc; + + with Calc; + with Text_IO; use Text_IO; + procedure Main is + begin + Put_Line (Calc.Z'Img); + end Main; + + In this example, there is more than one valid order of elaboration. For + example both the following are correct orders: + + Init_Constants spec + Constants spec + Calc spec + Main body + Init_Constants body + + and + + Init_Constants spec + Init_Constants body + Constants spec + Calc spec + Main body + + There is no language rule to prefer one or the other, both are correct + from an order of elaboration point of view. But the programmatic effects + of the two orders are very different. In the first, the elaboration + routine of `Calc' initializes `Z' to zero, and then the main program + runs with this value of zero. But in the second order, the elaboration + routine of `Calc' runs after the body of Init_Constants has set `X' and + `Y' and thus `Z' is set to 7 before `Main' runs. + + One could perhaps by applying pretty clever non-artificial + intelligence to the situation guess that it is more likely that the + second order of elaboration is the one desired, but there is no formal + linguistic reason to prefer one over the other. In fact in this + particular case, GNAT will prefer the second order, because of the rule + that bodies are elaborated as soon as possible, but it's just luck that + this is what was wanted (if indeed the second order was preferred). + + If the program cares about the order of elaboration routines in a + case like this, it is important to specify the order required. In this + particular case, that could have been achieved by adding to the spec of + Calc: + + pragma Elaborate_All (Constants); + + which requires that the body (if any) and spec of `Constants', as well + as the body and spec of any unit `with''ed by `Constants' be elaborated + before `Calc' is elaborated. + + Clearly no automatic method can always guess which alternative you + require, and if you are working with legacy code that had constraints + of this kind which were not properly specified by adding `Elaborate' or + `Elaborate_All' pragmas, then indeed it is possible that two different + compilers can choose different orders. + + The `gnatbind' `-p' switch may be useful in smoking out problems. + This switch causes bodies to be elaborated as late as possible instead + of as early as possible. In the example above, it would have forced the + choice of the first elaboration order. If you get different results + when using this switch, and particularly if one set of results is right, + and one is wrong as far as you are concerned, it shows that you have + some missing `Elaborate' pragmas. For the example above, we have the + following output: + + gnatmake -f -q main + main + 7 + gnatmake -f -q main -bargs -p + main + 0 + + It is of course quite unlikely that both these results are correct, so + it is up to you in a case like this to investigate the source of the + difference, by looking at the two elaboration orders that are chosen, + and figuring out which is correct, and then adding the necessary + `Elaborate_All' pragmas to ensure the desired order. + +  + File: gnat_ug_vxw.info, Node: The Cross-Referencing Tools gnatxref and gnatfind, Next: File Name Krunching Using gnatkr, Prev: Elaboration Order Handling in GNAT, Up: Top + + The Cross-Referencing Tools `gnatxref' and `gnatfind' + ***************************************************** + + The compiler generates cross-referencing information (unless you set + the `-gnatx' switch), which are saved in the `.ali' files. This + information indicates where in the source each entity is declared and + referenced. Note that entities in package Standard are not included, but + entities in all other predefined units are included in the output. + + Before using any of these two tools, you need to compile + successfully your application, so that GNAT gets a chance to generate + the cross-referencing information. + + The two tools `gnatxref' and `gnatfind' take advantage of this + information to provide the user with the capability to easily locate the + declaration and references to an entity. These tools are quite similar, + the difference being that `gnatfind' is intended for locating + definitions and/or references to a specified entity or entities, whereas + `gnatxref' is oriented to generating a full report of all + cross-references. + + To use these tools, you must not compile your application using the + `-gnatx' switch on the `gnatmake' command line (*note (gnat_ug)The GNAT + Make Program gnatmake::). Otherwise, cross-referencing information will + not be generated. + + * Menu: + + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + +  + File: gnat_ug_vxw.info, Node: gnatxref Switches, Next: gnatfind Switches, Up: The Cross-Referencing Tools gnatxref and gnatfind + + `gnatxref' Switches + =================== + + The command lines for `gnatxref' is: + $ gnatxref [switches] sourcefile1 [sourcefile2 ...] + + where + + `sourcefile1, sourcefile2' + identifies the source files for which a report is to be generated. + The 'with'ed units will be processed too. You must provide at + least one file. + + These file names are considered to be regular expressions, so for + instance specifying 'source*.adb' is the same as giving every file + in the current directory whose name starts with 'source' and whose + extension is 'adb'. + + The switches can be : + `-a' + If this switch is present, `gnatfind' and `gnatxref' will parse + the read-only files found in the library search path. Otherwise, + these files will be ignored. This option can be used to protect + Gnat sources or your own libraries from being parsed, thus making + `gnatfind' and `gnatxref' much faster, and their output much + smaller. + + `-aIDIR' + When looking for source files also look in directory DIR. The + order in which source file search is undertaken is the same as for + `gnatmake'. + + `-aODIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as + for `gnatmake'. + + `-nostdinc' + Do not look for sources in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-d' + If this switch is set `gnatxref' will output the parent type + reference for each matching derived types. + + `-f' + If this switch is set, the output file names will be preceded by + their directory (if the file was found in the search path). If + this switch is not set, the directory will not be printed. + + `-g' + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may + accelerate `gnatfind' and `gnatxref'. + + `-IDIR' + Equivalent to `-aODIR -aIDIR'. + + `-pFILE' + Specify a project file to use *Note Project Files::. By default, + `gnatxref' and `gnatfind' will try to locate a project file in the + current directory. + + If a project file is either specified or found by the tools, then + the content of the source directory and object directory lines are + added as if they had been specified respectively by `-aI' and + `-aO'. + + `-u' + Output only unused symbols. This may be really useful if you give + your main compilation unit on the command line, as `gnatxref' will + then display every unused entity and 'with'ed package. + + `-v' + Instead of producing the default output, `gnatxref' will generate a + `tags' file that can be used by vi. For examples how to use this + feature, see *Note Examples of gnatxref Usage::. The tags file is + output to the standard output, thus you will have to redirect it + to a file. + + All these switches may be in any order on the command line, and may + even appear after the file names. They need not be separated by spaces, + thus you can say `gnatxref -ag' instead of `gnatxref -a -g'. + +  + File: gnat_ug_vxw.info, Node: gnatfind Switches, Next: Project Files for gnatxref and gnatfind, Prev: gnatxref Switches, Up: The Cross-Referencing Tools gnatxref and gnatfind + + `gnatfind' Switches + =================== + + The command line for `gnatfind' is: + + $ gnatfind [switches] pattern[:sourcefile[:line[:column]]] + [file1 file2 ...] + + where + + `pattern' + An entity will be output only if it matches the regular expression + found in `pattern', see *Note Regular Expressions in gnatfind and + gnatxref::. + + Omitting the pattern is equivalent to specifying `*', which will + match any entity. Note that if you do not provide a pattern, you + have to provide both a sourcefile and a line. + + Entity names are given in Latin-1, with uppercase/lowercase + equivalence for matching purposes. At the current time there is no + support for 8-bit codes other than Latin-1, or for wide characters + in identifiers. + + `sourcefile' + `gnatfind' will look for references, bodies or declarations of + symbols referenced in `sourcefile', at line `line' and column + `column'. See *note Examples of gnatfind Usage:: for syntax + examples. + + `line' + is a decimal integer identifying the line number containing the + reference to the entity (or entities) to be located. + + `column' + is a decimal integer identifying the exact location on the line of + the first character of the identifier for the entity reference. + Columns are numbered from 1. + + `file1 file2 ...' + The search will be restricted to these files. If none are given, + then the search will be done for every library file in the search + path. These file must appear only after the pattern or sourcefile. + + These file names are considered to be regular expressions, so for + instance specifying 'source*.adb' is the same as giving every file + in the current directory whose name starts with 'source' and whose + extension is 'adb'. + + Not that if you specify at least one file in this part, `gnatfind' + may sometimes not be able to find the body of the subprograms... + + At least one of 'sourcefile' or 'pattern' has to be present on the + command line. + + The following switches are available: + `-a' + If this switch is present, `gnatfind' and `gnatxref' will parse + the read-only files found in the library search path. Otherwise, + these files will be ignored. This option can be used to protect + Gnat sources or your own libraries from being parsed, thus making + `gnatfind' and `gnatxref' much faster, and their output much + smaller. + + `-aIDIR' + When looking for source files also look in directory DIR. The + order in which source file search is undertaken is the same as for + `gnatmake'. + + `-aODIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as + for `gnatmake'. + + `-nostdinc' + Do not look for sources in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-d' + If this switch is set, then `gnatfind' will output the parent type + reference for each matching derived types. + + `-e' + By default, `gnatfind' accept the simple regular expression set for + `pattern'. If this switch is set, then the pattern will be + considered as full Unix-style regular expression. + + `-f' + If this switch is set, the output file names will be preceded by + their directory (if the file was found in the search path). If + this switch is not set, the directory will not be printed. + + `-g' + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may + accelerate `gnatfind' and `gnatxref'. + + `-IDIR' + Equivalent to `-aODIR -aIDIR'. + + `-pFILE' + Specify a project file (*note Project Files::) to use. By + default, `gnatxref' and `gnatfind' will try to locate a project + file in the current directory. + + If a project file is either specified or found by the tools, then + the content of the source directory and object directory lines are + added as if they had been specified respectively by `-aI' and + `-aO'. + + `-r' + By default, `gnatfind' will output only the information about the + declaration, body or type completion of the entities. If this + switch is set, the `gnatfind' will locate every reference to the + entities in the files specified on the command line (or in every + file in the search path if no file is given on the command line). + + `-s' + If this switch is set, then `gnatfind' will output the content of + the Ada source file lines were the entity was found. + + `-t' + If this switch is set, then `gnatfind' will output the type + hierarchy for the specified type. It act like -d option but + recursively from parent type to parent type. When this switch is + set it is not possible to specify more than one file. + + All these switches may be in any order on the command line, and may + even appear after the file names. They need not be separated by spaces, + thus you can say `gnatxref -ag' instead of `gnatxref -a -g'. + + As stated previously, gnatfind will search in every directory in the + search path. You can force it to look only in the current directory if + you specify `*' at the end of the command line. + +  + File: gnat_ug_vxw.info, Node: Project Files for gnatxref and gnatfind, Next: Regular Expressions in gnatfind and gnatxref, Prev: gnatfind Switches, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Project Files for `gnatxref' and `gnatfind' + =========================================== + + Project files allow a programmer to specify how to compile its + application, where to find sources,... These files are used primarily by + the Glide Ada mode, but they can also be used by the two tools + `gnatxref' and `gnatfind'. + + A project file name must end with `.adp'. If a single one is present + in the current directory, then `gnatxref' and `gnatfind' will extract + the information from it. If multiple project files are found, none of + them is read, and you have to use the `-p' switch to specify the one + you want to use. + + The following lines can be included, even though most of them have + default values which can be used in most cases. The lines can be + entered in any order in the file. Except for `src_dir' and `obj_dir', + you can only have one instance of each line. If you have multiple + instances, only the last one is taken into account. + + `src_dir=DIR [default: "./"]' + specifies a directory where to look for source files. Multiple + src_dir lines can be specified and they will be searched in the + order they are specified. + + `obj_dir=DIR [default: "./"]' + specifies a directory where to look for object and library files. + Multiple obj_dir lines can be specified and they will be searched + in the order they are specified + + `comp_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${comp_opt}' notation. This is intended to store the default + switches given to `gnatmake' and `gcc'. + + `bind_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${bind_opt}' notation. This is intended to store the default + switches given to `gnatbind'. + + `link_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${link_opt}' notation. This is intended to store the default + switches given to `gnatlink'. + + `main=EXECUTABLE [default: ""]' + specifies the name of the executable for the application. This + variable can be referred to in the following lines by using the + `${main}' notation. + + `comp_cmd=COMMAND [default: "gcc -c -I${src_dir} -g -gnatq"]' + specifies the command used to compile a single file in the + application. + + `make_cmd=COMMAND [default: "gnatmake ${main} -aI${src_dir} -aO${obj_dir} -g -gnatq -cargs ${comp_opt} -bargs ${bind_opt} -largs ${link_opt}"]' + specifies the command used to recompile the whole application. + + `run_cmd=COMMAND [default: "${main}"]' + specifies the command used to run the application. + + `debug_cmd=COMMAND [default: "gdb ${main}"]' + specifies the command used to debug the application + + `gnatxref' and `gnatfind' only take into account the `src_dir' and + `obj_dir' lines, and ignore the others. + +  + File: gnat_ug_vxw.info, Node: Regular Expressions in gnatfind and gnatxref, Next: Examples of gnatxref Usage, Prev: Project Files for gnatxref and gnatfind, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Regular Expressions in `gnatfind' and `gnatxref' + ================================================ + + As specified in the section about `gnatfind', the pattern can be a + regular expression. Actually, there are to set of regular expressions + which are recognized by the program : + + `globbing patterns' + These are the most usual regular expression. They are the same + that you generally used in a Unix shell command line, or in a DOS + session. + + Here is a more formal grammar : + regexp ::= term + term ::= elmt -- matches elmt + term ::= elmt elmt -- concatenation (elmt then elmt) + term ::= * -- any string of 0 or more characters + term ::= ? -- matches any character + term ::= [char {char}] -- matches any character listed + term ::= [char - char] -- matches any character in range + + `full regular expression' + The second set of regular expressions is much more powerful. This + is the type of regular expressions recognized by utilities such a + `grep'. + + The following is the form of a regular expression, expressed in Ada + reference manual style BNF is as follows + + regexp ::= term {| term} -- alternation (term or term ...) + + term ::= item {item} -- concatenation (item then item) + + item ::= elmt -- match elmt + item ::= elmt * -- zero or more elmt's + item ::= elmt + -- one or more elmt's + item ::= elmt ? -- matches elmt or nothing + elmt ::= nschar -- matches given character + elmt ::= [nschar {nschar}] -- matches any character listed + elmt ::= [^ nschar {nschar}] -- matches any character not listed + elmt ::= [char - char] -- matches chars in given range + elmt ::= \ char -- matches given character + elmt ::= . -- matches any single character + elmt ::= ( regexp ) -- parens used for grouping + + char ::= any character, including special characters + nschar ::= any character except ()[].*+?^ + + Following are a few examples : + + `abcde|fghi' + will match any of the two strings 'abcde' and 'fghi'. + + `abc*d' + will match any string like 'abd', 'abcd', 'abccd', 'abcccd', + and so on + + `[a-z]+' + will match any string which has only lowercase characters in + it (and at least one character + +  + File: gnat_ug_vxw.info, Node: Examples of gnatxref Usage, Next: Examples of gnatfind Usage, Prev: Regular Expressions in gnatfind and gnatxref, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Examples of `gnatxref' Usage + ============================ + + General Usage + ------------- + + For the following examples, we will consider the following units : + + main.ads: + 1: with Bar; + 2: package Main is + 3: procedure Foo (B : in Integer); + 4: C : Integer; + 5: private + 6: D : Integer; + 7: end Main; + + main.adb: + 1: package body Main is + 2: procedure Foo (B : in Integer) is + 3: begin + 4: C := B; + 5: D := B; + 6: Bar.Print (B); + 7: Bar.Print (C); + 8: end Foo; + 9: end Main; + + bar.ads: + 1: package Bar is + 2: procedure Print (B : Integer); + 3: end bar; + + The first thing to do is to recompile your application (for + instance, in that case just by doing a `gnatmake main', so that + GNAT generates the cross-referencing information. You can then + issue any of the following commands: + + `gnatxref main.adb' + `gnatxref' generates cross-reference information for main.adb and + every unit 'with'ed by main.adb. + + The output would be: + B Type: Integer + Decl: bar.ads 2:22 + B Type: Integer + Decl: main.ads 3:20 + Body: main.adb 2:20 + Ref: main.adb 4:13 5:13 6:19 + Bar Type: Unit + Decl: bar.ads 1:9 + Ref: main.adb 6:8 7:8 + main.ads 1:6 + C Type: Integer + Decl: main.ads 4:5 + Modi: main.adb 4:8 + Ref: main.adb 7:19 + D Type: Integer + Decl: main.ads 6:5 + Modi: main.adb 5:8 + Foo Type: Unit + Decl: main.ads 3:15 + Body: main.adb 2:15 + Main Type: Unit + Decl: main.ads 2:9 + Body: main.adb 1:14 + Print Type: Unit + Decl: bar.ads 2:15 + Ref: main.adb 6:12 7:12 + + that is the entity `Main' is declared in main.ads, line 2, column + 9, its body is in main.adb, line 1, column 14 and is not + referenced any where. + + The entity `Print' is declared in bar.ads, line 2, column 15 and it + it referenced in main.adb, line 6 column 12 and line 7 column 12. + + `gnatxref package1.adb package2.ads' + `gnatxref' will generates cross-reference information for + package1.adb, package2.ads and any other package 'with'ed by any + of these. + + Using gnatxref with vi + ---------------------- + + `gnatxref' can generate a tags file output, which can be used + directly from `vi'. Note that the standard version of `vi' will not + work properly with overloaded symbols. Consider using another free + implementation of `vi', such as `vim'. + + $ gnatxref -v gnatfind.adb > tags + + will generate the tags file for `gnatfind' itself (if the sources are + in the search path!). + + From `vi', you can then use the command `:tag entity' (replacing + entity by whatever you are looking for), and vi will display a new file + with the corresponding declaration of entity. + +  + File: gnat_ug_vxw.info, Node: Examples of gnatfind Usage, Prev: Examples of gnatxref Usage, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Examples of `gnatfind' Usage + ============================ + + `gnatfind -f xyz:main.adb' + Find declarations for all entities xyz referenced at least once in + main.adb. The references are search in every library file in the + search path. + + The directories will be printed as well (as the `-f' switch is set) + + The output will look like: + directory/main.ads:106:14: xyz <= declaration + directory/main.adb:24:10: xyz <= body + directory/foo.ads:45:23: xyz <= declaration + + that is to say, one of the entities xyz found in main.adb is + declared at line 12 of main.ads (and its body is in main.adb), and + another one is declared at line 45 of foo.ads + + `gnatfind -fs xyz:main.adb' + This is the same command as the previous one, instead `gnatfind' + will display the content of the Ada source file lines. + + The output will look like: + + directory/main.ads:106:14: xyz <= declaration + procedure xyz; + directory/main.adb:24:10: xyz <= body + procedure xyz is + directory/foo.ads:45:23: xyz <= declaration + xyz : Integer; + + This can make it easier to find exactly the location your are + looking for. + + `gnatfind -r "*x*":main.ads:123 foo.adb' + Find references to all entities containing an x that are + referenced on line 123 of main.ads. The references will be + searched only in main.adb and foo.adb. + + `gnatfind main.ads:123' + Find declarations and bodies for all entities that are referenced + on line 123 of main.ads. + + This is the same as `gnatfind "*":main.adb:123'. + + `gnatfind mydir/main.adb:123:45' + Find the declaration for the entity referenced at column 45 in + line 123 of file main.adb in directory mydir. Note that it is + usual to omit the identifier name when the column is given, since + the column position identifies a unique reference. + + The column has to be the beginning of the identifier, and should + not point to any character in the middle of the identifier. + +  + File: gnat_ug_vxw.info, Node: File Name Krunching Using gnatkr, Next: Preprocessing Using gnatprep, Prev: The Cross-Referencing Tools gnatxref and gnatfind, Up: Top + + File Name Krunching Using `gnatkr' + ********************************** + + This chapter discusses the method used by the compiler to shorten the + default file names chosen for Ada units so that they do not exceed the + maximum length permitted. It also describes the `gnatkr' utility that + can be used to determine the result of applying this shortening. + + * Menu: + + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + +  + File: gnat_ug_vxw.info, Node: About gnatkr, Next: Using gnatkr, Up: File Name Krunching Using gnatkr + + About `gnatkr' + ============== + + The default file naming rule in GNAT is that the file name must be + derived from the unit name. The exact default rule is as follows: + * Take the unit name and replace all dots by hyphens. + + * If such a replacement occurs in the second character position of a + name, and the first character is a, g, s, or i then replace the + dot by the character ~ (tilde) instead of a minus. + The reason for this exception is to avoid clashes with the standard + names for children of System, Ada, Interfaces, and GNAT, which use the + prefixes s- a- i- and g- respectively. + + The `-gnatkNN' switch of the compiler activates a "krunching" + circuit that limits file names to nn characters (where nn is a decimal + integer). For example, using OpenVMS, where the maximum file name + length is 39, the value of nn is usually set to 39, but if you want to + generate a set of files that would be usable if ported to a system with + some different maximum file length, then a different value can be + specified. The default value of 39 for OpenVMS need not be specified. + + The `gnatkr' utility can be used to determine the krunched name for + a given file, when krunched to a specified maximum length. + +  + File: gnat_ug_vxw.info, Node: Using gnatkr, Next: Krunching Method, Prev: About gnatkr, Up: File Name Krunching Using gnatkr + + Using `gnatkr' + ============== + + The `gnatkr' command has the form + + $ gnatkr NAME [LENGTH] + + NAME can be an Ada name with dots or the GNAT name of the unit, where + the dots representing child units or subunit are replaced by hyphens. + The only confusion arises if a name ends in `.ads' or `.adb'. `gnatkr' + takes this to be an extension if there are no other dots in the name + and the whole name is in lowercase. + + LENGTH represents the length of the krunched name. The default when + no argument is given is 8 characters. A length of zero stands for + unlimited, in other words do not chop except for system files which are + always 8. + + The output is the krunched name. The output has an extension only if the + original argument was a file name with an extension. + +  + File: gnat_ug_vxw.info, Node: Krunching Method, Next: Examples of gnatkr Usage, Prev: Using gnatkr, Up: File Name Krunching Using gnatkr + + Krunching Method + ================ + + The initial file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + lowercase for all letters, except that a hyphen in the second character + position is replaced by a tilde if the first character is a, i, g, or s. + The extension is `.ads' for a specification and `.adb' for a body. + Krunching does not affect the extension, but the file name is shortened + to the specified length by following these rules: + + * The name is divided into segments separated by hyphens, tildes or + underscores and all hyphens, tildes, and underscores are + eliminated. If this leaves the name short enough, we are done. + + * If the name is too long, the longest segment is located (left-most + if there are two of equal length), and shortened by dropping its + last character. This is repeated until the name is short enough. + + As an example, consider the krunching of + `our-strings-wide_fixed.adb' to fit the name into 8 characters as + required by some operating systems. + + our-strings-wide_fixed 22 + our strings wide fixed 19 + our string wide fixed 18 + our strin wide fixed 17 + our stri wide fixed 16 + our stri wide fixe 15 + our str wide fixe 14 + our str wid fixe 13 + our str wid fix 12 + ou str wid fix 11 + ou st wid fix 10 + ou st wi fix 9 + ou st wi fi 8 + Final file name: oustwifi.adb + + * The file names for all predefined units are always krunched to + eight characters. The krunching of these predefined units uses the + following special prefix replacements: + + `ada-' + replaced by `a-' + + `gnat-' + replaced by `g-' + + `interfaces-' + replaced by `i-' + + `system-' + replaced by `s-' + + These system files have a hyphen in the second character position. + That is why normal user files replace such a character with a + tilde, to avoid confusion with system file names. + + As an example of this special rule, consider + `ada-strings-wide_fixed.adb', which gets krunched as follows: + + ada-strings-wide_fixed 22 + a- strings wide fixed 18 + a- string wide fixed 17 + a- strin wide fixed 16 + a- stri wide fixed 15 + a- stri wide fixe 14 + a- str wide fixe 13 + a- str wid fixe 12 + a- str wid fix 11 + a- st wid fix 10 + a- st wi fix 9 + a- st wi fi 8 + Final file name: a-stwifi.adb + + Of course no file shortening algorithm can guarantee uniqueness over + all possible unit names, and if file name krunching is used then it is + your responsibility to ensure that no name clashes occur. The utility + program `gnatkr' is supplied for conveniently determining the krunched + name of a file. + +  + File: gnat_ug_vxw.info, Node: Examples of gnatkr Usage, Prev: Krunching Method, Up: File Name Krunching Using gnatkr + + Examples of `gnatkr' Usage + ========================== + + $ gnatkr very_long_unit_name.ads --> velounna.ads + $ gnatkr grandparent-parent-child.ads --> grparchi.ads + $ gnatkr Grandparent.Parent.Child --> grparchi + $ gnatkr very_long_unit_name.ads/count=6 --> vlunna.ads + $ gnatkr very_long_unit_name.ads/count=0 --> very_long_unit_name.ads + +  + File: gnat_ug_vxw.info, Node: Preprocessing Using gnatprep, Next: The GNAT Library Browser gnatls, Prev: File Name Krunching Using gnatkr, Up: Top + + Preprocessing Using `gnatprep' + ****************************** + + The `gnatprep' utility provides a simple preprocessing capability for + Ada programs. It is designed for use with GNAT, but is not dependent + on any special features of GNAT. + + * Menu: + + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + +  + File: gnat_ug_vxw.info, Node: Using gnatprep, Next: Switches for gnatprep, Up: Preprocessing Using gnatprep + + Using `gnatprep' + ================ + + To call `gnatprep' use + + $ gnatprep [-bcrsu] [-Dsymbol=value] infile outfile [deffile] + + where + `infile' + is the full name of the input file, which is an Ada source file + containing preprocessor directives. + + `outfile' + is the full name of the output file, which is an Ada source in + standard Ada form. When used with GNAT, this file name will + normally have an ads or adb suffix. + + `deffile' + is the full name of a text file containing definitions of symbols + to be referenced by the preprocessor. This argument is optional, + and can be replaced by the use of the `-D' switch. + + `switches' + is an optional sequence of switches as described in the next + section. + +  + File: gnat_ug_vxw.info, Node: Switches for gnatprep, Next: Form of Definitions File, Prev: Using gnatprep, Up: Preprocessing Using gnatprep + + Switches for `gnatprep' + ======================= + + `-b' + Causes both preprocessor lines and the lines deleted by + preprocessing to be replaced by blank lines in the output source + file, preserving line numbers in the output file. + + `-c' + Causes both preprocessor lines and the lines deleted by + preprocessing to be retained in the output source as comments + marked with the special string "-! ". This option will result in + line numbers being preserved in the output file. + + `-Dsymbol=value' + Defines a new symbol, associated with value. If no value is given + on the command line, then symbol is considered to be `True'. This + switch can be used in place of a definition file. + + `-r' + Causes a `Source_Reference' pragma to be generated that references + the original input file, so that error messages will use the file + name of this original file. The use of this switch implies that + preprocessor lines are not to be removed from the file, so its use + will force `-b' mode if `-c' has not been specified explicitly. + + Note that if the file to be preprocessed contains multiple units, + then it will be necessary to `gnatchop' the output file from + `gnatprep'. If a `Source_Reference' pragma is present in the + preprocessed file, it will be respected by `gnatchop -r' so that + the final chopped files will correctly refer to the original input + source file for `gnatprep'. + + `-s' + Causes a sorted list of symbol names and values to be listed on + the standard output file. + + `-u' + Causes undefined symbols to be treated as having the value FALSE + in the context of a preprocessor test. In the absence of this + option, an undefined symbol in a `#if' or `#elsif' test will be + treated as an error. + + Note: if neither `-b' nor `-c' is present, then preprocessor lines and + deleted lines are completely removed from the output, unless -r is + specified, in which case -b is assumed. + +  + File: gnat_ug_vxw.info, Node: Form of Definitions File, Next: Form of Input Text for gnatprep, Prev: Switches for gnatprep, Up: Preprocessing Using gnatprep + + Form of Definitions File + ======================== + + The definitions file contains lines of the form + + symbol := value + + where symbol is an identifier, following normal Ada (case-insensitive) + rules for its syntax, and value is one of the following: + + * Empty, corresponding to a null substitution + + * A string literal using normal Ada syntax + + * Any sequence of characters from the set (letters, digits, period, + underline). + + Comment lines may also appear in the definitions file, starting with + the usual `--', and comments may be added to the definitions lines. + +  + File: gnat_ug_vxw.info, Node: Form of Input Text for gnatprep, Prev: Form of Definitions File, Up: Preprocessing Using gnatprep + + Form of Input Text for `gnatprep' + ================================= + + The input text may contain preprocessor conditional inclusion lines, as + well as general symbol substitution sequences. + + The preprocessor conditional inclusion commands have the form + + #if expression [then] + lines + #elsif expression [then] + lines + #elsif expression [then] + lines + ... + #else + lines + #end if; + + In this example, expression is defined by the following grammar: + expression ::= + expression ::= = "" + expression ::= = + expression ::= 'Defined + expression ::= not expression + expression ::= expression and expression + expression ::= expression or expression + expression ::= expression and then expression + expression ::= expression or else expression + expression ::= ( expression ) + + For the first test (expression ::= ) the symbol must have + either the value true or false, that is to say the right-hand of the + symbol definition must be one of the (case-insensitive) literals `True' + or `False'. If the value is true, then the corresponding lines are + included, and if the value is false, they are excluded. + + The test (expression ::= `'Defined') is true only if the + symbol has been defined in the definition file or by a `-D' switch on + the command line. Otherwise, the test is false. + + The equality tests are case insensitive, as are all the preprocessor + lines. + + If the symbol referenced is not defined in the symbol definitions + file, then the effect depends on whether or not switch `-u' is + specified. If so, then the symbol is treated as if it had the value + false and the test fails. If this switch is not specified, then it is + an error to reference an undefined symbol. It is also an error to + reference a symbol that is defined with a value other than `True' or + `False'. + + The use of the `not' operator inverts the sense of this logical + test, so that the lines are included only if the symbol is not defined. + The `then' keyword is optional as shown + + The `#' must be the first non-blank character on a line, but + otherwise the format is free form. Spaces or tabs may appear between + the `#' and the keyword. The keywords and the symbols are case + insensitive as in normal Ada code. Comments may be used on a + preprocessor line, but other than that, no other tokens may appear on a + preprocessor line. Any number of `elsif' clauses can be present, + including none at all. The `else' is optional, as in Ada. + + The `#' marking the start of a preprocessor line must be the first + non-blank character on the line, i.e. it must be preceded only by + spaces or horizontal tabs. + + Symbol substitution outside of preprocessor lines is obtained by + using the sequence + + $symbol + + anywhere within a source line, except in a comment or within a string + literal. The identifier following the `$' must match one of the symbols + defined in the symbol definition file, and the result is to substitute + the value of the symbol in place of `$symbol' in the output file. + + Note that although the substitution of strings within a string + literal is not possible, it is possible to have a symbol whose defined + value is a string literal. So instead of setting XYZ to `hello' and + writing: + + Header : String := "$XYZ"; + + you should set XYZ to `"hello"' and write: + + Header : String := $XYZ; + + and then the substitution will occur as desired. + +  + File: gnat_ug_vxw.info, Node: The GNAT Library Browser gnatls, Next: GNAT and Libraries, Prev: Preprocessing Using gnatprep, Up: Top + + The GNAT Library Browser `gnatls' + ********************************* + + `gnatls' is a tool that outputs information about compiled units. It + gives the relationship between objects, unit names and source files. It + can also be used to check the source dependencies of a unit as well as + various characteristics. + + * Menu: + + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + +  + File: gnat_ug_vxw.info, Node: Running gnatls, Next: Switches for gnatls, Up: The GNAT Library Browser gnatls + + Running `gnatls' + ================ + + The `gnatls' command has the form + + $ gnatls switches OBJECT_OR_ALI_FILE + + The main argument is the list of object or `ali' files (*note The Ada + Library Information Files::) for which information is requested. + + In normal mode, without additional option, `gnatls' produces a + four-column listing. Each line represents information for a specific + object. The first column gives the full path of the object, the second + column gives the name of the principal unit in this object, the third + column gives the status of the source and the fourth column gives the + full path of the source representing this unit. Here is a simple + example of use: + + $ gnatls *.o + ./demo1.o demo1 DIF demo1.adb + ./demo2.o demo2 OK demo2.adb + ./hello.o h1 OK hello.adb + ./instr-child.o instr.child MOK instr-child.adb + ./instr.o instr OK instr.adb + ./tef.o tef DIF tef.adb + ./text_io_example.o text_io_example OK text_io_example.adb + ./tgef.o tgef DIF tgef.adb + + The first line can be interpreted as follows: the main unit which is + contained in object file `demo1.o' is demo1, whose main source is in + `demo1.adb'. Furthermore, the version of the source used for the + compilation of demo1 has been modified (DIF). Each source file has a + status qualifier which can be: + + `OK (unchanged)' + The version of the source file used for the compilation of the + specified unit corresponds exactly to the actual source file. + + `MOK (slightly modified)' + The version of the source file used for the compilation of the + specified unit differs from the actual source file but not enough + to require recompilation. If you use gnatmake with the qualifier + `-m (minimal recompilation)', a file marked MOK will not be + recompiled. + + `DIF (modified)' + No version of the source found on the path corresponds to the + source used to build this object. + + `??? (file not found)' + No source file was found for this unit. + + `HID (hidden, unchanged version not first on PATH)' + The version of the source that corresponds exactly to the source + used for compilation has been found on the path but it is hidden + by another version of the same source that has been modified. + +  + File: gnat_ug_vxw.info, Node: Switches for gnatls, Next: Examples of gnatls Usage, Prev: Running gnatls, Up: The GNAT Library Browser gnatls + + Switches for `gnatls' + ===================== + + `gnatls' recognizes the following switches: + + `-a' + Consider all units, including those of the predefined Ada library. + Especially useful with `-d'. + + `-d' + List sources from which specified units depend on. + + `-h' + Output the list of options. + + `-o' + Only output information about object files. + + `-s' + Only output information about source files. + + `-u' + Only output information about compilation units. + + `-aODIR' + `-aIDIR' + `-IDIR' + `-I-' + `-nostdinc' + Source path manipulation. Same meaning as the equivalent + `gnatmake' flags (see *Note Switches for gnatmake::). + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-v' + Verbose mode. Output the complete source and object paths. Do not + use the default column layout but instead use long format giving + as much as information possible on each requested units, including + special characteristics such as: + + `Preelaborable' + The unit is preelaborable in the Ada 95 sense. + + `No_Elab_Code' + No elaboration code has been produced by the compiler for + this unit. + + `Pure' + The unit is pure in the Ada 95 sense. + + `Elaborate_Body' + The unit contains a pragma Elaborate_Body. + + `Remote_Types' + The unit contains a pragma Remote_Types. + + `Shared_Passive' + The unit contains a pragma Shared_Passive. + + `Predefined' + This unit is part of the predefined environment and cannot be + modified by the user. + + `Remote_Call_Interface' + The unit contains a pragma Remote_Call_Interface. + +  + File: gnat_ug_vxw.info, Node: Examples of gnatls Usage, Prev: Switches for gnatls, Up: The GNAT Library Browser gnatls + + Example of `gnatls' Usage + ========================= + + Example of using the verbose switch. Note how the source and object + paths are affected by the -I switch. + + $ gnatls -v -I.. demo1.o + + GNATLS 3.10w (970212) Copyright 1999 Free Software Foundation, Inc. + + Source Search Path: + + ../ + /home/comar/local/adainclude/ + + Object Search Path: + + ../ + /home/comar/local/lib/gcc-lib/mips-sni-sysv4/2.7.2/adalib/ + + ./demo1.o + Unit => + Name => demo1 + Kind => subprogram body + Flags => No_Elab_Code + Source => demo1.adb modified + + The following is an example of use of the dependency list. Note the + use of the -s switch which gives a straight list of source files. This + can be useful for building specialized scripts. + + $ gnatls -d demo2.o + ./demo2.o demo2 OK demo2.adb + OK gen_list.ads + OK gen_list.adb + OK instr.ads + OK instr-child.ads + + $ gnatls -d -s -a demo1.o + demo1.adb + /home/comar/local/adainclude/ada.ads + /home/comar/local/adainclude/a-finali.ads + /home/comar/local/adainclude/a-filico.ads + /home/comar/local/adainclude/a-stream.ads + /home/comar/local/adainclude/a-tags.ads + gen_list.ads + gen_list.adb + /home/comar/local/adainclude/gnat.ads + /home/comar/local/adainclude/g-io.ads + instr.ads + /home/comar/local/adainclude/system.ads + /home/comar/local/adainclude/s-exctab.ads + /home/comar/local/adainclude/s-finimp.ads + /home/comar/local/adainclude/s-finroo.ads + /home/comar/local/adainclude/s-secsta.ads + /home/comar/local/adainclude/s-stalib.ads + /home/comar/local/adainclude/s-stoele.ads + /home/comar/local/adainclude/s-stratt.ads + /home/comar/local/adainclude/s-tasoli.ads + /home/comar/local/adainclude/s-unstyp.ads + /home/comar/local/adainclude/unchconv.ads + +  + File: gnat_ug_vxw.info, Node: GNAT and Libraries, Next: Using the GNU make Utility, Prev: The GNAT Library Browser gnatls, Up: Top + + GNAT and Libraries + ****************** + + This chapter addresses some of the issues related to building and using + a library with GNAT. It also shows how the GNAT run-time library can be + recompiled. + + * Menu: + + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + +  + File: gnat_ug_vxw.info, Node: Creating an Ada Library, Next: Installing an Ada Library, Up: GNAT and Libraries + + Creating an Ada Library + ======================= + + In the GNAT environment, a library has two components: + * Source files. + + * Compiled code and Ali files. See *Note The Ada Library Information + Files::. + + In order to use other packages *Note The GNAT Compilation Model:: + requires a certain number of sources to be available to the compiler. + The minimal set of sources required includes the specs of all the + packages that make up the visible part of the library as well as all + the sources upon which they depend. The bodies of all visible generic + units must also be provided. + + Although it is not strictly mandatory, it is recommended that all + sources needed to recompile the library be provided, so that the user + can make full use of inter-unit inlining and source-level debugging. + This can also make the situation easier for users that need to upgrade + their compilation toolchain and thus need to recompile the library from + sources. + + The compiled code can be provided in different ways. The simplest way is + to provide directly the set of objects produced by the compiler during + the compilation of the library. It is also possible to group the objects + into an archive using whatever commands are provided by the operating + system. Finally, it is also possible to create a shared library (see + option -shared in the GCC manual). + + There are various possibilities for compiling the units that make up the + library: for example with a Makefile *Note Using the GNU make Utility::, + or with a conventional script. For simple libraries, it is also + possible to create a dummy main program which depends upon all the + packages that comprise the interface of the library. This dummy main + program can then be given to gnatmake, in order to build all the + necessary objects. Here is an example of such a dummy program and the + generic commands used to build an archive or a shared library. + + with My_Lib.Service1; + with My_Lib.Service2; + with My_Lib.Service3; + procedure My_Lib_Dummy is + begin + null; + end; + + # compiling the library + $ gnatmake -c my_lib_dummy.adb + + # we don't need the dummy object itself + $ rm my_lib_dummy.o my_lib_dummy.ali + + # create an archive with the remaining objects + $ ar rc libmy_lib.a *.o + # some systems may require "ranlib" to be run as well + + # or create a shared library + $ gcc -shared -o libmy_lib.so *.o + # some systems may require the code to have been compiled with -fPIC + + When the objects are grouped in an archive or a shared library, the user + needs to specify the desired library at link time, unless a pragma + linker_options has been used in one of the sources: + pragma Linker_Options ("-lmy_lib"); + +  + File: gnat_ug_vxw.info, Node: Installing an Ada Library, Next: Using an Ada Library, Prev: Creating an Ada Library, Up: GNAT and Libraries + + Installing an Ada Library + ========================= + + In the GNAT model, installing a library consists in copying into a + specific location the files that make up this library. It is possible + to install the sources in a different directory from the other files + (ALI, objects, archives) since the source path and the object path can + easily be specified separately. + + For general purpose libraries, it is possible for the system + administrator to put those libraries in the default compiler paths. To + achieve this, he must specify their location in the configuration files + "ada_source_path" and "ada_object_path" that must be located in the GNAT + installation tree at the same place as the gcc spec file. The location + of the gcc spec file can be determined as follows: + $ gcc -v + + The configuration files mentioned above have simple format: each line + in them must contain one unique directory name. Those names are added + to the corresponding path in their order of appearance in the file. The + names can be either absolute or relative, in the latter case, they are + relative to where theses files are located. + + "ada_source_path" and "ada_object_path" might actually not be present + in a GNAT installation, in which case, GNAT will look for its run-time + library in the directories "adainclude" for the sources and "adalib" + for the objects and ALI files. When the files exist, the compiler does + not look in "adainclude" and "adalib" at all, and thus the + "ada_source_path" file must contain the location for the GNAT run-time + sources (which can simply be "adainclude"). In the same way, the + "ada_object_path" file must contain the location for the GNAT run-time + objects (which can simply be "adalib"). + + You can also specify a new default path to the runtime library at + compilation time with the switch "-RTS=RTS-PATH". You can easily choose + and change the runtime you want your program to be compiled with. This + switch is recognized by gcc, gnatmake, gnatbind, gnatls, gnatfind and + gnatxref. + + It is possible to install a library before or after the standard GNAT + library, by reordering the lines in the configuration files. In + general, a library must be installed before the GNAT library if it + redefines any part of it. + +  + File: gnat_ug_vxw.info, Node: Using an Ada Library, Next: Creating an Ada Library to be Used in a Non-Ada Context, Prev: Installing an Ada Library, Up: GNAT and Libraries + + Using an Ada Library + ==================== + + In order to use a Ada library, you need to make sure that this library + is on both your source and object path *Note Search Paths and the + Run-Time Library (RTL):: and *Note Search Paths for gnatbind::. For + instance, you can use the library "mylib" installed in "/dir/my_lib_src" + and "/dir/my_lib_obj" with the following commands: + + $ gnatmake -aI/dir/my_lib_src -aO/dir/my_lib_obj my_appl \ + -largs -lmy_lib + + This can be simplified down to the following: + $ gnatmake my_appl + when the following conditions are met: + * "/dir/my_lib_src" has been added by the user to the environment + variable "ADA_INCLUDE_PATH", or by the administrator to the file + "ada_source_path" + + * "/dir/my_lib_obj" has been added by the user to the environment + variable "ADA_OBJECTS_PATH", or by the administrator to the file + "ada_object_path" + + * a pragma linker_options, as mentioned in *Note Creating an Ada + Library:: as been added to the sources. + +  + File: gnat_ug_vxw.info, Node: Creating an Ada Library to be Used in a Non-Ada Context, Next: Rebuilding the GNAT Run-Time Library, Prev: Using an Ada Library, Up: GNAT and Libraries + + Creating an Ada Library to be Used in a Non-Ada Context + ======================================================= + + The previous sections detailed how to create and install a library that + was usable from an Ada main program. Using this library in a non-Ada + context is not possible, because the elaboration of the library is + automatically done as part of the main program elaboration. + + GNAT also provides the ability to build libraries that can be used + both in an Ada and non-Ada context. This section describes how to + build such a library, and then how to use it from a C program. The + method for interfacing with the library from other languages such as + Fortran for instance remains the same. + + Creating the Library + -------------------- + + * Identify the units representing the interface of the library. + + Here is an example of simple library interface: + + package Interface is + + procedure Do_Something; + + procedure Do_Something_Else; + + end Interface; + + * Use `pragma Export' or `pragma Convention' for the exported + entities. + + Our package `Interface' is then updated as follow: + package Interface is + + procedure Do_Something; + pragma Export (C, Do_Something, "do_something"); + + procedure Do_Something_Else; + pragma Export (C, Do_Something_Else, "do_something_else"); + + end Interface; + + * Compile all the units composing the library. + + * Bind the library objects. + + This step is performed by invoking gnatbind with the `-L' + switch. `gnatbind' will then generate the library elaboration + procedure (named `init') and the run-time finalization + procedure (named `final'). + + # generate the binder file in Ada + $ gnatbind -Lmylib interface + + # generate the binder file in C + $ gnatbind -C -Lmylib interface + + * Compile the files generated by the binder + + $ gcc -c b~interface.adb + + * Create the library; + + The procedure is identical to the procedure explained in *Note + Creating an Ada Library::, except that `b~interface.o' needs to be + added to the list of objects. + + # create an archive file + $ ar cr libmylib.a b~interface.o + + # create a shared library + $ gcc -shared -o libmylib.so b~interface.o + + * Provide a "foreign" view of the library interface; + + The example below shows the content of `mylib_interface.h' (note + that there is no rule for the naming of this file, any name can be + used) + /* the library elaboration procedure */ + extern void mylibinit (void); + + /* the library finalization procedure */ + extern void mylibfinal (void); + + /* the interface exported by the library */ + extern void do_something (void); + extern void do_something_else (void); + + Using the Library + ----------------- + + Libraries built as explained above can be used from any program, + provided that the elaboration procedures (named `mylibinit' in the + previous example) are called before the library services are used. Any + number of libraries can be used simultaneously, as long as the + elaboration procedure of each library is called. + + Below is an example of C program that uses our `mylib' library. + + #include "mylib_interface.h" + + int + main (void) + { + /* First, elaborate the library before using it */ + mylibinit (); + + /* Main program, using the library exported entities */ + do_something (); + do_something_else (); + + /* Library finalization at the end of the program */ + mylibfinal (); + return 0; + } + + Note that this same library can be used from an equivalent Ada main + program. In addition, if the libraries are installed as detailed in + *Note Installing an Ada Library::, it is not necessary to invoke the + library elaboration and finalization routines. The binder will ensure + that this is done as part of the main program elaboration and + finalization phases. + + The Finalization Phase + ---------------------- + + Invoking any library finalization procedure generated by `gnatbind' + shuts down the Ada run time permanently. Consequently, the finalization + of all Ada libraries must be performed at the end of the program. No + call to these libraries nor the Ada run time should be made past the + finalization phase. + + Restrictions in Libraries + ------------------------- + + The pragmas listed below should be used with caution inside libraries, + as they can create incompatibilities with other Ada libraries: + * pragma `Locking_Policy' + + * pragma `Queuing_Policy' + + * pragma `Task_Dispatching_Policy' + + * pragma `Unreserve_All_Interrupts' + When using a library that contains such pragmas, the user must make + sure that all libraries use the same pragmas with the same values. + Otherwise, a `Program_Error' will be raised during the elaboration of + the conflicting libraries. The usage of these pragmas and its + consequences for the user should therefore be well documented. + + Similarly, the traceback in exception occurrences mechanism should be + enabled or disabled in a consistent manner across all libraries. + Otherwise, a Program_Error will be raised during the elaboration of the + conflicting libraries. + + If the `'Version' and `'Body_Version' attributes are used inside a + library, then it is necessary to perform a `gnatbind' step that + mentions all ali files in all libraries, so that version identifiers + can be properly computed. In practice these attributes are rarely + used, so this is unlikely to be a consideration. + +  + File: gnat_ug_vxw.info, Node: Rebuilding the GNAT Run-Time Library, Prev: Creating an Ada Library to be Used in a Non-Ada Context, Up: GNAT and Libraries + + Rebuilding the GNAT Run-Time Library + ==================================== + + It may be useful to recompile the GNAT library in various contexts, the + most important one being the use of partition-wide configuration pragmas + such as Normalize_Scalar. A special Makefile called `Makefile.adalib' + is provided to that effect and can be found in the directory containing + the GNAT library. The location of this directory depends on the way the + GNAT environment has been installed and can be determined by means of + the command: + + $ gnatls -v + + The last entry in the object search path usually contains the gnat + library. This Makefile contains its own documentation and in particular + the set of instructions needed to rebuild a new library and to use it. + +  + File: gnat_ug_vxw.info, Node: Using the GNU make Utility, Next: Finding Memory Problems with GNAT Debug Pool, Prev: GNAT and Libraries, Up: Top + + Using the GNU `make' Utility + **************************** + + This chapter offers some examples of makefiles that solve specific + problems. It does not explain how to write a makefile (see the GNU make + documentation), nor does it try to replace the `gnatmake' utility + (*note The GNAT Make Program gnatmake::). + + All the examples in this section are specific to the GNU version of + make. Although `make' is a standard utility, and the basic language is + the same, these examples use some advanced features found only in `GNU + make'. + + * Menu: + + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + +  + File: gnat_ug_vxw.info, Node: Using gnatmake in a Makefile, Next: Automatically Creating a List of Directories, Up: Using the GNU make Utility + + Using gnatmake in a Makefile + ============================ + + Complex project organizations can be handled in a very powerful way by + using GNU make combined with gnatmake. For instance, here is a Makefile + which allows you to build each subsystem of a big project into a + separate shared library. Such a makefile allows you to significantly + reduce the link time of very big applications while maintaining full + coherence at each step of the build process. + + The list of dependencies are handled automatically by `gnatmake'. + The Makefile is simply used to call gnatmake in each of the appropriate + directories. + + Note that you should also read the example on how to automatically + create the list of directories (*note Automatically Creating a List of + Directories::) which might help you in case your project has a lot of + subdirectories. + + ## This Makefile is intended to be used with the following directory + ## configuration: + ## - The sources are split into a series of csc (computer software components) + ## Each of these csc is put in its own directory. + ## Their name are referenced by the directory names. + ## They will be compiled into shared library (although this would also work + ## with static libraries + ## - The main program (and possibly other packages that do not belong to any + ## csc is put in the top level directory (where the Makefile is). + ## toplevel_dir __ first_csc (sources) __ lib (will contain the library) + ## \_ second_csc (sources) __ lib (will contain the library) + ## \_ ... + ## Although this Makefile is build for shared library, it is easy to modify + ## to build partial link objects instead (modify the lines with -shared and + ## gnatlink below) + ## + ## With this makefile, you can change any file in the system or add any new + ## file, and everything will be recompiled correctly (only the relevant shared + ## objects will be recompiled, and the main program will be re-linked). + + # The list of computer software component for your project. This might be + # generated automatically. + CSC_LIST=aa bb cc + + # Name of the main program (no extension) + MAIN=main + + # If we need to build objects with -fPIC, uncomment the following line + #NEED_FPIC=-fPIC + + # The following variable should give the directory containing libgnat.so + # You can get this directory through 'gnatls -v'. This is usually the last + # directory in the Object_Path. + GLIB=... + + # The directories for the libraries + # (This macro expands the list of CSC to the list of shared libraries, you + # could simply use the expanded form : + # LIB_DIR=aa/lib/libaa.so bb/lib/libbb.so cc/lib/libcc.so + LIB_DIR=${foreach dir,${CSC_LIST},${dir}/lib/lib${dir}.so} + + ${MAIN}: objects ${LIB_DIR} + gnatbind ${MAIN} ${CSC_LIST:%=-aO%/lib} -shared + gnatlink ${MAIN} ${CSC_LIST:%=-l%} + + objects:: + # recompile the sources + gnatmake -c -i ${MAIN}.adb ${NEED_FPIC} ${CSC_LIST:%=-I%} + + # Note: In a future version of GNAT, the following commands will be simplified + # by a new tool, gnatmlib + ${LIB_DIR}: + mkdir -p ${dir $@ } + cd ${dir $@ }; gcc -shared -o ${notdir $@ } ../*.o -L${GLIB} -lgnat + cd ${dir $@ }; cp -f ../*.ali . + + # The dependencies for the modules + # Note that we have to force the expansion of *.o, since in some cases make won't + # be able to do it itself. + aa/lib/libaa.so: ${wildcard aa/*.o} + bb/lib/libbb.so: ${wildcard bb/*.o} + cc/lib/libcc.so: ${wildcard cc/*.o} + + # Make sure all of the shared libraries are in the path before starting the + # program + run:: + LD_LIBRARY_PATH=`pwd`/aa/lib:`pwd`/bb/lib:`pwd`/cc/lib ./${MAIN} + + clean:: + ${RM} -rf ${CSC_LIST:%=%/lib} + ${RM} ${CSC_LIST:%=%/*.ali} + ${RM} ${CSC_LIST:%=%/*.o} + ${RM} *.o *.ali ${MAIN} + +  + File: gnat_ug_vxw.info, Node: Automatically Creating a List of Directories, Next: Generating the Command Line Switches, Prev: Using gnatmake in a Makefile, Up: Using the GNU make Utility + + Automatically Creating a List of Directories + ============================================ + + In most makefiles, you will have to specify a list of directories, and + store it in a variable. For small projects, it is often easier to + specify each of them by hand, since you then have full control over what + is the proper order for these directories, which ones should be + included... + + However, in larger projects, which might involve hundreds of + subdirectories, it might be more convenient to generate this list + automatically. + + The example below presents two methods. The first one, although less + general, gives you more control over the list. It involves wildcard + characters, that are automatically expanded by `make'. Its shortcoming + is that you need to explicitly specify some of the organization of your + project, such as for instance the directory tree depth, whether some + directories are found in a separate tree,... + + The second method is the most general one. It requires an external + program, called `find', which is standard on all Unix systems. All the + directories found under a given root directory will be added to the + list. + + # The examples below are based on the following directory hierarchy: + # All the directories can contain any number of files + # ROOT_DIRECTORY -> a -> aa -> aaa + # -> ab + # -> ac + # -> b -> ba -> baa + # -> bb + # -> bc + # This Makefile creates a variable called DIRS, that can be reused any time + # you need this list (see the other examples in this section) + + # The root of your project's directory hierarchy + ROOT_DIRECTORY=. + + #### + # First method: specify explicitly the list of directories + # This allows you to specify any subset of all the directories you need. + #### + + DIRS := a/aa/ a/ab/ b/ba/ + + #### + # Second method: use wildcards + # Note that the argument(s) to wildcard below should end with a '/'. + # Since wildcards also return file names, we have to filter them out + # to avoid duplicate directory names. + # We thus use make's `dir' and `sort' functions. + # It sets DIRs to the following value (note that the directories aaa and baa + # are not given, unless you change the arguments to wildcard). + # DIRS= ./a/a/ ./b/ ./a/aa/ ./a/ab/ ./a/ac/ ./b/ba/ ./b/bb/ ./b/bc/ + #### + + DIRS := ${sort ${dir ${wildcard ${ROOT_DIRECTORY}/*/ ${ROOT_DIRECTORY}/*/*/}}} + + #### + # Third method: use an external program + # This command is much faster if run on local disks, avoiding NFS slowdowns. + # This is the most complete command: it sets DIRs to the following value: + # DIRS= ./a ./a/aa ./a/aa/aaa ./a/ab ./a/ac ./b ./b/ba ./b/ba/baa ./b/bb ./b/bc + #### + + DIRS := ${shell find ${ROOT_DIRECTORY} -type d -print} + +  + File: gnat_ug_vxw.info, Node: Generating the Command Line Switches, Next: Overcoming Command Line Length Limits, Prev: Automatically Creating a List of Directories, Up: Using the GNU make Utility + + Generating the Command Line Switches + ==================================== + + Once you have created the list of directories as explained in the + previous section (*note Automatically Creating a List of Directories::), + you can easily generate the command line arguments to pass to gnatmake. + + For the sake of completeness, this example assumes that the source + path is not the same as the object path, and that you have two separate + lists of directories. + + # see "Automatically creating a list of directories" to create + # these variables + SOURCE_DIRS= + OBJECT_DIRS= + + GNATMAKE_SWITCHES := ${patsubst %,-aI%,${SOURCE_DIRS}} + GNATMAKE_SWITCHES += ${patsubst %,-aO%,${OBJECT_DIRS}} + + all: + gnatmake ${GNATMAKE_SWITCHES} main_unit + +  + File: gnat_ug_vxw.info, Node: Overcoming Command Line Length Limits, Prev: Generating the Command Line Switches, Up: Using the GNU make Utility + + Overcoming Command Line Length Limits + ===================================== + + One problem that might be encountered on big projects is that many + operating systems limit the length of the command line. It is thus hard + to give gnatmake the list of source and object directories. + + This example shows how you can set up environment variables, which + will make `gnatmake' behave exactly as if the directories had been + specified on the command line, but have a much higher length limit (or + even none on most systems). + + It assumes that you have created a list of directories in your + Makefile, using one of the methods presented in *Note Automatically + Creating a List of Directories::. For the sake of completeness, we + assume that the object path (where the ALI files are found) is + different from the sources patch. + + Note a small trick in the Makefile below: for efficiency reasons, we + create two temporary variables (SOURCE_LIST and OBJECT_LIST), that are + expanded immediately by `make'. This way we overcome the standard make + behavior which is to expand the variables only when they are actually + used. + + # In this example, we create both ADA_INCLUDE_PATH and ADA_OBJECT_PATH. + # This is the same thing as putting the -I arguments on the command line. + # (the equivalent of using -aI on the command line would be to define + # only ADA_INCLUDE_PATH, the equivalent of -aO is ADA_OBJECT_PATH). + # You can of course have different values for these variables. + # + # Note also that we need to keep the previous values of these variables, since + # they might have been set before running 'make' to specify where the GNAT + # library is installed. + + # see "Automatically creating a list of directories" to create these + # variables + SOURCE_DIRS= + OBJECT_DIRS= + + empty:= + space:=${empty} ${empty} + SOURCE_LIST := ${subst ${space},:,${SOURCE_DIRS}} + OBJECT_LIST := ${subst ${space},:,${OBJECT_DIRS}} + ADA_INCLUDE_PATH += ${SOURCE_LIST} + ADA_OBJECT_PATH += ${OBJECT_LIST} + export ADA_INCLUDE_PATH + export ADA_OBJECT_PATH + + all: + gnatmake main_unit + +  + File: gnat_ug_vxw.info, Node: Finding Memory Problems with GNAT Debug Pool, Next: Creating Sample Bodies Using gnatstub, Prev: Using the GNU make Utility, Up: Top + + Finding Memory Problems with GNAT Debug Pool + ******************************************** + + The use of unchecked deallocation and unchecked conversion can easily + lead to incorrect memory references. The problems generated by such + references are usually difficult to tackle because the symptoms can be + very remote from the origin of the problem. In such cases, it is very + helpful to detect the problem as early as possible. This is the purpose + of the Storage Pool provided by `GNAT.Debug_Pools'. + + In order to use the GNAT specific debugging pool, the user must + associate a debug pool object with each of the access types that may be + related to suspected memory problems. See Ada Reference Manual 13.11. + type Ptr is access Some_Type; + Pool : GNAT.Debug_Pools.Debug_Pool; + for Ptr'Storage_Pool use Pool; + + `GNAT.Debug_Pools' is derived from of a GNAT-specific kind of pool: + the Checked_Pool. Such pools, like standard Ada storage pools, allow + the user to redefine allocation and deallocation strategies. They also + provide a checkpoint for each dereference, through the use of the + primitive operation `Dereference' which is implicitly called at each + dereference of an access value. + + Once an access type has been associated with a debug pool, + operations on values of the type may raise four distinct exceptions, + which correspond to four potential kinds of memory corruption: + * `GNAT.Debug_Pools.Accessing_Not_Allocated_Storage' + + * `GNAT.Debug_Pools.Accessing_Deallocated_Storage' + + * `GNAT.Debug_Pools.Freeing_Not_Allocated_Storage' + + * `GNAT.Debug_Pools.Freeing_Deallocated_Storage ' + + For types associated with a Debug_Pool, dynamic allocation is performed + using the standard GNAT allocation routine. References to all allocated + chunks of memory are kept in an internal dictionary. The deallocation + strategy consists in not releasing the memory to the underlying system + but rather to fill it with a memory pattern easily recognizable during + debugging sessions: The memory pattern is the old IBM hexadecimal + convention: 16#DEADBEEF#. Upon each dereference, a check is made that + the access value denotes a properly allocated memory location. Here is + a complete example of use of `Debug_Pools', that includes typical + instances of memory corruption: + with Gnat.Io; use Gnat.Io; + with Unchecked_Deallocation; + with Unchecked_Conversion; + with GNAT.Debug_Pools; + with System.Storage_Elements; + with Ada.Exceptions; use Ada.Exceptions; + procedure Debug_Pool_Test is + + type T is access Integer; + type U is access all T; + + P : GNAT.Debug_Pools.Debug_Pool; + for T'Storage_Pool use P; + + procedure Free is new Unchecked_Deallocation (Integer, T); + function UC is new Unchecked_Conversion (U, T); + A, B : aliased T; + + procedure Info is new GNAT.Debug_Pools.Print_Info(Put_Line); + + begin + Info (P); + A := new Integer; + B := new Integer; + B := A; + Info (P); + Free (A); + begin + Put_Line (Integer'Image(B.all)); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + begin + Free (B); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + B := UC(A'Access); + begin + Put_Line (Integer'Image(B.all)); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + begin + Free (B); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + Info (P); + end Debug_Pool_Test; + + The debug pool mechanism provides the following precise diagnostics on + the execution of this erroneous program: + Debug Pool info: + Total allocated bytes : 0 + Total deallocated bytes : 0 + Current Water Mark: 0 + High Water Mark: 0 + + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 0 + Current Water Mark: 8 + High Water Mark: 8 + + raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 4 + Current Water Mark: 4 + High Water Mark: 8 + +  + File: gnat_ug_vxw.info, Node: Creating Sample Bodies Using gnatstub, Next: Reducing the Size of Ada Executables with gnatelim, Prev: Finding Memory Problems with GNAT Debug Pool, Up: Top + + Creating Sample Bodies Using `gnatstub' + *************************************** + + `gnatstub' creates body stubs, that is, empty but compilable bodies for + library unit declarations. + + To create a body stub, `gnatstub' has to compile the library unit + declaration. Therefore, bodies can be created only for legal library + units. Moreover, if a library unit depends semantically upon units + located outside the current directory, you have to provide the source + search path when calling `gnatstub', see the description of `gnatstub' + switches below. + + * Menu: + + * Running gnatstub:: + * Switches for gnatstub:: + +  + File: gnat_ug_vxw.info, Node: Running gnatstub, Next: Switches for gnatstub, Up: Creating Sample Bodies Using gnatstub + + Running `gnatstub' + ================== + + `gnatstub' has the command-line interface of the form + + $ gnatstub [switches] filename [directory] + + where + `filename' + is the name of the source file that contains a library unit + declaration for which a body must be created. This name should + follow the GNAT file name conventions. No crunching is allowed for + this file name. The file name may contain the path information. + + `directory' + indicates the directory to place a body stub (default is the + current directory) + + `switches' + is an optional sequence of switches as described in the next + section + +  + File: gnat_ug_vxw.info, Node: Switches for gnatstub, Prev: Running gnatstub, Up: Creating Sample Bodies Using gnatstub + + Switches for `gnatstub' + ======================= + + `-f' + If the destination directory already contains a file with a name + of the body file for the argument spec file, replace it with the + generated body stub. + + `-hs' + Put the comment header (i.e. all the comments preceding the + compilation unit) from the source of the library unit declaration + into the body stub. + + `-hg' + Put a sample comment header into the body stub. + + `-IDIR' + `-I-' + These switches have the same meaning as in calls to gcc. They + define the source search path in the call to gcc issued by + `gnatstub' to compile an argument source file. + + `-iN' + (N is a decimal natural number). Set the indentation level in the + generated body sample to n, '-i0' means "no indentation", the + default indentation is 3. + + `-k' + Do not remove the tree file (i.e. the snapshot of the compiler + internal structures used by `gnatstub') after creating the body + stub. + + `-lN' + (N is a decimal positive number) Set the maximum line length in the + body stub to n, the default is 78. + + `-q' + Quiet mode: do not generate a confirmation when a body is + successfully created or a message when a body is not required for + an argument unit. + + `-r' + Reuse the tree file (if it exists) instead of creating it: instead + of creating the tree file for the library unit declaration, + gnatstub tries to find it in the current directory and use it for + creating a body. If the tree file is not found, no body is + created. `-r' also implies `-k', whether or not `-k' is set + explicitly. + + `-t' + Overwrite the existing tree file: if the current directory already + contains the file which, according to the GNAT file name rules + should be considered as a tree file for the argument source file, + gnatstub will refuse to create the tree file needed to create a + body sampler, unless `-t' option is set + + `-v' + Verbose mode: generate version information. + +  + File: gnat_ug_vxw.info, Node: Reducing the Size of Ada Executables with gnatelim, Next: Other Utility Programs, Prev: Creating Sample Bodies Using gnatstub, Up: Top + + Reducing the Size of Ada Executables with `gnatelim' + **************************************************** + + * Menu: + + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + +  + File: gnat_ug_vxw.info, Node: About gnatelim, Next: Eliminate Pragma, Up: Reducing the Size of Ada Executables with gnatelim + + About `gnatelim' + ================ + + When a program shares a set of Ada packages with other programs, it may + happen that this program uses only a fraction of the subprograms + defined in these packages. The code created for these unused + subprograms increases the size of the executable. + + `gnatelim' tracks unused subprograms in an Ada program and outputs a + list of GNAT-specific `Eliminate' pragmas (see next section) marking + all the subprograms that are declared but never called. By placing the + list of `Eliminate' pragmas in the GNAT configuration file `gnat.adc' + and recompiling your program, you may decrease the size of its + executable, because the compiler will not generate the code for + 'eliminated' subprograms. + + `gnatelim' needs as its input data a set of tree files (see *Note + Tree Files::) representing all the components of a program to process + and a bind file for a main subprogram (see *Note Preparing Tree and + Bind Files for gnatelim::). + +  + File: gnat_ug_vxw.info, Node: Eliminate Pragma, Next: Tree Files, Prev: About gnatelim, Up: Reducing the Size of Ada Executables with gnatelim + + `Eliminate' Pragma + ================== + + The simplified syntax of the Eliminate pragma used by `gnatelim' is: + + pragma Eliminate (Library_Unit_Name, Subprogram_Name); + + where + `Library_Unit_Name' + full expanded Ada name of a library unit + + `Subprogram_Name' + a simple or expanded name of a subprogram declared within this + compilation unit + + The effect of an `Eliminate' pragma placed in the GNAT configuration + file `gnat.adc' is: + + * If the subprogram `Subprogram_Name' is declared within the library + unit `Library_Unit_Name', the compiler will not generate code for + this subprogram. This applies to all overloaded subprograms denoted + by `Subprogram_Name'. + + * If a subprogram marked by the pragma `Eliminate' is used (called) + in a program, the compiler will produce an error message in the + place where it is called. + +  + File: gnat_ug_vxw.info, Node: Tree Files, Next: Preparing Tree and Bind Files for gnatelim, Prev: Eliminate Pragma, Up: Reducing the Size of Ada Executables with gnatelim + + Tree Files + ========== + + A tree file stores a snapshot of the compiler internal data structures + at the very end of a successful compilation. It contains all the + syntactic and semantic information for the compiled unit and all the + units upon which it depends semantically. To use tools that make use + of tree files, you need to first produce the right set of tree files. + + GNAT produces correct tree files when -gnatt -gnatc options are set + in a gcc call. The tree files have an .adt extension. Therefore, to + produce a tree file for the compilation unit contained in a file named + `foo.adb', you must use the command + + $ gcc -c -gnatc -gnatt foo.adb + + and you will get the tree file `foo.adt'. compilation. + +  + File: gnat_ug_vxw.info, Node: Preparing Tree and Bind Files for gnatelim, Next: Running gnatelim, Prev: Tree Files, Up: Reducing the Size of Ada Executables with gnatelim + + Preparing Tree and Bind Files for `gnatelim' + ============================================ + + A set of tree files covering the program to be analyzed with `gnatelim' + and the bind file for the main subprogram does not have to be in the + current directory. '-T' gnatelim option may be used to provide the + search path for tree files, and '-b' option may be used to point to the + bind file to process (see *Note Running gnatelim::) + + If you do not have the appropriate set of tree files and the right + bind file, you may create them in the current directory using the + following procedure. + + Let `Main_Prog' be the name of a main subprogram, and suppose this + subprogram is in a file named `main_prog.adb'. + + To create a bind file for `gnatelim', run `gnatbind' for the main + subprogram. `gnatelim' can work with both Ada and C bind files; when + both are present, it uses the Ada bind file. The following commands + will build the program and create the bind file: + + $ gnatmake -c Main_Prog + $ gnatbind main_prog + + To create a minimal set of tree files covering the whole program, call + `gnatmake' for this program as follows: + + $ gnatmake -f -c -gnatc -gnatt Main_Prog + + The `-c' gnatmake option turns off the bind and link steps, that are + useless anyway because the sources are compiled with `-gnatc' option + which turns off code generation. + + The `-f' gnatmake option forces recompilation of all the needed + sources. + + This sequence of actions will create all the data needed by + `gnatelim' from scratch and therefore guarantee its consistency. If you + would like to use some existing set of files as `gnatelim' output, you + must make sure that the set of files is complete and consistent. You + can use the `-m' switch to check if there are missed tree files + + Note, that `gnatelim' needs neither object nor ALI files. + +  + File: gnat_ug_vxw.info, Node: Running gnatelim, Next: Correcting the List of Eliminate Pragmas, Prev: Preparing Tree and Bind Files for gnatelim, Up: Reducing the Size of Ada Executables with gnatelim + + Running `gnatelim' + ================== + + `gnatelim' has the following command-line interface: + + $ gnatelim [options] name + + `name' should be a full expanded Ada name of a main subprogram of a + program (partition). + + `gnatelim' options: + + `-q' + Quiet mode: by default `gnatelim' generates to the standard error + stream a trace of the source file names of the compilation units + being processed. This option turns this trace off. + + `-v' + Verbose mode: `gnatelim' version information is printed as Ada + comments to the standard output stream. + + `-a' + Also look for subprograms from the GNAT run time that can be + eliminated. + + `-m' + Check if any tree files are missing for an accurate result. + + `-TDIR' + When looking for tree files also look in directory DIR + + `-bBIND_FILE' + Specifies BIND_FILE as the bind file to process. If not set, the + name of the bind file is computed from the full expanded Ada name + of a main subprogram. + + `-dX' + Activate internal debugging switches. X is a letter or digit, or + string of letters or digits, which specifies the type of debugging + mode desired. Normally these are used only for internal + development or system debugging purposes. You can find full + documentation for these switches in the body of the + `Gnatelim.Options' unit in the compiler source file + `gnatelim-options.adb'. + + `gnatelim' sends its output to the standard output stream, and all the + tracing and debug information is sent to the standard error stream. In + order to produce a proper GNAT configuration file `gnat.adc', + redirection must be used: + + $ gnatelim Main_Prog > gnat.adc + + or + + $ gnatelim Main_Prog >> gnat.adc + + In order to append the `gnatelim' output to the existing contents of + `gnat.adc'. + +  + File: gnat_ug_vxw.info, Node: Correcting the List of Eliminate Pragmas, Next: Making Your Executables Smaller, Prev: Running gnatelim, Up: Reducing the Size of Ada Executables with gnatelim + + Correcting the List of Eliminate Pragmas + ======================================== + + In some rare cases it may happen that `gnatelim' will try to eliminate + subprograms which are actually called in the program. In this case, the + compiler will generate an error message of the form: + + file.adb:106:07: cannot call eliminated subprogram "My_Prog" + + You will need to manually remove the wrong `Eliminate' pragmas from the + `gnat.adc' file. It is advised that you recompile your program from + scratch after that because you need a consistent `gnat.adc' file during + the entire compilation. + +  + File: gnat_ug_vxw.info, Node: Making Your Executables Smaller, Next: Summary of the gnatelim Usage Cycle, Prev: Correcting the List of Eliminate Pragmas, Up: Reducing the Size of Ada Executables with gnatelim + + Making Your Executables Smaller + =============================== + + In order to get a smaller executable for your program you now have to + recompile the program completely with the new `gnat.adc' file created + by `gnatelim' in your current directory: + + $ gnatmake -f Main_Prog + + (you will need `-f' option for gnatmake to recompile everything with + the set of pragmas `Eliminate' you have obtained with `gnatelim'). + + Be aware that the set of `Eliminate' pragmas is specific to each + program. It is not recommended to merge sets of `Eliminate' pragmas + created for different programs in one `gnat.adc' file. + +  + File: gnat_ug_vxw.info, Node: Summary of the gnatelim Usage Cycle, Prev: Making Your Executables Smaller, Up: Reducing the Size of Ada Executables with gnatelim + + Summary of the gnatelim Usage Cycle + =================================== + + Here is a quick summary of the steps to be taken in order to reduce the + size of your executables with `gnatelim'. You may use other GNAT + options to control the optimization level, to produce the debugging + information, to set search path, etc. + + 1. Produce a bind file and a set of tree files + + $ gnatmake -c Main_Prog + $ gnatbind main_prog + $ gnatmake -f -c -gnatc -gnatt Main_Prog + + 2. Generate a list of `Eliminate' pragmas + $ gnatelim Main_Prog >[>] gnat.adc + + 3. Recompile the application + + $ gnatmake -f Main_Prog + + +  + File: gnat_ug_vxw.info, Node: Other Utility Programs, Next: Running and Debugging Ada Programs, Prev: Reducing the Size of Ada Executables with gnatelim, Up: Top + + Other Utility Programs + ********************** + + This chapter discusses some other utility programs available in the Ada + environment. + + * Menu: + + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * Installing gnathtml:: + +  + File: gnat_ug_vxw.info, Node: Using Other Utility Programs with GNAT, Next: The gnatpsta Utility Program, Up: Other Utility Programs + + Using Other Utility Programs with GNAT + ====================================== + + The object files generated by GNAT are in standard system format and in + particular the debugging information uses this format. This means + programs generated by GNAT can be used with existing utilities that + depend on these formats. + + In general, any utility program that works with C will also often + work with Ada programs generated by GNAT. This includes software + utilities such as gprof (a profiling program), `gdb' (the FSF + debugger), and utilities such as Purify. + +  + File: gnat_ug_vxw.info, Node: The gnatpsta Utility Program, Next: The External Symbol Naming Scheme of GNAT, Prev: Using Other Utility Programs with GNAT, Up: Other Utility Programs + + The `gnatpsta' Utility Program + ============================== + + Many of the definitions in package Standard are + implementation-dependent. However, the source of this package does not + exist as an Ada source file, so these values cannot be determined by + inspecting the source. They can be determined by examining in detail + the coding of `cstand.adb' which creates the image of Standard in the + compiler, but this is awkward and requires a great deal of internal + knowledge about the system. + + The `gnatpsta' utility is designed to deal with this situation. It + is an Ada program that dynamically determines the values of all the + relevant parameters in Standard, and prints them out in the form of an + Ada source listing for Standard, displaying all the values of interest. + This output is generated to `stdout'. + + To determine the value of any parameter in package Standard, simply + run `gnatpsta' with no qualifiers or arguments, and examine the output. + This is preferable to consulting documentation, because you know that + the values you are getting are the actual ones provided by the + executing system. + +  + File: gnat_ug_vxw.info, Node: The External Symbol Naming Scheme of GNAT, Next: Ada Mode for Glide, Prev: The gnatpsta Utility Program, Up: Other Utility Programs + + The External Symbol Naming Scheme of GNAT + ========================================= + + In order to interpret the output from GNAT, when using tools that are + originally intended for use with other languages, it is useful to + understand the conventions used to generate link names from the Ada + entity names. + + All link names are in all lowercase letters. With the exception of + library procedure names, the mechanism used is simply to use the full + expanded Ada name with dots replaced by double underscores. For + example, suppose we have the following package spec: + + package QRS is + MN : Integer; + end QRS; + + The variable `MN' has a full expanded Ada name of `QRS.MN', so the + corresponding link name is `qrs__mn'. Of course if a `pragma Export' + is used this may be overridden: + + package Exports is + Var1 : Integer; + pragma Export (Var1, C, External_Name => "var1_name"); + Var2 : Integer; + pragma Export (Var2, C, Link_Name => "var2_link_name"); + end Exports; + + In this case, the link name for VAR1 is whatever link name the C + compiler would assign for the C function VAR1_NAME. This typically + would be either VAR1_NAME or _VAR1_NAME, depending on operating system + conventions, but other possibilities exist. The link name for VAR2 is + VAR2_LINK_NAME, and this is not operating system dependent. + + One exception occurs for library level procedures. A potential + ambiguity arises between the required name `_main' for the C main + program, and the name we would otherwise assign to an Ada library level + procedure called `Main' (which might well not be the main program). + + To avoid this ambiguity, we attach the prefix `_ada_' to such names. + So if we have a library level procedure such as + + procedure Hello (S : String); + + the external name of this procedure will be _ADA_HELLO. + +  + File: gnat_ug_vxw.info, Node: Ada Mode for Glide, Next: Converting Ada Files to html with gnathtml, Prev: The External Symbol Naming Scheme of GNAT, Up: Other Utility Programs + + Ada Mode for `Glide' + ==================== + + The Glide mode for programming in Ada (both, Ada83 and Ada95) helps the + user in understanding existing code and facilitates writing new code. It + furthermore provides some utility functions for easier integration of + standard Emacs features when programming in Ada. + + General Features: + ----------------- + + * Full Integrated Development Environment : + + * support of 'project files' for the configuration (directories, + compilation options,...) + + * compiling and stepping through error messages. + + * running and debugging your applications within Glide. + + * easy to use for beginners by pull-down menus, + + * user configurable by many user-option variables. + + Ada Mode Features That Help Understanding Code: + ----------------------------------------------- + + * functions for easy and quick stepping through Ada code, + + * getting cross reference information for identifiers (e.g. find the + defining place by a keystroke), + + * displaying an index menu of types and subprograms and move point to + the chosen one, + + * automatic color highlighting of the various entities in Ada code. + + Glide Support for Writing Ada Code: + ----------------------------------- + + * switching between spec and body files with possible autogeneration + of body files, + + * automatic formating of subprograms parameter lists. + + * automatic smart indentation according to Ada syntax, + + * automatic completion of identifiers, + + * automatic casing of identifiers, keywords, and attributes, + + * insertion of statement templates, + + * filling comment paragraphs like filling normal text, + + For more information, please refer to the online Glide documentation + available in the Glide -> Help Menu. + +  + File: gnat_ug_vxw.info, Node: Converting Ada Files to html with gnathtml, Next: Installing gnathtml, Prev: Ada Mode for Glide, Up: Other Utility Programs + + Converting Ada Files to html with `gnathtml' + ============================================ + + This `Perl' script allows Ada source files to be browsed using standard + Web browsers. For installation procedure, see the section *Note + Installing gnathtml::. + + Ada reserved keywords are highlighted in a bold font and Ada + comments in a blue font. Unless your program was compiled with the gcc + `-gnatx' switch to suppress the generation of cross-referencing + information, user defined variables and types will appear in a + different color; you will be able to click on any identifier and go to + its declaration. + + The command line is as follow: + $ perl gnathtml.pl [switches] ada-files + + You can pass it as many Ada files as you want. `gnathtml' will + generate an html file for every ada file, and a global file called + `index.htm'. This file is an index of every identifier defined in the + files. + + The available switches are the following ones : + + `-83' + Only the subset on the Ada 83 keywords will be highlighted, not + the full Ada 95 keywords set. + + `-cc COLOR' + This option allows you to change the color used for comments. The + default value is green. The color argument can be any name + accepted by html. + + `-d' + If the ada files depend on some other files (using for instance the + `with' command, the latter will also be converted to html. Only + the files in the user project will be converted to html, not the + files in the run-time library itself. + + `-D' + This command is the same as -d above, but `gnathtml' will also look + for files in the run-time library, and generate html files for + them. + + `-f' + By default, gnathtml will generate html links only for global + entities ('with'ed units, global variables and types,...). If you + specify the `-f' on the command line, then links will be generated + for local entities too. + + `-l NUMBER' + If this switch is provided and NUMBER is not 0, then `gnathtml' + will number the html files every NUMBER line. + + `-I DIR' + Specify a directory to search for library files (`.ali' files) and + source files. You can provide several -I switches on the command + line, and the directories will be parsed in the order of the + command line. + + `-o DIR' + Specify the output directory for html files. By default, gnathtml + will saved the generated html files in a subdirectory named + `html/'. + + `-p FILE' + If you are using Emacs and the most recent Emacs Ada mode, which + provides a full Integrated Development Environment for compiling, + checking, running and debugging applications, you may be using + `.adp' files to give the directories where Emacs can find sources + and object files. + + Using this switch, you can tell gnathtml to use these files. This + allows you to get an html version of your application, even if it + is spread over multiple directories. + + `-sc COLOR' + This option allows you to change the color used for symbol + definitions. The default value is red. The color argument can be + any name accepted by html. + + `-t FILE' + This switch provides the name of a file. This file contains a list + of file names to be converted, and the effect is exactly as though + they had appeared explicitly on the command line. This is the + recommended way to work around the command line length limit on + some systems. + +  + File: gnat_ug_vxw.info, Node: Installing gnathtml, Prev: Converting Ada Files to html with gnathtml, Up: Other Utility Programs + + Installing `gnathtml' + ===================== + + `Perl' needs to be installed on your machine to run this script. + `Perl' is freely available for almost every architecture and Operating + System via the Internet. + + On Unix systems, you may want to modify the first line of the + script `gnathtml', to explicitly tell the Operating system where + Perl is. The syntax of this line is : + #!full_path_name_to_perl + + Alternatively, you may run the script using the following command line: + + $ perl gnathtml.pl [switches] files + +  + File: gnat_ug_vxw.info, Node: Running and Debugging Ada Programs, Next: Inline Assembler, Prev: Other Utility Programs, Up: Top + + Running and Debugging Ada Programs + ********************************** + + This chapter discusses how to debug Ada programs. An incorrect Ada + program may be handled in three ways by the GNAT compiler: + + 1. The illegality may be a violation of the static semantics of Ada. + In that case GNAT diagnoses the constructs in the program that are + illegal. It is then a straightforward matter for the user to + modify those parts of the program. + + 2. The illegality may be a violation of the dynamic semantics of Ada. + In that case the program compiles and executes, but may generate + incorrect results, or may terminate abnormally with some exception. + + 3. When presented with a program that contains convoluted errors, GNAT + itself may terminate abnormally without providing full diagnostics + on the incorrect user program. + + * Menu: + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + +  + File: gnat_ug_vxw.info, Node: The GNAT Debugger GDB, Next: Running GDB, Up: Running and Debugging Ada Programs + + The GNAT Debugger GDB + ===================== + + `GDB' is a general purpose, platform-independent debugger that can be + used to debug mixed-language programs compiled with `GCC', and in + particular is capable of debugging Ada programs compiled with GNAT. The + latest versions of `GDB' are Ada-aware and can handle complex Ada data + structures. + + The manual `Debugging with GDB' contains full details on the usage + of `GDB', including a section on its usage on programs. This manual + should be consulted for full details. The section that follows is a + brief introduction to the philosophy and use of `GDB'. + + When GNAT programs are compiled, the compiler optionally writes + debugging information into the generated object file, including + information on line numbers, and on declared types and variables. This + information is separate from the generated code. It makes the object + files considerably larger, but it does not add to the size of the + actual executable that will be loaded into memory, and has no impact on + run-time performance. The generation of debug information is triggered + by the use of the -g switch in the gcc or gnatmake command used to + carry out the compilations. It is important to emphasize that the use + of these options does not change the generated code. + + The debugging information is written in standard system formats that + are used by many tools, including debuggers and profilers. The format + of the information is typically designed to describe C types and + semantics, but GNAT implements a translation scheme which allows full + details about Ada types and variables to be encoded into these standard + C formats. Details of this encoding scheme may be found in the file + exp_dbug.ads in the GNAT source distribution. However, the details of + this encoding are, in general, of no interest to a user, since `GDB' + automatically performs the necessary decoding. + + When a program is bound and linked, the debugging information is + collected from the object files, and stored in the executable image of + the program. Again, this process significantly increases the size of + the generated executable file, but it does not increase the size of the + executable program itself. Furthermore, if this program is run in the + normal manner, it runs exactly as if the debug information were not + present, and takes no more actual memory. + + However, if the program is run under control of `GDB', the debugger + is activated. The image of the program is loaded, at which point it is + ready to run. If a run command is given, then the program will run + exactly as it would have if `GDB' were not present. This is a crucial + part of the `GDB' design philosophy. `GDB' is entirely non-intrusive + until a breakpoint is encountered. If no breakpoint is ever hit, the + program will run exactly as it would if no debugger were present. When + a breakpoint is hit, `GDB' accesses the debugging information and can + respond to user commands to inspect variables, and more generally to + report on the state of execution. + +  + File: gnat_ug_vxw.info, Node: Running GDB, Next: Introduction to GDB Commands, Prev: The GNAT Debugger GDB, Up: Running and Debugging Ada Programs + + Running GDB + =========== + + Please refer to the debugging section of the chapter specific to your + cross environment at the end of this manual. + +  + File: gnat_ug_vxw.info, Node: Introduction to GDB Commands, Next: Using Ada Expressions, Prev: Running GDB, Up: Running and Debugging Ada Programs + + Introduction to GDB Commands + ============================ + + `GDB' contains a large repertoire of commands. The manual `Debugging + with GDB' includes extensive documentation on the use of these + commands, together with examples of their use. Furthermore, the command + HELP invoked from within `GDB' activates a simple help facility which + summarizes the available commands and their options. In this section + we summarize a few of the most commonly used commands to give an idea + of what `GDB' is about. You should create a simple program with + debugging information and experiment with the use of these `GDB' + commands on the program as you read through the following section. + + `set args ARGUMENTS' + The ARGUMENTS list above is a list of arguments to be passed to + the program on a subsequent run command, just as though the + arguments had been entered on a normal invocation of the program. + The `set args' command is not needed if the program does not + require arguments. + + `run' + The `run' command causes execution of the program to start from + the beginning. If the program is already running, that is to say if + you are currently positioned at a breakpoint, then a prompt will + ask for confirmation that you want to abandon the current + execution and restart. + + `breakpoint LOCATION' + The breakpoint command sets a breakpoint, that is to say a point + at which execution will halt and `GDB' will await further + commands. LOCATION is either a line number within a file, given in + the format `file:linenumber', or it is the name of a subprogram. + If you request that a breakpoint be set on a subprogram that is + overloaded, a prompt will ask you to specify on which of those + subprograms you want to breakpoint. You can also specify that all + of them should be breakpointed. If the program is run and + execution encounters the breakpoint, then the program stops and + `GDB' signals that the breakpoint was encountered by printing the + line of code before which the program is halted. + + `breakpoint exception NAME' + A special form of the breakpoint command which breakpoints whenever + exception NAME is raised. If NAME is omitted, then a breakpoint + will occur when any exception is raised. + + `print EXPRESSION' + This will print the value of the given expression. Most simple Ada + expression formats are properly handled by `GDB', so the expression + can contain function calls, variables, operators, and attribute + references. + + `continue' + Continues execution following a breakpoint, until the next + breakpoint or the termination of the program. + + `step' + Executes a single line after a breakpoint. If the next statement + is a subprogram call, execution continues into (the first + statement of) the called subprogram. + + `next' + Executes a single line. If this line is a subprogram call, + executes and returns from the call. + + `list' + Lists a few lines around the current source location. In practice, + it is usually more convenient to have a separate edit window open + with the relevant source file displayed. Successive applications + of this command print subsequent lines. The command can be given + an argument which is a line number, in which case it displays a + few lines around the specified one. + + `backtrace' + Displays a backtrace of the call chain. This command is typically + used after a breakpoint has occurred, to examine the sequence of + calls that leads to the current breakpoint. The display includes + one line for each activation record (frame) corresponding to an + active subprogram. + + `up' + At a breakpoint, `GDB' can display the values of variables local + to the current frame. The command `up' can be used to examine the + contents of other active frames, by moving the focus up the stack, + that is to say from callee to caller, one frame at a time. + + `down' + Moves the focus of `GDB' down from the frame currently being + examined to the frame of its callee (the reverse of the previous + command), + + `frame N' + Inspect the frame with the given number. The value 0 denotes the + frame of the current breakpoint, that is to say the top of the + call stack. + + The above list is a very short introduction to the commands that + `GDB' provides. Important additional capabilities, including conditional + breakpoints, the ability to execute command sequences on a breakpoint, + the ability to debug at the machine instruction level and many other + features are described in detail in `Debugging with GDB'. Note that + most commands can be abbreviated (for example, c for continue, bt for + backtrace). + +  + File: gnat_ug_vxw.info, Node: Using Ada Expressions, Next: Calling User-Defined Subprograms, Prev: Introduction to GDB Commands, Up: Running and Debugging Ada Programs + + Using Ada Expressions + ===================== + + `GDB' supports a fairly large subset of Ada expression syntax, with some + extensions. The philosophy behind the design of this subset is + + * That `GDB' should provide basic literals and access to operations + for arithmetic, dereferencing, field selection, indexing, and + subprogram calls, leaving more sophisticated computations to + subprograms written into the program (which therefore may be + called from `GDB'). + + * That type safety and strict adherence to Ada language restrictions + are not particularly important to the `GDB' user. + + * That brevity is important to the `GDB' user. + + Thus, for brevity, the debugger acts as if there were implicit + `with' and `use' clauses in effect for all user-written packages, thus + making it unnecessary to fully qualify most names with their packages, + regardless of context. Where this causes ambiguity, `GDB' asks the + user's intent. + + For details on the supported Ada syntax, see `Debugging with GDB'. + +  + File: gnat_ug_vxw.info, Node: Calling User-Defined Subprograms, Next: Using the Next Command in a Function, Prev: Using Ada Expressions, Up: Running and Debugging Ada Programs + + Calling User-Defined Subprograms + ================================ + + An important capability of `GDB' is the ability to call user-defined + subprograms while debugging. This is achieved simply by entering a + subprogram call statement in the form: + + call subprogram-name (parameters) + + The keyword `call' can be omitted in the normal case where the + `subprogram-name' does not coincide with any of the predefined `GDB' + commands. + + The effect is to invoke the given subprogram, passing it the list of + parameters that is supplied. The parameters can be expressions and can + include variables from the program being debugged. The subprogram must + be defined at the library level within your program, and `GDB' will + call the subprogram within the environment of your program execution + (which means that the subprogram is free to access or even modify + variables within your program). + + The most important use of this facility is in allowing the inclusion + of debugging routines that are tailored to particular data structures + in your program. Such debugging routines can be written to provide a + suitably high-level description of an abstract type, rather than a + low-level dump of its physical layout. After all, the standard `GDB + print' command only knows the physical layout of your types, not their + abstract meaning. Debugging routines can provide information at the + desired semantic level and are thus enormously useful. + + For example, when debugging GNAT itself, it is crucial to have + access to the contents of the tree nodes used to represent the program + internally. But tree nodes are represented simply by an integer value + (which in turn is an index into a table of nodes). Using the `print' + command on a tree node would simply print this integer value, which is + not very useful. But the PN routine (defined in file treepr.adb in the + GNAT sources) takes a tree node as input, and displays a useful high + level representation of the tree node, which includes the syntactic + category of the node, its position in the source, the integers that + denote descendant nodes and parent node, as well as varied semantic + information. To study this example in more detail, you might want to + look at the body of the PN procedure in the stated file. + +  + File: gnat_ug_vxw.info, Node: Using the Next Command in a Function, Next: Ada Exceptions, Prev: Calling User-Defined Subprograms, Up: Running and Debugging Ada Programs + + Using the Next Command in a Function + ==================================== + + When you use the `next' command in a function, the current source + location will advance to the next statement as usual. A special case + arises in the case of a `return' statement. + + Part of the code for a return statement is the "epilog" of the + function. This is the code that returns to the caller. There is only + one copy of this epilog code, and it is typically associated with the + last return statement in the function if there is more than one return. + In some implementations, this epilog is associated with the first + statement of the function. + + The result is that if you use the `next' command from a return + statement that is not the last return statement of the function you may + see a strange apparent jump to the last return statement or to the + start of the function. You should simply ignore this odd jump. The + value returned is always that from the first return statement that was + stepped through. + +  + File: gnat_ug_vxw.info, Node: Ada Exceptions, Next: Ada Tasks, Prev: Using the Next Command in a Function, Up: Running and Debugging Ada Programs + + Breaking on Ada Exceptions + ========================== + + You can set breakpoints that trip when your program raises selected + exceptions. + + `break exception' + Set a breakpoint that trips whenever (any task in the) program + raises any exception. + + `break exception NAME' + Set a breakpoint that trips whenever (any task in the) program + raises the exception NAME. + + `break exception unhandled' + Set a breakpoint that trips whenever (any task in the) program + raises an exception for which there is no handler. + + `info exceptions' + `info exceptions REGEXP' + The `info exceptions' command permits the user to examine all + defined exceptions within Ada programs. With a regular expression, + REGEXP, as argument, prints out only those exceptions whose name + matches REGEXP. + +  + File: gnat_ug_vxw.info, Node: Ada Tasks, Next: Debugging Generic Units, Prev: Ada Exceptions, Up: Running and Debugging Ada Programs + + Ada Tasks + ========= + + `GDB' allows the following task-related commands: + + `info tasks' + This command shows a list of current Ada tasks, as in the + following example: + + (gdb) info tasks + ID TID P-ID Thread Pri State Name + 1 8088000 0 807e000 15 Child Activation Wait main_task + 2 80a4000 1 80ae000 15 Accept/Select Wait b + 3 809a800 1 80a4800 15 Child Activation Wait a + * 4 80ae800 3 80b8000 15 Running c + + In this listing, the asterisk before the first task indicates it + to be the currently running task. The first column lists the task + ID that is used to refer to tasks in the following commands. + + `break LINESPEC task TASKID' + `break LINESPEC task TASKID if ...' + These commands are like the `break ... thread ...'. LINESPEC + specifies source lines. + + Use the qualifier `task TASKID' with a breakpoint command to + specify that you only want `GDB' to stop the program when a + particular Ada task reaches this breakpoint. TASKID is one of the + numeric task identifiers assigned by `GDB', shown in the first + column of the `info tasks' display. + + If you do not specify `task TASKID' when you set a breakpoint, the + breakpoint applies to _all_ tasks of your program. + + You can use the `task' qualifier on conditional breakpoints as + well; in this case, place `task TASKID' before the breakpoint + condition (before the `if'). + + `task TASKNO' + This command allows to switch to the task referred by TASKNO. In + particular, This allows to browse the backtrace of the specified + task. It is advised to switch back to the original task before + continuing execution otherwise the scheduling of the program may be + perturbated. + + For more detailed information on the tasking support, see `Debugging + with GDB'. + +  + File: gnat_ug_vxw.info, Node: Debugging Generic Units, Next: GNAT Abnormal Termination or Failure to Terminate, Prev: Ada Tasks, Up: Running and Debugging Ada Programs + + Debugging Generic Units + ======================= + + GNAT always uses code expansion for generic instantiation. This means + that each time an instantiation occurs, a complete copy of the original + code is made, with appropriate substitutions of formals by actuals. + + It is not possible to refer to the original generic entities in + `GDB', but it is always possible to debug a particular instance of a + generic, by using the appropriate expanded names. For example, if we + have + + procedure g is + + generic package k is + procedure kp (v1 : in out integer); + end k; + + package body k is + procedure kp (v1 : in out integer) is + begin + v1 := v1 + 1; + end kp; + end k; + + package k1 is new k; + package k2 is new k; + + var : integer := 1; + + begin + k1.kp (var); + k2.kp (var); + k1.kp (var); + k2.kp (var); + end; + + Then to break on a call to procedure kp in the k2 instance, simply use + the command: + + (gdb) break g.k2.kp + + When the breakpoint occurs, you can step through the code of the + instance in the normal manner and examine the values of local + variables, as for other units. + +  + File: gnat_ug_vxw.info, Node: GNAT Abnormal Termination or Failure to Terminate, Next: Naming Conventions for GNAT Source Files, Prev: Debugging Generic Units, Up: Running and Debugging Ada Programs + + GNAT Abnormal Termination or Failure to Terminate + ================================================= + + When presented with programs that contain serious errors in syntax or + semantics, GNAT may on rare occasions experience problems in + operation, such as aborting with a segmentation fault or illegal memory + access, raising an internal exception, terminating abnormally, or + failing to terminate at all. In such cases, you can activate various + features of GNAT that can help you pinpoint the construct in your + program that is the likely source of the problem. + + The following strategies are presented in increasing order of + difficulty, corresponding to your experience in using GNAT and your + familiarity with compiler internals. + + 1. Run `gcc' with the `-gnatf'. This first switch causes all errors + on a given line to be reported. In its absence, only the first + error on a line is displayed. + + The `-gnatdO' switch causes errors to be displayed as soon as they + are encountered, rather than after compilation is terminated. If + GNAT terminates prematurely or goes into an infinite loop, the + last error message displayed may help to pinpoint the culprit. + + 2. Run `gcc' with the `-v (verbose)' switch. In this mode, `gcc' + produces ongoing information about the progress of the compilation + and provides the name of each procedure as code is generated. This + switch allows you to find which Ada procedure was being compiled + when it encountered a code generation problem. + + 3. Run `gcc' with the `-gnatdc' switch. This is a GNAT specific + switch that does for the front-end what `-v' does for the back end. + The system prints the name of each unit, either a compilation unit + or nested unit, as it is being analyzed. + + 4. Finally, you can start `gdb' directly on the `gnat1' executable. + `gnat1' is the front-end of GNAT, and can be run independently + (normally it is just called from `gcc'). You can use `gdb' on + `gnat1' as you would on a C program (but *note The GNAT Debugger + GDB:: for caveats). The `where' command is the first line of + attack; the variable `lineno' (seen by `print lineno'), used by + the second phase of `gnat1' and by the `gcc' backend, indicates + the source line at which the execution stopped, and `input_file + name' indicates the name of the source file. + +  + File: gnat_ug_vxw.info, Node: Naming Conventions for GNAT Source Files, Next: Getting Internal Debugging Information, Prev: GNAT Abnormal Termination or Failure to Terminate, Up: Running and Debugging Ada Programs + + Naming Conventions for GNAT Source Files + ======================================== + + In order to examine the workings of the GNAT system, the following + brief description of its organization may be helpful: + + * Files with prefix `sc' contain the lexical scanner. + + * All files prefixed with `par' are components of the parser. The + numbers correspond to chapters of the Ada 95 Reference Manual. For + example, parsing of select statements can be found in + `par-ch9.adb'. + + * All files prefixed with `sem' perform semantic analysis. The + numbers correspond to chapters of the Ada standard. For example, + all issues involving context clauses can be found in + `sem_ch10.adb'. In addition, some features of the language require + sufficient special processing to justify their own semantic files: + sem_aggr for aggregates, sem_disp for dynamic dispatching, etc. + + * All files prefixed with `exp' perform normalization and expansion + of the intermediate representation (abstract syntax tree, or AST). + these files use the same numbering scheme as the parser and + semantics files. For example, the construction of record + initialization procedures is done in `exp_ch3.adb'. + + * The files prefixed with `bind' implement the binder, which + verifies the consistency of the compilation, determines an order of + elaboration, and generates the bind file. + + * The files `atree.ads' and `atree.adb' detail the low-level data + structures used by the front-end. + + * The files `sinfo.ads' and `sinfo.adb' detail the structure of the + abstract syntax tree as produced by the parser. + + * The files `einfo.ads' and `einfo.adb' detail the attributes of all + entities, computed during semantic analysis. + + * Library management issues are dealt with in files with prefix + `lib'. + + * Ada files with the prefix `a-' are children of `Ada', as defined + in Annex A. + + * Files with prefix `i-' are children of `Interfaces', as defined in + Annex B. + + * Files with prefix `s-' are children of `System'. This includes + both language-defined children and GNAT run-time routines. + + * Files with prefix `g-' are children of `GNAT'. These are useful + general-purpose packages, fully documented in their + specifications. All the other `.c' files are modifications of + common `gcc' files. + +  + File: gnat_ug_vxw.info, Node: Getting Internal Debugging Information, Next: Stack Traceback, Prev: Naming Conventions for GNAT Source Files, Up: Running and Debugging Ada Programs + + Getting Internal Debugging Information + ====================================== + + Most compilers have internal debugging switches and modes. GNAT does + also, except GNAT internal debugging switches and modes are not secret. + A summary and full description of all the compiler and binder debug + flags are in the file `debug.adb'. You must obtain the sources of the + compiler to see the full detailed effects of these flags. + + The switches that print the source of the program (reconstructed from + the internal tree) are of general interest for user programs, as are the + options to print the full internal tree, and the entity table (the + symbol table information). The reconstructed source provides a readable + version of the program after the front-end has completed analysis and + expansion, and is useful when studying the performance of specific + constructs. For example, constraint checks are indicated, complex + aggregates are replaced with loops and assignments, and tasking + primitives are replaced with run-time calls. + +  + File: gnat_ug_vxw.info, Node: Stack Traceback, Prev: Getting Internal Debugging Information, Up: Running and Debugging Ada Programs + + Stack Traceback + =============== + + Traceback is a mechanism to display the sequence of subprogram calls + that leads to a specified execution point in a program. Often (but not + always) the execution point is an instruction at which an exception has + been raised. This mechanism is also known as stack unwinding because + it obtains its information by scanning the run-time stack and + recovering the activation records of all active subprograms. Stack + unwinding is one of the most important tools for program debugging. + + The first entry stored in traceback corresponds to the deepest calling + level, that is to say the subprogram currently executing the instruction + from which we want to obtain the traceback. + + Note that there is no runtime performance penalty when stack traceback + is enabled and no exception are raised during program execution. + + * Menu: + + * Non-Symbolic Traceback:: + * Symbolic Traceback:: + +  + File: gnat_ug_vxw.info, Node: Non-Symbolic Traceback, Next: Symbolic Traceback, Up: Stack Traceback + + Non-Symbolic Traceback + ---------------------- + + Note: this feature is not supported on all platforms. See + `GNAT.Traceback spec in g-traceb.ads' for a complete list of supported + platforms. + + * Menu: + + * Tracebacks From an Unhandled Exception:: + * Tracebacks From Exception Occurrences (non-symbolic):: + * Tracebacks From Anywhere in a Program (non-symbolic):: + +  + File: gnat_ug_vxw.info, Node: Tracebacks From an Unhandled Exception, Next: Tracebacks From Exception Occurrences (non-symbolic), Up: Non-Symbolic Traceback + + Tracebacks From an Unhandled Exception + ...................................... + + A runtime non-symbolic traceback is a list of addresses of call + instructions. To enable this feature you must use the `-E' + `gnatbind''s option. With this option a stack traceback is stored as + part of exception information. It is possible to retrieve this + information using the standard `Ada.Exception.Exception_Information' + routine. + + Let's have a look at a simple example: + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + $ gnatmake stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + As we see the traceback lists a sequence of addresses for the unhandled + exception `CONSTAINT_ERROR' raised in procedure P1. It is easy to guess + that this exception come from procedure P1. To translate these + addresses into the source lines where the calls appear, the `addr2line' + tool, described below, is invaluable. The use of this tool requires the + program to be compiled with debug information. + + $ gnatmake -g stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + $ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 + 0x4011f1 0x77e892a4 + + 00401373 at d:/stb/stb.adb:5 + 0040138B at d:/stb/stb.adb:10 + 0040139C at d:/stb/stb.adb:14 + 00401335 at d:/stb/b~stb.adb:104 + 004011C4 at /build/.../crt1.c:200 + 004011F1 at /build/.../crt1.c:222 + 77E892A4 in ?? at ??:0 + + `addr2line' has a number of other useful options: + + `--functions' + to get the function name corresponding to any location + + `--demangle=gnat' + to use the gnat decoding mode for the function names. Note that + for binutils version 2.9.x the option is simply `--demangle'. + + $ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b + 0x40139c 0x401335 0x4011c4 0x4011f1 + + 00401373 in stb.p1 at d:/stb/stb.adb:5 + 0040138B in stb.p2 at d:/stb/stb.adb:10 + 0040139C in stb at d:/stb/stb.adb:14 + 00401335 in main at d:/stb/b~stb.adb:104 + 004011C4 in <__mingw_CRTStartup> at /build/.../crt1.c:200 + 004011F1 in at /build/.../crt1.c:222 + + From this traceback we can see that the exception was raised in + `stb.adb' at line 5, which was reached from a procedure call in + `stb.adb' at line 10, and so on. The `b~std.adb' is the binder file, + which contains the call to the main program. *note Running gnatbind::. + The remaining entries are assorted runtime routines, and the output + will vary from platform to platform. + + It is also possible to use `GDB' with these traceback addresses to debug + the program. For example, we can break at a given code location, as + reported in the stack traceback: + + $ gdb -nw stb + + (gdb) break *0x401373 + Breakpoint 1 at 0x401373: file stb.adb, line 5. + + It is important to note that the stack traceback addresses do not + change when debug information is included. This is particularly useful + because it makes it possible to release software without debug + information (to minimize object size), get a field report that includes + a stack traceback whenever an internal bug occurs, and then be able to + retrieve the sequence of calls with the same program compiled with + debug information. + +  + File: gnat_ug_vxw.info, Node: Tracebacks From Exception Occurrences (non-symbolic), Next: Tracebacks From Anywhere in a Program (non-symbolic), Prev: Tracebacks From an Unhandled Exception, Up: Non-Symbolic Traceback + + Tracebacks From Exception Occurrences + ..................................... + + Non-symbolic tracebacks are obtained by using the `-E' binder argument. + The stack traceback is attached to the exception information string, + and can be retrieved in an exception handler within the Ada program, by + means of the Ada95 facilities defined in `Ada.Exceptions'. Here is a + simple example: + + with Ada.Text_IO; + with Ada.Exceptions; + + procedure STB is + + use Ada; + use Ada.Exceptions; + + procedure P1 is + K : Positive := 1; + begin + K := K - 1; + exception + when E : others => + Text_IO.Put_Line (Exception_Information (E)); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + This program will output: + + $ stb + + Exception name: CONSTRAINT_ERROR + Message: stb.adb:12 + Call stack traceback locations: + 0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4 + +  + File: gnat_ug_vxw.info, Node: Tracebacks From Anywhere in a Program (non-symbolic), Prev: Tracebacks From Exception Occurrences (non-symbolic), Up: Non-Symbolic Traceback + + Tracebacks From Anywhere in a Program + ..................................... + + It is also possible to retrieve a stack traceback from anywhere in a + program. For this you need to use the `GNAT.Traceback' API. This + package includes a procedure called `Call_Chain' that computes a + complete stack traceback, as well as useful display procedures + described below. It is not necessary to use the `-E gnatbind' option in + this case, because the stack traceback mechanism is invoked explicitly. + + In the following example we compute a traceback at a specific location + in the program, and we display it using `GNAT.Debug_Utilities.Image' to + convert addresses to strings: + + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Debug_Utilities; + + procedure STB is + + use Ada; + use GNAT; + use GNAT.Traceback; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + + Text_IO.Put ("In STB.P1 : "); + + for K in 1 .. Len loop + Text_IO.Put (Debug_Utilities.Image (TB (K))); + Text_IO.Put (' '); + end loop; + + Text_IO.New_Line; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + $ gnatmake stb + $ stb + + In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C# + 16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4# + +  + File: gnat_ug_vxw.info, Node: Symbolic Traceback, Prev: Non-Symbolic Traceback, Up: Stack Traceback + + Symbolic Traceback + ------------------ + + A symbolic traceback is a stack traceback in which procedure names are + associated with each code location. + + Note that this feature is not supported on all platforms. See + `GNAT.Traceback.Symbolic spec in g-trasym.ads' for a complete list of + currently supported platforms. + + Note that the symbolic traceback requires that the program be compiled + with debug information. If it is not compiled with debug information + only the non-symbolic information will be valid. + + * Menu: + + * Tracebacks From Exception Occurrences (symbolic):: + * Tracebacks From Anywhere in a Program (symbolic):: + +  + File: gnat_ug_vxw.info, Node: Tracebacks From Exception Occurrences (symbolic), Next: Tracebacks From Anywhere in a Program (symbolic), Up: Symbolic Traceback + + Tracebacks From Exception Occurrences + ..................................... + + with Ada.Text_IO; + with GNAT.Traceback.Symbolic; + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + procedure P3 is + begin + P2; + end P3; + + begin + P3; + exception + when E : others => + Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); + end STB; + + $ gnatmake -g stb -bargs -E -largs -lgnat -laddr2line -lintl + $ stb + + 0040149F in stb.p1 at stb.adb:8 + 004014B7 in stb.p2 at stb.adb:13 + 004014CF in stb.p3 at stb.adb:18 + 004015DD in ada.stb at stb.adb:22 + 00401461 in main at b~stb.adb:168 + 004011C4 in __mingw_CRTStartup at crt1.c:200 + 004011F1 in mainCRTStartup at crt1.c:222 + 77E892A4 in ?? at ??:0 + + The exact sequence of linker options may vary from platform to platform. + The above `-largs' section is for Windows platforms. By contrast, under + Unix there is no need for the `-largs' section. Differences across + platforms are due to details of linker implementation. + +  + File: gnat_ug_vxw.info, Node: Tracebacks From Anywhere in a Program (symbolic), Prev: Tracebacks From Exception Occurrences (symbolic), Up: Symbolic Traceback + + Tracebacks From Anywhere in a Program + ..................................... + + It is possible to get a symbolic stack traceback from anywhere in a + program, just as for non-symbolic tracebacks. The first step is to + obtain a non-symbolic traceback, and then call `Symbolic_Traceback' to + compute the symbolic information. Here is an example: + + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Traceback.Symbolic; + + procedure STB is + + use Ada; + use GNAT.Traceback; + use GNAT.Traceback.Symbolic; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len))); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + +  + File: gnat_ug_vxw.info, Node: Inline Assembler, Next: VxWorks Topics, Prev: Running and Debugging Ada Programs, Up: Top + + Inline Assembler + **************** + + If you need to write low-level software that interacts directly with + the hardware, Ada provides two ways to incorporate assembly language + code into your program. First, you can import and invoke external + routines written in assembly language, an Ada feature fully supported + by GNAT. However, for small sections of code it may be simpler or more + efficient to include assembly language statements directly in your Ada + source program, using the facilities of the implementation-defined + package `System.Machine_Code', which incorporates the gcc Inline + Assembler. The Inline Assembler approach offers a number of + advantages, including the following: + + * No need to use non-Ada tools + + * Consistent interface over different targets + + * Automatic usage of the proper calling conventions + + * Access to Ada constants and variables + + * Definition of intrinsic routines + + * Possibility of inlining a subprogram comprising assembler code + + * Code optimizer can take Inline Assembler code into account + + This chapter presents a series of examples to show you how to use + the Inline Assembler. Although it focuses on the Intel x86, the + general approach applies also to other processors. It is assumed that + you are familiar with Ada and with assembly language programming. + + * Menu: + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + +  + File: gnat_ug_vxw.info, Node: Basic Assembler Syntax, Next: A Simple Example of Inline Assembler, Up: Inline Assembler + + Basic Assembler Syntax + ====================== + + The assembler used by GNAT and gcc is based not on the Intel assembly + language, but rather on a language that descends from the AT&T Unix + assembler _as_ (and which is often referred to as "AT&T syntax"). The + following table summarizes the main features of _as_ syntax and points + out the differences from the Intel conventions. See the gcc _as_ and + _gas_ (an _as_ macro pre-processor) documentation for further + information. + + Register names + gcc / _as_: Prefix with "%"; for example `%eax' + Intel: No extra punctuation; for example `eax' + + Immediate operand + gcc / _as_: Prefix with "$"; for example `$4' + Intel: No extra punctuation; for example `4' + + Address + gcc / _as_: Prefix with "$"; for example `$loc' + Intel: No extra punctuation; for example `loc' + + Memory contents + gcc / _as_: No extra punctuation; for example `loc' + Intel: Square brackets; for example `[loc]' + + Register contents + gcc / _as_: Parentheses; for example `(%eax)' + Intel: Square brackets; for example `[eax]' + + Hexadecimal numbers + gcc / _as_: Leading "0x" (C language syntax); for example `0xA0' + Intel: Trailing "h"; for example `A0h' + + Operand size + gcc / _as_: Explicit in op code; for example `movw' to move a + 16-bit word + Intel: Implicit, deduced by assembler; for example `mov' + + Instruction repetition + gcc / _as_: Split into two lines; for example + `rep' + `stosl' + Intel: Keep on one line; for example `rep stosl' + + Order of operands + gcc / _as_: Source first; for example `movw $4, %eax' + Intel: Destination first; for example `mov eax, 4' + +  + File: gnat_ug_vxw.info, Node: A Simple Example of Inline Assembler, Next: Output Variables in Inline Assembler, Prev: Basic Assembler Syntax, Up: Inline Assembler + + A Simple Example of Inline Assembler + ==================================== + + The following example will generate a single assembly language + statement, `nop', which does nothing. Despite its lack of run-time + effect, the example will be useful in illustrating the basics of the + Inline Assembler facility. + + with System.Machine_Code; use System.Machine_Code; + procedure Nothing is + begin + Asm ("nop"); + end Nothing; + + `Asm' is a procedure declared in package `System.Machine_Code'; here + it takes one parameter, a _template string_ that must be a static + expression and that will form the generated instruction. `Asm' may be + regarded as a compile-time procedure that parses the template string + and additional parameters (none here), from which it generates a + sequence of assembly language instructions. + + The examples in this chapter will illustrate several of the forms + for invoking `Asm'; a complete specification of the syntax is found in + the `GNAT Reference Manual'. + + Under the standard GNAT conventions, the `Nothing' procedure should + be in a file named `nothing.adb'. You can build the executable in the + usual way: + gnatmake nothing + However, the interesting aspect of this example is not its run-time + behavior but rather the generated assembly code. To see this output, + invoke the compiler as follows: + gcc -c -S -fomit-frame-pointer -gnatp `nothing.adb' + where the options are: + + `-c' + compile only (no bind or link) + + `-S' + generate assembler listing + + `-fomit-frame-pointer' + do not set up separate stack frames + + `-gnatp' + do not add runtime checks + + This gives a human-readable assembler version of the code. The + resulting file will have the same name as the Ada source file, but with + a `.s' extension. In our example, the file `nothing.s' has the + following contents: + + .file "nothing.adb" + gcc2_compiled.: + ___gnu_compiled_ada: + .text + .align 4 + .globl __ada_nothing + __ada_nothing: + #APP + nop + #NO_APP + jmp L1 + .align 2,0x90 + L1: + ret + + The assembly code you included is clearly indicated by the compiler, + between the `#APP' and `#NO_APP' delimiters. The character before the + 'APP' and 'NOAPP' can differ on different targets. For example, Linux + uses '#APP' while on NT you will see '/APP'. + + If you make a mistake in your assembler code (such as using the + wrong size modifier, or using a wrong operand for the instruction) GNAT + will report this error in a temporary file, which will be deleted when + the compilation is finished. Generating an assembler file will help in + such cases, since you can assemble this file separately using the _as_ + assembler that comes with gcc. + + Assembling the file using the command + + as `nothing.s' + + will give you error messages whose lines correspond to the assembler + input file, so you can easily find and correct any mistakes you made. + If there are no errors, _as_ will generate an object file `nothing.out'. + +  + File: gnat_ug_vxw.info, Node: Output Variables in Inline Assembler, Next: Input Variables in Inline Assembler, Prev: A Simple Example of Inline Assembler, Up: Inline Assembler + + Output Variables in Inline Assembler + ==================================== + + The examples in this section, showing how to access the processor + flags, illustrate how to specify the destination operands for assembly + language statements. + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags; + + In order to have a nicely aligned assembly listing, we have separated + multiple assembler statements in the Asm template string with linefeed + (ASCII.LF) and horizontal tab (ASCII.HT) characters. The resulting + section of the assembly output file is: + + #APP + pushfl + popl %eax + movl %eax, -40(%ebp) + #NO_APP + + It would have been legal to write the Asm invocation as: + + Asm ("pushfl popl %%eax movl %%eax, %0") + + but in the generated assembler file, this would come out as: + + #APP + pushfl popl %eax movl %eax, -40(%ebp) + #NO_APP + + which is not so convenient for the human reader. + + We use Ada comments at the end of each line to explain what the + assembler instructions actually do. This is a useful convention. + + When writing Inline Assembler instructions, you need to precede each + register and variable name with a percent sign. Since the assembler + already requires a percent sign at the beginning of a register name, + you need two consecutive percent signs for such names in the Asm + template string, thus `%%eax'. In the generated assembly code, one of + the percent signs will be stripped off. + + Names such as `%0', `%1', `%2', etc., denote input or output + variables: operands you later define using `Input' or `Output' + parameters to `Asm'. An output variable is illustrated in the third + statement in the Asm template string: + movl %%eax, %0 + The intent is to store the contents of the eax register in a + variable that can be accessed in Ada. Simply writing `movl %%eax, + Flags' would not necessarily work, since the compiler might optimize by + using a register to hold Flags, and the expansion of the `movl' + instruction would not be aware of this optimization. The solution is + not to store the result directly but rather to advise the compiler to + choose the correct operand form; that is the purpose of the `%0' output + variable. + + Information about the output variable is supplied in the `Outputs' + parameter to `Asm': + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + + The output is defined by the `Asm_Output' attribute of the target + type; the general format is + Type'Asm_Output (constraint_string, variable_name) + + The constraint string directs the compiler how to store/access the + associated variable. In the example + Unsigned_32'Asm_Output ("=m", Flags); + the `"m"' (memory) constraint tells the compiler that the variable + `Flags' should be stored in a memory variable, thus preventing the + optimizer from keeping it in a register. In contrast, + Unsigned_32'Asm_Output ("=r", Flags); + uses the `"r"' (register) constraint, telling the compiler to store + the variable in a register. + + If the constraint is preceded by the equal character (*=*), it tells + the compiler that the variable will be used to store data into it. + + In the `Get_Flags' example, we used the "g" (global) constraint, + allowing the optimizer to choose whatever it deems best. + + There are a fairly large number of constraints, but the ones that + are most useful (for the Intel x86 processor) are the following: + + `=' + output constraint + + `g' + global (i.e. can be stored anywhere) + + `m' + in memory + + `I' + a constant + + `a' + use eax + + `b' + use ebx + + `c' + use ecx + + `d' + use edx + + `S' + use esi + + `D' + use edi + + `r' + use one of eax, ebx, ecx or edx + + `q' + use one of eax, ebx, ecx, edx, esi or edi + + The full set of constraints is described in the gcc and _as_ + documentation; note that it is possible to combine certain constraints + in one constraint string. + + You specify the association of an output variable with an assembler + operand through the `%'_n_ notation, where _n_ is a non-negative + integer. Thus in + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + + `%0' will be replaced in the expanded code by the appropriate operand, + whatever the compiler decided for the `Flags' variable. + + In general, you may have any number of output variables: + * Count the operands starting at 0; thus `%0', `%1', etc. + + * Specify the `Outputs' parameter as a parenthesized comma-separated + list of `Asm_Output' attributes + + For example: + Asm ("movl %%eax, %0" & LF & HT & + "movl %%ebx, %1" & LF & HT & + "movl %%ecx, %2", + Outputs => (Unsigned_32'Asm_Output ("=g", Var_A), -- %0 = Var_A + Unsigned_32'Asm_Output ("=g", Var_B), -- %1 = Var_B + Unsigned_32'Asm_Output ("=g", Var_C))); -- %2 = Var_C + + where `Var_A', `Var_B', and `Var_C' are variables in the Ada program. + + As a variation on the `Get_Flags' example, we can use the + constraints string to direct the compiler to store the eax register + into the `Flags' variable, instead of including the store instruction + explicitly in the `Asm' template string: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_2 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax", -- save flags in eax + Outputs => Unsigned_32'Asm_Output ("=a", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_2; + + The `"a"' constraint tells the compiler that the `Flags' variable will + come from the eax register. Here is the resulting code: + + #APP + pushfl + popl %eax + #NO_APP + movl %eax,-40(%ebp) + + The compiler generated the store of eax into Flags after expanding the + assembler code. + + Actually, there was no need to pop the flags into the eax register; + more simply, we could just pop the flags directly into the program + variable: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_3 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "pop %0", -- save flags in Flags + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_3; + +  + File: gnat_ug_vxw.info, Node: Input Variables in Inline Assembler, Next: Inlining Inline Assembler Code, Prev: Output Variables in Inline Assembler, Up: Inline Assembler + + Input Variables in Inline Assembler + =================================== + + The example in this section illustrates how to specify the source + operands for assembly language statements. The program simply + increments its input value by 1: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Incr (Value); + Put_Line ("Value after is" & Value'Img); + end Increment; + + The `Outputs' parameter to `Asm' specifies that the result will be + in the eax register and that it is to be stored in the `Result' + variable. + + The `Inputs' parameter looks much like the `Outputs' parameter, but + with an `Asm_Input' attribute. The `"="' constraint, indicating an + output value, is not present. + + You can have multiple input variables, in the same way that you can + have more than one output variable. + + The parameter count (%0, %1) etc, now starts at the first input + statement, and continues with the output statements. When both + parameters use the same variable, the compiler will treat them as the + same %n operand, which is the case here. + + Just as the `Outputs' parameter causes the register to be stored + into the target variable after execution of the assembler statements, + so does the `Inputs' parameter cause its variable to be loaded into the + register before execution of the assembler statements. + + Thus the effect of the `Asm' invocation is: + 1. load the 32-bit value of `Value' into eax + + 2. execute the `incl %eax' instruction + + 3. store the contents of eax into the `Result' variable + + The resulting assembler file (with `-O2' optimization) contains: + _increment__incr.1: + subl $4,%esp + movl 8(%esp),%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + movl %ecx,(%esp) + addl $4,%esp + ret + +  + File: gnat_ug_vxw.info, Node: Inlining Inline Assembler Code, Next: Other Asm Functionality, Prev: Input Variables in Inline Assembler, Up: Inline Assembler + + Inlining Inline Assembler Code + ============================== + + For a short subprogram such as the `Incr' function in the previous + section, the overhead of the call and return (creating / deleting the + stack frame) can be significant, compared to the amount of code in the + subprogram body. A solution is to apply Ada's `Inline' pragma to the + subprogram, which directs the compiler to expand invocations of the + subprogram at the point(s) of call, instead of setting up a stack frame + for out-of-line calls. Here is the resulting program: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment_2 is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + pragma Inline (Increment); + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Increment (Value); + Put_Line ("Value after is" & Value'Img); + end Increment_2; + + Compile the program with both optimization (`-O2') and inlining + enabled (`-gnatpn' instead of `-gnatp'). + + The `Incr' function is still compiled as usual, but at the point in + `Increment' where our function used to be called: + + pushl %edi + call _increment__incr.1 + + the code for the function body directly appears: + + movl %esi,%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + + thus saving the overhead of stack frame setup and an out-of-line call. + +  + File: gnat_ug_vxw.info, Node: Other Asm Functionality, Next: A Complete Example, Prev: Inlining Inline Assembler Code, Up: Inline Assembler + + Other `Asm' Functionality + ========================= + + This section describes two important parameters to the `Asm' procedure: + `Clobber', which identifies register usage; and `Volatile', which + inhibits unwanted optimizations. + + * Menu: + + * The Clobber Parameter:: + * The Volatile Parameter:: + +  + File: gnat_ug_vxw.info, Node: The Clobber Parameter, Next: The Volatile Parameter, Up: Other Asm Functionality + + The `Clobber' Parameter + ----------------------- + + One of the dangers of intermixing assembly language and a compiled + language such as Ada is that the compiler needs to be aware of which + registers are being used by the assembly code. In some cases, such as + the earlier examples, the constraint string is sufficient to indicate + register usage (e.g. "a" for the eax register). But more generally, the + compiler needs an explicit identification of the registers that are + used by the Inline Assembly statements. + + Using a register that the compiler doesn't know about could be a + side effect of an instruction (like `mull' storing its result in both + eax and edx). It can also arise from explicit register usage in your + assembly code; for example: + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out)); + + where the compiler (since it does not analyze the `Asm' template string) + does not know you are using the ebx register. + + In such cases you need to supply the `Clobber' parameter to `Asm', + to identify the registers that will be used by your assembly code: + + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx"); + + The Clobber parameter is a static string expression specifying the + register(s) you are using. Note that register names are _not_ prefixed + by a percent sign. Also, if more than one register is used then their + names are separated by commas; e.g., `"eax, ebx"' + + The `Clobber' parameter has several additional uses: + 1. Use the "register" name `cc' to indicate that flags might have + changed + + 2. Use the "register" name `memory' if you changed a memory location + +  + File: gnat_ug_vxw.info, Node: The Volatile Parameter, Prev: The Clobber Parameter, Up: Other Asm Functionality + + The `Volatile' Parameter + ------------------------ + + Compiler optimizations in the presence of Inline Assembler may + sometimes have unwanted effects. For example, when an `Asm' invocation + with an input variable is inside a loop, the compiler might move the + loading of the input variable outside the loop, regarding it as a + one-time initialization. + + If this effect is not desired, you can disable such optimizations by + setting the `Volatile' parameter to `True'; for example: + + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx", + Volatile => True); + + By default, `Volatile' is set to `False' unless there is no `Outputs' + parameter. + + Although setting `Volatile' to `True' prevents unwanted + optimizations, it will also disable other optimizations that might be + important for efficiency. In general, you should set `Volatile' to + `True' only if the compiler's optimizations have created problems. + +  + File: gnat_ug_vxw.info, Node: A Complete Example, Prev: Other Asm Functionality, Up: Inline Assembler + + A Complete Example + ================== + + This section contains a complete program illustrating a realistic usage + of GNAT's Inline Assembler capabilities. It comprises a main procedure + `Check_CPU' and a package `Intel_CPU'. The package declares a + collection of functions that detect the properties of the 32-bit x86 + processor that is running the program. The main procedure invokes + these functions and displays the information. + + The Intel_CPU package could be enhanced by adding functions to + detect the type of x386 co-processor, the processor caching options and + special operations such as the SIMD extensions. + + Although the Intel_CPU package has been written for 32-bit Intel + compatible CPUs, it is OS neutral. It has been tested on DOS, + Windows/NT and Linux. + + * Menu: + + * Check_CPU Procedure:: + * Intel_CPU Package Specification:: + * Intel_CPU Package Body:: + +  + File: gnat_ug_vxw.info, Node: Check_CPU Procedure, Next: Intel_CPU Package Specification, Up: A Complete Example + + `Check_CPU' Procedure + --------------------- + + --------------------------------------------------------------------- + -- -- + -- Uses the Intel_CPU package to identify the CPU the program is -- + -- running on, and some of the features it supports. -- + -- -- + --------------------------------------------------------------------- + + with Intel_CPU; -- Intel CPU detection functions + with Ada.Text_IO; -- Standard text I/O + with Ada.Command_Line; -- To set the exit status + + procedure Check_CPU is + + Type_Found : Boolean := False; + -- Flag to indicate that processor was identified + + Features : Intel_CPU.Processor_Features; + -- The processor features + + Signature : Intel_CPU.Processor_Signature; + -- The processor type signature + + begin + + ----------------------------------- + -- Display the program banner. -- + ----------------------------------- + + Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name & + ": check Intel CPU version and features, v1.0"); + Ada.Text_IO.Put_Line ("distribute freely, but no warranty whatsoever"); + Ada.Text_IO.New_Line; + + ----------------------------------------------------------------------- + -- We can safely start with the assumption that we are on at least -- + -- a x386 processor. If the CPUID instruction is present, then we -- + -- have a later processor type. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Has_CPUID = False then + + -- No CPUID instruction, so we assume this is indeed a x386 + -- processor. We can still check if it has a FP co-processor. + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line + ("x386-type processor with a FP co-processor"); + else + Ada.Text_IO.Put_Line + ("x386-type processor without a FP co-processor"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check for CPUID + + ----------------------------------------------------------------------- + -- If CPUID is supported, check if this is a true Intel processor, -- + -- if it is not, display a warning. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Vendor_ID /= Intel_CPU.Intel_Processor then + Ada.Text_IO.Put_Line ("*** This is a Intel compatible processor"); + Ada.Text_IO.Put_Line ("*** Some information may be incorrect"); + end if; -- check if Intel + + ---------------------------------------------------------------------- + -- With the CPUID instruction present, we can assume at least a -- + -- x486 processor. If the CPUID support level is < 1 then we have -- + -- to leave it at that. -- + ---------------------------------------------------------------------- + + if Intel_CPU.CPUID_Level < 1 then + + -- Ok, this is a x486 processor. we still can get the Vendor ID + Ada.Text_IO.Put_Line ("x486-type processor"); + Ada.Text_IO.Put_Line ("Vendor ID is " & Intel_CPU.Vendor_ID); + + -- We can also check if there is a FPU present + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line ("Floating-Point support"); + else + Ada.Text_IO.Put_Line ("No Floating-Point support"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check CPUID level + + --------------------------------------------------------------------- + -- With a CPUID level of 1 we can use the processor signature to -- + -- determine it's exact type. -- + --------------------------------------------------------------------- + + Signature := Intel_CPU.Signature; + + ---------------------------------------------------------------------- + -- Ok, now we go into a lot of messy comparisons to get the -- + -- processor type. For clarity, no attememt to try to optimize the -- + -- comparisons has been made. Note that since Intel_CPU does not -- + -- support getting cache info, we cannot distinguish between P5 -- + -- and Celeron types yet. -- + ---------------------------------------------------------------------- + + -- x486SL + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486SL processor"); + end if; + + -- x486DX2 Write-Back + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0111# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Write-Back Enhanced x486DX2 processor"); + end if; + + -- x486DX4 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 processor"); + end if; + + -- x486DX4 Overdrive + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 OverDrive processor"); + end if; + + -- Pentium (60, 66) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium processor (60, 66)"); + end if; + + -- Pentium (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive (60, 66) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium OverDrive processor (60, 66)"); + end if; + + -- Pentium OverDrive (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive cpu (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive processor for x486 processor-based systems + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor for x486 processor-based systems"); + end if; + + -- Pentium processor with MMX technology (166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor with MMX technology (166, 200)"); + end if; + + -- Pentium OverDrive with MMX for Pentium (75, 90, 100, 120, 133) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor with MMX " & + "technology for Pentium processor (75, 90, 100, 120, 133)"); + end if; + + -- Pentium Pro processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro processor"); + end if; + + -- Pentium II processor, model 3 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium II processor, model 3"); + end if; + + -- Pentium II processor, model 5 or Celeron processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0101# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium II processor, model 5 or Celeron processor"); + end if; + + -- Pentium Pro OverDrive processor + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro OverDrive processor"); + end if; + + -- If no type recognized, we have an unknown. Display what + -- we _do_ know + if Type_Found = False then + Ada.Text_IO.Put_Line ("Unknown processor"); + end if; + + ----------------------------------------- + -- Display processor stepping level. -- + ----------------------------------------- + + Ada.Text_IO.Put_Line ("Stepping level:" & Signature.Stepping'Img); + + --------------------------------- + -- Display vendor ID string. -- + --------------------------------- + + Ada.Text_IO.Put_Line ("Vendor ID: " & Intel_CPU.Vendor_ID); + + ------------------------------------ + -- Get the processors features. -- + ------------------------------------ + + Features := Intel_CPU.Features; + + ----------------------------- + -- Check for a FPU unit. -- + ----------------------------- + + if Features.FPU = True then + Ada.Text_IO.Put_Line ("Floating-Point unit available"); + else + Ada.Text_IO.Put_Line ("no Floating-Point unit"); + end if; -- check for FPU + + -------------------------------- + -- List processor features. -- + -------------------------------- + + Ada.Text_IO.Put_Line ("Supported features: "); + + -- Virtual Mode Extension + if Features.VME = True then + Ada.Text_IO.Put_Line (" VME - Virtual Mode Extension"); + end if; + + -- Debugging Extension + if Features.DE = True then + Ada.Text_IO.Put_Line (" DE - Debugging Extension"); + end if; + + -- Page Size Extension + if Features.PSE = True then + Ada.Text_IO.Put_Line (" PSE - Page Size Extension"); + end if; + + -- Time Stamp Counter + if Features.TSC = True then + Ada.Text_IO.Put_Line (" TSC - Time Stamp Counter"); + end if; + + -- Model Specific Registers + if Features.MSR = True then + Ada.Text_IO.Put_Line (" MSR - Model Specific Registers"); + end if; + + -- Physical Address Extension + if Features.PAE = True then + Ada.Text_IO.Put_Line (" PAE - Physical Address Extension"); + end if; + + -- Machine Check Extension + if Features.MCE = True then + Ada.Text_IO.Put_Line (" MCE - Machine Check Extension"); + end if; + + -- CMPXCHG8 instruction supported + if Features.CX8 = True then + Ada.Text_IO.Put_Line (" CX8 - CMPXCHG8 instruction"); + end if; + + -- on-chip APIC hardware support + if Features.APIC = True then + Ada.Text_IO.Put_Line (" APIC - on-chip APIC hardware support"); + end if; + + -- Fast System Call + if Features.SEP = True then + Ada.Text_IO.Put_Line (" SEP - Fast System Call"); + end if; + + -- Memory Type Range Registers + if Features.MTRR = True then + Ada.Text_IO.Put_Line (" MTTR - Memory Type Range Registers"); + end if; + + -- Page Global Enable + if Features.PGE = True then + Ada.Text_IO.Put_Line (" PGE - Page Global Enable"); + end if; + + -- Machine Check Architecture + if Features.MCA = True then + Ada.Text_IO.Put_Line (" MCA - Machine Check Architecture"); + end if; + + -- Conditional Move Instruction Supported + if Features.CMOV = True then + Ada.Text_IO.Put_Line + (" CMOV - Conditional Move Instruction Supported"); + end if; + + -- Page Attribute Table + if Features.PAT = True then + Ada.Text_IO.Put_Line (" PAT - Page Attribute Table"); + end if; + + -- 36-bit Page Size Extension + if Features.PSE_36 = True then + Ada.Text_IO.Put_Line (" PSE_36 - 36-bit Page Size Extension"); + end if; + + -- MMX technology supported + if Features.MMX = True then + Ada.Text_IO.Put_Line (" MMX - MMX technology supported"); + end if; + + -- Fast FP Save and Restore + if Features.FXSR = True then + Ada.Text_IO.Put_Line (" FXSR - Fast FP Save and Restore"); + end if; + + --------------------- + -- Program done. -- + --------------------- + + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + + exception + + when others => + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); + raise; + + end Check_CPU; + +  + File: gnat_ug_vxw.info, Node: Intel_CPU Package Specification, Next: Intel_CPU Package Body, Prev: Check_CPU Procedure, Up: A Complete Example + + `Intel_CPU' Package Specification + --------------------------------- + + ------------------------------------------------------------------------- + -- -- + -- file: intel_cpu.ads -- + -- -- + -- ********************************************* -- + -- * WARNING: for 32-bit Intel processors only * -- + -- ********************************************* -- + -- -- + -- This package contains a number of subprograms that are useful in -- + -- determining the Intel x86 CPU (and the features it supports) on -- + -- which the program is running. -- + -- -- + -- The package is based upon the information given in the Intel -- + -- Application Note AP-485: "Intel Processor Identification and the -- + -- CPUID Instruction" as of April 1998. This application note can be -- + -- found on www.intel.com. -- + -- -- + -- It currently deals with 32-bit processors only, will not detect -- + -- features added after april 1998, and does not guarantee proper -- + -- results on Intel-compatible processors. -- + -- -- + -- Cache info and x386 fpu type detection are not supported. -- + -- -- + -- This package does not use any privileged instructions, so should -- + -- work on any OS running on a 32-bit Intel processor. -- + -- -- + ------------------------------------------------------------------------- + + with Interfaces; use Interfaces; + -- for using unsigned types + + with System.Machine_Code; use System.Machine_Code; + -- for using inline assembler code + + with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; + -- for inserting control characters + + package Intel_CPU is + + ---------------------- + -- Processor bits -- + ---------------------- + + subtype Num_Bits is Natural range 0 .. 31; + -- the number of processor bits (32) + + -------------------------- + -- Processor register -- + -------------------------- + + -- define a processor register type for easy access to + -- the individual bits + + type Processor_Register is array (Num_Bits) of Boolean; + pragma Pack (Processor_Register); + for Processor_Register'Size use 32; + + ------------------------- + -- Unsigned register -- + ------------------------- + + -- define a processor register type for easy access to + -- the individual bytes + + type Unsigned_Register is + record + L1 : Unsigned_8; + H1 : Unsigned_8; + L2 : Unsigned_8; + H2 : Unsigned_8; + end record; + + for Unsigned_Register use + record + L1 at 0 range 0 .. 7; + H1 at 0 range 8 .. 15; + L2 at 0 range 16 .. 23; + H2 at 0 range 24 .. 31; + end record; + + for Unsigned_Register'Size use 32; + + --------------------------------- + -- Intel processor vendor ID -- + --------------------------------- + + Intel_Processor : constant String (1 .. 12) := "GenuineIntel"; + -- indicates an Intel manufactured processor + + ------------------------------------ + -- Processor signature register -- + ------------------------------------ + + -- a register type to hold the processor signature + + type Processor_Signature is + record + Stepping : Natural range 0 .. 15; + Model : Natural range 0 .. 15; + Family : Natural range 0 .. 15; + Processor_Type : Natural range 0 .. 3; + Reserved : Natural range 0 .. 262143; + end record; + + for Processor_Signature use + record + Stepping at 0 range 0 .. 3; + Model at 0 range 4 .. 7; + Family at 0 range 8 .. 11; + Processor_Type at 0 range 12 .. 13; + Reserved at 0 range 14 .. 31; + end record; + + for Processor_Signature'Size use 32; + + ----------------------------------- + -- Processor features register -- + ----------------------------------- + + -- a processor register to hold the processor feature flags + + type Processor_Features is + record + FPU : Boolean; -- floating point unit on chip + VME : Boolean; -- virtual mode extension + DE : Boolean; -- debugging extension + PSE : Boolean; -- page size extension + TSC : Boolean; -- time stamp counter + MSR : Boolean; -- model specific registers + PAE : Boolean; -- physical address extension + MCE : Boolean; -- machine check extension + CX8 : Boolean; -- cmpxchg8 instruction + APIC : Boolean; -- on-chip apic hardware + Res_1 : Boolean; -- reserved for extensions + SEP : Boolean; -- fast system call + MTRR : Boolean; -- memory type range registers + PGE : Boolean; -- page global enable + MCA : Boolean; -- machine check architecture + CMOV : Boolean; -- conditional move supported + PAT : Boolean; -- page attribute table + PSE_36 : Boolean; -- 36-bit page size extension + Res_2 : Natural range 0 .. 31; -- reserved for extensions + MMX : Boolean; -- MMX technology supported + FXSR : Boolean; -- fast FP save and restore + Res_3 : Natural range 0 .. 127; -- reserved for extensions + end record; + + for Processor_Features use + record + FPU at 0 range 0 .. 0; + VME at 0 range 1 .. 1; + DE at 0 range 2 .. 2; + PSE at 0 range 3 .. 3; + TSC at 0 range 4 .. 4; + MSR at 0 range 5 .. 5; + PAE at 0 range 6 .. 6; + MCE at 0 range 7 .. 7; + CX8 at 0 range 8 .. 8; + APIC at 0 range 9 .. 9; + Res_1 at 0 range 10 .. 10; + SEP at 0 range 11 .. 11; + MTRR at 0 range 12 .. 12; + PGE at 0 range 13 .. 13; + MCA at 0 range 14 .. 14; + CMOV at 0 range 15 .. 15; + PAT at 0 range 16 .. 16; + PSE_36 at 0 range 17 .. 17; + Res_2 at 0 range 18 .. 22; + MMX at 0 range 23 .. 23; + FXSR at 0 range 24 .. 24; + Res_3 at 0 range 25 .. 31; + end record; + + for Processor_Features'Size use 32; + + ------------------- + -- Subprograms -- + ------------------- + + function Has_FPU return Boolean; + -- return True if a FPU is found + -- use only if CPUID is not supported + + function Has_CPUID return Boolean; + -- return True if the processor supports the CPUID instruction + + function CPUID_Level return Natural; + -- return the CPUID support level (0, 1 or 2) + -- can only be called if the CPUID instruction is supported + + function Vendor_ID return String; + -- return the processor vendor identification string + -- can only be called if the CPUID instruction is supported + + function Signature return Processor_Signature; + -- return the processor signature + -- can only be called if the CPUID instruction is supported + + function Features return Processor_Features; + -- return the processors features + -- can only be called if the CPUID instruction is supported + + private + + ------------------------ + -- EFLAGS bit names -- + ------------------------ + + ID_Flag : constant Num_Bits := 21; + -- ID flag bit + + end Intel_CPU; + +  + File: gnat_ug_vxw.info, Node: Intel_CPU Package Body, Prev: Intel_CPU Package Specification, Up: A Complete Example + + `Intel_CPU' Package Body + ------------------------ + + package body Intel_CPU is + + --------------------------- + -- Detect FPU presence -- + --------------------------- + + -- There is a FPU present if we can set values to the FPU Status + -- and Control Words. + + function Has_FPU return Boolean is + + Register : Unsigned_16; + -- processor register to store a word + + begin + + -- check if we can change the status word + Asm ( + + -- the assembler code + "finit" & LF & HT & -- reset status word + "movw $0x5A5A, %%ax" & LF & HT & -- set value status word + "fnstsw %0" & LF & HT & -- save status word + "movw %%ax, %0", -- store status word + + -- output stored in Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register), + + -- tell compiler that we used eax + Clobber => "eax"); + + -- if the status word is zero, there is no FPU + if Register = 0 then + return False; -- no status word + end if; -- check status word value + + -- check if we can get the control word + Asm ( + + -- the assembler code + "fnstcw %0", -- save the control word + + -- output into Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register)); + + -- check the relevant bits + if (Register and 16#103F#) /= 16#003F# then + return False; -- no control word + end if; -- check control word value + + -- FPU found + return True; + + end Has_FPU; + + -------------------------------- + -- Detect CPUID instruction -- + -------------------------------- + + -- The processor supports the CPUID instruction if it is possible + -- to change the value of ID flag bit in the EFLAGS register. + + function Has_CPUID return Boolean is + + Original_Flags, Modified_Flags : Processor_Register; + -- EFLAG contents before and after changing the ID flag + + begin + + -- try flipping the ID flag in the EFLAGS register + Asm ( + + -- the assembler code + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %%eax" & LF & HT & -- pop EFLAGS into eax + "movl %%eax, %0" & LF & HT & -- save EFLAGS content + "xor $0x200000, %%eax" & LF & HT & -- flip ID flag + "push %%eax" & LF & HT & -- push EFLAGS on stack + "popfl" & LF & HT & -- load EFLAGS register + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %1", -- save EFLAGS content + + -- output values, may be anything + -- Original_Flags is %0 + -- Modified_Flags is %1 + Outputs => + (Processor_Register'Asm_output ("=g", Original_Flags), + Processor_Register'Asm_output ("=g", Modified_Flags)), + + -- tell compiler eax is destroyed + Clobber => "eax"); + + -- check if CPUID is supported + if Original_Flags(ID_Flag) /= Modified_Flags(ID_Flag) then + return True; -- ID flag was modified + else + return False; -- ID flag unchanged + end if; -- check for CPUID + + end Has_CPUID; + + ------------------------------- + -- Get CPUID support level -- + ------------------------------- + + function CPUID_Level return Natural is + + Level : Unsigned_32; + -- returned support level + + begin + + -- execute CPUID, storing the results in the Level register + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero is stored in eax + -- returning the support level in eax + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- eax is stored in Level + Outputs => Unsigned_32'Asm_output ("=a", Level), + + -- tell compiler ebx, ecx and edx registers are destroyed + Clobber => "ebx, ecx, edx"); + + -- return the support level + return Natural (Level); + + end CPUID_Level; + + -------------------------------- + -- Get CPU Vendor ID String -- + -------------------------------- + + -- The vendor ID string is returned in the ebx, ecx and edx register + -- after executing the CPUID instruction with eax set to zero. + -- In case of a true Intel processor the string returned is + -- "GenuineIntel" + + function Vendor_ID return String is + + Ebx, Ecx, Edx : Unsigned_Register; + -- registers containing the vendor ID string + + Vendor_ID : String (1 .. 12); + -- the vendor ID string + + begin + + -- execute CPUID, storing the results in the processor registers + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero stored in eax + -- vendor ID string returned in ebx, ecx and edx + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- ebx is stored in Ebx + -- ecx is stored in Ecx + -- edx is stored in Edx + Outputs => (Unsigned_Register'Asm_output ("=b", Ebx), + Unsigned_Register'Asm_output ("=c", Ecx), + Unsigned_Register'Asm_output ("=d", Edx))); + + -- now build the vendor ID string + Vendor_ID( 1) := Character'Val (Ebx.L1); + Vendor_ID( 2) := Character'Val (Ebx.H1); + Vendor_ID( 3) := Character'Val (Ebx.L2); + Vendor_ID( 4) := Character'Val (Ebx.H2); + Vendor_ID( 5) := Character'Val (Edx.L1); + Vendor_ID( 6) := Character'Val (Edx.H1); + Vendor_ID( 7) := Character'Val (Edx.L2); + Vendor_ID( 8) := Character'Val (Edx.H2); + Vendor_ID( 9) := Character'Val (Ecx.L1); + Vendor_ID(10) := Character'Val (Ecx.H1); + Vendor_ID(11) := Character'Val (Ecx.L2); + Vendor_ID(12) := Character'Val (Ecx.H2); + + -- return string + return Vendor_ID; + + end Vendor_ID; + + ------------------------------- + -- Get processor signature -- + ------------------------------- + + function Signature return Processor_Signature is + + Result : Processor_Signature; + -- processor signature returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one is stored in eax + -- processor signature returned in eax + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- eax is stored in Result + Outputs => Processor_Signature'Asm_output ("=a", Result), + + -- tell compiler that ebx, ecx and edx are also destroyed + Clobber => "ebx, ecx, edx"); + + -- return processor signature + return Result; + + end Signature; + + ------------------------------ + -- Get processor features -- + ------------------------------ + + function Features return Processor_Features is + + Result : Processor_Features; + -- processor features returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one stored in eax + -- processor features returned in edx + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- edx is stored in Result + Outputs => Processor_Features'Asm_output ("=d", Result), + + -- tell compiler that ebx and ecx are also destroyed + Clobber => "ebx, ecx"); + + -- return processor signature + return Result; + + end Features; + + end Intel_CPU; + +  + File: gnat_ug_vxw.info, Node: VxWorks Topics, Next: LynxOS Topics, Prev: Inline Assembler, Up: Top + + VxWorks Topics + ************** + + This chapter describes topics that are specific to the GNAT for VxWorks + configurations. + + * Menu: + + * Kernel Configuration for VxWorks:: + * Kernel Compilation Issues for VxWorks:: + * Handling Relocation Issues for PowerPc Targets:: + * Support for Software Floating Point on PowerPC Processors:: + * Interrupt Handling for VxWorks:: + * Simulating Command Line Arguments for VxWorks:: + * Debugging Issues for VxWorks:: + * Using GNAT from the Tornado 2 Project Facility:: + * Frequently Asked Questions for VxWorks:: + +  + File: gnat_ug_vxw.info, Node: Kernel Configuration for VxWorks, Next: Kernel Compilation Issues for VxWorks, Up: VxWorks Topics + + Kernel Configuration for VxWorks + ================================ + + When configuring your VxWorks kernel we recommend including the target + shell. If you omit it from the configuration, you may get undefined + symbols at load time, e.g. + + -> ld < hello.exe + Loading hello.exe + Undefined symbols: + mkdir + + Generally, such undefined symbols are harmless since these are used by + optional parts of the GNAT run time. However if running your application + generates a VxWorks exception or illegal instruction, you should + reconfigure your kernel to resolve these symbols. + +  + File: gnat_ug_vxw.info, Node: Kernel Compilation Issues for VxWorks, Next: Handling Relocation Issues for PowerPc Targets, Prev: Kernel Configuration for VxWorks, Up: VxWorks Topics + + Kernel Compilation Issues for VxWorks + ===================================== + + If you plan to link an Ada module with a Tornado 2 Kernel, follow these + steps. (Note that these recommendations apply to `cygnus-2.7.2-960126', + shipped with Tornado 2 as the C compiler toolchain.) + + * Compile your Ada module without linking it with the VxWorks + Library: + gnatmake foo.adb -largs -nostdlib + + * Edit your makefile and add on the `LIBS' line the exact path and + name of the GCC library file provided with GNAT. + LIBS = $(WIND_BASE)/target/lib/libPPC604gnuvx.a \ + /opt/gnu/gnat/lib/gcc-lib/powerpc-wrs-vxworks/2.8.1/libgcc.a + + To know the exact name and location of this file, type `-gcc + -print-libgcc-file-name' in a console. Note that this version of + GCC is the one provided with GNAT. + ~ >powerpc-wrs-vxworks-gcc -print-libgcc-file-name + /opt/gnu/gnat/lib/gcc-lib/powerpc-wrs-vxworks/2.8.1/libgcc.a + +  + File: gnat_ug_vxw.info, Node: Handling Relocation Issues for PowerPc Targets, Next: Support for Software Floating Point on PowerPC Processors, Prev: Kernel Compilation Issues for VxWorks, Up: VxWorks Topics + + Handling Relocation Issues for PowerPc Targets + ============================================== + + Under certain circumstances, loading a program onto a PowerPC board + will fail with the message _Relocation value does not fit in 24 bits_. + + For some background on this issue, please refer to WRS' SPRs 6040, + 20257, and 22767. In summary, VxWorks on the PowerPC follows the + variation of the SVR4 ABI known as the Embedded ABI (_EABI_). In order + to save space and time in embedded applications, the EABI specifies + that the default for subprogram calls should be the branch instruction + with relative addressing using an immediate operand. The immediate + operand to this instruction (relative address) is 24 bits wide. It is + sign extended and 2#00# is appended for the last 2 bits (all + instructions must be on a 4 byte boundary). The resulting 26 bit + offset means that the target of the branch must be within +/- 32 Mbytes + of the relative branch instruction. When VxWorks is loading a program + it completes the linking phase by resolving all of the unresolved + references in the object being loaded. When one of those references is + a relative address in a branch instruction, and the linker determines + that the target is more than 32 Mbytes away from the branch, the error + occurs. + + This only happens when the BSP is configured to use more than 32 + MBytes of memory. The VxWorks kernel is loaded into low memory + addresses, and the error usually occurs when the target loader is used + (because it loads objects into high memory, and thus calls from the + program to the VxWorks kernel can be too far). + + One way to solve this problem is to use the Tornado host loader; + this will place programs in low memory, close to the kernel. + + Another approach is to make use of the `-mlongcall' option to the + compiler; GNAT has incorporated WRS' gcc modification that implements + this option. If a subprogram call is compiled with the `-mlongcall' + option, then the generated code constructs an absolute address in a + register and uses a branch instruction with absolute addressing mode. + + Starting with release 3.15, the GNAT runtime libraries that are + distributed are compiled with the `-mlongcall' option. In many cases + the use of these libraries is sufficient to avoid the relocation + problem, since it is the runtime library that contains calls to the + VxWorks kernel that need to span the address space gap. If you are + using an earlier GNAT release or a manually-built runtime, you should + recompile the GNAT runtime library with `-mlongcall'; you can use the + `Makefile.adalib' file from the `adalib' directory. + + Application code may need to be compiled with `-mlongcall' if there + are calls directly to the kernel, the application is very large, or in + some specialized linking/loading scenarios. + + You can compile individual files with `-mlongcall' by placing this + option on the `gcc' command line (for brevity we are omitting the + `powerpc-wrs-vxworks-' prefix on the commands shown in this paragraph). + If you provide `-mlongcall' as an option for `gnatmake', it will be + passed to all invocations of `gcc' that `gnatmake' directly performs. + Note that one other compilation is made by `gnatlink', on the file + created by `gnatbind' for the elaboration package body (see *Note + Binding Using gnatbind::). Passing `-mlongcall' to `gnatlink', either + directly on the `gnatlink' command line or by including `-mlongcall' in + the `-largs' list of `gnatmake', will direct `gnatlink' to compile the + binder file with the `-mlongcall' option. + + To see the effect of `-mlongcall', consider the following small + example: + + procedure Proc is + procedure Imported_Proc; + pragma Import (Ada, Imported_Proc); + begin + Imported_Proc; + end; + + If you compile `Proc' with the default options (no `-mlongcall'), the + following code is generated: + + _ada_proc: + ... + bl imported_proc + ... + + In contrast, here is the result with the `-mlongcall' option: + + _ada_proc: + ... + addis 9,0,imported_proc@ha + addi 0,9,imported_proc@l + mtlr 0 + blrl + ... + +  + File: gnat_ug_vxw.info, Node: Support for Software Floating Point on PowerPC Processors, Next: Interrupt Handling for VxWorks, Prev: Handling Relocation Issues for PowerPc Targets, Up: VxWorks Topics + + Support for Software Floating Point on PowerPC Processors + ========================================================= + + The PowerPC 860 processor does not have hardware floating-point support. + In order to build and run GNAT modules properly, you need to install and + invoke software-emulated floating-point support as follows: + + * At installation time: + * Create a file `ada_object_path' under the directory + `BASE\lib\gcc-lib\powerpc-wrs-vxworks\2.8.1' (by default + `BASE'=`c:\gnatpro') containing the following line: + rts-soft-float\adalib + + * Create a file `ada_source_path' under the directory + `BASE\lib\gcc-lib\powerpc-wrs-vxworks\2.8.1' (by default + `BASE'=`c:\gnatpro') containing the following line: + rts-soft-float\adainclude + + * When using the compiler, specify `-msoft-float' as a compiler and + a linker option, e.g.: + $powerpc-wrs-vxworks-gnatmake -msoft-float module -largs -msoft-float + +  + File: gnat_ug_vxw.info, Node: Interrupt Handling for VxWorks, Next: Simulating Command Line Arguments for VxWorks, Prev: Support for Software Floating Point on PowerPC Processors, Up: VxWorks Topics + + Interrupt Handling for VxWorks + ============================== + + GNAT offers a range of options for hardware interrupt handling. In rough + order of latency and lack of restrictions: + + * Directly vectored interrupt procedure handlers + + * Directly vectored interrupt procedures that signal a task using a + suspension object + + * Ada 95 protected procedure handlers for interrupts + + * Ada 83 style interrupt entry handlers for interrupts + + In general, the range of possible solutions trades off latency versus + restrictions in the handler code. Restrictions in direct vectored + interrupt handlers are documented in the `VxWorks Programmer's Guide'. + Protected procedure handlers have only the restriction that no + potentially blocking operations are performed within the handler. + Interrupt entries have no restrictions. We recommend the use of the + protected procedure mechanism as providing the best balance of these + considerations for most applications. + + All handler types must explicitly perform any required hardware + cleanups, such as issuing an end-of-interrupt if necessary. + + For VxWorks/AE, applications that handle interrupts must be loaded + into the kernel protection domain. + + * Direct Vectored Interrupt Routines + + This approach provides the lowest interrupt latency, but has the + most restrictions on what VxWorks and Ada runtime calls can be + made, as well as on what Ada entities are accessible to the + handler code. Such handlers are most useful when there are + stringent latency requirements, and very little processing is to + be performed in the handler. Access to the necessary VxWorks + routines for setting up such handlers is provided in the package + `Interfaces.VxWorks'. + + VxWorks restrictions are described in the `VxWorks Programmer's + Manual'. Note in particular that floating point context is not + automatically saved and restored when interrupts are vectored to + the handler. If the handler is to execute floating point + instructions, the statements involved must be bracketed by a pair + of calls to `fppSave' and `fppRestore' defined in + `Interfaces.VxWorks'. + + In general, it is a good idea to save and restore the handler that + was installed prior to application startup. The routines + `intVecGet' and `intVecSet' are used for this purpose. The Ada + handler code is installed into the vector table using routine + `intConnect', which generates wrapper code to save and restore + registers. + + Example: + + with Interfaces.VxWorks; use Interfaces.VxWorks; + with System; + + package P is + + Count : Natural := 0; + pragma Atomic (Count); + + -- Interrupt level used by this example + Level : constant := 1; + + -- Be sure to use a reasonable interrupt number for the target + -- board! Refer to the BSP for details. + Interrupt : constant := 16#14#; + + procedure Handler (Parameter : System.Address); + + end P; + + package body P is + + procedure Handler (parameter : System.Address) is + S : Status; + begin + Count := Count + 1; + -- Acknowledge interrupt. Not necessary for all interrupts. + S := sysBusIntAck (intLevel => Level); + end Handler; + end P; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + with Ada.Text_IO; use Ada.Text_IO; + + with P; use P; + procedure Useint is + task T; + + S : Status; + + task body T is + begin + for I in 1 .. 10 loop + Put_Line ("Generating an interrupt..."); + delay 1.0; + + -- Generate interrupt, using interrupt number + S := sysBusIntGen (Level, Interrupt); + end loop; + end T; + + -- Save old handler + Old_Handler : VOIDFUNCPTR := intVecGet (INUM_TO_IVEC (Interrupt)); + begin + S := intConnect (INUM_TO_IVEC (Interrupt), Handler'Access); + S := sysIntEnable (intLevel => Level); + + for I in 1 .. 10 loop + delay 2.0; + Put_Line ("value of count:" & P.Count'Img); + end loop; + + -- Restore previous handler + S := sysIntDisable (intLevel => Level); + intVecSet (INUM_TO_IVEC (Interrupt), Old_Handler); + end Useint; + + * Direct Vectored Interrupt Routines + + A variation on the direct vectored routine that allows for less + restrictive handler code is to separate the interrupt processing + into two levels. + + The first level is the same as in the previous section. Here we + perform simple hardware actions and signal a task pending on a + Suspension_Object (defined in `Ada.Synchronous_Task_Control') to + perform the more complex and time-consuming operations. The + routine `Set_True' signals a task whose body loops and pends on + the suspension object using `Suspend_Until_True'. The suspension + object is declared in a scope global to both the handler and the + task. This approach can be thought of as a slightly higher-level + application of the `C' example using a binary semaphore given in + the VxWorks Programmer's Manual. In fact, the implementation of + `Ada.Synchronous_Task_Control' is a very thin wrapper around a + VxWorks binary semaphore. + + This approach has a latency between the direct vectored approach + and the protected procedure approach. There are no restrictions + in the Ada task code, while the handler code has the same + restrictions as any other direct interrupt handler. + + Example: + + with System; + package Sem_Handler is + + Count : Natural := 0; + pragma Atomic (Count); + + -- Interrupt level used by this example + Level : constant := 1; + Interrupt : constant := 16#14#; + + -- Interrupt handler providing "immediate" handling + procedure Handler (Param : System.Address); + + -- Task whose body provides "deferred" handling + task Receiver is + pragma Interrupt_Priority + (System.Interrupt_Priority'First + Level + 1); + end Receiver; + + end Sem_Handler; + + with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control; + with Interfaces.VxWorks; use Interfaces.VxWorks; + package body Sema_Handler is + + SO : Suspension_Object; + + task body Receiver is + begin + loop + -- Wait for notification from immediate handler + Suspend_Until_True (SO); + + -- Interrupt processing + Count := Count + 1; + end loop; + end Receiver; + + procedure Handler (Param : System.Address) is + S : STATUS; + begin + -- Hardware cleanup, if necessary + S := sysBusIntAck (Level); + + -- Signal the task + Set_True (SO); + end Handler; + + end Sem_Handler; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + with Ada.Text_IO; use Ada.Text_IO; + with Sem_Handler; use Sem_Handler; + procedure Useint is + + S : STATUS; + + task T; + + task body T is + begin + for I in 1 .. 10 loop + Put_Line ("Generating an interrupt..."); + delay 1.0; + + -- Generate interrupt, using interrupt number + S := sysBusIntGen (Level, Interrupt); + end loop; + end T; + + -- Save old handler + Old_Handler : VOIDFUNCPTR := intVecGet (INUM_TO_IVEC (Interrupt)); + begin + S := intConnect (INUM_TO_IVEC (Interrupt), Handler'Access); + S := sysIntEnable (intLevel => Level); + + for I in 1 .. 10 loop + delay 2.0; + Put_Line ("value of Count:" & Sem_Handler.Count'Img); + end loop; + + -- Restore handler + S := sysIntDisable (intLevel => Level); + intVecSet (INUM_TO_IVEC (Interrupt), Old_Handler); + abort Receiver; + end Useint; + + * Protected Procedure Handlers for Interrupts + + This is the recommended default mechanism for interrupt handling. + It essentially wraps the hybrid handler / task mechanism in a + higher-level abstraction, and provides a good balance between + latency and capability. + + Vectored interrupts are designated by their interrupt number, + starting from 0 and ranging to the number of entries in the + interrupt vector table - 1. + + In the GNAT VxWorks implementation, the following priority + mappings are used: + * Normal task priorities are in the range 0 .. 245. + + * Interrupt priority 246 is used by the GNAT `Interrupt_Manager' + task. + + * Interrupt priority 247 is used for vectored interrupts that + do not correspond to those generated via an interrupt + controller. + + * Interrupt priorities 248 .. 255 correspond to PIC interrupt + levels 0 .. 7. + + * Priority 256 is reserved to the VxWorks kernel. + + Except for reserved priorities, the above are recommendations for + setting the ceiling priority of a protected object that handles + interrupts, or the priority of a task with interrupt entries. + It's a very good idea to follow these recommendations for vectored + interrupts that come in through the PIC as it will determine the + priority of execution of the code in the protected procedure or + interrupt entry. + + No vectored interrupt numbers are reserved in this implementation, + because dedicated interrupts are determined by the board support + package. Obviously, careful consideration of the hardware is + necessary when handling interrupts. The VxWorks BSP for the board + is the definitive reference for interrupt assignments. + + Example: + + package PO_Handler is + + -- Interrupt level used by this example + Level : constant := 1; + + Interrupt : constant := 16#14#; + + protected Protected_Handler is + procedure Handler; + pragma Attach_Handler (Handler, Interrupt); + + function Count return Natural; + + pragma Interrupt_Priority (248); + private + The_Count : Natural := 0; + end Protected_Handler; + + end PO_Handler; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + package body PO_Handler is + + protected body Protected_Handler is + + procedure Handler is + S : Status; + begin + -- Hardware cleanup if necessary + S := sysBusIntAck (Level); + + -- Interrupt processing + The_Count := The_Count + 1; + end Handler; + + function Count return Natural is + begin + return The_Count; + end Count; + end Protected_Handler; + + end PO_Handler; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + with Ada.Text_IO; use Ada.Text_IO; + + with PO_Handler; use PO_Handler; + procedure Useint is + + task T; + + S : STATUS; + + task body T is + begin + for I in 1 .. 10 loop + Put_Line ("Generating an interrupt..."); + delay 1.0; + + -- Generate interrupt, using interrupt number + S := sysBusIntGen (Level, Interrupt); + end loop; + end T; + + begin + S := sysIntEnable (intLevel => Level); + + for I in 1 .. 10 loop + delay 2.0; + Put_Line ("value of count:" & Protected_Handler.Count'Img); + end loop; + + S := sysIntDisable (intLevel => Level); + end Useint; + + This is obviously significantly higher-level and easier to write + than the previous examples. + + * Ada 83 Style Interrupt Entries + + GNAT provides a full implementation of the Ada 83 interrupt entry + mechanism for vectored interrupts. However, due to latency issues, + we only recommend using these for backward compatibility. The + comments in the previous section regarding interrupt priorities + and reserved interrupts apply here. + + In order to associate an interrupt with an entry, GNAT provides the + standard Ada convenience routine `Ada.Interrupts.Reference'. It + is used as follows: + + Interrupt_Address : constant System.Address := + Ada.Interrupts.Reference (Int_Num); + + task Handler_Task is + pragma Interrupt_Priority (248); -- For instance + entry Handler; + for Handler'Address use Interrupt_Address; + end Handler_Task; + + Since there is no restriction within an interrupt entry on + blocking operations, be sure to perform any hardware interrupt + controller related operations before executing a call that could + block within the entry's accept statements. It is assumed that + interrupt entries are always open alternatives when they appear + within a selective wait statement. The presence of a guard gives + undefined behavior. + + Example: + + with Ada.Interrupts; + with System; + package Task_Handler is + + -- Interrupt level used by this example + Level : constant := 1; + + Interrupt : constant := 16#14#; + + Interrupt_Address : constant System.Address := + Ada.Interrupts.Reference (Int_Num); + + task Handler_Task is + pragma Interrupt_Priority (248); -- For instance + entry Handler; + for Handler'Address use Interrupt_Address; + + entry Count (Value : out Natural); + end Handler_Task; + end Task_Handler; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + package body Task_Handler is + + task body Handler_Task is + The_Count : Natural := 0; + S : STATUS; + begin + loop + select + accept Handler do + -- Hardware cleanup if necessary + S := sysBusIntAck (Level); + + -- Interrupt processing + The_Count := The_Count + 1; + end Handler; + or + accept Count (Value : out Natural) do + Value := The_Count; + end Count; + end select; + end loop; + end Handler_Task; + + end Handler_Task; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + with Ada.Text_IO; use Ada.Text_IO; + + with Handler_Task; use Handler_Task; + procedure Useint is + + task T; + + S : STATUS; + Current_Count : Natural := 0; + + task body T is + begin + for I in 1 .. 10 loop + Put_Line ("Generating an interrupt..."); + delay 1.0; + + -- Generate interrupt, using interrupt number + S := sysBusIntGen (Level, Interrupt); + end loop; + end T; + + begin + S := sysIntEnable (intLevel => Level); + + for I in 1 .. 10 loop + delay 2.0; + Handler_Task.Count (Current_Count); + Put_Line ("value of count:" & Current_Count'Img); + end loop; + + S := sysIntDisable (intLevel => Level); + abort Handler_Task; + end Useint; + +  + File: gnat_ug_vxw.info, Node: Simulating Command Line Arguments for VxWorks, Next: Debugging Issues for VxWorks, Prev: Interrupt Handling for VxWorks, Up: VxWorks Topics + + Simulating Command Line Arguments for VxWorks + ============================================= + + The GNAT implementation of `Ada.Command_Line' relies on the standard C + symbols `argv' and `argc'. The model for invoking "programs" under + VxWorks does not provide these symbols. The typical method for + invoking a program under VxWorks is to call the `sp' function in order + to spawn a thread in which to execute a designated function (in GNAT, + this is the implicit main generated by gnatbind. `sp' provides the + capability to push a variable number of arguments onto the stack when + the function is invoked. But this does not work for the implicit Ada + main, because it has no way of knowing how many arguments might be + required. This eliminates the possibility to use `Ada.Command_Line'. + + One way to solve this problem is to define symbols in the VxWorks + environment, then import them into the Ada application. For example, + we could define the following package that imports two symbols, one an + int and the other a string: + + with Interfaces.C.Strings; + use Interfaces.C.Strings; + package Args is + -- Define and import a variable for each argument + Int_Arg : Interfaces.C.Int; + String_Arg : Chars_Ptr; + private + pragma Import (C, Int_Arg, "intarg"); + pragma Import (C, String_Arg, "stringarg"); + end Args; + + An Ada unit could then use the two imported variables `Int_Arg' and + `String_Arg' as follows: + + with Args; use Args; + with Interfaces.C.Strings; + use Interfaces.C, Interfaces.C.Strings; + with Ada.Text_IO; use Ada.Text_IO; + procedure Argtest is + begin + Put_Line (Int'Image (Int_Arg)); + Put_Line (Value (String_Arg)); + end Argtest; + + When invoking the application from the shell, one will then set the + values to be imported, and spawn the application, as follows: + + -> intarg=10 + -> stringarg="Hello" + -> sp (argtest) + +  + File: gnat_ug_vxw.info, Node: Debugging Issues for VxWorks, Next: Using GNAT from the Tornado 2 Project Facility, Prev: Simulating Command Line Arguments for VxWorks, Up: VxWorks Topics + + Debugging Issues for VxWorks + ============================ + + The debugger can be launched directly from the Tornado environment or + from `glide' through its graphical interface: `gvd'. It can also be used + directly in text mode as shown below: + + The command to run `GDB' in text mode is + + $ target-gdb + + where target is the name of target of the cross GNAT compiler. In + contrast with native `gdb', it is not useful to give the name of the + program to debug on the command line. Before starting a debugging + session, one needs to connect to the VxWorks-configured board and load + the relocatable object produced by `gnatlink'. This can be achieved by + the following commands: + + (vxgdb) target wtx myboard + (vxgdb) load program + + where `myboard' is the host name or IP number of the target board, and + `wtx' is the name of debugging protocol used to communicate with the + VxWorks board. Early versions of VxWorks, up tp 5.2, only support the + `' protocol whereas starting with VxWorks 5.3 and Tornado, + another protocol called `' was made available. The choice of the + protocol can be made when configuring the VxWorks kernel itself. When + available, the `' is greatly preferable and actually the only + supported protocol with GNAT. When the debugger is launched directly + from Tornado, the proper `target' command is automatically generated by + the environment. + + The GNAT debugger can be used for debugging multitasking programs in + two different modes and some minimal understanding of these modes is + necessary in order to use the debugger effectively. The two modes are: + + * Monotask mode: attach to, and debug, a single task. This mode is + equivalent to the capabilities offered by CrossWind. The debugger + interacts with a single task, while not affecting other tasks + (insofar as possible). This is the DEFAULT mode. + + * Multitask mode: The debugger has control over all Ada tasks in an + application. It is possible to gather information about all + application tasks, and to switch from one to another within a + single debugging session. + + It is not advised to switch between the two modes within a debugging + session. A third mode called System mode is also available and can be + used in place of the Multitask mode. Consult the Tornado documentation + for this. + + Among the criteria for selecting the appropriate mode is the effect + of task synchronization on the application's behavior. Debugging a + tasking application affects the timing of the application; minimizing + such effects may be critical in certain situations. The two modes have + different effects: monotask mode only affects the attached task: others + will run normally (if possible). Multitask mode stops all tasks at each + breakpoint and restarts them on single-step, next, finish or continue; + this may help avoid deadlocks in the presence of task synchronization + despite the inherent latency of stopping and restarting the tasks. + + Using the debugger in monotask mode + ----------------------------------- + + There are two ways to begin your debugging session: + + * The program is already running on the board. + + The sequence of commands to use this mode is: + * Launch GVD (possibly from the Tornado menu) + + Verify that the debugger has access to the debug information + of both your program and the kernel. The Console window + should have a message "Looking for all loaded modules:" + followed by the names of the modules on the board and "ok". + If you have some error messages here instead of "ok", the + debugging session may not work as expected. + + * Attach to the desired task using + File --> Attach... + + This task is stopped by the debugger. Other tasks continue to + operate normally (unless they are blocked by synchronization + with the stopped task). The source window should display the + code on which the task has been stopped, and if the stack + display is enabled, it should reflect the stack of the task. + + * The program hasn't been loaded yet on the board + * Launch GVD (possibly from the Tornado menu) + + * Load your program to the board: + File --> Open Program... + + GVD should display: + Downloading your_program ...done. + Reading symbols from your_program...expanding to full symbols...done. + + * Set breakpoints in your program. + + WARNING: they must be set in the main task (if your program + runs several tasks) + + * Run your program using one of the three methods below: + * Click on button or + + * Menu + Program --> Run/Start + + * Type in GVD's Console window + (gdb) run your_program + + * Whichever method you chose to start your debugging session, you + can use the following commands at this point: + * Browse sources and set breakpoints + + * Examine the call stack (Data -> call stack) + + * Go "up" and "down" in the call stack ("up" & "down" buttons) + + * Examine data (Data -> Display local variables, or any of the + other methods for viewing data in GVD) + + * Continue/finish + + Next/step/finish will only work if the top frame in the call stack + has debug information. This is almost never the case when first + attaching to the task since the task is usually stopped by the + attach operation in the GNAT runtime. You can verify which frames + of the call stack have debug information by: + Data --> call stack + (contextual menu inside the call stack window) + add "file location" + + If the current frame does not have a "file location", then there + is no debug information for the frame. We strongly recommended + that you set breakpoints in the source where debug information can + be found and "continue" until a breakpoint is reached before using + "next/step". Another convenient possibility is to use the "continue + until" capability available from the contextual menu of the Source + window. + + You can also examine the state of other tasks using + Data -> tasks + + but you can't "switch" to another task by clicking on the elements + of the task list. If you try to, you will get an error message in + GVD's console: + "Task switching is not allowed when multi-tasks mode is not active" + + Once you have completed your debugging session on the attached + task, you can detach from the task: + File --> detach + + The task resumes normal execution at this stage. WARNING: when you + detach from a task, be sure that you are in a frame where there is + debug information. Otherwise, the task won't resume properly. You + can then start another attach/detach cycle if you wish. + + Note that it is possible to launch several GVD sessions and + simultaneously attach each to a distinct task in monotask mode: + File --> New Debugger... (uncheck the box: Replace Current Debugger) + File --> Attach... (in the new window) + File --> detach + + Using the debugger in Multitask mode + ------------------------------------ + + The steps are as follows + + * Launch GVD (possibly from the Tornado menu) + + There are two possibilities: + * If the program is already loaded on the target board, you + need only verify that debug information has been found by the + debugger as described above. + + * Otherwise, load the program on the board using + File --> Open program + + * Set breakpoints in the desired parts of the program + + * Start the program + + The simplest way to start the debugger in multitask mode is to use + the menu + Program --> Run/Start + + and check the box "enable vxWorks multi-tasks mode". You can also + use the following gdb commands in the console window + (gdb) set multi-tasks-mode on + (gdb) run your_program + + * Debug the stopped program + + Once stopped at a breakpoint (or if you pressed the "stop" + button), you can use all the standard commands listed for monotask + mode + task switching (using Data -> tasks). Using next/step under + this mode is possible with the same restrictions as for monotask + mode, but is not recommended because all tasks are restarted, + leading to the possibility that a different task hits a breakpoint + before the stepping operation has completed. Such an occurrence + can result in a confusing state for both the user and the + debugger. So we strongly suggest the use of only breakpoints and + "continue" in this mode. + + A final reminder: whatever the mode, whether you are debugging or + not, the program has to be reloaded before each new execution, so that + data initialized by the loader is set correctly. For instance, if you + wish to restart the same execution of the same program, you can use the + following sequence of gdb commands in the console window: + (gdb) detach + (gdb) unload your_program(.exe) + (gdb) load your_program(.exe) + (gdb) run your_program + +  + File: gnat_ug_vxw.info, Node: Using GNAT from the Tornado 2 Project Facility, Next: Frequently Asked Questions for VxWorks, Prev: Debugging Issues for VxWorks, Up: VxWorks Topics + + Using GNAT from the Tornado 2 Project Facility + ============================================== + + * Menu: + + * The GNAT Toolchain as Used from the Tornado 2 Project Facility:: + * Building a Simple Application:: + * Mixing C and Ada Code in a Tornado 2 Project:: + * Compilation Switches:: + * Autoscale and Minimal Kernel Configuration:: + * Adapting BSPs to GNAT:: + * Using GNAT Project Files in a Tornado 2 Project:: + + This section describes how to add an Ada module in a Tornado project + using the Tornado 2 Project facility described in `Tornado User's + Guide', Chapter 4. All recommendations apply for both 'Downloadable + Modules' and 'Kernel' project types. + +  + File: gnat_ug_vxw.info, Node: The GNAT Toolchain as Used from the Tornado 2 Project Facility, Next: Building a Simple Application, Up: Using GNAT from the Tornado 2 Project Facility + + The GNAT Toolchain as Used from the Tornado 2 Project Facility + -------------------------------------------------------------- + + Tornado 2 allows you to integrate third-party C toolchains. (`Tornado + 2 API Programmer's Guide', Chapter 7). Thus the GNAT toolchain will be + seen as a new C toolchain when used from the Tornado 2 Project + Facility. For each processor you can compile for, you will find a + gnat toolchain, e.g. PPC604gnat. These toolchains will allow you + to include Ada modules into your projects, and simply build them. + + The name of the so-called C compiler is _cc_gnat__, the name + of the 'linker' is _ld_gnat__, where is an architecture; + e.g., PPC. These scripts will call the correct executables during the + compilation or link processes, thus the C compiler, the C linker, or + the GNAT toolchain, depending on the context. + +  + File: gnat_ug_vxw.info, Node: Building a Simple Application, Next: Mixing C and Ada Code in a Tornado 2 Project, Prev: The GNAT Toolchain as Used from the Tornado 2 Project Facility, Up: Using GNAT from the Tornado 2 Project Facility + + Building a Simple Application + ----------------------------- + + First, create a new project, using one of the gnat toolchains. + + To add an Ada source file to the current project, just click on + `Project -> Add/Include', browse to the relevant file, and include it. + The Ada source file included should be the Ada entry point. Only one + Ada entry point is allowed in a project. Any other required Ada source + files will be automatically compiled and linked by the underlying tools. + + You can now compile the project, `Build->Rebuild all'. A log of the + compilation process can be found in the build directory, in + `gnatbuild.log'. It contains all the calls executed by the scripts, and + associated information. + +  + File: gnat_ug_vxw.info, Node: Mixing C and Ada Code in a Tornado 2 Project, Next: Compilation Switches, Prev: Building a Simple Application, Up: Using GNAT from the Tornado 2 Project Facility + + Mixing C and Ada Code in a Tornado 2 Project + -------------------------------------------- + + You can mix C and Ada code in your projects. Your source files and the + build options should comply with the recommendations from the section + `Interfacing to C'. This means that you can have several or no C + source files, and one or no Ada entry point in your Tornado 2 Project. + +  + File: gnat_ug_vxw.info, Node: Compilation Switches, Next: Autoscale and Minimal Kernel Configuration, Prev: Mixing C and Ada Code in a Tornado 2 Project, Up: Using GNAT from the Tornado 2 Project Facility + + Compilation Switches + -------------------- + + Once you have included all your source files, you may modify some + compilation and linking options. To pass specific options to the GNAT + toolchain, go to the Project's build settings, on the `C/C++ Compiler' + tab, and add your arguments in the input window. + + You must comply with several rules to pass arguments to GNAT. + Arguments to be passed should be + + * after any arguments passed to the C toolchain. + + * prefixed depending on the tool that uses them, with the following + syntax + + * `-cargs _gnatmake-options_' to pass arguments to gnatmake + + * `-bargs _gnatbind-options_' to pass arguments to gnatbind + + * `-largs _gnatlink-options_' to pass arguments to gnatlink + + You will find more information on the compilation process of Ada source + files in the section `The GNAT Compilation Model'. For a list of all + available switches, refer to the sections describing `gnatmake', + `gnatbind' and `gnatlink'. + + Here is an example that passes the option `-v' to the GNAT compiler : + -g -mstrict-align -prjtype $(PRJ_TYPE) -ansi -nostdinc -DRW_MULTI_THREAD -D_REENTRANT + -fvolatile -fno-builtin -fno-for-scope -I. -I/usr/windppc-2.0/target/h -DCPU=PPC604 + -cargs -v + + Here is an example that passes the option `-v' to the GNAT compiler, + binder and linker, and `-v' and `-g' to the compiler : + -g -mstrict-align -prjtype $(PRJ_TYPE) -ansi -nostdinc -DRW_MULTI_THREAD -D_REENTRANT + -fvolatile -fno-builtin -fno-for-scope -I. -I/usr/windppc-2.0/target/h -DCPU=PPC604 + -cargs -v -g -O2 -bargs -v -largs -v + + In both examples, the following arguments have been automatically added + by the Project Facility, and will be used by the C compiler. + -g -mstrict-align -prjtype $(PRJ_TYPE) -ansi -nostdinc -DRW_MULTI_THREAD -D_REENTRANT + -fvolatile -fno-builtin -fno-for-scope -I. -I/usr/windppc-2.0/target/h -DCPU=PPC604 + + Note: The `-prjtype $(PRJ_TYPE)' option present in a few input boxes is + used by the GNAT toolchain. It is required for the compilation process. + You should not remove it from any input box. + +  + File: gnat_ug_vxw.info, Node: Autoscale and Minimal Kernel Configuration, Next: Adapting BSPs to GNAT, Prev: Compilation Switches, Up: Using GNAT from the Tornado 2 Project Facility + + Autoscale and Minimal Kernel Configuration + ------------------------------------------ + + The Autoscale feature, present in the Project Facility can be used on + your VxWorks Kernel projects to determine the minimum set of components + required for your kernel to work. (Please refer to the `Tornado II + User's Guide' Section 4.4 for more details.) This feature is also + available for projects involving Ada code. Just click on + `Project->Autoscale' to launch a check and determine the minimal kernel + configuration. + +  + File: gnat_ug_vxw.info, Node: Adapting BSPs to GNAT, Next: Using GNAT Project Files in a Tornado 2 Project, Prev: Autoscale and Minimal Kernel Configuration, Up: Using GNAT from the Tornado 2 Project Facility + + Adapting BSPs to GNAT + --------------------- + + To use your Board Support Packages with the GNAT toolchain, you will + have to adapt them, either manually or using the `adaptbsp4gnat' script. + This procedure is described in the `Tornado API Programmer's Guide', + Chapter 7. Here is a summary of this setup, depending on the context. + + * To do the adaptation manually: + + * Copy your BSP directory contents into a new directory + + * Go to this directory + + * Edit the file `Makefile', + + * Set tool to gnat, `TOOL=gnat' + + * Reverse the order of the following lines + * `include $(TGT_DIR)/h/make/make.$(CPU)$(TOOL)' + + * `include $(TGT_DIR)/h/make/defs.$(WIND_HOST_TYPE)' + + + + * To do the adaptation automatically, you may use the `adaptbsp4gnat' + script. Its syntax is `adaptbsp4gnat '. + + This script follows the different steps described above to perform + the adaptation. The name of the new bsp is given after the + modification. By default, if `' is the name of your BSP, + `-gnat', will be the name of the BSP created. + +  + File: gnat_ug_vxw.info, Node: Using GNAT Project Files in a Tornado 2 Project, Prev: Adapting BSPs to GNAT, Up: Using GNAT from the Tornado 2 Project Facility + + Using GNAT Project Files in a Tornado 2 Project + ----------------------------------------------- + + You can use GNAT Project files to compile your Ada files. To do so, + you need to use the `-Pproject_file.gpr' option from `gnatmake'. The + path to the project file can be either absolute, or relative to the + build directory, i.e. where the executable will be placed (e.g. + `~/myproject/PPC604gnat'). Your project file should set the + `Object_Dir' variable to a specific value. + project Sample is + + Target := external ("TARGET_DIR"); + for Object_Dir use Target; + + end Sample; + +  + File: gnat_ug_vxw.info, Node: Frequently Asked Questions for VxWorks, Prev: Using GNAT from the Tornado 2 Project Facility, Up: VxWorks Topics + + Frequently Asked Questions for VxWorks + ====================================== + + * When I run my program twice on the board, it does not work, why? + + Usually, Ada programs require elaboration and finalization, so the + compiler creates a wrapper procedure whose name is the same as the + Ada name of the main subprogram, which takes care of calling the + elaboration and finalization routines before and after your + program. But the static part of the elaboration is taken care of + while loading the program itself and thus if you launch it twice + this part of the elaboration will not be performed. This affects + the proper elaboration of the GNAT runtime and thus it is + mandatory to reload your program before relaunching it. + + * Can I load a collection of subprograms rather than a standalone + program? + + It is possible to write Ada programs with multiple entry points + which can be called from the VxWorks shell; you just need to + consider your main program as the VxWorks shell itself and + generate an Ada subsystem callable from outside *Note Binding with + Non-Ada Main Programs::. If you use this method, you need to call + `adainit' manually before calling any Ada entry point. + + * When I use the `break exception' command, I get the message + `"exception" is not a function', why? + + You are not in the proper language mode. Issue the command: + (vxgdb) set language ada + + * When I load a large application from the VxWorks shell using the + "ld" command, the load hangs and never finishes. How can I load + large executables? + + This is a classic VxWorks problem when using the default "rsh" + communication method. Using NFS instead should work. Use the + `nfsShowMount' command to verify that your program is in a NFS + mounted directory. + + * When I load a large application from the debugger using the wtx + target connection, the load never finishes, why? + + Make sure that the memory cache size parameter of the target + server is large enough. (`target -m big_enough_size', or Memory + cache size box in GUI.) See `Tornado 1.01 API Programming Guide', + Section 3.6.2. + + * When I spawn my program under the VxWorks shell, interactive input + does not work, why? + + Only programs directly launched from the shell can have interactive + input. For a program spawned with the `sp' or `taskSpawn' command, + you need to have file redirection for input: + -> # here you can have interactive input + -> main + -> # here you cannot + -> sp main + -> # neither here + -> taskSpawn("ess",100,0,8000000,main) + -> # but you can input from a file: + -> taskSpawn("Bae",100,0,8000000,main) < input_file + +  + File: gnat_ug_vxw.info, Node: LynxOS Topics, Next: Performance Considerations, Prev: VxWorks Topics, Up: Top + + LynxOS Topics + ************* + + This chapter describes topics that are specific to the GNAT for LynxOS + cross configurations. + + * Menu: + + * Getting Started with GNAT on LynxOS:: + * Kernel Configuration for LynxOS:: + * Patch Level Issues for LynxOS:: + * Debugging Issues for LynxOS:: + * An Example Debugging Session for LynxOS:: + +  + File: gnat_ug_vxw.info, Node: Getting Started with GNAT on LynxOS, Next: Kernel Configuration for LynxOS, Up: LynxOS Topics + + Getting Started with GNAT on LynxOS + =================================== + + This section is a starting point for using GNAT to develop and execute + Ada 95 programs for LynuxWorks' LynxOS target environment from a Unix + host environment. We assume that you know how to use GNAT in a native + environment and how to start a telnet or other login session to connect + to your LynxOS board. + + To compile code for a LynxOS system running on a PowerPC board, the + basic compiler command is `powerpc-xcoff-lynxos-gcc'. + + With GNAT, the easiest way to build the basic `Hello World' program + is with `gnatmake'. For the LynxOS PowerPC target this would look like: + + $ powerpc-xcoff-lynxos-gnatmake hello + powerpc-xcoff-lynxos-gcc -c hello.adb + powerpc-xcoff-lynxos-gnatbind -x hello.ali + powerpc-xcoff-lynxos-gnatlink hello.ali + + (The first line is the command entered by the user - the subseqent three + are the programs run by `gnatmake'.) + + This creates the executable `hello'" which you then need to load on + the board (using ftp or an NFS directory for example) to run it. + +  + File: gnat_ug_vxw.info, Node: Kernel Configuration for LynxOS, Next: Patch Level Issues for LynxOS, Prev: Getting Started with GNAT on LynxOS, Up: LynxOS Topics + + Kernel Configuration for LynxOS + =============================== + + The appropriate configuration for your LynxOS kernel depends on the + target system and the requirements of your application. GNAT itself + adds no additional demands; however in some situations it may be + appropriate to increase the conservative resource assumptions made by + the default configuration. + + Kernel parameters limiting the maximum number of file descriptors, + kernel and user threads, synchronization objects, etc., may be set in + the file `uparam.h'. You may also wish to modify the file + `/etc/starttab', which places limits on data, stack, and core file + size. See the documentation provided by LynuxWorks for more information. + +  + File: gnat_ug_vxw.info, Node: Patch Level Issues for LynxOS, Next: Debugging Issues for LynxOS, Prev: Kernel Configuration for LynxOS, Up: LynxOS Topics + + Patch Level Issues for LynxOS + ============================= + + The GNAT runtime requires that your system run at patch level 040 or + later. Please see the file `PatchCompatibility.txt' from the + distribution for more information. + +  + File: gnat_ug_vxw.info, Node: Debugging Issues for LynxOS, Next: An Example Debugging Session for LynxOS, Prev: Patch Level Issues for LynxOS, Up: LynxOS Topics + + Debugging Issues for LynxOS + =========================== + + GNAT's debugger is based on the same GNU gdb technology as the debugger + provided by LynxOS, though with a great number of extensions and + enhancements to support the Ada language and GNAT. The LynxOS + documentation is relevant to understanding how to get the debugger + started if you run into difficulties. + + To demonstrate a debugging session, we will use a slightly more + complex program called `demo1.adb', which can be found in the `examples' + directory of the GNAT distribution. This program is compiled with + debugging information as follows: + + $ powerpc-xcoff-lynxos-gnatmake -g demo1 + powerpc-xcoff-lynxos-gcc -c -g demo1.adb + powerpc-xcoff-lynxos-gcc -c -g gen_list.adb + powerpc-xcoff-lynxos-gcc -c -g instr.adb + powerpc-xcoff-lynxos-gnatbind -x demo1.ali + powerpc-xcoff-lynxos-gnatlink -g demo1.ali + + Once the executable is created, copy it to your working directory on the + board. In this directory, you will have to launch the gdb server and + choose a free port number on your TCP/IP socket. Presuming the Internet + hostname of the board is `myboard' and the port chosen is 2345, issue + the following command: + + myboard> gdbserver myboard:2345 demo1 + + Then return to your host environment. + + The graphical debugger interface, `gvd', supports both native and + cross environments at the same time. `gvd' can be launched from `Glide' + (see `README.Glide' for more information on customizing `Glide' for + LynxOS) or it can be launched from the command line as follows: + + $ gvd --debugger powerpc-xcoff-lynxos-gdb + + Then to attach to the target, enter in `gvd''s command line window: + + (gdb) target remote myboard:2345 + + For more information see the GVD documentation. + + The comments below concern debugging directly from the command line + but they also apply to `gvd', though in most cases an equivalent + graphical command is also available. + + To run the cross debugger from the command line without the visual + interface use the command `powerpc-xcoff-lynxos-gdb'. + + You will see something like: + + GNU gdb 4.17.gnat.3.14a1 + Copyright 1998 Free Software Foundation, Inc. + GDB is free software, covered by the GNU General Public License, and you are + welcome to change it and/or distribute copies of it under certain conditions. + Type "show copying" to see the conditions. + There is absolutely no warranty for GDB. Type "show warranty" for details. + This GDB was configured as "--host=sparc-sun-solaris2.5.1 --target=powerpc-xc + off-lynxos". + (gdb) + + Where `(gdb)' is the debugger's prompt. The first thing to do at the + prompt from within `gdb' is to load the symbol table from the + executable: + + (gdb) file demo1 + Reading symbols from demo1...done. + (gdb) + + You then have to attach to the server running on the board. Issue the + command: + + (gdb) target remote myboard:2345 + + After the server has been started and attached from the host, the + program is running on the target but has halted execution at the very + beginning. The following commands set a breakpoint and continue + execution: + + (gdb) break demo1.adb:37 + Breakpoint 1 at 0x100064d0: file demo1.adb, line 37. + (gdb) cont + Continuing. + + Breakpoint 1, demo1 () at demo1.adb:37 + 37 Set_Name (Fuel, "Fuel"); + (gdb) + + Here the execution has stopped at the breakpoint set above. Now you can + use the standard `gdb' commands to examine the stack and program + variables. + + Note that once execution has completed, the server on the board must + be restarted before a new debugging session may begin. + +  + File: gnat_ug_vxw.info, Node: An Example Debugging Session for LynxOS, Prev: Debugging Issues for LynxOS, Up: LynxOS Topics + + An Example Debugging Session for LynxOS + ======================================= + + Carrying on a little further with the debugging session, the following + example illustrates some of the usual debugging commands for moving + around and seeing where you are: + + (gdb) next + 38 Set_Name (Water, "Water"); + (gdb) bt + #0 demo1 () at demo1.adb:38 + #1 0x10001218 in main (argc=1, argv=2147483640, envp=2147483520) at + b~demo1.adb:118 + #2 0x10017538 in runmainthread () + #3 0x10001048 in __start () + (gdb) up + #1 0x10001218 in main (argc=1, argv=2147483640, envp=2147483520) at + b~demo1.adb:118 + 118 Ada_Main_Program; + (gdb) down + #0 demo1 () at demo1.adb:38 + 38 Set_Name (Water, "Water"); + (gdb) + + To examine and modify variables (of a tagged type here): + + (gdb) print speed + $1 = (name => "Speed ", value => -286331154) + (gdb) ptype speed + type = new instr.instrument with record + value: instr.speed; + end record + (gdb) speed.value := 3 + $2 = 3 + (gdb) print speed + $3 = (name => "Speed ", value => 3) + (gdb) info local + speed = (name => "Speed ", value => 3) + fuel = (name => "Fuel ", value => -286331154) + oil = (name => ' ' , value => -286331154, size => 20, + fill => 42 '*', empty => 46 '.') + water = (name => ' ' , value => -286331154, size => 20, + fill => 42 '*', empty => 46 '.') + time = (name => ' ' , seconds => 0, minutes => 0, hours => + 0) + chrono = (name => ' ' , seconds => 0, minutes => 0, + hours => 0) + db = (access demo1.dash_board.internal) 0x0 + (gdb) + + And finally letting the program it run to completion: + + (gdb) c + Continuing. + + Program exited normally. + (gdb) + +  + File: gnat_ug_vxw.info, Node: Performance Considerations, Next: GNU Free Documentation License, Prev: LynxOS Topics, Up: Top + + Performance Considerations + ************************** + + The GNAT system provides a number of options that allow a trade-off + between + + * performance of the generated code + + * speed of compilation + + * minimization of dependences and recompilation + + * the degree of run-time checking. + + The defaults (if no options are selected) aim at improving the speed of + compilation and minimizing dependences, at the expense of performance + of the generated code: + + * no optimization + + * no inlining of subprogram calls + + * all run-time checks enabled except overflow and elaboration checks + + These options are suitable for most program development purposes. This + chapter describes how you can modify these choices, and also provides + some guidelines on debugging optimized code. + + * Menu: + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + +  + File: gnat_ug_vxw.info, Node: Controlling Run-Time Checks, Next: Optimization Levels, Up: Performance Considerations + + Controlling Run-Time Checks + =========================== + + By default, GNAT generates all run-time checks, except arithmetic + overflow checking for integer operations and checks for access before + elaboration on subprogram calls. The latter are not required in default + mode, because all necessary checking is done at compile time. Two gnat + switches, `-gnatp' and `-gnato' allow this default to be modified. + *Note Run-Time Checks::. + + Our experience is that the default is suitable for most development + purposes. + + We treat integer overflow specially because these are quite + expensive and in our experience are not as important as other run-time + checks in the development process. Note that division by zero is not + considered an overflow check, and divide by zero checks are generated + where required by default. + + Elaboration checks are off by default, and also not needed by + default, since GNAT uses a static elaboration analysis approach that + avoids the need for run-time checking. This manual contains a full + chapter discussing the issue of elaboration checks, and if the default + is not satisfactory for your use, you should read this chapter. + + For validity checks, the minimal checks required by the Ada Reference + Manual (for case statements and assignments to array elements) are on + by default. These can be suppressed by use of the `-gnatVn' switch. + Note that in Ada 83, there were no validity checks, so if the Ada 83 + mode is acceptable (or when comparing GNAT performance with an Ada 83 + compiler), it may be reasonable to routinely use `-gnatVn'. Validity + checks are also suppressed entirely if `-gnatp' is used. + + Note that the setting of the switches controls the default setting of + the checks. They may be modified using either `pragma Suppress' (to + remove checks) or `pragma Unsuppress' (to add back suppressed checks) + in the program source. + +  + File: gnat_ug_vxw.info, Node: Optimization Levels, Next: Debugging Optimized Code, Prev: Controlling Run-Time Checks, Up: Performance Considerations + + Optimization Levels + =================== + + The default is optimization off. This results in the fastest compile + times, but GNAT makes absolutely no attempt to optimize, and the + generated programs are considerably larger and slower than when + optimization is enabled. You can use the `-ON' switch, where N is an + integer from 0 to 3, on the `gcc' command line to control the + optimization level: + + `-O0' + no optimization (the default) + + `-O1' + medium level optimization + + `-O2' + full optimization + + `-O3' + full optimization, and also attempt automatic inlining of small + subprograms within a unit (*note Inlining of Subprograms::). + + Higher optimization levels perform more global transformations on the + program and apply more expensive analysis algorithms in order to + generate faster and more compact code. The price in compilation time, + and the resulting improvement in execution time, both depend on the + particular application and the hardware environment. You should + experiment to find the best level for your application. + + Note: Unlike some other compilation systems, `gcc' has been tested + extensively at all optimization levels. There are some bugs which + appear only with optimization turned on, but there have also been bugs + which show up only in _unoptimized_ code. Selecting a lower level of + optimization does not improve the reliability of the code generator, + which in practice is highly reliable at all optimization levels. + + Note regarding the use of `-O3': The use of this optimization level + is generally discouraged with GNAT, since it often results in larger + executables which run more slowly. See further discussion of this point + in *note Inlining of Subprograms::. + +  + File: gnat_ug_vxw.info, Node: Debugging Optimized Code, Next: Inlining of Subprograms, Prev: Optimization Levels, Up: Performance Considerations + + Debugging Optimized Code + ======================== + + Since the compiler generates debugging tables for a compilation unit + before it performs optimizations, the optimizing transformations may + invalidate some of the debugging data. You therefore need to + anticipate certain anomalous situations that may arise while debugging + optimized code. This section describes the most common cases. + + 1. The "hopping Program Counter": Repeated 'step' or 'next' commands + show the PC bouncing back and forth in the code. This may result + from any of the following optimizations: + + * Common subexpression elimination: using a single instance of + code for a quantity that the source computes several times. + As a result you may not be able to stop on what looks like a + statement. + + * Invariant code motion: moving an expression that does not + change within a loop, to the beginning of the loop. + + * Instruction scheduling: moving instructions so as to overlap + loads and stores (typically) with other code, or in general + to move computations of values closer to their uses. Often + this causes you to pass an assignment statement without the + assignment happening and then later bounce back to the + statement when the value is actually needed. Placing a + breakpoint on a line of code and then stepping over it may, + therefore, not always cause all the expected side-effects. + + 2. The "big leap": More commonly known as cross-jumping, in which two + identical pieces of code are merged and the program counter + suddenly jumps to a statement that is not supposed to be executed, + simply because it (and the code following) translates to the same + thing as the code that _was_ supposed to be executed. This effect + is typically seen in sequences that end in a jump, such as a + `goto', a `return', or a `break' in a C `switch' statement. + + 3. The "roving variable": The symptom is an unexpected value in a + variable. There are various reasons for this effect: + + * In a subprogram prologue, a parameter may not yet have been + moved to its "home". + + * A variable may be dead, and its register re-used. This is + probably the most common cause. + + * As mentioned above, the assignment of a value to a variable + may have been moved. + + * A variable may be eliminated entirely by value propagation or + other means. In this case, GCC may incorrectly generate + debugging information for the variable + + In general, when an unexpected value appears for a local variable + or parameter you should first ascertain if that value was actually + computed by your program, as opposed to being incorrectly reported + by the debugger. Record fields or array elements in an object + designated by an access value are generally less of a problem, + once you have ascertained that the access value is sensible. + Typically, this means checking variables in the preceding code and + in the calling subprogram to verify that the value observed is + explainable from other values (one must apply the procedure + recursively to those other values); or re-running the code and + stopping a little earlier (perhaps before the call) and stepping + to better see how the variable obtained the value in question; or + continuing to step _from_ the point of the strange value to see if + code motion had simply moved the variable's assignments later. + +  + File: gnat_ug_vxw.info, Node: Inlining of Subprograms, Prev: Debugging Optimized Code, Up: Performance Considerations + + Inlining of Subprograms + ======================= + + A call to a subprogram in the current unit is inlined if all the + following conditions are met: + + * The optimization level is at least `-O1'. + + * The called subprogram is suitable for inlining: It must be small + enough and not contain nested subprograms or anything else that + `gcc' cannot support in inlined subprograms. + + * The call occurs after the definition of the body of the subprogram. + + * Either `pragma Inline' applies to the subprogram or it is small + and automatic inlining (optimization level `-O3') is specified. + + Calls to subprograms in `with''ed units are normally not inlined. To + achieve this level of inlining, the following conditions must all be + true: + + * The optimization level is at least `-O1'. + + * The called subprogram is suitable for inlining: It must be small + enough and not contain nested subprograms or anything else `gcc' + cannot support in inlined subprograms. + + * The call appears in a body (not in a package spec). + + * There is a `pragma Inline' for the subprogram. + + * The `-gnatn' switch is used in the `gcc' command line + + Note that specifying the `-gnatn' switch causes additional + compilation dependencies. Consider the following: + + package R is + procedure Q; + pragma Inline (Q); + end R; + package body R is + ... + end R; + + with R; + procedure Main is + begin + ... + R.Q; + end Main; + + With the default behavior (no `-gnatn' switch specified), the + compilation of the `Main' procedure depends only on its own source, + `main.adb', and the spec of the package in file `r.ads'. This means + that editing the body of `R' does not require recompiling `Main'. + + On the other hand, the call `R.Q' is not inlined under these + circumstances. If the `-gnatn' switch is present when `Main' is + compiled, the call will be inlined if the body of `Q' is small enough, + but now `Main' depends on the body of `R' in `r.adb' as well as on the + spec. This means that if this body is edited, the main program must be + recompiled. Note that this extra dependency occurs whether or not the + call is in fact inlined by `gcc'. + + The use of front end inlining with `-gnatN' generates similar + additional dependencies. + + Note: The `-fno-inline' switch can be used to prevent all inlining. + This switch overrides all other conditions and ensures that no inlining + occurs. The extra dependences resulting from `-gnatn' will still be + active, even if this switch is used to suppress the resulting inlining + actions. + + Note regarding the use of `-O3': There is no difference in inlining + behavior between `-O2' and `-O3' for subprograms with an explicit + pragma `Inline' assuming the use of `-gnatn' or `-gnatN' (the switches + that activate inlining). If you have used pragma `Inline' in + appropriate cases, then it is usually much better to use `-O2' and + `-gnatn' and avoid the use of `-O3' which in this case only has the + effect of inlining subprograms you did not think should be inlined. We + often find that the use of `-O3' slows down code by performing + excessive inlining, leading to increased instruction cache pressure + from the increased code size. So the bottom line here is that you + should not automatically assume that `-O3' is better than `-O2', and + indeed you should use `-O3' only if tests show that it actually + improves performance. + +  + File: gnat_ug_vxw.info, Node: GNU Free Documentation License, Next: Index, Prev: Performance Considerations, Up: Top + + GNU Free Documentation License + ****************************** + + Version 1.2, November 2002 + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. + We recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it + can be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You + accept the license if you copy, modify or distribute the work in a + way requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in + the notice that says that the Document is released under this + License. If a section does not fit the above definition of + Secondary then it is not allowed to be designated as Invariant. + The Document may contain zero Invariant Sections. If the Document + does not identify any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images + composed of pixels) generic paint programs or (for drawings) some + widely available drawing editor, and that is suitable for input to + text formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in an + otherwise Transparent file format whose markup, or absence of + markup, has been arranged to thwart or discourage subsequent + modification by readers is not Transparent. An image format is + not Transparent if used for any substantial amount of text. A + copy that is not "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and + standard-conforming simple HTML, PostScript or PDF designed for + human modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats that + can be read and edited only by proprietary word processors, SGML or + XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML, PostScript or PDF + produced by some word processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow + the conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the + title equally prominent and visible. You may add other material + on the covers in addition. Copying with changes limited to the + covers, as long as they preserve the title of the Document and + satisfy these conditions, can be treated as verbatim copying in + other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a computer-network location from + which the general network-using public has access to download + using public-standard network protocols a complete Transparent + copy of the Document, free of added material. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of + copies, to give them a chance to provide you with an updated + version of the Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with + the Modified Version filling the role of the Document, thus + licensing distribution and modification of the Modified Version to + whoever possesses a copy of it. In addition, you must do these + things in the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of + previous versions (which should, if there were any, be listed + in the History section of the Document). You may use the + same title as a previous version if the original publisher of + that version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on + the Title Page. If there is no section Entitled "History" in + the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, + then add an item describing the Modified Version as stated in + the previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in + the "History" section. You may omit a network location for a + work that was published at least four years before the + Document itself, or if the original publisher of the version + it refers to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the + section all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section + titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end + of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the + documents in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow + this License in all other respects regarding verbatim copying of + that document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warrany Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided for under this License. Any other + attempt to copy, modify, sublicense or distribute the Document is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + `http://www.gnu.org/copyleft/'. + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If + the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. + + ADDENDUM: How to use this License for your documents + ==================================================== + + To use this License in a document you have written, include a copy of + the License in the document and put the following copyright and license + notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover + Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other + combination of the three, merge those two alternatives to suit the + situation. + + If your document contains nontrivial examples of program code, we + recommend releasing these examples in parallel under your choice of + free software license, such as the GNU General Public License, to + permit their use in free software. + +  + File: gnat_ug_vxw.info, Node: Index, Prev: GNU Free Documentation License, Up: Top + + Index + ***** + + * Menu: + + * --GCC= (gnatchop): Switches for gnatchop. + * --GCC=compiler_name (gnatlink): Switches for gnatlink. + * --GCC=compiler_name (gnatmake): Switches for gnatmake. + * --GNATBIND=binder_name (gnatmake): Switches for gnatmake. + * --GNATLINK=linker_name (gnatmake): Switches for gnatmake. + * --LINK= (gnatlink): Switches for gnatlink. + * --RTS (gcc): Switches for gcc. + * --RTS (gnatbind): Summary of Binder Switches. + * --RTS (gnatfind): gnatfind Switches. + * --RTS (gnatls): Switches for gnatls. + * --RTS (gnatmake): Switches for gnatmake. + * --RTS (gnatxref): gnatxref Switches. + * -83 (gnathtml): Converting Ada Files to html with gnathtml. + * -A (gnatbind): Output Control. + * -A (gnatlink): Switches for gnatlink. + * -a (gnatls): Switches for gnatls. + * -A (gnatmake): Switches for gnatmake. + * -a (gnatmake): Switches for gnatmake. + * -aI (gnatmake): Switches for gnatmake. + * -aL (gnatmake): Switches for gnatmake. + * -aO (gnatmake): Switches for gnatmake. + * -B (gcc): Switches for gcc. + * -b (gcc): Switches for gcc. + * -b (gnatbind): Binder Error Message Control. + * -B (gnatlink): Switches for gnatlink. + * -b (gnatlink): Switches for gnatlink. + * -b (gnatmake): Switches for gnatmake. + * -bargs (gnatmake): Mode Switches for gnatmake. + * -c (gcc): Switches for gcc. + * -C (gnatbind): Output Control. + * -c (gnatbind): Output Control. + * -c (gnatchop): Switches for gnatchop. + * -C (gnatlink): Switches for gnatlink. + * -C (gnatmake): Switches for gnatmake. + * -c (gnatmake): Switches for gnatmake. + * -c (gnatname): Switches for gnatname. + * -cargs (gnatmake): Mode Switches for gnatmake. + * -d (gnathtml): Converting Ada Files to html with gnathtml. + * -d (gnatls): Switches for gnatls. + * -D (gnatname): Switches for gnatname. + * -d (gnatname): Switches for gnatname. + * -e (gnatbind): Output Control. + * -f (gnathtml): Converting Ada Files to html with gnathtml. + * -f (gnatlink): Switches for gnatlink. + * -f (gnatmake): Switches for gnatmake. + * -fno-inline (gcc): Inlining of Subprograms. + * -fstack-check: Stack Overflow Checking. + * -g (gcc): Switches for gcc. + * -g (gnatlink): Switches for gnatlink. + * -gnat83 (gcc): Compiling Ada 83 Programs. + * -gnata (gcc): Debugging and Assertion Control. + * -gnatb (gcc): Output and Error Message Control. + * -gnatc (gcc): Using gcc for Semantic Checking. + * -gnatD (gcc): Debugging Control. + * -gnatdc switch: GNAT Abnormal Termination or Failure to Terminate. + * -gnatE (gcc) <1>: Debugging Control. + * -gnatE (gcc): Run-Time Checks. + * -gnatem (gcc): Units to Sources Mapping Files. + * -gnatf (gcc): Output and Error Message Control. + * -gnatG (gcc): Debugging Control. + * -gnati (gcc): Character Set Control. + * -gnatk (gcc): File Naming Control. + * -gnatl (gcc): Output and Error Message Control. + * -gnatm (gcc): Output and Error Message Control. + * -gnatn (gcc): Inlining of Subprograms. + * -gnatN (gcc): Subprogram Inlining Control. + * -gnatn (gcc): Subprogram Inlining Control. + * -gnatN switch: Source Dependencies. + * -gnatn switch: Source Dependencies. + * -gnato (gcc) <1>: Controlling Run-Time Checks. + * -gnato (gcc): Run-Time Checks. + * -gnatp (gcc) <1>: Controlling Run-Time Checks. + * -gnatp (gcc): Run-Time Checks. + * -gnatq (gcc): Output and Error Message Control. + * -gnatR (gcc): Debugging Control. + * -gnats (gcc): Using gcc for Syntax Checking. + * -gnatt (gcc): Auxiliary Output Control. + * -gnatT (gcc): Run-Time Control. + * -gnatu (gcc): Auxiliary Output Control. + * -gnatU (gcc): Output and Error Message Control. + * -gnatv (gcc): Output and Error Message Control. + * -gnatW (gcc): Character Set Control. + * -gnatwA (gcc): Output and Error Message Control. + * -gnatwa (gcc): Output and Error Message Control. + * -gnatwB (gcc): Output and Error Message Control. + * -gnatwb (gcc): Output and Error Message Control. + * -gnatwC (gcc): Output and Error Message Control. + * -gnatwc (gcc): Output and Error Message Control. + * -gnatwD (gcc): Output and Error Message Control. + * -gnatwd (gcc): Output and Error Message Control. + * -gnatwe (gcc): Output and Error Message Control. + * -gnatwF (gcc): Output and Error Message Control. + * -gnatwf (gcc): Output and Error Message Control. + * -gnatwH (gcc): Output and Error Message Control. + * -gnatwh (gcc): Output and Error Message Control. + * -gnatwI (gcc): Output and Error Message Control. + * -gnatwi (gcc): Output and Error Message Control. + * -gnatwL (gcc): Output and Error Message Control. + * -gnatwl (gcc): Output and Error Message Control. + * -gnatwO (gcc): Output and Error Message Control. + * -gnatwo (gcc): Output and Error Message Control. + * -gnatwP (gcc): Output and Error Message Control. + * -gnatwp (gcc): Output and Error Message Control. + * -gnatwR (gcc): Output and Error Message Control. + * -gnatwr (gcc): Output and Error Message Control. + * -gnatws (gcc): Output and Error Message Control. + * -gnatwU (gcc): Output and Error Message Control. + * -gnatwu (gcc): Output and Error Message Control. + * -gnatx (gcc): Debugging Control. + * -h (gnatbind) <1>: Output Control. + * -h (gnatbind): Elaboration Control. + * -h (gnatls): Switches for gnatls. + * -h (gnatname): Switches for gnatname. + * -I (gcc): Switches for gcc. + * -I (gnathtml): Converting Ada Files to html with gnathtml. + * -I (gnatmake): Switches for gnatmake. + * -i (gnatmake): Switches for gnatmake. + * -I- (gcc): Switches for gcc. + * -I- (gnatmake): Switches for gnatmake. + * -j (gnatmake): Switches for gnatmake. + * -K (gnatbind): Output Control. + * -k (gnatchop): Switches for gnatchop. + * -k (gnatmake): Switches for gnatmake. + * -l (gnatbind): Output Control. + * -l (gnathtml): Converting Ada Files to html with gnathtml. + * -L (gnatmake): Switches for gnatmake. + * -l (gnatmake): Switches for gnatmake. + * -largs (gnatmake): Mode Switches for gnatmake. + * -M (gnatbind): Binder Error Message Control. + * -m (gnatbind): Binder Error Message Control. + * -M (gnatmake): Switches for gnatmake. + * -m (gnatmake): Switches for gnatmake. + * -mlongcall (gcc): Handling Relocation Issues for PowerPc Targets. + * -n (gnatbind): Binding with Non-Ada Main Programs. + * -n (gnatlink): Switches for gnatlink. + * -n (gnatmake): Switches for gnatmake. + * -nostdinc (gnatmake): Switches for gnatmake. + * -nostdlib (gnatmake): Switches for gnatmake. + * -O (gcc) <1>: Optimization Levels. + * -O (gcc): Switches for gcc. + * -o (gcc): Switches for gcc. + * -o (gnatbind): Output Control. + * -O (gnatbind): Output Control. + * -o (gnathtml): Converting Ada Files to html with gnathtml. + * -o (gnatlink): Switches for gnatlink. + * -o (gnatls): Switches for gnatls. + * -o (gnatmake): Switches for gnatmake. + * -p (gnatchop): Switches for gnatchop. + * -p (gnathtml): Converting Ada Files to html with gnathtml. + * -P (gnatname): Switches for gnatname. + * -pass-exit-codes (gcc): Auxiliary Output Control. + * -q (gnatchop): Switches for gnatchop. + * -q (gnatmake): Switches for gnatmake. + * -r (gnatbind): Output Control. + * -r (gnatchop): Switches for gnatchop. + * -S (gcc): Switches for gcc. + * -s (gnatbind): Consistency-Checking Modes. + * -s (gnatls): Switches for gnatls. + * -s (gnatmake): Switches for gnatmake. + * -sc (gnathtml): Converting Ada Files to html with gnathtml. + * -t (gnatbind): Binder Error Message Control. + * -t (gnathtml): Converting Ada Files to html with gnathtml. + * -u (gnatls): Switches for gnatls. + * -u (gnatmake): Switches for gnatmake. + * -V (gcc): Switches for gcc. + * -v (gcc): Switches for gcc. + * -v (gnatbind): Binder Error Message Control. + * -v (gnatchop): Switches for gnatchop. + * -v (gnatlink): Switches for gnatlink. + * -v (gnatmake): Switches for gnatmake. + * -v (gnatname): Switches for gnatname. + * -v -v (gnatlink): Switches for gnatlink. + * -w: Output and Error Message Control. + * -w (gnatchop): Switches for gnatchop. + * -we (gnatbind): Binder Error Message Control. + * -ws (gnatbind): Binder Error Message Control. + * -x (gnatbind): Consistency-Checking Modes. + * -z (gnatbind): Binding Programs with No Main Subprogram. + * -z (gnatmake): Switches for gnatmake. + * __gnat_finalize: Running gnatbind. + * __gnat_initialize: Running gnatbind. + * __gnat_set_globals: Running gnatbind. + * _main: The External Symbol Naming Scheme of GNAT. + * Access before elaboration: Run-Time Checks. + * Access-to-subprogram: Elaboration for Access-to-Subprogram Values. + * ACVC, Ada 83 tests: Compiling Ada 83 Programs. + * Ada <1>: Naming Conventions for GNAT Source Files. + * Ada: Search Paths for gnatbind. + * Ada 83 compatibility: Compiling Ada 83 Programs. + * Ada 95 Language Reference Manual: What You Should Know before Reading This Guide. + * Ada expressions: Using Ada Expressions. + * Ada Library Information files: The Ada Library Information Files. + * Ada.Characters.Latin_1: Latin-1. + * ADA_INCLUDE_PATH: Search Paths and the Run-Time Library (RTL). + * ADA_OBJECTS_PATH: Search Paths for gnatbind. + * adafinal <1>: Binding with Non-Ada Main Programs. + * adafinal: Running gnatbind. + * adainit <1>: Binding with Non-Ada Main Programs. + * adainit: Running gnatbind. + * Address Clauses, warnings: Output and Error Message Control. + * ali files: The Ada Library Information Files. + * Annex A: Naming Conventions for GNAT Source Files. + * Annex B: Naming Conventions for GNAT Source Files. + * Arbitrary File Naming Conventions: Handling Arbitrary File Naming Conventions Using gnatname. + * Asm: Calling Conventions. + * Assert: Debugging and Assertion Control. + * Assertions: Debugging and Assertion Control. + * Biased rounding: Output and Error Message Control. + * Binder consistency checks: Binder Error Message Control. + * Binder output file: Interfacing to C. + * Binder, multiple input files: Binding with Non-Ada Main Programs. + * Breakpoints and tasks: Ada Tasks. + * C: Calling Conventions. + * C++: Calling Conventions. + * Calling Conventions: Calling Conventions. + * Check, elaboration: Run-Time Checks. + * Check, overflow: Run-Time Checks. + * Check_CPU procedure: Check_CPU Procedure. + * Checks, access before elaboration: Run-Time Checks. + * Checks, division by zero: Run-Time Checks. + * Checks, elaboration: Checking the Elaboration Order in Ada 95. + * Checks, overflow: Controlling Run-Time Checks. + * Checks, suppressing: Run-Time Checks. + * COBOL: Calling Conventions. + * code page 437: Other 8-Bit Codes. + * code page 850: Other 8-Bit Codes. + * Combining GNAT switches: Switches for gcc. + * Command line length: Switches for gnatlink. + * Compilation model: The GNAT Compilation Model. + * Conditionals, constant: Output and Error Message Control. + * Configuration pragmas: Configuration Pragmas. + * Consistency checks, in binder: Binder Error Message Control. + * Convention Ada: Calling Conventions. + * Convention Asm: Calling Conventions. + * Convention Assembler: Calling Conventions. + * Convention C: Calling Conventions. + * Convention C++: Calling Conventions. + * Convention COBOL: Calling Conventions. + * Convention Default: Calling Conventions. + * Convention DLL: Calling Conventions. + * Convention External: Calling Conventions. + * Convention Fortran: Calling Conventions. + * Convention Stdcall: Calling Conventions. + * Convention Stubbed: Calling Conventions. + * Convention Win32: Calling Conventions. + * Conventions: Conventions. + * CR: Source Representation. + * Cyrillic: Other 8-Bit Codes. + * Debug: Debugging and Assertion Control. + * Debug Pool: Finding Memory Problems with GNAT Debug Pool. + * Debugger: Running and Debugging Ada Programs. + * Debugging: Running and Debugging Ada Programs. + * Debugging Generic Units: Debugging Generic Units. + * Debugging information, including: Switches for gnatlink. + * Debugging options: Debugging Control. + * Default: Calling Conventions. + * Dependencies, producing list: Switches for gnatmake. + * Dependency rules: The GNAT Make Program gnatmake. + * Dereferencing, implicit: Output and Error Message Control. + * Division by zero: Run-Time Checks. + * DLL: Calling Conventions. + * EABI (for VxWorks on PowerPc): Handling Relocation Issues for PowerPc Targets. + * Elaborate: Controlling the Elaboration Order in Ada 95. + * Elaborate_All: Controlling the Elaboration Order in Ada 95. + * Elaborate_Body: Controlling the Elaboration Order in Ada 95. + * Elaboration checks <1>: Checking the Elaboration Order in Ada 95. + * Elaboration checks: Run-Time Checks. + * Elaboration control <1>: Summary of Procedures for Elaboration Control. + * Elaboration control: Elaboration Order Handling in GNAT. + * Elaboration of library tasks: Elaboration Issues for Library Tasks. + * Elaboration order control: Comparison between GNAT and C/C++ Compilation Models. + * Elaboration, warnings: Output and Error Message Control. + * Eliminate: Eliminate Pragma. + * Embedded ABI (for VxWorks on PowerPc): Handling Relocation Issues for PowerPc Targets. + * End of source file: Source Representation. + * Error messages, suppressing: Output and Error Message Control. + * EUC Coding: Wide Character Encodings. + * Exceptions: Ada Exceptions. + * Export: The External Symbol Naming Scheme of GNAT. + * External: Calling Conventions. + * FDL, GNU Free Documentation License: GNU Free Documentation License. + * FF: Source Representation. + * File names <1>: Alternative File Naming Schemes. + * File names: Using Other File Names. + * File naming schemes, alternative: Alternative File Naming Schemes. + * Foreign Languages: Calling Conventions. + * Formals, unreferenced: Output and Error Message Control. + * Fortran: Calling Conventions. + * gdb: Running and Debugging Ada Programs. + * Generic formal parameters: Compiling Ada 83 Programs. + * Generics <1>: Debugging Generic Units. + * Generics: Generating Object Files. + * Glide: Introduction to Glide and GVD. + * GNAT <1>: Naming Conventions for GNAT Source Files. + * GNAT: Search Paths for gnatbind. + * GNAT Abnormal Termination or Failure to Terminate: GNAT Abnormal Termination or Failure to Terminate. + * GNAT compilation model: The GNAT Compilation Model. + * GNAT library: Comparison between GNAT and Conventional Ada Library Models. + * gnat.adc <1>: The Configuration Pragmas Files. + * gnat.adc: Using Other File Names. + * gnat1: Compiling Programs. + * gnat_argc: Command-Line Access. + * gnat_argv: Command-Line Access. + * GNAT_STACK_LIMIT: Stack Overflow Checking. + * gnatbind: Binding Using gnatbind. + * gnatchop: Renaming Files Using gnatchop. + * gnatelim: Reducing the Size of Ada Executables with gnatelim. + * gnatfind: The Cross-Referencing Tools gnatxref and gnatfind. + * gnatkr: File Name Krunching Using gnatkr. + * gnatlink: Linking Using gnatlink. + * gnatls: The GNAT Library Browser gnatls. + * gnatmake: The GNAT Make Program gnatmake. + * gnatprep: Preprocessing Using gnatprep. + * gnatstub: Creating Sample Bodies Using gnatstub. + * gnatxref: The Cross-Referencing Tools gnatxref and gnatfind. + * GNU make: Using gnatmake in a Makefile. + * GVD: Introduction to Glide and GVD. + * Hiding of Declarations: Output and Error Message Control. + * HT: Source Representation. + * Implicit dereferencing: Output and Error Message Control. + * Inline <1>: Inlining of Subprograms. + * Inline: Source Dependencies. + * Inlining: Comparison between GNAT and Conventional Ada Library Models. + * Inlining, warnings: Output and Error Message Control. + * Intel_CPU package body: Intel_CPU Package Body. + * Intel_CPU package specification: Intel_CPU Package Specification. + * Interfaces <1>: Naming Conventions for GNAT Source Files. + * Interfaces: Search Paths for gnatbind. + * Interfacing to Ada: Calling Conventions. + * Interfacing to Assembly: Calling Conventions. + * Interfacing to C: Calling Conventions. + * Interfacing to C++: Calling Conventions. + * Interfacing to COBOL: Calling Conventions. + * Interfacing to Fortran: Calling Conventions. + * Internal trees, writing to file: Auxiliary Output Control. + * Latin-1 <1>: Latin-1. + * Latin-1: Source Representation. + * Latin-2: Other 8-Bit Codes. + * Latin-3: Other 8-Bit Codes. + * Latin-4: Other 8-Bit Codes. + * Latin-5: Other 8-Bit Codes. + * LF: Source Representation. + * Library browser: The GNAT Library Browser gnatls. + * Library tasks, elaboration issues: Elaboration Issues for Library Tasks. + * Library, building, installing: GNAT and Libraries. + * Linker libraries: Switches for gnatmake. + * Machine_Overflows: Run-Time Checks. + * Main Program: Running gnatbind. + * make: Using the GNU make Utility. + * makefile: Using gnatmake in a Makefile. + * Mixed Language Programming: Mixed Language Programming. + * Multiple units, syntax checking: Using gcc for Syntax Checking. + * No code generated: Compiling Programs. + * No_Entry_Calls_In_Elaboration_Code: Elaboration Issues for Library Tasks. + * Object file list: Running gnatbind. + * Order of elaboration: Elaboration Order Handling in GNAT. + * Other Ada compilers: Calling Conventions. + * Overflow checks <1>: Controlling Run-Time Checks. + * Overflow checks: Run-Time Checks. + * Parallel make: Switches for gnatmake. + * Performance: Performance Considerations. + * PowerPc VxWorks, relocation issues: Handling Relocation Issues for PowerPc Targets. + * pragma Elaborate: Controlling the Elaboration Order in Ada 95. + * pragma Elaborate_All: Controlling the Elaboration Order in Ada 95. + * pragma Elaborate_Body: Controlling the Elaboration Order in Ada 95. + * pragma Inline: Inlining of Subprograms. + * pragma Preelaborate: Controlling the Elaboration Order in Ada 95. + * pragma Pure: Controlling the Elaboration Order in Ada 95. + * pragma Suppress: Controlling Run-Time Checks. + * pragma Unsuppress: Controlling Run-Time Checks. + * Pragmas, configuration: Configuration Pragmas. + * Preelaborate: Controlling the Elaboration Order in Ada 95. + * Pure: Controlling the Elaboration Order in Ada 95. + * Recompilation, by gnatmake: Notes on the Command Line. + * Relocation issues for PowerPc VxWorks targets: Handling Relocation Issues for PowerPc Targets. + * Rounding, biased: Output and Error Message Control. + * RTL: Switches for gcc. + * SDP_Table_Build: Running gnatbind. + * Search paths, for gnatmake: Switches for gnatmake. + * Shift JIS Coding: Wide Character Encodings. + * Source file, end: Source Representation. + * Source files, suppressing search: Switches for gnatmake. + * Source files, use by binder: Running gnatbind. + * Source_File_Name pragma <1>: Alternative File Naming Schemes. + * Source_File_Name pragma: Using Other File Names. + * Source_Reference: Switches for gnatchop. + * Stack Overflow Checking: Stack Overflow Checking. + * stack traceback: Stack Traceback. + * stack unwinding: Stack Traceback. + * Stdcall: Calling Conventions. + * stderr: Output and Error Message Control. + * stdout: Output and Error Message Control. + * storage, pool, memory corruption: Finding Memory Problems with GNAT Debug Pool. + * Stubbed: Calling Conventions. + * Style checking: Style Checking. + * SUB: Source Representation. + * Subunits: Generating Object Files. + * Suppress <1>: Controlling Run-Time Checks. + * Suppress: Run-Time Checks. + * Suppressing checks: Run-Time Checks. + * System <1>: Naming Conventions for GNAT Source Files. + * System: Search Paths for gnatbind. + * System.IO: Search Paths and the Run-Time Library (RTL). + * Task switching: Ada Tasks. + * Tasks: Ada Tasks. + * Time Slicing: Run-Time Control. + * Time stamp checks, in binder: Binder Error Message Control. + * Tornado II Project: Using GNAT from the Tornado 2 Project Facility. + * traceback: Stack Traceback. + * traceback, non-symbolic: Non-Symbolic Traceback. + * traceback, symbolic: Symbolic Traceback. + * Tree file: Tree Files. + * Typographical conventions: Conventions. + * Unsuppress <1>: Controlling Run-Time Checks. + * Unsuppress: Run-Time Checks. + * Upper-Half Coding: Wide Character Encodings. + * Validity Checking: Validity Checking. + * Version skew (avoided by gnatmake): Building a Simple Ada Program. + * Volatile parameter: The Volatile Parameter. + * VT: Source Representation. + * VxWorks kernel (relocation issues on PowerPc): Handling Relocation Issues for PowerPc Targets. + * VxWorks PowerPc, relocation issues: Handling Relocation Issues for PowerPc Targets. + * Warning messages: Output and Error Message Control. + * Warnings: Binder Error Message Control. + * Warnings, treat as error: Output and Error Message Control. + * Win32: Calling Conventions. + * Writing internal trees: Auxiliary Output Control. + * Zero Cost Exceptions: Running gnatbind. + + +  + Tag Table: + Node: Top91 + Node: About This Guide9416 + Node: What This Guide Contains9941 + Node: What You Should Know before Reading This Guide14411 + Node: Related Information14819 + Node: Conventions15542 + Node: Preliminary Note for Cross Platform Users16436 + Node: Getting Started with GNAT18226 + Node: Running GNAT19129 + Node: Building a Simple Ada Program19736 + Node: Executing a Program on VxWorks23116 + Node: Loading and Running the Program23562 + Node: Unloading the Program25295 + Node: Running a Program with Multiple Units26844 + Node: Using the gnatmake Utility29116 + Node: Introduction to Glide and GVD31530 + Node: Building a New Program with Glide32272 + Node: Simple Debugging with GVD37610 + Node: Other Glide Features40647 + Node: The GNAT Compilation Model42530 + Node: Source Representation43860 + Node: Foreign Language Representation45646 + Node: Latin-146132 + Node: Other 8-Bit Codes46998 + Node: Wide Character Encodings49091 + Node: File Naming Rules52897 + Node: Using Other File Names55186 + Node: Alternative File Naming Schemes57539 + Node: Generating Object Files62771 + Node: Source Dependencies65485 + Node: The Ada Library Information Files69008 + Node: Binding an Ada Program71141 + Node: Mixed Language Programming72989 + Node: Interfacing to C73266 + Node: Calling Conventions75772 + Node: Building Mixed Ada & C++ Programs81696 + Node: Interfacing to C++82777 + Node: Linking a Mixed C++ & Ada Program83817 + Node: A Simple Example86851 + Node: Adapting the Run Time to a New C++ Compiler89897 + Node: Comparison between GNAT and C/C++ Compilation Models90913 + Node: Comparison between GNAT and Conventional Ada Library Models92642 + Node: Compiling Using gcc95293 + Node: Compiling Programs95788 + Node: Switches for gcc98738 + Node: Output and Error Message Control107922 + Node: Debugging and Assertion Control126008 + Node: Validity Checking127338 + Node: Style Checking133485 + Node: Run-Time Checks144958 + Node: Stack Overflow Checking148942 + Node: Run-Time Control151029 + Node: Using gcc for Syntax Checking151923 + Node: Using gcc for Semantic Checking153422 + Node: Compiling Ada 83 Programs154900 + Node: Character Set Control156321 + Node: File Naming Control159248 + Node: Subprogram Inlining Control159756 + Node: Auxiliary Output Control161097 + Node: Debugging Control162528 + Node: Units to Sources Mapping Files169968 + Node: Search Paths and the Run-Time Library (RTL)171358 + Node: Order of Compilation Issues174529 + Node: Examples176230 + Node: Binding Using gnatbind176798 + Node: Running gnatbind178660 + Node: Generating the Binder Program in C209421 + Node: Consistency-Checking Modes226866 + Node: Binder Error Message Control228361 + Node: Elaboration Control230627 + Node: Output Control231852 + Node: Binding with Non-Ada Main Programs234293 + Node: Binding Programs with No Main Subprogram237433 + Node: Summary of Binder Switches238256 + Node: Command-Line Access241579 + Node: Search Paths for gnatbind242584 + Node: Examples of gnatbind Usage245150 + Node: Linking Using gnatlink246921 + Node: Running gnatlink247660 + Node: Switches for gnatlink249645 + Node: Setting Stack Size from gnatlink253918 + Node: Setting Heap Size from gnatlink254772 + Node: The GNAT Make Program gnatmake255587 + Node: Running gnatmake257038 + Node: Switches for gnatmake258697 + Node: Mode Switches for gnatmake271661 + Node: Notes on the Command Line272819 + Node: How gnatmake Works275715 + Node: Examples of gnatmake Usage277885 + Node: Renaming Files Using gnatchop279012 + Node: Handling Files with Multiple Units279601 + Node: Operating gnatchop in Compilation Mode280922 + Node: Command Line for gnatchop284245 + Node: Switches for gnatchop285710 + Node: Examples of gnatchop Usage289491 + Node: Configuration Pragmas290850 + Node: Handling of Configuration Pragmas292402 + Node: The Configuration Pragmas Files293261 + Node: Handling Arbitrary File Naming Conventions Using gnatname294624 + Node: Arbitrary File Naming Conventions295032 + Node: Running gnatname296293 + Node: Switches for gnatname297752 + Node: Examples of gnatname Usage300886 + Node: GNAT Project Manager301687 + Node: Introduction302349 + Node: Project Files303445 + Node: Examples of Project Files306648 + Node: Common Sources with Different Switches and Different Output Directories307122 + Node: Source Files310153 + Node: Specifying the Object Directory310629 + Node: Specifying the Exec Directory311561 + Node: Project File Packages312329 + Node: Specifying Switch Settings313338 + Node: Main Subprograms315306 + Node: Source File Naming Conventions315970 + Node: Source Language(s)316470 + Node: Using External Variables316911 + Node: Importing Other Projects319752 + Node: Extending a Project322860 + Node: Project File Syntax325331 + Node: Basic Syntax326693 + Node: Packages327701 + Node: Expressions328855 + Node: String Types330753 + Node: Variables332056 + Node: Attributes335084 + Node: Associative Array Attributes340517 + Node: case Constructions341362 + Node: Objects and Sources in Project Files343159 + Node: Object Directory343739 + Node: Exec Directory344730 + Node: Source Directories345559 + Node: Source File Names346926 + Node: Importing Projects349263 + Node: Project Extension352042 + Node: External References in Project Files353721 + Node: Packages in Project Files355464 + Node: Variables from Imported Projects357860 + Node: Naming Schemes359532 + Node: Library Projects363505 + Node: Switches Related to Project Files366399 + Node: Tools Supporting Project Files368103 + Node: gnatmake and Project Files368435 + Node: Switches and Project Files368888 + Node: Project Files and Main Subprograms374632 + Node: The GNAT Driver and Project Files376557 + Node: Glide and Project Files380225 + Node: An Extended Example381144 + Node: Project File Complete Syntax384139 + Node: Elaboration Order Handling in GNAT386931 + Node: Elaboration Code in Ada 95387951 + Node: Checking the Elaboration Order in Ada 95392597 + Node: Controlling the Elaboration Order in Ada 95396598 + Node: Controlling Elaboration in GNAT - Internal Calls404915 + Node: Controlling Elaboration in GNAT - External Calls410622 + Node: Default Behavior in GNAT - Ensuring Safety414356 + Node: Elaboration Issues for Library Tasks418439 + Node: Mixing Elaboration Models431644 + Node: What to Do If the Default Elaboration Behavior Fails434145 + Node: Elaboration for Access-to-Subprogram Values444460 + Node: Summary of Procedures for Elaboration Control446267 + Node: Other Elaboration Order Considerations447430 + Node: The Cross-Referencing Tools gnatxref and gnatfind452659 + Node: gnatxref Switches454323 + Node: gnatfind Switches457762 + Node: Project Files for gnatxref and gnatfind463358 + Node: Regular Expressions in gnatfind and gnatxref466464 + Node: Examples of gnatxref Usage469243 + Node: Examples of gnatfind Usage473042 + Node: File Name Krunching Using gnatkr475245 + Node: About gnatkr475859 + Node: Using gnatkr477181 + Node: Krunching Method478072 + Node: Examples of gnatkr Usage481309 + Node: Preprocessing Using gnatprep481799 + Node: Using gnatprep482310 + Node: Switches for gnatprep483162 + Node: Form of Definitions File485284 + Node: Form of Input Text for gnatprep486023 + Node: The GNAT Library Browser gnatls489642 + Node: Running gnatls490171 + Node: Switches for gnatls492681 + Node: Examples of gnatls Usage494576 + Node: GNAT and Libraries496765 + Node: Creating an Ada Library497293 + Node: Installing an Ada Library500133 + Node: Using an Ada Library502490 + Node: Creating an Ada Library to be Used in a Non-Ada Context503681 + Node: Rebuilding the GNAT Run-Time Library509649 + Node: Using the GNU make Utility510556 + Node: Using gnatmake in a Makefile511410 + Node: Automatically Creating a List of Directories515618 + Node: Generating the Command Line Switches518756 + Node: Overcoming Command Line Length Limits519734 + Node: Finding Memory Problems with GNAT Debug Pool522039 + Node: Creating Sample Bodies Using gnatstub526733 + Node: Running gnatstub527528 + Node: Switches for gnatstub528282 + Node: Reducing the Size of Ada Executables with gnatelim530414 + Node: About gnatelim530947 + Node: Eliminate Pragma532035 + Node: Tree Files533043 + Node: Preparing Tree and Bind Files for gnatelim533932 + Node: Running gnatelim535934 + Node: Correcting the List of Eliminate Pragmas537929 + Node: Making Your Executables Smaller538710 + Node: Summary of the gnatelim Usage Cycle539532 + Node: Other Utility Programs540341 + Node: Using Other Utility Programs with GNAT540869 + Node: The gnatpsta Utility Program541557 + Node: The External Symbol Naming Scheme of GNAT542851 + Node: Ada Mode for Glide544848 + Node: Converting Ada Files to html with gnathtml546799 + Node: Installing gnathtml550372 + Node: Running and Debugging Ada Programs551036 + Node: The GNAT Debugger GDB552430 + Node: Running GDB555548 + Node: Introduction to GDB Commands555846 + Node: Using Ada Expressions560711 + Node: Calling User-Defined Subprograms561905 + Node: Using the Next Command in a Function564325 + Node: Ada Exceptions565490 + Node: Ada Tasks566444 + Node: Debugging Generic Units568507 + Node: GNAT Abnormal Termination or Failure to Terminate569910 + Node: Naming Conventions for GNAT Source Files572489 + Node: Getting Internal Debugging Information575080 + Node: Stack Traceback576282 + Node: Non-Symbolic Traceback577319 + Node: Tracebacks From an Unhandled Exception577780 + Node: Tracebacks From Exception Occurrences (non-symbolic)581717 + Node: Tracebacks From Anywhere in a Program (non-symbolic)583000 + Node: Symbolic Traceback584843 + Node: Tracebacks From Exception Occurrences (symbolic)585566 + Node: Tracebacks From Anywhere in a Program (symbolic)586975 + Node: Inline Assembler588167 + Node: Basic Assembler Syntax589853 + Node: A Simple Example of Inline Assembler591630 + Node: Output Variables in Inline Assembler594797 + Node: Input Variables in Inline Assembler602177 + Node: Inlining Inline Assembler Code604685 + Node: Other Asm Functionality606619 + Node: The Clobber Parameter607054 + Node: The Volatile Parameter609053 + Node: A Complete Example610245 + Node: Check_CPU Procedure611219 + Node: Intel_CPU Package Specification626266 + Node: Intel_CPU Package Body635694 + Node: VxWorks Topics644852 + Node: Kernel Configuration for VxWorks645492 + Node: Kernel Compilation Issues for VxWorks646202 + Node: Handling Relocation Issues for PowerPc Targets647374 + Node: Support for Software Floating Point on PowerPC Processors651801 + Node: Interrupt Handling for VxWorks653001 + Node: Simulating Command Line Arguments for VxWorks670246 + Node: Debugging Issues for VxWorks672351 + Node: Using GNAT from the Tornado 2 Project Facility681772 + Node: The GNAT Toolchain as Used from the Tornado 2 Project Facility682605 + Node: Building a Simple Application683656 + Node: Mixing C and Ada Code in a Tornado 2 Project684603 + Node: Compilation Switches685172 + Node: Autoscale and Minimal Kernel Configuration687483 + Node: Adapting BSPs to GNAT688182 + Node: Using GNAT Project Files in a Tornado 2 Project689535 + Node: Frequently Asked Questions for VxWorks690303 + Node: LynxOS Topics693268 + Node: Getting Started with GNAT on LynxOS693703 + Node: Kernel Configuration for LynxOS694911 + Node: Patch Level Issues for LynxOS695782 + Node: Debugging Issues for LynxOS696169 + Node: An Example Debugging Session for LynxOS699965 + Node: Performance Considerations701984 + Node: Controlling Run-Time Checks703015 + Node: Optimization Levels705000 + Node: Debugging Optimized Code706857 + Node: Inlining of Subprograms710590 + Node: GNU Free Documentation License714114 + Node: Index736543 +  + End Tag Table diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_ug_vxw.texi gcc-3.3/gcc/ada/gnat_ug_vxw.texi *** gcc-3.2.3/gcc/ada/gnat_ug_vxw.texi 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_ug_vxw.texi 2003-05-14 00:31:46.000000000 +0000 *************** *** 0 **** --- 1,20085 ---- + \input texinfo @c -*-texinfo-*- + @c %**start of header + + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + @c o + @c GNAT DOCUMENTATION o + @c o + @c G N A T _ U G o + @c o + @c Copyright (C) 1992-2002 Ada Core Technologies, Inc. o + @c o + @c GNAT is free software; you can redistribute it and/or modify it under o + @c terms of the GNU General Public License as published by the Free Soft- o + @c ware Foundation; either version 2, or (at your option) any later ver- o + @c sion. GNAT is distributed in the hope that it will be useful, but WITH- o + @c OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY o + @c or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License o + @c for more details. You should have received a copy of the GNU General o + @c Public License distributed with GNAT; see file COPYING. If not, write o + @c to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, o + @c MA 02111-1307, USA. o + @c o + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + @c + @c GNAT_UG Style Guide + @c + @c 1. Always put a @noindent on the line before the first paragraph + @c after any of these commands: + @c + @c @chapter + @c @section + @c @subsection + @c @subsubsection + @c @subsubsubsection + @c + @c @end smallexample + @c @end itemize + @c @end enumerate + @c + @c 2. DO NOT use @example. Use @smallexample instead. + @c + @c 3. Each @chapter, @section, @subsection, @subsubsection, etc. + @c command must be preceded by two empty lines + @c + @c 4. The @item command must be on a line of its own if it is in an + @c @itemize or @enumerate command. + @c + @c 5. When talking about ALI files use "ALI" (all uppercase), not "Ali" + @c or "ali". + @c + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + + + + + @setfilename gnat_ug_vxw.info + @settitle GNAT User's Guide for Cross Platforms + + @include gcc-common.texi + + @setchapternewpage odd + @syncodeindex fn cp + @c %**end of header + + @copying + Copyright @copyright{} 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with the Invariant Sections being ``GNU Free Documentation License'', with the + Front-Cover Texts being + ``GNAT User's Guide for Cross Platforms'', + and with no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + @end copying + + @titlepage + + + + + @title GNAT User's Guide + @center @titlefont{for Cross Platforms} + + @subtitle GNAT, The GNU Ada 95 Compiler + @subtitle GNAT Version for GCC @value{version-GCC} + + @author Ada Core Technologies, Inc. + + @page + @vskip 0pt plus 1filll + + @insertcopying + + @end titlepage + + @ifnottex + @node Top, About This Guide, (dir), (dir) + @top GNAT User's Guide + + + + + GNAT User's Guide for Cross Platforms + + GNAT, The GNU Ada 95 Compiler + + GNAT Version for GCC @value{version-GCC} + + Ada Core Technologies, Inc. + + @insertcopying + + @menu + * About This Guide:: + * Preliminary Note for Cross Platform Users:: + * Getting Started with GNAT:: + * The GNAT Compilation Model:: + * Compiling Using gcc:: + * Binding Using gnatbind:: + * Linking Using gnatlink:: + * The GNAT Make Program gnatmake:: + * Renaming Files Using gnatchop:: + * Configuration Pragmas:: + * Handling Arbitrary File Naming Conventions Using gnatname:: + * GNAT Project Manager:: + * Elaboration Order Handling in GNAT:: + * The Cross-Referencing Tools gnatxref and gnatfind:: + * File Name Krunching Using gnatkr:: + * Preprocessing Using gnatprep:: + * The GNAT Library Browser gnatls:: + * GNAT and Libraries:: + * Using the GNU make Utility:: + * Finding Memory Problems with GNAT Debug Pool:: + * Creating Sample Bodies Using gnatstub:: + * Reducing the Size of Ada Executables with gnatelim:: + * Other Utility Programs:: + * Running and Debugging Ada Programs:: + * Inline Assembler:: + * VxWorks Topics:: + * LynxOS Topics:: + * Performance Considerations:: + * GNU Free Documentation License:: + * Index:: + + --- The Detailed Node Listing --- + + About This Guide + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + + Preliminary Note for Cross Platform Users:: + + Getting Started with GNAT + + * Running GNAT:: + * Building a Simple Ada Program:: + * Executing a Program on VxWorks:: + * Running a Program with Multiple Units:: + * Using the gnatmake Utility:: + + The GNAT Compilation Model + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + Foreign Language Representation + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + + Compiling Ada Programs With gcc + + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + + Switches for gcc + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + Binding Ada Programs With gnatbind + + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + + Linking Using gnatlink + + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + + The GNAT Make Program gnatmake + + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + + Renaming Files Using gnatchop + + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + + Configuration Pragmas + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + + Handling Arbitrary File Naming Conventions Using gnatname + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + + GNAT Project Manager + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + + Elaboration Order Handling in GNAT + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + The Cross-Referencing Tools gnatxref and gnatfind + + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + + File Name Krunching Using gnatkr + + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + + Preprocessing Using gnatprep + + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + + + The GNAT Library Browser gnatls + + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + + + GNAT and Libraries + + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + + Using the GNU make Utility + + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + + + Finding Memory Problems with GNAT Debug Pool + + Creating Sample Bodies Using gnatstub + + * Running gnatstub:: + * Switches for gnatstub:: + + Reducing the Size of Ada Executables with gnatelim + + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + + Other Utility Programs + + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + + + Running and Debugging Ada Programs + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + + Inline Assembler + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + + + VxWorks Topics + + * Kernel Configuration for VxWorks:: + * Kernel Compilation Issues for VxWorks:: + * Handling Relocation Issues for PowerPc Targets:: + * Support for Software Floating Point on PowerPC Processors:: + * Interrupt Handling for VxWorks:: + * Simulating Command Line Arguments for VxWorks:: + * Debugging Issues for VxWorks:: + * Using GNAT from the Tornado 2 Project Facility:: + * Frequently Asked Questions for VxWorks:: + + LynxOS Topics + + * Getting Started with GNAT on LynxOS:: + * Kernel Configuration for LynxOS:: + * Patch Level Issues for LynxOS:: + * Debugging Issues for LynxOS:: + * An Example Debugging Session for LynxOS:: + + Performance Considerations + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + + * Index:: + @end menu + @end ifnottex + + @node About This Guide + @unnumbered About This Guide + + @noindent + This guide describes the use of GNAT, a compiler and software development + toolset for the full Ada 95 programming language. + It describes the features of the compiler and tools, and details + how to use them to build Ada 95 applications. + + @menu + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + @end menu + + @node What This Guide Contains + @unnumberedsec What This Guide Contains + + @noindent + This guide contains the following chapters: + @itemize @bullet + @item + @ref{Preliminary Note for Cross Platform Users}, describes the basic + differences between the cross and native versions of GNAT. + @item + @ref{Getting Started with GNAT}, describes how to get started compiling + and running Ada programs with the GNAT Ada programming environment. + @item + @ref{The GNAT Compilation Model}, describes the compilation model used + by GNAT. + @item + @ref{Compiling Using gcc}, describes how to compile + Ada programs with @code{gcc}, the Ada compiler. + @item + @ref{Binding Using gnatbind}, describes how to + perform binding of Ada programs with @code{gnatbind}, the GNAT binding + utility. + @item + @ref{Linking Using gnatlink}, + describes @code{gnatlink}, a + program that provides for linking using the GNAT run-time library to + construct a program. @code{gnatlink} can also incorporate foreign language + object units into the executable. + @item + @ref{The GNAT Make Program gnatmake}, describes @code{gnatmake}, a + utility that automatically determines the set of sources + needed by an Ada compilation unit, and executes the necessary compilations + binding and link. + @item + @ref{Renaming Files Using gnatchop}, describes + @code{gnatchop}, a utility that allows you to preprocess a file that + contains Ada source code, and split it into one or more new files, one + for each compilation unit. + @item + @ref{Configuration Pragmas}, describes the configuration pragmas handled by GNAT. + @item + @ref{Handling Arbitrary File Naming Conventions Using gnatname}, shows how to override + the default GNAT file naming conventions, either for an individual unit or globally. + @item + @ref{GNAT Project Manager}, describes how to use project files to organize large projects. + @item + @ref{Elaboration Order Handling in GNAT}, describes how GNAT helps you deal with + elaboration order issues. + @item + @ref{The Cross-Referencing Tools gnatxref and gnatfind}, discusses + @code{gnatxref} and @code{gnatfind}, two tools that provide an easy + way to navigate through sources. + @item + @ref{File Name Krunching Using gnatkr}, describes the @code{gnatkr} + file name krunching utility, used to handle shortened + file names on operating systems with a limit on the length of names. + @item + @ref{Preprocessing Using gnatprep}, describes @code{gnatprep}, a + preprocessor utility that allows a single source file to be used to + generate multiple or parameterized source files, by means of macro + substitution. + @item + @ref{The GNAT Library Browser gnatls}, describes @code{gnatls}, a + utility that displays information about compiled units, including dependences + on the corresponding sources files, and consistency of compilations. + @item + @ref{GNAT and Libraries}, describes the process of creating and using + Libraries with GNAT. It also describes how to recompile the GNAT run-time + library. + + @item + @ref{Using the GNU make Utility}, describes some techniques for using + the GNAT toolset in Makefiles. + + @item + @ref{Finding Memory Problems with GNAT Debug Pool}, describes how to + use the GNAT-specific Debug Pool in order to detect as early as possible + the use of incorrect memory references. + + @item + @ref{Creating Sample Bodies Using gnatstub}, discusses @code{gnatstub}, + a utility that generates empty but compilable bodies for library units. + + @item + @ref{Reducing the Size of Ada Executables with gnatelim}, describes + @code{gnatelim}, a tool which detects unused subprograms and helps + the compiler to create a smaller executable for the program. + + @item + @ref{Other Utility Programs}, discusses several other GNAT utilities, + including @code{gnatpsta}. + + @item + @ref{Running and Debugging Ada Programs}, describes how to run and debug + Ada programs. + + @item + @ref{Inline Assembler}, shows how to use the inline assembly facility in an Ada program. + + @item + @ref{VxWorks Topics}, presents information relevant to the VxWorks target for cross-compilation + configurations. + + @item + @ref{LynxOS Topics}, presents information relevant to the LynxOS target for cross-compilation + configurations. + + @item + @ref{Performance Considerations}, reviews the trade offs between using + defaults or options in program development. + @end itemize + + @node What You Should Know before Reading This Guide + @unnumberedsec What You Should Know before Reading This Guide + + @cindex Ada 95 Language Reference Manual + @noindent + This user's guide assumes that you are familiar with Ada 95 language, as + described in the International Standard ANSI/ISO/IEC-8652:1995, Jan + 1995. + + @node Related Information + @unnumberedsec Related Information + + @noindent + For further information about related tools, refer to the following + documents: + + @itemize @bullet + @item + @cite{GNAT Reference Manual}, which contains all reference + material for the GNAT implementation of Ada 95. + + @item + @cite{Ada 95 Language Reference Manual}, which contains all reference + material for the Ada 95 programming language. + + @item + @cite{Debugging with GDB} + contains all details on the use of the GNU source-level debugger. + + @item + @cite{GNU Emacs Manual} + contains full information on the extensible editor and programming + environment Emacs. + + @end itemize + + @node Conventions + @unnumberedsec Conventions + @cindex Conventions + @cindex Typographical conventions + + @noindent + Following are examples of the typographical and graphic conventions used + in this guide: + + @itemize @bullet + @item + @code{Functions}, @code{utility program names}, @code{standard names}, + and @code{classes}. + + @item + @samp{Option flags} + + @item + @file{File Names}, @file{button names}, and @file{field names}. + + @item + @var{Variables}. + + @item + @emph{Emphasis}. + + @item + [optional information or parameters] + + @item + Examples are described by text + @smallexample + and then shown this way. + @end smallexample + @end itemize + + @noindent + Commands that are entered by the user are preceded in this manual by the + characters @w{"@code{$ }"} (dollar sign followed by space). If your system + uses this sequence as a prompt, then the commands will appear exactly as + you see them in the manual. If your system uses some other prompt, then + the command will appear with the @code{$} replaced by whatever prompt + character you are using. + + @node Preliminary Note for Cross Platform Users + @chapter Preliminary Note for Cross Platform Users + + @noindent + The use of GNAT in a cross environment is very similar to its use in a + native environment. Most of the tools described in this manual have + similar functions and options in both modes. The major + difference is that the name of the cross tools includes the target for + which the cross compiler is configured. For instance, the cross @command{gnatmake} + tool is called @command{@i{target}-gnatmake} where @code{@i{target}} stands for the name of + the cross target. Thus, in an environment configured for the + target @code{powerpc-wrs-vxworks}, the @command{gnatmake} command is + @code{powerpc-wrs-vxworks-gnatmake}. This convention allows the + installation of a native and one or several cross development + environments at the same location. + + The tools that are most relevant in a cross environment are: + @code{@i{target}-gcc}, @code{@i{target}-gnatmake}, + @code{@i{target}-gnatbind}, @code{@i{target}-gnatlink} to build cross + applications and @code{@i{target}-gnatls} for cross library + browsing. @code{@i{target}-gdb} is also usually available for cross + debugging in text mode. The graphical debugger interface + @code{gvd} is always a native tool but it can be configured to drive + the above mentioned cross debugger, thus allowing graphical cross debugging + sessions. Some other tools such as @code{@i{target}-gnatchop}, + @code{@i{target}-gnatkr}, @code{@i{target}-gnatprep}, + @code{@i{target}-gnatpsta}, @code{@i{target}-gnatxref}, @code{@i{target}-gnatfind} + and @code{@i{target}-gnatname} are also provided for completeness + even though they do not differ greatly from their native counterpart. + + In the rest of this manual, the tools are sometimes designated with + their full cross name, and sometimes with their simplified native + name. + + + @node Getting Started with GNAT + @chapter Getting Started with GNAT + + @noindent + This introduction is a starting point for using GNAT to develop + and execute Ada 95 programs in a cross environment. + It provides some specifics + about the GNAT toolchain targeted to the Wind River Sytems' VxWorks/Tornado platform; + for other targets please refer to the corresponding chapter later in this manual. + + Basic familiarity with use of GNAT in a native environment is + presumed. For the VxWorks specific part, a knowledge of how to start + Tornado's @code{windsh} tool is also presumed. + + @menu + * Running GNAT:: + * Building a Simple Ada Program:: + * Executing a Program on VxWorks:: + + * Running a Program with Multiple Units:: + + * Using the gnatmake Utility:: + * Introduction to Glide and GVD:: + @end menu + + @node Running GNAT + @section Running GNAT + + @noindent + Three steps are needed to create an executable file from an Ada source + file: + + @enumerate + @item + The source file(s) must be compiled. + @item + The file(s) must be bound using the GNAT binder. + @item + All appropriate object files must be linked to produce a loadable module. + @end enumerate + + @noindent + All three steps are most commonly handled by using the @code{gnatmake} + utility program that, given the name of the main program, automatically + performs the necessary compilation, binding and linking steps. + + @node Building a Simple Ada Program + @section Building a Simple Ada Program + + @noindent + Any text editor may be used to prepare an Ada program. If @code{Glide} is + used, the optional Ada mode may be helpful in laying out the program. The + program text is a normal text file. We will suppose in our initial + example that you have used your editor to prepare the following + standard format text file: + + @smallexample + @group + @cartouche + @b{with} Ada.Text_IO; @b{use} Ada.Text_IO; + @b{procedure} Hello @b{is} + @b{begin} + Put_Line ("Hello WORLD!"); + @b{end} Hello; + @end cartouche + @end group + @end smallexample + + @noindent + This file should be named @file{hello.adb}. + With the normal default file naming conventions, GNAT requires + that each file + contain a single compilation unit whose file name is the + unit name, + with periods replaced by hyphens; the + extension is @file{ads} for a + spec and @file{adb} for a body. + You can override this default file naming convention by use of the + special pragma @code{Source_File_Name} (@pxref{Using Other File Names}). + Alternatively, if you want to rename your files according to this default + convention, which is probably more convenient if you will be using GNAT + for all your compilations, then the @code{gnatchop} utility + can be used to generate correctly-named source files + (@pxref{Renaming Files Using gnatchop}). + + You can compile the program using the following command (@code{$} is used + as the command prompt in the examples in this document): + + + @smallexample + $ @i{target}-gcc -c hello.adb + @end smallexample + + @noindent + @code{gcc} is the command used to run the compiler. This compiler is + capable of compiling programs in several languages, including Ada 95 and + C. It assumes that you have given it an Ada program if the file extension is + either @file{.ads} or @file{.adb}, and it will then call the GNAT compiler to compile + the specified file. + + The @option{-c} switch is required. It tells @command{gcc} to only do a + compilation. (For C programs, @command{gcc} can also do linking, but this + capability is not used directly for Ada programs, so the @option{-c} + switch must always be present.) + + This compile command generates a file + @file{hello.o}, which is the object + file corresponding to your Ada program. It also generates an "Ada Library Information" file + @file{hello.ali}, + which contains additional information used to check + that an Ada program is consistent. + To build a downloadable module, + use @code{gnatbind} to bind the program + and @code{gnatlink} to link it. The + argument to both @code{gnatbind} and @code{gnatlink} is the name of the + @file{ali} file, but the default extension of @file{.ali} can + be omitted. This means that in the most common case, the argument + is simply the name of the main program: + + + @smallexample + $ @i{target}-gnatbind hello + $ @i{target}-gnatlink hello + @end smallexample + + @noindent + A simpler method of carrying out these steps is to use + @command{gnatmake}, + a master program that invokes all the required + compilation, binding and linking tools in the correct order. In particular, + @command{gnatmake} automatically recompiles any sources that have been modified + since they were last compiled, or sources that depend + on such modified sources, so that "version skew" is avoided. + @cindex Version skew (avoided by @command{gnatmake}) + + + @smallexample + $ @i{target}-gnatmake hello.adb + @end smallexample + + + @noindent + The result is a relocatable object called @file{hello}. + + @emph{Technical note:} the result of the linking stage is a + relocatable partially-linked object containing all the relevant GNAT + run-time units, in contrast with the executable-format object file found in + native environments. + + + @node Executing a Program on VxWorks + @section Executing a Program on VxWorks + + @noindent + Getting a program to execute involves loading it onto the target, running it, and then (if re-execution is needed) unloading it. + + @menu + * Loading and Running the Program:: + * Unloading the Program:: + @end menu + + @node Loading and Running the Program + @subsection Loading and Running the Program + + @noindent + An Ada program is loaded and run in the same way as a C program. + Details may be found in the @cite{Tornado User's Guide}. + + In order to load and run our simple "Hello World" example, we assume that + the target has access to the disk of the host containing this object and + that its working directory has been set to the directory containing this + object. The commands are typed in Tornado's Windshell. The @code{windsh} prompt + is the @code{->} sequence. + + @smallexample + -> vf0=open("/vio/0",2,0) + new symbol "vf0" added to symbol table. + vf0 = 0x2cab48: value = 12 = 0xc + -> ioGlobalStdSet(1,vf0) + value = 1 = 0x1 + -> ld < hello + value = 665408 = 0xa2740 + -> hello + Hello World + value = 0 = 0x0 + -> + @end smallexample + + @noindent + The first two commands redirect output to the shell window. + They are only needed if the target server was started without the + @code{-C} option. The third command loads the module, which is the file + @file{hello} created previously by the @code{@i{target}-gnatmake} command. + Note that for Tornado AE, the @command{ml} command replaces @command{ld}." + + The "Hello World" program comprises a procedure named @code{hello}, and this + is the name entered for the procedure in the target server's symbol table + when the module is loaded. To execute the procedure, type the symbol name @code{hello} + into @code{windsh} as shown in the last command above. + + Note that by default the entry point of an Ada program is the name of the main + Ada subprogram in a VxWorks environment. It is possible to use an alternative + name; see the description of @code{gnatbind} options for details. + + @node Unloading the Program + @subsection Unloading the Program + + @noindent + It is important to remember that + you must unload a program once you have run it. You + cannot load it once and run it several times. If you don't follow + this rule, your program's behavior can be unpredictable, and will most + probably crash. + + This effect is due to the implementation of Ada 95's @emph{elaboration} semantics. + The unit elaboration phase comprises a @emph{static} elaboration and a + @emph{dynamic} elaboration. On a native platform they both take place + when the program is run. Thus rerunning the program will repeat the complete + elaboration phase, and the program will run correctly. + + On VxWorks, the process is a bit different. + The static elaboration phase is handled by + the loader (typically when you type @code{ld < program_name} in + @code{windsh}). The dynamic phase takes place when the program is run. If the + program is run twice and has not been unloaded and then reloaded, the + second time it is run, the static elaboration phase is skipped. + Variables initialized during the static elaboration phase + may have been modified during the first execution of the program. Thus the + second execution isn't performed on a completely initialized environment. + + Note that in C programs, elaboration isn't systematic. Multiple runs without reload + might work, but, even with C programs, if there is an elaboration + phase, you will have to unload your program before re-running it. + + + @node Running a Program with Multiple Units + @section Running a Program with Multiple Units + + @noindent + Consider a slightly more complicated example that has three files: a + main program, and the spec and body of a package: + + @smallexample + @cartouche + @group + @b{package} Greetings @b{is} + @b{procedure} Hello; + @b{procedure} Goodbye; + @b{end} Greetings; + + @b{with} Ada.Text_IO; @b{use} Ada.Text_IO; + @b{package} @b{body} Greetings @b{is} + @b{procedure} Hello @b{is} + @b{begin} + Put_Line ("Hello WORLD!"); + @b{end} Hello; + + @b{procedure} Goodbye @b{is} + @b{begin} + Put_Line ("Goodbye WORLD!"); + @b{end} Goodbye; + @b{end} Greetings; + @end group + + @group + @b{with} Greetings; + @b{procedure} Gmain @b{is} + @b{begin} + Greetings.Hello; + Greetings.Goodbye; + @b{end} Gmain; + @end group + @end cartouche + @end smallexample + + @noindent + Following the one-unit-per-file rule, place this program in the + following three separate files: + + @table @file + @item greetings.ads + spec of package @code{Greetings} + + @item greetings.adb + body of package @code{Greetings} + + @item gmain.adb + body of main program + @end table + + @noindent + To build an executable version of + this program, we could use four separate steps to compile, bind, and link + the program, as follows: + + + @smallexample + $ @i{target}-gcc -c gmain.adb + $ @i{target}-gcc -c greetings.adb + $ @i{target}-gnatbind gmain + $ @i{target}-gnatlink gmain + @end smallexample + + @noindent + Note that there is no required order of compilation when using GNAT. + In particular it is perfectly fine to compile the main program first. + Also, it is not necessary to compile package specs in the case where + there is an accompanying body; you only need to compile the body. If you want + to submit these files to the compiler for semantic checking and not code generation, + then use the + @option{-gnatc} switch: + + + @smallexample + $ @i{target}-gcc -c greetings.ads -gnatc + @end smallexample + + @noindent + Although the compilation can be done in separate steps as in the + above example, in practice it is almost always more convenient + to use the @code{gnatmake} tool. All you need to know in this case + is the name of the main program's source file. The effect of the above four + commands can be achieved with a single one: + + + @smallexample + $ @i{target}-gnatmake gmain.adb + @end smallexample + + @noindent + In the next section we discuss the advantages of using @code{gnatmake} in + more detail. + + @node Using the gnatmake Utility + @section Using the @command{gnatmake} Utility + + @noindent + If you work on a program by compiling single components at a time using + @code{gcc}, you typically keep track of the units you modify. In order to + build a consistent system, you compile not only these units, but also any + units that depend on the units you have modified. + For example, in the preceding case, + if you edit @file{gmain.adb}, you only need to recompile that file. But if + you edit @file{greetings.ads}, you must recompile both + @file{greetings.adb} and @file{gmain.adb}, because both files contain + units that depend on @file{greetings.ads}. + + @code{gnatbind} will warn you if you forget one of these compilation + steps, so that it is impossible to generate an inconsistent program as a + result of forgetting to do a compilation. Nevertheless it is tedious and + error-prone to keep track of dependencies among units. + One approach to handle the dependency-bookkeeping is to use a + makefile. However, makefiles present maintenance problems of their own: + if the dependencies change as you change the program, you must make + sure that the makefile is kept up-to-date manually, which is also an + error-prone process. + + The @code{gnatmake} utility takes care of these details automatically. + Invoke it using either one of the following forms: + + + @smallexample + $ @i{target}-gnatmake gmain.adb + $ @i{target}-gnatmake gmain + @end smallexample + + @noindent + The argument is the name of the file containing the main program; + you may omit the extension. @code{gnatmake} + examines the environment, automatically recompiles any files that need + recompiling, and binds and links the resulting set of object files, + generating the executable file, @file{gmain}. + In a large program, it + can be extremely helpful to use @code{gnatmake}, because working out by hand + what needs to be recompiled can be difficult. + + Note that @code{gnatmake} + takes into account all the Ada 95 rules that + establish dependencies among units. These include dependencies that result + from inlining subprogram bodies, and from + generic instantiation. Unlike some other + Ada make tools, @code{gnatmake} does not rely on the dependencies that were + found by the compiler on a previous compilation, which may possibly + be wrong when sources change. @code{gnatmake} determines the exact set of + dependencies from scratch each time it is run. + + + @node Introduction to Glide and GVD + @section Introduction to Glide and GVD + @cindex Glide + @cindex GVD + @noindent + Although it is possible to develop programs using only the command line interface (@command{gnatmake}, etc.) a graphical Interactive Development Environment can make it easier for you to compose, navigate, and debug programs. This section describes the main features of Glide, the GNAT graphical IDE, and also shows how to use the basic commands in GVD, the GNU Visual Debugger. Additional information may be found in the on-line help for these tools. + + @menu + * Building a New Program with Glide:: + * Simple Debugging with GVD:: + * Other Glide Features:: + @end menu + + @node Building a New Program with Glide + @subsection Building a New Program with Glide + @noindent + The simplest way to invoke Glide is to enter @command{glide} at the command prompt. It will generally be useful to issue this as a background command, thus allowing you to continue using your command window for other purposes while Glide is running: + + @smallexample + $ glide& + @end smallexample + + @noindent + Glide will start up with an initial screen displaying the top-level menu items as well as some other information. The menu selections are as follows + @itemize @bullet + @item @code{Buffers} + @item @code{Files} + @item @code{Tools} + @item @code{Edit} + @item @code{Search} + @item @code{Mule} + @item @code{Glide} + @item @code{Help} + @end itemize + + @noindent + For this introductory example, you will need to create a new Ada source file. First, select the @code{Files} menu. This will pop open a menu with around a dozen or so items. To create a file, select the @code{Open file...} choice. Depending on the platform, you may see a pop-up window where you can browse to an appropriate directory and then enter the file name, or else simply see a line at the bottom of the Glide window where you can likewise enter the file name. Note that in Glide, when you attempt to open a non-existent file, the effect is to create a file with that name. For this example enter @file{hello.adb} as the name of the file. + + A new buffer will now appear, occupying the entire Glide window, with the file name at the top. The menu selections are slightly different from the ones you saw on the opening screen; there is an @code{Entities} item, and in place of @code{Glide} there is now an @code{Ada} item. Glide uses the file extension to identify the source language, so @file{adb} indicates an Ada source file. + + You will enter some of the source program lines explicitly, and use the syntax-oriented template mechanism to enter other lines. First, type the following text: + @smallexample + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + @end smallexample + + @noindent + Observe that Glide uses different colors to distinguish reserved words from identifiers. Also, after the @code{procedure Hello is} line, the cursor is automatically indented in anticipation of declarations. When you enter @code{begin}, Glide recognizes that there are no declarations and thus places @code{begin} flush left. But after the @code{begin} line the cursor is again indented, where the statement(s) will be placed. + + The main part of the program will be a @code{for} loop. Instead of entering the text explicitly, however, use a statement template. Select the @code{Ada} item on the top menu bar, move the mouse to the @code{Statements} item, and you will see a large selection of alternatives. Choose @code{for loop}. You will be prompted (at the bottom of the buffer) for a loop name; simply press the @key{Enter} key since a loop name is not needed. You should see the beginning of a @code{for} loop appear in the source program window. You will now be prompted for the name of the loop variable; enter a line with the identifier @code{ind} (lower case). Note that, by default, Glide capitalizes the name (you can override such behavior if you wish, although this is outside the scope of this introduction). Next, Glide prompts you for the loop range; enter a line containing @code{1..5} and you will see this also appear in the source program, together with the remaining elements of the @code{for} loop syntax. + + Next enter the statement (with an intentional error, a missing semicolon) that will form the body of the loop: + @smallexample + Put_Line("Hello, World" & Integer'Image(I)) + @end smallexample + + @noindent + Finally, type @code{end Hello;} as the last line in the program. Now save the file: choose the @code{File} menu item, and then the @code{Save buffer} selection. You will see a message at the bottom of the buffer confirming that the file has been saved. + + You are now ready to attempt to build the program. Select the @code{Ada} item from the top menu bar. Although we could choose simply to compile the file, we will instead attempt to do a build (which invokes @command{gnatmake}) since, if the compile is successful, we want to build an executable. Thus select @code{Ada build}. This will fail because of the compilation error, and you will notice that the Glide window has been split: the top window contains the source file, and the bottom window contains the output from the GNAT tools. Glide allows you to navigate from a compilation error to the source file position corresponding to the error: click the middle mouse button (or simultaneously press the left and right buttons, on a two-button mouse) on the diagnostic line in the tool window. The focus will shift to the source window, and the cursor will be positioned on the character at which the error was detected. + + Correct the error: type in a semicolon to terminate the statement. Although you can again save the file explicitly, you can also simply invoke @code{Ada} @result{} @code{Build} and you will be prompted to save the file. This time the build will succeed; the tool output window shows you the options that are supplied by default. The GNAT tools' output (e.g., object and ALI files, executable) will go in the directory from which Glide was launched. + + To execute the program, choose @code{Ada} and then @code{Run}. You should see the program's output displayed in the bottom window: + + @smallexample + Hello, world 1 + Hello, world 2 + Hello, world 3 + Hello, world 4 + Hello, world 5 + @end smallexample + + @node Simple Debugging with GVD + @subsection Simple Debugging with GVD + + @noindent + This section describes how to set breakpoints, examine/modify variables, and step through execution. + + In order to enable debugging, you need to pass the @option{-g} switch to both the compiler and to @command{gnatlink}. If you are using the command line, passing @option{-g} to @command{gnatmake} will have this effect. You can then launch GVD, e.g. on the @code{hello} program, by issuing the command: + + @smallexample + $ gvd hello + @end smallexample + + @noindent + If you are using Glide, then @option{-g} is passed to the relevant tools by default when you do a build. Start the debugger by selecting the @code{Ada} menu item, and then @code{Debug}. + + GVD comes up in a multi-part window. One pane shows the names of files comprising your executable; another pane shows the source code of the current unit (initially your main subprogram), another pane shows the debugger output and user interactions, and the fourth pane (the data canvas at the top of the window) displays data objects that you have selected. + + To the left of the source file pane, you will notice green dots adjacent to some lines. These are lines for which object code exists and where breakpoints can thus be set. You set/reset a breakpoint by clicking the green dot. When a breakpoint is set, the dot is replaced by an @code{X} in a red circle. Clicking the circle toggles the breakpoint off, and the red circle is replaced by the green dot. + + For this example, set a breakpoint at the statement where @code{Put_Line} is invoked. + + Start program execution by selecting the @code{Run} button on the top menu bar. (The @code{Start} button will also start your program, but it will cause program execution to break at the entry to your main subprogram.) Evidence of reaching the breakpoint will appear: the source file line will be highlighted, and the debugger interactions pane will display a relevant message. + + You can examine the values of variables in several ways. Move the mouse over an occurrence of @code{Ind} in the @code{for} loop, and you will see the value (now @code{1}) displayed. Alternatively, right-click on @code{Ind} and select @code{Display Ind}; a box showing the variable's name and value will appear in the data canvas. + + Although a loop index is a constant with respect to Ada semantics, you can change its value in the debugger. Right-click in the box for @code{Ind}, and select the @code{Set Value of Ind} item. Enter @code{2} as the new value, and press @command{OK}. The box for @code{Ind} shows the update. + + Press the @code{Step} button on the top menu bar; this will step through one line of program text (the invocation of @code{Put_Line}), and you can observe the effect of having modified @code{Ind} since the value displayed is @code{2}. + + Remove the breakpoint, and resume execution by selecting the @code{Cont} button. You will see the remaining output lines displayed in the debugger interaction window, along with a message confirming normal program termination. + + + @node Other Glide Features + @subsection Other Glide Features + + @noindent + You may have observed that some of the menu selections contain abbreviations; e.g., @code{(C-x C-f)} for @code{Open file...} in the @code{Files} menu. These are @emph{shortcut keys} that you can use instead of selecting menu items. The @key{C} stands for @key{Ctrl}; thus @code{(C-x C-f)} means @key{Ctrl-x} followed by @key{Ctrl-f}, and this sequence can be used instead of selecting @code{Files} and then @code{Open file...}. + + To abort a Glide command, type @key{Ctrl-g}. + + If you want Glide to start with an existing source file, you can either launch Glide as above and then open the file via @code{Files} @result{} @code{Open file...}, or else simply pass the name of the source file on the command line: + + @smallexample + $ glide hello.adb& + @end smallexample + + @noindent + While you are using Glide, a number of @emph{buffers} exist. You create some explicitly; e.g., when you open/create a file. Others arise as an effect of the commands that you issue; e.g., the buffer containing the output of the tools invoked during a build. If a buffer is hidden, you can bring it into a visible window by first opening the @code{Buffers} menu and then selecting the desired entry. + + If a buffer occupies only part of the Glide screen and you want to expand it to fill the entire screen, then click in the buffer and then select @code{Files} @result{} @code{One Window}. + + If a window is occupied by one buffer and you want to split the window to bring up a second buffer, perform the following steps: + @itemize @bullet + @item Select @code{Files} @result{} @code{Split Window}; this will produce two windows each of which holds the original buffer (these are not copies, but rather different views of the same buffer contents) + @item With the focus in one of the windows, select the desired buffer from the @code{Buffers} menu + @end itemize + + @noindent + To exit from Glide, choose @code{Files} @result{} @code{Exit}. + + @node The GNAT Compilation Model + @chapter The GNAT Compilation Model + @cindex GNAT compilation model + @cindex Compilation model + + @menu + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + @end menu + + @noindent + This chapter describes the compilation model used by GNAT. Although + similar to that used by other languages, such as C and C++, this model + is substantially different from the traditional Ada compilation models, + which are based on a library. The model is initially described without + reference to the library-based model. If you have not previously used an + Ada compiler, you need only read the first part of this chapter. The + last section describes and discusses the differences between the GNAT + model and the traditional Ada compiler models. If you have used other + Ada compilers, this section will help you to understand those + differences, and the advantages of the GNAT model. + + @node Source Representation + @section Source Representation + @cindex Latin-1 + + @noindent + Ada source programs are represented in standard text files, using + Latin-1 coding. Latin-1 is an 8-bit code that includes the familiar + 7-bit ASCII set, plus additional characters used for + representing foreign languages (@pxref{Foreign Language Representation} + for support of non-USA character sets). The format effector characters + are represented using their standard ASCII encodings, as follows: + + @table @code + @item VT + @findex VT + Vertical tab, @code{16#0B#} + + @item HT + @findex HT + Horizontal tab, @code{16#09#} + + @item CR + @findex CR + Carriage return, @code{16#0D#} + + @item LF + @findex LF + Line feed, @code{16#0A#} + + @item FF + @findex FF + Form feed, @code{16#0C#} + @end table + + @noindent + Source files are in standard text file format. In addition, GNAT will + recognize a wide variety of stream formats, in which the end of physical + physical lines is marked by any of the following sequences: + @code{LF}, @code{CR}, @code{CR-LF}, or @code{LF-CR}. This is useful + in accommodating files that are imported from other operating systems. + + @cindex End of source file + @cindex Source file, end + @findex SUB + The end of a source file is normally represented by the physical end of + file. However, the control character @code{16#1A#} (@code{SUB}) is also + recognized as signalling the end of the source file. Again, this is + provided for compatibility with other operating systems where this + code is used to represent the end of file. + + Each file contains a single Ada compilation unit, including any pragmas + associated with the unit. For example, this means you must place a + package declaration (a package @dfn{spec}) and the corresponding body in + separate files. An Ada @dfn{compilation} (which is a sequence of + compilation units) is represented using a sequence of files. Similarly, + you will place each subunit or child unit in a separate file. + + @node Foreign Language Representation + @section Foreign Language Representation + + @noindent + GNAT supports the standard character sets defined in Ada 95 as well as + several other non-standard character sets for use in localized versions + of the compiler (@pxref{Character Set Control}). + @menu + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + @end menu + + @node Latin-1 + @subsection Latin-1 + @cindex Latin-1 + + @noindent + The basic character set is Latin-1. This character set is defined by ISO + standard 8859, part 1. The lower half (character codes @code{16#00#} + ... @code{16#7F#)} is identical to standard ASCII coding, but the upper half is + used to represent additional characters. These include extended letters + used by European languages, such as French accents, the vowels with umlauts + used in German, and the extra letter A-ring used in Swedish. + + @findex Ada.Characters.Latin_1 + For a complete list of Latin-1 codes and their encodings, see the source + file of library unit @code{Ada.Characters.Latin_1} in file + @file{a-chlat1.ads}. + You may use any of these extended characters freely in character or + string literals. In addition, the extended characters that represent + letters can be used in identifiers. + + @node Other 8-Bit Codes + @subsection Other 8-Bit Codes + + @noindent + GNAT also supports several other 8-bit coding schemes: + + @table @asis + @cindex Latin-2 + @item Latin-2 + Latin-2 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-3 + @cindex Latin-3 + Latin-3 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-4 + @cindex Latin-4 + Latin-4 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-5 + @cindex Latin-5 + @cindex Cyrillic + Latin-4 letters (Cyrillic) allowed in identifiers, with uppercase and lowercase + equivalence. + + @item IBM PC (code page 437) + @cindex code page 437 + This code page is the normal default for PCs in the U.S. It corresponds + to the original IBM PC character set. This set has some, but not all, of + the extended Latin-1 letters, but these letters do not have the same + encoding as Latin-1. In this mode, these letters are allowed in + identifiers with uppercase and lowercase equivalence. + + @item IBM PC (code page 850) + @cindex code page 850 + This code page is a modification of 437 extended to include all the + Latin-1 letters, but still not with the usual Latin-1 encoding. In this + mode, all these letters are allowed in identifiers with uppercase and + lowercase equivalence. + + @item Full Upper 8-bit + Any character in the range 80-FF allowed in identifiers, and all are + considered distinct. In other words, there are no uppercase and lowercase + equivalences in this range. This is useful in conjunction with + certain encoding schemes used for some foreign character sets (e.g. + the typical method of representing Chinese characters on the PC). + + @item No Upper-Half + No upper-half characters in the range 80-FF are allowed in identifiers. + This gives Ada 83 compatibility for identifier names. + @end table + + @noindent + For precise data on the encodings permitted, and the uppercase and lowercase + equivalences that are recognized, see the file @file{csets.adb} in + the GNAT compiler sources. You will need to obtain a full source release + of GNAT to obtain this file. + + @node Wide Character Encodings + @subsection Wide Character Encodings + + @noindent + GNAT allows wide character codes to appear in character and string + literals, and also optionally in identifiers, by means of the following + possible encoding schemes: + + @table @asis + + @item Hex Coding + In this encoding, a wide character is represented by the following five + character sequence: + + @smallexample + ESC a b c d + @end smallexample + + @noindent + Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal + characters (using uppercase letters) of the wide character code. For + example, ESC A345 is used to represent the wide character with code + @code{16#A345#}. + This scheme is compatible with use of the full Wide_Character set. + + @item Upper-Half Coding + @cindex Upper-Half Coding + The wide character with encoding @code{16#abcd#} where the upper bit is on (in + other words, "a" is in the range 8-F) is represented as two bytes, + @code{16#ab#} and @code{16#cd#}. The second byte cannot be a format control + character, but is not required to be in the upper half. This method can + be also used for shift-JIS or EUC, where the internal coding matches the + external coding. + + @item Shift JIS Coding + @cindex Shift JIS Coding + A wide character is represented by a two-character sequence, + @code{16#ab#} and + @code{16#cd#}, with the restrictions described for upper-half encoding as + described above. The internal character code is the corresponding JIS + character according to the standard algorithm for Shift-JIS + conversion. Only characters defined in the JIS code set table can be + used with this encoding method. + + @item EUC Coding + @cindex EUC Coding + A wide character is represented by a two-character sequence + @code{16#ab#} and + @code{16#cd#}, with both characters being in the upper half. The internal + character code is the corresponding JIS character according to the EUC + encoding algorithm. Only characters defined in the JIS code set table + can be used with this encoding method. + + @item UTF-8 Coding + A wide character is represented using + UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO + 10646-1/Am.2. Depending on the character value, the representation + is a one, two, or three byte sequence: + @smallexample + @iftex + @leftskip=.7cm + @end iftex + 16#0000#-16#007f#: 2#0xxxxxxx# + 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx# + 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx# + + @end smallexample + + @noindent + where the xxx bits correspond to the left-padded bits of the + 16-bit character value. Note that all lower half ASCII characters + are represented as ASCII bytes and all upper half characters and + other wide characters are represented as sequences of upper-half + (The full UTF-8 scheme allows for encoding 31-bit characters as + 6-byte sequences, but in this implementation, all UTF-8 sequences + of four or more bytes length will be treated as illegal). + @item Brackets Coding + In this encoding, a wide character is represented by the following eight + character sequence: + + @smallexample + [ " a b c d " ] + @end smallexample + + @noindent + Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal + characters (using uppercase letters) of the wide character code. For + example, ["A345"] is used to represent the wide character with code + @code{16#A345#}. It is also possible (though not required) to use the + Brackets coding for upper half characters. For example, the code + @code{16#A3#} can be represented as @code{["A3"]}. + + This scheme is compatible with use of the full Wide_Character set, + and is also the method used for wide character encoding in the standard + ACVC (Ada Compiler Validation Capability) test suite distributions. + + @end table + + @noindent + Note: Some of these coding schemes do not permit the full use of the + Ada 95 character set. For example, neither Shift JIS, nor EUC allow the + use of the upper half of the Latin-1 set. + + @node File Naming Rules + @section File Naming Rules + + @noindent + The default file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + lowercase for all letters. + + An exception arises if the file name generated by the above rules starts + with one of the characters + a,g,i, or s, + and the second character is a + minus. In this case, the character tilde is used in place + of the minus. The reason for this special rule is to avoid clashes with + the standard names for child units of the packages System, Ada, + Interfaces, and GNAT, which use the prefixes + s- a- i- and g- + respectively. + + The file extension is @file{.ads} for a spec and + @file{.adb} for a body. The following list shows some + examples of these rules. + + @table @file + @item main.ads + Main (spec) + @item main.adb + Main (body) + @item arith_functions.ads + Arith_Functions (package spec) + @item arith_functions.adb + Arith_Functions (package body) + @item func-spec.ads + Func.Spec (child package spec) + @item func-spec.adb + Func.Spec (child package body) + @item main-sub.adb + Sub (subunit of Main) + @item a~bad.adb + A.Bad (child package body) + @end table + + @noindent + Following these rules can result in excessively long + file names if corresponding + unit names are long (for example, if child units or subunits are + heavily nested). An option is available to shorten such long file names + (called file name "krunching"). This may be particularly useful when + programs being developed with GNAT are to be used on operating systems + with limited file name lengths. @xref{Using gnatkr}. + + Of course, no file shortening algorithm can guarantee uniqueness over + all possible unit names; if file name krunching is used, it is your + responsibility to ensure no name clashes occur. Alternatively you + can specify the exact file names that you want used, as described + in the next section. Finally, if your Ada programs are migrating from a + compiler with a different naming convention, you can use the gnatchop + utility to produce source files that follow the GNAT naming conventions. + (For details @pxref{Renaming Files Using gnatchop}.) + + @node Using Other File Names + @section Using Other File Names + @cindex File names + + @noindent + In the previous section, we have described the default rules used by + GNAT to determine the file name in which a given unit resides. It is + often convenient to follow these default rules, and if you follow them, + the compiler knows without being explicitly told where to find all + the files it needs. + + However, in some cases, particularly when a program is imported from + another Ada compiler environment, it may be more convenient for the + programmer to specify which file names contain which units. GNAT allows + arbitrary file names to be used by means of the Source_File_Name pragma. + The form of this pragma is as shown in the following examples: + @cindex Source_File_Name pragma + + @smallexample + @group + @cartouche + @b{pragma} Source_File_Name (My_Utilities.Stacks, + Spec_File_Name => "myutilst_a.ada"); + @b{pragma} Source_File_name (My_Utilities.Stacks, + Body_File_Name => "myutilst.ada"); + @end cartouche + @end group + @end smallexample + + @noindent + As shown in this example, the first argument for the pragma is the unit + name (in this example a child unit). The second argument has the form + of a named association. The identifier + indicates whether the file name is for a spec or a body; + the file name itself is given by a string literal. + + The source file name pragma is a configuration pragma, which means that + normally it will be placed in the @file{gnat.adc} + file used to hold configuration + pragmas that apply to a complete compilation environment. + For more details on how the @file{gnat.adc} file is created and used + @pxref{Handling of Configuration Pragmas} + @cindex @file{gnat.adc} + + GNAT allows completely arbitrary file names to be specified using the + source file name pragma. However, if the file name specified has an + extension other than @file{.ads} or @file{.adb} it is necessary to use a special + syntax when compiling the file. The name in this case must be preceded + by the special sequence @code{-x} followed by a space and the name of the + language, here @code{ada}, as in: + + @smallexample + $ gcc -c -x ada peculiar_file_name.sim + @end smallexample + + @noindent + @code{gnatmake} handles non-standard file names in the usual manner (the + non-standard file name for the main program is simply used as the + argument to gnatmake). Note that if the extension is also non-standard, + then it must be included in the gnatmake command, it may not be omitted. + + @node Alternative File Naming Schemes + @section Alternative File Naming Schemes + @cindex File naming schemes, alternative + @cindex File names + + In the previous section, we described the use of the @code{Source_File_Name} + pragma to allow arbitrary names to be assigned to individual source files. + However, this approach requires one pragma for each file, and especially in + large systems can result in very long @file{gnat.adc} files, and also create + a maintenance problem. + + GNAT also provides a facility for specifying systematic file naming schemes + other than the standard default naming scheme previously described. An + alternative scheme for naming is specified by the use of + @code{Source_File_Name} pragmas having the following format: + @cindex Source_File_Name pragma + + @smallexample + pragma Source_File_Name ( + Spec_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Body_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Subunit_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + FILE_NAME_PATTERN ::= STRING_LITERAL + CASING_SPEC ::= Lowercase | Uppercase | Mixedcase + + @end smallexample + + @noindent + The @code{FILE_NAME_PATTERN} string shows how the file name is constructed. + It contains a single asterisk character, and the unit name is substituted + systematically for this asterisk. The optional parameter + @code{Casing} indicates + whether the unit name is to be all upper-case letters, all lower-case letters, + or mixed-case. If no + @code{Casing} parameter is used, then the default is all + lower-case. + + The optional @code{Dot_Replacement} string is used to replace any periods + that occur in subunit or child unit names. If no @code{Dot_Replacement} + argument is used then separating dots appear unchanged in the resulting + file name. + Although the above syntax indicates that the + @code{Casing} argument must appear + before the @code{Dot_Replacement} argument, but it + is also permissible to write these arguments in the opposite order. + + As indicated, it is possible to specify different naming schemes for + bodies, specs, and subunits. Quite often the rule for subunits is the + same as the rule for bodies, in which case, there is no need to give + a separate @code{Subunit_File_Name} rule, and in this case the + @code{Body_File_name} rule is used for subunits as well. + + The separate rule for subunits can also be used to implement the rather + unusual case of a compilation environment (e.g. a single directory) which + contains a subunit and a child unit with the same unit name. Although + both units cannot appear in the same partition, the Ada Reference Manual + allows (but does not require) the possibility of the two units coexisting + in the same environment. + + The file name translation works in the following steps: + + @itemize @bullet + + @item + If there is a specific @code{Source_File_Name} pragma for the given unit, + then this is always used, and any general pattern rules are ignored. + + @item + If there is a pattern type @code{Source_File_Name} pragma that applies to + the unit, then the resulting file name will be used if the file exists. If + more than one pattern matches, the latest one will be tried first, and the + first attempt resulting in a reference to a file that exists will be used. + + @item + If no pattern type @code{Source_File_Name} pragma that applies to the unit + for which the corresponding file exists, then the standard GNAT default + naming rules are used. + + @end itemize + + @noindent + As an example of the use of this mechanism, consider a commonly used scheme + in which file names are all lower case, with separating periods copied + unchanged to the resulting file name, and specs end with ".1.ada", and + bodies end with ".2.ada". GNAT will follow this scheme if the following + two pragmas appear: + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*.1.ada"); + pragma Source_File_Name + (Body_File_Name => "*.2.ada"); + @end smallexample + + @noindent + The default GNAT scheme is actually implemented by providing the following + default pragmas internally: + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*.ads", Dot_Replacement => "-"); + pragma Source_File_Name + (Body_File_Name => "*.adb", Dot_Replacement => "-"); + @end smallexample + + @noindent + Our final example implements a scheme typically used with one of the + Ada 83 compilers, where the separator character for subunits was "__" + (two underscores), specs were identified by adding @file{_.ADA}, bodies + by adding @file{.ADA}, and subunits by + adding @file{.SEP}. All file names were + upper case. Child units were not present of course since this was an + Ada 83 compiler, but it seems reasonable to extend this scheme to use + the same double underscore separator for child units. + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*_.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Body_File_Name => "*.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Subunit_File_Name => "*.SEP", + Dot_Replacement => "__", + Casing = Uppercase); + @end smallexample + + @node Generating Object Files + @section Generating Object Files + + @noindent + An Ada program consists of a set of source files, and the first step in + compiling the program is to generate the corresponding object files. + These are generated by compiling a subset of these source files. + The files you need to compile are the following: + + @itemize @bullet + @item + If a package spec has no body, compile the package spec to produce the + object file for the package. + + @item + If a package has both a spec and a body, compile the body to produce the + object file for the package. The source file for the package spec need + not be compiled in this case because there is only one object file, which + contains the code for both the spec and body of the package. + + @item + For a subprogram, compile the subprogram body to produce the object file + for the subprogram. The spec, if one is present, is as usual in a + separate file, and need not be compiled. + + @item + @cindex Subunits + In the case of subunits, only compile the parent unit. A single object + file is generated for the entire subunit tree, which includes all the + subunits. + + @item + Compile child units independently of their parent units + (though, of course, the spec of all the ancestor unit must be present in order + to compile a child unit). + + @item + @cindex Generics + Compile generic units in the same manner as any other units. The object + files in this case are small dummy files that contain at most the + flag used for elaboration checking. This is because GNAT always handles generic + instantiation by means of macro expansion. However, it is still necessary to + compile generic units, for dependency checking and elaboration purposes. + @end itemize + + @noindent + The preceding rules describe the set of files that must be compiled to + generate the object files for a program. Each object file has the same + name as the corresponding source file, except that the extension is + @file{.o} as usual. + + You may wish to compile other files for the purpose of checking their + syntactic and semantic correctness. For example, in the case where a + package has a separate spec and body, you would not normally compile the + spec. However, it is convenient in practice to compile the spec to make + sure it is error-free before compiling clients of this spec, because such + compilations will fail if there is an error in the spec. + + GNAT provides an option for compiling such files purely for the + purposes of checking correctness; such compilations are not required as + part of the process of building a program. To compile a file in this + checking mode, use the @option{-gnatc} switch. + + @node Source Dependencies + @section Source Dependencies + + @noindent + A given object file clearly depends on the source file which is compiled + to produce it. Here we are using @dfn{depends} in the sense of a typical + @code{make} utility; in other words, an object file depends on a source + file if changes to the source file require the object file to be + recompiled. + In addition to this basic dependency, a given object may depend on + additional source files as follows: + + @itemize @bullet + @item + If a file being compiled @code{with}'s a unit @var{X}, the object file + depends on the file containing the spec of unit @var{X}. This includes + files that are @code{with}'ed implicitly either because they are parents + of @code{with}'ed child units or they are run-time units required by the + language constructs used in a particular unit. + + @item + If a file being compiled instantiates a library level generic unit, the + object file depends on both the spec and body files for this generic + unit. + + @item + If a file being compiled instantiates a generic unit defined within a + package, the object file depends on the body file for the package as + well as the spec file. + + @item + @findex Inline + @cindex @option{-gnatn} switch + If a file being compiled contains a call to a subprogram for which + pragma @code{Inline} applies and inlining is activated with the + @option{-gnatn} switch, the object file depends on the file containing the + body of this subprogram as well as on the file containing the spec. Note + that for inlining to actually occur as a result of the use of this switch, + it is necessary to compile in optimizing mode. + + @cindex @option{-gnatN} switch + The use of @option{-gnatN} activates a more extensive inlining optimization + that is performed by the front end of the compiler. This inlining does + not require that the code generation be optimized. Like @option{-gnatn}, + the use of this switch generates additional dependencies. + + @item + If an object file O depends on the proper body of a subunit through inlining + or instantiation, it depends on the parent unit of the subunit. This means that + any modification of the parent unit or one of its subunits affects the + compilation of O. + + @item + The object file for a parent unit depends on all its subunit body files. + + @item + The previous two rules meant that for purposes of computing dependencies and + recompilation, a body and all its subunits are treated as an indivisible whole. + + @noindent + These rules are applied transitively: if unit @code{A} @code{with}'s + unit @code{B}, whose elaboration calls an inlined procedure in package + @code{C}, the object file for unit @code{A} will depend on the body of + @code{C}, in file @file{c.adb}. + + The set of dependent files described by these rules includes all the + files on which the unit is semantically dependent, as described in the + Ada 95 Language Reference Manual. However, it is a superset of what the + ARM describes, because it includes generic, inline, and subunit dependencies. + + An object file must be recreated by recompiling the corresponding source + file if any of the source files on which it depends are modified. For + example, if the @code{make} utility is used to control compilation, + the rule for an Ada object file must mention all the source files on + which the object file depends, according to the above definition. + The determination of the necessary + recompilations is done automatically when one uses @code{gnatmake}. + @end itemize + + @node The Ada Library Information Files + @section The Ada Library Information Files + @cindex Ada Library Information files + @cindex @file{ali} files + + @noindent + Each compilation actually generates two output files. The first of these + is the normal object file that has a @file{.o} extension. The second is a + text file containing full dependency information. It has the same + name as the source file, but an @file{.ali} extension. + This file is known as the Ada Library Information (@file{ali}) file. + The following information is contained in the @file{ali} file. + + @itemize @bullet + @item + Version information (indicates which version of GNAT was used to compile + the unit(s) in question) + + @item + Main program information (including priority and time slice settings, + as well as the wide character encoding used during compilation). + + @item + List of arguments used in the @code{gcc} command for the compilation + + @item + Attributes of the unit, including configuration pragmas used, an indication + of whether the compilation was successful, exception model used etc. + + @item + A list of relevant restrictions applying to the unit (used for consistency) + checking. + + @item + Categorization information (e.g. use of pragma @code{Pure}). + + @item + Information on all @code{with}'ed units, including presence of + @code{Elaborate} or @code{Elaborate_All} pragmas. + + @item + Information from any @code{Linker_Options} pragmas used in the unit + + @item + Information on the use of @code{Body_Version} or @code{Version} + attributes in the unit. + + @item + Dependency information. This is a list of files, together with + time stamp and checksum information. These are files on which + the unit depends in the sense that recompilation is required + if any of these units are modified. + + @item + Cross-reference data. Contains information on all entities referenced + in the unit. Used by tools like @code{gnatxref} and @code{gnatfind} to + provide cross-reference information. + + @end itemize + + @noindent + For a full detailed description of the format of the @file{ali} file, + see the source of the body of unit @code{Lib.Writ}, contained in file + @file{lib-writ.adb} in the GNAT compiler sources. + + @node Binding an Ada Program + @section Binding an Ada Program + + @noindent + When using languages such as C and C++, once the source files have been + compiled the only remaining step in building an executable program + is linking the object modules together. This means that it is possible to + link an inconsistent version of a program, in which two units have + included different versions of the same header. + + The rules of Ada do not permit such an inconsistent program to be built. + For example, if two clients have different versions of the same package, + it is illegal to build a program containing these two clients. + These rules are enforced by the GNAT binder, which also determines an + elaboration order consistent with the Ada rules. + + The GNAT binder is run after all the object files for a program have + been created. It is given the name of the main program unit, and from + this it determines the set of units required by the program, by reading the + corresponding ALI files. It generates error messages if the program is + inconsistent or if no valid order of elaboration exists. + + If no errors are detected, the binder produces a main program, in Ada by + default, that contains calls to the elaboration procedures of those + compilation unit that require them, followed by + a call to the main program. This Ada program is compiled to generate the + object file for the main program. The name of + the Ada file is @file{b~@var{xxx}.adb} (with the corresponding spec + @file{b~@var{xxx}.ads}) where @var{xxx} is the name of the + main program unit. + + Finally, the linker is used to build the resulting executable program, + using the object from the main program from the bind step as well as the + object files for the Ada units of the program. + + @node Mixed Language Programming + @section Mixed Language Programming + @cindex Mixed Language Programming + + @menu + * Interfacing to C:: + * Calling Conventions:: + @end menu + + @node Interfacing to C + @subsection Interfacing to C + @noindent + There are two ways to + build a program that contains some Ada files and some other language + files depending on whether the main program is in Ada or not. + If the main program is in Ada, you should proceed as follows: + + @enumerate + @item + Compile the other language files to generate object files. For instance: + @smallexample + gcc -c file1.c + gcc -c file2.c + @end smallexample + + @item + Compile the Ada units to produce a set of object files and ALI + files. For instance: + @smallexample + gnatmake -c my_main.adb + @end smallexample + + @item + Run the Ada binder on the Ada main program. For instance: + @smallexample + gnatbind my_main.ali + @end smallexample + + @item + Link the Ada main program, the Ada objects and the other language + objects. For instance: + @smallexample + gnatlink my_main.ali file1.o file2.o + @end smallexample + @end enumerate + + The three last steps can be grouped in a single command: + @smallexample + gnatmake my_main.adb -largs file1.o file2.o + @end smallexample + + @cindex Binder output file + @noindent + If the main program is in some language other than Ada, Then you may + have more than one entry point in the Ada subsystem. You must use a + special option of the binder to generate callable routines to initialize + and finalize the Ada units (@pxref{Binding with Non-Ada Main Programs}). + Calls to the initialization and finalization routines must be inserted in + the main program, or some other appropriate point in the code. The call to + initialize the Ada units must occur before the first Ada subprogram is + called, and the call to finalize the Ada units must occur after the last + Ada subprogram returns. You use the same procedure for building the + program as described previously. In this case, however, the binder + only places the initialization and finalization subprograms into file + @file{b~@var{xxx}.adb} instead of the main program. + So, if the main program is not in Ada, you should proceed as follows: + + @enumerate + @item + Compile the other language files to generate object files. For instance: + @smallexample + gcc -c file1.c + gcc -c file2.c + @end smallexample + + @item + Compile the Ada units to produce a set of object files and ALI + files. For instance: + @smallexample + gnatmake -c entry_point1.adb + gnatmake -c entry_point2.adb + @end smallexample + + @item + Run the Ada binder on the Ada main program. For instance: + @smallexample + gnatbind -n entry_point1.ali entry_point2.ali + @end smallexample + + @item + Link the Ada main program, the Ada objects and the other language + objects. You only need to give the last entry point here. For instance: + @smallexample + gnatlink entry_point2.ali file1.o file2.o + @end smallexample + @end enumerate + + @node Calling Conventions + @subsection Calling Conventions + @cindex Foreign Languages + @cindex Calling Conventions + GNAT follows standard calling sequence conventions and will thus interface + to any other language that also follows these conventions. The following + Convention identifiers are recognized by GNAT: + + @itemize @bullet + @cindex Interfacing to Ada + @cindex Other Ada compilers + @cindex Convention Ada + @item + Ada. This indicates that the standard Ada calling sequence will be + used and all Ada data items may be passed without any limitations in the + case where GNAT is used to generate both the caller and callee. It is also + possible to mix GNAT generated code and code generated by another Ada + compiler. In this case, the data types should be restricted to simple + cases, including primitive types. Whether complex data types can be passed + depends on the situation. Probably it is safe to pass simple arrays, such + as arrays of integers or floats. Records may or may not work, depending + on whether both compilers lay them out identically. Complex structures + involving variant records, access parameters, tasks, or protected types, + are unlikely to be able to be passed. + + Note that in the case of GNAT running + on a platform that supports DEC Ada 83, a higher degree of compatibility + can be guaranteed, and in particular records are layed out in an identical + manner in the two compilers. Note also that if output from two different + compilers is mixed, the program is responsible for dealing with elaboration + issues. Probably the safest approach is to write the main program in the + version of Ada other than GNAT, so that it takes care of its own elaboration + requirements, and then call the GNAT-generated adainit procedure to ensure + elaboration of the GNAT components. Consult the documentation of the other + Ada compiler for further details on elaboration. + + However, it is not possible to mix the tasking run time of GNAT and + DEC Ada 83, All the tasking operations must either be entirely within + GNAT compiled sections of the program, or entirely within DEC Ada 83 + compiled sections of the program. + + @cindex Interfacing to Assembly + @cindex Convention Assembler + @item + Assembler. Specifies assembler as the convention. In practice this has the + same effect as convention Ada (but is not equivalent in the sense of being + considered the same convention). + + @cindex Convention Asm + @findex Asm + @item + Asm. Equivalent to Assembler. + + @cindex Convention Asm + @findex Asm + @item + Asm. Equivalent to Assembly. + + @cindex Interfacing to COBOL + @cindex Convention COBOL + @findex COBOL + @item + COBOL. Data will be passed according to the conventions described + in section B.4 of the Ada 95 Reference Manual. + + @findex C + @cindex Interfacing to C + @cindex Convention C + @item + C. Data will be passed according to the conventions described + in section B.3 of the Ada 95 Reference Manual. + + @cindex Convention Default + @findex Default + @item + Default. Equivalent to C. + + @cindex Convention External + @findex External + @item + External. Equivalent to C. + + @findex C++ + @cindex Interfacing to C++ + @cindex Convention C++ + @item + CPP. This stands for C++. For most purposes this is identical to C. + See the separate description of the specialized GNAT pragmas relating to + C++ interfacing for further details. + + @findex Fortran + @cindex Interfacing to Fortran + @cindex Convention Fortran + @item + Fortran. Data will be passed according to the conventions described + in section B.5 of the Ada 95 Reference Manual. + + @item + Intrinsic. This applies to an intrinsic operation, as defined in the Ada 95 + Reference Manual. If a a pragma Import (Intrinsic) applies to a subprogram, + this means that the body of the subprogram is provided by the compiler itself, + usually by means of an efficient code sequence, and that the user does not + supply an explicit body for it. In an application program, the pragma can only + be applied to the following two sets of names, which the GNAT compiler + recognizes. + @itemize @bullet + @item + Rotate_Left, Rotate_Right, Shift_Left, Shift_Right, Shift_Right_- + Arithmetic. The corresponding subprogram declaration must have + two formal parameters. The + first one must be a signed integer type or a modular type with a binary + modulus, and the second parameter must be of type Natural. + The return type must be the same as the type of the first argument. The size + of this type can only be 8, 16, 32, or 64. + @item binary arithmetic operators: "+", "-", "*", "/" + The corresponding operator declaration must have parameters and result type + that have the same root numeric type (for example, all three are long_float + types). This simplifies the definition of operations that use type checking + to perform dimensional checks: + @smallexample + type Distance is new Long_Float; + type Time is new Long_Float; + type Velocity is new Long_Float; + function "/" (D : Distance; T : Time) + return Velocity; + pragma Import (Intrinsic, "/"); + @end smallexample + @noindent + This common idiom is often programmed with a generic definition and an explicit + body. The pragma makes it simpler to introduce such declarations. It incurs + no overhead in compilation time or code size, because it is implemented as a + single machine instruction. + @end itemize + @noindent + + @findex Stdcall + @cindex Convention Stdcall + @item + Stdcall. This is relevant only to NT/Win95 implementations of GNAT, + and specifies that the Stdcall calling sequence will be used, as defined + by the NT API. + + @findex DLL + @cindex Convention DLL + @item + DLL. This is equivalent to Stdcall. + + @findex Win32 + @cindex Convention Win32 + @item + Win32. This is equivalent to Stdcall. + + @findex Stubbed + @cindex Convention Stubbed + @item + Stubbed. This is a special convention that indicates that the compiler + should provide a stub body that raises @code{Program_Error}. + @end itemize + + @noindent + GNAT additionally provides a useful pragma @code{Convention_Identifier} + that can be used to parametrize conventions and allow additional synonyms + to be specified. For example if you have legacy code in which the convention + identifier Fortran77 was used for Fortran, you can use the configuration + pragma: + + @smallexample + pragma Convention_Identifier (Fortran77, Fortran); + @end smallexample + + @noindent + And from now on the identifier Fortran77 may be used as a convention + identifier (for example in an @code{Import} pragma) with the same + meaning as Fortran. + + @node Building Mixed Ada & C++ Programs + @section Building Mixed Ada & C++ Programs + + @noindent + Building a mixed application containing both Ada and C++ code may be a + challenge for the unaware programmer. As a matter of fact, this + interfacing has not been standardized in the Ada 95 reference manual due + to the immaturity and lack of standard of C++ at the time. This + section gives a few hints that should make this task easier. In + particular the first section addresses the differences with + interfacing with C. The second section looks into the delicate problem + of linking the complete application from its Ada and C++ parts. The last + section give some hints on how the GNAT run time can be adapted in order + to allow inter-language dispatching with a new C++ compiler. + + @menu + * Interfacing to C++:: + * Linking a Mixed C++ & Ada Program:: + * A Simple Example:: + * Adapting the Run Time to a New C++ Compiler:: + @end menu + + @node Interfacing to C++ + @subsection Interfacing to C++ + + @noindent + GNAT supports interfacing with C++ compilers generating code that is + compatible with the standard Application Binary Interface of the given + platform. + + @noindent + Interfacing can be done at 3 levels: simple data, subprograms and + classes. In the first 2 cases, GNAT offer a specific @var{Convention + CPP} that behaves exactly like @var{Convention C}. Usually C++ mangle + names of subprograms and currently GNAT does not provide any help to + solve the demangling problem. This problem can be addressed in 2 ways: + @itemize @bullet + @item + by modifying the C++ code in order to force a C convention using + the @var{extern "C"} syntax. + + @item + by figuring out the mangled name and use it as the Link_Name argument of + the pragma import. + @end itemize + + @noindent + Interfacing at the class level can be achieved by using the GNAT specific + pragmas such as @code{CPP_Class} and @code{CPP_Virtual}. See the GNAT + Reference Manual for additional information. + + @node Linking a Mixed C++ & Ada Program + @subsection Linking a Mixed C++ & Ada Program + + @noindent + Usually the linker of the C++ development system must be used to link + mixed applications because most C++ systems will resolve elaboration + issues (such as calling constructors on global class instances) + transparently during the link phase. GNAT has been adapted to ease the + use of a foreign linker for the last phase. Three cases can be + considered: + @enumerate + + @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 request recompiling the whole GCC + tree from sources and it does not allow to upgrade easily to a new + version of one compiler for one of the two languages without taking the + risk of destabilizing the other. + + @smallexample + $ c++ -c file1.C + $ c++ -c file2.C + $ gnatmake ada_unit -largs file1.o file2.o --LINK=c++ + @end smallexample + + @item + Using GNAT and G++ from 2 different GCC installations. If both compilers + are on the PATH, the same method can be used. It is important to be + aware that environment variables such as C_INCLUDE_PATH, + GCC_EXEC_PREFIX, BINUTILS_ROOT or GCC_ROOT will affect both compilers at + the same time and thus may make one of the 2 compilers operate + improperly if they are set for the other. In particular it is important + that the link command has access to the proper gcc library @file{libgcc.a}, + that is to say the one that is part of the C++ compiler + installation. The implicit link command as suggested in the gnatmake + command from the former example can be replaced by an explicit link + command with full verbosity in order to verify which library is used: + @smallexample + $ gnatbind ada_unit + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=c++ + @end smallexample + If there is a problem due to interfering environment variables, it can + be workaround by using an intermediate script. The following example + shows the proper script to use when GNAT has not been installed at its + default location and g++ has been installed at its default location: + + @smallexample + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + unset BINUTILS_ROOT + unset GCC_ROOT + c++ $* + @end smallexample + + @item + Using a non GNU C++ compiler. The same set of command as previously + described can be used to insure that the c++ linker is + used. Nonetheless, you need to add the path to libgcc explicitely, since some + libraries needed by GNAT are located in this directory: + + @smallexample + + $ gnatlink ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + CC $* `gcc -print-libgcc-file-name` + + @end smallexample + + Where CC is the name of the non GNU C++ compiler. + + @end enumerate + + @node A Simple Example + @subsection A Simple Example + @noindent + The following example, provided as part of the GNAT examples, show how + to achieve procedural interfacing between Ada and C++ in both + directions. The C++ class A has 2 methods. The first method is exported + to Ada by the means of an extern C wrapper function. The second method + calls an Ada subprogram. On the Ada side, The C++ calls is modelized by + a limited record with a layout comparable to the C++ class. The Ada + subprogram, in turn, calls the c++ method. So from the C++ main program + the code goes back and forth between the 2 languages. + + @noindent + Here are the compilation commands + for a GNAT VxWorks/PowerPC configuration: + @smallexample + $ powerpc-wrs-vxworks-gnatmake -c simple_cpp_interface + $ powerpc-wrs-vxworks-gnatbind -n simple_cpp_interface + $ gnatlink simple_cpp_interface -o ada_part + $ c++ppc -c -DCPU=PPC604 -I/usr/windppc/target/h cpp_main.C + $ c++ppc -c -DCPU=PPC604 -I/usr/windppc/target/h ex7.C + $ ldppc -r -o my_main my_main.o ex7.o ada_part + @end smallexample + @noindent + Here are the corresponding sources: + @smallexample + + //cpp_main.C + + #include "ex7.h" + + extern "C" @{ + void adainit (void); + void adafinal (void); + void method1 (A *t); + @} + + void method1 (A *t) + @{ + t->method1 (); + @} + + int main () + @{ + A obj; + adainit (); + obj.method2 (3030); + adafinal (); + @} + + //ex7.h + + class Origin @{ + public: + int o_value; + @}; + class A : public Origin @{ + public: + void method1 (void); + virtual void method2 (int v); + A(); + int a_value; + @}; + + //ex7.C + + #include "ex7.h" + #include + + extern "C" @{ void ada_method2 (A *t, int v);@} + + void A::method1 (void) + @{ + a_value = 2020; + printf ("in A::method1, a_value = %d \n",a_value); + + @} + + void A::method2 (int v) + @{ + ada_method2 (this, v); + printf ("in A::method2, a_value = %d \n",a_value); + + @} + + A::A(void) + @{ + a_value = 1010; + printf ("in A::A, a_value = %d \n",a_value); + @} + + -- Ada sources + @b{package} @b{body} Simple_Cpp_Interface @b{is} + + @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer) @b{is} + @b{begin} + Method1 (This); + This.A_Value := V; + @b{end} Ada_Method2; + + @b{end} Simple_Cpp_Interface; + + @b{package} Simple_Cpp_Interface @b{is} + @b{type} A @b{is} @b{limited} + @b{record} + O_Value : Integer; + A_Value : Integer; + @b{end} @b{record}; + @b{pragma} Convention (C, A); + + @b{procedure} Method1 (This : @b{in} @b{out} A); + @b{pragma} Import (C, Method1); + + @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer); + @b{pragma} Export (C, Ada_Method2); + + @b{end} Simple_Cpp_Interface; + @end smallexample + + @node Adapting the Run Time to a New C++ Compiler + @subsection Adapting the Run Time to a New C++ Compiler + @noindent + GNAT offers the capability to derive Ada 95 tagged types directly from + preexisting C++ classes and . See "Interfacing with C++" in the GNAT + reference manual. The mechanism used by GNAT for achieving such a goal + has been made user configurable through a GNAT library unit + @code{Interfaces.CPP}. The default version of this file is adapted to + the GNU c++ compiler. Internal knowledge of the virtual + table layout used by the new C++ compiler is needed to configure + properly this unit. The Interface of this unit is known by the compiler + and cannot be changed except for the value of the constants defining the + characteristics of the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size, + CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source + of this unit for more details. + + @node Comparison between GNAT and C/C++ Compilation Models + @section Comparison between GNAT and C/C++ Compilation Models + + @noindent + The GNAT model of compilation is close to the C and C++ models. You can + think of Ada specs as corresponding to header files in C. As in C, you + don't need to compile specs; they are compiled when they are used. The + Ada @code{with} is similar in effect to the @code{#include} of a C + header. + + One notable difference is that, in Ada, you may compile specs separately + to check them for semantic and syntactic accuracy. This is not always + possible with C headers because they are fragments of programs that have + less specific syntactic or semantic rules. + + The other major difference is the requirement for running the binder, + which performs two important functions. First, it checks for + consistency. In C or C++, the only defense against assembling + inconsistent programs lies outside the compiler, in a makefile, for + example. The binder satisfies the Ada requirement that it be impossible + to construct an inconsistent program when the compiler is used in normal + mode. + + @cindex Elaboration order control + The other important function of the binder is to deal with elaboration + issues. There are also elaboration issues in C++ that are handled + automatically. This automatic handling has the advantage of being + simpler to use, but the C++ programmer has no control over elaboration. + Where @code{gnatbind} might complain there was no valid order of + elaboration, a C++ compiler would simply construct a program that + malfunctioned at run time. + + @node Comparison between GNAT and Conventional Ada Library Models + @section Comparison between GNAT and Conventional Ada Library Models + + @noindent + This section is intended to be useful to Ada programmers who have + previously used an Ada compiler implementing the traditional Ada library + model, as described in the Ada 95 Language Reference Manual. If you + have not used such a system, please go on to the next section. + + @cindex GNAT library + In GNAT, there is no @dfn{library} in the normal sense. Instead, the set of + source files themselves acts as the library. Compiling Ada programs does + not generate any centralized information, but rather an object file and + a ALI file, which are of interest only to the binder and linker. + In a traditional system, the compiler reads information not only from + the source file being compiled, but also from the centralized library. + This means that the effect of a compilation depends on what has been + previously compiled. In particular: + + @itemize @bullet + @item + When a unit is @code{with}'ed, the unit seen by the compiler corresponds + to the version of the unit most recently compiled into the library. + + @item + Inlining is effective only if the necessary body has already been + compiled into the library. + + @item + Compiling a unit may obsolete other units in the library. + @end itemize + + @noindent + In GNAT, compiling one unit never affects the compilation of any other + units because the compiler reads only source files. Only changes to source + files can affect the results of a compilation. In particular: + + @itemize @bullet + @item + When a unit is @code{with}'ed, the unit seen by the compiler corresponds + to the source version of the unit that is currently accessible to the + compiler. + + @item + @cindex Inlining + Inlining requires the appropriate source files for the package or + subprogram bodies to be available to the compiler. Inlining is always + effective, independent of the order in which units are complied. + + @item + Compiling a unit never affects any other compilations. The editing of + sources may cause previous compilations to be out of date if they + depended on the source file being modified. + @end itemize + + @noindent + The most important result of these differences is that order of compilation + is never significant in GNAT. There is no situation in which one is + required to do one compilation before another. What shows up as order of + compilation requirements in the traditional Ada library becomes, in + GNAT, simple source dependencies; in other words, there is only a set + of rules saying what source files must be present when a file is + compiled. + + @node Compiling Using gcc + @chapter Compiling Using @code{gcc} + + @noindent + This chapter discusses how to compile Ada programs using the @code{gcc} + command. It also describes the set of switches + that can be used to control the behavior of the compiler. + @menu + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + @end menu + + @node Compiling Programs + @section Compiling Programs + + @noindent + The first step in creating an executable program is to compile the units + of the program using the @code{gcc} command. You must compile the + following files: + + @itemize @bullet + @item + the body file (@file{.adb}) for a library level subprogram or generic + subprogram + + @item + the spec file (@file{.ads}) for a library level package or generic + package that has no body + + @item + the body file (@file{.adb}) for a library level package + or generic package that has a body + + @end itemize + + @noindent + You need @emph{not} compile the following files + + @itemize @bullet + + @item + the spec of a library unit which has a body + + @item + subunits + @end itemize + + @noindent + because they are compiled as part of compiling related units. GNAT + package specs + when the corresponding body is compiled, and subunits when the parent is + compiled. + @cindex No code generated + If you attempt to compile any of these files, you will get one of the + following error messages (where fff is the name of the file you compiled): + + @smallexample + No code generated for file @var{fff} (@var{package spec}) + No code generated for file @var{fff} (@var{subunit}) + @end smallexample + + @noindent + The basic command for compiling a file containing an Ada unit is + + @smallexample + $ gcc -c [@var{switches}] @file{file name} + @end smallexample + + @noindent + where @var{file name} is the name of the Ada file (usually + having an extension + @file{.ads} for a spec or @file{.adb} for a body). + You specify the + @code{-c} switch to tell @code{gcc} to compile, but not link, the file. + The result of a successful compilation is an object file, which has the + same name as the source file but an extension of @file{.o} and an Ada + Library Information (ALI) file, which also has the same name as the + source file, but with @file{.ali} as the extension. GNAT creates these + two output files in the current directory, but you may specify a source + file in any directory using an absolute or relative path specification + containing the directory information. + + @findex gnat1 + @code{gcc} is actually a driver program that looks at the extensions of + the file arguments and loads the appropriate compiler. For example, the + GNU C compiler is @file{cc1}, and the Ada compiler is @file{gnat1}. + These programs are in directories known to the driver program (in some + configurations via environment variables you set), but need not be in + your path. The @code{gcc} driver also calls the assembler and any other + utilities needed to complete the generation of the required object + files. + + It is possible to supply several file names on the same @code{gcc} + command. This causes @code{gcc} to call the appropriate compiler for + each file. For example, the following command lists three separate + files to be compiled: + + @smallexample + $ gcc -c x.adb y.adb z.c + @end smallexample + + @noindent + calls @code{gnat1} (the Ada compiler) twice to compile @file{x.adb} and + @file{y.adb}, and @code{cc1} (the C compiler) once to compile @file{z.c}. + The compiler generates three object files @file{x.o}, @file{y.o} and + @file{z.o} and the two ALI files @file{x.ali} and @file{y.ali} from the + Ada compilations. Any switches apply to all the files listed, + except for + @option{-gnat@var{x}} switches, which apply only to Ada compilations. + + @node Switches for gcc + @section Switches for @code{gcc} + + @noindent + The @code{gcc} command accepts switches that control the + compilation process. These switches are fully described in this section. + First we briefly list all the switches, in alphabetical order, then we + describe the switches in more detail in functionally grouped sections. + + @menu + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + @end menu + + @table @code + @cindex @code{-b} (@code{gcc}) + @item -b @var{target} + Compile your program to run on @var{target}, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + @var{target} is not the same as your host system. + + @item -B@var{dir} + @cindex @code{-B} (@code{gcc}) + Load compiler executables (for example, @code{gnat1}, the Ada compiler) + from @var{dir} instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + @code{gcc} manual page for further details. You would normally use the + @code{-b} or @code{-V} switch instead. + + @item -c + @cindex @code{-c} (@code{gcc}) + Compile. Always use this switch when compiling Ada programs. + + Note: for some other languages when using @code{gcc}, notably in + the case of C and C++, it is possible to use + use @code{gcc} without a @code{-c} switch to + compile and link in one step. In the case of GNAT, you + cannot use this approach, because the binder must be run + and @code{gcc} cannot be used to run the GNAT binder. + + @item -g + @cindex @code{-g} (@code{gcc}) + Generate debugging information. This information is stored in the object + file and copied from there to the final executable file by the linker, + where it can be read by the debugger. You must use the + @code{-g} switch if you plan on using the debugger. + + @item -I@var{dir} + @cindex @code{-I} (@code{gcc}) + @cindex RTL + Direct GNAT to search the @var{dir} directory for source files needed by + the current compilation + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item -I- + @cindex @code{-I-} (@code{gcc}) + @cindex RTL + Except for the source file named in the command line, do not look for source files + in the directory containing the source file named in the command line + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item -o @var{file} + @cindex @code{-o} (@code{gcc}) + This switch is used in @code{gcc} to redirect the generated object file + and its associated ALI file. Beware of this switch with GNAT, because it may + cause the object file and ALI file to have different names which in turn + may confuse the binder and the linker. + + @item -O[@var{n}] + @cindex @code{-O} (@code{gcc}) + @var{n} controls the optimization level. + + @table @asis + @item n = 0 + No optimization, the default setting if no @code{-O} appears + + @item n = 1 + Normal optimization, the default if you specify @code{-O} without + an operand. + + @item n = 2 + Extensive optimization + + @item n = 3 + Extensive optimization with automatic inlining. This applies only to + inlining within a unit. For details on control of inter-unit inlining + see @xref{Subprogram Inlining Control}. + @end table + + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gcc}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -S + @cindex @code{-S} (@code{gcc}) + Used in place of @code{-c} to + cause the assembler source file to be + generated, using @file{.s} as the extension, + instead of the object file. + This may be useful if you need to examine the generated assembly code. + + @item -v + @cindex @code{-v} (@code{gcc}) + Show commands generated by the @code{gcc} driver. Normally used only for + debugging purposes or if you need to be sure what version of the + compiler you are executing. + + @item -V @var{ver} + @cindex @code{-V} (@code{gcc}) + Execute @var{ver} version of the compiler. This is the @code{gcc} + version, not the GNAT version. + + @item -gnata + Assertions enabled. @code{Pragma Assert} and @code{pragma Debug} to be + activated. + + @item -gnatA + Avoid processing @file{gnat.adc}. If a gnat.adc file is present, it will be ignored. + + @item -gnatb + Generate brief messages to @file{stderr} even if verbose mode set. + + @item -gnatc + Check syntax and semantics only (no code generation attempted). + + @item -gnatC + Compress debug information and external symbol name table entries. + + @item -gnatD + Output expanded source files for source level debugging. This switch + also suppress generation of cross-reference information (see -gnatx). + + @item -gnatec@var{path} + Specify a configuration pragma file. (see @ref{The Configuration Pragmas Files}) + + @item -gnatem@var{path} + Specify a mapping file. (see @ref{Units to Sources Mapping Files}) + + @item -gnatE + Full dynamic elaboration checks. + + @item -gnatf + Full errors. Multiple errors per line, all undefined references. + + @item -gnatF + Externals names are folded to all uppercase. + + @item -gnatg + Internal GNAT implementation mode. This should not be used for + applications programs, it is intended only for use by the compiler + and its run-time library. For documentation, see the GNAT sources. + + @item -gnatG + List generated expanded code in source form. + + @item -gnati@var{c} + Identifier character set + (@var{c}=1/2/3/4/8/9/p/f/n/w). + + @item -gnath + Output usage information. The output is written to @file{stdout}. + + @item -gnatk@var{n} + Limit file names to @var{n} (1-999) characters (@code{k} = krunch). + + @item -gnatl + Output full source listing with embedded error messages. + + @item -gnatm@var{n} + Limit number of detected errors to @var{n} (1-999). + + @item -gnatn + Activate inlining across unit boundaries for subprograms for which + pragma @code{inline} is specified. + + @item -gnatN + Activate front end inlining. + + @item -fno-inline + Suppresses all inlining, even if other optimization or inlining switches + are set. + + @item -fstack-check + Activates stack checking. See separate section on stack checking for + details of the use of this option. + + @item -gnato + Enable numeric overflow checking (which is not normally enabled by + default). Not that division by zero is a separate check that is not + controlled by this switch (division by zero checking is on by default). + + @item -gnatp + Suppress all checks. + + @item -gnatq + Don't quit; try semantics, even if parse errors. + + @item -gnatQ + Don't quit; generate @file{ali} and tree files even if illegalities. + + @item -gnatP + Enable polling. This is required on some systems (notably Windows NT) to + obtain asynchronous abort and asynchronous transfer of control capability. + See the description of pragma Polling in the GNAT Reference Manual for + full details. + + @item -gnatR[0/1/2/3][s] + Output representation information for declared types and objects. + + @item -gnats + Syntax check only. + + @item -gnatt + Tree output file to be generated. + + @item -gnatT nnn + Set time slice to specified number of microseconds + + @item -gnatu + List units for this compilation. + + @item -gnatU + Tag all error messages with the unique string "error:" + + @item -gnatv + Verbose mode. Full error output with source lines to @file{stdout}. + + @item -gnatV + Control level of validity checking. See separate section describing + this feature. + + @item -gnatwxxx@var{xxx} + Warning mode where + @var{xxx} is a string of options describing the exact warnings that + are enabled or disabled. See separate section on warning control. + + @item -gnatW@var{e} + Wide character encoding method + (@var{e}=n/h/u/s/e/8). + + @item -gnatx + Suppress generation of cross-reference information. + + @item -gnaty + Enable built-in style checks. See separate section describing this feature. + + @item -gnatz@var{m} + Distribution stub generation and compilation + (@var{m}=r/c for receiver/caller stubs). + + @item -gnat83 + Enforce Ada 83 restrictions. + + @item -pass-exit-codes + Catch exit codes from the compiler and use the most meaningful as + exit status. + @end table + + You may combine a sequence of GNAT switches into a single switch. For + example, the combined switch + + @cindex Combining GNAT switches + @smallexample + -gnatofi3 + @end smallexample + + @noindent + is equivalent to specifying the following sequence of switches: + + @smallexample + -gnato -gnatf -gnati3 + @end smallexample + + @noindent + The following restrictions apply to the combination of switches + in this manner: + + @itemize @bullet + @item + The switch @option{-gnatc} if combined with other switches must come + first in the string. + + @item + The switch @option{-gnats} if combined with other switches must come + first in the string. + + @item + Once a "y" appears in the string (that is a use of the @option{-gnaty} + switch), then all further characters in the switch are interpreted + as style modifiers (see description of @option{-gnaty}). + + @item + Once a "d" appears in the string (that is a use of the @option{-gnatd} + switch), then all further characters in the switch are interpreted + as debug flags (see description of @option{-gnatd}). + + @item + Once a "w" appears in the string (that is a use of the @option{-gnatw} + switch), then all further characters in the switch are interpreted + as warning mode modifiers (see description of @option{-gnatw}). + + @item + 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 + as validity checking options (see description of @option{-gnatV}). + + @end itemize + + @node Output and Error Message Control + @subsection Output and Error Message Control + @findex stderr + + @noindent + The standard default format for error messages is called "brief format." + Brief format messages are written to @file{stderr} (the standard error + file) and have the following form: + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:4:20: ";" should be "is" + @end smallexample + + @noindent + The first integer after the file name is the line number in the file, + and the second integer is the column number within the line. + @code{glide} can parse the error messages + and point to the referenced character. + The following switches provide control over the error message + format: + + @table @code + @item -gnatv + @cindex @option{-gnatv} (@code{gcc}) + @findex stdout + The v stands for verbose. + The effect of this setting is to write long-format error + messages to @file{stdout} (the standard output file. + The same program compiled with the + @option{-gnatv} switch would generate: + + @smallexample + @group + @cartouche + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + @end cartouche + @end group + @end smallexample + + @noindent + The vertical bar indicates the location of the error, and the @samp{>>>} + prefix can be used to search for error messages. When this switch is + used the only source lines output are those with errors. + + @item -gnatl + @cindex @option{-gnatl} (@code{gcc}) + The @code{l} stands for list. + This switch causes a full listing of + the file to be generated. The output might look as follows: + + @smallexample + @group + @cartouche + 1. procedure E is + 2. V : Integer; + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + 5. begin + 6. return Q + Q; + 7. end; + 8. begin + 9. V := X + X; + 10.end E; + @end cartouche + @end group + @end smallexample + + @noindent + @findex stderr + When you specify the @option{-gnatv} or @option{-gnatl} switches and + standard output is redirected, a brief summary is written to + @file{stderr} (standard error) giving the number of error messages and + warning messages generated. + + @item -gnatU + @cindex @option{-gnatU} (@code{gcc}) + This switch forces all error messages to be preceded by the unique + string "error:". This means that error messages take a few more + characters in space, but allows easy searching for and identification + of error messages. + + @item -gnatb + @cindex @option{-gnatb} (@code{gcc}) + The @code{b} stands for brief. + This switch causes GNAT to generate the + brief format error messages to @file{stderr} (the standard error + file) as well as the verbose + format message or full listing (which as usual is written to + @file{stdout} (the standard output file). + + @item -gnatm@var{n} + @cindex @option{-gnatm} (@code{gcc}) + The @code{m} stands for maximum. + @var{n} is a decimal integer in the + range of 1 to 999 and limits the number of error messages to be + generated. For example, using @option{-gnatm2} might yield + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:5:35: missing ".." + fatal error: maximum errors reached + compilation abandoned + @end smallexample + + @item -gnatf + @cindex @option{-gnatf} (@code{gcc}) + @cindex Error messages, suppressing + The @code{f} stands for full. + Normally, the compiler suppresses error messages that are likely to be + redundant. This switch causes all error + messages to be generated. In particular, in the case of + references to undefined variables. If a given variable is referenced + several times, the normal format of messages is + @smallexample + @iftex + @leftskip=.7cm + @end iftex + e.adb:7:07: "V" is undefined (more references follow) + @end smallexample + + @noindent + where the parenthetical comment warns that there are additional + references to the variable @code{V}. Compiling the same program with the + @option{-gnatf} switch yields + + @smallexample + e.adb:7:07: "V" is undefined + e.adb:8:07: "V" is undefined + e.adb:8:12: "V" is undefined + e.adb:8:16: "V" is undefined + e.adb:9:07: "V" is undefined + e.adb:9:12: "V" is undefined + @end smallexample + + @item -gnatq + @cindex @option{-gnatq} (@code{gcc}) + The @code{q} stands for quit (really "don't quit"). + In normal operation mode, the compiler first parses the program and + determines if there are any syntax errors. If there are, appropriate + error messages are generated and compilation is immediately terminated. + This switch tells + GNAT to continue with semantic analysis even if syntax errors have been + found. This may enable the detection of more errors in a single run. On + the other hand, the semantic analyzer is more likely to encounter some + internal fatal error when given a syntactically invalid tree. + + @item -gnatQ + In normal operation mode, the @file{ali} file is not generated if any + illegalities are detected in the program. The use of @option{-gnatQ} forces + generation of the @file{ali} file. This file is marked as being in + error, so it cannot be used for binding purposes, but it does contain + reasonably complete cross-reference information, and thus may be useful + for use by tools (e.g. semantic browsing tools or integrated development + environments) that are driven from the @file{ali} file. + + In addition, if @option{-gnatt} is also specified, then the tree file is + generated even if there are illegalities. It may be useful in this case + to also specify @option{-gnatq} to ensure that full semantic processing + occurs. The resulting tree file can be processed by ASIS, for the purpose + of providing partial information about illegal units, but if the error + causes the tree to be badly malformed, then ASIS may crash during the + analysis. + + @end table + + @noindent + In addition to error messages, which correspond to illegalities as defined + in the Ada 95 Reference Manual, the compiler detects two kinds of warning + situations. + + @cindex Warning messages + First, the compiler considers some constructs suspicious and generates a + warning message to alert you to a possible error. Second, if the + compiler detects a situation that is sure to raise an exception at + run time, it generates a warning message. The following shows an example + of warning messages: + @smallexample + @iftex + @leftskip=.2cm + @end iftex + e.adb:4:24: warning: creation of object may raise Storage_Error + e.adb:10:17: warning: static value out of range + e.adb:10:17: warning: "Constraint_Error" will be raised at run time + + @end smallexample + + @noindent + GNAT considers a large number of situations as appropriate + for the generation of warning messages. As always, warnings are not + definite indications of errors. For example, if you do an out-of-range + assignment with the deliberate intention of raising a + @code{Constraint_Error} exception, then the warning that may be + issued does not indicate an error. Some of the situations for which GNAT + issues warnings (at least some of the time) are given in the following + list, which is not necessarily complete. + + @itemize @bullet + @item + Possible infinitely recursive calls + + @item + Out-of-range values being assigned + + @item + Possible order of elaboration problems + + @item + Unreachable code + + @item + Fixed-point type declarations with a null range + + @item + Variables that are never assigned a value + + @item + Variables that are referenced before being initialized + + @item + Task entries with no corresponding accept statement + + @item + Duplicate accepts for the same task entry in a select + + @item + Objects that take too much storage + + @item + Unchecked conversion between types of differing sizes + + @item + Missing return statements along some execution paths in a function + + @item + Incorrect (unrecognized) pragmas + + @item + Incorrect external names + + @item + Allocation from empty storage pool + + @item + Potentially blocking operations in protected types + + @item + Suspicious parenthesization of expressions + + @item + Mismatching bounds in an aggregate + + @item + Attempt to return local value by reference + + @item + Unrecognized pragmas + + @item + Premature instantiation of a generic body + + @item + Attempt to pack aliased components + + @item + Out of bounds array subscripts + + @item + Wrong length on string assignment + + @item + Violations of style rules if style checking is enabled + + @item + Unused with clauses + + @item + Bit_Order usage that does not have any effect + + @item + Compile time biased rounding of floating-point constant + + @item + Standard.Duration used to resolve universal fixed expression + + @item + Dereference of possibly null value + + @item + Declaration that is likely to cause storage error + + @item + Internal GNAT unit with'ed by application unit + + @item + Values known to be out of range at compile time + + @item + Unreferenced labels and variables + + @item + Address overlays that could clobber memory + + @item + Unexpected initialization when address clause present + + @item + Bad alignment for address clause + + @item + Useless type conversions + + @item + Redundant assignment statements + + @item + Accidental hiding of name by child unit + + @item + Unreachable code + + @item + Access before elaboration detected at compile time + + @item + A range in a @code{for} loop that is known to be null or might be null + + @end itemize + + @noindent + The following switches are available to control the handling of + warning messages: + + @table @code + @item -gnatwa (activate all optional errors) + @cindex @option{-gnatwa} (@code{gcc}) + This switch activates most optional warning messages, see remaining list + in this section for details on optional warning messages that can be + individually controlled. The warnings that are not turned on by this + switch are @option{-gnatwb} (biased rounding), + @option{-gnatwd} (implicit dereferencing), + and @option{-gnatwh} (hiding). All other optional warnings are + turned on. + + @item -gnatwA (suppress all optional errors) + @cindex @option{-gnatwA} (@code{gcc}) + This switch suppresses all optional warning messages, see remaining list + in this section for details on optional warning messages that can be + individually controlled. + + @item -gnatwb (activate warnings on biased rounding) + @cindex @option{-gnatwb} (@code{gcc}) + @cindex Rounding, biased + @cindex Biased rounding + If a static floating-point expression has a value that is exactly half + way between two adjacent machine numbers, then the rules of Ada + (Ada Reference Manual, section 4.9(38)) require that this rounding + be done away from zero, even if the normal unbiased rounding rules + at run time would require rounding towards zero. This warning message + alerts you to such instances where compile-time rounding and run-time + rounding are not equivalent. If it is important to get proper run-time + rounding, then you can force this by making one of the operands into + a variable. The default is that such warnings are not generated. + Note that @option{-gnatwa} does not affect the setting of + this warning option. + + @item -gnatwB (suppress warnings on biased rounding) + @cindex @option{-gnatwB} (@code{gcc}) + This switch disables warnings on biased rounding. + + @item -gnatwc (activate warnings on conditionals) + @cindex @option{-gnatwc} (@code{gcc}) + @cindex Conditionals, constant + This switch activates warnings for conditional expressions used in + tests that are known to be True or False at compile time. The default + is that such warnings are not generated. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwC (suppress warnings on conditionals) + @cindex @option{-gnatwC} (@code{gcc}) + This switch suppresses warnings for conditional expressions used in + tests that are known to be True or False at compile time. + + @item -gnatwd (activate warnings on implicit dereferencing) + @cindex @option{-gnatwd} (@code{gcc}) + If this switch is set, then the use of a prefix of an access type + in an indexed component, slice, or selected component without an + explicit @code{.all} will generate a warning. With this warning + enabled, access checks occur only at points where an explicit + @code{.all} appears in the source code (assuming no warnings are + generated as a result of this switch). The default is that such + warnings are not generated. + Note that @option{-gnatwa} does not affect the setting of + this warning option. + + @item -gnatwD (suppress warnings on implicit dereferencing) + @cindex @option{-gnatwD} (@code{gcc}) + @cindex Implicit dereferencing + @cindex Dereferencing, implicit + This switch suppresses warnings for implicit deferences in + indexed components, slices, and selected components. + + @item -gnatwe (treat warnings as errors) + @cindex @option{-gnatwe} (@code{gcc}) + @cindex Warnings, treat as error + This switch causes warning messages to be treated as errors. + The warning string still appears, but the warning messages are counted + as errors, and prevent the generation of an object file. + + @item -gnatwf (activate warnings on unreferenced formals) + @cindex @option{-gnatwf} (@code{gcc}) + @cindex Formals, unreferenced + This switch causes a warning to be generated if a formal parameter + is not referenced in the body of the subprogram. This warning can + also be turned on using @option{-gnatwa} or @option{-gnatwu}. + + @item -gnatwF (suppress warnings on unreferenced formals) + @cindex @option{-gnatwF} (@code{gcc}) + This switch suppresses warnings for unreferenced formal + parameters. Note that the + combination @option{-gnatwu} followed by @option{-gnatwF} has the + effect of warning on unreferenced entities other than subprogram + formals. + + @item -gnatwh (activate warnings on hiding) + @cindex @option{-gnatwh} (@code{gcc}) + @cindex Hiding of Declarations + This switch activates warnings on hiding declarations. + A declaration is considered hiding + if it is for a non-overloadable entity, and it declares an entity with the + same name as some other entity that is directly or use-visible. The default + is that such warnings are not generated. + Note that @option{-gnatwa} does not affect the setting of this warning option. + + @item -gnatwH (suppress warnings on hiding) + @cindex @option{-gnatwH} (@code{gcc}) + This switch suppresses warnings on hiding declarations. + + @item -gnatwi (activate warnings on implementation units). + @cindex @option{-gnatwi} (@code{gcc}) + This switch activates warnings for a @code{with} of an internal GNAT + implementation unit, defined as any unit from the @code{Ada}, + @code{Interfaces}, @code{GNAT}, + or @code{System} + hierarchies that is not + documented in either the Ada Reference Manual or the GNAT + Programmer's Reference Manual. Such units are intended only + for internal implementation purposes and should not be @code{with}'ed + by user programs. The default is that such warnings are generated + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwI (disable warnings on implementation units). + @cindex @option{-gnatwI} (@code{gcc}) + This switch disables warnings for a @code{with} of an internal GNAT + implementation unit. + + @item -gnatwl (activate warnings on elaboration pragmas) + @cindex @option{-gnatwl} (@code{gcc}) + @cindex Elaboration, warnings + This switch activates warnings on missing pragma Elaborate_All statements. + See the section in this guide on elaboration checking for details on + when such pragma should be used. The default is that such warnings + are not generated. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwL (suppress warnings on elaboration pragmas) + @cindex @option{-gnatwL} (@code{gcc}) + This switch suppresses warnings on missing pragma Elaborate_All statements. + See the section in this guide on elaboration checking for details on + when such pragma should be used. + + @item -gnatwo (activate warnings on address clause overlays) + @cindex @option{-gnatwo} (@code{gcc}) + @cindex Address Clauses, warnings + This switch activates warnings for possibly unintended initialization + effects of defining address clauses that cause one variable to overlap + another. The default is that such warnings are generated. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwO (suppress warnings on address clause overlays) + @cindex @option{-gnatwO} (@code{gcc}) + This switch suppresses warnings on possibly unintended initialization + effects of defining address clauses that cause one variable to overlap + another. + + @item -gnatwp (activate warnings on ineffective pragma Inlines) + @cindex @option{-gnatwp} (@code{gcc}) + @cindex Inlining, warnings + This switch activates warnings for failure of front end inlining + (activated by @option{-gnatN}) to inline a particular call. There are + many reasons for not being able to inline a call, including most + commonly that the call is too complex to inline. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwP (suppress warnings on ineffective pragma Inlines) + @cindex @option{-gnatwP} (@code{gcc}) + This switch suppresses warnings on ineffective pragma Inlines. If the + inlining mechanism cannot inline a call, it will simply ignore the + request silently. + + @item -gnatwr (activate warnings on redundant constructs) + @cindex @option{-gnatwr} (@code{gcc}) + This switch activates warnings for redundant constructs. The following + is the current list of constructs regarded as redundant: + This warning can also be turned on using @option{-gnatwa}. + + @itemize @bullet + @item + Assignment of an item to itself. + @item + Type conversion that converts an expression to its own type. + @item + Use of the attribute @code{Base} where @code{typ'Base} is the same + as @code{typ}. + @item + Use of pragma @code{Pack} when all components are placed by a record + representation clause. + @end itemize + + @item -gnatwR (suppress warnings on redundant constructs) + @cindex @option{-gnatwR} (@code{gcc}) + This switch suppresses warnings for redundant constructs. + + @item -gnatws (suppress all warnings) + @cindex @option{-gnatws} (@code{gcc}) + This switch completely suppresses the + output of all warning messages from the GNAT front end. + Note that it does not suppress warnings from the @code{gcc} back end. + To suppress these back end warnings as well, use the switch @code{-w} + in addition to @option{-gnatws}. + + @item -gnatwu (activate warnings on unused entities) + @cindex @option{-gnatwu} (@code{gcc}) + This switch activates warnings to be generated for entities that + are defined but not referenced, and for units that are @code{with}'ed + and not + referenced. In the case of packages, a warning is also generated if + no entities in the package are referenced. This means that if the package + is referenced but the only references are in @code{use} + clauses or @code{renames} + declarations, a warning is still generated. A warning is also generated + for a generic package that is @code{with}'ed but never instantiated. + In the case where a package or subprogram body is compiled, and there + is a @code{with} on the corresponding spec + that is only referenced in the body, + a warning is also generated, noting that the + @code{with} can be moved to the body. The default is that + such warnings are not generated. + This switch also activates warnings on unreferenced formals + (it is includes the effect of @option{-gnatwf}). + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwU (suppress warnings on unused entities) + @cindex @option{-gnatwU} (@code{gcc}) + This switch suppresses warnings for unused entities and packages. + It also turns off warnings on unreferenced formals (and thus includes + the effect of @option{-gnatwF}). + + @noindent + A string of warning parameters can be used in the same parameter. For example: + + @smallexample + -gnatwaLe + @end smallexample + + @noindent + Would turn on all optional warnings except for elaboration pragma warnings, + and also specify that warnings should be treated as errors. + + @item -w + @cindex @code{-w} + This switch suppresses warnings from the @code{gcc} backend. It may be + used in conjunction with @option{-gnatws} to ensure that all warnings + are suppressed during the entire compilation process. + + @end table + + @node Debugging and Assertion Control + @subsection Debugging and Assertion Control + + @table @code + @item -gnata + @cindex @option{-gnata} (@code{gcc}) + @findex Assert + @findex Debug + @cindex Assertions + + @noindent + The pragmas @code{Assert} and @code{Debug} normally have no effect and + are ignored. This switch, where @samp{a} stands for assert, causes + @code{Assert} and @code{Debug} pragmas to be activated. + + The pragmas have the form: + + @smallexample + @group + @cartouche + @b{pragma} Assert (@var{Boolean-expression} [, + @var{static-string-expression}]) + @b{pragma} Debug (@var{procedure call}) + @end cartouche + @end group + @end smallexample + + @noindent + The @code{Assert} pragma causes @var{Boolean-expression} to be tested. + If the result is @code{True}, the pragma has no effect (other than + possible side effects from evaluating the expression). If the result is + @code{False}, the exception @code{Assert_Failure} declared in the package + @code{System.Assertions} is + raised (passing @var{static-string-expression}, if present, as the + message associated with the exception). If no string expression is + given the default is a string giving the file name and line number + of the pragma. + + The @code{Debug} pragma causes @var{procedure} to be called. Note that + @code{pragma Debug} may appear within a declaration sequence, allowing + debugging procedures to be called between declarations. + + @end table + + @node Validity Checking + @subsection Validity Checking + @findex Validity Checking + + @noindent + The Ada 95 Reference Manual has specific requirements for checking + for invalid values. In particular, RM 13.9.1 requires that the + evaluation of invalid values (for example from unchecked conversions), + not result in erroneous execution. In GNAT, the result of such an + evaluation in normal default mode is to either use the value + unmodified, or to raise Constraint_Error in those cases where use + of the unmodified value would cause erroneous execution. The cases + where unmodified values might lead to erroneous execution are case + statements (where a wild jump might result from an invalid value), + and subscripts on the left hand side (where memory corruption could + occur as a result of an invalid value). + + The @option{-gnatVx} switch allows more control over the validity checking + mode. The @code{x} argument here is a string of letters which control which + validity checks are performed in addition to the default checks described + above. + + @itemize @bullet + @item + @option{-gnatVc} Validity checks for copies + + The right hand side of assignments, and the initializing values of + object declarations are validity checked. + + @item + @option{-gnatVd} Default (RM) validity checks + + Some validity checks are done by default following normal Ada semantics + (RM 13.9.1 (9-11)). + A check is done in case statements that the expression is within the range + of the subtype. If it is not, Constraint_Error is raised. + For assignments to array components, a check is done that the expression used + as index is within the range. If it is not, Constraint_Error is raised. + Both these validity checks may be turned off using switch @option{-gnatVD}. + They are turned on by default. If @option{-gnatVD} is specified, a subsequent + switch @option{-gnatVd} will leave the checks turned on. + Switch @option{-gnatVD} should be used only if you are sure that all such + expressions have valid values. If you use this switch and invalid values + are present, then the program is erroneous, and wild jumps or memory + overwriting may occur. + + @item + @option{-gnatVi} Validity checks for @code{in} mode parameters + + Arguments for parameters of mode @code{in} are validity checked in function + and procedure calls at the point of call. + + @item + @option{-gnatVm} Validity checks for @code{in out} mode parameters + + Arguments for parameters of mode @code{in out} are validity checked in + procedure calls at the point of call. The @code{'m'} here stands for + modify, since this concerns parameters that can be modified by the call. + Note that there is no specific option to test @code{out} parameters, + but any reference within the subprogram will be tested in the usual + manner, and if an invalid value is copied back, any reference to it + will be subject to validity checking. + + @item + @option{-gnatVo} Validity checks for operator and attribute operands + + Arguments for predefined operators and attributes are validity checked. + This includes all operators in package @code{Standard}, + the shift operators defined as intrinsic in package @code{Interfaces} + and operands for attributes such as @code{Pos}. + + @item + @option{-gnatVr} Validity checks for function returns + + The expression in @code{return} statements in functions is validity + checked. + + @item + @option{-gnatVs} Validity checks for subscripts + + All subscripts expressions are checked for validity, whether they appear + on the right side or left side (in default mode only left side subscripts + are validity checked). + + @item + @option{-gnatVt} Validity checks for tests + + Expressions used as conditions in @code{if}, @code{while} or @code{exit} + statements are checked, as well as guard expressions in entry calls. + + @item + @option{-gnatVf} Validity checks for floating-point values + + In the absence of this switch, validity checking occurs only for discrete + values. If @option{-gnatVf} is specified, then validity checking also applies + for floating-point values, and NaN's and infinities are considered invalid, + as well as out of range values for constrained types. Note that this means + that standard @code{IEEE} infinity mode is not allowed. The exact contexts + in which floating-point values are checked depends on the setting of other + options. For example @option{-gnatVif} or @option{-gnatVfi} (the order does + not matter) specifies that floating-point parameters of mode @code{in} should + be validity checked. + + @item + @option{-gnatVa} All validity checks + + All the above validity checks are turned on. That is @option{-gnatVa} is + equivalent to @code{gnatVcdfimorst}. + + @item + @option{-gnatVn} No validity checks + + This switch turns off all validity checking, including the default checking + for case statements and left hand side subscripts. Note that the use of + the switch @option{-gnatp} supresses all run-time checks, including + validity checks, and thus implies @option{-gnatVn}. + + @end itemize + + The @option{-gnatV} switch may be followed by a string of letters to turn on + a series of validity checking options. For example, @option{-gnatVcr} specifies + that in addition to the default validity checking, copies and function + return expressions be validity checked. In order to make it easier to specify + a set of options, the upper case letters @code{CDFIMORST} may be used to turn + off the corresponding lower case option, so for example @option{-gnatVaM} turns + on all validity checking options except for checking of @code{in out} + procedure arguments. + + The specification of additional validity checking generates extra code (and + in the case of @option{-gnatva} the code expansion can be substantial. However, + these additional checks can be very useful in smoking out cases of + uninitialized variables, incorrect use of unchecked conversion, and other + errors leading to invalid values. The use of pragma @code{Initialize_Scalars} + is useful in conjunction with the extra validity checking, since this + ensures that wherever possible uninitialized variables have invalid values. + + See also the pragma @code{Validity_Checks} which allows modification of + the validity checking mode at the program source level, and also allows for + temporary disabling of validity checks. + + @node Style Checking + @subsection Style Checking + @findex Style checking + + @noindent + The -gnaty@var{x} switch causes the compiler to + enforce specified style rules. A limited set of style rules has been used + in writing the GNAT sources themselves. This switch allows user programs + to activate all or some of these checks. If the source program fails a + specified style check, an appropriate warning message is given, preceded by + the character sequence "(style)". + The string @var{x} is a sequence of letters or digits + indicating the particular style + checks to be performed. The following checks are defined: + + @table @code + @item 1-9 (specify indentation level) + If a digit from 1-9 appears in the string after @option{-gnaty} then proper + indentation is checked, with the digit indicating the indentation level + required. The general style of required indentation is as specified by + the examples in the Ada Reference Manual. Full line comments must be + aligned with the @code{--} starting on a column that is a multiple of + the alignment level. + + @item a (check attribute casing) + If the letter a appears in the string after @option{-gnaty} then + attribute names, including the case of keywords such as @code{digits} + used as attributes names, must be written in mixed case, that is, the + initial letter and any letter following an underscore must be uppercase. + All other letters must be lowercase. + + @item b (blanks not allowed at statement end) + If the letter b appears in the string after @option{-gnaty} then + trailing blanks are not allowed at the end of statements. The purpose of this + rule, together with h (no horizontal tabs), is to enforce a canonical format + for the use of blanks to separate source tokens. + + @item c (check comments) + If the letter c appears in the string after @option{-gnaty} then + comments must meet the following set of rules: + + @itemize @bullet + + @item + The "--" that starts the column must either start in column one, or else + at least one blank must precede this sequence. + + @item + Comments that follow other tokens on a line must have at least one blank + following the "--" at the start of the comment. + + @item + Full line comments must have two blanks following the "--" that starts + the comment, with the following exceptions. + + @item + A line consisting only of the "--" characters, possibly preceded by blanks + is permitted. + + @item + A comment starting with "--x" where x is a special character is permitted. + This alows proper processing of the output generated by specialized tools + including @code{gnatprep} (where --! is used) and the SPARK annnotation + language (where --# is used). For the purposes of this rule, a special + character is defined as being in one of the ASCII ranges + 16#21#..16#2F# or 16#3A#..16#3F#. + + @item + A line consisting entirely of minus signs, possibly preceded by blanks, is + permitted. This allows the construction of box comments where lines of minus + signs are used to form the top and bottom of the box. + + @item + If a comment starts and ends with "--" is permitted as long as at least + one blank follows the initial "--". Together with the preceding rule, + this allows the construction of box comments, as shown in the following + example: + @smallexample + --------------------------- + -- This is a box comment -- + -- with two text lines. -- + --------------------------- + @end smallexample + @end itemize + + @item e (check end/exit labels) + If the letter e appears in the string after @option{-gnaty} then + optional labels on @code{end} statements ending subprograms and on + @code{exit} statements exiting named loops, are required to be present. + + @item f (no form feeds or vertical tabs) + If the letter f appears in the string after @option{-gnaty} then + neither form feeds nor vertical tab characters are not permitted + in the source text. + + @item h (no horizontal tabs) + If the letter h appears in the string after @option{-gnaty} then + horizontal tab characters are not permitted in the source text. + Together with the b (no blanks at end of line) check, this + enforces a canonical form for the use of blanks to separate + source tokens. + + @item i (check if-then layout) + If the letter i appears in the string after @option{-gnaty}, + then the keyword @code{then} must appear either on the same + line as corresponding @code{if}, or on a line on its own, lined + up under the @code{if} with at least one non-blank line in between + containing all or part of the condition to be tested. + + @item k (check keyword casing) + If the letter k appears in the string after @option{-gnaty} then + all keywords must be in lower case (with the exception of keywords + such as @code{digits} used as attribute names to which this check + does not apply). + + @item l (check layout) + If the letter l appears in the string after @option{-gnaty} then + layout of statement and declaration constructs must follow the + recommendations in the Ada Reference Manual, as indicated by the + form of the syntax rules. For example an @code{else} keyword must + be lined up with the corresponding @code{if} keyword. + + There are two respects in which the style rule enforced by this check + option are more liberal than those in the Ada Reference Manual. First + in the case of record declarations, it is permissible to put the + @code{record} keyword on the same line as the @code{type} keyword, and + then the @code{end} in @code{end record} must line up under @code{type}. + For example, either of the following two layouts is acceptable: + + @smallexample + @group + @cartouche + @b{type} q @b{is record} + a : integer; + b : integer; + @b{end record}; + + @b{type} q @b{is} + @b{record} + a : integer; + b : integer; + @b{end record}; + @end cartouche + @end group + @end smallexample + + @noindent + Second, in the case of a block statement, a permitted alternative + is to put the block label on the same line as the @code{declare} or + @code{begin} keyword, and then line the @code{end} keyword up under + the block label. For example both the following are permitted: + + @smallexample + @group + @cartouche + Block : @b{declare} + A : Integer := 3; + @b{begin} + Proc (A, A); + @b{end} Block; + + Block : + @b{declare} + A : Integer := 3; + @b{begin} + Proc (A, A); + @b{end} Block; + @end cartouche + @end group + @end smallexample + + @noindent + The same alternative format is allowed for loops. For example, both of + the following are permitted: + + @smallexample + @group + @cartouche + Clear : @b{while} J < 10 @b{loop} + A (J) := 0; + @b{end loop} Clear; + + Clear : + @b{while} J < 10 @b{loop} + A (J) := 0; + @b{end loop} Clear; + @end cartouche + @end group + @end smallexample + + @item m (check maximum line length) + If the letter m appears in the string after @option{-gnaty} + then the length of source lines must not exceed 79 characters, including + any trailing blanks. The value of 79 allows convenient display on an + 80 character wide device or window, allowing for possible special + treatment of 80 character lines. + + @item Mnnn (set maximum line length) + If the sequence Mnnn, where nnn is a decimal number, appears in + the string after @option{-gnaty} then the length of lines must not exceed the + given value. + + @item n (check casing of entities in Standard) + If the letter n appears in the string + after @option{-gnaty} then any identifier from Standard must be cased + to match the presentation in the Ada Reference Manual (for example, + @code{Integer} and @code{ASCII.NUL}). + + @item o (check order of subprogram bodies) + If the letter o appears in the string + after @option{-gnaty} then all subprogram bodies in a given scope + (e.g. a package body) must be in alphabetical order. The ordering + rule uses normal Ada rules for comparing strings, ignoring casing + of letters, except that if there is a trailing numeric suffix, then + the value of this suffix is used in the ordering (e.g. Junk2 comes + before Junk10). + + @item p (check pragma casing) + If the letter p appears in the string after @option{-gnaty} then + pragma names must be written in mixed case, that is, the + initial letter and any letter following an underscore must be uppercase. + All other letters must be lowercase. + + @item r (check references) + If the letter r appears in the string after @option{-gnaty} + then all identifier references must be cased in the same way as the + corresponding declaration. No specific casing style is imposed on + identifiers. The only requirement is for consistency of references + with declarations. + + @item s (check separate specs) + If the letter s appears in the string after @option{-gnaty} then + separate declarations ("specs") are required for subprograms (a + body is not allowed to serve as its own declaration). The only + exception is that parameterless library level procedures are + not required to have a separate declaration. This exception covers + the most frequent form of main program procedures. + + @item t (check token spacing) + If the letter t appears in the string after @option{-gnaty} then + the following token spacing rules are enforced: + + @itemize @bullet + + @item + The keywords @code{abs} and @code{not} must be followed by a space. + + @item + The token @code{=>} must be surrounded by spaces. + + @item + The token @code{<>} must be preceded by a space or a left parenthesis. + + @item + Binary operators other than @code{**} must be surrounded by spaces. + There is no restriction on the layout of the @code{**} binary operator. + + @item + Colon must be surrounded by spaces. + + @item + Colon-equal (assignment) must be surrounded by spaces. + + @item + Comma must be the first non-blank character on the line, or be + immediately preceded by a non-blank character, and must be followed + by a space. + + @item + If the token preceding a left paren ends with a letter or digit, then + a space must separate the two tokens. + + @item + A right parenthesis must either be the first non-blank character on + a line, or it must be preceded by a non-blank character. + + @item + A semicolon must not be preceded by a space, and must not be followed by + a non-blank character. + + @item + A unary plus or minus may not be followed by a space. + + @item + A vertical bar must be surrounded by spaces. + @end itemize + + @noindent + In the above rules, appearing in column one is always permitted, that is, + counts as meeting either a requirement for a required preceding space, + or as meeting a requirement for no preceding space. + + Appearing at the end of a line is also always permitted, that is, counts + as meeting either a requirement for a following space, or as meeting + a requirement for no following space. + + @end table + + @noindent + If any of these style rules is violated, a message is generated giving + details on the violation. The initial characters of such messages are + always "(style)". Note that these messages are treated as warning + messages, so they normally do not prevent the generation of an object + file. The @option{-gnatwe} switch can be used to treat warning messages, + including style messages, as fatal errors. + + @noindent + The switch + @option{-gnaty} on its own (that is not followed by any letters or digits), + is equivalent to @code{gnaty3abcefhiklmprst}, that is all checking + options are enabled with + the exception of -gnatyo, + with an indentation level of 3. This is the standard + checking option that is used for the GNAT sources. + + @node Run-Time Checks + @subsection Run-Time Checks + @cindex Division by zero + @cindex Access before elaboration + @cindex Checks, division by zero + @cindex Checks, access before elaboration + + @noindent + If you compile with the default options, GNAT will insert many run-time + checks into the compiled code, including code that performs range + checking against constraints, but not arithmetic overflow checking for + integer operations (including division by zero) or checks for access + before elaboration on subprogram calls. All other run-time checks, as + required by the Ada 95 Reference Manual, are generated by default. + The following @code{gcc} switches refine this default behavior: + + @table @code + @item -gnatp + @cindex @option{-gnatp} (@code{gcc}) + @cindex Suppressing checks + @cindex Checks, suppressing + @findex Suppress + Suppress all run-time checks as though @code{pragma Suppress (all_checks}) + had been present in the source. Validity checks are also suppressed (in + other words @option{-gnatp} also implies @option{-gnatVn}. + Use this switch to improve the performance + of the code at the expense of safety in the presence of invalid data or + program bugs. + + @item -gnato + @cindex @option{-gnato} (@code{gcc}) + @cindex Overflow checks + @cindex Check, overflow + Enables overflow checking for integer operations. + This causes GNAT to generate slower and larger executable + programs by adding code to check for overflow (resulting in raising + @code{Constraint_Error} as required by standard Ada + semantics). These overflow checks correspond to situations in which + the true value of the result of an operation may be outside the base + range of the result type. The following example shows the distinction: + + @smallexample + X1 : Integer := Integer'Last; + X2 : Integer range 1 .. 5 := 5; + ... + X1 := X1 + 1; -- @option{-gnato} required to catch the Constraint_Error + X2 := X2 + 1; -- range check, @option{-gnato} has no effect here + @end smallexample + + @noindent + Here the first addition results in a value that is outside the base range + of Integer, and hence requires an overflow check for detection of the + constraint error. The second increment operation results in a violation + of the explicit range constraint, and such range checks are always + performed. Basically the compiler can assume that in the absence of + the @option{-gnato} switch that any value of type @code{xxx} is + in range of the base type of @code{xxx}. + + @findex Machine_Overflows + Note that the @option{-gnato} switch does not affect the code generated + for any floating-point operations; it applies only to integer + semantics). + For floating-point, GNAT has the @code{Machine_Overflows} + attribute set to @code{False} and the normal mode of operation is to + generate IEEE NaN and infinite values on overflow or invalid operations + (such as dividing 0.0 by 0.0). + + The reason that we distinguish overflow checking from other kinds of + range constraint checking is that a failure of an overflow check can + generate an incorrect value, but cannot cause erroneous behavior. This + is unlike the situation with a constraint check on an array subscript, + where failure to perform the check can result in random memory description, + or the range check on a case statement, where failure to perform the check + can cause a wild jump. + + Note again that @option{-gnato} is off by default, so overflow checking is + not performed in default mode. This means that out of the box, with the + default settings, GNAT does not do all the checks expected from the + language description in the Ada Reference Manual. If you want all constraint + checks to be performed, as described in this Manual, then you must + explicitly use the -gnato switch either on the @code{gnatmake} or + @code{gcc} command. + + @item -gnatE + @cindex @option{-gnatE} (@code{gcc}) + @cindex Elaboration checks + @cindex Check, elaboration + Enables dynamic checks for access-before-elaboration + on subprogram calls and generic instantiations. + For full details of the effect and use of this switch, + @xref{Compiling Using gcc}. + @end table + + @findex Unsuppress + @noindent + The setting of these switches only controls the default setting of the + checks. You may modify them using either @code{Suppress} (to remove + checks) or @code{Unsuppress} (to add back suppressed checks) pragmas in + the program source. + + @node Stack Overflow Checking + @subsection Stack Overflow Checking + @cindex Stack Overflow Checking + @cindex -fstack-check + + @noindent + For most operating systems, @code{gcc} does not perform stack overflow + checking by default. This means that if the main environment task or + some other task exceeds the available stack space, then unpredictable + behavior will occur. + + To activate stack checking, compile all units with the gcc option + @code{-fstack-check}. For example: + + @smallexample + gcc -c -fstack-check package1.adb + @end smallexample + + @noindent + Units compiled with this option will generate extra instructions to check + that any use of the stack (for procedure calls or for declaring local + variables in declare blocks) do not exceed the available stack space. + If the space is exceeded, then a @code{Storage_Error} exception is raised. + + For declared tasks, the stack size is always controlled by the size + given in an applicable @code{Storage_Size} pragma (or is set to + the default size if no pragma is used. + + For the environment task, the stack size depends on + system defaults and is unknown to the compiler. The stack + may even dynamically grow on some systems, precluding the + normal Ada semantics for stack overflow. In the worst case, + unbounded stack usage, causes unbounded stack expansion + resulting in the system running out of virtual memory. + + The stack checking may still work correctly if a fixed + size stack is allocated, but this cannot be guaranteed. + To ensure that a clean exception is signalled for stack + overflow, set the environment variable + @code{GNAT_STACK_LIMIT} to indicate the maximum + stack area that can be used, as in: + @cindex GNAT_STACK_LIMIT + + @smallexample + SET GNAT_STACK_LIMIT 1600 + @end smallexample + + @noindent + The limit is given in kilobytes, so the above declaration would + set the stack limit of the environment task to 1.6 megabytes. + Note that the only purpose of this usage is to limit the amount + of stack used by the environment task. If it is necessary to + increase the amount of stack for the environment task, then this + is an operating systems issue, and must be addressed with the + appropriate operating systems commands. + + @node Run-Time Control + @subsection Run-Time Control + + @table @code + @item -gnatT nnn + @cindex @option{-gnatT} (@code{gcc}) + @cindex Time Slicing + + @noindent + The @code{gnatT} switch can be used to specify the time-slicing value + to be used for task switching between equal priority tasks. The value + @code{nnn} is given in microseconds as a decimal integer. + + Setting the time-slicing value is only effective if the underlying thread + control system can accommodate time slicing. Check the documentation of + your operating system for details. Note that the time-slicing value can + also be set by use of pragma @code{Time_Slice} or by use of the + @code{t} switch in the gnatbind step. The pragma overrides a command + line argument if both are present, and the @code{t} switch for gnatbind + overrides both the pragma and the @code{gcc} command line switch. + @end table + + @node Using gcc for Syntax Checking + @subsection Using @code{gcc} for Syntax Checking + @table @code + @item -gnats + @cindex @option{-gnats} (@code{gcc}) + + @noindent + The @code{s} stands for syntax. + + Run GNAT in syntax checking only mode. For + example, the command + + @smallexample + $ gcc -c -gnats x.adb + @end smallexample + + @noindent + compiles file @file{x.adb} in syntax-check-only mode. You can check a + series of files in a single command + , and can use wild cards to specify such a group of files. + Note that you must specify the @code{-c} (compile + only) flag in addition to the @option{-gnats} flag. + . + + You may use other switches in conjunction with @option{-gnats}. In + particular, @option{-gnatl} and @option{-gnatv} are useful to control the + format of any generated error messages. + + The output is simply the error messages, if any. No object file or ALI + file is generated by a syntax-only compilation. Also, no units other + than the one specified are accessed. For example, if a unit @code{X} + @code{with}'s a unit @code{Y}, compiling unit @code{X} in syntax + check only mode does not access the source file containing unit + @code{Y}. + + @cindex Multiple units, syntax checking + Normally, GNAT allows only a single unit in a source file. However, this + restriction does not apply in syntax-check-only mode, and it is possible + to check a file containing multiple compilation units concatenated + together. This is primarily used by the @code{gnatchop} utility + (@pxref{Renaming Files Using gnatchop}). + @end table + + @node Using gcc for Semantic Checking + @subsection Using @code{gcc} for Semantic Checking + @table @code + @item -gnatc + @cindex @option{-gnatc} (@code{gcc}) + + @noindent + The @code{c} stands for check. + Causes the compiler to operate in semantic check mode, + with full checking for all illegalities specified in the + Ada 95 Reference Manual, but without generation of any object code + (no object file is generated). + + Because dependent files must be accessed, you must follow the GNAT + semantic restrictions on file structuring to operate in this mode: + + @itemize @bullet + @item + The needed source files must be accessible + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item + Each file must contain only one compilation unit. + + @item + The file name and unit name must match (@pxref{File Naming Rules}). + @end itemize + + The output consists of error messages as appropriate. No object file is + generated. An @file{ALI} file is generated for use in the context of + cross-reference tools, but this file is marked as not being suitable + for binding (since no object file is generated). + The checking corresponds exactly to the notion of + legality in the Ada 95 Reference Manual. + + Any unit can be compiled in semantics-checking-only mode, including + units that would not normally be compiled (subunits, + and specifications where a separate body is present). + @end table + + @node Compiling Ada 83 Programs + @subsection Compiling Ada 83 Programs + @table @code + @cindex Ada 83 compatibility + @item -gnat83 + @cindex @option{-gnat83} (@code{gcc}) + @cindex ACVC, Ada 83 tests + + @noindent + Although GNAT is primarily an Ada 95 compiler, it accepts this switch to + specify that an Ada 83 program is to be compiled in Ada83 mode. If you specify + this switch, GNAT rejects most Ada 95 extensions and applies Ada 83 semantics + where this can be done easily. + It is not possible to guarantee this switch does a perfect + job; for example, some subtle tests, such as are + found in earlier ACVC tests (that have been removed from the ACVC suite for Ada + 95), may not compile correctly. However, for most purposes, using + this switch should help to ensure that programs that compile correctly + under the @option{-gnat83} switch can be ported easily to an Ada 83 + compiler. This is the main use of the switch. + + With few exceptions (most notably the need to use @code{<>} on + @cindex Generic formal parameters + unconstrained generic formal parameters, the use of the new Ada 95 + keywords, and the use of packages + with optional bodies), it is not necessary to use the + @option{-gnat83} switch when compiling Ada 83 programs, because, with rare + exceptions, Ada 95 is upwardly compatible with Ada 83. This + means that a correct Ada 83 program is usually also a correct Ada 95 + program. + + @end table + + @node Character Set Control + @subsection Character Set Control + @table @code + @item -gnati@var{c} + @cindex @code{-gnati} (@code{gcc}) + + @noindent + Normally GNAT recognizes the Latin-1 character set in source program + identifiers, as described in the Ada 95 Reference Manual. + This switch causes + GNAT to recognize alternate character sets in identifiers. @var{c} is a + single character indicating the character set, as follows: + + @table @code + @item 1 + Latin-1 identifiers + + @item 2 + Latin-2 letters allowed in identifiers + + @item 3 + Latin-3 letters allowed in identifiers + + @item 4 + Latin-4 letters allowed in identifiers + + @item 5 + Latin-5 (Cyrillic) letters allowed in identifiers + + @item 9 + Latin-9 letters allowed in identifiers + + @item p + IBM PC letters (code page 437) allowed in identifiers + + @item 8 + IBM PC letters (code page 850) allowed in identifiers + + @item f + Full upper-half codes allowed in identifiers + + @item n + No upper-half codes allowed in identifiers + + @item w + Wide-character codes (that is, codes greater than 255) + allowed in identifiers + @end table + + @xref{Foreign Language Representation}, for full details on the + implementation of these character sets. + + @item -gnatW@var{e} + @cindex @code{-gnatW} (@code{gcc}) + Specify the method of encoding for wide characters. + @var{e} is one of the following: + + @table @code + + @item h + Hex encoding (brackets coding also recognized) + + @item u + Upper half encoding (brackets encoding also recognized) + + @item s + Shift/JIS encoding (brackets encoding also recognized) + + @item e + EUC encoding (brackets encoding also recognized) + + @item 8 + UTF-8 encoding (brackets encoding also recognized) + + @item b + Brackets encoding only (default value) + @end table + For full details on the these encoding + methods see @xref{Wide Character Encodings}. + Note that brackets coding is always accepted, even if one of the other + options is specified, so for example @option{-gnatW8} specifies that both + brackets and @code{UTF-8} encodings will be recognized. The units that are + with'ed directly or indirectly will be scanned using the specified + representation scheme, and so if one of the non-brackets scheme is + used, it must be used consistently throughout the program. However, + since brackets encoding is always recognized, it may be conveniently + used in standard libraries, allowing these libraries to be used with + any of the available coding schemes. + scheme. If no @option{-gnatW?} parameter is present, then the default + representation is Brackets encoding only. + + Note that the wide character representation that is specified (explicitly + or by default) for the main program also acts as the default encoding used + for Wide_Text_IO files if not specifically overridden by a WCEM form + parameter. + + @end table + @node File Naming Control + @subsection File Naming Control + + @table @code + @item -gnatk@var{n} + @cindex @option{-gnatk} (@code{gcc}) + Activates file name "krunching". @var{n}, a decimal integer in the range + 1-999, indicates the maximum allowable length of a file name (not + including the @file{.ads} or @file{.adb} extension). The default is not + to enable file name krunching. + + For the source file naming rules, @xref{File Naming Rules}. + @end table + + @node Subprogram Inlining Control + @subsection Subprogram Inlining Control + + @table @code + @item -gnatn + @cindex @option{-gnatn} (@code{gcc}) + The @code{n} here is intended to suggest the first syllable of the + word "inline". + GNAT recognizes and processes @code{Inline} pragmas. However, for the + inlining to actually occur, optimization must be enabled. To enable + inlining across unit boundaries, this is, inlining a call in one unit of + a subprogram declared in a @code{with}'ed unit, you must also specify + this switch. + In the absence of this switch, GNAT does not attempt + inlining across units and does not need to access the bodies of + subprograms for which @code{pragma Inline} is specified if they are not + in the current unit. + + If you specify this switch the compiler will access these bodies, + creating an extra source dependency for the resulting object file, and + where possible, the call will be inlined. + For further details on when inlining is possible + see @xref{Inlining of Subprograms}. + + @item -gnatN + @cindex @option{-gnatN} (@code{gcc}) + The front end inlining activated by this switch is generally more extensive, + and quite often more effective than the standard @option{-gnatn} inlining mode. + It will also generate additional dependencies. + + @end table + + @node Auxiliary Output Control + @subsection Auxiliary Output Control + + @table @code + @item -gnatt + @cindex @option{-gnatt} (@code{gcc}) + @cindex Writing internal trees + @cindex Internal trees, writing to file + Causes GNAT to write the internal tree for a unit to a file (with the + extension @file{.adt}. + This not normally required, but is used by separate analysis tools. + Typically + these tools do the necessary compilations automatically, so you should + not have to specify this switch in normal operation. + + @item -gnatu + @cindex @option{-gnatu} (@code{gcc}) + Print a list of units required by this compilation on @file{stdout}. + The listing includes all units on which the unit being compiled depends + either directly or indirectly. + + @item -pass-exit-codes + @cindex @code{-pass-exit-codes} (@code{gcc}) + If this switch is not used, the exit code returned by @code{gcc} when + compiling multiple files indicates whether all source files have + been successfully used to generate object files or not. + + When @code{-pass-exit-codes} is used, @code{gcc} exits with an extended + exit status and allows an integrated development environment to better + react to a compilation failure. Those exit status are: + + @table @asis + @item 5 + There was an error in at least one source file. + @item 3 + At least one source file did not generate an object file. + @item 2 + The compiler died unexpectedly (internal error for example). + @item 0 + An object file has been generated for every source file. + @end table + @end table + + @node Debugging Control + @subsection Debugging Control + + @table @code + @cindex Debugging options + @item -gnatd@var{x} + Activate internal debugging switches. @var{x} is a letter or digit, or + string of letters or digits, which specifies the type of debugging + outputs desired. Normally these are used only for internal development + or system debugging purposes. You can find full documentation for these + switches in the body of the @code{Debug} unit in the compiler source + file @file{debug.adb}. + + @item -gnatG + @cindex @option{-gnatG} (@code{gcc}) + This switch causes the compiler to generate auxiliary output containing + a pseudo-source listing of the generated expanded code. Like most Ada + compilers, GNAT works by first transforming the high level Ada code into + lower level constructs. For example, tasking operations are transformed + into calls to the tasking run-time routines. A unique capability of GNAT + is to list this expanded code in a form very close to normal Ada source. + This is very useful in understanding the implications of various Ada + usage on the efficiency of the generated code. There are many cases in + Ada (e.g. the use of controlled types), where simple Ada statements can + generate a lot of run-time code. By using @option{-gnatG} you can identify + these cases, and consider whether it may be desirable to modify the coding + approach to improve efficiency. + + The format of the output is very similar to standard Ada source, and is + easily understood by an Ada programmer. The following special syntactic + additions correspond to low level features used in the generated code that + do not have any exact analogies in pure Ada source form. The following + is a partial list of these special constructions. See the specification + of package @code{Sprint} in file @file{sprint.ads} for a full list. + + @table @code + @item new @var{xxx} [storage_pool = @var{yyy}] + Shows the storage pool being used for an allocator. + + @item at end @var{procedure-name}; + Shows the finalization (cleanup) procedure for a scope. + + @item (if @var{expr} then @var{expr} else @var{expr}) + Conditional expression equivalent to the @code{x?y:z} construction in C. + + @item @var{target}^(@var{source}) + A conversion with floating-point truncation instead of rounding. + + @item @var{target}?(@var{source}) + A conversion that bypasses normal Ada semantic checking. In particular + enumeration types and fixed-point types are treated simply as integers. + + @item @var{target}?^(@var{source}) + Combines the above two cases. + + @item @var{x} #/ @var{y} + @itemx @var{x} #mod @var{y} + @itemx @var{x} #* @var{y} + @itemx @var{x} #rem @var{y} + A division or multiplication of fixed-point values which are treated as + integers without any kind of scaling. + + @item free @var{expr} [storage_pool = @var{xxx}] + Shows the storage pool associated with a @code{free} statement. + + @item freeze @var{typename} [@var{actions}] + Shows the point at which @var{typename} is frozen, with possible + associated actions to be performed at the freeze point. + + @item reference @var{itype} + Reference (and hence definition) to internal type @var{itype}. + + @item @var{function-name}! (@var{arg}, @var{arg}, @var{arg}) + Intrinsic function call. + + @item @var{labelname} : label + Declaration of label @var{labelname}. + + @item @var{expr} && @var{expr} && @var{expr} ... && @var{expr} + A multiple concatenation (same effect as @var{expr} & @var{expr} & + @var{expr}, but handled more efficiently). + + @item [constraint_error] + Raise the @code{Constraint_Error} exception. + + @item @var{expression}'reference + A pointer to the result of evaluating @var{expression}. + + @item @var{target-type}!(@var{source-expression}) + An unchecked conversion of @var{source-expression} to @var{target-type}. + + @item [@var{numerator}/@var{denominator}] + Used to represent internal real literals (that) have no exact + representation in base 2-16 (for example, the result of compile time + evaluation of the expression 1.0/27.0). + + @item -gnatD + @cindex @option{-gnatD} (@code{gcc}) + This switch is used in conjunction with @option{-gnatG} to cause the expanded + source, as described above to be written to files with names + @file{xxx.dg}, where @file{xxx} is the normal file name, + for example, if the source file name is @file{hello.adb}, + then a file @file{hello.adb.dg} will be written. + The debugging information generated + by the @code{gcc} @code{-g} switch will refer to the generated + @file{xxx.dg} file. This allows you to do source level debugging using + the generated code which is sometimes useful for complex code, for example + to find out exactly which part of a complex construction raised an + exception. This switch also suppress generation of cross-reference + information (see -gnatx). + + @item -gnatC + @cindex @option{-gnatE} (@code{gcc}) + In the generated debugging information, and also in the case of long external + names, the compiler uses a compression mechanism if the name is very long. + This compression method uses a checksum, and avoids trouble on some operating + systems which have difficulty with very long names. The @option{-gnatC} switch + forces this compression approach to be used on all external names and names + in the debugging information tables. This reduces the size of the generated + executable, at the expense of making the naming scheme more complex. The + compression only affects the qualification of the name. Thus a name in + the source: + + @smallexample + Very_Long_Package.Very_Long_Inner_Package.Var + @end smallexample + + @noindent + would normally appear in these tables as: + + @smallexample + very_long_package__very_long_inner_package__var + @end smallexample + + @noindent + but if the @option{-gnatC} switch is used, then the name appears as + + @smallexample + XCb7e0c705__var + @end smallexample + + @noindent + Here b7e0c705 is a compressed encoding of the qualification prefix. + The GNAT Ada aware version of GDB understands these encoded prefixes, so if this + debugger is used, the encoding is largely hidden from the user of the compiler. + + @end table + + @item -gnatR[0|1|2|3][s] + @cindex @option{-gnatR} (@code{gcc}) + This switch controls output from the compiler of a listing showing + representation information for declared types and objects. For + @option{-gnatR0}, no information is output (equivalent to omitting + the @option{-gnatR} switch). For @option{-gnatR1} (which is the default, + so @option{-gnatR} with no parameter has the same effect), size and alignment + information is listed for declared array and record types. For + @option{-gnatR2}, size and alignment information is listed for all + expression information for values that are computed at run time for + variant records. These symbolic expressions have a mostly obvious + format with #n being used to represent the value of the n'th + discriminant. See source files @file{repinfo.ads/adb} in the + @code{GNAT} sources for full detalis on the format of @option{-gnatR3} + output. If the switch is followed by an s (e.g. @option{-gnatR2s}), then + the output is to a file with the name @file{file.rep} where + file is the name of the corresponding source file. + + @item -gnatx + @cindex @option{-gnatx} (@code{gcc}) + Normally the compiler generates full cross-referencing information in + the @file{ALI} file. This information is used by a number of tools, + including @code{gnatfind} and @code{gnatxref}. The -gnatx switch + suppresses this information. This saves some space and may slightly + speed up compilation, but means that these tools cannot be used. + @end table + + @node Units to Sources Mapping Files + @subsection Units to Sources Mapping Files + + @table @code + + @item -gnatem@var{path} + @cindex @option{-gnatem} (@code{gcc}) + A mapping file is a way to communicate to the compiler two mappings: + from unit names to file names (without any directory information) and from + file names to path names (with full directory information). These mappings + are used by the compiler to short-circuit the path search. + + A mapping file is a sequence of sets of three lines. In each set, + the first line is the unit name, in lower case, with "%s" appended for + specifications and "%b" appended for bodies; the second line is the file + name; and the third line is the path name. + + Example: + @smallexample + main%b + main.2.ada + /gnat/project1/sources/main.2.ada + @end smallexample + + When the switch @option{-gnatem} is specified, the compiler will create + in memory the two mappings from the specified file. If there is any problem + (non existent file, truncated file or duplicate entries), no mapping + will be created. + + Several @option{-gnatem} switches may be specified; however, only the last + one on the command line will be taken into account. + + When using a project file, @code{gnatmake} create a temporary mapping file + and communicates it to the compiler using this switch. + + @end table + + @node Search Paths and the Run-Time Library (RTL) + @section Search Paths and the Run-Time Library (RTL) + + @noindent + With the GNAT source-based library system, the compiler must be able to + find source files for units that are needed by the unit being compiled. + Search paths are used to guide this process. + + The compiler compiles one source file whose name must be given + explicitly on the command line. In other words, no searching is done + for this file. To find all other source files that are needed (the most + common being the specs of units), the compiler examines the following + directories, in the following order: + + @enumerate + @item + The directory containing the source file of the main unit being compiled + (the file name on the command line). + + @item + Each directory named by an @code{-I} switch given on the @code{gcc} + command line, in the order given. + + @item + @findex ADA_INCLUDE_PATH + Each of the directories listed in the value of the + @code{ADA_INCLUDE_PATH} environment variable. + Construct this value + exactly as the @code{PATH} environment variable: a list of directory + names separated by colons (semicolons when working with the NT version). + @item + The content of the "ada_source_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as the + GNAT Run Time Library (RTL) source files. + @ref{Installing an Ada Library} + @end enumerate + + @noindent + Specifying the switch @code{-I-} + inhibits the use of the directory + containing the source file named in the command line. You can still + have this directory on your search path, but in this case it must be + explicitly requested with a @code{-I} switch. + + Specifying the switch @code{-nostdinc} + inhibits the search of the default location for the GNAT Run Time + Library (RTL) source files. + + The compiler outputs its object files and ALI files in the current + working directory. + Caution: The object file can be redirected with the @code{-o} switch; + however, @code{gcc} and @code{gnat1} have not been coordinated on this + so the ALI file will not go to the right place. Therefore, you should + avoid using the @code{-o} switch. + + @findex System.IO + The packages @code{Ada}, @code{System}, and @code{Interfaces} and their + children make up the GNAT RTL, together with the simple @code{System.IO} + package used in the "Hello World" example. The sources for these units + are needed by the compiler and are kept together in one directory. Not + all of the bodies are needed, but all of the sources are kept together + anyway. In a normal installation, you need not specify these directory + names when compiling or binding. Either the environment variables or + the built-in defaults cause these files to be found. + + In addition to the language-defined hierarchies (System, Ada and + Interfaces), the GNAT distribution provides a fourth hierarchy, + consisting of child units of GNAT. This is a collection of generally + useful routines. See the GNAT Reference Manual for further details. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + + @node Order of Compilation Issues + @section Order of Compilation Issues + + @noindent + If, in our earlier example, there was a spec for the @code{hello} + procedure, it would be contained in the file @file{hello.ads}; yet this + file would not have to be explicitly compiled. This is the result of the + model we chose to implement library management. Some of the consequences + of this model are as follows: + + @itemize @bullet + @item + There is no point in compiling specs (except for package + specs with no bodies) because these are compiled as needed by clients. If + you attempt a useless compilation, you will receive an error message. + It is also useless to compile subunits because they are compiled as needed + by the parent. + + @item + There are no order of compilation requirements: performing a + compilation never obsoletes anything. The only way you can obsolete + something and require recompilations is to modify one of the + source files on which it depends. + + @item + There is no library as such, apart from the ALI files + (@pxref{The Ada Library Information Files}, for information on the format of these + files). For now we find it convenient to create separate ALI files, but + eventually the information therein may be incorporated into the object + file directly. + + @item + When you compile a unit, the source files for the specs of all units + that it @code{with}'s, all its subunits, and the bodies of any generics it + instantiates must be available (reachable by the search-paths mechanism + described above), or you will receive a fatal error message. + @end itemize + + @node Examples + @section Examples + + @noindent + The following are some typical Ada compilation command line examples: + + @table @code + @item $ gcc -c xyz.adb + Compile body in file @file{xyz.adb} with all default options. + + @item $ gcc -c -O2 -gnata xyz-def.adb + + Compile the child unit package in file @file{xyz-def.adb} with extensive + optimizations, and pragma @code{Assert}/@code{Debug} statements + enabled. + + @item $ gcc -c -gnatc abc-def.adb + Compile the subunit in file @file{abc-def.adb} in semantic-checking-only + mode. + @end table + + @node Binding Using gnatbind + @chapter Binding Using @code{gnatbind} + @findex gnatbind + + @menu + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + @end menu + + @noindent + This chapter describes the GNAT binder, @code{gnatbind}, which is used + to bind compiled GNAT objects. The @code{gnatbind} program performs + four separate functions: + + @enumerate + @item + Checks that a program is consistent, in accordance with the rules in + Chapter 10 of the Ada 95 Reference Manual. In particular, error + messages are generated if a program uses inconsistent versions of a + given unit. + + @item + Checks that an acceptable order of elaboration exists for the program + and issues an error message if it cannot find an order of elaboration + that satisfies the rules in Chapter 10 of the Ada 95 Language Manual. + + @item + Generates a main program incorporating the given elaboration order. + This program is a small Ada package (body and spec) that + must be subsequently compiled + using the GNAT compiler. The necessary compilation step is usually + performed automatically by @code{gnatlink}. The two most important + functions of this program + are to call the elaboration routines of units in an appropriate order + and to call the main program. + + @item + Determines the set of object files required by the given main program. + This information is output in the forms of comments in the generated program, + to be read by the @code{gnatlink} utility used to link the Ada application. + @end enumerate + + @node Running gnatbind + @section Running @code{gnatbind} + + @noindent + The form of the @code{gnatbind} command is + + @smallexample + $ gnatbind [@var{switches}] @var{mainprog}[.ali] [@var{switches}] + @end smallexample + + @noindent + where @var{mainprog}.adb is the Ada file containing the main program + unit body. If no switches are specified, @code{gnatbind} constructs an Ada + package in two files which names are + @file{b~@var{ada_main}.ads}, and @file{b~@var{ada_main}.adb}. + For example, if given the + parameter @samp{hello.ali}, for a main program contained in file + @file{hello.adb}, the binder output files would be @file{b~hello.ads} + and @file{b~hello.adb}. + + When doing consistency checking, the binder takes into consideration + any source files it can locate. For example, if the binder determines + that the given main program requires the package @code{Pack}, whose + @file{.ali} + file is @file{pack.ali} and whose corresponding source spec file is + @file{pack.ads}, it attempts to locate the source file @file{pack.ads} + (using the same search path conventions as previously described for the + @code{gcc} command). If it can locate this source file, it checks that + the time stamps + or source checksums of the source and its references to in @file{ali} files + match. In other words, any @file{ali} files that mentions this spec must have + resulted from compiling this version of the source file (or in the case + where the source checksums match, a version close enough that the + difference does not matter). + + @cindex Source files, use by binder + The effect of this consistency checking, which includes source files, is + that the binder ensures that the program is consistent with the latest + version of the source files that can be located at bind time. Editing a + source file without compiling files that depend on the source file cause + error messages to be generated by the binder. + + For example, suppose you have a main program @file{hello.adb} and a + package @code{P}, from file @file{p.ads} and you perform the following + steps: + + @enumerate + @item + Enter @code{gcc -c hello.adb} to compile the main program. + + @item + Enter @code{gcc -c p.ads} to compile package @code{P}. + + @item + Edit file @file{p.ads}. + + @item + Enter @code{gnatbind hello}. + @end enumerate + + At this point, the file @file{p.ali} contains an out-of-date time stamp + because the file @file{p.ads} has been edited. The attempt at binding + fails, and the binder generates the following error messages: + + @smallexample + error: "hello.adb" must be recompiled ("p.ads" has been modified) + error: "p.ads" has been modified and must be recompiled + @end smallexample + + @noindent + Now both files must be recompiled as indicated, and then the bind can + succeed, generating a main program. You need not normally be concerned + with the contents of this file, but it is similar to the following which + is the binder file generated for a simple "hello world" program. + + @smallexample + @iftex + @leftskip=0cm + @end iftex + -- The package is called Ada_Main unless this name is actually used + -- as a unit name in the partition, in which case some other unique + -- name is used. + + with System; + package ada_main is + + Elab_Final_Code : Integer; + pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code"); + + -- The main program saves the parameters (argument count, + -- argument values, environment pointer) in global variables + -- for later access by other units including + -- Ada.Command_Line. + + gnat_argc : Integer; + gnat_argv : System.Address; + gnat_envp : System.Address; + + -- The actual variables are stored in a library routine. This + -- is useful for some shared library situations, where there + -- are problems if variables are not in the library. + + pragma Import (C, gnat_argc); + pragma Import (C, gnat_argv); + pragma Import (C, gnat_envp); + + -- The exit status is similarly an external location + + gnat_exit_status : Integer; + pragma Import (C, gnat_exit_status); + + GNAT_Version : constant String := + "GNAT Version: 3.15w (20010315)"; + pragma Export (C, GNAT_Version, "__gnat_version"); + + -- This is the generated adafinal routine that performs + -- finalization at the end of execution. In the case where + -- Ada is the main program, this main program makes a call + -- to adafinal at program termination. + + procedure adafinal; + pragma Export (C, adafinal, "adafinal"); + + -- This is the generated adainit routine that performs + -- initialization at the start of execution. In the case + -- where Ada is the main program, this main program makes + -- a call to adainit at program startup. + + procedure adainit; + pragma Export (C, adainit, "adainit"); + + -- This routine is called at the start of execution. It is + -- a dummy routine that is used by the debugger to breakpoint + -- at the start of execution. + + procedure Break_Start; + pragma Import (C, Break_Start, "__gnat_break_start"); + + -- This is the actual generated main program (it would be + -- suppressed if the no main program switch were used). As + -- required by standard system conventions, this program has + -- the external name main. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer; + pragma Export (C, main, "main"); + + -- The following set of constants give the version + -- identification values for every unit in the bound + -- partition. This identification is computed from all + -- dependent semantic units, and corresponds to the + -- string that would be returned by use of the + -- Body_Version or Version attributes. + + type Version_32 is mod 2 ** 32; + u00001 : constant Version_32 := 16#7880BEB3#; + u00002 : constant Version_32 := 16#0D24CBD0#; + u00003 : constant Version_32 := 16#3283DBEB#; + u00004 : constant Version_32 := 16#2359F9ED#; + u00005 : constant Version_32 := 16#664FB847#; + u00006 : constant Version_32 := 16#68E803DF#; + u00007 : constant Version_32 := 16#5572E604#; + u00008 : constant Version_32 := 16#46B173D8#; + u00009 : constant Version_32 := 16#156A40CF#; + u00010 : constant Version_32 := 16#033DABE0#; + u00011 : constant Version_32 := 16#6AB38FEA#; + u00012 : constant Version_32 := 16#22B6217D#; + u00013 : constant Version_32 := 16#68A22947#; + u00014 : constant Version_32 := 16#18CC4A56#; + u00015 : constant Version_32 := 16#08258E1B#; + u00016 : constant Version_32 := 16#367D5222#; + u00017 : constant Version_32 := 16#20C9ECA4#; + u00018 : constant Version_32 := 16#50D32CB6#; + u00019 : constant Version_32 := 16#39A8BB77#; + u00020 : constant Version_32 := 16#5CF8FA2B#; + u00021 : constant Version_32 := 16#2F1EB794#; + u00022 : constant Version_32 := 16#31AB6444#; + u00023 : constant Version_32 := 16#1574B6E9#; + u00024 : constant Version_32 := 16#5109C189#; + u00025 : constant Version_32 := 16#56D770CD#; + u00026 : constant Version_32 := 16#02F9DE3D#; + u00027 : constant Version_32 := 16#08AB6B2C#; + u00028 : constant Version_32 := 16#3FA37670#; + u00029 : constant Version_32 := 16#476457A0#; + u00030 : constant Version_32 := 16#731E1B6E#; + u00031 : constant Version_32 := 16#23C2E789#; + u00032 : constant Version_32 := 16#0F1BD6A1#; + u00033 : constant Version_32 := 16#7C25DE96#; + u00034 : constant Version_32 := 16#39ADFFA2#; + u00035 : constant Version_32 := 16#571DE3E7#; + u00036 : constant Version_32 := 16#5EB646AB#; + u00037 : constant Version_32 := 16#4249379B#; + u00038 : constant Version_32 := 16#0357E00A#; + u00039 : constant Version_32 := 16#3784FB72#; + u00040 : constant Version_32 := 16#2E723019#; + u00041 : constant Version_32 := 16#623358EA#; + u00042 : constant Version_32 := 16#107F9465#; + u00043 : constant Version_32 := 16#6843F68A#; + u00044 : constant Version_32 := 16#63305874#; + u00045 : constant Version_32 := 16#31E56CE1#; + u00046 : constant Version_32 := 16#02917970#; + u00047 : constant Version_32 := 16#6CCBA70E#; + u00048 : constant Version_32 := 16#41CD4204#; + u00049 : constant Version_32 := 16#572E3F58#; + u00050 : constant Version_32 := 16#20729FF5#; + u00051 : constant Version_32 := 16#1D4F93E8#; + u00052 : constant Version_32 := 16#30B2EC3D#; + u00053 : constant Version_32 := 16#34054F96#; + u00054 : constant Version_32 := 16#5A199860#; + u00055 : constant Version_32 := 16#0E7F912B#; + u00056 : constant Version_32 := 16#5760634A#; + u00057 : constant Version_32 := 16#5D851835#; + + -- The following Export pragmas export the version numbers + -- with symbolic names ending in B (for body) or S + -- (for spec) so that they can be located in a link. The + -- information provided here is sufficient to track down + -- the exact versions of units used in a given build. + + pragma Export (C, u00001, "helloB"); + pragma Export (C, u00002, "system__standard_libraryB"); + pragma Export (C, u00003, "system__standard_libraryS"); + pragma Export (C, u00004, "adaS"); + pragma Export (C, u00005, "ada__text_ioB"); + pragma Export (C, u00006, "ada__text_ioS"); + pragma Export (C, u00007, "ada__exceptionsB"); + pragma Export (C, u00008, "ada__exceptionsS"); + pragma Export (C, u00009, "gnatS"); + pragma Export (C, u00010, "gnat__heap_sort_aB"); + pragma Export (C, u00011, "gnat__heap_sort_aS"); + pragma Export (C, u00012, "systemS"); + pragma Export (C, u00013, "system__exception_tableB"); + pragma Export (C, u00014, "system__exception_tableS"); + pragma Export (C, u00015, "gnat__htableB"); + pragma Export (C, u00016, "gnat__htableS"); + pragma Export (C, u00017, "system__exceptionsS"); + pragma Export (C, u00018, "system__machine_state_operationsB"); + pragma Export (C, u00019, "system__machine_state_operationsS"); + pragma Export (C, u00020, "system__machine_codeS"); + pragma Export (C, u00021, "system__storage_elementsB"); + pragma Export (C, u00022, "system__storage_elementsS"); + pragma Export (C, u00023, "system__secondary_stackB"); + pragma Export (C, u00024, "system__secondary_stackS"); + pragma Export (C, u00025, "system__parametersB"); + pragma Export (C, u00026, "system__parametersS"); + pragma Export (C, u00027, "system__soft_linksB"); + pragma Export (C, u00028, "system__soft_linksS"); + pragma Export (C, u00029, "system__stack_checkingB"); + pragma Export (C, u00030, "system__stack_checkingS"); + pragma Export (C, u00031, "system__tracebackB"); + pragma Export (C, u00032, "system__tracebackS"); + pragma Export (C, u00033, "ada__streamsS"); + pragma Export (C, u00034, "ada__tagsB"); + pragma Export (C, u00035, "ada__tagsS"); + pragma Export (C, u00036, "system__string_opsB"); + pragma Export (C, u00037, "system__string_opsS"); + pragma Export (C, u00038, "interfacesS"); + pragma Export (C, u00039, "interfaces__c_streamsB"); + pragma Export (C, u00040, "interfaces__c_streamsS"); + pragma Export (C, u00041, "system__file_ioB"); + pragma Export (C, u00042, "system__file_ioS"); + pragma Export (C, u00043, "ada__finalizationB"); + pragma Export (C, u00044, "ada__finalizationS"); + pragma Export (C, u00045, "system__finalization_rootB"); + pragma Export (C, u00046, "system__finalization_rootS"); + pragma Export (C, u00047, "system__finalization_implementationB"); + pragma Export (C, u00048, "system__finalization_implementationS"); + pragma Export (C, u00049, "system__string_ops_concat_3B"); + pragma Export (C, u00050, "system__string_ops_concat_3S"); + pragma Export (C, u00051, "system__stream_attributesB"); + pragma Export (C, u00052, "system__stream_attributesS"); + pragma Export (C, u00053, "ada__io_exceptionsS"); + pragma Export (C, u00054, "system__unsigned_typesS"); + pragma Export (C, u00055, "system__file_control_blockS"); + pragma Export (C, u00056, "ada__finalization__list_controllerB"); + pragma Export (C, u00057, "ada__finalization__list_controllerS"); + + -- BEGIN ELABORATION ORDER + -- ada (spec) + -- gnat (spec) + -- gnat.heap_sort_a (spec) + -- gnat.heap_sort_a (body) + -- gnat.htable (spec) + -- gnat.htable (body) + -- interfaces (spec) + -- system (spec) + -- system.machine_code (spec) + -- system.parameters (spec) + -- system.parameters (body) + -- interfaces.c_streams (spec) + -- interfaces.c_streams (body) + -- system.standard_library (spec) + -- ada.exceptions (spec) + -- system.exception_table (spec) + -- system.exception_table (body) + -- ada.io_exceptions (spec) + -- system.exceptions (spec) + -- system.storage_elements (spec) + -- system.storage_elements (body) + -- system.machine_state_operations (spec) + -- system.machine_state_operations (body) + -- system.secondary_stack (spec) + -- system.stack_checking (spec) + -- system.soft_links (spec) + -- system.soft_links (body) + -- system.stack_checking (body) + -- system.secondary_stack (body) + -- system.standard_library (body) + -- system.string_ops (spec) + -- system.string_ops (body) + -- ada.tags (spec) + -- ada.tags (body) + -- ada.streams (spec) + -- system.finalization_root (spec) + -- system.finalization_root (body) + -- system.string_ops_concat_3 (spec) + -- system.string_ops_concat_3 (body) + -- system.traceback (spec) + -- system.traceback (body) + -- ada.exceptions (body) + -- system.unsigned_types (spec) + -- system.stream_attributes (spec) + -- system.stream_attributes (body) + -- system.finalization_implementation (spec) + -- system.finalization_implementation (body) + -- ada.finalization (spec) + -- ada.finalization (body) + -- ada.finalization.list_controller (spec) + -- ada.finalization.list_controller (body) + -- system.file_control_block (spec) + -- system.file_io (spec) + -- system.file_io (body) + -- ada.text_io (spec) + -- ada.text_io (body) + -- hello (body) + -- END ELABORATION ORDER + + end ada_main; + + -- The following source file name pragmas allow the generated file + -- names to be unique for different main programs. They are needed + -- since the package name will always be Ada_Main. + + pragma Source_File_Name (ada_main, Spec_File_Name => "b~hello.ads"); + pragma Source_File_Name (ada_main, Body_File_Name => "b~hello.adb"); + + -- Generated package body for Ada_Main starts here + + package body ada_main is + + -- The actual finalization is performed by calling the + -- library routine in System.Standard_Library.Adafinal + + procedure Do_Finalize; + pragma Import (C, Do_Finalize, "system__standard_library__adafinal"); + + ------------- + -- adainit -- + ------------- + + @findex adainit + procedure adainit is + + -- These booleans are set to True once the associated unit has + -- been elaborated. It is also used to avoid elaborating the + -- same unit twice. + + E040 : Boolean; pragma Import (Ada, E040, "interfaces__c_streams_E"); + E008 : Boolean; pragma Import (Ada, E008, "ada__exceptions_E"); + E014 : Boolean; pragma Import (Ada, E014, "system__exception_table_E"); + E053 : Boolean; pragma Import (Ada, E053, "ada__io_exceptions_E"); + E017 : Boolean; pragma Import (Ada, E017, "system__exceptions_E"); + E024 : Boolean; pragma Import (Ada, E024, "system__secondary_stack_E"); + E030 : Boolean; pragma Import (Ada, E030, "system__stack_checking_E"); + E028 : Boolean; pragma Import (Ada, E028, "system__soft_links_E"); + E035 : Boolean; pragma Import (Ada, E035, "ada__tags_E"); + E033 : Boolean; pragma Import (Ada, E033, "ada__streams_E"); + E046 : Boolean; pragma Import (Ada, E046, "system__finalization_root_E"); + E048 : Boolean; pragma Import (Ada, E048, "system__finalization_implementation_E"); + E044 : Boolean; pragma Import (Ada, E044, "ada__finalization_E"); + E057 : Boolean; pragma Import (Ada, E057, "ada__finalization__list_controller_E"); + E055 : Boolean; pragma Import (Ada, E055, "system__file_control_block_E"); + E042 : Boolean; pragma Import (Ada, E042, "system__file_io_E"); + E006 : Boolean; pragma Import (Ada, E006, "ada__text_io_E"); + + -- Set_Globals is a library routine that stores away the + -- value of the indicated set of global values in global + -- variables within the library. + + procedure Set_Globals + (Main_Priority : Integer; + Time_Slice_Value : Integer; + WC_Encoding : Character; + Locking_Policy : Character; + Queuing_Policy : Character; + Task_Dispatching_Policy : Character; + Adafinal : System.Address; + Unreserve_All_Interrupts : Integer; + Exception_Tracebacks : Integer); + @findex __gnat_set_globals + pragma Import (C, Set_Globals, "__gnat_set_globals"); + + -- SDP_Table_Build is a library routine used to build the + -- exception tables. See unit Ada.Exceptions in files + -- a-except.ads/adb for full details of how zero cost + -- exception handling works. This procedure, the call to + -- it, and the two following tables are all omitted if the + -- build is in longjmp/setjump exception mode. + + @findex SDP_Table_Build + @findex Zero Cost Exceptions + procedure SDP_Table_Build + (SDP_Addresses : System.Address; + SDP_Count : Natural; + Elab_Addresses : System.Address; + Elab_Addr_Count : Natural); + pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build"); + + -- Table of Unit_Exception_Table addresses. Used for zero + -- cost exception handling to build the top level table. + + ST : aliased constant array (1 .. 23) of System.Address := ( + Hello'UET_Address, + Ada.Text_Io'UET_Address, + Ada.Exceptions'UET_Address, + Gnat.Heap_Sort_A'UET_Address, + System.Exception_Table'UET_Address, + System.Machine_State_Operations'UET_Address, + System.Secondary_Stack'UET_Address, + System.Parameters'UET_Address, + System.Soft_Links'UET_Address, + System.Stack_Checking'UET_Address, + System.Traceback'UET_Address, + Ada.Streams'UET_Address, + Ada.Tags'UET_Address, + System.String_Ops'UET_Address, + Interfaces.C_Streams'UET_Address, + System.File_Io'UET_Address, + Ada.Finalization'UET_Address, + System.Finalization_Root'UET_Address, + System.Finalization_Implementation'UET_Address, + System.String_Ops_Concat_3'UET_Address, + System.Stream_Attributes'UET_Address, + System.File_Control_Block'UET_Address, + Ada.Finalization.List_Controller'UET_Address); + + -- Table of addresses of elaboration routines. Used for + -- zero cost exception handling to make sure these + -- addresses are included in the top level procedure + -- address table. + + EA : aliased constant array (1 .. 23) of System.Address := ( + adainit'Code_Address, + Do_Finalize'Code_Address, + Ada.Exceptions'Elab_Spec'Address, + System.Exceptions'Elab_Spec'Address, + Interfaces.C_Streams'Elab_Spec'Address, + System.Exception_Table'Elab_Body'Address, + Ada.Io_Exceptions'Elab_Spec'Address, + System.Stack_Checking'Elab_Spec'Address, + System.Soft_Links'Elab_Body'Address, + System.Secondary_Stack'Elab_Body'Address, + Ada.Tags'Elab_Spec'Address, + Ada.Tags'Elab_Body'Address, + Ada.Streams'Elab_Spec'Address, + System.Finalization_Root'Elab_Spec'Address, + Ada.Exceptions'Elab_Body'Address, + System.Finalization_Implementation'Elab_Spec'Address, + System.Finalization_Implementation'Elab_Body'Address, + Ada.Finalization'Elab_Spec'Address, + Ada.Finalization.List_Controller'Elab_Spec'Address, + System.File_Control_Block'Elab_Spec'Address, + System.File_Io'Elab_Body'Address, + Ada.Text_Io'Elab_Spec'Address, + Ada.Text_Io'Elab_Body'Address); + + -- Start of processing for adainit + + begin + + -- Call SDP_Table_Build to build the top level procedure + -- table for zero cost exception handling (omitted in + -- longjmp/setjump mode). + + SDP_Table_Build (ST'Address, 23, EA'Address, 23); + + -- Call Set_Globals to record various information for + -- this partition. The values are derived by the binder + -- from information stored in the ali files by the compiler. + + @findex __gnat_set_globals + Set_Globals + (Main_Priority => -1, + -- Priority of main program, -1 if no pragma Priority used + + Time_Slice_Value => -1, + -- Time slice from Time_Slice pragma, -1 if none used + + WC_Encoding => 'b', + -- Wide_Character encoding used, default is brackets + + Locking_Policy => ' ', + -- Locking_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Queuing_Policy => ' ', + -- Queuing_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Task_Dispatching_Policy => ' ', + -- Task_Dispatching_Policy used, default of space means + -- not specified, otherwise first character of the + -- policy name. + + Adafinal => System.Null_Address, + -- Address of Adafinal routine, not used anymore + + Unreserve_All_Interrupts => 0, + -- Set true if pragma Unreserve_All_Interrupts was used + + Exception_Tracebacks => 0); + -- Indicates if exception tracebacks are enabled + + Elab_Final_Code := 1; + + -- Now we have the elaboration calls for all units in the partition. + -- The Elab_Spec and Elab_Body attributes generate references to the + -- implicit elaboration procedures generated by the compiler for + -- each unit that requires elaboration. + + if not E040 then + Interfaces.C_Streams'Elab_Spec; + end if; + E040 := True; + if not E008 then + Ada.Exceptions'Elab_Spec; + end if; + if not E014 then + System.Exception_Table'Elab_Body; + E014 := True; + end if; + if not E053 then + Ada.Io_Exceptions'Elab_Spec; + E053 := True; + end if; + if not E017 then + System.Exceptions'Elab_Spec; + E017 := True; + end if; + if not E030 then + System.Stack_Checking'Elab_Spec; + end if; + if not E028 then + System.Soft_Links'Elab_Body; + E028 := True; + end if; + E030 := True; + if not E024 then + System.Secondary_Stack'Elab_Body; + E024 := True; + end if; + if not E035 then + Ada.Tags'Elab_Spec; + end if; + if not E035 then + Ada.Tags'Elab_Body; + E035 := True; + end if; + if not E033 then + Ada.Streams'Elab_Spec; + E033 := True; + end if; + if not E046 then + System.Finalization_Root'Elab_Spec; + end if; + E046 := True; + if not E008 then + Ada.Exceptions'Elab_Body; + E008 := True; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Spec; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Body; + E048 := True; + end if; + if not E044 then + Ada.Finalization'Elab_Spec; + end if; + E044 := True; + if not E057 then + Ada.Finalization.List_Controller'Elab_Spec; + end if; + E057 := True; + if not E055 then + System.File_Control_Block'Elab_Spec; + E055 := True; + end if; + if not E042 then + System.File_Io'Elab_Body; + E042 := True; + end if; + if not E006 then + Ada.Text_Io'Elab_Spec; + end if; + if not E006 then + Ada.Text_Io'Elab_Body; + E006 := True; + end if; + + Elab_Final_Code := 0; + end adainit; + + -------------- + -- adafinal -- + -------------- + + @findex adafinal + procedure adafinal is + begin + Do_Finalize; + end adafinal; + + ---------- + -- main -- + ---------- + + -- main is actually a function, as in the ANSI C standard, + -- defined to return the exit status. The three parameters + -- are the argument count, argument values and environment + -- pointer. + + @findex Main Program + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer + is + -- The initialize routine performs low level system + -- initialization using a standard library routine which + -- sets up signal handling and performs any other + -- required setup. The routine can be found in file + -- a-init.c. + + @findex __gnat_initialize + procedure initialize; + pragma Import (C, initialize, "__gnat_initialize"); + + -- The finalize routine performs low level system + -- finalization using a standard library routine. The + -- routine is found in file a-final.c and in the standard + -- distribution is a dummy routine that does nothing, so + -- really this is a hook for special user finalization. + + @findex __gnat_finalize + procedure finalize; + pragma Import (C, finalize, "__gnat_finalize"); + + -- We get to the main program of the partition by using + -- pragma Import because if we try to with the unit and + -- call it Ada style, then not only do we waste time + -- recompiling it, but also, we don't really know the right + -- switches (e.g. identifier character set) to be used + -- to compile it. + + procedure Ada_Main_Program; + pragma Import (Ada, Ada_Main_Program, "_ada_hello"); + + -- Start of processing for main + + begin + -- Save global variables + + gnat_argc := argc; + gnat_argv := argv; + gnat_envp := envp; + + -- Call low level system initialization + + Initialize; + + -- Call our generated Ada initialization routine + + adainit; + + -- This is the point at which we want the debugger to get + -- control + + Break_Start; + + -- Now we call the main program of the partition + + Ada_Main_Program; + + -- Perform Ada finalization + + adafinal; + + -- Perform low level system finalization + + Finalize; + + -- Return the proper exit status + return (gnat_exit_status); + end; + + -- This section is entirely comments, so it has no effect on the + -- compilation of the Ada_Main package. It provides the list of + -- object files and linker options, as well as some standard + -- libraries needed for the link. The gnatlink utility parses + -- this b~hello.adb file to read these comment lines to generate + -- the appropriate command line arguments for the call to the + -- system linker. The BEGIN/END lines are used for sentinels for + -- this parsing operation. + + -- The exact file names will of course depend on the environment, + -- host/target and location of files on the host system. + + @findex Object file list + -- BEGIN Object file/option list + -- ./hello.o + -- -L./ + -- -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/ + -- /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a + -- END Object file/option list + + end ada_main; + + @end smallexample + + @noindent + The Ada code in the above example is exactly what is generated by the + binder. We have added comments to more clearly indicate the function + of each part of the generated @code{Ada_Main} package. + + The code is standard Ada in all respects, and can be processed by any + tools that handle Ada. In particular, it is possible to use the debugger + in Ada mode to debug the generated Ada_Main package. For example, suppose + that for reasons that you do not understand, your program is blowing up + during elaboration of the body of @code{Ada.Text_IO}. To chase this bug + down, you can place a breakpoint on the call: + + @smallexample + Ada.Text_Io'Elab_Body; + @end smallexample + + @noindent + and trace the elaboration routine for this package to find out where + the problem might be (more usually of course you would be debugging + elaboration code in your own application). + + @node Generating the Binder Program in C + @section Generating the Binder Program in C + @noindent + In most normal usage, the default mode of @code{gnatbind} which is to + generate the main package in Ada, as described in the previous section. + In particular, this means that any Ada programmer can read and understand + the generated main program. It can also be debugged just like any other + Ada code provided the @code{-g} switch is used for @code{gnatbind} + and @code{gnatlink}. + + However for some purposes it may be convenient to generate the main + program in C rather than Ada. This may for example be helpful when you + are generating a mixed language program with the main program in C. The + GNAT compiler itself is an example. The use of the @code{-C} switch + for both @code{gnatbind} and @code{gnatlink} will cause the program to + be generated in C (and compiled using the gnu C compiler). The + following shows the C code generated for the same "Hello World" + program: + + @smallexample + + #ifdef __STDC__ + #define PARAMS(paramlist) paramlist + #else + #define PARAMS(paramlist) () + #endif + + extern void __gnat_set_globals + PARAMS ((int, int, int, int, int, int, + void (*) PARAMS ((void)), int, int)); + extern void adafinal PARAMS ((void)); + extern void adainit PARAMS ((void)); + extern void system__standard_library__adafinal PARAMS ((void)); + extern int main PARAMS ((int, char **, char **)); + extern void exit PARAMS ((int)); + extern void __gnat_break_start PARAMS ((void)); + extern void _ada_hello PARAMS ((void)); + extern void __gnat_initialize PARAMS ((void)); + extern void __gnat_finalize PARAMS ((void)); + + extern void ada__exceptions___elabs PARAMS ((void)); + extern void system__exceptions___elabs PARAMS ((void)); + extern void interfaces__c_streams___elabs PARAMS ((void)); + extern void system__exception_table___elabb PARAMS ((void)); + extern void ada__io_exceptions___elabs PARAMS ((void)); + extern void system__stack_checking___elabs PARAMS ((void)); + extern void system__soft_links___elabb PARAMS ((void)); + extern void system__secondary_stack___elabb PARAMS ((void)); + extern void ada__tags___elabs PARAMS ((void)); + extern void ada__tags___elabb PARAMS ((void)); + extern void ada__streams___elabs PARAMS ((void)); + extern void system__finalization_root___elabs PARAMS ((void)); + extern void ada__exceptions___elabb PARAMS ((void)); + extern void system__finalization_implementation___elabs PARAMS ((void)); + extern void system__finalization_implementation___elabb PARAMS ((void)); + extern void ada__finalization___elabs PARAMS ((void)); + extern void ada__finalization__list_controller___elabs PARAMS ((void)); + extern void system__file_control_block___elabs PARAMS ((void)); + extern void system__file_io___elabb PARAMS ((void)); + extern void ada__text_io___elabs PARAMS ((void)); + extern void ada__text_io___elabb PARAMS ((void)); + + extern int __gnat_inside_elab_final_code; + + extern int gnat_argc; + extern char **gnat_argv; + extern char **gnat_envp; + extern int gnat_exit_status; + + char __gnat_version[] = "GNAT Version: 3.15w (20010315)"; + void adafinal () @{ + system__standard_library__adafinal (); + @} + + void adainit () + @{ + extern char ada__exceptions_E; + extern char system__exceptions_E; + extern char interfaces__c_streams_E; + extern char system__exception_table_E; + extern char ada__io_exceptions_E; + extern char system__secondary_stack_E; + extern char system__stack_checking_E; + extern char system__soft_links_E; + extern char ada__tags_E; + extern char ada__streams_E; + extern char system__finalization_root_E; + extern char system__finalization_implementation_E; + extern char ada__finalization_E; + extern char ada__finalization__list_controller_E; + extern char system__file_control_block_E; + extern char system__file_io_E; + extern char ada__text_io_E; + + extern void *__gnat_hello__SDP; + extern void *__gnat_ada__text_io__SDP; + extern void *__gnat_ada__exceptions__SDP; + extern void *__gnat_gnat__heap_sort_a__SDP; + extern void *__gnat_system__exception_table__SDP; + extern void *__gnat_system__machine_state_operations__SDP; + extern void *__gnat_system__secondary_stack__SDP; + extern void *__gnat_system__parameters__SDP; + extern void *__gnat_system__soft_links__SDP; + extern void *__gnat_system__stack_checking__SDP; + extern void *__gnat_system__traceback__SDP; + extern void *__gnat_ada__streams__SDP; + extern void *__gnat_ada__tags__SDP; + extern void *__gnat_system__string_ops__SDP; + extern void *__gnat_interfaces__c_streams__SDP; + extern void *__gnat_system__file_io__SDP; + extern void *__gnat_ada__finalization__SDP; + extern void *__gnat_system__finalization_root__SDP; + extern void *__gnat_system__finalization_implementation__SDP; + extern void *__gnat_system__string_ops_concat_3__SDP; + extern void *__gnat_system__stream_attributes__SDP; + extern void *__gnat_system__file_control_block__SDP; + extern void *__gnat_ada__finalization__list_controller__SDP; + + void **st[23] = @{ + &__gnat_hello__SDP, + &__gnat_ada__text_io__SDP, + &__gnat_ada__exceptions__SDP, + &__gnat_gnat__heap_sort_a__SDP, + &__gnat_system__exception_table__SDP, + &__gnat_system__machine_state_operations__SDP, + &__gnat_system__secondary_stack__SDP, + &__gnat_system__parameters__SDP, + &__gnat_system__soft_links__SDP, + &__gnat_system__stack_checking__SDP, + &__gnat_system__traceback__SDP, + &__gnat_ada__streams__SDP, + &__gnat_ada__tags__SDP, + &__gnat_system__string_ops__SDP, + &__gnat_interfaces__c_streams__SDP, + &__gnat_system__file_io__SDP, + &__gnat_ada__finalization__SDP, + &__gnat_system__finalization_root__SDP, + &__gnat_system__finalization_implementation__SDP, + &__gnat_system__string_ops_concat_3__SDP, + &__gnat_system__stream_attributes__SDP, + &__gnat_system__file_control_block__SDP, + &__gnat_ada__finalization__list_controller__SDP@}; + + extern void ada__exceptions___elabs (); + extern void system__exceptions___elabs (); + extern void interfaces__c_streams___elabs (); + extern void system__exception_table___elabb (); + extern void ada__io_exceptions___elabs (); + extern void system__stack_checking___elabs (); + extern void system__soft_links___elabb (); + extern void system__secondary_stack___elabb (); + extern void ada__tags___elabs (); + extern void ada__tags___elabb (); + extern void ada__streams___elabs (); + extern void system__finalization_root___elabs (); + extern void ada__exceptions___elabb (); + extern void system__finalization_implementation___elabs (); + extern void system__finalization_implementation___elabb (); + extern void ada__finalization___elabs (); + extern void ada__finalization__list_controller___elabs (); + extern void system__file_control_block___elabs (); + extern void system__file_io___elabb (); + extern void ada__text_io___elabs (); + extern void ada__text_io___elabb (); + + void (*ea[23]) () = @{ + adainit, + system__standard_library__adafinal, + ada__exceptions___elabs, + system__exceptions___elabs, + interfaces__c_streams___elabs, + system__exception_table___elabb, + ada__io_exceptions___elabs, + system__stack_checking___elabs, + system__soft_links___elabb, + system__secondary_stack___elabb, + ada__tags___elabs, + ada__tags___elabb, + ada__streams___elabs, + system__finalization_root___elabs, + ada__exceptions___elabb, + system__finalization_implementation___elabs, + system__finalization_implementation___elabb, + ada__finalization___elabs, + ada__finalization__list_controller___elabs, + system__file_control_block___elabs, + system__file_io___elabb, + ada__text_io___elabs, + ada__text_io___elabb@}; + + __gnat_SDP_Table_Build (&st, 23, ea, 23); + __gnat_set_globals ( + -1, /* Main_Priority */ + -1, /* Time_Slice_Value */ + 'b', /* WC_Encoding */ + ' ', /* Locking_Policy */ + ' ', /* Queuing_Policy */ + ' ', /* Tasking_Dispatching_Policy */ + 0, /* Finalization routine address, not used anymore */ + 0, /* Unreserve_All_Interrupts */ + 0); /* Exception_Tracebacks */ + + __gnat_inside_elab_final_code = 1; + + if (ada__exceptions_E == 0) @{ + ada__exceptions___elabs (); + @} + if (system__exceptions_E == 0) @{ + system__exceptions___elabs (); + system__exceptions_E++; + @} + if (interfaces__c_streams_E == 0) @{ + interfaces__c_streams___elabs (); + @} + interfaces__c_streams_E = 1; + if (system__exception_table_E == 0) @{ + system__exception_table___elabb (); + system__exception_table_E++; + @} + if (ada__io_exceptions_E == 0) @{ + ada__io_exceptions___elabs (); + ada__io_exceptions_E++; + @} + if (system__stack_checking_E == 0) @{ + system__stack_checking___elabs (); + @} + if (system__soft_links_E == 0) @{ + system__soft_links___elabb (); + system__soft_links_E++; + @} + system__stack_checking_E = 1; + if (system__secondary_stack_E == 0) @{ + system__secondary_stack___elabb (); + system__secondary_stack_E++; + @} + if (ada__tags_E == 0) @{ + ada__tags___elabs (); + @} + if (ada__tags_E == 0) @{ + ada__tags___elabb (); + ada__tags_E++; + @} + if (ada__streams_E == 0) @{ + ada__streams___elabs (); + ada__streams_E++; + @} + if (system__finalization_root_E == 0) @{ + system__finalization_root___elabs (); + @} + system__finalization_root_E = 1; + if (ada__exceptions_E == 0) @{ + ada__exceptions___elabb (); + ada__exceptions_E++; + @} + if (system__finalization_implementation_E == 0) @{ + system__finalization_implementation___elabs (); + @} + if (system__finalization_implementation_E == 0) @{ + system__finalization_implementation___elabb (); + system__finalization_implementation_E++; + @} + if (ada__finalization_E == 0) @{ + ada__finalization___elabs (); + @} + ada__finalization_E = 1; + if (ada__finalization__list_controller_E == 0) @{ + ada__finalization__list_controller___elabs (); + @} + ada__finalization__list_controller_E = 1; + if (system__file_control_block_E == 0) @{ + system__file_control_block___elabs (); + system__file_control_block_E++; + @} + if (system__file_io_E == 0) @{ + system__file_io___elabb (); + system__file_io_E++; + @} + if (ada__text_io_E == 0) @{ + ada__text_io___elabs (); + @} + if (ada__text_io_E == 0) @{ + ada__text_io___elabb (); + ada__text_io_E++; + @} + + __gnat_inside_elab_final_code = 0; + @} + int main (argc, argv, envp) + int argc; + char **argv; + char **envp; + @{ + gnat_argc = argc; + gnat_argv = argv; + gnat_envp = envp; + + __gnat_initialize (); + adainit (); + __gnat_break_start (); + + _ada_hello (); + + system__standard_library__adafinal (); + __gnat_finalize (); + exit (gnat_exit_status); + @} + unsigned helloB = 0x7880BEB3; + unsigned system__standard_libraryB = 0x0D24CBD0; + unsigned system__standard_libraryS = 0x3283DBEB; + unsigned adaS = 0x2359F9ED; + unsigned ada__text_ioB = 0x47C85FC4; + unsigned ada__text_ioS = 0x496FE45C; + unsigned ada__exceptionsB = 0x74F50187; + unsigned ada__exceptionsS = 0x6736945B; + unsigned gnatS = 0x156A40CF; + unsigned gnat__heap_sort_aB = 0x033DABE0; + unsigned gnat__heap_sort_aS = 0x6AB38FEA; + unsigned systemS = 0x0331C6FE; + unsigned system__exceptionsS = 0x20C9ECA4; + unsigned system__exception_tableB = 0x68A22947; + unsigned system__exception_tableS = 0x394BADD5; + unsigned gnat__htableB = 0x08258E1B; + unsigned gnat__htableS = 0x367D5222; + unsigned system__machine_state_operationsB = 0x4F3B7492; + unsigned system__machine_state_operationsS = 0x182F5CF4; + unsigned system__storage_elementsB = 0x2F1EB794; + unsigned system__storage_elementsS = 0x102C83C7; + unsigned system__secondary_stackB = 0x1574B6E9; + unsigned system__secondary_stackS = 0x708E260A; + unsigned system__parametersB = 0x56D770CD; + unsigned system__parametersS = 0x237E39BE; + unsigned system__soft_linksB = 0x08AB6B2C; + unsigned system__soft_linksS = 0x1E2491F3; + unsigned system__stack_checkingB = 0x476457A0; + unsigned system__stack_checkingS = 0x5299FCED; + unsigned system__tracebackB = 0x2971EBDE; + unsigned system__tracebackS = 0x2E9C3122; + unsigned ada__streamsS = 0x7C25DE96; + unsigned ada__tagsB = 0x39ADFFA2; + unsigned ada__tagsS = 0x769A0464; + unsigned system__string_opsB = 0x5EB646AB; + unsigned system__string_opsS = 0x63CED018; + unsigned interfacesS = 0x0357E00A; + unsigned interfaces__c_streamsB = 0x3784FB72; + unsigned interfaces__c_streamsS = 0x2E723019; + unsigned system__file_ioB = 0x623358EA; + unsigned system__file_ioS = 0x31F873E6; + unsigned ada__finalizationB = 0x6843F68A; + unsigned ada__finalizationS = 0x63305874; + unsigned system__finalization_rootB = 0x31E56CE1; + unsigned system__finalization_rootS = 0x23169EF3; + unsigned system__finalization_implementationB = 0x6CCBA70E; + unsigned system__finalization_implementationS = 0x604AA587; + unsigned system__string_ops_concat_3B = 0x572E3F58; + unsigned system__string_ops_concat_3S = 0x01F57876; + unsigned system__stream_attributesB = 0x1D4F93E8; + unsigned system__stream_attributesS = 0x30B2EC3D; + unsigned ada__io_exceptionsS = 0x34054F96; + unsigned system__unsigned_typesS = 0x7B9E7FE3; + unsigned system__file_control_blockS = 0x2FF876A8; + unsigned ada__finalization__list_controllerB = 0x5760634A; + unsigned ada__finalization__list_controllerS = 0x5D851835; + + /* BEGIN ELABORATION ORDER + ada (spec) + gnat (spec) + gnat.heap_sort_a (spec) + gnat.htable (spec) + gnat.htable (body) + interfaces (spec) + system (spec) + system.parameters (spec) + system.standard_library (spec) + ada.exceptions (spec) + system.exceptions (spec) + system.parameters (body) + gnat.heap_sort_a (body) + interfaces.c_streams (spec) + interfaces.c_streams (body) + system.exception_table (spec) + system.exception_table (body) + ada.io_exceptions (spec) + system.storage_elements (spec) + system.storage_elements (body) + system.machine_state_operations (spec) + system.machine_state_operations (body) + system.secondary_stack (spec) + system.stack_checking (spec) + system.soft_links (spec) + system.soft_links (body) + system.stack_checking (body) + system.secondary_stack (body) + system.standard_library (body) + system.string_ops (spec) + system.string_ops (body) + ada.tags (spec) + ada.tags (body) + ada.streams (spec) + system.finalization_root (spec) + system.finalization_root (body) + system.string_ops_concat_3 (spec) + system.string_ops_concat_3 (body) + system.traceback (spec) + system.traceback (body) + ada.exceptions (body) + system.unsigned_types (spec) + system.stream_attributes (spec) + system.stream_attributes (body) + system.finalization_implementation (spec) + system.finalization_implementation (body) + ada.finalization (spec) + ada.finalization (body) + ada.finalization.list_controller (spec) + ada.finalization.list_controller (body) + system.file_control_block (spec) + system.file_io (spec) + system.file_io (body) + ada.text_io (spec) + ada.text_io (body) + hello (body) + END ELABORATION ORDER */ + + /* BEGIN Object file/option list + ./hello.o + -L./ + -L/usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/ + /usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/libgnat.a + -lexc + END Object file/option list */ + + @end smallexample + + @noindent + Here again, the C code is exactly what is generated by the binder. The + functions of the various parts of this code correspond in an obvious + manner with the commented Ada code shown in the example in the previous + section. + + @node Consistency-Checking Modes + @section Consistency-Checking Modes + + @noindent + As described in the previous section, by default @code{gnatbind} checks + that object files are consistent with one another and are consistent + with any source files it can locate. The following switches control binder + access to sources. + + @table @code + @item -s + @cindex @code{-s} (@code{gnatbind}) + Require source files to be present. In this mode, the binder must be + able to locate all source files that are referenced, in order to check + their consistency. In normal mode, if a source file cannot be located it + is simply ignored. If you specify this switch, a missing source + file is an error. + + @item -x + @cindex @code{-x} (@code{gnatbind}) + Exclude source files. In this mode, the binder only checks that ALI + files are consistent with one another. Source files are not accessed. + The binder runs faster in this mode, and there is still a guarantee that + the resulting program is self-consistent. + If a source file has been edited since it was last compiled, and you + specify this switch, the binder will not detect that the object + file is out of date with respect to the source file. Note that this is the + mode that is automatically used by @code{gnatmake} because in this + case the checking against sources has already been performed by + @code{gnatmake} in the course of compilation (i.e. before binding). + + @end table + + @node Binder Error Message Control + @section Binder Error Message Control + + @noindent + The following switches provide control over the generation of error + messages from the binder: + + @table @code + @item -v + @cindex @code{-v} (@code{gnatbind}) + Verbose mode. In the normal mode, brief error messages are generated to + @file{stderr}. If this switch is present, a header is written + to @file{stdout} and any error messages are directed to @file{stdout}. + All that is written to @file{stderr} is a brief summary message. + + @item -b + @cindex @code{-b} (@code{gnatbind}) + Generate brief error messages to @file{stderr} even if verbose mode is + specified. This is relevant only when used with the + @code{-v} switch. + + @item -m@var{n} + @cindex @code{-m} (@code{gnatbind}) + Limits the number of error messages to @var{n}, a decimal integer in the + range 1-999. The binder terminates immediately if this limit is reached. + + @item -M@var{xxx} + @cindex @code{-M} (@code{gnatbind}) + Renames the generated main program from @code{main} to @code{xxx}. + This is useful in the case of some cross-building environments, where + the actual main program is separate from the one generated + by @code{gnatbind}. + + @item -ws + @cindex @code{-ws} (@code{gnatbind}) + @cindex Warnings + Suppress all warning messages. + + @item -we + @cindex @code{-we} (@code{gnatbind}) + Treat any warning messages as fatal errors. + + + @item -t + @cindex @code{-t} (@code{gnatbind}) + @cindex Time stamp checks, in binder + @cindex Binder consistency checks + @cindex Consistency checks, in binder + The binder performs a number of consistency checks including: + + @itemize @bullet + @item + Check that time stamps of a given source unit are consistent + @item + Check that checksums of a given source unit are consistent + @item + Check that consistent versions of @code{GNAT} were used for compilation + @item + Check consistency of configuration pragmas as required + @end itemize + + @noindent + Normally failure of such checks, in accordance with the consistency + requirements of the Ada Reference Manual, causes error messages to be + generated which abort the binder and prevent the output of a binder + file and subsequent link to obtain an executable. + + The @code{-t} switch converts these error messages + into warnings, so that + binding and linking can continue to completion even in the presence of such + errors. The result may be a failed link (due to missing symbols), or a + non-functional executable which has undefined semantics. + @emph{This means that + @code{-t} should be used only in unusual situations, + with extreme care.} + @end table + + @node Elaboration Control + @section Elaboration Control + + @noindent + The following switches provide additional control over the elaboration + order. For full details see @xref{Elaboration Order Handling in GNAT}. + + @table @code + @item -p + @cindex @code{-h} (@code{gnatbind}) + Normally the binder attempts to choose an elaboration order that is + likely to minimize the likelihood of an elaboration order error resulting + in raising a @code{Program_Error} exception. This switch reverses the + action of the binder, and requests that it deliberately choose an order + that is likely to maximize the likelihood of an elaboration error. + This is useful in ensuring portability and avoiding dependence on + accidental fortuitous elaboration ordering. + + Normally it only makes sense to use the @code{-p} switch if dynamic + elaboration checking is used (@option{-gnatE} switch used for compilation). + This is because in the default static elaboration mode, all necessary + @code{Elaborate_All} pragmas are implicitly inserted. These implicit + pragmas are still respected by the binder in @code{-p} mode, so a + safe elaboration order is assured. + @end table + + @node Output Control + @section Output Control + + @noindent + The following switches allow additional control over the output + generated by the binder. + + @table @code + + @item -A + @cindex @code{-A} (@code{gnatbind}) + Generate binder program in Ada (default). The binder program is named + @file{b~@var{mainprog}.adb} by default. This can be changed with + @code{-o} @code{gnatbind} option. + + @item -c + @cindex @code{-c} (@code{gnatbind}) + Check only. Do not generate the binder output file. In this mode the + binder performs all error checks but does not generate an output file. + + @item -C + @cindex @code{-C} (@code{gnatbind}) + Generate binder program in C. The binder program is named + @file{b_@var{mainprog}.c}. This can be changed with @code{-o} @code{gnatbind} + option. + + @item -e + @cindex @code{-e} (@code{gnatbind}) + Output complete list of elaboration-order dependencies, showing the + reason for each dependency. This output can be rather extensive but may + be useful in diagnosing problems with elaboration order. The output is + written to @file{stdout}. + + @item -h + @cindex @code{-h} (@code{gnatbind}) + Output usage information. The output is written to @file{stdout}. + + @item -K + @cindex @code{-K} (@code{gnatbind}) + Output linker options to @file{stdout}. Includes library search paths, + contents of pragmas Ident and Linker_Options, and libraries added + by @code{gnatbind}. + + @item -l + @cindex @code{-l} (@code{gnatbind}) + Output chosen elaboration order. The output is written to @file{stdout}. + + @item -O + @cindex @code{-O} (@code{gnatbind}) + Output full names of all the object files that must be linked to provide + the Ada component of the program. The output is written to @file{stdout}. + This list includes the files explicitly supplied and referenced by the user + as well as implicitly referenced run-time unit files. The latter are + omitted if the corresponding units reside in shared libraries. The + directory names for the run-time units depend on the system configuration. + + @item -o @var{file} + @cindex @code{-o} (@code{gnatbind}) + Set name of output file to @var{file} instead of the normal + @file{b~@var{mainprog}.adb} default. Note that @var{file} denote the Ada + binder generated body filename. In C mode you would normally give + @var{file} an extension of @file{.c} because it will be a C source program. + Note that if this option is used, then linking must be done manually. + It is not possible to use gnatlink in this case, since it cannot locate + the binder file. + + @item -r + @cindex @code{-r} (@code{gnatbind}) + Generate list of @code{pragma Rerstrictions} that could be applied to + the current unit. This is useful for code audit purposes, and also may + be used to improve code generation in some cases. + + @end table + + @node Binding with Non-Ada Main Programs + @section Binding with Non-Ada Main Programs + + @noindent + In our description so far we have assumed that the main + program is in Ada, and that the task of the binder is to generate a + corresponding function @code{main} that invokes this Ada main + program. GNAT also supports the building of executable programs where + the main program is not in Ada, but some of the called routines are + written in Ada and compiled using GNAT (@pxref{Mixed Language Programming}). + The following switch is used in this situation: + + @table @code + @item -n + @cindex @code{-n} (@code{gnatbind}) + No main program. The main program is not in Ada. + @end table + + @noindent + In this case, most of the functions of the binder are still required, + but instead of generating a main program, the binder generates a file + containing the following callable routines: + + @table @code + @item adainit + @findex adainit + You must call this routine to initialize the Ada part of the program by + calling the necessary elaboration routines. A call to @code{adainit} is + required before the first call to an Ada subprogram. + + Note that it is assumed that the basic execution environment must be setup + to be appropriate for Ada execution at the point where the first Ada + subprogram is called. In particular, if the Ada code will do any + floating-point operations, then the FPU must be setup in an appropriate + manner. For the case of the x86, for example, full precision mode is + required. The procedure GNAT.Float_Control.Reset may be used to ensure + that the FPU is in the right state. + + @item adafinal + @findex adafinal + You must call this routine to perform any library-level finalization + required by the Ada subprograms. A call to @code{adafinal} is required + after the last call to an Ada subprogram, and before the program + terminates. + @end table + + @noindent + If the @code{-n} switch + @cindex Binder, multiple input files + is given, more than one ALI file may appear on + the command line for @code{gnatbind}. The normal @dfn{closure} + calculation is performed for each of the specified units. Calculating + the closure means finding out the set of units involved by tracing + @code{with} references. The reason it is necessary to be able to + specify more than one ALI file is that a given program may invoke two or + more quite separate groups of Ada units. + + The binder takes the name of its output file from the last specified ALI + file, unless overridden by the use of the @code{-o file}. + The output is an Ada unit in source form that can + be compiled with GNAT unless the -C switch is used in which case the + output is a C source file, which must be compiled using the C compiler. + This compilation occurs automatically as part of the @code{gnatlink} + processing. + + Currently the GNAT run time requires a FPU using 80 bits mode + precision. Under targets where this is not the default it is required to + call GNAT.Float_Control.Reset before using floating point numbers (this + include float computation, float input and output) in the Ada code. A + side effect is that this could be the wrong mode for the foreign code + where floating point computation could be broken after this call. + + @node Binding Programs with No Main Subprogram + @section Binding Programs with No Main Subprogram + + @noindent + It is possible to have an Ada program which does not have a main + subprogram. This program will call the elaboration routines of all the + packages, then the finalization routines. + + The following switch is used to bind programs organized in this manner: + + @table @code + @item -z + @cindex @code{-z} (@code{gnatbind}) + Normally the binder checks that the unit name given on the command line + corresponds to a suitable main subprogram. When this switch is used, + a list of ALI files can be given, and the execution of the program + consists of elaboration of these units in an appropriate order. + @end table + + @node Summary of Binder Switches + @section Summary of Binder Switches + + @noindent + The following are the switches available with @code{gnatbind}: + + @table @code + @item -aO + Specify directory to be searched for ALI files. + + @item -aI + Specify directory to be searched for source file. + + @item -A + Generate binder program in Ada (default) + + @item -b + Generate brief messages to @file{stderr} even if verbose mode set. + + @item -c + Check only, no generation of binder output file. + + @item -C + Generate binder program in C + + @item -e + Output complete list of elaboration-order dependencies. + + @item -E + Store tracebacks in exception occurrences when the target supports it. + This is the default with the zero cost exception mechanism. + This option is currently supported on the following targets: + all x86 ports, Solaris, Windows, HP-UX, AIX, PowerPC VxWorks and Alpha VxWorks. + See also the packages @code{GNAT.Traceback} and + @code{GNAT.Traceback.Symbolic} for more information. + Note that on x86 ports, you must not use @code{-fomit-frame-pointer} + @code{gcc} option. + + @item -h + Output usage (help) information + + @item -I + Specify directory to be searched for source and ALI files. + + @item -I- + Do not look for sources in the current directory where @code{gnatbind} was + invoked, and do not look for ALI files in the directory containing the + ALI file named in the @code{gnatbind} command line. + + @item -l + Output chosen elaboration order. + + @item -Lxxx + Binds the units for library building. In this case the adainit and + adafinal procedures (See @pxref{Binding with Non-Ada Main Programs}) + are renamed to xxxinit and xxxfinal. Implies -n. + See @pxref{GNAT and Libraries} for more details. + + @item -Mxyz + Rename generated main program from main to xyz + + @item -m@var{n} + Limit number of detected errors to @var{n} (1-999). + + @item -n + No main program. + + @item -nostdinc + Do not look for sources in the system default directory. + + @item -nostdlib + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatbind}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -o @var{file} + Name the output file @var{file} (default is @file{b~@var{xxx}.adb}). + Note that if this option is used, then linking must be done manually, + gnatlink cannot be used. + + @item -O + Output object list. + + @item -p + Pessimistic (worst-case) elaboration order + + @item -s + Require all source files to be present. + + @item -static + Link against a static GNAT run time. + + @item -shared + Link against a shared GNAT run time when available. + + @item -t + Tolerate time stamp and other consistency errors + + @item -T@var{n} + Set the time slice value to n microseconds. A value of zero means no time + slicing and also indicates to the tasking run time to match as close as + possible to the annex D requirements of the RM. + + @item -v + Verbose mode. Write error messages, header, summary output to + @file{stdout}. + + @item -w@var{x} + Warning mode (@var{x}=s/e for suppress/treat as error) + + + @item -x + Exclude source files (check object consistency only). + + + @item -z + No main subprogram. + + @end table + + You may obtain this listing by running the program @code{gnatbind} with + no arguments. + + @node Command-Line Access + @section Command-Line Access + + @noindent + The package @code{Ada.Command_Line} provides access to the command-line + arguments and program name. In order for this interface to operate + correctly, the two variables + + @smallexample + @group + @cartouche + int gnat_argc; + char **gnat_argv; + @end cartouche + @end group + @end smallexample + + @noindent + @findex gnat_argv + @findex gnat_argc + are declared in one of the GNAT library routines. These variables must + be set from the actual @code{argc} and @code{argv} values passed to the + main program. With no @code{n} present, @code{gnatbind} + generates the C main program to automatically set these variables. + If the @code{n} switch is used, there is no automatic way to + set these variables. If they are not set, the procedures in + @code{Ada.Command_Line} will not be available, and any attempt to use + them will raise @code{Constraint_Error}. If command line access is + required, your main program must set @code{gnat_argc} and + @code{gnat_argv} from the @code{argc} and @code{argv} values passed to + it. + + @node Search Paths for gnatbind + @section Search Paths for @code{gnatbind} + + @noindent + The binder takes the name of an ALI file as its argument and needs to + locate source files as well as other ALI files to verify object consistency. + + For source files, it follows exactly the same search rules as @code{gcc} + (@pxref{Search Paths and the Run-Time Library (RTL)}). For ALI files the + directories searched are: + + @enumerate + @item + The directory containing the ALI file named in the command line, unless + the switch @code{-I-} is specified. + + @item + All directories specified by @code{-I} + switches on the @code{gnatbind} + command line, in the order given. + + @item + @findex ADA_OBJECTS_PATH + Each of the directories listed in the value of the + @code{ADA_OBJECTS_PATH} environment variable. + Construct this value + exactly as the @code{PATH} environment variable: a list of directory + names separated by colons (semicolons when working with the NT version + of GNAT). + + @item + The content of the "ada_object_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as the + GNAT Run Time Library (RTL) unless the switch @code{-nostdlib} is + specified. + @ref{Installing an Ada Library} + @end enumerate + + @noindent + In the binder the switch @code{-I} + is used to specify both source and + library file paths. Use @code{-aI} + instead if you want to specify + source paths only, and @code{-aO} + if you want to specify library paths + only. This means that for the binder + @code{-I}@var{dir} is equivalent to + @code{-aI}@var{dir} + @code{-aO}@var{dir}. + The binder generates the bind file (a C language source file) in the + current working directory. + + @findex Ada + @findex System + @findex Interfaces + @findex GNAT + The packages @code{Ada}, @code{System}, and @code{Interfaces} and their + children make up the GNAT Run-Time Library, together with the package + GNAT and its children, which contain a set of useful additional + library functions provided by GNAT. The sources for these units are + needed by the compiler and are kept together in one directory. The ALI + files and object files generated by compiling the RTL are needed by the + binder and the linker and are kept together in one directory, typically + different from the directory containing the sources. In a normal + installation, you need not specify these directory names when compiling + or binding. Either the environment variables or the built-in defaults + cause these files to be found. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + + @node Examples of gnatbind Usage + @section Examples of @code{gnatbind} Usage + + @noindent + This section contains a number of examples of using the GNAT binding + utility @code{gnatbind}. + + @table @code + @item gnatbind hello + The main program @code{Hello} (source program in @file{hello.adb}) is + bound using the standard switch settings. The generated main program is + @file{b~hello.adb}. This is the normal, default use of the binder. + + @item gnatbind hello -o mainprog.adb + The main program @code{Hello} (source program in @file{hello.adb}) is + bound using the standard switch settings. The generated main program is + @file{mainprog.adb} with the associated spec in + @file{mainprog.ads}. Note that you must specify the body here not the + spec, in the case where the output is in Ada. Note that if this option + is used, then linking must be done manually, since gnatlink will not + be able to find the generated file. + + @item gnatbind main -C -o mainprog.c -x + The main program @code{Main} (source program in + @file{main.adb}) is bound, excluding source files from the + consistency checking, generating + the file @file{mainprog.c}. + + @item gnatbind -x main_program -C -o mainprog.c + This command is exactly the same as the previous example. Switches may + appear anywhere in the command line, and single letter switches may be + combined into a single switch. + + @item gnatbind -n math dbase -C -o ada-control.c + The main program is in a language other than Ada, but calls to + subprograms in packages @code{Math} and @code{Dbase} appear. This call + to @code{gnatbind} generates the file @file{ada-control.c} containing + the @code{adainit} and @code{adafinal} routines to be called before and + after accessing the Ada units. + @end table + + @node Linking Using gnatlink + @chapter Linking Using @code{gnatlink} + @findex gnatlink + + @noindent + This chapter discusses @code{gnatlink}, a utility program used to link + Ada programs and build an executable file. This is a simple program + that invokes the Unix linker (via the @code{gcc} + command) with a correct list of object files and library references. + @code{gnatlink} automatically determines the list of files and + references for the Ada part of a program. It uses the binder file + generated by the binder to determine this list. + + @menu + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + @end menu + + @node Running gnatlink + @section Running @code{gnatlink} + + @noindent + The form of the @code{gnatlink} command is + + @smallexample + $ gnatlink [@var{switches}] @var{mainprog}[.ali] [@var{non-Ada objects}] + [@var{linker options}] + @end smallexample + + @noindent + @file{@var{mainprog}.ali} references the ALI file of the main program. + The @file{.ali} extension of this file can be omitted. From this + reference, @code{gnatlink} locates the corresponding binder file + @file{b~@var{mainprog}.adb} and, using the information in this file along + with the list of non-Ada objects and linker options, constructs a Unix + linker command file to create the executable. + + The arguments following @file{@var{mainprog}.ali} are passed to the + linker uninterpreted. They typically include the names of object files + for units written in other languages than Ada and any library references + required to resolve references in any of these foreign language units, + or in @code{pragma Import} statements in any Ada units. + + @var{linker options} is an optional list of linker specific + switches. The default linker called by gnatlink is @var{gcc} which in + turn calls the appropriate system linker usually called + @var{ld}. Standard options for the linker such as @code{-lmy_lib} or + @code{-Ldir} can be added as is. For options that are not recognized by + @var{gcc} as linker options, the @var{gcc} switches @code{-Xlinker} or + @code{-Wl,} shall be used. Refer to the GCC documentation for + details. Here is an example showing how to generate a linker map + assuming that the underlying linker is GNU ld: + + @smallexample + $ gnatlink my_prog -Wl,-Map,MAPFILE + @end smallexample + + Using @var{linker options} it is possible to set the program stack and + heap size. See @pxref{Setting Stack Size from gnatlink} and + @pxref{Setting Heap Size from gnatlink}. + + @code{gnatlink} determines the list of objects required by the Ada + program and prepends them to the list of objects passed to the linker. + @code{gnatlink} also gathers any arguments set by the use of + @code{pragma Linker_Options} and adds them to the list of arguments + presented to the linker. + + + @node Switches for gnatlink + @section Switches for @code{gnatlink} + + @noindent + The following switches are available with the @code{gnatlink} utility: + + @table @code + + @item -A + @cindex @code{-A} (@code{gnatlink}) + The binder has generated code in Ada. This is the default. + + @item -C + @cindex @code{-C} (@code{gnatlink}) + If instead of generating a file in Ada, the binder has generated one in + C, then the linker needs to know about it. Use this switch to signal + to @code{gnatlink} that the binder has generated C code rather than + Ada code. + + @item -f + @cindex Command line length + @cindex @code{-f} (@code{gnatlink}) + On some targets, the command line length is limited, and @code{gnatlink} + will generate a separate file for the linker if the list of object files + is too long. The @code{-f} flag forces this file to be generated even if + the limit is not exceeded. This is useful in some cases to deal with + special situations where the command line length is exceeded. + + @item -g + @cindex Debugging information, including + @cindex @code{-g} (@code{gnatlink}) + The option to include debugging information causes the Ada bind file (in + other words, @file{b~@var{mainprog}.adb}) to be compiled with + @code{-g}. + In addition, the binder does not delete the @file{b~@var{mainprog}.adb}, + @file{b~@var{mainprog}.o} and @file{b~@var{mainprog}.ali} files. + Without @code{-g}, the binder removes these files by + default. The same procedure apply if a C bind file was generated using + @code{-C} @code{gnatbind} option, in this case the filenames are + @file{b_@var{mainprog}.c} and @file{b_@var{mainprog}.o}. + + @item -n + @cindex @code{-n} (@code{gnatlink}) + Do not compile the file generated by the binder. This may be used when + a link is rerun with different options, but there is no need to recompile + the binder file. + + @item -v + @cindex @code{-v} (@code{gnatlink}) + Causes additional information to be output, including a full list of the + included object files. This switch option is most useful when you want + to see what set of object files are being used in the link step. + + @item -v -v + @cindex @code{-v -v} (@code{gnatlink}) + Very verbose mode. Requests that the compiler operate in verbose mode when + it compiles the binder file, and that the system linker run in verbose mode. + + @item -o @var{exec-name} + @cindex @code{-o} (@code{gnatlink}) + @var{exec-name} specifies an alternate name for the generated + executable program. If this switch is omitted, the executable has the same + name as the main unit. For example, @code{gnatlink try.ali} creates + an executable called @file{try}. + + @item -b @var{target} + @cindex @code{-b} (@code{gnatlink}) + Compile your program to run on @var{target}, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + @var{target} is not the same as your host system. + + @item -B@var{dir} + @cindex @code{-B} (@code{gnatlink}) + Load compiler executables (for example, @code{gnat1}, the Ada compiler) + from @var{dir} instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + @code{gcc} manual page for further details. You would normally use the + @code{-b} or @code{-V} switch instead. + + @item --GCC=@var{compiler_name} + @cindex @code{--GCC=compiler_name} (@code{gnatlink}) + Program used for compiling the binder file. The default is + `@code{gcc}'. You need to use quotes around @var{compiler_name} if + @code{compiler_name} contains spaces or other separator characters. As + an example @code{--GCC="foo -x -y"} will instruct @code{gnatlink} to use + @code{foo -x -y} as your compiler. Note that switch @code{-c} is always + inserted after your command name. Thus in the above example the compiler + command that will be used by @code{gnatlink} will be @code{foo -c -x -y}. + If several @code{--GCC=compiler_name} are used, only the last + @var{compiler_name} is taken into account. However, all the additional + switches are also taken into account. Thus, + @code{--GCC="foo -x -y" --GCC="bar -z -t"} is equivalent to + @code{--GCC="bar -x -y -z -t"}. + + @item --LINK=@var{name} + @cindex @code{--LINK=} (@code{gnatlink}) + @var{name} is the name of the linker to be invoked. This is especially + useful in mixed language programs since languages such as c++ require + their own linker to be used. When this switch is omitted, the default + name for the linker is (@file{gcc}). When this switch is used, the + specified linker is called instead of (@file{gcc}) with exactly the same + parameters that would have been passed to (@file{gcc}) so if the desired + linker requires different parameters it is necessary to use a wrapper + script that massages the parameters before invoking the real linker. It + may be useful to control the exact invocation by using the verbose + switch. + + + + @end table + + @node Setting Stack Size from gnatlink + @section Setting Stack Size from @code{gnatlink} + + @noindent + It is possible to specify the program stack size from @code{gnatlink}. + Assuming that the underlying linker is GNU ld there is two ways to do so: + + @itemize @bullet + + @item using @code{-Xlinker} linker option + + @smallexample + $ gnatlink hello -Xlinker --stack=0x10000,0x1000 + @end smallexample + + This set the stack reserve size to 0x10000 bytes and the stack commit + size to 0x1000 bytes. + + @item using @code{-Wl} linker option + + @smallexample + $ gnatlink hello -Wl,--stack=0x1000000 + @end smallexample + + This set the stack reserve size to 0x1000000 bytes. Note that with + @code{-Wl} option it is not possible to set the stack commit size + because the coma is a separator for this option. + + @end itemize + + @node Setting Heap Size from gnatlink + @section Setting Heap Size from @code{gnatlink} + + @noindent + It is possible to specify the program heap size from @code{gnatlink}. + Assuming that the underlying linker is GNU ld there is two ways to do so: + + @itemize @bullet + + @item using @code{-Xlinker} linker option + + @smallexample + $ gnatlink hello -Xlinker --heap=0x10000,0x1000 + @end smallexample + + This set the heap reserve size to 0x10000 bytes and the heap commit + size to 0x1000 bytes. + + @item using @code{-Wl} linker option + + @smallexample + $ gnatlink hello -Wl,--heap=0x1000000 + @end smallexample + + This set the heap reserve size to 0x1000000 bytes. Note that with + @code{-Wl} option it is not possible to set the heap commit size + because the coma is a separator for this option. + + @end itemize + + @node The GNAT Make Program gnatmake + @chapter The GNAT Make Program @code{gnatmake} + @findex gnatmake + + @menu + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + @end menu + @noindent + A typical development cycle when working on an Ada program consists of + the following steps: + + @enumerate + @item + Edit some sources to fix bugs. + + @item + Add enhancements. + + @item + Compile all sources affected. + + @item + Rebind and relink. + + @item + Test. + @end enumerate + + @noindent + The third step can be tricky, because not only do the modified files + @cindex Dependency rules + have to be compiled, but any files depending on these files must also be + recompiled. The dependency rules in Ada can be quite complex, especially + in the presence of overloading, @code{use} clauses, generics and inlined + subprograms. + + @code{gnatmake} automatically takes care of the third and fourth steps + of this process. It determines which sources need to be compiled, + compiles them, and binds and links the resulting object files. + + Unlike some other Ada make programs, the dependencies are always + accurately recomputed from the new sources. The source based approach of + the GNAT compilation model makes this possible. This means that if + changes to the source program cause corresponding changes in + dependencies, they will always be tracked exactly correctly by + @code{gnatmake}. + + @node Running gnatmake + @section Running @code{gnatmake} + + @noindent + The usual form of the @code{gnatmake} command is + + @smallexample + $ gnatmake [@var{switches}] @var{file_name} [@var{file_names}] [@var{mode_switches}] + @end smallexample + + @noindent + The only required argument is one @var{file_name}, which specifies + a compilation unit that is a main program. Several @var{file_names} can be + specified: this will result in several executables being built. + If @code{switches} are present, they can be placed before the first + @var{file_name}, between @var{file_names} or after the last @var{file_name}. + If @var{mode_switches} are present, they must always be placed after + the last @var{file_name} and all @code{switches}. + + If you are using standard file extensions (.adb and .ads), then the + extension may be omitted from the @var{file_name} arguments. However, if + you are using non-standard extensions, then it is required that the + extension be given. A relative or absolute directory path can be + specified in a @var{file_name}, in which case, the input source file will + be searched for in the specified directory only. Otherwise, the input + source file will first be searched in the directory where + @code{gnatmake} was invoked and if it is not found, it will be search on + the source path of the compiler as described in + @ref{Search Paths and the Run-Time Library (RTL)}. + + When several @var{file_names} are specified, if an executable needs to be + rebuilt and relinked, all subsequent executables will be rebuilt and + relinked, even if this would not be absolutely necessary. + + All @code{gnatmake} output (except when you specify + @code{-M}) is to + @file{stderr}. The output produced by the + @code{-M} switch is send to + @file{stdout}. + + @node Switches for gnatmake + @section Switches for @code{gnatmake} + + @noindent + You may specify any of the following switches to @code{gnatmake}: + + @table @code + @item --GCC=@var{compiler_name} + @cindex @code{--GCC=compiler_name} (@code{gnatmake}) + Program used for compiling. The default is `@code{gcc}'. You need to use + quotes around @var{compiler_name} if @code{compiler_name} contains + spaces or other separator characters. As an example @code{--GCC="foo -x + -y"} will instruct @code{gnatmake} to use @code{foo -x -y} as your + compiler. Note that switch @code{-c} is always inserted after your + command name. Thus in the above example the compiler command that will + be used by @code{gnatmake} will be @code{foo -c -x -y}. + If several @code{--GCC=compiler_name} are used, only the last + @var{compiler_name} is taken into account. However, all the additional + switches are also taken into account. Thus, + @code{--GCC="foo -x -y" --GCC="bar -z -t"} is equivalent to + @code{--GCC="bar -x -y -z -t"}. + + @item --GNATBIND=@var{binder_name} + @cindex @code{--GNATBIND=binder_name} (@code{gnatmake}) + Program used for binding. The default is `@code{gnatbind}'. You need to + use quotes around @var{binder_name} if @var{binder_name} contains spaces + or other separator characters. As an example @code{--GNATBIND="bar -x + -y"} will instruct @code{gnatmake} to use @code{bar -x -y} as your + binder. Binder switches that are normally appended by @code{gnatmake} to + `@code{gnatbind}' are now appended to the end of @code{bar -x -y}. + + @item --GNATLINK=@var{linker_name} + @cindex @code{--GNATLINK=linker_name} (@code{gnatmake}) + Program used for linking. The default is `@code{gnatlink}'. You need to + use quotes around @var{linker_name} if @var{linker_name} contains spaces + or other separator characters. As an example @code{--GNATLINK="lan -x + -y"} will instruct @code{gnatmake} to use @code{lan -x -y} as your + linker. Linker switches that are normally appended by @code{gnatmake} to + `@code{gnatlink}' are now appended to the end of @code{lan -x -y}. + + + @item -a + @cindex @code{-a} (@code{gnatmake}) + Consider all files in the make process, even the GNAT internal system + files (for example, the predefined Ada library files), as well as any + locked files. Locked files are files whose ALI file is write-protected. + By default, + @code{gnatmake} does not check these files, + because the assumption is that the GNAT internal files are properly up + to date, and also that any write protected ALI files have been properly + installed. Note that if there is an installation problem, such that one + of these files is not up to date, it will be properly caught by the + binder. + You may have to specify this switch if you are working on GNAT + itself. @code{-a} is also useful in conjunction with + @code{-f} + if you need to recompile an entire application, + including run-time files, using special configuration pragma settings, + such as a non-standard @code{Float_Representation} pragma. + By default + @code{gnatmake -a} compiles all GNAT + internal files with + @code{gcc -c -gnatpg} rather than @code{gcc -c}. + + @item -b + @cindex @code{-b} (@code{gnatmake}) + Bind only. Can be combined with @code{-c} to do compilation + and binding, but no link. Can be combined with @code{-l} + to do binding and linking. When not combined with @code{-c} + all the units in the closure of the main program must have been previously + compiled and must be up to date. The root unit specified by @var{file_name} + may be given without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + @item -c + @cindex @code{-c} (@code{gnatmake}) + Compile only. Do not perform binding, except when @code{-b} + is also specified. Do not perform linking, except if both + @code{-b} and + @code{-l} are also specified. + If the root unit specified by @var{file_name} is not a main unit, this is the + default. Otherwise @code{gnatmake} will attempt binding and linking + unless all objects are up to date and the executable is more recent than + the objects. + + @item -C + @cindex @code{-C} (@code{gnatmake}) + Use a mapping file. A mapping file is a way to communicate to the compiler + two mappings: from unit names to file names (without any directory information) + and from file names to path names (with full directory information). + These mappings are used by the compiler to short-circuit the path search. + When @code{gnatmake} is invoked with this switch, it will create a mapping + file, initially populated by the project manager, if @code{-P} is used, + otherwise initially empty. Each invocation of the compiler will add the newly + accessed sources to the mapping file. This will improve the source search + during the next invocation of the compiler. + + @item -f + @cindex @code{-f} (@code{gnatmake}) + Force recompilations. Recompile all sources, even though some object + files may be up to date, but don't recompile predefined or GNAT internal + files or locked files (files with a write-protected ALI file), + unless the @code{-a} switch is also specified. + + @item + @item -i + @cindex @code{-i} (@code{gnatmake}) + In normal mode, @code{gnatmake} compiles all object files and ALI files + into the current directory. If the @code{-i} switch is used, + then instead object files and ALI files that already exist are overwritten + in place. This means that once a large project is organized into separate + directories in the desired manner, then @code{gnatmake} will automatically + maintain and update this organization. If no ALI files are found on the + Ada object path (@ref{Search Paths and the Run-Time Library (RTL)}), + the new object and ALI files are created in the + directory containing the source being compiled. If another organization + is desired, where objects and sources are kept in different directories, + a useful technique is to create dummy ALI files in the desired directories. + When detecting such a dummy file, @code{gnatmake} will be forced to recompile + the corresponding source file, and it will be put the resulting object + and ALI files in the directory where it found the dummy file. + + @item -j@var{n} + @cindex @code{-j} (@code{gnatmake}) + @cindex Parallel make + Use @var{n} processes to carry out the (re)compilations. On a + multiprocessor machine compilations will occur in parallel. In the + event of compilation errors, messages from various compilations might + get interspersed (but @code{gnatmake} will give you the full ordered + list of failing compiles at the end). If this is problematic, rerun + the make process with n set to 1 to get a clean list of messages. + + @item -k + @cindex @code{-k} (@code{gnatmake}) + Keep going. Continue as much as possible after a compilation error. To + ease the programmer's task in case of compilation errors, the list of + sources for which the compile fails is given when @code{gnatmake} + terminates. + + If @code{gnatmake} is invoked with several @file{file_names} and with this + switch, if there are compilation errors when building an executable, + @code{gnatmake} will not attempt to build the following executables. + + @item -l + @cindex @code{-l} (@code{gnatmake}) + Link only. Can be combined with @code{-b} to binding + and linking. Linking will not be performed if combined with + @code{-c} + but not with @code{-b}. + When not combined with @code{-b} + all the units in the closure of the main program must have been previously + compiled and must be up to date, and the main program need to have been bound. + The root unit specified by @var{file_name} + may be given without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + @item -m + @cindex @code{-m} (@code{gnatmake}) + Specifies that the minimum necessary amount of recompilations + be performed. In this mode @code{gnatmake} ignores time + stamp differences when the only + modifications to a source file consist in adding/removing comments, + empty lines, spaces or tabs. This means that if you have changed the + comments in a source file or have simply reformatted it, using this + switch will tell gnatmake not to recompile files that depend on it + (provided other sources on which these files depend have undergone no + semantic modifications). Note that the debugging information may be + out of date with respect to the sources if the @code{-m} switch causes + a compilation to be switched, so the use of this switch represents a + trade-off between compilation time and accurate debugging information. + + @item -M + @cindex Dependencies, producing list + @cindex @code{-M} (@code{gnatmake}) + Check if all objects are up to date. If they are, output the object + dependences to @file{stdout} in a form that can be directly exploited in + a @file{Makefile}. By default, each source file is prefixed with its + (relative or absolute) directory name. This name is whatever you + specified in the various @code{-aI} + and @code{-I} switches. If you use + @code{gnatmake -M} + @code{-q} + (see below), only the source file names, + without relative paths, are output. If you just specify the + @code{-M} + switch, dependencies of the GNAT internal system files are omitted. This + is typically what you want. If you also specify + the @code{-a} switch, + dependencies of the GNAT internal files are also listed. Note that + dependencies of the objects in external Ada libraries (see switch + @code{-aL}@var{dir} in the following list) are never reported. + + @item -n + @cindex @code{-n} (@code{gnatmake}) + Don't compile, bind, or link. Checks if all objects are up to date. + If they are not, the full name of the first file that needs to be + recompiled is printed. + Repeated use of this option, followed by compiling the indicated source + file, will eventually result in recompiling all required units. + + @item -o @var{exec_name} + @cindex @code{-o} (@code{gnatmake}) + Output executable name. The name of the final executable program will be + @var{exec_name}. If the @code{-o} switch is omitted the default + name for the executable will be the name of the input file in appropriate form + for an executable file on the host system. + + This switch cannot be used when invoking @code{gnatmake} with several + @file{file_names}. + + @item -q + @cindex @code{-q} (@code{gnatmake}) + Quiet. When this flag is not set, the commands carried out by + @code{gnatmake} are displayed. + + @item -s + @cindex @code{-s} (@code{gnatmake}) + Recompile if compiler switches have changed since last compilation. + All compiler switches but -I and -o are taken into account in the + following way: + orders between different ``first letter'' switches are ignored, but + orders between same switches are taken into account. For example, + @code{-O -O2} is different than @code{-O2 -O}, but @code{-g -O} is equivalent + to @code{-O -g}. + + @item -u + @cindex @code{-u} (@code{gnatmake}) + Unique. Recompile at most the main file. It implies -c. Combined with + -f, it is equivalent to calling the compiler directly. + + @item -v + @cindex @code{-v} (@code{gnatmake}) + Verbose. Displays the reason for all recompilations @code{gnatmake} + decides are necessary. + + @item -z + @cindex @code{-z} (@code{gnatmake}) + No main subprogram. Bind and link the program even if the unit name + given on the command line is a package name. The resulting executable + will execute the elaboration routines of the package and its closure, + then the finalization routines. + + @item @code{gcc} @asis{switches} + The switch @code{-g} or any uppercase switch (other than @code{-A}, + @code{-L} or + @code{-S}) or any switch that is more than one character is passed to + @code{gcc} (e.g. @code{-O}, @option{-gnato,} etc.) + @end table + + @noindent + Source and library search path switches: + + @table @code + @item -aI@var{dir} + @cindex @code{-aI} (@code{gnatmake}) + When looking for source files also look in directory @var{dir}. + The order in which source files search is undertaken is + described in @ref{Search Paths and the Run-Time Library (RTL)}. + + @item -aL@var{dir} + @cindex @code{-aL} (@code{gnatmake}) + Consider @var{dir} as being an externally provided Ada library. + Instructs @code{gnatmake} to skip compilation units whose @file{.ali} + files have been located in directory @var{dir}. This allows you to have + missing bodies for the units in @var{dir} and to ignore out of date bodies + for the same units. You still need to specify + the location of the specs for these units by using the switches + @code{-aI@var{dir}} + or @code{-I@var{dir}}. + Note: this switch is provided for compatibility with previous versions + of @code{gnatmake}. The easier method of causing standard libraries + to be excluded from consideration is to write-protect the corresponding + ALI files. + + @item -aO@var{dir} + @cindex @code{-aO} (@code{gnatmake}) + When searching for library and object files, look in directory + @var{dir}. The order in which library files are searched is described in + @ref{Search Paths for gnatbind}. + + @item -A@var{dir} + @cindex Search paths, for @code{gnatmake} + @cindex @code{-A} (@code{gnatmake}) + Equivalent to @code{-aL@var{dir} + -aI@var{dir}}. + + @item -I@var{dir} + @cindex @code{-I} (@code{gnatmake}) + Equivalent to @code{-aO@var{dir} + -aI@var{dir}}. + + @item -I- + @cindex @code{-I-} (@code{gnatmake}) + @cindex Source files, suppressing search + Do not look for source files in the directory containing the source + file named in the command line. + Do not look for ALI or object files in the directory + where @code{gnatmake} was invoked. + + @item -L@var{dir} + @cindex @code{-L} (@code{gnatmake}) + @cindex Linker libraries + Add directory @var{dir} to the list of directories in which the linker + will search for libraries. This is equivalent to + @code{-largs -L}@var{dir}. + + @item -nostdinc + @cindex @code{-nostdinc} (@code{gnatmake}) + Do not look for source files in the system default directory. + + @item -nostdlib + @cindex @code{-nostdlib} (@code{gnatmake}) + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatmake}) + Specifies the default location of the runtime library. We look for the runtime + in the following directories, and stop as soon as a valid runtime is found + ("adainclude" or "ada_source_path", and "adalib" or "ada_object_path" present): + + @itemize @bullet + @item /$rts_path + + @item /$rts_path + + @item /rts-$rts_path + @end itemize + + @noindent + The selected path is handled like a normal RTS path. + + @end table + + @node Mode Switches for gnatmake + @section Mode Switches for @code{gnatmake} + + @noindent + The mode switches (referred to as @code{mode_switches}) allow the + inclusion of switches that are to be passed to the compiler itself, the + binder or the linker. The effect of a mode switch is to cause all + subsequent switches up to the end of the switch list, or up to the next + mode switch, to be interpreted as switches to be passed on to the + designated component of GNAT. + + @table @code + @item -cargs @var{switches} + @cindex @code{-cargs} (@code{gnatmake}) + Compiler switches. Here @var{switches} is a list of switches + that are valid switches for @code{gcc}. They will be passed on to + all compile steps performed by @code{gnatmake}. + + @item -bargs @var{switches} + @cindex @code{-bargs} (@code{gnatmake}) + Binder switches. Here @var{switches} is a list of switches + that are valid switches for @code{gcc}. They will be passed on to + all bind steps performed by @code{gnatmake}. + + @item -largs @var{switches} + @cindex @code{-largs} (@code{gnatmake}) + Linker switches. Here @var{switches} is a list of switches + that are valid switches for @code{gcc}. They will be passed on to + all link steps performed by @code{gnatmake}. + @end table + + @node Notes on the Command Line + @section Notes on the Command Line + + @noindent + This section contains some additional useful notes on the operation + of the @code{gnatmake} command. + + @itemize @bullet + @item + @cindex Recompilation, by @code{gnatmake} + If @code{gnatmake} finds no ALI files, it recompiles the main program + and all other units required by the main program. + This means that @code{gnatmake} + can be used for the initial compile, as well as during subsequent steps of + the development cycle. + + @item + If you enter @code{gnatmake @var{file}.adb}, where @file{@var{file}.adb} + is a subunit or body of a generic unit, @code{gnatmake} recompiles + @file{@var{file}.adb} (because it finds no ALI) and stops, issuing a + warning. + + @item + In @code{gnatmake} the switch @code{-I} + is used to specify both source and + library file paths. Use @code{-aI} + instead if you just want to specify + source paths only and @code{-aO} + if you want to specify library paths + only. + + @item + @code{gnatmake} examines both an ALI file and its corresponding object file + for consistency. If an ALI is more recent than its corresponding object, + or if the object file is missing, the corresponding source will be recompiled. + Note that @code{gnatmake} expects an ALI and the corresponding object file + to be in the same directory. + + @item + @code{gnatmake} will ignore any files whose ALI file is write-protected. + This may conveniently be used to exclude standard libraries from + consideration and in particular it means that the use of the + @code{-f} switch will not recompile these files + unless @code{-a} is also specified. + + @item + @code{gnatmake} has been designed to make the use of Ada libraries + particularly convenient. Assume you have an Ada library organized + as follows: @var{obj-dir} contains the objects and ALI files for + of your Ada compilation units, + whereas @var{include-dir} contains the + specs of these units, but no bodies. Then to compile a unit + stored in @code{main.adb}, which uses this Ada library you would just type + + @smallexample + $ gnatmake -aI@var{include-dir} -aL@var{obj-dir} main + @end smallexample + + @item + Using @code{gnatmake} along with the + @code{-m (minimal recompilation)} + switch provides a mechanism for avoiding unnecessary rcompilations. Using + this switch, + you can update the comments/format of your + source files without having to recompile everything. Note, however, that + adding or deleting lines in a source files may render its debugging + info obsolete. If the file in question is a spec, the impact is rather + limited, as that debugging info will only be useful during the + elaboration phase of your program. For bodies the impact can be more + significant. In all events, your debugger will warn you if a source file + is more recent than the corresponding object, and alert you to the fact + that the debugging information may be out of date. + @end itemize + + @node How gnatmake Works + @section How @code{gnatmake} Works + + @noindent + Generally @code{gnatmake} automatically performs all necessary + recompilations and you don't need to worry about how it works. However, + it may be useful to have some basic understanding of the @code{gnatmake} + approach and in particular to understand how it uses the results of + previous compilations without incorrectly depending on them. + + First a definition: an object file is considered @dfn{up to date} if the + corresponding ALI file exists and its time stamp predates that of the + object file and if all the source files listed in the + dependency section of this ALI file have time stamps matching those in + the ALI file. This means that neither the source file itself nor any + files that it depends on have been modified, and hence there is no need + to recompile this file. + + @code{gnatmake} works by first checking if the specified main unit is up + to date. If so, no compilations are required for the main unit. If not, + @code{gnatmake} compiles the main program to build a new ALI file that + reflects the latest sources. Then the ALI file of the main unit is + examined to find all the source files on which the main program depends, + and @code{gnatmake} recursively applies the above procedure on all these files. + + This process ensures that @code{gnatmake} only trusts the dependencies + in an existing ALI file if they are known to be correct. Otherwise it + always recompiles to determine a new, guaranteed accurate set of + dependencies. As a result the program is compiled "upside down" from what may + be more familiar as the required order of compilation in some other Ada + systems. In particular, clients are compiled before the units on which + they depend. The ability of GNAT to compile in any order is critical in + allowing an order of compilation to be chosen that guarantees that + @code{gnatmake} will recompute a correct set of new dependencies if + necessary. + + When invoking @code{gnatmake} with several @var{file_names}, if a unit is + imported by several of the executables, it will be recompiled at most once. + + @node Examples of gnatmake Usage + @section Examples of @code{gnatmake} Usage + + @table @code + @item gnatmake hello.adb + Compile all files necessary to bind and link the main program + @file{hello.adb} (containing unit @code{Hello}) and bind and link the + resulting object files to generate an executable file @file{hello}. + + @item gnatmake main1 main2 main3 + Compile all files necessary to bind and link the main programs + @file{main1.adb} (containing unit @code{Main1}), @file{main2.adb} + (containing unit @code{Main2}) and @file{main3.adb} + (containing unit @code{Main3}) and bind and link the resulting object files + to generate three executable files @file{main1}, + @file{main2} + and @file{main3}. + + @item gnatmake -q Main_Unit -cargs -O2 -bargs -l + + Compile all files necessary to bind and link the main program unit + @code{Main_Unit} (from file @file{main_unit.adb}). All compilations will + be done with optimization level 2 and the order of elaboration will be + listed by the binder. @code{gnatmake} will operate in quiet mode, not + displaying commands it is executing. + @end table + + @node Renaming Files Using gnatchop + @chapter Renaming Files Using @code{gnatchop} + @findex gnatchop + + @noindent + This chapter discusses how to handle files with multiple units by using + the @code{gnatchop} utility. This utility is also useful in renaming + files to meet the standard GNAT default file naming conventions. + + @menu + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + @end menu + + @node Handling Files with Multiple Units + @section Handling Files with Multiple Units + + @noindent + The basic compilation model of GNAT requires that a file submitted to the + compiler have only one unit and there be a strict correspondence + between the file name and the unit name. + + The @code{gnatchop} utility allows both of these rules to be relaxed, + allowing GNAT to process files which contain multiple compilation units + and files with arbitrary file names. @code{gnatchop} + reads the specified file and generates one or more output files, + containing one unit per file. The unit and the file name correspond, + as required by GNAT. + + If you want to permanently restructure a set of "foreign" files so that + they match the GNAT rules, and do the remaining development using the + GNAT structure, you can simply use @code{gnatchop} once, generate the + new set of files and work with them from that point on. + + Alternatively, if you want to keep your files in the "foreign" format, + perhaps to maintain compatibility with some other Ada compilation + system, you can set up a procedure where you use @code{gnatchop} each + time you compile, regarding the source files that it writes as temporary + files that you throw away. + + @node Operating gnatchop in Compilation Mode + @section Operating gnatchop in Compilation Mode + + @noindent + The basic function of @code{gnatchop} is to take a file with multiple units + and split it into separate files. The boundary between files is reasonably + clear, except for the issue of comments and pragmas. In default mode, the + rule is that any pragmas between units belong to the previous unit, except + that configuration pragmas always belong to the following unit. Any comments + belong to the following unit. These rules + almost always result in the right choice of + the split point without needing to mark it explicitly and most users will + find this default to be what they want. In this default mode it is incorrect to + submit a file containing only configuration pragmas, or one that ends in + configuration pragmas, to @code{gnatchop}. + + However, using a special option to activate "compilation mode", + @code{gnatchop} + can perform another function, which is to provide exactly the semantics + required by the RM for handling of configuration pragmas in a compilation. + In the absence of configuration pragmas (at the main file level), this + option has no effect, but it causes such configuration pragmas to be handled + in a quite different manner. + + First, in compilation mode, if @code{gnatchop} is given a file that consists of + only configuration pragmas, then this file is appended to the + @file{gnat.adc} file in the current directory. This behavior provides + the required behavior described in the RM for the actions to be taken + on submitting such a file to the compiler, namely that these pragmas + should apply to all subsequent compilations in the same compilation + environment. Using GNAT, the current directory, possibly containing a + @file{gnat.adc} file is the representation + of a compilation environment. For more information on the + @file{gnat.adc} file, see the section on handling of configuration + pragmas @pxref{Handling of Configuration Pragmas}. + + Second, in compilation mode, if @code{gnatchop} + is given a file that starts with + configuration pragmas, and contains one or more units, then these + configuration pragmas are prepended to each of the chopped files. This + behavior provides the required behavior described in the RM for the + actions to be taken on compiling such a file, namely that the pragmas + apply to all units in the compilation, but not to subsequently compiled + units. + + Finally, if configuration pragmas appear between units, they are appended + to the previous unit. This results in the previous unit being illegal, + since the compiler does not accept configuration pragmas that follow + a unit. This provides the required RM behavior that forbids configuration + pragmas other than those preceding the first compilation unit of a + compilation. + + For most purposes, @code{gnatchop} will be used in default mode. The + compilation mode described above is used only if you need exactly + accurate behavior with respect to compilations, and you have files + that contain multiple units and configuration pragmas. In this + circumstance the use of @code{gnatchop} with the compilation mode + switch provides the required behavior, and is for example the mode + in which GNAT processes the ACVC tests. + + @node Command Line for gnatchop + @section Command Line for @code{gnatchop} + + @noindent + The @code{gnatchop} command has the form: + + @smallexample + $ gnatchop switches @var{file name} [@var{file name} @var{file name} ...] + [@var{directory}] + @end smallexample + + @noindent + The only required argument is the file name of the file to be chopped. + There are no restrictions on the form of this file name. The file itself + contains one or more Ada units, in normal GNAT format, concatenated + together. As shown, more than one file may be presented to be chopped. + + When run in default mode, @code{gnatchop} generates one output file in + the current directory for each unit in each of the files. + + @var{directory}, if specified, gives the name of the directory to which + the output files will be written. If it is not specified, all files are + written to the current directory. + + For example, given a + file called @file{hellofiles} containing + + @smallexample + @group + @cartouche + @b{procedure} hello; + + @b{with} Text_IO; @b{use} Text_IO; + @b{procedure} hello @b{is} + @b{begin} + Put_Line ("Hello"); + @b{end} hello; + @end cartouche + @end group + @end smallexample + + @noindent + the command + + @smallexample + $ gnatchop hellofiles + @end smallexample + + @noindent + generates two files in the current directory, one called + @file{hello.ads} containing the single line that is the procedure spec, + and the other called @file{hello.adb} containing the remaining text. The + original file is not affected. The generated files can be compiled in + the normal manner. + + @node Switches for gnatchop + @section Switches for @code{gnatchop} + + @noindent + @code{gnatchop} recognizes the following switches: + + @table @code + + @item -c + @cindex @code{-c} (@code{gnatchop}) + Causes @code{gnatchop} to operate in compilation mode, in which + configuration pragmas are handled according to strict RM rules. See + previous section for a full description of this mode. + + @item -gnatxxx + This passes the given @option{-gnatxxx} switch to @code{gnat} which is + used to parse the given file. Not all @code{xxx} options make sense, + but for example, the use of @option{-gnati2} allows @code{gnatchop} to + process a source file that uses Latin-2 coding for identifiers. + + @item -h + Causes @code{gnatchop} to generate a brief help summary to the standard + output file showing usage information. + + @item -k@var{mm} + @cindex @code{-k} (@code{gnatchop}) + Limit generated file names to the specified number @code{mm} + of characters. + This is useful if the + resulting set of files is required to be interoperable with systems + which limit the length of file names. + No space is allowed between the @code{-k} and the numeric value. The numeric + value may be omitted in which case a default of @code{-k8}, + suitable for use + with DOS-like file systems, is used. If no @code{-k} switch + is present then + there is no limit on the length of file names. + + @item -p + @cindex @code{-p} (@code{gnatchop}) + Causes the file modification time stamp of the input file to be + preserved and used for the time stamp of the output file(s). This may be + useful for preserving coherency of time stamps in an enviroment where + @code{gnatchop} is used as part of a standard build process. + + @item -q + @cindex @code{-q} (@code{gnatchop}) + Causes output of informational messages indicating the set of generated + files to be suppressed. Warnings and error messages are unaffected. + + @item -r + @cindex @code{-r} (@code{gnatchop}) + @findex Source_Reference + Generate @code{Source_Reference} pragmas. Use this switch if the output + files are regarded as temporary and development is to be done in terms + of the original unchopped file. This switch causes + @code{Source_Reference} pragmas to be inserted into each of the + generated files to refers back to the original file name and line number. + The result is that all error messages refer back to the original + unchopped file. + In addition, the debugging information placed into the object file (when + the @code{-g} switch of @code{gcc} or @code{gnatmake} is specified) also + refers back to this original file so that tools like profilers and + debuggers will give information in terms of the original unchopped file. + + If the original file to be chopped itself contains + a @code{Source_Reference} + pragma referencing a third file, then gnatchop respects + this pragma, and the generated @code{Source_Reference} pragmas + in the chopped file refer to the original file, with appropriate + line numbers. This is particularly useful when @code{gnatchop} + is used in conjunction with @code{gnatprep} to compile files that + contain preprocessing statements and multiple units. + + @item -v + @cindex @code{-v} (@code{gnatchop}) + Causes @code{gnatchop} to operate in verbose mode. The version + number and copyright notice are output, as well as exact copies of + the gnat1 commands spawned to obtain the chop control information. + + @item -w + @cindex @code{-w} (@code{gnatchop}) + Overwrite existing file names. Normally @code{gnatchop} regards it as a + fatal error if there is already a file with the same name as a + file it would otherwise output, in other words if the files to be + chopped contain duplicated units. This switch bypasses this + check, and causes all but the last instance of such duplicated + units to be skipped. + + @item --GCC=xxxx + @cindex @code{--GCC=} (@code{gnatchop}) + Specify the path of the GNAT parser to be used. When this switch is used, + no attempt is made to add the prefix to the GNAT parser executable. + @end table + + @node Examples of gnatchop Usage + @section Examples of @code{gnatchop} Usage + + @table @code + @item gnatchop -w hello_s.ada ichbiah/files + + Chops the source file @file{hello_s.ada}. The output files will be + placed in the directory @file{ichbiah/files}, + overwriting any + files with matching names in that directory (no files in the current + directory are modified). + + @item gnatchop archive + Chops the source file @file{archive} + into the current directory. One + useful application of @code{gnatchop} is in sending sets of sources + around, for example in email messages. The required sources are simply + concatenated (for example, using a Unix @code{cat} + command), and then + @code{gnatchop} is used at the other end to reconstitute the original + file names. + + @item gnatchop file1 file2 file3 direc + Chops all units in files @file{file1}, @file{file2}, @file{file3}, placing + the resulting files in the directory @file{direc}. Note that if any units + occur more than once anywhere within this set of files, an error message + is generated, and no files are written. To override this check, use the + @code{-w} switch, + in which case the last occurrence in the last file will + be the one that is output, and earlier duplicate occurrences for a given + unit will be skipped. + @end table + + @node Configuration Pragmas + @chapter Configuration Pragmas + @cindex Configuration pragmas + @cindex Pragmas, configuration + + @noindent + In Ada 95, configuration pragmas include those pragmas described as + such in the Ada 95 Reference Manual, as well as + implementation-dependent pragmas that are configuration pragmas. See the + individual descriptions of pragmas in the GNAT Reference Manual for + details on these additional GNAT-specific configuration pragmas. Most + notably, the pragma @code{Source_File_Name}, which allows + specifying non-default names for source files, is a configuration + pragma. The following is a complete list of configuration pragmas + recognized by @code{GNAT}: + + @smallexample + Ada_83 + Ada_95 + C_Pass_By_Copy + Component_Alignment + Discard_Names + Elaboration_Checks + Eliminate + Extend_System + Extensions_Allowed + External_Name_Casing + Float_Representation + Initialize_Scalars + License + Locking_Policy + Long_Float + No_Run_Time + Normalize_Scalars + Polling + Propagate_Exceptions + Queuing_Policy + Ravenscar + Restricted_Run_Time + Restrictions + Reviewable + Source_File_Name + Style_Checks + Suppress + Task_Dispatching_Policy + Unsuppress + Use_VADS_Size + Warnings + Validity_Checks + @end smallexample + + @menu + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + @end menu + + @node Handling of Configuration Pragmas + @section Handling of Configuration Pragmas + + Configuration pragmas may either appear at the start of a compilation + unit, in which case they apply only to that unit, or they may apply to + all compilations performed in a given compilation environment. + + GNAT also provides the @code{gnatchop} utility to provide an automatic + way to handle configuration pragmas following the semantics for + compilations (that is, files with multiple units), described in the RM. + See section @pxref{Operating gnatchop in Compilation Mode} for details. + However, for most purposes, it will be more convenient to edit the + @file{gnat.adc} file that contains configuration pragmas directly, + as described in the following section. + + @node The Configuration Pragmas Files + @section The Configuration Pragmas Files + @cindex @file{gnat.adc} + + @noindent + In GNAT a compilation environment is defined by the current + directory at the time that a compile command is given. This current + directory is searched for a file whose name is @file{gnat.adc}. If + this file is present, it is expected to contain one or more + configuration pragmas that will be applied to the current compilation. + However, if the switch @option{-gnatA} is used, @file{gnat.adc} is not + considered. + + Configuration pragmas may be entered into the @file{gnat.adc} file + either by running @code{gnatchop} on a source file that consists only of + configuration pragmas, or more conveniently by + direct editing of the @file{gnat.adc} file, which is a standard format + source file. + + In addition to @file{gnat.adc}, one additional file containing configuration + pragmas may be applied to the current compilation using the switch + @option{-gnatec}@var{path}. @var{path} must designate an existing file that + contains only configuration pragmas. These configuration pragmas are + in addition to those found in @file{gnat.adc} (provided @file{gnat.adc} + is present and switch @option{-gnatA} is not used). + + It is allowed to specify several switches @option{-gnatec}, however only + the last one on the command line will be taken into account. + + + @node Handling Arbitrary File Naming Conventions Using gnatname + @chapter Handling Arbitrary File Naming Conventions Using @code{gnatname} + @cindex Arbitrary File Naming Conventions + + @menu + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + @end menu + + @node Arbitrary File Naming Conventions + @section Arbitrary File Naming Conventions + + @noindent + The GNAT compiler must be able to know the source file name of a compilation unit. + When using the standard GNAT default file naming conventions (@code{.ads} for specs, + @code{.adb} for bodies), the GNAT compiler does not need additional information. + + @noindent + When the source file names do not follow the standard GNAT default file naming + conventions, the GNAT compiler must be given additional information through + a configuration pragmas file (see @ref{Configuration Pragmas}) or a project file. + When the non standard file naming conventions are well-defined, a small number of + pragmas @code{Source_File_Name} specifying a naming pattern + (see @ref{Alternative File Naming Schemes}) may be sufficient. However, + if the file naming conventions are irregular or arbitrary, a number + of pragma @code{Source_File_Name} for individual compilation units must be defined. + To help maintain the correspondence between compilation unit names and + source file names within the compiler, + GNAT provides a tool @code{gnatname} to generate the required pragmas for a + set of files. + + @node Running gnatname + @section Running @code{gnatname} + + @noindent + The usual form of the @code{gnatname} command is + + @smallexample + $ gnatname [@var{switches}] @var{naming_pattern} [@var{naming_patterns}] + @end smallexample + + @noindent + All of the arguments are optional. If invoked without any argument, + @code{gnatname} will display its usage. + + @noindent + When used with at least one naming pattern, @code{gnatname} will attempt to + find all the compilation units in files that follow at least one of the + naming patterns. To find these compilation units, + @code{gnatname} will use the GNAT compiler in syntax-check-only mode on all + regular files. + + @noindent + One or several Naming Patterns may be given as arguments to @code{gnatname}. + Each Naming Pattern is enclosed between double quotes. + A Naming Pattern is a regular expression similar to the wildcard patterns + used in file names by the Unix shells or the DOS prompt. + + @noindent + Examples of Naming Patterns are + + @smallexample + "*.[12].ada" + "*.ad[sb]*" + "body_*" "spec_*" + @end smallexample + + @noindent + For a more complete description of the syntax of Naming Patterns, see the second kind + of regular expressions described in @file{g-regexp.ads} (the "Glob" regular + expressions). + + @noindent + When invoked with no switches, @code{gnatname} will create a configuration + pragmas file @file{gnat.adc} in the current working directory, with pragmas + @code{Source_File_Name} for each file that contains a valid Ada unit. + + @node Switches for gnatname + @section Switches for @code{gnatname} + + @noindent + Switches for @code{gnatname} must precede any specified Naming Pattern. + + @noindent + You may specify any of the following switches to @code{gnatname}: + + @table @code + + @item -c@file{file} + @cindex @code{-c} (@code{gnatname}) + Create a configuration pragmas file @file{file} (instead of the default + @file{gnat.adc}). There may be zero, one or more space between @code{-c} and + @file{file}. @file{file} may include directory information. @file{file} must be + writeable. There may be only one switch @code{-c}. When a switch @code{-c} is + specified, no switch @code{-P} may be specified (see below). + + @item -d@file{dir} + @cindex @code{-d} (@code{gnatname}) + Look for source files in directory @file{dir}. There may be zero, one or more spaces + between @code{-d} and @file{dir}. When a switch @code{-d} is specified, + the current working directory will not be searched for source files, unless it + is explictly + specified with a @code{-d} or @code{-D} switch. Several switches @code{-d} may be + specified. If @file{dir} is a relative path, it is relative to the directory of + the configuration pragmas file specified with switch @code{-c}, or to the directory + of the project file specified with switch @code{-P} or, if neither switch @code{-c} + nor switch @code{-P} are specified, it is relative to the current working + directory. The directory + specified with switch @code{-c} must exist and be readable. + + @item -D@file{file} + @cindex @code{-D} (@code{gnatname}) + Look for source files in all directories listed in text file @file{file}. There may be + zero, one or more spaces between @code{-d} and @file{dir}. @file{file} + must be an existing, readable text file. Each non empty line in @file{file} must be + a directory. Specifying switch @code{-D} is equivalent to specifying as many switches + @code{-d} as there are non empty lines in @file{file}. + + @item -h + @cindex @code{-h} (@code{gnatname}) + Output usage (help) information. The output is written to @file{stdout}. + + @item -P@file{proj} + @cindex @code{-P} (@code{gnatname}) + Create or update project file @file{proj}. There may be zero, one or more space + between @code{-P} and @file{proj}. @file{proj} may include directory information. + @file{proj} must be writeable. There may be only one switch @code{-P}. + When a switch @code{-P} is specified, no switch @code{-c} may be specified. + + @item -v + @cindex @code{-v} (@code{gnatname}) + Verbose mode. Output detailed explanation of behavior to @file{stdout}. This includes + name of the file written, the name of the directories to search and, for each file + in those directories whose name matches at least one of the Naming Patterns, an + indication of whether the file contains a unit, and if so the name of the unit. + + @item -v -v + Very Verbose mode. In addition to the output produced in verbose mode, for each file + in the searched directories whose name matches none of the Naming Patterns, an + indication is given that there is no match. + + @item -x@file{pattern} + Excluded patterns. Using this switch, it is possible to exclude some files + that would match the name patterns. For example, + @code{"gnatname -x "*_nt.ada" "*.ada"} will look for Ada units in all files + with the @file{.ada} extension, except those whose names end with + @file{_nt.ada}. + + @end table + + @node Examples of gnatname Usage + @section Examples of @code{gnatname} Usage + + @smallexample + $ gnatname -c /home/me/names.adc -d sources "[a-z]*.ada*" + @end smallexample + + In this example, the directory @file{/home/me} must already exist and be + writeable. In addition, the directory @file{/home/me/sources} (specified by + @code{-d sources}) must exist and be readable. Note the optional spaces after + @code{-c} and @code{-d}. + + @smallexample + $ gnatname -P/home/me/proj -x "*_nt_body.ada" -dsources -dsources/plus -Dcommon_dirs.txt "body_*" "spec_*" + @end smallexample + + Note that several switches @code{-d} may be used, even in conjunction with one + or several switches @code{-D}. Several Naming Patterns and one excluded pattern + are used in this example. + + + @c ***************************************** + @c * G N A T P r o j e c t M a n a g e r * + @c ***************************************** + @node GNAT Project Manager + @chapter GNAT Project Manager + + @menu + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + @end menu + + + @c **************** + @c * Introduction * + @c **************** + + @node Introduction + @section Introduction + + @noindent + This chapter describes GNAT's @emph{Project Manager}, a facility that + lets you configure various properties for a collection of source files. In + particular, you can specify: + @itemize @bullet + @item + The directory or set of directories containing the source files, and/or the + names of the specific source files themselves + @item + The directory in which the compiler's output + (@file{ALI} files, object files, tree files) will be placed + @item + The directory in which the executable programs will be placed + @item + Switch settings for any of the project-enabled tools (@command{gnatmake}, + compiler, binder, linker, @code{gnatls}, @code{gnatxref}, @code{gnatfind}); + you can apply these settings either globally or to individual units + @item + The source files containing the main subprogram(s) to be built + @item + The source programming language(s) (currently Ada and/or C) + @item + Source file naming conventions; you can specify these either globally or for + individual units + @end itemize + + @menu + * Project Files:: + @end menu + + @node Project Files + @subsection Project Files + + @noindent + A @dfn{project} is a specific set of values for these properties. You can + define a project's settings in a @dfn{project file}, a text file with an + Ada-like syntax; a property value is either a string or a list of strings. + Properties that are not explicitly set receive default values. A project + file may interrogate the values of @dfn{external variables} (user-defined + command-line switches or environment variables), and it may specify property + settings conditionally, based on the value of such variables. + + In simple cases, a project's source files depend only on other source files + in the same project, or on the predefined libraries. ("Dependence" is in + the technical sense; for example, one Ada unit "with"ing another.) However, + the Project Manager also allows much more sophisticated arrangements, + with the source files in one project depending on source files in other + projects: + @itemize @bullet + @item + One project can @emph{import} other projects containing needed source files. + @item + You can organize GNAT projects in a hierarchy: a @emph{child} project + can extend a @emph{parent} project, inheriting the parent's source files and + optionally overriding any of them with alternative versions + @end itemize + + @noindent + More generally, the Project Manager lets you structure large development + efforts into hierarchical subsystems, with build decisions deferred to the + subsystem level and thus different compilation environments (switch settings) + used for different subsystems. + + The Project Manager is invoked through the @option{-P@emph{projectfile}} + switch to @command{gnatmake} or to the @command{gnat} front driver. + If you want to define (on the command line) an external variable that is + queried by the project file, additionally use the + @option{-X@emph{vbl}=@emph{value}} switch. + The Project Manager parses and interprets the project file, and drives the + invoked tool based on the project settings. + + The Project Manager supports a wide range of development strategies, + for systems of all sizes. Some typical practices that are easily handled: + @itemize @bullet + @item + Using a common set of source files, but generating object files in different + directories via different switch settings + @item + Using a mostly-shared set of source files, but with different versions of + some unit or units + @end itemize + + @noindent + The destination of an executable can be controlled inside a project file + using the @option{-o} switch. In the absence of such a switch either inside + the project file or on the command line, any executable files generated by + @command{gnatmake} will be placed in the directory @code{Exec_Dir} specified + in the project file. If no @code{Exec_Dir} is specified, they will be placed + in the object directory of the project. + + You can use project files to achieve some of the effects of a source + versioning system (for example, defining separate projects for + the different sets of sources that comprise different releases) but the + Project Manager is independent of any source configuration management tools + that might be used by the developers. + + The next section introduces the main features of GNAT's project facility + through a sequence of examples; subsequent sections will present the syntax + and semantics in more detail. + + + @c ***************************** + @c * Examples of Project Files * + @c ***************************** + + @node Examples of Project Files + @section Examples of Project Files + @noindent + This section illustrates some of the typical uses of project files and + explains their basic structure and behavior. + + @menu + * Common Sources with Different Switches and Different Output Directories:: + * Using External Variables:: + * Importing Other Projects:: + * Extending a Project:: + @end menu + + @node Common Sources with Different Switches and Different Output Directories + @subsection Common Sources with Different Switches and Different Output Directories + + @menu + * Source Files:: + * Specifying the Object Directory:: + * Specifying the Exec Directory:: + * Project File Packages:: + * Specifying Switch Settings:: + * Main Subprograms:: + * Source File Naming Conventions:: + * Source Language(s):: + @end menu + + @noindent + Assume that the Ada source files @file{pack.ads}, @file{pack.adb}, and + @file{proc.adb} are in the @file{/common} directory. The file + @file{proc.adb} contains an Ada main subprogram @code{Proc} that "with"s + package @code{Pack}. We want to compile these source files under two sets + of switches: + @itemize @bullet + @item + When debugging, we want to pass the @option{-g} switch to @command{gnatmake}, + and the @option{-gnata}, @option{-gnato}, and @option{-gnatE} switches to the + compiler; the compiler's output is to appear in @file{/common/debug} + @item + When preparing a release version, we want to pass the @option{-O2} switch to + the compiler; the compiler's output is to appear in @file{/common/release} + @end itemize + + @noindent + The GNAT project files shown below, respectively @file{debug.gpr} and + @file{release.gpr} in the @file{/common} directory, achieve these effects. + + Diagrammatically: + @smallexample + @group + /common + debug.gpr + release.gpr + pack.ads + pack.adb + proc.adb + @end group + @group + /common/debug @{-g, -gnata, -gnato, -gnatE@} + proc.ali, proc.o + pack.ali, pack.o + @end group + @group + /common/release @{-O2@} + proc.ali, proc.o + pack.ali, pack.o + @end group + @end smallexample + Here are the project files: + @smallexample + @group + project Debug is + for Object_Dir use "debug"; + for Main use ("proc"); + + package Builder is + for Default_Switches ("Ada") use ("-g"); + end Builder; + @end group + + @group + package Compiler is + for Default_Switches ("Ada") + use ("-fstack-check", "-gnata", "-gnato", "-gnatE"); + end Compiler; + end Debug; + @end group + @end smallexample + + @smallexample + @group + project Release is + for Object_Dir use "release"; + for Exec_Dir use "."; + for Main use ("proc"); + + package Compiler is + for Default_Switches ("Ada") use ("-O2"); + end Compiler; + end Release; + @end group + @end smallexample + + @noindent + The name of the project defined by @file{debug.gpr} is @code{"Debug"} (case + insensitive), and analogously the project defined by @file{release.gpr} is + @code{"Release"}. For consistency the file should have the same name as the + project, and the project file's extension should be @code{"gpr"}. These + conventions are not required, but a warning is issued if they are not followed. + + If the current directory is @file{/temp}, then the command + @smallexample + gnatmake -P/common/debug.gpr + @end smallexample + + @noindent + generates object and ALI files in @file{/common/debug}, and the @code{proc} + executable also in @file{/common/debug}, using the switch settings defined in + the project file. + + Likewise, the command + @smallexample + gnatmake -P/common/release.gpr + @end smallexample + + @noindent + generates object and ALI files in @file{/common/release}, and the @code{proc} + executable in @file{/common}, using the switch settings from the project file. + + @node Source Files + @unnumberedsubsubsec Source Files + + @noindent + If a project file does not explicitly specify a set of source directories or + a set of source files, then by default the project's source files are the + Ada source files in the project file directory. Thus @file{pack.ads}, + @file{pack.adb}, and @file{proc.adb} are the source files for both projects. + + @node Specifying the Object Directory + @unnumberedsubsubsec Specifying the Object Directory + + @noindent + Several project properties are modeled by Ada-style @emph{attributes}; + you define the property by supplying the equivalent of an Ada attribute + definition clause in the project file. + A project's object directory is such a property; the corresponding + attribute is @code{Object_Dir}, and its value is a string expression. A + directory may be specified either as absolute or as relative; in the latter + case, it is relative to the project file directory. Thus the compiler's + output is directed to @file{/common/debug} (for the @code{Debug} project) + and to @file{/common/release} (for the @code{Release} project). If + @code{Object_Dir} is not specified, then the default is the project file + directory. + + @node Specifying the Exec Directory + @unnumberedsubsubsec Specifying the Exec Directory + + @noindent + A project's exec directory is another property; the corresponding + attribute is @code{Exec_Dir}, and its value is also a string expression, + either specified as relative or absolute. If @code{Exec_Dir} is not specified, + then the default is the object directory (which may also be the project file + directory if attribute @code{Object_Dir} is not specified). Thus the executable + is placed in @file{/common/debug} for the @code{Debug} project (attribute + @code{Exec_Dir} not specified) and in @file{/common} for the @code{Release} + project. + + @node Project File Packages + @unnumberedsubsubsec Project File Packages + + @noindent + A GNAT tool integrated with the Project Manager is modeled by a + corresponding package in the project file. + The @code{Debug} project defines the packages @code{Builder} + (for @command{gnatmake}) and @code{Compiler}; + the @code{Release} project defines only the @code{Compiler} package. + + The Ada package syntax is not to be taken literally. Although packages in + project files bear a surface resemblance to packages in Ada source code, the + notation is simply a way to convey a grouping of properties for a named + entity. Indeed, the package names permitted in project files are restricted + to a predefined set, corresponding to the project-aware tools, and the contents + of packages are limited to a small set of constructs. + The packages in the example above contain attribute definitions. + + + @node Specifying Switch Settings + @unnumberedsubsubsec Specifying Switch Settings + + @noindent + Switch settings for a project-aware tool can be specified through attributes + in the package corresponding to the tool. + The example above illustrates one of the relevant attributes, + @code{Default_Switches}, defined in the packages in both project files. + Unlike simple attributes like @code{Source_Dirs}, @code{Default_Switches} is + known as an @emph{associative array}. When you define this attribute, you must + supply an "index" (a literal string), and the effect of the attribute + definition is to set the value of the "array" at the specified "index". + For the @code{Default_Switches} attribute, the index is a programming + language (in our case, Ada) , and the value specified (after @code{use}) + must be a list of string expressions. + + The attributes permitted in project files are restricted to a predefined set. + Some may appear at project level, others in packages. + For any attribute that is an associate array, the index must always be a + literal string, but the restrictions on this string (e.g., a file name or a + language name) depend on the individual attribute. + Also depending on the attribute, its specified value will need to be either a + string or a string list. + + In the @code{Debug} project, we set the switches for two tools, + @command{gnatmake} and the compiler, and thus we include corresponding + packages, with each package defining the @code{Default_Switches} attribute + with index @code{"Ada"}. + Note that the package corresponding to + @command{gnatmake} is named @code{Builder}. The @code{Release} project is + similar, but with just the @code{Compiler} package. + + In project @code{Debug} above the switches starting with @option{-gnat} that + are specified in package @code{Compiler} could have been placed in package + @code{Builder}, since @command{gnatmake} transmits all such switches to the + compiler. + + @node Main Subprograms + @unnumberedsubsubsec Main Subprograms + + @noindent + One of the properties of a project is its list of main subprograms (actually + a list of names of source files containing main subprograms, with the file + extension optional. This property is captured in the @code{Main} attribute, + whose value is a list of strings. If a project defines the @code{Main} + attribute, then you do not need to identify the main subprogram(s) when + invoking @command{gnatmake} (see @ref{gnatmake and Project Files}). + + @node Source File Naming Conventions + @unnumberedsubsubsec Source File Naming Conventions + + @noindent + Since the project files do not specify any source file naming conventions, + the GNAT defaults are used. The mechanism for defining source file naming + conventions -- a package named @code{Naming} -- will be described below + (@pxref{Naming Schemes}). + + @node Source Language(s) + @unnumberedsubsubsec Source Language(s) + + @noindent + Since the project files do not specify a @code{Languages} attribute, by + default the GNAT tools assume that the language of the project file is Ada. + More generally, a project can comprise source files + in Ada, C, and/or other languages. + + @node Using External Variables + @subsection Using External Variables + + @noindent + Instead of supplying different project files for debug and release, we can + define a single project file that queries an external variable (set either + on the command line or via an environment variable) in order to + conditionally define the appropriate settings. Again, assume that the + source files @file{pack.ads}, @file{pack.adb}, and @file{proc.adb} are + located in directory @file{/common}. The following project file, + @file{build.gpr}, queries the external variable named @code{STYLE} and + defines an object directory and switch settings based on whether the value + is @code{"deb"} (debug) or @code{"rel"} (release), where the default is + @code{"deb"}. + + @smallexample + @group + project Build is + for Main use ("proc"); + + type Style_Type is ("deb", "rel"); + Style : Style_Type := external ("STYLE", "deb"); + + case Style is + when "deb" => + for Object_Dir use "debug"; + + when "rel" => + for Object_Dir use "release"; + for Exec_Dir use "."; + end case; + @end group + + @group + package Builder is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-g"); + end case; + + end Builder; + @end group + + @group + package Compiler is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-gnata", "-gnato", "-gnatE"); + + when "rel" => + for Default_Switches ("Ada") use ("-O2"); + end case; + + end Compiler; + + end Build; + @end group + @end smallexample + + @noindent + @code{Style_Type} is an example of a @emph{string type}, which is the project + file analog of an Ada enumeration type but containing string literals rather + than identifiers. @code{Style} is declared as a variable of this type. + + The form @code{external("STYLE", "deb")} is known as an + @emph{external reference}; its first argument is the name of an + @emph{external variable}, and the second argument is a default value to be + used if the external variable doesn't exist. You can define an external + variable on the command line via the @option{-X} switch, or you can use an + environment variable as an external variable. + + Each @code{case} construct is expanded by the Project Manager based on the + value of @code{Style}. Thus the command + @smallexample + gnatmake -P/common/build.gpr -XSTYLE=deb + @end smallexample + + @noindent + is equivalent to the @command{gnatmake} invocation using the project file + @file{debug.gpr} in the earlier example. So is the command + @smallexample + gnatmake -P/common/build.gpr + @end smallexample + + @noindent + since @code{"deb"} is the default for @code{STYLE}. + + Analogously, + @smallexample + gnatmake -P/common/build.gpr -XSTYLE=rel + @end smallexample + + @noindent + is equivalent to the @command{gnatmake} invocation using the project file + @file{release.gpr} in the earlier example. + + + @node Importing Other Projects + @subsection Importing Other Projects + + @noindent + A compilation unit in a source file in one project may depend on compilation + units in source files in other projects. To obtain this behavior, the + dependent project must @emph{import} the projects containing the needed source + files. This effect is embodied in syntax similar to an Ada @code{with} clause, + but the "with"ed entities are strings denoting project files. + + As an example, suppose that the two projects @code{GUI_Proj} and + @code{Comm_Proj} are defined in the project files @file{gui_proj.gpr} and + @file{comm_proj.gpr} in directories @file{/gui} and @file{/comm}, + respectively. Assume that the source files for @code{GUI_Proj} are + @file{gui.ads} and @file{gui.adb}, and that the source files for + @code{Comm_Proj} are @file{comm.ads} and @file{comm.adb}, with each set of + files located in its respective project file directory. Diagrammatically: + + @smallexample + @group + /gui + gui_proj.gpr + gui.ads + gui.adb + @end group + + @group + /comm + comm_proj.gpr + comm.ads + comm.adb + @end group + @end smallexample + + @noindent + We want to develop an application in directory @file{/app} that "with"s the + packages @code{GUI} and @code{Comm}, using the properties of the + corresponding project files (e.g. the switch settings and object directory). + Skeletal code for a main procedure might be something like the following: + + @smallexample + @group + with GUI, Comm; + procedure App_Main is + ... + begin + ... + end App_Main; + @end group + @end smallexample + + @noindent + Here is a project file, @file{app_proj.gpr}, that achieves the desired + effect: + + @smallexample + @group + with "/gui/gui_proj", "/comm/comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + @end group + @end smallexample + + @noindent + Building an executable is achieved through the command: + @smallexample + gnatmake -P/app/app_proj + @end smallexample + @noindent + which will generate the @code{app_main} executable in the directory where + @file{app_proj.gpr} resides. + + If an imported project file uses the standard extension (@code{gpr}) then + (as illustrated above) the @code{with} clause can omit the extension. + + Our example specified an absolute path for each imported project file. + Alternatively, you can omit the directory if either + @itemize @bullet + @item + The imported project file is in the same directory as the importing project + file, or + @item + You have defined an environment variable @code{ADA_PROJECT_PATH} that + includes the directory containing the needed project file. + @end itemize + + @noindent + Thus, if we define @code{ADA_PROJECT_PATH} to include @file{/gui} and + @file{/comm}, then our project file @file{app_proj.gpr} could be written as + follows: + + @smallexample + @group + with "gui_proj", "comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + @end group + @end smallexample + + @noindent + Importing other projects raises the possibility of ambiguities. For + example, the same unit might be present in different imported projects, or + it might be present in both the importing project and an imported project. + Both of these conditions are errors. Note that in the current version of + the Project Manager, it is illegal to have an ambiguous unit even if the + unit is never referenced by the importing project. This restriction may be + relaxed in a future release. + + @node Extending a Project + @subsection Extending a Project + + @noindent + A common situation in large software systems is to have multiple + implementations for a common interface; in Ada terms, multiple versions of a + package body for the same specification. For example, one implementation + might be safe for use in tasking programs, while another might only be used + in sequential applications. This can be modeled in GNAT using the concept + of @emph{project extension}. If one project (the "child") @emph{extends} + another project (the "parent") then by default all source files of the + parent project are inherited by the child, but the child project can + override any of the parent's source files with new versions, and can also + add new files. This facility is the project analog of extension in + Object-Oriented Programming. Project hierarchies are permitted (a child + project may be the parent of yet another project), and a project that + inherits one project can also import other projects. + + As an example, suppose that directory @file{/seq} contains the project file + @file{seq_proj.gpr} and the source files @file{pack.ads}, @file{pack.adb}, + and @file{proc.adb}: + + @smallexample + @group + /seq + pack.ads + pack.adb + proc.adb + seq_proj.gpr + @end group + @end smallexample + + @noindent + Note that the project file can simply be empty (that is, no attribute or + package is defined): + + @smallexample + @group + project Seq_Proj is + end Seq_Proj; + @end group + @end smallexample + + @noindent + implying that its source files are all the Ada source files in the project + directory. + + Suppose we want to supply an alternate version of @file{pack.adb}, in + directory @file{/tasking}, but use the existing versions of @file{pack.ads} + and @file{proc.adb}. We can define a project @code{Tasking_Proj} that + inherits @code{Seq_Proj}: + + @smallexample + @group + /tasking + pack.adb + tasking_proj.gpr + @end group + + @group + project Tasking_Proj extends "/seq/seq_proj" is + end Tasking_Proj; + @end group + @end smallexample + + @noindent + The version of @file{pack.adb} used in a build depends on which project file + is specified. + + Note that we could have designed this using project import rather than + project inheritance; a @code{base} project would contain the sources for + @file{pack.ads} and @file{proc.adb}, a sequential project would import + @code{base} and add @file{pack.adb}, and likewise a tasking project would + import @code{base} and add a different version of @file{pack.adb}. The + choice depends on whether other sources in the original project need to be + overridden. If they do, then project extension is necessary, otherwise, + importing is sufficient. + + + @c *********************** + @c * Project File Syntax * + @c *********************** + + @node Project File Syntax + @section Project File Syntax + + @menu + * Basic Syntax:: + * Packages:: + * Expressions:: + * String Types:: + * Variables:: + * Attributes:: + * Associative Array Attributes:: + * case Constructions:: + @end menu + + @noindent + This section describes the structure of project files. + + A project may be an @emph{independent project}, entirely defined by a single + project file. Any Ada source file in an independent project depends only + on the predefined library and other Ada source files in the same project. + + @noindent + A project may also @dfn{depend on} other projects, in either or both of the following ways: + @itemize @bullet + @item It may import any number of projects + @item It may extend at most one other project + @end itemize + + @noindent + The dependence relation is a directed acyclic graph (the subgraph reflecting + the "extends" relation is a tree). + + A project's @dfn{immediate sources} are the source files directly defined by + that project, either implicitly by residing in the project file's directory, + or explicitly through any of the source-related attributes described below. + More generally, a project @var{proj}'s @dfn{sources} are the immediate sources + of @var{proj} together with the immediate sources (unless overridden) of any + project on which @var{proj} depends (either directly or indirectly). + + @node Basic Syntax + @subsection Basic Syntax + + @noindent + As seen in the earlier examples, project files have an Ada-like syntax. + The minimal project file is: + @smallexample + @group + project Empty is + + end Empty; + @end group + @end smallexample + + @noindent + The identifier @code{Empty} is the name of the project. + This project name must be present after the reserved + word @code{end} at the end of the project file, followed by a semi-colon. + + Any name in a project file, such as the project name or a variable name, + has the same syntax as an Ada identifier. + + The reserved words of project files are the Ada reserved words plus + @code{extends}, @code{external}, and @code{project}. Note that the only Ada + reserved words currently used in project file syntax are: + + @itemize @bullet + @item + @code{case} + @item + @code{end} + @item + @code{for} + @item + @code{is} + @item + @code{others} + @item + @code{package} + @item + @code{renames} + @item + @code{type} + @item + @code{use} + @item + @code{when} + @item + @code{with} + @end itemize + + @noindent + Comments in project files have the same syntax as in Ada, two consecutives + hyphens through the end of the line. + + @node Packages + @subsection Packages + + @noindent + A project file may contain @emph{packages}. The name of a package must be one + of the identifiers (case insensitive) from a predefined list, and a package + with a given name may only appear once in a project file. The predefined list + includes the following packages: + + @itemize @bullet + @item + @code{Naming} + @item + @code{Builder} + @item + @code{Compiler} + @item + @code{Binder} + @item + @code{Linker} + @item + @code{Finder} + @item + @code{Cross_Reference} + @item + @code{gnatls} + @end itemize + + @noindent + (The complete list of the package names and their attributes can be found + in file @file{prj-attr.adb}). + + @noindent + In its simplest form, a package may be empty: + + @smallexample + @group + project Simple is + package Builder is + end Builder; + end Simple; + @end group + @end smallexample + + @noindent + A package may contain @emph{attribute declarations}, + @emph{variable declarations} and @emph{case constructions}, as will be + described below. + + When there is ambiguity between a project name and a package name, + the name always designates the project. To avoid possible confusion, it is + always a good idea to avoid naming a project with one of the + names allowed for packages or any name that starts with @code{gnat}. + + + @node Expressions + @subsection Expressions + + @noindent + An @emph{expression} is either a @emph{string expression} or a + @emph{string list expression}. + + A @emph{string expression} is either a @emph{simple string expression} or a + @emph{compound string expression}. + + A @emph{simple string expression} is one of the following: + @itemize @bullet + @item A literal string; e.g.@code{"comm/my_proj.gpr"} + @item A string-valued variable reference (see @ref{Variables}) + @item A string-valued attribute reference (see @ref{Attributes}) + @item An external reference (see @ref{External References in Project Files}) + @end itemize + + @noindent + A @emph{compound string expression} is a concatenation of string expressions, + using @code{"&"} + @smallexample + Path & "/" & File_Name & ".ads" + @end smallexample + + @noindent + A @emph{string list expression} is either a + @emph{simple string list expression} or a + @emph{compound string list expression}. + + A @emph{simple string list expression} is one of the following: + @itemize @bullet + @item A parenthesized list of zero or more string expressions, separated by commas + @smallexample + File_Names := (File_Name, "gnat.adc", File_Name & ".orig"); + Empty_List := (); + @end smallexample + @item A string list-valued variable reference + @item A string list-valued attribute reference + @end itemize + + @noindent + A @emph{compound string list expression} is the concatenation (using + @code{"&"}) of a simple string list expression and an expression. Note that + each term in a compound string list expression, except the first, may be + either a string expression or a string list expression. + + @smallexample + @group + File_Name_List := () & File_Name; -- One string in this list + Extended_File_Name_List := File_Name_List & (File_Name & ".orig"); + -- Two strings + Big_List := File_Name_List & Extended_File_Name_List; + -- Concatenation of two string lists: three strings + Illegal_List := "gnat.adc" & Extended_File_Name_List; + -- Illegal: must start with a string list + @end group + @end smallexample + + + @node String Types + @subsection String Types + + @noindent + The value of a variable may be restricted to a list of string literals. + The restricted list of string literals is given in a + @emph{string type declaration}. + + Here is an example of a string type declaration: + + @smallexample + type OS is ("NT, "nt", "Unix", "Linux", "other OS"); + @end smallexample + + @noindent + Variables of a string type are called @emph{typed variables}; all other + variables are called @emph{untyped variables}. Typed variables are + particularly useful in @code{case} constructions + (see @ref{case Constructions}). + + A string type declaration starts with the reserved word @code{type}, followed + by the name of the string type (case-insensitive), followed by the reserved + word @code{is}, followed by a parenthesized list of one or more string literals + separated by commas, followed by a semicolon. + + The string literals in the list are case sensitive and must all be different. + They may include any graphic characters allowed in Ada, including spaces. + + A string type may only be declared at the project level, not inside a package. + + A string type may be referenced by its name if it has been declared in the same + project file, or by its project name, followed by a dot, + followed by the string type name. + + + @node Variables + @subsection Variables + + @noindent + A variable may be declared at the project file level, or in a package. + Here are some examples of variable declarations: + + @smallexample + @group + This_OS : OS := external ("OS"); -- a typed variable declaration + That_OS := "Linux"; -- an untyped variable declaration + @end group + @end smallexample + + @noindent + A @emph{typed variable declaration} includes the variable name, followed by a colon, + followed by the name of a string type, followed by @code{:=}, followed by + a simple string expression. + + An @emph{untyped variable declaration} includes the variable name, + followed by @code{:=}, followed by an expression. Note that, despite the + terminology, this form of "declaration" resembles more an assignment + than a declaration in Ada. It is a declaration in several senses: + @itemize @bullet + @item + The variable name does not need to be defined previously + @item + The declaration establishes the @emph{kind} (string versus string list) of the + variable, and later declarations of the same variable need to be consistent + with this + @end itemize + + @noindent + A string variable declaration (typed or untyped) declares a variable + whose value is a string. This variable may be used as a string expression. + @smallexample + File_Name := "readme.txt"; + Saved_File_Name := File_Name & ".saved"; + @end smallexample + + @noindent + A string list variable declaration declares a variable whose value is a list + of strings. The list may contain any number (zero or more) of strings. + + @smallexample + Empty_List := (); + List_With_One_Element := ("-gnaty"); + List_With_Two_Elements := List_With_One_Element & "-gnatg"; + Long_List := ("main.ada", "pack1_.ada", "pack1.ada", "pack2_.ada" + "pack2.ada", "util_.ada", "util.ada"); + @end smallexample + + @noindent + The same typed variable may not be declared more than once at project level, and it may not be declared more than once in any package; it is in effect a constant or a readonly variable. + + The same untyped variable may be declared several times. + In this case, the new value replaces the old one, + and any subsequent reference to the variable uses the new value. + However, as noted above, if a variable has been declared as a string, all subsequent + declarations must give it a string value. Similarly, if a variable has + been declared as a string list, all subsequent declarations + must give it a string list value. + + A @emph{variable reference} may take several forms: + + @itemize @bullet + @item The simple variable name, for a variable in the current package (if any) or in the current project + @item A context name, followed by a dot, followed by the variable name. + @end itemize + + @noindent + A @emph{context} may be one of the following: + + @itemize @bullet + @item The name of an existing package in the current project + @item The name of an imported project of the current project + @item The name of an ancestor project (i.e., a project extended by the current project, either directly or indirectly) + @item An imported/parent project name, followed by a dot, followed by a package name + @end itemize + + @noindent + A variable reference may be used in an expression. + + + @node Attributes + @subsection Attributes + + @noindent + A project (and its packages) may have @emph{attributes} that define the project's properties. + Some attributes have values that are strings; + others have values that are string lists. + + There are two categories of attributes: @emph{simple attributes} and @emph{associative arrays} + (see @ref{Associative Array Attributes}). + + The names of the attributes are restricted; there is a list of project + attributes, and a list of package attributes for each package. + The names are not case sensitive. + + The project attributes are as follows (all are simple attributes): + + @multitable @columnfractions .4 .3 + @item @emph{Attribute Name} + @tab @emph{Value} + @item @code{Source_Files} + @tab string list + @item @code{Source_Dirs} + @tab string list + @item @code{Source_List_File} + @tab string + @item @code{Object_Dir} + @tab string + @item @code{Exec_Dir} + @tab string + @item @code{Main} + @tab string list + @item @code{Languages} + @tab string list + @item @code{Library_Dir} + @tab string + @item @code{Library_Name} + @tab string + @item @code{Library_Kind} + @tab string + @item @code{Library_Elaboration} + @tab string + @item @code{Library_Version} + @tab string + @end multitable + + @noindent + The attributes for package @code{Naming} are as follows + (see @ref{Naming Schemes}): + + @multitable @columnfractions .4 .2 .2 .2 + @item Attribute Name @tab Category @tab Index @tab Value + @item @code{Specification_Suffix} + @tab associative array + @tab language name + @tab string + @item @code{Implementation_Suffix} + @tab associative array + @tab language name + @tab string + @item @code{Separate_Suffix} + @tab simple attribute + @tab n/a + @tab string + @item @code{Casing} + @tab simple attribute + @tab n/a + @tab string + @item @code{Dot_Replacement} + @tab simple attribute + @tab n/a + @tab string + @item @code{Specification} + @tab associative array + @tab Ada unit name + @tab string + @item @code{Implementation} + @tab associative array + @tab Ada unit name + @tab string + @item @code{Specification_Exceptions} + @tab associative array + @tab language name + @tab string list + @item @code{Implementation_Exceptions} + @tab associative array + @tab language name + @tab string list + @end multitable + + @noindent + The attributes for package @code{Builder}, @code{Compiler}, @code{Binder}, + @code{Linker}, @code{Cross_Reference}, and @code{Finder} + are as follows (see @ref{Switches and Project Files}). + + @multitable @columnfractions .4 .2 .2 .2 + @item Attribute Name @tab Category @tab Index @tab Value + @item @code{Default_Switches} + @tab associative array + @tab language name + @tab string list + @item @code{Switches} + @tab associative array + @tab file name + @tab string list + @end multitable + + @noindent + In addition, package @code{Builder} has a single string attribute + @code{Local_Configuration_Pragmas} and package @code{Builder} has a single + string attribute @code{Global_Configuration_Pragmas}. + + @noindent + The attribute for package @code{Glide} are not documented: they are for + internal use only. + + @noindent + Each simple attribute has a default value: the empty string (for string-valued + attributes) and the empty list (for string list-valued attributes). + + Similar to variable declarations, an attribute declaration defines a new value + for an attribute. + + Examples of simple attribute declarations: + + @smallexample + for Object_Dir use "objects"; + for Source_Dirs use ("units", "test/drivers"); + @end smallexample + + @noindent + A @dfn{simple attribute declaration} starts with the reserved word @code{for}, + followed by the name of the attribute, followed by the reserved word + @code{use}, followed by an expression (whose kind depends on the attribute), + followed by a semicolon. + + Attributes may be referenced in expressions. + The general form for such a reference is @code{'}: + the entity for which the attribute is defined, + followed by an apostrophe, followed by the name of the attribute. + For associative array attributes, a litteral string between parentheses + need to be supplied as index. + + Examples are: + + @smallexample + project'Object_Dir + Naming'Dot_Replacement + Imported_Project'Source_Dirs + Imported_Project.Naming'Casing + Builder'Default_Switches("Ada") + @end smallexample + + @noindent + The entity may be: + @itemize @bullet + @item @code{project} for an attribute of the current project + @item The name of an existing package of the current project + @item The name of an imported project + @item The name of a parent project (extended by the current project) + @item An imported/parent project name, followed by a dot, + followed by a package name + @end itemize + + @noindent + Example: + @smallexample + @group + project Prj is + for Source_Dirs use project'Source_Dirs & "units"; + for Source_Dirs use project'Source_Dirs & "test/drivers" + end Prj; + @end group + @end smallexample + + @noindent + In the first attribute declaration, initially the attribute @code{Source_Dirs} + has the default value: an empty string list. After this declaration, + @code{Source_Dirs} is a string list of one element: "units". + After the second attribute declaration @code{Source_Dirs} is a string list of + two elements: "units" and "test/drivers". + + Note: this example is for illustration only. In practice, + the project file would contain only one attribute declaration: + + @smallexample + for Source_Dirs use ("units", "test/drivers"); + @end smallexample + + + @node Associative Array Attributes + @subsection Associative Array Attributes + + @noindent + Some attributes are defined as @emph{associative arrays}. An associative + array may be regarded as a function that takes a string as a parameter + and delivers a string or string list value as its result. + + Here are some examples of associative array attribute declarations: + + @smallexample + for Implementation ("main") use "Main.ada"; + for Switches ("main.ada") use ("-v", "-gnatv"); + for Switches ("main.ada") use Builder'Switches ("main.ada") & "-g"; + @end smallexample + + @noindent + Like untyped variables and simple attributes, associative array attributes may be declared several times. Each declaration supplies a new value for the + attribute, replacing the previous setting. + + + @node case Constructions + @subsection @code{case} Constructions + + @noindent + A @code{case} construction is used in a project file to effect conditional + behavior. + Here is a typical example: + + @smallexample + @group + project MyProj is + type OS_Type is ("Linux", "Unix", "NT", "VMS"); + + OS : OS_Type := external ("OS", "Linux"); + @end group + + @group + package Compiler is + case OS is + when "Linux" | "Unix" => + for Default_Switches ("Ada") use ("-gnath"); + when "NT" => + for Default_Switches ("Ada") use ("-gnatP"); + when others => + end case; + end Compiler; + end MyProj; + @end group + @end smallexample + + @noindent + The syntax of a @code{case} construction is based on the Ada case statement + (although there is no @code{null} construction for empty alternatives). + + Following the reserved word @code{case} there is the case variable (a typed + string variable), the reserved word @code{is}, and then a sequence of one or + more alternatives. + Each alternative comprises the reserved word @code{when}, either a list of + literal strings separated by the @code{"|"} character or the reserved word + @code{others}, and the @code{"=>"} token. + Each literal string must belong to the string type that is the type of the + case variable. + An @code{others} alternative, if present, must occur last. + The @code{end case;} sequence terminates the case construction. + + After each @code{=>}, there are zero or more constructions. The only + constructions allowed in a case construction are other case constructions and + attribute declarations. String type declarations, variable declarations and + package declarations are not allowed. + + The value of the case variable is often given by an external reference + (see @ref{External References in Project Files}). + + + @c **************************************** + @c * Objects and Sources in Project Files * + @c **************************************** + + @node Objects and Sources in Project Files + @section Objects and Sources in Project Files + + @menu + * Object Directory:: + * Exec Directory:: + * Source Directories:: + * Source File Names:: + @end menu + + @noindent + Each project has exactly one object directory and one or more source + directories. The source directories must contain at least one source file, + unless the project file explicitly specifies that no source files are present + (see @ref{Source File Names}). + + + @node Object Directory + @subsection Object Directory + + @noindent + The object directory for a project is the directory containing the compiler's + output (such as @file{ALI} files and object files) for the project's immediate + sources. Note that for inherited sources (when extending a parent project) the + parent project's object directory is used. + + The object directory is given by the value of the attribute @code{Object_Dir} + in the project file. + + @smallexample + for Object_Dir use "objects"; + @end smallexample + + @noindent + The attribute @var{Object_Dir} has a string value, the path name of the object + directory. The path name may be absolute or relative to the directory of the + project file. This directory must already exist, and be readable and writable. + + By default, when the attribute @code{Object_Dir} is not given an explicit value + or when its value is the empty string, the object directory is the same as the + directory containing the project file. + + + @node Exec Directory + @subsection Exec Directory + + @noindent + The exec directory for a project is the directory containing the executables + for the project's main subprograms. + + The exec directory is given by the value of the attribute @code{Exec_Dir} + in the project file. + + @smallexample + for Exec_Dir use "executables"; + @end smallexample + + @noindent + The attribute @var{Exec_Dir} has a string value, the path name of the exec + directory. The path name may be absolute or relative to the directory of the + project file. This directory must already exist, and be writable. + + By default, when the attribute @code{Exec_Dir} is not given an explicit value + or when its value is the empty string, the exec directory is the same as the + object directory of the project file. + + + @node Source Directories + @subsection Source Directories + + @noindent + The source directories of a project are specified by the project file + attribute @code{Source_Dirs}. + + This attribute's value is a string list. If the attribute is not given an + explicit value, then there is only one source directory, the one where the + project file resides. + + A @code{Source_Dirs} attribute that is explicitly defined to be the empty list, + as in + + @smallexample + for Source_Dirs use (); + @end smallexample + + @noindent + indicates that the project contains no source files. + + Otherwise, each string in the string list designates one or more + source directories. + + @smallexample + for Source_Dirs use ("sources", "test/drivers"); + @end smallexample + + @noindent + If a string in the list ends with @code{"/**"}, then the directory whose path + name precedes the two asterisks, as well as all its subdirectories + (recursively), are source directories. + + @smallexample + for Source_Dirs use ("/system/sources/**"); + @end smallexample + + @noindent + Here the directory @code{/system/sources} and all of its subdirectories + (recursively) are source directories. + + To specify that the source directories are the directory of the project file + and all of its subdirectories, you can declare @code{Source_Dirs} as follows: + @smallexample + for Source_Dirs use ("./**"); + @end smallexample + + @noindent + Each of the source directories must exist and be readable. + + + @node Source File Names + @subsection Source File Names + + @noindent + In a project that contains source files, their names may be specified by the + attributes @code{Source_Files} (a string list) or @code{Source_List_File} + (a string). Source file names never include any directory information. + + If the attribute @code{Source_Files} is given an explicit value, then each + element of the list is a source file name. + + @smallexample + for Source_Files use ("main.adb"); + for Source_Files use ("main.adb", "pack1.ads", "pack2.adb"); + @end smallexample + + @noindent + If the attribute @code{Source_Files} is not given an explicit value, + but the attribute @code{Source_List_File} is given a string value, + then the source file names are contained in the text file whose path name + (absolute or relative to the directory of the project file) is the + value of the attribute @code{Source_List_File}. + + Each line in the file that is not empty or is not a comment + contains a source file name. A comment line starts with two hyphens. + + @smallexample + for Source_List_File use "source_list.txt"; + @end smallexample + + @noindent + By default, if neither the attribute @code{Source_Files} nor the attribute + @code{Source_List_File} is given an explicit value, then each file in the + source directories that conforms to the project's naming scheme + (see @ref{Naming Schemes}) is an immediate source of the project. + + A warning is issued if both attributes @code{Source_Files} and + @code{Source_List_File} are given explicit values. In this case, the attribute + @code{Source_Files} prevails. + + Each source file name must be the name of one and only one existing source file + in one of the source directories. + + A @code{Source_Files} attribute defined with an empty list as its value + indicates that there are no source files in the project. + + Except for projects that are clearly specified as containing no Ada source + files (@code{Source_Dirs} or @code{Source_Files} specified as an empty list, + or @code{Languages} specified without @code{"Ada"} in the list) + @smallexample + for Source_Dirs use (); + for Source_Files use (); + for Languages use ("C", "C++"); + @end smallexample + + @noindent + a project must contain at least one immediate source. + + Projects with no source files are useful as template packages + (see @ref{Packages in Project Files}) for other projects; in particular to + define a package @code{Naming} (see @ref{Naming Schemes}). + + + @c **************************** + @c * Importing Projects * + @c **************************** + + @node Importing Projects + @section Importing Projects + + @noindent + An immediate source of a project P may depend on source files that + are neither immediate sources of P nor in the predefined library. + To get this effect, P must @emph{import} the projects that contain the needed + source files. + + @smallexample + @group + with "project1", "utilities.gpr"; + with "/namings/apex.gpr"; + project Main is + ... + @end group + @end smallexample + + @noindent + As can be seen in this example, the syntax for importing projects is similar + to the syntax for importing compilation units in Ada. However, project files + use literal strings instead of names, and the @code{with} clause identifies + project files rather than packages. + + Each literal string is the file name or path name (absolute or relative) of a + project file. If a string is simply a file name, with no path, then its + location is determined by the @emph{project path}: + + @itemize @bullet + @item + If the environment variable @env{ADA_PROJECT_PATH} exists, then the project + path includes all the directories in this environment variable, plus the + directory of the project file. + + @item + If the environment variable @env{ADA_PROJECT_PATH} does not exist, + then the project path contains only one directory, namely the one where + the project file is located. + @end itemize + + @noindent + If a relative pathname is used as in + + @smallexample + with "tests/proj"; + @end smallexample + + @noindent + then the path is relative to the directory where the importing project file is + located. Any symbolic link will be fully resolved in the directory + of the importing project file before the imported project file is looked up. + + When the @code{with}'ed project file name does not have an extension, + the default is @file{.gpr}. If a file with this extension is not found, then + the file name as specified in the @code{with} clause (no extension) will be + used. In the above example, if a file @code{project1.gpr} is found, then it + will be used; otherwise, if a file @code{project1} exists then it will be used; + if neither file exists, this is an error. + + A warning is issued if the name of the project file does not match the + name of the project; this check is case insensitive. + + Any source file that is an immediate source of the imported project can be + used by the immediate sources of the importing project, and recursively. Thus + if @code{A} imports @code{B}, and @code{B} imports @code{C}, the immediate + sources of @code{A} may depend on the immediate sources of @code{C}, even if + @code{A} does not import @code{C} explicitly. However, this is not recommended, + because if and when @code{B} ceases to import @code{C}, some sources in + @code{A} will no longer compile. + + A side effect of this capability is that cyclic dependences are not permitted: + if @code{A} imports @code{B} (directly or indirectly) then @code{B} is not + allowed to import @code{A}. + + + @c ********************* + @c * Project Extension * + @c ********************* + + @node Project Extension + @section Project Extension + + @noindent + During development of a large system, it is sometimes necessary to use + modified versions of some of the source files without changing the original + sources. This can be achieved through a facility known as + @emph{project extension}. + + @smallexample + project Modified_Utilities extends "/baseline/utilities.gpr" is ... + @end smallexample + + @noindent + The project file for the project being extended (the @emph{parent}) is + identified by the literal string that follows the reserved word @code{extends}, + which itself follows the name of the extending project (the @emph{child}). + + By default, a child project inherits all the sources of its parent. + However, inherited sources can be overridden: a unit with the same name as one + in the parent will hide the original unit. + Inherited sources are considered to be sources (but not immediate sources) + of the child project; see @ref{Project File Syntax}. + + An inherited source file retains any switches specified in the parent project. + + For example if the project @code{Utilities} contains the specification and the + body of an Ada package @code{Util_IO}, then the project + @code{Modified_Utilities} can contain a new body for package @code{Util_IO}. + The original body of @code{Util_IO} will not be considered in program builds. + However, the package specification will still be found in the project + @code{Utilities}. + + A child project can have only one parent but it may import any number of other + projects. + + A project is not allowed to import directly or indirectly at the same time a + child project and any of its ancestors. + + + @c **************************************** + @c * External References in Project Files * + @c **************************************** + + @node External References in Project Files + @section External References in Project Files + + @noindent + A project file may contain references to external variables; such references + are called @emph{external references}. + + An external variable is either defined as part of the environment (an + environment variable in Unix, for example) or else specified on the command + line via the @option{-X@emph{vbl}=@emph{value}} switch. If both, then the + command line value is used. + + An external reference is denoted by the built-in function + @code{external}, which returns a string value. This function has two forms: + @itemize @bullet + @item @code{external (external_variable_name)} + @item @code{external (external_variable_name, default_value)} + @end itemize + + @noindent + Each parameter must be a string literal. For example: + + @smallexample + external ("USER") + external ("OS", "Linux") + @end smallexample + + @noindent + In the form with one parameter, the function returns the value of + the external variable given as parameter. If this name is not present in the + environment, then the returned value is an empty string. + + In the form with two string parameters, the second parameter is + the value returned when the variable given as the first parameter is not + present in the environment. In the example above, if @code{"OS"} is not + the name of an environment variable and is not passed on the command line, + then the returned value will be @code{"Linux"}. + + An external reference may be part of a string expression or of a string + list expression, to define variables or attributes. + + @smallexample + @group + type Mode_Type is ("Debug", "Release"); + Mode : Mode_Type := external ("MODE"); + case Mode is + when "Debug" => + ... + @end group + @end smallexample + + + @c ***************************** + @c * Packages in Project Files * + @c ***************************** + + @node Packages in Project Files + @section Packages in Project Files + + @noindent + The @emph{package} is the project file feature that defines the settings for + project-aware tools. + For each such tool you can declare a corresponding package; the names for these + packages are preset (see @ref{Packages}) but are not case sensitive. + A package may contain variable declarations, attribute declarations, and case + constructions. + + @smallexample + @group + project Proj is + package Builder is -- used by gnatmake + for Default_Switches ("Ada") use ("-v", "-g"); + end Builder; + end Proj; + @end group + @end smallexample + + @noindent + A package declaration starts with the reserved word @code{package}, + followed by the package name (case insensitive), followed by the reserved word + @code{is}. It ends with the reserved word @code{end}, followed by the package + name, finally followed by a semi-colon. + + Most of the packages have an attribute @code{Default_Switches}. + This attribute is an associative array, and its value is a string list. + The index of the associative array is the name of a programming language (case + insensitive). This attribute indicates the switch or switches to be used + with the corresponding tool. + + Some packages also have another attribute, @code{Switches}, an associative + array whose value is a string list. The index is the name of a source file. + This attribute indicates the switch or switches to be used by the corresponding + tool when dealing with this specific file. + + Further information on these switch-related attributes is found in + @ref{Switches and Project Files}. + + A package may be declared as a @emph{renaming} of another package; e.g., from + the project file for an imported project. + + @smallexample + @group + with "/global/apex.gpr"; + project Example is + package Naming renames Apex.Naming; + ... + end Example; + @end group + @end smallexample + + @noindent + Packages that are renamed in other project files often come from project files + that have no sources: they are just used as templates. Any modification in the + template will be reflected automatically in all the project files that rename + a package from the template. + + In addition to the tool-oriented packages, you can also declare a package + named @code{Naming} to establish specialized source file naming conventions + (see @ref{Naming Schemes}). + + + @c ************************************ + @c * Variables from Imported Projects * + @c ************************************ + + @node Variables from Imported Projects + @section Variables from Imported Projects + + @noindent + An attribute or variable defined in an imported or parent project can + be used in expressions in the importing / extending project. + Such an attribute or variable is prefixed with the name of the project + and (if relevant) the name of package where it is defined. + + @smallexample + @group + with "imported"; + project Main extends "base" is + Var1 := Imported.Var; + Var2 := Base.Var & ".new"; + @end group + + @group + package Builder is + for Default_Switches ("Ada") use Imported.Builder.Ada_Switches & + "-gnatg" & "-v"; + end Builder; + @end group + + @group + package Compiler is + for Default_Switches ("Ada") use Base.Compiler.Ada_Switches; + end Compiler; + end Main; + @end group + @end smallexample + + @noindent + In this example: + + @itemize @bullet + @item + @code{Var1} is a copy of the variable @code{Var} defined in the project file + @file{"imported.gpr"} + @item + the value of @code{Var2} is a copy of the value of variable @code{Var} + defined in the project file @file{base.gpr}, concatenated with @code{".new"} + @item + attribute @code{Default_Switches ("Ada")} in package @code{Builder} + is a string list that includes in its value a copy of variable + @code{Ada_Switches} defined in the @code{Builder} package in project file + @file{imported.gpr} plus two new elements: @option{"-gnatg"} and @option{"-v"}; + @item + attribute @code{Default_Switches ("Ada")} in package @code{Compiler} + is a copy of the variable @code{Ada_Switches} defined in the @code{Compiler} + package in project file @file{base.gpr}, the project being extended. + @end itemize + + + @c ****************** + @c * Naming Schemes * + @c ****************** + + @node Naming Schemes + @section Naming Schemes + + @noindent + Sometimes an Ada software system is ported from a foreign compilation + environment to GNAT, with file names that do not use the default GNAT + conventions. Instead of changing all the file names (which for a variety of + reasons might not be possible), you can define the relevant file naming scheme + in the @code{Naming} package in your project file. For example, the following + package models the Apex file naming rules: + + @smallexample + @group + package Naming is + for Casing use "lowercase"; + for Dot_Replacement use "."; + for Specification_Suffix ("Ada") use ".1.ada"; + for Implementation_Suffix ("Ada") use ".2.ada"; + end Naming; + @end group + @end smallexample + + @noindent + You can define the following attributes in package @code{Naming}: + + @table @code + + @item @var{Casing} + This must be a string with one of the three values @code{"lowercase"}, + @code{"uppercase"} or @code{"mixedcase"}; these strings are case insensitive. + + @noindent + If @var{Casing} is not specified, then the default is @code{"lowercase"}. + + @item @var{Dot_Replacement} + This must be a string whose value satisfies the following conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start or end with an alphanumeric character + @item It cannot be a single underscore + @item It cannot start with an underscore followed by an alphanumeric + @item It cannot contain a dot @code{'.'} except if it the entire string is @code{"."} + @end itemize + + @noindent + If @code{Dot_Replacement} is not specified, then the default is @code{"-"}. + + @item @var{Specification_Suffix} + This is an associative array (indexed by the programming language name, case + insensitive) whose value is a string that must satisfy the following + conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start with an alphanumeric character + @item It cannot start with an underscore followed by an alphanumeric character + @end itemize + @noindent + If @code{Specification_Suffix ("Ada")} is not specified, then the default is + @code{".ads"}. + + @item @var{Implementation_Suffix} + This is an associative array (indexed by the programming language name, case + insensitive) whose value is a string that must satisfy the following + conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start with an alphanumeric character + @item It cannot start with an underscore followed by an alphanumeric character + @item It cannot be a suffix of @code{Specification_Suffix} + @end itemize + @noindent + If @code{Implementation_Suffix ("Ada")} is not specified, then the default is + @code{".adb"}. + + @item @var{Separate_Suffix} + This must be a string whose value satisfies the same conditions as + @code{Implementation_Suffix}. + + @noindent + If @code{Separate_Suffix ("Ada")} is not specified, then it defaults to same + value as @code{Implementation_Suffix ("Ada")}. + + @item @var{Specification} + @noindent + You can use the @code{Specification} attribute, an associative array, to define + the source file name for an individual Ada compilation unit's spec. The array + index must be a string literal that identifies the Ada unit (case insensitive). + The value of this attribute must be a string that identifies the file that + contains this unit's spec (case sensitive or insensitive depending on the + operating system). + + @smallexample + for Specification ("MyPack.MyChild") use "mypack.mychild.spec"; + @end smallexample + + @item @var{Implementation} + + You can use the @code{Implementation} attribute, an associative array, to + define the source file name for an individual Ada compilation unit's body + (possibly a subunit). The array index must be a string literal that identifies + the Ada unit (case insensitive). The value of this attribute must be a string + that identifies the file that contains this unit's body or subunit (case + sensitive or insensitive depending on the operating system). + + @smallexample + for Implementation ("MyPack.MyChild") use "mypack.mychild.body"; + @end smallexample + @end table + + + @c ******************** + @c * Library Projects * + @c ******************** + + @node Library Projects + @section Library Projects + + @noindent + @emph{Library projects} are projects whose object code is placed in a library. + (Note that this facility is not yet supported on all platforms) + + To create a library project, you need to define in its project file + two project-level attributes: @code{Library_Name} and @code{Library_Dir}. + Additionally, you may define the library-related attributes + @code{Library_Kind}, @code{Library_Version} and @code{Library_Elaboration}. + + The @code{Library_Name} attribute has a string value that must start with a + letter and include only letters and digits. + + The @code{Library_Dir} attribute has a string value that designates the path + (absolute or relative) of the directory where the library will reside. + It must designate an existing directory, and this directory needs to be + different from the project's object directory. It also needs to be writable. + + If both @code{Library_Name} and @code{Library_Dir} are specified and + are legal, then the project file defines a library project. The optional + library-related attributes are checked only for such project files. + + The @code{Library_Kind} attribute has a string value that must be one of the + following (case insensitive): @code{"static"}, @code{"dynamic"} or + @code{"relocatable"}. If this attribute is not specified, the library is a + static library. Otherwise, the library may be dynamic or relocatable. + Depending on the operating system, there may or may not be a distinction + between dynamic and relocatable libraries. For example, on Unix there is no + such distinction. + + The @code{Library_Version} attribute has a string value whose interpretation + is platform dependent. On Unix, it is used only for dynamic/relocatable + libraries as the internal name of the library (the @code{"soname"}). If the + library file name (built from the @code{Library_Name}) is different from the + @code{Library_Version}, then the library file will be a symbolic link to the + actual file whose name will be @code{Library_Version}. + + Example (on Unix): + + @smallexample + @group + project Plib is + + Version := "1"; + + for Library_Dir use "lib_dir"; + for Library_Name use "dummy"; + for Library_Kind use "relocatable"; + for Library_Version use "libdummy.so." & Version; + + end Plib; + @end group + @end smallexample + + @noindent + Directory @file{lib_dir} will contain the internal library file whose name + will be @file{libdummy.so.1}, and @file{libdummy.so} will be a symbolic link to + @file{libdummy.so.1}. + + When @command{gnatmake} detects that a project file (not the main project file) + is a library project file, it will check all immediate sources of the project + and rebuild the library if any of the sources have been recompiled. + All @file{ALI} files will also be copied from the object directory to the + library directory. To build executables, @command{gnatmake} will use the + library rather than the individual object files. + + + @c ************************************* + @c * Switches Related to Project Files * + @c ************************************* + @node Switches Related to Project Files + @section Switches Related to Project Files + + @noindent + The following switches are used by GNAT tools that support project files: + + @table @code + + @item @option{-P@var{project}} + Indicates the name of a project file. This project file will be parsed with + the verbosity indicated by @option{-vP@emph{x}}, if any, and using the external + references indicated by @option{-X} switches, if any. + + @noindent + There must be only one @option{-P} switch on the command line. + + @noindent + Since the Project Manager parses the project file only after all the switches + on the command line are checked, the order of the switches @option{-P}, + @option{-Vp@emph{x}} or @option{-X} is not significant. + + @item @option{-X@var{name=value}} + Indicates that external variable @var{name} has the value @var{value}. + The Project Manager will use this value for occurrences of + @code{external(name)} when parsing the project file. + + @noindent + If @var{name} or @var{value} includes a space, then @var{name=value} should be + put between quotes. + @smallexample + -XOS=NT + -X"user=John Doe" + @end smallexample + + @noindent + Several @option{-X} switches can be used simultaneously. + If several @option{-X} switches specify the same @var{name}, only the last one + is used. + + @noindent + An external variable specified with a @option{-X} switch takes precedence + over the value of the same name in the environment. + + @item @option{-vP@emph{x}} + Indicates the verbosity of the parsing of GNAT project files. + @option{-vP0} means Default (no output for syntactically correct project + files); + @option{-vP1} means Medium; + @option{-vP2} means High. + @noindent + The default is Default. + @noindent + If several @option{-vP@emph{x}} switches are present, only the last one is + used. + + @end table + + + @c ********************************** + @c * Tools Supporting Project Files * + @c ********************************** + + @node Tools Supporting Project Files + @section Tools Supporting Project Files + + @menu + * gnatmake and Project Files:: + * The GNAT Driver and Project Files:: + * Glide and Project Files:: + @end menu + + @node gnatmake and Project Files + @subsection gnatmake and Project Files + + @noindent + This section covers two topics related to @command{gnatmake} and project files: + defining switches for @command{gnatmake} and for the tools that it invokes; + and the use of the @code{Main} attribute. + + @menu + * Switches and Project Files:: + * Project Files and Main Subprograms:: + @end menu + + @node Switches and Project Files + @subsubsection Switches and Project Files + + @noindent + For each of the packages @code{Builder}, @code{Compiler}, @code{Binder}, and + @code{Linker}, you can specify a @code{Default_Switches} attribute, a + @code{Switches} attribute, or both; as their names imply, these switch-related + attributes affect which switches are used for which files when + @command{gnatmake} is invoked. As will be explained below, these + package-contributed switches precede the switches passed on the + @command{gnatmake} command line. + + The @code{Default_Switches} attribute is an associative array indexed by + language name (case insensitive) and returning a string list. For example: + + @smallexample + @group + package Compiler is + for Default_Switches ("Ada") use ("-gnaty", "-v"); + end Compiler; + @end group + @end smallexample + + @noindent + The @code{Switches} attribute is also an associative array, indexed by a file + name (which may or may not be case sensitive, depending on the operating + system) and returning a string list. For example: + + @smallexample + @group + package Builder is + for Switches ("main1.adb") use ("-O2"); + for Switches ("main2.adb") use ("-g"); + end Builder; + @end group + @end smallexample + + @noindent + For the @code{Builder} package, the file names should designate source files + for main subprograms. For the @code{Binder} and @code{Linker} packages, the + file names should designate @file{ALI} or source files for main subprograms. + In each case just the file name (without explicit extension) is acceptable. + + For each tool used in a program build (@command{gnatmake}, the compiler, the + binder, and the linker), its corresponding package @dfn{contributes} a set of + switches for each file on which the tool is invoked, based on the + switch-related attributes defined in the package. In particular, the switches + that each of these packages contributes for a given file @var{f} comprise: + + @itemize @bullet + @item + the value of attribute @code{Switches (@var{f})}, if it is specified in the + package for the given file, + @item + otherwise, the value of @code{Default_Switches ("Ada")}, if it is specified in + the package. + @end itemize + + @noindent + If neither of these attributes is defined in the package, then the package does + not contribute any switches for the given file. + + When @command{gnatmake} is invoked on a file, the switches comprise two sets, + in the following order: those contributed for the file by the @code{Builder} + package; and the switches passed on the command line. + + When @command{gnatmake} invokes a tool (compiler, binder, linker) on a file, + the switches passed to the tool comprise three sets, in the following order: + + @enumerate + @item + the applicable switches contributed for the file by the @code{Builder} package + in the project file supplied on the command line; + + @item + those contributed for the file by the package (in the relevant project file -- + see below) corresponding to the tool; and + + @item + the applicable switches passed on the command line. + @end enumerate + + @noindent + The term @emph{applicable switches} reflects the fact that @command{gnatmake} + switches may or may not be passed to individual tools, depending on the + individual switch. + + @command{gnatmake} may invoke the compiler on source files from different + projects. The Project Manager will use the appropriate project file to + determine the @code{Compiler} package for each source file being compiled. + Likewise for the @code{Binder} and @code{Linker} packages. + + As an example, consider the following package in a project file: + + @smallexample + @group + project Proj1 is + package Compiler is + for Default_Switches ("Ada") use ("-g"); + for Switches ("a.adb") use ("-O1"); + for Switches ("b.adb") use ("-O2", "-gnaty"); + end Compiler; + end Proj1; + @end group + @end smallexample + + @noindent + If @command{gnatmake} is invoked with this project file, and it needs to + compile, say, the files @file{a.adb}, @file{b.adb}, and @file{c.adb}, then + @file{a.adb} will be compiled with the switch @option{-O1}, @file{b.adb} + with switches @option{-O2} and @option{-gnaty}, and @file{c.adb} with + @option{-g}. + + Another example illustrates the ordering of the switches contributed by + different packages: + + @smallexample + @group + project Proj2 is + package Builder is + for Switches ("main.adb") use ("-g", "-O1", "-f"); + end Builder; + @end group + + @group + package Compiler is + for Switches ("main.adb") use ("-O2"); + end Compiler; + end Proj2; + @end group + @end smallexample + + @noindent + If you issue the command: + + @smallexample + gnatmake -PProj2 -O0 main + @end smallexample + + @noindent + then the compiler will be invoked on @file{main.adb} with the following sequence of switches + + @smallexample + -g -O1 -O2 -O0 + @end smallexample + + with the last @option{-O} switch having precedence over the earlier ones; + several other switches (such as @option{-c}) are added implicitly. + + The switches @option{-g} and @option{-O1} are contributed by package + @code{Builder}, @option{-O2} is contributed by the package @code{Compiler} + and @option{-O0} comes from the command line. + + The @option{-g} switch will also be passed in the invocation of + @command{gnatlink.} + + A final example illustrates switch contributions from packages in different + project files: + + @smallexample + @group + project Proj3 is + for Source_Files use ("pack.ads", "pack.adb"); + package Compiler is + for Default_Switches ("Ada") use ("-gnata"); + end Compiler; + end Proj3; + @end group + + @group + with "Proj3"; + project Proj4 is + for Source_Files use ("foo_main.adb", "bar_main.adb"); + package Builder is + for Switches ("foo_main.adb") use ("-s", "-g"); + end Builder; + end Proj4; + @end group + + @group + -- Ada source file: + with Pack; + procedure Foo_Main is + ... + end Foo_Main; + @end group + @end smallexample + + If the command is + @smallexample + gnatmake -PProj4 foo_main.adb -cargs -gnato + @end smallexample + + @noindent + then the switches passed to the compiler for @file{foo_main.adb} are + @option{-g} (contributed by the package @code{Proj4.Builder}) and + @option{-gnato} (passed on the command line). + When the imported package @code{Pack} is compiled, the switches used are + @option{-g} from @code{Proj4.Builder}, @option{-gnata} (contributed from + package @code{Proj3.Compiler}, and @option{-gnato} from the command line. + + + @node Project Files and Main Subprograms + @subsubsection Project Files and Main Subprograms + + @noindent + When using a project file, you can invoke @command{gnatmake} + with several main subprograms, by specifying their source files on the command + line. Each of these needs to be an immediate source file of the project. + + @smallexample + gnatmake -Pprj main1 main2 main3 + @end smallexample + + @noindent + When using a project file, you can also invoke @command{gnatmake} without + explicitly specifying any main, and the effect depends on whether you have + defined the @code{Main} attribute. This attribute has a string list value, + where each element in the list is the name of a source file (the file + extension is optional) containing a main subprogram. + + If the @code{Main} attribute is defined in a project file as a non-empty + string list and the switch @option{-u} is not used on the command line, then + invoking @command{gnatmake} with this project file but without any main on the + command line is equivalent to invoking @command{gnatmake} with all the file + names in the @code{Main} attribute on the command line. + + Example: + @smallexample + @group + project Prj is + for Main use ("main1", "main2", "main3"); + end Prj; + @end group + @end smallexample + + @noindent + With this project file, @code{"gnatmake -Pprj"} is equivalent to + @code{"gnatmake -Pprj main1 main2 main3"}. + + When the project attribute @code{Main} is not specified, or is specified + as an empty string list, or when the switch @option{-u} is used on the command + line, then invoking @command{gnatmake} with no main on the command line will + result in all immediate sources of the project file being checked, and + potentially recompiled. Depending on the presence of the switch @option{-u}, + sources from other project files on which the immediate sources of the main + project file depend are also checked and potentially recompiled. In other + words, the @option{-u} switch is applied to all of the immediate sources of themain project file. + + + @node The GNAT Driver and Project Files + @subsection The GNAT Driver and Project Files + + @noindent + A number of GNAT tools, other than @command{gnatmake} are project-aware: + @command{gnatbind}, @command{gnatfind}, @command{gnatlink}, @command{gnatls} + and @command{gnatxref}. However, none of these tools can be invoked directly + with a project file switch (@code{-P}). They need to be invoke through the + @command{gnat} driver. + + The @command{gnat} driver is a front-end that accepts a number of commands and + call the corresponding tool. It has been designed initially for VMS to convert + VMS style qualifiers to Unix style switches, but it is now available to all + the GNAT supported platforms. + + On non VMS platforms, the @command{gnat} driver accepts the following commands + (case insensitive): + + @itemize @bullet + @item + BIND to invoke @command{gnatbind} + @item + CHOP to invoke @command{gnatchop} + @item + COMP or COMPILE to invoke the compiler + @item + ELIM to invoke @command{gnatelim} + @item + FIND to invoke @command{gnatfind} + @item + KR or KRUNCH to invoke @command{gnatkr} + @item + LINK to invoke @command{gnatlink} + @item + LS or LIST to invoke @command{gnatls} + @item + MAKE to invoke @command{gnatmake} + @item + NAME to invoke @command{gnatname} + @item + PREP or PREPROCESS to invoke @command{gnatprep} + @item + PSTA or STANDARD to invoke @command{gnatpsta} + @item + STUB to invoke @command{gnatstub} + @item + XREF to invoke @command{gnatxref} + @end itemize + + @noindent + Note that the compiler is invoked using the command @command{gnatmake -f -u}. + + @noindent + Following the command, you may put switches and arguments for the invoked + tool. + + @smallexample + gnat bind -C main.ali + gnat ls -a main + gnat chop foo.txt + @end smallexample + + @noindent + In addition, for command BIND, FIND, LS or LIST, LINK and XREF, the project + file related switches (@code{-P}, @code{-X} and @code{-vPx}) may be used in + addition to the switches of the invoking tool. + + @noindent + For each of these command, there is possibly a package in the main project that + corresponds to the invoked tool. + + @itemize @bullet + @item + package @code{Binder} for command BIND (invoking @code{gnatbind}) + + @item + package @code{Finder} for command FIND (invoking @code{gnatfind}) + + @item + package @code{Gnatls} for command LS or LIST (invoking @code{gnatls}) + + @item + package @code{Linker} for command LINK (invoking @code{gnatlink}) + + @item + package @code{Cross_Reference} for command XREF (invoking @code{gnatlink}) + + @end itemize + + @noindent + Package @code{Gnatls} has a unique attribute @code{Switches}, a simple variable + with a string list value. It contains switches for the invocation of + @code{gnatls}. + + @smallexample + @group + project Proj1 is + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + end Proj1; + @end group + @end smallexample + + @noindent + All other packages contains a switch @code{Default_Switches}, an associative + array, indexed by the programming language (case insensitive) and having a + string list value. @code{Default_Switches ("Ada")} contains the switches for + the invocation of the tool corresponding to the package. + + @smallexample + @group + project Proj is + + for Source_Dirs use ("./**"); + + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + @end group + @group + + package Binder is + for Default_Switches ("Ada") use ("-C", "-e"); + end Binder; + @end group + @group + + package Linker is + for Default_Switches ("Ada") use ("-C"); + end Linker; + @end group + @group + + package Finder is + for Default_Switches ("Ada") use ("-a", "-f"); + end Finder; + @end group + @group + + package Cross_Reference is + for Default_Switches ("Ada") use ("-a", "-f", "-d", "-u"); + end Cross_Reference; + end Proj; + @end group + @end smallexample + + @noindent + With the above project file, commands such as + + @smallexample + gnat ls -Pproj main + gnat xref -Pproj main + gnat bind -Pproj main.ali + @end smallexample + + @noindent + will set up the environment properly and invoke the tool with the switches + found in the package corresponding to the tool. + + + @node Glide and Project Files + @subsection Glide and Project Files + + @noindent + Glide will automatically recognize the @file{.gpr} extension for + project files, and will + convert them to its own internal format automatically. However, it + doesn't provide a syntax-oriented editor for modifying these + files. + The project file will be loaded as text when you select the menu item + @code{Ada} @result{} @code{Project} @result{} @code{Edit}. + You can edit this text and save the @file{gpr} file; + when you next select this project file in Glide it + will be automatically reloaded. + + Glide uses the @code{gnatlist} attribute in the @code{Ide} package, whose value + is something like @code{powerpc-wrs-vxworks-gnatls}, to compute the + cross-prefix. From this information the correct location for the + GNAT runtime, and thus also the correct cross-references, can be + determined. + + + @node An Extended Example + @section An Extended Example + + @noindent + Suppose that we have two programs, @var{prog1} and @var{prog2}, with the sources + in the respective directories. We would like to build them with a single + @command{gnatmake} command, and we would like to place their object files into + @file{.build} subdirectories of the source directories. Furthermore, we would + like to have to have two separate subdirectories in @file{.build} -- + @file{release} and @file{debug} -- which will contain the object files compiled with + different set of compilation flags. + + In other words, we have the following structure: + + @smallexample + @group + main + |- prog1 + | |- .build + | | debug + | | release + |- prog2 + |- .build + | debug + | release + @end group + @end smallexample + + @noindent + Here are the project files that we need to create in a directory @file{main} + to maintain this structure: + + @enumerate + + @item We create a @code{Common} project with a package @code{Compiler} that + specifies the compilation switches: + + @smallexample + File "common.gpr": + @group + @b{project} Common @b{is} + + @b{for} Source_Dirs @b{use} (); -- No source files + @end group + + @group + @b{type} Build_Type @b{is} ("release", "debug"); + Build : Build_Type := External ("BUILD", "debug"); + @end group + @group + @b{package} Compiler @b{is} + @b{case} Build @b{is} + @b{when} "release" => + @b{for} Default_Switches ("Ada") @b{use} ("-O2"); + @b{when} "debug" => + @b{for} Default_Switches ("Ada") @b{use} ("-g"); + @b{end case}; + @b{end} Compiler; + + @b{end} Common; + @end group + @end smallexample + + @item We create separate projects for the two programs: + + @smallexample + @group + File "prog1.gpr": + + @b{with} "common"; + @b{project} Prog1 @b{is} + + @b{for} Source_Dirs @b{use} ("prog1"); + @b{for} Object_Dir @b{use} "prog1/.build/" & Common.Build; + + @b{package} Compiler @b{renames} Common.Compiler; + + @b{end} Prog1; + @end group + @end smallexample + + @smallexample + @group + File "prog2.gpr": + + @b{with} "common"; + @b{project} Prog2 @b{is} + + @b{for} Source_Dirs @b{use} ("prog2"); + @b{for} Object_Dir @b{use} "prog2/.build/" & Common.Build; + + @b{package} Compiler @b{renames} Common.Compiler; + + @end group + @b{end} Prog2; + @end smallexample + + @item We create a wrapping project @var{Main}: + + @smallexample + @group + File "main.gpr": + + @b{with} "common"; + @b{with} "prog1"; + @b{with} "prog2"; + @b{project} Main @b{is} + + @b{package} Compiler @b{renames} Common.Compiler; + + @b{end} Main; + @end group + @end smallexample + + @item Finally we need to create a dummy procedure that @code{with}s (either + explicitly or implicitly) all the sources of our two programs. + + @end enumerate + + @noindent + Now we can build the programs using the command + + @smallexample + gnatmake -Pmain dummy + @end smallexample + + @noindent + for the Debug mode, or + + @smallexample + gnatmake -Pmain -XBUILD=release + @end smallexample + + @noindent + for the Release mode. + + + @c ******************************** + @c * Project File Complete Syntax * + @c ******************************** + + @node Project File Complete Syntax + @section Project File Complete Syntax + + @smallexample + project ::= + context_clause project_declaration + + context_clause ::= + @{with_clause@} + + with_clause ::= + @b{with} literal_string @{ , literal_string @} ; + + project_declaration ::= + @b{project} simple_name [ @b{extends} literal_string ] @b{is} + @{declarative_item@} + @b{end} simple_name; + + declarative_item ::= + package_declaration | + typed_string_declaration | + other_declarative_item + + package_declaration ::= + @b{package} simple_name package_completion + + package_completion ::= + package_body | package_renaming + + package body ::= + @b{is} + @{other_declarative_item@} + @b{end} simple_name ; + + package_renaming ::== + @b{renames} simple_name.simple_name ; + + typed_string_declaration ::= + @b{type} _simple_name @b{is} + ( literal_string @{, literal_string@} ); + + other_declarative_item ::= + attribute_declaration | + typed_variable_declaration | + variable_declaration | + case_construction + + attribute_declaration ::= + @b{for} attribute @b{use} expression ; + + attribute ::= + simple_name | + simple_name ( literal_string ) + + typed_variable_declaration ::= + simple_name : name := string_expression ; + + variable_declaration ::= + simple_name := expression; + + expression ::= + term @{& term@} + + term ::= + literal_string | + string_list | + name | + external_value | + attribute_reference + + literal_string ::= + (same as Ada) + + string_list ::= + ( expression @{ , expression @} ) + + external_value ::= + @b{external} ( literal_string [, literal_string] ) + + attribute_reference ::= + attribute_parent ' simple_name [ ( literal_string ) ] + + attribute_parent ::= + @b{project} | + simple_name | + simple_name . simple_name + + case_construction ::= + @b{case} name @b{is} + @{case_item@} + @b{end case} ; + + case_item ::= + @b{when} discrete_choice_list => @{case_construction | attribute_declaration@} + + discrete_choice_list ::= + literal_string @{| literal_string@} + + name ::= + simple_name @{. simple_name@} + + simple_name ::= + identifier (same as Ada) + + @end smallexample + + + @node Elaboration Order Handling in GNAT + @chapter Elaboration Order Handling in GNAT + @cindex Order of elaboration + @cindex Elaboration control + + @menu + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + @end menu + + @noindent + This chapter describes the handling of elaboration code in Ada 95 and + in GNAT, and discusses how the order of elaboration of program units can + be controlled in GNAT, either automatically or with explicit programming + features. + + @node Elaboration Code in Ada 95 + @section Elaboration Code in Ada 95 + + @noindent + Ada 95 provides rather general mechanisms for executing code at elaboration + time, that is to say before the main program starts executing. Such code arises + in three contexts: + + @table @asis + @item Initializers for variables. + Variables declared at the library level, in package specs or bodies, can + require initialization that is performed at elaboration time, as in: + @smallexample + @cartouche + Sqrt_Half : Float := Sqrt (0.5); + @end cartouche + @end smallexample + + @item Package initialization code + Code in a @code{BEGIN-END} section at the outer level of a package body is + executed as part of the package body elaboration code. + + @item Library level task allocators + Tasks that are declared using task allocators at the library level + start executing immediately and hence can execute at elaboration time. + @end table + + @noindent + Subprogram calls are possible in any of these contexts, which means that + any arbitrary part of the program may be executed as part of the elaboration + code. It is even possible to write a program which does all its work at + elaboration time, with a null main program, although stylistically this + would usually be considered an inappropriate way to structure + a program. + + An important concern arises in the context of elaboration code: + we have to be sure that it is executed in an appropriate order. What we + have is a series of elaboration code sections, potentially one section + for each unit in the program. It is important that these execute + in the correct order. Correctness here means that, taking the above + example of the declaration of @code{Sqrt_Half}, + if some other piece of + elaboration code references @code{Sqrt_Half}, + then it must run after the + section of elaboration code that contains the declaration of + @code{Sqrt_Half}. + + There would never be any order of elaboration problem if we made a rule + that whenever you @code{with} a unit, you must elaborate both the spec and body + of that unit before elaborating the unit doing the @code{with}'ing: + + @smallexample + @group + @cartouche + @b{with} Unit_1; + @b{package} Unit_2 @b{is} ... + @end cartouche + @end group + @end smallexample + + @noindent + would require that both the body and spec of @code{Unit_1} be elaborated + before the spec of @code{Unit_2}. However, a rule like that would be far too + restrictive. In particular, it would make it impossible to have routines + in separate packages that were mutually recursive. + + You might think that a clever enough compiler could look at the actual + elaboration code and determine an appropriate correct order of elaboration, + but in the general case, this is not possible. Consider the following + example. + + In the body of @code{Unit_1}, we have a procedure @code{Func_1} + that references + the variable @code{Sqrt_1}, which is declared in the elaboration code + of the body of @code{Unit_1}: + + @smallexample + @cartouche + Sqrt_1 : Float := Sqrt (0.1); + @end cartouche + @end smallexample + + @noindent + The elaboration code of the body of @code{Unit_1} also contains: + + @smallexample + @group + @cartouche + @b{if} expression_1 = 1 @b{then} + Q := Unit_2.Func_2; + @b{end if}; + @end cartouche + @end group + @end smallexample + + @noindent + @code{Unit_2} is exactly parallel, + it has a procedure @code{Func_2} that references + the variable @code{Sqrt_2}, which is declared in the elaboration code of + the body @code{Unit_2}: + + @smallexample + @cartouche + Sqrt_2 : Float := Sqrt (0.1); + @end cartouche + @end smallexample + + @noindent + The elaboration code of the body of @code{Unit_2} also contains: + + @smallexample + @group + @cartouche + @b{if} expression_2 = 2 @b{then} + Q := Unit_1.Func_1; + @b{end if}; + @end cartouche + @end group + @end smallexample + + @noindent + Now the question is, which of the following orders of elaboration is + acceptable: + + @smallexample + @group + Spec of Unit_1 + Spec of Unit_2 + Body of Unit_1 + Body of Unit_2 + @end group + @end smallexample + + @noindent + or + + @smallexample + @group + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_2 + Body of Unit_1 + @end group + @end smallexample + + @noindent + If you carefully analyze the flow here, you will see that you cannot tell + at compile time the answer to this question. + If @code{expression_1} is not equal to 1, + and @code{expression_2} is not equal to 2, + then either order is acceptable, because neither of the function calls is + executed. If both tests evaluate to true, then neither order is acceptable + and in fact there is no correct order. + + If one of the two expressions is true, and the other is false, then one + of the above orders is correct, and the other is incorrect. For example, + if @code{expression_1} = 1 and @code{expression_2} /= 2, + then the call to @code{Func_2} + will occur, but not the call to @code{Func_1.} + This means that it is essential + to elaborate the body of @code{Unit_1} before + the body of @code{Unit_2}, so the first + order of elaboration is correct and the second is wrong. + + By making @code{expression_1} and @code{expression_2} + depend on input data, or perhaps + the time of day, we can make it impossible for the compiler or binder + to figure out which of these expressions will be true, and hence it + is impossible to guarantee a safe order of elaboration at run time. + + @node Checking the Elaboration Order in Ada 95 + @section Checking the Elaboration Order in Ada 95 + + @noindent + In some languages that involve the same kind of elaboration problems, + e.g. Java and C++, the programmer is expected to worry about these + ordering problems himself, and it is common to + write a program in which an incorrect elaboration order gives + surprising results, because it references variables before they + are initialized. + Ada 95 is designed to be a safe language, and a programmer-beware approach is + clearly not sufficient. Consequently, the language provides three lines + of defense: + + @table @asis + @item Standard rules + Some standard rules restrict the possible choice of elaboration + order. In particular, if you @code{with} a unit, then its spec is always + elaborated before the unit doing the @code{with}. Similarly, a parent + spec is always elaborated before the child spec, and finally + a spec is always elaborated before its corresponding body. + + @item Dynamic elaboration checks + @cindex Elaboration checks + @cindex Checks, elaboration + Dynamic checks are made at run time, so that if some entity is accessed + before it is elaborated (typically by means of a subprogram call) + then the exception (@code{Program_Error}) is raised. + + @item Elaboration control + Facilities are provided for the programmer to specify the desired order + of elaboration. + @end table + + Let's look at these facilities in more detail. First, the rules for + dynamic checking. One possible rule would be simply to say that the + exception is raised if you access a variable which has not yet been + elaborated. The trouble with this approach is that it could require + expensive checks on every variable reference. Instead Ada 95 has two + rules which are a little more restrictive, but easier to check, and + easier to state: + + @table @asis + @item Restrictions on calls + A subprogram can only be called at elaboration time if its body + has been elaborated. The rules for elaboration given above guarantee + that the spec of the subprogram has been elaborated before the + call, but not the body. If this rule is violated, then the + exception @code{Program_Error} is raised. + + @item Restrictions on instantiations + A generic unit can only be instantiated if the body of the generic + unit has been elaborated. Again, the rules for elaboration given above + guarantee that the spec of the generic unit has been elaborated + before the instantiation, but not the body. If this rule is + violated, then the exception @code{Program_Error} is raised. + @end table + + @noindent + The idea is that if the body has been elaborated, then any variables + it references must have been elaborated; by checking for the body being + elaborated we guarantee that none of its references causes any + trouble. As we noted above, this is a little too restrictive, because a + subprogram that has no non-local references in its body may in fact be safe + to call. However, it really would be unsafe to rely on this, because + it would mean that the caller was aware of details of the implementation + in the body. This goes against the basic tenets of Ada. + + A plausible implementation can be described as follows. + A Boolean variable is associated with each subprogram + and each generic unit. This variable is initialized to False, and is set to + True at the point body is elaborated. Every call or instantiation checks the + variable, and raises @code{Program_Error} if the variable is False. + + Note that one might think that it would be good enough to have one Boolean + variable for each package, but that would not deal with cases of trying + to call a body in the same package as the call + that has not been elaborated yet. + Of course a compiler may be able to do enough analysis to optimize away + some of the Boolean variables as unnecessary, and @code{GNAT} indeed + does such optimizations, but still the easiest conceptual model is to + think of there being one variable per subprogram. + + @node Controlling the Elaboration Order in Ada 95 + @section Controlling the Elaboration Order in Ada 95 + + @noindent + In the previous section we discussed the rules in Ada 95 which ensure + that @code{Program_Error} is raised if an incorrect elaboration order is + chosen. This prevents erroneous executions, but we need mechanisms to + specify a correct execution and avoid the exception altogether. + To achieve this, Ada 95 provides a number of features for controlling + the order of elaboration. We discuss these features in this section. + + First, there are several ways of indicating to the compiler that a given + unit has no elaboration problems: + + @table @asis + @item packages that do not require a body + In Ada 95, a library package that does not require a body does not permit + a body. This means that if we have a such a package, as in: + + @smallexample + @group + @cartouche + @b{package} Definitions @b{is} + @b{generic} + @b{type} m @b{is new} integer; + @b{package} Subp @b{is} + @b{type} a @b{is array} (1 .. 10) @b{of} m; + @b{type} b @b{is array} (1 .. 20) @b{of} m; + @b{end} Subp; + @b{end} Definitions; + @end cartouche + @end group + @end smallexample + + @noindent + A package that @code{with}'s @code{Definitions} may safely instantiate + @code{Definitions.Subp} because the compiler can determine that there + definitely is no package body to worry about in this case + + @item pragma Pure + @cindex pragma Pure + @findex Pure + Places sufficient restrictions on a unit to guarantee that + no call to any subprogram in the unit can result in an + elaboration problem. This means that the compiler does not need + to worry about the point of elaboration of such units, and in + particular, does not need to check any calls to any subprograms + in this unit. + + @item pragma Preelaborate + @findex Preelaborate + @cindex pragma Preelaborate + This pragma places slightly less stringent restrictions on a unit than + does pragma Pure, + but these restrictions are still sufficient to ensure that there + are no elaboration problems with any calls to the unit. + + @item pragma Elaborate_Body + @findex Elaborate_Body + @cindex pragma Elaborate_Body + This pragma requires that the body of a unit be elaborated immediately + after its spec. Suppose a unit @code{A} has such a pragma, + and unit @code{B} does + a @code{with} of unit @code{A}. Recall that the standard rules require + the spec of unit @code{A} + to be elaborated before the @code{with}'ing unit; given the pragma in + @code{A}, we also know that the body of @code{A} + will be elaborated before @code{B}, so + that calls to @code{A} are safe and do not need a check. + @end table + + @noindent + Note that, + unlike pragma @code{Pure} and pragma @code{Preelaborate}, + the use of + @code{Elaborate_Body} does not guarantee that the program is + free of elaboration problems, because it may not be possible + to satisfy the requested elaboration order. + Let's go back to the example with @code{Unit_1} and @code{Unit_2}. + If a programmer + marks @code{Unit_1} as @code{Elaborate_Body}, + and not @code{Unit_2,} then the order of + elaboration will be: + + @smallexample + @group + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_1 + Body of Unit_2 + @end group + @end smallexample + + @noindent + Now that means that the call to @code{Func_1} in @code{Unit_2} + need not be checked, + it must be safe. But the call to @code{Func_2} in + @code{Unit_1} may still fail if + @code{Expression_1} is equal to 1, + and the programmer must still take + responsibility for this not being the case. + + If all units carry a pragma @code{Elaborate_Body}, then all problems are + eliminated, except for calls entirely within a body, which are + in any case fully under programmer control. However, using the pragma + everywhere is not always possible. + In particular, for our @code{Unit_1}/@code{Unit_2} example, if + we marked both of them as having pragma @code{Elaborate_Body}, then + clearly there would be no possible elaboration order. + + The above pragmas allow a server to guarantee safe use by clients, and + clearly this is the preferable approach. Consequently a good rule in + Ada 95 is to mark units as @code{Pure} or @code{Preelaborate} if possible, + and if this is not possible, + mark them as @code{Elaborate_Body} if possible. + As we have seen, there are situations where neither of these + three pragmas can be used. + So we also provide methods for clients to control the + order of elaboration of the servers on which they depend: + + @table @asis + @item pragma Elaborate (unit) + @findex Elaborate + @cindex pragma Elaborate + This pragma is placed in the context clause, after a @code{with} clause, + and it requires that the body of the named unit be elaborated before + the unit in which the pragma occurs. The idea is to use this pragma + if the current unit calls at elaboration time, directly or indirectly, + some subprogram in the named unit. + + @item pragma Elaborate_All (unit) + @findex Elaborate_All + @cindex pragma Elaborate_All + This is a stronger version of the Elaborate pragma. Consider the + following example: + + @smallexample + Unit A @code{with}'s unit B and calls B.Func in elab code + Unit B @code{with}'s unit C, and B.Func calls C.Func + @end smallexample + + @noindent + Now if we put a pragma @code{Elaborate (B)} + in unit @code{A}, this ensures that the + body of @code{B} is elaborated before the call, but not the + body of @code{C}, so + the call to @code{C.Func} could still cause @code{Program_Error} to + be raised. + + The effect of a pragma @code{Elaborate_All} is stronger, it requires + not only that the body of the named unit be elaborated before the + unit doing the @code{with}, but also the bodies of all units that the + named unit uses, following @code{with} links transitively. For example, + if we put a pragma @code{Elaborate_All (B)} in unit @code{A}, + then it requires + not only that the body of @code{B} be elaborated before @code{A}, + but also the + body of @code{C}, because @code{B} @code{with}'s @code{C}. + @end table + + @noindent + We are now in a position to give a usage rule in Ada 95 for avoiding + elaboration problems, at least if dynamic dispatching and access to + subprogram values are not used. We will handle these cases separately + later. + + The rule is simple. If a unit has elaboration code that can directly or + indirectly make a call to a subprogram in a @code{with}'ed unit, or instantiate + a generic unit in a @code{with}'ed unit, + then if the @code{with}'ed unit does not have + pragma @code{Pure} or @code{Preelaborate}, then the client should have + a pragma @code{Elaborate_All} + for the @code{with}'ed unit. By following this rule a client is + assured that calls can be made without risk of an exception. + If this rule is not followed, then a program may be in one of four + states: + + @table @asis + @item No order exists + No order of elaboration exists which follows the rules, taking into + account any @code{Elaborate}, @code{Elaborate_All}, + or @code{Elaborate_Body} pragmas. In + this case, an Ada 95 compiler must diagnose the situation at bind + time, and refuse to build an executable program. + + @item One or more orders exist, all incorrect + One or more acceptable elaboration orders exists, and all of them + generate an elaboration order problem. In this case, the binder + can build an executable program, but @code{Program_Error} will be raised + when the program is run. + + @item Several orders exist, some right, some incorrect + One or more acceptable elaboration orders exists, and some of them + work, and some do not. The programmer has not controlled + the order of elaboration, so the binder may or may not pick one of + the correct orders, and the program may or may not raise an + exception when it is run. This is the worst case, because it means + that the program may fail when moved to another compiler, or even + another version of the same compiler. + + @item One or more orders exists, all correct + One ore more acceptable elaboration orders exist, and all of them + work. In this case the program runs successfully. This state of + affairs can be guaranteed by following the rule we gave above, but + may be true even if the rule is not followed. + @end table + + @noindent + Note that one additional advantage of following our Elaborate_All rule + is that the program continues to stay in the ideal (all orders OK) state + even if maintenance + changes some bodies of some subprograms. Conversely, if a program that does + not follow this rule happens to be safe at some point, this state of affairs + may deteriorate silently as a result of maintenance changes. + + You may have noticed that the above discussion did not mention + the use of @code{Elaborate_Body}. This was a deliberate omission. If you + @code{with} an @code{Elaborate_Body} unit, it still may be the case that + code in the body makes calls to some other unit, so it is still necessary + to use @code{Elaborate_All} on such units. + + @node Controlling Elaboration in GNAT - Internal Calls + @section Controlling Elaboration in GNAT - Internal Calls + + @noindent + In the case of internal calls, i.e. calls within a single package, the + programmer has full control over the order of elaboration, and it is up + to the programmer to elaborate declarations in an appropriate order. For + example writing: + + @smallexample + @group + @cartouche + @b{function} One @b{return} Float; + + Q : Float := One; + + @b{function} One @b{return} Float @b{is} + @b{begin} + return 1.0; + @b{end} One; + @end cartouche + @end group + @end smallexample + + @noindent + will obviously raise @code{Program_Error} at run time, because function + One will be called before its body is elaborated. In this case GNAT will + generate a warning that the call will raise @code{Program_Error}: + + @smallexample + @group + @cartouche + 1. procedure y is + 2. function One return Float; + 3. + 4. Q : Float := One; + | + >>> warning: cannot call "One" before body is elaborated + >>> warning: Program_Error will be raised at run time + + 5. + 6. function One return Float is + 7. begin + 8. return 1.0; + 9. end One; + 10. + 11. begin + 12. null; + 13. end; + @end cartouche + @end group + @end smallexample + + @noindent + Note that in this particular case, it is likely that the call is safe, because + the function @code{One} does not access any global variables. + Nevertheless in Ada 95, we do not want the validity of the check to depend on + the contents of the body (think about the separate compilation case), so this + is still wrong, as we discussed in the previous sections. + + The error is easily corrected by rearranging the declarations so that the + body of One appears before the declaration containing the call + (note that in Ada 95, + declarations can appear in any order, so there is no restriction that + would prevent this reordering, and if we write: + + @smallexample + @group + @cartouche + @b{function} One @b{return} Float; + + @b{function} One @b{return} Float @b{is} + @b{begin} + return 1.0; + @b{end} One; + + Q : Float := One; + @end cartouche + @end group + @end smallexample + + @noindent + then all is well, no warning is generated, and no + @code{Program_Error} exception + will be raised. + Things are more complicated when a chain of subprograms is executed: + + @smallexample + @group + @cartouche + @b{function} A @b{return} Integer; + @b{function} B @b{return} Integer; + @b{function} C @b{return} Integer; + + @b{function} B @b{return} Integer @b{is begin return} A; @b{end}; + @b{function} C @b{return} Integer @b{is begin return} B; @b{end}; + + X : Integer := C; + + @b{function} A @b{return} Integer @b{is begin return} 1; @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + Now the call to @code{C} + at elaboration time in the declaration of @code{X} is correct, because + the body of @code{C} is already elaborated, + and the call to @code{B} within the body of + @code{C} is correct, but the call + to @code{A} within the body of @code{B} is incorrect, because the body + of @code{A} has not been elaborated, so @code{Program_Error} + will be raised on the call to @code{A}. + In this case GNAT will generate a + warning that @code{Program_Error} may be + raised at the point of the call. Let's look at the warning: + + @smallexample + @group + @cartouche + 1. procedure x is + 2. function A return Integer; + 3. function B return Integer; + 4. function C return Integer; + 5. + 6. function B return Integer is begin return A; end; + | + >>> warning: call to "A" before body is elaborated may + raise Program_Error + >>> warning: "B" called at line 7 + >>> warning: "C" called at line 9 + + 7. function C return Integer is begin return B; end; + 8. + 9. X : Integer := C; + 10. + 11. function A return Integer is begin return 1; end; + 12. + 13. begin + 14. null; + 15. end; + @end cartouche + @end group + @end smallexample + + @noindent + Note that the message here says "may raise", instead of the direct case, + where the message says "will be raised". That's because whether + @code{A} is + actually called depends in general on run-time flow of control. + For example, if the body of @code{B} said + + @smallexample + @group + @cartouche + @b{function} B @b{return} Integer @b{is} + @b{begin} + @b{if} some-condition-depending-on-input-data @b{then} + @b{return} A; + @b{else} + @b{return} 1; + @b{end if}; + @b{end} B; + @end cartouche + @end group + @end smallexample + + @noindent + then we could not know until run time whether the incorrect call to A would + actually occur, so @code{Program_Error} might + or might not be raised. It is possible for a compiler to + do a better job of analyzing bodies, to + determine whether or not @code{Program_Error} + might be raised, but it certainly + couldn't do a perfect job (that would require solving the halting problem + and is provably impossible), and because this is a warning anyway, it does + not seem worth the effort to do the analysis. Cases in which it + would be relevant are rare. + + In practice, warnings of either of the forms given + above will usually correspond to + real errors, and should be examined carefully and eliminated. + In the rare case where a warning is bogus, it can be suppressed by any of + the following methods: + + @itemize @bullet + @item + Compile with the @option{-gnatws} switch set + + @item + Suppress @code{Elaboration_Checks} for the called subprogram + + @item + Use pragma @code{Warnings_Off} to turn warnings off for the call + @end itemize + + @noindent + For the internal elaboration check case, + GNAT by default generates the + necessary run-time checks to ensure + that @code{Program_Error} is raised if any + call fails an elaboration check. Of course this can only happen if a + warning has been issued as described above. The use of pragma + @code{Suppress (Elaboration_Checks)} may (but is not guaranteed to) suppress + some of these checks, meaning that it may be possible (but is not + guaranteed) for a program to be able to call a subprogram whose body + is not yet elaborated, without raising a @code{Program_Error} exception. + + @node Controlling Elaboration in GNAT - External Calls + @section Controlling Elaboration in GNAT - External Calls + + @noindent + The previous section discussed the case in which the execution of a + particular thread of elaboration code occurred entirely within a + single unit. This is the easy case to handle, because a programmer + has direct and total control over the order of elaboration, and + furthermore, checks need only be generated in cases which are rare + and which the compiler can easily detect. + The situation is more complex when separate compilation is taken into account. + Consider the following: + + @smallexample + @cartouche + @group + @b{package} Math @b{is} + @b{function} Sqrt (Arg : Float) @b{return} Float; + @b{end} Math; + + @b{package body} Math @b{is} + @b{function} Sqrt (Arg : Float) @b{return} Float @b{is} + @b{begin} + ... + @b{end} Sqrt; + @b{end} Math; + @end group + @group + @b{with} Math; + @b{package} Stuff @b{is} + X : Float := Math.Sqrt (0.5); + @b{end} Stuff; + + @b{with} Stuff; + @b{procedure} Main @b{is} + @b{begin} + ... + @b{end} Main; + @end group + @end cartouche + @end smallexample + + @noindent + where @code{Main} is the main program. When this program is executed, the + elaboration code must first be executed, and one of the jobs of the + binder is to determine the order in which the units of a program are + to be elaborated. In this case we have four units: the spec and body + of @code{Math}, + the spec of @code{Stuff} and the body of @code{Main}). + In what order should the four separate sections of elaboration code + be executed? + + There are some restrictions in the order of elaboration that the binder + can choose. In particular, if unit U has a @code{with} + for a package @code{X}, then you + are assured that the spec of @code{X} + is elaborated before U , but you are + not assured that the body of @code{X} + is elaborated before U. + This means that in the above case, the binder is allowed to choose the + order: + + @smallexample + spec of Math + spec of Stuff + body of Math + body of Main + @end smallexample + + @noindent + but that's not good, because now the call to @code{Math.Sqrt} + that happens during + the elaboration of the @code{Stuff} + spec happens before the body of @code{Math.Sqrt} is + elaborated, and hence causes @code{Program_Error} exception to be raised. + At first glance, one might say that the binder is misbehaving, because + obviously you want to elaborate the body of something you @code{with} + first, but + that is not a general rule that can be followed in all cases. Consider + + @smallexample + @group + @cartouche + @b{package} X @b{is} ... + + @b{package} Y @b{is} ... + + @b{with} X; + @b{package body} Y @b{is} ... + + @b{with} Y; + @b{package body} X @b{is} ... + @end cartouche + @end group + @end smallexample + + @noindent + This is a common arrangement, and, apart from the order of elaboration + problems that might arise in connection with elaboration code, this works fine. + A rule that says that you must first elaborate the body of anything you + @code{with} cannot work in this case: + the body of @code{X} @code{with}'s @code{Y}, + which means you would have to + elaborate the body of @code{Y} first, but that @code{with}'s @code{X}, + which means + you have to elaborate the body of @code{X} first, but ... and we have a + loop that cannot be broken. + + It is true that the binder can in many cases guess an order of elaboration + that is unlikely to cause a @code{Program_Error} + exception to be raised, and it tries to do so (in the + above example of @code{Math/Stuff/Spec}, the GNAT binder will + by default + elaborate the body of @code{Math} right after its spec, so all will be well). + + However, a program that blindly relies on the binder to be helpful can + get into trouble, as we discussed in the previous sections, so + GNAT + provides a number of facilities for assisting the programmer in + developing programs that are robust with respect to elaboration order. + + @node Default Behavior in GNAT - Ensuring Safety + @section Default Behavior in GNAT - Ensuring Safety + + @noindent + The default behavior in GNAT ensures elaboration safety. In its + default mode GNAT implements the + rule we previously described as the right approach. Let's restate it: + + @itemize + @item + @emph{If a unit has elaboration code that can directly or indirectly make a + call to a subprogram in a @code{with}'ed unit, or instantiate a generic unit + in a @code{with}'ed unit, then if the @code{with}'ed unit + does not have pragma @code{Pure} or + @code{Preelaborate}, then the client should have an + @code{Elaborate_All} for the @code{with}'ed unit.} + @end itemize + + @noindent + By following this rule a client + is assured that calls and instantiations can be made without risk of an exception. + + In this mode GNAT traces all calls that are potentially made from + elaboration code, and puts in any missing implicit @code{Elaborate_All} + pragmas. + The advantage of this approach is that no elaboration problems + are possible if the binder can find an elaboration order that is + consistent with these implicit @code{Elaborate_All} pragmas. The + disadvantage of this approach is that no such order may exist. + + If the binder does not generate any diagnostics, then it means that it + has found an elaboration order that is guaranteed to be safe. However, + the binder may still be relying on implicitly generated + @code{Elaborate_All} pragmas so portability to other compilers than + GNAT is not guaranteed. + + If it is important to guarantee portability, then the compilations should + use the + @option{-gnatwl} + (warn on elaboration problems) switch. This will cause warning messages + to be generated indicating the missing @code{Elaborate_All} pragmas. + Consider the following source program: + + @smallexample + @group + @cartouche + @b{with} k; + @b{package} j @b{is} + m : integer := k.r; + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + where it is clear that there + should be a pragma @code{Elaborate_All} + for unit @code{k}. An implicit pragma will be generated, and it is + likely that the binder will be able to honor it. However, + it is safer to include the pragma explicitly in the source. If this + unit is compiled with the + @option{-gnatwl} + switch, then the compiler outputs a warning: + + @smallexample + @group + @cartouche + 1. with k; + 2. package j is + 3. m : integer := k.r; + | + >>> warning: call to "r" may raise Program_Error + >>> warning: missing pragma Elaborate_All for "k" + + 4. end; + @end cartouche + @end group + @end smallexample + + @noindent + and these warnings can be used as a guide for supplying manually + the missing pragmas. + + This default mode is more restrictive than the Ada Reference + Manual, and it is possible to construct programs which will compile + using the dynamic model described there, but will run into a + circularity using the safer static model we have described. + + Of course any Ada compiler must be able to operate in a mode + consistent with the requirements of the Ada Reference Manual, + and in particular must have the capability of implementing the + standard dynamic model of elaboration with run-time checks. + + In GNAT, this standard mode can be achieved either by the use of + the @option{-gnatE} switch on the compiler (@code{gcc} or @code{gnatmake}) + command, or by the use of the configuration pragma: + + @smallexample + pragma Elaboration_Checks (RM); + @end smallexample + + @noindent + Either approach will cause the unit affected to be compiled using the + standard dynamic run-time elaboration checks described in the Ada + Reference Manual. The static model is generally preferable, since it + is clearly safer to rely on compile and link time checks rather than + run-time checks. However, in the case of legacy code, it may be + difficult to meet the requirements of the static model. This + issue is further discussed in + @ref{What to Do If the Default Elaboration Behavior Fails}. + + Note that the static model provides a strict subset of the allowed + behavior and programs of the Ada Reference Manual, so if you do + adhere to the static model and no circularities exist, + then you are assured that your program will + work using the dynamic model. + + @node Elaboration Issues for Library Tasks + @section Elaboration Issues for Library Tasks + @cindex Library tasks, elaboration issues + @cindex Elaboration of library tasks + + @noindent + In this section we examine special elaboration issues that arise for + programs that declare library level tasks. + + Generally the model of execution of an Ada program is that all units are + elaborated, and then execution of the program starts. However, the + declaration of library tasks definitely does not fit this model. The + reason for this is that library tasks start as soon as they are declared + (more precisely, as soon as the statement part of the enclosing package + body is reached), that is to say before elaboration + of the program is complete. This means that if such a task calls a + subprogram, or an entry in another task, the callee may or may not be + elaborated yet, and in the standard + Reference Manual model of dynamic elaboration checks, you can even + get timing dependent Program_Error exceptions, since there can be + a race between the elaboration code and the task code. + + The static model of elaboration in GNAT seeks to avoid all such + dynamic behavior, by being conservative, and the conservative + approach in this particular case is to assume that all the code + in a task body is potentially executed at elaboration time if + a task is declared at the library level. + + This can definitely result in unexpected circularities. Consider + the following example + + @smallexample + package Decls is + task Lib_Task is + entry Start; + end Lib_Task; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + procedure Main is + begin + Decls.Lib_Task.Start; + end; + @end smallexample + + @noindent + If the above example is compiled in the default static elaboration + mode, then a circularity occurs. The circularity comes from the call + @code{Utils.Put_Val} in the task body of @code{Decls.Lib_Task}. Since + this call occurs in elaboration code, we need an implicit pragma + @code{Elaborate_All} for @code{Utils}. This means that not only must + the spec and body of @code{Utils} be elaborated before the body + of @code{Decls}, but also the spec and body of any unit that is + @code{with'ed} by the body of @code{Utils} must also be elaborated before + the body of @code{Decls}. This is the transitive implication of + pragma @code{Elaborate_All} and it makes sense, because in general + the body of @code{Put_Val} might have a call to something in a + @code{with'ed} unit. + + In this case, the body of Utils (actually its spec) @code{with's} + @code{Decls}. Unfortunately this means that the body of @code{Decls} + must be elaborated before itself, in case there is a call from the + body of @code{Utils}. + + Here is the exact chain of events we are worrying about: + + @enumerate + @item + In the body of @code{Decls} a call is made from within the body of a library + task to a subprogram in the package @code{Utils}. Since this call may + occur at elaboration time (given that the task is activated at elaboration + time), we have to assume the worst, i.e. that the + call does happen at elaboration time. + + @item + This means that the body and spec of @code{Util} must be elaborated before + the body of @code{Decls} so that this call does not cause an access before + elaboration. + + @item + Within the body of @code{Util}, specifically within the body of + @code{Util.Put_Val} there may be calls to any unit @code{with}'ed + by this package. + + @item + One such @code{with}'ed package is package @code{Decls}, so there + might be a call to a subprogram in @code{Decls} in @code{Put_Val}. + In fact there is such a call in this example, but we would have to + assume that there was such a call even if it were not there, since + we are not supposed to write the body of @code{Decls} knowing what + is in the body of @code{Utils}; certainly in the case of the + static elaboration model, the compiler does not know what is in + other bodies and must assume the worst. + + @item + This means that the spec and body of @code{Decls} must also be + elaborated before we elaborate the unit containing the call, but + that unit is @code{Decls}! This means that the body of @code{Decls} + must be elaborated before itself, and that's a circularity. + @end enumerate + + @noindent + Indeed, if you add an explicit pragma Elaborate_All for @code{Utils} in + the body of @code{Decls} you will get a true Ada Reference Manual + circularity that makes the program illegal. + + In practice, we have found that problems with the static model of + elaboration in existing code often arise from library tasks, so + we must address this particular situation. + + Note that if we compile and run the program above, using the dynamic model of + elaboration (that is to say use the @option{-gnatE} switch), + then it compiles, binds, + links, and runs, printing the expected result of 2. Therefore in some sense + the circularity here is only apparent, and we need to capture + the properties of this program that distinguish it from other library-level + tasks that have real elaboration problems. + + We have four possible answers to this question: + + @itemize @bullet + + @item + Use the dynamic model of elaboration. + + If we use the @option{-gnatE} switch, then as noted above, the program works. + Why is this? If we examine the task body, it is apparent that the task cannot + proceed past the + @code{accept} statement until after elaboration has been completed, because + the corresponding entry call comes from the main program, not earlier. + This is why the dynamic model works here. But that's really giving + up on a precise analysis, and we prefer to take this approach only if we cannot + solve the + problem in any other manner. So let us examine two ways to reorganize + the program to avoid the potential elaboration problem. + + @item + Split library tasks into separate packages. + + Write separate packages, so that library tasks are isolated from + other declarations as much as possible. Let us look at a variation on + the above program. + + @smallexample + package Decls1 is + task Lib_Task is + entry Start; + end Lib_Task; + end Decls1; + + with Utils; + package body Decls1 is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + end Decls1; + + package Decls2 is + type My_Int is new Integer; + function Ident (M : My_Int) return My_Int; + end Decls2; + + with Utils; + package body Decls2 is + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls2; + + with Decls2; + package Utils is + procedure Put_Val (Arg : Decls2.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls2.My_Int) is + begin + Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls1; + procedure Main is + begin + Decls1.Lib_Task.Start; + end; + @end smallexample + + @noindent + All we have done is to split @code{Decls} into two packages, one + containing the library task, and one containing everything else. Now + there is no cycle, and the program compiles, binds, links and executes + using the default static model of elaboration. + + @item + Declare separate task types. + + A significant part of the problem arises because of the use of the + single task declaration form. This means that the elaboration of + the task type, and the elaboration of the task itself (i.e. the + creation of the task) happen at the same time. A good rule + of style in Ada 95 is to always create explicit task types. By + following the additional step of placing task objects in separate + packages from the task type declaration, many elaboration problems + are avoided. Here is another modified example of the example program: + + @smallexample + package Decls is + task type Lib_Task_Type is + entry Start; + end Lib_Task_Type; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task_Type is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task_Type; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + package Declst is + Lib_Task : Decls.Lib_Task_Type; + end Declst; + + with Declst; + procedure Main is + begin + Declst.Lib_Task.Start; + end; + @end smallexample + + @noindent + What we have done here is to replace the @code{task} declaration in + package @code{Decls} with a @code{task type} declaration. Then we + introduce a separate package @code{Declst} to contain the actual + task object. This separates the elaboration issues for + the @code{task type} + declaration, which causes no trouble, from the elaboration issues + of the task object, which is also unproblematic, since it is now independent + of the elaboration of @code{Utils}. + This separation of concerns also corresponds to + a generally sound engineering principle of separating declarations + from instances. This version of the program also compiles, binds, links, + and executes, generating the expected output. + + @item + Use No_Entry_Calls_In_Elaboration_Code restriction. + @cindex No_Entry_Calls_In_Elaboration_Code + + The previous two approaches described how a program can be restructured + to avoid the special problems caused by library task bodies. in practice, + however, such restructuring may be difficult to apply to existing legacy code, + so we must consider solutions that do not require massive rewriting. + + Let us consider more carefully why our original sample program works + under the dynamic model of elaboration. The reason is that the code + in the task body blocks immediately on the @code{accept} + statement. Now of course there is nothing to prohibit elaboration + code from making entry calls (for example from another library level task), + so we cannot tell in isolation that + the task will not execute the accept statement during elaboration. + + However, in practice it is very unusual to see elaboration code + make any entry calls, and the pattern of tasks starting + at elaboration time and then immediately blocking on @code{accept} or + @code{select} statements is very common. What this means is that + the compiler is being too pessimistic when it analyzes the + whole package body as though it might be executed at elaboration + time. + + If we know that the elaboration code contains no entry calls, (a very safe + assumption most of the time, that could almost be made the default + behavior), then we can compile all units of the program under control + of the following configuration pragma: + + @smallexample + pragma Restrictions (No_Entry_Calls_In_Elaboration_Code); + @end smallexample + + @noindent + This pragma can be placed in the @file{gnat.adc} file in the usual + manner. If we take our original unmodified program and compile it + in the presence of a @file{gnat.adc} containing the above pragma, + then once again, we can compile, bind, link, and execute, obtaining + the expected result. In the presence of this pragma, the compiler does + not trace calls in a task body, that appear after the first @code{accept} + or @code{select} statement, and therefore does not report a potential + circularity in the original program. + + The compiler will check to the extent it can that the above + restriction is not violated, but it is not always possible to do a + complete check at compile time, so it is important to use this + pragma only if the stated restriction is in fact met, that is to say + no task receives an entry call before elaboration of all units is completed. + + @end itemize + + @node Mixing Elaboration Models + @section Mixing Elaboration Models + @noindent + So far, we have assumed that the entire program is either compiled + using the dynamic model or static model, ensuring consistency. It + is possible to mix the two models, but rules have to be followed + if this mixing is done to ensure that elaboration checks are not + omitted. + + The basic rule is that @emph{a unit compiled with the static model cannot + be @code{with'ed} by a unit compiled with the dynamic model}. The + reason for this is that in the static model, a unit assumes that + its clients guarantee to use (the equivalent of) pragma + @code{Elaborate_All} so that no elaboration checks are required + in inner subprograms, and this assumption is violated if the + client is compiled with dynamic checks. + + The precise rule is as follows. A unit that is compiled with dynamic + checks can only @code{with} a unit that meets at least one of the + following criteria: + + @itemize @bullet + + @item + The @code{with'ed} unit is itself compiled with dynamic elaboration + checks (that is with the @option{-gnatE} switch. + + @item + The @code{with'ed} unit is an internal GNAT implementation unit from + the System, Interfaces, Ada, or GNAT hierarchies. + + @item + The @code{with'ed} unit has pragma Preelaborate or pragma Pure. + + @item + The @code{with'ing} unit (that is the client) has an explicit pragma + @code{Elaborate_All} for the @code{with'ed} unit. + + @end itemize + + @noindent + If this rule is violated, that is if a unit with dynamic elaboration + checks @code{with's} a unit that does not meet one of the above four + criteria, then the binder (@code{gnatbind}) will issue a warning + similar to that in the following example: + + @smallexample + warning: "x.ads" has dynamic elaboration checks and with's + warning: "y.ads" which has static elaboration checks + @end smallexample + + @noindent + These warnings indicate that the rule has been violated, and that as a result + elaboration checks may be missed in the resulting executable file. + This warning may be suppressed using the @code{-ws} binder switch + in the usual manner. + + One useful application of this mixing rule is in the case of a subsystem + which does not itself @code{with} units from the remainder of the + application. In this case, the entire subsystem can be compiled with + dynamic checks to resolve a circularity in the subsystem, while + allowing the main application that uses this subsystem to be compiled + using the more reliable default static model. + + @node What to Do If the Default Elaboration Behavior Fails + @section What to Do If the Default Elaboration Behavior Fails + + @noindent + If the binder cannot find an acceptable order, it outputs detailed + diagnostics. For example: + @smallexample + @group + @iftex + @leftskip=0cm + @end iftex + error: elaboration circularity detected + info: "proc (body)" must be elaborated before "pack (body)" + info: reason: Elaborate_All probably needed in unit "pack (body)" + info: recompile "pack (body)" with -gnatwl + info: for full details + info: "proc (body)" + info: is needed by its spec: + info: "proc (spec)" + info: which is withed by: + info: "pack (body)" + info: "pack (body)" must be elaborated before "proc (body)" + info: reason: pragma Elaborate in unit "proc (body)" + @end group + + @end smallexample + + @noindent + In this case we have a cycle that the binder cannot break. On the one + hand, there is an explicit pragma Elaborate in @code{proc} for + @code{pack}. This means that the body of @code{pack} must be elaborated + before the body of @code{proc}. On the other hand, there is elaboration + code in @code{pack} that calls a subprogram in @code{proc}. This means + that for maximum safety, there should really be a pragma + Elaborate_All in @code{pack} for @code{proc} which would require that + the body of @code{proc} be elaborated before the body of + @code{pack}. Clearly both requirements cannot be satisfied. + Faced with a circularity of this kind, you have three different options. + + @table @asis + @item Fix the program + The most desirable option from the point of view of long-term maintenance + is to rearrange the program so that the elaboration problems are avoided. + One useful technique is to place the elaboration code into separate + child packages. Another is to move some of the initialization code to + explicitly called subprograms, where the program controls the order + of initialization explicitly. Although this is the most desirable option, + it may be impractical and involve too much modification, especially in + the case of complex legacy code. + + @item Perform dynamic checks + If the compilations are done using the + @option{-gnatE} + (dynamic elaboration check) switch, then GNAT behaves in + a quite different manner. Dynamic checks are generated for all calls + that could possibly result in raising an exception. With this switch, + the compiler does not generate implicit @code{Elaborate_All} pragmas. + The behavior then is exactly as specified in the Ada 95 Reference Manual. + The binder will generate an executable program that may or may not + raise @code{Program_Error}, and then it is the programmer's job to ensure + that it does not raise an exception. Note that it is important to + compile all units with the switch, it cannot be used selectively. + + @item Suppress checks + The drawback of dynamic checks is that they generate a + significant overhead at run time, both in space and time. If you + are absolutely sure that your program cannot raise any elaboration + exceptions, and you still want to use the dynamic elaboration model, + then you can use the configuration pragma + @code{Suppress (Elaboration_Checks)} to suppress all such checks. For + example this pragma could be placed in the @file{gnat.adc} file. + + @item Suppress checks selectively + When you know that certain calls in elaboration code cannot possibly + lead to an elaboration error, and the binder nevertheless generates warnings + on those calls and inserts Elaborate_All pragmas that lead to elaboration + circularities, it is possible to remove those warnings locally and obtain + a program that will bind. Clearly this can be unsafe, and it is the + responsibility of the programmer to make sure that the resulting program has + no elaboration anomalies. The pragma @code{Suppress (Elaboration_Check)} can + be used with different granularity to suppress warnings and break + elaboration circularities: + + @itemize @bullet + @item + Place the pragma that names the called subprogram in the declarative part + that contains the call. + + @item + Place the pragma in the declarative part, without naming an entity. This + disables warnings on all calls in the corresponding declarative region. + + @item + Place the pragma in the package spec that declares the called subprogram, + and name the subprogram. This disables warnings on all elaboration calls to + that subprogram. + + @item + Place the pragma in the package spec that declares the called subprogram, + without naming any entity. This disables warnings on all elaboration calls to + all subprograms declared in this spec. + @end itemize + + @noindent + These four cases are listed in order of decreasing safety, and therefore + require increasing programmer care in their application. Consider the + following program: + @smallexample + + package Pack1 is + function F1 return Integer; + X1 : Integer; + end Pack1; + + package Pack2 is + function F2 return Integer; + function Pure (x : integer) return integer; + -- pragma Suppress (Elaboration_Check, On => Pure); -- (3) + -- pragma Suppress (Elaboration_Check); -- (4) + end Pack2; + + with Pack2; + package body Pack1 is + function F1 return Integer is + begin + return 100; + end F1; + Val : integer := Pack2.Pure (11); -- Elab. call (1) + begin + declare + -- pragma Suppress(Elaboration_Check, Pack2.F2); -- (1) + -- pragma Suppress(Elaboration_Check); -- (2) + begin + X1 := Pack2.F2 + 1; -- Elab. call (2) + end; + end Pack1; + + with Pack1; + package body Pack2 is + function F2 return Integer is + begin + return Pack1.F1; + end F2; + function Pure (x : integer) return integer is + begin + return x ** 3 - 3 * x; + end; + end Pack2; + + with Pack1, Ada.Text_IO; + procedure Proc3 is + begin + Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101 + end Proc3; + @end smallexample + In the absence of any pragmas, an attempt to bind this program produces + the following diagnostics: + @smallexample + @group + @iftex + @leftskip=.5cm + @end iftex + error: elaboration circularity detected + info: "pack1 (body)" must be elaborated before "pack1 (body)" + info: reason: Elaborate_All probably needed in unit "pack1 (body)" + info: recompile "pack1 (body)" with -gnatwl for full details + info: "pack1 (body)" + info: must be elaborated along with its spec: + info: "pack1 (spec)" + info: which is withed by: + info: "pack2 (body)" + info: which must be elaborated along with its spec: + info: "pack2 (spec)" + info: which is withed by: + info: "pack1 (body)" + @end group + @end smallexample + The sources of the circularity are the two calls to @code{Pack2.Pure} and + @code{Pack2.F2} in the body of @code{Pack1}. We can see that the call to + F2 is safe, even though F2 calls F1, because the call appears after the + elaboration of the body of F1. Therefore the pragma (1) is safe, and will + remove the warning on the call. It is also possible to use pragma (2) + because there are no other potentially unsafe calls in the block. + + @noindent + The call to @code{Pure} is safe because this function does not depend on the + state of @code{Pack2}. Therefore any call to this function is safe, and it + is correct to place pragma (3) in the corresponding package spec. + + @noindent + Finally, we could place pragma (4) in the spec of @code{Pack2} to disable + warnings on all calls to functions declared therein. Note that this is not + necessarily safe, and requires more detailed examination of the subprogram + bodies involved. In particular, a call to @code{F2} requires that @code{F1} + be already elaborated. + @end table + + @noindent + It is hard to generalize on which of these four approaches should be + taken. Obviously if it is possible to fix the program so that the default + treatment works, this is preferable, but this may not always be practical. + It is certainly simple enough to use + @option{-gnatE} + but the danger in this case is that, even if the GNAT binder + finds a correct elaboration order, it may not always do so, + and certainly a binder from another Ada compiler might not. A + combination of testing and analysis (for which the warnings generated + with the + @option{-gnatwl} + switch can be useful) must be used to ensure that the program is free + of errors. One switch that is useful in this testing is the + @code{-p (pessimistic elaboration order)} + switch for + @code{gnatbind}. + Normally the binder tries to find an order that has the best chance of + of avoiding elaboration problems. With this switch, the binder + plays a devil's advocate role, and tries to choose the order that + has the best chance of failing. If your program works even with this + switch, then it has a better chance of being error free, but this is still + not a guarantee. + + For an example of this approach in action, consider the C-tests (executable + tests) from the ACVC suite. If these are compiled and run with the default + treatment, then all but one of them succeed without generating any error + diagnostics from the binder. However, there is one test that fails, and + this is not surprising, because the whole point of this test is to ensure + that the compiler can handle cases where it is impossible to determine + a correct order statically, and it checks that an exception is indeed + raised at run time. + + This one test must be compiled and run using the + @option{-gnatE} + switch, and then it passes. Alternatively, the entire suite can + be run using this switch. It is never wrong to run with the dynamic + elaboration switch if your code is correct, and we assume that the + C-tests are indeed correct (it is less efficient, but efficiency is + not a factor in running the ACVC tests.) + + @node Elaboration for Access-to-Subprogram Values + @section Elaboration for Access-to-Subprogram Values + @cindex Access-to-subprogram + + @noindent + The introduction of access-to-subprogram types in Ada 95 complicates + the handling of elaboration. The trouble is that it becomes + impossible to tell at compile time which procedure + is being called. This means that it is not possible for the binder + to analyze the elaboration requirements in this case. + + If at the point at which the access value is created + (i.e., the evaluation of @code{P'Access} for a subprogram @code{P}), + the body of the subprogram is + known to have been elaborated, then the access value is safe, and its use + does not require a check. This may be achieved by appropriate arrangement + of the order of declarations if the subprogram is in the current unit, + or, if the subprogram is in another unit, by using pragma + @code{Pure}, @code{Preelaborate}, or @code{Elaborate_Body} + on the referenced unit. + + If the referenced body is not known to have been elaborated at the point + the access value is created, then any use of the access value must do a + dynamic check, and this dynamic check will fail and raise a + @code{Program_Error} exception if the body has not been elaborated yet. + GNAT will generate the necessary checks, and in addition, if the + @option{-gnatwl} + switch is set, will generate warnings that such checks are required. + + The use of dynamic dispatching for tagged types similarly generates + a requirement for dynamic checks, and premature calls to any primitive + operation of a tagged type before the body of the operation has been elaborated, + will result in the raising of @code{Program_Error}. + + @node Summary of Procedures for Elaboration Control + @section Summary of Procedures for Elaboration Control + @cindex Elaboration control + + @noindent + First, compile your program with the default options, using none of + the special elaboration control switches. If the binder successfully + binds your program, then you can be confident that, apart from issues + raised by the use of access-to-subprogram types and dynamic dispatching, + the program is free of elaboration errors. If it is important that the + program be portable, then use the + @option{-gnatwl} + switch to generate warnings about missing @code{Elaborate_All} + pragmas, and supply the missing pragmas. + + If the program fails to bind using the default static elaboration + handling, then you can fix the program to eliminate the binder + message, or recompile the entire program with the + @option{-gnatE} switch to generate dynamic elaboration checks, + and, if you are sure there really are no elaboration problems, + use a global pragma @code{Suppress (Elaboration_Checks)}. + + @node Other Elaboration Order Considerations + @section Other Elaboration Order Considerations + @noindent + This section has been entirely concerned with the issue of finding a valid + elaboration order, as defined by the Ada Reference Manual. In a case + where several elaboration orders are valid, the task is to find one + of the possible valid elaboration orders (and the static model in GNAT + will ensure that this is achieved). + + The purpose of the elaboration rules in the Ada Reference Manual is to + make sure that no entity is accessed before it has been elaborated. For + a subprogram, this means that the spec and body must have been elaborated + before the subprogram is called. For an object, this means that the object + must have been elaborated before its value is read or written. A violation + of either of these two requirements is an access before elaboration order, + and this section has been all about avoiding such errors. + + In the case where more than one order of elaboration is possible, in the + sense that access before elaboration errors are avoided, then any one of + the orders is "correct" in the sense that it meets the requirements of + the Ada Reference Manual, and no such error occurs. + + However, it may be the case for a given program, that there are + constraints on the order of elaboration that come not from consideration + of avoiding elaboration errors, but rather from extra-lingual logic + requirements. Consider this example: + + @smallexample + with Init_Constants; + package Constants is + X : Integer := 0; + Y : Integer := 0; + end Constants; + + package Init_Constants is + procedure Calc; + end Init_Constants; + + with Constants; + package body Init_Constants is + procedure Calc is begin null; end; + begin + Constants.X := 3; + Constants.Y := 4; + end Init_Constants; + + with Constants; + package Calc is + Z : Integer := Constants.X + Constants.Y; + end Calc; + + with Calc; + with Text_IO; use Text_IO; + procedure Main is + begin + Put_Line (Calc.Z'Img); + end Main; + @end smallexample + + @noindent + In this example, there is more than one valid order of elaboration. For + example both the following are correct orders: + + @smallexample + Init_Constants spec + Constants spec + Calc spec + Main body + Init_Constants body + + and + + Init_Constants spec + Init_Constants body + Constants spec + Calc spec + Main body + @end smallexample + + @noindent + There is no language rule to prefer one or the other, both are correct + from an order of elaboration point of view. But the programmatic effects + of the two orders are very different. In the first, the elaboration routine + of @code{Calc} initializes @code{Z} to zero, and then the main program + runs with this value of zero. But in the second order, the elaboration + routine of @code{Calc} runs after the body of Init_Constants has set + @code{X} and @code{Y} and thus @code{Z} is set to 7 before @code{Main} + runs. + + One could perhaps by applying pretty clever non-artificial intelligence + to the situation guess that it is more likely that the second order of + elaboration is the one desired, but there is no formal linguistic reason + to prefer one over the other. In fact in this particular case, GNAT will + prefer the second order, because of the rule that bodies are elaborated + as soon as possible, but it's just luck that this is what was wanted + (if indeed the second order was preferred). + + If the program cares about the order of elaboration routines in a case like + this, it is important to specify the order required. In this particular + case, that could have been achieved by adding to the spec of Calc: + + @smallexample + pragma Elaborate_All (Constants); + @end smallexample + + @noindent + which requires that the body (if any) and spec of @code{Constants}, + as well as the body and spec of any unit @code{with}'ed by + @code{Constants} be elaborated before @code{Calc} is elaborated. + + Clearly no automatic method can always guess which alternative you require, + and if you are working with legacy code that had constraints of this kind + which were not properly specified by adding @code{Elaborate} or + @code{Elaborate_All} pragmas, then indeed it is possible that two different + compilers can choose different orders. + + The @code{gnatbind} + @code{-p} switch may be useful in smoking + out problems. This switch causes bodies to be elaborated as late as possible + instead of as early as possible. In the example above, it would have forced + the choice of the first elaboration order. If you get different results + when using this switch, and particularly if one set of results is right, + and one is wrong as far as you are concerned, it shows that you have some + missing @code{Elaborate} pragmas. For the example above, we have the + following output: + + @smallexample + gnatmake -f -q main + main + 7 + gnatmake -f -q main -bargs -p + main + 0 + @end smallexample + + @noindent + It is of course quite unlikely that both these results are correct, so + it is up to you in a case like this to investigate the source of the + difference, by looking at the two elaboration orders that are chosen, + and figuring out which is correct, and then adding the necessary + @code{Elaborate_All} pragmas to ensure the desired order. + + @node The Cross-Referencing Tools gnatxref and gnatfind + @chapter The Cross-Referencing Tools @code{gnatxref} and @code{gnatfind} + @findex gnatxref + @findex gnatfind + + @noindent + The compiler generates cross-referencing information (unless + you set the @samp{-gnatx} switch), which are saved in the @file{.ali} files. + This information indicates where in the source each entity is declared and + referenced. Note that entities in package Standard are not included, but + entities in all other predefined units are included in the output. + + Before using any of these two tools, you need to compile successfully your + application, so that GNAT gets a chance to generate the cross-referencing + information. + + The two tools @code{gnatxref} and @code{gnatfind} take advantage of this + information to provide the user with the capability to easily locate the + declaration and references to an entity. These tools are quite similar, + the difference being that @code{gnatfind} is intended for locating + definitions and/or references to a specified entity or entities, whereas + @code{gnatxref} is oriented to generating a full report of all + cross-references. + + To use these tools, you must not compile your application using the + @option{-gnatx} switch on the @file{gnatmake} command line (@inforef{The + GNAT Make Program gnatmake,,gnat_ug}). Otherwise, cross-referencing + information will not be generated. + + @menu + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + @end menu + + @node gnatxref Switches + @section @code{gnatxref} Switches + + @noindent + The command lines for @code{gnatxref} is: + @smallexample + $ gnatxref [switches] sourcefile1 [sourcefile2 ...] + @end smallexample + + @noindent + where + + @table @code + @item sourcefile1, sourcefile2 + identifies the source files for which a report is to be generated. The + 'with'ed units will be processed too. You must provide at least one file. + + These file names are considered to be regular expressions, so for instance + specifying 'source*.adb' is the same as giving every file in the current + directory whose name starts with 'source' and whose extension is 'adb'. + + @end table + + @noindent + The switches can be : + @table @code + @item -a + If this switch is present, @code{gnatfind} and @code{gnatxref} will parse + the read-only files found in the library search path. Otherwise, these files + will be ignored. This option can be used to protect Gnat sources or your own + libraries from being parsed, thus making @code{gnatfind} and @code{gnatxref} + much faster, and their output much smaller. + + @item -aIDIR + When looking for source files also look in directory DIR. The order in which + source file search is undertaken is the same as for @file{gnatmake}. + + @item -aODIR + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as for + @file{gnatmake}. + + @item -nostdinc + Do not look for sources in the system default directory. + + @item -nostdlib + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatxref}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -d + If this switch is set @code{gnatxref} will output the parent type + reference for each matching derived types. + + @item -f + If this switch is set, the output file names will be preceded by their + directory (if the file was found in the search path). If this switch is + not set, the directory will not be printed. + + @item -g + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may accelerate + @code{gnatfind} and @code{gnatxref}. + + @item -IDIR + Equivalent to @samp{-aODIR -aIDIR}. + + @item -pFILE + Specify a project file to use @xref{Project Files}. + By default, @code{gnatxref} and @code{gnatfind} will try to locate a + project file in the current directory. + + If a project file is either specified or found by the tools, then the content + of the source directory and object directory lines are added as if they + had been specified respectively by @samp{-aI} + and @samp{-aO}. + @item -u + Output only unused symbols. This may be really useful if you give your + main compilation unit on the command line, as @code{gnatxref} will then + display every unused entity and 'with'ed package. + + @item -v + Instead of producing the default output, @code{gnatxref} will generate a + @file{tags} file that can be used by vi. For examples how to use this + feature, see @xref{Examples of gnatxref Usage}. The tags file is output + to the standard output, thus you will have to redirect it to a file. + + @end table + + All these switches may be in any order on the command line, and may even + appear after the file names. They need not be separated by spaces, thus + you can say @samp{gnatxref -ag} instead of + @samp{gnatxref -a -g}. + + @node gnatfind Switches + @section @code{gnatfind} Switches + + @noindent + The command line for @code{gnatfind} is: + + @smallexample + $ gnatfind [switches] pattern[:sourcefile[:line[:column]]] + [file1 file2 ...] + @end smallexample + + @noindent + where + + @table @code + @item pattern + An entity will be output only if it matches the regular expression found + in @samp{pattern}, see @xref{Regular Expressions in gnatfind and gnatxref}. + + Omitting the pattern is equivalent to specifying @samp{*}, which + will match any entity. Note that if you do not provide a pattern, you + have to provide both a sourcefile and a line. + + Entity names are given in Latin-1, with uppercase/lowercase equivalence + for matching purposes. At the current time there is no support for + 8-bit codes other than Latin-1, or for wide characters in identifiers. + + @item sourcefile + @code{gnatfind} will look for references, bodies or declarations + of symbols referenced in @file{sourcefile}, at line @samp{line} + and column @samp{column}. See @pxref{Examples of gnatfind Usage} + for syntax examples. + + @item line + is a decimal integer identifying the line number containing + the reference to the entity (or entities) to be located. + + @item column + is a decimal integer identifying the exact location on the + line of the first character of the identifier for the + entity reference. Columns are numbered from 1. + + @item file1 file2 ... + The search will be restricted to these files. If none are given, then + the search will be done for every library file in the search path. + These file must appear only after the pattern or sourcefile. + + These file names are considered to be regular expressions, so for instance + specifying 'source*.adb' is the same as giving every file in the current + directory whose name starts with 'source' and whose extension is 'adb'. + + Not that if you specify at least one file in this part, @code{gnatfind} may + sometimes not be able to find the body of the subprograms... + + @end table + + At least one of 'sourcefile' or 'pattern' has to be present on + the command line. + + The following switches are available: + @table @code + + @item -a + If this switch is present, @code{gnatfind} and @code{gnatxref} will parse + the read-only files found in the library search path. Otherwise, these files + will be ignored. This option can be used to protect Gnat sources or your own + libraries from being parsed, thus making @code{gnatfind} and @code{gnatxref} + much faster, and their output much smaller. + + @item -aIDIR + When looking for source files also look in directory DIR. The order in which + source file search is undertaken is the same as for @file{gnatmake}. + + @item -aODIR + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as for + @file{gnatmake}. + + @item -nostdinc + Do not look for sources in the system default directory. + + @item -nostdlib + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatfind}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -d + If this switch is set, then @code{gnatfind} will output the parent type + reference for each matching derived types. + + @item -e + By default, @code{gnatfind} accept the simple regular expression set for + @samp{pattern}. If this switch is set, then the pattern will be + considered as full Unix-style regular expression. + + @item -f + If this switch is set, the output file names will be preceded by their + directory (if the file was found in the search path). If this switch is + not set, the directory will not be printed. + + @item -g + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may accelerate + @code{gnatfind} and @code{gnatxref}. + + @item -IDIR + Equivalent to @samp{-aODIR -aIDIR}. + + @item -pFILE + Specify a project file (@pxref{Project Files}) to use. + By default, @code{gnatxref} and @code{gnatfind} will try to locate a + project file in the current directory. + + If a project file is either specified or found by the tools, then the content + of the source directory and object directory lines are added as if they + had been specified respectively by @samp{-aI} and + @samp{-aO}. + + @item -r + By default, @code{gnatfind} will output only the information about the + declaration, body or type completion of the entities. If this switch is + set, the @code{gnatfind} will locate every reference to the entities in + the files specified on the command line (or in every file in the search + path if no file is given on the command line). + + @item -s + If this switch is set, then @code{gnatfind} will output the content + of the Ada source file lines were the entity was found. + + @item -t + If this switch is set, then @code{gnatfind} will output the type hierarchy for + the specified type. It act like -d option but recursively from parent + type to parent type. When this switch is set it is not possible to + specify more than one file. + + @end table + + All these switches may be in any order on the command line, and may even + appear after the file names. They need not be separated by spaces, thus + you can say @samp{gnatxref -ag} instead of + @samp{gnatxref -a -g}. + + As stated previously, gnatfind will search in every directory in the + search path. You can force it to look only in the current directory if + you specify @code{*} at the end of the command line. + + + @node Project Files for gnatxref and gnatfind + @section Project Files for @command{gnatxref} and @command{gnatfind} + + @noindent + Project files allow a programmer to specify how to compile its + application, where to find sources,... These files are used primarily by + the Glide Ada mode, but they can also be used by the two tools + @code{gnatxref} and @code{gnatfind}. + + A project file name must end with @file{.adp}. If a single one is + present in the current directory, then @code{gnatxref} and @code{gnatfind} will + extract the information from it. If multiple project files are found, none of + them is read, and you have to use the @samp{-p} switch to specify the one + you want to use. + + The following lines can be included, even though most of them have default + values which can be used in most cases. + The lines can be entered in any order in the file. + Except for @samp{src_dir} and @samp{obj_dir}, you can only have one instance of + each line. If you have multiple instances, only the last one is taken into + account. + + @table @code + @item src_dir=DIR [default: "./"] + specifies a directory where to look for source files. Multiple src_dir lines + can be specified and they will be searched in the order they + are specified. + + @item obj_dir=DIR [default: "./"] + specifies a directory where to look for object and library files. Multiple + obj_dir lines can be specified and they will be searched in the order they + are specified + + @item comp_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{comp_opt@}} notation. This is intended to store the default + switches given to @file{gnatmake} and @file{gcc}. + + @item bind_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{bind_opt@}} notation. This is intended to store the default + switches given to @file{gnatbind}. + + @item link_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{link_opt@}} notation. This is intended to store the default + switches given to @file{gnatlink}. + + @item main=EXECUTABLE [default: ""] + specifies the name of the executable for the application. This variable can + be referred to in the following lines by using the @samp{$@{main@}} notation. + + @item comp_cmd=COMMAND [default: "gcc -c -I$@{src_dir@} -g -gnatq"] + specifies the command used to compile a single file in the application. + + @item make_cmd=COMMAND [default: "gnatmake $@{main@} -aI$@{src_dir@} -aO$@{obj_dir@} -g -gnatq -cargs $@{comp_opt@} -bargs $@{bind_opt@} -largs $@{link_opt@}"] + specifies the command used to recompile the whole application. + + @item run_cmd=COMMAND [default: "$@{main@}"] + specifies the command used to run the application. + + @item debug_cmd=COMMAND [default: "gdb $@{main@}"] + specifies the command used to debug the application + + @end table + + @code{gnatxref} and @code{gnatfind} only take into account the @samp{src_dir} + and @samp{obj_dir} lines, and ignore the others. + + @node Regular Expressions in gnatfind and gnatxref + @section Regular Expressions in @code{gnatfind} and @code{gnatxref} + + @noindent + As specified in the section about @code{gnatfind}, the pattern can be a + regular expression. Actually, there are to set of regular expressions + which are recognized by the program : + + @table @code + @item globbing patterns + These are the most usual regular expression. They are the same that you + generally used in a Unix shell command line, or in a DOS session. + + Here is a more formal grammar : + @smallexample + @group + @iftex + @leftskip=.5cm + @end iftex + regexp ::= term + term ::= elmt -- matches elmt + term ::= elmt elmt -- concatenation (elmt then elmt) + term ::= * -- any string of 0 or more characters + term ::= ? -- matches any character + term ::= [char @{char@}] -- matches any character listed + term ::= [char - char] -- matches any character in range + @end group + @end smallexample + + @item full regular expression + The second set of regular expressions is much more powerful. This is the + type of regular expressions recognized by utilities such a @file{grep}. + + The following is the form of a regular expression, expressed in Ada + reference manual style BNF is as follows + + @smallexample + @iftex + @leftskip=.5cm + @end iftex + @group + regexp ::= term @{| term@} -- alternation (term or term ...) + + term ::= item @{item@} -- concatenation (item then item) + + item ::= elmt -- match elmt + item ::= elmt * -- zero or more elmt's + item ::= elmt + -- one or more elmt's + item ::= elmt ? -- matches elmt or nothing + @end group + @group + elmt ::= nschar -- matches given character + elmt ::= [nschar @{nschar@}] -- matches any character listed + elmt ::= [^ nschar @{nschar@}] -- matches any character not listed + elmt ::= [char - char] -- matches chars in given range + elmt ::= \ char -- matches given character + elmt ::= . -- matches any single character + elmt ::= ( regexp ) -- parens used for grouping + + char ::= any character, including special characters + nschar ::= any character except ()[].*+?^ + @end group + @end smallexample + + Following are a few examples : + + @table @samp + @item abcde|fghi + will match any of the two strings 'abcde' and 'fghi'. + + @item abc*d + will match any string like 'abd', 'abcd', 'abccd', 'abcccd', and so on + + @item [a-z]+ + will match any string which has only lowercase characters in it (and at + least one character + + @end table + @end table + + @node Examples of gnatxref Usage + @section Examples of @code{gnatxref} Usage + + @subsection General Usage + + @noindent + For the following examples, we will consider the following units : + + @smallexample + @group + @cartouche + main.ads: + 1: @b{with} Bar; + 2: @b{package} Main @b{is} + 3: @b{procedure} Foo (B : @b{in} Integer); + 4: C : Integer; + 5: @b{private} + 6: D : Integer; + 7: @b{end} Main; + + main.adb: + 1: @b{package body} Main @b{is} + 2: @b{procedure} Foo (B : @b{in} Integer) @b{is} + 3: @b{begin} + 4: C := B; + 5: D := B; + 6: Bar.Print (B); + 7: Bar.Print (C); + 8: @b{end} Foo; + 9: @b{end} Main; + + bar.ads: + 1: @b{package} Bar @b{is} + 2: @b{procedure} Print (B : Integer); + 3: @b{end} bar; + @end cartouche + @end group + @end smallexample + + @table @code + + @noindent + The first thing to do is to recompile your application (for instance, in + that case just by doing a @samp{gnatmake main}, so that GNAT generates + the cross-referencing information. + You can then issue any of the following commands: + + @item gnatxref main.adb + @code{gnatxref} generates cross-reference information for main.adb + and every unit 'with'ed by main.adb. + + The output would be: + @smallexample + @iftex + @leftskip=0cm + @end iftex + B Type: Integer + Decl: bar.ads 2:22 + B Type: Integer + Decl: main.ads 3:20 + Body: main.adb 2:20 + Ref: main.adb 4:13 5:13 6:19 + Bar Type: Unit + Decl: bar.ads 1:9 + Ref: main.adb 6:8 7:8 + main.ads 1:6 + C Type: Integer + Decl: main.ads 4:5 + Modi: main.adb 4:8 + Ref: main.adb 7:19 + D Type: Integer + Decl: main.ads 6:5 + Modi: main.adb 5:8 + Foo Type: Unit + Decl: main.ads 3:15 + Body: main.adb 2:15 + Main Type: Unit + Decl: main.ads 2:9 + Body: main.adb 1:14 + Print Type: Unit + Decl: bar.ads 2:15 + Ref: main.adb 6:12 7:12 + @end smallexample + + @noindent + that is the entity @code{Main} is declared in main.ads, line 2, column 9, + its body is in main.adb, line 1, column 14 and is not referenced any where. + + The entity @code{Print} is declared in bar.ads, line 2, column 15 and it + it referenced in main.adb, line 6 column 12 and line 7 column 12. + + @item gnatxref package1.adb package2.ads + @code{gnatxref} will generates cross-reference information for + package1.adb, package2.ads and any other package 'with'ed by any + of these. + + @end table + + @subsection Using gnatxref with vi + + @code{gnatxref} can generate a tags file output, which can be used + directly from @file{vi}. Note that the standard version of @file{vi} + will not work properly with overloaded symbols. Consider using another + free implementation of @file{vi}, such as @file{vim}. + + @smallexample + $ gnatxref -v gnatfind.adb > tags + @end smallexample + + @noindent + will generate the tags file for @code{gnatfind} itself (if the sources + are in the search path!). + + From @file{vi}, you can then use the command @samp{:tag @i{entity}} + (replacing @i{entity} by whatever you are looking for), and vi will + display a new file with the corresponding declaration of entity. + + @node Examples of gnatfind Usage + @section Examples of @code{gnatfind} Usage + + @table @code + + @item gnatfind -f xyz:main.adb + Find declarations for all entities xyz referenced at least once in + main.adb. The references are search in every library file in the search + path. + + The directories will be printed as well (as the @samp{-f} + switch is set) + + The output will look like: + @smallexample + directory/main.ads:106:14: xyz <= declaration + directory/main.adb:24:10: xyz <= body + directory/foo.ads:45:23: xyz <= declaration + @end smallexample + + @noindent + that is to say, one of the entities xyz found in main.adb is declared at + line 12 of main.ads (and its body is in main.adb), and another one is + declared at line 45 of foo.ads + + @item gnatfind -fs xyz:main.adb + This is the same command as the previous one, instead @code{gnatfind} will + display the content of the Ada source file lines. + + The output will look like: + + @smallexample + directory/main.ads:106:14: xyz <= declaration + procedure xyz; + directory/main.adb:24:10: xyz <= body + procedure xyz is + directory/foo.ads:45:23: xyz <= declaration + xyz : Integer; + @end smallexample + + @noindent + This can make it easier to find exactly the location your are looking + for. + + @item gnatfind -r "*x*":main.ads:123 foo.adb + Find references to all entities containing an x that are + referenced on line 123 of main.ads. + The references will be searched only in main.adb and foo.adb. + + @item gnatfind main.ads:123 + Find declarations and bodies for all entities that are referenced on + line 123 of main.ads. + + This is the same as @code{gnatfind "*":main.adb:123}. + + @item gnatfind mydir/main.adb:123:45 + Find the declaration for the entity referenced at column 45 in + line 123 of file main.adb in directory mydir. Note that it + is usual to omit the identifier name when the column is given, + since the column position identifies a unique reference. + + The column has to be the beginning of the identifier, and should not + point to any character in the middle of the identifier. + + @end table + + @node File Name Krunching Using gnatkr + @chapter File Name Krunching Using @code{gnatkr} + @findex gnatkr + + @noindent + This chapter discusses the method used by the compiler to shorten + the default file names chosen for Ada units so that they do not + exceed the maximum length permitted. It also describes the + @code{gnatkr} utility that can be used to determine the result of + applying this shortening. + @menu + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + @end menu + + @node About gnatkr + @section About @code{gnatkr} + + @noindent + The default file naming rule in GNAT + is that the file name must be derived from + the unit name. The exact default rule is as follows: + @itemize @bullet + @item + Take the unit name and replace all dots by hyphens. + @item + If such a replacement occurs in the + second character position of a name, and the first character is + a, g, s, or i then replace the dot by the character + ~ (tilde) + instead of a minus. + @end itemize + The reason for this exception is to avoid clashes + with the standard names for children of System, Ada, Interfaces, + and GNAT, which use the prefixes s- a- i- and g- + respectively. + + The @code{-gnatk@var{nn}} + switch of the compiler activates a "krunching" + circuit that limits file names to nn characters (where nn is a decimal + integer). For example, using OpenVMS, + where the maximum file name length is + 39, the value of nn is usually set to 39, but if you want to generate + a set of files that would be usable if ported to a system with some + different maximum file length, then a different value can be specified. + The default value of 39 for OpenVMS need not be specified. + + The @code{gnatkr} utility can be used to determine the krunched name for + a given file, when krunched to a specified maximum length. + + @node Using gnatkr + @section Using @code{gnatkr} + + @noindent + The @code{gnatkr} command has the form + + @smallexample + $ gnatkr @var{name} [@var{length}] + @end smallexample + + + @noindent + @var{name} can be an Ada name with dots or the GNAT name of the unit, + where the dots representing child units or subunit are replaced by + hyphens. The only confusion arises if a name ends in @code{.ads} or + @code{.adb}. @code{gnatkr} takes this to be an extension if there are + no other dots in the name and the whole name is in lowercase. + + @var{length} represents the length of the krunched name. The default + when no argument is given is 8 characters. A length of zero stands for + unlimited, in other words do not chop except for system files which are + always 8. + + @noindent + The output is the krunched name. The output has an extension only if the + original argument was a file name with an extension. + + @node Krunching Method + @section Krunching Method + + @noindent + The initial file name is determined by the name of the unit that the file + contains. The name is formed by taking the full expanded name of the + unit and replacing the separating dots with hyphens and + using lowercase + for all letters, except that a hyphen in the second character position is + replaced by a tilde if the first character is + a, i, g, or s. + The extension is @code{.ads} for a + specification and @code{.adb} for a body. + Krunching does not affect the extension, but the file name is shortened to + the specified length by following these rules: + + @itemize @bullet + @item + The name is divided into segments separated by hyphens, tildes or + underscores and all hyphens, tildes, and underscores are + eliminated. If this leaves the name short enough, we are done. + + @item + If the name is too long, the longest segment is located (left-most if there are two + of equal length), and shortened by dropping its last character. This is + repeated until the name is short enough. + + As an example, consider the krunching of @*@file{our-strings-wide_fixed.adb} + to fit the name into 8 characters as required by some operating systems. + + @smallexample + our-strings-wide_fixed 22 + our strings wide fixed 19 + our string wide fixed 18 + our strin wide fixed 17 + our stri wide fixed 16 + our stri wide fixe 15 + our str wide fixe 14 + our str wid fixe 13 + our str wid fix 12 + ou str wid fix 11 + ou st wid fix 10 + ou st wi fix 9 + ou st wi fi 8 + Final file name: oustwifi.adb + @end smallexample + + @item + The file names for all predefined units are always krunched to eight + characters. The krunching of these predefined units uses the following + special prefix replacements: + + @table @file + @item ada- + replaced by @file{a-} + + @item gnat- + replaced by @file{g-} + + @item interfaces- + replaced by @file{i-} + + @item system- + replaced by @file{s-} + @end table + + These system files have a hyphen in the second character position. That + is why normal user files replace such a character with a + tilde, to + avoid confusion with system file names. + + As an example of this special rule, consider + @*@file{ada-strings-wide_fixed.adb}, which gets krunched as follows: + + @smallexample + ada-strings-wide_fixed 22 + a- strings wide fixed 18 + a- string wide fixed 17 + a- strin wide fixed 16 + a- stri wide fixed 15 + a- stri wide fixe 14 + a- str wide fixe 13 + a- str wid fixe 12 + a- str wid fix 11 + a- st wid fix 10 + a- st wi fix 9 + a- st wi fi 8 + Final file name: a-stwifi.adb + @end smallexample + @end itemize + + Of course no file shortening algorithm can guarantee uniqueness over all + possible unit names, and if file name krunching is used then it is your + responsibility to ensure that no name clashes occur. The utility + program @code{gnatkr} is supplied for conveniently determining the + krunched name of a file. + + @node Examples of gnatkr Usage + @section Examples of @code{gnatkr} Usage + + @smallexample + @iftex + @leftskip=0cm + @end iftex + $ gnatkr very_long_unit_name.ads --> velounna.ads + $ gnatkr grandparent-parent-child.ads --> grparchi.ads + $ gnatkr Grandparent.Parent.Child --> grparchi + $ gnatkr very_long_unit_name.ads/count=6 --> vlunna.ads + $ gnatkr very_long_unit_name.ads/count=0 --> very_long_unit_name.ads + @end smallexample + + @node Preprocessing Using gnatprep + @chapter Preprocessing Using @code{gnatprep} + @findex gnatprep + + @noindent + The @code{gnatprep} utility provides + a simple preprocessing capability for Ada programs. + It is designed for use with GNAT, but is not dependent on any special + features of GNAT. + + @menu + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + @end menu + + @node Using gnatprep + @section Using @code{gnatprep} + + @noindent + To call @code{gnatprep} use + + @smallexample + $ gnatprep [-bcrsu] [-Dsymbol=value] infile outfile [deffile] + @end smallexample + + @noindent + where + @table @code + @item infile + is the full name of the input file, which is an Ada source + file containing preprocessor directives. + + @item outfile + is the full name of the output file, which is an Ada source + in standard Ada form. When used with GNAT, this file name will + normally have an ads or adb suffix. + + @item deffile + is the full name of a text file containing definitions of + symbols to be referenced by the preprocessor. This argument is + optional, and can be replaced by the use of the @code{-D} switch. + + @item switches + is an optional sequence of switches as described in the next section. + @end table + + @node Switches for gnatprep + @section Switches for @code{gnatprep} + + @table @code + + @item -b + Causes both preprocessor lines and the lines deleted by + preprocessing to be replaced by blank lines in the output source file, + preserving line numbers in the output file. + + @item -c + Causes both preprocessor lines and the lines deleted + by preprocessing to be retained in the output source as comments marked + with the special string "--! ". This option will result in line numbers + being preserved in the output file. + + @item -Dsymbol=value + Defines a new symbol, associated with value. If no value is given on the + command line, then symbol is considered to be @code{True}. This switch + can be used in place of a definition file. + + + @item -r + Causes a @code{Source_Reference} pragma to be generated that + references the original input file, so that error messages will use + the file name of this original file. The use of this switch implies + that preprocessor lines are not to be removed from the file, so its + use will force @code{-b} mode if + @code{-c} + has not been specified explicitly. + + Note that if the file to be preprocessed contains multiple units, then + it will be necessary to @code{gnatchop} the output file from + @code{gnatprep}. If a @code{Source_Reference} pragma is present + in the preprocessed file, it will be respected by + @code{gnatchop -r} + so that the final chopped files will correctly refer to the original + input source file for @code{gnatprep}. + + @item -s + Causes a sorted list of symbol names and values to be + listed on the standard output file. + + @item -u + Causes undefined symbols to be treated as having the value FALSE in the context + of a preprocessor test. In the absence of this option, an undefined symbol in + a @code{#if} or @code{#elsif} test will be treated as an error. + + @end table + + @noindent + Note: if neither @code{-b} nor @code{-c} is present, + then preprocessor lines and + deleted lines are completely removed from the output, unless -r is + specified, in which case -b is assumed. + + @node Form of Definitions File + @section Form of Definitions File + + @noindent + The definitions file contains lines of the form + + @smallexample + symbol := value + @end smallexample + + @noindent + where symbol is an identifier, following normal Ada (case-insensitive) + rules for its syntax, and value is one of the following: + + @itemize @bullet + @item + Empty, corresponding to a null substitution + @item + A string literal using normal Ada syntax + @item + Any sequence of characters from the set + (letters, digits, period, underline). + @end itemize + + @noindent + Comment lines may also appear in the definitions file, starting with + the usual @code{--}, + and comments may be added to the definitions lines. + + @node Form of Input Text for gnatprep + @section Form of Input Text for @code{gnatprep} + + @noindent + The input text may contain preprocessor conditional inclusion lines, + as well as general symbol substitution sequences. + + The preprocessor conditional inclusion commands have the form + + @smallexample + @group + @cartouche + #if @i{expression} [then] + lines + #elsif @i{expression} [then] + lines + #elsif @i{expression} [then] + lines + ... + #else + lines + #end if; + @end cartouche + @end group + @end smallexample + + @noindent + In this example, @i{expression} is defined by the following grammar: + @smallexample + @i{expression} ::= + @i{expression} ::= = "" + @i{expression} ::= = + @i{expression} ::= 'Defined + @i{expression} ::= not @i{expression} + @i{expression} ::= @i{expression} and @i{expression} + @i{expression} ::= @i{expression} or @i{expression} + @i{expression} ::= @i{expression} and then @i{expression} + @i{expression} ::= @i{expression} or else @i{expression} + @i{expression} ::= ( @i{expression} ) + @end smallexample + + @noindent + For the first test (@i{expression} ::= ) the symbol must have + either the value true or false, that is to say the right-hand of the + symbol definition must be one of the (case-insensitive) literals + @code{True} or @code{False}. If the value is true, then the + corresponding lines are included, and if the value is false, they are + excluded. + + The test (@i{expression} ::= @code{'Defined}) is true only if + the symbol has been defined in the definition file or by a @code{-D} + switch on the command line. Otherwise, the test is false. + + The equality tests are case insensitive, as are all the preprocessor lines. + + If the symbol referenced is not defined in the symbol definitions file, + then the effect depends on whether or not switch @code{-u} + is specified. If so, then the symbol is treated as if it had the value + false and the test fails. If this switch is not specified, then + it is an error to reference an undefined symbol. It is also an error to + reference a symbol that is defined with a value other than @code{True} + or @code{False}. + + The use of the @code{not} operator inverts the sense of this logical test, so + that the lines are included only if the symbol is not defined. + The @code{then} keyword is optional as shown + + The @code{#} must be the first non-blank character on a line, but + otherwise the format is free form. Spaces or tabs may appear between + the @code{#} and the keyword. The keywords and the symbols are case + insensitive as in normal Ada code. Comments may be used on a + preprocessor line, but other than that, no other tokens may appear on a + preprocessor line. Any number of @code{elsif} clauses can be present, + including none at all. The @code{else} is optional, as in Ada. + + The @code{#} marking the start of a preprocessor line must be the first + non-blank character on the line, i.e. it must be preceded only by + spaces or horizontal tabs. + + Symbol substitution outside of preprocessor lines is obtained by using + the sequence + + @smallexample + $symbol + @end smallexample + + @noindent + anywhere within a source line, except in a comment or within a + string literal. The identifier + following the @code{$} must match one of the symbols defined in the symbol + definition file, and the result is to substitute the value of the + symbol in place of @code{$symbol} in the output file. + + Note that although the substitution of strings within a string literal + is not possible, it is possible to have a symbol whose defined value is + a string literal. So instead of setting XYZ to @code{hello} and writing: + + @smallexample + Header : String := "$XYZ"; + @end smallexample + + @noindent + you should set XYZ to @code{"hello"} and write: + + @smallexample + Header : String := $XYZ; + @end smallexample + + @noindent + and then the substitution will occur as desired. + + + @node The GNAT Library Browser gnatls + @chapter The GNAT Library Browser @code{gnatls} + @findex gnatls + @cindex Library browser + + @noindent + @code{gnatls} is a tool that outputs information about compiled + units. It gives the relationship between objects, unit names and source + files. It can also be used to check the source dependencies of a unit + as well as various characteristics. + + @menu + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + @end menu + + @node Running gnatls + @section Running @code{gnatls} + + @noindent + The @code{gnatls} command has the form + + @smallexample + $ gnatls switches @var{object_or_ali_file} + @end smallexample + + @noindent + The main argument is the list of object or @file{ali} files + (@pxref{The Ada Library Information Files}) + for which information is requested. + + In normal mode, without additional option, @code{gnatls} produces a + four-column listing. Each line represents information for a specific + object. The first column gives the full path of the object, the second + column gives the name of the principal unit in this object, the third + column gives the status of the source and the fourth column gives the + full path of the source representing this unit. + Here is a simple example of use: + + @smallexample + $ gnatls *.o + ./demo1.o demo1 DIF demo1.adb + ./demo2.o demo2 OK demo2.adb + ./hello.o h1 OK hello.adb + ./instr-child.o instr.child MOK instr-child.adb + ./instr.o instr OK instr.adb + ./tef.o tef DIF tef.adb + ./text_io_example.o text_io_example OK text_io_example.adb + ./tgef.o tgef DIF tgef.adb + @end smallexample + + @noindent + The first line can be interpreted as follows: the main unit which is + contained in + object file @file{demo1.o} is demo1, whose main source is in + @file{demo1.adb}. Furthermore, the version of the source used for the + compilation of demo1 has been modified (DIF). Each source file has a status + qualifier which can be: + + @table @code + @item OK (unchanged) + The version of the source file used for the compilation of the + specified unit corresponds exactly to the actual source file. + + @item MOK (slightly modified) + The version of the source file used for the compilation of the + specified unit differs from the actual source file but not enough to + require recompilation. If you use gnatmake with the qualifier + @code{-m (minimal recompilation)}, a file marked + MOK will not be recompiled. + + @item DIF (modified) + No version of the source found on the path corresponds to the source + used to build this object. + + @item ??? (file not found) + No source file was found for this unit. + + @item HID (hidden, unchanged version not first on PATH) + The version of the source that corresponds exactly to the source used + for compilation has been found on the path but it is hidden by another + version of the same source that has been modified. + + @end table + + @node Switches for gnatls + @section Switches for @code{gnatls} + + @noindent + @code{gnatls} recognizes the following switches: + + @table @code + @item -a + @cindex @code{-a} (@code{gnatls}) + Consider all units, including those of the predefined Ada library. + Especially useful with @code{-d}. + + @item -d + @cindex @code{-d} (@code{gnatls}) + List sources from which specified units depend on. + + @item -h + @cindex @code{-h} (@code{gnatls}) + Output the list of options. + + @item -o + @cindex @code{-o} (@code{gnatls}) + Only output information about object files. + + @item -s + @cindex @code{-s} (@code{gnatls}) + Only output information about source files. + + @item -u + @cindex @code{-u} (@code{gnatls}) + Only output information about compilation units. + + @item -aO@var{dir} + @itemx -aI@var{dir} + @itemx -I@var{dir} + @itemx -I- + @itemx -nostdinc + Source path manipulation. Same meaning as the equivalent @code{gnatmake} flags + (see @ref{Switches for gnatmake}). + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatls}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -v + @cindex @code{-s} (@code{gnatls}) + Verbose mode. Output the complete source and object paths. Do not use + the default column layout but instead use long format giving as much as + information possible on each requested units, including special + characteristics such as: + + @table @code + @item Preelaborable + The unit is preelaborable in the Ada 95 sense. + + @item No_Elab_Code + No elaboration code has been produced by the compiler for this unit. + + @item Pure + The unit is pure in the Ada 95 sense. + + @item Elaborate_Body + The unit contains a pragma Elaborate_Body. + + @item Remote_Types + The unit contains a pragma Remote_Types. + + @item Shared_Passive + The unit contains a pragma Shared_Passive. + + @item Predefined + This unit is part of the predefined environment and cannot be modified + by the user. + + @item Remote_Call_Interface + The unit contains a pragma Remote_Call_Interface. + + @end table + + @end table + + @node Examples of gnatls Usage + @section Example of @code{gnatls} Usage + + @noindent + Example of using the verbose switch. Note how the source and + object paths are affected by the -I switch. + + @smallexample + $ gnatls -v -I.. demo1.o + + GNATLS 3.10w (970212) Copyright 1999 Free Software Foundation, Inc. + + Source Search Path: + + ../ + /home/comar/local/adainclude/ + + Object Search Path: + + ../ + /home/comar/local/lib/gcc-lib/mips-sni-sysv4/2.7.2/adalib/ + + ./demo1.o + Unit => + Name => demo1 + Kind => subprogram body + Flags => No_Elab_Code + Source => demo1.adb modified + @end smallexample + + @noindent + The following is an example of use of the dependency list. + Note the use of the -s switch + which gives a straight list of source files. This can be useful for + building specialized scripts. + + @smallexample + $ gnatls -d demo2.o + ./demo2.o demo2 OK demo2.adb + OK gen_list.ads + OK gen_list.adb + OK instr.ads + OK instr-child.ads + + $ gnatls -d -s -a demo1.o + demo1.adb + /home/comar/local/adainclude/ada.ads + /home/comar/local/adainclude/a-finali.ads + /home/comar/local/adainclude/a-filico.ads + /home/comar/local/adainclude/a-stream.ads + /home/comar/local/adainclude/a-tags.ads + gen_list.ads + gen_list.adb + /home/comar/local/adainclude/gnat.ads + /home/comar/local/adainclude/g-io.ads + instr.ads + /home/comar/local/adainclude/system.ads + /home/comar/local/adainclude/s-exctab.ads + /home/comar/local/adainclude/s-finimp.ads + /home/comar/local/adainclude/s-finroo.ads + /home/comar/local/adainclude/s-secsta.ads + /home/comar/local/adainclude/s-stalib.ads + /home/comar/local/adainclude/s-stoele.ads + /home/comar/local/adainclude/s-stratt.ads + /home/comar/local/adainclude/s-tasoli.ads + /home/comar/local/adainclude/s-unstyp.ads + /home/comar/local/adainclude/unchconv.ads + @end smallexample + + + @node GNAT and Libraries + @chapter GNAT and Libraries + @cindex Library, building, installing + + @noindent + This chapter addresses some of the issues related to building and using + a library with GNAT. It also shows how the GNAT run-time library can be + recompiled. + + @menu + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + @end menu + + @node Creating an Ada Library + @section Creating an Ada Library + + @noindent + In the GNAT environment, a library has two components: + @itemize @bullet + @item + Source files. + @item + Compiled code and Ali files. See @ref{The Ada Library Information Files}. + @end itemize + + @noindent + In order to use other packages @ref{The GNAT Compilation Model} + requires a certain number of sources to be available to the compiler. + The minimal set of + sources required includes the specs of all the packages that make up the + visible part of the library as well as all the sources upon which they + depend. The bodies of all visible generic units must also be provided. + @noindent + Although it is not strictly mandatory, it is recommended that all sources + needed to recompile the library be provided, so that the user can make + full use of inter-unit inlining and source-level debugging. This can also + make the situation easier for users that need to upgrade their compilation + toolchain and thus need to recompile the library from sources. + + @noindent + The compiled code can be provided in different ways. The simplest way is + to provide directly the set of objects produced by the compiler during + the compilation of the library. It is also possible to group the objects + into an archive using whatever commands are provided by the operating + system. Finally, it is also possible to create a shared library (see + option -shared in the GCC manual). + + @noindent + There are various possibilities for compiling the units that make up the + library: for example with a Makefile @ref{Using the GNU make Utility}, + or with a conventional script. + For simple libraries, it is also possible to create a + dummy main program which depends upon all the packages that comprise the + interface of the library. This dummy main program can then be given to + gnatmake, in order to build all the necessary objects. Here is an example + of such a dummy program and the generic commands used to build an + archive or a shared library. + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + @b{with} My_Lib.Service1; + @b{with} My_Lib.Service2; + @b{with} My_Lib.Service3; + @b{procedure} My_Lib_Dummy @b{is} + @b{begin} + @b{null}; + @b{end}; + + # compiling the library + $ gnatmake -c my_lib_dummy.adb + + # we don't need the dummy object itself + $ rm my_lib_dummy.o my_lib_dummy.ali + + # create an archive with the remaining objects + $ ar rc libmy_lib.a *.o + # some systems may require "ranlib" to be run as well + + # or create a shared library + $ gcc -shared -o libmy_lib.so *.o + # some systems may require the code to have been compiled with -fPIC + @end smallexample + + @noindent + When the objects are grouped in an archive or a shared library, the user + needs to specify the desired library at link time, unless a pragma + linker_options has been used in one of the sources: + @smallexample + @b{pragma} Linker_Options ("-lmy_lib"); + @end smallexample + + @node Installing an Ada Library + @section Installing an Ada Library + + @noindent + In the GNAT model, installing a library consists in copying into a specific + location the files that make up this library. It is possible to install + the sources in a different directory from the other files (ALI, objects, + archives) since the source path and the object path can easily be + specified separately. + + @noindent + For general purpose libraries, it is possible for the system + administrator to put those libraries in the default compiler paths. To + achieve this, he must specify their location in the configuration files + "ada_source_path" and "ada_object_path" that must be located in the GNAT + installation tree at the same place as the gcc spec file. The location of + the gcc spec file can be determined as follows: + @smallexample + $ gcc -v + @end smallexample + + @noindent + The configuration files mentioned above have simple format: each line in them + must contain one unique + directory name. Those names are added to the corresponding path + in their order of appearance in the file. The names can be either absolute + or relative, in the latter case, they are relative to where theses files + are located. + + @noindent + "ada_source_path" and "ada_object_path" might actually not be present in a + GNAT installation, in which case, GNAT will look for its run-time library in + the directories "adainclude" for the sources and "adalib" for the + objects and ALI files. When the files exist, the compiler does not + look in "adainclude" and "adalib" at all, and thus the "ada_source_path" file + must contain the location for the GNAT run-time sources (which can simply + be "adainclude"). In the same way, the "ada_object_path" file must contain + the location for the GNAT run-time objects (which can simply + be "adalib"). + + @noindent + You can also specify a new default path to the runtime library at compilation + time with the switch "--RTS=@var{rts-path}". You can easily choose and change + the runtime you want your program to be compiled with. This switch is + recognized by gcc, gnatmake, gnatbind, gnatls, gnatfind and gnatxref. + + @noindent + It is possible to install a library before or after the standard GNAT + library, by reordering the lines in the configuration files. In general, a + library must be installed before the GNAT library if it redefines any part of it. + + @node Using an Ada Library + @section Using an Ada Library + + @noindent + In order to use a Ada library, you need to make sure that this + library is on both your source and object path + @ref{Search Paths and the Run-Time Library (RTL)} + and @ref{Search Paths for gnatbind}. For + instance, you can use the library "mylib" installed in "/dir/my_lib_src" + and "/dir/my_lib_obj" with the following commands: + + @smallexample + $ gnatmake -aI/dir/my_lib_src -aO/dir/my_lib_obj my_appl \ + -largs -lmy_lib + @end smallexample + + @noindent + This can be simplified down to the following: + @smallexample + $ gnatmake my_appl + @end smallexample + when the following conditions are met: + @itemize @bullet + @item + "/dir/my_lib_src" has been added by the user to the environment + variable "ADA_INCLUDE_PATH", or by the administrator to the file + "ada_source_path" + @item + "/dir/my_lib_obj" has been added by the user to the environment + variable "ADA_OBJECTS_PATH", or by the administrator to the file + "ada_object_path" + @item + a pragma linker_options, as mentioned in @ref{Creating an Ada Library} + as been added to the sources. + @end itemize + @noindent + + @node Creating an Ada Library to be Used in a Non-Ada Context + @section Creating an Ada Library to be Used in a Non-Ada Context + + @noindent + The previous sections detailed how to create and install a library that + was usable from an Ada main program. Using this library in a non-Ada + context is not possible, because the elaboration of the library is + automatically done as part of the main program elaboration. + + GNAT also provides the ability to build libraries that can be used both + in an Ada and non-Ada context. This section describes how to build such + a library, and then how to use it from a C program. The method for + interfacing with the library from other languages such as Fortran for + instance remains the same. + + @subsection Creating the Library + + @itemize @bullet + @item Identify the units representing the interface of the library. + + Here is an example of simple library interface: + + @smallexample + package Interface is + + procedure Do_Something; + + procedure Do_Something_Else; + + end Interface; + @end smallexample + + @item Use @code{pragma Export} or @code{pragma Convention} for the + exported entities. + + Our package @code{Interface} is then updated as follow: + @smallexample + package Interface is + + procedure Do_Something; + pragma Export (C, Do_Something, "do_something"); + + procedure Do_Something_Else; + pragma Export (C, Do_Something_Else, "do_something_else"); + + end Interface; + @end smallexample + + @item Compile all the units composing the library. + + @item Bind the library objects. + + This step is performed by invoking gnatbind with the @code{-L} + switch. @code{gnatbind} will then generate the library elaboration + procedure (named @code{init}) and the run-time finalization + procedure (named @code{final}). + + @smallexample + # generate the binder file in Ada + $ gnatbind -Lmylib interface + + # generate the binder file in C + $ gnatbind -C -Lmylib interface + @end smallexample + + @item Compile the files generated by the binder + + @smallexample + $ gcc -c b~interface.adb + @end smallexample + + @item Create the library; + + The procedure is identical to the procedure explained in + @ref{Creating an Ada Library}, + except that @file{b~interface.o} needs to be added to + the list of objects. + + @smallexample + # create an archive file + $ ar cr libmylib.a b~interface.o + + # create a shared library + $ gcc -shared -o libmylib.so b~interface.o + @end smallexample + + @item Provide a "foreign" view of the library interface; + + The example below shows the content of @code{mylib_interface.h} (note + that there is no rule for the naming of this file, any name can be used) + @smallexample + /* the library elaboration procedure */ + extern void mylibinit (void); + + /* the library finalization procedure */ + extern void mylibfinal (void); + + /* the interface exported by the library */ + extern void do_something (void); + extern void do_something_else (void); + @end smallexample + @end itemize + + @subsection Using the Library + + @noindent + Libraries built as explained above can be used from any program, provided + that the elaboration procedures (named @code{mylibinit} in the previous + example) are called before the library services are used. Any number of + libraries can be used simultaneously, as long as the elaboration + procedure of each library is called. + + Below is an example of C program that uses our @code{mylib} library. + + @smallexample + #include "mylib_interface.h" + + int + main (void) + @{ + /* First, elaborate the library before using it */ + mylibinit (); + + /* Main program, using the library exported entities */ + do_something (); + do_something_else (); + + /* Library finalization at the end of the program */ + mylibfinal (); + return 0; + @} + @end smallexample + + @noindent + Note that this same library can be used from an equivalent Ada main + program. In addition, if the libraries are installed as detailed in + @ref{Installing an Ada Library}, it is not necessary to invoke the + library elaboration and finalization routines. The binder will ensure + that this is done as part of the main program elaboration and + finalization phases. + + @subsection The Finalization Phase + + @noindent + Invoking any library finalization procedure generated by @code{gnatbind} + shuts down the Ada run time permanently. Consequently, the finalization + of all Ada libraries must be performed at the end of the program. No + call to these libraries nor the Ada run time should be made past the + finalization phase. + + @subsection Restrictions in Libraries + + @noindent + The pragmas listed below should be used with caution inside libraries, + as they can create incompatibilities with other Ada libraries: + @itemize @bullet + @item pragma @code{Locking_Policy} + @item pragma @code{Queuing_Policy} + @item pragma @code{Task_Dispatching_Policy} + @item pragma @code{Unreserve_All_Interrupts} + @end itemize + When using a library that contains such pragmas, the user must make sure + that all libraries use the same pragmas with the same values. Otherwise, + a @code{Program_Error} will + be raised during the elaboration of the conflicting + libraries. The usage of these pragmas and its consequences for the user + should therefore be well documented. + + Similarly, the traceback in exception occurrences mechanism should be + enabled or disabled in a consistent manner across all libraries. + Otherwise, a Program_Error will be raised during the elaboration of the + conflicting libraries. + + If the @code{'Version} and @code{'Body_Version} + attributes are used inside a library, then it is necessary to + perform a @code{gnatbind} step that mentions all ali files in all + libraries, so that version identifiers can be properly computed. + In practice these attributes are rarely used, so this is unlikely + to be a consideration. + + @node Rebuilding the GNAT Run-Time Library + @section Rebuilding the GNAT Run-Time Library + + @noindent + It may be useful to recompile the GNAT library in various contexts, the + most important one being the use of partition-wide configuration pragmas + such as Normalize_Scalar. A special Makefile called + @code{Makefile.adalib} is provided to that effect and can be found in + the directory containing the GNAT library. The location of this + directory depends on the way the GNAT environment has been installed and can + be determined by means of the command: + + @smallexample + $ gnatls -v + @end smallexample + + @noindent + The last entry in the object search path usually contains the + gnat library. This Makefile contains its own documentation and in + particular the set of instructions needed to rebuild a new library and + to use it. + + @node Using the GNU make Utility + @chapter Using the GNU @code{make} Utility + @findex make + + @noindent + This chapter offers some examples of makefiles that solve specific + problems. It does not explain how to write a makefile (see the GNU make + documentation), nor does it try to replace the @code{gnatmake} utility + (@pxref{The GNAT Make Program gnatmake}). + + All the examples in this section are specific to the GNU version of + make. Although @code{make} is a standard utility, and the basic language + is the same, these examples use some advanced features found only in + @code{GNU make}. + + @menu + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + @end menu + + @node Using gnatmake in a Makefile + @section Using gnatmake in a Makefile + @findex makefile + @cindex GNU make + + @noindent + Complex project organizations can be handled in a very powerful way by + using GNU make combined with gnatmake. For instance, here is a Makefile + which allows you to build each subsystem of a big project into a separate + shared library. Such a makefile allows you to significantly reduce the link + time of very big applications while maintaining full coherence at + each step of the build process. + + The list of dependencies are handled automatically by + @code{gnatmake}. The Makefile is simply used to call gnatmake in each of + the appropriate directories. + + Note that you should also read the example on how to automatically + create the list of directories (@pxref{Automatically Creating a List of Directories}) + which might help you in case your project has a lot of + subdirectories. + + @smallexample + @iftex + @leftskip=0cm + @font@heightrm=cmr8 + @heightrm + @end iftex + ## This Makefile is intended to be used with the following directory + ## configuration: + ## - The sources are split into a series of csc (computer software components) + ## Each of these csc is put in its own directory. + ## Their name are referenced by the directory names. + ## They will be compiled into shared library (although this would also work + ## with static libraries + ## - The main program (and possibly other packages that do not belong to any + ## csc is put in the top level directory (where the Makefile is). + ## toplevel_dir __ first_csc (sources) __ lib (will contain the library) + ## \_ second_csc (sources) __ lib (will contain the library) + ## \_ ... + ## Although this Makefile is build for shared library, it is easy to modify + ## to build partial link objects instead (modify the lines with -shared and + ## gnatlink below) + ## + ## With this makefile, you can change any file in the system or add any new + ## file, and everything will be recompiled correctly (only the relevant shared + ## objects will be recompiled, and the main program will be re-linked). + + # The list of computer software component for your project. This might be + # generated automatically. + CSC_LIST=aa bb cc + + # Name of the main program (no extension) + MAIN=main + + # If we need to build objects with -fPIC, uncomment the following line + #NEED_FPIC=-fPIC + + # The following variable should give the directory containing libgnat.so + # You can get this directory through 'gnatls -v'. This is usually the last + # directory in the Object_Path. + GLIB=... + + # The directories for the libraries + # (This macro expands the list of CSC to the list of shared libraries, you + # could simply use the expanded form : + # LIB_DIR=aa/lib/libaa.so bb/lib/libbb.so cc/lib/libcc.so + LIB_DIR=$@{foreach dir,$@{CSC_LIST@},$@{dir@}/lib/lib$@{dir@}.so@} + + $@{MAIN@}: objects $@{LIB_DIR@} + gnatbind $@{MAIN@} $@{CSC_LIST:%=-aO%/lib@} -shared + gnatlink $@{MAIN@} $@{CSC_LIST:%=-l%@} + + objects:: + # recompile the sources + gnatmake -c -i $@{MAIN@}.adb $@{NEED_FPIC@} $@{CSC_LIST:%=-I%@} + + # Note: In a future version of GNAT, the following commands will be simplified + # by a new tool, gnatmlib + $@{LIB_DIR@}: + mkdir -p $@{dir $@@ @} + cd $@{dir $@@ @}; gcc -shared -o $@{notdir $@@ @} ../*.o -L$@{GLIB@} -lgnat + cd $@{dir $@@ @}; cp -f ../*.ali . + + # The dependencies for the modules + # Note that we have to force the expansion of *.o, since in some cases make won't + # be able to do it itself. + aa/lib/libaa.so: $@{wildcard aa/*.o@} + bb/lib/libbb.so: $@{wildcard bb/*.o@} + cc/lib/libcc.so: $@{wildcard cc/*.o@} + + # Make sure all of the shared libraries are in the path before starting the + # program + run:: + LD_LIBRARY_PATH=`pwd`/aa/lib:`pwd`/bb/lib:`pwd`/cc/lib ./$@{MAIN@} + + clean:: + $@{RM@} -rf $@{CSC_LIST:%=%/lib@} + $@{RM@} $@{CSC_LIST:%=%/*.ali@} + $@{RM@} $@{CSC_LIST:%=%/*.o@} + $@{RM@} *.o *.ali $@{MAIN@} + @end smallexample + + @node Automatically Creating a List of Directories + @section Automatically Creating a List of Directories + + @noindent + In most makefiles, you will have to specify a list of directories, and + store it in a variable. For small projects, it is often easier to + specify each of them by hand, since you then have full control over what + is the proper order for these directories, which ones should be + included... + + However, in larger projects, which might involve hundreds of + subdirectories, it might be more convenient to generate this list + automatically. + + The example below presents two methods. The first one, although less + general, gives you more control over the list. It involves wildcard + characters, that are automatically expanded by @code{make}. Its + shortcoming is that you need to explicitly specify some of the + organization of your project, such as for instance the directory tree + depth, whether some directories are found in a separate tree,... + + The second method is the most general one. It requires an external + program, called @code{find}, which is standard on all Unix systems. All + the directories found under a given root directory will be added to the + list. + + @smallexample + @iftex + @leftskip=0cm + @font@heightrm=cmr8 + @heightrm + @end iftex + # The examples below are based on the following directory hierarchy: + # All the directories can contain any number of files + # ROOT_DIRECTORY -> a -> aa -> aaa + # -> ab + # -> ac + # -> b -> ba -> baa + # -> bb + # -> bc + # This Makefile creates a variable called DIRS, that can be reused any time + # you need this list (see the other examples in this section) + + # The root of your project's directory hierarchy + ROOT_DIRECTORY=. + + #### + # First method: specify explicitly the list of directories + # This allows you to specify any subset of all the directories you need. + #### + + DIRS := a/aa/ a/ab/ b/ba/ + + #### + # Second method: use wildcards + # Note that the argument(s) to wildcard below should end with a '/'. + # Since wildcards also return file names, we have to filter them out + # to avoid duplicate directory names. + # We thus use make's @code{dir} and @code{sort} functions. + # It sets DIRs to the following value (note that the directories aaa and baa + # are not given, unless you change the arguments to wildcard). + # DIRS= ./a/a/ ./b/ ./a/aa/ ./a/ab/ ./a/ac/ ./b/ba/ ./b/bb/ ./b/bc/ + #### + + DIRS := $@{sort $@{dir $@{wildcard $@{ROOT_DIRECTORY@}/*/ $@{ROOT_DIRECTORY@}/*/*/@}@}@} + + #### + # Third method: use an external program + # This command is much faster if run on local disks, avoiding NFS slowdowns. + # This is the most complete command: it sets DIRs to the following value: + # DIRS= ./a ./a/aa ./a/aa/aaa ./a/ab ./a/ac ./b ./b/ba ./b/ba/baa ./b/bb ./b/bc + #### + + DIRS := $@{shell find $@{ROOT_DIRECTORY@} -type d -print@} + + @end smallexample + + @node Generating the Command Line Switches + @section Generating the Command Line Switches + + @noindent + Once you have created the list of directories as explained in the + previous section (@pxref{Automatically Creating a List of Directories}), + you can easily generate the command line arguments to pass to gnatmake. + + For the sake of completeness, this example assumes that the source path + is not the same as the object path, and that you have two separate lists + of directories. + + @smallexample + # see "Automatically creating a list of directories" to create + # these variables + SOURCE_DIRS= + OBJECT_DIRS= + + GNATMAKE_SWITCHES := $@{patsubst %,-aI%,$@{SOURCE_DIRS@}@} + GNATMAKE_SWITCHES += $@{patsubst %,-aO%,$@{OBJECT_DIRS@}@} + + all: + gnatmake $@{GNATMAKE_SWITCHES@} main_unit + @end smallexample + + @node Overcoming Command Line Length Limits + @section Overcoming Command Line Length Limits + + @noindent + One problem that might be encountered on big projects is that many + operating systems limit the length of the command line. It is thus hard to give + gnatmake the list of source and object directories. + + This example shows how you can set up environment variables, which will + make @code{gnatmake} behave exactly as if the directories had been + specified on the command line, but have a much higher length limit (or + even none on most systems). + + It assumes that you have created a list of directories in your Makefile, + using one of the methods presented in + @ref{Automatically Creating a List of Directories}. + For the sake of completeness, we assume that the object + path (where the ALI files are found) is different from the sources patch. + + Note a small trick in the Makefile below: for efficiency reasons, we + create two temporary variables (SOURCE_LIST and OBJECT_LIST), that are + expanded immediately by @code{make}. This way we overcome the standard + make behavior which is to expand the variables only when they are + actually used. + + @smallexample + @iftex + @leftskip=0cm + @font@heightrm=cmr8 + @heightrm + @end iftex + # In this example, we create both ADA_INCLUDE_PATH and ADA_OBJECT_PATH. + # This is the same thing as putting the -I arguments on the command line. + # (the equivalent of using -aI on the command line would be to define + # only ADA_INCLUDE_PATH, the equivalent of -aO is ADA_OBJECT_PATH). + # You can of course have different values for these variables. + # + # Note also that we need to keep the previous values of these variables, since + # they might have been set before running 'make' to specify where the GNAT + # library is installed. + + # see "Automatically creating a list of directories" to create these + # variables + SOURCE_DIRS= + OBJECT_DIRS= + + empty:= + space:=$@{empty@} $@{empty@} + SOURCE_LIST := $@{subst $@{space@},:,$@{SOURCE_DIRS@}@} + OBJECT_LIST := $@{subst $@{space@},:,$@{OBJECT_DIRS@}@} + ADA_INCLUDE_PATH += $@{SOURCE_LIST@} + ADA_OBJECT_PATH += $@{OBJECT_LIST@} + export ADA_INCLUDE_PATH + export ADA_OBJECT_PATH + + all: + gnatmake main_unit + @end smallexample + + + @node Finding Memory Problems with GNAT Debug Pool + @chapter Finding Memory Problems with GNAT Debug Pool + @findex Debug Pool + @cindex storage, pool, memory corruption + + @noindent + The use of unchecked deallocation and unchecked conversion can easily + lead to incorrect memory references. The problems generated by such + references are usually difficult to tackle because the symptoms can be + very remote from the origin of the problem. In such cases, it is + very helpful to detect the problem as early as possible. This is the + purpose of the Storage Pool provided by @code{GNAT.Debug_Pools}. + + @noindent + In order to use the GNAT specific debugging pool, the user must + associate a debug pool object with each of the access types that may be + related to suspected memory problems. See Ada Reference Manual + 13.11. + @smallexample + @b{type} Ptr @b{is} @b{access} Some_Type; + Pool : GNAT.Debug_Pools.Debug_Pool; + @b{for} Ptr'Storage_Pool @b{use} Pool; + @end smallexample + + @code{GNAT.Debug_Pools} is derived from of a GNAT-specific kind of + pool: the Checked_Pool. Such pools, like standard Ada storage pools, + allow the user to redefine allocation and deallocation strategies. They + also provide a checkpoint for each dereference, through the use of + the primitive operation @code{Dereference} which is implicitly called at + each dereference of an access value. + + Once an access type has been associated with a debug pool, operations on + values of the type may raise four distinct exceptions, + which correspond to four potential kinds of memory corruption: + @itemize @bullet + @item + @code{GNAT.Debug_Pools.Accessing_Not_Allocated_Storage} + @item + @code{GNAT.Debug_Pools.Accessing_Deallocated_Storage} + @item + @code{GNAT.Debug_Pools.Freeing_Not_Allocated_Storage} + @item + @code{GNAT.Debug_Pools.Freeing_Deallocated_Storage } + @end itemize + + @noindent + For types associated with a Debug_Pool, dynamic allocation is performed using + the standard + GNAT allocation routine. References to all allocated chunks of memory + are kept in an internal dictionary. The deallocation strategy consists + in not releasing the memory to the underlying system but rather to fill + it with a memory pattern easily recognizable during debugging sessions: + The memory pattern is the old IBM hexadecimal convention: 16#DEADBEEF#. + Upon each dereference, a check is made that the access value denotes a properly + allocated memory location. Here is a complete example of use of + @code{Debug_Pools}, that includes typical instances of memory corruption: + @smallexample + @iftex + @leftskip=0cm + @end iftex + @b{with} Gnat.Io; @b{use} Gnat.Io; + @b{with} Unchecked_Deallocation; + @b{with} Unchecked_Conversion; + @b{with} GNAT.Debug_Pools; + @b{with} System.Storage_Elements; + @b{with} Ada.Exceptions; @b{use} Ada.Exceptions; + @b{procedure} Debug_Pool_Test @b{is} + + @b{type} T @b{is} @b{access} Integer; + @b{type} U @b{is} @b{access} @b{all} T; + + P : GNAT.Debug_Pools.Debug_Pool; + @b{for} T'Storage_Pool @b{use} P; + + @b{procedure} Free @b{is} @b{new} Unchecked_Deallocation (Integer, T); + @b{function} UC @b{is} @b{new} Unchecked_Conversion (U, T); + A, B : @b{aliased} T; + + @b{procedure} Info @b{is} @b{new} GNAT.Debug_Pools.Print_Info(Put_Line); + + @b{begin} + Info (P); + A := @b{new} Integer; + B := @b{new} Integer; + B := A; + Info (P); + Free (A); + @b{begin} + Put_Line (Integer'Image(B.@b{all})); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + @b{begin} + Free (B); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + B := UC(A'Access); + @b{begin} + Put_Line (Integer'Image(B.@b{all})); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + @b{begin} + Free (B); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + Info (P); + @b{end} Debug_Pool_Test; + @end smallexample + @noindent + The debug pool mechanism provides the following precise diagnostics on the + execution of this erroneous program: + @smallexample + Debug Pool info: + Total allocated bytes : 0 + Total deallocated bytes : 0 + Current Water Mark: 0 + High Water Mark: 0 + + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 0 + Current Water Mark: 8 + High Water Mark: 8 + + raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 4 + Current Water Mark: 4 + High Water Mark: 8 + + @end smallexample + + @node Creating Sample Bodies Using gnatstub + @chapter Creating Sample Bodies Using @code{gnatstub} + @findex gnatstub + + @noindent + @code{gnatstub} creates body stubs, that is, empty but compilable bodies + for library unit declarations. + + To create a body stub, @code{gnatstub} has to compile the library + unit declaration. Therefore, bodies can be created only for legal + library units. Moreover, if a library unit depends semantically upon + units located outside the current directory, you have to provide + the source search path when calling @code{gnatstub}, see the description + of @code{gnatstub} switches below. + + @menu + * Running gnatstub:: + * Switches for gnatstub:: + @end menu + + @node Running gnatstub + @section Running @code{gnatstub} + + @noindent + @code{gnatstub} has the command-line interface of the form + + @smallexample + $ gnatstub [switches] filename [directory] + @end smallexample + + @noindent + where + @table @code + @item filename + is the name of the source file that contains a library unit declaration + for which a body must be created. This name should follow the GNAT file name + conventions. No crunching is allowed for this file name. The file + name may contain the path information. + + @item directory + indicates the directory to place a body stub (default is the + current directory) + + @item switches + is an optional sequence of switches as described in the next section + @end table + + @node Switches for gnatstub + @section Switches for @code{gnatstub} + + @table @code + + @item -f + If the destination directory already contains a file with a name of the body file + for the argument spec file, replace it with the generated body stub. + + @item -hs + Put the comment header (i.e. all the comments preceding the + compilation unit) from the source of the library unit declaration + into the body stub. + + @item -hg + Put a sample comment header into the body stub. + + @item -IDIR + @itemx -I- + These switches have the same meaning as in calls to gcc. + They define the source search path in the call to gcc issued + by @code{gnatstub} to compile an argument source file. + + @item -i@var{n} + (@var{n} is a decimal natural number). Set the indentation level in the + generated body sample to n, '-i0' means "no indentation", + the default indentation is 3. + + @item -k + Do not remove the tree file (i.e. the snapshot of the compiler internal + structures used by @code{gnatstub}) after creating the body stub. + + @item -l@var{n} + (@var{n} is a decimal positive number) Set the maximum line length in the + body stub to n, the default is 78. + + @item -q + Quiet mode: do not generate a confirmation when a body is + successfully created or a message when a body is not required for an + argument unit. + + @item -r + Reuse the tree file (if it exists) instead of creating it: instead of + creating the tree file for the library unit declaration, gnatstub + tries to find it in the current directory and use it for creating + a body. If the tree file is not found, no body is created. @code{-r} + also implies @code{-k}, whether or not + @code{-k} is set explicitly. + + @item -t + Overwrite the existing tree file: if the current directory already + contains the file which, according to the GNAT file name rules should + be considered as a tree file for the argument source file, gnatstub + will refuse to create the tree file needed to create a body sampler, + unless @code{-t} option is set + + @item -v + Verbose mode: generate version information. + + @end table + + @node Reducing the Size of Ada Executables with gnatelim + @chapter Reducing the Size of Ada Executables with @code{gnatelim} + @findex gnatelim + + @menu + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + @end menu + + @node About gnatelim + @section About @code{gnatelim} + + @noindent + When a program shares a set of Ada + packages with other programs, it may happen that this program uses + only a fraction of the subprograms defined in these packages. The code + created for these unused subprograms increases the size of the executable. + + @code{gnatelim} tracks unused subprograms in an Ada program and + outputs a list of GNAT-specific @code{Eliminate} pragmas (see next + section) marking all the subprograms that are declared but never called. + By placing the list of @code{Eliminate} pragmas in the GNAT configuration + file @file{gnat.adc} and recompiling your program, you may decrease the + size of its executable, because the compiler will not generate the code + for 'eliminated' subprograms. + + @code{gnatelim} needs as its input data a set of tree files + (see @ref{Tree Files}) representing all the components of a program to + process and a bind file for a main subprogram (see + @ref{Preparing Tree and Bind Files for gnatelim}). + + @node Eliminate Pragma + @section @code{Eliminate} Pragma + @findex Eliminate + + @noindent + The simplified syntax of the Eliminate pragma used by @code{gnatelim} is: + + @smallexample + @cartouche + @b{pragma} Eliminate (Library_Unit_Name, Subprogram_Name); + @end cartouche + @end smallexample + + @noindent + where + @table @code + @item Library_Unit_Name + full expanded Ada name of a library unit + + @item Subprogram_Name + a simple or expanded name of a subprogram declared within this + compilation unit + + @end table + + @noindent + The effect of an @code{Eliminate} pragma placed in the GNAT configuration + file @file{gnat.adc} is: + + @itemize @bullet + + @item + If the subprogram @code{Subprogram_Name} is declared within + the library unit @code{Library_Unit_Name}, the compiler will not generate + code for this subprogram. This applies to all overloaded subprograms denoted + by @code{Subprogram_Name}. + + @item + If a subprogram marked by the pragma @code{Eliminate} is used (called) + in a program, the compiler will produce an error message in the place where + it is called. + @end itemize + + @node Tree Files + @section Tree Files + @cindex Tree file + + @noindent + A tree file stores a snapshot of the compiler internal data + structures at the very end of a successful compilation. It contains all the + syntactic and semantic information for the compiled unit and all the + units upon which it depends semantically. + To use tools that make use of tree files, you + need to first produce the right set of tree files. + + GNAT produces correct tree files when -gnatt -gnatc options are set + in a gcc call. The tree files have an .adt extension. + Therefore, to produce a tree file for the compilation unit contained in a file + named @file{foo.adb}, you must use the command + + @smallexample + $ gcc -c -gnatc -gnatt foo.adb + @end smallexample + + @noindent + and you will get the tree file @file{foo.adt}. + compilation. + + @node Preparing Tree and Bind Files for gnatelim + @section Preparing Tree and Bind Files for @code{gnatelim} + + @noindent + A set of tree files covering the program to be analyzed with + @code{gnatelim} and + the bind file for the main subprogram does not have to + be in the current directory. + '-T' gnatelim option may be used to provide + the search path for tree files, and '-b' + option may be used to point to the bind + file to process (see @ref{Running gnatelim}) + + If you do not have the appropriate set of tree + files and the right bind file, you + may create them in the current directory using the following procedure. + + Let @code{Main_Prog} be the name of a main subprogram, and suppose + this subprogram is in a file named @file{main_prog.adb}. + + To create a bind file for @code{gnatelim}, run @code{gnatbind} for + the main subprogram. @code{gnatelim} can work with both Ada and C + bind files; when both are present, it uses the Ada bind file. + The following commands will build the program and create the bind file: + + @smallexample + $ gnatmake -c Main_Prog + $ gnatbind main_prog + @end smallexample + + @noindent + To create a minimal set of tree files covering the whole program, call + @code{gnatmake} for this program as follows: + + @smallexample + $ gnatmake -f -c -gnatc -gnatt Main_Prog + @end smallexample + + @noindent + The @code{-c} gnatmake option turns off the bind and link + steps, that are useless anyway because the sources are compiled with + @option{-gnatc} option which turns off code generation. + + The @code{-f} gnatmake option forces + recompilation of all the needed sources. + + This sequence of actions will create all the data needed by @code{gnatelim} + from scratch and therefore guarantee its consistency. If you would like to + use some existing set of files as @code{gnatelim} output, you must make + sure that the set of files is complete and consistent. You can use the + @code{-m} switch to check if there are missed tree files + + Note, that @code{gnatelim} needs neither object nor ALI files. + + @node Running gnatelim + @section Running @code{gnatelim} + + @noindent + @code{gnatelim} has the following command-line interface: + + @smallexample + $ gnatelim [options] name + @end smallexample + + @noindent + @code{name} should be a full expanded Ada name of a main subprogram + of a program (partition). + + @code{gnatelim} options: + + @table @code + @item -q + Quiet mode: by default @code{gnatelim} generates to the standard error + stream a trace of the source file names of the compilation units being + processed. This option turns this trace off. + + @item -v + Verbose mode: @code{gnatelim} version information is printed as Ada + comments to the standard output stream. + + @item -a + Also look for subprograms from the GNAT run time that can be eliminated. + + @item -m + Check if any tree files are missing for an accurate result. + + @item -T@var{dir} + When looking for tree files also look in directory @var{dir} + + @item -b@var{bind_file} + Specifies @var{bind_file} as the bind file to process. If not set, the name + of the bind file is computed from the full expanded Ada name of a main subprogram. + + @item -d@var{x} + Activate internal debugging switches. @var{x} is a letter or digit, or + string of letters or digits, which specifies the type of debugging + mode desired. Normally these are used only for internal development + or system debugging purposes. You can find full documentation for these + switches in the body of the @code{Gnatelim.Options} unit in the compiler + source file @file{gnatelim-options.adb}. + @end table + + @noindent + @code{gnatelim} sends its output to the standard output stream, and all the + tracing and debug information is sent to the standard error stream. + In order to produce a proper GNAT configuration file + @file{gnat.adc}, redirection must be used: + + @smallexample + $ gnatelim Main_Prog > gnat.adc + @end smallexample + + @noindent + or + + @smallexample + $ gnatelim Main_Prog >> gnat.adc + @end smallexample + + @noindent + In order to append the @code{gnatelim} output to the existing contents of + @file{gnat.adc}. + + @node Correcting the List of Eliminate Pragmas + @section Correcting the List of Eliminate Pragmas + + @noindent + In some rare cases it may happen that @code{gnatelim} will try to eliminate + subprograms which are actually called in the program. In this case, the + compiler will generate an error message of the form: + + @smallexample + file.adb:106:07: cannot call eliminated subprogram "My_Prog" + @end smallexample + + @noindent + You will need to manually remove the wrong @code{Eliminate} pragmas from + the @file{gnat.adc} file. It is advised that you recompile your program + from scratch after that because you need a consistent @file{gnat.adc} file + during the entire compilation. + + @node Making Your Executables Smaller + @section Making Your Executables Smaller + + @noindent + In order to get a smaller executable for your program you now have to + recompile the program completely with the new @file{gnat.adc} file + created by @code{gnatelim} in your current directory: + + @smallexample + $ gnatmake -f Main_Prog + @end smallexample + + @noindent + (you will need @code{-f} option for gnatmake to + recompile everything + with the set of pragmas @code{Eliminate} you have obtained with + @code{gnatelim}). + + Be aware that the set of @code{Eliminate} pragmas is specific to each + program. It is not recommended to merge sets of @code{Eliminate} + pragmas created for different programs in one @file{gnat.adc} file. + + @node Summary of the gnatelim Usage Cycle + @section Summary of the gnatelim Usage Cycle + + @noindent + Here is a quick summary of the steps to be taken in order to reduce + the size of your executables with @code{gnatelim}. You may use + other GNAT options to control the optimization level, + to produce the debugging information, to set search path, etc. + + @enumerate + @item + Produce a bind file and a set of tree files + + @smallexample + $ gnatmake -c Main_Prog + $ gnatbind main_prog + $ gnatmake -f -c -gnatc -gnatt Main_Prog + @end smallexample + + @item + Generate a list of @code{Eliminate} pragmas + @smallexample + $ gnatelim Main_Prog >[>] gnat.adc + @end smallexample + + @item + Recompile the application + + @smallexample + $ gnatmake -f Main_Prog + @end smallexample + + @end enumerate + + @node Other Utility Programs + @chapter Other Utility Programs + + @noindent + This chapter discusses some other utility programs available in the Ada + environment. + + @menu + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * Installing gnathtml:: + @end menu + + @node Using Other Utility Programs with GNAT + @section Using Other Utility Programs with GNAT + + @noindent + The object files generated by GNAT are in standard system format and in + particular the debugging information uses this format. This means + programs generated by GNAT can be used with existing utilities that + depend on these formats. + + In general, any utility program that works with C will also often work with + Ada programs generated by GNAT. This includes software utilities such as + gprof (a profiling program), @code{gdb} (the FSF debugger), and utilities such + as Purify. + + @node The gnatpsta Utility Program + @section The @code{gnatpsta} Utility Program + + @noindent + Many of the definitions in package Standard are implementation-dependent. + However, the source of this package does not exist as an Ada source + file, so these values cannot be determined by inspecting the source. + They can be determined by examining in detail the coding of + @file{cstand.adb} which creates the image of Standard in the compiler, + but this is awkward and requires a great deal of internal knowledge + about the system. + + The @code{gnatpsta} utility is designed to deal with this situation. + It is an Ada program that dynamically determines the + values of all the relevant parameters in Standard, and prints them + out in the form of an Ada source listing for Standard, displaying all + the values of interest. This output is generated to + @file{stdout}. + + To determine the value of any parameter in package Standard, simply + run @code{gnatpsta} with no qualifiers or arguments, and examine + the output. This is preferable to consulting documentation, because + you know that the values you are getting are the actual ones provided + by the executing system. + + @node The External Symbol Naming Scheme of GNAT + @section The External Symbol Naming Scheme of GNAT + + @noindent + In order to interpret the output from GNAT, when using tools that are + originally intended for use with other languages, it is useful to + understand the conventions used to generate link names from the Ada + entity names. + + All link names are in all lowercase letters. With the exception of library + procedure names, the mechanism used is simply to use the full expanded + Ada name with dots replaced by double underscores. For example, suppose + we have the following package spec: + + @smallexample + @group + @cartouche + @b{package} QRS @b{is} + MN : Integer; + @b{end} QRS; + @end cartouche + @end group + @end smallexample + + @noindent + The variable @code{MN} has a full expanded Ada name of @code{QRS.MN}, so + the corresponding link name is @code{qrs__mn}. + @findex Export + Of course if a @code{pragma Export} is used this may be overridden: + + @smallexample + @group + @cartouche + @b{package} Exports @b{is} + Var1 : Integer; + @b{pragma} Export (Var1, C, External_Name => "var1_name"); + Var2 : Integer; + @b{pragma} Export (Var2, C, Link_Name => "var2_link_name"); + @b{end} Exports; + @end cartouche + @end group + @end smallexample + + @noindent + In this case, the link name for @var{Var1} is whatever link name the + C compiler would assign for the C function @var{var1_name}. This typically + would be either @var{var1_name} or @var{_var1_name}, depending on operating + system conventions, but other possibilities exist. The link name for + @var{Var2} is @var{var2_link_name}, and this is not operating system + dependent. + + @findex _main + One exception occurs for library level procedures. A potential ambiguity + arises between the required name @code{_main} for the C main program, + and the name we would otherwise assign to an Ada library level procedure + called @code{Main} (which might well not be the main program). + + To avoid this ambiguity, we attach the prefix @code{_ada_} to such + names. So if we have a library level procedure such as + + @smallexample + @group + @cartouche + @b{procedure} Hello (S : String); + @end cartouche + @end group + @end smallexample + + @noindent + the external name of this procedure will be @var{_ada_hello}. + + @node Ada Mode for Glide + @section Ada Mode for @code{Glide} + + @noindent + The Glide mode for programming in Ada (both, Ada83 and Ada95) helps the + user in understanding existing code and facilitates writing new code. It + furthermore provides some utility functions for easier integration of + standard Emacs features when programming in Ada. + + @subsection General Features: + + @itemize @bullet + @item + Full Integrated Development Environment : + + @itemize @bullet + @item + support of 'project files' for the configuration (directories, + compilation options,...) + + @item + compiling and stepping through error messages. + + @item + running and debugging your applications within Glide. + @end itemize + + @item + easy to use for beginners by pull-down menus, + + @item + user configurable by many user-option variables. + @end itemize + + @subsection Ada Mode Features That Help Understanding Code: + + @itemize @bullet + @item + functions for easy and quick stepping through Ada code, + + @item + getting cross reference information for identifiers (e.g. find the + defining place by a keystroke), + + @item + displaying an index menu of types and subprograms and move point to + the chosen one, + + @item + automatic color highlighting of the various entities in Ada code. + @end itemize + + @subsection Glide Support for Writing Ada Code: + + @itemize @bullet + @item + switching between spec and body files with possible + autogeneration of body files, + + @item + automatic formating of subprograms parameter lists. + + @item + automatic smart indentation according to Ada syntax, + + @item + automatic completion of identifiers, + + @item + automatic casing of identifiers, keywords, and attributes, + + @item + insertion of statement templates, + + @item + filling comment paragraphs like filling normal text, + @end itemize + + For more information, please refer to the online Glide documentation + available in the Glide --> Help Menu. + + @node Converting Ada Files to html with gnathtml + @section Converting Ada Files to html with @code{gnathtml} + + @noindent + This @code{Perl} script allows Ada source files to be browsed using + standard Web browsers. For installation procedure, see the section + @xref{Installing gnathtml}. + + Ada reserved keywords are highlighted in a bold font and Ada comments in + a blue font. Unless your program was compiled with the gcc @option{-gnatx} + switch to suppress the generation of cross-referencing information, user + defined variables and types will appear in a different color; you will + be able to click on any identifier and go to its declaration. + + The command line is as follow: + @smallexample + $ perl gnathtml.pl [switches] ada-files + @end smallexample + + You can pass it as many Ada files as you want. @code{gnathtml} will generate + an html file for every ada file, and a global file called @file{index.htm}. + This file is an index of every identifier defined in the files. + + The available switches are the following ones : + + @table @code + @item -83 + @cindex @code{-83} (@code{gnathtml}) + Only the subset on the Ada 83 keywords will be highlighted, not the full + Ada 95 keywords set. + + @item -cc @var{color} + This option allows you to change the color used for comments. The default + value is green. The color argument can be any name accepted by html. + + @item -d + @cindex @code{-d} (@code{gnathtml}) + If the ada files depend on some other files (using for instance the + @code{with} command, the latter will also be converted to html. + Only the files in the user project will be converted to html, not the files + in the run-time library itself. + + @item -D + This command is the same as -d above, but @code{gnathtml} will also look + for files in the run-time library, and generate html files for them. + + @item -f + @cindex @code{-f} (@code{gnathtml}) + By default, gnathtml will generate html links only for global entities + ('with'ed units, global variables and types,...). If you specify the + @code{-f} on the command line, then links will be generated for local + entities too. + + @item -l @var{number} + @cindex @code{-l} (@code{gnathtml}) + If this switch is provided and @var{number} is not 0, then @code{gnathtml} + will number the html files every @var{number} line. + + @item -I @var{dir} + @cindex @code{-I} (@code{gnathtml}) + Specify a directory to search for library files (@file{.ali} files) and + source files. You can provide several -I switches on the command line, + and the directories will be parsed in the order of the command line. + + @item -o @var{dir} + @cindex @code{-o} (@code{gnathtml}) + Specify the output directory for html files. By default, gnathtml will + saved the generated html files in a subdirectory named @file{html/}. + + @item -p @var{file} + @cindex @code{-p} (@code{gnathtml}) + If you are using Emacs and the most recent Emacs Ada mode, which provides + a full Integrated Development Environment for compiling, checking, + running and debugging applications, you may be using @file{.adp} files + to give the directories where Emacs can find sources and object files. + + Using this switch, you can tell gnathtml to use these files. This allows + you to get an html version of your application, even if it is spread + over multiple directories. + + @item -sc @var{color} + @cindex @code{-sc} (@code{gnathtml}) + This option allows you to change the color used for symbol definitions. + The default value is red. The color argument can be any name accepted by html. + + @item -t @var{file} + @cindex @code{-t} (@code{gnathtml}) + This switch provides the name of a file. This file contains a list of + file names to be converted, and the effect is exactly as though they had + appeared explicitly on the command line. This + is the recommended way to work around the command line length limit on some + systems. + + @end table + + @node Installing gnathtml + @section Installing @code{gnathtml} + + @noindent + @code{Perl} needs to be installed on your machine to run this script. + @code{Perl} is freely available for almost every architecture and + Operating System via the Internet. + + On Unix systems, you may want to modify the first line of the script + @code{gnathtml}, to explicitly tell the Operating system where Perl + is. The syntax of this line is : + @smallexample + #!full_path_name_to_perl + @end smallexample + + @noindent + Alternatively, you may run the script using the following command line: + + @smallexample + $ perl gnathtml.pl [switches] files + @end smallexample + + + @node Running and Debugging Ada Programs + @chapter Running and Debugging Ada Programs + @cindex Debugging + + @noindent + This chapter discusses how to debug Ada programs. An incorrect Ada program + may be handled in three ways by the GNAT compiler: + + @enumerate + @item + The illegality may be a violation of the static semantics of Ada. In + that case GNAT diagnoses the constructs in the program that are illegal. + It is then a straightforward matter for the user to modify those parts of + the program. + + @item + The illegality may be a violation of the dynamic semantics of Ada. In + that case the program compiles and executes, but may generate incorrect + results, or may terminate abnormally with some exception. + + @item + When presented with a program that contains convoluted errors, GNAT + itself may terminate abnormally without providing full diagnostics on + the incorrect user program. + @end enumerate + + @menu + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + @end menu + + @cindex Debugger + @findex gdb + + @node The GNAT Debugger GDB + @section The GNAT Debugger GDB + + @noindent + @code{GDB} is a general purpose, platform-independent debugger that + can be used to debug mixed-language programs compiled with @code{GCC}, + and in particular is capable of debugging Ada programs compiled with + GNAT. The latest versions of @code{GDB} are Ada-aware and can handle + complex Ada data structures. + + The manual @cite{Debugging with GDB} + contains full details on the usage of @code{GDB}, including a section on + its usage on programs. This manual should be consulted for full + details. The section that follows is a brief introduction to the + philosophy and use of @code{GDB}. + + When GNAT programs are compiled, the compiler optionally writes debugging + information into the generated object file, including information on + line numbers, and on declared types and variables. This information is + separate from the generated code. It makes the object files considerably + larger, but it does not add to the size of the actual executable that + will be loaded into memory, and has no impact on run-time performance. The + generation of debug information is triggered by the use of the + -g switch in the gcc or gnatmake command used to carry out + the compilations. It is important to emphasize that the use of these + options does not change the generated code. + + The debugging information is written in standard system formats that + are used by many tools, including debuggers and profilers. The format + of the information is typically designed to describe C types and + semantics, but GNAT implements a translation scheme which allows full + details about Ada types and variables to be encoded into these + standard C formats. Details of this encoding scheme may be found in + the file exp_dbug.ads in the GNAT source distribution. However, the + details of this encoding are, in general, of no interest to a user, + since @code{GDB} automatically performs the necessary decoding. + + When a program is bound and linked, the debugging information is + collected from the object files, and stored in the executable image of + the program. Again, this process significantly increases the size of + the generated executable file, but it does not increase the size of + the executable program itself. Furthermore, if this program is run in + the normal manner, it runs exactly as if the debug information were + not present, and takes no more actual memory. + + However, if the program is run under control of @code{GDB}, the + debugger is activated. The image of the program is loaded, at which + point it is ready to run. If a run command is given, then the program + will run exactly as it would have if @code{GDB} were not present. This + is a crucial part of the @code{GDB} design philosophy. @code{GDB} is + entirely non-intrusive until a breakpoint is encountered. If no + breakpoint is ever hit, the program will run exactly as it would if no + debugger were present. When a breakpoint is hit, @code{GDB} accesses + the debugging information and can respond to user commands to inspect + variables, and more generally to report on the state of execution. + + @node Running GDB + @section Running GDB + + + Please refer to the debugging section of the chapter specific to your + cross environment at the end of this manual. + + @node Introduction to GDB Commands + @section Introduction to GDB Commands + + @noindent + @code{GDB} contains a large repertoire of commands. The manual + @cite{Debugging with GDB} + includes extensive documentation on the use + of these commands, together with examples of their use. Furthermore, + the command @var{help} invoked from within @code{GDB} activates a simple help + facility which summarizes the available commands and their options. + In this section we summarize a few of the most commonly + used commands to give an idea of what @code{GDB} is about. You should create + a simple program with debugging information and experiment with the use of + these @code{GDB} commands on the program as you read through the + following section. + + @table @code + @item set args @var{arguments} + The @var{arguments} list above is a list of arguments to be passed to + the program on a subsequent run command, just as though the arguments + had been entered on a normal invocation of the program. The @code{set args} + command is not needed if the program does not require arguments. + + @item run + The @code{run} command causes execution of the program to start from + the beginning. If the program is already running, that is to say if + you are currently positioned at a breakpoint, then a prompt will ask + for confirmation that you want to abandon the current execution and + restart. + + @item breakpoint @var{location} + The breakpoint command sets a breakpoint, that is to say a point at which + execution will halt and @code{GDB} will await further + commands. @var{location} is + either a line number within a file, given in the format @code{file:linenumber}, + or it is the name of a subprogram. If you request that a breakpoint be set on + a subprogram that is overloaded, a prompt will ask you to specify on which of + those subprograms you want to breakpoint. You can also + specify that all of them should be breakpointed. If the program is run + and execution encounters the breakpoint, then the program + stops and @code{GDB} signals that the breakpoint was encountered by + printing the line of code before which the program is halted. + + @item breakpoint exception @var{name} + A special form of the breakpoint command which breakpoints whenever + exception @var{name} is raised. + If @var{name} is omitted, + then a breakpoint will occur when any exception is raised. + + @item print @var{expression} + This will print the value of the given expression. Most simple + Ada expression formats are properly handled by @code{GDB}, so the expression + can contain function calls, variables, operators, and attribute references. + + @item continue + Continues execution following a breakpoint, until the next breakpoint or the + termination of the program. + + @item step + Executes a single line after a breakpoint. If the next statement is a subprogram + call, execution continues into (the first statement of) the + called subprogram. + + @item next + Executes a single line. If this line is a subprogram call, executes and + returns from the call. + + @item list + Lists a few lines around the current source location. In practice, it + is usually more convenient to have a separate edit window open with the + relevant source file displayed. Successive applications of this command + print subsequent lines. The command can be given an argument which is a + line number, in which case it displays a few lines around the specified one. + + @item backtrace + Displays a backtrace of the call chain. This command is typically + used after a breakpoint has occurred, to examine the sequence of calls that + leads to the current breakpoint. The display includes one line for each + activation record (frame) corresponding to an active subprogram. + + @item up + At a breakpoint, @code{GDB} can display the values of variables local + to the current frame. The command @code{up} can be used to + examine the contents of other active frames, by moving the focus up + the stack, that is to say from callee to caller, one frame at a time. + + @item down + Moves the focus of @code{GDB} down from the frame currently being + examined to the frame of its callee (the reverse of the previous command), + + @item frame @var{n} + Inspect the frame with the given number. The value 0 denotes the frame + of the current breakpoint, that is to say the top of the call stack. + + @end table + + The above list is a very short introduction to the commands that + @code{GDB} provides. Important additional capabilities, including conditional + breakpoints, the ability to execute command sequences on a breakpoint, + the ability to debug at the machine instruction level and many other + features are described in detail in @cite{Debugging with GDB}. + Note that most commands can be abbreviated + (for example, c for continue, bt for backtrace). + + @node Using Ada Expressions + @section Using Ada Expressions + @cindex Ada expressions + + @noindent + @code{GDB} supports a fairly large subset of Ada expression syntax, with some + extensions. The philosophy behind the design of this subset is + + @itemize @bullet + @item + That @code{GDB} should provide basic literals and access to operations for + arithmetic, dereferencing, field selection, indexing, and subprogram calls, + leaving more sophisticated computations to subprograms written into the + program (which therefore may be called from @code{GDB}). + + @item + That type safety and strict adherence to Ada language restrictions + are not particularly important to the @code{GDB} user. + + @item + That brevity is important to the @code{GDB} user. + @end itemize + + Thus, for brevity, the debugger acts as if there were + implicit @code{with} and @code{use} clauses in effect for all user-written + packages, thus making it unnecessary to fully qualify most names with + their packages, regardless of context. Where this causes ambiguity, + @code{GDB} asks the user's intent. + + For details on the supported Ada syntax, see @cite{Debugging with GDB}. + + @node Calling User-Defined Subprograms + @section Calling User-Defined Subprograms + + @noindent + An important capability of @code{GDB} is the ability to call user-defined + subprograms while debugging. This is achieved simply by entering + a subprogram call statement in the form: + + @smallexample + call subprogram-name (parameters) + @end smallexample + + @noindent + The keyword @code{call} can be omitted in the normal case where the + @code{subprogram-name} does not coincide with any of the predefined + @code{GDB} commands. + + The effect is to invoke the given subprogram, passing it the + list of parameters that is supplied. The parameters can be expressions and + can include variables from the program being debugged. The + subprogram must be defined + at the library level within your program, and @code{GDB} will call the + subprogram within the environment of your program execution (which + means that the subprogram is free to access or even modify variables + within your program). + + The most important use of this facility is in allowing the inclusion of + debugging routines that are tailored to particular data structures + in your program. Such debugging routines can be written to provide a suitably + high-level description of an abstract type, rather than a low-level dump + of its physical layout. After all, the standard + @code{GDB print} command only knows the physical layout of your + types, not their abstract meaning. Debugging routines can provide information + at the desired semantic level and are thus enormously useful. + + For example, when debugging GNAT itself, it is crucial to have access to + the contents of the tree nodes used to represent the program internally. + But tree nodes are represented simply by an integer value (which in turn + is an index into a table of nodes). + Using the @code{print} command on a tree node would simply print this integer + value, which is not very useful. But the PN routine (defined in file + treepr.adb in the GNAT sources) takes a tree node as input, and displays + a useful high level representation of the tree node, which includes the + syntactic category of the node, its position in the source, the integers + that denote descendant nodes and parent node, as well as varied + semantic information. To study this example in more detail, you might want to + look at the body of the PN procedure in the stated file. + + @node Using the Next Command in a Function + @section Using the Next Command in a Function + + @noindent + When you use the @code{next} command in a function, the current source + location will advance to the next statement as usual. A special case + arises in the case of a @code{return} statement. + + Part of the code for a return statement is the "epilog" of the function. + This is the code that returns to the caller. There is only one copy of + this epilog code, and it is typically associated with the last return + statement in the function if there is more than one return. In some + implementations, this epilog is associated with the first statement + of the function. + + The result is that if you use the @code{next} command from a return + statement that is not the last return statement of the function you + may see a strange apparent jump to the last return statement or to + the start of the function. You should simply ignore this odd jump. + The value returned is always that from the first return statement + that was stepped through. + + @node Ada Exceptions + @section Breaking on Ada Exceptions + @cindex Exceptions + + @noindent + You can set breakpoints that trip when your program raises + selected exceptions. + + @table @code + @item break exception + Set a breakpoint that trips whenever (any task in the) program raises + any exception. + + @item break exception @var{name} + Set a breakpoint that trips whenever (any task in the) program raises + the exception @var{name}. + + @item break exception unhandled + Set a breakpoint that trips whenever (any task in the) program raises an + exception for which there is no handler. + + @item info exceptions + @itemx info exceptions @var{regexp} + The @code{info exceptions} command permits the user to examine all defined + exceptions within Ada programs. With a regular expression, @var{regexp}, as + argument, prints out only those exceptions whose name matches @var{regexp}. + @end table + + @node Ada Tasks + @section Ada Tasks + @cindex Tasks + + @noindent + @code{GDB} allows the following task-related commands: + + @table @code + @item info tasks + This command shows a list of current Ada tasks, as in the following example: + + @smallexample + @iftex + @leftskip=0cm + @end iftex + (gdb) info tasks + ID TID P-ID Thread Pri State Name + 1 8088000 0 807e000 15 Child Activation Wait main_task + 2 80a4000 1 80ae000 15 Accept/Select Wait b + 3 809a800 1 80a4800 15 Child Activation Wait a + * 4 80ae800 3 80b8000 15 Running c + @end smallexample + + @noindent + In this listing, the asterisk before the first task indicates it to be the + currently running task. The first column lists the task ID that is used + to refer to tasks in the following commands. + + @item break @var{linespec} task @var{taskid} + @itemx break @var{linespec} task @var{taskid} if @dots{} + @cindex Breakpoints and tasks + These commands are like the @code{break @dots{} thread @dots{}}. + @var{linespec} specifies source lines. + + Use the qualifier @samp{task @var{taskid}} with a breakpoint command + to specify that you only want @code{GDB} to stop the program when a + particular Ada task reaches this breakpoint. @var{taskid} is one of the + numeric task identifiers assigned by @code{GDB}, shown in the first + column of the @samp{info tasks} display. + + If you do not specify @samp{task @var{taskid}} when you set a + breakpoint, the breakpoint applies to @emph{all} tasks of your + program. + + You can use the @code{task} qualifier on conditional breakpoints as + well; in this case, place @samp{task @var{taskid}} before the + breakpoint condition (before the @code{if}). + + @item task @var{taskno} + @cindex Task switching + + This command allows to switch to the task referred by @var{taskno}. In + particular, This allows to browse the backtrace of the specified + task. It is advised to switch back to the original task before + continuing execution otherwise the scheduling of the program may be + perturbated. + @end table + + @noindent + For more detailed information on the tasking support, see @cite{Debugging with GDB}. + + @node Debugging Generic Units + @section Debugging Generic Units + @cindex Debugging Generic Units + @cindex Generics + + @noindent + GNAT always uses code expansion for generic instantiation. This means that + each time an instantiation occurs, a complete copy of the original code is + made, with appropriate substitutions of formals by actuals. + + It is not possible to refer to the original generic entities in + @code{GDB}, but it is always possible to debug a particular instance of + a generic, by using the appropriate expanded names. For example, if we have + + @smallexample + @group + @cartouche + @b{procedure} g @b{is} + + @b{generic package} k @b{is} + @b{procedure} kp (v1 : @b{in out} integer); + @b{end} k; + + @b{package body} k @b{is} + @b{procedure} kp (v1 : @b{in out} integer) @b{is} + @b{begin} + v1 := v1 + 1; + @b{end} kp; + @b{end} k; + + @b{package} k1 @b{is new} k; + @b{package} k2 @b{is new} k; + + var : integer := 1; + + @b{begin} + k1.kp (var); + k2.kp (var); + k1.kp (var); + k2.kp (var); + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + Then to break on a call to procedure kp in the k2 instance, simply + use the command: + + @smallexample + (gdb) break g.k2.kp + @end smallexample + + @noindent + When the breakpoint occurs, you can step through the code of the + instance in the normal manner and examine the values of local variables, as for + other units. + + @node GNAT Abnormal Termination or Failure to Terminate + @section GNAT Abnormal Termination or Failure to Terminate + @cindex GNAT Abnormal Termination or Failure to Terminate + + @noindent + When presented with programs that contain serious errors in syntax + or semantics, + GNAT may on rare occasions experience problems in operation, such + as aborting with a + segmentation fault or illegal memory access, raising an internal + exception, terminating abnormally, or failing to terminate at all. + In such cases, you can activate + various features of GNAT that can help you pinpoint the construct in your + program that is the likely source of the problem. + + The following strategies are presented in increasing order of + difficulty, corresponding to your experience in using GNAT and your + familiarity with compiler internals. + + @enumerate + @item + Run @code{gcc} with the @option{-gnatf}. This first + switch causes all errors on a given line to be reported. In its absence, + only the first error on a line is displayed. + + The @option{-gnatdO} switch causes errors to be displayed as soon as they + are encountered, rather than after compilation is terminated. If GNAT + terminates prematurely or goes into an infinite loop, the last error + message displayed may help to pinpoint the culprit. + + @item + Run @code{gcc} with the @code{-v (verbose)} switch. In this mode, + @code{gcc} produces ongoing information about the progress of the + compilation and provides the name of each procedure as code is + generated. This switch allows you to find which Ada procedure was being + compiled when it encountered a code generation problem. + + @item + @cindex @option{-gnatdc} switch + Run @code{gcc} with the @option{-gnatdc} switch. This is a GNAT specific + switch that does for the front-end what @code{-v} does for the back end. + The system prints the name of each unit, either a compilation unit or + nested unit, as it is being analyzed. + @item + Finally, you can start + @code{gdb} directly on the @code{gnat1} executable. @code{gnat1} is the + front-end of GNAT, and can be run independently (normally it is just + called from @code{gcc}). You can use @code{gdb} on @code{gnat1} as you + would on a C program (but @pxref{The GNAT Debugger GDB} for caveats). The + @code{where} command is the first line of attack; the variable + @code{lineno} (seen by @code{print lineno}), used by the second phase of + @code{gnat1} and by the @code{gcc} backend, indicates the source line at + which the execution stopped, and @code{input_file name} indicates the name of + the source file. + @end enumerate + + @node Naming Conventions for GNAT Source Files + @section Naming Conventions for GNAT Source Files + + @noindent + In order to examine the workings of the GNAT system, the following + brief description of its organization may be helpful: + + @itemize @bullet + @item + Files with prefix @file{sc} contain the lexical scanner. + + @item + All files prefixed with @file{par} are components of the parser. The + numbers correspond to chapters of the Ada 95 Reference Manual. For example, + parsing of select statements can be found in @file{par-ch9.adb}. + + @item + All files prefixed with @file{sem} perform semantic analysis. The + numbers correspond to chapters of the Ada standard. For example, all + issues involving context clauses can be found in @file{sem_ch10.adb}. In + addition, some features of the language require sufficient special processing + to justify their own semantic files: sem_aggr for aggregates, sem_disp for + dynamic dispatching, etc. + + @item + All files prefixed with @file{exp} perform normalization and + expansion of the intermediate representation (abstract syntax tree, or AST). + these files use the same numbering scheme as the parser and semantics files. + For example, the construction of record initialization procedures is done in + @file{exp_ch3.adb}. + + @item + The files prefixed with @file{bind} implement the binder, which + verifies the consistency of the compilation, determines an order of + elaboration, and generates the bind file. + + @item + The files @file{atree.ads} and @file{atree.adb} detail the low-level + data structures used by the front-end. + + @item + The files @file{sinfo.ads} and @file{sinfo.adb} detail the structure of + the abstract syntax tree as produced by the parser. + + @item + The files @file{einfo.ads} and @file{einfo.adb} detail the attributes of + all entities, computed during semantic analysis. + + @item + Library management issues are dealt with in files with prefix + @file{lib}. + + @item + @findex Ada + @cindex Annex A + Ada files with the prefix @file{a-} are children of @code{Ada}, as + defined in Annex A. + + @item + @findex Interfaces + @cindex Annex B + Files with prefix @file{i-} are children of @code{Interfaces}, as + defined in Annex B. + + @item + @findex System + Files with prefix @file{s-} are children of @code{System}. This includes + both language-defined children and GNAT run-time routines. + + @item + @findex GNAT + Files with prefix @file{g-} are children of @code{GNAT}. These are useful + general-purpose packages, fully documented in their specifications. All + the other @file{.c} files are modifications of common @code{gcc} files. + @end itemize + + @node Getting Internal Debugging Information + @section Getting Internal Debugging Information + + @noindent + Most compilers have internal debugging switches and modes. GNAT + does also, except GNAT internal debugging switches and modes are not + secret. A summary and full description of all the compiler and binder + debug flags are in the file @file{debug.adb}. You must obtain the + sources of the compiler to see the full detailed effects of these flags. + + The switches that print the source of the program (reconstructed from + the internal tree) are of general interest for user programs, as are the + options to print + the full internal tree, and the entity table (the symbol table + information). The reconstructed source provides a readable version of the + program after the front-end has completed analysis and expansion, and is useful + when studying the performance of specific constructs. For example, constraint + checks are indicated, complex aggregates are replaced with loops and + assignments, and tasking primitives are replaced with run-time calls. + + @node Stack Traceback + @section Stack Traceback + @cindex traceback + @cindex stack traceback + @cindex stack unwinding + + @noindent + Traceback is a mechanism to display the sequence of subprogram calls that + leads to a specified execution point in a program. Often (but not always) + the execution point is an instruction at which an exception has been raised. + This mechanism is also known as @i{stack unwinding} because it obtains + its information by scanning the run-time stack and recovering the activation + records of all active subprograms. Stack unwinding is one of the most + important tools for program debugging. + + @noindent + The first entry stored in traceback corresponds to the deepest calling level, + that is to say the subprogram currently executing the instruction + from which we want to obtain the traceback. + + @noindent + Note that there is no runtime performance penalty when stack traceback + is enabled and no exception are raised during program execution. + + @menu + * Non-Symbolic Traceback:: + * Symbolic Traceback:: + @end menu + + @node Non-Symbolic Traceback + @subsection Non-Symbolic Traceback + @cindex traceback, non-symbolic + + @noindent + Note: this feature is not supported on all platforms. See + @file{GNAT.Traceback spec in g-traceb.ads} for a complete list of supported + platforms. + + @menu + * Tracebacks From an Unhandled Exception:: + * Tracebacks From Exception Occurrences (non-symbolic):: + * Tracebacks From Anywhere in a Program (non-symbolic):: + @end menu + + @node Tracebacks From an Unhandled Exception + @subsubsection Tracebacks From an Unhandled Exception + + @noindent + A runtime non-symbolic traceback is a list of addresses of call instructions. + To enable this feature you must use the @code{-E} + @code{gnatbind}'s option. With this option a stack traceback is stored as part + of exception information. It is possible to retrieve this information using the + standard @code{Ada.Exception.Exception_Information} routine. + + @noindent + Let's have a look at a simple example: + + @smallexample + @cartouche + @group + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ gnatmake stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + @end smallexample + + @noindent + As we see the traceback lists a sequence of addresses for the unhandled + exception @code{CONSTAINT_ERROR} raised in procedure P1. It is easy to + guess that this exception come from procedure P1. To translate these + addresses into the source lines where the calls appear, the + @code{addr2line} tool, described below, is invaluable. The use of this tool + requires the program to be compiled with debug information. + + @smallexample + $ gnatmake -g stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + $ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 + 0x4011f1 0x77e892a4 + + 00401373 at d:/stb/stb.adb:5 + 0040138B at d:/stb/stb.adb:10 + 0040139C at d:/stb/stb.adb:14 + 00401335 at d:/stb/b~stb.adb:104 + 004011C4 at /build/.../crt1.c:200 + 004011F1 at /build/.../crt1.c:222 + 77E892A4 in ?? at ??:0 + @end smallexample + + @noindent + @code{addr2line} has a number of other useful options: + + @table @code + @item --functions + to get the function name corresponding to any location + + @item --demangle=gnat + to use the @b{gnat} decoding mode for the function names. Note that + for binutils version 2.9.x the option is simply @code{--demangle}. + @end table + + @smallexample + $ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b + 0x40139c 0x401335 0x4011c4 0x4011f1 + + 00401373 in stb.p1 at d:/stb/stb.adb:5 + 0040138B in stb.p2 at d:/stb/stb.adb:10 + 0040139C in stb at d:/stb/stb.adb:14 + 00401335 in main at d:/stb/b~stb.adb:104 + 004011C4 in <__mingw_CRTStartup> at /build/.../crt1.c:200 + 004011F1 in at /build/.../crt1.c:222 + @end smallexample + + @noindent + From this traceback we can see that the exception was raised in + @file{stb.adb} at line 5, which was reached from a procedure call in + @file{stb.adb} at line 10, and so on. The @file{b~std.adb} is the binder file, + which contains the call to the main program. + @pxref{Running gnatbind}. The remaining entries are assorted runtime routines, + and the output will vary from platform to platform. + + @noindent + It is also possible to use @code{GDB} with these traceback addresses to debug + the program. For example, we can break at a given code location, as reported + in the stack traceback: + + @smallexample + $ gdb -nw stb + + (gdb) break *0x401373 + Breakpoint 1 at 0x401373: file stb.adb, line 5. + @end smallexample + + @noindent + It is important to note that the stack traceback addresses + do not change when debug information is included. This is particularly useful + because it makes it possible to release software without debug information (to + minimize object size), get a field report that includes a stack traceback + whenever an internal bug occurs, and then be able to retrieve the sequence + of calls with the same program compiled with debug information. + + @node Tracebacks From Exception Occurrences (non-symbolic) + @subsubsection Tracebacks From Exception Occurrences + + @noindent + Non-symbolic tracebacks are obtained by using the @code{-E} binder argument. + The stack traceback is attached to the exception information string, and can + be retrieved in an exception handler within the Ada program, by means of the + Ada95 facilities defined in @code{Ada.Exceptions}. Here is a simple example: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with Ada.Exceptions; + + procedure STB is + + use Ada; + use Ada.Exceptions; + + procedure P1 is + K : Positive := 1; + begin + K := K - 1; + exception + when E : others => + Text_IO.Put_Line (Exception_Information (E)); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @noindent + This program will output: + + @smallexample + $ stb + + Exception name: CONSTRAINT_ERROR + Message: stb.adb:12 + Call stack traceback locations: + 0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4 + @end smallexample + + @node Tracebacks From Anywhere in a Program (non-symbolic) + @subsubsection Tracebacks From Anywhere in a Program + + @noindent + It is also possible to retrieve a stack traceback from anywhere in a + program. For this you need to + use the @code{GNAT.Traceback} API. This package includes a procedure called + @code{Call_Chain} that computes a complete stack traceback, as well as useful + display procedures described below. It is not necessary to use the + @code{-E gnatbind} option in this case, because the stack traceback mechanism + is invoked explicitly. + + @noindent + In the following example we compute a traceback at a specific location in + the program, and we display it using @code{GNAT.Debug_Utilities.Image} to + convert addresses to strings: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Debug_Utilities; + + procedure STB is + + use Ada; + use GNAT; + use GNAT.Traceback; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + + Text_IO.Put ("In STB.P1 : "); + + for K in 1 .. Len loop + Text_IO.Put (Debug_Utilities.Image (TB (K))); + Text_IO.Put (' '); + end loop; + + Text_IO.New_Line; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ gnatmake stb + $ stb + + In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C# + 16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4# + @end smallexample + + @node Symbolic Traceback + @subsection Symbolic Traceback + @cindex traceback, symbolic + + @noindent + A symbolic traceback is a stack traceback in which procedure names are + associated with each code location. + + @noindent + Note that this feature is not supported on all platforms. See + @file{GNAT.Traceback.Symbolic spec in g-trasym.ads} for a complete + list of currently supported platforms. + + @noindent + Note that the symbolic traceback requires that the program be compiled + with debug information. If it is not compiled with debug information + only the non-symbolic information will be valid. + + @menu + * Tracebacks From Exception Occurrences (symbolic):: + * Tracebacks From Anywhere in a Program (symbolic):: + @end menu + + @node Tracebacks From Exception Occurrences (symbolic) + @subsubsection Tracebacks From Exception Occurrences + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback.Symbolic; + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + procedure P3 is + begin + P2; + end P3; + + begin + P3; + exception + when E : others => + Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ gnatmake -g stb -bargs -E -largs -lgnat -laddr2line -lintl + $ stb + + 0040149F in stb.p1 at stb.adb:8 + 004014B7 in stb.p2 at stb.adb:13 + 004014CF in stb.p3 at stb.adb:18 + 004015DD in ada.stb at stb.adb:22 + 00401461 in main at b~stb.adb:168 + 004011C4 in __mingw_CRTStartup at crt1.c:200 + 004011F1 in mainCRTStartup at crt1.c:222 + 77E892A4 in ?? at ??:0 + @end smallexample + + @noindent + The exact sequence of linker options may vary from platform to platform. + The above @code{-largs} section is for Windows platforms. By contrast, + under Unix there is no need for the @code{-largs} section. + Differences across platforms are due to details of linker implementation. + + @node Tracebacks From Anywhere in a Program (symbolic) + @subsubsection Tracebacks From Anywhere in a Program + + @noindent + It is possible to get a symbolic stack traceback + from anywhere in a program, just as for non-symbolic tracebacks. + The first step is to obtain a non-symbolic + traceback, and then call @code{Symbolic_Traceback} to compute the symbolic + information. Here is an example: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Traceback.Symbolic; + + procedure STB is + + use Ada; + use GNAT.Traceback; + use GNAT.Traceback.Symbolic; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len))); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + + @node Inline Assembler + @chapter Inline Assembler + + @noindent + If you need to write low-level software that interacts directly with the hardware, Ada provides two ways to incorporate assembly language code into your program. First, you can import and invoke external routines written in assembly language, an Ada feature fully supported by GNAT. However, for small sections of code it may be simpler or more efficient to include assembly language statements directly in your Ada source program, using the facilities of the implementation-defined package @code{System.Machine_Code}, which incorporates the gcc Inline Assembler. The Inline Assembler approach offers a number of advantages, including the following: + + @itemize @bullet + @item No need to use non-Ada tools + @item Consistent interface over different targets + @item Automatic usage of the proper calling conventions + @item Access to Ada constants and variables + @item Definition of intrinsic routines + @item Possibility of inlining a subprogram comprising assembler code + @item Code optimizer can take Inline Assembler code into account + @end itemize + + This chapter presents a series of examples to show you how to use the Inline Assembler. Although it focuses on the Intel x86, the general approach applies also to other processors. It is assumed that you are familiar with Ada and with assembly language programming. + + @menu + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + @end menu + + @c --------------------------------------------------------------------------- + @node Basic Assembler Syntax + @section Basic Assembler Syntax + + @noindent + The assembler used by GNAT and gcc is based not on the Intel assembly language, but rather on a + language that descends from the AT&T Unix assembler @emph{as} (and which is often + referred to as ``AT&T syntax''). + The following table summarizes the main features of @emph{as} syntax and points out the differences from the Intel conventions. + See the gcc @emph{as} and @emph{gas} (an @emph{as} macro + pre-processor) documentation for further information. + + @table @asis + @item Register names + gcc / @emph{as}: Prefix with ``%''; for example @code{%eax} + @* + Intel: No extra punctuation; for example @code{eax} + + @item Immediate operand + gcc / @emph{as}: Prefix with ``$''; for example @code{$4} + @* + Intel: No extra punctuation; for example @code{4} + + @item Address + gcc / @emph{as}: Prefix with ``$''; for example @code{$loc} + @* + Intel: No extra punctuation; for example @code{loc} + + @item Memory contents + gcc / @emph{as}: No extra punctuation; for example @code{loc} + @* + Intel: Square brackets; for example @code{[loc]} + + @item Register contents + gcc / @emph{as}: Parentheses; for example @code{(%eax)} + @* + Intel: Square brackets; for example @code{[eax]} + + @item Hexadecimal numbers + gcc / @emph{as}: Leading ``0x'' (C language syntax); for example @code{0xA0} + @* + Intel: Trailing ``h''; for example @code{A0h} + + @item Operand size + gcc / @emph{as}: Explicit in op code; for example @code{movw} to move a 16-bit word + @* + Intel: Implicit, deduced by assembler; for example @code{mov} + + @item Instruction repetition + gcc / @emph{as}: Split into two lines; for example + @* + @code{rep} + @* + @code{stosl} + @* + Intel: Keep on one line; for example @code{rep stosl} + + @item Order of operands + gcc / @emph{as}: Source first; for example @code{movw $4, %eax} + @* + Intel: Destination first; for example @code{mov eax, 4} + @end table + + @c --------------------------------------------------------------------------- + @node A Simple Example of Inline Assembler + @section A Simple Example of Inline Assembler + + @noindent + The following example will generate a single assembly language statement, @code{nop}, which does nothing. Despite its lack of run-time effect, the example will be useful in illustrating the basics of the Inline Assembler facility. + + @smallexample + @group + with System.Machine_Code; use System.Machine_Code; + procedure Nothing is + begin + Asm ("nop"); + end Nothing; + @end group + @end smallexample + + @code{Asm} is a procedure declared in package @code{System.Machine_Code}; here it takes one parameter, a @emph{template string} that must be a static expression and that will form the generated instruction. + @code{Asm} may be regarded as a compile-time procedure that parses the template string and additional parameters (none here), from which it generates a sequence of assembly language instructions. + + The examples in this chapter will illustrate several of the forms for invoking @code{Asm}; a complete specification of the syntax is found in the @cite{GNAT Reference Manual}. + + Under the standard GNAT conventions, the @code{Nothing} procedure should be in a file named @file{nothing.adb}. You can build the executable in the usual way: + @smallexample + gnatmake nothing + @end smallexample + However, the interesting aspect of this example is not its run-time behavior but rather the + generated assembly code. To see this output, invoke the compiler as follows: + @smallexample + gcc -c -S -fomit-frame-pointer -gnatp @file{nothing.adb} + @end smallexample + where the options are: + + @table @code + @item -c + compile only (no bind or link) + @item -S + generate assembler listing + @item -fomit-frame-pointer + do not set up separate stack frames + @item -gnatp + do not add runtime checks + @end table + + This gives a human-readable assembler version of the code. The resulting + file will have the same name as the Ada source file, but with a @code{.s} extension. + In our example, the file @file{nothing.s} has the following contents: + + @smallexample + @group + .file "nothing.adb" + gcc2_compiled.: + ___gnu_compiled_ada: + .text + .align 4 + .globl __ada_nothing + __ada_nothing: + #APP + nop + #NO_APP + jmp L1 + .align 2,0x90 + L1: + ret + @end group + @end smallexample + + The assembly code you included is clearly indicated by + the compiler, between the @code{#APP} and @code{#NO_APP} + delimiters. The character before the 'APP' and 'NOAPP' + can differ on different targets. For example, Linux uses '#APP' while + on NT you will see '/APP'. + + If you make a mistake in your assembler code (such as using the + wrong size modifier, or using a wrong operand for the instruction) GNAT + will report this error in a temporary file, which will be deleted when + the compilation is finished. Generating an assembler file will help + in such cases, since you can assemble this file separately using the + @emph{as} assembler that comes with gcc. + + Assembling the file using the command + + @smallexample + as @file{nothing.s} + @end smallexample + @noindent + will give you error messages whose lines correspond to the assembler + input file, so you can easily find and correct any mistakes you made. + If there are no errors, @emph{as} will generate an object file @file{nothing.out}. + + @c --------------------------------------------------------------------------- + @node Output Variables in Inline Assembler + @section Output Variables in Inline Assembler + + @noindent + The examples in this section, showing how to access the processor flags, illustrate how to specify the destination operands for assembly language statements. + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags; + @end group + @end smallexample + + In order to have a nicely aligned assembly listing, we have separated + multiple assembler statements in the Asm template string with linefeed (ASCII.LF) + and horizontal tab (ASCII.HT) characters. The resulting section of the + assembly output file is: + + @smallexample + @group + #APP + pushfl + popl %eax + movl %eax, -40(%ebp) + #NO_APP + @end group + @end smallexample + + It would have been legal to write the Asm invocation as: + + @smallexample + Asm ("pushfl popl %%eax movl %%eax, %0") + @end smallexample + + but in the generated assembler file, this would come out as: + + @smallexample + #APP + pushfl popl %eax movl %eax, -40(%ebp) + #NO_APP + @end smallexample + + which is not so convenient for the human reader. + + We use Ada comments + at the end of each line to explain what the assembler instructions + actually do. This is a useful convention. + + When writing Inline Assembler instructions, you need to precede each register and variable name with a percent sign. Since the assembler already requires a percent sign at the beginning of a register name, you need two consecutive percent signs for such names in the Asm template string, thus @code{%%eax}. In the generated assembly code, one of the percent signs will be stripped off. + + Names such as @code{%0}, @code{%1}, @code{%2}, etc., denote input or output variables: operands you later define using @code{Input} or @code{Output} parameters to @code{Asm}. + An output variable is illustrated in + the third statement in the Asm template string: + @smallexample + movl %%eax, %0 + @end smallexample + The intent is to store the contents of the eax register in a variable that can be accessed in Ada. Simply writing @code{movl %%eax, Flags} would not necessarily work, since the compiler might optimize by using a register to hold Flags, and the expansion of the @code{movl} instruction would not be aware of this optimization. The solution is not to store the result directly but rather to advise the compiler to choose the correct operand form; that is the purpose of the @code{%0} output variable. + + Information about the output variable is supplied in the @code{Outputs} parameter to @code{Asm}: + @smallexample + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + @end smallexample + + The output is defined by the @code{Asm_Output} attribute of the target type; the general format is + @smallexample + Type'Asm_Output (constraint_string, variable_name) + @end smallexample + + The constraint string directs the compiler how + to store/access the associated variable. In the example + @smallexample + Unsigned_32'Asm_Output ("=m", Flags); + @end smallexample + the @code{"m"} (memory) constraint tells the compiler that the variable + @code{Flags} should be stored in a memory variable, thus preventing + the optimizer from keeping it in a register. In contrast, + @smallexample + Unsigned_32'Asm_Output ("=r", Flags); + @end smallexample + uses the @code{"r"} (register) constraint, telling the compiler to + store the variable in a register. + + If the constraint is preceded by the equal character (@strong{=}), it tells the + compiler that the variable will be used to store data into it. + + In the @code{Get_Flags} example, we used the "g" (global) constraint, allowing the optimizer + to choose whatever it deems best. + + There are a fairly large number of constraints, but the ones that are most useful (for the Intel x86 processor) are the following: + + @table @code + @item = + output constraint + @item g + global (i.e. can be stored anywhere) + @item m + in memory + @item I + a constant + @item a + use eax + @item b + use ebx + @item c + use ecx + @item d + use edx + @item S + use esi + @item D + use edi + @item r + use one of eax, ebx, ecx or edx + @item q + use one of eax, ebx, ecx, edx, esi or edi + @end table + + The full set of constraints is described in the gcc and @emph{as} documentation; note that it is possible to combine certain constraints in one constraint string. + + You specify the association of an output variable with an assembler operand through the @code{%}@emph{n} notation, where @emph{n} is a non-negative integer. Thus in + @smallexample + @group + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + @end group + @end smallexample + @noindent + @code{%0} will be replaced in the expanded code by the appropriate operand, + whatever + the compiler decided for the @code{Flags} variable. + + In general, you may have any number of output variables: + @itemize @bullet + @item + Count the operands starting at 0; thus @code{%0}, @code{%1}, etc. + @item + Specify the @code{Outputs} parameter as a parenthesized comma-separated list of @code{Asm_Output} attributes + @end itemize + + For example: + @smallexample + @group + Asm ("movl %%eax, %0" & LF & HT & + "movl %%ebx, %1" & LF & HT & + "movl %%ecx, %2", + Outputs => (Unsigned_32'Asm_Output ("=g", Var_A), -- %0 = Var_A + Unsigned_32'Asm_Output ("=g", Var_B), -- %1 = Var_B + Unsigned_32'Asm_Output ("=g", Var_C))); -- %2 = Var_C + @end group + @end smallexample + @noindent + where @code{Var_A}, @code{Var_B}, and @code{Var_C} are variables in the Ada program. + + As a variation on the @code{Get_Flags} example, we can use the constraints string to direct the compiler to store the eax register into the @code{Flags} variable, instead of including the store instruction explicitly in the @code{Asm} template string: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_2 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax", -- save flags in eax + Outputs => Unsigned_32'Asm_Output ("=a", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_2; + @end group + @end smallexample + + @noindent + The @code{"a"} constraint tells the compiler that the @code{Flags} + variable will come from the eax register. Here is the resulting code: + + @smallexample + @group + #APP + pushfl + popl %eax + #NO_APP + movl %eax,-40(%ebp) + @end group + @end smallexample + + @noindent + The compiler generated the store of eax into Flags after + expanding the assembler code. + + Actually, there was no need to pop the flags into the eax register; more simply, we could just pop the flags directly into the program variable: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_3 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "pop %0", -- save flags in Flags + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_3; + @end group + @end smallexample + + @c --------------------------------------------------------------------------- + @node Input Variables in Inline Assembler + @section Input Variables in Inline Assembler + + @noindent + The example in this section illustrates how to specify the source operands for assembly language statements. The program simply increments its input value by 1: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Incr (Value); + Put_Line ("Value after is" & Value'Img); + end Increment; + @end group + @end smallexample + + The @code{Outputs} parameter to @code{Asm} specifies + that the result will be in the eax register and that it is to be stored in the @code{Result} + variable. + + The @code{Inputs} parameter looks much like the @code{Outputs} parameter, but with an + @code{Asm_Input} attribute. The + @code{"="} constraint, indicating an output value, is not present. + + You can have multiple input variables, in the same way that you can have more + than one output variable. + + The parameter count (%0, %1) etc, now starts at the first input + statement, and continues with the output statements. + When both parameters use the same variable, the + compiler will treat them as the same %n operand, which is the case here. + + Just as the @code{Outputs} parameter causes the register to be stored into the + target variable after execution of the assembler statements, so does the + @code{Inputs} parameter cause its variable to be loaded into the register before execution + of the + assembler statements. + + Thus the effect of the @code{Asm} invocation is: + @enumerate + @item load the 32-bit value of @code{Value} into eax + @item execute the @code{incl %eax} instruction + @item store the contents of eax into the @code{Result} variable + @end enumerate + + The resulting assembler file (with @code{-O2} optimization) contains: + @smallexample + @group + _increment__incr.1: + subl $4,%esp + movl 8(%esp),%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + movl %ecx,(%esp) + addl $4,%esp + ret + @end group + @end smallexample + + @c --------------------------------------------------------------------------- + @node Inlining Inline Assembler Code + @section Inlining Inline Assembler Code + + @noindent + For a short subprogram such as the @code{Incr} function in the previous section, the overhead of the call and return (creating / deleting the stack frame) + can be significant, compared to the amount of code in the subprogram body. + A solution is to apply Ada's @code{Inline} pragma to the subprogram, + which directs the compiler to expand invocations of the subprogram at the point(s) + of call, instead of setting up a stack frame for out-of-line calls. + Here is the resulting program: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment_2 is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + pragma Inline (Increment); + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Increment (Value); + Put_Line ("Value after is" & Value'Img); + end Increment_2; + @end group + @end smallexample + + Compile the program with both optimization (@code{-O2}) and inlining + enabled (@option{-gnatpn} instead of @option{-gnatp}). + + The @code{Incr} function is still compiled as usual, but at the + point in @code{Increment} where our function used to be called: + + @smallexample + @group + pushl %edi + call _increment__incr.1 + @end group + @end smallexample + + @noindent + the code for the function body directly appears: + + @smallexample + @group + movl %esi,%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + @end group + @end smallexample + + @noindent + thus saving the overhead of stack frame setup and an out-of-line call. + + @c --------------------------------------------------------------------------- + @node Other Asm Functionality + @section Other @code{Asm} Functionality + + @noindent + This section describes two important parameters to the @code{Asm} procedure: @code{Clobber}, which identifies register usage; and @code{Volatile}, which inhibits unwanted optimizations. + + @menu + * The Clobber Parameter:: + * The Volatile Parameter:: + @end menu + + @c --------------------------------------------------------------------------- + @node The Clobber Parameter + @subsection The @code{Clobber} Parameter + + @noindent + One of the dangers of intermixing assembly language and a compiled language such as Ada is + that the compiler needs to be aware of which registers are being used by the assembly code. + In some cases, such as the earlier examples, the constraint string is sufficient to + indicate register usage (e.g. "a" for the eax register). But more generally, the + compiler needs an explicit identification of the registers that are used by the Inline + Assembly statements. + + Using a register that the compiler doesn't know about + could be a side effect of an instruction (like @code{mull} + storing its result in both eax and edx). + It can also arise from explicit register usage in your + assembly code; for example: + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out)); + @end group + @end smallexample + @noindent + where the compiler (since it does not analyze the @code{Asm} template string) + does not know you are using the ebx register. + + In such cases you need to supply the @code{Clobber} parameter to @code{Asm}, + to identify the registers that will be used by your assembly code: + + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx"); + @end group + @end smallexample + + The Clobber parameter is a static string expression specifying the + register(s) you are using. Note that register names are @emph{not} prefixed by a percent sign. + Also, if more than one register is used then their names are separated by commas; e.g., @code{"eax, ebx"} + + The @code{Clobber} parameter has several additional uses: + @enumerate + @item Use the "register" name @code{cc} to indicate that flags might have changed + @item Use the "register" name @code{memory} if you changed a memory location + @end enumerate + + @c --------------------------------------------------------------------------- + @node The Volatile Parameter + @subsection The @code{Volatile} Parameter + @cindex Volatile parameter + + @noindent + Compiler optimizations in the presence of Inline Assembler may sometimes have unwanted effects. + For example, when + an @code{Asm} invocation with an input variable is inside a loop, the compiler might move + the loading of the input variable outside the loop, regarding it as a + one-time initialization. + + If this effect is not desired, you can disable such optimizations by setting the + @code{Volatile} parameter to @code{True}; for example: + + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx", + Volatile => True); + @end group + @end smallexample + + By default, @code{Volatile} is set to @code{False} unless there is no @code{Outputs} + parameter. + + Although setting @code{Volatile} to @code{True} prevents unwanted optimizations, + it will also disable other optimizations that might be important for efficiency. + In general, you should set @code{Volatile} to @code{True} only if the compiler's + optimizations have created problems. + + @c --------------------------------------------------------------------------- + @node A Complete Example + @section A Complete Example + + @noindent + This section contains a complete program illustrating a realistic usage of GNAT's Inline Assembler + capabilities. It comprises a main procedure @code{Check_CPU} and a package @code{Intel_CPU}. + The package declares a collection of functions that detect the properties of the 32-bit + x86 processor that is running the program. The main procedure invokes these functions + and displays the information. + + The Intel_CPU package could be enhanced by adding functions to + detect the type of x386 co-processor, the processor caching options and + special operations such as the SIMD extensions. + + Although the Intel_CPU package has been written for 32-bit Intel + compatible CPUs, it is OS neutral. It has been tested on DOS, + Windows/NT and Linux. + + @menu + * Check_CPU Procedure:: + * Intel_CPU Package Specification:: + * Intel_CPU Package Body:: + @end menu + + @c --------------------------------------------------------------------------- + @node Check_CPU Procedure + @subsection @code{Check_CPU} Procedure + @cindex Check_CPU procedure + + @smallexample + --------------------------------------------------------------------- + -- -- + -- Uses the Intel_CPU package to identify the CPU the program is -- + -- running on, and some of the features it supports. -- + -- -- + --------------------------------------------------------------------- + + with Intel_CPU; -- Intel CPU detection functions + with Ada.Text_IO; -- Standard text I/O + with Ada.Command_Line; -- To set the exit status + + procedure Check_CPU is + + Type_Found : Boolean := False; + -- Flag to indicate that processor was identified + + Features : Intel_CPU.Processor_Features; + -- The processor features + + Signature : Intel_CPU.Processor_Signature; + -- The processor type signature + + begin + + ----------------------------------- + -- Display the program banner. -- + ----------------------------------- + + Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name & + ": check Intel CPU version and features, v1.0"); + Ada.Text_IO.Put_Line ("distribute freely, but no warranty whatsoever"); + Ada.Text_IO.New_Line; + + ----------------------------------------------------------------------- + -- We can safely start with the assumption that we are on at least -- + -- a x386 processor. If the CPUID instruction is present, then we -- + -- have a later processor type. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Has_CPUID = False then + + -- No CPUID instruction, so we assume this is indeed a x386 + -- processor. We can still check if it has a FP co-processor. + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line + ("x386-type processor with a FP co-processor"); + else + Ada.Text_IO.Put_Line + ("x386-type processor without a FP co-processor"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check for CPUID + + ----------------------------------------------------------------------- + -- If CPUID is supported, check if this is a true Intel processor, -- + -- if it is not, display a warning. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Vendor_ID /= Intel_CPU.Intel_Processor then + Ada.Text_IO.Put_Line ("*** This is a Intel compatible processor"); + Ada.Text_IO.Put_Line ("*** Some information may be incorrect"); + end if; -- check if Intel + + ---------------------------------------------------------------------- + -- With the CPUID instruction present, we can assume at least a -- + -- x486 processor. If the CPUID support level is < 1 then we have -- + -- to leave it at that. -- + ---------------------------------------------------------------------- + + if Intel_CPU.CPUID_Level < 1 then + + -- Ok, this is a x486 processor. we still can get the Vendor ID + Ada.Text_IO.Put_Line ("x486-type processor"); + Ada.Text_IO.Put_Line ("Vendor ID is " & Intel_CPU.Vendor_ID); + + -- We can also check if there is a FPU present + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line ("Floating-Point support"); + else + Ada.Text_IO.Put_Line ("No Floating-Point support"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check CPUID level + + --------------------------------------------------------------------- + -- With a CPUID level of 1 we can use the processor signature to -- + -- determine it's exact type. -- + --------------------------------------------------------------------- + + Signature := Intel_CPU.Signature; + + ---------------------------------------------------------------------- + -- Ok, now we go into a lot of messy comparisons to get the -- + -- processor type. For clarity, no attememt to try to optimize the -- + -- comparisons has been made. Note that since Intel_CPU does not -- + -- support getting cache info, we cannot distinguish between P5 -- + -- and Celeron types yet. -- + ---------------------------------------------------------------------- + + -- x486SL + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486SL processor"); + end if; + + -- x486DX2 Write-Back + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0111# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Write-Back Enhanced x486DX2 processor"); + end if; + + -- x486DX4 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 processor"); + end if; + + -- x486DX4 Overdrive + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 OverDrive processor"); + end if; + + -- Pentium (60, 66) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium processor (60, 66)"); + end if; + + -- Pentium (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive (60, 66) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium OverDrive processor (60, 66)"); + end if; + + -- Pentium OverDrive (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive cpu (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive processor for x486 processor-based systems + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor for x486 processor-based systems"); + end if; + + -- Pentium processor with MMX technology (166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor with MMX technology (166, 200)"); + end if; + + -- Pentium OverDrive with MMX for Pentium (75, 90, 100, 120, 133) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor with MMX " & + "technology for Pentium processor (75, 90, 100, 120, 133)"); + end if; + + -- Pentium Pro processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro processor"); + end if; + + -- Pentium II processor, model 3 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium II processor, model 3"); + end if; + + -- Pentium II processor, model 5 or Celeron processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0101# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium II processor, model 5 or Celeron processor"); + end if; + + -- Pentium Pro OverDrive processor + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro OverDrive processor"); + end if; + + -- If no type recognized, we have an unknown. Display what + -- we _do_ know + if Type_Found = False then + Ada.Text_IO.Put_Line ("Unknown processor"); + end if; + + ----------------------------------------- + -- Display processor stepping level. -- + ----------------------------------------- + + Ada.Text_IO.Put_Line ("Stepping level:" & Signature.Stepping'Img); + + --------------------------------- + -- Display vendor ID string. -- + --------------------------------- + + Ada.Text_IO.Put_Line ("Vendor ID: " & Intel_CPU.Vendor_ID); + + ------------------------------------ + -- Get the processors features. -- + ------------------------------------ + + Features := Intel_CPU.Features; + + ----------------------------- + -- Check for a FPU unit. -- + ----------------------------- + + if Features.FPU = True then + Ada.Text_IO.Put_Line ("Floating-Point unit available"); + else + Ada.Text_IO.Put_Line ("no Floating-Point unit"); + end if; -- check for FPU + + -------------------------------- + -- List processor features. -- + -------------------------------- + + Ada.Text_IO.Put_Line ("Supported features: "); + + -- Virtual Mode Extension + if Features.VME = True then + Ada.Text_IO.Put_Line (" VME - Virtual Mode Extension"); + end if; + + -- Debugging Extension + if Features.DE = True then + Ada.Text_IO.Put_Line (" DE - Debugging Extension"); + end if; + + -- Page Size Extension + if Features.PSE = True then + Ada.Text_IO.Put_Line (" PSE - Page Size Extension"); + end if; + + -- Time Stamp Counter + if Features.TSC = True then + Ada.Text_IO.Put_Line (" TSC - Time Stamp Counter"); + end if; + + -- Model Specific Registers + if Features.MSR = True then + Ada.Text_IO.Put_Line (" MSR - Model Specific Registers"); + end if; + + -- Physical Address Extension + if Features.PAE = True then + Ada.Text_IO.Put_Line (" PAE - Physical Address Extension"); + end if; + + -- Machine Check Extension + if Features.MCE = True then + Ada.Text_IO.Put_Line (" MCE - Machine Check Extension"); + end if; + + -- CMPXCHG8 instruction supported + if Features.CX8 = True then + Ada.Text_IO.Put_Line (" CX8 - CMPXCHG8 instruction"); + end if; + + -- on-chip APIC hardware support + if Features.APIC = True then + Ada.Text_IO.Put_Line (" APIC - on-chip APIC hardware support"); + end if; + + -- Fast System Call + if Features.SEP = True then + Ada.Text_IO.Put_Line (" SEP - Fast System Call"); + end if; + + -- Memory Type Range Registers + if Features.MTRR = True then + Ada.Text_IO.Put_Line (" MTTR - Memory Type Range Registers"); + end if; + + -- Page Global Enable + if Features.PGE = True then + Ada.Text_IO.Put_Line (" PGE - Page Global Enable"); + end if; + + -- Machine Check Architecture + if Features.MCA = True then + Ada.Text_IO.Put_Line (" MCA - Machine Check Architecture"); + end if; + + -- Conditional Move Instruction Supported + if Features.CMOV = True then + Ada.Text_IO.Put_Line + (" CMOV - Conditional Move Instruction Supported"); + end if; + + -- Page Attribute Table + if Features.PAT = True then + Ada.Text_IO.Put_Line (" PAT - Page Attribute Table"); + end if; + + -- 36-bit Page Size Extension + if Features.PSE_36 = True then + Ada.Text_IO.Put_Line (" PSE_36 - 36-bit Page Size Extension"); + end if; + + -- MMX technology supported + if Features.MMX = True then + Ada.Text_IO.Put_Line (" MMX - MMX technology supported"); + end if; + + -- Fast FP Save and Restore + if Features.FXSR = True then + Ada.Text_IO.Put_Line (" FXSR - Fast FP Save and Restore"); + end if; + + --------------------- + -- Program done. -- + --------------------- + + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + + exception + + when others => + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); + raise; + + end Check_CPU; + @end smallexample + + @c --------------------------------------------------------------------------- + @node Intel_CPU Package Specification + @subsection @code{Intel_CPU} Package Specification + @cindex Intel_CPU package specification + + @smallexample + ------------------------------------------------------------------------- + -- -- + -- file: intel_cpu.ads -- + -- -- + -- ********************************************* -- + -- * WARNING: for 32-bit Intel processors only * -- + -- ********************************************* -- + -- -- + -- This package contains a number of subprograms that are useful in -- + -- determining the Intel x86 CPU (and the features it supports) on -- + -- which the program is running. -- + -- -- + -- The package is based upon the information given in the Intel -- + -- Application Note AP-485: "Intel Processor Identification and the -- + -- CPUID Instruction" as of April 1998. This application note can be -- + -- found on www.intel.com. -- + -- -- + -- It currently deals with 32-bit processors only, will not detect -- + -- features added after april 1998, and does not guarantee proper -- + -- results on Intel-compatible processors. -- + -- -- + -- Cache info and x386 fpu type detection are not supported. -- + -- -- + -- This package does not use any privileged instructions, so should -- + -- work on any OS running on a 32-bit Intel processor. -- + -- -- + ------------------------------------------------------------------------- + + with Interfaces; use Interfaces; + -- for using unsigned types + + with System.Machine_Code; use System.Machine_Code; + -- for using inline assembler code + + with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; + -- for inserting control characters + + package Intel_CPU is + + ---------------------- + -- Processor bits -- + ---------------------- + + subtype Num_Bits is Natural range 0 .. 31; + -- the number of processor bits (32) + + -------------------------- + -- Processor register -- + -------------------------- + + -- define a processor register type for easy access to + -- the individual bits + + type Processor_Register is array (Num_Bits) of Boolean; + pragma Pack (Processor_Register); + for Processor_Register'Size use 32; + + ------------------------- + -- Unsigned register -- + ------------------------- + + -- define a processor register type for easy access to + -- the individual bytes + + type Unsigned_Register is + record + L1 : Unsigned_8; + H1 : Unsigned_8; + L2 : Unsigned_8; + H2 : Unsigned_8; + end record; + + for Unsigned_Register use + record + L1 at 0 range 0 .. 7; + H1 at 0 range 8 .. 15; + L2 at 0 range 16 .. 23; + H2 at 0 range 24 .. 31; + end record; + + for Unsigned_Register'Size use 32; + + --------------------------------- + -- Intel processor vendor ID -- + --------------------------------- + + Intel_Processor : constant String (1 .. 12) := "GenuineIntel"; + -- indicates an Intel manufactured processor + + ------------------------------------ + -- Processor signature register -- + ------------------------------------ + + -- a register type to hold the processor signature + + type Processor_Signature is + record + Stepping : Natural range 0 .. 15; + Model : Natural range 0 .. 15; + Family : Natural range 0 .. 15; + Processor_Type : Natural range 0 .. 3; + Reserved : Natural range 0 .. 262143; + end record; + + for Processor_Signature use + record + Stepping at 0 range 0 .. 3; + Model at 0 range 4 .. 7; + Family at 0 range 8 .. 11; + Processor_Type at 0 range 12 .. 13; + Reserved at 0 range 14 .. 31; + end record; + + for Processor_Signature'Size use 32; + + ----------------------------------- + -- Processor features register -- + ----------------------------------- + + -- a processor register to hold the processor feature flags + + type Processor_Features is + record + FPU : Boolean; -- floating point unit on chip + VME : Boolean; -- virtual mode extension + DE : Boolean; -- debugging extension + PSE : Boolean; -- page size extension + TSC : Boolean; -- time stamp counter + MSR : Boolean; -- model specific registers + PAE : Boolean; -- physical address extension + MCE : Boolean; -- machine check extension + CX8 : Boolean; -- cmpxchg8 instruction + APIC : Boolean; -- on-chip apic hardware + Res_1 : Boolean; -- reserved for extensions + SEP : Boolean; -- fast system call + MTRR : Boolean; -- memory type range registers + PGE : Boolean; -- page global enable + MCA : Boolean; -- machine check architecture + CMOV : Boolean; -- conditional move supported + PAT : Boolean; -- page attribute table + PSE_36 : Boolean; -- 36-bit page size extension + Res_2 : Natural range 0 .. 31; -- reserved for extensions + MMX : Boolean; -- MMX technology supported + FXSR : Boolean; -- fast FP save and restore + Res_3 : Natural range 0 .. 127; -- reserved for extensions + end record; + + for Processor_Features use + record + FPU at 0 range 0 .. 0; + VME at 0 range 1 .. 1; + DE at 0 range 2 .. 2; + PSE at 0 range 3 .. 3; + TSC at 0 range 4 .. 4; + MSR at 0 range 5 .. 5; + PAE at 0 range 6 .. 6; + MCE at 0 range 7 .. 7; + CX8 at 0 range 8 .. 8; + APIC at 0 range 9 .. 9; + Res_1 at 0 range 10 .. 10; + SEP at 0 range 11 .. 11; + MTRR at 0 range 12 .. 12; + PGE at 0 range 13 .. 13; + MCA at 0 range 14 .. 14; + CMOV at 0 range 15 .. 15; + PAT at 0 range 16 .. 16; + PSE_36 at 0 range 17 .. 17; + Res_2 at 0 range 18 .. 22; + MMX at 0 range 23 .. 23; + FXSR at 0 range 24 .. 24; + Res_3 at 0 range 25 .. 31; + end record; + + for Processor_Features'Size use 32; + + ------------------- + -- Subprograms -- + ------------------- + + function Has_FPU return Boolean; + -- return True if a FPU is found + -- use only if CPUID is not supported + + function Has_CPUID return Boolean; + -- return True if the processor supports the CPUID instruction + + function CPUID_Level return Natural; + -- return the CPUID support level (0, 1 or 2) + -- can only be called if the CPUID instruction is supported + + function Vendor_ID return String; + -- return the processor vendor identification string + -- can only be called if the CPUID instruction is supported + + function Signature return Processor_Signature; + -- return the processor signature + -- can only be called if the CPUID instruction is supported + + function Features return Processor_Features; + -- return the processors features + -- can only be called if the CPUID instruction is supported + + private + + ------------------------ + -- EFLAGS bit names -- + ------------------------ + + ID_Flag : constant Num_Bits := 21; + -- ID flag bit + + end Intel_CPU; + @end smallexample + + @c --------------------------------------------------------------------------- + @node Intel_CPU Package Body + @subsection @code{Intel_CPU} Package Body + @cindex Intel_CPU package body + + @smallexample + package body Intel_CPU is + + --------------------------- + -- Detect FPU presence -- + --------------------------- + + -- There is a FPU present if we can set values to the FPU Status + -- and Control Words. + + function Has_FPU return Boolean is + + Register : Unsigned_16; + -- processor register to store a word + + begin + + -- check if we can change the status word + Asm ( + + -- the assembler code + "finit" & LF & HT & -- reset status word + "movw $0x5A5A, %%ax" & LF & HT & -- set value status word + "fnstsw %0" & LF & HT & -- save status word + "movw %%ax, %0", -- store status word + + -- output stored in Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register), + + -- tell compiler that we used eax + Clobber => "eax"); + + -- if the status word is zero, there is no FPU + if Register = 0 then + return False; -- no status word + end if; -- check status word value + + -- check if we can get the control word + Asm ( + + -- the assembler code + "fnstcw %0", -- save the control word + + -- output into Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register)); + + -- check the relevant bits + if (Register and 16#103F#) /= 16#003F# then + return False; -- no control word + end if; -- check control word value + + -- FPU found + return True; + + end Has_FPU; + + -------------------------------- + -- Detect CPUID instruction -- + -------------------------------- + + -- The processor supports the CPUID instruction if it is possible + -- to change the value of ID flag bit in the EFLAGS register. + + function Has_CPUID return Boolean is + + Original_Flags, Modified_Flags : Processor_Register; + -- EFLAG contents before and after changing the ID flag + + begin + + -- try flipping the ID flag in the EFLAGS register + Asm ( + + -- the assembler code + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %%eax" & LF & HT & -- pop EFLAGS into eax + "movl %%eax, %0" & LF & HT & -- save EFLAGS content + "xor $0x200000, %%eax" & LF & HT & -- flip ID flag + "push %%eax" & LF & HT & -- push EFLAGS on stack + "popfl" & LF & HT & -- load EFLAGS register + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %1", -- save EFLAGS content + + -- output values, may be anything + -- Original_Flags is %0 + -- Modified_Flags is %1 + Outputs => + (Processor_Register'Asm_output ("=g", Original_Flags), + Processor_Register'Asm_output ("=g", Modified_Flags)), + + -- tell compiler eax is destroyed + Clobber => "eax"); + + -- check if CPUID is supported + if Original_Flags(ID_Flag) /= Modified_Flags(ID_Flag) then + return True; -- ID flag was modified + else + return False; -- ID flag unchanged + end if; -- check for CPUID + + end Has_CPUID; + + ------------------------------- + -- Get CPUID support level -- + ------------------------------- + + function CPUID_Level return Natural is + + Level : Unsigned_32; + -- returned support level + + begin + + -- execute CPUID, storing the results in the Level register + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero is stored in eax + -- returning the support level in eax + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- eax is stored in Level + Outputs => Unsigned_32'Asm_output ("=a", Level), + + -- tell compiler ebx, ecx and edx registers are destroyed + Clobber => "ebx, ecx, edx"); + + -- return the support level + return Natural (Level); + + end CPUID_Level; + + -------------------------------- + -- Get CPU Vendor ID String -- + -------------------------------- + + -- The vendor ID string is returned in the ebx, ecx and edx register + -- after executing the CPUID instruction with eax set to zero. + -- In case of a true Intel processor the string returned is + -- "GenuineIntel" + + function Vendor_ID return String is + + Ebx, Ecx, Edx : Unsigned_Register; + -- registers containing the vendor ID string + + Vendor_ID : String (1 .. 12); + -- the vendor ID string + + begin + + -- execute CPUID, storing the results in the processor registers + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero stored in eax + -- vendor ID string returned in ebx, ecx and edx + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- ebx is stored in Ebx + -- ecx is stored in Ecx + -- edx is stored in Edx + Outputs => (Unsigned_Register'Asm_output ("=b", Ebx), + Unsigned_Register'Asm_output ("=c", Ecx), + Unsigned_Register'Asm_output ("=d", Edx))); + + -- now build the vendor ID string + Vendor_ID( 1) := Character'Val (Ebx.L1); + Vendor_ID( 2) := Character'Val (Ebx.H1); + Vendor_ID( 3) := Character'Val (Ebx.L2); + Vendor_ID( 4) := Character'Val (Ebx.H2); + Vendor_ID( 5) := Character'Val (Edx.L1); + Vendor_ID( 6) := Character'Val (Edx.H1); + Vendor_ID( 7) := Character'Val (Edx.L2); + Vendor_ID( 8) := Character'Val (Edx.H2); + Vendor_ID( 9) := Character'Val (Ecx.L1); + Vendor_ID(10) := Character'Val (Ecx.H1); + Vendor_ID(11) := Character'Val (Ecx.L2); + Vendor_ID(12) := Character'Val (Ecx.H2); + + -- return string + return Vendor_ID; + + end Vendor_ID; + + ------------------------------- + -- Get processor signature -- + ------------------------------- + + function Signature return Processor_Signature is + + Result : Processor_Signature; + -- processor signature returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one is stored in eax + -- processor signature returned in eax + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- eax is stored in Result + Outputs => Processor_Signature'Asm_output ("=a", Result), + + -- tell compiler that ebx, ecx and edx are also destroyed + Clobber => "ebx, ecx, edx"); + + -- return processor signature + return Result; + + end Signature; + + ------------------------------ + -- Get processor features -- + ------------------------------ + + function Features return Processor_Features is + + Result : Processor_Features; + -- processor features returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one stored in eax + -- processor features returned in edx + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- edx is stored in Result + Outputs => Processor_Features'Asm_output ("=d", Result), + + -- tell compiler that ebx and ecx are also destroyed + Clobber => "ebx, ecx"); + + -- return processor signature + return Result; + + end Features; + + end Intel_CPU; + @end smallexample + @c END OF INLINE ASSEMBLER CHAPTER + @c =============================== + + + @node VxWorks Topics + @chapter VxWorks Topics + + @noindent + This chapter describes topics that are specific to the GNAT for VxWorks + configurations. + + @menu + * Kernel Configuration for VxWorks:: + * Kernel Compilation Issues for VxWorks:: + * Handling Relocation Issues for PowerPc Targets:: + * Support for Software Floating Point on PowerPC Processors:: + * Interrupt Handling for VxWorks:: + * Simulating Command Line Arguments for VxWorks:: + * Debugging Issues for VxWorks:: + * Using GNAT from the Tornado 2 Project Facility:: + * Frequently Asked Questions for VxWorks:: + @end menu + + @node Kernel Configuration for VxWorks + @section Kernel Configuration for VxWorks + + @noindent + When configuring your VxWorks kernel we recommend including the target + shell. If you omit it from the configuration, you may get undefined + symbols at load time, e.g. + + @smallexample + -> ld < hello.exe + Loading hello.exe + Undefined symbols: + mkdir + @end smallexample + + @noindent + Generally, such undefined symbols are harmless since these are used by + optional parts of the GNAT run time. However if running your application + generates a VxWorks exception or illegal instruction, you should reconfigure + your kernel to resolve these symbols. + + @node Kernel Compilation Issues for VxWorks + @section Kernel Compilation Issues for VxWorks + + @noindent + If you plan to link an Ada module with a Tornado 2 Kernel, follow these steps. + (Note that these recommendations apply to @file{cygnus-2.7.2-960126}, + shipped with Tornado 2 as the C compiler toolchain.) + + @itemize @bullet + @item + Compile your Ada module without linking it with the VxWorks Library: + @smallexample + gnatmake foo.adb -largs -nostdlib + @end smallexample + + @item + Edit your makefile and add on the @code{LIBS} line the exact path and name + of the GCC library file provided with GNAT. + @smallexample + LIBS = $(WIND_BASE)/target/lib/libPPC604gnuvx.a \ + /opt/gnu/gnat/lib/gcc-lib/powerpc-wrs-vxworks/2.8.1/libgcc.a + @end smallexample + + @noindent + To know the exact name and location of this file, type + @code{-gcc -print-libgcc-file-name} in a console. Note that this version of GCC is the + one provided with GNAT. + @smallexample + ~ >powerpc-wrs-vxworks-gcc -print-libgcc-file-name + /opt/gnu/gnat/lib/gcc-lib/powerpc-wrs-vxworks/2.8.1/libgcc.a + @end smallexample + @end itemize + + + @node Handling Relocation Issues for PowerPc Targets + @section Handling Relocation Issues for PowerPc Targets + @cindex Relocation issues for PowerPc VxWorks targets + @cindex PowerPc VxWorks, relocation issues + @cindex VxWorks PowerPc, relocation issues + + @noindent + Under certain circumstances, loading a program onto a PowerPC + board will fail with the message + @emph{Relocation value does not fit in 24 bits}. + + For some background on this issue, please refer to WRS' SPRs + 6040, 20257, and 22767. + In summary, + VxWorks on the PowerPC follows the variation of the SVR4 ABI known + as the Embedded ABI (@emph{EABI}). + @cindex Embedded ABI (for VxWorks on PowerPc) + @cindex EABI (for VxWorks on PowerPc) + In order to save space and time in + embedded applications, the EABI specifies that the default for + subprogram calls should be the branch instruction with relative + addressing using an immediate operand. The immediate operand + to this instruction (relative address) is 24 bits wide. It + is sign extended and 2#00# is appended for the last 2 bits (all + instructions must be on a 4 byte boundary). + The resulting + 26 bit offset means that the target of the branch must be within + +/- 32 Mbytes of the relative branch instruction. When VxWorks + is loading a program it completes the linking phase by + resolving all of the unresolved references in the object being + loaded. When one of those references is a relative address in + a branch instruction, and the linker determines that the target + is more than 32 Mbytes away from the branch, the error occurs. + + This only happens when the BSP is configured to use + more than 32 MBytes of memory. The VxWorks kernel is loaded into + low memory addresses, and the error usually occurs when the target + loader is used (because it loads objects into high memory, and thus + calls from the program to the VxWorks kernel can be too far). + @cindex VxWorks kernel (relocation issues on PowerPc) + + One way to solve this problem is to use the Tornado + host loader; this will place programs in low memory, close to the kernel. + + Another approach is to make use of the @code{-mlongcall} option to the + compiler; + @cindex @code{-mlongcall} (gcc) + GNAT has incorporated WRS' + gcc modification that implements this option. + If a subprogram call is + compiled with the @code{-mlongcall} option, then the generated code + constructs an absolute address in a register and uses a branch + instruction with absolute addressing mode. + + Starting with release 3.15, the GNAT runtime libraries that are + distributed are compiled with the @code{-mlongcall} option. In many + cases the use of these libraries is sufficient to avoid the + relocation problem, since it is the runtime library that contains + calls to the VxWorks kernel that need to span the address space gap. + If you are using an earlier GNAT release or a manually-built runtime, + you should recompile the GNAT runtime library with @code{-mlongcall}; + you can use the + @file{Makefile.adalib} file from the @file{adalib} directory. + + Application code may need to be compiled with @code{-mlongcall} if there + are calls directly to the kernel, the application is very large, + or in some specialized linking/loading scenarios. + + You can compile individual files with @code{-mlongcall} by placing this + option on the @code{gcc} command line (for brevity we are omitting the + @code{powerpc-wrs-vxworks-} prefix on the commands shown in this + paragraph). + If you provide @code{-mlongcall} as an option for @code{gnatmake}, it will be + passed to all invocations of @code{gcc} that @code{gnatmake} directly performs. + Note that one other compilation is made by @code{gnatlink}, on the file created + by @code{gnatbind} for the elaboration package body + (see @ref{Binding Using gnatbind}). + Passing @code{-mlongcall} to @code{gnatlink}, either directly + on the @code{gnatlink} command line or by including @code{-mlongcall} in the + @code{-largs} list of @code{gnatmake}, will direct @code{gnatlink} to compile the + binder file with the @code{-mlongcall} option. + + To see the effect of @code{-mlongcall}, consider the following small example: + + @smallexample + procedure Proc is + procedure Imported_Proc; + pragma Import (Ada, Imported_Proc); + begin + Imported_Proc; + end; + @end smallexample + + @noindent + If you compile @code{Proc} with the default options (no @code{-mlongcall}), the following code is generated: + + @smallexample + _ada_proc: + ... + bl imported_proc + ... + @end smallexample + + @noindent + In contrast, here is the result with the @code{-mlongcall} option: + + @smallexample + _ada_proc: + ... + addis 9,0,imported_proc@@ha + addi 0,9,imported_proc@@l + mtlr 0 + blrl + ... + @end smallexample + + + @node Support for Software Floating Point on PowerPC Processors + @section Support for Software Floating Point on PowerPC Processors + + @noindent + The PowerPC 860 processor does not have hardware floating-point support. + In order to build and run GNAT modules properly, you need to install and + invoke software-emulated floating-point support as follows: + + @itemize @bullet + @item + At installation time: + @itemize @bullet + @item + Create a file @file{ada_object_path} under the directory + @file{BASE\lib\gcc-lib\powerpc-wrs-vxworks\2.8.1} + (by default @file{BASE}=@file{c:\gnatpro}) + containing the following line: + @smallexample + rts-soft-float\adalib + @end smallexample + + @item + Create a file @file{ada_source_path} under the directory + @file{BASE\lib\gcc-lib\powerpc-wrs-vxworks\2.8.1} + (by default @file{BASE}=@file{c:\gnatpro}) + containing the following line: + @smallexample + rts-soft-float\adainclude + @end smallexample + @end itemize + + @item + When using the compiler, specify @option{-msoft-float} + as a compiler and a linker option, e.g.: + @smallexample + $powerpc-wrs-vxworks-gnatmake -msoft-float module -largs -msoft-float + @end smallexample + @end itemize + + + @node Interrupt Handling for VxWorks + @section Interrupt Handling for VxWorks + + @noindent + GNAT offers a range of options for hardware interrupt handling. In rough + order of latency and lack of restrictions: + + @itemize @bullet + @item Directly vectored interrupt procedure handlers + @item Directly vectored interrupt procedures that signal a task using + a suspension object + @item Ada 95 protected procedure handlers for interrupts + @item Ada 83 style interrupt entry handlers for interrupts + @end itemize + + @noindent + In general, the range of possible solutions trades off latency versus + restrictions in the handler code. Restrictions in direct vectored + interrupt handlers are documented in the @cite{VxWorks Programmer's Guide}. + Protected procedure handlers have only the + restriction that no potentially blocking operations are performed within + the handler. Interrupt entries have no restrictions. We recommend the + use of the protected procedure mechanism as providing the best balance + of these considerations for most applications. + + All handler types must explicitly perform any required hardware cleanups, + such as issuing an end-of-interrupt if necessary. + + For VxWorks/AE, applications that handle interrupts must be loaded into + the kernel protection domain. + + @itemize @bullet + @item Direct Vectored Interrupt Routines + + @noindent + This approach provides the lowest interrupt latency, but has the most + restrictions on what VxWorks and Ada runtime calls can be made, as well + as on what Ada entities are accessible to the handler code. Such handlers + are most useful when there are stringent latency requirements, and very + little processing is to be performed in the handler. Access to the + necessary VxWorks routines for setting up such handlers is provided in + the package @code{Interfaces.VxWorks}. + + VxWorks restrictions are described in the @cite{VxWorks Programmer's Manual}. + Note in particular that floating point context is not automatically saved and + restored when interrupts are vectored to the handler. If the handler is + to execute floating point instructions, the statements involved must be + bracketed by a pair of calls to @code{fppSave} and @code{fppRestore} defined + in @code{Interfaces.VxWorks}. + + In general, it is a good idea to save and restore the handler that was + installed prior to application startup. The routines @code{intVecGet} + and @code{intVecSet} are used for this purpose. The Ada handler code + is installed into the vector table using routine @code{intConnect}, + which generates wrapper code to save and restore registers. + + Example: + + @smallexample + with Interfaces.VxWorks; use Interfaces.VxWorks; + with System; + + package P is + + Count : Natural := 0; + pragma Atomic (Count); + + -- Interrupt level used by this example + Level : constant := 1; + + -- Be sure to use a reasonable interrupt number for the target + -- board! Refer to the BSP for details. + Interrupt : constant := 16#14#; + + procedure Handler (Parameter : System.Address); + + end P; + + package body P is + + procedure Handler (parameter : System.Address) is + S : Status; + begin + Count := Count + 1; + -- Acknowledge interrupt. Not necessary for all interrupts. + S := sysBusIntAck (intLevel => Level); + end Handler; + end P; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + with Ada.Text_IO; use Ada.Text_IO; + + with P; use P; + procedure Useint is + task T; + + S : Status; + + task body T is + begin + for I in 1 .. 10 loop + Put_Line ("Generating an interrupt..."); + delay 1.0; + + -- Generate interrupt, using interrupt number + S := sysBusIntGen (Level, Interrupt); + end loop; + end T; + + -- Save old handler + Old_Handler : VOIDFUNCPTR := intVecGet (INUM_TO_IVEC (Interrupt)); + begin + S := intConnect (INUM_TO_IVEC (Interrupt), Handler'Access); + S := sysIntEnable (intLevel => Level); + + for I in 1 .. 10 loop + delay 2.0; + Put_Line ("value of count:" & P.Count'Img); + end loop; + + -- Restore previous handler + S := sysIntDisable (intLevel => Level); + intVecSet (INUM_TO_IVEC (Interrupt), Old_Handler); + end Useint; + @end smallexample + + @item Direct Vectored Interrupt Routines + + @noindent + A variation on the direct vectored routine that allows for less restrictive + handler code is to separate the interrupt processing into two levels. + + The first level is the same as in the previous section. Here we perform + simple hardware actions and signal a task pending on a Suspension_Object + (defined in @code{Ada.Synchronous_Task_Control}) to perform the more complex + and time-consuming operations. The routine @code{Set_True} signals a task + whose body loops and pends on the suspension object using @code{Suspend_Until_True}. + The suspension object is declared in a scope global to both the handler and + the task. This approach can be thought of as a slightly higher-level + application of the @code{C} example using a binary semaphore given in the + VxWorks Programmer's Manual. In fact, the implementation of + @code{Ada.Synchronous_Task_Control} is a very thin wrapper around a VxWorks + binary semaphore. + + This approach has a latency between the direct vectored approach and the + protected procedure approach. There are no restrictions in the Ada task + code, while the handler code has the same restrictions as any other + direct interrupt handler. + + Example: + + @smallexample + with System; + package Sem_Handler is + + Count : Natural := 0; + pragma Atomic (Count); + + -- Interrupt level used by this example + Level : constant := 1; + Interrupt : constant := 16#14#; + + -- Interrupt handler providing "immediate" handling + procedure Handler (Param : System.Address); + + -- Task whose body provides "deferred" handling + task Receiver is + pragma Interrupt_Priority + (System.Interrupt_Priority'First + Level + 1); + end Receiver; + + end Sem_Handler; + + with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control; + with Interfaces.VxWorks; use Interfaces.VxWorks; + package body Sema_Handler is + + SO : Suspension_Object; + + task body Receiver is + begin + loop + -- Wait for notification from immediate handler + Suspend_Until_True (SO); + + -- Interrupt processing + Count := Count + 1; + end loop; + end Receiver; + + procedure Handler (Param : System.Address) is + S : STATUS; + begin + -- Hardware cleanup, if necessary + S := sysBusIntAck (Level); + + -- Signal the task + Set_True (SO); + end Handler; + + end Sem_Handler; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + with Ada.Text_IO; use Ada.Text_IO; + with Sem_Handler; use Sem_Handler; + procedure Useint is + + S : STATUS; + + task T; + + task body T is + begin + for I in 1 .. 10 loop + Put_Line ("Generating an interrupt..."); + delay 1.0; + + -- Generate interrupt, using interrupt number + S := sysBusIntGen (Level, Interrupt); + end loop; + end T; + + -- Save old handler + Old_Handler : VOIDFUNCPTR := intVecGet (INUM_TO_IVEC (Interrupt)); + begin + S := intConnect (INUM_TO_IVEC (Interrupt), Handler'Access); + S := sysIntEnable (intLevel => Level); + + for I in 1 .. 10 loop + delay 2.0; + Put_Line ("value of Count:" & Sem_Handler.Count'Img); + end loop; + + -- Restore handler + S := sysIntDisable (intLevel => Level); + intVecSet (INUM_TO_IVEC (Interrupt), Old_Handler); + abort Receiver; + end Useint; + @end smallexample + + @item Protected Procedure Handlers for Interrupts + + @noindent + This is the recommended default mechanism for interrupt handling. + It essentially wraps the hybrid handler / task mechanism in a higher-level + abstraction, and provides a good balance between latency and capability. + + Vectored interrupts are designated by their interrupt number, starting from + 0 and ranging to the number of entries in the interrupt vector table - 1. + + In the GNAT VxWorks implementation, the following priority mappings are used: + @itemize @bullet + @item Normal task priorities are in the range 0 .. 245. + @item Interrupt priority 246 is used by the GNAT @code{Interrupt_Manager} + task. + @item Interrupt priority 247 is used for vectored interrupts + that do not correspond to those generated via an interrupt controller. + @item Interrupt priorities 248 .. 255 correspond to PIC interrupt levels + 0 .. 7. + @item Priority 256 is reserved to the VxWorks kernel. + @end itemize + + Except for reserved priorities, the above are recommendations for setting the + ceiling priority of a protected object that handles interrupts, or the + priority of a task with interrupt entries. It's a very good idea to follow + these recommendations for vectored interrupts that come in through the PIC + as it will determine the priority of execution of the code in the protected + procedure or interrupt entry. + + No vectored interrupt numbers are reserved in this implementation, because + dedicated interrupts are determined by the board support package. Obviously, + careful consideration of the hardware is necessary when handling interrupts. + The VxWorks BSP for the board is the definitive reference for interrupt + assignments. + + Example: + + @smallexample + package PO_Handler is + + -- Interrupt level used by this example + Level : constant := 1; + + Interrupt : constant := 16#14#; + + protected Protected_Handler is + procedure Handler; + pragma Attach_Handler (Handler, Interrupt); + + function Count return Natural; + + pragma Interrupt_Priority (248); + private + The_Count : Natural := 0; + end Protected_Handler; + + end PO_Handler; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + package body PO_Handler is + + protected body Protected_Handler is + + procedure Handler is + S : Status; + begin + -- Hardware cleanup if necessary + S := sysBusIntAck (Level); + + -- Interrupt processing + The_Count := The_Count + 1; + end Handler; + + function Count return Natural is + begin + return The_Count; + end Count; + end Protected_Handler; + + end PO_Handler; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + with Ada.Text_IO; use Ada.Text_IO; + + with PO_Handler; use PO_Handler; + procedure Useint is + + task T; + + S : STATUS; + + task body T is + begin + for I in 1 .. 10 loop + Put_Line ("Generating an interrupt..."); + delay 1.0; + + -- Generate interrupt, using interrupt number + S := sysBusIntGen (Level, Interrupt); + end loop; + end T; + + begin + S := sysIntEnable (intLevel => Level); + + for I in 1 .. 10 loop + delay 2.0; + Put_Line ("value of count:" & Protected_Handler.Count'Img); + end loop; + + S := sysIntDisable (intLevel => Level); + end Useint; + @end smallexample + + @noindent + This is obviously significantly higher-level and easier to write than the + previous examples. + + @item Ada 83 Style Interrupt Entries + + GNAT provides a full implementation of the Ada 83 interrupt entry mechanism + for vectored interrupts. However, due to latency issues, + we only recommend using these for backward compatibility. The comments in + the previous section regarding interrupt priorities and reserved interrupts + apply here. + + In order to associate an interrupt with an entry, GNAT provides the + standard Ada convenience routine @code{Ada.Interrupts.Reference}. It is used + as follows: + + @smallexample + Interrupt_Address : constant System.Address := + Ada.Interrupts.Reference (Int_Num); + + task Handler_Task is + pragma Interrupt_Priority (248); -- For instance + entry Handler; + for Handler'Address use Interrupt_Address; + end Handler_Task; + @end smallexample + + @noindent + Since there is no restriction within an interrupt entry on blocking operations, + be sure to perform any hardware interrupt controller related operations before + executing a call that could block within the entry's accept statements. It + is assumed that interrupt entries are always open alternatives when they + appear within a selective wait statement. The presence of a guard gives + undefined behavior. + + Example: + + @smallexample + with Ada.Interrupts; + with System; + package Task_Handler is + + -- Interrupt level used by this example + Level : constant := 1; + + Interrupt : constant := 16#14#; + + Interrupt_Address : constant System.Address := + Ada.Interrupts.Reference (Int_Num); + + task Handler_Task is + pragma Interrupt_Priority (248); -- For instance + entry Handler; + for Handler'Address use Interrupt_Address; + + entry Count (Value : out Natural); + end Handler_Task; + end Task_Handler; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + package body Task_Handler is + + task body Handler_Task is + The_Count : Natural := 0; + S : STATUS; + begin + loop + select + accept Handler do + -- Hardware cleanup if necessary + S := sysBusIntAck (Level); + + -- Interrupt processing + The_Count := The_Count + 1; + end Handler; + or + accept Count (Value : out Natural) do + Value := The_Count; + end Count; + end select; + end loop; + end Handler_Task; + + end Handler_Task; + + with Interfaces.VxWorks; use Interfaces.VxWorks; + with Ada.Text_IO; use Ada.Text_IO; + + with Handler_Task; use Handler_Task; + procedure Useint is + + task T; + + S : STATUS; + Current_Count : Natural := 0; + + task body T is + begin + for I in 1 .. 10 loop + Put_Line ("Generating an interrupt..."); + delay 1.0; + + -- Generate interrupt, using interrupt number + S := sysBusIntGen (Level, Interrupt); + end loop; + end T; + + begin + S := sysIntEnable (intLevel => Level); + + for I in 1 .. 10 loop + delay 2.0; + Handler_Task.Count (Current_Count); + Put_Line ("value of count:" & Current_Count'Img); + end loop; + + S := sysIntDisable (intLevel => Level); + abort Handler_Task; + end Useint; + @end smallexample + @end itemize + + + @node Simulating Command Line Arguments for VxWorks + @section Simulating Command Line Arguments for VxWorks + + @noindent + The GNAT implementation of @code{Ada.Command_Line} relies on the standard C + symbols @code{argv} and @code{argc}. The model for invoking "programs" under + VxWorks does not provide these symbols. The typical method for invoking a + program under VxWorks is to call the @code{sp} function in order to spawn a + thread in which to execute a designated function (in GNAT, this is the implicit + main generated by gnatbind. @code{sp} provides the capability to push a variable + number of arguments onto the stack when the function is invoked. But this does + not work for the implicit Ada main, because it has no way of knowing how many + arguments might be required. This eliminates the possibility to use + @code{Ada.Command_Line}. + + One way to solve this problem is to define symbols in the VxWorks environment, + then import them into the Ada application. For example, we could define the + following package that imports two symbols, one an int and the other a string: + + @smallexample + with Interfaces.C.Strings; + use Interfaces.C.Strings; + package Args is + -- Define and import a variable for each argument + Int_Arg : Interfaces.C.Int; + String_Arg : Chars_Ptr; + private + pragma Import (C, Int_Arg, "intarg"); + pragma Import (C, String_Arg, "stringarg"); + end Args; + @end smallexample + + @noindent + An Ada unit could then use the two imported variables @code{Int_Arg} and + @code{String_Arg} as follows: + + @smallexample + with Args; use Args; + with Interfaces.C.Strings; + use Interfaces.C, Interfaces.C.Strings; + with Ada.Text_IO; use Ada.Text_IO; + procedure Argtest is + begin + Put_Line (Int'Image (Int_Arg)); + Put_Line (Value (String_Arg)); + end Argtest; + @end smallexample + + @noindent + When invoking the application from the shell, one will then set the values + to be imported, and spawn the application, as follows: + + @smallexample + -> intarg=10 + -> stringarg="Hello" + -> sp (argtest) + @end smallexample + + + @node Debugging Issues for VxWorks + @section Debugging Issues for VxWorks + + @noindent + The debugger can be launched directly from the Tornado environment or from @code{glide} + through its graphical interface: @code{gvd}. It can also be used + directly in text mode as shown below: + @noindent + The command to run @code{GDB} in text mode is + + @smallexample + $ @i{target}-gdb + @end smallexample + + @noindent + where @i{target} is the name of target of the cross GNAT + compiler. In contrast with native @code{gdb}, it is not useful to give the name of + the program to debug on the command line. Before starting a debugging + session, one needs to connect to the VxWorks-configured board and load + the relocatable object produced by @code{gnatlink}. This can be achieved + by the following commands: + + @smallexample + (vxgdb) target wtx myboard + (vxgdb) load program + @end smallexample + + @noindent + where @code{myboard} is the host name or IP number of the target board, and + @code{wtx} is the name of debugging protocol used to communicate + with the VxWorks board. Early versions of VxWorks, up tp 5.2, only + support the @code{} protocol whereas starting with VxWorks 5.3 + and Tornado, another protocol called @code{} was made available. The + choice of the protocol can be made when configuring the VxWorks + kernel itself. When available, the @code{} is greatly preferable + and actually the only supported protocol with GNAT. When the debugger + is launched directly from Tornado, the proper @code{target} command + is automatically generated by the environment. + + The GNAT debugger can be used for debugging multitasking programs in two + different modes and some minimal understanding of these modes is + necessary in order to use the debugger effectively. The two modes are: + + @itemize @bullet + @item Monotask mode: attach to, and debug, a single task. + This mode is equivalent to the capabilities offered by CrossWind. The + debugger interacts with a single task, while not affecting other tasks + (insofar as possible). This is the DEFAULT mode. + + @item Multitask mode: + The debugger has control over all Ada tasks in an application. It is + possible to gather information about all application tasks, and to + switch from one to another within a single debugging session. + @end itemize + + @noindent + It is not advised to switch between the two modes within a debugging + session. A third mode called System mode is also available and can be + used in place of the Multitask mode. Consult the Tornado documentation + for this. + + Among the criteria for selecting the appropriate mode is the effect of + task synchronization on the application's behavior. Debugging a + tasking application affects the timing of the application; minimizing + such effects may be critical in certain situations. The two modes have + different effects: monotask mode only affects the attached task: + others will run normally (if possible). Multitask mode stops all tasks + at each breakpoint and restarts them on single-step, next, finish or + continue; this may help avoid deadlocks in the presence of task + synchronization despite the inherent latency of stopping and + restarting the tasks. + + @subsection Using the debugger in monotask mode + + @noindent + There are two ways to begin your debugging session: + + @itemize @bullet + @item The program is already running on the board. + + @noindent + The sequence of commands to use this mode is: + @itemize @bullet + @item Launch GVD (possibly from the Tornado menu) + + @noindent + Verify that the debugger has access to the debug information of both + your program and the kernel. The Console window should have a message + "Looking for all loaded modules:" followed by the names of the modules + on the board and "ok". If you have some error messages here instead of + "ok", the debugging session may not work as expected. + + @item Attach to the desired task using + @smallexample + File --> Attach... + @end smallexample + @noindent + This task is stopped by the debugger. Other tasks continue to operate + normally (unless they are blocked by synchronization with the stopped + task). The source window should display the code on which the task has + been stopped, and if the stack display is enabled, it should reflect + the stack of the task. + @end itemize + + @item The program hasn't been loaded yet on the board + @itemize @bullet + @item Launch GVD (possibly from the Tornado menu) + @item Load your program to the board: + @smallexample + File --> Open Program... + @end smallexample + + @noindent + GVD should display: + @smallexample + Downloading your_program ...done. + Reading symbols from your_program...expanding to full symbols...done. + @end smallexample + + @item Set breakpoints in your program. + + @noindent + WARNING: they must be set in the main task (if your program runs + several tasks) + + @item Run your program using one of the three methods below: + @itemize @bullet + @item + Click on button or + + @item Menu + @smallexample + Program --> Run/Start + @end smallexample + + @item + Type in GVD's Console window + @smallexample + (gdb) run your_program + @end smallexample + @end itemize + @end itemize + + @item Whichever method you chose to start your debugging session, + you can use the following commands at this point: + @itemize @bullet + @item Browse sources and set breakpoints + @item Examine the call stack (Data --> call stack) + @item Go "up" and "down" in the call stack ("up" & "down" buttons) + @item Examine data + (Data --> Display local variables, or any of the other methods for viewing data in GVD) + @item Continue/finish + @end itemize + + Next/step/finish will only work if the top frame in the call stack has + debug information. This is almost never the case when first attaching + to the task since the task is usually stopped by the attach operation + in the GNAT runtime. You can verify which frames of the call stack + have debug information by: + @smallexample + Data --> call stack + (contextual menu inside the call stack window) + add "file location" + @end smallexample + + @noindent + If the current frame does not have a "file location", then there is no + debug information for the frame. We strongly recommended that you set + breakpoints in the source where debug information can be found and + "continue" until a breakpoint is reached before using + "next/step". Another convenient possibility is to use the "continue + until" capability available from the contextual menu of the Source + window. + + You can also examine the state of other tasks using + @smallexample + Data -> tasks + @end smallexample + + @noindent + but you can't "switch" to another task by clicking on the + elements of the task list. If you try to, you will get an error + message in GVD's console: + @smallexample + "Task switching is not allowed when multi-tasks mode is not active" + @end smallexample + + @noindent + Once you have completed your debugging session on the attached + task, you can detach from the task: + @smallexample + File --> detach + @end smallexample + + @noindent + The task resumes normal execution at this stage. WARNING: when you + detach from a task, be sure that you are in a frame where there is + debug information. Otherwise, the task won't resume properly. You can + then start another attach/detach cycle if you wish. + + Note that it is possible to launch several GVD sessions and + simultaneously attach each to a distinct task in monotask mode: + @smallexample + File --> New Debugger... (uncheck the box: Replace Current Debugger) + File --> Attach... (in the new window) + File --> detach + @end smallexample + @end itemize + + + @subsection Using the debugger in Multitask mode + + @noindent + The steps are as follows + + @itemize @bullet + @item + Launch GVD (possibly from the Tornado menu) + + @noindent + There are two possibilities: + @itemize @bullet + @item + If the program is already loaded on the target board, you need only verify + that debug information has been found by the debugger as described + above. + + @item + Otherwise, load the program on the board using + @smallexample + File --> Open program + @end smallexample + @end itemize + + @item Set breakpoints in the desired parts of the program + + @item Start the program + + @noindent + The simplest way to start the debugger in multitask mode is to use the + menu + @smallexample + Program --> Run/Start + @end smallexample + + @noindent + and check the box "enable vxWorks multi-tasks mode". + You can also use the following gdb commands in the console window + @smallexample + (gdb) set multi-tasks-mode on + (gdb) run your_program + @end smallexample + + @item Debug the stopped program + + @noindent + Once stopped at a breakpoint + (or if you pressed the "stop" button), you can use all the standard + commands listed for monotask mode + task switching (using Data --> + tasks). Using next/step under this mode is possible with the same + restrictions as for monotask mode, but is not recommended because all + tasks are restarted, leading to the possibility that a different task + hits a breakpoint before the stepping operation has completed. Such + an occurrence can result in a confusing state for both the user and + the debugger. So we strongly suggest the use of only breakpoints and + "continue" in this mode. + @end itemize + + A final reminder: whatever the mode, whether you are debugging or not, + the program has to be reloaded before each new execution, so that data + initialized by the loader is set correctly. For instance, if you wish + to restart the same execution of the same program, you can use the + following sequence of gdb commands in the console window: + @smallexample + (gdb) detach + (gdb) unload your_program(.exe) + (gdb) load your_program(.exe) + (gdb) run your_program + @end smallexample + + + @node Using GNAT from the Tornado 2 Project Facility + @section Using GNAT from the Tornado 2 Project Facility + @cindex Tornado II Project + + @menu + * The GNAT Toolchain as Used from the Tornado 2 Project Facility:: + * Building a Simple Application:: + * Mixing C and Ada Code in a Tornado 2 Project:: + * Compilation Switches:: + * Autoscale and Minimal Kernel Configuration:: + * Adapting BSPs to GNAT:: + * Using GNAT Project Files in a Tornado 2 Project:: + @end menu + + @noindent + This section describes how to add an Ada module in a Tornado project + using the Tornado 2 Project facility described in + @cite{Tornado User's Guide}, Chapter 4. + All recommendations apply for both 'Downloadable Modules' and 'Kernel' + project types. + + + @node The GNAT Toolchain as Used from the Tornado 2 Project Facility + @subsection The GNAT Toolchain as Used from the Tornado 2 Project Facility + + @noindent + Tornado 2 allows you to integrate third-party C toolchains. + (@cite{Tornado 2 API Programmer's Guide}, Chapter 7). + Thus the GNAT toolchain will be seen as a new C toolchain when used from + the Tornado 2 Project Facility. For each processor you can compile for, + you will find a gnat toolchain, e.g. PPC604gnat. These toolchains will + allow you to include Ada modules into your projects, and simply build them. + + The name of the so-called C compiler is @emph{cc_gnat_}, the name + of the 'linker' is @emph{ld_gnat_}, where is an architecture; e.g., + PPC. These scripts will call the correct executables during the compilation or + link processes, thus the C compiler, the C linker, or the GNAT toolchain, + depending on the context. + + + @node Building a Simple Application + @subsection Building a Simple Application + + @noindent + First, create a new project, using one of the gnat toolchains. + + To add an Ada source file to the current project, just click on + @code{Project -> Add/Include}, browse to the relevant file, and include it. + The Ada source file included should be the Ada entry point. Only + one Ada entry point is allowed in a project. Any other required Ada source + files will be automatically compiled and linked by the underlying tools. + + You can now compile the project, @code{Build->Rebuild all}. + A log of the compilation process can be found in the build directory, in + @file{gnatbuild.log}. It contains all the calls executed by the scripts, and + associated information. + + + @node Mixing C and Ada Code in a Tornado 2 Project + @subsection Mixing C and Ada Code in a Tornado 2 Project + + @noindent + You can mix C and Ada code in your projects. Your source files and the build + options should comply with the recommendations from the section + @cite{Interfacing to C}. + This means that you can have several or no C source files, and one or no Ada entry + point in your Tornado 2 Project. + + + @node Compilation Switches + @subsection Compilation Switches + @noindent + Once you have included all your source files, you may modify some compilation + and linking options. + To pass specific options to the GNAT toolchain, go to the Project's build + settings, on the @code{C/C++ Compiler} tab, and add your arguments in the + input window. + + You must comply with several rules to pass arguments to GNAT. + Arguments to be passed should be + + @itemize @bullet + + @item after any arguments passed to the C toolchain. + + @item prefixed depending on the tool that uses them, with the following syntax + + @itemize @bullet + @item @code{-cargs @emph{gnatmake-options}} to pass arguments to gnatmake + @item @code{-bargs @emph{gnatbind-options}} to pass arguments to gnatbind + @item @code{-largs @emph{gnatlink-options}} to pass arguments to gnatlink + @end itemize + @end itemize + + @noindent + You will find more information on the compilation process of Ada source files + in the section @cite{The GNAT Compilation Model}. + For a list of all available switches, refer to the sections describing + @code{gnatmake}, @code{gnatbind} and @code{gnatlink}. + + Here is an example that passes the option @code{-v} to the GNAT compiler : + @smallexample + -g -mstrict-align -prjtype $(PRJ_TYPE) -ansi -nostdinc -DRW_MULTI_THREAD -D_REENTRANT + -fvolatile -fno-builtin -fno-for-scope -I. -I/usr/windppc-2.0/target/h -DCPU=PPC604 + -cargs -v + @end smallexample + + @noindent + Here is an example that passes the option @code{-v} to the GNAT compiler, binder and linker, + and @code{-v} and @code{-g} to the compiler : + @smallexample + -g -mstrict-align -prjtype $(PRJ_TYPE) -ansi -nostdinc -DRW_MULTI_THREAD -D_REENTRANT + -fvolatile -fno-builtin -fno-for-scope -I. -I/usr/windppc-2.0/target/h -DCPU=PPC604 + -cargs -v -g -O2 -bargs -v -largs -v + @end smallexample + + @noindent + In both examples, the following arguments have been automatically added by the Project + Facility, and will be used by the C compiler. + @smallexample + -g -mstrict-align -prjtype $(PRJ_TYPE) -ansi -nostdinc -DRW_MULTI_THREAD -D_REENTRANT + -fvolatile -fno-builtin -fno-for-scope -I. -I/usr/windppc-2.0/target/h -DCPU=PPC604 + @end smallexample + + @noindent + Note: The @code{-prjtype $(PRJ_TYPE)} option present in a few input + boxes is used by the GNAT toolchain. It is required for the compilation + process. You should not remove it from any input box. + + + @node Autoscale and Minimal Kernel Configuration + @subsection Autoscale and Minimal Kernel Configuration + + @noindent + The Autoscale feature, present in the Project Facility can be used on your + VxWorks Kernel projects to determine the minimum set of components required + for your kernel to work. + (Please refer to the @cite{Tornado II User's Guide} Section 4.4 for more details.) + This feature is also available for projects involving Ada code. Just click on + @code{Project->Autoscale} to launch a check and determine the minimal kernel + configuration. + + + @node Adapting BSPs to GNAT + @subsection Adapting BSPs to GNAT + + @noindent + To use your Board Support Packages with the GNAT toolchain, you will have to adapt them, + either manually or using the @code{adaptbsp4gnat} script. + This procedure is described in the @cite{Tornado API Programmer's Guide}, + Chapter 7. + Here is a summary of this setup, depending on the context. + + @itemize @bullet + @item To do the adaptation manually: + + @itemize @bullet + + @item Copy your BSP directory contents into a new directory + + @item Go to this directory + + @item Edit the file @file{Makefile}, + + @itemize @bullet + @item Set tool to gnat, @code{TOOL=gnat} + + @item Reverse the order of the following lines + @itemize @bullet + @item @code{include $(TGT_DIR)/h/make/make.$(CPU)$(TOOL)} + @item @code{include $(TGT_DIR)/h/make/defs.$(WIND_HOST_TYPE)} + @end itemize + + @end itemize + + @end itemize + + @item To do the adaptation automatically, you may use the @code{adaptbsp4gnat} + script. Its syntax is @code{adaptbsp4gnat }. + + @noindent + This script follows the different steps described above to perform the + adaptation. + The name of the new bsp is given after the modification. By default, if + @file{} is the name of your BSP, @file{-gnat}, will be the name of + the BSP created. + @end itemize + + + @node Using GNAT Project Files in a Tornado 2 Project + @subsection Using GNAT Project Files in a Tornado 2 Project + + @noindent + You can use GNAT Project files to compile your Ada files. + To do so, you need to use the @option{-Pproject_file.gpr} option from @command{gnatmake}. + The path to the project file can be either absolute, or relative to the build + directory, i.e. where the executable will be placed (e.g. @file{~/myproject/PPC604gnat}). + Your project file should set the @code{Object_Dir} variable to a specific + value. + @smallexample + project Sample is + + Target := external ("TARGET_DIR"); + for Object_Dir use Target; + + end Sample; + @end smallexample + + + @node Frequently Asked Questions for VxWorks + @section Frequently Asked Questions for VxWorks + + @itemize @bullet + + @item + When I run my program twice on the board, it does not work, why? + + @noindent + Usually, Ada programs require elaboration and finalization, so the + compiler creates a wrapper procedure whose name is the same as the Ada + name of the main subprogram, which takes care of calling the elaboration + and finalization routines before and after your program. But the static + part of the elaboration is taken care of while loading the program + itself and thus if you launch it twice this part of the elaboration will + not be performed. This affects the proper elaboration of the + GNAT runtime and thus it is mandatory to reload your program before + relaunching it. + + @item + Can I load a collection of subprograms rather than a standalone program? + + @noindent + It is possible to write Ada programs with multiple entry points which + can be called from the VxWorks shell; you just need to consider your + main program as the VxWorks shell itself and generate an Ada subsystem + callable from outside @xref{Binding with Non-Ada Main Programs}. If you + use this method, you need to call @code{adainit} manually before calling + any Ada entry point. + + @item + When I use the @code{break exception} command, I get the message + @code{"exception" is not a function}, why? + + You are not in the proper language mode. Issue the command: + @smallexample + (vxgdb) set language ada + @end smallexample + + @item + When I load a large application from the VxWorks shell using the "ld" + command, the load hangs and never finishes. How can I load large + executables? + + This is a classic VxWorks problem when using the default "rsh" communication + method. Using NFS instead should work. Use the @code{nfsShowMount} command to + verify that your program is in a NFS mounted directory. + + @item + When I load a large application from the debugger using the wtx target + connection, the load never finishes, why? + + Make sure that the memory cache size parameter of the target server is + large enough. (@code{target -m big_enough_size}, or Memory cache size box in GUI.) + See @cite{Tornado 1.01 API Programming Guide}, Section 3.6.2. + + @item + When I spawn my program under the VxWorks shell, interactive input does + not work, why? + + Only programs directly launched from the shell can have interactive + input. For a program spawned with the @code{sp} or @code{taskSpawn} + command, you need to have file redirection for input: + @smallexample + -> # here you can have interactive input + -> main + -> # here you cannot + -> sp main + -> # neither here + -> taskSpawn("ess",100,0,8000000,main) + -> # but you can input from a file: + -> taskSpawn("Bae",100,0,8000000,main) < input_file + @end smallexample + @end itemize + + + @node LynxOS Topics + @chapter LynxOS Topics + @noindent + This chapter describes topics that are specific to the GNAT for LynxOS + cross configurations. + + @menu + * Getting Started with GNAT on LynxOS:: + * Kernel Configuration for LynxOS:: + * Patch Level Issues for LynxOS:: + * Debugging Issues for LynxOS:: + * An Example Debugging Session for LynxOS:: + @end menu + + @node Getting Started with GNAT on LynxOS + @section Getting Started with GNAT on LynxOS + + @noindent + This section is a starting point for using GNAT to develop and + execute Ada 95 programs for LynuxWorks' LynxOS target environment from a + Unix host environment. + We assume that you know how to use GNAT in a native environment + and how to start a telnet or other login session to connect to your LynxOS board. + + To compile code for a LynxOS system running on a PowerPC + board, the basic compiler command is + @command{powerpc-xcoff-lynxos-gcc}. + + With GNAT, the easiest way to build the basic @code{Hello World} program is + with @code{gnatmake}. For the LynxOS PowerPC target this would look + like: + + @smallexample + $ powerpc-xcoff-lynxos-gnatmake hello + @i{powerpc-xcoff-lynxos-gcc -c hello.adb + powerpc-xcoff-lynxos-gnatbind -x hello.ali + powerpc-xcoff-lynxos-gnatlink hello.ali} + @end smallexample + + @noindent + (The first line is the command entered by the user -- the subseqent three + are the programs run by @code{gnatmake}.) + + This creates the executable @command{hello}" which you then need to load on the + board (using ftp or an NFS directory for example) to run it. + + + @node Kernel Configuration for LynxOS + @section Kernel Configuration for LynxOS + + @noindent + The appropriate configuration for your LynxOS kernel depends + on the target system and the requirements of your application. GNAT itself + adds no additional demands; however in some situations it may be appropriate + to increase the conservative + resource assumptions made by the default configuration. + + Kernel parameters limiting the maximum number of file descriptors, + kernel and user threads, synchronization objects, etc., may be set in the + file @file{uparam.h}. You may also wish to modify the file + @file{/etc/starttab}, which places limits on data, stack, and core file + size. See the documentation provided by LynuxWorks for more information. + + + @node Patch Level Issues for LynxOS + @section Patch Level Issues for LynxOS + + @noindent + The GNAT runtime requires that your system run at patch level 040 or + later. Please see the file @file{PatchCompatibility.txt} from the + distribution for more information. + + + @node Debugging Issues for LynxOS + @section Debugging Issues for LynxOS + + @noindent + GNAT's debugger is based on the same GNU gdb technology as the debugger + provided by LynxOS, though with a great number of extensions and + enhancements to support the Ada language and GNAT. The LynxOS + documentation is relevant to understanding how to get the debugger + started if you run into difficulties. + + To demonstrate a debugging session, we will use a slightly more complex + program called @file{demo1.adb}, which can be found in the @file{examples} + directory of the GNAT distribution. This program is compiled with + debugging information as follows: + + @smallexample + $ powerpc-xcoff-lynxos-gnatmake -g demo1 + powerpc-xcoff-lynxos-gcc -c -g demo1.adb + powerpc-xcoff-lynxos-gcc -c -g gen_list.adb + powerpc-xcoff-lynxos-gcc -c -g instr.adb + powerpc-xcoff-lynxos-gnatbind -x demo1.ali + powerpc-xcoff-lynxos-gnatlink -g demo1.ali + @end smallexample + + @noindent + Once the executable is created, copy it to your working directory on the + board. In this directory, you will have to launch the gdb server and + choose a free port number on your TCP/IP socket. Presuming the Internet + hostname of the board is @file{myboard} and the port chosen is 2345, + issue the following command: + + @smallexample + myboard> gdbserver myboard:2345 demo1 + @end smallexample + + @noindent + Then return to your host environment. + + The graphical debugger interface, @command{gvd}, supports both native + and cross environments at the same time. @command{gvd} can be launched from + @command{Glide} (see @file{README.Glide} for more information on customizing + @command{Glide} for LynxOS) or it can be launched from the command line as + follows: + + @smallexample + $ gvd --debugger powerpc-xcoff-lynxos-gdb + @end smallexample + + @noindent + Then to attach to the target, enter in @command{gvd}'s command line window: + + @smallexample + (gdb) target remote myboard:2345 + @end smallexample + + @noindent + For more information see the GVD documentation. + + The comments below concern debugging directly from the command line but + they also apply to @command{gvd}, though in most cases an equivalent + graphical command is also available. + + To run the cross debugger from the command line without the visual + interface use the command @code{powerpc-xcoff-lynxos-gdb}. + + You will see something like: + + @smallexample + GNU gdb 4.17.gnat.3.14a1 + Copyright 1998 Free Software Foundation, Inc. + GDB is free software, covered by the GNU General Public License, and you are + welcome to change it and/or distribute copies of it under certain conditions. + Type "show copying" to see the conditions. + There is absolutely no warranty for GDB. Type "show warranty" for details. + This GDB was configured as "--host=sparc-sun-solaris2.5.1 --target=powerpc-xc + off-lynxos". + (gdb) + @end smallexample + + @noindent + Where @command{(gdb)} is the debugger's prompt. The first thing to do at the + prompt from within @command{gdb} is to load the symbol table from the + executable: + + @smallexample + (gdb) file demo1 + Reading symbols from demo1...done. + (gdb) + @end smallexample + + @noindent + You then have to attach to the server running on the board. Issue the command: + + @smallexample + (gdb) target remote myboard:2345 + @end smallexample + + @noindent + After the server has been started and attached from the host, the program is + running on the target but has halted execution at the very beginning. + The following commands set a breakpoint and continue execution: + + @smallexample + (gdb) break demo1.adb:37 + Breakpoint 1 at 0x100064d0: file demo1.adb, line 37. + (gdb) cont + Continuing. + + Breakpoint 1, demo1 () at demo1.adb:37 + 37 Set_Name (Fuel, "Fuel"); + (gdb) + @end smallexample + + @noindent + Here the execution has stopped at the breakpoint set above. Now + you can use the standard @code{gdb} commands to examine the stack and + program variables. + + Note that once execution has completed, the server on the board must be + restarted before a new debugging session may begin. + + @node An Example Debugging Session for LynxOS + @section An Example Debugging Session for LynxOS + + @noindent + Carrying on a little further with the debugging session, the following + example illustrates some of the usual debugging commands for moving + around and seeing where you are: + + @smallexample + (gdb) next + 38 Set_Name (Water, "Water"); + (gdb) bt + #0 demo1 () at demo1.adb:38 + #1 0x10001218 in main (argc=1, argv=2147483640, envp=2147483520) at + b~demo1.adb:118 + #2 0x10017538 in runmainthread () + #3 0x10001048 in __start () + (gdb) up + #1 0x10001218 in main (argc=1, argv=2147483640, envp=2147483520) at + b~demo1.adb:118 + 118 Ada_Main_Program; + (gdb) down + #0 demo1 () at demo1.adb:38 + 38 Set_Name (Water, "Water"); + (gdb) + @end smallexample + + @noindent + To examine and modify variables (of a tagged type here): + + @smallexample + (gdb) print speed + $1 = (name => "Speed ", value => -286331154) + (gdb) ptype speed + type = new instr.instrument with record + value: instr.speed; + end record + (gdb) speed.value := 3 + $2 = 3 + (gdb) print speed + $3 = (name => "Speed ", value => 3) + (gdb) info local + speed = (name => "Speed ", value => 3) + fuel = (name => "Fuel ", value => -286331154) + oil = (name => ' ' , value => -286331154, size => 20, + fill => 42 '*', empty => 46 '.') + water = (name => ' ' , value => -286331154, size => 20, + fill => 42 '*', empty => 46 '.') + time = (name => ' ' , seconds => 0, minutes => 0, hours => + 0) + chrono = (name => ' ' , seconds => 0, minutes => 0, + hours => 0) + db = (access demo1.dash_board.internal) 0x0 + (gdb) + @end smallexample + + @noindent + And finally letting the program it run to completion: + + @smallexample + (gdb) c + Continuing. + + Program exited normally. + (gdb) + @end smallexample + + + @node Performance Considerations + @chapter Performance Considerations + @cindex Performance + + @noindent + The GNAT system provides a number of options that allow a trade-off + between + + @itemize @bullet + @item + performance of the generated code + + @item + speed of compilation + + @item + minimization of dependences and recompilation + + @item + the degree of run-time checking. + @end itemize + + @noindent + The defaults (if no options are selected) aim at improving the speed + of compilation and minimizing dependences, at the expense of performance + of the generated code: + + @itemize @bullet + @item + no optimization + + @item + no inlining of subprogram calls + + @item + all run-time checks enabled except overflow and elaboration checks + @end itemize + + @noindent + These options are suitable for most program development purposes. This + chapter describes how you can modify these choices, and also provides + some guidelines on debugging optimized code. + + @menu + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + @end menu + + @node Controlling Run-Time Checks + @section Controlling Run-Time Checks + + @noindent + By default, GNAT generates all run-time checks, except arithmetic overflow + checking for integer operations and checks for access before elaboration on + subprogram calls. The latter are not required in default mode, because all + necessary checking is done at compile time. + @cindex @option{-gnatp} (@code{gcc}) + @cindex @option{-gnato} (@code{gcc}) + Two gnat switches, @option{-gnatp} and @option{-gnato} allow this default to + be modified. @xref{Run-Time Checks}. + + Our experience is that the default is suitable for most development + purposes. + + We treat integer overflow specially because these + are quite expensive and in our experience are not as important as other + run-time checks in the development process. Note that division by zero + is not considered an overflow check, and divide by zero checks are + generated where required by default. + + Elaboration checks are off by default, and also not needed by default, since + GNAT uses a static elaboration analysis approach that avoids the need for + run-time checking. This manual contains a full chapter discussing the issue + of elaboration checks, and if the default is not satisfactory for your use, + you should read this chapter. + + For validity checks, the minimal checks required by the Ada Reference + Manual (for case statements and assignments to array elements) are on + by default. These can be suppressed by use of the @option{-gnatVn} switch. + Note that in Ada 83, there were no validity checks, so if the Ada 83 mode + is acceptable (or when comparing GNAT performance with an Ada 83 compiler), + it may be reasonable to routinely use @option{-gnatVn}. Validity checks + are also suppressed entirely if @option{-gnatp} is used. + + @cindex Overflow checks + @cindex Checks, overflow + @findex Suppress + @findex Unsuppress + @cindex pragma Suppress + @cindex pragma Unsuppress + Note that the setting of the switches controls the default setting of + the checks. They may be modified using either @code{pragma Suppress} (to + remove checks) or @code{pragma Unsuppress} (to add back suppressed + checks) in the program source. + + @node Optimization Levels + @section Optimization Levels + @cindex @code{-O} (@code{gcc}) + + @noindent + The default is optimization off. This results in the fastest compile + times, but GNAT makes absolutely no attempt to optimize, and the + generated programs are considerably larger and slower than when + optimization is enabled. You can use the + @code{-O@var{n}} switch, where @var{n} is an integer from 0 to 3, + on the @code{gcc} command line to control the optimization level: + + @table @code + @item -O0 + no optimization (the default) + + @item -O1 + medium level optimization + + @item -O2 + full optimization + + @item -O3 + full optimization, and also attempt automatic inlining of small + subprograms within a unit (@pxref{Inlining of Subprograms}). + @end table + + Higher optimization levels perform more global transformations on the + program and apply more expensive analysis algorithms in order to generate + faster and more compact code. The price in compilation time, and the + resulting improvement in execution time, + both depend on the particular application and the hardware environment. + You should experiment to find the best level for your application. + + Note: Unlike some other compilation systems, @code{gcc} has + been tested extensively at all optimization levels. There are some bugs + which appear only with optimization turned on, but there have also been + bugs which show up only in @emph{unoptimized} code. Selecting a lower + level of optimization does not improve the reliability of the code + generator, which in practice is highly reliable at all optimization + levels. + + Note regarding the use of @code{-O3}: The use of this optimization level + is generally discouraged with GNAT, since it often results in larger + executables which run more slowly. See further discussion of this point + in @pxref{Inlining of Subprograms}. + + @node Debugging Optimized Code + @section Debugging Optimized Code + + @noindent + Since the compiler generates debugging tables for a compilation unit before + it performs optimizations, the optimizing transformations may invalidate some + of the debugging data. You therefore need to anticipate certain + anomalous situations that may arise while debugging optimized code. This + section describes the most common cases. + + @enumerate + @item + @i{The "hopping Program Counter":} Repeated 'step' or 'next' commands show the PC + bouncing back and forth in the code. This may result from any of the following + optimizations: + + @itemize @bullet + @item + @i{Common subexpression elimination:} using a single instance of code for a + quantity that the source computes several times. As a result you + may not be able to stop on what looks like a statement. + + @item + @i{Invariant code motion:} moving an expression that does not change within a + loop, to the beginning of the loop. + + @item + @i{Instruction scheduling:} moving instructions so as to + overlap loads and stores (typically) with other code, or in + general to move computations of values closer to their uses. Often + this causes you to pass an assignment statement without the assignment + happening and then later bounce back to the statement when the + value is actually needed. Placing a breakpoint on a line of code + and then stepping over it may, therefore, not always cause all the + expected side-effects. + @end itemize + + @item + @i{The "big leap":} More commonly known as @i{cross-jumping}, in which two + identical pieces of code are merged and the program counter suddenly + jumps to a statement that is not supposed to be executed, simply because + it (and the code following) translates to the same thing as the code + that @emph{was} supposed to be executed. This effect is typically seen in + sequences that end in a jump, such as a @code{goto}, a @code{return}, or + a @code{break} in a C @code{switch} statement. + + @item + @i{The "roving variable":} The symptom is an unexpected value in a variable. + There are various reasons for this effect: + + @itemize @bullet + @item + In a subprogram prologue, a parameter may not yet have been moved to its + "home". + + @item + A variable may be dead, and its register re-used. This is + probably the most common cause. + + @item + As mentioned above, the assignment of a value to a variable may + have been moved. + + @item + A variable may be eliminated entirely by value propagation or + other means. In this case, GCC may incorrectly generate debugging + information for the variable + @end itemize + + @noindent + In general, when an unexpected value appears for a local variable or parameter + you should first ascertain if that value was actually computed by + your program, as opposed to being incorrectly reported by the debugger. + Record fields or + array elements in an object designated by an access value + are generally less of a problem, once you have ascertained that the access value + is sensible. + Typically, this means checking variables in the preceding code and in the + calling subprogram to verify that the value observed is explainable from other + values (one must apply the procedure recursively to those + other values); or re-running the code and stopping a little earlier + (perhaps before the call) and stepping to better see how the variable obtained + the value in question; or continuing to step @emph{from} the point of the + strange value to see if code motion had simply moved the variable's + assignments later. + @end enumerate + + @node Inlining of Subprograms + @section Inlining of Subprograms + + @noindent + A call to a subprogram in the current unit is inlined if all the + following conditions are met: + + @itemize @bullet + @item + The optimization level is at least @code{-O1}. + + @item + The called subprogram is suitable for inlining: It must be small enough + and not contain nested subprograms or anything else that @code{gcc} + cannot support in inlined subprograms. + + @item + The call occurs after the definition of the body of the subprogram. + + @item + @cindex pragma Inline + @findex Inline + Either @code{pragma Inline} applies to the subprogram or it is + small and automatic inlining (optimization level @code{-O3}) is + specified. + @end itemize + + @noindent + Calls to subprograms in @code{with}'ed units are normally not inlined. + To achieve this level of inlining, the following conditions must all be + true: + + @itemize @bullet + @item + The optimization level is at least @code{-O1}. + + @item + The called subprogram is suitable for inlining: It must be small enough + and not contain nested subprograms or anything else @code{gcc} cannot + support in inlined subprograms. + + @item + The call appears in a body (not in a package spec). + + @item + There is a @code{pragma Inline} for the subprogram. + + @item + @cindex @option{-gnatn} (@code{gcc}) + The @code{-gnatn} switch + is used in the @code{gcc} command line + @end itemize + + Note that specifying the @option{-gnatn} switch causes additional + compilation dependencies. Consider the following: + + @smallexample + @group + @cartouche + @b{package} R @b{is} + @b{procedure} Q; + @b{pragma} Inline (Q); + @b{end} R; + @b{package body} R @b{is} + ... + @b{end} R; + + @b{with} R; + @b{procedure} Main @b{is} + @b{begin} + ... + R.Q; + @b{end} Main; + @end cartouche + @end group + @end smallexample + + @noindent + With the default behavior (no @option{-gnatn} switch specified), the + compilation of the @code{Main} procedure depends only on its own source, + @file{main.adb}, and the spec of the package in file @file{r.ads}. This + means that editing the body of @code{R} does not require recompiling + @code{Main}. + + On the other hand, the call @code{R.Q} is not inlined under these + circumstances. If the @option{-gnatn} switch is present when @code{Main} + is compiled, the call will be inlined if the body of @code{Q} is small + enough, but now @code{Main} depends on the body of @code{R} in + @file{r.adb} as well as on the spec. This means that if this body is edited, + the main program must be recompiled. Note that this extra dependency + occurs whether or not the call is in fact inlined by @code{gcc}. + + The use of front end inlining with @option{-gnatN} generates similar + additional dependencies. + + @cindex @code{-fno-inline} (@code{gcc}) + Note: The @code{-fno-inline} switch + can be used to prevent + all inlining. This switch overrides all other conditions and ensures + that no inlining occurs. The extra dependences resulting from + @option{-gnatn} will still be active, even if + this switch is used to suppress the resulting inlining actions. + + Note regarding the use of @code{-O3}: There is no difference in inlining + behavior between @code{-O2} and @code{-O3} for subprograms with an explicit + pragma @code{Inline} assuming the use of @option{-gnatn} + or @option{-gnatN} (the switches that activate inlining). If you have used + pragma @code{Inline} in appropriate cases, then it is usually much better + to use @code{-O2} and @option{-gnatn} and avoid the use of @code{-O3} which + in this case only has the effect of inlining subprograms you did not + think should be inlined. We often find that the use of @code{-O3} slows + down code by performing excessive inlining, leading to increased instruction + cache pressure from the increased code size. So the bottom line here is + that you should not automatically assume that @code{-O3} is better than + @code{-O2}, and indeed you should use @code{-O3} only if tests show that + it actually improves performance. + + + @include fdl.texi + @c GNU Free Documentation License + + @node Index,,GNU Free Documentation License, Top + @unnumbered Index + + @printindex cp + + @contents + + @bye diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_ug_wnt.info gcc-3.3/gcc/ada/gnat_ug_wnt.info *** gcc-3.2.3/gcc/ada/gnat_ug_wnt.info 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_ug_wnt.info 2003-05-14 00:31:43.000000000 +0000 *************** *** 0 **** --- 1,19316 ---- + This is ada/gnat_ug_wnt.info, produced by makeinfo version 4.2 from + ada/gnat_ug_wnt.texi. + + Copyright (C) 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT User's Guide for Windows NT", and with no + Back-Cover Texts. A copy of the license is included in the section + entitled "GNU Free Documentation License". +  + File: gnat_ug_wnt.info, Node: Top, Next: About This Guide, Prev: (dir), Up: (dir) + + GNAT User's Guide + ***************** + + GNAT User's Guide for Windows NT + + GNAT, The GNU Ada 95 Compiler + + GNAT Version for GCC 3.3 + + Ada Core Technologies, Inc. + + Copyright (C) 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 or + any later version published by the Free Software Foundation; with the + Invariant Sections being "GNU Free Documentation License", with the + Front-Cover Texts being "GNAT User's Guide for Windows NT", and with no + Back-Cover Texts. A copy of the license is included in the section + entitled "GNU Free Documentation License". + * Menu: + + * About This Guide:: + * Getting Started with GNAT:: + * The GNAT Compilation Model:: + * Compiling Using gcc:: + * Binding Using gnatbind:: + * Linking Using gnatlink:: + * The GNAT Make Program gnatmake:: + * Renaming Files Using gnatchop:: + * Configuration Pragmas:: + * Handling Arbitrary File Naming Conventions Using gnatname:: + * GNAT Project Manager:: + * Elaboration Order Handling in GNAT:: + * The Cross-Referencing Tools gnatxref and gnatfind:: + * File Name Krunching Using gnatkr:: + * Preprocessing Using gnatprep:: + * The GNAT Library Browser gnatls:: + * GNAT and Libraries:: + * Using the GNU make Utility:: + * Finding Memory Problems with gnatmem:: + * Finding Memory Problems with GNAT Debug Pool:: + * Creating Sample Bodies Using gnatstub:: + * Reducing the Size of Ada Executables with gnatelim:: + * Other Utility Programs:: + * Running and Debugging Ada Programs:: + * Inline Assembler:: + * Microsoft Windows Topics:: + * Performance Considerations:: + * GNU Free Documentation License:: + * Index:: + + --- The Detailed Node Listing --- + + About This Guide + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + + + Getting Started with GNAT + + * Running GNAT:: + * Running a Simple Ada Program:: + * Running a Program with Multiple Units:: + * Using the gnatmake Utility:: + + The GNAT Compilation Model + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + Foreign Language Representation + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + + Compiling Ada Programs With gcc + + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + + Switches for gcc + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + Binding Ada Programs With gnatbind + + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + + Linking Using gnatlink + + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + + The GNAT Make Program gnatmake + + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + + Renaming Files Using gnatchop + + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + + Configuration Pragmas + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + + Handling Arbitrary File Naming Conventions Using gnatname + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + + GNAT Project Manager + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + + Elaboration Order Handling in GNAT + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + The Cross-Referencing Tools gnatxref and gnatfind + + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + + File Name Krunching Using gnatkr + + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + + Preprocessing Using gnatprep + + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + + + The GNAT Library Browser gnatls + + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + + + GNAT and Libraries + + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + + Using the GNU make Utility + + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + + Finding Memory Problems with gnatmem + + * Running gnatmem (GDB Mode):: + * Running gnatmem (GMEM Mode):: + * Switches for gnatmem:: + * Examples of gnatmem Usage:: + * GDB and GMEM Modes:: + * Implementation Note:: + + + Finding Memory Problems with GNAT Debug Pool + + Creating Sample Bodies Using gnatstub + + * Running gnatstub:: + * Switches for gnatstub:: + + Reducing the Size of Ada Executables with gnatelim + + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + + Other Utility Programs + + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + + + Running and Debugging Ada Programs + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + + Inline Assembler + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + + Microsoft Windows Topics + + * Using GNAT on Windows:: + * GNAT Setup Tool:: + * CONSOLE and WINDOWS subsystems:: + * Temporary Files:: + * Mixed-Language Programming on Windows:: + * Windows Calling Conventions:: + * Introduction to Dynamic Link Libraries (DLLs):: + * Using DLLs with GNAT:: + * Building DLLs with GNAT:: + * GNAT and Windows Resources:: + * GNAT and COM/DCOM Objects:: + + + Performance Considerations + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + + * Index:: + +  + File: gnat_ug_wnt.info, Node: About This Guide, Next: Getting Started with GNAT, Prev: Top, Up: Top + + About This Guide + **************** + + This guide describes the use of GNAT, a compiler and software + development toolset for the full Ada 95 programming language. It + describes the features of the compiler and tools, and details how to + use them to build Ada 95 applications. + + * Menu: + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + +  + File: gnat_ug_wnt.info, Node: What This Guide Contains, Next: What You Should Know before Reading This Guide, Up: About This Guide + + What This Guide Contains + ======================== + + This guide contains the following chapters: + * *Note Getting Started with GNAT::, describes how to get started + compiling and running Ada programs with the GNAT Ada programming + environment. + + * *Note The GNAT Compilation Model::, describes the compilation + model used by GNAT. + + * *Note Compiling Using gcc::, describes how to compile Ada programs + with `gcc', the Ada compiler. + + * *Note Binding Using gnatbind::, describes how to perform binding + of Ada programs with `gnatbind', the GNAT binding utility. + + * *Note Linking Using gnatlink::, describes `gnatlink', a program + that provides for linking using the GNAT run-time library to + construct a program. `gnatlink' can also incorporate foreign + language object units into the executable. + + * *Note The GNAT Make Program gnatmake::, describes `gnatmake', a + utility that automatically determines the set of sources needed by + an Ada compilation unit, and executes the necessary compilations + binding and link. + + * *Note Renaming Files Using gnatchop::, describes `gnatchop', a + utility that allows you to preprocess a file that contains Ada + source code, and split it into one or more new files, one for each + compilation unit. + + * *Note Configuration Pragmas::, describes the configuration pragmas + handled by GNAT. + + * *Note Handling Arbitrary File Naming Conventions Using gnatname::, + shows how to override the default GNAT file naming conventions, + either for an individual unit or globally. + + * *Note GNAT Project Manager::, describes how to use project files + to organize large projects. + + * *Note Elaboration Order Handling in GNAT::, describes how GNAT + helps you deal with elaboration order issues. + + * *Note The Cross-Referencing Tools gnatxref and gnatfind::, + discusses `gnatxref' and `gnatfind', two tools that provide an easy + way to navigate through sources. + + * *Note File Name Krunching Using gnatkr::, describes the `gnatkr' + file name krunching utility, used to handle shortened file names + on operating systems with a limit on the length of names. + + * *Note Preprocessing Using gnatprep::, describes `gnatprep', a + preprocessor utility that allows a single source file to be used to + generate multiple or parameterized source files, by means of macro + substitution. + + * *Note The GNAT Library Browser gnatls::, describes `gnatls', a + utility that displays information about compiled units, including + dependences on the corresponding sources files, and consistency of + compilations. + + * *Note GNAT and Libraries::, describes the process of creating and + using Libraries with GNAT. It also describes how to recompile the + GNAT run-time library. + + * *Note Using the GNU make Utility::, describes some techniques for + using the GNAT toolset in Makefiles. + + * *Note Finding Memory Problems with gnatmem::, describes `gnatmem', + a utility that monitors dynamic allocation and deallocation + activity in a program, and displays information about incorrect + deallocations and sources of possible memory leaks. + + * *Note Finding Memory Problems with GNAT Debug Pool::, describes + how to use the GNAT-specific Debug Pool in order to detect as + early as possible the use of incorrect memory references. + + * *Note Creating Sample Bodies Using gnatstub::, discusses + `gnatstub', a utility that generates empty but compilable bodies + for library units. + + * *Note Reducing the Size of Ada Executables with gnatelim::, + describes `gnatelim', a tool which detects unused subprograms and + helps the compiler to create a smaller executable for the program. + + * *Note Other Utility Programs::, discusses several other GNAT + utilities, including `gnatpsta'. + + * *Note Running and Debugging Ada Programs::, describes how to run + and debug Ada programs. + + * *Note Inline Assembler::, shows how to use the inline assembly + facility in an Ada program. + + * *Note Performance Considerations::, reviews the trade offs between + using defaults or options in program development. + +  + File: gnat_ug_wnt.info, Node: What You Should Know before Reading This Guide, Next: Related Information, Prev: What This Guide Contains, Up: About This Guide + + What You Should Know before Reading This Guide + ============================================== + + This user's guide assumes that you are familiar with Ada 95 language, as + described in the International Standard ANSI/ISO/IEC-8652:1995, Jan + 1995. + +  + File: gnat_ug_wnt.info, Node: Related Information, Next: Conventions, Prev: What You Should Know before Reading This Guide, Up: About This Guide + + Related Information + =================== + + For further information about related tools, refer to the following + documents: + + * `GNAT Reference Manual', which contains all reference material for + the GNAT implementation of Ada 95. + + * `Ada 95 Language Reference Manual', which contains all reference + material for the Ada 95 programming language. + + * `Debugging with GDB' contains all details on the use of the GNU + source-level debugger. + + * `GNU Emacs Manual' contains full information on the extensible + editor and programming environment Emacs. + + +  + File: gnat_ug_wnt.info, Node: Conventions, Prev: Related Information, Up: About This Guide + + Conventions + =========== + + Following are examples of the typographical and graphic conventions used + in this guide: + + * `Functions', `utility program names', `standard names', and + `classes'. + + * `Option flags' + + * `File Names', `button names', and `field names'. + + * VARIABLES. + + * _Emphasis_. + + * [optional information or parameters] + + * Examples are described by text + and then shown this way. + + Commands that are entered by the user are preceded in this manual by the + characters "`$ '" (dollar sign followed by space). If your system uses + this sequence as a prompt, then the commands will appear exactly as you + see them in the manual. If your system uses some other prompt, then the + command will appear with the `$' replaced by whatever prompt character + you are using. + +  + File: gnat_ug_wnt.info, Node: Getting Started with GNAT, Next: The GNAT Compilation Model, Prev: About This Guide, Up: Top + + Getting Started with GNAT + ************************* + + This chapter describes some simple ways of using GNAT to build + executable Ada programs. + + * Menu: + + * Running GNAT:: + * Running a Simple Ada Program:: + + * Running a Program with Multiple Units:: + + * Using the gnatmake Utility:: + * Introduction to Glide and GVD:: + +  + File: gnat_ug_wnt.info, Node: Running GNAT, Next: Running a Simple Ada Program, Up: Getting Started with GNAT + + Running GNAT + ============ + + Three steps are needed to create an executable file from an Ada source + file: + + 1. The source file(s) must be compiled. + + 2. The file(s) must be bound using the GNAT binder. + + 3. All appropriate object files must be linked to produce an + executable. + + All three steps are most commonly handled by using the `gnatmake' + utility program that, given the name of the main program, automatically + performs the necessary compilation, binding and linking steps. + +  + File: gnat_ug_wnt.info, Node: Running a Simple Ada Program, Next: Running a Program with Multiple Units, Prev: Running GNAT, Up: Getting Started with GNAT + + Running a Simple Ada Program + ============================ + + Any text editor may be used to prepare an Ada program. If `Glide' is + used, the optional Ada mode may be helpful in laying out the program. + The program text is a normal text file. We will suppose in our initial + example that you have used your editor to prepare the following + standard format text file: + + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + Put_Line ("Hello WORLD!"); + end Hello; + + This file should be named `hello.adb'. With the normal default file + naming conventions, GNAT requires that each file contain a single + compilation unit whose file name is the unit name, with periods + replaced by hyphens; the extension is `ads' for a spec and `adb' for a + body. You can override this default file naming convention by use of + the special pragma `Source_File_Name' (*note Using Other File Names::). + Alternatively, if you want to rename your files according to this + default convention, which is probably more convenient if you will be + using GNAT for all your compilations, then the `gnatchop' utility can + be used to generate correctly-named source files (*note Renaming Files + Using gnatchop::). + + You can compile the program using the following command (`$' is used + as the command prompt in the examples in this document): + + $ gcc -c hello.adb + + `gcc' is the command used to run the compiler. This compiler is capable + of compiling programs in several languages, including Ada 95 and C. It + assumes that you have given it an Ada program if the file extension is + either `.ads' or `.adb', and it will then call the GNAT compiler to + compile the specified file. + + The `-c' switch is required. It tells `gcc' to only do a + compilation. (For C programs, `gcc' can also do linking, but this + capability is not used directly for Ada programs, so the `-c' switch + must always be present.) + + This compile command generates a file `hello.o', which is the object + file corresponding to your Ada program. It also generates an "Ada + Library Information" file `hello.ali', which contains additional + information used to check that an Ada program is consistent. To build + an executable file, use `gnatbind' to bind the program and `gnatlink' + to link it. The argument to both `gnatbind' and `gnatlink' is the name + of the `ali' file, but the default extension of `.ali' can be omitted. + This means that in the most common case, the argument is simply the + name of the main program: + + $ gnatbind hello + $ gnatlink hello + + A simpler method of carrying out these steps is to use `gnatmake', a + master program that invokes all the required compilation, binding and + linking tools in the correct order. In particular, `gnatmake' + automatically recompiles any sources that have been modified since they + were last compiled, or sources that depend on such modified sources, so + that "version skew" is avoided. + + $ gnatmake hello.adb + + The result is an executable program called `hello', which can be run by + entering: + + $ hello + + assuming that the current directory is on the search path for + executable programs. + + and, if all has gone well, you will see + + Hello WORLD! + + appear in response to this command. + +  + File: gnat_ug_wnt.info, Node: Running a Program with Multiple Units, Next: Using the gnatmake Utility, Prev: Running a Simple Ada Program, Up: Getting Started with GNAT + + Running a Program with Multiple Units + ===================================== + + Consider a slightly more complicated example that has three files: a + main program, and the spec and body of a package: + + package Greetings is + procedure Hello; + procedure Goodbye; + end Greetings; + + with Ada.Text_IO; use Ada.Text_IO; + package body Greetings is + procedure Hello is + begin + Put_Line ("Hello WORLD!"); + end Hello; + + procedure Goodbye is + begin + Put_Line ("Goodbye WORLD!"); + end Goodbye; + end Greetings; + + with Greetings; + procedure Gmain is + begin + Greetings.Hello; + Greetings.Goodbye; + end Gmain; + + Following the one-unit-per-file rule, place this program in the + following three separate files: + + `greetings.ads' + spec of package `Greetings' + + `greetings.adb' + body of package `Greetings' + + `gmain.adb' + body of main program + + To build an executable version of this program, we could use four + separate steps to compile, bind, and link the program, as follows: + + $ gcc -c gmain.adb + $ gcc -c greetings.adb + $ gnatbind gmain + $ gnatlink gmain + + Note that there is no required order of compilation when using GNAT. + In particular it is perfectly fine to compile the main program first. + Also, it is not necessary to compile package specs in the case where + there is an accompanying body; you only need to compile the body. If + you want to submit these files to the compiler for semantic checking + and not code generation, then use the `-gnatc' switch: + + $ gcc -c greetings.ads -gnatc + + Although the compilation can be done in separate steps as in the above + example, in practice it is almost always more convenient to use the + `gnatmake' tool. All you need to know in this case is the name of the + main program's source file. The effect of the above four commands can + be achieved with a single one: + + $ gnatmake gmain.adb + + In the next section we discuss the advantages of using `gnatmake' in + more detail. + +  + File: gnat_ug_wnt.info, Node: Using the gnatmake Utility, Next: Introduction to Glide and GVD, Prev: Running a Program with Multiple Units, Up: Getting Started with GNAT + + Using the `gnatmake' Utility + ============================ + + If you work on a program by compiling single components at a time using + `gcc', you typically keep track of the units you modify. In order to + build a consistent system, you compile not only these units, but also + any units that depend on the units you have modified. For example, in + the preceding case, if you edit `gmain.adb', you only need to recompile + that file. But if you edit `greetings.ads', you must recompile both + `greetings.adb' and `gmain.adb', because both files contain units that + depend on `greetings.ads'. + + `gnatbind' will warn you if you forget one of these compilation + steps, so that it is impossible to generate an inconsistent program as a + result of forgetting to do a compilation. Nevertheless it is tedious and + error-prone to keep track of dependencies among units. One approach to + handle the dependency-bookkeeping is to use a makefile. However, + makefiles present maintenance problems of their own: if the + dependencies change as you change the program, you must make sure that + the makefile is kept up-to-date manually, which is also an error-prone + process. + + The `gnatmake' utility takes care of these details automatically. + Invoke it using either one of the following forms: + + $ gnatmake gmain.adb + $ gnatmake gmain + + The argument is the name of the file containing the main program; you + may omit the extension. `gnatmake' examines the environment, + automatically recompiles any files that need recompiling, and binds and + links the resulting set of object files, generating the executable + file, `gmain'. In a large program, it can be extremely helpful to use + `gnatmake', because working out by hand what needs to be recompiled can + be difficult. + + Note that `gnatmake' takes into account all the Ada 95 rules that + establish dependencies among units. These include dependencies that + result from inlining subprogram bodies, and from generic instantiation. + Unlike some other Ada make tools, `gnatmake' does not rely on the + dependencies that were found by the compiler on a previous compilation, + which may possibly be wrong when sources change. `gnatmake' determines + the exact set of dependencies from scratch each time it is run. + +  + File: gnat_ug_wnt.info, Node: Introduction to Glide and GVD, Prev: Using the gnatmake Utility, Up: Getting Started with GNAT + + Introduction to Glide and GVD + ============================= + + Although it is possible to develop programs using only the command line + interface (`gnatmake', etc.) a graphical Interactive Development + Environment can make it easier for you to compose, navigate, and debug + programs. This section describes the main features of Glide, the GNAT + graphical IDE, and also shows how to use the basic commands in GVD, the + GNU Visual Debugger. Additional information may be found in the + on-line help for these tools. + + * Menu: + + * Building a New Program with Glide:: + * Simple Debugging with GVD:: + * Other Glide Features:: + +  + File: gnat_ug_wnt.info, Node: Building a New Program with Glide, Next: Simple Debugging with GVD, Up: Introduction to Glide and GVD + + Building a New Program with Glide + --------------------------------- + + The simplest way to invoke Glide is to enter `glide' at the command + prompt. It will generally be useful to issue this as a background + command, thus allowing you to continue using your command window for + other purposes while Glide is running: + + $ glide& + + Glide will start up with an initial screen displaying the top-level + menu items as well as some other information. The menu selections are + as follows + * `Buffers' + + * `Files' + + * `Tools' + + * `Edit' + + * `Search' + + * `Mule' + + * `Glide' + + * `Help' + + For this introductory example, you will need to create a new Ada source + file. First, select the `Files' menu. This will pop open a menu with + around a dozen or so items. To create a file, select the `Open + file...' choice. Depending on the platform, you may see a pop-up + window where you can browse to an appropriate directory and then enter + the file name, or else simply see a line at the bottom of the Glide + window where you can likewise enter the file name. Note that in Glide, + when you attempt to open a non-existent file, the effect is to create a + file with that name. For this example enter `hello.adb' as the name of + the file. + + A new buffer will now appear, occupying the entire Glide window, + with the file name at the top. The menu selections are slightly + different from the ones you saw on the opening screen; there is an + `Entities' item, and in place of `Glide' there is now an `Ada' item. + Glide uses the file extension to identify the source language, so `adb' + indicates an Ada source file. + + You will enter some of the source program lines explicitly, and use + the syntax-oriented template mechanism to enter other lines. First, + type the following text: + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + + Observe that Glide uses different colors to distinguish reserved words + from identifiers. Also, after the `procedure Hello is' line, the + cursor is automatically indented in anticipation of declarations. When + you enter `begin', Glide recognizes that there are no declarations and + thus places `begin' flush left. But after the `begin' line the cursor + is again indented, where the statement(s) will be placed. + + The main part of the program will be a `for' loop. Instead of + entering the text explicitly, however, use a statement template. + Select the `Ada' item on the top menu bar, move the mouse to the + `Statements' item, and you will see a large selection of alternatives. + Choose `for loop'. You will be prompted (at the bottom of the buffer) + for a loop name; simply press the key since a loop name is not + needed. You should see the beginning of a `for' loop appear in the + source program window. You will now be prompted for the name of the + loop variable; enter a line with the identifier `ind' (lower case). + Note that, by default, Glide capitalizes the name (you can override + such behavior if you wish, although this is outside the scope of this + introduction). Next, Glide prompts you for the loop range; enter a + line containing `1..5' and you will see this also appear in the source + program, together with the remaining elements of the `for' loop syntax. + + Next enter the statement (with an intentional error, a missing + semicolon) that will form the body of the loop: + Put_Line("Hello, World" & Integer'Image(I)) + + Finally, type `end Hello;' as the last line in the program. Now save + the file: choose the `File' menu item, and then the `Save buffer' + selection. You will see a message at the bottom of the buffer + confirming that the file has been saved. + + You are now ready to attempt to build the program. Select the `Ada' + item from the top menu bar. Although we could choose simply to compile + the file, we will instead attempt to do a build (which invokes + `gnatmake') since, if the compile is successful, we want to build an + executable. Thus select `Ada build'. This will fail because of the + compilation error, and you will notice that the Glide window has been + split: the top window contains the source file, and the bottom window + contains the output from the GNAT tools. Glide allows you to navigate + from a compilation error to the source file position corresponding to + the error: click the middle mouse button (or simultaneously press the + left and right buttons, on a two-button mouse) on the diagnostic line + in the tool window. The focus will shift to the source window, and the + cursor will be positioned on the character at which the error was + detected. + + Correct the error: type in a semicolon to terminate the statement. + Although you can again save the file explicitly, you can also simply + invoke `Ada' => `Build' and you will be prompted to save the file. + This time the build will succeed; the tool output window shows you the + options that are supplied by default. The GNAT tools' output (e.g., + object and ALI files, executable) will go in the directory from which + Glide was launched. + + To execute the program, choose `Ada' and then `Run'. You should see + the program's output displayed in the bottom window: + + Hello, world 1 + Hello, world 2 + Hello, world 3 + Hello, world 4 + Hello, world 5 + +  + File: gnat_ug_wnt.info, Node: Simple Debugging with GVD, Next: Other Glide Features, Prev: Building a New Program with Glide, Up: Introduction to Glide and GVD + + Simple Debugging with GVD + ------------------------- + + This section describes how to set breakpoints, examine/modify + variables, and step through execution. + + In order to enable debugging, you need to pass the `-g' switch to + both the compiler and to `gnatlink'. If you are using the command + line, passing `-g' to `gnatmake' will have this effect. You can then + launch GVD, e.g. on the `hello' program, by issuing the command: + + $ gvd hello + + If you are using Glide, then `-g' is passed to the relevant tools by + default when you do a build. Start the debugger by selecting the `Ada' + menu item, and then `Debug'. + + GVD comes up in a multi-part window. One pane shows the names of + files comprising your executable; another pane shows the source code of + the current unit (initially your main subprogram), another pane shows + the debugger output and user interactions, and the fourth pane (the + data canvas at the top of the window) displays data objects that you + have selected. + + To the left of the source file pane, you will notice green dots + adjacent to some lines. These are lines for which object code exists + and where breakpoints can thus be set. You set/reset a breakpoint by + clicking the green dot. When a breakpoint is set, the dot is replaced + by an `X' in a red circle. Clicking the circle toggles the breakpoint + off, and the red circle is replaced by the green dot. + + For this example, set a breakpoint at the statement where `Put_Line' + is invoked. + + Start program execution by selecting the `Run' button on the top + menu bar. (The `Start' button will also start your program, but it + will cause program execution to break at the entry to your main + subprogram.) Evidence of reaching the breakpoint will appear: the + source file line will be highlighted, and the debugger interactions + pane will display a relevant message. + + You can examine the values of variables in several ways. Move the + mouse over an occurrence of `Ind' in the `for' loop, and you will see + the value (now `1') displayed. Alternatively, right-click on `Ind' and + select `Display Ind'; a box showing the variable's name and value will + appear in the data canvas. + + Although a loop index is a constant with respect to Ada semantics, + you can change its value in the debugger. Right-click in the box for + `Ind', and select the `Set Value of Ind' item. Enter `2' as the new + value, and press `OK'. The box for `Ind' shows the update. + + Press the `Step' button on the top menu bar; this will step through + one line of program text (the invocation of `Put_Line'), and you can + observe the effect of having modified `Ind' since the value displayed + is `2'. + + Remove the breakpoint, and resume execution by selecting the `Cont' + button. You will see the remaining output lines displayed in the + debugger interaction window, along with a message confirming normal + program termination. + +  + File: gnat_ug_wnt.info, Node: Other Glide Features, Prev: Simple Debugging with GVD, Up: Introduction to Glide and GVD + + Other Glide Features + -------------------- + + You may have observed that some of the menu selections contain + abbreviations; e.g., `(C-x C-f)' for `Open file...' in the `Files' + menu. These are _shortcut keys_ that you can use instead of selecting + menu items. The stands for ; thus `(C-x C-f)' means + followed by , and this sequence can be used instead of + selecting `Files' and then `Open file...'. + + To abort a Glide command, type . + + If you want Glide to start with an existing source file, you can + either launch Glide as above and then open the file via `Files' => + `Open file...', or else simply pass the name of the source file on the + command line: + + $ glide hello.adb& + + While you are using Glide, a number of _buffers_ exist. You create + some explicitly; e.g., when you open/create a file. Others arise as an + effect of the commands that you issue; e.g., the buffer containing the + output of the tools invoked during a build. If a buffer is hidden, you + can bring it into a visible window by first opening the `Buffers' menu + and then selecting the desired entry. + + If a buffer occupies only part of the Glide screen and you want to + expand it to fill the entire screen, then click in the buffer and then + select `Files' => `One Window'. + + If a window is occupied by one buffer and you want to split the + window to bring up a second buffer, perform the following steps: + * Select `Files' => `Split Window'; this will produce two windows + each of which holds the original buffer (these are not copies, but + rather different views of the same buffer contents) + + * With the focus in one of the windows, select the desired buffer + from the `Buffers' menu + + To exit from Glide, choose `Files' => `Exit'. + +  + File: gnat_ug_wnt.info, Node: The GNAT Compilation Model, Next: Compiling Using gcc, Prev: Getting Started with GNAT, Up: Top + + The GNAT Compilation Model + ************************** + + * Menu: + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + This chapter describes the compilation model used by GNAT. Although + similar to that used by other languages, such as C and C++, this model + is substantially different from the traditional Ada compilation models, + which are based on a library. The model is initially described without + reference to the library-based model. If you have not previously used an + Ada compiler, you need only read the first part of this chapter. The + last section describes and discusses the differences between the GNAT + model and the traditional Ada compiler models. If you have used other + Ada compilers, this section will help you to understand those + differences, and the advantages of the GNAT model. + +  + File: gnat_ug_wnt.info, Node: Source Representation, Next: Foreign Language Representation, Up: The GNAT Compilation Model + + Source Representation + ===================== + + Ada source programs are represented in standard text files, using + Latin-1 coding. Latin-1 is an 8-bit code that includes the familiar + 7-bit ASCII set, plus additional characters used for representing + foreign languages (*note Foreign Language Representation:: for support + of non-USA character sets). The format effector characters are + represented using their standard ASCII encodings, as follows: + + `VT' + Vertical tab, `16#0B#' + + `HT' + Horizontal tab, `16#09#' + + `CR' + Carriage return, `16#0D#' + + `LF' + Line feed, `16#0A#' + + `FF' + Form feed, `16#0C#' + + Source files are in standard text file format. In addition, GNAT will + recognize a wide variety of stream formats, in which the end of physical + physical lines is marked by any of the following sequences: `LF', `CR', + `CR-LF', or `LF-CR'. This is useful in accommodating files that are + imported from other operating systems. + + The end of a source file is normally represented by the physical end + of file. However, the control character `16#1A#' (`SUB') is also + recognized as signalling the end of the source file. Again, this is + provided for compatibility with other operating systems where this code + is used to represent the end of file. + + Each file contains a single Ada compilation unit, including any + pragmas associated with the unit. For example, this means you must + place a package declaration (a package "spec") and the corresponding + body in separate files. An Ada "compilation" (which is a sequence of + compilation units) is represented using a sequence of files. Similarly, + you will place each subunit or child unit in a separate file. + +  + File: gnat_ug_wnt.info, Node: Foreign Language Representation, Next: File Naming Rules, Prev: Source Representation, Up: The GNAT Compilation Model + + Foreign Language Representation + =============================== + + GNAT supports the standard character sets defined in Ada 95 as well as + several other non-standard character sets for use in localized versions + of the compiler (*note Character Set Control::). + + * Menu: + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + +  + File: gnat_ug_wnt.info, Node: Latin-1, Next: Other 8-Bit Codes, Up: Foreign Language Representation + + Latin-1 + ------- + + The basic character set is Latin-1. This character set is defined by ISO + standard 8859, part 1. The lower half (character codes `16#00#' ... + `16#7F#)' is identical to standard ASCII coding, but the upper half is + used to represent additional characters. These include extended letters + used by European languages, such as French accents, the vowels with + umlauts used in German, and the extra letter A-ring used in Swedish. + + For a complete list of Latin-1 codes and their encodings, see the + source file of library unit `Ada.Characters.Latin_1' in file + `a-chlat1.ads'. You may use any of these extended characters freely in + character or string literals. In addition, the extended characters that + represent letters can be used in identifiers. + +  + File: gnat_ug_wnt.info, Node: Other 8-Bit Codes, Next: Wide Character Encodings, Prev: Latin-1, Up: Foreign Language Representation + + Other 8-Bit Codes + ----------------- + + GNAT also supports several other 8-bit coding schemes: + + Latin-2 + Latin-2 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-3 + Latin-3 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-4 + Latin-4 letters allowed in identifiers, with uppercase and + lowercase equivalence. + + Latin-5 + Latin-4 letters (Cyrillic) allowed in identifiers, with uppercase + and lowercase equivalence. + + IBM PC (code page 437) + This code page is the normal default for PCs in the U.S. It + corresponds to the original IBM PC character set. This set has + some, but not all, of the extended Latin-1 letters, but these + letters do not have the same encoding as Latin-1. In this mode, + these letters are allowed in identifiers with uppercase and + lowercase equivalence. + + IBM PC (code page 850) + This code page is a modification of 437 extended to include all the + Latin-1 letters, but still not with the usual Latin-1 encoding. In + this mode, all these letters are allowed in identifiers with + uppercase and lowercase equivalence. + + Full Upper 8-bit + Any character in the range 80-FF allowed in identifiers, and all + are considered distinct. In other words, there are no uppercase + and lowercase equivalences in this range. This is useful in + conjunction with certain encoding schemes used for some foreign + character sets (e.g. the typical method of representing Chinese + characters on the PC). + + No Upper-Half + No upper-half characters in the range 80-FF are allowed in + identifiers. This gives Ada 83 compatibility for identifier names. + + For precise data on the encodings permitted, and the uppercase and + lowercase equivalences that are recognized, see the file `csets.adb' in + the GNAT compiler sources. You will need to obtain a full source release + of GNAT to obtain this file. + +  + File: gnat_ug_wnt.info, Node: Wide Character Encodings, Prev: Other 8-Bit Codes, Up: Foreign Language Representation + + Wide Character Encodings + ------------------------ + + GNAT allows wide character codes to appear in character and string + literals, and also optionally in identifiers, by means of the following + possible encoding schemes: + + Hex Coding + In this encoding, a wide character is represented by the following + five character sequence: + + ESC a b c d + + Where `a', `b', `c', `d' are the four hexadecimal characters + (using uppercase letters) of the wide character code. For example, + ESC A345 is used to represent the wide character with code + `16#A345#'. This scheme is compatible with use of the full + Wide_Character set. + + Upper-Half Coding + The wide character with encoding `16#abcd#' where the upper bit is + on (in other words, "a" is in the range 8-F) is represented as two + bytes, `16#ab#' and `16#cd#'. The second byte cannot be a format + control character, but is not required to be in the upper half. + This method can be also used for shift-JIS or EUC, where the + internal coding matches the external coding. + + Shift JIS Coding + A wide character is represented by a two-character sequence, + `16#ab#' and `16#cd#', with the restrictions described for + upper-half encoding as described above. The internal character + code is the corresponding JIS character according to the standard + algorithm for Shift-JIS conversion. Only characters defined in the + JIS code set table can be used with this encoding method. + + EUC Coding + A wide character is represented by a two-character sequence + `16#ab#' and `16#cd#', with both characters being in the upper + half. The internal character code is the corresponding JIS + character according to the EUC encoding algorithm. Only characters + defined in the JIS code set table can be used with this encoding + method. + + UTF-8 Coding + A wide character is represented using UCS Transformation Format 8 + (UTF-8) as defined in Annex R of ISO 10646-1/Am.2. Depending on + the character value, the representation is a one, two, or three + byte sequence: + 16#0000#-16#007f#: 2#0xxxxxxx# + 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx# + 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx# + + where the xxx bits correspond to the left-padded bits of the + 16-bit character value. Note that all lower half ASCII characters + are represented as ASCII bytes and all upper half characters and + other wide characters are represented as sequences of upper-half + (The full UTF-8 scheme allows for encoding 31-bit characters as + 6-byte sequences, but in this implementation, all UTF-8 sequences + of four or more bytes length will be treated as illegal). + + Brackets Coding + In this encoding, a wide character is represented by the following + eight character sequence: + + [ " a b c d " ] + + Where `a', `b', `c', `d' are the four hexadecimal characters + (using uppercase letters) of the wide character code. For example, + ["A345"] is used to represent the wide character with code + `16#A345#'. It is also possible (though not required) to use the + Brackets coding for upper half characters. For example, the code + `16#A3#' can be represented as `["A3"]'. + + This scheme is compatible with use of the full Wide_Character set, + and is also the method used for wide character encoding in the + standard ACVC (Ada Compiler Validation Capability) test suite + distributions. + + Note: Some of these coding schemes do not permit the full use of the + Ada 95 character set. For example, neither Shift JIS, nor EUC allow the + use of the upper half of the Latin-1 set. + +  + File: gnat_ug_wnt.info, Node: File Naming Rules, Next: Using Other File Names, Prev: Foreign Language Representation, Up: The GNAT Compilation Model + + File Naming Rules + ================= + + The default file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + lowercase for all letters. + + An exception arises if the file name generated by the above rules + starts with one of the characters a,g,i, or s, and the second character + is a minus. In this case, the character tilde is used in place of the + minus. The reason for this special rule is to avoid clashes with the + standard names for child units of the packages System, Ada, Interfaces, + and GNAT, which use the prefixes s- a- i- and g- respectively. + + The file extension is `.ads' for a spec and `.adb' for a body. The + following list shows some examples of these rules. + + `main.ads' + Main (spec) + + `main.adb' + Main (body) + + `arith_functions.ads' + Arith_Functions (package spec) + + `arith_functions.adb' + Arith_Functions (package body) + + `func-spec.ads' + Func.Spec (child package spec) + + `func-spec.adb' + Func.Spec (child package body) + + `main-sub.adb' + Sub (subunit of Main) + + `a~bad.adb' + A.Bad (child package body) + + Following these rules can result in excessively long file names if + corresponding unit names are long (for example, if child units or + subunits are heavily nested). An option is available to shorten such + long file names (called file name "krunching"). This may be + particularly useful when programs being developed with GNAT are to be + used on operating systems with limited file name lengths. *Note Using + gnatkr::. + + Of course, no file shortening algorithm can guarantee uniqueness over + all possible unit names; if file name krunching is used, it is your + responsibility to ensure no name clashes occur. Alternatively you can + specify the exact file names that you want used, as described in the + next section. Finally, if your Ada programs are migrating from a + compiler with a different naming convention, you can use the gnatchop + utility to produce source files that follow the GNAT naming conventions. + (For details *note Renaming Files Using gnatchop::.) + +  + File: gnat_ug_wnt.info, Node: Using Other File Names, Next: Alternative File Naming Schemes, Prev: File Naming Rules, Up: The GNAT Compilation Model + + Using Other File Names + ====================== + + In the previous section, we have described the default rules used by + GNAT to determine the file name in which a given unit resides. It is + often convenient to follow these default rules, and if you follow them, + the compiler knows without being explicitly told where to find all the + files it needs. + + However, in some cases, particularly when a program is imported from + another Ada compiler environment, it may be more convenient for the + programmer to specify which file names contain which units. GNAT allows + arbitrary file names to be used by means of the Source_File_Name pragma. + The form of this pragma is as shown in the following examples: + + pragma Source_File_Name (My_Utilities.Stacks, + Spec_File_Name => "myutilst_a.ada"); + pragma Source_File_name (My_Utilities.Stacks, + Body_File_Name => "myutilst.ada"); + + As shown in this example, the first argument for the pragma is the unit + name (in this example a child unit). The second argument has the form + of a named association. The identifier indicates whether the file name + is for a spec or a body; the file name itself is given by a string + literal. + + The source file name pragma is a configuration pragma, which means + that normally it will be placed in the `gnat.adc' file used to hold + configuration pragmas that apply to a complete compilation environment. + For more details on how the `gnat.adc' file is created and used *note + Handling of Configuration Pragmas:: + + GNAT allows completely arbitrary file names to be specified using the + source file name pragma. However, if the file name specified has an + extension other than `.ads' or `.adb' it is necessary to use a special + syntax when compiling the file. The name in this case must be preceded + by the special sequence `-x' followed by a space and the name of the + language, here `ada', as in: + + $ gcc -c -x ada peculiar_file_name.sim + + `gnatmake' handles non-standard file names in the usual manner (the + non-standard file name for the main program is simply used as the + argument to gnatmake). Note that if the extension is also non-standard, + then it must be included in the gnatmake command, it may not be omitted. + +  + File: gnat_ug_wnt.info, Node: Alternative File Naming Schemes, Next: Generating Object Files, Prev: Using Other File Names, Up: The GNAT Compilation Model + + Alternative File Naming Schemes + =============================== + + In the previous section, we described the use of the + `Source_File_Name' pragma to allow arbitrary names to be assigned to + individual source files. However, this approach requires one pragma + for each file, and especially in large systems can result in very long + `gnat.adc' files, and also create a maintenance problem. + + GNAT also provides a facility for specifying systematic file naming + schemes other than the standard default naming scheme previously + described. An alternative scheme for naming is specified by the use of + `Source_File_Name' pragmas having the following format: + + pragma Source_File_Name ( + Spec_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Body_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Subunit_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + FILE_NAME_PATTERN ::= STRING_LITERAL + CASING_SPEC ::= Lowercase | Uppercase | Mixedcase + + The `FILE_NAME_PATTERN' string shows how the file name is constructed. + It contains a single asterisk character, and the unit name is + substituted systematically for this asterisk. The optional parameter + `Casing' indicates whether the unit name is to be all upper-case + letters, all lower-case letters, or mixed-case. If no `Casing' + parameter is used, then the default is all lower-case. + + The optional `Dot_Replacement' string is used to replace any periods + that occur in subunit or child unit names. If no `Dot_Replacement' + argument is used then separating dots appear unchanged in the resulting + file name. Although the above syntax indicates that the `Casing' + argument must appear before the `Dot_Replacement' argument, but it is + also permissible to write these arguments in the opposite order. + + As indicated, it is possible to specify different naming schemes for + bodies, specs, and subunits. Quite often the rule for subunits is the + same as the rule for bodies, in which case, there is no need to give a + separate `Subunit_File_Name' rule, and in this case the + `Body_File_name' rule is used for subunits as well. + + The separate rule for subunits can also be used to implement the + rather unusual case of a compilation environment (e.g. a single + directory) which contains a subunit and a child unit with the same unit + name. Although both units cannot appear in the same partition, the Ada + Reference Manual allows (but does not require) the possibility of the + two units coexisting in the same environment. + + The file name translation works in the following steps: + + * If there is a specific `Source_File_Name' pragma for the given + unit, then this is always used, and any general pattern rules are + ignored. + + * If there is a pattern type `Source_File_Name' pragma that applies + to the unit, then the resulting file name will be used if the file + exists. If more than one pattern matches, the latest one will be + tried first, and the first attempt resulting in a reference to a + file that exists will be used. + + * If no pattern type `Source_File_Name' pragma that applies to the + unit for which the corresponding file exists, then the standard + GNAT default naming rules are used. + + + As an example of the use of this mechanism, consider a commonly used + scheme in which file names are all lower case, with separating periods + copied unchanged to the resulting file name, and specs end with + ".1.ada", and bodies end with ".2.ada". GNAT will follow this scheme if + the following two pragmas appear: + + pragma Source_File_Name + (Spec_File_Name => "*.1.ada"); + pragma Source_File_Name + (Body_File_Name => "*.2.ada"); + + The default GNAT scheme is actually implemented by providing the + following default pragmas internally: + + pragma Source_File_Name + (Spec_File_Name => "*.ads", Dot_Replacement => "-"); + pragma Source_File_Name + (Body_File_Name => "*.adb", Dot_Replacement => "-"); + + Our final example implements a scheme typically used with one of the + Ada 83 compilers, where the separator character for subunits was "__" + (two underscores), specs were identified by adding `_.ADA', bodies by + adding `.ADA', and subunits by adding `.SEP'. All file names were upper + case. Child units were not present of course since this was an Ada 83 + compiler, but it seems reasonable to extend this scheme to use the same + double underscore separator for child units. + + pragma Source_File_Name + (Spec_File_Name => "*_.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Body_File_Name => "*.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Subunit_File_Name => "*.SEP", + Dot_Replacement => "__", + Casing = Uppercase); + +  + File: gnat_ug_wnt.info, Node: Generating Object Files, Next: Source Dependencies, Prev: Alternative File Naming Schemes, Up: The GNAT Compilation Model + + Generating Object Files + ======================= + + An Ada program consists of a set of source files, and the first step in + compiling the program is to generate the corresponding object files. + These are generated by compiling a subset of these source files. The + files you need to compile are the following: + + * If a package spec has no body, compile the package spec to produce + the object file for the package. + + * If a package has both a spec and a body, compile the body to + produce the object file for the package. The source file for the + package spec need not be compiled in this case because there is + only one object file, which contains the code for both the spec + and body of the package. + + * For a subprogram, compile the subprogram body to produce the + object file for the subprogram. The spec, if one is present, is as + usual in a separate file, and need not be compiled. + + * In the case of subunits, only compile the parent unit. A single + object file is generated for the entire subunit tree, which + includes all the subunits. + + * Compile child units independently of their parent units (though, + of course, the spec of all the ancestor unit must be present in + order to compile a child unit). + + * Compile generic units in the same manner as any other units. The + object files in this case are small dummy files that contain at + most the flag used for elaboration checking. This is because GNAT + always handles generic instantiation by means of macro expansion. + However, it is still necessary to compile generic units, for + dependency checking and elaboration purposes. + + The preceding rules describe the set of files that must be compiled to + generate the object files for a program. Each object file has the same + name as the corresponding source file, except that the extension is + `.o' as usual. + + You may wish to compile other files for the purpose of checking their + syntactic and semantic correctness. For example, in the case where a + package has a separate spec and body, you would not normally compile the + spec. However, it is convenient in practice to compile the spec to make + sure it is error-free before compiling clients of this spec, because + such compilations will fail if there is an error in the spec. + + GNAT provides an option for compiling such files purely for the + purposes of checking correctness; such compilations are not required as + part of the process of building a program. To compile a file in this + checking mode, use the `-gnatc' switch. + +  + File: gnat_ug_wnt.info, Node: Source Dependencies, Next: The Ada Library Information Files, Prev: Generating Object Files, Up: The GNAT Compilation Model + + Source Dependencies + =================== + + A given object file clearly depends on the source file which is compiled + to produce it. Here we are using "depends" in the sense of a typical + `make' utility; in other words, an object file depends on a source file + if changes to the source file require the object file to be recompiled. + In addition to this basic dependency, a given object may depend on + additional source files as follows: + + * If a file being compiled `with''s a unit X, the object file + depends on the file containing the spec of unit X. This includes + files that are `with''ed implicitly either because they are parents + of `with''ed child units or they are run-time units required by the + language constructs used in a particular unit. + + * If a file being compiled instantiates a library level generic + unit, the object file depends on both the spec and body files for + this generic unit. + + * If a file being compiled instantiates a generic unit defined + within a package, the object file depends on the body file for the + package as well as the spec file. + + * If a file being compiled contains a call to a subprogram for which + pragma `Inline' applies and inlining is activated with the + `-gnatn' switch, the object file depends on the file containing the + body of this subprogram as well as on the file containing the + spec. Note that for inlining to actually occur as a result of the + use of this switch, it is necessary to compile in optimizing mode. + + The use of `-gnatN' activates a more extensive inlining + optimization that is performed by the front end of the compiler. + This inlining does not require that the code generation be + optimized. Like `-gnatn', the use of this switch generates + additional dependencies. + + * If an object file O depends on the proper body of a subunit + through inlining or instantiation, it depends on the parent unit + of the subunit. This means that any modification of the parent + unit or one of its subunits affects the compilation of O. + + * The object file for a parent unit depends on all its subunit body + files. + + * The previous two rules meant that for purposes of computing + dependencies and recompilation, a body and all its subunits are + treated as an indivisible whole. + + These rules are applied transitively: if unit `A' `with''s unit + `B', whose elaboration calls an inlined procedure in package `C', + the object file for unit `A' will depend on the body of `C', in + file `c.adb'. + + The set of dependent files described by these rules includes all + the files on which the unit is semantically dependent, as + described in the Ada 95 Language Reference Manual. However, it is + a superset of what the ARM describes, because it includes generic, + inline, and subunit dependencies. + + An object file must be recreated by recompiling the corresponding + source file if any of the source files on which it depends are + modified. For example, if the `make' utility is used to control + compilation, the rule for an Ada object file must mention all the + source files on which the object file depends, according to the + above definition. The determination of the necessary + recompilations is done automatically when one uses `gnatmake'. + +  + File: gnat_ug_wnt.info, Node: The Ada Library Information Files, Next: Binding an Ada Program, Prev: Source Dependencies, Up: The GNAT Compilation Model + + The Ada Library Information Files + ================================= + + Each compilation actually generates two output files. The first of these + is the normal object file that has a `.o' extension. The second is a + text file containing full dependency information. It has the same name + as the source file, but an `.ali' extension. This file is known as the + Ada Library Information (`ali') file. The following information is + contained in the `ali' file. + + * Version information (indicates which version of GNAT was used to + compile the unit(s) in question) + + * Main program information (including priority and time slice + settings, as well as the wide character encoding used during + compilation). + + * List of arguments used in the `gcc' command for the compilation + + * Attributes of the unit, including configuration pragmas used, an + indication of whether the compilation was successful, exception + model used etc. + + * A list of relevant restrictions applying to the unit (used for + consistency) checking. + + * Categorization information (e.g. use of pragma `Pure'). + + * Information on all `with''ed units, including presence of + `Elaborate' or `Elaborate_All' pragmas. + + * Information from any `Linker_Options' pragmas used in the unit + + * Information on the use of `Body_Version' or `Version' attributes + in the unit. + + * Dependency information. This is a list of files, together with + time stamp and checksum information. These are files on which the + unit depends in the sense that recompilation is required if any of + these units are modified. + + * Cross-reference data. Contains information on all entities + referenced in the unit. Used by tools like `gnatxref' and + `gnatfind' to provide cross-reference information. + + + For a full detailed description of the format of the `ali' file, see + the source of the body of unit `Lib.Writ', contained in file + `lib-writ.adb' in the GNAT compiler sources. + +  + File: gnat_ug_wnt.info, Node: Binding an Ada Program, Next: Mixed Language Programming, Prev: The Ada Library Information Files, Up: The GNAT Compilation Model + + Binding an Ada Program + ====================== + + When using languages such as C and C++, once the source files have been + compiled the only remaining step in building an executable program is + linking the object modules together. This means that it is possible to + link an inconsistent version of a program, in which two units have + included different versions of the same header. + + The rules of Ada do not permit such an inconsistent program to be + built. For example, if two clients have different versions of the same + package, it is illegal to build a program containing these two clients. + These rules are enforced by the GNAT binder, which also determines an + elaboration order consistent with the Ada rules. + + The GNAT binder is run after all the object files for a program have + been created. It is given the name of the main program unit, and from + this it determines the set of units required by the program, by reading + the corresponding ALI files. It generates error messages if the program + is inconsistent or if no valid order of elaboration exists. + + If no errors are detected, the binder produces a main program, in + Ada by default, that contains calls to the elaboration procedures of + those compilation unit that require them, followed by a call to the + main program. This Ada program is compiled to generate the object file + for the main program. The name of the Ada file is `b~XXX.adb' (with the + corresponding spec `b~XXX.ads') where XXX is the name of the main + program unit. + + Finally, the linker is used to build the resulting executable + program, using the object from the main program from the bind step as + well as the object files for the Ada units of the program. + +  + File: gnat_ug_wnt.info, Node: Mixed Language Programming, Next: Building Mixed Ada & C++ Programs, Prev: Binding an Ada Program, Up: The GNAT Compilation Model + + Mixed Language Programming + ========================== + + * Menu: + + * Interfacing to C:: + * Calling Conventions:: + +  + File: gnat_ug_wnt.info, Node: Interfacing to C, Next: Calling Conventions, Up: Mixed Language Programming + + Interfacing to C + ---------------- + + There are two ways to build a program that contains some Ada files and + some other language files depending on whether the main program is in + Ada or not. If the main program is in Ada, you should proceed as + follows: + + 1. Compile the other language files to generate object files. For + instance: + gcc -c file1.c + gcc -c file2.c + + 2. Compile the Ada units to produce a set of object files and ALI + files. For instance: + gnatmake -c my_main.adb + + 3. Run the Ada binder on the Ada main program. For instance: + gnatbind my_main.ali + + 4. Link the Ada main program, the Ada objects and the other language + objects. For instance: + gnatlink my_main.ali file1.o file2.o + + The three last steps can be grouped in a single command: + gnatmake my_main.adb -largs file1.o file2.o + + If the main program is in some language other than Ada, Then you may + have more than one entry point in the Ada subsystem. You must use a + special option of the binder to generate callable routines to initialize + and finalize the Ada units (*note Binding with Non-Ada Main Programs::). + Calls to the initialization and finalization routines must be inserted + in the main program, or some other appropriate point in the code. The + call to initialize the Ada units must occur before the first Ada + subprogram is called, and the call to finalize the Ada units must occur + after the last Ada subprogram returns. You use the same procedure for + building the program as described previously. In this case, however, + the binder only places the initialization and finalization subprograms + into file `b~XXX.adb' instead of the main program. So, if the main + program is not in Ada, you should proceed as follows: + + 1. Compile the other language files to generate object files. For + instance: + gcc -c file1.c + gcc -c file2.c + + 2. Compile the Ada units to produce a set of object files and ALI + files. For instance: + gnatmake -c entry_point1.adb + gnatmake -c entry_point2.adb + + 3. Run the Ada binder on the Ada main program. For instance: + gnatbind -n entry_point1.ali entry_point2.ali + + 4. Link the Ada main program, the Ada objects and the other language + objects. You only need to give the last entry point here. For + instance: + gnatlink entry_point2.ali file1.o file2.o + +  + File: gnat_ug_wnt.info, Node: Calling Conventions, Prev: Interfacing to C, Up: Mixed Language Programming + + Calling Conventions + ------------------- + + GNAT follows standard calling sequence conventions and will thus + interface to any other language that also follows these conventions. + The following Convention identifiers are recognized by GNAT: + + * Ada. This indicates that the standard Ada calling sequence will be + used and all Ada data items may be passed without any limitations + in the case where GNAT is used to generate both the caller and + callee. It is also possible to mix GNAT generated code and code + generated by another Ada compiler. In this case, the data types + should be restricted to simple cases, including primitive types. + Whether complex data types can be passed depends on the situation. + Probably it is safe to pass simple arrays, such as arrays of + integers or floats. Records may or may not work, depending on + whether both compilers lay them out identically. Complex structures + involving variant records, access parameters, tasks, or protected + types, are unlikely to be able to be passed. + + Note that in the case of GNAT running on a platform that supports + DEC Ada 83, a higher degree of compatibility can be guaranteed, + and in particular records are layed out in an identical manner in + the two compilers. Note also that if output from two different + compilers is mixed, the program is responsible for dealing with + elaboration issues. Probably the safest approach is to write the + main program in the version of Ada other than GNAT, so that it + takes care of its own elaboration requirements, and then call the + GNAT-generated adainit procedure to ensure elaboration of the GNAT + components. Consult the documentation of the other Ada compiler + for further details on elaboration. + + However, it is not possible to mix the tasking run time of GNAT and + DEC Ada 83, All the tasking operations must either be entirely + within GNAT compiled sections of the program, or entirely within + DEC Ada 83 compiled sections of the program. + + * Assembler. Specifies assembler as the convention. In practice this + has the same effect as convention Ada (but is not equivalent in + the sense of being considered the same convention). + + * Asm. Equivalent to Assembler. + + * Asm. Equivalent to Assembly. + + * COBOL. Data will be passed according to the conventions described + in section B.4 of the Ada 95 Reference Manual. + + * C. Data will be passed according to the conventions described in + section B.3 of the Ada 95 Reference Manual. + + * Default. Equivalent to C. + + * External. Equivalent to C. + + * CPP. This stands for C++. For most purposes this is identical to C. + See the separate description of the specialized GNAT pragmas + relating to C++ interfacing for further details. + + * Fortran. Data will be passed according to the conventions described + in section B.5 of the Ada 95 Reference Manual. + + * Intrinsic. This applies to an intrinsic operation, as defined in + the Ada 95 Reference Manual. If a a pragma Import (Intrinsic) + applies to a subprogram, this means that the body of the + subprogram is provided by the compiler itself, usually by means of + an efficient code sequence, and that the user does not supply an + explicit body for it. In an application program, the pragma can + only be applied to the following two sets of names, which the GNAT + compiler recognizes. + * Rotate_Left, Rotate_Right, Shift_Left, Shift_Right, + Shift_Right_- Arithmetic. The corresponding subprogram + declaration must have two formal parameters. The first one + must be a signed integer type or a modular type with a binary + modulus, and the second parameter must be of type Natural. + The return type must be the same as the type of the first + argument. The size of this type can only be 8, 16, 32, or 64. + + * binary arithmetic operators: "+", "-", "*", "/" The + corresponding operator declaration must have parameters and + result type that have the same root numeric type (for + example, all three are long_float types). This simplifies the + definition of operations that use type checking to perform + dimensional checks: + type Distance is new Long_Float; + type Time is new Long_Float; + type Velocity is new Long_Float; + function "/" (D : Distance; T : Time) + return Velocity; + pragma Import (Intrinsic, "/"); + + This common idiom is often programmed with a generic + definition and an explicit body. The pragma makes it simpler + to introduce such declarations. It incurs no overhead in + compilation time or code size, because it is implemented as a + single machine instruction. + + * Stdcall. This is relevant only to NT/Win95 implementations of GNAT, + and specifies that the Stdcall calling sequence will be used, as + defined by the NT API. + + * DLL. This is equivalent to Stdcall. + + * Win32. This is equivalent to Stdcall. + + * Stubbed. This is a special convention that indicates that the + compiler should provide a stub body that raises `Program_Error'. + + GNAT additionally provides a useful pragma `Convention_Identifier' that + can be used to parametrize conventions and allow additional synonyms to + be specified. For example if you have legacy code in which the + convention identifier Fortran77 was used for Fortran, you can use the + configuration pragma: + + pragma Convention_Identifier (Fortran77, Fortran); + + And from now on the identifier Fortran77 may be used as a convention + identifier (for example in an `Import' pragma) with the same meaning as + Fortran. + +  + File: gnat_ug_wnt.info, Node: Building Mixed Ada & C++ Programs, Next: Comparison between GNAT and C/C++ Compilation Models, Prev: Mixed Language Programming, Up: The GNAT Compilation Model + + Building Mixed Ada & C++ Programs + ================================= + + Building a mixed application containing both Ada and C++ code may be a + challenge for the unaware programmer. As a matter of fact, this + interfacing has not been standardized in the Ada 95 reference manual due + to the immaturity and lack of standard of C++ at the time. This section + gives a few hints that should make this task easier. In particular the + first section addresses the differences with interfacing with C. The + second section looks into the delicate problem of linking the complete + application from its Ada and C++ parts. The last section give some + hints on how the GNAT run time can be adapted in order to allow + inter-language dispatching with a new C++ compiler. + + * Menu: + + * Interfacing to C++:: + * Linking a Mixed C++ & Ada Program:: + * A Simple Example:: + * Adapting the Run Time to a New C++ Compiler:: + +  + File: gnat_ug_wnt.info, Node: Interfacing to C++, Next: Linking a Mixed C++ & Ada Program, Up: Building Mixed Ada & C++ Programs + + Interfacing to C++ + ------------------ + + GNAT supports interfacing with C++ compilers generating code that is + compatible with the standard Application Binary Interface of the given + platform. + + Interfacing can be done at 3 levels: simple data, subprograms and + classes. In the first 2 cases, GNAT offer a specific CONVENTION CPP + that behaves exactly like CONVENTION C. Usually C++ mangle names of + subprograms and currently GNAT does not provide any help to solve the + demangling problem. This problem can be addressed in 2 ways: + * by modifying the C++ code in order to force a C convention using + the EXTERN "C" syntax. + + * by figuring out the mangled name and use it as the Link_Name + argument of the pragma import. + + Interfacing at the class level can be achieved by using the GNAT + specific pragmas such as `CPP_Class' and `CPP_Virtual'. See the GNAT + Reference Manual for additional information. + +  + File: gnat_ug_wnt.info, Node: Linking a Mixed C++ & Ada Program, Next: A Simple Example, Prev: Interfacing to C++, Up: Building Mixed Ada & C++ Programs + + Linking a Mixed C++ & Ada Program + --------------------------------- + + Usually the linker of the C++ development system must be used to link + mixed applications because most C++ systems will resolve elaboration + issues (such as calling constructors on global class instances) + transparently during the link phase. GNAT has been adapted to ease the + use of a foreign linker for the last phase. Three cases can be + considered: + 1. 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 `c++'. Note that this setup is not very + common because it may request recompiling the whole GCC tree from + sources and it does not allow to upgrade easily to a new version + of one compiler for one of the two languages without taking the + risk of destabilizing the other. + + $ c++ -c file1.C + $ c++ -c file2.C + $ gnatmake ada_unit -largs file1.o file2.o --LINK=c++ + + 2. Using GNAT and G++ from 2 different GCC installations. If both + compilers are on the PATH, the same method can be used. It is + important to be aware that environment variables such as + C_INCLUDE_PATH, GCC_EXEC_PREFIX, BINUTILS_ROOT or GCC_ROOT will + affect both compilers at the same time and thus may make one of + the 2 compilers operate improperly if they are set for the other. + In particular it is important that the link command has access to + the proper gcc library `libgcc.a', that is to say the one that is + part of the C++ compiler installation. The implicit link command + as suggested in the gnatmake command from the former example can + be replaced by an explicit link command with full verbosity in + order to verify which library is used: + $ gnatbind ada_unit + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=c++ + If there is a problem due to interfering environment variables, it + can be workaround by using an intermediate script. The following + example shows the proper script to use when GNAT has not been + installed at its default location and g++ has been installed at + its default location: + + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + unset BINUTILS_ROOT + unset GCC_ROOT + c++ $* + + 3. Using a non GNU C++ compiler. The same set of command as previously + described can be used to insure that the c++ linker is used. + Nonetheless, you need to add the path to libgcc explicitely, since + some libraries needed by GNAT are located in this directory: + + + $ gnatlink ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + CC $* `gcc -print-libgcc-file-name` + + Where CC is the name of the non GNU C++ compiler. + + +  + File: gnat_ug_wnt.info, Node: A Simple Example, Next: Adapting the Run Time to a New C++ Compiler, Prev: Linking a Mixed C++ & Ada Program, Up: Building Mixed Ada & C++ Programs + + A Simple Example + ---------------- + + The following example, provided as part of the GNAT examples, show how + to achieve procedural interfacing between Ada and C++ in both + directions. The C++ class A has 2 methods. The first method is exported + to Ada by the means of an extern C wrapper function. The second method + calls an Ada subprogram. On the Ada side, The C++ calls is modelized by + a limited record with a layout comparable to the C++ class. The Ada + subprogram, in turn, calls the c++ method. So from the C++ main program + the code goes back and forth between the 2 languages. + + Here are the compilation commands for native configurations: + $ gnatmake -c simple_cpp_interface + $ c++ -c cpp_main.C + $ c++ -c ex7.C + $ gnatbind -n simple_cpp_interface + $ gnatlink simple_cpp_interface -o cpp_main --LINK=$(CPLUSPLUS) + -lstdc++ ex7.o cpp_main.o + + Here are the corresponding sources: + + //cpp_main.C + + #include "ex7.h" + + extern "C" { + void adainit (void); + void adafinal (void); + void method1 (A *t); + } + + void method1 (A *t) + { + t->method1 (); + } + + int main () + { + A obj; + adainit (); + obj.method2 (3030); + adafinal (); + } + + //ex7.h + + class Origin { + public: + int o_value; + }; + class A : public Origin { + public: + void method1 (void); + virtual void method2 (int v); + A(); + int a_value; + }; + + //ex7.C + + #include "ex7.h" + #include + + extern "C" { void ada_method2 (A *t, int v);} + + void A::method1 (void) + { + a_value = 2020; + printf ("in A::method1, a_value = %d \n",a_value); + + } + + void A::method2 (int v) + { + ada_method2 (this, v); + printf ("in A::method2, a_value = %d \n",a_value); + + } + + A::A(void) + { + a_value = 1010; + printf ("in A::A, a_value = %d \n",a_value); + } + + -- Ada sources + package body Simple_Cpp_Interface is + + procedure Ada_Method2 (This : in out A; V : Integer) is + begin + Method1 (This); + This.A_Value := V; + end Ada_Method2; + + end Simple_Cpp_Interface; + + package Simple_Cpp_Interface is + type A is limited + record + O_Value : Integer; + A_Value : Integer; + end record; + pragma Convention (C, A); + + procedure Method1 (This : in out A); + pragma Import (C, Method1); + + procedure Ada_Method2 (This : in out A; V : Integer); + pragma Export (C, Ada_Method2); + + end Simple_Cpp_Interface; + +  + File: gnat_ug_wnt.info, Node: Adapting the Run Time to a New C++ Compiler, Prev: A Simple Example, Up: Building Mixed Ada & C++ Programs + + Adapting the Run Time to a New C++ Compiler + ------------------------------------------- + + GNAT offers the capability to derive Ada 95 tagged types directly from + preexisting C++ classes and . See "Interfacing with C++" in the GNAT + reference manual. The mechanism used by GNAT for achieving such a goal + has been made user configurable through a GNAT library unit + `Interfaces.CPP'. The default version of this file is adapted to the + GNU c++ compiler. Internal knowledge of the virtual table layout used + by the new C++ compiler is needed to configure properly this unit. The + Interface of this unit is known by the compiler and cannot be changed + except for the value of the constants defining the characteristics of + the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size, + CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source + of this unit for more details. + +  + File: gnat_ug_wnt.info, Node: Comparison between GNAT and C/C++ Compilation Models, Next: Comparison between GNAT and Conventional Ada Library Models, Prev: Building Mixed Ada & C++ Programs, Up: The GNAT Compilation Model + + Comparison between GNAT and C/C++ Compilation Models + ==================================================== + + The GNAT model of compilation is close to the C and C++ models. You can + think of Ada specs as corresponding to header files in C. As in C, you + don't need to compile specs; they are compiled when they are used. The + Ada `with' is similar in effect to the `#include' of a C header. + + One notable difference is that, in Ada, you may compile specs + separately to check them for semantic and syntactic accuracy. This is + not always possible with C headers because they are fragments of + programs that have less specific syntactic or semantic rules. + + The other major difference is the requirement for running the binder, + which performs two important functions. First, it checks for + consistency. In C or C++, the only defense against assembling + inconsistent programs lies outside the compiler, in a makefile, for + example. The binder satisfies the Ada requirement that it be impossible + to construct an inconsistent program when the compiler is used in normal + mode. + + The other important function of the binder is to deal with + elaboration issues. There are also elaboration issues in C++ that are + handled automatically. This automatic handling has the advantage of + being simpler to use, but the C++ programmer has no control over + elaboration. Where `gnatbind' might complain there was no valid order + of elaboration, a C++ compiler would simply construct a program that + malfunctioned at run time. + +  + File: gnat_ug_wnt.info, Node: Comparison between GNAT and Conventional Ada Library Models, Prev: Comparison between GNAT and C/C++ Compilation Models, Up: The GNAT Compilation Model + + Comparison between GNAT and Conventional Ada Library Models + =========================================================== + + This section is intended to be useful to Ada programmers who have + previously used an Ada compiler implementing the traditional Ada library + model, as described in the Ada 95 Language Reference Manual. If you + have not used such a system, please go on to the next section. + + In GNAT, there is no "library" in the normal sense. Instead, the set + of source files themselves acts as the library. Compiling Ada programs + does not generate any centralized information, but rather an object + file and a ALI file, which are of interest only to the binder and + linker. In a traditional system, the compiler reads information not + only from the source file being compiled, but also from the centralized + library. This means that the effect of a compilation depends on what + has been previously compiled. In particular: + + * When a unit is `with''ed, the unit seen by the compiler corresponds + to the version of the unit most recently compiled into the library. + + * Inlining is effective only if the necessary body has already been + compiled into the library. + + * Compiling a unit may obsolete other units in the library. + + In GNAT, compiling one unit never affects the compilation of any other + units because the compiler reads only source files. Only changes to + source files can affect the results of a compilation. In particular: + + * When a unit is `with''ed, the unit seen by the compiler corresponds + to the source version of the unit that is currently accessible to + the compiler. + + * Inlining requires the appropriate source files for the package or + subprogram bodies to be available to the compiler. Inlining is + always effective, independent of the order in which units are + complied. + + * Compiling a unit never affects any other compilations. The editing + of sources may cause previous compilations to be out of date if + they depended on the source file being modified. + + The most important result of these differences is that order of + compilation is never significant in GNAT. There is no situation in + which one is required to do one compilation before another. What shows + up as order of compilation requirements in the traditional Ada library + becomes, in GNAT, simple source dependencies; in other words, there is + only a set of rules saying what source files must be present when a + file is compiled. + +  + File: gnat_ug_wnt.info, Node: Compiling Using gcc, Next: Binding Using gnatbind, Prev: The GNAT Compilation Model, Up: Top + + Compiling Using `gcc' + ********************* + + This chapter discusses how to compile Ada programs using the `gcc' + command. It also describes the set of switches that can be used to + control the behavior of the compiler. + + * Menu: + + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + +  + File: gnat_ug_wnt.info, Node: Compiling Programs, Next: Switches for gcc, Up: Compiling Using gcc + + Compiling Programs + ================== + + The first step in creating an executable program is to compile the units + of the program using the `gcc' command. You must compile the following + files: + + * the body file (`.adb') for a library level subprogram or generic + subprogram + + * the spec file (`.ads') for a library level package or generic + package that has no body + + * the body file (`.adb') for a library level package or generic + package that has a body + + + You need _not_ compile the following files + + * the spec of a library unit which has a body + + * subunits + + because they are compiled as part of compiling related units. GNAT + package specs when the corresponding body is compiled, and subunits + when the parent is compiled. If you attempt to compile any of these + files, you will get one of the following error messages (where fff is + the name of the file you compiled): + + No code generated for file FFF (PACKAGE SPEC) + No code generated for file FFF (SUBUNIT) + + The basic command for compiling a file containing an Ada unit is + + $ gcc -c [SWITCHES] `file name' + + where FILE NAME is the name of the Ada file (usually having an extension + `.ads' for a spec or `.adb' for a body). You specify the `-c' switch + to tell `gcc' to compile, but not link, the file. The result of a + successful compilation is an object file, which has the same name as + the source file but an extension of `.o' and an Ada Library Information + (ALI) file, which also has the same name as the source file, but with + `.ali' as the extension. GNAT creates these two output files in the + current directory, but you may specify a source file in any directory + using an absolute or relative path specification containing the + directory information. + + `gcc' is actually a driver program that looks at the extensions of + the file arguments and loads the appropriate compiler. For example, the + GNU C compiler is `cc1', and the Ada compiler is `gnat1'. These + programs are in directories known to the driver program (in some + configurations via environment variables you set), but need not be in + your path. The `gcc' driver also calls the assembler and any other + utilities needed to complete the generation of the required object + files. + + It is possible to supply several file names on the same `gcc' + command. This causes `gcc' to call the appropriate compiler for each + file. For example, the following command lists three separate files to + be compiled: + + $ gcc -c x.adb y.adb z.c + + calls `gnat1' (the Ada compiler) twice to compile `x.adb' and `y.adb', + and `cc1' (the C compiler) once to compile `z.c'. The compiler + generates three object files `x.o', `y.o' and `z.o' and the two ALI + files `x.ali' and `y.ali' from the Ada compilations. Any switches apply + to all the files listed, except for `-gnatX' switches, which apply only + to Ada compilations. + +  + File: gnat_ug_wnt.info, Node: Switches for gcc, Next: Search Paths and the Run-Time Library (RTL), Prev: Compiling Programs, Up: Compiling Using gcc + + Switches for `gcc' + ================== + + The `gcc' command accepts switches that control the compilation + process. These switches are fully described in this section. First we + briefly list all the switches, in alphabetical order, then we describe + the switches in more detail in functionally grouped sections. + + * Menu: + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + `-b TARGET' + Compile your program to run on TARGET, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + TARGET is not the same as your host system. + + `-BDIR' + Load compiler executables (for example, `gnat1', the Ada compiler) + from DIR instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + `gcc' manual page for further details. You would normally use the + `-b' or `-V' switch instead. + + `-c' + Compile. Always use this switch when compiling Ada programs. + + Note: for some other languages when using `gcc', notably in the + case of C and C++, it is possible to use use `gcc' without a `-c' + switch to compile and link in one step. In the case of GNAT, you + cannot use this approach, because the binder must be run and `gcc' + cannot be used to run the GNAT binder. + + `-g' + Generate debugging information. This information is stored in the + object file and copied from there to the final executable file by + the linker, where it can be read by the debugger. You must use the + `-g' switch if you plan on using the debugger. + + `-IDIR' + Direct GNAT to search the DIR directory for source files needed by + the current compilation (*note Search Paths and the Run-Time + Library (RTL)::). + + `-I-' + Except for the source file named in the command line, do not look + for source files in the directory containing the source file named + in the command line (*note Search Paths and the Run-Time Library + (RTL)::). + + `-o FILE' + This switch is used in `gcc' to redirect the generated object file + and its associated ALI file. Beware of this switch with GNAT, + because it may cause the object file and ALI file to have + different names which in turn may confuse the binder and the + linker. + + `-O[N]' + N controls the optimization level. + + n = 0 + No optimization, the default setting if no `-O' appears + + n = 1 + Normal optimization, the default if you specify `-O' without + an operand. + + n = 2 + Extensive optimization + + n = 3 + Extensive optimization with automatic inlining. This applies + only to inlining within a unit. For details on control of + inter-unit inlining see *Note Subprogram Inlining Control::. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-S' + Used in place of `-c' to cause the assembler source file to be + generated, using `.s' as the extension, instead of the object file. + This may be useful if you need to examine the generated assembly + code. + + `-v' + Show commands generated by the `gcc' driver. Normally used only for + debugging purposes or if you need to be sure what version of the + compiler you are executing. + + `-V VER' + Execute VER version of the compiler. This is the `gcc' version, + not the GNAT version. + + `-gnata' + Assertions enabled. `Pragma Assert' and `pragma Debug' to be + activated. + + `-gnatA' + Avoid processing `gnat.adc'. If a gnat.adc file is present, it + will be ignored. + + `-gnatb' + Generate brief messages to `stderr' even if verbose mode set. + + `-gnatc' + Check syntax and semantics only (no code generation attempted). + + `-gnatC' + Compress debug information and external symbol name table entries. + + `-gnatD' + Output expanded source files for source level debugging. This + switch also suppress generation of cross-reference information + (see -gnatx). + + `-gnatecPATH' + Specify a configuration pragma file. (see *Note The Configuration + Pragmas Files::) + + `-gnatemPATH' + Specify a mapping file. (see *Note Units to Sources Mapping + Files::) + + `-gnatE' + Full dynamic elaboration checks. + + `-gnatf' + Full errors. Multiple errors per line, all undefined references. + + `-gnatF' + Externals names are folded to all uppercase. + + `-gnatg' + Internal GNAT implementation mode. This should not be used for + applications programs, it is intended only for use by the compiler + and its run-time library. For documentation, see the GNAT sources. + + `-gnatG' + List generated expanded code in source form. + + `-gnatiC' + Identifier character set (C=1/2/3/4/8/9/p/f/n/w). + + `-gnath' + Output usage information. The output is written to `stdout'. + + `-gnatkN' + Limit file names to N (1-999) characters (`k' = krunch). + + `-gnatl' + Output full source listing with embedded error messages. + + `-gnatmN' + Limit number of detected errors to N (1-999). + + `-gnatn' + Activate inlining across unit boundaries for subprograms for which + pragma `inline' is specified. + + `-gnatN' + Activate front end inlining. + + `-fno-inline' + Suppresses all inlining, even if other optimization or inlining + switches are set. + + `-fstack-check' + Activates stack checking. See separate section on stack checking + for details of the use of this option. + + `-gnato' + Enable numeric overflow checking (which is not normally enabled by + default). Not that division by zero is a separate check that is not + controlled by this switch (division by zero checking is on by + default). + + `-gnatp' + Suppress all checks. + + `-gnatq' + Don't quit; try semantics, even if parse errors. + + `-gnatQ' + Don't quit; generate `ali' and tree files even if illegalities. + + `-gnatP' + Enable polling. This is required on some systems (notably Windows + NT) to obtain asynchronous abort and asynchronous transfer of + control capability. See the description of pragma Polling in the + GNAT Reference Manual for full details. + + `-gnatR[0/1/2/3][s]' + Output representation information for declared types and objects. + + `-gnats' + Syntax check only. + + `-gnatt' + Tree output file to be generated. + + `-gnatT nnn' + Set time slice to specified number of microseconds + + `-gnatu' + List units for this compilation. + + `-gnatU' + Tag all error messages with the unique string "error:" + + `-gnatv' + Verbose mode. Full error output with source lines to `stdout'. + + `-gnatV' + Control level of validity checking. See separate section describing + this feature. + + `-gnatwxxxXXX' + Warning mode where XXX is a string of options describing the exact + warnings that are enabled or disabled. See separate section on + warning control. + + `-gnatWE' + Wide character encoding method (E=n/h/u/s/e/8). + + `-gnatx' + Suppress generation of cross-reference information. + + `-gnaty' + Enable built-in style checks. See separate section describing this + feature. + + `-gnatzM' + Distribution stub generation and compilation (M=r/c for + receiver/caller stubs). + + `-gnat83' + Enforce Ada 83 restrictions. + + `-pass-exit-codes' + Catch exit codes from the compiler and use the most meaningful as + exit status. + + You may combine a sequence of GNAT switches into a single switch. For + example, the combined switch + + -gnatofi3 + + is equivalent to specifying the following sequence of switches: + + -gnato -gnatf -gnati3 + + The following restrictions apply to the combination of switches in this + manner: + + * The switch `-gnatc' if combined with other switches must come + first in the string. + + * The switch `-gnats' if combined with other switches must come + first in the string. + + * Once a "y" appears in the string (that is a use of the `-gnaty' + switch), then all further characters in the switch are interpreted + as style modifiers (see description of `-gnaty'). + + * Once a "d" appears in the string (that is a use of the `-gnatd' + switch), then all further characters in the switch are interpreted + as debug flags (see description of `-gnatd'). + + * Once a "w" appears in the string (that is a use of the `-gnatw' + switch), then all further characters in the switch are interpreted + as warning mode modifiers (see description of `-gnatw'). + + * Once a "V" appears in the string (that is a use of the `-gnatV' + switch), then all further characters in the switch are interpreted + as validity checking options (see description of `-gnatV'). + + +  + File: gnat_ug_wnt.info, Node: Output and Error Message Control, Next: Debugging and Assertion Control, Up: Switches for gcc + + Output and Error Message Control + -------------------------------- + + The standard default format for error messages is called "brief format." + Brief format messages are written to `stderr' (the standard error file) + and have the following form: + + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:4:20: ";" should be "is" + + The first integer after the file name is the line number in the file, + and the second integer is the column number within the line. `glide' + can parse the error messages and point to the referenced character. + The following switches provide control over the error message format: + + `-gnatv' + The v stands for verbose. The effect of this setting is to write + long-format error messages to `stdout' (the standard output file. + The same program compiled with the `-gnatv' switch would generate: + + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + + The vertical bar indicates the location of the error, and the `>>>' + prefix can be used to search for error messages. When this switch + is used the only source lines output are those with errors. + + `-gnatl' + The `l' stands for list. This switch causes a full listing of the + file to be generated. The output might look as follows: + + 1. procedure E is + 2. V : Integer; + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + 5. begin + 6. return Q + Q; + 7. end; + 8. begin + 9. V := X + X; + 10.end E; + + When you specify the `-gnatv' or `-gnatl' switches and standard + output is redirected, a brief summary is written to `stderr' + (standard error) giving the number of error messages and warning + messages generated. + + `-gnatU' + This switch forces all error messages to be preceded by the unique + string "error:". This means that error messages take a few more + characters in space, but allows easy searching for and + identification of error messages. + + `-gnatb' + The `b' stands for brief. This switch causes GNAT to generate the + brief format error messages to `stderr' (the standard error file) + as well as the verbose format message or full listing (which as + usual is written to `stdout' (the standard output file). + + `-gnatmN' + The `m' stands for maximum. N is a decimal integer in the range + of 1 to 999 and limits the number of error messages to be + generated. For example, using `-gnatm2' might yield + + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:5:35: missing ".." + fatal error: maximum errors reached + compilation abandoned + + `-gnatf' + The `f' stands for full. Normally, the compiler suppresses error + messages that are likely to be redundant. This switch causes all + error messages to be generated. In particular, in the case of + references to undefined variables. If a given variable is + referenced several times, the normal format of messages is + e.adb:7:07: "V" is undefined (more references follow) + + where the parenthetical comment warns that there are additional + references to the variable `V'. Compiling the same program with the + `-gnatf' switch yields + + e.adb:7:07: "V" is undefined + e.adb:8:07: "V" is undefined + e.adb:8:12: "V" is undefined + e.adb:8:16: "V" is undefined + e.adb:9:07: "V" is undefined + e.adb:9:12: "V" is undefined + + `-gnatq' + The `q' stands for quit (really "don't quit"). In normal + operation mode, the compiler first parses the program and + determines if there are any syntax errors. If there are, + appropriate error messages are generated and compilation is + immediately terminated. This switch tells GNAT to continue with + semantic analysis even if syntax errors have been found. This may + enable the detection of more errors in a single run. On the other + hand, the semantic analyzer is more likely to encounter some + internal fatal error when given a syntactically invalid tree. + + `-gnatQ' + In normal operation mode, the `ali' file is not generated if any + illegalities are detected in the program. The use of `-gnatQ' + forces generation of the `ali' file. This file is marked as being + in error, so it cannot be used for binding purposes, but it does + contain reasonably complete cross-reference information, and thus + may be useful for use by tools (e.g. semantic browsing tools or + integrated development environments) that are driven from the + `ali' file. + + In addition, if `-gnatt' is also specified, then the tree file is + generated even if there are illegalities. It may be useful in this + case to also specify `-gnatq' to ensure that full semantic + processing occurs. The resulting tree file can be processed by + ASIS, for the purpose of providing partial information about + illegal units, but if the error causes the tree to be badly + malformed, then ASIS may crash during the analysis. + + In addition to error messages, which correspond to illegalities as + defined in the Ada 95 Reference Manual, the compiler detects two kinds + of warning situations. + + First, the compiler considers some constructs suspicious and + generates a warning message to alert you to a possible error. Second, + if the compiler detects a situation that is sure to raise an exception + at run time, it generates a warning message. The following shows an + example of warning messages: + e.adb:4:24: warning: creation of object may raise Storage_Error + e.adb:10:17: warning: static value out of range + e.adb:10:17: warning: "Constraint_Error" will be raised at run time + + GNAT considers a large number of situations as appropriate for the + generation of warning messages. As always, warnings are not definite + indications of errors. For example, if you do an out-of-range + assignment with the deliberate intention of raising a + `Constraint_Error' exception, then the warning that may be issued does + not indicate an error. Some of the situations for which GNAT issues + warnings (at least some of the time) are given in the following list, + which is not necessarily complete. + + * Possible infinitely recursive calls + + * Out-of-range values being assigned + + * Possible order of elaboration problems + + * Unreachable code + + * Fixed-point type declarations with a null range + + * Variables that are never assigned a value + + * Variables that are referenced before being initialized + + * Task entries with no corresponding accept statement + + * Duplicate accepts for the same task entry in a select + + * Objects that take too much storage + + * Unchecked conversion between types of differing sizes + + * Missing return statements along some execution paths in a function + + * Incorrect (unrecognized) pragmas + + * Incorrect external names + + * Allocation from empty storage pool + + * Potentially blocking operations in protected types + + * Suspicious parenthesization of expressions + + * Mismatching bounds in an aggregate + + * Attempt to return local value by reference + + * Unrecognized pragmas + + * Premature instantiation of a generic body + + * Attempt to pack aliased components + + * Out of bounds array subscripts + + * Wrong length on string assignment + + * Violations of style rules if style checking is enabled + + * Unused with clauses + + * Bit_Order usage that does not have any effect + + * Compile time biased rounding of floating-point constant + + * Standard.Duration used to resolve universal fixed expression + + * Dereference of possibly null value + + * Declaration that is likely to cause storage error + + * Internal GNAT unit with'ed by application unit + + * Values known to be out of range at compile time + + * Unreferenced labels and variables + + * Address overlays that could clobber memory + + * Unexpected initialization when address clause present + + * Bad alignment for address clause + + * Useless type conversions + + * Redundant assignment statements + + * Accidental hiding of name by child unit + + * Unreachable code + + * Access before elaboration detected at compile time + + * A range in a `for' loop that is known to be null or might be null + + + The following switches are available to control the handling of warning + messages: + + `-gnatwa (activate all optional errors)' + This switch activates most optional warning messages, see + remaining list in this section for details on optional warning + messages that can be individually controlled. The warnings that + are not turned on by this switch are `-gnatwb' (biased rounding), + `-gnatwd' (implicit dereferencing), and `-gnatwh' (hiding). All + other optional warnings are turned on. + + `-gnatwA (suppress all optional errors)' + This switch suppresses all optional warning messages, see + remaining list in this section for details on optional warning + messages that can be individually controlled. + + `-gnatwb (activate warnings on biased rounding)' + If a static floating-point expression has a value that is exactly + half way between two adjacent machine numbers, then the rules of + Ada (Ada Reference Manual, section 4.9(38)) require that this + rounding be done away from zero, even if the normal unbiased + rounding rules at run time would require rounding towards zero. + This warning message alerts you to such instances where + compile-time rounding and run-time rounding are not equivalent. If + it is important to get proper run-time rounding, then you can + force this by making one of the operands into a variable. The + default is that such warnings are not generated. Note that + `-gnatwa' does not affect the setting of this warning option. + + `-gnatwB (suppress warnings on biased rounding)' + This switch disables warnings on biased rounding. + + `-gnatwc (activate warnings on conditionals)' + This switch activates warnings for conditional expressions used in + tests that are known to be True or False at compile time. The + default is that such warnings are not generated. This warning can + also be turned on using `-gnatwa'. + + `-gnatwC (suppress warnings on conditionals)' + This switch suppresses warnings for conditional expressions used in + tests that are known to be True or False at compile time. + + `-gnatwd (activate warnings on implicit dereferencing)' + If this switch is set, then the use of a prefix of an access type + in an indexed component, slice, or selected component without an + explicit `.all' will generate a warning. With this warning + enabled, access checks occur only at points where an explicit + `.all' appears in the source code (assuming no warnings are + generated as a result of this switch). The default is that such + warnings are not generated. Note that `-gnatwa' does not affect + the setting of this warning option. + + `-gnatwD (suppress warnings on implicit dereferencing)' + This switch suppresses warnings for implicit deferences in indexed + components, slices, and selected components. + + `-gnatwe (treat warnings as errors)' + This switch causes warning messages to be treated as errors. The + warning string still appears, but the warning messages are counted + as errors, and prevent the generation of an object file. + + `-gnatwf (activate warnings on unreferenced formals)' + This switch causes a warning to be generated if a formal parameter + is not referenced in the body of the subprogram. This warning can + also be turned on using `-gnatwa' or `-gnatwu'. + + `-gnatwF (suppress warnings on unreferenced formals)' + This switch suppresses warnings for unreferenced formal + parameters. Note that the combination `-gnatwu' followed by + `-gnatwF' has the effect of warning on unreferenced entities other + than subprogram formals. + + `-gnatwh (activate warnings on hiding)' + This switch activates warnings on hiding declarations. A + declaration is considered hiding if it is for a non-overloadable + entity, and it declares an entity with the same name as some other + entity that is directly or use-visible. The default is that such + warnings are not generated. Note that `-gnatwa' does not affect + the setting of this warning option. + + `-gnatwH (suppress warnings on hiding)' + This switch suppresses warnings on hiding declarations. + + `-gnatwi (activate warnings on implementation units).' + This switch activates warnings for a `with' of an internal GNAT + implementation unit, defined as any unit from the `Ada', + `Interfaces', `GNAT', or `System' hierarchies that is not + documented in either the Ada Reference Manual or the GNAT + Programmer's Reference Manual. Such units are intended only for + internal implementation purposes and should not be `with''ed by + user programs. The default is that such warnings are generated + This warning can also be turned on using `-gnatwa'. + + `-gnatwI (disable warnings on implementation units).' + This switch disables warnings for a `with' of an internal GNAT + implementation unit. + + `-gnatwl (activate warnings on elaboration pragmas)' + This switch activates warnings on missing pragma Elaborate_All + statements. See the section in this guide on elaboration checking + for details on when such pragma should be used. The default is + that such warnings are not generated. This warning can also be + turned on using `-gnatwa'. + + `-gnatwL (suppress warnings on elaboration pragmas)' + This switch suppresses warnings on missing pragma Elaborate_All + statements. See the section in this guide on elaboration checking + for details on when such pragma should be used. + + `-gnatwo (activate warnings on address clause overlays)' + This switch activates warnings for possibly unintended + initialization effects of defining address clauses that cause one + variable to overlap another. The default is that such warnings are + generated. This warning can also be turned on using `-gnatwa'. + + `-gnatwO (suppress warnings on address clause overlays)' + This switch suppresses warnings on possibly unintended + initialization effects of defining address clauses that cause one + variable to overlap another. + + `-gnatwp (activate warnings on ineffective pragma Inlines)' + This switch activates warnings for failure of front end inlining + (activated by `-gnatN') to inline a particular call. There are + many reasons for not being able to inline a call, including most + commonly that the call is too complex to inline. This warning can + also be turned on using `-gnatwa'. + + `-gnatwP (suppress warnings on ineffective pragma Inlines)' + This switch suppresses warnings on ineffective pragma Inlines. If + the inlining mechanism cannot inline a call, it will simply ignore + the request silently. + + `-gnatwr (activate warnings on redundant constructs)' + This switch activates warnings for redundant constructs. The + following is the current list of constructs regarded as redundant: + This warning can also be turned on using `-gnatwa'. + + * Assignment of an item to itself. + + * Type conversion that converts an expression to its own type. + + * Use of the attribute `Base' where `typ'Base' is the same as + `typ'. + + * Use of pragma `Pack' when all components are placed by a + record representation clause. + + `-gnatwR (suppress warnings on redundant constructs)' + This switch suppresses warnings for redundant constructs. + + `-gnatws (suppress all warnings)' + This switch completely suppresses the output of all warning + messages from the GNAT front end. Note that it does not suppress + warnings from the `gcc' back end. To suppress these back end + warnings as well, use the switch `-w' in addition to `-gnatws'. + + `-gnatwu (activate warnings on unused entities)' + This switch activates warnings to be generated for entities that + are defined but not referenced, and for units that are `with''ed + and not referenced. In the case of packages, a warning is also + generated if no entities in the package are referenced. This means + that if the package is referenced but the only references are in + `use' clauses or `renames' declarations, a warning is still + generated. A warning is also generated for a generic package that + is `with''ed but never instantiated. In the case where a package + or subprogram body is compiled, and there is a `with' on the + corresponding spec that is only referenced in the body, a warning + is also generated, noting that the `with' can be moved to the + body. The default is that such warnings are not generated. This + switch also activates warnings on unreferenced formals (it is + includes the effect of `-gnatwf'). This warning can also be + turned on using `-gnatwa'. + + `-gnatwU (suppress warnings on unused entities)' + This switch suppresses warnings for unused entities and packages. + It also turns off warnings on unreferenced formals (and thus + includes the effect of `-gnatwF'). + + A string of warning parameters can be used in the same parameter. + For example: + + -gnatwaLe + + Would turn on all optional warnings except for elaboration pragma + warnings, and also specify that warnings should be treated as + errors. + + `-w' + This switch suppresses warnings from the `gcc' backend. It may be + used in conjunction with `-gnatws' to ensure that all warnings are + suppressed during the entire compilation process. + +  + File: gnat_ug_wnt.info, Node: Debugging and Assertion Control, Next: Run-Time Checks, Prev: Output and Error Message Control, Up: Switches for gcc + + Debugging and Assertion Control + ------------------------------- + + `-gnata' + The pragmas `Assert' and `Debug' normally have no effect and are + ignored. This switch, where `a' stands for assert, causes `Assert' + and `Debug' pragmas to be activated. + + The pragmas have the form: + + pragma Assert (BOOLEAN-EXPRESSION [, + STATIC-STRING-EXPRESSION]) + pragma Debug (PROCEDURE CALL) + + The `Assert' pragma causes BOOLEAN-EXPRESSION to be tested. If + the result is `True', the pragma has no effect (other than + possible side effects from evaluating the expression). If the + result is `False', the exception `Assert_Failure' declared in the + package `System.Assertions' is raised (passing + STATIC-STRING-EXPRESSION, if present, as the message associated + with the exception). If no string expression is given the default + is a string giving the file name and line number of the pragma. + + The `Debug' pragma causes PROCEDURE to be called. Note that + `pragma Debug' may appear within a declaration sequence, allowing + debugging procedures to be called between declarations. + +  + File: gnat_ug_wnt.info, Node: Validity Checking, Next: Style Checking, Prev: Run-Time Control, Up: Switches for gcc + + Validity Checking + ----------------- + + The Ada 95 Reference Manual has specific requirements for checking for + invalid values. In particular, RM 13.9.1 requires that the evaluation + of invalid values (for example from unchecked conversions), not result + in erroneous execution. In GNAT, the result of such an evaluation in + normal default mode is to either use the value unmodified, or to raise + Constraint_Error in those cases where use of the unmodified value would + cause erroneous execution. The cases where unmodified values might lead + to erroneous execution are case statements (where a wild jump might + result from an invalid value), and subscripts on the left hand side + (where memory corruption could occur as a result of an invalid value). + + The `-gnatVx' switch allows more control over the validity checking + mode. The `x' argument here is a string of letters which control which + validity checks are performed in addition to the default checks + described above. + + * `-gnatVc' Validity checks for copies + + The right hand side of assignments, and the initializing values of + object declarations are validity checked. + + * `-gnatVd' Default (RM) validity checks + + Some validity checks are done by default following normal Ada + semantics (RM 13.9.1 (9-11)). A check is done in case statements + that the expression is within the range of the subtype. If it is + not, Constraint_Error is raised. For assignments to array + components, a check is done that the expression used as index is + within the range. If it is not, Constraint_Error is raised. Both + these validity checks may be turned off using switch `-gnatVD'. + They are turned on by default. If `-gnatVD' is specified, a + subsequent switch `-gnatVd' will leave the checks turned on. + Switch `-gnatVD' should be used only if you are sure that all such + expressions have valid values. If you use this switch and invalid + values are present, then the program is erroneous, and wild jumps + or memory overwriting may occur. + + * `-gnatVi' Validity checks for `in' mode parameters + + Arguments for parameters of mode `in' are validity checked in + function and procedure calls at the point of call. + + * `-gnatVm' Validity checks for `in out' mode parameters + + Arguments for parameters of mode `in out' are validity checked in + procedure calls at the point of call. The `'m'' here stands for + modify, since this concerns parameters that can be modified by the + call. Note that there is no specific option to test `out' + parameters, but any reference within the subprogram will be tested + in the usual manner, and if an invalid value is copied back, any + reference to it will be subject to validity checking. + + * `-gnatVo' Validity checks for operator and attribute operands + + Arguments for predefined operators and attributes are validity + checked. This includes all operators in package `Standard', the + shift operators defined as intrinsic in package `Interfaces' and + operands for attributes such as `Pos'. + + * `-gnatVr' Validity checks for function returns + + The expression in `return' statements in functions is validity + checked. + + * `-gnatVs' Validity checks for subscripts + + All subscripts expressions are checked for validity, whether they + appear on the right side or left side (in default mode only left + side subscripts are validity checked). + + * `-gnatVt' Validity checks for tests + + Expressions used as conditions in `if', `while' or `exit' + statements are checked, as well as guard expressions in entry + calls. + + * `-gnatVf' Validity checks for floating-point values + + In the absence of this switch, validity checking occurs only for + discrete values. If `-gnatVf' is specified, then validity checking + also applies for floating-point values, and NaN's and infinities + are considered invalid, as well as out of range values for + constrained types. Note that this means that standard `IEEE' + infinity mode is not allowed. The exact contexts in which + floating-point values are checked depends on the setting of other + options. For example `-gnatVif' or `-gnatVfi' (the order does not + matter) specifies that floating-point parameters of mode `in' + should be validity checked. + + * `-gnatVa' All validity checks + + All the above validity checks are turned on. That is `-gnatVa' is + equivalent to `gnatVcdfimorst'. + + * `-gnatVn' No validity checks + + This switch turns off all validity checking, including the default + checking for case statements and left hand side subscripts. Note + that the use of the switch `-gnatp' supresses all run-time checks, + including validity checks, and thus implies `-gnatVn'. + + + The `-gnatV' switch may be followed by a string of letters to turn on + a series of validity checking options. For example, `-gnatVcr' specifies + that in addition to the default validity checking, copies and function + return expressions be validity checked. In order to make it easier to + specify a set of options, the upper case letters `CDFIMORST' may be + used to turn off the corresponding lower case option, so for example + `-gnatVaM' turns on all validity checking options except for checking + of `in out' procedure arguments. + + The specification of additional validity checking generates extra + code (and in the case of `-gnatva' the code expansion can be + substantial. However, these additional checks can be very useful in + smoking out cases of uninitialized variables, incorrect use of + unchecked conversion, and other errors leading to invalid values. The + use of pragma `Initialize_Scalars' is useful in conjunction with the + extra validity checking, since this ensures that wherever possible + uninitialized variables have invalid values. + + See also the pragma `Validity_Checks' which allows modification of + the validity checking mode at the program source level, and also allows + for temporary disabling of validity checks. + +  + File: gnat_ug_wnt.info, Node: Style Checking, Next: Using gcc for Syntax Checking, Prev: Validity Checking, Up: Switches for gcc + + Style Checking + -------------- + + The -gnatyX switch causes the compiler to enforce specified style + rules. A limited set of style rules has been used in writing the GNAT + sources themselves. This switch allows user programs to activate all or + some of these checks. If the source program fails a specified style + check, an appropriate warning message is given, preceded by the + character sequence "(style)". The string X is a sequence of letters or + digits indicating the particular style checks to be performed. The + following checks are defined: + + `1-9 (specify indentation level)' + If a digit from 1-9 appears in the string after `-gnaty' then + proper indentation is checked, with the digit indicating the + indentation level required. The general style of required + indentation is as specified by the examples in the Ada Reference + Manual. Full line comments must be aligned with the `--' starting + on a column that is a multiple of the alignment level. + + `a (check attribute casing)' + If the letter a appears in the string after `-gnaty' then + attribute names, including the case of keywords such as `digits' + used as attributes names, must be written in mixed case, that is, + the initial letter and any letter following an underscore must be + uppercase. All other letters must be lowercase. + + `b (blanks not allowed at statement end)' + If the letter b appears in the string after `-gnaty' then trailing + blanks are not allowed at the end of statements. The purpose of + this rule, together with h (no horizontal tabs), is to enforce a + canonical format for the use of blanks to separate source tokens. + + `c (check comments)' + If the letter c appears in the string after `-gnaty' then comments + must meet the following set of rules: + + * The "-" that starts the column must either start in column + one, or else at least one blank must precede this sequence. + + * Comments that follow other tokens on a line must have at + least one blank following the "-" at the start of the comment. + + * Full line comments must have two blanks following the "-" + that starts the comment, with the following exceptions. + + * A line consisting only of the "-" characters, possibly + preceded by blanks is permitted. + + * A comment starting with "-x" where x is a special character + is permitted. This alows proper processing of the output + generated by specialized tools including `gnatprep' (where -! + is used) and the SPARK annnotation language (where -# is + used). For the purposes of this rule, a special character is + defined as being in one of the ASCII ranges 16#21#..16#2F# or + 16#3A#..16#3F#. + + * A line consisting entirely of minus signs, possibly preceded + by blanks, is permitted. This allows the construction of box + comments where lines of minus signs are used to form the top + and bottom of the box. + + * If a comment starts and ends with "-" is permitted as long as + at least one blank follows the initial "-". Together with the + preceding rule, this allows the construction of box comments, + as shown in the following example: + --------------------------- + -- This is a box comment -- + -- with two text lines. -- + --------------------------- + + `e (check end/exit labels)' + If the letter e appears in the string after `-gnaty' then optional + labels on `end' statements ending subprograms and on `exit' + statements exiting named loops, are required to be present. + + `f (no form feeds or vertical tabs)' + If the letter f appears in the string after `-gnaty' then neither + form feeds nor vertical tab characters are not permitted in the + source text. + + `h (no horizontal tabs)' + If the letter h appears in the string after `-gnaty' then + horizontal tab characters are not permitted in the source text. + Together with the b (no blanks at end of line) check, this + enforces a canonical form for the use of blanks to separate source + tokens. + + `i (check if-then layout)' + If the letter i appears in the string after `-gnaty', then the + keyword `then' must appear either on the same line as + corresponding `if', or on a line on its own, lined up under the + `if' with at least one non-blank line in between containing all or + part of the condition to be tested. + + `k (check keyword casing)' + If the letter k appears in the string after `-gnaty' then all + keywords must be in lower case (with the exception of keywords + such as `digits' used as attribute names to which this check does + not apply). + + `l (check layout)' + If the letter l appears in the string after `-gnaty' then layout + of statement and declaration constructs must follow the + recommendations in the Ada Reference Manual, as indicated by the + form of the syntax rules. For example an `else' keyword must be + lined up with the corresponding `if' keyword. + + There are two respects in which the style rule enforced by this + check option are more liberal than those in the Ada Reference + Manual. First in the case of record declarations, it is + permissible to put the `record' keyword on the same line as the + `type' keyword, and then the `end' in `end record' must line up + under `type'. For example, either of the following two layouts is + acceptable: + + type q is record + a : integer; + b : integer; + end record; + + type q is + record + a : integer; + b : integer; + end record; + + Second, in the case of a block statement, a permitted alternative + is to put the block label on the same line as the `declare' or + `begin' keyword, and then line the `end' keyword up under the + block label. For example both the following are permitted: + + Block : declare + A : Integer := 3; + begin + Proc (A, A); + end Block; + + Block : + declare + A : Integer := 3; + begin + Proc (A, A); + end Block; + + The same alternative format is allowed for loops. For example, + both of the following are permitted: + + Clear : while J < 10 loop + A (J) := 0; + end loop Clear; + + Clear : + while J < 10 loop + A (J) := 0; + end loop Clear; + + `m (check maximum line length)' + If the letter m appears in the string after `-gnaty' then the + length of source lines must not exceed 79 characters, including + any trailing blanks. The value of 79 allows convenient display on + an 80 character wide device or window, allowing for possible + special treatment of 80 character lines. + + `Mnnn (set maximum line length)' + If the sequence Mnnn, where nnn is a decimal number, appears in + the string after `-gnaty' then the length of lines must not exceed + the given value. + + `n (check casing of entities in Standard)' + If the letter n appears in the string after `-gnaty' then any + identifier from Standard must be cased to match the presentation + in the Ada Reference Manual (for example, `Integer' and + `ASCII.NUL'). + + `o (check order of subprogram bodies)' + If the letter o appears in the string after `-gnaty' then all + subprogram bodies in a given scope (e.g. a package body) must be + in alphabetical order. The ordering rule uses normal Ada rules for + comparing strings, ignoring casing of letters, except that if + there is a trailing numeric suffix, then the value of this suffix + is used in the ordering (e.g. Junk2 comes before Junk10). + + `p (check pragma casing)' + If the letter p appears in the string after `-gnaty' then pragma + names must be written in mixed case, that is, the initial letter + and any letter following an underscore must be uppercase. All + other letters must be lowercase. + + `r (check references)' + If the letter r appears in the string after `-gnaty' then all + identifier references must be cased in the same way as the + corresponding declaration. No specific casing style is imposed on + identifiers. The only requirement is for consistency of references + with declarations. + + `s (check separate specs)' + If the letter s appears in the string after `-gnaty' then separate + declarations ("specs") are required for subprograms (a body is not + allowed to serve as its own declaration). The only exception is + that parameterless library level procedures are not required to + have a separate declaration. This exception covers the most + frequent form of main program procedures. + + `t (check token spacing)' + If the letter t appears in the string after `-gnaty' then the + following token spacing rules are enforced: + + * The keywords `abs' and `not' must be followed by a space. + + * The token `=>' must be surrounded by spaces. + + * The token `<>' must be preceded by a space or a left + parenthesis. + + * Binary operators other than `**' must be surrounded by spaces. + There is no restriction on the layout of the `**' binary + operator. + + * Colon must be surrounded by spaces. + + * Colon-equal (assignment) must be surrounded by spaces. + + * Comma must be the first non-blank character on the line, or be + immediately preceded by a non-blank character, and must be + followed by a space. + + * If the token preceding a left paren ends with a letter or + digit, then a space must separate the two tokens. + + * A right parenthesis must either be the first non-blank + character on a line, or it must be preceded by a non-blank + character. + + * A semicolon must not be preceded by a space, and must not be + followed by a non-blank character. + + * A unary plus or minus may not be followed by a space. + + * A vertical bar must be surrounded by spaces. + + In the above rules, appearing in column one is always permitted, + that is, counts as meeting either a requirement for a required + preceding space, or as meeting a requirement for no preceding + space. + + Appearing at the end of a line is also always permitted, that is, + counts as meeting either a requirement for a following space, or + as meeting a requirement for no following space. + + If any of these style rules is violated, a message is generated giving + details on the violation. The initial characters of such messages are + always "(style)". Note that these messages are treated as warning + messages, so they normally do not prevent the generation of an object + file. The `-gnatwe' switch can be used to treat warning messages, + including style messages, as fatal errors. + + The switch `-gnaty' on its own (that is not followed by any letters or + digits), is equivalent to `gnaty3abcefhiklmprst', that is all checking + options are enabled with the exception of -gnatyo, with an indentation + level of 3. This is the standard checking option that is used for the + GNAT sources. + +  + File: gnat_ug_wnt.info, Node: Run-Time Checks, Next: Stack Overflow Checking, Prev: Debugging and Assertion Control, Up: Switches for gcc + + Run-Time Checks + --------------- + + If you compile with the default options, GNAT will insert many run-time + checks into the compiled code, including code that performs range + checking against constraints, but not arithmetic overflow checking for + integer operations (including division by zero) or checks for access + before elaboration on subprogram calls. All other run-time checks, as + required by the Ada 95 Reference Manual, are generated by default. The + following `gcc' switches refine this default behavior: + + `-gnatp' + Suppress all run-time checks as though `pragma Suppress + (all_checks') had been present in the source. Validity checks are + also suppressed (in other words `-gnatp' also implies `-gnatVn'. + Use this switch to improve the performance of the code at the + expense of safety in the presence of invalid data or program bugs. + + `-gnato' + Enables overflow checking for integer operations. This causes + GNAT to generate slower and larger executable programs by adding + code to check for overflow (resulting in raising + `Constraint_Error' as required by standard Ada semantics). These + overflow checks correspond to situations in which the true value + of the result of an operation may be outside the base range of the + result type. The following example shows the distinction: + + X1 : Integer := Integer'Last; + X2 : Integer range 1 .. 5 := 5; + ... + X1 := X1 + 1; -- `-gnato' required to catch the Constraint_Error + X2 := X2 + 1; -- range check, `-gnato' has no effect here + + Here the first addition results in a value that is outside the + base range of Integer, and hence requires an overflow check for + detection of the constraint error. The second increment operation + results in a violation of the explicit range constraint, and such + range checks are always performed. Basically the compiler can + assume that in the absence of the `-gnato' switch that any value + of type `xxx' is in range of the base type of `xxx'. + + Note that the `-gnato' switch does not affect the code generated + for any floating-point operations; it applies only to integer + semantics). For floating-point, GNAT has the `Machine_Overflows' + attribute set to `False' and the normal mode of operation is to + generate IEEE NaN and infinite values on overflow or invalid + operations (such as dividing 0.0 by 0.0). + + The reason that we distinguish overflow checking from other kinds + of range constraint checking is that a failure of an overflow + check can generate an incorrect value, but cannot cause erroneous + behavior. This is unlike the situation with a constraint check on + an array subscript, where failure to perform the check can result + in random memory description, or the range check on a case + statement, where failure to perform the check can cause a wild + jump. + + Note again that `-gnato' is off by default, so overflow checking is + not performed in default mode. This means that out of the box, + with the default settings, GNAT does not do all the checks + expected from the language description in the Ada Reference + Manual. If you want all constraint checks to be performed, as + described in this Manual, then you must explicitly use the -gnato + switch either on the `gnatmake' or `gcc' command. + + `-gnatE' + Enables dynamic checks for access-before-elaboration on subprogram + calls and generic instantiations. For full details of the effect + and use of this switch, *Note Compiling Using gcc::. + + The setting of these switches only controls the default setting of the + checks. You may modify them using either `Suppress' (to remove checks) + or `Unsuppress' (to add back suppressed checks) pragmas in the program + source. + +  + File: gnat_ug_wnt.info, Node: Stack Overflow Checking, Next: Run-Time Control, Prev: Run-Time Checks, Up: Switches for gcc + + Stack Overflow Checking + ----------------------- + + For most operating systems, `gcc' does not perform stack overflow + checking by default. This means that if the main environment task or + some other task exceeds the available stack space, then unpredictable + behavior will occur. + + To activate stack checking, compile all units with the gcc option + `-fstack-check'. For example: + + gcc -c -fstack-check package1.adb + + Units compiled with this option will generate extra instructions to + check that any use of the stack (for procedure calls or for declaring + local variables in declare blocks) do not exceed the available stack + space. If the space is exceeded, then a `Storage_Error' exception is + raised. + + For declared tasks, the stack size is always controlled by the size + given in an applicable `Storage_Size' pragma (or is set to the default + size if no pragma is used. + + For the environment task, the stack size depends on system defaults + and is unknown to the compiler. The stack may even dynamically grow on + some systems, precluding the normal Ada semantics for stack overflow. + In the worst case, unbounded stack usage, causes unbounded stack + expansion resulting in the system running out of virtual memory. + + The stack checking may still work correctly if a fixed size stack is + allocated, but this cannot be guaranteed. To ensure that a clean + exception is signalled for stack overflow, set the environment variable + `GNAT_STACK_LIMIT' to indicate the maximum stack area that can be used, + as in: + + SET GNAT_STACK_LIMIT 1600 + + The limit is given in kilobytes, so the above declaration would set the + stack limit of the environment task to 1.6 megabytes. Note that the + only purpose of this usage is to limit the amount of stack used by the + environment task. If it is necessary to increase the amount of stack + for the environment task, then this is an operating systems issue, and + must be addressed with the appropriate operating systems commands. + +  + File: gnat_ug_wnt.info, Node: Run-Time Control, Next: Validity Checking, Prev: Stack Overflow Checking, Up: Switches for gcc + + Run-Time Control + ---------------- + + `-gnatT nnn' + The `gnatT' switch can be used to specify the time-slicing value + to be used for task switching between equal priority tasks. The + value `nnn' is given in microseconds as a decimal integer. + + Setting the time-slicing value is only effective if the underlying + thread control system can accommodate time slicing. Check the + documentation of your operating system for details. Note that the + time-slicing value can also be set by use of pragma `Time_Slice' + or by use of the `t' switch in the gnatbind step. The pragma + overrides a command line argument if both are present, and the `t' + switch for gnatbind overrides both the pragma and the `gcc' + command line switch. + +  + File: gnat_ug_wnt.info, Node: Using gcc for Syntax Checking, Next: Using gcc for Semantic Checking, Prev: Style Checking, Up: Switches for gcc + + Using `gcc' for Syntax Checking + ------------------------------- + + `-gnats' + The `s' stands for syntax. + + Run GNAT in syntax checking only mode. For example, the command + + $ gcc -c -gnats x.adb + + compiles file `x.adb' in syntax-check-only mode. You can check a + series of files in a single command , and can use wild cards to + specify such a group of files. Note that you must specify the + `-c' (compile only) flag in addition to the `-gnats' flag. . + + You may use other switches in conjunction with `-gnats'. In + particular, `-gnatl' and `-gnatv' are useful to control the format + of any generated error messages. + + The output is simply the error messages, if any. No object file or + ALI file is generated by a syntax-only compilation. Also, no units + other than the one specified are accessed. For example, if a unit + `X' `with''s a unit `Y', compiling unit `X' in syntax check only + mode does not access the source file containing unit `Y'. + + Normally, GNAT allows only a single unit in a source file. + However, this restriction does not apply in syntax-check-only + mode, and it is possible to check a file containing multiple + compilation units concatenated together. This is primarily used by + the `gnatchop' utility (*note Renaming Files Using gnatchop::). + +  + File: gnat_ug_wnt.info, Node: Using gcc for Semantic Checking, Next: Compiling Ada 83 Programs, Prev: Using gcc for Syntax Checking, Up: Switches for gcc + + Using `gcc' for Semantic Checking + --------------------------------- + + `-gnatc' + The `c' stands for check. Causes the compiler to operate in + semantic check mode, with full checking for all illegalities + specified in the Ada 95 Reference Manual, but without generation + of any object code (no object file is generated). + + Because dependent files must be accessed, you must follow the GNAT + semantic restrictions on file structuring to operate in this mode: + + * The needed source files must be accessible (*note Search + Paths and the Run-Time Library (RTL)::). + + * Each file must contain only one compilation unit. + + * The file name and unit name must match (*note File Naming + Rules::). + + The output consists of error messages as appropriate. No object + file is generated. An `ALI' file is generated for use in the + context of cross-reference tools, but this file is marked as not + being suitable for binding (since no object file is generated). + The checking corresponds exactly to the notion of legality in the + Ada 95 Reference Manual. + + Any unit can be compiled in semantics-checking-only mode, including + units that would not normally be compiled (subunits, and + specifications where a separate body is present). + +  + File: gnat_ug_wnt.info, Node: Compiling Ada 83 Programs, Next: Character Set Control, Prev: Using gcc for Semantic Checking, Up: Switches for gcc + + Compiling Ada 83 Programs + ------------------------- + + `-gnat83' + Although GNAT is primarily an Ada 95 compiler, it accepts this + switch to specify that an Ada 83 program is to be compiled in + Ada83 mode. If you specify this switch, GNAT rejects most Ada 95 + extensions and applies Ada 83 semantics where this can be done + easily. It is not possible to guarantee this switch does a perfect + job; for example, some subtle tests, such as are found in earlier + ACVC tests (that have been removed from the ACVC suite for Ada + 95), may not compile correctly. However, for most purposes, using + this switch should help to ensure that programs that compile + correctly under the `-gnat83' switch can be ported easily to an + Ada 83 compiler. This is the main use of the switch. + + With few exceptions (most notably the need to use `<>' on + unconstrained generic formal parameters, the use of the new Ada 95 + keywords, and the use of packages with optional bodies), it is not + necessary to use the `-gnat83' switch when compiling Ada 83 + programs, because, with rare exceptions, Ada 95 is upwardly + compatible with Ada 83. This means that a correct Ada 83 program + is usually also a correct Ada 95 program. + +  + File: gnat_ug_wnt.info, Node: Character Set Control, Next: File Naming Control, Prev: Compiling Ada 83 Programs, Up: Switches for gcc + + Character Set Control + --------------------- + + `-gnatiC' + Normally GNAT recognizes the Latin-1 character set in source + program identifiers, as described in the Ada 95 Reference Manual. + This switch causes GNAT to recognize alternate character sets in + identifiers. C is a single character indicating the character + set, as follows: + + `1' + Latin-1 identifiers + + `2' + Latin-2 letters allowed in identifiers + + `3' + Latin-3 letters allowed in identifiers + + `4' + Latin-4 letters allowed in identifiers + + `5' + Latin-5 (Cyrillic) letters allowed in identifiers + + `9' + Latin-9 letters allowed in identifiers + + `p' + IBM PC letters (code page 437) allowed in identifiers + + `8' + IBM PC letters (code page 850) allowed in identifiers + + `f' + Full upper-half codes allowed in identifiers + + `n' + No upper-half codes allowed in identifiers + + `w' + Wide-character codes (that is, codes greater than 255) + allowed in identifiers + + *Note Foreign Language Representation::, for full details on the + implementation of these character sets. + + `-gnatWE' + Specify the method of encoding for wide characters. E is one of + the following: + + `h' + Hex encoding (brackets coding also recognized) + + `u' + Upper half encoding (brackets encoding also recognized) + + `s' + Shift/JIS encoding (brackets encoding also recognized) + + `e' + EUC encoding (brackets encoding also recognized) + + `8' + UTF-8 encoding (brackets encoding also recognized) + + `b' + Brackets encoding only (default value) For full details on + the these encoding methods see *Note Wide Character Encodings::. + Note that brackets coding is always accepted, even if one of the + other options is specified, so for example `-gnatW8' specifies + that both brackets and `UTF-8' encodings will be recognized. The + units that are with'ed directly or indirectly will be scanned + using the specified representation scheme, and so if one of the + non-brackets scheme is used, it must be used consistently + throughout the program. However, since brackets encoding is always + recognized, it may be conveniently used in standard libraries, + allowing these libraries to be used with any of the available + coding schemes. scheme. If no `-gnatW?' parameter is present, + then the default representation is Brackets encoding only. + + Note that the wide character representation that is specified + (explicitly or by default) for the main program also acts as the + default encoding used for Wide_Text_IO files if not specifically + overridden by a WCEM form parameter. + +  + File: gnat_ug_wnt.info, Node: File Naming Control, Next: Subprogram Inlining Control, Prev: Character Set Control, Up: Switches for gcc + + File Naming Control + ------------------- + + `-gnatkN' + Activates file name "krunching". N, a decimal integer in the range + 1-999, indicates the maximum allowable length of a file name (not + including the `.ads' or `.adb' extension). The default is not to + enable file name krunching. + + For the source file naming rules, *Note File Naming Rules::. + +  + File: gnat_ug_wnt.info, Node: Subprogram Inlining Control, Next: Auxiliary Output Control, Prev: File Naming Control, Up: Switches for gcc + + Subprogram Inlining Control + --------------------------- + + `-gnatn' + The `n' here is intended to suggest the first syllable of the word + "inline". GNAT recognizes and processes `Inline' pragmas. + However, for the inlining to actually occur, optimization must be + enabled. To enable inlining across unit boundaries, this is, + inlining a call in one unit of a subprogram declared in a + `with''ed unit, you must also specify this switch. In the absence + of this switch, GNAT does not attempt inlining across units and + does not need to access the bodies of subprograms for which + `pragma Inline' is specified if they are not in the current unit. + + If you specify this switch the compiler will access these bodies, + creating an extra source dependency for the resulting object file, + and where possible, the call will be inlined. For further details + on when inlining is possible see *Note Inlining of Subprograms::. + + `-gnatN' + The front end inlining activated by this switch is generally more + extensive, and quite often more effective than the standard + `-gnatn' inlining mode. It will also generate additional + dependencies. + +  + File: gnat_ug_wnt.info, Node: Auxiliary Output Control, Next: Debugging Control, Prev: Subprogram Inlining Control, Up: Switches for gcc + + Auxiliary Output Control + ------------------------ + + `-gnatt' + Causes GNAT to write the internal tree for a unit to a file (with + the extension `.adt'. This not normally required, but is used by + separate analysis tools. Typically these tools do the necessary + compilations automatically, so you should not have to specify this + switch in normal operation. + + `-gnatu' + Print a list of units required by this compilation on `stdout'. + The listing includes all units on which the unit being compiled + depends either directly or indirectly. + + `-pass-exit-codes' + If this switch is not used, the exit code returned by `gcc' when + compiling multiple files indicates whether all source files have + been successfully used to generate object files or not. + + When `-pass-exit-codes' is used, `gcc' exits with an extended exit + status and allows an integrated development environment to better + react to a compilation failure. Those exit status are: + + 5 + There was an error in at least one source file. + + 3 + At least one source file did not generate an object file. + + 2 + The compiler died unexpectedly (internal error for example). + + 0 + An object file has been generated for every source file. + +  + File: gnat_ug_wnt.info, Node: Debugging Control, Next: Units to Sources Mapping Files, Prev: Auxiliary Output Control, Up: Switches for gcc + + Debugging Control + ----------------- + + `-gnatdX' + Activate internal debugging switches. X is a letter or digit, or + string of letters or digits, which specifies the type of debugging + outputs desired. Normally these are used only for internal + development or system debugging purposes. You can find full + documentation for these switches in the body of the `Debug' unit + in the compiler source file `debug.adb'. + + `-gnatG' + This switch causes the compiler to generate auxiliary output + containing a pseudo-source listing of the generated expanded code. + Like most Ada compilers, GNAT works by first transforming the high + level Ada code into lower level constructs. For example, tasking + operations are transformed into calls to the tasking run-time + routines. A unique capability of GNAT is to list this expanded + code in a form very close to normal Ada source. This is very + useful in understanding the implications of various Ada usage on + the efficiency of the generated code. There are many cases in Ada + (e.g. the use of controlled types), where simple Ada statements can + generate a lot of run-time code. By using `-gnatG' you can identify + these cases, and consider whether it may be desirable to modify + the coding approach to improve efficiency. + + The format of the output is very similar to standard Ada source, + and is easily understood by an Ada programmer. The following + special syntactic additions correspond to low level features used + in the generated code that do not have any exact analogies in pure + Ada source form. The following is a partial list of these special + constructions. See the specification of package `Sprint' in file + `sprint.ads' for a full list. + + `new XXX [storage_pool = YYY]' + Shows the storage pool being used for an allocator. + + `at end PROCEDURE-NAME;' + Shows the finalization (cleanup) procedure for a scope. + + `(if EXPR then EXPR else EXPR)' + Conditional expression equivalent to the `x?y:z' construction + in C. + + `TARGET^(SOURCE)' + A conversion with floating-point truncation instead of + rounding. + + `TARGET?(SOURCE)' + A conversion that bypasses normal Ada semantic checking. In + particular enumeration types and fixed-point types are + treated simply as integers. + + `TARGET?^(SOURCE)' + Combines the above two cases. + + `X #/ Y' + `X #mod Y' + `X #* Y' + `X #rem Y' + A division or multiplication of fixed-point values which are + treated as integers without any kind of scaling. + + `free EXPR [storage_pool = XXX]' + Shows the storage pool associated with a `free' statement. + + `freeze TYPENAME [ACTIONS]' + Shows the point at which TYPENAME is frozen, with possible + associated actions to be performed at the freeze point. + + `reference ITYPE' + Reference (and hence definition) to internal type ITYPE. + + `FUNCTION-NAME! (ARG, ARG, ARG)' + Intrinsic function call. + + `LABELNAME : label' + Declaration of label LABELNAME. + + `EXPR && EXPR && EXPR ... && EXPR' + A multiple concatenation (same effect as EXPR & EXPR & EXPR, + but handled more efficiently). + + `[constraint_error]' + Raise the `Constraint_Error' exception. + + `EXPRESSION'reference' + A pointer to the result of evaluating EXPRESSION. + + `TARGET-TYPE!(SOURCE-EXPRESSION)' + An unchecked conversion of SOURCE-EXPRESSION to TARGET-TYPE. + + `[NUMERATOR/DENOMINATOR]' + Used to represent internal real literals (that) have no exact + representation in base 2-16 (for example, the result of + compile time evaluation of the expression 1.0/27.0). + + `-gnatD' + This switch is used in conjunction with `-gnatG' to cause the + expanded source, as described above to be written to files + with names `xxx.dg', where `xxx' is the normal file name, for + example, if the source file name is `hello.adb', then a file + `hello.adb.dg' will be written. The debugging information + generated by the `gcc' `-g' switch will refer to the generated + `xxx.dg' file. This allows you to do source level debugging + using the generated code which is sometimes useful for + complex code, for example to find out exactly which part of a + complex construction raised an exception. This switch also + suppress generation of cross-reference information (see + -gnatx). + + `-gnatC' + In the generated debugging information, and also in the case + of long external names, the compiler uses a compression + mechanism if the name is very long. This compression method + uses a checksum, and avoids trouble on some operating systems + which have difficulty with very long names. The `-gnatC' + switch forces this compression approach to be used on all + external names and names in the debugging information tables. + This reduces the size of the generated executable, at the + expense of making the naming scheme more complex. The + compression only affects the qualification of the name. Thus + a name in the source: + + Very_Long_Package.Very_Long_Inner_Package.Var + + would normally appear in these tables as: + + very_long_package__very_long_inner_package__var + + but if the `-gnatC' switch is used, then the name appears as + + XCb7e0c705__var + + Here b7e0c705 is a compressed encoding of the qualification + prefix. The GNAT Ada aware version of GDB understands these + encoded prefixes, so if this debugger is used, the encoding + is largely hidden from the user of the compiler. + + `-gnatR[0|1|2|3][s]' + This switch controls output from the compiler of a listing showing + representation information for declared types and objects. For + `-gnatR0', no information is output (equivalent to omitting the + `-gnatR' switch). For `-gnatR1' (which is the default, so `-gnatR' + with no parameter has the same effect), size and alignment + information is listed for declared array and record types. For + `-gnatR2', size and alignment information is listed for all + expression information for values that are computed at run time for + variant records. These symbolic expressions have a mostly obvious + format with #n being used to represent the value of the n'th + discriminant. See source files `repinfo.ads/adb' in the `GNAT' + sources for full detalis on the format of `-gnatR3' output. If the + switch is followed by an s (e.g. `-gnatR2s'), then the output is + to a file with the name `file.rep' where file is the name of the + corresponding source file. + + `-gnatx' + Normally the compiler generates full cross-referencing information + in the `ALI' file. This information is used by a number of tools, + including `gnatfind' and `gnatxref'. The -gnatx switch suppresses + this information. This saves some space and may slightly speed up + compilation, but means that these tools cannot be used. + +  + File: gnat_ug_wnt.info, Node: Units to Sources Mapping Files, Prev: Debugging Control, Up: Switches for gcc + + Units to Sources Mapping Files + ------------------------------ + + `-gnatemPATH' + A mapping file is a way to communicate to the compiler two + mappings: from unit names to file names (without any directory + information) and from file names to path names (with full + directory information). These mappings are used by the compiler to + short-circuit the path search. + + A mapping file is a sequence of sets of three lines. In each set, + the first line is the unit name, in lower case, with "%s" appended + for specifications and "%b" appended for bodies; the second line + is the file name; and the third line is the path name. + + Example: + main%b + main.2.ada + /gnat/project1/sources/main.2.ada + + When the switch `-gnatem' is specified, the compiler will create + in memory the two mappings from the specified file. If there is + any problem (non existent file, truncated file or duplicate + entries), no mapping will be created. + + Several `-gnatem' switches may be specified; however, only the last + one on the command line will be taken into account. + + When using a project file, `gnatmake' create a temporary mapping + file and communicates it to the compiler using this switch. + +  + File: gnat_ug_wnt.info, Node: Search Paths and the Run-Time Library (RTL), Next: Order of Compilation Issues, Prev: Switches for gcc, Up: Compiling Using gcc + + Search Paths and the Run-Time Library (RTL) + =========================================== + + With the GNAT source-based library system, the compiler must be able to + find source files for units that are needed by the unit being compiled. + Search paths are used to guide this process. + + The compiler compiles one source file whose name must be given + explicitly on the command line. In other words, no searching is done + for this file. To find all other source files that are needed (the most + common being the specs of units), the compiler examines the following + directories, in the following order: + + 1. The directory containing the source file of the main unit being + compiled (the file name on the command line). + + 2. Each directory named by an `-I' switch given on the `gcc' command + line, in the order given. + + 3. Each of the directories listed in the value of the + `ADA_INCLUDE_PATH' environment variable. Construct this value + exactly as the `PATH' environment variable: a list of directory + names separated by colons (semicolons when working with the NT + version). + + 4. The content of the "ada_source_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as + the GNAT Run Time Library (RTL) source files. *Note Installing an + Ada Library:: + + Specifying the switch `-I-' inhibits the use of the directory + containing the source file named in the command line. You can still + have this directory on your search path, but in this case it must be + explicitly requested with a `-I' switch. + + Specifying the switch `-nostdinc' inhibits the search of the default + location for the GNAT Run Time Library (RTL) source files. + + The compiler outputs its object files and ALI files in the current + working directory. Caution: The object file can be redirected with the + `-o' switch; however, `gcc' and `gnat1' have not been coordinated on + this so the ALI file will not go to the right place. Therefore, you + should avoid using the `-o' switch. + + The packages `Ada', `System', and `Interfaces' and their children + make up the GNAT RTL, together with the simple `System.IO' package used + in the "Hello World" example. The sources for these units are needed by + the compiler and are kept together in one directory. Not all of the + bodies are needed, but all of the sources are kept together anyway. In + a normal installation, you need not specify these directory names when + compiling or binding. Either the environment variables or the built-in + defaults cause these files to be found. + + In addition to the language-defined hierarchies (System, Ada and + Interfaces), the GNAT distribution provides a fourth hierarchy, + consisting of child units of GNAT. This is a collection of generally + useful routines. See the GNAT Reference Manual for further details. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + +  + File: gnat_ug_wnt.info, Node: Order of Compilation Issues, Next: Examples, Prev: Search Paths and the Run-Time Library (RTL), Up: Compiling Using gcc + + Order of Compilation Issues + =========================== + + If, in our earlier example, there was a spec for the `hello' procedure, + it would be contained in the file `hello.ads'; yet this file would not + have to be explicitly compiled. This is the result of the model we + chose to implement library management. Some of the consequences of this + model are as follows: + + * There is no point in compiling specs (except for package specs + with no bodies) because these are compiled as needed by clients. If + you attempt a useless compilation, you will receive an error + message. It is also useless to compile subunits because they are + compiled as needed by the parent. + + * There are no order of compilation requirements: performing a + compilation never obsoletes anything. The only way you can obsolete + something and require recompilations is to modify one of the + source files on which it depends. + + * There is no library as such, apart from the ALI files (*note The + Ada Library Information Files::, for information on the format of + these files). For now we find it convenient to create separate ALI + files, but eventually the information therein may be incorporated + into the object file directly. + + * When you compile a unit, the source files for the specs of all + units that it `with''s, all its subunits, and the bodies of any + generics it instantiates must be available (reachable by the + search-paths mechanism described above), or you will receive a + fatal error message. + +  + File: gnat_ug_wnt.info, Node: Examples, Prev: Order of Compilation Issues, Up: Compiling Using gcc + + Examples + ======== + + The following are some typical Ada compilation command line examples: + + `$ gcc -c xyz.adb' + Compile body in file `xyz.adb' with all default options. + + `$ gcc -c -O2 -gnata xyz-def.adb' + Compile the child unit package in file `xyz-def.adb' with extensive + optimizations, and pragma `Assert'/`Debug' statements enabled. + + `$ gcc -c -gnatc abc-def.adb' + Compile the subunit in file `abc-def.adb' in semantic-checking-only + mode. + +  + File: gnat_ug_wnt.info, Node: Binding Using gnatbind, Next: Linking Using gnatlink, Prev: Compiling Using gcc, Up: Top + + Binding Using `gnatbind' + ************************ + + * Menu: + + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + + This chapter describes the GNAT binder, `gnatbind', which is used to + bind compiled GNAT objects. The `gnatbind' program performs four + separate functions: + + 1. Checks that a program is consistent, in accordance with the rules + in Chapter 10 of the Ada 95 Reference Manual. In particular, error + messages are generated if a program uses inconsistent versions of a + given unit. + + 2. Checks that an acceptable order of elaboration exists for the + program and issues an error message if it cannot find an order of + elaboration that satisfies the rules in Chapter 10 of the Ada 95 + Language Manual. + + 3. Generates a main program incorporating the given elaboration order. + This program is a small Ada package (body and spec) that must be + subsequently compiled using the GNAT compiler. The necessary + compilation step is usually performed automatically by `gnatlink'. + The two most important functions of this program are to call the + elaboration routines of units in an appropriate order and to call + the main program. + + 4. Determines the set of object files required by the given main + program. This information is output in the forms of comments in + the generated program, to be read by the `gnatlink' utility used + to link the Ada application. + +  + File: gnat_ug_wnt.info, Node: Running gnatbind, Next: Generating the Binder Program in C, Up: Binding Using gnatbind + + Running `gnatbind' + ================== + + The form of the `gnatbind' command is + + $ gnatbind [SWITCHES] MAINPROG[.ali] [SWITCHES] + + where MAINPROG.adb is the Ada file containing the main program unit + body. If no switches are specified, `gnatbind' constructs an Ada + package in two files which names are `b~ADA_MAIN.ads', and + `b~ADA_MAIN.adb'. For example, if given the parameter `hello.ali', for + a main program contained in file `hello.adb', the binder output files + would be `b~hello.ads' and `b~hello.adb'. + + When doing consistency checking, the binder takes into consideration + any source files it can locate. For example, if the binder determines + that the given main program requires the package `Pack', whose `.ali' + file is `pack.ali' and whose corresponding source spec file is + `pack.ads', it attempts to locate the source file `pack.ads' (using the + same search path conventions as previously described for the `gcc' + command). If it can locate this source file, it checks that the time + stamps or source checksums of the source and its references to in `ali' + files match. In other words, any `ali' files that mentions this spec + must have resulted from compiling this version of the source file (or + in the case where the source checksums match, a version close enough + that the difference does not matter). + + The effect of this consistency checking, which includes source + files, is that the binder ensures that the program is consistent with + the latest version of the source files that can be located at bind + time. Editing a source file without compiling files that depend on the + source file cause error messages to be generated by the binder. + + For example, suppose you have a main program `hello.adb' and a + package `P', from file `p.ads' and you perform the following steps: + + 1. Enter `gcc -c hello.adb' to compile the main program. + + 2. Enter `gcc -c p.ads' to compile package `P'. + + 3. Edit file `p.ads'. + + 4. Enter `gnatbind hello'. + + At this point, the file `p.ali' contains an out-of-date time stamp + because the file `p.ads' has been edited. The attempt at binding fails, + and the binder generates the following error messages: + + error: "hello.adb" must be recompiled ("p.ads" has been modified) + error: "p.ads" has been modified and must be recompiled + + Now both files must be recompiled as indicated, and then the bind can + succeed, generating a main program. You need not normally be concerned + with the contents of this file, but it is similar to the following which + is the binder file generated for a simple "hello world" program. + + -- The package is called Ada_Main unless this name is actually used + -- as a unit name in the partition, in which case some other unique + -- name is used. + + with System; + package ada_main is + + Elab_Final_Code : Integer; + pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code"); + + -- The main program saves the parameters (argument count, + -- argument values, environment pointer) in global variables + -- for later access by other units including + -- Ada.Command_Line. + + gnat_argc : Integer; + gnat_argv : System.Address; + gnat_envp : System.Address; + + -- The actual variables are stored in a library routine. This + -- is useful for some shared library situations, where there + -- are problems if variables are not in the library. + + pragma Import (C, gnat_argc); + pragma Import (C, gnat_argv); + pragma Import (C, gnat_envp); + + -- The exit status is similarly an external location + + gnat_exit_status : Integer; + pragma Import (C, gnat_exit_status); + + GNAT_Version : constant String := + "GNAT Version: 3.15w (20010315)"; + pragma Export (C, GNAT_Version, "__gnat_version"); + + -- This is the generated adafinal routine that performs + -- finalization at the end of execution. In the case where + -- Ada is the main program, this main program makes a call + -- to adafinal at program termination. + + procedure adafinal; + pragma Export (C, adafinal, "adafinal"); + + -- This is the generated adainit routine that performs + -- initialization at the start of execution. In the case + -- where Ada is the main program, this main program makes + -- a call to adainit at program startup. + + procedure adainit; + pragma Export (C, adainit, "adainit"); + + -- This routine is called at the start of execution. It is + -- a dummy routine that is used by the debugger to breakpoint + -- at the start of execution. + + procedure Break_Start; + pragma Import (C, Break_Start, "__gnat_break_start"); + + -- This is the actual generated main program (it would be + -- suppressed if the no main program switch were used). As + -- required by standard system conventions, this program has + -- the external name main. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer; + pragma Export (C, main, "main"); + + -- The following set of constants give the version + -- identification values for every unit in the bound + -- partition. This identification is computed from all + -- dependent semantic units, and corresponds to the + -- string that would be returned by use of the + -- Body_Version or Version attributes. + + type Version_32 is mod 2 ** 32; + u00001 : constant Version_32 := 16#7880BEB3#; + u00002 : constant Version_32 := 16#0D24CBD0#; + u00003 : constant Version_32 := 16#3283DBEB#; + u00004 : constant Version_32 := 16#2359F9ED#; + u00005 : constant Version_32 := 16#664FB847#; + u00006 : constant Version_32 := 16#68E803DF#; + u00007 : constant Version_32 := 16#5572E604#; + u00008 : constant Version_32 := 16#46B173D8#; + u00009 : constant Version_32 := 16#156A40CF#; + u00010 : constant Version_32 := 16#033DABE0#; + u00011 : constant Version_32 := 16#6AB38FEA#; + u00012 : constant Version_32 := 16#22B6217D#; + u00013 : constant Version_32 := 16#68A22947#; + u00014 : constant Version_32 := 16#18CC4A56#; + u00015 : constant Version_32 := 16#08258E1B#; + u00016 : constant Version_32 := 16#367D5222#; + u00017 : constant Version_32 := 16#20C9ECA4#; + u00018 : constant Version_32 := 16#50D32CB6#; + u00019 : constant Version_32 := 16#39A8BB77#; + u00020 : constant Version_32 := 16#5CF8FA2B#; + u00021 : constant Version_32 := 16#2F1EB794#; + u00022 : constant Version_32 := 16#31AB6444#; + u00023 : constant Version_32 := 16#1574B6E9#; + u00024 : constant Version_32 := 16#5109C189#; + u00025 : constant Version_32 := 16#56D770CD#; + u00026 : constant Version_32 := 16#02F9DE3D#; + u00027 : constant Version_32 := 16#08AB6B2C#; + u00028 : constant Version_32 := 16#3FA37670#; + u00029 : constant Version_32 := 16#476457A0#; + u00030 : constant Version_32 := 16#731E1B6E#; + u00031 : constant Version_32 := 16#23C2E789#; + u00032 : constant Version_32 := 16#0F1BD6A1#; + u00033 : constant Version_32 := 16#7C25DE96#; + u00034 : constant Version_32 := 16#39ADFFA2#; + u00035 : constant Version_32 := 16#571DE3E7#; + u00036 : constant Version_32 := 16#5EB646AB#; + u00037 : constant Version_32 := 16#4249379B#; + u00038 : constant Version_32 := 16#0357E00A#; + u00039 : constant Version_32 := 16#3784FB72#; + u00040 : constant Version_32 := 16#2E723019#; + u00041 : constant Version_32 := 16#623358EA#; + u00042 : constant Version_32 := 16#107F9465#; + u00043 : constant Version_32 := 16#6843F68A#; + u00044 : constant Version_32 := 16#63305874#; + u00045 : constant Version_32 := 16#31E56CE1#; + u00046 : constant Version_32 := 16#02917970#; + u00047 : constant Version_32 := 16#6CCBA70E#; + u00048 : constant Version_32 := 16#41CD4204#; + u00049 : constant Version_32 := 16#572E3F58#; + u00050 : constant Version_32 := 16#20729FF5#; + u00051 : constant Version_32 := 16#1D4F93E8#; + u00052 : constant Version_32 := 16#30B2EC3D#; + u00053 : constant Version_32 := 16#34054F96#; + u00054 : constant Version_32 := 16#5A199860#; + u00055 : constant Version_32 := 16#0E7F912B#; + u00056 : constant Version_32 := 16#5760634A#; + u00057 : constant Version_32 := 16#5D851835#; + + -- The following Export pragmas export the version numbers + -- with symbolic names ending in B (for body) or S + -- (for spec) so that they can be located in a link. The + -- information provided here is sufficient to track down + -- the exact versions of units used in a given build. + + pragma Export (C, u00001, "helloB"); + pragma Export (C, u00002, "system__standard_libraryB"); + pragma Export (C, u00003, "system__standard_libraryS"); + pragma Export (C, u00004, "adaS"); + pragma Export (C, u00005, "ada__text_ioB"); + pragma Export (C, u00006, "ada__text_ioS"); + pragma Export (C, u00007, "ada__exceptionsB"); + pragma Export (C, u00008, "ada__exceptionsS"); + pragma Export (C, u00009, "gnatS"); + pragma Export (C, u00010, "gnat__heap_sort_aB"); + pragma Export (C, u00011, "gnat__heap_sort_aS"); + pragma Export (C, u00012, "systemS"); + pragma Export (C, u00013, "system__exception_tableB"); + pragma Export (C, u00014, "system__exception_tableS"); + pragma Export (C, u00015, "gnat__htableB"); + pragma Export (C, u00016, "gnat__htableS"); + pragma Export (C, u00017, "system__exceptionsS"); + pragma Export (C, u00018, "system__machine_state_operationsB"); + pragma Export (C, u00019, "system__machine_state_operationsS"); + pragma Export (C, u00020, "system__machine_codeS"); + pragma Export (C, u00021, "system__storage_elementsB"); + pragma Export (C, u00022, "system__storage_elementsS"); + pragma Export (C, u00023, "system__secondary_stackB"); + pragma Export (C, u00024, "system__secondary_stackS"); + pragma Export (C, u00025, "system__parametersB"); + pragma Export (C, u00026, "system__parametersS"); + pragma Export (C, u00027, "system__soft_linksB"); + pragma Export (C, u00028, "system__soft_linksS"); + pragma Export (C, u00029, "system__stack_checkingB"); + pragma Export (C, u00030, "system__stack_checkingS"); + pragma Export (C, u00031, "system__tracebackB"); + pragma Export (C, u00032, "system__tracebackS"); + pragma Export (C, u00033, "ada__streamsS"); + pragma Export (C, u00034, "ada__tagsB"); + pragma Export (C, u00035, "ada__tagsS"); + pragma Export (C, u00036, "system__string_opsB"); + pragma Export (C, u00037, "system__string_opsS"); + pragma Export (C, u00038, "interfacesS"); + pragma Export (C, u00039, "interfaces__c_streamsB"); + pragma Export (C, u00040, "interfaces__c_streamsS"); + pragma Export (C, u00041, "system__file_ioB"); + pragma Export (C, u00042, "system__file_ioS"); + pragma Export (C, u00043, "ada__finalizationB"); + pragma Export (C, u00044, "ada__finalizationS"); + pragma Export (C, u00045, "system__finalization_rootB"); + pragma Export (C, u00046, "system__finalization_rootS"); + pragma Export (C, u00047, "system__finalization_implementationB"); + pragma Export (C, u00048, "system__finalization_implementationS"); + pragma Export (C, u00049, "system__string_ops_concat_3B"); + pragma Export (C, u00050, "system__string_ops_concat_3S"); + pragma Export (C, u00051, "system__stream_attributesB"); + pragma Export (C, u00052, "system__stream_attributesS"); + pragma Export (C, u00053, "ada__io_exceptionsS"); + pragma Export (C, u00054, "system__unsigned_typesS"); + pragma Export (C, u00055, "system__file_control_blockS"); + pragma Export (C, u00056, "ada__finalization__list_controllerB"); + pragma Export (C, u00057, "ada__finalization__list_controllerS"); + + -- BEGIN ELABORATION ORDER + -- ada (spec) + -- gnat (spec) + -- gnat.heap_sort_a (spec) + -- gnat.heap_sort_a (body) + -- gnat.htable (spec) + -- gnat.htable (body) + -- interfaces (spec) + -- system (spec) + -- system.machine_code (spec) + -- system.parameters (spec) + -- system.parameters (body) + -- interfaces.c_streams (spec) + -- interfaces.c_streams (body) + -- system.standard_library (spec) + -- ada.exceptions (spec) + -- system.exception_table (spec) + -- system.exception_table (body) + -- ada.io_exceptions (spec) + -- system.exceptions (spec) + -- system.storage_elements (spec) + -- system.storage_elements (body) + -- system.machine_state_operations (spec) + -- system.machine_state_operations (body) + -- system.secondary_stack (spec) + -- system.stack_checking (spec) + -- system.soft_links (spec) + -- system.soft_links (body) + -- system.stack_checking (body) + -- system.secondary_stack (body) + -- system.standard_library (body) + -- system.string_ops (spec) + -- system.string_ops (body) + -- ada.tags (spec) + -- ada.tags (body) + -- ada.streams (spec) + -- system.finalization_root (spec) + -- system.finalization_root (body) + -- system.string_ops_concat_3 (spec) + -- system.string_ops_concat_3 (body) + -- system.traceback (spec) + -- system.traceback (body) + -- ada.exceptions (body) + -- system.unsigned_types (spec) + -- system.stream_attributes (spec) + -- system.stream_attributes (body) + -- system.finalization_implementation (spec) + -- system.finalization_implementation (body) + -- ada.finalization (spec) + -- ada.finalization (body) + -- ada.finalization.list_controller (spec) + -- ada.finalization.list_controller (body) + -- system.file_control_block (spec) + -- system.file_io (spec) + -- system.file_io (body) + -- ada.text_io (spec) + -- ada.text_io (body) + -- hello (body) + -- END ELABORATION ORDER + + end ada_main; + + -- The following source file name pragmas allow the generated file + -- names to be unique for different main programs. They are needed + -- since the package name will always be Ada_Main. + + pragma Source_File_Name (ada_main, Spec_File_Name => "b~hello.ads"); + pragma Source_File_Name (ada_main, Body_File_Name => "b~hello.adb"); + + -- Generated package body for Ada_Main starts here + + package body ada_main is + + -- The actual finalization is performed by calling the + -- library routine in System.Standard_Library.Adafinal + + procedure Do_Finalize; + pragma Import (C, Do_Finalize, "system__standard_library__adafinal"); + + ------------- + -- adainit -- + ------------- + + procedure adainit is + + -- These booleans are set to True once the associated unit has + -- been elaborated. It is also used to avoid elaborating the + -- same unit twice. + + E040 : Boolean; pragma Import (Ada, E040, "interfaces__c_streams_E"); + E008 : Boolean; pragma Import (Ada, E008, "ada__exceptions_E"); + E014 : Boolean; pragma Import (Ada, E014, "system__exception_table_E"); + E053 : Boolean; pragma Import (Ada, E053, "ada__io_exceptions_E"); + E017 : Boolean; pragma Import (Ada, E017, "system__exceptions_E"); + E024 : Boolean; pragma Import (Ada, E024, "system__secondary_stack_E"); + E030 : Boolean; pragma Import (Ada, E030, "system__stack_checking_E"); + E028 : Boolean; pragma Import (Ada, E028, "system__soft_links_E"); + E035 : Boolean; pragma Import (Ada, E035, "ada__tags_E"); + E033 : Boolean; pragma Import (Ada, E033, "ada__streams_E"); + E046 : Boolean; pragma Import (Ada, E046, "system__finalization_root_E"); + E048 : Boolean; pragma Import (Ada, E048, "system__finalization_implementation_E"); + E044 : Boolean; pragma Import (Ada, E044, "ada__finalization_E"); + E057 : Boolean; pragma Import (Ada, E057, "ada__finalization__list_controller_E"); + E055 : Boolean; pragma Import (Ada, E055, "system__file_control_block_E"); + E042 : Boolean; pragma Import (Ada, E042, "system__file_io_E"); + E006 : Boolean; pragma Import (Ada, E006, "ada__text_io_E"); + + -- Set_Globals is a library routine that stores away the + -- value of the indicated set of global values in global + -- variables within the library. + + procedure Set_Globals + (Main_Priority : Integer; + Time_Slice_Value : Integer; + WC_Encoding : Character; + Locking_Policy : Character; + Queuing_Policy : Character; + Task_Dispatching_Policy : Character; + Adafinal : System.Address; + Unreserve_All_Interrupts : Integer; + Exception_Tracebacks : Integer); + pragma Import (C, Set_Globals, "__gnat_set_globals"); + + -- SDP_Table_Build is a library routine used to build the + -- exception tables. See unit Ada.Exceptions in files + -- a-except.ads/adb for full details of how zero cost + -- exception handling works. This procedure, the call to + -- it, and the two following tables are all omitted if the + -- build is in longjmp/setjump exception mode. + + procedure SDP_Table_Build + (SDP_Addresses : System.Address; + SDP_Count : Natural; + Elab_Addresses : System.Address; + Elab_Addr_Count : Natural); + pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build"); + + -- Table of Unit_Exception_Table addresses. Used for zero + -- cost exception handling to build the top level table. + + ST : aliased constant array (1 .. 23) of System.Address := ( + Hello'UET_Address, + Ada.Text_Io'UET_Address, + Ada.Exceptions'UET_Address, + Gnat.Heap_Sort_A'UET_Address, + System.Exception_Table'UET_Address, + System.Machine_State_Operations'UET_Address, + System.Secondary_Stack'UET_Address, + System.Parameters'UET_Address, + System.Soft_Links'UET_Address, + System.Stack_Checking'UET_Address, + System.Traceback'UET_Address, + Ada.Streams'UET_Address, + Ada.Tags'UET_Address, + System.String_Ops'UET_Address, + Interfaces.C_Streams'UET_Address, + System.File_Io'UET_Address, + Ada.Finalization'UET_Address, + System.Finalization_Root'UET_Address, + System.Finalization_Implementation'UET_Address, + System.String_Ops_Concat_3'UET_Address, + System.Stream_Attributes'UET_Address, + System.File_Control_Block'UET_Address, + Ada.Finalization.List_Controller'UET_Address); + + -- Table of addresses of elaboration routines. Used for + -- zero cost exception handling to make sure these + -- addresses are included in the top level procedure + -- address table. + + EA : aliased constant array (1 .. 23) of System.Address := ( + adainit'Code_Address, + Do_Finalize'Code_Address, + Ada.Exceptions'Elab_Spec'Address, + System.Exceptions'Elab_Spec'Address, + Interfaces.C_Streams'Elab_Spec'Address, + System.Exception_Table'Elab_Body'Address, + Ada.Io_Exceptions'Elab_Spec'Address, + System.Stack_Checking'Elab_Spec'Address, + System.Soft_Links'Elab_Body'Address, + System.Secondary_Stack'Elab_Body'Address, + Ada.Tags'Elab_Spec'Address, + Ada.Tags'Elab_Body'Address, + Ada.Streams'Elab_Spec'Address, + System.Finalization_Root'Elab_Spec'Address, + Ada.Exceptions'Elab_Body'Address, + System.Finalization_Implementation'Elab_Spec'Address, + System.Finalization_Implementation'Elab_Body'Address, + Ada.Finalization'Elab_Spec'Address, + Ada.Finalization.List_Controller'Elab_Spec'Address, + System.File_Control_Block'Elab_Spec'Address, + System.File_Io'Elab_Body'Address, + Ada.Text_Io'Elab_Spec'Address, + Ada.Text_Io'Elab_Body'Address); + + -- Start of processing for adainit + + begin + + -- Call SDP_Table_Build to build the top level procedure + -- table for zero cost exception handling (omitted in + -- longjmp/setjump mode). + + SDP_Table_Build (ST'Address, 23, EA'Address, 23); + + -- Call Set_Globals to record various information for + -- this partition. The values are derived by the binder + -- from information stored in the ali files by the compiler. + + Set_Globals + (Main_Priority => -1, + -- Priority of main program, -1 if no pragma Priority used + + Time_Slice_Value => -1, + -- Time slice from Time_Slice pragma, -1 if none used + + WC_Encoding => 'b', + -- Wide_Character encoding used, default is brackets + + Locking_Policy => ' ', + -- Locking_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Queuing_Policy => ' ', + -- Queuing_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Task_Dispatching_Policy => ' ', + -- Task_Dispatching_Policy used, default of space means + -- not specified, otherwise first character of the + -- policy name. + + Adafinal => System.Null_Address, + -- Address of Adafinal routine, not used anymore + + Unreserve_All_Interrupts => 0, + -- Set true if pragma Unreserve_All_Interrupts was used + + Exception_Tracebacks => 0); + -- Indicates if exception tracebacks are enabled + + Elab_Final_Code := 1; + + -- Now we have the elaboration calls for all units in the partition. + -- The Elab_Spec and Elab_Body attributes generate references to the + -- implicit elaboration procedures generated by the compiler for + -- each unit that requires elaboration. + + if not E040 then + Interfaces.C_Streams'Elab_Spec; + end if; + E040 := True; + if not E008 then + Ada.Exceptions'Elab_Spec; + end if; + if not E014 then + System.Exception_Table'Elab_Body; + E014 := True; + end if; + if not E053 then + Ada.Io_Exceptions'Elab_Spec; + E053 := True; + end if; + if not E017 then + System.Exceptions'Elab_Spec; + E017 := True; + end if; + if not E030 then + System.Stack_Checking'Elab_Spec; + end if; + if not E028 then + System.Soft_Links'Elab_Body; + E028 := True; + end if; + E030 := True; + if not E024 then + System.Secondary_Stack'Elab_Body; + E024 := True; + end if; + if not E035 then + Ada.Tags'Elab_Spec; + end if; + if not E035 then + Ada.Tags'Elab_Body; + E035 := True; + end if; + if not E033 then + Ada.Streams'Elab_Spec; + E033 := True; + end if; + if not E046 then + System.Finalization_Root'Elab_Spec; + end if; + E046 := True; + if not E008 then + Ada.Exceptions'Elab_Body; + E008 := True; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Spec; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Body; + E048 := True; + end if; + if not E044 then + Ada.Finalization'Elab_Spec; + end if; + E044 := True; + if not E057 then + Ada.Finalization.List_Controller'Elab_Spec; + end if; + E057 := True; + if not E055 then + System.File_Control_Block'Elab_Spec; + E055 := True; + end if; + if not E042 then + System.File_Io'Elab_Body; + E042 := True; + end if; + if not E006 then + Ada.Text_Io'Elab_Spec; + end if; + if not E006 then + Ada.Text_Io'Elab_Body; + E006 := True; + end if; + + Elab_Final_Code := 0; + end adainit; + + -------------- + -- adafinal -- + -------------- + + procedure adafinal is + begin + Do_Finalize; + end adafinal; + + ---------- + -- main -- + ---------- + + -- main is actually a function, as in the ANSI C standard, + -- defined to return the exit status. The three parameters + -- are the argument count, argument values and environment + -- pointer. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer + is + -- The initialize routine performs low level system + -- initialization using a standard library routine which + -- sets up signal handling and performs any other + -- required setup. The routine can be found in file + -- a-init.c. + + procedure initialize; + pragma Import (C, initialize, "__gnat_initialize"); + + -- The finalize routine performs low level system + -- finalization using a standard library routine. The + -- routine is found in file a-final.c and in the standard + -- distribution is a dummy routine that does nothing, so + -- really this is a hook for special user finalization. + + procedure finalize; + pragma Import (C, finalize, "__gnat_finalize"); + + -- We get to the main program of the partition by using + -- pragma Import because if we try to with the unit and + -- call it Ada style, then not only do we waste time + -- recompiling it, but also, we don't really know the right + -- switches (e.g. identifier character set) to be used + -- to compile it. + + procedure Ada_Main_Program; + pragma Import (Ada, Ada_Main_Program, "_ada_hello"); + + -- Start of processing for main + + begin + -- Save global variables + + gnat_argc := argc; + gnat_argv := argv; + gnat_envp := envp; + + -- Call low level system initialization + + Initialize; + + -- Call our generated Ada initialization routine + + adainit; + + -- This is the point at which we want the debugger to get + -- control + + Break_Start; + + -- Now we call the main program of the partition + + Ada_Main_Program; + + -- Perform Ada finalization + + adafinal; + + -- Perform low level system finalization + + Finalize; + + -- Return the proper exit status + return (gnat_exit_status); + end; + + -- This section is entirely comments, so it has no effect on the + -- compilation of the Ada_Main package. It provides the list of + -- object files and linker options, as well as some standard + -- libraries needed for the link. The gnatlink utility parses + -- this b~hello.adb file to read these comment lines to generate + -- the appropriate command line arguments for the call to the + -- system linker. The BEGIN/END lines are used for sentinels for + -- this parsing operation. + + -- The exact file names will of course depend on the environment, + -- host/target and location of files on the host system. + + -- BEGIN Object file/option list + -- ./hello.o + -- -L./ + -- -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/ + -- /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a + -- END Object file/option list + + end ada_main; + + The Ada code in the above example is exactly what is generated by the + binder. We have added comments to more clearly indicate the function of + each part of the generated `Ada_Main' package. + + The code is standard Ada in all respects, and can be processed by any + tools that handle Ada. In particular, it is possible to use the debugger + in Ada mode to debug the generated Ada_Main package. For example, + suppose that for reasons that you do not understand, your program is + blowing up during elaboration of the body of `Ada.Text_IO'. To chase + this bug down, you can place a breakpoint on the call: + + Ada.Text_Io'Elab_Body; + + and trace the elaboration routine for this package to find out where + the problem might be (more usually of course you would be debugging + elaboration code in your own application). + +  + File: gnat_ug_wnt.info, Node: Generating the Binder Program in C, Next: Consistency-Checking Modes, Prev: Running gnatbind, Up: Binding Using gnatbind + + Generating the Binder Program in C + ================================== + + In most normal usage, the default mode of `gnatbind' which is to + generate the main package in Ada, as described in the previous section. + In particular, this means that any Ada programmer can read and + understand the generated main program. It can also be debugged just + like any other Ada code provided the `-g' switch is used for `gnatbind' + and `gnatlink'. + + However for some purposes it may be convenient to generate the main + program in C rather than Ada. This may for example be helpful when you + are generating a mixed language program with the main program in C. The + GNAT compiler itself is an example. The use of the `-C' switch for both + `gnatbind' and `gnatlink' will cause the program to be generated in C + (and compiled using the gnu C compiler). The following shows the C code + generated for the same "Hello World" program: + + + #ifdef __STDC__ + #define PARAMS(paramlist) paramlist + #else + #define PARAMS(paramlist) () + #endif + + extern void __gnat_set_globals + PARAMS ((int, int, int, int, int, int, + void (*) PARAMS ((void)), int, int)); + extern void adafinal PARAMS ((void)); + extern void adainit PARAMS ((void)); + extern void system__standard_library__adafinal PARAMS ((void)); + extern int main PARAMS ((int, char **, char **)); + extern void exit PARAMS ((int)); + extern void __gnat_break_start PARAMS ((void)); + extern void _ada_hello PARAMS ((void)); + extern void __gnat_initialize PARAMS ((void)); + extern void __gnat_finalize PARAMS ((void)); + + extern void ada__exceptions___elabs PARAMS ((void)); + extern void system__exceptions___elabs PARAMS ((void)); + extern void interfaces__c_streams___elabs PARAMS ((void)); + extern void system__exception_table___elabb PARAMS ((void)); + extern void ada__io_exceptions___elabs PARAMS ((void)); + extern void system__stack_checking___elabs PARAMS ((void)); + extern void system__soft_links___elabb PARAMS ((void)); + extern void system__secondary_stack___elabb PARAMS ((void)); + extern void ada__tags___elabs PARAMS ((void)); + extern void ada__tags___elabb PARAMS ((void)); + extern void ada__streams___elabs PARAMS ((void)); + extern void system__finalization_root___elabs PARAMS ((void)); + extern void ada__exceptions___elabb PARAMS ((void)); + extern void system__finalization_implementation___elabs PARAMS ((void)); + extern void system__finalization_implementation___elabb PARAMS ((void)); + extern void ada__finalization___elabs PARAMS ((void)); + extern void ada__finalization__list_controller___elabs PARAMS ((void)); + extern void system__file_control_block___elabs PARAMS ((void)); + extern void system__file_io___elabb PARAMS ((void)); + extern void ada__text_io___elabs PARAMS ((void)); + extern void ada__text_io___elabb PARAMS ((void)); + + extern int __gnat_inside_elab_final_code; + + extern int gnat_argc; + extern char **gnat_argv; + extern char **gnat_envp; + extern int gnat_exit_status; + + char __gnat_version[] = "GNAT Version: 3.15w (20010315)"; + void adafinal () { + system__standard_library__adafinal (); + } + + void adainit () + { + extern char ada__exceptions_E; + extern char system__exceptions_E; + extern char interfaces__c_streams_E; + extern char system__exception_table_E; + extern char ada__io_exceptions_E; + extern char system__secondary_stack_E; + extern char system__stack_checking_E; + extern char system__soft_links_E; + extern char ada__tags_E; + extern char ada__streams_E; + extern char system__finalization_root_E; + extern char system__finalization_implementation_E; + extern char ada__finalization_E; + extern char ada__finalization__list_controller_E; + extern char system__file_control_block_E; + extern char system__file_io_E; + extern char ada__text_io_E; + + extern void *__gnat_hello__SDP; + extern void *__gnat_ada__text_io__SDP; + extern void *__gnat_ada__exceptions__SDP; + extern void *__gnat_gnat__heap_sort_a__SDP; + extern void *__gnat_system__exception_table__SDP; + extern void *__gnat_system__machine_state_operations__SDP; + extern void *__gnat_system__secondary_stack__SDP; + extern void *__gnat_system__parameters__SDP; + extern void *__gnat_system__soft_links__SDP; + extern void *__gnat_system__stack_checking__SDP; + extern void *__gnat_system__traceback__SDP; + extern void *__gnat_ada__streams__SDP; + extern void *__gnat_ada__tags__SDP; + extern void *__gnat_system__string_ops__SDP; + extern void *__gnat_interfaces__c_streams__SDP; + extern void *__gnat_system__file_io__SDP; + extern void *__gnat_ada__finalization__SDP; + extern void *__gnat_system__finalization_root__SDP; + extern void *__gnat_system__finalization_implementation__SDP; + extern void *__gnat_system__string_ops_concat_3__SDP; + extern void *__gnat_system__stream_attributes__SDP; + extern void *__gnat_system__file_control_block__SDP; + extern void *__gnat_ada__finalization__list_controller__SDP; + + void **st[23] = { + &__gnat_hello__SDP, + &__gnat_ada__text_io__SDP, + &__gnat_ada__exceptions__SDP, + &__gnat_gnat__heap_sort_a__SDP, + &__gnat_system__exception_table__SDP, + &__gnat_system__machine_state_operations__SDP, + &__gnat_system__secondary_stack__SDP, + &__gnat_system__parameters__SDP, + &__gnat_system__soft_links__SDP, + &__gnat_system__stack_checking__SDP, + &__gnat_system__traceback__SDP, + &__gnat_ada__streams__SDP, + &__gnat_ada__tags__SDP, + &__gnat_system__string_ops__SDP, + &__gnat_interfaces__c_streams__SDP, + &__gnat_system__file_io__SDP, + &__gnat_ada__finalization__SDP, + &__gnat_system__finalization_root__SDP, + &__gnat_system__finalization_implementation__SDP, + &__gnat_system__string_ops_concat_3__SDP, + &__gnat_system__stream_attributes__SDP, + &__gnat_system__file_control_block__SDP, + &__gnat_ada__finalization__list_controller__SDP}; + + extern void ada__exceptions___elabs (); + extern void system__exceptions___elabs (); + extern void interfaces__c_streams___elabs (); + extern void system__exception_table___elabb (); + extern void ada__io_exceptions___elabs (); + extern void system__stack_checking___elabs (); + extern void system__soft_links___elabb (); + extern void system__secondary_stack___elabb (); + extern void ada__tags___elabs (); + extern void ada__tags___elabb (); + extern void ada__streams___elabs (); + extern void system__finalization_root___elabs (); + extern void ada__exceptions___elabb (); + extern void system__finalization_implementation___elabs (); + extern void system__finalization_implementation___elabb (); + extern void ada__finalization___elabs (); + extern void ada__finalization__list_controller___elabs (); + extern void system__file_control_block___elabs (); + extern void system__file_io___elabb (); + extern void ada__text_io___elabs (); + extern void ada__text_io___elabb (); + + void (*ea[23]) () = { + adainit, + system__standard_library__adafinal, + ada__exceptions___elabs, + system__exceptions___elabs, + interfaces__c_streams___elabs, + system__exception_table___elabb, + ada__io_exceptions___elabs, + system__stack_checking___elabs, + system__soft_links___elabb, + system__secondary_stack___elabb, + ada__tags___elabs, + ada__tags___elabb, + ada__streams___elabs, + system__finalization_root___elabs, + ada__exceptions___elabb, + system__finalization_implementation___elabs, + system__finalization_implementation___elabb, + ada__finalization___elabs, + ada__finalization__list_controller___elabs, + system__file_control_block___elabs, + system__file_io___elabb, + ada__text_io___elabs, + ada__text_io___elabb}; + + __gnat_SDP_Table_Build (&st, 23, ea, 23); + __gnat_set_globals ( + -1, /* Main_Priority */ + -1, /* Time_Slice_Value */ + 'b', /* WC_Encoding */ + ' ', /* Locking_Policy */ + ' ', /* Queuing_Policy */ + ' ', /* Tasking_Dispatching_Policy */ + 0, /* Finalization routine address, not used anymore */ + 0, /* Unreserve_All_Interrupts */ + 0); /* Exception_Tracebacks */ + + __gnat_inside_elab_final_code = 1; + + if (ada__exceptions_E == 0) { + ada__exceptions___elabs (); + } + if (system__exceptions_E == 0) { + system__exceptions___elabs (); + system__exceptions_E++; + } + if (interfaces__c_streams_E == 0) { + interfaces__c_streams___elabs (); + } + interfaces__c_streams_E = 1; + if (system__exception_table_E == 0) { + system__exception_table___elabb (); + system__exception_table_E++; + } + if (ada__io_exceptions_E == 0) { + ada__io_exceptions___elabs (); + ada__io_exceptions_E++; + } + if (system__stack_checking_E == 0) { + system__stack_checking___elabs (); + } + if (system__soft_links_E == 0) { + system__soft_links___elabb (); + system__soft_links_E++; + } + system__stack_checking_E = 1; + if (system__secondary_stack_E == 0) { + system__secondary_stack___elabb (); + system__secondary_stack_E++; + } + if (ada__tags_E == 0) { + ada__tags___elabs (); + } + if (ada__tags_E == 0) { + ada__tags___elabb (); + ada__tags_E++; + } + if (ada__streams_E == 0) { + ada__streams___elabs (); + ada__streams_E++; + } + if (system__finalization_root_E == 0) { + system__finalization_root___elabs (); + } + system__finalization_root_E = 1; + if (ada__exceptions_E == 0) { + ada__exceptions___elabb (); + ada__exceptions_E++; + } + if (system__finalization_implementation_E == 0) { + system__finalization_implementation___elabs (); + } + if (system__finalization_implementation_E == 0) { + system__finalization_implementation___elabb (); + system__finalization_implementation_E++; + } + if (ada__finalization_E == 0) { + ada__finalization___elabs (); + } + ada__finalization_E = 1; + if (ada__finalization__list_controller_E == 0) { + ada__finalization__list_controller___elabs (); + } + ada__finalization__list_controller_E = 1; + if (system__file_control_block_E == 0) { + system__file_control_block___elabs (); + system__file_control_block_E++; + } + if (system__file_io_E == 0) { + system__file_io___elabb (); + system__file_io_E++; + } + if (ada__text_io_E == 0) { + ada__text_io___elabs (); + } + if (ada__text_io_E == 0) { + ada__text_io___elabb (); + ada__text_io_E++; + } + + __gnat_inside_elab_final_code = 0; + } + int main (argc, argv, envp) + int argc; + char **argv; + char **envp; + { + gnat_argc = argc; + gnat_argv = argv; + gnat_envp = envp; + + __gnat_initialize (); + adainit (); + __gnat_break_start (); + + _ada_hello (); + + system__standard_library__adafinal (); + __gnat_finalize (); + exit (gnat_exit_status); + } + unsigned helloB = 0x7880BEB3; + unsigned system__standard_libraryB = 0x0D24CBD0; + unsigned system__standard_libraryS = 0x3283DBEB; + unsigned adaS = 0x2359F9ED; + unsigned ada__text_ioB = 0x47C85FC4; + unsigned ada__text_ioS = 0x496FE45C; + unsigned ada__exceptionsB = 0x74F50187; + unsigned ada__exceptionsS = 0x6736945B; + unsigned gnatS = 0x156A40CF; + unsigned gnat__heap_sort_aB = 0x033DABE0; + unsigned gnat__heap_sort_aS = 0x6AB38FEA; + unsigned systemS = 0x0331C6FE; + unsigned system__exceptionsS = 0x20C9ECA4; + unsigned system__exception_tableB = 0x68A22947; + unsigned system__exception_tableS = 0x394BADD5; + unsigned gnat__htableB = 0x08258E1B; + unsigned gnat__htableS = 0x367D5222; + unsigned system__machine_state_operationsB = 0x4F3B7492; + unsigned system__machine_state_operationsS = 0x182F5CF4; + unsigned system__storage_elementsB = 0x2F1EB794; + unsigned system__storage_elementsS = 0x102C83C7; + unsigned system__secondary_stackB = 0x1574B6E9; + unsigned system__secondary_stackS = 0x708E260A; + unsigned system__parametersB = 0x56D770CD; + unsigned system__parametersS = 0x237E39BE; + unsigned system__soft_linksB = 0x08AB6B2C; + unsigned system__soft_linksS = 0x1E2491F3; + unsigned system__stack_checkingB = 0x476457A0; + unsigned system__stack_checkingS = 0x5299FCED; + unsigned system__tracebackB = 0x2971EBDE; + unsigned system__tracebackS = 0x2E9C3122; + unsigned ada__streamsS = 0x7C25DE96; + unsigned ada__tagsB = 0x39ADFFA2; + unsigned ada__tagsS = 0x769A0464; + unsigned system__string_opsB = 0x5EB646AB; + unsigned system__string_opsS = 0x63CED018; + unsigned interfacesS = 0x0357E00A; + unsigned interfaces__c_streamsB = 0x3784FB72; + unsigned interfaces__c_streamsS = 0x2E723019; + unsigned system__file_ioB = 0x623358EA; + unsigned system__file_ioS = 0x31F873E6; + unsigned ada__finalizationB = 0x6843F68A; + unsigned ada__finalizationS = 0x63305874; + unsigned system__finalization_rootB = 0x31E56CE1; + unsigned system__finalization_rootS = 0x23169EF3; + unsigned system__finalization_implementationB = 0x6CCBA70E; + unsigned system__finalization_implementationS = 0x604AA587; + unsigned system__string_ops_concat_3B = 0x572E3F58; + unsigned system__string_ops_concat_3S = 0x01F57876; + unsigned system__stream_attributesB = 0x1D4F93E8; + unsigned system__stream_attributesS = 0x30B2EC3D; + unsigned ada__io_exceptionsS = 0x34054F96; + unsigned system__unsigned_typesS = 0x7B9E7FE3; + unsigned system__file_control_blockS = 0x2FF876A8; + unsigned ada__finalization__list_controllerB = 0x5760634A; + unsigned ada__finalization__list_controllerS = 0x5D851835; + + /* BEGIN ELABORATION ORDER + ada (spec) + gnat (spec) + gnat.heap_sort_a (spec) + gnat.htable (spec) + gnat.htable (body) + interfaces (spec) + system (spec) + system.parameters (spec) + system.standard_library (spec) + ada.exceptions (spec) + system.exceptions (spec) + system.parameters (body) + gnat.heap_sort_a (body) + interfaces.c_streams (spec) + interfaces.c_streams (body) + system.exception_table (spec) + system.exception_table (body) + ada.io_exceptions (spec) + system.storage_elements (spec) + system.storage_elements (body) + system.machine_state_operations (spec) + system.machine_state_operations (body) + system.secondary_stack (spec) + system.stack_checking (spec) + system.soft_links (spec) + system.soft_links (body) + system.stack_checking (body) + system.secondary_stack (body) + system.standard_library (body) + system.string_ops (spec) + system.string_ops (body) + ada.tags (spec) + ada.tags (body) + ada.streams (spec) + system.finalization_root (spec) + system.finalization_root (body) + system.string_ops_concat_3 (spec) + system.string_ops_concat_3 (body) + system.traceback (spec) + system.traceback (body) + ada.exceptions (body) + system.unsigned_types (spec) + system.stream_attributes (spec) + system.stream_attributes (body) + system.finalization_implementation (spec) + system.finalization_implementation (body) + ada.finalization (spec) + ada.finalization (body) + ada.finalization.list_controller (spec) + ada.finalization.list_controller (body) + system.file_control_block (spec) + system.file_io (spec) + system.file_io (body) + ada.text_io (spec) + ada.text_io (body) + hello (body) + END ELABORATION ORDER */ + + /* BEGIN Object file/option list + ./hello.o + -L./ + -L/usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/ + /usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/libgnat.a + -lexc + END Object file/option list */ + + Here again, the C code is exactly what is generated by the binder. The + functions of the various parts of this code correspond in an obvious + manner with the commented Ada code shown in the example in the previous + section. + +  + File: gnat_ug_wnt.info, Node: Consistency-Checking Modes, Next: Binder Error Message Control, Prev: Generating the Binder Program in C, Up: Binding Using gnatbind + + Consistency-Checking Modes + ========================== + + As described in the previous section, by default `gnatbind' checks that + object files are consistent with one another and are consistent with + any source files it can locate. The following switches control binder + access to sources. + + `-s' + Require source files to be present. In this mode, the binder must + be able to locate all source files that are referenced, in order + to check their consistency. In normal mode, if a source file + cannot be located it is simply ignored. If you specify this + switch, a missing source file is an error. + + `-x' + Exclude source files. In this mode, the binder only checks that ALI + files are consistent with one another. Source files are not + accessed. The binder runs faster in this mode, and there is still + a guarantee that the resulting program is self-consistent. If a + source file has been edited since it was last compiled, and you + specify this switch, the binder will not detect that the object + file is out of date with respect to the source file. Note that + this is the mode that is automatically used by `gnatmake' because + in this case the checking against sources has already been + performed by `gnatmake' in the course of compilation (i.e. before + binding). + +  + File: gnat_ug_wnt.info, Node: Binder Error Message Control, Next: Elaboration Control, Prev: Consistency-Checking Modes, Up: Binding Using gnatbind + + Binder Error Message Control + ============================ + + The following switches provide control over the generation of error + messages from the binder: + + `-v' + Verbose mode. In the normal mode, brief error messages are + generated to `stderr'. If this switch is present, a header is + written to `stdout' and any error messages are directed to + `stdout'. All that is written to `stderr' is a brief summary + message. + + `-b' + Generate brief error messages to `stderr' even if verbose mode is + specified. This is relevant only when used with the `-v' switch. + + `-mN' + Limits the number of error messages to N, a decimal integer in the + range 1-999. The binder terminates immediately if this limit is + reached. + + `-MXXX' + Renames the generated main program from `main' to `xxx'. This is + useful in the case of some cross-building environments, where the + actual main program is separate from the one generated by + `gnatbind'. + + `-ws' + Suppress all warning messages. + + `-we' + Treat any warning messages as fatal errors. + + `-t' + The binder performs a number of consistency checks including: + + * Check that time stamps of a given source unit are consistent + + * Check that checksums of a given source unit are consistent + + * Check that consistent versions of `GNAT' were used for + compilation + + * Check consistency of configuration pragmas as required + + Normally failure of such checks, in accordance with the consistency + requirements of the Ada Reference Manual, causes error messages to + be generated which abort the binder and prevent the output of a + binder file and subsequent link to obtain an executable. + + The `-t' switch converts these error messages into warnings, so + that binding and linking can continue to completion even in the + presence of such errors. The result may be a failed link (due to + missing symbols), or a non-functional executable which has + undefined semantics. _This means that `-t' should be used only in + unusual situations, with extreme care._ + +  + File: gnat_ug_wnt.info, Node: Elaboration Control, Next: Output Control, Prev: Binder Error Message Control, Up: Binding Using gnatbind + + Elaboration Control + =================== + + The following switches provide additional control over the elaboration + order. For full details see *Note Elaboration Order Handling in GNAT::. + + `-p' + Normally the binder attempts to choose an elaboration order that is + likely to minimize the likelihood of an elaboration order error + resulting in raising a `Program_Error' exception. This switch + reverses the action of the binder, and requests that it + deliberately choose an order that is likely to maximize the + likelihood of an elaboration error. This is useful in ensuring + portability and avoiding dependence on accidental fortuitous + elaboration ordering. + + Normally it only makes sense to use the `-p' switch if dynamic + elaboration checking is used (`-gnatE' switch used for + compilation). This is because in the default static elaboration + mode, all necessary `Elaborate_All' pragmas are implicitly + inserted. These implicit pragmas are still respected by the binder + in `-p' mode, so a safe elaboration order is assured. + +  + File: gnat_ug_wnt.info, Node: Output Control, Next: Binding with Non-Ada Main Programs, Prev: Elaboration Control, Up: Binding Using gnatbind + + Output Control + ============== + + The following switches allow additional control over the output + generated by the binder. + + `-A' + Generate binder program in Ada (default). The binder program is + named `b~MAINPROG.adb' by default. This can be changed with `-o' + `gnatbind' option. + + `-c' + Check only. Do not generate the binder output file. In this mode + the binder performs all error checks but does not generate an + output file. + + `-C' + Generate binder program in C. The binder program is named + `b_MAINPROG.c'. This can be changed with `-o' `gnatbind' option. + + `-e' + Output complete list of elaboration-order dependencies, showing the + reason for each dependency. This output can be rather extensive + but may be useful in diagnosing problems with elaboration order. + The output is written to `stdout'. + + `-h' + Output usage information. The output is written to `stdout'. + + `-K' + Output linker options to `stdout'. Includes library search paths, + contents of pragmas Ident and Linker_Options, and libraries added + by `gnatbind'. + + `-l' + Output chosen elaboration order. The output is written to `stdout'. + + `-O' + Output full names of all the object files that must be linked to + provide the Ada component of the program. The output is written to + `stdout'. This list includes the files explicitly supplied and + referenced by the user as well as implicitly referenced run-time + unit files. The latter are omitted if the corresponding units + reside in shared libraries. The directory names for the run-time + units depend on the system configuration. + + `-o FILE' + Set name of output file to FILE instead of the normal + `b~MAINPROG.adb' default. Note that FILE denote the Ada binder + generated body filename. In C mode you would normally give FILE an + extension of `.c' because it will be a C source program. Note + that if this option is used, then linking must be done manually. + It is not possible to use gnatlink in this case, since it cannot + locate the binder file. + + `-r' + Generate list of `pragma Rerstrictions' that could be applied to + the current unit. This is useful for code audit purposes, and also + may be used to improve code generation in some cases. + +  + File: gnat_ug_wnt.info, Node: Binding with Non-Ada Main Programs, Next: Binding Programs with No Main Subprogram, Prev: Output Control, Up: Binding Using gnatbind + + Binding with Non-Ada Main Programs + ================================== + + In our description so far we have assumed that the main program is in + Ada, and that the task of the binder is to generate a corresponding + function `main' that invokes this Ada main program. GNAT also supports + the building of executable programs where the main program is not in + Ada, but some of the called routines are written in Ada and compiled + using GNAT (*note Mixed Language Programming::). The following switch + is used in this situation: + + `-n' + No main program. The main program is not in Ada. + + In this case, most of the functions of the binder are still required, + but instead of generating a main program, the binder generates a file + containing the following callable routines: + + `adainit' + You must call this routine to initialize the Ada part of the + program by calling the necessary elaboration routines. A call to + `adainit' is required before the first call to an Ada subprogram. + + Note that it is assumed that the basic execution environment must + be setup to be appropriate for Ada execution at the point where + the first Ada subprogram is called. In particular, if the Ada code + will do any floating-point operations, then the FPU must be setup + in an appropriate manner. For the case of the x86, for example, + full precision mode is required. The procedure + GNAT.Float_Control.Reset may be used to ensure that the FPU is in + the right state. + + `adafinal' + You must call this routine to perform any library-level + finalization required by the Ada subprograms. A call to `adafinal' + is required after the last call to an Ada subprogram, and before + the program terminates. + + If the `-n' switch is given, more than one ALI file may appear on the + command line for `gnatbind'. The normal "closure" calculation is + performed for each of the specified units. Calculating the closure + means finding out the set of units involved by tracing `with' + references. The reason it is necessary to be able to specify more than + one ALI file is that a given program may invoke two or more quite + separate groups of Ada units. + + The binder takes the name of its output file from the last specified + ALI file, unless overridden by the use of the `-o file'. The output is + an Ada unit in source form that can be compiled with GNAT unless the -C + switch is used in which case the output is a C source file, which must + be compiled using the C compiler. This compilation occurs + automatically as part of the `gnatlink' processing. + + Currently the GNAT run time requires a FPU using 80 bits mode + precision. Under targets where this is not the default it is required to + call GNAT.Float_Control.Reset before using floating point numbers (this + include float computation, float input and output) in the Ada code. A + side effect is that this could be the wrong mode for the foreign code + where floating point computation could be broken after this call. + +  + File: gnat_ug_wnt.info, Node: Binding Programs with No Main Subprogram, Next: Summary of Binder Switches, Prev: Binding with Non-Ada Main Programs, Up: Binding Using gnatbind + + Binding Programs with No Main Subprogram + ======================================== + + It is possible to have an Ada program which does not have a main + subprogram. This program will call the elaboration routines of all the + packages, then the finalization routines. + + The following switch is used to bind programs organized in this + manner: + + `-z' + Normally the binder checks that the unit name given on the command + line corresponds to a suitable main subprogram. When this switch + is used, a list of ALI files can be given, and the execution of + the program consists of elaboration of these units in an + appropriate order. + +  + File: gnat_ug_wnt.info, Node: Summary of Binder Switches, Next: Command-Line Access, Prev: Binding Programs with No Main Subprogram, Up: Binding Using gnatbind + + Summary of Binder Switches + ========================== + + The following are the switches available with `gnatbind': + + `-aO' + Specify directory to be searched for ALI files. + + `-aI' + Specify directory to be searched for source file. + + `-A' + Generate binder program in Ada (default) + + `-b' + Generate brief messages to `stderr' even if verbose mode set. + + `-c' + Check only, no generation of binder output file. + + `-C' + Generate binder program in C + + `-e' + Output complete list of elaboration-order dependencies. + + `-E' + Store tracebacks in exception occurrences when the target supports + it. This is the default with the zero cost exception mechanism. + This option is currently supported on the following targets: all + x86 ports, Solaris, Windows, HP-UX, AIX, PowerPC VxWorks and Alpha + VxWorks. See also the packages `GNAT.Traceback' and + `GNAT.Traceback.Symbolic' for more information. Note that on x86 + ports, you must not use `-fomit-frame-pointer' `gcc' option. + + `-h' + Output usage (help) information + + `-I' + Specify directory to be searched for source and ALI files. + + `-I-' + Do not look for sources in the current directory where `gnatbind' + was invoked, and do not look for ALI files in the directory + containing the ALI file named in the `gnatbind' command line. + + `-l' + Output chosen elaboration order. + + `-Lxxx' + Binds the units for library building. In this case the adainit and + adafinal procedures (See *note Binding with Non-Ada Main + Programs::) are renamed to xxxinit and xxxfinal. Implies -n. See + *note GNAT and Libraries:: for more details. + + `-Mxyz' + Rename generated main program from main to xyz + + `-mN' + Limit number of detected errors to N (1-999). Furthermore, under + Windows, the sources pointed to by the libraries path set in the + registry are not searched for. + + `-n' + No main program. + + `-nostdinc' + Do not look for sources in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-o FILE' + Name the output file FILE (default is `b~XXX.adb'). Note that if + this option is used, then linking must be done manually, gnatlink + cannot be used. + + `-O' + Output object list. + + `-p' + Pessimistic (worst-case) elaboration order + + `-s' + Require all source files to be present. + + `-static' + Link against a static GNAT run time. + + `-shared' + Link against a shared GNAT run time when available. + + `-t' + Tolerate time stamp and other consistency errors + + `-TN' + Set the time slice value to n microseconds. A value of zero means + no time slicing and also indicates to the tasking run time to + match as close as possible to the annex D requirements of the RM. + + `-v' + Verbose mode. Write error messages, header, summary output to + `stdout'. + + `-wX' + Warning mode (X=s/e for suppress/treat as error) + + `-x' + Exclude source files (check object consistency only). + + `-z' + No main subprogram. + + You may obtain this listing by running the program `gnatbind' with + no arguments. + +  + File: gnat_ug_wnt.info, Node: Command-Line Access, Next: Search Paths for gnatbind, Prev: Summary of Binder Switches, Up: Binding Using gnatbind + + Command-Line Access + =================== + + The package `Ada.Command_Line' provides access to the command-line + arguments and program name. In order for this interface to operate + correctly, the two variables + + int gnat_argc; + char **gnat_argv; + + are declared in one of the GNAT library routines. These variables must + be set from the actual `argc' and `argv' values passed to the main + program. With no `n' present, `gnatbind' generates the C main program + to automatically set these variables. If the `n' switch is used, there + is no automatic way to set these variables. If they are not set, the + procedures in `Ada.Command_Line' will not be available, and any attempt + to use them will raise `Constraint_Error'. If command line access is + required, your main program must set `gnat_argc' and `gnat_argv' from + the `argc' and `argv' values passed to it. + +  + File: gnat_ug_wnt.info, Node: Search Paths for gnatbind, Next: Examples of gnatbind Usage, Prev: Command-Line Access, Up: Binding Using gnatbind + + Search Paths for `gnatbind' + =========================== + + The binder takes the name of an ALI file as its argument and needs to + locate source files as well as other ALI files to verify object + consistency. + + For source files, it follows exactly the same search rules as `gcc' + (*note Search Paths and the Run-Time Library (RTL)::). For ALI files the + directories searched are: + + 1. The directory containing the ALI file named in the command line, + unless the switch `-I-' is specified. + + 2. All directories specified by `-I' switches on the `gnatbind' + command line, in the order given. + + 3. Each of the directories listed in the value of the + `ADA_OBJECTS_PATH' environment variable. Construct this value + exactly as the `PATH' environment variable: a list of directory + names separated by colons (semicolons when working with the NT + version of GNAT). + + 4. The content of the "ada_object_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as + the GNAT Run Time Library (RTL) unless the switch `-nostdlib' is + specified. *Note Installing an Ada Library:: + + In the binder the switch `-I' is used to specify both source and + library file paths. Use `-aI' instead if you want to specify source + paths only, and `-aO' if you want to specify library paths only. This + means that for the binder `-I'DIR is equivalent to `-aI'DIR `-aO'DIR. + The binder generates the bind file (a C language source file) in the + current working directory. + + The packages `Ada', `System', and `Interfaces' and their children + make up the GNAT Run-Time Library, together with the package GNAT and + its children, which contain a set of useful additional library + functions provided by GNAT. The sources for these units are needed by + the compiler and are kept together in one directory. The ALI files and + object files generated by compiling the RTL are needed by the binder + and the linker and are kept together in one directory, typically + different from the directory containing the sources. In a normal + installation, you need not specify these directory names when compiling + or binding. Either the environment variables or the built-in defaults + cause these files to be found. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + +  + File: gnat_ug_wnt.info, Node: Examples of gnatbind Usage, Prev: Search Paths for gnatbind, Up: Binding Using gnatbind + + Examples of `gnatbind' Usage + ============================ + + This section contains a number of examples of using the GNAT binding + utility `gnatbind'. + + `gnatbind hello' + The main program `Hello' (source program in `hello.adb') is bound + using the standard switch settings. The generated main program is + `b~hello.adb'. This is the normal, default use of the binder. + + `gnatbind hello -o mainprog.adb' + The main program `Hello' (source program in `hello.adb') is bound + using the standard switch settings. The generated main program is + `mainprog.adb' with the associated spec in `mainprog.ads'. Note + that you must specify the body here not the spec, in the case + where the output is in Ada. Note that if this option is used, then + linking must be done manually, since gnatlink will not be able to + find the generated file. + + `gnatbind main -C -o mainprog.c -x' + The main program `Main' (source program in `main.adb') is bound, + excluding source files from the consistency checking, generating + the file `mainprog.c'. + + `gnatbind -x main_program -C -o mainprog.c' + This command is exactly the same as the previous example. Switches + may appear anywhere in the command line, and single letter + switches may be combined into a single switch. + + `gnatbind -n math dbase -C -o ada-control.c' + The main program is in a language other than Ada, but calls to + subprograms in packages `Math' and `Dbase' appear. This call to + `gnatbind' generates the file `ada-control.c' containing the + `adainit' and `adafinal' routines to be called before and after + accessing the Ada units. + +  + File: gnat_ug_wnt.info, Node: Linking Using gnatlink, Next: The GNAT Make Program gnatmake, Prev: Binding Using gnatbind, Up: Top + + Linking Using `gnatlink' + ************************ + + This chapter discusses `gnatlink', a utility program used to link Ada + programs and build an executable file. This is a simple program that + invokes the Unix linker (via the `gcc' command) with a correct list of + object files and library references. `gnatlink' automatically + determines the list of files and references for the Ada part of a + program. It uses the binder file generated by the binder to determine + this list. + + * Menu: + + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + +  + File: gnat_ug_wnt.info, Node: Running gnatlink, Next: Switches for gnatlink, Up: Linking Using gnatlink + + Running `gnatlink' + ================== + + The form of the `gnatlink' command is + + $ gnatlink [SWITCHES] MAINPROG[.ali] [NON-ADA OBJECTS] + [LINKER OPTIONS] + + `MAINPROG.ali' references the ALI file of the main program. The `.ali' + extension of this file can be omitted. From this reference, `gnatlink' + locates the corresponding binder file `b~MAINPROG.adb' and, using the + information in this file along with the list of non-Ada objects and + linker options, constructs a Unix linker command file to create the + executable. + + The arguments following `MAINPROG.ali' are passed to the linker + uninterpreted. They typically include the names of object files for + units written in other languages than Ada and any library references + required to resolve references in any of these foreign language units, + or in `pragma Import' statements in any Ada units. + + LINKER OPTIONS is an optional list of linker specific switches. The + default linker called by gnatlink is GCC which in turn calls the + appropriate system linker usually called LD. Standard options for the + linker such as `-lmy_lib' or `-Ldir' can be added as is. For options + that are not recognized by GCC as linker options, the GCC switches + `-Xlinker' or `-Wl,' shall be used. Refer to the GCC documentation for + details. Here is an example showing how to generate a linker map + assuming that the underlying linker is GNU ld: + + $ gnatlink my_prog -Wl,-Map,MAPFILE + + Using LINKER OPTIONS it is possible to set the program stack and + heap size. See *note Setting Stack Size from gnatlink:: and *note + Setting Heap Size from gnatlink::. + + `gnatlink' determines the list of objects required by the Ada + program and prepends them to the list of objects passed to the linker. + `gnatlink' also gathers any arguments set by the use of `pragma + Linker_Options' and adds them to the list of arguments presented to the + linker. + +  + File: gnat_ug_wnt.info, Node: Switches for gnatlink, Next: Setting Stack Size from gnatlink, Prev: Running gnatlink, Up: Linking Using gnatlink + + Switches for `gnatlink' + ======================= + + The following switches are available with the `gnatlink' utility: + + `-A' + The binder has generated code in Ada. This is the default. + + `-C' + If instead of generating a file in Ada, the binder has generated + one in C, then the linker needs to know about it. Use this switch + to signal to `gnatlink' that the binder has generated C code + rather than Ada code. + + `-f' + On some targets, the command line length is limited, and `gnatlink' + will generate a separate file for the linker if the list of object + files is too long. The `-f' flag forces this file to be generated + even if the limit is not exceeded. This is useful in some cases to + deal with special situations where the command line length is + exceeded. + + `-g' + The option to include debugging information causes the Ada bind + file (in other words, `b~MAINPROG.adb') to be compiled with `-g'. + In addition, the binder does not delete the `b~MAINPROG.adb', + `b~MAINPROG.o' and `b~MAINPROG.ali' files. Without `-g', the + binder removes these files by default. The same procedure apply if + a C bind file was generated using `-C' `gnatbind' option, in this + case the filenames are `b_MAINPROG.c' and `b_MAINPROG.o'. + + `-n' + Do not compile the file generated by the binder. This may be used + when a link is rerun with different options, but there is no need + to recompile the binder file. + + `-v' + Causes additional information to be output, including a full list + of the included object files. This switch option is most useful + when you want to see what set of object files are being used in + the link step. + + `-v -v' + Very verbose mode. Requests that the compiler operate in verbose + mode when it compiles the binder file, and that the system linker + run in verbose mode. + + `-o EXEC-NAME' + EXEC-NAME specifies an alternate name for the generated executable + program. If this switch is omitted, the executable has the same + name as the main unit. For example, `gnatlink try.ali' creates an + executable called `try'. + + `-b TARGET' + Compile your program to run on TARGET, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + TARGET is not the same as your host system. + + `-BDIR' + Load compiler executables (for example, `gnat1', the Ada compiler) + from DIR instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + `gcc' manual page for further details. You would normally use the + `-b' or `-V' switch instead. + + `--GCC=COMPILER_NAME' + Program used for compiling the binder file. The default is + ``gcc''. You need to use quotes around COMPILER_NAME if + `compiler_name' contains spaces or other separator characters. As + an example `--GCC="foo -x -y"' will instruct `gnatlink' to use + `foo -x -y' as your compiler. Note that switch `-c' is always + inserted after your command name. Thus in the above example the + compiler command that will be used by `gnatlink' will be `foo -c + -x -y'. If several `--GCC=compiler_name' are used, only the last + COMPILER_NAME is taken into account. However, all the additional + switches are also taken into account. Thus, `--GCC="foo -x -y" + --GCC="bar -z -t"' is equivalent to `--GCC="bar -x -y -z -t"'. + + `--LINK=NAME' + NAME is the name of the linker to be invoked. This is especially + useful in mixed language programs since languages such as c++ + require their own linker to be used. When this switch is omitted, + the default name for the linker is (`gcc'). When this switch is + used, the specified linker is called instead of (`gcc') with + exactly the same parameters that would have been passed to (`gcc') + so if the desired linker requires different parameters it is + necessary to use a wrapper script that massages the parameters + before invoking the real linker. It may be useful to control the + exact invocation by using the verbose switch. + +  + File: gnat_ug_wnt.info, Node: Setting Stack Size from gnatlink, Next: Setting Heap Size from gnatlink, Prev: Switches for gnatlink, Up: Linking Using gnatlink + + Setting Stack Size from `gnatlink' + ================================== + + It is possible to specify the program stack size from `gnatlink'. + Assuming that the underlying linker is GNU ld there is two ways to do + so: + + * using `-Xlinker' linker option + + $ gnatlink hello -Xlinker --stack=0x10000,0x1000 + + This set the stack reserve size to 0x10000 bytes and the stack + commit size to 0x1000 bytes. + + * using `-Wl' linker option + + $ gnatlink hello -Wl,--stack=0x1000000 + + This set the stack reserve size to 0x1000000 bytes. Note that with + `-Wl' option it is not possible to set the stack commit size + because the coma is a separator for this option. + + +  + File: gnat_ug_wnt.info, Node: Setting Heap Size from gnatlink, Prev: Setting Stack Size from gnatlink, Up: Linking Using gnatlink + + Setting Heap Size from `gnatlink' + ================================= + + It is possible to specify the program heap size from `gnatlink'. + Assuming that the underlying linker is GNU ld there is two ways to do + so: + + * using `-Xlinker' linker option + + $ gnatlink hello -Xlinker --heap=0x10000,0x1000 + + This set the heap reserve size to 0x10000 bytes and the heap commit + size to 0x1000 bytes. + + * using `-Wl' linker option + + $ gnatlink hello -Wl,--heap=0x1000000 + + This set the heap reserve size to 0x1000000 bytes. Note that with + `-Wl' option it is not possible to set the heap commit size + because the coma is a separator for this option. + + +  + File: gnat_ug_wnt.info, Node: The GNAT Make Program gnatmake, Next: Renaming Files Using gnatchop, Prev: Linking Using gnatlink, Up: Top + + The GNAT Make Program `gnatmake' + ******************************** + + * Menu: + + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + + A typical development cycle when working on an Ada program consists of + the following steps: + + 1. Edit some sources to fix bugs. + + 2. Add enhancements. + + 3. Compile all sources affected. + + 4. Rebind and relink. + + 5. Test. + + The third step can be tricky, because not only do the modified files + have to be compiled, but any files depending on these files must also be + recompiled. The dependency rules in Ada can be quite complex, especially + in the presence of overloading, `use' clauses, generics and inlined + subprograms. + + `gnatmake' automatically takes care of the third and fourth steps of + this process. It determines which sources need to be compiled, compiles + them, and binds and links the resulting object files. + + Unlike some other Ada make programs, the dependencies are always + accurately recomputed from the new sources. The source based approach of + the GNAT compilation model makes this possible. This means that if + changes to the source program cause corresponding changes in + dependencies, they will always be tracked exactly correctly by + `gnatmake'. + +  + File: gnat_ug_wnt.info, Node: Running gnatmake, Next: Switches for gnatmake, Up: The GNAT Make Program gnatmake + + Running `gnatmake' + ================== + + The usual form of the `gnatmake' command is + + $ gnatmake [SWITCHES] FILE_NAME [FILE_NAMES] [MODE_SWITCHES] + + The only required argument is one FILE_NAME, which specifies a + compilation unit that is a main program. Several FILE_NAMES can be + specified: this will result in several executables being built. If + `switches' are present, they can be placed before the first FILE_NAME, + between FILE_NAMES or after the last FILE_NAME. If MODE_SWITCHES are + present, they must always be placed after the last FILE_NAME and all + `switches'. + + If you are using standard file extensions (.adb and .ads), then the + extension may be omitted from the FILE_NAME arguments. However, if you + are using non-standard extensions, then it is required that the + extension be given. A relative or absolute directory path can be + specified in a FILE_NAME, in which case, the input source file will be + searched for in the specified directory only. Otherwise, the input + source file will first be searched in the directory where `gnatmake' + was invoked and if it is not found, it will be search on the source + path of the compiler as described in *Note Search Paths and the + Run-Time Library (RTL)::. + + When several FILE_NAMES are specified, if an executable needs to be + rebuilt and relinked, all subsequent executables will be rebuilt and + relinked, even if this would not be absolutely necessary. + + All `gnatmake' output (except when you specify `-M') is to `stderr'. + The output produced by the `-M' switch is send to `stdout'. + +  + File: gnat_ug_wnt.info, Node: Switches for gnatmake, Next: Mode Switches for gnatmake, Prev: Running gnatmake, Up: The GNAT Make Program gnatmake + + Switches for `gnatmake' + ======================= + + You may specify any of the following switches to `gnatmake': + + `--GCC=COMPILER_NAME' + Program used for compiling. The default is ``gcc''. You need to use + quotes around COMPILER_NAME if `compiler_name' contains spaces or + other separator characters. As an example `--GCC="foo -x -y"' will + instruct `gnatmake' to use `foo -x -y' as your compiler. Note that + switch `-c' is always inserted after your command name. Thus in + the above example the compiler command that will be used by + `gnatmake' will be `foo -c -x -y'. If several + `--GCC=compiler_name' are used, only the last COMPILER_NAME is + taken into account. However, all the additional switches are also + taken into account. Thus, `--GCC="foo -x -y" --GCC="bar -z -t"' is + equivalent to `--GCC="bar -x -y -z -t"'. + + `--GNATBIND=BINDER_NAME' + Program used for binding. The default is ``gnatbind''. You need to + use quotes around BINDER_NAME if BINDER_NAME contains spaces or + other separator characters. As an example `--GNATBIND="bar -x -y"' + will instruct `gnatmake' to use `bar -x -y' as your binder. Binder + switches that are normally appended by `gnatmake' to ``gnatbind'' + are now appended to the end of `bar -x -y'. + + `--GNATLINK=LINKER_NAME' + Program used for linking. The default is ``gnatlink''. You need to + use quotes around LINKER_NAME if LINKER_NAME contains spaces or + other separator characters. As an example `--GNATLINK="lan -x -y"' + will instruct `gnatmake' to use `lan -x -y' as your linker. Linker + switches that are normally appended by `gnatmake' to ``gnatlink'' + are now appended to the end of `lan -x -y'. + + `-a' + Consider all files in the make process, even the GNAT internal + system files (for example, the predefined Ada library files), as + well as any locked files. Locked files are files whose ALI file is + write-protected. By default, `gnatmake' does not check these + files, because the assumption is that the GNAT internal files are + properly up to date, and also that any write protected ALI files + have been properly installed. Note that if there is an + installation problem, such that one of these files is not up to + date, it will be properly caught by the binder. You may have to + specify this switch if you are working on GNAT itself. `-a' is + also useful in conjunction with `-f' if you need to recompile an + entire application, including run-time files, using special + configuration pragma settings, such as a non-standard + `Float_Representation' pragma. By default `gnatmake -a' compiles + all GNAT internal files with `gcc -c -gnatpg' rather than `gcc -c'. + + `-b' + Bind only. Can be combined with `-c' to do compilation and + binding, but no link. Can be combined with `-l' to do binding and + linking. When not combined with `-c' all the units in the closure + of the main program must have been previously compiled and must be + up to date. The root unit specified by FILE_NAME may be given + without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + `-c' + Compile only. Do not perform binding, except when `-b' is also + specified. Do not perform linking, except if both `-b' and `-l' + are also specified. If the root unit specified by FILE_NAME is + not a main unit, this is the default. Otherwise `gnatmake' will + attempt binding and linking unless all objects are up to date and + the executable is more recent than the objects. + + `-C' + Use a mapping file. A mapping file is a way to communicate to the + compiler two mappings: from unit names to file names (without any + directory information) and from file names to path names (with + full directory information). These mappings are used by the + compiler to short-circuit the path search. When `gnatmake' is + invoked with this switch, it will create a mapping file, initially + populated by the project manager, if `-P' is used, otherwise + initially empty. Each invocation of the compiler will add the newly + accessed sources to the mapping file. This will improve the source + search during the next invocation of the compiler. + + `-f' + Force recompilations. Recompile all sources, even though some + object files may be up to date, but don't recompile predefined or + GNAT internal files or locked files (files with a write-protected + ALI file), unless the `-a' switch is also specified. + + `' + + `-i' + In normal mode, `gnatmake' compiles all object files and ALI files + into the current directory. If the `-i' switch is used, then + instead object files and ALI files that already exist are + overwritten in place. This means that once a large project is + organized into separate directories in the desired manner, then + `gnatmake' will automatically maintain and update this + organization. If no ALI files are found on the Ada object path + (*Note Search Paths and the Run-Time Library (RTL)::), the new + object and ALI files are created in the directory containing the + source being compiled. If another organization is desired, where + objects and sources are kept in different directories, a useful + technique is to create dummy ALI files in the desired directories. + When detecting such a dummy file, `gnatmake' will be forced to + recompile the corresponding source file, and it will be put the + resulting object and ALI files in the directory where it found the + dummy file. + + `-jN' + Use N processes to carry out the (re)compilations. On a + multiprocessor machine compilations will occur in parallel. In the + event of compilation errors, messages from various compilations + might get interspersed (but `gnatmake' will give you the full + ordered list of failing compiles at the end). If this is + problematic, rerun the make process with n set to 1 to get a clean + list of messages. + + `-k' + Keep going. Continue as much as possible after a compilation + error. To ease the programmer's task in case of compilation + errors, the list of sources for which the compile fails is given + when `gnatmake' terminates. + + If `gnatmake' is invoked with several `file_names' and with this + switch, if there are compilation errors when building an + executable, `gnatmake' will not attempt to build the following + executables. + + `-l' + Link only. Can be combined with `-b' to binding and linking. + Linking will not be performed if combined with `-c' but not with + `-b'. When not combined with `-b' all the units in the closure of + the main program must have been previously compiled and must be up + to date, and the main program need to have been bound. The root + unit specified by FILE_NAME may be given without extension, with + the source extension or, if no GNAT Project File is specified, + with the ALI file extension. + + `-m' + Specifies that the minimum necessary amount of recompilations be + performed. In this mode `gnatmake' ignores time stamp differences + when the only modifications to a source file consist in + adding/removing comments, empty lines, spaces or tabs. This means + that if you have changed the comments in a source file or have + simply reformatted it, using this switch will tell gnatmake not to + recompile files that depend on it (provided other sources on which + these files depend have undergone no semantic modifications). Note + that the debugging information may be out of date with respect to + the sources if the `-m' switch causes a compilation to be + switched, so the use of this switch represents a trade-off between + compilation time and accurate debugging information. + + `-M' + Check if all objects are up to date. If they are, output the object + dependences to `stdout' in a form that can be directly exploited in + a `Makefile'. By default, each source file is prefixed with its + (relative or absolute) directory name. This name is whatever you + specified in the various `-aI' and `-I' switches. If you use + `gnatmake -M' `-q' (see below), only the source file names, + without relative paths, are output. If you just specify the `-M' + switch, dependencies of the GNAT internal system files are + omitted. This is typically what you want. If you also specify the + `-a' switch, dependencies of the GNAT internal files are also + listed. Note that dependencies of the objects in external Ada + libraries (see switch `-aL'DIR in the following list) are never + reported. + + `-n' + Don't compile, bind, or link. Checks if all objects are up to date. + If they are not, the full name of the first file that needs to be + recompiled is printed. Repeated use of this option, followed by + compiling the indicated source file, will eventually result in + recompiling all required units. + + `-o EXEC_NAME' + Output executable name. The name of the final executable program + will be EXEC_NAME. If the `-o' switch is omitted the default name + for the executable will be the name of the input file in + appropriate form for an executable file on the host system. + + This switch cannot be used when invoking `gnatmake' with several + `file_names'. + + `-q' + Quiet. When this flag is not set, the commands carried out by + `gnatmake' are displayed. + + `-s' + Recompile if compiler switches have changed since last compilation. + All compiler switches but -I and -o are taken into account in the + following way: orders between different "first letter" switches + are ignored, but orders between same switches are taken into + account. For example, `-O -O2' is different than `-O2 -O', but `-g + -O' is equivalent to `-O -g'. + + `-u' + Unique. Recompile at most the main file. It implies -c. Combined + with -f, it is equivalent to calling the compiler directly. + + `-v' + Verbose. Displays the reason for all recompilations `gnatmake' + decides are necessary. + + `-z' + No main subprogram. Bind and link the program even if the unit name + given on the command line is a package name. The resulting + executable will execute the elaboration routines of the package + and its closure, then the finalization routines. + + ``gcc' switches' + The switch `-g' or any uppercase switch (other than `-A', `-L' or + `-S') or any switch that is more than one character is passed to + `gcc' (e.g. `-O', `-gnato,' etc.) + + Source and library search path switches: + + `-aIDIR' + When looking for source files also look in directory DIR. The + order in which source files search is undertaken is described in + *Note Search Paths and the Run-Time Library (RTL)::. + + `-aLDIR' + Consider DIR as being an externally provided Ada library. + Instructs `gnatmake' to skip compilation units whose `.ali' files + have been located in directory DIR. This allows you to have + missing bodies for the units in DIR and to ignore out of date + bodies for the same units. You still need to specify the location + of the specs for these units by using the switches `-aIDIR' or + `-IDIR'. Note: this switch is provided for compatibility with + previous versions of `gnatmake'. The easier method of causing + standard libraries to be excluded from consideration is to + write-protect the corresponding ALI files. + + `-aODIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is described in + *Note Search Paths for gnatbind::. + + `-ADIR' + Equivalent to `-aLDIR -aIDIR'. + + `-IDIR' + Equivalent to `-aODIR -aIDIR'. + + `-I-' + Do not look for source files in the directory containing the source + file named in the command line. Do not look for ALI or object + files in the directory where `gnatmake' was invoked. + + `-LDIR' + Add directory DIR to the list of directories in which the linker + Furthermore, under Windows, the sources pointed to by the + libraries path set in the registry are not searched for. will + search for libraries. This is equivalent to `-largs -L'DIR. + + `-nostdinc' + Do not look for source files in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. We look for + the runtime in the following directories, and stop as soon as a + valid runtime is found ("adainclude" or "ada_source_path", and + "adalib" or "ada_object_path" present): + + * /$rts_path + + * /$rts_path + + * /rts-$rts_path + + The selected path is handled like a normal RTS path. + +  + File: gnat_ug_wnt.info, Node: Mode Switches for gnatmake, Next: Notes on the Command Line, Prev: Switches for gnatmake, Up: The GNAT Make Program gnatmake + + Mode Switches for `gnatmake' + ============================ + + The mode switches (referred to as `mode_switches') allow the inclusion + of switches that are to be passed to the compiler itself, the binder or + the linker. The effect of a mode switch is to cause all subsequent + switches up to the end of the switch list, or up to the next mode + switch, to be interpreted as switches to be passed on to the designated + component of GNAT. + + `-cargs SWITCHES' + Compiler switches. Here SWITCHES is a list of switches that are + valid switches for `gcc'. They will be passed on to all compile + steps performed by `gnatmake'. + + `-bargs SWITCHES' + Binder switches. Here SWITCHES is a list of switches that are + valid switches for `gcc'. They will be passed on to all bind steps + performed by `gnatmake'. + + `-largs SWITCHES' + Linker switches. Here SWITCHES is a list of switches that are + valid switches for `gcc'. They will be passed on to all link steps + performed by `gnatmake'. + +  + File: gnat_ug_wnt.info, Node: Notes on the Command Line, Next: How gnatmake Works, Prev: Mode Switches for gnatmake, Up: The GNAT Make Program gnatmake + + Notes on the Command Line + ========================= + + This section contains some additional useful notes on the operation of + the `gnatmake' command. + + * If `gnatmake' finds no ALI files, it recompiles the main program + and all other units required by the main program. This means that + `gnatmake' can be used for the initial compile, as well as during + subsequent steps of the development cycle. + + * If you enter `gnatmake FILE.adb', where `FILE.adb' is a subunit or + body of a generic unit, `gnatmake' recompiles `FILE.adb' (because + it finds no ALI) and stops, issuing a warning. + + * In `gnatmake' the switch `-I' is used to specify both source and + library file paths. Use `-aI' instead if you just want to specify + source paths only and `-aO' if you want to specify library paths + only. + + * `gnatmake' examines both an ALI file and its corresponding object + file for consistency. If an ALI is more recent than its + corresponding object, or if the object file is missing, the + corresponding source will be recompiled. Note that `gnatmake' + expects an ALI and the corresponding object file to be in the same + directory. + + * `gnatmake' will ignore any files whose ALI file is write-protected. + This may conveniently be used to exclude standard libraries from + consideration and in particular it means that the use of the `-f' + switch will not recompile these files unless `-a' is also + specified. + + * `gnatmake' has been designed to make the use of Ada libraries + particularly convenient. Assume you have an Ada library organized + as follows: OBJ-DIR contains the objects and ALI files for of your + Ada compilation units, whereas INCLUDE-DIR contains the specs of + these units, but no bodies. Then to compile a unit stored in + `main.adb', which uses this Ada library you would just type + + $ gnatmake -aIINCLUDE-DIR -aLOBJ-DIR main + + * Using `gnatmake' along with the `-m (minimal recompilation)' + switch provides a mechanism for avoiding unnecessary + rcompilations. Using this switch, you can update the + comments/format of your source files without having to recompile + everything. Note, however, that adding or deleting lines in a + source files may render its debugging info obsolete. If the file + in question is a spec, the impact is rather limited, as that + debugging info will only be useful during the elaboration phase of + your program. For bodies the impact can be more significant. In + all events, your debugger will warn you if a source file is more + recent than the corresponding object, and alert you to the fact + that the debugging information may be out of date. + +  + File: gnat_ug_wnt.info, Node: How gnatmake Works, Next: Examples of gnatmake Usage, Prev: Notes on the Command Line, Up: The GNAT Make Program gnatmake + + How `gnatmake' Works + ==================== + + Generally `gnatmake' automatically performs all necessary + recompilations and you don't need to worry about how it works. However, + it may be useful to have some basic understanding of the `gnatmake' + approach and in particular to understand how it uses the results of + previous compilations without incorrectly depending on them. + + First a definition: an object file is considered "up to date" if the + corresponding ALI file exists and its time stamp predates that of the + object file and if all the source files listed in the dependency + section of this ALI file have time stamps matching those in the ALI + file. This means that neither the source file itself nor any files that + it depends on have been modified, and hence there is no need to + recompile this file. + + `gnatmake' works by first checking if the specified main unit is up + to date. If so, no compilations are required for the main unit. If not, + `gnatmake' compiles the main program to build a new ALI file that + reflects the latest sources. Then the ALI file of the main unit is + examined to find all the source files on which the main program depends, + and `gnatmake' recursively applies the above procedure on all these + files. + + This process ensures that `gnatmake' only trusts the dependencies in + an existing ALI file if they are known to be correct. Otherwise it + always recompiles to determine a new, guaranteed accurate set of + dependencies. As a result the program is compiled "upside down" from + what may be more familiar as the required order of compilation in some + other Ada systems. In particular, clients are compiled before the units + on which they depend. The ability of GNAT to compile in any order is + critical in allowing an order of compilation to be chosen that + guarantees that `gnatmake' will recompute a correct set of new + dependencies if necessary. + + When invoking `gnatmake' with several FILE_NAMES, if a unit is + imported by several of the executables, it will be recompiled at most + once. + +  + File: gnat_ug_wnt.info, Node: Examples of gnatmake Usage, Prev: How gnatmake Works, Up: The GNAT Make Program gnatmake + + Examples of `gnatmake' Usage + ============================ + + `gnatmake hello.adb' + Compile all files necessary to bind and link the main program + `hello.adb' (containing unit `Hello') and bind and link the + resulting object files to generate an executable file `hello'. + + `gnatmake main1 main2 main3' + Compile all files necessary to bind and link the main programs + `main1.adb' (containing unit `Main1'), `main2.adb' (containing + unit `Main2') and `main3.adb' (containing unit `Main3') and bind + and link the resulting object files to generate three executable + files `main1', `main2' and `main3'. + + `gnatmake -q Main_Unit -cargs -O2 -bargs -l' + Compile all files necessary to bind and link the main program unit + `Main_Unit' (from file `main_unit.adb'). All compilations will be + done with optimization level 2 and the order of elaboration will be + listed by the binder. `gnatmake' will operate in quiet mode, not + displaying commands it is executing. + +  + File: gnat_ug_wnt.info, Node: Renaming Files Using gnatchop, Next: Configuration Pragmas, Prev: The GNAT Make Program gnatmake, Up: Top + + Renaming Files Using `gnatchop' + ******************************* + + This chapter discusses how to handle files with multiple units by using + the `gnatchop' utility. This utility is also useful in renaming files + to meet the standard GNAT default file naming conventions. + + * Menu: + + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + +  + File: gnat_ug_wnt.info, Node: Handling Files with Multiple Units, Next: Operating gnatchop in Compilation Mode, Up: Renaming Files Using gnatchop + + Handling Files with Multiple Units + ================================== + + The basic compilation model of GNAT requires that a file submitted to + the compiler have only one unit and there be a strict correspondence + between the file name and the unit name. + + The `gnatchop' utility allows both of these rules to be relaxed, + allowing GNAT to process files which contain multiple compilation units + and files with arbitrary file names. `gnatchop' reads the specified + file and generates one or more output files, containing one unit per + file. The unit and the file name correspond, as required by GNAT. + + If you want to permanently restructure a set of "foreign" files so + that they match the GNAT rules, and do the remaining development using + the GNAT structure, you can simply use `gnatchop' once, generate the + new set of files and work with them from that point on. + + Alternatively, if you want to keep your files in the "foreign" + format, perhaps to maintain compatibility with some other Ada + compilation system, you can set up a procedure where you use `gnatchop' + each time you compile, regarding the source files that it writes as + temporary files that you throw away. + +  + File: gnat_ug_wnt.info, Node: Operating gnatchop in Compilation Mode, Next: Command Line for gnatchop, Prev: Handling Files with Multiple Units, Up: Renaming Files Using gnatchop + + Operating gnatchop in Compilation Mode + ====================================== + + The basic function of `gnatchop' is to take a file with multiple units + and split it into separate files. The boundary between files is + reasonably clear, except for the issue of comments and pragmas. In + default mode, the rule is that any pragmas between units belong to the + previous unit, except that configuration pragmas always belong to the + following unit. Any comments belong to the following unit. These rules + almost always result in the right choice of the split point without + needing to mark it explicitly and most users will find this default to + be what they want. In this default mode it is incorrect to submit a + file containing only configuration pragmas, or one that ends in + configuration pragmas, to `gnatchop'. + + However, using a special option to activate "compilation mode", + `gnatchop' can perform another function, which is to provide exactly + the semantics required by the RM for handling of configuration pragmas + in a compilation. In the absence of configuration pragmas (at the main + file level), this option has no effect, but it causes such + configuration pragmas to be handled in a quite different manner. + + First, in compilation mode, if `gnatchop' is given a file that + consists of only configuration pragmas, then this file is appended to + the `gnat.adc' file in the current directory. This behavior provides + the required behavior described in the RM for the actions to be taken + on submitting such a file to the compiler, namely that these pragmas + should apply to all subsequent compilations in the same compilation + environment. Using GNAT, the current directory, possibly containing a + `gnat.adc' file is the representation of a compilation environment. For + more information on the `gnat.adc' file, see the section on handling of + configuration pragmas *note Handling of Configuration Pragmas::. + + Second, in compilation mode, if `gnatchop' is given a file that + starts with configuration pragmas, and contains one or more units, then + these configuration pragmas are prepended to each of the chopped files. + This behavior provides the required behavior described in the RM for the + actions to be taken on compiling such a file, namely that the pragmas + apply to all units in the compilation, but not to subsequently compiled + units. + + Finally, if configuration pragmas appear between units, they are + appended to the previous unit. This results in the previous unit being + illegal, since the compiler does not accept configuration pragmas that + follow a unit. This provides the required RM behavior that forbids + configuration pragmas other than those preceding the first compilation + unit of a compilation. + + For most purposes, `gnatchop' will be used in default mode. The + compilation mode described above is used only if you need exactly + accurate behavior with respect to compilations, and you have files that + contain multiple units and configuration pragmas. In this circumstance + the use of `gnatchop' with the compilation mode switch provides the + required behavior, and is for example the mode in which GNAT processes + the ACVC tests. + +  + File: gnat_ug_wnt.info, Node: Command Line for gnatchop, Next: Switches for gnatchop, Prev: Operating gnatchop in Compilation Mode, Up: Renaming Files Using gnatchop + + Command Line for `gnatchop' + =========================== + + The `gnatchop' command has the form: + + $ gnatchop switches FILE NAME [FILE NAME FILE NAME ...] + [DIRECTORY] + + The only required argument is the file name of the file to be chopped. + There are no restrictions on the form of this file name. The file itself + contains one or more Ada units, in normal GNAT format, concatenated + together. As shown, more than one file may be presented to be chopped. + + When run in default mode, `gnatchop' generates one output file in + the current directory for each unit in each of the files. + + DIRECTORY, if specified, gives the name of the directory to which + the output files will be written. If it is not specified, all files are + written to the current directory. + + For example, given a file called `hellofiles' containing + + procedure hello; + + with Text_IO; use Text_IO; + procedure hello is + begin + Put_Line ("Hello"); + end hello; + + the command + + $ gnatchop hellofiles + + generates two files in the current directory, one called `hello.ads' + containing the single line that is the procedure spec, and the other + called `hello.adb' containing the remaining text. The original file is + not affected. The generated files can be compiled in the normal manner. + +  + File: gnat_ug_wnt.info, Node: Switches for gnatchop, Next: Examples of gnatchop Usage, Prev: Command Line for gnatchop, Up: Renaming Files Using gnatchop + + Switches for `gnatchop' + ======================= + + `gnatchop' recognizes the following switches: + + `-c' + Causes `gnatchop' to operate in compilation mode, in which + configuration pragmas are handled according to strict RM rules. See + previous section for a full description of this mode. + + `-gnatxxx' + This passes the given `-gnatxxx' switch to `gnat' which is used to + parse the given file. Not all `xxx' options make sense, but for + example, the use of `-gnati2' allows `gnatchop' to process a + source file that uses Latin-2 coding for identifiers. + + `-h' + Causes `gnatchop' to generate a brief help summary to the standard + output file showing usage information. + + `-kMM' + Limit generated file names to the specified number `mm' of + characters. This is useful if the resulting set of files is + required to be interoperable with systems which limit the length + of file names. No space is allowed between the `-k' and the + numeric value. The numeric value may be omitted in which case a + default of `-k8', suitable for use with DOS-like file systems, is + used. If no `-k' switch is present then there is no limit on the + length of file names. + + `-p' + Causes the file modification time stamp of the input file to be + preserved and used for the time stamp of the output file(s). This + may be useful for preserving coherency of time stamps in an + enviroment where `gnatchop' is used as part of a standard build + process. + + `-q' + Causes output of informational messages indicating the set of + generated files to be suppressed. Warnings and error messages are + unaffected. + + `-r' + Generate `Source_Reference' pragmas. Use this switch if the output + files are regarded as temporary and development is to be done in + terms of the original unchopped file. This switch causes + `Source_Reference' pragmas to be inserted into each of the + generated files to refers back to the original file name and line + number. The result is that all error messages refer back to the + original unchopped file. In addition, the debugging information + placed into the object file (when the `-g' switch of `gcc' or + `gnatmake' is specified) also refers back to this original file so + that tools like profilers and debuggers will give information in + terms of the original unchopped file. + + If the original file to be chopped itself contains a + `Source_Reference' pragma referencing a third file, then gnatchop + respects this pragma, and the generated `Source_Reference' pragmas + in the chopped file refer to the original file, with appropriate + line numbers. This is particularly useful when `gnatchop' is used + in conjunction with `gnatprep' to compile files that contain + preprocessing statements and multiple units. + + `-v' + Causes `gnatchop' to operate in verbose mode. The version number + and copyright notice are output, as well as exact copies of the + gnat1 commands spawned to obtain the chop control information. + + `-w' + Overwrite existing file names. Normally `gnatchop' regards it as a + fatal error if there is already a file with the same name as a + file it would otherwise output, in other words if the files to be + chopped contain duplicated units. This switch bypasses this check, + and causes all but the last instance of such duplicated units to + be skipped. + + `--GCC=xxxx' + Specify the path of the GNAT parser to be used. When this switch + is used, no attempt is made to add the prefix to the GNAT parser + executable. + +  + File: gnat_ug_wnt.info, Node: Examples of gnatchop Usage, Prev: Switches for gnatchop, Up: Renaming Files Using gnatchop + + Examples of `gnatchop' Usage + ============================ + + `gnatchop -w hello_s.ada ichbiah/files' + Chops the source file `hello_s.ada'. The output files will be + placed in the directory `ichbiah/files', overwriting any files + with matching names in that directory (no files in the current + directory are modified). + + `gnatchop archive' + Chops the source file `archive' into the current directory. One + useful application of `gnatchop' is in sending sets of sources + around, for example in email messages. The required sources are + simply concatenated (for example, using a Unix `cat' command), and + then `gnatchop' is used at the other end to reconstitute the + original file names. + + `gnatchop file1 file2 file3 direc' + Chops all units in files `file1', `file2', `file3', placing the + resulting files in the directory `direc'. Note that if any units + occur more than once anywhere within this set of files, an error + message is generated, and no files are written. To override this + check, use the `-w' switch, in which case the last occurrence in + the last file will be the one that is output, and earlier + duplicate occurrences for a given unit will be skipped. + +  + File: gnat_ug_wnt.info, Node: Configuration Pragmas, Next: Handling Arbitrary File Naming Conventions Using gnatname, Prev: Renaming Files Using gnatchop, Up: Top + + Configuration Pragmas + ********************* + + In Ada 95, configuration pragmas include those pragmas described as + such in the Ada 95 Reference Manual, as well as + implementation-dependent pragmas that are configuration pragmas. See the + individual descriptions of pragmas in the GNAT Reference Manual for + details on these additional GNAT-specific configuration pragmas. Most + notably, the pragma `Source_File_Name', which allows specifying + non-default names for source files, is a configuration pragma. The + following is a complete list of configuration pragmas recognized by + `GNAT': + + Ada_83 + Ada_95 + C_Pass_By_Copy + Component_Alignment + Discard_Names + Elaboration_Checks + Eliminate + Extend_System + Extensions_Allowed + External_Name_Casing + Float_Representation + Initialize_Scalars + License + Locking_Policy + Long_Float + No_Run_Time + Normalize_Scalars + Polling + Propagate_Exceptions + Queuing_Policy + Ravenscar + Restricted_Run_Time + Restrictions + Reviewable + Source_File_Name + Style_Checks + Suppress + Task_Dispatching_Policy + Unsuppress + Use_VADS_Size + Warnings + Validity_Checks + + * Menu: + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + +  + File: gnat_ug_wnt.info, Node: Handling of Configuration Pragmas, Next: The Configuration Pragmas Files, Up: Configuration Pragmas + + Handling of Configuration Pragmas + ================================= + + Configuration pragmas may either appear at the start of a compilation + unit, in which case they apply only to that unit, or they may apply to + all compilations performed in a given compilation environment. + + GNAT also provides the `gnatchop' utility to provide an automatic + way to handle configuration pragmas following the semantics for + compilations (that is, files with multiple units), described in the RM. + See section *note Operating gnatchop in Compilation Mode:: for details. + However, for most purposes, it will be more convenient to edit the + `gnat.adc' file that contains configuration pragmas directly, as + described in the following section. + +  + File: gnat_ug_wnt.info, Node: The Configuration Pragmas Files, Prev: Handling of Configuration Pragmas, Up: Configuration Pragmas + + The Configuration Pragmas Files + =============================== + + In GNAT a compilation environment is defined by the current directory + at the time that a compile command is given. This current directory is + searched for a file whose name is `gnat.adc'. If this file is present, + it is expected to contain one or more configuration pragmas that will + be applied to the current compilation. However, if the switch `-gnatA' + is used, `gnat.adc' is not considered. + + Configuration pragmas may be entered into the `gnat.adc' file either + by running `gnatchop' on a source file that consists only of + configuration pragmas, or more conveniently by direct editing of the + `gnat.adc' file, which is a standard format source file. + + In addition to `gnat.adc', one additional file containing + configuration pragmas may be applied to the current compilation using + the switch `-gnatec'PATH. PATH must designate an existing file that + contains only configuration pragmas. These configuration pragmas are in + addition to those found in `gnat.adc' (provided `gnat.adc' is present + and switch `-gnatA' is not used). + + It is allowed to specify several switches `-gnatec', however only + the last one on the command line will be taken into account. + +  + File: gnat_ug_wnt.info, Node: Handling Arbitrary File Naming Conventions Using gnatname, Next: GNAT Project Manager, Prev: Configuration Pragmas, Up: Top + + Handling Arbitrary File Naming Conventions Using `gnatname' + *********************************************************** + + * Menu: + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + +  + File: gnat_ug_wnt.info, Node: Arbitrary File Naming Conventions, Next: Running gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Arbitrary File Naming Conventions + ================================= + + The GNAT compiler must be able to know the source file name of a + compilation unit. When using the standard GNAT default file naming + conventions (`.ads' for specs, `.adb' for bodies), the GNAT compiler + does not need additional information. + + When the source file names do not follow the standard GNAT default file + naming conventions, the GNAT compiler must be given additional + information through a configuration pragmas file (see *Note + Configuration Pragmas::) or a project file. When the non standard file + naming conventions are well-defined, a small number of pragmas + `Source_File_Name' specifying a naming pattern (see *Note Alternative + File Naming Schemes::) may be sufficient. However, if the file naming + conventions are irregular or arbitrary, a number of pragma + `Source_File_Name' for individual compilation units must be defined. + To help maintain the correspondence between compilation unit names and + source file names within the compiler, GNAT provides a tool `gnatname' + to generate the required pragmas for a set of files. + +  + File: gnat_ug_wnt.info, Node: Running gnatname, Next: Switches for gnatname, Prev: Arbitrary File Naming Conventions, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Running `gnatname' + ================== + + The usual form of the `gnatname' command is + + $ gnatname [SWITCHES] NAMING_PATTERN [NAMING_PATTERNS] + + All of the arguments are optional. If invoked without any argument, + `gnatname' will display its usage. + + When used with at least one naming pattern, `gnatname' will attempt to + find all the compilation units in files that follow at least one of the + naming patterns. To find these compilation units, `gnatname' will use + the GNAT compiler in syntax-check-only mode on all regular files. + + One or several Naming Patterns may be given as arguments to `gnatname'. + Each Naming Pattern is enclosed between double quotes. A Naming + Pattern is a regular expression similar to the wildcard patterns used + in file names by the Unix shells or the DOS prompt. + + Examples of Naming Patterns are + + "*.[12].ada" + "*.ad[sb]*" + "body_*" "spec_*" + + For a more complete description of the syntax of Naming Patterns, see + the second kind of regular expressions described in `g-regexp.ads' (the + "Glob" regular expressions). + + When invoked with no switches, `gnatname' will create a configuration + pragmas file `gnat.adc' in the current working directory, with pragmas + `Source_File_Name' for each file that contains a valid Ada unit. + +  + File: gnat_ug_wnt.info, Node: Switches for gnatname, Next: Examples of gnatname Usage, Prev: Running gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Switches for `gnatname' + ======================= + + Switches for `gnatname' must precede any specified Naming Pattern. + + You may specify any of the following switches to `gnatname': + + `-c`file'' + Create a configuration pragmas file `file' (instead of the default + `gnat.adc'). There may be zero, one or more space between `-c' and + `file'. `file' may include directory information. `file' must be + writeable. There may be only one switch `-c'. When a switch `-c' is + specified, no switch `-P' may be specified (see below). + + `-d`dir'' + Look for source files in directory `dir'. There may be zero, one + or more spaces between `-d' and `dir'. When a switch `-d' is + specified, the current working directory will not be searched for + source files, unless it is explictly specified with a `-d' or `-D' + switch. Several switches `-d' may be specified. If `dir' is a + relative path, it is relative to the directory of the + configuration pragmas file specified with switch `-c', or to the + directory of the project file specified with switch `-P' or, if + neither switch `-c' nor switch `-P' are specified, it is relative + to the current working directory. The directory specified with + switch `-c' must exist and be readable. + + `-D`file'' + Look for source files in all directories listed in text file + `file'. There may be zero, one or more spaces between `-d' and + `dir'. `file' must be an existing, readable text file. Each non + empty line in `file' must be a directory. Specifying switch `-D' + is equivalent to specifying as many switches `-d' as there are non + empty lines in `file'. + + `-h' + Output usage (help) information. The output is written to `stdout'. + + `-P`proj'' + Create or update project file `proj'. There may be zero, one or + more space between `-P' and `proj'. `proj' may include directory + information. `proj' must be writeable. There may be only one + switch `-P'. When a switch `-P' is specified, no switch `-c' may + be specified. + + `-v' + Verbose mode. Output detailed explanation of behavior to `stdout'. + This includes name of the file written, the name of the + directories to search and, for each file in those directories + whose name matches at least one of the Naming Patterns, an + indication of whether the file contains a unit, and if so the name + of the unit. + + `-v -v' + Very Verbose mode. In addition to the output produced in verbose + mode, for each file in the searched directories whose name matches + none of the Naming Patterns, an indication is given that there is + no match. + + `-x`pattern'' + Excluded patterns. Using this switch, it is possible to exclude + some files that would match the name patterns. For example, + `"gnatname -x "*_nt.ada" "*.ada"' will look for Ada units in all + files with the `.ada' extension, except those whose names end with + `_nt.ada'. + +  + File: gnat_ug_wnt.info, Node: Examples of gnatname Usage, Prev: Switches for gnatname, Up: Handling Arbitrary File Naming Conventions Using gnatname + + Examples of `gnatname' Usage + ============================ + + $ gnatname -c /home/me/names.adc -d sources "[a-z]*.ada*" + + In this example, the directory `/home/me' must already exist and be + writeable. In addition, the directory `/home/me/sources' (specified by + `-d sources') must exist and be readable. Note the optional spaces after + `-c' and `-d'. + + $ gnatname -P/home/me/proj -x "*_nt_body.ada" -dsources -dsources/plus -Dcommon_dirs.txt "body_*" "spec_*" + + Note that several switches `-d' may be used, even in conjunction + with one or several switches `-D'. Several Naming Patterns and one + excluded pattern are used in this example. + +  + File: gnat_ug_wnt.info, Node: GNAT Project Manager, Next: Elaboration Order Handling in GNAT, Prev: Handling Arbitrary File Naming Conventions Using gnatname, Up: Top + + GNAT Project Manager + ******************** + + * Menu: + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + +  + File: gnat_ug_wnt.info, Node: Introduction, Next: Examples of Project Files, Up: GNAT Project Manager + + Introduction + ============ + + This chapter describes GNAT's _Project Manager_, a facility that lets + you configure various properties for a collection of source files. In + particular, you can specify: + * The directory or set of directories containing the source files, + and/or the names of the specific source files themselves + + * The directory in which the compiler's output (`ALI' files, object + files, tree files) will be placed + + * The directory in which the executable programs will be placed + + * Switch settings for any of the project-enabled tools (`gnatmake', + compiler, binder, linker, `gnatls', `gnatxref', `gnatfind'); you + can apply these settings either globally or to individual units + + * The source files containing the main subprogram(s) to be built + + * The source programming language(s) (currently Ada and/or C) + + * Source file naming conventions; you can specify these either + globally or for individual units + + * Menu: + + * Project Files:: + +  + File: gnat_ug_wnt.info, Node: Project Files, Up: Introduction + + Project Files + ------------- + + A "project" is a specific set of values for these properties. You can + define a project's settings in a "project file", a text file with an + Ada-like syntax; a property value is either a string or a list of + strings. Properties that are not explicitly set receive default + values. A project file may interrogate the values of "external + variables" (user-defined command-line switches or environment + variables), and it may specify property settings conditionally, based + on the value of such variables. + + In simple cases, a project's source files depend only on other + source files in the same project, or on the predefined libraries. + ("Dependence" is in the technical sense; for example, one Ada unit + "with"ing another.) However, the Project Manager also allows much more + sophisticated arrangements, with the source files in one project + depending on source files in other projects: + * One project can _import_ other projects containing needed source + files. + + * You can organize GNAT projects in a hierarchy: a _child_ project + can extend a _parent_ project, inheriting the parent's source + files and optionally overriding any of them with alternative + versions + + More generally, the Project Manager lets you structure large development + efforts into hierarchical subsystems, with build decisions deferred to + the subsystem level and thus different compilation environments (switch + settings) used for different subsystems. + + The Project Manager is invoked through the `-P_projectfile_' switch + to `gnatmake' or to the `gnat' front driver. If you want to define (on + the command line) an external variable that is queried by the project + file, additionally use the `-X_vbl_=_value_' switch. The Project + Manager parses and interprets the project file, and drives the invoked + tool based on the project settings. + + The Project Manager supports a wide range of development strategies, + for systems of all sizes. Some typical practices that are easily + handled: + * Using a common set of source files, but generating object files in + different directories via different switch settings + + * Using a mostly-shared set of source files, but with different + versions of some unit or units + + The destination of an executable can be controlled inside a project file + using the `-o' switch. In the absence of such a switch either inside + the project file or on the command line, any executable files generated + by `gnatmake' will be placed in the directory `Exec_Dir' specified in + the project file. If no `Exec_Dir' is specified, they will be placed in + the object directory of the project. + + You can use project files to achieve some of the effects of a source + versioning system (for example, defining separate projects for the + different sets of sources that comprise different releases) but the + Project Manager is independent of any source configuration management + tools that might be used by the developers. + + The next section introduces the main features of GNAT's project + facility through a sequence of examples; subsequent sections will + present the syntax and semantics in more detail. + +  + File: gnat_ug_wnt.info, Node: Examples of Project Files, Next: Project File Syntax, Prev: Introduction, Up: GNAT Project Manager + + Examples of Project Files + ========================= + + This section illustrates some of the typical uses of project files and + explains their basic structure and behavior. + + * Menu: + + * Common Sources with Different Switches and Different Output Directories:: + * Using External Variables:: + * Importing Other Projects:: + * Extending a Project:: + +  + File: gnat_ug_wnt.info, Node: Common Sources with Different Switches and Different Output Directories, Next: Using External Variables, Up: Examples of Project Files + + Common Sources with Different Switches and Different Output Directories + ----------------------------------------------------------------------- + + * Menu: + + * Source Files:: + * Specifying the Object Directory:: + * Specifying the Exec Directory:: + * Project File Packages:: + * Specifying Switch Settings:: + * Main Subprograms:: + * Source File Naming Conventions:: + * Source Language(s):: + + Assume that the Ada source files `pack.ads', `pack.adb', and `proc.adb' + are in the `/common' directory. The file `proc.adb' contains an Ada + main subprogram `Proc' that "with"s package `Pack'. We want to compile + these source files under two sets of switches: + * When debugging, we want to pass the `-g' switch to `gnatmake', and + the `-gnata', `-gnato', and `-gnatE' switches to the compiler; the + compiler's output is to appear in `/common/debug' + + * When preparing a release version, we want to pass the `-O2' switch + to the compiler; the compiler's output is to appear in + `/common/release' + + The GNAT project files shown below, respectively `debug.gpr' and + `release.gpr' in the `/common' directory, achieve these effects. + + Diagrammatically: + /common + debug.gpr + release.gpr + pack.ads + pack.adb + proc.adb + /common/debug {-g, -gnata, -gnato, -gnatE} + proc.ali, proc.o + pack.ali, pack.o + /common/release {-O2} + proc.ali, proc.o + pack.ali, pack.o + Here are the project files: + project Debug is + for Object_Dir use "debug"; + for Main use ("proc"); + + package Builder is + for Default_Switches ("Ada") use ("-g"); + end Builder; + + package Compiler is + for Default_Switches ("Ada") + use ("-fstack-check", "-gnata", "-gnato", "-gnatE"); + end Compiler; + end Debug; + + project Release is + for Object_Dir use "release"; + for Exec_Dir use "."; + for Main use ("proc"); + + package Compiler is + for Default_Switches ("Ada") use ("-O2"); + end Compiler; + end Release; + + The name of the project defined by `debug.gpr' is `"Debug"' (case + insensitive), and analogously the project defined by `release.gpr' is + `"Release"'. For consistency the file should have the same name as the + project, and the project file's extension should be `"gpr"'. These + conventions are not required, but a warning is issued if they are not + followed. + + If the current directory is `/temp', then the command + gnatmake -P/common/debug.gpr + + generates object and ALI files in `/common/debug', and the `proc' + executable also in `/common/debug', using the switch settings defined in + the project file. + + Likewise, the command + gnatmake -P/common/release.gpr + + generates object and ALI files in `/common/release', and the `proc' + executable in `/common', using the switch settings from the project + file. + +  + File: gnat_ug_wnt.info, Node: Source Files, Next: Specifying the Object Directory, Up: Common Sources with Different Switches and Different Output Directories + + Source Files + ............ + + If a project file does not explicitly specify a set of source + directories or a set of source files, then by default the project's + source files are the Ada source files in the project file directory. + Thus `pack.ads', `pack.adb', and `proc.adb' are the source files for + both projects. + +  + File: gnat_ug_wnt.info, Node: Specifying the Object Directory, Next: Specifying the Exec Directory, Prev: Source Files, Up: Common Sources with Different Switches and Different Output Directories + + Specifying the Object Directory + ............................... + + Several project properties are modeled by Ada-style _attributes_; you + define the property by supplying the equivalent of an Ada attribute + definition clause in the project file. A project's object directory is + such a property; the corresponding attribute is `Object_Dir', and its + value is a string expression. A directory may be specified either as + absolute or as relative; in the latter case, it is relative to the + project file directory. Thus the compiler's output is directed to + `/common/debug' (for the `Debug' project) and to `/common/release' (for + the `Release' project). If `Object_Dir' is not specified, then the + default is the project file directory. + +  + File: gnat_ug_wnt.info, Node: Specifying the Exec Directory, Next: Project File Packages, Prev: Specifying the Object Directory, Up: Common Sources with Different Switches and Different Output Directories + + Specifying the Exec Directory + ............................. + + A project's exec directory is another property; the corresponding + attribute is `Exec_Dir', and its value is also a string expression, + either specified as relative or absolute. If `Exec_Dir' is not + specified, then the default is the object directory (which may also be + the project file directory if attribute `Object_Dir' is not specified). + Thus the executable is placed in `/common/debug' for the `Debug' + project (attribute `Exec_Dir' not specified) and in `/common' for the + `Release' project. + +  + File: gnat_ug_wnt.info, Node: Project File Packages, Next: Specifying Switch Settings, Prev: Specifying the Exec Directory, Up: Common Sources with Different Switches and Different Output Directories + + Project File Packages + ..................... + + A GNAT tool integrated with the Project Manager is modeled by a + corresponding package in the project file. The `Debug' project defines + the packages `Builder' (for `gnatmake') and `Compiler'; the `Release' + project defines only the `Compiler' package. + + The Ada package syntax is not to be taken literally. Although + packages in project files bear a surface resemblance to packages in Ada + source code, the notation is simply a way to convey a grouping of + properties for a named entity. Indeed, the package names permitted in + project files are restricted to a predefined set, corresponding to the + project-aware tools, and the contents of packages are limited to a + small set of constructs. The packages in the example above contain + attribute definitions. + +  + File: gnat_ug_wnt.info, Node: Specifying Switch Settings, Next: Main Subprograms, Prev: Project File Packages, Up: Common Sources with Different Switches and Different Output Directories + + Specifying Switch Settings + .......................... + + Switch settings for a project-aware tool can be specified through + attributes in the package corresponding to the tool. The example above + illustrates one of the relevant attributes, `Default_Switches', defined + in the packages in both project files. Unlike simple attributes like + `Source_Dirs', `Default_Switches' is known as an _associative array_. + When you define this attribute, you must supply an "index" (a literal + string), and the effect of the attribute definition is to set the value + of the "array" at the specified "index". For the `Default_Switches' + attribute, the index is a programming language (in our case, Ada) , and + the value specified (after `use') must be a list of string expressions. + + The attributes permitted in project files are restricted to a + predefined set. Some may appear at project level, others in packages. + For any attribute that is an associate array, the index must always be a + literal string, but the restrictions on this string (e.g., a file name + or a language name) depend on the individual attribute. Also depending + on the attribute, its specified value will need to be either a string + or a string list. + + In the `Debug' project, we set the switches for two tools, + `gnatmake' and the compiler, and thus we include corresponding + packages, with each package defining the `Default_Switches' attribute + with index `"Ada"'. Note that the package corresponding to `gnatmake' + is named `Builder'. The `Release' project is similar, but with just + the `Compiler' package. + + In project `Debug' above the switches starting with `-gnat' that are + specified in package `Compiler' could have been placed in package + `Builder', since `gnatmake' transmits all such switches to the compiler. + +  + File: gnat_ug_wnt.info, Node: Main Subprograms, Next: Source File Naming Conventions, Prev: Specifying Switch Settings, Up: Common Sources with Different Switches and Different Output Directories + + Main Subprograms + ................ + + One of the properties of a project is its list of main subprograms + (actually a list of names of source files containing main subprograms, + with the file extension optional. This property is captured in the + `Main' attribute, whose value is a list of strings. If a project + defines the `Main' attribute, then you do not need to identify the main + subprogram(s) when invoking `gnatmake' (see *Note gnatmake and Project + Files::). + +  + File: gnat_ug_wnt.info, Node: Source File Naming Conventions, Next: Source Language(s), Prev: Main Subprograms, Up: Common Sources with Different Switches and Different Output Directories + + Source File Naming Conventions + .............................. + + Since the project files do not specify any source file naming + conventions, the GNAT defaults are used. The mechanism for defining + source file naming conventions - a package named `Naming' - will be + described below (*note Naming Schemes::). + +  + File: gnat_ug_wnt.info, Node: Source Language(s), Prev: Source File Naming Conventions, Up: Common Sources with Different Switches and Different Output Directories + + Source Language(s) + .................. + + Since the project files do not specify a `Languages' attribute, by + default the GNAT tools assume that the language of the project file is + Ada. More generally, a project can comprise source files in Ada, C, + and/or other languages. + +  + File: gnat_ug_wnt.info, Node: Using External Variables, Next: Importing Other Projects, Prev: Common Sources with Different Switches and Different Output Directories, Up: Examples of Project Files + + Using External Variables + ------------------------ + + Instead of supplying different project files for debug and release, we + can define a single project file that queries an external variable (set + either on the command line or via an environment variable) in order to + conditionally define the appropriate settings. Again, assume that the + source files `pack.ads', `pack.adb', and `proc.adb' are located in + directory `/common'. The following project file, `build.gpr', queries + the external variable named `STYLE' and defines an object directory and + switch settings based on whether the value is `"deb"' (debug) or + `"rel"' (release), where the default is `"deb"'. + + project Build is + for Main use ("proc"); + + type Style_Type is ("deb", "rel"); + Style : Style_Type := external ("STYLE", "deb"); + + case Style is + when "deb" => + for Object_Dir use "debug"; + + when "rel" => + for Object_Dir use "release"; + for Exec_Dir use "."; + end case; + + package Builder is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-g"); + end case; + + end Builder; + + package Compiler is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-gnata", "-gnato", "-gnatE"); + + when "rel" => + for Default_Switches ("Ada") use ("-O2"); + end case; + + end Compiler; + + end Build; + + `Style_Type' is an example of a _string type_, which is the project + file analog of an Ada enumeration type but containing string literals + rather than identifiers. `Style' is declared as a variable of this + type. + + The form `external("STYLE", "deb")' is known as an _external + reference_; its first argument is the name of an _external variable_, + and the second argument is a default value to be used if the external + variable doesn't exist. You can define an external variable on the + command line via the `-X' switch, or you can use an environment + variable as an external variable. + + Each `case' construct is expanded by the Project Manager based on the + value of `Style'. Thus the command + gnatmake -P/common/build.gpr -XSTYLE=deb + + is equivalent to the `gnatmake' invocation using the project file + `debug.gpr' in the earlier example. So is the command + gnatmake -P/common/build.gpr + + since `"deb"' is the default for `STYLE'. + + Analogously, + gnatmake -P/common/build.gpr -XSTYLE=rel + + is equivalent to the `gnatmake' invocation using the project file + `release.gpr' in the earlier example. + +  + File: gnat_ug_wnt.info, Node: Importing Other Projects, Next: Extending a Project, Prev: Using External Variables, Up: Examples of Project Files + + Importing Other Projects + ------------------------ + + A compilation unit in a source file in one project may depend on + compilation units in source files in other projects. To obtain this + behavior, the dependent project must _import_ the projects containing + the needed source files. This effect is embodied in syntax similar to + an Ada `with' clause, but the "with"ed entities are strings denoting + project files. + + As an example, suppose that the two projects `GUI_Proj' and + `Comm_Proj' are defined in the project files `gui_proj.gpr' and + `comm_proj.gpr' in directories `/gui' and `/comm', respectively. + Assume that the source files for `GUI_Proj' are `gui.ads' and + `gui.adb', and that the source files for `Comm_Proj' are `comm.ads' and + `comm.adb', with each set of files located in its respective project + file directory. Diagrammatically: + + /gui + gui_proj.gpr + gui.ads + gui.adb + + /comm + comm_proj.gpr + comm.ads + comm.adb + + We want to develop an application in directory `/app' that "with"s the + packages `GUI' and `Comm', using the properties of the corresponding + project files (e.g. the switch settings and object directory). + Skeletal code for a main procedure might be something like the + following: + + with GUI, Comm; + procedure App_Main is + ... + begin + ... + end App_Main; + + Here is a project file, `app_proj.gpr', that achieves the desired + effect: + + with "/gui/gui_proj", "/comm/comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + + Building an executable is achieved through the command: + gnatmake -P/app/app_proj + + which will generate the `app_main' executable in the directory where + `app_proj.gpr' resides. + + If an imported project file uses the standard extension (`gpr') then + (as illustrated above) the `with' clause can omit the extension. + + Our example specified an absolute path for each imported project + file. Alternatively, you can omit the directory if either + * The imported project file is in the same directory as the + importing project file, or + + * You have defined an environment variable `ADA_PROJECT_PATH' that + includes the directory containing the needed project file. + + Thus, if we define `ADA_PROJECT_PATH' to include `/gui' and `/comm', + then our project file `app_proj.gpr' could be written as follows: + + with "gui_proj", "comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + + Importing other projects raises the possibility of ambiguities. For + example, the same unit might be present in different imported projects, + or it might be present in both the importing project and an imported + project. Both of these conditions are errors. Note that in the + current version of the Project Manager, it is illegal to have an + ambiguous unit even if the unit is never referenced by the importing + project. This restriction may be relaxed in a future release. + +  + File: gnat_ug_wnt.info, Node: Extending a Project, Prev: Importing Other Projects, Up: Examples of Project Files + + Extending a Project + ------------------- + + A common situation in large software systems is to have multiple + implementations for a common interface; in Ada terms, multiple versions + of a package body for the same specification. For example, one + implementation might be safe for use in tasking programs, while another + might only be used in sequential applications. This can be modeled in + GNAT using the concept of _project extension_. If one project (the + "child") _extends_ another project (the "parent") then by default all + source files of the parent project are inherited by the child, but the + child project can override any of the parent's source files with new + versions, and can also add new files. This facility is the project + analog of extension in Object-Oriented Programming. Project + hierarchies are permitted (a child project may be the parent of yet + another project), and a project that inherits one project can also + import other projects. + + As an example, suppose that directory `/seq' contains the project + file `seq_proj.gpr' and the source files `pack.ads', `pack.adb', and + `proc.adb': + + /seq + pack.ads + pack.adb + proc.adb + seq_proj.gpr + + Note that the project file can simply be empty (that is, no attribute or + package is defined): + + project Seq_Proj is + end Seq_Proj; + + implying that its source files are all the Ada source files in the + project directory. + + Suppose we want to supply an alternate version of `pack.adb', in + directory `/tasking', but use the existing versions of `pack.ads' and + `proc.adb'. We can define a project `Tasking_Proj' that inherits + `Seq_Proj': + + /tasking + pack.adb + tasking_proj.gpr + + project Tasking_Proj extends "/seq/seq_proj" is + end Tasking_Proj; + + The version of `pack.adb' used in a build depends on which project file + is specified. + + Note that we could have designed this using project import rather + than project inheritance; a `base' project would contain the sources for + `pack.ads' and `proc.adb', a sequential project would import `base' and + add `pack.adb', and likewise a tasking project would import `base' and + add a different version of `pack.adb'. The choice depends on whether + other sources in the original project need to be overridden. If they + do, then project extension is necessary, otherwise, importing is + sufficient. + +  + File: gnat_ug_wnt.info, Node: Project File Syntax, Next: Objects and Sources in Project Files, Prev: Examples of Project Files, Up: GNAT Project Manager + + Project File Syntax + =================== + + * Menu: + + * Basic Syntax:: + * Packages:: + * Expressions:: + * String Types:: + * Variables:: + * Attributes:: + * Associative Array Attributes:: + * case Constructions:: + + This section describes the structure of project files. + + A project may be an _independent project_, entirely defined by a + single project file. Any Ada source file in an independent project + depends only on the predefined library and other Ada source files in + the same project. + + A project may also "depend on" other projects, in either or both of the + following ways: + * It may import any number of projects + + * It may extend at most one other project + + The dependence relation is a directed acyclic graph (the subgraph + reflecting the "extends" relation is a tree). + + A project's "immediate sources" are the source files directly + defined by that project, either implicitly by residing in the project + file's directory, or explicitly through any of the source-related + attributes described below. More generally, a project PROJ's "sources" + are the immediate sources of PROJ together with the immediate sources + (unless overridden) of any project on which PROJ depends (either + directly or indirectly). + +  + File: gnat_ug_wnt.info, Node: Basic Syntax, Next: Packages, Up: Project File Syntax + + Basic Syntax + ------------ + + As seen in the earlier examples, project files have an Ada-like syntax. + The minimal project file is: + project Empty is + + end Empty; + + The identifier `Empty' is the name of the project. This project name + must be present after the reserved word `end' at the end of the project + file, followed by a semi-colon. + + Any name in a project file, such as the project name or a variable + name, has the same syntax as an Ada identifier. + + The reserved words of project files are the Ada reserved words plus + `extends', `external', and `project'. Note that the only Ada reserved + words currently used in project file syntax are: + + * `case' + + * `end' + + * `for' + + * `is' + + * `others' + + * `package' + + * `renames' + + * `type' + + * `use' + + * `when' + + * `with' + + Comments in project files have the same syntax as in Ada, two + consecutives hyphens through the end of the line. + +  + File: gnat_ug_wnt.info, Node: Packages, Next: Expressions, Prev: Basic Syntax, Up: Project File Syntax + + Packages + -------- + + A project file may contain _packages_. The name of a package must be one + of the identifiers (case insensitive) from a predefined list, and a + package with a given name may only appear once in a project file. The + predefined list includes the following packages: + + * `Naming' + + * `Builder' + + * `Compiler' + + * `Binder' + + * `Linker' + + * `Finder' + + * `Cross_Reference' + + * `gnatls' + + (The complete list of the package names and their attributes can be + found in file `prj-attr.adb'). + + In its simplest form, a package may be empty: + + project Simple is + package Builder is + end Builder; + end Simple; + + A package may contain _attribute declarations_, _variable declarations_ + and _case constructions_, as will be described below. + + When there is ambiguity between a project name and a package name, + the name always designates the project. To avoid possible confusion, it + is always a good idea to avoid naming a project with one of the names + allowed for packages or any name that starts with `gnat'. + +  + File: gnat_ug_wnt.info, Node: Expressions, Next: String Types, Prev: Packages, Up: Project File Syntax + + Expressions + ----------- + + An _expression_ is either a _string expression_ or a _string list + expression_. + + A _string expression_ is either a _simple string expression_ or a + _compound string expression_. + + A _simple string expression_ is one of the following: + * A literal string; e.g.`"comm/my_proj.gpr"' + + * A string-valued variable reference (see *Note Variables::) + + * A string-valued attribute reference (see *Note Attributes::) + + * An external reference (see *Note External References in Project + Files::) + + A _compound string expression_ is a concatenation of string expressions, + using `"&"' + Path & "/" & File_Name & ".ads" + + A _string list expression_ is either a _simple string list expression_ + or a _compound string list expression_. + + A _simple string list expression_ is one of the following: + * A parenthesized list of zero or more string expressions, separated + by commas + File_Names := (File_Name, "gnat.adc", File_Name & ".orig"); + Empty_List := (); + + * A string list-valued variable reference + + * A string list-valued attribute reference + + A _compound string list expression_ is the concatenation (using `"&"') + of a simple string list expression and an expression. Note that each + term in a compound string list expression, except the first, may be + either a string expression or a string list expression. + + File_Name_List := () & File_Name; -- One string in this list + Extended_File_Name_List := File_Name_List & (File_Name & ".orig"); + -- Two strings + Big_List := File_Name_List & Extended_File_Name_List; + -- Concatenation of two string lists: three strings + Illegal_List := "gnat.adc" & Extended_File_Name_List; + -- Illegal: must start with a string list + +  + File: gnat_ug_wnt.info, Node: String Types, Next: Variables, Prev: Expressions, Up: Project File Syntax + + String Types + ------------ + + The value of a variable may be restricted to a list of string literals. + The restricted list of string literals is given in a _string type + declaration_. + + Here is an example of a string type declaration: + + type OS is ("NT, "nt", "Unix", "Linux", "other OS"); + + Variables of a string type are called _typed variables_; all other + variables are called _untyped variables_. Typed variables are + particularly useful in `case' constructions (see *Note case + Constructions::). + + A string type declaration starts with the reserved word `type', + followed by the name of the string type (case-insensitive), followed by + the reserved word `is', followed by a parenthesized list of one or more + string literals separated by commas, followed by a semicolon. + + The string literals in the list are case sensitive and must all be + different. They may include any graphic characters allowed in Ada, + including spaces. + + A string type may only be declared at the project level, not inside + a package. + + A string type may be referenced by its name if it has been declared + in the same project file, or by its project name, followed by a dot, + followed by the string type name. + +  + File: gnat_ug_wnt.info, Node: Variables, Next: Attributes, Prev: String Types, Up: Project File Syntax + + Variables + --------- + + A variable may be declared at the project file level, or in a package. + Here are some examples of variable declarations: + + This_OS : OS := external ("OS"); -- a typed variable declaration + That_OS := "Linux"; -- an untyped variable declaration + + A _typed variable declaration_ includes the variable name, followed by + a colon, followed by the name of a string type, followed by `:=', + followed by a simple string expression. + + An _untyped variable declaration_ includes the variable name, + followed by `:=', followed by an expression. Note that, despite the + terminology, this form of "declaration" resembles more an assignment + than a declaration in Ada. It is a declaration in several senses: + * The variable name does not need to be defined previously + + * The declaration establishes the _kind_ (string versus string list) + of the variable, and later declarations of the same variable need + to be consistent with this + + A string variable declaration (typed or untyped) declares a variable + whose value is a string. This variable may be used as a string + expression. + File_Name := "readme.txt"; + Saved_File_Name := File_Name & ".saved"; + + A string list variable declaration declares a variable whose value is a + list of strings. The list may contain any number (zero or more) of + strings. + + Empty_List := (); + List_With_One_Element := ("-gnaty"); + List_With_Two_Elements := List_With_One_Element & "-gnatg"; + Long_List := ("main.ada", "pack1_.ada", "pack1.ada", "pack2_.ada" + "pack2.ada", "util_.ada", "util.ada"); + + The same typed variable may not be declared more than once at project + level, and it may not be declared more than once in any package; it is + in effect a constant or a readonly variable. + + The same untyped variable may be declared several times. In this + case, the new value replaces the old one, and any subsequent reference + to the variable uses the new value. However, as noted above, if a + variable has been declared as a string, all subsequent declarations + must give it a string value. Similarly, if a variable has been declared + as a string list, all subsequent declarations must give it a string + list value. + + A _variable reference_ may take several forms: + + * The simple variable name, for a variable in the current package + (if any) or in the current project + + * A context name, followed by a dot, followed by the variable name. + + A _context_ may be one of the following: + + * The name of an existing package in the current project + + * The name of an imported project of the current project + + * The name of an ancestor project (i.e., a project extended by the + current project, either directly or indirectly) + + * An imported/parent project name, followed by a dot, followed by a + package name + + A variable reference may be used in an expression. + +  + File: gnat_ug_wnt.info, Node: Attributes, Next: Associative Array Attributes, Prev: Variables, Up: Project File Syntax + + Attributes + ---------- + + A project (and its packages) may have _attributes_ that define the + project's properties. Some attributes have values that are strings; + others have values that are string lists. + + There are two categories of attributes: _simple attributes_ and + _associative arrays_ (see *Note Associative Array Attributes::). + + The names of the attributes are restricted; there is a list of + project attributes, and a list of package attributes for each package. + The names are not case sensitive. + + The project attributes are as follows (all are simple attributes): + + _Attribute Name_ _Value_ + `Source_Files' string list + `Source_Dirs' string list + `Source_List_File' string + `Object_Dir' string + `Exec_Dir' string + `Main' string list + `Languages' string list + `Library_Dir' string + `Library_Name' string + `Library_Kind' string + `Library_Elaboration' string + `Library_Version' string + + The attributes for package `Naming' are as follows (see *Note Naming + Schemes::): + + Attribute Name Category Index Value + `Specification_Suffix' associative language name string + array + `Implementation_Suffix' associative language name string + array + `Separate_Suffix' simple n/a string + attribute + `Casing' simple n/a string + attribute + `Dot_Replacement' simple n/a string + attribute + `Specification' associative Ada unit name string + array + `Implementation' associative Ada unit name string + array + `Specification_Exceptions' associative language name string list + array + `Implementation_Exceptions' associative language name string list + array + + The attributes for package `Builder', `Compiler', `Binder', `Linker', + `Cross_Reference', and `Finder' are as follows (see *Note Switches and + Project Files::). + + Attribute Name Category Index Value + `Default_Switches' associative language name string list + array + `Switches' associative file name string list + array + + In addition, package `Builder' has a single string attribute + `Local_Configuration_Pragmas' and package `Builder' has a single string + attribute `Global_Configuration_Pragmas'. + + The attribute for package `Glide' are not documented: they are for + internal use only. + + Each simple attribute has a default value: the empty string (for + string-valued attributes) and the empty list (for string list-valued + attributes). + + Similar to variable declarations, an attribute declaration defines a + new value for an attribute. + + Examples of simple attribute declarations: + + for Object_Dir use "objects"; + for Source_Dirs use ("units", "test/drivers"); + + A "simple attribute declaration" starts with the reserved word `for', + followed by the name of the attribute, followed by the reserved word + `use', followed by an expression (whose kind depends on the attribute), + followed by a semicolon. + + Attributes may be referenced in expressions. The general form for + such a reference is `'': the entity for which the + attribute is defined, followed by an apostrophe, followed by the name + of the attribute. For associative array attributes, a litteral string + between parentheses need to be supplied as index. + + Examples are: + + project'Object_Dir + Naming'Dot_Replacement + Imported_Project'Source_Dirs + Imported_Project.Naming'Casing + Builder'Default_Switches("Ada") + + The entity may be: + * `project' for an attribute of the current project + + * The name of an existing package of the current project + + * The name of an imported project + + * The name of a parent project (extended by the current project) + + * An imported/parent project name, followed by a dot, followed + by a package name + + Example: + project Prj is + for Source_Dirs use project'Source_Dirs & "units"; + for Source_Dirs use project'Source_Dirs & "test/drivers" + end Prj; + + In the first attribute declaration, initially the attribute + `Source_Dirs' has the default value: an empty string list. After this + declaration, `Source_Dirs' is a string list of one element: "units". + After the second attribute declaration `Source_Dirs' is a string list of + two elements: "units" and "test/drivers". + + Note: this example is for illustration only. In practice, the + project file would contain only one attribute declaration: + + for Source_Dirs use ("units", "test/drivers"); + +  + File: gnat_ug_wnt.info, Node: Associative Array Attributes, Next: case Constructions, Prev: Attributes, Up: Project File Syntax + + Associative Array Attributes + ---------------------------- + + Some attributes are defined as _associative arrays_. An associative + array may be regarded as a function that takes a string as a parameter + and delivers a string or string list value as its result. + + Here are some examples of associative array attribute declarations: + + for Implementation ("main") use "Main.ada"; + for Switches ("main.ada") use ("-v", "-gnatv"); + for Switches ("main.ada") use Builder'Switches ("main.ada") & "-g"; + + Like untyped variables and simple attributes, associative array + attributes may be declared several times. Each declaration supplies a + new value for the attribute, replacing the previous setting. + +  + File: gnat_ug_wnt.info, Node: case Constructions, Prev: Associative Array Attributes, Up: Project File Syntax + + `case' Constructions + -------------------- + + A `case' construction is used in a project file to effect conditional + behavior. Here is a typical example: + + project MyProj is + type OS_Type is ("Linux", "Unix", "NT", "VMS"); + + OS : OS_Type := external ("OS", "Linux"); + + package Compiler is + case OS is + when "Linux" | "Unix" => + for Default_Switches ("Ada") use ("-gnath"); + when "NT" => + for Default_Switches ("Ada") use ("-gnatP"); + when others => + end case; + end Compiler; + end MyProj; + + The syntax of a `case' construction is based on the Ada case statement + (although there is no `null' construction for empty alternatives). + + Following the reserved word `case' there is the case variable (a + typed string variable), the reserved word `is', and then a sequence of + one or more alternatives. Each alternative comprises the reserved word + `when', either a list of literal strings separated by the `"|"' + character or the reserved word `others', and the `"=>"' token. Each + literal string must belong to the string type that is the type of the + case variable. An `others' alternative, if present, must occur last. + The `end case;' sequence terminates the case construction. + + After each `=>', there are zero or more constructions. The only + constructions allowed in a case construction are other case + constructions and attribute declarations. String type declarations, + variable declarations and package declarations are not allowed. + + The value of the case variable is often given by an external + reference (see *Note External References in Project Files::). + +  + File: gnat_ug_wnt.info, Node: Objects and Sources in Project Files, Next: Importing Projects, Prev: Project File Syntax, Up: GNAT Project Manager + + Objects and Sources in Project Files + ==================================== + + * Menu: + + * Object Directory:: + * Exec Directory:: + * Source Directories:: + * Source File Names:: + + Each project has exactly one object directory and one or more source + directories. The source directories must contain at least one source + file, unless the project file explicitly specifies that no source + files are present (see *Note Source File Names::). + +  + File: gnat_ug_wnt.info, Node: Object Directory, Next: Exec Directory, Up: Objects and Sources in Project Files + + Object Directory + ---------------- + + The object directory for a project is the directory containing the + compiler's output (such as `ALI' files and object files) for the + project's immediate sources. Note that for inherited sources (when + extending a parent project) the parent project's object directory is + used. + + The object directory is given by the value of the attribute + `Object_Dir' in the project file. + + for Object_Dir use "objects"; + + The attribute OBJECT_DIR has a string value, the path name of the object + directory. The path name may be absolute or relative to the directory + of the project file. This directory must already exist, and be readable + and writable. + + By default, when the attribute `Object_Dir' is not given an explicit + value or when its value is the empty string, the object directory is + the same as the directory containing the project file. + +  + File: gnat_ug_wnt.info, Node: Exec Directory, Next: Source Directories, Prev: Object Directory, Up: Objects and Sources in Project Files + + Exec Directory + -------------- + + The exec directory for a project is the directory containing the + executables for the project's main subprograms. + + The exec directory is given by the value of the attribute `Exec_Dir' + in the project file. + + for Exec_Dir use "executables"; + + The attribute EXEC_DIR has a string value, the path name of the exec + directory. The path name may be absolute or relative to the directory + of the project file. This directory must already exist, and be writable. + + By default, when the attribute `Exec_Dir' is not given an explicit + value or when its value is the empty string, the exec directory is the + same as the object directory of the project file. + +  + File: gnat_ug_wnt.info, Node: Source Directories, Next: Source File Names, Prev: Exec Directory, Up: Objects and Sources in Project Files + + Source Directories + ------------------ + + The source directories of a project are specified by the project file + attribute `Source_Dirs'. + + This attribute's value is a string list. If the attribute is not + given an explicit value, then there is only one source directory, the + one where the project file resides. + + A `Source_Dirs' attribute that is explicitly defined to be the empty + list, as in + + for Source_Dirs use (); + + indicates that the project contains no source files. + + Otherwise, each string in the string list designates one or more + source directories. + + for Source_Dirs use ("sources", "test/drivers"); + + If a string in the list ends with `"/**"', then the directory whose + path name precedes the two asterisks, as well as all its subdirectories + (recursively), are source directories. + + for Source_Dirs use ("/system/sources/**"); + + Here the directory `/system/sources' and all of its subdirectories + (recursively) are source directories. + + To specify that the source directories are the directory of the + project file and all of its subdirectories, you can declare + `Source_Dirs' as follows: + for Source_Dirs use ("./**"); + + Each of the source directories must exist and be readable. + +  + File: gnat_ug_wnt.info, Node: Source File Names, Prev: Source Directories, Up: Objects and Sources in Project Files + + Source File Names + ----------------- + + In a project that contains source files, their names may be specified + by the attributes `Source_Files' (a string list) or `Source_List_File' + (a string). Source file names never include any directory information. + + If the attribute `Source_Files' is given an explicit value, then each + element of the list is a source file name. + + for Source_Files use ("main.adb"); + for Source_Files use ("main.adb", "pack1.ads", "pack2.adb"); + + If the attribute `Source_Files' is not given an explicit value, but the + attribute `Source_List_File' is given a string value, then the source + file names are contained in the text file whose path name (absolute or + relative to the directory of the project file) is the value of the + attribute `Source_List_File'. + + Each line in the file that is not empty or is not a comment contains + a source file name. A comment line starts with two hyphens. + + for Source_List_File use "source_list.txt"; + + By default, if neither the attribute `Source_Files' nor the attribute + `Source_List_File' is given an explicit value, then each file in the + source directories that conforms to the project's naming scheme (see + *Note Naming Schemes::) is an immediate source of the project. + + A warning is issued if both attributes `Source_Files' and + `Source_List_File' are given explicit values. In this case, the + attribute `Source_Files' prevails. + + Each source file name must be the name of one and only one existing + source file in one of the source directories. + + A `Source_Files' attribute defined with an empty list as its value + indicates that there are no source files in the project. + + Except for projects that are clearly specified as containing no Ada + source files (`Source_Dirs' or `Source_Files' specified as an empty + list, or `Languages' specified without `"Ada"' in the list) + for Source_Dirs use (); + for Source_Files use (); + for Languages use ("C", "C++"); + + a project must contain at least one immediate source. + + Projects with no source files are useful as template packages (see + *Note Packages in Project Files::) for other projects; in particular to + define a package `Naming' (see *Note Naming Schemes::). + +  + File: gnat_ug_wnt.info, Node: Importing Projects, Next: Project Extension, Prev: Objects and Sources in Project Files, Up: GNAT Project Manager + + Importing Projects + ================== + + An immediate source of a project P may depend on source files that are + neither immediate sources of P nor in the predefined library. To get + this effect, P must _import_ the projects that contain the needed + source files. + + with "project1", "utilities.gpr"; + with "/namings/apex.gpr"; + project Main is + ... + + As can be seen in this example, the syntax for importing projects is + similar to the syntax for importing compilation units in Ada. However, + project files use literal strings instead of names, and the `with' + clause identifies project files rather than packages. + + Each literal string is the file name or path name (absolute or + relative) of a project file. If a string is simply a file name, with no + path, then its location is determined by the _project path_: + + * If the environment variable `ADA_PROJECT_PATH' exists, then the + project path includes all the directories in this environment + variable, plus the directory of the project file. + + * If the environment variable `ADA_PROJECT_PATH' does not exist, + then the project path contains only one directory, namely the one + where the project file is located. + + If a relative pathname is used as in + + with "tests/proj"; + + then the path is relative to the directory where the importing project + file is located. Any symbolic link will be fully resolved in the + directory of the importing project file before the imported project + file is looked up. + + When the `with''ed project file name does not have an extension, the + default is `.gpr'. If a file with this extension is not found, then the + file name as specified in the `with' clause (no extension) will be + used. In the above example, if a file `project1.gpr' is found, then it + will be used; otherwise, if a file `project1' exists then it will be + used; if neither file exists, this is an error. + + A warning is issued if the name of the project file does not match + the name of the project; this check is case insensitive. + + Any source file that is an immediate source of the imported project + can be used by the immediate sources of the importing project, and + recursively. Thus if `A' imports `B', and `B' imports `C', the immediate + sources of `A' may depend on the immediate sources of `C', even if `A' + does not import `C' explicitly. However, this is not recommended, + because if and when `B' ceases to import `C', some sources in `A' will + no longer compile. + + A side effect of this capability is that cyclic dependences are not + permitted: if `A' imports `B' (directly or indirectly) then `B' is not + allowed to import `A'. + +  + File: gnat_ug_wnt.info, Node: Project Extension, Next: External References in Project Files, Prev: Importing Projects, Up: GNAT Project Manager + + Project Extension + ================= + + During development of a large system, it is sometimes necessary to use + modified versions of some of the source files without changing the + original sources. This can be achieved through a facility known as + _project extension_. + + project Modified_Utilities extends "/baseline/utilities.gpr" is ... + + The project file for the project being extended (the _parent_) is + identified by the literal string that follows the reserved word + `extends', which itself follows the name of the extending project (the + _child_). + + By default, a child project inherits all the sources of its parent. + However, inherited sources can be overridden: a unit with the same name + as one in the parent will hide the original unit. Inherited sources + are considered to be sources (but not immediate sources) of the child + project; see *Note Project File Syntax::. + + An inherited source file retains any switches specified in the + parent project. + + For example if the project `Utilities' contains the specification + and the body of an Ada package `Util_IO', then the project + `Modified_Utilities' can contain a new body for package `Util_IO'. The + original body of `Util_IO' will not be considered in program builds. + However, the package specification will still be found in the project + `Utilities'. + + A child project can have only one parent but it may import any + number of other projects. + + A project is not allowed to import directly or indirectly at the + same time a child project and any of its ancestors. + +  + File: gnat_ug_wnt.info, Node: External References in Project Files, Next: Packages in Project Files, Prev: Project Extension, Up: GNAT Project Manager + + External References in Project Files + ==================================== + + A project file may contain references to external variables; such + references are called _external references_. + + An external variable is either defined as part of the environment (an + environment variable in Unix, for example) or else specified on the + command line via the `-X_vbl_=_value_' switch. If both, then the + command line value is used. + + An external reference is denoted by the built-in function + `external', which returns a string value. This function has two forms: + * `external (external_variable_name)' + + * `external (external_variable_name, default_value)' + + Each parameter must be a string literal. For example: + + external ("USER") + external ("OS", "Linux") + + In the form with one parameter, the function returns the value of the + external variable given as parameter. If this name is not present in the + environment, then the returned value is an empty string. + + In the form with two string parameters, the second parameter is the + value returned when the variable given as the first parameter is not + present in the environment. In the example above, if `"OS"' is not the + name of an environment variable and is not passed on the command line, + then the returned value will be `"Linux"'. + + An external reference may be part of a string expression or of a + string list expression, to define variables or attributes. + + type Mode_Type is ("Debug", "Release"); + Mode : Mode_Type := external ("MODE"); + case Mode is + when "Debug" => + ... + +  + File: gnat_ug_wnt.info, Node: Packages in Project Files, Next: Variables from Imported Projects, Prev: External References in Project Files, Up: GNAT Project Manager + + Packages in Project Files + ========================= + + The _package_ is the project file feature that defines the settings for + project-aware tools. For each such tool you can declare a + corresponding package; the names for these packages are preset (see + *Note Packages::) but are not case sensitive. A package may contain + variable declarations, attribute declarations, and case constructions. + + project Proj is + package Builder is -- used by gnatmake + for Default_Switches ("Ada") use ("-v", "-g"); + end Builder; + end Proj; + + A package declaration starts with the reserved word `package', followed + by the package name (case insensitive), followed by the reserved word + `is'. It ends with the reserved word `end', followed by the package + name, finally followed by a semi-colon. + + Most of the packages have an attribute `Default_Switches'. This + attribute is an associative array, and its value is a string list. The + index of the associative array is the name of a programming language + (case insensitive). This attribute indicates the switch or switches to + be used with the corresponding tool. + + Some packages also have another attribute, `Switches', an associative + array whose value is a string list. The index is the name of a source + file. This attribute indicates the switch or switches to be used by + the corresponding tool when dealing with this specific file. + + Further information on these switch-related attributes is found in + *Note Switches and Project Files::. + + A package may be declared as a _renaming_ of another package; e.g., + from the project file for an imported project. + + with "/global/apex.gpr"; + project Example is + package Naming renames Apex.Naming; + ... + end Example; + + Packages that are renamed in other project files often come from + project files that have no sources: they are just used as templates. + Any modification in the template will be reflected automatically in all + the project files that rename a package from the template. + + In addition to the tool-oriented packages, you can also declare a + package named `Naming' to establish specialized source file naming + conventions (see *Note Naming Schemes::). + +  + File: gnat_ug_wnt.info, Node: Variables from Imported Projects, Next: Naming Schemes, Prev: Packages in Project Files, Up: GNAT Project Manager + + Variables from Imported Projects + ================================ + + An attribute or variable defined in an imported or parent project can + be used in expressions in the importing / extending project. Such an + attribute or variable is prefixed with the name of the project and (if + relevant) the name of package where it is defined. + + with "imported"; + project Main extends "base" is + Var1 := Imported.Var; + Var2 := Base.Var & ".new"; + + package Builder is + for Default_Switches ("Ada") use Imported.Builder.Ada_Switches & + "-gnatg" & "-v"; + end Builder; + + package Compiler is + for Default_Switches ("Ada") use Base.Compiler.Ada_Switches; + end Compiler; + end Main; + + In this example: + + * `Var1' is a copy of the variable `Var' defined in the project file + `"imported.gpr"' + + * the value of `Var2' is a copy of the value of variable `Var' + defined in the project file `base.gpr', concatenated with `".new"' + + * attribute `Default_Switches ("Ada")' in package `Builder' is a + string list that includes in its value a copy of variable + `Ada_Switches' defined in the `Builder' package in project file + `imported.gpr' plus two new elements: `"-gnatg"' and `"-v"'; + + * attribute `Default_Switches ("Ada")' in package `Compiler' is a + copy of the variable `Ada_Switches' defined in the `Compiler' + package in project file `base.gpr', the project being extended. + +  + File: gnat_ug_wnt.info, Node: Naming Schemes, Next: Library Projects, Prev: Variables from Imported Projects, Up: GNAT Project Manager + + Naming Schemes + ============== + + Sometimes an Ada software system is ported from a foreign compilation + environment to GNAT, with file names that do not use the default GNAT + conventions. Instead of changing all the file names (which for a + variety of reasons might not be possible), you can define the relevant + file naming scheme in the `Naming' package in your project file. For + example, the following package models the Apex file naming rules: + + package Naming is + for Casing use "lowercase"; + for Dot_Replacement use "."; + for Specification_Suffix ("Ada") use ".1.ada"; + for Implementation_Suffix ("Ada") use ".2.ada"; + end Naming; + + You can define the following attributes in package `Naming': + + `CASING' + This must be a string with one of the three values `"lowercase"', + `"uppercase"' or `"mixedcase"'; these strings are case insensitive. + + If CASING is not specified, then the default is `"lowercase"'. + + `DOT_REPLACEMENT' + This must be a string whose value satisfies the following + conditions: + + * It must not be empty + + * It cannot start or end with an alphanumeric character + + * It cannot be a single underscore + + * It cannot start with an underscore followed by an alphanumeric + + * It cannot contain a dot `'.'' except if it the entire string + is `"."' + + If `Dot_Replacement' is not specified, then the default is `"-"'. + + `SPECIFICATION_SUFFIX' + This is an associative array (indexed by the programming language + name, case insensitive) whose value is a string that must satisfy + the following conditions: + + * It must not be empty + + * It cannot start with an alphanumeric character + + * It cannot start with an underscore followed by an + alphanumeric character + + If `Specification_Suffix ("Ada")' is not specified, then the + default is `".ads"'. + + `IMPLEMENTATION_SUFFIX' + This is an associative array (indexed by the programming language + name, case insensitive) whose value is a string that must satisfy + the following conditions: + + * It must not be empty + + * It cannot start with an alphanumeric character + + * It cannot start with an underscore followed by an + alphanumeric character + + * It cannot be a suffix of `Specification_Suffix' + + If `Implementation_Suffix ("Ada")' is not specified, then the + default is `".adb"'. + + `SEPARATE_SUFFIX' + This must be a string whose value satisfies the same conditions as + `Implementation_Suffix'. + + If `Separate_Suffix ("Ada")' is not specified, then it defaults to + same value as `Implementation_Suffix ("Ada")'. + + `SPECIFICATION' + You can use the `Specification' attribute, an associative array, + to define the source file name for an individual Ada compilation + unit's spec. The array index must be a string literal that + identifies the Ada unit (case insensitive). The value of this + attribute must be a string that identifies the file that contains + this unit's spec (case sensitive or insensitive depending on the + operating system). + + for Specification ("MyPack.MyChild") use "mypack.mychild.spec"; + + `IMPLEMENTATION' + You can use the `Implementation' attribute, an associative array, + to define the source file name for an individual Ada compilation + unit's body (possibly a subunit). The array index must be a + string literal that identifies the Ada unit (case insensitive). + The value of this attribute must be a string that identifies the + file that contains this unit's body or subunit (case sensitive or + insensitive depending on the operating system). + + for Implementation ("MyPack.MyChild") use "mypack.mychild.body"; + +  + File: gnat_ug_wnt.info, Node: Library Projects, Next: Switches Related to Project Files, Prev: Naming Schemes, Up: GNAT Project Manager + + Library Projects + ================ + + _Library projects_ are projects whose object code is placed in a + library. (Note that this facility is not yet supported on all + platforms) + + To create a library project, you need to define in its project file + two project-level attributes: `Library_Name' and `Library_Dir'. + Additionally, you may define the library-related attributes + `Library_Kind', `Library_Version' and `Library_Elaboration'. + + The `Library_Name' attribute has a string value that must start with + a letter and include only letters and digits. + + The `Library_Dir' attribute has a string value that designates the + path (absolute or relative) of the directory where the library will + reside. It must designate an existing directory, and this directory + needs to be different from the project's object directory. It also + needs to be writable. + + If both `Library_Name' and `Library_Dir' are specified and are + legal, then the project file defines a library project. The optional + library-related attributes are checked only for such project files. + + The `Library_Kind' attribute has a string value that must be one of + the following (case insensitive): `"static"', `"dynamic"' or + `"relocatable"'. If this attribute is not specified, the library is a + static library. Otherwise, the library may be dynamic or relocatable. + Depending on the operating system, there may or may not be a distinction + between dynamic and relocatable libraries. For example, on Unix there + is no such distinction. + + The `Library_Version' attribute has a string value whose + interpretation is platform dependent. On Unix, it is used only for + dynamic/relocatable libraries as the internal name of the library (the + `"soname"'). If the library file name (built from the `Library_Name') + is different from the `Library_Version', then the library file will be + a symbolic link to the actual file whose name will be `Library_Version'. + + Example (on Unix): + + project Plib is + + Version := "1"; + + for Library_Dir use "lib_dir"; + for Library_Name use "dummy"; + for Library_Kind use "relocatable"; + for Library_Version use "libdummy.so." & Version; + + end Plib; + + Directory `lib_dir' will contain the internal library file whose name + will be `libdummy.so.1', and `libdummy.so' will be a symbolic link to + `libdummy.so.1'. + + When `gnatmake' detects that a project file (not the main project + file) is a library project file, it will check all immediate sources of + the project and rebuild the library if any of the sources have been + recompiled. All `ALI' files will also be copied from the object + directory to the library directory. To build executables, `gnatmake' + will use the library rather than the individual object files. + +  + File: gnat_ug_wnt.info, Node: Switches Related to Project Files, Next: Tools Supporting Project Files, Prev: Library Projects, Up: GNAT Project Manager + + Switches Related to Project Files + ================================= + + The following switches are used by GNAT tools that support project + files: + + ``-PPROJECT'' + Indicates the name of a project file. This project file will be + parsed with the verbosity indicated by `-vP_x_', if any, and using + the external references indicated by `-X' switches, if any. + + There must be only one `-P' switch on the command line. + + Since the Project Manager parses the project file only after all + the switches on the command line are checked, the order of the + switches `-P', `-Vp_x_' or `-X' is not significant. + + ``-XNAME=VALUE'' + Indicates that external variable NAME has the value VALUE. The + Project Manager will use this value for occurrences of + `external(name)' when parsing the project file. + + If NAME or VALUE includes a space, then NAME=VALUE should be put + between quotes. + -XOS=NT + -X"user=John Doe" + + Several `-X' switches can be used simultaneously. If several `-X' + switches specify the same NAME, only the last one is used. + + An external variable specified with a `-X' switch takes precedence + over the value of the same name in the environment. + + ``-vP_x_'' + Indicates the verbosity of the parsing of GNAT project files. + `-vP0' means Default (no output for syntactically correct project + files); `-vP1' means Medium; `-vP2' means High. + + The default is Default. + + If several `-vP_x_' switches are present, only the last one is + used. + +  + File: gnat_ug_wnt.info, Node: Tools Supporting Project Files, Next: An Extended Example, Prev: Switches Related to Project Files, Up: GNAT Project Manager + + Tools Supporting Project Files + ============================== + + * Menu: + + * gnatmake and Project Files:: + * The GNAT Driver and Project Files:: + * Glide and Project Files:: + +  + File: gnat_ug_wnt.info, Node: gnatmake and Project Files, Next: The GNAT Driver and Project Files, Up: Tools Supporting Project Files + + gnatmake and Project Files + -------------------------- + + This section covers two topics related to `gnatmake' and project files: + defining switches for `gnatmake' and for the tools that it invokes; and + the use of the `Main' attribute. + + * Menu: + + * Switches and Project Files:: + * Project Files and Main Subprograms:: + +  + File: gnat_ug_wnt.info, Node: Switches and Project Files, Next: Project Files and Main Subprograms, Up: gnatmake and Project Files + + Switches and Project Files + .......................... + + For each of the packages `Builder', `Compiler', `Binder', and `Linker', + you can specify a `Default_Switches' attribute, a `Switches' attribute, + or both; as their names imply, these switch-related attributes affect + which switches are used for which files when `gnatmake' is invoked. As + will be explained below, these package-contributed switches precede the + switches passed on the `gnatmake' command line. + + The `Default_Switches' attribute is an associative array indexed by + language name (case insensitive) and returning a string list. For + example: + + package Compiler is + for Default_Switches ("Ada") use ("-gnaty", "-v"); + end Compiler; + + The `Switches' attribute is also an associative array, indexed by a file + name (which may or may not be case sensitive, depending on the operating + system) and returning a string list. For example: + + package Builder is + for Switches ("main1.adb") use ("-O2"); + for Switches ("main2.adb") use ("-g"); + end Builder; + + For the `Builder' package, the file names should designate source files + for main subprograms. For the `Binder' and `Linker' packages, the file + names should designate `ALI' or source files for main subprograms. In + each case just the file name (without explicit extension) is acceptable. + + For each tool used in a program build (`gnatmake', the compiler, the + binder, and the linker), its corresponding package "contributes" a set + of switches for each file on which the tool is invoked, based on the + switch-related attributes defined in the package. In particular, the + switches that each of these packages contributes for a given file F + comprise: + + * the value of attribute `Switches (F)', if it is specified in the + package for the given file, + + * otherwise, the value of `Default_Switches ("Ada")', if it is + specified in the package. + + If neither of these attributes is defined in the package, then the + package does not contribute any switches for the given file. + + When `gnatmake' is invoked on a file, the switches comprise two sets, + in the following order: those contributed for the file by the `Builder' + package; and the switches passed on the command line. + + When `gnatmake' invokes a tool (compiler, binder, linker) on a file, + the switches passed to the tool comprise three sets, in the following + order: + + 1. the applicable switches contributed for the file by the `Builder' + package in the project file supplied on the command line; + + 2. those contributed for the file by the package (in the relevant + project file - see below) corresponding to the tool; and + + 3. the applicable switches passed on the command line. + + The term _applicable switches_ reflects the fact that `gnatmake' + switches may or may not be passed to individual tools, depending on the + individual switch. + + `gnatmake' may invoke the compiler on source files from different + projects. The Project Manager will use the appropriate project file to + determine the `Compiler' package for each source file being compiled. + Likewise for the `Binder' and `Linker' packages. + + As an example, consider the following package in a project file: + + project Proj1 is + package Compiler is + for Default_Switches ("Ada") use ("-g"); + for Switches ("a.adb") use ("-O1"); + for Switches ("b.adb") use ("-O2", "-gnaty"); + end Compiler; + end Proj1; + + If `gnatmake' is invoked with this project file, and it needs to + compile, say, the files `a.adb', `b.adb', and `c.adb', then `a.adb' + will be compiled with the switch `-O1', `b.adb' with switches `-O2' and + `-gnaty', and `c.adb' with `-g'. + + Another example illustrates the ordering of the switches contributed + by different packages: + + project Proj2 is + package Builder is + for Switches ("main.adb") use ("-g", "-O1", "-f"); + end Builder; + + package Compiler is + for Switches ("main.adb") use ("-O2"); + end Compiler; + end Proj2; + + If you issue the command: + + gnatmake -PProj2 -O0 main + + then the compiler will be invoked on `main.adb' with the following + sequence of switches + + -g -O1 -O2 -O0 + + with the last `-O' switch having precedence over the earlier ones; + several other switches (such as `-c') are added implicitly. + + The switches `-g' and `-O1' are contributed by package `Builder', + `-O2' is contributed by the package `Compiler' and `-O0' comes from the + command line. + + The `-g' switch will also be passed in the invocation of `gnatlink.' + + A final example illustrates switch contributions from packages in + different project files: + + project Proj3 is + for Source_Files use ("pack.ads", "pack.adb"); + package Compiler is + for Default_Switches ("Ada") use ("-gnata"); + end Compiler; + end Proj3; + + with "Proj3"; + project Proj4 is + for Source_Files use ("foo_main.adb", "bar_main.adb"); + package Builder is + for Switches ("foo_main.adb") use ("-s", "-g"); + end Builder; + end Proj4; + + -- Ada source file: + with Pack; + procedure Foo_Main is + ... + end Foo_Main; + + If the command is + gnatmake -PProj4 foo_main.adb -cargs -gnato + + then the switches passed to the compiler for `foo_main.adb' are `-g' + (contributed by the package `Proj4.Builder') and `-gnato' (passed on + the command line). When the imported package `Pack' is compiled, the + switches used are `-g' from `Proj4.Builder', `-gnata' (contributed from + package `Proj3.Compiler', and `-gnato' from the command line. + +  + File: gnat_ug_wnt.info, Node: Project Files and Main Subprograms, Prev: Switches and Project Files, Up: gnatmake and Project Files + + Project Files and Main Subprograms + .................................. + + When using a project file, you can invoke `gnatmake' with several main + subprograms, by specifying their source files on the command line. + Each of these needs to be an immediate source file of the project. + + gnatmake -Pprj main1 main2 main3 + + When using a project file, you can also invoke `gnatmake' without + explicitly specifying any main, and the effect depends on whether you + have defined the `Main' attribute. This attribute has a string list + value, where each element in the list is the name of a source file (the + file extension is optional) containing a main subprogram. + + If the `Main' attribute is defined in a project file as a non-empty + string list and the switch `-u' is not used on the command line, then + invoking `gnatmake' with this project file but without any main on the + command line is equivalent to invoking `gnatmake' with all the file + names in the `Main' attribute on the command line. + + Example: + project Prj is + for Main use ("main1", "main2", "main3"); + end Prj; + + With this project file, `"gnatmake -Pprj"' is equivalent to `"gnatmake + -Pprj main1 main2 main3"'. + + When the project attribute `Main' is not specified, or is specified + as an empty string list, or when the switch `-u' is used on the command + line, then invoking `gnatmake' with no main on the command line will + result in all immediate sources of the project file being checked, and + potentially recompiled. Depending on the presence of the switch `-u', + sources from other project files on which the immediate sources of the + main project file depend are also checked and potentially recompiled. + In other words, the `-u' switch is applied to all of the immediate + sources of themain project file. + +  + File: gnat_ug_wnt.info, Node: The GNAT Driver and Project Files, Next: Glide and Project Files, Prev: gnatmake and Project Files, Up: Tools Supporting Project Files + + The GNAT Driver and Project Files + --------------------------------- + + A number of GNAT tools, other than `gnatmake' are project-aware: + `gnatbind', `gnatfind', `gnatlink', `gnatls' and `gnatxref'. However, + none of these tools can be invoked directly with a project file switch + (`-P'). They need to be invoke through the `gnat' driver. + + The `gnat' driver is a front-end that accepts a number of commands + and call the corresponding tool. It has been designed initially for VMS + to convert VMS style qualifiers to Unix style switches, but it is now + available to all the GNAT supported platforms. + + On non VMS platforms, the `gnat' driver accepts the following + commands (case insensitive): + + * BIND to invoke `gnatbind' + + * CHOP to invoke `gnatchop' + + * COMP or COMPILE to invoke the compiler + + * ELIM to invoke `gnatelim' + + * FIND to invoke `gnatfind' + + * KR or KRUNCH to invoke `gnatkr' + + * LINK to invoke `gnatlink' + + * LS or LIST to invoke `gnatls' + + * MAKE to invoke `gnatmake' + + * NAME to invoke `gnatname' + + * PREP or PREPROCESS to invoke `gnatprep' + + * PSTA or STANDARD to invoke `gnatpsta' + + * STUB to invoke `gnatstub' + + * XREF to invoke `gnatxref' + + Note that the compiler is invoked using the command `gnatmake -f -u'. + + Following the command, you may put switches and arguments for the + invoked tool. + + gnat bind -C main.ali + gnat ls -a main + gnat chop foo.txt + + In addition, for command BIND, FIND, LS or LIST, LINK and XREF, the + project file related switches (`-P', `-X' and `-vPx') may be used in + addition to the switches of the invoking tool. + + For each of these command, there is possibly a package in the main + project that corresponds to the invoked tool. + + * package `Binder' for command BIND (invoking `gnatbind') + + * package `Finder' for command FIND (invoking `gnatfind') + + * package `Gnatls' for command LS or LIST (invoking `gnatls') + + * package `Linker' for command LINK (invoking `gnatlink') + + * package `Cross_Reference' for command XREF (invoking `gnatlink') + + + Package `Gnatls' has a unique attribute `Switches', a simple variable + with a string list value. It contains switches for the invocation of + `gnatls'. + + project Proj1 is + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + end Proj1; + + All other packages contains a switch `Default_Switches', an associative + array, indexed by the programming language (case insensitive) and + having a string list value. `Default_Switches ("Ada")' contains the + switches for the invocation of the tool corresponding to the package. + + project Proj is + + for Source_Dirs use ("./**"); + + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + + package Binder is + for Default_Switches ("Ada") use ("-C", "-e"); + end Binder; + + package Linker is + for Default_Switches ("Ada") use ("-C"); + end Linker; + + package Finder is + for Default_Switches ("Ada") use ("-a", "-f"); + end Finder; + + package Cross_Reference is + for Default_Switches ("Ada") use ("-a", "-f", "-d", "-u"); + end Cross_Reference; + end Proj; + + With the above project file, commands such as + + gnat ls -Pproj main + gnat xref -Pproj main + gnat bind -Pproj main.ali + + will set up the environment properly and invoke the tool with the + switches found in the package corresponding to the tool. + +  + File: gnat_ug_wnt.info, Node: Glide and Project Files, Prev: The GNAT Driver and Project Files, Up: Tools Supporting Project Files + + Glide and Project Files + ----------------------- + + Glide will automatically recognize the `.gpr' extension for project + files, and will convert them to its own internal format automatically. + However, it doesn't provide a syntax-oriented editor for modifying these + files. The project file will be loaded as text when you select the + menu item `Ada' => `Project' => `Edit'. You can edit this text and + save the `gpr' file; when you next select this project file in Glide it + will be automatically reloaded. + +  + File: gnat_ug_wnt.info, Node: An Extended Example, Next: Project File Complete Syntax, Prev: Tools Supporting Project Files, Up: GNAT Project Manager + + An Extended Example + =================== + + Suppose that we have two programs, PROG1 and PROG2, with the sources in + the respective directories. We would like to build them with a single + `gnatmake' command, and we would like to place their object files into + `.build' subdirectories of the source directories. Furthermore, we would + like to have to have two separate subdirectories in `.build' - + `release' and `debug' - which will contain the object files compiled + with different set of compilation flags. + + In other words, we have the following structure: + + main + |- prog1 + | |- .build + | | debug + | | release + |- prog2 + |- .build + | debug + | release + + Here are the project files that we need to create in a directory `main' + to maintain this structure: + + 1. We create a `Common' project with a package `Compiler' that + specifies the compilation switches: + + File "common.gpr": + project Common is + + for Source_Dirs use (); -- No source files + + type Build_Type is ("release", "debug"); + Build : Build_Type := External ("BUILD", "debug"); + package Compiler is + case Build is + when "release" => + for Default_Switches ("Ada") use ("-O2"); + when "debug" => + for Default_Switches ("Ada") use ("-g"); + end case; + end Compiler; + + end Common; + + 2. We create separate projects for the two programs: + + File "prog1.gpr": + + with "common"; + project Prog1 is + + for Source_Dirs use ("prog1"); + for Object_Dir use "prog1/.build/" & Common.Build; + + package Compiler renames Common.Compiler; + + end Prog1; + + File "prog2.gpr": + + with "common"; + project Prog2 is + + for Source_Dirs use ("prog2"); + for Object_Dir use "prog2/.build/" & Common.Build; + + package Compiler renames Common.Compiler; + end Prog2; + + 3. We create a wrapping project MAIN: + + File "main.gpr": + + with "common"; + with "prog1"; + with "prog2"; + project Main is + + package Compiler renames Common.Compiler; + + end Main; + + 4. Finally we need to create a dummy procedure that `with's (either + explicitly or implicitly) all the sources of our two programs. + + + Now we can build the programs using the command + + gnatmake -Pmain dummy + + for the Debug mode, or + + gnatmake -Pmain -XBUILD=release + + for the Release mode. + +  + File: gnat_ug_wnt.info, Node: Project File Complete Syntax, Prev: An Extended Example, Up: GNAT Project Manager + + Project File Complete Syntax + ============================ + + project ::= + context_clause project_declaration + + context_clause ::= + {with_clause} + + with_clause ::= + with literal_string { , literal_string } ; + + project_declaration ::= + project simple_name [ extends literal_string ] is + {declarative_item} + end simple_name; + + declarative_item ::= + package_declaration | + typed_string_declaration | + other_declarative_item + + package_declaration ::= + package simple_name package_completion + + package_completion ::= + package_body | package_renaming + + package body ::= + is + {other_declarative_item} + end simple_name ; + + package_renaming ::== + renames simple_name.simple_name ; + + typed_string_declaration ::= + type _simple_name is + ( literal_string {, literal_string} ); + + other_declarative_item ::= + attribute_declaration | + typed_variable_declaration | + variable_declaration | + case_construction + + attribute_declaration ::= + for attribute use expression ; + + attribute ::= + simple_name | + simple_name ( literal_string ) + + typed_variable_declaration ::= + simple_name : name := string_expression ; + + variable_declaration ::= + simple_name := expression; + + expression ::= + term {& term} + + term ::= + literal_string | + string_list | + name | + external_value | + attribute_reference + + literal_string ::= + (same as Ada) + + string_list ::= + ( expression { , expression } ) + + external_value ::= + external ( literal_string [, literal_string] ) + + attribute_reference ::= + attribute_parent ' simple_name [ ( literal_string ) ] + + attribute_parent ::= + project | + simple_name | + simple_name . simple_name + + case_construction ::= + case name is + {case_item} + end case ; + + case_item ::= + when discrete_choice_list => {case_construction | attribute_declaration} + + discrete_choice_list ::= + literal_string {| literal_string} + + name ::= + simple_name {. simple_name} + + simple_name ::= + identifier (same as Ada) + +  + File: gnat_ug_wnt.info, Node: Elaboration Order Handling in GNAT, Next: The Cross-Referencing Tools gnatxref and gnatfind, Prev: GNAT Project Manager, Up: Top + + Elaboration Order Handling in GNAT + ********************************** + + * Menu: + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + This chapter describes the handling of elaboration code in Ada 95 and + in GNAT, and discusses how the order of elaboration of program units can + be controlled in GNAT, either automatically or with explicit programming + features. + +  + File: gnat_ug_wnt.info, Node: Elaboration Code in Ada 95, Next: Checking the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Elaboration Code in Ada 95 + ========================== + + Ada 95 provides rather general mechanisms for executing code at + elaboration time, that is to say before the main program starts + executing. Such code arises in three contexts: + + Initializers for variables. + Variables declared at the library level, in package specs or + bodies, can require initialization that is performed at + elaboration time, as in: + Sqrt_Half : Float := Sqrt (0.5); + + Package initialization code + Code in a `BEGIN-END' section at the outer level of a package body + is executed as part of the package body elaboration code. + + Library level task allocators + Tasks that are declared using task allocators at the library level + start executing immediately and hence can execute at elaboration + time. + + Subprogram calls are possible in any of these contexts, which means that + any arbitrary part of the program may be executed as part of the + elaboration code. It is even possible to write a program which does all + its work at elaboration time, with a null main program, although + stylistically this would usually be considered an inappropriate way to + structure a program. + + An important concern arises in the context of elaboration code: we + have to be sure that it is executed in an appropriate order. What we + have is a series of elaboration code sections, potentially one section + for each unit in the program. It is important that these execute in the + correct order. Correctness here means that, taking the above example of + the declaration of `Sqrt_Half', if some other piece of elaboration code + references `Sqrt_Half', then it must run after the section of + elaboration code that contains the declaration of `Sqrt_Half'. + + There would never be any order of elaboration problem if we made a + rule that whenever you `with' a unit, you must elaborate both the spec + and body of that unit before elaborating the unit doing the `with''ing: + + with Unit_1; + package Unit_2 is ... + + would require that both the body and spec of `Unit_1' be elaborated + before the spec of `Unit_2'. However, a rule like that would be far too + restrictive. In particular, it would make it impossible to have routines + in separate packages that were mutually recursive. + + You might think that a clever enough compiler could look at the + actual elaboration code and determine an appropriate correct order of + elaboration, but in the general case, this is not possible. Consider + the following example. + + In the body of `Unit_1', we have a procedure `Func_1' that references + the variable `Sqrt_1', which is declared in the elaboration code of the + body of `Unit_1': + + Sqrt_1 : Float := Sqrt (0.1); + + The elaboration code of the body of `Unit_1' also contains: + + if expression_1 = 1 then + Q := Unit_2.Func_2; + end if; + + `Unit_2' is exactly parallel, it has a procedure `Func_2' that + references the variable `Sqrt_2', which is declared in the elaboration + code of the body `Unit_2': + + Sqrt_2 : Float := Sqrt (0.1); + + The elaboration code of the body of `Unit_2' also contains: + + if expression_2 = 2 then + Q := Unit_1.Func_1; + end if; + + Now the question is, which of the following orders of elaboration is + acceptable: + + Spec of Unit_1 + Spec of Unit_2 + Body of Unit_1 + Body of Unit_2 + + or + + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_2 + Body of Unit_1 + + If you carefully analyze the flow here, you will see that you cannot + tell at compile time the answer to this question. If `expression_1' is + not equal to 1, and `expression_2' is not equal to 2, then either order + is acceptable, because neither of the function calls is executed. If + both tests evaluate to true, then neither order is acceptable and in + fact there is no correct order. + + If one of the two expressions is true, and the other is false, then + one of the above orders is correct, and the other is incorrect. For + example, if `expression_1' = 1 and `expression_2' /= 2, then the call + to `Func_2' will occur, but not the call to `Func_1.' This means that + it is essential to elaborate the body of `Unit_1' before the body of + `Unit_2', so the first order of elaboration is correct and the second + is wrong. + + By making `expression_1' and `expression_2' depend on input data, or + perhaps the time of day, we can make it impossible for the compiler or + binder to figure out which of these expressions will be true, and hence + it is impossible to guarantee a safe order of elaboration at run time. + +  + File: gnat_ug_wnt.info, Node: Checking the Elaboration Order in Ada 95, Next: Controlling the Elaboration Order in Ada 95, Prev: Elaboration Code in Ada 95, Up: Elaboration Order Handling in GNAT + + Checking the Elaboration Order in Ada 95 + ======================================== + + In some languages that involve the same kind of elaboration problems, + e.g. Java and C++, the programmer is expected to worry about these + ordering problems himself, and it is common to write a program in which + an incorrect elaboration order gives surprising results, because it + references variables before they are initialized. Ada 95 is designed + to be a safe language, and a programmer-beware approach is clearly not + sufficient. Consequently, the language provides three lines of defense: + + Standard rules + Some standard rules restrict the possible choice of elaboration + order. In particular, if you `with' a unit, then its spec is always + elaborated before the unit doing the `with'. Similarly, a parent + spec is always elaborated before the child spec, and finally a + spec is always elaborated before its corresponding body. + + Dynamic elaboration checks + Dynamic checks are made at run time, so that if some entity is + accessed before it is elaborated (typically by means of a + subprogram call) then the exception (`Program_Error') is raised. + + Elaboration control + Facilities are provided for the programmer to specify the desired + order of elaboration. + + Let's look at these facilities in more detail. First, the rules for + dynamic checking. One possible rule would be simply to say that the + exception is raised if you access a variable which has not yet been + elaborated. The trouble with this approach is that it could require + expensive checks on every variable reference. Instead Ada 95 has two + rules which are a little more restrictive, but easier to check, and + easier to state: + + Restrictions on calls + A subprogram can only be called at elaboration time if its body + has been elaborated. The rules for elaboration given above + guarantee that the spec of the subprogram has been elaborated + before the call, but not the body. If this rule is violated, then + the exception `Program_Error' is raised. + + Restrictions on instantiations + A generic unit can only be instantiated if the body of the generic + unit has been elaborated. Again, the rules for elaboration given + above guarantee that the spec of the generic unit has been + elaborated before the instantiation, but not the body. If this + rule is violated, then the exception `Program_Error' is raised. + + The idea is that if the body has been elaborated, then any variables it + references must have been elaborated; by checking for the body being + elaborated we guarantee that none of its references causes any trouble. + As we noted above, this is a little too restrictive, because a + subprogram that has no non-local references in its body may in fact be + safe to call. However, it really would be unsafe to rely on this, + because it would mean that the caller was aware of details of the + implementation in the body. This goes against the basic tenets of Ada. + + A plausible implementation can be described as follows. A Boolean + variable is associated with each subprogram and each generic unit. This + variable is initialized to False, and is set to True at the point body + is elaborated. Every call or instantiation checks the variable, and + raises `Program_Error' if the variable is False. + + Note that one might think that it would be good enough to have one + Boolean variable for each package, but that would not deal with cases + of trying to call a body in the same package as the call that has not + been elaborated yet. Of course a compiler may be able to do enough + analysis to optimize away some of the Boolean variables as unnecessary, + and `GNAT' indeed does such optimizations, but still the easiest + conceptual model is to think of there being one variable per subprogram. + +  + File: gnat_ug_wnt.info, Node: Controlling the Elaboration Order in Ada 95, Next: Controlling Elaboration in GNAT - Internal Calls, Prev: Checking the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Controlling the Elaboration Order in Ada 95 + =========================================== + + In the previous section we discussed the rules in Ada 95 which ensure + that `Program_Error' is raised if an incorrect elaboration order is + chosen. This prevents erroneous executions, but we need mechanisms to + specify a correct execution and avoid the exception altogether. To + achieve this, Ada 95 provides a number of features for controlling the + order of elaboration. We discuss these features in this section. + + First, there are several ways of indicating to the compiler that a + given unit has no elaboration problems: + + packages that do not require a body + In Ada 95, a library package that does not require a body does not + permit a body. This means that if we have a such a package, as in: + + package Definitions is + generic + type m is new integer; + package Subp is + type a is array (1 .. 10) of m; + type b is array (1 .. 20) of m; + end Subp; + end Definitions; + + A package that `with''s `Definitions' may safely instantiate + `Definitions.Subp' because the compiler can determine that there + definitely is no package body to worry about in this case + + pragma Pure + Places sufficient restrictions on a unit to guarantee that no call + to any subprogram in the unit can result in an elaboration + problem. This means that the compiler does not need to worry about + the point of elaboration of such units, and in particular, does + not need to check any calls to any subprograms in this unit. + + pragma Preelaborate + This pragma places slightly less stringent restrictions on a unit + than does pragma Pure, but these restrictions are still sufficient + to ensure that there are no elaboration problems with any calls to + the unit. + + pragma Elaborate_Body + This pragma requires that the body of a unit be elaborated + immediately after its spec. Suppose a unit `A' has such a pragma, + and unit `B' does a `with' of unit `A'. Recall that the standard + rules require the spec of unit `A' to be elaborated before the + `with''ing unit; given the pragma in `A', we also know that the + body of `A' will be elaborated before `B', so that calls to `A' + are safe and do not need a check. + + Note that, unlike pragma `Pure' and pragma `Preelaborate', the use of + `Elaborate_Body' does not guarantee that the program is free of + elaboration problems, because it may not be possible to satisfy the + requested elaboration order. Let's go back to the example with + `Unit_1' and `Unit_2'. If a programmer marks `Unit_1' as + `Elaborate_Body', and not `Unit_2,' then the order of elaboration will + be: + + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_1 + Body of Unit_2 + + Now that means that the call to `Func_1' in `Unit_2' need not be + checked, it must be safe. But the call to `Func_2' in `Unit_1' may + still fail if `Expression_1' is equal to 1, and the programmer must + still take responsibility for this not being the case. + + If all units carry a pragma `Elaborate_Body', then all problems are + eliminated, except for calls entirely within a body, which are in any + case fully under programmer control. However, using the pragma + everywhere is not always possible. In particular, for our + `Unit_1'/`Unit_2' example, if we marked both of them as having pragma + `Elaborate_Body', then clearly there would be no possible elaboration + order. + + The above pragmas allow a server to guarantee safe use by clients, + and clearly this is the preferable approach. Consequently a good rule in + Ada 95 is to mark units as `Pure' or `Preelaborate' if possible, and if + this is not possible, mark them as `Elaborate_Body' if possible. As we + have seen, there are situations where neither of these three pragmas + can be used. So we also provide methods for clients to control the + order of elaboration of the servers on which they depend: + + pragma Elaborate (unit) + This pragma is placed in the context clause, after a `with' clause, + and it requires that the body of the named unit be elaborated + before the unit in which the pragma occurs. The idea is to use + this pragma if the current unit calls at elaboration time, + directly or indirectly, some subprogram in the named unit. + + pragma Elaborate_All (unit) + This is a stronger version of the Elaborate pragma. Consider the + following example: + + Unit A `with''s unit B and calls B.Func in elab code + Unit B `with''s unit C, and B.Func calls C.Func + + Now if we put a pragma `Elaborate (B)' in unit `A', this ensures + that the body of `B' is elaborated before the call, but not the + body of `C', so the call to `C.Func' could still cause + `Program_Error' to be raised. + + The effect of a pragma `Elaborate_All' is stronger, it requires + not only that the body of the named unit be elaborated before the + unit doing the `with', but also the bodies of all units that the + named unit uses, following `with' links transitively. For example, + if we put a pragma `Elaborate_All (B)' in unit `A', then it + requires not only that the body of `B' be elaborated before `A', + but also the body of `C', because `B' `with''s `C'. + + We are now in a position to give a usage rule in Ada 95 for avoiding + elaboration problems, at least if dynamic dispatching and access to + subprogram values are not used. We will handle these cases separately + later. + + The rule is simple. If a unit has elaboration code that can directly + or indirectly make a call to a subprogram in a `with''ed unit, or + instantiate a generic unit in a `with''ed unit, then if the `with''ed + unit does not have pragma `Pure' or `Preelaborate', then the client + should have a pragma `Elaborate_All' for the `with''ed unit. By + following this rule a client is assured that calls can be made without + risk of an exception. If this rule is not followed, then a program may + be in one of four states: + + No order exists + No order of elaboration exists which follows the rules, taking into + account any `Elaborate', `Elaborate_All', or `Elaborate_Body' + pragmas. In this case, an Ada 95 compiler must diagnose the + situation at bind time, and refuse to build an executable program. + + One or more orders exist, all incorrect + One or more acceptable elaboration orders exists, and all of them + generate an elaboration order problem. In this case, the binder + can build an executable program, but `Program_Error' will be raised + when the program is run. + + Several orders exist, some right, some incorrect + One or more acceptable elaboration orders exists, and some of them + work, and some do not. The programmer has not controlled the order + of elaboration, so the binder may or may not pick one of the + correct orders, and the program may or may not raise an exception + when it is run. This is the worst case, because it means that the + program may fail when moved to another compiler, or even another + version of the same compiler. + + One or more orders exists, all correct + One ore more acceptable elaboration orders exist, and all of them + work. In this case the program runs successfully. This state of + affairs can be guaranteed by following the rule we gave above, but + may be true even if the rule is not followed. + + Note that one additional advantage of following our Elaborate_All rule + is that the program continues to stay in the ideal (all orders OK) state + even if maintenance changes some bodies of some subprograms. + Conversely, if a program that does not follow this rule happens to be + safe at some point, this state of affairs may deteriorate silently as a + result of maintenance changes. + + You may have noticed that the above discussion did not mention the + use of `Elaborate_Body'. This was a deliberate omission. If you `with' + an `Elaborate_Body' unit, it still may be the case that code in the + body makes calls to some other unit, so it is still necessary to use + `Elaborate_All' on such units. + +  + File: gnat_ug_wnt.info, Node: Controlling Elaboration in GNAT - Internal Calls, Next: Controlling Elaboration in GNAT - External Calls, Prev: Controlling the Elaboration Order in Ada 95, Up: Elaboration Order Handling in GNAT + + Controlling Elaboration in GNAT - Internal Calls + ================================================ + + In the case of internal calls, i.e. calls within a single package, the + programmer has full control over the order of elaboration, and it is up + to the programmer to elaborate declarations in an appropriate order. For + example writing: + + function One return Float; + + Q : Float := One; + + function One return Float is + begin + return 1.0; + end One; + + will obviously raise `Program_Error' at run time, because function One + will be called before its body is elaborated. In this case GNAT will + generate a warning that the call will raise `Program_Error': + + 1. procedure y is + 2. function One return Float; + 3. + 4. Q : Float := One; + | + >>> warning: cannot call "One" before body is elaborated + >>> warning: Program_Error will be raised at run time + + 5. + 6. function One return Float is + 7. begin + 8. return 1.0; + 9. end One; + 10. + 11. begin + 12. null; + 13. end; + + Note that in this particular case, it is likely that the call is safe, + because the function `One' does not access any global variables. + Nevertheless in Ada 95, we do not want the validity of the check to + depend on the contents of the body (think about the separate + compilation case), so this is still wrong, as we discussed in the + previous sections. + + The error is easily corrected by rearranging the declarations so + that the body of One appears before the declaration containing the call + (note that in Ada 95, declarations can appear in any order, so there is + no restriction that would prevent this reordering, and if we write: + + function One return Float; + + function One return Float is + begin + return 1.0; + end One; + + Q : Float := One; + + then all is well, no warning is generated, and no `Program_Error' + exception will be raised. Things are more complicated when a chain of + subprograms is executed: + + function A return Integer; + function B return Integer; + function C return Integer; + + function B return Integer is begin return A; end; + function C return Integer is begin return B; end; + + X : Integer := C; + + function A return Integer is begin return 1; end; + + Now the call to `C' at elaboration time in the declaration of `X' is + correct, because the body of `C' is already elaborated, and the call to + `B' within the body of `C' is correct, but the call to `A' within the + body of `B' is incorrect, because the body of `A' has not been + elaborated, so `Program_Error' will be raised on the call to `A'. In + this case GNAT will generate a warning that `Program_Error' may be + raised at the point of the call. Let's look at the warning: + + 1. procedure x is + 2. function A return Integer; + 3. function B return Integer; + 4. function C return Integer; + 5. + 6. function B return Integer is begin return A; end; + | + >>> warning: call to "A" before body is elaborated may + raise Program_Error + >>> warning: "B" called at line 7 + >>> warning: "C" called at line 9 + + 7. function C return Integer is begin return B; end; + 8. + 9. X : Integer := C; + 10. + 11. function A return Integer is begin return 1; end; + 12. + 13. begin + 14. null; + 15. end; + + Note that the message here says "may raise", instead of the direct case, + where the message says "will be raised". That's because whether `A' is + actually called depends in general on run-time flow of control. For + example, if the body of `B' said + + function B return Integer is + begin + if some-condition-depending-on-input-data then + return A; + else + return 1; + end if; + end B; + + then we could not know until run time whether the incorrect call to A + would actually occur, so `Program_Error' might or might not be raised. + It is possible for a compiler to do a better job of analyzing bodies, to + determine whether or not `Program_Error' might be raised, but it + certainly couldn't do a perfect job (that would require solving the + halting problem and is provably impossible), and because this is a + warning anyway, it does not seem worth the effort to do the analysis. + Cases in which it would be relevant are rare. + + In practice, warnings of either of the forms given above will + usually correspond to real errors, and should be examined carefully and + eliminated. In the rare case where a warning is bogus, it can be + suppressed by any of the following methods: + + * Compile with the `-gnatws' switch set + + * Suppress `Elaboration_Checks' for the called subprogram + + * Use pragma `Warnings_Off' to turn warnings off for the call + + For the internal elaboration check case, GNAT by default generates the + necessary run-time checks to ensure that `Program_Error' is raised if + any call fails an elaboration check. Of course this can only happen if a + warning has been issued as described above. The use of pragma `Suppress + (Elaboration_Checks)' may (but is not guaranteed to) suppress some of + these checks, meaning that it may be possible (but is not guaranteed) + for a program to be able to call a subprogram whose body is not yet + elaborated, without raising a `Program_Error' exception. + +  + File: gnat_ug_wnt.info, Node: Controlling Elaboration in GNAT - External Calls, Next: Default Behavior in GNAT - Ensuring Safety, Prev: Controlling Elaboration in GNAT - Internal Calls, Up: Elaboration Order Handling in GNAT + + Controlling Elaboration in GNAT - External Calls + ================================================ + + The previous section discussed the case in which the execution of a + particular thread of elaboration code occurred entirely within a single + unit. This is the easy case to handle, because a programmer has direct + and total control over the order of elaboration, and furthermore, + checks need only be generated in cases which are rare and which the + compiler can easily detect. The situation is more complex when + separate compilation is taken into account. Consider the following: + + package Math is + function Sqrt (Arg : Float) return Float; + end Math; + + package body Math is + function Sqrt (Arg : Float) return Float is + begin + ... + end Sqrt; + end Math; + + with Math; + package Stuff is + X : Float := Math.Sqrt (0.5); + end Stuff; + + with Stuff; + procedure Main is + begin + ... + end Main; + + where `Main' is the main program. When this program is executed, the + elaboration code must first be executed, and one of the jobs of the + binder is to determine the order in which the units of a program are to + be elaborated. In this case we have four units: the spec and body of + `Math', the spec of `Stuff' and the body of `Main'). In what order + should the four separate sections of elaboration code be executed? + + There are some restrictions in the order of elaboration that the + binder can choose. In particular, if unit U has a `with' for a package + `X', then you are assured that the spec of `X' is elaborated before U , + but you are not assured that the body of `X' is elaborated before U. + This means that in the above case, the binder is allowed to choose the + order: + + spec of Math + spec of Stuff + body of Math + body of Main + + but that's not good, because now the call to `Math.Sqrt' that happens + during the elaboration of the `Stuff' spec happens before the body of + `Math.Sqrt' is elaborated, and hence causes `Program_Error' exception + to be raised. At first glance, one might say that the binder is + misbehaving, because obviously you want to elaborate the body of + something you `with' first, but that is not a general rule that can be + followed in all cases. Consider + + package X is ... + + package Y is ... + + with X; + package body Y is ... + + with Y; + package body X is ... + + This is a common arrangement, and, apart from the order of elaboration + problems that might arise in connection with elaboration code, this + works fine. A rule that says that you must first elaborate the body of + anything you `with' cannot work in this case: the body of `X' `with''s + `Y', which means you would have to elaborate the body of `Y' first, but + that `with''s `X', which means you have to elaborate the body of `X' + first, but ... and we have a loop that cannot be broken. + + It is true that the binder can in many cases guess an order of + elaboration that is unlikely to cause a `Program_Error' exception to be + raised, and it tries to do so (in the above example of + `Math/Stuff/Spec', the GNAT binder will by default elaborate the body + of `Math' right after its spec, so all will be well). + + However, a program that blindly relies on the binder to be helpful + can get into trouble, as we discussed in the previous sections, so GNAT + provides a number of facilities for assisting the programmer in + developing programs that are robust with respect to elaboration order. + +  + File: gnat_ug_wnt.info, Node: Default Behavior in GNAT - Ensuring Safety, Next: Elaboration Issues for Library Tasks, Prev: Controlling Elaboration in GNAT - External Calls, Up: Elaboration Order Handling in GNAT + + Default Behavior in GNAT - Ensuring Safety + ========================================== + + The default behavior in GNAT ensures elaboration safety. In its default + mode GNAT implements the rule we previously described as the right + approach. Let's restate it: + + * _If a unit has elaboration code that can directly or indirectly + make a call to a subprogram in a `with''ed unit, or instantiate a + generic unit in a `with''ed unit, then if the `with''ed unit does + not have pragma `Pure' or `Preelaborate', then the client should + have an `Elaborate_All' for the `with''ed unit._ + + By following this rule a client is assured that calls and + instantiations can be made without risk of an exception. + + In this mode GNAT traces all calls that are potentially made from + elaboration code, and puts in any missing implicit `Elaborate_All' + pragmas. The advantage of this approach is that no elaboration problems + are possible if the binder can find an elaboration order that is + consistent with these implicit `Elaborate_All' pragmas. The + disadvantage of this approach is that no such order may exist. + + If the binder does not generate any diagnostics, then it means that + it has found an elaboration order that is guaranteed to be safe. + However, the binder may still be relying on implicitly generated + `Elaborate_All' pragmas so portability to other compilers than GNAT is + not guaranteed. + + If it is important to guarantee portability, then the compilations + should use the `-gnatwl' (warn on elaboration problems) switch. This + will cause warning messages to be generated indicating the missing + `Elaborate_All' pragmas. Consider the following source program: + + with k; + package j is + m : integer := k.r; + end; + + where it is clear that there should be a pragma `Elaborate_All' for + unit `k'. An implicit pragma will be generated, and it is likely that + the binder will be able to honor it. However, it is safer to include + the pragma explicitly in the source. If this unit is compiled with the + `-gnatwl' switch, then the compiler outputs a warning: + + 1. with k; + 2. package j is + 3. m : integer := k.r; + | + >>> warning: call to "r" may raise Program_Error + >>> warning: missing pragma Elaborate_All for "k" + + 4. end; + + and these warnings can be used as a guide for supplying manually the + missing pragmas. + + This default mode is more restrictive than the Ada Reference Manual, + and it is possible to construct programs which will compile using the + dynamic model described there, but will run into a circularity using + the safer static model we have described. + + Of course any Ada compiler must be able to operate in a mode + consistent with the requirements of the Ada Reference Manual, and in + particular must have the capability of implementing the standard + dynamic model of elaboration with run-time checks. + + In GNAT, this standard mode can be achieved either by the use of the + `-gnatE' switch on the compiler (`gcc' or `gnatmake') command, or by + the use of the configuration pragma: + + pragma Elaboration_Checks (RM); + + Either approach will cause the unit affected to be compiled using the + standard dynamic run-time elaboration checks described in the Ada + Reference Manual. The static model is generally preferable, since it is + clearly safer to rely on compile and link time checks rather than + run-time checks. However, in the case of legacy code, it may be + difficult to meet the requirements of the static model. This issue is + further discussed in *Note What to Do If the Default Elaboration + Behavior Fails::. + + Note that the static model provides a strict subset of the allowed + behavior and programs of the Ada Reference Manual, so if you do adhere + to the static model and no circularities exist, then you are assured + that your program will work using the dynamic model. + +  + File: gnat_ug_wnt.info, Node: Elaboration Issues for Library Tasks, Next: Mixing Elaboration Models, Prev: Default Behavior in GNAT - Ensuring Safety, Up: Elaboration Order Handling in GNAT + + Elaboration Issues for Library Tasks + ==================================== + + In this section we examine special elaboration issues that arise for + programs that declare library level tasks. + + Generally the model of execution of an Ada program is that all units + are elaborated, and then execution of the program starts. However, the + declaration of library tasks definitely does not fit this model. The + reason for this is that library tasks start as soon as they are declared + (more precisely, as soon as the statement part of the enclosing package + body is reached), that is to say before elaboration of the program is + complete. This means that if such a task calls a subprogram, or an + entry in another task, the callee may or may not be elaborated yet, and + in the standard Reference Manual model of dynamic elaboration checks, + you can even get timing dependent Program_Error exceptions, since there + can be a race between the elaboration code and the task code. + + The static model of elaboration in GNAT seeks to avoid all such + dynamic behavior, by being conservative, and the conservative approach + in this particular case is to assume that all the code in a task body + is potentially executed at elaboration time if a task is declared at + the library level. + + This can definitely result in unexpected circularities. Consider the + following example + + package Decls is + task Lib_Task is + entry Start; + end Lib_Task; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + procedure Main is + begin + Decls.Lib_Task.Start; + end; + + If the above example is compiled in the default static elaboration + mode, then a circularity occurs. The circularity comes from the call + `Utils.Put_Val' in the task body of `Decls.Lib_Task'. Since this call + occurs in elaboration code, we need an implicit pragma `Elaborate_All' + for `Utils'. This means that not only must the spec and body of `Utils' + be elaborated before the body of `Decls', but also the spec and body of + any unit that is `with'ed' by the body of `Utils' must also be + elaborated before the body of `Decls'. This is the transitive + implication of pragma `Elaborate_All' and it makes sense, because in + general the body of `Put_Val' might have a call to something in a + `with'ed' unit. + + In this case, the body of Utils (actually its spec) `with's' + `Decls'. Unfortunately this means that the body of `Decls' must be + elaborated before itself, in case there is a call from the body of + `Utils'. + + Here is the exact chain of events we are worrying about: + + 1. In the body of `Decls' a call is made from within the body of a + library task to a subprogram in the package `Utils'. Since this + call may occur at elaboration time (given that the task is + activated at elaboration time), we have to assume the worst, i.e. + that the call does happen at elaboration time. + + 2. This means that the body and spec of `Util' must be elaborated + before the body of `Decls' so that this call does not cause an + access before elaboration. + + 3. Within the body of `Util', specifically within the body of + `Util.Put_Val' there may be calls to any unit `with''ed by this + package. + + 4. One such `with''ed package is package `Decls', so there might be a + call to a subprogram in `Decls' in `Put_Val'. In fact there is + such a call in this example, but we would have to assume that + there was such a call even if it were not there, since we are not + supposed to write the body of `Decls' knowing what is in the body + of `Utils'; certainly in the case of the static elaboration model, + the compiler does not know what is in other bodies and must assume + the worst. + + 5. This means that the spec and body of `Decls' must also be + elaborated before we elaborate the unit containing the call, but + that unit is `Decls'! This means that the body of `Decls' must be + elaborated before itself, and that's a circularity. + + Indeed, if you add an explicit pragma Elaborate_All for `Utils' in the + body of `Decls' you will get a true Ada Reference Manual circularity + that makes the program illegal. + + In practice, we have found that problems with the static model of + elaboration in existing code often arise from library tasks, so we must + address this particular situation. + + Note that if we compile and run the program above, using the dynamic + model of elaboration (that is to say use the `-gnatE' switch), then it + compiles, binds, links, and runs, printing the expected result of 2. + Therefore in some sense the circularity here is only apparent, and we + need to capture the properties of this program that distinguish it + from other library-level tasks that have real elaboration problems. + + We have four possible answers to this question: + + * Use the dynamic model of elaboration. + + If we use the `-gnatE' switch, then as noted above, the program + works. Why is this? If we examine the task body, it is apparent + that the task cannot proceed past the `accept' statement until + after elaboration has been completed, because the corresponding + entry call comes from the main program, not earlier. This is why + the dynamic model works here. But that's really giving up on a + precise analysis, and we prefer to take this approach only if we + cannot solve the problem in any other manner. So let us examine + two ways to reorganize the program to avoid the potential + elaboration problem. + + * Split library tasks into separate packages. + + Write separate packages, so that library tasks are isolated from + other declarations as much as possible. Let us look at a variation + on the above program. + + package Decls1 is + task Lib_Task is + entry Start; + end Lib_Task; + end Decls1; + + with Utils; + package body Decls1 is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + end Decls1; + + package Decls2 is + type My_Int is new Integer; + function Ident (M : My_Int) return My_Int; + end Decls2; + + with Utils; + package body Decls2 is + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls2; + + with Decls2; + package Utils is + procedure Put_Val (Arg : Decls2.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls2.My_Int) is + begin + Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls1; + procedure Main is + begin + Decls1.Lib_Task.Start; + end; + + All we have done is to split `Decls' into two packages, one + containing the library task, and one containing everything else. + Now there is no cycle, and the program compiles, binds, links and + executes using the default static model of elaboration. + + * Declare separate task types. + + A significant part of the problem arises because of the use of the + single task declaration form. This means that the elaboration of + the task type, and the elaboration of the task itself (i.e. the + creation of the task) happen at the same time. A good rule of + style in Ada 95 is to always create explicit task types. By + following the additional step of placing task objects in separate + packages from the task type declaration, many elaboration problems + are avoided. Here is another modified example of the example + program: + + package Decls is + task type Lib_Task_Type is + entry Start; + end Lib_Task_Type; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task_Type is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task_Type; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + package Declst is + Lib_Task : Decls.Lib_Task_Type; + end Declst; + + with Declst; + procedure Main is + begin + Declst.Lib_Task.Start; + end; + + What we have done here is to replace the `task' declaration in + package `Decls' with a `task type' declaration. Then we introduce + a separate package `Declst' to contain the actual task object. + This separates the elaboration issues for the `task type' + declaration, which causes no trouble, from the elaboration issues + of the task object, which is also unproblematic, since it is now + independent of the elaboration of `Utils'. This separation of + concerns also corresponds to a generally sound engineering + principle of separating declarations from instances. This version + of the program also compiles, binds, links, and executes, + generating the expected output. + + * Use No_Entry_Calls_In_Elaboration_Code restriction. + + The previous two approaches described how a program can be + restructured to avoid the special problems caused by library task + bodies. in practice, however, such restructuring may be difficult + to apply to existing legacy code, so we must consider solutions + that do not require massive rewriting. + + Let us consider more carefully why our original sample program + works under the dynamic model of elaboration. The reason is that + the code in the task body blocks immediately on the `accept' + statement. Now of course there is nothing to prohibit elaboration + code from making entry calls (for example from another library + level task), so we cannot tell in isolation that the task will not + execute the accept statement during elaboration. + + However, in practice it is very unusual to see elaboration code + make any entry calls, and the pattern of tasks starting at + elaboration time and then immediately blocking on `accept' or + `select' statements is very common. What this means is that the + compiler is being too pessimistic when it analyzes the whole + package body as though it might be executed at elaboration time. + + If we know that the elaboration code contains no entry calls, (a + very safe assumption most of the time, that could almost be made + the default behavior), then we can compile all units of the + program under control of the following configuration pragma: + + pragma Restrictions (No_Entry_Calls_In_Elaboration_Code); + + This pragma can be placed in the `gnat.adc' file in the usual + manner. If we take our original unmodified program and compile it + in the presence of a `gnat.adc' containing the above pragma, then + once again, we can compile, bind, link, and execute, obtaining the + expected result. In the presence of this pragma, the compiler does + not trace calls in a task body, that appear after the first + `accept' or `select' statement, and therefore does not report a + potential circularity in the original program. + + The compiler will check to the extent it can that the above + restriction is not violated, but it is not always possible to do a + complete check at compile time, so it is important to use this + pragma only if the stated restriction is in fact met, that is to + say no task receives an entry call before elaboration of all units + is completed. + + +  + File: gnat_ug_wnt.info, Node: Mixing Elaboration Models, Next: What to Do If the Default Elaboration Behavior Fails, Prev: Elaboration Issues for Library Tasks, Up: Elaboration Order Handling in GNAT + + Mixing Elaboration Models + ========================= + + So far, we have assumed that the entire program is either compiled + using the dynamic model or static model, ensuring consistency. It is + possible to mix the two models, but rules have to be followed if this + mixing is done to ensure that elaboration checks are not omitted. + + The basic rule is that _a unit compiled with the static model cannot + be `with'ed' by a unit compiled with the dynamic model_. The reason for + this is that in the static model, a unit assumes that its clients + guarantee to use (the equivalent of) pragma `Elaborate_All' so that no + elaboration checks are required in inner subprograms, and this + assumption is violated if the client is compiled with dynamic checks. + + The precise rule is as follows. A unit that is compiled with dynamic + checks can only `with' a unit that meets at least one of the following + criteria: + + * The `with'ed' unit is itself compiled with dynamic elaboration + checks (that is with the `-gnatE' switch. + + * The `with'ed' unit is an internal GNAT implementation unit from + the System, Interfaces, Ada, or GNAT hierarchies. + + * The `with'ed' unit has pragma Preelaborate or pragma Pure. + + * The `with'ing' unit (that is the client) has an explicit pragma + `Elaborate_All' for the `with'ed' unit. + + + If this rule is violated, that is if a unit with dynamic elaboration + checks `with's' a unit that does not meet one of the above four + criteria, then the binder (`gnatbind') will issue a warning similar to + that in the following example: + + warning: "x.ads" has dynamic elaboration checks and with's + warning: "y.ads" which has static elaboration checks + + These warnings indicate that the rule has been violated, and that as a + result elaboration checks may be missed in the resulting executable + file. This warning may be suppressed using the `-ws' binder switch in + the usual manner. + + One useful application of this mixing rule is in the case of a + subsystem which does not itself `with' units from the remainder of the + application. In this case, the entire subsystem can be compiled with + dynamic checks to resolve a circularity in the subsystem, while + allowing the main application that uses this subsystem to be compiled + using the more reliable default static model. + +  + File: gnat_ug_wnt.info, Node: What to Do If the Default Elaboration Behavior Fails, Next: Elaboration for Access-to-Subprogram Values, Prev: Mixing Elaboration Models, Up: Elaboration Order Handling in GNAT + + What to Do If the Default Elaboration Behavior Fails + ==================================================== + + If the binder cannot find an acceptable order, it outputs detailed + diagnostics. For example: + error: elaboration circularity detected + info: "proc (body)" must be elaborated before "pack (body)" + info: reason: Elaborate_All probably needed in unit "pack (body)" + info: recompile "pack (body)" with -gnatwl + info: for full details + info: "proc (body)" + info: is needed by its spec: + info: "proc (spec)" + info: which is withed by: + info: "pack (body)" + info: "pack (body)" must be elaborated before "proc (body)" + info: reason: pragma Elaborate in unit "proc (body)" + + + In this case we have a cycle that the binder cannot break. On the one + hand, there is an explicit pragma Elaborate in `proc' for `pack'. This + means that the body of `pack' must be elaborated before the body of + `proc'. On the other hand, there is elaboration code in `pack' that + calls a subprogram in `proc'. This means that for maximum safety, there + should really be a pragma Elaborate_All in `pack' for `proc' which + would require that the body of `proc' be elaborated before the body of + `pack'. Clearly both requirements cannot be satisfied. Faced with a + circularity of this kind, you have three different options. + + Fix the program + The most desirable option from the point of view of long-term + maintenance is to rearrange the program so that the elaboration + problems are avoided. One useful technique is to place the + elaboration code into separate child packages. Another is to move + some of the initialization code to explicitly called subprograms, + where the program controls the order of initialization explicitly. + Although this is the most desirable option, it may be impractical + and involve too much modification, especially in the case of + complex legacy code. + + Perform dynamic checks + If the compilations are done using the `-gnatE' (dynamic + elaboration check) switch, then GNAT behaves in a quite different + manner. Dynamic checks are generated for all calls that could + possibly result in raising an exception. With this switch, the + compiler does not generate implicit `Elaborate_All' pragmas. The + behavior then is exactly as specified in the Ada 95 Reference + Manual. The binder will generate an executable program that may + or may not raise `Program_Error', and then it is the programmer's + job to ensure that it does not raise an exception. Note that it is + important to compile all units with the switch, it cannot be used + selectively. + + Suppress checks + The drawback of dynamic checks is that they generate a significant + overhead at run time, both in space and time. If you are + absolutely sure that your program cannot raise any elaboration + exceptions, and you still want to use the dynamic elaboration + model, then you can use the configuration pragma `Suppress + (Elaboration_Checks)' to suppress all such checks. For example + this pragma could be placed in the `gnat.adc' file. + + Suppress checks selectively + When you know that certain calls in elaboration code cannot + possibly lead to an elaboration error, and the binder nevertheless + generates warnings on those calls and inserts Elaborate_All + pragmas that lead to elaboration circularities, it is possible to + remove those warnings locally and obtain a program that will bind. + Clearly this can be unsafe, and it is the responsibility of the + programmer to make sure that the resulting program has no + elaboration anomalies. The pragma `Suppress (Elaboration_Check)' + can be used with different granularity to suppress warnings and + break elaboration circularities: + + * Place the pragma that names the called subprogram in the + declarative part that contains the call. + + * Place the pragma in the declarative part, without naming an + entity. This disables warnings on all calls in the + corresponding declarative region. + + * Place the pragma in the package spec that declares the called + subprogram, and name the subprogram. This disables warnings + on all elaboration calls to that subprogram. + + * Place the pragma in the package spec that declares the called + subprogram, without naming any entity. This disables warnings + on all elaboration calls to all subprograms declared in this + spec. + + These four cases are listed in order of decreasing safety, and + therefore require increasing programmer care in their application. + Consider the following program: + + package Pack1 is + function F1 return Integer; + X1 : Integer; + end Pack1; + + package Pack2 is + function F2 return Integer; + function Pure (x : integer) return integer; + -- pragma Suppress (Elaboration_Check, On => Pure); -- (3) + -- pragma Suppress (Elaboration_Check); -- (4) + end Pack2; + + with Pack2; + package body Pack1 is + function F1 return Integer is + begin + return 100; + end F1; + Val : integer := Pack2.Pure (11); -- Elab. call (1) + begin + declare + -- pragma Suppress(Elaboration_Check, Pack2.F2); -- (1) + -- pragma Suppress(Elaboration_Check); -- (2) + begin + X1 := Pack2.F2 + 1; -- Elab. call (2) + end; + end Pack1; + + with Pack1; + package body Pack2 is + function F2 return Integer is + begin + return Pack1.F1; + end F2; + function Pure (x : integer) return integer is + begin + return x ** 3 - 3 * x; + end; + end Pack2; + + with Pack1, Ada.Text_IO; + procedure Proc3 is + begin + Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101 + end Proc3; + In the absence of any pragmas, an attempt to bind this program + produces the following diagnostics: + error: elaboration circularity detected + info: "pack1 (body)" must be elaborated before "pack1 (body)" + info: reason: Elaborate_All probably needed in unit "pack1 (body)" + info: recompile "pack1 (body)" with -gnatwl for full details + info: "pack1 (body)" + info: must be elaborated along with its spec: + info: "pack1 (spec)" + info: which is withed by: + info: "pack2 (body)" + info: which must be elaborated along with its spec: + info: "pack2 (spec)" + info: which is withed by: + info: "pack1 (body)" + The sources of the circularity are the two calls to + `Pack2.Pure' and `Pack2.F2' in the body of `Pack1'. We can see + that the call to F2 is safe, even though F2 calls F1, because the + call appears after the elaboration of the body of F1. Therefore + the pragma (1) is safe, and will remove the warning on the call. + It is also possible to use pragma (2) because there are no other + potentially unsafe calls in the block. + + The call to `Pure' is safe because this function does not depend + on the state of `Pack2'. Therefore any call to this function is + safe, and it is correct to place pragma (3) in the corresponding + package spec. + + Finally, we could place pragma (4) in the spec of `Pack2' to + disable warnings on all calls to functions declared therein. Note + that this is not necessarily safe, and requires more detailed + examination of the subprogram bodies involved. In particular, a + call to `F2' requires that `F1' be already elaborated. + + It is hard to generalize on which of these four approaches should be + taken. Obviously if it is possible to fix the program so that the + default treatment works, this is preferable, but this may not always be + practical. It is certainly simple enough to use `-gnatE' but the + danger in this case is that, even if the GNAT binder finds a correct + elaboration order, it may not always do so, and certainly a binder from + another Ada compiler might not. A combination of testing and analysis + (for which the warnings generated with the `-gnatwl' switch can be + useful) must be used to ensure that the program is free of errors. One + switch that is useful in this testing is the `-p (pessimistic + elaboration order)' switch for `gnatbind'. Normally the binder tries + to find an order that has the best chance of of avoiding elaboration + problems. With this switch, the binder plays a devil's advocate role, + and tries to choose the order that has the best chance of failing. If + your program works even with this switch, then it has a better chance + of being error free, but this is still not a guarantee. + + For an example of this approach in action, consider the C-tests + (executable tests) from the ACVC suite. If these are compiled and run + with the default treatment, then all but one of them succeed without + generating any error diagnostics from the binder. However, there is one + test that fails, and this is not surprising, because the whole point of + this test is to ensure that the compiler can handle cases where it is + impossible to determine a correct order statically, and it checks that + an exception is indeed raised at run time. + + This one test must be compiled and run using the `-gnatE' switch, + and then it passes. Alternatively, the entire suite can be run using + this switch. It is never wrong to run with the dynamic elaboration + switch if your code is correct, and we assume that the C-tests are + indeed correct (it is less efficient, but efficiency is not a factor in + running the ACVC tests.) + +  + File: gnat_ug_wnt.info, Node: Elaboration for Access-to-Subprogram Values, Next: Summary of Procedures for Elaboration Control, Prev: What to Do If the Default Elaboration Behavior Fails, Up: Elaboration Order Handling in GNAT + + Elaboration for Access-to-Subprogram Values + =========================================== + + The introduction of access-to-subprogram types in Ada 95 complicates + the handling of elaboration. The trouble is that it becomes impossible + to tell at compile time which procedure is being called. This means + that it is not possible for the binder to analyze the elaboration + requirements in this case. + + If at the point at which the access value is created (i.e., the + evaluation of `P'Access' for a subprogram `P'), the body of the + subprogram is known to have been elaborated, then the access value is + safe, and its use does not require a check. This may be achieved by + appropriate arrangement of the order of declarations if the subprogram + is in the current unit, or, if the subprogram is in another unit, by + using pragma `Pure', `Preelaborate', or `Elaborate_Body' on the + referenced unit. + + If the referenced body is not known to have been elaborated at the + point the access value is created, then any use of the access value + must do a dynamic check, and this dynamic check will fail and raise a + `Program_Error' exception if the body has not been elaborated yet. + GNAT will generate the necessary checks, and in addition, if the + `-gnatwl' switch is set, will generate warnings that such checks are + required. + + The use of dynamic dispatching for tagged types similarly generates + a requirement for dynamic checks, and premature calls to any primitive + operation of a tagged type before the body of the operation has been + elaborated, will result in the raising of `Program_Error'. + +  + File: gnat_ug_wnt.info, Node: Summary of Procedures for Elaboration Control, Next: Other Elaboration Order Considerations, Prev: Elaboration for Access-to-Subprogram Values, Up: Elaboration Order Handling in GNAT + + Summary of Procedures for Elaboration Control + ============================================= + + First, compile your program with the default options, using none of the + special elaboration control switches. If the binder successfully binds + your program, then you can be confident that, apart from issues raised + by the use of access-to-subprogram types and dynamic dispatching, the + program is free of elaboration errors. If it is important that the + program be portable, then use the `-gnatwl' switch to generate warnings + about missing `Elaborate_All' pragmas, and supply the missing pragmas. + + If the program fails to bind using the default static elaboration + handling, then you can fix the program to eliminate the binder message, + or recompile the entire program with the `-gnatE' switch to generate + dynamic elaboration checks, and, if you are sure there really are no + elaboration problems, use a global pragma `Suppress + (Elaboration_Checks)'. + +  + File: gnat_ug_wnt.info, Node: Other Elaboration Order Considerations, Prev: Summary of Procedures for Elaboration Control, Up: Elaboration Order Handling in GNAT + + Other Elaboration Order Considerations + ====================================== + + This section has been entirely concerned with the issue of finding a + valid elaboration order, as defined by the Ada Reference Manual. In a + case where several elaboration orders are valid, the task is to find one + of the possible valid elaboration orders (and the static model in GNAT + will ensure that this is achieved). + + The purpose of the elaboration rules in the Ada Reference Manual is + to make sure that no entity is accessed before it has been elaborated. + For a subprogram, this means that the spec and body must have been + elaborated before the subprogram is called. For an object, this means + that the object must have been elaborated before its value is read or + written. A violation of either of these two requirements is an access + before elaboration order, and this section has been all about avoiding + such errors. + + In the case where more than one order of elaboration is possible, in + the sense that access before elaboration errors are avoided, then any + one of the orders is "correct" in the sense that it meets the + requirements of the Ada Reference Manual, and no such error occurs. + + However, it may be the case for a given program, that there are + constraints on the order of elaboration that come not from consideration + of avoiding elaboration errors, but rather from extra-lingual logic + requirements. Consider this example: + + with Init_Constants; + package Constants is + X : Integer := 0; + Y : Integer := 0; + end Constants; + + package Init_Constants is + procedure Calc; + end Init_Constants; + + with Constants; + package body Init_Constants is + procedure Calc is begin null; end; + begin + Constants.X := 3; + Constants.Y := 4; + end Init_Constants; + + with Constants; + package Calc is + Z : Integer := Constants.X + Constants.Y; + end Calc; + + with Calc; + with Text_IO; use Text_IO; + procedure Main is + begin + Put_Line (Calc.Z'Img); + end Main; + + In this example, there is more than one valid order of elaboration. For + example both the following are correct orders: + + Init_Constants spec + Constants spec + Calc spec + Main body + Init_Constants body + + and + + Init_Constants spec + Init_Constants body + Constants spec + Calc spec + Main body + + There is no language rule to prefer one or the other, both are correct + from an order of elaboration point of view. But the programmatic effects + of the two orders are very different. In the first, the elaboration + routine of `Calc' initializes `Z' to zero, and then the main program + runs with this value of zero. But in the second order, the elaboration + routine of `Calc' runs after the body of Init_Constants has set `X' and + `Y' and thus `Z' is set to 7 before `Main' runs. + + One could perhaps by applying pretty clever non-artificial + intelligence to the situation guess that it is more likely that the + second order of elaboration is the one desired, but there is no formal + linguistic reason to prefer one over the other. In fact in this + particular case, GNAT will prefer the second order, because of the rule + that bodies are elaborated as soon as possible, but it's just luck that + this is what was wanted (if indeed the second order was preferred). + + If the program cares about the order of elaboration routines in a + case like this, it is important to specify the order required. In this + particular case, that could have been achieved by adding to the spec of + Calc: + + pragma Elaborate_All (Constants); + + which requires that the body (if any) and spec of `Constants', as well + as the body and spec of any unit `with''ed by `Constants' be elaborated + before `Calc' is elaborated. + + Clearly no automatic method can always guess which alternative you + require, and if you are working with legacy code that had constraints + of this kind which were not properly specified by adding `Elaborate' or + `Elaborate_All' pragmas, then indeed it is possible that two different + compilers can choose different orders. + + The `gnatbind' `-p' switch may be useful in smoking out problems. + This switch causes bodies to be elaborated as late as possible instead + of as early as possible. In the example above, it would have forced the + choice of the first elaboration order. If you get different results + when using this switch, and particularly if one set of results is right, + and one is wrong as far as you are concerned, it shows that you have + some missing `Elaborate' pragmas. For the example above, we have the + following output: + + gnatmake -f -q main + main + 7 + gnatmake -f -q main -bargs -p + main + 0 + + It is of course quite unlikely that both these results are correct, so + it is up to you in a case like this to investigate the source of the + difference, by looking at the two elaboration orders that are chosen, + and figuring out which is correct, and then adding the necessary + `Elaborate_All' pragmas to ensure the desired order. + +  + File: gnat_ug_wnt.info, Node: The Cross-Referencing Tools gnatxref and gnatfind, Next: File Name Krunching Using gnatkr, Prev: Elaboration Order Handling in GNAT, Up: Top + + The Cross-Referencing Tools `gnatxref' and `gnatfind' + ***************************************************** + + The compiler generates cross-referencing information (unless you set + the `-gnatx' switch), which are saved in the `.ali' files. This + information indicates where in the source each entity is declared and + referenced. Note that entities in package Standard are not included, but + entities in all other predefined units are included in the output. + + Before using any of these two tools, you need to compile + successfully your application, so that GNAT gets a chance to generate + the cross-referencing information. + + The two tools `gnatxref' and `gnatfind' take advantage of this + information to provide the user with the capability to easily locate the + declaration and references to an entity. These tools are quite similar, + the difference being that `gnatfind' is intended for locating + definitions and/or references to a specified entity or entities, whereas + `gnatxref' is oriented to generating a full report of all + cross-references. + + To use these tools, you must not compile your application using the + `-gnatx' switch on the `gnatmake' command line (*note (gnat_ug)The GNAT + Make Program gnatmake::). Otherwise, cross-referencing information will + not be generated. + + * Menu: + + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + +  + File: gnat_ug_wnt.info, Node: gnatxref Switches, Next: gnatfind Switches, Up: The Cross-Referencing Tools gnatxref and gnatfind + + `gnatxref' Switches + =================== + + The command lines for `gnatxref' is: + $ gnatxref [switches] sourcefile1 [sourcefile2 ...] + + where + + `sourcefile1, sourcefile2' + identifies the source files for which a report is to be generated. + The 'with'ed units will be processed too. You must provide at + least one file. + + These file names are considered to be regular expressions, so for + instance specifying 'source*.adb' is the same as giving every file + in the current directory whose name starts with 'source' and whose + extension is 'adb'. + + The switches can be : + `-a' + If this switch is present, `gnatfind' and `gnatxref' will parse + the read-only files found in the library search path. Otherwise, + these files will be ignored. This option can be used to protect + Gnat sources or your own libraries from being parsed, thus making + `gnatfind' and `gnatxref' much faster, and their output much + smaller. + + `-aIDIR' + When looking for source files also look in directory DIR. The + order in which source file search is undertaken is the same as for + `gnatmake'. + + `-aODIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as + for `gnatmake'. + + `-nostdinc' + Do not look for sources in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-d' + If this switch is set `gnatxref' will output the parent type + reference for each matching derived types. + + `-f' + If this switch is set, the output file names will be preceded by + their directory (if the file was found in the search path). If + this switch is not set, the directory will not be printed. + + `-g' + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may + accelerate `gnatfind' and `gnatxref'. + + `-IDIR' + Equivalent to `-aODIR -aIDIR'. + + `-pFILE' + Specify a project file to use *Note Project Files::. By default, + `gnatxref' and `gnatfind' will try to locate a project file in the + current directory. + + If a project file is either specified or found by the tools, then + the content of the source directory and object directory lines are + added as if they had been specified respectively by `-aI' and + `-aO'. + + `-u' + Output only unused symbols. This may be really useful if you give + your main compilation unit on the command line, as `gnatxref' will + then display every unused entity and 'with'ed package. + + `-v' + Instead of producing the default output, `gnatxref' will generate a + `tags' file that can be used by vi. For examples how to use this + feature, see *Note Examples of gnatxref Usage::. The tags file is + output to the standard output, thus you will have to redirect it + to a file. + + All these switches may be in any order on the command line, and may + even appear after the file names. They need not be separated by spaces, + thus you can say `gnatxref -ag' instead of `gnatxref -a -g'. + +  + File: gnat_ug_wnt.info, Node: gnatfind Switches, Next: Project Files for gnatxref and gnatfind, Prev: gnatxref Switches, Up: The Cross-Referencing Tools gnatxref and gnatfind + + `gnatfind' Switches + =================== + + The command line for `gnatfind' is: + + $ gnatfind [switches] pattern[:sourcefile[:line[:column]]] + [file1 file2 ...] + + where + + `pattern' + An entity will be output only if it matches the regular expression + found in `pattern', see *Note Regular Expressions in gnatfind and + gnatxref::. + + Omitting the pattern is equivalent to specifying `*', which will + match any entity. Note that if you do not provide a pattern, you + have to provide both a sourcefile and a line. + + Entity names are given in Latin-1, with uppercase/lowercase + equivalence for matching purposes. At the current time there is no + support for 8-bit codes other than Latin-1, or for wide characters + in identifiers. + + `sourcefile' + `gnatfind' will look for references, bodies or declarations of + symbols referenced in `sourcefile', at line `line' and column + `column'. See *note Examples of gnatfind Usage:: for syntax + examples. + + `line' + is a decimal integer identifying the line number containing the + reference to the entity (or entities) to be located. + + `column' + is a decimal integer identifying the exact location on the line of + the first character of the identifier for the entity reference. + Columns are numbered from 1. + + `file1 file2 ...' + The search will be restricted to these files. If none are given, + then the search will be done for every library file in the search + path. These file must appear only after the pattern or sourcefile. + + These file names are considered to be regular expressions, so for + instance specifying 'source*.adb' is the same as giving every file + in the current directory whose name starts with 'source' and whose + extension is 'adb'. + + Not that if you specify at least one file in this part, `gnatfind' + may sometimes not be able to find the body of the subprograms... + + At least one of 'sourcefile' or 'pattern' has to be present on the + command line. + + The following switches are available: + `-a' + If this switch is present, `gnatfind' and `gnatxref' will parse + the read-only files found in the library search path. Otherwise, + these files will be ignored. This option can be used to protect + Gnat sources or your own libraries from being parsed, thus making + `gnatfind' and `gnatxref' much faster, and their output much + smaller. + + `-aIDIR' + When looking for source files also look in directory DIR. The + order in which source file search is undertaken is the same as for + `gnatmake'. + + `-aODIR' + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as + for `gnatmake'. + + `-nostdinc' + Do not look for sources in the system default directory. + + `-nostdlib' + Do not look for library files in the system default directory. + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-d' + If this switch is set, then `gnatfind' will output the parent type + reference for each matching derived types. + + `-e' + By default, `gnatfind' accept the simple regular expression set for + `pattern'. If this switch is set, then the pattern will be + considered as full Unix-style regular expression. + + `-f' + If this switch is set, the output file names will be preceded by + their directory (if the file was found in the search path). If + this switch is not set, the directory will not be printed. + + `-g' + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may + accelerate `gnatfind' and `gnatxref'. + + `-IDIR' + Equivalent to `-aODIR -aIDIR'. + + `-pFILE' + Specify a project file (*note Project Files::) to use. By + default, `gnatxref' and `gnatfind' will try to locate a project + file in the current directory. + + If a project file is either specified or found by the tools, then + the content of the source directory and object directory lines are + added as if they had been specified respectively by `-aI' and + `-aO'. + + `-r' + By default, `gnatfind' will output only the information about the + declaration, body or type completion of the entities. If this + switch is set, the `gnatfind' will locate every reference to the + entities in the files specified on the command line (or in every + file in the search path if no file is given on the command line). + + `-s' + If this switch is set, then `gnatfind' will output the content of + the Ada source file lines were the entity was found. + + `-t' + If this switch is set, then `gnatfind' will output the type + hierarchy for the specified type. It act like -d option but + recursively from parent type to parent type. When this switch is + set it is not possible to specify more than one file. + + All these switches may be in any order on the command line, and may + even appear after the file names. They need not be separated by spaces, + thus you can say `gnatxref -ag' instead of `gnatxref -a -g'. + + As stated previously, gnatfind will search in every directory in the + search path. You can force it to look only in the current directory if + you specify `*' at the end of the command line. + +  + File: gnat_ug_wnt.info, Node: Project Files for gnatxref and gnatfind, Next: Regular Expressions in gnatfind and gnatxref, Prev: gnatfind Switches, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Project Files for `gnatxref' and `gnatfind' + =========================================== + + Project files allow a programmer to specify how to compile its + application, where to find sources,... These files are used primarily by + the Glide Ada mode, but they can also be used by the two tools + `gnatxref' and `gnatfind'. + + A project file name must end with `.adp'. If a single one is present + in the current directory, then `gnatxref' and `gnatfind' will extract + the information from it. If multiple project files are found, none of + them is read, and you have to use the `-p' switch to specify the one + you want to use. + + The following lines can be included, even though most of them have + default values which can be used in most cases. The lines can be + entered in any order in the file. Except for `src_dir' and `obj_dir', + you can only have one instance of each line. If you have multiple + instances, only the last one is taken into account. + + `src_dir=DIR [default: "./"]' + specifies a directory where to look for source files. Multiple + src_dir lines can be specified and they will be searched in the + order they are specified. + + `obj_dir=DIR [default: "./"]' + specifies a directory where to look for object and library files. + Multiple obj_dir lines can be specified and they will be searched + in the order they are specified + + `comp_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${comp_opt}' notation. This is intended to store the default + switches given to `gnatmake' and `gcc'. + + `bind_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${bind_opt}' notation. This is intended to store the default + switches given to `gnatbind'. + + `link_opt=SWITCHES [default: ""]' + creates a variable which can be referred to subsequently by using + the `${link_opt}' notation. This is intended to store the default + switches given to `gnatlink'. + + `main=EXECUTABLE [default: ""]' + specifies the name of the executable for the application. This + variable can be referred to in the following lines by using the + `${main}' notation. + + `comp_cmd=COMMAND [default: "gcc -c -I${src_dir} -g -gnatq"]' + specifies the command used to compile a single file in the + application. + + `make_cmd=COMMAND [default: "gnatmake ${main} -aI${src_dir} -aO${obj_dir} -g -gnatq -cargs ${comp_opt} -bargs ${bind_opt} -largs ${link_opt}"]' + specifies the command used to recompile the whole application. + + `run_cmd=COMMAND [default: "${main}"]' + specifies the command used to run the application. + + `debug_cmd=COMMAND [default: "gdb ${main}"]' + specifies the command used to debug the application + + `gnatxref' and `gnatfind' only take into account the `src_dir' and + `obj_dir' lines, and ignore the others. + +  + File: gnat_ug_wnt.info, Node: Regular Expressions in gnatfind and gnatxref, Next: Examples of gnatxref Usage, Prev: Project Files for gnatxref and gnatfind, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Regular Expressions in `gnatfind' and `gnatxref' + ================================================ + + As specified in the section about `gnatfind', the pattern can be a + regular expression. Actually, there are to set of regular expressions + which are recognized by the program : + + `globbing patterns' + These are the most usual regular expression. They are the same + that you generally used in a Unix shell command line, or in a DOS + session. + + Here is a more formal grammar : + regexp ::= term + term ::= elmt -- matches elmt + term ::= elmt elmt -- concatenation (elmt then elmt) + term ::= * -- any string of 0 or more characters + term ::= ? -- matches any character + term ::= [char {char}] -- matches any character listed + term ::= [char - char] -- matches any character in range + + `full regular expression' + The second set of regular expressions is much more powerful. This + is the type of regular expressions recognized by utilities such a + `grep'. + + The following is the form of a regular expression, expressed in Ada + reference manual style BNF is as follows + + regexp ::= term {| term} -- alternation (term or term ...) + + term ::= item {item} -- concatenation (item then item) + + item ::= elmt -- match elmt + item ::= elmt * -- zero or more elmt's + item ::= elmt + -- one or more elmt's + item ::= elmt ? -- matches elmt or nothing + elmt ::= nschar -- matches given character + elmt ::= [nschar {nschar}] -- matches any character listed + elmt ::= [^ nschar {nschar}] -- matches any character not listed + elmt ::= [char - char] -- matches chars in given range + elmt ::= \ char -- matches given character + elmt ::= . -- matches any single character + elmt ::= ( regexp ) -- parens used for grouping + + char ::= any character, including special characters + nschar ::= any character except ()[].*+?^ + + Following are a few examples : + + `abcde|fghi' + will match any of the two strings 'abcde' and 'fghi'. + + `abc*d' + will match any string like 'abd', 'abcd', 'abccd', 'abcccd', + and so on + + `[a-z]+' + will match any string which has only lowercase characters in + it (and at least one character + +  + File: gnat_ug_wnt.info, Node: Examples of gnatxref Usage, Next: Examples of gnatfind Usage, Prev: Regular Expressions in gnatfind and gnatxref, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Examples of `gnatxref' Usage + ============================ + + General Usage + ------------- + + For the following examples, we will consider the following units : + + main.ads: + 1: with Bar; + 2: package Main is + 3: procedure Foo (B : in Integer); + 4: C : Integer; + 5: private + 6: D : Integer; + 7: end Main; + + main.adb: + 1: package body Main is + 2: procedure Foo (B : in Integer) is + 3: begin + 4: C := B; + 5: D := B; + 6: Bar.Print (B); + 7: Bar.Print (C); + 8: end Foo; + 9: end Main; + + bar.ads: + 1: package Bar is + 2: procedure Print (B : Integer); + 3: end bar; + + The first thing to do is to recompile your application (for + instance, in that case just by doing a `gnatmake main', so that + GNAT generates the cross-referencing information. You can then + issue any of the following commands: + + `gnatxref main.adb' + `gnatxref' generates cross-reference information for main.adb and + every unit 'with'ed by main.adb. + + The output would be: + B Type: Integer + Decl: bar.ads 2:22 + B Type: Integer + Decl: main.ads 3:20 + Body: main.adb 2:20 + Ref: main.adb 4:13 5:13 6:19 + Bar Type: Unit + Decl: bar.ads 1:9 + Ref: main.adb 6:8 7:8 + main.ads 1:6 + C Type: Integer + Decl: main.ads 4:5 + Modi: main.adb 4:8 + Ref: main.adb 7:19 + D Type: Integer + Decl: main.ads 6:5 + Modi: main.adb 5:8 + Foo Type: Unit + Decl: main.ads 3:15 + Body: main.adb 2:15 + Main Type: Unit + Decl: main.ads 2:9 + Body: main.adb 1:14 + Print Type: Unit + Decl: bar.ads 2:15 + Ref: main.adb 6:12 7:12 + + that is the entity `Main' is declared in main.ads, line 2, column + 9, its body is in main.adb, line 1, column 14 and is not + referenced any where. + + The entity `Print' is declared in bar.ads, line 2, column 15 and it + it referenced in main.adb, line 6 column 12 and line 7 column 12. + + `gnatxref package1.adb package2.ads' + `gnatxref' will generates cross-reference information for + package1.adb, package2.ads and any other package 'with'ed by any + of these. + + Using gnatxref with vi + ---------------------- + + `gnatxref' can generate a tags file output, which can be used + directly from `vi'. Note that the standard version of `vi' will not + work properly with overloaded symbols. Consider using another free + implementation of `vi', such as `vim'. + + $ gnatxref -v gnatfind.adb > tags + + will generate the tags file for `gnatfind' itself (if the sources are + in the search path!). + + From `vi', you can then use the command `:tag entity' (replacing + entity by whatever you are looking for), and vi will display a new file + with the corresponding declaration of entity. + +  + File: gnat_ug_wnt.info, Node: Examples of gnatfind Usage, Prev: Examples of gnatxref Usage, Up: The Cross-Referencing Tools gnatxref and gnatfind + + Examples of `gnatfind' Usage + ============================ + + `gnatfind -f xyz:main.adb' + Find declarations for all entities xyz referenced at least once in + main.adb. The references are search in every library file in the + search path. + + The directories will be printed as well (as the `-f' switch is set) + + The output will look like: + directory/main.ads:106:14: xyz <= declaration + directory/main.adb:24:10: xyz <= body + directory/foo.ads:45:23: xyz <= declaration + + that is to say, one of the entities xyz found in main.adb is + declared at line 12 of main.ads (and its body is in main.adb), and + another one is declared at line 45 of foo.ads + + `gnatfind -fs xyz:main.adb' + This is the same command as the previous one, instead `gnatfind' + will display the content of the Ada source file lines. + + The output will look like: + + directory/main.ads:106:14: xyz <= declaration + procedure xyz; + directory/main.adb:24:10: xyz <= body + procedure xyz is + directory/foo.ads:45:23: xyz <= declaration + xyz : Integer; + + This can make it easier to find exactly the location your are + looking for. + + `gnatfind -r "*x*":main.ads:123 foo.adb' + Find references to all entities containing an x that are + referenced on line 123 of main.ads. The references will be + searched only in main.adb and foo.adb. + + `gnatfind main.ads:123' + Find declarations and bodies for all entities that are referenced + on line 123 of main.ads. + + This is the same as `gnatfind "*":main.adb:123'. + + `gnatfind mydir/main.adb:123:45' + Find the declaration for the entity referenced at column 45 in + line 123 of file main.adb in directory mydir. Note that it is + usual to omit the identifier name when the column is given, since + the column position identifies a unique reference. + + The column has to be the beginning of the identifier, and should + not point to any character in the middle of the identifier. + +  + File: gnat_ug_wnt.info, Node: File Name Krunching Using gnatkr, Next: Preprocessing Using gnatprep, Prev: The Cross-Referencing Tools gnatxref and gnatfind, Up: Top + + File Name Krunching Using `gnatkr' + ********************************** + + This chapter discusses the method used by the compiler to shorten the + default file names chosen for Ada units so that they do not exceed the + maximum length permitted. It also describes the `gnatkr' utility that + can be used to determine the result of applying this shortening. + + * Menu: + + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + +  + File: gnat_ug_wnt.info, Node: About gnatkr, Next: Using gnatkr, Up: File Name Krunching Using gnatkr + + About `gnatkr' + ============== + + The default file naming rule in GNAT is that the file name must be + derived from the unit name. The exact default rule is as follows: + * Take the unit name and replace all dots by hyphens. + + * If such a replacement occurs in the second character position of a + name, and the first character is a, g, s, or i then replace the + dot by the character ~ (tilde) instead of a minus. + The reason for this exception is to avoid clashes with the standard + names for children of System, Ada, Interfaces, and GNAT, which use the + prefixes s- a- i- and g- respectively. + + The `-gnatkNN' switch of the compiler activates a "krunching" + circuit that limits file names to nn characters (where nn is a decimal + integer). For example, using OpenVMS, where the maximum file name + length is 39, the value of nn is usually set to 39, but if you want to + generate a set of files that would be usable if ported to a system with + some different maximum file length, then a different value can be + specified. The default value of 39 for OpenVMS need not be specified. + + The `gnatkr' utility can be used to determine the krunched name for + a given file, when krunched to a specified maximum length. + +  + File: gnat_ug_wnt.info, Node: Using gnatkr, Next: Krunching Method, Prev: About gnatkr, Up: File Name Krunching Using gnatkr + + Using `gnatkr' + ============== + + The `gnatkr' command has the form + + $ gnatkr NAME [LENGTH] + + NAME can be an Ada name with dots or the GNAT name of the unit, where + the dots representing child units or subunit are replaced by hyphens. + The only confusion arises if a name ends in `.ads' or `.adb'. `gnatkr' + takes this to be an extension if there are no other dots in the name + and the whole name is in lowercase. + + LENGTH represents the length of the krunched name. The default when + no argument is given is 8 characters. A length of zero stands for + unlimited, in other words do not chop except for system files which are + always 8. + + The output is the krunched name. The output has an extension only if the + original argument was a file name with an extension. + +  + File: gnat_ug_wnt.info, Node: Krunching Method, Next: Examples of gnatkr Usage, Prev: Using gnatkr, Up: File Name Krunching Using gnatkr + + Krunching Method + ================ + + The initial file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + lowercase for all letters, except that a hyphen in the second character + position is replaced by a tilde if the first character is a, i, g, or s. + The extension is `.ads' for a specification and `.adb' for a body. + Krunching does not affect the extension, but the file name is shortened + to the specified length by following these rules: + + * The name is divided into segments separated by hyphens, tildes or + underscores and all hyphens, tildes, and underscores are + eliminated. If this leaves the name short enough, we are done. + + * If the name is too long, the longest segment is located (left-most + if there are two of equal length), and shortened by dropping its + last character. This is repeated until the name is short enough. + + As an example, consider the krunching of + `our-strings-wide_fixed.adb' to fit the name into 8 characters as + required by some operating systems. + + our-strings-wide_fixed 22 + our strings wide fixed 19 + our string wide fixed 18 + our strin wide fixed 17 + our stri wide fixed 16 + our stri wide fixe 15 + our str wide fixe 14 + our str wid fixe 13 + our str wid fix 12 + ou str wid fix 11 + ou st wid fix 10 + ou st wi fix 9 + ou st wi fi 8 + Final file name: oustwifi.adb + + * The file names for all predefined units are always krunched to + eight characters. The krunching of these predefined units uses the + following special prefix replacements: + + `ada-' + replaced by `a-' + + `gnat-' + replaced by `g-' + + `interfaces-' + replaced by `i-' + + `system-' + replaced by `s-' + + These system files have a hyphen in the second character position. + That is why normal user files replace such a character with a + tilde, to avoid confusion with system file names. + + As an example of this special rule, consider + `ada-strings-wide_fixed.adb', which gets krunched as follows: + + ada-strings-wide_fixed 22 + a- strings wide fixed 18 + a- string wide fixed 17 + a- strin wide fixed 16 + a- stri wide fixed 15 + a- stri wide fixe 14 + a- str wide fixe 13 + a- str wid fixe 12 + a- str wid fix 11 + a- st wid fix 10 + a- st wi fix 9 + a- st wi fi 8 + Final file name: a-stwifi.adb + + Of course no file shortening algorithm can guarantee uniqueness over + all possible unit names, and if file name krunching is used then it is + your responsibility to ensure that no name clashes occur. The utility + program `gnatkr' is supplied for conveniently determining the krunched + name of a file. + +  + File: gnat_ug_wnt.info, Node: Examples of gnatkr Usage, Prev: Krunching Method, Up: File Name Krunching Using gnatkr + + Examples of `gnatkr' Usage + ========================== + + $ gnatkr very_long_unit_name.ads --> velounna.ads + $ gnatkr grandparent-parent-child.ads --> grparchi.ads + $ gnatkr Grandparent.Parent.Child --> grparchi + $ gnatkr very_long_unit_name.ads/count=6 --> vlunna.ads + $ gnatkr very_long_unit_name.ads/count=0 --> very_long_unit_name.ads + +  + File: gnat_ug_wnt.info, Node: Preprocessing Using gnatprep, Next: The GNAT Library Browser gnatls, Prev: File Name Krunching Using gnatkr, Up: Top + + Preprocessing Using `gnatprep' + ****************************** + + The `gnatprep' utility provides a simple preprocessing capability for + Ada programs. It is designed for use with GNAT, but is not dependent + on any special features of GNAT. + + * Menu: + + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + +  + File: gnat_ug_wnt.info, Node: Using gnatprep, Next: Switches for gnatprep, Up: Preprocessing Using gnatprep + + Using `gnatprep' + ================ + + To call `gnatprep' use + + $ gnatprep [-bcrsu] [-Dsymbol=value] infile outfile [deffile] + + where + `infile' + is the full name of the input file, which is an Ada source file + containing preprocessor directives. + + `outfile' + is the full name of the output file, which is an Ada source in + standard Ada form. When used with GNAT, this file name will + normally have an ads or adb suffix. + + `deffile' + is the full name of a text file containing definitions of symbols + to be referenced by the preprocessor. This argument is optional, + and can be replaced by the use of the `-D' switch. + + `switches' + is an optional sequence of switches as described in the next + section. + +  + File: gnat_ug_wnt.info, Node: Switches for gnatprep, Next: Form of Definitions File, Prev: Using gnatprep, Up: Preprocessing Using gnatprep + + Switches for `gnatprep' + ======================= + + `-b' + Causes both preprocessor lines and the lines deleted by + preprocessing to be replaced by blank lines in the output source + file, preserving line numbers in the output file. + + `-c' + Causes both preprocessor lines and the lines deleted by + preprocessing to be retained in the output source as comments + marked with the special string "-! ". This option will result in + line numbers being preserved in the output file. + + `-Dsymbol=value' + Defines a new symbol, associated with value. If no value is given + on the command line, then symbol is considered to be `True'. This + switch can be used in place of a definition file. + + `-r' + Causes a `Source_Reference' pragma to be generated that references + the original input file, so that error messages will use the file + name of this original file. The use of this switch implies that + preprocessor lines are not to be removed from the file, so its use + will force `-b' mode if `-c' has not been specified explicitly. + + Note that if the file to be preprocessed contains multiple units, + then it will be necessary to `gnatchop' the output file from + `gnatprep'. If a `Source_Reference' pragma is present in the + preprocessed file, it will be respected by `gnatchop -r' so that + the final chopped files will correctly refer to the original input + source file for `gnatprep'. + + `-s' + Causes a sorted list of symbol names and values to be listed on + the standard output file. + + `-u' + Causes undefined symbols to be treated as having the value FALSE + in the context of a preprocessor test. In the absence of this + option, an undefined symbol in a `#if' or `#elsif' test will be + treated as an error. + + Note: if neither `-b' nor `-c' is present, then preprocessor lines and + deleted lines are completely removed from the output, unless -r is + specified, in which case -b is assumed. + +  + File: gnat_ug_wnt.info, Node: Form of Definitions File, Next: Form of Input Text for gnatprep, Prev: Switches for gnatprep, Up: Preprocessing Using gnatprep + + Form of Definitions File + ======================== + + The definitions file contains lines of the form + + symbol := value + + where symbol is an identifier, following normal Ada (case-insensitive) + rules for its syntax, and value is one of the following: + + * Empty, corresponding to a null substitution + + * A string literal using normal Ada syntax + + * Any sequence of characters from the set (letters, digits, period, + underline). + + Comment lines may also appear in the definitions file, starting with + the usual `--', and comments may be added to the definitions lines. + +  + File: gnat_ug_wnt.info, Node: Form of Input Text for gnatprep, Prev: Form of Definitions File, Up: Preprocessing Using gnatprep + + Form of Input Text for `gnatprep' + ================================= + + The input text may contain preprocessor conditional inclusion lines, as + well as general symbol substitution sequences. + + The preprocessor conditional inclusion commands have the form + + #if expression [then] + lines + #elsif expression [then] + lines + #elsif expression [then] + lines + ... + #else + lines + #end if; + + In this example, expression is defined by the following grammar: + expression ::= + expression ::= = "" + expression ::= = + expression ::= 'Defined + expression ::= not expression + expression ::= expression and expression + expression ::= expression or expression + expression ::= expression and then expression + expression ::= expression or else expression + expression ::= ( expression ) + + For the first test (expression ::= ) the symbol must have + either the value true or false, that is to say the right-hand of the + symbol definition must be one of the (case-insensitive) literals `True' + or `False'. If the value is true, then the corresponding lines are + included, and if the value is false, they are excluded. + + The test (expression ::= `'Defined') is true only if the + symbol has been defined in the definition file or by a `-D' switch on + the command line. Otherwise, the test is false. + + The equality tests are case insensitive, as are all the preprocessor + lines. + + If the symbol referenced is not defined in the symbol definitions + file, then the effect depends on whether or not switch `-u' is + specified. If so, then the symbol is treated as if it had the value + false and the test fails. If this switch is not specified, then it is + an error to reference an undefined symbol. It is also an error to + reference a symbol that is defined with a value other than `True' or + `False'. + + The use of the `not' operator inverts the sense of this logical + test, so that the lines are included only if the symbol is not defined. + The `then' keyword is optional as shown + + The `#' must be the first non-blank character on a line, but + otherwise the format is free form. Spaces or tabs may appear between + the `#' and the keyword. The keywords and the symbols are case + insensitive as in normal Ada code. Comments may be used on a + preprocessor line, but other than that, no other tokens may appear on a + preprocessor line. Any number of `elsif' clauses can be present, + including none at all. The `else' is optional, as in Ada. + + The `#' marking the start of a preprocessor line must be the first + non-blank character on the line, i.e. it must be preceded only by + spaces or horizontal tabs. + + Symbol substitution outside of preprocessor lines is obtained by + using the sequence + + $symbol + + anywhere within a source line, except in a comment or within a string + literal. The identifier following the `$' must match one of the symbols + defined in the symbol definition file, and the result is to substitute + the value of the symbol in place of `$symbol' in the output file. + + Note that although the substitution of strings within a string + literal is not possible, it is possible to have a symbol whose defined + value is a string literal. So instead of setting XYZ to `hello' and + writing: + + Header : String := "$XYZ"; + + you should set XYZ to `"hello"' and write: + + Header : String := $XYZ; + + and then the substitution will occur as desired. + +  + File: gnat_ug_wnt.info, Node: The GNAT Library Browser gnatls, Next: GNAT and Libraries, Prev: Preprocessing Using gnatprep, Up: Top + + The GNAT Library Browser `gnatls' + ********************************* + + `gnatls' is a tool that outputs information about compiled units. It + gives the relationship between objects, unit names and source files. It + can also be used to check the source dependencies of a unit as well as + various characteristics. + + * Menu: + + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + +  + File: gnat_ug_wnt.info, Node: Running gnatls, Next: Switches for gnatls, Up: The GNAT Library Browser gnatls + + Running `gnatls' + ================ + + The `gnatls' command has the form + + $ gnatls switches OBJECT_OR_ALI_FILE + + The main argument is the list of object or `ali' files (*note The Ada + Library Information Files::) for which information is requested. + + In normal mode, without additional option, `gnatls' produces a + four-column listing. Each line represents information for a specific + object. The first column gives the full path of the object, the second + column gives the name of the principal unit in this object, the third + column gives the status of the source and the fourth column gives the + full path of the source representing this unit. Here is a simple + example of use: + + $ gnatls *.o + ./demo1.o demo1 DIF demo1.adb + ./demo2.o demo2 OK demo2.adb + ./hello.o h1 OK hello.adb + ./instr-child.o instr.child MOK instr-child.adb + ./instr.o instr OK instr.adb + ./tef.o tef DIF tef.adb + ./text_io_example.o text_io_example OK text_io_example.adb + ./tgef.o tgef DIF tgef.adb + + The first line can be interpreted as follows: the main unit which is + contained in object file `demo1.o' is demo1, whose main source is in + `demo1.adb'. Furthermore, the version of the source used for the + compilation of demo1 has been modified (DIF). Each source file has a + status qualifier which can be: + + `OK (unchanged)' + The version of the source file used for the compilation of the + specified unit corresponds exactly to the actual source file. + + `MOK (slightly modified)' + The version of the source file used for the compilation of the + specified unit differs from the actual source file but not enough + to require recompilation. If you use gnatmake with the qualifier + `-m (minimal recompilation)', a file marked MOK will not be + recompiled. + + `DIF (modified)' + No version of the source found on the path corresponds to the + source used to build this object. + + `??? (file not found)' + No source file was found for this unit. + + `HID (hidden, unchanged version not first on PATH)' + The version of the source that corresponds exactly to the source + used for compilation has been found on the path but it is hidden + by another version of the same source that has been modified. + +  + File: gnat_ug_wnt.info, Node: Switches for gnatls, Next: Examples of gnatls Usage, Prev: Running gnatls, Up: The GNAT Library Browser gnatls + + Switches for `gnatls' + ===================== + + `gnatls' recognizes the following switches: + + `-a' + Consider all units, including those of the predefined Ada library. + Especially useful with `-d'. + + `-d' + List sources from which specified units depend on. + + `-h' + Output the list of options. + + `-o' + Only output information about object files. + + `-s' + Only output information about source files. + + `-u' + Only output information about compilation units. + + `-aODIR' + `-aIDIR' + `-IDIR' + `-I-' + `-nostdinc' + Source path manipulation. Same meaning as the equivalent + `gnatmake' flags (see *Note Switches for gnatmake::). + + `--RTS=RTS-PATH' + Specifies the default location of the runtime library. Same + meaning as the equivalent `gnatmake' flag (see *Note Switches for + gnatmake::). + + `-v' + Verbose mode. Output the complete source and object paths. Do not + use the default column layout but instead use long format giving + as much as information possible on each requested units, including + special characteristics such as: + + `Preelaborable' + The unit is preelaborable in the Ada 95 sense. + + `No_Elab_Code' + No elaboration code has been produced by the compiler for + this unit. + + `Pure' + The unit is pure in the Ada 95 sense. + + `Elaborate_Body' + The unit contains a pragma Elaborate_Body. + + `Remote_Types' + The unit contains a pragma Remote_Types. + + `Shared_Passive' + The unit contains a pragma Shared_Passive. + + `Predefined' + This unit is part of the predefined environment and cannot be + modified by the user. + + `Remote_Call_Interface' + The unit contains a pragma Remote_Call_Interface. + +  + File: gnat_ug_wnt.info, Node: Examples of gnatls Usage, Prev: Switches for gnatls, Up: The GNAT Library Browser gnatls + + Example of `gnatls' Usage + ========================= + + Example of using the verbose switch. Note how the source and object + paths are affected by the -I switch. + + $ gnatls -v -I.. demo1.o + + GNATLS 3.10w (970212) Copyright 1999 Free Software Foundation, Inc. + + Source Search Path: + + ../ + /home/comar/local/adainclude/ + + Object Search Path: + + ../ + /home/comar/local/lib/gcc-lib/mips-sni-sysv4/2.7.2/adalib/ + + ./demo1.o + Unit => + Name => demo1 + Kind => subprogram body + Flags => No_Elab_Code + Source => demo1.adb modified + + The following is an example of use of the dependency list. Note the + use of the -s switch which gives a straight list of source files. This + can be useful for building specialized scripts. + + $ gnatls -d demo2.o + ./demo2.o demo2 OK demo2.adb + OK gen_list.ads + OK gen_list.adb + OK instr.ads + OK instr-child.ads + + $ gnatls -d -s -a demo1.o + demo1.adb + /home/comar/local/adainclude/ada.ads + /home/comar/local/adainclude/a-finali.ads + /home/comar/local/adainclude/a-filico.ads + /home/comar/local/adainclude/a-stream.ads + /home/comar/local/adainclude/a-tags.ads + gen_list.ads + gen_list.adb + /home/comar/local/adainclude/gnat.ads + /home/comar/local/adainclude/g-io.ads + instr.ads + /home/comar/local/adainclude/system.ads + /home/comar/local/adainclude/s-exctab.ads + /home/comar/local/adainclude/s-finimp.ads + /home/comar/local/adainclude/s-finroo.ads + /home/comar/local/adainclude/s-secsta.ads + /home/comar/local/adainclude/s-stalib.ads + /home/comar/local/adainclude/s-stoele.ads + /home/comar/local/adainclude/s-stratt.ads + /home/comar/local/adainclude/s-tasoli.ads + /home/comar/local/adainclude/s-unstyp.ads + /home/comar/local/adainclude/unchconv.ads + +  + File: gnat_ug_wnt.info, Node: GNAT and Libraries, Next: Using the GNU make Utility, Prev: The GNAT Library Browser gnatls, Up: Top + + GNAT and Libraries + ****************** + + This chapter addresses some of the issues related to building and using + a library with GNAT. It also shows how the GNAT run-time library can be + recompiled. + + * Menu: + + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + +  + File: gnat_ug_wnt.info, Node: Creating an Ada Library, Next: Installing an Ada Library, Up: GNAT and Libraries + + Creating an Ada Library + ======================= + + In the GNAT environment, a library has two components: + * Source files. + + * Compiled code and Ali files. See *Note The Ada Library Information + Files::. + + In order to use other packages *Note The GNAT Compilation Model:: + requires a certain number of sources to be available to the compiler. + The minimal set of sources required includes the specs of all the + packages that make up the visible part of the library as well as all + the sources upon which they depend. The bodies of all visible generic + units must also be provided. + + Although it is not strictly mandatory, it is recommended that all + sources needed to recompile the library be provided, so that the user + can make full use of inter-unit inlining and source-level debugging. + This can also make the situation easier for users that need to upgrade + their compilation toolchain and thus need to recompile the library from + sources. + + The compiled code can be provided in different ways. The simplest way is + to provide directly the set of objects produced by the compiler during + the compilation of the library. It is also possible to group the objects + into an archive using whatever commands are provided by the operating + system. Finally, it is also possible to create a shared library (see + option -shared in the GCC manual). + + There are various possibilities for compiling the units that make up the + library: for example with a Makefile *Note Using the GNU make Utility::, + or with a conventional script. For simple libraries, it is also + possible to create a dummy main program which depends upon all the + packages that comprise the interface of the library. This dummy main + program can then be given to gnatmake, in order to build all the + necessary objects. Here is an example of such a dummy program and the + generic commands used to build an archive or a shared library. + + with My_Lib.Service1; + with My_Lib.Service2; + with My_Lib.Service3; + procedure My_Lib_Dummy is + begin + null; + end; + + # compiling the library + $ gnatmake -c my_lib_dummy.adb + + # we don't need the dummy object itself + $ rm my_lib_dummy.o my_lib_dummy.ali + + # create an archive with the remaining objects + $ ar rc libmy_lib.a *.o + # some systems may require "ranlib" to be run as well + + # or create a shared library + $ gcc -shared -o libmy_lib.so *.o + # some systems may require the code to have been compiled with -fPIC + + When the objects are grouped in an archive or a shared library, the user + needs to specify the desired library at link time, unless a pragma + linker_options has been used in one of the sources: + pragma Linker_Options ("-lmy_lib"); + +  + File: gnat_ug_wnt.info, Node: Installing an Ada Library, Next: Using an Ada Library, Prev: Creating an Ada Library, Up: GNAT and Libraries + + Installing an Ada Library + ========================= + + In the GNAT model, installing a library consists in copying into a + specific location the files that make up this library. It is possible + to install the sources in a different directory from the other files + (ALI, objects, archives) since the source path and the object path can + easily be specified separately. + + For general purpose libraries, it is possible for the system + administrator to put those libraries in the default compiler paths. To + achieve this, he must specify their location in the configuration files + "ada_source_path" and "ada_object_path" that must be located in the GNAT + installation tree at the same place as the gcc spec file. The location + of the gcc spec file can be determined as follows: + $ gcc -v + + The configuration files mentioned above have simple format: each line + in them must contain one unique directory name. Those names are added + to the corresponding path in their order of appearance in the file. The + names can be either absolute or relative, in the latter case, they are + relative to where theses files are located. + + "ada_source_path" and "ada_object_path" might actually not be present + in a GNAT installation, in which case, GNAT will look for its run-time + library in the directories "adainclude" for the sources and "adalib" + for the objects and ALI files. When the files exist, the compiler does + not look in "adainclude" and "adalib" at all, and thus the + "ada_source_path" file must contain the location for the GNAT run-time + sources (which can simply be "adainclude"). In the same way, the + "ada_object_path" file must contain the location for the GNAT run-time + objects (which can simply be "adalib"). + + You can also specify a new default path to the runtime library at + compilation time with the switch "-RTS=RTS-PATH". You can easily choose + and change the runtime you want your program to be compiled with. This + switch is recognized by gcc, gnatmake, gnatbind, gnatls, gnatfind and + gnatxref. + + It is possible to install a library before or after the standard GNAT + library, by reordering the lines in the configuration files. In + general, a library must be installed before the GNAT library if it + redefines any part of it. + +  + File: gnat_ug_wnt.info, Node: Using an Ada Library, Next: Creating an Ada Library to be Used in a Non-Ada Context, Prev: Installing an Ada Library, Up: GNAT and Libraries + + Using an Ada Library + ==================== + + In order to use a Ada library, you need to make sure that this library + is on both your source and object path *Note Search Paths and the + Run-Time Library (RTL):: and *Note Search Paths for gnatbind::. For + instance, you can use the library "mylib" installed in "/dir/my_lib_src" + and "/dir/my_lib_obj" with the following commands: + + $ gnatmake -aI/dir/my_lib_src -aO/dir/my_lib_obj my_appl \ + -largs -lmy_lib + + This can be simplified down to the following: + $ gnatmake my_appl + when the following conditions are met: + * "/dir/my_lib_src" has been added by the user to the environment + variable "ADA_INCLUDE_PATH", or by the administrator to the file + "ada_source_path" + + * "/dir/my_lib_obj" has been added by the user to the environment + variable "ADA_OBJECTS_PATH", or by the administrator to the file + "ada_object_path" + + * a pragma linker_options, as mentioned in *Note Creating an Ada + Library:: as been added to the sources. + +  + File: gnat_ug_wnt.info, Node: Creating an Ada Library to be Used in a Non-Ada Context, Next: Rebuilding the GNAT Run-Time Library, Prev: Using an Ada Library, Up: GNAT and Libraries + + Creating an Ada Library to be Used in a Non-Ada Context + ======================================================= + + The previous sections detailed how to create and install a library that + was usable from an Ada main program. Using this library in a non-Ada + context is not possible, because the elaboration of the library is + automatically done as part of the main program elaboration. + + GNAT also provides the ability to build libraries that can be used + both in an Ada and non-Ada context. This section describes how to + build such a library, and then how to use it from a C program. The + method for interfacing with the library from other languages such as + Fortran for instance remains the same. + + Creating the Library + -------------------- + + * Identify the units representing the interface of the library. + + Here is an example of simple library interface: + + package Interface is + + procedure Do_Something; + + procedure Do_Something_Else; + + end Interface; + + * Use `pragma Export' or `pragma Convention' for the exported + entities. + + Our package `Interface' is then updated as follow: + package Interface is + + procedure Do_Something; + pragma Export (C, Do_Something, "do_something"); + + procedure Do_Something_Else; + pragma Export (C, Do_Something_Else, "do_something_else"); + + end Interface; + + * Compile all the units composing the library. + + * Bind the library objects. + + This step is performed by invoking gnatbind with the `-L' + switch. `gnatbind' will then generate the library elaboration + procedure (named `init') and the run-time finalization + procedure (named `final'). + + # generate the binder file in Ada + $ gnatbind -Lmylib interface + + # generate the binder file in C + $ gnatbind -C -Lmylib interface + + * Compile the files generated by the binder + + $ gcc -c b~interface.adb + + * Create the library; + + The procedure is identical to the procedure explained in *Note + Creating an Ada Library::, except that `b~interface.o' needs to be + added to the list of objects. + + # create an archive file + $ ar cr libmylib.a b~interface.o + + # create a shared library + $ gcc -shared -o libmylib.so b~interface.o + + * Provide a "foreign" view of the library interface; + + The example below shows the content of `mylib_interface.h' (note + that there is no rule for the naming of this file, any name can be + used) + /* the library elaboration procedure */ + extern void mylibinit (void); + + /* the library finalization procedure */ + extern void mylibfinal (void); + + /* the interface exported by the library */ + extern void do_something (void); + extern void do_something_else (void); + + Using the Library + ----------------- + + Libraries built as explained above can be used from any program, + provided that the elaboration procedures (named `mylibinit' in the + previous example) are called before the library services are used. Any + number of libraries can be used simultaneously, as long as the + elaboration procedure of each library is called. + + Below is an example of C program that uses our `mylib' library. + + #include "mylib_interface.h" + + int + main (void) + { + /* First, elaborate the library before using it */ + mylibinit (); + + /* Main program, using the library exported entities */ + do_something (); + do_something_else (); + + /* Library finalization at the end of the program */ + mylibfinal (); + return 0; + } + + Note that this same library can be used from an equivalent Ada main + program. In addition, if the libraries are installed as detailed in + *Note Installing an Ada Library::, it is not necessary to invoke the + library elaboration and finalization routines. The binder will ensure + that this is done as part of the main program elaboration and + finalization phases. + + The Finalization Phase + ---------------------- + + Invoking any library finalization procedure generated by `gnatbind' + shuts down the Ada run time permanently. Consequently, the finalization + of all Ada libraries must be performed at the end of the program. No + call to these libraries nor the Ada run time should be made past the + finalization phase. + + Restrictions in Libraries + ------------------------- + + The pragmas listed below should be used with caution inside libraries, + as they can create incompatibilities with other Ada libraries: + * pragma `Locking_Policy' + + * pragma `Queuing_Policy' + + * pragma `Task_Dispatching_Policy' + + * pragma `Unreserve_All_Interrupts' + When using a library that contains such pragmas, the user must make + sure that all libraries use the same pragmas with the same values. + Otherwise, a `Program_Error' will be raised during the elaboration of + the conflicting libraries. The usage of these pragmas and its + consequences for the user should therefore be well documented. + + Similarly, the traceback in exception occurrences mechanism should be + enabled or disabled in a consistent manner across all libraries. + Otherwise, a Program_Error will be raised during the elaboration of the + conflicting libraries. + + If the `'Version' and `'Body_Version' attributes are used inside a + library, then it is necessary to perform a `gnatbind' step that + mentions all ali files in all libraries, so that version identifiers + can be properly computed. In practice these attributes are rarely + used, so this is unlikely to be a consideration. + +  + File: gnat_ug_wnt.info, Node: Rebuilding the GNAT Run-Time Library, Prev: Creating an Ada Library to be Used in a Non-Ada Context, Up: GNAT and Libraries + + Rebuilding the GNAT Run-Time Library + ==================================== + + It may be useful to recompile the GNAT library in various contexts, the + most important one being the use of partition-wide configuration pragmas + such as Normalize_Scalar. A special Makefile called `Makefile.adalib' + is provided to that effect and can be found in the directory containing + the GNAT library. The location of this directory depends on the way the + GNAT environment has been installed and can be determined by means of + the command: + + $ gnatls -v + + The last entry in the object search path usually contains the gnat + library. This Makefile contains its own documentation and in particular + the set of instructions needed to rebuild a new library and to use it. + +  + File: gnat_ug_wnt.info, Node: Using the GNU make Utility, Next: Finding Memory Problems with gnatmem, Prev: GNAT and Libraries, Up: Top + + Using the GNU `make' Utility + **************************** + + This chapter offers some examples of makefiles that solve specific + problems. It does not explain how to write a makefile (see the GNU make + documentation), nor does it try to replace the `gnatmake' utility + (*note The GNAT Make Program gnatmake::). + + All the examples in this section are specific to the GNU version of + make. Although `make' is a standard utility, and the basic language is + the same, these examples use some advanced features found only in `GNU + make'. + + * Menu: + + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + +  + File: gnat_ug_wnt.info, Node: Using gnatmake in a Makefile, Next: Automatically Creating a List of Directories, Up: Using the GNU make Utility + + Using gnatmake in a Makefile + ============================ + + Complex project organizations can be handled in a very powerful way by + using GNU make combined with gnatmake. For instance, here is a Makefile + which allows you to build each subsystem of a big project into a + separate shared library. Such a makefile allows you to significantly + reduce the link time of very big applications while maintaining full + coherence at each step of the build process. + + The list of dependencies are handled automatically by `gnatmake'. + The Makefile is simply used to call gnatmake in each of the appropriate + directories. + + Note that you should also read the example on how to automatically + create the list of directories (*note Automatically Creating a List of + Directories::) which might help you in case your project has a lot of + subdirectories. + + ## This Makefile is intended to be used with the following directory + ## configuration: + ## - The sources are split into a series of csc (computer software components) + ## Each of these csc is put in its own directory. + ## Their name are referenced by the directory names. + ## They will be compiled into shared library (although this would also work + ## with static libraries + ## - The main program (and possibly other packages that do not belong to any + ## csc is put in the top level directory (where the Makefile is). + ## toplevel_dir __ first_csc (sources) __ lib (will contain the library) + ## \_ second_csc (sources) __ lib (will contain the library) + ## \_ ... + ## Although this Makefile is build for shared library, it is easy to modify + ## to build partial link objects instead (modify the lines with -shared and + ## gnatlink below) + ## + ## With this makefile, you can change any file in the system or add any new + ## file, and everything will be recompiled correctly (only the relevant shared + ## objects will be recompiled, and the main program will be re-linked). + + # The list of computer software component for your project. This might be + # generated automatically. + CSC_LIST=aa bb cc + + # Name of the main program (no extension) + MAIN=main + + # If we need to build objects with -fPIC, uncomment the following line + #NEED_FPIC=-fPIC + + # The following variable should give the directory containing libgnat.so + # You can get this directory through 'gnatls -v'. This is usually the last + # directory in the Object_Path. + GLIB=... + + # The directories for the libraries + # (This macro expands the list of CSC to the list of shared libraries, you + # could simply use the expanded form : + # LIB_DIR=aa/lib/libaa.so bb/lib/libbb.so cc/lib/libcc.so + LIB_DIR=${foreach dir,${CSC_LIST},${dir}/lib/lib${dir}.so} + + ${MAIN}: objects ${LIB_DIR} + gnatbind ${MAIN} ${CSC_LIST:%=-aO%/lib} -shared + gnatlink ${MAIN} ${CSC_LIST:%=-l%} + + objects:: + # recompile the sources + gnatmake -c -i ${MAIN}.adb ${NEED_FPIC} ${CSC_LIST:%=-I%} + + # Note: In a future version of GNAT, the following commands will be simplified + # by a new tool, gnatmlib + ${LIB_DIR}: + mkdir -p ${dir $@ } + cd ${dir $@ }; gcc -shared -o ${notdir $@ } ../*.o -L${GLIB} -lgnat + cd ${dir $@ }; cp -f ../*.ali . + + # The dependencies for the modules + # Note that we have to force the expansion of *.o, since in some cases make won't + # be able to do it itself. + aa/lib/libaa.so: ${wildcard aa/*.o} + bb/lib/libbb.so: ${wildcard bb/*.o} + cc/lib/libcc.so: ${wildcard cc/*.o} + + # Make sure all of the shared libraries are in the path before starting the + # program + run:: + LD_LIBRARY_PATH=`pwd`/aa/lib:`pwd`/bb/lib:`pwd`/cc/lib ./${MAIN} + + clean:: + ${RM} -rf ${CSC_LIST:%=%/lib} + ${RM} ${CSC_LIST:%=%/*.ali} + ${RM} ${CSC_LIST:%=%/*.o} + ${RM} *.o *.ali ${MAIN} + +  + File: gnat_ug_wnt.info, Node: Automatically Creating a List of Directories, Next: Generating the Command Line Switches, Prev: Using gnatmake in a Makefile, Up: Using the GNU make Utility + + Automatically Creating a List of Directories + ============================================ + + In most makefiles, you will have to specify a list of directories, and + store it in a variable. For small projects, it is often easier to + specify each of them by hand, since you then have full control over what + is the proper order for these directories, which ones should be + included... + + However, in larger projects, which might involve hundreds of + subdirectories, it might be more convenient to generate this list + automatically. + + The example below presents two methods. The first one, although less + general, gives you more control over the list. It involves wildcard + characters, that are automatically expanded by `make'. Its shortcoming + is that you need to explicitly specify some of the organization of your + project, such as for instance the directory tree depth, whether some + directories are found in a separate tree,... + + The second method is the most general one. It requires an external + program, called `find', which is standard on all Unix systems. All the + directories found under a given root directory will be added to the + list. + + # The examples below are based on the following directory hierarchy: + # All the directories can contain any number of files + # ROOT_DIRECTORY -> a -> aa -> aaa + # -> ab + # -> ac + # -> b -> ba -> baa + # -> bb + # -> bc + # This Makefile creates a variable called DIRS, that can be reused any time + # you need this list (see the other examples in this section) + + # The root of your project's directory hierarchy + ROOT_DIRECTORY=. + + #### + # First method: specify explicitly the list of directories + # This allows you to specify any subset of all the directories you need. + #### + + DIRS := a/aa/ a/ab/ b/ba/ + + #### + # Second method: use wildcards + # Note that the argument(s) to wildcard below should end with a '/'. + # Since wildcards also return file names, we have to filter them out + # to avoid duplicate directory names. + # We thus use make's `dir' and `sort' functions. + # It sets DIRs to the following value (note that the directories aaa and baa + # are not given, unless you change the arguments to wildcard). + # DIRS= ./a/a/ ./b/ ./a/aa/ ./a/ab/ ./a/ac/ ./b/ba/ ./b/bb/ ./b/bc/ + #### + + DIRS := ${sort ${dir ${wildcard ${ROOT_DIRECTORY}/*/ ${ROOT_DIRECTORY}/*/*/}}} + + #### + # Third method: use an external program + # This command is much faster if run on local disks, avoiding NFS slowdowns. + # This is the most complete command: it sets DIRs to the following value: + # DIRS= ./a ./a/aa ./a/aa/aaa ./a/ab ./a/ac ./b ./b/ba ./b/ba/baa ./b/bb ./b/bc + #### + + DIRS := ${shell find ${ROOT_DIRECTORY} -type d -print} + +  + File: gnat_ug_wnt.info, Node: Generating the Command Line Switches, Next: Overcoming Command Line Length Limits, Prev: Automatically Creating a List of Directories, Up: Using the GNU make Utility + + Generating the Command Line Switches + ==================================== + + Once you have created the list of directories as explained in the + previous section (*note Automatically Creating a List of Directories::), + you can easily generate the command line arguments to pass to gnatmake. + + For the sake of completeness, this example assumes that the source + path is not the same as the object path, and that you have two separate + lists of directories. + + # see "Automatically creating a list of directories" to create + # these variables + SOURCE_DIRS= + OBJECT_DIRS= + + GNATMAKE_SWITCHES := ${patsubst %,-aI%,${SOURCE_DIRS}} + GNATMAKE_SWITCHES += ${patsubst %,-aO%,${OBJECT_DIRS}} + + all: + gnatmake ${GNATMAKE_SWITCHES} main_unit + +  + File: gnat_ug_wnt.info, Node: Overcoming Command Line Length Limits, Prev: Generating the Command Line Switches, Up: Using the GNU make Utility + + Overcoming Command Line Length Limits + ===================================== + + One problem that might be encountered on big projects is that many + operating systems limit the length of the command line. It is thus hard + to give gnatmake the list of source and object directories. + + This example shows how you can set up environment variables, which + will make `gnatmake' behave exactly as if the directories had been + specified on the command line, but have a much higher length limit (or + even none on most systems). + + It assumes that you have created a list of directories in your + Makefile, using one of the methods presented in *Note Automatically + Creating a List of Directories::. For the sake of completeness, we + assume that the object path (where the ALI files are found) is + different from the sources patch. + + Note a small trick in the Makefile below: for efficiency reasons, we + create two temporary variables (SOURCE_LIST and OBJECT_LIST), that are + expanded immediately by `make'. This way we overcome the standard make + behavior which is to expand the variables only when they are actually + used. + + # In this example, we create both ADA_INCLUDE_PATH and ADA_OBJECT_PATH. + # This is the same thing as putting the -I arguments on the command line. + # (the equivalent of using -aI on the command line would be to define + # only ADA_INCLUDE_PATH, the equivalent of -aO is ADA_OBJECT_PATH). + # You can of course have different values for these variables. + # + # Note also that we need to keep the previous values of these variables, since + # they might have been set before running 'make' to specify where the GNAT + # library is installed. + + # see "Automatically creating a list of directories" to create these + # variables + SOURCE_DIRS= + OBJECT_DIRS= + + empty:= + space:=${empty} ${empty} + SOURCE_LIST := ${subst ${space},:,${SOURCE_DIRS}} + OBJECT_LIST := ${subst ${space},:,${OBJECT_DIRS}} + ADA_INCLUDE_PATH += ${SOURCE_LIST} + ADA_OBJECT_PATH += ${OBJECT_LIST} + export ADA_INCLUDE_PATH + export ADA_OBJECT_PATH + + all: + gnatmake main_unit + +  + File: gnat_ug_wnt.info, Node: Finding Memory Problems with gnatmem, Next: Finding Memory Problems with GNAT Debug Pool, Prev: Using the GNU make Utility, Up: Top + + Finding Memory Problems with `gnatmem' + ************************************** + + `gnatmem', is a tool that monitors dynamic allocation and deallocation + activity in a program, and displays information about incorrect + deallocations and possible sources of memory leaks. Gnatmem provides + three type of information: + * General information concerning memory management, such as the total + number of allocations and deallocations, the amount of allocated + memory and the high water mark, i.e. the largest amount of + allocated memory in the course of program execution. + + * Backtraces for all incorrect deallocations, that is to say + deallocations which do not correspond to a valid allocation. + + * Information on each allocation that is potentially the origin of a + memory leak. + + The `gnatmem' command has two modes. It can be used with `gdb' or + with instrumented allocation and deallocation routines. The later mode + is called the `GMEM' mode. Both modes produce the very same output. + + * Menu: + + * Running gnatmem (GDB Mode):: + * Running gnatmem (GMEM Mode):: + * Switches for gnatmem:: + * Examples of gnatmem Usage:: + * GDB and GMEM Modes:: + * Implementation Note:: + +  + File: gnat_ug_wnt.info, Node: Running gnatmem (GDB Mode), Next: Running gnatmem (GMEM Mode), Up: Finding Memory Problems with gnatmem + + Running `gnatmem' (GDB Mode) + ============================ + + The `gnatmem' command has the form + + $ gnatmem [-q] [n] [-o file] user_program [program_arg]* + or + $ gnatmem [-q] [n] -i file + + Gnatmem must be supplied with the executable to examine, followed by its + run-time inputs. For example, if a program is executed with the command: + $ my_program arg1 arg2 + then it can be run under `gnatmem' control using the command: + $ gnatmem my_program arg1 arg2 + + The program is transparently executed under the control of the + debugger *Note The GNAT Debugger GDB::. This does not affect the + behavior of the program, except for sensitive real-time programs. When + the program has completed execution, `gnatmem' outputs a report + containing general allocation/deallocation information and potential + memory leak. For better results, the user program should be compiled + with debugging options *Note Switches for gcc::. + + Here is a simple example of use: + + *************** debut cc + $ gnatmem test_gm + + Global information + ------------------ + Total number of allocations : 45 + Total number of deallocations : 6 + Final Water Mark (non freed mem) : 11.29 Kilobytes + High Water Mark : 11.40 Kilobytes + + . + . + . + Allocation Root # 2 + ------------------- + Number of non freed allocations : 11 + Final Water Mark (non freed mem) : 1.16 Kilobytes + High Water Mark : 1.27 Kilobytes + Backtrace : + test_gm.adb:23 test_gm.alloc + . + . + . + + The first block of output give general information. In this case, the + Ada construct "new" was executed 45 times, and only 6 calls to an + unchecked deallocation routine occurred. + + Subsequent paragraphs display information on all allocation roots. + An allocation root is a specific point in the execution of the program + that generates some dynamic allocation, such as a "new" construct. This + root is represented by an execution backtrace (or subprogram call + stack). By default the backtrace depth for allocations roots is 1, so + that a root corresponds exactly to a source location. The backtrace can + be made deeper, to make the root more specific. + +  + File: gnat_ug_wnt.info, Node: Running gnatmem (GMEM Mode), Next: Switches for gnatmem, Prev: Running gnatmem (GDB Mode), Up: Finding Memory Problems with gnatmem + + Running `gnatmem' (GMEM Mode) + ============================= + + The `gnatmem' command has the form + + $ gnatmem [-q] [n] -i gmem.out user_program [program_arg]* + + The program must have been linked with the instrumented version of + the allocation and deallocation routines. This is done with linking + with the `libgmem.a' library. For better results, the user program + should be compiled with debugging options *Note Switches for gcc::. For + example to build `my_program': + + $ gnatmake -g my_program -largs -lgmem + + When running `my_program' the file `gmem.out' is produced. This file + contains information about all allocations and deallocations done by the + program. It is produced by the instrumented allocations and + deallocations routines and will be used by `gnatmem'. + + Gnatmem must be supplied with the `gmem.out' file and the executable to + examine followed by its run-time inputs. For example, if a program is + executed with the command: + $ my_program arg1 arg2 + then `gmem.out' can be analysed by `gnatmem' using the command: + $ gnatmem -i gmem.out my_program arg1 arg2 + +  + File: gnat_ug_wnt.info, Node: Switches for gnatmem, Next: Examples of gnatmem Usage, Prev: Running gnatmem (GMEM Mode), Up: Finding Memory Problems with gnatmem + + Switches for `gnatmem' + ====================== + + `gnatmem' recognizes the following switches: + + ``-q'' + Quiet. Gives the minimum output needed to identify the origin of + the memory leaks. Omit statistical information. + + ``n'' + N is an integer literal (usually between 1 and 10) which controls + the depth of the backtraces defining allocation root. The default + value for N is 1. The deeper the backtrace, the more precise the + localization of the root. Note that the total number of roots can + depend on this parameter. + + ``-o file'' + Direct the gdb output to the specified file. The `gdb' script used + to generate this output is also saved in the file `gnatmem.tmp'. + + ``-i file'' + Do the `gnatmem' processing starting from `file' which has been + generated by a previous call to `gnatmem' with the -o switch or + `gmem.out' produced by `GMEM' mode. This is useful for post mortem + processing. + +  + File: gnat_ug_wnt.info, Node: Examples of gnatmem Usage, Next: GDB and GMEM Modes, Prev: Switches for gnatmem, Up: Finding Memory Problems with gnatmem + + Example of `gnatmem' Usage + ========================== + + This section is based on the `GDB' mode of `gnatmem'. The same results + can be achieved using `GMEM' mode. See section *Note Running gnatmem + (GMEM Mode)::. + + The first example shows the use of `gnatmem' on a simple leaking + program. Suppose that we have the following Ada program: + + with Unchecked_Deallocation; + procedure Test_Gm is + + type T is array (1..1000) of Integer; + type Ptr is access T; + procedure Free is new Unchecked_Deallocation (T, Ptr); + A : Ptr; + + procedure My_Alloc is + begin + A := new T; + end My_Alloc; + + procedure My_DeAlloc is + B : Ptr := A; + begin + Free (B); + end My_DeAlloc; + + begin + My_Alloc; + for I in 1 .. 5 loop + for J in I .. 5 loop + My_Alloc; + end loop; + My_Dealloc; + end loop; + end; + + The program needs to be compiled with debugging option: + + $ gnatmake -g test_gm + + `gnatmem' is invoked simply with + $ gnatmem test_gm + + which produces the following output: + + Global information + ------------------ + Total number of allocations : 18 + Total number of deallocations : 5 + Final Water Mark (non freed mem) : 53.00 Kilobytes + High Water Mark : 56.90 Kilobytes + + Allocation Root # 1 + ------------------- + Number of non freed allocations : 11 + Final Water Mark (non freed mem) : 42.97 Kilobytes + High Water Mark : 46.88 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + + Allocation Root # 2 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 10.02 Kilobytes + High Water Mark : 10.02 Kilobytes + Backtrace : + s-secsta.adb:81 system.secondary_stack.ss_init + + Allocation Root # 3 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 12 Bytes + High Water Mark : 12 Bytes + Backtrace : + s-secsta.adb:181 system.secondary_stack.ss_init + + Note that the GNAT run time contains itself a certain number of + allocations that have no corresponding deallocation, as shown here for + root #2 and root #1. This is a normal behavior when the number of non + freed allocations is one, it locates dynamic data structures that the + run time needs for the complete lifetime of the program. Note also that + there is only one allocation root in the user program with a single + line back trace: test_gm.adb:11 test_gm.my_alloc, whereas a careful + analysis of the program shows that 'My_Alloc' is called at 2 different + points in the source (line 21 and line 24). If those two allocation + roots need to be distinguished, the backtrace depth parameter can be + used: + + $ gnatmem 3 test_gm + + which will give the following output: + + Global information + ------------------ + Total number of allocations : 18 + Total number of deallocations : 5 + Final Water Mark (non freed mem) : 53.00 Kilobytes + High Water Mark : 56.90 Kilobytes + + Allocation Root # 1 + ------------------- + Number of non freed allocations : 10 + Final Water Mark (non freed mem) : 39.06 Kilobytes + High Water Mark : 42.97 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + test_gm.adb:24 test_gm + b_test_gm.c:52 main + + Allocation Root # 2 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 10.02 Kilobytes + High Water Mark : 10.02 Kilobytes + Backtrace : + s-secsta.adb:81 system.secondary_stack.ss_init + s-secsta.adb:283 + b_test_gm.c:33 adainit + + Allocation Root # 3 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 3.91 Kilobytes + High Water Mark : 3.91 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + test_gm.adb:21 test_gm + b_test_gm.c:52 main + + Allocation Root # 4 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 12 Bytes + High Water Mark : 12 Bytes + Backtrace : + s-secsta.adb:181 system.secondary_stack.ss_init + s-secsta.adb:283 + b_test_gm.c:33 adainit + + The allocation root #1 of the first example has been split in 2 roots #1 + and #3 thanks to the more precise associated backtrace. + +  + File: gnat_ug_wnt.info, Node: GDB and GMEM Modes, Next: Implementation Note, Prev: Examples of gnatmem Usage, Up: Finding Memory Problems with gnatmem + + GDB and GMEM Modes + ================== + + The main advantage of the `GMEM' mode is that it is a lot faster than + the `GDB' mode where the application must be monitored by a `GDB' + script. But the `GMEM' mode is available only for DEC Unix, Linux x86, + Solaris (sparc and x86) and Windows 95/98/NT/2000 (x86). + + The main advantage of the `GDB' mode is that it is available on all + supported platforms. But it can be very slow if the application does a + lot of allocations and deallocations. + +  + File: gnat_ug_wnt.info, Node: Implementation Note, Prev: GDB and GMEM Modes, Up: Finding Memory Problems with gnatmem + + Implementation Note + =================== + + * Menu: + + * gnatmem Using GDB Mode:: + * gnatmem Using GMEM Mode:: + +  + File: gnat_ug_wnt.info, Node: gnatmem Using GDB Mode, Next: gnatmem Using GMEM Mode, Up: Implementation Note + + `gnatmem' Using `GDB' Mode + -------------------------- + + `gnatmem' executes the user program under the control of `GDB' using a + script that sets breakpoints and gathers information on each dynamic + allocation and deallocation. The output of the script is then analyzed + by `gnatmem' in order to locate memory leaks and their origin in the + program. Gnatmem works by recording each address returned by the + allocation procedure (`__gnat_malloc') along with the backtrace at the + allocation point. On each deallocation, the deallocated address is + matched with the corresponding allocation. At the end of the processing, + the unmatched allocations are considered potential leaks. All the + allocations associated with the same backtrace are grouped together and + form an allocation root. The allocation roots are then sorted so that + those with the biggest number of unmatched allocation are printed + first. A delicate aspect of this technique is to distinguish between the + data produced by the user program and the data produced by the gdb + script. Currently, on systems that allow probing the terminal, the gdb + command "tty" is used to force the program output to be redirected to + the current terminal while the `gdb' output is directed to a file or to + a pipe in order to be processed subsequently by `gnatmem'. + +  + File: gnat_ug_wnt.info, Node: gnatmem Using GMEM Mode, Prev: gnatmem Using GDB Mode, Up: Implementation Note + + `gnatmem' Using `GMEM' Mode + --------------------------- + + This mode use the same algorithm to detect memory leak as the `GDB' + mode of `gnatmem', the only difference is in the way data are gathered. + In `GMEM' mode the program is linked with instrumented version of + `__gnat_malloc' and `__gnat_free' routines. Information needed to find + memory leak are recorded by these routines in file `gmem.out'. This + mode also require that the stack traceback be available, this is only + implemented on some platforms *Note GDB and GMEM Modes::. + +  + File: gnat_ug_wnt.info, Node: Finding Memory Problems with GNAT Debug Pool, Next: Creating Sample Bodies Using gnatstub, Prev: Finding Memory Problems with gnatmem, Up: Top + + Finding Memory Problems with GNAT Debug Pool + ******************************************** + + The use of unchecked deallocation and unchecked conversion can easily + lead to incorrect memory references. The problems generated by such + references are usually difficult to tackle because the symptoms can be + very remote from the origin of the problem. In such cases, it is very + helpful to detect the problem as early as possible. This is the purpose + of the Storage Pool provided by `GNAT.Debug_Pools'. + + In order to use the GNAT specific debugging pool, the user must + associate a debug pool object with each of the access types that may be + related to suspected memory problems. See Ada Reference Manual 13.11. + type Ptr is access Some_Type; + Pool : GNAT.Debug_Pools.Debug_Pool; + for Ptr'Storage_Pool use Pool; + + `GNAT.Debug_Pools' is derived from of a GNAT-specific kind of pool: + the Checked_Pool. Such pools, like standard Ada storage pools, allow + the user to redefine allocation and deallocation strategies. They also + provide a checkpoint for each dereference, through the use of the + primitive operation `Dereference' which is implicitly called at each + dereference of an access value. + + Once an access type has been associated with a debug pool, + operations on values of the type may raise four distinct exceptions, + which correspond to four potential kinds of memory corruption: + * `GNAT.Debug_Pools.Accessing_Not_Allocated_Storage' + + * `GNAT.Debug_Pools.Accessing_Deallocated_Storage' + + * `GNAT.Debug_Pools.Freeing_Not_Allocated_Storage' + + * `GNAT.Debug_Pools.Freeing_Deallocated_Storage ' + + For types associated with a Debug_Pool, dynamic allocation is performed + using the standard GNAT allocation routine. References to all allocated + chunks of memory are kept in an internal dictionary. The deallocation + strategy consists in not releasing the memory to the underlying system + but rather to fill it with a memory pattern easily recognizable during + debugging sessions: The memory pattern is the old IBM hexadecimal + convention: 16#DEADBEEF#. Upon each dereference, a check is made that + the access value denotes a properly allocated memory location. Here is + a complete example of use of `Debug_Pools', that includes typical + instances of memory corruption: + with Gnat.Io; use Gnat.Io; + with Unchecked_Deallocation; + with Unchecked_Conversion; + with GNAT.Debug_Pools; + with System.Storage_Elements; + with Ada.Exceptions; use Ada.Exceptions; + procedure Debug_Pool_Test is + + type T is access Integer; + type U is access all T; + + P : GNAT.Debug_Pools.Debug_Pool; + for T'Storage_Pool use P; + + procedure Free is new Unchecked_Deallocation (Integer, T); + function UC is new Unchecked_Conversion (U, T); + A, B : aliased T; + + procedure Info is new GNAT.Debug_Pools.Print_Info(Put_Line); + + begin + Info (P); + A := new Integer; + B := new Integer; + B := A; + Info (P); + Free (A); + begin + Put_Line (Integer'Image(B.all)); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + begin + Free (B); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + B := UC(A'Access); + begin + Put_Line (Integer'Image(B.all)); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + begin + Free (B); + exception + when E : others => Put_Line ("raised: " & Exception_Name (E)); + end; + Info (P); + end Debug_Pool_Test; + + The debug pool mechanism provides the following precise diagnostics on + the execution of this erroneous program: + Debug Pool info: + Total allocated bytes : 0 + Total deallocated bytes : 0 + Current Water Mark: 0 + High Water Mark: 0 + + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 0 + Current Water Mark: 8 + High Water Mark: 8 + + raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 4 + Current Water Mark: 4 + High Water Mark: 8 + +  + File: gnat_ug_wnt.info, Node: Creating Sample Bodies Using gnatstub, Next: Reducing the Size of Ada Executables with gnatelim, Prev: Finding Memory Problems with GNAT Debug Pool, Up: Top + + Creating Sample Bodies Using `gnatstub' + *************************************** + + `gnatstub' creates body stubs, that is, empty but compilable bodies for + library unit declarations. + + To create a body stub, `gnatstub' has to compile the library unit + declaration. Therefore, bodies can be created only for legal library + units. Moreover, if a library unit depends semantically upon units + located outside the current directory, you have to provide the source + search path when calling `gnatstub', see the description of `gnatstub' + switches below. + + * Menu: + + * Running gnatstub:: + * Switches for gnatstub:: + +  + File: gnat_ug_wnt.info, Node: Running gnatstub, Next: Switches for gnatstub, Up: Creating Sample Bodies Using gnatstub + + Running `gnatstub' + ================== + + `gnatstub' has the command-line interface of the form + + $ gnatstub [switches] filename [directory] + + where + `filename' + is the name of the source file that contains a library unit + declaration for which a body must be created. This name should + follow the GNAT file name conventions. No crunching is allowed for + this file name. The file name may contain the path information. + + `directory' + indicates the directory to place a body stub (default is the + current directory) + + `switches' + is an optional sequence of switches as described in the next + section + +  + File: gnat_ug_wnt.info, Node: Switches for gnatstub, Prev: Running gnatstub, Up: Creating Sample Bodies Using gnatstub + + Switches for `gnatstub' + ======================= + + `-f' + If the destination directory already contains a file with a name + of the body file for the argument spec file, replace it with the + generated body stub. + + `-hs' + Put the comment header (i.e. all the comments preceding the + compilation unit) from the source of the library unit declaration + into the body stub. + + `-hg' + Put a sample comment header into the body stub. + + `-IDIR' + `-I-' + These switches have the same meaning as in calls to gcc. They + define the source search path in the call to gcc issued by + `gnatstub' to compile an argument source file. + + `-iN' + (N is a decimal natural number). Set the indentation level in the + generated body sample to n, '-i0' means "no indentation", the + default indentation is 3. + + `-k' + Do not remove the tree file (i.e. the snapshot of the compiler + internal structures used by `gnatstub') after creating the body + stub. + + `-lN' + (N is a decimal positive number) Set the maximum line length in the + body stub to n, the default is 78. + + `-q' + Quiet mode: do not generate a confirmation when a body is + successfully created or a message when a body is not required for + an argument unit. + + `-r' + Reuse the tree file (if it exists) instead of creating it: instead + of creating the tree file for the library unit declaration, + gnatstub tries to find it in the current directory and use it for + creating a body. If the tree file is not found, no body is + created. `-r' also implies `-k', whether or not `-k' is set + explicitly. + + `-t' + Overwrite the existing tree file: if the current directory already + contains the file which, according to the GNAT file name rules + should be considered as a tree file for the argument source file, + gnatstub will refuse to create the tree file needed to create a + body sampler, unless `-t' option is set + + `-v' + Verbose mode: generate version information. + +  + File: gnat_ug_wnt.info, Node: Reducing the Size of Ada Executables with gnatelim, Next: Other Utility Programs, Prev: Creating Sample Bodies Using gnatstub, Up: Top + + Reducing the Size of Ada Executables with `gnatelim' + **************************************************** + + * Menu: + + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + +  + File: gnat_ug_wnt.info, Node: About gnatelim, Next: Eliminate Pragma, Up: Reducing the Size of Ada Executables with gnatelim + + About `gnatelim' + ================ + + When a program shares a set of Ada packages with other programs, it may + happen that this program uses only a fraction of the subprograms + defined in these packages. The code created for these unused + subprograms increases the size of the executable. + + `gnatelim' tracks unused subprograms in an Ada program and outputs a + list of GNAT-specific `Eliminate' pragmas (see next section) marking + all the subprograms that are declared but never called. By placing the + list of `Eliminate' pragmas in the GNAT configuration file `gnat.adc' + and recompiling your program, you may decrease the size of its + executable, because the compiler will not generate the code for + 'eliminated' subprograms. + + `gnatelim' needs as its input data a set of tree files (see *Note + Tree Files::) representing all the components of a program to process + and a bind file for a main subprogram (see *Note Preparing Tree and + Bind Files for gnatelim::). + +  + File: gnat_ug_wnt.info, Node: Eliminate Pragma, Next: Tree Files, Prev: About gnatelim, Up: Reducing the Size of Ada Executables with gnatelim + + `Eliminate' Pragma + ================== + + The simplified syntax of the Eliminate pragma used by `gnatelim' is: + + pragma Eliminate (Library_Unit_Name, Subprogram_Name); + + where + `Library_Unit_Name' + full expanded Ada name of a library unit + + `Subprogram_Name' + a simple or expanded name of a subprogram declared within this + compilation unit + + The effect of an `Eliminate' pragma placed in the GNAT configuration + file `gnat.adc' is: + + * If the subprogram `Subprogram_Name' is declared within the library + unit `Library_Unit_Name', the compiler will not generate code for + this subprogram. This applies to all overloaded subprograms denoted + by `Subprogram_Name'. + + * If a subprogram marked by the pragma `Eliminate' is used (called) + in a program, the compiler will produce an error message in the + place where it is called. + +  + File: gnat_ug_wnt.info, Node: Tree Files, Next: Preparing Tree and Bind Files for gnatelim, Prev: Eliminate Pragma, Up: Reducing the Size of Ada Executables with gnatelim + + Tree Files + ========== + + A tree file stores a snapshot of the compiler internal data structures + at the very end of a successful compilation. It contains all the + syntactic and semantic information for the compiled unit and all the + units upon which it depends semantically. To use tools that make use + of tree files, you need to first produce the right set of tree files. + + GNAT produces correct tree files when -gnatt -gnatc options are set + in a gcc call. The tree files have an .adt extension. Therefore, to + produce a tree file for the compilation unit contained in a file named + `foo.adb', you must use the command + + $ gcc -c -gnatc -gnatt foo.adb + + and you will get the tree file `foo.adt'. compilation. + +  + File: gnat_ug_wnt.info, Node: Preparing Tree and Bind Files for gnatelim, Next: Running gnatelim, Prev: Tree Files, Up: Reducing the Size of Ada Executables with gnatelim + + Preparing Tree and Bind Files for `gnatelim' + ============================================ + + A set of tree files covering the program to be analyzed with `gnatelim' + and the bind file for the main subprogram does not have to be in the + current directory. '-T' gnatelim option may be used to provide the + search path for tree files, and '-b' option may be used to point to the + bind file to process (see *Note Running gnatelim::) + + If you do not have the appropriate set of tree files and the right + bind file, you may create them in the current directory using the + following procedure. + + Let `Main_Prog' be the name of a main subprogram, and suppose this + subprogram is in a file named `main_prog.adb'. + + To create a bind file for `gnatelim', run `gnatbind' for the main + subprogram. `gnatelim' can work with both Ada and C bind files; when + both are present, it uses the Ada bind file. The following commands + will build the program and create the bind file: + + $ gnatmake -c Main_Prog + $ gnatbind main_prog + + To create a minimal set of tree files covering the whole program, call + `gnatmake' for this program as follows: + + $ gnatmake -f -c -gnatc -gnatt Main_Prog + + The `-c' gnatmake option turns off the bind and link steps, that are + useless anyway because the sources are compiled with `-gnatc' option + which turns off code generation. + + The `-f' gnatmake option forces recompilation of all the needed + sources. + + This sequence of actions will create all the data needed by + `gnatelim' from scratch and therefore guarantee its consistency. If you + would like to use some existing set of files as `gnatelim' output, you + must make sure that the set of files is complete and consistent. You + can use the `-m' switch to check if there are missed tree files + + Note, that `gnatelim' needs neither object nor ALI files. + +  + File: gnat_ug_wnt.info, Node: Running gnatelim, Next: Correcting the List of Eliminate Pragmas, Prev: Preparing Tree and Bind Files for gnatelim, Up: Reducing the Size of Ada Executables with gnatelim + + Running `gnatelim' + ================== + + `gnatelim' has the following command-line interface: + + $ gnatelim [options] name + + `name' should be a full expanded Ada name of a main subprogram of a + program (partition). + + `gnatelim' options: + + `-q' + Quiet mode: by default `gnatelim' generates to the standard error + stream a trace of the source file names of the compilation units + being processed. This option turns this trace off. + + `-v' + Verbose mode: `gnatelim' version information is printed as Ada + comments to the standard output stream. + + `-a' + Also look for subprograms from the GNAT run time that can be + eliminated. + + `-m' + Check if any tree files are missing for an accurate result. + + `-TDIR' + When looking for tree files also look in directory DIR + + `-bBIND_FILE' + Specifies BIND_FILE as the bind file to process. If not set, the + name of the bind file is computed from the full expanded Ada name + of a main subprogram. + + `-dX' + Activate internal debugging switches. X is a letter or digit, or + string of letters or digits, which specifies the type of debugging + mode desired. Normally these are used only for internal + development or system debugging purposes. You can find full + documentation for these switches in the body of the + `Gnatelim.Options' unit in the compiler source file + `gnatelim-options.adb'. + + `gnatelim' sends its output to the standard output stream, and all the + tracing and debug information is sent to the standard error stream. In + order to produce a proper GNAT configuration file `gnat.adc', + redirection must be used: + + $ gnatelim Main_Prog > gnat.adc + + or + + $ gnatelim Main_Prog >> gnat.adc + + In order to append the `gnatelim' output to the existing contents of + `gnat.adc'. + +  + File: gnat_ug_wnt.info, Node: Correcting the List of Eliminate Pragmas, Next: Making Your Executables Smaller, Prev: Running gnatelim, Up: Reducing the Size of Ada Executables with gnatelim + + Correcting the List of Eliminate Pragmas + ======================================== + + In some rare cases it may happen that `gnatelim' will try to eliminate + subprograms which are actually called in the program. In this case, the + compiler will generate an error message of the form: + + file.adb:106:07: cannot call eliminated subprogram "My_Prog" + + You will need to manually remove the wrong `Eliminate' pragmas from the + `gnat.adc' file. It is advised that you recompile your program from + scratch after that because you need a consistent `gnat.adc' file during + the entire compilation. + +  + File: gnat_ug_wnt.info, Node: Making Your Executables Smaller, Next: Summary of the gnatelim Usage Cycle, Prev: Correcting the List of Eliminate Pragmas, Up: Reducing the Size of Ada Executables with gnatelim + + Making Your Executables Smaller + =============================== + + In order to get a smaller executable for your program you now have to + recompile the program completely with the new `gnat.adc' file created + by `gnatelim' in your current directory: + + $ gnatmake -f Main_Prog + + (you will need `-f' option for gnatmake to recompile everything with + the set of pragmas `Eliminate' you have obtained with `gnatelim'). + + Be aware that the set of `Eliminate' pragmas is specific to each + program. It is not recommended to merge sets of `Eliminate' pragmas + created for different programs in one `gnat.adc' file. + +  + File: gnat_ug_wnt.info, Node: Summary of the gnatelim Usage Cycle, Prev: Making Your Executables Smaller, Up: Reducing the Size of Ada Executables with gnatelim + + Summary of the gnatelim Usage Cycle + =================================== + + Here is a quick summary of the steps to be taken in order to reduce the + size of your executables with `gnatelim'. You may use other GNAT + options to control the optimization level, to produce the debugging + information, to set search path, etc. + + 1. Produce a bind file and a set of tree files + + $ gnatmake -c Main_Prog + $ gnatbind main_prog + $ gnatmake -f -c -gnatc -gnatt Main_Prog + + 2. Generate a list of `Eliminate' pragmas + $ gnatelim Main_Prog >[>] gnat.adc + + 3. Recompile the application + + $ gnatmake -f Main_Prog + + +  + File: gnat_ug_wnt.info, Node: Other Utility Programs, Next: Running and Debugging Ada Programs, Prev: Reducing the Size of Ada Executables with gnatelim, Up: Top + + Other Utility Programs + ********************** + + This chapter discusses some other utility programs available in the Ada + environment. + + * Menu: + + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * Installing gnathtml:: + +  + File: gnat_ug_wnt.info, Node: Using Other Utility Programs with GNAT, Next: The gnatpsta Utility Program, Up: Other Utility Programs + + Using Other Utility Programs with GNAT + ====================================== + + The object files generated by GNAT are in standard system format and in + particular the debugging information uses this format. This means + programs generated by GNAT can be used with existing utilities that + depend on these formats. + + In general, any utility program that works with C will also often + work with Ada programs generated by GNAT. This includes software + utilities such as gprof (a profiling program), `gdb' (the FSF + debugger), and utilities such as Purify. + +  + File: gnat_ug_wnt.info, Node: The gnatpsta Utility Program, Next: The External Symbol Naming Scheme of GNAT, Prev: Using Other Utility Programs with GNAT, Up: Other Utility Programs + + The `gnatpsta' Utility Program + ============================== + + Many of the definitions in package Standard are + implementation-dependent. However, the source of this package does not + exist as an Ada source file, so these values cannot be determined by + inspecting the source. They can be determined by examining in detail + the coding of `cstand.adb' which creates the image of Standard in the + compiler, but this is awkward and requires a great deal of internal + knowledge about the system. + + The `gnatpsta' utility is designed to deal with this situation. It + is an Ada program that dynamically determines the values of all the + relevant parameters in Standard, and prints them out in the form of an + Ada source listing for Standard, displaying all the values of interest. + This output is generated to `stdout'. + + To determine the value of any parameter in package Standard, simply + run `gnatpsta' with no qualifiers or arguments, and examine the output. + This is preferable to consulting documentation, because you know that + the values you are getting are the actual ones provided by the + executing system. + +  + File: gnat_ug_wnt.info, Node: The External Symbol Naming Scheme of GNAT, Next: Ada Mode for Glide, Prev: The gnatpsta Utility Program, Up: Other Utility Programs + + The External Symbol Naming Scheme of GNAT + ========================================= + + In order to interpret the output from GNAT, when using tools that are + originally intended for use with other languages, it is useful to + understand the conventions used to generate link names from the Ada + entity names. + + All link names are in all lowercase letters. With the exception of + library procedure names, the mechanism used is simply to use the full + expanded Ada name with dots replaced by double underscores. For + example, suppose we have the following package spec: + + package QRS is + MN : Integer; + end QRS; + + The variable `MN' has a full expanded Ada name of `QRS.MN', so the + corresponding link name is `qrs__mn'. Of course if a `pragma Export' + is used this may be overridden: + + package Exports is + Var1 : Integer; + pragma Export (Var1, C, External_Name => "var1_name"); + Var2 : Integer; + pragma Export (Var2, C, Link_Name => "var2_link_name"); + end Exports; + + In this case, the link name for VAR1 is whatever link name the C + compiler would assign for the C function VAR1_NAME. This typically + would be either VAR1_NAME or _VAR1_NAME, depending on operating system + conventions, but other possibilities exist. The link name for VAR2 is + VAR2_LINK_NAME, and this is not operating system dependent. + + One exception occurs for library level procedures. A potential + ambiguity arises between the required name `_main' for the C main + program, and the name we would otherwise assign to an Ada library level + procedure called `Main' (which might well not be the main program). + + To avoid this ambiguity, we attach the prefix `_ada_' to such names. + So if we have a library level procedure such as + + procedure Hello (S : String); + + the external name of this procedure will be _ADA_HELLO. + +  + File: gnat_ug_wnt.info, Node: Ada Mode for Glide, Next: Converting Ada Files to html with gnathtml, Prev: The External Symbol Naming Scheme of GNAT, Up: Other Utility Programs + + Ada Mode for `Glide' + ==================== + + The Glide mode for programming in Ada (both, Ada83 and Ada95) helps the + user in understanding existing code and facilitates writing new code. It + furthermore provides some utility functions for easier integration of + standard Emacs features when programming in Ada. + + General Features: + ----------------- + + * Full Integrated Development Environment : + + * support of 'project files' for the configuration (directories, + compilation options,...) + + * compiling and stepping through error messages. + + * running and debugging your applications within Glide. + + * easy to use for beginners by pull-down menus, + + * user configurable by many user-option variables. + + Ada Mode Features That Help Understanding Code: + ----------------------------------------------- + + * functions for easy and quick stepping through Ada code, + + * getting cross reference information for identifiers (e.g. find the + defining place by a keystroke), + + * displaying an index menu of types and subprograms and move point to + the chosen one, + + * automatic color highlighting of the various entities in Ada code. + + Glide Support for Writing Ada Code: + ----------------------------------- + + * switching between spec and body files with possible autogeneration + of body files, + + * automatic formating of subprograms parameter lists. + + * automatic smart indentation according to Ada syntax, + + * automatic completion of identifiers, + + * automatic casing of identifiers, keywords, and attributes, + + * insertion of statement templates, + + * filling comment paragraphs like filling normal text, + + For more information, please refer to the online Glide documentation + available in the Glide -> Help Menu. + +  + File: gnat_ug_wnt.info, Node: Converting Ada Files to html with gnathtml, Next: Installing gnathtml, Prev: Ada Mode for Glide, Up: Other Utility Programs + + Converting Ada Files to html with `gnathtml' + ============================================ + + This `Perl' script allows Ada source files to be browsed using standard + Web browsers. For installation procedure, see the section *Note + Installing gnathtml::. + + Ada reserved keywords are highlighted in a bold font and Ada + comments in a blue font. Unless your program was compiled with the gcc + `-gnatx' switch to suppress the generation of cross-referencing + information, user defined variables and types will appear in a + different color; you will be able to click on any identifier and go to + its declaration. + + The command line is as follow: + $ perl gnathtml.pl [switches] ada-files + + You can pass it as many Ada files as you want. `gnathtml' will + generate an html file for every ada file, and a global file called + `index.htm'. This file is an index of every identifier defined in the + files. + + The available switches are the following ones : + + `-83' + Only the subset on the Ada 83 keywords will be highlighted, not + the full Ada 95 keywords set. + + `-cc COLOR' + This option allows you to change the color used for comments. The + default value is green. The color argument can be any name + accepted by html. + + `-d' + If the ada files depend on some other files (using for instance the + `with' command, the latter will also be converted to html. Only + the files in the user project will be converted to html, not the + files in the run-time library itself. + + `-D' + This command is the same as -d above, but `gnathtml' will also look + for files in the run-time library, and generate html files for + them. + + `-f' + By default, gnathtml will generate html links only for global + entities ('with'ed units, global variables and types,...). If you + specify the `-f' on the command line, then links will be generated + for local entities too. + + `-l NUMBER' + If this switch is provided and NUMBER is not 0, then `gnathtml' + will number the html files every NUMBER line. + + `-I DIR' + Specify a directory to search for library files (`.ali' files) and + source files. You can provide several -I switches on the command + line, and the directories will be parsed in the order of the + command line. + + `-o DIR' + Specify the output directory for html files. By default, gnathtml + will saved the generated html files in a subdirectory named + `html/'. + + `-p FILE' + If you are using Emacs and the most recent Emacs Ada mode, which + provides a full Integrated Development Environment for compiling, + checking, running and debugging applications, you may be using + `.adp' files to give the directories where Emacs can find sources + and object files. + + Using this switch, you can tell gnathtml to use these files. This + allows you to get an html version of your application, even if it + is spread over multiple directories. + + `-sc COLOR' + This option allows you to change the color used for symbol + definitions. The default value is red. The color argument can be + any name accepted by html. + + `-t FILE' + This switch provides the name of a file. This file contains a list + of file names to be converted, and the effect is exactly as though + they had appeared explicitly on the command line. This is the + recommended way to work around the command line length limit on + some systems. + +  + File: gnat_ug_wnt.info, Node: Installing gnathtml, Prev: Converting Ada Files to html with gnathtml, Up: Other Utility Programs + + Installing `gnathtml' + ===================== + + `Perl' needs to be installed on your machine to run this script. + `Perl' is freely available for almost every architecture and Operating + System via the Internet. + + On Unix systems, you may want to modify the first line of the + script `gnathtml', to explicitly tell the Operating system where + Perl is. The syntax of this line is : + #!full_path_name_to_perl + + Alternatively, you may run the script using the following command line: + + $ perl gnathtml.pl [switches] files + +  + File: gnat_ug_wnt.info, Node: Running and Debugging Ada Programs, Next: Inline Assembler, Prev: Other Utility Programs, Up: Top + + Running and Debugging Ada Programs + ********************************** + + This chapter discusses how to debug Ada programs. An incorrect Ada + program may be handled in three ways by the GNAT compiler: + + 1. The illegality may be a violation of the static semantics of Ada. + In that case GNAT diagnoses the constructs in the program that are + illegal. It is then a straightforward matter for the user to + modify those parts of the program. + + 2. The illegality may be a violation of the dynamic semantics of Ada. + In that case the program compiles and executes, but may generate + incorrect results, or may terminate abnormally with some exception. + + 3. When presented with a program that contains convoluted errors, GNAT + itself may terminate abnormally without providing full diagnostics + on the incorrect user program. + + * Menu: + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + +  + File: gnat_ug_wnt.info, Node: The GNAT Debugger GDB, Next: Running GDB, Up: Running and Debugging Ada Programs + + The GNAT Debugger GDB + ===================== + + `GDB' is a general purpose, platform-independent debugger that can be + used to debug mixed-language programs compiled with `GCC', and in + particular is capable of debugging Ada programs compiled with GNAT. The + latest versions of `GDB' are Ada-aware and can handle complex Ada data + structures. + + The manual `Debugging with GDB' contains full details on the usage + of `GDB', including a section on its usage on programs. This manual + should be consulted for full details. The section that follows is a + brief introduction to the philosophy and use of `GDB'. + + When GNAT programs are compiled, the compiler optionally writes + debugging information into the generated object file, including + information on line numbers, and on declared types and variables. This + information is separate from the generated code. It makes the object + files considerably larger, but it does not add to the size of the + actual executable that will be loaded into memory, and has no impact on + run-time performance. The generation of debug information is triggered + by the use of the -g switch in the gcc or gnatmake command used to + carry out the compilations. It is important to emphasize that the use + of these options does not change the generated code. + + The debugging information is written in standard system formats that + are used by many tools, including debuggers and profilers. The format + of the information is typically designed to describe C types and + semantics, but GNAT implements a translation scheme which allows full + details about Ada types and variables to be encoded into these standard + C formats. Details of this encoding scheme may be found in the file + exp_dbug.ads in the GNAT source distribution. However, the details of + this encoding are, in general, of no interest to a user, since `GDB' + automatically performs the necessary decoding. + + When a program is bound and linked, the debugging information is + collected from the object files, and stored in the executable image of + the program. Again, this process significantly increases the size of + the generated executable file, but it does not increase the size of the + executable program itself. Furthermore, if this program is run in the + normal manner, it runs exactly as if the debug information were not + present, and takes no more actual memory. + + However, if the program is run under control of `GDB', the debugger + is activated. The image of the program is loaded, at which point it is + ready to run. If a run command is given, then the program will run + exactly as it would have if `GDB' were not present. This is a crucial + part of the `GDB' design philosophy. `GDB' is entirely non-intrusive + until a breakpoint is encountered. If no breakpoint is ever hit, the + program will run exactly as it would if no debugger were present. When + a breakpoint is hit, `GDB' accesses the debugging information and can + respond to user commands to inspect variables, and more generally to + report on the state of execution. + +  + File: gnat_ug_wnt.info, Node: Running GDB, Next: Introduction to GDB Commands, Prev: The GNAT Debugger GDB, Up: Running and Debugging Ada Programs + + Running GDB + =========== + + The debugger can be launched directly and simply from `glide' or + through its graphical interface: `gvd'. It can also be used directly in + text mode. Here is described the basic use of `GDB' in text mode. All + the commands described below can be used in the `gvd' console window + eventhough there is usually other more graphical ways to achieve the + same goals. + + The command to run de graphical interface of the debugger is + $ gvd program + + The command to run `GDB' in text mode is + + $ gdb program + + where `program' is the name of the executable file. This activates the + debugger and results in a prompt for debugger commands. The simplest + command is simply `run', which causes the program to run exactly as if + the debugger were not present. The following section describes some of + the additional commands that can be given to `GDB'. + +  + File: gnat_ug_wnt.info, Node: Introduction to GDB Commands, Next: Using Ada Expressions, Prev: Running GDB, Up: Running and Debugging Ada Programs + + Introduction to GDB Commands + ============================ + + `GDB' contains a large repertoire of commands. The manual `Debugging + with GDB' includes extensive documentation on the use of these + commands, together with examples of their use. Furthermore, the command + HELP invoked from within `GDB' activates a simple help facility which + summarizes the available commands and their options. In this section + we summarize a few of the most commonly used commands to give an idea + of what `GDB' is about. You should create a simple program with + debugging information and experiment with the use of these `GDB' + commands on the program as you read through the following section. + + `set args ARGUMENTS' + The ARGUMENTS list above is a list of arguments to be passed to + the program on a subsequent run command, just as though the + arguments had been entered on a normal invocation of the program. + The `set args' command is not needed if the program does not + require arguments. + + `run' + The `run' command causes execution of the program to start from + the beginning. If the program is already running, that is to say if + you are currently positioned at a breakpoint, then a prompt will + ask for confirmation that you want to abandon the current + execution and restart. + + `breakpoint LOCATION' + The breakpoint command sets a breakpoint, that is to say a point + at which execution will halt and `GDB' will await further + commands. LOCATION is either a line number within a file, given in + the format `file:linenumber', or it is the name of a subprogram. + If you request that a breakpoint be set on a subprogram that is + overloaded, a prompt will ask you to specify on which of those + subprograms you want to breakpoint. You can also specify that all + of them should be breakpointed. If the program is run and + execution encounters the breakpoint, then the program stops and + `GDB' signals that the breakpoint was encountered by printing the + line of code before which the program is halted. + + `breakpoint exception NAME' + A special form of the breakpoint command which breakpoints whenever + exception NAME is raised. If NAME is omitted, then a breakpoint + will occur when any exception is raised. + + `print EXPRESSION' + This will print the value of the given expression. Most simple Ada + expression formats are properly handled by `GDB', so the expression + can contain function calls, variables, operators, and attribute + references. + + `continue' + Continues execution following a breakpoint, until the next + breakpoint or the termination of the program. + + `step' + Executes a single line after a breakpoint. If the next statement + is a subprogram call, execution continues into (the first + statement of) the called subprogram. + + `next' + Executes a single line. If this line is a subprogram call, + executes and returns from the call. + + `list' + Lists a few lines around the current source location. In practice, + it is usually more convenient to have a separate edit window open + with the relevant source file displayed. Successive applications + of this command print subsequent lines. The command can be given + an argument which is a line number, in which case it displays a + few lines around the specified one. + + `backtrace' + Displays a backtrace of the call chain. This command is typically + used after a breakpoint has occurred, to examine the sequence of + calls that leads to the current breakpoint. The display includes + one line for each activation record (frame) corresponding to an + active subprogram. + + `up' + At a breakpoint, `GDB' can display the values of variables local + to the current frame. The command `up' can be used to examine the + contents of other active frames, by moving the focus up the stack, + that is to say from callee to caller, one frame at a time. + + `down' + Moves the focus of `GDB' down from the frame currently being + examined to the frame of its callee (the reverse of the previous + command), + + `frame N' + Inspect the frame with the given number. The value 0 denotes the + frame of the current breakpoint, that is to say the top of the + call stack. + + The above list is a very short introduction to the commands that + `GDB' provides. Important additional capabilities, including conditional + breakpoints, the ability to execute command sequences on a breakpoint, + the ability to debug at the machine instruction level and many other + features are described in detail in `Debugging with GDB'. Note that + most commands can be abbreviated (for example, c for continue, bt for + backtrace). + +  + File: gnat_ug_wnt.info, Node: Using Ada Expressions, Next: Calling User-Defined Subprograms, Prev: Introduction to GDB Commands, Up: Running and Debugging Ada Programs + + Using Ada Expressions + ===================== + + `GDB' supports a fairly large subset of Ada expression syntax, with some + extensions. The philosophy behind the design of this subset is + + * That `GDB' should provide basic literals and access to operations + for arithmetic, dereferencing, field selection, indexing, and + subprogram calls, leaving more sophisticated computations to + subprograms written into the program (which therefore may be + called from `GDB'). + + * That type safety and strict adherence to Ada language restrictions + are not particularly important to the `GDB' user. + + * That brevity is important to the `GDB' user. + + Thus, for brevity, the debugger acts as if there were implicit + `with' and `use' clauses in effect for all user-written packages, thus + making it unnecessary to fully qualify most names with their packages, + regardless of context. Where this causes ambiguity, `GDB' asks the + user's intent. + + For details on the supported Ada syntax, see `Debugging with GDB'. + +  + File: gnat_ug_wnt.info, Node: Calling User-Defined Subprograms, Next: Using the Next Command in a Function, Prev: Using Ada Expressions, Up: Running and Debugging Ada Programs + + Calling User-Defined Subprograms + ================================ + + An important capability of `GDB' is the ability to call user-defined + subprograms while debugging. This is achieved simply by entering a + subprogram call statement in the form: + + call subprogram-name (parameters) + + The keyword `call' can be omitted in the normal case where the + `subprogram-name' does not coincide with any of the predefined `GDB' + commands. + + The effect is to invoke the given subprogram, passing it the list of + parameters that is supplied. The parameters can be expressions and can + include variables from the program being debugged. The subprogram must + be defined at the library level within your program, and `GDB' will + call the subprogram within the environment of your program execution + (which means that the subprogram is free to access or even modify + variables within your program). + + The most important use of this facility is in allowing the inclusion + of debugging routines that are tailored to particular data structures + in your program. Such debugging routines can be written to provide a + suitably high-level description of an abstract type, rather than a + low-level dump of its physical layout. After all, the standard `GDB + print' command only knows the physical layout of your types, not their + abstract meaning. Debugging routines can provide information at the + desired semantic level and are thus enormously useful. + + For example, when debugging GNAT itself, it is crucial to have + access to the contents of the tree nodes used to represent the program + internally. But tree nodes are represented simply by an integer value + (which in turn is an index into a table of nodes). Using the `print' + command on a tree node would simply print this integer value, which is + not very useful. But the PN routine (defined in file treepr.adb in the + GNAT sources) takes a tree node as input, and displays a useful high + level representation of the tree node, which includes the syntactic + category of the node, its position in the source, the integers that + denote descendant nodes and parent node, as well as varied semantic + information. To study this example in more detail, you might want to + look at the body of the PN procedure in the stated file. + +  + File: gnat_ug_wnt.info, Node: Using the Next Command in a Function, Next: Ada Exceptions, Prev: Calling User-Defined Subprograms, Up: Running and Debugging Ada Programs + + Using the Next Command in a Function + ==================================== + + When you use the `next' command in a function, the current source + location will advance to the next statement as usual. A special case + arises in the case of a `return' statement. + + Part of the code for a return statement is the "epilog" of the + function. This is the code that returns to the caller. There is only + one copy of this epilog code, and it is typically associated with the + last return statement in the function if there is more than one return. + In some implementations, this epilog is associated with the first + statement of the function. + + The result is that if you use the `next' command from a return + statement that is not the last return statement of the function you may + see a strange apparent jump to the last return statement or to the + start of the function. You should simply ignore this odd jump. The + value returned is always that from the first return statement that was + stepped through. + +  + File: gnat_ug_wnt.info, Node: Ada Exceptions, Next: Ada Tasks, Prev: Using the Next Command in a Function, Up: Running and Debugging Ada Programs + + Breaking on Ada Exceptions + ========================== + + You can set breakpoints that trip when your program raises selected + exceptions. + + `break exception' + Set a breakpoint that trips whenever (any task in the) program + raises any exception. + + `break exception NAME' + Set a breakpoint that trips whenever (any task in the) program + raises the exception NAME. + + `break exception unhandled' + Set a breakpoint that trips whenever (any task in the) program + raises an exception for which there is no handler. + + `info exceptions' + `info exceptions REGEXP' + The `info exceptions' command permits the user to examine all + defined exceptions within Ada programs. With a regular expression, + REGEXP, as argument, prints out only those exceptions whose name + matches REGEXP. + +  + File: gnat_ug_wnt.info, Node: Ada Tasks, Next: Debugging Generic Units, Prev: Ada Exceptions, Up: Running and Debugging Ada Programs + + Ada Tasks + ========= + + `GDB' allows the following task-related commands: + + `info tasks' + This command shows a list of current Ada tasks, as in the + following example: + + (gdb) info tasks + ID TID P-ID Thread Pri State Name + 1 8088000 0 807e000 15 Child Activation Wait main_task + 2 80a4000 1 80ae000 15 Accept/Select Wait b + 3 809a800 1 80a4800 15 Child Activation Wait a + * 4 80ae800 3 80b8000 15 Running c + + In this listing, the asterisk before the first task indicates it + to be the currently running task. The first column lists the task + ID that is used to refer to tasks in the following commands. + + `break LINESPEC task TASKID' + `break LINESPEC task TASKID if ...' + These commands are like the `break ... thread ...'. LINESPEC + specifies source lines. + + Use the qualifier `task TASKID' with a breakpoint command to + specify that you only want `GDB' to stop the program when a + particular Ada task reaches this breakpoint. TASKID is one of the + numeric task identifiers assigned by `GDB', shown in the first + column of the `info tasks' display. + + If you do not specify `task TASKID' when you set a breakpoint, the + breakpoint applies to _all_ tasks of your program. + + You can use the `task' qualifier on conditional breakpoints as + well; in this case, place `task TASKID' before the breakpoint + condition (before the `if'). + + `task TASKNO' + This command allows to switch to the task referred by TASKNO. In + particular, This allows to browse the backtrace of the specified + task. It is advised to switch back to the original task before + continuing execution otherwise the scheduling of the program may be + perturbated. + + For more detailed information on the tasking support, see `Debugging + with GDB'. + +  + File: gnat_ug_wnt.info, Node: Debugging Generic Units, Next: GNAT Abnormal Termination or Failure to Terminate, Prev: Ada Tasks, Up: Running and Debugging Ada Programs + + Debugging Generic Units + ======================= + + GNAT always uses code expansion for generic instantiation. This means + that each time an instantiation occurs, a complete copy of the original + code is made, with appropriate substitutions of formals by actuals. + + It is not possible to refer to the original generic entities in + `GDB', but it is always possible to debug a particular instance of a + generic, by using the appropriate expanded names. For example, if we + have + + procedure g is + + generic package k is + procedure kp (v1 : in out integer); + end k; + + package body k is + procedure kp (v1 : in out integer) is + begin + v1 := v1 + 1; + end kp; + end k; + + package k1 is new k; + package k2 is new k; + + var : integer := 1; + + begin + k1.kp (var); + k2.kp (var); + k1.kp (var); + k2.kp (var); + end; + + Then to break on a call to procedure kp in the k2 instance, simply use + the command: + + (gdb) break g.k2.kp + + When the breakpoint occurs, you can step through the code of the + instance in the normal manner and examine the values of local + variables, as for other units. + +  + File: gnat_ug_wnt.info, Node: GNAT Abnormal Termination or Failure to Terminate, Next: Naming Conventions for GNAT Source Files, Prev: Debugging Generic Units, Up: Running and Debugging Ada Programs + + GNAT Abnormal Termination or Failure to Terminate + ================================================= + + When presented with programs that contain serious errors in syntax or + semantics, GNAT may on rare occasions experience problems in + operation, such as aborting with a segmentation fault or illegal memory + access, raising an internal exception, terminating abnormally, or + failing to terminate at all. In such cases, you can activate various + features of GNAT that can help you pinpoint the construct in your + program that is the likely source of the problem. + + The following strategies are presented in increasing order of + difficulty, corresponding to your experience in using GNAT and your + familiarity with compiler internals. + + 1. Run `gcc' with the `-gnatf'. This first switch causes all errors + on a given line to be reported. In its absence, only the first + error on a line is displayed. + + The `-gnatdO' switch causes errors to be displayed as soon as they + are encountered, rather than after compilation is terminated. If + GNAT terminates prematurely or goes into an infinite loop, the + last error message displayed may help to pinpoint the culprit. + + 2. Run `gcc' with the `-v (verbose)' switch. In this mode, `gcc' + produces ongoing information about the progress of the compilation + and provides the name of each procedure as code is generated. This + switch allows you to find which Ada procedure was being compiled + when it encountered a code generation problem. + + 3. Run `gcc' with the `-gnatdc' switch. This is a GNAT specific + switch that does for the front-end what `-v' does for the back end. + The system prints the name of each unit, either a compilation unit + or nested unit, as it is being analyzed. + + 4. Finally, you can start `gdb' directly on the `gnat1' executable. + `gnat1' is the front-end of GNAT, and can be run independently + (normally it is just called from `gcc'). You can use `gdb' on + `gnat1' as you would on a C program (but *note The GNAT Debugger + GDB:: for caveats). The `where' command is the first line of + attack; the variable `lineno' (seen by `print lineno'), used by + the second phase of `gnat1' and by the `gcc' backend, indicates + the source line at which the execution stopped, and `input_file + name' indicates the name of the source file. + +  + File: gnat_ug_wnt.info, Node: Naming Conventions for GNAT Source Files, Next: Getting Internal Debugging Information, Prev: GNAT Abnormal Termination or Failure to Terminate, Up: Running and Debugging Ada Programs + + Naming Conventions for GNAT Source Files + ======================================== + + In order to examine the workings of the GNAT system, the following + brief description of its organization may be helpful: + + * Files with prefix `sc' contain the lexical scanner. + + * All files prefixed with `par' are components of the parser. The + numbers correspond to chapters of the Ada 95 Reference Manual. For + example, parsing of select statements can be found in + `par-ch9.adb'. + + * All files prefixed with `sem' perform semantic analysis. The + numbers correspond to chapters of the Ada standard. For example, + all issues involving context clauses can be found in + `sem_ch10.adb'. In addition, some features of the language require + sufficient special processing to justify their own semantic files: + sem_aggr for aggregates, sem_disp for dynamic dispatching, etc. + + * All files prefixed with `exp' perform normalization and expansion + of the intermediate representation (abstract syntax tree, or AST). + these files use the same numbering scheme as the parser and + semantics files. For example, the construction of record + initialization procedures is done in `exp_ch3.adb'. + + * The files prefixed with `bind' implement the binder, which + verifies the consistency of the compilation, determines an order of + elaboration, and generates the bind file. + + * The files `atree.ads' and `atree.adb' detail the low-level data + structures used by the front-end. + + * The files `sinfo.ads' and `sinfo.adb' detail the structure of the + abstract syntax tree as produced by the parser. + + * The files `einfo.ads' and `einfo.adb' detail the attributes of all + entities, computed during semantic analysis. + + * Library management issues are dealt with in files with prefix + `lib'. + + * Ada files with the prefix `a-' are children of `Ada', as defined + in Annex A. + + * Files with prefix `i-' are children of `Interfaces', as defined in + Annex B. + + * Files with prefix `s-' are children of `System'. This includes + both language-defined children and GNAT run-time routines. + + * Files with prefix `g-' are children of `GNAT'. These are useful + general-purpose packages, fully documented in their + specifications. All the other `.c' files are modifications of + common `gcc' files. + +  + File: gnat_ug_wnt.info, Node: Getting Internal Debugging Information, Next: Stack Traceback, Prev: Naming Conventions for GNAT Source Files, Up: Running and Debugging Ada Programs + + Getting Internal Debugging Information + ====================================== + + Most compilers have internal debugging switches and modes. GNAT does + also, except GNAT internal debugging switches and modes are not secret. + A summary and full description of all the compiler and binder debug + flags are in the file `debug.adb'. You must obtain the sources of the + compiler to see the full detailed effects of these flags. + + The switches that print the source of the program (reconstructed from + the internal tree) are of general interest for user programs, as are the + options to print the full internal tree, and the entity table (the + symbol table information). The reconstructed source provides a readable + version of the program after the front-end has completed analysis and + expansion, and is useful when studying the performance of specific + constructs. For example, constraint checks are indicated, complex + aggregates are replaced with loops and assignments, and tasking + primitives are replaced with run-time calls. + +  + File: gnat_ug_wnt.info, Node: Stack Traceback, Prev: Getting Internal Debugging Information, Up: Running and Debugging Ada Programs + + Stack Traceback + =============== + + Traceback is a mechanism to display the sequence of subprogram calls + that leads to a specified execution point in a program. Often (but not + always) the execution point is an instruction at which an exception has + been raised. This mechanism is also known as stack unwinding because + it obtains its information by scanning the run-time stack and + recovering the activation records of all active subprograms. Stack + unwinding is one of the most important tools for program debugging. + + The first entry stored in traceback corresponds to the deepest calling + level, that is to say the subprogram currently executing the instruction + from which we want to obtain the traceback. + + Note that there is no runtime performance penalty when stack traceback + is enabled and no exception are raised during program execution. + + * Menu: + + * Non-Symbolic Traceback:: + * Symbolic Traceback:: + +  + File: gnat_ug_wnt.info, Node: Non-Symbolic Traceback, Next: Symbolic Traceback, Up: Stack Traceback + + Non-Symbolic Traceback + ---------------------- + + Note: this feature is not supported on all platforms. See + `GNAT.Traceback spec in g-traceb.ads' for a complete list of supported + platforms. + + * Menu: + + * Tracebacks From an Unhandled Exception:: + * Tracebacks From Exception Occurrences (non-symbolic):: + * Tracebacks From Anywhere in a Program (non-symbolic):: + +  + File: gnat_ug_wnt.info, Node: Tracebacks From an Unhandled Exception, Next: Tracebacks From Exception Occurrences (non-symbolic), Up: Non-Symbolic Traceback + + Tracebacks From an Unhandled Exception + ...................................... + + A runtime non-symbolic traceback is a list of addresses of call + instructions. To enable this feature you must use the `-E' + `gnatbind''s option. With this option a stack traceback is stored as + part of exception information. It is possible to retrieve this + information using the standard `Ada.Exception.Exception_Information' + routine. + + Let's have a look at a simple example: + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + $ gnatmake stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + As we see the traceback lists a sequence of addresses for the unhandled + exception `CONSTAINT_ERROR' raised in procedure P1. It is easy to guess + that this exception come from procedure P1. To translate these + addresses into the source lines where the calls appear, the `addr2line' + tool, described below, is invaluable. The use of this tool requires the + program to be compiled with debug information. + + $ gnatmake -g stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + $ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 + 0x4011f1 0x77e892a4 + + 00401373 at d:/stb/stb.adb:5 + 0040138B at d:/stb/stb.adb:10 + 0040139C at d:/stb/stb.adb:14 + 00401335 at d:/stb/b~stb.adb:104 + 004011C4 at /build/.../crt1.c:200 + 004011F1 at /build/.../crt1.c:222 + 77E892A4 in ?? at ??:0 + + `addr2line' has a number of other useful options: + + `--functions' + to get the function name corresponding to any location + + `--demangle=gnat' + to use the gnat decoding mode for the function names. Note that + for binutils version 2.9.x the option is simply `--demangle'. + + $ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b + 0x40139c 0x401335 0x4011c4 0x4011f1 + + 00401373 in stb.p1 at d:/stb/stb.adb:5 + 0040138B in stb.p2 at d:/stb/stb.adb:10 + 0040139C in stb at d:/stb/stb.adb:14 + 00401335 in main at d:/stb/b~stb.adb:104 + 004011C4 in <__mingw_CRTStartup> at /build/.../crt1.c:200 + 004011F1 in at /build/.../crt1.c:222 + + From this traceback we can see that the exception was raised in + `stb.adb' at line 5, which was reached from a procedure call in + `stb.adb' at line 10, and so on. The `b~std.adb' is the binder file, + which contains the call to the main program. *note Running gnatbind::. + The remaining entries are assorted runtime routines, and the output + will vary from platform to platform. + + It is also possible to use `GDB' with these traceback addresses to debug + the program. For example, we can break at a given code location, as + reported in the stack traceback: + + $ gdb -nw stb + + Furthermore, this feature is not implemented inside Windows DLL. Only + the non-symbolic traceback is reported in this case. + + (gdb) break *0x401373 + Breakpoint 1 at 0x401373: file stb.adb, line 5. + + It is important to note that the stack traceback addresses do not + change when debug information is included. This is particularly useful + because it makes it possible to release software without debug + information (to minimize object size), get a field report that includes + a stack traceback whenever an internal bug occurs, and then be able to + retrieve the sequence of calls with the same program compiled with + debug information. + +  + File: gnat_ug_wnt.info, Node: Tracebacks From Exception Occurrences (non-symbolic), Next: Tracebacks From Anywhere in a Program (non-symbolic), Prev: Tracebacks From an Unhandled Exception, Up: Non-Symbolic Traceback + + Tracebacks From Exception Occurrences + ..................................... + + Non-symbolic tracebacks are obtained by using the `-E' binder argument. + The stack traceback is attached to the exception information string, + and can be retrieved in an exception handler within the Ada program, by + means of the Ada95 facilities defined in `Ada.Exceptions'. Here is a + simple example: + + with Ada.Text_IO; + with Ada.Exceptions; + + procedure STB is + + use Ada; + use Ada.Exceptions; + + procedure P1 is + K : Positive := 1; + begin + K := K - 1; + exception + when E : others => + Text_IO.Put_Line (Exception_Information (E)); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + This program will output: + + $ stb + + Exception name: CONSTRAINT_ERROR + Message: stb.adb:12 + Call stack traceback locations: + 0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4 + +  + File: gnat_ug_wnt.info, Node: Tracebacks From Anywhere in a Program (non-symbolic), Prev: Tracebacks From Exception Occurrences (non-symbolic), Up: Non-Symbolic Traceback + + Tracebacks From Anywhere in a Program + ..................................... + + It is also possible to retrieve a stack traceback from anywhere in a + program. For this you need to use the `GNAT.Traceback' API. This + package includes a procedure called `Call_Chain' that computes a + complete stack traceback, as well as useful display procedures + described below. It is not necessary to use the `-E gnatbind' option in + this case, because the stack traceback mechanism is invoked explicitly. + + In the following example we compute a traceback at a specific location + in the program, and we display it using `GNAT.Debug_Utilities.Image' to + convert addresses to strings: + + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Debug_Utilities; + + procedure STB is + + use Ada; + use GNAT; + use GNAT.Traceback; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + + Text_IO.Put ("In STB.P1 : "); + + for K in 1 .. Len loop + Text_IO.Put (Debug_Utilities.Image (TB (K))); + Text_IO.Put (' '); + end loop; + + Text_IO.New_Line; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + + $ gnatmake stb + $ stb + + In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C# + 16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4# + +  + File: gnat_ug_wnt.info, Node: Symbolic Traceback, Prev: Non-Symbolic Traceback, Up: Stack Traceback + + Symbolic Traceback + ------------------ + + A symbolic traceback is a stack traceback in which procedure names are + associated with each code location. + + Note that this feature is not supported on all platforms. See + `GNAT.Traceback.Symbolic spec in g-trasym.ads' for a complete list of + currently supported platforms. + + Note that the symbolic traceback requires that the program be compiled + with debug information. If it is not compiled with debug information + only the non-symbolic information will be valid. + + * Menu: + + * Tracebacks From Exception Occurrences (symbolic):: + * Tracebacks From Anywhere in a Program (symbolic):: + +  + File: gnat_ug_wnt.info, Node: Tracebacks From Exception Occurrences (symbolic), Next: Tracebacks From Anywhere in a Program (symbolic), Up: Symbolic Traceback + + Tracebacks From Exception Occurrences + ..................................... + + with Ada.Text_IO; + with GNAT.Traceback.Symbolic; + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + procedure P3 is + begin + P2; + end P3; + + begin + P3; + exception + when E : others => + Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); + end STB; + + $ gnatmake -g stb -bargs -E -largs -lgnat -laddr2line -lintl + $ stb + + 0040149F in stb.p1 at stb.adb:8 + 004014B7 in stb.p2 at stb.adb:13 + 004014CF in stb.p3 at stb.adb:18 + 004015DD in ada.stb at stb.adb:22 + 00401461 in main at b~stb.adb:168 + 004011C4 in __mingw_CRTStartup at crt1.c:200 + 004011F1 in mainCRTStartup at crt1.c:222 + 77E892A4 in ?? at ??:0 + + The exact sequence of linker options may vary from platform to platform. + The above `-largs' section is for Windows platforms. By contrast, under + Unix there is no need for the `-largs' section. Differences across + platforms are due to details of linker implementation. + +  + File: gnat_ug_wnt.info, Node: Tracebacks From Anywhere in a Program (symbolic), Prev: Tracebacks From Exception Occurrences (symbolic), Up: Symbolic Traceback + + Tracebacks From Anywhere in a Program + ..................................... + + It is possible to get a symbolic stack traceback from anywhere in a + program, just as for non-symbolic tracebacks. The first step is to + obtain a non-symbolic traceback, and then call `Symbolic_Traceback' to + compute the symbolic information. Here is an example: + + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Traceback.Symbolic; + + procedure STB is + + use Ada; + use GNAT.Traceback; + use GNAT.Traceback.Symbolic; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len))); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + +  + File: gnat_ug_wnt.info, Node: Inline Assembler, Next: Microsoft Windows Topics, Prev: Running and Debugging Ada Programs, Up: Top + + Inline Assembler + **************** + + If you need to write low-level software that interacts directly with + the hardware, Ada provides two ways to incorporate assembly language + code into your program. First, you can import and invoke external + routines written in assembly language, an Ada feature fully supported + by GNAT. However, for small sections of code it may be simpler or more + efficient to include assembly language statements directly in your Ada + source program, using the facilities of the implementation-defined + package `System.Machine_Code', which incorporates the gcc Inline + Assembler. The Inline Assembler approach offers a number of + advantages, including the following: + + * No need to use non-Ada tools + + * Consistent interface over different targets + + * Automatic usage of the proper calling conventions + + * Access to Ada constants and variables + + * Definition of intrinsic routines + + * Possibility of inlining a subprogram comprising assembler code + + * Code optimizer can take Inline Assembler code into account + + This chapter presents a series of examples to show you how to use + the Inline Assembler. Although it focuses on the Intel x86, the + general approach applies also to other processors. It is assumed that + you are familiar with Ada and with assembly language programming. + + * Menu: + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + +  + File: gnat_ug_wnt.info, Node: Basic Assembler Syntax, Next: A Simple Example of Inline Assembler, Up: Inline Assembler + + Basic Assembler Syntax + ====================== + + The assembler used by GNAT and gcc is based not on the Intel assembly + language, but rather on a language that descends from the AT&T Unix + assembler _as_ (and which is often referred to as "AT&T syntax"). The + following table summarizes the main features of _as_ syntax and points + out the differences from the Intel conventions. See the gcc _as_ and + _gas_ (an _as_ macro pre-processor) documentation for further + information. + + Register names + gcc / _as_: Prefix with "%"; for example `%eax' + Intel: No extra punctuation; for example `eax' + + Immediate operand + gcc / _as_: Prefix with "$"; for example `$4' + Intel: No extra punctuation; for example `4' + + Address + gcc / _as_: Prefix with "$"; for example `$loc' + Intel: No extra punctuation; for example `loc' + + Memory contents + gcc / _as_: No extra punctuation; for example `loc' + Intel: Square brackets; for example `[loc]' + + Register contents + gcc / _as_: Parentheses; for example `(%eax)' + Intel: Square brackets; for example `[eax]' + + Hexadecimal numbers + gcc / _as_: Leading "0x" (C language syntax); for example `0xA0' + Intel: Trailing "h"; for example `A0h' + + Operand size + gcc / _as_: Explicit in op code; for example `movw' to move a + 16-bit word + Intel: Implicit, deduced by assembler; for example `mov' + + Instruction repetition + gcc / _as_: Split into two lines; for example + `rep' + `stosl' + Intel: Keep on one line; for example `rep stosl' + + Order of operands + gcc / _as_: Source first; for example `movw $4, %eax' + Intel: Destination first; for example `mov eax, 4' + +  + File: gnat_ug_wnt.info, Node: A Simple Example of Inline Assembler, Next: Output Variables in Inline Assembler, Prev: Basic Assembler Syntax, Up: Inline Assembler + + A Simple Example of Inline Assembler + ==================================== + + The following example will generate a single assembly language + statement, `nop', which does nothing. Despite its lack of run-time + effect, the example will be useful in illustrating the basics of the + Inline Assembler facility. + + with System.Machine_Code; use System.Machine_Code; + procedure Nothing is + begin + Asm ("nop"); + end Nothing; + + `Asm' is a procedure declared in package `System.Machine_Code'; here + it takes one parameter, a _template string_ that must be a static + expression and that will form the generated instruction. `Asm' may be + regarded as a compile-time procedure that parses the template string + and additional parameters (none here), from which it generates a + sequence of assembly language instructions. + + The examples in this chapter will illustrate several of the forms + for invoking `Asm'; a complete specification of the syntax is found in + the `GNAT Reference Manual'. + + Under the standard GNAT conventions, the `Nothing' procedure should + be in a file named `nothing.adb'. You can build the executable in the + usual way: + gnatmake nothing + However, the interesting aspect of this example is not its run-time + behavior but rather the generated assembly code. To see this output, + invoke the compiler as follows: + gcc -c -S -fomit-frame-pointer -gnatp `nothing.adb' + where the options are: + + `-c' + compile only (no bind or link) + + `-S' + generate assembler listing + + `-fomit-frame-pointer' + do not set up separate stack frames + + `-gnatp' + do not add runtime checks + + This gives a human-readable assembler version of the code. The + resulting file will have the same name as the Ada source file, but with + a `.s' extension. In our example, the file `nothing.s' has the + following contents: + + .file "nothing.adb" + gcc2_compiled.: + ___gnu_compiled_ada: + .text + .align 4 + .globl __ada_nothing + __ada_nothing: + #APP + nop + #NO_APP + jmp L1 + .align 2,0x90 + L1: + ret + + The assembly code you included is clearly indicated by the compiler, + between the `#APP' and `#NO_APP' delimiters. The character before the + 'APP' and 'NOAPP' can differ on different targets. For example, Linux + uses '#APP' while on NT you will see '/APP'. + + If you make a mistake in your assembler code (such as using the + wrong size modifier, or using a wrong operand for the instruction) GNAT + will report this error in a temporary file, which will be deleted when + the compilation is finished. Generating an assembler file will help in + such cases, since you can assemble this file separately using the _as_ + assembler that comes with gcc. + + Assembling the file using the command + + as `nothing.s' + + will give you error messages whose lines correspond to the assembler + input file, so you can easily find and correct any mistakes you made. + If there are no errors, _as_ will generate an object file `nothing.out'. + +  + File: gnat_ug_wnt.info, Node: Output Variables in Inline Assembler, Next: Input Variables in Inline Assembler, Prev: A Simple Example of Inline Assembler, Up: Inline Assembler + + Output Variables in Inline Assembler + ==================================== + + The examples in this section, showing how to access the processor + flags, illustrate how to specify the destination operands for assembly + language statements. + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags; + + In order to have a nicely aligned assembly listing, we have separated + multiple assembler statements in the Asm template string with linefeed + (ASCII.LF) and horizontal tab (ASCII.HT) characters. The resulting + section of the assembly output file is: + + #APP + pushfl + popl %eax + movl %eax, -40(%ebp) + #NO_APP + + It would have been legal to write the Asm invocation as: + + Asm ("pushfl popl %%eax movl %%eax, %0") + + but in the generated assembler file, this would come out as: + + #APP + pushfl popl %eax movl %eax, -40(%ebp) + #NO_APP + + which is not so convenient for the human reader. + + We use Ada comments at the end of each line to explain what the + assembler instructions actually do. This is a useful convention. + + When writing Inline Assembler instructions, you need to precede each + register and variable name with a percent sign. Since the assembler + already requires a percent sign at the beginning of a register name, + you need two consecutive percent signs for such names in the Asm + template string, thus `%%eax'. In the generated assembly code, one of + the percent signs will be stripped off. + + Names such as `%0', `%1', `%2', etc., denote input or output + variables: operands you later define using `Input' or `Output' + parameters to `Asm'. An output variable is illustrated in the third + statement in the Asm template string: + movl %%eax, %0 + The intent is to store the contents of the eax register in a + variable that can be accessed in Ada. Simply writing `movl %%eax, + Flags' would not necessarily work, since the compiler might optimize by + using a register to hold Flags, and the expansion of the `movl' + instruction would not be aware of this optimization. The solution is + not to store the result directly but rather to advise the compiler to + choose the correct operand form; that is the purpose of the `%0' output + variable. + + Information about the output variable is supplied in the `Outputs' + parameter to `Asm': + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + + The output is defined by the `Asm_Output' attribute of the target + type; the general format is + Type'Asm_Output (constraint_string, variable_name) + + The constraint string directs the compiler how to store/access the + associated variable. In the example + Unsigned_32'Asm_Output ("=m", Flags); + the `"m"' (memory) constraint tells the compiler that the variable + `Flags' should be stored in a memory variable, thus preventing the + optimizer from keeping it in a register. In contrast, + Unsigned_32'Asm_Output ("=r", Flags); + uses the `"r"' (register) constraint, telling the compiler to store + the variable in a register. + + If the constraint is preceded by the equal character (*=*), it tells + the compiler that the variable will be used to store data into it. + + In the `Get_Flags' example, we used the "g" (global) constraint, + allowing the optimizer to choose whatever it deems best. + + There are a fairly large number of constraints, but the ones that + are most useful (for the Intel x86 processor) are the following: + + `=' + output constraint + + `g' + global (i.e. can be stored anywhere) + + `m' + in memory + + `I' + a constant + + `a' + use eax + + `b' + use ebx + + `c' + use ecx + + `d' + use edx + + `S' + use esi + + `D' + use edi + + `r' + use one of eax, ebx, ecx or edx + + `q' + use one of eax, ebx, ecx, edx, esi or edi + + The full set of constraints is described in the gcc and _as_ + documentation; note that it is possible to combine certain constraints + in one constraint string. + + You specify the association of an output variable with an assembler + operand through the `%'_n_ notation, where _n_ is a non-negative + integer. Thus in + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + + `%0' will be replaced in the expanded code by the appropriate operand, + whatever the compiler decided for the `Flags' variable. + + In general, you may have any number of output variables: + * Count the operands starting at 0; thus `%0', `%1', etc. + + * Specify the `Outputs' parameter as a parenthesized comma-separated + list of `Asm_Output' attributes + + For example: + Asm ("movl %%eax, %0" & LF & HT & + "movl %%ebx, %1" & LF & HT & + "movl %%ecx, %2", + Outputs => (Unsigned_32'Asm_Output ("=g", Var_A), -- %0 = Var_A + Unsigned_32'Asm_Output ("=g", Var_B), -- %1 = Var_B + Unsigned_32'Asm_Output ("=g", Var_C))); -- %2 = Var_C + + where `Var_A', `Var_B', and `Var_C' are variables in the Ada program. + + As a variation on the `Get_Flags' example, we can use the + constraints string to direct the compiler to store the eax register + into the `Flags' variable, instead of including the store instruction + explicitly in the `Asm' template string: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_2 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax", -- save flags in eax + Outputs => Unsigned_32'Asm_Output ("=a", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_2; + + The `"a"' constraint tells the compiler that the `Flags' variable will + come from the eax register. Here is the resulting code: + + #APP + pushfl + popl %eax + #NO_APP + movl %eax,-40(%ebp) + + The compiler generated the store of eax into Flags after expanding the + assembler code. + + Actually, there was no need to pop the flags into the eax register; + more simply, we could just pop the flags directly into the program + variable: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_3 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "pop %0", -- save flags in Flags + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_3; + +  + File: gnat_ug_wnt.info, Node: Input Variables in Inline Assembler, Next: Inlining Inline Assembler Code, Prev: Output Variables in Inline Assembler, Up: Inline Assembler + + Input Variables in Inline Assembler + =================================== + + The example in this section illustrates how to specify the source + operands for assembly language statements. The program simply + increments its input value by 1: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Incr (Value); + Put_Line ("Value after is" & Value'Img); + end Increment; + + The `Outputs' parameter to `Asm' specifies that the result will be + in the eax register and that it is to be stored in the `Result' + variable. + + The `Inputs' parameter looks much like the `Outputs' parameter, but + with an `Asm_Input' attribute. The `"="' constraint, indicating an + output value, is not present. + + You can have multiple input variables, in the same way that you can + have more than one output variable. + + The parameter count (%0, %1) etc, now starts at the first input + statement, and continues with the output statements. When both + parameters use the same variable, the compiler will treat them as the + same %n operand, which is the case here. + + Just as the `Outputs' parameter causes the register to be stored + into the target variable after execution of the assembler statements, + so does the `Inputs' parameter cause its variable to be loaded into the + register before execution of the assembler statements. + + Thus the effect of the `Asm' invocation is: + 1. load the 32-bit value of `Value' into eax + + 2. execute the `incl %eax' instruction + + 3. store the contents of eax into the `Result' variable + + The resulting assembler file (with `-O2' optimization) contains: + _increment__incr.1: + subl $4,%esp + movl 8(%esp),%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + movl %ecx,(%esp) + addl $4,%esp + ret + +  + File: gnat_ug_wnt.info, Node: Inlining Inline Assembler Code, Next: Other Asm Functionality, Prev: Input Variables in Inline Assembler, Up: Inline Assembler + + Inlining Inline Assembler Code + ============================== + + For a short subprogram such as the `Incr' function in the previous + section, the overhead of the call and return (creating / deleting the + stack frame) can be significant, compared to the amount of code in the + subprogram body. A solution is to apply Ada's `Inline' pragma to the + subprogram, which directs the compiler to expand invocations of the + subprogram at the point(s) of call, instead of setting up a stack frame + for out-of-line calls. Here is the resulting program: + + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment_2 is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + pragma Inline (Increment); + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Increment (Value); + Put_Line ("Value after is" & Value'Img); + end Increment_2; + + Compile the program with both optimization (`-O2') and inlining + enabled (`-gnatpn' instead of `-gnatp'). + + The `Incr' function is still compiled as usual, but at the point in + `Increment' where our function used to be called: + + pushl %edi + call _increment__incr.1 + + the code for the function body directly appears: + + movl %esi,%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + + thus saving the overhead of stack frame setup and an out-of-line call. + +  + File: gnat_ug_wnt.info, Node: Other Asm Functionality, Next: A Complete Example, Prev: Inlining Inline Assembler Code, Up: Inline Assembler + + Other `Asm' Functionality + ========================= + + This section describes two important parameters to the `Asm' procedure: + `Clobber', which identifies register usage; and `Volatile', which + inhibits unwanted optimizations. + + * Menu: + + * The Clobber Parameter:: + * The Volatile Parameter:: + +  + File: gnat_ug_wnt.info, Node: The Clobber Parameter, Next: The Volatile Parameter, Up: Other Asm Functionality + + The `Clobber' Parameter + ----------------------- + + One of the dangers of intermixing assembly language and a compiled + language such as Ada is that the compiler needs to be aware of which + registers are being used by the assembly code. In some cases, such as + the earlier examples, the constraint string is sufficient to indicate + register usage (e.g. "a" for the eax register). But more generally, the + compiler needs an explicit identification of the registers that are + used by the Inline Assembly statements. + + Using a register that the compiler doesn't know about could be a + side effect of an instruction (like `mull' storing its result in both + eax and edx). It can also arise from explicit register usage in your + assembly code; for example: + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out)); + + where the compiler (since it does not analyze the `Asm' template string) + does not know you are using the ebx register. + + In such cases you need to supply the `Clobber' parameter to `Asm', + to identify the registers that will be used by your assembly code: + + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx"); + + The Clobber parameter is a static string expression specifying the + register(s) you are using. Note that register names are _not_ prefixed + by a percent sign. Also, if more than one register is used then their + names are separated by commas; e.g., `"eax, ebx"' + + The `Clobber' parameter has several additional uses: + 1. Use the "register" name `cc' to indicate that flags might have + changed + + 2. Use the "register" name `memory' if you changed a memory location + +  + File: gnat_ug_wnt.info, Node: The Volatile Parameter, Prev: The Clobber Parameter, Up: Other Asm Functionality + + The `Volatile' Parameter + ------------------------ + + Compiler optimizations in the presence of Inline Assembler may + sometimes have unwanted effects. For example, when an `Asm' invocation + with an input variable is inside a loop, the compiler might move the + loading of the input variable outside the loop, regarding it as a + one-time initialization. + + If this effect is not desired, you can disable such optimizations by + setting the `Volatile' parameter to `True'; for example: + + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx", + Volatile => True); + + By default, `Volatile' is set to `False' unless there is no `Outputs' + parameter. + + Although setting `Volatile' to `True' prevents unwanted + optimizations, it will also disable other optimizations that might be + important for efficiency. In general, you should set `Volatile' to + `True' only if the compiler's optimizations have created problems. + +  + File: gnat_ug_wnt.info, Node: A Complete Example, Prev: Other Asm Functionality, Up: Inline Assembler + + A Complete Example + ================== + + This section contains a complete program illustrating a realistic usage + of GNAT's Inline Assembler capabilities. It comprises a main procedure + `Check_CPU' and a package `Intel_CPU'. The package declares a + collection of functions that detect the properties of the 32-bit x86 + processor that is running the program. The main procedure invokes + these functions and displays the information. + + The Intel_CPU package could be enhanced by adding functions to + detect the type of x386 co-processor, the processor caching options and + special operations such as the SIMD extensions. + + Although the Intel_CPU package has been written for 32-bit Intel + compatible CPUs, it is OS neutral. It has been tested on DOS, + Windows/NT and Linux. + + * Menu: + + * Check_CPU Procedure:: + * Intel_CPU Package Specification:: + * Intel_CPU Package Body:: + +  + File: gnat_ug_wnt.info, Node: Check_CPU Procedure, Next: Intel_CPU Package Specification, Up: A Complete Example + + `Check_CPU' Procedure + --------------------- + + --------------------------------------------------------------------- + -- -- + -- Uses the Intel_CPU package to identify the CPU the program is -- + -- running on, and some of the features it supports. -- + -- -- + --------------------------------------------------------------------- + + with Intel_CPU; -- Intel CPU detection functions + with Ada.Text_IO; -- Standard text I/O + with Ada.Command_Line; -- To set the exit status + + procedure Check_CPU is + + Type_Found : Boolean := False; + -- Flag to indicate that processor was identified + + Features : Intel_CPU.Processor_Features; + -- The processor features + + Signature : Intel_CPU.Processor_Signature; + -- The processor type signature + + begin + + ----------------------------------- + -- Display the program banner. -- + ----------------------------------- + + Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name & + ": check Intel CPU version and features, v1.0"); + Ada.Text_IO.Put_Line ("distribute freely, but no warranty whatsoever"); + Ada.Text_IO.New_Line; + + ----------------------------------------------------------------------- + -- We can safely start with the assumption that we are on at least -- + -- a x386 processor. If the CPUID instruction is present, then we -- + -- have a later processor type. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Has_CPUID = False then + + -- No CPUID instruction, so we assume this is indeed a x386 + -- processor. We can still check if it has a FP co-processor. + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line + ("x386-type processor with a FP co-processor"); + else + Ada.Text_IO.Put_Line + ("x386-type processor without a FP co-processor"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check for CPUID + + ----------------------------------------------------------------------- + -- If CPUID is supported, check if this is a true Intel processor, -- + -- if it is not, display a warning. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Vendor_ID /= Intel_CPU.Intel_Processor then + Ada.Text_IO.Put_Line ("*** This is a Intel compatible processor"); + Ada.Text_IO.Put_Line ("*** Some information may be incorrect"); + end if; -- check if Intel + + ---------------------------------------------------------------------- + -- With the CPUID instruction present, we can assume at least a -- + -- x486 processor. If the CPUID support level is < 1 then we have -- + -- to leave it at that. -- + ---------------------------------------------------------------------- + + if Intel_CPU.CPUID_Level < 1 then + + -- Ok, this is a x486 processor. we still can get the Vendor ID + Ada.Text_IO.Put_Line ("x486-type processor"); + Ada.Text_IO.Put_Line ("Vendor ID is " & Intel_CPU.Vendor_ID); + + -- We can also check if there is a FPU present + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line ("Floating-Point support"); + else + Ada.Text_IO.Put_Line ("No Floating-Point support"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check CPUID level + + --------------------------------------------------------------------- + -- With a CPUID level of 1 we can use the processor signature to -- + -- determine it's exact type. -- + --------------------------------------------------------------------- + + Signature := Intel_CPU.Signature; + + ---------------------------------------------------------------------- + -- Ok, now we go into a lot of messy comparisons to get the -- + -- processor type. For clarity, no attememt to try to optimize the -- + -- comparisons has been made. Note that since Intel_CPU does not -- + -- support getting cache info, we cannot distinguish between P5 -- + -- and Celeron types yet. -- + ---------------------------------------------------------------------- + + -- x486SL + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486SL processor"); + end if; + + -- x486DX2 Write-Back + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0111# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Write-Back Enhanced x486DX2 processor"); + end if; + + -- x486DX4 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 processor"); + end if; + + -- x486DX4 Overdrive + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 OverDrive processor"); + end if; + + -- Pentium (60, 66) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium processor (60, 66)"); + end if; + + -- Pentium (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive (60, 66) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium OverDrive processor (60, 66)"); + end if; + + -- Pentium OverDrive (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive cpu (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive processor for x486 processor-based systems + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor for x486 processor-based systems"); + end if; + + -- Pentium processor with MMX technology (166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor with MMX technology (166, 200)"); + end if; + + -- Pentium OverDrive with MMX for Pentium (75, 90, 100, 120, 133) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor with MMX " & + "technology for Pentium processor (75, 90, 100, 120, 133)"); + end if; + + -- Pentium Pro processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro processor"); + end if; + + -- Pentium II processor, model 3 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium II processor, model 3"); + end if; + + -- Pentium II processor, model 5 or Celeron processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0101# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium II processor, model 5 or Celeron processor"); + end if; + + -- Pentium Pro OverDrive processor + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro OverDrive processor"); + end if; + + -- If no type recognized, we have an unknown. Display what + -- we _do_ know + if Type_Found = False then + Ada.Text_IO.Put_Line ("Unknown processor"); + end if; + + ----------------------------------------- + -- Display processor stepping level. -- + ----------------------------------------- + + Ada.Text_IO.Put_Line ("Stepping level:" & Signature.Stepping'Img); + + --------------------------------- + -- Display vendor ID string. -- + --------------------------------- + + Ada.Text_IO.Put_Line ("Vendor ID: " & Intel_CPU.Vendor_ID); + + ------------------------------------ + -- Get the processors features. -- + ------------------------------------ + + Features := Intel_CPU.Features; + + ----------------------------- + -- Check for a FPU unit. -- + ----------------------------- + + if Features.FPU = True then + Ada.Text_IO.Put_Line ("Floating-Point unit available"); + else + Ada.Text_IO.Put_Line ("no Floating-Point unit"); + end if; -- check for FPU + + -------------------------------- + -- List processor features. -- + -------------------------------- + + Ada.Text_IO.Put_Line ("Supported features: "); + + -- Virtual Mode Extension + if Features.VME = True then + Ada.Text_IO.Put_Line (" VME - Virtual Mode Extension"); + end if; + + -- Debugging Extension + if Features.DE = True then + Ada.Text_IO.Put_Line (" DE - Debugging Extension"); + end if; + + -- Page Size Extension + if Features.PSE = True then + Ada.Text_IO.Put_Line (" PSE - Page Size Extension"); + end if; + + -- Time Stamp Counter + if Features.TSC = True then + Ada.Text_IO.Put_Line (" TSC - Time Stamp Counter"); + end if; + + -- Model Specific Registers + if Features.MSR = True then + Ada.Text_IO.Put_Line (" MSR - Model Specific Registers"); + end if; + + -- Physical Address Extension + if Features.PAE = True then + Ada.Text_IO.Put_Line (" PAE - Physical Address Extension"); + end if; + + -- Machine Check Extension + if Features.MCE = True then + Ada.Text_IO.Put_Line (" MCE - Machine Check Extension"); + end if; + + -- CMPXCHG8 instruction supported + if Features.CX8 = True then + Ada.Text_IO.Put_Line (" CX8 - CMPXCHG8 instruction"); + end if; + + -- on-chip APIC hardware support + if Features.APIC = True then + Ada.Text_IO.Put_Line (" APIC - on-chip APIC hardware support"); + end if; + + -- Fast System Call + if Features.SEP = True then + Ada.Text_IO.Put_Line (" SEP - Fast System Call"); + end if; + + -- Memory Type Range Registers + if Features.MTRR = True then + Ada.Text_IO.Put_Line (" MTTR - Memory Type Range Registers"); + end if; + + -- Page Global Enable + if Features.PGE = True then + Ada.Text_IO.Put_Line (" PGE - Page Global Enable"); + end if; + + -- Machine Check Architecture + if Features.MCA = True then + Ada.Text_IO.Put_Line (" MCA - Machine Check Architecture"); + end if; + + -- Conditional Move Instruction Supported + if Features.CMOV = True then + Ada.Text_IO.Put_Line + (" CMOV - Conditional Move Instruction Supported"); + end if; + + -- Page Attribute Table + if Features.PAT = True then + Ada.Text_IO.Put_Line (" PAT - Page Attribute Table"); + end if; + + -- 36-bit Page Size Extension + if Features.PSE_36 = True then + Ada.Text_IO.Put_Line (" PSE_36 - 36-bit Page Size Extension"); + end if; + + -- MMX technology supported + if Features.MMX = True then + Ada.Text_IO.Put_Line (" MMX - MMX technology supported"); + end if; + + -- Fast FP Save and Restore + if Features.FXSR = True then + Ada.Text_IO.Put_Line (" FXSR - Fast FP Save and Restore"); + end if; + + --------------------- + -- Program done. -- + --------------------- + + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + + exception + + when others => + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); + raise; + + end Check_CPU; + +  + File: gnat_ug_wnt.info, Node: Intel_CPU Package Specification, Next: Intel_CPU Package Body, Prev: Check_CPU Procedure, Up: A Complete Example + + `Intel_CPU' Package Specification + --------------------------------- + + ------------------------------------------------------------------------- + -- -- + -- file: intel_cpu.ads -- + -- -- + -- ********************************************* -- + -- * WARNING: for 32-bit Intel processors only * -- + -- ********************************************* -- + -- -- + -- This package contains a number of subprograms that are useful in -- + -- determining the Intel x86 CPU (and the features it supports) on -- + -- which the program is running. -- + -- -- + -- The package is based upon the information given in the Intel -- + -- Application Note AP-485: "Intel Processor Identification and the -- + -- CPUID Instruction" as of April 1998. This application note can be -- + -- found on www.intel.com. -- + -- -- + -- It currently deals with 32-bit processors only, will not detect -- + -- features added after april 1998, and does not guarantee proper -- + -- results on Intel-compatible processors. -- + -- -- + -- Cache info and x386 fpu type detection are not supported. -- + -- -- + -- This package does not use any privileged instructions, so should -- + -- work on any OS running on a 32-bit Intel processor. -- + -- -- + ------------------------------------------------------------------------- + + with Interfaces; use Interfaces; + -- for using unsigned types + + with System.Machine_Code; use System.Machine_Code; + -- for using inline assembler code + + with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; + -- for inserting control characters + + package Intel_CPU is + + ---------------------- + -- Processor bits -- + ---------------------- + + subtype Num_Bits is Natural range 0 .. 31; + -- the number of processor bits (32) + + -------------------------- + -- Processor register -- + -------------------------- + + -- define a processor register type for easy access to + -- the individual bits + + type Processor_Register is array (Num_Bits) of Boolean; + pragma Pack (Processor_Register); + for Processor_Register'Size use 32; + + ------------------------- + -- Unsigned register -- + ------------------------- + + -- define a processor register type for easy access to + -- the individual bytes + + type Unsigned_Register is + record + L1 : Unsigned_8; + H1 : Unsigned_8; + L2 : Unsigned_8; + H2 : Unsigned_8; + end record; + + for Unsigned_Register use + record + L1 at 0 range 0 .. 7; + H1 at 0 range 8 .. 15; + L2 at 0 range 16 .. 23; + H2 at 0 range 24 .. 31; + end record; + + for Unsigned_Register'Size use 32; + + --------------------------------- + -- Intel processor vendor ID -- + --------------------------------- + + Intel_Processor : constant String (1 .. 12) := "GenuineIntel"; + -- indicates an Intel manufactured processor + + ------------------------------------ + -- Processor signature register -- + ------------------------------------ + + -- a register type to hold the processor signature + + type Processor_Signature is + record + Stepping : Natural range 0 .. 15; + Model : Natural range 0 .. 15; + Family : Natural range 0 .. 15; + Processor_Type : Natural range 0 .. 3; + Reserved : Natural range 0 .. 262143; + end record; + + for Processor_Signature use + record + Stepping at 0 range 0 .. 3; + Model at 0 range 4 .. 7; + Family at 0 range 8 .. 11; + Processor_Type at 0 range 12 .. 13; + Reserved at 0 range 14 .. 31; + end record; + + for Processor_Signature'Size use 32; + + ----------------------------------- + -- Processor features register -- + ----------------------------------- + + -- a processor register to hold the processor feature flags + + type Processor_Features is + record + FPU : Boolean; -- floating point unit on chip + VME : Boolean; -- virtual mode extension + DE : Boolean; -- debugging extension + PSE : Boolean; -- page size extension + TSC : Boolean; -- time stamp counter + MSR : Boolean; -- model specific registers + PAE : Boolean; -- physical address extension + MCE : Boolean; -- machine check extension + CX8 : Boolean; -- cmpxchg8 instruction + APIC : Boolean; -- on-chip apic hardware + Res_1 : Boolean; -- reserved for extensions + SEP : Boolean; -- fast system call + MTRR : Boolean; -- memory type range registers + PGE : Boolean; -- page global enable + MCA : Boolean; -- machine check architecture + CMOV : Boolean; -- conditional move supported + PAT : Boolean; -- page attribute table + PSE_36 : Boolean; -- 36-bit page size extension + Res_2 : Natural range 0 .. 31; -- reserved for extensions + MMX : Boolean; -- MMX technology supported + FXSR : Boolean; -- fast FP save and restore + Res_3 : Natural range 0 .. 127; -- reserved for extensions + end record; + + for Processor_Features use + record + FPU at 0 range 0 .. 0; + VME at 0 range 1 .. 1; + DE at 0 range 2 .. 2; + PSE at 0 range 3 .. 3; + TSC at 0 range 4 .. 4; + MSR at 0 range 5 .. 5; + PAE at 0 range 6 .. 6; + MCE at 0 range 7 .. 7; + CX8 at 0 range 8 .. 8; + APIC at 0 range 9 .. 9; + Res_1 at 0 range 10 .. 10; + SEP at 0 range 11 .. 11; + MTRR at 0 range 12 .. 12; + PGE at 0 range 13 .. 13; + MCA at 0 range 14 .. 14; + CMOV at 0 range 15 .. 15; + PAT at 0 range 16 .. 16; + PSE_36 at 0 range 17 .. 17; + Res_2 at 0 range 18 .. 22; + MMX at 0 range 23 .. 23; + FXSR at 0 range 24 .. 24; + Res_3 at 0 range 25 .. 31; + end record; + + for Processor_Features'Size use 32; + + ------------------- + -- Subprograms -- + ------------------- + + function Has_FPU return Boolean; + -- return True if a FPU is found + -- use only if CPUID is not supported + + function Has_CPUID return Boolean; + -- return True if the processor supports the CPUID instruction + + function CPUID_Level return Natural; + -- return the CPUID support level (0, 1 or 2) + -- can only be called if the CPUID instruction is supported + + function Vendor_ID return String; + -- return the processor vendor identification string + -- can only be called if the CPUID instruction is supported + + function Signature return Processor_Signature; + -- return the processor signature + -- can only be called if the CPUID instruction is supported + + function Features return Processor_Features; + -- return the processors features + -- can only be called if the CPUID instruction is supported + + private + + ------------------------ + -- EFLAGS bit names -- + ------------------------ + + ID_Flag : constant Num_Bits := 21; + -- ID flag bit + + end Intel_CPU; + +  + File: gnat_ug_wnt.info, Node: Intel_CPU Package Body, Prev: Intel_CPU Package Specification, Up: A Complete Example + + `Intel_CPU' Package Body + ------------------------ + + package body Intel_CPU is + + --------------------------- + -- Detect FPU presence -- + --------------------------- + + -- There is a FPU present if we can set values to the FPU Status + -- and Control Words. + + function Has_FPU return Boolean is + + Register : Unsigned_16; + -- processor register to store a word + + begin + + -- check if we can change the status word + Asm ( + + -- the assembler code + "finit" & LF & HT & -- reset status word + "movw $0x5A5A, %%ax" & LF & HT & -- set value status word + "fnstsw %0" & LF & HT & -- save status word + "movw %%ax, %0", -- store status word + + -- output stored in Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register), + + -- tell compiler that we used eax + Clobber => "eax"); + + -- if the status word is zero, there is no FPU + if Register = 0 then + return False; -- no status word + end if; -- check status word value + + -- check if we can get the control word + Asm ( + + -- the assembler code + "fnstcw %0", -- save the control word + + -- output into Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register)); + + -- check the relevant bits + if (Register and 16#103F#) /= 16#003F# then + return False; -- no control word + end if; -- check control word value + + -- FPU found + return True; + + end Has_FPU; + + -------------------------------- + -- Detect CPUID instruction -- + -------------------------------- + + -- The processor supports the CPUID instruction if it is possible + -- to change the value of ID flag bit in the EFLAGS register. + + function Has_CPUID return Boolean is + + Original_Flags, Modified_Flags : Processor_Register; + -- EFLAG contents before and after changing the ID flag + + begin + + -- try flipping the ID flag in the EFLAGS register + Asm ( + + -- the assembler code + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %%eax" & LF & HT & -- pop EFLAGS into eax + "movl %%eax, %0" & LF & HT & -- save EFLAGS content + "xor $0x200000, %%eax" & LF & HT & -- flip ID flag + "push %%eax" & LF & HT & -- push EFLAGS on stack + "popfl" & LF & HT & -- load EFLAGS register + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %1", -- save EFLAGS content + + -- output values, may be anything + -- Original_Flags is %0 + -- Modified_Flags is %1 + Outputs => + (Processor_Register'Asm_output ("=g", Original_Flags), + Processor_Register'Asm_output ("=g", Modified_Flags)), + + -- tell compiler eax is destroyed + Clobber => "eax"); + + -- check if CPUID is supported + if Original_Flags(ID_Flag) /= Modified_Flags(ID_Flag) then + return True; -- ID flag was modified + else + return False; -- ID flag unchanged + end if; -- check for CPUID + + end Has_CPUID; + + ------------------------------- + -- Get CPUID support level -- + ------------------------------- + + function CPUID_Level return Natural is + + Level : Unsigned_32; + -- returned support level + + begin + + -- execute CPUID, storing the results in the Level register + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero is stored in eax + -- returning the support level in eax + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- eax is stored in Level + Outputs => Unsigned_32'Asm_output ("=a", Level), + + -- tell compiler ebx, ecx and edx registers are destroyed + Clobber => "ebx, ecx, edx"); + + -- return the support level + return Natural (Level); + + end CPUID_Level; + + -------------------------------- + -- Get CPU Vendor ID String -- + -------------------------------- + + -- The vendor ID string is returned in the ebx, ecx and edx register + -- after executing the CPUID instruction with eax set to zero. + -- In case of a true Intel processor the string returned is + -- "GenuineIntel" + + function Vendor_ID return String is + + Ebx, Ecx, Edx : Unsigned_Register; + -- registers containing the vendor ID string + + Vendor_ID : String (1 .. 12); + -- the vendor ID string + + begin + + -- execute CPUID, storing the results in the processor registers + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero stored in eax + -- vendor ID string returned in ebx, ecx and edx + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- ebx is stored in Ebx + -- ecx is stored in Ecx + -- edx is stored in Edx + Outputs => (Unsigned_Register'Asm_output ("=b", Ebx), + Unsigned_Register'Asm_output ("=c", Ecx), + Unsigned_Register'Asm_output ("=d", Edx))); + + -- now build the vendor ID string + Vendor_ID( 1) := Character'Val (Ebx.L1); + Vendor_ID( 2) := Character'Val (Ebx.H1); + Vendor_ID( 3) := Character'Val (Ebx.L2); + Vendor_ID( 4) := Character'Val (Ebx.H2); + Vendor_ID( 5) := Character'Val (Edx.L1); + Vendor_ID( 6) := Character'Val (Edx.H1); + Vendor_ID( 7) := Character'Val (Edx.L2); + Vendor_ID( 8) := Character'Val (Edx.H2); + Vendor_ID( 9) := Character'Val (Ecx.L1); + Vendor_ID(10) := Character'Val (Ecx.H1); + Vendor_ID(11) := Character'Val (Ecx.L2); + Vendor_ID(12) := Character'Val (Ecx.H2); + + -- return string + return Vendor_ID; + + end Vendor_ID; + + ------------------------------- + -- Get processor signature -- + ------------------------------- + + function Signature return Processor_Signature is + + Result : Processor_Signature; + -- processor signature returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one is stored in eax + -- processor signature returned in eax + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- eax is stored in Result + Outputs => Processor_Signature'Asm_output ("=a", Result), + + -- tell compiler that ebx, ecx and edx are also destroyed + Clobber => "ebx, ecx, edx"); + + -- return processor signature + return Result; + + end Signature; + + ------------------------------ + -- Get processor features -- + ------------------------------ + + function Features return Processor_Features is + + Result : Processor_Features; + -- processor features returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one stored in eax + -- processor features returned in edx + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- edx is stored in Result + Outputs => Processor_Features'Asm_output ("=d", Result), + + -- tell compiler that ebx and ecx are also destroyed + Clobber => "ebx, ecx"); + + -- return processor signature + return Result; + + end Features; + + end Intel_CPU; + +  + File: gnat_ug_wnt.info, Node: Microsoft Windows Topics, Next: Performance Considerations, Prev: Inline Assembler, Up: Top + + Microsoft Windows Topics + ************************ + + This chapter describes topics that are specific to the Microsoft Windows + platforms (NT, 95 and 98). + + * Menu: + + * Using GNAT on Windows:: + * GNAT Setup Tool:: + * CONSOLE and WINDOWS subsystems:: + * Temporary Files:: + * Mixed-Language Programming on Windows:: + * Windows Calling Conventions:: + * Introduction to Dynamic Link Libraries (DLLs):: + * Using DLLs with GNAT:: + * Building DLLs with GNAT:: + * GNAT and Windows Resources:: + * Debugging a DLL:: + * GNAT and COM/DCOM Objects:: + +  + File: gnat_ug_wnt.info, Node: Using GNAT on Windows, Next: GNAT Setup Tool, Up: Microsoft Windows Topics + + Using GNAT on Windows + ===================== + + One of the strengths of the GNAT technology is that its tool set + (`gcc', `gnatbind', `gnatlink', `gnatmake', the `gdb' debugger, etc.) + is used in the same way regardless of the platform. + + On Windows this tool set is complemented by a number of + Microsoft-specific tools that have been provided to facilitate + interoperability with Windows when this is required. With these tools: + + * You can build applications using the `CONSOLE' or `WINDOWS' + subsystems. + + * You can use any Dynamically Linked Library (DLL) in your Ada code + (both relocatable and non-relocatable DLLs are supported). + + * You can build Ada DLLs for use in other applications. These + applications can be written in a language other than Ada (e.g., C, + C++, etc). Again both relocatable and non-relocatable Ada DLLs are + supported. + + * You can include Windows resources in your Ada application. + + * You can use or create COM/DCOM objects. + + Immediately below are listed all known general GNAT-for-Windows + restrictions. Other restrictions about specific features like Windows + Resources and DLLs are listed in separate sections below. + + * It is not possible to use `GetLastError' and `SetLastError' when + tasking, protected records, or exceptions are used. In these + cases, in order to implement Ada semantics, the GNAT run-time + system calls certain Win32 routines that set the last error + variable to 0 upon success. It should be possible to use + `GetLastError' and `SetLastError' when tasking, protected record, + and exception features are not used, but it is not guaranteed to + work. + +  + File: gnat_ug_wnt.info, Node: GNAT Setup Tool, Next: CONSOLE and WINDOWS subsystems, Prev: Using GNAT on Windows, Up: Microsoft Windows Topics + + GNAT Setup Tool + =============== + + * Menu: + + * Command-line arguments:: + * Creating a network installation of GNAT:: + * Registering and unregistering additional libraries:: + + GNAT installation on Windows is using the Windows registry in order to + locate proper executables and standard libraries. GNAT setup tool, + called `gnatreg.exe', is provided in order to display and modify + GNAT-specific registry entries, allowing to create network GNAT + installations, modify the locations of GNAT components, as well as + register and unregister additional libraries for use with GNAT. + +  + File: gnat_ug_wnt.info, Node: Command-line arguments, Next: Creating a network installation of GNAT, Up: GNAT Setup Tool + + Command-line arguments + ---------------------- + + `gnatreg [switches] [parameter]' + + Specifying no arguments causes gnatreg to display current configuration. + + The switches understood by gnatreg are: + -h + print the help message + + -a + add a standard library + + -r + remove a standard library + + -f + force creation of keys if they don't exist + + -q + be quiet/terse + +  + File: gnat_ug_wnt.info, Node: Creating a network installation of GNAT, Next: Registering and unregistering additional libraries, Prev: Command-line arguments, Up: GNAT Setup Tool + + Creating a network installation of GNAT + --------------------------------------- + + Make sure the system on which GNAT is installed is accessible from the + current machine. + + Use the command + + ` gnatreg -f \\server\sharename\path' + + in order to setup the registry entries on a current machine. + + For example, if GNAT is installed in `\GNAT' directory of a share + location called `c-drive' on a machine `LOKI', the command that can be + used on other machines to allow the remote use of GNAT is, + + ` gnatreg -f \\loki\c-drive\gnat' + + Remember to also add `\\loki\c-drive\gnat\bin' in front of your PATH + variable. + + Be aware that every compilation using the network installation + results in the transfer of large amounts of data across the network and + may cause serious performance penalty. + +  + File: gnat_ug_wnt.info, Node: Registering and unregistering additional libraries, Prev: Creating a network installation of GNAT, Up: GNAT Setup Tool + + Registering and unregistering additional libraries + -------------------------------------------------- + + To register a standard library use a command: + + ` gnatreg -a =' + + For example: + + ` gnatreg -a WIN32ADA=c:\Win32Ada' + + The libraries registered in this manner will be treated like + standard libraries by the compiler (i.e. they don't have to be + specified in -I and -l switches to various GNAT tools). + + To unregister a library, enter ` gnatreg -r ' + + e.g., ` gnatreg -r WIN32ADA' + +  + File: gnat_ug_wnt.info, Node: CONSOLE and WINDOWS subsystems, Next: Temporary Files, Prev: GNAT Setup Tool, Up: Microsoft Windows Topics + + CONSOLE and WINDOWS subsystems + ============================== + + Under Windows there is two main subsystems. The `CONSOLE' subsystem + (which is the default subsystem) will always create a console when + launching the application. This is not something desirable when the + application has a Windows GUI. To get rid of this console the + application must be using the `WINDOWS' subsystem. To do so the + `-mwindows' linker option must be specified. + + $ gnatmake winprog -largs -mwindows + +  + File: gnat_ug_wnt.info, Node: Temporary Files, Next: Mixed-Language Programming on Windows, Prev: CONSOLE and WINDOWS subsystems, Up: Microsoft Windows Topics + + Temporary Files + =============== + + It is possible to control where temporary files gets created by setting + the TMP environment variable. The file will be created: + + * Under the directory pointed to by the TMP environment variable if + this directory exists. + + * Under c:\temp, if the TMP environment variable is not set (or not + pointing to a directory) and if this directory exists. + + * Under the current working directory otherwise. + + This allows you to determine exactly where the temporary file will be + created. This is particularly useful in networked environments where + you may not have write access to some directories. + +  + File: gnat_ug_wnt.info, Node: Mixed-Language Programming on Windows, Next: Windows Calling Conventions, Prev: Temporary Files, Up: Microsoft Windows Topics + + Mixed-Language Programming on Windows + ===================================== + + Developing pure Ada applications on Windows is no different than on + other GNAT-supported platforms. However, when developing or porting an + application that contains a mix of Ada and C/C++, the choice of your + Windows C/C++ development environment conditions your overall + interoperability strategy. + + If you use `gcc' to compile the non-Ada part of your application, + there are no Windows-specific restrictions that affect the overall + interoperability with your Ada code. If you plan to use Microsoft tools + (e.g. Microsoft Visual C/C++), you should be aware of the following + limitations: + + * You cannot link your Ada code with an object or library generated + with Microsoft tools if these use the `.tls' section (Thread Local + Storage section) since the GNAT linker does not yet support this + section. + + * You cannot link your Ada code with an object or library generated + with Microsoft tools if these use I/O routines other than those + provided in the Microsoft DLL: `msvcrt.dll'. This is because the + GNAT run time uses the services of `msvcrt.dll' for its I/Os. Use + of other I/O libraries can cause a conflict with `msvcrt.dll' + services. For instance Visual C++ I/O stream routines conflict + with those in `msvcrt.dll'. + + If you do want to use the Microsoft tools for your non-Ada code and hit + one of the above limitations, you have two choices: + + 1. Encapsulate your non Ada code in a DLL to be linked with your Ada + application. In this case, use the Microsoft or whatever + environment to build the DLL and use GNAT to build your executable + (*note Using DLLs with GNAT::). + + 2. Or you can encapsulate your Ada code in a DLL to be linked with the + other part of your application. In this case, use GNAT to build + the DLL (*note Building DLLs with GNAT::) and use the Microsoft or + whatever environment to build your executable. + +  + File: gnat_ug_wnt.info, Node: Windows Calling Conventions, Next: Introduction to Dynamic Link Libraries (DLLs), Prev: Mixed-Language Programming on Windows, Up: Microsoft Windows Topics + + Windows Calling Conventions + =========================== + + * Menu: + + * C Calling Convention:: + * Stdcall Calling Convention:: + * DLL Calling Convention:: + + When a subprogram `F' (caller) calls a subprogram `G' (callee), there + are several ways to push `G''s parameters on the stack and there are + several possible scenarios to clean up the stack upon `G''s return. A + calling convention is an agreed upon software protocol whereby the + responsibilities between the caller (`F') and the callee (`G') are + clearly defined. Several calling conventions are available for Windows: + + * `C' (Microsoft defined) + + * `Stdcall' (Microsoft defined) + + * `DLL' (GNAT specific) + +  + File: gnat_ug_wnt.info, Node: C Calling Convention, Next: Stdcall Calling Convention, Up: Windows Calling Conventions + + `C' Calling Convention + ---------------------- + + This is the default calling convention used when interfacing to C/C++ + routines compiled with either `gcc' or Microsoft Visual C++. + + In the `C' calling convention subprogram parameters are pushed on the + stack by the caller from right to left. The caller itself is in charge + of cleaning up the stack after the call. In addition, the name of a + routine with `C' calling convention is mangled by adding a leading + underscore. + + The name to use on the Ada side when importing (or exporting) a + routine with `C' calling convention is the name of the routine. For + instance the C function: + + int get_val (long); + + should be imported from Ada as follows: + + function Get_Val (V : Interfaces.C.long) return Interfaces.C.int; + pragma Import (C, Get_Val, External_Name => "get_val"); + + Note that in this particular case the `External_Name' parameter could + have been omitted since, when missing, this parameter is taken to be the + name of the Ada entity in lower case. When the `Link_Name' parameter is + missing, as in the above example, this parameter is set to be the + `External_Name' with a leading underscore. + + When importing a variable defined in C, you should always use the `C' + calling convention unless the object containing the variable is part of + a DLL (in which case you should use the `DLL' calling convention, *note + DLL Calling Convention::). + +  + File: gnat_ug_wnt.info, Node: Stdcall Calling Convention, Next: DLL Calling Convention, Prev: C Calling Convention, Up: Windows Calling Conventions + + `Stdcall' Calling Convention + ---------------------------- + + This convention, which was the calling convention used for Pascal + programs, is used by Microsoft for all the routines in the Win32 API for + efficiency reasons. It must be used to import any routine for which this + convention was specified. + + In the `Stdcall' calling convention subprogram parameters are pushed + on the stack by the caller from right to left. The callee (and not the + caller) is in charge of cleaning the stack on routine exit. In addition, + the name of a routine with `Stdcall' calling convention is mangled by + adding a leading underscore (as for the `C' calling convention) and a + trailing `@'`nn', where nn is the overall size (in bytes) of the + parameters passed to the routine. + + The name to use on the Ada side when importing a C routine with a + `Stdcall' calling convention is the name of the C routine. The leading + underscore and trailing `@'`nn' are added automatically by the + compiler. For instance the Win32 function: + + APIENTRY int get_val (long); + + should be imported from Ada as follows: + + function Get_Val (V : Interfaces.C.long) return Interfaces.C.int; + pragma Import (Stdcall, Get_Val); + -- On the x86 a long is 4 bytes, so the Link_Name is "_get_val@4" + + As for the `C' calling convention, when the `External_Name' parameter + is missing, it is taken to be the name of the Ada entity in lower case. + If instead of writing the above import pragma you write: + + function Get_Val (V : Interfaces.C.long) return Interfaces.C.int; + pragma Import (Stdcall, Get_Val, External_Name => "retrieve_val"); + + then the imported routine is `_retrieve_val@4'. However, if instead of + specifying the `External_Name' parameter you specify the `Link_Name' as + in the following example: + + function Get_Val (V : Interfaces.C.long) return Interfaces.C.int; + pragma Import (Stdcall, Get_Val, Link_Name => "retrieve_val"); + + then the imported routine is `retrieve_val@4', that is, there is no + trailing underscore but the appropriate `@'`nn' is always added at the + end of the `Link_Name' by the compiler. + + Note, that in some special cases a DLL's entry point name lacks a + trailing `@'`nn' while the exported name generated for a call has it. + The `gnatdll' tool, which creates the import library for the DLL, is + able to handle those cases (see the description of the switches in + *note Using gnatdll:: section). + +  + File: gnat_ug_wnt.info, Node: DLL Calling Convention, Prev: Stdcall Calling Convention, Up: Windows Calling Conventions + + `DLL' Calling Convention + ------------------------ + + This convention, which is GNAT-specific, must be used when you want to + import in Ada a variables defined in a DLL. For functions and procedures + this convention is equivalent to the `Stdcall' convention. As an + example, if a DLL contains a variable defined as: + + int my_var; + + then, to access this variable from Ada you should write: + + My_Var : Interfaces.C.int; + pragma Import (DLL, My_Var); + + The remarks concerning the `External_Name' and `Link_Name' + parameters given in the previous sections equally apply to the `DLL' + calling convention. + +  + File: gnat_ug_wnt.info, Node: Introduction to Dynamic Link Libraries (DLLs), Next: Using DLLs with GNAT, Prev: Windows Calling Conventions, Up: Microsoft Windows Topics + + Introduction to Dynamic Link Libraries (DLLs) + ============================================= + + A Dynamically Linked Library (DLL) is a library that can be shared by + several applications running under Windows. A DLL can contain any + number of routines and variables. + + One advantage of DLLs is that you can change and enhance them without + forcing all the applications that depend on them to be relinked or + recompiled. However, you should be aware than all calls to DLL routines + are slower since, as you will understand below, such calls are indirect. + + To illustrate the remainder of this section, suppose that an + application wants to use the services of a DLL `API.dll'. To use the + services provided by `API.dll' you must statically link against an + import library which contains a jump table with an entry for each + routine and variable exported by the DLL. In the Microsoft world this + import library is called `API.lib'. When using GNAT this import library + is called either `libAPI.a' or `libapi.a' (names are case insensitive). + + After you have statically linked your application with the import + library and you run your application, here is what happens: + + 1. Your application is loaded into memory. + + 2. The DLL `API.dll' is mapped into the address space of your + application. This means that: + + * The DLL will use the stack of the calling thread. + + * The DLL will use the virtual address space of the calling + process. + + * The DLL will allocate memory from the virtual address space + of the calling process. + + * Handles (pointers) can be safely exchanged between routines + in the DLL routines and routines in the application using the + DLL. + + 3. The entries in the `libAPI.a' or `API.lib' jump table which is + part of your application are initialized with the addresses of the + routines and variables in `API.dll'. + + 4. If present in `API.dll', routines `DllMain' or `DllMainCRTStartup' + are invoked. These routines typically contain the initialization + code needed for the well-being of the routines and variables + exported by the DLL. + + There is an additional point which is worth mentioning. In the Windows + world there are two kind of DLLs: relocatable and non-relocatable DLLs. + Non-relocatable DLLs can only be loaded at a very specific address in + the target application address space. If the addresses of two + non-relocatable DLLs overlap and these happen to be used by the same + application, a conflict will occur and the application will run + incorrectly. Hence, when possible, it is always preferable to use and + build relocatable DLLs. Both relocatable and non-relocatable DLLs are + supported by GNAT. + + As a side note, an interesting difference between Microsoft DLLs and + Unix shared libraries, is the fact that on most Unix systems all public + routines are exported by default in a Unix shared library, while under + Windows the exported routines must be listed explicitly in a definition + file (*note The Definition File::). + +  + File: gnat_ug_wnt.info, Node: Using DLLs with GNAT, Next: Building DLLs with GNAT, Prev: Introduction to Dynamic Link Libraries (DLLs), Up: Microsoft Windows Topics + + Using DLLs with GNAT + ==================== + + * Menu: + + * Creating an Ada Spec for the DLL Services:: + * Creating an Import Library:: + + To use the services of a DLL, say `API.dll', in your Ada application + you must have: + + 1. The Ada spec for the routines and/or variables you want to access + in `API.dll'. If not available this Ada spec must be built from + the C/C++ header files provided with the DLL. + + 2. The import library (`libAPI.a' or `API.lib'). As previously + mentioned an import library is a statically linked library + containing the import table which will be filled at load time to + point to the actual `API.dll' routines. Sometimes you don't have + an import library for the DLL you want to use. The following + sections will explain how to build one. + + 3. The actual DLL, `API.dll'. + + Once you have all the above, to compile an Ada application that uses the + services of `API.dll' and whose main subprogram is `My_Ada_App', you + simply issue the command + + $ gnatmake my_ada_app -largs -lAPI + + The argument `-largs -lAPI' at the end of the `gnatmake' command tells + the GNAT linker to look first for a library named `API.lib' + (Microsoft-style name) and if not found for a library named `libAPI.a' + (GNAT-style name). Note that if the Ada package spec for `API.dll' + contains the following pragma + + pragma Linker_Options ("-lAPI"); + + you do not have to add `-largs -lAPI' at the end of the `gnatmake' + command. + + If any one of the items above is missing you will have to create it + yourself. The following sections explain how to do so using as an + example a fictitious DLL called `API.dll'. + +  + File: gnat_ug_wnt.info, Node: Creating an Ada Spec for the DLL Services, Next: Creating an Import Library, Up: Using DLLs with GNAT + + Creating an Ada Spec for the DLL Services + ----------------------------------------- + + A DLL typically comes with a C/C++ header file which provides the + definitions of the routines and variables exported by the DLL. The Ada + equivalent of this header file is a package spec that contains + definitions for the imported entities. If the DLL you intend to use + does not come with an Ada spec you have to generate one such spec + yourself. For example if the header file of `API.dll' is a file `api.h' + containing the following two definitions: + + int some_var; + int get (char *); + + then the equivalent Ada spec could be: + + with Interfaces.C.Strings; + package API is + use Interfaces; + + Some_Var : C.int; + function Get (Str : C.Strings.Chars_Ptr) return C.int; + + private + pragma Import (C, Get); + pragma Import (DLL, Some_Var); + end API; + + Note that a variable is *always imported with a DLL convention*. A + function can have `C', `Stdcall' or `DLL' convention. For subprograms, + the `DLL' convention is a synonym of `Stdcall' (*note Windows Calling + Conventions::). + +  + File: gnat_ug_wnt.info, Node: Creating an Import Library, Prev: Creating an Ada Spec for the DLL Services, Up: Using DLLs with GNAT + + Creating an Import Library + -------------------------- + + * Menu: + + * The Definition File:: + * GNAT-Style Import Library:: + * Microsoft-Style Import Library:: + + If a Microsoft-style import library `API.lib' or a GNAT-style import + library `libAPI.a' is available with `API.dll' you can skip this + section. Otherwise read on. + +  + File: gnat_ug_wnt.info, Node: The Definition File, Next: GNAT-Style Import Library, Up: Creating an Import Library + + The Definition File + ................... + + As previously mentioned, and unlike Unix systems, the list of symbols + that are exported from a DLL must be provided explicitly in Windows. + The main goal of a definition file is precisely that: list the symbols + exported by a DLL. A definition file (usually a file with a `.def' + suffix) has the following structure: + + [LIBRARY name] + [DESCRIPTION string] + EXPORTS + symbol1 + symbol2 + ... + + `LIBRARY name' + This section, which is optional, gives the name of the DLL. + + `DESCRIPTION string' + This section, which is optional, gives a description string that + will be embedded in the import library. + + `EXPORTS' + This section gives the list of exported symbols (procedures, + functions or variables). For instance in the case of `API.dll' the + `EXPORTS' section of `API.def' looks like: + + EXPORTS + some_var + get + + Note that you must specify the correct suffix (`@'`nn') (*note Windows + Calling Conventions::) for a Stdcall calling convention function in the + exported symbols list. + + There can actually be other sections in a definition file, but these + sections are not relevant to the discussion at hand. + +  + File: gnat_ug_wnt.info, Node: GNAT-Style Import Library, Next: Microsoft-Style Import Library, Prev: The Definition File, Up: Creating an Import Library + + GNAT-Style Import Library + ......................... + + To create a static import library from `API.dll' with the GNAT tools + you should proceed as follows: + + 1. Create the definition file `API.def' (*note The Definition File::). + For that use the `dll2def' tool as follows: + + $ dll2def API.dll > API.def + + `dll2def' is a very simple tool: it takes as input a DLL and prints + to standard output the list of entry points in the DLL. Note that + if some routines in the DLL have the `Stdcall' convention (*note + Windows Calling Conventions::) with stripped `@'nn suffix then + you'll have to edit `api.def' to add it. + + Here are some hints to find the right `@'nn suffix. + + 1. If you have the Microsoft import library (.lib), it is + possible to get the right symbols by using Microsoft + `dumpbin' tool (see the corresponding Microsoft documentation + for further details). + + $ dumpbin /exports api.lib + + 2. If you have a message about a missing symbol at link time the + compiler tells you what symbol is expected. You just have to + go back to the definition file and add the right suffix. + + 2. Build the import library `libAPI.a', using `gnatdll' (*note Using + gnatdll::) as follows: + + $ gnatdll -e API.def -d API.dll + + `gnatdll' takes as input a definition file `API.def' and the name + of the DLL containing the services listed in the definition file + `API.dll'. The name of the static import library generated is + computed from the name of the definition file as follows: if the + definition file name is xyz`.def', the import library name will be + `lib'xyz`.a'. Note that in the previous example option `-e' could + have been removed because the name of the definition file (before + the "`.def'" suffix) is the same as the name of the DLL (*note + Using gnatdll:: for more information about `gnatdll'). + +  + File: gnat_ug_wnt.info, Node: Microsoft-Style Import Library, Prev: GNAT-Style Import Library, Up: Creating an Import Library + + Microsoft-Style Import Library + .............................. + + With GNAT you can either use a GNAT-style or Microsoft-style import + library. A Microsoft import library is needed only if you plan to make + an Ada DLL available to applications developed with Microsoft tools + (*note Mixed-Language Programming on Windows::). + + To create a Microsoft-style import library for `API.dll' you should + proceed as follows: + + 1. Create the definition file `API.def' from the DLL. For this use + either the `dll2def' tool as described above or the Microsoft + `dumpbin' tool (see the corresponding Microsoft documentation for + further details). + + 2. Build the actual import library using Microsoft's `lib' utility: + + $ lib -machine:IX86 -def:API.def -out:API.lib + + If you use the above command the definition file `API.def' must + contain a line giving the name of the DLL: + + LIBRARY "API" + + See the Microsoft documentation for further details about the + usage of `lib'. + +  + File: gnat_ug_wnt.info, Node: Building DLLs with GNAT, Next: GNAT and Windows Resources, Prev: Using DLLs with GNAT, Up: Microsoft Windows Topics + + Building DLLs with GNAT + ======================= + + * Menu: + + * Limitations When Using Ada DLLs from Ada:: + * Exporting Ada Entities:: + * Ada DLLs and Elaboration:: + * Ada DLLs and Finalization:: + * Creating a Spec for Ada DLLs:: + * Creating the Definition File:: + * Using gnatdll:: + + This section explains how to build DLLs containing Ada code. These DLLs + will be referred to as Ada DLLs in the remainder of this section. + + The steps required to build an Ada DLL that is to be used by Ada as + well as non-Ada applications are as follows: + + 1. You need to mark each Ada entity exported by the DLL with a `C' or + `Stdcall' calling convention to avoid any Ada name mangling for the + entities exported by the DLL (*note Exporting Ada Entities::). You + can skip this step if you plan to use the Ada DLL only from Ada + applications. + + 2. Your Ada code must export an initialization routine which calls + the routine `adainit' generated by `gnatbind' to perform the + elaboration of the Ada code in the DLL (*note Ada DLLs and + Elaboration::). The initialization routine exported by the Ada DLL + must be invoked by the clients of the DLL to initialize the DLL. + + 3. When useful, the DLL should also export a finalization routine + which calls routine `adafinal' generated by `gnatbind' to perform + the finalization of the Ada code in the DLL (*note Ada DLLs and + Finalization::). The finalization routine exported by the Ada DLL + must be invoked by the clients of the DLL when the DLL services + are no further needed. + + 4. You must provide a spec for the services exported by the Ada DLL + in each of the programming languages to which you plan to make the + DLL available. + + 5. You must provide a definition file listing the exported entities + (*note The Definition File::). + + 6. Finally you must use `gnatdll' to produce the DLL and the import + library (*note Using gnatdll::). + +  + File: gnat_ug_wnt.info, Node: Limitations When Using Ada DLLs from Ada, Next: Exporting Ada Entities, Up: Building DLLs with GNAT + + Limitations When Using Ada DLLs from Ada + ---------------------------------------- + + When using Ada DLLs from Ada applications there is a limitation users + should be aware of. Because on Windows the GNAT run time is not in a + DLL of its own, each Ada DLL includes a part of the GNAT run time. + Specifically, each Ada DLL includes the services of the GNAT run time + that are necessary to the Ada code inside the DLL. As a result, when an + Ada program uses an Ada DLL there are two independent GNAT run times: + one in the Ada DLL and one in the main program. + + It is therefore not possible to exchange GNAT run-time objects + between the Ada DLL and the main Ada program. Example of GNAT run-time + objects are file handles (e.g. `Text_IO.File_Type'), tasks types, + protected objects types, etc. + + It is completely safe to exchange plain elementary, array or record + types, Windows object handles, etc. + +  + File: gnat_ug_wnt.info, Node: Exporting Ada Entities, Next: Ada DLLs and Elaboration, Prev: Limitations When Using Ada DLLs from Ada, Up: Building DLLs with GNAT + + Exporting Ada Entities + ---------------------- + + Building a DLL is a way to encapsulate a set of services usable from any + application. As a result, the Ada entities exported by a DLL should be + exported with the `C' or `Stdcall' calling conventions to avoid any Ada + name mangling. Please note that the `Stdcall' convention should only be + used for subprograms, not for variables. As an example here is an Ada + package `API', spec and body, exporting two procedures, a function, and + a variable: + + with Interfaces.C; use Interfaces; + package API is + Count : C.int := 0; + function Factorial (Val : C.int) return C.int; + + procedure Initialize_API; + procedure Finalize_API; + -- Initialization & Finalization routines. More in the next section. + private + pragma Export (C, Initialize_API); + pragma Export (C, Finalize_API); + pragma Export (C, Count); + pragma Export (C, Factorial); + end API; + + package body API is + function Factorial (Val : C.int) return C.int is + Fact : C.int := 1; + begin + Count := Count + 1; + for K in 1 .. Val loop + Fact := Fact * K; + end loop; + return Fact; + end Factorial; + + procedure Initialize_API is + procedure Adainit; + pragma Import (C, Adainit); + begin + Adainit; + end Initialize_API; + + procedure Finalize_API is + procedure Adafinal; + pragma Import (C, Adafinal); + begin + Adafinal; + end Finalize_API; + end API; + + If the Ada DLL you are building will only be used by Ada applications + you do not have to export Ada entities with a `C' or `Stdcall' + convention. As an example, the previous package could be written as + follows: + + package API is + Count : Integer := 0; + function Factorial (Val : Integer) return Integer; + + procedure Initialize_API; + procedure Finalize_API; + -- Initialization and Finalization routines. + end API; + + package body API is + function Factorial (Val : Integer) return Integer is + Fact : Integer := 1; + begin + Count := Count + 1; + for K in 1 .. Val loop + Fact := Fact * K; + end loop; + return Fact; + end Factorial; + + ... + -- The remainder of this package body is unchanged. + end API; + + Note that if you do not export the Ada entities with a `C' or `Stdcall' + convention you will have to provide the mangled Ada names in the + definition file of the Ada DLL (*note Creating the Definition File::). + +  + File: gnat_ug_wnt.info, Node: Ada DLLs and Elaboration, Next: Ada DLLs and Finalization, Prev: Exporting Ada Entities, Up: Building DLLs with GNAT + + Ada DLLs and Elaboration + ------------------------ + + The DLL that you are building contains your Ada code as well as all the + routines in the Ada library that are needed by it. The first thing a + user of your DLL must do is elaborate the Ada code (*note Elaboration + Order Handling in GNAT::). + + To achieve this you must export an initialization routine + (`Initialize_API' in the previous example), which must be invoked + before using any of the DLL services. This elaboration routine must call + the Ada elaboration routine `adainit' generated by the GNAT binder + (*note Binding with Non-Ada Main Programs::). See the body of + `Initialize_Api' for an example. Note that the GNAT binder is + automatically invoked during the DLL build process by the `gnatdll' + tool (*note Using gnatdll::). + + When a DLL is loaded, Windows systematically invokes a routine called + `DllMain'. It would therefore be possible to call `adainit' directly + from `DllMain' without having to provide an explicit initialization + routine. Unfortunately, it is not possible to call `adainit' from the + `DllMain' if your program has library level tasks because access to the + `DllMain' entry point is serialized by the system (that is, only a + single thread can execute "through" it at a time), which means that the + GNAT run time will deadlock waiting for the newly created task to + complete its initialization. + +  + File: gnat_ug_wnt.info, Node: Ada DLLs and Finalization, Next: Creating a Spec for Ada DLLs, Prev: Ada DLLs and Elaboration, Up: Building DLLs with GNAT + + Ada DLLs and Finalization + ------------------------- + + When the services of an Ada DLL are no longer needed, the client code + should invoke the DLL finalization routine, if available. The DLL + finalization routine is in charge of releasing all resources acquired + by the DLL. In the case of the Ada code contained in the DLL, this is + achieved by calling routine `adafinal' generated by the GNAT binder + (*note Binding with Non-Ada Main Programs::). See the body of + `Finalize_Api' for an example. As already pointed out the GNAT binder + is automatically invoked during the DLL build process by the `gnatdll' + tool (*note Using gnatdll::). + + `-g' + Generate debugging information. This information is stored in the object + file and copied from there to the final DLL file by the linker, where + it can be read by the debugger. You must use the `-g' switch if you + plan on using the debugger or the symbolic stack traceback. + +  + File: gnat_ug_wnt.info, Node: Creating a Spec for Ada DLLs, Next: Creating the Definition File, Prev: Ada DLLs and Finalization, Up: Building DLLs with GNAT + + Creating a Spec for Ada DLLs + ---------------------------- + + To use the services exported by the Ada DLL from another programming + language (e.g. C), you have to translate the specs of the exported Ada + entities in that language. For instance in the case of `API.dll', the + corresponding C header file could look like: + + extern int *__imp__count; + #define count (*__imp__count) + int factorial (int); + + It is important to understand that when building an Ada DLL to be used + by other Ada applications, you need two different specs for the packages + contained in the DLL: one for building the DLL and the other for using + the DLL. This is because the `DLL' calling convention is needed to use + a variable defined in a DLL, but when building the DLL, the variable + must have either the `Ada' or `C' calling convention. As an example + consider a DLL comprising the following package `API': + + package API is + Count : Integer := 0; + ... + -- Remainder of the package omitted. + end API; + + After producing a DLL containing package `API', the spec that must be + used to import `API.Count' from Ada code outside of the DLL is: + + package API is + Count : Integer; + pragma Import (DLL, Count); + end API; + +  + File: gnat_ug_wnt.info, Node: Creating the Definition File, Next: Using gnatdll, Prev: Creating a Spec for Ada DLLs, Up: Building DLLs with GNAT + + Creating the Definition File + ---------------------------- + + The definition file is the last file needed to build the DLL. It lists + the exported symbols. As an example, the definition file for a DLL + containing only package `API' (where all the entities are exported with + a `C' calling convention) is: + + EXPORTS + count + factorial + finalize_api + initialize_api + + If the `C' calling convention is missing from package `API', then the + definition file contains the mangled Ada names of the above entities, + which in this case are: + + EXPORTS + api__count + api__factorial + api__finalize_api + api__initialize_api + +  + File: gnat_ug_wnt.info, Node: Using gnatdll, Prev: Creating the Definition File, Up: Building DLLs with GNAT + + Using `gnatdll' + --------------- + + * Menu: + + * gnatdll Example:: + * gnatdll behind the Scenes:: + * Using dlltool:: + + `gnatdll' is a tool to automate the DLL build process once all the Ada + and non-Ada sources that make up your DLL have been compiled. + `gnatdll' is actually in charge of two distinct tasks: build the static + import library for the DLL and the actual DLL. The form of the + `gnatdll' command is + + $ gnatdll [SWITCHES] LIST-OF-FILES [-largs OPTS] + + where list-of-files is a list of ALI and object files. The object file + list must be the exact list of objects corresponding to the non-Ada + sources whose services are to be included in the DLL. The ALI file list + must be the exact list of ALI files for the corresponding Ada sources + whose services are to be included in the DLL. If list-of-files is + missing, only the static import library is generated. + + You may specify any of the following switches to `gnatdll': + + `-a[ADDRESS]' + Build a non-relocatable DLL at ADDRESS. If ADDRESS is not + specified the default address 0X11000000 will be used. By default, + when this switch is missing, `gnatdll' builds relocatable DLL. We + advise the reader to build relocatable DLL. + + `-b ADDRESS' + Set the relocatable DLL base address. By default the address is + 0X11000000. + + `-d DLLFILE' + DLLFILE is the name of the DLL. This switch must be present for + `gnatdll' to do anything. The name of the generated import library + is obtained algorithmically from DLLFILE as shown in the following + example: if DLLFILE is `xyz.dll', the import library name is + `libxyz.a'. The name of the definition file to use (if not + specified by option `-e') is obtained algorithmically from DLLFILE + as shown in the following example: if DLLFILE is `xyz.dll', the + definition file used is `xyz.def'. + + `-e DEFFILE' + DEFFILE is the name of the definition file. + + `-h' + Help mode. Displays `gnatdll' switch usage information. + + `-Idir' + Direct `gnatdll' to search the DIR directory for source and object + files needed to build the DLL. (*note Search Paths and the + Run-Time Library (RTL)::). + + `-k' + Removes the `@'nn suffix from the import library's exported names. + You must specified this option if you want to use a `Stdcall' + function in a DLL for which the `@'nn suffix has been removed. + This is the case for most of the Windows NT DLL for example. This + option has no effect when `-n' option is specified. + + `-l FILE' + The list of ALI and object files used to build the DLL are listed + in FILE, instead of being given in the command line. Each line in + FILE contains the name of an ALI or object file. + + `-n' + No Import. Do not create the import library. + + `-q' + Quiet mode. Do not display unnecessary messages. + + `-v' + Verbose mode. Display extra information. + + `-largs OPTS' + Linker options. Pass OPTS to the linker. + +  + File: gnat_ug_wnt.info, Node: gnatdll Example, Next: gnatdll behind the Scenes, Up: Using gnatdll + + `gnatdll' Example + ................. + + As an example the command to build a relocatable DLL from `api.adb' + once `api.adb' has been compiled and `api.def' created is + + $ gnatdll -d api.dll api.ali + + The above command creates two files: `libapi.a' (the import library) + and `api.dll' (the actual DLL). If you want to create only the DLL, + just type: + + $ gnatdll -d api.dll -n api.ali + + Alternatively if you want to create just the import library, type: + + $ gnatdll -d api.dll + +  + File: gnat_ug_wnt.info, Node: gnatdll behind the Scenes, Next: Using dlltool, Prev: gnatdll Example, Up: Using gnatdll + + `gnatdll' behind the Scenes + ........................... + + This section details the steps involved in creating a DLL. `gnatdll' + does these steps for you. Unless you are interested in understanding + what goes on behind the scenes, you should skip this section. + + We use the previous example of a DLL containing the Ada package + `API', to illustrate the steps necessary to build a DLL. The starting + point is a set of objects that will make up the DLL and the + corresponding ALI files. In the case of this example this means that + `api.o' and `api.ali' are available. To build a relocatable DLL, + `gnatdll' does the following: + + 1. `gnatdll' builds the base file (`api.base'). A base file gives the + information necessary to generate relocation information for the + DLL. + + $ gnatbind -n api + $ gnatlink api -o api.jnk -mdll -Wl,--base-file,api.base + + In addition to the base file, the `gnatlink' command generates an + output file `api.jnk' which can be discarded. The `-mdll' switch + asks `gnatlink' to generate the routines `DllMain' and + `DllMainCRTStartup' that are called by the Windows loader when the + DLL is loaded into memory. + + 2. `gnatdll' uses `dlltool' (*note Using dlltool::) to build the + export table (`api.exp'). The export table contains the relocation + information in a form which can be used during the final link to + ensure that the Windows loader is able to place the DLL anywhere + in memory. + + $ dlltool --dllname api.dll --def api.def --base-file api.base \ + --output-exp api.exp + + 3. `gnatdll' builds the base file using the new export table. Note + that `gnatbind' must be called once again since the binder + generated file has been deleted during the previous call to + `gnatlink'. + + $ gnatbind -n api + $ gnatlink api -o api.jnk api.exp -mdll + -Wl,--base-file,api.base + + 4. `gnatdll' builds the new export table using the new base file and + generates the DLL import library `libAPI.a'. + + $ dlltool --dllname api.dll --def api.def --base-file api.base \ + --output-exp api.exp --output-lib libAPI.a + + 5. Finally `gnatdll' builds the relocatable DLL using the final export + table. + + $ gnatbind -n api + $ gnatlink api api.exp -o api.dll -mdll + +  + File: gnat_ug_wnt.info, Node: Using dlltool, Prev: gnatdll behind the Scenes, Up: Using gnatdll + + Using `dlltool' + ............... + + `dlltool' is the low-level tool used by `gnatdll' to build DLLs and + static import libraries. This section summarizes the most common + `dlltool' switches. The form of the `dlltool' command is + + $ dlltool [SWITCHES] + + `dlltool' switches include: + + `--base-file BASEFILE' + Read the base file BASEFILE generated by the linker. This switch + is used to create a relocatable DLL. + + `--def DEFFILE' + Read the definition file. + + `--dllname NAME' + Gives the name of the DLL. This switch is used to embed the name + of the DLL in the static import library generated by `dlltool' + with switch `--output-lib'. + + `-k' + Kill `@'nn from exported names (*note Windows Calling Conventions:: + for a discussion about `Stdcall'-style symbols. + + `--help' + Prints the `dlltool' switches with a concise description. + + `--output-exp EXPORTFILE' + Generate an export file EXPORTFILE. The export file contains the + export table (list of symbols in the DLL) and is used to create + the DLL. + + `--output-lib libfile' + Generate a static import library LIBFILE. + + `-v' + Verbose mode. + + `--as assembler-name' + Use assembler-name as the assembler. The default is `as'. + +  + File: gnat_ug_wnt.info, Node: GNAT and Windows Resources, Next: Debugging a DLL, Prev: Building DLLs with GNAT, Up: Microsoft Windows Topics + + GNAT and Windows Resources + ========================== + + * Menu: + + * Building Resources:: + * Compiling Resources:: + * Using Resources:: + * Limitations:: + + Resources are an easy way to add Windows specific objects to your + application. The objects that can be added as resources include: + + * menus + + * accelerators + + * dialog boxes + + * string tables + + * bitmaps + + * cursors + + * icons + + * fonts + + This section explains how to build, compile and use resources. + +  + File: gnat_ug_wnt.info, Node: Building Resources, Next: Compiling Resources, Up: GNAT and Windows Resources + + Building Resources + ------------------ + + A resource file is an ASCII file. By convention resource files have an + `.rc' extension. The easiest way to build a resource file is to use + Microsoft tools such as `imagedit.exe' to build bitmaps, icons and + cursors and `dlgedit.exe' to build dialogs. It is always possible to + build an `.rc' file yourself by writing a resource script. + + It is not our objective to explain how to write a resource file. A + complete description of the resource script language can be found in the + Microsoft documentation. + +  + File: gnat_ug_wnt.info, Node: Compiling Resources, Next: Using Resources, Prev: Building Resources, Up: GNAT and Windows Resources + + Compiling Resources + ------------------- + + This section describes how to build a GNAT-compatible (COFF) object file + containing the resources. This is done using the Resource Compiler + `rcl' as follows: + + $ rcl -i myres.rc -o myres.o + + By default `rcl' will run `gcc' to preprocess the `.rc' file. You can + specify an alternate preprocessor (usually named `cpp.exe') using the + `rcl' `-cpp' parameter. A list of all possible options may be obtained + by entering the command `rcl' with no parameters. + + It is also possible to use the Microsoft resource compiler `rc.exe' + to produce a `.res' file (binary resource file). See the corresponding + Microsoft documentation for further details. In this case you need to + use `res2coff' to translate the `.res' file to a GNAT-compatible object + file as follows: + + $ res2coff -i myres.res -o myres.o + +  + File: gnat_ug_wnt.info, Node: Using Resources, Next: Limitations, Prev: Compiling Resources, Up: GNAT and Windows Resources + + Using Resources + --------------- + + To include the resource file in your program just add the + GNAT-compatible object file for the resource(s) to the linker + arguments. With `gnatmake' this is done by using the `-largs' option: + + $ gnatmake myprog -largs myres.o + +  + File: gnat_ug_wnt.info, Node: Limitations, Prev: Using Resources, Up: GNAT and Windows Resources + + Limitations + ----------- + + In this section we describe the current limitations together with + suggestions for workarounds. + + * `rcl' does not handle the `RCINCLUDE' directive. + Workaround: replace `RCINCLUDE' by an `#include' directive. + + * `rcl' does not handle the brackets as block delimiters. + Workaround: replace character '{' by `BEGIN' and '}' by `END'. + Note that Microsoft's `rc' handles both forms of block delimiters. + + * `rcl' does not handle `TypeLib' resources. This type of resource + is used to build COM, DCOM or ActiveX objects. + Workaround: use `rc', the Microsoft resource compiler. + + * It is not possible to use `strip' to remove the debugging symbols + from a program with resources. + Workaround: use linker option `-s' to strip debugging symbols from + the final executable. + +  + File: gnat_ug_wnt.info, Node: Debugging a DLL, Next: GNAT and COM/DCOM Objects, Prev: GNAT and Windows Resources, Up: Microsoft Windows Topics + + Debugging a DLL + =============== + + * Menu: + + * The Program and the DLL Are Built with GCC/GNAT:: + * The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT:: + + Debugging a DLL is similar to debugging a standard program. But we have + to deal with two different executable parts: the DLL and the program + that uses it. We have the following four possibilities: + + 1. The program and the DLL are built with `GCC/GNAT'. + + 2. The program is built with foreign tools and the DLL is built with + `GCC/GNAT'. + + 3. The program is built with `GCC/GNAT' and the DLL is built with + foreign tools. + + 4. + In this section we address only cases one and two above. There is no + point in trying to debug a DLL with `GNU/GDB', if there is no + GDB-compatible debugging information in it. To do so you must use a + debugger compatible with the tools suite used to build the DLL. + +  + File: gnat_ug_wnt.info, Node: The Program and the DLL Are Built with GCC/GNAT, Next: The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT, Up: Debugging a DLL + + The Program and the DLL Are Built with GCC/GNAT + ----------------------------------------------- + + This is the simplest case. Both the DLL and the program have `GDB' + compatible debugging information. It is then possible to break anywhere + in the process. Let's suppose here that the main procedure is named + `ada_main' and that in the DLL there is an entry point named `ada_dll'. + + The DLL (*note Introduction to Dynamic Link Libraries (DLLs)::) and + program must have been built with the debugging information (see GNAT -g + switch). Here are the step-by-step instructions for debugging it: + + 1. Launch `GDB' on the main program. + + $ gdb -nw ada_main + + 2. Break on the main procedure and run the program. + + (gdb) break ada_main + (gdb) run + + This step is required to be able to set a breakpoint inside the + DLL. As long as the program is not run, the DLL is not loaded. + This has the consequence that the DLL debugging information is + also not loaded, so it is not possible to set a breakpoint in the + DLL. + + 3. Set a breakpoint inside the DLL + + (gdb) break ada_dll + (gdb) run + + + At this stage a breakpoint is set inside the DLL. From there on you can + use the standard approach to debug the whole program (*note Running and + Debugging Ada Programs::). + +  + File: gnat_ug_wnt.info, Node: The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT, Prev: The Program and the DLL Are Built with GCC/GNAT, Up: Debugging a DLL + + The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT + ------------------------------------------------------------------------------- + + * Menu: + + * Debugging the DLL Directly:: + * Attaching to a Running Process:: + + In this case things are slightly more complex because it is not + possible to start the main program and then break at the beginning to + load the DLL and the associated DLL debugging information. It is not + possible to break at the beginning of the program because there is no + `GDB' debugging information, and therefore there is no direct way of + getting initial control. This section addresses this issue by + describing some methods that can be used to break somewhere in the DLL + to debug it. + + First suppose that the main procedure is named `main' (this is for + example some C code built with Microsoft Visual C) and that there is a + DLL named `test.dll' containing an Ada entry point named `ada_dll'. + + The DLL (*note Introduction to Dynamic Link Libraries (DLLs)::) must + have been built with debugging information (see GNAT -g option). + +  + File: gnat_ug_wnt.info, Node: Debugging the DLL Directly, Next: Attaching to a Running Process, Up: The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT + + Debugging the DLL Directly + .......................... + + 1. Launch the debugger on the DLL. + + $ gdb -nw test.dll + + 2. Set a breakpoint on a DLL subroutine. + + (gdb) break ada_dll + + 3. Specify the executable file to `GDB'. + + (gdb) exec-file main.exe + + 4. Run the program. + + (gdb) run + + This will run the program until it reaches the breakpoint that has + been set. From that point you can use the standard way to debug a + program as described in (*note Running and Debugging Ada + Programs::). + + + It is also possible to debug the DLL by attaching to a running process. + +  + File: gnat_ug_wnt.info, Node: Attaching to a Running Process, Prev: Debugging the DLL Directly, Up: The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT + + Attaching to a Running Process + .............................. + + With `GDB' it is always possible to debug a running process by + attaching to it. It is possible to debug a DLL this way. The limitation + of this approach is that the DLL must run long enough to perform the + attach operation. It may be useful for instance to insert a time wasting + loop in the code of the DLL to meet this criterion. + + 1. Launch the main program `main.exe'. + + $ main + + 2. Use the Windows Task Manager to find the process ID. Let's say + that the process PID for `main.exe' is 208. + + 3. Launch gdb. + + $ gdb -nw + + 4. Attach to the running process to be debugged. + + (gdb) attach 208 + + 5. Load the process debugging information. + + (gdb) symbol-file main.exe + + 6. Break somewhere in the DLL. + + (gdb) break ada_dll + + 7. Continue process execution. + + (gdb) continue + + + This last step will resume the process execution, and stop at the + breakpoint we have set. From there you can use the standard approach to + debug a program as described in (*note Running and Debugging Ada + Programs::). + +  + File: gnat_ug_wnt.info, Node: GNAT and COM/DCOM Objects, Prev: Debugging a DLL, Up: Microsoft Windows Topics + + GNAT and COM/DCOM Objects + ========================= + + This section is temporarily left blank. + +  + File: gnat_ug_wnt.info, Node: Performance Considerations, Next: GNU Free Documentation License, Prev: Microsoft Windows Topics, Up: Top + + Performance Considerations + ************************** + + The GNAT system provides a number of options that allow a trade-off + between + + * performance of the generated code + + * speed of compilation + + * minimization of dependences and recompilation + + * the degree of run-time checking. + + The defaults (if no options are selected) aim at improving the speed of + compilation and minimizing dependences, at the expense of performance + of the generated code: + + * no optimization + + * no inlining of subprogram calls + + * all run-time checks enabled except overflow and elaboration checks + + These options are suitable for most program development purposes. This + chapter describes how you can modify these choices, and also provides + some guidelines on debugging optimized code. + + * Menu: + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + +  + File: gnat_ug_wnt.info, Node: Controlling Run-Time Checks, Next: Optimization Levels, Up: Performance Considerations + + Controlling Run-Time Checks + =========================== + + By default, GNAT generates all run-time checks, except arithmetic + overflow checking for integer operations and checks for access before + elaboration on subprogram calls. The latter are not required in default + mode, because all necessary checking is done at compile time. Two gnat + switches, `-gnatp' and `-gnato' allow this default to be modified. + *Note Run-Time Checks::. + + Our experience is that the default is suitable for most development + purposes. + + We treat integer overflow specially because these are quite + expensive and in our experience are not as important as other run-time + checks in the development process. Note that division by zero is not + considered an overflow check, and divide by zero checks are generated + where required by default. + + Elaboration checks are off by default, and also not needed by + default, since GNAT uses a static elaboration analysis approach that + avoids the need for run-time checking. This manual contains a full + chapter discussing the issue of elaboration checks, and if the default + is not satisfactory for your use, you should read this chapter. + + For validity checks, the minimal checks required by the Ada Reference + Manual (for case statements and assignments to array elements) are on + by default. These can be suppressed by use of the `-gnatVn' switch. + Note that in Ada 83, there were no validity checks, so if the Ada 83 + mode is acceptable (or when comparing GNAT performance with an Ada 83 + compiler), it may be reasonable to routinely use `-gnatVn'. Validity + checks are also suppressed entirely if `-gnatp' is used. + + Note that the setting of the switches controls the default setting of + the checks. They may be modified using either `pragma Suppress' (to + remove checks) or `pragma Unsuppress' (to add back suppressed checks) + in the program source. + +  + File: gnat_ug_wnt.info, Node: Optimization Levels, Next: Debugging Optimized Code, Prev: Controlling Run-Time Checks, Up: Performance Considerations + + Optimization Levels + =================== + + The default is optimization off. This results in the fastest compile + times, but GNAT makes absolutely no attempt to optimize, and the + generated programs are considerably larger and slower than when + optimization is enabled. You can use the `-ON' switch, where N is an + integer from 0 to 3, on the `gcc' command line to control the + optimization level: + + `-O0' + no optimization (the default) + + `-O1' + medium level optimization + + `-O2' + full optimization + + `-O3' + full optimization, and also attempt automatic inlining of small + subprograms within a unit (*note Inlining of Subprograms::). + + Higher optimization levels perform more global transformations on the + program and apply more expensive analysis algorithms in order to + generate faster and more compact code. The price in compilation time, + and the resulting improvement in execution time, both depend on the + particular application and the hardware environment. You should + experiment to find the best level for your application. + + Note: Unlike some other compilation systems, `gcc' has been tested + extensively at all optimization levels. There are some bugs which + appear only with optimization turned on, but there have also been bugs + which show up only in _unoptimized_ code. Selecting a lower level of + optimization does not improve the reliability of the code generator, + which in practice is highly reliable at all optimization levels. + + Note regarding the use of `-O3': The use of this optimization level + is generally discouraged with GNAT, since it often results in larger + executables which run more slowly. See further discussion of this point + in *note Inlining of Subprograms::. + +  + File: gnat_ug_wnt.info, Node: Debugging Optimized Code, Next: Inlining of Subprograms, Prev: Optimization Levels, Up: Performance Considerations + + Debugging Optimized Code + ======================== + + Since the compiler generates debugging tables for a compilation unit + before it performs optimizations, the optimizing transformations may + invalidate some of the debugging data. You therefore need to + anticipate certain anomalous situations that may arise while debugging + optimized code. This section describes the most common cases. + + 1. The "hopping Program Counter": Repeated 'step' or 'next' commands + show the PC bouncing back and forth in the code. This may result + from any of the following optimizations: + + * Common subexpression elimination: using a single instance of + code for a quantity that the source computes several times. + As a result you may not be able to stop on what looks like a + statement. + + * Invariant code motion: moving an expression that does not + change within a loop, to the beginning of the loop. + + * Instruction scheduling: moving instructions so as to overlap + loads and stores (typically) with other code, or in general + to move computations of values closer to their uses. Often + this causes you to pass an assignment statement without the + assignment happening and then later bounce back to the + statement when the value is actually needed. Placing a + breakpoint on a line of code and then stepping over it may, + therefore, not always cause all the expected side-effects. + + 2. The "big leap": More commonly known as cross-jumping, in which two + identical pieces of code are merged and the program counter + suddenly jumps to a statement that is not supposed to be executed, + simply because it (and the code following) translates to the same + thing as the code that _was_ supposed to be executed. This effect + is typically seen in sequences that end in a jump, such as a + `goto', a `return', or a `break' in a C `switch' statement. + + 3. The "roving variable": The symptom is an unexpected value in a + variable. There are various reasons for this effect: + + * In a subprogram prologue, a parameter may not yet have been + moved to its "home". + + * A variable may be dead, and its register re-used. This is + probably the most common cause. + + * As mentioned above, the assignment of a value to a variable + may have been moved. + + * A variable may be eliminated entirely by value propagation or + other means. In this case, GCC may incorrectly generate + debugging information for the variable + + In general, when an unexpected value appears for a local variable + or parameter you should first ascertain if that value was actually + computed by your program, as opposed to being incorrectly reported + by the debugger. Record fields or array elements in an object + designated by an access value are generally less of a problem, + once you have ascertained that the access value is sensible. + Typically, this means checking variables in the preceding code and + in the calling subprogram to verify that the value observed is + explainable from other values (one must apply the procedure + recursively to those other values); or re-running the code and + stopping a little earlier (perhaps before the call) and stepping + to better see how the variable obtained the value in question; or + continuing to step _from_ the point of the strange value to see if + code motion had simply moved the variable's assignments later. + +  + File: gnat_ug_wnt.info, Node: Inlining of Subprograms, Prev: Debugging Optimized Code, Up: Performance Considerations + + Inlining of Subprograms + ======================= + + A call to a subprogram in the current unit is inlined if all the + following conditions are met: + + * The optimization level is at least `-O1'. + + * The called subprogram is suitable for inlining: It must be small + enough and not contain nested subprograms or anything else that + `gcc' cannot support in inlined subprograms. + + * The call occurs after the definition of the body of the subprogram. + + * Either `pragma Inline' applies to the subprogram or it is small + and automatic inlining (optimization level `-O3') is specified. + + Calls to subprograms in `with''ed units are normally not inlined. To + achieve this level of inlining, the following conditions must all be + true: + + * The optimization level is at least `-O1'. + + * The called subprogram is suitable for inlining: It must be small + enough and not contain nested subprograms or anything else `gcc' + cannot support in inlined subprograms. + + * The call appears in a body (not in a package spec). + + * There is a `pragma Inline' for the subprogram. + + * The `-gnatn' switch is used in the `gcc' command line + + Note that specifying the `-gnatn' switch causes additional + compilation dependencies. Consider the following: + + package R is + procedure Q; + pragma Inline (Q); + end R; + package body R is + ... + end R; + + with R; + procedure Main is + begin + ... + R.Q; + end Main; + + With the default behavior (no `-gnatn' switch specified), the + compilation of the `Main' procedure depends only on its own source, + `main.adb', and the spec of the package in file `r.ads'. This means + that editing the body of `R' does not require recompiling `Main'. + + On the other hand, the call `R.Q' is not inlined under these + circumstances. If the `-gnatn' switch is present when `Main' is + compiled, the call will be inlined if the body of `Q' is small enough, + but now `Main' depends on the body of `R' in `r.adb' as well as on the + spec. This means that if this body is edited, the main program must be + recompiled. Note that this extra dependency occurs whether or not the + call is in fact inlined by `gcc'. + + The use of front end inlining with `-gnatN' generates similar + additional dependencies. + + Note: The `-fno-inline' switch can be used to prevent all inlining. + This switch overrides all other conditions and ensures that no inlining + occurs. The extra dependences resulting from `-gnatn' will still be + active, even if this switch is used to suppress the resulting inlining + actions. + + Note regarding the use of `-O3': There is no difference in inlining + behavior between `-O2' and `-O3' for subprograms with an explicit + pragma `Inline' assuming the use of `-gnatn' or `-gnatN' (the switches + that activate inlining). If you have used pragma `Inline' in + appropriate cases, then it is usually much better to use `-O2' and + `-gnatn' and avoid the use of `-O3' which in this case only has the + effect of inlining subprograms you did not think should be inlined. We + often find that the use of `-O3' slows down code by performing + excessive inlining, leading to increased instruction cache pressure + from the increased code size. So the bottom line here is that you + should not automatically assume that `-O3' is better than `-O2', and + indeed you should use `-O3' only if tests show that it actually + improves performance. + +  + File: gnat_ug_wnt.info, Node: GNU Free Documentation License, Next: Index, Prev: Performance Considerations, Up: Top + + GNU Free Documentation License + ****************************** + + Version 1.2, November 2002 + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. + We recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it + can be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You + accept the license if you copy, modify or distribute the work in a + way requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in + the notice that says that the Document is released under this + License. If a section does not fit the above definition of + Secondary then it is not allowed to be designated as Invariant. + The Document may contain zero Invariant Sections. If the Document + does not identify any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images + composed of pixels) generic paint programs or (for drawings) some + widely available drawing editor, and that is suitable for input to + text formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in an + otherwise Transparent file format whose markup, or absence of + markup, has been arranged to thwart or discourage subsequent + modification by readers is not Transparent. An image format is + not Transparent if used for any substantial amount of text. A + copy that is not "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and + standard-conforming simple HTML, PostScript or PDF designed for + human modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats that + can be read and edited only by proprietary word processors, SGML or + XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML, PostScript or PDF + produced by some word processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow + the conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the + title equally prominent and visible. You may add other material + on the covers in addition. Copying with changes limited to the + covers, as long as they preserve the title of the Document and + satisfy these conditions, can be treated as verbatim copying in + other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a computer-network location from + which the general network-using public has access to download + using public-standard network protocols a complete Transparent + copy of the Document, free of added material. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of + copies, to give them a chance to provide you with an updated + version of the Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with + the Modified Version filling the role of the Document, thus + licensing distribution and modification of the Modified Version to + whoever possesses a copy of it. In addition, you must do these + things in the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of + previous versions (which should, if there were any, be listed + in the History section of the Document). You may use the + same title as a previous version if the original publisher of + that version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on + the Title Page. If there is no section Entitled "History" in + the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, + then add an item describing the Modified Version as stated in + the previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in + the "History" section. You may omit a network location for a + work that was published at least four years before the + Document itself, or if the original publisher of the version + it refers to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the + section all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section + titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end + of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the + documents in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow + this License in all other respects regarding verbatim copying of + that document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warrany Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided for under this License. Any other + attempt to copy, modify, sublicense or distribute the Document is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + `http://www.gnu.org/copyleft/'. + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If + the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. + + ADDENDUM: How to use this License for your documents + ==================================================== + + To use this License in a document you have written, include a copy of + the License in the document and put the following copyright and license + notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover + Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other + combination of the three, merge those two alternatives to suit the + situation. + + If your document contains nontrivial examples of program code, we + recommend releasing these examples in parallel under your choice of + free software license, such as the GNU General Public License, to + permit their use in free software. + +  + File: gnat_ug_wnt.info, Node: Index, Prev: GNU Free Documentation License, Up: Top + + Index + ***** + + * Menu: + + * --GCC= (gnatchop): Switches for gnatchop. + * --GCC=compiler_name (gnatlink): Switches for gnatlink. + * --GCC=compiler_name (gnatmake): Switches for gnatmake. + * --GNATBIND=binder_name (gnatmake): Switches for gnatmake. + * --GNATLINK=linker_name (gnatmake): Switches for gnatmake. + * --LINK= (gnatlink): Switches for gnatlink. + * --RTS (gcc): Switches for gcc. + * --RTS (gnatbind): Summary of Binder Switches. + * --RTS (gnatfind): gnatfind Switches. + * --RTS (gnatls): Switches for gnatls. + * --RTS (gnatmake): Switches for gnatmake. + * --RTS (gnatxref): gnatxref Switches. + * -83 (gnathtml): Converting Ada Files to html with gnathtml. + * -A (gnatbind): Output Control. + * -a (gnatdll): Using gnatdll. + * -A (gnatlink): Switches for gnatlink. + * -a (gnatls): Switches for gnatls. + * -A (gnatmake): Switches for gnatmake. + * -a (gnatmake): Switches for gnatmake. + * -aI (gnatmake): Switches for gnatmake. + * -aL (gnatmake): Switches for gnatmake. + * -aO (gnatmake): Switches for gnatmake. + * -B (gcc): Switches for gcc. + * -b (gcc): Switches for gcc. + * -b (gnatbind): Binder Error Message Control. + * -b (gnatdll): Using gnatdll. + * -B (gnatlink): Switches for gnatlink. + * -b (gnatlink): Switches for gnatlink. + * -b (gnatmake): Switches for gnatmake. + * -bargs (gnatmake): Mode Switches for gnatmake. + * -c (gcc): Switches for gcc. + * -C (gnatbind): Output Control. + * -c (gnatbind): Output Control. + * -c (gnatchop): Switches for gnatchop. + * -C (gnatlink): Switches for gnatlink. + * -C (gnatmake): Switches for gnatmake. + * -c (gnatmake): Switches for gnatmake. + * -c (gnatname): Switches for gnatname. + * -cargs (gnatmake): Mode Switches for gnatmake. + * -d (gnatdll): Using gnatdll. + * -d (gnathtml): Converting Ada Files to html with gnathtml. + * -d (gnatls): Switches for gnatls. + * -D (gnatname): Switches for gnatname. + * -d (gnatname): Switches for gnatname. + * -e (gnatbind): Output Control. + * -e (gnatdll): Using gnatdll. + * -f (gnathtml): Converting Ada Files to html with gnathtml. + * -f (gnatlink): Switches for gnatlink. + * -f (gnatmake): Switches for gnatmake. + * -fno-inline (gcc): Inlining of Subprograms. + * -fstack-check: Stack Overflow Checking. + * -g (gcc): Switches for gcc. + * -g (gnatdll): Ada DLLs and Finalization. + * -g (gnatlink): Switches for gnatlink. + * -gnat83 (gcc): Compiling Ada 83 Programs. + * -gnata (gcc): Debugging and Assertion Control. + * -gnatb (gcc): Output and Error Message Control. + * -gnatc (gcc): Using gcc for Semantic Checking. + * -gnatD (gcc): Debugging Control. + * -gnatdc switch: GNAT Abnormal Termination or Failure to Terminate. + * -gnatE (gcc) <1>: Debugging Control. + * -gnatE (gcc): Run-Time Checks. + * -gnatem (gcc): Units to Sources Mapping Files. + * -gnatf (gcc): Output and Error Message Control. + * -gnatG (gcc): Debugging Control. + * -gnati (gcc): Character Set Control. + * -gnatk (gcc): File Naming Control. + * -gnatl (gcc): Output and Error Message Control. + * -gnatm (gcc): Output and Error Message Control. + * -gnatn (gcc): Inlining of Subprograms. + * -gnatN (gcc): Subprogram Inlining Control. + * -gnatn (gcc): Subprogram Inlining Control. + * -gnatN switch: Source Dependencies. + * -gnatn switch: Source Dependencies. + * -gnato (gcc) <1>: Controlling Run-Time Checks. + * -gnato (gcc): Run-Time Checks. + * -gnatp (gcc) <1>: Controlling Run-Time Checks. + * -gnatp (gcc): Run-Time Checks. + * -gnatq (gcc): Output and Error Message Control. + * -gnatR (gcc): Debugging Control. + * -gnats (gcc): Using gcc for Syntax Checking. + * -gnatt (gcc): Auxiliary Output Control. + * -gnatT (gcc): Run-Time Control. + * -gnatu (gcc): Auxiliary Output Control. + * -gnatU (gcc): Output and Error Message Control. + * -gnatv (gcc): Output and Error Message Control. + * -gnatW (gcc): Character Set Control. + * -gnatwA (gcc): Output and Error Message Control. + * -gnatwa (gcc): Output and Error Message Control. + * -gnatwB (gcc): Output and Error Message Control. + * -gnatwb (gcc): Output and Error Message Control. + * -gnatwC (gcc): Output and Error Message Control. + * -gnatwc (gcc): Output and Error Message Control. + * -gnatwD (gcc): Output and Error Message Control. + * -gnatwd (gcc): Output and Error Message Control. + * -gnatwe (gcc): Output and Error Message Control. + * -gnatwF (gcc): Output and Error Message Control. + * -gnatwf (gcc): Output and Error Message Control. + * -gnatwH (gcc): Output and Error Message Control. + * -gnatwh (gcc): Output and Error Message Control. + * -gnatwI (gcc): Output and Error Message Control. + * -gnatwi (gcc): Output and Error Message Control. + * -gnatwL (gcc): Output and Error Message Control. + * -gnatwl (gcc): Output and Error Message Control. + * -gnatwO (gcc): Output and Error Message Control. + * -gnatwo (gcc): Output and Error Message Control. + * -gnatwP (gcc): Output and Error Message Control. + * -gnatwp (gcc): Output and Error Message Control. + * -gnatwR (gcc): Output and Error Message Control. + * -gnatwr (gcc): Output and Error Message Control. + * -gnatws (gcc): Output and Error Message Control. + * -gnatwU (gcc): Output and Error Message Control. + * -gnatwu (gcc): Output and Error Message Control. + * -gnatx (gcc): Debugging Control. + * -h (gnatbind) <1>: Output Control. + * -h (gnatbind): Elaboration Control. + * -h (gnatdll): Using gnatdll. + * -h (gnatls): Switches for gnatls. + * -h (gnatname): Switches for gnatname. + * -I (gcc): Switches for gcc. + * -I (gnathtml): Converting Ada Files to html with gnathtml. + * -I (gnatmake): Switches for gnatmake. + * -i (gnatmake): Switches for gnatmake. + * -i (gnatmem): Switches for gnatmem. + * -I- (gcc): Switches for gcc. + * -I- (gnatmake): Switches for gnatmake. + * -j (gnatmake): Switches for gnatmake. + * -K (gnatbind): Output Control. + * -k (gnatchop): Switches for gnatchop. + * -k (gnatmake): Switches for gnatmake. + * -l (gnatbind): Output Control. + * -l (gnatdll): Using gnatdll. + * -l (gnathtml): Converting Ada Files to html with gnathtml. + * -L (gnatmake): Switches for gnatmake. + * -l (gnatmake): Switches for gnatmake. + * -largs (gnatdll): Using gnatdll. + * -largs (gnatmake): Mode Switches for gnatmake. + * -M (gnatbind): Binder Error Message Control. + * -m (gnatbind): Binder Error Message Control. + * -M (gnatmake): Switches for gnatmake. + * -m (gnatmake): Switches for gnatmake. + * -mwindows: CONSOLE and WINDOWS subsystems. + * -n (gnatbind): Binding with Non-Ada Main Programs. + * -n (gnatdll): Using gnatdll. + * -n (gnatlink): Switches for gnatlink. + * -n (gnatmake): Switches for gnatmake. + * -nostdinc (gnatmake): Switches for gnatmake. + * -nostdlib (gnatmake): Switches for gnatmake. + * -O (gcc) <1>: Optimization Levels. + * -O (gcc): Switches for gcc. + * -o (gcc): Switches for gcc. + * -o (gnatbind): Output Control. + * -O (gnatbind): Output Control. + * -o (gnathtml): Converting Ada Files to html with gnathtml. + * -o (gnatlink): Switches for gnatlink. + * -o (gnatls): Switches for gnatls. + * -o (gnatmake): Switches for gnatmake. + * -o (gnatmem): Switches for gnatmem. + * -p (gnatchop): Switches for gnatchop. + * -p (gnathtml): Converting Ada Files to html with gnathtml. + * -P (gnatname): Switches for gnatname. + * -pass-exit-codes (gcc): Auxiliary Output Control. + * -q (gnatchop): Switches for gnatchop. + * -q (gnatdll): Using gnatdll. + * -q (gnatmake): Switches for gnatmake. + * -q (gnatmem): Switches for gnatmem. + * -r (gnatbind): Output Control. + * -r (gnatchop): Switches for gnatchop. + * -S (gcc): Switches for gcc. + * -s (gnatbind): Consistency-Checking Modes. + * -s (gnatls): Switches for gnatls. + * -s (gnatmake): Switches for gnatmake. + * -sc (gnathtml): Converting Ada Files to html with gnathtml. + * -t (gnatbind): Binder Error Message Control. + * -t (gnathtml): Converting Ada Files to html with gnathtml. + * -u (gnatls): Switches for gnatls. + * -u (gnatmake): Switches for gnatmake. + * -V (gcc): Switches for gcc. + * -v (gcc): Switches for gcc. + * -v (gnatbind): Binder Error Message Control. + * -v (gnatchop): Switches for gnatchop. + * -v (gnatdll): Using gnatdll. + * -v (gnatlink): Switches for gnatlink. + * -v (gnatmake): Switches for gnatmake. + * -v (gnatname): Switches for gnatname. + * -v -v (gnatlink): Switches for gnatlink. + * -w: Output and Error Message Control. + * -w (gnatchop): Switches for gnatchop. + * -we (gnatbind): Binder Error Message Control. + * -ws (gnatbind): Binder Error Message Control. + * -x (gnatbind): Consistency-Checking Modes. + * -z (gnatbind): Binding Programs with No Main Subprogram. + * -z (gnatmake): Switches for gnatmake. + * .def: The Definition File. + * __gnat_finalize: Running gnatbind. + * __gnat_initialize: Running gnatbind. + * __gnat_set_globals: Running gnatbind. + * _main: The External Symbol Naming Scheme of GNAT. + * Access before elaboration: Run-Time Checks. + * Access-to-subprogram: Elaboration for Access-to-Subprogram Values. + * ACVC, Ada 83 tests: Compiling Ada 83 Programs. + * Ada <1>: Naming Conventions for GNAT Source Files. + * Ada: Search Paths for gnatbind. + * Ada 83 compatibility: Compiling Ada 83 Programs. + * Ada 95 Language Reference Manual: What You Should Know before Reading This Guide. + * Ada expressions: Using Ada Expressions. + * Ada Library Information files: The Ada Library Information Files. + * Ada.Characters.Latin_1: Latin-1. + * ADA_INCLUDE_PATH: Search Paths and the Run-Time Library (RTL). + * ADA_OBJECTS_PATH: Search Paths for gnatbind. + * adafinal <1>: Binding with Non-Ada Main Programs. + * adafinal: Running gnatbind. + * adainit <1>: Binding with Non-Ada Main Programs. + * adainit: Running gnatbind. + * Address Clauses, warnings: Output and Error Message Control. + * ali files: The Ada Library Information Files. + * Annex A: Naming Conventions for GNAT Source Files. + * Annex B: Naming Conventions for GNAT Source Files. + * APIENTRY: Windows Calling Conventions. + * Arbitrary File Naming Conventions: Handling Arbitrary File Naming Conventions Using gnatname. + * Asm: Calling Conventions. + * Assert: Debugging and Assertion Control. + * Assertions: Debugging and Assertion Control. + * Biased rounding: Output and Error Message Control. + * Binder consistency checks: Binder Error Message Control. + * Binder output file: Interfacing to C. + * Binder, multiple input files: Binding with Non-Ada Main Programs. + * Breakpoints and tasks: Ada Tasks. + * C: Calling Conventions. + * C++: Calling Conventions. + * Calling Conventions: Calling Conventions. + * Check, elaboration: Run-Time Checks. + * Check, overflow: Run-Time Checks. + * Check_CPU procedure: Check_CPU Procedure. + * Checks, access before elaboration: Run-Time Checks. + * Checks, division by zero: Run-Time Checks. + * Checks, elaboration: Checking the Elaboration Order in Ada 95. + * Checks, overflow: Controlling Run-Time Checks. + * Checks, suppressing: Run-Time Checks. + * COBOL: Calling Conventions. + * code page 437: Other 8-Bit Codes. + * code page 850: Other 8-Bit Codes. + * COM: GNAT and COM/DCOM Objects. + * Combining GNAT switches: Switches for gcc. + * Command line length: Switches for gnatlink. + * Compilation model: The GNAT Compilation Model. + * Conditionals, constant: Output and Error Message Control. + * Configuration pragmas: Configuration Pragmas. + * Consistency checks, in binder: Binder Error Message Control. + * CONSOLE Subsystem: CONSOLE and WINDOWS subsystems. + * Convention Ada: Calling Conventions. + * Convention Asm: Calling Conventions. + * Convention Assembler: Calling Conventions. + * Convention C: Calling Conventions. + * Convention C++: Calling Conventions. + * Convention COBOL: Calling Conventions. + * Convention Default: Calling Conventions. + * Convention DLL: Calling Conventions. + * Convention External: Calling Conventions. + * Convention Fortran: Calling Conventions. + * Convention Stdcall: Calling Conventions. + * Convention Stubbed: Calling Conventions. + * Convention Win32: Calling Conventions. + * Conventions: Conventions. + * CR: Source Representation. + * Cyrillic: Other 8-Bit Codes. + * DCOM: GNAT and COM/DCOM Objects. + * Debug: Debugging and Assertion Control. + * Debug Pool: Finding Memory Problems with GNAT Debug Pool. + * Debugger: Running and Debugging Ada Programs. + * Debugging: Running and Debugging Ada Programs. + * Debugging Generic Units: Debugging Generic Units. + * Debugging information, including: Switches for gnatlink. + * Debugging options: Debugging Control. + * Default: Calling Conventions. + * Definition file: The Definition File. + * Dependencies, producing list: Switches for gnatmake. + * Dependency rules: The GNAT Make Program gnatmake. + * Dereferencing, implicit: Output and Error Message Control. + * Division by zero: Run-Time Checks. + * DLL <1>: Introduction to Dynamic Link Libraries (DLLs). + * DLL: Calling Conventions. + * DLL debugging: Debugging a DLL. + * DLL debugging, attach to process: Attaching to a Running Process. + * DLLs and elaboration: Ada DLLs and Elaboration. + * DLLs and finalization: Ada DLLs and Finalization. + * DLLs, building: Building DLLs with GNAT. + * Elaborate: Controlling the Elaboration Order in Ada 95. + * Elaborate_All: Controlling the Elaboration Order in Ada 95. + * Elaborate_Body: Controlling the Elaboration Order in Ada 95. + * Elaboration checks <1>: Checking the Elaboration Order in Ada 95. + * Elaboration checks: Run-Time Checks. + * Elaboration control <1>: Summary of Procedures for Elaboration Control. + * Elaboration control: Elaboration Order Handling in GNAT. + * Elaboration of library tasks: Elaboration Issues for Library Tasks. + * Elaboration order control: Comparison between GNAT and C/C++ Compilation Models. + * Elaboration, warnings: Output and Error Message Control. + * Eliminate: Eliminate Pragma. + * End of source file: Source Representation. + * Error messages, suppressing: Output and Error Message Control. + * EUC Coding: Wide Character Encodings. + * Exceptions: Ada Exceptions. + * Export: The External Symbol Naming Scheme of GNAT. + * Export table: Exporting Ada Entities. + * External: Calling Conventions. + * FDL, GNU Free Documentation License: GNU Free Documentation License. + * FF: Source Representation. + * File names <1>: Alternative File Naming Schemes. + * File names: Using Other File Names. + * File naming schemes, alternative: Alternative File Naming Schemes. + * Foreign Languages: Calling Conventions. + * Formals, unreferenced: Output and Error Message Control. + * Fortran: Calling Conventions. + * gdb: Running and Debugging Ada Programs. + * Generic formal parameters: Compiling Ada 83 Programs. + * Generics <1>: Debugging Generic Units. + * Generics: Generating Object Files. + * Glide: Introduction to Glide and GVD. + * GMEM (gnatmem): Running gnatmem (GMEM Mode). + * GNAT <1>: Naming Conventions for GNAT Source Files. + * GNAT: Search Paths for gnatbind. + * GNAT Abnormal Termination or Failure to Terminate: GNAT Abnormal Termination or Failure to Terminate. + * GNAT compilation model: The GNAT Compilation Model. + * GNAT library: Comparison between GNAT and Conventional Ada Library Models. + * GNAT Setup Tool: GNAT Setup Tool. + * gnat.adc <1>: The Configuration Pragmas Files. + * gnat.adc: Using Other File Names. + * gnat1: Compiling Programs. + * gnat_argc: Command-Line Access. + * gnat_argv: Command-Line Access. + * GNAT_STACK_LIMIT: Stack Overflow Checking. + * gnatbind: Binding Using gnatbind. + * gnatchop: Renaming Files Using gnatchop. + * gnatdll: Using gnatdll. + * gnatelim: Reducing the Size of Ada Executables with gnatelim. + * gnatfind: The Cross-Referencing Tools gnatxref and gnatfind. + * gnatkr: File Name Krunching Using gnatkr. + * gnatlink: Linking Using gnatlink. + * gnatls: The GNAT Library Browser gnatls. + * gnatmake: The GNAT Make Program gnatmake. + * gnatmem: Finding Memory Problems with gnatmem. + * gnatprep: Preprocessing Using gnatprep. + * gnatreg: GNAT Setup Tool. + * gnatstub: Creating Sample Bodies Using gnatstub. + * gnatxref: The Cross-Referencing Tools gnatxref and gnatfind. + * GNU make: Using gnatmake in a Makefile. + * GVD: Introduction to Glide and GVD. + * Hiding of Declarations: Output and Error Message Control. + * HT: Source Representation. + * Implicit dereferencing: Output and Error Message Control. + * Import library: Creating an Import Library. + * Inline <1>: Inlining of Subprograms. + * Inline: Source Dependencies. + * Inlining: Comparison between GNAT and Conventional Ada Library Models. + * Inlining, warnings: Output and Error Message Control. + * Intel_CPU package body: Intel_CPU Package Body. + * Intel_CPU package specification: Intel_CPU Package Specification. + * Interfaces <1>: Naming Conventions for GNAT Source Files. + * Interfaces: Search Paths for gnatbind. + * Interfacing to Ada: Calling Conventions. + * Interfacing to Assembly: Calling Conventions. + * Interfacing to C: Calling Conventions. + * Interfacing to C++: Calling Conventions. + * Interfacing to COBOL: Calling Conventions. + * Interfacing to Fortran: Calling Conventions. + * Internal trees, writing to file: Auxiliary Output Control. + * Latin-1 <1>: Latin-1. + * Latin-1: Source Representation. + * Latin-2: Other 8-Bit Codes. + * Latin-3: Other 8-Bit Codes. + * Latin-4: Other 8-Bit Codes. + * Latin-5: Other 8-Bit Codes. + * LF: Source Representation. + * Library browser: The GNAT Library Browser gnatls. + * Library tasks, elaboration issues: Elaboration Issues for Library Tasks. + * Library, building, installing: GNAT and Libraries. + * Linker libraries: Switches for gnatmake. + * Machine_Overflows: Run-Time Checks. + * Main Program: Running gnatbind. + * make: Using the GNU make Utility. + * makefile: Using gnatmake in a Makefile. + * Mixed Language Programming: Mixed Language Programming. + * Multiple units, syntax checking: Using gcc for Syntax Checking. + * n (gnatmem): Switches for gnatmem. + * No code generated: Compiling Programs. + * No_Entry_Calls_In_Elaboration_Code: Elaboration Issues for Library Tasks. + * Object file list: Running gnatbind. + * Order of elaboration: Elaboration Order Handling in GNAT. + * Other Ada compilers: Calling Conventions. + * Overflow checks <1>: Controlling Run-Time Checks. + * Overflow checks: Run-Time Checks. + * Parallel make: Switches for gnatmake. + * Performance: Performance Considerations. + * pragma Elaborate: Controlling the Elaboration Order in Ada 95. + * pragma Elaborate_All: Controlling the Elaboration Order in Ada 95. + * pragma Elaborate_Body: Controlling the Elaboration Order in Ada 95. + * pragma Inline: Inlining of Subprograms. + * pragma Preelaborate: Controlling the Elaboration Order in Ada 95. + * pragma Pure: Controlling the Elaboration Order in Ada 95. + * pragma Suppress: Controlling Run-Time Checks. + * pragma Unsuppress: Controlling Run-Time Checks. + * Pragmas, configuration: Configuration Pragmas. + * Preelaborate: Controlling the Elaboration Order in Ada 95. + * Pure: Controlling the Elaboration Order in Ada 95. + * rc: Compiling Resources. + * rcl: Compiling Resources. + * Recompilation, by gnatmake: Notes on the Command Line. + * res2coff: Compiling Resources. + * Resources, building: Building Resources. + * Resources, compiling: Compiling Resources. + * Resources, limitations: Limitations. + * Resources, using: Using Resources. + * Resources, windows: GNAT and Windows Resources. + * Rounding, biased: Output and Error Message Control. + * RTL: Switches for gcc. + * SDP_Table_Build: Running gnatbind. + * Search paths, for gnatmake: Switches for gnatmake. + * Setup Tool: GNAT Setup Tool. + * Shift JIS Coding: Wide Character Encodings. + * Source file, end: Source Representation. + * Source files, suppressing search: Switches for gnatmake. + * Source files, use by binder: Running gnatbind. + * Source_File_Name pragma <1>: Alternative File Naming Schemes. + * Source_File_Name pragma: Using Other File Names. + * Source_Reference: Switches for gnatchop. + * Stack Overflow Checking: Stack Overflow Checking. + * stack traceback: Stack Traceback. + * stack unwinding: Stack Traceback. + * Stdcall <1>: Windows Calling Conventions. + * Stdcall: Calling Conventions. + * stderr: Output and Error Message Control. + * stdout: Output and Error Message Control. + * storage, pool, memory corruption: Finding Memory Problems with GNAT Debug Pool. + * Stubbed: Calling Conventions. + * Style checking: Style Checking. + * SUB: Source Representation. + * Subunits: Generating Object Files. + * Suppress <1>: Controlling Run-Time Checks. + * Suppress: Run-Time Checks. + * Suppressing checks: Run-Time Checks. + * System <1>: Naming Conventions for GNAT Source Files. + * System: Search Paths for gnatbind. + * System.IO: Search Paths and the Run-Time Library (RTL). + * Task switching: Ada Tasks. + * Tasks: Ada Tasks. + * Temporary files: Temporary Files. + * Time Slicing: Run-Time Control. + * Time stamp checks, in binder: Binder Error Message Control. + * traceback: Stack Traceback. + * traceback, non-symbolic: Non-Symbolic Traceback. + * traceback, symbolic: Symbolic Traceback. + * Tree file: Tree Files. + * Typographical conventions: Conventions. + * Unsuppress <1>: Controlling Run-Time Checks. + * Unsuppress: Run-Time Checks. + * Upper-Half Coding: Wide Character Encodings. + * Validity Checking: Validity Checking. + * Version skew (avoided by gnatmake): Running a Simple Ada Program. + * Volatile parameter: The Volatile Parameter. + * VT: Source Representation. + * Warning messages: Output and Error Message Control. + * Warnings: Binder Error Message Control. + * Warnings, treat as error: Output and Error Message Control. + * Win32: Calling Conventions. + * Windows 95: Microsoft Windows Topics. + * Windows 98: Microsoft Windows Topics. + * Windows NT: Microsoft Windows Topics. + * WINDOWS Subsystem: CONSOLE and WINDOWS subsystems. + * Writing internal trees: Auxiliary Output Control. + * Zero Cost Exceptions: Running gnatbind. + + +  + Tag Table: + Node: Top91 + Node: About This Guide9255 + Node: What This Guide Contains9764 + Node: What You Should Know before Reading This Guide14109 + Node: Related Information14517 + Node: Conventions15240 + Node: Getting Started with GNAT16134 + Node: Running GNAT16575 + Node: Running a Simple Ada Program17177 + Node: Running a Program with Multiple Units20531 + Node: Using the gnatmake Utility22762 + Node: Introduction to Glide and GVD25162 + Node: Building a New Program with Glide25904 + Node: Simple Debugging with GVD31242 + Node: Other Glide Features34279 + Node: The GNAT Compilation Model36162 + Node: Source Representation37492 + Node: Foreign Language Representation39278 + Node: Latin-139764 + Node: Other 8-Bit Codes40630 + Node: Wide Character Encodings42723 + Node: File Naming Rules46529 + Node: Using Other File Names48818 + Node: Alternative File Naming Schemes51171 + Node: Generating Object Files56403 + Node: Source Dependencies59117 + Node: The Ada Library Information Files62640 + Node: Binding an Ada Program64773 + Node: Mixed Language Programming66621 + Node: Interfacing to C66898 + Node: Calling Conventions69404 + Node: Building Mixed Ada & C++ Programs75328 + Node: Interfacing to C++76409 + Node: Linking a Mixed C++ & Ada Program77449 + Node: A Simple Example80483 + Node: Adapting the Run Time to a New C++ Compiler83395 + Node: Comparison between GNAT and C/C++ Compilation Models84411 + Node: Comparison between GNAT and Conventional Ada Library Models86140 + Node: Compiling Using gcc88791 + Node: Compiling Programs89286 + Node: Switches for gcc92236 + Node: Output and Error Message Control101420 + Node: Debugging and Assertion Control119506 + Node: Validity Checking120836 + Node: Style Checking126983 + Node: Run-Time Checks138456 + Node: Stack Overflow Checking142440 + Node: Run-Time Control144527 + Node: Using gcc for Syntax Checking145421 + Node: Using gcc for Semantic Checking146920 + Node: Compiling Ada 83 Programs148398 + Node: Character Set Control149819 + Node: File Naming Control152746 + Node: Subprogram Inlining Control153254 + Node: Auxiliary Output Control154595 + Node: Debugging Control156026 + Node: Units to Sources Mapping Files163466 + Node: Search Paths and the Run-Time Library (RTL)164856 + Node: Order of Compilation Issues168027 + Node: Examples169728 + Node: Binding Using gnatbind170296 + Node: Running gnatbind172158 + Node: Generating the Binder Program in C202919 + Node: Consistency-Checking Modes220364 + Node: Binder Error Message Control221859 + Node: Elaboration Control224125 + Node: Output Control225350 + Node: Binding with Non-Ada Main Programs227791 + Node: Binding Programs with No Main Subprogram230931 + Node: Summary of Binder Switches231754 + Node: Command-Line Access235203 + Node: Search Paths for gnatbind236208 + Node: Examples of gnatbind Usage238774 + Node: Linking Using gnatlink240545 + Node: Running gnatlink241284 + Node: Switches for gnatlink243269 + Node: Setting Stack Size from gnatlink247542 + Node: Setting Heap Size from gnatlink248396 + Node: The GNAT Make Program gnatmake249211 + Node: Running gnatmake250662 + Node: Switches for gnatmake252321 + Node: Mode Switches for gnatmake265411 + Node: Notes on the Command Line266569 + Node: How gnatmake Works269465 + Node: Examples of gnatmake Usage271635 + Node: Renaming Files Using gnatchop272762 + Node: Handling Files with Multiple Units273351 + Node: Operating gnatchop in Compilation Mode274672 + Node: Command Line for gnatchop277995 + Node: Switches for gnatchop279460 + Node: Examples of gnatchop Usage283241 + Node: Configuration Pragmas284600 + Node: Handling of Configuration Pragmas286152 + Node: The Configuration Pragmas Files287011 + Node: Handling Arbitrary File Naming Conventions Using gnatname288374 + Node: Arbitrary File Naming Conventions288782 + Node: Running gnatname290043 + Node: Switches for gnatname291502 + Node: Examples of gnatname Usage294636 + Node: GNAT Project Manager295437 + Node: Introduction296099 + Node: Project Files297195 + Node: Examples of Project Files300398 + Node: Common Sources with Different Switches and Different Output Directories300872 + Node: Source Files303903 + Node: Specifying the Object Directory304379 + Node: Specifying the Exec Directory305311 + Node: Project File Packages306079 + Node: Specifying Switch Settings307088 + Node: Main Subprograms309056 + Node: Source File Naming Conventions309720 + Node: Source Language(s)310220 + Node: Using External Variables310661 + Node: Importing Other Projects313502 + Node: Extending a Project316610 + Node: Project File Syntax319081 + Node: Basic Syntax320443 + Node: Packages321451 + Node: Expressions322605 + Node: String Types324503 + Node: Variables325806 + Node: Attributes328834 + Node: Associative Array Attributes334267 + Node: case Constructions335112 + Node: Objects and Sources in Project Files336909 + Node: Object Directory337489 + Node: Exec Directory338480 + Node: Source Directories339309 + Node: Source File Names340676 + Node: Importing Projects343013 + Node: Project Extension345792 + Node: External References in Project Files347471 + Node: Packages in Project Files349214 + Node: Variables from Imported Projects351610 + Node: Naming Schemes353282 + Node: Library Projects357255 + Node: Switches Related to Project Files360149 + Node: Tools Supporting Project Files361853 + Node: gnatmake and Project Files362185 + Node: Switches and Project Files362638 + Node: Project Files and Main Subprograms368382 + Node: The GNAT Driver and Project Files370307 + Node: Glide and Project Files373975 + Node: An Extended Example374614 + Node: Project File Complete Syntax377609 + Node: Elaboration Order Handling in GNAT380401 + Node: Elaboration Code in Ada 95381421 + Node: Checking the Elaboration Order in Ada 95386067 + Node: Controlling the Elaboration Order in Ada 95390068 + Node: Controlling Elaboration in GNAT - Internal Calls398385 + Node: Controlling Elaboration in GNAT - External Calls404092 + Node: Default Behavior in GNAT - Ensuring Safety407826 + Node: Elaboration Issues for Library Tasks411909 + Node: Mixing Elaboration Models425114 + Node: What to Do If the Default Elaboration Behavior Fails427615 + Node: Elaboration for Access-to-Subprogram Values437930 + Node: Summary of Procedures for Elaboration Control439737 + Node: Other Elaboration Order Considerations440900 + Node: The Cross-Referencing Tools gnatxref and gnatfind446129 + Node: gnatxref Switches447793 + Node: gnatfind Switches451232 + Node: Project Files for gnatxref and gnatfind456828 + Node: Regular Expressions in gnatfind and gnatxref459934 + Node: Examples of gnatxref Usage462713 + Node: Examples of gnatfind Usage466512 + Node: File Name Krunching Using gnatkr468715 + Node: About gnatkr469329 + Node: Using gnatkr470651 + Node: Krunching Method471542 + Node: Examples of gnatkr Usage474779 + Node: Preprocessing Using gnatprep475269 + Node: Using gnatprep475780 + Node: Switches for gnatprep476632 + Node: Form of Definitions File478754 + Node: Form of Input Text for gnatprep479493 + Node: The GNAT Library Browser gnatls483112 + Node: Running gnatls483641 + Node: Switches for gnatls486151 + Node: Examples of gnatls Usage488046 + Node: GNAT and Libraries490235 + Node: Creating an Ada Library490763 + Node: Installing an Ada Library493603 + Node: Using an Ada Library495960 + Node: Creating an Ada Library to be Used in a Non-Ada Context497151 + Node: Rebuilding the GNAT Run-Time Library503119 + Node: Using the GNU make Utility504026 + Node: Using gnatmake in a Makefile504872 + Node: Automatically Creating a List of Directories509080 + Node: Generating the Command Line Switches512218 + Node: Overcoming Command Line Length Limits513196 + Node: Finding Memory Problems with gnatmem515501 + Node: Running gnatmem (GDB Mode)516852 + Node: Running gnatmem (GMEM Mode)519289 + Node: Switches for gnatmem520547 + Node: Examples of gnatmem Usage521655 + Node: GDB and GMEM Modes526879 + Node: Implementation Note527520 + Node: gnatmem Using GDB Mode527750 + Node: gnatmem Using GMEM Mode529163 + Node: Finding Memory Problems with GNAT Debug Pool529809 + Node: Creating Sample Bodies Using gnatstub534513 + Node: Running gnatstub535308 + Node: Switches for gnatstub536062 + Node: Reducing the Size of Ada Executables with gnatelim538194 + Node: About gnatelim538727 + Node: Eliminate Pragma539815 + Node: Tree Files540823 + Node: Preparing Tree and Bind Files for gnatelim541712 + Node: Running gnatelim543714 + Node: Correcting the List of Eliminate Pragmas545709 + Node: Making Your Executables Smaller546490 + Node: Summary of the gnatelim Usage Cycle547312 + Node: Other Utility Programs548121 + Node: Using Other Utility Programs with GNAT548649 + Node: The gnatpsta Utility Program549337 + Node: The External Symbol Naming Scheme of GNAT550631 + Node: Ada Mode for Glide552628 + Node: Converting Ada Files to html with gnathtml554579 + Node: Installing gnathtml558152 + Node: Running and Debugging Ada Programs558816 + Node: The GNAT Debugger GDB560210 + Node: Running GDB563328 + Node: Introduction to GDB Commands564344 + Node: Using Ada Expressions569209 + Node: Calling User-Defined Subprograms570403 + Node: Using the Next Command in a Function572823 + Node: Ada Exceptions573988 + Node: Ada Tasks574942 + Node: Debugging Generic Units577005 + Node: GNAT Abnormal Termination or Failure to Terminate578408 + Node: Naming Conventions for GNAT Source Files580987 + Node: Getting Internal Debugging Information583578 + Node: Stack Traceback584780 + Node: Non-Symbolic Traceback585817 + Node: Tracebacks From an Unhandled Exception586278 + Node: Tracebacks From Exception Occurrences (non-symbolic)590354 + Node: Tracebacks From Anywhere in a Program (non-symbolic)591637 + Node: Symbolic Traceback593480 + Node: Tracebacks From Exception Occurrences (symbolic)594203 + Node: Tracebacks From Anywhere in a Program (symbolic)595612 + Node: Inline Assembler596804 + Node: Basic Assembler Syntax598500 + Node: A Simple Example of Inline Assembler600277 + Node: Output Variables in Inline Assembler603444 + Node: Input Variables in Inline Assembler610824 + Node: Inlining Inline Assembler Code613332 + Node: Other Asm Functionality615266 + Node: The Clobber Parameter615701 + Node: The Volatile Parameter617700 + Node: A Complete Example618892 + Node: Check_CPU Procedure619866 + Node: Intel_CPU Package Specification634913 + Node: Intel_CPU Package Body644341 + Node: Microsoft Windows Topics653499 + Node: Using GNAT on Windows654149 + Node: GNAT Setup Tool655920 + Node: Command-line arguments656638 + Node: Creating a network installation of GNAT657135 + Node: Registering and unregistering additional libraries658121 + Node: CONSOLE and WINDOWS subsystems658811 + Node: Temporary Files659435 + Node: Mixed-Language Programming on Windows660239 + Node: Windows Calling Conventions662380 + Node: C Calling Convention663233 + Node: Stdcall Calling Convention664759 + Node: DLL Calling Convention667313 + Node: Introduction to Dynamic Link Libraries (DLLs)668045 + Node: Using DLLs with GNAT671250 + Node: Creating an Ada Spec for the DLL Services673049 + Node: Creating an Import Library674305 + Node: The Definition File674760 + Node: GNAT-Style Import Library676104 + Node: Microsoft-Style Import Library678218 + Node: Building DLLs with GNAT679358 + Node: Limitations When Using Ada DLLs from Ada681446 + Node: Exporting Ada Entities682474 + Node: Ada DLLs and Elaboration685325 + Node: Ada DLLs and Finalization686846 + Node: Creating a Spec for Ada DLLs687918 + Node: Creating the Definition File689323 + Node: Using gnatdll690148 + Node: gnatdll Example693175 + Node: gnatdll behind the Scenes693760 + Node: Using dlltool696236 + Node: GNAT and Windows Resources697558 + Node: Building Resources698172 + Node: Compiling Resources698831 + Node: Using Resources699809 + Node: Limitations700203 + Node: Debugging a DLL701139 + Node: The Program and the DLL Are Built with GCC/GNAT702171 + Node: The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT703674 + Node: Debugging the DLL Directly704934 + Node: Attaching to a Running Process705740 + Node: GNAT and COM/DCOM Objects707043 + Node: Performance Considerations707252 + Node: Controlling Run-Time Checks708294 + Node: Optimization Levels710279 + Node: Debugging Optimized Code712136 + Node: Inlining of Subprograms715869 + Node: GNU Free Documentation License719393 + Node: Index741822 +  + End Tag Table diff -Nrc3pad gcc-3.2.3/gcc/ada/gnat_ug_wnt.texi gcc-3.3/gcc/ada/gnat_ug_wnt.texi *** gcc-3.2.3/gcc/ada/gnat_ug_wnt.texi 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnat_ug_wnt.texi 2003-05-14 00:31:43.000000000 +0000 *************** *** 0 **** --- 1,20661 ---- + \input texinfo @c -*-texinfo-*- + @c %**start of header + + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + @c o + @c GNAT DOCUMENTATION o + @c o + @c G N A T _ U G o + @c o + @c Copyright (C) 1992-2002 Ada Core Technologies, Inc. o + @c o + @c GNAT is free software; you can redistribute it and/or modify it under o + @c terms of the GNU General Public License as published by the Free Soft- o + @c ware Foundation; either version 2, or (at your option) any later ver- o + @c sion. GNAT is distributed in the hope that it will be useful, but WITH- o + @c OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY o + @c or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License o + @c for more details. You should have received a copy of the GNU General o + @c Public License distributed with GNAT; see file COPYING. If not, write o + @c to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, o + @c MA 02111-1307, USA. o + @c o + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + @c + @c GNAT_UG Style Guide + @c + @c 1. Always put a @noindent on the line before the first paragraph + @c after any of these commands: + @c + @c @chapter + @c @section + @c @subsection + @c @subsubsection + @c @subsubsubsection + @c + @c @end smallexample + @c @end itemize + @c @end enumerate + @c + @c 2. DO NOT use @example. Use @smallexample instead. + @c + @c 3. Each @chapter, @section, @subsection, @subsubsection, etc. + @c command must be preceded by two empty lines + @c + @c 4. The @item command must be on a line of its own if it is in an + @c @itemize or @enumerate command. + @c + @c 5. When talking about ALI files use "ALI" (all uppercase), not "Ali" + @c or "ali". + @c + @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo + + + @setfilename gnat_ug_wnt.info + @settitle GNAT User's Guide for Windows NT + + + + @include gcc-common.texi + + @setchapternewpage odd + @syncodeindex fn cp + @c %**end of header + + @copying + Copyright @copyright{} 1995-2002, Free Software Foundation + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with the Invariant Sections being ``GNU Free Documentation License'', with the + Front-Cover Texts being + ``GNAT User's Guide for Windows NT'', + and with no Back-Cover Texts. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + @end copying + + @titlepage + + + @title GNAT User's Guide + @center @titlefont{for Windows NT} + + + + @subtitle GNAT, The GNU Ada 95 Compiler + @subtitle GNAT Version for GCC @value{version-GCC} + + @author Ada Core Technologies, Inc. + + @page + @vskip 0pt plus 1filll + + @insertcopying + + @end titlepage + + @ifnottex + @node Top, About This Guide, (dir), (dir) + @top GNAT User's Guide + + + GNAT User's Guide for Windows NT + + + + GNAT, The GNU Ada 95 Compiler + + GNAT Version for GCC @value{version-GCC} + + Ada Core Technologies, Inc. + + @insertcopying + + @menu + * About This Guide:: + * Getting Started with GNAT:: + * The GNAT Compilation Model:: + * Compiling Using gcc:: + * Binding Using gnatbind:: + * Linking Using gnatlink:: + * The GNAT Make Program gnatmake:: + * Renaming Files Using gnatchop:: + * Configuration Pragmas:: + * Handling Arbitrary File Naming Conventions Using gnatname:: + * GNAT Project Manager:: + * Elaboration Order Handling in GNAT:: + * The Cross-Referencing Tools gnatxref and gnatfind:: + * File Name Krunching Using gnatkr:: + * Preprocessing Using gnatprep:: + * The GNAT Library Browser gnatls:: + * GNAT and Libraries:: + * Using the GNU make Utility:: + * Finding Memory Problems with gnatmem:: + * Finding Memory Problems with GNAT Debug Pool:: + * Creating Sample Bodies Using gnatstub:: + * Reducing the Size of Ada Executables with gnatelim:: + * Other Utility Programs:: + * Running and Debugging Ada Programs:: + * Inline Assembler:: + * Microsoft Windows Topics:: + * Performance Considerations:: + * GNU Free Documentation License:: + * Index:: + + --- The Detailed Node Listing --- + + About This Guide + + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + + + Getting Started with GNAT + + * Running GNAT:: + * Running a Simple Ada Program:: + * Running a Program with Multiple Units:: + * Using the gnatmake Utility:: + + The GNAT Compilation Model + + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + + Foreign Language Representation + + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + + Compiling Ada Programs With gcc + + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + + Switches for gcc + + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + + Binding Ada Programs With gnatbind + + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + + Linking Using gnatlink + + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + + The GNAT Make Program gnatmake + + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + + Renaming Files Using gnatchop + + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + + Configuration Pragmas + + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + + Handling Arbitrary File Naming Conventions Using gnatname + + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + + GNAT Project Manager + + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + + Elaboration Order Handling in GNAT + + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + + The Cross-Referencing Tools gnatxref and gnatfind + + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + + File Name Krunching Using gnatkr + + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + + Preprocessing Using gnatprep + + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + + + The GNAT Library Browser gnatls + + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + + + GNAT and Libraries + + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + + Using the GNU make Utility + + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + + Finding Memory Problems with gnatmem + + * Running gnatmem (GDB Mode):: + * Running gnatmem (GMEM Mode):: + * Switches for gnatmem:: + * Examples of gnatmem Usage:: + * GDB and GMEM Modes:: + * Implementation Note:: + + + Finding Memory Problems with GNAT Debug Pool + + Creating Sample Bodies Using gnatstub + + * Running gnatstub:: + * Switches for gnatstub:: + + Reducing the Size of Ada Executables with gnatelim + + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + + Other Utility Programs + + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + + + Running and Debugging Ada Programs + + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + + Inline Assembler + + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + + Microsoft Windows Topics + + * Using GNAT on Windows:: + * GNAT Setup Tool:: + * CONSOLE and WINDOWS subsystems:: + * Temporary Files:: + * Mixed-Language Programming on Windows:: + * Windows Calling Conventions:: + * Introduction to Dynamic Link Libraries (DLLs):: + * Using DLLs with GNAT:: + * Building DLLs with GNAT:: + * GNAT and Windows Resources:: + * GNAT and COM/DCOM Objects:: + + + Performance Considerations + + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + + * Index:: + @end menu + @end ifnottex + + @node About This Guide + @unnumbered About This Guide + + @noindent + This guide describes the use of GNAT, a compiler and software development + toolset for the full Ada 95 programming language. + It describes the features of the compiler and tools, and details + how to use them to build Ada 95 applications. + + @menu + * What This Guide Contains:: + * What You Should Know before Reading This Guide:: + * Related Information:: + * Conventions:: + @end menu + + @node What This Guide Contains + @unnumberedsec What This Guide Contains + + @noindent + This guide contains the following chapters: + @itemize @bullet + @item + @ref{Getting Started with GNAT}, describes how to get started compiling + and running Ada programs with the GNAT Ada programming environment. + @item + @ref{The GNAT Compilation Model}, describes the compilation model used + by GNAT. + @item + @ref{Compiling Using gcc}, describes how to compile + Ada programs with @code{gcc}, the Ada compiler. + @item + @ref{Binding Using gnatbind}, describes how to + perform binding of Ada programs with @code{gnatbind}, the GNAT binding + utility. + @item + @ref{Linking Using gnatlink}, + describes @code{gnatlink}, a + program that provides for linking using the GNAT run-time library to + construct a program. @code{gnatlink} can also incorporate foreign language + object units into the executable. + @item + @ref{The GNAT Make Program gnatmake}, describes @code{gnatmake}, a + utility that automatically determines the set of sources + needed by an Ada compilation unit, and executes the necessary compilations + binding and link. + @item + @ref{Renaming Files Using gnatchop}, describes + @code{gnatchop}, a utility that allows you to preprocess a file that + contains Ada source code, and split it into one or more new files, one + for each compilation unit. + @item + @ref{Configuration Pragmas}, describes the configuration pragmas handled by GNAT. + @item + @ref{Handling Arbitrary File Naming Conventions Using gnatname}, shows how to override + the default GNAT file naming conventions, either for an individual unit or globally. + @item + @ref{GNAT Project Manager}, describes how to use project files to organize large projects. + @item + @ref{Elaboration Order Handling in GNAT}, describes how GNAT helps you deal with + elaboration order issues. + @item + @ref{The Cross-Referencing Tools gnatxref and gnatfind}, discusses + @code{gnatxref} and @code{gnatfind}, two tools that provide an easy + way to navigate through sources. + @item + @ref{File Name Krunching Using gnatkr}, describes the @code{gnatkr} + file name krunching utility, used to handle shortened + file names on operating systems with a limit on the length of names. + @item + @ref{Preprocessing Using gnatprep}, describes @code{gnatprep}, a + preprocessor utility that allows a single source file to be used to + generate multiple or parameterized source files, by means of macro + substitution. + @item + @ref{The GNAT Library Browser gnatls}, describes @code{gnatls}, a + utility that displays information about compiled units, including dependences + on the corresponding sources files, and consistency of compilations. + @item + @ref{GNAT and Libraries}, describes the process of creating and using + Libraries with GNAT. It also describes how to recompile the GNAT run-time + library. + + @item + @ref{Using the GNU make Utility}, describes some techniques for using + the GNAT toolset in Makefiles. + + @item + @ref{Finding Memory Problems with gnatmem}, describes @code{gnatmem}, a + utility that monitors dynamic allocation and deallocation activity in a + program, and displays information about incorrect deallocations and sources + of possible memory leaks. + @item + @ref{Finding Memory Problems with GNAT Debug Pool}, describes how to + use the GNAT-specific Debug Pool in order to detect as early as possible + the use of incorrect memory references. + + @item + @ref{Creating Sample Bodies Using gnatstub}, discusses @code{gnatstub}, + a utility that generates empty but compilable bodies for library units. + + @item + @ref{Reducing the Size of Ada Executables with gnatelim}, describes + @code{gnatelim}, a tool which detects unused subprograms and helps + the compiler to create a smaller executable for the program. + + @item + @ref{Other Utility Programs}, discusses several other GNAT utilities, + including @code{gnatpsta}. + + @item + @ref{Running and Debugging Ada Programs}, describes how to run and debug + Ada programs. + + @item + @ref{Inline Assembler}, shows how to use the inline assembly facility in an Ada program. + + + @item + @ref{Performance Considerations}, reviews the trade offs between using + defaults or options in program development. + @end itemize + + @node What You Should Know before Reading This Guide + @unnumberedsec What You Should Know before Reading This Guide + + @cindex Ada 95 Language Reference Manual + @noindent + This user's guide assumes that you are familiar with Ada 95 language, as + described in the International Standard ANSI/ISO/IEC-8652:1995, Jan + 1995. + + @node Related Information + @unnumberedsec Related Information + + @noindent + For further information about related tools, refer to the following + documents: + + @itemize @bullet + @item + @cite{GNAT Reference Manual}, which contains all reference + material for the GNAT implementation of Ada 95. + + @item + @cite{Ada 95 Language Reference Manual}, which contains all reference + material for the Ada 95 programming language. + + @item + @cite{Debugging with GDB} + contains all details on the use of the GNU source-level debugger. + + @item + @cite{GNU Emacs Manual} + contains full information on the extensible editor and programming + environment Emacs. + + @end itemize + + @node Conventions + @unnumberedsec Conventions + @cindex Conventions + @cindex Typographical conventions + + @noindent + Following are examples of the typographical and graphic conventions used + in this guide: + + @itemize @bullet + @item + @code{Functions}, @code{utility program names}, @code{standard names}, + and @code{classes}. + + @item + @samp{Option flags} + + @item + @file{File Names}, @file{button names}, and @file{field names}. + + @item + @var{Variables}. + + @item + @emph{Emphasis}. + + @item + [optional information or parameters] + + @item + Examples are described by text + @smallexample + and then shown this way. + @end smallexample + @end itemize + + @noindent + Commands that are entered by the user are preceded in this manual by the + characters @w{"@code{$ }"} (dollar sign followed by space). If your system + uses this sequence as a prompt, then the commands will appear exactly as + you see them in the manual. If your system uses some other prompt, then + the command will appear with the @code{$} replaced by whatever prompt + character you are using. + + + @node Getting Started with GNAT + @chapter Getting Started with GNAT + + @noindent + This chapter describes some simple ways of using GNAT to build + executable Ada programs. + + @menu + * Running GNAT:: + * Running a Simple Ada Program:: + + * Running a Program with Multiple Units:: + + * Using the gnatmake Utility:: + * Introduction to Glide and GVD:: + @end menu + + @node Running GNAT + @section Running GNAT + + @noindent + Three steps are needed to create an executable file from an Ada source + file: + + @enumerate + @item + The source file(s) must be compiled. + @item + The file(s) must be bound using the GNAT binder. + @item + All appropriate object files must be linked to produce an executable. + @end enumerate + + @noindent + All three steps are most commonly handled by using the @code{gnatmake} + utility program that, given the name of the main program, automatically + performs the necessary compilation, binding and linking steps. + + @node Running a Simple Ada Program + @section Running a Simple Ada Program + + @noindent + Any text editor may be used to prepare an Ada program. If @code{Glide} is + used, the optional Ada mode may be helpful in laying out the program. The + program text is a normal text file. We will suppose in our initial + example that you have used your editor to prepare the following + standard format text file: + + @smallexample + @group + @cartouche + @b{with} Ada.Text_IO; @b{use} Ada.Text_IO; + @b{procedure} Hello @b{is} + @b{begin} + Put_Line ("Hello WORLD!"); + @b{end} Hello; + @end cartouche + @end group + @end smallexample + + @noindent + This file should be named @file{hello.adb}. + With the normal default file naming conventions, GNAT requires + that each file + contain a single compilation unit whose file name is the + unit name, + with periods replaced by hyphens; the + extension is @file{ads} for a + spec and @file{adb} for a body. + You can override this default file naming convention by use of the + special pragma @code{Source_File_Name} (@pxref{Using Other File Names}). + Alternatively, if you want to rename your files according to this default + convention, which is probably more convenient if you will be using GNAT + for all your compilations, then the @code{gnatchop} utility + can be used to generate correctly-named source files + (@pxref{Renaming Files Using gnatchop}). + + You can compile the program using the following command (@code{$} is used + as the command prompt in the examples in this document): + + @smallexample + $ gcc -c hello.adb + @end smallexample + + + @noindent + @code{gcc} is the command used to run the compiler. This compiler is + capable of compiling programs in several languages, including Ada 95 and + C. It assumes that you have given it an Ada program if the file extension is + either @file{.ads} or @file{.adb}, and it will then call the GNAT compiler to compile + the specified file. + + The @option{-c} switch is required. It tells @command{gcc} to only do a + compilation. (For C programs, @command{gcc} can also do linking, but this + capability is not used directly for Ada programs, so the @option{-c} + switch must always be present.) + + This compile command generates a file + @file{hello.o}, which is the object + file corresponding to your Ada program. It also generates an "Ada Library Information" file + @file{hello.ali}, + which contains additional information used to check + that an Ada program is consistent. + To build an executable file, + use @code{gnatbind} to bind the program + and @code{gnatlink} to link it. The + argument to both @code{gnatbind} and @code{gnatlink} is the name of the + @file{ali} file, but the default extension of @file{.ali} can + be omitted. This means that in the most common case, the argument + is simply the name of the main program: + + @smallexample + $ gnatbind hello + $ gnatlink hello + @end smallexample + + + @noindent + A simpler method of carrying out these steps is to use + @command{gnatmake}, + a master program that invokes all the required + compilation, binding and linking tools in the correct order. In particular, + @command{gnatmake} automatically recompiles any sources that have been modified + since they were last compiled, or sources that depend + on such modified sources, so that "version skew" is avoided. + @cindex Version skew (avoided by @command{gnatmake}) + + @smallexample + $ gnatmake hello.adb + @end smallexample + + + @noindent + The result is an executable program called @file{hello}, which can be + run by entering: + + @c The following should be removed (BMB 2001-01-23) + @c @smallexample + @c $ ./hello + @c @end smallexample + + @smallexample + $ hello + @end smallexample + + @noindent + assuming that the current directory is on the search path for executable programs. + + @noindent + and, if all has gone well, you will see + + @smallexample + Hello WORLD! + @end smallexample + + @noindent + appear in response to this command. + + + + + @node Running a Program with Multiple Units + @section Running a Program with Multiple Units + + @noindent + Consider a slightly more complicated example that has three files: a + main program, and the spec and body of a package: + + @smallexample + @cartouche + @group + @b{package} Greetings @b{is} + @b{procedure} Hello; + @b{procedure} Goodbye; + @b{end} Greetings; + + @b{with} Ada.Text_IO; @b{use} Ada.Text_IO; + @b{package} @b{body} Greetings @b{is} + @b{procedure} Hello @b{is} + @b{begin} + Put_Line ("Hello WORLD!"); + @b{end} Hello; + + @b{procedure} Goodbye @b{is} + @b{begin} + Put_Line ("Goodbye WORLD!"); + @b{end} Goodbye; + @b{end} Greetings; + @end group + + @group + @b{with} Greetings; + @b{procedure} Gmain @b{is} + @b{begin} + Greetings.Hello; + Greetings.Goodbye; + @b{end} Gmain; + @end group + @end cartouche + @end smallexample + + @noindent + Following the one-unit-per-file rule, place this program in the + following three separate files: + + @table @file + @item greetings.ads + spec of package @code{Greetings} + + @item greetings.adb + body of package @code{Greetings} + + @item gmain.adb + body of main program + @end table + + @noindent + To build an executable version of + this program, we could use four separate steps to compile, bind, and link + the program, as follows: + + @smallexample + $ gcc -c gmain.adb + $ gcc -c greetings.adb + $ gnatbind gmain + $ gnatlink gmain + @end smallexample + + + @noindent + Note that there is no required order of compilation when using GNAT. + In particular it is perfectly fine to compile the main program first. + Also, it is not necessary to compile package specs in the case where + there is an accompanying body; you only need to compile the body. If you want + to submit these files to the compiler for semantic checking and not code generation, + then use the + @option{-gnatc} switch: + + @smallexample + $ gcc -c greetings.ads -gnatc + @end smallexample + + + @noindent + Although the compilation can be done in separate steps as in the + above example, in practice it is almost always more convenient + to use the @code{gnatmake} tool. All you need to know in this case + is the name of the main program's source file. The effect of the above four + commands can be achieved with a single one: + + @smallexample + $ gnatmake gmain.adb + @end smallexample + + + @noindent + In the next section we discuss the advantages of using @code{gnatmake} in + more detail. + + @node Using the gnatmake Utility + @section Using the @command{gnatmake} Utility + + @noindent + If you work on a program by compiling single components at a time using + @code{gcc}, you typically keep track of the units you modify. In order to + build a consistent system, you compile not only these units, but also any + units that depend on the units you have modified. + For example, in the preceding case, + if you edit @file{gmain.adb}, you only need to recompile that file. But if + you edit @file{greetings.ads}, you must recompile both + @file{greetings.adb} and @file{gmain.adb}, because both files contain + units that depend on @file{greetings.ads}. + + @code{gnatbind} will warn you if you forget one of these compilation + steps, so that it is impossible to generate an inconsistent program as a + result of forgetting to do a compilation. Nevertheless it is tedious and + error-prone to keep track of dependencies among units. + One approach to handle the dependency-bookkeeping is to use a + makefile. However, makefiles present maintenance problems of their own: + if the dependencies change as you change the program, you must make + sure that the makefile is kept up-to-date manually, which is also an + error-prone process. + + The @code{gnatmake} utility takes care of these details automatically. + Invoke it using either one of the following forms: + + @smallexample + $ gnatmake gmain.adb + $ gnatmake gmain + @end smallexample + + + @noindent + The argument is the name of the file containing the main program; + you may omit the extension. @code{gnatmake} + examines the environment, automatically recompiles any files that need + recompiling, and binds and links the resulting set of object files, + generating the executable file, @file{gmain}. + In a large program, it + can be extremely helpful to use @code{gnatmake}, because working out by hand + what needs to be recompiled can be difficult. + + Note that @code{gnatmake} + takes into account all the Ada 95 rules that + establish dependencies among units. These include dependencies that result + from inlining subprogram bodies, and from + generic instantiation. Unlike some other + Ada make tools, @code{gnatmake} does not rely on the dependencies that were + found by the compiler on a previous compilation, which may possibly + be wrong when sources change. @code{gnatmake} determines the exact set of + dependencies from scratch each time it is run. + + + @node Introduction to Glide and GVD + @section Introduction to Glide and GVD + @cindex Glide + @cindex GVD + @noindent + Although it is possible to develop programs using only the command line interface (@command{gnatmake}, etc.) a graphical Interactive Development Environment can make it easier for you to compose, navigate, and debug programs. This section describes the main features of Glide, the GNAT graphical IDE, and also shows how to use the basic commands in GVD, the GNU Visual Debugger. Additional information may be found in the on-line help for these tools. + + @menu + * Building a New Program with Glide:: + * Simple Debugging with GVD:: + * Other Glide Features:: + @end menu + + @node Building a New Program with Glide + @subsection Building a New Program with Glide + @noindent + The simplest way to invoke Glide is to enter @command{glide} at the command prompt. It will generally be useful to issue this as a background command, thus allowing you to continue using your command window for other purposes while Glide is running: + + @smallexample + $ glide& + @end smallexample + + @noindent + Glide will start up with an initial screen displaying the top-level menu items as well as some other information. The menu selections are as follows + @itemize @bullet + @item @code{Buffers} + @item @code{Files} + @item @code{Tools} + @item @code{Edit} + @item @code{Search} + @item @code{Mule} + @item @code{Glide} + @item @code{Help} + @end itemize + + @noindent + For this introductory example, you will need to create a new Ada source file. First, select the @code{Files} menu. This will pop open a menu with around a dozen or so items. To create a file, select the @code{Open file...} choice. Depending on the platform, you may see a pop-up window where you can browse to an appropriate directory and then enter the file name, or else simply see a line at the bottom of the Glide window where you can likewise enter the file name. Note that in Glide, when you attempt to open a non-existent file, the effect is to create a file with that name. For this example enter @file{hello.adb} as the name of the file. + + A new buffer will now appear, occupying the entire Glide window, with the file name at the top. The menu selections are slightly different from the ones you saw on the opening screen; there is an @code{Entities} item, and in place of @code{Glide} there is now an @code{Ada} item. Glide uses the file extension to identify the source language, so @file{adb} indicates an Ada source file. + + You will enter some of the source program lines explicitly, and use the syntax-oriented template mechanism to enter other lines. First, type the following text: + @smallexample + with Ada.Text_IO; use Ada.Text_IO; + procedure Hello is + begin + @end smallexample + + @noindent + Observe that Glide uses different colors to distinguish reserved words from identifiers. Also, after the @code{procedure Hello is} line, the cursor is automatically indented in anticipation of declarations. When you enter @code{begin}, Glide recognizes that there are no declarations and thus places @code{begin} flush left. But after the @code{begin} line the cursor is again indented, where the statement(s) will be placed. + + The main part of the program will be a @code{for} loop. Instead of entering the text explicitly, however, use a statement template. Select the @code{Ada} item on the top menu bar, move the mouse to the @code{Statements} item, and you will see a large selection of alternatives. Choose @code{for loop}. You will be prompted (at the bottom of the buffer) for a loop name; simply press the @key{Enter} key since a loop name is not needed. You should see the beginning of a @code{for} loop appear in the source program window. You will now be prompted for the name of the loop variable; enter a line with the identifier @code{ind} (lower case). Note that, by default, Glide capitalizes the name (you can override such behavior if you wish, although this is outside the scope of this introduction). Next, Glide prompts you for the loop range; enter a line containing @code{1..5} and you will see this also appear in the source program, together with the remaining elements of the @code{for} loop syntax. + + Next enter the statement (with an intentional error, a missing semicolon) that will form the body of the loop: + @smallexample + Put_Line("Hello, World" & Integer'Image(I)) + @end smallexample + + @noindent + Finally, type @code{end Hello;} as the last line in the program. Now save the file: choose the @code{File} menu item, and then the @code{Save buffer} selection. You will see a message at the bottom of the buffer confirming that the file has been saved. + + You are now ready to attempt to build the program. Select the @code{Ada} item from the top menu bar. Although we could choose simply to compile the file, we will instead attempt to do a build (which invokes @command{gnatmake}) since, if the compile is successful, we want to build an executable. Thus select @code{Ada build}. This will fail because of the compilation error, and you will notice that the Glide window has been split: the top window contains the source file, and the bottom window contains the output from the GNAT tools. Glide allows you to navigate from a compilation error to the source file position corresponding to the error: click the middle mouse button (or simultaneously press the left and right buttons, on a two-button mouse) on the diagnostic line in the tool window. The focus will shift to the source window, and the cursor will be positioned on the character at which the error was detected. + + Correct the error: type in a semicolon to terminate the statement. Although you can again save the file explicitly, you can also simply invoke @code{Ada} @result{} @code{Build} and you will be prompted to save the file. This time the build will succeed; the tool output window shows you the options that are supplied by default. The GNAT tools' output (e.g., object and ALI files, executable) will go in the directory from which Glide was launched. + + To execute the program, choose @code{Ada} and then @code{Run}. You should see the program's output displayed in the bottom window: + + @smallexample + Hello, world 1 + Hello, world 2 + Hello, world 3 + Hello, world 4 + Hello, world 5 + @end smallexample + + @node Simple Debugging with GVD + @subsection Simple Debugging with GVD + + @noindent + This section describes how to set breakpoints, examine/modify variables, and step through execution. + + In order to enable debugging, you need to pass the @option{-g} switch to both the compiler and to @command{gnatlink}. If you are using the command line, passing @option{-g} to @command{gnatmake} will have this effect. You can then launch GVD, e.g. on the @code{hello} program, by issuing the command: + + @smallexample + $ gvd hello + @end smallexample + + @noindent + If you are using Glide, then @option{-g} is passed to the relevant tools by default when you do a build. Start the debugger by selecting the @code{Ada} menu item, and then @code{Debug}. + + GVD comes up in a multi-part window. One pane shows the names of files comprising your executable; another pane shows the source code of the current unit (initially your main subprogram), another pane shows the debugger output and user interactions, and the fourth pane (the data canvas at the top of the window) displays data objects that you have selected. + + To the left of the source file pane, you will notice green dots adjacent to some lines. These are lines for which object code exists and where breakpoints can thus be set. You set/reset a breakpoint by clicking the green dot. When a breakpoint is set, the dot is replaced by an @code{X} in a red circle. Clicking the circle toggles the breakpoint off, and the red circle is replaced by the green dot. + + For this example, set a breakpoint at the statement where @code{Put_Line} is invoked. + + Start program execution by selecting the @code{Run} button on the top menu bar. (The @code{Start} button will also start your program, but it will cause program execution to break at the entry to your main subprogram.) Evidence of reaching the breakpoint will appear: the source file line will be highlighted, and the debugger interactions pane will display a relevant message. + + You can examine the values of variables in several ways. Move the mouse over an occurrence of @code{Ind} in the @code{for} loop, and you will see the value (now @code{1}) displayed. Alternatively, right-click on @code{Ind} and select @code{Display Ind}; a box showing the variable's name and value will appear in the data canvas. + + Although a loop index is a constant with respect to Ada semantics, you can change its value in the debugger. Right-click in the box for @code{Ind}, and select the @code{Set Value of Ind} item. Enter @code{2} as the new value, and press @command{OK}. The box for @code{Ind} shows the update. + + Press the @code{Step} button on the top menu bar; this will step through one line of program text (the invocation of @code{Put_Line}), and you can observe the effect of having modified @code{Ind} since the value displayed is @code{2}. + + Remove the breakpoint, and resume execution by selecting the @code{Cont} button. You will see the remaining output lines displayed in the debugger interaction window, along with a message confirming normal program termination. + + + @node Other Glide Features + @subsection Other Glide Features + + @noindent + You may have observed that some of the menu selections contain abbreviations; e.g., @code{(C-x C-f)} for @code{Open file...} in the @code{Files} menu. These are @emph{shortcut keys} that you can use instead of selecting menu items. The @key{C} stands for @key{Ctrl}; thus @code{(C-x C-f)} means @key{Ctrl-x} followed by @key{Ctrl-f}, and this sequence can be used instead of selecting @code{Files} and then @code{Open file...}. + + To abort a Glide command, type @key{Ctrl-g}. + + If you want Glide to start with an existing source file, you can either launch Glide as above and then open the file via @code{Files} @result{} @code{Open file...}, or else simply pass the name of the source file on the command line: + + @smallexample + $ glide hello.adb& + @end smallexample + + @noindent + While you are using Glide, a number of @emph{buffers} exist. You create some explicitly; e.g., when you open/create a file. Others arise as an effect of the commands that you issue; e.g., the buffer containing the output of the tools invoked during a build. If a buffer is hidden, you can bring it into a visible window by first opening the @code{Buffers} menu and then selecting the desired entry. + + If a buffer occupies only part of the Glide screen and you want to expand it to fill the entire screen, then click in the buffer and then select @code{Files} @result{} @code{One Window}. + + If a window is occupied by one buffer and you want to split the window to bring up a second buffer, perform the following steps: + @itemize @bullet + @item Select @code{Files} @result{} @code{Split Window}; this will produce two windows each of which holds the original buffer (these are not copies, but rather different views of the same buffer contents) + @item With the focus in one of the windows, select the desired buffer from the @code{Buffers} menu + @end itemize + + @noindent + To exit from Glide, choose @code{Files} @result{} @code{Exit}. + + @node The GNAT Compilation Model + @chapter The GNAT Compilation Model + @cindex GNAT compilation model + @cindex Compilation model + + @menu + * Source Representation:: + * Foreign Language Representation:: + * File Naming Rules:: + * Using Other File Names:: + * Alternative File Naming Schemes:: + * Generating Object Files:: + * Source Dependencies:: + * The Ada Library Information Files:: + * Binding an Ada Program:: + * Mixed Language Programming:: + * Building Mixed Ada & C++ Programs:: + * Comparison between GNAT and C/C++ Compilation Models:: + * Comparison between GNAT and Conventional Ada Library Models:: + @end menu + + @noindent + This chapter describes the compilation model used by GNAT. Although + similar to that used by other languages, such as C and C++, this model + is substantially different from the traditional Ada compilation models, + which are based on a library. The model is initially described without + reference to the library-based model. If you have not previously used an + Ada compiler, you need only read the first part of this chapter. The + last section describes and discusses the differences between the GNAT + model and the traditional Ada compiler models. If you have used other + Ada compilers, this section will help you to understand those + differences, and the advantages of the GNAT model. + + @node Source Representation + @section Source Representation + @cindex Latin-1 + + @noindent + Ada source programs are represented in standard text files, using + Latin-1 coding. Latin-1 is an 8-bit code that includes the familiar + 7-bit ASCII set, plus additional characters used for + representing foreign languages (@pxref{Foreign Language Representation} + for support of non-USA character sets). The format effector characters + are represented using their standard ASCII encodings, as follows: + + @table @code + @item VT + @findex VT + Vertical tab, @code{16#0B#} + + @item HT + @findex HT + Horizontal tab, @code{16#09#} + + @item CR + @findex CR + Carriage return, @code{16#0D#} + + @item LF + @findex LF + Line feed, @code{16#0A#} + + @item FF + @findex FF + Form feed, @code{16#0C#} + @end table + + @noindent + Source files are in standard text file format. In addition, GNAT will + recognize a wide variety of stream formats, in which the end of physical + physical lines is marked by any of the following sequences: + @code{LF}, @code{CR}, @code{CR-LF}, or @code{LF-CR}. This is useful + in accommodating files that are imported from other operating systems. + + @cindex End of source file + @cindex Source file, end + @findex SUB + The end of a source file is normally represented by the physical end of + file. However, the control character @code{16#1A#} (@code{SUB}) is also + recognized as signalling the end of the source file. Again, this is + provided for compatibility with other operating systems where this + code is used to represent the end of file. + + Each file contains a single Ada compilation unit, including any pragmas + associated with the unit. For example, this means you must place a + package declaration (a package @dfn{spec}) and the corresponding body in + separate files. An Ada @dfn{compilation} (which is a sequence of + compilation units) is represented using a sequence of files. Similarly, + you will place each subunit or child unit in a separate file. + + @node Foreign Language Representation + @section Foreign Language Representation + + @noindent + GNAT supports the standard character sets defined in Ada 95 as well as + several other non-standard character sets for use in localized versions + of the compiler (@pxref{Character Set Control}). + @menu + * Latin-1:: + * Other 8-Bit Codes:: + * Wide Character Encodings:: + @end menu + + @node Latin-1 + @subsection Latin-1 + @cindex Latin-1 + + @noindent + The basic character set is Latin-1. This character set is defined by ISO + standard 8859, part 1. The lower half (character codes @code{16#00#} + ... @code{16#7F#)} is identical to standard ASCII coding, but the upper half is + used to represent additional characters. These include extended letters + used by European languages, such as French accents, the vowels with umlauts + used in German, and the extra letter A-ring used in Swedish. + + @findex Ada.Characters.Latin_1 + For a complete list of Latin-1 codes and their encodings, see the source + file of library unit @code{Ada.Characters.Latin_1} in file + @file{a-chlat1.ads}. + You may use any of these extended characters freely in character or + string literals. In addition, the extended characters that represent + letters can be used in identifiers. + + @node Other 8-Bit Codes + @subsection Other 8-Bit Codes + + @noindent + GNAT also supports several other 8-bit coding schemes: + + @table @asis + @cindex Latin-2 + @item Latin-2 + Latin-2 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-3 + @cindex Latin-3 + Latin-3 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-4 + @cindex Latin-4 + Latin-4 letters allowed in identifiers, with uppercase and lowercase + equivalence. + + @item Latin-5 + @cindex Latin-5 + @cindex Cyrillic + Latin-4 letters (Cyrillic) allowed in identifiers, with uppercase and lowercase + equivalence. + + @item IBM PC (code page 437) + @cindex code page 437 + This code page is the normal default for PCs in the U.S. It corresponds + to the original IBM PC character set. This set has some, but not all, of + the extended Latin-1 letters, but these letters do not have the same + encoding as Latin-1. In this mode, these letters are allowed in + identifiers with uppercase and lowercase equivalence. + + @item IBM PC (code page 850) + @cindex code page 850 + This code page is a modification of 437 extended to include all the + Latin-1 letters, but still not with the usual Latin-1 encoding. In this + mode, all these letters are allowed in identifiers with uppercase and + lowercase equivalence. + + @item Full Upper 8-bit + Any character in the range 80-FF allowed in identifiers, and all are + considered distinct. In other words, there are no uppercase and lowercase + equivalences in this range. This is useful in conjunction with + certain encoding schemes used for some foreign character sets (e.g. + the typical method of representing Chinese characters on the PC). + + @item No Upper-Half + No upper-half characters in the range 80-FF are allowed in identifiers. + This gives Ada 83 compatibility for identifier names. + @end table + + @noindent + For precise data on the encodings permitted, and the uppercase and lowercase + equivalences that are recognized, see the file @file{csets.adb} in + the GNAT compiler sources. You will need to obtain a full source release + of GNAT to obtain this file. + + @node Wide Character Encodings + @subsection Wide Character Encodings + + @noindent + GNAT allows wide character codes to appear in character and string + literals, and also optionally in identifiers, by means of the following + possible encoding schemes: + + @table @asis + + @item Hex Coding + In this encoding, a wide character is represented by the following five + character sequence: + + @smallexample + ESC a b c d + @end smallexample + + @noindent + Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal + characters (using uppercase letters) of the wide character code. For + example, ESC A345 is used to represent the wide character with code + @code{16#A345#}. + This scheme is compatible with use of the full Wide_Character set. + + @item Upper-Half Coding + @cindex Upper-Half Coding + The wide character with encoding @code{16#abcd#} where the upper bit is on (in + other words, "a" is in the range 8-F) is represented as two bytes, + @code{16#ab#} and @code{16#cd#}. The second byte cannot be a format control + character, but is not required to be in the upper half. This method can + be also used for shift-JIS or EUC, where the internal coding matches the + external coding. + + @item Shift JIS Coding + @cindex Shift JIS Coding + A wide character is represented by a two-character sequence, + @code{16#ab#} and + @code{16#cd#}, with the restrictions described for upper-half encoding as + described above. The internal character code is the corresponding JIS + character according to the standard algorithm for Shift-JIS + conversion. Only characters defined in the JIS code set table can be + used with this encoding method. + + @item EUC Coding + @cindex EUC Coding + A wide character is represented by a two-character sequence + @code{16#ab#} and + @code{16#cd#}, with both characters being in the upper half. The internal + character code is the corresponding JIS character according to the EUC + encoding algorithm. Only characters defined in the JIS code set table + can be used with this encoding method. + + @item UTF-8 Coding + A wide character is represented using + UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO + 10646-1/Am.2. Depending on the character value, the representation + is a one, two, or three byte sequence: + @smallexample + @iftex + @leftskip=.7cm + @end iftex + 16#0000#-16#007f#: 2#0xxxxxxx# + 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx# + 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx# + + @end smallexample + + @noindent + where the xxx bits correspond to the left-padded bits of the + 16-bit character value. Note that all lower half ASCII characters + are represented as ASCII bytes and all upper half characters and + other wide characters are represented as sequences of upper-half + (The full UTF-8 scheme allows for encoding 31-bit characters as + 6-byte sequences, but in this implementation, all UTF-8 sequences + of four or more bytes length will be treated as illegal). + @item Brackets Coding + In this encoding, a wide character is represented by the following eight + character sequence: + + @smallexample + [ " a b c d " ] + @end smallexample + + @noindent + Where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal + characters (using uppercase letters) of the wide character code. For + example, ["A345"] is used to represent the wide character with code + @code{16#A345#}. It is also possible (though not required) to use the + Brackets coding for upper half characters. For example, the code + @code{16#A3#} can be represented as @code{["A3"]}. + + This scheme is compatible with use of the full Wide_Character set, + and is also the method used for wide character encoding in the standard + ACVC (Ada Compiler Validation Capability) test suite distributions. + + @end table + + @noindent + Note: Some of these coding schemes do not permit the full use of the + Ada 95 character set. For example, neither Shift JIS, nor EUC allow the + use of the upper half of the Latin-1 set. + + @node File Naming Rules + @section File Naming Rules + + @noindent + The default file name is determined by the name of the unit that the + file contains. The name is formed by taking the full expanded name of + the unit and replacing the separating dots with hyphens and using + lowercase for all letters. + + An exception arises if the file name generated by the above rules starts + with one of the characters + a,g,i, or s, + and the second character is a + minus. In this case, the character tilde is used in place + of the minus. The reason for this special rule is to avoid clashes with + the standard names for child units of the packages System, Ada, + Interfaces, and GNAT, which use the prefixes + s- a- i- and g- + respectively. + + The file extension is @file{.ads} for a spec and + @file{.adb} for a body. The following list shows some + examples of these rules. + + @table @file + @item main.ads + Main (spec) + @item main.adb + Main (body) + @item arith_functions.ads + Arith_Functions (package spec) + @item arith_functions.adb + Arith_Functions (package body) + @item func-spec.ads + Func.Spec (child package spec) + @item func-spec.adb + Func.Spec (child package body) + @item main-sub.adb + Sub (subunit of Main) + @item a~bad.adb + A.Bad (child package body) + @end table + + @noindent + Following these rules can result in excessively long + file names if corresponding + unit names are long (for example, if child units or subunits are + heavily nested). An option is available to shorten such long file names + (called file name "krunching"). This may be particularly useful when + programs being developed with GNAT are to be used on operating systems + with limited file name lengths. @xref{Using gnatkr}. + + Of course, no file shortening algorithm can guarantee uniqueness over + all possible unit names; if file name krunching is used, it is your + responsibility to ensure no name clashes occur. Alternatively you + can specify the exact file names that you want used, as described + in the next section. Finally, if your Ada programs are migrating from a + compiler with a different naming convention, you can use the gnatchop + utility to produce source files that follow the GNAT naming conventions. + (For details @pxref{Renaming Files Using gnatchop}.) + + @node Using Other File Names + @section Using Other File Names + @cindex File names + + @noindent + In the previous section, we have described the default rules used by + GNAT to determine the file name in which a given unit resides. It is + often convenient to follow these default rules, and if you follow them, + the compiler knows without being explicitly told where to find all + the files it needs. + + However, in some cases, particularly when a program is imported from + another Ada compiler environment, it may be more convenient for the + programmer to specify which file names contain which units. GNAT allows + arbitrary file names to be used by means of the Source_File_Name pragma. + The form of this pragma is as shown in the following examples: + @cindex Source_File_Name pragma + + @smallexample + @group + @cartouche + @b{pragma} Source_File_Name (My_Utilities.Stacks, + Spec_File_Name => "myutilst_a.ada"); + @b{pragma} Source_File_name (My_Utilities.Stacks, + Body_File_Name => "myutilst.ada"); + @end cartouche + @end group + @end smallexample + + @noindent + As shown in this example, the first argument for the pragma is the unit + name (in this example a child unit). The second argument has the form + of a named association. The identifier + indicates whether the file name is for a spec or a body; + the file name itself is given by a string literal. + + The source file name pragma is a configuration pragma, which means that + normally it will be placed in the @file{gnat.adc} + file used to hold configuration + pragmas that apply to a complete compilation environment. + For more details on how the @file{gnat.adc} file is created and used + @pxref{Handling of Configuration Pragmas} + @cindex @file{gnat.adc} + + GNAT allows completely arbitrary file names to be specified using the + source file name pragma. However, if the file name specified has an + extension other than @file{.ads} or @file{.adb} it is necessary to use a special + syntax when compiling the file. The name in this case must be preceded + by the special sequence @code{-x} followed by a space and the name of the + language, here @code{ada}, as in: + + @smallexample + $ gcc -c -x ada peculiar_file_name.sim + @end smallexample + + @noindent + @code{gnatmake} handles non-standard file names in the usual manner (the + non-standard file name for the main program is simply used as the + argument to gnatmake). Note that if the extension is also non-standard, + then it must be included in the gnatmake command, it may not be omitted. + + @node Alternative File Naming Schemes + @section Alternative File Naming Schemes + @cindex File naming schemes, alternative + @cindex File names + + In the previous section, we described the use of the @code{Source_File_Name} + pragma to allow arbitrary names to be assigned to individual source files. + However, this approach requires one pragma for each file, and especially in + large systems can result in very long @file{gnat.adc} files, and also create + a maintenance problem. + + GNAT also provides a facility for specifying systematic file naming schemes + other than the standard default naming scheme previously described. An + alternative scheme for naming is specified by the use of + @code{Source_File_Name} pragmas having the following format: + @cindex Source_File_Name pragma + + @smallexample + pragma Source_File_Name ( + Spec_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Body_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + pragma Source_File_Name ( + Subunit_File_Name => FILE_NAME_PATTERN + [,Casing => CASING_SPEC] + [,Dot_Replacement => STRING_LITERAL]); + + FILE_NAME_PATTERN ::= STRING_LITERAL + CASING_SPEC ::= Lowercase | Uppercase | Mixedcase + + @end smallexample + + @noindent + The @code{FILE_NAME_PATTERN} string shows how the file name is constructed. + It contains a single asterisk character, and the unit name is substituted + systematically for this asterisk. The optional parameter + @code{Casing} indicates + whether the unit name is to be all upper-case letters, all lower-case letters, + or mixed-case. If no + @code{Casing} parameter is used, then the default is all + lower-case. + + The optional @code{Dot_Replacement} string is used to replace any periods + that occur in subunit or child unit names. If no @code{Dot_Replacement} + argument is used then separating dots appear unchanged in the resulting + file name. + Although the above syntax indicates that the + @code{Casing} argument must appear + before the @code{Dot_Replacement} argument, but it + is also permissible to write these arguments in the opposite order. + + As indicated, it is possible to specify different naming schemes for + bodies, specs, and subunits. Quite often the rule for subunits is the + same as the rule for bodies, in which case, there is no need to give + a separate @code{Subunit_File_Name} rule, and in this case the + @code{Body_File_name} rule is used for subunits as well. + + The separate rule for subunits can also be used to implement the rather + unusual case of a compilation environment (e.g. a single directory) which + contains a subunit and a child unit with the same unit name. Although + both units cannot appear in the same partition, the Ada Reference Manual + allows (but does not require) the possibility of the two units coexisting + in the same environment. + + The file name translation works in the following steps: + + @itemize @bullet + + @item + If there is a specific @code{Source_File_Name} pragma for the given unit, + then this is always used, and any general pattern rules are ignored. + + @item + If there is a pattern type @code{Source_File_Name} pragma that applies to + the unit, then the resulting file name will be used if the file exists. If + more than one pattern matches, the latest one will be tried first, and the + first attempt resulting in a reference to a file that exists will be used. + + @item + If no pattern type @code{Source_File_Name} pragma that applies to the unit + for which the corresponding file exists, then the standard GNAT default + naming rules are used. + + @end itemize + + @noindent + As an example of the use of this mechanism, consider a commonly used scheme + in which file names are all lower case, with separating periods copied + unchanged to the resulting file name, and specs end with ".1.ada", and + bodies end with ".2.ada". GNAT will follow this scheme if the following + two pragmas appear: + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*.1.ada"); + pragma Source_File_Name + (Body_File_Name => "*.2.ada"); + @end smallexample + + @noindent + The default GNAT scheme is actually implemented by providing the following + default pragmas internally: + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*.ads", Dot_Replacement => "-"); + pragma Source_File_Name + (Body_File_Name => "*.adb", Dot_Replacement => "-"); + @end smallexample + + @noindent + Our final example implements a scheme typically used with one of the + Ada 83 compilers, where the separator character for subunits was "__" + (two underscores), specs were identified by adding @file{_.ADA}, bodies + by adding @file{.ADA}, and subunits by + adding @file{.SEP}. All file names were + upper case. Child units were not present of course since this was an + Ada 83 compiler, but it seems reasonable to extend this scheme to use + the same double underscore separator for child units. + + @smallexample + pragma Source_File_Name + (Spec_File_Name => "*_.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Body_File_Name => "*.ADA", + Dot_Replacement => "__", + Casing = Uppercase); + pragma Source_File_Name + (Subunit_File_Name => "*.SEP", + Dot_Replacement => "__", + Casing = Uppercase); + @end smallexample + + @node Generating Object Files + @section Generating Object Files + + @noindent + An Ada program consists of a set of source files, and the first step in + compiling the program is to generate the corresponding object files. + These are generated by compiling a subset of these source files. + The files you need to compile are the following: + + @itemize @bullet + @item + If a package spec has no body, compile the package spec to produce the + object file for the package. + + @item + If a package has both a spec and a body, compile the body to produce the + object file for the package. The source file for the package spec need + not be compiled in this case because there is only one object file, which + contains the code for both the spec and body of the package. + + @item + For a subprogram, compile the subprogram body to produce the object file + for the subprogram. The spec, if one is present, is as usual in a + separate file, and need not be compiled. + + @item + @cindex Subunits + In the case of subunits, only compile the parent unit. A single object + file is generated for the entire subunit tree, which includes all the + subunits. + + @item + Compile child units independently of their parent units + (though, of course, the spec of all the ancestor unit must be present in order + to compile a child unit). + + @item + @cindex Generics + Compile generic units in the same manner as any other units. The object + files in this case are small dummy files that contain at most the + flag used for elaboration checking. This is because GNAT always handles generic + instantiation by means of macro expansion. However, it is still necessary to + compile generic units, for dependency checking and elaboration purposes. + @end itemize + + @noindent + The preceding rules describe the set of files that must be compiled to + generate the object files for a program. Each object file has the same + name as the corresponding source file, except that the extension is + @file{.o} as usual. + + You may wish to compile other files for the purpose of checking their + syntactic and semantic correctness. For example, in the case where a + package has a separate spec and body, you would not normally compile the + spec. However, it is convenient in practice to compile the spec to make + sure it is error-free before compiling clients of this spec, because such + compilations will fail if there is an error in the spec. + + GNAT provides an option for compiling such files purely for the + purposes of checking correctness; such compilations are not required as + part of the process of building a program. To compile a file in this + checking mode, use the @option{-gnatc} switch. + + @node Source Dependencies + @section Source Dependencies + + @noindent + A given object file clearly depends on the source file which is compiled + to produce it. Here we are using @dfn{depends} in the sense of a typical + @code{make} utility; in other words, an object file depends on a source + file if changes to the source file require the object file to be + recompiled. + In addition to this basic dependency, a given object may depend on + additional source files as follows: + + @itemize @bullet + @item + If a file being compiled @code{with}'s a unit @var{X}, the object file + depends on the file containing the spec of unit @var{X}. This includes + files that are @code{with}'ed implicitly either because they are parents + of @code{with}'ed child units or they are run-time units required by the + language constructs used in a particular unit. + + @item + If a file being compiled instantiates a library level generic unit, the + object file depends on both the spec and body files for this generic + unit. + + @item + If a file being compiled instantiates a generic unit defined within a + package, the object file depends on the body file for the package as + well as the spec file. + + @item + @findex Inline + @cindex @option{-gnatn} switch + If a file being compiled contains a call to a subprogram for which + pragma @code{Inline} applies and inlining is activated with the + @option{-gnatn} switch, the object file depends on the file containing the + body of this subprogram as well as on the file containing the spec. Note + that for inlining to actually occur as a result of the use of this switch, + it is necessary to compile in optimizing mode. + + @cindex @option{-gnatN} switch + The use of @option{-gnatN} activates a more extensive inlining optimization + that is performed by the front end of the compiler. This inlining does + not require that the code generation be optimized. Like @option{-gnatn}, + the use of this switch generates additional dependencies. + + @item + If an object file O depends on the proper body of a subunit through inlining + or instantiation, it depends on the parent unit of the subunit. This means that + any modification of the parent unit or one of its subunits affects the + compilation of O. + + @item + The object file for a parent unit depends on all its subunit body files. + + @item + The previous two rules meant that for purposes of computing dependencies and + recompilation, a body and all its subunits are treated as an indivisible whole. + + @noindent + These rules are applied transitively: if unit @code{A} @code{with}'s + unit @code{B}, whose elaboration calls an inlined procedure in package + @code{C}, the object file for unit @code{A} will depend on the body of + @code{C}, in file @file{c.adb}. + + The set of dependent files described by these rules includes all the + files on which the unit is semantically dependent, as described in the + Ada 95 Language Reference Manual. However, it is a superset of what the + ARM describes, because it includes generic, inline, and subunit dependencies. + + An object file must be recreated by recompiling the corresponding source + file if any of the source files on which it depends are modified. For + example, if the @code{make} utility is used to control compilation, + the rule for an Ada object file must mention all the source files on + which the object file depends, according to the above definition. + The determination of the necessary + recompilations is done automatically when one uses @code{gnatmake}. + @end itemize + + @node The Ada Library Information Files + @section The Ada Library Information Files + @cindex Ada Library Information files + @cindex @file{ali} files + + @noindent + Each compilation actually generates two output files. The first of these + is the normal object file that has a @file{.o} extension. The second is a + text file containing full dependency information. It has the same + name as the source file, but an @file{.ali} extension. + This file is known as the Ada Library Information (@file{ali}) file. + The following information is contained in the @file{ali} file. + + @itemize @bullet + @item + Version information (indicates which version of GNAT was used to compile + the unit(s) in question) + + @item + Main program information (including priority and time slice settings, + as well as the wide character encoding used during compilation). + + @item + List of arguments used in the @code{gcc} command for the compilation + + @item + Attributes of the unit, including configuration pragmas used, an indication + of whether the compilation was successful, exception model used etc. + + @item + A list of relevant restrictions applying to the unit (used for consistency) + checking. + + @item + Categorization information (e.g. use of pragma @code{Pure}). + + @item + Information on all @code{with}'ed units, including presence of + @code{Elaborate} or @code{Elaborate_All} pragmas. + + @item + Information from any @code{Linker_Options} pragmas used in the unit + + @item + Information on the use of @code{Body_Version} or @code{Version} + attributes in the unit. + + @item + Dependency information. This is a list of files, together with + time stamp and checksum information. These are files on which + the unit depends in the sense that recompilation is required + if any of these units are modified. + + @item + Cross-reference data. Contains information on all entities referenced + in the unit. Used by tools like @code{gnatxref} and @code{gnatfind} to + provide cross-reference information. + + @end itemize + + @noindent + For a full detailed description of the format of the @file{ali} file, + see the source of the body of unit @code{Lib.Writ}, contained in file + @file{lib-writ.adb} in the GNAT compiler sources. + + @node Binding an Ada Program + @section Binding an Ada Program + + @noindent + When using languages such as C and C++, once the source files have been + compiled the only remaining step in building an executable program + is linking the object modules together. This means that it is possible to + link an inconsistent version of a program, in which two units have + included different versions of the same header. + + The rules of Ada do not permit such an inconsistent program to be built. + For example, if two clients have different versions of the same package, + it is illegal to build a program containing these two clients. + These rules are enforced by the GNAT binder, which also determines an + elaboration order consistent with the Ada rules. + + The GNAT binder is run after all the object files for a program have + been created. It is given the name of the main program unit, and from + this it determines the set of units required by the program, by reading the + corresponding ALI files. It generates error messages if the program is + inconsistent or if no valid order of elaboration exists. + + If no errors are detected, the binder produces a main program, in Ada by + default, that contains calls to the elaboration procedures of those + compilation unit that require them, followed by + a call to the main program. This Ada program is compiled to generate the + object file for the main program. The name of + the Ada file is @file{b~@var{xxx}.adb} (with the corresponding spec + @file{b~@var{xxx}.ads}) where @var{xxx} is the name of the + main program unit. + + Finally, the linker is used to build the resulting executable program, + using the object from the main program from the bind step as well as the + object files for the Ada units of the program. + + @node Mixed Language Programming + @section Mixed Language Programming + @cindex Mixed Language Programming + + @menu + * Interfacing to C:: + * Calling Conventions:: + @end menu + + @node Interfacing to C + @subsection Interfacing to C + @noindent + There are two ways to + build a program that contains some Ada files and some other language + files depending on whether the main program is in Ada or not. + If the main program is in Ada, you should proceed as follows: + + @enumerate + @item + Compile the other language files to generate object files. For instance: + @smallexample + gcc -c file1.c + gcc -c file2.c + @end smallexample + + @item + Compile the Ada units to produce a set of object files and ALI + files. For instance: + @smallexample + gnatmake -c my_main.adb + @end smallexample + + @item + Run the Ada binder on the Ada main program. For instance: + @smallexample + gnatbind my_main.ali + @end smallexample + + @item + Link the Ada main program, the Ada objects and the other language + objects. For instance: + @smallexample + gnatlink my_main.ali file1.o file2.o + @end smallexample + @end enumerate + + The three last steps can be grouped in a single command: + @smallexample + gnatmake my_main.adb -largs file1.o file2.o + @end smallexample + + @cindex Binder output file + @noindent + If the main program is in some language other than Ada, Then you may + have more than one entry point in the Ada subsystem. You must use a + special option of the binder to generate callable routines to initialize + and finalize the Ada units (@pxref{Binding with Non-Ada Main Programs}). + Calls to the initialization and finalization routines must be inserted in + the main program, or some other appropriate point in the code. The call to + initialize the Ada units must occur before the first Ada subprogram is + called, and the call to finalize the Ada units must occur after the last + Ada subprogram returns. You use the same procedure for building the + program as described previously. In this case, however, the binder + only places the initialization and finalization subprograms into file + @file{b~@var{xxx}.adb} instead of the main program. + So, if the main program is not in Ada, you should proceed as follows: + + @enumerate + @item + Compile the other language files to generate object files. For instance: + @smallexample + gcc -c file1.c + gcc -c file2.c + @end smallexample + + @item + Compile the Ada units to produce a set of object files and ALI + files. For instance: + @smallexample + gnatmake -c entry_point1.adb + gnatmake -c entry_point2.adb + @end smallexample + + @item + Run the Ada binder on the Ada main program. For instance: + @smallexample + gnatbind -n entry_point1.ali entry_point2.ali + @end smallexample + + @item + Link the Ada main program, the Ada objects and the other language + objects. You only need to give the last entry point here. For instance: + @smallexample + gnatlink entry_point2.ali file1.o file2.o + @end smallexample + @end enumerate + + @node Calling Conventions + @subsection Calling Conventions + @cindex Foreign Languages + @cindex Calling Conventions + GNAT follows standard calling sequence conventions and will thus interface + to any other language that also follows these conventions. The following + Convention identifiers are recognized by GNAT: + + @itemize @bullet + @cindex Interfacing to Ada + @cindex Other Ada compilers + @cindex Convention Ada + @item + Ada. This indicates that the standard Ada calling sequence will be + used and all Ada data items may be passed without any limitations in the + case where GNAT is used to generate both the caller and callee. It is also + possible to mix GNAT generated code and code generated by another Ada + compiler. In this case, the data types should be restricted to simple + cases, including primitive types. Whether complex data types can be passed + depends on the situation. Probably it is safe to pass simple arrays, such + as arrays of integers or floats. Records may or may not work, depending + on whether both compilers lay them out identically. Complex structures + involving variant records, access parameters, tasks, or protected types, + are unlikely to be able to be passed. + + Note that in the case of GNAT running + on a platform that supports DEC Ada 83, a higher degree of compatibility + can be guaranteed, and in particular records are layed out in an identical + manner in the two compilers. Note also that if output from two different + compilers is mixed, the program is responsible for dealing with elaboration + issues. Probably the safest approach is to write the main program in the + version of Ada other than GNAT, so that it takes care of its own elaboration + requirements, and then call the GNAT-generated adainit procedure to ensure + elaboration of the GNAT components. Consult the documentation of the other + Ada compiler for further details on elaboration. + + However, it is not possible to mix the tasking run time of GNAT and + DEC Ada 83, All the tasking operations must either be entirely within + GNAT compiled sections of the program, or entirely within DEC Ada 83 + compiled sections of the program. + + @cindex Interfacing to Assembly + @cindex Convention Assembler + @item + Assembler. Specifies assembler as the convention. In practice this has the + same effect as convention Ada (but is not equivalent in the sense of being + considered the same convention). + + @cindex Convention Asm + @findex Asm + @item + Asm. Equivalent to Assembler. + + @cindex Convention Asm + @findex Asm + @item + Asm. Equivalent to Assembly. + + @cindex Interfacing to COBOL + @cindex Convention COBOL + @findex COBOL + @item + COBOL. Data will be passed according to the conventions described + in section B.4 of the Ada 95 Reference Manual. + + @findex C + @cindex Interfacing to C + @cindex Convention C + @item + C. Data will be passed according to the conventions described + in section B.3 of the Ada 95 Reference Manual. + + @cindex Convention Default + @findex Default + @item + Default. Equivalent to C. + + @cindex Convention External + @findex External + @item + External. Equivalent to C. + + @findex C++ + @cindex Interfacing to C++ + @cindex Convention C++ + @item + CPP. This stands for C++. For most purposes this is identical to C. + See the separate description of the specialized GNAT pragmas relating to + C++ interfacing for further details. + + @findex Fortran + @cindex Interfacing to Fortran + @cindex Convention Fortran + @item + Fortran. Data will be passed according to the conventions described + in section B.5 of the Ada 95 Reference Manual. + + @item + Intrinsic. This applies to an intrinsic operation, as defined in the Ada 95 + Reference Manual. If a a pragma Import (Intrinsic) applies to a subprogram, + this means that the body of the subprogram is provided by the compiler itself, + usually by means of an efficient code sequence, and that the user does not + supply an explicit body for it. In an application program, the pragma can only + be applied to the following two sets of names, which the GNAT compiler + recognizes. + @itemize @bullet + @item + Rotate_Left, Rotate_Right, Shift_Left, Shift_Right, Shift_Right_- + Arithmetic. The corresponding subprogram declaration must have + two formal parameters. The + first one must be a signed integer type or a modular type with a binary + modulus, and the second parameter must be of type Natural. + The return type must be the same as the type of the first argument. The size + of this type can only be 8, 16, 32, or 64. + @item binary arithmetic operators: "+", "-", "*", "/" + The corresponding operator declaration must have parameters and result type + that have the same root numeric type (for example, all three are long_float + types). This simplifies the definition of operations that use type checking + to perform dimensional checks: + @smallexample + type Distance is new Long_Float; + type Time is new Long_Float; + type Velocity is new Long_Float; + function "/" (D : Distance; T : Time) + return Velocity; + pragma Import (Intrinsic, "/"); + @end smallexample + @noindent + This common idiom is often programmed with a generic definition and an explicit + body. The pragma makes it simpler to introduce such declarations. It incurs + no overhead in compilation time or code size, because it is implemented as a + single machine instruction. + @end itemize + @noindent + + @findex Stdcall + @cindex Convention Stdcall + @item + Stdcall. This is relevant only to NT/Win95 implementations of GNAT, + and specifies that the Stdcall calling sequence will be used, as defined + by the NT API. + + @findex DLL + @cindex Convention DLL + @item + DLL. This is equivalent to Stdcall. + + @findex Win32 + @cindex Convention Win32 + @item + Win32. This is equivalent to Stdcall. + + @findex Stubbed + @cindex Convention Stubbed + @item + Stubbed. This is a special convention that indicates that the compiler + should provide a stub body that raises @code{Program_Error}. + @end itemize + + @noindent + GNAT additionally provides a useful pragma @code{Convention_Identifier} + that can be used to parametrize conventions and allow additional synonyms + to be specified. For example if you have legacy code in which the convention + identifier Fortran77 was used for Fortran, you can use the configuration + pragma: + + @smallexample + pragma Convention_Identifier (Fortran77, Fortran); + @end smallexample + + @noindent + And from now on the identifier Fortran77 may be used as a convention + identifier (for example in an @code{Import} pragma) with the same + meaning as Fortran. + + @node Building Mixed Ada & C++ Programs + @section Building Mixed Ada & C++ Programs + + @noindent + Building a mixed application containing both Ada and C++ code may be a + challenge for the unaware programmer. As a matter of fact, this + interfacing has not been standardized in the Ada 95 reference manual due + to the immaturity and lack of standard of C++ at the time. This + section gives a few hints that should make this task easier. In + particular the first section addresses the differences with + interfacing with C. The second section looks into the delicate problem + of linking the complete application from its Ada and C++ parts. The last + section give some hints on how the GNAT run time can be adapted in order + to allow inter-language dispatching with a new C++ compiler. + + @menu + * Interfacing to C++:: + * Linking a Mixed C++ & Ada Program:: + * A Simple Example:: + * Adapting the Run Time to a New C++ Compiler:: + @end menu + + @node Interfacing to C++ + @subsection Interfacing to C++ + + @noindent + GNAT supports interfacing with C++ compilers generating code that is + compatible with the standard Application Binary Interface of the given + platform. + + @noindent + Interfacing can be done at 3 levels: simple data, subprograms and + classes. In the first 2 cases, GNAT offer a specific @var{Convention + CPP} that behaves exactly like @var{Convention C}. Usually C++ mangle + names of subprograms and currently GNAT does not provide any help to + solve the demangling problem. This problem can be addressed in 2 ways: + @itemize @bullet + @item + by modifying the C++ code in order to force a C convention using + the @var{extern "C"} syntax. + + @item + by figuring out the mangled name and use it as the Link_Name argument of + the pragma import. + @end itemize + + @noindent + Interfacing at the class level can be achieved by using the GNAT specific + pragmas such as @code{CPP_Class} and @code{CPP_Virtual}. See the GNAT + Reference Manual for additional information. + + @node Linking a Mixed C++ & Ada Program + @subsection Linking a Mixed C++ & Ada Program + + @noindent + Usually the linker of the C++ development system must be used to link + mixed applications because most C++ systems will resolve elaboration + issues (such as calling constructors on global class instances) + transparently during the link phase. GNAT has been adapted to ease the + use of a foreign linker for the last phase. Three cases can be + considered: + @enumerate + + @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 request recompiling the whole GCC + tree from sources and it does not allow to upgrade easily to a new + version of one compiler for one of the two languages without taking the + risk of destabilizing the other. + + @smallexample + $ c++ -c file1.C + $ c++ -c file2.C + $ gnatmake ada_unit -largs file1.o file2.o --LINK=c++ + @end smallexample + + @item + Using GNAT and G++ from 2 different GCC installations. If both compilers + are on the PATH, the same method can be used. It is important to be + aware that environment variables such as C_INCLUDE_PATH, + GCC_EXEC_PREFIX, BINUTILS_ROOT or GCC_ROOT will affect both compilers at + the same time and thus may make one of the 2 compilers operate + improperly if they are set for the other. In particular it is important + that the link command has access to the proper gcc library @file{libgcc.a}, + that is to say the one that is part of the C++ compiler + installation. The implicit link command as suggested in the gnatmake + command from the former example can be replaced by an explicit link + command with full verbosity in order to verify which library is used: + @smallexample + $ gnatbind ada_unit + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=c++ + @end smallexample + If there is a problem due to interfering environment variables, it can + be workaround by using an intermediate script. The following example + shows the proper script to use when GNAT has not been installed at its + default location and g++ has been installed at its default location: + + @smallexample + $ gnatlink -v -v ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + unset BINUTILS_ROOT + unset GCC_ROOT + c++ $* + @end smallexample + + @item + Using a non GNU C++ compiler. The same set of command as previously + described can be used to insure that the c++ linker is + used. Nonetheless, you need to add the path to libgcc explicitely, since some + libraries needed by GNAT are located in this directory: + + @smallexample + + $ gnatlink ada_unit file1.o file2.o --LINK=./my_script + $ cat ./my_script + #!/bin/sh + CC $* `gcc -print-libgcc-file-name` + + @end smallexample + + Where CC is the name of the non GNU C++ compiler. + + @end enumerate + + @node A Simple Example + @subsection A Simple Example + @noindent + The following example, provided as part of the GNAT examples, show how + to achieve procedural interfacing between Ada and C++ in both + directions. The C++ class A has 2 methods. The first method is exported + to Ada by the means of an extern C wrapper function. The second method + calls an Ada subprogram. On the Ada side, The C++ calls is modelized by + a limited record with a layout comparable to the C++ class. The Ada + subprogram, in turn, calls the c++ method. So from the C++ main program + the code goes back and forth between the 2 languages. + + @noindent + Here are the compilation commands + for native configurations: + @smallexample + $ gnatmake -c simple_cpp_interface + $ c++ -c cpp_main.C + $ c++ -c ex7.C + $ gnatbind -n simple_cpp_interface + $ gnatlink simple_cpp_interface -o cpp_main --LINK=$(CPLUSPLUS) + -lstdc++ ex7.o cpp_main.o + @end smallexample + @noindent + Here are the corresponding sources: + @smallexample + + //cpp_main.C + + #include "ex7.h" + + extern "C" @{ + void adainit (void); + void adafinal (void); + void method1 (A *t); + @} + + void method1 (A *t) + @{ + t->method1 (); + @} + + int main () + @{ + A obj; + adainit (); + obj.method2 (3030); + adafinal (); + @} + + //ex7.h + + class Origin @{ + public: + int o_value; + @}; + class A : public Origin @{ + public: + void method1 (void); + virtual void method2 (int v); + A(); + int a_value; + @}; + + //ex7.C + + #include "ex7.h" + #include + + extern "C" @{ void ada_method2 (A *t, int v);@} + + void A::method1 (void) + @{ + a_value = 2020; + printf ("in A::method1, a_value = %d \n",a_value); + + @} + + void A::method2 (int v) + @{ + ada_method2 (this, v); + printf ("in A::method2, a_value = %d \n",a_value); + + @} + + A::A(void) + @{ + a_value = 1010; + printf ("in A::A, a_value = %d \n",a_value); + @} + + -- Ada sources + @b{package} @b{body} Simple_Cpp_Interface @b{is} + + @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer) @b{is} + @b{begin} + Method1 (This); + This.A_Value := V; + @b{end} Ada_Method2; + + @b{end} Simple_Cpp_Interface; + + @b{package} Simple_Cpp_Interface @b{is} + @b{type} A @b{is} @b{limited} + @b{record} + O_Value : Integer; + A_Value : Integer; + @b{end} @b{record}; + @b{pragma} Convention (C, A); + + @b{procedure} Method1 (This : @b{in} @b{out} A); + @b{pragma} Import (C, Method1); + + @b{procedure} Ada_Method2 (This : @b{in} @b{out} A; V : Integer); + @b{pragma} Export (C, Ada_Method2); + + @b{end} Simple_Cpp_Interface; + @end smallexample + + @node Adapting the Run Time to a New C++ Compiler + @subsection Adapting the Run Time to a New C++ Compiler + @noindent + GNAT offers the capability to derive Ada 95 tagged types directly from + preexisting C++ classes and . See "Interfacing with C++" in the GNAT + reference manual. The mechanism used by GNAT for achieving such a goal + has been made user configurable through a GNAT library unit + @code{Interfaces.CPP}. The default version of this file is adapted to + the GNU c++ compiler. Internal knowledge of the virtual + table layout used by the new C++ compiler is needed to configure + properly this unit. The Interface of this unit is known by the compiler + and cannot be changed except for the value of the constants defining the + characteristics of the virtual table: CPP_DT_Prologue_Size, CPP_DT_Entry_Size, + CPP_TSD_Prologue_Size, CPP_TSD_Entry_Size. Read comments in the source + of this unit for more details. + + @node Comparison between GNAT and C/C++ Compilation Models + @section Comparison between GNAT and C/C++ Compilation Models + + @noindent + The GNAT model of compilation is close to the C and C++ models. You can + think of Ada specs as corresponding to header files in C. As in C, you + don't need to compile specs; they are compiled when they are used. The + Ada @code{with} is similar in effect to the @code{#include} of a C + header. + + One notable difference is that, in Ada, you may compile specs separately + to check them for semantic and syntactic accuracy. This is not always + possible with C headers because they are fragments of programs that have + less specific syntactic or semantic rules. + + The other major difference is the requirement for running the binder, + which performs two important functions. First, it checks for + consistency. In C or C++, the only defense against assembling + inconsistent programs lies outside the compiler, in a makefile, for + example. The binder satisfies the Ada requirement that it be impossible + to construct an inconsistent program when the compiler is used in normal + mode. + + @cindex Elaboration order control + The other important function of the binder is to deal with elaboration + issues. There are also elaboration issues in C++ that are handled + automatically. This automatic handling has the advantage of being + simpler to use, but the C++ programmer has no control over elaboration. + Where @code{gnatbind} might complain there was no valid order of + elaboration, a C++ compiler would simply construct a program that + malfunctioned at run time. + + @node Comparison between GNAT and Conventional Ada Library Models + @section Comparison between GNAT and Conventional Ada Library Models + + @noindent + This section is intended to be useful to Ada programmers who have + previously used an Ada compiler implementing the traditional Ada library + model, as described in the Ada 95 Language Reference Manual. If you + have not used such a system, please go on to the next section. + + @cindex GNAT library + In GNAT, there is no @dfn{library} in the normal sense. Instead, the set of + source files themselves acts as the library. Compiling Ada programs does + not generate any centralized information, but rather an object file and + a ALI file, which are of interest only to the binder and linker. + In a traditional system, the compiler reads information not only from + the source file being compiled, but also from the centralized library. + This means that the effect of a compilation depends on what has been + previously compiled. In particular: + + @itemize @bullet + @item + When a unit is @code{with}'ed, the unit seen by the compiler corresponds + to the version of the unit most recently compiled into the library. + + @item + Inlining is effective only if the necessary body has already been + compiled into the library. + + @item + Compiling a unit may obsolete other units in the library. + @end itemize + + @noindent + In GNAT, compiling one unit never affects the compilation of any other + units because the compiler reads only source files. Only changes to source + files can affect the results of a compilation. In particular: + + @itemize @bullet + @item + When a unit is @code{with}'ed, the unit seen by the compiler corresponds + to the source version of the unit that is currently accessible to the + compiler. + + @item + @cindex Inlining + Inlining requires the appropriate source files for the package or + subprogram bodies to be available to the compiler. Inlining is always + effective, independent of the order in which units are complied. + + @item + Compiling a unit never affects any other compilations. The editing of + sources may cause previous compilations to be out of date if they + depended on the source file being modified. + @end itemize + + @noindent + The most important result of these differences is that order of compilation + is never significant in GNAT. There is no situation in which one is + required to do one compilation before another. What shows up as order of + compilation requirements in the traditional Ada library becomes, in + GNAT, simple source dependencies; in other words, there is only a set + of rules saying what source files must be present when a file is + compiled. + + @node Compiling Using gcc + @chapter Compiling Using @code{gcc} + + @noindent + This chapter discusses how to compile Ada programs using the @code{gcc} + command. It also describes the set of switches + that can be used to control the behavior of the compiler. + @menu + * Compiling Programs:: + * Switches for gcc:: + * Search Paths and the Run-Time Library (RTL):: + * Order of Compilation Issues:: + * Examples:: + @end menu + + @node Compiling Programs + @section Compiling Programs + + @noindent + The first step in creating an executable program is to compile the units + of the program using the @code{gcc} command. You must compile the + following files: + + @itemize @bullet + @item + the body file (@file{.adb}) for a library level subprogram or generic + subprogram + + @item + the spec file (@file{.ads}) for a library level package or generic + package that has no body + + @item + the body file (@file{.adb}) for a library level package + or generic package that has a body + + @end itemize + + @noindent + You need @emph{not} compile the following files + + @itemize @bullet + + @item + the spec of a library unit which has a body + + @item + subunits + @end itemize + + @noindent + because they are compiled as part of compiling related units. GNAT + package specs + when the corresponding body is compiled, and subunits when the parent is + compiled. + @cindex No code generated + If you attempt to compile any of these files, you will get one of the + following error messages (where fff is the name of the file you compiled): + + @smallexample + No code generated for file @var{fff} (@var{package spec}) + No code generated for file @var{fff} (@var{subunit}) + @end smallexample + + @noindent + The basic command for compiling a file containing an Ada unit is + + @smallexample + $ gcc -c [@var{switches}] @file{file name} + @end smallexample + + @noindent + where @var{file name} is the name of the Ada file (usually + having an extension + @file{.ads} for a spec or @file{.adb} for a body). + You specify the + @code{-c} switch to tell @code{gcc} to compile, but not link, the file. + The result of a successful compilation is an object file, which has the + same name as the source file but an extension of @file{.o} and an Ada + Library Information (ALI) file, which also has the same name as the + source file, but with @file{.ali} as the extension. GNAT creates these + two output files in the current directory, but you may specify a source + file in any directory using an absolute or relative path specification + containing the directory information. + + @findex gnat1 + @code{gcc} is actually a driver program that looks at the extensions of + the file arguments and loads the appropriate compiler. For example, the + GNU C compiler is @file{cc1}, and the Ada compiler is @file{gnat1}. + These programs are in directories known to the driver program (in some + configurations via environment variables you set), but need not be in + your path. The @code{gcc} driver also calls the assembler and any other + utilities needed to complete the generation of the required object + files. + + It is possible to supply several file names on the same @code{gcc} + command. This causes @code{gcc} to call the appropriate compiler for + each file. For example, the following command lists three separate + files to be compiled: + + @smallexample + $ gcc -c x.adb y.adb z.c + @end smallexample + + @noindent + calls @code{gnat1} (the Ada compiler) twice to compile @file{x.adb} and + @file{y.adb}, and @code{cc1} (the C compiler) once to compile @file{z.c}. + The compiler generates three object files @file{x.o}, @file{y.o} and + @file{z.o} and the two ALI files @file{x.ali} and @file{y.ali} from the + Ada compilations. Any switches apply to all the files listed, + except for + @option{-gnat@var{x}} switches, which apply only to Ada compilations. + + @node Switches for gcc + @section Switches for @code{gcc} + + @noindent + The @code{gcc} command accepts switches that control the + compilation process. These switches are fully described in this section. + First we briefly list all the switches, in alphabetical order, then we + describe the switches in more detail in functionally grouped sections. + + @menu + * Output and Error Message Control:: + * Debugging and Assertion Control:: + * Run-Time Checks:: + * Stack Overflow Checking:: + * Run-Time Control:: + * Validity Checking:: + * Style Checking:: + * Using gcc for Syntax Checking:: + * Using gcc for Semantic Checking:: + * Compiling Ada 83 Programs:: + * Character Set Control:: + * File Naming Control:: + * Subprogram Inlining Control:: + * Auxiliary Output Control:: + * Debugging Control:: + * Units to Sources Mapping Files:: + @end menu + + @table @code + @cindex @code{-b} (@code{gcc}) + @item -b @var{target} + Compile your program to run on @var{target}, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + @var{target} is not the same as your host system. + + @item -B@var{dir} + @cindex @code{-B} (@code{gcc}) + Load compiler executables (for example, @code{gnat1}, the Ada compiler) + from @var{dir} instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + @code{gcc} manual page for further details. You would normally use the + @code{-b} or @code{-V} switch instead. + + @item -c + @cindex @code{-c} (@code{gcc}) + Compile. Always use this switch when compiling Ada programs. + + Note: for some other languages when using @code{gcc}, notably in + the case of C and C++, it is possible to use + use @code{gcc} without a @code{-c} switch to + compile and link in one step. In the case of GNAT, you + cannot use this approach, because the binder must be run + and @code{gcc} cannot be used to run the GNAT binder. + + @item -g + @cindex @code{-g} (@code{gcc}) + Generate debugging information. This information is stored in the object + file and copied from there to the final executable file by the linker, + where it can be read by the debugger. You must use the + @code{-g} switch if you plan on using the debugger. + + @item -I@var{dir} + @cindex @code{-I} (@code{gcc}) + @cindex RTL + Direct GNAT to search the @var{dir} directory for source files needed by + the current compilation + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item -I- + @cindex @code{-I-} (@code{gcc}) + @cindex RTL + Except for the source file named in the command line, do not look for source files + in the directory containing the source file named in the command line + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item -o @var{file} + @cindex @code{-o} (@code{gcc}) + This switch is used in @code{gcc} to redirect the generated object file + and its associated ALI file. Beware of this switch with GNAT, because it may + cause the object file and ALI file to have different names which in turn + may confuse the binder and the linker. + + @item -O[@var{n}] + @cindex @code{-O} (@code{gcc}) + @var{n} controls the optimization level. + + @table @asis + @item n = 0 + No optimization, the default setting if no @code{-O} appears + + @item n = 1 + Normal optimization, the default if you specify @code{-O} without + an operand. + + @item n = 2 + Extensive optimization + + @item n = 3 + Extensive optimization with automatic inlining. This applies only to + inlining within a unit. For details on control of inter-unit inlining + see @xref{Subprogram Inlining Control}. + @end table + + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gcc}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -S + @cindex @code{-S} (@code{gcc}) + Used in place of @code{-c} to + cause the assembler source file to be + generated, using @file{.s} as the extension, + instead of the object file. + This may be useful if you need to examine the generated assembly code. + + @item -v + @cindex @code{-v} (@code{gcc}) + Show commands generated by the @code{gcc} driver. Normally used only for + debugging purposes or if you need to be sure what version of the + compiler you are executing. + + @item -V @var{ver} + @cindex @code{-V} (@code{gcc}) + Execute @var{ver} version of the compiler. This is the @code{gcc} + version, not the GNAT version. + + @item -gnata + Assertions enabled. @code{Pragma Assert} and @code{pragma Debug} to be + activated. + + @item -gnatA + Avoid processing @file{gnat.adc}. If a gnat.adc file is present, it will be ignored. + + @item -gnatb + Generate brief messages to @file{stderr} even if verbose mode set. + + @item -gnatc + Check syntax and semantics only (no code generation attempted). + + @item -gnatC + Compress debug information and external symbol name table entries. + + @item -gnatD + Output expanded source files for source level debugging. This switch + also suppress generation of cross-reference information (see -gnatx). + + @item -gnatec@var{path} + Specify a configuration pragma file. (see @ref{The Configuration Pragmas Files}) + + @item -gnatem@var{path} + Specify a mapping file. (see @ref{Units to Sources Mapping Files}) + + @item -gnatE + Full dynamic elaboration checks. + + @item -gnatf + Full errors. Multiple errors per line, all undefined references. + + @item -gnatF + Externals names are folded to all uppercase. + + @item -gnatg + Internal GNAT implementation mode. This should not be used for + applications programs, it is intended only for use by the compiler + and its run-time library. For documentation, see the GNAT sources. + + @item -gnatG + List generated expanded code in source form. + + @item -gnati@var{c} + Identifier character set + (@var{c}=1/2/3/4/8/9/p/f/n/w). + + @item -gnath + Output usage information. The output is written to @file{stdout}. + + @item -gnatk@var{n} + Limit file names to @var{n} (1-999) characters (@code{k} = krunch). + + @item -gnatl + Output full source listing with embedded error messages. + + @item -gnatm@var{n} + Limit number of detected errors to @var{n} (1-999). + + @item -gnatn + Activate inlining across unit boundaries for subprograms for which + pragma @code{inline} is specified. + + @item -gnatN + Activate front end inlining. + + @item -fno-inline + Suppresses all inlining, even if other optimization or inlining switches + are set. + + @item -fstack-check + Activates stack checking. See separate section on stack checking for + details of the use of this option. + + @item -gnato + Enable numeric overflow checking (which is not normally enabled by + default). Not that division by zero is a separate check that is not + controlled by this switch (division by zero checking is on by default). + + @item -gnatp + Suppress all checks. + + @item -gnatq + Don't quit; try semantics, even if parse errors. + + @item -gnatQ + Don't quit; generate @file{ali} and tree files even if illegalities. + + @item -gnatP + Enable polling. This is required on some systems (notably Windows NT) to + obtain asynchronous abort and asynchronous transfer of control capability. + See the description of pragma Polling in the GNAT Reference Manual for + full details. + + @item -gnatR[0/1/2/3][s] + Output representation information for declared types and objects. + + @item -gnats + Syntax check only. + + @item -gnatt + Tree output file to be generated. + + @item -gnatT nnn + Set time slice to specified number of microseconds + + @item -gnatu + List units for this compilation. + + @item -gnatU + Tag all error messages with the unique string "error:" + + @item -gnatv + Verbose mode. Full error output with source lines to @file{stdout}. + + @item -gnatV + Control level of validity checking. See separate section describing + this feature. + + @item -gnatwxxx@var{xxx} + Warning mode where + @var{xxx} is a string of options describing the exact warnings that + are enabled or disabled. See separate section on warning control. + + @item -gnatW@var{e} + Wide character encoding method + (@var{e}=n/h/u/s/e/8). + + @item -gnatx + Suppress generation of cross-reference information. + + @item -gnaty + Enable built-in style checks. See separate section describing this feature. + + @item -gnatz@var{m} + Distribution stub generation and compilation + (@var{m}=r/c for receiver/caller stubs). + + @item -gnat83 + Enforce Ada 83 restrictions. + + @item -pass-exit-codes + Catch exit codes from the compiler and use the most meaningful as + exit status. + @end table + + You may combine a sequence of GNAT switches into a single switch. For + example, the combined switch + + @cindex Combining GNAT switches + @smallexample + -gnatofi3 + @end smallexample + + @noindent + is equivalent to specifying the following sequence of switches: + + @smallexample + -gnato -gnatf -gnati3 + @end smallexample + + @noindent + The following restrictions apply to the combination of switches + in this manner: + + @itemize @bullet + @item + The switch @option{-gnatc} if combined with other switches must come + first in the string. + + @item + The switch @option{-gnats} if combined with other switches must come + first in the string. + + @item + Once a "y" appears in the string (that is a use of the @option{-gnaty} + switch), then all further characters in the switch are interpreted + as style modifiers (see description of @option{-gnaty}). + + @item + Once a "d" appears in the string (that is a use of the @option{-gnatd} + switch), then all further characters in the switch are interpreted + as debug flags (see description of @option{-gnatd}). + + @item + Once a "w" appears in the string (that is a use of the @option{-gnatw} + switch), then all further characters in the switch are interpreted + as warning mode modifiers (see description of @option{-gnatw}). + + @item + 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 + as validity checking options (see description of @option{-gnatV}). + + @end itemize + + @node Output and Error Message Control + @subsection Output and Error Message Control + @findex stderr + + @noindent + The standard default format for error messages is called "brief format." + Brief format messages are written to @file{stderr} (the standard error + file) and have the following form: + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:4:20: ";" should be "is" + @end smallexample + + @noindent + The first integer after the file name is the line number in the file, + and the second integer is the column number within the line. + @code{glide} can parse the error messages + and point to the referenced character. + The following switches provide control over the error message + format: + + @table @code + @item -gnatv + @cindex @option{-gnatv} (@code{gcc}) + @findex stdout + The v stands for verbose. + The effect of this setting is to write long-format error + messages to @file{stdout} (the standard output file. + The same program compiled with the + @option{-gnatv} switch would generate: + + @smallexample + @group + @cartouche + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + @end cartouche + @end group + @end smallexample + + @noindent + The vertical bar indicates the location of the error, and the @samp{>>>} + prefix can be used to search for error messages. When this switch is + used the only source lines output are those with errors. + + @item -gnatl + @cindex @option{-gnatl} (@code{gcc}) + The @code{l} stands for list. + This switch causes a full listing of + the file to be generated. The output might look as follows: + + @smallexample + @group + @cartouche + 1. procedure E is + 2. V : Integer; + 3. funcion X (Q : Integer) + | + >>> Incorrect spelling of keyword "function" + 4. return Integer; + | + >>> ";" should be "is" + 5. begin + 6. return Q + Q; + 7. end; + 8. begin + 9. V := X + X; + 10.end E; + @end cartouche + @end group + @end smallexample + + @noindent + @findex stderr + When you specify the @option{-gnatv} or @option{-gnatl} switches and + standard output is redirected, a brief summary is written to + @file{stderr} (standard error) giving the number of error messages and + warning messages generated. + + @item -gnatU + @cindex @option{-gnatU} (@code{gcc}) + This switch forces all error messages to be preceded by the unique + string "error:". This means that error messages take a few more + characters in space, but allows easy searching for and identification + of error messages. + + @item -gnatb + @cindex @option{-gnatb} (@code{gcc}) + The @code{b} stands for brief. + This switch causes GNAT to generate the + brief format error messages to @file{stderr} (the standard error + file) as well as the verbose + format message or full listing (which as usual is written to + @file{stdout} (the standard output file). + + @item -gnatm@var{n} + @cindex @option{-gnatm} (@code{gcc}) + The @code{m} stands for maximum. + @var{n} is a decimal integer in the + range of 1 to 999 and limits the number of error messages to be + generated. For example, using @option{-gnatm2} might yield + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + e.adb:3:04: Incorrect spelling of keyword "function" + e.adb:5:35: missing ".." + fatal error: maximum errors reached + compilation abandoned + @end smallexample + + @item -gnatf + @cindex @option{-gnatf} (@code{gcc}) + @cindex Error messages, suppressing + The @code{f} stands for full. + Normally, the compiler suppresses error messages that are likely to be + redundant. This switch causes all error + messages to be generated. In particular, in the case of + references to undefined variables. If a given variable is referenced + several times, the normal format of messages is + @smallexample + @iftex + @leftskip=.7cm + @end iftex + e.adb:7:07: "V" is undefined (more references follow) + @end smallexample + + @noindent + where the parenthetical comment warns that there are additional + references to the variable @code{V}. Compiling the same program with the + @option{-gnatf} switch yields + + @smallexample + e.adb:7:07: "V" is undefined + e.adb:8:07: "V" is undefined + e.adb:8:12: "V" is undefined + e.adb:8:16: "V" is undefined + e.adb:9:07: "V" is undefined + e.adb:9:12: "V" is undefined + @end smallexample + + @item -gnatq + @cindex @option{-gnatq} (@code{gcc}) + The @code{q} stands for quit (really "don't quit"). + In normal operation mode, the compiler first parses the program and + determines if there are any syntax errors. If there are, appropriate + error messages are generated and compilation is immediately terminated. + This switch tells + GNAT to continue with semantic analysis even if syntax errors have been + found. This may enable the detection of more errors in a single run. On + the other hand, the semantic analyzer is more likely to encounter some + internal fatal error when given a syntactically invalid tree. + + @item -gnatQ + In normal operation mode, the @file{ali} file is not generated if any + illegalities are detected in the program. The use of @option{-gnatQ} forces + generation of the @file{ali} file. This file is marked as being in + error, so it cannot be used for binding purposes, but it does contain + reasonably complete cross-reference information, and thus may be useful + for use by tools (e.g. semantic browsing tools or integrated development + environments) that are driven from the @file{ali} file. + + In addition, if @option{-gnatt} is also specified, then the tree file is + generated even if there are illegalities. It may be useful in this case + to also specify @option{-gnatq} to ensure that full semantic processing + occurs. The resulting tree file can be processed by ASIS, for the purpose + of providing partial information about illegal units, but if the error + causes the tree to be badly malformed, then ASIS may crash during the + analysis. + + @end table + + @noindent + In addition to error messages, which correspond to illegalities as defined + in the Ada 95 Reference Manual, the compiler detects two kinds of warning + situations. + + @cindex Warning messages + First, the compiler considers some constructs suspicious and generates a + warning message to alert you to a possible error. Second, if the + compiler detects a situation that is sure to raise an exception at + run time, it generates a warning message. The following shows an example + of warning messages: + @smallexample + @iftex + @leftskip=.2cm + @end iftex + e.adb:4:24: warning: creation of object may raise Storage_Error + e.adb:10:17: warning: static value out of range + e.adb:10:17: warning: "Constraint_Error" will be raised at run time + + @end smallexample + + @noindent + GNAT considers a large number of situations as appropriate + for the generation of warning messages. As always, warnings are not + definite indications of errors. For example, if you do an out-of-range + assignment with the deliberate intention of raising a + @code{Constraint_Error} exception, then the warning that may be + issued does not indicate an error. Some of the situations for which GNAT + issues warnings (at least some of the time) are given in the following + list, which is not necessarily complete. + + @itemize @bullet + @item + Possible infinitely recursive calls + + @item + Out-of-range values being assigned + + @item + Possible order of elaboration problems + + @item + Unreachable code + + @item + Fixed-point type declarations with a null range + + @item + Variables that are never assigned a value + + @item + Variables that are referenced before being initialized + + @item + Task entries with no corresponding accept statement + + @item + Duplicate accepts for the same task entry in a select + + @item + Objects that take too much storage + + @item + Unchecked conversion between types of differing sizes + + @item + Missing return statements along some execution paths in a function + + @item + Incorrect (unrecognized) pragmas + + @item + Incorrect external names + + @item + Allocation from empty storage pool + + @item + Potentially blocking operations in protected types + + @item + Suspicious parenthesization of expressions + + @item + Mismatching bounds in an aggregate + + @item + Attempt to return local value by reference + + @item + Unrecognized pragmas + + @item + Premature instantiation of a generic body + + @item + Attempt to pack aliased components + + @item + Out of bounds array subscripts + + @item + Wrong length on string assignment + + @item + Violations of style rules if style checking is enabled + + @item + Unused with clauses + + @item + Bit_Order usage that does not have any effect + + @item + Compile time biased rounding of floating-point constant + + @item + Standard.Duration used to resolve universal fixed expression + + @item + Dereference of possibly null value + + @item + Declaration that is likely to cause storage error + + @item + Internal GNAT unit with'ed by application unit + + @item + Values known to be out of range at compile time + + @item + Unreferenced labels and variables + + @item + Address overlays that could clobber memory + + @item + Unexpected initialization when address clause present + + @item + Bad alignment for address clause + + @item + Useless type conversions + + @item + Redundant assignment statements + + @item + Accidental hiding of name by child unit + + @item + Unreachable code + + @item + Access before elaboration detected at compile time + + @item + A range in a @code{for} loop that is known to be null or might be null + + @end itemize + + @noindent + The following switches are available to control the handling of + warning messages: + + @table @code + @item -gnatwa (activate all optional errors) + @cindex @option{-gnatwa} (@code{gcc}) + This switch activates most optional warning messages, see remaining list + in this section for details on optional warning messages that can be + individually controlled. The warnings that are not turned on by this + switch are @option{-gnatwb} (biased rounding), + @option{-gnatwd} (implicit dereferencing), + and @option{-gnatwh} (hiding). All other optional warnings are + turned on. + + @item -gnatwA (suppress all optional errors) + @cindex @option{-gnatwA} (@code{gcc}) + This switch suppresses all optional warning messages, see remaining list + in this section for details on optional warning messages that can be + individually controlled. + + @item -gnatwb (activate warnings on biased rounding) + @cindex @option{-gnatwb} (@code{gcc}) + @cindex Rounding, biased + @cindex Biased rounding + If a static floating-point expression has a value that is exactly half + way between two adjacent machine numbers, then the rules of Ada + (Ada Reference Manual, section 4.9(38)) require that this rounding + be done away from zero, even if the normal unbiased rounding rules + at run time would require rounding towards zero. This warning message + alerts you to such instances where compile-time rounding and run-time + rounding are not equivalent. If it is important to get proper run-time + rounding, then you can force this by making one of the operands into + a variable. The default is that such warnings are not generated. + Note that @option{-gnatwa} does not affect the setting of + this warning option. + + @item -gnatwB (suppress warnings on biased rounding) + @cindex @option{-gnatwB} (@code{gcc}) + This switch disables warnings on biased rounding. + + @item -gnatwc (activate warnings on conditionals) + @cindex @option{-gnatwc} (@code{gcc}) + @cindex Conditionals, constant + This switch activates warnings for conditional expressions used in + tests that are known to be True or False at compile time. The default + is that such warnings are not generated. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwC (suppress warnings on conditionals) + @cindex @option{-gnatwC} (@code{gcc}) + This switch suppresses warnings for conditional expressions used in + tests that are known to be True or False at compile time. + + @item -gnatwd (activate warnings on implicit dereferencing) + @cindex @option{-gnatwd} (@code{gcc}) + If this switch is set, then the use of a prefix of an access type + in an indexed component, slice, or selected component without an + explicit @code{.all} will generate a warning. With this warning + enabled, access checks occur only at points where an explicit + @code{.all} appears in the source code (assuming no warnings are + generated as a result of this switch). The default is that such + warnings are not generated. + Note that @option{-gnatwa} does not affect the setting of + this warning option. + + @item -gnatwD (suppress warnings on implicit dereferencing) + @cindex @option{-gnatwD} (@code{gcc}) + @cindex Implicit dereferencing + @cindex Dereferencing, implicit + This switch suppresses warnings for implicit deferences in + indexed components, slices, and selected components. + + @item -gnatwe (treat warnings as errors) + @cindex @option{-gnatwe} (@code{gcc}) + @cindex Warnings, treat as error + This switch causes warning messages to be treated as errors. + The warning string still appears, but the warning messages are counted + as errors, and prevent the generation of an object file. + + @item -gnatwf (activate warnings on unreferenced formals) + @cindex @option{-gnatwf} (@code{gcc}) + @cindex Formals, unreferenced + This switch causes a warning to be generated if a formal parameter + is not referenced in the body of the subprogram. This warning can + also be turned on using @option{-gnatwa} or @option{-gnatwu}. + + @item -gnatwF (suppress warnings on unreferenced formals) + @cindex @option{-gnatwF} (@code{gcc}) + This switch suppresses warnings for unreferenced formal + parameters. Note that the + combination @option{-gnatwu} followed by @option{-gnatwF} has the + effect of warning on unreferenced entities other than subprogram + formals. + + @item -gnatwh (activate warnings on hiding) + @cindex @option{-gnatwh} (@code{gcc}) + @cindex Hiding of Declarations + This switch activates warnings on hiding declarations. + A declaration is considered hiding + if it is for a non-overloadable entity, and it declares an entity with the + same name as some other entity that is directly or use-visible. The default + is that such warnings are not generated. + Note that @option{-gnatwa} does not affect the setting of this warning option. + + @item -gnatwH (suppress warnings on hiding) + @cindex @option{-gnatwH} (@code{gcc}) + This switch suppresses warnings on hiding declarations. + + @item -gnatwi (activate warnings on implementation units). + @cindex @option{-gnatwi} (@code{gcc}) + This switch activates warnings for a @code{with} of an internal GNAT + implementation unit, defined as any unit from the @code{Ada}, + @code{Interfaces}, @code{GNAT}, + or @code{System} + hierarchies that is not + documented in either the Ada Reference Manual or the GNAT + Programmer's Reference Manual. Such units are intended only + for internal implementation purposes and should not be @code{with}'ed + by user programs. The default is that such warnings are generated + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwI (disable warnings on implementation units). + @cindex @option{-gnatwI} (@code{gcc}) + This switch disables warnings for a @code{with} of an internal GNAT + implementation unit. + + @item -gnatwl (activate warnings on elaboration pragmas) + @cindex @option{-gnatwl} (@code{gcc}) + @cindex Elaboration, warnings + This switch activates warnings on missing pragma Elaborate_All statements. + See the section in this guide on elaboration checking for details on + when such pragma should be used. The default is that such warnings + are not generated. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwL (suppress warnings on elaboration pragmas) + @cindex @option{-gnatwL} (@code{gcc}) + This switch suppresses warnings on missing pragma Elaborate_All statements. + See the section in this guide on elaboration checking for details on + when such pragma should be used. + + @item -gnatwo (activate warnings on address clause overlays) + @cindex @option{-gnatwo} (@code{gcc}) + @cindex Address Clauses, warnings + This switch activates warnings for possibly unintended initialization + effects of defining address clauses that cause one variable to overlap + another. The default is that such warnings are generated. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwO (suppress warnings on address clause overlays) + @cindex @option{-gnatwO} (@code{gcc}) + This switch suppresses warnings on possibly unintended initialization + effects of defining address clauses that cause one variable to overlap + another. + + @item -gnatwp (activate warnings on ineffective pragma Inlines) + @cindex @option{-gnatwp} (@code{gcc}) + @cindex Inlining, warnings + This switch activates warnings for failure of front end inlining + (activated by @option{-gnatN}) to inline a particular call. There are + many reasons for not being able to inline a call, including most + commonly that the call is too complex to inline. + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwP (suppress warnings on ineffective pragma Inlines) + @cindex @option{-gnatwP} (@code{gcc}) + This switch suppresses warnings on ineffective pragma Inlines. If the + inlining mechanism cannot inline a call, it will simply ignore the + request silently. + + @item -gnatwr (activate warnings on redundant constructs) + @cindex @option{-gnatwr} (@code{gcc}) + This switch activates warnings for redundant constructs. The following + is the current list of constructs regarded as redundant: + This warning can also be turned on using @option{-gnatwa}. + + @itemize @bullet + @item + Assignment of an item to itself. + @item + Type conversion that converts an expression to its own type. + @item + Use of the attribute @code{Base} where @code{typ'Base} is the same + as @code{typ}. + @item + Use of pragma @code{Pack} when all components are placed by a record + representation clause. + @end itemize + + @item -gnatwR (suppress warnings on redundant constructs) + @cindex @option{-gnatwR} (@code{gcc}) + This switch suppresses warnings for redundant constructs. + + @item -gnatws (suppress all warnings) + @cindex @option{-gnatws} (@code{gcc}) + This switch completely suppresses the + output of all warning messages from the GNAT front end. + Note that it does not suppress warnings from the @code{gcc} back end. + To suppress these back end warnings as well, use the switch @code{-w} + in addition to @option{-gnatws}. + + @item -gnatwu (activate warnings on unused entities) + @cindex @option{-gnatwu} (@code{gcc}) + This switch activates warnings to be generated for entities that + are defined but not referenced, and for units that are @code{with}'ed + and not + referenced. In the case of packages, a warning is also generated if + no entities in the package are referenced. This means that if the package + is referenced but the only references are in @code{use} + clauses or @code{renames} + declarations, a warning is still generated. A warning is also generated + for a generic package that is @code{with}'ed but never instantiated. + In the case where a package or subprogram body is compiled, and there + is a @code{with} on the corresponding spec + that is only referenced in the body, + a warning is also generated, noting that the + @code{with} can be moved to the body. The default is that + such warnings are not generated. + This switch also activates warnings on unreferenced formals + (it is includes the effect of @option{-gnatwf}). + This warning can also be turned on using @option{-gnatwa}. + + @item -gnatwU (suppress warnings on unused entities) + @cindex @option{-gnatwU} (@code{gcc}) + This switch suppresses warnings for unused entities and packages. + It also turns off warnings on unreferenced formals (and thus includes + the effect of @option{-gnatwF}). + + @noindent + A string of warning parameters can be used in the same parameter. For example: + + @smallexample + -gnatwaLe + @end smallexample + + @noindent + Would turn on all optional warnings except for elaboration pragma warnings, + and also specify that warnings should be treated as errors. + + @item -w + @cindex @code{-w} + This switch suppresses warnings from the @code{gcc} backend. It may be + used in conjunction with @option{-gnatws} to ensure that all warnings + are suppressed during the entire compilation process. + + @end table + + @node Debugging and Assertion Control + @subsection Debugging and Assertion Control + + @table @code + @item -gnata + @cindex @option{-gnata} (@code{gcc}) + @findex Assert + @findex Debug + @cindex Assertions + + @noindent + The pragmas @code{Assert} and @code{Debug} normally have no effect and + are ignored. This switch, where @samp{a} stands for assert, causes + @code{Assert} and @code{Debug} pragmas to be activated. + + The pragmas have the form: + + @smallexample + @group + @cartouche + @b{pragma} Assert (@var{Boolean-expression} [, + @var{static-string-expression}]) + @b{pragma} Debug (@var{procedure call}) + @end cartouche + @end group + @end smallexample + + @noindent + The @code{Assert} pragma causes @var{Boolean-expression} to be tested. + If the result is @code{True}, the pragma has no effect (other than + possible side effects from evaluating the expression). If the result is + @code{False}, the exception @code{Assert_Failure} declared in the package + @code{System.Assertions} is + raised (passing @var{static-string-expression}, if present, as the + message associated with the exception). If no string expression is + given the default is a string giving the file name and line number + of the pragma. + + The @code{Debug} pragma causes @var{procedure} to be called. Note that + @code{pragma Debug} may appear within a declaration sequence, allowing + debugging procedures to be called between declarations. + + @end table + + @node Validity Checking + @subsection Validity Checking + @findex Validity Checking + + @noindent + The Ada 95 Reference Manual has specific requirements for checking + for invalid values. In particular, RM 13.9.1 requires that the + evaluation of invalid values (for example from unchecked conversions), + not result in erroneous execution. In GNAT, the result of such an + evaluation in normal default mode is to either use the value + unmodified, or to raise Constraint_Error in those cases where use + of the unmodified value would cause erroneous execution. The cases + where unmodified values might lead to erroneous execution are case + statements (where a wild jump might result from an invalid value), + and subscripts on the left hand side (where memory corruption could + occur as a result of an invalid value). + + The @option{-gnatVx} switch allows more control over the validity checking + mode. The @code{x} argument here is a string of letters which control which + validity checks are performed in addition to the default checks described + above. + + @itemize @bullet + @item + @option{-gnatVc} Validity checks for copies + + The right hand side of assignments, and the initializing values of + object declarations are validity checked. + + @item + @option{-gnatVd} Default (RM) validity checks + + Some validity checks are done by default following normal Ada semantics + (RM 13.9.1 (9-11)). + A check is done in case statements that the expression is within the range + of the subtype. If it is not, Constraint_Error is raised. + For assignments to array components, a check is done that the expression used + as index is within the range. If it is not, Constraint_Error is raised. + Both these validity checks may be turned off using switch @option{-gnatVD}. + They are turned on by default. If @option{-gnatVD} is specified, a subsequent + switch @option{-gnatVd} will leave the checks turned on. + Switch @option{-gnatVD} should be used only if you are sure that all such + expressions have valid values. If you use this switch and invalid values + are present, then the program is erroneous, and wild jumps or memory + overwriting may occur. + + @item + @option{-gnatVi} Validity checks for @code{in} mode parameters + + Arguments for parameters of mode @code{in} are validity checked in function + and procedure calls at the point of call. + + @item + @option{-gnatVm} Validity checks for @code{in out} mode parameters + + Arguments for parameters of mode @code{in out} are validity checked in + procedure calls at the point of call. The @code{'m'} here stands for + modify, since this concerns parameters that can be modified by the call. + Note that there is no specific option to test @code{out} parameters, + but any reference within the subprogram will be tested in the usual + manner, and if an invalid value is copied back, any reference to it + will be subject to validity checking. + + @item + @option{-gnatVo} Validity checks for operator and attribute operands + + Arguments for predefined operators and attributes are validity checked. + This includes all operators in package @code{Standard}, + the shift operators defined as intrinsic in package @code{Interfaces} + and operands for attributes such as @code{Pos}. + + @item + @option{-gnatVr} Validity checks for function returns + + The expression in @code{return} statements in functions is validity + checked. + + @item + @option{-gnatVs} Validity checks for subscripts + + All subscripts expressions are checked for validity, whether they appear + on the right side or left side (in default mode only left side subscripts + are validity checked). + + @item + @option{-gnatVt} Validity checks for tests + + Expressions used as conditions in @code{if}, @code{while} or @code{exit} + statements are checked, as well as guard expressions in entry calls. + + @item + @option{-gnatVf} Validity checks for floating-point values + + In the absence of this switch, validity checking occurs only for discrete + values. If @option{-gnatVf} is specified, then validity checking also applies + for floating-point values, and NaN's and infinities are considered invalid, + as well as out of range values for constrained types. Note that this means + that standard @code{IEEE} infinity mode is not allowed. The exact contexts + in which floating-point values are checked depends on the setting of other + options. For example @option{-gnatVif} or @option{-gnatVfi} (the order does + not matter) specifies that floating-point parameters of mode @code{in} should + be validity checked. + + @item + @option{-gnatVa} All validity checks + + All the above validity checks are turned on. That is @option{-gnatVa} is + equivalent to @code{gnatVcdfimorst}. + + @item + @option{-gnatVn} No validity checks + + This switch turns off all validity checking, including the default checking + for case statements and left hand side subscripts. Note that the use of + the switch @option{-gnatp} supresses all run-time checks, including + validity checks, and thus implies @option{-gnatVn}. + + @end itemize + + The @option{-gnatV} switch may be followed by a string of letters to turn on + a series of validity checking options. For example, @option{-gnatVcr} specifies + that in addition to the default validity checking, copies and function + return expressions be validity checked. In order to make it easier to specify + a set of options, the upper case letters @code{CDFIMORST} may be used to turn + off the corresponding lower case option, so for example @option{-gnatVaM} turns + on all validity checking options except for checking of @code{in out} + procedure arguments. + + The specification of additional validity checking generates extra code (and + in the case of @option{-gnatva} the code expansion can be substantial. However, + these additional checks can be very useful in smoking out cases of + uninitialized variables, incorrect use of unchecked conversion, and other + errors leading to invalid values. The use of pragma @code{Initialize_Scalars} + is useful in conjunction with the extra validity checking, since this + ensures that wherever possible uninitialized variables have invalid values. + + See also the pragma @code{Validity_Checks} which allows modification of + the validity checking mode at the program source level, and also allows for + temporary disabling of validity checks. + + @node Style Checking + @subsection Style Checking + @findex Style checking + + @noindent + The -gnaty@var{x} switch causes the compiler to + enforce specified style rules. A limited set of style rules has been used + in writing the GNAT sources themselves. This switch allows user programs + to activate all or some of these checks. If the source program fails a + specified style check, an appropriate warning message is given, preceded by + the character sequence "(style)". + The string @var{x} is a sequence of letters or digits + indicating the particular style + checks to be performed. The following checks are defined: + + @table @code + @item 1-9 (specify indentation level) + If a digit from 1-9 appears in the string after @option{-gnaty} then proper + indentation is checked, with the digit indicating the indentation level + required. The general style of required indentation is as specified by + the examples in the Ada Reference Manual. Full line comments must be + aligned with the @code{--} starting on a column that is a multiple of + the alignment level. + + @item a (check attribute casing) + If the letter a appears in the string after @option{-gnaty} then + attribute names, including the case of keywords such as @code{digits} + used as attributes names, must be written in mixed case, that is, the + initial letter and any letter following an underscore must be uppercase. + All other letters must be lowercase. + + @item b (blanks not allowed at statement end) + If the letter b appears in the string after @option{-gnaty} then + trailing blanks are not allowed at the end of statements. The purpose of this + rule, together with h (no horizontal tabs), is to enforce a canonical format + for the use of blanks to separate source tokens. + + @item c (check comments) + If the letter c appears in the string after @option{-gnaty} then + comments must meet the following set of rules: + + @itemize @bullet + + @item + The "--" that starts the column must either start in column one, or else + at least one blank must precede this sequence. + + @item + Comments that follow other tokens on a line must have at least one blank + following the "--" at the start of the comment. + + @item + Full line comments must have two blanks following the "--" that starts + the comment, with the following exceptions. + + @item + A line consisting only of the "--" characters, possibly preceded by blanks + is permitted. + + @item + A comment starting with "--x" where x is a special character is permitted. + This alows proper processing of the output generated by specialized tools + including @code{gnatprep} (where --! is used) and the SPARK annnotation + language (where --# is used). For the purposes of this rule, a special + character is defined as being in one of the ASCII ranges + 16#21#..16#2F# or 16#3A#..16#3F#. + + @item + A line consisting entirely of minus signs, possibly preceded by blanks, is + permitted. This allows the construction of box comments where lines of minus + signs are used to form the top and bottom of the box. + + @item + If a comment starts and ends with "--" is permitted as long as at least + one blank follows the initial "--". Together with the preceding rule, + this allows the construction of box comments, as shown in the following + example: + @smallexample + --------------------------- + -- This is a box comment -- + -- with two text lines. -- + --------------------------- + @end smallexample + @end itemize + + @item e (check end/exit labels) + If the letter e appears in the string after @option{-gnaty} then + optional labels on @code{end} statements ending subprograms and on + @code{exit} statements exiting named loops, are required to be present. + + @item f (no form feeds or vertical tabs) + If the letter f appears in the string after @option{-gnaty} then + neither form feeds nor vertical tab characters are not permitted + in the source text. + + @item h (no horizontal tabs) + If the letter h appears in the string after @option{-gnaty} then + horizontal tab characters are not permitted in the source text. + Together with the b (no blanks at end of line) check, this + enforces a canonical form for the use of blanks to separate + source tokens. + + @item i (check if-then layout) + If the letter i appears in the string after @option{-gnaty}, + then the keyword @code{then} must appear either on the same + line as corresponding @code{if}, or on a line on its own, lined + up under the @code{if} with at least one non-blank line in between + containing all or part of the condition to be tested. + + @item k (check keyword casing) + If the letter k appears in the string after @option{-gnaty} then + all keywords must be in lower case (with the exception of keywords + such as @code{digits} used as attribute names to which this check + does not apply). + + @item l (check layout) + If the letter l appears in the string after @option{-gnaty} then + layout of statement and declaration constructs must follow the + recommendations in the Ada Reference Manual, as indicated by the + form of the syntax rules. For example an @code{else} keyword must + be lined up with the corresponding @code{if} keyword. + + There are two respects in which the style rule enforced by this check + option are more liberal than those in the Ada Reference Manual. First + in the case of record declarations, it is permissible to put the + @code{record} keyword on the same line as the @code{type} keyword, and + then the @code{end} in @code{end record} must line up under @code{type}. + For example, either of the following two layouts is acceptable: + + @smallexample + @group + @cartouche + @b{type} q @b{is record} + a : integer; + b : integer; + @b{end record}; + + @b{type} q @b{is} + @b{record} + a : integer; + b : integer; + @b{end record}; + @end cartouche + @end group + @end smallexample + + @noindent + Second, in the case of a block statement, a permitted alternative + is to put the block label on the same line as the @code{declare} or + @code{begin} keyword, and then line the @code{end} keyword up under + the block label. For example both the following are permitted: + + @smallexample + @group + @cartouche + Block : @b{declare} + A : Integer := 3; + @b{begin} + Proc (A, A); + @b{end} Block; + + Block : + @b{declare} + A : Integer := 3; + @b{begin} + Proc (A, A); + @b{end} Block; + @end cartouche + @end group + @end smallexample + + @noindent + The same alternative format is allowed for loops. For example, both of + the following are permitted: + + @smallexample + @group + @cartouche + Clear : @b{while} J < 10 @b{loop} + A (J) := 0; + @b{end loop} Clear; + + Clear : + @b{while} J < 10 @b{loop} + A (J) := 0; + @b{end loop} Clear; + @end cartouche + @end group + @end smallexample + + @item m (check maximum line length) + If the letter m appears in the string after @option{-gnaty} + then the length of source lines must not exceed 79 characters, including + any trailing blanks. The value of 79 allows convenient display on an + 80 character wide device or window, allowing for possible special + treatment of 80 character lines. + + @item Mnnn (set maximum line length) + If the sequence Mnnn, where nnn is a decimal number, appears in + the string after @option{-gnaty} then the length of lines must not exceed the + given value. + + @item n (check casing of entities in Standard) + If the letter n appears in the string + after @option{-gnaty} then any identifier from Standard must be cased + to match the presentation in the Ada Reference Manual (for example, + @code{Integer} and @code{ASCII.NUL}). + + @item o (check order of subprogram bodies) + If the letter o appears in the string + after @option{-gnaty} then all subprogram bodies in a given scope + (e.g. a package body) must be in alphabetical order. The ordering + rule uses normal Ada rules for comparing strings, ignoring casing + of letters, except that if there is a trailing numeric suffix, then + the value of this suffix is used in the ordering (e.g. Junk2 comes + before Junk10). + + @item p (check pragma casing) + If the letter p appears in the string after @option{-gnaty} then + pragma names must be written in mixed case, that is, the + initial letter and any letter following an underscore must be uppercase. + All other letters must be lowercase. + + @item r (check references) + If the letter r appears in the string after @option{-gnaty} + then all identifier references must be cased in the same way as the + corresponding declaration. No specific casing style is imposed on + identifiers. The only requirement is for consistency of references + with declarations. + + @item s (check separate specs) + If the letter s appears in the string after @option{-gnaty} then + separate declarations ("specs") are required for subprograms (a + body is not allowed to serve as its own declaration). The only + exception is that parameterless library level procedures are + not required to have a separate declaration. This exception covers + the most frequent form of main program procedures. + + @item t (check token spacing) + If the letter t appears in the string after @option{-gnaty} then + the following token spacing rules are enforced: + + @itemize @bullet + + @item + The keywords @code{abs} and @code{not} must be followed by a space. + + @item + The token @code{=>} must be surrounded by spaces. + + @item + The token @code{<>} must be preceded by a space or a left parenthesis. + + @item + Binary operators other than @code{**} must be surrounded by spaces. + There is no restriction on the layout of the @code{**} binary operator. + + @item + Colon must be surrounded by spaces. + + @item + Colon-equal (assignment) must be surrounded by spaces. + + @item + Comma must be the first non-blank character on the line, or be + immediately preceded by a non-blank character, and must be followed + by a space. + + @item + If the token preceding a left paren ends with a letter or digit, then + a space must separate the two tokens. + + @item + A right parenthesis must either be the first non-blank character on + a line, or it must be preceded by a non-blank character. + + @item + A semicolon must not be preceded by a space, and must not be followed by + a non-blank character. + + @item + A unary plus or minus may not be followed by a space. + + @item + A vertical bar must be surrounded by spaces. + @end itemize + + @noindent + In the above rules, appearing in column one is always permitted, that is, + counts as meeting either a requirement for a required preceding space, + or as meeting a requirement for no preceding space. + + Appearing at the end of a line is also always permitted, that is, counts + as meeting either a requirement for a following space, or as meeting + a requirement for no following space. + + @end table + + @noindent + If any of these style rules is violated, a message is generated giving + details on the violation. The initial characters of such messages are + always "(style)". Note that these messages are treated as warning + messages, so they normally do not prevent the generation of an object + file. The @option{-gnatwe} switch can be used to treat warning messages, + including style messages, as fatal errors. + + @noindent + The switch + @option{-gnaty} on its own (that is not followed by any letters or digits), + is equivalent to @code{gnaty3abcefhiklmprst}, that is all checking + options are enabled with + the exception of -gnatyo, + with an indentation level of 3. This is the standard + checking option that is used for the GNAT sources. + + @node Run-Time Checks + @subsection Run-Time Checks + @cindex Division by zero + @cindex Access before elaboration + @cindex Checks, division by zero + @cindex Checks, access before elaboration + + @noindent + If you compile with the default options, GNAT will insert many run-time + checks into the compiled code, including code that performs range + checking against constraints, but not arithmetic overflow checking for + integer operations (including division by zero) or checks for access + before elaboration on subprogram calls. All other run-time checks, as + required by the Ada 95 Reference Manual, are generated by default. + The following @code{gcc} switches refine this default behavior: + + @table @code + @item -gnatp + @cindex @option{-gnatp} (@code{gcc}) + @cindex Suppressing checks + @cindex Checks, suppressing + @findex Suppress + Suppress all run-time checks as though @code{pragma Suppress (all_checks}) + had been present in the source. Validity checks are also suppressed (in + other words @option{-gnatp} also implies @option{-gnatVn}. + Use this switch to improve the performance + of the code at the expense of safety in the presence of invalid data or + program bugs. + + @item -gnato + @cindex @option{-gnato} (@code{gcc}) + @cindex Overflow checks + @cindex Check, overflow + Enables overflow checking for integer operations. + This causes GNAT to generate slower and larger executable + programs by adding code to check for overflow (resulting in raising + @code{Constraint_Error} as required by standard Ada + semantics). These overflow checks correspond to situations in which + the true value of the result of an operation may be outside the base + range of the result type. The following example shows the distinction: + + @smallexample + X1 : Integer := Integer'Last; + X2 : Integer range 1 .. 5 := 5; + ... + X1 := X1 + 1; -- @option{-gnato} required to catch the Constraint_Error + X2 := X2 + 1; -- range check, @option{-gnato} has no effect here + @end smallexample + + @noindent + Here the first addition results in a value that is outside the base range + of Integer, and hence requires an overflow check for detection of the + constraint error. The second increment operation results in a violation + of the explicit range constraint, and such range checks are always + performed. Basically the compiler can assume that in the absence of + the @option{-gnato} switch that any value of type @code{xxx} is + in range of the base type of @code{xxx}. + + @findex Machine_Overflows + Note that the @option{-gnato} switch does not affect the code generated + for any floating-point operations; it applies only to integer + semantics). + For floating-point, GNAT has the @code{Machine_Overflows} + attribute set to @code{False} and the normal mode of operation is to + generate IEEE NaN and infinite values on overflow or invalid operations + (such as dividing 0.0 by 0.0). + + The reason that we distinguish overflow checking from other kinds of + range constraint checking is that a failure of an overflow check can + generate an incorrect value, but cannot cause erroneous behavior. This + is unlike the situation with a constraint check on an array subscript, + where failure to perform the check can result in random memory description, + or the range check on a case statement, where failure to perform the check + can cause a wild jump. + + Note again that @option{-gnato} is off by default, so overflow checking is + not performed in default mode. This means that out of the box, with the + default settings, GNAT does not do all the checks expected from the + language description in the Ada Reference Manual. If you want all constraint + checks to be performed, as described in this Manual, then you must + explicitly use the -gnato switch either on the @code{gnatmake} or + @code{gcc} command. + + @item -gnatE + @cindex @option{-gnatE} (@code{gcc}) + @cindex Elaboration checks + @cindex Check, elaboration + Enables dynamic checks for access-before-elaboration + on subprogram calls and generic instantiations. + For full details of the effect and use of this switch, + @xref{Compiling Using gcc}. + @end table + + @findex Unsuppress + @noindent + The setting of these switches only controls the default setting of the + checks. You may modify them using either @code{Suppress} (to remove + checks) or @code{Unsuppress} (to add back suppressed checks) pragmas in + the program source. + + @node Stack Overflow Checking + @subsection Stack Overflow Checking + @cindex Stack Overflow Checking + @cindex -fstack-check + + @noindent + For most operating systems, @code{gcc} does not perform stack overflow + checking by default. This means that if the main environment task or + some other task exceeds the available stack space, then unpredictable + behavior will occur. + + To activate stack checking, compile all units with the gcc option + @code{-fstack-check}. For example: + + @smallexample + gcc -c -fstack-check package1.adb + @end smallexample + + @noindent + Units compiled with this option will generate extra instructions to check + that any use of the stack (for procedure calls or for declaring local + variables in declare blocks) do not exceed the available stack space. + If the space is exceeded, then a @code{Storage_Error} exception is raised. + + For declared tasks, the stack size is always controlled by the size + given in an applicable @code{Storage_Size} pragma (or is set to + the default size if no pragma is used. + + For the environment task, the stack size depends on + system defaults and is unknown to the compiler. The stack + may even dynamically grow on some systems, precluding the + normal Ada semantics for stack overflow. In the worst case, + unbounded stack usage, causes unbounded stack expansion + resulting in the system running out of virtual memory. + + The stack checking may still work correctly if a fixed + size stack is allocated, but this cannot be guaranteed. + To ensure that a clean exception is signalled for stack + overflow, set the environment variable + @code{GNAT_STACK_LIMIT} to indicate the maximum + stack area that can be used, as in: + @cindex GNAT_STACK_LIMIT + + @smallexample + SET GNAT_STACK_LIMIT 1600 + @end smallexample + + @noindent + The limit is given in kilobytes, so the above declaration would + set the stack limit of the environment task to 1.6 megabytes. + Note that the only purpose of this usage is to limit the amount + of stack used by the environment task. If it is necessary to + increase the amount of stack for the environment task, then this + is an operating systems issue, and must be addressed with the + appropriate operating systems commands. + + @node Run-Time Control + @subsection Run-Time Control + + @table @code + @item -gnatT nnn + @cindex @option{-gnatT} (@code{gcc}) + @cindex Time Slicing + + @noindent + The @code{gnatT} switch can be used to specify the time-slicing value + to be used for task switching between equal priority tasks. The value + @code{nnn} is given in microseconds as a decimal integer. + + Setting the time-slicing value is only effective if the underlying thread + control system can accommodate time slicing. Check the documentation of + your operating system for details. Note that the time-slicing value can + also be set by use of pragma @code{Time_Slice} or by use of the + @code{t} switch in the gnatbind step. The pragma overrides a command + line argument if both are present, and the @code{t} switch for gnatbind + overrides both the pragma and the @code{gcc} command line switch. + @end table + + @node Using gcc for Syntax Checking + @subsection Using @code{gcc} for Syntax Checking + @table @code + @item -gnats + @cindex @option{-gnats} (@code{gcc}) + + @noindent + The @code{s} stands for syntax. + + Run GNAT in syntax checking only mode. For + example, the command + + @smallexample + $ gcc -c -gnats x.adb + @end smallexample + + @noindent + compiles file @file{x.adb} in syntax-check-only mode. You can check a + series of files in a single command + , and can use wild cards to specify such a group of files. + Note that you must specify the @code{-c} (compile + only) flag in addition to the @option{-gnats} flag. + . + + You may use other switches in conjunction with @option{-gnats}. In + particular, @option{-gnatl} and @option{-gnatv} are useful to control the + format of any generated error messages. + + The output is simply the error messages, if any. No object file or ALI + file is generated by a syntax-only compilation. Also, no units other + than the one specified are accessed. For example, if a unit @code{X} + @code{with}'s a unit @code{Y}, compiling unit @code{X} in syntax + check only mode does not access the source file containing unit + @code{Y}. + + @cindex Multiple units, syntax checking + Normally, GNAT allows only a single unit in a source file. However, this + restriction does not apply in syntax-check-only mode, and it is possible + to check a file containing multiple compilation units concatenated + together. This is primarily used by the @code{gnatchop} utility + (@pxref{Renaming Files Using gnatchop}). + @end table + + @node Using gcc for Semantic Checking + @subsection Using @code{gcc} for Semantic Checking + @table @code + @item -gnatc + @cindex @option{-gnatc} (@code{gcc}) + + @noindent + The @code{c} stands for check. + Causes the compiler to operate in semantic check mode, + with full checking for all illegalities specified in the + Ada 95 Reference Manual, but without generation of any object code + (no object file is generated). + + Because dependent files must be accessed, you must follow the GNAT + semantic restrictions on file structuring to operate in this mode: + + @itemize @bullet + @item + The needed source files must be accessible + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item + Each file must contain only one compilation unit. + + @item + The file name and unit name must match (@pxref{File Naming Rules}). + @end itemize + + The output consists of error messages as appropriate. No object file is + generated. An @file{ALI} file is generated for use in the context of + cross-reference tools, but this file is marked as not being suitable + for binding (since no object file is generated). + The checking corresponds exactly to the notion of + legality in the Ada 95 Reference Manual. + + Any unit can be compiled in semantics-checking-only mode, including + units that would not normally be compiled (subunits, + and specifications where a separate body is present). + @end table + + @node Compiling Ada 83 Programs + @subsection Compiling Ada 83 Programs + @table @code + @cindex Ada 83 compatibility + @item -gnat83 + @cindex @option{-gnat83} (@code{gcc}) + @cindex ACVC, Ada 83 tests + + @noindent + Although GNAT is primarily an Ada 95 compiler, it accepts this switch to + specify that an Ada 83 program is to be compiled in Ada83 mode. If you specify + this switch, GNAT rejects most Ada 95 extensions and applies Ada 83 semantics + where this can be done easily. + It is not possible to guarantee this switch does a perfect + job; for example, some subtle tests, such as are + found in earlier ACVC tests (that have been removed from the ACVC suite for Ada + 95), may not compile correctly. However, for most purposes, using + this switch should help to ensure that programs that compile correctly + under the @option{-gnat83} switch can be ported easily to an Ada 83 + compiler. This is the main use of the switch. + + With few exceptions (most notably the need to use @code{<>} on + @cindex Generic formal parameters + unconstrained generic formal parameters, the use of the new Ada 95 + keywords, and the use of packages + with optional bodies), it is not necessary to use the + @option{-gnat83} switch when compiling Ada 83 programs, because, with rare + exceptions, Ada 95 is upwardly compatible with Ada 83. This + means that a correct Ada 83 program is usually also a correct Ada 95 + program. + + @end table + + @node Character Set Control + @subsection Character Set Control + @table @code + @item -gnati@var{c} + @cindex @code{-gnati} (@code{gcc}) + + @noindent + Normally GNAT recognizes the Latin-1 character set in source program + identifiers, as described in the Ada 95 Reference Manual. + This switch causes + GNAT to recognize alternate character sets in identifiers. @var{c} is a + single character indicating the character set, as follows: + + @table @code + @item 1 + Latin-1 identifiers + + @item 2 + Latin-2 letters allowed in identifiers + + @item 3 + Latin-3 letters allowed in identifiers + + @item 4 + Latin-4 letters allowed in identifiers + + @item 5 + Latin-5 (Cyrillic) letters allowed in identifiers + + @item 9 + Latin-9 letters allowed in identifiers + + @item p + IBM PC letters (code page 437) allowed in identifiers + + @item 8 + IBM PC letters (code page 850) allowed in identifiers + + @item f + Full upper-half codes allowed in identifiers + + @item n + No upper-half codes allowed in identifiers + + @item w + Wide-character codes (that is, codes greater than 255) + allowed in identifiers + @end table + + @xref{Foreign Language Representation}, for full details on the + implementation of these character sets. + + @item -gnatW@var{e} + @cindex @code{-gnatW} (@code{gcc}) + Specify the method of encoding for wide characters. + @var{e} is one of the following: + + @table @code + + @item h + Hex encoding (brackets coding also recognized) + + @item u + Upper half encoding (brackets encoding also recognized) + + @item s + Shift/JIS encoding (brackets encoding also recognized) + + @item e + EUC encoding (brackets encoding also recognized) + + @item 8 + UTF-8 encoding (brackets encoding also recognized) + + @item b + Brackets encoding only (default value) + @end table + For full details on the these encoding + methods see @xref{Wide Character Encodings}. + Note that brackets coding is always accepted, even if one of the other + options is specified, so for example @option{-gnatW8} specifies that both + brackets and @code{UTF-8} encodings will be recognized. The units that are + with'ed directly or indirectly will be scanned using the specified + representation scheme, and so if one of the non-brackets scheme is + used, it must be used consistently throughout the program. However, + since brackets encoding is always recognized, it may be conveniently + used in standard libraries, allowing these libraries to be used with + any of the available coding schemes. + scheme. If no @option{-gnatW?} parameter is present, then the default + representation is Brackets encoding only. + + Note that the wide character representation that is specified (explicitly + or by default) for the main program also acts as the default encoding used + for Wide_Text_IO files if not specifically overridden by a WCEM form + parameter. + + @end table + @node File Naming Control + @subsection File Naming Control + + @table @code + @item -gnatk@var{n} + @cindex @option{-gnatk} (@code{gcc}) + Activates file name "krunching". @var{n}, a decimal integer in the range + 1-999, indicates the maximum allowable length of a file name (not + including the @file{.ads} or @file{.adb} extension). The default is not + to enable file name krunching. + + For the source file naming rules, @xref{File Naming Rules}. + @end table + + @node Subprogram Inlining Control + @subsection Subprogram Inlining Control + + @table @code + @item -gnatn + @cindex @option{-gnatn} (@code{gcc}) + The @code{n} here is intended to suggest the first syllable of the + word "inline". + GNAT recognizes and processes @code{Inline} pragmas. However, for the + inlining to actually occur, optimization must be enabled. To enable + inlining across unit boundaries, this is, inlining a call in one unit of + a subprogram declared in a @code{with}'ed unit, you must also specify + this switch. + In the absence of this switch, GNAT does not attempt + inlining across units and does not need to access the bodies of + subprograms for which @code{pragma Inline} is specified if they are not + in the current unit. + + If you specify this switch the compiler will access these bodies, + creating an extra source dependency for the resulting object file, and + where possible, the call will be inlined. + For further details on when inlining is possible + see @xref{Inlining of Subprograms}. + + @item -gnatN + @cindex @option{-gnatN} (@code{gcc}) + The front end inlining activated by this switch is generally more extensive, + and quite often more effective than the standard @option{-gnatn} inlining mode. + It will also generate additional dependencies. + + @end table + + @node Auxiliary Output Control + @subsection Auxiliary Output Control + + @table @code + @item -gnatt + @cindex @option{-gnatt} (@code{gcc}) + @cindex Writing internal trees + @cindex Internal trees, writing to file + Causes GNAT to write the internal tree for a unit to a file (with the + extension @file{.adt}. + This not normally required, but is used by separate analysis tools. + Typically + these tools do the necessary compilations automatically, so you should + not have to specify this switch in normal operation. + + @item -gnatu + @cindex @option{-gnatu} (@code{gcc}) + Print a list of units required by this compilation on @file{stdout}. + The listing includes all units on which the unit being compiled depends + either directly or indirectly. + + @item -pass-exit-codes + @cindex @code{-pass-exit-codes} (@code{gcc}) + If this switch is not used, the exit code returned by @code{gcc} when + compiling multiple files indicates whether all source files have + been successfully used to generate object files or not. + + When @code{-pass-exit-codes} is used, @code{gcc} exits with an extended + exit status and allows an integrated development environment to better + react to a compilation failure. Those exit status are: + + @table @asis + @item 5 + There was an error in at least one source file. + @item 3 + At least one source file did not generate an object file. + @item 2 + The compiler died unexpectedly (internal error for example). + @item 0 + An object file has been generated for every source file. + @end table + @end table + + @node Debugging Control + @subsection Debugging Control + + @table @code + @cindex Debugging options + @item -gnatd@var{x} + Activate internal debugging switches. @var{x} is a letter or digit, or + string of letters or digits, which specifies the type of debugging + outputs desired. Normally these are used only for internal development + or system debugging purposes. You can find full documentation for these + switches in the body of the @code{Debug} unit in the compiler source + file @file{debug.adb}. + + @item -gnatG + @cindex @option{-gnatG} (@code{gcc}) + This switch causes the compiler to generate auxiliary output containing + a pseudo-source listing of the generated expanded code. Like most Ada + compilers, GNAT works by first transforming the high level Ada code into + lower level constructs. For example, tasking operations are transformed + into calls to the tasking run-time routines. A unique capability of GNAT + is to list this expanded code in a form very close to normal Ada source. + This is very useful in understanding the implications of various Ada + usage on the efficiency of the generated code. There are many cases in + Ada (e.g. the use of controlled types), where simple Ada statements can + generate a lot of run-time code. By using @option{-gnatG} you can identify + these cases, and consider whether it may be desirable to modify the coding + approach to improve efficiency. + + The format of the output is very similar to standard Ada source, and is + easily understood by an Ada programmer. The following special syntactic + additions correspond to low level features used in the generated code that + do not have any exact analogies in pure Ada source form. The following + is a partial list of these special constructions. See the specification + of package @code{Sprint} in file @file{sprint.ads} for a full list. + + @table @code + @item new @var{xxx} [storage_pool = @var{yyy}] + Shows the storage pool being used for an allocator. + + @item at end @var{procedure-name}; + Shows the finalization (cleanup) procedure for a scope. + + @item (if @var{expr} then @var{expr} else @var{expr}) + Conditional expression equivalent to the @code{x?y:z} construction in C. + + @item @var{target}^(@var{source}) + A conversion with floating-point truncation instead of rounding. + + @item @var{target}?(@var{source}) + A conversion that bypasses normal Ada semantic checking. In particular + enumeration types and fixed-point types are treated simply as integers. + + @item @var{target}?^(@var{source}) + Combines the above two cases. + + @item @var{x} #/ @var{y} + @itemx @var{x} #mod @var{y} + @itemx @var{x} #* @var{y} + @itemx @var{x} #rem @var{y} + A division or multiplication of fixed-point values which are treated as + integers without any kind of scaling. + + @item free @var{expr} [storage_pool = @var{xxx}] + Shows the storage pool associated with a @code{free} statement. + + @item freeze @var{typename} [@var{actions}] + Shows the point at which @var{typename} is frozen, with possible + associated actions to be performed at the freeze point. + + @item reference @var{itype} + Reference (and hence definition) to internal type @var{itype}. + + @item @var{function-name}! (@var{arg}, @var{arg}, @var{arg}) + Intrinsic function call. + + @item @var{labelname} : label + Declaration of label @var{labelname}. + + @item @var{expr} && @var{expr} && @var{expr} ... && @var{expr} + A multiple concatenation (same effect as @var{expr} & @var{expr} & + @var{expr}, but handled more efficiently). + + @item [constraint_error] + Raise the @code{Constraint_Error} exception. + + @item @var{expression}'reference + A pointer to the result of evaluating @var{expression}. + + @item @var{target-type}!(@var{source-expression}) + An unchecked conversion of @var{source-expression} to @var{target-type}. + + @item [@var{numerator}/@var{denominator}] + Used to represent internal real literals (that) have no exact + representation in base 2-16 (for example, the result of compile time + evaluation of the expression 1.0/27.0). + + @item -gnatD + @cindex @option{-gnatD} (@code{gcc}) + This switch is used in conjunction with @option{-gnatG} to cause the expanded + source, as described above to be written to files with names + @file{xxx.dg}, where @file{xxx} is the normal file name, + for example, if the source file name is @file{hello.adb}, + then a file @file{hello.adb.dg} will be written. + The debugging information generated + by the @code{gcc} @code{-g} switch will refer to the generated + @file{xxx.dg} file. This allows you to do source level debugging using + the generated code which is sometimes useful for complex code, for example + to find out exactly which part of a complex construction raised an + exception. This switch also suppress generation of cross-reference + information (see -gnatx). + + @item -gnatC + @cindex @option{-gnatE} (@code{gcc}) + In the generated debugging information, and also in the case of long external + names, the compiler uses a compression mechanism if the name is very long. + This compression method uses a checksum, and avoids trouble on some operating + systems which have difficulty with very long names. The @option{-gnatC} switch + forces this compression approach to be used on all external names and names + in the debugging information tables. This reduces the size of the generated + executable, at the expense of making the naming scheme more complex. The + compression only affects the qualification of the name. Thus a name in + the source: + + @smallexample + Very_Long_Package.Very_Long_Inner_Package.Var + @end smallexample + + @noindent + would normally appear in these tables as: + + @smallexample + very_long_package__very_long_inner_package__var + @end smallexample + + @noindent + but if the @option{-gnatC} switch is used, then the name appears as + + @smallexample + XCb7e0c705__var + @end smallexample + + @noindent + Here b7e0c705 is a compressed encoding of the qualification prefix. + The GNAT Ada aware version of GDB understands these encoded prefixes, so if this + debugger is used, the encoding is largely hidden from the user of the compiler. + + @end table + + @item -gnatR[0|1|2|3][s] + @cindex @option{-gnatR} (@code{gcc}) + This switch controls output from the compiler of a listing showing + representation information for declared types and objects. For + @option{-gnatR0}, no information is output (equivalent to omitting + the @option{-gnatR} switch). For @option{-gnatR1} (which is the default, + so @option{-gnatR} with no parameter has the same effect), size and alignment + information is listed for declared array and record types. For + @option{-gnatR2}, size and alignment information is listed for all + expression information for values that are computed at run time for + variant records. These symbolic expressions have a mostly obvious + format with #n being used to represent the value of the n'th + discriminant. See source files @file{repinfo.ads/adb} in the + @code{GNAT} sources for full detalis on the format of @option{-gnatR3} + output. If the switch is followed by an s (e.g. @option{-gnatR2s}), then + the output is to a file with the name @file{file.rep} where + file is the name of the corresponding source file. + + @item -gnatx + @cindex @option{-gnatx} (@code{gcc}) + Normally the compiler generates full cross-referencing information in + the @file{ALI} file. This information is used by a number of tools, + including @code{gnatfind} and @code{gnatxref}. The -gnatx switch + suppresses this information. This saves some space and may slightly + speed up compilation, but means that these tools cannot be used. + @end table + + @node Units to Sources Mapping Files + @subsection Units to Sources Mapping Files + + @table @code + + @item -gnatem@var{path} + @cindex @option{-gnatem} (@code{gcc}) + A mapping file is a way to communicate to the compiler two mappings: + from unit names to file names (without any directory information) and from + file names to path names (with full directory information). These mappings + are used by the compiler to short-circuit the path search. + + A mapping file is a sequence of sets of three lines. In each set, + the first line is the unit name, in lower case, with "%s" appended for + specifications and "%b" appended for bodies; the second line is the file + name; and the third line is the path name. + + Example: + @smallexample + main%b + main.2.ada + /gnat/project1/sources/main.2.ada + @end smallexample + + When the switch @option{-gnatem} is specified, the compiler will create + in memory the two mappings from the specified file. If there is any problem + (non existent file, truncated file or duplicate entries), no mapping + will be created. + + Several @option{-gnatem} switches may be specified; however, only the last + one on the command line will be taken into account. + + When using a project file, @code{gnatmake} create a temporary mapping file + and communicates it to the compiler using this switch. + + @end table + + @node Search Paths and the Run-Time Library (RTL) + @section Search Paths and the Run-Time Library (RTL) + + @noindent + With the GNAT source-based library system, the compiler must be able to + find source files for units that are needed by the unit being compiled. + Search paths are used to guide this process. + + The compiler compiles one source file whose name must be given + explicitly on the command line. In other words, no searching is done + for this file. To find all other source files that are needed (the most + common being the specs of units), the compiler examines the following + directories, in the following order: + + @enumerate + @item + The directory containing the source file of the main unit being compiled + (the file name on the command line). + + @item + Each directory named by an @code{-I} switch given on the @code{gcc} + command line, in the order given. + + @item + @findex ADA_INCLUDE_PATH + Each of the directories listed in the value of the + @code{ADA_INCLUDE_PATH} environment variable. + Construct this value + exactly as the @code{PATH} environment variable: a list of directory + names separated by colons (semicolons when working with the NT version). + @item + The content of the "ada_source_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as the + GNAT Run Time Library (RTL) source files. + @ref{Installing an Ada Library} + @end enumerate + + @noindent + Specifying the switch @code{-I-} + inhibits the use of the directory + containing the source file named in the command line. You can still + have this directory on your search path, but in this case it must be + explicitly requested with a @code{-I} switch. + + Specifying the switch @code{-nostdinc} + inhibits the search of the default location for the GNAT Run Time + Library (RTL) source files. + + The compiler outputs its object files and ALI files in the current + working directory. + Caution: The object file can be redirected with the @code{-o} switch; + however, @code{gcc} and @code{gnat1} have not been coordinated on this + so the ALI file will not go to the right place. Therefore, you should + avoid using the @code{-o} switch. + + @findex System.IO + The packages @code{Ada}, @code{System}, and @code{Interfaces} and their + children make up the GNAT RTL, together with the simple @code{System.IO} + package used in the "Hello World" example. The sources for these units + are needed by the compiler and are kept together in one directory. Not + all of the bodies are needed, but all of the sources are kept together + anyway. In a normal installation, you need not specify these directory + names when compiling or binding. Either the environment variables or + the built-in defaults cause these files to be found. + + In addition to the language-defined hierarchies (System, Ada and + Interfaces), the GNAT distribution provides a fourth hierarchy, + consisting of child units of GNAT. This is a collection of generally + useful routines. See the GNAT Reference Manual for further details. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + + @node Order of Compilation Issues + @section Order of Compilation Issues + + @noindent + If, in our earlier example, there was a spec for the @code{hello} + procedure, it would be contained in the file @file{hello.ads}; yet this + file would not have to be explicitly compiled. This is the result of the + model we chose to implement library management. Some of the consequences + of this model are as follows: + + @itemize @bullet + @item + There is no point in compiling specs (except for package + specs with no bodies) because these are compiled as needed by clients. If + you attempt a useless compilation, you will receive an error message. + It is also useless to compile subunits because they are compiled as needed + by the parent. + + @item + There are no order of compilation requirements: performing a + compilation never obsoletes anything. The only way you can obsolete + something and require recompilations is to modify one of the + source files on which it depends. + + @item + There is no library as such, apart from the ALI files + (@pxref{The Ada Library Information Files}, for information on the format of these + files). For now we find it convenient to create separate ALI files, but + eventually the information therein may be incorporated into the object + file directly. + + @item + When you compile a unit, the source files for the specs of all units + that it @code{with}'s, all its subunits, and the bodies of any generics it + instantiates must be available (reachable by the search-paths mechanism + described above), or you will receive a fatal error message. + @end itemize + + @node Examples + @section Examples + + @noindent + The following are some typical Ada compilation command line examples: + + @table @code + @item $ gcc -c xyz.adb + Compile body in file @file{xyz.adb} with all default options. + + @item $ gcc -c -O2 -gnata xyz-def.adb + + Compile the child unit package in file @file{xyz-def.adb} with extensive + optimizations, and pragma @code{Assert}/@code{Debug} statements + enabled. + + @item $ gcc -c -gnatc abc-def.adb + Compile the subunit in file @file{abc-def.adb} in semantic-checking-only + mode. + @end table + + @node Binding Using gnatbind + @chapter Binding Using @code{gnatbind} + @findex gnatbind + + @menu + * Running gnatbind:: + * Generating the Binder Program in C:: + * Consistency-Checking Modes:: + * Binder Error Message Control:: + * Elaboration Control:: + * Output Control:: + * Binding with Non-Ada Main Programs:: + * Binding Programs with No Main Subprogram:: + * Summary of Binder Switches:: + * Command-Line Access:: + * Search Paths for gnatbind:: + * Examples of gnatbind Usage:: + @end menu + + @noindent + This chapter describes the GNAT binder, @code{gnatbind}, which is used + to bind compiled GNAT objects. The @code{gnatbind} program performs + four separate functions: + + @enumerate + @item + Checks that a program is consistent, in accordance with the rules in + Chapter 10 of the Ada 95 Reference Manual. In particular, error + messages are generated if a program uses inconsistent versions of a + given unit. + + @item + Checks that an acceptable order of elaboration exists for the program + and issues an error message if it cannot find an order of elaboration + that satisfies the rules in Chapter 10 of the Ada 95 Language Manual. + + @item + Generates a main program incorporating the given elaboration order. + This program is a small Ada package (body and spec) that + must be subsequently compiled + using the GNAT compiler. The necessary compilation step is usually + performed automatically by @code{gnatlink}. The two most important + functions of this program + are to call the elaboration routines of units in an appropriate order + and to call the main program. + + @item + Determines the set of object files required by the given main program. + This information is output in the forms of comments in the generated program, + to be read by the @code{gnatlink} utility used to link the Ada application. + @end enumerate + + @node Running gnatbind + @section Running @code{gnatbind} + + @noindent + The form of the @code{gnatbind} command is + + @smallexample + $ gnatbind [@var{switches}] @var{mainprog}[.ali] [@var{switches}] + @end smallexample + + @noindent + where @var{mainprog}.adb is the Ada file containing the main program + unit body. If no switches are specified, @code{gnatbind} constructs an Ada + package in two files which names are + @file{b~@var{ada_main}.ads}, and @file{b~@var{ada_main}.adb}. + For example, if given the + parameter @samp{hello.ali}, for a main program contained in file + @file{hello.adb}, the binder output files would be @file{b~hello.ads} + and @file{b~hello.adb}. + + When doing consistency checking, the binder takes into consideration + any source files it can locate. For example, if the binder determines + that the given main program requires the package @code{Pack}, whose + @file{.ali} + file is @file{pack.ali} and whose corresponding source spec file is + @file{pack.ads}, it attempts to locate the source file @file{pack.ads} + (using the same search path conventions as previously described for the + @code{gcc} command). If it can locate this source file, it checks that + the time stamps + or source checksums of the source and its references to in @file{ali} files + match. In other words, any @file{ali} files that mentions this spec must have + resulted from compiling this version of the source file (or in the case + where the source checksums match, a version close enough that the + difference does not matter). + + @cindex Source files, use by binder + The effect of this consistency checking, which includes source files, is + that the binder ensures that the program is consistent with the latest + version of the source files that can be located at bind time. Editing a + source file without compiling files that depend on the source file cause + error messages to be generated by the binder. + + For example, suppose you have a main program @file{hello.adb} and a + package @code{P}, from file @file{p.ads} and you perform the following + steps: + + @enumerate + @item + Enter @code{gcc -c hello.adb} to compile the main program. + + @item + Enter @code{gcc -c p.ads} to compile package @code{P}. + + @item + Edit file @file{p.ads}. + + @item + Enter @code{gnatbind hello}. + @end enumerate + + At this point, the file @file{p.ali} contains an out-of-date time stamp + because the file @file{p.ads} has been edited. The attempt at binding + fails, and the binder generates the following error messages: + + @smallexample + error: "hello.adb" must be recompiled ("p.ads" has been modified) + error: "p.ads" has been modified and must be recompiled + @end smallexample + + @noindent + Now both files must be recompiled as indicated, and then the bind can + succeed, generating a main program. You need not normally be concerned + with the contents of this file, but it is similar to the following which + is the binder file generated for a simple "hello world" program. + + @smallexample + @iftex + @leftskip=0cm + @end iftex + -- The package is called Ada_Main unless this name is actually used + -- as a unit name in the partition, in which case some other unique + -- name is used. + + with System; + package ada_main is + + Elab_Final_Code : Integer; + pragma Import (C, Elab_Final_Code, "__gnat_inside_elab_final_code"); + + -- The main program saves the parameters (argument count, + -- argument values, environment pointer) in global variables + -- for later access by other units including + -- Ada.Command_Line. + + gnat_argc : Integer; + gnat_argv : System.Address; + gnat_envp : System.Address; + + -- The actual variables are stored in a library routine. This + -- is useful for some shared library situations, where there + -- are problems if variables are not in the library. + + pragma Import (C, gnat_argc); + pragma Import (C, gnat_argv); + pragma Import (C, gnat_envp); + + -- The exit status is similarly an external location + + gnat_exit_status : Integer; + pragma Import (C, gnat_exit_status); + + GNAT_Version : constant String := + "GNAT Version: 3.15w (20010315)"; + pragma Export (C, GNAT_Version, "__gnat_version"); + + -- This is the generated adafinal routine that performs + -- finalization at the end of execution. In the case where + -- Ada is the main program, this main program makes a call + -- to adafinal at program termination. + + procedure adafinal; + pragma Export (C, adafinal, "adafinal"); + + -- This is the generated adainit routine that performs + -- initialization at the start of execution. In the case + -- where Ada is the main program, this main program makes + -- a call to adainit at program startup. + + procedure adainit; + pragma Export (C, adainit, "adainit"); + + -- This routine is called at the start of execution. It is + -- a dummy routine that is used by the debugger to breakpoint + -- at the start of execution. + + procedure Break_Start; + pragma Import (C, Break_Start, "__gnat_break_start"); + + -- This is the actual generated main program (it would be + -- suppressed if the no main program switch were used). As + -- required by standard system conventions, this program has + -- the external name main. + + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer; + pragma Export (C, main, "main"); + + -- The following set of constants give the version + -- identification values for every unit in the bound + -- partition. This identification is computed from all + -- dependent semantic units, and corresponds to the + -- string that would be returned by use of the + -- Body_Version or Version attributes. + + type Version_32 is mod 2 ** 32; + u00001 : constant Version_32 := 16#7880BEB3#; + u00002 : constant Version_32 := 16#0D24CBD0#; + u00003 : constant Version_32 := 16#3283DBEB#; + u00004 : constant Version_32 := 16#2359F9ED#; + u00005 : constant Version_32 := 16#664FB847#; + u00006 : constant Version_32 := 16#68E803DF#; + u00007 : constant Version_32 := 16#5572E604#; + u00008 : constant Version_32 := 16#46B173D8#; + u00009 : constant Version_32 := 16#156A40CF#; + u00010 : constant Version_32 := 16#033DABE0#; + u00011 : constant Version_32 := 16#6AB38FEA#; + u00012 : constant Version_32 := 16#22B6217D#; + u00013 : constant Version_32 := 16#68A22947#; + u00014 : constant Version_32 := 16#18CC4A56#; + u00015 : constant Version_32 := 16#08258E1B#; + u00016 : constant Version_32 := 16#367D5222#; + u00017 : constant Version_32 := 16#20C9ECA4#; + u00018 : constant Version_32 := 16#50D32CB6#; + u00019 : constant Version_32 := 16#39A8BB77#; + u00020 : constant Version_32 := 16#5CF8FA2B#; + u00021 : constant Version_32 := 16#2F1EB794#; + u00022 : constant Version_32 := 16#31AB6444#; + u00023 : constant Version_32 := 16#1574B6E9#; + u00024 : constant Version_32 := 16#5109C189#; + u00025 : constant Version_32 := 16#56D770CD#; + u00026 : constant Version_32 := 16#02F9DE3D#; + u00027 : constant Version_32 := 16#08AB6B2C#; + u00028 : constant Version_32 := 16#3FA37670#; + u00029 : constant Version_32 := 16#476457A0#; + u00030 : constant Version_32 := 16#731E1B6E#; + u00031 : constant Version_32 := 16#23C2E789#; + u00032 : constant Version_32 := 16#0F1BD6A1#; + u00033 : constant Version_32 := 16#7C25DE96#; + u00034 : constant Version_32 := 16#39ADFFA2#; + u00035 : constant Version_32 := 16#571DE3E7#; + u00036 : constant Version_32 := 16#5EB646AB#; + u00037 : constant Version_32 := 16#4249379B#; + u00038 : constant Version_32 := 16#0357E00A#; + u00039 : constant Version_32 := 16#3784FB72#; + u00040 : constant Version_32 := 16#2E723019#; + u00041 : constant Version_32 := 16#623358EA#; + u00042 : constant Version_32 := 16#107F9465#; + u00043 : constant Version_32 := 16#6843F68A#; + u00044 : constant Version_32 := 16#63305874#; + u00045 : constant Version_32 := 16#31E56CE1#; + u00046 : constant Version_32 := 16#02917970#; + u00047 : constant Version_32 := 16#6CCBA70E#; + u00048 : constant Version_32 := 16#41CD4204#; + u00049 : constant Version_32 := 16#572E3F58#; + u00050 : constant Version_32 := 16#20729FF5#; + u00051 : constant Version_32 := 16#1D4F93E8#; + u00052 : constant Version_32 := 16#30B2EC3D#; + u00053 : constant Version_32 := 16#34054F96#; + u00054 : constant Version_32 := 16#5A199860#; + u00055 : constant Version_32 := 16#0E7F912B#; + u00056 : constant Version_32 := 16#5760634A#; + u00057 : constant Version_32 := 16#5D851835#; + + -- The following Export pragmas export the version numbers + -- with symbolic names ending in B (for body) or S + -- (for spec) so that they can be located in a link. The + -- information provided here is sufficient to track down + -- the exact versions of units used in a given build. + + pragma Export (C, u00001, "helloB"); + pragma Export (C, u00002, "system__standard_libraryB"); + pragma Export (C, u00003, "system__standard_libraryS"); + pragma Export (C, u00004, "adaS"); + pragma Export (C, u00005, "ada__text_ioB"); + pragma Export (C, u00006, "ada__text_ioS"); + pragma Export (C, u00007, "ada__exceptionsB"); + pragma Export (C, u00008, "ada__exceptionsS"); + pragma Export (C, u00009, "gnatS"); + pragma Export (C, u00010, "gnat__heap_sort_aB"); + pragma Export (C, u00011, "gnat__heap_sort_aS"); + pragma Export (C, u00012, "systemS"); + pragma Export (C, u00013, "system__exception_tableB"); + pragma Export (C, u00014, "system__exception_tableS"); + pragma Export (C, u00015, "gnat__htableB"); + pragma Export (C, u00016, "gnat__htableS"); + pragma Export (C, u00017, "system__exceptionsS"); + pragma Export (C, u00018, "system__machine_state_operationsB"); + pragma Export (C, u00019, "system__machine_state_operationsS"); + pragma Export (C, u00020, "system__machine_codeS"); + pragma Export (C, u00021, "system__storage_elementsB"); + pragma Export (C, u00022, "system__storage_elementsS"); + pragma Export (C, u00023, "system__secondary_stackB"); + pragma Export (C, u00024, "system__secondary_stackS"); + pragma Export (C, u00025, "system__parametersB"); + pragma Export (C, u00026, "system__parametersS"); + pragma Export (C, u00027, "system__soft_linksB"); + pragma Export (C, u00028, "system__soft_linksS"); + pragma Export (C, u00029, "system__stack_checkingB"); + pragma Export (C, u00030, "system__stack_checkingS"); + pragma Export (C, u00031, "system__tracebackB"); + pragma Export (C, u00032, "system__tracebackS"); + pragma Export (C, u00033, "ada__streamsS"); + pragma Export (C, u00034, "ada__tagsB"); + pragma Export (C, u00035, "ada__tagsS"); + pragma Export (C, u00036, "system__string_opsB"); + pragma Export (C, u00037, "system__string_opsS"); + pragma Export (C, u00038, "interfacesS"); + pragma Export (C, u00039, "interfaces__c_streamsB"); + pragma Export (C, u00040, "interfaces__c_streamsS"); + pragma Export (C, u00041, "system__file_ioB"); + pragma Export (C, u00042, "system__file_ioS"); + pragma Export (C, u00043, "ada__finalizationB"); + pragma Export (C, u00044, "ada__finalizationS"); + pragma Export (C, u00045, "system__finalization_rootB"); + pragma Export (C, u00046, "system__finalization_rootS"); + pragma Export (C, u00047, "system__finalization_implementationB"); + pragma Export (C, u00048, "system__finalization_implementationS"); + pragma Export (C, u00049, "system__string_ops_concat_3B"); + pragma Export (C, u00050, "system__string_ops_concat_3S"); + pragma Export (C, u00051, "system__stream_attributesB"); + pragma Export (C, u00052, "system__stream_attributesS"); + pragma Export (C, u00053, "ada__io_exceptionsS"); + pragma Export (C, u00054, "system__unsigned_typesS"); + pragma Export (C, u00055, "system__file_control_blockS"); + pragma Export (C, u00056, "ada__finalization__list_controllerB"); + pragma Export (C, u00057, "ada__finalization__list_controllerS"); + + -- BEGIN ELABORATION ORDER + -- ada (spec) + -- gnat (spec) + -- gnat.heap_sort_a (spec) + -- gnat.heap_sort_a (body) + -- gnat.htable (spec) + -- gnat.htable (body) + -- interfaces (spec) + -- system (spec) + -- system.machine_code (spec) + -- system.parameters (spec) + -- system.parameters (body) + -- interfaces.c_streams (spec) + -- interfaces.c_streams (body) + -- system.standard_library (spec) + -- ada.exceptions (spec) + -- system.exception_table (spec) + -- system.exception_table (body) + -- ada.io_exceptions (spec) + -- system.exceptions (spec) + -- system.storage_elements (spec) + -- system.storage_elements (body) + -- system.machine_state_operations (spec) + -- system.machine_state_operations (body) + -- system.secondary_stack (spec) + -- system.stack_checking (spec) + -- system.soft_links (spec) + -- system.soft_links (body) + -- system.stack_checking (body) + -- system.secondary_stack (body) + -- system.standard_library (body) + -- system.string_ops (spec) + -- system.string_ops (body) + -- ada.tags (spec) + -- ada.tags (body) + -- ada.streams (spec) + -- system.finalization_root (spec) + -- system.finalization_root (body) + -- system.string_ops_concat_3 (spec) + -- system.string_ops_concat_3 (body) + -- system.traceback (spec) + -- system.traceback (body) + -- ada.exceptions (body) + -- system.unsigned_types (spec) + -- system.stream_attributes (spec) + -- system.stream_attributes (body) + -- system.finalization_implementation (spec) + -- system.finalization_implementation (body) + -- ada.finalization (spec) + -- ada.finalization (body) + -- ada.finalization.list_controller (spec) + -- ada.finalization.list_controller (body) + -- system.file_control_block (spec) + -- system.file_io (spec) + -- system.file_io (body) + -- ada.text_io (spec) + -- ada.text_io (body) + -- hello (body) + -- END ELABORATION ORDER + + end ada_main; + + -- The following source file name pragmas allow the generated file + -- names to be unique for different main programs. They are needed + -- since the package name will always be Ada_Main. + + pragma Source_File_Name (ada_main, Spec_File_Name => "b~hello.ads"); + pragma Source_File_Name (ada_main, Body_File_Name => "b~hello.adb"); + + -- Generated package body for Ada_Main starts here + + package body ada_main is + + -- The actual finalization is performed by calling the + -- library routine in System.Standard_Library.Adafinal + + procedure Do_Finalize; + pragma Import (C, Do_Finalize, "system__standard_library__adafinal"); + + ------------- + -- adainit -- + ------------- + + @findex adainit + procedure adainit is + + -- These booleans are set to True once the associated unit has + -- been elaborated. It is also used to avoid elaborating the + -- same unit twice. + + E040 : Boolean; pragma Import (Ada, E040, "interfaces__c_streams_E"); + E008 : Boolean; pragma Import (Ada, E008, "ada__exceptions_E"); + E014 : Boolean; pragma Import (Ada, E014, "system__exception_table_E"); + E053 : Boolean; pragma Import (Ada, E053, "ada__io_exceptions_E"); + E017 : Boolean; pragma Import (Ada, E017, "system__exceptions_E"); + E024 : Boolean; pragma Import (Ada, E024, "system__secondary_stack_E"); + E030 : Boolean; pragma Import (Ada, E030, "system__stack_checking_E"); + E028 : Boolean; pragma Import (Ada, E028, "system__soft_links_E"); + E035 : Boolean; pragma Import (Ada, E035, "ada__tags_E"); + E033 : Boolean; pragma Import (Ada, E033, "ada__streams_E"); + E046 : Boolean; pragma Import (Ada, E046, "system__finalization_root_E"); + E048 : Boolean; pragma Import (Ada, E048, "system__finalization_implementation_E"); + E044 : Boolean; pragma Import (Ada, E044, "ada__finalization_E"); + E057 : Boolean; pragma Import (Ada, E057, "ada__finalization__list_controller_E"); + E055 : Boolean; pragma Import (Ada, E055, "system__file_control_block_E"); + E042 : Boolean; pragma Import (Ada, E042, "system__file_io_E"); + E006 : Boolean; pragma Import (Ada, E006, "ada__text_io_E"); + + -- Set_Globals is a library routine that stores away the + -- value of the indicated set of global values in global + -- variables within the library. + + procedure Set_Globals + (Main_Priority : Integer; + Time_Slice_Value : Integer; + WC_Encoding : Character; + Locking_Policy : Character; + Queuing_Policy : Character; + Task_Dispatching_Policy : Character; + Adafinal : System.Address; + Unreserve_All_Interrupts : Integer; + Exception_Tracebacks : Integer); + @findex __gnat_set_globals + pragma Import (C, Set_Globals, "__gnat_set_globals"); + + -- SDP_Table_Build is a library routine used to build the + -- exception tables. See unit Ada.Exceptions in files + -- a-except.ads/adb for full details of how zero cost + -- exception handling works. This procedure, the call to + -- it, and the two following tables are all omitted if the + -- build is in longjmp/setjump exception mode. + + @findex SDP_Table_Build + @findex Zero Cost Exceptions + procedure SDP_Table_Build + (SDP_Addresses : System.Address; + SDP_Count : Natural; + Elab_Addresses : System.Address; + Elab_Addr_Count : Natural); + pragma Import (C, SDP_Table_Build, "__gnat_SDP_Table_Build"); + + -- Table of Unit_Exception_Table addresses. Used for zero + -- cost exception handling to build the top level table. + + ST : aliased constant array (1 .. 23) of System.Address := ( + Hello'UET_Address, + Ada.Text_Io'UET_Address, + Ada.Exceptions'UET_Address, + Gnat.Heap_Sort_A'UET_Address, + System.Exception_Table'UET_Address, + System.Machine_State_Operations'UET_Address, + System.Secondary_Stack'UET_Address, + System.Parameters'UET_Address, + System.Soft_Links'UET_Address, + System.Stack_Checking'UET_Address, + System.Traceback'UET_Address, + Ada.Streams'UET_Address, + Ada.Tags'UET_Address, + System.String_Ops'UET_Address, + Interfaces.C_Streams'UET_Address, + System.File_Io'UET_Address, + Ada.Finalization'UET_Address, + System.Finalization_Root'UET_Address, + System.Finalization_Implementation'UET_Address, + System.String_Ops_Concat_3'UET_Address, + System.Stream_Attributes'UET_Address, + System.File_Control_Block'UET_Address, + Ada.Finalization.List_Controller'UET_Address); + + -- Table of addresses of elaboration routines. Used for + -- zero cost exception handling to make sure these + -- addresses are included in the top level procedure + -- address table. + + EA : aliased constant array (1 .. 23) of System.Address := ( + adainit'Code_Address, + Do_Finalize'Code_Address, + Ada.Exceptions'Elab_Spec'Address, + System.Exceptions'Elab_Spec'Address, + Interfaces.C_Streams'Elab_Spec'Address, + System.Exception_Table'Elab_Body'Address, + Ada.Io_Exceptions'Elab_Spec'Address, + System.Stack_Checking'Elab_Spec'Address, + System.Soft_Links'Elab_Body'Address, + System.Secondary_Stack'Elab_Body'Address, + Ada.Tags'Elab_Spec'Address, + Ada.Tags'Elab_Body'Address, + Ada.Streams'Elab_Spec'Address, + System.Finalization_Root'Elab_Spec'Address, + Ada.Exceptions'Elab_Body'Address, + System.Finalization_Implementation'Elab_Spec'Address, + System.Finalization_Implementation'Elab_Body'Address, + Ada.Finalization'Elab_Spec'Address, + Ada.Finalization.List_Controller'Elab_Spec'Address, + System.File_Control_Block'Elab_Spec'Address, + System.File_Io'Elab_Body'Address, + Ada.Text_Io'Elab_Spec'Address, + Ada.Text_Io'Elab_Body'Address); + + -- Start of processing for adainit + + begin + + -- Call SDP_Table_Build to build the top level procedure + -- table for zero cost exception handling (omitted in + -- longjmp/setjump mode). + + SDP_Table_Build (ST'Address, 23, EA'Address, 23); + + -- Call Set_Globals to record various information for + -- this partition. The values are derived by the binder + -- from information stored in the ali files by the compiler. + + @findex __gnat_set_globals + Set_Globals + (Main_Priority => -1, + -- Priority of main program, -1 if no pragma Priority used + + Time_Slice_Value => -1, + -- Time slice from Time_Slice pragma, -1 if none used + + WC_Encoding => 'b', + -- Wide_Character encoding used, default is brackets + + Locking_Policy => ' ', + -- Locking_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Queuing_Policy => ' ', + -- Queuing_Policy used, default of space means not + -- specified, otherwise it is the first character of + -- the policy name. + + Task_Dispatching_Policy => ' ', + -- Task_Dispatching_Policy used, default of space means + -- not specified, otherwise first character of the + -- policy name. + + Adafinal => System.Null_Address, + -- Address of Adafinal routine, not used anymore + + Unreserve_All_Interrupts => 0, + -- Set true if pragma Unreserve_All_Interrupts was used + + Exception_Tracebacks => 0); + -- Indicates if exception tracebacks are enabled + + Elab_Final_Code := 1; + + -- Now we have the elaboration calls for all units in the partition. + -- The Elab_Spec and Elab_Body attributes generate references to the + -- implicit elaboration procedures generated by the compiler for + -- each unit that requires elaboration. + + if not E040 then + Interfaces.C_Streams'Elab_Spec; + end if; + E040 := True; + if not E008 then + Ada.Exceptions'Elab_Spec; + end if; + if not E014 then + System.Exception_Table'Elab_Body; + E014 := True; + end if; + if not E053 then + Ada.Io_Exceptions'Elab_Spec; + E053 := True; + end if; + if not E017 then + System.Exceptions'Elab_Spec; + E017 := True; + end if; + if not E030 then + System.Stack_Checking'Elab_Spec; + end if; + if not E028 then + System.Soft_Links'Elab_Body; + E028 := True; + end if; + E030 := True; + if not E024 then + System.Secondary_Stack'Elab_Body; + E024 := True; + end if; + if not E035 then + Ada.Tags'Elab_Spec; + end if; + if not E035 then + Ada.Tags'Elab_Body; + E035 := True; + end if; + if not E033 then + Ada.Streams'Elab_Spec; + E033 := True; + end if; + if not E046 then + System.Finalization_Root'Elab_Spec; + end if; + E046 := True; + if not E008 then + Ada.Exceptions'Elab_Body; + E008 := True; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Spec; + end if; + if not E048 then + System.Finalization_Implementation'Elab_Body; + E048 := True; + end if; + if not E044 then + Ada.Finalization'Elab_Spec; + end if; + E044 := True; + if not E057 then + Ada.Finalization.List_Controller'Elab_Spec; + end if; + E057 := True; + if not E055 then + System.File_Control_Block'Elab_Spec; + E055 := True; + end if; + if not E042 then + System.File_Io'Elab_Body; + E042 := True; + end if; + if not E006 then + Ada.Text_Io'Elab_Spec; + end if; + if not E006 then + Ada.Text_Io'Elab_Body; + E006 := True; + end if; + + Elab_Final_Code := 0; + end adainit; + + -------------- + -- adafinal -- + -------------- + + @findex adafinal + procedure adafinal is + begin + Do_Finalize; + end adafinal; + + ---------- + -- main -- + ---------- + + -- main is actually a function, as in the ANSI C standard, + -- defined to return the exit status. The three parameters + -- are the argument count, argument values and environment + -- pointer. + + @findex Main Program + function main + (argc : Integer; + argv : System.Address; + envp : System.Address) + return Integer + is + -- The initialize routine performs low level system + -- initialization using a standard library routine which + -- sets up signal handling and performs any other + -- required setup. The routine can be found in file + -- a-init.c. + + @findex __gnat_initialize + procedure initialize; + pragma Import (C, initialize, "__gnat_initialize"); + + -- The finalize routine performs low level system + -- finalization using a standard library routine. The + -- routine is found in file a-final.c and in the standard + -- distribution is a dummy routine that does nothing, so + -- really this is a hook for special user finalization. + + @findex __gnat_finalize + procedure finalize; + pragma Import (C, finalize, "__gnat_finalize"); + + -- We get to the main program of the partition by using + -- pragma Import because if we try to with the unit and + -- call it Ada style, then not only do we waste time + -- recompiling it, but also, we don't really know the right + -- switches (e.g. identifier character set) to be used + -- to compile it. + + procedure Ada_Main_Program; + pragma Import (Ada, Ada_Main_Program, "_ada_hello"); + + -- Start of processing for main + + begin + -- Save global variables + + gnat_argc := argc; + gnat_argv := argv; + gnat_envp := envp; + + -- Call low level system initialization + + Initialize; + + -- Call our generated Ada initialization routine + + adainit; + + -- This is the point at which we want the debugger to get + -- control + + Break_Start; + + -- Now we call the main program of the partition + + Ada_Main_Program; + + -- Perform Ada finalization + + adafinal; + + -- Perform low level system finalization + + Finalize; + + -- Return the proper exit status + return (gnat_exit_status); + end; + + -- This section is entirely comments, so it has no effect on the + -- compilation of the Ada_Main package. It provides the list of + -- object files and linker options, as well as some standard + -- libraries needed for the link. The gnatlink utility parses + -- this b~hello.adb file to read these comment lines to generate + -- the appropriate command line arguments for the call to the + -- system linker. The BEGIN/END lines are used for sentinels for + -- this parsing operation. + + -- The exact file names will of course depend on the environment, + -- host/target and location of files on the host system. + + @findex Object file list + -- BEGIN Object file/option list + -- ./hello.o + -- -L./ + -- -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/ + -- /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a + -- END Object file/option list + + end ada_main; + + @end smallexample + + @noindent + The Ada code in the above example is exactly what is generated by the + binder. We have added comments to more clearly indicate the function + of each part of the generated @code{Ada_Main} package. + + The code is standard Ada in all respects, and can be processed by any + tools that handle Ada. In particular, it is possible to use the debugger + in Ada mode to debug the generated Ada_Main package. For example, suppose + that for reasons that you do not understand, your program is blowing up + during elaboration of the body of @code{Ada.Text_IO}. To chase this bug + down, you can place a breakpoint on the call: + + @smallexample + Ada.Text_Io'Elab_Body; + @end smallexample + + @noindent + and trace the elaboration routine for this package to find out where + the problem might be (more usually of course you would be debugging + elaboration code in your own application). + + @node Generating the Binder Program in C + @section Generating the Binder Program in C + @noindent + In most normal usage, the default mode of @code{gnatbind} which is to + generate the main package in Ada, as described in the previous section. + In particular, this means that any Ada programmer can read and understand + the generated main program. It can also be debugged just like any other + Ada code provided the @code{-g} switch is used for @code{gnatbind} + and @code{gnatlink}. + + However for some purposes it may be convenient to generate the main + program in C rather than Ada. This may for example be helpful when you + are generating a mixed language program with the main program in C. The + GNAT compiler itself is an example. The use of the @code{-C} switch + for both @code{gnatbind} and @code{gnatlink} will cause the program to + be generated in C (and compiled using the gnu C compiler). The + following shows the C code generated for the same "Hello World" + program: + + @smallexample + + #ifdef __STDC__ + #define PARAMS(paramlist) paramlist + #else + #define PARAMS(paramlist) () + #endif + + extern void __gnat_set_globals + PARAMS ((int, int, int, int, int, int, + void (*) PARAMS ((void)), int, int)); + extern void adafinal PARAMS ((void)); + extern void adainit PARAMS ((void)); + extern void system__standard_library__adafinal PARAMS ((void)); + extern int main PARAMS ((int, char **, char **)); + extern void exit PARAMS ((int)); + extern void __gnat_break_start PARAMS ((void)); + extern void _ada_hello PARAMS ((void)); + extern void __gnat_initialize PARAMS ((void)); + extern void __gnat_finalize PARAMS ((void)); + + extern void ada__exceptions___elabs PARAMS ((void)); + extern void system__exceptions___elabs PARAMS ((void)); + extern void interfaces__c_streams___elabs PARAMS ((void)); + extern void system__exception_table___elabb PARAMS ((void)); + extern void ada__io_exceptions___elabs PARAMS ((void)); + extern void system__stack_checking___elabs PARAMS ((void)); + extern void system__soft_links___elabb PARAMS ((void)); + extern void system__secondary_stack___elabb PARAMS ((void)); + extern void ada__tags___elabs PARAMS ((void)); + extern void ada__tags___elabb PARAMS ((void)); + extern void ada__streams___elabs PARAMS ((void)); + extern void system__finalization_root___elabs PARAMS ((void)); + extern void ada__exceptions___elabb PARAMS ((void)); + extern void system__finalization_implementation___elabs PARAMS ((void)); + extern void system__finalization_implementation___elabb PARAMS ((void)); + extern void ada__finalization___elabs PARAMS ((void)); + extern void ada__finalization__list_controller___elabs PARAMS ((void)); + extern void system__file_control_block___elabs PARAMS ((void)); + extern void system__file_io___elabb PARAMS ((void)); + extern void ada__text_io___elabs PARAMS ((void)); + extern void ada__text_io___elabb PARAMS ((void)); + + extern int __gnat_inside_elab_final_code; + + extern int gnat_argc; + extern char **gnat_argv; + extern char **gnat_envp; + extern int gnat_exit_status; + + char __gnat_version[] = "GNAT Version: 3.15w (20010315)"; + void adafinal () @{ + system__standard_library__adafinal (); + @} + + void adainit () + @{ + extern char ada__exceptions_E; + extern char system__exceptions_E; + extern char interfaces__c_streams_E; + extern char system__exception_table_E; + extern char ada__io_exceptions_E; + extern char system__secondary_stack_E; + extern char system__stack_checking_E; + extern char system__soft_links_E; + extern char ada__tags_E; + extern char ada__streams_E; + extern char system__finalization_root_E; + extern char system__finalization_implementation_E; + extern char ada__finalization_E; + extern char ada__finalization__list_controller_E; + extern char system__file_control_block_E; + extern char system__file_io_E; + extern char ada__text_io_E; + + extern void *__gnat_hello__SDP; + extern void *__gnat_ada__text_io__SDP; + extern void *__gnat_ada__exceptions__SDP; + extern void *__gnat_gnat__heap_sort_a__SDP; + extern void *__gnat_system__exception_table__SDP; + extern void *__gnat_system__machine_state_operations__SDP; + extern void *__gnat_system__secondary_stack__SDP; + extern void *__gnat_system__parameters__SDP; + extern void *__gnat_system__soft_links__SDP; + extern void *__gnat_system__stack_checking__SDP; + extern void *__gnat_system__traceback__SDP; + extern void *__gnat_ada__streams__SDP; + extern void *__gnat_ada__tags__SDP; + extern void *__gnat_system__string_ops__SDP; + extern void *__gnat_interfaces__c_streams__SDP; + extern void *__gnat_system__file_io__SDP; + extern void *__gnat_ada__finalization__SDP; + extern void *__gnat_system__finalization_root__SDP; + extern void *__gnat_system__finalization_implementation__SDP; + extern void *__gnat_system__string_ops_concat_3__SDP; + extern void *__gnat_system__stream_attributes__SDP; + extern void *__gnat_system__file_control_block__SDP; + extern void *__gnat_ada__finalization__list_controller__SDP; + + void **st[23] = @{ + &__gnat_hello__SDP, + &__gnat_ada__text_io__SDP, + &__gnat_ada__exceptions__SDP, + &__gnat_gnat__heap_sort_a__SDP, + &__gnat_system__exception_table__SDP, + &__gnat_system__machine_state_operations__SDP, + &__gnat_system__secondary_stack__SDP, + &__gnat_system__parameters__SDP, + &__gnat_system__soft_links__SDP, + &__gnat_system__stack_checking__SDP, + &__gnat_system__traceback__SDP, + &__gnat_ada__streams__SDP, + &__gnat_ada__tags__SDP, + &__gnat_system__string_ops__SDP, + &__gnat_interfaces__c_streams__SDP, + &__gnat_system__file_io__SDP, + &__gnat_ada__finalization__SDP, + &__gnat_system__finalization_root__SDP, + &__gnat_system__finalization_implementation__SDP, + &__gnat_system__string_ops_concat_3__SDP, + &__gnat_system__stream_attributes__SDP, + &__gnat_system__file_control_block__SDP, + &__gnat_ada__finalization__list_controller__SDP@}; + + extern void ada__exceptions___elabs (); + extern void system__exceptions___elabs (); + extern void interfaces__c_streams___elabs (); + extern void system__exception_table___elabb (); + extern void ada__io_exceptions___elabs (); + extern void system__stack_checking___elabs (); + extern void system__soft_links___elabb (); + extern void system__secondary_stack___elabb (); + extern void ada__tags___elabs (); + extern void ada__tags___elabb (); + extern void ada__streams___elabs (); + extern void system__finalization_root___elabs (); + extern void ada__exceptions___elabb (); + extern void system__finalization_implementation___elabs (); + extern void system__finalization_implementation___elabb (); + extern void ada__finalization___elabs (); + extern void ada__finalization__list_controller___elabs (); + extern void system__file_control_block___elabs (); + extern void system__file_io___elabb (); + extern void ada__text_io___elabs (); + extern void ada__text_io___elabb (); + + void (*ea[23]) () = @{ + adainit, + system__standard_library__adafinal, + ada__exceptions___elabs, + system__exceptions___elabs, + interfaces__c_streams___elabs, + system__exception_table___elabb, + ada__io_exceptions___elabs, + system__stack_checking___elabs, + system__soft_links___elabb, + system__secondary_stack___elabb, + ada__tags___elabs, + ada__tags___elabb, + ada__streams___elabs, + system__finalization_root___elabs, + ada__exceptions___elabb, + system__finalization_implementation___elabs, + system__finalization_implementation___elabb, + ada__finalization___elabs, + ada__finalization__list_controller___elabs, + system__file_control_block___elabs, + system__file_io___elabb, + ada__text_io___elabs, + ada__text_io___elabb@}; + + __gnat_SDP_Table_Build (&st, 23, ea, 23); + __gnat_set_globals ( + -1, /* Main_Priority */ + -1, /* Time_Slice_Value */ + 'b', /* WC_Encoding */ + ' ', /* Locking_Policy */ + ' ', /* Queuing_Policy */ + ' ', /* Tasking_Dispatching_Policy */ + 0, /* Finalization routine address, not used anymore */ + 0, /* Unreserve_All_Interrupts */ + 0); /* Exception_Tracebacks */ + + __gnat_inside_elab_final_code = 1; + + if (ada__exceptions_E == 0) @{ + ada__exceptions___elabs (); + @} + if (system__exceptions_E == 0) @{ + system__exceptions___elabs (); + system__exceptions_E++; + @} + if (interfaces__c_streams_E == 0) @{ + interfaces__c_streams___elabs (); + @} + interfaces__c_streams_E = 1; + if (system__exception_table_E == 0) @{ + system__exception_table___elabb (); + system__exception_table_E++; + @} + if (ada__io_exceptions_E == 0) @{ + ada__io_exceptions___elabs (); + ada__io_exceptions_E++; + @} + if (system__stack_checking_E == 0) @{ + system__stack_checking___elabs (); + @} + if (system__soft_links_E == 0) @{ + system__soft_links___elabb (); + system__soft_links_E++; + @} + system__stack_checking_E = 1; + if (system__secondary_stack_E == 0) @{ + system__secondary_stack___elabb (); + system__secondary_stack_E++; + @} + if (ada__tags_E == 0) @{ + ada__tags___elabs (); + @} + if (ada__tags_E == 0) @{ + ada__tags___elabb (); + ada__tags_E++; + @} + if (ada__streams_E == 0) @{ + ada__streams___elabs (); + ada__streams_E++; + @} + if (system__finalization_root_E == 0) @{ + system__finalization_root___elabs (); + @} + system__finalization_root_E = 1; + if (ada__exceptions_E == 0) @{ + ada__exceptions___elabb (); + ada__exceptions_E++; + @} + if (system__finalization_implementation_E == 0) @{ + system__finalization_implementation___elabs (); + @} + if (system__finalization_implementation_E == 0) @{ + system__finalization_implementation___elabb (); + system__finalization_implementation_E++; + @} + if (ada__finalization_E == 0) @{ + ada__finalization___elabs (); + @} + ada__finalization_E = 1; + if (ada__finalization__list_controller_E == 0) @{ + ada__finalization__list_controller___elabs (); + @} + ada__finalization__list_controller_E = 1; + if (system__file_control_block_E == 0) @{ + system__file_control_block___elabs (); + system__file_control_block_E++; + @} + if (system__file_io_E == 0) @{ + system__file_io___elabb (); + system__file_io_E++; + @} + if (ada__text_io_E == 0) @{ + ada__text_io___elabs (); + @} + if (ada__text_io_E == 0) @{ + ada__text_io___elabb (); + ada__text_io_E++; + @} + + __gnat_inside_elab_final_code = 0; + @} + int main (argc, argv, envp) + int argc; + char **argv; + char **envp; + @{ + gnat_argc = argc; + gnat_argv = argv; + gnat_envp = envp; + + __gnat_initialize (); + adainit (); + __gnat_break_start (); + + _ada_hello (); + + system__standard_library__adafinal (); + __gnat_finalize (); + exit (gnat_exit_status); + @} + unsigned helloB = 0x7880BEB3; + unsigned system__standard_libraryB = 0x0D24CBD0; + unsigned system__standard_libraryS = 0x3283DBEB; + unsigned adaS = 0x2359F9ED; + unsigned ada__text_ioB = 0x47C85FC4; + unsigned ada__text_ioS = 0x496FE45C; + unsigned ada__exceptionsB = 0x74F50187; + unsigned ada__exceptionsS = 0x6736945B; + unsigned gnatS = 0x156A40CF; + unsigned gnat__heap_sort_aB = 0x033DABE0; + unsigned gnat__heap_sort_aS = 0x6AB38FEA; + unsigned systemS = 0x0331C6FE; + unsigned system__exceptionsS = 0x20C9ECA4; + unsigned system__exception_tableB = 0x68A22947; + unsigned system__exception_tableS = 0x394BADD5; + unsigned gnat__htableB = 0x08258E1B; + unsigned gnat__htableS = 0x367D5222; + unsigned system__machine_state_operationsB = 0x4F3B7492; + unsigned system__machine_state_operationsS = 0x182F5CF4; + unsigned system__storage_elementsB = 0x2F1EB794; + unsigned system__storage_elementsS = 0x102C83C7; + unsigned system__secondary_stackB = 0x1574B6E9; + unsigned system__secondary_stackS = 0x708E260A; + unsigned system__parametersB = 0x56D770CD; + unsigned system__parametersS = 0x237E39BE; + unsigned system__soft_linksB = 0x08AB6B2C; + unsigned system__soft_linksS = 0x1E2491F3; + unsigned system__stack_checkingB = 0x476457A0; + unsigned system__stack_checkingS = 0x5299FCED; + unsigned system__tracebackB = 0x2971EBDE; + unsigned system__tracebackS = 0x2E9C3122; + unsigned ada__streamsS = 0x7C25DE96; + unsigned ada__tagsB = 0x39ADFFA2; + unsigned ada__tagsS = 0x769A0464; + unsigned system__string_opsB = 0x5EB646AB; + unsigned system__string_opsS = 0x63CED018; + unsigned interfacesS = 0x0357E00A; + unsigned interfaces__c_streamsB = 0x3784FB72; + unsigned interfaces__c_streamsS = 0x2E723019; + unsigned system__file_ioB = 0x623358EA; + unsigned system__file_ioS = 0x31F873E6; + unsigned ada__finalizationB = 0x6843F68A; + unsigned ada__finalizationS = 0x63305874; + unsigned system__finalization_rootB = 0x31E56CE1; + unsigned system__finalization_rootS = 0x23169EF3; + unsigned system__finalization_implementationB = 0x6CCBA70E; + unsigned system__finalization_implementationS = 0x604AA587; + unsigned system__string_ops_concat_3B = 0x572E3F58; + unsigned system__string_ops_concat_3S = 0x01F57876; + unsigned system__stream_attributesB = 0x1D4F93E8; + unsigned system__stream_attributesS = 0x30B2EC3D; + unsigned ada__io_exceptionsS = 0x34054F96; + unsigned system__unsigned_typesS = 0x7B9E7FE3; + unsigned system__file_control_blockS = 0x2FF876A8; + unsigned ada__finalization__list_controllerB = 0x5760634A; + unsigned ada__finalization__list_controllerS = 0x5D851835; + + /* BEGIN ELABORATION ORDER + ada (spec) + gnat (spec) + gnat.heap_sort_a (spec) + gnat.htable (spec) + gnat.htable (body) + interfaces (spec) + system (spec) + system.parameters (spec) + system.standard_library (spec) + ada.exceptions (spec) + system.exceptions (spec) + system.parameters (body) + gnat.heap_sort_a (body) + interfaces.c_streams (spec) + interfaces.c_streams (body) + system.exception_table (spec) + system.exception_table (body) + ada.io_exceptions (spec) + system.storage_elements (spec) + system.storage_elements (body) + system.machine_state_operations (spec) + system.machine_state_operations (body) + system.secondary_stack (spec) + system.stack_checking (spec) + system.soft_links (spec) + system.soft_links (body) + system.stack_checking (body) + system.secondary_stack (body) + system.standard_library (body) + system.string_ops (spec) + system.string_ops (body) + ada.tags (spec) + ada.tags (body) + ada.streams (spec) + system.finalization_root (spec) + system.finalization_root (body) + system.string_ops_concat_3 (spec) + system.string_ops_concat_3 (body) + system.traceback (spec) + system.traceback (body) + ada.exceptions (body) + system.unsigned_types (spec) + system.stream_attributes (spec) + system.stream_attributes (body) + system.finalization_implementation (spec) + system.finalization_implementation (body) + ada.finalization (spec) + ada.finalization (body) + ada.finalization.list_controller (spec) + ada.finalization.list_controller (body) + system.file_control_block (spec) + system.file_io (spec) + system.file_io (body) + ada.text_io (spec) + ada.text_io (body) + hello (body) + END ELABORATION ORDER */ + + /* BEGIN Object file/option list + ./hello.o + -L./ + -L/usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/ + /usr/local/gnat/lib/gcc-lib/alpha-dec-osf5.1/2.8.1/adalib/libgnat.a + -lexc + END Object file/option list */ + + @end smallexample + + @noindent + Here again, the C code is exactly what is generated by the binder. The + functions of the various parts of this code correspond in an obvious + manner with the commented Ada code shown in the example in the previous + section. + + @node Consistency-Checking Modes + @section Consistency-Checking Modes + + @noindent + As described in the previous section, by default @code{gnatbind} checks + that object files are consistent with one another and are consistent + with any source files it can locate. The following switches control binder + access to sources. + + @table @code + @item -s + @cindex @code{-s} (@code{gnatbind}) + Require source files to be present. In this mode, the binder must be + able to locate all source files that are referenced, in order to check + their consistency. In normal mode, if a source file cannot be located it + is simply ignored. If you specify this switch, a missing source + file is an error. + + @item -x + @cindex @code{-x} (@code{gnatbind}) + Exclude source files. In this mode, the binder only checks that ALI + files are consistent with one another. Source files are not accessed. + The binder runs faster in this mode, and there is still a guarantee that + the resulting program is self-consistent. + If a source file has been edited since it was last compiled, and you + specify this switch, the binder will not detect that the object + file is out of date with respect to the source file. Note that this is the + mode that is automatically used by @code{gnatmake} because in this + case the checking against sources has already been performed by + @code{gnatmake} in the course of compilation (i.e. before binding). + + @end table + + @node Binder Error Message Control + @section Binder Error Message Control + + @noindent + The following switches provide control over the generation of error + messages from the binder: + + @table @code + @item -v + @cindex @code{-v} (@code{gnatbind}) + Verbose mode. In the normal mode, brief error messages are generated to + @file{stderr}. If this switch is present, a header is written + to @file{stdout} and any error messages are directed to @file{stdout}. + All that is written to @file{stderr} is a brief summary message. + + @item -b + @cindex @code{-b} (@code{gnatbind}) + Generate brief error messages to @file{stderr} even if verbose mode is + specified. This is relevant only when used with the + @code{-v} switch. + + @item -m@var{n} + @cindex @code{-m} (@code{gnatbind}) + Limits the number of error messages to @var{n}, a decimal integer in the + range 1-999. The binder terminates immediately if this limit is reached. + + @item -M@var{xxx} + @cindex @code{-M} (@code{gnatbind}) + Renames the generated main program from @code{main} to @code{xxx}. + This is useful in the case of some cross-building environments, where + the actual main program is separate from the one generated + by @code{gnatbind}. + + @item -ws + @cindex @code{-ws} (@code{gnatbind}) + @cindex Warnings + Suppress all warning messages. + + @item -we + @cindex @code{-we} (@code{gnatbind}) + Treat any warning messages as fatal errors. + + + @item -t + @cindex @code{-t} (@code{gnatbind}) + @cindex Time stamp checks, in binder + @cindex Binder consistency checks + @cindex Consistency checks, in binder + The binder performs a number of consistency checks including: + + @itemize @bullet + @item + Check that time stamps of a given source unit are consistent + @item + Check that checksums of a given source unit are consistent + @item + Check that consistent versions of @code{GNAT} were used for compilation + @item + Check consistency of configuration pragmas as required + @end itemize + + @noindent + Normally failure of such checks, in accordance with the consistency + requirements of the Ada Reference Manual, causes error messages to be + generated which abort the binder and prevent the output of a binder + file and subsequent link to obtain an executable. + + The @code{-t} switch converts these error messages + into warnings, so that + binding and linking can continue to completion even in the presence of such + errors. The result may be a failed link (due to missing symbols), or a + non-functional executable which has undefined semantics. + @emph{This means that + @code{-t} should be used only in unusual situations, + with extreme care.} + @end table + + @node Elaboration Control + @section Elaboration Control + + @noindent + The following switches provide additional control over the elaboration + order. For full details see @xref{Elaboration Order Handling in GNAT}. + + @table @code + @item -p + @cindex @code{-h} (@code{gnatbind}) + Normally the binder attempts to choose an elaboration order that is + likely to minimize the likelihood of an elaboration order error resulting + in raising a @code{Program_Error} exception. This switch reverses the + action of the binder, and requests that it deliberately choose an order + that is likely to maximize the likelihood of an elaboration error. + This is useful in ensuring portability and avoiding dependence on + accidental fortuitous elaboration ordering. + + Normally it only makes sense to use the @code{-p} switch if dynamic + elaboration checking is used (@option{-gnatE} switch used for compilation). + This is because in the default static elaboration mode, all necessary + @code{Elaborate_All} pragmas are implicitly inserted. These implicit + pragmas are still respected by the binder in @code{-p} mode, so a + safe elaboration order is assured. + @end table + + @node Output Control + @section Output Control + + @noindent + The following switches allow additional control over the output + generated by the binder. + + @table @code + + @item -A + @cindex @code{-A} (@code{gnatbind}) + Generate binder program in Ada (default). The binder program is named + @file{b~@var{mainprog}.adb} by default. This can be changed with + @code{-o} @code{gnatbind} option. + + @item -c + @cindex @code{-c} (@code{gnatbind}) + Check only. Do not generate the binder output file. In this mode the + binder performs all error checks but does not generate an output file. + + @item -C + @cindex @code{-C} (@code{gnatbind}) + Generate binder program in C. The binder program is named + @file{b_@var{mainprog}.c}. This can be changed with @code{-o} @code{gnatbind} + option. + + @item -e + @cindex @code{-e} (@code{gnatbind}) + Output complete list of elaboration-order dependencies, showing the + reason for each dependency. This output can be rather extensive but may + be useful in diagnosing problems with elaboration order. The output is + written to @file{stdout}. + + @item -h + @cindex @code{-h} (@code{gnatbind}) + Output usage information. The output is written to @file{stdout}. + + @item -K + @cindex @code{-K} (@code{gnatbind}) + Output linker options to @file{stdout}. Includes library search paths, + contents of pragmas Ident and Linker_Options, and libraries added + by @code{gnatbind}. + + @item -l + @cindex @code{-l} (@code{gnatbind}) + Output chosen elaboration order. The output is written to @file{stdout}. + + @item -O + @cindex @code{-O} (@code{gnatbind}) + Output full names of all the object files that must be linked to provide + the Ada component of the program. The output is written to @file{stdout}. + This list includes the files explicitly supplied and referenced by the user + as well as implicitly referenced run-time unit files. The latter are + omitted if the corresponding units reside in shared libraries. The + directory names for the run-time units depend on the system configuration. + + @item -o @var{file} + @cindex @code{-o} (@code{gnatbind}) + Set name of output file to @var{file} instead of the normal + @file{b~@var{mainprog}.adb} default. Note that @var{file} denote the Ada + binder generated body filename. In C mode you would normally give + @var{file} an extension of @file{.c} because it will be a C source program. + Note that if this option is used, then linking must be done manually. + It is not possible to use gnatlink in this case, since it cannot locate + the binder file. + + @item -r + @cindex @code{-r} (@code{gnatbind}) + Generate list of @code{pragma Rerstrictions} that could be applied to + the current unit. This is useful for code audit purposes, and also may + be used to improve code generation in some cases. + + @end table + + @node Binding with Non-Ada Main Programs + @section Binding with Non-Ada Main Programs + + @noindent + In our description so far we have assumed that the main + program is in Ada, and that the task of the binder is to generate a + corresponding function @code{main} that invokes this Ada main + program. GNAT also supports the building of executable programs where + the main program is not in Ada, but some of the called routines are + written in Ada and compiled using GNAT (@pxref{Mixed Language Programming}). + The following switch is used in this situation: + + @table @code + @item -n + @cindex @code{-n} (@code{gnatbind}) + No main program. The main program is not in Ada. + @end table + + @noindent + In this case, most of the functions of the binder are still required, + but instead of generating a main program, the binder generates a file + containing the following callable routines: + + @table @code + @item adainit + @findex adainit + You must call this routine to initialize the Ada part of the program by + calling the necessary elaboration routines. A call to @code{adainit} is + required before the first call to an Ada subprogram. + + Note that it is assumed that the basic execution environment must be setup + to be appropriate for Ada execution at the point where the first Ada + subprogram is called. In particular, if the Ada code will do any + floating-point operations, then the FPU must be setup in an appropriate + manner. For the case of the x86, for example, full precision mode is + required. The procedure GNAT.Float_Control.Reset may be used to ensure + that the FPU is in the right state. + + @item adafinal + @findex adafinal + You must call this routine to perform any library-level finalization + required by the Ada subprograms. A call to @code{adafinal} is required + after the last call to an Ada subprogram, and before the program + terminates. + @end table + + @noindent + If the @code{-n} switch + @cindex Binder, multiple input files + is given, more than one ALI file may appear on + the command line for @code{gnatbind}. The normal @dfn{closure} + calculation is performed for each of the specified units. Calculating + the closure means finding out the set of units involved by tracing + @code{with} references. The reason it is necessary to be able to + specify more than one ALI file is that a given program may invoke two or + more quite separate groups of Ada units. + + The binder takes the name of its output file from the last specified ALI + file, unless overridden by the use of the @code{-o file}. + The output is an Ada unit in source form that can + be compiled with GNAT unless the -C switch is used in which case the + output is a C source file, which must be compiled using the C compiler. + This compilation occurs automatically as part of the @code{gnatlink} + processing. + + Currently the GNAT run time requires a FPU using 80 bits mode + precision. Under targets where this is not the default it is required to + call GNAT.Float_Control.Reset before using floating point numbers (this + include float computation, float input and output) in the Ada code. A + side effect is that this could be the wrong mode for the foreign code + where floating point computation could be broken after this call. + + @node Binding Programs with No Main Subprogram + @section Binding Programs with No Main Subprogram + + @noindent + It is possible to have an Ada program which does not have a main + subprogram. This program will call the elaboration routines of all the + packages, then the finalization routines. + + The following switch is used to bind programs organized in this manner: + + @table @code + @item -z + @cindex @code{-z} (@code{gnatbind}) + Normally the binder checks that the unit name given on the command line + corresponds to a suitable main subprogram. When this switch is used, + a list of ALI files can be given, and the execution of the program + consists of elaboration of these units in an appropriate order. + @end table + + @node Summary of Binder Switches + @section Summary of Binder Switches + + @noindent + The following are the switches available with @code{gnatbind}: + + @table @code + @item -aO + Specify directory to be searched for ALI files. + + @item -aI + Specify directory to be searched for source file. + + @item -A + Generate binder program in Ada (default) + + @item -b + Generate brief messages to @file{stderr} even if verbose mode set. + + @item -c + Check only, no generation of binder output file. + + @item -C + Generate binder program in C + + @item -e + Output complete list of elaboration-order dependencies. + + @item -E + Store tracebacks in exception occurrences when the target supports it. + This is the default with the zero cost exception mechanism. + This option is currently supported on the following targets: + all x86 ports, Solaris, Windows, HP-UX, AIX, PowerPC VxWorks and Alpha VxWorks. + See also the packages @code{GNAT.Traceback} and + @code{GNAT.Traceback.Symbolic} for more information. + Note that on x86 ports, you must not use @code{-fomit-frame-pointer} + @code{gcc} option. + + @item -h + Output usage (help) information + + @item -I + Specify directory to be searched for source and ALI files. + + @item -I- + Do not look for sources in the current directory where @code{gnatbind} was + invoked, and do not look for ALI files in the directory containing the + ALI file named in the @code{gnatbind} command line. + + @item -l + Output chosen elaboration order. + + @item -Lxxx + Binds the units for library building. In this case the adainit and + adafinal procedures (See @pxref{Binding with Non-Ada Main Programs}) + are renamed to xxxinit and xxxfinal. Implies -n. + See @pxref{GNAT and Libraries} for more details. + + @item -Mxyz + Rename generated main program from main to xyz + + @item -m@var{n} + Limit number of detected errors to @var{n} (1-999). + Furthermore, under Windows, the sources pointed to by the libraries path + set in the registry are not searched for. + + @item -n + No main program. + + @item -nostdinc + Do not look for sources in the system default directory. + + @item -nostdlib + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatbind}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -o @var{file} + Name the output file @var{file} (default is @file{b~@var{xxx}.adb}). + Note that if this option is used, then linking must be done manually, + gnatlink cannot be used. + + @item -O + Output object list. + + @item -p + Pessimistic (worst-case) elaboration order + + @item -s + Require all source files to be present. + + @item -static + Link against a static GNAT run time. + + @item -shared + Link against a shared GNAT run time when available. + + @item -t + Tolerate time stamp and other consistency errors + + @item -T@var{n} + Set the time slice value to n microseconds. A value of zero means no time + slicing and also indicates to the tasking run time to match as close as + possible to the annex D requirements of the RM. + + @item -v + Verbose mode. Write error messages, header, summary output to + @file{stdout}. + + @item -w@var{x} + Warning mode (@var{x}=s/e for suppress/treat as error) + + + @item -x + Exclude source files (check object consistency only). + + + @item -z + No main subprogram. + + @end table + + You may obtain this listing by running the program @code{gnatbind} with + no arguments. + + @node Command-Line Access + @section Command-Line Access + + @noindent + The package @code{Ada.Command_Line} provides access to the command-line + arguments and program name. In order for this interface to operate + correctly, the two variables + + @smallexample + @group + @cartouche + int gnat_argc; + char **gnat_argv; + @end cartouche + @end group + @end smallexample + + @noindent + @findex gnat_argv + @findex gnat_argc + are declared in one of the GNAT library routines. These variables must + be set from the actual @code{argc} and @code{argv} values passed to the + main program. With no @code{n} present, @code{gnatbind} + generates the C main program to automatically set these variables. + If the @code{n} switch is used, there is no automatic way to + set these variables. If they are not set, the procedures in + @code{Ada.Command_Line} will not be available, and any attempt to use + them will raise @code{Constraint_Error}. If command line access is + required, your main program must set @code{gnat_argc} and + @code{gnat_argv} from the @code{argc} and @code{argv} values passed to + it. + + @node Search Paths for gnatbind + @section Search Paths for @code{gnatbind} + + @noindent + The binder takes the name of an ALI file as its argument and needs to + locate source files as well as other ALI files to verify object consistency. + + For source files, it follows exactly the same search rules as @code{gcc} + (@pxref{Search Paths and the Run-Time Library (RTL)}). For ALI files the + directories searched are: + + @enumerate + @item + The directory containing the ALI file named in the command line, unless + the switch @code{-I-} is specified. + + @item + All directories specified by @code{-I} + switches on the @code{gnatbind} + command line, in the order given. + + @item + @findex ADA_OBJECTS_PATH + Each of the directories listed in the value of the + @code{ADA_OBJECTS_PATH} environment variable. + Construct this value + exactly as the @code{PATH} environment variable: a list of directory + names separated by colons (semicolons when working with the NT version + of GNAT). + + @item + The content of the "ada_object_path" file which is part of the GNAT + installation tree and is used to store standard libraries such as the + GNAT Run Time Library (RTL) unless the switch @code{-nostdlib} is + specified. + @ref{Installing an Ada Library} + @end enumerate + + @noindent + In the binder the switch @code{-I} + is used to specify both source and + library file paths. Use @code{-aI} + instead if you want to specify + source paths only, and @code{-aO} + if you want to specify library paths + only. This means that for the binder + @code{-I}@var{dir} is equivalent to + @code{-aI}@var{dir} + @code{-aO}@var{dir}. + The binder generates the bind file (a C language source file) in the + current working directory. + + @findex Ada + @findex System + @findex Interfaces + @findex GNAT + The packages @code{Ada}, @code{System}, and @code{Interfaces} and their + children make up the GNAT Run-Time Library, together with the package + GNAT and its children, which contain a set of useful additional + library functions provided by GNAT. The sources for these units are + needed by the compiler and are kept together in one directory. The ALI + files and object files generated by compiling the RTL are needed by the + binder and the linker and are kept together in one directory, typically + different from the directory containing the sources. In a normal + installation, you need not specify these directory names when compiling + or binding. Either the environment variables or the built-in defaults + cause these files to be found. + + Besides simplifying access to the RTL, a major use of search paths is + in compiling sources from multiple directories. This can make + development environments much more flexible. + + @node Examples of gnatbind Usage + @section Examples of @code{gnatbind} Usage + + @noindent + This section contains a number of examples of using the GNAT binding + utility @code{gnatbind}. + + @table @code + @item gnatbind hello + The main program @code{Hello} (source program in @file{hello.adb}) is + bound using the standard switch settings. The generated main program is + @file{b~hello.adb}. This is the normal, default use of the binder. + + @item gnatbind hello -o mainprog.adb + The main program @code{Hello} (source program in @file{hello.adb}) is + bound using the standard switch settings. The generated main program is + @file{mainprog.adb} with the associated spec in + @file{mainprog.ads}. Note that you must specify the body here not the + spec, in the case where the output is in Ada. Note that if this option + is used, then linking must be done manually, since gnatlink will not + be able to find the generated file. + + @item gnatbind main -C -o mainprog.c -x + The main program @code{Main} (source program in + @file{main.adb}) is bound, excluding source files from the + consistency checking, generating + the file @file{mainprog.c}. + + @item gnatbind -x main_program -C -o mainprog.c + This command is exactly the same as the previous example. Switches may + appear anywhere in the command line, and single letter switches may be + combined into a single switch. + + @item gnatbind -n math dbase -C -o ada-control.c + The main program is in a language other than Ada, but calls to + subprograms in packages @code{Math} and @code{Dbase} appear. This call + to @code{gnatbind} generates the file @file{ada-control.c} containing + the @code{adainit} and @code{adafinal} routines to be called before and + after accessing the Ada units. + @end table + + @node Linking Using gnatlink + @chapter Linking Using @code{gnatlink} + @findex gnatlink + + @noindent + This chapter discusses @code{gnatlink}, a utility program used to link + Ada programs and build an executable file. This is a simple program + that invokes the Unix linker (via the @code{gcc} + command) with a correct list of object files and library references. + @code{gnatlink} automatically determines the list of files and + references for the Ada part of a program. It uses the binder file + generated by the binder to determine this list. + + @menu + * Running gnatlink:: + * Switches for gnatlink:: + * Setting Stack Size from gnatlink:: + * Setting Heap Size from gnatlink:: + @end menu + + @node Running gnatlink + @section Running @code{gnatlink} + + @noindent + The form of the @code{gnatlink} command is + + @smallexample + $ gnatlink [@var{switches}] @var{mainprog}[.ali] [@var{non-Ada objects}] + [@var{linker options}] + @end smallexample + + @noindent + @file{@var{mainprog}.ali} references the ALI file of the main program. + The @file{.ali} extension of this file can be omitted. From this + reference, @code{gnatlink} locates the corresponding binder file + @file{b~@var{mainprog}.adb} and, using the information in this file along + with the list of non-Ada objects and linker options, constructs a Unix + linker command file to create the executable. + + The arguments following @file{@var{mainprog}.ali} are passed to the + linker uninterpreted. They typically include the names of object files + for units written in other languages than Ada and any library references + required to resolve references in any of these foreign language units, + or in @code{pragma Import} statements in any Ada units. + + @var{linker options} is an optional list of linker specific + switches. The default linker called by gnatlink is @var{gcc} which in + turn calls the appropriate system linker usually called + @var{ld}. Standard options for the linker such as @code{-lmy_lib} or + @code{-Ldir} can be added as is. For options that are not recognized by + @var{gcc} as linker options, the @var{gcc} switches @code{-Xlinker} or + @code{-Wl,} shall be used. Refer to the GCC documentation for + details. Here is an example showing how to generate a linker map + assuming that the underlying linker is GNU ld: + + @smallexample + $ gnatlink my_prog -Wl,-Map,MAPFILE + @end smallexample + + Using @var{linker options} it is possible to set the program stack and + heap size. See @pxref{Setting Stack Size from gnatlink} and + @pxref{Setting Heap Size from gnatlink}. + + @code{gnatlink} determines the list of objects required by the Ada + program and prepends them to the list of objects passed to the linker. + @code{gnatlink} also gathers any arguments set by the use of + @code{pragma Linker_Options} and adds them to the list of arguments + presented to the linker. + + + @node Switches for gnatlink + @section Switches for @code{gnatlink} + + @noindent + The following switches are available with the @code{gnatlink} utility: + + @table @code + + @item -A + @cindex @code{-A} (@code{gnatlink}) + The binder has generated code in Ada. This is the default. + + @item -C + @cindex @code{-C} (@code{gnatlink}) + If instead of generating a file in Ada, the binder has generated one in + C, then the linker needs to know about it. Use this switch to signal + to @code{gnatlink} that the binder has generated C code rather than + Ada code. + + @item -f + @cindex Command line length + @cindex @code{-f} (@code{gnatlink}) + On some targets, the command line length is limited, and @code{gnatlink} + will generate a separate file for the linker if the list of object files + is too long. The @code{-f} flag forces this file to be generated even if + the limit is not exceeded. This is useful in some cases to deal with + special situations where the command line length is exceeded. + + @item -g + @cindex Debugging information, including + @cindex @code{-g} (@code{gnatlink}) + The option to include debugging information causes the Ada bind file (in + other words, @file{b~@var{mainprog}.adb}) to be compiled with + @code{-g}. + In addition, the binder does not delete the @file{b~@var{mainprog}.adb}, + @file{b~@var{mainprog}.o} and @file{b~@var{mainprog}.ali} files. + Without @code{-g}, the binder removes these files by + default. The same procedure apply if a C bind file was generated using + @code{-C} @code{gnatbind} option, in this case the filenames are + @file{b_@var{mainprog}.c} and @file{b_@var{mainprog}.o}. + + @item -n + @cindex @code{-n} (@code{gnatlink}) + Do not compile the file generated by the binder. This may be used when + a link is rerun with different options, but there is no need to recompile + the binder file. + + @item -v + @cindex @code{-v} (@code{gnatlink}) + Causes additional information to be output, including a full list of the + included object files. This switch option is most useful when you want + to see what set of object files are being used in the link step. + + @item -v -v + @cindex @code{-v -v} (@code{gnatlink}) + Very verbose mode. Requests that the compiler operate in verbose mode when + it compiles the binder file, and that the system linker run in verbose mode. + + @item -o @var{exec-name} + @cindex @code{-o} (@code{gnatlink}) + @var{exec-name} specifies an alternate name for the generated + executable program. If this switch is omitted, the executable has the same + name as the main unit. For example, @code{gnatlink try.ali} creates + an executable called @file{try}. + + @item -b @var{target} + @cindex @code{-b} (@code{gnatlink}) + Compile your program to run on @var{target}, which is the name of a + system configuration. You must have a GNAT cross-compiler built if + @var{target} is not the same as your host system. + + @item -B@var{dir} + @cindex @code{-B} (@code{gnatlink}) + Load compiler executables (for example, @code{gnat1}, the Ada compiler) + from @var{dir} instead of the default location. Only use this switch + when multiple versions of the GNAT compiler are available. See the + @code{gcc} manual page for further details. You would normally use the + @code{-b} or @code{-V} switch instead. + + @item --GCC=@var{compiler_name} + @cindex @code{--GCC=compiler_name} (@code{gnatlink}) + Program used for compiling the binder file. The default is + `@code{gcc}'. You need to use quotes around @var{compiler_name} if + @code{compiler_name} contains spaces or other separator characters. As + an example @code{--GCC="foo -x -y"} will instruct @code{gnatlink} to use + @code{foo -x -y} as your compiler. Note that switch @code{-c} is always + inserted after your command name. Thus in the above example the compiler + command that will be used by @code{gnatlink} will be @code{foo -c -x -y}. + If several @code{--GCC=compiler_name} are used, only the last + @var{compiler_name} is taken into account. However, all the additional + switches are also taken into account. Thus, + @code{--GCC="foo -x -y" --GCC="bar -z -t"} is equivalent to + @code{--GCC="bar -x -y -z -t"}. + + @item --LINK=@var{name} + @cindex @code{--LINK=} (@code{gnatlink}) + @var{name} is the name of the linker to be invoked. This is especially + useful in mixed language programs since languages such as c++ require + their own linker to be used. When this switch is omitted, the default + name for the linker is (@file{gcc}). When this switch is used, the + specified linker is called instead of (@file{gcc}) with exactly the same + parameters that would have been passed to (@file{gcc}) so if the desired + linker requires different parameters it is necessary to use a wrapper + script that massages the parameters before invoking the real linker. It + may be useful to control the exact invocation by using the verbose + switch. + + + + @end table + + @node Setting Stack Size from gnatlink + @section Setting Stack Size from @code{gnatlink} + + @noindent + It is possible to specify the program stack size from @code{gnatlink}. + Assuming that the underlying linker is GNU ld there is two ways to do so: + + @itemize @bullet + + @item using @code{-Xlinker} linker option + + @smallexample + $ gnatlink hello -Xlinker --stack=0x10000,0x1000 + @end smallexample + + This set the stack reserve size to 0x10000 bytes and the stack commit + size to 0x1000 bytes. + + @item using @code{-Wl} linker option + + @smallexample + $ gnatlink hello -Wl,--stack=0x1000000 + @end smallexample + + This set the stack reserve size to 0x1000000 bytes. Note that with + @code{-Wl} option it is not possible to set the stack commit size + because the coma is a separator for this option. + + @end itemize + + @node Setting Heap Size from gnatlink + @section Setting Heap Size from @code{gnatlink} + + @noindent + It is possible to specify the program heap size from @code{gnatlink}. + Assuming that the underlying linker is GNU ld there is two ways to do so: + + @itemize @bullet + + @item using @code{-Xlinker} linker option + + @smallexample + $ gnatlink hello -Xlinker --heap=0x10000,0x1000 + @end smallexample + + This set the heap reserve size to 0x10000 bytes and the heap commit + size to 0x1000 bytes. + + @item using @code{-Wl} linker option + + @smallexample + $ gnatlink hello -Wl,--heap=0x1000000 + @end smallexample + + This set the heap reserve size to 0x1000000 bytes. Note that with + @code{-Wl} option it is not possible to set the heap commit size + because the coma is a separator for this option. + + @end itemize + + @node The GNAT Make Program gnatmake + @chapter The GNAT Make Program @code{gnatmake} + @findex gnatmake + + @menu + * Running gnatmake:: + * Switches for gnatmake:: + * Mode Switches for gnatmake:: + * Notes on the Command Line:: + * How gnatmake Works:: + * Examples of gnatmake Usage:: + @end menu + @noindent + A typical development cycle when working on an Ada program consists of + the following steps: + + @enumerate + @item + Edit some sources to fix bugs. + + @item + Add enhancements. + + @item + Compile all sources affected. + + @item + Rebind and relink. + + @item + Test. + @end enumerate + + @noindent + The third step can be tricky, because not only do the modified files + @cindex Dependency rules + have to be compiled, but any files depending on these files must also be + recompiled. The dependency rules in Ada can be quite complex, especially + in the presence of overloading, @code{use} clauses, generics and inlined + subprograms. + + @code{gnatmake} automatically takes care of the third and fourth steps + of this process. It determines which sources need to be compiled, + compiles them, and binds and links the resulting object files. + + Unlike some other Ada make programs, the dependencies are always + accurately recomputed from the new sources. The source based approach of + the GNAT compilation model makes this possible. This means that if + changes to the source program cause corresponding changes in + dependencies, they will always be tracked exactly correctly by + @code{gnatmake}. + + @node Running gnatmake + @section Running @code{gnatmake} + + @noindent + The usual form of the @code{gnatmake} command is + + @smallexample + $ gnatmake [@var{switches}] @var{file_name} [@var{file_names}] [@var{mode_switches}] + @end smallexample + + @noindent + The only required argument is one @var{file_name}, which specifies + a compilation unit that is a main program. Several @var{file_names} can be + specified: this will result in several executables being built. + If @code{switches} are present, they can be placed before the first + @var{file_name}, between @var{file_names} or after the last @var{file_name}. + If @var{mode_switches} are present, they must always be placed after + the last @var{file_name} and all @code{switches}. + + If you are using standard file extensions (.adb and .ads), then the + extension may be omitted from the @var{file_name} arguments. However, if + you are using non-standard extensions, then it is required that the + extension be given. A relative or absolute directory path can be + specified in a @var{file_name}, in which case, the input source file will + be searched for in the specified directory only. Otherwise, the input + source file will first be searched in the directory where + @code{gnatmake} was invoked and if it is not found, it will be search on + the source path of the compiler as described in + @ref{Search Paths and the Run-Time Library (RTL)}. + + When several @var{file_names} are specified, if an executable needs to be + rebuilt and relinked, all subsequent executables will be rebuilt and + relinked, even if this would not be absolutely necessary. + + All @code{gnatmake} output (except when you specify + @code{-M}) is to + @file{stderr}. The output produced by the + @code{-M} switch is send to + @file{stdout}. + + @node Switches for gnatmake + @section Switches for @code{gnatmake} + + @noindent + You may specify any of the following switches to @code{gnatmake}: + + @table @code + @item --GCC=@var{compiler_name} + @cindex @code{--GCC=compiler_name} (@code{gnatmake}) + Program used for compiling. The default is `@code{gcc}'. You need to use + quotes around @var{compiler_name} if @code{compiler_name} contains + spaces or other separator characters. As an example @code{--GCC="foo -x + -y"} will instruct @code{gnatmake} to use @code{foo -x -y} as your + compiler. Note that switch @code{-c} is always inserted after your + command name. Thus in the above example the compiler command that will + be used by @code{gnatmake} will be @code{foo -c -x -y}. + If several @code{--GCC=compiler_name} are used, only the last + @var{compiler_name} is taken into account. However, all the additional + switches are also taken into account. Thus, + @code{--GCC="foo -x -y" --GCC="bar -z -t"} is equivalent to + @code{--GCC="bar -x -y -z -t"}. + + @item --GNATBIND=@var{binder_name} + @cindex @code{--GNATBIND=binder_name} (@code{gnatmake}) + Program used for binding. The default is `@code{gnatbind}'. You need to + use quotes around @var{binder_name} if @var{binder_name} contains spaces + or other separator characters. As an example @code{--GNATBIND="bar -x + -y"} will instruct @code{gnatmake} to use @code{bar -x -y} as your + binder. Binder switches that are normally appended by @code{gnatmake} to + `@code{gnatbind}' are now appended to the end of @code{bar -x -y}. + + @item --GNATLINK=@var{linker_name} + @cindex @code{--GNATLINK=linker_name} (@code{gnatmake}) + Program used for linking. The default is `@code{gnatlink}'. You need to + use quotes around @var{linker_name} if @var{linker_name} contains spaces + or other separator characters. As an example @code{--GNATLINK="lan -x + -y"} will instruct @code{gnatmake} to use @code{lan -x -y} as your + linker. Linker switches that are normally appended by @code{gnatmake} to + `@code{gnatlink}' are now appended to the end of @code{lan -x -y}. + + + @item -a + @cindex @code{-a} (@code{gnatmake}) + Consider all files in the make process, even the GNAT internal system + files (for example, the predefined Ada library files), as well as any + locked files. Locked files are files whose ALI file is write-protected. + By default, + @code{gnatmake} does not check these files, + because the assumption is that the GNAT internal files are properly up + to date, and also that any write protected ALI files have been properly + installed. Note that if there is an installation problem, such that one + of these files is not up to date, it will be properly caught by the + binder. + You may have to specify this switch if you are working on GNAT + itself. @code{-a} is also useful in conjunction with + @code{-f} + if you need to recompile an entire application, + including run-time files, using special configuration pragma settings, + such as a non-standard @code{Float_Representation} pragma. + By default + @code{gnatmake -a} compiles all GNAT + internal files with + @code{gcc -c -gnatpg} rather than @code{gcc -c}. + + @item -b + @cindex @code{-b} (@code{gnatmake}) + Bind only. Can be combined with @code{-c} to do compilation + and binding, but no link. Can be combined with @code{-l} + to do binding and linking. When not combined with @code{-c} + all the units in the closure of the main program must have been previously + compiled and must be up to date. The root unit specified by @var{file_name} + may be given without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + @item -c + @cindex @code{-c} (@code{gnatmake}) + Compile only. Do not perform binding, except when @code{-b} + is also specified. Do not perform linking, except if both + @code{-b} and + @code{-l} are also specified. + If the root unit specified by @var{file_name} is not a main unit, this is the + default. Otherwise @code{gnatmake} will attempt binding and linking + unless all objects are up to date and the executable is more recent than + the objects. + + @item -C + @cindex @code{-C} (@code{gnatmake}) + Use a mapping file. A mapping file is a way to communicate to the compiler + two mappings: from unit names to file names (without any directory information) + and from file names to path names (with full directory information). + These mappings are used by the compiler to short-circuit the path search. + When @code{gnatmake} is invoked with this switch, it will create a mapping + file, initially populated by the project manager, if @code{-P} is used, + otherwise initially empty. Each invocation of the compiler will add the newly + accessed sources to the mapping file. This will improve the source search + during the next invocation of the compiler. + + @item -f + @cindex @code{-f} (@code{gnatmake}) + Force recompilations. Recompile all sources, even though some object + files may be up to date, but don't recompile predefined or GNAT internal + files or locked files (files with a write-protected ALI file), + unless the @code{-a} switch is also specified. + + @item + @item -i + @cindex @code{-i} (@code{gnatmake}) + In normal mode, @code{gnatmake} compiles all object files and ALI files + into the current directory. If the @code{-i} switch is used, + then instead object files and ALI files that already exist are overwritten + in place. This means that once a large project is organized into separate + directories in the desired manner, then @code{gnatmake} will automatically + maintain and update this organization. If no ALI files are found on the + Ada object path (@ref{Search Paths and the Run-Time Library (RTL)}), + the new object and ALI files are created in the + directory containing the source being compiled. If another organization + is desired, where objects and sources are kept in different directories, + a useful technique is to create dummy ALI files in the desired directories. + When detecting such a dummy file, @code{gnatmake} will be forced to recompile + the corresponding source file, and it will be put the resulting object + and ALI files in the directory where it found the dummy file. + + @item -j@var{n} + @cindex @code{-j} (@code{gnatmake}) + @cindex Parallel make + Use @var{n} processes to carry out the (re)compilations. On a + multiprocessor machine compilations will occur in parallel. In the + event of compilation errors, messages from various compilations might + get interspersed (but @code{gnatmake} will give you the full ordered + list of failing compiles at the end). If this is problematic, rerun + the make process with n set to 1 to get a clean list of messages. + + @item -k + @cindex @code{-k} (@code{gnatmake}) + Keep going. Continue as much as possible after a compilation error. To + ease the programmer's task in case of compilation errors, the list of + sources for which the compile fails is given when @code{gnatmake} + terminates. + + If @code{gnatmake} is invoked with several @file{file_names} and with this + switch, if there are compilation errors when building an executable, + @code{gnatmake} will not attempt to build the following executables. + + @item -l + @cindex @code{-l} (@code{gnatmake}) + Link only. Can be combined with @code{-b} to binding + and linking. Linking will not be performed if combined with + @code{-c} + but not with @code{-b}. + When not combined with @code{-b} + all the units in the closure of the main program must have been previously + compiled and must be up to date, and the main program need to have been bound. + The root unit specified by @var{file_name} + may be given without extension, with the source extension or, if no GNAT + Project File is specified, with the ALI file extension. + + @item -m + @cindex @code{-m} (@code{gnatmake}) + Specifies that the minimum necessary amount of recompilations + be performed. In this mode @code{gnatmake} ignores time + stamp differences when the only + modifications to a source file consist in adding/removing comments, + empty lines, spaces or tabs. This means that if you have changed the + comments in a source file or have simply reformatted it, using this + switch will tell gnatmake not to recompile files that depend on it + (provided other sources on which these files depend have undergone no + semantic modifications). Note that the debugging information may be + out of date with respect to the sources if the @code{-m} switch causes + a compilation to be switched, so the use of this switch represents a + trade-off between compilation time and accurate debugging information. + + @item -M + @cindex Dependencies, producing list + @cindex @code{-M} (@code{gnatmake}) + Check if all objects are up to date. If they are, output the object + dependences to @file{stdout} in a form that can be directly exploited in + a @file{Makefile}. By default, each source file is prefixed with its + (relative or absolute) directory name. This name is whatever you + specified in the various @code{-aI} + and @code{-I} switches. If you use + @code{gnatmake -M} + @code{-q} + (see below), only the source file names, + without relative paths, are output. If you just specify the + @code{-M} + switch, dependencies of the GNAT internal system files are omitted. This + is typically what you want. If you also specify + the @code{-a} switch, + dependencies of the GNAT internal files are also listed. Note that + dependencies of the objects in external Ada libraries (see switch + @code{-aL}@var{dir} in the following list) are never reported. + + @item -n + @cindex @code{-n} (@code{gnatmake}) + Don't compile, bind, or link. Checks if all objects are up to date. + If they are not, the full name of the first file that needs to be + recompiled is printed. + Repeated use of this option, followed by compiling the indicated source + file, will eventually result in recompiling all required units. + + @item -o @var{exec_name} + @cindex @code{-o} (@code{gnatmake}) + Output executable name. The name of the final executable program will be + @var{exec_name}. If the @code{-o} switch is omitted the default + name for the executable will be the name of the input file in appropriate form + for an executable file on the host system. + + This switch cannot be used when invoking @code{gnatmake} with several + @file{file_names}. + + @item -q + @cindex @code{-q} (@code{gnatmake}) + Quiet. When this flag is not set, the commands carried out by + @code{gnatmake} are displayed. + + @item -s + @cindex @code{-s} (@code{gnatmake}) + Recompile if compiler switches have changed since last compilation. + All compiler switches but -I and -o are taken into account in the + following way: + orders between different ``first letter'' switches are ignored, but + orders between same switches are taken into account. For example, + @code{-O -O2} is different than @code{-O2 -O}, but @code{-g -O} is equivalent + to @code{-O -g}. + + @item -u + @cindex @code{-u} (@code{gnatmake}) + Unique. Recompile at most the main file. It implies -c. Combined with + -f, it is equivalent to calling the compiler directly. + + @item -v + @cindex @code{-v} (@code{gnatmake}) + Verbose. Displays the reason for all recompilations @code{gnatmake} + decides are necessary. + + @item -z + @cindex @code{-z} (@code{gnatmake}) + No main subprogram. Bind and link the program even if the unit name + given on the command line is a package name. The resulting executable + will execute the elaboration routines of the package and its closure, + then the finalization routines. + + @item @code{gcc} @asis{switches} + The switch @code{-g} or any uppercase switch (other than @code{-A}, + @code{-L} or + @code{-S}) or any switch that is more than one character is passed to + @code{gcc} (e.g. @code{-O}, @option{-gnato,} etc.) + @end table + + @noindent + Source and library search path switches: + + @table @code + @item -aI@var{dir} + @cindex @code{-aI} (@code{gnatmake}) + When looking for source files also look in directory @var{dir}. + The order in which source files search is undertaken is + described in @ref{Search Paths and the Run-Time Library (RTL)}. + + @item -aL@var{dir} + @cindex @code{-aL} (@code{gnatmake}) + Consider @var{dir} as being an externally provided Ada library. + Instructs @code{gnatmake} to skip compilation units whose @file{.ali} + files have been located in directory @var{dir}. This allows you to have + missing bodies for the units in @var{dir} and to ignore out of date bodies + for the same units. You still need to specify + the location of the specs for these units by using the switches + @code{-aI@var{dir}} + or @code{-I@var{dir}}. + Note: this switch is provided for compatibility with previous versions + of @code{gnatmake}. The easier method of causing standard libraries + to be excluded from consideration is to write-protect the corresponding + ALI files. + + @item -aO@var{dir} + @cindex @code{-aO} (@code{gnatmake}) + When searching for library and object files, look in directory + @var{dir}. The order in which library files are searched is described in + @ref{Search Paths for gnatbind}. + + @item -A@var{dir} + @cindex Search paths, for @code{gnatmake} + @cindex @code{-A} (@code{gnatmake}) + Equivalent to @code{-aL@var{dir} + -aI@var{dir}}. + + @item -I@var{dir} + @cindex @code{-I} (@code{gnatmake}) + Equivalent to @code{-aO@var{dir} + -aI@var{dir}}. + + @item -I- + @cindex @code{-I-} (@code{gnatmake}) + @cindex Source files, suppressing search + Do not look for source files in the directory containing the source + file named in the command line. + Do not look for ALI or object files in the directory + where @code{gnatmake} was invoked. + + @item -L@var{dir} + @cindex @code{-L} (@code{gnatmake}) + @cindex Linker libraries + Add directory @var{dir} to the list of directories in which the linker + Furthermore, under Windows, the sources pointed to by the libraries path + set in the registry are not searched for. + will search for libraries. This is equivalent to + @code{-largs -L}@var{dir}. + + @item -nostdinc + @cindex @code{-nostdinc} (@code{gnatmake}) + Do not look for source files in the system default directory. + + @item -nostdlib + @cindex @code{-nostdlib} (@code{gnatmake}) + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatmake}) + Specifies the default location of the runtime library. We look for the runtime + in the following directories, and stop as soon as a valid runtime is found + ("adainclude" or "ada_source_path", and "adalib" or "ada_object_path" present): + + @itemize @bullet + @item /$rts_path + + @item /$rts_path + + @item /rts-$rts_path + @end itemize + + @noindent + The selected path is handled like a normal RTS path. + + @end table + + @node Mode Switches for gnatmake + @section Mode Switches for @code{gnatmake} + + @noindent + The mode switches (referred to as @code{mode_switches}) allow the + inclusion of switches that are to be passed to the compiler itself, the + binder or the linker. The effect of a mode switch is to cause all + subsequent switches up to the end of the switch list, or up to the next + mode switch, to be interpreted as switches to be passed on to the + designated component of GNAT. + + @table @code + @item -cargs @var{switches} + @cindex @code{-cargs} (@code{gnatmake}) + Compiler switches. Here @var{switches} is a list of switches + that are valid switches for @code{gcc}. They will be passed on to + all compile steps performed by @code{gnatmake}. + + @item -bargs @var{switches} + @cindex @code{-bargs} (@code{gnatmake}) + Binder switches. Here @var{switches} is a list of switches + that are valid switches for @code{gcc}. They will be passed on to + all bind steps performed by @code{gnatmake}. + + @item -largs @var{switches} + @cindex @code{-largs} (@code{gnatmake}) + Linker switches. Here @var{switches} is a list of switches + that are valid switches for @code{gcc}. They will be passed on to + all link steps performed by @code{gnatmake}. + @end table + + @node Notes on the Command Line + @section Notes on the Command Line + + @noindent + This section contains some additional useful notes on the operation + of the @code{gnatmake} command. + + @itemize @bullet + @item + @cindex Recompilation, by @code{gnatmake} + If @code{gnatmake} finds no ALI files, it recompiles the main program + and all other units required by the main program. + This means that @code{gnatmake} + can be used for the initial compile, as well as during subsequent steps of + the development cycle. + + @item + If you enter @code{gnatmake @var{file}.adb}, where @file{@var{file}.adb} + is a subunit or body of a generic unit, @code{gnatmake} recompiles + @file{@var{file}.adb} (because it finds no ALI) and stops, issuing a + warning. + + @item + In @code{gnatmake} the switch @code{-I} + is used to specify both source and + library file paths. Use @code{-aI} + instead if you just want to specify + source paths only and @code{-aO} + if you want to specify library paths + only. + + @item + @code{gnatmake} examines both an ALI file and its corresponding object file + for consistency. If an ALI is more recent than its corresponding object, + or if the object file is missing, the corresponding source will be recompiled. + Note that @code{gnatmake} expects an ALI and the corresponding object file + to be in the same directory. + + @item + @code{gnatmake} will ignore any files whose ALI file is write-protected. + This may conveniently be used to exclude standard libraries from + consideration and in particular it means that the use of the + @code{-f} switch will not recompile these files + unless @code{-a} is also specified. + + @item + @code{gnatmake} has been designed to make the use of Ada libraries + particularly convenient. Assume you have an Ada library organized + as follows: @var{obj-dir} contains the objects and ALI files for + of your Ada compilation units, + whereas @var{include-dir} contains the + specs of these units, but no bodies. Then to compile a unit + stored in @code{main.adb}, which uses this Ada library you would just type + + @smallexample + $ gnatmake -aI@var{include-dir} -aL@var{obj-dir} main + @end smallexample + + @item + Using @code{gnatmake} along with the + @code{-m (minimal recompilation)} + switch provides a mechanism for avoiding unnecessary rcompilations. Using + this switch, + you can update the comments/format of your + source files without having to recompile everything. Note, however, that + adding or deleting lines in a source files may render its debugging + info obsolete. If the file in question is a spec, the impact is rather + limited, as that debugging info will only be useful during the + elaboration phase of your program. For bodies the impact can be more + significant. In all events, your debugger will warn you if a source file + is more recent than the corresponding object, and alert you to the fact + that the debugging information may be out of date. + @end itemize + + @node How gnatmake Works + @section How @code{gnatmake} Works + + @noindent + Generally @code{gnatmake} automatically performs all necessary + recompilations and you don't need to worry about how it works. However, + it may be useful to have some basic understanding of the @code{gnatmake} + approach and in particular to understand how it uses the results of + previous compilations without incorrectly depending on them. + + First a definition: an object file is considered @dfn{up to date} if the + corresponding ALI file exists and its time stamp predates that of the + object file and if all the source files listed in the + dependency section of this ALI file have time stamps matching those in + the ALI file. This means that neither the source file itself nor any + files that it depends on have been modified, and hence there is no need + to recompile this file. + + @code{gnatmake} works by first checking if the specified main unit is up + to date. If so, no compilations are required for the main unit. If not, + @code{gnatmake} compiles the main program to build a new ALI file that + reflects the latest sources. Then the ALI file of the main unit is + examined to find all the source files on which the main program depends, + and @code{gnatmake} recursively applies the above procedure on all these files. + + This process ensures that @code{gnatmake} only trusts the dependencies + in an existing ALI file if they are known to be correct. Otherwise it + always recompiles to determine a new, guaranteed accurate set of + dependencies. As a result the program is compiled "upside down" from what may + be more familiar as the required order of compilation in some other Ada + systems. In particular, clients are compiled before the units on which + they depend. The ability of GNAT to compile in any order is critical in + allowing an order of compilation to be chosen that guarantees that + @code{gnatmake} will recompute a correct set of new dependencies if + necessary. + + When invoking @code{gnatmake} with several @var{file_names}, if a unit is + imported by several of the executables, it will be recompiled at most once. + + @node Examples of gnatmake Usage + @section Examples of @code{gnatmake} Usage + + @table @code + @item gnatmake hello.adb + Compile all files necessary to bind and link the main program + @file{hello.adb} (containing unit @code{Hello}) and bind and link the + resulting object files to generate an executable file @file{hello}. + + @item gnatmake main1 main2 main3 + Compile all files necessary to bind and link the main programs + @file{main1.adb} (containing unit @code{Main1}), @file{main2.adb} + (containing unit @code{Main2}) and @file{main3.adb} + (containing unit @code{Main3}) and bind and link the resulting object files + to generate three executable files @file{main1}, + @file{main2} + and @file{main3}. + + @item gnatmake -q Main_Unit -cargs -O2 -bargs -l + + Compile all files necessary to bind and link the main program unit + @code{Main_Unit} (from file @file{main_unit.adb}). All compilations will + be done with optimization level 2 and the order of elaboration will be + listed by the binder. @code{gnatmake} will operate in quiet mode, not + displaying commands it is executing. + @end table + + @node Renaming Files Using gnatchop + @chapter Renaming Files Using @code{gnatchop} + @findex gnatchop + + @noindent + This chapter discusses how to handle files with multiple units by using + the @code{gnatchop} utility. This utility is also useful in renaming + files to meet the standard GNAT default file naming conventions. + + @menu + * Handling Files with Multiple Units:: + * Operating gnatchop in Compilation Mode:: + * Command Line for gnatchop:: + * Switches for gnatchop:: + * Examples of gnatchop Usage:: + @end menu + + @node Handling Files with Multiple Units + @section Handling Files with Multiple Units + + @noindent + The basic compilation model of GNAT requires that a file submitted to the + compiler have only one unit and there be a strict correspondence + between the file name and the unit name. + + The @code{gnatchop} utility allows both of these rules to be relaxed, + allowing GNAT to process files which contain multiple compilation units + and files with arbitrary file names. @code{gnatchop} + reads the specified file and generates one or more output files, + containing one unit per file. The unit and the file name correspond, + as required by GNAT. + + If you want to permanently restructure a set of "foreign" files so that + they match the GNAT rules, and do the remaining development using the + GNAT structure, you can simply use @code{gnatchop} once, generate the + new set of files and work with them from that point on. + + Alternatively, if you want to keep your files in the "foreign" format, + perhaps to maintain compatibility with some other Ada compilation + system, you can set up a procedure where you use @code{gnatchop} each + time you compile, regarding the source files that it writes as temporary + files that you throw away. + + @node Operating gnatchop in Compilation Mode + @section Operating gnatchop in Compilation Mode + + @noindent + The basic function of @code{gnatchop} is to take a file with multiple units + and split it into separate files. The boundary between files is reasonably + clear, except for the issue of comments and pragmas. In default mode, the + rule is that any pragmas between units belong to the previous unit, except + that configuration pragmas always belong to the following unit. Any comments + belong to the following unit. These rules + almost always result in the right choice of + the split point without needing to mark it explicitly and most users will + find this default to be what they want. In this default mode it is incorrect to + submit a file containing only configuration pragmas, or one that ends in + configuration pragmas, to @code{gnatchop}. + + However, using a special option to activate "compilation mode", + @code{gnatchop} + can perform another function, which is to provide exactly the semantics + required by the RM for handling of configuration pragmas in a compilation. + In the absence of configuration pragmas (at the main file level), this + option has no effect, but it causes such configuration pragmas to be handled + in a quite different manner. + + First, in compilation mode, if @code{gnatchop} is given a file that consists of + only configuration pragmas, then this file is appended to the + @file{gnat.adc} file in the current directory. This behavior provides + the required behavior described in the RM for the actions to be taken + on submitting such a file to the compiler, namely that these pragmas + should apply to all subsequent compilations in the same compilation + environment. Using GNAT, the current directory, possibly containing a + @file{gnat.adc} file is the representation + of a compilation environment. For more information on the + @file{gnat.adc} file, see the section on handling of configuration + pragmas @pxref{Handling of Configuration Pragmas}. + + Second, in compilation mode, if @code{gnatchop} + is given a file that starts with + configuration pragmas, and contains one or more units, then these + configuration pragmas are prepended to each of the chopped files. This + behavior provides the required behavior described in the RM for the + actions to be taken on compiling such a file, namely that the pragmas + apply to all units in the compilation, but not to subsequently compiled + units. + + Finally, if configuration pragmas appear between units, they are appended + to the previous unit. This results in the previous unit being illegal, + since the compiler does not accept configuration pragmas that follow + a unit. This provides the required RM behavior that forbids configuration + pragmas other than those preceding the first compilation unit of a + compilation. + + For most purposes, @code{gnatchop} will be used in default mode. The + compilation mode described above is used only if you need exactly + accurate behavior with respect to compilations, and you have files + that contain multiple units and configuration pragmas. In this + circumstance the use of @code{gnatchop} with the compilation mode + switch provides the required behavior, and is for example the mode + in which GNAT processes the ACVC tests. + + @node Command Line for gnatchop + @section Command Line for @code{gnatchop} + + @noindent + The @code{gnatchop} command has the form: + + @smallexample + $ gnatchop switches @var{file name} [@var{file name} @var{file name} ...] + [@var{directory}] + @end smallexample + + @noindent + The only required argument is the file name of the file to be chopped. + There are no restrictions on the form of this file name. The file itself + contains one or more Ada units, in normal GNAT format, concatenated + together. As shown, more than one file may be presented to be chopped. + + When run in default mode, @code{gnatchop} generates one output file in + the current directory for each unit in each of the files. + + @var{directory}, if specified, gives the name of the directory to which + the output files will be written. If it is not specified, all files are + written to the current directory. + + For example, given a + file called @file{hellofiles} containing + + @smallexample + @group + @cartouche + @b{procedure} hello; + + @b{with} Text_IO; @b{use} Text_IO; + @b{procedure} hello @b{is} + @b{begin} + Put_Line ("Hello"); + @b{end} hello; + @end cartouche + @end group + @end smallexample + + @noindent + the command + + @smallexample + $ gnatchop hellofiles + @end smallexample + + @noindent + generates two files in the current directory, one called + @file{hello.ads} containing the single line that is the procedure spec, + and the other called @file{hello.adb} containing the remaining text. The + original file is not affected. The generated files can be compiled in + the normal manner. + + @node Switches for gnatchop + @section Switches for @code{gnatchop} + + @noindent + @code{gnatchop} recognizes the following switches: + + @table @code + + @item -c + @cindex @code{-c} (@code{gnatchop}) + Causes @code{gnatchop} to operate in compilation mode, in which + configuration pragmas are handled according to strict RM rules. See + previous section for a full description of this mode. + + @item -gnatxxx + This passes the given @option{-gnatxxx} switch to @code{gnat} which is + used to parse the given file. Not all @code{xxx} options make sense, + but for example, the use of @option{-gnati2} allows @code{gnatchop} to + process a source file that uses Latin-2 coding for identifiers. + + @item -h + Causes @code{gnatchop} to generate a brief help summary to the standard + output file showing usage information. + + @item -k@var{mm} + @cindex @code{-k} (@code{gnatchop}) + Limit generated file names to the specified number @code{mm} + of characters. + This is useful if the + resulting set of files is required to be interoperable with systems + which limit the length of file names. + No space is allowed between the @code{-k} and the numeric value. The numeric + value may be omitted in which case a default of @code{-k8}, + suitable for use + with DOS-like file systems, is used. If no @code{-k} switch + is present then + there is no limit on the length of file names. + + @item -p + @cindex @code{-p} (@code{gnatchop}) + Causes the file modification time stamp of the input file to be + preserved and used for the time stamp of the output file(s). This may be + useful for preserving coherency of time stamps in an enviroment where + @code{gnatchop} is used as part of a standard build process. + + @item -q + @cindex @code{-q} (@code{gnatchop}) + Causes output of informational messages indicating the set of generated + files to be suppressed. Warnings and error messages are unaffected. + + @item -r + @cindex @code{-r} (@code{gnatchop}) + @findex Source_Reference + Generate @code{Source_Reference} pragmas. Use this switch if the output + files are regarded as temporary and development is to be done in terms + of the original unchopped file. This switch causes + @code{Source_Reference} pragmas to be inserted into each of the + generated files to refers back to the original file name and line number. + The result is that all error messages refer back to the original + unchopped file. + In addition, the debugging information placed into the object file (when + the @code{-g} switch of @code{gcc} or @code{gnatmake} is specified) also + refers back to this original file so that tools like profilers and + debuggers will give information in terms of the original unchopped file. + + If the original file to be chopped itself contains + a @code{Source_Reference} + pragma referencing a third file, then gnatchop respects + this pragma, and the generated @code{Source_Reference} pragmas + in the chopped file refer to the original file, with appropriate + line numbers. This is particularly useful when @code{gnatchop} + is used in conjunction with @code{gnatprep} to compile files that + contain preprocessing statements and multiple units. + + @item -v + @cindex @code{-v} (@code{gnatchop}) + Causes @code{gnatchop} to operate in verbose mode. The version + number and copyright notice are output, as well as exact copies of + the gnat1 commands spawned to obtain the chop control information. + + @item -w + @cindex @code{-w} (@code{gnatchop}) + Overwrite existing file names. Normally @code{gnatchop} regards it as a + fatal error if there is already a file with the same name as a + file it would otherwise output, in other words if the files to be + chopped contain duplicated units. This switch bypasses this + check, and causes all but the last instance of such duplicated + units to be skipped. + + @item --GCC=xxxx + @cindex @code{--GCC=} (@code{gnatchop}) + Specify the path of the GNAT parser to be used. When this switch is used, + no attempt is made to add the prefix to the GNAT parser executable. + @end table + + @node Examples of gnatchop Usage + @section Examples of @code{gnatchop} Usage + + @table @code + @item gnatchop -w hello_s.ada ichbiah/files + + Chops the source file @file{hello_s.ada}. The output files will be + placed in the directory @file{ichbiah/files}, + overwriting any + files with matching names in that directory (no files in the current + directory are modified). + + @item gnatchop archive + Chops the source file @file{archive} + into the current directory. One + useful application of @code{gnatchop} is in sending sets of sources + around, for example in email messages. The required sources are simply + concatenated (for example, using a Unix @code{cat} + command), and then + @code{gnatchop} is used at the other end to reconstitute the original + file names. + + @item gnatchop file1 file2 file3 direc + Chops all units in files @file{file1}, @file{file2}, @file{file3}, placing + the resulting files in the directory @file{direc}. Note that if any units + occur more than once anywhere within this set of files, an error message + is generated, and no files are written. To override this check, use the + @code{-w} switch, + in which case the last occurrence in the last file will + be the one that is output, and earlier duplicate occurrences for a given + unit will be skipped. + @end table + + @node Configuration Pragmas + @chapter Configuration Pragmas + @cindex Configuration pragmas + @cindex Pragmas, configuration + + @noindent + In Ada 95, configuration pragmas include those pragmas described as + such in the Ada 95 Reference Manual, as well as + implementation-dependent pragmas that are configuration pragmas. See the + individual descriptions of pragmas in the GNAT Reference Manual for + details on these additional GNAT-specific configuration pragmas. Most + notably, the pragma @code{Source_File_Name}, which allows + specifying non-default names for source files, is a configuration + pragma. The following is a complete list of configuration pragmas + recognized by @code{GNAT}: + + @smallexample + Ada_83 + Ada_95 + C_Pass_By_Copy + Component_Alignment + Discard_Names + Elaboration_Checks + Eliminate + Extend_System + Extensions_Allowed + External_Name_Casing + Float_Representation + Initialize_Scalars + License + Locking_Policy + Long_Float + No_Run_Time + Normalize_Scalars + Polling + Propagate_Exceptions + Queuing_Policy + Ravenscar + Restricted_Run_Time + Restrictions + Reviewable + Source_File_Name + Style_Checks + Suppress + Task_Dispatching_Policy + Unsuppress + Use_VADS_Size + Warnings + Validity_Checks + @end smallexample + + @menu + * Handling of Configuration Pragmas:: + * The Configuration Pragmas Files:: + @end menu + + @node Handling of Configuration Pragmas + @section Handling of Configuration Pragmas + + Configuration pragmas may either appear at the start of a compilation + unit, in which case they apply only to that unit, or they may apply to + all compilations performed in a given compilation environment. + + GNAT also provides the @code{gnatchop} utility to provide an automatic + way to handle configuration pragmas following the semantics for + compilations (that is, files with multiple units), described in the RM. + See section @pxref{Operating gnatchop in Compilation Mode} for details. + However, for most purposes, it will be more convenient to edit the + @file{gnat.adc} file that contains configuration pragmas directly, + as described in the following section. + + @node The Configuration Pragmas Files + @section The Configuration Pragmas Files + @cindex @file{gnat.adc} + + @noindent + In GNAT a compilation environment is defined by the current + directory at the time that a compile command is given. This current + directory is searched for a file whose name is @file{gnat.adc}. If + this file is present, it is expected to contain one or more + configuration pragmas that will be applied to the current compilation. + However, if the switch @option{-gnatA} is used, @file{gnat.adc} is not + considered. + + Configuration pragmas may be entered into the @file{gnat.adc} file + either by running @code{gnatchop} on a source file that consists only of + configuration pragmas, or more conveniently by + direct editing of the @file{gnat.adc} file, which is a standard format + source file. + + In addition to @file{gnat.adc}, one additional file containing configuration + pragmas may be applied to the current compilation using the switch + @option{-gnatec}@var{path}. @var{path} must designate an existing file that + contains only configuration pragmas. These configuration pragmas are + in addition to those found in @file{gnat.adc} (provided @file{gnat.adc} + is present and switch @option{-gnatA} is not used). + + It is allowed to specify several switches @option{-gnatec}, however only + the last one on the command line will be taken into account. + + + @node Handling Arbitrary File Naming Conventions Using gnatname + @chapter Handling Arbitrary File Naming Conventions Using @code{gnatname} + @cindex Arbitrary File Naming Conventions + + @menu + * Arbitrary File Naming Conventions:: + * Running gnatname:: + * Switches for gnatname:: + * Examples of gnatname Usage:: + @end menu + + @node Arbitrary File Naming Conventions + @section Arbitrary File Naming Conventions + + @noindent + The GNAT compiler must be able to know the source file name of a compilation unit. + When using the standard GNAT default file naming conventions (@code{.ads} for specs, + @code{.adb} for bodies), the GNAT compiler does not need additional information. + + @noindent + When the source file names do not follow the standard GNAT default file naming + conventions, the GNAT compiler must be given additional information through + a configuration pragmas file (see @ref{Configuration Pragmas}) or a project file. + When the non standard file naming conventions are well-defined, a small number of + pragmas @code{Source_File_Name} specifying a naming pattern + (see @ref{Alternative File Naming Schemes}) may be sufficient. However, + if the file naming conventions are irregular or arbitrary, a number + of pragma @code{Source_File_Name} for individual compilation units must be defined. + To help maintain the correspondence between compilation unit names and + source file names within the compiler, + GNAT provides a tool @code{gnatname} to generate the required pragmas for a + set of files. + + @node Running gnatname + @section Running @code{gnatname} + + @noindent + The usual form of the @code{gnatname} command is + + @smallexample + $ gnatname [@var{switches}] @var{naming_pattern} [@var{naming_patterns}] + @end smallexample + + @noindent + All of the arguments are optional. If invoked without any argument, + @code{gnatname} will display its usage. + + @noindent + When used with at least one naming pattern, @code{gnatname} will attempt to + find all the compilation units in files that follow at least one of the + naming patterns. To find these compilation units, + @code{gnatname} will use the GNAT compiler in syntax-check-only mode on all + regular files. + + @noindent + One or several Naming Patterns may be given as arguments to @code{gnatname}. + Each Naming Pattern is enclosed between double quotes. + A Naming Pattern is a regular expression similar to the wildcard patterns + used in file names by the Unix shells or the DOS prompt. + + @noindent + Examples of Naming Patterns are + + @smallexample + "*.[12].ada" + "*.ad[sb]*" + "body_*" "spec_*" + @end smallexample + + @noindent + For a more complete description of the syntax of Naming Patterns, see the second kind + of regular expressions described in @file{g-regexp.ads} (the "Glob" regular + expressions). + + @noindent + When invoked with no switches, @code{gnatname} will create a configuration + pragmas file @file{gnat.adc} in the current working directory, with pragmas + @code{Source_File_Name} for each file that contains a valid Ada unit. + + @node Switches for gnatname + @section Switches for @code{gnatname} + + @noindent + Switches for @code{gnatname} must precede any specified Naming Pattern. + + @noindent + You may specify any of the following switches to @code{gnatname}: + + @table @code + + @item -c@file{file} + @cindex @code{-c} (@code{gnatname}) + Create a configuration pragmas file @file{file} (instead of the default + @file{gnat.adc}). There may be zero, one or more space between @code{-c} and + @file{file}. @file{file} may include directory information. @file{file} must be + writeable. There may be only one switch @code{-c}. When a switch @code{-c} is + specified, no switch @code{-P} may be specified (see below). + + @item -d@file{dir} + @cindex @code{-d} (@code{gnatname}) + Look for source files in directory @file{dir}. There may be zero, one or more spaces + between @code{-d} and @file{dir}. When a switch @code{-d} is specified, + the current working directory will not be searched for source files, unless it + is explictly + specified with a @code{-d} or @code{-D} switch. Several switches @code{-d} may be + specified. If @file{dir} is a relative path, it is relative to the directory of + the configuration pragmas file specified with switch @code{-c}, or to the directory + of the project file specified with switch @code{-P} or, if neither switch @code{-c} + nor switch @code{-P} are specified, it is relative to the current working + directory. The directory + specified with switch @code{-c} must exist and be readable. + + @item -D@file{file} + @cindex @code{-D} (@code{gnatname}) + Look for source files in all directories listed in text file @file{file}. There may be + zero, one or more spaces between @code{-d} and @file{dir}. @file{file} + must be an existing, readable text file. Each non empty line in @file{file} must be + a directory. Specifying switch @code{-D} is equivalent to specifying as many switches + @code{-d} as there are non empty lines in @file{file}. + + @item -h + @cindex @code{-h} (@code{gnatname}) + Output usage (help) information. The output is written to @file{stdout}. + + @item -P@file{proj} + @cindex @code{-P} (@code{gnatname}) + Create or update project file @file{proj}. There may be zero, one or more space + between @code{-P} and @file{proj}. @file{proj} may include directory information. + @file{proj} must be writeable. There may be only one switch @code{-P}. + When a switch @code{-P} is specified, no switch @code{-c} may be specified. + + @item -v + @cindex @code{-v} (@code{gnatname}) + Verbose mode. Output detailed explanation of behavior to @file{stdout}. This includes + name of the file written, the name of the directories to search and, for each file + in those directories whose name matches at least one of the Naming Patterns, an + indication of whether the file contains a unit, and if so the name of the unit. + + @item -v -v + Very Verbose mode. In addition to the output produced in verbose mode, for each file + in the searched directories whose name matches none of the Naming Patterns, an + indication is given that there is no match. + + @item -x@file{pattern} + Excluded patterns. Using this switch, it is possible to exclude some files + that would match the name patterns. For example, + @code{"gnatname -x "*_nt.ada" "*.ada"} will look for Ada units in all files + with the @file{.ada} extension, except those whose names end with + @file{_nt.ada}. + + @end table + + @node Examples of gnatname Usage + @section Examples of @code{gnatname} Usage + + @smallexample + $ gnatname -c /home/me/names.adc -d sources "[a-z]*.ada*" + @end smallexample + + In this example, the directory @file{/home/me} must already exist and be + writeable. In addition, the directory @file{/home/me/sources} (specified by + @code{-d sources}) must exist and be readable. Note the optional spaces after + @code{-c} and @code{-d}. + + @smallexample + $ gnatname -P/home/me/proj -x "*_nt_body.ada" -dsources -dsources/plus -Dcommon_dirs.txt "body_*" "spec_*" + @end smallexample + + Note that several switches @code{-d} may be used, even in conjunction with one + or several switches @code{-D}. Several Naming Patterns and one excluded pattern + are used in this example. + + + @c ***************************************** + @c * G N A T P r o j e c t M a n a g e r * + @c ***************************************** + @node GNAT Project Manager + @chapter GNAT Project Manager + + @menu + * Introduction:: + * Examples of Project Files:: + * Project File Syntax:: + * Objects and Sources in Project Files:: + * Importing Projects:: + * Project Extension:: + * External References in Project Files:: + * Packages in Project Files:: + * Variables from Imported Projects:: + * Naming Schemes:: + * Library Projects:: + * Switches Related to Project Files:: + * Tools Supporting Project Files:: + * An Extended Example:: + * Project File Complete Syntax:: + @end menu + + + @c **************** + @c * Introduction * + @c **************** + + @node Introduction + @section Introduction + + @noindent + This chapter describes GNAT's @emph{Project Manager}, a facility that + lets you configure various properties for a collection of source files. In + particular, you can specify: + @itemize @bullet + @item + The directory or set of directories containing the source files, and/or the + names of the specific source files themselves + @item + The directory in which the compiler's output + (@file{ALI} files, object files, tree files) will be placed + @item + The directory in which the executable programs will be placed + @item + Switch settings for any of the project-enabled tools (@command{gnatmake}, + compiler, binder, linker, @code{gnatls}, @code{gnatxref}, @code{gnatfind}); + you can apply these settings either globally or to individual units + @item + The source files containing the main subprogram(s) to be built + @item + The source programming language(s) (currently Ada and/or C) + @item + Source file naming conventions; you can specify these either globally or for + individual units + @end itemize + + @menu + * Project Files:: + @end menu + + @node Project Files + @subsection Project Files + + @noindent + A @dfn{project} is a specific set of values for these properties. You can + define a project's settings in a @dfn{project file}, a text file with an + Ada-like syntax; a property value is either a string or a list of strings. + Properties that are not explicitly set receive default values. A project + file may interrogate the values of @dfn{external variables} (user-defined + command-line switches or environment variables), and it may specify property + settings conditionally, based on the value of such variables. + + In simple cases, a project's source files depend only on other source files + in the same project, or on the predefined libraries. ("Dependence" is in + the technical sense; for example, one Ada unit "with"ing another.) However, + the Project Manager also allows much more sophisticated arrangements, + with the source files in one project depending on source files in other + projects: + @itemize @bullet + @item + One project can @emph{import} other projects containing needed source files. + @item + You can organize GNAT projects in a hierarchy: a @emph{child} project + can extend a @emph{parent} project, inheriting the parent's source files and + optionally overriding any of them with alternative versions + @end itemize + + @noindent + More generally, the Project Manager lets you structure large development + efforts into hierarchical subsystems, with build decisions deferred to the + subsystem level and thus different compilation environments (switch settings) + used for different subsystems. + + The Project Manager is invoked through the @option{-P@emph{projectfile}} + switch to @command{gnatmake} or to the @command{gnat} front driver. + If you want to define (on the command line) an external variable that is + queried by the project file, additionally use the + @option{-X@emph{vbl}=@emph{value}} switch. + The Project Manager parses and interprets the project file, and drives the + invoked tool based on the project settings. + + The Project Manager supports a wide range of development strategies, + for systems of all sizes. Some typical practices that are easily handled: + @itemize @bullet + @item + Using a common set of source files, but generating object files in different + directories via different switch settings + @item + Using a mostly-shared set of source files, but with different versions of + some unit or units + @end itemize + + @noindent + The destination of an executable can be controlled inside a project file + using the @option{-o} switch. In the absence of such a switch either inside + the project file or on the command line, any executable files generated by + @command{gnatmake} will be placed in the directory @code{Exec_Dir} specified + in the project file. If no @code{Exec_Dir} is specified, they will be placed + in the object directory of the project. + + You can use project files to achieve some of the effects of a source + versioning system (for example, defining separate projects for + the different sets of sources that comprise different releases) but the + Project Manager is independent of any source configuration management tools + that might be used by the developers. + + The next section introduces the main features of GNAT's project facility + through a sequence of examples; subsequent sections will present the syntax + and semantics in more detail. + + + @c ***************************** + @c * Examples of Project Files * + @c ***************************** + + @node Examples of Project Files + @section Examples of Project Files + @noindent + This section illustrates some of the typical uses of project files and + explains their basic structure and behavior. + + @menu + * Common Sources with Different Switches and Different Output Directories:: + * Using External Variables:: + * Importing Other Projects:: + * Extending a Project:: + @end menu + + @node Common Sources with Different Switches and Different Output Directories + @subsection Common Sources with Different Switches and Different Output Directories + + @menu + * Source Files:: + * Specifying the Object Directory:: + * Specifying the Exec Directory:: + * Project File Packages:: + * Specifying Switch Settings:: + * Main Subprograms:: + * Source File Naming Conventions:: + * Source Language(s):: + @end menu + + @noindent + Assume that the Ada source files @file{pack.ads}, @file{pack.adb}, and + @file{proc.adb} are in the @file{/common} directory. The file + @file{proc.adb} contains an Ada main subprogram @code{Proc} that "with"s + package @code{Pack}. We want to compile these source files under two sets + of switches: + @itemize @bullet + @item + When debugging, we want to pass the @option{-g} switch to @command{gnatmake}, + and the @option{-gnata}, @option{-gnato}, and @option{-gnatE} switches to the + compiler; the compiler's output is to appear in @file{/common/debug} + @item + When preparing a release version, we want to pass the @option{-O2} switch to + the compiler; the compiler's output is to appear in @file{/common/release} + @end itemize + + @noindent + The GNAT project files shown below, respectively @file{debug.gpr} and + @file{release.gpr} in the @file{/common} directory, achieve these effects. + + Diagrammatically: + @smallexample + @group + /common + debug.gpr + release.gpr + pack.ads + pack.adb + proc.adb + @end group + @group + /common/debug @{-g, -gnata, -gnato, -gnatE@} + proc.ali, proc.o + pack.ali, pack.o + @end group + @group + /common/release @{-O2@} + proc.ali, proc.o + pack.ali, pack.o + @end group + @end smallexample + Here are the project files: + @smallexample + @group + project Debug is + for Object_Dir use "debug"; + for Main use ("proc"); + + package Builder is + for Default_Switches ("Ada") use ("-g"); + end Builder; + @end group + + @group + package Compiler is + for Default_Switches ("Ada") + use ("-fstack-check", "-gnata", "-gnato", "-gnatE"); + end Compiler; + end Debug; + @end group + @end smallexample + + @smallexample + @group + project Release is + for Object_Dir use "release"; + for Exec_Dir use "."; + for Main use ("proc"); + + package Compiler is + for Default_Switches ("Ada") use ("-O2"); + end Compiler; + end Release; + @end group + @end smallexample + + @noindent + The name of the project defined by @file{debug.gpr} is @code{"Debug"} (case + insensitive), and analogously the project defined by @file{release.gpr} is + @code{"Release"}. For consistency the file should have the same name as the + project, and the project file's extension should be @code{"gpr"}. These + conventions are not required, but a warning is issued if they are not followed. + + If the current directory is @file{/temp}, then the command + @smallexample + gnatmake -P/common/debug.gpr + @end smallexample + + @noindent + generates object and ALI files in @file{/common/debug}, and the @code{proc} + executable also in @file{/common/debug}, using the switch settings defined in + the project file. + + Likewise, the command + @smallexample + gnatmake -P/common/release.gpr + @end smallexample + + @noindent + generates object and ALI files in @file{/common/release}, and the @code{proc} + executable in @file{/common}, using the switch settings from the project file. + + @node Source Files + @unnumberedsubsubsec Source Files + + @noindent + If a project file does not explicitly specify a set of source directories or + a set of source files, then by default the project's source files are the + Ada source files in the project file directory. Thus @file{pack.ads}, + @file{pack.adb}, and @file{proc.adb} are the source files for both projects. + + @node Specifying the Object Directory + @unnumberedsubsubsec Specifying the Object Directory + + @noindent + Several project properties are modeled by Ada-style @emph{attributes}; + you define the property by supplying the equivalent of an Ada attribute + definition clause in the project file. + A project's object directory is such a property; the corresponding + attribute is @code{Object_Dir}, and its value is a string expression. A + directory may be specified either as absolute or as relative; in the latter + case, it is relative to the project file directory. Thus the compiler's + output is directed to @file{/common/debug} (for the @code{Debug} project) + and to @file{/common/release} (for the @code{Release} project). If + @code{Object_Dir} is not specified, then the default is the project file + directory. + + @node Specifying the Exec Directory + @unnumberedsubsubsec Specifying the Exec Directory + + @noindent + A project's exec directory is another property; the corresponding + attribute is @code{Exec_Dir}, and its value is also a string expression, + either specified as relative or absolute. If @code{Exec_Dir} is not specified, + then the default is the object directory (which may also be the project file + directory if attribute @code{Object_Dir} is not specified). Thus the executable + is placed in @file{/common/debug} for the @code{Debug} project (attribute + @code{Exec_Dir} not specified) and in @file{/common} for the @code{Release} + project. + + @node Project File Packages + @unnumberedsubsubsec Project File Packages + + @noindent + A GNAT tool integrated with the Project Manager is modeled by a + corresponding package in the project file. + The @code{Debug} project defines the packages @code{Builder} + (for @command{gnatmake}) and @code{Compiler}; + the @code{Release} project defines only the @code{Compiler} package. + + The Ada package syntax is not to be taken literally. Although packages in + project files bear a surface resemblance to packages in Ada source code, the + notation is simply a way to convey a grouping of properties for a named + entity. Indeed, the package names permitted in project files are restricted + to a predefined set, corresponding to the project-aware tools, and the contents + of packages are limited to a small set of constructs. + The packages in the example above contain attribute definitions. + + + @node Specifying Switch Settings + @unnumberedsubsubsec Specifying Switch Settings + + @noindent + Switch settings for a project-aware tool can be specified through attributes + in the package corresponding to the tool. + The example above illustrates one of the relevant attributes, + @code{Default_Switches}, defined in the packages in both project files. + Unlike simple attributes like @code{Source_Dirs}, @code{Default_Switches} is + known as an @emph{associative array}. When you define this attribute, you must + supply an "index" (a literal string), and the effect of the attribute + definition is to set the value of the "array" at the specified "index". + For the @code{Default_Switches} attribute, the index is a programming + language (in our case, Ada) , and the value specified (after @code{use}) + must be a list of string expressions. + + The attributes permitted in project files are restricted to a predefined set. + Some may appear at project level, others in packages. + For any attribute that is an associate array, the index must always be a + literal string, but the restrictions on this string (e.g., a file name or a + language name) depend on the individual attribute. + Also depending on the attribute, its specified value will need to be either a + string or a string list. + + In the @code{Debug} project, we set the switches for two tools, + @command{gnatmake} and the compiler, and thus we include corresponding + packages, with each package defining the @code{Default_Switches} attribute + with index @code{"Ada"}. + Note that the package corresponding to + @command{gnatmake} is named @code{Builder}. The @code{Release} project is + similar, but with just the @code{Compiler} package. + + In project @code{Debug} above the switches starting with @option{-gnat} that + are specified in package @code{Compiler} could have been placed in package + @code{Builder}, since @command{gnatmake} transmits all such switches to the + compiler. + + @node Main Subprograms + @unnumberedsubsubsec Main Subprograms + + @noindent + One of the properties of a project is its list of main subprograms (actually + a list of names of source files containing main subprograms, with the file + extension optional. This property is captured in the @code{Main} attribute, + whose value is a list of strings. If a project defines the @code{Main} + attribute, then you do not need to identify the main subprogram(s) when + invoking @command{gnatmake} (see @ref{gnatmake and Project Files}). + + @node Source File Naming Conventions + @unnumberedsubsubsec Source File Naming Conventions + + @noindent + Since the project files do not specify any source file naming conventions, + the GNAT defaults are used. The mechanism for defining source file naming + conventions -- a package named @code{Naming} -- will be described below + (@pxref{Naming Schemes}). + + @node Source Language(s) + @unnumberedsubsubsec Source Language(s) + + @noindent + Since the project files do not specify a @code{Languages} attribute, by + default the GNAT tools assume that the language of the project file is Ada. + More generally, a project can comprise source files + in Ada, C, and/or other languages. + + @node Using External Variables + @subsection Using External Variables + + @noindent + Instead of supplying different project files for debug and release, we can + define a single project file that queries an external variable (set either + on the command line or via an environment variable) in order to + conditionally define the appropriate settings. Again, assume that the + source files @file{pack.ads}, @file{pack.adb}, and @file{proc.adb} are + located in directory @file{/common}. The following project file, + @file{build.gpr}, queries the external variable named @code{STYLE} and + defines an object directory and switch settings based on whether the value + is @code{"deb"} (debug) or @code{"rel"} (release), where the default is + @code{"deb"}. + + @smallexample + @group + project Build is + for Main use ("proc"); + + type Style_Type is ("deb", "rel"); + Style : Style_Type := external ("STYLE", "deb"); + + case Style is + when "deb" => + for Object_Dir use "debug"; + + when "rel" => + for Object_Dir use "release"; + for Exec_Dir use "."; + end case; + @end group + + @group + package Builder is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-g"); + end case; + + end Builder; + @end group + + @group + package Compiler is + + case Style is + when "deb" => + for Default_Switches ("Ada") use ("-gnata", "-gnato", "-gnatE"); + + when "rel" => + for Default_Switches ("Ada") use ("-O2"); + end case; + + end Compiler; + + end Build; + @end group + @end smallexample + + @noindent + @code{Style_Type} is an example of a @emph{string type}, which is the project + file analog of an Ada enumeration type but containing string literals rather + than identifiers. @code{Style} is declared as a variable of this type. + + The form @code{external("STYLE", "deb")} is known as an + @emph{external reference}; its first argument is the name of an + @emph{external variable}, and the second argument is a default value to be + used if the external variable doesn't exist. You can define an external + variable on the command line via the @option{-X} switch, or you can use an + environment variable as an external variable. + + Each @code{case} construct is expanded by the Project Manager based on the + value of @code{Style}. Thus the command + @smallexample + gnatmake -P/common/build.gpr -XSTYLE=deb + @end smallexample + + @noindent + is equivalent to the @command{gnatmake} invocation using the project file + @file{debug.gpr} in the earlier example. So is the command + @smallexample + gnatmake -P/common/build.gpr + @end smallexample + + @noindent + since @code{"deb"} is the default for @code{STYLE}. + + Analogously, + @smallexample + gnatmake -P/common/build.gpr -XSTYLE=rel + @end smallexample + + @noindent + is equivalent to the @command{gnatmake} invocation using the project file + @file{release.gpr} in the earlier example. + + + @node Importing Other Projects + @subsection Importing Other Projects + + @noindent + A compilation unit in a source file in one project may depend on compilation + units in source files in other projects. To obtain this behavior, the + dependent project must @emph{import} the projects containing the needed source + files. This effect is embodied in syntax similar to an Ada @code{with} clause, + but the "with"ed entities are strings denoting project files. + + As an example, suppose that the two projects @code{GUI_Proj} and + @code{Comm_Proj} are defined in the project files @file{gui_proj.gpr} and + @file{comm_proj.gpr} in directories @file{/gui} and @file{/comm}, + respectively. Assume that the source files for @code{GUI_Proj} are + @file{gui.ads} and @file{gui.adb}, and that the source files for + @code{Comm_Proj} are @file{comm.ads} and @file{comm.adb}, with each set of + files located in its respective project file directory. Diagrammatically: + + @smallexample + @group + /gui + gui_proj.gpr + gui.ads + gui.adb + @end group + + @group + /comm + comm_proj.gpr + comm.ads + comm.adb + @end group + @end smallexample + + @noindent + We want to develop an application in directory @file{/app} that "with"s the + packages @code{GUI} and @code{Comm}, using the properties of the + corresponding project files (e.g. the switch settings and object directory). + Skeletal code for a main procedure might be something like the following: + + @smallexample + @group + with GUI, Comm; + procedure App_Main is + ... + begin + ... + end App_Main; + @end group + @end smallexample + + @noindent + Here is a project file, @file{app_proj.gpr}, that achieves the desired + effect: + + @smallexample + @group + with "/gui/gui_proj", "/comm/comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + @end group + @end smallexample + + @noindent + Building an executable is achieved through the command: + @smallexample + gnatmake -P/app/app_proj + @end smallexample + @noindent + which will generate the @code{app_main} executable in the directory where + @file{app_proj.gpr} resides. + + If an imported project file uses the standard extension (@code{gpr}) then + (as illustrated above) the @code{with} clause can omit the extension. + + Our example specified an absolute path for each imported project file. + Alternatively, you can omit the directory if either + @itemize @bullet + @item + The imported project file is in the same directory as the importing project + file, or + @item + You have defined an environment variable @code{ADA_PROJECT_PATH} that + includes the directory containing the needed project file. + @end itemize + + @noindent + Thus, if we define @code{ADA_PROJECT_PATH} to include @file{/gui} and + @file{/comm}, then our project file @file{app_proj.gpr} could be written as + follows: + + @smallexample + @group + with "gui_proj", "comm_proj"; + project App_Proj is + for Main use ("app_main"); + end App_Proj; + @end group + @end smallexample + + @noindent + Importing other projects raises the possibility of ambiguities. For + example, the same unit might be present in different imported projects, or + it might be present in both the importing project and an imported project. + Both of these conditions are errors. Note that in the current version of + the Project Manager, it is illegal to have an ambiguous unit even if the + unit is never referenced by the importing project. This restriction may be + relaxed in a future release. + + @node Extending a Project + @subsection Extending a Project + + @noindent + A common situation in large software systems is to have multiple + implementations for a common interface; in Ada terms, multiple versions of a + package body for the same specification. For example, one implementation + might be safe for use in tasking programs, while another might only be used + in sequential applications. This can be modeled in GNAT using the concept + of @emph{project extension}. If one project (the "child") @emph{extends} + another project (the "parent") then by default all source files of the + parent project are inherited by the child, but the child project can + override any of the parent's source files with new versions, and can also + add new files. This facility is the project analog of extension in + Object-Oriented Programming. Project hierarchies are permitted (a child + project may be the parent of yet another project), and a project that + inherits one project can also import other projects. + + As an example, suppose that directory @file{/seq} contains the project file + @file{seq_proj.gpr} and the source files @file{pack.ads}, @file{pack.adb}, + and @file{proc.adb}: + + @smallexample + @group + /seq + pack.ads + pack.adb + proc.adb + seq_proj.gpr + @end group + @end smallexample + + @noindent + Note that the project file can simply be empty (that is, no attribute or + package is defined): + + @smallexample + @group + project Seq_Proj is + end Seq_Proj; + @end group + @end smallexample + + @noindent + implying that its source files are all the Ada source files in the project + directory. + + Suppose we want to supply an alternate version of @file{pack.adb}, in + directory @file{/tasking}, but use the existing versions of @file{pack.ads} + and @file{proc.adb}. We can define a project @code{Tasking_Proj} that + inherits @code{Seq_Proj}: + + @smallexample + @group + /tasking + pack.adb + tasking_proj.gpr + @end group + + @group + project Tasking_Proj extends "/seq/seq_proj" is + end Tasking_Proj; + @end group + @end smallexample + + @noindent + The version of @file{pack.adb} used in a build depends on which project file + is specified. + + Note that we could have designed this using project import rather than + project inheritance; a @code{base} project would contain the sources for + @file{pack.ads} and @file{proc.adb}, a sequential project would import + @code{base} and add @file{pack.adb}, and likewise a tasking project would + import @code{base} and add a different version of @file{pack.adb}. The + choice depends on whether other sources in the original project need to be + overridden. If they do, then project extension is necessary, otherwise, + importing is sufficient. + + + @c *********************** + @c * Project File Syntax * + @c *********************** + + @node Project File Syntax + @section Project File Syntax + + @menu + * Basic Syntax:: + * Packages:: + * Expressions:: + * String Types:: + * Variables:: + * Attributes:: + * Associative Array Attributes:: + * case Constructions:: + @end menu + + @noindent + This section describes the structure of project files. + + A project may be an @emph{independent project}, entirely defined by a single + project file. Any Ada source file in an independent project depends only + on the predefined library and other Ada source files in the same project. + + @noindent + A project may also @dfn{depend on} other projects, in either or both of the following ways: + @itemize @bullet + @item It may import any number of projects + @item It may extend at most one other project + @end itemize + + @noindent + The dependence relation is a directed acyclic graph (the subgraph reflecting + the "extends" relation is a tree). + + A project's @dfn{immediate sources} are the source files directly defined by + that project, either implicitly by residing in the project file's directory, + or explicitly through any of the source-related attributes described below. + More generally, a project @var{proj}'s @dfn{sources} are the immediate sources + of @var{proj} together with the immediate sources (unless overridden) of any + project on which @var{proj} depends (either directly or indirectly). + + @node Basic Syntax + @subsection Basic Syntax + + @noindent + As seen in the earlier examples, project files have an Ada-like syntax. + The minimal project file is: + @smallexample + @group + project Empty is + + end Empty; + @end group + @end smallexample + + @noindent + The identifier @code{Empty} is the name of the project. + This project name must be present after the reserved + word @code{end} at the end of the project file, followed by a semi-colon. + + Any name in a project file, such as the project name or a variable name, + has the same syntax as an Ada identifier. + + The reserved words of project files are the Ada reserved words plus + @code{extends}, @code{external}, and @code{project}. Note that the only Ada + reserved words currently used in project file syntax are: + + @itemize @bullet + @item + @code{case} + @item + @code{end} + @item + @code{for} + @item + @code{is} + @item + @code{others} + @item + @code{package} + @item + @code{renames} + @item + @code{type} + @item + @code{use} + @item + @code{when} + @item + @code{with} + @end itemize + + @noindent + Comments in project files have the same syntax as in Ada, two consecutives + hyphens through the end of the line. + + @node Packages + @subsection Packages + + @noindent + A project file may contain @emph{packages}. The name of a package must be one + of the identifiers (case insensitive) from a predefined list, and a package + with a given name may only appear once in a project file. The predefined list + includes the following packages: + + @itemize @bullet + @item + @code{Naming} + @item + @code{Builder} + @item + @code{Compiler} + @item + @code{Binder} + @item + @code{Linker} + @item + @code{Finder} + @item + @code{Cross_Reference} + @item + @code{gnatls} + @end itemize + + @noindent + (The complete list of the package names and their attributes can be found + in file @file{prj-attr.adb}). + + @noindent + In its simplest form, a package may be empty: + + @smallexample + @group + project Simple is + package Builder is + end Builder; + end Simple; + @end group + @end smallexample + + @noindent + A package may contain @emph{attribute declarations}, + @emph{variable declarations} and @emph{case constructions}, as will be + described below. + + When there is ambiguity between a project name and a package name, + the name always designates the project. To avoid possible confusion, it is + always a good idea to avoid naming a project with one of the + names allowed for packages or any name that starts with @code{gnat}. + + + @node Expressions + @subsection Expressions + + @noindent + An @emph{expression} is either a @emph{string expression} or a + @emph{string list expression}. + + A @emph{string expression} is either a @emph{simple string expression} or a + @emph{compound string expression}. + + A @emph{simple string expression} is one of the following: + @itemize @bullet + @item A literal string; e.g.@code{"comm/my_proj.gpr"} + @item A string-valued variable reference (see @ref{Variables}) + @item A string-valued attribute reference (see @ref{Attributes}) + @item An external reference (see @ref{External References in Project Files}) + @end itemize + + @noindent + A @emph{compound string expression} is a concatenation of string expressions, + using @code{"&"} + @smallexample + Path & "/" & File_Name & ".ads" + @end smallexample + + @noindent + A @emph{string list expression} is either a + @emph{simple string list expression} or a + @emph{compound string list expression}. + + A @emph{simple string list expression} is one of the following: + @itemize @bullet + @item A parenthesized list of zero or more string expressions, separated by commas + @smallexample + File_Names := (File_Name, "gnat.adc", File_Name & ".orig"); + Empty_List := (); + @end smallexample + @item A string list-valued variable reference + @item A string list-valued attribute reference + @end itemize + + @noindent + A @emph{compound string list expression} is the concatenation (using + @code{"&"}) of a simple string list expression and an expression. Note that + each term in a compound string list expression, except the first, may be + either a string expression or a string list expression. + + @smallexample + @group + File_Name_List := () & File_Name; -- One string in this list + Extended_File_Name_List := File_Name_List & (File_Name & ".orig"); + -- Two strings + Big_List := File_Name_List & Extended_File_Name_List; + -- Concatenation of two string lists: three strings + Illegal_List := "gnat.adc" & Extended_File_Name_List; + -- Illegal: must start with a string list + @end group + @end smallexample + + + @node String Types + @subsection String Types + + @noindent + The value of a variable may be restricted to a list of string literals. + The restricted list of string literals is given in a + @emph{string type declaration}. + + Here is an example of a string type declaration: + + @smallexample + type OS is ("NT, "nt", "Unix", "Linux", "other OS"); + @end smallexample + + @noindent + Variables of a string type are called @emph{typed variables}; all other + variables are called @emph{untyped variables}. Typed variables are + particularly useful in @code{case} constructions + (see @ref{case Constructions}). + + A string type declaration starts with the reserved word @code{type}, followed + by the name of the string type (case-insensitive), followed by the reserved + word @code{is}, followed by a parenthesized list of one or more string literals + separated by commas, followed by a semicolon. + + The string literals in the list are case sensitive and must all be different. + They may include any graphic characters allowed in Ada, including spaces. + + A string type may only be declared at the project level, not inside a package. + + A string type may be referenced by its name if it has been declared in the same + project file, or by its project name, followed by a dot, + followed by the string type name. + + + @node Variables + @subsection Variables + + @noindent + A variable may be declared at the project file level, or in a package. + Here are some examples of variable declarations: + + @smallexample + @group + This_OS : OS := external ("OS"); -- a typed variable declaration + That_OS := "Linux"; -- an untyped variable declaration + @end group + @end smallexample + + @noindent + A @emph{typed variable declaration} includes the variable name, followed by a colon, + followed by the name of a string type, followed by @code{:=}, followed by + a simple string expression. + + An @emph{untyped variable declaration} includes the variable name, + followed by @code{:=}, followed by an expression. Note that, despite the + terminology, this form of "declaration" resembles more an assignment + than a declaration in Ada. It is a declaration in several senses: + @itemize @bullet + @item + The variable name does not need to be defined previously + @item + The declaration establishes the @emph{kind} (string versus string list) of the + variable, and later declarations of the same variable need to be consistent + with this + @end itemize + + @noindent + A string variable declaration (typed or untyped) declares a variable + whose value is a string. This variable may be used as a string expression. + @smallexample + File_Name := "readme.txt"; + Saved_File_Name := File_Name & ".saved"; + @end smallexample + + @noindent + A string list variable declaration declares a variable whose value is a list + of strings. The list may contain any number (zero or more) of strings. + + @smallexample + Empty_List := (); + List_With_One_Element := ("-gnaty"); + List_With_Two_Elements := List_With_One_Element & "-gnatg"; + Long_List := ("main.ada", "pack1_.ada", "pack1.ada", "pack2_.ada" + "pack2.ada", "util_.ada", "util.ada"); + @end smallexample + + @noindent + The same typed variable may not be declared more than once at project level, and it may not be declared more than once in any package; it is in effect a constant or a readonly variable. + + The same untyped variable may be declared several times. + In this case, the new value replaces the old one, + and any subsequent reference to the variable uses the new value. + However, as noted above, if a variable has been declared as a string, all subsequent + declarations must give it a string value. Similarly, if a variable has + been declared as a string list, all subsequent declarations + must give it a string list value. + + A @emph{variable reference} may take several forms: + + @itemize @bullet + @item The simple variable name, for a variable in the current package (if any) or in the current project + @item A context name, followed by a dot, followed by the variable name. + @end itemize + + @noindent + A @emph{context} may be one of the following: + + @itemize @bullet + @item The name of an existing package in the current project + @item The name of an imported project of the current project + @item The name of an ancestor project (i.e., a project extended by the current project, either directly or indirectly) + @item An imported/parent project name, followed by a dot, followed by a package name + @end itemize + + @noindent + A variable reference may be used in an expression. + + + @node Attributes + @subsection Attributes + + @noindent + A project (and its packages) may have @emph{attributes} that define the project's properties. + Some attributes have values that are strings; + others have values that are string lists. + + There are two categories of attributes: @emph{simple attributes} and @emph{associative arrays} + (see @ref{Associative Array Attributes}). + + The names of the attributes are restricted; there is a list of project + attributes, and a list of package attributes for each package. + The names are not case sensitive. + + The project attributes are as follows (all are simple attributes): + + @multitable @columnfractions .4 .3 + @item @emph{Attribute Name} + @tab @emph{Value} + @item @code{Source_Files} + @tab string list + @item @code{Source_Dirs} + @tab string list + @item @code{Source_List_File} + @tab string + @item @code{Object_Dir} + @tab string + @item @code{Exec_Dir} + @tab string + @item @code{Main} + @tab string list + @item @code{Languages} + @tab string list + @item @code{Library_Dir} + @tab string + @item @code{Library_Name} + @tab string + @item @code{Library_Kind} + @tab string + @item @code{Library_Elaboration} + @tab string + @item @code{Library_Version} + @tab string + @end multitable + + @noindent + The attributes for package @code{Naming} are as follows + (see @ref{Naming Schemes}): + + @multitable @columnfractions .4 .2 .2 .2 + @item Attribute Name @tab Category @tab Index @tab Value + @item @code{Specification_Suffix} + @tab associative array + @tab language name + @tab string + @item @code{Implementation_Suffix} + @tab associative array + @tab language name + @tab string + @item @code{Separate_Suffix} + @tab simple attribute + @tab n/a + @tab string + @item @code{Casing} + @tab simple attribute + @tab n/a + @tab string + @item @code{Dot_Replacement} + @tab simple attribute + @tab n/a + @tab string + @item @code{Specification} + @tab associative array + @tab Ada unit name + @tab string + @item @code{Implementation} + @tab associative array + @tab Ada unit name + @tab string + @item @code{Specification_Exceptions} + @tab associative array + @tab language name + @tab string list + @item @code{Implementation_Exceptions} + @tab associative array + @tab language name + @tab string list + @end multitable + + @noindent + The attributes for package @code{Builder}, @code{Compiler}, @code{Binder}, + @code{Linker}, @code{Cross_Reference}, and @code{Finder} + are as follows (see @ref{Switches and Project Files}). + + @multitable @columnfractions .4 .2 .2 .2 + @item Attribute Name @tab Category @tab Index @tab Value + @item @code{Default_Switches} + @tab associative array + @tab language name + @tab string list + @item @code{Switches} + @tab associative array + @tab file name + @tab string list + @end multitable + + @noindent + In addition, package @code{Builder} has a single string attribute + @code{Local_Configuration_Pragmas} and package @code{Builder} has a single + string attribute @code{Global_Configuration_Pragmas}. + + @noindent + The attribute for package @code{Glide} are not documented: they are for + internal use only. + + @noindent + Each simple attribute has a default value: the empty string (for string-valued + attributes) and the empty list (for string list-valued attributes). + + Similar to variable declarations, an attribute declaration defines a new value + for an attribute. + + Examples of simple attribute declarations: + + @smallexample + for Object_Dir use "objects"; + for Source_Dirs use ("units", "test/drivers"); + @end smallexample + + @noindent + A @dfn{simple attribute declaration} starts with the reserved word @code{for}, + followed by the name of the attribute, followed by the reserved word + @code{use}, followed by an expression (whose kind depends on the attribute), + followed by a semicolon. + + Attributes may be referenced in expressions. + The general form for such a reference is @code{'}: + the entity for which the attribute is defined, + followed by an apostrophe, followed by the name of the attribute. + For associative array attributes, a litteral string between parentheses + need to be supplied as index. + + Examples are: + + @smallexample + project'Object_Dir + Naming'Dot_Replacement + Imported_Project'Source_Dirs + Imported_Project.Naming'Casing + Builder'Default_Switches("Ada") + @end smallexample + + @noindent + The entity may be: + @itemize @bullet + @item @code{project} for an attribute of the current project + @item The name of an existing package of the current project + @item The name of an imported project + @item The name of a parent project (extended by the current project) + @item An imported/parent project name, followed by a dot, + followed by a package name + @end itemize + + @noindent + Example: + @smallexample + @group + project Prj is + for Source_Dirs use project'Source_Dirs & "units"; + for Source_Dirs use project'Source_Dirs & "test/drivers" + end Prj; + @end group + @end smallexample + + @noindent + In the first attribute declaration, initially the attribute @code{Source_Dirs} + has the default value: an empty string list. After this declaration, + @code{Source_Dirs} is a string list of one element: "units". + After the second attribute declaration @code{Source_Dirs} is a string list of + two elements: "units" and "test/drivers". + + Note: this example is for illustration only. In practice, + the project file would contain only one attribute declaration: + + @smallexample + for Source_Dirs use ("units", "test/drivers"); + @end smallexample + + + @node Associative Array Attributes + @subsection Associative Array Attributes + + @noindent + Some attributes are defined as @emph{associative arrays}. An associative + array may be regarded as a function that takes a string as a parameter + and delivers a string or string list value as its result. + + Here are some examples of associative array attribute declarations: + + @smallexample + for Implementation ("main") use "Main.ada"; + for Switches ("main.ada") use ("-v", "-gnatv"); + for Switches ("main.ada") use Builder'Switches ("main.ada") & "-g"; + @end smallexample + + @noindent + Like untyped variables and simple attributes, associative array attributes may be declared several times. Each declaration supplies a new value for the + attribute, replacing the previous setting. + + + @node case Constructions + @subsection @code{case} Constructions + + @noindent + A @code{case} construction is used in a project file to effect conditional + behavior. + Here is a typical example: + + @smallexample + @group + project MyProj is + type OS_Type is ("Linux", "Unix", "NT", "VMS"); + + OS : OS_Type := external ("OS", "Linux"); + @end group + + @group + package Compiler is + case OS is + when "Linux" | "Unix" => + for Default_Switches ("Ada") use ("-gnath"); + when "NT" => + for Default_Switches ("Ada") use ("-gnatP"); + when others => + end case; + end Compiler; + end MyProj; + @end group + @end smallexample + + @noindent + The syntax of a @code{case} construction is based on the Ada case statement + (although there is no @code{null} construction for empty alternatives). + + Following the reserved word @code{case} there is the case variable (a typed + string variable), the reserved word @code{is}, and then a sequence of one or + more alternatives. + Each alternative comprises the reserved word @code{when}, either a list of + literal strings separated by the @code{"|"} character or the reserved word + @code{others}, and the @code{"=>"} token. + Each literal string must belong to the string type that is the type of the + case variable. + An @code{others} alternative, if present, must occur last. + The @code{end case;} sequence terminates the case construction. + + After each @code{=>}, there are zero or more constructions. The only + constructions allowed in a case construction are other case constructions and + attribute declarations. String type declarations, variable declarations and + package declarations are not allowed. + + The value of the case variable is often given by an external reference + (see @ref{External References in Project Files}). + + + @c **************************************** + @c * Objects and Sources in Project Files * + @c **************************************** + + @node Objects and Sources in Project Files + @section Objects and Sources in Project Files + + @menu + * Object Directory:: + * Exec Directory:: + * Source Directories:: + * Source File Names:: + @end menu + + @noindent + Each project has exactly one object directory and one or more source + directories. The source directories must contain at least one source file, + unless the project file explicitly specifies that no source files are present + (see @ref{Source File Names}). + + + @node Object Directory + @subsection Object Directory + + @noindent + The object directory for a project is the directory containing the compiler's + output (such as @file{ALI} files and object files) for the project's immediate + sources. Note that for inherited sources (when extending a parent project) the + parent project's object directory is used. + + The object directory is given by the value of the attribute @code{Object_Dir} + in the project file. + + @smallexample + for Object_Dir use "objects"; + @end smallexample + + @noindent + The attribute @var{Object_Dir} has a string value, the path name of the object + directory. The path name may be absolute or relative to the directory of the + project file. This directory must already exist, and be readable and writable. + + By default, when the attribute @code{Object_Dir} is not given an explicit value + or when its value is the empty string, the object directory is the same as the + directory containing the project file. + + + @node Exec Directory + @subsection Exec Directory + + @noindent + The exec directory for a project is the directory containing the executables + for the project's main subprograms. + + The exec directory is given by the value of the attribute @code{Exec_Dir} + in the project file. + + @smallexample + for Exec_Dir use "executables"; + @end smallexample + + @noindent + The attribute @var{Exec_Dir} has a string value, the path name of the exec + directory. The path name may be absolute or relative to the directory of the + project file. This directory must already exist, and be writable. + + By default, when the attribute @code{Exec_Dir} is not given an explicit value + or when its value is the empty string, the exec directory is the same as the + object directory of the project file. + + + @node Source Directories + @subsection Source Directories + + @noindent + The source directories of a project are specified by the project file + attribute @code{Source_Dirs}. + + This attribute's value is a string list. If the attribute is not given an + explicit value, then there is only one source directory, the one where the + project file resides. + + A @code{Source_Dirs} attribute that is explicitly defined to be the empty list, + as in + + @smallexample + for Source_Dirs use (); + @end smallexample + + @noindent + indicates that the project contains no source files. + + Otherwise, each string in the string list designates one or more + source directories. + + @smallexample + for Source_Dirs use ("sources", "test/drivers"); + @end smallexample + + @noindent + If a string in the list ends with @code{"/**"}, then the directory whose path + name precedes the two asterisks, as well as all its subdirectories + (recursively), are source directories. + + @smallexample + for Source_Dirs use ("/system/sources/**"); + @end smallexample + + @noindent + Here the directory @code{/system/sources} and all of its subdirectories + (recursively) are source directories. + + To specify that the source directories are the directory of the project file + and all of its subdirectories, you can declare @code{Source_Dirs} as follows: + @smallexample + for Source_Dirs use ("./**"); + @end smallexample + + @noindent + Each of the source directories must exist and be readable. + + + @node Source File Names + @subsection Source File Names + + @noindent + In a project that contains source files, their names may be specified by the + attributes @code{Source_Files} (a string list) or @code{Source_List_File} + (a string). Source file names never include any directory information. + + If the attribute @code{Source_Files} is given an explicit value, then each + element of the list is a source file name. + + @smallexample + for Source_Files use ("main.adb"); + for Source_Files use ("main.adb", "pack1.ads", "pack2.adb"); + @end smallexample + + @noindent + If the attribute @code{Source_Files} is not given an explicit value, + but the attribute @code{Source_List_File} is given a string value, + then the source file names are contained in the text file whose path name + (absolute or relative to the directory of the project file) is the + value of the attribute @code{Source_List_File}. + + Each line in the file that is not empty or is not a comment + contains a source file name. A comment line starts with two hyphens. + + @smallexample + for Source_List_File use "source_list.txt"; + @end smallexample + + @noindent + By default, if neither the attribute @code{Source_Files} nor the attribute + @code{Source_List_File} is given an explicit value, then each file in the + source directories that conforms to the project's naming scheme + (see @ref{Naming Schemes}) is an immediate source of the project. + + A warning is issued if both attributes @code{Source_Files} and + @code{Source_List_File} are given explicit values. In this case, the attribute + @code{Source_Files} prevails. + + Each source file name must be the name of one and only one existing source file + in one of the source directories. + + A @code{Source_Files} attribute defined with an empty list as its value + indicates that there are no source files in the project. + + Except for projects that are clearly specified as containing no Ada source + files (@code{Source_Dirs} or @code{Source_Files} specified as an empty list, + or @code{Languages} specified without @code{"Ada"} in the list) + @smallexample + for Source_Dirs use (); + for Source_Files use (); + for Languages use ("C", "C++"); + @end smallexample + + @noindent + a project must contain at least one immediate source. + + Projects with no source files are useful as template packages + (see @ref{Packages in Project Files}) for other projects; in particular to + define a package @code{Naming} (see @ref{Naming Schemes}). + + + @c **************************** + @c * Importing Projects * + @c **************************** + + @node Importing Projects + @section Importing Projects + + @noindent + An immediate source of a project P may depend on source files that + are neither immediate sources of P nor in the predefined library. + To get this effect, P must @emph{import} the projects that contain the needed + source files. + + @smallexample + @group + with "project1", "utilities.gpr"; + with "/namings/apex.gpr"; + project Main is + ... + @end group + @end smallexample + + @noindent + As can be seen in this example, the syntax for importing projects is similar + to the syntax for importing compilation units in Ada. However, project files + use literal strings instead of names, and the @code{with} clause identifies + project files rather than packages. + + Each literal string is the file name or path name (absolute or relative) of a + project file. If a string is simply a file name, with no path, then its + location is determined by the @emph{project path}: + + @itemize @bullet + @item + If the environment variable @env{ADA_PROJECT_PATH} exists, then the project + path includes all the directories in this environment variable, plus the + directory of the project file. + + @item + If the environment variable @env{ADA_PROJECT_PATH} does not exist, + then the project path contains only one directory, namely the one where + the project file is located. + @end itemize + + @noindent + If a relative pathname is used as in + + @smallexample + with "tests/proj"; + @end smallexample + + @noindent + then the path is relative to the directory where the importing project file is + located. Any symbolic link will be fully resolved in the directory + of the importing project file before the imported project file is looked up. + + When the @code{with}'ed project file name does not have an extension, + the default is @file{.gpr}. If a file with this extension is not found, then + the file name as specified in the @code{with} clause (no extension) will be + used. In the above example, if a file @code{project1.gpr} is found, then it + will be used; otherwise, if a file @code{project1} exists then it will be used; + if neither file exists, this is an error. + + A warning is issued if the name of the project file does not match the + name of the project; this check is case insensitive. + + Any source file that is an immediate source of the imported project can be + used by the immediate sources of the importing project, and recursively. Thus + if @code{A} imports @code{B}, and @code{B} imports @code{C}, the immediate + sources of @code{A} may depend on the immediate sources of @code{C}, even if + @code{A} does not import @code{C} explicitly. However, this is not recommended, + because if and when @code{B} ceases to import @code{C}, some sources in + @code{A} will no longer compile. + + A side effect of this capability is that cyclic dependences are not permitted: + if @code{A} imports @code{B} (directly or indirectly) then @code{B} is not + allowed to import @code{A}. + + + @c ********************* + @c * Project Extension * + @c ********************* + + @node Project Extension + @section Project Extension + + @noindent + During development of a large system, it is sometimes necessary to use + modified versions of some of the source files without changing the original + sources. This can be achieved through a facility known as + @emph{project extension}. + + @smallexample + project Modified_Utilities extends "/baseline/utilities.gpr" is ... + @end smallexample + + @noindent + The project file for the project being extended (the @emph{parent}) is + identified by the literal string that follows the reserved word @code{extends}, + which itself follows the name of the extending project (the @emph{child}). + + By default, a child project inherits all the sources of its parent. + However, inherited sources can be overridden: a unit with the same name as one + in the parent will hide the original unit. + Inherited sources are considered to be sources (but not immediate sources) + of the child project; see @ref{Project File Syntax}. + + An inherited source file retains any switches specified in the parent project. + + For example if the project @code{Utilities} contains the specification and the + body of an Ada package @code{Util_IO}, then the project + @code{Modified_Utilities} can contain a new body for package @code{Util_IO}. + The original body of @code{Util_IO} will not be considered in program builds. + However, the package specification will still be found in the project + @code{Utilities}. + + A child project can have only one parent but it may import any number of other + projects. + + A project is not allowed to import directly or indirectly at the same time a + child project and any of its ancestors. + + + @c **************************************** + @c * External References in Project Files * + @c **************************************** + + @node External References in Project Files + @section External References in Project Files + + @noindent + A project file may contain references to external variables; such references + are called @emph{external references}. + + An external variable is either defined as part of the environment (an + environment variable in Unix, for example) or else specified on the command + line via the @option{-X@emph{vbl}=@emph{value}} switch. If both, then the + command line value is used. + + An external reference is denoted by the built-in function + @code{external}, which returns a string value. This function has two forms: + @itemize @bullet + @item @code{external (external_variable_name)} + @item @code{external (external_variable_name, default_value)} + @end itemize + + @noindent + Each parameter must be a string literal. For example: + + @smallexample + external ("USER") + external ("OS", "Linux") + @end smallexample + + @noindent + In the form with one parameter, the function returns the value of + the external variable given as parameter. If this name is not present in the + environment, then the returned value is an empty string. + + In the form with two string parameters, the second parameter is + the value returned when the variable given as the first parameter is not + present in the environment. In the example above, if @code{"OS"} is not + the name of an environment variable and is not passed on the command line, + then the returned value will be @code{"Linux"}. + + An external reference may be part of a string expression or of a string + list expression, to define variables or attributes. + + @smallexample + @group + type Mode_Type is ("Debug", "Release"); + Mode : Mode_Type := external ("MODE"); + case Mode is + when "Debug" => + ... + @end group + @end smallexample + + + @c ***************************** + @c * Packages in Project Files * + @c ***************************** + + @node Packages in Project Files + @section Packages in Project Files + + @noindent + The @emph{package} is the project file feature that defines the settings for + project-aware tools. + For each such tool you can declare a corresponding package; the names for these + packages are preset (see @ref{Packages}) but are not case sensitive. + A package may contain variable declarations, attribute declarations, and case + constructions. + + @smallexample + @group + project Proj is + package Builder is -- used by gnatmake + for Default_Switches ("Ada") use ("-v", "-g"); + end Builder; + end Proj; + @end group + @end smallexample + + @noindent + A package declaration starts with the reserved word @code{package}, + followed by the package name (case insensitive), followed by the reserved word + @code{is}. It ends with the reserved word @code{end}, followed by the package + name, finally followed by a semi-colon. + + Most of the packages have an attribute @code{Default_Switches}. + This attribute is an associative array, and its value is a string list. + The index of the associative array is the name of a programming language (case + insensitive). This attribute indicates the switch or switches to be used + with the corresponding tool. + + Some packages also have another attribute, @code{Switches}, an associative + array whose value is a string list. The index is the name of a source file. + This attribute indicates the switch or switches to be used by the corresponding + tool when dealing with this specific file. + + Further information on these switch-related attributes is found in + @ref{Switches and Project Files}. + + A package may be declared as a @emph{renaming} of another package; e.g., from + the project file for an imported project. + + @smallexample + @group + with "/global/apex.gpr"; + project Example is + package Naming renames Apex.Naming; + ... + end Example; + @end group + @end smallexample + + @noindent + Packages that are renamed in other project files often come from project files + that have no sources: they are just used as templates. Any modification in the + template will be reflected automatically in all the project files that rename + a package from the template. + + In addition to the tool-oriented packages, you can also declare a package + named @code{Naming} to establish specialized source file naming conventions + (see @ref{Naming Schemes}). + + + @c ************************************ + @c * Variables from Imported Projects * + @c ************************************ + + @node Variables from Imported Projects + @section Variables from Imported Projects + + @noindent + An attribute or variable defined in an imported or parent project can + be used in expressions in the importing / extending project. + Such an attribute or variable is prefixed with the name of the project + and (if relevant) the name of package where it is defined. + + @smallexample + @group + with "imported"; + project Main extends "base" is + Var1 := Imported.Var; + Var2 := Base.Var & ".new"; + @end group + + @group + package Builder is + for Default_Switches ("Ada") use Imported.Builder.Ada_Switches & + "-gnatg" & "-v"; + end Builder; + @end group + + @group + package Compiler is + for Default_Switches ("Ada") use Base.Compiler.Ada_Switches; + end Compiler; + end Main; + @end group + @end smallexample + + @noindent + In this example: + + @itemize @bullet + @item + @code{Var1} is a copy of the variable @code{Var} defined in the project file + @file{"imported.gpr"} + @item + the value of @code{Var2} is a copy of the value of variable @code{Var} + defined in the project file @file{base.gpr}, concatenated with @code{".new"} + @item + attribute @code{Default_Switches ("Ada")} in package @code{Builder} + is a string list that includes in its value a copy of variable + @code{Ada_Switches} defined in the @code{Builder} package in project file + @file{imported.gpr} plus two new elements: @option{"-gnatg"} and @option{"-v"}; + @item + attribute @code{Default_Switches ("Ada")} in package @code{Compiler} + is a copy of the variable @code{Ada_Switches} defined in the @code{Compiler} + package in project file @file{base.gpr}, the project being extended. + @end itemize + + + @c ****************** + @c * Naming Schemes * + @c ****************** + + @node Naming Schemes + @section Naming Schemes + + @noindent + Sometimes an Ada software system is ported from a foreign compilation + environment to GNAT, with file names that do not use the default GNAT + conventions. Instead of changing all the file names (which for a variety of + reasons might not be possible), you can define the relevant file naming scheme + in the @code{Naming} package in your project file. For example, the following + package models the Apex file naming rules: + + @smallexample + @group + package Naming is + for Casing use "lowercase"; + for Dot_Replacement use "."; + for Specification_Suffix ("Ada") use ".1.ada"; + for Implementation_Suffix ("Ada") use ".2.ada"; + end Naming; + @end group + @end smallexample + + @noindent + You can define the following attributes in package @code{Naming}: + + @table @code + + @item @var{Casing} + This must be a string with one of the three values @code{"lowercase"}, + @code{"uppercase"} or @code{"mixedcase"}; these strings are case insensitive. + + @noindent + If @var{Casing} is not specified, then the default is @code{"lowercase"}. + + @item @var{Dot_Replacement} + This must be a string whose value satisfies the following conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start or end with an alphanumeric character + @item It cannot be a single underscore + @item It cannot start with an underscore followed by an alphanumeric + @item It cannot contain a dot @code{'.'} except if it the entire string is @code{"."} + @end itemize + + @noindent + If @code{Dot_Replacement} is not specified, then the default is @code{"-"}. + + @item @var{Specification_Suffix} + This is an associative array (indexed by the programming language name, case + insensitive) whose value is a string that must satisfy the following + conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start with an alphanumeric character + @item It cannot start with an underscore followed by an alphanumeric character + @end itemize + @noindent + If @code{Specification_Suffix ("Ada")} is not specified, then the default is + @code{".ads"}. + + @item @var{Implementation_Suffix} + This is an associative array (indexed by the programming language name, case + insensitive) whose value is a string that must satisfy the following + conditions: + + @itemize @bullet + @item It must not be empty + @item It cannot start with an alphanumeric character + @item It cannot start with an underscore followed by an alphanumeric character + @item It cannot be a suffix of @code{Specification_Suffix} + @end itemize + @noindent + If @code{Implementation_Suffix ("Ada")} is not specified, then the default is + @code{".adb"}. + + @item @var{Separate_Suffix} + This must be a string whose value satisfies the same conditions as + @code{Implementation_Suffix}. + + @noindent + If @code{Separate_Suffix ("Ada")} is not specified, then it defaults to same + value as @code{Implementation_Suffix ("Ada")}. + + @item @var{Specification} + @noindent + You can use the @code{Specification} attribute, an associative array, to define + the source file name for an individual Ada compilation unit's spec. The array + index must be a string literal that identifies the Ada unit (case insensitive). + The value of this attribute must be a string that identifies the file that + contains this unit's spec (case sensitive or insensitive depending on the + operating system). + + @smallexample + for Specification ("MyPack.MyChild") use "mypack.mychild.spec"; + @end smallexample + + @item @var{Implementation} + + You can use the @code{Implementation} attribute, an associative array, to + define the source file name for an individual Ada compilation unit's body + (possibly a subunit). The array index must be a string literal that identifies + the Ada unit (case insensitive). The value of this attribute must be a string + that identifies the file that contains this unit's body or subunit (case + sensitive or insensitive depending on the operating system). + + @smallexample + for Implementation ("MyPack.MyChild") use "mypack.mychild.body"; + @end smallexample + @end table + + + @c ******************** + @c * Library Projects * + @c ******************** + + @node Library Projects + @section Library Projects + + @noindent + @emph{Library projects} are projects whose object code is placed in a library. + (Note that this facility is not yet supported on all platforms) + + To create a library project, you need to define in its project file + two project-level attributes: @code{Library_Name} and @code{Library_Dir}. + Additionally, you may define the library-related attributes + @code{Library_Kind}, @code{Library_Version} and @code{Library_Elaboration}. + + The @code{Library_Name} attribute has a string value that must start with a + letter and include only letters and digits. + + The @code{Library_Dir} attribute has a string value that designates the path + (absolute or relative) of the directory where the library will reside. + It must designate an existing directory, and this directory needs to be + different from the project's object directory. It also needs to be writable. + + If both @code{Library_Name} and @code{Library_Dir} are specified and + are legal, then the project file defines a library project. The optional + library-related attributes are checked only for such project files. + + The @code{Library_Kind} attribute has a string value that must be one of the + following (case insensitive): @code{"static"}, @code{"dynamic"} or + @code{"relocatable"}. If this attribute is not specified, the library is a + static library. Otherwise, the library may be dynamic or relocatable. + Depending on the operating system, there may or may not be a distinction + between dynamic and relocatable libraries. For example, on Unix there is no + such distinction. + + The @code{Library_Version} attribute has a string value whose interpretation + is platform dependent. On Unix, it is used only for dynamic/relocatable + libraries as the internal name of the library (the @code{"soname"}). If the + library file name (built from the @code{Library_Name}) is different from the + @code{Library_Version}, then the library file will be a symbolic link to the + actual file whose name will be @code{Library_Version}. + + Example (on Unix): + + @smallexample + @group + project Plib is + + Version := "1"; + + for Library_Dir use "lib_dir"; + for Library_Name use "dummy"; + for Library_Kind use "relocatable"; + for Library_Version use "libdummy.so." & Version; + + end Plib; + @end group + @end smallexample + + @noindent + Directory @file{lib_dir} will contain the internal library file whose name + will be @file{libdummy.so.1}, and @file{libdummy.so} will be a symbolic link to + @file{libdummy.so.1}. + + When @command{gnatmake} detects that a project file (not the main project file) + is a library project file, it will check all immediate sources of the project + and rebuild the library if any of the sources have been recompiled. + All @file{ALI} files will also be copied from the object directory to the + library directory. To build executables, @command{gnatmake} will use the + library rather than the individual object files. + + + @c ************************************* + @c * Switches Related to Project Files * + @c ************************************* + @node Switches Related to Project Files + @section Switches Related to Project Files + + @noindent + The following switches are used by GNAT tools that support project files: + + @table @code + + @item @option{-P@var{project}} + Indicates the name of a project file. This project file will be parsed with + the verbosity indicated by @option{-vP@emph{x}}, if any, and using the external + references indicated by @option{-X} switches, if any. + + @noindent + There must be only one @option{-P} switch on the command line. + + @noindent + Since the Project Manager parses the project file only after all the switches + on the command line are checked, the order of the switches @option{-P}, + @option{-Vp@emph{x}} or @option{-X} is not significant. + + @item @option{-X@var{name=value}} + Indicates that external variable @var{name} has the value @var{value}. + The Project Manager will use this value for occurrences of + @code{external(name)} when parsing the project file. + + @noindent + If @var{name} or @var{value} includes a space, then @var{name=value} should be + put between quotes. + @smallexample + -XOS=NT + -X"user=John Doe" + @end smallexample + + @noindent + Several @option{-X} switches can be used simultaneously. + If several @option{-X} switches specify the same @var{name}, only the last one + is used. + + @noindent + An external variable specified with a @option{-X} switch takes precedence + over the value of the same name in the environment. + + @item @option{-vP@emph{x}} + Indicates the verbosity of the parsing of GNAT project files. + @option{-vP0} means Default (no output for syntactically correct project + files); + @option{-vP1} means Medium; + @option{-vP2} means High. + @noindent + The default is Default. + @noindent + If several @option{-vP@emph{x}} switches are present, only the last one is + used. + + @end table + + + @c ********************************** + @c * Tools Supporting Project Files * + @c ********************************** + + @node Tools Supporting Project Files + @section Tools Supporting Project Files + + @menu + * gnatmake and Project Files:: + * The GNAT Driver and Project Files:: + * Glide and Project Files:: + @end menu + + @node gnatmake and Project Files + @subsection gnatmake and Project Files + + @noindent + This section covers two topics related to @command{gnatmake} and project files: + defining switches for @command{gnatmake} and for the tools that it invokes; + and the use of the @code{Main} attribute. + + @menu + * Switches and Project Files:: + * Project Files and Main Subprograms:: + @end menu + + @node Switches and Project Files + @subsubsection Switches and Project Files + + @noindent + For each of the packages @code{Builder}, @code{Compiler}, @code{Binder}, and + @code{Linker}, you can specify a @code{Default_Switches} attribute, a + @code{Switches} attribute, or both; as their names imply, these switch-related + attributes affect which switches are used for which files when + @command{gnatmake} is invoked. As will be explained below, these + package-contributed switches precede the switches passed on the + @command{gnatmake} command line. + + The @code{Default_Switches} attribute is an associative array indexed by + language name (case insensitive) and returning a string list. For example: + + @smallexample + @group + package Compiler is + for Default_Switches ("Ada") use ("-gnaty", "-v"); + end Compiler; + @end group + @end smallexample + + @noindent + The @code{Switches} attribute is also an associative array, indexed by a file + name (which may or may not be case sensitive, depending on the operating + system) and returning a string list. For example: + + @smallexample + @group + package Builder is + for Switches ("main1.adb") use ("-O2"); + for Switches ("main2.adb") use ("-g"); + end Builder; + @end group + @end smallexample + + @noindent + For the @code{Builder} package, the file names should designate source files + for main subprograms. For the @code{Binder} and @code{Linker} packages, the + file names should designate @file{ALI} or source files for main subprograms. + In each case just the file name (without explicit extension) is acceptable. + + For each tool used in a program build (@command{gnatmake}, the compiler, the + binder, and the linker), its corresponding package @dfn{contributes} a set of + switches for each file on which the tool is invoked, based on the + switch-related attributes defined in the package. In particular, the switches + that each of these packages contributes for a given file @var{f} comprise: + + @itemize @bullet + @item + the value of attribute @code{Switches (@var{f})}, if it is specified in the + package for the given file, + @item + otherwise, the value of @code{Default_Switches ("Ada")}, if it is specified in + the package. + @end itemize + + @noindent + If neither of these attributes is defined in the package, then the package does + not contribute any switches for the given file. + + When @command{gnatmake} is invoked on a file, the switches comprise two sets, + in the following order: those contributed for the file by the @code{Builder} + package; and the switches passed on the command line. + + When @command{gnatmake} invokes a tool (compiler, binder, linker) on a file, + the switches passed to the tool comprise three sets, in the following order: + + @enumerate + @item + the applicable switches contributed for the file by the @code{Builder} package + in the project file supplied on the command line; + + @item + those contributed for the file by the package (in the relevant project file -- + see below) corresponding to the tool; and + + @item + the applicable switches passed on the command line. + @end enumerate + + @noindent + The term @emph{applicable switches} reflects the fact that @command{gnatmake} + switches may or may not be passed to individual tools, depending on the + individual switch. + + @command{gnatmake} may invoke the compiler on source files from different + projects. The Project Manager will use the appropriate project file to + determine the @code{Compiler} package for each source file being compiled. + Likewise for the @code{Binder} and @code{Linker} packages. + + As an example, consider the following package in a project file: + + @smallexample + @group + project Proj1 is + package Compiler is + for Default_Switches ("Ada") use ("-g"); + for Switches ("a.adb") use ("-O1"); + for Switches ("b.adb") use ("-O2", "-gnaty"); + end Compiler; + end Proj1; + @end group + @end smallexample + + @noindent + If @command{gnatmake} is invoked with this project file, and it needs to + compile, say, the files @file{a.adb}, @file{b.adb}, and @file{c.adb}, then + @file{a.adb} will be compiled with the switch @option{-O1}, @file{b.adb} + with switches @option{-O2} and @option{-gnaty}, and @file{c.adb} with + @option{-g}. + + Another example illustrates the ordering of the switches contributed by + different packages: + + @smallexample + @group + project Proj2 is + package Builder is + for Switches ("main.adb") use ("-g", "-O1", "-f"); + end Builder; + @end group + + @group + package Compiler is + for Switches ("main.adb") use ("-O2"); + end Compiler; + end Proj2; + @end group + @end smallexample + + @noindent + If you issue the command: + + @smallexample + gnatmake -PProj2 -O0 main + @end smallexample + + @noindent + then the compiler will be invoked on @file{main.adb} with the following sequence of switches + + @smallexample + -g -O1 -O2 -O0 + @end smallexample + + with the last @option{-O} switch having precedence over the earlier ones; + several other switches (such as @option{-c}) are added implicitly. + + The switches @option{-g} and @option{-O1} are contributed by package + @code{Builder}, @option{-O2} is contributed by the package @code{Compiler} + and @option{-O0} comes from the command line. + + The @option{-g} switch will also be passed in the invocation of + @command{gnatlink.} + + A final example illustrates switch contributions from packages in different + project files: + + @smallexample + @group + project Proj3 is + for Source_Files use ("pack.ads", "pack.adb"); + package Compiler is + for Default_Switches ("Ada") use ("-gnata"); + end Compiler; + end Proj3; + @end group + + @group + with "Proj3"; + project Proj4 is + for Source_Files use ("foo_main.adb", "bar_main.adb"); + package Builder is + for Switches ("foo_main.adb") use ("-s", "-g"); + end Builder; + end Proj4; + @end group + + @group + -- Ada source file: + with Pack; + procedure Foo_Main is + ... + end Foo_Main; + @end group + @end smallexample + + If the command is + @smallexample + gnatmake -PProj4 foo_main.adb -cargs -gnato + @end smallexample + + @noindent + then the switches passed to the compiler for @file{foo_main.adb} are + @option{-g} (contributed by the package @code{Proj4.Builder}) and + @option{-gnato} (passed on the command line). + When the imported package @code{Pack} is compiled, the switches used are + @option{-g} from @code{Proj4.Builder}, @option{-gnata} (contributed from + package @code{Proj3.Compiler}, and @option{-gnato} from the command line. + + + @node Project Files and Main Subprograms + @subsubsection Project Files and Main Subprograms + + @noindent + When using a project file, you can invoke @command{gnatmake} + with several main subprograms, by specifying their source files on the command + line. Each of these needs to be an immediate source file of the project. + + @smallexample + gnatmake -Pprj main1 main2 main3 + @end smallexample + + @noindent + When using a project file, you can also invoke @command{gnatmake} without + explicitly specifying any main, and the effect depends on whether you have + defined the @code{Main} attribute. This attribute has a string list value, + where each element in the list is the name of a source file (the file + extension is optional) containing a main subprogram. + + If the @code{Main} attribute is defined in a project file as a non-empty + string list and the switch @option{-u} is not used on the command line, then + invoking @command{gnatmake} with this project file but without any main on the + command line is equivalent to invoking @command{gnatmake} with all the file + names in the @code{Main} attribute on the command line. + + Example: + @smallexample + @group + project Prj is + for Main use ("main1", "main2", "main3"); + end Prj; + @end group + @end smallexample + + @noindent + With this project file, @code{"gnatmake -Pprj"} is equivalent to + @code{"gnatmake -Pprj main1 main2 main3"}. + + When the project attribute @code{Main} is not specified, or is specified + as an empty string list, or when the switch @option{-u} is used on the command + line, then invoking @command{gnatmake} with no main on the command line will + result in all immediate sources of the project file being checked, and + potentially recompiled. Depending on the presence of the switch @option{-u}, + sources from other project files on which the immediate sources of the main + project file depend are also checked and potentially recompiled. In other + words, the @option{-u} switch is applied to all of the immediate sources of themain project file. + + + @node The GNAT Driver and Project Files + @subsection The GNAT Driver and Project Files + + @noindent + A number of GNAT tools, other than @command{gnatmake} are project-aware: + @command{gnatbind}, @command{gnatfind}, @command{gnatlink}, @command{gnatls} + and @command{gnatxref}. However, none of these tools can be invoked directly + with a project file switch (@code{-P}). They need to be invoke through the + @command{gnat} driver. + + The @command{gnat} driver is a front-end that accepts a number of commands and + call the corresponding tool. It has been designed initially for VMS to convert + VMS style qualifiers to Unix style switches, but it is now available to all + the GNAT supported platforms. + + On non VMS platforms, the @command{gnat} driver accepts the following commands + (case insensitive): + + @itemize @bullet + @item + BIND to invoke @command{gnatbind} + @item + CHOP to invoke @command{gnatchop} + @item + COMP or COMPILE to invoke the compiler + @item + ELIM to invoke @command{gnatelim} + @item + FIND to invoke @command{gnatfind} + @item + KR or KRUNCH to invoke @command{gnatkr} + @item + LINK to invoke @command{gnatlink} + @item + LS or LIST to invoke @command{gnatls} + @item + MAKE to invoke @command{gnatmake} + @item + NAME to invoke @command{gnatname} + @item + PREP or PREPROCESS to invoke @command{gnatprep} + @item + PSTA or STANDARD to invoke @command{gnatpsta} + @item + STUB to invoke @command{gnatstub} + @item + XREF to invoke @command{gnatxref} + @end itemize + + @noindent + Note that the compiler is invoked using the command @command{gnatmake -f -u}. + + @noindent + Following the command, you may put switches and arguments for the invoked + tool. + + @smallexample + gnat bind -C main.ali + gnat ls -a main + gnat chop foo.txt + @end smallexample + + @noindent + In addition, for command BIND, FIND, LS or LIST, LINK and XREF, the project + file related switches (@code{-P}, @code{-X} and @code{-vPx}) may be used in + addition to the switches of the invoking tool. + + @noindent + For each of these command, there is possibly a package in the main project that + corresponds to the invoked tool. + + @itemize @bullet + @item + package @code{Binder} for command BIND (invoking @code{gnatbind}) + + @item + package @code{Finder} for command FIND (invoking @code{gnatfind}) + + @item + package @code{Gnatls} for command LS or LIST (invoking @code{gnatls}) + + @item + package @code{Linker} for command LINK (invoking @code{gnatlink}) + + @item + package @code{Cross_Reference} for command XREF (invoking @code{gnatlink}) + + @end itemize + + @noindent + Package @code{Gnatls} has a unique attribute @code{Switches}, a simple variable + with a string list value. It contains switches for the invocation of + @code{gnatls}. + + @smallexample + @group + project Proj1 is + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + end Proj1; + @end group + @end smallexample + + @noindent + All other packages contains a switch @code{Default_Switches}, an associative + array, indexed by the programming language (case insensitive) and having a + string list value. @code{Default_Switches ("Ada")} contains the switches for + the invocation of the tool corresponding to the package. + + @smallexample + @group + project Proj is + + for Source_Dirs use ("./**"); + + package gnatls is + for Switches use ("-a", "-v"); + end gnatls; + @end group + @group + + package Binder is + for Default_Switches ("Ada") use ("-C", "-e"); + end Binder; + @end group + @group + + package Linker is + for Default_Switches ("Ada") use ("-C"); + end Linker; + @end group + @group + + package Finder is + for Default_Switches ("Ada") use ("-a", "-f"); + end Finder; + @end group + @group + + package Cross_Reference is + for Default_Switches ("Ada") use ("-a", "-f", "-d", "-u"); + end Cross_Reference; + end Proj; + @end group + @end smallexample + + @noindent + With the above project file, commands such as + + @smallexample + gnat ls -Pproj main + gnat xref -Pproj main + gnat bind -Pproj main.ali + @end smallexample + + @noindent + will set up the environment properly and invoke the tool with the switches + found in the package corresponding to the tool. + + + @node Glide and Project Files + @subsection Glide and Project Files + + @noindent + Glide will automatically recognize the @file{.gpr} extension for + project files, and will + convert them to its own internal format automatically. However, it + doesn't provide a syntax-oriented editor for modifying these + files. + The project file will be loaded as text when you select the menu item + @code{Ada} @result{} @code{Project} @result{} @code{Edit}. + You can edit this text and save the @file{gpr} file; + when you next select this project file in Glide it + will be automatically reloaded. + + + + @node An Extended Example + @section An Extended Example + + @noindent + Suppose that we have two programs, @var{prog1} and @var{prog2}, with the sources + in the respective directories. We would like to build them with a single + @command{gnatmake} command, and we would like to place their object files into + @file{.build} subdirectories of the source directories. Furthermore, we would + like to have to have two separate subdirectories in @file{.build} -- + @file{release} and @file{debug} -- which will contain the object files compiled with + different set of compilation flags. + + In other words, we have the following structure: + + @smallexample + @group + main + |- prog1 + | |- .build + | | debug + | | release + |- prog2 + |- .build + | debug + | release + @end group + @end smallexample + + @noindent + Here are the project files that we need to create in a directory @file{main} + to maintain this structure: + + @enumerate + + @item We create a @code{Common} project with a package @code{Compiler} that + specifies the compilation switches: + + @smallexample + File "common.gpr": + @group + @b{project} Common @b{is} + + @b{for} Source_Dirs @b{use} (); -- No source files + @end group + + @group + @b{type} Build_Type @b{is} ("release", "debug"); + Build : Build_Type := External ("BUILD", "debug"); + @end group + @group + @b{package} Compiler @b{is} + @b{case} Build @b{is} + @b{when} "release" => + @b{for} Default_Switches ("Ada") @b{use} ("-O2"); + @b{when} "debug" => + @b{for} Default_Switches ("Ada") @b{use} ("-g"); + @b{end case}; + @b{end} Compiler; + + @b{end} Common; + @end group + @end smallexample + + @item We create separate projects for the two programs: + + @smallexample + @group + File "prog1.gpr": + + @b{with} "common"; + @b{project} Prog1 @b{is} + + @b{for} Source_Dirs @b{use} ("prog1"); + @b{for} Object_Dir @b{use} "prog1/.build/" & Common.Build; + + @b{package} Compiler @b{renames} Common.Compiler; + + @b{end} Prog1; + @end group + @end smallexample + + @smallexample + @group + File "prog2.gpr": + + @b{with} "common"; + @b{project} Prog2 @b{is} + + @b{for} Source_Dirs @b{use} ("prog2"); + @b{for} Object_Dir @b{use} "prog2/.build/" & Common.Build; + + @b{package} Compiler @b{renames} Common.Compiler; + + @end group + @b{end} Prog2; + @end smallexample + + @item We create a wrapping project @var{Main}: + + @smallexample + @group + File "main.gpr": + + @b{with} "common"; + @b{with} "prog1"; + @b{with} "prog2"; + @b{project} Main @b{is} + + @b{package} Compiler @b{renames} Common.Compiler; + + @b{end} Main; + @end group + @end smallexample + + @item Finally we need to create a dummy procedure that @code{with}s (either + explicitly or implicitly) all the sources of our two programs. + + @end enumerate + + @noindent + Now we can build the programs using the command + + @smallexample + gnatmake -Pmain dummy + @end smallexample + + @noindent + for the Debug mode, or + + @smallexample + gnatmake -Pmain -XBUILD=release + @end smallexample + + @noindent + for the Release mode. + + + @c ******************************** + @c * Project File Complete Syntax * + @c ******************************** + + @node Project File Complete Syntax + @section Project File Complete Syntax + + @smallexample + project ::= + context_clause project_declaration + + context_clause ::= + @{with_clause@} + + with_clause ::= + @b{with} literal_string @{ , literal_string @} ; + + project_declaration ::= + @b{project} simple_name [ @b{extends} literal_string ] @b{is} + @{declarative_item@} + @b{end} simple_name; + + declarative_item ::= + package_declaration | + typed_string_declaration | + other_declarative_item + + package_declaration ::= + @b{package} simple_name package_completion + + package_completion ::= + package_body | package_renaming + + package body ::= + @b{is} + @{other_declarative_item@} + @b{end} simple_name ; + + package_renaming ::== + @b{renames} simple_name.simple_name ; + + typed_string_declaration ::= + @b{type} _simple_name @b{is} + ( literal_string @{, literal_string@} ); + + other_declarative_item ::= + attribute_declaration | + typed_variable_declaration | + variable_declaration | + case_construction + + attribute_declaration ::= + @b{for} attribute @b{use} expression ; + + attribute ::= + simple_name | + simple_name ( literal_string ) + + typed_variable_declaration ::= + simple_name : name := string_expression ; + + variable_declaration ::= + simple_name := expression; + + expression ::= + term @{& term@} + + term ::= + literal_string | + string_list | + name | + external_value | + attribute_reference + + literal_string ::= + (same as Ada) + + string_list ::= + ( expression @{ , expression @} ) + + external_value ::= + @b{external} ( literal_string [, literal_string] ) + + attribute_reference ::= + attribute_parent ' simple_name [ ( literal_string ) ] + + attribute_parent ::= + @b{project} | + simple_name | + simple_name . simple_name + + case_construction ::= + @b{case} name @b{is} + @{case_item@} + @b{end case} ; + + case_item ::= + @b{when} discrete_choice_list => @{case_construction | attribute_declaration@} + + discrete_choice_list ::= + literal_string @{| literal_string@} + + name ::= + simple_name @{. simple_name@} + + simple_name ::= + identifier (same as Ada) + + @end smallexample + + + @node Elaboration Order Handling in GNAT + @chapter Elaboration Order Handling in GNAT + @cindex Order of elaboration + @cindex Elaboration control + + @menu + * Elaboration Code in Ada 95:: + * Checking the Elaboration Order in Ada 95:: + * Controlling the Elaboration Order in Ada 95:: + * Controlling Elaboration in GNAT - Internal Calls:: + * Controlling Elaboration in GNAT - External Calls:: + * Default Behavior in GNAT - Ensuring Safety:: + * Elaboration Issues for Library Tasks:: + * Mixing Elaboration Models:: + * What to Do If the Default Elaboration Behavior Fails:: + * Elaboration for Access-to-Subprogram Values:: + * Summary of Procedures for Elaboration Control:: + * Other Elaboration Order Considerations:: + @end menu + + @noindent + This chapter describes the handling of elaboration code in Ada 95 and + in GNAT, and discusses how the order of elaboration of program units can + be controlled in GNAT, either automatically or with explicit programming + features. + + @node Elaboration Code in Ada 95 + @section Elaboration Code in Ada 95 + + @noindent + Ada 95 provides rather general mechanisms for executing code at elaboration + time, that is to say before the main program starts executing. Such code arises + in three contexts: + + @table @asis + @item Initializers for variables. + Variables declared at the library level, in package specs or bodies, can + require initialization that is performed at elaboration time, as in: + @smallexample + @cartouche + Sqrt_Half : Float := Sqrt (0.5); + @end cartouche + @end smallexample + + @item Package initialization code + Code in a @code{BEGIN-END} section at the outer level of a package body is + executed as part of the package body elaboration code. + + @item Library level task allocators + Tasks that are declared using task allocators at the library level + start executing immediately and hence can execute at elaboration time. + @end table + + @noindent + Subprogram calls are possible in any of these contexts, which means that + any arbitrary part of the program may be executed as part of the elaboration + code. It is even possible to write a program which does all its work at + elaboration time, with a null main program, although stylistically this + would usually be considered an inappropriate way to structure + a program. + + An important concern arises in the context of elaboration code: + we have to be sure that it is executed in an appropriate order. What we + have is a series of elaboration code sections, potentially one section + for each unit in the program. It is important that these execute + in the correct order. Correctness here means that, taking the above + example of the declaration of @code{Sqrt_Half}, + if some other piece of + elaboration code references @code{Sqrt_Half}, + then it must run after the + section of elaboration code that contains the declaration of + @code{Sqrt_Half}. + + There would never be any order of elaboration problem if we made a rule + that whenever you @code{with} a unit, you must elaborate both the spec and body + of that unit before elaborating the unit doing the @code{with}'ing: + + @smallexample + @group + @cartouche + @b{with} Unit_1; + @b{package} Unit_2 @b{is} ... + @end cartouche + @end group + @end smallexample + + @noindent + would require that both the body and spec of @code{Unit_1} be elaborated + before the spec of @code{Unit_2}. However, a rule like that would be far too + restrictive. In particular, it would make it impossible to have routines + in separate packages that were mutually recursive. + + You might think that a clever enough compiler could look at the actual + elaboration code and determine an appropriate correct order of elaboration, + but in the general case, this is not possible. Consider the following + example. + + In the body of @code{Unit_1}, we have a procedure @code{Func_1} + that references + the variable @code{Sqrt_1}, which is declared in the elaboration code + of the body of @code{Unit_1}: + + @smallexample + @cartouche + Sqrt_1 : Float := Sqrt (0.1); + @end cartouche + @end smallexample + + @noindent + The elaboration code of the body of @code{Unit_1} also contains: + + @smallexample + @group + @cartouche + @b{if} expression_1 = 1 @b{then} + Q := Unit_2.Func_2; + @b{end if}; + @end cartouche + @end group + @end smallexample + + @noindent + @code{Unit_2} is exactly parallel, + it has a procedure @code{Func_2} that references + the variable @code{Sqrt_2}, which is declared in the elaboration code of + the body @code{Unit_2}: + + @smallexample + @cartouche + Sqrt_2 : Float := Sqrt (0.1); + @end cartouche + @end smallexample + + @noindent + The elaboration code of the body of @code{Unit_2} also contains: + + @smallexample + @group + @cartouche + @b{if} expression_2 = 2 @b{then} + Q := Unit_1.Func_1; + @b{end if}; + @end cartouche + @end group + @end smallexample + + @noindent + Now the question is, which of the following orders of elaboration is + acceptable: + + @smallexample + @group + Spec of Unit_1 + Spec of Unit_2 + Body of Unit_1 + Body of Unit_2 + @end group + @end smallexample + + @noindent + or + + @smallexample + @group + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_2 + Body of Unit_1 + @end group + @end smallexample + + @noindent + If you carefully analyze the flow here, you will see that you cannot tell + at compile time the answer to this question. + If @code{expression_1} is not equal to 1, + and @code{expression_2} is not equal to 2, + then either order is acceptable, because neither of the function calls is + executed. If both tests evaluate to true, then neither order is acceptable + and in fact there is no correct order. + + If one of the two expressions is true, and the other is false, then one + of the above orders is correct, and the other is incorrect. For example, + if @code{expression_1} = 1 and @code{expression_2} /= 2, + then the call to @code{Func_2} + will occur, but not the call to @code{Func_1.} + This means that it is essential + to elaborate the body of @code{Unit_1} before + the body of @code{Unit_2}, so the first + order of elaboration is correct and the second is wrong. + + By making @code{expression_1} and @code{expression_2} + depend on input data, or perhaps + the time of day, we can make it impossible for the compiler or binder + to figure out which of these expressions will be true, and hence it + is impossible to guarantee a safe order of elaboration at run time. + + @node Checking the Elaboration Order in Ada 95 + @section Checking the Elaboration Order in Ada 95 + + @noindent + In some languages that involve the same kind of elaboration problems, + e.g. Java and C++, the programmer is expected to worry about these + ordering problems himself, and it is common to + write a program in which an incorrect elaboration order gives + surprising results, because it references variables before they + are initialized. + Ada 95 is designed to be a safe language, and a programmer-beware approach is + clearly not sufficient. Consequently, the language provides three lines + of defense: + + @table @asis + @item Standard rules + Some standard rules restrict the possible choice of elaboration + order. In particular, if you @code{with} a unit, then its spec is always + elaborated before the unit doing the @code{with}. Similarly, a parent + spec is always elaborated before the child spec, and finally + a spec is always elaborated before its corresponding body. + + @item Dynamic elaboration checks + @cindex Elaboration checks + @cindex Checks, elaboration + Dynamic checks are made at run time, so that if some entity is accessed + before it is elaborated (typically by means of a subprogram call) + then the exception (@code{Program_Error}) is raised. + + @item Elaboration control + Facilities are provided for the programmer to specify the desired order + of elaboration. + @end table + + Let's look at these facilities in more detail. First, the rules for + dynamic checking. One possible rule would be simply to say that the + exception is raised if you access a variable which has not yet been + elaborated. The trouble with this approach is that it could require + expensive checks on every variable reference. Instead Ada 95 has two + rules which are a little more restrictive, but easier to check, and + easier to state: + + @table @asis + @item Restrictions on calls + A subprogram can only be called at elaboration time if its body + has been elaborated. The rules for elaboration given above guarantee + that the spec of the subprogram has been elaborated before the + call, but not the body. If this rule is violated, then the + exception @code{Program_Error} is raised. + + @item Restrictions on instantiations + A generic unit can only be instantiated if the body of the generic + unit has been elaborated. Again, the rules for elaboration given above + guarantee that the spec of the generic unit has been elaborated + before the instantiation, but not the body. If this rule is + violated, then the exception @code{Program_Error} is raised. + @end table + + @noindent + The idea is that if the body has been elaborated, then any variables + it references must have been elaborated; by checking for the body being + elaborated we guarantee that none of its references causes any + trouble. As we noted above, this is a little too restrictive, because a + subprogram that has no non-local references in its body may in fact be safe + to call. However, it really would be unsafe to rely on this, because + it would mean that the caller was aware of details of the implementation + in the body. This goes against the basic tenets of Ada. + + A plausible implementation can be described as follows. + A Boolean variable is associated with each subprogram + and each generic unit. This variable is initialized to False, and is set to + True at the point body is elaborated. Every call or instantiation checks the + variable, and raises @code{Program_Error} if the variable is False. + + Note that one might think that it would be good enough to have one Boolean + variable for each package, but that would not deal with cases of trying + to call a body in the same package as the call + that has not been elaborated yet. + Of course a compiler may be able to do enough analysis to optimize away + some of the Boolean variables as unnecessary, and @code{GNAT} indeed + does such optimizations, but still the easiest conceptual model is to + think of there being one variable per subprogram. + + @node Controlling the Elaboration Order in Ada 95 + @section Controlling the Elaboration Order in Ada 95 + + @noindent + In the previous section we discussed the rules in Ada 95 which ensure + that @code{Program_Error} is raised if an incorrect elaboration order is + chosen. This prevents erroneous executions, but we need mechanisms to + specify a correct execution and avoid the exception altogether. + To achieve this, Ada 95 provides a number of features for controlling + the order of elaboration. We discuss these features in this section. + + First, there are several ways of indicating to the compiler that a given + unit has no elaboration problems: + + @table @asis + @item packages that do not require a body + In Ada 95, a library package that does not require a body does not permit + a body. This means that if we have a such a package, as in: + + @smallexample + @group + @cartouche + @b{package} Definitions @b{is} + @b{generic} + @b{type} m @b{is new} integer; + @b{package} Subp @b{is} + @b{type} a @b{is array} (1 .. 10) @b{of} m; + @b{type} b @b{is array} (1 .. 20) @b{of} m; + @b{end} Subp; + @b{end} Definitions; + @end cartouche + @end group + @end smallexample + + @noindent + A package that @code{with}'s @code{Definitions} may safely instantiate + @code{Definitions.Subp} because the compiler can determine that there + definitely is no package body to worry about in this case + + @item pragma Pure + @cindex pragma Pure + @findex Pure + Places sufficient restrictions on a unit to guarantee that + no call to any subprogram in the unit can result in an + elaboration problem. This means that the compiler does not need + to worry about the point of elaboration of such units, and in + particular, does not need to check any calls to any subprograms + in this unit. + + @item pragma Preelaborate + @findex Preelaborate + @cindex pragma Preelaborate + This pragma places slightly less stringent restrictions on a unit than + does pragma Pure, + but these restrictions are still sufficient to ensure that there + are no elaboration problems with any calls to the unit. + + @item pragma Elaborate_Body + @findex Elaborate_Body + @cindex pragma Elaborate_Body + This pragma requires that the body of a unit be elaborated immediately + after its spec. Suppose a unit @code{A} has such a pragma, + and unit @code{B} does + a @code{with} of unit @code{A}. Recall that the standard rules require + the spec of unit @code{A} + to be elaborated before the @code{with}'ing unit; given the pragma in + @code{A}, we also know that the body of @code{A} + will be elaborated before @code{B}, so + that calls to @code{A} are safe and do not need a check. + @end table + + @noindent + Note that, + unlike pragma @code{Pure} and pragma @code{Preelaborate}, + the use of + @code{Elaborate_Body} does not guarantee that the program is + free of elaboration problems, because it may not be possible + to satisfy the requested elaboration order. + Let's go back to the example with @code{Unit_1} and @code{Unit_2}. + If a programmer + marks @code{Unit_1} as @code{Elaborate_Body}, + and not @code{Unit_2,} then the order of + elaboration will be: + + @smallexample + @group + Spec of Unit_2 + Spec of Unit_1 + Body of Unit_1 + Body of Unit_2 + @end group + @end smallexample + + @noindent + Now that means that the call to @code{Func_1} in @code{Unit_2} + need not be checked, + it must be safe. But the call to @code{Func_2} in + @code{Unit_1} may still fail if + @code{Expression_1} is equal to 1, + and the programmer must still take + responsibility for this not being the case. + + If all units carry a pragma @code{Elaborate_Body}, then all problems are + eliminated, except for calls entirely within a body, which are + in any case fully under programmer control. However, using the pragma + everywhere is not always possible. + In particular, for our @code{Unit_1}/@code{Unit_2} example, if + we marked both of them as having pragma @code{Elaborate_Body}, then + clearly there would be no possible elaboration order. + + The above pragmas allow a server to guarantee safe use by clients, and + clearly this is the preferable approach. Consequently a good rule in + Ada 95 is to mark units as @code{Pure} or @code{Preelaborate} if possible, + and if this is not possible, + mark them as @code{Elaborate_Body} if possible. + As we have seen, there are situations where neither of these + three pragmas can be used. + So we also provide methods for clients to control the + order of elaboration of the servers on which they depend: + + @table @asis + @item pragma Elaborate (unit) + @findex Elaborate + @cindex pragma Elaborate + This pragma is placed in the context clause, after a @code{with} clause, + and it requires that the body of the named unit be elaborated before + the unit in which the pragma occurs. The idea is to use this pragma + if the current unit calls at elaboration time, directly or indirectly, + some subprogram in the named unit. + + @item pragma Elaborate_All (unit) + @findex Elaborate_All + @cindex pragma Elaborate_All + This is a stronger version of the Elaborate pragma. Consider the + following example: + + @smallexample + Unit A @code{with}'s unit B and calls B.Func in elab code + Unit B @code{with}'s unit C, and B.Func calls C.Func + @end smallexample + + @noindent + Now if we put a pragma @code{Elaborate (B)} + in unit @code{A}, this ensures that the + body of @code{B} is elaborated before the call, but not the + body of @code{C}, so + the call to @code{C.Func} could still cause @code{Program_Error} to + be raised. + + The effect of a pragma @code{Elaborate_All} is stronger, it requires + not only that the body of the named unit be elaborated before the + unit doing the @code{with}, but also the bodies of all units that the + named unit uses, following @code{with} links transitively. For example, + if we put a pragma @code{Elaborate_All (B)} in unit @code{A}, + then it requires + not only that the body of @code{B} be elaborated before @code{A}, + but also the + body of @code{C}, because @code{B} @code{with}'s @code{C}. + @end table + + @noindent + We are now in a position to give a usage rule in Ada 95 for avoiding + elaboration problems, at least if dynamic dispatching and access to + subprogram values are not used. We will handle these cases separately + later. + + The rule is simple. If a unit has elaboration code that can directly or + indirectly make a call to a subprogram in a @code{with}'ed unit, or instantiate + a generic unit in a @code{with}'ed unit, + then if the @code{with}'ed unit does not have + pragma @code{Pure} or @code{Preelaborate}, then the client should have + a pragma @code{Elaborate_All} + for the @code{with}'ed unit. By following this rule a client is + assured that calls can be made without risk of an exception. + If this rule is not followed, then a program may be in one of four + states: + + @table @asis + @item No order exists + No order of elaboration exists which follows the rules, taking into + account any @code{Elaborate}, @code{Elaborate_All}, + or @code{Elaborate_Body} pragmas. In + this case, an Ada 95 compiler must diagnose the situation at bind + time, and refuse to build an executable program. + + @item One or more orders exist, all incorrect + One or more acceptable elaboration orders exists, and all of them + generate an elaboration order problem. In this case, the binder + can build an executable program, but @code{Program_Error} will be raised + when the program is run. + + @item Several orders exist, some right, some incorrect + One or more acceptable elaboration orders exists, and some of them + work, and some do not. The programmer has not controlled + the order of elaboration, so the binder may or may not pick one of + the correct orders, and the program may or may not raise an + exception when it is run. This is the worst case, because it means + that the program may fail when moved to another compiler, or even + another version of the same compiler. + + @item One or more orders exists, all correct + One ore more acceptable elaboration orders exist, and all of them + work. In this case the program runs successfully. This state of + affairs can be guaranteed by following the rule we gave above, but + may be true even if the rule is not followed. + @end table + + @noindent + Note that one additional advantage of following our Elaborate_All rule + is that the program continues to stay in the ideal (all orders OK) state + even if maintenance + changes some bodies of some subprograms. Conversely, if a program that does + not follow this rule happens to be safe at some point, this state of affairs + may deteriorate silently as a result of maintenance changes. + + You may have noticed that the above discussion did not mention + the use of @code{Elaborate_Body}. This was a deliberate omission. If you + @code{with} an @code{Elaborate_Body} unit, it still may be the case that + code in the body makes calls to some other unit, so it is still necessary + to use @code{Elaborate_All} on such units. + + @node Controlling Elaboration in GNAT - Internal Calls + @section Controlling Elaboration in GNAT - Internal Calls + + @noindent + In the case of internal calls, i.e. calls within a single package, the + programmer has full control over the order of elaboration, and it is up + to the programmer to elaborate declarations in an appropriate order. For + example writing: + + @smallexample + @group + @cartouche + @b{function} One @b{return} Float; + + Q : Float := One; + + @b{function} One @b{return} Float @b{is} + @b{begin} + return 1.0; + @b{end} One; + @end cartouche + @end group + @end smallexample + + @noindent + will obviously raise @code{Program_Error} at run time, because function + One will be called before its body is elaborated. In this case GNAT will + generate a warning that the call will raise @code{Program_Error}: + + @smallexample + @group + @cartouche + 1. procedure y is + 2. function One return Float; + 3. + 4. Q : Float := One; + | + >>> warning: cannot call "One" before body is elaborated + >>> warning: Program_Error will be raised at run time + + 5. + 6. function One return Float is + 7. begin + 8. return 1.0; + 9. end One; + 10. + 11. begin + 12. null; + 13. end; + @end cartouche + @end group + @end smallexample + + @noindent + Note that in this particular case, it is likely that the call is safe, because + the function @code{One} does not access any global variables. + Nevertheless in Ada 95, we do not want the validity of the check to depend on + the contents of the body (think about the separate compilation case), so this + is still wrong, as we discussed in the previous sections. + + The error is easily corrected by rearranging the declarations so that the + body of One appears before the declaration containing the call + (note that in Ada 95, + declarations can appear in any order, so there is no restriction that + would prevent this reordering, and if we write: + + @smallexample + @group + @cartouche + @b{function} One @b{return} Float; + + @b{function} One @b{return} Float @b{is} + @b{begin} + return 1.0; + @b{end} One; + + Q : Float := One; + @end cartouche + @end group + @end smallexample + + @noindent + then all is well, no warning is generated, and no + @code{Program_Error} exception + will be raised. + Things are more complicated when a chain of subprograms is executed: + + @smallexample + @group + @cartouche + @b{function} A @b{return} Integer; + @b{function} B @b{return} Integer; + @b{function} C @b{return} Integer; + + @b{function} B @b{return} Integer @b{is begin return} A; @b{end}; + @b{function} C @b{return} Integer @b{is begin return} B; @b{end}; + + X : Integer := C; + + @b{function} A @b{return} Integer @b{is begin return} 1; @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + Now the call to @code{C} + at elaboration time in the declaration of @code{X} is correct, because + the body of @code{C} is already elaborated, + and the call to @code{B} within the body of + @code{C} is correct, but the call + to @code{A} within the body of @code{B} is incorrect, because the body + of @code{A} has not been elaborated, so @code{Program_Error} + will be raised on the call to @code{A}. + In this case GNAT will generate a + warning that @code{Program_Error} may be + raised at the point of the call. Let's look at the warning: + + @smallexample + @group + @cartouche + 1. procedure x is + 2. function A return Integer; + 3. function B return Integer; + 4. function C return Integer; + 5. + 6. function B return Integer is begin return A; end; + | + >>> warning: call to "A" before body is elaborated may + raise Program_Error + >>> warning: "B" called at line 7 + >>> warning: "C" called at line 9 + + 7. function C return Integer is begin return B; end; + 8. + 9. X : Integer := C; + 10. + 11. function A return Integer is begin return 1; end; + 12. + 13. begin + 14. null; + 15. end; + @end cartouche + @end group + @end smallexample + + @noindent + Note that the message here says "may raise", instead of the direct case, + where the message says "will be raised". That's because whether + @code{A} is + actually called depends in general on run-time flow of control. + For example, if the body of @code{B} said + + @smallexample + @group + @cartouche + @b{function} B @b{return} Integer @b{is} + @b{begin} + @b{if} some-condition-depending-on-input-data @b{then} + @b{return} A; + @b{else} + @b{return} 1; + @b{end if}; + @b{end} B; + @end cartouche + @end group + @end smallexample + + @noindent + then we could not know until run time whether the incorrect call to A would + actually occur, so @code{Program_Error} might + or might not be raised. It is possible for a compiler to + do a better job of analyzing bodies, to + determine whether or not @code{Program_Error} + might be raised, but it certainly + couldn't do a perfect job (that would require solving the halting problem + and is provably impossible), and because this is a warning anyway, it does + not seem worth the effort to do the analysis. Cases in which it + would be relevant are rare. + + In practice, warnings of either of the forms given + above will usually correspond to + real errors, and should be examined carefully and eliminated. + In the rare case where a warning is bogus, it can be suppressed by any of + the following methods: + + @itemize @bullet + @item + Compile with the @option{-gnatws} switch set + + @item + Suppress @code{Elaboration_Checks} for the called subprogram + + @item + Use pragma @code{Warnings_Off} to turn warnings off for the call + @end itemize + + @noindent + For the internal elaboration check case, + GNAT by default generates the + necessary run-time checks to ensure + that @code{Program_Error} is raised if any + call fails an elaboration check. Of course this can only happen if a + warning has been issued as described above. The use of pragma + @code{Suppress (Elaboration_Checks)} may (but is not guaranteed to) suppress + some of these checks, meaning that it may be possible (but is not + guaranteed) for a program to be able to call a subprogram whose body + is not yet elaborated, without raising a @code{Program_Error} exception. + + @node Controlling Elaboration in GNAT - External Calls + @section Controlling Elaboration in GNAT - External Calls + + @noindent + The previous section discussed the case in which the execution of a + particular thread of elaboration code occurred entirely within a + single unit. This is the easy case to handle, because a programmer + has direct and total control over the order of elaboration, and + furthermore, checks need only be generated in cases which are rare + and which the compiler can easily detect. + The situation is more complex when separate compilation is taken into account. + Consider the following: + + @smallexample + @cartouche + @group + @b{package} Math @b{is} + @b{function} Sqrt (Arg : Float) @b{return} Float; + @b{end} Math; + + @b{package body} Math @b{is} + @b{function} Sqrt (Arg : Float) @b{return} Float @b{is} + @b{begin} + ... + @b{end} Sqrt; + @b{end} Math; + @end group + @group + @b{with} Math; + @b{package} Stuff @b{is} + X : Float := Math.Sqrt (0.5); + @b{end} Stuff; + + @b{with} Stuff; + @b{procedure} Main @b{is} + @b{begin} + ... + @b{end} Main; + @end group + @end cartouche + @end smallexample + + @noindent + where @code{Main} is the main program. When this program is executed, the + elaboration code must first be executed, and one of the jobs of the + binder is to determine the order in which the units of a program are + to be elaborated. In this case we have four units: the spec and body + of @code{Math}, + the spec of @code{Stuff} and the body of @code{Main}). + In what order should the four separate sections of elaboration code + be executed? + + There are some restrictions in the order of elaboration that the binder + can choose. In particular, if unit U has a @code{with} + for a package @code{X}, then you + are assured that the spec of @code{X} + is elaborated before U , but you are + not assured that the body of @code{X} + is elaborated before U. + This means that in the above case, the binder is allowed to choose the + order: + + @smallexample + spec of Math + spec of Stuff + body of Math + body of Main + @end smallexample + + @noindent + but that's not good, because now the call to @code{Math.Sqrt} + that happens during + the elaboration of the @code{Stuff} + spec happens before the body of @code{Math.Sqrt} is + elaborated, and hence causes @code{Program_Error} exception to be raised. + At first glance, one might say that the binder is misbehaving, because + obviously you want to elaborate the body of something you @code{with} + first, but + that is not a general rule that can be followed in all cases. Consider + + @smallexample + @group + @cartouche + @b{package} X @b{is} ... + + @b{package} Y @b{is} ... + + @b{with} X; + @b{package body} Y @b{is} ... + + @b{with} Y; + @b{package body} X @b{is} ... + @end cartouche + @end group + @end smallexample + + @noindent + This is a common arrangement, and, apart from the order of elaboration + problems that might arise in connection with elaboration code, this works fine. + A rule that says that you must first elaborate the body of anything you + @code{with} cannot work in this case: + the body of @code{X} @code{with}'s @code{Y}, + which means you would have to + elaborate the body of @code{Y} first, but that @code{with}'s @code{X}, + which means + you have to elaborate the body of @code{X} first, but ... and we have a + loop that cannot be broken. + + It is true that the binder can in many cases guess an order of elaboration + that is unlikely to cause a @code{Program_Error} + exception to be raised, and it tries to do so (in the + above example of @code{Math/Stuff/Spec}, the GNAT binder will + by default + elaborate the body of @code{Math} right after its spec, so all will be well). + + However, a program that blindly relies on the binder to be helpful can + get into trouble, as we discussed in the previous sections, so + GNAT + provides a number of facilities for assisting the programmer in + developing programs that are robust with respect to elaboration order. + + @node Default Behavior in GNAT - Ensuring Safety + @section Default Behavior in GNAT - Ensuring Safety + + @noindent + The default behavior in GNAT ensures elaboration safety. In its + default mode GNAT implements the + rule we previously described as the right approach. Let's restate it: + + @itemize + @item + @emph{If a unit has elaboration code that can directly or indirectly make a + call to a subprogram in a @code{with}'ed unit, or instantiate a generic unit + in a @code{with}'ed unit, then if the @code{with}'ed unit + does not have pragma @code{Pure} or + @code{Preelaborate}, then the client should have an + @code{Elaborate_All} for the @code{with}'ed unit.} + @end itemize + + @noindent + By following this rule a client + is assured that calls and instantiations can be made without risk of an exception. + + In this mode GNAT traces all calls that are potentially made from + elaboration code, and puts in any missing implicit @code{Elaborate_All} + pragmas. + The advantage of this approach is that no elaboration problems + are possible if the binder can find an elaboration order that is + consistent with these implicit @code{Elaborate_All} pragmas. The + disadvantage of this approach is that no such order may exist. + + If the binder does not generate any diagnostics, then it means that it + has found an elaboration order that is guaranteed to be safe. However, + the binder may still be relying on implicitly generated + @code{Elaborate_All} pragmas so portability to other compilers than + GNAT is not guaranteed. + + If it is important to guarantee portability, then the compilations should + use the + @option{-gnatwl} + (warn on elaboration problems) switch. This will cause warning messages + to be generated indicating the missing @code{Elaborate_All} pragmas. + Consider the following source program: + + @smallexample + @group + @cartouche + @b{with} k; + @b{package} j @b{is} + m : integer := k.r; + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + where it is clear that there + should be a pragma @code{Elaborate_All} + for unit @code{k}. An implicit pragma will be generated, and it is + likely that the binder will be able to honor it. However, + it is safer to include the pragma explicitly in the source. If this + unit is compiled with the + @option{-gnatwl} + switch, then the compiler outputs a warning: + + @smallexample + @group + @cartouche + 1. with k; + 2. package j is + 3. m : integer := k.r; + | + >>> warning: call to "r" may raise Program_Error + >>> warning: missing pragma Elaborate_All for "k" + + 4. end; + @end cartouche + @end group + @end smallexample + + @noindent + and these warnings can be used as a guide for supplying manually + the missing pragmas. + + This default mode is more restrictive than the Ada Reference + Manual, and it is possible to construct programs which will compile + using the dynamic model described there, but will run into a + circularity using the safer static model we have described. + + Of course any Ada compiler must be able to operate in a mode + consistent with the requirements of the Ada Reference Manual, + and in particular must have the capability of implementing the + standard dynamic model of elaboration with run-time checks. + + In GNAT, this standard mode can be achieved either by the use of + the @option{-gnatE} switch on the compiler (@code{gcc} or @code{gnatmake}) + command, or by the use of the configuration pragma: + + @smallexample + pragma Elaboration_Checks (RM); + @end smallexample + + @noindent + Either approach will cause the unit affected to be compiled using the + standard dynamic run-time elaboration checks described in the Ada + Reference Manual. The static model is generally preferable, since it + is clearly safer to rely on compile and link time checks rather than + run-time checks. However, in the case of legacy code, it may be + difficult to meet the requirements of the static model. This + issue is further discussed in + @ref{What to Do If the Default Elaboration Behavior Fails}. + + Note that the static model provides a strict subset of the allowed + behavior and programs of the Ada Reference Manual, so if you do + adhere to the static model and no circularities exist, + then you are assured that your program will + work using the dynamic model. + + @node Elaboration Issues for Library Tasks + @section Elaboration Issues for Library Tasks + @cindex Library tasks, elaboration issues + @cindex Elaboration of library tasks + + @noindent + In this section we examine special elaboration issues that arise for + programs that declare library level tasks. + + Generally the model of execution of an Ada program is that all units are + elaborated, and then execution of the program starts. However, the + declaration of library tasks definitely does not fit this model. The + reason for this is that library tasks start as soon as they are declared + (more precisely, as soon as the statement part of the enclosing package + body is reached), that is to say before elaboration + of the program is complete. This means that if such a task calls a + subprogram, or an entry in another task, the callee may or may not be + elaborated yet, and in the standard + Reference Manual model of dynamic elaboration checks, you can even + get timing dependent Program_Error exceptions, since there can be + a race between the elaboration code and the task code. + + The static model of elaboration in GNAT seeks to avoid all such + dynamic behavior, by being conservative, and the conservative + approach in this particular case is to assume that all the code + in a task body is potentially executed at elaboration time if + a task is declared at the library level. + + This can definitely result in unexpected circularities. Consider + the following example + + @smallexample + package Decls is + task Lib_Task is + entry Start; + end Lib_Task; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + procedure Main is + begin + Decls.Lib_Task.Start; + end; + @end smallexample + + @noindent + If the above example is compiled in the default static elaboration + mode, then a circularity occurs. The circularity comes from the call + @code{Utils.Put_Val} in the task body of @code{Decls.Lib_Task}. Since + this call occurs in elaboration code, we need an implicit pragma + @code{Elaborate_All} for @code{Utils}. This means that not only must + the spec and body of @code{Utils} be elaborated before the body + of @code{Decls}, but also the spec and body of any unit that is + @code{with'ed} by the body of @code{Utils} must also be elaborated before + the body of @code{Decls}. This is the transitive implication of + pragma @code{Elaborate_All} and it makes sense, because in general + the body of @code{Put_Val} might have a call to something in a + @code{with'ed} unit. + + In this case, the body of Utils (actually its spec) @code{with's} + @code{Decls}. Unfortunately this means that the body of @code{Decls} + must be elaborated before itself, in case there is a call from the + body of @code{Utils}. + + Here is the exact chain of events we are worrying about: + + @enumerate + @item + In the body of @code{Decls} a call is made from within the body of a library + task to a subprogram in the package @code{Utils}. Since this call may + occur at elaboration time (given that the task is activated at elaboration + time), we have to assume the worst, i.e. that the + call does happen at elaboration time. + + @item + This means that the body and spec of @code{Util} must be elaborated before + the body of @code{Decls} so that this call does not cause an access before + elaboration. + + @item + Within the body of @code{Util}, specifically within the body of + @code{Util.Put_Val} there may be calls to any unit @code{with}'ed + by this package. + + @item + One such @code{with}'ed package is package @code{Decls}, so there + might be a call to a subprogram in @code{Decls} in @code{Put_Val}. + In fact there is such a call in this example, but we would have to + assume that there was such a call even if it were not there, since + we are not supposed to write the body of @code{Decls} knowing what + is in the body of @code{Utils}; certainly in the case of the + static elaboration model, the compiler does not know what is in + other bodies and must assume the worst. + + @item + This means that the spec and body of @code{Decls} must also be + elaborated before we elaborate the unit containing the call, but + that unit is @code{Decls}! This means that the body of @code{Decls} + must be elaborated before itself, and that's a circularity. + @end enumerate + + @noindent + Indeed, if you add an explicit pragma Elaborate_All for @code{Utils} in + the body of @code{Decls} you will get a true Ada Reference Manual + circularity that makes the program illegal. + + In practice, we have found that problems with the static model of + elaboration in existing code often arise from library tasks, so + we must address this particular situation. + + Note that if we compile and run the program above, using the dynamic model of + elaboration (that is to say use the @option{-gnatE} switch), + then it compiles, binds, + links, and runs, printing the expected result of 2. Therefore in some sense + the circularity here is only apparent, and we need to capture + the properties of this program that distinguish it from other library-level + tasks that have real elaboration problems. + + We have four possible answers to this question: + + @itemize @bullet + + @item + Use the dynamic model of elaboration. + + If we use the @option{-gnatE} switch, then as noted above, the program works. + Why is this? If we examine the task body, it is apparent that the task cannot + proceed past the + @code{accept} statement until after elaboration has been completed, because + the corresponding entry call comes from the main program, not earlier. + This is why the dynamic model works here. But that's really giving + up on a precise analysis, and we prefer to take this approach only if we cannot + solve the + problem in any other manner. So let us examine two ways to reorganize + the program to avoid the potential elaboration problem. + + @item + Split library tasks into separate packages. + + Write separate packages, so that library tasks are isolated from + other declarations as much as possible. Let us look at a variation on + the above program. + + @smallexample + package Decls1 is + task Lib_Task is + entry Start; + end Lib_Task; + end Decls1; + + with Utils; + package body Decls1 is + task body Lib_Task is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task; + end Decls1; + + package Decls2 is + type My_Int is new Integer; + function Ident (M : My_Int) return My_Int; + end Decls2; + + with Utils; + package body Decls2 is + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls2; + + with Decls2; + package Utils is + procedure Put_Val (Arg : Decls2.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls2.My_Int) is + begin + Text_IO.Put_Line (Decls2.My_Int'Image (Decls2.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls1; + procedure Main is + begin + Decls1.Lib_Task.Start; + end; + @end smallexample + + @noindent + All we have done is to split @code{Decls} into two packages, one + containing the library task, and one containing everything else. Now + there is no cycle, and the program compiles, binds, links and executes + using the default static model of elaboration. + + @item + Declare separate task types. + + A significant part of the problem arises because of the use of the + single task declaration form. This means that the elaboration of + the task type, and the elaboration of the task itself (i.e. the + creation of the task) happen at the same time. A good rule + of style in Ada 95 is to always create explicit task types. By + following the additional step of placing task objects in separate + packages from the task type declaration, many elaboration problems + are avoided. Here is another modified example of the example program: + + @smallexample + package Decls is + task type Lib_Task_Type is + entry Start; + end Lib_Task_Type; + + type My_Int is new Integer; + + function Ident (M : My_Int) return My_Int; + end Decls; + + with Utils; + package body Decls is + task body Lib_Task_Type is + begin + accept Start; + Utils.Put_Val (2); + end Lib_Task_Type; + + function Ident (M : My_Int) return My_Int is + begin + return M; + end Ident; + end Decls; + + with Decls; + package Utils is + procedure Put_Val (Arg : Decls.My_Int); + end Utils; + + with Text_IO; + package body Utils is + procedure Put_Val (Arg : Decls.My_Int) is + begin + Text_IO.Put_Line (Decls.My_Int'Image (Decls.Ident (Arg))); + end Put_Val; + end Utils; + + with Decls; + package Declst is + Lib_Task : Decls.Lib_Task_Type; + end Declst; + + with Declst; + procedure Main is + begin + Declst.Lib_Task.Start; + end; + @end smallexample + + @noindent + What we have done here is to replace the @code{task} declaration in + package @code{Decls} with a @code{task type} declaration. Then we + introduce a separate package @code{Declst} to contain the actual + task object. This separates the elaboration issues for + the @code{task type} + declaration, which causes no trouble, from the elaboration issues + of the task object, which is also unproblematic, since it is now independent + of the elaboration of @code{Utils}. + This separation of concerns also corresponds to + a generally sound engineering principle of separating declarations + from instances. This version of the program also compiles, binds, links, + and executes, generating the expected output. + + @item + Use No_Entry_Calls_In_Elaboration_Code restriction. + @cindex No_Entry_Calls_In_Elaboration_Code + + The previous two approaches described how a program can be restructured + to avoid the special problems caused by library task bodies. in practice, + however, such restructuring may be difficult to apply to existing legacy code, + so we must consider solutions that do not require massive rewriting. + + Let us consider more carefully why our original sample program works + under the dynamic model of elaboration. The reason is that the code + in the task body blocks immediately on the @code{accept} + statement. Now of course there is nothing to prohibit elaboration + code from making entry calls (for example from another library level task), + so we cannot tell in isolation that + the task will not execute the accept statement during elaboration. + + However, in practice it is very unusual to see elaboration code + make any entry calls, and the pattern of tasks starting + at elaboration time and then immediately blocking on @code{accept} or + @code{select} statements is very common. What this means is that + the compiler is being too pessimistic when it analyzes the + whole package body as though it might be executed at elaboration + time. + + If we know that the elaboration code contains no entry calls, (a very safe + assumption most of the time, that could almost be made the default + behavior), then we can compile all units of the program under control + of the following configuration pragma: + + @smallexample + pragma Restrictions (No_Entry_Calls_In_Elaboration_Code); + @end smallexample + + @noindent + This pragma can be placed in the @file{gnat.adc} file in the usual + manner. If we take our original unmodified program and compile it + in the presence of a @file{gnat.adc} containing the above pragma, + then once again, we can compile, bind, link, and execute, obtaining + the expected result. In the presence of this pragma, the compiler does + not trace calls in a task body, that appear after the first @code{accept} + or @code{select} statement, and therefore does not report a potential + circularity in the original program. + + The compiler will check to the extent it can that the above + restriction is not violated, but it is not always possible to do a + complete check at compile time, so it is important to use this + pragma only if the stated restriction is in fact met, that is to say + no task receives an entry call before elaboration of all units is completed. + + @end itemize + + @node Mixing Elaboration Models + @section Mixing Elaboration Models + @noindent + So far, we have assumed that the entire program is either compiled + using the dynamic model or static model, ensuring consistency. It + is possible to mix the two models, but rules have to be followed + if this mixing is done to ensure that elaboration checks are not + omitted. + + The basic rule is that @emph{a unit compiled with the static model cannot + be @code{with'ed} by a unit compiled with the dynamic model}. The + reason for this is that in the static model, a unit assumes that + its clients guarantee to use (the equivalent of) pragma + @code{Elaborate_All} so that no elaboration checks are required + in inner subprograms, and this assumption is violated if the + client is compiled with dynamic checks. + + The precise rule is as follows. A unit that is compiled with dynamic + checks can only @code{with} a unit that meets at least one of the + following criteria: + + @itemize @bullet + + @item + The @code{with'ed} unit is itself compiled with dynamic elaboration + checks (that is with the @option{-gnatE} switch. + + @item + The @code{with'ed} unit is an internal GNAT implementation unit from + the System, Interfaces, Ada, or GNAT hierarchies. + + @item + The @code{with'ed} unit has pragma Preelaborate or pragma Pure. + + @item + The @code{with'ing} unit (that is the client) has an explicit pragma + @code{Elaborate_All} for the @code{with'ed} unit. + + @end itemize + + @noindent + If this rule is violated, that is if a unit with dynamic elaboration + checks @code{with's} a unit that does not meet one of the above four + criteria, then the binder (@code{gnatbind}) will issue a warning + similar to that in the following example: + + @smallexample + warning: "x.ads" has dynamic elaboration checks and with's + warning: "y.ads" which has static elaboration checks + @end smallexample + + @noindent + These warnings indicate that the rule has been violated, and that as a result + elaboration checks may be missed in the resulting executable file. + This warning may be suppressed using the @code{-ws} binder switch + in the usual manner. + + One useful application of this mixing rule is in the case of a subsystem + which does not itself @code{with} units from the remainder of the + application. In this case, the entire subsystem can be compiled with + dynamic checks to resolve a circularity in the subsystem, while + allowing the main application that uses this subsystem to be compiled + using the more reliable default static model. + + @node What to Do If the Default Elaboration Behavior Fails + @section What to Do If the Default Elaboration Behavior Fails + + @noindent + If the binder cannot find an acceptable order, it outputs detailed + diagnostics. For example: + @smallexample + @group + @iftex + @leftskip=0cm + @end iftex + error: elaboration circularity detected + info: "proc (body)" must be elaborated before "pack (body)" + info: reason: Elaborate_All probably needed in unit "pack (body)" + info: recompile "pack (body)" with -gnatwl + info: for full details + info: "proc (body)" + info: is needed by its spec: + info: "proc (spec)" + info: which is withed by: + info: "pack (body)" + info: "pack (body)" must be elaborated before "proc (body)" + info: reason: pragma Elaborate in unit "proc (body)" + @end group + + @end smallexample + + @noindent + In this case we have a cycle that the binder cannot break. On the one + hand, there is an explicit pragma Elaborate in @code{proc} for + @code{pack}. This means that the body of @code{pack} must be elaborated + before the body of @code{proc}. On the other hand, there is elaboration + code in @code{pack} that calls a subprogram in @code{proc}. This means + that for maximum safety, there should really be a pragma + Elaborate_All in @code{pack} for @code{proc} which would require that + the body of @code{proc} be elaborated before the body of + @code{pack}. Clearly both requirements cannot be satisfied. + Faced with a circularity of this kind, you have three different options. + + @table @asis + @item Fix the program + The most desirable option from the point of view of long-term maintenance + is to rearrange the program so that the elaboration problems are avoided. + One useful technique is to place the elaboration code into separate + child packages. Another is to move some of the initialization code to + explicitly called subprograms, where the program controls the order + of initialization explicitly. Although this is the most desirable option, + it may be impractical and involve too much modification, especially in + the case of complex legacy code. + + @item Perform dynamic checks + If the compilations are done using the + @option{-gnatE} + (dynamic elaboration check) switch, then GNAT behaves in + a quite different manner. Dynamic checks are generated for all calls + that could possibly result in raising an exception. With this switch, + the compiler does not generate implicit @code{Elaborate_All} pragmas. + The behavior then is exactly as specified in the Ada 95 Reference Manual. + The binder will generate an executable program that may or may not + raise @code{Program_Error}, and then it is the programmer's job to ensure + that it does not raise an exception. Note that it is important to + compile all units with the switch, it cannot be used selectively. + + @item Suppress checks + The drawback of dynamic checks is that they generate a + significant overhead at run time, both in space and time. If you + are absolutely sure that your program cannot raise any elaboration + exceptions, and you still want to use the dynamic elaboration model, + then you can use the configuration pragma + @code{Suppress (Elaboration_Checks)} to suppress all such checks. For + example this pragma could be placed in the @file{gnat.adc} file. + + @item Suppress checks selectively + When you know that certain calls in elaboration code cannot possibly + lead to an elaboration error, and the binder nevertheless generates warnings + on those calls and inserts Elaborate_All pragmas that lead to elaboration + circularities, it is possible to remove those warnings locally and obtain + a program that will bind. Clearly this can be unsafe, and it is the + responsibility of the programmer to make sure that the resulting program has + no elaboration anomalies. The pragma @code{Suppress (Elaboration_Check)} can + be used with different granularity to suppress warnings and break + elaboration circularities: + + @itemize @bullet + @item + Place the pragma that names the called subprogram in the declarative part + that contains the call. + + @item + Place the pragma in the declarative part, without naming an entity. This + disables warnings on all calls in the corresponding declarative region. + + @item + Place the pragma in the package spec that declares the called subprogram, + and name the subprogram. This disables warnings on all elaboration calls to + that subprogram. + + @item + Place the pragma in the package spec that declares the called subprogram, + without naming any entity. This disables warnings on all elaboration calls to + all subprograms declared in this spec. + @end itemize + + @noindent + These four cases are listed in order of decreasing safety, and therefore + require increasing programmer care in their application. Consider the + following program: + @smallexample + + package Pack1 is + function F1 return Integer; + X1 : Integer; + end Pack1; + + package Pack2 is + function F2 return Integer; + function Pure (x : integer) return integer; + -- pragma Suppress (Elaboration_Check, On => Pure); -- (3) + -- pragma Suppress (Elaboration_Check); -- (4) + end Pack2; + + with Pack2; + package body Pack1 is + function F1 return Integer is + begin + return 100; + end F1; + Val : integer := Pack2.Pure (11); -- Elab. call (1) + begin + declare + -- pragma Suppress(Elaboration_Check, Pack2.F2); -- (1) + -- pragma Suppress(Elaboration_Check); -- (2) + begin + X1 := Pack2.F2 + 1; -- Elab. call (2) + end; + end Pack1; + + with Pack1; + package body Pack2 is + function F2 return Integer is + begin + return Pack1.F1; + end F2; + function Pure (x : integer) return integer is + begin + return x ** 3 - 3 * x; + end; + end Pack2; + + with Pack1, Ada.Text_IO; + procedure Proc3 is + begin + Ada.Text_IO.Put_Line(Pack1.X1'Img); -- 101 + end Proc3; + @end smallexample + In the absence of any pragmas, an attempt to bind this program produces + the following diagnostics: + @smallexample + @group + @iftex + @leftskip=.5cm + @end iftex + error: elaboration circularity detected + info: "pack1 (body)" must be elaborated before "pack1 (body)" + info: reason: Elaborate_All probably needed in unit "pack1 (body)" + info: recompile "pack1 (body)" with -gnatwl for full details + info: "pack1 (body)" + info: must be elaborated along with its spec: + info: "pack1 (spec)" + info: which is withed by: + info: "pack2 (body)" + info: which must be elaborated along with its spec: + info: "pack2 (spec)" + info: which is withed by: + info: "pack1 (body)" + @end group + @end smallexample + The sources of the circularity are the two calls to @code{Pack2.Pure} and + @code{Pack2.F2} in the body of @code{Pack1}. We can see that the call to + F2 is safe, even though F2 calls F1, because the call appears after the + elaboration of the body of F1. Therefore the pragma (1) is safe, and will + remove the warning on the call. It is also possible to use pragma (2) + because there are no other potentially unsafe calls in the block. + + @noindent + The call to @code{Pure} is safe because this function does not depend on the + state of @code{Pack2}. Therefore any call to this function is safe, and it + is correct to place pragma (3) in the corresponding package spec. + + @noindent + Finally, we could place pragma (4) in the spec of @code{Pack2} to disable + warnings on all calls to functions declared therein. Note that this is not + necessarily safe, and requires more detailed examination of the subprogram + bodies involved. In particular, a call to @code{F2} requires that @code{F1} + be already elaborated. + @end table + + @noindent + It is hard to generalize on which of these four approaches should be + taken. Obviously if it is possible to fix the program so that the default + treatment works, this is preferable, but this may not always be practical. + It is certainly simple enough to use + @option{-gnatE} + but the danger in this case is that, even if the GNAT binder + finds a correct elaboration order, it may not always do so, + and certainly a binder from another Ada compiler might not. A + combination of testing and analysis (for which the warnings generated + with the + @option{-gnatwl} + switch can be useful) must be used to ensure that the program is free + of errors. One switch that is useful in this testing is the + @code{-p (pessimistic elaboration order)} + switch for + @code{gnatbind}. + Normally the binder tries to find an order that has the best chance of + of avoiding elaboration problems. With this switch, the binder + plays a devil's advocate role, and tries to choose the order that + has the best chance of failing. If your program works even with this + switch, then it has a better chance of being error free, but this is still + not a guarantee. + + For an example of this approach in action, consider the C-tests (executable + tests) from the ACVC suite. If these are compiled and run with the default + treatment, then all but one of them succeed without generating any error + diagnostics from the binder. However, there is one test that fails, and + this is not surprising, because the whole point of this test is to ensure + that the compiler can handle cases where it is impossible to determine + a correct order statically, and it checks that an exception is indeed + raised at run time. + + This one test must be compiled and run using the + @option{-gnatE} + switch, and then it passes. Alternatively, the entire suite can + be run using this switch. It is never wrong to run with the dynamic + elaboration switch if your code is correct, and we assume that the + C-tests are indeed correct (it is less efficient, but efficiency is + not a factor in running the ACVC tests.) + + @node Elaboration for Access-to-Subprogram Values + @section Elaboration for Access-to-Subprogram Values + @cindex Access-to-subprogram + + @noindent + The introduction of access-to-subprogram types in Ada 95 complicates + the handling of elaboration. The trouble is that it becomes + impossible to tell at compile time which procedure + is being called. This means that it is not possible for the binder + to analyze the elaboration requirements in this case. + + If at the point at which the access value is created + (i.e., the evaluation of @code{P'Access} for a subprogram @code{P}), + the body of the subprogram is + known to have been elaborated, then the access value is safe, and its use + does not require a check. This may be achieved by appropriate arrangement + of the order of declarations if the subprogram is in the current unit, + or, if the subprogram is in another unit, by using pragma + @code{Pure}, @code{Preelaborate}, or @code{Elaborate_Body} + on the referenced unit. + + If the referenced body is not known to have been elaborated at the point + the access value is created, then any use of the access value must do a + dynamic check, and this dynamic check will fail and raise a + @code{Program_Error} exception if the body has not been elaborated yet. + GNAT will generate the necessary checks, and in addition, if the + @option{-gnatwl} + switch is set, will generate warnings that such checks are required. + + The use of dynamic dispatching for tagged types similarly generates + a requirement for dynamic checks, and premature calls to any primitive + operation of a tagged type before the body of the operation has been elaborated, + will result in the raising of @code{Program_Error}. + + @node Summary of Procedures for Elaboration Control + @section Summary of Procedures for Elaboration Control + @cindex Elaboration control + + @noindent + First, compile your program with the default options, using none of + the special elaboration control switches. If the binder successfully + binds your program, then you can be confident that, apart from issues + raised by the use of access-to-subprogram types and dynamic dispatching, + the program is free of elaboration errors. If it is important that the + program be portable, then use the + @option{-gnatwl} + switch to generate warnings about missing @code{Elaborate_All} + pragmas, and supply the missing pragmas. + + If the program fails to bind using the default static elaboration + handling, then you can fix the program to eliminate the binder + message, or recompile the entire program with the + @option{-gnatE} switch to generate dynamic elaboration checks, + and, if you are sure there really are no elaboration problems, + use a global pragma @code{Suppress (Elaboration_Checks)}. + + @node Other Elaboration Order Considerations + @section Other Elaboration Order Considerations + @noindent + This section has been entirely concerned with the issue of finding a valid + elaboration order, as defined by the Ada Reference Manual. In a case + where several elaboration orders are valid, the task is to find one + of the possible valid elaboration orders (and the static model in GNAT + will ensure that this is achieved). + + The purpose of the elaboration rules in the Ada Reference Manual is to + make sure that no entity is accessed before it has been elaborated. For + a subprogram, this means that the spec and body must have been elaborated + before the subprogram is called. For an object, this means that the object + must have been elaborated before its value is read or written. A violation + of either of these two requirements is an access before elaboration order, + and this section has been all about avoiding such errors. + + In the case where more than one order of elaboration is possible, in the + sense that access before elaboration errors are avoided, then any one of + the orders is "correct" in the sense that it meets the requirements of + the Ada Reference Manual, and no such error occurs. + + However, it may be the case for a given program, that there are + constraints on the order of elaboration that come not from consideration + of avoiding elaboration errors, but rather from extra-lingual logic + requirements. Consider this example: + + @smallexample + with Init_Constants; + package Constants is + X : Integer := 0; + Y : Integer := 0; + end Constants; + + package Init_Constants is + procedure Calc; + end Init_Constants; + + with Constants; + package body Init_Constants is + procedure Calc is begin null; end; + begin + Constants.X := 3; + Constants.Y := 4; + end Init_Constants; + + with Constants; + package Calc is + Z : Integer := Constants.X + Constants.Y; + end Calc; + + with Calc; + with Text_IO; use Text_IO; + procedure Main is + begin + Put_Line (Calc.Z'Img); + end Main; + @end smallexample + + @noindent + In this example, there is more than one valid order of elaboration. For + example both the following are correct orders: + + @smallexample + Init_Constants spec + Constants spec + Calc spec + Main body + Init_Constants body + + and + + Init_Constants spec + Init_Constants body + Constants spec + Calc spec + Main body + @end smallexample + + @noindent + There is no language rule to prefer one or the other, both are correct + from an order of elaboration point of view. But the programmatic effects + of the two orders are very different. In the first, the elaboration routine + of @code{Calc} initializes @code{Z} to zero, and then the main program + runs with this value of zero. But in the second order, the elaboration + routine of @code{Calc} runs after the body of Init_Constants has set + @code{X} and @code{Y} and thus @code{Z} is set to 7 before @code{Main} + runs. + + One could perhaps by applying pretty clever non-artificial intelligence + to the situation guess that it is more likely that the second order of + elaboration is the one desired, but there is no formal linguistic reason + to prefer one over the other. In fact in this particular case, GNAT will + prefer the second order, because of the rule that bodies are elaborated + as soon as possible, but it's just luck that this is what was wanted + (if indeed the second order was preferred). + + If the program cares about the order of elaboration routines in a case like + this, it is important to specify the order required. In this particular + case, that could have been achieved by adding to the spec of Calc: + + @smallexample + pragma Elaborate_All (Constants); + @end smallexample + + @noindent + which requires that the body (if any) and spec of @code{Constants}, + as well as the body and spec of any unit @code{with}'ed by + @code{Constants} be elaborated before @code{Calc} is elaborated. + + Clearly no automatic method can always guess which alternative you require, + and if you are working with legacy code that had constraints of this kind + which were not properly specified by adding @code{Elaborate} or + @code{Elaborate_All} pragmas, then indeed it is possible that two different + compilers can choose different orders. + + The @code{gnatbind} + @code{-p} switch may be useful in smoking + out problems. This switch causes bodies to be elaborated as late as possible + instead of as early as possible. In the example above, it would have forced + the choice of the first elaboration order. If you get different results + when using this switch, and particularly if one set of results is right, + and one is wrong as far as you are concerned, it shows that you have some + missing @code{Elaborate} pragmas. For the example above, we have the + following output: + + @smallexample + gnatmake -f -q main + main + 7 + gnatmake -f -q main -bargs -p + main + 0 + @end smallexample + + @noindent + It is of course quite unlikely that both these results are correct, so + it is up to you in a case like this to investigate the source of the + difference, by looking at the two elaboration orders that are chosen, + and figuring out which is correct, and then adding the necessary + @code{Elaborate_All} pragmas to ensure the desired order. + + @node The Cross-Referencing Tools gnatxref and gnatfind + @chapter The Cross-Referencing Tools @code{gnatxref} and @code{gnatfind} + @findex gnatxref + @findex gnatfind + + @noindent + The compiler generates cross-referencing information (unless + you set the @samp{-gnatx} switch), which are saved in the @file{.ali} files. + This information indicates where in the source each entity is declared and + referenced. Note that entities in package Standard are not included, but + entities in all other predefined units are included in the output. + + Before using any of these two tools, you need to compile successfully your + application, so that GNAT gets a chance to generate the cross-referencing + information. + + The two tools @code{gnatxref} and @code{gnatfind} take advantage of this + information to provide the user with the capability to easily locate the + declaration and references to an entity. These tools are quite similar, + the difference being that @code{gnatfind} is intended for locating + definitions and/or references to a specified entity or entities, whereas + @code{gnatxref} is oriented to generating a full report of all + cross-references. + + To use these tools, you must not compile your application using the + @option{-gnatx} switch on the @file{gnatmake} command line (@inforef{The + GNAT Make Program gnatmake,,gnat_ug}). Otherwise, cross-referencing + information will not be generated. + + @menu + * gnatxref Switches:: + * gnatfind Switches:: + * Project Files for gnatxref and gnatfind:: + * Regular Expressions in gnatfind and gnatxref:: + * Examples of gnatxref Usage:: + * Examples of gnatfind Usage:: + @end menu + + @node gnatxref Switches + @section @code{gnatxref} Switches + + @noindent + The command lines for @code{gnatxref} is: + @smallexample + $ gnatxref [switches] sourcefile1 [sourcefile2 ...] + @end smallexample + + @noindent + where + + @table @code + @item sourcefile1, sourcefile2 + identifies the source files for which a report is to be generated. The + 'with'ed units will be processed too. You must provide at least one file. + + These file names are considered to be regular expressions, so for instance + specifying 'source*.adb' is the same as giving every file in the current + directory whose name starts with 'source' and whose extension is 'adb'. + + @end table + + @noindent + The switches can be : + @table @code + @item -a + If this switch is present, @code{gnatfind} and @code{gnatxref} will parse + the read-only files found in the library search path. Otherwise, these files + will be ignored. This option can be used to protect Gnat sources or your own + libraries from being parsed, thus making @code{gnatfind} and @code{gnatxref} + much faster, and their output much smaller. + + @item -aIDIR + When looking for source files also look in directory DIR. The order in which + source file search is undertaken is the same as for @file{gnatmake}. + + @item -aODIR + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as for + @file{gnatmake}. + + @item -nostdinc + Do not look for sources in the system default directory. + + @item -nostdlib + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatxref}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -d + If this switch is set @code{gnatxref} will output the parent type + reference for each matching derived types. + + @item -f + If this switch is set, the output file names will be preceded by their + directory (if the file was found in the search path). If this switch is + not set, the directory will not be printed. + + @item -g + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may accelerate + @code{gnatfind} and @code{gnatxref}. + + @item -IDIR + Equivalent to @samp{-aODIR -aIDIR}. + + @item -pFILE + Specify a project file to use @xref{Project Files}. + By default, @code{gnatxref} and @code{gnatfind} will try to locate a + project file in the current directory. + + If a project file is either specified or found by the tools, then the content + of the source directory and object directory lines are added as if they + had been specified respectively by @samp{-aI} + and @samp{-aO}. + @item -u + Output only unused symbols. This may be really useful if you give your + main compilation unit on the command line, as @code{gnatxref} will then + display every unused entity and 'with'ed package. + + @item -v + Instead of producing the default output, @code{gnatxref} will generate a + @file{tags} file that can be used by vi. For examples how to use this + feature, see @xref{Examples of gnatxref Usage}. The tags file is output + to the standard output, thus you will have to redirect it to a file. + + @end table + + All these switches may be in any order on the command line, and may even + appear after the file names. They need not be separated by spaces, thus + you can say @samp{gnatxref -ag} instead of + @samp{gnatxref -a -g}. + + @node gnatfind Switches + @section @code{gnatfind} Switches + + @noindent + The command line for @code{gnatfind} is: + + @smallexample + $ gnatfind [switches] pattern[:sourcefile[:line[:column]]] + [file1 file2 ...] + @end smallexample + + @noindent + where + + @table @code + @item pattern + An entity will be output only if it matches the regular expression found + in @samp{pattern}, see @xref{Regular Expressions in gnatfind and gnatxref}. + + Omitting the pattern is equivalent to specifying @samp{*}, which + will match any entity. Note that if you do not provide a pattern, you + have to provide both a sourcefile and a line. + + Entity names are given in Latin-1, with uppercase/lowercase equivalence + for matching purposes. At the current time there is no support for + 8-bit codes other than Latin-1, or for wide characters in identifiers. + + @item sourcefile + @code{gnatfind} will look for references, bodies or declarations + of symbols referenced in @file{sourcefile}, at line @samp{line} + and column @samp{column}. See @pxref{Examples of gnatfind Usage} + for syntax examples. + + @item line + is a decimal integer identifying the line number containing + the reference to the entity (or entities) to be located. + + @item column + is a decimal integer identifying the exact location on the + line of the first character of the identifier for the + entity reference. Columns are numbered from 1. + + @item file1 file2 ... + The search will be restricted to these files. If none are given, then + the search will be done for every library file in the search path. + These file must appear only after the pattern or sourcefile. + + These file names are considered to be regular expressions, so for instance + specifying 'source*.adb' is the same as giving every file in the current + directory whose name starts with 'source' and whose extension is 'adb'. + + Not that if you specify at least one file in this part, @code{gnatfind} may + sometimes not be able to find the body of the subprograms... + + @end table + + At least one of 'sourcefile' or 'pattern' has to be present on + the command line. + + The following switches are available: + @table @code + + @item -a + If this switch is present, @code{gnatfind} and @code{gnatxref} will parse + the read-only files found in the library search path. Otherwise, these files + will be ignored. This option can be used to protect Gnat sources or your own + libraries from being parsed, thus making @code{gnatfind} and @code{gnatxref} + much faster, and their output much smaller. + + @item -aIDIR + When looking for source files also look in directory DIR. The order in which + source file search is undertaken is the same as for @file{gnatmake}. + + @item -aODIR + When searching for library and object files, look in directory + DIR. The order in which library files are searched is the same as for + @file{gnatmake}. + + @item -nostdinc + Do not look for sources in the system default directory. + + @item -nostdlib + Do not look for library files in the system default directory. + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatfind}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -d + If this switch is set, then @code{gnatfind} will output the parent type + reference for each matching derived types. + + @item -e + By default, @code{gnatfind} accept the simple regular expression set for + @samp{pattern}. If this switch is set, then the pattern will be + considered as full Unix-style regular expression. + + @item -f + If this switch is set, the output file names will be preceded by their + directory (if the file was found in the search path). If this switch is + not set, the directory will not be printed. + + @item -g + If this switch is set, information is output only for library-level + entities, ignoring local entities. The use of this switch may accelerate + @code{gnatfind} and @code{gnatxref}. + + @item -IDIR + Equivalent to @samp{-aODIR -aIDIR}. + + @item -pFILE + Specify a project file (@pxref{Project Files}) to use. + By default, @code{gnatxref} and @code{gnatfind} will try to locate a + project file in the current directory. + + If a project file is either specified or found by the tools, then the content + of the source directory and object directory lines are added as if they + had been specified respectively by @samp{-aI} and + @samp{-aO}. + + @item -r + By default, @code{gnatfind} will output only the information about the + declaration, body or type completion of the entities. If this switch is + set, the @code{gnatfind} will locate every reference to the entities in + the files specified on the command line (or in every file in the search + path if no file is given on the command line). + + @item -s + If this switch is set, then @code{gnatfind} will output the content + of the Ada source file lines were the entity was found. + + @item -t + If this switch is set, then @code{gnatfind} will output the type hierarchy for + the specified type. It act like -d option but recursively from parent + type to parent type. When this switch is set it is not possible to + specify more than one file. + + @end table + + All these switches may be in any order on the command line, and may even + appear after the file names. They need not be separated by spaces, thus + you can say @samp{gnatxref -ag} instead of + @samp{gnatxref -a -g}. + + As stated previously, gnatfind will search in every directory in the + search path. You can force it to look only in the current directory if + you specify @code{*} at the end of the command line. + + + @node Project Files for gnatxref and gnatfind + @section Project Files for @command{gnatxref} and @command{gnatfind} + + @noindent + Project files allow a programmer to specify how to compile its + application, where to find sources,... These files are used primarily by + the Glide Ada mode, but they can also be used by the two tools + @code{gnatxref} and @code{gnatfind}. + + A project file name must end with @file{.adp}. If a single one is + present in the current directory, then @code{gnatxref} and @code{gnatfind} will + extract the information from it. If multiple project files are found, none of + them is read, and you have to use the @samp{-p} switch to specify the one + you want to use. + + The following lines can be included, even though most of them have default + values which can be used in most cases. + The lines can be entered in any order in the file. + Except for @samp{src_dir} and @samp{obj_dir}, you can only have one instance of + each line. If you have multiple instances, only the last one is taken into + account. + + @table @code + @item src_dir=DIR [default: "./"] + specifies a directory where to look for source files. Multiple src_dir lines + can be specified and they will be searched in the order they + are specified. + + @item obj_dir=DIR [default: "./"] + specifies a directory where to look for object and library files. Multiple + obj_dir lines can be specified and they will be searched in the order they + are specified + + @item comp_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{comp_opt@}} notation. This is intended to store the default + switches given to @file{gnatmake} and @file{gcc}. + + @item bind_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{bind_opt@}} notation. This is intended to store the default + switches given to @file{gnatbind}. + + @item link_opt=SWITCHES [default: ""] + creates a variable which can be referred to subsequently by using + the @samp{$@{link_opt@}} notation. This is intended to store the default + switches given to @file{gnatlink}. + + @item main=EXECUTABLE [default: ""] + specifies the name of the executable for the application. This variable can + be referred to in the following lines by using the @samp{$@{main@}} notation. + + @item comp_cmd=COMMAND [default: "gcc -c -I$@{src_dir@} -g -gnatq"] + specifies the command used to compile a single file in the application. + + @item make_cmd=COMMAND [default: "gnatmake $@{main@} -aI$@{src_dir@} -aO$@{obj_dir@} -g -gnatq -cargs $@{comp_opt@} -bargs $@{bind_opt@} -largs $@{link_opt@}"] + specifies the command used to recompile the whole application. + + @item run_cmd=COMMAND [default: "$@{main@}"] + specifies the command used to run the application. + + @item debug_cmd=COMMAND [default: "gdb $@{main@}"] + specifies the command used to debug the application + + @end table + + @code{gnatxref} and @code{gnatfind} only take into account the @samp{src_dir} + and @samp{obj_dir} lines, and ignore the others. + + @node Regular Expressions in gnatfind and gnatxref + @section Regular Expressions in @code{gnatfind} and @code{gnatxref} + + @noindent + As specified in the section about @code{gnatfind}, the pattern can be a + regular expression. Actually, there are to set of regular expressions + which are recognized by the program : + + @table @code + @item globbing patterns + These are the most usual regular expression. They are the same that you + generally used in a Unix shell command line, or in a DOS session. + + Here is a more formal grammar : + @smallexample + @group + @iftex + @leftskip=.5cm + @end iftex + regexp ::= term + term ::= elmt -- matches elmt + term ::= elmt elmt -- concatenation (elmt then elmt) + term ::= * -- any string of 0 or more characters + term ::= ? -- matches any character + term ::= [char @{char@}] -- matches any character listed + term ::= [char - char] -- matches any character in range + @end group + @end smallexample + + @item full regular expression + The second set of regular expressions is much more powerful. This is the + type of regular expressions recognized by utilities such a @file{grep}. + + The following is the form of a regular expression, expressed in Ada + reference manual style BNF is as follows + + @smallexample + @iftex + @leftskip=.5cm + @end iftex + @group + regexp ::= term @{| term@} -- alternation (term or term ...) + + term ::= item @{item@} -- concatenation (item then item) + + item ::= elmt -- match elmt + item ::= elmt * -- zero or more elmt's + item ::= elmt + -- one or more elmt's + item ::= elmt ? -- matches elmt or nothing + @end group + @group + elmt ::= nschar -- matches given character + elmt ::= [nschar @{nschar@}] -- matches any character listed + elmt ::= [^ nschar @{nschar@}] -- matches any character not listed + elmt ::= [char - char] -- matches chars in given range + elmt ::= \ char -- matches given character + elmt ::= . -- matches any single character + elmt ::= ( regexp ) -- parens used for grouping + + char ::= any character, including special characters + nschar ::= any character except ()[].*+?^ + @end group + @end smallexample + + Following are a few examples : + + @table @samp + @item abcde|fghi + will match any of the two strings 'abcde' and 'fghi'. + + @item abc*d + will match any string like 'abd', 'abcd', 'abccd', 'abcccd', and so on + + @item [a-z]+ + will match any string which has only lowercase characters in it (and at + least one character + + @end table + @end table + + @node Examples of gnatxref Usage + @section Examples of @code{gnatxref} Usage + + @subsection General Usage + + @noindent + For the following examples, we will consider the following units : + + @smallexample + @group + @cartouche + main.ads: + 1: @b{with} Bar; + 2: @b{package} Main @b{is} + 3: @b{procedure} Foo (B : @b{in} Integer); + 4: C : Integer; + 5: @b{private} + 6: D : Integer; + 7: @b{end} Main; + + main.adb: + 1: @b{package body} Main @b{is} + 2: @b{procedure} Foo (B : @b{in} Integer) @b{is} + 3: @b{begin} + 4: C := B; + 5: D := B; + 6: Bar.Print (B); + 7: Bar.Print (C); + 8: @b{end} Foo; + 9: @b{end} Main; + + bar.ads: + 1: @b{package} Bar @b{is} + 2: @b{procedure} Print (B : Integer); + 3: @b{end} bar; + @end cartouche + @end group + @end smallexample + + @table @code + + @noindent + The first thing to do is to recompile your application (for instance, in + that case just by doing a @samp{gnatmake main}, so that GNAT generates + the cross-referencing information. + You can then issue any of the following commands: + + @item gnatxref main.adb + @code{gnatxref} generates cross-reference information for main.adb + and every unit 'with'ed by main.adb. + + The output would be: + @smallexample + @iftex + @leftskip=0cm + @end iftex + B Type: Integer + Decl: bar.ads 2:22 + B Type: Integer + Decl: main.ads 3:20 + Body: main.adb 2:20 + Ref: main.adb 4:13 5:13 6:19 + Bar Type: Unit + Decl: bar.ads 1:9 + Ref: main.adb 6:8 7:8 + main.ads 1:6 + C Type: Integer + Decl: main.ads 4:5 + Modi: main.adb 4:8 + Ref: main.adb 7:19 + D Type: Integer + Decl: main.ads 6:5 + Modi: main.adb 5:8 + Foo Type: Unit + Decl: main.ads 3:15 + Body: main.adb 2:15 + Main Type: Unit + Decl: main.ads 2:9 + Body: main.adb 1:14 + Print Type: Unit + Decl: bar.ads 2:15 + Ref: main.adb 6:12 7:12 + @end smallexample + + @noindent + that is the entity @code{Main} is declared in main.ads, line 2, column 9, + its body is in main.adb, line 1, column 14 and is not referenced any where. + + The entity @code{Print} is declared in bar.ads, line 2, column 15 and it + it referenced in main.adb, line 6 column 12 and line 7 column 12. + + @item gnatxref package1.adb package2.ads + @code{gnatxref} will generates cross-reference information for + package1.adb, package2.ads and any other package 'with'ed by any + of these. + + @end table + + @subsection Using gnatxref with vi + + @code{gnatxref} can generate a tags file output, which can be used + directly from @file{vi}. Note that the standard version of @file{vi} + will not work properly with overloaded symbols. Consider using another + free implementation of @file{vi}, such as @file{vim}. + + @smallexample + $ gnatxref -v gnatfind.adb > tags + @end smallexample + + @noindent + will generate the tags file for @code{gnatfind} itself (if the sources + are in the search path!). + + From @file{vi}, you can then use the command @samp{:tag @i{entity}} + (replacing @i{entity} by whatever you are looking for), and vi will + display a new file with the corresponding declaration of entity. + + @node Examples of gnatfind Usage + @section Examples of @code{gnatfind} Usage + + @table @code + + @item gnatfind -f xyz:main.adb + Find declarations for all entities xyz referenced at least once in + main.adb. The references are search in every library file in the search + path. + + The directories will be printed as well (as the @samp{-f} + switch is set) + + The output will look like: + @smallexample + directory/main.ads:106:14: xyz <= declaration + directory/main.adb:24:10: xyz <= body + directory/foo.ads:45:23: xyz <= declaration + @end smallexample + + @noindent + that is to say, one of the entities xyz found in main.adb is declared at + line 12 of main.ads (and its body is in main.adb), and another one is + declared at line 45 of foo.ads + + @item gnatfind -fs xyz:main.adb + This is the same command as the previous one, instead @code{gnatfind} will + display the content of the Ada source file lines. + + The output will look like: + + @smallexample + directory/main.ads:106:14: xyz <= declaration + procedure xyz; + directory/main.adb:24:10: xyz <= body + procedure xyz is + directory/foo.ads:45:23: xyz <= declaration + xyz : Integer; + @end smallexample + + @noindent + This can make it easier to find exactly the location your are looking + for. + + @item gnatfind -r "*x*":main.ads:123 foo.adb + Find references to all entities containing an x that are + referenced on line 123 of main.ads. + The references will be searched only in main.adb and foo.adb. + + @item gnatfind main.ads:123 + Find declarations and bodies for all entities that are referenced on + line 123 of main.ads. + + This is the same as @code{gnatfind "*":main.adb:123}. + + @item gnatfind mydir/main.adb:123:45 + Find the declaration for the entity referenced at column 45 in + line 123 of file main.adb in directory mydir. Note that it + is usual to omit the identifier name when the column is given, + since the column position identifies a unique reference. + + The column has to be the beginning of the identifier, and should not + point to any character in the middle of the identifier. + + @end table + + @node File Name Krunching Using gnatkr + @chapter File Name Krunching Using @code{gnatkr} + @findex gnatkr + + @noindent + This chapter discusses the method used by the compiler to shorten + the default file names chosen for Ada units so that they do not + exceed the maximum length permitted. It also describes the + @code{gnatkr} utility that can be used to determine the result of + applying this shortening. + @menu + * About gnatkr:: + * Using gnatkr:: + * Krunching Method:: + * Examples of gnatkr Usage:: + @end menu + + @node About gnatkr + @section About @code{gnatkr} + + @noindent + The default file naming rule in GNAT + is that the file name must be derived from + the unit name. The exact default rule is as follows: + @itemize @bullet + @item + Take the unit name and replace all dots by hyphens. + @item + If such a replacement occurs in the + second character position of a name, and the first character is + a, g, s, or i then replace the dot by the character + ~ (tilde) + instead of a minus. + @end itemize + The reason for this exception is to avoid clashes + with the standard names for children of System, Ada, Interfaces, + and GNAT, which use the prefixes s- a- i- and g- + respectively. + + The @code{-gnatk@var{nn}} + switch of the compiler activates a "krunching" + circuit that limits file names to nn characters (where nn is a decimal + integer). For example, using OpenVMS, + where the maximum file name length is + 39, the value of nn is usually set to 39, but if you want to generate + a set of files that would be usable if ported to a system with some + different maximum file length, then a different value can be specified. + The default value of 39 for OpenVMS need not be specified. + + The @code{gnatkr} utility can be used to determine the krunched name for + a given file, when krunched to a specified maximum length. + + @node Using gnatkr + @section Using @code{gnatkr} + + @noindent + The @code{gnatkr} command has the form + + @smallexample + $ gnatkr @var{name} [@var{length}] + @end smallexample + + + @noindent + @var{name} can be an Ada name with dots or the GNAT name of the unit, + where the dots representing child units or subunit are replaced by + hyphens. The only confusion arises if a name ends in @code{.ads} or + @code{.adb}. @code{gnatkr} takes this to be an extension if there are + no other dots in the name and the whole name is in lowercase. + + @var{length} represents the length of the krunched name. The default + when no argument is given is 8 characters. A length of zero stands for + unlimited, in other words do not chop except for system files which are + always 8. + + @noindent + The output is the krunched name. The output has an extension only if the + original argument was a file name with an extension. + + @node Krunching Method + @section Krunching Method + + @noindent + The initial file name is determined by the name of the unit that the file + contains. The name is formed by taking the full expanded name of the + unit and replacing the separating dots with hyphens and + using lowercase + for all letters, except that a hyphen in the second character position is + replaced by a tilde if the first character is + a, i, g, or s. + The extension is @code{.ads} for a + specification and @code{.adb} for a body. + Krunching does not affect the extension, but the file name is shortened to + the specified length by following these rules: + + @itemize @bullet + @item + The name is divided into segments separated by hyphens, tildes or + underscores and all hyphens, tildes, and underscores are + eliminated. If this leaves the name short enough, we are done. + + @item + If the name is too long, the longest segment is located (left-most if there are two + of equal length), and shortened by dropping its last character. This is + repeated until the name is short enough. + + As an example, consider the krunching of @*@file{our-strings-wide_fixed.adb} + to fit the name into 8 characters as required by some operating systems. + + @smallexample + our-strings-wide_fixed 22 + our strings wide fixed 19 + our string wide fixed 18 + our strin wide fixed 17 + our stri wide fixed 16 + our stri wide fixe 15 + our str wide fixe 14 + our str wid fixe 13 + our str wid fix 12 + ou str wid fix 11 + ou st wid fix 10 + ou st wi fix 9 + ou st wi fi 8 + Final file name: oustwifi.adb + @end smallexample + + @item + The file names for all predefined units are always krunched to eight + characters. The krunching of these predefined units uses the following + special prefix replacements: + + @table @file + @item ada- + replaced by @file{a-} + + @item gnat- + replaced by @file{g-} + + @item interfaces- + replaced by @file{i-} + + @item system- + replaced by @file{s-} + @end table + + These system files have a hyphen in the second character position. That + is why normal user files replace such a character with a + tilde, to + avoid confusion with system file names. + + As an example of this special rule, consider + @*@file{ada-strings-wide_fixed.adb}, which gets krunched as follows: + + @smallexample + ada-strings-wide_fixed 22 + a- strings wide fixed 18 + a- string wide fixed 17 + a- strin wide fixed 16 + a- stri wide fixed 15 + a- stri wide fixe 14 + a- str wide fixe 13 + a- str wid fixe 12 + a- str wid fix 11 + a- st wid fix 10 + a- st wi fix 9 + a- st wi fi 8 + Final file name: a-stwifi.adb + @end smallexample + @end itemize + + Of course no file shortening algorithm can guarantee uniqueness over all + possible unit names, and if file name krunching is used then it is your + responsibility to ensure that no name clashes occur. The utility + program @code{gnatkr} is supplied for conveniently determining the + krunched name of a file. + + @node Examples of gnatkr Usage + @section Examples of @code{gnatkr} Usage + + @smallexample + @iftex + @leftskip=0cm + @end iftex + $ gnatkr very_long_unit_name.ads --> velounna.ads + $ gnatkr grandparent-parent-child.ads --> grparchi.ads + $ gnatkr Grandparent.Parent.Child --> grparchi + $ gnatkr very_long_unit_name.ads/count=6 --> vlunna.ads + $ gnatkr very_long_unit_name.ads/count=0 --> very_long_unit_name.ads + @end smallexample + + @node Preprocessing Using gnatprep + @chapter Preprocessing Using @code{gnatprep} + @findex gnatprep + + @noindent + The @code{gnatprep} utility provides + a simple preprocessing capability for Ada programs. + It is designed for use with GNAT, but is not dependent on any special + features of GNAT. + + @menu + * Using gnatprep:: + * Switches for gnatprep:: + * Form of Definitions File:: + * Form of Input Text for gnatprep:: + @end menu + + @node Using gnatprep + @section Using @code{gnatprep} + + @noindent + To call @code{gnatprep} use + + @smallexample + $ gnatprep [-bcrsu] [-Dsymbol=value] infile outfile [deffile] + @end smallexample + + @noindent + where + @table @code + @item infile + is the full name of the input file, which is an Ada source + file containing preprocessor directives. + + @item outfile + is the full name of the output file, which is an Ada source + in standard Ada form. When used with GNAT, this file name will + normally have an ads or adb suffix. + + @item deffile + is the full name of a text file containing definitions of + symbols to be referenced by the preprocessor. This argument is + optional, and can be replaced by the use of the @code{-D} switch. + + @item switches + is an optional sequence of switches as described in the next section. + @end table + + @node Switches for gnatprep + @section Switches for @code{gnatprep} + + @table @code + + @item -b + Causes both preprocessor lines and the lines deleted by + preprocessing to be replaced by blank lines in the output source file, + preserving line numbers in the output file. + + @item -c + Causes both preprocessor lines and the lines deleted + by preprocessing to be retained in the output source as comments marked + with the special string "--! ". This option will result in line numbers + being preserved in the output file. + + @item -Dsymbol=value + Defines a new symbol, associated with value. If no value is given on the + command line, then symbol is considered to be @code{True}. This switch + can be used in place of a definition file. + + + @item -r + Causes a @code{Source_Reference} pragma to be generated that + references the original input file, so that error messages will use + the file name of this original file. The use of this switch implies + that preprocessor lines are not to be removed from the file, so its + use will force @code{-b} mode if + @code{-c} + has not been specified explicitly. + + Note that if the file to be preprocessed contains multiple units, then + it will be necessary to @code{gnatchop} the output file from + @code{gnatprep}. If a @code{Source_Reference} pragma is present + in the preprocessed file, it will be respected by + @code{gnatchop -r} + so that the final chopped files will correctly refer to the original + input source file for @code{gnatprep}. + + @item -s + Causes a sorted list of symbol names and values to be + listed on the standard output file. + + @item -u + Causes undefined symbols to be treated as having the value FALSE in the context + of a preprocessor test. In the absence of this option, an undefined symbol in + a @code{#if} or @code{#elsif} test will be treated as an error. + + @end table + + @noindent + Note: if neither @code{-b} nor @code{-c} is present, + then preprocessor lines and + deleted lines are completely removed from the output, unless -r is + specified, in which case -b is assumed. + + @node Form of Definitions File + @section Form of Definitions File + + @noindent + The definitions file contains lines of the form + + @smallexample + symbol := value + @end smallexample + + @noindent + where symbol is an identifier, following normal Ada (case-insensitive) + rules for its syntax, and value is one of the following: + + @itemize @bullet + @item + Empty, corresponding to a null substitution + @item + A string literal using normal Ada syntax + @item + Any sequence of characters from the set + (letters, digits, period, underline). + @end itemize + + @noindent + Comment lines may also appear in the definitions file, starting with + the usual @code{--}, + and comments may be added to the definitions lines. + + @node Form of Input Text for gnatprep + @section Form of Input Text for @code{gnatprep} + + @noindent + The input text may contain preprocessor conditional inclusion lines, + as well as general symbol substitution sequences. + + The preprocessor conditional inclusion commands have the form + + @smallexample + @group + @cartouche + #if @i{expression} [then] + lines + #elsif @i{expression} [then] + lines + #elsif @i{expression} [then] + lines + ... + #else + lines + #end if; + @end cartouche + @end group + @end smallexample + + @noindent + In this example, @i{expression} is defined by the following grammar: + @smallexample + @i{expression} ::= + @i{expression} ::= = "" + @i{expression} ::= = + @i{expression} ::= 'Defined + @i{expression} ::= not @i{expression} + @i{expression} ::= @i{expression} and @i{expression} + @i{expression} ::= @i{expression} or @i{expression} + @i{expression} ::= @i{expression} and then @i{expression} + @i{expression} ::= @i{expression} or else @i{expression} + @i{expression} ::= ( @i{expression} ) + @end smallexample + + @noindent + For the first test (@i{expression} ::= ) the symbol must have + either the value true or false, that is to say the right-hand of the + symbol definition must be one of the (case-insensitive) literals + @code{True} or @code{False}. If the value is true, then the + corresponding lines are included, and if the value is false, they are + excluded. + + The test (@i{expression} ::= @code{'Defined}) is true only if + the symbol has been defined in the definition file or by a @code{-D} + switch on the command line. Otherwise, the test is false. + + The equality tests are case insensitive, as are all the preprocessor lines. + + If the symbol referenced is not defined in the symbol definitions file, + then the effect depends on whether or not switch @code{-u} + is specified. If so, then the symbol is treated as if it had the value + false and the test fails. If this switch is not specified, then + it is an error to reference an undefined symbol. It is also an error to + reference a symbol that is defined with a value other than @code{True} + or @code{False}. + + The use of the @code{not} operator inverts the sense of this logical test, so + that the lines are included only if the symbol is not defined. + The @code{then} keyword is optional as shown + + The @code{#} must be the first non-blank character on a line, but + otherwise the format is free form. Spaces or tabs may appear between + the @code{#} and the keyword. The keywords and the symbols are case + insensitive as in normal Ada code. Comments may be used on a + preprocessor line, but other than that, no other tokens may appear on a + preprocessor line. Any number of @code{elsif} clauses can be present, + including none at all. The @code{else} is optional, as in Ada. + + The @code{#} marking the start of a preprocessor line must be the first + non-blank character on the line, i.e. it must be preceded only by + spaces or horizontal tabs. + + Symbol substitution outside of preprocessor lines is obtained by using + the sequence + + @smallexample + $symbol + @end smallexample + + @noindent + anywhere within a source line, except in a comment or within a + string literal. The identifier + following the @code{$} must match one of the symbols defined in the symbol + definition file, and the result is to substitute the value of the + symbol in place of @code{$symbol} in the output file. + + Note that although the substitution of strings within a string literal + is not possible, it is possible to have a symbol whose defined value is + a string literal. So instead of setting XYZ to @code{hello} and writing: + + @smallexample + Header : String := "$XYZ"; + @end smallexample + + @noindent + you should set XYZ to @code{"hello"} and write: + + @smallexample + Header : String := $XYZ; + @end smallexample + + @noindent + and then the substitution will occur as desired. + + + @node The GNAT Library Browser gnatls + @chapter The GNAT Library Browser @code{gnatls} + @findex gnatls + @cindex Library browser + + @noindent + @code{gnatls} is a tool that outputs information about compiled + units. It gives the relationship between objects, unit names and source + files. It can also be used to check the source dependencies of a unit + as well as various characteristics. + + @menu + * Running gnatls:: + * Switches for gnatls:: + * Examples of gnatls Usage:: + @end menu + + @node Running gnatls + @section Running @code{gnatls} + + @noindent + The @code{gnatls} command has the form + + @smallexample + $ gnatls switches @var{object_or_ali_file} + @end smallexample + + @noindent + The main argument is the list of object or @file{ali} files + (@pxref{The Ada Library Information Files}) + for which information is requested. + + In normal mode, without additional option, @code{gnatls} produces a + four-column listing. Each line represents information for a specific + object. The first column gives the full path of the object, the second + column gives the name of the principal unit in this object, the third + column gives the status of the source and the fourth column gives the + full path of the source representing this unit. + Here is a simple example of use: + + @smallexample + $ gnatls *.o + ./demo1.o demo1 DIF demo1.adb + ./demo2.o demo2 OK demo2.adb + ./hello.o h1 OK hello.adb + ./instr-child.o instr.child MOK instr-child.adb + ./instr.o instr OK instr.adb + ./tef.o tef DIF tef.adb + ./text_io_example.o text_io_example OK text_io_example.adb + ./tgef.o tgef DIF tgef.adb + @end smallexample + + @noindent + The first line can be interpreted as follows: the main unit which is + contained in + object file @file{demo1.o} is demo1, whose main source is in + @file{demo1.adb}. Furthermore, the version of the source used for the + compilation of demo1 has been modified (DIF). Each source file has a status + qualifier which can be: + + @table @code + @item OK (unchanged) + The version of the source file used for the compilation of the + specified unit corresponds exactly to the actual source file. + + @item MOK (slightly modified) + The version of the source file used for the compilation of the + specified unit differs from the actual source file but not enough to + require recompilation. If you use gnatmake with the qualifier + @code{-m (minimal recompilation)}, a file marked + MOK will not be recompiled. + + @item DIF (modified) + No version of the source found on the path corresponds to the source + used to build this object. + + @item ??? (file not found) + No source file was found for this unit. + + @item HID (hidden, unchanged version not first on PATH) + The version of the source that corresponds exactly to the source used + for compilation has been found on the path but it is hidden by another + version of the same source that has been modified. + + @end table + + @node Switches for gnatls + @section Switches for @code{gnatls} + + @noindent + @code{gnatls} recognizes the following switches: + + @table @code + @item -a + @cindex @code{-a} (@code{gnatls}) + Consider all units, including those of the predefined Ada library. + Especially useful with @code{-d}. + + @item -d + @cindex @code{-d} (@code{gnatls}) + List sources from which specified units depend on. + + @item -h + @cindex @code{-h} (@code{gnatls}) + Output the list of options. + + @item -o + @cindex @code{-o} (@code{gnatls}) + Only output information about object files. + + @item -s + @cindex @code{-s} (@code{gnatls}) + Only output information about source files. + + @item -u + @cindex @code{-u} (@code{gnatls}) + Only output information about compilation units. + + @item -aO@var{dir} + @itemx -aI@var{dir} + @itemx -I@var{dir} + @itemx -I- + @itemx -nostdinc + Source path manipulation. Same meaning as the equivalent @code{gnatmake} flags + (see @ref{Switches for gnatmake}). + + @item --RTS=@var{rts-path} + @cindex @code{--RTS} (@code{gnatls}) + Specifies the default location of the runtime library. Same meaning as the + equivalent @code{gnatmake} flag (see @ref{Switches for gnatmake}). + + @item -v + @cindex @code{-s} (@code{gnatls}) + Verbose mode. Output the complete source and object paths. Do not use + the default column layout but instead use long format giving as much as + information possible on each requested units, including special + characteristics such as: + + @table @code + @item Preelaborable + The unit is preelaborable in the Ada 95 sense. + + @item No_Elab_Code + No elaboration code has been produced by the compiler for this unit. + + @item Pure + The unit is pure in the Ada 95 sense. + + @item Elaborate_Body + The unit contains a pragma Elaborate_Body. + + @item Remote_Types + The unit contains a pragma Remote_Types. + + @item Shared_Passive + The unit contains a pragma Shared_Passive. + + @item Predefined + This unit is part of the predefined environment and cannot be modified + by the user. + + @item Remote_Call_Interface + The unit contains a pragma Remote_Call_Interface. + + @end table + + @end table + + @node Examples of gnatls Usage + @section Example of @code{gnatls} Usage + + @noindent + Example of using the verbose switch. Note how the source and + object paths are affected by the -I switch. + + @smallexample + $ gnatls -v -I.. demo1.o + + GNATLS 3.10w (970212) Copyright 1999 Free Software Foundation, Inc. + + Source Search Path: + + ../ + /home/comar/local/adainclude/ + + Object Search Path: + + ../ + /home/comar/local/lib/gcc-lib/mips-sni-sysv4/2.7.2/adalib/ + + ./demo1.o + Unit => + Name => demo1 + Kind => subprogram body + Flags => No_Elab_Code + Source => demo1.adb modified + @end smallexample + + @noindent + The following is an example of use of the dependency list. + Note the use of the -s switch + which gives a straight list of source files. This can be useful for + building specialized scripts. + + @smallexample + $ gnatls -d demo2.o + ./demo2.o demo2 OK demo2.adb + OK gen_list.ads + OK gen_list.adb + OK instr.ads + OK instr-child.ads + + $ gnatls -d -s -a demo1.o + demo1.adb + /home/comar/local/adainclude/ada.ads + /home/comar/local/adainclude/a-finali.ads + /home/comar/local/adainclude/a-filico.ads + /home/comar/local/adainclude/a-stream.ads + /home/comar/local/adainclude/a-tags.ads + gen_list.ads + gen_list.adb + /home/comar/local/adainclude/gnat.ads + /home/comar/local/adainclude/g-io.ads + instr.ads + /home/comar/local/adainclude/system.ads + /home/comar/local/adainclude/s-exctab.ads + /home/comar/local/adainclude/s-finimp.ads + /home/comar/local/adainclude/s-finroo.ads + /home/comar/local/adainclude/s-secsta.ads + /home/comar/local/adainclude/s-stalib.ads + /home/comar/local/adainclude/s-stoele.ads + /home/comar/local/adainclude/s-stratt.ads + /home/comar/local/adainclude/s-tasoli.ads + /home/comar/local/adainclude/s-unstyp.ads + /home/comar/local/adainclude/unchconv.ads + @end smallexample + + + @node GNAT and Libraries + @chapter GNAT and Libraries + @cindex Library, building, installing + + @noindent + This chapter addresses some of the issues related to building and using + a library with GNAT. It also shows how the GNAT run-time library can be + recompiled. + + @menu + * Creating an Ada Library:: + * Installing an Ada Library:: + * Using an Ada Library:: + * Creating an Ada Library to be Used in a Non-Ada Context:: + * Rebuilding the GNAT Run-Time Library:: + @end menu + + @node Creating an Ada Library + @section Creating an Ada Library + + @noindent + In the GNAT environment, a library has two components: + @itemize @bullet + @item + Source files. + @item + Compiled code and Ali files. See @ref{The Ada Library Information Files}. + @end itemize + + @noindent + In order to use other packages @ref{The GNAT Compilation Model} + requires a certain number of sources to be available to the compiler. + The minimal set of + sources required includes the specs of all the packages that make up the + visible part of the library as well as all the sources upon which they + depend. The bodies of all visible generic units must also be provided. + @noindent + Although it is not strictly mandatory, it is recommended that all sources + needed to recompile the library be provided, so that the user can make + full use of inter-unit inlining and source-level debugging. This can also + make the situation easier for users that need to upgrade their compilation + toolchain and thus need to recompile the library from sources. + + @noindent + The compiled code can be provided in different ways. The simplest way is + to provide directly the set of objects produced by the compiler during + the compilation of the library. It is also possible to group the objects + into an archive using whatever commands are provided by the operating + system. Finally, it is also possible to create a shared library (see + option -shared in the GCC manual). + + @noindent + There are various possibilities for compiling the units that make up the + library: for example with a Makefile @ref{Using the GNU make Utility}, + or with a conventional script. + For simple libraries, it is also possible to create a + dummy main program which depends upon all the packages that comprise the + interface of the library. This dummy main program can then be given to + gnatmake, in order to build all the necessary objects. Here is an example + of such a dummy program and the generic commands used to build an + archive or a shared library. + + @smallexample + @iftex + @leftskip=.7cm + @end iftex + @b{with} My_Lib.Service1; + @b{with} My_Lib.Service2; + @b{with} My_Lib.Service3; + @b{procedure} My_Lib_Dummy @b{is} + @b{begin} + @b{null}; + @b{end}; + + # compiling the library + $ gnatmake -c my_lib_dummy.adb + + # we don't need the dummy object itself + $ rm my_lib_dummy.o my_lib_dummy.ali + + # create an archive with the remaining objects + $ ar rc libmy_lib.a *.o + # some systems may require "ranlib" to be run as well + + # or create a shared library + $ gcc -shared -o libmy_lib.so *.o + # some systems may require the code to have been compiled with -fPIC + @end smallexample + + @noindent + When the objects are grouped in an archive or a shared library, the user + needs to specify the desired library at link time, unless a pragma + linker_options has been used in one of the sources: + @smallexample + @b{pragma} Linker_Options ("-lmy_lib"); + @end smallexample + + @node Installing an Ada Library + @section Installing an Ada Library + + @noindent + In the GNAT model, installing a library consists in copying into a specific + location the files that make up this library. It is possible to install + the sources in a different directory from the other files (ALI, objects, + archives) since the source path and the object path can easily be + specified separately. + + @noindent + For general purpose libraries, it is possible for the system + administrator to put those libraries in the default compiler paths. To + achieve this, he must specify their location in the configuration files + "ada_source_path" and "ada_object_path" that must be located in the GNAT + installation tree at the same place as the gcc spec file. The location of + the gcc spec file can be determined as follows: + @smallexample + $ gcc -v + @end smallexample + + @noindent + The configuration files mentioned above have simple format: each line in them + must contain one unique + directory name. Those names are added to the corresponding path + in their order of appearance in the file. The names can be either absolute + or relative, in the latter case, they are relative to where theses files + are located. + + @noindent + "ada_source_path" and "ada_object_path" might actually not be present in a + GNAT installation, in which case, GNAT will look for its run-time library in + the directories "adainclude" for the sources and "adalib" for the + objects and ALI files. When the files exist, the compiler does not + look in "adainclude" and "adalib" at all, and thus the "ada_source_path" file + must contain the location for the GNAT run-time sources (which can simply + be "adainclude"). In the same way, the "ada_object_path" file must contain + the location for the GNAT run-time objects (which can simply + be "adalib"). + + @noindent + You can also specify a new default path to the runtime library at compilation + time with the switch "--RTS=@var{rts-path}". You can easily choose and change + the runtime you want your program to be compiled with. This switch is + recognized by gcc, gnatmake, gnatbind, gnatls, gnatfind and gnatxref. + + @noindent + It is possible to install a library before or after the standard GNAT + library, by reordering the lines in the configuration files. In general, a + library must be installed before the GNAT library if it redefines any part of it. + + @node Using an Ada Library + @section Using an Ada Library + + @noindent + In order to use a Ada library, you need to make sure that this + library is on both your source and object path + @ref{Search Paths and the Run-Time Library (RTL)} + and @ref{Search Paths for gnatbind}. For + instance, you can use the library "mylib" installed in "/dir/my_lib_src" + and "/dir/my_lib_obj" with the following commands: + + @smallexample + $ gnatmake -aI/dir/my_lib_src -aO/dir/my_lib_obj my_appl \ + -largs -lmy_lib + @end smallexample + + @noindent + This can be simplified down to the following: + @smallexample + $ gnatmake my_appl + @end smallexample + when the following conditions are met: + @itemize @bullet + @item + "/dir/my_lib_src" has been added by the user to the environment + variable "ADA_INCLUDE_PATH", or by the administrator to the file + "ada_source_path" + @item + "/dir/my_lib_obj" has been added by the user to the environment + variable "ADA_OBJECTS_PATH", or by the administrator to the file + "ada_object_path" + @item + a pragma linker_options, as mentioned in @ref{Creating an Ada Library} + as been added to the sources. + @end itemize + @noindent + + @node Creating an Ada Library to be Used in a Non-Ada Context + @section Creating an Ada Library to be Used in a Non-Ada Context + + @noindent + The previous sections detailed how to create and install a library that + was usable from an Ada main program. Using this library in a non-Ada + context is not possible, because the elaboration of the library is + automatically done as part of the main program elaboration. + + GNAT also provides the ability to build libraries that can be used both + in an Ada and non-Ada context. This section describes how to build such + a library, and then how to use it from a C program. The method for + interfacing with the library from other languages such as Fortran for + instance remains the same. + + @subsection Creating the Library + + @itemize @bullet + @item Identify the units representing the interface of the library. + + Here is an example of simple library interface: + + @smallexample + package Interface is + + procedure Do_Something; + + procedure Do_Something_Else; + + end Interface; + @end smallexample + + @item Use @code{pragma Export} or @code{pragma Convention} for the + exported entities. + + Our package @code{Interface} is then updated as follow: + @smallexample + package Interface is + + procedure Do_Something; + pragma Export (C, Do_Something, "do_something"); + + procedure Do_Something_Else; + pragma Export (C, Do_Something_Else, "do_something_else"); + + end Interface; + @end smallexample + + @item Compile all the units composing the library. + + @item Bind the library objects. + + This step is performed by invoking gnatbind with the @code{-L} + switch. @code{gnatbind} will then generate the library elaboration + procedure (named @code{init}) and the run-time finalization + procedure (named @code{final}). + + @smallexample + # generate the binder file in Ada + $ gnatbind -Lmylib interface + + # generate the binder file in C + $ gnatbind -C -Lmylib interface + @end smallexample + + @item Compile the files generated by the binder + + @smallexample + $ gcc -c b~interface.adb + @end smallexample + + @item Create the library; + + The procedure is identical to the procedure explained in + @ref{Creating an Ada Library}, + except that @file{b~interface.o} needs to be added to + the list of objects. + + @smallexample + # create an archive file + $ ar cr libmylib.a b~interface.o + + # create a shared library + $ gcc -shared -o libmylib.so b~interface.o + @end smallexample + + @item Provide a "foreign" view of the library interface; + + The example below shows the content of @code{mylib_interface.h} (note + that there is no rule for the naming of this file, any name can be used) + @smallexample + /* the library elaboration procedure */ + extern void mylibinit (void); + + /* the library finalization procedure */ + extern void mylibfinal (void); + + /* the interface exported by the library */ + extern void do_something (void); + extern void do_something_else (void); + @end smallexample + @end itemize + + @subsection Using the Library + + @noindent + Libraries built as explained above can be used from any program, provided + that the elaboration procedures (named @code{mylibinit} in the previous + example) are called before the library services are used. Any number of + libraries can be used simultaneously, as long as the elaboration + procedure of each library is called. + + Below is an example of C program that uses our @code{mylib} library. + + @smallexample + #include "mylib_interface.h" + + int + main (void) + @{ + /* First, elaborate the library before using it */ + mylibinit (); + + /* Main program, using the library exported entities */ + do_something (); + do_something_else (); + + /* Library finalization at the end of the program */ + mylibfinal (); + return 0; + @} + @end smallexample + + @noindent + Note that this same library can be used from an equivalent Ada main + program. In addition, if the libraries are installed as detailed in + @ref{Installing an Ada Library}, it is not necessary to invoke the + library elaboration and finalization routines. The binder will ensure + that this is done as part of the main program elaboration and + finalization phases. + + @subsection The Finalization Phase + + @noindent + Invoking any library finalization procedure generated by @code{gnatbind} + shuts down the Ada run time permanently. Consequently, the finalization + of all Ada libraries must be performed at the end of the program. No + call to these libraries nor the Ada run time should be made past the + finalization phase. + + @subsection Restrictions in Libraries + + @noindent + The pragmas listed below should be used with caution inside libraries, + as they can create incompatibilities with other Ada libraries: + @itemize @bullet + @item pragma @code{Locking_Policy} + @item pragma @code{Queuing_Policy} + @item pragma @code{Task_Dispatching_Policy} + @item pragma @code{Unreserve_All_Interrupts} + @end itemize + When using a library that contains such pragmas, the user must make sure + that all libraries use the same pragmas with the same values. Otherwise, + a @code{Program_Error} will + be raised during the elaboration of the conflicting + libraries. The usage of these pragmas and its consequences for the user + should therefore be well documented. + + Similarly, the traceback in exception occurrences mechanism should be + enabled or disabled in a consistent manner across all libraries. + Otherwise, a Program_Error will be raised during the elaboration of the + conflicting libraries. + + If the @code{'Version} and @code{'Body_Version} + attributes are used inside a library, then it is necessary to + perform a @code{gnatbind} step that mentions all ali files in all + libraries, so that version identifiers can be properly computed. + In practice these attributes are rarely used, so this is unlikely + to be a consideration. + + @node Rebuilding the GNAT Run-Time Library + @section Rebuilding the GNAT Run-Time Library + + @noindent + It may be useful to recompile the GNAT library in various contexts, the + most important one being the use of partition-wide configuration pragmas + such as Normalize_Scalar. A special Makefile called + @code{Makefile.adalib} is provided to that effect and can be found in + the directory containing the GNAT library. The location of this + directory depends on the way the GNAT environment has been installed and can + be determined by means of the command: + + @smallexample + $ gnatls -v + @end smallexample + + @noindent + The last entry in the object search path usually contains the + gnat library. This Makefile contains its own documentation and in + particular the set of instructions needed to rebuild a new library and + to use it. + + @node Using the GNU make Utility + @chapter Using the GNU @code{make} Utility + @findex make + + @noindent + This chapter offers some examples of makefiles that solve specific + problems. It does not explain how to write a makefile (see the GNU make + documentation), nor does it try to replace the @code{gnatmake} utility + (@pxref{The GNAT Make Program gnatmake}). + + All the examples in this section are specific to the GNU version of + make. Although @code{make} is a standard utility, and the basic language + is the same, these examples use some advanced features found only in + @code{GNU make}. + + @menu + * Using gnatmake in a Makefile:: + * Automatically Creating a List of Directories:: + * Generating the Command Line Switches:: + * Overcoming Command Line Length Limits:: + @end menu + + @node Using gnatmake in a Makefile + @section Using gnatmake in a Makefile + @findex makefile + @cindex GNU make + + @noindent + Complex project organizations can be handled in a very powerful way by + using GNU make combined with gnatmake. For instance, here is a Makefile + which allows you to build each subsystem of a big project into a separate + shared library. Such a makefile allows you to significantly reduce the link + time of very big applications while maintaining full coherence at + each step of the build process. + + The list of dependencies are handled automatically by + @code{gnatmake}. The Makefile is simply used to call gnatmake in each of + the appropriate directories. + + Note that you should also read the example on how to automatically + create the list of directories (@pxref{Automatically Creating a List of Directories}) + which might help you in case your project has a lot of + subdirectories. + + @smallexample + @iftex + @leftskip=0cm + @font@heightrm=cmr8 + @heightrm + @end iftex + ## This Makefile is intended to be used with the following directory + ## configuration: + ## - The sources are split into a series of csc (computer software components) + ## Each of these csc is put in its own directory. + ## Their name are referenced by the directory names. + ## They will be compiled into shared library (although this would also work + ## with static libraries + ## - The main program (and possibly other packages that do not belong to any + ## csc is put in the top level directory (where the Makefile is). + ## toplevel_dir __ first_csc (sources) __ lib (will contain the library) + ## \_ second_csc (sources) __ lib (will contain the library) + ## \_ ... + ## Although this Makefile is build for shared library, it is easy to modify + ## to build partial link objects instead (modify the lines with -shared and + ## gnatlink below) + ## + ## With this makefile, you can change any file in the system or add any new + ## file, and everything will be recompiled correctly (only the relevant shared + ## objects will be recompiled, and the main program will be re-linked). + + # The list of computer software component for your project. This might be + # generated automatically. + CSC_LIST=aa bb cc + + # Name of the main program (no extension) + MAIN=main + + # If we need to build objects with -fPIC, uncomment the following line + #NEED_FPIC=-fPIC + + # The following variable should give the directory containing libgnat.so + # You can get this directory through 'gnatls -v'. This is usually the last + # directory in the Object_Path. + GLIB=... + + # The directories for the libraries + # (This macro expands the list of CSC to the list of shared libraries, you + # could simply use the expanded form : + # LIB_DIR=aa/lib/libaa.so bb/lib/libbb.so cc/lib/libcc.so + LIB_DIR=$@{foreach dir,$@{CSC_LIST@},$@{dir@}/lib/lib$@{dir@}.so@} + + $@{MAIN@}: objects $@{LIB_DIR@} + gnatbind $@{MAIN@} $@{CSC_LIST:%=-aO%/lib@} -shared + gnatlink $@{MAIN@} $@{CSC_LIST:%=-l%@} + + objects:: + # recompile the sources + gnatmake -c -i $@{MAIN@}.adb $@{NEED_FPIC@} $@{CSC_LIST:%=-I%@} + + # Note: In a future version of GNAT, the following commands will be simplified + # by a new tool, gnatmlib + $@{LIB_DIR@}: + mkdir -p $@{dir $@@ @} + cd $@{dir $@@ @}; gcc -shared -o $@{notdir $@@ @} ../*.o -L$@{GLIB@} -lgnat + cd $@{dir $@@ @}; cp -f ../*.ali . + + # The dependencies for the modules + # Note that we have to force the expansion of *.o, since in some cases make won't + # be able to do it itself. + aa/lib/libaa.so: $@{wildcard aa/*.o@} + bb/lib/libbb.so: $@{wildcard bb/*.o@} + cc/lib/libcc.so: $@{wildcard cc/*.o@} + + # Make sure all of the shared libraries are in the path before starting the + # program + run:: + LD_LIBRARY_PATH=`pwd`/aa/lib:`pwd`/bb/lib:`pwd`/cc/lib ./$@{MAIN@} + + clean:: + $@{RM@} -rf $@{CSC_LIST:%=%/lib@} + $@{RM@} $@{CSC_LIST:%=%/*.ali@} + $@{RM@} $@{CSC_LIST:%=%/*.o@} + $@{RM@} *.o *.ali $@{MAIN@} + @end smallexample + + @node Automatically Creating a List of Directories + @section Automatically Creating a List of Directories + + @noindent + In most makefiles, you will have to specify a list of directories, and + store it in a variable. For small projects, it is often easier to + specify each of them by hand, since you then have full control over what + is the proper order for these directories, which ones should be + included... + + However, in larger projects, which might involve hundreds of + subdirectories, it might be more convenient to generate this list + automatically. + + The example below presents two methods. The first one, although less + general, gives you more control over the list. It involves wildcard + characters, that are automatically expanded by @code{make}. Its + shortcoming is that you need to explicitly specify some of the + organization of your project, such as for instance the directory tree + depth, whether some directories are found in a separate tree,... + + The second method is the most general one. It requires an external + program, called @code{find}, which is standard on all Unix systems. All + the directories found under a given root directory will be added to the + list. + + @smallexample + @iftex + @leftskip=0cm + @font@heightrm=cmr8 + @heightrm + @end iftex + # The examples below are based on the following directory hierarchy: + # All the directories can contain any number of files + # ROOT_DIRECTORY -> a -> aa -> aaa + # -> ab + # -> ac + # -> b -> ba -> baa + # -> bb + # -> bc + # This Makefile creates a variable called DIRS, that can be reused any time + # you need this list (see the other examples in this section) + + # The root of your project's directory hierarchy + ROOT_DIRECTORY=. + + #### + # First method: specify explicitly the list of directories + # This allows you to specify any subset of all the directories you need. + #### + + DIRS := a/aa/ a/ab/ b/ba/ + + #### + # Second method: use wildcards + # Note that the argument(s) to wildcard below should end with a '/'. + # Since wildcards also return file names, we have to filter them out + # to avoid duplicate directory names. + # We thus use make's @code{dir} and @code{sort} functions. + # It sets DIRs to the following value (note that the directories aaa and baa + # are not given, unless you change the arguments to wildcard). + # DIRS= ./a/a/ ./b/ ./a/aa/ ./a/ab/ ./a/ac/ ./b/ba/ ./b/bb/ ./b/bc/ + #### + + DIRS := $@{sort $@{dir $@{wildcard $@{ROOT_DIRECTORY@}/*/ $@{ROOT_DIRECTORY@}/*/*/@}@}@} + + #### + # Third method: use an external program + # This command is much faster if run on local disks, avoiding NFS slowdowns. + # This is the most complete command: it sets DIRs to the following value: + # DIRS= ./a ./a/aa ./a/aa/aaa ./a/ab ./a/ac ./b ./b/ba ./b/ba/baa ./b/bb ./b/bc + #### + + DIRS := $@{shell find $@{ROOT_DIRECTORY@} -type d -print@} + + @end smallexample + + @node Generating the Command Line Switches + @section Generating the Command Line Switches + + @noindent + Once you have created the list of directories as explained in the + previous section (@pxref{Automatically Creating a List of Directories}), + you can easily generate the command line arguments to pass to gnatmake. + + For the sake of completeness, this example assumes that the source path + is not the same as the object path, and that you have two separate lists + of directories. + + @smallexample + # see "Automatically creating a list of directories" to create + # these variables + SOURCE_DIRS= + OBJECT_DIRS= + + GNATMAKE_SWITCHES := $@{patsubst %,-aI%,$@{SOURCE_DIRS@}@} + GNATMAKE_SWITCHES += $@{patsubst %,-aO%,$@{OBJECT_DIRS@}@} + + all: + gnatmake $@{GNATMAKE_SWITCHES@} main_unit + @end smallexample + + @node Overcoming Command Line Length Limits + @section Overcoming Command Line Length Limits + + @noindent + One problem that might be encountered on big projects is that many + operating systems limit the length of the command line. It is thus hard to give + gnatmake the list of source and object directories. + + This example shows how you can set up environment variables, which will + make @code{gnatmake} behave exactly as if the directories had been + specified on the command line, but have a much higher length limit (or + even none on most systems). + + It assumes that you have created a list of directories in your Makefile, + using one of the methods presented in + @ref{Automatically Creating a List of Directories}. + For the sake of completeness, we assume that the object + path (where the ALI files are found) is different from the sources patch. + + Note a small trick in the Makefile below: for efficiency reasons, we + create two temporary variables (SOURCE_LIST and OBJECT_LIST), that are + expanded immediately by @code{make}. This way we overcome the standard + make behavior which is to expand the variables only when they are + actually used. + + @smallexample + @iftex + @leftskip=0cm + @font@heightrm=cmr8 + @heightrm + @end iftex + # In this example, we create both ADA_INCLUDE_PATH and ADA_OBJECT_PATH. + # This is the same thing as putting the -I arguments on the command line. + # (the equivalent of using -aI on the command line would be to define + # only ADA_INCLUDE_PATH, the equivalent of -aO is ADA_OBJECT_PATH). + # You can of course have different values for these variables. + # + # Note also that we need to keep the previous values of these variables, since + # they might have been set before running 'make' to specify where the GNAT + # library is installed. + + # see "Automatically creating a list of directories" to create these + # variables + SOURCE_DIRS= + OBJECT_DIRS= + + empty:= + space:=$@{empty@} $@{empty@} + SOURCE_LIST := $@{subst $@{space@},:,$@{SOURCE_DIRS@}@} + OBJECT_LIST := $@{subst $@{space@},:,$@{OBJECT_DIRS@}@} + ADA_INCLUDE_PATH += $@{SOURCE_LIST@} + ADA_OBJECT_PATH += $@{OBJECT_LIST@} + export ADA_INCLUDE_PATH + export ADA_OBJECT_PATH + + all: + gnatmake main_unit + @end smallexample + + @node Finding Memory Problems with gnatmem + @chapter Finding Memory Problems with @code{gnatmem} + @findex gnatmem + + @noindent + @code{gnatmem}, is a tool that monitors dynamic allocation and + deallocation activity in a program, and displays information about + incorrect deallocations and possible sources of memory leaks. Gnatmem + provides three type of information: + @itemize @bullet + @item + General information concerning memory management, such as the total + number of allocations and deallocations, the amount of allocated + memory and the high water mark, i.e. the largest amount of allocated + memory in the course of program execution. + + @item + Backtraces for all incorrect deallocations, that is to say deallocations + which do not correspond to a valid allocation. + + @item + Information on each allocation that is potentially the origin of a memory + leak. + @end itemize + + The @code{gnatmem} command has two modes. It can be used with @code{gdb} + or with instrumented allocation and deallocation routines. The later + mode is called the @code{GMEM} mode. Both modes produce the very same + output. + + @menu + * Running gnatmem (GDB Mode):: + * Running gnatmem (GMEM Mode):: + * Switches for gnatmem:: + * Examples of gnatmem Usage:: + * GDB and GMEM Modes:: + * Implementation Note:: + @end menu + + @node Running gnatmem (GDB Mode) + @section Running @code{gnatmem} (GDB Mode) + + @noindent + The @code{gnatmem} command has the form + + @smallexample + $ gnatmem [-q] [n] [-o file] user_program [program_arg]* + or + $ gnatmem [-q] [n] -i file + @end smallexample + + @noindent + Gnatmem must be supplied with the executable to examine, followed by its + run-time inputs. For example, if a program is executed with the command: + @smallexample + $ my_program arg1 arg2 + @end smallexample + then it can be run under @code{gnatmem} control using the command: + @smallexample + $ gnatmem my_program arg1 arg2 + @end smallexample + + The program is transparently executed under the control of the debugger + @ref{The GNAT Debugger GDB}. This does not affect the behavior + of the program, except for sensitive real-time programs. When the program + has completed execution, @code{gnatmem} outputs a report containing general + allocation/deallocation information and potential memory leak. + For better results, the user program should be compiled with + debugging options @ref{Switches for gcc}. + + Here is a simple example of use: + + *************** debut cc + @smallexample + $ gnatmem test_gm + + Global information + ------------------ + Total number of allocations : 45 + Total number of deallocations : 6 + Final Water Mark (non freed mem) : 11.29 Kilobytes + High Water Mark : 11.40 Kilobytes + + . + . + . + Allocation Root # 2 + ------------------- + Number of non freed allocations : 11 + Final Water Mark (non freed mem) : 1.16 Kilobytes + High Water Mark : 1.27 Kilobytes + Backtrace : + test_gm.adb:23 test_gm.alloc + . + . + . + @end smallexample + + The first block of output give general information. In this case, the + Ada construct "@b{new}" was executed 45 times, and only 6 calls to an + unchecked deallocation routine occurred. + + Subsequent paragraphs display information on all allocation roots. + An allocation root is a specific point in the execution of the program + that generates some dynamic allocation, such as a "@b{new}" construct. This + root is represented by an execution backtrace (or subprogram call + stack). By default the backtrace depth for allocations roots is 1, so + that a root corresponds exactly to a source location. The backtrace can + be made deeper, to make the root more specific. + + @node Running gnatmem (GMEM Mode) + @section Running @code{gnatmem} (GMEM Mode) + @cindex @code{GMEM} (@code{gnatmem}) + + @noindent + The @code{gnatmem} command has the form + + @smallexample + $ gnatmem [-q] [n] -i gmem.out user_program [program_arg]* + @end smallexample + + The program must have been linked with the instrumented version of the + allocation and deallocation routines. This is done with linking with the + @file{libgmem.a} library. For better results, the user program should be + compiled with debugging options @ref{Switches for gcc}. For example to + build @file{my_program}: + + @smallexample + $ gnatmake -g my_program -largs -lgmem + @end smallexample + + @noindent + When running @file{my_program} the file @file{gmem.out} is produced. This file + contains information about all allocations and deallocations done by the + program. It is produced by the instrumented allocations and + deallocations routines and will be used by @code{gnatmem}. + + @noindent + Gnatmem must be supplied with the @file{gmem.out} file and the executable to + examine followed by its run-time inputs. For example, if a program is + executed with the command: + @smallexample + $ my_program arg1 arg2 + @end smallexample + then @file{gmem.out} can be analysed by @code{gnatmem} using the command: + @smallexample + $ gnatmem -i gmem.out my_program arg1 arg2 + @end smallexample + + @node Switches for gnatmem + @section Switches for @code{gnatmem} + + @noindent + @code{gnatmem} recognizes the following switches: + + @table @code + + @item @code{-q} + @cindex @code{-q} (@code{gnatmem}) + Quiet. Gives the minimum output needed to identify the origin of the + memory leaks. Omit statistical information. + + @item @code{n} + @cindex @code{n} (@code{gnatmem}) + N is an integer literal (usually between 1 and 10) which controls the + depth of the backtraces defining allocation root. The default value for + N is 1. The deeper the backtrace, the more precise the localization of + the root. Note that the total number of roots can depend on this + parameter. + + @item @code{-o file} + @cindex @code{-o} (@code{gnatmem}) + Direct the gdb output to the specified file. The @code{gdb} script used + to generate this output is also saved in the file @file{gnatmem.tmp}. + + @item @code{-i file} + @cindex @code{-i} (@code{gnatmem}) + Do the @code{gnatmem} processing starting from @file{file} which has + been generated by a previous call to @code{gnatmem} with the -o + switch or @file{gmem.out} produced by @code{GMEM} mode. This is useful + for post mortem processing. + + @end table + + @node Examples of gnatmem Usage + @section Example of @code{gnatmem} Usage + + @noindent + This section is based on the @code{GDB} mode of @code{gnatmem}. The same + results can be achieved using @code{GMEM} mode. See section + @ref{Running gnatmem (GMEM Mode)}. + + @noindent + The first example shows the use of @code{gnatmem} + on a simple leaking program. + Suppose that we have the following Ada program: + + @smallexample + @group + @cartouche + @b{with} Unchecked_Deallocation; + @b{procedure} Test_Gm @b{is} + + @b{type} T @b{is array} (1..1000) @b{of} Integer; + @b{type} Ptr @b{is access} T; + @b{procedure} Free @b{is new} Unchecked_Deallocation (T, Ptr); + A : Ptr; + + @b{procedure} My_Alloc @b{is} + @b{begin} + A := @b{new} T; + @b{end} My_Alloc; + + @b{procedure} My_DeAlloc @b{is} + B : Ptr := A; + @b{begin} + Free (B); + @b{end} My_DeAlloc; + + @b{begin} + My_Alloc; + @b{for} I @b{in} 1 .. 5 @b{loop} + @b{for} J @b{in} I .. 5 @b{loop} + My_Alloc; + @b{end loop}; + My_Dealloc; + @b{end loop}; + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + The program needs to be compiled with debugging option: + + @smallexample + $ gnatmake -g test_gm + @end smallexample + + @code{gnatmem} is invoked simply with + @smallexample + $ gnatmem test_gm + @end smallexample + + @noindent + which produces the following output: + + @smallexample + Global information + ------------------ + Total number of allocations : 18 + Total number of deallocations : 5 + Final Water Mark (non freed mem) : 53.00 Kilobytes + High Water Mark : 56.90 Kilobytes + + Allocation Root # 1 + ------------------- + Number of non freed allocations : 11 + Final Water Mark (non freed mem) : 42.97 Kilobytes + High Water Mark : 46.88 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + + Allocation Root # 2 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 10.02 Kilobytes + High Water Mark : 10.02 Kilobytes + Backtrace : + s-secsta.adb:81 system.secondary_stack.ss_init + + Allocation Root # 3 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 12 Bytes + High Water Mark : 12 Bytes + Backtrace : + s-secsta.adb:181 system.secondary_stack.ss_init + @end smallexample + + @noindent + Note that the GNAT run time contains itself a certain number of + allocations that have no corresponding deallocation, + as shown here for root #2 and root + #1. This is a normal behavior when the number of non freed allocations + is one, it locates dynamic data structures that the run time needs for + the complete lifetime of the program. Note also that there is only one + allocation root in the user program with a single line back trace: + test_gm.adb:11 test_gm.my_alloc, whereas a careful analysis of the + program shows that 'My_Alloc' is called at 2 different points in the + source (line 21 and line 24). If those two allocation roots need to be + distinguished, the backtrace depth parameter can be used: + + @smallexample + $ gnatmem 3 test_gm + @end smallexample + + @noindent + which will give the following output: + + @smallexample + Global information + ------------------ + Total number of allocations : 18 + Total number of deallocations : 5 + Final Water Mark (non freed mem) : 53.00 Kilobytes + High Water Mark : 56.90 Kilobytes + + Allocation Root # 1 + ------------------- + Number of non freed allocations : 10 + Final Water Mark (non freed mem) : 39.06 Kilobytes + High Water Mark : 42.97 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + test_gm.adb:24 test_gm + b_test_gm.c:52 main + + Allocation Root # 2 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 10.02 Kilobytes + High Water Mark : 10.02 Kilobytes + Backtrace : + s-secsta.adb:81 system.secondary_stack.ss_init + s-secsta.adb:283 + b_test_gm.c:33 adainit + + Allocation Root # 3 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 3.91 Kilobytes + High Water Mark : 3.91 Kilobytes + Backtrace : + test_gm.adb:11 test_gm.my_alloc + test_gm.adb:21 test_gm + b_test_gm.c:52 main + + Allocation Root # 4 + ------------------- + Number of non freed allocations : 1 + Final Water Mark (non freed mem) : 12 Bytes + High Water Mark : 12 Bytes + Backtrace : + s-secsta.adb:181 system.secondary_stack.ss_init + s-secsta.adb:283 + b_test_gm.c:33 adainit + @end smallexample + + @noindent + The allocation root #1 of the first example has been split in 2 roots #1 + and #3 thanks to the more precise associated backtrace. + + @node GDB and GMEM Modes + @section GDB and GMEM Modes + + @noindent + The main advantage of the @code{GMEM} mode is that it is a lot faster than the + @code{GDB} mode where the application must be monitored by a @code{GDB} script. + But the @code{GMEM} mode is available only for DEC Unix, Linux x86, + Solaris (sparc and x86) and Windows 95/98/NT/2000 (x86). + + @noindent + The main advantage of the @code{GDB} mode is that it is available on all + supported platforms. But it can be very slow if the application does a + lot of allocations and deallocations. + + @node Implementation Note + @section Implementation Note + + @menu + * gnatmem Using GDB Mode:: + * gnatmem Using GMEM Mode:: + @end menu + + @node gnatmem Using GDB Mode + @subsection @code{gnatmem} Using @code{GDB} Mode + + @noindent + @code{gnatmem} executes the user program under the control of @code{GDB} using + a script that sets breakpoints and gathers information on each dynamic + allocation and deallocation. The output of the script is then analyzed + by @code{gnatmem} + in order to locate memory leaks and their origin in the + program. Gnatmem works by recording each address returned by the + allocation procedure (@code{__gnat_malloc}) + along with the backtrace at the + allocation point. On each deallocation, the deallocated address is + matched with the corresponding allocation. At the end of the processing, + the unmatched allocations are considered potential leaks. All the + allocations associated with the same backtrace are grouped together and + form an allocation root. The allocation roots are then sorted so that + those with the biggest number of unmatched allocation are printed + first. A delicate aspect of this technique is to distinguish between the + data produced by the user program and the data produced by the gdb + script. Currently, on systems that allow probing the terminal, the gdb + command "tty" is used to force the program output to be redirected to the + current terminal while the @code{gdb} output is directed to a file or to a + pipe in order to be processed subsequently by @code{gnatmem}. + + @node gnatmem Using GMEM Mode + @subsection @code{gnatmem} Using @code{GMEM} Mode + + @noindent + This mode use the same algorithm to detect memory leak as the @code{GDB} + mode of @code{gnatmem}, the only difference is in the way data are + gathered. In @code{GMEM} mode the program is linked with instrumented + version of @code{__gnat_malloc} and @code{__gnat_free} + routines. Information needed to find memory leak are recorded by these + routines in file @file{gmem.out}. This mode also require that the stack + traceback be available, this is only implemented on some platforms + @ref{GDB and GMEM Modes}. + + + @node Finding Memory Problems with GNAT Debug Pool + @chapter Finding Memory Problems with GNAT Debug Pool + @findex Debug Pool + @cindex storage, pool, memory corruption + + @noindent + The use of unchecked deallocation and unchecked conversion can easily + lead to incorrect memory references. The problems generated by such + references are usually difficult to tackle because the symptoms can be + very remote from the origin of the problem. In such cases, it is + very helpful to detect the problem as early as possible. This is the + purpose of the Storage Pool provided by @code{GNAT.Debug_Pools}. + + @noindent + In order to use the GNAT specific debugging pool, the user must + associate a debug pool object with each of the access types that may be + related to suspected memory problems. See Ada Reference Manual + 13.11. + @smallexample + @b{type} Ptr @b{is} @b{access} Some_Type; + Pool : GNAT.Debug_Pools.Debug_Pool; + @b{for} Ptr'Storage_Pool @b{use} Pool; + @end smallexample + + @code{GNAT.Debug_Pools} is derived from of a GNAT-specific kind of + pool: the Checked_Pool. Such pools, like standard Ada storage pools, + allow the user to redefine allocation and deallocation strategies. They + also provide a checkpoint for each dereference, through the use of + the primitive operation @code{Dereference} which is implicitly called at + each dereference of an access value. + + Once an access type has been associated with a debug pool, operations on + values of the type may raise four distinct exceptions, + which correspond to four potential kinds of memory corruption: + @itemize @bullet + @item + @code{GNAT.Debug_Pools.Accessing_Not_Allocated_Storage} + @item + @code{GNAT.Debug_Pools.Accessing_Deallocated_Storage} + @item + @code{GNAT.Debug_Pools.Freeing_Not_Allocated_Storage} + @item + @code{GNAT.Debug_Pools.Freeing_Deallocated_Storage } + @end itemize + + @noindent + For types associated with a Debug_Pool, dynamic allocation is performed using + the standard + GNAT allocation routine. References to all allocated chunks of memory + are kept in an internal dictionary. The deallocation strategy consists + in not releasing the memory to the underlying system but rather to fill + it with a memory pattern easily recognizable during debugging sessions: + The memory pattern is the old IBM hexadecimal convention: 16#DEADBEEF#. + Upon each dereference, a check is made that the access value denotes a properly + allocated memory location. Here is a complete example of use of + @code{Debug_Pools}, that includes typical instances of memory corruption: + @smallexample + @iftex + @leftskip=0cm + @end iftex + @b{with} Gnat.Io; @b{use} Gnat.Io; + @b{with} Unchecked_Deallocation; + @b{with} Unchecked_Conversion; + @b{with} GNAT.Debug_Pools; + @b{with} System.Storage_Elements; + @b{with} Ada.Exceptions; @b{use} Ada.Exceptions; + @b{procedure} Debug_Pool_Test @b{is} + + @b{type} T @b{is} @b{access} Integer; + @b{type} U @b{is} @b{access} @b{all} T; + + P : GNAT.Debug_Pools.Debug_Pool; + @b{for} T'Storage_Pool @b{use} P; + + @b{procedure} Free @b{is} @b{new} Unchecked_Deallocation (Integer, T); + @b{function} UC @b{is} @b{new} Unchecked_Conversion (U, T); + A, B : @b{aliased} T; + + @b{procedure} Info @b{is} @b{new} GNAT.Debug_Pools.Print_Info(Put_Line); + + @b{begin} + Info (P); + A := @b{new} Integer; + B := @b{new} Integer; + B := A; + Info (P); + Free (A); + @b{begin} + Put_Line (Integer'Image(B.@b{all})); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + @b{begin} + Free (B); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + B := UC(A'Access); + @b{begin} + Put_Line (Integer'Image(B.@b{all})); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + @b{begin} + Free (B); + @b{exception} + @b{when} E : @b{others} => Put_Line ("raised: " & Exception_Name (E)); + @b{end}; + Info (P); + @b{end} Debug_Pool_Test; + @end smallexample + @noindent + The debug pool mechanism provides the following precise diagnostics on the + execution of this erroneous program: + @smallexample + Debug Pool info: + Total allocated bytes : 0 + Total deallocated bytes : 0 + Current Water Mark: 0 + High Water Mark: 0 + + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 0 + Current Water Mark: 8 + High Water Mark: 8 + + raised: GNAT.DEBUG_POOLS.ACCESSING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_DEALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.ACCESSING_NOT_ALLOCATED_STORAGE + raised: GNAT.DEBUG_POOLS.FREEING_NOT_ALLOCATED_STORAGE + Debug Pool info: + Total allocated bytes : 8 + Total deallocated bytes : 4 + Current Water Mark: 4 + High Water Mark: 8 + + @end smallexample + + @node Creating Sample Bodies Using gnatstub + @chapter Creating Sample Bodies Using @code{gnatstub} + @findex gnatstub + + @noindent + @code{gnatstub} creates body stubs, that is, empty but compilable bodies + for library unit declarations. + + To create a body stub, @code{gnatstub} has to compile the library + unit declaration. Therefore, bodies can be created only for legal + library units. Moreover, if a library unit depends semantically upon + units located outside the current directory, you have to provide + the source search path when calling @code{gnatstub}, see the description + of @code{gnatstub} switches below. + + @menu + * Running gnatstub:: + * Switches for gnatstub:: + @end menu + + @node Running gnatstub + @section Running @code{gnatstub} + + @noindent + @code{gnatstub} has the command-line interface of the form + + @smallexample + $ gnatstub [switches] filename [directory] + @end smallexample + + @noindent + where + @table @code + @item filename + is the name of the source file that contains a library unit declaration + for which a body must be created. This name should follow the GNAT file name + conventions. No crunching is allowed for this file name. The file + name may contain the path information. + + @item directory + indicates the directory to place a body stub (default is the + current directory) + + @item switches + is an optional sequence of switches as described in the next section + @end table + + @node Switches for gnatstub + @section Switches for @code{gnatstub} + + @table @code + + @item -f + If the destination directory already contains a file with a name of the body file + for the argument spec file, replace it with the generated body stub. + + @item -hs + Put the comment header (i.e. all the comments preceding the + compilation unit) from the source of the library unit declaration + into the body stub. + + @item -hg + Put a sample comment header into the body stub. + + @item -IDIR + @itemx -I- + These switches have the same meaning as in calls to gcc. + They define the source search path in the call to gcc issued + by @code{gnatstub} to compile an argument source file. + + @item -i@var{n} + (@var{n} is a decimal natural number). Set the indentation level in the + generated body sample to n, '-i0' means "no indentation", + the default indentation is 3. + + @item -k + Do not remove the tree file (i.e. the snapshot of the compiler internal + structures used by @code{gnatstub}) after creating the body stub. + + @item -l@var{n} + (@var{n} is a decimal positive number) Set the maximum line length in the + body stub to n, the default is 78. + + @item -q + Quiet mode: do not generate a confirmation when a body is + successfully created or a message when a body is not required for an + argument unit. + + @item -r + Reuse the tree file (if it exists) instead of creating it: instead of + creating the tree file for the library unit declaration, gnatstub + tries to find it in the current directory and use it for creating + a body. If the tree file is not found, no body is created. @code{-r} + also implies @code{-k}, whether or not + @code{-k} is set explicitly. + + @item -t + Overwrite the existing tree file: if the current directory already + contains the file which, according to the GNAT file name rules should + be considered as a tree file for the argument source file, gnatstub + will refuse to create the tree file needed to create a body sampler, + unless @code{-t} option is set + + @item -v + Verbose mode: generate version information. + + @end table + + @node Reducing the Size of Ada Executables with gnatelim + @chapter Reducing the Size of Ada Executables with @code{gnatelim} + @findex gnatelim + + @menu + * About gnatelim:: + * Eliminate Pragma:: + * Tree Files:: + * Preparing Tree and Bind Files for gnatelim:: + * Running gnatelim:: + * Correcting the List of Eliminate Pragmas:: + * Making Your Executables Smaller:: + * Summary of the gnatelim Usage Cycle:: + @end menu + + @node About gnatelim + @section About @code{gnatelim} + + @noindent + When a program shares a set of Ada + packages with other programs, it may happen that this program uses + only a fraction of the subprograms defined in these packages. The code + created for these unused subprograms increases the size of the executable. + + @code{gnatelim} tracks unused subprograms in an Ada program and + outputs a list of GNAT-specific @code{Eliminate} pragmas (see next + section) marking all the subprograms that are declared but never called. + By placing the list of @code{Eliminate} pragmas in the GNAT configuration + file @file{gnat.adc} and recompiling your program, you may decrease the + size of its executable, because the compiler will not generate the code + for 'eliminated' subprograms. + + @code{gnatelim} needs as its input data a set of tree files + (see @ref{Tree Files}) representing all the components of a program to + process and a bind file for a main subprogram (see + @ref{Preparing Tree and Bind Files for gnatelim}). + + @node Eliminate Pragma + @section @code{Eliminate} Pragma + @findex Eliminate + + @noindent + The simplified syntax of the Eliminate pragma used by @code{gnatelim} is: + + @smallexample + @cartouche + @b{pragma} Eliminate (Library_Unit_Name, Subprogram_Name); + @end cartouche + @end smallexample + + @noindent + where + @table @code + @item Library_Unit_Name + full expanded Ada name of a library unit + + @item Subprogram_Name + a simple or expanded name of a subprogram declared within this + compilation unit + + @end table + + @noindent + The effect of an @code{Eliminate} pragma placed in the GNAT configuration + file @file{gnat.adc} is: + + @itemize @bullet + + @item + If the subprogram @code{Subprogram_Name} is declared within + the library unit @code{Library_Unit_Name}, the compiler will not generate + code for this subprogram. This applies to all overloaded subprograms denoted + by @code{Subprogram_Name}. + + @item + If a subprogram marked by the pragma @code{Eliminate} is used (called) + in a program, the compiler will produce an error message in the place where + it is called. + @end itemize + + @node Tree Files + @section Tree Files + @cindex Tree file + + @noindent + A tree file stores a snapshot of the compiler internal data + structures at the very end of a successful compilation. It contains all the + syntactic and semantic information for the compiled unit and all the + units upon which it depends semantically. + To use tools that make use of tree files, you + need to first produce the right set of tree files. + + GNAT produces correct tree files when -gnatt -gnatc options are set + in a gcc call. The tree files have an .adt extension. + Therefore, to produce a tree file for the compilation unit contained in a file + named @file{foo.adb}, you must use the command + + @smallexample + $ gcc -c -gnatc -gnatt foo.adb + @end smallexample + + @noindent + and you will get the tree file @file{foo.adt}. + compilation. + + @node Preparing Tree and Bind Files for gnatelim + @section Preparing Tree and Bind Files for @code{gnatelim} + + @noindent + A set of tree files covering the program to be analyzed with + @code{gnatelim} and + the bind file for the main subprogram does not have to + be in the current directory. + '-T' gnatelim option may be used to provide + the search path for tree files, and '-b' + option may be used to point to the bind + file to process (see @ref{Running gnatelim}) + + If you do not have the appropriate set of tree + files and the right bind file, you + may create them in the current directory using the following procedure. + + Let @code{Main_Prog} be the name of a main subprogram, and suppose + this subprogram is in a file named @file{main_prog.adb}. + + To create a bind file for @code{gnatelim}, run @code{gnatbind} for + the main subprogram. @code{gnatelim} can work with both Ada and C + bind files; when both are present, it uses the Ada bind file. + The following commands will build the program and create the bind file: + + @smallexample + $ gnatmake -c Main_Prog + $ gnatbind main_prog + @end smallexample + + @noindent + To create a minimal set of tree files covering the whole program, call + @code{gnatmake} for this program as follows: + + @smallexample + $ gnatmake -f -c -gnatc -gnatt Main_Prog + @end smallexample + + @noindent + The @code{-c} gnatmake option turns off the bind and link + steps, that are useless anyway because the sources are compiled with + @option{-gnatc} option which turns off code generation. + + The @code{-f} gnatmake option forces + recompilation of all the needed sources. + + This sequence of actions will create all the data needed by @code{gnatelim} + from scratch and therefore guarantee its consistency. If you would like to + use some existing set of files as @code{gnatelim} output, you must make + sure that the set of files is complete and consistent. You can use the + @code{-m} switch to check if there are missed tree files + + Note, that @code{gnatelim} needs neither object nor ALI files. + + @node Running gnatelim + @section Running @code{gnatelim} + + @noindent + @code{gnatelim} has the following command-line interface: + + @smallexample + $ gnatelim [options] name + @end smallexample + + @noindent + @code{name} should be a full expanded Ada name of a main subprogram + of a program (partition). + + @code{gnatelim} options: + + @table @code + @item -q + Quiet mode: by default @code{gnatelim} generates to the standard error + stream a trace of the source file names of the compilation units being + processed. This option turns this trace off. + + @item -v + Verbose mode: @code{gnatelim} version information is printed as Ada + comments to the standard output stream. + + @item -a + Also look for subprograms from the GNAT run time that can be eliminated. + + @item -m + Check if any tree files are missing for an accurate result. + + @item -T@var{dir} + When looking for tree files also look in directory @var{dir} + + @item -b@var{bind_file} + Specifies @var{bind_file} as the bind file to process. If not set, the name + of the bind file is computed from the full expanded Ada name of a main subprogram. + + @item -d@var{x} + Activate internal debugging switches. @var{x} is a letter or digit, or + string of letters or digits, which specifies the type of debugging + mode desired. Normally these are used only for internal development + or system debugging purposes. You can find full documentation for these + switches in the body of the @code{Gnatelim.Options} unit in the compiler + source file @file{gnatelim-options.adb}. + @end table + + @noindent + @code{gnatelim} sends its output to the standard output stream, and all the + tracing and debug information is sent to the standard error stream. + In order to produce a proper GNAT configuration file + @file{gnat.adc}, redirection must be used: + + @smallexample + $ gnatelim Main_Prog > gnat.adc + @end smallexample + + @noindent + or + + @smallexample + $ gnatelim Main_Prog >> gnat.adc + @end smallexample + + @noindent + In order to append the @code{gnatelim} output to the existing contents of + @file{gnat.adc}. + + @node Correcting the List of Eliminate Pragmas + @section Correcting the List of Eliminate Pragmas + + @noindent + In some rare cases it may happen that @code{gnatelim} will try to eliminate + subprograms which are actually called in the program. In this case, the + compiler will generate an error message of the form: + + @smallexample + file.adb:106:07: cannot call eliminated subprogram "My_Prog" + @end smallexample + + @noindent + You will need to manually remove the wrong @code{Eliminate} pragmas from + the @file{gnat.adc} file. It is advised that you recompile your program + from scratch after that because you need a consistent @file{gnat.adc} file + during the entire compilation. + + @node Making Your Executables Smaller + @section Making Your Executables Smaller + + @noindent + In order to get a smaller executable for your program you now have to + recompile the program completely with the new @file{gnat.adc} file + created by @code{gnatelim} in your current directory: + + @smallexample + $ gnatmake -f Main_Prog + @end smallexample + + @noindent + (you will need @code{-f} option for gnatmake to + recompile everything + with the set of pragmas @code{Eliminate} you have obtained with + @code{gnatelim}). + + Be aware that the set of @code{Eliminate} pragmas is specific to each + program. It is not recommended to merge sets of @code{Eliminate} + pragmas created for different programs in one @file{gnat.adc} file. + + @node Summary of the gnatelim Usage Cycle + @section Summary of the gnatelim Usage Cycle + + @noindent + Here is a quick summary of the steps to be taken in order to reduce + the size of your executables with @code{gnatelim}. You may use + other GNAT options to control the optimization level, + to produce the debugging information, to set search path, etc. + + @enumerate + @item + Produce a bind file and a set of tree files + + @smallexample + $ gnatmake -c Main_Prog + $ gnatbind main_prog + $ gnatmake -f -c -gnatc -gnatt Main_Prog + @end smallexample + + @item + Generate a list of @code{Eliminate} pragmas + @smallexample + $ gnatelim Main_Prog >[>] gnat.adc + @end smallexample + + @item + Recompile the application + + @smallexample + $ gnatmake -f Main_Prog + @end smallexample + + @end enumerate + + @node Other Utility Programs + @chapter Other Utility Programs + + @noindent + This chapter discusses some other utility programs available in the Ada + environment. + + @menu + * Using Other Utility Programs with GNAT:: + * The gnatpsta Utility Program:: + * The External Symbol Naming Scheme of GNAT:: + * Ada Mode for Glide:: + * Converting Ada Files to html with gnathtml:: + * Installing gnathtml:: + @end menu + + @node Using Other Utility Programs with GNAT + @section Using Other Utility Programs with GNAT + + @noindent + The object files generated by GNAT are in standard system format and in + particular the debugging information uses this format. This means + programs generated by GNAT can be used with existing utilities that + depend on these formats. + + In general, any utility program that works with C will also often work with + Ada programs generated by GNAT. This includes software utilities such as + gprof (a profiling program), @code{gdb} (the FSF debugger), and utilities such + as Purify. + + @node The gnatpsta Utility Program + @section The @code{gnatpsta} Utility Program + + @noindent + Many of the definitions in package Standard are implementation-dependent. + However, the source of this package does not exist as an Ada source + file, so these values cannot be determined by inspecting the source. + They can be determined by examining in detail the coding of + @file{cstand.adb} which creates the image of Standard in the compiler, + but this is awkward and requires a great deal of internal knowledge + about the system. + + The @code{gnatpsta} utility is designed to deal with this situation. + It is an Ada program that dynamically determines the + values of all the relevant parameters in Standard, and prints them + out in the form of an Ada source listing for Standard, displaying all + the values of interest. This output is generated to + @file{stdout}. + + To determine the value of any parameter in package Standard, simply + run @code{gnatpsta} with no qualifiers or arguments, and examine + the output. This is preferable to consulting documentation, because + you know that the values you are getting are the actual ones provided + by the executing system. + + @node The External Symbol Naming Scheme of GNAT + @section The External Symbol Naming Scheme of GNAT + + @noindent + In order to interpret the output from GNAT, when using tools that are + originally intended for use with other languages, it is useful to + understand the conventions used to generate link names from the Ada + entity names. + + All link names are in all lowercase letters. With the exception of library + procedure names, the mechanism used is simply to use the full expanded + Ada name with dots replaced by double underscores. For example, suppose + we have the following package spec: + + @smallexample + @group + @cartouche + @b{package} QRS @b{is} + MN : Integer; + @b{end} QRS; + @end cartouche + @end group + @end smallexample + + @noindent + The variable @code{MN} has a full expanded Ada name of @code{QRS.MN}, so + the corresponding link name is @code{qrs__mn}. + @findex Export + Of course if a @code{pragma Export} is used this may be overridden: + + @smallexample + @group + @cartouche + @b{package} Exports @b{is} + Var1 : Integer; + @b{pragma} Export (Var1, C, External_Name => "var1_name"); + Var2 : Integer; + @b{pragma} Export (Var2, C, Link_Name => "var2_link_name"); + @b{end} Exports; + @end cartouche + @end group + @end smallexample + + @noindent + In this case, the link name for @var{Var1} is whatever link name the + C compiler would assign for the C function @var{var1_name}. This typically + would be either @var{var1_name} or @var{_var1_name}, depending on operating + system conventions, but other possibilities exist. The link name for + @var{Var2} is @var{var2_link_name}, and this is not operating system + dependent. + + @findex _main + One exception occurs for library level procedures. A potential ambiguity + arises between the required name @code{_main} for the C main program, + and the name we would otherwise assign to an Ada library level procedure + called @code{Main} (which might well not be the main program). + + To avoid this ambiguity, we attach the prefix @code{_ada_} to such + names. So if we have a library level procedure such as + + @smallexample + @group + @cartouche + @b{procedure} Hello (S : String); + @end cartouche + @end group + @end smallexample + + @noindent + the external name of this procedure will be @var{_ada_hello}. + + @node Ada Mode for Glide + @section Ada Mode for @code{Glide} + + @noindent + The Glide mode for programming in Ada (both, Ada83 and Ada95) helps the + user in understanding existing code and facilitates writing new code. It + furthermore provides some utility functions for easier integration of + standard Emacs features when programming in Ada. + + @subsection General Features: + + @itemize @bullet + @item + Full Integrated Development Environment : + + @itemize @bullet + @item + support of 'project files' for the configuration (directories, + compilation options,...) + + @item + compiling and stepping through error messages. + + @item + running and debugging your applications within Glide. + @end itemize + + @item + easy to use for beginners by pull-down menus, + + @item + user configurable by many user-option variables. + @end itemize + + @subsection Ada Mode Features That Help Understanding Code: + + @itemize @bullet + @item + functions for easy and quick stepping through Ada code, + + @item + getting cross reference information for identifiers (e.g. find the + defining place by a keystroke), + + @item + displaying an index menu of types and subprograms and move point to + the chosen one, + + @item + automatic color highlighting of the various entities in Ada code. + @end itemize + + @subsection Glide Support for Writing Ada Code: + + @itemize @bullet + @item + switching between spec and body files with possible + autogeneration of body files, + + @item + automatic formating of subprograms parameter lists. + + @item + automatic smart indentation according to Ada syntax, + + @item + automatic completion of identifiers, + + @item + automatic casing of identifiers, keywords, and attributes, + + @item + insertion of statement templates, + + @item + filling comment paragraphs like filling normal text, + @end itemize + + For more information, please refer to the online Glide documentation + available in the Glide --> Help Menu. + + @node Converting Ada Files to html with gnathtml + @section Converting Ada Files to html with @code{gnathtml} + + @noindent + This @code{Perl} script allows Ada source files to be browsed using + standard Web browsers. For installation procedure, see the section + @xref{Installing gnathtml}. + + Ada reserved keywords are highlighted in a bold font and Ada comments in + a blue font. Unless your program was compiled with the gcc @option{-gnatx} + switch to suppress the generation of cross-referencing information, user + defined variables and types will appear in a different color; you will + be able to click on any identifier and go to its declaration. + + The command line is as follow: + @smallexample + $ perl gnathtml.pl [switches] ada-files + @end smallexample + + You can pass it as many Ada files as you want. @code{gnathtml} will generate + an html file for every ada file, and a global file called @file{index.htm}. + This file is an index of every identifier defined in the files. + + The available switches are the following ones : + + @table @code + @item -83 + @cindex @code{-83} (@code{gnathtml}) + Only the subset on the Ada 83 keywords will be highlighted, not the full + Ada 95 keywords set. + + @item -cc @var{color} + This option allows you to change the color used for comments. The default + value is green. The color argument can be any name accepted by html. + + @item -d + @cindex @code{-d} (@code{gnathtml}) + If the ada files depend on some other files (using for instance the + @code{with} command, the latter will also be converted to html. + Only the files in the user project will be converted to html, not the files + in the run-time library itself. + + @item -D + This command is the same as -d above, but @code{gnathtml} will also look + for files in the run-time library, and generate html files for them. + + @item -f + @cindex @code{-f} (@code{gnathtml}) + By default, gnathtml will generate html links only for global entities + ('with'ed units, global variables and types,...). If you specify the + @code{-f} on the command line, then links will be generated for local + entities too. + + @item -l @var{number} + @cindex @code{-l} (@code{gnathtml}) + If this switch is provided and @var{number} is not 0, then @code{gnathtml} + will number the html files every @var{number} line. + + @item -I @var{dir} + @cindex @code{-I} (@code{gnathtml}) + Specify a directory to search for library files (@file{.ali} files) and + source files. You can provide several -I switches on the command line, + and the directories will be parsed in the order of the command line. + + @item -o @var{dir} + @cindex @code{-o} (@code{gnathtml}) + Specify the output directory for html files. By default, gnathtml will + saved the generated html files in a subdirectory named @file{html/}. + + @item -p @var{file} + @cindex @code{-p} (@code{gnathtml}) + If you are using Emacs and the most recent Emacs Ada mode, which provides + a full Integrated Development Environment for compiling, checking, + running and debugging applications, you may be using @file{.adp} files + to give the directories where Emacs can find sources and object files. + + Using this switch, you can tell gnathtml to use these files. This allows + you to get an html version of your application, even if it is spread + over multiple directories. + + @item -sc @var{color} + @cindex @code{-sc} (@code{gnathtml}) + This option allows you to change the color used for symbol definitions. + The default value is red. The color argument can be any name accepted by html. + + @item -t @var{file} + @cindex @code{-t} (@code{gnathtml}) + This switch provides the name of a file. This file contains a list of + file names to be converted, and the effect is exactly as though they had + appeared explicitly on the command line. This + is the recommended way to work around the command line length limit on some + systems. + + @end table + + @node Installing gnathtml + @section Installing @code{gnathtml} + + @noindent + @code{Perl} needs to be installed on your machine to run this script. + @code{Perl} is freely available for almost every architecture and + Operating System via the Internet. + + On Unix systems, you may want to modify the first line of the script + @code{gnathtml}, to explicitly tell the Operating system where Perl + is. The syntax of this line is : + @smallexample + #!full_path_name_to_perl + @end smallexample + + @noindent + Alternatively, you may run the script using the following command line: + + @smallexample + $ perl gnathtml.pl [switches] files + @end smallexample + + + @node Running and Debugging Ada Programs + @chapter Running and Debugging Ada Programs + @cindex Debugging + + @noindent + This chapter discusses how to debug Ada programs. An incorrect Ada program + may be handled in three ways by the GNAT compiler: + + @enumerate + @item + The illegality may be a violation of the static semantics of Ada. In + that case GNAT diagnoses the constructs in the program that are illegal. + It is then a straightforward matter for the user to modify those parts of + the program. + + @item + The illegality may be a violation of the dynamic semantics of Ada. In + that case the program compiles and executes, but may generate incorrect + results, or may terminate abnormally with some exception. + + @item + When presented with a program that contains convoluted errors, GNAT + itself may terminate abnormally without providing full diagnostics on + the incorrect user program. + @end enumerate + + @menu + * The GNAT Debugger GDB:: + * Running GDB:: + * Introduction to GDB Commands:: + * Using Ada Expressions:: + * Calling User-Defined Subprograms:: + * Using the Next Command in a Function:: + * Ada Exceptions:: + * Ada Tasks:: + * Debugging Generic Units:: + * GNAT Abnormal Termination or Failure to Terminate:: + * Naming Conventions for GNAT Source Files:: + * Getting Internal Debugging Information:: + * Stack Traceback:: + @end menu + + @cindex Debugger + @findex gdb + + @node The GNAT Debugger GDB + @section The GNAT Debugger GDB + + @noindent + @code{GDB} is a general purpose, platform-independent debugger that + can be used to debug mixed-language programs compiled with @code{GCC}, + and in particular is capable of debugging Ada programs compiled with + GNAT. The latest versions of @code{GDB} are Ada-aware and can handle + complex Ada data structures. + + The manual @cite{Debugging with GDB} + contains full details on the usage of @code{GDB}, including a section on + its usage on programs. This manual should be consulted for full + details. The section that follows is a brief introduction to the + philosophy and use of @code{GDB}. + + When GNAT programs are compiled, the compiler optionally writes debugging + information into the generated object file, including information on + line numbers, and on declared types and variables. This information is + separate from the generated code. It makes the object files considerably + larger, but it does not add to the size of the actual executable that + will be loaded into memory, and has no impact on run-time performance. The + generation of debug information is triggered by the use of the + -g switch in the gcc or gnatmake command used to carry out + the compilations. It is important to emphasize that the use of these + options does not change the generated code. + + The debugging information is written in standard system formats that + are used by many tools, including debuggers and profilers. The format + of the information is typically designed to describe C types and + semantics, but GNAT implements a translation scheme which allows full + details about Ada types and variables to be encoded into these + standard C formats. Details of this encoding scheme may be found in + the file exp_dbug.ads in the GNAT source distribution. However, the + details of this encoding are, in general, of no interest to a user, + since @code{GDB} automatically performs the necessary decoding. + + When a program is bound and linked, the debugging information is + collected from the object files, and stored in the executable image of + the program. Again, this process significantly increases the size of + the generated executable file, but it does not increase the size of + the executable program itself. Furthermore, if this program is run in + the normal manner, it runs exactly as if the debug information were + not present, and takes no more actual memory. + + However, if the program is run under control of @code{GDB}, the + debugger is activated. The image of the program is loaded, at which + point it is ready to run. If a run command is given, then the program + will run exactly as it would have if @code{GDB} were not present. This + is a crucial part of the @code{GDB} design philosophy. @code{GDB} is + entirely non-intrusive until a breakpoint is encountered. If no + breakpoint is ever hit, the program will run exactly as it would if no + debugger were present. When a breakpoint is hit, @code{GDB} accesses + the debugging information and can respond to user commands to inspect + variables, and more generally to report on the state of execution. + + @node Running GDB + @section Running GDB + + @noindent + The debugger can be launched directly and simply from @code{glide} or + through its graphical interface: @code{gvd}. It can also be used + directly in text mode. Here is described the basic use of @code{GDB} + in text mode. All the commands described below can be used in the + @code{gvd} console window eventhough there is usually other more + graphical ways to achieve the same goals. + + @noindent + The command to run de graphical interface of the debugger is + @smallexample + $ gvd program + @end smallexample + + @noindent + The command to run @code{GDB} in text mode is + + @smallexample + $ gdb program + @end smallexample + + @noindent + where @code{program} is the name of the executable file. This + activates the debugger and results in a prompt for debugger commands. + The simplest command is simply @code{run}, which causes the program to run + exactly as if the debugger were not present. The following section + describes some of the additional commands that can be given to @code{GDB}. + + + @node Introduction to GDB Commands + @section Introduction to GDB Commands + + @noindent + @code{GDB} contains a large repertoire of commands. The manual + @cite{Debugging with GDB} + includes extensive documentation on the use + of these commands, together with examples of their use. Furthermore, + the command @var{help} invoked from within @code{GDB} activates a simple help + facility which summarizes the available commands and their options. + In this section we summarize a few of the most commonly + used commands to give an idea of what @code{GDB} is about. You should create + a simple program with debugging information and experiment with the use of + these @code{GDB} commands on the program as you read through the + following section. + + @table @code + @item set args @var{arguments} + The @var{arguments} list above is a list of arguments to be passed to + the program on a subsequent run command, just as though the arguments + had been entered on a normal invocation of the program. The @code{set args} + command is not needed if the program does not require arguments. + + @item run + The @code{run} command causes execution of the program to start from + the beginning. If the program is already running, that is to say if + you are currently positioned at a breakpoint, then a prompt will ask + for confirmation that you want to abandon the current execution and + restart. + + @item breakpoint @var{location} + The breakpoint command sets a breakpoint, that is to say a point at which + execution will halt and @code{GDB} will await further + commands. @var{location} is + either a line number within a file, given in the format @code{file:linenumber}, + or it is the name of a subprogram. If you request that a breakpoint be set on + a subprogram that is overloaded, a prompt will ask you to specify on which of + those subprograms you want to breakpoint. You can also + specify that all of them should be breakpointed. If the program is run + and execution encounters the breakpoint, then the program + stops and @code{GDB} signals that the breakpoint was encountered by + printing the line of code before which the program is halted. + + @item breakpoint exception @var{name} + A special form of the breakpoint command which breakpoints whenever + exception @var{name} is raised. + If @var{name} is omitted, + then a breakpoint will occur when any exception is raised. + + @item print @var{expression} + This will print the value of the given expression. Most simple + Ada expression formats are properly handled by @code{GDB}, so the expression + can contain function calls, variables, operators, and attribute references. + + @item continue + Continues execution following a breakpoint, until the next breakpoint or the + termination of the program. + + @item step + Executes a single line after a breakpoint. If the next statement is a subprogram + call, execution continues into (the first statement of) the + called subprogram. + + @item next + Executes a single line. If this line is a subprogram call, executes and + returns from the call. + + @item list + Lists a few lines around the current source location. In practice, it + is usually more convenient to have a separate edit window open with the + relevant source file displayed. Successive applications of this command + print subsequent lines. The command can be given an argument which is a + line number, in which case it displays a few lines around the specified one. + + @item backtrace + Displays a backtrace of the call chain. This command is typically + used after a breakpoint has occurred, to examine the sequence of calls that + leads to the current breakpoint. The display includes one line for each + activation record (frame) corresponding to an active subprogram. + + @item up + At a breakpoint, @code{GDB} can display the values of variables local + to the current frame. The command @code{up} can be used to + examine the contents of other active frames, by moving the focus up + the stack, that is to say from callee to caller, one frame at a time. + + @item down + Moves the focus of @code{GDB} down from the frame currently being + examined to the frame of its callee (the reverse of the previous command), + + @item frame @var{n} + Inspect the frame with the given number. The value 0 denotes the frame + of the current breakpoint, that is to say the top of the call stack. + + @end table + + The above list is a very short introduction to the commands that + @code{GDB} provides. Important additional capabilities, including conditional + breakpoints, the ability to execute command sequences on a breakpoint, + the ability to debug at the machine instruction level and many other + features are described in detail in @cite{Debugging with GDB}. + Note that most commands can be abbreviated + (for example, c for continue, bt for backtrace). + + @node Using Ada Expressions + @section Using Ada Expressions + @cindex Ada expressions + + @noindent + @code{GDB} supports a fairly large subset of Ada expression syntax, with some + extensions. The philosophy behind the design of this subset is + + @itemize @bullet + @item + That @code{GDB} should provide basic literals and access to operations for + arithmetic, dereferencing, field selection, indexing, and subprogram calls, + leaving more sophisticated computations to subprograms written into the + program (which therefore may be called from @code{GDB}). + + @item + That type safety and strict adherence to Ada language restrictions + are not particularly important to the @code{GDB} user. + + @item + That brevity is important to the @code{GDB} user. + @end itemize + + Thus, for brevity, the debugger acts as if there were + implicit @code{with} and @code{use} clauses in effect for all user-written + packages, thus making it unnecessary to fully qualify most names with + their packages, regardless of context. Where this causes ambiguity, + @code{GDB} asks the user's intent. + + For details on the supported Ada syntax, see @cite{Debugging with GDB}. + + @node Calling User-Defined Subprograms + @section Calling User-Defined Subprograms + + @noindent + An important capability of @code{GDB} is the ability to call user-defined + subprograms while debugging. This is achieved simply by entering + a subprogram call statement in the form: + + @smallexample + call subprogram-name (parameters) + @end smallexample + + @noindent + The keyword @code{call} can be omitted in the normal case where the + @code{subprogram-name} does not coincide with any of the predefined + @code{GDB} commands. + + The effect is to invoke the given subprogram, passing it the + list of parameters that is supplied. The parameters can be expressions and + can include variables from the program being debugged. The + subprogram must be defined + at the library level within your program, and @code{GDB} will call the + subprogram within the environment of your program execution (which + means that the subprogram is free to access or even modify variables + within your program). + + The most important use of this facility is in allowing the inclusion of + debugging routines that are tailored to particular data structures + in your program. Such debugging routines can be written to provide a suitably + high-level description of an abstract type, rather than a low-level dump + of its physical layout. After all, the standard + @code{GDB print} command only knows the physical layout of your + types, not their abstract meaning. Debugging routines can provide information + at the desired semantic level and are thus enormously useful. + + For example, when debugging GNAT itself, it is crucial to have access to + the contents of the tree nodes used to represent the program internally. + But tree nodes are represented simply by an integer value (which in turn + is an index into a table of nodes). + Using the @code{print} command on a tree node would simply print this integer + value, which is not very useful. But the PN routine (defined in file + treepr.adb in the GNAT sources) takes a tree node as input, and displays + a useful high level representation of the tree node, which includes the + syntactic category of the node, its position in the source, the integers + that denote descendant nodes and parent node, as well as varied + semantic information. To study this example in more detail, you might want to + look at the body of the PN procedure in the stated file. + + @node Using the Next Command in a Function + @section Using the Next Command in a Function + + @noindent + When you use the @code{next} command in a function, the current source + location will advance to the next statement as usual. A special case + arises in the case of a @code{return} statement. + + Part of the code for a return statement is the "epilog" of the function. + This is the code that returns to the caller. There is only one copy of + this epilog code, and it is typically associated with the last return + statement in the function if there is more than one return. In some + implementations, this epilog is associated with the first statement + of the function. + + The result is that if you use the @code{next} command from a return + statement that is not the last return statement of the function you + may see a strange apparent jump to the last return statement or to + the start of the function. You should simply ignore this odd jump. + The value returned is always that from the first return statement + that was stepped through. + + @node Ada Exceptions + @section Breaking on Ada Exceptions + @cindex Exceptions + + @noindent + You can set breakpoints that trip when your program raises + selected exceptions. + + @table @code + @item break exception + Set a breakpoint that trips whenever (any task in the) program raises + any exception. + + @item break exception @var{name} + Set a breakpoint that trips whenever (any task in the) program raises + the exception @var{name}. + + @item break exception unhandled + Set a breakpoint that trips whenever (any task in the) program raises an + exception for which there is no handler. + + @item info exceptions + @itemx info exceptions @var{regexp} + The @code{info exceptions} command permits the user to examine all defined + exceptions within Ada programs. With a regular expression, @var{regexp}, as + argument, prints out only those exceptions whose name matches @var{regexp}. + @end table + + @node Ada Tasks + @section Ada Tasks + @cindex Tasks + + @noindent + @code{GDB} allows the following task-related commands: + + @table @code + @item info tasks + This command shows a list of current Ada tasks, as in the following example: + + @smallexample + @iftex + @leftskip=0cm + @end iftex + (gdb) info tasks + ID TID P-ID Thread Pri State Name + 1 8088000 0 807e000 15 Child Activation Wait main_task + 2 80a4000 1 80ae000 15 Accept/Select Wait b + 3 809a800 1 80a4800 15 Child Activation Wait a + * 4 80ae800 3 80b8000 15 Running c + @end smallexample + + @noindent + In this listing, the asterisk before the first task indicates it to be the + currently running task. The first column lists the task ID that is used + to refer to tasks in the following commands. + + @item break @var{linespec} task @var{taskid} + @itemx break @var{linespec} task @var{taskid} if @dots{} + @cindex Breakpoints and tasks + These commands are like the @code{break @dots{} thread @dots{}}. + @var{linespec} specifies source lines. + + Use the qualifier @samp{task @var{taskid}} with a breakpoint command + to specify that you only want @code{GDB} to stop the program when a + particular Ada task reaches this breakpoint. @var{taskid} is one of the + numeric task identifiers assigned by @code{GDB}, shown in the first + column of the @samp{info tasks} display. + + If you do not specify @samp{task @var{taskid}} when you set a + breakpoint, the breakpoint applies to @emph{all} tasks of your + program. + + You can use the @code{task} qualifier on conditional breakpoints as + well; in this case, place @samp{task @var{taskid}} before the + breakpoint condition (before the @code{if}). + + @item task @var{taskno} + @cindex Task switching + + This command allows to switch to the task referred by @var{taskno}. In + particular, This allows to browse the backtrace of the specified + task. It is advised to switch back to the original task before + continuing execution otherwise the scheduling of the program may be + perturbated. + @end table + + @noindent + For more detailed information on the tasking support, see @cite{Debugging with GDB}. + + @node Debugging Generic Units + @section Debugging Generic Units + @cindex Debugging Generic Units + @cindex Generics + + @noindent + GNAT always uses code expansion for generic instantiation. This means that + each time an instantiation occurs, a complete copy of the original code is + made, with appropriate substitutions of formals by actuals. + + It is not possible to refer to the original generic entities in + @code{GDB}, but it is always possible to debug a particular instance of + a generic, by using the appropriate expanded names. For example, if we have + + @smallexample + @group + @cartouche + @b{procedure} g @b{is} + + @b{generic package} k @b{is} + @b{procedure} kp (v1 : @b{in out} integer); + @b{end} k; + + @b{package body} k @b{is} + @b{procedure} kp (v1 : @b{in out} integer) @b{is} + @b{begin} + v1 := v1 + 1; + @b{end} kp; + @b{end} k; + + @b{package} k1 @b{is new} k; + @b{package} k2 @b{is new} k; + + var : integer := 1; + + @b{begin} + k1.kp (var); + k2.kp (var); + k1.kp (var); + k2.kp (var); + @b{end}; + @end cartouche + @end group + @end smallexample + + @noindent + Then to break on a call to procedure kp in the k2 instance, simply + use the command: + + @smallexample + (gdb) break g.k2.kp + @end smallexample + + @noindent + When the breakpoint occurs, you can step through the code of the + instance in the normal manner and examine the values of local variables, as for + other units. + + @node GNAT Abnormal Termination or Failure to Terminate + @section GNAT Abnormal Termination or Failure to Terminate + @cindex GNAT Abnormal Termination or Failure to Terminate + + @noindent + When presented with programs that contain serious errors in syntax + or semantics, + GNAT may on rare occasions experience problems in operation, such + as aborting with a + segmentation fault or illegal memory access, raising an internal + exception, terminating abnormally, or failing to terminate at all. + In such cases, you can activate + various features of GNAT that can help you pinpoint the construct in your + program that is the likely source of the problem. + + The following strategies are presented in increasing order of + difficulty, corresponding to your experience in using GNAT and your + familiarity with compiler internals. + + @enumerate + @item + Run @code{gcc} with the @option{-gnatf}. This first + switch causes all errors on a given line to be reported. In its absence, + only the first error on a line is displayed. + + The @option{-gnatdO} switch causes errors to be displayed as soon as they + are encountered, rather than after compilation is terminated. If GNAT + terminates prematurely or goes into an infinite loop, the last error + message displayed may help to pinpoint the culprit. + + @item + Run @code{gcc} with the @code{-v (verbose)} switch. In this mode, + @code{gcc} produces ongoing information about the progress of the + compilation and provides the name of each procedure as code is + generated. This switch allows you to find which Ada procedure was being + compiled when it encountered a code generation problem. + + @item + @cindex @option{-gnatdc} switch + Run @code{gcc} with the @option{-gnatdc} switch. This is a GNAT specific + switch that does for the front-end what @code{-v} does for the back end. + The system prints the name of each unit, either a compilation unit or + nested unit, as it is being analyzed. + @item + Finally, you can start + @code{gdb} directly on the @code{gnat1} executable. @code{gnat1} is the + front-end of GNAT, and can be run independently (normally it is just + called from @code{gcc}). You can use @code{gdb} on @code{gnat1} as you + would on a C program (but @pxref{The GNAT Debugger GDB} for caveats). The + @code{where} command is the first line of attack; the variable + @code{lineno} (seen by @code{print lineno}), used by the second phase of + @code{gnat1} and by the @code{gcc} backend, indicates the source line at + which the execution stopped, and @code{input_file name} indicates the name of + the source file. + @end enumerate + + @node Naming Conventions for GNAT Source Files + @section Naming Conventions for GNAT Source Files + + @noindent + In order to examine the workings of the GNAT system, the following + brief description of its organization may be helpful: + + @itemize @bullet + @item + Files with prefix @file{sc} contain the lexical scanner. + + @item + All files prefixed with @file{par} are components of the parser. The + numbers correspond to chapters of the Ada 95 Reference Manual. For example, + parsing of select statements can be found in @file{par-ch9.adb}. + + @item + All files prefixed with @file{sem} perform semantic analysis. The + numbers correspond to chapters of the Ada standard. For example, all + issues involving context clauses can be found in @file{sem_ch10.adb}. In + addition, some features of the language require sufficient special processing + to justify their own semantic files: sem_aggr for aggregates, sem_disp for + dynamic dispatching, etc. + + @item + All files prefixed with @file{exp} perform normalization and + expansion of the intermediate representation (abstract syntax tree, or AST). + these files use the same numbering scheme as the parser and semantics files. + For example, the construction of record initialization procedures is done in + @file{exp_ch3.adb}. + + @item + The files prefixed with @file{bind} implement the binder, which + verifies the consistency of the compilation, determines an order of + elaboration, and generates the bind file. + + @item + The files @file{atree.ads} and @file{atree.adb} detail the low-level + data structures used by the front-end. + + @item + The files @file{sinfo.ads} and @file{sinfo.adb} detail the structure of + the abstract syntax tree as produced by the parser. + + @item + The files @file{einfo.ads} and @file{einfo.adb} detail the attributes of + all entities, computed during semantic analysis. + + @item + Library management issues are dealt with in files with prefix + @file{lib}. + + @item + @findex Ada + @cindex Annex A + Ada files with the prefix @file{a-} are children of @code{Ada}, as + defined in Annex A. + + @item + @findex Interfaces + @cindex Annex B + Files with prefix @file{i-} are children of @code{Interfaces}, as + defined in Annex B. + + @item + @findex System + Files with prefix @file{s-} are children of @code{System}. This includes + both language-defined children and GNAT run-time routines. + + @item + @findex GNAT + Files with prefix @file{g-} are children of @code{GNAT}. These are useful + general-purpose packages, fully documented in their specifications. All + the other @file{.c} files are modifications of common @code{gcc} files. + @end itemize + + @node Getting Internal Debugging Information + @section Getting Internal Debugging Information + + @noindent + Most compilers have internal debugging switches and modes. GNAT + does also, except GNAT internal debugging switches and modes are not + secret. A summary and full description of all the compiler and binder + debug flags are in the file @file{debug.adb}. You must obtain the + sources of the compiler to see the full detailed effects of these flags. + + The switches that print the source of the program (reconstructed from + the internal tree) are of general interest for user programs, as are the + options to print + the full internal tree, and the entity table (the symbol table + information). The reconstructed source provides a readable version of the + program after the front-end has completed analysis and expansion, and is useful + when studying the performance of specific constructs. For example, constraint + checks are indicated, complex aggregates are replaced with loops and + assignments, and tasking primitives are replaced with run-time calls. + + @node Stack Traceback + @section Stack Traceback + @cindex traceback + @cindex stack traceback + @cindex stack unwinding + + @noindent + Traceback is a mechanism to display the sequence of subprogram calls that + leads to a specified execution point in a program. Often (but not always) + the execution point is an instruction at which an exception has been raised. + This mechanism is also known as @i{stack unwinding} because it obtains + its information by scanning the run-time stack and recovering the activation + records of all active subprograms. Stack unwinding is one of the most + important tools for program debugging. + + @noindent + The first entry stored in traceback corresponds to the deepest calling level, + that is to say the subprogram currently executing the instruction + from which we want to obtain the traceback. + + @noindent + Note that there is no runtime performance penalty when stack traceback + is enabled and no exception are raised during program execution. + + @menu + * Non-Symbolic Traceback:: + * Symbolic Traceback:: + @end menu + + @node Non-Symbolic Traceback + @subsection Non-Symbolic Traceback + @cindex traceback, non-symbolic + + @noindent + Note: this feature is not supported on all platforms. See + @file{GNAT.Traceback spec in g-traceb.ads} for a complete list of supported + platforms. + + @menu + * Tracebacks From an Unhandled Exception:: + * Tracebacks From Exception Occurrences (non-symbolic):: + * Tracebacks From Anywhere in a Program (non-symbolic):: + @end menu + + @node Tracebacks From an Unhandled Exception + @subsubsection Tracebacks From an Unhandled Exception + + @noindent + A runtime non-symbolic traceback is a list of addresses of call instructions. + To enable this feature you must use the @code{-E} + @code{gnatbind}'s option. With this option a stack traceback is stored as part + of exception information. It is possible to retrieve this information using the + standard @code{Ada.Exception.Exception_Information} routine. + + @noindent + Let's have a look at a simple example: + + @smallexample + @cartouche + @group + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ gnatmake stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + @end smallexample + + @noindent + As we see the traceback lists a sequence of addresses for the unhandled + exception @code{CONSTAINT_ERROR} raised in procedure P1. It is easy to + guess that this exception come from procedure P1. To translate these + addresses into the source lines where the calls appear, the + @code{addr2line} tool, described below, is invaluable. The use of this tool + requires the program to be compiled with debug information. + + @smallexample + $ gnatmake -g stb -bargs -E + $ stb + + Execution terminated by unhandled exception + Exception name: CONSTRAINT_ERROR + Message: stb.adb:5 + Call stack traceback locations: + 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 0x4011f1 0x77e892a4 + + $ addr2line --exe=stb 0x401373 0x40138b 0x40139c 0x401335 0x4011c4 + 0x4011f1 0x77e892a4 + + 00401373 at d:/stb/stb.adb:5 + 0040138B at d:/stb/stb.adb:10 + 0040139C at d:/stb/stb.adb:14 + 00401335 at d:/stb/b~stb.adb:104 + 004011C4 at /build/.../crt1.c:200 + 004011F1 at /build/.../crt1.c:222 + 77E892A4 in ?? at ??:0 + @end smallexample + + @noindent + @code{addr2line} has a number of other useful options: + + @table @code + @item --functions + to get the function name corresponding to any location + + @item --demangle=gnat + to use the @b{gnat} decoding mode for the function names. Note that + for binutils version 2.9.x the option is simply @code{--demangle}. + @end table + + @smallexample + $ addr2line --exe=stb --functions --demangle=gnat 0x401373 0x40138b + 0x40139c 0x401335 0x4011c4 0x4011f1 + + 00401373 in stb.p1 at d:/stb/stb.adb:5 + 0040138B in stb.p2 at d:/stb/stb.adb:10 + 0040139C in stb at d:/stb/stb.adb:14 + 00401335 in main at d:/stb/b~stb.adb:104 + 004011C4 in <__mingw_CRTStartup> at /build/.../crt1.c:200 + 004011F1 in at /build/.../crt1.c:222 + @end smallexample + + @noindent + From this traceback we can see that the exception was raised in + @file{stb.adb} at line 5, which was reached from a procedure call in + @file{stb.adb} at line 10, and so on. The @file{b~std.adb} is the binder file, + which contains the call to the main program. + @pxref{Running gnatbind}. The remaining entries are assorted runtime routines, + and the output will vary from platform to platform. + + @noindent + It is also possible to use @code{GDB} with these traceback addresses to debug + the program. For example, we can break at a given code location, as reported + in the stack traceback: + + @smallexample + $ gdb -nw stb + @noindent + Furthermore, this feature is not implemented inside Windows DLL. Only + the non-symbolic traceback is reported in this case. + + (gdb) break *0x401373 + Breakpoint 1 at 0x401373: file stb.adb, line 5. + @end smallexample + + @noindent + It is important to note that the stack traceback addresses + do not change when debug information is included. This is particularly useful + because it makes it possible to release software without debug information (to + minimize object size), get a field report that includes a stack traceback + whenever an internal bug occurs, and then be able to retrieve the sequence + of calls with the same program compiled with debug information. + + @node Tracebacks From Exception Occurrences (non-symbolic) + @subsubsection Tracebacks From Exception Occurrences + + @noindent + Non-symbolic tracebacks are obtained by using the @code{-E} binder argument. + The stack traceback is attached to the exception information string, and can + be retrieved in an exception handler within the Ada program, by means of the + Ada95 facilities defined in @code{Ada.Exceptions}. Here is a simple example: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with Ada.Exceptions; + + procedure STB is + + use Ada; + use Ada.Exceptions; + + procedure P1 is + K : Positive := 1; + begin + K := K - 1; + exception + when E : others => + Text_IO.Put_Line (Exception_Information (E)); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @noindent + This program will output: + + @smallexample + $ stb + + Exception name: CONSTRAINT_ERROR + Message: stb.adb:12 + Call stack traceback locations: + 0x4015e4 0x401633 0x401644 0x401461 0x4011c4 0x4011f1 0x77e892a4 + @end smallexample + + @node Tracebacks From Anywhere in a Program (non-symbolic) + @subsubsection Tracebacks From Anywhere in a Program + + @noindent + It is also possible to retrieve a stack traceback from anywhere in a + program. For this you need to + use the @code{GNAT.Traceback} API. This package includes a procedure called + @code{Call_Chain} that computes a complete stack traceback, as well as useful + display procedures described below. It is not necessary to use the + @code{-E gnatbind} option in this case, because the stack traceback mechanism + is invoked explicitly. + + @noindent + In the following example we compute a traceback at a specific location in + the program, and we display it using @code{GNAT.Debug_Utilities.Image} to + convert addresses to strings: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Debug_Utilities; + + procedure STB is + + use Ada; + use GNAT; + use GNAT.Traceback; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + + Text_IO.Put ("In STB.P1 : "); + + for K in 1 .. Len loop + Text_IO.Put (Debug_Utilities.Image (TB (K))); + Text_IO.Put (' '); + end loop; + + Text_IO.New_Line; + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ gnatmake stb + $ stb + + In STB.P1 : 16#0040_F1E4# 16#0040_14F2# 16#0040_170B# 16#0040_171C# + 16#0040_1461# 16#0040_11C4# 16#0040_11F1# 16#77E8_92A4# + @end smallexample + + @node Symbolic Traceback + @subsection Symbolic Traceback + @cindex traceback, symbolic + + @noindent + A symbolic traceback is a stack traceback in which procedure names are + associated with each code location. + + @noindent + Note that this feature is not supported on all platforms. See + @file{GNAT.Traceback.Symbolic spec in g-trasym.ads} for a complete + list of currently supported platforms. + + @noindent + Note that the symbolic traceback requires that the program be compiled + with debug information. If it is not compiled with debug information + only the non-symbolic information will be valid. + + @menu + * Tracebacks From Exception Occurrences (symbolic):: + * Tracebacks From Anywhere in a Program (symbolic):: + @end menu + + @node Tracebacks From Exception Occurrences (symbolic) + @subsubsection Tracebacks From Exception Occurrences + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback.Symbolic; + + procedure STB is + + procedure P1 is + begin + raise Constraint_Error; + end P1; + + procedure P2 is + begin + P1; + end P2; + + procedure P3 is + begin + P2; + end P3; + + begin + P3; + exception + when E : others => + Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); + end STB; + @end group + @end cartouche + @end smallexample + + @smallexample + $ gnatmake -g stb -bargs -E -largs -lgnat -laddr2line -lintl + $ stb + + 0040149F in stb.p1 at stb.adb:8 + 004014B7 in stb.p2 at stb.adb:13 + 004014CF in stb.p3 at stb.adb:18 + 004015DD in ada.stb at stb.adb:22 + 00401461 in main at b~stb.adb:168 + 004011C4 in __mingw_CRTStartup at crt1.c:200 + 004011F1 in mainCRTStartup at crt1.c:222 + 77E892A4 in ?? at ??:0 + @end smallexample + + @noindent + The exact sequence of linker options may vary from platform to platform. + The above @code{-largs} section is for Windows platforms. By contrast, + under Unix there is no need for the @code{-largs} section. + Differences across platforms are due to details of linker implementation. + + @node Tracebacks From Anywhere in a Program (symbolic) + @subsubsection Tracebacks From Anywhere in a Program + + @noindent + It is possible to get a symbolic stack traceback + from anywhere in a program, just as for non-symbolic tracebacks. + The first step is to obtain a non-symbolic + traceback, and then call @code{Symbolic_Traceback} to compute the symbolic + information. Here is an example: + + @smallexample + @cartouche + @group + with Ada.Text_IO; + with GNAT.Traceback; + with GNAT.Traceback.Symbolic; + + procedure STB is + + use Ada; + use GNAT.Traceback; + use GNAT.Traceback.Symbolic; + + procedure P1 is + TB : Tracebacks_Array (1 .. 10); + -- We are asking for a maximum of 10 stack frames. + Len : Natural; + -- Len will receive the actual number of stack frames returned. + begin + Call_Chain (TB, Len); + Text_IO.Put_Line (Symbolic_Traceback (TB (1 .. Len))); + end P1; + + procedure P2 is + begin + P1; + end P2; + + begin + P2; + end STB; + @end group + @end cartouche + @end smallexample + + + @node Inline Assembler + @chapter Inline Assembler + + @noindent + If you need to write low-level software that interacts directly with the hardware, Ada provides two ways to incorporate assembly language code into your program. First, you can import and invoke external routines written in assembly language, an Ada feature fully supported by GNAT. However, for small sections of code it may be simpler or more efficient to include assembly language statements directly in your Ada source program, using the facilities of the implementation-defined package @code{System.Machine_Code}, which incorporates the gcc Inline Assembler. The Inline Assembler approach offers a number of advantages, including the following: + + @itemize @bullet + @item No need to use non-Ada tools + @item Consistent interface over different targets + @item Automatic usage of the proper calling conventions + @item Access to Ada constants and variables + @item Definition of intrinsic routines + @item Possibility of inlining a subprogram comprising assembler code + @item Code optimizer can take Inline Assembler code into account + @end itemize + + This chapter presents a series of examples to show you how to use the Inline Assembler. Although it focuses on the Intel x86, the general approach applies also to other processors. It is assumed that you are familiar with Ada and with assembly language programming. + + @menu + * Basic Assembler Syntax:: + * A Simple Example of Inline Assembler:: + * Output Variables in Inline Assembler:: + * Input Variables in Inline Assembler:: + * Inlining Inline Assembler Code:: + * Other Asm Functionality:: + * A Complete Example:: + @end menu + + @c --------------------------------------------------------------------------- + @node Basic Assembler Syntax + @section Basic Assembler Syntax + + @noindent + The assembler used by GNAT and gcc is based not on the Intel assembly language, but rather on a + language that descends from the AT&T Unix assembler @emph{as} (and which is often + referred to as ``AT&T syntax''). + The following table summarizes the main features of @emph{as} syntax and points out the differences from the Intel conventions. + See the gcc @emph{as} and @emph{gas} (an @emph{as} macro + pre-processor) documentation for further information. + + @table @asis + @item Register names + gcc / @emph{as}: Prefix with ``%''; for example @code{%eax} + @* + Intel: No extra punctuation; for example @code{eax} + + @item Immediate operand + gcc / @emph{as}: Prefix with ``$''; for example @code{$4} + @* + Intel: No extra punctuation; for example @code{4} + + @item Address + gcc / @emph{as}: Prefix with ``$''; for example @code{$loc} + @* + Intel: No extra punctuation; for example @code{loc} + + @item Memory contents + gcc / @emph{as}: No extra punctuation; for example @code{loc} + @* + Intel: Square brackets; for example @code{[loc]} + + @item Register contents + gcc / @emph{as}: Parentheses; for example @code{(%eax)} + @* + Intel: Square brackets; for example @code{[eax]} + + @item Hexadecimal numbers + gcc / @emph{as}: Leading ``0x'' (C language syntax); for example @code{0xA0} + @* + Intel: Trailing ``h''; for example @code{A0h} + + @item Operand size + gcc / @emph{as}: Explicit in op code; for example @code{movw} to move a 16-bit word + @* + Intel: Implicit, deduced by assembler; for example @code{mov} + + @item Instruction repetition + gcc / @emph{as}: Split into two lines; for example + @* + @code{rep} + @* + @code{stosl} + @* + Intel: Keep on one line; for example @code{rep stosl} + + @item Order of operands + gcc / @emph{as}: Source first; for example @code{movw $4, %eax} + @* + Intel: Destination first; for example @code{mov eax, 4} + @end table + + @c --------------------------------------------------------------------------- + @node A Simple Example of Inline Assembler + @section A Simple Example of Inline Assembler + + @noindent + The following example will generate a single assembly language statement, @code{nop}, which does nothing. Despite its lack of run-time effect, the example will be useful in illustrating the basics of the Inline Assembler facility. + + @smallexample + @group + with System.Machine_Code; use System.Machine_Code; + procedure Nothing is + begin + Asm ("nop"); + end Nothing; + @end group + @end smallexample + + @code{Asm} is a procedure declared in package @code{System.Machine_Code}; here it takes one parameter, a @emph{template string} that must be a static expression and that will form the generated instruction. + @code{Asm} may be regarded as a compile-time procedure that parses the template string and additional parameters (none here), from which it generates a sequence of assembly language instructions. + + The examples in this chapter will illustrate several of the forms for invoking @code{Asm}; a complete specification of the syntax is found in the @cite{GNAT Reference Manual}. + + Under the standard GNAT conventions, the @code{Nothing} procedure should be in a file named @file{nothing.adb}. You can build the executable in the usual way: + @smallexample + gnatmake nothing + @end smallexample + However, the interesting aspect of this example is not its run-time behavior but rather the + generated assembly code. To see this output, invoke the compiler as follows: + @smallexample + gcc -c -S -fomit-frame-pointer -gnatp @file{nothing.adb} + @end smallexample + where the options are: + + @table @code + @item -c + compile only (no bind or link) + @item -S + generate assembler listing + @item -fomit-frame-pointer + do not set up separate stack frames + @item -gnatp + do not add runtime checks + @end table + + This gives a human-readable assembler version of the code. The resulting + file will have the same name as the Ada source file, but with a @code{.s} extension. + In our example, the file @file{nothing.s} has the following contents: + + @smallexample + @group + .file "nothing.adb" + gcc2_compiled.: + ___gnu_compiled_ada: + .text + .align 4 + .globl __ada_nothing + __ada_nothing: + #APP + nop + #NO_APP + jmp L1 + .align 2,0x90 + L1: + ret + @end group + @end smallexample + + The assembly code you included is clearly indicated by + the compiler, between the @code{#APP} and @code{#NO_APP} + delimiters. The character before the 'APP' and 'NOAPP' + can differ on different targets. For example, Linux uses '#APP' while + on NT you will see '/APP'. + + If you make a mistake in your assembler code (such as using the + wrong size modifier, or using a wrong operand for the instruction) GNAT + will report this error in a temporary file, which will be deleted when + the compilation is finished. Generating an assembler file will help + in such cases, since you can assemble this file separately using the + @emph{as} assembler that comes with gcc. + + Assembling the file using the command + + @smallexample + as @file{nothing.s} + @end smallexample + @noindent + will give you error messages whose lines correspond to the assembler + input file, so you can easily find and correct any mistakes you made. + If there are no errors, @emph{as} will generate an object file @file{nothing.out}. + + @c --------------------------------------------------------------------------- + @node Output Variables in Inline Assembler + @section Output Variables in Inline Assembler + + @noindent + The examples in this section, showing how to access the processor flags, illustrate how to specify the destination operands for assembly language statements. + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags; + @end group + @end smallexample + + In order to have a nicely aligned assembly listing, we have separated + multiple assembler statements in the Asm template string with linefeed (ASCII.LF) + and horizontal tab (ASCII.HT) characters. The resulting section of the + assembly output file is: + + @smallexample + @group + #APP + pushfl + popl %eax + movl %eax, -40(%ebp) + #NO_APP + @end group + @end smallexample + + It would have been legal to write the Asm invocation as: + + @smallexample + Asm ("pushfl popl %%eax movl %%eax, %0") + @end smallexample + + but in the generated assembler file, this would come out as: + + @smallexample + #APP + pushfl popl %eax movl %eax, -40(%ebp) + #NO_APP + @end smallexample + + which is not so convenient for the human reader. + + We use Ada comments + at the end of each line to explain what the assembler instructions + actually do. This is a useful convention. + + When writing Inline Assembler instructions, you need to precede each register and variable name with a percent sign. Since the assembler already requires a percent sign at the beginning of a register name, you need two consecutive percent signs for such names in the Asm template string, thus @code{%%eax}. In the generated assembly code, one of the percent signs will be stripped off. + + Names such as @code{%0}, @code{%1}, @code{%2}, etc., denote input or output variables: operands you later define using @code{Input} or @code{Output} parameters to @code{Asm}. + An output variable is illustrated in + the third statement in the Asm template string: + @smallexample + movl %%eax, %0 + @end smallexample + The intent is to store the contents of the eax register in a variable that can be accessed in Ada. Simply writing @code{movl %%eax, Flags} would not necessarily work, since the compiler might optimize by using a register to hold Flags, and the expansion of the @code{movl} instruction would not be aware of this optimization. The solution is not to store the result directly but rather to advise the compiler to choose the correct operand form; that is the purpose of the @code{%0} output variable. + + Information about the output variable is supplied in the @code{Outputs} parameter to @code{Asm}: + @smallexample + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + @end smallexample + + The output is defined by the @code{Asm_Output} attribute of the target type; the general format is + @smallexample + Type'Asm_Output (constraint_string, variable_name) + @end smallexample + + The constraint string directs the compiler how + to store/access the associated variable. In the example + @smallexample + Unsigned_32'Asm_Output ("=m", Flags); + @end smallexample + the @code{"m"} (memory) constraint tells the compiler that the variable + @code{Flags} should be stored in a memory variable, thus preventing + the optimizer from keeping it in a register. In contrast, + @smallexample + Unsigned_32'Asm_Output ("=r", Flags); + @end smallexample + uses the @code{"r"} (register) constraint, telling the compiler to + store the variable in a register. + + If the constraint is preceded by the equal character (@strong{=}), it tells the + compiler that the variable will be used to store data into it. + + In the @code{Get_Flags} example, we used the "g" (global) constraint, allowing the optimizer + to choose whatever it deems best. + + There are a fairly large number of constraints, but the ones that are most useful (for the Intel x86 processor) are the following: + + @table @code + @item = + output constraint + @item g + global (i.e. can be stored anywhere) + @item m + in memory + @item I + a constant + @item a + use eax + @item b + use ebx + @item c + use ecx + @item d + use edx + @item S + use esi + @item D + use edi + @item r + use one of eax, ebx, ecx or edx + @item q + use one of eax, ebx, ecx, edx, esi or edi + @end table + + The full set of constraints is described in the gcc and @emph{as} documentation; note that it is possible to combine certain constraints in one constraint string. + + You specify the association of an output variable with an assembler operand through the @code{%}@emph{n} notation, where @emph{n} is a non-negative integer. Thus in + @smallexample + @group + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax" & LF & HT & -- load eax with flags + "movl %%eax, %0", -- store flags in variable + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + @end group + @end smallexample + @noindent + @code{%0} will be replaced in the expanded code by the appropriate operand, + whatever + the compiler decided for the @code{Flags} variable. + + In general, you may have any number of output variables: + @itemize @bullet + @item + Count the operands starting at 0; thus @code{%0}, @code{%1}, etc. + @item + Specify the @code{Outputs} parameter as a parenthesized comma-separated list of @code{Asm_Output} attributes + @end itemize + + For example: + @smallexample + @group + Asm ("movl %%eax, %0" & LF & HT & + "movl %%ebx, %1" & LF & HT & + "movl %%ecx, %2", + Outputs => (Unsigned_32'Asm_Output ("=g", Var_A), -- %0 = Var_A + Unsigned_32'Asm_Output ("=g", Var_B), -- %1 = Var_B + Unsigned_32'Asm_Output ("=g", Var_C))); -- %2 = Var_C + @end group + @end smallexample + @noindent + where @code{Var_A}, @code{Var_B}, and @code{Var_C} are variables in the Ada program. + + As a variation on the @code{Get_Flags} example, we can use the constraints string to direct the compiler to store the eax register into the @code{Flags} variable, instead of including the store instruction explicitly in the @code{Asm} template string: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_2 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "popl %%eax", -- save flags in eax + Outputs => Unsigned_32'Asm_Output ("=a", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_2; + @end group + @end smallexample + + @noindent + The @code{"a"} constraint tells the compiler that the @code{Flags} + variable will come from the eax register. Here is the resulting code: + + @smallexample + @group + #APP + pushfl + popl %eax + #NO_APP + movl %eax,-40(%ebp) + @end group + @end smallexample + + @noindent + The compiler generated the store of eax into Flags after + expanding the assembler code. + + Actually, there was no need to pop the flags into the eax register; more simply, we could just pop the flags directly into the program variable: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Get_Flags_3 is + Flags : Unsigned_32; + use ASCII; + begin + Asm ("pushfl" & LF & HT & -- push flags on stack + "pop %0", -- save flags in Flags + Outputs => Unsigned_32'Asm_Output ("=g", Flags)); + Put_Line ("Flags register:" & Flags'Img); + end Get_Flags_3; + @end group + @end smallexample + + @c --------------------------------------------------------------------------- + @node Input Variables in Inline Assembler + @section Input Variables in Inline Assembler + + @noindent + The example in this section illustrates how to specify the source operands for assembly language statements. The program simply increments its input value by 1: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Incr (Value); + Put_Line ("Value after is" & Value'Img); + end Increment; + @end group + @end smallexample + + The @code{Outputs} parameter to @code{Asm} specifies + that the result will be in the eax register and that it is to be stored in the @code{Result} + variable. + + The @code{Inputs} parameter looks much like the @code{Outputs} parameter, but with an + @code{Asm_Input} attribute. The + @code{"="} constraint, indicating an output value, is not present. + + You can have multiple input variables, in the same way that you can have more + than one output variable. + + The parameter count (%0, %1) etc, now starts at the first input + statement, and continues with the output statements. + When both parameters use the same variable, the + compiler will treat them as the same %n operand, which is the case here. + + Just as the @code{Outputs} parameter causes the register to be stored into the + target variable after execution of the assembler statements, so does the + @code{Inputs} parameter cause its variable to be loaded into the register before execution + of the + assembler statements. + + Thus the effect of the @code{Asm} invocation is: + @enumerate + @item load the 32-bit value of @code{Value} into eax + @item execute the @code{incl %eax} instruction + @item store the contents of eax into the @code{Result} variable + @end enumerate + + The resulting assembler file (with @code{-O2} optimization) contains: + @smallexample + @group + _increment__incr.1: + subl $4,%esp + movl 8(%esp),%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + movl %ecx,(%esp) + addl $4,%esp + ret + @end group + @end smallexample + + @c --------------------------------------------------------------------------- + @node Inlining Inline Assembler Code + @section Inlining Inline Assembler Code + + @noindent + For a short subprogram such as the @code{Incr} function in the previous section, the overhead of the call and return (creating / deleting the stack frame) + can be significant, compared to the amount of code in the subprogram body. + A solution is to apply Ada's @code{Inline} pragma to the subprogram, + which directs the compiler to expand invocations of the subprogram at the point(s) + of call, instead of setting up a stack frame for out-of-line calls. + Here is the resulting program: + + @smallexample + @group + with Interfaces; use Interfaces; + with Ada.Text_IO; use Ada.Text_IO; + with System.Machine_Code; use System.Machine_Code; + procedure Increment_2 is + + function Incr (Value : Unsigned_32) return Unsigned_32 is + Result : Unsigned_32; + begin + Asm ("incl %0", + Inputs => Unsigned_32'Asm_Input ("a", Value), + Outputs => Unsigned_32'Asm_Output ("=a", Result)); + return Result; + end Incr; + pragma Inline (Increment); + + Value : Unsigned_32; + + begin + Value := 5; + Put_Line ("Value before is" & Value'Img); + Value := Increment (Value); + Put_Line ("Value after is" & Value'Img); + end Increment_2; + @end group + @end smallexample + + Compile the program with both optimization (@code{-O2}) and inlining + enabled (@option{-gnatpn} instead of @option{-gnatp}). + + The @code{Incr} function is still compiled as usual, but at the + point in @code{Increment} where our function used to be called: + + @smallexample + @group + pushl %edi + call _increment__incr.1 + @end group + @end smallexample + + @noindent + the code for the function body directly appears: + + @smallexample + @group + movl %esi,%eax + #APP + incl %eax + #NO_APP + movl %eax,%edx + @end group + @end smallexample + + @noindent + thus saving the overhead of stack frame setup and an out-of-line call. + + @c --------------------------------------------------------------------------- + @node Other Asm Functionality + @section Other @code{Asm} Functionality + + @noindent + This section describes two important parameters to the @code{Asm} procedure: @code{Clobber}, which identifies register usage; and @code{Volatile}, which inhibits unwanted optimizations. + + @menu + * The Clobber Parameter:: + * The Volatile Parameter:: + @end menu + + @c --------------------------------------------------------------------------- + @node The Clobber Parameter + @subsection The @code{Clobber} Parameter + + @noindent + One of the dangers of intermixing assembly language and a compiled language such as Ada is + that the compiler needs to be aware of which registers are being used by the assembly code. + In some cases, such as the earlier examples, the constraint string is sufficient to + indicate register usage (e.g. "a" for the eax register). But more generally, the + compiler needs an explicit identification of the registers that are used by the Inline + Assembly statements. + + Using a register that the compiler doesn't know about + could be a side effect of an instruction (like @code{mull} + storing its result in both eax and edx). + It can also arise from explicit register usage in your + assembly code; for example: + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out)); + @end group + @end smallexample + @noindent + where the compiler (since it does not analyze the @code{Asm} template string) + does not know you are using the ebx register. + + In such cases you need to supply the @code{Clobber} parameter to @code{Asm}, + to identify the registers that will be used by your assembly code: + + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx"); + @end group + @end smallexample + + The Clobber parameter is a static string expression specifying the + register(s) you are using. Note that register names are @emph{not} prefixed by a percent sign. + Also, if more than one register is used then their names are separated by commas; e.g., @code{"eax, ebx"} + + The @code{Clobber} parameter has several additional uses: + @enumerate + @item Use the "register" name @code{cc} to indicate that flags might have changed + @item Use the "register" name @code{memory} if you changed a memory location + @end enumerate + + @c --------------------------------------------------------------------------- + @node The Volatile Parameter + @subsection The @code{Volatile} Parameter + @cindex Volatile parameter + + @noindent + Compiler optimizations in the presence of Inline Assembler may sometimes have unwanted effects. + For example, when + an @code{Asm} invocation with an input variable is inside a loop, the compiler might move + the loading of the input variable outside the loop, regarding it as a + one-time initialization. + + If this effect is not desired, you can disable such optimizations by setting the + @code{Volatile} parameter to @code{True}; for example: + + @smallexample + @group + Asm ("movl %0, %%ebx" & LF & HT & + "movl %%ebx, %1", + Inputs => Unsigned_32'Asm_Input ("g", Var_In), + Outputs => Unsigned_32'Asm_Output ("=g", Var_Out), + Clobber => "ebx", + Volatile => True); + @end group + @end smallexample + + By default, @code{Volatile} is set to @code{False} unless there is no @code{Outputs} + parameter. + + Although setting @code{Volatile} to @code{True} prevents unwanted optimizations, + it will also disable other optimizations that might be important for efficiency. + In general, you should set @code{Volatile} to @code{True} only if the compiler's + optimizations have created problems. + + @c --------------------------------------------------------------------------- + @node A Complete Example + @section A Complete Example + + @noindent + This section contains a complete program illustrating a realistic usage of GNAT's Inline Assembler + capabilities. It comprises a main procedure @code{Check_CPU} and a package @code{Intel_CPU}. + The package declares a collection of functions that detect the properties of the 32-bit + x86 processor that is running the program. The main procedure invokes these functions + and displays the information. + + The Intel_CPU package could be enhanced by adding functions to + detect the type of x386 co-processor, the processor caching options and + special operations such as the SIMD extensions. + + Although the Intel_CPU package has been written for 32-bit Intel + compatible CPUs, it is OS neutral. It has been tested on DOS, + Windows/NT and Linux. + + @menu + * Check_CPU Procedure:: + * Intel_CPU Package Specification:: + * Intel_CPU Package Body:: + @end menu + + @c --------------------------------------------------------------------------- + @node Check_CPU Procedure + @subsection @code{Check_CPU} Procedure + @cindex Check_CPU procedure + + @smallexample + --------------------------------------------------------------------- + -- -- + -- Uses the Intel_CPU package to identify the CPU the program is -- + -- running on, and some of the features it supports. -- + -- -- + --------------------------------------------------------------------- + + with Intel_CPU; -- Intel CPU detection functions + with Ada.Text_IO; -- Standard text I/O + with Ada.Command_Line; -- To set the exit status + + procedure Check_CPU is + + Type_Found : Boolean := False; + -- Flag to indicate that processor was identified + + Features : Intel_CPU.Processor_Features; + -- The processor features + + Signature : Intel_CPU.Processor_Signature; + -- The processor type signature + + begin + + ----------------------------------- + -- Display the program banner. -- + ----------------------------------- + + Ada.Text_IO.Put_Line (Ada.Command_Line.Command_Name & + ": check Intel CPU version and features, v1.0"); + Ada.Text_IO.Put_Line ("distribute freely, but no warranty whatsoever"); + Ada.Text_IO.New_Line; + + ----------------------------------------------------------------------- + -- We can safely start with the assumption that we are on at least -- + -- a x386 processor. If the CPUID instruction is present, then we -- + -- have a later processor type. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Has_CPUID = False then + + -- No CPUID instruction, so we assume this is indeed a x386 + -- processor. We can still check if it has a FP co-processor. + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line + ("x386-type processor with a FP co-processor"); + else + Ada.Text_IO.Put_Line + ("x386-type processor without a FP co-processor"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check for CPUID + + ----------------------------------------------------------------------- + -- If CPUID is supported, check if this is a true Intel processor, -- + -- if it is not, display a warning. -- + ----------------------------------------------------------------------- + + if Intel_CPU.Vendor_ID /= Intel_CPU.Intel_Processor then + Ada.Text_IO.Put_Line ("*** This is a Intel compatible processor"); + Ada.Text_IO.Put_Line ("*** Some information may be incorrect"); + end if; -- check if Intel + + ---------------------------------------------------------------------- + -- With the CPUID instruction present, we can assume at least a -- + -- x486 processor. If the CPUID support level is < 1 then we have -- + -- to leave it at that. -- + ---------------------------------------------------------------------- + + if Intel_CPU.CPUID_Level < 1 then + + -- Ok, this is a x486 processor. we still can get the Vendor ID + Ada.Text_IO.Put_Line ("x486-type processor"); + Ada.Text_IO.Put_Line ("Vendor ID is " & Intel_CPU.Vendor_ID); + + -- We can also check if there is a FPU present + if Intel_CPU.Has_FPU then + Ada.Text_IO.Put_Line ("Floating-Point support"); + else + Ada.Text_IO.Put_Line ("No Floating-Point support"); + end if; -- check for FPU + + -- Program done + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + return; + + end if; -- check CPUID level + + --------------------------------------------------------------------- + -- With a CPUID level of 1 we can use the processor signature to -- + -- determine it's exact type. -- + --------------------------------------------------------------------- + + Signature := Intel_CPU.Signature; + + ---------------------------------------------------------------------- + -- Ok, now we go into a lot of messy comparisons to get the -- + -- processor type. For clarity, no attememt to try to optimize the -- + -- comparisons has been made. Note that since Intel_CPU does not -- + -- support getting cache info, we cannot distinguish between P5 -- + -- and Celeron types yet. -- + ---------------------------------------------------------------------- + + -- x486SL + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486SL processor"); + end if; + + -- x486DX2 Write-Back + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#0111# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Write-Back Enhanced x486DX2 processor"); + end if; + + -- x486DX4 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 processor"); + end if; + + -- x486DX4 Overdrive + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0100# and + Signature.Model = 2#1000# then + Type_Found := True; + Ada.Text_IO.Put_Line ("x486DX4 OverDrive processor"); + end if; + + -- Pentium (60, 66) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium processor (60, 66)"); + end if; + + -- Pentium (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive (60, 66) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium OverDrive processor (60, 66)"); + end if; + + -- Pentium OverDrive (75, 90, 100, 120, 133, 150, 166, 200) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0010# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive cpu (75, 90, 100, 120, 133, 150, 166, 200)"); + end if; + + -- Pentium OverDrive processor for x486 processor-based systems + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor for x486 processor-based systems"); + end if; + + -- Pentium processor with MMX technology (166, 200) + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium processor with MMX technology (166, 200)"); + end if; + + -- Pentium OverDrive with MMX for Pentium (75, 90, 100, 120, 133) + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0101# and + Signature.Model = 2#0100# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium OverDrive processor with MMX " & + "technology for Pentium processor (75, 90, 100, 120, 133)"); + end if; + + -- Pentium Pro processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0001# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro processor"); + end if; + + -- Pentium II processor, model 3 + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium II processor, model 3"); + end if; + + -- Pentium II processor, model 5 or Celeron processor + if Signature.Processor_Type = 2#00# and + Signature.Family = 2#0110# and + Signature.Model = 2#0101# then + Type_Found := True; + Ada.Text_IO.Put_Line + ("Pentium II processor, model 5 or Celeron processor"); + end if; + + -- Pentium Pro OverDrive processor + if Signature.Processor_Type = 2#01# and + Signature.Family = 2#0110# and + Signature.Model = 2#0011# then + Type_Found := True; + Ada.Text_IO.Put_Line ("Pentium Pro OverDrive processor"); + end if; + + -- If no type recognized, we have an unknown. Display what + -- we _do_ know + if Type_Found = False then + Ada.Text_IO.Put_Line ("Unknown processor"); + end if; + + ----------------------------------------- + -- Display processor stepping level. -- + ----------------------------------------- + + Ada.Text_IO.Put_Line ("Stepping level:" & Signature.Stepping'Img); + + --------------------------------- + -- Display vendor ID string. -- + --------------------------------- + + Ada.Text_IO.Put_Line ("Vendor ID: " & Intel_CPU.Vendor_ID); + + ------------------------------------ + -- Get the processors features. -- + ------------------------------------ + + Features := Intel_CPU.Features; + + ----------------------------- + -- Check for a FPU unit. -- + ----------------------------- + + if Features.FPU = True then + Ada.Text_IO.Put_Line ("Floating-Point unit available"); + else + Ada.Text_IO.Put_Line ("no Floating-Point unit"); + end if; -- check for FPU + + -------------------------------- + -- List processor features. -- + -------------------------------- + + Ada.Text_IO.Put_Line ("Supported features: "); + + -- Virtual Mode Extension + if Features.VME = True then + Ada.Text_IO.Put_Line (" VME - Virtual Mode Extension"); + end if; + + -- Debugging Extension + if Features.DE = True then + Ada.Text_IO.Put_Line (" DE - Debugging Extension"); + end if; + + -- Page Size Extension + if Features.PSE = True then + Ada.Text_IO.Put_Line (" PSE - Page Size Extension"); + end if; + + -- Time Stamp Counter + if Features.TSC = True then + Ada.Text_IO.Put_Line (" TSC - Time Stamp Counter"); + end if; + + -- Model Specific Registers + if Features.MSR = True then + Ada.Text_IO.Put_Line (" MSR - Model Specific Registers"); + end if; + + -- Physical Address Extension + if Features.PAE = True then + Ada.Text_IO.Put_Line (" PAE - Physical Address Extension"); + end if; + + -- Machine Check Extension + if Features.MCE = True then + Ada.Text_IO.Put_Line (" MCE - Machine Check Extension"); + end if; + + -- CMPXCHG8 instruction supported + if Features.CX8 = True then + Ada.Text_IO.Put_Line (" CX8 - CMPXCHG8 instruction"); + end if; + + -- on-chip APIC hardware support + if Features.APIC = True then + Ada.Text_IO.Put_Line (" APIC - on-chip APIC hardware support"); + end if; + + -- Fast System Call + if Features.SEP = True then + Ada.Text_IO.Put_Line (" SEP - Fast System Call"); + end if; + + -- Memory Type Range Registers + if Features.MTRR = True then + Ada.Text_IO.Put_Line (" MTTR - Memory Type Range Registers"); + end if; + + -- Page Global Enable + if Features.PGE = True then + Ada.Text_IO.Put_Line (" PGE - Page Global Enable"); + end if; + + -- Machine Check Architecture + if Features.MCA = True then + Ada.Text_IO.Put_Line (" MCA - Machine Check Architecture"); + end if; + + -- Conditional Move Instruction Supported + if Features.CMOV = True then + Ada.Text_IO.Put_Line + (" CMOV - Conditional Move Instruction Supported"); + end if; + + -- Page Attribute Table + if Features.PAT = True then + Ada.Text_IO.Put_Line (" PAT - Page Attribute Table"); + end if; + + -- 36-bit Page Size Extension + if Features.PSE_36 = True then + Ada.Text_IO.Put_Line (" PSE_36 - 36-bit Page Size Extension"); + end if; + + -- MMX technology supported + if Features.MMX = True then + Ada.Text_IO.Put_Line (" MMX - MMX technology supported"); + end if; + + -- Fast FP Save and Restore + if Features.FXSR = True then + Ada.Text_IO.Put_Line (" FXSR - Fast FP Save and Restore"); + end if; + + --------------------- + -- Program done. -- + --------------------- + + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Success); + + exception + + when others => + Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); + raise; + + end Check_CPU; + @end smallexample + + @c --------------------------------------------------------------------------- + @node Intel_CPU Package Specification + @subsection @code{Intel_CPU} Package Specification + @cindex Intel_CPU package specification + + @smallexample + ------------------------------------------------------------------------- + -- -- + -- file: intel_cpu.ads -- + -- -- + -- ********************************************* -- + -- * WARNING: for 32-bit Intel processors only * -- + -- ********************************************* -- + -- -- + -- This package contains a number of subprograms that are useful in -- + -- determining the Intel x86 CPU (and the features it supports) on -- + -- which the program is running. -- + -- -- + -- The package is based upon the information given in the Intel -- + -- Application Note AP-485: "Intel Processor Identification and the -- + -- CPUID Instruction" as of April 1998. This application note can be -- + -- found on www.intel.com. -- + -- -- + -- It currently deals with 32-bit processors only, will not detect -- + -- features added after april 1998, and does not guarantee proper -- + -- results on Intel-compatible processors. -- + -- -- + -- Cache info and x386 fpu type detection are not supported. -- + -- -- + -- This package does not use any privileged instructions, so should -- + -- work on any OS running on a 32-bit Intel processor. -- + -- -- + ------------------------------------------------------------------------- + + with Interfaces; use Interfaces; + -- for using unsigned types + + with System.Machine_Code; use System.Machine_Code; + -- for using inline assembler code + + with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; + -- for inserting control characters + + package Intel_CPU is + + ---------------------- + -- Processor bits -- + ---------------------- + + subtype Num_Bits is Natural range 0 .. 31; + -- the number of processor bits (32) + + -------------------------- + -- Processor register -- + -------------------------- + + -- define a processor register type for easy access to + -- the individual bits + + type Processor_Register is array (Num_Bits) of Boolean; + pragma Pack (Processor_Register); + for Processor_Register'Size use 32; + + ------------------------- + -- Unsigned register -- + ------------------------- + + -- define a processor register type for easy access to + -- the individual bytes + + type Unsigned_Register is + record + L1 : Unsigned_8; + H1 : Unsigned_8; + L2 : Unsigned_8; + H2 : Unsigned_8; + end record; + + for Unsigned_Register use + record + L1 at 0 range 0 .. 7; + H1 at 0 range 8 .. 15; + L2 at 0 range 16 .. 23; + H2 at 0 range 24 .. 31; + end record; + + for Unsigned_Register'Size use 32; + + --------------------------------- + -- Intel processor vendor ID -- + --------------------------------- + + Intel_Processor : constant String (1 .. 12) := "GenuineIntel"; + -- indicates an Intel manufactured processor + + ------------------------------------ + -- Processor signature register -- + ------------------------------------ + + -- a register type to hold the processor signature + + type Processor_Signature is + record + Stepping : Natural range 0 .. 15; + Model : Natural range 0 .. 15; + Family : Natural range 0 .. 15; + Processor_Type : Natural range 0 .. 3; + Reserved : Natural range 0 .. 262143; + end record; + + for Processor_Signature use + record + Stepping at 0 range 0 .. 3; + Model at 0 range 4 .. 7; + Family at 0 range 8 .. 11; + Processor_Type at 0 range 12 .. 13; + Reserved at 0 range 14 .. 31; + end record; + + for Processor_Signature'Size use 32; + + ----------------------------------- + -- Processor features register -- + ----------------------------------- + + -- a processor register to hold the processor feature flags + + type Processor_Features is + record + FPU : Boolean; -- floating point unit on chip + VME : Boolean; -- virtual mode extension + DE : Boolean; -- debugging extension + PSE : Boolean; -- page size extension + TSC : Boolean; -- time stamp counter + MSR : Boolean; -- model specific registers + PAE : Boolean; -- physical address extension + MCE : Boolean; -- machine check extension + CX8 : Boolean; -- cmpxchg8 instruction + APIC : Boolean; -- on-chip apic hardware + Res_1 : Boolean; -- reserved for extensions + SEP : Boolean; -- fast system call + MTRR : Boolean; -- memory type range registers + PGE : Boolean; -- page global enable + MCA : Boolean; -- machine check architecture + CMOV : Boolean; -- conditional move supported + PAT : Boolean; -- page attribute table + PSE_36 : Boolean; -- 36-bit page size extension + Res_2 : Natural range 0 .. 31; -- reserved for extensions + MMX : Boolean; -- MMX technology supported + FXSR : Boolean; -- fast FP save and restore + Res_3 : Natural range 0 .. 127; -- reserved for extensions + end record; + + for Processor_Features use + record + FPU at 0 range 0 .. 0; + VME at 0 range 1 .. 1; + DE at 0 range 2 .. 2; + PSE at 0 range 3 .. 3; + TSC at 0 range 4 .. 4; + MSR at 0 range 5 .. 5; + PAE at 0 range 6 .. 6; + MCE at 0 range 7 .. 7; + CX8 at 0 range 8 .. 8; + APIC at 0 range 9 .. 9; + Res_1 at 0 range 10 .. 10; + SEP at 0 range 11 .. 11; + MTRR at 0 range 12 .. 12; + PGE at 0 range 13 .. 13; + MCA at 0 range 14 .. 14; + CMOV at 0 range 15 .. 15; + PAT at 0 range 16 .. 16; + PSE_36 at 0 range 17 .. 17; + Res_2 at 0 range 18 .. 22; + MMX at 0 range 23 .. 23; + FXSR at 0 range 24 .. 24; + Res_3 at 0 range 25 .. 31; + end record; + + for Processor_Features'Size use 32; + + ------------------- + -- Subprograms -- + ------------------- + + function Has_FPU return Boolean; + -- return True if a FPU is found + -- use only if CPUID is not supported + + function Has_CPUID return Boolean; + -- return True if the processor supports the CPUID instruction + + function CPUID_Level return Natural; + -- return the CPUID support level (0, 1 or 2) + -- can only be called if the CPUID instruction is supported + + function Vendor_ID return String; + -- return the processor vendor identification string + -- can only be called if the CPUID instruction is supported + + function Signature return Processor_Signature; + -- return the processor signature + -- can only be called if the CPUID instruction is supported + + function Features return Processor_Features; + -- return the processors features + -- can only be called if the CPUID instruction is supported + + private + + ------------------------ + -- EFLAGS bit names -- + ------------------------ + + ID_Flag : constant Num_Bits := 21; + -- ID flag bit + + end Intel_CPU; + @end smallexample + + @c --------------------------------------------------------------------------- + @node Intel_CPU Package Body + @subsection @code{Intel_CPU} Package Body + @cindex Intel_CPU package body + + @smallexample + package body Intel_CPU is + + --------------------------- + -- Detect FPU presence -- + --------------------------- + + -- There is a FPU present if we can set values to the FPU Status + -- and Control Words. + + function Has_FPU return Boolean is + + Register : Unsigned_16; + -- processor register to store a word + + begin + + -- check if we can change the status word + Asm ( + + -- the assembler code + "finit" & LF & HT & -- reset status word + "movw $0x5A5A, %%ax" & LF & HT & -- set value status word + "fnstsw %0" & LF & HT & -- save status word + "movw %%ax, %0", -- store status word + + -- output stored in Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register), + + -- tell compiler that we used eax + Clobber => "eax"); + + -- if the status word is zero, there is no FPU + if Register = 0 then + return False; -- no status word + end if; -- check status word value + + -- check if we can get the control word + Asm ( + + -- the assembler code + "fnstcw %0", -- save the control word + + -- output into Register + -- register must be a memory location + Outputs => Unsigned_16'Asm_output ("=m", Register)); + + -- check the relevant bits + if (Register and 16#103F#) /= 16#003F# then + return False; -- no control word + end if; -- check control word value + + -- FPU found + return True; + + end Has_FPU; + + -------------------------------- + -- Detect CPUID instruction -- + -------------------------------- + + -- The processor supports the CPUID instruction if it is possible + -- to change the value of ID flag bit in the EFLAGS register. + + function Has_CPUID return Boolean is + + Original_Flags, Modified_Flags : Processor_Register; + -- EFLAG contents before and after changing the ID flag + + begin + + -- try flipping the ID flag in the EFLAGS register + Asm ( + + -- the assembler code + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %%eax" & LF & HT & -- pop EFLAGS into eax + "movl %%eax, %0" & LF & HT & -- save EFLAGS content + "xor $0x200000, %%eax" & LF & HT & -- flip ID flag + "push %%eax" & LF & HT & -- push EFLAGS on stack + "popfl" & LF & HT & -- load EFLAGS register + "pushfl" & LF & HT & -- push EFLAGS on stack + "pop %1", -- save EFLAGS content + + -- output values, may be anything + -- Original_Flags is %0 + -- Modified_Flags is %1 + Outputs => + (Processor_Register'Asm_output ("=g", Original_Flags), + Processor_Register'Asm_output ("=g", Modified_Flags)), + + -- tell compiler eax is destroyed + Clobber => "eax"); + + -- check if CPUID is supported + if Original_Flags(ID_Flag) /= Modified_Flags(ID_Flag) then + return True; -- ID flag was modified + else + return False; -- ID flag unchanged + end if; -- check for CPUID + + end Has_CPUID; + + ------------------------------- + -- Get CPUID support level -- + ------------------------------- + + function CPUID_Level return Natural is + + Level : Unsigned_32; + -- returned support level + + begin + + -- execute CPUID, storing the results in the Level register + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero is stored in eax + -- returning the support level in eax + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- eax is stored in Level + Outputs => Unsigned_32'Asm_output ("=a", Level), + + -- tell compiler ebx, ecx and edx registers are destroyed + Clobber => "ebx, ecx, edx"); + + -- return the support level + return Natural (Level); + + end CPUID_Level; + + -------------------------------- + -- Get CPU Vendor ID String -- + -------------------------------- + + -- The vendor ID string is returned in the ebx, ecx and edx register + -- after executing the CPUID instruction with eax set to zero. + -- In case of a true Intel processor the string returned is + -- "GenuineIntel" + + function Vendor_ID return String is + + Ebx, Ecx, Edx : Unsigned_Register; + -- registers containing the vendor ID string + + Vendor_ID : String (1 .. 12); + -- the vendor ID string + + begin + + -- execute CPUID, storing the results in the processor registers + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- zero stored in eax + -- vendor ID string returned in ebx, ecx and edx + Inputs => Unsigned_32'Asm_input ("a", 0), + + -- ebx is stored in Ebx + -- ecx is stored in Ecx + -- edx is stored in Edx + Outputs => (Unsigned_Register'Asm_output ("=b", Ebx), + Unsigned_Register'Asm_output ("=c", Ecx), + Unsigned_Register'Asm_output ("=d", Edx))); + + -- now build the vendor ID string + Vendor_ID( 1) := Character'Val (Ebx.L1); + Vendor_ID( 2) := Character'Val (Ebx.H1); + Vendor_ID( 3) := Character'Val (Ebx.L2); + Vendor_ID( 4) := Character'Val (Ebx.H2); + Vendor_ID( 5) := Character'Val (Edx.L1); + Vendor_ID( 6) := Character'Val (Edx.H1); + Vendor_ID( 7) := Character'Val (Edx.L2); + Vendor_ID( 8) := Character'Val (Edx.H2); + Vendor_ID( 9) := Character'Val (Ecx.L1); + Vendor_ID(10) := Character'Val (Ecx.H1); + Vendor_ID(11) := Character'Val (Ecx.L2); + Vendor_ID(12) := Character'Val (Ecx.H2); + + -- return string + return Vendor_ID; + + end Vendor_ID; + + ------------------------------- + -- Get processor signature -- + ------------------------------- + + function Signature return Processor_Signature is + + Result : Processor_Signature; + -- processor signature returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one is stored in eax + -- processor signature returned in eax + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- eax is stored in Result + Outputs => Processor_Signature'Asm_output ("=a", Result), + + -- tell compiler that ebx, ecx and edx are also destroyed + Clobber => "ebx, ecx, edx"); + + -- return processor signature + return Result; + + end Signature; + + ------------------------------ + -- Get processor features -- + ------------------------------ + + function Features return Processor_Features is + + Result : Processor_Features; + -- processor features returned + + begin + + -- execute CPUID, storing the results in the Result variable + Asm ( + + -- the assembler code + "cpuid", -- execute CPUID + + -- one stored in eax + -- processor features returned in edx + Inputs => Unsigned_32'Asm_input ("a", 1), + + -- edx is stored in Result + Outputs => Processor_Features'Asm_output ("=d", Result), + + -- tell compiler that ebx and ecx are also destroyed + Clobber => "ebx, ecx"); + + -- return processor signature + return Result; + + end Features; + + end Intel_CPU; + @end smallexample + @c END OF INLINE ASSEMBLER CHAPTER + @c =============================== + + @node Microsoft Windows Topics + @chapter Microsoft Windows Topics + @cindex Windows NT + @cindex Windows 95 + @cindex Windows 98 + + @noindent + This chapter describes topics that are specific to the Microsoft Windows + platforms (NT, 95 and 98). + + @menu + * Using GNAT on Windows:: + * GNAT Setup Tool:: + * CONSOLE and WINDOWS subsystems:: + * Temporary Files:: + * Mixed-Language Programming on Windows:: + * Windows Calling Conventions:: + * Introduction to Dynamic Link Libraries (DLLs):: + * Using DLLs with GNAT:: + * Building DLLs with GNAT:: + * GNAT and Windows Resources:: + * Debugging a DLL:: + * GNAT and COM/DCOM Objects:: + @end menu + + @node Using GNAT on Windows + @section Using GNAT on Windows + + @noindent + One of the strengths of the GNAT technology is that its tool set + (@code{gcc}, @code{gnatbind}, @code{gnatlink}, @code{gnatmake}, the + @code{gdb} debugger, etc.) is used in the same way regardless of the + platform. + + On Windows this tool set is complemented by a number of Microsoft-specific + tools that have been provided to facilitate interoperability with Windows + when this is required. With these tools: + + @itemize @bullet + + @item + You can build applications using the @code{CONSOLE} or @code{WINDOWS} + subsystems. + + @item + You can use any Dynamically Linked Library (DLL) in your Ada code (both + relocatable and non-relocatable DLLs are supported). + + @item + You can build Ada DLLs for use in other applications. These applications + can be written in a language other than Ada (e.g., C, C++, etc). Again both + relocatable and non-relocatable Ada DLLs are supported. + + @item + You can include Windows resources in your Ada application. + + @item + You can use or create COM/DCOM objects. + @end itemize + + @noindent + Immediately below are listed all known general GNAT-for-Windows restrictions. + Other restrictions about specific features like Windows Resources and DLLs + are listed in separate sections below. + + @itemize @bullet + + @item + It is not possible to use @code{GetLastError} and @code{SetLastError} + when tasking, protected records, or exceptions are used. In these + cases, in order to implement Ada semantics, the GNAT run-time system + calls certain Win32 routines that set the last error variable to 0 upon + success. It should be possible to use @code{GetLastError} and + @code{SetLastError} when tasking, protected record, and exception + features are not used, but it is not guaranteed to work. + @end itemize + + @node GNAT Setup Tool + @section GNAT Setup Tool + @cindex GNAT Setup Tool + @cindex Setup Tool + @cindex gnatreg + + @menu + * Command-line arguments:: + * Creating a network installation of GNAT:: + * Registering and unregistering additional libraries:: + @end menu + + @noindent + GNAT installation on Windows is using the Windows registry in order to + locate proper executables and standard libraries. GNAT setup tool, called + @code{gnatreg.exe}, is provided in order to display and modify GNAT-specific + registry entries, allowing to create network GNAT installations, modify the + locations of GNAT components, as well as register and unregister additional + libraries for use with GNAT. + + @node Command-line arguments + @subsection Command-line arguments + + @noindent + @code{gnatreg [switches] [parameter]} + + @noindent + Specifying no arguments causes gnatreg to display current configuration. + + @noindent + The switches understood by gnatreg are: + @table @asis + @item -h + print the help message + @item -a + add a standard library + @item -r + remove a standard library + @item -f + force creation of keys if they don't exist + @item -q + be quiet/terse + @end table + + @node Creating a network installation of GNAT + @subsection Creating a network installation of GNAT + + @noindent + Make sure the system on which GNAT is installed is accessible from the + current machine. + + Use the command + + @code{@ @ @ gnatreg -f \\server\sharename\path} + + in order to setup the registry entries on a current machine. + + For example, if GNAT is installed in @file{\GNAT} directory of a share location + called @file{c-drive} on a machine @file{LOKI}, the command that can be used on + other machines to allow the remote use of GNAT is, + + @code{@ @ @ gnatreg -f \\loki\c-drive\gnat} + + Remember to also add @file{\\loki\c-drive\gnat\bin} in front of your PATH variable. + + Be aware that every compilation using the network installation results in the + transfer of large amounts of data across the network and may cause serious + performance penalty. + + @node Registering and unregistering additional libraries + @subsection Registering and unregistering additional libraries + + @noindent + To register a standard library use a command: + + @code{@ @ @ gnatreg -a =} + + For example: + + @code{@ @ @ gnatreg -a WIN32ADA=c:\Win32Ada} + + The libraries registered in this manner will be treated like standard libraries + by the compiler (i.e. they don't have to be specified in -I and -l switches to + various GNAT tools). + + To unregister a library, enter + @code{ gnatreg -r } + + e.g., + @code{ gnatreg -r WIN32ADA} + + @node CONSOLE and WINDOWS subsystems + @section CONSOLE and WINDOWS subsystems + @cindex CONSOLE Subsystem + @cindex WINDOWS Subsystem + @cindex -mwindows + + @noindent + Under Windows there is two main subsystems. The @code{CONSOLE} subsystem + (which is the default subsystem) will always create a console when + launching the application. This is not something desirable when the + application has a Windows GUI. To get rid of this console the + application must be using the @code{WINDOWS} subsystem. To do so + the @code{-mwindows} linker option must be specified. + + @smallexample + $ gnatmake winprog -largs -mwindows + @end smallexample + + @node Temporary Files + @section Temporary Files + @cindex Temporary files + + @noindent + It is possible to control where temporary files gets created by setting + the TMP environment variable. The file will be created: + + @itemize + @item Under the directory pointed to by the TMP environment variable if + this directory exists. + + @item Under c:\temp, if the TMP environment variable is not set (or not + pointing to a directory) and if this directory exists. + + @item Under the current working directory otherwise. + @end itemize + + @noindent + This allows you to determine exactly where the temporary + file will be created. This is particularly useful in networked + environments where you may not have write access to some + directories. + + @node Mixed-Language Programming on Windows + @section Mixed-Language Programming on Windows + + @noindent + Developing pure Ada applications on Windows is no different than on + other GNAT-supported platforms. However, when developing or porting an + application that contains a mix of Ada and C/C++, the choice of your + Windows C/C++ development environment conditions your overall + interoperability strategy. + + If you use @code{gcc} to compile the non-Ada part of your application, + there are no Windows-specific restrictions that affect the overall + interoperability with your Ada code. If you plan to use + Microsoft tools (e.g. Microsoft Visual C/C++), you should be aware of + the following limitations: + + @itemize @bullet + @item + You cannot link your Ada code with an object or library generated with + Microsoft tools if these use the @code{.tls} section (Thread Local + Storage section) since the GNAT linker does not yet support this section. + + @item + You cannot link your Ada code with an object or library generated with + Microsoft tools if these use I/O routines other than those provided in + the Microsoft DLL: @code{msvcrt.dll}. This is because the GNAT run time + uses the services of @code{msvcrt.dll} for its I/Os. Use of other I/O + libraries can cause a conflict with @code{msvcrt.dll} services. For + instance Visual C++ I/O stream routines conflict with those in + @code{msvcrt.dll}. + @end itemize + + @noindent + If you do want to use the Microsoft tools for your non-Ada code and hit one + of the above limitations, you have two choices: + + @enumerate + @item + Encapsulate your non Ada code in a DLL to be linked with your Ada + application. In this case, use the Microsoft or whatever environment to + build the DLL and use GNAT to build your executable + (@pxref{Using DLLs with GNAT}). + + @item + Or you can encapsulate your Ada code in a DLL to be linked with the + other part of your application. In this case, use GNAT to build the DLL + (@pxref{Building DLLs with GNAT}) and use the Microsoft or whatever + environment to build your executable. + @end enumerate + + @node Windows Calling Conventions + @section Windows Calling Conventions + @findex Stdcall + @findex APIENTRY + + @menu + * C Calling Convention:: + * Stdcall Calling Convention:: + * DLL Calling Convention:: + @end menu + + @noindent + When a subprogram @code{F} (caller) calls a subprogram @code{G} + (callee), there are several ways to push @code{G}'s parameters on the + stack and there are several possible scenarios to clean up the stack + upon @code{G}'s return. A calling convention is an agreed upon software + protocol whereby the responsibilities between the caller (@code{F}) and + the callee (@code{G}) are clearly defined. Several calling conventions + are available for Windows: + + @itemize @bullet + @item + @code{C} (Microsoft defined) + + @item + @code{Stdcall} (Microsoft defined) + + @item + @code{DLL} (GNAT specific) + @end itemize + + @node C Calling Convention + @subsection @code{C} Calling Convention + + @noindent + This is the default calling convention used when interfacing to C/C++ + routines compiled with either @code{gcc} or Microsoft Visual C++. + + In the @code{C} calling convention subprogram parameters are pushed on the + stack by the caller from right to left. The caller itself is in charge of + cleaning up the stack after the call. In addition, the name of a routine + with @code{C} calling convention is mangled by adding a leading underscore. + + The name to use on the Ada side when importing (or exporting) a routine + with @code{C} calling convention is the name of the routine. For + instance the C function: + + @smallexample + int get_val (long); + @end smallexample + + @noindent + should be imported from Ada as follows: + + @smallexample + @group + @b{function} Get_Val (V : Interfaces.C.long) @b{return} Interfaces.C.int; + @b{pragma} Import (C, Get_Val, External_Name => "get_val"); + @end group + @end smallexample + + @noindent + Note that in this particular case the @code{External_Name} parameter could + have been omitted since, when missing, this parameter is taken to be the + name of the Ada entity in lower case. When the @code{Link_Name} parameter + is missing, as in the above example, this parameter is set to be the + @code{External_Name} with a leading underscore. + + When importing a variable defined in C, you should always use the @code{C} + calling convention unless the object containing the variable is part of a + DLL (in which case you should use the @code{DLL} calling convention, + @pxref{DLL Calling Convention}). + + @node Stdcall Calling Convention + @subsection @code{Stdcall} Calling Convention + + @noindent + This convention, which was the calling convention used for Pascal + programs, is used by Microsoft for all the routines in the Win32 API for + efficiency reasons. It must be used to import any routine for which this + convention was specified. + + In the @code{Stdcall} calling convention subprogram parameters are pushed + on the stack by the caller from right to left. The callee (and not the + caller) is in charge of cleaning the stack on routine exit. In addition, + the name of a routine with @code{Stdcall} calling convention is mangled by + adding a leading underscore (as for the @code{C} calling convention) and a + trailing @code{@@}@code{@i{nn}}, where @i{nn} is the overall size (in + bytes) of the parameters passed to the routine. + + The name to use on the Ada side when importing a C routine with a + @code{Stdcall} calling convention is the name of the C routine. The leading + underscore and trailing @code{@@}@code{@i{nn}} are added automatically by + the compiler. For instance the Win32 function: + + @smallexample + @b{APIENTRY} int get_val (long); + @end smallexample + + @noindent + should be imported from Ada as follows: + + @smallexample + @group + @b{function} Get_Val (V : Interfaces.C.long) @b{return} Interfaces.C.int; + @b{pragma} Import (Stdcall, Get_Val); + -- @i{On the x86 a long is 4 bytes, so the Link_Name is }"_get_val@@4" + @end group + @end smallexample + + @noindent + As for the @code{C} calling convention, when the @code{External_Name} + parameter is missing, it is taken to be the name of the Ada entity in lower + case. If instead of writing the above import pragma you write: + + @smallexample + @group + @b{function} Get_Val (V : Interfaces.C.long) @b{return} Interfaces.C.int; + @b{pragma} Import (Stdcall, Get_Val, External_Name => "retrieve_val"); + @end group + @end smallexample + + @noindent + then the imported routine is @code{_retrieve_val@@4}. However, if instead + of specifying the @code{External_Name} parameter you specify the + @code{Link_Name} as in the following example: + + @smallexample + @group + @b{function} Get_Val (V : Interfaces.C.long) @b{return} Interfaces.C.int; + @b{pragma} Import (Stdcall, Get_Val, Link_Name => "retrieve_val"); + @end group + @end smallexample + + @noindent + then the imported routine is @code{retrieve_val@@4}, that is, there is no + trailing underscore but the appropriate @code{@@}@code{@i{nn}} is always + added at the end of the @code{Link_Name} by the compiler. + + @noindent + Note, that in some special cases a DLL's entry point name lacks a trailing + @code{@@}@code{@i{nn}} while the exported name generated for a call has it. + The @code{gnatdll} tool, which creates the import library for the DLL, is able + to handle those cases (see the description of the switches in + @pxref{Using gnatdll} section). + + @node DLL Calling Convention + @subsection @code{DLL} Calling Convention + + @noindent + This convention, which is GNAT-specific, must be used when you want to + import in Ada a variables defined in a DLL. For functions and procedures + this convention is equivalent to the @code{Stdcall} convention. As an + example, if a DLL contains a variable defined as: + + @smallexample + int my_var; + @end smallexample + + @noindent + then, to access this variable from Ada you should write: + + @smallexample + @group + My_Var : Interfaces.C.int; + @b{pragma} Import (DLL, My_Var); + @end group + @end smallexample + + The remarks concerning the @code{External_Name} and @code{Link_Name} + parameters given in the previous sections equally apply to the @code{DLL} + calling convention. + + @node Introduction to Dynamic Link Libraries (DLLs) + @section Introduction to Dynamic Link Libraries (DLLs) + @findex DLL + + @noindent + A Dynamically Linked Library (DLL) is a library that can be shared by + several applications running under Windows. A DLL can contain any number of + routines and variables. + + One advantage of DLLs is that you can change and enhance them without + forcing all the applications that depend on them to be relinked or + recompiled. However, you should be aware than all calls to DLL routines are + slower since, as you will understand below, such calls are indirect. + + To illustrate the remainder of this section, suppose that an application + wants to use the services of a DLL @file{API.dll}. To use the services + provided by @file{API.dll} you must statically link against an import + library which contains a jump table with an entry for each routine and + variable exported by the DLL. In the Microsoft world this import library is + called @file{API.lib}. When using GNAT this import library is called either + @file{libAPI.a} or @file{libapi.a} (names are case insensitive). + + After you have statically linked your application with the import library + and you run your application, here is what happens: + + @enumerate + @item + Your application is loaded into memory. + + @item + The DLL @file{API.dll} is mapped into the address space of your + application. This means that: + + @itemize @bullet + @item + The DLL will use the stack of the calling thread. + + @item + The DLL will use the virtual address space of the calling process. + + @item + The DLL will allocate memory from the virtual address space of the calling + process. + + @item + Handles (pointers) can be safely exchanged between routines in the DLL + routines and routines in the application using the DLL. + @end itemize + + @item + The entries in the @file{libAPI.a} or @file{API.lib} jump table which is + part of your application are initialized with the addresses of the routines + and variables in @file{API.dll}. + + @item + If present in @file{API.dll}, routines @code{DllMain} or + @code{DllMainCRTStartup} are invoked. These routines typically contain + the initialization code needed for the well-being of the routines and + variables exported by the DLL. + @end enumerate + + @noindent + There is an additional point which is worth mentioning. In the Windows + world there are two kind of DLLs: relocatable and non-relocatable + DLLs. Non-relocatable DLLs can only be loaded at a very specific address + in the target application address space. If the addresses of two + non-relocatable DLLs overlap and these happen to be used by the same + application, a conflict will occur and the application will run + incorrectly. Hence, when possible, it is always preferable to use and + build relocatable DLLs. Both relocatable and non-relocatable DLLs are + supported by GNAT. + + As a side note, an interesting difference between Microsoft DLLs and + Unix shared libraries, is the fact that on most Unix systems all public + routines are exported by default in a Unix shared library, while under + Windows the exported routines must be listed explicitly in a definition + file (@pxref{The Definition File}). + + @node Using DLLs with GNAT + @section Using DLLs with GNAT + + @menu + * Creating an Ada Spec for the DLL Services:: + * Creating an Import Library:: + @end menu + + @noindent + To use the services of a DLL, say @file{API.dll}, in your Ada application + you must have: + + @enumerate + @item + The Ada spec for the routines and/or variables you want to access in + @file{API.dll}. If not available this Ada spec must be built from the C/C++ + header files provided with the DLL. + + @item + The import library (@file{libAPI.a} or @file{API.lib}). As previously + mentioned an import library is a statically linked library containing the + import table which will be filled at load time to point to the actual + @file{API.dll} routines. Sometimes you don't have an import library for the + DLL you want to use. The following sections will explain how to build one. + + @item + The actual DLL, @file{API.dll}. + @end enumerate + + @noindent + Once you have all the above, to compile an Ada application that uses the + services of @file{API.dll} and whose main subprogram is @code{My_Ada_App}, + you simply issue the command + + @smallexample + $ gnatmake my_ada_app -largs -lAPI + @end smallexample + + @noindent + The argument @code{-largs -lAPI} at the end of the @code{gnatmake} command + tells the GNAT linker to look first for a library named @file{API.lib} + (Microsoft-style name) and if not found for a library named @file{libAPI.a} + (GNAT-style name). Note that if the Ada package spec for @file{API.dll} + contains the following pragma + + @smallexample + @b{pragma} Linker_Options ("-lAPI"); + @end smallexample + + @noindent + you do not have to add @code{-largs -lAPI} at the end of the @code{gnatmake} + command. + + If any one of the items above is missing you will have to create it + yourself. The following sections explain how to do so using as an + example a fictitious DLL called @file{API.dll}. + + @node Creating an Ada Spec for the DLL Services + @subsection Creating an Ada Spec for the DLL Services + + @noindent + A DLL typically comes with a C/C++ header file which provides the + definitions of the routines and variables exported by the DLL. The Ada + equivalent of this header file is a package spec that contains definitions + for the imported entities. If the DLL you intend to use does not come with + an Ada spec you have to generate one such spec yourself. For example if + the header file of @file{API.dll} is a file @file{api.h} containing the + following two definitions: + + @smallexample + @group + @cartouche + int some_var; + int get (char *); + @end cartouche + @end group + @end smallexample + + @noindent + then the equivalent Ada spec could be: + + @smallexample + @group + @cartouche + @b{with} Interfaces.C.Strings; + @b{package} API @b{is} + @b{use} Interfaces; + + Some_Var : C.int; + @b{function} Get (Str : C.Strings.Chars_Ptr) @b{return} C.int; + + @b{private} + @b{pragma} Import (C, Get); + @b{pragma} Import (DLL, Some_Var); + @b{end} API; + @end cartouche + @end group + @end smallexample + + @noindent + Note that a variable is @strong{always imported with a DLL convention}. A + function can have @code{C}, @code{Stdcall} or @code{DLL} convention. For + subprograms, the @code{DLL} convention is a synonym of @code{Stdcall} + (@pxref{Windows Calling Conventions}). + + @node Creating an Import Library + @subsection Creating an Import Library + @cindex Import library + + @menu + * The Definition File:: + * GNAT-Style Import Library:: + * Microsoft-Style Import Library:: + @end menu + + @noindent + If a Microsoft-style import library @file{API.lib} or a GNAT-style + import library @file{libAPI.a} is available with @file{API.dll} you + can skip this section. Otherwise read on. + + @node The Definition File + @subsubsection The Definition File + @cindex Definition file + @findex .def + + @noindent + As previously mentioned, and unlike Unix systems, the list of symbols + that are exported from a DLL must be provided explicitly in Windows. + The main goal of a definition file is precisely that: list the symbols + exported by a DLL. A definition file (usually a file with a @code{.def} + suffix) has the following structure: + + @smallexample + @group + @cartouche + [LIBRARY @i{name}] + [DESCRIPTION @i{string}] + EXPORTS + @i{symbol1} + @i{symbol2} + ... + @end cartouche + @end group + @end smallexample + + @table @code + @item LIBRARY @i{name} + This section, which is optional, gives the name of the DLL. + + @item DESCRIPTION @i{string} + This section, which is optional, gives a description string that will be + embedded in the import library. + + @item EXPORTS + This section gives the list of exported symbols (procedures, functions or + variables). For instance in the case of @file{API.dll} the @code{EXPORTS} + section of @file{API.def} looks like: + + @smallexample + @group + @cartouche + EXPORTS + some_var + get + @end cartouche + @end group + @end smallexample + @end table + + @noindent + Note that you must specify the correct suffix (@code{@@}@code{@i{nn}}) + (@pxref{Windows Calling Conventions}) for a Stdcall + calling convention function in the exported symbols list. + + @noindent + There can actually be other sections in a definition file, but these + sections are not relevant to the discussion at hand. + + @node GNAT-Style Import Library + @subsubsection GNAT-Style Import Library + + @noindent + To create a static import library from @file{API.dll} with the GNAT tools + you should proceed as follows: + + @enumerate + @item + Create the definition file @file{API.def} (@pxref{The Definition File}). + For that use the @code{dll2def} tool as follows: + + @smallexample + $ dll2def API.dll > API.def + @end smallexample + + @noindent + @code{dll2def} is a very simple tool: it takes as input a DLL and prints + to standard output the list of entry points in the DLL. Note that if + some routines in the DLL have the @code{Stdcall} convention + (@pxref{Windows Calling Conventions}) with stripped @code{@@}@i{nn} + suffix then you'll have to edit @file{api.def} to add it. + + @noindent + Here are some hints to find the right @code{@@}@i{nn} suffix. + + @enumerate + @item + If you have the Microsoft import library (.lib), it is possible to get + the right symbols by using Microsoft @code{dumpbin} tool (see the + corresponding Microsoft documentation for further details). + + @smallexample + $ dumpbin /exports api.lib + @end smallexample + + @item + If you have a message about a missing symbol at link time the compiler + tells you what symbol is expected. You just have to go back to the + definition file and add the right suffix. + @end enumerate + + @item + Build the import library @code{libAPI.a}, using @code{gnatdll} + (@pxref{Using gnatdll}) as follows: + + @smallexample + $ gnatdll -e API.def -d API.dll + @end smallexample + + @noindent + @code{gnatdll} takes as input a definition file @file{API.def} and the + name of the DLL containing the services listed in the definition file + @file{API.dll}. The name of the static import library generated is + computed from the name of the definition file as follows: if the + definition file name is @i{xyz}@code{.def}, the import library name will + be @code{lib}@i{xyz}@code{.a}. Note that in the previous example option + @code{-e} could have been removed because the name of the definition + file (before the "@code{.def}" suffix) is the same as the name of the + DLL (@pxref{Using gnatdll} for more information about @code{gnatdll}). + @end enumerate + + @node Microsoft-Style Import Library + @subsubsection Microsoft-Style Import Library + + @noindent + With GNAT you can either use a GNAT-style or Microsoft-style import + library. A Microsoft import library is needed only if you plan to make an + Ada DLL available to applications developed with Microsoft + tools (@pxref{Mixed-Language Programming on Windows}). + + To create a Microsoft-style import library for @file{API.dll} you + should proceed as follows: + + @enumerate + @item + Create the definition file @file{API.def} from the DLL. For this use either + the @code{dll2def} tool as described above or the Microsoft @code{dumpbin} + tool (see the corresponding Microsoft documentation for further details). + + @item + Build the actual import library using Microsoft's @code{lib} utility: + + @smallexample + $ lib -machine:IX86 -def:API.def -out:API.lib + @end smallexample + + @noindent + If you use the above command the definition file @file{API.def} must + contain a line giving the name of the DLL: + + @smallexample + LIBRARY "API" + @end smallexample + + @noindent + See the Microsoft documentation for further details about the usage of + @code{lib}. + @end enumerate + + @node Building DLLs with GNAT + @section Building DLLs with GNAT + @cindex DLLs, building + + @menu + * Limitations When Using Ada DLLs from Ada:: + * Exporting Ada Entities:: + * Ada DLLs and Elaboration:: + * Ada DLLs and Finalization:: + * Creating a Spec for Ada DLLs:: + * Creating the Definition File:: + * Using gnatdll:: + @end menu + + @noindent + This section explains how to build DLLs containing Ada code. These DLLs + will be referred to as Ada DLLs in the remainder of this section. + + The steps required to build an Ada DLL that is to be used by Ada as well as + non-Ada applications are as follows: + + @enumerate + @item + You need to mark each Ada @i{entity} exported by the DLL with a @code{C} or + @code{Stdcall} calling convention to avoid any Ada name mangling for the + entities exported by the DLL (@pxref{Exporting Ada Entities}). You can + skip this step if you plan to use the Ada DLL only from Ada applications. + + @item + Your Ada code must export an initialization routine which calls the routine + @code{adainit} generated by @code{gnatbind} to perform the elaboration of + the Ada code in the DLL (@pxref{Ada DLLs and Elaboration}). The initialization + routine exported by the Ada DLL must be invoked by the clients of the DLL + to initialize the DLL. + + @item + When useful, the DLL should also export a finalization routine which calls + routine @code{adafinal} generated by @code{gnatbind} to perform the + finalization of the Ada code in the DLL (@pxref{Ada DLLs and Finalization}). + The finalization routine exported by the Ada DLL must be invoked by the + clients of the DLL when the DLL services are no further needed. + + @item + You must provide a spec for the services exported by the Ada DLL in each + of the programming languages to which you plan to make the DLL available. + + @item + You must provide a definition file listing the exported entities + (@pxref{The Definition File}). + + @item + Finally you must use @code{gnatdll} to produce the DLL and the import + library (@pxref{Using gnatdll}). + @end enumerate + + @node Limitations When Using Ada DLLs from Ada + @subsection Limitations When Using Ada DLLs from Ada + + @noindent + When using Ada DLLs from Ada applications there is a limitation users + should be aware of. Because on Windows the GNAT run time is not in a DLL of + its own, each Ada DLL includes a part of the GNAT run time. Specifically, + each Ada DLL includes the services of the GNAT run time that are necessary + to the Ada code inside the DLL. As a result, when an Ada program uses an + Ada DLL there are two independent GNAT run times: one in the Ada DLL and + one in the main program. + + It is therefore not possible to exchange GNAT run-time objects between the + Ada DLL and the main Ada program. Example of GNAT run-time objects are file + handles (e.g. @code{Text_IO.File_Type}), tasks types, protected objects + types, etc. + + It is completely safe to exchange plain elementary, array or record types, + Windows object handles, etc. + + @node Exporting Ada Entities + @subsection Exporting Ada Entities + @cindex Export table + + @noindent + Building a DLL is a way to encapsulate a set of services usable from any + application. As a result, the Ada entities exported by a DLL should be + exported with the @code{C} or @code{Stdcall} calling conventions to avoid + any Ada name mangling. Please note that the @code{Stdcall} convention + should only be used for subprograms, not for variables. As an example here + is an Ada package @code{API}, spec and body, exporting two procedures, a + function, and a variable: + + @smallexample + @group + @cartouche + @b{with} Interfaces.C; @b{use} Interfaces; + @b{package} API @b{is} + Count : C.int := 0; + @b{function} Factorial (Val : C.int) @b{return} C.int; + + @b{procedure} Initialize_API; + @b{procedure} Finalize_API; + -- @i{Initialization & Finalization routines. More in the next section.} + @b{private} + @b{pragma} Export (C, Initialize_API); + @b{pragma} Export (C, Finalize_API); + @b{pragma} Export (C, Count); + @b{pragma} Export (C, Factorial); + @b{end} API; + @end cartouche + @end group + @end smallexample + + @smallexample + @group + @cartouche + @b{package body} API @b{is} + @b{function} Factorial (Val : C.int) @b{return} C.int @b{is} + Fact : C.int := 1; + @b{begin} + Count := Count + 1; + @b{for} K @b{in} 1 .. Val @b{loop} + Fact := Fact * K; + @b{end loop}; + @b{return} Fact; + @b{end} Factorial; + + @b{procedure} Initialize_API @b{is} + @b{procedure} Adainit; + @b{pragma} Import (C, Adainit); + @b{begin} + Adainit; + @b{end} Initialize_API; + + @b{procedure} Finalize_API @b{is} + @b{procedure} Adafinal; + @b{pragma} Import (C, Adafinal); + @b{begin} + Adafinal; + @b{end} Finalize_API; + @b{end} API; + @end cartouche + @end group + @end smallexample + + @noindent + If the Ada DLL you are building will only be used by Ada applications + you do not have to export Ada entities with a @code{C} or @code{Stdcall} + convention. As an example, the previous package could be written as + follows: + + @smallexample + @group + @cartouche + @b{package} API @b{is} + Count : Integer := 0; + @b{function} Factorial (Val : Integer) @b{return} Integer; + + @b{procedure} Initialize_API; + @b{procedure} Finalize_API; + -- @i{Initialization and Finalization routines.} + @b{end} API; + @end cartouche + @end group + @end smallexample + + @smallexample + @group + @cartouche + @b{package body} API @b{is} + @b{function} Factorial (Val : Integer) @b{return} Integer @b{is} + Fact : Integer := 1; + @b{begin} + Count := Count + 1; + @b{for} K @b{in} 1 .. Val @b{loop} + Fact := Fact * K; + @b{end loop}; + @b{return} Fact; + @b{end} Factorial; + + ... + -- @i{The remainder of this package body is unchanged.} + @b{end} API; + @end cartouche + @end group + @end smallexample + + @noindent + Note that if you do not export the Ada entities with a @code{C} or + @code{Stdcall} convention you will have to provide the mangled Ada names + in the definition file of the Ada DLL + (@pxref{Creating the Definition File}). + + @node Ada DLLs and Elaboration + @subsection Ada DLLs and Elaboration + @cindex DLLs and elaboration + + @noindent + The DLL that you are building contains your Ada code as well as all the + routines in the Ada library that are needed by it. The first thing a + user of your DLL must do is elaborate the Ada code + (@pxref{Elaboration Order Handling in GNAT}). + + To achieve this you must export an initialization routine + (@code{Initialize_API} in the previous example), which must be invoked + before using any of the DLL services. This elaboration routine must call + the Ada elaboration routine @code{adainit} generated by the GNAT binder + (@pxref{Binding with Non-Ada Main Programs}). See the body of + @code{Initialize_Api} for an example. Note that the GNAT binder is + automatically invoked during the DLL build process by the @code{gnatdll} + tool (@pxref{Using gnatdll}). + + When a DLL is loaded, Windows systematically invokes a routine called + @code{DllMain}. It would therefore be possible to call @code{adainit} + directly from @code{DllMain} without having to provide an explicit + initialization routine. Unfortunately, it is not possible to call + @code{adainit} from the @code{DllMain} if your program has library level + tasks because access to the @code{DllMain} entry point is serialized by + the system (that is, only a single thread can execute "through" it at a + time), which means that the GNAT run time will deadlock waiting for the + newly created task to complete its initialization. + + @node Ada DLLs and Finalization + @subsection Ada DLLs and Finalization + @cindex DLLs and finalization + + @noindent + When the services of an Ada DLL are no longer needed, the client code should + invoke the DLL finalization routine, if available. The DLL finalization + routine is in charge of releasing all resources acquired by the DLL. In the + case of the Ada code contained in the DLL, this is achieved by calling + routine @code{adafinal} generated by the GNAT binder + (@pxref{Binding with Non-Ada Main Programs}). + See the body of @code{Finalize_Api} for an + example. As already pointed out the GNAT binder is automatically invoked + during the DLL build process by the @code{gnatdll} tool + (@pxref{Using gnatdll}). + + @code{-g} + @cindex @code{-g} (@code{gnatdll}) + @* + Generate debugging information. This information is stored in the object + file and copied from there to the final DLL file by the linker, + where it can be read by the debugger. You must use the + @code{-g} switch if you plan on using the debugger or the symbolic + stack traceback. + + @node Creating a Spec for Ada DLLs + @subsection Creating a Spec for Ada DLLs + + @noindent + To use the services exported by the Ada DLL from another programming + language (e.g. C), you have to translate the specs of the exported Ada + entities in that language. For instance in the case of @code{API.dll}, + the corresponding C header file could look like: + + @smallexample + @group + @cartouche + extern int *__imp__count; + #define count (*__imp__count) + int factorial (int); + @end cartouche + @end group + @end smallexample + + @noindent + It is important to understand that when building an Ada DLL to be used by + other Ada applications, you need two different specs for the packages + contained in the DLL: one for building the DLL and the other for using + the DLL. This is because the @code{DLL} calling convention is needed to + use a variable defined in a DLL, but when building the DLL, the variable + must have either the @code{Ada} or @code{C} calling convention. As an + example consider a DLL comprising the following package @code{API}: + + @smallexample + @group + @cartouche + @b{package} API @b{is} + Count : Integer := 0; + ... + -- @i{Remainder of the package omitted.} + @b{end} API; + @end cartouche + @end group + @end smallexample + + @noindent + After producing a DLL containing package @code{API}, the spec that + must be used to import @code{API.Count} from Ada code outside of the + DLL is: + + @smallexample + @group + @cartouche + @b{package} API @b{is} + Count : Integer; + @b{pragma} Import (DLL, Count); + @b{end} API; + @end cartouche + @end group + @end smallexample + + @node Creating the Definition File + @subsection Creating the Definition File + + @noindent + The definition file is the last file needed to build the DLL. It lists + the exported symbols. As an example, the definition file for a DLL + containing only package @code{API} (where all the entities are exported + with a @code{C} calling convention) is: + + @smallexample + @group + @cartouche + EXPORTS + count + factorial + finalize_api + initialize_api + @end cartouche + @end group + @end smallexample + + @noindent + If the @code{C} calling convention is missing from package @code{API}, + then the definition file contains the mangled Ada names of the above + entities, which in this case are: + + @smallexample + @group + @cartouche + EXPORTS + api__count + api__factorial + api__finalize_api + api__initialize_api + @end cartouche + @end group + @end smallexample + + @node Using gnatdll + @subsection Using @code{gnatdll} + @findex gnatdll + + @menu + * gnatdll Example:: + * gnatdll behind the Scenes:: + * Using dlltool:: + @end menu + + @noindent + @code{gnatdll} is a tool to automate the DLL build process once all the Ada + and non-Ada sources that make up your DLL have been compiled. + @code{gnatdll} is actually in charge of two distinct tasks: build the + static import library for the DLL and the actual DLL. The form of the + @code{gnatdll} command is + + @smallexample + @cartouche + $ gnatdll [@var{switches}] @var{list-of-files} [-largs @var{opts}] + @end cartouche + @end smallexample + + @noindent + where @i{list-of-files} is a list of ALI and object files. The object + file list must be the exact list of objects corresponding to the non-Ada + sources whose services are to be included in the DLL. The ALI file list + must be the exact list of ALI files for the corresponding Ada sources + whose services are to be included in the DLL. If @i{list-of-files} is + missing, only the static import library is generated. + + @noindent + You may specify any of the following switches to @code{gnatdll}: + + @table @code + @item -a[@var{address}] + @cindex @code{-a} (@code{gnatdll}) + Build a non-relocatable DLL at @var{address}. If @var{address} is not + specified the default address @var{0x11000000} will be used. By default, + when this switch is missing, @code{gnatdll} builds relocatable DLL. We + advise the reader to build relocatable DLL. + + @item -b @var{address} + @cindex @code{-b} (@code{gnatdll}) + Set the relocatable DLL base address. By default the address is + @var{0x11000000}. + + @item -d @var{dllfile} + @cindex @code{-d} (@code{gnatdll}) + @var{dllfile} is the name of the DLL. This switch must be present for + @code{gnatdll} to do anything. The name of the generated import library is + obtained algorithmically from @var{dllfile} as shown in the following + example: if @var{dllfile} is @code{xyz.dll}, the import library name is + @code{libxyz.a}. The name of the definition file to use (if not specified + by option @code{-e}) is obtained algorithmically from @var{dllfile} as shown in + the following example: if @var{dllfile} is @code{xyz.dll}, the definition + file used is @code{xyz.def}. + + @item -e @var{deffile} + @cindex @code{-e} (@code{gnatdll}) + @var{deffile} is the name of the definition file. + + @item -h + @cindex @code{-h} (@code{gnatdll}) + Help mode. Displays @code{gnatdll} switch usage information. + + @item -Idir + Direct @code{gnatdll} to search the @var{dir} directory for source and + object files needed to build the DLL. + (@pxref{Search Paths and the Run-Time Library (RTL)}). + + @item -k + Removes the @code{@@}@i{nn} suffix from the import library's exported + names. You must specified this option if you want to use a + @code{Stdcall} function in a DLL for which the @code{@@}@i{nn} suffix + has been removed. This is the case for most of the Windows NT DLL for + example. This option has no effect when @code{-n} option is specified. + + @item -l @var{file} + @cindex @code{-l} (@code{gnatdll}) + The list of ALI and object files used to build the DLL are listed in + @var{file}, instead of being given in the command line. Each line in + @var{file} contains the name of an ALI or object file. + + @item -n + @cindex @code{-n} (@code{gnatdll}) + No Import. Do not create the import library. + + @item -q + @cindex @code{-q} (@code{gnatdll}) + Quiet mode. Do not display unnecessary messages. + + @item -v + @cindex @code{-v} (@code{gnatdll}) + Verbose mode. Display extra information. + + @item -largs @var{opts} + @cindex @code{-largs} (@code{gnatdll}) + Linker options. Pass @var{opts} to the linker. + @end table + + @node gnatdll Example + @subsubsection @code{gnatdll} Example + + @noindent + As an example the command to build a relocatable DLL from @file{api.adb} + once @file{api.adb} has been compiled and @file{api.def} created is + + @smallexample + $ gnatdll -d api.dll api.ali + @end smallexample + + @noindent + The above command creates two files: @file{libapi.a} (the import + library) and @file{api.dll} (the actual DLL). If you want to create + only the DLL, just type: + + @smallexample + $ gnatdll -d api.dll -n api.ali + @end smallexample + + @noindent + Alternatively if you want to create just the import library, type: + + @smallexample + $ gnatdll -d api.dll + @end smallexample + + @node gnatdll behind the Scenes + @subsubsection @code{gnatdll} behind the Scenes + + @noindent + This section details the steps involved in creating a DLL. @code{gnatdll} + does these steps for you. Unless you are interested in understanding what + goes on behind the scenes, you should skip this section. + + We use the previous example of a DLL containing the Ada package @code{API}, + to illustrate the steps necessary to build a DLL. The starting point is a + set of objects that will make up the DLL and the corresponding ALI + files. In the case of this example this means that @file{api.o} and + @file{api.ali} are available. To build a relocatable DLL, @code{gnatdll} does + the following: + + @enumerate + @item + @code{gnatdll} builds the base file (@file{api.base}). A base file gives + the information necessary to generate relocation information for the + DLL. + + @smallexample + @group + $ gnatbind -n api + $ gnatlink api -o api.jnk -mdll -Wl,--base-file,api.base + @end group + @end smallexample + + @noindent + In addition to the base file, the @code{gnatlink} command generates an + output file @file{api.jnk} which can be discarded. The @code{-mdll} switch + asks @code{gnatlink} to generate the routines @code{DllMain} and + @code{DllMainCRTStartup} that are called by the Windows loader when the DLL + is loaded into memory. + + @item + @code{gnatdll} uses @code{dlltool} (@pxref{Using dlltool}) to build the + export table (@file{api.exp}). The export table contains the relocation + information in a form which can be used during the final link to ensure + that the Windows loader is able to place the DLL anywhere in memory. + + @smallexample + @group + $ dlltool --dllname api.dll --def api.def --base-file api.base \ + --output-exp api.exp + @end group + @end smallexample + + @item + @code{gnatdll} builds the base file using the new export table. Note that + @code{gnatbind} must be called once again since the binder generated file + has been deleted during the previous call to @code{gnatlink}. + + @smallexample + @group + $ gnatbind -n api + $ gnatlink api -o api.jnk api.exp -mdll + -Wl,--base-file,api.base + @end group + @end smallexample + + @item + @code{gnatdll} builds the new export table using the new base file and + generates the DLL import library @file{libAPI.a}. + + @smallexample + @group + $ dlltool --dllname api.dll --def api.def --base-file api.base \ + --output-exp api.exp --output-lib libAPI.a + @end group + @end smallexample + + @item + Finally @code{gnatdll} builds the relocatable DLL using the final export + table. + + @smallexample + @group + $ gnatbind -n api + $ gnatlink api api.exp -o api.dll -mdll + @end group + @end smallexample + @end enumerate + + @node Using dlltool + @subsubsection Using @code{dlltool} + + @noindent + @code{dlltool} is the low-level tool used by @code{gnatdll} to build + DLLs and static import libraries. This section summarizes the most + common @code{dlltool} switches. The form of the @code{dlltool} command + is + + @smallexample + $ dlltool [@var{switches}] + @end smallexample + + @noindent + @code{dlltool} switches include: + + @table @code + @item --base-file @var{basefile} + Read the base file @var{basefile} generated by the linker. This switch + is used to create a relocatable DLL. + + @item --def @var{deffile} + Read the definition file. + + @item --dllname @var{name} + Gives the name of the DLL. This switch is used to embed the name of the + DLL in the static import library generated by @code{dlltool} with switch + @code{--output-lib}. + + @item -k + Kill @code{@@}@i{nn} from exported names + (@pxref{Windows Calling Conventions} + for a discussion about @code{Stdcall}-style symbols. + + @item --help + Prints the @code{dlltool} switches with a concise description. + + @item --output-exp @var{exportfile} + Generate an export file @var{exportfile}. The export file contains the + export table (list of symbols in the DLL) and is used to create the DLL. + + @item --output-lib @i{libfile} + Generate a static import library @var{libfile}. + + @item -v + Verbose mode. + + @item --as @i{assembler-name} + Use @i{assembler-name} as the assembler. The default is @code{as}. + @end table + + @node GNAT and Windows Resources + @section GNAT and Windows Resources + @cindex Resources, windows + + @menu + * Building Resources:: + * Compiling Resources:: + * Using Resources:: + * Limitations:: + @end menu + + @noindent + Resources are an easy way to add Windows specific objects to your + application. The objects that can be added as resources include: + + @itemize @bullet + @item + menus + + @item + accelerators + + @item + dialog boxes + + @item + string tables + + @item + bitmaps + + @item + cursors + + @item + icons + + @item + fonts + @end itemize + + @noindent + This section explains how to build, compile and use resources. + + @node Building Resources + @subsection Building Resources + @cindex Resources, building + + @noindent + A resource file is an ASCII file. By convention resource files have an + @file{.rc} extension. + The easiest way to build a resource file is to use Microsoft tools + such as @code{imagedit.exe} to build bitmaps, icons and cursors and + @code{dlgedit.exe} to build dialogs. + It is always possible to build an @file{.rc} file yourself by writing a + resource script. + + It is not our objective to explain how to write a resource file. A + complete description of the resource script language can be found in the + Microsoft documentation. + + @node Compiling Resources + @subsection Compiling Resources + @findex rc + @findex rcl + @findex res2coff + @cindex Resources, compiling + + @noindent + This section describes how to build a GNAT-compatible (COFF) object file + containing the resources. This is done using the Resource Compiler + @code{rcl} as follows: + + @smallexample + $ rcl -i myres.rc -o myres.o + @end smallexample + + @noindent + By default @code{rcl} will run @code{gcc} to preprocess the @file{.rc} + file. You can specify an alternate preprocessor (usually named + @file{cpp.exe}) using the @code{rcl} @code{-cpp} parameter. A list of + all possible options may be obtained by entering the command @code{rcl} + with no parameters. + + It is also possible to use the Microsoft resource compiler @code{rc.exe} + to produce a @file{.res} file (binary resource file). See the + corresponding Microsoft documentation for further details. In this case + you need to use @code{res2coff} to translate the @file{.res} file to a + GNAT-compatible object file as follows: + + @smallexample + $ res2coff -i myres.res -o myres.o + @end smallexample + + @node Using Resources + @subsection Using Resources + @cindex Resources, using + + @noindent + To include the resource file in your program just add the + GNAT-compatible object file for the resource(s) to the linker + arguments. With @code{gnatmake} this is done by using the @code{-largs} + option: + + @smallexample + $ gnatmake myprog -largs myres.o + @end smallexample + + @node Limitations + @subsection Limitations + @cindex Resources, limitations + + @noindent + In this section we describe the current limitations together with + suggestions for workarounds. + + @itemize @bullet + @item + @code{rcl} does not handle the @code{RCINCLUDE} directive. + @* + Workaround: replace @code{RCINCLUDE} by an @code{#include} directive. + + @item + @code{rcl} does not handle the brackets as block delimiters. + @* + Workaround: replace character '@{' by @code{BEGIN} and '@}' by + @code{END}. Note that Microsoft's @code{rc} handles both forms of block + delimiters. + + @item + @code{rcl} does not handle @code{TypeLib} resources. This type of + resource is used to build COM, DCOM or ActiveX objects. + @* + Workaround: use @code{rc}, the Microsoft resource compiler. + + @item + It is not possible to use @code{strip} to remove the debugging symbols + from a program with resources. + @* + Workaround: use linker option @code{-s} to strip debugging symbols from + the final executable. + @end itemize + + @node Debugging a DLL + @section Debugging a DLL + @cindex DLL debugging + + @menu + * The Program and the DLL Are Built with GCC/GNAT:: + * The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT:: + @end menu + + @noindent + Debugging a DLL is similar to debugging a standard program. But + we have to deal with two different executable parts: the DLL and the + program that uses it. We have the following four possibilities: + + @enumerate 1 + @item + The program and the DLL are built with @code{GCC/GNAT}. + @item + The program is built with foreign tools and the DLL is built with + @code{GCC/GNAT}. + @item + The program is built with @code{GCC/GNAT} and the DLL is built with + foreign tools. + @item + @end enumerate + + @noindent + In this section we address only cases one and two above. + There is no point in trying to debug + a DLL with @code{GNU/GDB}, if there is no GDB-compatible debugging + information in it. To do so you must use a debugger compatible with the + tools suite used to build the DLL. + + @node The Program and the DLL Are Built with GCC/GNAT + @subsection The Program and the DLL Are Built with GCC/GNAT + + @noindent + This is the simplest case. Both the DLL and the program have @code{GDB} + compatible debugging information. It is then possible to break anywhere in + the process. Let's suppose here that the main procedure is named + @code{ada_main} and that in the DLL there is an entry point named + @code{ada_dll}. + + @noindent + The DLL (@pxref{Introduction to Dynamic Link Libraries (DLLs)}) and + program must have been built with the debugging information (see GNAT -g + switch). Here are the step-by-step instructions for debugging it: + + @enumerate 1 + @item Launch @code{GDB} on the main program. + + @smallexample + $ gdb -nw ada_main + @end smallexample + + @item Break on the main procedure and run the program. + + @smallexample + (gdb) break ada_main + (gdb) run + @end smallexample + + @noindent + This step is required to be able to set a breakpoint inside the DLL. As long + as the program is not run, the DLL is not loaded. This has the + consequence that the DLL debugging information is also not loaded, so it is not + possible to set a breakpoint in the DLL. + + @item Set a breakpoint inside the DLL + + @smallexample + (gdb) break ada_dll + (gdb) run + @end smallexample + + @end enumerate + + @noindent + At this stage a breakpoint is set inside the DLL. From there on + you can use the standard approach to debug the whole program + (@pxref{Running and Debugging Ada Programs}). + + @node The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT + @subsection The Program Is Built with Some Foreign Tools and the DLL Is Built with GCC/GNAT + + @menu + * Debugging the DLL Directly:: + * Attaching to a Running Process:: + @end menu + + @noindent + In this case things are slightly more complex because it is not possible to + start the main program and then break at the beginning to load the DLL and the + associated DLL debugging information. It is not possible to break at the + beginning of the program because there is no @code{GDB} debugging information, + and therefore there is no direct way of getting initial control. This + section addresses this issue by describing some methods that can be used + to break somewhere in the DLL to debug it. + + @noindent + First suppose that the main procedure is named @code{main} (this is for + example some C code built with Microsoft Visual C) and that there is a + DLL named @code{test.dll} containing an Ada entry point named + @code{ada_dll}. + + @noindent + The DLL (@pxref{Introduction to Dynamic Link Libraries (DLLs)}) must have + been built with debugging information (see GNAT -g option). + + @node Debugging the DLL Directly + @subsubsection Debugging the DLL Directly + + @enumerate 1 + @item + Launch the debugger on the DLL. + + @smallexample + $ gdb -nw test.dll + @end smallexample + + @item Set a breakpoint on a DLL subroutine. + + @smallexample + (gdb) break ada_dll + @end smallexample + + @item + Specify the executable file to @code{GDB}. + + @smallexample + (gdb) exec-file main.exe + @end smallexample + + @item + Run the program. + + @smallexample + (gdb) run + @end smallexample + + @noindent + This will run the program until it reaches the breakpoint that has been + set. From that point you can use the standard way to debug a program + as described in (@pxref{Running and Debugging Ada Programs}). + + @end enumerate + + @noindent + It is also possible to debug the DLL by attaching to a running process. + + @node Attaching to a Running Process + @subsubsection Attaching to a Running Process + @cindex DLL debugging, attach to process + + @noindent + With @code{GDB} it is always possible to debug a running process by + attaching to it. It is possible to debug a DLL this way. The limitation + of this approach is that the DLL must run long enough to perform the + attach operation. It may be useful for instance to insert a time wasting + loop in the code of the DLL to meet this criterion. + + @enumerate 1 + + @item Launch the main program @file{main.exe}. + + @smallexample + $ main + @end smallexample + + @item Use the Windows @i{Task Manager} to find the process ID. Let's say + that the process PID for @file{main.exe} is 208. + + @item Launch gdb. + + @smallexample + $ gdb -nw + @end smallexample + + @item Attach to the running process to be debugged. + + @smallexample + (gdb) attach 208 + @end smallexample + + @item Load the process debugging information. + + @smallexample + (gdb) symbol-file main.exe + @end smallexample + + @item Break somewhere in the DLL. + + @smallexample + (gdb) break ada_dll + @end smallexample + + @item Continue process execution. + + @smallexample + (gdb) continue + @end smallexample + + @end enumerate + + @noindent + This last step will resume the process execution, and stop at + the breakpoint we have set. From there you can use the standard + approach to debug a program as described in + (@pxref{Running and Debugging Ada Programs}). + + @node GNAT and COM/DCOM Objects + @section GNAT and COM/DCOM Objects + @findex COM + @findex DCOM + + @noindent + This section is temporarily left blank. + + @ignore + @reread + ???????????? WE NEED TO DECIDE WHETHER TO DISTRIBUTE IT ?????????????????????? + + @node gnatreg : Registry Tool for NT + @section @code{gnatreg} : Registry Tool for NT + @findex gnatreg + @cindex Registry + + @menu + * Changing the GNAT compiler to Use:: + * Adding/Changing a Library Path:: + * Removing a Library Path:: + * List Current Configuration:: + @end menu + + @noindent + This tool can be used to switch from one compiler to another and to manage + the list of directories where GNAT must look to find packages. It is + also a convenient way to do network installation of GNAT. + + The form of the @code{gnatreg} command is + + @smallexample + $ gnatreg [@var{-hqcarf}] parameter + @end smallexample + + @noindent + Commons options are + + @table @code + + @item -h + print a usage message. + + @item -q + quiet/terse - display nothing, just do the job. + + @item -f + force mode - create the registry keys if they do not + exist. @code{gnatreg} will exit with an error if this option is omitted + and some registry keys are not setup correctly. + + @end table + + @subsection Changing the GNAT compiler to use + + @smallexample + $ gnatreg c:\gnatpro + @end smallexample + + @noindent + This will setup the registry to use the GNAT compiler that has been + installed under c:\gnatpro. @code{gnatreg} check that this directory contain + effectively a GNAT compiler. If you want to setup a network installation + and if GNAT has never been installed on this computer you'll have to use + the -f option. + + @subsection Adding/Changing a library path + + @smallexample + $ gnatreg -a COMPNT=c:\ada\components + @end smallexample + + @noindent + Add the directory c:\ada\components to the list of standards libraries. When + running gnatmake the option -Ic:\ada\components is added automatically to the + command line. + + The directory c:\ada\components is associated with the name COMPNT. This + name will be used to remove the library path. + + @subsection Removing a library path + + @smallexample + $ gnatreg -r COMPNT + @end smallexample + + @noindent + Remove the library path named COMPNT. + + @subsection List current configuration + + @smallexample + $ gnatreg -c + @end smallexample + + @noindent + @code{gnatreg} will display the GNAT and AdaGIDE path used and + all the standards libraries and their associated names that have been set. + + @end ignore + + + + @node Performance Considerations + @chapter Performance Considerations + @cindex Performance + + @noindent + The GNAT system provides a number of options that allow a trade-off + between + + @itemize @bullet + @item + performance of the generated code + + @item + speed of compilation + + @item + minimization of dependences and recompilation + + @item + the degree of run-time checking. + @end itemize + + @noindent + The defaults (if no options are selected) aim at improving the speed + of compilation and minimizing dependences, at the expense of performance + of the generated code: + + @itemize @bullet + @item + no optimization + + @item + no inlining of subprogram calls + + @item + all run-time checks enabled except overflow and elaboration checks + @end itemize + + @noindent + These options are suitable for most program development purposes. This + chapter describes how you can modify these choices, and also provides + some guidelines on debugging optimized code. + + @menu + * Controlling Run-Time Checks:: + * Optimization Levels:: + * Debugging Optimized Code:: + * Inlining of Subprograms:: + @end menu + + @node Controlling Run-Time Checks + @section Controlling Run-Time Checks + + @noindent + By default, GNAT generates all run-time checks, except arithmetic overflow + checking for integer operations and checks for access before elaboration on + subprogram calls. The latter are not required in default mode, because all + necessary checking is done at compile time. + @cindex @option{-gnatp} (@code{gcc}) + @cindex @option{-gnato} (@code{gcc}) + Two gnat switches, @option{-gnatp} and @option{-gnato} allow this default to + be modified. @xref{Run-Time Checks}. + + Our experience is that the default is suitable for most development + purposes. + + We treat integer overflow specially because these + are quite expensive and in our experience are not as important as other + run-time checks in the development process. Note that division by zero + is not considered an overflow check, and divide by zero checks are + generated where required by default. + + Elaboration checks are off by default, and also not needed by default, since + GNAT uses a static elaboration analysis approach that avoids the need for + run-time checking. This manual contains a full chapter discussing the issue + of elaboration checks, and if the default is not satisfactory for your use, + you should read this chapter. + + For validity checks, the minimal checks required by the Ada Reference + Manual (for case statements and assignments to array elements) are on + by default. These can be suppressed by use of the @option{-gnatVn} switch. + Note that in Ada 83, there were no validity checks, so if the Ada 83 mode + is acceptable (or when comparing GNAT performance with an Ada 83 compiler), + it may be reasonable to routinely use @option{-gnatVn}. Validity checks + are also suppressed entirely if @option{-gnatp} is used. + + @cindex Overflow checks + @cindex Checks, overflow + @findex Suppress + @findex Unsuppress + @cindex pragma Suppress + @cindex pragma Unsuppress + Note that the setting of the switches controls the default setting of + the checks. They may be modified using either @code{pragma Suppress} (to + remove checks) or @code{pragma Unsuppress} (to add back suppressed + checks) in the program source. + + @node Optimization Levels + @section Optimization Levels + @cindex @code{-O} (@code{gcc}) + + @noindent + The default is optimization off. This results in the fastest compile + times, but GNAT makes absolutely no attempt to optimize, and the + generated programs are considerably larger and slower than when + optimization is enabled. You can use the + @code{-O@var{n}} switch, where @var{n} is an integer from 0 to 3, + on the @code{gcc} command line to control the optimization level: + + @table @code + @item -O0 + no optimization (the default) + + @item -O1 + medium level optimization + + @item -O2 + full optimization + + @item -O3 + full optimization, and also attempt automatic inlining of small + subprograms within a unit (@pxref{Inlining of Subprograms}). + @end table + + Higher optimization levels perform more global transformations on the + program and apply more expensive analysis algorithms in order to generate + faster and more compact code. The price in compilation time, and the + resulting improvement in execution time, + both depend on the particular application and the hardware environment. + You should experiment to find the best level for your application. + + Note: Unlike some other compilation systems, @code{gcc} has + been tested extensively at all optimization levels. There are some bugs + which appear only with optimization turned on, but there have also been + bugs which show up only in @emph{unoptimized} code. Selecting a lower + level of optimization does not improve the reliability of the code + generator, which in practice is highly reliable at all optimization + levels. + + Note regarding the use of @code{-O3}: The use of this optimization level + is generally discouraged with GNAT, since it often results in larger + executables which run more slowly. See further discussion of this point + in @pxref{Inlining of Subprograms}. + + @node Debugging Optimized Code + @section Debugging Optimized Code + + @noindent + Since the compiler generates debugging tables for a compilation unit before + it performs optimizations, the optimizing transformations may invalidate some + of the debugging data. You therefore need to anticipate certain + anomalous situations that may arise while debugging optimized code. This + section describes the most common cases. + + @enumerate + @item + @i{The "hopping Program Counter":} Repeated 'step' or 'next' commands show the PC + bouncing back and forth in the code. This may result from any of the following + optimizations: + + @itemize @bullet + @item + @i{Common subexpression elimination:} using a single instance of code for a + quantity that the source computes several times. As a result you + may not be able to stop on what looks like a statement. + + @item + @i{Invariant code motion:} moving an expression that does not change within a + loop, to the beginning of the loop. + + @item + @i{Instruction scheduling:} moving instructions so as to + overlap loads and stores (typically) with other code, or in + general to move computations of values closer to their uses. Often + this causes you to pass an assignment statement without the assignment + happening and then later bounce back to the statement when the + value is actually needed. Placing a breakpoint on a line of code + and then stepping over it may, therefore, not always cause all the + expected side-effects. + @end itemize + + @item + @i{The "big leap":} More commonly known as @i{cross-jumping}, in which two + identical pieces of code are merged and the program counter suddenly + jumps to a statement that is not supposed to be executed, simply because + it (and the code following) translates to the same thing as the code + that @emph{was} supposed to be executed. This effect is typically seen in + sequences that end in a jump, such as a @code{goto}, a @code{return}, or + a @code{break} in a C @code{switch} statement. + + @item + @i{The "roving variable":} The symptom is an unexpected value in a variable. + There are various reasons for this effect: + + @itemize @bullet + @item + In a subprogram prologue, a parameter may not yet have been moved to its + "home". + + @item + A variable may be dead, and its register re-used. This is + probably the most common cause. + + @item + As mentioned above, the assignment of a value to a variable may + have been moved. + + @item + A variable may be eliminated entirely by value propagation or + other means. In this case, GCC may incorrectly generate debugging + information for the variable + @end itemize + + @noindent + In general, when an unexpected value appears for a local variable or parameter + you should first ascertain if that value was actually computed by + your program, as opposed to being incorrectly reported by the debugger. + Record fields or + array elements in an object designated by an access value + are generally less of a problem, once you have ascertained that the access value + is sensible. + Typically, this means checking variables in the preceding code and in the + calling subprogram to verify that the value observed is explainable from other + values (one must apply the procedure recursively to those + other values); or re-running the code and stopping a little earlier + (perhaps before the call) and stepping to better see how the variable obtained + the value in question; or continuing to step @emph{from} the point of the + strange value to see if code motion had simply moved the variable's + assignments later. + @end enumerate + + @node Inlining of Subprograms + @section Inlining of Subprograms + + @noindent + A call to a subprogram in the current unit is inlined if all the + following conditions are met: + + @itemize @bullet + @item + The optimization level is at least @code{-O1}. + + @item + The called subprogram is suitable for inlining: It must be small enough + and not contain nested subprograms or anything else that @code{gcc} + cannot support in inlined subprograms. + + @item + The call occurs after the definition of the body of the subprogram. + + @item + @cindex pragma Inline + @findex Inline + Either @code{pragma Inline} applies to the subprogram or it is + small and automatic inlining (optimization level @code{-O3}) is + specified. + @end itemize + + @noindent + Calls to subprograms in @code{with}'ed units are normally not inlined. + To achieve this level of inlining, the following conditions must all be + true: + + @itemize @bullet + @item + The optimization level is at least @code{-O1}. + + @item + The called subprogram is suitable for inlining: It must be small enough + and not contain nested subprograms or anything else @code{gcc} cannot + support in inlined subprograms. + + @item + The call appears in a body (not in a package spec). + + @item + There is a @code{pragma Inline} for the subprogram. + + @item + @cindex @option{-gnatn} (@code{gcc}) + The @code{-gnatn} switch + is used in the @code{gcc} command line + @end itemize + + Note that specifying the @option{-gnatn} switch causes additional + compilation dependencies. Consider the following: + + @smallexample + @group + @cartouche + @b{package} R @b{is} + @b{procedure} Q; + @b{pragma} Inline (Q); + @b{end} R; + @b{package body} R @b{is} + ... + @b{end} R; + + @b{with} R; + @b{procedure} Main @b{is} + @b{begin} + ... + R.Q; + @b{end} Main; + @end cartouche + @end group + @end smallexample + + @noindent + With the default behavior (no @option{-gnatn} switch specified), the + compilation of the @code{Main} procedure depends only on its own source, + @file{main.adb}, and the spec of the package in file @file{r.ads}. This + means that editing the body of @code{R} does not require recompiling + @code{Main}. + + On the other hand, the call @code{R.Q} is not inlined under these + circumstances. If the @option{-gnatn} switch is present when @code{Main} + is compiled, the call will be inlined if the body of @code{Q} is small + enough, but now @code{Main} depends on the body of @code{R} in + @file{r.adb} as well as on the spec. This means that if this body is edited, + the main program must be recompiled. Note that this extra dependency + occurs whether or not the call is in fact inlined by @code{gcc}. + + The use of front end inlining with @option{-gnatN} generates similar + additional dependencies. + + @cindex @code{-fno-inline} (@code{gcc}) + Note: The @code{-fno-inline} switch + can be used to prevent + all inlining. This switch overrides all other conditions and ensures + that no inlining occurs. The extra dependences resulting from + @option{-gnatn} will still be active, even if + this switch is used to suppress the resulting inlining actions. + + Note regarding the use of @code{-O3}: There is no difference in inlining + behavior between @code{-O2} and @code{-O3} for subprograms with an explicit + pragma @code{Inline} assuming the use of @option{-gnatn} + or @option{-gnatN} (the switches that activate inlining). If you have used + pragma @code{Inline} in appropriate cases, then it is usually much better + to use @code{-O2} and @option{-gnatn} and avoid the use of @code{-O3} which + in this case only has the effect of inlining subprograms you did not + think should be inlined. We often find that the use of @code{-O3} slows + down code by performing excessive inlining, leading to increased instruction + cache pressure from the increased code size. So the bottom line here is + that you should not automatically assume that @code{-O3} is better than + @code{-O2}, and indeed you should use @code{-O3} only if tests show that + it actually improves performance. + + + @include fdl.texi + @c GNU Free Documentation License + + @node Index,,GNU Free Documentation License, Top + @unnumbered Index + + @printindex cp + + @contents + + @bye diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatvsn.adb gcc-3.3/gcc/ada/gnatvsn.adb *** gcc-3.2.3/gcc/ada/gnatvsn.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/gnatvsn.adb 2002-09-24 03:44:32.000000000 +0000 *************** *** 0 **** --- 1,82 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- G N A T V S N -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- + -- -- + ------------------------------------------------------------------------------ + + package body Gnatvsn is + + -- Import the string constant defined in the (language-independent) + -- source file version.c. + + -- The size is a lie; we have no way of writing the truth (the size + -- is variable and depends on the actual text of the constant). + + -- FIXME: It should be possible to declare this to be a constant, but + -- that is rejected by the compiler ("invalid context for deferred + -- constant declaration"). Per Ada95 this constraint only applies to + -- deferred constants completed by a full constant declaration, not + -- deferred constants completed by a pragma Import. + + Version_String : array (0 .. Ver_Len_Max) of aliased Character; + pragma Import (C, Version_String, "version_string"); + + -- Convert that string constant to an Ada String and return it. + -- This is essentially the same as the To_Ada routine in + -- Interfaces.C; that package is not linked into gnat1 so + -- we cannot use it. + + function Gnat_Version_String return String + is + Count : Natural := 0; + + begin + loop + if Version_String (Count) = Character'First then + exit; + else + Count := Count + 1; + end if; + end loop; + + declare + R : String (1 .. Count); + + begin + for J in R'Range loop + R (J) := Version_String (J - 1); + end loop; + + return R; + end; + end Gnat_Version_String; + + end Gnatvsn; diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatvsn.ads gcc-3.3/gcc/ada/gnatvsn.ads *** gcc-3.2.3/gcc/ada/gnatvsn.ads 2003-04-22 06:16:06.000000000 +0000 --- gcc-3.3/gcc/ada/gnatvsn.ads 2002-11-15 01:45:29.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.65.2.276 $ -- -- ! -- Copyright (C) 1992-2003 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** *** 33,51 **** -- -- ------------------------------------------------------------------------------ ! -- This package spec holds version information for GNAT, GNATBIND and ! -- GNATMAKE. It is updated whenever the release number is changed. package Gnatvsn is ! Gnat_Version_String : constant String := "3.2.3 20030422 (release)"; -- Version output when GNAT (compiler), or its related tools, including -- GNATBIND, GNATCHOP, GNATFIND, GNATLINK, GNATMAKE, GNATXREF, are run -- (with appropriate verbose option switch set). -- ! -- WARNING: some gnatmail scripts (at least make-bin and corcs) rely on ! -- the format of this string. Any change must be coordinated with ! -- a gnatmail maintainer. Ver_Len_Max : constant := 32; -- Longest possible length for Gnat_Version_String in this or any --- 32,59 ---- -- -- ------------------------------------------------------------------------------ ! -- This package spec exports version information for GNAT, GNATBIND and ! -- GNATMAKE. package Gnatvsn is ! function Gnat_Version_String ! return String; -- Version output when GNAT (compiler), or its related tools, including -- GNATBIND, GNATCHOP, GNATFIND, GNATLINK, GNATMAKE, GNATXREF, are run -- (with appropriate verbose option switch set). + + Gnat_Version_Type : constant String := "FSF "; + -- This string is set to one of three values: -- ! -- "FSF " ! -- GNAT FSF version. This version of GNAT is part of a Free Software ! -- Foundation release of the GNU Compiler Collection (GCC). The binder ! -- will not output informational messages regarding intended use. ! -- and the bug box generated by Comperr will give information on ! -- how to report bugs and list the "no warranty" information. ! -- ! -- These are the only allowable settings for this string Ver_Len_Max : constant := 32; -- Longest possible length for Gnat_Version_String in this or any *************** package Gnatvsn is *** 54,60 **** -- value should never be decreased in the future, but it would be -- OK to increase it if absolutely necessary. ! Library_Version : constant String := "GNAT Lib v3.15a"; -- Library version. This value must be updated whenever any change to the -- compiler affects the library formats in such a way as to obsolete -- previously compiled library modules. --- 62,68 ---- -- value should never be decreased in the future, but it would be -- OK to increase it if absolutely necessary. ! Library_Version : constant String := "GNAT Lib v3.15"; -- Library version. This value must be updated whenever any change to the -- compiler affects the library formats in such a way as to obsolete -- previously compiled library modules. diff -Nrc3pad gcc-3.2.3/gcc/ada/gnatxref.adb gcc-3.3/gcc/ada/gnatxref.adb *** gcc-3.2.3/gcc/ada/gnatxref.adb 2002-05-04 03:28:13.000000000 +0000 --- gcc-3.3/gcc/ada/gnatxref.adb 2002-10-23 07:33:25.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1998-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2002 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- -- *************** *** 23,35 **** -- -- ------------------------------------------------------------------------------ ! with Xr_Tabls; ! with Xref_Lib; use Xref_Lib; ! with Ada.Text_IO; ! with Ada.Strings.Fixed; ! with GNAT.Command_Line; with Gnatvsn; ! with Osint; procedure Gnatxref is --- 22,38 ---- -- -- ------------------------------------------------------------------------------ ! with Xr_Tabls; use Xr_Tabls; ! with Xref_Lib; use Xref_Lib; ! with Osint; use Osint; ! with Types; use Types; ! with Gnatvsn; ! with Opt; ! ! with Ada.Strings.Fixed; use Ada.Strings.Fixed; ! with Ada.Text_IO; use Ada.Text_IO; ! with GNAT.Command_Line; use GNAT.Command_Line; procedure Gnatxref is *************** procedure Gnatxref is *** 57,76 **** procedure Parse_Cmd_Line is begin loop ! case GNAT.Command_Line.Getopt ("a aI: aO: d f g h I: p: u v") is when ASCII.NUL => exit; when 'a' => if GNAT.Command_Line.Full_Switch = "a" then Read_Only := True; elsif GNAT.Command_Line.Full_Switch = "aI" then Osint.Add_Src_Search_Dir (GNAT.Command_Line.Parameter); else Osint.Add_Lib_Search_Dir (GNAT.Command_Line.Parameter); end if; ! when 'd' => Der_Info := True; when 'f' => --- 60,84 ---- procedure Parse_Cmd_Line is begin loop ! case ! GNAT.Command_Line.Getopt ! ("a aI: aO: d f g h I: nostdinc nostdlib p: u v -RTS=") ! is when ASCII.NUL => exit; when 'a' => if GNAT.Command_Line.Full_Switch = "a" then Read_Only := True; + elsif GNAT.Command_Line.Full_Switch = "aI" then Osint.Add_Src_Search_Dir (GNAT.Command_Line.Parameter); + else Osint.Add_Lib_Search_Dir (GNAT.Command_Line.Parameter); end if; ! when 'd' => Der_Info := True; when 'f' => *************** procedure Gnatxref is *** 86,91 **** --- 94,106 ---- Osint.Add_Src_Search_Dir (GNAT.Command_Line.Parameter); Osint.Add_Lib_Search_Dir (GNAT.Command_Line.Parameter); + when 'n' => + if GNAT.Command_Line.Full_Switch = "nostdinc" then + Opt.No_Stdinc := True; + elsif GNAT.Command_Line.Full_Switch = "nostlib" then + Opt.No_Stdlib := True; + end if; + when 'p' => declare S : constant String := GNAT.Command_Line.Parameter; *************** procedure Gnatxref is *** 103,108 **** --- 118,157 ---- Vi_Mode := True; Search_Unused := False; + -- The only switch starting with -- recognized is --RTS + + when '-' => + Opt.No_Stdinc := True; + Opt.RTS_Switch := True; + + declare + Src_Path_Name : String_Ptr := + Get_RTS_Search_Dir + (GNAT.Command_Line.Parameter, Include); + + Lib_Path_Name : String_Ptr := + Get_RTS_Search_Dir + (GNAT.Command_Line.Parameter, Objects); + + begin + if Src_Path_Name /= null and then Lib_Path_Name /= null then + Add_Search_Dirs (Src_Path_Name, Include); + Add_Search_Dirs (Lib_Path_Name, Objects); + + elsif Src_Path_Name = null and then Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude and adalib directories"); + + elsif Src_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude directory"); + + elsif Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adalib directory"); + end if; + end; + when others => Write_Usage; end case; *************** procedure Gnatxref is *** 123,129 **** Write_Usage; end if; ! Add_File (S); Have_File := True; end; end loop; --- 172,178 ---- Write_Usage; end if; ! Add_Xref_File (S); Have_File := True; end; end loop; *************** procedure Gnatxref is *** 136,142 **** when GNAT.Command_Line.Invalid_Parameter => Ada.Text_IO.Put_Line ("Parameter missing for : " ! & GNAT.Command_Line.Parameter); Write_Usage; end Parse_Cmd_Line; --- 185,191 ---- when GNAT.Command_Line.Invalid_Parameter => Ada.Text_IO.Put_Line ("Parameter missing for : " ! & GNAT.Command_Line.Full_Switch); Write_Usage; end Parse_Cmd_Line; *************** procedure Gnatxref is *** 149,172 **** begin Put_Line ("GNATXREF " & Gnatvsn.Gnat_Version_String ! & " Copyright 1998-2001, Ada Core Technologies Inc."); Put_Line ("Usage: gnatxref [switches] file1 file2 ..."); New_Line; Put_Line (" file ... list of source files to xref, " & "including with'ed units"); New_Line; Put_Line ("gnatxref switches:"); ! Put_Line (" -a Consider all files, even when the ali file is" & " readonly"); ! Put_Line (" -aIdir Specify source files search path"); ! Put_Line (" -aOdir Specify library/object files search path"); ! Put_Line (" -d Output derived type information"); ! Put_Line (" -f Output full path name"); ! Put_Line (" -g Output information only for global symbols"); ! Put_Line (" -Idir Like -aIdir -aOdir"); ! Put_Line (" -p file Use file as the default project file"); ! Put_Line (" -u List unused entities"); ! Put_Line (" -v Print a 'tags' file for vi"); New_Line; raise Usage_Error; --- 198,227 ---- begin Put_Line ("GNATXREF " & Gnatvsn.Gnat_Version_String ! & " Copyright 1998-2002, Ada Core Technologies Inc."); Put_Line ("Usage: gnatxref [switches] file1 file2 ..."); New_Line; Put_Line (" file ... list of source files to xref, " & "including with'ed units"); New_Line; Put_Line ("gnatxref switches:"); ! Put_Line (" -a Consider all files, even when the ali file is" & " readonly"); ! Put_Line (" -aIdir Specify source files search path"); ! Put_Line (" -aOdir Specify library/object files search path"); ! Put_Line (" -d Output derived type information"); ! Put_Line (" -f Output full path name"); ! Put_Line (" -g Output information only for global symbols"); ! Put_Line (" -Idir Like -aIdir -aOdir"); ! Put_Line (" -nostdinc Don't look for sources in the system default" ! & " directory"); ! Put_Line (" -nostdlib Don't look for library files in the system" ! & " default directory"); ! Put_Line (" --RTS=dir specify the default source and object search" ! & " path"); ! Put_Line (" -p file Use file as the default project file"); ! Put_Line (" -u List unused entities"); ! Put_Line (" -v Print a 'tags' file for vi"); New_Line; raise Usage_Error; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-os_lib.adb gcc-3.3/gcc/ada/g-os_lib.adb *** gcc-3.2.3/gcc/ada/g-os_lib.adb 2001-11-29 05:15:53.000000000 +0000 --- gcc-3.3/gcc/ada/g-os_lib.adb 2002-05-31 18:08:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3 $ -- -- ! -- Copyright (C) 1995-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1995-2002 Ada Core Technologies, 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- -- *************** package body GNAT.OS_Lib is *** 58,67 **** Result : out Integer; Pid : out Process_Id; Blocking : Boolean); ! -- Internal routine to implement the to Spawn (blocking and non blocking) -- routines. If Blocking is set to True then the spawn is blocking -- otherwise it is non blocking. In this latter case the Pid contains -- the process id number. The first three parameters are as in Spawn. function To_Path_String_Access (Path_Addr : Address; --- 57,71 ---- Result : out Integer; Pid : out Process_Id; Blocking : Boolean); ! -- Internal routine to implement the two Spawn (blocking/non blocking) -- routines. If Blocking is set to True then the spawn is blocking -- otherwise it is non blocking. In this latter case the Pid contains -- the process id number. The first three parameters are as in Spawn. + -- Note that Spawn_Internal normalizes the argument list before calling + -- the low level system spawn routines (see Normalize_Arguments). Note + -- that Normalize_Arguments is designed to do nothing if it is called + -- more than once, so calling Normalize_Arguments before calling one + -- of the spawn routines is fine. function To_Path_String_Access (Path_Addr : Address; *************** package body GNAT.OS_Lib is *** 103,133 **** loop declare ! Quoted : Boolean := False; ! Backqd : Boolean := False; ! Old_Idx : Integer; begin Old_Idx := Idx; loop ! -- A vanilla space is the end of an argument ! if not Backqd and then not Quoted and then Arg_String (Idx) = ' ' then exit; -- Start of a quoted string ! elsif not Backqd and then not Quoted and then Arg_String (Idx) = '"' then Quoted := True; -- End of a quoted string and end of an argument ! elsif not Backqd and then Quoted and then Arg_String (Idx) = '"' then Idx := Idx + 1; --- 107,137 ---- loop declare ! Quoted : Boolean := False; ! Backqd : Boolean := False; ! Old_Idx : Integer; begin Old_Idx := Idx; loop ! -- An unquoted space is the end of an argument ! if not (Backqd or Quoted) and then Arg_String (Idx) = ' ' then exit; -- Start of a quoted string ! elsif not (Backqd or Quoted) and then Arg_String (Idx) = '"' then Quoted := True; -- End of a quoted string and end of an argument ! elsif (Quoted and not Backqd) and then Arg_String (Idx) = '"' then Idx := Idx + 1; *************** package body GNAT.OS_Lib is *** 320,325 **** --- 324,348 ---- return File_Time_Stamp (F_Name'Address); end File_Time_Stamp; + ---------- + -- Free -- + ---------- + + procedure Free (Arg : in out String_List_Access) is + X : String_Access; + + procedure Free_Array is new Unchecked_Deallocation + (Object => String_List, Name => String_List_Access); + + begin + for J in Arg'Range loop + X := Arg (J); + Free (X); + end loop; + + Free_Array (Arg); + end Free; + --------------------------- -- Get_Debuggable_Suffix -- --------------------------- *************** package body GNAT.OS_Lib is *** 768,773 **** --- 791,872 ---- return Pid; end Non_Blocking_Spawn; + ------------------------- + -- Normalize_Arguments -- + ------------------------- + + procedure Normalize_Arguments (Args : in out Argument_List) is + + procedure Quote_Argument (Arg : in out String_Access); + -- Add quote around argument if it contains spaces. + + Argument_Needs_Quote : Boolean; + pragma Import (C, Argument_Needs_Quote, "__gnat_argument_needs_quote"); + + -------------------- + -- Quote_Argument -- + -------------------- + + procedure Quote_Argument (Arg : in out String_Access) is + Res : String (1 .. Arg'Length * 2); + J : Positive := 1; + Quote_Needed : Boolean := False; + + begin + if Arg (Arg'First) /= '"' or else Arg (Arg'Last) /= '"' then + + -- Starting quote + + Res (J) := '"'; + + for K in Arg'Range loop + + J := J + 1; + + if Arg (K) = '"' then + Res (J) := '\'; + J := J + 1; + Res (J) := '"'; + + elsif Arg (K) = ' ' then + Res (J) := Arg (K); + Quote_Needed := True; + + else + Res (J) := Arg (K); + end if; + + end loop; + + if Quote_Needed then + + -- Ending quote + + J := J + 1; + Res (J) := '"'; + + declare + Old : String_Access := Arg; + + begin + Arg := new String'(Res (1 .. J)); + Free (Old); + end; + end if; + + end if; + end Quote_Argument; + + begin + if Argument_Needs_Quote then + for K in Args'Range loop + if Args (K) /= null then + Quote_Argument (Args (K)); + end if; + end loop; + end if; + end Normalize_Arguments; + ------------------------ -- Normalize_Pathname -- ------------------------ *************** package body GNAT.OS_Lib is *** 778,784 **** return String is Max_Path : Integer; ! pragma Import (C, Max_Path, "max_path_len"); -- Maximum length of a path name procedure Get_Current_Dir --- 877,883 ---- return String is Max_Path : Integer; ! pragma Import (C, Max_Path, "__gnat_max_path_len"); -- Maximum length of a path name procedure Get_Current_Dir *************** package body GNAT.OS_Lib is *** 876,881 **** --- 975,984 ---- Reference_Dir : constant String := Get_Directory; -- Current directory name specified + ----------------- + -- Final_Value -- + ----------------- + function Final_Value (S : String) return String is begin -- Interix has the non standard notion of disk drive *************** package body GNAT.OS_Lib is *** 1280,1353 **** Pid : out Process_Id; Blocking : Boolean) is - type Chars is array (Positive range <>) of aliased Character; - type Char_Ptr is access constant Character; ! Command_Len : constant Positive := Program_Name'Length + 1 ! + Args_Length (Args); ! Command_Last : Natural := 0; ! Command : aliased Chars (1 .. Command_Len); ! -- Command contains all characters of the Program_Name and Args, ! -- all terminated by ASCII.NUL characters ! Arg_List_Len : constant Positive := Args'Length + 2; ! Arg_List_Last : Natural := 0; ! Arg_List : aliased array (1 .. Arg_List_Len) of Char_Ptr; ! -- List with pointers to NUL-terminated strings of the ! -- Program_Name and the Args and terminated with a null pointer. ! -- We rely on the default initialization for the last null pointer. ! procedure Add_To_Command (S : String); ! -- Add S and a NUL character to Command, updating Last ! function Portable_Spawn (Args : Address) return Integer; ! pragma Import (C, Portable_Spawn, "__gnat_portable_spawn"); ! function Portable_No_Block_Spawn (Args : Address) return Process_Id; ! pragma Import ! (C, Portable_No_Block_Spawn, "__gnat_portable_no_block_spawn"); ! -------------------- ! -- Add_To_Command -- ! -------------------- ! procedure Add_To_Command (S : String) is ! First : constant Natural := Command_Last + 1; ! begin ! Command_Last := Command_Last + S'Length; ! -- Move characters one at a time, because Command has ! -- aliased components. ! for J in S'Range loop ! Command (First + J - S'First) := S (J); ! end loop; ! Command_Last := Command_Last + 1; ! Command (Command_Last) := ASCII.NUL; ! Arg_List_Last := Arg_List_Last + 1; ! Arg_List (Arg_List_Last) := Command (First)'Access; ! end Add_To_Command; -- Start of processing for Spawn_Internal begin ! Add_To_Command (Program_Name); ! for J in Args'Range loop ! Add_To_Command (Args (J).all); end loop; ! if Blocking then ! Pid := Invalid_Pid; ! Result := Portable_Spawn (Arg_List'Address); ! else ! Pid := Portable_No_Block_Spawn (Arg_List'Address); ! Result := Boolean'Pos (Pid /= Invalid_Pid); ! end if; end Spawn_Internal; --------------------------- --- 1383,1491 ---- Pid : out Process_Id; Blocking : Boolean) is ! procedure Spawn (Args : Argument_List); ! -- Call Spawn. ! N_Args : Argument_List (Args'Range); ! -- Normalized arguments ! ----------- ! -- Spawn -- ! ----------- ! procedure Spawn (Args : Argument_List) is ! type Chars is array (Positive range <>) of aliased Character; ! type Char_Ptr is access constant Character; ! Command_Len : constant Positive := Program_Name'Length + 1 ! + Args_Length (Args); ! Command_Last : Natural := 0; ! Command : aliased Chars (1 .. Command_Len); ! -- Command contains all characters of the Program_Name and Args, ! -- all terminated by ASCII.NUL characters ! Arg_List_Len : constant Positive := Args'Length + 2; ! Arg_List_Last : Natural := 0; ! Arg_List : aliased array (1 .. Arg_List_Len) of Char_Ptr; ! -- List with pointers to NUL-terminated strings of the ! -- Program_Name and the Args and terminated with a null pointer. ! -- We rely on the default initialization for the last null pointer. ! procedure Add_To_Command (S : String); ! -- Add S and a NUL character to Command, updating Last ! function Portable_Spawn (Args : Address) return Integer; ! pragma Import (C, Portable_Spawn, "__gnat_portable_spawn"); ! function Portable_No_Block_Spawn (Args : Address) return Process_Id; ! pragma Import ! (C, Portable_No_Block_Spawn, "__gnat_portable_no_block_spawn"); ! -------------------- ! -- Add_To_Command -- ! -------------------- ! procedure Add_To_Command (S : String) is ! First : constant Natural := Command_Last + 1; ! begin ! Command_Last := Command_Last + S'Length; ! ! -- Move characters one at a time, because Command has ! -- aliased components. ! ! for J in S'Range loop ! Command (First + J - S'First) := S (J); ! end loop; ! ! Command_Last := Command_Last + 1; ! Command (Command_Last) := ASCII.NUL; ! ! Arg_List_Last := Arg_List_Last + 1; ! Arg_List (Arg_List_Last) := Command (First)'Access; ! end Add_To_Command; ! ! -- Start of processing for Spawn ! ! begin ! Add_To_Command (Program_Name); ! ! for J in Args'Range loop ! Add_To_Command (Args (J).all); ! end loop; ! ! if Blocking then ! Pid := Invalid_Pid; ! Result := Portable_Spawn (Arg_List'Address); ! else ! Pid := Portable_No_Block_Spawn (Arg_List'Address); ! Result := Boolean'Pos (Pid /= Invalid_Pid); ! end if; ! end Spawn; -- Start of processing for Spawn_Internal begin ! -- Copy arguments into a local structure ! for K in N_Args'Range loop ! N_Args (K) := new String'(Args (K).all); end loop; ! -- Normalize those arguments ! ! Normalize_Arguments (N_Args); ! ! -- Call spawn using the normalized arguments ! ! Spawn (N_Args); ! ! -- Free arguments list + for K in N_Args'Range loop + Free (N_Args (K)); + end loop; end Spawn_Internal; --------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-os_lib.ads gcc-3.3/gcc/ada/g-os_lib.ads *** gcc-3.2.3/gcc/ada/g-os_lib.ads 2002-05-04 03:28:05.000000000 +0000 --- gcc-3.3/gcc/ada/g-os_lib.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1995-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1995-2002 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- -- *************** *** 42,50 **** -- This package tends to use fairly low-level Ada in order to not bring -- in large portions of the RTL. For example, functions return access ! -- to string as part of avoiding functions returning unconstrained types; ! -- types related to dates are defined here instead of using the types ! -- from Calendar, since use of Calendar forces linking in of tasking code. -- Except where specifically noted, these routines are portable across -- all GNAT implementations on all supported operating systems. --- 41,47 ---- -- This package tends to use fairly low-level Ada in order to not bring -- in large portions of the RTL. For example, functions return access ! -- to string as part of avoiding functions returning unconstrained types. -- Except where specifically noted, these routines are portable across -- all GNAT implementations on all supported operating systems. *************** package GNAT.OS_Lib is *** 56,70 **** pragma Elaborate_Body (OS_Lib); type String_Access is access all String; ! -- General purpose string access type procedure Free is new Unchecked_Deallocation (Object => String, Name => String_Access); type String_List is array (Positive range <>) of String_Access; type String_List_Access is access all String_List; -- General purpose array and pointer for list of string accesses --------------------- -- Time/Date Stuff -- --------------------- --- 53,77 ---- pragma Elaborate_Body (OS_Lib); type String_Access is access all String; ! -- General purpose string access type. Some of the functions in this ! -- package allocate string results on the heap, and return a value of ! -- this type. Note that the caller is responsible for freeing this ! -- String to avoid memory leaks. procedure Free is new Unchecked_Deallocation (Object => String, Name => String_Access); + -- This procedure is provided for freeing returned values of type + -- String_Access type String_List is array (Positive range <>) of String_Access; type String_List_Access is access all String_List; -- General purpose array and pointer for list of string accesses + procedure Free (Arg : in out String_List_Access); + -- Frees the given array and all strings that its elements reference, + -- and then sets the argument to null. Provided for freeing returned + -- values of this type (including Argument_List_Access). + --------------------- -- Time/Date Stuff -- --------------------- *************** pragma Elaborate_Body (OS_Lib); *** 200,206 **** (Old_Name : String; New_Name : String; Success : out Boolean); ! -- Rename a file. Successis set True or False indicating if the rename is -- successful. function Read --- 207,213 ---- (Old_Name : String; New_Name : String; Success : out Boolean); ! -- Rename a file. Success is set True or False indicating if the rename is -- successful. function Read *************** pragma Elaborate_Body (OS_Lib); *** 316,337 **** function Get_Debuggable_Suffix return String_Access; -- Return the debuggable suffix convention. Usually this is the same as ! -- the convention for Get_Executable_Suffix. ! -- ! -- Note that this function allocates some memory for the returned value. ! -- This memory needs to be deallocated after use. function Get_Executable_Suffix return String_Access; ! -- Return the executable suffix convention. ! -- ! -- Note that this function allocates some memory for the returned value. ! -- This memory needs to be deallocated after use. function Get_Object_Suffix return String_Access; ! -- Return the object suffix convention. ! -- ! -- Note that this function allocates some memory for the returned value. ! -- This memory needs to be deallocated after use. -- The following section contains low-level routines using addresses to -- pass file name and executable name. In each routine the name must be --- 323,340 ---- function Get_Debuggable_Suffix return String_Access; -- Return the 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 when no longer needed to avoid storage ! -- leaks. function Get_Executable_Suffix return String_Access; ! -- Return the executable suffix convention. The result is allocated on ! -- the heap and should be freed when no longer needed to avoid storage ! -- leaks. function Get_Object_Suffix return String_Access; ! -- Return the object suffix convention. The result is allocated on the ! -- heap and should be freed when no longer needed to avoid storage leaks. -- The following section contains low-level routines using addresses to -- pass file name and executable name. In each routine the name must be *************** pragma Elaborate_Body (OS_Lib); *** 392,399 **** -- the number of arguments. subtype Argument_List_Access is String_List_Access; ! -- Type used to return an Argument_List without dragging in secondary ! -- stack. procedure Spawn (Program_Name : String; --- 395,415 ---- -- the number of arguments. subtype Argument_List_Access is String_List_Access; ! -- Type used to return Argument_List without dragging in secondary stack. ! -- Note that there is a Free procedure declared for this subtype which ! -- frees the array and all referenced strings. ! ! procedure Normalize_Arguments (Args : in out Argument_List); ! -- Normalize all arguments in the list. This ensure that the argument list ! -- is compatible with the running OS and will works fine with Spawn and ! -- Non_Blocking_Spawn for example. If Normalize_Arguments is called twice ! -- on the same list it will do nothing the second time. Note that Spawn ! -- and Non_Blocking_Spawn call Normalize_Arguments automatically, but ! -- since there is a guarantee that a second call does nothing, this ! -- internal call with have no effect if Normalize_Arguments is called ! -- before calling Spawn. The call to Normalize_Arguments assumes that ! -- the individual referenced arguments in Argument_List are on the heap, ! -- and may free them and reallocate if they are modified. procedure Spawn (Program_Name : String; *************** pragma Elaborate_Body (OS_Lib); *** 408,422 **** -- argument. On some systems (notably Unix systems) a simple file -- name may also work (if the executable can be located in the path). -- ! -- Note: Arguments that contain spaces and/or quotes such as ! -- "--GCC=gcc -v" or "--GCC=""gcc-v""" are not portable ! -- across OSes. They may or may not have the desired effect. function Spawn (Program_Name : String; Args : Argument_List) return Integer; ! -- Like above, but as function returning the exact exit status type Process_Id is private; -- A private type used to identify a process activated by the following --- 424,454 ---- -- argument. On some systems (notably Unix systems) a simple file -- name may also work (if the executable can be located in the path). -- ! -- Note: Arguments in Args that contain spaces and/or quotes such as ! -- "--GCC=gcc -v" or "--GCC=""gcc -v""" are not portable across all ! -- operating systems, and would not have the desired effect if they ! -- were passed directly to the operating system. To avoid this problem, ! -- Spawn makes an internal call to Normalize_Arguments, which ensures ! -- that such arguments are modified in a manner that ensures that the ! -- desired effect is obtained on all operating systems. The caller may ! -- call Normalize_Arguments explicitly before the call (e.g. to print ! -- out the exact form of arguments passed to the operating system). In ! -- this case the guarantee a second call to Normalize_Arguments has no ! -- effect ensures that the internal call will not affect the result. ! -- Note that the implicit call to Normalize_Arguments may free and ! -- reallocate some of the individual arguments. ! -- ! -- This function will always set Success to False under VxWorks and ! -- other similar operating systems which have no notion of the concept ! -- of a dynamically executable file. function Spawn (Program_Name : String; Args : Argument_List) return Integer; ! -- Similar to the above procedure, but returns the actual status returned ! -- by the operating system, or -1 under VxWorks and any other similar ! -- operating systems which have no notion of separately spawnable programs. type Process_Id is private; -- A private type used to identify a process activated by the following *************** pragma Elaborate_Body (OS_Lib); *** 433,438 **** --- 465,473 ---- -- This is a non blocking call. The Process_Id of the spawned process -- is returned. Parameters are to be used as in Spawn. If Invalid_Id -- is returned the program could not be spawned. + -- + -- This function will always return Invalid_Id under VxWorks, since + -- there is no notion of executables under this OS. procedure Wait_Process (Pid : out Process_Id; Success : out Boolean); -- Wait for the completion of any of the processes created by previous *************** pragma Elaborate_Body (OS_Lib); *** 444,455 **** -- has terminated (matching the value returned from Non_Blocking_Spawn). -- Success is set to True if this sub-process terminated successfully. -- If Pid = Invalid_Id, there were no subprocesses left to wait on. function Argument_String_To_List (Arg_String : String) return Argument_List_Access; -- Take a string that is a program and it's arguments and parse it into ! -- an Argument_List. ------------------- -- Miscellaneous -- --- 479,495 ---- -- has terminated (matching the value returned from Non_Blocking_Spawn). -- Success is set to True if this sub-process terminated successfully. -- If Pid = Invalid_Id, there were no subprocesses left to wait on. + -- + -- This function will always set success to False under VxWorks, since + -- there is no notion of executables under this OS. function Argument_String_To_List (Arg_String : String) return Argument_List_Access; -- Take a string that is a program and it's arguments and parse it into ! -- an Argument_List. Note that the result is allocated on the heap, and ! -- must be freed by the programmer (when it is no longer needed) to avoid ! -- memory leaks. ------------------- -- Miscellaneous -- *************** pragma Elaborate_Body (OS_Lib); *** 460,466 **** -- to the empty string if the environment variable does not exist -- or has an explicit null value (in some operating systems these -- are distinct cases, in others they are not; this interface ! -- abstracts away that difference. procedure Setenv (Name : String; Value : String); -- Set the value of the environment variable Name to Value. This call --- 500,508 ---- -- to the empty string if the environment variable does not exist -- or has an explicit null value (in some operating systems these -- are distinct cases, in others they are not; this interface ! -- abstracts away that difference. The argument is allocated on ! -- the heap (even in the null case), and needs to be freed explicitly ! -- when no longer needed to avoid memory leaks. procedure Setenv (Name : String; Value : String); -- Set the value of the environment variable Name to Value. This call *************** pragma Elaborate_Body (OS_Lib); *** 476,485 **** --- 518,529 ---- 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) procedure OS_Abort; pragma Import (C, OS_Abort, "abort"); + pragma No_Return (OS_Abort); -- Exit to OS signalling an abort (traceback or other appropriate -- diagnostic information should be given if possible, or entry made -- to the debugger if that is possible). diff -Nrc3pad gcc-3.2.3/gcc/ada/g-regexp.adb gcc-3.3/gcc/ada/g-regexp.adb *** gcc-3.2.3/gcc/ada/g-regexp.adb 2001-12-12 21:26:45.000000000 +0000 --- gcc-3.3/gcc/ada/g-regexp.adb 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3 $ -- -- -- Copyright (C) 1999-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** package body GNAT.Regexp is *** 1092,1097 **** --- 1091,1098 ---- End_State : State_Index) return Regexp is + pragma Warnings (Off, Num_States); + Last_Index : constant State_Index := First_Table'Last (1); type Meta_State is array (1 .. Last_Index) of Boolean; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-regexp.ads gcc-3.3/gcc/ada/g-regexp.ads *** gcc-3.2.3/gcc/ada/g-regexp.ads 2001-10-02 14:15:32.000000000 +0000 --- gcc-3.3/gcc/ada/g-regexp.ads 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1998-1999 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-regist.adb gcc-3.3/gcc/ada/g-regist.adb *** gcc-3.2.3/gcc/ada/g-regist.adb 2002-05-04 03:28:05.000000000 +0000 --- gcc-3.3/gcc/ada/g-regist.adb 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-regist.ads gcc-3.3/gcc/ada/g-regist.ads *** gcc-3.2.3/gcc/ada/g-regist.ads 2002-05-04 03:28:05.000000000 +0000 --- gcc-3.3/gcc/ada/g-regist.ads 2002-10-23 07:33:24.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-regpat.adb gcc-3.3/gcc/ada/g-regpat.adb *** gcc-3.2.3/gcc/ada/g-regpat.adb 2001-12-20 06:22:41.000000000 +0000 --- gcc-3.3/gcc/ada/g-regpat.adb 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,15 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3 $ -- -- -- Copyright (C) 1986 by University of Toronto. -- ! -- Copyright (C) 1996-2001 Ada Core Technologies, 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- -- --- 6,14 ---- -- -- -- B o d y -- -- -- -- -- -- Copyright (C) 1986 by University of Toronto. -- ! -- Copyright (C) 1996-2002 Ada Core Technologies, 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- -- *************** package body GNAT.Regpat is *** 253,260 **** -- Local Subprograms -- ----------------------- - function "+" (Left : Opcode; Right : Integer) return Opcode; - function "-" (Left : Opcode; Right : Opcode) return Integer; function "=" (Left : Character; Right : Opcode) return Boolean; function Is_Alnum (C : Character) return Boolean; --- 252,257 ---- *************** package body GNAT.Regpat is *** 307,314 **** -- All of the subprograms above are tiny and should be inlined - pragma Inline ("+"); - pragma Inline ("-"); pragma Inline ("="); pragma Inline (Is_Alnum); pragma Inline (Is_Space); --- 304,309 ---- *************** package body GNAT.Regpat is *** 329,352 **** -- Worst case --------- - -- "+" -- - --------- - - function "+" (Left : Opcode; Right : Integer) return Opcode is - begin - return Opcode'Val (Opcode'Pos (Left) + Right); - end "+"; - - --------- - -- "-" -- - --------- - - function "-" (Left : Opcode; Right : Opcode) return Integer is - begin - return Opcode'Pos (Left) - Opcode'Pos (Right); - end "-"; - - --------- -- "=" -- --------- --- 324,329 ---- *************** package body GNAT.Regpat is *** 482,487 **** --- 459,465 ---- -- Dig the "next" pointer out of a node procedure Fail (M : in String); + pragma No_Return (Fail); -- Fail with a diagnostic message, if possible function Is_Curly_Operator (IP : Natural) return Boolean; *************** package body GNAT.Regpat is *** 612,617 **** --- 590,597 ---- Max : out Natural; Greedy : out Boolean) is + pragma Warnings (Off, IP); + Save_Pos : Natural := Parse_Pos + 1; begin *************** package body GNAT.Regpat is *** 896,901 **** --- 876,882 ---- else IP := 0; + Par_No := 0; end if; -- Pick up the branches, linking them together *************** package body GNAT.Regpat is *** 1030,1035 **** --- 1011,1017 ---- else IP := Emit_Node (ANY); end if; + Expr_Flags.Has_Width := True; Expr_Flags.Simple := True; *************** package body GNAT.Regpat is *** 1133,1139 **** Parse_Literal (Expr_Flags, IP); end case; ! when others => Parse_Literal (Expr_Flags, IP); end case; end Parse_Atom; --- 1115,1122 ---- Parse_Literal (Expr_Flags, IP); end case; ! when others => ! Parse_Literal (Expr_Flags, IP); end case; end Parse_Atom; *************** package body GNAT.Regpat is *** 2936,2944 **** -- parent's current state that we can try again after backing off. function Match_Whilem (IP : Pointer) return Boolean is Cc : Current_Curly_Access := Current_Curly; ! N : Natural := Cc.Cur + 1; ! Ln : Natural; Lastloc : Natural := Cc.Lastloc; -- Detection of 0-len. --- 2919,2930 ---- -- parent's current state that we can try again after backing off. function Match_Whilem (IP : Pointer) return Boolean is + pragma Warnings (Off, IP); + Cc : Current_Curly_Access := Current_Curly; ! N : Natural := Cc.Cur + 1; ! Ln : Natural := 0; ! Lastloc : Natural := Cc.Lastloc; -- Detection of 0-len. diff -Nrc3pad gcc-3.2.3/gcc/ada/g-regpat.ads gcc-3.3/gcc/ada/g-regpat.ads *** gcc-3.2.3/gcc/ada/g-regpat.ads 2001-10-02 14:15:32.000000000 +0000 --- gcc-3.3/gcc/ada/g-regpat.ads 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1986 by University of Toronto. -- -- Copyright (C) 1996-2001 Ada Core Technologies, Inc. -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-soccon.ads gcc-3.3/gcc/ada/g-soccon.ads *** gcc-3.2.3/gcc/ada/g-soccon.ads 2001-10-04 17:50:42.000000000 +0000 --- gcc-3.3/gcc/ada/g-soccon.ads 2002-03-14 10:59:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-socket.adb gcc-3.3/gcc/ada/g-socket.adb *** gcc-3.2.3/gcc/ada/g-socket.adb 2001-12-20 06:22:41.000000000 +0000 --- gcc-3.3/gcc/ada/g-socket.adb 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001-2002 Ada Core Technologies, 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- -- *************** package body GNAT.Sockets is *** 112,118 **** function Resolve_Error (Error_Value : Integer; From_Errno : Boolean := True) ! return Error_Type; -- Associate an enumeration value (error_type) to en error value -- (errno). From_Errno prevents from mixing h_errno with errno. --- 111,117 ---- function Resolve_Error (Error_Value : Integer; From_Errno : Boolean := True) ! return Error_Type; -- Associate an enumeration value (error_type) to en error value -- (errno). From_Errno prevents from mixing h_errno with errno. *************** package body GNAT.Sockets is *** 207,222 **** -------------------- procedure Abort_Selector (Selector : Selector_Type) is begin -- Send an empty array to unblock C select system call if Selector.In_Progress then ! declare ! Buf : Character; ! Res : C.int; ! begin ! Res := C_Write (C.int (Selector.W_Sig_Socket), Buf'Address, 0); ! end; end if; end Abort_Selector; --- 206,219 ---- -------------------- procedure Abort_Selector (Selector : Selector_Type) is + Buf : Character; + Res : C.int; + begin -- Send an empty array to unblock C select system call if Selector.In_Progress then ! Res := C_Write (C.int (Selector.W_Sig_Socket), Buf'Address, 1); end if; end Abort_Selector; *************** package body GNAT.Sockets is *** 235,240 **** --- 232,238 ---- begin Res := C_Accept (C.int (Server), Sin'Address, Len'Access); + if Res = Failure then Raise_Socket_Error (Socket_Errno); end if; *************** package body GNAT.Sockets is *** 364,369 **** --- 362,368 ---- else WSet := Fd_Set (W_Socket_Set.all); end if; + Len := C.int'Max (Max (RSet) + 1, Len); Selector.In_Progress := True; *************** package body GNAT.Sockets is *** 384,390 **** declare Buf : Character; begin ! Res := C_Read (C.int (Selector.R_Sig_Socket), Buf'Address, 0); end; -- Select was resumed because of read signalling socket, but --- 383,389 ---- declare Buf : Character; begin ! Res := C_Read (C.int (Selector.R_Sig_Socket), Buf'Address, 1); end; -- Select was resumed because of read signalling socket, but *************** package body GNAT.Sockets is *** 568,573 **** --- 567,573 ---- -- Get the port used by the socket Res := C_Getsockname (S0, Sin'Address, Len'Access); + if Res = Failure then Err := Socket_Errno; Res := C_Close (S0); *************** package body GNAT.Sockets is *** 575,580 **** --- 575,581 ---- end if; Res := C_Listen (S0, 2); + if Res = Failure then Err := Socket_Errno; Res := C_Close (S0); *************** package body GNAT.Sockets is *** 582,587 **** --- 583,589 ---- end if; S1 := C_Socket (Constants.AF_INET, Constants.SOCK_STREAM, 0); + if S1 = Failure then Err := Socket_Errno; Res := C_Close (S0); *************** package body GNAT.Sockets is *** 598,603 **** --- 600,606 ---- -- Do a connect and accept the connection Res := C_Connect (S1, Sin'Address, Len); + if Res = Failure then Err := Socket_Errno; Res := C_Close (S0); *************** package body GNAT.Sockets is *** 606,611 **** --- 609,615 ---- end if; S2 := C_Accept (S0, Sin'Address, Len'Access); + if S2 = Failure then Err := Socket_Errno; Res := C_Close (S0); *************** package body GNAT.Sockets is *** 614,619 **** --- 618,624 ---- end if; Res := C_Close (S0); + if Res = Failure then Raise_Socket_Error (Socket_Errno); end if; *************** package body GNAT.Sockets is *** 694,699 **** --- 699,706 ---- Family : Family_Type := Family_Inet) return Host_Entry_Type is + pragma Unreferenced (Family); + HA : aliased In_Addr := To_In_Addr (Address); Res : Hostent_Access; Err : Integer; *************** package body GNAT.Sockets is *** 849,859 **** end case; ! Res := C_Getsockopt ! (C.int (Socket), ! Levels (Level), ! Options (Name), ! Add, Len'Unchecked_Access); if Res = Failure then Raise_Socket_Error (Socket_Errno); --- 856,867 ---- end case; ! Res := ! C_Getsockopt ! (C.int (Socket), ! Levels (Level), ! Options (Name), ! Add, Len'Unchecked_Access); if Res = Failure then Raise_Socket_Error (Socket_Errno); *************** package body GNAT.Sockets is *** 1229,1235 **** function Resolve_Error (Error_Value : Integer; From_Errno : Boolean := True) ! return Error_Type is use GNAT.Sockets.Constants; --- 1237,1243 ---- function Resolve_Error (Error_Value : Integer; From_Errno : Boolean := True) ! return Error_Type is use GNAT.Sockets.Constants; *************** package body GNAT.Sockets is *** 1243,1248 **** --- 1251,1257 ---- when others => return Cannot_Resolve_Error; end case; end if; + case Error_Value is when EACCES => return Permission_Denied; when EADDRINUSE => return Address_Already_In_Use; *************** package body GNAT.Sockets is *** 1537,1542 **** --- 1546,1552 ---- begin Res := C_Shutdown (C.int (Socket), Shutmodes (How)); + if Res = Failure then Raise_Socket_Error (Socket_Errno); end if; *************** package body GNAT.Sockets is *** 1554,1560 **** S : Datagram_Socket_Stream_Access; begin ! S := new Datagram_Socket_Stream_Type; S.Socket := Socket; S.To := Send_To; S.From := Get_Socket_Name (Socket); --- 1564,1570 ---- S : Datagram_Socket_Stream_Access; begin ! S := new Datagram_Socket_Stream_Type; S.Socket := Socket; S.To := Send_To; S.From := Get_Socket_Name (Socket); *************** package body GNAT.Sockets is *** 1567,1573 **** function Stream (Socket : Socket_Type) ! return Stream_Access is S : Stream_Socket_Stream_Access; --- 1577,1583 ---- function Stream (Socket : Socket_Type) ! return Stream_Access is S : Stream_Socket_Stream_Access; *************** package body GNAT.Sockets is *** 1608,1614 **** In_Addr_Access_Pointers.Value (Host.H_Addr_List); -- H_Addr_List points to a list of binary addresses (in network -- byte order). The list is terminated by a NULL pointer. ! -- H_Length is not used because it is currently only set to 4. -- H_Addrtype is always AF_INET --- 1618,1624 ---- In_Addr_Access_Pointers.Value (Host.H_Addr_List); -- H_Addr_List points to a list of binary addresses (in network -- byte order). The list is terminated by a NULL pointer. ! -- -- H_Length is not used because it is currently only set to 4. -- H_Addrtype is always AF_INET diff -Nrc3pad gcc-3.2.3/gcc/ada/g-socket.ads gcc-3.3/gcc/ada/g-socket.ads *** gcc-3.2.3/gcc/ada/g-socket.ads 2001-12-17 21:00:59.000000000 +0000 --- gcc-3.3/gcc/ada/g-socket.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3 $ -- -- ! -- Copyright (C) 2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 2001-2002 Ada Core Technologies, 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- -- *************** *** 34,41 **** -- This package provides an interface to the sockets communication facility -- provided on many operating systems. Currently this is implemented on all ! -- native GNAT ports except for VMS. It is not yet implemented for any of ! -- the cross-ports (e.g. it is not available for VxWorks or LynxOS). -- Another restriction is that there is no multicast support under Windows -- or under any system on which the multicast support is not available or -- installed. --- 33,41 ---- -- This package provides an interface to the sockets communication facility -- provided on many operating systems. Currently this is implemented on all ! -- native GNAT ports except for VMS. It is not yet implemented on the Lynx ! -- cross-ports. ! -- Another restriction is that there is no multicast support under Windows -- or under any system on which the multicast support is not available or -- installed. *************** with Ada.Streams; *** 45,55 **** package GNAT.Sockets is ! -- Sockets are designed to provide a consistent communication ! -- facility between applications. This package provides an ! -- Ada-like interface similar to the one proposed as part of the ! -- BSD socket layer. This is a system independent thick binding. ! -- Here is a typical example of what you can do. -- with GNAT.Sockets; use GNAT.Sockets; -- --- 45,56 ---- package GNAT.Sockets is ! -- Sockets are designed to provide a consistent communication facility ! -- between applications. This package provides an Ada-like intrerface ! -- similar to that proposed as part of the BSD socket layer. This is a ! -- system independent thick binding. ! ! -- Here is a typical example of what you can do: -- with GNAT.Sockets; use GNAT.Sockets; -- *************** package GNAT.Sockets is *** 75,93 **** -- begin -- accept Start; -- ! -- -- Get an Internet address of a host (here "localhost"). -- -- Note that a host can have several addresses. Here we get -- -- the first one which is supposed to be the official one. -- ! -- Address.Addr := Addresses (Get_Host_By_Name ("localhost"), 1); -- -- -- Get a socket address that is an Internet address and a port -- -- Address.Port := 5432; -- -- -- The first step is to create a socket. Once created, this ! -- -- socket must be associated to with an address. Usually only a ! -- -- server (Pong here) needs to bind an address explicitly. -- -- Most of the time clients can skip this step because the -- -- socket routines will bind an arbitrary address to an unbound -- -- socket. --- 76,94 ---- -- begin -- accept Start; -- ! -- -- Get an Internet address of a host (here the local host name). -- -- Note that a host can have several addresses. Here we get -- -- the first one which is supposed to be the official one. -- ! -- Address.Addr := Addresses (Get_Host_By_Name (Host_Name), 1); -- -- -- Get a socket address that is an Internet address and a port -- -- Address.Port := 5432; -- -- -- The first step is to create a socket. Once created, this ! -- -- socket must be associated to with an address. Usually only ! -- -- a server (Pong here) needs to bind an address explicitly. -- -- Most of the time clients can skip this step because the -- -- socket routines will bind an arbitrary address to an unbound -- -- socket. *************** package GNAT.Sockets is *** 234,240 **** -- -- -- See comments in Ping section for the first steps. -- ! -- Address.Addr := Addresses (Get_Host_By_Name ("localhost"), 1); -- Address.Port := 5432; -- Create_Socket (Socket); -- --- 235,241 ---- -- -- -- See comments in Ping section for the first steps. -- ! -- Address.Addr := Addresses (Get_Host_By_Name (Host_Name), 1); -- Address.Port := 5432; -- Create_Socket (Socket); -- *************** package GNAT.Sockets is *** 481,488 **** -- Errors are described by an enumeration type. There is only one -- exception Socket_Error in this package to deal with an error -- during a socket routine. Once raised, its message contains the ! -- error code between brackets and a string describing the error ! -- code. type Error_Type is (Permission_Denied, --- 482,490 ---- -- Errors are described by an enumeration type. There is only one -- exception Socket_Error in this package to deal with an error -- during a socket routine. Once raised, its message contains the ! -- error code between brackets and a string describing the error code. ! ! -- The name of the enumeration constant documents the error condition. type Error_Type is (Permission_Denied, *************** package GNAT.Sockets is *** 813,819 **** -- data. In these cases Status is set to Completed and sockets -- that are ready are set in R_Socket_Set or W_Socket_Set. Status -- is set to Expired if no socket was ready after a Timeout ! -- expiration. Status is set to Aborted if an abort signal as been -- received while checking socket status. As this procedure -- returns when Timeout occurs, it is a design choice to keep this -- procedure process blocking. Note that a Timeout of 0.0 returns --- 815,821 ---- -- data. In these cases Status is set to Completed and sockets -- that are ready are set in R_Socket_Set or W_Socket_Set. Status -- is set to Expired if no socket was ready after a Timeout ! -- expiration. Status is set to Aborted if an abort signal has been -- received while checking socket status. As this procedure -- returns when Timeout occurs, it is a design choice to keep this -- procedure process blocking. Note that a Timeout of 0.0 returns diff -Nrc3pad gcc-3.2.3/gcc/ada/g-socthi.adb gcc-3.3/gcc/ada/g-socthi.adb *** gcc-3.2.3/gcc/ada/g-socthi.adb 2001-10-02 14:15:33.000000000 +0000 --- gcc-3.3/gcc/ada/g-socthi.adb 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-socthi.ads gcc-3.3/gcc/ada/g-socthi.ads *** gcc-3.2.3/gcc/ada/g-socthi.ads 2001-10-02 14:15:33.000000000 +0000 --- gcc-3.3/gcc/ada/g-socthi.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-soliop.ads gcc-3.3/gcc/ada/g-soliop.ads *** gcc-3.2.3/gcc/ada/g-soliop.ads 2001-10-02 14:15:33.000000000 +0000 --- gcc-3.3/gcc/ada/g-soliop.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-souinf.ads gcc-3.3/gcc/ada/g-souinf.ads *** gcc-3.2.3/gcc/ada/g-souinf.ads 2001-10-02 14:15:33.000000000 +0000 --- gcc-3.3/gcc/ada/g-souinf.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-speche.adb gcc-3.3/gcc/ada/g-speche.adb *** gcc-3.2.3/gcc/ada/g-speche.adb 2001-10-02 14:15:33.000000000 +0000 --- gcc-3.3/gcc/ada/g-speche.adb 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1998-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-speche.ads gcc-3.3/gcc/ada/g-speche.ads *** gcc-3.2.3/gcc/ada/g-speche.ads 2002-05-07 08:22:16.000000000 +0000 --- gcc-3.3/gcc/ada/g-speche.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-spipat.adb gcc-3.3/gcc/ada/g-spipat.adb *** gcc-3.2.3/gcc/ada/g-spipat.adb 2001-12-16 01:13:40.000000000 +0000 --- gcc-3.3/gcc/ada/g-spipat.adb 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1998-2001, Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2002, Ada Core Technologies, 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- -- *************** package body GNAT.Spitbol.Patterns is *** 77,83 **** subtype String_Ptr is Ada.Strings.Unbounded.String_Access; subtype File_Ptr is Ada.Text_IO.File_Access; - function To_PE_Ptr is new Unchecked_Conversion (Address, PE_Ptr); function To_Address is new Unchecked_Conversion (PE_Ptr, Address); -- Used only for debugging output purposes --- 76,81 ---- *************** package body GNAT.Spitbol.Patterns is *** 86,92 **** N : constant PE_Ptr := null; -- Shorthand used to initialize Copy fields to null - type Character_Ptr is access all Character; type Natural_Ptr is access all Natural; type Pattern_Ptr is access all Pattern; --- 84,89 ---- *************** package body GNAT.Spitbol.Patterns is *** 1229,1238 **** -- in the left operand, it represents the additional stack space -- required by the right operand. - function "&" (L, R : PE_Ptr) return PE_Ptr; - pragma Inline ("&"); - -- Equivalent to Concat (L, R, 0) - function C_To_PE (C : PChar) return PE_Ptr; -- Given a character, constructs a pattern element that matches -- the single character. --- 1226,1231 ---- *************** package body GNAT.Spitbol.Patterns is *** 1347,1357 **** return (AFC with L.Stk + R.Stk, Concat (Copy (L.P), Copy (R.P), R.Stk)); end "&"; - function "&" (L, R : PE_Ptr) return PE_Ptr is - begin - return Concat (L, R, 0); - end "&"; - --------- -- "*" -- --------- --- 1340,1345 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-spipat.ads gcc-3.3/gcc/ada/g-spipat.ads *** gcc-3.2.3/gcc/ada/g-spipat.ads 2001-10-02 14:15:34.000000000 +0000 --- gcc-3.3/gcc/ada/g-spipat.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1997-1999 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-spitbo.adb gcc-3.3/gcc/ada/g-spitbo.adb *** gcc-3.2.3/gcc/ada/g-spitbo.adb 2002-05-07 08:22:17.000000000 +0000 --- gcc-3.3/gcc/ada/g-spitbo.adb 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-spitbo.ads gcc-3.3/gcc/ada/g-spitbo.ads *** gcc-3.2.3/gcc/ada/g-spitbo.ads 2002-05-07 08:22:17.000000000 +0000 --- gcc-3.3/gcc/ada/g-spitbo.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1999 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-sptabo.ads gcc-3.3/gcc/ada/g-sptabo.ads *** gcc-3.2.3/gcc/ada/g-sptabo.ads 2002-05-07 08:22:17.000000000 +0000 --- gcc-3.3/gcc/ada/g-sptabo.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-sptain.ads gcc-3.3/gcc/ada/g-sptain.ads *** gcc-3.2.3/gcc/ada/g-sptain.ads 2002-05-07 08:22:17.000000000 +0000 --- gcc-3.3/gcc/ada/g-sptain.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-sptavs.ads gcc-3.3/gcc/ada/g-sptavs.ads *** gcc-3.2.3/gcc/ada/g-sptavs.ads 2002-05-07 08:22:17.000000000 +0000 --- gcc-3.3/gcc/ada/g-sptavs.ads 2002-03-14 10:59:22.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-1998 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-table.adb gcc-3.3/gcc/ada/g-table.adb *** gcc-3.2.3/gcc/ada/g-table.adb 2001-10-02 14:15:34.000000000 +0000 --- gcc-3.3/gcc/ada/g-table.adb 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1998-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** *** 32,38 **** -- -- ------------------------------------------------------------------------------ ! with System; use System; package body GNAT.Table is --- 31,39 ---- -- -- ------------------------------------------------------------------------------ ! with System; use System; ! with System.Memory; use System.Memory; ! with System.Address_To_Access_Conversions; package body GNAT.Table is *************** package body GNAT.Table is *** 49,56 **** Last_Val : Integer; -- Current value of Last. - type size_t is new Integer; - ----------------------- -- Local Subprograms -- ----------------------- --- 50,55 ---- *************** package body GNAT.Table is *** 60,65 **** --- 59,76 ---- -- in Max. Works correctly to do an initial allocation if the table -- is currently null. + package Table_Conversions is + new System.Address_To_Access_Conversions (Big_Table_Type); + -- Address and Access conversions for a Table object. + + function To_Address (Table : Table_Ptr) return Address; + pragma Inline (To_Address); + -- Returns the Address for the Table object. + + function To_Pointer (Table : Address) return Table_Ptr; + pragma Inline (To_Pointer); + -- Returns the Access pointer for the Table object. + -------------- -- Allocate -- -------------- *************** package body GNAT.Table is *** 101,111 **** ---------- procedure Free is - procedure free (T : Table_Ptr); - pragma Import (C, free); - begin ! free (Table); Table := null; Length := 0; end Free; --- 112,119 ---- ---------- procedure Free is begin ! Free (To_Address (Table)); Table := null; Length := 0; end Free; *************** package body GNAT.Table is *** 166,183 **** ---------------- procedure Reallocate is - - function realloc - (memblock : Table_Ptr; - size : size_t) - return Table_Ptr; - pragma Import (C, realloc); - - function malloc - (size : size_t) - return Table_Ptr; - pragma Import (C, malloc); - New_Size : size_t; begin --- 174,179 ---- *************** package body GNAT.Table is *** 202,214 **** (Table_Type'Component_Size / Storage_Unit)); if Table = null then ! Table := malloc (New_Size); elsif New_Size > 0 then Table := ! realloc ! (memblock => Table, ! size => New_Size); end if; if Length /= 0 and then Table = null then --- 198,209 ---- (Table_Type'Component_Size / Storage_Unit)); if Table = null then ! Table := To_Pointer (Alloc (New_Size)); elsif New_Size > 0 then Table := ! To_Pointer (Realloc (Ptr => To_Address (Table), ! Size => New_Size)); end if; if Length /= 0 and then Table = null then *************** package body GNAT.Table is *** 261,266 **** --- 256,280 ---- end if; end Set_Last; + ---------------- + -- To_Address -- + ---------------- + + function To_Address (Table : Table_Ptr) return Address is + begin + return Table_Conversions.To_Address + (Table_Conversions.Object_Pointer (Table)); + end To_Address; + + ---------------- + -- To_Pointer -- + ---------------- + + function To_Pointer (Table : Address) return Table_Ptr is + begin + return Table_Ptr (Table_Conversions.To_Pointer (Table)); + end To_Pointer; + begin Init; end GNAT.Table; diff -Nrc3pad gcc-3.2.3/gcc/ada/g-table.ads gcc-3.3/gcc/ada/g-table.ads *** gcc-3.2.3/gcc/ada/g-table.ads 2001-10-28 12:55:50.000000000 +0000 --- gcc-3.3/gcc/ada/g-table.ads 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 1998-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-tasloc.adb gcc-3.3/gcc/ada/g-tasloc.adb *** gcc-3.2.3/gcc/ada/g-tasloc.adb 2001-10-02 14:15:34.000000000 +0000 --- gcc-3.3/gcc/ada/g-tasloc.adb 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1997-1999 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-tasloc.ads gcc-3.3/gcc/ada/g-tasloc.ads *** gcc-3.2.3/gcc/ada/g-tasloc.ads 2001-10-02 14:15:34.000000000 +0000 --- gcc-3.3/gcc/ada/g-tasloc.ads 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1998-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-thread.adb gcc-3.3/gcc/ada/g-thread.adb *** gcc-3.2.3/gcc/ada/g-thread.adb 2001-10-02 14:15:34.000000000 +0000 --- gcc-3.3/gcc/ada/g-thread.adb 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1998-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-thread.ads gcc-3.3/gcc/ada/g-thread.ads *** gcc-3.2.3/gcc/ada/g-thread.ads 2001-10-02 14:15:34.000000000 +0000 --- gcc-3.3/gcc/ada/g-thread.ads 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1998-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-traceb.adb gcc-3.3/gcc/ada/g-traceb.adb *** gcc-3.2.3/gcc/ada/g-traceb.adb 2001-10-02 14:15:34.000000000 +0000 --- gcc-3.3/gcc/ada/g-traceb.adb 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1999-2000 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-traceb.ads gcc-3.3/gcc/ada/g-traceb.ads *** gcc-3.2.3/gcc/ada/g-traceb.ads 2001-10-30 23:26:09.000000000 +0000 --- gcc-3.3/gcc/ada/g-traceb.ads 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3 $ -- -- -- Copyright (C) 1999-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-trasym.adb gcc-3.3/gcc/ada/g-trasym.adb *** gcc-3.2.3/gcc/ada/g-trasym.adb 2001-10-02 14:15:35.000000000 +0000 --- gcc-3.3/gcc/ada/g-trasym.adb 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1999 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1999-2002 Ada Core Technologies, 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/g-trasym.ads gcc-3.3/gcc/ada/g-trasym.ads *** gcc-3.2.3/gcc/ada/g-trasym.ads 2001-10-04 17:50:42.000000000 +0000 --- gcc-3.3/gcc/ada/g-trasym.ads 2002-03-14 10:59:23.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1999-2002 Ada Core Technologies, 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- -- *************** *** 35,45 **** -- Run-time symbolic traceback support -- Note: this is only available on selected targets. Currently it is ! -- supported on Sparc/Solaris, GNU/Linux, Windows NT, HP-UX, IRIX and Tru64. -- The routines provided in this package assume that your application has -- been compiled with debugging information turned on, since this information -- is used to build a symbolic traceback. with Ada.Exceptions; use Ada.Exceptions; --- 34,55 ---- -- Run-time symbolic traceback support -- Note: this is only available on selected targets. Currently it is ! -- supported on Sparc/Solaris, GNU/Linux, Windows NT, HP-UX and Tru64. -- The routines provided in this package assume that your application has -- been compiled with debugging information turned on, since this information -- is used to build a symbolic traceback. + -- + -- In order to retrieve symbolic information, functions in this package will + -- read on disk all the debug information of the current executable and load + -- them in memory, causing a significant cpu and memory overhead. + -- + -- This package is not intended to be used within a shared library, + -- symbolic tracebacks are only supported for the main executable + -- and not for shared libraries. + -- + -- You should consider using off-line symbolic traceback instead, using + -- addr2line or gdb. with Ada.Exceptions; use Ada.Exceptions; diff -Nrc3pad gcc-3.2.3/gcc/ada/hlo.adb gcc-3.3/gcc/ada/hlo.adb *** gcc-3.2.3/gcc/ada/hlo.adb 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/hlo.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1998 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2001 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- -- *************** package body HLO is *** 35,40 **** --- 34,41 ---- ------------------------- procedure High_Level_Optimize (N : Node_Id) is + pragma Warnings (Off, N); + begin Write_Str ("High level optimizer activated"); Write_Eol; diff -Nrc3pad gcc-3.2.3/gcc/ada/hlo.ads gcc-3.3/gcc/ada/hlo.ads *** gcc-3.2.3/gcc/ada/hlo.ads 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/hlo.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/hostparm.ads gcc-3.3/gcc/ada/hostparm.ads *** gcc-3.2.3/gcc/ada/hostparm.ads 2002-05-04 03:28:13.000000000 +0000 --- gcc-3.3/gcc/ada/hostparm.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** *** 38,44 **** -- compiler is running, and thus this package is part of the compiler. package Hostparm is - pragma Preelaborate (Hostparm); ----------------------- -- TARGET Parameters -- --- 37,42 ---- *************** pragma Preelaborate (Hostparm); *** 53,59 **** -- HOST Parameters -- --------------------- ! OpenVMS : Boolean := False; -- Set True for OpenVMS host. See also OpenVMS target boolean in -- 5vsystem.ads and OpenVMS_On_Target boolean in Targparm. This is -- not a constant, because it can be modified by -gnatdm. --- 51,60 ---- -- HOST Parameters -- --------------------- ! Gnat_VMSp : Integer; ! pragma Import (C, Gnat_VMSp, "__gnat_vmsp"); ! ! OpenVMS : Boolean := Gnat_VMSp /= 0; -- Set True for OpenVMS host. See also OpenVMS target boolean in -- 5vsystem.ads and OpenVMS_On_Target boolean in Targparm. This is -- not a constant, because it can be modified by -gnatdm. diff -Nrc3pad gcc-3.2.3/gcc/ada/i-c.adb gcc-3.3/gcc/ada/i-c.adb *** gcc-3.2.3/gcc/ada/i-c.adb 2002-05-04 03:28:13.000000000 +0000 --- gcc-3.3/gcc/ada/i-c.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-c.ads gcc-3.3/gcc/ada/i-c.ads *** gcc-3.2.3/gcc/ada/i-c.ads 2002-05-07 08:22:18.000000000 +0000 --- gcc-3.3/gcc/ada/i-c.ads 2002-03-14 10:59:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cexten.ads gcc-3.3/gcc/ada/i-cexten.ads *** gcc-3.2.3/gcc/ada/i-cexten.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/i-cexten.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cobol.adb gcc-3.3/gcc/ada/i-cobol.adb *** gcc-3.2.3/gcc/ada/i-cobol.adb 2002-05-04 03:28:13.000000000 +0000 --- gcc-3.3/gcc/ada/i-cobol.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-1999 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body Interfaces.COBOL is *** 696,702 **** if Format = Packed_Unsigned then return Item (Item'Last) = 16#F#; - -- For signed, accept all standard and non-standard signs else --- 695,700 ---- *************** package body Interfaces.COBOL is *** 718,723 **** --- 716,723 ---- -- Note that the tests here are all compile time tests function Length (Format : Binary_Format) return Natural is + pragma Warnings (Off, Format); + begin if Num'Digits <= 2 then return 1; *************** package body Interfaces.COBOL is *** 756,761 **** --- 756,763 ---- (Format : Packed_Format) return Natural is + pragma Warnings (Off, Format); + begin case Packed_Representation is when IBM => diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cobol.ads gcc-3.3/gcc/ada/i-cobol.ads *** gcc-3.2.3/gcc/ada/i-cobol.ads 2002-05-04 03:28:13.000000000 +0000 --- gcc-3.3/gcc/ada/i-cobol.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (ASCII Version) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1993-2000 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cpoint.adb gcc-3.3/gcc/ada/i-cpoint.adb *** gcc-3.2.3/gcc/ada/i-cpoint.adb 2002-05-04 03:28:13.000000000 +0000 --- gcc-3.3/gcc/ada/i-cpoint.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cpoint.ads gcc-3.3/gcc/ada/i-cpoint.ads *** gcc-3.2.3/gcc/ada/i-cpoint.ads 2002-05-04 03:28:14.000000000 +0000 --- gcc-3.3/gcc/ada/i-cpoint.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1993-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cpp.adb gcc-3.3/gcc/ada/i-cpp.adb *** gcc-3.2.3/gcc/ada/i-cpp.adb 2002-05-04 03:28:14.000000000 +0000 --- gcc-3.3/gcc/ada/i-cpp.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Interfaces.CPP is *** 75,87 **** function To_Type_Specific_Data_Ptr is new Unchecked_Conversion (Address, Type_Specific_Data_Ptr); - function To_Address is new Unchecked_Conversion (Vtable_Ptr, Address); function To_Address is new Unchecked_Conversion (Type_Specific_Data_Ptr, Address); - function To_Vtable_Ptr is new Unchecked_Conversion (Tag, Vtable_Ptr); - function To_Tag is new Unchecked_Conversion (Vtable_Ptr, Tag); - --------------------------------------------- -- Unchecked Conversions for String Fields -- --------------------------------------------- --- 74,82 ---- *************** package body Interfaces.CPP is *** 158,163 **** --- 153,160 ---- ----------------------- function CPP_Get_RC_Offset (T : Vtable_Ptr) return SSE.Storage_Offset is + pragma Warnings (Off, T); + begin return 0; end CPP_Get_RC_Offset; *************** package body Interfaces.CPP is *** 167,172 **** --- 164,171 ---- ------------------------------- function CPP_Get_Remotely_Callable (T : Vtable_Ptr) return Boolean is + pragma Warnings (Off, T); + begin return True; end CPP_Get_Remotely_Callable; *************** package body Interfaces.CPP is *** 269,274 **** --- 268,276 ---- ----------------------- procedure CPP_Set_RC_Offset (T : Vtable_Ptr; Value : SSE.Storage_Offset) is + pragma Warnings (Off, T); + pragma Warnings (Off, Value); + begin null; end CPP_Set_RC_Offset; *************** package body Interfaces.CPP is *** 278,283 **** --- 280,288 ---- ------------------------------- procedure CPP_Set_Remotely_Callable (T : Vtable_Ptr; Value : Boolean) is + pragma Warnings (Off, T); + pragma Warnings (Off, Value); + begin null; end CPP_Set_Remotely_Callable; *************** package body Interfaces.CPP is *** 301,306 **** --- 306,314 ---- Position : Positive) return System.Address is + pragma Warnings (Off, Vptr); + pragma Warnings (Off, Position); + begin return Current_This; diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cpp.ads gcc-3.3/gcc/ada/i-cpp.ads *** gcc-3.2.3/gcc/ada/i-cpp.ads 2002-05-04 03:28:14.000000000 +0000 --- gcc-3.3/gcc/ada/i-cpp.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cstrea.adb gcc-3.3/gcc/ada/i-cstrea.adb *** gcc-3.2.3/gcc/ada/i-cstrea.adb 2002-05-04 03:28:14.000000000 +0000 --- gcc-3.3/gcc/ada/i-cstrea.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cstrea.ads gcc-3.3/gcc/ada/i-cstrea.ads *** gcc-3.2.3/gcc/ada/i-cstrea.ads 2002-05-04 03:28:14.000000000 +0000 --- gcc-3.3/gcc/ada/i-cstrea.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1995-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1995-2002 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- -- *************** *** 33,48 **** -- -- ------------------------------------------------------------------------------ - - -- This package is a thin binding to selected functions in the C -- library that provide a complete interface for handling C streams. - with Unchecked_Conversion; with System.Parameters; package Interfaces.C_Streams is ! pragma Elaborate_Body (C_Streams); -- Note: the reason we do not use the types that are in Interfaces.C is -- that we want to avoid dragging in the code in this unit if possible. --- 32,44 ---- -- -- ------------------------------------------------------------------------------ -- This package is a thin binding to selected functions in the C -- library that provide a complete interface for handling C streams. with System.Parameters; package Interfaces.C_Streams is ! pragma Preelaborate; -- Note: the reason we do not use the types that are in Interfaces.C is -- that we want to avoid dragging in the code in this unit if possible. *************** private *** 287,346 **** pragma Import (C, set_binary_mode, "__gnat_set_binary_mode"); pragma Import (C, set_text_mode, "__gnat_set_text_mode"); ! pragma Import (C, max_path_len, "max_path_len"); pragma Import (C, full_name, "__gnat_full_name"); -- The following may be implemented as macros, and so are supported ! -- via an interface function in the a-stdio.c file. pragma Import (C, feof, "__gnat_feof"); pragma Import (C, ferror, "__gnat_ferror"); pragma Import (C, fileno, "__gnat_fileno"); ! -- Constants in stdio are provided via imported variables that are ! -- defined in a-cstrea.c using the stdio.h header. It would be cleaner ! -- if we could import constant directly, but GNAT does not support ! -- pragma Import for constants ??? ! ! c_constant_EOF : int; ! ! c_constant_IOFBF : int; ! c_constant_IOLBF : int; ! c_constant_IONBF : int; ! ! c_constant_SEEK_CUR : int; ! c_constant_SEEK_END : int; ! c_constant_SEEK_SET : int; ! ! c_constant_L_tmpnam : int; ! ! pragma Import (C, c_constant_EOF, "__gnat_constant_eof"); ! pragma Import (C, c_constant_IOFBF, "__gnat_constant_iofbf"); ! pragma Import (C, c_constant_IOLBF, "__gnat_constant_iolbf"); ! pragma Import (C, c_constant_IONBF, "__gnat_constant_ionbf"); ! pragma Import (C, c_constant_SEEK_CUR, "__gnat_constant_seek_cur"); ! pragma Import (C, c_constant_SEEK_END, "__gnat_constant_seek_end"); ! pragma Import (C, c_constant_SEEK_SET, "__gnat_constant_seek_set"); ! pragma Import (C, c_constant_L_tmpnam, "__gnat_constant_l_tmpnam"); pragma Import (C, stderr, "__gnat_constant_stderr"); pragma Import (C, stdin, "__gnat_constant_stdin"); pragma Import (C, stdout, "__gnat_constant_stdout"); ! EOF : constant int := c_constant_EOF; ! IOFBF : constant int := c_constant_IOFBF; ! IOLBF : constant int := c_constant_IOLBF; ! IONBF : constant int := c_constant_IONBF; ! SEEK_CUR : constant int := c_constant_SEEK_CUR; ! SEEK_END : constant int := c_constant_SEEK_END; ! SEEK_SET : constant int := c_constant_SEEK_SET; ! L_tmpnam : constant int := c_constant_L_tmpnam; ! ! type Dummy is access Integer; ! function To_Address is new Unchecked_Conversion (Dummy, System.Address); ! -- Used to concoct the null address below ! ! NULL_Stream : constant FILEs := To_Address (Dummy'(null)); ! -- Value returned (NULL in C) to indicate an fdopen/fopen/tmpfile error end Interfaces.C_Streams; --- 283,311 ---- pragma Import (C, set_binary_mode, "__gnat_set_binary_mode"); pragma Import (C, set_text_mode, "__gnat_set_text_mode"); ! pragma Import (C, max_path_len, "__gnat_max_path_len"); pragma Import (C, full_name, "__gnat_full_name"); -- The following may be implemented as macros, and so are supported ! -- via an interface function in the a-cstrea.c file. pragma Import (C, feof, "__gnat_feof"); pragma Import (C, ferror, "__gnat_ferror"); pragma Import (C, fileno, "__gnat_fileno"); ! pragma Import (C, EOF, "__gnat_constant_eof"); ! pragma Import (C, IOFBF, "__gnat_constant_iofbf"); ! pragma Import (C, IOLBF, "__gnat_constant_iolbf"); ! pragma Import (C, IONBF, "__gnat_constant_ionbf"); ! pragma Import (C, SEEK_CUR, "__gnat_constant_seek_cur"); ! pragma Import (C, SEEK_END, "__gnat_constant_seek_end"); ! pragma Import (C, SEEK_SET, "__gnat_constant_seek_set"); ! pragma Import (C, L_tmpnam, "__gnat_constant_l_tmpnam"); pragma Import (C, stderr, "__gnat_constant_stderr"); pragma Import (C, stdin, "__gnat_constant_stdin"); pragma Import (C, stdout, "__gnat_constant_stdout"); ! NULL_Stream : constant FILEs := System.Null_Address; end Interfaces.C_Streams; diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cstrin.adb gcc-3.3/gcc/ada/i-cstrin.adb *** gcc-3.2.3/gcc/ada/i-cstrin.adb 2002-05-04 03:28:14.000000000 +0000 --- gcc-3.3/gcc/ada/i-cstrin.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body Interfaces.C.Strings is *** 59,69 **** function Position_Of_Nul (Into : char_array) return size_t; -- Returns position of the first Nul in Into or Into'Last + 1 if none ! function C_Malloc (Size : size_t) return chars_ptr; ! pragma Import (C, C_Malloc, "__gnat_malloc"); ! procedure C_Free (Address : chars_ptr); ! pragma Import (C, C_Free, "__gnat_free"); --------- -- "+" -- --- 58,71 ---- function Position_Of_Nul (Into : char_array) return size_t; -- Returns position of the first Nul in Into or Into'Last + 1 if none ! -- We can't use directly System.Memory because the categorization is not ! -- compatible, so we directly import here the malloc and free routines. ! function Memory_Alloc (Size : size_t) return chars_ptr; ! pragma Import (C, Memory_Alloc, "__gnat_malloc"); ! ! procedure Memory_Free (Address : chars_ptr); ! pragma Import (C, Memory_Free, "__gnat_free"); --------- -- "+" -- *************** package body Interfaces.C.Strings is *** 84,90 **** return; end if; ! C_Free (Item); Item := Null_Ptr; end Free; --- 86,92 ---- return; end if; ! Memory_Free (Item); Item := Null_Ptr; end Free; *************** package body Interfaces.C.Strings is *** 101,107 **** -- nul is absent and must be added explicitly. Index := Position_Of_Nul (Into => Chars); ! Pointer := C_Malloc ((Index - Chars'First + 1)); -- If nul is present, transfer string up to and including it. --- 103,109 ---- -- nul is absent and must be added explicitly. Index := Position_Of_Nul (Into => Chars); ! Pointer := Memory_Alloc ((Index - Chars'First + 1)); -- If nul is present, transfer string up to and including it. diff -Nrc3pad gcc-3.2.3/gcc/ada/i-cstrin.ads gcc-3.3/gcc/ada/i-cstrin.ads *** gcc-3.2.3/gcc/ada/i-cstrin.ads 2002-05-04 03:28:14.000000000 +0000 --- gcc-3.3/gcc/ada/i-cstrin.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1993-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-fortra.adb gcc-3.3/gcc/ada/i-fortra.adb *** gcc-3.2.3/gcc/ada/i-fortra.adb 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/i-fortra.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-fortra.ads gcc-3.3/gcc/ada/i-fortra.ads *** gcc-3.2.3/gcc/ada/i-fortra.ads 2001-10-02 14:15:37.000000000 +0000 --- gcc-3.3/gcc/ada/i-fortra.ads 2002-03-14 10:59:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/impunit.adb gcc-3.3/gcc/ada/impunit.adb *** gcc-3.2.3/gcc/ada/impunit.adb 2002-05-04 03:28:15.000000000 +0000 --- gcc-3.3/gcc/ada/impunit.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 2000-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2000-2002 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- -- *************** package body Impunit is *** 138,145 **** --- 137,146 ---- -- GNAT Defined Additions to Ada -- ----------------------------------- + "a-chlat9", -- Ada.Characters.Latin_9 "a-colire", -- Ada.Command_Line.Remove "a-cwila1", -- Ada.Characters.Wide_Latin_1 + "a-cwila9", -- Ada.Characters.Wide_Latin_9 "a-diocst", -- Ada.Direct_IO.C_Streams "a-einuoc", -- Ada.Exceptions.Is_Null_Occurrence "a-siocst", -- Ada.Sequential_IO.C_Streams *************** package body Impunit is *** 207,212 **** --- 208,214 ---- "g-io ", -- GNAT.IO "g-io_aux", -- GNAT.IO_Aux "g-locfil", -- GNAT.Lock_Files + "g-md5 ", -- GNAT.MD5 "g-moreex", -- GNAT.Most_Recent_Exception "g-os_lib", -- GNAT.Os_Lib "g-regexp", -- GNAT.Regexp *************** package body Impunit is *** 254,260 **** "i-os2syn", -- Interfaces.Os2lib.Synchronization "i-os2thr", -- Interfaces.Os2lib.Threads "i-pacdec", -- Interfaces.Packed_Decimal ! "i-vxwork", -- Interfaces.Vxworks -------------------------------------------------- -- System Hierarchy Units from Reference Manual -- --- 256,263 ---- "i-os2syn", -- Interfaces.Os2lib.Synchronization "i-os2thr", -- Interfaces.Os2lib.Threads "i-pacdec", -- Interfaces.Packed_Decimal ! "i-vxwork", -- Interfaces.VxWorks ! "i-vxwoio", -- Interfaces.VxWorks.IO -------------------------------------------------- -- System Hierarchy Units from Reference Manual -- diff -Nrc3pad gcc-3.2.3/gcc/ada/impunit.ads gcc-3.3/gcc/ada/impunit.ads *** gcc-3.2.3/gcc/ada/impunit.ads 2002-05-04 03:28:15.000000000 +0000 --- gcc-3.3/gcc/ada/impunit.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/init.c gcc-3.3/gcc/ada/init.c *** gcc-3.2.3/gcc/ada/init.c 2003-01-29 17:34:09.000000000 +0000 --- gcc-3.3/gcc/ada/init.c 2003-01-29 17:40:47.000000000 +0000 *************** *** 4,14 **** * * * I N I T * * * - * $Revision: 1.8.10.1.4.1 $ * * * C Implementation File * * * ! * Copyright (C) 1992-2001 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- * --- 4,13 ---- * * * I N I T * * * * * * C Implementation File * * * ! * Copyright (C) 1992-2002 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- * *************** *** 51,56 **** --- 50,58 ---- #include "tconfig.h" #include "tsystem.h" #include + + /* We don't have libiberty, so us malloc. */ + #define xmalloc(S) malloc (S) #else #include "config.h" #include "system.h" *************** extern void Propagate_Signal_Exception *** 94,107 **** PARAMS ((struct Machine_State *, struct Exception_Data *, const char *)); /* Copies of global values computed by the binder */ ! int __gl_main_priority = -1; ! int __gl_time_slice_val = -1; ! char __gl_wc_encoding = 'n'; ! char __gl_locking_policy = ' '; ! char __gl_queuing_policy = ' '; ! char __gl_task_dispatching_policy = ' '; ! int __gl_unreserve_all_interrupts = 0; ! int __gl_exception_tracebacks = 0; /* Indication of whether synchronous signal handler has already been installed by a previous call to adainit */ --- 96,111 ---- PARAMS ((struct Machine_State *, struct Exception_Data *, const char *)); /* Copies of global values computed by the binder */ ! int __gl_main_priority = -1; ! int __gl_time_slice_val = -1; ! char __gl_wc_encoding = 'n'; ! char __gl_locking_policy = ' '; ! char __gl_queuing_policy = ' '; ! char *__gl_restrictions = 0; ! char __gl_task_dispatching_policy = ' '; ! int __gl_unreserve_all_interrupts = 0; ! int __gl_exception_tracebacks = 0; ! int __gl_zero_cost_exceptions = 0; /* Indication of whether synchronous signal handler has already been installed by a previous call to adainit */ *************** int __gnat_handler_installed = 0; *** 126,139 **** void __gnat_set_globals (main_priority, time_slice_val, wc_encoding, locking_policy, ! queuing_policy, task_dispatching_policy, adafinal_ptr, ! unreserve_all_interrupts, exception_tracebacks) int main_priority; int time_slice_val; ! int wc_encoding; ! int locking_policy, queuing_policy, task_dispatching_policy; ! void (*adafinal_ptr) PARAMS ((void)) ATTRIBUTE_UNUSED; ! int unreserve_all_interrupts, exception_tracebacks; { static int already_called = 0; --- 130,144 ---- void __gnat_set_globals (main_priority, time_slice_val, wc_encoding, locking_policy, ! queuing_policy, task_dispatching_policy, restrictions, ! unreserve_all_interrupts, exception_tracebacks, ! zero_cost_exceptions) int main_priority; int time_slice_val; ! char wc_encoding; ! char locking_policy, queuing_policy, task_dispatching_policy; ! char *restrictions; ! int unreserve_all_interrupts, exception_tracebacks, zero_cost_exceptions; { static int already_called = 0; *************** __gnat_set_globals (main_priority, time_ *** 163,176 **** if (already_called) { ! if (__gl_locking_policy != locking_policy || ! __gl_queuing_policy != queuing_policy || ! __gl_task_dispatching_policy != task_dispatching_policy || ! __gl_unreserve_all_interrupts != unreserve_all_interrupts || ! __gl_exception_tracebacks != exception_tracebacks) ! { ! __gnat_raise_program_error (__FILE__, __LINE__); ! } return; } already_called = 1; --- 168,181 ---- if (already_called) { ! if (__gl_locking_policy != locking_policy ! || __gl_queuing_policy != queuing_policy ! || __gl_task_dispatching_policy != task_dispatching_policy ! || __gl_unreserve_all_interrupts != unreserve_all_interrupts ! || __gl_exception_tracebacks != exception_tracebacks ! || __gl_zero_cost_exceptions != zero_cost_exceptions) ! __gnat_raise_program_error (__FILE__, __LINE__); ! return; } already_called = 1; *************** __gnat_set_globals (main_priority, time_ *** 180,188 **** --- 185,209 ---- __gl_wc_encoding = wc_encoding; __gl_locking_policy = locking_policy; __gl_queuing_policy = queuing_policy; + __gl_restrictions = restrictions; __gl_task_dispatching_policy = task_dispatching_policy; __gl_unreserve_all_interrupts = unreserve_all_interrupts; __gl_exception_tracebacks = exception_tracebacks; + + /* ??? __gl_zero_cost_exceptions is new in 3.15 and is referenced from + a-except.adb, which is also part of the compiler sources. Since the + compiler is built with an older release of GNAT, the call generated by + the old binder to this function does not provide any value for the + corresponding argument, so the global has to be initialized in some + reasonable other way. This could be removed as soon as the next major + release is out. */ + + #ifdef IN_RTS + __gl_zero_cost_exceptions = zero_cost_exceptions; + #else + __gl_zero_cost_exceptions = 0; + /* We never build the compiler to run in ZCX mode currently anyway. */ + #endif } /*********************/ *************** __gnat_install_handler () *** 268,280 **** (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); ! ! if (__gl_unreserve_all_interrupts == 0) ! { ! (void) sigaction (SIGILL, &act, NULL); ! (void) sigaction (SIGSEGV, &act, NULL); ! (void) sigaction (SIGBUS, &act, NULL); ! } __gnat_handler_installed = 1; } --- 289,297 ---- (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); ! (void) sigaction (SIGILL, &act, NULL); ! (void) sigaction (SIGSEGV, &act, NULL); ! (void) sigaction (SIGBUS, &act, NULL); __gnat_handler_installed = 1; } *************** __gnat_install_handler () *** 393,405 **** (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); ! ! if (__gl_unreserve_all_interrupts == 0) ! { ! (void) sigaction (SIGILL, &act, NULL); ! (void) sigaction (SIGSEGV, &act, NULL); ! (void) sigaction (SIGBUS, &act, NULL); ! } __gnat_handler_installed = 1; } --- 410,418 ---- (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); ! (void) sigaction (SIGILL, &act, NULL); ! (void) sigaction (SIGSEGV, &act, NULL); ! (void) sigaction (SIGBUS, &act, NULL); __gnat_handler_installed = 1; } *************** __gnat_install_handler () *** 491,502 **** handled properly, avoiding a SEGV generation from stack usage by the handler itself. */ ! static char handler_stack [SIGSTKSZ]; stack_t stack; stack.ss_sp = handler_stack; ! stack.ss_size = SIGSTKSZ; stack.ss_flags = 0; (void) sigaltstack (&stack, NULL); --- 504,517 ---- handled properly, avoiding a SEGV generation from stack usage by the handler itself. */ ! static char handler_stack[SIGSTKSZ*2]; ! /* SIGSTKSZ appeared to be "short" for the needs in some contexts ! (e.g. experiments with GCC ZCX exceptions). */ stack_t stack; stack.ss_sp = handler_stack; ! stack.ss_size = sizeof (handler_stack); stack.ss_flags = 0; (void) sigaltstack (&stack, NULL); *************** __gnat_install_handler () *** 507,519 **** (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); - if (__gl_unreserve_all_interrupts == 0) - { - (void) sigaction (SIGILL, &act, NULL); - (void) sigaction (SIGSEGV, &act, NULL); - (void) sigaction (SIGBUS, &act, NULL); - } __gnat_handler_installed = 1; } --- 522,531 ---- (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); + (void) sigaction (SIGILL, &act, NULL); + (void) sigaction (SIGSEGV, &act, NULL); + (void) sigaction (SIGBUS, &act, NULL); __gnat_handler_installed = 1; } *************** __gnat_install_handler () *** 654,666 **** (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); - if (__gl_unreserve_all_interrupts == 0) - { - (void) sigaction (SIGILL, &act, NULL); - (void) sigaction (SIGSEGV, &act, NULL); - (void) sigaction (SIGBUS, &act, NULL); - } __gnat_handler_installed = 1; } --- 666,675 ---- (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); + (void) sigaction (SIGILL, &act, NULL); + (void) sigaction (SIGSEGV, &act, NULL); + (void) sigaction (SIGBUS, &act, NULL); __gnat_handler_installed = 1; } *************** __gnat_install_handler () *** 878,887 **** /* (void) sigaction (SIGABRT, &act, NULL); */ /* (void) sigaction (SIGFPE, &act, NULL); */ /* (void) sigaction (SIGBUS, &act, NULL); */ ! if (__gl_unreserve_all_interrupts == 0) ! { ! (void) sigaction (SIGSEGV, &act, NULL); ! } __gnat_handler_installed = 1; } --- 887,895 ---- /* (void) sigaction (SIGABRT, &act, NULL); */ /* (void) sigaction (SIGFPE, &act, NULL); */ /* (void) sigaction (SIGBUS, &act, NULL); */ ! ! (void) sigaction (SIGSEGV, &act, NULL); ! __gnat_handler_installed = 1; } *************** __gnat_install_handler () *** 1061,1073 **** (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); ! ! if (__gl_unreserve_all_interrupts == 0) ! { ! (void) sigaction (SIGILL, &act, NULL); ! (void) sigaction (SIGSEGV, &act, NULL); ! (void) sigaction (SIGBUS, &act, NULL); ! } (void) sigaction (SIGADAABORT, &act, NULL); __gnat_handler_installed = 1; } --- 1069,1077 ---- (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); ! (void) sigaction (SIGILL, &act, NULL); ! (void) sigaction (SIGSEGV, &act, NULL); ! (void) sigaction (SIGBUS, &act, NULL); (void) sigaction (SIGADAABORT, &act, NULL); __gnat_handler_installed = 1; } *************** __gnat_install_handler () *** 1170,1182 **** (void) sigemptyset (&act.sa_mask); (void) sigaction (SIGABRT, &act, NULL); - if (__gl_unreserve_all_interrupts == 0) - { - (void) sigaction (SIGFPE, &act, NULL); - (void) sigaction (SIGSEGV, &act, NULL); - (void) sigaction (SIGBUS, &act, NULL); - } __gnat_handler_installed = 1; } --- 1174,1183 ---- (void) sigemptyset (&act.sa_mask); (void) sigaction (SIGABRT, &act, NULL); + (void) sigaction (SIGFPE, &act, NULL); + (void) sigaction (SIGSEGV, &act, NULL); + (void) sigaction (SIGBUS, &act, NULL); __gnat_handler_installed = 1; } *************** __gnat_install_handler () *** 1256,1268 **** (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); - if (__gl_unreserve_all_interrupts == 0) - { - (void) sigaction (SIGILL, &act, NULL); - (void) sigaction (SIGSEGV, &act, NULL); - (void) sigaction (SIGBUS, &act, NULL); - } __gnat_handler_installed = 1; } --- 1257,1266 ---- (void) sigaction (SIGABRT, &act, NULL); (void) sigaction (SIGFPE, &act, NULL); + (void) sigaction (SIGILL, &act, NULL); + (void) sigaction (SIGSEGV, &act, NULL); + (void) sigaction (SIGBUS, &act, NULL); __gnat_handler_installed = 1; } *************** extern struct Exception_Data *Coded_Exce *** 1317,1337 **** struct descriptor_s {unsigned short len, mbz; char *adr; }; ! static long __gnat_error_handler PARAMS ((int *, void *)); ! static long __gnat_error_handler (sigargs, mechargs) int *sigargs; void *mechargs; { struct Exception_Data *exception = 0; char *msg = ""; ! char message [256]; long prvhnd; struct descriptor_s msgdesc; int msg_flag = 0x000f; /* 1 bit for each of the four message parts */ unsigned short outlen; ! char curr_icb [544]; long curr_invo_handle; long *mstate; --- 1315,1335 ---- struct descriptor_s {unsigned short len, mbz; char *adr; }; ! long __gnat_error_handler PARAMS ((int *, void *)); ! long __gnat_error_handler (sigargs, mechargs) int *sigargs; void *mechargs; { struct Exception_Data *exception = 0; char *msg = ""; ! char message[256]; long prvhnd; struct descriptor_s msgdesc; int msg_flag = 0x000f; /* 1 bit for each of the four message parts */ unsigned short outlen; ! char curr_icb[544]; long curr_invo_handle; long *mstate; *************** __gnat_error_handler (sigargs, mechargs) *** 1359,1378 **** #ifdef IN_RTS /* See if it's an imported exception. Mask off severity bits. */ ! exception = Coded_Exception (sigargs [1] & 0xfffffff8); if (exception) { msgdesc.len = 256; msgdesc.mbz = 0; msgdesc.adr = message; SYS$GETMSG (sigargs[1], &outlen, &msgdesc, msg_flag, 0); ! message [outlen] = 0; msg = message; exception->Name_Length = 19; /* The full name really should be get sys$getmsg returns. ??? */ exception->Full_Name = "IMPORTED_EXCEPTION"; ! exception->Import_Code = sigargs [1] & 0xfffffff8; } #endif --- 1357,1376 ---- #ifdef IN_RTS /* See if it's an imported exception. Mask off severity bits. */ ! exception = Coded_Exception (sigargs[1] & 0xfffffff8); if (exception) { msgdesc.len = 256; msgdesc.mbz = 0; msgdesc.adr = message; SYS$GETMSG (sigargs[1], &outlen, &msgdesc, msg_flag, 0); ! message[outlen] = 0; msg = message; exception->Name_Length = 19; /* The full name really should be get sys$getmsg returns. ??? */ exception->Full_Name = "IMPORTED_EXCEPTION"; ! exception->Import_Code = sigargs[1] & 0xfffffff8; } #endif *************** __gnat_error_handler (sigargs, mechargs) *** 1440,1446 **** msgdesc.mbz = 0; msgdesc.adr = message; SYS$GETMSG (sigargs[1], &outlen, &msgdesc, msg_flag, 0); ! message [outlen] = 0; msg = message; break; } --- 1438,1444 ---- msgdesc.mbz = 0; msgdesc.adr = message; SYS$GETMSG (sigargs[1], &outlen, &msgdesc, msg_flag, 0); ! message[outlen] = 0; msg = message; break; } *************** __gnat_install_handler () *** 1463,1469 **** long prvhnd; char *c; ! c = (char *) malloc (2049); __gnat_error_prehandler_stack = &c[2048]; --- 1461,1467 ---- long prvhnd; char *c; ! c = (char *) xmalloc (2049); __gnat_error_prehandler_stack = &c[2048]; *************** __gnat_install_handler () *** 1593,1605 **** (void) sigemptyset (&act.sa_mask); (void) sigaction (SIGFPE, &act, NULL); - if (__gl_unreserve_all_interrupts == 0) - { - (void) sigaction (SIGILL, &act, NULL); - (void) sigaction (SIGSEGV, &act, NULL); - (void) sigaction (SIGBUS, &act, NULL); - } __gnat_handler_installed = 1; } --- 1591,1600 ---- (void) sigemptyset (&act.sa_mask); (void) sigaction (SIGFPE, &act, NULL); + (void) sigaction (SIGILL, &act, NULL); + (void) sigaction (SIGSEGV, &act, NULL); + (void) sigaction (SIGBUS, &act, NULL); __gnat_handler_installed = 1; } diff -Nrc3pad gcc-3.2.3/gcc/ada/inline.adb gcc-3.3/gcc/ada/inline.adb *** gcc-3.2.3/gcc/ada/inline.adb 2002-05-04 03:28:16.000000000 +0000 --- gcc-3.3/gcc/ada/inline.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Inline is *** 479,490 **** begin Analyzing_Inlined_Bodies := False; ! if Errors_Detected = 0 then New_Scope (Standard_Standard); J := 0; while J <= Inlined_Bodies.Last ! and then Errors_Detected = 0 loop Pack := Inlined_Bodies.Table (J); --- 478,489 ---- begin Analyzing_Inlined_Bodies := False; ! if Serious_Errors_Detected = 0 then New_Scope (Standard_Standard); J := 0; while J <= Inlined_Bodies.Last ! and then Serious_Errors_Detected = 0 loop Pack := Inlined_Bodies.Table (J); *************** package body Inline is *** 503,511 **** --- 502,515 ---- Comp_Unit := Parent (Comp_Unit); end loop; + -- Load the body, unless it the main unit, or is an instance + -- whose body has already been analyzed. + if Present (Comp_Unit) and then Comp_Unit /= Cunit (Main_Unit) and then Body_Required (Comp_Unit) + and then (Nkind (Unit (Comp_Unit)) /= N_Package_Declaration + or else No (Corresponding_Body (Unit (Comp_Unit)))) then declare Bname : constant Unit_Name_Type := *************** package body Inline is *** 757,763 **** Info : Pending_Body_Info; begin ! if Errors_Detected = 0 then Expander_Active := (Operating_Mode = Opt.Generate_Code); New_Scope (Standard_Standard); --- 761,767 ---- Info : Pending_Body_Info; begin ! if Serious_Errors_Detected = 0 then Expander_Active := (Operating_Mode = Opt.Generate_Code); New_Scope (Standard_Standard); *************** package body Inline is *** 774,780 **** J := 0; while J <= Pending_Instantiations.Last ! and then Errors_Detected = 0 loop Info := Pending_Instantiations.Table (J); --- 778,784 ---- J := 0; while J <= Pending_Instantiations.Last ! and then Serious_Errors_Detected = 0 loop Info := Pending_Instantiations.Table (J); diff -Nrc3pad gcc-3.2.3/gcc/ada/inline.ads gcc-3.3/gcc/ada/inline.ads *** gcc-3.2.3/gcc/ada/inline.ads 2002-05-04 03:28:16.000000000 +0000 --- gcc-3.3/gcc/ada/inline.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/interfac.ads gcc-3.3/gcc/ada/interfac.ads *** gcc-3.2.3/gcc/ada/interfac.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/interfac.ads 2002-03-14 10:59:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/io-aux.c gcc-3.3/gcc/ada/io-aux.c *** gcc-3.2.3/gcc/ada/io-aux.c 2002-05-04 03:28:16.000000000 +0000 --- gcc-3.3/gcc/ada/io-aux.c 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** * * * C Implementation File * * * - * $Revision: 1.2.10.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- *************** *** 34,73 **** #include - #ifdef IN_RTS - #include "tconfig.h" - #else - #include "config.h" - #endif - /* Function wrappers are needed to access the values from Ada which are */ /* defined as C macros. */ ! FILE *c_stdin PARAMS ((void)); ! FILE *c_stdout PARAMS ((void)); ! FILE *c_stderr PARAMS ((void)); ! int seek_set_function PARAMS ((void)); ! int seek_end_function PARAMS ((void)); ! void *null_function PARAMS ((void)); ! int c_fileno PARAMS ((FILE *)); ! ! FILE * ! c_stdin () ! { ! return stdin; ! } ! ! FILE * ! c_stdout () ! { ! return stdout; ! } ! ! FILE * ! c_stderr () ! { ! return stderr; ! } #ifndef SEEK_SET /* Symbolic constants for the "fseek" function: */ #define SEEK_SET 0 /* Set file pointer to offset */ --- 33,44 ---- #include /* Function wrappers are needed to access the values from Ada which are */ /* defined as C macros. */ ! FILE *c_stdin (void) { return stdin; } ! FILE *c_stdout (void) { return stdout;} ! FILE *c_stderr (void) { return stderr;} #ifndef SEEK_SET /* Symbolic constants for the "fseek" function: */ #define SEEK_SET 0 /* Set file pointer to offset */ *************** c_stderr () *** 75,100 **** #define SEEK_END 2 /* Set file pointer to the size of the file plus offset */ #endif ! int ! seek_set_function () ! { ! return SEEK_SET; ! } ! ! int ! seek_end_function () ! { ! return SEEK_END; ! } ! ! void *null_function () ! { ! return NULL; ! } ! int ! c_fileno (s) ! FILE *s; ! { ! return fileno (s); ! } --- 46,53 ---- #define SEEK_END 2 /* Set file pointer to the size of the file plus offset */ #endif ! int seek_set_function (void) { return SEEK_SET; } ! int seek_end_function (void) { return SEEK_END; } ! void *null_function (void) { return NULL; } ! int c_fileno (FILE *s) { return fileno (s); } diff -Nrc3pad gcc-3.2.3/gcc/ada/ioexcept.ads gcc-3.3/gcc/ada/ioexcept.ads *** gcc-3.2.3/gcc/ada/ioexcept.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/ioexcept.ads 2002-03-14 10:59:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-os2err.ads gcc-3.3/gcc/ada/i-os2err.ads *** gcc-3.2.3/gcc/ada/i-os2err.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/i-os2err.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-os2lib.adb gcc-3.3/gcc/ada/i-os2lib.adb *** gcc-3.2.3/gcc/ada/i-os2lib.adb 2002-05-04 03:28:14.000000000 +0000 --- gcc-3.3/gcc/ada/i-os2lib.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1993-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-os2lib.ads gcc-3.3/gcc/ada/i-os2lib.ads *** gcc-3.2.3/gcc/ada/i-os2lib.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/i-os2lib.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1993-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-os2syn.ads gcc-3.3/gcc/ada/i-os2syn.ads *** gcc-3.2.3/gcc/ada/i-os2syn.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/i-os2syn.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1993-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-os2thr.ads gcc-3.3/gcc/ada/i-os2thr.ads *** gcc-3.2.3/gcc/ada/i-os2thr.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/i-os2thr.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1993-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-pacdec.adb gcc-3.3/gcc/ada/i-pacdec.adb *** gcc-3.2.3/gcc/ada/i-pacdec.adb 2002-05-04 03:28:15.000000000 +0000 --- gcc-3.3/gcc/ada/i-pacdec.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 7,13 **** -- B o d y -- -- (Version for IBM Mainframe Packed Decimal Format) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 7,12 ---- *************** package body Interfaces.Packed_Decimal i *** 209,214 **** --- 208,214 ---- -- Cases where all nibbles are used else + V := 0; J := 1; end if; *************** package body Interfaces.Packed_Decimal i *** 294,299 **** --- 294,300 ---- else J := 1; + V := 0; end if; -- Loop to process bytes containing two digit nibbles diff -Nrc3pad gcc-3.2.3/gcc/ada/i-pacdec.ads gcc-3.3/gcc/ada/i-pacdec.ads *** gcc-3.2.3/gcc/ada/i-pacdec.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/i-pacdec.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (Version for IBM Mainframe Packed Decimal Format) -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/itypes.adb gcc-3.3/gcc/ada/itypes.adb *** gcc-3.2.3/gcc/ada/itypes.adb 2002-05-04 03:28:16.000000000 +0000 --- gcc-3.3/gcc/ada/itypes.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/itypes.ads gcc-3.3/gcc/ada/itypes.ads *** gcc-3.2.3/gcc/ada/itypes.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/itypes.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/i-vxwork.ads gcc-3.3/gcc/ada/i-vxwork.ads *** gcc-3.2.3/gcc/ada/i-vxwork.ads 2001-10-02 14:15:37.000000000 +0000 --- gcc-3.3/gcc/ada/i-vxwork.ads 2002-03-14 10:59:28.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1999 - 2001 Ada Core Technologies, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1999 - 2002 Ada Core Technologies, Inc. -- -- -- -- GNARL 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/krunch.adb gcc-3.3/gcc/ada/krunch.adb *** gcc-3.2.3/gcc/ada/krunch.adb 2002-05-04 03:28:16.000000000 +0000 --- gcc-3.3/gcc/ada/krunch.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/krunch.ads gcc-3.3/gcc/ada/krunch.ads *** gcc-3.2.3/gcc/ada/krunch.ads 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/krunch.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/lang-options.h gcc-3.3/gcc/ada/lang-options.h *** gcc-3.2.3/gcc/ada/lang-options.h 2002-05-04 03:28:16.000000000 +0000 --- gcc-3.3/gcc/ada/lang-options.h 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/lang-specs.h gcc-3.3/gcc/ada/lang-specs.h *** gcc-3.2.3/gcc/ada/lang-specs.h 2002-05-04 03:28:16.000000000 +0000 --- gcc-3.3/gcc/ada/lang-specs.h 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.2.10.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/layout.adb gcc-3.3/gcc/ada/layout.adb *** gcc-3.2.3/gcc/ada/layout.adb 2002-05-04 03:28:16.000000000 +0000 --- gcc-3.3/gcc/ada/layout.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.6.10.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** package body Layout is *** 171,176 **** --- 170,181 ---- -- E are set (either from previously given values, or from the newly -- computed values, as appropriate). + procedure Set_Composite_Alignment (E : Entity_Id); + -- This procedure is called for record types and subtypes, and also for + -- atomic array types and subtypes. If no alignment is set, and the size + -- is 2 or 4 (or 8 if the word size is 8), then the alignment is set to + -- match the size. + ---------------------------- -- Adjust_Esize_Alignment -- ---------------------------- *************** package body Layout is *** 930,945 **** Insert_Typ := E; end if; ! -- Cannot do anything if Esize of component type unknown ! if Unknown_Esize (Ctyp) then ! return; ! end if; ! -- Set component size if not set already ! if Unknown_Component_Size (E) then ! Set_Component_Size (E, Esize (Ctyp)); end if; -- (RM 13.3 (48)) says that the size of an unconstrained array --- 935,955 ---- Insert_Typ := E; end if; ! -- Deal with component size if base type ! if Ekind (E) = E_Array_Type then ! -- Cannot do anything if Esize of component type unknown ! if Unknown_Esize (Ctyp) then ! return; ! end if; ! ! -- Set component size if not set already ! ! if Unknown_Component_Size (E) then ! Set_Component_Size (E, Esize (Ctyp)); ! end if; end if; -- (RM 13.3 (48)) says that the size of an unconstrained array *************** package body Layout is *** 2263,2271 **** --- 2273,2302 ---- if Frontend_Layout_On_Target then if Is_Array_Type (E) and then not Is_Bit_Packed_Array (E) then Layout_Array_Type (E); + return; elsif Is_Record_Type (E) then Layout_Record_Type (E); + return; end if; + + -- Special remaining processing for record types with a known size + -- of 16, 32, or 64 bits whose alignment is not yet set. For these + -- types, we set a corresponding alignment matching the size if + -- possible, or as large as possible if not. + + elsif Is_Record_Type (E) and not Debug_Flag_Q then + Set_Composite_Alignment (E); + + -- For arrays, we only do this processing for arrays that are + -- required to be atomic. Here, we really need to have proper + -- alignment, but for the normal case of non-atomic arrays it + -- seems better to use the component alignment as the default. + + elsif Is_Array_Type (E) + and then Is_Atomic (E) + and then not Debug_Flag_Q + then + Set_Composite_Alignment (E); end if; end Layout_Type; *************** package body Layout is *** 2379,2384 **** --- 2410,2467 ---- end if; end Set_And_Check_Static_Size; + ----------------------------- + -- Set_Composite_Alignment -- + ----------------------------- + + procedure Set_Composite_Alignment (E : Entity_Id) is + Siz : Uint; + Align : Nat; + + begin + if Unknown_Alignment (E) then + if Known_Static_Esize (E) then + Siz := Esize (E); + + elsif Unknown_Esize (E) + and then Known_Static_RM_Size (E) + then + Siz := RM_Size (E); + + else + return; + end if; + + -- Size is known, alignment is not set + + if Siz = System_Storage_Unit then + Align := 1; + elsif Siz = 2 * System_Storage_Unit then + Align := 2; + elsif Siz = 4 * System_Storage_Unit then + Align := 4; + elsif Siz = 8 * System_Storage_Unit then + Align := 8; + else + return; + end if; + + if Align > Maximum_Alignment then + Align := Maximum_Alignment; + end if; + + if Align > System_Word_Size / System_Storage_Unit then + Align := System_Word_Size / System_Storage_Unit; + end if; + + Set_Alignment (E, UI_From_Int (Align)); + + if Unknown_Esize (E) then + Set_Esize (E, UI_From_Int (Align * System_Storage_Unit)); + end if; + end if; + end Set_Composite_Alignment; + -------------------------- -- Set_Discrete_RM_Size -- -------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/layout.ads gcc-3.3/gcc/ada/layout.ads *** gcc-3.2.3/gcc/ada/layout.ads 2002-05-04 03:28:16.000000000 +0000 --- gcc-3.3/gcc/ada/layout.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 2000-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/lib.adb gcc-3.3/gcc/ada/lib.adb *** gcc-3.2.3/gcc/ada/lib.adb 2002-05-04 03:28:18.000000000 +0000 --- gcc-3.3/gcc/ada/lib.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Lib is *** 177,183 **** procedure Set_Fatal_Error (U : Unit_Number_Type; B : Boolean := True) is begin ! Units.Table (U).Fatal_Error := True; end Set_Fatal_Error; procedure Set_Generate_Code (U : Unit_Number_Type; B : Boolean := True) is --- 176,182 ---- procedure Set_Fatal_Error (U : Unit_Number_Type; B : Boolean := True) is begin ! Units.Table (U).Fatal_Error := B; end Set_Fatal_Error; procedure Set_Generate_Code (U : Unit_Number_Type; B : Boolean := True) is *************** package body Lib is *** 397,402 **** --- 396,410 ---- end Check_Same_Extended_Unit; + ------------------------------- + -- Compilation_Switches_Last -- + ------------------------------- + + function Compilation_Switches_Last return Nat is + begin + return Compilation_Switches.Last; + end Compilation_Switches_Last; + ------------------------------ -- Earlier_In_Extended_Unit -- ------------------------------ *************** package body Lib is *** 474,480 **** return Main_Unit; end Get_Code_Unit; ! function Get_Code_Unit (N : Node_Id) return Unit_Number_Type is begin return Get_Code_Unit (Sloc (N)); end Get_Code_Unit; --- 482,488 ---- return Main_Unit; end Get_Code_Unit; ! function Get_Code_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type is begin return Get_Code_Unit (Sloc (N)); end Get_Code_Unit; *************** package body Lib is *** 485,491 **** function Get_Compilation_Switch (N : Pos) return String_Ptr is begin ! if N >= Compilation_Switches.Last then return Compilation_Switches.Table (N); else --- 493,499 ---- function Get_Compilation_Switch (N : Pos) return String_Ptr is begin ! if N <= Compilation_Switches.Last then return Compilation_Switches.Table (N); else *************** package body Lib is *** 558,564 **** return Main_Unit; end Get_Source_Unit; ! function Get_Source_Unit (N : Node_Id) return Unit_Number_Type is begin return Get_Source_Unit (Sloc (N)); end Get_Source_Unit; --- 566,572 ---- return Main_Unit; end Get_Source_Unit; ! function Get_Source_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type is begin return Get_Source_Unit (Sloc (N)); end Get_Source_Unit; *************** package body Lib is *** 567,573 **** -- In_Extended_Main_Code_Unit -- -------------------------------- ! function In_Extended_Main_Code_Unit (N : Node_Id) return Boolean is begin if Sloc (N) = Standard_Location then return True; --- 575,584 ---- -- In_Extended_Main_Code_Unit -- -------------------------------- ! function In_Extended_Main_Code_Unit ! (N : Node_Or_Entity_Id) ! return Boolean ! is begin if Sloc (N) = Standard_Location then return True; *************** package body Lib is *** 599,605 **** -- In_Extended_Main_Source_Unit -- ---------------------------------- ! function In_Extended_Main_Source_Unit (N : Node_Id) return Boolean is begin if Sloc (N) = Standard_Location then return True; --- 610,619 ---- -- In_Extended_Main_Source_Unit -- ---------------------------------- ! function In_Extended_Main_Source_Unit ! (N : Node_Or_Entity_Id) ! return Boolean ! is begin if Sloc (N) = Standard_Location then return True; *************** package body Lib is *** 767,776 **** begin if Match_String'Length > 0 then for J in 1 .. Linker_Option_Lines.Last loop ! String_To_Name_Buffer (Linker_Option_Lines.Table (J)); if Match_String = Name_Buffer (1 .. Match_String'Length) then ! Linker_Option_Lines.Table (J) := S; return; end if; end loop; --- 781,790 ---- begin if Match_String'Length > 0 then for J in 1 .. Linker_Option_Lines.Last loop ! String_To_Name_Buffer (Linker_Option_Lines.Table (J).Option); if Match_String = Name_Buffer (1 .. Match_String'Length) then ! Linker_Option_Lines.Table (J).Option := S; return; end if; end loop; *************** package body Lib is *** 803,809 **** procedure Store_Linker_Option_String (S : String_Id) is begin Linker_Option_Lines.Increment_Last; ! Linker_Option_Lines.Table (Linker_Option_Lines.Last) := S; end Store_Linker_Option_String; --------------- --- 817,824 ---- procedure Store_Linker_Option_String (S : String_Id) is begin Linker_Option_Lines.Increment_Last; ! Linker_Option_Lines.Table (Linker_Option_Lines.Last) := ! (Option => S, Unit => Current_Sem_Unit); end Store_Linker_Option_String; --------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/lib.ads gcc-3.3/gcc/ada/lib.ads *** gcc-3.2.3/gcc/ada/lib.ads 2002-05-04 03:28:18.000000000 +0000 --- gcc-3.3/gcc/ada/lib.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Lib is *** 425,431 **** -- within generic instantiations return True if the instantiation is -- itself "in the main unit" by this definition. Otherwise False. ! function Get_Source_Unit (N : Node_Id) return Unit_Number_Type; pragma Inline (Get_Source_Unit); function Get_Source_Unit (S : Source_Ptr) return Unit_Number_Type; -- Return unit number of file identified by given source pointer value. --- 424,430 ---- -- within generic instantiations return True if the instantiation is -- itself "in the main unit" by this definition. Otherwise False. ! function Get_Source_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type; pragma Inline (Get_Source_Unit); function Get_Source_Unit (S : Source_Ptr) return Unit_Number_Type; -- Return unit number of file identified by given source pointer value. *************** package Lib is *** 436,442 **** -- corresponding to the given Source_Ptr value. The version taking -- a Node_Id argument, N, simply applies the function to Sloc (N). ! function Get_Code_Unit (N : Node_Id) return Unit_Number_Type; pragma Inline (Get_Code_Unit); function Get_Code_Unit (S : Source_Ptr) return Unit_Number_Type; -- This is like Get_Source_Unit, except that in the instantiation case, --- 435,441 ---- -- corresponding to the given Source_Ptr value. The version taking -- a Node_Id argument, N, simply applies the function to Sloc (N). ! function Get_Code_Unit (N : Node_Or_Entity_Id) return Unit_Number_Type; pragma Inline (Get_Code_Unit); function Get_Code_Unit (S : Source_Ptr) return Unit_Number_Type; -- This is like Get_Source_Unit, except that in the instantiation case, *************** package Lib is *** 463,469 **** -- included). Returns true if S1 and S2 are in the same extended unit -- and False otherwise. ! function In_Extended_Main_Code_Unit (N : Node_Id) return Boolean; -- Return True if the node is in the generated code of the extended main -- unit, defined as the main unit, its specification (if any), and all -- its subunits (considered recursively). Units for which this enquiry --- 462,470 ---- -- included). Returns true if S1 and S2 are in the same extended unit -- and False otherwise. ! function In_Extended_Main_Code_Unit ! (N : Node_Or_Entity_Id) ! return Boolean; -- Return True if the node is in the generated code of the extended main -- unit, defined as the main unit, its specification (if any), and all -- its subunits (considered recursively). Units for which this enquiry *************** package Lib is *** 472,478 **** -- If the main unit is itself a subunit, then the extended main unit -- includes its parent unit, and the parent unit spec if it is separate. ! function In_Extended_Main_Source_Unit (N : Node_Id) return Boolean; -- Return True if the node is in the source text of the extended main -- unit, defined as the main unit, its specification (if any), and all -- its subunits (considered recursively). Units for which this enquiry --- 473,481 ---- -- If the main unit is itself a subunit, then the extended main unit -- includes its parent unit, and the parent unit spec if it is separate. ! function In_Extended_Main_Source_Unit ! (N : Node_Or_Entity_Id) ! return Boolean; -- Return True if the node is in the source text of the extended main -- unit, defined as the main unit, its specification (if any), and all -- its subunits (considered recursively). Units for which this enquiry *************** package Lib is *** 488,496 **** -- S2, and False otherwise. The result is undefined if S1 and S2 are -- not in the same extended unit. function Get_Compilation_Switch (N : Pos) return String_Ptr; -- Return the Nth stored compilation switch, or null if less than N ! -- switches have been stored. Used by ASIS. function Get_Cunit_Unit_Number (N : Node_Id) return Unit_Number_Type; -- Return unit number of the unit whose N_Compilation_Unit node is the --- 491,502 ---- -- S2, and False otherwise. The result is undefined if S1 and S2 are -- not in the same extended unit. + function Compilation_Switches_Last return Nat; + -- Return the count of stored compilation switches + function Get_Compilation_Switch (N : Pos) return String_Ptr; -- Return the Nth stored compilation switch, or null if less than N ! -- switches have been stored. Used by ASIS and back ends written in Ada. function Get_Cunit_Unit_Number (N : Node_Id) return Unit_Number_Type; -- Return unit number of the unit whose N_Compilation_Unit node is the *************** private *** 600,606 **** Expected_Unit : Unit_Name_Type; Source_Index : Source_File_Index; Cunit : Node_Id; ! Cunit_Entity : Node_Id; Dependency_Num : Int; Dependent_Unit : Boolean; Fatal_Error : Boolean; --- 606,612 ---- Expected_Unit : Unit_Name_Type; Source_Index : Source_File_Index; Cunit : Node_Id; ! Cunit_Entity : Entity_Id; Dependency_Num : Int; Dependent_Unit : Boolean; Fatal_Error : Boolean; *************** private *** 625,632 **** -- The following table stores strings from pragma Linker_Option lines package Linker_Option_Lines is new Table.Table ( ! Table_Component_Type => String_Id, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => Alloc.Linker_Option_Lines_Initial, --- 631,646 ---- -- The following table stores strings from pragma Linker_Option lines + type Linker_Option_Entry is record + Option : String_Id; + -- The string for the linker option line + + Unit : Unit_Number_Type; + -- The unit from which the linker option comes + end record; + package Linker_Option_Lines is new Table.Table ( ! Table_Component_Type => Linker_Option_Entry, Table_Index_Type => Integer, Table_Low_Bound => 1, Table_Initial => Alloc.Linker_Option_Lines_Initial, diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-list.adb gcc-3.3/gcc/ada/lib-list.adb *** gcc-3.2.3/gcc/ada/lib-list.adb 2002-05-04 03:28:17.000000000 +0000 --- gcc-3.3/gcc/ada/lib-list.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-load.adb gcc-3.3/gcc/ada/lib-load.adb *** gcc-3.2.3/gcc/ada/lib-load.adb 2002-05-04 03:28:17.000000000 +0000 --- gcc-3.3/gcc/ada/lib-load.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Nlists; use Nlists; *** 36,47 **** --- 35,48 ---- with Nmake; use Nmake; with Opt; use Opt; with Osint; use Osint; + with Osint.C; use Osint.C; with Output; use Output; with Par; with Scn; use Scn; with Sinfo; use Sinfo; with Sinput; use Sinput; with Sinput.L; use Sinput.L; + with Targparm; use Targparm; with Tbuild; use Tbuild; with Uname; use Uname; *************** package body Lib.Load is *** 241,249 **** --- 242,266 ---- -- to inline stuff from it. If this is not the case, an error -- message will be issued in Rtsfind in any case. + ------------------------------ + -- Set_Load_Unit_Dependency -- + ------------------------------ + procedure Set_Load_Unit_Dependency (U : Unit_Number_Type) is begin + -- Differentiate between pragma No_Run_Time (that can be used + -- with a standard installation), and HI-E mode which comes + -- with a special installation. + -- + -- For No_Run_Time mode, we do not want to create a dependency + -- since the binder would generate references to these units. + -- In the case of HI-E, a special run time is provided that do + -- not have any elaboration, so it is safe (and useful) to add + -- the dependency. In particular, this allows the user to + -- recompile run time units, e.g GNAT.IO. + if No_Run_Time + and then not High_Integrity_Mode_On_Target and then Is_Internal_File_Name (Unit_File_Name (U)) then null; diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-load.ads gcc-3.3/gcc/ada/lib-load.ads *** gcc-3.2.3/gcc/ada/lib-load.ads 2002-05-04 03:28:17.000000000 +0000 --- gcc-3.3/gcc/ada/lib-load.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-sort.adb gcc-3.3/gcc/ada/lib-sort.adb *** gcc-3.2.3/gcc/ada/lib-sort.adb 2002-05-07 08:22:19.000000000 +0000 --- gcc-3.3/gcc/ada/lib-sort.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-util.adb gcc-3.3/gcc/ada/lib-util.adb *** gcc-3.2.3/gcc/ada/lib-util.adb 2002-05-04 03:28:17.000000000 +0000 --- gcc-3.3/gcc/ada/lib-util.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 28,34 **** with Hostparm; with Namet; use Namet; ! with Osint; use Osint; package body Lib.Util is --- 27,33 ---- with Hostparm; with Namet; use Namet; ! with Osint.C; use Osint.C; package body Lib.Util is diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-util.ads gcc-3.3/gcc/ada/lib-util.ads *** gcc-3.2.3/gcc/ada/lib-util.ads 2002-05-04 03:28:17.000000000 +0000 --- gcc-3.3/gcc/ada/lib-util.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-writ.adb gcc-3.3/gcc/ada/lib-writ.adb *** gcc-3.2.3/gcc/ada/lib-writ.adb 2002-05-04 03:28:17.000000000 +0000 --- gcc-3.3/gcc/ada/lib-writ.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Nlists; use Nlists; *** 40,52 **** with Gnatvsn; use Gnatvsn; with Opt; use Opt; with Osint; use Osint; with Par; with Restrict; use Restrict; with Scn; use Scn; with Sinfo; use Sinfo; with Sinput; use Sinput; with Stringt; use Stringt; - with Targparm; use Targparm; with Uname; use Uname; with System.WCh_Con; use System.WCh_Con; --- 39,51 ---- with Gnatvsn; use Gnatvsn; with Opt; use Opt; with Osint; use Osint; + with Osint.C; use Osint.C; with Par; with Restrict; use Restrict; with Scn; use Scn; with Sinfo; use Sinfo; with Sinput; use Sinput; with Stringt; use Stringt; with Uname; use Uname; with System.WCh_Con; use System.WCh_Con; *************** package body Lib.Writ is *** 483,488 **** --- 482,532 ---- end if; Write_With_Lines; + + -- Output linker option lines + + for J in 1 .. Linker_Option_Lines.Last loop + declare + S : constant Linker_Option_Entry := + Linker_Option_Lines.Table (J); + C : Character; + + begin + if S.Unit = Unit_Num then + Write_Info_Initiate ('L'); + Write_Info_Str (" """); + + for J in 1 .. String_Length (S.Option) loop + C := Get_Character (Get_String_Char (S.Option, J)); + + if C in Character'Val (16#20#) .. Character'Val (16#7E#) + and then C /= '{' + then + Write_Info_Char (C); + + if C = '"' then + Write_Info_Char (C); + end if; + + else + declare + Hex : array (0 .. 15) of Character := + "0123456789ABCDEF"; + + begin + Write_Info_Char ('{'); + Write_Info_Char (Hex (Character'Pos (C) / 16)); + Write_Info_Char (Hex (Character'Pos (C) mod 16)); + Write_Info_Char ('}'); + end; + end if; + end loop; + + Write_Info_Char ('"'); + Write_Info_EOL; + end if; + end; + end loop; end Write_Unit_Information; ---------------------- *************** package body Lib.Writ is *** 773,779 **** Write_Info_Str (" UA"); end if; ! if ZCX_By_Default_On_Target then if Unit_Exception_Table_Present then Write_Info_Str (" UX"); end if; --- 817,823 ---- Write_Info_Str (" UA"); end if; ! if Exception_Mechanism /= Setjmp_Longjmp then if Unit_Exception_Table_Present then Write_Info_Str (" UX"); end if; *************** package body Lib.Writ is *** 788,794 **** Write_Info_Initiate ('R'); Write_Info_Char (' '); ! for J in Partition_Restrictions loop if Main_Restrictions (J) then Write_Info_Char ('r'); elsif Violations (J) then --- 832,838 ---- Write_Info_Initiate ('R'); Write_Info_Char (' '); ! for J in All_Restrictions loop if Main_Restrictions (J) then Write_Info_Char ('r'); elsif Violations (J) then *************** package body Lib.Writ is *** 814,860 **** Write_Info_EOL; -- blank line - -- Output linker option lines - - for J in 1 .. Linker_Option_Lines.Last loop - declare - S : constant String_Id := Linker_Option_Lines.Table (J); - C : Character; - - begin - Write_Info_Initiate ('L'); - Write_Info_Str (" """); - - for J in 1 .. String_Length (S) loop - C := Get_Character (Get_String_Char (S, J)); - - if C in Character'Val (16#20#) .. Character'Val (16#7E#) - and then C /= '{' - then - Write_Info_Char (C); - - if C = '"' then - Write_Info_Char (C); - end if; - - else - declare - Hex : array (0 .. 15) of Character := "0123456789ABCDEF"; - - begin - Write_Info_Char ('{'); - Write_Info_Char (Hex (Character'Pos (C) / 16)); - Write_Info_Char (Hex (Character'Pos (C) mod 16)); - Write_Info_Char ('}'); - end; - end if; - end loop; - - Write_Info_Char ('"'); - Write_Info_EOL; - end; - end loop; - -- Output external version reference lines for J in 1 .. Version_Ref.Last loop --- 858,863 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-writ.ads gcc-3.3/gcc/ada/lib-writ.ads *** gcc-3.2.3/gcc/ada/lib-writ.ads 2002-05-04 03:28:17.000000000 +0000 --- gcc-3.3/gcc/ada/lib-writ.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Lib.Writ is *** 203,210 **** -- This line records information regarding restrictions. The -- parameter is a string of characters, one for each entry in ! -- Restrict.Partition_Restrictions, in order. There are three ! -- settings possible settings for each restriction: -- r Restricted. Unit was compiled under control of a pragma -- Restrictions for the corresponding restriction. In --- 202,209 ---- -- This line records information regarding restrictions. The -- parameter is a string of characters, one for each entry in ! -- Restrict.Compilation_Unit_Restrictions, in order. There are ! -- three settings possible settings for each restriction: -- r Restricted. Unit was compiled under control of a pragma -- Restrictions for the corresponding restriction. In *************** package Lib.Writ is *** 216,222 **** -- pragma Restrictions for the corresponding restriction, -- and does not make any use of the referenced feature. ! -- v Violated. The unit was not compiled uner control of a -- pragma Restrictions for the corresponding restriction, -- and it does indeed use the referenced feature. --- 215,221 ---- -- pragma Restrictions for the corresponding restriction, -- and does not make any use of the referenced feature. ! -- v Violated. The unit was not compiled under control of a -- pragma Restrictions for the corresponding restriction, -- and it does indeed use the referenced feature. *************** package Lib.Writ is *** 344,366 **** -- of a generic unit compiled with earlier versions of GNAT which -- did not generate object or ali files for generics. - --------------------- - -- Reference Lines -- - --------------------- - - -- The reference lines contain information about references from - -- any of the units in the compilation (including, body version - -- and version attributes, linker options pragmas and source - -- dependencies. - -- ----------------------- -- -- L Linker_Options -- -- ----------------------- ! -- Following the unit information is an optional series of lines that ! -- indicates the usage of pragma Linker_Options. For each appearence ! -- of pragma Linker_Actions in any of the units for which unit lines ! -- are present, a line of the form: -- L "string" --- 343,357 ---- -- of a generic unit compiled with earlier versions of GNAT which -- did not generate object or ali files for generics. -- ----------------------- -- -- L Linker_Options -- -- ----------------------- ! -- Following the W lines (if any, or the U line if not), are an ! -- optional series of lines that indicates the usage of the pragma ! -- Linker_Options in the associated unit. For each appearence of a ! -- pragma Linker_Options (or Link_With) in the unit, a line is ! -- present with the form: -- L "string" *************** package Lib.Writ is *** 378,383 **** --- 369,388 ---- -- that wide characters in the form {hhhh} cannot be produced, since -- pragma Linker_Option accepts only String, not Wide_String. + -- The L lines are required to appear in the same order as the + -- corresponding Linker_Options (or Link_With) pragmas appear in + -- the source file, so that this order is preserved by the binder + -- in constructing the set of linker arguments. + + --------------------- + -- Reference Lines -- + --------------------- + + -- The reference lines contain information about references from + -- any of the units in the compilation (including, body version + -- and version attributes, linker options pragmas and source + -- dependencies. + -- ------------------------------------ -- -- E External Version References -- -- ------------------------------------ diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-xref.adb gcc-3.3/gcc/ada/lib-xref.adb *** gcc-3.2.3/gcc/ada/lib-xref.adb 2002-05-04 03:28:18.000000000 +0000 --- gcc-3.3/gcc/ada/lib-xref.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.6.10.1 $ -- -- ! -- Copyright (C) 1998-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2002, 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- -- *************** *** 28,39 **** with Atree; use Atree; with Csets; use Csets; ! with Debug; use Debug; with Lib.Util; use Lib.Util; with Namet; use Namet; with Opt; use Opt; with Sinfo; use Sinfo; with Sinput; use Sinput; with Table; use Table; with Widechar; use Widechar; --- 27,39 ---- with Atree; use Atree; with Csets; use Csets; ! with Errout; use Errout; with Lib.Util; use Lib.Util; with Namet; use Namet; with Opt; use Opt; with Sinfo; use Sinfo; with Sinput; use Sinput; + with Stand; use Stand; with Table; use Table; with Widechar; use Widechar; *************** package body Lib.Xref is *** 79,85 **** package Xrefs is new Table.Table ( Table_Component_Type => Xref_Entry, ! Table_Index_Type => Int, Table_Low_Bound => 1, Table_Initial => Alloc.Xrefs_Initial, Table_Increment => Alloc.Xrefs_Increment, --- 79,85 ---- package Xrefs is new Table.Table ( Table_Component_Type => Xref_Entry, ! Table_Index_Type => Xref_Entry_Number, Table_Low_Bound => 1, Table_Initial => Alloc.Xrefs_Initial, Table_Increment => Alloc.Xrefs_Increment, *************** package body Lib.Xref is *** 201,213 **** --- 201,222 ---- -- we omit this test if Typ is 'e', since these entries are -- really structural, and it is useful to have them in units -- that reference packages as well as units that define packages. + -- We also omit the test for the case of 'p' since we want to + -- include inherited primitive operations from other packages. if not In_Extended_Main_Source_Unit (N) and then Typ /= 'e' + and then Typ /= 'p' then return; end if; + -- For reference type p, then entity must be in main source unit + + if Typ = 'p' and then not In_Extended_Main_Source_Unit (E) then + return; + end if; + -- Unless the reference is forced, we ignore references where -- the reference itself does not come from Source. *************** package body Lib.Xref is *** 227,232 **** --- 236,261 ---- if Set_Ref then Set_Referenced (E); + -- Check for pragma unreferenced given + + if Has_Pragma_Unreferenced (E) then + + -- A reference as a named parameter in a call does not count + -- as a violation of pragma Unreferenced for this purpose. + + if Nkind (N) = N_Identifier + and then Nkind (Parent (N)) = N_Parameter_Association + and then Selector_Name (Parent (N)) = N + then + null; + + -- Here we issue the warning, since this is a real reference + + else + Error_Msg_NE ("?pragma Unreferenced given for&", N, E); + end if; + end if; + -- If this is a subprogram instance, mark as well the internal -- subprogram in the wrapper package, which may be a visible -- compilation unit. *************** package body Lib.Xref is *** 523,534 **** return; end if; - -- For now, nothing to do unless special debug flag set - - if not Debug_Flag_MM then - return; - end if; - -- Output instantiation reference Write_Info_Char ('['); --- 552,557 ---- *************** package body Lib.Xref is *** 768,774 **** -- Write out renaming reference if we have one ! if Debug_Flag_MM and then Present (Rref) then Write_Info_Char ('='); Write_Info_Nat (Int (Get_Logical_Line_Number (Sloc (Rref)))); --- 791,797 ---- -- Write out renaming reference if we have one ! if Present (Rref) then Write_Info_Char ('='); Write_Info_Nat (Int (Get_Logical_Line_Number (Sloc (Rref)))); *************** package body Lib.Xref is *** 850,869 **** end if; -- Exit if no type reference, or we are stuck in ! -- some loop trying to find the type reference. ! exit when No (Tref) or else Tref = Sav; -- Here we have a type reference to output -- Case of standard entity, output name if Sloc (Tref) = Standard_Location then - - -- For now, output only if special -gnatdM flag set - - exit when not Debug_Flag_MM; - Write_Info_Char (Left); Write_Info_Name (Chars (Tref)); Write_Info_Char (Right); --- 873,892 ---- end if; -- Exit if no type reference, or we are stuck in ! -- some loop trying to find the type reference, or ! -- if the type is standard void type (the latter is ! -- an implementation artifact that should not show ! -- up in the generated cross-references). ! exit when No (Tref) ! or else Tref = Sav ! or else Tref = Standard_Void_Type; -- Here we have a type reference to output -- Case of standard entity, output name if Sloc (Tref) = Standard_Location then Write_Info_Char (Left); Write_Info_Name (Chars (Tref)); Write_Info_Char (Right); *************** package body Lib.Xref is *** 873,883 **** elsif Comes_From_Source (Tref) then - -- For now, output only derived type entries - -- unless we have special debug flag -gnatdM - - exit when not (Debug_Flag_MM or else Left = '<'); - -- Do not output type reference if referenced -- entity is not in the main unit and is itself -- not referenced, since otherwise the reference --- 896,901 ---- *************** package body Lib.Xref is *** 898,905 **** Write_Info_Nat (Int (Get_Logical_Line_Number (Sloc (Tref)))); ! Write_Info_Char ! (Xref_Entity_Letters (Ekind (Tref))); Write_Info_Nat (Int (Get_Column_Number (Sloc (Tref)))); Write_Info_Char (Right); --- 916,941 ---- Write_Info_Nat (Int (Get_Logical_Line_Number (Sloc (Tref)))); ! ! declare ! Ent : Entity_Id := Tref; ! Kind : constant Entity_Kind := Ekind (Ent); ! Ctyp : Character := Xref_Entity_Letters (Kind); ! ! begin ! if Ctyp = '+' ! and then Present (Full_View (Ent)) ! then ! Ent := Underlying_Type (Ent); ! ! if Present (Ent) then ! Ctyp := Xref_Entity_Letters (Ekind (Ent)); ! end if; ! end if; ! ! Write_Info_Char (Ctyp); ! end; ! Write_Info_Nat (Int (Get_Column_Number (Sloc (Tref)))); Write_Info_Char (Right); diff -Nrc3pad gcc-3.2.3/gcc/ada/lib-xref.ads gcc-3.3/gcc/ada/lib-xref.ads *** gcc-3.2.3/gcc/ada/lib-xref.ads 2002-05-04 03:28:18.000000000 +0000 --- gcc-3.3/gcc/ada/lib-xref.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1998-2001, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2002, 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- -- *************** package Lib.Xref is *** 40,76 **** -- Cross-reference sections follow the dependency section (D lines) in -- an ALI file, so that they need not be read by gnatbind, gnatmake etc. ! -- -- A cross reference section has a header of the form ! -- -- X dependency-number filename ! -- -- This header precedes xref information (entities/references from -- the unit, identified by dependency number and file name. The -- dependency number is the index into the generated D lines and -- is ones origin (i.e. 2 = reference to second generated D line). ! -- -- Note that the filename here will reflect the original name if -- a Source_Reference pragma was encountered (since all line number -- references will be with respect to the original file). ! -- -- The lines following the header look like ! -- -- line type col level entity renameref typeref ref ref ref ! -- ! -- line is the line number of the referenced entity. It starts ! -- in column one. ! -- -- type is a single letter identifying the type of the entity. -- See next section (Cross-Reference Entity Identifiers) for a -- full list of the characters used). ! -- -- col is the column number of the referenced entity ! -- -- level is a single character that separates the col and -- entity fields. It is an asterisk for a top level library -- entity that is publicly visible, and space otherwise. ! -- -- entity is the name of the referenced entity, with casing in -- the canical casing for the source file where it is defined. --- 39,79 ---- -- Cross-reference sections follow the dependency section (D lines) in -- an ALI file, so that they need not be read by gnatbind, gnatmake etc. ! -- A cross reference section has a header of the form ! -- X dependency-number filename ! -- This header precedes xref information (entities/references from -- the unit, identified by dependency number and file name. The -- dependency number is the index into the generated D lines and -- is ones origin (i.e. 2 = reference to second generated D line). ! -- Note that the filename here will reflect the original name if -- a Source_Reference pragma was encountered (since all line number -- references will be with respect to the original file). ! -- The lines following the header look like ! -- line type col level entity renameref typeref ref ref ref ! ! -- line is the line number of the referenced entity. The name of ! -- the entity starts in column col. Columns are numbered from one, ! -- and if horizontal tab characters are present, the column number ! -- is computed assuming standard 1,9,17,.. tab stops. For example, ! -- if the entity is the first token on the line, and is preceded ! -- by space-HT-space, then the column would be column 10. ! -- type is a single letter identifying the type of the entity. -- See next section (Cross-Reference Entity Identifiers) for a -- full list of the characters used). ! -- col is the column number of the referenced entity ! -- level is a single character that separates the col and -- entity fields. It is an asterisk for a top level library -- entity that is publicly visible, and space otherwise. ! -- entity is the name of the referenced entity, with casing in -- the canical casing for the source file where it is defined. *************** package Lib.Xref is *** 79,110 **** -- a renaming declaration, and the renaming refers to an entity -- with a simple identifier or expanded name, then renameref has -- the form: ! -- -- =line:col ! -- -- Here line:col give the reference to the identifier that -- appears in the renaming declaration. Note that we never need -- a file entry, since this identifier is always in the current -- file in which the entity is declared. Currently, renameref -- appears only for the simple renaming case. If the renaming -- reference is a complex expressions, then renameref is omitted. ! -- -- typeref is the reference for a related type. This part is -- optional. It is present for the following cases: ! -- -- derived types (points to the parent type) LR=<> -- access types (points to designated type) LR=() -- subtypes (points to ancestor type) LR={} -- functions (points to result type) LR={} -- enumeration literals (points to enum type) LR={} -- objects and components (points to type) LR={} ! -- -- In the above list LR shows the brackets used in the output, -- which has one of the two following forms: ! -- -- L file | line type col R user entity -- L name-in-lower-case R standard entity ! -- -- For the form for a user entity, file is the dependency number -- of the file containing the declaration of the related type. -- This number and the following vertical bar are omitted if the --- 82,114 ---- -- a renaming declaration, and the renaming refers to an entity -- with a simple identifier or expanded name, then renameref has -- the form: ! -- =line:col ! -- Here line:col give the reference to the identifier that -- appears in the renaming declaration. Note that we never need -- a file entry, since this identifier is always in the current -- file in which the entity is declared. Currently, renameref -- appears only for the simple renaming case. If the renaming -- reference is a complex expressions, then renameref is omitted. ! -- Here line/col give line/column as defined above. ! -- typeref is the reference for a related type. This part is -- optional. It is present for the following cases: ! -- derived types (points to the parent type) LR=<> -- access types (points to designated type) LR=() -- subtypes (points to ancestor type) LR={} -- functions (points to result type) LR={} -- enumeration literals (points to enum type) LR={} -- objects and components (points to type) LR={} ! -- In the above list LR shows the brackets used in the output, -- which has one of the two following forms: ! -- L file | line type col R user entity -- L name-in-lower-case R standard entity ! -- For the form for a user entity, file is the dependency number -- of the file containing the declaration of the related type. -- This number and the following vertical bar are omitted if the *************** package Lib.Xref is *** 113,138 **** -- specify the location of the relevant type declaration in the -- referenced file. For the standard entity form, the name between -- the brackets is the normal name of the entity in lower case. ! -- -- There may be zero or more ref entries on each line ! -- -- file | line type col [...] ! -- -- file is the dependency number of the file with the reference. -- It and the following vertical bar are omitted if the file is -- the same as the previous ref, and the refs for the current -- file are first (and do not need a bar). ! -- -- type is one of - -- r = reference - -- m = modification -- b = body entity -- c = completion of private or incomplete type - -- x = type extension - -- i = implicit reference -- e = end of spec -- t = end of body ! -- -- b is used for spec entities that are repeated in a body, -- including the unit (subprogram, package, task, protected -- body, protected entry) name itself, and in the case of a --- 117,148 ---- -- specify the location of the relevant type declaration in the -- referenced file. For the standard entity form, the name between -- the brackets is the normal name of the entity in lower case. ! -- There may be zero or more ref entries on each line ! -- file | line type col [...] ! -- file is the dependency number of the file with the reference. -- It and the following vertical bar are omitted if the file is -- the same as the previous ref, and the refs for the current -- file are first (and do not need a bar). ! ! -- line is the line number of the reference ! ! -- col is the column number of the reference, as defined above. ! -- type is one of -- b = body entity -- c = completion of private or incomplete type -- e = end of spec + -- i = implicit reference + -- l = label on end line + -- m = modification + -- p = primitive operation + -- r = reference -- t = end of body ! -- x = type extension ! -- b is used for spec entities that are repeated in a body, -- including the unit (subprogram, package, task, protected -- body, protected entry) name itself, and in the case of a *************** package Lib.Xref is *** 141,193 **** -- are not considered to be definitions for cross-referencing -- purposes, but rather are considered to be references to the -- corresponding spec entities, marked with this special type. ! -- ! -- c is similarly used to mark the completion of a private or ! -- incomplete type. Again, the completion is not regarded as ! -- a separate definition, but rather a reference to the initial ! -- declaration, marked with this special type. ! -- ! -- x is used to identify the reference as the entity from which ! -- a tagged type is extended. This allows immediate access to ! -- the parent of a tagged type. ! -- ! -- i is used to identify a reference to the entity in a generic ! -- actual or in a default in a call. The node that denotes the ! -- entity does not come from source, but it has the Sloc of the ! -- source node that generates the implicit reference, and it is ! -- useful to record this one. ! -- -- e is used to identify the end of a construct in the following -- cases: ! -- -- Block Statement end [block_IDENTIFIER]; -- Loop Statement end loop [loop_IDENTIFIER]; -- Package Specification end [[PARENT_UNIT_NAME .] IDENTIFIER]; -- Task Definition end [task_IDENTIFIER]; -- Protected Definition end [protected_IDENTIFIER]; -- Record Definition end record; ! -- ! -- Note that 'e' entries are special in that you get they appear ! -- even in referencing units (normally xref entries appear only -- for references in the extended main source unit (see Lib) to -- which the ali applies. But 'e' entries are really structural -- and simply indicate where packages end. This information can -- be used to reconstruct scope information for any entities ! -- referenced from within the package. ! -- ! -- t is similarly used to identify the end of a corresponding -- body (such a reference always links up with a b reference) ! -- -- Subprogram Body end [DESIGNATOR]; -- Package Body end [[PARENT_UNIT_NAME .] IDENTIFIER]; -- Task Body end [task_IDENTIFIER]; -- Entry Body end [entry_IDENTIFIER]; -- Protected Body end [protected_IDENTIFIER] -- Accept Statement end [entry_IDENTIFIER]]; ! -- -- Note that in the case of accept statements, there can ! -- be multiple b and T/t entries for the same entity. ! -- -- [..] is used for generic instantiation references. These -- references are present only if the entity in question is -- a generic entity, and in that case the [..] contains the --- 151,222 ---- -- are not considered to be definitions for cross-referencing -- purposes, but rather are considered to be references to the -- corresponding spec entities, marked with this special type. ! ! -- c is similar to b but is used to mark the completion of a ! -- private or incomplete type. As with b, the completion is not ! -- regarded as a separate definition, but rather a reference to ! -- the initial declaration, marked with this special type. ! -- e is used to identify the end of a construct in the following -- cases: ! -- Block Statement end [block_IDENTIFIER]; -- Loop Statement end loop [loop_IDENTIFIER]; -- Package Specification end [[PARENT_UNIT_NAME .] IDENTIFIER]; -- Task Definition end [task_IDENTIFIER]; -- Protected Definition end [protected_IDENTIFIER]; -- Record Definition end record; ! -- Enumeration Definition ); ! ! -- Note that 'e' entries are special in that they appear even ! -- in referencing units (normally xref entries appear only -- for references in the extended main source unit (see Lib) to -- which the ali applies. But 'e' entries are really structural -- and simply indicate where packages end. This information can -- be used to reconstruct scope information for any entities ! -- referenced from within the package. The line/column values ! -- for these entries point to the semicolon ending the construct. ! ! -- i is used to identify a reference to the entity in a generic ! -- actual or in a default in a call. The node that denotes the ! -- entity does not come from source, but it has the Sloc of the ! -- source node that generates the implicit reference, and it is ! -- useful to record this one. ! ! -- l is used to identify the occurrence in the source of the ! -- name on an end line. This is just a syntactic reference ! -- which can be ignored for semantic purposes (such as call ! -- graph construction). Again, in the case of an accept there ! -- can be multiple l lines. ! ! -- p is used to mark a primitive operation of the given entity. ! -- For example, if we have a type Tx, and a primitive operation ! -- Pq of this type, then an entry in the list of references to ! -- Tx will point to the declaration of Pq. Note that this entry ! -- type is unusual because it an implicit rather than explicit, ! -- and the name of the refrerence does not match the name of the ! -- entity for which a reference is generated. These entries are ! -- generated only for entities declared in the extended main ! -- source unit (main unit itself, its separate spec (if any). ! -- and all subunits (considered recursively). ! ! -- t is similar to e. It identifies the end of a corresponding -- body (such a reference always links up with a b reference) ! -- Subprogram Body end [DESIGNATOR]; -- Package Body end [[PARENT_UNIT_NAME .] IDENTIFIER]; -- Task Body end [task_IDENTIFIER]; -- Entry Body end [entry_IDENTIFIER]; -- Protected Body end [protected_IDENTIFIER] -- Accept Statement end [entry_IDENTIFIER]]; ! -- Note that in the case of accept statements, there can ! -- be multiple b and t entries for the same entity. ! ! -- x is used to identify the reference as the entity from which ! -- a tagged type is extended. This allows immediate access to ! -- the parent of a tagged type. ! -- [..] is used for generic instantiation references. These -- references are present only if the entity in question is -- a generic entity, and in that case the [..] contains the *************** package Lib.Xref is *** 199,256 **** -- of file numbers in such references follows the normal -- rules (present only if needed, and resets the current -- file for subsequent references). ! -- -- Examples: ! -- -- 44B5*Flag_Type{boolean} 5r23 6m45 3|9r35 11r56 ! -- -- This line gives references for the publicly visible Boolean -- type Flag_Type declared on line 44, column 5. There are four -- references ! -- -- a reference on line 5, column 23 of the current file ! -- -- a modification on line 6, column 45 of the current file ! -- -- a reference on line 9, column 35 of unit number 3 ! -- -- a reference on line 11, column 56 of unit number 3 ! -- -- 2U13 p3=2:35 5b13 8r4 12r13 12t15 ! -- -- This line gives references for the non-publicly visible -- procedure p3 declared on line 2, column 13. This procedure -- renames the procedure whose identifier reference is at -- line 2 column 35. There are four references: ! -- -- the corresponding body entity at line 5, column 13, -- of the current file. ! -- -- a reference (e.g. a call) at line 8 column 4 of the -- of the current file. ! -- -- the END line of the body has an explict reference to -- the name of the procedure at line 12, column 13. ! -- -- the body ends at line 12, column 15, just past this label. ! -- -- 16I9*My_Type<2|4I9> 18r8 ! -- -- This line gives references for the publicly visible Integer -- derived type My_Type declared on line 16, column 9. It also -- gives references to the parent type declared in the unit -- number 2 on line 4, column 9. There is one reference: ! -- -- a reference (e.g. a variable declaration) at line 18 column -- 4 of the current file. ! -- -- 10I3*Genv{integer} 3|4I10[6|12] ! -- -- This line gives a reference for the entity Genv in a generic -- package. The reference in file 3, line 4, col 10, refers to -- an instance of the generic where the instantiation can be -- found in file 6 at line 12. ! -- -- Continuation lines are used if the reference list gets too long, -- a continuation line starts with a period, and then has references -- continuing from the previous line. The references are sorted first --- 228,285 ---- -- of file numbers in such references follows the normal -- rules (present only if needed, and resets the current -- file for subsequent references). ! -- Examples: ! -- 44B5*Flag_Type{boolean} 5r23 6m45 3|9r35 11r56 ! -- This line gives references for the publicly visible Boolean -- type Flag_Type declared on line 44, column 5. There are four -- references ! -- a reference on line 5, column 23 of the current file ! -- a modification on line 6, column 45 of the current file ! -- a reference on line 9, column 35 of unit number 3 ! -- a reference on line 11, column 56 of unit number 3 ! -- 2U13 p3=2:35 5b13 8r4 12r13 12t15 ! -- This line gives references for the non-publicly visible -- procedure p3 declared on line 2, column 13. This procedure -- renames the procedure whose identifier reference is at -- line 2 column 35. There are four references: ! -- the corresponding body entity at line 5, column 13, -- of the current file. ! -- a reference (e.g. a call) at line 8 column 4 of the -- of the current file. ! -- the END line of the body has an explict reference to -- the name of the procedure at line 12, column 13. ! -- the body ends at line 12, column 15, just past this label. ! -- 16I9*My_Type<2|4I9> 18r8 ! -- This line gives references for the publicly visible Integer -- derived type My_Type declared on line 16, column 9. It also -- gives references to the parent type declared in the unit -- number 2 on line 4, column 9. There is one reference: ! -- a reference (e.g. a variable declaration) at line 18 column -- 4 of the current file. ! -- 10I3*Genv{integer} 3|4I10[6|12] ! -- This line gives a reference for the entity Genv in a generic -- package. The reference in file 3, line 4, col 10, refers to -- an instance of the generic where the instantiation can be -- found in file 6 at line 12. ! -- Continuation lines are used if the reference list gets too long, -- a continuation line starts with a period, and then has references -- continuing from the previous line. The references are sorted first *************** package Lib.Xref is *** 439,453 **** -- This procedure is called to record a reference. N is the location -- of the reference and E is the referenced entity. Typ is one of: -- ! -- 'b' body entity (see below) -- 'c' completion of incomplete or private type (see below) ! -- 'E' end of spec (label present) ! -- 'e' end of spec (no label present) -- 'i' implicit reference -- 'm' modification -- 'r' standard reference ! -- 'T' end of body (label present) ! -- 't' end of body (no label present) -- 'x' type extension -- ' ' dummy reference (see below) -- --- 468,482 ---- -- This procedure is called to record a reference. N is the location -- of the reference and E is the referenced entity. Typ is one of: -- ! -- 'b' body entity -- 'c' completion of incomplete or private type (see below) ! -- 'e' end of construct -- 'i' implicit reference + -- 'l' label on end line -- 'm' modification + -- 'p' primitive operation -- 'r' standard reference ! -- 't' end of body -- 'x' type extension -- ' ' dummy reference (see below) -- *************** package Lib.Xref is *** 459,481 **** -- for the spec. The entity in the body is treated as a reference -- with type 'b'. Similar handling for references to subprogram formals. -- ! -- The call has no effect if N is not in the extended main source unit. ! -- If N is in the extended main source unit, then the Is_Referenced ! -- flag of E is set. In addition, if appropriate, a cross-reference ! -- entry is made. The entry is made if: -- ! -- cross-reference collection is enabled ! -- both entity and reference come from source (or Force is True) ! -- the entity is one for which xrefs are appropriate ! -- the type letter is non-blank ! -- the node N is an identifier, defining identifier, or expanded name -- ! -- If all these conditions are met, then a cross-reference entry is ! -- made for later output when Output_References is called. -- ! -- Note: the dummy entry is for the convenience of some callers, who ! -- find it easier to pass a space to suppress the entry than to do a ! -- specific test. The call has no effect if the type is a space. -- -- The parameter Set_Ref is normally True, and indicates that in -- addition to generating a cross-reference, the Referenced flag --- 488,516 ---- -- for the spec. The entity in the body is treated as a reference -- with type 'b'. Similar handling for references to subprogram formals. -- ! -- The call has no effect if N is not in the extended main source unit ! -- This check is omitted for type 'e' references (where it is useful to ! -- have structural scoping information for other than the main source), ! -- and for 'p' (since we want to pick up inherited primitive operations ! -- that are defined in other packages). -- ! -- The call also has no effect if any of the following conditions hold: -- ! -- cross-reference collection is disabled ! -- entity does not come from source (and Force is False) ! -- reference does not come from source (and Force is False) ! -- the entity is not one for which xrefs are appropriate ! -- the type letter is blank ! -- the node N is not an identifier, defining identifier, or expanded name ! -- the type is 'p' and the entity is not in the extended main source -- ! -- If all these conditions are met, then the Is_Referenced flag of E ! -- is set (unless Set_Ref is False) and a cross-reference entry is ! -- recorded for later output when Output_References is called. ! -- ! -- Note: the dummy space entry is for the convenience of some callers, ! -- who find it easier to pass a space to suppress the entry than to do ! -- a specific test. The call has no effect if the type is a space. -- -- The parameter Set_Ref is normally True, and indicates that in -- addition to generating a cross-reference, the Referenced flag diff -Nrc3pad gcc-3.2.3/gcc/ada/link.c gcc-3.3/gcc/ada/link.c *** gcc-3.2.3/gcc/ada/link.c 2003-03-31 21:07:56.000000000 +0000 --- gcc-3.3/gcc/ada/link.c 2003-03-31 21:11:35.000000000 +0000 *************** *** 4,10 **** * * * L I N K * * * - * $Revision: 1.1.16.1.4.1 $ * * * C Implementation File * * * --- 4,9 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/live.adb gcc-3.3/gcc/ada/live.adb *** gcc-3.2.3/gcc/ada/live.adb 2002-05-04 03:28:19.000000000 +0000 --- gcc-3.3/gcc/ada/live.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/live.ads gcc-3.3/gcc/ada/live.ads *** gcc-3.2.3/gcc/ada/live.ads 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/live.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/machcode.ads gcc-3.3/gcc/ada/machcode.ads *** gcc-3.2.3/gcc/ada/machcode.ads 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/machcode.ads 2002-03-14 10:59:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/make.adb gcc-3.3/gcc/ada/make.adb *** gcc-3.2.3/gcc/ada/make.adb 2002-05-04 03:28:19.000000000 +0000 --- gcc-3.3/gcc/ada/make.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.10.10.2 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Ada.Exceptions; use Ada.Exception *** 30,56 **** with Ada.Command_Line; use Ada.Command_Line; with GNAT.Directory_Operations; use GNAT.Directory_Operations; - with GNAT.OS_Lib; use GNAT.OS_Lib; ! with ALI; use ALI; ! with ALI.Util; use ALI.Util; with Csets; with Debug; ! with Fname; use Fname; ! with Fname.SF; use Fname.SF; ! with Fname.UF; use Fname.UF; ! with Gnatvsn; use Gnatvsn; ! with Hostparm; use Hostparm; with Makeusg; with MLib.Prj; with MLib.Tgt; with MLib.Utl; ! with Namet; use Namet; ! with Opt; use Opt; ! with Osint; use Osint; with Gnatvsn; ! with Output; use Output; ! with Prj; use Prj; with Prj.Com; with Prj.Env; with Prj.Ext; --- 29,55 ---- with Ada.Command_Line; use Ada.Command_Line; with GNAT.Directory_Operations; use GNAT.Directory_Operations; ! with ALI; use ALI; ! with ALI.Util; use ALI.Util; with Csets; with Debug; ! with Fname; use Fname; ! with Fname.SF; use Fname.SF; ! with Fname.UF; use Fname.UF; ! with Gnatvsn; use Gnatvsn; ! with Hostparm; use Hostparm; with Makeusg; with MLib.Prj; with MLib.Tgt; with MLib.Utl; ! with Namet; use Namet; ! with Opt; use Opt; ! with Osint.M; use Osint.M; ! with Osint; use Osint; with Gnatvsn; ! with Output; use Output; ! with Prj; use Prj; with Prj.Com; with Prj.Env; with Prj.Ext; *************** with Prj.Pars; *** 58,70 **** with Prj.Util; with SFN_Scan; with Sinput.L; ! with Snames; use Snames; ! with Stringt; use Stringt; ! with Table; ! with Types; use Types; ! with Switch; use Switch; ! with System.WCh_Con; use System.WCh_Con; package body Make is --- 57,69 ---- with Prj.Util; with SFN_Scan; with Sinput.L; ! with Snames; use Snames; ! with Stringt; use Stringt; ! with Switch; use Switch; ! with Switch.M; use Switch.M; ! with Targparm; ! with System.WCh_Con; use System.WCh_Con; package body Make is *************** package body Make is *** 193,198 **** --- 192,208 ---- Table_Increment => 100, Table_Name => "Make.Saved_Make_Switches"); + package Switches_To_Check is new Table.Table ( + Table_Component_Type => String_Access, + Table_Index_Type => Integer, + Table_Low_Bound => 1, + Table_Initial => 20, + Table_Increment => 100, + Table_Name => "Make.Switches_To_Check"); + + Normalized_Switches : Argument_List_Access := new Argument_List (1 .. 10); + Last_Norm_Switch : Natural := 0; + Saved_Maximum_Processes : Natural := 0; Saved_WC_Encoding_Method : WC_Encoding_Method := WC_Encoding_Method'First; Saved_WC_Encoding_Method_Set : Boolean := False; *************** package body Make is *** 238,260 **** Table_Name => "Make.Bad_Compilation"); -- Full name of all the source files for which compilation fails. - type Special_Argument is record - File : String_Access; - Args : Argument_List_Access; - end record; - -- File is the name of the file for which a special set of compilation - -- arguments (Args) is required. - - package Special_Args is new Table.Table ( - Table_Component_Type => Special_Argument, - Table_Index_Type => Natural, - Table_Low_Bound => 1, - Table_Initial => 20, - Table_Increment => 100, - Table_Name => "Make.Special_Args"); - -- Compilation arguments of all the source files for which an entry has - -- been found in the project file. - Original_Ada_Include_Path : constant String_Access := Getenv ("ADA_INCLUDE_PATH"); Original_Ada_Objects_Path : constant String_Access := --- 248,253 ---- *************** package body Make is *** 283,291 **** function Is_Marked (Source_File : File_Name_Type) return Boolean; -- Returns True if Source_File was previously marked. - procedure Unmark (Source_File : File_Name_Type); - -- Unmarks Source_File. - ------------------- -- Misc Routines -- ------------------- --- 276,281 ---- *************** package body Make is *** 315,328 **** -- after S1. S2 is printed last. Both N1 and N2 are printed in quotation -- marks. ----------------------- -- Gnatmake Routines -- ----------------------- subtype Lib_Mark_Type is Byte; ! Ada_Lib_Dir : constant Lib_Mark_Type := 1; ! GNAT_Lib_Dir : constant Lib_Mark_Type := 2; -- Note that the notion of GNAT lib dir is no longer used. The code -- related to it has not been removed to give an idea on how to use --- 305,326 ---- -- after S1. S2 is printed last. Both N1 and N2 are printed in quotation -- marks. + Usage_Needed : Boolean := True; + -- Flag used to make sure Makeusg is call at most once + + procedure Usage; + -- Call Makeusg, if Usage_Needed is True. + -- Set Usage_Needed to False. + ----------------------- -- Gnatmake Routines -- ----------------------- subtype Lib_Mark_Type is Byte; + -- ??? this needs a comment ! Ada_Lib_Dir : constant Lib_Mark_Type := 1; ! -- ??? this needs a comment -- Note that the notion of GNAT lib dir is no longer used. The code -- related to it has not been removed to give an idea on how to use *************** package body Make is *** 352,362 **** -- Get directory prefix of this file and get lib mark stored in name -- table for this directory. Then check if an Ada lib mark has been set. - procedure Mark_Dir_Path - (Path : String_Access; - Mark : Lib_Mark_Type); - -- Invoke Mark_Directory on each directory of the path. - procedure Mark_Directory (Dir : String; Mark : Lib_Mark_Type); --- 350,355 ---- *************** package body Make is *** 388,401 **** -- Return the switches for the source file in the specified package -- of a project file. If the Source_File ends with a standard GNAT -- extension (".ads" or ".adb"), try first the full name, then the ! -- name without the extension. If there is no switches for either ! -- names, try the default switches for Ada. If all failed, return ! -- No_Variable_Value. ! procedure Test_If_Relative_Path (Switch : String_Access); -- Test if Switch is a relative search path switch. ! -- Fail if it is. This subprogram is only called ! -- when using project files. procedure Set_Library_For (Project : Project_Id; --- 381,396 ---- -- Return the switches for the source file in the specified package -- of a project file. If the Source_File ends with a standard GNAT -- extension (".ads" or ".adb"), try first the full name, then the ! -- name without the extension, then, if Allow_ALI is True, the name with ! -- the extension ".ali". If there is no switches for either names, try the ! -- default switches for Ada. If all failed, return No_Variable_Value. ! procedure Test_If_Relative_Path ! (Switch : in out String_Access; ! Parent : String_Access); -- Test if Switch is a relative search path switch. ! -- If it is, fail if Parent is null, otherwise prepend the path with ! -- Parent. This subprogram is only called when using project files. procedure Set_Library_For (Project : Project_Id; *************** package body Make is *** 442,447 **** --- 437,445 ---- Object_Suffix : constant String := Get_Object_Suffix.all; Executable_Suffix : constant String := Get_Executable_Suffix.all; + Syntax_Only : Boolean := False; + -- Set to True when compiling with -gnats + Display_Executed_Programs : Boolean := True; -- Set to True if name of commands should be output on stderr. *************** package body Make is *** 506,511 **** --- 504,523 ---- -- Displays Program followed by the arguments in Args if variable -- Display_Executed_Programs is set. The lower bound of Args must be 1. + type Temp_File_Names is array (Positive range <>) of Temp_File_Name; + + type Temp_Files_Ptr is access Temp_File_Names; + + The_Mapping_File_Names : Temp_Files_Ptr; + Last_Mapping_File_Name : Natural := 0; + + procedure Delete_Mapping_Files; + -- Delete all temporary mapping files + + procedure Init_Mapping_File (File_Name : in out Temp_File_Name); + -- Create a new temporary mapping file, and fill it with the project file + -- mappings, when using project file(s) + -------------------- -- Add_Object_Dir -- -------------------- *************** package body Make is *** 551,559 **** generic with package T is new Table.Table (<>); procedure Generic_Position (New_Position : out Integer); ! -- Generic procedure that allocates a position for S in T at the -- beginning or the end, depending on the boolean Append_Switch. ---------------------- -- Generic_Position -- ---------------------- --- 563,572 ---- generic with package T is new Table.Table (<>); procedure Generic_Position (New_Position : out Integer); ! -- Generic procedure that chooses a position for S in T at the -- beginning or the end, depending on the boolean Append_Switch. + ---------------------- -- Generic_Position -- ---------------------- *************** package body Make is *** 750,755 **** --- 763,770 ---- Bind_Last := Bind_Last + 1; Bind_Args (Bind_Last) := new String'(Name_Buffer (1 .. Name_Len)); + GNAT.OS_Lib.Normalize_Arguments (Bind_Args (Args'First .. Bind_Last)); + Display (Gnatbind.all, Bind_Args (Args'First .. Bind_Last)); if Gnatbind_Path = null then *************** package body Make is *** 914,922 **** Num_Args : Integer; -- Number of compiler arguments processed - Special_Arg : Argument_List_Access; - -- Special arguments if any of a given compilation file - -- Start of processing for Check begin --- 929,934 ---- *************** package body Make is *** 986,1099 **** Get_Name_String (ALIs.Table (ALI).Sfile); ! for J in 1 .. Special_Args.Last loop ! if Special_Args.Table (J).File.all = ! Name_Buffer (1 .. Name_Len) ! then ! Special_Arg := Special_Args.Table (J).Args; ! exit; ! end if; ! end loop; ! if Main_Project /= No_Project then ! null; ! end if; ! if Special_Arg = null then ! for J in Gcc_Switches.First .. Gcc_Switches.Last loop ! -- Skip non switches, -I and -o switches ! if (Gcc_Switches.Table (J) (1) = '-' ! or else ! Gcc_Switches.Table (J) (1) = Switch_Character) ! and then Gcc_Switches.Table (J) (2) /= 'o' ! and then Gcc_Switches.Table (J) (2) /= 'I' ! then ! Num_Args := Num_Args + 1; ! -- Comparing switches is delicate because gcc reorders ! -- a number of switches, according to lang-specs.h, but ! -- gnatmake doesn't have the sufficient knowledge to ! -- perform the same reordering. Instead, we ignore orders ! -- between different "first letter" switches, but keep ! -- orders between same switches, e.g -O -O2 is different ! -- than -O2 -O, but -g -O is equivalent to -O -g. ! if Gcc_Switches.Table (J) (2) /= Prev_Switch then ! Prev_Switch := Gcc_Switches.Table (J) (2); ! Arg := ! Units.Table (ALIs.Table (ALI).First_Unit).First_Arg; ! end if; ! Switch_Found := False; ! for K in Arg .. ! Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg ! loop ! if Gcc_Switches.Table (J).all = Args.Table (K).all then ! Arg := K + 1; ! Switch_Found := True; ! exit; ! end if; ! end loop; ! if not Switch_Found then ! if Opt.Verbose_Mode then ! Verbose_Msg (ALIs.Table (ALI).Sfile, ! "switch mismatch"); ! end if; ! ALI := No_ALI_Id; ! return; ! end if; end if; end loop; ! -- Special_Arg is non-null ! ! else ! for J in Special_Arg'Range loop ! ! -- Skip non switches, -I and -o switches ! ! if (Special_Arg (J) (1) = '-' ! or else Special_Arg (J) (1) = Switch_Character) ! and then Special_Arg (J) (2) /= 'o' ! and then Special_Arg (J) (2) /= 'I' ! then ! Num_Args := Num_Args + 1; ! ! if Special_Arg (J) (2) /= Prev_Switch then ! Prev_Switch := Special_Arg (J) (2); ! Arg := ! Units.Table (ALIs.Table (ALI).First_Unit).First_Arg; ! end if; ! ! Switch_Found := False; ! ! for K in Arg .. ! Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg ! loop ! if Special_Arg (J).all = Args.Table (K).all then ! Arg := K + 1; ! Switch_Found := True; ! exit; ! end if; ! end loop; ! ! if not Switch_Found then ! if Opt.Verbose_Mode then ! Verbose_Msg (ALIs.Table (ALI).Sfile, ! "switch mismatch"); ! end if; ! ! ALI := No_ALI_Id; ! return; ! end if; end if; ! end loop; ! end if; if Num_Args /= Integer (Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg - --- 998,1068 ---- Get_Name_String (ALIs.Table (ALI).Sfile); ! Switches_To_Check.Set_Last (0); ! for J in Gcc_Switches.First .. Gcc_Switches.Last loop ! -- Skip non switches, -I and -o switches ! if Gcc_Switches.Table (J) (1) = '-' ! and then Gcc_Switches.Table (J) (2) /= 'o' ! and then Gcc_Switches.Table (J) (2) /= 'I' ! then ! Normalize_Compiler_Switches ! (Gcc_Switches.Table (J).all, ! Normalized_Switches, ! Last_Norm_Switch); ! for K in 1 .. Last_Norm_Switch loop ! Switches_To_Check.Increment_Last; ! Switches_To_Check.Table (Switches_To_Check.Last) := ! Normalized_Switches (K); ! end loop; ! end if; ! end loop; ! for J in 1 .. Switches_To_Check.Last loop ! -- Comparing switches is delicate because gcc reorders ! -- a number of switches, according to lang-specs.h, but ! -- gnatmake doesn't have the sufficient knowledge to ! -- perform the same reordering. Instead, we ignore orders ! -- between different "first letter" switches, but keep ! -- orders between same switches, e.g -O -O2 is different ! -- than -O2 -O, but -g -O is equivalent to -O -g. ! if Switches_To_Check.Table (J) (2) /= Prev_Switch then ! Prev_Switch := Switches_To_Check.Table (J) (2); ! Arg := ! Units.Table (ALIs.Table (ALI).First_Unit).First_Arg; ! end if; ! Switch_Found := False; ! for K in Arg .. ! Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg ! loop ! Num_Args := Num_Args + 1; ! if ! Switches_To_Check.Table (J).all = Args.Table (K).all ! then ! Arg := K + 1; ! Switch_Found := True; ! exit; end if; end loop; ! if not Switch_Found then ! if Opt.Verbose_Mode then ! Verbose_Msg (ALIs.Table (ALI).Sfile, ! "switch mismatch"); end if; ! ! ALI := No_ALI_Id; ! return; ! end if; ! end loop; if Num_Args /= Integer (Units.Table (ALIs.Table (ALI).First_Unit).Last_Arg - *************** package body Make is *** 1195,1203 **** if Name_Len <= 0 then return; ! elsif Name_Buffer (1) = Get_Switch_Character ! or else Name_Buffer (1) = '-' ! then -- Do not check if File is a switch other than "-l" if Name_Buffer (2) /= 'l' then --- 1164,1171 ---- if Name_Len <= 0 then return; ! elsif Name_Buffer (1) = '-' then ! -- Do not check if File is a switch other than "-l" if Name_Buffer (2) /= 'l' then *************** package body Make is *** 1346,1356 **** --- 1314,1329 ---- -- expected library file name. Process_Id of the process spawned to -- execute the compile. + No_Mapping_File : constant Temp_File_Name := (others => ' '); + type Compilation_Data is record Pid : Process_Id; Full_Source_File : File_Name_Type; Lib_File : File_Name_Type; Source_Unit : Unit_Name_Type; + Mapping_File : Temp_File_Name := No_Mapping_File; + Use_Mapping_File : Boolean := False; + Syntax_Only : Boolean := False; end record; Running_Compile : array (1 .. Max_Process) of Compilation_Data; *************** package body Make is *** 1392,1397 **** --- 1365,1372 ---- Pid : Process_Id; Text : Text_Buffer_Ptr; + Mfile : Temp_File_Name := No_Mapping_File; + Data : Prj.Project_Data; Arg_Index : Natural; *************** package body Make is *** 1399,1409 **** Need_To_Check_Standard_Library : Boolean := Check_Readonly_Files; procedure Add_Process ! (Pid : Process_Id; ! Sfile : File_Name_Type; ! Afile : File_Name_Type; ! Uname : Unit_Name_Type); -- Adds process Pid to the current list of outstanding compilation -- processes and record the full name of the source file Sfile that -- we are compiling, the name of its library file Afile and the --- 1374,1390 ---- Need_To_Check_Standard_Library : Boolean := Check_Readonly_Files; + Mapping_File_Arg : constant String_Access := new String' + (1 => '-', 2 => 'g', 3 => 'n', 4 => 'a', 5 => 't', 6 => 'e', 7 => 'm', + 8 .. 7 + Mfile'Length => ' '); + procedure Add_Process ! (Pid : Process_Id; ! Sfile : File_Name_Type; ! Afile : File_Name_Type; ! Uname : Unit_Name_Type; ! Mfile : Temp_File_Name := No_Mapping_File; ! UMfile : Boolean := False); -- Adds process Pid to the current list of outstanding compilation -- processes and record the full name of the source file Sfile that -- we are compiling, the name of its library file Afile and the *************** package body Make is *** 1423,1429 **** -- resp. No_File, No_File and No_Name if there were no compilations -- to wait for. ! procedure Collect_Arguments_And_Compile; -- Collect arguments from project file (if any) and compile package Good_ALI is new Table.Table ( --- 1404,1410 ---- -- resp. No_File, No_File and No_Name if there were no compilations -- to wait for. ! procedure Collect_Arguments_And_Compile (Source_File : File_Name_Type); -- Collect arguments from project file (if any) and compile package Good_ALI is new Table.Table ( *************** package body Make is *** 1465,1479 **** -- pragmas file to be specified for For_Project, -- otherwise return an empty argument list. ----------------- -- Add_Process -- ----------------- procedure Add_Process ! (Pid : Process_Id; ! Sfile : File_Name_Type; ! Afile : File_Name_Type; ! Uname : Unit_Name_Type) is OC1 : constant Positive := Outstanding_Compiles + 1; --- 1446,1466 ---- -- pragmas file to be specified for For_Project, -- otherwise return an empty argument list. + procedure Get_Mapping_File; + -- Get a mapping file name. If there is one to be reused, reuse it. + -- Otherwise, create a new mapping file. + ----------------- -- Add_Process -- ----------------- procedure Add_Process ! (Pid : Process_Id; ! Sfile : File_Name_Type; ! Afile : File_Name_Type; ! Uname : Unit_Name_Type; ! Mfile : Temp_File_Name := No_Mapping_File; ! UMfile : Boolean := False) is OC1 : constant Positive := Outstanding_Compiles + 1; *************** package body Make is *** 1485,1490 **** --- 1472,1480 ---- Running_Compile (OC1).Full_Source_File := Sfile; Running_Compile (OC1).Lib_File := Afile; Running_Compile (OC1).Source_Unit := Uname; + Running_Compile (OC1).Mapping_File := Mfile; + Running_Compile (OC1).Use_Mapping_File := UMfile; + Running_Compile (OC1).Syntax_Only := Syntax_Only; Outstanding_Compiles := OC1; end Add_Process; *************** package body Make is *** 1520,1525 **** --- 1510,1525 ---- Sfile := Running_Compile (J).Full_Source_File; Afile := Running_Compile (J).Lib_File; Uname := Running_Compile (J).Source_Unit; + Syntax_Only := Running_Compile (J).Syntax_Only; + + -- If a mapping file was used by this compilation, + -- get its file name for reuse by a subsequent compilation + + if Running_Compile (J).Use_Mapping_File then + Last_Mapping_File_Name := Last_Mapping_File_Name + 1; + The_Mapping_File_Names (Last_Mapping_File_Name) := + Running_Compile (J).Mapping_File; + end if; -- To actually remove this Pid and related info from -- Running_Compile replace its entry with the last valid *************** package body Make is *** 1554,1561 **** -- Collect_Arguments_And_Compile -- ----------------------------------- ! procedure Collect_Arguments_And_Compile is begin -- If no project file is used, then just call Compile with -- the specified Args. --- 1554,1568 ---- -- Collect_Arguments_And_Compile -- ----------------------------------- ! procedure Collect_Arguments_And_Compile (Source_File : File_Name_Type) is begin + + -- If we use mapping file (-P or -C switches), then get one + + if Create_Mapping_File then + Get_Mapping_File; + end if; + -- If no project file is used, then just call Compile with -- the specified Args. *************** package body Make is *** 1575,1581 **** declare Source_File_Name : constant String := ! Name_Buffer (1 .. Name_Len); Current_Project : Prj.Project_Id; Path_Name : File_Name_Type := Source_File; Compiler_Package : Prj.Package_Id; --- 1582,1588 ---- declare Source_File_Name : constant String := ! Get_Name_String (Source_File); Current_Project : Prj.Project_Id; Path_Name : File_Name_Type := Source_File; Compiler_Package : Prj.Package_Id; *************** package body Make is *** 1737,1743 **** String_To_Name_Buffer (Element.Value); New_Args (Index) := new String' (Name_Buffer (1 .. Name_Len)); ! Test_If_Relative_Path (New_Args (Index)); Current := Element.Next; end loop; --- 1744,1751 ---- String_To_Name_Buffer (Element.Value); New_Args (Index) := new String' (Name_Buffer (1 .. Name_Len)); ! Test_If_Relative_Path ! (New_Args (Index), Parent => null); Current := Element.Next; end loop; *************** package body Make is *** 1755,1769 **** -- this switch, plus the saved gcc switches. when Single => - String_To_Name_Buffer (Switches.Value); declare ! New_Args : constant Argument_List := (1 => new String' (Name_Buffer (1 .. Name_Len))); begin ! Test_If_Relative_Path (New_Args (1)); Pid := Compile (Path_Name, Lib_File, --- 1763,1778 ---- -- this switch, plus the saved gcc switches. when Single => String_To_Name_Buffer (Switches.Value); + declare ! New_Args : Argument_List := (1 => new String' (Name_Buffer (1 .. Name_Len))); begin ! Test_If_Relative_Path ! (New_Args (1), Parent => null); Pid := Compile (Path_Name, Lib_File, *************** package body Make is *** 1788,1795 **** (Path_Name, Lib_File, Args & Output_Flag & Object_File & ! Configuration_Pragmas_Switch (Current_Project) & ! The_Saved_Gcc_Switches.all); end case; end if; end; --- 1797,1804 ---- (Path_Name, Lib_File, Args & Output_Flag & Object_File & ! Configuration_Pragmas_Switch (Current_Project) & ! The_Saved_Gcc_Switches.all); end case; end if; end; *************** package body Make is *** 1803,1809 **** function Compile (S : Name_Id; L : Name_Id; Args : Argument_List) return Process_Id is ! Comp_Args : Argument_List (Args'First .. Args'Last + 7); Comp_Next : Integer := Args'First; Comp_Last : Integer; --- 1812,1818 ---- function Compile (S : Name_Id; L : Name_Id; Args : Argument_List) return Process_Id is ! Comp_Args : Argument_List (Args'First .. Args'Last + 8); Comp_Next : Integer := Args'First; Comp_Last : Integer; *************** package body Make is *** 1829,1834 **** --- 1838,1871 ---- -- Start of processing for Compile begin + -- By default, Syntax_Only is False + + Syntax_Only := False; + + for J in Args'Range loop + if Args (J).all = "-gnats" then + + -- If we compile with -gnats, the bind step and the link step + -- are inhibited. Also, we set Syntax_Only to True, so that + -- we don't fail when we don't find the ALI file, after + -- compilation. + + Do_Bind_Step := False; + Do_Link_Step := False; + Syntax_Only := True; + + elsif Args (J).all = "-gnatc" then + + -- If we compile with -gnatc, the bind step and the link step + -- are inhibited. We set Syntax_Only to True for the case when + -- -gnats was previously specified. + + Do_Bind_Step := False; + Do_Link_Step := False; + Syntax_Only := False; + end if; + end loop; + Comp_Args (Comp_Next) := Comp_Flag; Comp_Next := Comp_Next + 1; *************** package body Make is *** 1902,1912 **** --- 1939,1956 ---- Comp_Args (Comp_Last) := new String'(Name_Buffer (1 .. Name_Len)); end if; + if Create_Mapping_File then + Comp_Last := Comp_Last + 1; + Comp_Args (Comp_Last) := Mapping_File_Arg; + end if; + Get_Name_String (S); Comp_Last := Comp_Last + 1; Comp_Args (Comp_Last) := new String'(Name_Buffer (1 .. Name_Len)); + GNAT.OS_Lib.Normalize_Arguments (Comp_Args (Args'First .. Comp_Last)); + Display (Gcc.all, Comp_Args (Args'First .. Comp_Last)); if Gcc_Path = null then *************** package body Make is *** 1955,1960 **** --- 1999,2029 ---- end if; end Debug_Msg; + ---------------------- + -- Get_Mapping_File -- + ---------------------- + + procedure Get_Mapping_File is + begin + -- If there is a mapping file ready to be reused, reuse it + + if Last_Mapping_File_Name > 0 then + Mfile := The_Mapping_File_Names (Last_Mapping_File_Name); + Last_Mapping_File_Name := Last_Mapping_File_Name - 1; + + -- Otherwise, create and initialize a new one + + else + Init_Mapping_File (File_Name => Mfile); + end if; + + -- Put the name in the mapping file argument for the invocation + -- of the compiler. + + Mapping_File_Arg (8 .. Mapping_File_Arg'Last) := Mfile; + + end Get_Mapping_File; + ----------------------- -- Get_Next_Good_ALI -- ----------------------- *************** package body Make is *** 2010,2016 **** -- Package and Queue initializations. Good_ALI.Init; - Bad_Compilation.Init; Output.Set_Standard_Error; Init_Q; --- 2079,2084 ---- *************** package body Make is *** 2184,2195 **** -- Check for special compilation flags Arg_Index := 0; - Get_Name_String (Source_File); -- Start the compilation and record it. We can do this -- because there is at least one free process. ! Collect_Arguments_And_Compile; -- Make sure we could successfully start the compilation --- 2252,2262 ---- -- Check for special compilation flags Arg_Index := 0; -- Start the compilation and record it. We can do this -- because there is at least one free process. ! Collect_Arguments_And_Compile (Source_File); -- Make sure we could successfully start the compilation *************** package body Make is *** 2197,2203 **** Record_Failure (Full_Source_File, Source_Unit); else Add_Process ! (Pid, Full_Source_File, Lib_File, Source_Unit); end if; end if; end if; --- 2264,2275 ---- Record_Failure (Full_Source_File, Source_Unit); else Add_Process ! (Pid, ! Full_Source_File, ! Lib_File, ! Source_Unit, ! Mfile, ! Create_Mapping_File); end if; end if; end if; *************** package body Make is *** 2218,2228 **** if not Compilation_OK then Record_Failure (Full_Source_File, Source_Unit); - else -- Re-read the updated library file ! Text := Read_Library_Info (Lib_File); -- If no ALI file was generated by this compilation nothing -- more to do, otherwise scan the ali file and record it. --- 2290,2317 ---- if not Compilation_OK then Record_Failure (Full_Source_File, Source_Unit); + end if; + + if Compilation_OK or else Keep_Going then -- Re-read the updated library file ! declare ! Saved_Object_Consistency : constant Boolean := ! Opt.Check_Object_Consistency; ! ! begin ! -- If compilation was not OK, don't check object ! -- consistency. ! ! Opt.Check_Object_Consistency := ! Opt.Check_Object_Consistency and Compilation_OK; ! Text := Read_Library_Info (Lib_File); ! ! -- Restore Check_Object_Consistency to its initial value ! ! Opt.Check_Object_Consistency := Saved_Object_Consistency; ! end; -- If no ALI file was generated by this compilation nothing -- more to do, otherwise scan the ali file and record it. *************** package body Make is *** 2234,2242 **** Scan_ALI (Lib_File, Text, Ignore_ED => False, Err => True); if ALI = No_ALI_Id then ! Inform ! (Lib_File, "incompatible ALI file, please recompile"); ! Record_Failure (Full_Source_File, Source_Unit); else Free (Text); Record_Good_ALI (ALI); --- 2323,2337 ---- Scan_ALI (Lib_File, Text, Ignore_ED => False, Err => True); if ALI = No_ALI_Id then ! ! -- Record a failure only if not already done ! ! if Compilation_OK then ! Inform ! (Lib_File, ! "incompatible ALI file, please recompile"); ! Record_Failure (Full_Source_File, Source_Unit); ! end if; else Free (Text); Record_Good_ALI (ALI); *************** package body Make is *** 2248,2259 **** -- is set Read_Library_Info checks that the time stamp of the -- object file is more recent than that of the ALI). For an -- example of problems caught by this test see [6625-009]. else ! Inform ! (Lib_File, ! "WARNING: ALI or object file not found after compile"); ! Record_Failure (Full_Source_File, Source_Unit); end if; end if; end if; --- 2343,2357 ---- -- is set Read_Library_Info checks that the time stamp of the -- object file is more recent than that of the ALI). For an -- example of problems caught by this test see [6625-009]. + -- However, we record a failure only if not already done. else ! if Compilation_OK and not Syntax_Only then ! Inform ! (Lib_File, ! "WARNING: ALI or object file not found after compile"); ! Record_Failure (Full_Source_File, Source_Unit); ! end if; end if; end if; end if; *************** package body Make is *** 2292,2298 **** if not ALIs.Table (ALI).No_Run_Time then declare ! Sfile : Name_Id; begin Name_Len := Standard_Library_Package_Body_Name'Length; --- 2390,2397 ---- if not ALIs.Table (ALI).No_Run_Time then declare ! Sfile : Name_Id; ! Add_It : Boolean := True; begin Name_Len := Standard_Library_Package_Body_Name'Length; *************** package body Make is *** 2300,2306 **** Standard_Library_Package_Body_Name; Sfile := Name_Enter; ! if not Is_Marked (Sfile) then Insert_Q (Sfile); Mark (Sfile); end if; --- 2399,2412 ---- Standard_Library_Package_Body_Name; Sfile := Name_Enter; ! -- If we have a special runtime, we add the standard ! -- library only if we can find it. ! ! if Opt.RTS_Switch then ! Add_It := Find_File (Sfile, Osint.Source) /= No_File; ! end if; ! ! if Add_It and then not Is_Marked (Sfile) then Insert_Q (Sfile); Mark (Sfile); end if; *************** package body Make is *** 2390,2395 **** --- 2496,2515 ---- end if; end Compile_Sources; + -------------------------- + -- Delete_Mapping_Files -- + -------------------------- + + procedure Delete_Mapping_Files is + Success : Boolean; + + begin + for Index in 1 .. Last_Mapping_File_Name loop + Delete_File + (Name => The_Mapping_File_Names (Index), Success => Success); + end loop; + end Delete_Mapping_Files; + ------------- -- Display -- ------------- *************** package body Make is *** 2402,2409 **** Write_Str (Program); for J in Args'Range loop ! Write_Str (" "); ! Write_Str (Args (J).all); end loop; Write_Eol; --- 2522,2539 ---- Write_Str (Program); for J in Args'Range loop ! ! -- Do not display the mapping file argument automatically ! -- created when using a project file. ! ! if Main_Project = No_Project ! or else Args (J)'Length /= 7 + Temp_File_Name'Length ! or else Args (J)'First /= 1 ! or else Args (J)(1 .. 7) /= "-gnatem" ! then ! Write_Str (" "); ! Write_Str (Args (J).all); ! end if; end loop; Write_Eol; *************** package body Make is *** 2492,2497 **** --- 2622,2629 ---- Compilation_Failures : Natural; + Total_Compilation_Failures : Natural := 0; + Is_Main_Unit : Boolean; -- Set to True by Compile_Sources if the Main_Source_File can be a -- main unit. *************** package body Make is *** 2502,2508 **** Executable : File_Name_Type := No_File; -- The file name of an executable ! Non_Std_Executable : Boolean := False; -- Non_Std_Executable is set to True when there is a possibility -- that the linker will not choose the correct executable file name. --- 2634,2640 ---- Executable : File_Name_Type := No_File; -- The file name of an executable ! Non_Std_Executable : Boolean := False; -- Non_Std_Executable is set to True when there is a possibility -- that the linker will not choose the correct executable file name. *************** package body Make is *** 2512,2520 **** -- be rebuild (if we rebuild mains), even in the case when it is not -- really necessary, because it is too hard to decide. ! Mapping_File_Name : Temp_File_Name; ! -- The name of the temporary mapping file that is copmmunicated ! -- to the compiler through a -gnatem switch, when using project files. begin Do_Compile_Step := True; --- 2644,2653 ---- -- be rebuild (if we rebuild mains), even in the case when it is not -- really necessary, because it is too hard to decide. ! Current_Work_Dir : constant String_Access := ! new String'(Get_Current_Dir); ! -- The current working directory, used to modify some relative path ! -- switches on the command line when a project file is used. begin Do_Compile_Step := True; *************** package body Make is *** 2535,2544 **** end if; if Opt.Verbose_Mode then Write_Eol; Write_Str ("GNATMAKE "); Write_Str (Gnatvsn.Gnat_Version_String); ! Write_Str (" Copyright 1995-2001 Free Software Foundation, Inc."); Write_Eol; end if; --- 2668,2684 ---- end if; if Opt.Verbose_Mode then + Targparm.Get_Target_Parameters; + Write_Eol; Write_Str ("GNATMAKE "); + + if Targparm.High_Integrity_Mode_On_Target then + Write_Str ("Pro High Integrity "); + end if; + Write_Str (Gnatvsn.Gnat_Version_String); ! Write_Str (" Copyright 1995-2002 Free Software Foundation, Inc."); Write_Eol; end if; *************** package body Make is *** 2574,2579 **** --- 2714,2723 ---- Do_Bind_Step := False; Do_Link_Step := False; + -- Set Unique_Compile if it was not already set + + Unique_Compile := True; + -- Put all the sources in the queue Insert_Project_Sources *************** package body Make is *** 2604,2610 **** end if; ! -- If -l was specified behave as if -n was specified if Opt.List_Dependencies then Opt.Do_Not_Execute := True; --- 2748,2754 ---- end if; ! -- If -M was specified, behave as if -n was specified if Opt.List_Dependencies then Opt.Do_Not_Execute := True; *************** package body Make is *** 2826,2831 **** --- 2970,3012 ---- Display_Commands (not Opt.Quiet_Output); + -- If we are using a project file, relative paths are forbidden in the + -- project file, but we add the current working directory for any + -- relative path on the command line. + + if Main_Project /= No_Project then + + for J in 1 .. Binder_Switches.Last loop + Test_If_Relative_Path + (Binder_Switches.Table (J), Parent => null); + end loop; + + for J in 1 .. Saved_Binder_Switches.Last loop + Test_If_Relative_Path + (Saved_Binder_Switches.Table (J), Parent => Current_Work_Dir); + end loop; + + for J in 1 .. Linker_Switches.Last loop + Test_If_Relative_Path + (Linker_Switches.Table (J), Parent => null); + end loop; + + for J in 1 .. Saved_Linker_Switches.Last loop + Test_If_Relative_Path + (Saved_Linker_Switches.Table (J), Parent => Current_Work_Dir); + end loop; + + for J in 1 .. Gcc_Switches.Last loop + Test_If_Relative_Path + (Gcc_Switches.Table (J), Parent => null); + end loop; + + for J in 1 .. Saved_Gcc_Switches.Last loop + Test_If_Relative_Path + (Saved_Gcc_Switches.Table (J), Parent => Current_Work_Dir); + end loop; + end if; + -- We now put in the Binder_Switches and Linker_Switches tables, -- the binder and linker switches of the command line that have been -- put in the Saved_ tables. If a project file was used, then the *************** package body Make is *** 2862,2900 **** -- in procedure Compile_Sources. The_Saved_Gcc_Switches := ! new Argument_List (1 .. Saved_Gcc_Switches.Last + 2); for J in 1 .. Saved_Gcc_Switches.Last loop The_Saved_Gcc_Switches (J) := Saved_Gcc_Switches.Table (J); - Test_If_Relative_Path (The_Saved_Gcc_Switches (J)); end loop; -- We never use gnat.adc when a project file is used - The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last - 1) := - No_gnat_adc; - - -- Create a temporary mapping file and add the switch -gnatem - -- with its name to the compiler. - - Prj.Env.Create_Mapping_File (Name => Mapping_File_Name); The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last) := ! new String'("-gnatem" & Mapping_File_Name); ! ! -- Check if there are any relative search paths in the switches. ! -- Fail if there is one. ! ! for J in 1 .. Gcc_Switches.Last loop ! Test_If_Relative_Path (Gcc_Switches.Table (J)); ! end loop; ! ! for J in 1 .. Binder_Switches.Last loop ! Test_If_Relative_Path (Binder_Switches.Table (J)); ! end loop; ! ! for J in 1 .. Linker_Switches.Last loop ! Test_If_Relative_Path (Linker_Switches.Table (J)); ! end loop; end if; --- 3043,3058 ---- -- in procedure Compile_Sources. The_Saved_Gcc_Switches := ! new Argument_List (1 .. Saved_Gcc_Switches.Last + 1); for J in 1 .. Saved_Gcc_Switches.Last loop The_Saved_Gcc_Switches (J) := Saved_Gcc_Switches.Table (J); end loop; -- We never use gnat.adc when a project file is used The_Saved_Gcc_Switches (The_Saved_Gcc_Switches'Last) := ! No_gnat_adc; end if; *************** package body Make is *** 2926,2931 **** --- 3084,3095 ---- Saved_Maximum_Processes := Opt.Maximum_Processes; end if; + -- Allocate as many temporary mapping file names as the maximum + -- number of compilation processed. + + The_Mapping_File_Names := + new Temp_File_Names (1 .. Saved_Maximum_Processes); + -- If either -c, -b or -l has been specified, we will not necessarily -- execute all steps. *************** package body Make is *** 2941,2946 **** --- 3105,3112 ---- end if; end if; + Bad_Compilation.Init; + -- Here is where the make process is started -- We do the same process for each main *************** package body Make is *** 3133,3141 **** Write_Eol; end if; ! if Compilation_Failures /= 0 then ! List_Bad_Compilations; ! raise Compilation_Failed; end if; -- Regenerate libraries, if any and if object files --- 3299,3315 ---- Write_Eol; end if; ! Total_Compilation_Failures := ! Total_Compilation_Failures + Compilation_Failures; ! ! if Total_Compilation_Failures /= 0 then ! if Opt.Keep_Going then ! goto Next_Main; ! ! else ! List_Bad_Compilations; ! raise Compilation_Failed; ! end if; end if; -- Regenerate libraries, if any and if object files *************** package body Make is *** 3188,3194 **** -- 1) -n (Do_Not_Execute) specified ! -- 2) -l (List_Dependencies) specified (also sets -- Do_Not_Execute above, so this is probably superfluous). -- 3) -c (Compile_Only) specified, but not -b (Bind_Only) --- 3362,3368 ---- -- 1) -n (Do_Not_Execute) specified ! -- 2) -M (List_Dependencies) specified (also sets -- Do_Not_Execute above, so this is probably superfluous). -- 3) -c (Compile_Only) specified, but not -b (Bind_Only) *************** package body Make is *** 3495,3525 **** end if; end loop Multiple_Main_Loop; -- Delete the temporary mapping file that was created if we are -- using project files. ! if Main_Project /= No_Project then ! declare ! Success : Boolean; ! ! begin ! Delete_File (Name => Mapping_File_Name, Success => Success); ! end; ! end if; Exit_Program (E_Success); exception when Bind_Failed => Osint.Fail ("*** bind failed."); when Compilation_Failed => Exit_Program (E_Fatal); when Link_Failed => Osint.Fail ("*** link failed."); when X : others => Write_Line (Exception_Information (X)); Osint.Fail ("INTERNAL ERROR. Please report."); --- 3669,3701 ---- end if; end loop Multiple_Main_Loop; + if Total_Compilation_Failures /= 0 then + List_Bad_Compilations; + raise Compilation_Failed; + end if; + -- Delete the temporary mapping file that was created if we are -- using project files. ! Delete_Mapping_Files; Exit_Program (E_Success); exception when Bind_Failed => + Delete_Mapping_Files; Osint.Fail ("*** bind failed."); when Compilation_Failed => + Delete_Mapping_Files; Exit_Program (E_Fatal); when Link_Failed => + Delete_Mapping_Files; Osint.Fail ("*** link failed."); when X : others => + Delete_Mapping_Files; Write_Line (Exception_Information (X)); Osint.Fail ("INTERNAL ERROR. Please report."); *************** package body Make is *** 3557,3562 **** --- 3733,3759 ---- Write_Eol; end Inform; + ----------------------- + -- Init_Mapping_File -- + ----------------------- + + procedure Init_Mapping_File (File_Name : in out Temp_File_Name) is + FD : File_Descriptor; + begin + if Main_Project /= No_Project then + Prj.Env.Create_Mapping_File (File_Name); + + else + Create_Temp_File (FD, File_Name); + + if FD = Invalid_FD then + Fail ("disk full"); + end if; + + Close (FD); + end if; + end Init_Mapping_File; + ------------ -- Init_Q -- ------------ *************** package body Make is *** 3586,3592 **** -- Package initializations. The order of calls is important here. Output.Set_Standard_Error; - Osint.Initialize (Osint.Make); Gcc_Switches.Init; Binder_Switches.Init; --- 3783,3788 ---- *************** package body Make is *** 3863,3868 **** --- 4059,4066 ---- Get_Name_String (ALI_File); Link_Args (Args'Last + 1) := new String'(Name_Buffer (1 .. Name_Len)); + GNAT.OS_Lib.Normalize_Arguments (Link_Args); + Display (Gnatlink.all, Link_Args); if Gnatlink_Path = null then *************** package body Make is *** 3969,3996 **** Set_Name_Table_Byte (Source_File, 1); end Mark; - ------------------- - -- Mark_Dir_Path -- - ------------------- - - procedure Mark_Dir_Path - (Path : String_Access; - Mark : Lib_Mark_Type) - is - Dir : String_Access; - - begin - if Path /= null then - Osint.Get_Next_Dir_In_Path_Init (Path); - - loop - Dir := Osint.Get_Next_Dir_In_Path (Path); - exit when Dir = null; - Mark_Directory (Dir.all, Mark); - end loop; - end if; - end Mark_Dir_Path; - -------------------- -- Mark_Directory -- -------------------- --- 4167,4172 ---- *************** package body Make is *** 4025,4043 **** ---------------------- function Object_File_Name (Source : String) return String is - Pos : Natural := Source'Last; - begin ! while Pos >= Source'First and then ! Source (Pos) /= '.' loop ! Pos := Pos - 1; end loop; ! if Pos >= Source'First then ! Pos := Pos - 1; ! end if; ! return Source (Source'First .. Pos) & Object_Suffix; end Object_File_Name; ------------------- --- 4201,4220 ---- ---------------------- function Object_File_Name (Source : String) return String is begin ! -- If the source name has an extension, then replace it with ! -- the object suffix. ! ! for Index in reverse Source'First + 1 .. Source'Last loop ! if Source (Index) = '.' then ! return Source (Source'First .. Index - 1) & Object_Suffix; ! end if; end loop; ! -- If there is no dot, or if it is the first character, just add the ! -- object suffix. ! return Source & Object_Suffix; end Object_File_Name; ------------------- *************** package body Make is *** 4059,4066 **** if Opt.Output_File_Name_Present and then not Output_File_Name_Seen then Output_File_Name_Seen := True; ! if Argv (1) = Switch_Character or else Argv (1) = '-' then Fail ("output file name missing after -o"); else Add_Switch ("-o", Linker, And_Save => And_Save); --- 4236,4244 ---- if Opt.Output_File_Name_Present and then not Output_File_Name_Seen then Output_File_Name_Seen := True; ! if Argv (1) = '-' then Fail ("output file name missing after -o"); + else Add_Switch ("-o", Linker, And_Save => And_Save); *************** package body Make is *** 4080,4092 **** end if; end if; ! -- Then check if we are dealing with a -cargs, -bargs or -largs ! elsif (Argv (1) = Switch_Character or else Argv (1) = '-') ! and then (Argv (2 .. Argv'Last) = "cargs" ! or else Argv (2 .. Argv'Last) = "bargs" ! or else Argv (2 .. Argv'Last) = "largs" ! or else Argv (2 .. Argv'Last) = "margs") then case Argv (2) is when 'c' => Program_Args := Compiler; --- 4258,4272 ---- end if; end if; ! -- Then check if we are dealing with -cargs/-bargs/-largs ! elsif Argv = "-bargs" ! or else ! Argv = "-cargs" ! or else ! Argv = "-largs" ! or else ! Argv = "-margs" then case Argv (2) is when 'c' => Program_Args := Compiler; *************** package body Make is *** 4103,4110 **** -- executable. elsif Program_Args = Linker ! and then (Argv (1) = Switch_Character or else Argv (1) = '-') ! and then Argv (2 .. Argv'Last) = "o" then Fail ("switch -o not allowed within a -largs. Use -o directly."); --- 4283,4289 ---- -- executable. elsif Program_Args = Linker ! and then Argv = "-o" then Fail ("switch -o not allowed within a -largs. Use -o directly."); *************** package body Make is *** 4134,4140 **** Add_Switch (Argv, Program_Args, And_Save => And_Save); ! -- Handle non-default compiler, binder, linker elsif Argv'Length > 2 and then Argv (1 .. 2) = "--" then if Argv'Length > 6 --- 4313,4319 ---- Add_Switch (Argv, Program_Args, And_Save => And_Save); ! -- Handle non-default compiler, binder, linker, and handle --RTS switch elsif Argv'Length > 2 and then Argv (1 .. 2) = "--" then if Argv'Length > 6 *************** package body Make is *** 4200,4212 **** end loop; end; else Fail ("unknown switch: ", Argv); end if; -- If we have seen a regular switch process it ! elsif Argv (1) = Switch_Character or else Argv (1) = '-' then if Argv'Length = 1 then Fail ("switch character cannot be followed by a blank"); --- 4379,4438 ---- end loop; end; + elsif Argv'Length >= 5 and then + Argv (1 .. 5) = "--RTS" + then + Add_Switch (Argv, Compiler, And_Save => And_Save); + Add_Switch (Argv, Binder, And_Save => And_Save); + + if Argv'Length <= 6 or else Argv (6) /= '=' then + Osint.Fail ("missing path for --RTS"); + + else + -- Valid --RTS switch + + Opt.No_Stdinc := True; + Opt.No_Stdlib := True; + Opt.RTS_Switch := True; + + declare + Src_Path_Name : String_Ptr := + Get_RTS_Search_Dir + (Argv (7 .. Argv'Last), Include); + Lib_Path_Name : String_Ptr := + Get_RTS_Search_Dir + (Argv (7 .. Argv'Last), Objects); + + begin + if Src_Path_Name /= null and then + Lib_Path_Name /= null + then + Add_Search_Dirs (Src_Path_Name, Include); + Add_Search_Dirs (Lib_Path_Name, Objects); + + elsif Src_Path_Name = null + and Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude and adalib directories"); + + elsif Src_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude directory"); + + elsif Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adalib directory"); + end if; + end; + end if; + else Fail ("unknown switch: ", Argv); end if; -- If we have seen a regular switch process it ! elsif Argv (1) = '-' then if Argv'Length = 1 then Fail ("switch character cannot be followed by a blank"); *************** package body Make is *** 4394,4404 **** null; -- If -gnath is present, then generate the usage information ! -- right now for the compiler, and do not pass this option ! -- on to the compiler calls. elsif Argv = "-gnath" then ! null; -- If -gnatc is specified, make sure the bind step and the link -- step are not executed. --- 4620,4629 ---- null; -- If -gnath is present, then generate the usage information ! -- right now and do not pass this option on to the compiler calls. elsif Argv = "-gnath" then ! Usage; -- If -gnatc is specified, make sure the bind step and the link -- step are not executed. *************** package body Make is *** 4433,4443 **** -- By default all switches with more than one character -- or one character switches which are not in 'a' .. 'z' ! -- (except 'M') are passed to the compiler, unless we are dealing ! -- with a debug switch (starts with 'd') elsif Argv (2) /= 'd' and then Argv (2 .. Argv'Last) /= "M" and then (Argv'Length > 2 or else Argv (2) not in 'a' .. 'z') then Add_Switch (Argv, Compiler, And_Save => And_Save); --- 4658,4669 ---- -- By default all switches with more than one character -- or one character switches which are not in 'a' .. 'z' ! -- (except 'C' and 'M') are passed to the compiler, unless we are ! -- dealing with a debug switch (starts with 'd') elsif Argv (2) /= 'd' and then Argv (2 .. Argv'Last) /= "M" + and then Argv (2 .. Argv'Last) /= "C" and then (Argv'Length > 2 or else Argv (2) not in 'a' .. 'z') then Add_Switch (Argv, Compiler, And_Save => And_Save); *************** package body Make is *** 4451,4457 **** -- If not a switch it must be a file name else ! Set_Main_File_Name (Argv); end if; end Scan_Make_Arg; --- 4677,4683 ---- -- If not a switch it must be a file name else ! Add_File (Argv); end if; end Scan_Make_Arg; *************** package body Make is *** 4674,4680 **** (Index => Name_Find, In_Array => Switches_Array); ! if Switches = Nil_Variable_Value then Last := Source_File_Name'Length; while Name (Last) /= '.' loop --- 4900,4908 ---- (Index => Name_Find, In_Array => Switches_Array); ! if Switches = Nil_Variable_Value ! and then Allow_ALI ! then Last := Source_File_Name'Length; while Name (Last) /= '.' loop *************** package body Make is *** 4684,4693 **** Name (Last + 1 .. Last + 3) := "ali"; Name_Len := Last + 3; Name_Buffer (1 .. Name_Len) := Name (1 .. Name_Len); ! Switches := ! Prj.Util.Value_Of ! (Index => Name_Find, ! In_Array => Switches_Array); end if; end if; end; --- 4912,4921 ---- Name (Last + 1 .. Last + 3) := "ali"; Name_Len := Last + 3; Name_Buffer (1 .. Name_Len) := Name (1 .. Name_Len); ! Switches := ! Prj.Util.Value_Of ! (Index => Name_Find, ! In_Array => Switches_Array); end if; end if; end; *************** package body Make is *** 4705,4711 **** -- Test_If_Relative_Path -- --------------------------- ! procedure Test_If_Relative_Path (Switch : String_Access) is begin if Switch /= null then --- 4933,4942 ---- -- Test_If_Relative_Path -- --------------------------- ! procedure Test_If_Relative_Path ! (Switch : in out String_Access; ! Parent : String_Access) ! is begin if Switch /= null then *************** package body Make is *** 4735,4761 **** then Start := 4; else return; end if; if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then ! Fail ("relative search path switches (""" & ! Sw & """) are not allowed when using project files"); end if; end if; end; end if; end Test_If_Relative_Path; ! ------------ ! -- Unmark -- ! ------------ ! procedure Unmark (Source_File : File_Name_Type) is begin ! Set_Name_Table_Byte (Source_File, 0); ! end Unmark; ----------------- -- Verbose_Msg -- --- 4966,5009 ---- then Start := 4; + elsif Sw'Length >= 7 + and then Sw (2 .. 6) = "-RTS=" + then + Start := 7; else return; end if; if not Is_Absolute_Path (Sw (Start .. Sw'Last)) then ! if Parent = null then ! Fail ("relative search path switches (""" & Sw & ! """) are not allowed inside project files"); ! ! else ! Switch := ! new String' ! (Sw (1 .. Start - 1) & ! Parent.all & ! Directory_Separator & ! Sw (Start .. Sw'Last)); ! end if; end if; end if; end; end if; end Test_If_Relative_Path; ! ----------- ! -- Usage -- ! ----------- ! procedure Usage is begin ! if Usage_Needed then ! Usage_Needed := False; ! Makeusg; ! end if; ! end Usage; ----------------- -- Verbose_Msg -- diff -Nrc3pad gcc-3.2.3/gcc/ada/make.ads gcc-3.3/gcc/ada/make.ads *** gcc-3.2.3/gcc/ada/make.ads 2002-05-04 03:28:19.000000000 +0000 --- gcc-3.3/gcc/ada/make.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/Makefile.adalib gcc-3.3/gcc/ada/Makefile.adalib *** gcc-3.2.3/gcc/ada/Makefile.adalib 2001-12-04 23:13:07.000000000 +0000 --- gcc-3.3/gcc/ada/Makefile.adalib 2002-05-16 17:42:35.000000000 +0000 *************** *** 42,51 **** # updating the value of the environment variable ADA_OBJECTS_PATH SHELL=sh CC = gcc AR = ar ! GNAT_ROOT = $(shell cd $(ROOT);pwd)/ target = $(shell $(CC) -dumpmachine) version = $(shell $(CC) -dumpversion) ADA_INCLUDE_PATH = $(GNAT_ROOT)lib/gcc-lib/$(target)/$(version)/adainclude/ --- 42,52 ---- # updating the value of the environment variable ADA_OBJECTS_PATH SHELL=sh + PWD=$${PWDCMD-pwd} CC = gcc AR = ar ! GNAT_ROOT = $(shell cd $(ROOT);${PWD})/ target = $(shell $(CC) -dumpmachine) version = $(shell $(CC) -dumpversion) ADA_INCLUDE_PATH = $(GNAT_ROOT)lib/gcc-lib/$(target)/$(version)/adainclude/ diff -Nrc3pad gcc-3.2.3/gcc/ada/Makefile.in gcc-3.3/gcc/ada/Makefile.in *** gcc-3.2.3/gcc/ada/Makefile.in 2003-03-28 10:38:19.000000000 +0000 --- gcc-3.3/gcc/ada/Makefile.in 2003-03-27 21:48:10.000000000 +0000 *************** *** 1,5 **** # Makefile for GNU Ada Compiler (GNAT). ! # Copyright (C) 1994-2001 Free Software Foundation, Inc. #This file is part of GNU CC. --- 1,5 ---- # Makefile for GNU Ada Compiler (GNAT). ! # Copyright (C) 1994-2002 Free Software Foundation, Inc. #This file is part of GNU CC. *************** *** 67,73 **** # Variables that exist for you to override. # See below for how to change them for certain systems. - ALLOCA = # Various ways of specifying flags for compilations: # CFLAGS is for the user to override to, e.g., do a bootstrap with -O2. # BOOT_CFLAGS is the value of CFLAGS to pass --- 67,72 ---- *************** T_CFLAGS = *** 83,88 **** --- 82,90 ---- X_CPPFLAGS = T_CPPFLAGS = + X_ADA_CFLAGS = + T_ADA_CFLAGS = + X_ADAFLAGS = T_ADAFLAGS = *************** AR_FLAGS = rc *** 112,134 **** RANLIB = ranlib # Test to use to see whether ranlib exists on the system. RANLIB_TEST = [ -f /usr/bin/ranlib -o -f /bin/ranlib ] ! SHELL = /bin/sh # How to copy preserving the date INSTALL_DATA_DATE = cp -p MAKEINFO = makeinfo TEXI2DVI = texi2dvi GNATBIND = $(STAGE_PREFIX)gnatbind -C ADA_CFLAGS = ADAFLAGS = -W -Wall -gnatpg -gnata SOME_ADAFLAGS =-gnata FORCE_DEBUG_ADAFLAGS = -g GNATLIBFLAGS = -gnatpg ! GNATLIBCFLAGS= -g -O2 ! ALL_ADAFLAGS = $(CFLAGS) $(ADA_CFLAGS) $(X_ADAFLAGS) $(T_ADAFLAGS) $(ADAFLAGS) ! MOST_ADAFLAGS = $(CFLAGS) $(ADA_CFLAGS) $(X_ADAFLAGS) $(T_ADAFLAGS) \ $(SOME_ADAFLAGS) ! THREAD_KIND=native ! GMEM_LIB= MISCLIB = objext = .o --- 114,143 ---- RANLIB = ranlib # Test to use to see whether ranlib exists on the system. RANLIB_TEST = [ -f /usr/bin/ranlib -o -f /bin/ranlib ] ! SHELL = @SHELL@ ! PWD = $${PWDCMD-pwd} # How to copy preserving the date INSTALL_DATA_DATE = cp -p MAKEINFO = makeinfo TEXI2DVI = texi2dvi GNATBIND = $(STAGE_PREFIX)gnatbind -C + GNATBIND_FLAGS = -static -x ADA_CFLAGS = ADAFLAGS = -W -Wall -gnatpg -gnata SOME_ADAFLAGS =-gnata FORCE_DEBUG_ADAFLAGS = -g GNATLIBFLAGS = -gnatpg ! GNATLIBCFLAGS = -g -O2 ! GNATLIBCFLAGS_FOR_C = $(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -fexceptions \ ! -DIN_RTS ! ALL_ADA_CFLAGS = $(X_ADA_CFLAGS) $(T_ADA_CFLAGS) $(ADA_CFLAGS) ! ALL_ADAFLAGS = $(CFLAGS) $(ALL_ADA_CFLAGS) $(X_ADAFLAGS) $(T_ADAFLAGS) \ ! $(ADAFLAGS) ! MOST_ADAFLAGS = $(CFLAGS) $(ALL_ADA_CFLAGS) $(X_ADAFLAGS) $(T_ADAFLAGS) \ $(SOME_ADAFLAGS) ! THREAD_KIND = native ! THREADSLIB = ! GMEM_LIB = MISCLIB = objext = .o *************** P = *** 154,160 **** # This is used instead of ALL_CFLAGS when compiling with GCC_FOR_TARGET. # It omits XCFLAGS, and specifies -B./. # It also specifies -B$(tooldir)/ to find as and ld for a cross compiler. ! GCC_CFLAGS=$(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS) # Tools to use when building a cross-compiler. # These are used because `configure' appends `cross-make' --- 163,169 ---- # This is used instead of ALL_CFLAGS when compiling with GCC_FOR_TARGET. # It omits XCFLAGS, and specifies -B./. # It also specifies -B$(tooldir)/ to find as and ld for a cross compiler. ! GCC_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS) # Tools to use when building a cross-compiler. # These are used because `configure' appends `cross-make' *************** target=@target@ *** 170,175 **** --- 179,185 ---- target_alias=@target_alias@ xmake_file=@dep_host_xmake_file@ tmake_file=@dep_tmake_file@ + host_canonical=@host_canonical@ #version=`sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < $(srcdir)/version.c` #mainversion=`sed -e 's/.*\"\([0-9]*\.[0-9]*\).*/\1/' < $(srcdir)/version.c` *************** tmake_file=@dep_tmake_file@ *** 177,213 **** srcdir = @srcdir@ VPATH = @srcdir@ ! MACHMODE_H = $(srcdir)/../machmode.h $(srcdir)/../machmode.def ! RTL_H = $(srcdir)/../rtl.h $(srcdir)/../rtl.def $(MACHMODE_H) ! TREE_H = $(srcdir)/../tree.h $(srcdir)/../real.h $(srcdir)/../tree.def \ ! $(MACHMODE_H) $(srcdir)/../tree-check.h $(srdir)/../version.h \ ! $(srcdir)/../builtins.def ! ! fsrcdir:=$(shell cd $(srcdir);pwd) ! fsrcpfx:=$(shell cd $(srcdir);pwd)/ ! fcurdir:=$(shell pwd) ! fcurpfx:=$(shell pwd)/ # Top build directory, relative to here. top_builddir = .. # Internationalization library. INTLLIBS = @INTLLIBS@ # Any system libraries needed just for GNAT. SYSLIBS = @GNAT_LIBEXC@ # List of extra object files linked in with various programs. - EXTRA_GNAT1_OBJS = ../prefix.o - EXTRA_GNATBIND_OBJS = ../prefix.o EXTRA_GNATTOOLS_OBJS = ../prefix.o # List extra gnattools EXTRA_GNATTOOLS = - # List of target dependent sources, overridden below as necessary - TARGET_ADA_SRCS = - # End of variables for you to override. # Definition of `all' is here so that new rules inserted by sed --- 187,213 ---- srcdir = @srcdir@ VPATH = @srcdir@ ! fsrcdir := $(shell cd $(srcdir);${PWD}) ! fsrcpfx := $(shell cd $(srcdir);${PWD})/ ! fcurdir := $(shell ${PWD}) ! fcurpfx := $(shell ${PWD})/ # Top build directory, relative to here. top_builddir = .. # Internationalization library. INTLLIBS = @INTLLIBS@ + INTLDEPS = @INTLDEPS@ # Any system libraries needed just for GNAT. SYSLIBS = @GNAT_LIBEXC@ # List of extra object files linked in with various programs. EXTRA_GNATTOOLS_OBJS = ../prefix.o # List extra gnattools EXTRA_GNATTOOLS = # End of variables for you to override. # Definition of `all' is here so that new rules inserted by sed *************** ALL_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLA *** 241,255 **** # Likewise. ALL_CPPFLAGS = $(CPPFLAGS) $(X_CPPFLAGS) $(T_CPPFLAGS) - # Even if ALLOCA is set, don't use it if compiling with GCC. - # This is where we get libiberty.a from. LIBIBERTY = ../../libiberty/libiberty.a # How to link with both our special library facilities # and the system's installed libraries. LIBS = $(INTLLIBS) $(LIBIBERTY) $(SYSLIBS) ! LIBDEPS = $(INTLLIBS) $(LIBIBERTY) # Specify the directories to be searched for header files. # Both . and srcdir are used, in that order, --- 241,255 ---- # Likewise. ALL_CPPFLAGS = $(CPPFLAGS) $(X_CPPFLAGS) $(T_CPPFLAGS) # This is where we get libiberty.a from. LIBIBERTY = ../../libiberty/libiberty.a # How to link with both our special library facilities # and the system's installed libraries. LIBS = $(INTLLIBS) $(LIBIBERTY) $(SYSLIBS) ! LIBDEPS = $(INTLDEPS) $(LIBIBERTY) ! TOOLS_LIBS = ../../prefix.o ../../version.o $(LIBGNAT) \ ! ../../../libiberty/libiberty.a $(SYSLIBS) # Specify the directories to be searched for header files. # Both . and srcdir are used, in that order, *************** ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdi *** 272,278 **** # Always use -I$(srcdir)/config when compiling. .c.o: ! $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< .adb.o: $(ADAC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< .ads.o: --- 272,278 ---- # Always use -I$(srcdir)/config when compiling. .c.o: ! $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< .adb.o: $(ADAC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< .ads.o: *************** ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdi *** 284,767 **** # Lists of files for various purposes. - # Languages-specific object files for Ada. - # Object files for gnat1 from C sources. - GNAT1_C_OBJS = b_gnat1.o adaint.o cstreams.o cio.o targtyps.o decl.o \ - misc.o utils.o utils2.o trans.o cuintp.o argv.o raise.o \ - init.o tracebak.o - - # Object files from Ada sources that are used by gnat1 - - GNAT_ADA_OBJS = \ - ada.o a-charac.o a-chlat1.o a-except.o s-memory.o \ - s-traceb.o s-mastop.o s-except.o ali.o alloc.o atree.o butil.o casing.o \ - checks.o comperr.o csets.o cstand.o debug.o debug_a.o einfo.o elists.o \ - errout.o eval_fat.o exp_attr.o exp_ch11.o exp_ch12.o exp_ch13.o exp_ch2.o \ - exp_ch3.o exp_ch4.o exp_ch5.o exp_ch6.o exp_ch7.o exp_ch8.o exp_ch9.o \ - exp_code.o exp_dbug.o exp_disp.o exp_dist.o exp_fixd.o exp_aggr.o exp_imgv.o \ - exp_intr.o exp_pakd.o exp_prag.o exp_smem.o \ - exp_strm.o exp_tss.o exp_util.o exp_vfpt.o expander.o fname.o fname-uf.o \ - fmap.o freeze.o frontend.o gnat.o g-hesora.o g-htable.o g-os_lib.o \ - g-speche.o s-crc32.o get_targ.o gnatvsn.o \ - hlo.o hostparm.o impunit.o \ - interfac.o itypes.o inline.o krunch.o lib.o \ - layout.o lib-load.o lib-util.o lib-xref.o lib-writ.o live.o \ - namet.o nlists.o nmake.o opt.o osint.o output.o par.o \ - repinfo.o restrict.o rident.o rtsfind.o \ - s-assert.o s-parame.o s-stache.o s-stalib.o \ - s-imgenu.o s-stoele.o s-soflin.o \ - s-exctab.o s-secsta.o s-wchcnv.o s-wchcon.o s-wchjis.o s-unstyp.o \ - scans.o scn.o sdefault.o sem.o sem_aggr.o \ - sem_attr.o sem_cat.o sem_ch10.o sem_ch11.o sem_ch12.o sem_ch13.o sem_ch2.o \ - sem_ch3.o sem_ch4.o sem_ch5.o sem_ch6.o sem_ch7.o sem_ch8.o sem_ch9.o \ - sem_case.o sem_disp.o sem_dist.o \ - sem_elab.o sem_elim.o sem_eval.o sem_intr.o \ - sem_maps.o sem_mech.o sem_prag.o sem_res.o \ - sem_smem.o sem_type.o sem_util.o sem_vfpt.o sem_warn.o \ - sinfo-cn.o sinfo.o sinput.o sinput-l.o snames.o sprint.o stand.o stringt.o \ - style.o switch.o stylesw.o validsw.o system.o \ - table.o targparm.o tbuild.o tree_gen.o tree_io.o treepr.o treeprs.o \ - ttypef.o ttypes.o types.o uintp.o uname.o urealp.o usage.o widechar.o - # Object files for gnat executables - GNAT1_ADA_OBJS = $(GNAT_ADA_OBJS) back_end.o gnat1drv.o - GNAT1_OBJS = $(GNAT1_C_OBJS) $(GNAT1_ADA_OBJS) $(EXTRA_GNAT1_OBJS) - GNATBIND_OBJS = \ - link.o ada.o adaint.o cstreams.o cio.o ali.o ali-util.o \ - alloc.o bcheck.o binde.o \ - binderr.o bindgen.o bindusg.o \ - butil.o casing.o csets.o \ - debug.o fmap.o fname.o gnat.o g-hesora.o g-htable.o \ - g-os_lib.o gnatbind.o gnatvsn.o hostparm.o \ - krunch.o namet.o opt.o osint.o output.o rident.o s-crc32.o s-assert.o \ - s-parame.o s-sopco3.o s-sopco4.o s-sopco5.o s-stache.o s-stalib.o \ - s-stoele.o s-imgenu.o s-strops.o s-soflin.o s-wchcon.o s-wchjis.o \ - sdefault.o switch.o stylesw.o validsw.o \ - system.o table.o tree_io.o types.o widechar.o \ - raise.o exit.o argv.o init.o adafinal.o s-wchcnv.o s-exctab.o \ - a-except.o s-memory.o s-traceb.o tracebak.o s-mastop.o s-except.o \ - s-secsta.o $(EXTRA_GNATBIND_OBJS) - - GNATCHOP_RTL_OBJS = adaint.o argv.o cio.o cstreams.o exit.o \ - adafinal.o init.o raise.o sysdep.o ada.o a-comlin.o gnat.o a-string.o \ - a-stmaco.o a-strsea.o a-charac.o a-chlat1.o g-except.o s-io.o \ - a-chahan.o a-strunb.o a-strfix.o a-strmap.o g-casuti.o g-comlin.o hostparm.o \ - g-dirope.o g-hesora.o g-htable.o g-regexp.o interfac.o system.o s-assert.o \ - s-parame.o i-cstrea.o s-exctab.o a-ioexce.o s-except.o s-stache.o s-stoele.o \ - s-imgint.o a-tags.o a-stream.o s-strops.o s-sopco3.o s-bitops.o \ - s-sopco4.o s-sopco5.o s-imgenu.o s-soflin.o s-secsta.o a-except.o \ - s-mastop.o s-stalib.o g-os_lib.o s-unstyp.o s-stratt.o s-finroo.o s-finimp.o \ - tracebak.o s-memory.o s-traceb.o a-finali.o a-filico.o s-ficobl.o s-fileio.o \ - a-textio.o s-valuti.o s-valuns.o s-valint.o s-arit64.o - - GNATCHOP_OBJS = gnatchop.o gnatvsn.o \ - $(GNATCHOP_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) - - GNATCMD_RTL_OBJS = adaint.o argv.o raise.o exit.o adafinal.o init.o \ - ada.o a-charac.o a-chahan.o a-comlin.o cstreams.o cio.o \ - a-except.o tracebak.o s-memory.o s-traceb.o s-mastop.o s-except.o \ - a-finali.o a-filico.o a-ioexce.o a-stream.o \ - a-string.o a-strmap.o a-stmaco.o g-htable.o \ - sysdep.o a-tags.o a-textio.o gnat.o g-hesora.o g-os_lib.o \ - interfac.o i-cstrea.o system.o s-assert.o s-bitops.o g-except.o s-exctab.o \ - s-ficobl.o s-fileio.o s-finimp.o s-finroo.o s-imgint.o s-imguns.o \ - s-parame.o s-secsta.o s-stalib.o s-imgenu.o s-stoele.o s-stratt.o \ - s-stache.o s-sopco3.o s-sopco4.o s-sopco5.o \ - s-strops.o s-soflin.o s-wchcon.o s-wchcnv.o s-wchjis.o s-unstyp.o - - GNATCMD_OBJS = alloc.o debug.o fmap.o fname.o gnatcmd.o gnatvsn.o hostparm.o \ - krunch.o namet.o opt.o osint.o casing.o csets.o widechar.o \ - output.o sdefault.o switch.o stylesw.o validsw.o table.o tree_io.o types.o \ - $(GNATCMD_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) - - GNATKR_RTL_OBJS = ada.o a-charac.o a-chahan.o a-chlat1.o a-comlin.o \ - cstreams.o a-finali.o \ - a-string.o a-strmap.o a-stmaco.o a-stream.o a-tags.o \ - gnat.o g-hesora.o g-htable.o interfac.o \ - system.o s-bitops.o g-except.o s-finimp.o s-io.o s-parame.o s-secsta.o \ - s-stopoo.o s-sopco3.o s-sopco4.o s-sopco5.o s-stache.o \ - s-stoele.o s-soflin.o s-stalib.o s-unstyp.o adaint.o \ - raise.o exit.o argv.o cio.o init.o adafinal.o s-finroo.o \ - a-except.o tracebak.o s-memory.o s-traceb.o s-mastop.o s-except.o \ - a-filico.o s-strops.o s-stratt.o s-imgenu.o a-ioexce.o s-exctab.o - GNATKR_OBJS = gnatkr.o gnatvsn.o \ - krunch.o hostparm.o $(GNATKR_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) - - GNATLINK_RTL_OBJS = \ - adaint.o argv.o cio.o cstreams.o \ - exit.o init.o adafinal.o raise.o tracebak.o \ - ada.o a-comlin.o a-except.o \ - gnat.o g-hesora.o g-htable.o g-os_lib.o \ - interfac.o i-cstrea.o \ - system.o s-assert.o s-except.o s-exctab.o s-mastop.o \ - s-parame.o s-secsta.o s-soflin.o s-sopco3.o s-sopco4.o \ - s-stache.o s-stalib.o s-stoele.o s-imgenu.o s-strops.o \ - s-memory.o s-traceb.o s-wchcnv.o s-wchcon.o s-wchjis.o - GNATLINK_OBJS = gnatlink.o link.o \ ! alloc.o debug.o fmap.o gnatvsn.o hostparm.o namet.o \ ! opt.o osint.o output.o sdefault.o stylesw.o validsw.o \ ! switch.o table.o tree_io.o types.o widechar.o \ ! $(GNATLINK_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) ! ! GNATLS_RTL_OBJS = \ ! ada.o \ ! adaint.o \ ! argv.o \ ! a-charac.o \ ! a-chahan.o \ ! cio.o \ ! a-comlin.o \ ! cstreams.o \ ! a-except.o \ ! exit.o \ ! a-filico.o \ ! adafinal.o \ ! a-finali.o \ ! init.o \ ! a-ioexce.o \ ! raise.o \ ! a-stmaco.o \ ! a-stream.o \ ! a-strfix.o \ ! a-string.o \ ! a-strmap.o \ ! a-strsea.o \ ! a-strunb.o \ ! sysdep.o \ ! a-tags.o \ ! a-textio.o \ ! tracebak.o \ ! gnat.o \ ! g-casuti.o \ ! g-dirope.o \ ! g-except.o \ ! g-hesora.o \ ! g-htable.o \ ! g-os_lib.o \ ! g-regexp.o \ ! interfac.o \ ! i-cstrea.o \ ! system.o \ ! s-assert.o \ ! s-bitops.o \ ! s-crc32.o \ ! s-except.o \ ! s-exctab.o \ ! s-finroo.o \ ! s-finimp.o \ ! s-ficobl.o \ ! s-fileio.o \ ! s-imgenu.o \ ! s-imgint.o \ ! s-io.o \ ! s-mastop.o \ ! s-parame.o \ ! s-secsta.o \ ! s-soflin.o \ ! s-sopco3.o \ ! s-sopco4.o \ ! s-sopco5.o \ ! s-stache.o \ ! s-stalib.o \ ! s-stoele.o \ ! s-stratt.o \ ! s-strops.o \ ! s-memory.o \ ! s-traceb.o \ ! s-valenu.o \ ! s-valuti.o \ ! s-wchcnv.o \ ! s-wchcon.o \ ! s-wchjis.o ! ! GNATLS_OBJS = \ ! ali.o \ ! ali-util.o \ ! alloc.o \ ! atree.o \ ! binderr.o \ ! butil.o \ ! casing.o \ ! csets.o \ ! debug.o \ ! einfo.o \ ! elists.o \ ! errout.o \ ! fmap.o \ ! fname.o \ ! gnatls.o \ ! gnatvsn.o \ ! hostparm.o \ ! krunch.o \ ! lib.o \ ! mlib.o \ ! mlib-fil.o \ ! mlib-tgt.o \ ! mlib-utl.o \ ! namet.o \ ! nlists.o \ ! opt.o \ ! osint.o \ ! output.o \ ! prj.o \ ! prj-attr.o \ ! prj-com.o \ ! prj-dect.o \ ! prj-env.o \ ! prj-ext.o \ ! prj-nmsc.o \ ! prj-pars.o \ ! prj-part.o \ ! prj-proc.o \ ! prj-strt.o \ ! prj-tree.o \ ! prj-util.o \ ! rident.o \ ! scans.o \ ! scn.o \ ! sdefault.o \ ! sinfo.o \ ! sinfo-cn.o \ ! sinput.o \ ! sinput-p.o \ ! snames.o \ ! stand.o \ ! stringt.o \ ! style.o \ ! stylesw.o \ ! validsw.o \ ! switch.o \ ! table.o \ ! tree_io.o \ ! uintp.o \ ! uname.o \ ! urealp.o \ ! types.o \ ! widechar.o $(GNATLS_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) ! ! GNATMAKE_RTL_OBJS = adaint.o argv.o raise.o exit.o a-comlin.o \ ! cio.o cstreams.o a-except.o s-mastop.o s-except.o adafinal.o init.o \ ! a-finali.o a-filico.o s-finroo.o s-finimp.o s-ficobl.o\ ! a-charac.o a-chahan.o a-string.o a-strfix.o a-strmap.o a-strunb.o \ ! a-stmaco.o a-strsea.o a-textio.o s-bitops.o sysdep.o \ ! s-imgint.o s-stratt.o \ ! a-tags.o a-stream.o \ ! a-ioexce.o \ ! tracebak.o s-memory.o s-traceb.o \ ! gnat.o g-dirope.o g-os_lib.o g-hesora.o g-except.o \ ! i-cstrea.o \ ! s-parame.o s-stache.o s-stalib.o s-wchcon.o s-wchjis.o \ ! s-imgenu.o s-assert.o s-secsta.o s-stoele.o s-soflin.o s-fileio.o \ ! s-valenu.o s-valuti.o g-casuti.o \ ! system.o s-exctab.o s-strops.o s-sopco3.o s-sopco4.o s-sopco5.o \ ! g-htable.o s-io.o g-regexp.o s-crc32.o s-wchcnv.o GNATMAKE_OBJS = ali.o ali-util.o \ alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o einfo.o elists.o \ errout.o fmap.o fname.o fname-uf.o fname-sf.o \ gnatmake.o gnatvsn.o hostparm.o krunch.o lib.o make.o makeusg.o \ mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o mlib-utl.o \ ! namet.o nlists.o opt.o osint.o output.o \ prj.o prj-attr.o prj-com.o prj-dect.o prj-env.o prj-ext.o prj-nmsc.o \ prj-pars.o prj-part.o prj-proc.o prj-strt.o prj-tree.o prj-util.o \ rident.o scans.o scn.o sdefault.o sfn_scan.o sinfo.o sinfo-cn.o \ sinput.o sinput-l.o sinput-p.o \ ! snames.o stand.o stringt.o style.o stylesw.o validsw.o switch.o\ ! table.o tree_io.o types.o \ ! uintp.o uname.o urealp.o usage.o widechar.o \ ! $(GNATMAKE_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) ! ! GNATMEM_RTL_OBJS = \ ! adaint.o \ ! argv.o \ ! cio.o \ ! cstreams.o \ ! exit.o \ ! adafinal.o \ ! init.o \ ! raise.o \ ! sysdep.o \ ! ada.o \ ! a-comlin.o \ ! a-except.o \ ! a-filico.o \ ! a-finali.o \ ! a-flteio.o \ ! a-inteio.o \ ! a-ioexce.o \ ! a-stream.o \ ! a-tags.o \ ! a-textio.o \ ! a-tiflau.o \ ! a-tigeau.o \ ! a-tiinau.o \ ! a-tiocst.o \ ! gnat.o \ ! g-casuti.o \ ! g-hesora.o \ ! g-htable.o \ ! g-os_lib.o \ ! gnatvsn.o \ ! interfac.o \ ! i-cstrea.o \ ! system.o \ ! s-assert.o \ ! s-except.o \ ! s-exctab.o \ ! s-exngen.o \ ! s-exnllf.o \ ! s-fatllf.o \ ! s-ficobl.o \ ! s-fileio.o \ ! s-finimp.o \ ! s-finroo.o \ ! s-imgbiu.o \ ! s-imgenu.o \ ! s-imgint.o \ ! s-imgllb.o \ ! s-imglli.o \ ! s-imgllu.o \ ! s-imgllw.o \ ! s-imgrea.o \ ! s-imguns.o \ ! s-imgwiu.o \ ! tracebak.o \ ! s-memory.o \ ! s-traceb.o \ ! s-mastop.o \ ! s-parame.o \ ! s-powtab.o \ ! s-secsta.o \ ! s-sopco3.o \ ! s-sopco4.o \ ! s-sopco5.o \ ! s-stache.o \ ! s-stalib.o \ ! s-stoele.o \ ! s-stratt.o \ ! s-strops.o \ ! s-soflin.o \ ! s-unstyp.o \ ! s-valllu.o \ ! s-vallli.o \ ! s-valint.o \ ! s-valrea.o \ ! s-valuns.o \ ! s-valuti.o ! GNATMEM_OBJS = gnatmem.o memroot.o gmem.o \ ! $(GNATMEM_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) ! ! GNATPREP_RTL_OBJS = adaint.o argv.o raise.o exit.o adafinal.o init.o \ ! ada.o a-charac.o a-chahan.o a-comlin.o cstreams.o cio.o \ ! a-except.o tracebak.o s-memory.o s-traceb.o s-mastop.o s-except.o \ ! a-finali.o a-filico.o a-ioexce.o a-stream.o a-string.o a-strmap.o \ ! a-stmaco.o a-strfix.o s-imgenu.o a-strsea.o a-strunb.o \ ! sysdep.o a-tags.o a-textio.o gnat.o g-hesora.o s-io.o \ ! g-casuti.o g-dirope.o g-os_lib.o g-regexp.o g-comlin.o i-cstrea.o \ ! system.o s-bitops.o g-except.o s-exctab.o s-ficobl.o s-fileio.o s-finimp.o \ ! s-finroo.o s-imgint.o s-parame.o s-secsta.o s-stache.o s-stalib.o \ ! s-stoele.o s-sopco3.o s-sopco4.o s-sopco5.o s-arit64.o \ ! s-stratt.o s-strops.o s-soflin.o s-unstyp.o ! ! GNATPREP_OBJS = gnatprep.o gnatvsn.o \ ! hostparm.o $(GNATPREP_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) ! ! GNATPSTA_RTL_OBJS = adaint.o argv.o cstreams.o cio.o \ ! deftarg.o a-except.o targtyps.o tracebak.o s-memory.o s-traceb.o \ ! s-mastop.o s-except.o exit.o a-filico.o adafinal.o a-finali.o init.o \ ! a-ioexce.o raise.o a-stream.o get_targ.o gnat.o g-hesora.o \ ! sysdep.o a-tags.o a-textio.o i-cstrea.o system.o s-assert.o \ ! s-exctab.o s-fatllf.o s-ficobl.o s-fileio.o s-finimp.o s-finroo.o \ ! s-imgint.o s-imgrea.o s-imglli.o s-imgllu.o s-imguns.o s-parame.o \ ! s-powtab.o s-sopco3.o s-sopco4.o s-sopco5.o s-secsta.o s-stache.o \ ! s-stalib.o s-stoele.o s-stratt.o s-strops.o s-soflin.o \ ! s-imgenu.o g-htable.o ! ! GNATPSTA_OBJS = gnatpsta.o types.o ttypes.o \ ! gnatvsn.o ttypef.o $(GNATPSTA_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) ! ! GNATPSYS_RTL_OBJS = adaint.o argv.o cstreams.o cio.o \ ! a-except.o tracebak.o s-memory.o s-traceb.o s-mastop.o s-except.o exit.o \ ! a-filico.o adafinal.o a-finali.o init.o a-ioexce.o \ ! raise.o a-stream.o \ ! sysdep.o a-tags.o a-textio.o i-cstrea.o system.o s-assert.o \ ! gnat.o g-hesora.o g-htable.o s-imgenu.o \ ! s-exctab.o s-fatllf.o s-ficobl.o s-fileio.o s-finimp.o s-finroo.o \ ! s-imgint.o s-imgrea.o s-imglli.o s-imgllu.o s-imguns.o s-parame.o \ ! s-powtab.o s-secsta.o s-stache.o s-stalib.o s-stoele.o s-stratt.o \ ! s-strops.o s-soflin.o s-sopco3.o s-sopco4.o s-sopco5.o ! ! GNATPSYS_OBJS = gnatpsys.o \ ! gnatvsn.o $(GNATPSYS_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) ! ! GNATXREF_RTL_OBJS = \ ! adaint.o argv.o cio.o cstreams.o \ ! exit.o init.o adafinal.o raise.o sysdep.o tracebak.o \ ! ada.o a-charac.o a-chlat1.o gnat.o g-casuti.o g-hesora.o \ ! g-htable.o interfac.o system.o i-cstrea.o s-parame.o s-exctab.o \ ! a-ioexce.o a-string.o s-assert.o s-except.o \ ! s-imgenu.o s-stoele.o s-mastop.o \ ! s-imgint.o a-comlin.o s-soflin.o s-stache.o s-secsta.o s-stalib.o \ ! g-os_lib.o s-strops.o a-tags.o a-stream.o s-sopco3.o s-sopco4.o \ ! s-sopco5.o s-memory.o s-traceb.o a-except.o s-unstyp.o a-strmap.o \ ! a-stmaco.o s-io.o \ ! a-chahan.o a-strsea.o a-strfix.o s-stratt.o s-finroo.o g-except.o \ ! s-bitops.o s-finimp.o a-finali.o a-filico.o a-strunb.o g-dirope.o \ ! g-comlin.o s-ficobl.o s-fileio.o a-textio.o g-regexp.o g-io_aux.o \ ! s-valuti.o s-valuns.o s-valint.o s-wchcon.o s-wchjis.o s-wchcnv.o ! ! GNATXREF_OBJS = gnatxref.o xr_tabls.o xref_lib.o \ ! alloc.o debug.o fmap.o gnatvsn.o hostparm.o types.o output.o \ ! sdefault.o stylesw.o validsw.o tree_io.o opt.o table.o osint.o \ ! switch.o widechar.o namet.o \ ! $(GNATXREF_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) ! ! GNATFIND_RTL_OBJS = \ ! adaint.o argv.o cio.o cstreams.o \ ! exit.o init.o adafinal.o raise.o sysdep.o tracebak.o \ ! ada.o a-chahan.o a-charac.o a-chlat1.o a-comlin.o a-except.o \ ! a-filico.o a-finali.o a-ioexce.o a-stmaco.o a-stream.o \ ! a-strfix.o a-string.o a-strmap.o a-strsea.o a-strunb.o \ ! a-tags.o a-textio.o \ ! gnat.o g-casuti.o g-comlin.o g-dirope.o g-except.o \ ! g-hesora.o g-htable.o g-io_aux.o g-os_lib.o g-regexp.o \ ! interfac.o i-cstrea.o s-io.o \ ! system.o s-assert.o s-bitops.o s-except.o s-exctab.o \ ! s-imgenu.o s-ficobl.o s-fileio.o s-finimp.o s-finroo.o s-imgint.o \ ! s-mastop.o s-parame.o s-secsta.o s-soflin.o s-sopco3.o \ ! s-sopco4.o s-sopco5.o s-stache.o s-stalib.o s-stoele.o \ ! s-stratt.o s-strops.o s-memory.o s-traceb.o s-unstyp.o s-valint.o \ ! s-valuns.o s-valuti.o s-wchcnv.o s-wchcon.o s-wchjis.o ! ! GNATFIND_OBJS = gnatfind.o xr_tabls.o xref_lib.o \ ! alloc.o debug.o fmap.o gnatvsn.o hostparm.o namet.o opt.o \ ! osint.o output.o sdefault.o stylesw.o validsw.o switch.o table.o \ ! tree_io.o types.o widechar.o \ ! $(GNATFIND_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) ! ! GNATDLL_RTL_OBJS = \ ! adaint.o argv.o cio.o cstreams.o \ ! exit.o init.o adafinal.o raise.o sysdep.o tracebak.o \ ! a-charac.o a-chlat1.o a-chahan.o a-comlin.o a-except.o a-filico.o \ ! a-finali.o a-ioexce.o a-stream.o a-strfix.o a-string.o a-strmap.o \ ! a-strsea.o a-stmaco.o a-strunb.o a-tags.o a-textio.o ada.o \ ! g-casuti.o g-comlin.o g-dirope.o g-except.o g-hesora.o g-htable.o \ ! g-os_lib.o g-regexp.o gnat.o \ ! i-cstrea.o interfac.o s-io.o \ ! s-bitops.o s-except.o s-exctab.o s-ficobl.o s-fileio.o s-finimp.o \ ! s-finroo.o s-imgint.o s-mastop.o s-parame.o s-secsta.o s-soflin.o \ ! s-sopco3.o s-sopco4.o s-stache.o s-stalib.o s-stoele.o s-stratt.o \ ! s-strops.o s-memory.o s-traceb.o s-unstyp.o system.o ! ! GNATDLL_OBJS = \ ! gnatdll.o gnatvsn.o mdll.o mdllfile.o mdlltool.o sdefault.o types.o \ ! $(GNATDLL_RTL_OBJS) $(EXTRA_GNATTOOLS_OBJS) # Convert the target variable into a space separated list of architecture, # manufacturer, and operating system and assign each of those to its own # variable. targ:=$(subst -, ,$(target)) arch:=$(word 1,$(targ)) ifeq ($(words $(targ)),2) --- 284,314 ---- # Lists of files for various purposes. # Object files for gnat executables GNATLINK_OBJS = gnatlink.o link.o \ ! ali.o alloc.o butil.o casing.o csets.o debug.o fmap.o fname.o gnatvsn.o \ ! hostparm.o namet.o opt.o osint.o output.o rident.o sdefault.o stylesw.o \ ! switch.o table.o tree_io.o types.o validsw.o widechar.o GNATMAKE_OBJS = ali.o ali-util.o \ alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o einfo.o elists.o \ errout.o fmap.o fname.o fname-uf.o fname-sf.o \ gnatmake.o gnatvsn.o hostparm.o krunch.o lib.o make.o makeusg.o \ mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o mlib-utl.o \ ! namet.o nlists.o opt.o osint.o osint-m.o output.o \ prj.o prj-attr.o prj-com.o prj-dect.o prj-env.o prj-ext.o prj-nmsc.o \ prj-pars.o prj-part.o prj-proc.o prj-strt.o prj-tree.o prj-util.o \ rident.o scans.o scn.o sdefault.o sfn_scan.o sinfo.o sinfo-cn.o \ sinput.o sinput-l.o sinput-p.o \ ! snames.o stand.o stringt.o style.o stylesw.o validsw.o switch.o switch-m.o \ ! switch-c.o table.o targparm.o tree_io.o types.o \ ! uintp.o uname.o urealp.o usage.o widechar.o # Convert the target variable into a space separated list of architecture, # manufacturer, and operating system and assign each of those to its own # variable. + host:=$(subst -, ,$(host_canonical)) targ:=$(subst -, ,$(target)) arch:=$(word 1,$(targ)) ifeq ($(words $(targ)),2) *************** s-taspri.ads<5ntaspri.ads *** 792,806 **** # option will always be present and last in this flag, so that we can have # $(SO_OPTS)libgnat-x.xx ! SO_OPTS=-Wl,-soname, # Default gnatlib-shared target. # This is needed on some targets to use a different gnatlib-shared target, e.g # gnatlib-shared-dual ! GNATLIB_SHARED=gnatlib-shared-default # default value for gnatmake's target dependent file ! MLIB_TGT=mlib-tgt # $(filter-out PATTERN...,TEXT) removes all PATTERN words from TEXT. # $(strip STRING) removes leading and trailing spaces from STRING. --- 339,353 ---- # option will always be present and last in this flag, so that we can have # $(SO_OPTS)libgnat-x.xx ! SO_OPTS = -Wl,-soname, # Default gnatlib-shared target. # This is needed on some targets to use a different gnatlib-shared target, e.g # gnatlib-shared-dual ! GNATLIB_SHARED = gnatlib-shared-default # default value for gnatmake's target dependent file ! MLIB_TGT = mlib-tgt # $(filter-out PATTERN...,TEXT) removes all PATTERN words from TEXT. # $(strip STRING) removes leading and trailing spaces from STRING. *************** ifeq ($(strip $(filter-out %86 os2 OS2 o *** 831,841 **** i-os2thr.o endif ! ifeq ($(strip $(filter-out %86 interix,$(arch) $(osys))),) LIBGNAT_TARGET_PAIRS = \ a-intnam.ads<4pintnam.ads \ a-numaux.adb<86numaux.adb \ a-numaux.ads<86numaux.ads \ s-inmaop.adb<7sinmaop.adb \ s-intman.adb<7sintman.adb \ s-mastop.adb<5omastop.adb \ --- 378,390 ---- i-os2thr.o endif ! ifeq ($(strip $(filter-out %86 interix%,$(arch) $(osys))),) LIBGNAT_TARGET_PAIRS = \ + a-excpol.adb<4hexcpol.adb \ a-intnam.ads<4pintnam.ads \ a-numaux.adb<86numaux.adb \ a-numaux.ads<86numaux.ads \ + g-soccon.ads<3psoccon.ads \ s-inmaop.adb<7sinmaop.adb \ s-intman.adb<7sintman.adb \ s-mastop.adb<5omastop.adb \ *************** ifeq ($(strip $(filter-out %86 interix,$ *** 843,867 **** s-osinte.ads<5posinte.ads \ s-osprim.adb<5posprim.adb \ s-taprop.adb<7staprop.adb \ s-taspri.ads<7staspri.ads \ s-tpopsp.adb<7stpopsp.adb ! THREADSLIB=-lgthreads -lmalloc ! ! # Work around for gcc optimization bug wrt cxa5a09 ! a-numaux.o : a-numaux.adb a-numaux.ads ! $(ADAC) -c $(ALL_ADAFLAGS) -O2 $(ADA_INCLUDES) $< ! ! # Work around for gcc optimization bug wrt cxf3a01 ! a-teioed.o : a-teioed.adb a-teioed.ads ! $(ADAC) -c $(ALL_ADAFLAGS) -O0 $(ADA_INCLUDES) $< ! endif # sysv5uw is SCO UnixWare 7 ifeq ($(strip $(filter-out %86 sysv5uw%,$(arch) $(osys))),) LIBGNAT_TARGET_PAIRS = \ ! a-excpol.adb<4hexcpol.adb \ a-intnam.ads<41intnam.ads \ a-numaux.adb<86numaux.adb \ a-numaux.ads<86numaux.ads \ --- 392,408 ---- s-osinte.ads<5posinte.ads \ s-osprim.adb<5posprim.adb \ s-taprop.adb<7staprop.adb \ + system.ads<5psystem.ads \ s-taspri.ads<7staspri.ads \ s-tpopsp.adb<7stpopsp.adb ! THREADSLIB = -lgthreads -lmalloc endif # sysv5uw is SCO UnixWare 7 ifeq ($(strip $(filter-out %86 sysv5uw%,$(arch) $(osys))),) LIBGNAT_TARGET_PAIRS = \ ! a-excpol.adb<4wexcpol.adb \ a-intnam.ads<41intnam.ads \ a-numaux.adb<86numaux.adb \ a-numaux.ads<86numaux.ads \ *************** ifeq ($(strip $(filter-out %86 sysv5uw%, *** 874,935 **** s-taprop.adb<7staprop.adb \ s-taspri.ads<7staspri.ads \ s-tpopsp.adb<5atpopsp.adb \ g-soccon.ads<31soccon.ads \ g-soliop.ads<31soliop.ads ! THREADSLIB=-lthread ! SO_OPTS=-Wl,-h, ! GNATLIB_SHARED=gnatlib-shared-dual LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) endif - ifeq ($(strip $(filter-out sparc sun sunos4%,$(targ))),) - LIBGNAT_TARGET_PAIRS = \ - a-intnam.ads<4uintnam.ads \ - s-inmaop.adb<7sinmaop.adb \ - s-intman.adb<5uintman.adb \ - s-osinte.adb<7sosinte.adb \ - s-osinte.ads<5uosinte.ads \ - s-osprim.adb<5posprim.adb \ - s-taprop.adb<7staprop.adb \ - s-taspri.ads<7staspri.ads \ - s-tpopsp.adb<7stpopsp.adb - endif - - ifeq ($(strip $(filter-out alpha% dec vms%,$(targ))),) - LIBGNAT_TARGET_PAIRS = \ - a-caldel.adb<4vcaldel.adb \ - a-calend.adb<4vcalend.adb \ - a-calend.ads<4vcalend.ads \ - a-excpol.adb<4wexcpol.adb \ - a-intnam.ads<4vintnam.ads \ - i-cstrea.adb<6vcstrea.adb \ - i-cpp.adb<6vcpp.adb \ - interfac.ads<6vinterf.ads \ - s-asthan.adb<5vasthan.adb \ - s-inmaop.adb<5vinmaop.adb \ - s-interr.adb<5vinterr.adb \ - s-intman.adb<5vintman.adb \ - s-intman.ads<5vintman.ads \ - s-mastop.adb<5vmastop.adb \ - s-osinte.adb<5vosinte.adb \ - s-osinte.ads<5vosinte.ads \ - s-osprim.adb<5vosprim.adb \ - s-osprim.ads<5vosprim.ads \ - s-parame.ads<5vparame.ads \ - s-taprop.adb<5vtaprop.adb \ - s-taspri.ads<5vtaspri.ads \ - s-tpopde.adb<5vtpopde.adb \ - s-tpopde.ads<5vtpopde.ads \ - s-vaflop.adb<5vvaflop.adb \ - system.ads<5vsystem.ads - - GNATLIB_SHARED=gnatlib-shared-vms - EXTRA_LIBGNAT_SRCS=vmshandler.asm - EXTRA_LIBGNAT_OBJS=vmshandler.o - EXTRA_GNATRTL_TASKING_OBJS=s-tpopde.o - endif - ifeq ($(strip $(filter-out alpha% dec vx%,$(targ))),) LIBGNAT_TARGET_PAIRS = \ a-sytaco.ads<4zsytaco.ads \ --- 415,430 ---- s-taprop.adb<7staprop.adb \ s-taspri.ads<7staspri.ads \ s-tpopsp.adb<5atpopsp.adb \ + system.ads<51system.ads \ g-soccon.ads<31soccon.ads \ g-soliop.ads<31soliop.ads ! THREADSLIB = -lthread ! SO_OPTS = -Wl,-h, ! GNATLIB_SHARED = gnatlib-shared-dual LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) endif ifeq ($(strip $(filter-out alpha% dec vx%,$(targ))),) LIBGNAT_TARGET_PAIRS = \ a-sytaco.ads<4zsytaco.ads \ *************** ifeq ($(strip $(filter-out alpha% dec vx *** 943,953 **** s-osinte.ads<5zosinte.ads \ s-osprim.adb<5zosprim.adb \ s-taprop.adb<5ztaprop.adb \ ! s-taspri.ads<7staspri.ads \ s-vxwork.ads<5avxwork.ads \ system.ads<5zsystem.ads ! EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o endif --- 438,451 ---- s-osinte.ads<5zosinte.ads \ s-osprim.adb<5zosprim.adb \ s-taprop.adb<5ztaprop.adb \ ! s-taspri.ads<5ztaspri.ads \ s-vxwork.ads<5avxwork.ads \ + g-soccon.ads<3zsoccon.ads \ + g-socthi.ads<3zsocthi.ads \ + g-socthi.adb<3zsocthi.adb \ system.ads<5zsystem.ads ! EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o i-vxwoio.o EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o endif *************** ifeq ($(strip $(filter-out m68k% wrs vx% *** 963,980 **** s-osinte.adb<5zosinte.adb \ s-osinte.ads<5zosinte.ads \ s-osprim.adb<5zosprim.adb \ - s-parame.ads<5zparame.ads \ s-taprop.adb<5ztaprop.adb \ ! s-taspri.ads<7staspri.ads \ s-vxwork.ads<5kvxwork.ads \ system.ads<5ksystem.ads ! EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o ! # ??? work around a gcc -O2 bug on m68k ! s-interr.o : s-interr.adb s-interr.ads ! $(ADAC) -c $(ALL_ADAFLAGS) -O1 $(ADA_INCLUDES) $< endif ifeq ($(strip $(filter-out powerpc% wrs vx%,$(targ))),) --- 461,485 ---- s-osinte.adb<5zosinte.adb \ s-osinte.ads<5zosinte.ads \ s-osprim.adb<5zosprim.adb \ s-taprop.adb<5ztaprop.adb \ ! s-taspri.ads<5ztaspri.ads \ s-vxwork.ads<5kvxwork.ads \ + g-soccon.ads<3zsoccon.ads \ + g-socthi.ads<3zsocthi.ads \ + g-socthi.adb<3zsocthi.adb \ system.ads<5ksystem.ads ! EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o i-vxwoio.o EXTRA_GNATRTL_TASKING_OBJS=s-vxwork.o ! ifeq ($(strip $(filter-out yes,$(TRACE))),) ! LIBGNAT_TARGET_PAIRS += \ ! s-traces.adb<7straces.adb \ ! s-tratas.adb<7stratas.adb \ ! s-trafor.adb<7strafor.adb \ ! s-trafor.ads<7strafor.ads \ ! s-tfsetr.adb<5ztfsetr.adb ! endif endif ifeq ($(strip $(filter-out powerpc% wrs vx%,$(targ))),) *************** ifeq ($(strip $(filter-out powerpc% wrs *** 990,1017 **** s-osinte.ads<5zosinte.ads \ s-osprim.adb<5zosprim.adb \ s-taprop.adb<5ztaprop.adb \ ! s-taspri.ads<7staspri.ads \ s-vxwork.ads<5pvxwork.ads \ system.ads<5ysystem.ads - ifeq ($(strip $(filter-out vxworks6% vxworksae%,$(osys))),) - LIBGNAT_TARGET_PAIRS = \ - a-sytaco.ads<4zsytaco.ads \ - a-sytaco.adb<4zsytaco.adb \ - a-intnam.ads<4zintnam.ads \ - a-numaux.ads<4znumaux.ads \ - s-inmaop.adb<7sinmaop.adb \ - s-interr.adb<5zinterr.adb \ - s-intman.adb<5zintman.adb \ - s-osinte.adb<5zosinte.adb \ - s-osinte.ads<5zosinte.ads \ - s-osprim.adb<5zosprim.adb \ - s-taprop.adb<5ztaprop.adb \ - s-taspri.ads<7staspri.ads \ - s-vxwork.ads<5qvxwork.ads \ - system.ads<5ysystem.ads - endif - EXTRA_RAVEN_SOURCES=i-vxwork.ads s-vxwork.ads EXTRA_RAVEN_OBJS=i-vxwork.o s-vxwork.o EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o --- 495,507 ---- s-osinte.ads<5zosinte.ads \ s-osprim.adb<5zosprim.adb \ s-taprop.adb<5ztaprop.adb \ ! s-taspri.ads<5ztaspri.ads \ s-vxwork.ads<5pvxwork.ads \ + g-soccon.ads<3zsoccon.ads \ + g-socthi.ads<3zsocthi.ads \ + g-socthi.adb<3zsocthi.adb \ system.ads<5ysystem.ads EXTRA_RAVEN_SOURCES=i-vxwork.ads s-vxwork.ads EXTRA_RAVEN_OBJS=i-vxwork.o s-vxwork.o EXTRA_GNATRTL_NONTASKING_OBJS=i-vxwork.o *************** ifeq ($(strip $(filter-out sparc sun sol *** 1078,1088 **** g-soliop.ads<3ssoliop.ads \ system.ads<5ssystem.ads ! THREADSLIB=-lposix4 -lthread ! MISCLIB=-laddr2line -lbfd -lposix4 -lnsl -lsocket ! SO_OPTS=-Wl,-h, ! GNATLIB_SHARED=gnatlib-shared-dual ! GMEM_LIB=gmemlib LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) ifeq ($(strip $(filter-out fsu FSU,$(THREAD_KIND))),) --- 568,579 ---- g-soliop.ads<3ssoliop.ads \ system.ads<5ssystem.ads ! THREADSLIB = -lposix4 -lthread ! MISCLIB = -lposix4 -lnsl -lsocket ! SYMLIB = -laddr2line -lbfd $(INTLLIBS) ! SO_OPTS = -Wl,-h, ! GNATLIB_SHARED = gnatlib-shared-dual ! GMEM_LIB = gmemlib LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) ifeq ($(strip $(filter-out fsu FSU,$(THREAD_KIND))),) *************** ifeq ($(strip $(filter-out sparc sun sol *** 1100,1106 **** g-soliop.ads<3ssoliop.ads \ system.ads<5ssystem.ads ! THREADSLIB=-lgthreads -lmalloc endif ifeq ($(strip $(filter-out pthread PTHREAD,$(THREAD_KIND))),) --- 591,597 ---- g-soliop.ads<3ssoliop.ads \ system.ads<5ssystem.ads ! THREADSLIB = -lgthreads -lmalloc endif ifeq ($(strip $(filter-out pthread PTHREAD,$(THREAD_KIND))),) *************** ifeq ($(strip $(filter-out sparc sun sol *** 1118,1124 **** g-soliop.ads<3ssoliop.ads \ system.ads<5ssystem.ads ! THREADSLIB=-lposix4 -lpthread endif endif --- 609,615 ---- g-soliop.ads<3ssoliop.ads \ system.ads<5ssystem.ads ! THREADSLIB = -lposix4 -lpthread endif endif *************** ifeq ($(strip $(filter-out %86 solaris2% *** 1143,1157 **** g-soliop.ads<3ssoliop.ads \ system.ads<5esystem.ads ! THREADSLIB=-lposix4 -lthread ! MISCLIB=-lposix4 -lnsl -lsocket ! SO_OPTS=-Wl,-h, ! GNATLIB_SHARED=gnatlib-shared-dual LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) - - # ??? work around a gcc -O3 bug on x86 - a-numaux.o : a-numaux.adb a-numaux.ads - $(ADAC) -c $(ALL_ADAFLAGS) -O2 $(ADA_INCLUDES) $< endif ifeq ($(strip $(filter-out %86 linux%,$(arch) $(osys))),) --- 634,644 ---- g-soliop.ads<3ssoliop.ads \ system.ads<5esystem.ads ! THREADSLIB = -lposix4 -lthread ! MISCLIB = -lposix4 -lnsl -lsocket ! SO_OPTS = -Wl,-h, ! GNATLIB_SHARED = gnatlib-shared-dual LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) endif ifeq ($(strip $(filter-out %86 linux%,$(arch) $(osys))),) *************** ifeq ($(strip $(filter-out %86 linux%,$( *** 1167,1179 **** s-osprim.adb<7sosprim.adb \ s-taprop.adb<5itaprop.adb \ s-taspri.ads<5itaspri.ads \ system.ads<5lsystem.ads ! MLIB_TGT=5lml-tgt ! MISCLIB=-laddr2line -lbfd ! THREADSLIB=-lpthread ! GNATLIB_SHARED=gnatlib-shared-dual ! GMEM_LIB=gmemlib LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) ifeq ($(strip $(filter-out fsu FSU,$(THREAD_KIND))),) --- 654,667 ---- s-osprim.adb<7sosprim.adb \ s-taprop.adb<5itaprop.adb \ s-taspri.ads<5itaspri.ads \ + s-tpopsp.adb<5atpopsp.adb \ system.ads<5lsystem.ads ! TOOLS_TARGET_PAIRS = mlib-tgt.adb<5lml-tgt.adb ! SYMLIB = -laddr2line -lbfd $(INTLLIBS) ! THREADSLIB = -lpthread ! GNATLIB_SHARED = gnatlib-shared-dual ! GMEM_LIB = gmemlib LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) ifeq ($(strip $(filter-out fsu FSU,$(THREAD_KIND))),) *************** ifeq ($(strip $(filter-out %86 linux%,$( *** 1192,1198 **** s-tpopsp.adb<7stpopsp.adb \ system.ads<5lsystem.ads ! THREADSLIB=-lgthreads -lmalloc endif ifeq ($(strip $(filter-out rt-linux RT-LINUX,$(THREAD_KIND))),) --- 680,686 ---- s-tpopsp.adb<7stpopsp.adb \ system.ads<5lsystem.ads ! THREADSLIB = -lgthreads -lmalloc endif ifeq ($(strip $(filter-out rt-linux RT-LINUX,$(THREAD_KIND))),) *************** ifeq ($(strip $(filter-out %86 linux%,$( *** 1203,1216 **** s-osinte.adb<5qosinte.adb \ s-osinte.ads<5qosinte.ads \ s-osprim.adb<5qosprim.adb \ - s-parame.ads<5qparame.ads \ s-stache.adb<5qstache.adb \ s-taprop.adb<5qtaprop.adb \ s-taspri.ads<5qtaspri.ads \ system.ads<5lsystem.ads ! ! THREADSLIB= ! RT_FLAGS=-D__RT__ endif endif --- 691,702 ---- s-osinte.adb<5qosinte.adb \ s-osinte.ads<5qosinte.ads \ s-osprim.adb<5qosprim.adb \ s-stache.adb<5qstache.adb \ s-taprop.adb<5qtaprop.adb \ s-taspri.ads<5qtaspri.ads \ system.ads<5lsystem.ads ! ! RT_FLAGS = -D__RT__ endif endif *************** ifeq ($(strip $(filter-out mips sgi irix *** 1229,1241 **** s-taprop.adb<5ftaprop.adb \ s-tasinf.ads<5ftasinf.ads \ s-taspri.ads<7staspri.ads \ - s-tpgetc.adb<5gtpgetc.adb \ s-traceb.adb<7straceb.adb \ g-soccon.ads<3gsoccon.ads \ system.ads<5gsystem.ads ! THREADSLIB=-lpthread ! GMEM_LIB=gmemlib else LIBGNAT_TARGET_PAIRS = \ --- 715,725 ---- s-taprop.adb<5ftaprop.adb \ s-tasinf.ads<5ftasinf.ads \ s-taspri.ads<7staspri.ads \ s-traceb.adb<7straceb.adb \ g-soccon.ads<3gsoccon.ads \ system.ads<5gsystem.ads ! THREADSLIB = -lpthread else LIBGNAT_TARGET_PAIRS = \ *************** ifeq ($(strip $(filter-out mips sgi irix *** 1253,1282 **** s-tasinf.adb<5gtasinf.adb \ s-tasinf.ads<5gtasinf.ads \ s-taspri.ads<7staspri.ads \ - s-tpgetc.adb<5gtpgetc.adb \ s-traceb.adb<7straceb.adb \ g-soccon.ads<3gsoccon.ads \ system.ads<5fsystem.ads ! THREADSLIB=-lathread endif ! EXTRA_GNATRTL_TASKING_OBJS=s-tpgetc.o a-tcbinf.o ! MISCLIB=-lexc -laddr2line -lbfd ! SO_OPTS=-Wl,-all,-set_version,sgi1.0,-update_registry,../so_locations,-soname, LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) - - a-tcbinf.o: s-tpgetc.ali - ../../gnatbind -nostdlib -I- -I. s-tpgetc.ali - ../../gnatlink --GCC="../../xgcc -B../../" s-tpgetc.ali -o gen_tcbinf \ - $(LIBGNAT_OBJS) - ./gen_tcbinf - $(CC) -c -g a-tcbinf.c - $(RM) gen_tcbinf - - # force debug info so that workshop can find the All_Tasks_List symbol - s-taskin.o: s-taskin.adb s-taskin.ads - $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) $(ADA_INCLUDES) $< endif ifeq ($(strip $(filter-out hppa% hp hpux10%,$(targ))),) --- 737,753 ---- s-tasinf.adb<5gtasinf.adb \ s-tasinf.ads<5gtasinf.ads \ s-taspri.ads<7staspri.ads \ s-traceb.adb<7straceb.adb \ g-soccon.ads<3gsoccon.ads \ system.ads<5fsystem.ads ! THREADSLIB = -lathread endif ! TGT_LIB = -lexc ! MISCLIB = -lexc ! SO_OPTS = -Wl,-all,-set_version,sgi1.0,-update_registry,../so_locations,-soname, LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) endif ifeq ($(strip $(filter-out hppa% hp hpux10%,$(targ))),) *************** ifeq ($(strip $(filter-out hppa% hp hpux *** 1313,1322 **** g-soccon.ads<3hsoccon.ads \ system.ads<5hsystem.ads ! THREADSLIB=-lpthread -lc_r ! soext=.sl ! SO_OPTS=-Wl,+h, ! GNATLIB_SHARED=gnatlib-shared-dual ifeq ($(strip $(filter-out dce DCE,$(THREAD_KIND))),) LIBGNAT_TARGET_PAIRS = \ --- 784,795 ---- g-soccon.ads<3hsoccon.ads \ system.ads<5hsystem.ads ! TGT_LIB = /usr/lib/libcl.a ! THREADSLIB = -lpthread -lc_r ! SYMLIB = -laddr2line -lbfd $(INTLLIBS) ! soext = .sl ! SO_OPTS = -Wl,+h, ! GNATLIB_SHARED = gnatlib-shared-dual ifeq ($(strip $(filter-out dce DCE,$(THREAD_KIND))),) LIBGNAT_TARGET_PAIRS = \ *************** ifeq ($(strip $(filter-out hppa% hp hpux *** 1329,1341 **** s-osinte.ads<5hosinte.ads \ s-parame.ads<5hparame.ads \ s-osprim.adb<7sosprim.adb \ - s-traceb.adb<5htraceb.adb \ s-taprop.adb<5htaprop.adb \ s-taspri.ads<5htaspri.ads \ g-soccon.ads<3hsoccon.ads \ system.ads<5hsystem.ads ! THREADSLIB=-lcma endif endif --- 802,814 ---- s-osinte.ads<5hosinte.ads \ s-parame.ads<5hparame.ads \ s-osprim.adb<7sosprim.adb \ s-taprop.adb<5htaprop.adb \ s-taspri.ads<5htaspri.ads \ g-soccon.ads<3hsoccon.ads \ system.ads<5hsystem.ads ! TGT_LIB = ! THREADSLIB = -lcma endif endif *************** ifeq ($(strip $(filter-out ibm aix4%,$(m *** 1353,1359 **** g-soccon.ads<3bsoccon.ads \ system.ads<5bsystem.ads ! THREADSLIB=-lpthreads ifeq ($(strip $(filter-out fsu FSU,$(THREAD_KIND))),) LIBGNAT_TARGET_PAIRS = \ a-intnam.ads<4cintnam.ads \ --- 826,832 ---- g-soccon.ads<3bsoccon.ads \ system.ads<5bsystem.ads ! THREADSLIB = -lpthreads ifeq ($(strip $(filter-out fsu FSU,$(THREAD_KIND))),) LIBGNAT_TARGET_PAIRS = \ a-intnam.ads<4cintnam.ads \ *************** ifeq ($(strip $(filter-out ibm aix4%,$(m *** 1368,1374 **** g-soccon.ads<3bsoccon.ads \ system.ads<5bsystem.ads ! THREADSLIB=-lgthreads -lmalloc endif endif --- 841,847 ---- g-soccon.ads<3bsoccon.ads \ system.ads<5bsystem.ads ! THREADSLIB = -lgthreads -lmalloc endif endif *************** ifeq ($(strip $(filter-out lynxos,$(osys *** 1400,1407 **** s-osinte.adb<56osinte.adb \ s-osinte.ads<56osinte.ads \ s-osprim.adb<7sosprim.adb \ ! s-taprop.adb<7staprop.adb \ ! s-taspri.ads<7staspri.ads \ s-tpopsp.adb<5atpopsp.adb \ system.ads<52system.ads endif --- 873,880 ---- s-osinte.adb<56osinte.adb \ s-osinte.ads<56osinte.ads \ s-osprim.adb<7sosprim.adb \ ! s-taprop.adb<56taprop.adb \ ! s-taspri.ads<56taspri.ads \ s-tpopsp.adb<5atpopsp.adb \ system.ads<52system.ads endif *************** ifeq ($(strip $(filter-out lynxos,$(osys *** 1411,1422 **** a-intnam.ads<42intnam.ads \ s-inmaop.adb<7sinmaop.adb \ s-intman.adb<7sintman.adb \ ! s-osinte.adb<52osinte.adb \ ! s-osinte.ads<52osinte.ads \ s-osprim.adb<7sosprim.adb \ ! s-taprop.adb<7staprop.adb \ ! s-taspri.ads<7staspri.ads \ ! s-tpopsp.adb<7stpopsp.adb \ system.ads<52system.ads endif endif --- 884,895 ---- a-intnam.ads<42intnam.ads \ s-inmaop.adb<7sinmaop.adb \ s-intman.adb<7sintman.adb \ ! s-osinte.adb<56osinte.adb \ ! s-osinte.ads<56osinte.ads \ s-osprim.adb<7sosprim.adb \ ! s-taprop.adb<56taprop.adb \ ! s-taspri.ads<56taspri.ads \ ! s-tpopsp.adb<5atpopsp.adb \ system.ads<52system.ads endif endif *************** ifeq ($(strip $(filter-out alpha% dec os *** 1465,1486 **** g-soccon.ads<3asoccon.ads \ system.ads<5asystem.ads ! MISCLIB=-laddr2line -lbfd ! THREADSLIB=-lpthread -lmach -lexc -lrt LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) endif ! ifeq ($(strip $(filter-out ppc mac machten,$(targ))),) LIBGNAT_TARGET_PAIRS = \ ! a-intnam.ads<4mintnam.ads \ ! s-inmaop.adb<7sinmaop.adb \ ! s-intman.adb<7sintman.adb \ ! s-osinte.adb<7sosinte.adb \ ! s-osinte.ads<5mosinte.ads \ ! s-osprim.adb<7sosprim.adb \ ! s-taprop.adb<7staprop.adb \ ! s-taspri.ads<7staspri.ads \ ! s-tpopsp.adb<7stpopsp.adb endif ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),) --- 938,1001 ---- g-soccon.ads<3asoccon.ads \ system.ads<5asystem.ads ! THREADSLIB = -lpthread -lmach -lexc -lrt ! SYMLIB = -laddr2line -lbfd $(INTLLIBS) LIBRARY_VERSION := $(strip $(shell grep Library_Version $(fsrcpfx)gnatvsn.ads | sed -e 's/.*GNAT Lib v\(.*\)[ "].*/\1/')) endif ! ifeq ($(strip $(filter-out alpha% dec vms% openvms% alphavms%,$(host))),) ! ! EXTRA_GNAT1_OBJS = ../prefix.o vmshandler.o ! EXTRA_GNATBIND_OBJS = ../prefix.o vmshandler.o ! ! endif ! ! ifeq ($(strip $(filter-out alpha% dec vms% openvms% alphavms%,$(targ))),) ! ! ifeq ($(strip $(filter-out alpha64% dec vms% openvms% alphavms%,$(targ))),) ! LIBGNAT_TARGET_PAIRS_AUX = ! else ! ifeq ($(strip $(filter-out express EXPRESS,$(THREAD_KIND))),) ! LIBGNAT_TARGET_PAIRS_AUX = \ ! s-parame.ads<5xparame.ads ! else ! LIBGNAT_TARGET_PAIRS_AUX = \ ! s-parame.ads<5vparame.ads ! endif ! endif ! LIBGNAT_TARGET_PAIRS = \ ! a-caldel.adb<4vcaldel.adb \ ! a-calend.adb<4vcalend.adb \ ! a-calend.ads<4vcalend.ads \ ! a-excpol.adb<4wexcpol.adb \ ! a-intnam.ads<4vintnam.ads \ ! g-enblsp.adb<3venblsp.adb \ ! i-cstrea.adb<6vcstrea.adb \ ! i-cpp.adb<6vcpp.adb \ ! interfac.ads<6vinterf.ads \ ! s-asthan.adb<5vasthan.adb \ ! s-inmaop.adb<5vinmaop.adb \ ! s-interr.adb<5vinterr.adb \ ! s-intman.adb<5vintman.adb \ ! s-intman.ads<5vintman.ads \ ! s-osinte.adb<5vosinte.adb \ ! s-osinte.ads<5vosinte.ads \ ! s-osprim.adb<5vosprim.adb \ ! s-osprim.ads<5vosprim.ads \ ! s-taprop.adb<5vtaprop.adb \ ! s-taspri.ads<5vtaspri.ads \ ! s-tpopde.adb<5vtpopde.adb \ ! s-tpopde.ads<5vtpopde.ads \ ! s-vaflop.adb<5vvaflop.adb \ ! system.ads<5xsystem.ads \ ! $(LIBGNAT_TARGET_PAIRS_AUX) ! ! GNATLIB_SHARED=gnatlib-shared-vms ! EXTRA_LIBGNAT_SRCS=vmshandler.asm ! EXTRA_LIBGNAT_OBJS=vmshandler.o ! EXTRA_GNATRTL_TASKING_OBJS=s-tpopde.o ! EXTRA_GNATTOOLS_OBJS = ../prefix.o vmshandler.o endif ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),) *************** ifeq ($(strip $(filter-out cygwin32% min *** 1506,1519 **** g-soliop.ads<3wsoliop.ads \ system.ads<5wsystem.ads ! MISCLIB = -laddr2line -lbfd -lwsock32 ! GMEM_LIB=gmemlib ! EXTRA_GNATTOOLS = ../gnatdll$(exeext) EXTRA_GNATRTL_NONTASKING_OBJS = g-regist.o - - # ??? work around a gcc -O3 bug on x86 - a-numaux.o : a-numaux.adb a-numaux.ads - $(ADAC) -c $(ALL_ADAFLAGS) -O2 $(ADA_INCLUDES) $< endif # The runtime library for gnat comprises two directories. One contains the --- 1021,1031 ---- g-soliop.ads<3wsoliop.ads \ system.ads<5wsystem.ads ! MISCLIB = -lwsock32 ! SYMLIB = -laddr2line -lbfd $(INTLLIBS) ! GMEM_LIB = gmemlib ! EXTRA_GNATTOOLS = ../../gnatdll$(exeext) EXTRA_GNATRTL_NONTASKING_OBJS = g-regist.o endif # The runtime library for gnat comprises two directories. One contains the *************** endif *** 1527,1538 **** # subdirectory and copied. LIBGNAT_SRCS = ada.h adaint.c adaint.h argv.c cio.c cstreams.c \ errno.c exit.c cal.c \ ! raise.h raise.c sysdep.c types.h io-aux.c init.c \ ! adafinal.c tracebak.c expect.c $(EXTRA_LIBGNAT_SRCS) LIBGNAT_OBJS = adaint.o argv.o cio.o cstreams.o errno.o exit.o \ ! raise.o sysdep.o io-aux.o init.o cal.o adafinal.o \ ! tracebak.o expect.o ../../prefix.o $(EXTRA_LIBGNAT_OBJS) # NOTE ??? - when the -I option for compiling Ada code is made to work, # the library installation will change and there will be a --- 1039,1050 ---- # subdirectory and copied. LIBGNAT_SRCS = ada.h adaint.c adaint.h argv.c cio.c cstreams.c \ errno.c exit.c cal.c \ ! raise.h raise.c sysdep.c types.h aux-io.c init.c \ ! adafinal.c tracebak.c expect.c mkdir.c $(EXTRA_LIBGNAT_SRCS) LIBGNAT_OBJS = adaint.o argv.o cio.o cstreams.o errno.o exit.o \ ! raise.o sysdep.o aux-io.o init.o cal.o adafinal.o \ ! tracebak.o expect.o mkdir.o $(EXTRA_LIBGNAT_OBJS) # NOTE ??? - when the -I option for compiling Ada code is made to work, # the library installation will change and there will be a *************** GNATRTL_TASKING_OBJS= \ *** 1577,1583 **** s-tpinop.o \ s-tpoben.o \ s-tpobop.o \ ! s-tposen.o $(EXTRA_GNATRTL_TASKING_OBJS) # Objects needed for non-tasking. GNATRTL_NONTASKING_OBJS= \ --- 1089,1096 ---- s-tpinop.o \ s-tpoben.o \ s-tpobop.o \ ! s-tposen.o \ ! s-tratas.o $(EXTRA_GNATRTL_TASKING_OBJS) # Objects needed for non-tasking. GNATRTL_NONTASKING_OBJS= \ *************** GNATRTL_NONTASKING_OBJS= \ *** 1586,1595 **** --- 1099,1110 ---- a-chahan.o \ a-charac.o \ a-chlat1.o \ + a-chlat9.o \ a-colien.o \ a-colire.o \ a-comlin.o \ a-cwila1.o \ + a-cwila9.o \ a-decima.o \ a-einuoc.o \ a-except.o \ *************** GNATRTL_NONTASKING_OBJS= \ *** 1698,1703 **** --- 1213,1219 ---- g-io.o \ g-io_aux.o \ g-locfil.o \ + g-md5.o \ g-moreex.o \ g-os_lib.o \ g-regexp.o \ *************** GNATRTL_NONTASKING_OBJS= \ *** 1715,1721 **** g-sptavs.o \ g-tasloc.o \ g-traceb.o \ - g-trasym.o \ gnat.o \ i-c.o \ i-cexten.o \ --- 1231,1236 ---- *************** GNATRTL_NONTASKING_OBJS= \ *** 1872,1877 **** --- 1387,1393 ---- s-soflin.o \ s-memory.o \ s-traceb.o \ + s-traces.o \ s-unstyp.o \ s-vaflop.o \ s-valboo.o \ *************** GNATRTL_NONTASKING_OBJS= \ *** 1905,1911 **** system.o \ text_io.o $(EXTRA_GNATRTL_NONTASKING_OBJS) ! GNATRTL_OBJS = $(GNATRTL_NONTASKING_OBJS) $(GNATRTL_TASKING_OBJS) # Files which are suitable in no run time/hi integrity mode --- 1421,1427 ---- system.o \ text_io.o $(EXTRA_GNATRTL_NONTASKING_OBJS) ! GNATRTL_OBJS = $(GNATRTL_NONTASKING_OBJS) $(GNATRTL_TASKING_OBJS) g-trasym.o # Files which are suitable in no run time/hi integrity mode *************** RAVEN_OBJS = \ *** 2007,2012 **** --- 1523,1531 ---- # Default run time files + ADA_INCLUDE_DIR = $(libsubdir)/adainclude + ADA_RTL_OBJ_DIR = $(libsubdir)/adalib + ADA_INCLUDE_SRCS =\ ada.ads calendar.ads directio.ads gnat.ads interfac.ads ioexcept.ads \ machcode.ads text_io.ads unchconv.ads unchdeal.ads \ *************** ADA_INCLUDE_SRCS =\ *** 2015,2102 **** s-[a-o]*.adb s-[p-z]*.adb \ s-[a-o]*.ads s-[p-z]*.ads - # Files specific to the C interpreter bytecode compiler(s). - BC_OBJS = ../bc-emit.o ../bc-optab.o - # Language-independent object files. ! BACKEND = ../main.o ../attribs.o ../libbackend.a ! Makefile: $(srcdir)/Makefile.in $(srcdir)/../configure ! cd ..; $(SHELL) config.status ! native: ../gnat1$(exeext) ! compiler: ../gnat1$(exeext) ! tools: ../gnatbl$(exeext) ../gnatchop$(exeext) ../gnatcmd$(exeext)\ ! ../gnatkr$(exeext) ../gnatlink$(exeext) ../gnatlbr$(exeext) \ ! ../gnatls$(exeext) ../gnatmake$(exeext) \ ! ../gnatprep$(exeext) ../gnatpsta$(exeext) ../gnatpsys$(exeext) \ ! ../gnatxref$(exeext) ../gnatfind$(exeext) ! # Needs to be built with CC=gcc ! # Since the RTL should be built with the latest compiler, remove the ! # stamp target in the parent directory whenever gnat1 is rebuilt ! ../gnat1$(exeext): $(P) $(GNAT1_OBJS) $(BACKEND) $(LIBDEPS) $(TARGET_ADA_SRCS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GNAT1_OBJS) $(BACKEND) $(LIBS) ! $(RM) ../stamp-gnatlib2 ! ../gnatbind$(exeext): $(P) b_gnatb.o $(GNATBIND_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatb.o $(GNATBIND_OBJS) \ ! $(LIBIBERTY) $(LIBS) ! ../gnatchop$(exeext): $(P) b_gnatch.o $(GNATCHOP_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatch.o $(GNATCHOP_OBJS) \ ! $(LIBS) ! ../gnatmake$(exeext): $(P) b_gnatm.o $(GNATMAKE_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) $(LIBS) ! gnatbl.o: gnatbl.c adaint.h ! $(CC) $(ALL_CFLAGS) $(INCLUDES) -c $< ! ../gnatbl$(exeext): gnatbl.o adaint.o ! $(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) gnatbl.o adaint.o $(LIBS) ! ../gnatcmd$(exeext): $(P) b_gnatc.o $(GNATCMD_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatc.o $(GNATCMD_OBJS) $(LIBS) ! ../gnatkr$(exeext): $(P) b_gnatkr.o $(GNATKR_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatkr.o $(GNATKR_OBJS) $(LIBS) ! ../gnatlink$(exeext): $(P) b_gnatl.o $(GNATLINK_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) $(LIBS) ! ../gnatls$(exeext): $(P) b_gnatls.o $(GNATLS_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatls.o $(GNATLS_OBJS) $(LIBS) ! ../gnatmem$(exeext): $(P) b_gnatmem.o $(GNATMEM_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatmem.o $(GNATMEM_OBJS) \ ! $(MISCLIB) $(LIBS) ! ../gnatprep$(exeext): $(P) b_gnatp.o $(GNATPREP_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatp.o $(GNATPREP_OBJS) $(LIBS) ! ../gnatpsta$(exeext): $(P) b_gnatpa.o $(GNATPSTA_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatpa.o $(GNATPSTA_OBJS) \ ! $(LIBS) ! ../gnatpsys$(exeext): $(P) b_gnatps.o $(GNATPSYS_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatps.o $(GNATPSYS_OBJS) \ ! $(LIBS) ! ../gnatxref$(exeext): $(P) b_gnatxref.o $(GNATXREF_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatxref.o $(GNATXREF_OBJS) \ ! $(LIBS) ! ../gnatfind$(exeext): $(P) b_gnatfind.o $(GNATFIND_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatfind.o $(GNATFIND_OBJS) \ ! $(LIBS) ! ../gnatdll$(exeext): $(P) b_gnatdll.o $(GNATDLL_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatdll.o $(GNATDLL_OBJS) \ ! $(LIBS) ../stamp-gnatlib: @if [ ! -f stamp-gnatlib ] ; \ then \ --- 1534,1722 ---- s-[a-o]*.adb s-[p-z]*.adb \ s-[a-o]*.ads s-[p-z]*.ads # Language-independent object files. ! LIBGNAT=../rts/libgnat.a ! TOOLS_FLAGS_TO_PASS= \ ! "CC=$(CC)" \ ! "CFLAGS=$(CFLAGS)" \ ! "LDFLAGS=$(LDFLAGS)" \ ! "ADAFLAGS=$(ADAFLAGS)" \ ! "INCLUDES=$(INCLUDES_FOR_SUBDIR)"\ ! "ADA_INCLUDES=$(ADA_INCLUDES) $(ADA_INCLUDES_FOR_SUBDIR)"\ ! "libsubdir=$(libsubdir)" \ ! "exeext=$(exeext)" \ ! "srcdir=$(fsrcdir)" \ ! "VPATH=$(fsrcdir)" \ ! "TOOLS_LIBS=$(TOOLS_LIBS) $(TGT_LIB)" \ ! "GNATMAKE=$(GNATMAKE)" \ ! "GNATLINK=$(GNATLINK)" \ ! "GNATBIND=$(GNATBIND)" ! # Build directory for the tools. Let's copy the target dependent ! # sources using the same mechanism as for gnatlib. The other sources are ! # accessed using the vpath directive below ! ../stamp-tools: ! -$(RM) tools/* ! -$(RMDIR) tools ! -$(MKDIR) tools ! -(cd tools; $(LN_S) ../sdefault.adb .) ! -$(foreach PAIR,$(TOOLS_TARGET_PAIRS), \ ! $(RM) tools/$(word 1,$(subst <, ,$(PAIR)));\ ! $(LN_S) $(fsrcdir)/$(word 2,$(subst <, ,$(PAIR))) \ ! tools/$(word 1,$(subst <, ,$(PAIR)));) ! touch ../stamp-tools ! # when compiling the tools, the runtime has to be first on the path so that ! # it hides the runtime files lying with the rest of the sources ! ifeq ($(TOOLSCASE),native) ! vpath %.ads ../rts ../ ! vpath %.adb ../rts ../ ! vpath %.c ../rts ../ ! vpath %.h ../rts ../ ! endif ! # in the cross tools case, everything is compiled with the native ! # gnatmake/link. Therefore only -I needs to be modified in ADA_INCLUDES ! ifeq ($(TOOLSCASE),cross) ! vpath %.ads ../ ! vpath %.adb ../ ! vpath %.c ../ ! vpath %.h ../ ! endif ! # gnatmake/link tools cannot always be built with gnatmake/link for bootstrap ! # reasons: gnatmake should be built with a recent compiler, a recent compiler ! # may not generate ALI files compatible with an old gnatmake so it is important ! # to be able to build gnatmake without a version of gnatmake around. Once ! # everything has been compiled once, gnatmake can be recompiled with itself ! # (see target gnattools1-re) ! gnattools1: ../stamp-tools ../stamp-gnatlib ! $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \ ! TOOLSCASE=native \ ! ../../gnatmake$(exeext) ../../gnatlink$(exeext) ../../gnatbl$(exeext) ! # gnatmake/link can be build with recent gnatmake/link if they are available. ! # This is especially convenient for building cross tools or for rebuilding ! # the tools when the original bootstrap has already be done. ! gnattools1-re: ../stamp-tools ! $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \ ! TOOLSCASE=cross INCLUDES="" gnatmake-re gnatlink-re ! # these tools are built with gnatmake & are common to native and cross ! gnattools2: ../stamp-tools ! $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \ ! TOOLSCASE=native \ ! ../../gnatchop$(exeext) ../../gnat$(exeext) ../../gnatkr$(exeext) \ ! ../../gnatls$(exeext) ../../gnatprep$(exeext) \ ! ../../gnatpsta$(exeext) ../../gnatxref$(exeext) \ ! ../../gnatfind$(exeext) ../../gnatname$(exeext) ! # These tools are only built for the native version. ! gnattools3: ../stamp-tools ! # $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \ ! # TOOLSCASE=native \ ! # top_builddir=../.. ../../gnatmem$(exeext) $(EXTRA_GNATTOOLS) ! ../../gnatchop$(exeext): ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatchop --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatchop ! $(GNATLINK) -v gnatchop -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \ ! $(TOOLS_LIBS) ! ../../gnat$(exeext): ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatcmd --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatcmd ! $(GNATLINK) -v gnatcmd -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \ ! $(TOOLS_LIBS) ! ../../gnatkr$(exeext): ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatkr --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatkr ! $(GNATLINK) -v gnatkr -o $@ --GCC="$(CC) $(ADA_INCLUDES)" $(TOOLS_LIBS) ! ../../gnatls$(exeext): ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatls --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatls ! $(GNATLINK) -v gnatls -o $@ --GCC="$(CC) $(ADA_INCLUDES)" $(TOOLS_LIBS) ! ../../gnatname$(exeext): ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatname --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatname ! $(GNATLINK) -v gnatname -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \ ! $(TOOLS_LIBS) ! ../../gnatprep$(exeext): ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatprep --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatprep ! $(GNATLINK) -v gnatprep -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \ ! $(TOOLS_LIBS) ! ../../gnatpsta$(exeext): deftarg.o ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatpsta --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatpsta ! $(GNATLINK) -v gnatpsta -o $@ --GCC="$(CC) $(ADA_INCLUDES)"\ ! ../targtyps.o deftarg.o $(TOOLS_LIBS) ! ../../gnatxref$(exeext): ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatxref --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatxref ! $(GNATLINK) -v gnatxref -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \ ! $(TOOLS_LIBS) ! ../../gnatfind$(exeext): ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatfind --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatfind ! $(GNATLINK) -v gnatfind -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \ ! $(TOOLS_LIBS) ! ../../gnatmem$(exeext): gmem.o $(SYMDEPS) ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatmem --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmem ! $(GNATLINK) -v gnatmem -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \ ! gmem.o $(SYMLIB) $(TOOLS_LIBS) ! ../../gnatdll$(exeext): ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatdll --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) $(GNATBIND_FLAGS) gnatdll ! $(GNATLINK) -v gnatdll -o $@ --GCC="$(CC) $(ADA_INCLUDES)" \ ! $(TOOLS_LIBS) ! gnatmake-re: ! $(GNATMAKE) $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)" ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmake ! $(GNATLINK) -v gnatmake -o ../../gnatmake$(exeext) \ ! --GCC="$(CC) $(ADA_INCLUDES)" $(TOOLS_LIBS) ! # Note the use of the "mv" command in order to allow gnatlink to be linked with ! # with the former version of gnatlink itself which cannot override itself. ! gnatlink-re: link.o ! $(GNATMAKE) -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) $(ALL_ADAFLAGS)" ! $(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatlink ! $(GNATLINK) -v gnatlink -o ../../gnatlinknew$(exeext) \ ! --GCC="$(CC) $(ADA_INCLUDES)" link.o $(TOOLS_LIBS) ! $(MV) ../../gnatlinknew$(exeext) ../../gnatlink$(exeext) ! ! ! # Needs to be built with CC=gcc ! # Since the RTL should be built with the latest compiler, remove the ! # stamp target in the parent directory whenever gnat1 is rebuilt ! # Likewise for the tools ! ../../gnatmake$(exeext): $(P) b_gnatm.o $(GNATMAKE_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) \ ! $(TOOLS_LIBS) + ../../gnatlink$(exeext): $(P) b_gnatl.o $(GNATLINK_OBJS) + $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) \ + $(TOOLS_LIBS) + + ../../gnatbl$(exeext): gnatbl.o + $(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) gnatbl.o $(TOOLS_LIBS) + + gnatbl.o: gnatbl.c adaint.h + $(CC) $(ALL_CFLAGS) $(INCLUDES) -c $< + ../stamp-gnatlib: @if [ ! -f stamp-gnatlib ] ; \ then \ *************** gnatbl.o: gnatbl.c adaint.h *** 2106,2118 **** true; \ fi ! gnattools: ../gnatbl$(exeext) ../gnatchop$(exeext) ../gnatcmd$(exeext) \ ! ../gnatkr$(exeext) ../gnatlink$(exeext) \ ! ../gnatls$(exeext) ../gnatmake$(exeext) \ ! ../gnatprep$(exeext) ../gnatpsta$(exeext) ../gnatpsys$(exeext) \ ! ../gnatxref$(exeext) ../gnatfind$(exeext) $(EXTRA_GNATTOOLS) ! ! install-gnatlib: stamp-gnatlib # Create the directory before deleting it, in case the directory is # a list of directories (as it may be on VMS). This ensures we are # deleting the right one. --- 1726,1732 ---- true; \ fi ! install-gnatlib: ../stamp-gnatlib # Create the directory before deleting it, in case the directory is # a list of directories (as it may be on VMS). This ensures we are # deleting the right one. *************** install-gnatlib: stamp-gnatlib *** 2129,2135 **** -for file in ada/rts/*$(arext);do \ $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ done ! ifeq ($(strip $(filter-out alpha% dec vms%,$(targ))),) -for file in ada/rts/lib*$(soext);do \ $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ done --- 1743,1749 ---- -for file in ada/rts/*$(arext);do \ $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ done ! ifeq ($(strip $(filter-out alpha% dec vms% openvms% alphavms%,$(targ))),) -for file in ada/rts/lib*$(soext);do \ $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \ done *************** else *** 2139,2147 **** done endif -( cd $(DESTDIR)$(ADA_RTL_OBJ_DIR) && \ ! $(LN) libgnat-*$(soext) libgnat$(soext) ) -( cd $(DESTDIR)$(ADA_RTL_OBJ_DIR) && \ ! $(LN) libgnarl-*$(soext) libgnarl$(soext) ) # This copy must be done preserving the date on the original file. for file in ada/rts/*.adb ada/rts/*.ads; do \ $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR); \ --- 1753,1761 ---- done endif -( cd $(DESTDIR)$(ADA_RTL_OBJ_DIR) && \ ! $(LN_S) libgnat-*$(soext) libgnat$(soext) ) -( cd $(DESTDIR)$(ADA_RTL_OBJ_DIR) && \ ! $(LN_S) libgnarl-*$(soext) libgnarl$(soext) ) # This copy must be done preserving the date on the original file. for file in ada/rts/*.adb ada/rts/*.ads; do \ $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR); \ *************** gnatlib: ../stamp-gnatlib1 ../stamp-gnat *** 2199,2234 **** # ../xgcc -B../ -dD -E ../tconfig.h $(INCLUDES) > rts/tconfig.h $(MAKE) -C rts CC="../../xgcc -B../../" \ INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \ ! CFLAGS="$(GNATLIBCFLAGS) $(TARGET_LIBGCC2_CFLAGS) -DIN_RTS" \ ! ADA_CFLAGS="$(GNATLIBCFLAGS)" \ srcdir=$(fsrcdir) \ ! -f ../Makefile $(LIBGNAT_OBJS) $(MAKE) -C rts CC="../../xgcc -B../../" \ ADA_INCLUDES="$(ADA_INCLUDES_FOR_SUBDIR)" \ CFLAGS="$(GNATLIBCFLAGS)" ADA_CFLAGS="$(GNATLIBCFLAGS)" \ ADAFLAGS="$(GNATLIBFLAGS)" \ ! srcdir=$(fsrcdir) \ -f ../Makefile \ $(GNATRTL_OBJS) $(RM) rts/libgnat$(arext) rts/libgnarl$(arext) $(AR) $(AR_FLAGS) rts/libgnat$(arext) \ ! $(addprefix rts/,$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS)) if $(RANLIB_TEST) ; then $(RANLIB) rts/libgnat$(arext); else true; fi $(AR) $(AR_FLAGS) rts/libgnarl$(arext) \ $(addprefix rts/,$(GNATRTL_TASKING_OBJS)) if $(RANLIB_TEST) ; then $(RANLIB) rts/libgnarl$(arext); else true; fi ifeq ($(GMEM_LIB),gmemlib) $(AR) $(AR_FLAGS) rts/libgmem$(arext) rts/memtrack.o; - if $(RANLIB_TEST) ; then \ - $(RANLIB) rts/libgmem$(arext); \ - else \ - true; \ - fi endif $(CHMOD) a-wx rts/*.ali touch ../stamp-gnatlib ! # generate read-only ali files for HI-E. internal-hielib: ../stamp-gnatlib1 sed -e 's/High_Integrity_Mode.*/High_Integrity_Mode : constant Boolean := True;/' rts/system.ads > rts/s.ads --- 1813,1894 ---- # ../xgcc -B../ -dD -E ../tconfig.h $(INCLUDES) > rts/tconfig.h $(MAKE) -C rts CC="../../xgcc -B../../" \ INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \ ! CFLAGS="$(GNATLIBCFLAGS_FOR_C)" \ srcdir=$(fsrcdir) \ ! -f ../Makefile $(LIBGNAT_OBJS) prefix.o $(MAKE) -C rts CC="../../xgcc -B../../" \ ADA_INCLUDES="$(ADA_INCLUDES_FOR_SUBDIR)" \ CFLAGS="$(GNATLIBCFLAGS)" ADA_CFLAGS="$(GNATLIBCFLAGS)" \ ADAFLAGS="$(GNATLIBFLAGS)" \ ! srcdir=$(fsrcdir) VPATH=$(fsrcdir) \ -f ../Makefile \ $(GNATRTL_OBJS) $(RM) rts/libgnat$(arext) rts/libgnarl$(arext) $(AR) $(AR_FLAGS) rts/libgnat$(arext) \ ! $(addprefix rts/,$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) prefix.o) if $(RANLIB_TEST) ; then $(RANLIB) rts/libgnat$(arext); else true; fi $(AR) $(AR_FLAGS) rts/libgnarl$(arext) \ $(addprefix rts/,$(GNATRTL_TASKING_OBJS)) if $(RANLIB_TEST) ; then $(RANLIB) rts/libgnarl$(arext); else true; fi ifeq ($(GMEM_LIB),gmemlib) $(AR) $(AR_FLAGS) rts/libgmem$(arext) rts/memtrack.o; endif $(CHMOD) a-wx rts/*.ali touch ../stamp-gnatlib ! HIE_NONE_TARGET_PAIRS=\ ! a-except.ads<1aexcept.ads \ ! a-except.adb<1aexcept.adb \ ! a-tags.adb<1atags.adb \ ! s-secsta.ads<1ssecsta.ads \ ! s-secsta.adb<1ssecsta.adb \ ! i-c.ads<1ic.ads ! ! HIE_SUBST:='s/High_Integrity_Mode.*/High_Integrity_Mode : constant Boolean := True;/' ! # This target needs RTS_NAME, RTS_SRCS, RTS_TARGET_PAIRS to be set properly ! # it creates a rts with the proper structure and the right target dependent srcs ! prepare-rts: ! $(RMDIR) rts-$(RTS_NAME) ! $(MKDIR) rts-$(RTS_NAME) ! $(CHMOD) u+w rts-$(RTS_NAME) ! $(MKDIR) rts-$(RTS_NAME)/adalib ! $(MKDIR) rts-$(RTS_NAME)/adainclude ! $(CHMOD) u+w rts-$(RTS_NAME)/* ! $(LN) $(fsrcpfx)$(RTS_NAME).gpr rts-$(RTS_NAME) ! # Copy target independent sources ! $(foreach f,$(RTS_SRCS), \ ! $(LN) $(fsrcpfx)$(f) rts-$(RTS_NAME)/adainclude ;) true ! # Remove files to be replaced by target dependent sources ! $(RM) $(foreach PAIR,$(RTS_TARGET_PAIRS), \ ! rts-$(RTS_NAME)/adainclude/$(word 1,$(subst <, ,$(PAIR)))) ! # Copy new target dependent sources ! $(foreach PAIR,$(RTS_TARGET_PAIRS), \ ! $(LN) $(fsrcpfx)$(word 2,$(subst <, ,$(PAIR))) \ ! rts-$(RTS_NAME)/adainclude/$(word 1,$(subst <, ,$(PAIR)));) ! # change system.High_Integrity_Mode to true for the none & ravenscar rts ! ifeq ($(filter-out none ravenscar,$(RTS_NAME)),) ! sed -e $(HIE_SUBST) rts-$(RTS_NAME)/adainclude/system.ads \ ! > dummy ! $(MV) dummy rts-$(RTS_NAME)/adainclude/system.ads ! endif ! ! install-rts: force ! $(CP) -r rts-$(RTS_NAME) $(DESTDIR)$(libsubdir)/ ! ! rts-none: force ! $(MAKE) $(FLAGS_TO_PASS) prepare-rts \ ! RTS_NAME=none RTS_SRCS="$(HIE_SOURCES)" \ ! RTS_TARGET_PAIRS="$(HIE_NONE_TARGET_PAIRS)" ! -$(GNATMAKE) -Prts-none/none.gpr ! $(RM) rts-none/adalib/*.o ! $(CHMOD) a-wx rts-none/adalib/*.ali ! ! rts-ravenscar: force ! $(MAKE) $(FLAGS_TO_PASS) prepare-rts \ ! RTS_NAME=ravenscar RTS_SRCS="$(RAVEN_SOURCES)" \ ! RTS_TARGET_PAIRS="$(HIE_RAVEN_TARGET_PAIRS)" ! -$(GNATMAKE) -Prts-ravenscar/none.gpr ! $(CHMOD) a-wx rts-ravenscar/adalib/*.ali internal-hielib: ../stamp-gnatlib1 sed -e 's/High_Integrity_Mode.*/High_Integrity_Mode : constant Boolean := True;/' rts/system.ads > rts/s.ads *************** internal-hielib: ../stamp-gnatlib1 *** 2237,2243 **** ADA_INCLUDES="$(ADA_INCLUDES_FOR_SUBDIR)" \ CFLAGS="$(GNATLIBCFLAGS)" \ ADAFLAGS="$(GNATLIBFLAGS)" \ ! srcdir=$(fsrcdir) \ -f ../Makefile \ $(HIE_OBJS) $(CHMOD) a-wx rts/*.ali --- 1897,1903 ---- ADA_INCLUDES="$(ADA_INCLUDES_FOR_SUBDIR)" \ CFLAGS="$(GNATLIBCFLAGS)" \ ADAFLAGS="$(GNATLIBFLAGS)" \ ! srcdir=$(fsrcdir) VPATH=$(fsrcdir) \ -f ../Makefile \ $(HIE_OBJS) $(CHMOD) a-wx rts/*.ali *************** hielib: *** 2248,2266 **** $(MAKE) ADA_INCLUDE_SRCS="$(HIE_SOURCES)" LIBGNAT_SRCS="" \ LIBGNAT_TARGET_PAIRS="a-except.ads<1aexcept.ads \ a-except.adb<1aexcept.adb \ i-c.ads<1ic.ads" internal-hielib internal-ravenlib: ../stamp-gnatlib1 ! echo "pragma Ravenscar;" > rts/gnat.adc ! echo "pragma Restrictions (No_Exception_Handlers);" >> rts/gnat.adc ! $(foreach f,$(RAVEN_MOD), \ ! $(RM) rts/$(f) ; \ ! grep -v "not needed in no exc mode" $(fsrcpfx)$(f) > rts/$(f) ;) true $(MAKE) -C rts CC="../../xgcc -B../../" \ ADA_INCLUDES="$(ADA_INCLUDES_FOR_SUBDIR)" \ CFLAGS="$(GNATLIBCFLAGS)" \ ADAFLAGS="$(GNATLIBFLAGS)" \ ! srcdir=$(fsrcdir) \ -f ../Makefile \ $(RAVEN_OBJS) $(CHMOD) a-wx rts/*.ali --- 1908,1926 ---- $(MAKE) ADA_INCLUDE_SRCS="$(HIE_SOURCES)" LIBGNAT_SRCS="" \ LIBGNAT_TARGET_PAIRS="a-except.ads<1aexcept.ads \ a-except.adb<1aexcept.adb \ + a-tags.adb<1atags.adb \ + s-secsta.ads<1ssecsta.ads \ + s-secsta.adb<1ssecsta.adb \ i-c.ads<1ic.ads" internal-hielib internal-ravenlib: ../stamp-gnatlib1 ! sed -e 's/High_Integrity_Mode.*/High_Integrity_Mode : constant Boolean := True;/' rts/system.ads > rts/s.ads ! $(MV) rts/s.ads rts/system.ads $(MAKE) -C rts CC="../../xgcc -B../../" \ ADA_INCLUDES="$(ADA_INCLUDES_FOR_SUBDIR)" \ CFLAGS="$(GNATLIBCFLAGS)" \ ADAFLAGS="$(GNATLIBFLAGS)" \ ! srcdir=$(fsrcdir) VPATH=$(fsrcdir) \ -f ../Makefile \ $(RAVEN_OBJS) $(CHMOD) a-wx rts/*.ali *************** ravenppclib: *** 2271,2286 **** $(MAKE) ADA_INCLUDE_SRCS="$(RAVEN_SOURCES)" LIBGNAT_SRCS="" \ LIBGNAT_TARGET_PAIRS="a-except.ads<1aexcept.ads \ a-except.adb<1aexcept.adb \ i-c.ads<1ic.ads \ a-interr.adb<1ainterr.adb \ s-interr.ads<1sinterr.ads \ s-interr.adb<1sinterr.adb \ ! s-parame.ads<1sparame.ads \ ! s-secsta.adb<1ssecsta.adb \ ! s-soflin.ads<1ssoflin.ads \ ! s-soflin.adb<1ssoflin.adb \ ! s-stalib.ads<1sstalib.ads \ ! s-stalib.adb<1sstalib.adb \ s-taprop.ads<1staprop.ads \ s-taprop.adb<1staprop.adb \ a-sytaco.ads<1asytaco.ads \ --- 1931,1952 ---- $(MAKE) ADA_INCLUDE_SRCS="$(RAVEN_SOURCES)" LIBGNAT_SRCS="" \ LIBGNAT_TARGET_PAIRS="a-except.ads<1aexcept.ads \ a-except.adb<1aexcept.adb \ + a-tags.adb<1atags.adb \ + s-secsta.ads<1ssecsta.ads \ + s-secsta.adb<1ssecsta.adb \ i-c.ads<1ic.ads \ + a-reatim.ads<1areatim.ads \ + a-reatim.adb<1areatim.adb \ + a-retide.adb<1aretide.adb \ a-interr.adb<1ainterr.adb \ s-interr.ads<1sinterr.ads \ s-interr.adb<1sinterr.adb \ ! s-taskin.ads<1staskin.ads \ ! s-taskin.adb<1staskin.adb \ ! s-tarest.adb<1starest.adb \ ! s-tposen.ads<1stposen.ads \ ! s-tposen.adb<1stposen.adb \ ! s-osinte.adb<1sosinte.adb \ s-taprop.ads<1staprop.ads \ s-taprop.adb<1staprop.adb \ a-sytaco.ads<1asytaco.ads \ *************** ravenppclib: *** 2292,2298 **** s-vxwork.ads<5pvxwork.ads \ system.ads<5ysystem.ads" internal-ravenlib - # Warning: this target assumes that LIBRARY_VERSION has been set correctly. gnatlib-shared-default: $(MAKE) $(FLAGS_TO_PASS) \ --- 1958,1963 ---- *************** gnatlib-shared-default: *** 2302,2314 **** gnatlib $(RM) rts/libgnat$(soext) rts/libgnarl$(soext) cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \ ! -o libgnat-$(LIBRARY_VERSION)$(soext) $(SO_OPTS)libgnat-$(LIBRARY_VERSION)$(soext) \ ! $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) $(MISCLIB) -lm cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \ ! -o libgnarl-$(LIBRARY_VERSION)$(soext) $(SO_OPTS)libgnarl-$(LIBRARY_VERSION)$(soext) \ ! $(GNATRTL_TASKING_OBJS) $(THREADSLIB) ! cd rts; $(LN) libgnat-$(LIBRARY_VERSION)$(soext) libgnat$(soext) ! cd rts; $(LN) libgnarl-$(LIBRARY_VERSION)$(soext) libgnarl$(soext) gnatlib-shared-dual: $(MAKE) $(FLAGS_TO_PASS) \ --- 1967,1981 ---- gnatlib $(RM) rts/libgnat$(soext) rts/libgnarl$(soext) cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \ ! -o libgnat-$(LIBRARY_VERSION)$(soext) \ ! $(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \ ! $(SO_OPTS)libgnat-$(LIBRARY_VERSION)$(soext) $(MISCLIB) -lm cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \ ! -o libgnarl-$(LIBRARY_VERSION)$(soext) \ ! $(GNATRTL_TASKING_OBJS) \ ! $(SO_OPTS)libgnarl-$(LIBRARY_VERSION)$(soext) $(THREADSLIB) ! cd rts; $(LN_S) libgnat-$(LIBRARY_VERSION)$(soext) libgnat$(soext) ! cd rts; $(LN_S) libgnarl-$(LIBRARY_VERSION)$(soext) libgnarl$(soext) gnatlib-shared-dual: $(MAKE) $(FLAGS_TO_PASS) \ *************** gnatlib-shared: *** 2354,2359 **** --- 2021,2027 ---- GNATLIBFLAGS="$(GNATLIBFLAGS)" \ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ THREAD_KIND="$(THREAD_KIND)" \ + TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \ $(GNATLIB_SHARED) # .s files for cross-building *************** gnat-cross: force *** 2363,2546 **** # Compiling object files from source files. - # Note that dependencies on obstack.h are not written - # because that file is not part of GCC. - # Dependencies on gvarargs.h are not written - # because all that file does, when not compiling with GCC, - # is include the system varargs.h. - - TREE_H = $(srcdir)/../tree.h $(srcdir)/../real.h $(srcdir)/../tree.def \ - $(srcdir)/../machmode.h $(srcdir)/../machmode.def - # Ada language specific files. - ada_extra_files : treeprs.ads einfo.h sinfo.h nmake.adb nmake.ads - - b_gnat1.c : $(GNAT1_ADA_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnat1.c -n gnat1drv.ali - b_gnat1.o : b_gnat1.c - - b_gnatb.c : $(GNATBIND_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatb.c gnatbind.ali - b_gnatb.o : b_gnatb.c - - b_gnatc.c : $(GNATCMD_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatc.c gnatcmd.ali - b_gnatc.o : b_gnatc.c - - b_gnatch.c : $(GNATCHOP_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatch.c gnatchop.ali - b_gnatch.o : b_gnatch.c - - b_gnatkr.c : $(GNATKR_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatkr.c gnatkr.ali - b_gnatkr.o : b_gnatkr.c - b_gnatl.c : $(GNATLINK_OBJS) $(GNATBIND) $(ADA_INCLUDES) -o b_gnatl.c gnatlink.ali b_gnatl.o : b_gnatl.c - b_gnatls.c : $(GNATLS_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatls.c gnatls.ali - b_gnatm.c : $(GNATMAKE_OBJS) $(GNATBIND) $(ADA_INCLUDES) -o b_gnatm.c gnatmake.ali b_gnatm.o : b_gnatm.c - b_gnatmem.c : $(GNATMEM_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatmem.c gnatmem.ali - b_gnatmem.o : b_gnatmem.c - - b_gnatp.c : $(GNATPREP_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatp.c gnatprep.ali - b_gnatp.o : b_gnatp.c - - b_gnatpa.c : $(GNATPSTA_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatpa.c gnatpsta.ali - b_gnatpa.o : b_gnatpa.c - - b_gnatps.c : $(GNATPSYS_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatps.c gnatpsys.ali - b_gnatps.o : b_gnatps.c - - b_gnatxref.c : $(GNATXREF_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatxref.c gnatxref.ali - b_gnatxref.o : b_gnatxref.c - - b_gnatfind.c : $(GNATFIND_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatfind.c gnatfind.ali - b_gnatfind.o : b_gnatfind.c - - b_gnatdll.c : $(GNATDLL_OBJS) - $(GNATBIND) $(ADA_INCLUDES) -o b_gnatdll.c gnatdll.ali - b_gnatdll.o : b_gnatdll.c - - treeprs.ads : treeprs.adt sinfo.ads xtreeprs.adb - -$(MKDIR) bldtools - $(CP) $^ bldtools - (cd bldtools; gnatmake -q xtreeprs ; ./xtreeprs ../treeprs.ads ) - - einfo.h : einfo.ads einfo.adb xeinfo.adb - -$(MKDIR) bldtools - $(CP) $^ bldtools - (cd bldtools; gnatmake -q xeinfo ; ./xeinfo ../einfo.h ) - - sinfo.h : sinfo.ads xsinfo.adb - -$(MKDIR) bldtools - $(CP) $^ bldtools - (cd bldtools; gnatmake -q xsinfo ; ./xsinfo ../sinfo.h ) - - nmake.adb : sinfo.ads nmake.adt xnmake.adb - -$(MKDIR) bldtools - $(CP) $^ bldtools - (cd bldtools; gnatmake -q xnmake ; ./xnmake -b ../nmake.adb ) - - nmake.ads : sinfo.ads nmake.adt xnmake.adb - -$(MKDIR) bldtools - $(CP) $^ bldtools - (cd bldtools; gnatmake -q xnmake ; ./xnmake -s ../nmake.ads ) - - # We remove the generated .texi files to force regeneration. - doctools/xgnatug : xgnatug.adb - -$(MKDIR) doctools - $(CP) $^ doctools - (cd doctools ; gnatmake -q xgnatug) - -rm gnat_ug_*.texi - - # We cannot list the dependency on the xgnatug binary here because we - # have to (a) use the VPATH feature, and (b) include the target flag. - gnat_ug_vms.texi : gnat_ug.texi ug_words - doctools/xgnatug vms $^ - - gnat_ug_wnt.texi : gnat_ug.texi ug_words - doctools/xgnatug wnt $^ - - gnat_ug_unx.texi : gnat_ug.texi ug_words - doctools/xgnatug unx $^ - - gnat_ug_vxw.texi : gnat_ug.texi ug_words - doctools/xgnatug vxworks $^ - - %.info : %.texi - $(MAKEINFO) -I $(srcdir)/../doc/include -o $@ $< - - %.dvi : %.texi - $(TEXI2DVI) -I $(srcdir)/../doc/include $< - - # List the dependency on the xgnatug binary explicitly (see above). - doc : doctools/xgnatug \ - gnat_ug_vms.info gnat_ug_wnt.info gnat_ug_unx.info gnat_ug_vxw.info \ - gnat_rm.info gnat-style.info - - dvi : doctools/xgnatug \ - gnat_ug_vms.dvi gnat_ug_wnt.dvi gnat_ug_unx.dvi gnat_ug_vxw.dvi \ - gnat_rm.dvi gnat-style.dvi - - update-sources : treeprs.ads einfo.h sinfo.h nmake.adb nmake.ads - $(CP) $^ $(srcdir) - - ADA_INCLUDE_DIR = $(libsubdir)/adainclude - ADA_RTL_OBJ_DIR = $(libsubdir)/adalib - - # Note: the strings below do not make sense for Ada strings in the OS/2 - # case. This is ignored for now since the OS/2 version doesn't use - # these -- there are no default locations. - sdefault.adb: stamp-sdefault ; @true - stamp-sdefault : $(srcdir)/../version.c $(srcdir)/../move-if-change \ - Makefile - $(ECHO) "package body Sdefault is" >tmp-sdefault.adb - $(ECHO) " S1 : aliased constant String := \"$(ADA_INCLUDE_DIR)/\";" >>tmp-sdefault.adb - $(ECHO) " S2 : aliased constant String := \"$(ADA_RTL_OBJ_DIR)/\";" >>tmp-sdefault.adb - $(ECHO) " S3 : aliased constant String := \"$(target)/\";" >>tmp-sdefault.adb - $(ECHO) " S4 : aliased constant String := \"$(libsubdir)/\";" >>tmp-sdefault.adb - $(ECHO) " function Include_Dir_Default_Name return String_Ptr is" >>tmp-sdefault.adb - $(ECHO) " begin" >>tmp-sdefault.adb - $(ECHO) " return new String'(S1);" >>tmp-sdefault.adb - $(ECHO) " end Include_Dir_Default_Name;" >>tmp-sdefault.adb - $(ECHO) " function Object_Dir_Default_Name return String_Ptr is" >>tmp-sdefault.adb - $(ECHO) " begin" >>tmp-sdefault.adb - $(ECHO) " return new String'(S2);" >>tmp-sdefault.adb - $(ECHO) " end Object_Dir_Default_Name;" >>tmp-sdefault.adb - $(ECHO) " function Target_Name return String_Ptr is" >>tmp-sdefault.adb - $(ECHO) " begin" >>tmp-sdefault.adb - $(ECHO) " return new String'(S3);" >>tmp-sdefault.adb - $(ECHO) " end Target_Name;" >>tmp-sdefault.adb - $(ECHO) " function Search_Dir_Prefix return String_Ptr is" >>tmp-sdefault.adb - $(ECHO) " begin" >>tmp-sdefault.adb - $(ECHO) " return new String'(S4);" >>tmp-sdefault.adb - $(ECHO) " end Search_Dir_Prefix;" >>tmp-sdefault.adb - $(ECHO) "end Sdefault;" >> tmp-sdefault.adb - $(srcdir)/../move-if-change tmp-sdefault.adb sdefault.adb - touch stamp-sdefault - - ADA_TREE_H = ada-tree.h ada-tree.def - - # special compiles for sdefault without -gnatg, to avoid long line error - - sdefault.o : sdefault.ads sdefault.adb types.ads unchdeal.ads \ - system.ads s-exctab.ads s-stalib.ads unchconv.ads - $(ADAC) -c -O2 $(MOST_ADAFLAGS) $(ADA_INCLUDES) sdefault.adb - # force debugging information on s-tasdeb.o so that it is always # possible to set conditional breakpoints on tasks. --- 2031,2046 ---- *************** s-assert.o : s-assert.adb s-assert.ads *** 2570,2582 **** $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O2 \ $(ADA_INCLUDES) $< ! # force debugging information on s-stalib.o so that it is always ! # possible to set breakpoints on exceptions. ! s-stalib.o : s-stalib.adb s-stalib.ads ! $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O2 \ ! $(ADA_INCLUDES) $< # force debugging information and no optimization on s-memory.o so that it # is always possible to set breakpoint on __gnat_malloc and __gnat_free # this is important for gnatmem using GDB. memtrack.o is built from --- 2070,2084 ---- $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O2 \ $(ADA_INCLUDES) $< ! mdll.o : mdll.adb mdll.ads mdll-file.ads mdll-utl.ads ! $(CC) -c $(ALL_ADAFLAGS) -O2 $(ADA_INCLUDES) $< ! mdll-fil.o : mdll-fil.adb mdll.ads mdll-fil.ads ! $(CC) -c $(ALL_ADAFLAGS) -O2 $(ADA_INCLUDES) $< + mdll-utl.o : mdll-utl.adb mdll.ads mdll-utl.ads sdefault.ads types.ads + $(CC) -c $(ALL_ADAFLAGS) -O2 $(ADA_INCLUDES) $< + # force debugging information and no optimization on s-memory.o so that it # is always possible to set breakpoint on __gnat_malloc and __gnat_free # this is important for gnatmem using GDB. memtrack.o is built from *************** s-stalib.o : s-stalib.adb s-stalib.ads *** 2584,4355 **** s-memory.o : s-memory.adb s-memory.ads memtrack.o $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 \ ! $(ADA_INCLUDES) $< memtrack.o : memtrack.adb s-memory.ads $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 \ ! $(ADA_INCLUDES) $< # Need to keep the frame pointer in this file to pop the stack properly on # some targets. ! tracebak.o : tracebak.c ! $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) \ ! $(ALL_CPPFLAGS) $(INCLUDES) -fno-omit-frame-pointer $< ! expect.o : expect.c ! io-aux.o : io-aux.c argv.o : argv.c cal.o : cal.c - cio.o : cio.c - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) $(RT_FLAGS) \ - $(ALL_CPPFLAGS) $(INCLUDES) $< deftarg.o : deftarg.c errno.o : errno.c exit.o : raise.h exit.c adafinal.o : raise.h adafinal.c gmem.o : gmem.c - - raise.o : raise.c raise.h - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) $(RT_FLAGS) \ - $(ALL_CPPFLAGS) $(INCLUDES) $< - - ifeq ($(strip $(filter-out mips sgi irix5%,$(targ))),) - init.o : init.c ada.h types.h raise.h - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) $(RT_FLAGS) \ - $(ALL_CPPFLAGS) $(INCLUDES) $< - else - init.o : init.c ada.h types.h raise.h - $(CC) -c $(ALL_CFLAGS) $(ADA_CFLAGS) $(RT_FLAGS) \ - $(ALL_CPPFLAGS) $(INCLUDES) -fexceptions $< - endif - link.o : link.c sysdep.o : sysdep.c ! cuintp.o : cuintp.c $(CONFIG_H) $(TREE_H) ada.h types.h uintp.h atree.h \ ! stringt.h elists.h nlists.h fe.h gigi.h ! decl.o : decl.c $(CONFIG_H) $(TREE_H) $(srcdir)/../flags.h \ ! $(srcdir)/../toplev.h $(srcdir)/../convert.h ada.h types.h atree.h \ ! nlists.h elists.h uintp.h sinfo.h einfo.h snames.h namet.h \ ! stringt.h repinfo.h fe.h $(ADA_TREE_H) gigi.h ! misc.o : misc.c $(CONFIG_H) $(TREE_H) $(RTL_H) $(srcdir)/../expr.h \ ! ../insn-codes.h ../insn-flags.h ../insn-config.h $(srcdir)/../recog.h \ ! $(srcdir)/../flags.h $(srcdir)/../diagnostic.h $(srcdir)/../output.h \ ! $(srcdir)/../except.h ../tm_p.h $(srcdir)/../langhooks.h ada.h types.h \ ! atree.h nlists.h elists.h sinfo.h einfo.h namet.h stringt.h uintp.h fe.h \ ! $(ADA_TREE_H) gigi.h $(srcdir)/../langhooks-def.h $(srcdir)/../optabs.h targtyps.o : targtyps.c $(CONFIG_H) ada.h types.h atree.h nlists.h elists.h \ uintp.h sinfo.h einfo.h namet.h snames.h stringt.h urealp.h fe.h \ $(ADA_TREE_H) gigi.h ! trans.o : trans.c $(CONFIG_H) $(TREE_H) $(RTL_H) $(srcdir)/../flags.h ada.h \ ! types.h atree.h nlists.h elists.h uintp.h sinfo.h einfo.h \ ! namet.h snames.h stringt.h urealp.h fe.h $(ADA_TREE_H) gigi.h ! ! utils.o : utils.c $(CONFIG_H) $(TREE_H) $(srcdir)/../flags.h \ ! $(srcdir)/../convert.h $(srcdir)/../defaults.h ada.h types.h atree.h \ ! nlists.h elists.h sinfo.h einfo.h namet.h stringt.h uintp.h fe.h \ ! $(ADA_TREE_H) gigi.h ! ! utils2.o : utils2.c $(CONFIG_H) $(TREE_H) $(srcdir)/../flags.h ada.h types.h \ ! atree.h nlists.h elists.h sinfo.h einfo.h namet.h snames.h stringt.h \ ! uintp.h fe.h $(ADA_TREE_H) gigi.h ! ! # specific rules for tools needing target dependent sources ! # for each such source (e.g. mlib-tgt.adb) a link from the target ! # specific name to the default name is defined in the subdir "tools". ! # This subdir is added at the beginning of the source path fore the compilation ! # of this unit. Here are the step for adding a new target dependent source: ! # - create a Macro with the default name for the source (e.g. mlib-tgt) ! # - change the value if this Macro in each target-dependent section of this ! # Makefile (close to LIBGNAT_TARGET_PAIRS defs) if there is a ! # specific version of the file for this section ! # - Add a link from target dependent version to the default name in "tools" ! # (see stamp-tool_src_dir target) ! # - Add a specific target for the object in order to compile with ! # "tools" on the source path (see mlib-tgt) ! ! stamp-tool_src_dir: ! -$(RMDIR) tools ! -$(MKDIR) tools ! -$(LN_S) $(fsrcdir)/$(MLIB_TGT).adb tools/mlib-tgt.adb ! touch stamp-tool_src_dir ! ! mlib-tgt.o : stamp-tool_src_dir ! $(ADAC) -c -Itools $(ALL_ADAFLAGS) $(ADA_INCLUDES) tools/mlib-tgt.adb ! ! # GNAT DEPENDENCIES ! # regular dependencies ! a-chahan.o : ada.ads a-charac.ads a-chahan.ads a-chahan.adb a-chlat1.ads \ ! a-string.ads a-strmap.ads a-stmaco.ads system.ads s-exctab.ads \ ! s-secsta.ads s-stalib.ads s-stoele.ads s-unstyp.ads unchconv.ads ! ! a-charac.o : ada.ads a-charac.ads system.ads ! ! a-chlat1.o : ada.ads a-charac.ads a-chlat1.ads system.ads ! ! a-comlin.o : ada.ads a-comlin.ads a-comlin.adb system.ads s-secsta.ads \ ! s-stoele.ads ! ! ada.o : ada.ads system.ads ! ! a-except.o : ada.ads a-except.ads a-except.adb a-excpol.adb a-uncdea.ads \ ! gnat.ads g-hesora.ads system.ads s-exctab.ads s-except.ads s-mastop.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-stoele.adb s-traceb.ads unchconv.ads ! ! a-filico.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-filico.adb \ ! a-stream.ads a-tags.ads a-tags.adb gnat.ads g-htable.ads system.ads \ ! s-exctab.ads s-finimp.ads s-finroo.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads s-unstyp.ads \ ! unchconv.ads ! ! a-finali.o : ada.ads a-except.ads a-finali.ads a-finali.adb a-stream.ads \ ! a-tags.ads a-tags.adb gnat.ads g-htable.ads system.ads s-exctab.ads \ ! s-finimp.ads s-finroo.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-stratt.ads s-unstyp.ads unchconv.ads ! ! a-flteio.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-flteio.ads \ ! a-flteio.ads a-ioexce.ads a-stream.ads a-tags.ads a-textio.ads \ ! a-tiflau.ads a-tiflio.ads a-tiflio.adb interfac.ads i-cstrea.ads \ ! system.ads s-exctab.ads s-ficobl.ads s-finimp.ads s-finroo.ads \ ! s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-stratt.ads s-unstyp.ads unchconv.ads ! ! a-inteio.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-inteio.ads \ ! a-inteio.ads a-ioexce.ads a-stream.ads a-tags.ads a-textio.ads \ ! a-tiinau.ads a-tiinio.ads a-tiinio.adb interfac.ads i-cstrea.ads \ ! system.ads s-exctab.ads s-ficobl.ads s-finimp.ads s-finroo.ads \ ! s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-stratt.ads s-unstyp.ads unchconv.ads ! ! a-ioexce.o : ada.ads a-ioexce.ads system.ads s-exctab.ads s-stalib.ads \ ! unchconv.ads ! ! ali.o : ada.ads a-except.ads a-uncdea.ads ali.ads ali.adb alloc.ads \ ! butil.ads casing.ads debug.ads fname.ads gnat.ads g-htable.ads \ ! g-htable.adb g-os_lib.ads gnatvsn.ads hostparm.ads namet.ads opt.ads \ ! osint.ads output.ads rident.ads system.ads s-assert.ads s-exctab.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads unchconv.ads unchdeal.ads ! ! ali-util.o : ada.ads a-except.ads ali.ads ali-util.ads ali-util.adb \ ! alloc.ads binderr.ads casing.ads debug.ads gnat.ads g-htable.ads \ ! g-os_lib.ads gnatvsn.ads hostparm.ads interfac.ads namet.ads opt.ads \ ! osint.ads output.ads rident.ads system.ads s-assert.ads s-crc32.ads \ ! s-exctab.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads table.adb tree_io.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! alloc.o : alloc.ads system.ads ! ! a-stmaco.o : ada.ads a-charac.ads a-chlat1.ads a-string.ads a-strmap.ads \ ! a-stmaco.ads system.ads s-exctab.ads s-stalib.ads s-unstyp.ads \ ! unchconv.ads ! ! a-stream.o : ada.ads a-except.ads a-stream.ads a-tags.ads a-tags.adb \ ! gnat.ads g-htable.ads system.ads s-exctab.ads s-secsta.ads s-stalib.ads \ ! s-stoele.ads unchconv.ads ! ! a-strfix.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads a-string.ads \ ! a-strfix.ads a-strfix.adb a-strmap.ads a-strsea.ads system.ads \ ! s-exctab.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-unstyp.ads unchconv.ads ! ! a-string.o : ada.ads a-string.ads system.ads s-exctab.ads s-stalib.ads \ ! unchconv.ads ! ! a-strmap.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads a-string.ads \ ! a-strmap.ads a-strmap.adb system.ads s-bitops.ads s-exctab.ads \ ! s-secsta.ads s-stalib.ads s-stoele.ads s-unstyp.ads unchconv.ads ! ! a-strsea.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads a-string.ads \ ! a-strmap.ads a-strsea.ads a-strsea.adb system.ads s-exctab.ads \ ! s-stalib.ads s-unstyp.ads unchconv.ads ! ! a-strunb.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads a-finali.ads \ ! a-stream.ads a-string.ads a-strfix.ads a-strmap.ads a-strsea.ads \ ! a-strunb.ads a-strunb.adb a-tags.ads a-tags.adb a-uncdea.ads gnat.ads \ ! g-htable.ads system.ads s-exctab.ads s-finimp.ads s-finroo.ads \ ! s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-stratt.ads s-unstyp.ads unchconv.ads ! ! a-tags.o : ada.ads a-except.ads a-tags.ads a-tags.adb a-uncdea.ads \ ! gnat.ads g-htable.ads g-htable.adb system.ads s-exctab.ads s-secsta.ads \ ! s-stalib.ads s-stoele.ads unchconv.ads ! ! a-textio.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-tags.adb a-textio.ads a-textio.adb gnat.ads \ ! g-htable.ads interfac.ads i-cstrea.ads system.ads s-exctab.ads \ ! s-ficobl.ads s-fileio.ads s-finimp.ads s-finroo.ads s-parame.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-stratt.ads s-unstyp.ads unchconv.ads unchdeal.ads ! ! a-tiflau.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-textio.ads a-tiflau.ads a-tiflau.adb \ ! a-tigeau.ads interfac.ads i-cstrea.ads system.ads s-exctab.ads \ ! s-ficobl.ads s-finimp.ads s-finroo.ads s-imgrea.ads s-parame.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-stratt.ads s-unstyp.ads s-valrea.ads unchconv.ads ! ! a-tigeau.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-textio.ads a-tigeau.ads a-tigeau.adb \ ! interfac.ads i-cstrea.ads system.ads s-exctab.ads s-ficobl.ads \ ! s-fileio.ads s-finimp.ads s-finroo.ads s-parame.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads \ ! s-unstyp.ads unchconv.ads ! ! a-tiinau.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-textio.ads a-tigeau.ads a-tiinau.ads \ ! a-tiinau.adb interfac.ads i-cstrea.ads system.ads s-exctab.ads \ ! s-ficobl.ads s-finimp.ads s-finroo.ads s-imgbiu.ads s-imgint.ads \ ! s-imgllb.ads s-imglli.ads s-imgllw.ads s-imgwiu.ads s-parame.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-stratt.ads s-unstyp.ads s-valint.ads s-vallli.ads unchconv.ads ! ! a-tiocst.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-textio.ads a-tiocst.ads a-tiocst.adb \ ! interfac.ads i-cstrea.ads system.ads s-exctab.ads s-ficobl.ads \ ! s-fileio.ads s-finimp.ads s-finroo.ads s-parame.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads \ ! s-unstyp.ads unchconv.ads ! ! atree.o : ada.ads a-except.ads a-uncdea.ads alloc.ads atree.ads atree.adb \ ! casing.ads debug.ads einfo.ads elists.ads gnat.ads g-htable.ads \ ! g-htable.adb g-os_lib.ads hostparm.ads nlists.ads opt.ads output.ads \ ! sinfo.ads sinput.ads snames.ads system.ads s-assert.ads s-exctab.ads \ ! s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads table.ads table.adb tree_io.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! back_end.o : alloc.ads atree.ads back_end.ads back_end.adb casing.ads \ ! debug.ads einfo.ads elists.ads gnat.ads g-os_lib.ads hostparm.ads \ ! lib.ads namet.ads nlists.ads opt.ads osint.ads sinfo.ads sinput.ads \ ! snames.ads stand.ads stringt.ads switch.ads system.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! bcheck.o : ada.ads a-except.ads ali.ads ali-util.ads alloc.ads bcheck.ads \ ! bcheck.adb binderr.ads butil.ads casing.ads debug.ads fname.ads \ ! gnat.ads g-htable.ads g-os_lib.ads gnatvsn.ads hostparm.ads namet.ads \ ! opt.ads osint.ads output.ads rident.ads system.ads s-exctab.ads \ ! s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads table.ads types.ads unchconv.ads unchdeal.ads ! ! binde.o : ada.ads a-except.ads ali.ads alloc.ads binde.ads binde.adb \ ! binderr.ads butil.ads casing.ads debug.ads fname.ads gnat.ads \ ! g-htable.ads g-os_lib.ads gnatvsn.ads hostparm.ads namet.ads opt.ads \ ! output.ads rident.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads table.adb tree_io.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! binderr.o : ada.ads a-except.ads alloc.ads binderr.ads binderr.adb \ ! butil.ads hostparm.ads namet.ads opt.ads output.ads system.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! bindgen.o : ada.ads a-except.ads ali.ads alloc.ads binde.ads bindgen.ads \ ! bindgen.adb butil.ads casing.ads fname.ads gnat.ads g-hesora.ads \ ! g-htable.ads g-os_lib.ads gnatvsn.ads hostparm.ads namet.ads opt.ads \ ! osint.ads output.ads rident.ads sdefault.ads system.ads s-assert.ads \ ! s-exctab.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-strops.ads s-sopco3.ads s-sopco4.ads s-sopco5.ads \ ! s-wchcon.ads table.ads types.ads unchconv.ads unchdeal.ads ! ! bindusg.o : bindusg.ads bindusg.adb gnat.ads g-os_lib.ads osint.ads \ ! output.ads system.ads s-exctab.ads s-stalib.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! butil.o : alloc.ads butil.ads butil.adb hostparm.ads namet.ads output.ads \ ! system.ads s-exctab.ads s-stalib.ads table.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! casing.o : alloc.ads casing.ads casing.adb csets.ads hostparm.ads \ ! namet.ads opt.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads types.ads unchconv.ads unchdeal.ads widechar.ads ! ! checks.o : ada.ads a-except.ads alloc.ads atree.ads checks.ads checks.adb \ ! debug.ads einfo.ads elists.ads errout.ads exp_ch2.ads exp_util.ads \ ! freeze.ads get_targ.ads hostparm.ads namet.ads nlists.ads nmake.ads \ ! opt.ads rtsfind.ads sem.ads sem_eval.ads sem_res.ads sem_util.ads \ ! sem_warn.ads sinfo.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads tbuild.ads ttypes.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads validsw.ads ! ! comperr.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads \ ! comperr.ads comperr.adb debug.ads einfo.ads errout.ads fname.ads \ ! gnat.ads g-os_lib.ads gnatvsn.ads lib.ads namet.ads osint.ads \ ! output.ads sdefault.ads sinfo.ads sinput.ads snames.ads sprint.ads \ ! system.ads s-exctab.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads table.ads treepr.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! csets.o : csets.ads csets.adb hostparm.ads opt.ads system.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads types.ads unchconv.ads unchdeal.ads ! ! cstand.o : ada.ads a-except.ads alloc.ads atree.ads csets.ads cstand.ads \ ! cstand.adb debug.ads einfo.ads get_targ.ads hostparm.ads layout.ads \ ! namet.ads nlists.ads nmake.ads opt.ads sem_mech.ads sem_util.ads \ ! sinfo.ads snames.ads stand.ads system.ads s-assert.ads s-exctab.ads \ ! s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads table.ads tbuild.ads ttypef.ads ttypes.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! debug_a.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads debug.ads \ ! debug_a.ads debug_a.adb einfo.ads output.ads sinfo.ads sinput.ads \ ! snames.ads system.ads s-exctab.ads s-imgenu.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads table.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! debug.o : debug.ads debug.adb system.ads ! ! einfo.o : ada.ads a-except.ads alloc.ads atree.ads einfo.ads einfo.adb \ ! namet.ads nlists.ads output.ads sinfo.ads snames.ads stand.ads \ ! system.ads s-assert.ads s-exctab.ads s-imgenu.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads table.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! elists.o : ada.ads a-except.ads alloc.ads debug.ads elists.ads elists.adb \ ! gnat.ads g-os_lib.ads hostparm.ads opt.ads output.ads system.ads \ ! s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads table.adb \ ! tree_io.ads types.ads unchconv.ads unchdeal.ads ! ! errout.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! csets.ads debug.ads einfo.ads elists.ads errout.ads errout.adb \ ! fname.ads gnat.ads g-htable.ads g-os_lib.ads hostparm.ads lib.ads \ ! namet.ads nlists.ads opt.ads output.ads scans.ads sinfo.ads sinput.ads \ ! snames.ads stand.ads style.ads system.ads s-assert.ads s-exctab.ads \ ! s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads table.ads table.adb tree_io.ads types.ads \ ! uintp.ads uname.ads unchconv.ads unchdeal.ads urealp.ads ! ! eval_fat.o : alloc.ads einfo.ads eval_fat.ads eval_fat.adb sem_util.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads table.ads \ ! targparm.ads ttypef.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! exp_aggr.o : alloc.ads atree.ads checks.ads einfo.ads elists.ads \ ! exp_aggr.ads exp_aggr.adb exp_ch3.ads exp_ch7.ads exp_util.ads \ ! expander.ads freeze.ads hostparm.ads itypes.ads namet.ads nlists.ads \ ! nmake.ads opt.ads restrict.ads rident.ads rtsfind.ads sem.ads \ ! sem_ch3.ads sem_eval.ads sem_res.ads sem_util.ads sinfo.ads snames.ads \ ! stand.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads tbuild.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! expander.o : ada.ads a-except.ads alloc.ads atree.ads debug.ads \ ! debug_a.ads einfo.ads elists.ads errout.ads exp_aggr.ads exp_attr.ads \ ! exp_ch11.ads exp_ch12.ads exp_ch13.ads exp_ch2.ads exp_ch3.ads \ ! exp_ch4.ads exp_ch5.ads exp_ch6.ads exp_ch7.ads exp_ch8.ads exp_ch9.ads \ ! exp_prag.ads expander.ads expander.adb gnat.ads g-os_lib.ads \ ! hostparm.ads opt.ads output.ads sem.ads sem_ch8.ads sem_util.ads \ ! sinfo.ads snames.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads table.adb tree_io.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! exp_attr.o : alloc.ads atree.ads checks.ads einfo.ads exp_attr.ads \ ! exp_attr.adb exp_ch2.ads exp_ch9.ads exp_imgv.ads exp_pakd.ads \ ! exp_strm.ads exp_tss.ads exp_util.ads get_targ.ads gnatvsn.ads \ ! hostparm.ads lib.ads namet.ads nlists.ads nmake.ads opt.ads \ ! restrict.ads rident.ads rtsfind.ads sem.ads sem_ch13.ads sem_ch7.ads \ ! sem_ch8.ads sem_eval.ads sem_res.ads sem_util.ads sinfo.ads snames.ads \ ! stand.ads stringt.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads tbuild.ads ttypes.ads types.ads uintp.ads \ ! uname.ads unchconv.ads unchdeal.ads urealp.ads validsw.ads ! ! exp_ch11.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! debug.ads einfo.ads elists.ads exp_ch11.ads exp_ch11.adb exp_ch7.ads \ ! exp_util.ads gnat.ads g-htable.ads g-os_lib.ads hostparm.ads inline.ads \ ! lib.ads namet.ads nlists.ads nmake.ads opt.ads output.ads restrict.ads \ ! rident.ads rtsfind.ads sem.ads sem_ch5.ads sem_ch8.ads sem_res.ads \ ! sem_util.ads sinfo.ads sinput.ads snames.ads stand.ads stringt.ads \ ! system.ads s-assert.ads s-exctab.ads s-imgenu.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-wchcon.ads \ ! table.ads targparm.ads tbuild.ads tree_io.ads types.ads uintp.ads \ ! uname.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_ch12.o : alloc.ads atree.ads checks.ads einfo.ads exp_ch12.ads \ ! exp_ch12.adb exp_util.ads namet.ads nlists.ads nmake.ads rtsfind.ads \ ! sinfo.ads snames.ads stand.ads system.ads s-exctab.ads s-stalib.ads \ ! table.ads tbuild.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! exp_ch13.o : alloc.ads atree.ads einfo.ads elists.ads exp_ch13.ads \ ! exp_ch13.adb exp_ch3.ads exp_ch6.ads exp_imgv.ads exp_util.ads \ ! hostparm.ads namet.ads nlists.ads nmake.ads opt.ads rtsfind.ads sem.ads \ ! sem_ch7.ads sem_ch8.ads sem_eval.ads sem_util.ads sinfo.ads snames.ads \ ! stand.ads stringt.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads tbuild.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! exp_ch2.o : alloc.ads atree.ads einfo.ads elists.ads exp_ch2.ads \ ! exp_ch2.adb exp_smem.ads exp_util.ads exp_vfpt.ads hostparm.ads \ ! nlists.ads nmake.ads opt.ads rtsfind.ads sem.ads sem_res.ads \ ! sem_util.ads sinfo.ads snames.ads system.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads tbuild.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! exp_ch3.o : alloc.ads atree.ads checks.ads einfo.ads elists.ads \ ! exp_aggr.ads exp_ch11.ads exp_ch3.ads exp_ch3.adb exp_ch4.ads \ ! exp_ch7.ads exp_ch9.ads exp_disp.ads exp_dist.ads exp_smem.ads \ ! exp_strm.ads exp_tss.ads exp_util.ads freeze.ads get_targ.ads \ ! hostparm.ads namet.ads nlists.ads nmake.ads opt.ads restrict.ads \ ! rident.ads rtsfind.ads sem.ads sem_ch3.ads sem_ch8.ads sem_eval.ads \ ! sem_mech.ads sem_res.ads sem_util.ads sinfo.ads snames.ads stand.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads tbuild.ads ttypes.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads validsw.ads ! ! exp_ch4.o : alloc.ads atree.ads checks.ads einfo.ads elists.ads errout.ads \ ! exp_aggr.ads exp_ch3.ads exp_ch4.ads exp_ch4.adb exp_ch7.ads \ ! exp_ch9.ads exp_disp.ads exp_fixd.ads exp_pakd.ads exp_tss.ads \ ! exp_util.ads exp_vfpt.ads get_targ.ads hostparm.ads inline.ads \ ! namet.ads nlists.ads nmake.ads opt.ads rtsfind.ads sem.ads sem_cat.ads \ ! sem_ch13.ads sem_eval.ads sem_res.ads sem_type.ads sem_util.ads \ ! sinfo.ads sinfo-cn.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads tbuild.ads ttypes.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads validsw.ads ! ! exp_ch5.o : alloc.ads atree.ads checks.ads einfo.ads exp_aggr.ads \ ! exp_ch11.ads exp_ch5.ads exp_ch5.adb exp_ch7.ads exp_dbug.ads \ ! exp_pakd.ads exp_util.ads get_targ.ads hostparm.ads namet.ads \ ! nlists.ads nmake.ads opt.ads restrict.ads rident.ads rtsfind.ads \ ! sem.ads sem_ch13.ads sem_ch8.ads sem_eval.ads sem_res.ads sem_util.ads \ ! sinfo.ads snames.ads stand.ads system.ads s-assert.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads tbuild.ads ttypes.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads validsw.ads ! ! exp_ch6.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! checks.ads debug.ads einfo.ads elists.ads errout.ads exp_ch11.ads \ ! exp_ch2.ads exp_ch3.ads exp_ch6.ads exp_ch6.adb exp_ch7.ads exp_ch9.ads \ ! exp_dbug.ads exp_disp.ads exp_dist.ads exp_intr.ads exp_pakd.ads \ ! exp_tss.ads exp_util.ads freeze.ads get_targ.ads gnat.ads g-htable.ads \ ! g-os_lib.ads hostparm.ads inline.ads lib.ads namet.ads nlists.ads \ ! nmake.ads opt.ads output.ads restrict.ads rident.ads rtsfind.ads \ ! sem.ads sem_ch12.ads sem_ch13.ads sem_ch6.ads sem_ch8.ads sem_disp.ads \ ! sem_dist.ads sem_res.ads sem_util.ads sinfo.ads sinput.ads snames.ads \ ! stand.ads system.ads s-assert.ads s-exctab.ads s-imgenu.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads tbuild.ads tree_io.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads validsw.ads ! ! exp_ch7.o : alloc.ads atree.ads debug.ads einfo.ads exp_ch11.ads \ ! exp_ch7.ads exp_ch7.adb exp_ch9.ads exp_dbug.ads exp_tss.ads \ ! exp_util.ads freeze.ads get_targ.ads hostparm.ads lib.ads lib-xref.ads \ ! namet.ads nlists.ads nmake.ads opt.ads output.ads restrict.ads \ ! rident.ads rtsfind.ads sem.ads sem_ch3.ads sem_ch7.ads sem_ch8.ads \ ! sem_res.ads sem_type.ads sem_util.ads sinfo.ads snames.ads stand.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads targparm.ads tbuild.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! exp_ch8.o : alloc.ads atree.ads einfo.ads exp_ch8.ads exp_ch8.adb \ ! exp_dbug.ads exp_util.ads get_targ.ads hostparm.ads namet.ads \ ! nlists.ads opt.ads rtsfind.ads sem.ads sem_ch8.ads sinfo.ads snames.ads \ ! stand.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_ch9.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! checks.ads debug.ads einfo.ads elists.ads errout.ads exp_ch11.ads \ ! exp_ch3.ads exp_ch6.ads exp_ch9.ads exp_ch9.adb exp_dbug.ads \ ! exp_smem.ads exp_tss.ads exp_util.ads freeze.ads get_targ.ads gnat.ads \ ! g-htable.ads g-os_lib.ads hostparm.ads namet.ads nlists.ads nmake.ads \ ! opt.ads output.ads restrict.ads rident.ads rtsfind.ads sem.ads \ ! sem_ch11.ads sem_ch6.ads sem_ch8.ads sem_elab.ads sem_res.ads \ ! sem_util.ads sinfo.ads sinput.ads snames.ads stand.ads system.ads \ ! s-assert.ads s-exctab.ads s-imgenu.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-wchcon.ads table.ads \ ! tbuild.ads tree_io.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! exp_code.o : alloc.ads atree.ads einfo.ads errout.ads exp_code.ads \ ! exp_code.adb fname.ads hostparm.ads lib.ads namet.ads nlists.ads \ ! nmake.ads opt.ads rtsfind.ads sem_eval.ads sem_util.ads sinfo.ads \ ! snames.ads stringt.ads system.ads s-assert.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads tbuild.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! exp_dbug.o : ada.ads a-except.ads a-uncdea.ads alloc.ads atree.ads \ ! casing.ads debug.ads einfo.ads exp_dbug.ads exp_dbug.adb exp_util.ads \ ! freeze.ads get_targ.ads gnat.ads g-htable.ads g-htable.adb g-os_lib.ads \ ! hostparm.ads lib.ads namet.ads nlists.ads nmake.ads opt.ads output.ads \ ! rtsfind.ads sem_eval.ads sem_util.ads sinfo.ads sinput.ads snames.ads \ ! stand.ads stringt.ads system.ads s-assert.ads s-exctab.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! exp_disp.o : alloc.ads atree.ads checks.ads einfo.ads elists.ads \ ! errout.ads exp_ch7.ads exp_disp.ads exp_disp.adb exp_tss.ads \ ! exp_util.ads fname.ads hostparm.ads itypes.ads lib.ads namet.ads \ ! nlists.ads nmake.ads opt.ads rtsfind.ads sem_disp.ads sem_res.ads \ ! sem_util.ads sinfo.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads tbuild.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_dist.o : ada.ads a-uncdea.ads alloc.ads atree.ads einfo.ads elists.ads \ ! exp_dist.ads exp_dist.adb exp_tss.ads exp_util.ads gnat.ads \ ! g-htable.ads g-htable.adb hostparm.ads lib.ads namet.ads nlists.ads \ ! nmake.ads opt.ads rtsfind.ads sem.ads sem_ch3.ads sem_ch8.ads \ ! sem_dist.ads sem_util.ads sinfo.ads snames.ads stand.ads stringt.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads tbuild.ads types.ads uintp.ads uname.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! exp_fixd.o : alloc.ads atree.ads checks.ads einfo.ads exp_fixd.ads \ ! exp_fixd.adb exp_util.ads get_targ.ads hostparm.ads namet.ads \ ! nlists.ads nmake.ads opt.ads restrict.ads rident.ads rtsfind.ads \ ! sem.ads sem_eval.ads sem_res.ads sem_util.ads sinfo.ads snames.ads \ ! stand.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads tbuild.ads ttypes.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! exp_imgv.o : alloc.ads atree.ads casing.ads checks.ads einfo.ads \ ! exp_imgv.ads exp_imgv.adb exp_util.ads get_targ.ads hostparm.ads \ ! namet.ads nlists.ads nmake.ads opt.ads rtsfind.ads sem_res.ads \ ! sinfo.ads snames.ads stand.ads stringt.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads tbuild.ads ttypes.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_intr.o : alloc.ads atree.ads casing.ads einfo.ads errout.ads \ ! exp_ch11.ads exp_ch4.ads exp_ch7.ads exp_ch9.ads exp_code.ads \ ! exp_fixd.ads exp_intr.ads exp_intr.adb exp_util.ads hostparm.ads \ ! itypes.ads namet.ads nlists.ads nmake.ads opt.ads restrict.ads \ ! rident.ads rtsfind.ads sem.ads sem_eval.ads sem_res.ads sem_util.ads \ ! sinfo.ads sinput.ads snames.ads stand.ads stringt.ads system.ads \ ! s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! tbuild.ads types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_pakd.o : alloc.ads atree.ads checks.ads einfo.ads exp_dbug.ads \ ! exp_pakd.ads exp_pakd.adb exp_util.ads get_targ.ads hostparm.ads \ ! namet.ads nlists.ads nmake.ads opt.ads rtsfind.ads sem.ads sem_ch13.ads \ ! sem_ch8.ads sem_eval.ads sem_res.ads sem_util.ads sinfo.ads snames.ads \ ! stand.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads targparm.ads tbuild.ads ttypes.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_prag.o : alloc.ads atree.ads casing.ads einfo.ads errout.ads \ ! exp_ch11.ads exp_prag.ads exp_prag.adb exp_tss.ads exp_util.ads \ ! expander.ads hostparm.ads namet.ads nlists.ads nmake.ads opt.ads \ ! rtsfind.ads sem.ads sem_eval.ads sem_res.ads sem_util.ads sinfo.ads \ ! sinput.ads snames.ads stand.ads stringt.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads tbuild.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_smem.o : alloc.ads atree.ads einfo.ads exp_smem.ads exp_smem.adb \ ! exp_util.ads hostparm.ads namet.ads nlists.ads nmake.ads opt.ads \ ! rtsfind.ads sem.ads sem_util.ads sinfo.ads snames.ads stand.ads \ ! stringt.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! tbuild.ads types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_strm.o : alloc.ads atree.ads einfo.ads exp_strm.ads exp_strm.adb \ ! exp_tss.ads get_targ.ads lib.ads namet.ads nlists.ads nmake.ads \ ! rtsfind.ads sinfo.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads table.ads tbuild.ads ttypes.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_tss.o : alloc.ads atree.ads einfo.ads elists.ads exp_tss.ads \ ! exp_tss.adb exp_util.ads lib.ads rtsfind.ads sem_util.ads sinfo.ads \ ! snames.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads table.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! exp_util.o : alloc.ads atree.ads checks.ads einfo.ads elists.ads \ ! errout.ads exp_ch11.ads exp_ch7.ads exp_util.ads exp_util.adb \ ! get_targ.ads hostparm.ads inline.ads itypes.ads lib.ads namet.ads \ ! nlists.ads nmake.ads opt.ads restrict.ads rident.ads rtsfind.ads \ ! sem.ads sem_ch8.ads sem_eval.ads sem_res.ads sem_util.ads sinfo.ads \ ! snames.ads stand.ads stringt.ads system.ads s-assert.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads tbuild.ads ttypes.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads validsw.ads ! ! exp_vfpt.o : alloc.ads atree.ads einfo.ads exp_vfpt.ads exp_vfpt.adb \ ! namet.ads nlists.ads nmake.ads rtsfind.ads sem_res.ads sinfo.ads \ ! snames.ads stand.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! table.ads tbuild.ads ttypef.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! fname.o : ada.ads a-except.ads alloc.ads debug.ads fname.ads fname.adb \ ! gnat.ads g-os_lib.ads hostparm.ads namet.ads opt.ads output.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads unchconv.ads unchdeal.ads ! ! fmap.o : alloc.ads debug.ads fmap.ads fmap.adb hostparm.ads namet.ads opt.ads \ ! osint.ads output.ads table.ads table.adb tree_io.ads types.ads ! ! fname-sf.o : alloc.ads casing.ads fname.ads fname-sf.ads fname-sf.adb \ ! fname-uf.ads gnat.ads g-os_lib.ads namet.ads osint.ads sfn_scan.ads \ ! system.ads s-exctab.ads s-stalib.ads s-stoele.ads table.ads types.ads \ ! unchconv.ads unchdeal.ads ! ! fname-uf.o : ada.ads a-except.ads a-uncdea.ads alloc.ads casing.ads \ ! debug.ads fname.ads fname-uf.ads fname-uf.adb gnat.ads g-htable.ads \ ! g-htable.adb g-os_lib.ads hostparm.ads krunch.ads namet.ads opt.ads \ ! osint.ads output.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads table.ads table.adb tree_io.ads types.ads \ ! unchconv.ads unchdeal.ads widechar.ads ! ! freeze.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! debug.ads einfo.ads elists.ads errout.ads exp_ch11.ads exp_ch7.ads \ ! exp_pakd.ads exp_util.ads freeze.ads freeze.adb get_targ.ads gnat.ads \ ! g-htable.ads g-os_lib.ads hostparm.ads layout.ads namet.ads nlists.ads \ ! nmake.ads opt.ads output.ads restrict.ads rident.ads rtsfind.ads \ ! sem.ads sem_cat.ads sem_ch13.ads sem_ch6.ads sem_ch7.ads sem_ch8.ads \ ! sem_eval.ads sem_mech.ads sem_prag.ads sem_res.ads sem_util.ads \ ! sinfo.ads sinput.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-wchcon.ads table.ads targparm.ads \ ! tbuild.ads tree_io.ads ttypes.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! frontend.o : alloc.ads atree.ads casing.ads checks.ads cstand.ads \ ! debug.ads einfo.ads elists.ads exp_ch11.ads exp_dbug.ads fname.ads \ ! fname-uf.ads frontend.ads frontend.adb get_targ.ads gnat.ads \ ! g-os_lib.ads hostparm.ads inline.ads lib.ads lib-load.ads live.ads \ ! namet.ads nlists.ads opt.ads osint.ads output.ads par.ads rtsfind.ads \ ! scn.ads sem.ads sem_ch8.ads sem_elab.ads sem_prag.ads sem_warn.ads \ ! sinfo.ads sinput.ads sinput-l.ads snames.ads sprint.ads system.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! g-casuti.o : gnat.ads g-casuti.ads g-casuti.adb system.ads ! ! g-comlin.o : ada.ads a-comlin.ads a-except.ads a-finali.ads a-filico.ads \ ! a-stream.ads a-tags.ads gnat.ads g-comlin.ads g-comlin.adb g-dirope.ads \ ! g-regexp.ads system.ads s-exctab.ads s-finimp.ads s-finroo.ads \ ! s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-stratt.ads s-strops.ads s-unstyp.ads unchconv.ads ! ! g-diopit.o : ada.ads a-charac.ads a-chahan.ads a-chlat1.ads a-except.ads \ ! a-finali.ads a-filico.ads a-stream.ads a-string.ads a-strfix.ads \ ! a-strmap.ads a-tags.ads gnat.ads g-dirope.ads g-dirope.adb \ ! g-os_lib.ads g-regexp.ads system.ads s-exctab.ads s-finimp.ads \ ! s-finroo.ads s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads s-unstyp.ads \ ! unchconv.ads unchdeal.ads ! ! g-dirope.o : ada.ads a-charac.ads a-chahan.ads a-chlat1.ads a-except.ads \ ! a-finali.ads a-filico.ads a-stream.ads a-string.ads a-strfix.ads \ ! a-strmap.ads a-tags.ads gnat.ads g-dirope.ads g-dirope.adb \ ! g-os_lib.ads system.ads s-exctab.ads s-finimp.ads \ ! s-finroo.ads s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads s-unstyp.ads \ ! unchconv.ads unchdeal.ads ! ! get_targ.o : get_targ.ads get_targ.adb system.ads s-exctab.ads \ ! s-stalib.ads types.ads unchconv.ads unchdeal.ads ! ! g-except.o : gnat.ads g-except.ads system.ads ! ! g-hesora.o : gnat.ads g-hesora.ads g-hesora.adb system.ads ! ! g-htable.o : ada.ads a-uncdea.ads gnat.ads g-htable.ads g-htable.adb \ ! system.ads ! ! g-io_aux.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-textio.ads gnat.ads g-io_aux.ads g-io_aux.adb \ ! interfac.ads i-cstrea.ads system.ads s-exctab.ads s-ficobl.ads \ ! s-finimp.ads s-finroo.ads s-parame.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads \ ! s-unstyp.ads unchconv.ads ! ! gnat1drv.o : ada.ads a-except.ads alloc.ads atree.ads back_end.ads \ ! casing.ads comperr.ads csets.ads debug.ads einfo.ads elists.ads \ ! errout.ads fname.ads fname-uf.ads frontend.ads get_targ.ads gnat.ads \ ! g-os_lib.ads gnat1drv.ads gnat1drv.adb gnatvsn.ads hostparm.ads \ ! inline.ads lib.ads lib-writ.ads namet.ads nlists.ads opt.ads osint.ads \ ! output.ads repinfo.ads restrict.ads rident.ads sem.ads sem_ch13.ads \ ! sem_warn.ads sinfo.ads sinput.ads sinput-l.ads snames.ads sprint.ads \ ! stringt.ads system.ads s-assert.ads s-exctab.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-wchcon.ads table.ads \ ! targparm.ads tree_gen.ads treepr.ads ttypes.ads types.ads uintp.ads \ ! uname.ads unchconv.ads unchdeal.ads urealp.ads usage.ads ! ! gnat.o : gnat.ads system.ads ! ! gnatbind.o : ada.ads a-except.ads ali.ads ali-util.ads alloc.ads \ ! bcheck.ads binde.ads binderr.ads bindgen.ads bindusg.ads butil.ads \ ! casing.ads csets.ads gnat.ads g-htable.ads g-os_lib.ads gnatbind.ads \ ! gnatbind.adb gnatvsn.ads hostparm.ads namet.ads opt.ads osint.ads \ ! output.ads rident.ads switch.ads system.ads s-assert.ads s-exctab.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-strops.ads s-wchcon.ads table.ads types.ads unchconv.ads unchdeal.ads ! ! gnatchop.o : ada.ads a-comlin.ads a-except.ads a-finali.ads a-filico.ads \ ! a-ioexce.ads a-stream.ads a-tags.ads a-textio.ads gnat.ads g-comlin.ads \ ! g-dirope.ads g-hesorg.ads g-hesorg.adb g-os_lib.ads g-regexp.ads \ ! g-table.ads g-table.adb gnatchop.adb gnatvsn.ads hostparm.ads \ ! interfac.ads i-cstrea.ads system.ads s-assert.ads s-exctab.ads \ ! s-ficobl.ads s-finimp.ads s-finroo.ads s-imgint.ads s-parame.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-stratt.ads s-strops.ads s-sopco3.ads s-sopco4.ads s-sopco5.ads \ ! s-unstyp.ads s-valint.ads unchconv.ads unchdeal.ads ! ! gnatcmd.o : ada.ads a-charac.ads a-chahan.ads a-comlin.ads a-except.ads \ ! a-finali.ads a-filico.ads a-ioexce.ads a-stream.ads a-tags.ads \ ! a-textio.ads debug.ads gnat.ads g-os_lib.ads gnatcmd.ads gnatcmd.adb \ ! gnatvsn.ads hostparm.ads interfac.ads i-cstrea.ads opt.ads osint.ads \ ! output.ads sdefault.ads system.ads s-assert.ads s-exctab.ads \ ! s-ficobl.ads s-finimp.ads s-finroo.ads s-imgint.ads s-parame.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-stratt.ads s-strops.ads s-sopco4.ads s-unstyp.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads unchconv.ads unchdeal.ads ! ! gnatfind.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads a-finali.ads \ ! a-filico.ads a-ioexce.ads a-stream.ads a-string.ads a-strfix.ads \ ! a-strmap.ads a-strunb.ads a-tags.ads a-textio.ads gnat.ads g-comlin.ads \ ! g-dirope.ads g-dyntab.ads g-os_lib.ads g-regexp.ads gnatfind.adb \ ! gnatvsn.ads hostparm.ads interfac.ads i-cstrea.ads osint.ads system.ads \ ! s-exctab.ads s-ficobl.ads s-finimp.ads s-finroo.ads s-parame.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-stratt.ads s-strops.ads s-unstyp.ads types.ads unchconv.ads \ ! unchdeal.ads xr_tabls.ads xref_lib.ads ! ! gnatkr.o : ada.ads a-charac.ads a-chahan.ads a-comlin.ads a-except.ads \ ! gnatkr.ads gnatkr.adb gnatvsn.ads krunch.ads system.ads s-exctab.ads \ ! s-io.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads unchconv.ads ! ! gnatlink.o : ada.ads a-comlin.ads a-except.ads debug.ads gnat.ads \ ! g-os_lib.ads gnatlink.ads gnatlink.adb gnatvsn.ads hostparm.ads \ ! interfac.ads i-cstrea.ads opt.ads osint.ads output.ads system.ads \ ! s-assert.ads s-exctab.ads s-parame.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-strops.ads s-sopco3.ads \ ! s-sopco4.ads s-wchcon.ads table.ads table.adb tree_io.ads types.ads \ ! unchconv.ads unchdeal.ads ! ! gnatls.o : ada.ads a-except.ads ali.ads ali-util.ads alloc.ads binderr.ads \ ! butil.ads casing.ads csets.ads fname.ads gnat.ads g-htable.ads \ ! g-os_lib.ads gnatls.ads gnatls.adb gnatvsn.ads hostparm.ads namet.ads \ ! opt.ads osint.ads output.ads prj.ads prj-com.ads prj-env.ads \ ! prj-env.adb prj-ext.ads prj-pars.ads prj-util.ads rident.ads scans.ads \ ! snames.ads stringt.ads system.ads s-assert.ads s-exctab.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-strops.ads s-sopco3.ads s-sopco4.ads s-wchcon.ads table.ads types.ads \ ! unchconv.ads unchdeal.ads ! ! gnatmake.o : gnat.ads g-os_lib.ads gnatmake.ads gnatmake.adb gnatvsn.ads \ ! make.ads system.ads s-exctab.ads s-stalib.ads table.ads types.ads \ ! unchconv.ads unchdeal.ads ! ! gnatmem.o : ada.ads a-comlin.ads a-except.ads a-finali.ads a-filico.ads \ ! a-flteio.ads a-inteio.ads a-ioexce.ads a-stream.ads a-tags.ads \ ! a-textio.ads a-tiocst.ads a-tiflio.ads a-tiinio.ads a-uncdea.ads \ ! gnat.ads g-hesorg.ads g-hesorg.adb g-htable.ads g-htable.adb \ ! g-os_lib.ads gnatmem.adb gnatvsn.ads interfac.ads i-cstrea.ads \ ! memroot.ads system.ads s-exctab.ads s-ficobl.ads s-finimp.ads \ ! s-finroo.ads s-imgint.ads s-parame.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads \ ! s-sopco3.ads s-sopco4.ads s-sopco5.ads s-unstyp.ads s-valint.ads \ ! s-valuns.ads unchconv.ads unchdeal.ads ! ! gnatprep.o : ada.ads a-charac.ads a-chahan.ads a-chlat1.ads a-comlin.ads \ ! a-except.ads a-finali.ads a-filico.ads a-ioexce.ads a-stream.ads \ ! a-string.ads a-strfix.ads a-strmap.ads a-tags.ads a-textio.ads gnat.ads \ ! g-comlin.ads g-dirope.ads g-hesorg.ads g-hesorg.adb g-regexp.ads \ ! gnatprep.ads gnatprep.adb gnatvsn.ads interfac.ads i-cstrea.ads \ ! system.ads s-exctab.ads s-ficobl.ads s-finimp.ads s-finroo.ads \ ! s-imgint.ads s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads s-sopco3.ads \ ! s-sopco4.ads s-unstyp.ads unchconv.ads ! ! gnatpsta.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-textio.ads get_targ.ads gnatpsta.adb \ ! gnatvsn.ads interfac.ads i-cstrea.ads system.ads s-exctab.ads \ ! s-ficobl.ads s-finimp.ads s-finroo.ads s-imgint.ads s-imgrea.ads \ ! s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-stratt.ads s-strops.ads s-sopco3.ads s-sopco4.ads \ ! s-sopco5.ads s-unstyp.ads ttypef.ads ttypes.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! gnatpsys.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-textio.ads gnatpsys.adb gnatvsn.ads \ ! interfac.ads i-cstrea.ads system.ads s-exctab.ads s-ficobl.ads \ ! s-finimp.ads s-finroo.ads s-imgenu.ads s-imgint.ads s-imglli.ads \ ! s-imgrea.ads s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-stratt.ads s-sopco3.ads s-sopco5.ads \ ! s-unstyp.ads unchconv.ads ! ! gnatvsn.o : gnatvsn.ads system.ads ! ! gnatxref.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads a-finali.ads \ ! a-filico.ads a-ioexce.ads a-stream.ads a-string.ads a-strfix.ads \ ! a-strmap.ads a-strunb.ads a-tags.ads a-textio.ads gnat.ads g-comlin.ads \ ! g-dirope.ads g-dyntab.ads g-os_lib.ads g-regexp.ads gnatvsn.ads \ ! gnatxref.adb hostparm.ads interfac.ads i-cstrea.ads osint.ads \ ! system.ads s-exctab.ads s-ficobl.ads s-finimp.ads s-finroo.ads \ ! s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-stratt.ads s-strops.ads s-unstyp.ads types.ads \ ! unchconv.ads unchdeal.ads xr_tabls.ads xref_lib.ads ! ! g-os_lib.o : ada.ads a-except.ads gnat.ads g-os_lib.ads g-os_lib.adb \ ! system.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads unchconv.ads unchdeal.ads ! ! g-regexp.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-tags.adb a-textio.ads gnat.ads g-casuti.ads \ ! g-htable.ads g-regexp.ads g-regexp.adb interfac.ads i-cstrea.ads \ ! system.ads s-exctab.ads s-ficobl.ads s-finimp.ads s-finroo.ads \ ! s-imgint.ads s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads s-sopco3.ads \ ! s-unstyp.ads unchconv.ads unchdeal.ads ! ! g-speche.o : gnat.ads g-speche.ads g-speche.adb system.ads ! ! hlo.o : hlo.ads hlo.adb output.ads system.ads s-exctab.ads s-stalib.ads \ ! types.ads unchconv.ads unchdeal.ads ! ! hostparm.o : hostparm.ads system.ads ! ! i-cstrea.o : interfac.ads i-cstrea.ads i-cstrea.adb system.ads \ ! s-parame.ads unchconv.ads ! ! impunit.o : alloc.ads hostparm.ads impunit.ads impunit.adb lib.ads \ ! namet.ads opt.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads types.ads unchconv.ads unchdeal.ads ! ! inline.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads debug.ads \ ! einfo.ads elists.ads errout.ads exp_ch11.ads exp_ch7.ads exp_tss.ads \ ! fname.ads fname-uf.ads gnat.ads g-os_lib.ads hostparm.ads inline.ads \ ! inline.adb lib.ads namet.ads nlists.ads opt.ads output.ads sem_ch10.ads \ ! sem_ch12.ads sem_ch8.ads sem_util.ads sinfo.ads snames.ads stand.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads uintp.ads uname.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! interfac.o : interfac.ads system.ads ! ! itypes.o : alloc.ads atree.ads einfo.ads itypes.ads itypes.adb namet.ads \ ! sem_util.ads sinfo.ads snames.ads stand.ads system.ads s-exctab.ads \ ! s-stalib.ads table.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! krunch.o : hostparm.ads krunch.ads krunch.adb system.ads s-stoele.ads ! ! layout.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! checks.ads debug.ads einfo.ads elists.ads errout.ads exp_ch3.ads \ ! exp_util.ads get_targ.ads gnat.ads g-htable.ads g-os_lib.ads \ ! hostparm.ads layout.ads layout.adb namet.ads nlists.ads nmake.ads \ ! opt.ads output.ads repinfo.ads rtsfind.ads sem.ads sem_ch13.ads \ ! sem_eval.ads sem_res.ads sem_util.ads sinfo.ads sinput.ads snames.ads \ ! stand.ads system.ads s-assert.ads s-exctab.ads s-imgenu.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads targparm.ads tbuild.ads tree_io.ads ttypes.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! lib.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads debug.ads \ ! einfo.ads fname.ads gnat.ads g-hesora.ads g-os_lib.ads hostparm.ads \ ! lib.ads lib.adb lib-list.adb lib-sort.adb namet.ads opt.ads output.ads \ ! sinfo.ads sinput.ads snames.ads stand.ads stringt.ads system.ads \ ! s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads table.adb \ ! tree_io.ads types.ads uintp.ads uname.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! lib-load.o : alloc.ads atree.ads casing.ads debug.ads einfo.ads errout.ads \ ! fname.ads fname-uf.ads gnat.ads g-os_lib.ads hostparm.ads lib.ads \ ! lib-load.ads lib-load.adb namet.ads nlists.ads nmake.ads opt.ads \ ! osint.ads output.ads par.ads scn.ads sinfo.ads sinput.ads sinput-l.ads \ ! snames.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! tbuild.ads types.ads uintp.ads uname.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! lib-util.o : alloc.ads gnat.ads g-os_lib.ads hostparm.ads lib.ads \ ! lib-util.ads lib-util.adb namet.ads osint.ads system.ads s-exctab.ads \ ! s-stalib.ads s-stoele.ads table.ads types.ads unchconv.ads unchdeal.ads ! ! lib-writ.o : ali.ads alloc.ads atree.ads casing.ads einfo.ads errout.ads \ ! fname.ads fname-uf.ads gnat.ads g-htable.ads g-os_lib.ads gnatvsn.ads \ ! hostparm.ads lib.ads lib-util.ads lib-writ.ads lib-writ.adb \ ! lib-xref.ads namet.ads nlists.ads opt.ads osint.ads par.ads \ ! restrict.ads rident.ads scn.ads sinfo.ads sinput.ads snames.ads \ ! stringt.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! targparm.ads types.ads uintp.ads uname.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! lib-xref.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads csets.ads \ ! debug.ads einfo.ads gnat.ads g-hesora.ads g-os_lib.ads hostparm.ads \ ! lib.ads lib-util.ads lib-xref.ads lib-xref.adb namet.ads opt.ads \ ! output.ads sinfo.ads sinput.ads snames.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads table.adb tree_io.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads widechar.ads ! ! live.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! debug.ads einfo.ads elists.ads gnat.ads g-htable.ads g-os_lib.ads \ ! lib.ads live.ads live.adb nlists.ads output.ads sem_util.ads sinfo.ads \ ! sinput.ads snames.ads system.ads s-assert.ads s-exctab.ads s-imgenu.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-unstyp.ads table.ads tree_io.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! make.o : ada.ads a-charac.ads a-chahan.ads a-comlin.ads a-except.ads \ ! ali.ads ali-util.ads alloc.ads casing.ads csets.ads debug.ads \ ! errout.ads fname.ads fname-sf.ads fname-uf.ads gnat.ads g-htable.ads \ ! g-os_lib.ads gnatvsn.ads hostparm.ads make.ads make.adb makeusg.ads \ ! mlib.ads mlib-prj.ads mlib-tgt.ads mlib-utl.ads namet.ads opt.ads \ ! osint.ads output.ads prj.ads prj.adb prj-attr.ads prj-com.ads \ ! prj-env.ads prj-env.adb prj-ext.ads prj-pars.ads prj-util.ads \ ! rident.ads scans.ads scn.ads sfn_scan.ads sinfo.ads sinfo-cn.ads \ ! sinput.ads sinput-l.ads snames.ads stringt.ads switch.ads system.ads \ ! s-assert.ads s-exctab.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-strops.ads s-sopco3.ads s-sopco5.ads \ ! s-wchcon.ads table.ads table.adb tree_io.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! makeusg.o : gnat.ads g-os_lib.ads makeusg.ads makeusg.adb osint.ads \ ! output.ads system.ads s-exctab.ads s-stalib.ads types.ads unchconv.ads \ ! unchdeal.ads usage.ads ! ! memroot.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-textio.ads a-uncdea.ads gnat.ads g-htable.ads \ ! g-htable.adb g-table.ads g-table.adb interfac.ads i-cstrea.ads \ ! memroot.ads memroot.adb system.ads s-assert.ads s-exctab.ads \ ! s-ficobl.ads s-finimp.ads s-finroo.ads s-parame.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads \ ! s-sopco5.ads s-unstyp.ads unchconv.ads ! ! memtrack.o : ada.ads a-except.ads system.ads s-memory.ads memtrack.adb \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-traceb.ads \ ! unchconv.ads ! ! mlib.o : ada.ads a-charac.ads a-chahan.ads a-except.ads gnat.ads \ ! g-os_lib.ads hostparm.ads mlib.ads mlib.adb mlib-utl.ads opt.ads \ ! osint.ads output.ads system.ads s-exctab.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-sopco4.ads s-wchcon.ads \ ! types.ads unchconv.ads unchdeal.ads ! ! mlib-fil.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads a-string.ads \ ! a-strfix.ads a-strmap.ads gnat.ads g-os_lib.ads mlib.ads mlib-fil.ads \ ! mlib-fil.adb mlib-tgt.ads system.ads s-exctab.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-sopco3.ads \ ! s-unstyp.ads types.ads unchconv.ads unchdeal.ads ! ! mlib-prj.o : ada.ads a-charac.ads a-chahan.ads a-except.ads a-finali.ads \ ! a-filico.ads a-stream.ads a-tags.ads alloc.ads casing.ads debug.ads \ ! gnat.ads g-dirope.ads g-os_lib.ads hostparm.ads mlib.ads mlib-fil.ads \ ! mlib-prj.ads mlib-prj.adb mlib-tgt.ads namet.ads opt.ads osint.ads \ ! output.ads prj.ads scans.ads system.ads s-assert.ads s-exctab.ads \ ! s-finimp.ads s-finroo.ads s-imgenu.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads \ ! s-sopco3.ads s-unstyp.ads s-wchcon.ads table.ads table.adb tree_io.ads \ ! types.ads unchconv.ads unchdeal.ads ! ! mlib-tgt.o : ada.ads a-charac.ads a-chahan.ads a-except.ads a-finali.ads \ ! a-filico.ads a-stream.ads a-tags.ads alloc.ads gnat.ads g-dirope.ads \ ! g-os_lib.ads hostparm.ads mlib.ads mlib-fil.ads mlib-tgt.ads \ ! mlib-tgt.adb mlib-utl.ads namet.ads opt.ads osint.ads output.ads \ ! system.ads s-exctab.ads s-finimp.ads s-finroo.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads \ ! s-strops.ads s-sopco3.ads s-sopco4.ads s-unstyp.ads s-wchcon.ads \ ! table.ads types.ads unchconv.ads unchdeal.ads ! ! mlib-utl.o : ada.ads a-except.ads alloc.ads gnat.ads g-os_lib.ads \ ! hostparm.ads mlib.ads mlib-fil.ads mlib-tgt.ads mlib-utl.ads \ ! mlib-utl.adb namet.ads opt.ads osint.ads output.ads system.ads \ ! s-exctab.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-strops.ads s-wchcon.ads table.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! namet.o : ada.ads a-except.ads alloc.ads debug.ads gnat.ads g-os_lib.ads \ ! hostparm.ads namet.ads namet.adb opt.ads output.ads system.ads \ ! s-assert.ads s-exctab.ads s-secsta.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads table.adb tree_io.ads types.ads unchconv.ads \ ! unchdeal.ads widechar.ads ! ! nlists.o : ada.ads a-except.ads alloc.ads atree.ads debug.ads einfo.ads \ ! gnat.ads g-os_lib.ads hostparm.ads nlists.ads nlists.adb opt.ads \ ! output.ads sinfo.ads snames.ads system.ads s-assert.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads table.adb tree_io.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! nmake.o : alloc.ads atree.ads einfo.ads namet.ads nlists.ads nmake.ads \ ! nmake.adb sinfo.ads snames.ads stand.ads system.ads s-exctab.ads \ ! s-stalib.ads table.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! opt.o : ada.ads a-except.ads gnat.ads g-os_lib.ads gnatvsn.ads \ ! hostparm.ads opt.ads opt.adb system.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads tree_io.ads types.ads unchconv.ads unchdeal.ads ! ! osint.o : ada.ads a-except.ads a-uncdea.ads alloc.ads debug.ads fmap.ads \ ! gnat.ads g-htable.ads g-htable.adb g-os_lib.ads hostparm.ads namet.ads \ ! opt.ads osint.ads osint.adb output.ads sdefault.ads system.ads \ ! s-assert.ads s-exctab.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-wchcon.ads table.ads table.adb tree_io.ads \ ! types.ads unchconv.ads unchdeal.ads ! ! output.o : gnat.ads g-os_lib.ads output.ads output.adb system.ads \ ! s-exctab.ads s-stalib.ads types.ads unchconv.ads unchdeal.ads ! ! par.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads csets.ads \ ! debug.ads einfo.ads elists.ads errout.ads fname.ads fname-uf.ads \ ! gnat.ads g-os_lib.ads g-speche.ads hostparm.ads lib.ads lib-load.ads \ ! namet.ads nlists.ads nmake.ads opt.ads osint.ads output.ads par.ads \ ! par.adb par-ch10.adb par-ch11.adb par-ch12.adb par-ch13.adb par-ch2.adb \ ! par-ch3.adb par-ch4.adb par-ch5.adb par-ch6.adb par-ch7.adb par-ch8.adb \ ! par-ch9.adb par-endh.adb par-labl.adb par-load.adb par-prag.adb \ ! par-sync.adb par-tchk.adb par-util.adb scans.ads scn.ads sinfo.ads \ ! sinfo-cn.ads sinput.ads sinput-l.ads snames.ads stringt.ads style.ads \ ! stylesw.ads system.ads s-assert.ads s-exctab.ads s-imgenu.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads table.adb tree_io.ads types.ads uintp.ads \ ! uname.ads unchconv.ads unchdeal.ads urealp.ads validsw.ads ! ! prj.o : ada.ads a-charac.ads a-chahan.ads a-except.ads alloc.ads \ ! casing.ads debug.ads errout.ads gnat.ads g-htable.ads g-os_lib.ads \ ! hostparm.ads namet.ads opt.ads output.ads prj.ads prj.adb prj-attr.ads \ ! prj-com.ads prj-env.ads scans.ads scn.ads sinfo.ads sinfo-cn.ads \ ! snames.ads stringt.ads system.ads s-assert.ads s-exctab.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-sopco3.ads s-wchcon.ads table.ads table.adb tree_io.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! prj-attr.o : ada.ads a-charac.ads a-chahan.ads a-except.ads alloc.ads \ ! casing.ads debug.ads gnat.ads g-os_lib.ads hostparm.ads namet.ads \ ! opt.ads output.ads prj.ads prj-attr.ads prj-attr.adb scans.ads \ ! system.ads s-assert.ads s-exctab.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-sopco3.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads unchconv.ads unchdeal.ads ! ! prj-com.o : ada.ads a-except.ads a-uncdea.ads alloc.ads casing.ads \ ! debug.ads gnat.ads g-htable.ads g-htable.adb g-os_lib.ads hostparm.ads \ ! namet.ads opt.ads output.ads prj.ads prj-com.ads prj-com.adb scans.ads \ ! stringt.ads system.ads s-assert.ads s-exctab.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads unchconv.ads unchdeal.ads ! ! prj-dect.o : alloc.ads casing.ads errout.ads gnat.ads g-htable.ads \ ! g-os_lib.ads prj.ads prj-attr.ads prj-com.ads prj-dect.ads prj-dect.adb \ ! prj-strt.ads prj-tree.ads scans.ads sinfo.ads system.ads s-exctab.ads \ ! s-stalib.ads table.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! prj-env.o : ada.ads a-except.ads alloc.ads casing.ads debug.ads gnat.ads \ ! g-htable.ads g-os_lib.ads hostparm.ads namet.ads opt.ads osint.ads \ ! output.ads prj.ads prj-com.ads prj-env.ads prj-env.adb prj-util.ads \ ! scans.ads snames.ads stringt.ads system.ads s-assert.ads s-exctab.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-strops.ads s-sopco3.ads s-wchcon.ads table.ads table.adb tree_io.ads \ ! types.ads unchconv.ads unchdeal.ads ! ! prj-ext.o : ada.ads a-except.ads a-uncdea.ads alloc.ads casing.ads \ ! gnat.ads g-htable.ads g-htable.adb g-os_lib.ads namet.ads prj.ads \ ! prj-com.ads prj-ext.ads prj-ext.adb scans.ads stringt.ads system.ads \ ! s-exctab.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads table.ads types.ads unchconv.ads unchdeal.ads ! ! prj-nmsc.o : ada.ads a-charac.ads a-chahan.ads a-chlat1.ads a-except.ads \ ! a-finali.ads a-filico.ads a-stream.ads a-string.ads a-strfix.ads \ ! a-strmap.ads a-stmaco.ads a-tags.ads alloc.ads casing.ads errout.ads \ ! gnat.ads g-casuti.ads g-dirope.ads g-htable.ads g-os_lib.ads namet.ads \ ! osint.ads output.ads prj.ads prj-com.ads prj-nmsc.ads prj-nmsc.adb \ ! prj-util.ads scans.ads snames.ads stringt.ads system.ads s-assert.ads \ ! s-exctab.ads s-finimp.ads s-finroo.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads \ ! s-sopco3.ads s-sopco5.ads s-unstyp.ads table.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads ! ! prj-pars.o : ada.ads a-except.ads alloc.ads casing.ads errout.ads gnat.ads \ ! g-htable.ads g-os_lib.ads output.ads prj.ads prj-attr.ads prj-com.ads \ ! prj-pars.ads prj-pars.adb prj-part.ads prj-proc.ads prj-tree.ads \ ! scans.ads system.ads s-exctab.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads table.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads ! ! prj-part.o : ada.ads a-charac.ads a-chahan.ads a-except.ads a-finali.ads \ ! a-filico.ads a-stream.ads a-tags.ads alloc.ads casing.ads debug.ads \ ! errout.ads gnat.ads g-dirope.ads g-htable.ads g-os_lib.ads hostparm.ads \ ! namet.ads opt.ads osint.ads output.ads prj.ads prj-attr.ads prj-com.ads \ ! prj-dect.ads prj-part.ads prj-part.adb prj-tree.ads scans.ads scn.ads \ ! sinfo.ads sinput.ads sinput-p.ads stringt.ads system.ads s-assert.ads \ ! s-exctab.ads s-finimp.ads s-finroo.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads \ ! s-sopco3.ads s-unstyp.ads s-wchcon.ads table.ads table.adb tree_io.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! prj-proc.o : ada.ads a-except.ads a-uncdea.ads alloc.ads casing.ads \ ! errout.ads gnat.ads g-casuti.ads g-htable.ads g-htable.adb g-os_lib.ads \ ! hostparm.ads namet.ads opt.ads output.ads prj.ads prj-attr.ads \ ! prj-com.ads prj-ext.ads prj-nmsc.ads prj-proc.ads prj-proc.adb \ ! prj-tree.ads scans.ads stringt.ads system.ads s-assert.ads s-exctab.ads \ ! s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-strops.ads s-sopco3.ads s-sopco5.ads s-wchcon.ads \ ! table.ads types.ads uintp.ads unchconv.ads unchdeal.ads ! ! prj-strt.o : ada.ads a-except.ads alloc.ads casing.ads debug.ads \ ! errout.ads gnat.ads g-htable.ads g-os_lib.ads hostparm.ads opt.ads \ ! output.ads prj.ads prj-attr.ads prj-com.ads prj-strt.ads prj-strt.adb \ ! prj-tree.ads scans.ads sinfo.ads stringt.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads table.adb tree_io.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! prj-tree.o : ada.ads a-except.ads a-uncdea.ads casing.ads debug.ads \ ! gnat.ads g-htable.ads g-htable.adb g-os_lib.ads hostparm.ads opt.ads \ ! output.ads prj.ads prj-attr.ads prj-com.ads prj-tree.ads prj-tree.adb \ ! scans.ads stringt.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads table.adb tree_io.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! prj-util.o : ada.ads a-uncdea.ads alloc.ads casing.ads gnat.ads \ ! g-os_lib.ads namet.ads osint.ads output.ads prj.ads prj-util.ads \ ! prj-util.adb scans.ads stringt.ads system.ads s-exctab.ads s-secsta.ads \ ! s-stalib.ads s-stoele.ads table.ads types.ads unchconv.ads unchdeal.ads ! ! repinfo.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads debug.ads \ ! einfo.ads gnat.ads g-os_lib.ads hostparm.ads lib.ads namet.ads opt.ads \ ! output.ads repinfo.ads repinfo.adb sinfo.ads sinput.ads snames.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads uintp.ads uname.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! restrict.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads einfo.ads \ ! errout.ads exp_util.ads fname.ads fname-uf.ads hostparm.ads lib.ads \ ! namet.ads nlists.ads nmake.ads opt.ads restrict.ads restrict.adb \ ! rident.ads rtsfind.ads sinfo.ads snames.ads stand.ads system.ads \ ! s-exctab.ads s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-wchcon.ads table.ads targparm.ads types.ads \ ! uintp.ads uname.ads unchconv.ads unchdeal.ads urealp.ads ! ! rident.o : rident.ads system.ads ! ! rtsfind.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads csets.ads \ ! debug.ads einfo.ads elists.ads fname.ads fname-uf.ads hostparm.ads \ ! lib.ads lib-load.ads namet.ads nlists.ads nmake.ads opt.ads output.ads \ ! restrict.ads rident.ads rtsfind.ads rtsfind.adb sem.ads sem_ch7.ads \ ! sem_util.ads sinfo.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-wchcon.ads table.ads tbuild.ads types.ads \ ! uintp.ads uname.ads unchconv.ads unchdeal.ads urealp.ads ! ! s-arit64.o : gnat.ads g-except.ads interfac.ads system.ads s-arit64.ads \ ! s-arit64.adb unchconv.ads ! ! s-assert.o : ada.ads a-except.ads system.ads s-assert.ads s-assert.adb \ ! s-exctab.ads s-stalib.ads unchconv.ads ! ! s-bitops.o : gnat.ads g-except.ads system.ads s-bitops.ads s-bitops.adb \ ! s-unstyp.ads unchconv.ads ! ! scans.o : scans.ads scans.adb system.ads s-exctab.ads s-stalib.ads \ ! types.ads unchconv.ads unchdeal.ads ! ! scn.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads csets.ads \ ! einfo.ads errout.ads hostparm.ads interfac.ads namet.ads opt.ads \ ! scans.ads scn.ads scn.adb scn-nlit.adb scn-slit.adb sinfo.ads \ ! sinput.ads snames.ads stringt.ads style.ads system.ads s-crc32.ads \ ! s-exctab.ads s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-wchcon.ads table.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads widechar.ads ! ! s-crc32.o : interfac.ads system.ads s-crc32.ads s-crc32.adb ! ! sem_aggr.o : alloc.ads atree.ads checks.ads einfo.ads elists.ads \ ! errout.ads exp_util.ads freeze.ads gnat.ads g-speche.ads hostparm.ads \ ! itypes.ads namet.ads nlists.ads nmake.ads opt.ads rtsfind.ads sem.ads \ ! sem_aggr.ads sem_aggr.adb sem_cat.ads sem_ch13.ads sem_ch8.ads \ ! sem_eval.ads sem_res.ads sem_type.ads sem_util.ads sinfo.ads snames.ads \ ! stand.ads stringt.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads tbuild.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! sem.o : ada.ads a-except.ads alloc.ads atree.ads debug.ads debug_a.ads \ ! einfo.ads errout.ads expander.ads fname.ads gnat.ads g-os_lib.ads \ ! hlo.ads hostparm.ads inline.ads lib.ads lib-load.ads namet.ads \ ! nlists.ads opt.ads output.ads sem.ads sem.adb sem_attr.ads sem_ch10.ads \ ! sem_ch11.ads sem_ch12.ads sem_ch13.ads sem_ch2.ads sem_ch3.ads \ ! sem_ch4.ads sem_ch5.ads sem_ch6.ads sem_ch7.ads sem_ch8.ads sem_ch9.ads \ ! sem_prag.ads sem_util.ads sinfo.ads snames.ads stand.ads system.ads \ ! s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads table.adb \ ! tree_io.ads types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_attr.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads alloc.ads \ ! atree.ads casing.ads checks.ads einfo.ads errout.ads eval_fat.ads \ ! exp_tss.ads exp_util.ads expander.ads freeze.ads get_targ.ads \ ! hostparm.ads lib.ads lib-xref.ads namet.ads nlists.ads nmake.ads \ ! opt.ads restrict.ads rident.ads rtsfind.ads sem.ads sem_attr.ads \ ! sem_attr.adb sem_cat.ads sem_ch13.ads sem_ch6.ads sem_ch8.ads \ ! sem_dist.ads sem_eval.ads sem_res.ads sem_type.ads sem_util.ads \ ! sinfo.ads sinput.ads snames.ads stand.ads stringt.ads system.ads \ ! s-assert.ads s-exctab.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads table.ads targparm.ads tbuild.ads ttypef.ads \ ! ttypes.ads types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads \ ! widechar.ads ! ! sem_case.o : alloc.ads atree.ads einfo.ads errout.ads gnat.ads \ ! g-hesora.ads hostparm.ads namet.ads nlists.ads opt.ads sem.ads \ ! sem_case.ads sem_case.adb sem_eval.ads sem_res.ads sem_type.ads \ ! sem_util.ads sinfo.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! sem_cat.o : alloc.ads atree.ads debug.ads einfo.ads elists.ads errout.ads \ ! exp_tss.ads fname.ads hostparm.ads lib.ads namet.ads nlists.ads opt.ads \ ! sem.ads sem_cat.ads sem_cat.adb sem_util.ads sinfo.ads snames.ads \ ! stand.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! sem_ch10.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads debug.ads \ ! einfo.ads errout.ads exp_util.ads fname.ads fname-uf.ads freeze.ads \ ! get_targ.ads hostparm.ads impunit.ads inline.ads lib.ads lib-load.ads \ ! lib-xref.ads namet.ads nlists.ads nmake.ads opt.ads output.ads \ ! restrict.ads rident.ads rtsfind.ads sem.ads sem_ch10.ads sem_ch10.adb \ ! sem_ch6.ads sem_ch7.ads sem_ch8.ads sem_dist.ads sem_prag.ads \ ! sem_util.ads sem_warn.ads sinfo.ads sinfo-cn.ads sinput.ads snames.ads \ ! stand.ads style.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads tbuild.ads ttypes.ads types.ads uintp.ads \ ! uname.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_ch11.o : alloc.ads atree.ads einfo.ads errout.ads hostparm.ads lib.ads \ ! lib-xref.ads namet.ads nlists.ads nmake.ads opt.ads restrict.ads \ ! rident.ads rtsfind.ads sem.ads sem_ch11.ads sem_ch11.adb sem_ch5.ads \ ! sem_ch8.ads sem_res.ads sem_util.ads sinfo.ads snames.ads stand.ads \ ! system.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_ch12.o : ada.ads a-except.ads a-uncdea.ads alloc.ads atree.ads \ ! casing.ads debug.ads einfo.ads elists.ads errout.ads expander.ads \ ! fname.ads fname-uf.ads freeze.ads gnat.ads g-htable.ads g-htable.adb \ ! g-os_lib.ads hostparm.ads inline.ads lib.ads lib-load.ads lib-xref.ads \ ! namet.ads nlists.ads nmake.ads opt.ads output.ads restrict.ads \ ! rident.ads rtsfind.ads sem.ads sem_cat.ads sem_ch10.ads sem_ch12.ads \ ! sem_ch12.adb sem_ch13.ads sem_ch3.ads sem_ch6.ads sem_ch7.ads \ ! sem_ch8.ads sem_elab.ads sem_elim.ads sem_eval.ads sem_res.ads \ ! sem_type.ads sem_util.ads sinfo.ads sinfo-cn.ads sinput.ads \ ! sinput-l.ads snames.ads stand.ads stringt.ads system.ads s-assert.ads \ ! s-exctab.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads table.adb tbuild.ads tree_io.ads types.ads \ ! uintp.ads uname.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_ch13.o : ada.ads a-except.ads alloc.ads atree.ads debug.ads einfo.ads \ ! errout.ads exp_tss.ads exp_util.ads get_targ.ads gnat.ads g-hesora.ads \ ! g-os_lib.ads hostparm.ads lib.ads namet.ads nlists.ads nmake.ads \ ! opt.ads output.ads rtsfind.ads sem.ads sem_ch13.ads sem_ch13.adb \ ! sem_ch8.ads sem_eval.ads sem_res.ads sem_type.ads sem_util.ads \ ! sinfo.ads snames.ads stand.ads system.ads s-assert.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads table.adb tbuild.ads tree_io.ads \ ! ttypes.ads types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_ch2.o : alloc.ads atree.ads einfo.ads hostparm.ads namet.ads opt.ads \ ! restrict.ads rident.ads sem_ch2.ads sem_ch2.adb sem_ch8.ads sinfo.ads \ ! snames.ads stand.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_ch3.o : alloc.ads atree.ads checks.ads einfo.ads elists.ads errout.ads \ ! eval_fat.ads exp_ch3.ads exp_dist.ads exp_util.ads freeze.ads \ ! get_targ.ads gnat.ads g-hesora.ads hostparm.ads itypes.ads layout.ads \ ! lib.ads lib-xref.ads namet.ads nlists.ads nmake.ads opt.ads \ ! restrict.ads rident.ads rtsfind.ads sem.ads sem_case.ads sem_case.adb \ ! sem_cat.ads sem_ch13.ads sem_ch3.ads sem_ch3.adb sem_ch6.ads \ ! sem_ch7.ads sem_ch8.ads sem_disp.ads sem_dist.ads sem_elim.ads \ ! sem_eval.ads sem_mech.ads sem_res.ads sem_smem.ads sem_type.ads \ ! sem_util.ads sinfo.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads tbuild.ads ttypes.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_ch4.o : alloc.ads atree.ads debug.ads einfo.ads errout.ads \ ! exp_util.ads gnat.ads g-speche.ads hostparm.ads itypes.ads lib.ads \ ! lib-xref.ads namet.ads nlists.ads nmake.ads opt.ads output.ads \ ! restrict.ads rident.ads rtsfind.ads sem.ads sem_cat.ads sem_ch3.ads \ ! sem_ch4.ads sem_ch4.adb sem_ch8.ads sem_dist.ads sem_eval.ads \ ! sem_res.ads sem_type.ads sem_util.ads sinfo.ads snames.ads stand.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads tbuild.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! sem_ch5.o : alloc.ads atree.ads checks.ads einfo.ads errout.ads \ ! exp_util.ads expander.ads freeze.ads gnat.ads g-hesora.ads hostparm.ads \ ! lib.ads lib-xref.ads namet.ads nlists.ads opt.ads rtsfind.ads sem.ads \ ! sem_case.ads sem_case.adb sem_ch3.ads sem_ch5.ads sem_ch5.adb \ ! sem_ch8.ads sem_disp.ads sem_eval.ads sem_res.ads sem_type.ads \ ! sem_util.ads sem_warn.ads sinfo.ads snames.ads stand.ads system.ads \ ! s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! tbuild.ads types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_ch6.o : alloc.ads atree.ads casing.ads checks.ads debug.ads einfo.ads \ ! elists.ads errout.ads exp_ch7.ads expander.ads fname.ads freeze.ads \ ! hostparm.ads inline.ads lib.ads lib-xref.ads namet.ads nlists.ads \ ! nmake.ads opt.ads output.ads rtsfind.ads sem.ads sem_cat.ads \ ! sem_ch12.ads sem_ch3.ads sem_ch4.ads sem_ch5.ads sem_ch6.ads \ ! sem_ch6.adb sem_ch8.ads sem_disp.ads sem_dist.ads sem_elim.ads \ ! sem_eval.ads sem_mech.ads sem_prag.ads sem_res.ads sem_type.ads \ ! sem_util.ads sem_warn.ads sinfo.ads sinfo-cn.ads sinput.ads snames.ads \ ! stand.ads stringt.ads style.ads stylesw.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads tbuild.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads validsw.ads ! ! sem_ch7.o : alloc.ads atree.ads casing.ads debug.ads einfo.ads elists.ads \ ! errout.ads exp_dbug.ads exp_disp.ads get_targ.ads hostparm.ads \ ! inline.ads lib.ads lib-xref.ads namet.ads nlists.ads nmake.ads opt.ads \ ! output.ads sem.ads sem_cat.ads sem_ch12.ads sem_ch3.ads sem_ch6.ads \ ! sem_ch7.ads sem_ch7.adb sem_ch8.ads sem_util.ads sem_warn.ads sinfo.ads \ ! sinput.ads snames.ads stand.ads style.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! sem_ch8.o : ada.ads a-except.ads alloc.ads atree.ads debug.ads einfo.ads \ ! elists.ads errout.ads exp_util.ads fname.ads freeze.ads gnat.ads \ ! g-os_lib.ads g-speche.ads hostparm.ads inline.ads lib.ads lib-load.ads \ ! lib-xref.ads namet.ads nlists.ads nmake.ads opt.ads output.ads \ ! restrict.ads rident.ads rtsfind.ads sem.ads sem_ch12.ads sem_ch3.ads \ ! sem_ch4.ads sem_ch6.ads sem_ch8.ads sem_ch8.adb sem_res.ads \ ! sem_type.ads sem_util.ads sinfo.ads sinfo-cn.ads snames.ads stand.ads \ ! style.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads table.adb tbuild.ads tree_io.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_ch9.o : alloc.ads atree.ads checks.ads einfo.ads elists.ads errout.ads \ ! exp_ch9.ads hostparm.ads itypes.ads lib.ads lib-xref.ads namet.ads \ ! nlists.ads nmake.ads opt.ads restrict.ads rident.ads rtsfind.ads \ ! sem.ads sem_ch3.ads sem_ch5.ads sem_ch6.ads sem_ch8.ads sem_ch9.ads \ ! sem_ch9.adb sem_eval.ads sem_res.ads sem_type.ads sem_util.ads \ ! sem_warn.ads sinfo.ads snames.ads stand.ads style.ads system.ads \ ! s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! tbuild.ads types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_disp.o : alloc.ads atree.ads debug.ads einfo.ads elists.ads errout.ads \ ! exp_disp.ads hostparm.ads nlists.ads output.ads sem_ch6.ads \ ! sem_disp.ads sem_disp.adb sem_eval.ads sem_util.ads sinfo.ads \ ! snames.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads table.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_dist.o : alloc.ads atree.ads casing.ads einfo.ads errout.ads \ ! exp_dist.ads exp_tss.ads hostparm.ads namet.ads nlists.ads nmake.ads \ ! opt.ads rtsfind.ads sem.ads sem_dist.ads sem_dist.adb sem_res.ads \ ! sem_util.ads sinfo.ads snames.ads stand.ads stringt.ads system.ads \ ! s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! tbuild.ads types.ads uintp.ads uname.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! sem_elab.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! checks.ads debug.ads einfo.ads elists.ads errout.ads exp_util.ads \ ! expander.ads fname.ads gnat.ads g-htable.ads g-os_lib.ads hostparm.ads \ ! lib.ads lib-load.ads namet.ads nlists.ads nmake.ads opt.ads output.ads \ ! restrict.ads rident.ads rtsfind.ads sem.ads sem_cat.ads sem_ch7.ads \ ! sem_ch8.ads sem_elab.ads sem_elab.adb sem_res.ads sem_util.ads \ ! sinfo.ads sinput.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-wchcon.ads table.ads table.adb tbuild.ads \ ! tree_io.ads types.ads uintp.ads uname.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! sem_elim.o : ada.ads a-uncdea.ads alloc.ads atree.ads einfo.ads errout.ads \ ! gnat.ads g-htable.ads g-htable.adb namet.ads nlists.ads sem_elim.ads \ ! sem_elim.adb sinfo.ads snames.ads stand.ads stringt.ads system.ads \ ! s-exctab.ads s-stalib.ads table.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! sem_eval.o : ada.ads a-except.ads alloc.ads atree.ads checks.ads debug.ads \ ! einfo.ads elists.ads errout.ads eval_fat.ads hostparm.ads namet.ads \ ! nlists.ads nmake.ads opt.ads sem.ads sem_cat.ads sem_ch8.ads \ ! sem_eval.ads sem_eval.adb sem_res.ads sem_type.ads sem_util.ads \ ! sem_warn.ads sinfo.ads snames.ads stand.ads stringt.ads system.ads \ ! s-assert.ads s-exctab.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads table.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! sem_intr.o : alloc.ads atree.ads einfo.ads errout.ads fname.ads lib.ads \ ! namet.ads sem_eval.ads sem_intr.ads sem_intr.adb sem_util.ads sinfo.ads \ ! snames.ads stand.ads stringt.ads system.ads s-exctab.ads s-stalib.ads \ ! table.ads targparm.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! sem_maps.o : ada.ads a-except.ads alloc.ads atree.ads debug.ads einfo.ads \ ! gnat.ads g-os_lib.ads hostparm.ads namet.ads opt.ads output.ads \ ! sem_maps.ads sem_maps.adb sinfo.ads snames.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads table.adb tree_io.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_mech.o : alloc.ads atree.ads einfo.ads errout.ads hostparm.ads \ ! namet.ads nlists.ads opt.ads sem.ads sem_mech.ads sem_mech.adb \ ! sem_util.ads sinfo.ads snames.ads stand.ads system.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads targparm.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! sem_prag.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads csets.ads \ ! debug.ads einfo.ads elists.ads errout.ads exp_dist.ads expander.ads \ ! fname.ads get_targ.ads hostparm.ads lib.ads namet.ads nlists.ads \ ! nmake.ads opt.ads output.ads restrict.ads rident.ads rtsfind.ads \ ! sem.ads sem_ch13.ads sem_ch8.ads sem_disp.ads sem_elim.ads sem_eval.ads \ ! sem_intr.ads sem_mech.ads sem_prag.ads sem_prag.adb sem_res.ads \ ! sem_type.ads sem_util.ads sem_vfpt.ads sinfo.ads sinfo-cn.ads \ ! sinput.ads snames.ads stand.ads stringt.ads stylesw.ads system.ads \ ! s-exctab.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads targparm.ads tbuild.ads ttypes.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads validsw.ads ! ! sem_res.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! checks.ads debug.ads debug_a.ads einfo.ads elists.ads errout.ads \ ! exp_ch7.ads exp_util.ads expander.ads freeze.ads gnat.ads g-htable.ads \ ! g-os_lib.ads hostparm.ads itypes.ads lib.ads lib-xref.ads namet.ads \ ! nlists.ads nmake.ads opt.ads output.ads restrict.ads rident.ads \ ! rtsfind.ads sem.ads sem_aggr.ads sem_attr.ads sem_cat.ads sem_ch4.ads \ ! sem_ch6.ads sem_ch8.ads sem_disp.ads sem_dist.ads sem_elab.ads \ ! sem_eval.ads sem_intr.ads sem_res.ads sem_res.adb sem_type.ads \ ! sem_util.ads sem_warn.ads sinfo.ads sinput.ads snames.ads stand.ads \ ! stringt.ads system.ads s-assert.ads s-exctab.ads s-imgenu.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads targparm.ads tbuild.ads tree_io.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_smem.o : alloc.ads atree.ads einfo.ads errout.ads namet.ads \ ! sem_smem.ads sem_smem.adb sinfo.ads snames.ads system.ads s-exctab.ads \ ! s-stalib.ads table.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! sem_type.o : ada.ads a-except.ads alloc.ads atree.ads debug.ads einfo.ads \ ! errout.ads gnat.ads g-os_lib.ads hostparm.ads lib.ads namet.ads opt.ads \ ! output.ads sem.ads sem_ch6.ads sem_ch8.ads sem_type.ads sem_type.adb \ ! sem_util.ads sinfo.ads snames.ads stand.ads system.ads s-assert.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads table.adb tree_io.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_util.o : ada.ads a-except.ads alloc.ads atree.ads atree.adb casing.ads \ ! debug.ads einfo.ads elists.ads errout.ads exp_util.ads freeze.ads \ ! get_targ.ads gnat.ads g-htable.ads g-os_lib.ads hostparm.ads lib.ads \ ! lib-xref.ads namet.ads nlists.ads nmake.ads opt.ads output.ads \ ! restrict.ads rident.ads rtsfind.ads scans.ads scn.ads sem.ads \ ! sem_ch8.ads sem_eval.ads sem_res.ads sem_type.ads sem_util.ads \ ! sem_util.adb sinfo.ads sinput.ads snames.ads stand.ads stringt.ads \ ! style.ads system.ads s-assert.ads s-exctab.ads s-imgenu.ads \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! s-wchcon.ads table.ads targparm.ads tbuild.ads tree_io.ads ttypes.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_vfpt.o : alloc.ads cstand.ads einfo.ads hostparm.ads namet.ads opt.ads \ ! sem_vfpt.ads sem_vfpt.adb stand.ads system.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads targparm.ads ttypef.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sem_warn.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads debug.ads \ ! einfo.ads errout.ads fname.ads gnat.ads g-os_lib.ads hostparm.ads \ ! lib.ads namet.ads nlists.ads opt.ads output.ads sem.ads sem_util.ads \ ! sem_warn.ads sem_warn.adb sinfo.ads sinput.ads snames.ads stand.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! s-except.o : ada.ads a-except.ads system.ads s-except.ads s-stalib.ads \ ! unchconv.ads ! ! s-exctab.o : ada.ads a-uncdea.ads gnat.ads g-htable.ads g-htable.adb \ ! system.ads s-exctab.ads s-exctab.adb s-stalib.ads unchconv.ads ! ! s-exngen.o : system.ads s-exngen.ads s-exngen.adb ! ! s-exnllf.o : ada.ads a-except.ads system.ads s-exngen.ads s-exngen.adb \ ! s-exnllf.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! unchconv.ads ! ! s-fatllf.o : ada.ads a-unccon.ads system.ads s-assert.ads s-exctab.ads \ ! s-fatgen.ads s-fatgen.adb s-fatllf.ads s-stalib.ads s-unstyp.ads \ ! unchconv.ads ! ! s-ficobl.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-stream.ads \ ! a-tags.ads a-tags.adb gnat.ads g-htable.ads interfac.ads i-cstrea.ads \ ! system.ads s-exctab.ads s-ficobl.ads s-finimp.ads s-finroo.ads \ ! s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-stratt.ads s-unstyp.ads unchconv.ads ! ! s-fileio.o : ada.ads a-except.ads a-finali.ads a-filico.ads a-ioexce.ads \ ! a-stream.ads a-tags.ads a-tags.adb gnat.ads g-htable.ads interfac.ads \ ! i-cstrea.ads system.ads s-exctab.ads s-ficobl.ads s-fileio.ads \ ! s-fileio.adb s-finimp.ads s-finroo.ads s-parame.ads s-secsta.ads \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads \ ! s-unstyp.ads unchconv.ads unchdeal.ads ! ! s-finimp.o : ada.ads a-except.ads a-stream.ads a-tags.ads a-tags.adb \ ! a-unccon.ads gnat.ads g-htable.ads system.ads s-exctab.ads s-finimp.ads \ ! s-finimp.adb s-finroo.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-stoele.adb s-stratt.ads s-sopco3.ads \ ! s-unstyp.ads unchconv.ads ! ! s-finroo.o : ada.ads a-except.ads a-stream.ads a-tags.ads a-tags.adb \ ! gnat.ads g-htable.ads system.ads s-exctab.ads s-finroo.ads s-finroo.adb \ ! s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! unchconv.ads ! ! sfn_scan.o : ada.ads a-except.ads sfn_scan.ads sfn_scan.adb system.ads \ ! s-exctab.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads unchconv.ads ! ! s-imgbiu.o : system.ads s-imgbiu.ads s-imgbiu.adb s-unstyp.ads ! ! s-imgenu.o : system.ads s-imgenu.ads s-imgenu.adb s-secsta.ads \ ! s-stoele.ads unchconv.ads ! ! s-imgint.o : system.ads s-imgint.ads s-imgint.adb s-secsta.ads \ ! s-stoele.ads ! ! s-imgllb.o : system.ads s-imgllb.ads s-imgllb.adb s-unstyp.ads ! ! s-imglli.o : system.ads s-imglli.ads s-imglli.adb s-secsta.ads \ ! s-stoele.ads ! ! s-imgllu.o : system.ads s-imgllu.ads s-imgllu.adb s-secsta.ads \ ! s-stoele.ads s-unstyp.ads ! ! s-imgllw.o : system.ads s-imgllw.ads s-imgllw.adb s-unstyp.ads ! ! s-imgrea.o : ada.ads a-unccon.ads system.ads s-assert.ads s-exctab.ads \ ! s-fatgen.ads s-fatgen.adb s-fatllf.ads s-imgllu.ads s-imgrea.ads \ ! s-imgrea.adb s-imguns.ads s-powtab.ads s-secsta.ads s-stalib.ads \ ! s-stoele.ads s-unstyp.ads unchconv.ads ! ! s-imguns.o : system.ads s-imguns.ads s-imguns.adb s-secsta.ads \ ! s-stoele.ads s-unstyp.ads ! ! s-imgwiu.o : system.ads s-imgwiu.ads s-imgwiu.adb s-unstyp.ads ! ! sinfo.o : alloc.ads atree.ads einfo.ads sinfo.ads sinfo.adb snames.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads table.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sinfo-cn.o : alloc.ads atree.ads einfo.ads sinfo.ads sinfo-cn.ads \ ! sinfo-cn.adb snames.ads system.ads s-exctab.ads s-stalib.ads table.ads \ ! types.ads uintp.ads unchconv.ads unchdeal.ads urealp.ads ! ! sinput.o : ada.ads a-except.ads alloc.ads casing.ads debug.ads gnat.ads \ ! g-os_lib.ads hostparm.ads namet.ads opt.ads output.ads sinput.ads \ ! sinput.adb system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads table.adb tree_io.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! sinput-l.o : alloc.ads atree.ads casing.ads debug.ads einfo.ads gnat.ads \ ! g-os_lib.ads hostparm.ads namet.ads opt.ads osint.ads output.ads \ ! scans.ads scn.ads sinfo.ads sinput.ads sinput-l.ads sinput-l.adb \ ! snames.ads system.ads s-assert.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads table.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! sinput-p.o : ada.ads a-unccon.ads alloc.ads casing.ads gnat.ads \ ! g-os_lib.ads hostparm.ads namet.ads opt.ads scans.ads sinput.ads \ ! sinput-p.ads sinput-p.adb system.ads s-exctab.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads table.ads types.ads unchconv.ads unchdeal.ads ! ! s-io.o : system.ads s-io.ads s-io.adb ! ! s-mastop.o : ada.ads a-except.ads system.ads s-except.ads s-mastop.ads \ ! s-mastop.adb s-stalib.ads s-stoele.ads unchconv.ads ! ! s-memory.o : ada.ads a-except.ads system.ads s-memory.ads s-memory.adb \ ! s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads unchconv.ads ! ! snames.o : alloc.ads namet.ads snames.ads snames.adb system.ads \ ! s-assert.ads s-exctab.ads s-stalib.ads table.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! s-parame.o : system.ads s-parame.ads s-parame.adb ! ! s-powtab.o : system.ads s-powtab.ads ! ! sprint.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads debug.ads \ ! einfo.ads hostparm.ads lib.ads namet.ads nlists.ads opt.ads output.ads \ ! rtsfind.ads sinfo.ads sinput.ads sinput-l.ads snames.ads sprint.ads \ ! sprint.adb stand.ads stringt.ads system.ads s-assert.ads s-exctab.ads \ ! s-imgenu.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads table.ads types.ads uintp.ads uname.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! s-secsta.o : ada.ads a-except.ads system.ads s-parame.ads s-secsta.ads \ ! s-secsta.adb s-soflin.ads s-stache.ads s-stalib.ads s-stoele.ads \ ! unchconv.ads unchdeal.ads ! ! s-soflin.o : ada.ads a-except.ads system.ads s-except.ads s-mastop.ads \ ! s-parame.ads s-secsta.ads s-soflin.ads s-soflin.adb s-stache.ads \ ! s-stalib.ads s-stoele.ads unchconv.ads ! ! s-sopco3.o : system.ads s-secsta.ads s-stoele.ads s-strops.ads \ ! s-sopco3.ads s-sopco3.adb ! ! s-sopco4.o : system.ads s-secsta.ads s-stoele.ads s-sopco3.ads \ ! s-sopco4.ads s-sopco4.adb ! ! s-sopco5.o : system.ads s-secsta.ads s-stoele.ads s-sopco4.ads \ ! s-sopco5.ads s-sopco5.adb ! ! s-stache.o : ada.ads a-except.ads system.ads s-parame.ads s-soflin.ads \ ! s-stache.ads s-stache.adb s-stalib.ads s-stoele.ads s-stoele.adb \ ! unchconv.ads ! ! s-stalib.o : ada.ads a-except.ads system.ads s-memory.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stalib.adb s-stoele.ads unchconv.ads ! ! s-stoele.o : system.ads s-stoele.ads s-stoele.adb unchconv.ads ! ! s-stopoo.o : ada.ads a-except.ads a-finali.ads a-stream.ads a-tags.ads \ ! a-tags.adb gnat.ads g-htable.ads system.ads s-exctab.ads s-finimp.ads \ ! s-finroo.ads s-secsta.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-stopoo.ads s-stratt.ads s-unstyp.ads unchconv.ads ! ! s-stratt.o : ada.ads a-except.ads a-ioexce.ads a-stream.ads a-tags.ads \ ! a-tags.adb gnat.ads g-htable.ads system.ads s-exctab.ads s-secsta.ads \ ! s-stalib.ads s-stoele.ads s-stratt.ads s-stratt.adb s-unstyp.ads \ ! unchconv.ads ! ! s-strops.o : system.ads s-secsta.ads s-stoele.ads s-strops.ads \ ! s-strops.adb ! ! stand.o : alloc.ads gnat.ads g-os_lib.ads namet.ads stand.ads stand.adb \ ! system.ads s-exctab.ads s-stalib.ads table.ads tree_io.ads types.ads \ ! unchconv.ads unchdeal.ads ! ! s-traceb.o : system.ads s-traceb.ads s-traceb.adb ! ! stringt.o : ada.ads a-except.ads alloc.ads debug.ads gnat.ads g-os_lib.ads \ ! hostparm.ads namet.ads opt.ads output.ads stringt.ads stringt.adb \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-wchcon.ads \ ! table.ads table.adb tree_io.ads types.ads unchconv.ads unchdeal.ads ! ! style.o : alloc.ads atree.ads casing.ads csets.ads einfo.ads errout.ads \ ! hostparm.ads namet.ads opt.ads scans.ads scn.ads sinfo.ads sinput.ads \ ! snames.ads stand.ads style.ads style.adb stylesw.ads system.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads table.ads types.ads uintp.ads \ ! unchconv.ads unchdeal.ads urealp.ads ! ! stylesw.o : hostparm.ads opt.ads stylesw.ads stylesw.adb system.ads \ ! s-exctab.ads s-stalib.ads s-wchcon.ads types.ads unchconv.ads \ ! unchdeal.ads ! ! s-unstyp.o : system.ads s-unstyp.ads ! ! s-valenu.o : system.ads s-valenu.ads s-valenu.adb s-valuti.ads \ ! unchconv.ads ! ! s-valint.o : system.ads s-unstyp.ads s-valint.ads s-valint.adb \ ! s-valuns.ads s-valuti.ads ! ! s-vallli.o : system.ads s-unstyp.ads s-vallli.ads s-vallli.adb \ ! s-valllu.ads s-valuti.ads ! ! s-valllu.o : system.ads s-unstyp.ads s-valllu.ads s-valllu.adb \ ! s-valuti.ads ! ! s-valrea.o : system.ads s-exngen.ads s-exnllf.ads s-powtab.ads \ ! s-valrea.ads s-valrea.adb s-valuti.ads ! ! s-valuns.o : system.ads s-unstyp.ads s-valuns.ads s-valuns.adb \ ! s-valuti.ads ! ! s-valuti.o : gnat.ads g-casuti.ads system.ads s-valuti.ads s-valuti.adb ! ! s-wchcnv.o : interfac.ads system.ads s-wchcnv.ads s-wchcnv.adb \ ! s-wchcon.ads s-wchjis.ads ! ! s-wchcon.o : system.ads s-wchcon.ads ! ! s-wchjis.o : system.ads s-wchjis.ads s-wchjis.adb ! ! switch.o : ada.ads a-except.ads debug.ads gnat.ads g-os_lib.ads \ ! hostparm.ads opt.ads osint.ads stylesw.ads switch.ads switch.adb \ ! system.ads s-exctab.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-wchcon.ads types.ads unchconv.ads unchdeal.ads \ ! validsw.ads ! ! system.o : system.ads ! ! table.o : debug.ads gnat.ads g-os_lib.ads hostparm.ads opt.ads output.ads \ ! system.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads table.adb \ ! tree_io.ads types.ads unchconv.ads unchdeal.ads ! ! targparm.o : ada.ads a-except.ads alloc.ads casing.ads fname.ads \ ! fname-uf.ads namet.ads output.ads sinput.ads sinput-l.ads system.ads \ ! s-assert.ads s-exctab.ads s-stalib.ads table.ads targparm.ads \ ! targparm.adb types.ads unchconv.ads unchdeal.ads ! ! tbuild.o : alloc.ads atree.ads einfo.ads lib.ads namet.ads nlists.ads \ ! nmake.ads restrict.ads rident.ads sinfo.ads snames.ads stand.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads s-stoele.ads \ ! table.ads tbuild.ads tbuild.adb types.ads uintp.ads unchconv.ads \ ! unchdeal.ads urealp.ads ! ! tree_gen.o : alloc.ads atree.ads casing.ads einfo.ads elists.ads fname.ads \ ! gnat.ads g-os_lib.ads hostparm.ads lib.ads namet.ads nlists.ads opt.ads \ ! osint.ads repinfo.ads sinfo.ads sinput.ads snames.ads stand.ads \ ! stringt.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! tree_gen.ads tree_gen.adb types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! tree_io.o : ada.ads a-except.ads debug.ads gnat.ads g-os_lib.ads \ ! output.ads system.ads s-exctab.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads tree_io.ads tree_io.adb types.ads \ ! unchconv.ads unchdeal.ads ! ! treepr.o : ada.ads a-except.ads alloc.ads atree.ads casing.ads csets.ads \ ! debug.ads einfo.ads elists.ads lib.ads namet.ads nlists.ads output.ads \ ! sem_mech.ads sinfo.ads sinput.ads snames.ads stand.ads stringt.ads \ ! system.ads s-exctab.ads s-imgenu.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads table.ads treepr.ads treepr.adb \ ! treeprs.ads types.ads uintp.ads uname.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! treeprs.o : alloc.ads sinfo.ads system.ads s-exctab.ads s-stalib.ads \ ! table.ads treeprs.ads types.ads uintp.ads unchconv.ads unchdeal.ads \ ! urealp.ads ! ! ttypef.o : system.ads ttypef.ads ! ! ttypes.o : get_targ.ads system.ads s-exctab.ads s-stalib.ads ttypes.ads \ ! types.ads unchconv.ads unchdeal.ads ! ! types.o : system.ads s-exctab.ads s-stalib.ads types.ads types.adb \ ! unchconv.ads unchdeal.ads ! ! uintp.o : ada.ads a-except.ads alloc.ads debug.ads gnat.ads g-os_lib.ads \ ! hostparm.ads opt.ads output.ads system.ads s-assert.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads table.adb tree_io.ads types.ads \ ! uintp.ads uintp.adb unchconv.ads unchdeal.ads ! ! uname.o : alloc.ads atree.ads casing.ads einfo.ads hostparm.ads lib.ads \ ! namet.ads nlists.ads output.ads sinfo.ads sinput.ads snames.ads \ ! system.ads s-assert.ads s-exctab.ads s-stalib.ads table.ads types.ads \ ! uintp.ads uname.ads uname.adb unchconv.ads unchdeal.ads urealp.ads ! ! urealp.o : ada.ads a-except.ads alloc.ads debug.ads gnat.ads g-os_lib.ads \ ! hostparm.ads opt.ads output.ads system.ads s-assert.ads s-exctab.ads \ ! s-stalib.ads s-wchcon.ads table.ads table.adb tree_io.ads types.ads \ ! uintp.ads unchconv.ads unchdeal.ads urealp.ads urealp.adb ! ! usage.o : alloc.ads gnat.ads g-os_lib.ads hostparm.ads namet.ads osint.ads \ ! output.ads system.ads s-exctab.ads s-stalib.ads s-wchcon.ads table.ads \ ! types.ads unchconv.ads unchdeal.ads usage.ads usage.adb ! ! validsw.o : hostparm.ads opt.ads system.ads s-exctab.ads s-stalib.ads \ ! s-wchcon.ads types.ads unchconv.ads unchdeal.ads validsw.ads \ ! validsw.adb ! ! widechar.o : ada.ads a-except.ads hostparm.ads interfac.ads opt.ads \ ! system.ads s-exctab.ads s-soflin.ads s-stache.ads s-stalib.ads \ ! s-stoele.ads s-wchcnv.ads s-wchcnv.adb s-wchcon.ads s-wchjis.ads \ ! types.ads unchconv.ads unchdeal.ads widechar.ads widechar.adb ! ! xref_lib.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads a-finali.ads \ ! a-filico.ads a-ioexce.ads a-stream.ads a-string.ads a-strfix.ads \ ! a-strmap.ads a-strunb.ads a-tags.ads a-textio.ads gnat.ads g-comlin.ads \ ! g-dirope.ads g-dyntab.ads g-dyntab.adb g-io_aux.ads g-os_lib.ads \ ! g-regexp.ads hostparm.ads interfac.ads i-cstrea.ads osint.ads \ ! output.ads system.ads s-exctab.ads s-ficobl.ads s-finimp.ads \ ! s-finroo.ads s-parame.ads s-secsta.ads s-soflin.ads s-stache.ads \ ! s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads s-sopco3.ads \ ! s-sopco4.ads s-sopco5.ads s-unstyp.ads s-valint.ads types.ads \ ! unchconv.ads unchdeal.ads xr_tabls.ads xref_lib.ads xref_lib.adb ! ! xr_tabls.o : ada.ads a-charac.ads a-chlat1.ads a-except.ads a-finali.ads \ ! a-filico.ads a-ioexce.ads a-stream.ads a-string.ads a-strfix.ads \ ! a-strmap.ads a-strunb.ads a-tags.ads a-textio.ads gnat.ads g-dirope.ads \ ! g-io_aux.ads g-os_lib.ads hostparm.ads interfac.ads i-cstrea.ads \ ! osint.ads system.ads s-exctab.ads s-ficobl.ads s-finimp.ads \ ! s-finroo.ads s-imgint.ads s-parame.ads s-secsta.ads s-soflin.ads \ ! s-stache.ads s-stalib.ads s-stoele.ads s-stratt.ads s-strops.ads \ ! s-sopco3.ads s-unstyp.ads types.ads unchconv.ads unchdeal.ads \ ! xr_tabls.ads xr_tabls.adb ! # end of regular dependencies ! #In GNU Make, ignore whether `stage*' exists. .PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap .PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4 --- 2086,2148 ---- s-memory.o : s-memory.adb s-memory.ads memtrack.o $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 \ ! $(ADA_INCLUDES) $< memtrack.o : memtrack.adb s-memory.ads $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 \ ! $(ADA_INCLUDES) $< # Need to keep the frame pointer in this file to pop the stack properly on # some targets. ! traceb.o : traceb.c ! $(CC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 $(ADA_INCLUDES) \ ! $< ! ! aux-io.o : aux-io.c argv.o : argv.c cal.o : cal.c deftarg.o : deftarg.c errno.o : errno.c exit.o : raise.h exit.c + expect.o : expect.c adafinal.o : raise.h adafinal.c gmem.o : gmem.c link.o : link.c + mkdir.o : mkdir.c sysdep.o : sysdep.c ! cio.o : cio.c ! $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \ ! $(ALL_CPPFLAGS) $(INCLUDES) $< ! init.o : init.c ada.h types.h raise.h ! $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \ ! $(ALL_CPPFLAGS) $(INCLUDES) $< ! raise.o : raise.c raise.h ! $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \ ! $(ALL_CPPFLAGS) $(INCLUDES) $< ! ! # Need to keep the frame pointer in this file to pop the stack properly on ! # some targets. ! tracebak.o : tracebak.c ! $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ ! -fno-omit-frame-pointer $< targtyps.o : targtyps.c $(CONFIG_H) ada.h types.h atree.h nlists.h elists.h \ uintp.h sinfo.h einfo.h namet.h snames.h stringt.h urealp.h fe.h \ $(ADA_TREE_H) gigi.h ! # Rule to compile prefix.o for the run-time. ! prefix.o : $(srcdir)/../prefix.c ! $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \ ! $(ALL_CPPFLAGS) $(INCLUDES) -I$(srcdir)/../.. -I../.. \ ! -DPREFIX=\"$(prefix)\" $< ! # In GNU Make, ignore whether `stage*' exists. .PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap .PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4 *************** GNATLBR_RTL_C_OBJS = adaint.o argv.o cio *** 4361,4368 **** raise.o sysdep.o tracebak.o GNATLBR_C_OBJS = $(GNATLBR_RTL_C_OBJS) ! ../gnatlbr$(exeext):: sdefault.o $(GNATLBR_C_OBJS) \ ! $(EXTRA_GNATTOOLS_OBJS) $(RM) $@ ../gnatlbr$(exeext):: force $(GNATMAKE) -a --GCC="$(CC)" $(ALL_ADAFLAGS) $(ADA_INCLUDES) \ --- 2154,2160 ---- raise.o sysdep.o tracebak.o GNATLBR_C_OBJS = $(GNATLBR_RTL_C_OBJS) ! ../gnatlbr$(exeext):: sdefault.o $(GNATLBR_C_OBJS) $(EXTRA_GNATTOOLS_OBJS) $(RM) $@ ../gnatlbr$(exeext):: force $(GNATMAKE) -a --GCC="$(CC)" $(ALL_ADAFLAGS) $(ADA_INCLUDES) \ *************** GNATLBR_C_OBJS = $(GNATLBR_RTL_C_OBJS) *** 4370,4372 **** --- 2162,2165 ---- -nostdlib $(fsrcpfx)gnatlbr -o $@ \ -largs --GCC="$(CC) $(ALL_CFLAGS) $(LDFLAGS)" \ $(GNATLBR_C_OBJS) $(EXTRA_GNATTOOLS_OBJS) + diff -Nrc3pad gcc-3.2.3/gcc/ada/Make-lang.in gcc-3.3/gcc/ada/Make-lang.in *** gcc-3.2.3/gcc/ada/Make-lang.in 2003-02-14 17:51:45.000000000 +0000 --- gcc-3.3/gcc/ada/Make-lang.in 2003-01-29 22:37:55.000000000 +0000 *************** *** 1,5 **** # Top level makefile fragment for GNU Ada (GNAT). ! # Copyright (C) 1994, 1995, 1996, 1997, 1997, 1999, 2000, 2001 # Free Software Foundation, Inc. #This file is part of GNU CC. --- 1,5 ---- # Top level makefile fragment for GNU Ada (GNAT). ! # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # Free Software Foundation, Inc. #This file is part of GNU CC. *************** *** 22,28 **** # This file provides the language dependent support in the main Makefile. # Each language makefile fragment must provide the following targets: # ! # foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap, # foo.info, foo.dvi, # foo.install-normal, foo.install-common, foo.install-info, foo.install-man, # foo.uninstall, foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean, --- 22,28 ---- # This file provides the language dependent support in the main Makefile. # Each language makefile fragment must provide the following targets: # ! # foo.all.cross, foo.start.encap, foo.rest.encap, # foo.info, foo.dvi, # foo.install-normal, foo.install-common, foo.install-info, foo.install-man, # foo.uninstall, foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean, *************** *** 38,43 **** --- 38,45 ---- # tool definitions CHMOD = chmod CHMOD_AX_FLAGS = a+x + CP = cp -p + ECHO = echo MV = mv MKDIR = mkdir -p RM = rm -f *************** RMDIR = rm -rf *** 45,68 **** # default extensions shext = # Extra flags to pass to recursive makes. BOOT_ADAFLAGS= $(ADAFLAGS) ! ADAFLAGS= -W -Wall -gnatpg -gnata GNATLIBFLAGS= -W -Wall -gnatpg GNATLIBCFLAGS= -g -O2 ADA_INCLUDE_DIR = $(libsubdir)/adainclude ADA_RTL_OBJ_DIR = $(libsubdir)/adalib THREAD_KIND=native ! GNATBIND = gnatbind ADA_FLAGS_TO_PASS = \ ! "ADA_FOR_BUILD=$(ADA_FOR_BUILD)" \ ! "ADA_INCLUDE_DIR=$(ADA_INCLUDE_DIR)" \ ! "ADA_RTL_OBJ_DIR=$(ADA_RTL_OBJ_DIR)" \ ! "ADAFLAGS=$(ADAFLAGS)" \ ! "ADA_FOR_TARGET=$(ADA_FOR_TARGET)" \ ! "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" # Define the names for selecting Ada in LANGUAGES. Ada ada: gnat1$(exeext) gnatbind$(exeext) --- 47,95 ---- # default extensions shext = + X_ADA_CFLAGS = + T_ADA_CFLAGS = + + X_ADAFLAGS = + T_ADAFLAGS = + # Extra flags to pass to recursive makes. BOOT_ADAFLAGS= $(ADAFLAGS) ! ADAFLAGS= -gnatpg -gnata ! ALL_ADAFLAGS = $(CFLAGS) $(ALL_ADA_CFLAGS) $(X_ADAFLAGS) $(T_ADAFLAGS) \ ! $(ADAFLAGS) ! FORCE_DEBUG_ADAFLAGS = -g ! ADA_CFLAGS = ! ALL_ADA_CFLAGS = $(X_ADA_CFLAGS) $(T_ADA_CFLAGS) $(ADA_CFLAGS) ! ADA_INCLUDES = -I- -I. -Iada -I$(srcdir)/ada GNATLIBFLAGS= -W -Wall -gnatpg GNATLIBCFLAGS= -g -O2 ADA_INCLUDE_DIR = $(libsubdir)/adainclude ADA_RTL_OBJ_DIR = $(libsubdir)/adalib THREAD_KIND=native ! TRACE=no ! GNATBIND = $(STAGE_PREFIX)gnatbind -C ADA_FLAGS_TO_PASS = \ ! "ADA_FOR_BUILD=$(ADA_FOR_BUILD)" \ ! "ADA_INCLUDE_DIR=$(ADA_INCLUDE_DIR)" \ ! "ADA_RTL_OBJ_DIR=$(ADA_RTL_OBJ_DIR)" \ ! "ADAFLAGS=$(ADAFLAGS)" \ ! "ADA_FOR_TARGET=$(ADA_FOR_TARGET)" \ ! "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" + # Say how to compile Ada programs. + .SUFFIXES: .ada .adb .ads + + # FIXME: need to add $(ALL_ADA_CFLAGS) to .c.o suffix rule + # Use loose warnings for this front end, but add some special flags + ada-warn = $(ALL_ADA_CFLAGS) + + .adb.o: + $(ADAC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION) + .ads.o: + $(ADAC) -c $(ALL_ADAFLAGS) $(ADA_INCLUDES) $< $(OUTPUT_OPTION) + # Define the names for selecting Ada in LANGUAGES. Ada ada: gnat1$(exeext) gnatbind$(exeext) *************** Ada ada: gnat1$(exeext) gnatbind$(exeext *** 71,180 **** # There are too many Ada sources to check against here. Let's # always force the recursive make. ! gnat1$(exeext): prefix.o attribs.o $(LIBDEPS) $(BACKEND) force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnat1$(exeext) ! gnatbind$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatbind$(exeext) ! gnatmake$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatmake$(exeext) ! gnatbl$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatbl$(exeext) ! gnatchop$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatchop$(exeext) ! gnatcmd$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatcmd$(exeext) ! gnatlink$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatlink$(exeext) ! gnatkr$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatkr$(exeext) ! gnatls$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatls$(exeext) ! gnatmem$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatmem$(exeext) ! gnatprep$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatprep$(exeext) ! gnatpsta$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatpsta$(exeext) ! gnatpsys$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatpsys$(exeext) ! gnatxref$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatxref$(exeext) ! gnatfind$(exeext): $(CONFIG_H) prefix.o force $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatfind$(exeext) ! # Gnatlbr is extra tool only used on VMS ! gnatlbr$(exeext): $(CONFIG_H) prefix.o force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ../gnatlbr$(exeext) ! # use target-gcc ! gnattools: $(GCC_PARTS) force ! $(MAKE) $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! CC="../xgcc -B../" STAGE_PREFIX=../ \ ! gnatbl$(exeext) gnatchop$(exeext) gnatcmd$(exeext) \ ! gnatkr$(exeext) gnatlink$(exeext) \ ! gnatls$(exeext) gnatmake$(exeext) \ ! gnatprep$(exeext) gnatpsta$(exeext) gnatpsys$(exeext) \ ! gnatxref$(exeext) gnatfind$(exeext) $(EXTRA_GNATTOOLS) ! # use host-gcc ! cross-gnattools: force ! $(MAKE) $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! gnatbl$(exeext) gnatchop$(exeext) gnatcmd$(exeext) \ ! gnatkr$(exeext) gnatlink$(exeext) \ ! gnatls$(exeext) gnatmake$(exeext) \ ! gnatprep$(exeext) gnatpsta$(exeext) gnatpsys$(exeext) \ ! gnatxref$(exeext) gnatfind$(exeext) $(EXTRA_GNATTOOLS) - # use target-gcc gnatlib: force $(MAKE) -C ada $(FLAGS_TO_PASS) \ - CC="../xgcc -B../" ADAC="../xgcc -B../" STAGE_PREFIX=../ \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \ THREAD_KIND="$(THREAD_KIND)" \ gnatlib - # use target-gcc gnatlib-shared: force $(MAKE) -C ada $(FLAGS_TO_PASS) \ - CC="../xgcc -B../" ADAC="../xgcc -B../" STAGE_PREFIX=../ \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ GNATLIBLDFLAGS="$(GNATLIBLDFLAGS)" \ TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \ THREAD_KIND="$(THREAD_KIND)" \ gnatlib-shared # use only for native compiler --- 98,269 ---- # There are too many Ada sources to check against here. Let's # always force the recursive make. ! ADA_TOOLS_FLAGS_TO_PASS=\ ! "CC=../../xgcc -B../../" \ ! "CFLAGS=$(CFLAGS)" \ ! "exeext=$(exeext)" \ ! "ADAFLAGS=$(ADAFLAGS)" \ ! "ADA_INCLUDES=-I../rts" \ ! "GNATMAKE=../../gnatmake" \ ! "GNATLINK=../../gnatlink" \ ! "GNATBIND=../../gnatbind" ! # Lists of files for various purposes. ! # Languages-specific object files for Ada. ! # Object files for gnat1 from C sources. ! GNAT1_C_OBJS = ada/b_gnat1.o ada/adadecode.o ada/adaint.o ada/cstreams.o \ ! ada/cio.o ada/targtyps.o ada/decl.o ada/misc.o ada/utils.o ada/utils2.o \ ! ada/trans.o ada/cuintp.o ada/argv.o ada/raise.o ada/init.o ada/tracebak.o ! # Object files from Ada sources that are used by gnat1 ! GNAT_ADA_OBJS = \ ! ada/ada.o ada/a-charac.o ada/a-chlat1.o ada/a-except.o ada/s-memory.o \ ! ada/s-traceb.o ada/s-mastop.o ada/s-except.o ada/ali.o ada/alloc.o \ ! ada/atree.o ada/butil.o ada/casing.o ada/checks.o ada/comperr.o ada/csets.o \ ! ada/cstand.o ada/debug.o ada/debug_a.o ada/einfo.o ada/elists.o ada/errout.o \ ! ada/eval_fat.o ada/exp_attr.o ada/exp_ch11.o ada/exp_ch12.o ada/exp_ch13.o \ ! ada/exp_ch2.o ada/exp_ch3.o ada/exp_ch4.o ada/exp_ch5.o ada/exp_ch6.o \ ! ada/exp_ch7.o ada/exp_ch8.o ada/exp_ch9.o ada/exp_code.o ada/exp_dbug.o \ ! ada/exp_disp.o ada/exp_dist.o ada/exp_fixd.o ada/exp_aggr.o ada/exp_imgv.o \ ! ada/exp_intr.o ada/exp_pakd.o ada/exp_prag.o ada/exp_smem.o ada/exp_strm.o \ ! ada/exp_tss.o ada/exp_util.o ada/exp_vfpt.o ada/expander.o ada/fname.o \ ! ada/fname-uf.o ada/fmap.o ada/freeze.o ada/frontend.o ada/gnat.o \ ! ada/g-hesora.o ada/g-htable.o ada/g-os_lib.o ada/g-speche.o ada/s-crc32.o \ ! ada/get_targ.o ada/gnatvsn.o ada/hlo.o ada/hostparm.o ada/impunit.o \ ! ada/interfac.o ada/itypes.o ada/inline.o ada/krunch.o ada/lib.o ada/layout.o \ ! ada/lib-load.o ada/lib-util.o ada/lib-xref.o ada/lib-writ.o ada/live.o \ ! ada/namet.o ada/nlists.o ada/nmake.o ada/opt.o ada/osint.o ada/osint-c.o \ ! ada/output.o ada/par.o ada/repinfo.o ada/restrict.o ada/rident.o \ ! ada/rtsfind.o ada/s-assert.o ada/s-parame.o ada/s-stache.o ada/s-stalib.o \ ! ada/s-imgenu.o ada/s-stoele.o ada/s-soflin.o ada/s-exctab.o ada/s-secsta.o \ ! ada/s-wchcnv.o ada/s-wchcon.o ada/s-wchjis.o ada/s-unstyp.o ada/scans.o \ ! ada/scn.o ada/sdefault.o ada/sem.o ada/sem_aggr.o ada/sem_attr.o \ ! ada/sem_cat.o ada/sem_ch10.o ada/sem_ch11.o ada/sem_ch12.o ada/sem_ch13.o \ ! ada/sem_ch2.o ada/sem_ch3.o ada/sem_ch4.o ada/sem_ch5.o ada/sem_ch6.o \ ! ada/sem_ch7.o ada/sem_ch8.o ada/sem_ch9.o ada/sem_case.o ada/sem_disp.o \ ! ada/sem_dist.o ada/sem_elab.o ada/sem_elim.o ada/sem_eval.o ada/sem_intr.o \ ! ada/sem_maps.o ada/sem_mech.o ada/sem_prag.o ada/sem_res.o ada/sem_smem.o \ ! ada/sem_type.o ada/sem_util.o ada/sem_vfpt.o ada/sem_warn.o ada/sinfo-cn.o \ ! ada/sinfo.o ada/sinput.o ada/sinput-d.o ada/sinput-l.o ada/snames.o \ ! ada/sprint.o ada/stand.o ada/stringt.o ada/style.o ada/switch.o \ ! ada/switch-c.o ada/stylesw.o ada/validsw.o ada/system.o ada/table.o \ ! ada/targparm.o ada/tbuild.o ada/tree_gen.o ada/tree_io.o ada/treepr.o \ ! ada/treeprs.o ada/ttypef.o ada/ttypes.o ada/types.o ada/uintp.o ada/uname.o \ ! ada/urealp.o ada/usage.o ada/widechar.o ! # Object files for gnat executables ! GNAT1_ADA_OBJS = $(GNAT_ADA_OBJS) ada/back_end.o ada/gnat1drv.o ! GNAT1_OBJS = $(GNAT1_C_OBJS) $(GNAT1_ADA_OBJS) $(EXTRA_GNAT1_OBJS) ! GNATBIND_OBJS = \ ! ada/link.o ada/ada.o ada/adaint.o ada/cstreams.o ada/cio.o ada/ali.o \ ! ada/ali-util.o ada/alloc.o ada/a-tags.o ada/a-stream.o ada/bcheck.o \ ! ada/binde.o ada/binderr.o ada/bindgen.o ada/bindusg.o ada/butil.o \ ! ada/casing.o ada/csets.o ada/debug.o ada/fname.o ada/gnat.o ada/g-hesora.o \ ! ada/g-htable.o ada/g-os_lib.o ada/s-crc32.o ada/fmap.o ada/gnatbind.o \ ! ada/gnatvsn.o ada/hostparm.o ada/krunch.o ada/namet.o ada/opt.o ada/osint.o \ ! ada/osint-b.o ada/output.o ada/rident.o ada/s-assert.o ada/s-parame.o \ ! ada/s-sopco3.o ada/s-sopco4.o ada/s-sopco5.o ada/s-stache.o ada/s-stalib.o \ ! ada/s-stoele.o ada/s-imgenu.o ada/s-strops.o ada/s-soflin.o ada/s-wchcon.o \ ! ada/s-wchjis.o ada/sdefault.o ada/switch.o ada/switch-b.o ada/stylesw.o \ ! ada/validsw.o ada/system.o ada/table.o ada/tree_io.o ada/types.o \ ! ada/widechar.o ada/raise.o ada/exit.o ada/argv.o ada/init.o ada/adafinal.o \ ! ada/s-wchcnv.o ada/s-exctab.o ada/a-except.o ada/s-memory.o ada/s-traceb.o \ ! ada/tracebak.o ada/s-mastop.o ada/s-except.o ada/s-secsta.o ada/atree.o \ ! ada/scans.o ada/einfo.o ada/sinfo.o ada/scn.o ada/sinput.o ada/sinput-l.o \ ! ada/targparm.o ada/errout.o ada/style.o ada/stand.o ada/lib.o ada/uintp.o \ ! ada/elists.o ada/nlists.o ada/stringt.o ada/snames.o ada/uname.o \ ! ada/urealp.o \ ! $(EXTRA_GNATBIND_OBJS) ! # List of extra object files linked in with various programs. ! EXTRA_GNAT1_OBJS = prefix.o ! EXTRA_GNATBIND_OBJS = prefix.o version.o ! # FIXME: handle with configure substitutions ! #ifeq ($(strip $(filter-out alpha% dec vms% openvms% alphavms%,$(host))),) ! # ! #EXTRA_GNAT1_OBJS = prefix.o vmshandler.o ! #EXTRA_GNATBIND_OBJS = prefix.o vmshandler.o ! # ! #endif ! # Language-independent object files. ! ADA_BACKEND = $(BACKEND) attribs.o ! # List of target dependent sources, overridden below as necessary ! TARGET_ADA_SRCS = ! # Needs to be built with CC=gcc ! # Since the RTL should be built with the latest compiler, remove the ! # stamp target in the parent directory whenever gnat1 is rebuilt ! gnat1$(exeext): $(TARGET_ADA_SRCS) $(GNAT1_OBJS) $(ADA_BACKEND) $(LIBDEPS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(GNAT1_OBJS) $(ADA_BACKEND) $(LIBS) \ ! $(SYSLIBS) ! $(RM) stamp-gnatlib2 stamp-tools ! gnatbind$(exeext): ada/b_gnatb.o $(CONFIG_H) $(GNATBIND_OBJS) ! $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ ada/b_gnatb.o $(GNATBIND_OBJS) \ ! $(LIBIBERTY) $(LIBS) $(SYSLIBS) ! # use target-gcc target-gnatmake target-gnatbind target-gnatlink ! gnattools: $(GCC_PARTS) $(CONFIG_H) prefix.o force $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ! ADA_INCLUDES="-I- -I../rts"\ ! CC="../../xgcc -B../../" STAGE_PREFIX=../../ gnattools1 ! $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools2 ! $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools3 ! regnattools: ! $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools1-re ! $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools2 ! $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools3 ! # use host-gcc host-gnatmake host-gnatbind host-gnatlink ! # put the host RTS dir first in the PATH to hide the default runtime ! # files that are among the sources ! RTS_DIR:=$(dir $(subst \,/,$(shell $(CC) -print-libgcc-file-name))) ! cross-gnattools: force ! $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS)\ ! ADA_INCLUDES="-I$(RTS_DIR)adainclude -I$(RTS_DIR)adalib" \ ! GNATMAKE="gnatmake" \ ! GNATBIND="gnatbind" \ ! GNATLINK="gnatlink" \ ! LIBGNAT="" \ ! gnattools1-re gnattools2 ! rts-none: force ! $(MAKE) -C ada $(FLAGS_TO_PASS) GNATMAKE=../gnatmake rts-none ! install-rts-none: force ! $(MAKE) -C ada $(FLAGS_TO_PASS) install-rts RTS_NAME=none ! ! rts-ravenscar: force ! $(MAKE) -C ada $(FLAGS_TO_PASS) GNATMAKE=../gnatmake rts-ravenscar ! ! install-rts-ravenscar: force ! $(MAKE) -C ada $(FLAGS_TO_PASS) install-rts RTS_NAME=ravenscar gnatlib: force $(MAKE) -C ada $(FLAGS_TO_PASS) \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \ THREAD_KIND="$(THREAD_KIND)" \ + TRACE="$(TRACE)" \ gnatlib gnatlib-shared: force $(MAKE) -C ada $(FLAGS_TO_PASS) \ GNATLIBFLAGS="$(GNATLIBFLAGS)" \ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \ GNATLIBLDFLAGS="$(GNATLIBLDFLAGS)" \ TARGET_LIBGCC2_CFLAGS="$(TARGET_LIBGCC2_CFLAGS)" \ THREAD_KIND="$(THREAD_KIND)" \ + TRACE="$(TRACE)" \ gnatlib-shared # use only for native compiler *************** gnatlib_and_tools: gnatlib gnattools *** 183,192 **** # use cross-gcc gnat-cross: force $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) gnat-cross # Build hooks: - ada.all.build: ada.all.cross: -if [ -f gnatbind$(exeext) ] ; \ then \ --- 272,283 ---- # use cross-gcc gnat-cross: force $(MAKE) -C ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) gnat-cross + + gt-ada-decl.h gt-ada-trans.h gt-ada-utils.h gtype-ada.h : s-gtype ; @true + # Build hooks: ada.all.cross: -if [ -f gnatbind$(exeext) ] ; \ then \ *************** ada.all.cross: *** 200,208 **** then \ $(MV) gnatchop$(exeext) gnatchop-cross$(exeext); \ fi ! -if [ -f gnatcmd$(exeext) ] ; \ then \ ! $(MV) gnatcmd$(exeext) gnatcmd-cross$(exeext); \ fi -if [ -f gnatkr$(exeext) ] ; \ then \ --- 291,299 ---- then \ $(MV) gnatchop$(exeext) gnatchop-cross$(exeext); \ fi ! -if [ -f gnat$(exeext) ] ; \ then \ ! $(MV) gnat$(exeext) gnat-cross$(exeext); \ fi -if [ -f gnatkr$(exeext) ] ; \ then \ *************** ada.all.cross: *** 224,229 **** --- 315,324 ---- then \ $(MV) gnatmem$(exeext) gnatmem-cross$(exeext); \ fi + -if [ -f gnatname$(exeext) ] ; \ + then \ + $(MV) gnatname$(exeext) gnatname-cross$(exeext); \ + fi -if [ -f gnatprep$(exeext) ] ; \ then \ $(MV) gnatprep$(exeext) gnatprep-cross$(exeext); \ *************** ada.all.cross: *** 232,241 **** then \ $(MV) gnatpsta$(exeext) gnatpsta-cross$(exeext); \ fi - -if [ -f gnatpsys$(exeext) ] ; \ - then \ - $(MV) gnatpsys$(exeext) gnatpsys-cross$(exeext); \ - fi -if [ -f gnatxref$(exeext) ] ; \ then \ $(MV) gnatxref$(exeext) gnatxref-cross$(exeext); \ --- 327,332 ---- *************** ada.all.cross: *** 246,254 **** fi ada.start.encap: ! ada.rest.encap: ! ada.info: ! ada.dvi: ada.generated-manpages: # Install hooks: --- 337,459 ---- fi ada.start.encap: ! ada.rest.encap: ! ! # Generate documentation. ! # ! # The generated Texinfo files for the User Guideare stored in ! # $(srcdir), like the Info files. ! ! ada/doctools/xgnatug : ada/xgnatug.adb ! -$(MKDIR) ada/doctools ! cp $^ ada/doctools ! cd ada/doctools && gnatmake -q xgnatug ! ! $(srcdir)/ada/gnat_ug_unx.texi : ada/doctools/xgnatug \ ! $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words ! ada/doctools/xgnatug unx $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words $(srcdir)/ada/gnat_ug_unx.texi ! ! $(srcdir)/ada/gnat_ug_vms.texi : ada/doctools/xgnatug \ ! $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words ! ada/doctools/xgnatug vms $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words $(srcdir)/ada/gnat_ug_vms.texi ! ! $(srcdir)/ada/gnat_ug_vxw.texi : ada/doctools/xgnatug \ ! $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words ! ada/doctools/xgnatug vxworks $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words $(srcdir)/ada/gnat_ug_vxw.texi ! ! $(srcdir)/ada/gnat_ug_wnt.texi : ada/doctools/xgnatug \ ! $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words ! ada/doctools/xgnatug wnt $(srcdir)/ada/gnat_ug.texi $(srcdir)/ada/ug_words $(srcdir)/ada/gnat_ug_wnt.texi ! ! $(srcdir)/ada/gnat_ug_unx.info : $(srcdir)/ada/gnat_ug_unx.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! cd $(srcdir) && $(MAKEINFO) -I doc/include -I ada -o ada/gnat_ug_unx.info ada/gnat_ug_unx.texi ! ! $(srcdir)/ada/gnat_ug_vms.info : $(srcdir)/ada/gnat_ug_vms.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! cd $(srcdir) && $(MAKEINFO) -I doc/include -I ada -o ada/gnat_ug_vms.info ada/gnat_ug_vms.texi ! ! $(srcdir)/ada/gnat_ug_vxw.info : $(srcdir)/ada/gnat_ug_vxw.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! cd $(srcdir) && $(MAKEINFO) -I doc/include -I ada -o ada/gnat_ug_vxw.info ada/gnat_ug_vxw.texi ! ! $(srcdir)/ada/gnat_ug_wnt.info : $(srcdir)/ada/gnat_ug_wnt.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! cd $(srcdir) && $(MAKEINFO) -I doc/include -I ada -o ada/gnat_ug_wnt.info ada/gnat_ug_wnt.texi ! ! $(srcdir)/ada/gnat_rm.info : $(srcdir)/ada/gnat_rm.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! cd $(srcdir) && $(MAKEINFO) -I doc/include -I ada -o ada/gnat_rm.info ada/gnat_rm.texi ! ! $(srcdir)/ada/gnat-style.info : $(srcdir)/ada/gnat-style.texi \ ! $(srcdir)/doc/include/fdl.texi ! cd $(srcdir) && $(MAKEINFO) -I doc/include -I ada -o ada/gnat-style.info ada/gnat-style.texi ! ! ada.info: $(srcdir)/ada/gnat_ug_vms.info $(srcdir)/ada/gnat_ug_wnt.info \ ! $(srcdir)/ada/gnat_ug_unx.info $(srcdir)/ada/gnat_ug_vxw.info \ ! $(srcdir)/ada/gnat_rm.info $(srcdir)/ada/gnat-style.info ! ! ada.install-info: ! -rm -f $(DESTDIR)$(infodir)/gnat_ug_*.info* ! -rm -f $(DESTDIR)$(infodir)/gnat_rm.info* ! -rm -f $(DESTDIR)$(infodir)/gnat-style.info* ! $(MKDIR) $(DESTDIR)$(infodir) ! if [ -f $(srcdir)/ada/gnat_ug_unx.info ]; then \ ! for f in $(srcdir)/ada/gnat_ug_*.info* \ ! $(srcdir)/ada/gnat_rm.info* \ ! $(srcdir)/ada/gnat-style.info*; do \ ! realfile=`echo $$f | sed -e 's|.*/\([^/]*\)$$|\1|'`; \ ! $(INSTALL_DATA) $$f $(DESTDIR)$(infodir)/$$realfile; \ ! done; \ ! else true; fi ! -if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ ! if [ -f $(DESTDIR)$(infodir)/dir ] ; then \ ! for f in gnat_ug_vms.info gnat_ug_wnt.info gnat_ug_unx.info \ ! gnat_ug_vxw.info gnat_rm.info gnat-style.info; do \ ! if [ -f $(DESTDIR)$(infodir)/$$f ]; then \ ! install-info --dir-file=$(DESTDIR)$(infodir)/dir $(DESTDIR)$(infodir)/$$f; \ ! else true; fi; \ ! done; \ ! else true; fi; \ ! else true; fi; ! -chmod a-x $(DESTDIR)$(infodir)/gnat_ug_vms.info* $(DESTDIR)$(infodir)/gnat_ug_wnt.info* ! -chmod a-x $(DESTDIR)$(infodir)/gnat_ug_unx.info* $(DESTDIR)$(infodir)/gnat_ug_vxw.info* ! -chmod a-x $(DESTDIR)$(infodir)/gnat_rm.info* $(DESTDIR)$(infodir)/gnat-style.info* ! ! ada/gnat_ug_unx.dvi : $(srcdir)/ada/gnat_ug_unx.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! s=`cd $(srcdir); ${PWD}`; \ ! cd ada && $(TEXI2DVI) -c -I $$s/doc/include -o gnat_ug_unx.dvi $$s/ada/gnat_ug_unx.texi ! ! ada/gnat_ug_vms.dvi : $(srcdir)/ada/gnat_ug_vms.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! s=`cd $(srcdir); ${PWD}`; \ ! cd ada && $(TEXI2DVI) -c -I $$s/doc/include -o gnat_ug_vms.dvi $$s/ada/gnat_ug_vms.texi ! ! ada/gnat_ug_vxw.dvi : $(srcdir)/ada/gnat_ug_vxw.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! s=`cd $(srcdir); ${PWD}`; \ ! cd ada && $(TEXI2DVI) -c -I $$s/doc/include -o gnat_ug_vxw.dvi $$s/ada/gnat_ug_vxw.texi ! ! ada/gnat_ug_wnt.dvi : $(srcdir)/ada/gnat_ug_wnt.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! s=`cd $(srcdir); ${PWD}`; \ ! cd ada && $(TEXI2DVI) -c -I $$s/doc/include -o gnat_ug_wnt.dvi $$s/ada/gnat_ug_wnt.texi ! ! ada/gnat_rm.dvi : $(srcdir)/ada/gnat_rm.texi \ ! $(srcdir)/doc/include/fdl.texi $(srcdir)/doc/include/gcc-common.texi ! s=`cd $(srcdir); ${PWD}`; \ ! cd ada && $(TEXI2DVI) -c -I $$s/doc/include -o gnat_rm.dvi $$s/ada/gnat_rm.texi ! ! ada/gnat-style.dvi : $(srcdir)/ada/gnat-style.texi \ ! $(srcdir)/doc/include/fdl.texi ! s=`cd $(srcdir); ${PWD}`; \ ! cd ada && $(TEXI2DVI) -c -I $$s/doc/include -o gnat-style.dvi $$s/ada/gnat-style.texi ! ! ada.dvi: ada/gnat_ug_vms.dvi ada/gnat_ug_wnt.dvi \ ! ada/gnat_ug_unx.dvi ada/gnat_ug_vxw.dvi \ ! ada/gnat_rm.dvi ada/gnat-style.dvi ! ada.generated-manpages: # Install hooks: *************** ada.install-normal: *** 258,264 **** # Install the binder program as $(target_alias)-gnatbind # and also as either gnatbind (if native) or $(tooldir)/bin/gnatbind ! # likewise for gnatf, gnatchop, and gnatlink, gnatkr, gnatmake, gnatcmd, # gnatprep, gnatbl, gnatls, gnatxref, gnatfind ada.install-common: $(MKDIR) $(DESTDIR)$(bindir) --- 463,469 ---- # Install the binder program as $(target_alias)-gnatbind # and also as either gnatbind (if native) or $(tooldir)/bin/gnatbind ! # likewise for gnatf, gnatchop, and gnatlink, gnatkr, gnatmake, gnat, # gnatprep, gnatbl, gnatls, gnatxref, gnatfind ada.install-common: $(MKDIR) $(DESTDIR)$(bindir) *************** ada.install-common: *** 309,325 **** fi -if [ -f gnat1$(exeext) ] ; \ then \ ! if [ -f gnatcmd-cross$(exeext) ] ; \ then \ $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnat$(exeext); \ ! $(INSTALL_PROGRAM) gnatcmd-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnat$(exeext); \ if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \ rm -f $(DESTDIR)$(tooldir)/bin/gnat$(exeext); \ ! $(INSTALL_PROGRAM) gnatcmd-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnat$(exeext); \ fi; \ else \ $(RM) $(DESTDIR)$(bindir)/gnat$(exeext); \ ! $(INSTALL_PROGRAM) gnatcmd$(exeext) $(DESTDIR)$(bindir)/gnat$(exeext); \ fi ; \ fi -if [ -f gnat1$(exeext) ] ; \ --- 514,530 ---- fi -if [ -f gnat1$(exeext) ] ; \ then \ ! if [ -f gnat-cross$(exeext) ] ; \ then \ $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnat$(exeext); \ ! $(INSTALL_PROGRAM) gnat-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnat$(exeext); \ if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \ rm -f $(DESTDIR)$(tooldir)/bin/gnat$(exeext); \ ! $(INSTALL_PROGRAM) gnat-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnat$(exeext); \ fi; \ else \ $(RM) $(DESTDIR)$(bindir)/gnat$(exeext); \ ! $(INSTALL_PROGRAM) gnat$(exeext) $(DESTDIR)$(bindir)/gnat$(exeext); \ fi ; \ fi -if [ -f gnat1$(exeext) ] ; \ *************** ada.install-common: *** 395,400 **** --- 600,616 ---- fi -if [ -f gnat1$(exeext) ] ; \ then \ + if [ -f gnatname-cross$(exeext) ] ; \ + then \ + $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatname$(exeext); \ + $(INSTALL_PROGRAM) gnatname-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatname$(exeext); \ + else \ + $(RM) $(DESTDIR)$(bindir)/gnatname$(exeext); \ + $(INSTALL_PROGRAM) gnatname$(exeext) $(DESTDIR)$(bindir)/gnatname$(exeext); \ + fi ; \ + fi + -if [ -f gnat1$(exeext) ] ; \ + then \ if [ -f gnatprep-cross$(exeext) ] ; \ then \ $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatprep$(exeext); \ *************** ada.install-common: *** 425,445 **** fi -if [ -f gnat1$(exeext) ] ; \ then \ - if [ -f gnatpsys-cross$(exeext) ] ; \ - then \ - $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsys$(exeext); \ - $(INSTALL_PROGRAM) gnatpsys-cross$(exeext) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsys$(exeext); \ - if [ -d $(DESTDIR)$(tooldir)/bin/. ] ; then \ - rm -f $(DESTDIR)$(tooldir)/bin/gnatpsys$(exeext); \ - $(INSTALL_PROGRAM) gnatpsys-cross$(exeext) $(DESTDIR)$(tooldir)/bin/gnatpsys$(exeext); \ - fi; \ - else \ - $(RM) $(DESTDIR)$(bindir)/gnatpsys$(exeext); \ - $(INSTALL_PROGRAM) gnatpsys$(exeext) $(DESTDIR)$(bindir)/gnatpsys$(exeext); \ - fi ; \ - fi - -if [ -f gnat1$(exeext) ] ; \ - then \ if [ -f gnatxref-cross$(exeext) ] ; \ then \ $(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatxref$(exeext); \ --- 641,646 ---- *************** ada.install-common: *** 461,467 **** fi ; \ fi # ! # Gnatlbr is only use on VMS # -if [ -f gnat1$(exeext) ] ; \ then \ --- 662,668 ---- fi ; \ fi # ! # Gnatlbr is only used on VMS. # -if [ -f gnat1$(exeext) ] ; \ then \ *************** ada.uninstall: *** 501,557 **** -$(RM) $(DESTDIR)$(bindir)/gnatbl$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatchop$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnat$(exeext) - -$(RM) $(DESTDIR)$(bindir)/gnatdll$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatfind$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatkr$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatlbr$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatlink$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatls$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatmake$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatmem$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatprep$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatpsta$(exeext) - -$(RM) $(DESTDIR)$(bindir)/gnatpsys$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatxref$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatbind$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatbl$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatchop$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnat$(exeext) - -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatdll$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatfind$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatkr(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatlbr$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatlink$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatls$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatmake$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatmem$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatprep$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsta$(exeext) - -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsys$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatxref$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatbind$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatbl$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatchop$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnat$(exeext) - -$(RM) $(DESTDIR)$(tooldir)/bin/gnatdll$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatfind$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatkr$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatlbr$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatlink$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatls$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatmake$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatmem$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatprep$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatpsta$(exeext) - -$(RM) $(DESTDIR)$(tooldir)/bin/gnatpsys$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatxref$(exeext) ! # Clean hooks: # A lot of the ancillary files are deleted by the main makefile. # We just have to delete files specific to us. ada.mostlyclean: -$(RM) ada/*$(objext) ada/*.ali ada/b_*.c -$(RM) ada/sdefault.adb ada/stamp-sdefault -$(RMDIR) ada/tools ada.clean: --- 702,759 ---- -$(RM) $(DESTDIR)$(bindir)/gnatbl$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatchop$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnat$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatfind$(exeext) + -$(RM) $(DESTDIR)$(bindir)/gnatdll$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatkr$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatlbr$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatlink$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatls$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatmake$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatmem$(exeext) + -$(RM) $(DESTDIR)$(bindir)/gnatname$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatprep$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatpsta$(exeext) -$(RM) $(DESTDIR)$(bindir)/gnatxref$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatbind$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatbl$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatchop$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnat$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatfind$(exeext) + -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatdll$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatkr(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatlbr$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatlink$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatls$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatmake$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatmem$(exeext) + -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatname$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatprep$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatpsta$(exeext) -$(RM) $(DESTDIR)$(bindir)/$(target_alias)-gnatxref$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatbind$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatbl$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatchop$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnat$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatfind$(exeext) + -$(RM) $(DESTDIR)$(tooldir)/bin/gnatdll$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatkr$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatlbr$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatlink$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatls$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatmake$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatmem$(exeext) + -$(RM) $(DESTDIR)$(tooldir)/bin/gnatname$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatprep$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatpsta$(exeext) -$(RM) $(DESTDIR)$(tooldir)/bin/gnatxref$(exeext) ! # Clean hooks: # A lot of the ancillary files are deleted by the main makefile. # We just have to delete files specific to us. ada.mostlyclean: -$(RM) ada/*$(objext) ada/*.ali ada/b_*.c + -$(RM) ada/*$(coverageexts) -$(RM) ada/sdefault.adb ada/stamp-sdefault -$(RMDIR) ada/tools ada.clean: *************** ada.distclean: *** 559,580 **** -$(RM) ada/Makefile -$(RM) gnatbl$(exeext) -$(RM) gnatchop$(exeext) ! -$(RM) gnatcmd$(exeext) -$(RM) gnatdll$(exeext) -$(RM) gnatkr$(exeext) -$(RM) gnatlink$(exeext) -$(RM) gnatls$(exeext) -$(RM) gnatmake$(exeext) -$(RM) gnatmem$(exeext) -$(RM) gnatprep$(exeext) -$(RM) gnatpsta$(exeext) - -$(RM) gnatpsys$(exeext) -$(RM) gnatfind$(exeext) -$(RM) gnatxref$(exeext) ! # Gnatlbr and Gnatchop are only used on VMS ! -$(RM) gnatchop$(exeext) gnatlbr$(exeext) -$(RM) ada/rts/* -$(RMDIR) ada/rts -$(RMDIR) ada/tools ada.extraclean: ada.maintainer-clean: --- 761,783 ---- -$(RM) ada/Makefile -$(RM) gnatbl$(exeext) -$(RM) gnatchop$(exeext) ! -$(RM) gnat$(exeext) -$(RM) gnatdll$(exeext) -$(RM) gnatkr$(exeext) -$(RM) gnatlink$(exeext) -$(RM) gnatls$(exeext) -$(RM) gnatmake$(exeext) -$(RM) gnatmem$(exeext) + -$(RM) gnatname$(exeext) -$(RM) gnatprep$(exeext) -$(RM) gnatpsta$(exeext) -$(RM) gnatfind$(exeext) -$(RM) gnatxref$(exeext) ! # Gnatlbr is only used on VMS ! -$(RM) gnatlbr$(exeext) -$(RM) ada/rts/* -$(RMDIR) ada/rts + -$(RM) ada/tools/* -$(RMDIR) ada/tools ada.extraclean: ada.maintainer-clean: *************** ada.maintainer-clean: *** 587,602 **** # Stage hooks: # The main makefile has already created stage?/ada ! ada.stage1: -$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage1/ada -$(MV) ada/stamp-* stage1/ada ! ada.stage2: -$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage2/ada -$(MV) ada/stamp-* stage2/ada ! ada.stage3: -$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage3/ada -$(MV) ada/stamp-* stage3/ada ! ada.stage4: -$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage4/ada -$(MV) ada/stamp-* stage4/ada --- 790,805 ---- # Stage hooks: # The main makefile has already created stage?/ada ! ada.stage1: stage1-start -$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage1/ada -$(MV) ada/stamp-* stage1/ada ! ada.stage2: stage2-start -$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage2/ada -$(MV) ada/stamp-* stage2/ada ! ada.stage3: stage3-start -$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage3/ada -$(MV) ada/stamp-* stage3/ada ! ada.stage4: stage4-start -$(MV) ada/*$(objext) ada/*.ali ada/b_*.c stage4/ada -$(MV) ada/stamp-* stage4/ada *************** gnatstage2: force *** 643,645 **** --- 846,2519 ---- -$(MV) gnat1$(exeext) gnatbind$(exeext) stage2 -$(MV) ada/*$(objext) ada/*.ali stage2/ada -$(MV) ada/stamp-* stage2/ada + + # Compiling object files from source files. + + # Note that dependencies on obstack.h are not written + # because that file is not part of GCC. + # Dependencies on gvarargs.h are not written + # because all that file does, when not compiling with GCC, + # is include the system varargs.h. + + # Ada language specific files. + + ada_extra_files : ada/treeprs.ads ada/einfo.h ada/sinfo.h ada/nmake.adb \ + ada/nmake.ads + + ada/b_gnat1.c : $(GNAT1_ADA_OBJS) + $(GNATBIND) $(ADA_INCLUDES) -o ada/b_gnat1.c -n ada/gnat1drv.ali + ada/b_gnat1.o : ada/b_gnat1.c + + ada/b_gnatb.c : $(GNATBIND_OBJS) ada/gnatbind.o ada/interfac.o + $(GNATBIND) $(ADA_INCLUDES) -o ada/b_gnatb.c ada/gnatbind.ali + ada/b_gnatb.o : ada/b_gnatb.c + + ada/treeprs.ads : ada/treeprs.adt ada/sinfo.ads ada/xtreeprs.adb + -$(MKDIR) ada/bldtools + $(CP) $^ ada/bldtools + (cd ada/bldtools; gnatmake -q xtreeprs ; ./xtreeprs ../treeprs.ads ) + + ada/einfo.h : ada/einfo.ads ada/einfo.adb ada/xeinfo.adb + -$(MKDIR) ada/bldtools + $(CP) $^ ada/bldtools + (cd ada/bldtools; gnatmake -q xeinfo ; ./xeinfo ../einfo.h ) + + ada/sinfo.h : ada/sinfo.ads ada/xsinfo.adb + -$(MKDIR) ada/bldtools + $(CP) $^ ada/bldtools + (cd ada/bldtools; gnatmake -q xsinfo ; ./xsinfo ../sinfo.h ) + + ada/nmake.adb : ada/sinfo.ads ada/nmake.adt ada/xnmake.adb + -$(MKDIR) ada/bldtools + $(CP) $^ ada/bldtools + (cd ada/bldtools; gnatmake -q xnmake ; ./xnmake -b ../nmake.adb ) + + ada/nmake.ads : ada/sinfo.ads ada/nmake.adt ada/xnmake.adb + -$(MKDIR) ada/bldtools + $(CP) $^ ada/bldtools + (cd ada/bldtools; gnatmake -q xnmake ; ./xnmake -s ../nmake.ads ) + + update-sources : ada/treeprs.ads ada/einfo.h ada/sinfo.h ada/nmake.adb \ + ada/nmake.ads + $(CP) $^ $(srcdir)/ada + + # Note: the strings below do not make sense for Ada strings in the OS/2 + # case. This is ignored for now since the OS/2 version doesn't use + # these -- there are no default locations. + ada/sdefault.adb: ada/stamp-sdefault ; @true + ada/stamp-sdefault : $(srcdir)/version.c $(srcdir)/move-if-change \ + Makefile + $(ECHO) "pragma Style_Checks (Off);" >tmp-sdefault.adb + $(ECHO) "package body Sdefault is" >>tmp-sdefault.adb + $(ECHO) " S1 : aliased constant String := \"$(ADA_INCLUDE_DIR)/\";" >>tmp-sdefault.adb + $(ECHO) " S2 : aliased constant String := \"$(ADA_RTL_OBJ_DIR)/\";" >>tmp-sdefault.adb + $(ECHO) " S3 : aliased constant String := \"$(target)/\";" >>tmp-sdefault.adb + $(ECHO) " S4 : aliased constant String := \"$(libsubdir)/\";" >>tmp-sdefault.adb + $(ECHO) " function Include_Dir_Default_Name return String_Ptr is" >>tmp-sdefault.adb + $(ECHO) " begin" >>tmp-sdefault.adb + $(ECHO) " return new String'(S1);" >>tmp-sdefault.adb + $(ECHO) " end Include_Dir_Default_Name;" >>tmp-sdefault.adb + $(ECHO) " function Object_Dir_Default_Name return String_Ptr is" >>tmp-sdefault.adb + $(ECHO) " begin" >>tmp-sdefault.adb + $(ECHO) " return new String'(S2);" >>tmp-sdefault.adb + $(ECHO) " end Object_Dir_Default_Name;" >>tmp-sdefault.adb + $(ECHO) " function Target_Name return String_Ptr is" >>tmp-sdefault.adb + $(ECHO) " begin" >>tmp-sdefault.adb + $(ECHO) " return new String'(S3);" >>tmp-sdefault.adb + $(ECHO) " end Target_Name;" >>tmp-sdefault.adb + $(ECHO) " function Search_Dir_Prefix return String_Ptr is" >>tmp-sdefault.adb + $(ECHO) " begin" >>tmp-sdefault.adb + $(ECHO) " return new String'(S4);" >>tmp-sdefault.adb + $(ECHO) " end Search_Dir_Prefix;" >>tmp-sdefault.adb + $(ECHO) "end Sdefault;" >> tmp-sdefault.adb + $(srcdir)/move-if-change tmp-sdefault.adb ada/sdefault.adb + touch ada/stamp-sdefault + + ada/sdefault.o : ada/sdefault.ads ada/sdefault.adb ada/types.ads \ + ada/unchdeal.ads ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/unchconv.ads + + ADA_TREE_H = ada/ada-tree.h ada/ada-tree.def + + # force debugging information on a-except.o so that it is always + # possible to set conditional breakpoints on exceptions. + # use -O1 otherwise gdb isn't able to get a full backtrace on mips targets. + + ada/a-except.o : ada/a-except.adb ada/a-except.ads + $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O1 -fno-inline \ + $(ADA_INCLUDES) $< $(OUTPUT_OPTION) + + # force debugging information on s-assert.o so that it is always + # possible to set breakpoint on assert failures. + + ada/s-assert.o : ada/s-assert.adb ada/s-assert.ads ada/a-except.ads + $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O2 \ + $(ADA_INCLUDES) $< $(OUTPUT_OPTION) + + # force debugging information and no optimization on s-memory.o so that it + # is always possible to set breakpoint on __gnat_malloc and __gnat_free + # this is important for gnatmem using GDB. memtrack.o is built from + # memtrack.adb, and used by the post-mortem analysis with gnatmem. + + ada/s-memory.o : ada/s-memory.adb ada/s-memory.ads ada/memtrack.o + $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 \ + $(ADA_INCLUDES) $< $(OUTPUT_OPTION) + + ada/memtrack.o : ada/memtrack.adb ada/s-memory.ads + $(ADAC) -c $(ALL_ADAFLAGS) $(FORCE_DEBUG_ADAFLAGS) -O0 \ + $(ADA_INCLUDES) $< $(OUTPUT_OPTION) + + ada/adadecode.o : ada/adadecode.c ada/adadecode.h $(CONFIG_H) $(SYSTEM_H) \ + ada/adadecode.h + ada/adaint.o : ada/adaint.c $(CONFIG_H) $(SYSTEM_H) ada/adaint.h + ada/argv.o : ada/argv.c $(CONFIG_H) $(SYSTEM_H) ada/adaint.h + ada/cstreams.o : ada/cstreams.c $(CONFIG_H) $(SYSTEM_H) ada/adaint.h + ada/exit.o : ada/exit.c $(CONFIG_H) $(SYSTEM_H) ada/adaint.h + ada/adafinal.o : ada/adafinal.c $(CONFIG_H) $(SYSTEM_H) ada/raise.h + ada/link.o : ada/link.c + + ada/cio.o : ada/cio.c $(CONFIG_H) $(SYSTEM_H) ada/adaint.h + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \ + $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + + ada/init.o : ada/init.c $(CONFIG_H) $(SYSTEM_H) ada/adaint.h ada/raise.h + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \ + $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + + ada/raise.o : ada/raise.c $(CONFIG_H) $(SYSTEM_H) ada/adaint.h ada/raise.h + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(RT_FLAGS) \ + $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) + + # Need to keep the frame pointer in this file to pop the stack properly on + # some targets. + ada/tracebak.o : ada/tracebak.c $(CONFIG_H) $(SYSTEM_H) + $(CC) -c $(ALL_CFLAGS) $(ALL_ADA_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + -fno-omit-frame-pointer $< $(OUTPUT_OPTION) + + ada/cuintp.o : ada/cuintp.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) ada/ada.h \ + ada/types.h ada/uintp.h ada/atree.h ada/stringt.h ada/elists.h \ + ada/nlists.h ada/fe.h ada/gigi.h + + ada/decl.o : ada/decl.c $(CONFIG_H) $(TREE_H) $(srcdir)/flags.h \ + $(srcdir)/toplev.h $(srcdir)/convert.h ada/ada.h ada/types.h ada/atree.h \ + ada/nlists.h ada/elists.h ada/uintp.h ada/sinfo.h ada/einfo.h ada/snames.h \ + ada/namet.h ada/stringt.h ada/repinfo.h ada/fe.h $(ADA_TREE_H) ada/gigi.h \ + gt-ada-decl.h + + ada/misc.o : ada/misc.c $(CONFIG_H) $(TREE_H) $(RTL_H) $(srcdir)/expr.h \ + insn-codes.h insn-flags.h insn-config.h $(srcdir)/recog.h \ + $(srcdir)/flags.h $(srcdir)/diagnostic.h $(srcdir)/output.h \ + $(srcdir)/except.h tm_p.h $(srcdir)/langhooks.h $(srcdir)/debug.h \ + $(srcdir)/langhooks-def.h $(srcdir)/libfuncs.h $(srcdir)/optabs.h \ + ada/ada.h ada/types.h ada/atree.h ada/nlists.h ada/elists.h ada/sinfo.h \ + ada/einfo.h ada/namet.h ada/stringt.h ada/uintp.h ada/fe.h $(ADA_TREE_H) \ + ada/gigi.h ada/adadecode.h + + ada/targtyps.o : ada/targtyps.c $(CONFIG_H) ada/ada.h ada/types.h ada/atree.h \ + ada/nlists.h ada/elists.h ada/uintp.h ada/sinfo.h ada/einfo.h ada/namet.h \ + ada/snames.h ada/stringt.h ada/urealp.h ada/fe.h $(ADA_TREE_H) ada/gigi.h + + ada/trans.o : ada/trans.c $(CONFIG_H) $(TREE_H) $(RTL_H) $(srcdir)/flags.h \ + ada/ada.h $(srcdir)/except.h ada/types.h ada/atree.h ada/nlists.h \ + ada/elists.h ada/uintp.h ada/sinfo.h ada/einfo.h ada/namet.h ada/snames.h \ + ada/stringt.h ada/urealp.h ada/fe.h $(ADA_TREE_H) ada/gigi.h gt-ada-trans.h + + ada/utils.o : ada/utils.c $(CONFIG_H) $(TREE_H) $(srcdir)/flags.h \ + $(srcdir)/expr.h $(srcdir)/convert.h $(srcdir)/defaults.h ada/ada.h \ + ada/types.h ada/atree.h ada/nlists.h ada/elists.h ada/sinfo.h ada/einfo.h \ + ada/namet.h ada/stringt.h ada/uintp.h ada/fe.h $(ADA_TREE_H) ada/gigi.h \ + gt-ada-utils.h gtype-ada.h + + ada/utils2.o : ada/utils2.c $(CONFIG_H) $(TREE_H) $(srcdir)/flags.h ada/ada.h \ + ada/types.h ada/atree.h ada/nlists.h ada/elists.h ada/sinfo.h ada/einfo.h \ + ada/namet.h ada/snames.h ada/stringt.h ada/uintp.h ada/fe.h $(ADA_TREE_H) \ + ada/gigi.h + + # + # DO NOT PUT SPECIAL RULES BELOW, THIS SECTION IS UPDATED AUTOMATICALLY + # + # GNAT DEPENDENCIES + # regular dependencies + ada/a-charac.o : ada/ada.ads ada/a-charac.ads ada/system.ads + + ada/a-chlat1.o : ada/ada.ads ada/a-charac.ads ada/a-chlat1.ads \ + ada/system.ads + + ada/a-except.o : ada/ada.ads ada/a-except.ads ada/a-except.adb \ + ada/a-excpol.adb ada/a-uncdea.ads ada/gnat.ads ada/g-hesora.ads \ + ada/system.ads ada/s-exctab.ads ada/s-except.ads ada/s-mastop.ads \ + ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-stoele.adb ada/s-traceb.ads ada/unchconv.ads + + ada/a-stream.o : ada/ada.ads ada/a-except.ads ada/a-stream.ads \ + ada/a-tags.ads ada/a-tags.adb ada/gnat.ads ada/g-htable.ads ada/system.ads \ + ada/s-exctab.ads ada/s-secsta.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/unchconv.ads + + ada/a-tags.o : ada/ada.ads ada/a-except.ads ada/a-tags.ads ada/a-tags.adb \ + ada/a-uncdea.ads ada/gnat.ads ada/g-htable.ads ada/g-htable.adb \ + ada/system.ads ada/s-exctab.ads ada/s-secsta.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/unchconv.ads + + ada/ada.o : ada/ada.ads ada/system.ads + + ada/ali-util.o : ada/ada.ads ada/a-except.ads ada/ali.ads ada/ali-util.ads \ + ada/ali-util.adb ada/alloc.ads ada/binderr.ads ada/casing.ads ada/debug.ads \ + ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads ada/gnatvsn.ads \ + ada/hostparm.ads ada/interfac.ads ada/namet.ads ada/opt.ads ada/osint.ads \ + ada/output.ads ada/rident.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-crc32.ads ada/s-exctab.ads \ + ada/s-memory.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/tree_io.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/ali.o : ada/ada.ads ada/a-except.ads ada/a-uncdea.ads ada/ali.ads \ + ada/ali.adb ada/alloc.ads ada/butil.ads ada/casing.ads ada/debug.ads \ + ada/fname.ads ada/gnat.ads ada/g-htable.ads ada/g-htable.adb \ + ada/g-os_lib.ads ada/gnatvsn.ads ada/hostparm.ads ada/namet.ads ada/opt.ads \ + ada/osint.ads ada/output.ads ada/rident.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads + + ada/alloc.o : ada/alloc.ads ada/system.ads + + ada/atree.o : ada/ada.ads ada/a-except.ads ada/a-uncdea.ads ada/alloc.ads \ + ada/atree.ads ada/atree.adb ada/casing.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/gnat.ads ada/g-htable.ads ada/g-htable.adb \ + ada/g-os_lib.ads ada/hostparm.ads ada/nlists.ads ada/opt.ads ada/output.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads ada/s-imgenu.ads \ + ada/s-memory.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/back_end.o : ada/alloc.ads ada/atree.ads ada/back_end.ads \ + ada/back_end.adb ada/casing.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/lib.ads ada/namet.ads \ + ada/nlists.ads ada/opt.ads ada/osint.ads ada/osint-c.ads ada/sinfo.ads \ + ada/sinput.ads ada/snames.ads ada/stand.ads ada/stringt.ads ada/switch.ads \ + ada/switch-c.ads ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/bcheck.o : ada/ada.ads ada/a-except.ads ada/ali.ads ada/ali-util.ads \ + ada/alloc.ads ada/bcheck.ads ada/bcheck.adb ada/binderr.ads ada/butil.ads \ + ada/casing.ads ada/fname.ads ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads \ + ada/gnatvsn.ads ada/hostparm.ads ada/namet.ads ada/opt.ads ada/osint.ads \ + ada/output.ads ada/rident.ads ada/system.ads ada/s-exctab.ads \ + ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/binde.o : ada/ada.ads ada/a-except.ads ada/ali.ads ada/alloc.ads \ + ada/binde.ads ada/binde.adb ada/binderr.ads ada/butil.ads ada/casing.ads \ + ada/debug.ads ada/fname.ads ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads \ + ada/gnatvsn.ads ada/hostparm.ads ada/namet.ads ada/opt.ads ada/output.ads \ + ada/rident.ads ada/system.ads ada/s-atacco.ads ada/s-atacco.adb \ + ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads + + ada/binderr.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/binderr.ads \ + ada/binderr.adb ada/butil.ads ada/hostparm.ads ada/namet.ads ada/opt.ads \ + ada/output.ads ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/bindgen.o : ada/ada.ads ada/a-except.ads ada/ali.ads ada/alloc.ads \ + ada/binde.ads ada/bindgen.ads ada/bindgen.adb ada/butil.ads ada/casing.ads \ + ada/fname.ads ada/gnat.ads ada/g-hesora.ads ada/g-htable.ads \ + ada/g-os_lib.ads ada/gnatvsn.ads ada/hostparm.ads ada/namet.ads ada/opt.ads \ + ada/osint.ads ada/osint-b.ads ada/output.ads ada/rident.ads \ + ada/sdefault.ads ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-strops.ads ada/s-sopco3.ads ada/s-sopco4.ads \ + ada/s-sopco5.ads ada/s-wchcon.ads ada/table.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads + + ada/bindusg.o : ada/bindusg.ads ada/bindusg.adb ada/gnat.ads \ + ada/g-os_lib.ads ada/osint.ads ada/output.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/butil.o : ada/alloc.ads ada/butil.ads ada/butil.adb ada/hostparm.ads \ + ada/namet.ads ada/output.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/table.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/casing.o : ada/alloc.ads ada/casing.ads ada/casing.adb ada/csets.ads \ + ada/hostparm.ads ada/namet.ads ada/opt.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/widechar.ads + + ada/checks.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/checks.ads ada/checks.adb ada/debug.ads \ + ada/einfo.ads ada/elists.ads ada/errout.ads ada/exp_ch2.ads \ + ada/exp_util.ads ada/freeze.ads ada/get_targ.ads ada/gnat.ads \ + ada/g-htable.ads ada/g-os_lib.ads ada/hostparm.ads ada/namet.ads \ + ada/nlists.ads ada/nmake.ads ada/opt.ads ada/output.ads ada/restrict.ads \ + ada/rident.ads ada/rtsfind.ads ada/sem.ads ada/sem_eval.ads ada/sem_res.ads \ + ada/sem_util.ads ada/sem_warn.ads ada/sinfo.ads ada/sinput.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/targparm.ads ada/tbuild.ads ada/tree_io.ads \ + ada/ttypes.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads ada/validsw.ads + + ada/comperr.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/comperr.ads ada/comperr.adb ada/debug.ads ada/einfo.ads \ + ada/errout.ads ada/fname.ads ada/gnat.ads ada/g-os_lib.ads ada/gnatvsn.ads \ + ada/lib.ads ada/namet.ads ada/osint.ads ada/output.ads ada/sdefault.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/sprint.ads ada/system.ads \ + ada/s-exctab.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/table.ads ada/treepr.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/csets.o : ada/csets.ads ada/csets.adb ada/hostparm.ads ada/opt.ads \ + ada/system.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/cstand.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/csets.ads ada/cstand.ads ada/cstand.adb ada/debug.ads ada/einfo.ads \ + ada/get_targ.ads ada/hostparm.ads ada/layout.ads ada/namet.ads \ + ada/nlists.ads ada/nmake.ads ada/opt.ads ada/sem_mech.ads ada/sem_util.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/ttypef.ads ada/ttypes.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/debug.o : ada/debug.ads ada/debug.adb ada/system.ads + + ada/debug_a.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/debug.ads ada/debug_a.ads ada/debug_a.adb ada/einfo.ads \ + ada/output.ads ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/system.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/table.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/einfo.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/einfo.ads ada/einfo.adb ada/namet.ads ada/nlists.ads ada/output.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/table.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/elists.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/debug.ads \ + ada/elists.ads ada/elists.adb ada/gnat.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/opt.ads ada/output.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/tree_io.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/errout.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/csets.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/errout.adb ada/fname.ads ada/gnat.ads \ + ada/g-htable.ads ada/g-os_lib.ads ada/hostparm.ads ada/lib.ads \ + ada/namet.ads ada/nlists.ads ada/opt.ads ada/output.ads ada/scans.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads ada/style.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-memory.ads ada/s-secsta.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads \ + ada/uintp.ads ada/uname.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/eval_fat.o : ada/alloc.ads ada/einfo.ads ada/eval_fat.ads \ + ada/eval_fat.adb ada/sem_util.ads ada/snames.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/table.ads \ + ada/targparm.ads ada/ttypef.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/exp_aggr.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/checks.ads ada/debug.ads ada/einfo.ads ada/elists.ads ada/exp_aggr.ads \ + ada/exp_aggr.adb ada/exp_ch3.ads ada/exp_ch7.ads ada/exp_util.ads \ + ada/expander.ads ada/freeze.ads ada/get_targ.ads ada/hostparm.ads \ + ada/itypes.ads ada/lib.ads ada/namet.ads ada/nlists.ads ada/nmake.ads \ + ada/opt.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_ch3.ads ada/sem_eval.ads ada/sem_res.ads ada/sem_util.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads ada/tbuild.ads \ + ada/ttypes.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/exp_attr.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/exp_attr.ads ada/exp_attr.adb ada/exp_ch2.ads ada/exp_ch9.ads \ + ada/exp_imgv.ads ada/exp_pakd.ads ada/exp_strm.ads ada/exp_tss.ads \ + ada/exp_util.ads ada/get_targ.ads ada/gnatvsn.ads ada/hostparm.ads \ + ada/lib.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads ada/sem_ch7.ads \ + ada/sem_ch8.ads ada/sem_eval.ads ada/sem_res.ads ada/sem_util.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/stringt.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/ttypes.ads ada/types.ads ada/uintp.ads \ + ada/uname.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads \ + ada/validsw.ads + + ada/exp_ch11.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/errout.ads ada/exp_ch11.ads ada/exp_ch11.adb ada/exp_ch7.ads \ + ada/exp_util.ads ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/inline.ads ada/lib.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/output.ads ada/restrict.ads ada/rident.ads \ + ada/rtsfind.ads ada/sem.ads ada/sem_ch5.ads ada/sem_ch8.ads ada/sem_res.ads \ + ada/sem_util.ads ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads \ + ada/stringt.ads ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/tbuild.ads ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/uname.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/exp_ch12.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/exp_ch12.ads ada/exp_ch12.adb ada/exp_util.ads ada/namet.ads \ + ada/nlists.ads ada/nmake.ads ada/rtsfind.ads ada/sinfo.ads ada/snames.ads \ + ada/stand.ads ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/exp_ch13.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/elists.ads ada/exp_ch13.ads ada/exp_ch13.adb ada/exp_ch3.ads \ + ada/exp_ch6.ads ada/exp_imgv.ads ada/exp_util.ads ada/hostparm.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_eval.ads \ + ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/system.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/exp_ch2.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/elists.ads \ + ada/errout.ads ada/exp_ch2.ads ada/exp_ch2.adb ada/exp_smem.ads \ + ada/exp_util.ads ada/exp_vfpt.ads ada/hostparm.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/rtsfind.ads ada/sem.ads ada/sem_res.ads \ + ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/exp_ch3.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_aggr.ads ada/exp_ch11.ads \ + ada/exp_ch3.ads ada/exp_ch3.adb ada/exp_ch4.ads ada/exp_ch7.ads \ + ada/exp_ch9.ads ada/exp_disp.ads ada/exp_dist.ads ada/exp_smem.ads \ + ada/exp_strm.ads ada/exp_tss.ads ada/exp_util.ads ada/freeze.ads \ + ada/get_targ.ads ada/hostparm.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_ch3.ads ada/sem_ch8.ads ada/sem_eval.ads \ + ada/sem_mech.ads ada/sem_res.ads ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/tbuild.ads ada/ttypes.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads ada/validsw.ads + + ada/exp_ch4.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_aggr.ads ada/exp_ch3.ads \ + ada/exp_ch4.ads ada/exp_ch4.adb ada/exp_ch7.ads ada/exp_ch9.ads \ + ada/exp_disp.ads ada/exp_fixd.ads ada/exp_pakd.ads ada/exp_tss.ads \ + ada/exp_util.ads ada/exp_vfpt.ads ada/get_targ.ads ada/hostparm.ads \ + ada/inline.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads ada/sem_cat.ads \ + ada/sem_ch13.ads ada/sem_eval.ads ada/sem_res.ads ada/sem_type.ads \ + ada/sem_util.ads ada/sem_warn.ads ada/sinfo.ads ada/sinfo-cn.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/tbuild.ads ada/ttypes.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/validsw.ads + + ada/exp_ch5.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/exp_aggr.ads ada/exp_ch11.ads ada/exp_ch5.ads ada/exp_ch5.adb \ + ada/exp_ch7.ads ada/exp_dbug.ads ada/exp_pakd.ads ada/exp_util.ads \ + ada/get_targ.ads ada/hostparm.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_ch13.ads ada/sem_ch8.ads ada/sem_eval.ads \ + ada/sem_res.ads ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads \ + ada/system.ads ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/tbuild.ads ada/ttypes.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads \ + ada/validsw.ads + + ada/exp_ch6.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/checks.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_ch11.ads ada/exp_ch2.ads \ + ada/exp_ch3.ads ada/exp_ch6.ads ada/exp_ch6.adb ada/exp_ch7.ads \ + ada/exp_ch9.ads ada/exp_dbug.ads ada/exp_disp.ads ada/exp_dist.ads \ + ada/exp_intr.ads ada/exp_pakd.ads ada/exp_tss.ads ada/exp_util.ads \ + ada/freeze.ads ada/get_targ.ads ada/gnat.ads ada/g-htable.ads \ + ada/g-os_lib.ads ada/hostparm.ads ada/inline.ads ada/lib.ads ada/namet.ads \ + ada/nlists.ads ada/nmake.ads ada/opt.ads ada/output.ads ada/restrict.ads \ + ada/rident.ads ada/rtsfind.ads ada/sem.ads ada/sem_ch12.ads \ + ada/sem_ch13.ads ada/sem_ch6.ads ada/sem_ch8.ads ada/sem_disp.ads \ + ada/sem_dist.ads ada/sem_res.ads ada/sem_util.ads ada/sinfo.ads \ + ada/sinput.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/validsw.ads + + ada/exp_ch7.o : ada/alloc.ads ada/atree.ads ada/debug.ads ada/einfo.ads \ + ada/exp_ch11.ads ada/exp_ch7.ads ada/exp_ch7.adb ada/exp_ch9.ads \ + ada/exp_dbug.ads ada/exp_tss.ads ada/exp_util.ads ada/freeze.ads \ + ada/get_targ.ads ada/hostparm.ads ada/lib.ads ada/lib-xref.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads ada/output.ads \ + ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads ada/sem_ch3.ads \ + ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_res.ads ada/sem_type.ads \ + ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/targparm.ads ada/tbuild.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/exp_ch8.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/exp_ch8.ads \ + ada/exp_ch8.adb ada/exp_dbug.ads ada/exp_util.ads ada/get_targ.ads \ + ada/hostparm.ads ada/namet.ads ada/nlists.ads ada/opt.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_ch8.ads ada/sinfo.ads ada/snames.ads ada/stand.ads \ + ada/system.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/exp_ch9.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/checks.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_ch11.ads ada/exp_ch3.ads \ + ada/exp_ch6.ads ada/exp_ch9.ads ada/exp_ch9.adb ada/exp_dbug.ads \ + ada/exp_smem.ads ada/exp_tss.ads ada/exp_util.ads ada/freeze.ads \ + ada/get_targ.ads ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/output.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_ch11.ads ada/sem_ch6.ads ada/sem_ch8.ads ada/sem_elab.ads \ + ada/sem_res.ads ada/sem_util.ads ada/sinfo.ads ada/sinput.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/exp_code.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/errout.ads \ + ada/exp_code.ads ada/exp_code.adb ada/fname.ads ada/hostparm.ads \ + ada/lib.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/rtsfind.ads ada/sem_eval.ads ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stringt.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/exp_dbug.o : ada/ada.ads ada/a-except.ads ada/a-uncdea.ads \ + ada/alloc.ads ada/atree.ads ada/debug.ads ada/einfo.ads ada/exp_dbug.ads \ + ada/exp_dbug.adb ada/exp_util.ads ada/freeze.ads ada/get_targ.ads \ + ada/gnat.ads ada/g-htable.ads ada/g-htable.adb ada/g-os_lib.ads \ + ada/hostparm.ads ada/lib.ads ada/namet.ads ada/nlists.ads ada/nmake.ads \ + ada/opt.ads ada/output.ads ada/rtsfind.ads ada/sem_eval.ads \ + ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-memory.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/exp_disp.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_ch7.ads ada/exp_disp.ads \ + ada/exp_disp.adb ada/exp_tss.ads ada/exp_util.ads ada/fname.ads \ + ada/hostparm.ads ada/itypes.ads ada/lib.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/rtsfind.ads ada/sem_disp.ads ada/sem_res.ads \ + ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/exp_dist.o : ada/ada.ads ada/a-uncdea.ads ada/alloc.ads ada/atree.ads \ + ada/einfo.ads ada/elists.ads ada/exp_dist.ads ada/exp_dist.adb \ + ada/exp_tss.ads ada/exp_util.ads ada/gnat.ads ada/g-htable.ads \ + ada/g-htable.adb ada/hostparm.ads ada/lib.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/rtsfind.ads ada/sem.ads ada/sem_ch3.ads \ + ada/sem_ch8.ads ada/sem_dist.ads ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/stringt.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads ada/uname.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/exp_fixd.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/exp_fixd.ads ada/exp_fixd.adb ada/exp_util.ads ada/get_targ.ads \ + ada/hostparm.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_eval.ads ada/sem_res.ads ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/tbuild.ads ada/ttypes.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/exp_imgv.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/checks.ads \ + ada/einfo.ads ada/exp_imgv.ads ada/exp_imgv.adb ada/exp_util.ads \ + ada/get_targ.ads ada/hostparm.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/rtsfind.ads ada/sem_res.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/stringt.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/ttypes.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/exp_intr.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/einfo.ads \ + ada/errout.ads ada/exp_ch11.ads ada/exp_ch4.ads ada/exp_ch7.ads \ + ada/exp_ch9.ads ada/exp_code.ads ada/exp_fixd.ads ada/exp_intr.ads \ + ada/exp_intr.adb ada/exp_util.ads ada/hostparm.ads ada/itypes.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads ada/restrict.ads \ + ada/rident.ads ada/rtsfind.ads ada/sem.ads ada/sem_eval.ads ada/sem_res.ads \ + ada/sem_util.ads ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads \ + ada/stringt.ads ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/tbuild.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/exp_pakd.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/exp_dbug.ads ada/exp_pakd.ads ada/exp_pakd.adb ada/exp_util.ads \ + ada/get_targ.ads ada/hostparm.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/rtsfind.ads ada/sem.ads ada/sem_ch13.ads \ + ada/sem_ch8.ads ada/sem_eval.ads ada/sem_res.ads ada/sem_util.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/tbuild.ads ada/ttypes.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/exp_prag.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/einfo.ads \ + ada/errout.ads ada/exp_ch11.ads ada/exp_prag.ads ada/exp_prag.adb \ + ada/exp_tss.ads ada/exp_util.ads ada/expander.ads ada/hostparm.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_eval.ads ada/sem_res.ads ada/sem_util.ads ada/sinfo.ads \ + ada/sinput.ads ada/snames.ads ada/stand.ads ada/stringt.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/exp_smem.o : ada/alloc.ads ada/atree.ads ada/einfo.ads \ + ada/exp_smem.ads ada/exp_smem.adb ada/exp_util.ads ada/hostparm.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads \ + ada/stringt.ads ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/exp_strm.o : ada/alloc.ads ada/atree.ads ada/einfo.ads \ + ada/exp_strm.ads ada/exp_strm.adb ada/exp_tss.ads ada/get_targ.ads \ + ada/lib.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/rtsfind.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/table.ads ada/tbuild.ads \ + ada/ttypes.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/exp_tss.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/elists.ads \ + ada/exp_tss.ads ada/exp_tss.adb ada/exp_util.ads ada/lib.ads \ + ada/rtsfind.ads ada/sem_util.ads ada/sinfo.ads ada/snames.ads \ + ada/system.ads ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/table.ads ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/exp_util.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_ch11.ads ada/exp_ch7.ads \ + ada/exp_util.ads ada/exp_util.adb ada/get_targ.ads ada/hostparm.ads \ + ada/inline.ads ada/itypes.ads ada/lib.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_ch8.ads ada/sem_eval.ads ada/sem_res.ads \ + ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/system.ads ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/targparm.ads ada/tbuild.ads \ + ada/ttypes.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads ada/validsw.ads + + ada/exp_vfpt.o : ada/alloc.ads ada/atree.ads ada/einfo.ads \ + ada/exp_vfpt.ads ada/exp_vfpt.adb ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/rtsfind.ads ada/sem_res.ads ada/sinfo.ads ada/snames.ads \ + ada/stand.ads ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/table.ads ada/tbuild.ads ada/ttypef.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/expander.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/debug.ads ada/debug_a.ads ada/einfo.ads ada/elists.ads ada/errout.ads \ + ada/exp_aggr.ads ada/exp_attr.ads ada/exp_ch11.ads ada/exp_ch12.ads \ + ada/exp_ch13.ads ada/exp_ch2.ads ada/exp_ch3.ads ada/exp_ch4.ads \ + ada/exp_ch5.ads ada/exp_ch6.ads ada/exp_ch7.ads ada/exp_ch8.ads \ + ada/exp_ch9.ads ada/exp_prag.ads ada/expander.ads ada/expander.adb \ + ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/opt.ads ada/output.ads \ + ada/sem.ads ada/sem_ch8.ads ada/sem_util.ads ada/sinfo.ads ada/snames.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/fmap.o : ada/ada.ads ada/a-except.ads ada/a-uncdea.ads ada/alloc.ads \ + ada/debug.ads ada/fmap.ads ada/fmap.adb ada/gnat.ads ada/g-htable.ads \ + ada/g-htable.adb ada/g-os_lib.ads ada/hostparm.ads ada/namet.ads \ + ada/opt.ads ada/osint.ads ada/output.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads \ + ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/tree_io.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/fname-uf.o : ada/ada.ads ada/a-except.ads ada/a-uncdea.ads \ + ada/alloc.ads ada/casing.ads ada/debug.ads ada/fmap.ads ada/fname.ads \ + ada/fname-uf.ads ada/fname-uf.adb ada/gnat.ads ada/g-htable.ads \ + ada/g-htable.adb ada/g-os_lib.ads ada/hostparm.ads ada/krunch.ads \ + ada/namet.ads ada/opt.ads ada/osint.ads ada/output.ads ada/system.ads \ + ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads \ + ada/s-memory.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/widechar.ads + + ada/fname.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/debug.ads \ + ada/fname.ads ada/fname.adb ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads \ + ada/namet.ads ada/opt.ads ada/output.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/tree_io.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/freeze.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/errout.ads ada/exp_ch11.ads ada/exp_ch7.ads ada/exp_pakd.ads \ + ada/exp_util.ads ada/freeze.ads ada/freeze.adb ada/get_targ.ads \ + ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads ada/hostparm.ads \ + ada/layout.ads ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/output.ads ada/restrict.ads ada/rident.ads \ + ada/rtsfind.ads ada/sem.ads ada/sem_cat.ads ada/sem_ch13.ads \ + ada/sem_ch6.ads ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_eval.ads \ + ada/sem_mech.ads ada/sem_prag.ads ada/sem_res.ads ada/sem_util.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/s-wchcon.ads ada/table.ads ada/targparm.ads ada/tbuild.ads \ + ada/tree_io.ads ada/ttypes.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/frontend.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/checks.ads \ + ada/cstand.ads ada/debug.ads ada/einfo.ads ada/elists.ads ada/exp_ch11.ads \ + ada/exp_dbug.ads ada/fmap.ads ada/fname.ads ada/fname-uf.ads \ + ada/frontend.ads ada/frontend.adb ada/get_targ.ads ada/gnat.ads \ + ada/g-os_lib.ads ada/hostparm.ads ada/inline.ads ada/lib.ads \ + ada/lib-load.ads ada/live.ads ada/namet.ads ada/nlists.ads ada/opt.ads \ + ada/osint.ads ada/output.ads ada/par.ads ada/rtsfind.ads ada/scn.ads \ + ada/sem.ads ada/sem_ch8.ads ada/sem_elab.ads ada/sem_prag.ads \ + ada/sem_warn.ads ada/sinfo.ads ada/sinput.ads ada/sinput-l.ads \ + ada/snames.ads ada/sprint.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/g-hesora.o : ada/gnat.ads ada/g-hesora.ads ada/g-hesora.adb \ + ada/system.ads + + ada/g-htable.o : ada/ada.ads ada/a-uncdea.ads ada/gnat.ads \ + ada/g-htable.ads ada/g-htable.adb ada/system.ads + + ada/g-os_lib.o : ada/ada.ads ada/a-except.ads ada/gnat.ads \ + ada/g-os_lib.ads ada/g-os_lib.adb ada/system.ads ada/s-secsta.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/unchconv.ads ada/unchdeal.ads + + ada/g-speche.o : ada/gnat.ads ada/g-speche.ads ada/g-speche.adb \ + ada/system.ads + + ada/get_targ.o : ada/get_targ.ads ada/get_targ.adb ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/gnat.o : ada/gnat.ads ada/system.ads + + ada/gnat1drv.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/back_end.ads ada/casing.ads ada/comperr.ads ada/csets.ads ada/debug.ads \ + ada/einfo.ads ada/elists.ads ada/errout.ads ada/fname.ads ada/fname-uf.ads \ + ada/frontend.ads ada/get_targ.ads ada/gnat.ads ada/g-os_lib.ads \ + ada/gnat1drv.ads ada/gnat1drv.adb ada/gnatvsn.ads ada/hostparm.ads \ + ada/inline.ads ada/lib.ads ada/lib-writ.ads ada/namet.ads ada/nlists.ads \ + ada/opt.ads ada/osint.ads ada/output.ads ada/repinfo.ads ada/restrict.ads \ + ada/rident.ads ada/sem.ads ada/sem_ch13.ads ada/sinfo.ads ada/sinput.ads \ + ada/sinput-l.ads ada/snames.ads ada/sprint.ads ada/stringt.ads \ + ada/system.ads ada/s-assert.ads ada/s-exctab.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/targparm.ads ada/tree_gen.ads ada/treepr.ads \ + ada/ttypes.ads ada/types.ads ada/uintp.ads ada/uname.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads ada/usage.ads + + ada/gnatbind.o : ada/ada.ads ada/a-except.ads ada/ali.ads ada/ali-util.ads \ + ada/alloc.ads ada/bcheck.ads ada/binde.ads ada/binderr.ads ada/bindgen.ads \ + ada/bindusg.ads ada/butil.ads ada/casing.ads ada/csets.ads ada/gnat.ads \ + ada/g-htable.ads ada/g-os_lib.ads ada/gnatbind.ads ada/gnatbind.adb \ + ada/gnatvsn.ads ada/hostparm.ads ada/namet.ads ada/opt.ads ada/osint.ads \ + ada/osint-b.ads ada/output.ads ada/rident.ads ada/switch.ads \ + ada/switch-b.ads ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-strops.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/gnatvsn.o : ada/gnatvsn.ads ada/system.ads + + ada/hlo.o : ada/hlo.ads ada/hlo.adb ada/output.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/hostparm.o : ada/hostparm.ads ada/system.ads + + ada/impunit.o : ada/alloc.ads ada/hostparm.ads ada/impunit.ads \ + ada/impunit.adb ada/lib.ads ada/namet.ads ada/opt.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/inline.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/debug.ads ada/einfo.ads ada/elists.ads ada/errout.ads \ + ada/exp_ch11.ads ada/exp_ch7.ads ada/exp_tss.ads ada/fname.ads \ + ada/fname-uf.ads ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads \ + ada/inline.ads ada/inline.adb ada/lib.ads ada/namet.ads ada/nlists.ads \ + ada/opt.ads ada/output.ads ada/sem_ch10.ads ada/sem_ch12.ads \ + ada/sem_ch8.ads ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/uname.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/interfac.o : ada/interfac.ads ada/system.ads + + ada/itypes.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/itypes.ads \ + ada/itypes.adb ada/namet.ads ada/sem_util.ads ada/sinfo.ads ada/snames.ads \ + ada/stand.ads ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/table.ads ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/krunch.o : ada/hostparm.ads ada/krunch.ads ada/krunch.adb \ + ada/system.ads ada/s-stoele.ads + + ada/layout.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/checks.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_ch3.ads ada/exp_util.ads \ + ada/get_targ.ads ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/layout.ads ada/layout.adb ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/output.ads ada/repinfo.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_ch13.ads ada/sem_eval.ads ada/sem_util.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/s-wchcon.ads ada/table.ads ada/targparm.ads ada/tbuild.ads \ + ada/tree_io.ads ada/ttypes.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/lib-load.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/debug.ads \ + ada/einfo.ads ada/errout.ads ada/fname.ads ada/fname-uf.ads ada/gnat.ads \ + ada/g-os_lib.ads ada/hostparm.ads ada/lib.ads ada/lib-load.ads \ + ada/lib-load.adb ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/osint.ads ada/osint-c.ads ada/output.ads ada/par.ads ada/scn.ads \ + ada/sinfo.ads ada/sinput.ads ada/sinput-l.ads ada/snames.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/tbuild.ads ada/types.ads ada/uintp.ads ada/uname.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/lib-util.o : ada/alloc.ads ada/gnat.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/lib.ads ada/lib-util.ads ada/lib-util.adb \ + ada/namet.ads ada/osint.ads ada/osint-c.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/table.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads + + ada/lib-writ.o : ada/ali.ads ada/alloc.ads ada/atree.ads ada/casing.ads \ + ada/einfo.ads ada/errout.ads ada/fname.ads ada/fname-uf.ads ada/gnat.ads \ + ada/g-htable.ads ada/g-os_lib.ads ada/gnatvsn.ads ada/hostparm.ads \ + ada/lib.ads ada/lib-util.ads ada/lib-writ.ads ada/lib-writ.adb \ + ada/lib-xref.ads ada/namet.ads ada/nlists.ads ada/opt.ads ada/osint.ads \ + ada/osint-c.ads ada/par.ads ada/restrict.ads ada/rident.ads ada/scn.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stringt.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/types.ads ada/uintp.ads ada/uname.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/lib-xref.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/csets.ads ada/debug.ads ada/einfo.ads ada/errout.ads \ + ada/gnat.ads ada/g-hesora.ads ada/g-os_lib.ads ada/hostparm.ads ada/lib.ads \ + ada/lib-util.ads ada/lib-xref.ads ada/lib-xref.adb ada/namet.ads \ + ada/opt.ads ada/output.ads ada/sinfo.ads ada/sinput.ads ada/snames.ads \ + ada/stand.ads ada/system.ads ada/s-atacco.ads ada/s-atacco.adb \ + ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads \ + ada/widechar.ads + + ada/lib.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/debug.ads ada/einfo.ads ada/fname.ads ada/gnat.ads \ + ada/g-hesora.ads ada/g-os_lib.ads ada/hostparm.ads ada/lib.ads ada/lib.adb \ + ada/lib-list.adb ada/lib-sort.adb ada/namet.ads ada/opt.ads ada/output.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/uname.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/live.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads ada/lib.ads ada/live.ads \ + ada/live.adb ada/nlists.ads ada/output.ads ada/sem_util.ads ada/sinfo.ads \ + ada/sinput.ads ada/snames.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-unstyp.ads \ + ada/table.ads ada/tree_io.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/memtrack.o : ada/ada.ads ada/a-except.ads ada/system.ads \ + ada/s-memory.ads ada/memtrack.adb ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-traceb.ads ada/unchconv.ads + + ada/namet.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/debug.ads \ + ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/namet.ads ada/namet.adb \ + ada/opt.ads ada/output.ads ada/system.ads ada/s-atacco.ads ada/s-atacco.adb \ + ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads ada/s-secsta.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/tree_io.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/widechar.ads + + ada/nlists.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/debug.ads ada/einfo.ads ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads \ + ada/nlists.ads ada/nlists.adb ada/opt.ads ada/output.ads ada/sinfo.ads \ + ada/snames.ads ada/system.ads ada/s-atacco.ads ada/s-atacco.adb \ + ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/nmake.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/namet.ads \ + ada/nlists.ads ada/nmake.ads ada/nmake.adb ada/sinfo.ads ada/snames.ads \ + ada/stand.ads ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/table.ads ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/opt.o : ada/ada.ads ada/a-except.ads ada/gnat.ads ada/g-os_lib.ads \ + ada/gnatvsn.ads ada/hostparm.ads ada/opt.ads ada/opt.adb ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/tree_io.ads \ + ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/osint-b.o : ada/alloc.ads ada/gnat.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/namet.ads ada/opt.ads ada/osint.ads ada/osint-b.ads \ + ada/osint-b.adb ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads + + ada/osint-c.o : ada/alloc.ads ada/gnat.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/namet.ads ada/opt.ads ada/osint.ads ada/osint-c.ads \ + ada/osint-c.adb ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/tree_io.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/osint.o : ada/ada.ads ada/a-except.ads ada/a-uncdea.ads ada/alloc.ads \ + ada/debug.ads ada/fmap.ads ada/gnat.ads ada/g-htable.ads ada/g-htable.adb \ + ada/g-os_lib.ads ada/hostparm.ads ada/namet.ads ada/opt.ads ada/osint.ads \ + ada/osint.adb ada/output.ads ada/sdefault.ads ada/system.ads \ + ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads \ + ada/s-memory.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/tree_io.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/output.o : ada/gnat.ads ada/g-os_lib.ads ada/output.ads ada/output.adb \ + ada/system.ads ada/s-exctab.ads ada/s-stalib.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads + + ada/par.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/csets.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/errout.ads ada/fname.ads ada/fname-uf.ads ada/gnat.ads ada/g-os_lib.ads \ + ada/g-speche.ads ada/hostparm.ads ada/lib.ads ada/lib-load.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads ada/osint.ads \ + ada/output.ads ada/par.ads ada/par.adb ada/par-ch10.adb ada/par-ch11.adb \ + ada/par-ch12.adb ada/par-ch13.adb ada/par-ch2.adb ada/par-ch3.adb \ + ada/par-ch4.adb ada/par-ch5.adb ada/par-ch6.adb ada/par-ch7.adb \ + ada/par-ch8.adb ada/par-ch9.adb ada/par-endh.adb ada/par-labl.adb \ + ada/par-load.adb ada/par-prag.adb ada/par-sync.adb ada/par-tchk.adb \ + ada/par-util.adb ada/scans.ads ada/scn.ads ada/sinfo.ads ada/sinfo-cn.ads \ + ada/sinput.ads ada/sinput-l.ads ada/snames.ads ada/stringt.ads \ + ada/style.ads ada/stylesw.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads ada/s-imgenu.ads \ + ada/s-memory.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads ada/uname.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/validsw.ads + + ada/repinfo.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/debug.ads ada/einfo.ads ada/gnat.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/lib.ads ada/namet.ads ada/opt.ads ada/output.ads \ + ada/repinfo.ads ada/repinfo.adb ada/sinfo.ads ada/sinput.ads ada/snames.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/uname.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/restrict.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/einfo.ads ada/errout.ads ada/exp_util.ads ada/fname.ads \ + ada/fname-uf.ads ada/hostparm.ads ada/lib.ads ada/namet.ads ada/opt.ads \ + ada/restrict.ads ada/restrict.adb ada/rident.ads ada/rtsfind.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-exctab.ads \ + ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/tbuild.ads ada/types.ads ada/uintp.ads ada/uname.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/rident.o : ada/rident.ads ada/system.ads + + ada/rtsfind.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/csets.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/fname.ads ada/fname-uf.ads ada/hostparm.ads ada/lib.ads \ + ada/lib-load.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/output.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/rtsfind.adb ada/sem.ads ada/sem_ch7.ads ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads ada/uname.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/s-assert.o : ada/ada.ads ada/a-except.ads ada/system.ads \ + ada/s-assert.ads ada/s-assert.adb ada/s-exctab.ads ada/s-stalib.ads \ + ada/unchconv.ads + + ada/s-crc32.o : ada/interfac.ads ada/system.ads ada/s-crc32.ads \ + ada/s-crc32.adb + + ada/s-except.o : ada/ada.ads ada/a-except.ads ada/system.ads \ + ada/s-except.ads ada/s-stalib.ads ada/unchconv.ads + + ada/s-exctab.o : ada/ada.ads ada/a-uncdea.ads ada/gnat.ads \ + ada/g-htable.ads ada/g-htable.adb ada/system.ads ada/s-exctab.ads \ + ada/s-exctab.adb ada/s-stalib.ads ada/unchconv.ads + + ada/s-imgenu.o : ada/system.ads ada/s-imgenu.ads ada/s-imgenu.adb \ + ada/s-secsta.ads ada/s-stoele.ads ada/unchconv.ads + + ada/s-mastop.o : ada/ada.ads ada/a-except.ads ada/system.ads \ + ada/s-except.ads ada/s-mastop.ads ada/s-mastop.adb ada/s-stalib.ads \ + ada/s-stoele.ads ada/unchconv.ads + + ada/s-memory.o : ada/ada.ads ada/a-except.ads ada/system.ads \ + ada/s-memory.ads ada/s-memory.adb ada/s-parame.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/unchconv.ads + + ada/s-parame.o : ada/system.ads ada/s-parame.ads ada/s-parame.adb + + ada/s-secsta.o : ada/ada.ads ada/a-except.ads ada/system.ads \ + ada/s-parame.ads ada/s-secsta.ads ada/s-secsta.adb ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/s-soflin.o : ada/ada.ads ada/a-except.ads ada/system.ads \ + ada/s-except.ads ada/s-mastop.ads ada/s-parame.ads ada/s-secsta.ads \ + ada/s-soflin.ads ada/s-soflin.adb ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/unchconv.ads + + ada/s-sopco3.o : ada/system.ads ada/s-secsta.ads ada/s-stoele.ads \ + ada/s-strops.ads ada/s-sopco3.ads ada/s-sopco3.adb + + ada/s-sopco4.o : ada/system.ads ada/s-secsta.ads ada/s-stoele.ads \ + ada/s-sopco3.ads ada/s-sopco4.ads ada/s-sopco4.adb + + ada/s-sopco5.o : ada/system.ads ada/s-secsta.ads ada/s-stoele.ads \ + ada/s-sopco4.ads ada/s-sopco5.ads ada/s-sopco5.adb + + ada/s-stache.o : ada/ada.ads ada/a-except.ads ada/system.ads \ + ada/s-parame.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stache.adb \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb ada/unchconv.ads + + ada/s-stalib.o : ada/ada.ads ada/a-except.ads ada/system.ads \ + ada/s-memory.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stalib.adb ada/s-stoele.ads ada/unchconv.ads + + ada/s-stoele.o : ada/system.ads ada/s-stoele.ads ada/s-stoele.adb \ + ada/unchconv.ads + + ada/s-strops.o : ada/system.ads ada/s-secsta.ads ada/s-stoele.ads \ + ada/s-strops.ads ada/s-strops.adb + + ada/s-traceb.o : ada/system.ads ada/s-traceb.ads ada/s-traceb.adb + + ada/s-unstyp.o : ada/system.ads ada/s-unstyp.ads + + ada/s-wchcnv.o : ada/interfac.ads ada/system.ads ada/s-wchcnv.ads \ + ada/s-wchcnv.adb ada/s-wchcon.ads ada/s-wchjis.ads + + ada/s-wchcon.o : ada/system.ads ada/s-wchcon.ads + + ada/s-wchjis.o : ada/system.ads ada/s-wchjis.ads ada/s-wchjis.adb + + ada/scans.o : ada/scans.ads ada/scans.adb ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/scn.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/csets.ads ada/einfo.ads ada/errout.ads ada/hostparm.ads \ + ada/interfac.ads ada/namet.ads ada/opt.ads ada/scans.ads ada/scn.ads \ + ada/scn.adb ada/scn-nlit.adb ada/scn-slit.adb ada/sinfo.ads ada/sinput.ads \ + ada/snames.ads ada/stringt.ads ada/style.ads ada/system.ads ada/s-crc32.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads ada/widechar.ads + + ada/sem.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/debug.ads ada/debug_a.ads ada/einfo.ads ada/errout.ads ada/expander.ads \ + ada/fname.ads ada/gnat.ads ada/g-os_lib.ads ada/hlo.ads ada/hostparm.ads \ + ada/inline.ads ada/lib.ads ada/lib-load.ads ada/namet.ads ada/nlists.ads \ + ada/opt.ads ada/output.ads ada/sem.ads ada/sem.adb ada/sem_attr.ads \ + ada/sem_ch10.ads ada/sem_ch11.ads ada/sem_ch12.ads ada/sem_ch13.ads \ + ada/sem_ch2.ads ada/sem_ch3.ads ada/sem_ch4.ads ada/sem_ch5.ads \ + ada/sem_ch6.ads ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_ch9.ads \ + ada/sem_prag.ads ada/sem_util.ads ada/sinfo.ads ada/snames.ads \ + ada/stand.ads ada/system.ads ada/s-atacco.ads ada/s-atacco.adb \ + ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_aggr.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_util.ads ada/freeze.ads ada/gnat.ads \ + ada/g-speche.ads ada/hostparm.ads ada/itypes.ads ada/namet.ads \ + ada/nlists.ads ada/nmake.ads ada/opt.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_aggr.ads ada/sem_aggr.adb ada/sem_cat.ads ada/sem_ch13.ads \ + ada/sem_ch8.ads ada/sem_eval.ads ada/sem_res.ads ada/sem_type.ads \ + ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/system.ads ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_attr.o : ada/ada.ads ada/a-charac.ads ada/a-chlat1.ads \ + ada/a-except.ads ada/alloc.ads ada/atree.ads ada/casing.ads ada/checks.ads \ + ada/einfo.ads ada/errout.ads ada/eval_fat.ads ada/exp_tss.ads \ + ada/exp_util.ads ada/expander.ads ada/freeze.ads ada/get_targ.ads \ + ada/hostparm.ads ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_attr.ads ada/sem_attr.adb ada/sem_cat.ads \ + ada/sem_ch6.ads ada/sem_ch8.ads ada/sem_dist.ads ada/sem_eval.ads \ + ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sinfo.ads \ + ada/sinput.ads ada/snames.ads ada/stand.ads ada/stringt.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/tbuild.ads ada/ttypef.ads ada/ttypes.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads \ + ada/widechar.ads + + ada/sem_case.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/errout.ads \ + ada/gnat.ads ada/g-hesora.ads ada/hostparm.ads ada/namet.ads ada/nlists.ads \ + ada/opt.ads ada/sem.ads ada/sem_case.ads ada/sem_case.adb ada/sem_eval.ads \ + ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/sem_cat.o : ada/alloc.ads ada/atree.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_tss.ads ada/fname.ads \ + ada/hostparm.ads ada/lib.ads ada/namet.ads ada/nlists.ads ada/opt.ads \ + ada/sem.ads ada/sem_cat.ads ada/sem_cat.adb ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/sem_ch10.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/debug.ads ada/einfo.ads ada/errout.ads ada/exp_util.ads \ + ada/fname.ads ada/fname-uf.ads ada/freeze.ads ada/get_targ.ads \ + ada/hostparm.ads ada/impunit.ads ada/inline.ads ada/lib.ads \ + ada/lib-load.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/output.ads ada/restrict.ads ada/rident.ads \ + ada/rtsfind.ads ada/sem.ads ada/sem_ch10.ads ada/sem_ch10.adb \ + ada/sem_ch6.ads ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_dist.ads \ + ada/sem_prag.ads ada/sem_util.ads ada/sem_warn.ads ada/sinfo.ads \ + ada/sinfo-cn.ads ada/sinput.ads ada/snames.ads ada/stand.ads ada/style.ads \ + ada/system.ads ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/tbuild.ads ada/ttypes.ads ada/types.ads \ + ada/uintp.ads ada/uname.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/sem_ch11.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/errout.ads \ + ada/hostparm.ads ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_ch11.ads ada/sem_ch11.adb ada/sem_ch5.ads \ + ada/sem_ch8.ads ada/sem_res.ads ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_ch12.o : ada/ada.ads ada/a-except.ads ada/a-uncdea.ads \ + ada/alloc.ads ada/atree.ads ada/casing.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/expander.ads ada/fname.ads \ + ada/fname-uf.ads ada/freeze.ads ada/gnat.ads ada/g-htable.ads \ + ada/g-htable.adb ada/g-os_lib.ads ada/hostparm.ads ada/inline.ads \ + ada/lib.ads ada/lib-load.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/output.ads ada/restrict.ads ada/rident.ads \ + ada/rtsfind.ads ada/sem.ads ada/sem_cat.ads ada/sem_ch10.ads \ + ada/sem_ch12.ads ada/sem_ch12.adb ada/sem_ch13.ads ada/sem_ch3.ads \ + ada/sem_ch6.ads ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_elab.ads \ + ada/sem_elim.ads ada/sem_eval.ads ada/sem_res.ads ada/sem_type.ads \ + ada/sem_util.ads ada/sinfo.ads ada/sinfo-cn.ads ada/sinput.ads \ + ada/sinput-l.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-memory.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/tbuild.ads ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/uname.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_ch13.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/checks.ads ada/debug.ads ada/einfo.ads ada/errout.ads ada/exp_tss.ads \ + ada/exp_util.ads ada/get_targ.ads ada/gnat.ads ada/g-hesora.ads \ + ada/g-os_lib.ads ada/hostparm.ads ada/lib.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/output.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_ch13.ads ada/sem_ch13.adb ada/sem_ch8.ads ada/sem_eval.ads \ + ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/tbuild.ads ada/tree_io.ads ada/ttypes.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_ch2.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/errout.ads \ + ada/hostparm.ads ada/namet.ads ada/opt.ads ada/restrict.ads ada/rident.ads \ + ada/sem_ch2.ads ada/sem_ch2.adb ada/sem_ch8.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_ch3.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/checks.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/eval_fat.ads ada/exp_ch3.ads \ + ada/exp_dist.ads ada/exp_util.ads ada/freeze.ads ada/get_targ.ads \ + ada/gnat.ads ada/g-hesora.ads ada/g-htable.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/itypes.ads ada/layout.ads ada/lib.ads ada/lib-xref.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads ada/output.ads \ + ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_case.ads ada/sem_case.adb ada/sem_cat.ads ada/sem_ch13.ads \ + ada/sem_ch3.ads ada/sem_ch3.adb ada/sem_ch6.ads ada/sem_ch7.ads \ + ada/sem_ch8.ads ada/sem_disp.ads ada/sem_dist.ads ada/sem_elim.ads \ + ada/sem_eval.ads ada/sem_mech.ads ada/sem_res.ads ada/sem_smem.ads \ + ada/sem_type.ads ada/sem_util.ads ada/sinfo.ads ada/sinput.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/tree_io.ads ada/ttypes.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_ch4.o : ada/alloc.ads ada/atree.ads ada/debug.ads ada/einfo.ads \ + ada/errout.ads ada/exp_util.ads ada/gnat.ads ada/g-speche.ads \ + ada/hostparm.ads ada/itypes.ads ada/lib.ads ada/lib-xref.ads ada/namet.ads \ + ada/nlists.ads ada/nmake.ads ada/opt.ads ada/output.ads ada/restrict.ads \ + ada/rident.ads ada/rtsfind.ads ada/sem.ads ada/sem_cat.ads ada/sem_ch3.ads \ + ada/sem_ch4.ads ada/sem_ch4.adb ada/sem_ch8.ads ada/sem_dist.ads \ + ada/sem_eval.ads ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/sem_ch5.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/errout.ads ada/exp_util.ads ada/expander.ads ada/freeze.ads \ + ada/gnat.ads ada/g-hesora.ads ada/hostparm.ads ada/lib.ads ada/lib-xref.ads \ + ada/namet.ads ada/nlists.ads ada/opt.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_case.ads ada/sem_case.adb ada/sem_ch3.ads ada/sem_ch5.ads \ + ada/sem_ch5.adb ada/sem_ch8.ads ada/sem_disp.ads ada/sem_eval.ads \ + ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sem_warn.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/sem_ch6.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/checks.ads \ + ada/debug.ads ada/einfo.ads ada/elists.ads ada/errout.ads ada/exp_ch7.ads \ + ada/expander.ads ada/freeze.ads ada/hostparm.ads ada/inline.ads ada/lib.ads \ + ada/lib-xref.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/output.ads ada/rtsfind.ads ada/sem.ads ada/sem_cat.ads ada/sem_ch12.ads \ + ada/sem_ch3.ads ada/sem_ch4.ads ada/sem_ch5.ads ada/sem_ch6.ads \ + ada/sem_ch6.adb ada/sem_ch8.ads ada/sem_disp.ads ada/sem_dist.ads \ + ada/sem_elim.ads ada/sem_eval.ads ada/sem_mech.ads ada/sem_prag.ads \ + ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sem_warn.ads \ + ada/sinfo.ads ada/sinfo-cn.ads ada/sinput.ads ada/snames.ads ada/stand.ads \ + ada/stringt.ads ada/style.ads ada/stylesw.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads ada/validsw.ads + + ada/sem_ch7.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/debug.ads \ + ada/einfo.ads ada/elists.ads ada/errout.ads ada/exp_dbug.ads \ + ada/exp_disp.ads ada/get_targ.ads ada/hostparm.ads ada/inline.ads \ + ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads ada/nmake.ads \ + ada/opt.ads ada/output.ads ada/sem.ads ada/sem_cat.ads ada/sem_ch12.ads \ + ada/sem_ch3.ads ada/sem_ch6.ads ada/sem_ch7.ads ada/sem_ch7.adb \ + ada/sem_ch8.ads ada/sem_util.ads ada/sem_warn.ads ada/sinfo.ads \ + ada/sinput.ads ada/snames.ads ada/stand.ads ada/style.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/sem_ch8.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/debug.ads ada/einfo.ads ada/elists.ads ada/errout.ads ada/exp_util.ads \ + ada/fname.ads ada/freeze.ads ada/gnat.ads ada/g-os_lib.ads ada/g-speche.ads \ + ada/hostparm.ads ada/inline.ads ada/lib.ads ada/lib-load.ads \ + ada/lib-xref.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/output.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_ch12.ads ada/sem_ch3.ads ada/sem_ch4.ads ada/sem_ch6.ads \ + ada/sem_ch8.ads ada/sem_ch8.adb ada/sem_res.ads ada/sem_type.ads \ + ada/sem_util.ads ada/sinfo.ads ada/sinfo-cn.ads ada/snames.ads \ + ada/stand.ads ada/style.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/tbuild.ads ada/tree_io.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/sem_ch9.o : ada/alloc.ads ada/atree.ads ada/checks.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_ch9.ads ada/hostparm.ads \ + ada/itypes.ads ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_ch3.ads ada/sem_ch5.ads ada/sem_ch6.ads ada/sem_ch8.ads \ + ada/sem_ch9.ads ada/sem_ch9.adb ada/sem_eval.ads ada/sem_res.ads \ + ada/sem_type.ads ada/sem_util.ads ada/sem_warn.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/style.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/sem_disp.o : ada/alloc.ads ada/atree.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_ch7.ads ada/exp_disp.ads \ + ada/exp_tss.ads ada/hostparm.ads ada/nlists.ads ada/opt.ads ada/output.ads \ + ada/sem.ads ada/sem_ch6.ads ada/sem_disp.ads ada/sem_disp.adb \ + ada/sem_eval.ads ada/sem_util.ads ada/sinfo.ads ada/snames.ads \ + ada/system.ads ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/sem_dist.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/einfo.ads \ + ada/errout.ads ada/exp_dist.ads ada/exp_tss.ads ada/hostparm.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_dist.ads ada/sem_dist.adb ada/sem_res.ads \ + ada/sem_util.ads ada/sinfo.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/system.ads ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/tbuild.ads ada/types.ads ada/uintp.ads \ + ada/uname.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_elab.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/checks.ads ada/debug.ads ada/einfo.ads \ + ada/elists.ads ada/errout.ads ada/exp_util.ads ada/expander.ads \ + ada/fname.ads ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/lib.ads ada/lib-load.ads ada/namet.ads ada/nlists.ads \ + ada/nmake.ads ada/opt.ads ada/output.ads ada/restrict.ads ada/rident.ads \ + ada/rtsfind.ads ada/sem.ads ada/sem_cat.ads ada/sem_ch7.ads ada/sem_ch8.ads \ + ada/sem_elab.ads ada/sem_elab.adb ada/sem_res.ads ada/sem_util.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads ada/system.ads \ + ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads \ + ada/s-imgenu.ads ada/s-memory.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tbuild.ads ada/tree_io.ads ada/types.ads \ + ada/uintp.ads ada/uname.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/sem_elim.o : ada/ada.ads ada/a-uncdea.ads ada/alloc.ads ada/atree.ads \ + ada/einfo.ads ada/errout.ads ada/gnat.ads ada/g-htable.ads ada/g-htable.adb \ + ada/namet.ads ada/nlists.ads ada/sem_elim.ads ada/sem_elim.adb \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/stringt.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/table.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_eval.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/checks.ads ada/debug.ads ada/einfo.ads ada/elists.ads ada/errout.ads \ + ada/eval_fat.ads ada/exp_util.ads ada/hostparm.ads ada/namet.ads \ + ada/nlists.ads ada/nmake.ads ada/opt.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_cat.ads ada/sem_ch8.ads ada/sem_eval.ads ada/sem_eval.adb \ + ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sem_warn.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/stringt.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/tbuild.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/sem_intr.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/errout.ads \ + ada/fname.ads ada/lib.ads ada/namet.ads ada/sem_eval.ads ada/sem_intr.ads \ + ada/sem_intr.adb ada/sem_util.ads ada/sinfo.ads ada/snames.ads \ + ada/stand.ads ada/stringt.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/table.ads ada/targparm.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_maps.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/debug.ads ada/einfo.ads ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads \ + ada/namet.ads ada/opt.ads ada/output.ads ada/sem_maps.ads ada/sem_maps.adb \ + ada/sinfo.ads ada/snames.ads ada/system.ads ada/s-atacco.ads \ + ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/tree_io.ads ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/sem_mech.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/errout.ads \ + ada/hostparm.ads ada/namet.ads ada/nlists.ads ada/opt.ads ada/sem.ads \ + ada/sem_mech.ads ada/sem_mech.adb ada/sem_util.ads ada/sinfo.ads \ + ada/snames.ads ada/stand.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/targparm.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/sem_prag.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/csets.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/errout.ads ada/exp_dist.ads ada/expander.ads ada/fname.ads \ + ada/get_targ.ads ada/gnat.ads ada/g-speche.ads ada/hostparm.ads ada/lib.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads ada/output.ads \ + ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads \ + ada/sem_ch13.ads ada/sem_ch8.ads ada/sem_disp.ads ada/sem_elim.ads \ + ada/sem_eval.ads ada/sem_intr.ads ada/sem_mech.ads ada/sem_prag.ads \ + ada/sem_prag.adb ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads \ + ada/sem_vfpt.ads ada/sinfo.ads ada/sinfo-cn.ads ada/sinput.ads \ + ada/snames.ads ada/stand.ads ada/stringt.ads ada/stylesw.ads ada/system.ads \ + ada/s-exctab.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/tbuild.ads ada/ttypes.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/validsw.ads + + ada/sem_res.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/checks.ads ada/debug.ads ada/debug_a.ads \ + ada/einfo.ads ada/elists.ads ada/errout.ads ada/exp_ch7.ads \ + ada/exp_util.ads ada/expander.ads ada/freeze.ads ada/gnat.ads \ + ada/g-htable.ads ada/g-os_lib.ads ada/hostparm.ads ada/itypes.ads \ + ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads ada/nmake.ads \ + ada/opt.ads ada/output.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_aggr.ads ada/sem_attr.ads ada/sem_cat.ads \ + ada/sem_ch4.ads ada/sem_ch6.ads ada/sem_ch8.ads ada/sem_disp.ads \ + ada/sem_dist.ads ada/sem_elab.ads ada/sem_eval.ads ada/sem_intr.ads \ + ada/sem_res.ads ada/sem_res.adb ada/sem_type.ads ada/sem_util.ads \ + ada/sem_warn.ads ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads \ + ada/stringt.ads ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/tbuild.ads ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_smem.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/errout.ads \ + ada/namet.ads ada/sem_smem.ads ada/sem_smem.adb ada/sinfo.ads \ + ada/snames.ads ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/table.ads ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/sem_type.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/debug.ads ada/einfo.ads ada/errout.ads ada/gnat.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/lib.ads ada/namet.ads ada/opt.ads ada/output.ads \ + ada/sem.ads ada/sem_ch6.ads ada/sem_ch8.ads ada/sem_type.ads \ + ada/sem_type.adb ada/sem_util.ads ada/sinfo.ads ada/snames.ads \ + ada/stand.ads ada/system.ads ada/s-atacco.ads ada/s-atacco.adb \ + ada/s-assert.ads ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_util.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/errout.ads ada/exp_util.ads ada/freeze.ads ada/get_targ.ads \ + ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads ada/hostparm.ads ada/lib.ads \ + ada/lib-xref.ads ada/namet.ads ada/nlists.ads ada/nmake.ads ada/opt.ads \ + ada/output.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/scans.ads ada/scn.ads ada/sem.ads ada/sem_ch8.ads ada/sem_eval.ads \ + ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/style.ads ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-imgenu.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/tbuild.ads ada/tree_io.ads ada/ttypes.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/sem_vfpt.o : ada/alloc.ads ada/cstand.ads ada/einfo.ads \ + ada/hostparm.ads ada/namet.ads ada/opt.ads ada/sem_vfpt.ads \ + ada/sem_vfpt.adb ada/snames.ads ada/stand.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/targparm.ads ada/ttypef.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sem_warn.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/atree.adb ada/casing.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/errout.ads ada/fname.ads ada/gnat.ads ada/g-htable.ads ada/g-os_lib.ads \ + ada/hostparm.ads ada/lib.ads ada/namet.ads ada/nlists.ads ada/opt.ads \ + ada/output.ads ada/sem.ads ada/sem_util.ads ada/sem_warn.ads \ + ada/sem_warn.adb ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-imgenu.ads ada/s-memory.ads ada/s-secsta.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads \ + ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sinfo-cn.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/sinfo.ads \ + ada/sinfo-cn.ads ada/sinfo-cn.adb ada/snames.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/table.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sinfo.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/sinfo.ads \ + ada/sinfo.adb ada/snames.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/table.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sinput-d.o : ada/alloc.ads ada/casing.ads ada/gnat.ads \ + ada/g-os_lib.ads ada/osint.ads ada/osint-c.ads ada/sinput.ads \ + ada/sinput-d.ads ada/sinput-d.adb ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/table.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/sinput-l.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/debug.ads \ + ada/einfo.ads ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/namet.ads \ + ada/opt.ads ada/osint.ads ada/output.ads ada/scans.ads ada/scn.ads \ + ada/sinfo.ads ada/sinput.ads ada/sinput-l.ads ada/sinput-l.adb \ + ada/snames.ads ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/sinput.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/casing.ads \ + ada/debug.ads ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/namet.ads \ + ada/opt.ads ada/output.ads ada/sinput.ads ada/sinput.adb ada/system.ads \ + ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads \ + ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/tree_io.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/snames.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/debug.ads \ + ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/namet.ads ada/opt.ads \ + ada/output.ads ada/snames.ads ada/snames.adb ada/system.ads \ + ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads \ + ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/tree_io.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/sprint.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/csets.ads ada/debug.ads ada/einfo.ads ada/hostparm.ads \ + ada/lib.ads ada/namet.ads ada/nlists.ads ada/opt.ads ada/output.ads \ + ada/rtsfind.ads ada/sinfo.ads ada/sinput.ads ada/sinput-d.ads \ + ada/snames.ads ada/sprint.ads ada/sprint.adb ada/stand.ads ada/stringt.ads \ + ada/system.ads ada/s-assert.ads ada/s-exctab.ads ada/s-imgenu.ads \ + ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-wchcon.ads ada/table.ads ada/types.ads ada/uintp.ads \ + ada/uname.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads + + ada/stand.o : ada/alloc.ads ada/gnat.ads ada/g-os_lib.ads ada/namet.ads \ + ada/stand.ads ada/stand.adb ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/table.ads ada/tree_io.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads + + ada/stringt.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/debug.ads \ + ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/namet.ads ada/opt.ads \ + ada/output.ads ada/stringt.ads ada/stringt.adb ada/system.ads \ + ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads ada/s-exctab.ads \ + ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/tree_io.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/style.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/csets.ads \ + ada/einfo.ads ada/errout.ads ada/hostparm.ads ada/namet.ads ada/opt.ads \ + ada/scans.ads ada/scn.ads ada/sinfo.ads ada/sinput.ads ada/snames.ads \ + ada/stand.ads ada/style.ads ada/style.adb ada/stylesw.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/stylesw.o : ada/hostparm.ads ada/opt.ads ada/stylesw.ads \ + ada/stylesw.adb ada/system.ads ada/s-exctab.ads ada/s-stalib.ads \ + ada/s-wchcon.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/switch-b.o : ada/ada.ads ada/a-except.ads ada/debug.ads ada/gnat.ads \ + ada/g-os_lib.ads ada/hostparm.ads ada/opt.ads ada/osint.ads ada/switch.ads \ + ada/switch-b.ads ada/switch-b.adb ada/system.ads ada/s-exctab.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/s-wchcon.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads + + ada/switch-c.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/debug.ads \ + ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/lib.ads ada/opt.ads \ + ada/osint.ads ada/stylesw.ads ada/switch.ads ada/switch-c.ads \ + ada/switch-c.adb ada/system.ads ada/s-exctab.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-wchcon.ads \ + ada/table.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/validsw.ads + + ada/switch.o : ada/ada.ads ada/a-except.ads ada/switch.ads ada/switch.adb \ + ada/system.ads ada/s-exctab.ads ada/s-stalib.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads + + ada/system.o : ada/system.ads + + ada/table.o : ada/debug.ads ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads \ + ada/opt.ads ada/output.ads ada/system.ads ada/s-atacco.ads ada/s-atacco.adb \ + ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/targparm.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/casing.ads \ + ada/namet.ads ada/output.ads ada/sinput.ads ada/sinput-l.ads ada/system.ads \ + ada/s-assert.ads ada/s-exctab.ads ada/s-stalib.ads ada/table.ads \ + ada/targparm.ads ada/targparm.adb ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/tbuild.o : ada/alloc.ads ada/atree.ads ada/einfo.ads ada/lib.ads \ + ada/namet.ads ada/nlists.ads ada/nmake.ads ada/restrict.ads ada/rident.ads \ + ada/sinfo.ads ada/snames.ads ada/stand.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-stoele.ads ada/table.ads \ + ada/tbuild.ads ada/tbuild.adb ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/tree_gen.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/einfo.ads \ + ada/elists.ads ada/fname.ads ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads \ + ada/lib.ads ada/namet.ads ada/nlists.ads ada/opt.ads ada/osint.ads \ + ada/osint-c.ads ada/repinfo.ads ada/sinfo.ads ada/sinput.ads ada/snames.ads \ + ada/stand.ads ada/stringt.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/tree_gen.ads \ + ada/tree_gen.adb ada/types.ads ada/uintp.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads + + ada/tree_io.o : ada/ada.ads ada/a-except.ads ada/debug.ads ada/gnat.ads \ + ada/g-os_lib.ads ada/output.ads ada/system.ads ada/s-exctab.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/tree_io.ads ada/tree_io.adb ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/treepr.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/atree.ads \ + ada/casing.ads ada/csets.ads ada/debug.ads ada/einfo.ads ada/elists.ads \ + ada/lib.ads ada/namet.ads ada/nlists.ads ada/output.ads ada/sem_mech.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/system.ads ada/s-exctab.ads ada/s-imgenu.ads ada/s-secsta.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/table.ads ada/treepr.ads ada/treepr.adb ada/treeprs.ads ada/types.ads \ + ada/uintp.ads ada/uname.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/treeprs.o : ada/alloc.ads ada/sinfo.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/table.ads ada/treeprs.ads \ + ada/types.ads ada/uintp.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/ttypef.o : ada/system.ads ada/ttypef.ads + + ada/ttypes.o : ada/get_targ.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/ttypes.ads ada/types.ads ada/unchconv.ads \ + ada/unchdeal.ads + + ada/types.o : ada/system.ads ada/s-assert.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/types.ads ada/types.adb ada/unchconv.ads \ + ada/unchdeal.ads + + ada/uintp.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/debug.ads \ + ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/opt.ads ada/output.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/uintp.adb ada/unchconv.ads ada/unchdeal.ads + + ada/uname.o : ada/alloc.ads ada/atree.ads ada/casing.ads ada/einfo.ads \ + ada/hostparm.ads ada/lib.ads ada/namet.ads ada/nlists.ads ada/output.ads \ + ada/sinfo.ads ada/sinput.ads ada/snames.ads ada/system.ads ada/s-assert.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/table.ads ada/types.ads ada/uintp.ads \ + ada/uname.ads ada/uname.adb ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads + + ada/urealp.o : ada/ada.ads ada/a-except.ads ada/alloc.ads ada/debug.ads \ + ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads ada/opt.ads ada/output.ads \ + ada/system.ads ada/s-atacco.ads ada/s-atacco.adb ada/s-assert.ads \ + ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/urealp.adb + + ada/usage.o : ada/alloc.ads ada/gnat.ads ada/g-os_lib.ads ada/hostparm.ads \ + ada/namet.ads ada/osint.ads ada/output.ads ada/system.ads ada/s-exctab.ads \ + ada/s-stalib.ads ada/s-wchcon.ads ada/table.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/usage.ads ada/usage.adb + + ada/validsw.o : ada/hostparm.ads ada/opt.ads ada/system.ads \ + ada/s-exctab.ads ada/s-stalib.ads ada/s-wchcon.ads ada/types.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/validsw.ads ada/validsw.adb + + ada/widechar.o : ada/ada.ads ada/a-except.ads ada/hostparm.ads \ + ada/interfac.ads ada/opt.ads ada/system.ads ada/s-exctab.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/s-wchcnv.ads ada/s-wchcnv.adb ada/s-wchcon.ads ada/s-wchjis.ads \ + ada/types.ads ada/unchconv.ads ada/unchdeal.ads ada/widechar.ads \ + ada/widechar.adb + + # end of regular dependencies diff -Nrc3pad gcc-3.2.3/gcc/ada/makeusg.adb gcc-3.3/gcc/ada/makeusg.adb *** gcc-3.2.3/gcc/ada/makeusg.adb 2002-05-04 03:28:20.000000000 +0000 --- gcc-3.3/gcc/ada/makeusg.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Usage; *** 32,46 **** procedure Makeusg is - procedure Write_Switch_Char; - -- Write two spaces followed by appropriate switch character - - procedure Write_Switch_Char is - begin - Write_Str (" "); - Write_Char (Switch_Character); - end Write_Switch_Char; - -- Start of processing for Makeusg begin --- 31,36 ---- *************** begin *** 64,187 **** -- Line for -a ! Write_Switch_Char; ! Write_Str ("a Consider all files, even readonly ali files"); Write_Eol; -- Line for -b ! Write_Switch_Char; ! Write_Str ("b Bind only"); Write_Eol; -- Line for -c ! Write_Switch_Char; ! Write_Str ("c Compile only"); Write_Eol; -- Line for -f ! Write_Switch_Char; ! Write_Str ("f Force recompilations of non predefined units"); Write_Eol; -- Line for -i ! Write_Switch_Char; ! Write_Str ("i In place. Replace existing ali file, "); Write_Str ("or put it with source"); Write_Eol; -- Line for -jnnn ! Write_Switch_Char; ! Write_Str ("jnum Use nnn processes to compile"); Write_Eol; -- Line for -k ! Write_Switch_Char; ! Write_Str ("k Keep going after compilation errors"); Write_Eol; -- Line for -l ! Write_Switch_Char; ! Write_Str ("l Link only"); Write_Eol; -- Line for -m ! Write_Switch_Char; ! Write_Str ("m Minimal recompilation"); Write_Eol; -- Line for -M ! Write_Switch_Char; ! Write_Str ("M List object file dependences for Makefile"); Write_Eol; -- Line for -n ! Write_Switch_Char; ! Write_Str ("n Check objects up to date, output next file "); Write_Str ("to compile if not"); Write_Eol; -- Line for -o ! Write_Switch_Char; ! Write_Str ("o name Choose an alternate executable name"); Write_Eol; -- Line for -P ! Write_Switch_Char; ! Write_Str ("Pproj Use GNAT Project File proj"); Write_Eol; -- Line for -q ! Write_Switch_Char; ! Write_Str ("q Be quiet/terse"); Write_Eol; -- Line for -s ! Write_Switch_Char; ! Write_Str ("s Recompile if compiler switches have changed"); Write_Eol; -- Line for -u ! Write_Switch_Char; ! Write_Str ("u Unique compilation. Only compile the given file."); Write_Eol; -- Line for -v ! Write_Switch_Char; ! Write_Str ("v Display reasons for all (re)compilations"); Write_Eol; -- Line for -vPx ! Write_Switch_Char; ! Write_Str ("vPx Specify verbosity when parsing GNAT Project Files"); Write_Eol; -- Line for -X ! Write_Switch_Char; ! Write_Str ("Xnm=val Specify an external reference for GNAT Project Files"); Write_Eol; -- Line for -z ! Write_Switch_Char; ! Write_Str ("z No main subprogram (zero main)"); Write_Eol; Write_Eol; --- 54,164 ---- -- Line for -a ! Write_Str (" -a Consider all files, even readonly ali files"); Write_Eol; -- Line for -b ! Write_Str (" -b Bind only"); Write_Eol; -- Line for -c ! Write_Str (" -c Compile only"); ! Write_Eol; ! ! -- Line for -C ! ! Write_Str (" -C Cache source mappings: " & ! "invoke the compiler with a mapping file"); Write_Eol; -- Line for -f ! Write_Str (" -f Force recompilations of non predefined units"); Write_Eol; -- Line for -i ! Write_Str (" -i In place. Replace existing ali file, "); Write_Str ("or put it with source"); Write_Eol; -- Line for -jnnn ! Write_Str (" -jnum Use nnn processes to compile"); Write_Eol; -- Line for -k ! Write_Str (" -k Keep going after compilation errors"); Write_Eol; -- Line for -l ! Write_Str (" -l Link only"); Write_Eol; -- Line for -m ! Write_Str (" -m Minimal recompilation"); Write_Eol; -- Line for -M ! Write_Str (" -M List object file dependences for Makefile"); Write_Eol; -- Line for -n ! Write_Str (" -n Check objects up to date, output next file "); Write_Str ("to compile if not"); Write_Eol; -- Line for -o ! Write_Str (" -o name Choose an alternate executable name"); Write_Eol; -- Line for -P ! Write_Str (" -Pproj Use GNAT Project File proj"); Write_Eol; -- Line for -q ! Write_Str (" -q Be quiet/terse"); Write_Eol; -- Line for -s ! Write_Str (" -s Recompile if compiler switches have changed"); Write_Eol; -- Line for -u ! Write_Str (" -u Unique compilation. Only compile the given file."); Write_Eol; -- Line for -v ! Write_Str (" -v Display reasons for all (re)compilations"); Write_Eol; -- Line for -vPx ! Write_Str (" -vPx Specify verbosity when parsing GNAT Project Files"); Write_Eol; -- Line for -X ! Write_Str (" -Xnm=val Specify an external reference for GNAT " & ! "Project Files"); Write_Eol; -- Line for -z ! Write_Str (" -z No main subprogram (zero main)"); Write_Eol; Write_Eol; *************** begin *** 202,261 **** -- Line for -aL ! Write_Switch_Char; ! Write_Str ("aLdir Skip missing library sources if ali in dir"); Write_Eol; -- Line for -A ! Write_Switch_Char; ! Write_Str ("Adir like -aLdir -aIdir"); Write_Eol; -- Line for -aO switch ! Write_Switch_Char; ! Write_Str ("aOdir Specify library/object files search path"); Write_Eol; -- Line for -aI switch ! Write_Switch_Char; ! Write_Str ("aIdir Specify source files search path"); Write_Eol; -- Line for -I switch ! Write_Switch_Char; ! Write_Str ("Idir Like -aIdir -aOdir"); Write_Eol; -- Line for -I- switch ! Write_Switch_Char; ! Write_Str ("I- Don't look for sources & library files"); Write_Str (" in the default directory"); Write_Eol; -- Line for -L ! Write_Switch_Char; ! Write_Str ("Ldir Look for program libraries also in dir"); Write_Eol; -- Line for -nostdinc ! Write_Switch_Char; ! Write_Str ("nostdinc Don't look for sources"); Write_Str (" in the system default directory"); Write_Eol; -- Line for -nostdlib ! Write_Switch_Char; ! Write_Str ("nostdlib Don't look for library files"); Write_Str (" in the system default directory"); Write_Eol; Write_Eol; -- General Compiler, Binder, Linker switches --- 179,235 ---- -- Line for -aL ! Write_Str (" -aLdir Skip missing library sources if ali in dir"); Write_Eol; -- Line for -A ! Write_Str (" -Adir like -aLdir -aIdir"); Write_Eol; -- Line for -aO switch ! Write_Str (" -aOdir Specify library/object files search path"); Write_Eol; -- Line for -aI switch ! Write_Str (" -aIdir Specify source files search path"); Write_Eol; -- Line for -I switch ! Write_Str (" -Idir Like -aIdir -aOdir"); Write_Eol; -- Line for -I- switch ! Write_Str (" -I- Don't look for sources & library files"); Write_Str (" in the default directory"); Write_Eol; -- Line for -L ! Write_Str (" -Ldir Look for program libraries also in dir"); Write_Eol; -- Line for -nostdinc ! Write_Str (" -nostdinc Don't look for sources"); Write_Str (" in the system default directory"); Write_Eol; -- Line for -nostdlib ! Write_Str (" -nostdlib Don't look for library files"); Write_Str (" in the system default directory"); Write_Eol; + + -- Line for --RTS + + Write_Str (" --RTS=dir specify the default source and object search" + & " path"); + Write_Eol; Write_Eol; -- General Compiler, Binder, Linker switches *************** begin *** 266,291 **** -- Line for -cargs ! Write_Switch_Char; ! Write_Str ("cargs opts opts are passed to the compiler"); Write_Eol; -- Line for -bargs ! Write_Switch_Char; ! Write_Str ("bargs opts opts are passed to the binder"); Write_Eol; -- Line for -largs ! Write_Switch_Char; ! Write_Str ("largs opts opts are passed to the linker"); Write_Eol; ! -- Line for -largs ! Write_Switch_Char; ! Write_Str ("margs opts opts are passed to gnatmake"); Write_Eol; -- Add usage information for gcc --- 240,261 ---- -- Line for -cargs ! Write_Str (" -cargs opts opts are passed to the compiler"); Write_Eol; -- Line for -bargs ! Write_Str (" -bargs opts opts are passed to the binder"); Write_Eol; -- Line for -largs ! Write_Str (" -largs opts opts are passed to the linker"); Write_Eol; ! -- Line for -margs ! Write_Str (" -margs opts opts are passed to gnatmake"); Write_Eol; -- Add usage information for gcc diff -Nrc3pad gcc-3.2.3/gcc/ada/makeusg.ads gcc-3.3/gcc/ada/makeusg.ads *** gcc-3.2.3/gcc/ada/makeusg.ads 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/makeusg.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/math_lib.adb gcc-3.3/gcc/ada/math_lib.adb *** gcc-3.2.3/gcc/ada/math_lib.adb 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/math_lib.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mdll.adb gcc-3.3/gcc/ada/mdll.adb *** gcc-3.2.3/gcc/ada/mdll.adb 2002-05-04 03:28:20.000000000 +0000 --- gcc-3.3/gcc/ada/mdll.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 31,38 **** with Ada.Text_IO; ! with MDLL.Tools; ! with MDLL.Files; package body MDLL is --- 30,37 ---- with Ada.Text_IO; ! with MDLL.Utl; ! with MDLL.Fil; package body MDLL is *************** package body MDLL is *** 58,64 **** use type OS_Lib.Argument_List; ! Base_Filename : constant String := MDLL.Files.Ext_To (Lib_Filename); Def_File : aliased String := Def_Filename; Jnk_File : aliased String := Base_Filename & ".jnk"; --- 57,63 ---- use type OS_Lib.Argument_List; ! Base_Filename : constant String := MDLL.Fil.Ext_To (Lib_Filename); Def_File : aliased String := Def_Filename; Jnk_File : aliased String := Base_Filename & ".jnk"; *************** package body MDLL is *** 70,75 **** --- 69,75 ---- Bas_Opt : aliased String := "-Wl,--base-file," & Bas_File; Lib_Opt : aliased String := "-mdll"; Out_Opt : aliased String := "-o"; + Adr_Opt : aliased String := "-Wl,--image-base=" & Lib_Address; All_Options : constant Argument_List := Options & Largs_Options; *************** package body MDLL is *** 92,103 **** --------------------- procedure Build_Reloc_DLL is - -- Objects plus the export table (.exp) file ! Objects_Exp_File : OS_Lib.Argument_List := Exp_File'Unchecked_Access & Ofiles; begin if not Quiet then Text_IO.Put_Line ("building relocatable DLL..."); --- 92,104 ---- --------------------- procedure Build_Reloc_DLL is -- Objects plus the export table (.exp) file ! Objects_Exp_File : constant OS_Lib.Argument_List := Exp_File'Unchecked_Access & Ofiles; + Success : Boolean; + begin if not Quiet then Text_IO.Put_Line ("building relocatable DLL..."); *************** package body MDLL is *** 112,161 **** -- 1) Build base file with objects files. ! Tools.Gcc (Output_File => Jnk_File, ! Files => Ofiles, ! Options => All_Options, ! Base_File => Bas_File, ! Build_Lib => True); -- 2) Build exp from base file. ! Tools.Dlltool (Def_File, Dll_File, Lib_File, ! Base_File => Bas_File, ! Exp_Table => Exp_File, ! Build_Import => False); -- 3) Build base file with exp file and objects files. ! Tools.Gcc (Output_File => Jnk_File, ! Files => Objects_Exp_File, ! Options => All_Options, ! Base_File => Bas_File, ! Build_Lib => True); -- 4) Build new exp from base file and the lib file (.a) ! Tools.Dlltool (Def_File, Dll_File, Lib_File, ! Base_File => Bas_File, ! Exp_Table => Exp_File, ! Build_Import => Build_Import); -- 5) Build the dynamic library ! Tools.Gcc (Output_File => Dll_File, ! Files => Objects_Exp_File, ! Options => All_Options, ! Build_Lib => True); ! Tools.Delete_File (Exp_File); ! Tools.Delete_File (Bas_File); ! Tools.Delete_File (Jnk_File); exception when others => ! Tools.Delete_File (Exp_File); ! Tools.Delete_File (Bas_File); ! Tools.Delete_File (Jnk_File); raise; end Build_Reloc_DLL; --- 113,162 ---- -- 1) Build base file with objects files. ! Utl.Gcc (Output_File => Jnk_File, ! Files => Ofiles, ! Options => All_Options, ! Base_File => Bas_File, ! Build_Lib => True); -- 2) Build exp from base file. ! Utl.Dlltool (Def_File, Dll_File, Lib_File, ! Base_File => Bas_File, ! Exp_Table => Exp_File, ! Build_Import => False); -- 3) Build base file with exp file and objects files. ! Utl.Gcc (Output_File => Jnk_File, ! Files => Objects_Exp_File, ! Options => All_Options, ! Base_File => Bas_File, ! Build_Lib => True); -- 4) Build new exp from base file and the lib file (.a) ! Utl.Dlltool (Def_File, Dll_File, Lib_File, ! Base_File => Bas_File, ! Exp_Table => Exp_File, ! Build_Import => Build_Import); -- 5) Build the dynamic library ! Utl.Gcc (Output_File => Dll_File, ! Files => Objects_Exp_File, ! Options => Adr_Opt'Unchecked_Access & All_Options, ! Build_Lib => True); ! OS_Lib.Delete_File (Exp_File, Success); ! OS_Lib.Delete_File (Bas_File, Success); ! OS_Lib.Delete_File (Jnk_File, Success); exception when others => ! OS_Lib.Delete_File (Exp_File, Success); ! OS_Lib.Delete_File (Bas_File, Success); ! OS_Lib.Delete_File (Jnk_File, Success); raise; end Build_Reloc_DLL; *************** package body MDLL is *** 164,169 **** --- 165,171 ---- ------------------------- procedure Ada_Build_Reloc_DLL is + Success : Boolean; begin if not Quiet then Text_IO.Put_Line ("Building relocatable DLL..."); *************** package body MDLL is *** 178,184 **** -- 1) Build base file with objects files. ! Tools.Gnatbind (Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := --- 180,186 ---- -- 1) Build base file with objects files. ! Utl.Gnatbind (Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := *************** package body MDLL is *** 186,205 **** Lib_Opt'Unchecked_Access & Bas_Opt'Unchecked_Access & Ofiles & All_Options; begin ! Tools.Gnatlink (Afiles (Afiles'Last).all, ! Params); end; -- 2) Build exp from base file. ! Tools.Dlltool (Def_File, Dll_File, Lib_File, ! Base_File => Bas_File, ! Exp_Table => Exp_File, ! Build_Import => False); -- 3) Build base file with exp file and objects files. ! Tools.Gnatbind (Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := --- 188,206 ---- Lib_Opt'Unchecked_Access & Bas_Opt'Unchecked_Access & Ofiles & All_Options; begin ! Utl.Gnatlink (Afiles (Afiles'Last).all, Params); end; -- 2) Build exp from base file. ! Utl.Dlltool (Def_File, Dll_File, Lib_File, ! Base_File => Bas_File, ! Exp_Table => Exp_File, ! Build_Import => False); -- 3) Build base file with exp file and objects files. ! Utl.Gnatbind (Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := *************** package body MDLL is *** 210,251 **** Ofiles & All_Options; begin ! Tools.Gnatlink (Afiles (Afiles'Last).all, ! Params); end; -- 4) Build new exp from base file and the lib file (.a) ! Tools.Dlltool (Def_File, Dll_File, Lib_File, ! Base_File => Bas_File, ! Exp_Table => Exp_File, ! Build_Import => Build_Import); -- 5) Build the dynamic library ! Tools.Gnatbind (Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := Out_Opt'Unchecked_Access & Dll_File'Unchecked_Access & Lib_Opt'Unchecked_Access & Exp_File'Unchecked_Access & Ofiles & All_Options; begin ! Tools.Gnatlink (Afiles (Afiles'Last).all, ! Params); end; ! Tools.Delete_File (Exp_File); ! Tools.Delete_File (Bas_File); ! Tools.Delete_File (Jnk_File); exception when others => ! Tools.Delete_File (Exp_File); ! Tools.Delete_File (Bas_File); ! Tools.Delete_File (Jnk_File); raise; end Ada_Build_Reloc_DLL; --- 211,251 ---- Ofiles & All_Options; begin ! Utl.Gnatlink (Afiles (Afiles'Last).all, Params); end; -- 4) Build new exp from base file and the lib file (.a) ! Utl.Dlltool (Def_File, Dll_File, Lib_File, ! Base_File => Bas_File, ! Exp_Table => Exp_File, ! Build_Import => Build_Import); -- 5) Build the dynamic library ! Utl.Gnatbind (Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := Out_Opt'Unchecked_Access & Dll_File'Unchecked_Access & Lib_Opt'Unchecked_Access & Exp_File'Unchecked_Access & + Adr_Opt'Unchecked_Access & Ofiles & All_Options; begin ! Utl.Gnatlink (Afiles (Afiles'Last).all, Params); end; ! OS_Lib.Delete_File (Exp_File, Success); ! OS_Lib.Delete_File (Bas_File, Success); ! OS_Lib.Delete_File (Jnk_File, Success); exception when others => ! OS_Lib.Delete_File (Exp_File, Success); ! OS_Lib.Delete_File (Bas_File, Success); ! OS_Lib.Delete_File (Jnk_File, Success); raise; end Ada_Build_Reloc_DLL; *************** package body MDLL is *** 254,259 **** --- 254,260 ---- ------------------------- procedure Build_Non_Reloc_DLL is + Success : Boolean; begin if not Quiet then Text_IO.Put_Line ("building non relocatable DLL..."); *************** package body MDLL is *** 269,290 **** -- Build exp table and the lib .a file. ! Tools.Dlltool (Def_File, Dll_File, Lib_File, ! Exp_Table => Exp_File, ! Build_Import => Build_Import); -- Build the DLL ! Tools.Gcc (Output_File => Dll_File, ! Files => Exp_File'Unchecked_Access & Ofiles, ! Options => All_Options, ! Build_Lib => True); ! Tools.Delete_File (Exp_File); exception when others => ! Tools.Delete_File (Exp_File); raise; end Build_Non_Reloc_DLL; --- 270,291 ---- -- Build exp table and the lib .a file. ! Utl.Dlltool (Def_File, Dll_File, Lib_File, ! Exp_Table => Exp_File, ! Build_Import => Build_Import); -- Build the DLL ! Utl.Gcc (Output_File => Dll_File, ! Files => Exp_File'Unchecked_Access & Ofiles, ! Options => Adr_Opt'Unchecked_Access & All_Options, ! Build_Lib => True); ! OS_Lib.Delete_File (Exp_File, Success); exception when others => ! OS_Lib.Delete_File (Exp_File, Success); raise; end Build_Non_Reloc_DLL; *************** package body MDLL is *** 295,300 **** --- 296,302 ---- -- Build a non relocatable DLL with Ada code. procedure Ada_Build_Non_Reloc_DLL is + Success : Boolean; begin if not Quiet then Text_IO.Put_Line ("building non relocatable DLL..."); *************** package body MDLL is *** 310,340 **** -- Build exp table and the lib .a file. ! Tools.Dlltool (Def_File, Dll_File, Lib_File, ! Exp_Table => Exp_File, ! Build_Import => Build_Import); -- Build the DLL ! Tools.Gnatbind (Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := Out_Opt'Unchecked_Access & Dll_File'Unchecked_Access & Lib_Opt'Unchecked_Access & Exp_File'Unchecked_Access & Ofiles & All_Options; begin ! Tools.Gnatlink (Afiles (Afiles'Last).all, ! Params); end; ! Tools.Delete_File (Exp_File); exception when others => ! Tools.Delete_File (Exp_File); raise; end Ada_Build_Non_Reloc_DLL; --- 312,342 ---- -- Build exp table and the lib .a file. ! Utl.Dlltool (Def_File, Dll_File, Lib_File, ! Exp_Table => Exp_File, ! Build_Import => Build_Import); -- Build the DLL ! Utl.Gnatbind (Afiles, Options & Bargs_Options); declare Params : OS_Lib.Argument_List := Out_Opt'Unchecked_Access & Dll_File'Unchecked_Access & Lib_Opt'Unchecked_Access & Exp_File'Unchecked_Access & + Adr_Opt'Unchecked_Access & Ofiles & All_Options; begin ! Utl.Gnatlink (Afiles (Afiles'Last).all, Params); end; ! OS_Lib.Delete_File (Exp_File, Success); exception when others => ! OS_Lib.Delete_File (Exp_File, Success); raise; end Ada_Build_Non_Reloc_DLL; *************** package body MDLL is *** 371,377 **** -- Build an import library. -- this is to build only a .a library to link against a DLL. ! Base_Filename : constant String := MDLL.Files.Ext_To (Lib_Filename); -------------------------- -- Build_Import_Library -- --- 373,379 ---- -- Build an import library. -- this is to build only a .a library to link against a DLL. ! Base_Filename : constant String := MDLL.Fil.Ext_To (Lib_Filename); -------------------------- -- Build_Import_Library -- *************** package body MDLL is *** 391,398 **** " to use dynamic library " & Dll_File); end if; ! Tools.Dlltool (Def_File, Dll_File, Lib_File, ! Build_Import => True); end Build_Import_Library; begin --- 393,400 ---- " to use dynamic library " & Dll_File); end if; ! Utl.Dlltool (Def_File, Dll_File, Lib_File, ! Build_Import => True); end Build_Import_Library; begin diff -Nrc3pad gcc-3.2.3/gcc/ada/mdll.ads gcc-3.3/gcc/ada/mdll.ads *** gcc-3.2.3/gcc/ada/mdll.ads 2002-05-04 03:28:20.000000000 +0000 --- gcc-3.3/gcc/ada/mdll.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mdll-fil.adb gcc-3.3/gcc/ada/mdll-fil.adb *** gcc-3.2.3/gcc/ada/mdll-fil.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/mdll-fil.adb 2002-03-14 10:59:31.000000000 +0000 *************** *** 0 **** --- 1,93 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- M D L L . F I L E S -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 1992-2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- + -- -- + ------------------------------------------------------------------------------ + + -- Simple services used by GNATDLL to deal with Filename extension. + + with Ada.Strings.Fixed; + + package body MDLL.Fil is + + use Ada; + + ------------- + -- Get_Ext -- + ------------- + + function Get_Ext (Filename : String) return String is + use Strings.Fixed; + I : constant Natural := Index (Filename, ".", Strings.Backward); + begin + if I = 0 then + return ""; + else + return Filename (I .. Filename'Last); + end if; + end Get_Ext; + + ------------ + -- Is_Ali -- + ------------ + + function Is_Ali (Filename : String) return Boolean is + begin + return Get_Ext (Filename) = ".ali"; + end Is_Ali; + + ------------ + -- Is_Obj -- + ------------ + + function Is_Obj (Filename : String) return Boolean is + Ext : constant String := Get_Ext (Filename); + begin + return Ext = ".o" or else Ext = ".obj"; + end Is_Obj; + + ------------ + -- Ext_To -- + ------------ + + function Ext_To + (Filename : String; + New_Ext : String := No_Ext) + return String + is + use Strings.Fixed; + I : constant Natural := Index (Filename, ".", Strings.Backward); + begin + if I = 0 then + return Filename; + else + if New_Ext = "" then + return Head (Filename, I - 1); + else + return Head (Filename, I - 1) & '.' & New_Ext; + end if; + end if; + end Ext_To; + + end MDLL.Fil; diff -Nrc3pad gcc-3.2.3/gcc/ada/mdll-fil.ads gcc-3.3/gcc/ada/mdll-fil.ads *** gcc-3.2.3/gcc/ada/mdll-fil.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/mdll-fil.ads 2002-03-14 10:59:31.000000000 +0000 *************** *** 0 **** --- 1,50 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- M D L L . F I L E S -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 1992-2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- + -- -- + ------------------------------------------------------------------------------ + + -- Simple services used by GNATDLL to deal with Filename extension + + package MDLL.Fil is + + No_Ext : constant String := ""; + -- Used to mark the absence of an extension + + function Get_Ext (Filename : String) return String; + -- Return extension of Filename + + function Is_Ali (Filename : String) return Boolean; + -- Test if Filename is an Ada library file (.ali). + + function Is_Obj (Filename : String) return Boolean; + -- Test if Filename is an object file (.o or .obj) + + function Ext_To + (Filename : String; + New_Ext : String := No_Ext) + return String; + -- Return Filename with the extension change to New_Ext + + end MDLL.Fil; diff -Nrc3pad gcc-3.2.3/gcc/ada/mdllfile.adb gcc-3.3/gcc/ada/mdllfile.adb *** gcc-3.2.3/gcc/ada/mdllfile.adb 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/mdllfile.adb 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,98 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- M D L L . F I L E S -- - -- -- - -- B o d y -- - -- -- - -- $Revision: 1.1.16.2 $ - -- -- - -- Copyright (C) 1992-1999 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - -- Simple services used by GNATDLL to deal with Filename extension. - - with Ada.Strings.Fixed; - - package body MDLL.Files is - - use Ada; - - ------------- - -- Get_Ext -- - ------------- - - function Get_Ext (Filename : in String) - return String - is - use Strings.Fixed; - I : constant Natural := Index (Filename, ".", Strings.Backward); - begin - if I = 0 then - return ""; - else - return Filename (I .. Filename'Last); - end if; - end Get_Ext; - - ------------ - -- Is_Ali -- - ------------ - - function Is_Ali (Filename : in String) - return Boolean is - begin - return Get_Ext (Filename) = ".ali"; - end Is_Ali; - - ------------ - -- Is_Obj -- - ------------ - - function Is_Obj (Filename : in String) - return Boolean - is - Ext : constant String := Get_Ext (Filename); - begin - return Ext = ".o" or else Ext = ".obj"; - end Is_Obj; - - ------------ - -- Ext_To -- - ------------ - - function Ext_To (Filename : in String; - New_Ext : in String := No_Ext) - return String - is - use Strings.Fixed; - I : constant Natural := Index (Filename, ".", Strings.Backward); - begin - if I = 0 then - return Filename; - else - if New_Ext = "" then - return Head (Filename, I - 1); - else - return Head (Filename, I - 1) & '.' & New_Ext; - end if; - end if; - end Ext_To; - - end MDLL.Files; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mdllfile.ads gcc-3.3/gcc/ada/mdllfile.ads *** gcc-3.2.3/gcc/ada/mdllfile.ads 2002-05-04 03:28:20.000000000 +0000 --- gcc-3.3/gcc/ada/mdllfile.ads 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,51 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- M D L L . F I L E S -- - -- -- - -- S p e c -- - -- -- - -- $Revision: 1.4.10.1 $ - -- -- - -- Copyright (C) 1992-2001 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - -- Simple services used by GNATDLL to deal with Filename extension - - package MDLL.Files is - - No_Ext : constant String := ""; - -- Used to mark the absence of an extension - - function Get_Ext (Filename : String) return String; - -- Return extension of Filename - - function Is_Ali (Filename : String) return Boolean; - -- Test if Filename is an Ada library file (.ali). - - function Is_Obj (Filename : String) return Boolean; - -- Test if Filename is an object file (.o or .obj) - - function Ext_To - (Filename : String; - New_Ext : String := No_Ext) - return String; - -- Return Filename with the extension change to New_Ext - - end MDLL.Files; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mdlltool.adb gcc-3.3/gcc/ada/mdlltool.adb *** gcc-3.2.3/gcc/ada/mdlltool.adb 2002-05-04 03:28:20.000000000 +0000 --- gcc-3.3/gcc/ada/mdlltool.adb 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,346 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- M D L L . T O O L S -- - -- -- - -- B o d y -- - -- -- - -- $Revision: 1.2.10.1 $ - -- -- - -- Copyright (C) 1992-2000 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - -- Interface to externals tools used to build DLL and import libraries - - with Ada.Text_IO; - with Ada.Exceptions; - with Ada.Unchecked_Deallocation; - - with Sdefault; - - package body MDLL.Tools is - - use Ada; - use GNAT; - - Dlltool_Name : constant String := "dlltool"; - Dlltool_Exec : OS_Lib.String_Access; - - Gcc_Name : constant String := "gcc"; - Gcc_Exec : OS_Lib.String_Access; - - Gnatbind_Name : constant String := "gnatbind"; - Gnatbind_Exec : OS_Lib.String_Access; - - Gnatlink_Name : constant String := "gnatlink"; - Gnatlink_Exec : OS_Lib.String_Access; - - procedure Free is - new Ada.Unchecked_Deallocation (OS_Lib.Argument_List, - OS_Lib.Argument_List_Access); - - procedure Print_Command (Tool_Name : in String; - Arguments : in OS_Lib.Argument_List); - -- display the command runned when in Verbose mode - - ------------------- - -- Print_Command -- - ------------------- - - procedure Print_Command (Tool_Name : in String; - Arguments : in OS_Lib.Argument_List) is - begin - if Verbose then - Text_IO.Put (Tool_Name); - for K in Arguments'Range loop - Text_IO.Put (" " & Arguments (K).all); - end loop; - Text_IO.New_Line; - end if; - end Print_Command; - - ----------------- - -- Delete_File -- - ----------------- - - procedure Delete_File (Filename : in String) is - File : constant String := Filename & ASCII.Nul; - Success : Boolean; - begin - OS_Lib.Delete_File (File'Address, Success); - end Delete_File; - - ------------- - -- Dlltool -- - ------------- - - procedure Dlltool (Def_Filename : in String; - DLL_Name : in String; - Library : in String; - Exp_Table : in String := ""; - Base_File : in String := ""; - Build_Import : in Boolean) - is - - Arguments : OS_Lib.Argument_List (1 .. 11); - A : Positive; - - Success : Boolean; - - Def_Opt : aliased String := "--def"; - Def_V : aliased String := Def_Filename; - Dll_Opt : aliased String := "--dllname"; - Dll_V : aliased String := DLL_Name; - Lib_Opt : aliased String := "--output-lib"; - Lib_V : aliased String := Library; - Exp_Opt : aliased String := "--output-exp"; - Exp_V : aliased String := Exp_Table; - Bas_Opt : aliased String := "--base-file"; - Bas_V : aliased String := Base_File; - No_Suf_Opt : aliased String := "-k"; - begin - Arguments (1 .. 4) := (1 => Def_Opt'Unchecked_Access, - 2 => Def_V'Unchecked_Access, - 3 => Dll_Opt'Unchecked_Access, - 4 => Dll_V'Unchecked_Access); - A := 4; - - if Kill_Suffix then - A := A + 1; - Arguments (A) := No_Suf_Opt'Unchecked_Access; - end if; - - if Library /= "" and then Build_Import then - A := A + 1; - Arguments (A) := Lib_Opt'Unchecked_Access; - A := A + 1; - Arguments (A) := Lib_V'Unchecked_Access; - end if; - - if Exp_Table /= "" then - A := A + 1; - Arguments (A) := Exp_Opt'Unchecked_Access; - A := A + 1; - Arguments (A) := Exp_V'Unchecked_Access; - end if; - - if Base_File /= "" then - A := A + 1; - Arguments (A) := Bas_Opt'Unchecked_Access; - A := A + 1; - Arguments (A) := Bas_V'Unchecked_Access; - end if; - - Print_Command ("dlltool", Arguments (1 .. A)); - - OS_Lib.Spawn (Dlltool_Exec.all, Arguments (1 .. A), Success); - - if not Success then - Exceptions.Raise_Exception (Tools_Error'Identity, - Dlltool_Name & " execution error."); - end if; - - end Dlltool; - - --------- - -- Gcc -- - --------- - - procedure Gcc (Output_File : in String; - Files : in Argument_List; - Options : in Argument_List; - Base_File : in String := ""; - Build_Lib : in Boolean := False) - is - use Sdefault; - - Arguments : OS_Lib.Argument_List - (1 .. 5 + Files'Length + Options'Length); - A : Natural := 0; - - Success : Boolean; - C_Opt : aliased String := "-c"; - Out_Opt : aliased String := "-o"; - Out_V : aliased String := Output_File; - Bas_Opt : aliased String := "-Wl,--base-file," & Base_File; - Lib_Opt : aliased String := "-mdll"; - Lib_Dir : aliased String := "-L" & Object_Dir_Default_Name.all; - - begin - A := A + 1; - if Build_Lib then - Arguments (A) := Lib_Opt'Unchecked_Access; - else - Arguments (A) := C_Opt'Unchecked_Access; - end if; - - A := A + 1; - Arguments (A .. A + 2) := (Out_Opt'Unchecked_Access, - Out_V'Unchecked_Access, - Lib_Dir'Unchecked_Access); - A := A + 2; - - if Base_File /= "" then - A := A + 1; - Arguments (A) := Bas_Opt'Unchecked_Access; - end if; - - A := A + 1; - Arguments (A .. A + Files'Length - 1) := Files; - A := A + Files'Length - 1; - - if Build_Lib then - A := A + 1; - Arguments (A .. A + Options'Length - 1) := Options; - A := A + Options'Length - 1; - else - declare - Largs : Argument_List (Options'Range); - L : Natural := Largs'First - 1; - begin - for K in Options'Range loop - if Options (K) (1 .. 2) /= "-l" then - L := L + 1; - Largs (L) := Options (K); - end if; - end loop; - A := A + 1; - Arguments (A .. A + L - 1) := Largs (1 .. L); - A := A + L - 1; - end; - end if; - - Print_Command ("gcc", Arguments (1 .. A)); - - OS_Lib.Spawn (Gcc_Exec.all, Arguments (1 .. A), Success); - - if not Success then - Exceptions.Raise_Exception (Tools_Error'Identity, - Gcc_Name & " execution error."); - end if; - end Gcc; - - -------------- - -- Gnatbind -- - -------------- - - procedure Gnatbind (Alis : in Argument_List; - Args : in Argument_List := Null_Argument_List) - is - Arguments : OS_Lib.Argument_List (1 .. 1 + Alis'Length + Args'Length); - Success : Boolean; - - No_Main_Opt : aliased String := "-n"; - - begin - Arguments (1) := No_Main_Opt'Unchecked_Access; - Arguments (2 .. 1 + Alis'Length) := Alis; - Arguments (2 + Alis'Length .. Arguments'Last) := Args; - - Print_Command ("gnatbind", Arguments); - - OS_Lib.Spawn (Gnatbind_Exec.all, Arguments, Success); - - if not Success then - Exceptions.Raise_Exception (Tools_Error'Identity, - Gnatbind_Name & " execution error."); - end if; - end Gnatbind; - - -------------- - -- Gnatlink -- - -------------- - - procedure Gnatlink (Ali : in String; - Args : in Argument_List := Null_Argument_List) - is - Arguments : OS_Lib.Argument_List (1 .. 1 + Args'Length); - Success : Boolean; - - Ali_Name : aliased String := Ali; - - begin - Arguments (1) := Ali_Name'Unchecked_Access; - Arguments (2 .. Arguments'Last) := Args; - - Print_Command ("gnatlink", Arguments); - - OS_Lib.Spawn (Gnatlink_Exec.all, Arguments, Success); - - if not Success then - Exceptions.Raise_Exception (Tools_Error'Identity, - Gnatlink_Name & " execution error."); - end if; - end Gnatlink; - - ------------ - -- Locate -- - ------------ - - procedure Locate is - use type OS_Lib.String_Access; - begin - -- dlltool - - Dlltool_Exec := OS_Lib.Locate_Exec_On_Path (Dlltool_Name); - - if Dlltool_Exec = null then - Exceptions.Raise_Exception (Tools_Error'Identity, - Dlltool_Name & " not found in path"); - elsif Verbose then - Text_IO.Put_Line ("using " & Dlltool_Exec.all); - end if; - - -- gcc - - Gcc_Exec := OS_Lib.Locate_Exec_On_Path (Gcc_Name); - - if Gcc_Exec = null then - Exceptions.Raise_Exception (Tools_Error'Identity, - Gcc_Name & " not found in path"); - elsif Verbose then - Text_IO.Put_Line ("using " & Gcc_Exec.all); - end if; - - -- gnatbind - - Gnatbind_Exec := OS_Lib.Locate_Exec_On_Path (Gnatbind_Name); - - if Gnatbind_Exec = null then - Exceptions.Raise_Exception (Tools_Error'Identity, - Gnatbind_Name & " not found in path"); - elsif Verbose then - Text_IO.Put_Line ("using " & Gnatbind_Exec.all); - end if; - - -- gnatlink - - Gnatlink_Exec := OS_Lib.Locate_Exec_On_Path (Gnatlink_Name); - - if Gnatlink_Exec = null then - Exceptions.Raise_Exception (Tools_Error'Identity, - Gnatlink_Name & " not found in path"); - elsif Verbose then - Text_IO.Put_Line ("using " & Gnatlink_Exec.all); - Text_IO.New_Line; - end if; - - end Locate; - - end MDLL.Tools; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mdlltool.ads gcc-3.3/gcc/ada/mdlltool.ads *** gcc-3.2.3/gcc/ada/mdlltool.ads 2002-05-04 03:28:21.000000000 +0000 --- gcc-3.3/gcc/ada/mdlltool.ads 1970-01-01 00:00:00.000000000 +0000 *************** *** 1,66 **** - ------------------------------------------------------------------------------ - -- -- - -- GNAT COMPILER COMPONENTS -- - -- -- - -- M D L L . T O O L S -- - -- -- - -- S p e c -- - -- -- - -- $Revision: 1.1.16.1 $ - -- -- - -- Copyright (C) 1992-1999 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- -- - -- 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, 59 Temple Place - Suite 330, Boston, -- - -- MA 02111-1307, USA. -- - -- -- - -- GNAT was originally developed by the GNAT team at New York University. -- - -- Extensive contributions were provided by Ada Core Technologies Inc. -- - -- -- - ------------------------------------------------------------------------------ - - -- Interface to externals tools used to build DLL and import libraries - - package MDLL.Tools is - - procedure Delete_File (Filename : in String); - -- delete the file filename from the file system. - - procedure Dlltool (Def_Filename : in String; - DLL_Name : in String; - Library : in String; - Exp_Table : in String := ""; - Base_File : in String := ""; - Build_Import : in Boolean); - -- run dlltool binary. - -- this tools is used to build an import library and an export table - - procedure Gcc (Output_File : in String; - Files : in Argument_List; - Options : in Argument_List; - Base_File : in String := ""; - Build_Lib : in Boolean := False); - -- run gcc binary. - - procedure Gnatbind (Alis : in Argument_List; - Args : in Argument_List := Null_Argument_List); - -- run gnatbind binary to build the binder program. - -- it runs the command : gnatbind -n alis... to build the binder program. - - procedure Gnatlink (Ali : in String; - Args : in Argument_List := Null_Argument_List); - -- run gnatlink binary. - -- it runs the command : gnatlink ali arg1 arg2... - - procedure Locate; - -- look for the needed tools in the path and record the full path for each - -- one in a variable. - - end MDLL.Tools; --- 0 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mdll-utl.adb gcc-3.3/gcc/ada/mdll-utl.adb *** gcc-3.2.3/gcc/ada/mdll-utl.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/mdll-utl.adb 2002-03-14 10:59:31.000000000 +0000 *************** *** 0 **** --- 1,335 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- M D L L . T O O L S -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 1992-2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- + -- -- + ------------------------------------------------------------------------------ + + -- Interface to externals tools used to build DLL and import libraries + + with Ada.Text_IO; + with Ada.Exceptions; + + with Sdefault; + + package body MDLL.Utl is + + use Ada; + use GNAT; + + Dlltool_Name : constant String := "dlltool"; + Dlltool_Exec : OS_Lib.String_Access; + + Gcc_Name : constant String := "gcc"; + Gcc_Exec : OS_Lib.String_Access; + + Gnatbind_Name : constant String := "gnatbind"; + Gnatbind_Exec : OS_Lib.String_Access; + + Gnatlink_Name : constant String := "gnatlink"; + Gnatlink_Exec : OS_Lib.String_Access; + + procedure Print_Command + (Tool_Name : String; + Arguments : OS_Lib.Argument_List); + -- display the command runned when in Verbose mode + + ------------------- + -- Print_Command -- + ------------------- + + procedure Print_Command + (Tool_Name : String; + Arguments : OS_Lib.Argument_List) + is + begin + if Verbose then + Text_IO.Put (Tool_Name); + for K in Arguments'Range loop + Text_IO.Put (" " & Arguments (K).all); + end loop; + Text_IO.New_Line; + end if; + end Print_Command; + + ------------- + -- Dlltool -- + ------------- + + procedure Dlltool + (Def_Filename : String; + DLL_Name : String; + Library : String; + Exp_Table : String := ""; + Base_File : String := ""; + Build_Import : Boolean) + is + Arguments : OS_Lib.Argument_List (1 .. 11); + A : Positive; + + Success : Boolean; + + Def_Opt : aliased String := "--def"; + Def_V : aliased String := Def_Filename; + Dll_Opt : aliased String := "--dllname"; + Dll_V : aliased String := DLL_Name; + Lib_Opt : aliased String := "--output-lib"; + Lib_V : aliased String := Library; + Exp_Opt : aliased String := "--output-exp"; + Exp_V : aliased String := Exp_Table; + Bas_Opt : aliased String := "--base-file"; + Bas_V : aliased String := Base_File; + No_Suf_Opt : aliased String := "-k"; + begin + Arguments (1 .. 4) := (1 => Def_Opt'Unchecked_Access, + 2 => Def_V'Unchecked_Access, + 3 => Dll_Opt'Unchecked_Access, + 4 => Dll_V'Unchecked_Access); + A := 4; + + if Kill_Suffix then + A := A + 1; + Arguments (A) := No_Suf_Opt'Unchecked_Access; + end if; + + if Library /= "" and then Build_Import then + A := A + 1; + Arguments (A) := Lib_Opt'Unchecked_Access; + A := A + 1; + Arguments (A) := Lib_V'Unchecked_Access; + end if; + + if Exp_Table /= "" then + A := A + 1; + Arguments (A) := Exp_Opt'Unchecked_Access; + A := A + 1; + Arguments (A) := Exp_V'Unchecked_Access; + end if; + + if Base_File /= "" then + A := A + 1; + Arguments (A) := Bas_Opt'Unchecked_Access; + A := A + 1; + Arguments (A) := Bas_V'Unchecked_Access; + end if; + + Print_Command ("dlltool", Arguments (1 .. A)); + + OS_Lib.Spawn (Dlltool_Exec.all, Arguments (1 .. A), Success); + + if not Success then + Exceptions.Raise_Exception (Tools_Error'Identity, + Dlltool_Name & " execution error."); + end if; + + end Dlltool; + + --------- + -- Gcc -- + --------- + + procedure Gcc + (Output_File : String; + Files : Argument_List; + Options : Argument_List; + Base_File : String := ""; + Build_Lib : Boolean := False) + is + use Sdefault; + + Arguments : OS_Lib.Argument_List + (1 .. 5 + Files'Length + Options'Length); + A : Natural := 0; + + Success : Boolean; + C_Opt : aliased String := "-c"; + Out_Opt : aliased String := "-o"; + Out_V : aliased String := Output_File; + Bas_Opt : aliased String := "-Wl,--base-file," & Base_File; + Lib_Opt : aliased String := "-mdll"; + Lib_Dir : aliased String := "-L" & Object_Dir_Default_Name.all; + + begin + A := A + 1; + if Build_Lib then + Arguments (A) := Lib_Opt'Unchecked_Access; + else + Arguments (A) := C_Opt'Unchecked_Access; + end if; + + A := A + 1; + Arguments (A .. A + 2) := (Out_Opt'Unchecked_Access, + Out_V'Unchecked_Access, + Lib_Dir'Unchecked_Access); + A := A + 2; + + if Base_File /= "" then + A := A + 1; + Arguments (A) := Bas_Opt'Unchecked_Access; + end if; + + A := A + 1; + Arguments (A .. A + Files'Length - 1) := Files; + A := A + Files'Length - 1; + + if Build_Lib then + A := A + 1; + Arguments (A .. A + Options'Length - 1) := Options; + A := A + Options'Length - 1; + else + declare + Largs : Argument_List (Options'Range); + L : Natural := Largs'First - 1; + begin + for K in Options'Range loop + if Options (K) (1 .. 2) /= "-l" then + L := L + 1; + Largs (L) := Options (K); + end if; + end loop; + A := A + 1; + Arguments (A .. A + L - 1) := Largs (1 .. L); + A := A + L - 1; + end; + end if; + + Print_Command ("gcc", Arguments (1 .. A)); + + OS_Lib.Spawn (Gcc_Exec.all, Arguments (1 .. A), Success); + + if not Success then + Exceptions.Raise_Exception (Tools_Error'Identity, + Gcc_Name & " execution error."); + end if; + end Gcc; + + -------------- + -- Gnatbind -- + -------------- + + procedure Gnatbind + (Alis : Argument_List; + Args : Argument_List := Null_Argument_List) + is + Arguments : OS_Lib.Argument_List (1 .. 1 + Alis'Length + Args'Length); + Success : Boolean; + + No_Main_Opt : aliased String := "-n"; + + begin + Arguments (1) := No_Main_Opt'Unchecked_Access; + Arguments (2 .. 1 + Alis'Length) := Alis; + Arguments (2 + Alis'Length .. Arguments'Last) := Args; + + Print_Command ("gnatbind", Arguments); + + OS_Lib.Spawn (Gnatbind_Exec.all, Arguments, Success); + + if not Success then + Exceptions.Raise_Exception (Tools_Error'Identity, + Gnatbind_Name & " execution error."); + end if; + end Gnatbind; + + -------------- + -- Gnatlink -- + -------------- + + procedure Gnatlink + (Ali : String; + Args : Argument_List := Null_Argument_List) + is + Arguments : OS_Lib.Argument_List (1 .. 1 + Args'Length); + Success : Boolean; + + Ali_Name : aliased String := Ali; + + begin + Arguments (1) := Ali_Name'Unchecked_Access; + Arguments (2 .. Arguments'Last) := Args; + + Print_Command ("gnatlink", Arguments); + + OS_Lib.Spawn (Gnatlink_Exec.all, Arguments, Success); + + if not Success then + Exceptions.Raise_Exception (Tools_Error'Identity, + Gnatlink_Name & " execution error."); + end if; + end Gnatlink; + + ------------ + -- Locate -- + ------------ + + procedure Locate is + use type OS_Lib.String_Access; + begin + -- dlltool + + Dlltool_Exec := OS_Lib.Locate_Exec_On_Path (Dlltool_Name); + + if Dlltool_Exec = null then + Exceptions.Raise_Exception (Tools_Error'Identity, + Dlltool_Name & " not found in path"); + elsif Verbose then + Text_IO.Put_Line ("using " & Dlltool_Exec.all); + end if; + + -- gcc + + Gcc_Exec := OS_Lib.Locate_Exec_On_Path (Gcc_Name); + + if Gcc_Exec = null then + Exceptions.Raise_Exception (Tools_Error'Identity, + Gcc_Name & " not found in path"); + elsif Verbose then + Text_IO.Put_Line ("using " & Gcc_Exec.all); + end if; + + -- gnatbind + + Gnatbind_Exec := OS_Lib.Locate_Exec_On_Path (Gnatbind_Name); + + if Gnatbind_Exec = null then + Exceptions.Raise_Exception (Tools_Error'Identity, + Gnatbind_Name & " not found in path"); + elsif Verbose then + Text_IO.Put_Line ("using " & Gnatbind_Exec.all); + end if; + + -- gnatlink + + Gnatlink_Exec := OS_Lib.Locate_Exec_On_Path (Gnatlink_Name); + + if Gnatlink_Exec = null then + Exceptions.Raise_Exception (Tools_Error'Identity, + Gnatlink_Name & " not found in path"); + elsif Verbose then + Text_IO.Put_Line ("using " & Gnatlink_Exec.all); + Text_IO.New_Line; + end if; + + end Locate; + + end MDLL.Utl; diff -Nrc3pad gcc-3.2.3/gcc/ada/mdll-utl.ads gcc-3.3/gcc/ada/mdll-utl.ads *** gcc-3.2.3/gcc/ada/mdll-utl.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/mdll-utl.ads 2002-03-14 10:59:31.000000000 +0000 *************** *** 0 **** --- 1,66 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- M D L L . T O O L S -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 1992-2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- + -- -- + ------------------------------------------------------------------------------ + + -- Interface to externals tools used to build DLL and import libraries + + package MDLL.Utl is + + procedure Dlltool + (Def_Filename : String; + DLL_Name : String; + Library : String; + Exp_Table : String := ""; + Base_File : String := ""; + Build_Import : Boolean); + -- Run dlltool binary. + -- This tools is used to build an import library and an export table + + procedure Gcc + (Output_File : String; + Files : Argument_List; + Options : Argument_List; + Base_File : String := ""; + Build_Lib : Boolean := False); + -- Run gcc binary. + + procedure Gnatbind + (Alis : Argument_List; + Args : Argument_List := Null_Argument_List); + -- Run gnatbind binary to build the binder program. + -- it Runs the command : gnatbind -n alis... to build the binder program. + + procedure Gnatlink + (Ali : String; + Args : Argument_List := Null_Argument_List); + -- Run gnatlink binary. + -- It runs the command : gnatlink ali arg1 arg2... + + procedure Locate; + -- Look for the needed tools in the path and record the full path for each + -- one in a variable. + + end MDLL.Utl; diff -Nrc3pad gcc-3.2.3/gcc/ada/memroot.adb gcc-3.3/gcc/ada/memroot.adb *** gcc-3.2.3/gcc/ada/memroot.adb 2001-10-02 13:45:37.000000000 +0000 --- gcc-3.3/gcc/ada/memroot.adb 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1997-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2002 Ada Core Technologies, 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- -- *************** package body Memroot is *** 574,596 **** while Last >= 1 and then Line (1) = '#' and then not Main_Found loop if F <= BT_Depth then Find_Name; ! Nam := Enter_Name (Line (Curs1 .. Curs2)); ! Main_Found := Line (Curs1 .. Curs2) = "main"; ! Find_File; ! if No_File then ! Fil := No_Name_Id; ! Lin := No_Name_Id; ! else ! Fil := Enter_Name (Line (Curs1 .. Curs2)); ! Find_Line; ! Lin := Enter_Name (Line (Curs1 .. Curs2)); ! end if; ! Frames (F) := Enter_Frame (Nam, Fil, Lin); ! F := F + 1; end if; if No_File then --- 573,598 ---- while Last >= 1 and then Line (1) = '#' and then not Main_Found loop if F <= BT_Depth then Find_Name; ! -- Skip the __gnat_malloc frame itself ! if Line (Curs1 .. Curs2) /= "<__gnat_malloc>" then ! Nam := Enter_Name (Line (Curs1 .. Curs2)); ! Main_Found := Line (Curs1 .. Curs2) = "main"; ! Find_File; ! if No_File then ! Fil := No_Name_Id; ! Lin := No_Name_Id; ! else ! Fil := Enter_Name (Line (Curs1 .. Curs2)); ! Find_Line; ! Lin := Enter_Name (Line (Curs1 .. Curs2)); ! end if; ! Frames (F) := Enter_Frame (Nam, Fil, Lin); ! F := F + 1; ! end if; end if; if No_File then diff -Nrc3pad gcc-3.2.3/gcc/ada/memroot.ads gcc-3.3/gcc/ada/memroot.ads *** gcc-3.2.3/gcc/ada/memroot.ads 2001-10-02 13:45:37.000000000 +0000 --- gcc-3.3/gcc/ada/memroot.ads 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1997-2001 Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/memtrack.adb gcc-3.3/gcc/ada/memtrack.adb *** gcc-3.2.3/gcc/ada/memtrack.adb 2002-05-04 03:28:21.000000000 +0000 --- gcc-3.3/gcc/ada/memtrack.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/misc.c gcc-3.3/gcc/ada/misc.c *** gcc-3.2.3/gcc/ada/misc.c 2002-05-04 03:28:21.000000000 +0000 --- gcc-3.3/gcc/ada/misc.c 2002-10-30 17:42:53.000000000 +0000 *************** *** 6,14 **** * * * C Implementation File * * * - * $Revision: 1.17.10.1 $ * * ! * Copyright (C) 1992-2001 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- * --- 6,13 ---- * * * C Implementation File * * * * * ! * Copyright (C) 1992-2002 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- * *************** *** 43,50 **** --- 42,51 ---- #include "errors.h" #include "diagnostic.h" #include "expr.h" + #include "libfuncs.h" #include "ggc.h" #include "flags.h" + #include "debug.h" #include "insn-codes.h" #include "insn-flags.h" #include "insn-config.h" *************** *** 70,80 **** --- 71,140 ---- #include "einfo.h" #include "ada-tree.h" #include "gigi.h" + #include "adadecode.h" extern FILE *asm_out_file; extern int save_argc; extern char **save_argv; + static const char *gnat_init PARAMS ((const char *)); + static void gnat_init_options PARAMS ((void)); + static int gnat_decode_option PARAMS ((int, char **)); + static HOST_WIDE_INT gnat_get_alias_set PARAMS ((tree)); + static void gnat_print_decl PARAMS ((FILE *, tree, int)); + static void gnat_print_type PARAMS ((FILE *, tree, int)); + static const char *gnat_printable_name PARAMS ((tree, int)); + static tree gnat_eh_runtime_type PARAMS ((tree)); + static int gnat_eh_type_covers PARAMS ((tree, tree)); + static void gnat_parse_file PARAMS ((int)); + static rtx gnat_expand_expr PARAMS ((tree, rtx, enum machine_mode, + int)); + + /* Structure giving our language-specific hooks. */ + + #undef LANG_HOOKS_NAME + #define LANG_HOOKS_NAME "GNU Ada" + #undef LANG_HOOKS_IDENTIFIER_SIZE + #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct tree_identifier) + #undef LANG_HOOKS_INIT + #define LANG_HOOKS_INIT gnat_init + #undef LANG_HOOKS_INIT_OPTIONS + #define LANG_HOOKS_INIT_OPTIONS gnat_init_options + #undef LANG_HOOKS_DECODE_OPTION + #define LANG_HOOKS_DECODE_OPTION gnat_decode_option + #undef LANG_HOOKS_PARSE_FILE + #define LANG_HOOKS_PARSE_FILE gnat_parse_file + #undef LANG_HOOKS_HONOR_READONLY + #define LANG_HOOKS_HONOR_READONLY 1 + #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL + #define LANG_HOOKS_FINISH_INCOMPLETE_DECL gnat_finish_incomplete_decl + #undef LANG_HOOKS_GET_ALIAS_SET + #define LANG_HOOKS_GET_ALIAS_SET gnat_get_alias_set + #undef LANG_HOOKS_EXPAND_EXPR + #define LANG_HOOKS_EXPAND_EXPR gnat_expand_expr + #undef LANG_HOOKS_MARK_ADDRESSABLE + #define LANG_HOOKS_MARK_ADDRESSABLE gnat_mark_addressable + #undef LANG_HOOKS_TRUTHVALUE_CONVERSION + #define LANG_HOOKS_TRUTHVALUE_CONVERSION gnat_truthvalue_conversion + #undef LANG_HOOKS_PRINT_DECL + #define LANG_HOOKS_PRINT_DECL gnat_print_decl + #undef LANG_HOOKS_PRINT_TYPE + #define LANG_HOOKS_PRINT_TYPE gnat_print_type + #undef LANG_HOOKS_DECL_PRINTABLE_NAME + #define LANG_HOOKS_DECL_PRINTABLE_NAME gnat_printable_name + #undef LANG_HOOKS_TYPE_FOR_MODE + #define LANG_HOOKS_TYPE_FOR_MODE gnat_type_for_mode + #undef LANG_HOOKS_TYPE_FOR_SIZE + #define LANG_HOOKS_TYPE_FOR_SIZE gnat_type_for_size + #undef LANG_HOOKS_SIGNED_TYPE + #define LANG_HOOKS_SIGNED_TYPE gnat_signed_type + #undef LANG_HOOKS_UNSIGNED_TYPE + #define LANG_HOOKS_UNSIGNED_TYPE gnat_unsigned_type + #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE + #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE gnat_signed_or_unsigned_type + + const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; + /* Tables describing GCC tree codes used only by GNAT. Table indexed by tree code giving a string containing a character *************** extern char **save_argv; *** 83,89 **** #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, ! static char const gnat_tree_code_type[] = { 'x', #include "ada-tree.def" }; --- 143,150 ---- #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, ! const char tree_code_type[] = { ! #include "tree.def" 'x', #include "ada-tree.def" }; *************** static char const gnat_tree_code_type[] *** 95,101 **** #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, ! static int const gnat_tree_code_length[] = { 0, #include "ada-tree.def" }; --- 156,163 ---- #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, ! const unsigned char tree_code_length[] = { ! #include "tree.def" 0, #include "ada-tree.def" }; *************** static int const gnat_tree_code_length[] *** 105,181 **** Used for printing out the tree and error messages. */ #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME, ! static const char *gnat_tree_code_name[] = { "@@dummy", #include "ada-tree.def" }; #undef DEFTREECODE - static const char *gnat_init PARAMS ((const char *)); - static void gnat_init_options PARAMS ((void)); - static int gnat_decode_option PARAMS ((int, char **)); - static HOST_WIDE_INT gnat_get_alias_set PARAMS ((tree)); - static void gnat_print_decl PARAMS ((FILE *, tree, int)); - static void gnat_print_type PARAMS ((FILE *, tree, int)); - extern void gnat_init_decl_processing PARAMS ((void)); - static tree gnat_expand_constant PARAMS ((tree)); - - /* Structure giving our language-specific hooks. */ - - #undef LANG_HOOKS_NAME - #define LANG_HOOKS_NAME "GNU Ada" - #undef LANG_HOOKS_IDENTIFIER_SIZE - #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct tree_identifier) - #undef LANG_HOOKS_INIT - #define LANG_HOOKS_INIT gnat_init - #undef LANG_HOOKS_INIT_OPTIONS - #define LANG_HOOKS_INIT_OPTIONS gnat_init_options - #undef LANG_HOOKS_DECODE_OPTION - #define LANG_HOOKS_DECODE_OPTION gnat_decode_option - #undef LANG_HOOKS_HONOR_READONLY - #define LANG_HOOKS_HONOR_READONLY 1 - #undef LANG_HOOKS_GET_ALIAS_SET - #define LANG_HOOKS_GET_ALIAS_SET gnat_get_alias_set - #undef LANG_HOOKS_PRINT_DECL - #define LANG_HOOKS_PRINT_DECL gnat_print_decl - #undef LANG_HOOKS_PRINT_TYPE - #define LANG_HOOKS_PRINT_TYPE gnat_print_type - #undef LANG_HOOKS_EXPAND_CONSTANT - #define LANG_HOOKS_EXPAND_CONSTANT gnat_expand_constant - - const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; - /* gnat standard argc argv */ extern int gnat_argc; extern char **gnat_argv; - /* Global Variables Expected by gcc: */ - - int flag_traditional; /* Used by dwarfout.c. */ - int ggc_p = 1; - static void internal_error_function PARAMS ((const char *, va_list *)); - static rtx gnat_expand_expr PARAMS ((tree, rtx, enum machine_mode, - enum expand_modifier)); static void gnat_adjust_rli PARAMS ((record_layout_info)); - - #if defined(MIPS_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO) - static char *convert_ada_name_to_qualified_name PARAMS ((char *)); - #endif - /* Routines Expected by gcc: */ - - /* For most front-ends, this is the parser for the language. For us, we - process the GNAT tree. */ - /* Declare functions we use as part of startup. */ extern void __gnat_initialize PARAMS((void)); extern void adainit PARAMS((void)); extern void _ada_gnat1drv PARAMS((void)); ! int ! yyparse () { /* call the target specific initializations */ __gnat_initialize(); --- 167,197 ---- Used for printing out the tree and error messages. */ #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME, ! const char *const tree_code_name[] = { ! #include "tree.def" "@@dummy", #include "ada-tree.def" }; #undef DEFTREECODE /* gnat standard argc argv */ extern int gnat_argc; extern char **gnat_argv; static void internal_error_function PARAMS ((const char *, va_list *)); static void gnat_adjust_rli PARAMS ((record_layout_info)); /* Declare functions we use as part of startup. */ extern void __gnat_initialize PARAMS((void)); extern void adainit PARAMS((void)); extern void _ada_gnat1drv PARAMS((void)); ! /* The parser for the language. For us, we process the GNAT tree. */ ! ! static void ! gnat_parse_file (set_yydebug) ! int set_yydebug ATTRIBUTE_UNUSED; { /* call the target specific initializations */ __gnat_initialize(); *************** yyparse () *** 187,194 **** /* Call the front end */ _ada_gnat1drv (); - - return 0; } /* Decode all the language specific options that cannot be decoded by GCC. --- 203,208 ---- *************** gnat_decode_option (argc, argv) *** 214,223 **** else if (!strncmp (p, "-gant", 5)) { ! char *q = (char *) xmalloc (strlen (p) + 1); warning ("`-gnat' misspelled as `-gant'"); - strcpy (q, p); q[2] = 'n', q[3] = 'a'; p = q; return 1; --- 228,236 ---- else if (!strncmp (p, "-gant", 5)) { ! char *q = xstrdup (p); warning ("`-gnat' misspelled as `-gant'"); q[2] = 'n', q[3] = 'a'; p = q; return 1; *************** gnat_decode_option (argc, argv) *** 245,250 **** --- 258,272 ---- return 1; } + /* Handle the --RTS switch. The real option we get is -fRTS. This + modification is done by the driver program. */ + if (!strncmp (p, "-fRTS", 5)) + { + gnat_argv[gnat_argc] = p; + gnat_argc ++; + return 1; + } + /* Ignore -W flags since people may want to use the same flags for all languages. */ else if (p[0] == '-' && p[1] == 'W' && p[2] != 0) *************** gnat_init_options () *** 260,317 **** { /* Initialize gnat_argv with save_argv size */ gnat_argv = (char **) xmalloc ((save_argc + 1) * sizeof (gnat_argv[0])); ! gnat_argv [0] = save_argv[0]; /* name of the command */ gnat_argc = 1; } ! void ! lang_mark_tree (t) ! tree t; ! { ! switch (TREE_CODE (t)) ! { ! case FUNCTION_TYPE: ! ggc_mark_tree (TYPE_CI_CO_LIST (t)); ! return; ! ! case INTEGER_TYPE: ! if (TYPE_MODULAR_P (t)) ! ggc_mark_tree (TYPE_MODULUS (t)); ! else if (TYPE_VAX_FLOATING_POINT_P (t)) ! ; ! else if (TYPE_HAS_ACTUAL_BOUNDS_P (t)) ! ggc_mark_tree (TYPE_ACTUAL_BOUNDS (t)); ! else ! ggc_mark_tree (TYPE_INDEX_TYPE (t)); ! return; ! ! case ENUMERAL_TYPE: ! ggc_mark_tree (TYPE_RM_SIZE_ENUM (t)); ! return; ! ! case ARRAY_TYPE: ! ggc_mark_tree (TYPE_ACTUAL_BOUNDS (t)); ! return; ! ! case RECORD_TYPE: case UNION_TYPE: case QUAL_UNION_TYPE: ! /* This is really TYPE_UNCONSTRAINED_ARRAY for fat pointers. */ ! ggc_mark_tree (TYPE_ADA_SIZE (t)); ! return; ! ! case CONST_DECL: ! ggc_mark_tree (DECL_CONST_CORRESPONDING_VAR (t)); ! return; ! ! case FIELD_DECL: ! ggc_mark_tree (DECL_ORIGINAL_FIELD (t)); ! return; ! ! default: ! return; ! } ! } ! ! /* Here we have the function to handle the compiler error processing in GCC. */ static void internal_error_function (msgid, ap) --- 282,292 ---- { /* Initialize gnat_argv with save_argv size */ gnat_argv = (char **) xmalloc ((save_argc + 1) * sizeof (gnat_argv[0])); ! gnat_argv[0] = save_argv[0]; /* name of the command */ gnat_argc = 1; } ! /* Here is the function to handle the compiler error processing in GCC. */ static void internal_error_function (msgid, ap) *************** static const char * *** 346,419 **** gnat_init (filename) const char *filename; { ! /* Performs whatever initialization steps needed by the language-dependent ! lexical analyzer. ! ! Define the additional tree codes here. This isn't the best place to put ! it, but it's where g++ does it. */ ! ! lang_expand_expr = gnat_expand_expr; ! ! memcpy ((char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE), ! (char *) gnat_tree_code_type, ! ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE) ! * sizeof (char *))); ! ! memcpy ((char *) (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE), ! (char *) gnat_tree_code_length, ! ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE) ! * sizeof (int))); ! memcpy ((char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE), ! (char *) gnat_tree_code_name, ! ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE) ! * sizeof (char *))); gnat_init_decl_processing (); /* Add the input filename as the last argument. */ ! gnat_argv [gnat_argc] = (char *) filename; gnat_argc++; ! gnat_argv [gnat_argc] = 0; ! set_internal_error_function (internal_error_function); /* Show that REFERENCE_TYPEs are internal and should be Pmode. */ internal_reference_types (); - /* Show we don't use the common language attributes. */ - lang_attribute_common = 0; - set_lang_adjust_rli (gnat_adjust_rli); - #if defined(MIPS_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO) - dwarf2out_set_demangle_name_func (convert_ada_name_to_qualified_name); - #endif - if (filename == 0) filename = ""; return filename; } ! /* If DECL has a cleanup, build and return that cleanup here. ! This is a callback called by expand_expr. */ ! tree ! maybe_build_cleanup (decl) ! tree decl ATTRIBUTE_UNUSED; { ! /* There are no cleanups in C. */ ! return NULL_TREE; ! } ! /* integrate_decl_tree calls this function, but since we don't use the ! DECL_LANG_SPECIFIC field, this is a no-op. */ ! void ! copy_lang_decl (node) ! tree node ATTRIBUTE_UNUSED; ! { } /* Hooks for print-tree.c: */ --- 321,376 ---- gnat_init (filename) const char *filename; { ! /* Performs whatever initialization steps needed by the language-dependent ! lexical analyzer. ! Define the additional tree codes here. This isn't the best place to put ! it, but it's where g++ does it. */ gnat_init_decl_processing (); /* Add the input filename as the last argument. */ ! gnat_argv[gnat_argc] = (char *) filename; gnat_argc++; ! gnat_argv[gnat_argc] = 0; ! global_dc->internal_error = &internal_error_function; /* Show that REFERENCE_TYPEs are internal and should be Pmode. */ internal_reference_types (); set_lang_adjust_rli (gnat_adjust_rli); if (filename == 0) filename = ""; return filename; } ! /* If we are using the GCC mechanism for to process exception handling, we ! have to register the personality routine for Ada and to initialize ! various language dependent hooks. */ ! void ! gnat_init_gcc_eh () { ! /* We shouldn't do anything if the No_Exceptions_Handler pragma is set, ! though. This could for instance lead to the emission of tables with ! references to symbols (such as the Ada eh personality routine) within ! libraries we won't link against. */ ! if (No_Exception_Handlers_Set ()) ! return; ! eh_personality_libfunc = init_one_libfunc ("__gnat_eh_personality"); ! lang_eh_type_covers = gnat_eh_type_covers; ! lang_eh_runtime_type = gnat_eh_runtime_type; ! flag_exceptions = 1; ! init_eh (); ! #ifdef DWARF2_UNWIND_INFO ! if (dwarf2out_do_frame ()) ! dwarf2out_frame_init (); ! #endif } /* Hooks for print-tree.c: */ *************** gnat_print_type (file, node, indent) *** 493,514 **** } } /* Expands GNAT-specific GCC tree nodes. The only ones we support ! here are TRANSFORM_EXPR, UNCHECKED_CONVERT_EXPR, ALLOCATE_EXPR, ! USE_EXPR and NULL_EXPR. */ static rtx gnat_expand_expr (exp, target, tmode, modifier) tree exp; rtx target; enum machine_mode tmode; ! enum expand_modifier modifier; { tree type = TREE_TYPE (exp); - tree inner_type; tree new; rtx result; - int align_ok; /* Update EXP to be the new expression to expand. */ --- 450,481 ---- } } + static const char * + gnat_printable_name (decl, verbosity) + tree decl; + int verbosity ATTRIBUTE_UNUSED; + { + const char *coded_name = IDENTIFIER_POINTER (DECL_NAME (decl)); + char *ada_name = (char *) ggc_alloc (strlen (coded_name) * 2 + 60); + + __gnat_decode (coded_name, ada_name, 0); + + return (const char *) ada_name; + } + /* Expands GNAT-specific GCC tree nodes. The only ones we support ! here are TRANSFORM_EXPR, ALLOCATE_EXPR, USE_EXPR and NULL_EXPR. */ static rtx gnat_expand_expr (exp, target, tmode, modifier) tree exp; rtx target; enum machine_mode tmode; ! int modifier; /* Actually an enum expand_modifier. */ { tree type = TREE_TYPE (exp); tree new; rtx result; /* Update EXP to be the new expression to expand. */ *************** gnat_expand_expr (exp, target, tmode, mo *** 519,639 **** return const0_rtx; break; - case UNCHECKED_CONVERT_EXPR: - inner_type = TREE_TYPE (TREE_OPERAND (exp, 0)); - - /* The alignment is OK if the flag saying it is OK is set in either - type, if the inner type is already maximally aligned, if the - new type is no more strictly aligned than the old type, or - if byte accesses are not slow. */ - align_ok = (! SLOW_BYTE_ACCESS - || TYPE_ALIGN_OK_P (type) || TYPE_ALIGN_OK_P (inner_type) - || TYPE_ALIGN (inner_type) >= BIGGEST_ALIGNMENT - || TYPE_ALIGN (type) <= TYPE_ALIGN (inner_type)); - - /* If we're converting between an aggregate and non-aggregate type - and we have a MEM TARGET, we can't use it, since MEM_IN_STRUCT_P - would be set incorrectly. */ - if (target != 0 && GET_CODE (target) == MEM - && (MEM_IN_STRUCT_P (target) != AGGREGATE_TYPE_P (inner_type))) - target = 0; - - /* If the input and output are both the same mode (usually BLKmode), - just return the expanded input since we want just the bits. But - we can't do this if the output is more strictly aligned than - the input or if the type is BLKmode and the sizes differ. */ - if (TYPE_MODE (type) == TYPE_MODE (inner_type) - && align_ok - && ! (TYPE_MODE (type) == BLKmode - && ! operand_equal_p (TYPE_SIZE (type), - TYPE_SIZE (inner_type), 0))) - { - new = TREE_OPERAND (exp, 0); - - /* If the new type is less strictly aligned than the inner type, - make a new type with the less strict alignment just for - code generation purposes of this node. If it is a decl, - we can't change the type, so make a NOP_EXPR. */ - if (TYPE_ALIGN (type) != TYPE_ALIGN (inner_type)) - { - tree copy_type = copy_node (inner_type); - - TYPE_ALIGN (copy_type) = TYPE_ALIGN (type); - if (DECL_P (new)) - new = build1 (NOP_EXPR, copy_type, new); - else - { - /* If NEW is a constant, it might be coming from a CONST_DECL - and hence shared. */ - if (TREE_CONSTANT (new)) - new = copy_node (new); - - TREE_TYPE (new) = copy_type; - } - } - } - - /* If either mode is BLKmode, memory will be involved, so do this - via pointer punning. Likewise, this doesn't work if there - is an alignment issue. But we must do it for types that are known - to be aligned properly. */ - else if ((TYPE_MODE (type) == BLKmode - || TYPE_MODE (inner_type) == BLKmode) - && align_ok) - new = build_unary_op (INDIRECT_REF, NULL_TREE, - convert - (build_pointer_type (type), - build_unary_op (ADDR_EXPR, NULL_TREE, - TREE_OPERAND (exp, 0)))); - - /* Otherwise make a union of the two types, convert to the union, and - extract the other value. */ - else - { - tree union_type, in_field, out_field; - - /* If this is inside the LHS of an assignment, this would generate - bad code, so abort. */ - if (TREE_ADDRESSABLE (exp)) - gigi_abort (202); - - union_type = make_node (UNION_TYPE); - in_field = create_field_decl (get_identifier ("in"), - inner_type, union_type, 0, 0, 0, 0); - out_field = create_field_decl (get_identifier ("out"), - type, union_type, 0, 0, 0, 0); - - TYPE_FIELDS (union_type) = chainon (in_field, out_field); - layout_type (union_type); - - /* Though this is a "union", we can treat its size as that of - the output type in case the size of the input type is variable. - If the output size is a variable, use the input size. */ - TYPE_SIZE (union_type) = TYPE_SIZE (type); - TYPE_SIZE_UNIT (union_type) = TYPE_SIZE (type); - if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST - && TREE_CODE (TYPE_SIZE (inner_type)) == INTEGER_CST) - { - TYPE_SIZE (union_type) = TYPE_SIZE (inner_type); - TYPE_SIZE_UNIT (union_type) = TYPE_SIZE_UNIT (inner_type); - } - - new = build (COMPONENT_REF, type, - build1 (CONVERT_EXPR, union_type, - TREE_OPERAND (exp, 0)), - out_field); - } - - result = expand_expr (new, target, tmode, modifier); - - if (GET_CODE (result) == MEM) - { - /* Update so it looks like this is of the proper type. */ - set_mem_alias_set (result, 0); - set_mem_attributes (result, exp, 0); - } - return result; - case NULL_EXPR: expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0); --- 486,491 ---- *************** gnat_expand_expr (exp, target, tmode, mo *** 689,714 **** return expand_expr (new, target, tmode, modifier); } - /* Transform a constant into a form that the language-independent code - can handle. */ - - static tree - gnat_expand_constant (exp) - tree exp; - { - /* If this is an unchecked conversion that does not change the size of the - object and the object is not a CONSTRUCTOR return the operand since the - underlying constant is still the same. Otherwise, return our operand. */ - if (TREE_CODE (exp) == UNCHECKED_CONVERT_EXPR - && operand_equal_p (TYPE_SIZE_UNIT (TREE_TYPE (exp)), - TYPE_SIZE_UNIT (TREE_TYPE (TREE_OPERAND (exp, 0))), - 1) - && TREE_CODE (TREE_OPERAND (exp, 0)) != CONSTRUCTOR) - return TREE_OPERAND (exp, 0); - - return exp; - } - /* Adjusts the RLI used to layout a record after all the fields have been added. We only handle the packed case and cause it to use the alignment that will pad the record at the end. */ --- 541,546 ---- *************** static void *** 717,724 **** gnat_adjust_rli (rli) record_layout_info rli; { if (TYPE_PACKED (rli->t)) ! rli->record_align = rli->unpadded_align; } /* Make a TRANSFORM_EXPR to later expand GNAT_NODE into code. */ --- 549,565 ---- gnat_adjust_rli (rli) record_layout_info rli; { + unsigned int record_align = rli->unpadded_align; + tree field; + + /* If any fields have variable size, we need to force the record to be at + least as aligned as the alignment of that type. */ + for (field = TYPE_FIELDS (rli->t); field; field = TREE_CHAIN (field)) + if (TREE_CODE (DECL_SIZE_UNIT (field)) != INTEGER_CST) + record_align = MAX (record_align, DECL_ALIGN (field)); + if (TYPE_PACKED (rli->t)) ! rli->record_align = record_align; } /* Make a TRANSFORM_EXPR to later expand GNAT_NODE into code. */ *************** update_setjmp_buf (buf) *** 746,754 **** #ifdef HAVE_save_stack_nonlocal if (HAVE_save_stack_nonlocal) ! sa_mode = insn_data [(int) CODE_FOR_save_stack_nonlocal].operand[0].mode; #endif - #ifdef STACK_SAVEAREA_MODE sa_mode = STACK_SAVEAREA_MODE (SAVE_NONLOCAL); #endif --- 587,594 ---- #ifdef HAVE_save_stack_nonlocal if (HAVE_save_stack_nonlocal) ! sa_mode = insn_data[(int) CODE_FOR_save_stack_nonlocal].operand[0].mode; #endif #ifdef STACK_SAVEAREA_MODE sa_mode = STACK_SAVEAREA_MODE (SAVE_NONLOCAL); #endif *************** update_setjmp_buf (buf) *** 770,775 **** --- 610,641 ---- emit_stack_save (SAVE_NONLOCAL, &stack_save, NULL_RTX); } + /* These routines are used in conjunction with GCC exception handling. */ + + /* Map compile-time to run-time tree for GCC exception handling scheme. */ + + static tree + gnat_eh_runtime_type (type) + tree type; + { + return type; + } + + /* Return true if type A catches type B. Callback for flow analysis from + the exception handling part of the back-end. */ + + static int + gnat_eh_type_covers (a, b) + tree a, b; + { + /* a catches b if they represent the same exception id or if a + is an "others". + + ??? integer_zero_node for "others" is hardwired in too many places + currently. */ + return (a == b || a == integer_zero_node); + } + /* See if DECL has an RTL that is indirect via a pseudo-register or a memory location and replace it with an indirect reference if so. This improves the debugger's ability to display the value. */ *************** insert_code_for (gnat_node) *** 871,897 **** { rtx insns; start_sequence (); mark_all_temps_used (); gnat_to_code (gnat_node); insns = get_insns (); end_sequence (); ! emit_insns_after (insns, RTL_EXPR_RTL (get_gnu_tree (gnat_node))); } } - #if 0 - - /* Return the alignment for GNAT_TYPE. */ - - unsigned int - get_type_alignment (gnat_type) - Entity_Id gnat_type; - { - return TYPE_ALIGN (gnat_to_gnu_type (gnat_type)) / BITS_PER_UNIT; - } - #endif - /* Get the alias set corresponding to a type or expression. */ static HOST_WIDE_INT --- 737,753 ---- { rtx insns; + do_pending_stack_adjust (); start_sequence (); mark_all_temps_used (); gnat_to_code (gnat_node); + do_pending_stack_adjust (); insns = get_insns (); end_sequence (); ! emit_insn_after (insns, RTL_EXPR_RTL (get_gnu_tree (gnat_node))); } } /* Get the alias set corresponding to a type or expression. */ static HOST_WIDE_INT *************** gnat_get_alias_set (type) *** 903,917 **** && TYPE_IS_PADDING_P (type)) return get_alias_set (TREE_TYPE (TYPE_FIELDS (type))); ! return -1; ! } - /* Set default attributes for functions. We do nothing. */ ! void ! insert_default_attributes (decl) ! tree decl ATTRIBUTE_UNUSED; ! { } /* GNU_TYPE is a type. Determine if it should be passed by reference by --- 759,772 ---- && TYPE_IS_PADDING_P (type)) return get_alias_set (TREE_TYPE (TYPE_FIELDS (type))); ! /* If the type is an unconstrained array, use the type of the ! self-referential array we make. */ ! else if (TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) ! return ! get_alias_set (TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (type))))); ! return -1; } /* GNU_TYPE is a type. Determine if it should be passed by reference by *************** must_pass_by_ref (gnu_type) *** 960,1058 **** || (TYPE_SIZE (gnu_type) != 0 && TREE_CODE (TYPE_SIZE (gnu_type)) != INTEGER_CST)); } - - #if defined(MIPS_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO) - - /* Convert NAME, which is possibly an Ada name, back to standard Ada - notation for SGI Workshop. */ - - static char * - convert_ada_name_to_qualified_name (name) - char *name; - { - int len = strlen (name); - char *new_name = xstrdup (name); - char *buf; - int i, start; - char *qual_name_suffix = 0; - char *p; - - if (len <= 3 || use_gnu_debug_info_extensions) - { - free (new_name); - return name; - } - - /* Find the position of the first "__" after the first character of - NAME. This is the same as calling strstr except that we can't assume - the host has that function. We start after the first character so - we don't eliminate leading "__": these are emitted only by C - programs and are not qualified names */ - for (p = (char *) index (&name[1], '_'); p != 0; - p = (char *) index (p+1, '_')) - if (p[1] == '_') - { - qual_name_suffix = p; - break; - } - - if (qual_name_suffix == 0) - { - free (new_name); - return name; - } - - start = qual_name_suffix - name; - buf = new_name + start; - - for (i = start; i < len; i++) - { - if (name[i] == '_' && name[i + 1] == '_') - { - if (islower (name[i + 2])) - { - *buf++ = '.'; - *buf++ = name[i + 2]; - i += 2; - } - else if (name[i + 2] == '_' && islower (name[i + 3])) - { - /* convert foo___c___XVN to foo.c___XVN */ - *buf++ = '.'; - *buf++ = name[i + 3]; - i += 3; - } - else if (name[i + 2] == 'T') - { - /* convert foo__TtypeS to foo.__TTypeS */ - *buf++ = '.'; - *buf++ = '_'; - *buf++ = '_'; - *buf++ = 'T'; - i += 3; - } - else - *buf++ = name[i]; - } - else - *buf++ = name[i]; - } - - *buf = 0; - return new_name; - } - #endif ! /* Emit a label UNITNAME_LABEL and specify that it is part of source ! file FILENAME. If this is being written for SGI's Workshop ! debugger, and we are writing Dwarf2 debugging information, add ! additional debug info. */ ! void ! emit_unit_label (unitname_label, filename) ! char *unitname_label; ! char *filename ATTRIBUTE_UNUSED; { ! ASM_GLOBALIZE_LABEL (asm_out_file, unitname_label); ! ASM_OUTPUT_LABEL (asm_out_file, unitname_label); } --- 815,825 ---- || (TYPE_SIZE (gnu_type) != 0 && TREE_CODE (TYPE_SIZE (gnu_type)) != INTEGER_CST)); } ! /* This function returns the version of GCC being used. Here it's GCC 3. */ ! int ! gcc_version () { ! return 3; } diff -Nrc3pad gcc-3.2.3/gcc/ada/mkdir.c gcc-3.3/gcc/ada/mkdir.c *** gcc-3.2.3/gcc/ada/mkdir.c 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/mkdir.c 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,52 ---- + /**************************************************************************** + * * + * GNAT COMPILER COMPONENTS * + * * + * M K D I R * + * * + * * + * C Implementation File * + * * + * Copyright (C) 2002, 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- * + * 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, 59 Temple Place - Suite 330, Boston, * + * MA 02111-1307, USA. * + * * + * As a special exception, if you link this file with other files to * + * produce an executable, this file does not by itself cause the resulting * + * executable to be covered by the GNU General Public License. This except- * + * ion does not however invalidate any other reasons why the executable * + * file might be covered by the GNU Public License. * + * * + * GNAT was originally developed by the GNAT team at New York University. * + * Extensive contributions were provided by Ada Core Technologies Inc. * + * * + ****************************************************************************/ + + /* This file provides a portable binding to the mkdir() function */ + + #ifdef __vxworks + #include "vxWorks.h" + #endif /* __vxworks */ + + #include + #include + + int + __gnat_mkdir (dir_name) + char *dir_name; + { + #if defined (_WIN32) || defined (__vxworks) + return mkdir (dir_name); + #else + return mkdir (dir_name, S_IRWXU | S_IRWXG | S_IRWXO); + #endif + } diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib.adb gcc-3.3/gcc/ada/mlib.adb *** gcc-3.2.3/gcc/ada/mlib.adb 2001-10-02 13:45:38.000000000 +0000 --- gcc-3.3/gcc/ada/mlib.adb 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1999-2001, Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- *************** package body MLib is *** 46,51 **** --- 45,52 ---- Output_File : String; Output_Dir : String) is + pragma Warnings (Off, Afiles); + use GNAT.OS_Lib; begin diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib.ads gcc-3.3/gcc/ada/mlib.ads *** gcc-3.2.3/gcc/ada/mlib.ads 2001-10-02 13:45:38.000000000 +0000 --- gcc-3.3/gcc/ada/mlib.ads 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1999-2001, Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib-fil.adb gcc-3.3/gcc/ada/mlib-fil.adb *** gcc-3.2.3/gcc/ada/mlib-fil.adb 2001-10-02 13:45:38.000000000 +0000 --- gcc-3.3/gcc/ada/mlib-fil.adb 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001, Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib-fil.ads gcc-3.3/gcc/ada/mlib-fil.ads *** gcc-3.2.3/gcc/ada/mlib-fil.ads 2001-12-12 21:26:44.000000000 +0000 --- gcc-3.3/gcc/ada/mlib-fil.ads 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3 $ -- -- -- Copyright (C) 2001, Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib-prj.adb gcc-3.3/gcc/ada/mlib-prj.adb *** gcc-3.2.3/gcc/ada/mlib-prj.adb 2001-10-02 13:45:38.000000000 +0000 --- gcc-3.3/gcc/ada/mlib-prj.adb 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001, Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib-prj.ads gcc-3.3/gcc/ada/mlib-prj.ads *** gcc-3.2.3/gcc/ada/mlib-prj.ads 2001-10-02 13:45:38.000000000 +0000 --- gcc-3.3/gcc/ada/mlib-prj.ads 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001, Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib-tgt.adb gcc-3.3/gcc/ada/mlib-tgt.adb *** gcc-3.2.3/gcc/ada/mlib-tgt.adb 2001-10-02 13:45:38.000000000 +0000 --- gcc-3.3/gcc/ada/mlib-tgt.adb 2002-03-14 10:59:31.000000000 +0000 *************** *** 7,13 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001, Ada Core Technologies, Inc. -- -- -- --- 7,12 ---- *************** *** 33,38 **** --- 32,39 ---- package body MLib.Tgt is + pragma Warnings (Off); -- stop warnings on unreferenced formals + ----------------- -- Archive_Ext -- ----------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib-tgt.ads gcc-3.3/gcc/ada/mlib-tgt.ads *** gcc-3.2.3/gcc/ada/mlib-tgt.ads 2001-10-02 13:45:38.000000000 +0000 --- gcc-3.3/gcc/ada/mlib-tgt.ads 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 2001, Ada Core Technologies, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib-utl.adb gcc-3.3/gcc/ada/mlib-utl.adb *** gcc-3.2.3/gcc/ada/mlib-utl.adb 2001-10-02 13:45:38.000000000 +0000 --- gcc-3.3/gcc/ada/mlib-utl.adb 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 2001, Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2002, Ada Core Technologies, 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- -- *************** package body MLib.Utl is *** 140,147 **** procedure Gcc (Output_File : String; Objects : Argument_List; ! Options : Argument_List; ! Base_File : String := "") is Arguments : OS_Lib.Argument_List (1 .. 7 + Objects'Length + Options'Length); --- 139,145 ---- procedure Gcc (Output_File : String; Objects : Argument_List; ! Options : Argument_List) is Arguments : OS_Lib.Argument_List (1 .. 7 + Objects'Length + Options'Length); *************** package body MLib.Utl is *** 163,168 **** --- 161,167 ---- A := A + 1; Arguments (A) := Out_Opt; + A := A + 1; Arguments (A) := Out_V; diff -Nrc3pad gcc-3.2.3/gcc/ada/mlib-utl.ads gcc-3.3/gcc/ada/mlib-utl.ads *** gcc-3.2.3/gcc/ada/mlib-utl.ads 2001-10-02 13:45:38.000000000 +0000 --- gcc-3.3/gcc/ada/mlib-utl.ads 2002-03-14 10:59:31.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 2001, Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 2001-2002, Ada Core Technologies, 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- -- *************** package MLib.Utl is *** 37,44 **** procedure Gcc (Output_File : String; Objects : Argument_List; ! Options : Argument_List; ! Base_File : String := ""); -- Invoke gcc to create a library. procedure Ar --- 36,42 ---- procedure Gcc (Output_File : String; Objects : Argument_List; ! Options : Argument_List); -- Invoke gcc to create a library. procedure Ar diff -Nrc3pad gcc-3.2.3/gcc/ada/namet.adb gcc-3.3/gcc/ada/namet.adb *** gcc-3.2.3/gcc/ada/namet.adb 2002-05-04 03:28:21.000000000 +0000 --- gcc-3.3/gcc/ada/namet.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Namet is *** 78,84 **** pragma Inline (Hash); -- Compute hash code for name stored in Name_Buffer (length in Name_Len) ! procedure Strip_Qualification_And_Package_Body_Suffix; -- Given an encoded entity name in Name_Buffer, remove package body -- suffix as described for Strip_Package_Body_Suffix, and also remove -- all qualification, i.e. names followed by two underscores. The --- 77,83 ---- pragma Inline (Hash); -- Compute hash code for name stored in Name_Buffer (length in Name_Len) ! procedure Strip_Qualification_And_Suffixes; -- Given an encoded entity name in Name_Buffer, remove package body -- suffix as described for Strip_Package_Body_Suffix, and also remove -- all qualification, i.e. names followed by two underscores. The *************** package body Namet is *** 589,595 **** procedure Get_Unqualified_Decoded_Name_String (Id : Name_Id) is begin Get_Decoded_Name_String (Id); ! Strip_Qualification_And_Package_Body_Suffix; end Get_Unqualified_Decoded_Name_String; --------------------------------- --- 588,594 ---- procedure Get_Unqualified_Decoded_Name_String (Id : Name_Id) is begin Get_Decoded_Name_String (Id); ! Strip_Qualification_And_Suffixes; end Get_Unqualified_Decoded_Name_String; --------------------------------- *************** package body Namet is *** 599,605 **** procedure Get_Unqualified_Name_String (Id : Name_Id) is begin Get_Name_String (Id); ! Strip_Qualification_And_Package_Body_Suffix; end Get_Unqualified_Name_String; ---------- --- 598,604 ---- procedure Get_Unqualified_Name_String (Id : Name_Id) is begin Get_Name_String (Id); ! Strip_Qualification_And_Suffixes; end Get_Unqualified_Name_String; ---------- *************** package body Namet is *** 1105,1115 **** end Store_Encoded_Character; ! ------------------------------------------------- ! -- Strip_Qualification_And_Package_Body_Suffix -- ! ------------------------------------------------- - procedure Strip_Qualification_And_Package_Body_Suffix is begin -- Strip package body qualification string off end --- 1104,1116 ---- end Store_Encoded_Character; ! -------------------------------------- ! -- Strip_Qualification_And_Suffixes -- ! -------------------------------------- ! ! procedure Strip_Qualification_And_Suffixes is ! J : Integer; begin -- Strip package body qualification string off end *************** package body Namet is *** 1124,1141 **** and then Name_Buffer (J) /= 'p'; end loop; ! -- Find rightmost __ separator if one exists and strip it ! -- and everything that precedes it from the name. ! for J in reverse 2 .. Name_Len - 2 loop ! if Name_Buffer (J) = '_' and then Name_Buffer (J + 1) = '_' then ! Name_Buffer (1 .. Name_Len - J - 1) := ! Name_Buffer (J + 2 .. Name_Len); ! Name_Len := Name_Len - J - 1; ! exit; end if; end loop; ! end Strip_Qualification_And_Package_Body_Suffix; --------------- -- Tree_Read -- --- 1125,1167 ---- and then Name_Buffer (J) /= 'p'; end loop; ! -- Find rightmost __ or $ separator if one exists ! J := Name_Len - 1; ! while J > 1 loop ! ! -- If $ separator, homonym separator, so strip it and keep looking ! ! if Name_Buffer (J) = '$' then ! Name_Len := J - 1; ! J := Name_Len - 1; ! ! -- Else check for __ found ! ! elsif Name_Buffer (J) = '_' and then Name_Buffer (J + 1) = '_' then ! ! -- Found __ so see if digit follows, and if so, this is a ! -- homonym separator, so strip it and keep looking. ! ! if Name_Buffer (J + 2) in '0' .. '9' then ! Name_Len := J - 1; ! J := Name_Len - 1; ! ! -- If not a homonym separator, then we simply strip the ! -- separator and everything that precedes it, and we are done ! ! else ! Name_Buffer (1 .. Name_Len - J - 1) := ! Name_Buffer (J + 2 .. Name_Len); ! Name_Len := Name_Len - J - 1; ! exit; ! end if; ! ! else ! J := J - 1; end if; end loop; ! end Strip_Qualification_And_Suffixes; --------------- -- Tree_Read -- diff -Nrc3pad gcc-3.2.3/gcc/ada/namet.ads gcc-3.3/gcc/ada/namet.ads *** gcc-3.2.3/gcc/ada/namet.ads 2002-05-04 03:28:21.000000000 +0000 --- gcc-3.3/gcc/ada/namet.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Namet is *** 148,158 **** procedure Get_Unqualified_Name_String (Id : Name_Id); -- Similar to the above except that qualification (as defined in unit -- Exp_Dbug) is removed (including both preceding __ delimited names, ! -- and also the suffix used to indicate package body entities). Note ! -- that names are not qualified until just before the call to gigi, so ! -- this routine is only needed by processing that occurs after gigi has ! -- been called. This includes all ASIS processing, since ASIS works on ! -- the tree written after gigi has been called. procedure Get_Name_String_And_Append (Id : Name_Id); -- Like Get_Name_String but the resulting characters are appended to --- 147,158 ---- procedure Get_Unqualified_Name_String (Id : Name_Id); -- Similar to the above except that qualification (as defined in unit -- Exp_Dbug) is removed (including both preceding __ delimited names, ! -- and also the suffixes used to indicate package body entities and to ! -- distinguish between overloaded entities). Note that names are not ! -- qualified until just before the call to gigi, so this routine is ! -- only needed by processing that occurs after gigi has been called. ! -- This includes all ASIS processing, since ASIS works on the tree ! -- written after gigi has been called. procedure Get_Name_String_And_Append (Id : Name_Id); -- Like Get_Name_String but the resulting characters are appended to *************** package Namet is *** 335,340 **** --- 335,341 ---- -- the name table). If Id is Error_Name, or No_Name, no text is output. procedure wn (Id : Name_Id); + pragma Export (Ada, wn); -- Like Write_Name, but includes new line at end. Intended for use -- from the debugger only. diff -Nrc3pad gcc-3.2.3/gcc/ada/namet.h gcc-3.3/gcc/ada/namet.h *** gcc-3.2.3/gcc/ada/namet.h 2002-05-04 03:28:21.000000000 +0000 --- gcc-3.3/gcc/ada/namet.h 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,14 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * ! * Copyright (C) 1992-2001 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- * --- 6,13 ---- * * * C Header File * * * * * ! * Copyright (C) 1992-2002 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- * *************** INLINE char * *** 67,73 **** Get_Name_String (Id) Name_Id Id; { ! return Name_Chars_Ptr + Names_Ptr [Id - First_Name_Id].Name_Chars_Index + 1; } /* Get_Decoded_Name_String returns a null terminated C string in the same --- 66,72 ---- Get_Name_String (Id) Name_Id Id; { ! return Name_Chars_Ptr + Names_Ptr[Id - First_Name_Id].Name_Chars_Index + 1; } /* Get_Decoded_Name_String returns a null terminated C string in the same *************** Get_Decoded_Name_String (Id) *** 84,90 **** Name_Id Id; { namet__get_decoded_name_string (Id); ! Name_Buffer [Name_Len] = 0; return Name_Buffer; } --- 83,89 ---- Name_Id Id; { namet__get_decoded_name_string (Id); ! Name_Buffer[Name_Len] = 0; return Name_Buffer; } *************** Get_Decoded_Name_String (Id) *** 93,112 **** cased. This is used fo rbuilding the enumeration literal table. */ extern void casing__set_all_upper_case PARAMS ((void)); - extern void namet__get_unqualified_decoded_name_string PARAMS ((Name_Id)); - - static char *Get_Upper_Decoded_Name_String PARAMS ((Name_Id)); - - INLINE char * - Get_Upper_Decoded_Name_String (Id) - Name_Id Id; - { - namet__get_unqualified_decoded_name_string (Id); - if (Name_Buffer [0] != '\'') - casing__set_all_upper_case (); - Name_Buffer [Name_Len] = 0; - return Name_Buffer; - } /* The following routines and variables are not part of Namet, but we include the header here since it seems the best place for it. */ --- 92,97 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/nlists.adb gcc-3.3/gcc/ada/nlists.adb *** gcc-3.2.3/gcc/ada/nlists.adb 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/nlists.adb 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/nlists.ads gcc-3.3/gcc/ada/nlists.ads *** gcc-3.2.3/gcc/ada/nlists.ads 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/nlists.ads 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/nlists.h gcc-3.3/gcc/ada/nlists.h *** gcc-3.2.3/gcc/ada/nlists.h 2002-05-04 03:28:21.000000000 +0000 --- gcc-3.3/gcc/ada/nlists.h 2002-10-23 07:33:26.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001, Free Software Foundation, Inc. * * * --- 6,11 ---- *************** struct List_Header *** 45,60 **** /* The list headers are stored in an array. The pointer to this array is passed as a parameter to gigi and stored in the global variable ! List_Headers_Ptr after adjusting it by subtracting List_First_Entry, ! so that List_Id values can be used as subscripts. */ extern struct List_Header *List_Headers_Ptr; ! /* The previous and next links for lists are held in two arrays, Next_Node ! and Prev_Node. The pointers to these arrays are passed as parameters ! to gigi and stored in the global variables Prev_Node_Ptr and Next_Node_Ptr ! after adjusting them by subtracting First_Node_Id so that Node_Id values ! can be used as subscripts. */ extern Node_Id *Next_Node_Ptr; extern Node_Id *Prev_Node_Ptr; --- 44,56 ---- /* The list headers are stored in an array. The pointer to this array is passed as a parameter to gigi and stored in the global variable ! List_Headers_Ptr. */ extern struct List_Header *List_Headers_Ptr; ! /* The previous and next links for lists are held in two arrays, Next_Node and ! Prev_Node. The pointers to these arrays are passed as parameters to gigi ! and stored in the global variables Prev_Node_Ptr and Next_Node_Ptr. */ extern Node_Id *Next_Node_Ptr; extern Node_Id *Prev_Node_Ptr; *************** INLINE Node_Id *** 67,77 **** First (List) List_Id List; { ! return List_Headers_Ptr [List].first; } #define First_Non_Pragma nlists__first_non_pragma ! extern Node_Id First_Non_Pragma PARAMS((Node_Id)); static Node_Id Last PARAMS ((List_Id)); --- 63,73 ---- First (List) List_Id List; { ! return List_Headers_Ptr[List - First_List_Id].first; } #define First_Non_Pragma nlists__first_non_pragma ! extern Node_Id First_Non_Pragma PARAMS ((Node_Id)); static Node_Id Last PARAMS ((List_Id)); *************** INLINE Node_Id *** 79,89 **** Last (List) List_Id List; { ! return List_Headers_Ptr [List].last; } #define First_Non_Pragma nlists__first_non_pragma ! extern Node_Id First_Non_Pragma PARAMS((List_Id)); static Node_Id Next PARAMS ((Node_Id)); --- 75,85 ---- Last (List) List_Id List; { ! return List_Headers_Ptr[List - First_List_Id].last; } #define First_Non_Pragma nlists__first_non_pragma ! extern Node_Id First_Non_Pragma PARAMS ((List_Id)); static Node_Id Next PARAMS ((Node_Id)); *************** INLINE Node_Id *** 91,101 **** Next (Node) Node_Id Node; { ! return Next_Node_Ptr [Node]; } #define Next_Non_Pragma nlists__next_non_pragma ! extern Node_Id Next_Non_Pragma PARAMS((List_Id)); static Node_Id Prev PARAMS ((Node_Id)); --- 87,97 ---- Next (Node) Node_Id Node; { ! return Next_Node_Ptr[Node - First_Node_Id]; } #define Next_Non_Pragma nlists__next_non_pragma ! extern Node_Id Next_Non_Pragma PARAMS ((List_Id)); static Node_Id Prev PARAMS ((Node_Id)); *************** INLINE Node_Id *** 103,114 **** Prev (Node) Node_Id Node; { ! return Prev_Node_Ptr [Node]; } #define Prev_Non_Pragma nlists__prev_non_pragma ! extern Node_Id Prev_Non_Pragma PARAMS((Node_Id)); static Boolean Is_Empty_List PARAMS ((List_Id)); static Boolean Is_Non_Empty_List PARAMS ((List_Id)); --- 99,110 ---- Prev (Node) Node_Id Node; { ! return Prev_Node_Ptr[Node - First_Node_Id]; } #define Prev_Non_Pragma nlists__prev_non_pragma ! extern Node_Id Prev_Non_Pragma PARAMS ((Node_Id)); static Boolean Is_Empty_List PARAMS ((List_Id)); static Boolean Is_Non_Empty_List PARAMS ((List_Id)); *************** INLINE Boolean *** 133,144 **** Is_List_Member (Node) Node_Id Node; { ! return Nodes_Ptr [Node].U.K.in_list; } INLINE List_Id List_Containing (Node) Node_Id Node; { ! return Nodes_Ptr [Node].V.NX.link; } --- 129,140 ---- Is_List_Member (Node) Node_Id Node; { ! return Nodes_Ptr[Node - First_Node_Id].U.K.in_list; } INLINE List_Id List_Containing (Node) Node_Id Node; { ! return Nodes_Ptr[Node - First_Node_Id].V.NX.link; } diff -Nrc3pad gcc-3.2.3/gcc/ada/nmake.adb gcc-3.3/gcc/ada/nmake.adb *** gcc-3.2.3/gcc/ada/nmake.adb 2003-04-22 06:56:18.000000000 +0000 --- gcc-3.3/gcc/ada/nmake.adb 2003-05-14 00:18:14.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- ! -- Generated by xnmake revision 1.2 using -- ! -- sinfo.ads revision 1.6 -- ! -- nmake.adt revision 1.1 -- -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,14 ---- -- -- -- B o d y -- -- -- ! -- Generated by xnmake revision 1.29 using -- ! -- sinfo.ads revision 1.439 -- ! -- nmake.adt revision 1.12 -- -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- *************** package body Nmake is *** 270,282 **** end Make_Range; function Make_Enumeration_Type_Definition (Sloc : Source_Ptr; ! Literals : List_Id) return Node_Id is N : constant Node_Id := New_Node (N_Enumeration_Type_Definition, Sloc); begin Set_Literals (N, Literals); return N; end Make_Enumeration_Type_Definition; --- 270,284 ---- end Make_Range; function Make_Enumeration_Type_Definition (Sloc : Source_Ptr; ! Literals : List_Id; ! End_Label : Node_Id := Empty) return Node_Id is N : constant Node_Id := New_Node (N_Enumeration_Type_Definition, Sloc); begin Set_Literals (N, Literals); + Set_End_Label (N, End_Label); return N; end Make_Enumeration_Type_Definition; *************** package body Nmake is *** 663,669 **** function Make_Attribute_Reference (Sloc : Source_Ptr; Prefix : Node_Id; Attribute_Name : Name_Id; ! Expressions : List_Id := No_List) return Node_Id is N : constant Node_Id := --- 665,672 ---- function Make_Attribute_Reference (Sloc : Source_Ptr; Prefix : Node_Id; Attribute_Name : Name_Id; ! Expressions : List_Id := No_List; ! Must_Be_Byte_Aligned : Boolean := False) return Node_Id is N : constant Node_Id := *************** package body Nmake is *** 672,677 **** --- 675,681 ---- Set_Prefix (N, Prefix); Set_Attribute_Name (N, Attribute_Name); Set_Expressions (N, Expressions); + Set_Must_Be_Byte_Aligned (N, Must_Be_Byte_Aligned); return N; end Make_Attribute_Reference; *************** package body Nmake is *** 2756,2790 **** end Make_Itype_Reference; function Make_Raise_Constraint_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty) return Node_Id is N : constant Node_Id := New_Node (N_Raise_Constraint_Error, Sloc); begin Set_Condition (N, Condition); return N; end Make_Raise_Constraint_Error; function Make_Raise_Program_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty) return Node_Id is N : constant Node_Id := New_Node (N_Raise_Program_Error, Sloc); begin Set_Condition (N, Condition); return N; end Make_Raise_Program_Error; function Make_Raise_Storage_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty) return Node_Id is N : constant Node_Id := New_Node (N_Raise_Storage_Error, Sloc); begin Set_Condition (N, Condition); return N; end Make_Raise_Storage_Error; --- 2760,2800 ---- end Make_Itype_Reference; function Make_Raise_Constraint_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty; ! Reason : Uint) return Node_Id is N : constant Node_Id := New_Node (N_Raise_Constraint_Error, Sloc); begin Set_Condition (N, Condition); + Set_Reason (N, Reason); return N; end Make_Raise_Constraint_Error; function Make_Raise_Program_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty; ! Reason : Uint) return Node_Id is N : constant Node_Id := New_Node (N_Raise_Program_Error, Sloc); begin Set_Condition (N, Condition); + Set_Reason (N, Reason); return N; end Make_Raise_Program_Error; function Make_Raise_Storage_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty; ! Reason : Uint) return Node_Id is N : constant Node_Id := New_Node (N_Raise_Storage_Error, Sloc); begin Set_Condition (N, Condition); + Set_Reason (N, Reason); return N; end Make_Raise_Storage_Error; diff -Nrc3pad gcc-3.2.3/gcc/ada/nmake.ads gcc-3.3/gcc/ada/nmake.ads *** gcc-3.2.3/gcc/ada/nmake.ads 2003-04-22 06:56:18.000000000 +0000 --- gcc-3.3/gcc/ada/nmake.ads 2003-05-14 00:18:14.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- ! -- Generated by xnmake revision 1.2 using -- ! -- sinfo.ads revision 1.6 -- ! -- nmake.adt revision 1.1 -- -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,14 ---- -- -- -- S p e c -- -- -- ! -- Generated by xnmake revision 1.29 using -- ! -- sinfo.ads revision 1.439 -- ! -- nmake.adt revision 1.12 -- -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- *************** package Nmake is *** 178,184 **** pragma Inline (Make_Range); function Make_Enumeration_Type_Definition (Sloc : Source_Ptr; ! Literals : List_Id) return Node_Id; pragma Inline (Make_Enumeration_Type_Definition); --- 178,185 ---- pragma Inline (Make_Range); function Make_Enumeration_Type_Definition (Sloc : Source_Ptr; ! Literals : List_Id; ! End_Label : Node_Id := Empty) return Node_Id; pragma Inline (Make_Enumeration_Type_Definition); *************** package Nmake is *** 360,366 **** function Make_Attribute_Reference (Sloc : Source_Ptr; Prefix : Node_Id; Attribute_Name : Name_Id; ! Expressions : List_Id := No_List) return Node_Id; pragma Inline (Make_Attribute_Reference); --- 361,368 ---- function Make_Attribute_Reference (Sloc : Source_Ptr; Prefix : Node_Id; Attribute_Name : Name_Id; ! Expressions : List_Id := No_List; ! Must_Be_Byte_Aligned : Boolean := False) return Node_Id; pragma Inline (Make_Attribute_Reference); *************** package Nmake is *** 1301,1317 **** pragma Inline (Make_Itype_Reference); function Make_Raise_Constraint_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty) return Node_Id; pragma Inline (Make_Raise_Constraint_Error); function Make_Raise_Program_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty) return Node_Id; pragma Inline (Make_Raise_Program_Error); function Make_Raise_Storage_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty) return Node_Id; pragma Inline (Make_Raise_Storage_Error); --- 1303,1322 ---- pragma Inline (Make_Itype_Reference); function Make_Raise_Constraint_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty; ! Reason : Uint) return Node_Id; pragma Inline (Make_Raise_Constraint_Error); function Make_Raise_Program_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty; ! Reason : Uint) return Node_Id; pragma Inline (Make_Raise_Program_Error); function Make_Raise_Storage_Error (Sloc : Source_Ptr; ! Condition : Node_Id := Empty; ! Reason : Uint) return Node_Id; pragma Inline (Make_Raise_Storage_Error); diff -Nrc3pad gcc-3.2.3/gcc/ada/nmake.adt gcc-3.3/gcc/ada/nmake.adt *** gcc-3.2.3/gcc/ada/nmake.adt 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/nmake.adt 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- T e m p l a t e -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/opt.adb gcc-3.3/gcc/ada/opt.adb *** gcc-3.2.3/gcc/ada/opt.adb 2002-05-04 03:28:22.000000000 +0000 --- gcc-3.3/gcc/ada/opt.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, 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- -- *************** package body Opt is *** 147,152 **** --- 146,152 ---- Tree_Read_Bool (Ada_83_Config); Tree_Read_Bool (All_Errors_Mode); Tree_Read_Bool (Assertions_Enabled); + Tree_Read_Bool (Enable_Overflow_Checks); Tree_Read_Bool (Full_List); -- Read and check version string *************** package body Opt is *** 174,180 **** Tree_Read_Bool (No_Run_Time); Tree_Read_Data (Operating_Mode'Address, Operating_Mode_Type'Object_Size / Storage_Unit); ! Tree_Read_Bool (Software_Overflow_Checking); Tree_Read_Bool (Try_Semantics); Tree_Read_Data (Wide_Character_Encoding_Method'Address, WC_Encoding_Method'Object_Size / Storage_Unit); --- 174,180 ---- Tree_Read_Bool (No_Run_Time); Tree_Read_Data (Operating_Mode'Address, Operating_Mode_Type'Object_Size / Storage_Unit); ! Tree_Read_Bool (Suppress_Checks); Tree_Read_Bool (Try_Semantics); Tree_Read_Data (Wide_Character_Encoding_Method'Address, WC_Encoding_Method'Object_Size / Storage_Unit); *************** package body Opt is *** 200,205 **** --- 200,206 ---- Tree_Write_Bool (Ada_83_Config); Tree_Write_Bool (All_Errors_Mode); Tree_Write_Bool (Assertions_Enabled); + Tree_Write_Bool (Enable_Overflow_Checks); Tree_Write_Bool (Full_List); Tree_Write_Int (Int (Gnat_Version_String'Length)); Tree_Write_Data (Gnat_Version_String'Address, *************** package body Opt is *** 213,219 **** Tree_Write_Bool (No_Run_Time); Tree_Write_Data (Operating_Mode'Address, Operating_Mode_Type'Object_Size / Storage_Unit); ! Tree_Write_Bool (Software_Overflow_Checking); Tree_Write_Bool (Try_Semantics); Tree_Write_Data (Wide_Character_Encoding_Method'Address, WC_Encoding_Method'Object_Size / Storage_Unit); --- 214,220 ---- Tree_Write_Bool (No_Run_Time); Tree_Write_Data (Operating_Mode'Address, Operating_Mode_Type'Object_Size / Storage_Unit); ! Tree_Write_Bool (Suppress_Checks); Tree_Write_Bool (Try_Semantics); Tree_Write_Data (Wide_Character_Encoding_Method'Address, WC_Encoding_Method'Object_Size / Storage_Unit); diff -Nrc3pad gcc-3.2.3/gcc/ada/opt.ads gcc-3.3/gcc/ada/opt.ads *** gcc-3.2.3/gcc/ada/opt.ads 2002-05-04 03:28:22.000000000 +0000 --- gcc-3.3/gcc/ada/opt.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** *** 33,42 **** -- -- ------------------------------------------------------------------------------ ! -- This package contains global switches set by the initialization -- routine from the command line and referenced throughout the compiler, ! -- the binder or gnatmake. The comments indicate which options are used by ! -- which programs (GNAT, GNATBIND, GNATMAKE). with Hostparm; use Hostparm; with Types; use Types; --- 32,41 ---- -- -- ------------------------------------------------------------------------------ ! -- This package contains global flags set by the initialization -- routine from the command line and referenced throughout the compiler, ! -- the binder, gnatmake or other GNAT tools. The comments indicate which ! -- options are used by which programs (GNAT, GNATBIND, GNATMAKE, etc). with Hostparm; use Hostparm; with Types; use Types; *************** package Opt is *** 56,62 **** -- the default values. Ada_Bind_File : Boolean := True; ! -- GNATBIND -- Set True if binder file to be generated in Ada rather than C Ada_95 : Boolean := True; --- 55,61 ---- -- the default values. Ada_Bind_File : Boolean := True; ! -- GNATBIND, GNATLINK -- Set True if binder file to be generated in Ada rather than C Ada_95 : Boolean := True; *************** package Opt is *** 70,89 **** -- Set False if operating in Ada 95 mode Ada_Final_Suffix : constant String := "final"; - -- GNATBIND - -- The suffix of the name of the finalization procedure. This variable - -- may be modified by Gnatbind.Scan_Bind_Arg. - Ada_Final_Name : String_Ptr := new String'("ada" & Ada_Final_Suffix); -- GNATBIND -- The name of the procedure that performs the finalization at the end of -- execution. This variable may be modified by Gnatbind.Scan_Bind_Arg. Ada_Init_Suffix : constant String := "init"; - -- GNATBIND - -- The suffix of the name of the initialization procedure. This variable - -- may be modified by Gnatbind.Scan_Bind_Arg. - Ada_Init_Name : String_Ptr := new String'("ada" & Ada_Init_Suffix); -- GNATBIND -- The name of the procedure that performs initialization at the start --- 69,80 ---- *************** package Opt is *** 117,122 **** --- 108,114 ---- -- directly modified by gnatmake to affect the shared binder routines. Alternate_Main_Name : String_Ptr := null; + -- GNATBIND -- Set to non null when Bind_Alternate_Main_Name is True. This value -- is modified as needed by Gnatbind.Scan_Bind_Arg. *************** package Opt is *** 131,138 **** Bind_Alternate_Main_Name : Boolean := False; -- GNATBIND ! -- Set to True if main should be called Alternate_Main_Name.all. This ! -- variable may be set to True by Gnatbind.Scan_Bind_Arg. Bind_Main_Program : Boolean := True; -- GNATBIND --- 123,130 ---- Bind_Alternate_Main_Name : Boolean := False; -- GNATBIND ! -- True if main should be called Alternate_Main_Name.all. ! -- This variable may be set to True by Gnatbind.Scan_Bind_Arg. Bind_Main_Program : Boolean := True; -- GNATBIND *************** package Opt is *** 156,167 **** Check_Object_Consistency : Boolean := False; -- GNATBIND, GNATMAKE -- Set to True to check whether every object file is consistent with ! -- with its corresponding ada library information (ali) file. An object ! -- file is inconsistent with the corresponding ali file if the object ! -- file does not exist or if it has an older time stamp than the ali file. -- Default above is for GNATBIND. GNATMAKE overrides this default to ! -- True (see Make.Initialize) since we do not need to check source ! -- consistencies in gnatmake in this sense. Check_Only : Boolean := False; -- GNATBIND --- 148,159 ---- Check_Object_Consistency : Boolean := False; -- GNATBIND, GNATMAKE -- Set to True to check whether every object file is consistent with ! -- its corresponding ada library information (ALI) file. An object ! -- file is inconsistent with the corresponding ALI file if the object ! -- file does not exist or if it has an older time stamp than the ALI file. -- Default above is for GNATBIND. GNATMAKE overrides this default to ! -- True (see Make.Initialize) since we normally do need to check source ! -- consistencies in gnatmake. Check_Only : Boolean := False; -- GNATBIND *************** package Opt is *** 172,178 **** -- Set to True to check readonly files during the make process. Check_Source_Files : Boolean := True; ! -- GNATBIND -- Set to True to enable consistency checking for any source files that -- are present (i.e. date must match the date in the library info file). -- Set to False for object file consistency check only. This flag is --- 164,170 ---- -- Set to True to check readonly files during the make process. Check_Source_Files : Boolean := True; ! -- GNATBIND, GNATMAKE -- Set to True to enable consistency checking for any source files that -- are present (i.e. date must match the date in the library info file). -- Set to False for object file consistency check only. This flag is *************** package Opt is *** 184,190 **** Check_Unreferenced : Boolean := False; -- GNAT ! -- Set to True to enable checking for unreferenced variables Check_Withs : Boolean := False; -- GNAT --- 176,188 ---- Check_Unreferenced : Boolean := False; -- GNAT ! -- Set to True to enable checking for unreferenced entities other ! -- than formal parameters (for which see Check_Unreferenced_Formals) ! ! Check_Unreferenced_Formals : Boolean := False; ! -- GNAT ! -- Set True to check for unreferenced formals. This is turned ! -- on by -gnatwa/wf/wu and turned off by -gnatwA/wF/wU. Check_Withs : Boolean := False; -- GNAT *************** package Opt is *** 196,202 **** -- Set to True to skip bind and link steps (except when Bind_Only is True) Compress_Debug_Names : Boolean := False; ! -- GNATMAKE -- Set to True if the option to compress debug information is set (-gnatC) Config_File : Boolean := True; --- 194,200 ---- -- Set to True to skip bind and link steps (except when Bind_Only is True) Compress_Debug_Names : Boolean := False; ! -- GNAT -- Set to True if the option to compress debug information is set (-gnatC) Config_File : Boolean := True; *************** package Opt is *** 211,216 **** --- 209,219 ---- -- GNAT -- Set to True to activate warnings on constant conditions + Create_Mapping_File : Boolean := False; + -- GNATMAKE + -- Set to True (-C switch) to indicate that gnatmake + -- invokes the compiler with a mapping file (-gnatem compiler switch). + subtype Debug_Level_Value is Nat range 0 .. 3; Debugger_Level : Debug_Level_Value := 0; -- GNATBIND *************** package Opt is *** 229,235 **** Display_Compilation_Progress : Boolean := False; -- GNATMAKE -- Set True (-d switch) to display information on progress while compiling ! -- files. Internal switch to be used in conjunction with an IDE such as -- Glide. type Distribution_Stub_Mode_Type is --- 232,238 ---- Display_Compilation_Progress : Boolean := False; -- GNATMAKE -- Set True (-d switch) to display information on progress while compiling ! -- files. Internal flag to be used in conjunction with an IDE such as -- Glide. type Distribution_Stub_Mode_Type is *************** package Opt is *** 271,282 **** -- GNAT -- Set to True to generate full elaboration warnings (-gnatwl) type Exception_Mechanism_Type is (Setjmp_Longjmp, Front_End_ZCX, GCC_ZCX); Exception_Mechanism : Exception_Mechanism_Type := Setjmp_Longjmp; -- GNAT -- Set to the appropriate value depending on the default as given in -- system.ads (ZCX_By_Default, GCC_ZCX_Support, Front_End_ZCX_Support) ! -- and the use of -gnatL -gnatZ (and -gnatdX) Exception_Tracebacks : Boolean := False; -- GNATBIND --- 274,293 ---- -- GNAT -- Set to True to generate full elaboration warnings (-gnatwl) + Enable_Overflow_Checks : Boolean := False; + -- GNAT + -- Set to True if -gnato (enable overflow checks) switch is set, + -- but not -gnatp. + type Exception_Mechanism_Type is (Setjmp_Longjmp, Front_End_ZCX, GCC_ZCX); + pragma Convention (C, Exception_Mechanism_Type); + Exception_Mechanism : Exception_Mechanism_Type := Setjmp_Longjmp; -- GNAT -- Set to the appropriate value depending on the default as given in -- system.ads (ZCX_By_Default, GCC_ZCX_Support, Front_End_ZCX_Support) ! -- and the use of -gnatL -gnatZ (and -gnatdX). The C convention is ! -- there to make this variable accessible to gigi. Exception_Tracebacks : Boolean := False; -- GNATBIND *************** package Opt is *** 284,289 **** --- 295,302 ---- Extensions_Allowed : Boolean := False; -- GNAT + -- Set to True by switch -gnatX if GNAT specific language extensions + -- are allowed. For example, "with type" is a GNAT extension. type External_Casing_Type is ( As_Is, -- External names cased as they appear in the Ada source *************** package Opt is *** 291,297 **** Lowercase); -- External names forced to all lowercase letters External_Name_Imp_Casing : External_Casing_Type := Lowercase; ! -- The setting of this switch determines the casing of external names -- when the name is implicitly derived from an entity name (i.e. either -- no explicit External_Name or Link_Name argument is used, or, in the -- case of extended DEC pragmas, the external name is given using an --- 304,311 ---- Lowercase); -- External names forced to all lowercase letters External_Name_Imp_Casing : External_Casing_Type := Lowercase; ! -- GNAT ! -- The setting of this flag determines the casing of external names -- when the name is implicitly derived from an entity name (i.e. either -- no explicit External_Name or Link_Name argument is used, or, in the -- case of extended DEC pragmas, the external name is given using an *************** package Opt is *** 299,305 **** -- create Ada source programs that were case sensitive). External_Name_Exp_Casing : External_Casing_Type := As_Is; ! -- The setting of this switch determines the casing of an external name -- specified explicitly with a string literal. As_Is means the string -- literal is used as given with no modification to the casing. If -- Lowercase or Uppercase is set, then the string is forced to all --- 313,320 ---- -- create Ada source programs that were case sensitive). External_Name_Exp_Casing : External_Casing_Type := As_Is; ! -- GNAT ! -- The setting of this flag determines the casing of an external name -- specified explicitly with a string literal. As_Is means the string -- literal is used as given with no modification to the casing. If -- Lowercase or Uppercase is set, then the string is forced to all *************** package Opt is *** 326,332 **** Force_ALI_Tree_File : Boolean := False; -- GNAT ! -- Force generation of ali file even if errors are encountered. -- Also forces generation of tree file if -gnatt is also set. Force_Compilations : Boolean := False; --- 341,347 ---- Force_ALI_Tree_File : Boolean := False; -- GNAT ! -- Force generation of ALI file even if errors are encountered. -- Also forces generation of tree file if -gnatt is also set. Force_Compilations : Boolean := False; *************** package Opt is *** 337,343 **** -- GNATBIND -- True if binding with forced RM elaboration order (-f switch set) -- Note: this is considered an obsolescent option, to be removed in ! -- some future release. it is no longer documented. The proper way -- to get this effect is to use -gnatE and suppress elab checks. Full_List : Boolean := False; --- 352,358 ---- -- GNATBIND -- True if binding with forced RM elaboration order (-f switch set) -- Note: this is considered an obsolescent option, to be removed in ! -- some future release. It is no longer documented. The proper way -- to get this effect is to use -gnatE and suppress elab checks. Full_List : Boolean := False; *************** package Opt is *** 350,360 **** GNAT_Mode : Boolean := False; -- GNAT ! -- True if compiling in GNAT system mode (-g switch set) HLO_Active : Boolean := False; -- GNAT ! -- True if High Level Optimizer is activated Implementation_Unit_Warnings : Boolean := True; -- GNAT --- 365,375 ---- GNAT_Mode : Boolean := False; -- GNAT ! -- True if compiling in GNAT system mode (-gnatg switch) HLO_Active : Boolean := False; -- GNAT ! -- True if High Level Optimizer is activated (-gnatH switch) Implementation_Unit_Warnings : Boolean := True; -- GNAT *************** package Opt is *** 365,374 **** -- GNAT -- This variable indicates the character set to be used for identifiers. -- The possible settings are: ! -- '1' Latin-1 ! -- '2' Latin-2 ! -- '3' Latin-3 ! -- '4' Latin-4 -- 'p' PC (US, IBM page 437) -- '8' PC (European, IBM page 850) -- 'f' Full upper set (all distinct) --- 380,391 ---- -- GNAT -- This variable indicates the character set to be used for identifiers. -- The possible settings are: ! -- '1' Latin-5 (ISO-8859-1) ! -- '2' Latin-5 (ISO-8859-2) ! -- '3' Latin-5 (ISO-8859-3) ! -- '4' Latin-5 (ISO-8859-4) ! -- '5' Latin-5 (ISO-8859-5, Cyrillic) ! -- '9' Latin-5 (ISO-8859-9) -- 'p' PC (US, IBM page 437) -- '8' PC (European, IBM page 850) -- 'f' Full upper set (all distinct) *************** package Opt is *** 438,456 **** -- Set to True to skip compile and bind steps -- (except when Bind_Only is set to True). List_Units : Boolean := False; -- GNAT ! -- List units in the active library List_Dependencies : Boolean := False; -- GNATMAKE -- When True gnatmake verifies that the objects are up to date and ! -- outputs the list of object dependencies. This list can be used ! -- directly in a Makefile. List_Representation_Info : Int range 0 .. 3 := 0; -- GNAT ! -- Set true by -gnatR switch to list representation information. -- The settings are as follows: -- -- 0 = no listing of representation information (default as above) --- 455,478 ---- -- Set to True to skip compile and bind steps -- (except when Bind_Only is set to True). + List_Restrictions : Boolean := False; + -- GNATBIND + -- Set to True to list restrictions pragmas that could apply to partition + List_Units : Boolean := False; -- GNAT ! -- List units in the active library for a compilation (-gnatu switch) List_Dependencies : Boolean := False; -- GNATMAKE -- When True gnatmake verifies that the objects are up to date and ! -- outputs the list of object dependencies (-M switch). ! -- Output depends if -a switch is used or not. ! -- This list can be used directly in a Makefile. List_Representation_Info : Int range 0 .. 3 := 0; -- GNAT ! -- Set non-zero by -gnatR switch to list representation information. -- The settings are as follows: -- -- 0 = no listing of representation information (default as above) *************** package Opt is *** 458,463 **** --- 480,508 ---- -- 2 = list rep info for all user defined types and objects -- 3 = like 2, but variable fields are decoded symbolically + List_Representation_Info_To_File : Boolean := False; + -- GNAT + -- Set true by -gnatRs switch. Causes information from -gnatR/1/2/3 + -- to be written to file.rep (where file is the name of the source + -- file) instead of stdout. For example, if file x.adb is compiled + -- using -gnatR2s then representation info is written to x.adb.ref. + + type Creat_Repinfo_File_Proc is access procedure (Src : File_Name_Type); + type Write_Repinfo_Line_Proc is access procedure (Info : String); + type Close_Repinfo_File_Proc is access procedure; + -- Types used for procedure addresses below + + Creat_Repinfo_File_Access : Creat_Repinfo_File_Proc := null; + Write_Repinfo_Line_Access : Write_Repinfo_Line_Proc := null; + Close_Repinfo_File_Access : Close_Repinfo_File_Proc := null; + -- GNAT + -- These three locations are left null when operating in non-compiler + -- (e.g. ASIS mode), but when operating in compiler mode, they are + -- set to point to the three corresponding procedures in Osint. The + -- reason for this slightly strange interface is to prevent Repinfo + -- from dragging in Osint in ASIS mode, which would include a lot of + -- unwanted units in the ASIS build. + Locking_Policy : Character := ' '; -- GNAT -- Set to ' ' for the default case (no locking policy specified). *************** package Opt is *** 495,505 **** -- Set to True if minimal recompilation mode requested. No_Stdlib : Boolean := False; ! -- GNATMAKE -- Set to True if no default library search dirs added to search list. No_Stdinc : Boolean := False; ! -- GNATMAKE -- Set to True if no default source search dirs added to search list. No_Main_Subprogram : Boolean := False; --- 540,550 ---- -- Set to True if minimal recompilation mode requested. No_Stdlib : Boolean := False; ! -- GNATMAKE, GNATBIND, GNATFIND, GNATXREF -- Set to True if no default library search dirs added to search list. No_Stdinc : Boolean := False; ! -- GNAT, GNATBIND, GNATMAKE, GNATFIND, GNATXREF -- Set to True if no default source search dirs added to search list. No_Main_Subprogram : Boolean := False; *************** package Opt is *** 529,538 **** -- after generating an error message. Output_File_Name_Present : Boolean := False; ! -- GNATBIND, GNAT -- Set to True when the output C file name is given with option -o ! -- for GNATBIND or when the object file name is given with option ! -- -gnatO for GNAT. Output_Linker_Option_List : Boolean := False; -- GNATBIND --- 574,584 ---- -- after generating an error message. Output_File_Name_Present : Boolean := False; ! -- GNATBIND, GNAT, GNATMAKE -- Set to True when the output C file name is given with option -o ! -- for GNATBIND, when the object file name is given with option ! -- -gnatO for GNAT or when the executable is given with option -o ! -- for GNATMAKE. Output_Linker_Option_List : Boolean := False; -- GNATBIND *************** package Opt is *** 564,570 **** Queuing_Policy : Character := ' '; -- GNAT ! -- Set to ' ' for the default case (no queuing policy specified). Reset to -- Reset to first character (uppercase) of locking policy name if a valid -- Queuing_Policy pragma is encountered. --- 610,616 ---- Queuing_Policy : Character := ' '; -- GNAT ! -- Set to ' ' for the default case (no queuing policy specified). -- Reset to first character (uppercase) of locking policy name if a valid -- Queuing_Policy pragma is encountered. *************** package Opt is *** 572,589 **** -- GNATMAKE -- Set to True if the list of compilation commands should not be output. Shared_Libgnat : Boolean; -- GNATBIND -- Set to True if a shared libgnat is requested by using the -shared -- option for GNATBIND and to False when using the -static option. The ! -- value of this switch is set by Gnatbind.Scan_Bind_Arg. ! ! Software_Overflow_Checking : Boolean; ! -- GNAT ! -- Set to True by Osint.Initialize if the target requires the software ! -- approach to integer arithmetic overflow checking (i.e. the use of ! -- double length arithmetic followed by a range check). Set to False ! -- if the target implements hardware overflow checking. Stack_Checking_Enabled : Boolean; -- GNAT --- 618,632 ---- -- GNATMAKE -- Set to True if the list of compilation commands should not be output. + RTS_Switch : Boolean := False; + -- GNAT, GNATMAKE, GNATBIND, GNATLS, GNATFIND, GNATXREF + -- Set to True when the --RTS switch is set + Shared_Libgnat : Boolean; -- GNATBIND -- Set to True if a shared libgnat is requested by using the -shared -- option for GNATBIND and to False when using the -static option. The ! -- value of this flag is set by Gnatbind.Scan_Bind_Arg. Stack_Checking_Enabled : Boolean; -- GNAT *************** package Opt is *** 594,610 **** -- in the gcc backend (see Frontend) and may be referenced throughout -- the compilation phases. - Strict_Math : aliased Boolean := False; - -- GNAT - -- This switch is set True if the current unit is to be compiled in - -- strict math mode. The effect is to cause certain library file name - -- substitutions to implement strict math semantics. See the routine - -- Adjust_File_Name_For_Configuration, and also the configuration - -- in the body of Opt. - -- - -- Note: currently this switch is always False. Eventually it will be - -- settable by a switch and a configuration pragma. - Style_Check : Boolean := False; -- GNAT -- Set True to perform style checks. Activates checks carried out --- 637,642 ---- *************** package Opt is *** 618,626 **** --- 650,663 ---- -- be located as Chars (Expression (System_Extend_Pragma_Arg)). Subunits_Missing : Boolean := False; + -- GNAT -- This flag is set true if missing subunits are detected with code -- generation active. This causes code generation to be skipped. + Suppress_Checks : Boolean := False; + -- GNAT + -- Set to True if -gnatp (suppress all checks) switch present. + Suppress_Options : Suppress_Record; -- GNAT -- Flags set True to suppress corresponding check, i.e. add an implicit *************** package Opt is *** 629,634 **** --- 666,672 ---- -- pragma. This variable is initialized by Osint.Initialize. Table_Factor : Int := 1; + -- GNAT -- Factor by which all initial table sizes set in Alloc are multiplied. -- Used in Table to calculate initial table sizes (the initial table -- size is the value in Alloc, used as the Table_Initial parameter *************** package Opt is *** 643,676 **** Tasking_Used : Boolean := False; -- Set True if any tasking construct is encountered. Used to activate the ! -- output of the Q, L and T lines in ali files. Time_Slice_Set : Boolean := False; -- Set True if a pragma Time_Slice is processed in the main unit, or ! -- if the T switch is present to set a time slice value. Time_Slice_Value : Nat; -- Time slice value. Valid only if Time_Slice_Set is True, i.e. if a -- Time_Slice pragma has been processed. Set to the time slice value -- in microseconds. Negative values are stored as zero, and the value -- is not larger than 1_000_000_000 (1000 seconds). Values larger than ! -- this are reset to this maximum. Tolerate_Consistency_Errors : Boolean := False; -- GNATBIND ! -- Tolerate time stamp and other consistency errors. If this switch is ! -- set true, then inconsistencies result in warnings rather than errors. Tree_Output : Boolean := False; -- GNAT ! -- Set True to generate output tree file Try_Semantics : Boolean := False; -- GNAT -- Flag set to force attempt at semantic analysis, even if parser errors -- occur. This will probably cause blowups at this stage in the game. On -- the other hand, most such blowups will be caught cleanly and simply ! -- say compilation abandoned. Unique_Error_Tag : Boolean := Tag_Errors; -- GNAT --- 681,718 ---- Tasking_Used : Boolean := False; -- Set True if any tasking construct is encountered. Used to activate the ! -- output of the Q, L and T lines in ALI files. Time_Slice_Set : Boolean := False; + -- GNATBIND -- Set True if a pragma Time_Slice is processed in the main unit, or ! -- if the -gnatTnn switch is present to set a time slice value. Time_Slice_Value : Nat; + -- GNATBIND -- Time slice value. Valid only if Time_Slice_Set is True, i.e. if a -- Time_Slice pragma has been processed. Set to the time slice value -- in microseconds. Negative values are stored as zero, and the value -- is not larger than 1_000_000_000 (1000 seconds). Values larger than ! -- this are reset to this maximum. This can also be set with the -gnatTnn ! -- switch. Tolerate_Consistency_Errors : Boolean := False; -- GNATBIND ! -- Tolerate time stamp and other consistency errors. If this flag is ! -- set to True (-t), then inconsistencies result in warnings rather than ! -- errors. Tree_Output : Boolean := False; -- GNAT ! -- Set to True (-gnatt) to generate output tree file Try_Semantics : Boolean := False; -- GNAT -- Flag set to force attempt at semantic analysis, even if parser errors -- occur. This will probably cause blowups at this stage in the game. On -- the other hand, most such blowups will be caught cleanly and simply ! -- say compilation abandoned. This flag is set to True by -gnatq or -gnatQ. Unique_Error_Tag : Boolean := Tag_Errors; -- GNAT *************** package Opt is *** 693,715 **** Usage_Requested : Boolean := False; -- GNAT, GNATBIND, GNATMAKE ! -- Set to True if h switch encountered requesting usage information Use_VADS_Size : Boolean := False; -- GNAT -- Set to True if a valid pragma Use_VADS_Size is processed Validity_Checks_On : Boolean := True; -- This flag determines if validity checking is on or off. The initial -- state is on, and the required default validity checks are active. The -- actual set of checks that is performed if Validity_Checks_On is set -- is defined by the switches in package Sem_Val. The Validity_Checks_On ! -- switch is controlled by pragma Validity_Checks (On | Off), and also -- some generated compiler code (typically code that has to do with ! -- validity check generation) is compiled with this switch set to False. Verbose_Mode : Boolean := False; ! -- GNAT, GNATBIND -- Set to True to get verbose mode (full error message text and location -- information sent to standard output, also header, copyright and summary) --- 735,760 ---- Usage_Requested : Boolean := False; -- GNAT, GNATBIND, GNATMAKE ! -- Set to True if -h (-gnath for the compiler) switch encountered ! -- requesting usage information Use_VADS_Size : Boolean := False; -- GNAT -- Set to True if a valid pragma Use_VADS_Size is processed Validity_Checks_On : Boolean := True; + -- GNAT -- This flag determines if validity checking is on or off. The initial -- state is on, and the required default validity checks are active. The -- actual set of checks that is performed if Validity_Checks_On is set -- is defined by the switches in package Sem_Val. The Validity_Checks_On ! -- flag is controlled by pragma Validity_Checks (On | Off), and also -- some generated compiler code (typically code that has to do with ! -- validity check generation) is compiled with this flag set to False. ! -- This flag is set to False by the -gnatp switch. Verbose_Mode : Boolean := False; ! -- GNAT, GNATBIND, GNATMAKE, GNATLINK, GNATLS, GNATCHOP, GNATNAME -- Set to True to get verbose mode (full error message text and location -- information sent to standard output, also header, copyright and summary) *************** package Opt is *** 719,724 **** --- 764,774 ---- -- in a manner inconsistent with unbiased rounding (round to even). Can -- be modified by use of -gnatwb/B. + Warn_On_Dereference : Boolean := False; + -- GNAT + -- Set to True to generate warnings for implicit dereferences for array + -- indexing and record component access. Modified by use of -gnatwd/D. + Warn_On_Hiding : Boolean := False; -- GNAT -- Set to True to generate warnings if a declared entity hides another *************** package Opt is *** 745,756 **** -- recognized in source programs regardless of the setting of this -- variable. The default setting causes only the brackets notation -- to be recognized. If this is the main unit, this setting also ! -- controls the output of the W=? parameter in the ali file, which -- is used to provide the default for Wide_Text_IO files. Xref_Active : Boolean := True; -- GNAT ! -- Set if cross-referencing is enabled (i.e. xref info in ali files) Zero_Cost_Exceptions_Val : Boolean; Zero_Cost_Exceptions_Set : Boolean := False; --- 795,806 ---- -- recognized in source programs regardless of the setting of this -- variable. The default setting causes only the brackets notation -- to be recognized. If this is the main unit, this setting also ! -- controls the output of the W=? parameter in the ALI file, which -- is used to provide the default for Wide_Text_IO files. Xref_Active : Boolean := True; -- GNAT ! -- Set if cross-referencing is enabled (i.e. xref info in ALI files) Zero_Cost_Exceptions_Val : Boolean; Zero_Cost_Exceptions_Set : Boolean := False; *************** package Opt is *** 759,765 **** -- handling mode set by argument switches (-gnatZ/-gnatL). If the -- value is set by one of these switches, then Zero_Cost_Exceptions_Set -- is set to True, and Zero_Cost_Exceptions_Val indicates the setting. - -- This value is used to reset ZCX_By_Default_On_Target. ---------------------------- -- Configuration Settings -- --- 809,814 ---- *************** package Opt is *** 776,782 **** -- by the command line switch -gnat83, and possibly modified by the use -- of configuration pragmas Ada_95 and Ada_83 in the gnat.adc file. This -- switch is used to set the initial value for Ada_83 mode at the start ! -- of analysis of a unit. Note however, that the setting of this switch -- is ignored for internal and predefined units (which are always compiled -- in Ada 95 mode). --- 825,831 ---- -- by the command line switch -gnat83, and possibly modified by the use -- of configuration pragmas Ada_95 and Ada_83 in the gnat.adc file. This -- switch is used to set the initial value for Ada_83 mode at the start ! -- of analysis of a unit. Note however, that the setting of this flag -- is ignored for internal and predefined units (which are always compiled -- in Ada 95 mode). *************** package Opt is *** 787,793 **** Extensions_Allowed_Config : Boolean; -- GNAT ! -- This is the switch that indicates whether extensions are allowed. -- It can be set True either by use of the -gnatX switch, or by use -- of the configuration pragma Extensions_Allowed (On). It is always -- set to True for internal GNAT units, since extensions are always --- 836,842 ---- Extensions_Allowed_Config : Boolean; -- GNAT ! -- This is the flag that indicates whether extensions are allowed. -- It can be set True either by use of the -gnatX switch, or by use -- of the configuration pragma Extensions_Allowed (On). It is always -- set to True for internal GNAT units, since extensions are always *************** package Opt is *** 799,807 **** -- of external symbols for which an explicit external name is given. It -- can be set to Uppercase by the command line switch -gnatF, and further -- modified by the use of the configuration pragma External_Name_Casing ! -- in the gnat.adc file. This switch is used to set the initial value -- for External_Name_Exp_Casing at the start of analyzing each unit. ! -- Note however that the setting of this switch is ignored for internal -- and predefined units (which are always compiled with As_Is mode). External_Name_Imp_Casing_Config : External_Casing_Type; --- 848,856 ---- -- of external symbols for which an explicit external name is given. It -- can be set to Uppercase by the command line switch -gnatF, and further -- modified by the use of the configuration pragma External_Name_Casing ! -- in the gnat.adc file. This flag is used to set the initial value -- for External_Name_Exp_Casing at the start of analyzing each unit. ! -- Note however that the setting of this flag is ignored for internal -- and predefined units (which are always compiled with As_Is mode). External_Name_Imp_Casing_Config : External_Casing_Type; *************** package Opt is *** 810,818 **** -- of external symbols where the external name is implicitly given. It -- can be set to Uppercase by the command line switch -gnatF, and further -- modified by the use of the configuration pragma External_Name_Casing ! -- in the gnat.adc file. This switch is used to set the initial value -- for External_Name_Imp_Casing at the start of analyzing each unit. ! -- Note however that the setting of this switch is ignored for internal -- and predefined units (which are always compiled with Lowercase mode). Polling_Required_Config : Boolean; --- 859,867 ---- -- of external symbols where the external name is implicitly given. It -- can be set to Uppercase by the command line switch -gnatF, and further -- modified by the use of the configuration pragma External_Name_Casing ! -- in the gnat.adc file. This flag is used to set the initial value -- for External_Name_Imp_Casing at the start of analyzing each unit. ! -- Note however that the setting of this flag is ignored for internal -- and predefined units (which are always compiled with Lowercase mode). Polling_Required_Config : Boolean; *************** package Opt is *** 820,826 **** -- This is the value of the configuration switch that controls polling -- mode. It can be set True by the command line switch -gnatP, and then -- further modified by the use of pragma Polling in the gnat.adc file. ! -- This switch is used to set the initial value for Polling_Required -- at the start of analyzing each unit. Use_VADS_Size_Config : Boolean; --- 869,875 ---- -- This is the value of the configuration switch that controls polling -- mode. It can be set True by the command line switch -gnatP, and then -- further modified by the use of pragma Polling in the gnat.adc file. ! -- This flag is used to set the initial value for Polling_Required -- at the start of analyzing each unit. Use_VADS_Size_Config : Boolean; *************** package Opt is *** 828,836 **** -- This is the value of the configuration switch that controls the use -- of VADS_Size instead of Size whereever the attribute Size is used. -- It can be set True by the use of the pragma Use_VADS_Size in the ! -- gnat.adc file. This switch is used to set the initial value for -- Use_VADS_Size at the start of analyzing each unit. Note however that ! -- the setting of this switch is ignored for internal and predefined -- units (which are always compiled with the standard Size semantics). type Config_Switches_Type is private; --- 877,885 ---- -- This is the value of the configuration switch that controls the use -- of VADS_Size instead of Size whereever the attribute Size is used. -- It can be set True by the use of the pragma Use_VADS_Size in the ! -- gnat.adc file. This flag is used to set the initial value for -- Use_VADS_Size at the start of analyzing each unit. Note however that ! -- the setting of this flag is ignored for internal and predefined -- units (which are always compiled with the standard Size semantics). type Config_Switches_Type is private; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint.adb gcc-3.3/gcc/ada/osint.adb *** gcc-3.2.3/gcc/ada/osint.adb 2002-05-04 03:28:22.000000000 +0000 --- gcc-3.3/gcc/ada/osint.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.6.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Opt; use Opt; *** 33,39 **** with Output; use Output; with Sdefault; use Sdefault; with Table; - with Tree_IO; use Tree_IO; with Unchecked_Conversion; --- 32,37 ---- *************** with GNAT.HTable; *** 42,47 **** --- 40,48 ---- package body Osint is + Running_Program : Program_Type := Unspecified; + Program_Set : Boolean := False; + ------------------------------------- -- Use of Name_Find and Name_Enter -- ------------------------------------- *************** package body Osint is *** 68,90 **** function OS_Time_To_GNAT_Time (T : OS_Time) return Time_Stamp_Type; -- Convert OS format time to GNAT format time stamp ! procedure Create_File_And_Check ! (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). ! ! procedure Set_Library_Info_Name; ! -- Sets a default ali file name from the main compiler source name. ! -- This is used by Create_Output_Library_Info, and by the version of ! -- Read_Library_Info that takes a default file 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 --- 69,80 ---- function OS_Time_To_GNAT_Time (T : OS_Time) return Time_Stamp_Type; -- Convert OS format time to GNAT format time stamp ! function Concat (String_One : String; String_Two : String) return String; ! -- Concatenates 2 strings and returns the result of the concatenation ! function Update_Path (Path : String_Ptr) return String_Ptr; ! -- Update the specified path to replace the prefix with the location ! -- where GNAT is installed. See the file prefix.c in GCC for details. procedure Write_With_Check (A : Address; N : Integer); -- Writes N bytes from buffer starting at address A to file whose FD is *************** package body Osint is *** 93,104 **** -- detected, the file being written is deleted, and a fatal error is -- signalled. - function More_Files return Boolean; - -- Implements More_Source_Files and More_Lib_Files. - - function Next_Main_File return File_Name_Type; - -- Implements Next_Main_Source and Next_Main_Lib_File. - function Locate_File (N : File_Name_Type; T : File_Type; --- 83,88 ---- *************** package body Osint is *** 125,166 **** -- Other Local Declarations -- ------------------------------ - ALI_Suffix : constant String_Ptr := new String'("ali"); - -- The suffix used for the library files (also known as ALI files). - - Object_Suffix : constant String := Get_Object_Suffix.all; - -- The suffix used for the object files. - EOL : constant Character := ASCII.LF; -- End of line character - Argument_Count : constant Integer := Arg_Count - 1; - -- Number of arguments (excluding program name) - - type File_Name_Array is array (Int range <>) of String_Ptr; - 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 in Initialize, file names are stored - -- in this array. The string does not contain a terminating NUL. - -- The array is "extensible" because when using project files, - -- there may be more file names than argument on the command line. - Number_File_Names : Int := 0; -- The total number of file names found on command line and placed in -- File_Names. - Current_File_Name_Index : Int := 0; - -- The index in File_Names of the last file opened by Next_Main_Source - -- or Next_Main_Lib_File. The value 0 indicates that no files have been - -- opened yet. - - Current_Main : File_Name_Type := No_File; - -- Used to save a simple file name between calls to Next_Main_Source and - -- Read_Source_File. If the file name argument to Read_Source_File is - -- No_File, that indicates that the file whose name was returned by the - -- last call to Next_Main_Source (and stored here) is to be read. - Look_In_Primary_Directory_For_Current_Main : Boolean := False; -- When this variable is True, Find_File will only look in -- the Primary_Directory for the Current_Main file. --- 109,121 ---- *************** package body Osint is *** 178,205 **** -- the latest source, library and object files opened by Read_Source_File -- and Read_Library_Info. - Old_Binder_Output_Time_Stamp : Time_Stamp_Type; - New_Binder_Output_Time_Stamp : Time_Stamp_Type; - Recording_Time_From_Last_Bind : Boolean := False; - Binder_Output_Time_Stamps_Set : Boolean := False; - - In_Binder : Boolean := False; - In_Compiler : Boolean := False; - In_Make : Boolean := False; - -- Exactly one of these flags is set True to indicate which program - -- is bound and executing with Osint, which is used by all these programs. - - Output_FD : File_Descriptor; - -- The file descriptor for the current library info, 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 - -- stored does not include the trailing NUL character. - - Output_Object_File_Name : String_Ptr; - -- Argument of -o compiler option, if given. This is needed to - -- verify consistency with the ALI file name. - ------------------ -- Search Paths -- ------------------ --- 133,138 ---- *************** package body Osint is *** 301,307 **** procedure Add_Search_Dir (Search_Dir : String_Access; Additional_Source_Dir : Boolean); ! -- Needs documentation ??? function Get_Libraries_From_Registry return String_Ptr; -- On Windows systems, get the list of installed standard libraries --- 234,241 ---- procedure Add_Search_Dir (Search_Dir : String_Access; Additional_Source_Dir : Boolean); ! -- Add a source search dir or a library search dir, depending on the ! -- value of Additional_Source_Dir. function Get_Libraries_From_Registry return String_Ptr; -- On Windows systems, get the list of installed standard libraries *************** package body Osint is *** 310,320 **** -- GNAT\Standard Libraries -- Return an empty string on other systems - function Update_Path (Path : String_Ptr) return String_Ptr; - -- Update the specified path to replace the prefix with - -- the location where GNAT is installed. See the file prefix.c - -- in GCC for more details. - -------------------- -- Add_Search_Dir -- -------------------- --- 244,249 ---- *************** package body Osint is *** 356,395 **** return Out_String; end Get_Libraries_From_Registry; - ----------------- - -- Update_Path -- - ----------------- - - function Update_Path (Path : String_Ptr) return String_Ptr is - - function C_Update_Path (Path, Component : Address) return Address; - pragma Import (C, C_Update_Path, "update_path"); - - function Strlen (Str : Address) return Integer; - pragma Import (C, Strlen, "strlen"); - - procedure Strncpy (X : Address; Y : Address; Length : Integer); - pragma Import (C, Strncpy, "strncpy"); - - In_Length : constant Integer := Path'Length; - In_String : String (1 .. In_Length + 1); - Component_Name : aliased String := "GNAT" & ASCII.NUL; - Result_Ptr : Address; - Result_Length : Integer; - Out_String : String_Ptr; - - begin - In_String (1 .. In_Length) := Path.all; - In_String (In_Length + 1) := ASCII.NUL; - Result_Ptr := C_Update_Path (In_String'Address, - Component_Name'Address); - Result_Length := Strlen (Result_Ptr); - - Out_String := new String (1 .. Result_Length); - Strncpy (Out_String.all'Address, Result_Ptr, Result_Length); - return Out_String; - end Update_Path; - -- Start of processing for Add_Default_Search_Dirs begin --- 285,290 ---- *************** package body Osint is *** 461,467 **** end loop; end if; ! if not Opt.No_Stdlib then Search_Path := Read_Default_Search_Dirs (String_Access (Update_Path (Search_Dir_Prefix)), Objects_Search_File, --- 356,362 ---- end loop; end if; ! if not Opt.No_Stdlib and not Opt.RTS_Switch then Search_Path := Read_Default_Search_Dirs (String_Access (Update_Path (Search_Dir_Prefix)), Objects_Search_File, *************** package body Osint is *** 511,516 **** --- 406,436 ---- Normalize_Directory_Name (Dir); end Add_Lib_Search_Dir; + --------------------- + -- Add_Search_Dirs -- + --------------------- + + procedure Add_Search_Dirs + (Search_Path : String_Ptr; + Path_Type : Search_File_Type) + is + Current_Search_Path : String_Access; + + begin + Get_Next_Dir_In_Path_Init (String_Access (Search_Path)); + loop + Current_Search_Path := + Get_Next_Dir_In_Path (String_Access (Search_Path)); + exit when Current_Search_Path = null; + + if Path_Type = Include then + Add_Src_Search_Dir (Current_Search_Path.all); + else + Add_Lib_Search_Dir (Current_Search_Path.all); + end if; + end loop; + end Add_Search_Dirs; + ------------------------ -- Add_Src_Search_Dir -- ------------------------ *************** package body Osint is *** 579,768 **** end if; end Canonical_Case_File_Name; ! ------------------------- ! -- Close_Binder_Output -- ! ------------------------- ! ! procedure Close_Binder_Output is ! begin ! pragma Assert (In_Binder); ! Close (Output_FD); ! ! if Recording_Time_From_Last_Bind then ! New_Binder_Output_Time_Stamp := File_Stamp (Output_File_Name); ! Binder_Output_Time_Stamps_Set := True; ! end if; ! end Close_Binder_Output; ! ! ---------------------- ! -- Close_Debug_File -- ! ---------------------- ! ! procedure Close_Debug_File is ! begin ! pragma Assert (In_Compiler); ! Close (Output_FD); ! end Close_Debug_File; ! ! ------------------------------- ! -- Close_Output_Library_Info -- ! ------------------------------- ! ! procedure Close_Output_Library_Info is ! begin ! pragma Assert (In_Compiler); ! Close (Output_FD); ! end Close_Output_Library_Info; ! ! -------------------------- ! -- Create_Binder_Output -- ! -------------------------- ! ! procedure Create_Binder_Output ! (Output_File_Name : String; ! Typ : Character; ! Bfile : out Name_Id) ! is ! File_Name : String_Ptr; ! Findex1 : Natural; ! Findex2 : Natural; ! Flength : Natural; ! ! begin ! pragma Assert (In_Binder); ! ! if Output_File_Name /= "" then ! Name_Buffer (Output_File_Name'Range) := Output_File_Name; ! Name_Buffer (Output_File_Name'Last + 1) := ASCII.NUL; ! ! if Typ = 's' then ! Name_Buffer (Output_File_Name'Last) := 's'; ! end if; ! ! Name_Len := Output_File_Name'Last; ! ! else ! Name_Buffer (1) := 'b'; ! File_Name := File_Names (Current_File_Name_Index); ! ! Findex1 := File_Name'First; ! ! -- The ali file might be specified by a full path name. However, ! -- the binder generated file should always be created in the ! -- current directory, so the path might need to be stripped away. ! -- In addition to the default directory_separator allow the '/' to ! -- act as separator since this is allowed in MS-DOS and OS2 ports. ! ! for J in reverse File_Name'Range loop ! if File_Name (J) = Directory_Separator ! or else File_Name (J) = '/' ! then ! Findex1 := J + 1; ! exit; ! end if; ! end loop; ! ! Findex2 := File_Name'Last; ! while File_Name (Findex2) /= '.' loop ! Findex2 := Findex2 - 1; ! end loop; ! ! Flength := Findex2 - Findex1; ! ! if Maximum_File_Name_Length > 0 then ! ! -- Make room for the extra two characters in "b?" ! ! while Int (Flength) > Maximum_File_Name_Length - 2 loop ! Findex2 := Findex2 - 1; ! Flength := Findex2 - Findex1; ! end loop; ! end if; ! ! Name_Buffer (3 .. Flength + 2) := File_Name (Findex1 .. Findex2 - 1); ! Name_Buffer (Flength + 3) := '.'; ! ! -- C bind file, name is b_xxx.c ! ! if Typ = 'c' then ! Name_Buffer (2) := '_'; ! Name_Buffer (Flength + 4) := 'c'; ! Name_Buffer (Flength + 5) := ASCII.NUL; ! Name_Len := Flength + 4; ! ! -- Ada bind file, name is b~xxx.adb or b~xxx.ads ! -- (with $ instead of ~ in VMS) ! ! else ! if Hostparm.OpenVMS then ! Name_Buffer (2) := '$'; ! else ! Name_Buffer (2) := '~'; ! end if; ! ! Name_Buffer (Flength + 4) := 'a'; ! Name_Buffer (Flength + 5) := 'd'; ! Name_Buffer (Flength + 6) := Typ; ! Name_Buffer (Flength + 7) := ASCII.NUL; ! Name_Len := Flength + 6; ! end if; ! end if; ! ! Bfile := Name_Find; ! ! if Recording_Time_From_Last_Bind then ! Old_Binder_Output_Time_Stamp := File_Stamp (Bfile); ! end if; ! ! Create_File_And_Check (Output_FD, Text); ! end Create_Binder_Output; ! ! ----------------------- ! -- Create_Debug_File -- ! ----------------------- ! function Create_Debug_File (Src : File_Name_Type) return File_Name_Type is ! Result : File_Name_Type; begin ! Get_Name_String (Src); ! ! if Hostparm.OpenVMS then ! Name_Buffer (Name_Len + 1 .. Name_Len + 3) := "_dg"; ! else ! Name_Buffer (Name_Len + 1 .. Name_Len + 3) := ".dg"; ! end if; ! ! Name_Len := Name_Len + 3; ! ! if Output_Object_File_Name /= null then ! ! for Index in reverse Output_Object_File_Name'Range loop ! ! if Output_Object_File_Name (Index) = Directory_Separator then ! declare ! File_Name : constant String := Name_Buffer (1 .. Name_Len); ! ! begin ! Name_Len := Index - Output_Object_File_Name'First + 1; ! Name_Buffer (1 .. Name_Len) := ! Output_Object_File_Name ! (Output_Object_File_Name'First .. Index); ! Name_Buffer (Name_Len + 1 .. Name_Len + File_Name'Length) := ! File_Name; ! Name_Len := Name_Len + File_Name'Length; ! end; ! ! exit; ! end if; ! end loop; ! end if; ! ! Result := Name_Find; ! Name_Buffer (Name_Len + 1) := ASCII.NUL; ! Create_File_And_Check (Output_FD, Text); ! return Result; ! end Create_Debug_File; --------------------------- -- Create_File_And_Check -- --- 499,516 ---- end if; end Canonical_Case_File_Name; ! ------------ ! -- Concat -- ! ------------ ! function Concat (String_One : String; String_Two : String) return String is ! Buffer : String (1 .. String_One'Length + String_Two'Length); begin ! Buffer (1 .. String_One'Length) := String_One; ! Buffer (String_One'Length + 1 .. Buffer'Last) := String_Two; ! return Buffer; ! end Concat; --------------------------- -- Create_File_And_Check -- *************** package body Osint is *** 782,797 **** end Create_File_And_Check; -------------------------------- - -- Create_Output_Library_Info -- - -------------------------------- - - procedure Create_Output_Library_Info is - begin - Set_Library_Info_Name; - Create_File_And_Check (Output_FD, Text); - end Create_Output_Library_Info; - - -------------------------------- -- Current_Library_File_Stamp -- -------------------------------- --- 530,535 ---- *************** package body Osint is *** 818,838 **** return Current_Full_Source_Stamp; end Current_Source_File_Stamp; - --------------------------- - -- Debug_File_Eol_Length -- - --------------------------- - - function Debug_File_Eol_Length return Nat is - begin - -- There has to be a cleaner way to do this! ??? - - if Directory_Separator = '/' then - return 1; - else - return 2; - end if; - end Debug_File_Eol_Length; - ---------------------------- -- Dir_In_Obj_Search_Path -- ---------------------------- --- 556,561 ---- *************** package body Osint is *** 914,920 **** --- 637,647 ---- ---------- procedure Fail (S1 : String; S2 : String := ""; S3 : String := "") is + begin + -- We use Output in case there is a special output set up. + -- In this case Set_Standard_Error will have no immediate effect. + Set_Standard_Error; Osint.Write_Program_Name; Write_Str (": "); *************** package body Osint is *** 923,931 **** Write_Str (S3); Write_Eol; - -- ??? Using Output is ugly, should do direct writes - -- ??? shouldn't this go to standard error instead of stdout? - Exit_Program (E_Fatal); end Fail; --- 650,655 ---- *************** package body Osint is *** 1202,1288 **** return Src_Search_Directories.Table (Primary_Directory); end Get_Primary_Src_Search_Directory; ! ---------------- ! -- Initialize -- ! ---------------- ! ! procedure Initialize (P : Program_Type) is ! function Get_Default_Identifier_Character_Set return Character; ! pragma Import (C, Get_Default_Identifier_Character_Set, ! "__gnat_get_default_identifier_character_set"); ! -- Function to determine the default identifier character set, ! -- which is system dependent. See Opt package spec for a list of ! -- the possible character codes and their interpretations. ! function Get_Maximum_File_Name_Length return Int; ! pragma Import (C, Get_Maximum_File_Name_Length, ! "__gnat_get_maximum_file_name_length"); ! -- Function to get maximum file name length for system ! procedure Adjust_OS_Resource_Limits; ! pragma Import (C, Adjust_OS_Resource_Limits, ! "__gnat_adjust_os_resource_limits"); ! -- Procedure to make system specific adjustments to make GNAT ! -- run better. ! -- Start of processing for Initialize begin ! Program := P; ! case Program is ! when Binder => In_Binder := True; ! when Compiler => In_Compiler := True; ! when Make => In_Make := True; ! end case; ! if In_Compiler then ! Adjust_OS_Resource_Limits; end if; ! Src_Search_Directories.Init; ! Lib_Search_Directories.Init; ! Identifier_Character_Set := Get_Default_Identifier_Character_Set; ! Maximum_File_Name_Length := Get_Maximum_File_Name_Length; ! -- Following should be removed by having above function return ! -- Integer'Last as indication of no maximum instead of -1 ??? ! if Maximum_File_Name_Length = -1 then ! Maximum_File_Name_Length := Int'Last; ! end if; ! -- Start off by setting all suppress options to False, these will ! -- be reset later (turning some on if -gnato is not specified, and ! -- turning all of them on if -gnatp is specified). ! Suppress_Options := (others => False); ! -- Set software overflow check flag. For now all targets require the ! -- use of software overflow checks. Later on, this will have to be ! -- specialized to the backend target. Also, if software overflow ! -- checking mode is set, then the default for suppressing overflow ! -- checks is True, since the software approach is expensive. ! Software_Overflow_Checking := True; ! Suppress_Options.Overflow_Checks := True; ! -- Reserve the first slot in the search paths table. This is the ! -- directory of the main source file or main library file and is ! -- filled in by each call to Next_Main_Source/Next_Main_Lib_File with ! -- the directory specified for this main source or library file. This ! -- is the directory which is searched first by default. This default ! -- search is inhibited by the option -I- for both source and library ! -- files. ! Src_Search_Directories.Set_Last (Primary_Directory); ! Src_Search_Directories.Table (Primary_Directory) := new String'(""); ! Lib_Search_Directories.Set_Last (Primary_Directory); ! Lib_Search_Directories.Table (Primary_Directory) := new String'(""); ! end Initialize; ---------------------------- -- Is_Directory_Separator -- --- 926,1100 ---- return Src_Search_Directories.Table (Primary_Directory); end Get_Primary_Src_Search_Directory; ! ------------------------- ! -- Get_RTS_Search_Dir -- ! ------------------------- ! function Get_RTS_Search_Dir ! (Search_Dir : String; ! File_Type : Search_File_Type) ! return String_Ptr ! is ! procedure Get_Current_Dir ! (Dir : System.Address; ! Length : System.Address); ! pragma Import (C, Get_Current_Dir, "__gnat_get_current_dir"); ! Max_Path : Integer; ! pragma Import (C, Max_Path, "__gnat_max_path_len"); ! -- Maximum length of a path name ! Current_Dir : String_Ptr; ! Default_Search_Dir : String_Access; ! Default_Suffix_Dir : String_Access; ! Local_Search_Dir : String_Access; ! Norm_Search_Dir : String_Access; ! Result_Search_Dir : String_Access; ! Search_File : String_Access; ! Temp_String : String_Ptr; begin ! -- Add a directory separator at the end of the directory if necessary ! -- so that we can directly append a file to the directory ! if Search_Dir (Search_Dir'Last) /= Directory_Separator then ! Local_Search_Dir := new String' ! (Concat (Search_Dir, String' (1 => Directory_Separator))); ! else ! Local_Search_Dir := new String' (Search_Dir); ! end if; ! if File_Type = Include then ! Search_File := Include_Search_File; ! Default_Suffix_Dir := new String'("adainclude"); ! else ! Search_File := Objects_Search_File; ! Default_Suffix_Dir := new String' ("adalib"); end if; ! Norm_Search_Dir := To_Canonical_Path_Spec (Local_Search_Dir.all); ! if Is_Absolute_Path (Norm_Search_Dir.all) then ! -- We first verify if there is a directory Include_Search_Dir ! -- containing default search directories ! Result_Search_Dir ! := Read_Default_Search_Dirs (Norm_Search_Dir, ! Search_File, ! null); ! Default_Search_Dir := new String' ! (Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all)); ! Free (Norm_Search_Dir); ! if Result_Search_Dir /= null then ! return String_Ptr (Result_Search_Dir); ! elsif Is_Directory (Default_Search_Dir.all) then ! return String_Ptr (Default_Search_Dir); ! else ! return null; ! end if; ! else ! -- Search in the current directory ! -- Get the current directory ! declare ! Buffer : String (1 .. Max_Path + 2); ! Path_Len : Natural := Max_Path; ! begin ! Get_Current_Dir (Buffer'Address, Path_Len'Address); ! if Buffer (Path_Len) /= Directory_Separator then ! Path_Len := Path_Len + 1; ! Buffer (Path_Len) := Directory_Separator; ! end if; ! Current_Dir := new String'(Buffer (1 .. Path_Len)); ! end; ! Norm_Search_Dir := ! new String' ! (Concat (Current_Dir.all, Local_Search_Dir.all)); ! ! Result_Search_Dir := ! Read_Default_Search_Dirs ! (String_Access (Update_Path (String_Ptr (Norm_Search_Dir))), ! Search_File, ! null); ! ! Default_Search_Dir := ! new String' ! (Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all)); ! ! Free (Norm_Search_Dir); ! ! if Result_Search_Dir /= null then ! return String_Ptr (Result_Search_Dir); ! ! elsif Is_Directory (Default_Search_Dir.all) then ! return String_Ptr (Default_Search_Dir); ! ! else ! -- Search in Search_Dir_Prefix/Search_Dir ! ! Norm_Search_Dir := ! new String' ! (Concat (Search_Dir_Prefix.all, Local_Search_Dir.all)); ! ! Result_Search_Dir := ! Read_Default_Search_Dirs ! (String_Access (Update_Path (String_Ptr (Norm_Search_Dir))), ! Search_File, ! null); ! ! Default_Search_Dir := ! new String' ! (Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all)); ! ! Free (Norm_Search_Dir); ! ! if Result_Search_Dir /= null then ! return String_Ptr (Result_Search_Dir); ! ! elsif Is_Directory (Default_Search_Dir.all) then ! return String_Ptr (Default_Search_Dir); ! ! else ! -- We finally search in Search_Dir_Prefix/rts-Search_Dir ! ! Temp_String := ! new String'(Concat (Search_Dir_Prefix.all, "rts-")); ! ! Norm_Search_Dir := ! new String' (Concat (Temp_String.all, Local_Search_Dir.all)); ! ! Result_Search_Dir := ! Read_Default_Search_Dirs ! (String_Access (Update_Path (String_Ptr (Norm_Search_Dir))), ! Search_File, ! null); ! ! Default_Search_Dir := ! new String' ! (Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all)); ! Free (Norm_Search_Dir); ! ! if Result_Search_Dir /= null then ! return String_Ptr (Result_Search_Dir); ! ! elsif Is_Directory (Default_Search_Dir.all) then ! return String_Ptr (Default_Search_Dir); ! ! else ! return null; ! end if; ! end if; ! end if; ! end if; ! end Get_RTS_Search_Dir; ---------------------------- -- Is_Directory_Separator -- *************** package body Osint is *** 1330,1336 **** Get_Name_String (Source_File); Fptr := Name_Len + 1; ! for J in reverse 1 .. Name_Len loop if Name_Buffer (J) = '.' then Fptr := J; exit; --- 1142,1148 ---- Get_Name_String (Source_File); Fptr := Name_Len + 1; ! for J in reverse 2 .. Name_Len loop if Name_Buffer (J) = '.' then Fptr := J; exit; *************** package body Osint is *** 1447,1472 **** return (Current_File_Name_Index < Number_File_Names); end More_Files; - -------------------- - -- More_Lib_Files -- - -------------------- - - function More_Lib_Files return Boolean is - begin - pragma Assert (In_Binder); - return More_Files; - end More_Lib_Files; - - ----------------------- - -- More_Source_Files -- - ----------------------- - - function More_Source_Files return Boolean is - begin - pragma Assert (In_Compiler or else In_Make); - return More_Files; - end More_Source_Files; - ------------------------------- -- Nb_Dir_In_Obj_Search_Path -- ------------------------------- --- 1259,1264 ---- *************** package body Osint is *** 1530,1549 **** Dir_Name := new String'(File_Name (File_Name'First .. Fptr - 1)); ! if In_Compiler then ! Src_Search_Directories.Table (Primary_Directory) := Dir_Name; ! Look_In_Primary_Directory_For_Current_Main := True; ! elsif In_Make then ! Src_Search_Directories.Table (Primary_Directory) := Dir_Name; ! if Fptr > File_Name'First then Look_In_Primary_Directory_For_Current_Main := True; - end if; ! else pragma Assert (In_Binder); ! Dir_Name := Normalize_Directory_Name (Dir_Name.all); ! Lib_Search_Directories.Table (Primary_Directory) := Dir_Name; ! end if; Name_Len := File_Name'Last - Fptr + 1; Name_Buffer (1 .. Name_Len) := File_Name (Fptr .. File_Name'Last); --- 1322,1347 ---- Dir_Name := new String'(File_Name (File_Name'First .. Fptr - 1)); ! case Running_Program is ! when Compiler => ! Src_Search_Directories.Table (Primary_Directory) := Dir_Name; Look_In_Primary_Directory_For_Current_Main := True; ! when Make => ! Src_Search_Directories.Table (Primary_Directory) := Dir_Name; ! ! if Fptr > File_Name'First then ! Look_In_Primary_Directory_For_Current_Main := True; ! end if; ! ! when Binder | Gnatls => ! Dir_Name := Normalize_Directory_Name (Dir_Name.all); ! Lib_Search_Directories.Table (Primary_Directory) := Dir_Name; ! ! when Unspecified => ! null; ! end case; Name_Len := File_Name'Last - Fptr + 1; Name_Buffer (1 .. Name_Len) := File_Name (Fptr .. File_Name'Last); *************** package body Osint is *** 1553,1559 **** -- In the gnatmake case, the main file may have not have the -- extension. Try ".adb" first then ".ads" ! if In_Make then declare Orig_Main : File_Name_Type := Current_Main; --- 1351,1357 ---- -- In the gnatmake case, the main file may have not have the -- extension. Try ".adb" first then ".ads" ! if Running_Program = Make then declare Orig_Main : File_Name_Type := Current_Main; *************** package body Osint is *** 1576,1603 **** return Current_Main; end Next_Main_File; - ------------------------ - -- Next_Main_Lib_File -- - ------------------------ - - function Next_Main_Lib_File return File_Name_Type is - begin - pragma Assert (In_Binder); - return Next_Main_File; - end Next_Main_Lib_File; - - ---------------------- - -- Next_Main_Source -- - ---------------------- - - function Next_Main_Source return File_Name_Type is - Main_File : File_Name_Type := Next_Main_File; - - begin - pragma Assert (In_Compiler or else In_Make); - return Main_File; - end Next_Main_Source; - ------------------------------ -- Normalize_Directory_Name -- ------------------------------ --- 1374,1379 ---- *************** package body Osint is *** 1962,1979 **** end Read_Library_Info; - -- Version with default file name - - procedure Read_Library_Info - (Name : out File_Name_Type; - Text : out Text_Buffer_Ptr) - is - begin - Set_Library_Info_Name; - Name := Name_Find; - Text := Read_Library_Info (Name, Fatal_Err => False); - end Read_Library_Info; - ---------------------- -- Read_Source_File -- ---------------------- --- 1738,1743 ---- *************** package body Osint is *** 2087,2189 **** end Read_Source_File; ! -------------------------------- ! -- Record_Time_From_Last_Bind -- ! -------------------------------- ! ! procedure Record_Time_From_Last_Bind is ! begin ! Recording_Time_From_Last_Bind := True; ! end Record_Time_From_Last_Bind; ! ! --------------------------- ! -- Set_Library_Info_Name -- ! --------------------------- ! ! procedure Set_Library_Info_Name is ! Dot_Index : Natural; ! ! begin ! pragma Assert (In_Compiler); ! Get_Name_String (Current_Main); ! ! -- Find last dot since we replace the existing extension by .ali. The ! -- initialization to Name_Len + 1 provides for simply adding the .ali ! -- extension if the source file name has no extension. ! ! Dot_Index := Name_Len + 1; ! for J in reverse 1 .. Name_Len loop ! if Name_Buffer (J) = '.' then ! Dot_Index := J; ! exit; ! end if; ! end loop; ! ! -- Make sure that the output file name matches the source file name. ! -- To compare them, remove file name directories and extensions. ! ! if Output_Object_File_Name /= null then ! declare ! Name : constant String := Name_Buffer (1 .. Dot_Index); ! Len : constant Natural := Dot_Index; ! ! begin ! Name_Buffer (1 .. Output_Object_File_Name'Length) ! := Output_Object_File_Name.all; ! Dot_Index := 0; ! ! for J in reverse Output_Object_File_Name'Range loop ! if Name_Buffer (J) = '.' then ! Dot_Index := J; ! exit; ! end if; ! end loop; ! ! pragma Assert (Dot_Index /= 0); ! -- We check for the extension elsewhere ! ! if Name /= Name_Buffer (Dot_Index - Len + 1 .. Dot_Index) then ! Fail ("incorrect object file name"); ! end if; ! end; ! end if; ! ! Name_Buffer (Dot_Index) := '.'; ! Name_Buffer (Dot_Index + 1 .. Dot_Index + 3) := ALI_Suffix.all; ! Name_Buffer (Dot_Index + 4) := ASCII.NUL; ! Name_Len := Dot_Index + 3; ! end Set_Library_Info_Name; ! ! --------------------------------- ! -- Set_Output_Object_File_Name -- ! --------------------------------- ! ! procedure Set_Output_Object_File_Name (Name : String) is ! Ext : constant String := Object_Suffix; ! NL : constant Natural := Name'Length; ! EL : constant Natural := Ext'Length; begin ! -- Make sure that the object file has the expected extension. ! ! if NL <= EL ! or else Name (NL - EL + Name'First .. Name'Last) /= Ext ! then ! Fail ("incorrect object file extension"); end if; ! Output_Object_File_Name := new String'(Name); ! end Set_Output_Object_File_Name; ! ! ------------------------ ! -- Set_Main_File_Name -- ! ------------------------ ! ! procedure Set_Main_File_Name (Name : String) is ! begin ! Number_File_Names := Number_File_Names + 1; ! File_Names (Number_File_Names) := new String'(Name); ! end Set_Main_File_Name; ---------------------- -- Smart_File_Stamp -- --- 1851,1869 ---- end Read_Source_File; ! ----------------- ! -- Set_Program -- ! ----------------- + procedure Set_Program (P : Program_Type) is begin ! if Program_Set then ! Fail ("Set_Program called twice"); end if; ! Program_Set := True; ! Running_Program := P; ! end Set_Program; ---------------------- -- Smart_File_Stamp -- *************** package body Osint is *** 2263,2288 **** begin Get_Name_String (Name); ! declare ! S : String (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); ! Fptr : Natural := S'First; ! begin ! for J in reverse S'Range loop ! if Is_Directory_Separator (S (J)) then ! Fptr := J + 1; ! exit; ! end if; ! end loop; ! if Fptr = S'First then ! return Name; end if; ! Name_Buffer (1 .. S'Last - Fptr + 1) := S (Fptr .. S'Last); ! Name_Len := S'Last - Fptr + 1; ! return Name_Find; ! end; end Strip_Directory; ------------------ --- 1943,1964 ---- begin Get_Name_String (Name); ! for J in reverse 1 .. Name_Len - 1 loop ! -- If we find the last directory separator ! if Is_Directory_Separator (Name_Buffer (J)) then ! -- Return the part of Name that follows this last directory ! -- separator. ! Name_Buffer (1 .. Name_Len - J) := Name_Buffer (J + 1 .. Name_Len); ! Name_Len := Name_Len - J; ! return Name_Find; end if; + end loop; ! -- There were no directory separator, just return Name ! ! return Name; end Strip_Directory; ------------------ *************** package body Osint is *** 2293,2299 **** begin Get_Name_String (Name); ! for J in reverse 1 .. Name_Len loop if Name_Buffer (J) = '.' then Name_Len := J - 1; return Name_Enter; --- 1969,1979 ---- begin Get_Name_String (Name); ! for J in reverse 2 .. Name_Len loop ! ! -- If we found the last '.', return the part of Name that precedes ! -- this '.'. ! if Name_Buffer (J) = '.' then Name_Len := J - 1; return Name_Enter; *************** package body Osint is *** 2303,2373 **** return Name; end Strip_Suffix; - ------------------------- - -- Time_From_Last_Bind -- - ------------------------- - - function Time_From_Last_Bind return Nat is - Old_Y : Nat; - Old_M : Nat; - Old_D : Nat; - Old_H : Nat; - Old_Mi : Nat; - Old_S : Nat; - New_Y : Nat; - New_M : Nat; - New_D : Nat; - New_H : Nat; - New_Mi : Nat; - New_S : Nat; - - type Month_Data is array (Int range 1 .. 12) of Int; - Cumul : constant Month_Data := (0, 0, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7); - -- Represents the difference in days from a period compared to the - -- same period if all months had 31 days, i.e: - -- - -- Cumul (m) = 31x(m-1) - (number of days from 01/01 to m/01) - - Res : Int; - - begin - if not Recording_Time_From_Last_Bind - or else not Binder_Output_Time_Stamps_Set - or else Old_Binder_Output_Time_Stamp = Empty_Time_Stamp - then - return Nat'Last; - end if; - - Split_Time_Stamp - (Old_Binder_Output_Time_Stamp, - Old_Y, Old_M, Old_D, Old_H, Old_Mi, Old_S); - - Split_Time_Stamp - (New_Binder_Output_Time_Stamp, - New_Y, New_M, New_D, New_H, New_Mi, New_S); - - Res := New_Mi - Old_Mi; - - -- 60 minutes in an hour - - Res := Res + 60 * (New_H - Old_H); - - -- 24 hours in a day - - Res := Res + 60 * 24 * (New_D - Old_D); - - -- Almost 31 days in a month - - Res := Res + 60 * 24 * - (31 * (New_M - Old_M) - Cumul (New_M) + Cumul (Old_M)); - - -- 365 days in a year - - Res := Res + 60 * 24 * 365 * (New_Y - Old_Y); - - return Res; - end Time_From_Last_Bind; - --------------------------- -- To_Canonical_Dir_Spec -- --------------------------- --- 1983,1988 ---- *************** package body Osint is *** 2637,2697 **** return Return_Val; end To_Path_String_Access; - ---------------- - -- Tree_Close -- - ---------------- - - procedure Tree_Close is - begin - pragma Assert (In_Compiler); - Tree_Write_Terminate; - Close (Output_FD); - end Tree_Close; - ----------------- ! -- Tree_Create -- ----------------- ! procedure Tree_Create is ! Dot_Index : Natural; ! ! begin ! pragma Assert (In_Compiler); ! Get_Name_String (Current_Main); ! ! -- If an object file has been specified, then the ALI file ! -- will be in the same directory as the object file; ! -- so, we put the tree file in this same directory, ! -- even though no object file needs to be generated. ! ! if Output_Object_File_Name /= null then ! Name_Len := Output_Object_File_Name'Length; ! Name_Buffer (1 .. Name_Len) := Output_Object_File_Name.all; ! end if; ! Dot_Index := 0; ! for J in reverse 1 .. Name_Len loop ! if Name_Buffer (J) = '.' then ! Dot_Index := J; ! exit; ! end if; ! end loop; ! -- Should be impossible to not have an extension ! pragma Assert (Dot_Index /= 0); ! -- Change exctension to adt ! Name_Buffer (Dot_Index + 1) := 'a'; ! Name_Buffer (Dot_Index + 2) := 'd'; ! Name_Buffer (Dot_Index + 3) := 't'; ! Name_Buffer (Dot_Index + 4) := ASCII.NUL; ! Name_Len := Dot_Index + 3; ! Create_File_And_Check (Output_FD, Binary); ! Tree_Write_Initialize (Output_FD); ! end Tree_Create; ---------------- -- Write_Info -- --- 2252,2290 ---- return Return_Val; end To_Path_String_Access; ----------------- ! -- Update_Path -- ----------------- ! function Update_Path (Path : String_Ptr) return String_Ptr is ! function C_Update_Path (Path, Component : Address) return Address; ! pragma Import (C, C_Update_Path, "update_path"); ! function Strlen (Str : Address) return Integer; ! pragma Import (C, Strlen, "strlen"); ! procedure Strncpy (X : Address; Y : Address; Length : Integer); ! pragma Import (C, Strncpy, "strncpy"); ! In_Length : constant Integer := Path'Length; ! In_String : String (1 .. In_Length + 1); ! Component_Name : aliased String := "GNAT" & ASCII.NUL; ! Result_Ptr : Address; ! Result_Length : Integer; ! Out_String : String_Ptr; ! begin ! In_String (1 .. In_Length) := Path.all; ! In_String (In_Length + 1) := ASCII.NUL; ! Result_Ptr := C_Update_Path (In_String'Address, ! Component_Name'Address); ! Result_Length := Strlen (Result_Ptr); ! Out_String := new String (1 .. Result_Length); ! Strncpy (Out_String.all'Address, Result_Ptr, Result_Length); ! return Out_String; ! end Update_Path; ---------------- -- Write_Info -- *************** package body Osint is *** 2699,2727 **** procedure Write_Info (Info : String) is begin - pragma Assert (In_Binder or In_Compiler); Write_With_Check (Info'Address, Info'Length); Write_With_Check (EOL'Address, 1); end Write_Info; - ----------------------- - -- Write_Binder_Info -- - ----------------------- - - procedure Write_Binder_Info (Info : String) renames Write_Info; - - ----------------------- - -- Write_Debug_Info -- - ----------------------- - - procedure Write_Debug_Info (Info : String) renames Write_Info; - - ------------------------ - -- Write_Library_Info -- - ------------------------ - - procedure Write_Library_Info (Info : String) renames Write_Info; - ------------------------ -- Write_Program_Name -- ------------------------ --- 2292,2301 ---- *************** package body Osint is *** 2774,2777 **** --- 2348,2405 ---- end if; end Write_With_Check; + ---------------------------- + -- Package Initialization -- + ---------------------------- + + begin + Initialization : declare + + function Get_Default_Identifier_Character_Set return Character; + pragma Import (C, Get_Default_Identifier_Character_Set, + "__gnat_get_default_identifier_character_set"); + -- Function to determine the default identifier character set, + -- which is system dependent. See Opt package spec for a list of + -- the possible character codes and their interpretations. + + function Get_Maximum_File_Name_Length return Int; + pragma Import (C, Get_Maximum_File_Name_Length, + "__gnat_get_maximum_file_name_length"); + -- Function to get maximum file name length for system + + begin + Src_Search_Directories.Init; + Lib_Search_Directories.Init; + + Identifier_Character_Set := Get_Default_Identifier_Character_Set; + Maximum_File_Name_Length := Get_Maximum_File_Name_Length; + + -- Following should be removed by having above function return + -- Integer'Last as indication of no maximum instead of -1 ??? + + if Maximum_File_Name_Length = -1 then + Maximum_File_Name_Length := Int'Last; + end if; + + -- Start off by setting all suppress options to False, these will + -- be reset later (turning some on if -gnato is not specified, and + -- turning all of them on if -gnatp is specified). + + Suppress_Options := (others => False); + + -- Reserve the first slot in the search paths table. This is the + -- directory of the main source file or main library file and is + -- filled in by each call to Next_Main_Source/Next_Main_Lib_File with + -- the directory specified for this main source or library file. This + -- is the directory which is searched first by default. This default + -- search is inhibited by the option -I- for both source and library + -- files. + + Src_Search_Directories.Set_Last (Primary_Directory); + Src_Search_Directories.Table (Primary_Directory) := new String'(""); + + Lib_Search_Directories.Set_Last (Primary_Directory); + Lib_Search_Directories.Table (Primary_Directory) := new String'(""); + end Initialization; + end Osint; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint.ads gcc-3.3/gcc/ada/osint.ads *** gcc-3.2.3/gcc/ada/osint.ads 2002-05-04 03:28:22.000000000 +0000 --- gcc-3.3/gcc/ada/osint.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 28,48 **** -- This package contains the low level, operating system routines used in -- the GNAT compiler and binder for command line processing and file input ! -- output. The specification is suitable for use with MS-DOS, Unix, and ! -- similar systems. Note that for input source and library information ! -- files, the line terminator may be either CR/LF or LF alone, and the ! -- DOS-style EOF (16#1A#) character marking the end of the text in a ! -- file may be used in all systems including Unix. This allows for more ! -- convenient processing of DOS files in a Unix environment. with GNAT.OS_Lib; use GNAT.OS_Lib; with System; use System; with Types; use Types; ! package Osint is ! procedure Set_Main_File_Name (Name : String); ! -- Set the main file name for Gnatmake. function Normalize_Directory_Name (Directory : String) return String_Ptr; -- Verify and normalize a directory name. If directory name is invalid, --- 27,41 ---- -- This package contains the low level, operating system routines used in -- the GNAT 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; ! pragma Elaborate (GNAT.OS_Lib); ! package Osint is function Normalize_Directory_Name (Directory : String) return String_Ptr; -- Verify and normalize a directory name. If directory name is invalid, *************** package Osint is *** 55,83 **** (N : File_Name_Type; T : File_Type) return File_Name_Type; ! -- Finds a source or library 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. ! ! function Get_Switch_Character return Character; ! pragma Import (C, Get_Switch_Character, "__gnat_get_switch_character"); ! Switch_Character : constant Character := Get_Switch_Character; ! -- Set to the default switch character (note that minus is always an ! -- acceptable alternative switch character) function Get_File_Names_Case_Sensitive return Int; pragma Import (C, Get_File_Names_Case_Sensitive, ! "__gnat_get_file_names_case_sensitive"); File_Names_Case_Sensitive : constant Boolean := ! Get_File_Names_Case_Sensitive /= 0; -- Set to indicate whether the operating system convention is for file -- names to be case sensitive (e.g., in Unix, set True), or non case -- sensitive (e.g., in OS/2, set False). --- 48,71 ---- (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. function Get_File_Names_Case_Sensitive return Int; pragma Import (C, Get_File_Names_Case_Sensitive, ! "__gnat_get_file_names_case_sensitive"); File_Names_Case_Sensitive : constant Boolean := ! Get_File_Names_Case_Sensitive /= 0; -- Set to indicate whether the operating system convention is for file -- names to be case sensitive (e.g., in Unix, set True), or non case -- sensitive (e.g., in OS/2, set False). *************** package Osint is *** 97,125 **** -- Called by the subprogram processing the command line for each -- file name found. - procedure Set_Output_Object_File_Name (Name : String); - -- Called by the subprogram processing the command line when an - -- output object file name is found. - - type Program_Type is (Compiler, Binder, Make); - Program : Program_Type; - -- Program currently running (set by Initialize below) - - procedure Initialize (P : Program_Type); - -- This routine scans parameters and initializes for the first call to - -- Next_Main_Source (Compiler or Make) or Next_Main_Lib_File (Binder). - -- It also resets any of the variables in package Opt in response to - -- command switch settings. - -- - -- Initialize may terminate execution if the parameters are invalid or some - -- other fatal error is encountered. The interface is set up to - -- accommodate scanning a series of files (e.g. as the result of - -- wild card references in DOS, or an expanded list of source files - -- in Unix). Of course it is perfectly possible to ignore this in - -- the implementation and provide for opening only one file. - -- The parameter P is the program (Compiler, Binder or Make) that is - -- actually running. - procedure Find_Program_Name; -- Put simple name of current program being run (excluding the directory -- path) in Name_Buffer, with the length in Name_Len. --- 85,90 ---- *************** package Osint is *** 133,161 **** -- Name_Buffer and Name_Len. procedure Write_Program_Name; ! -- Writes name of program as invoked to standard output procedure Fail (S1 : String; S2 : String := ""; S3 : String := ""); -- Outputs error messages S1 & S2 & S3 preceded by the name of the ! -- executing program and exits with E_Fatal. function Is_Directory_Separator (C : Character) return Boolean; -- Returns True if C is a directory separator function Get_Directory (Name : File_Name_Type) return File_Name_Type; -- Get the prefix directory name (if any) from Name. The last separator ! -- is preserved. Return No_File if there is no directory part in the ! -- name. function Is_Readonly_Library (File : File_Name_Type) return Boolean; -- Check if this library file is a read-only file. function Strip_Directory (Name : File_Name_Type) return File_Name_Type; -- Strips the prefix directory name (if any) from Name. Returns the ! -- stripped name. function Strip_Suffix (Name : File_Name_Type) return File_Name_Type; ! -- Strips the suffix (the '.' and whatever comes after it) from Name. -- Returns the stripped name. function Executable_Name (Name : File_Name_Type) return File_Name_Type; --- 98,129 ---- -- Name_Buffer and Name_Len. procedure Write_Program_Name; ! -- Writes name of program as invoked to the current output ! -- (normally standard output). procedure Fail (S1 : String; S2 : String := ""; S3 : String := ""); + pragma No_Return (Fail); -- Outputs error messages S1 & S2 & S3 preceded by the name of the ! -- executing program and exits with E_Fatal. The output goes to ! -- standard error, except if special output is in effect (see Output). function Is_Directory_Separator (C : Character) return Boolean; -- Returns True if C is a directory separator function Get_Directory (Name : File_Name_Type) return File_Name_Type; -- Get the prefix directory name (if any) from Name. The last separator ! -- is preserved. Return the normalized current directory if there is no ! -- directory part in the name. function Is_Readonly_Library (File : File_Name_Type) return Boolean; -- Check if this library file is a read-only file. function Strip_Directory (Name : File_Name_Type) return File_Name_Type; -- Strips the prefix directory name (if any) from Name. Returns the ! -- stripped name. Name cannot end with a directory separator. function Strip_Suffix (Name : File_Name_Type) return File_Name_Type; ! -- Strips the suffix (the last '.' and whatever comes after it) from Name. -- Returns the stripped name. function Executable_Name (Name : File_Name_Type) return File_Name_Type; *************** package Osint is *** 170,202 **** -- opened, or Name = No_File, and all blank time stamp is returned (this is -- not an error situation). - procedure Record_Time_From_Last_Bind; - -- Trigger the computing of the time from the last bind of the same - -- program. - - function Time_From_Last_Bind return Nat; - -- This function give an approximate number of minute from the last bind. - -- It bases its computation on file stamp and therefore does gibe not - -- any meaningful result before the new output binder file is written. - -- So it returns Nat'last if - -- - it is the first bind of this specific program - -- - Record_Time_From_Last_Bind was not Called first - -- - Close_Binder_Output was not called first - -- otherwise returns the number of minutes - -- till the last bind. The computation does not try to be completely - -- accurate and in particular does not take leap years into account. - type String_Access_List is array (Positive range <>) of String_Access; -- Deferenced type used to return a list of file specs in -- To_Canonical_File_List. type String_Access_List_Access is access all String_Access_List; ! -- Type used to return a String_Access_List without dragging in secondary -- stack. function To_Canonical_File_List ! (Wildcard_Host_File : String; Only_Dirs : Boolean) ! return String_Access_List_Access; -- Expand a wildcard host syntax file or directory specification (e.g. on -- a VMS host, any file or directory spec that contains: -- "*", or "%", or "...") --- 138,155 ---- -- opened, or Name = No_File, and all blank time stamp is returned (this is -- not an error situation). type String_Access_List is array (Positive range <>) of String_Access; -- Deferenced type used to return a list of file specs in -- To_Canonical_File_List. type String_Access_List_Access is access all String_Access_List; ! -- Type used to return a String_Access_List without dragging in secondary -- stack. function To_Canonical_File_List ! (Wildcard_Host_File : String; ! Only_Dirs : Boolean) ! return String_Access_List_Access; -- Expand a wildcard host syntax file or directory specification (e.g. on -- a VMS host, any file or directory spec that contains: -- "*", or "%", or "...") *************** package Osint is *** 206,212 **** function To_Canonical_Dir_Spec (Host_Dir : String; Prefix_Style : Boolean) ! return String_Access; -- Convert a host syntax directory specification (e.g. on a VMS host: -- "SYS$DEVICE:[DIR]") to canonical (Unix) syntax (e.g. "/sys$device/dir"). -- If Prefix_Style then make it a valid file specification prefix. --- 159,165 ---- function To_Canonical_Dir_Spec (Host_Dir : String; Prefix_Style : Boolean) ! return String_Access; -- Convert a host syntax directory specification (e.g. on a VMS host: -- "SYS$DEVICE:[DIR]") to canonical (Unix) syntax (e.g. "/sys$device/dir"). -- If Prefix_Style then make it a valid file specification prefix. *************** package Osint is *** 217,230 **** function To_Canonical_File_Spec (Host_File : String) ! return String_Access; -- Convert a host syntax file specification (e.g. on a VMS host: -- "SYS$DEVICE:[DIR]FILE.EXT;69 to canonical (Unix) syntax (e.g. -- "/sys$device/dir/file.ext.69"). function To_Canonical_Path_Spec (Host_Path : String) ! return String_Access; -- Convert a host syntax Path specification (e.g. on a VMS host: -- "SYS$DEVICE:[BAR],DISK$USER:[FOO] to canonical (Unix) syntax (e.g. -- "/sys$device/foo:disk$user/foo"). --- 170,183 ---- function To_Canonical_File_Spec (Host_File : String) ! return String_Access; -- Convert a host syntax file specification (e.g. on a VMS host: -- "SYS$DEVICE:[DIR]FILE.EXT;69 to canonical (Unix) syntax (e.g. -- "/sys$device/dir/file.ext.69"). function To_Canonical_Path_Spec (Host_Path : String) ! return String_Access; -- Convert a host syntax Path specification (e.g. on a VMS host: -- "SYS$DEVICE:[BAR],DISK$USER:[FOO] to canonical (Unix) syntax (e.g. -- "/sys$device/foo:disk$user/foo"). *************** package Osint is *** 232,245 **** function To_Host_Dir_Spec (Canonical_Dir : String; Prefix_Style : Boolean) ! return String_Access; -- Convert a canonical syntax directory specification to host syntax. -- The Prefix_Style flag is currently ignored but should be set to -- False. function To_Host_File_Spec (Canonical_File : String) ! return String_Access; -- Convert a canonical syntax file specification to host syntax. ------------------------- --- 185,198 ---- function To_Host_Dir_Spec (Canonical_Dir : String; Prefix_Style : Boolean) ! return String_Access; -- Convert a canonical syntax directory specification to host syntax. -- The Prefix_Style flag is currently ignored but should be set to -- False. function To_Host_File_Spec (Canonical_File : String) ! return String_Access; -- Convert a canonical syntax file specification to host syntax. ------------------------- *************** package Osint is *** 267,275 **** -- name, and calls to the function return successive directory names, -- with a null pointer marking the end of the list. function Get_Primary_Src_Search_Directory return String_Ptr; -- Retrieved the primary directory (directory containing the main source ! -- file for Gnatmake. function Nb_Dir_In_Src_Search_Path return Natural; function Dir_In_Src_Search_Path (Position : Natural) return String_Ptr; --- 220,236 ---- -- name, and calls to the function return successive directory names, -- with a null pointer marking the end of the list. + type Search_File_Type is (Include, Objects); + + procedure Add_Search_Dirs + (Search_Path : String_Ptr; + Path_Type : Search_File_Type); + -- These procedure adds all the search directories that are in Search_Path + -- in the proper file search path (library or source) + function Get_Primary_Src_Search_Directory return String_Ptr; -- Retrieved the primary directory (directory containing the main source ! -- file for Gnatmake. function Nb_Dir_In_Src_Search_Path return Natural; function Dir_In_Src_Search_Path (Position : Natural) return String_Ptr; *************** package Osint is *** 279,301 **** function Dir_In_Obj_Search_Path (Position : Natural) return String_Ptr; -- Functions to access the directory names in the Object search path ! Include_Search_File : constant String_Access ! := new String'("ada_source_path"); ! Objects_Search_File : constant String_Access ! := new String'("ada_object_path"); ! ! -- Files containg the default include or objects search directories. function Read_Default_Search_Dirs ! (Search_Dir_Prefix : String_Access; ! Search_File : String_Access; Search_Dir_Default_Name : String_Access) ! return String_Access; -- Read and return the default search directories from the file located -- in Search_Dir_Prefix (as modified by update_path) and named Search_File. -- If no such file exists or an error occurs then instead return the -- Search_Dir_Default_Name (as modified by update_path). ----------------------- -- Source File Input -- ----------------------- --- 240,283 ---- function Dir_In_Obj_Search_Path (Position : Natural) return String_Ptr; -- Functions to access the directory names in the Object search path ! Include_Search_File : constant String_Access := ! new String'("ada_source_path"); ! Objects_Search_File : constant String_Access := ! new String'("ada_object_path"); ! -- Names of the files containg the default include or objects search ! -- directories. These files, located in Sdefault.Search_Dir_Prefix, do ! -- not necessarily exist. function Read_Default_Search_Dirs ! (Search_Dir_Prefix : String_Access; ! Search_File : String_Access; Search_Dir_Default_Name : String_Access) ! return String_Access; -- Read and return the default search directories from the file located -- in Search_Dir_Prefix (as modified by update_path) and named Search_File. -- If no such file exists or an error occurs then instead return the -- Search_Dir_Default_Name (as modified by update_path). + function Get_RTS_Search_Dir + (Search_Dir : String; + File_Type : Search_File_Type) + return String_Ptr; + -- This function retrieves the paths to the search (resp. lib) dirs and + -- return them. The search dir can be absolute or relative. If the search + -- dir contains Include_Search_File (resp. Object_Search_File), then this + -- function reads and returns the default search directories from the file. + -- Otherwise, if the directory is absolute, it will try to find 'adalib' + -- (resp. 'adainclude'). If found, null is returned. If the directory is + -- relative, the following directories for the directories 'adalib' and + -- 'adainclude' will be scanned: + -- + -- - current directory (from which the tool has been spawned) + -- - $GNAT_ROOT/gcc/gcc-lib/$targ/$vers/ + -- - $GNAT_ROOT/gcc/gcc-lib/$targ/$vers/rts- + -- + -- The scan will stop as soon as the directory being searched for (adalib + -- or adainclude) is found. If the scan fails, null is returned. + ----------------------- -- Source File Input -- ----------------------- *************** package Osint is *** 304,321 **** -- source files and the subsidiary source files (e.g. with'ed units), and -- also by the binder to check presence/time stamps of sources. - function More_Source_Files return Boolean; - -- Indicates whether more source file remain to be processed. Returns - -- False right away if no source files, or if all source files have - -- been processed. - - function Next_Main_Source return File_Name_Type; - -- This function returns the name of the next main source file specified - -- on the command line. It is an error to call Next_Main_Source if no more - -- source files exist (i.e. Next_Main_Source may be called only if a - -- previous call to More_Source_Files returned True). This name is the - -- simple file name (without any directory information). - procedure Read_Source_File (N : File_Name_Type; Lo : Source_Ptr; --- 286,291 ---- *************** package Osint is *** 436,453 **** -- These subprograms are used by the binder to read library information -- files, see section above for representation of these files. - function More_Lib_Files return Boolean; - -- Indicates whether more library information files remain to be processed. - -- Returns False right away if no source files, or if all source files - -- have been processed. - - function Next_Main_Lib_File return File_Name_Type; - -- This function returns the name of the next library info file specified - -- on the command line. It is an error to call Next_Main_Lib_File if no - -- more library information files exist (i.e. Next_Main_Lib_File may be - -- called only if a previous call to More_Lib_Files returned True). This - -- name is the simple name, excluding any directory information. - function Read_Library_Info (Lib_File : File_Name_Type; Fatal_Err : Boolean := False) --- 406,411 ---- *************** package Osint is *** 477,491 **** -- behaves as if it did not find Lib_File (namely if Fatal_Err is -- False, null is returned). - procedure Read_Library_Info - (Name : out File_Name_Type; - Text : out Text_Buffer_Ptr); - -- The procedure version of Read_Library_Info is used from the compiler - -- to read an existing ali file associated with the main unit. If the - -- ALI file exists, then its file name is returned in Name, and its - -- text is returned in Text. If the file does not exist, then Text is - -- set to null. - function Full_Library_Info_Name return File_Name_Type; function Full_Object_File_Name return File_Name_Type; -- Returns the full name of the library/object file most recently read --- 435,440 ---- *************** package Osint is *** 511,549 **** -- file directory lookup penalty is incurred every single time this -- routine is called. - 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. - - -------------------------------- - -- Library Information Output -- - -------------------------------- - - -- These routines are used by the compiler to generate the library - -- information file for the main source file being compiled. See section - -- above for a discussion of how library information files are stored. - - procedure Create_Output_Library_Info; - -- Creates the output library information file for the source file which - -- is currently being compiled (i.e. the file which was most recently - -- returned by Next_Main_Source). - - procedure Write_Library_Info (Info : String); - -- Writes the contents of the referenced string to the library information - -- file for the main source file currently being compiled (i.e. the file - -- which was most recently opened with a call to Read_Next_File). Info - -- represents a single line in the file, but does not contain any line - -- termination characters. The implementation of Write_Library_Info is - -- responsible for adding necessary end of line and end of file control - -- characters to the generated file. - - procedure Close_Output_Library_Info; - -- Closes the file created by Create_Output_Library_Info, flushing any - -- buffers etc from writes by Write_Library_Info. - function Lib_File_Name (Source_File : File_Name_Type) return File_Name_Type; -- Given the name of a source file, returns the name of the corresponding -- library information file. This may be the name of the object file, or --- 460,465 ---- *************** package Osint is *** 553,635 **** -- compiler to determine the proper library information names to be placed -- in the generated library information file. - ------------------------------ - -- Debug Source File Output -- - ------------------------------ - - -- These routines are used by the compiler to generate the debug source - -- file for the Debug_Generated_Code (-gnatD switch) option. Note that - -- debug source file writing occurs at a completely different point in - -- the processing from library information output, so the code in the - -- body can assume these functions are never used at the same time. - - function Create_Debug_File (Src : File_Name_Type) return File_Name_Type; - -- Given the simple name of a source file, this routine creates the - -- corresponding debug file, and returns its full name. - - procedure Write_Debug_Info (Info : String); - -- Writes contents of given string as next line of the current debug - -- source file created by the most recent call to Get_Debug_Name. Info - -- does not contain any end of line or other formatting characters. - - procedure Close_Debug_File; - -- Close current debug file created by the most recent call to - -- Get_Debug_Name. - - function Debug_File_Eol_Length return Nat; - -- Returns the number of characters (1 for NL, 2 for CR/LF) written - -- at the end of each line by Write_Debug_Info. - - -------------------------------- - -- Semantic Tree Input-Output -- - -------------------------------- - - procedure Tree_Create; - -- Creates the tree output file for the source file which is currently - -- being compiled (i.e. the file which was most recently returned by - -- Next_Main_Source), and initializes Tree_IO.Tree_Write for output. - - procedure Tree_Close; - -- Closes the file previously opened by Tree_Create - - ------------------- - -- Binder Output -- - ------------------- - - -- These routines are used by the binder to generate the C source file - -- containing the binder output. The format of this file is described - -- in the package Bindfmt. - - procedure Create_Binder_Output - (Output_File_Name : String; - Typ : Character; - Bfile : out Name_Id); - -- Creates the binder output file. Typ is one of - -- - -- 'c' create output file for case of generating C - -- 'b' create body file for case of generating Ada - -- 's' create spec file for case of generating Ada - -- - -- If Output_File_Name is null, then a default name is used based on - -- the name of the most recently accessed main source file name. If - -- Output_File_Name is non-null then it is the full path name of the - -- file to be output (in the case of Ada, it must have an extension - -- of adb, and the spec file is created by changing the last character - -- from b to s. On return, Bfile also contains the Name_Id for the - -- generated file name. - - procedure Write_Binder_Info (Info : String); - -- Writes the contents of the referenced string to the binder output file - -- created by a previous call to Create_Binder_Output. Info represents a - -- single line in the file, but does not contain any line termination - -- characters. The implementation of Write_Binder_Info is responsible - -- for adding necessary end of line and end of file control characters - -- as required by the operating system. - - procedure Close_Binder_Output; - -- Closes the file created by Create_Binder_Output, flushing any - -- buffers etc from writes by Write_Binder_Info. - ----------------- -- Termination -- ----------------- --- 469,474 ---- *************** package Osint is *** 644,649 **** --- 483,489 ---- E_Abort); -- Internally detected compiler error 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. *************** package Osint is *** 668,671 **** --- 508,582 ---- pragma Import (C, Len_Arg, "__gnat_len_arg"); -- Get length of argument + private + + ALI_Suffix : constant String_Ptr := new String'("ali"); + -- The suffix used for the library files (also known as ALI files). + + Current_Main : File_Name_Type := No_File; + -- Used to save a simple file name between calls to Next_Main_Source and + -- Read_Source_File. If the file name argument to Read_Source_File is + -- No_File, that indicates that the file whose name was returned by the + -- last call to Next_Main_Source (and stored here) is to be read. + + Object_Suffix : constant String := Get_Object_Suffix.all; + -- The suffix used for the object files. + + Output_FD : File_Descriptor; + -- The file descriptor for the current library info, 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 + -- stored does not include the trailing NUL character. + + Argument_Count : constant Integer := Arg_Count - 1; + -- Number of arguments (excluding program name) + + type File_Name_Array is array (Int range <>) of String_Ptr; + 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 in Initialize, file names are stored + -- in this array. The string does not contain a terminating NUL. + -- The array is "extensible" because when using project files, + -- there may be more file names than argument on the command line. + + Current_File_Name_Index : Int := 0; + -- The index in File_Names of the last file opened by Next_Main_Source + -- or Next_Main_Lib_File. The value 0 indicates that no files have been + -- opened yet. + + procedure Create_File_And_Check + (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). + + 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. + + function More_Files return Boolean; + -- Implements More_Source_Files and More_Lib_Files. + + function Next_Main_File return File_Name_Type; + -- 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. + + procedure Write_Info (Info : String); + -- Implementation of Write_Binder_Info, Write_Debug_Info and + -- Write_Library_Info (identical) + end Osint; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint-b.adb gcc-3.3/gcc/ada/osint-b.adb *** gcc-3.2.3/gcc/ada/osint-b.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/osint-b.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,249 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- O S I N T - B -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with Hostparm; + with Namet; use Namet; + with Opt; use Opt; + + package body Osint.B is + + Binder_Output_Time_Stamps_Set : Boolean := False; + + Old_Binder_Output_Time_Stamp : Time_Stamp_Type; + New_Binder_Output_Time_Stamp : Time_Stamp_Type; + Recording_Time_From_Last_Bind : Boolean := False; + + ------------------------- + -- Close_Binder_Output -- + ------------------------- + + procedure Close_Binder_Output is + begin + Close (Output_FD); + + if Recording_Time_From_Last_Bind then + New_Binder_Output_Time_Stamp := File_Stamp (Output_File_Name); + Binder_Output_Time_Stamps_Set := True; + end if; + end Close_Binder_Output; + + -------------------------- + -- Create_Binder_Output -- + -------------------------- + + procedure Create_Binder_Output + (Output_File_Name : String; + Typ : Character; + Bfile : out Name_Id) + is + File_Name : String_Ptr; + Findex1 : Natural; + Findex2 : Natural; + Flength : Natural; + + begin + if Output_File_Name /= "" then + Name_Buffer (Output_File_Name'Range) := Output_File_Name; + Name_Buffer (Output_File_Name'Last + 1) := ASCII.NUL; + + if Typ = 's' then + Name_Buffer (Output_File_Name'Last) := 's'; + end if; + + Name_Len := Output_File_Name'Last; + + else + Name_Buffer (1) := 'b'; + File_Name := File_Names (Current_File_Name_Index); + + Findex1 := File_Name'First; + + -- The ali file might be specified by a full path name. However, + -- the binder generated file should always be created in the + -- current directory, so the path might need to be stripped away. + -- In addition to the default directory_separator allow the '/' to + -- act as separator since this is allowed in MS-DOS and OS2 ports. + + for J in reverse File_Name'Range loop + if File_Name (J) = Directory_Separator + or else File_Name (J) = '/' + then + Findex1 := J + 1; + exit; + end if; + end loop; + + Findex2 := File_Name'Last; + while File_Name (Findex2) /= '.' loop + Findex2 := Findex2 - 1; + end loop; + + Flength := Findex2 - Findex1; + + if Maximum_File_Name_Length > 0 then + + -- Make room for the extra two characters in "b?" + + while Int (Flength) > Maximum_File_Name_Length - 2 loop + Findex2 := Findex2 - 1; + Flength := Findex2 - Findex1; + end loop; + end if; + + Name_Buffer (3 .. Flength + 2) := File_Name (Findex1 .. Findex2 - 1); + Name_Buffer (Flength + 3) := '.'; + + -- C bind file, name is b_xxx.c + + if Typ = 'c' then + Name_Buffer (2) := '_'; + Name_Buffer (Flength + 4) := 'c'; + Name_Buffer (Flength + 5) := ASCII.NUL; + Name_Len := Flength + 4; + + -- Ada bind file, name is b~xxx.adb or b~xxx.ads + -- (with $ instead of ~ in VMS) + + else + if Hostparm.OpenVMS then + Name_Buffer (2) := '$'; + else + Name_Buffer (2) := '~'; + end if; + + Name_Buffer (Flength + 4) := 'a'; + Name_Buffer (Flength + 5) := 'd'; + Name_Buffer (Flength + 6) := Typ; + Name_Buffer (Flength + 7) := ASCII.NUL; + Name_Len := Flength + 6; + end if; + end if; + + Bfile := Name_Find; + + if Recording_Time_From_Last_Bind then + Old_Binder_Output_Time_Stamp := File_Stamp (Bfile); + end if; + + Create_File_And_Check (Output_FD, Text); + end Create_Binder_Output; + + -------------------- + -- More_Lib_Files -- + -------------------- + + function More_Lib_Files return Boolean renames More_Files; + + ------------------------ + -- Next_Main_Lib_File -- + ------------------------ + + function Next_Main_Lib_File return File_Name_Type renames Next_Main_File; + + -------------------------------- + -- Record_Time_From_Last_Bind -- + -------------------------------- + + procedure Record_Time_From_Last_Bind is + begin + Recording_Time_From_Last_Bind := True; + end Record_Time_From_Last_Bind; + + ------------------------- + -- Time_From_Last_Bind -- + ------------------------- + + function Time_From_Last_Bind return Nat is + Old_Y : Nat; + Old_M : Nat; + Old_D : Nat; + Old_H : Nat; + Old_Mi : Nat; + Old_S : Nat; + New_Y : Nat; + New_M : Nat; + New_D : Nat; + New_H : Nat; + New_Mi : Nat; + New_S : Nat; + + type Month_Data is array (Int range 1 .. 12) of Int; + Cumul : constant Month_Data := (0, 0, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7); + -- Represents the difference in days from a period compared to the + -- same period if all months had 31 days, i.e: + -- + -- Cumul (m) = 31x(m-1) - (number of days from 01/01 to m/01) + + Res : Int; + + begin + if not Recording_Time_From_Last_Bind + or else not Binder_Output_Time_Stamps_Set + or else Old_Binder_Output_Time_Stamp = Empty_Time_Stamp + then + return Nat'Last; + end if; + + Split_Time_Stamp + (Old_Binder_Output_Time_Stamp, + Old_Y, Old_M, Old_D, Old_H, Old_Mi, Old_S); + + Split_Time_Stamp + (New_Binder_Output_Time_Stamp, + New_Y, New_M, New_D, New_H, New_Mi, New_S); + + Res := New_Mi - Old_Mi; + + -- 60 minutes in an hour + + Res := Res + 60 * (New_H - Old_H); + + -- 24 hours in a day + + Res := Res + 60 * 24 * (New_D - Old_D); + + -- Almost 31 days in a month + + Res := Res + 60 * 24 * + (31 * (New_M - Old_M) - Cumul (New_M) + Cumul (Old_M)); + + -- 365 days in a year + + Res := Res + 60 * 24 * 365 * (New_Y - Old_Y); + + return Res; + end Time_From_Last_Bind; + + ----------------------- + -- Write_Binder_Info -- + ----------------------- + + procedure Write_Binder_Info (Info : String) renames Write_Info; + + begin + Set_Program (Binder); + end Osint.B; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint-b.ads gcc-3.3/gcc/ada/osint-b.ads *** gcc-3.2.3/gcc/ada/osint-b.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/osint-b.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,101 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- O S I N T - B -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package contains the low level, operating system routines used only + -- in the GNAT binder for command line processing and file input output. + + package Osint.B is + + procedure Record_Time_From_Last_Bind; + -- Trigger the computing of the time from the last bind of the same + -- program. + + function More_Lib_Files return Boolean; + -- Indicates whether more library information files remain to be processed. + -- Returns False right away if no source files, or if all source files + -- have been processed. + + function Next_Main_Lib_File return File_Name_Type; + -- This function returns the name of the next library info file specified + -- on the command line. It is an error to call Next_Main_Lib_File if no + -- more library information files exist (i.e. Next_Main_Lib_File may be + -- called only if a previous call to More_Lib_Files returned True). This + -- name is the simple name, excluding any directory information. + + function Time_From_Last_Bind return Nat; + -- This function give an approximate number of minute from the last bind. + -- It bases its computation on file stamp and therefore does gibe not + -- any meaningful result before the new output binder file is written. + -- So it returns Nat'last if: + -- + -- - it is the first bind of this specific program + -- - Record_Time_From_Last_Bind was not Called first + -- - Close_Binder_Output was not called first + -- + -- otherwise it returns the number of minutes from the last bind. The + -- computation does not try to be completely accurate and in particular + -- does not take leap years into account. + + ------------------- + -- Binder Output -- + ------------------- + + -- These routines are used by the binder to generate the C source file + -- containing the binder output. The format of this file is described + -- in the package Bindfmt. + + procedure Create_Binder_Output + (Output_File_Name : String; + Typ : Character; + Bfile : out Name_Id); + -- Creates the binder output file. Typ is one of + -- + -- 'c' create output file for case of generating C + -- 'b' create body file for case of generating Ada + -- 's' create spec file for case of generating Ada + -- + -- If Output_File_Name is null, then a default name is used based on + -- the name of the most recently accessed main source file name. If + -- Output_File_Name is non-null then it is the full path name of the + -- file to be output (in the case of Ada, it must have an extension + -- of adb, and the spec file is created by changing the last character + -- from b to s. On return, Bfile also contains the Name_Id for the + -- generated file name. + + procedure Write_Binder_Info (Info : String); + -- Writes the contents of the referenced string to the binder output file + -- created by a previous call to Create_Binder_Output. Info represents a + -- single line in the file, but does not contain any line termination + -- characters. The implementation of Write_Binder_Info is responsible + -- for adding necessary end of line and end of file control characters + -- as required by the operating system. + + procedure Close_Binder_Output; + -- Closes the file created by Create_Binder_Output, flushing any + -- buffers etc from writes by Write_Binder_Info. + + end Osint.B; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint-c.adb gcc-3.3/gcc/ada/osint-c.adb *** gcc-3.2.3/gcc/ada/osint-c.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/osint-c.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,379 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- O S I N T - C -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with Hostparm; + with Namet; use Namet; + with Opt; use Opt; + with Tree_IO; use Tree_IO; + + package body Osint.C is + + Output_Object_File_Name : String_Ptr; + -- Argument of -o compiler option, if given. This is needed to + -- verify consistency with the ALI file name. + + procedure Adjust_OS_Resource_Limits; + pragma Import (C, Adjust_OS_Resource_Limits, + "__gnat_adjust_os_resource_limits"); + -- Procedure to make system specific adjustments to make GNAT + -- run better. + + function Create_Auxiliary_File + (Src : File_Name_Type; + Suffix : String) + return File_Name_Type; + -- Common processing for Creat_Repinfo_File and Create_Debug_File. + -- Src is the file name used to create the required output file and + -- Suffix is the desired suffic (dg/rep for debug/repinfo file). + + procedure Set_Library_Info_Name; + -- Sets a default ali file name from the main compiler source name. + -- This is used by Create_Output_Library_Info, and by the version of + -- Read_Library_Info that takes a default file name. + + ---------------------- + -- Close_Debug_File -- + ---------------------- + + procedure Close_Debug_File is + begin + Close (Output_FD); + end Close_Debug_File; + + ------------------------------- + -- Close_Output_Library_Info -- + ------------------------------- + + procedure Close_Output_Library_Info is + begin + Close (Output_FD); + end Close_Output_Library_Info; + + ------------------------ + -- Close_Repinfo_File -- + ------------------------ + + procedure Close_Repinfo_File is + begin + Close (Output_FD); + end Close_Repinfo_File; + + --------------------------- + -- Create_Auxiliary_File -- + --------------------------- + + function Create_Auxiliary_File + (Src : File_Name_Type; + Suffix : String) + return File_Name_Type + is + Result : File_Name_Type; + + begin + Get_Name_String (Src); + + if Hostparm.OpenVMS then + Name_Buffer (Name_Len + 1) := '_'; + else + Name_Buffer (Name_Len + 1) := '.'; + end if; + + Name_Len := Name_Len + 1; + Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix; + Name_Len := Name_Len + Suffix'Length; + + if Output_Object_File_Name /= null then + + for Index in reverse Output_Object_File_Name'Range loop + + if Output_Object_File_Name (Index) = Directory_Separator then + declare + File_Name : constant String := Name_Buffer (1 .. Name_Len); + + begin + Name_Len := Index - Output_Object_File_Name'First + 1; + Name_Buffer (1 .. Name_Len) := + Output_Object_File_Name + (Output_Object_File_Name'First .. Index); + Name_Buffer (Name_Len + 1 .. Name_Len + File_Name'Length) := + File_Name; + Name_Len := Name_Len + File_Name'Length; + end; + + exit; + end if; + end loop; + end if; + + Result := Name_Find; + Name_Buffer (Name_Len + 1) := ASCII.NUL; + Create_File_And_Check (Output_FD, Text); + return Result; + end Create_Auxiliary_File; + + ----------------------- + -- Create_Debug_File -- + ----------------------- + + function Create_Debug_File (Src : File_Name_Type) return File_Name_Type is + begin + return Create_Auxiliary_File (Src, "dg"); + end Create_Debug_File; + + -------------------------------- + -- Create_Output_Library_Info -- + -------------------------------- + + procedure Create_Output_Library_Info is + begin + Set_Library_Info_Name; + Create_File_And_Check (Output_FD, Text); + end Create_Output_Library_Info; + + -------------------------- + -- Creat_Repinfo_File -- + -------------------------- + + procedure Creat_Repinfo_File (Src : File_Name_Type) is + S : constant File_Name_Type := Create_Auxiliary_File (Src, "rep"); + pragma Warnings (Off, S); + + begin + return; + end Creat_Repinfo_File; + + --------------------------- + -- Debug_File_Eol_Length -- + --------------------------- + + function Debug_File_Eol_Length return Nat is + begin + -- There has to be a cleaner way to do this! ??? + + if Directory_Separator = '/' then + return 1; + else + return 2; + end if; + end Debug_File_Eol_Length; + + ----------------------- + -- More_Source_Files -- + ----------------------- + + function More_Source_Files return Boolean renames More_Files; + + ---------------------- + -- Next_Main_Source -- + ---------------------- + + function Next_Main_Source return File_Name_Type renames Next_Main_File; + + ----------------------- + -- Read_Library_Info -- + ----------------------- + + -- Version with default file name + + procedure Read_Library_Info + (Name : out File_Name_Type; + Text : out Text_Buffer_Ptr) + is + begin + Set_Library_Info_Name; + Name := Name_Find; + Text := Read_Library_Info (Name, Fatal_Err => False); + end Read_Library_Info; + + --------------------------- + -- Set_Library_Info_Name -- + --------------------------- + + procedure Set_Library_Info_Name is + Dot_Index : Natural; + + begin + Get_Name_String (Current_Main); + + -- Find last dot since we replace the existing extension by .ali. The + -- initialization to Name_Len + 1 provides for simply adding the .ali + -- extension if the source file name has no extension. + + Dot_Index := Name_Len + 1; + + for J in reverse 1 .. Name_Len loop + if Name_Buffer (J) = '.' then + Dot_Index := J; + exit; + end if; + end loop; + + -- Make sure that the output file name matches the source file name. + -- To compare them, remove file name directories and extensions. + + if Output_Object_File_Name /= null then + -- Make sure there is a dot at Dot_Index. This may not be the case + -- if the source file name has no extension. + + Name_Buffer (Dot_Index) := '.'; + + declare + Name : constant String := Name_Buffer (1 .. Dot_Index); + Len : constant Natural := Dot_Index; + + begin + Name_Buffer (1 .. Output_Object_File_Name'Length) + := Output_Object_File_Name.all; + Dot_Index := 0; + + for J in reverse Output_Object_File_Name'Range loop + if Name_Buffer (J) = '.' then + Dot_Index := J; + exit; + end if; + end loop; + + pragma Assert (Dot_Index /= 0); + -- We check for the extension elsewhere + + if Name /= Name_Buffer (Dot_Index - Len + 1 .. Dot_Index) then + Fail ("incorrect object file name"); + end if; + end; + end if; + + Name_Buffer (Dot_Index) := '.'; + Name_Buffer (Dot_Index + 1 .. Dot_Index + 3) := ALI_Suffix.all; + Name_Buffer (Dot_Index + 4) := ASCII.NUL; + Name_Len := Dot_Index + 3; + end Set_Library_Info_Name; + + --------------------------------- + -- Set_Output_Object_File_Name -- + --------------------------------- + + procedure Set_Output_Object_File_Name (Name : String) is + Ext : constant String := Object_Suffix; + NL : constant Natural := Name'Length; + EL : constant Natural := Ext'Length; + + begin + -- Make sure that the object file has the expected extension. + + if NL <= EL + or else + (Name (NL - EL + Name'First .. Name'Last) /= Ext + and then Name (NL - 2 + Name'First .. Name'Last) /= ".o") + then + Fail ("incorrect object file extension"); + end if; + + Output_Object_File_Name := new String'(Name); + end Set_Output_Object_File_Name; + + ---------------- + -- Tree_Close -- + ---------------- + + procedure Tree_Close is + begin + Tree_Write_Terminate; + Close (Output_FD); + end Tree_Close; + + ----------------- + -- Tree_Create -- + ----------------- + + procedure Tree_Create is + Dot_Index : Natural; + + begin + Get_Name_String (Current_Main); + + -- If an object file has been specified, then the ALI file + -- will be in the same directory as the object file; + -- so, we put the tree file in this same directory, + -- even though no object file needs to be generated. + + if Output_Object_File_Name /= null then + Name_Len := Output_Object_File_Name'Length; + Name_Buffer (1 .. Name_Len) := Output_Object_File_Name.all; + end if; + + Dot_Index := 0; + for J in reverse 1 .. Name_Len loop + if Name_Buffer (J) = '.' then + Dot_Index := J; + exit; + end if; + end loop; + + -- Should be impossible to not have an extension + + pragma Assert (Dot_Index /= 0); + + -- Change exctension to adt + + Name_Buffer (Dot_Index + 1) := 'a'; + Name_Buffer (Dot_Index + 2) := 'd'; + Name_Buffer (Dot_Index + 3) := 't'; + Name_Buffer (Dot_Index + 4) := ASCII.NUL; + Name_Len := Dot_Index + 3; + Create_File_And_Check (Output_FD, Binary); + + Tree_Write_Initialize (Output_FD); + end Tree_Create; + + ----------------------- + -- Write_Debug_Info -- + ----------------------- + + procedure Write_Debug_Info (Info : String) renames Write_Info; + + ------------------------ + -- Write_Library_Info -- + ------------------------ + + procedure Write_Library_Info (Info : String) renames Write_Info; + + ------------------------ + -- Write_Repinfo_Line -- + ------------------------ + + procedure Write_Repinfo_Line (Info : String) renames Write_Info; + + begin + + Adjust_OS_Resource_Limits; + Opt.Creat_Repinfo_File_Access := Creat_Repinfo_File'Access; + Opt.Write_Repinfo_Line_Access := Write_Repinfo_Line'Access; + Opt.Close_Repinfo_File_Access := Close_Repinfo_File'Access; + + Set_Program (Compiler); + + end Osint.C; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint-c.ads gcc-3.3/gcc/ada/osint-c.ads *** gcc-3.2.3/gcc/ada/osint-c.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/osint-c.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,155 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- O S I N T - C -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package contains the low level, operating system routines used only + -- in the GNAT compiler for command line processing and file input output. + + package Osint.C is + + procedure Set_Output_Object_File_Name (Name : String); + -- Called by the subprogram processing the command line when an + -- output object file name is found. + + function More_Source_Files return Boolean; + -- Indicates whether more source file remain to be processed. Returns + -- False right away if no source files, or if all source files have + -- been processed. + + function Next_Main_Source return File_Name_Type; + -- This function returns the name of the next main source file specified + -- on the command line. It is an error to call Next_Main_Source if no more + -- source files exist (i.e. Next_Main_Source may be called only if a + -- previous call to More_Source_Files returned True). This name is the + -- simple file name (without any directory information). + + ------------------------------ + -- Debug Source File Output -- + ------------------------------ + + -- These routines are used by the compiler to generate the debug source + -- file for the Debug_Generated_Code (-gnatD switch) option. Note that + -- debug source file writing occurs at a completely different point in + -- the processing from library information output, or representation + -- output, so the code in the body can assume that no two of these + -- functions are ever used at the same time. + + function Create_Debug_File (Src : File_Name_Type) return File_Name_Type; + -- Given the simple name of a source file, this routine creates the + -- corresponding debug file, and returns its full name. + + procedure Write_Debug_Info (Info : String); + -- Writes contents of given string as next line of the current debug + -- source file created by the most recent call to Create_Debug_File. + -- Info does not contain end of line or other formatting characters. + + procedure Close_Debug_File; + -- Close current debug file created by the most recent call to + -- Create_Debug_File. + + function Debug_File_Eol_Length return Nat; + -- Returns the number of characters (1 for NL, 2 for CR/LF) written + -- at the end of each line by Write_Debug_Info. + + -------------------------------- + -- Representation File Output -- + -------------------------------- + + -- These routines are used by the compiler to generate the representation + -- information to a file if this option is specified (-gnatR?s switch). + -- Note that the writing of this file occurs at a completely different + -- point in the processing from library information output, or from + -- debug file output, so the code in the body can assume that no two + -- of these functions are ever used at the same time. + + -- Note: these routines are called from Repinfo, but are not called + -- directly, since we do not want Repinfo to depend on Osint. That + -- would cause a lot of unwanted junk to be dragged into ASIS. So + -- what we do is we have Initialize set the addresses of these three + -- procedures in appropriate variables in Repinfo, so that they can + -- be called indirectly without creating a dependence. + + procedure Creat_Repinfo_File (Src : File_Name_Type); + -- Given the simple name of a source file, this routine creates the + -- corresponding file to hold representation information + + procedure Write_Repinfo_Line (Info : String); + -- Writes contents of given string as next line of the current debug + -- source file created by the most recent call to Create_Repinfo_File. + -- Info does not contain end of line or other formatting characters. + + procedure Close_Repinfo_File; + -- Close current debug file created by the most recent call to + -- Create_Repinfo_File. + + -------------------------------- + -- Library Information Output -- + -------------------------------- + + -- These routines are used by the compiler to generate the library + -- information file for the main source file being compiled. See section + -- above for a discussion of how library information files are stored. + + procedure Create_Output_Library_Info; + -- Creates the output library information file for the source file which + -- is currently being compiled (i.e. the file which was most recently + -- returned by Next_Main_Source). + + procedure Write_Library_Info (Info : String); + -- Writes the contents of the referenced string to the library information + -- file for the main source file currently being compiled (i.e. the file + -- which was most recently opened with a call to Read_Next_File). Info + -- represents a single line in the file, but does not contain any line + -- termination characters. The implementation of Write_Library_Info is + -- responsible for adding necessary end of line and end of file control + -- characters to the generated file. + + procedure Close_Output_Library_Info; + -- Closes the file created by Create_Output_Library_Info, flushing any + -- buffers etc from writes by Write_Library_Info. + + procedure Read_Library_Info + (Name : out File_Name_Type; + Text : out Text_Buffer_Ptr); + -- The procedure version of Read_Library_Info is used from the compiler + -- to read an existing ali file associated with the main unit. If the + -- ALI file exists, then its file name is returned in Name, and its + -- text is returned in Text. If the file does not exist, then Text is + -- set to null. + + -------------------------------- + -- Semantic Tree Input-Output -- + -------------------------------- + + procedure Tree_Create; + -- Creates the tree output file for the source file which is currently + -- being compiled (i.e. the file which was most recently returned by + -- Next_Main_Source), and initializes Tree_IO.Tree_Write for output. + + procedure Tree_Close; + -- Closes the file previously opened by Tree_Create + + end Osint.C; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint-l.adb gcc-3.3/gcc/ada/osint-l.adb *** gcc-3.2.3/gcc/ada/osint-l.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/osint-l.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,44 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- O S I N T - L -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + package body Osint.L is + + -------------------- + -- More_Lib_Files -- + -------------------- + + function More_Lib_Files return Boolean renames More_Files; + + ------------------------ + -- Next_Main_Lib_File -- + ------------------------ + + function Next_Main_Lib_File return File_Name_Type renames Next_Main_File; + + begin + Set_Program (Gnatls); + end Osint.L; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint-l.ads gcc-3.3/gcc/ada/osint-l.ads *** gcc-3.2.3/gcc/ada/osint-l.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/osint-l.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,45 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- O S I N T - L -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package contains the low level, operating system routines used only + -- in gnatls for command line processing and file input output. + + package Osint.L is + + function More_Lib_Files return Boolean; + -- Indicates whether more library information files remain to be processed. + -- Returns False right away if no source files, or if all source files + -- have been processed. + + function Next_Main_Lib_File return File_Name_Type; + -- This function returns the name of the next library info file specified + -- on the command line. It is an error to call Next_Main_Lib_File if no + -- more library information files exist (i.e. Next_Main_Lib_File may be + -- called only if a previous call to More_Lib_Files returned True). This + -- name is the simple name, excluding any directory information. + + end Osint.L; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint-m.adb gcc-3.3/gcc/ada/osint-m.adb *** gcc-3.2.3/gcc/ada/osint-m.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/osint-m.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,51 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- O S I N T - M -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + package body Osint.M is + + ----------------------- + -- More_Source_Files -- + ----------------------- + + function More_Source_Files return Boolean renames More_Files; + + ---------------------- + -- Next_Main_Source -- + ---------------------- + + function Next_Main_Source return File_Name_Type renames Next_Main_File; + + ---------------------- + -- Object_File_Name -- + ---------------------- + + function Object_File_Name (N : File_Name_Type) return File_Name_Type + renames Osint.Object_File_Name; + + begin + Set_Program (Make); + end Osint.M; diff -Nrc3pad gcc-3.2.3/gcc/ada/osint-m.ads gcc-3.3/gcc/ada/osint-m.ads *** gcc-3.2.3/gcc/ada/osint-m.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/osint-m.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,52 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- O S I N T - M -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package contains the low level, operating system routines used only + -- in gnatmake for command line processing and file input output. + + package Osint.M is + + function More_Source_Files return Boolean; + -- Indicates whether more source file remain to be processed. Returns + -- False right away if no source files, or if all source files have + -- been processed. + + function Next_Main_Source return File_Name_Type; + -- This function returns the name of the next main source file specified + -- on the command line. It is an error to call Next_Main_Source if no more + -- source files exist (i.e. Next_Main_Source may be called only if a + -- previous call to More_Source_Files returned True). This name is the + -- simple file name (without any directory information). + + 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. + + end Osint.M; diff -Nrc3pad gcc-3.2.3/gcc/ada/output.adb gcc-3.3/gcc/ada/output.adb *** gcc-3.2.3/gcc/ada/output.adb 2002-05-04 03:28:23.000000000 +0000 --- gcc-3.3/gcc/ada/output.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Output is *** 40,45 **** --- 39,71 ---- Current_FD : File_Descriptor := Standout; -- File descriptor for current output + Special_Output_Proc : Output_Proc := null; + -- Record argument to last call to Set_Special_Output. If this is + -- non-null, then we are in special output mode. + + ------------------------- + -- Line Buffer Control -- + ------------------------- + + -- Note: the following buffer and column position are maintained by + -- the subprograms defined in this package, and are not normally + -- directly modified or accessed by a client. However, a client is + -- permitted to modify these values, using the knowledge that only + -- Write_Eol actually generates any output. + + Buffer_Max : constant := 8192; + Buffer : String (1 .. Buffer_Max + 1); + -- Buffer used to build output line. We do line buffering because it + -- is needed for the support of the debug-generated-code option (-gnatD). + -- Historically it was first added because on VMS, line buffering is + -- needed with certain file formats. So in any case line buffering must + -- be retained for this purpose, even if other reasons disappear. Note + -- any attempt to write more output to a line than can fit in the buffer + -- will be silently ignored. + + Next_Column : Pos range 1 .. Buffer'Length + 1 := 1; + -- Column about to be written. + ----------------------- -- Local_Subprograms -- ----------------------- *************** package body Output is *** 47,80 **** procedure Flush_Buffer; -- Flush buffer if non-empty and reset column counter ------------------ -- Flush_Buffer -- ------------------ procedure Flush_Buffer is ! Len : constant Natural := Natural (Column - 1); begin if Len /= 0 then ! if Len /= Write (Current_FD, Buffer'Address, Len) then ! Set_Standard_Error; ! Write_Line ("fatal error: disk full"); ! OS_Exit (2); end if; ! Column := 1; end if; end Flush_Buffer; ------------------------ -- Set_Standard_Error -- ------------------------ procedure Set_Standard_Error is begin ! Flush_Buffer; Current_FD := Standerr; - Column := 1; end Set_Standard_Error; ------------------------- --- 73,159 ---- procedure Flush_Buffer; -- Flush buffer if non-empty and reset column counter + --------------------------- + -- Cancel_Special_Output -- + --------------------------- + + procedure Cancel_Special_Output is + begin + Special_Output_Proc := null; + end Cancel_Special_Output; + ------------------ -- Flush_Buffer -- ------------------ procedure Flush_Buffer is ! Len : constant Natural := Natural (Next_Column - 1); begin if Len /= 0 then ! ! -- If Special_Output_Proc has been set, then use it ! ! if Special_Output_Proc /= null then ! Special_Output_Proc.all (Buffer (1 .. Len)); ! ! -- If output is not set, then output to either standard output ! -- or standard error. ! ! elsif Len /= Write (Current_FD, Buffer'Address, Len) then ! ! -- If there are errors with standard error, just quit ! ! if Current_FD = Standerr then ! OS_Exit (2); ! ! -- Otherwise, set the output to standard error before ! -- reporting a failure and quitting. ! ! else ! Current_FD := Standerr; ! Next_Column := 1; ! Write_Line ("fatal error: disk full"); ! OS_Exit (2); ! end if; end if; ! -- Buffer is now empty ! ! Next_Column := 1; end if; end Flush_Buffer; + ------------ + -- Column -- + ------------ + + function Column return Nat is + begin + return Next_Column; + end Column; + + ------------------------ + -- Set_Special_Output -- + ------------------------ + + procedure Set_Special_Output (P : Output_Proc) is + begin + Special_Output_Proc := P; + end Set_Special_Output; + ------------------------ -- Set_Standard_Error -- ------------------------ procedure Set_Standard_Error is begin ! if Special_Output_Proc = null then ! Flush_Buffer; ! Next_Column := 1; ! end if; ! Current_FD := Standerr; end Set_Standard_Error; ------------------------- *************** package body Output is *** 83,91 **** procedure Set_Standard_Output is begin ! Flush_Buffer; Current_FD := Standout; - Column := 1; end Set_Standard_Output; ------- --- 162,173 ---- procedure Set_Standard_Output is begin ! if Special_Output_Proc = null then ! Flush_Buffer; ! Next_Column := 1; ! end if; ! Current_FD := Standout; end Set_Standard_Output; ------- *************** package body Output is *** 155,163 **** procedure Write_Char (C : Character) is begin ! if Column < Buffer'Length then ! Buffer (Natural (Column)) := C; ! Column := Column + 1; end if; end Write_Char; --- 237,245 ---- procedure Write_Char (C : Character) is begin ! if Next_Column < Buffer'Length then ! Buffer (Natural (Next_Column)) := C; ! Next_Column := Next_Column + 1; end if; end Write_Char; *************** package body Output is *** 167,174 **** procedure Write_Eol is begin ! Buffer (Natural (Column)) := ASCII.LF; ! Column := Column + 1; Flush_Buffer; end Write_Eol; --- 249,256 ---- procedure Write_Eol is begin ! Buffer (Natural (Next_Column)) := ASCII.LF; ! Next_Column := Next_Column + 1; Flush_Buffer; end Write_Eol; diff -Nrc3pad gcc-3.2.3/gcc/ada/output.ads gcc-3.3/gcc/ada/output.ads *** gcc-3.2.3/gcc/ada/output.ads 2002-05-04 03:28:23.000000000 +0000 --- gcc-3.3/gcc/ada/output.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Types; use Types; *** 42,82 **** package Output is pragma Elaborate_Body (Output); ! ------------------------- ! -- Line Buffer Control -- ! ------------------------- ! ! -- Note: the following buffer and column position are maintained by ! -- the subprograms defined in this package, and are not normally ! -- directly modified or accessed by a client. However, a client is ! -- permitted to modify these values, using the knowledge that only ! -- Write_Eol actually generates any output. ! ! Buffer_Max : constant := 8192; ! Buffer : String (1 .. Buffer_Max + 1); ! -- Buffer used to build output line. We do line buffering because it ! -- is needed for the support of the debug-generated-code option (-gnatD). ! -- Historically it was first added because on VMS, line buffering is ! -- needed with certain file formats. So in any case line buffering must ! -- be retained for this purpose, even if other reasons disappear. Note ! -- any attempt to write more output to a line than can fit in the buffer ! -- will be silently ignored. ! ! Column : Pos range 1 .. Buffer'Length + 1 := 1; ! -- Column about to be written. ----------------- -- Subprograms -- ----------------- procedure Set_Standard_Error; -- Sets subsequent output to appear on the standard error file (whatever ! -- that might mean for the host operating system, if anything). procedure Set_Standard_Output; -- Sets subsequent output to appear on the standard output file (whatever ! -- that might mean for the host operating system, if anything). This is ! -- the default mode before any call to either of the Set procedures. procedure Write_Char (C : Character); -- Write one character to the standard output file. Note that the --- 41,87 ---- package Output is pragma Elaborate_Body (Output); ! type Output_Proc is access procedure (S : String); ! -- This type is used for the Set_Special_Output procedure. If this ! -- procedure is called, then instead of lines being written to ! -- standard error or standard output, a call is made to the given ! -- procedure for each line, passing the line with an end of line ! -- character (which is a single ASCII.LF character, even in systems ! -- which normally use CR/LF or some other sequence for line end). ----------------- -- Subprograms -- ----------------- + procedure Set_Special_Output (P : Output_Proc); + -- Sets subsequent output to call procedure P. If P is null, then + -- the call cancels the effect of a previous call, reverting the + -- output to standard error or standard output depending on the + -- mode at the time of previous call. Any exception generated by + -- by calls to P is simply propagated to the caller of the routine + -- causing the write operation. + + procedure Cancel_Special_Output; + -- Cancels the effect of a call to Set_Special_Output, if any. + -- The output is then directed to standard error or standard output + -- depending on the last call to Set_Standard_Error or Set_Standard_Output. + -- It is never an error to call Cancel_Special_Output. It has the same + -- effect as calling Set_Special_Output (null). + procedure Set_Standard_Error; -- Sets subsequent output to appear on the standard error file (whatever ! -- that might mean for the host operating system, if anything) when ! -- no special output is in effect. When a special output is in effect, ! -- the output will appear on standard error only after special output ! -- has been cancelled. procedure Set_Standard_Output; -- Sets subsequent output to appear on the standard output file (whatever ! -- that might mean for the host operating system, if anything) when ! -- no special output is in effect. When a special output is in effect, ! -- the output will appear on standard output only after special output ! -- has been cancelled. Output to standard output is the default mode ! -- before any call to either of the Set procedures. procedure Write_Char (C : Character); -- Write one character to the standard output file. Note that the *************** pragma Elaborate_Body (Output); *** 102,107 **** --- 107,117 ---- procedure Write_Line (S : String); -- Equivalent to Write_Str (S) followed by Write_Eol; + function Column return Nat; + pragma Inline (Column); + -- Returns the number of the column about to be written (e.g. a value + -- of 1 means the current line is empty). + -------------------------- -- Debugging Procedures -- -------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/par.adb gcc-3.3/gcc/ada/par.adb *** gcc-3.2.3/gcc/ada/par.adb 2002-05-04 03:28:28.000000000 +0000 --- gcc-3.3/gcc/ada/par.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** function Par (Configuration_Pragmas : Bo *** 974,980 **** -- of implementation defined pragmas. The second parameter records the -- location of the semicolon following the pragma (this is needed for -- correct processing of the List and Page pragmas). The returned value ! -- is a copy of Pragma_Node, or Error if an error is found. ------------------------- -- Subsidiary Routines -- --- 973,984 ---- -- of implementation defined pragmas. The second parameter records the -- location of the semicolon following the pragma (this is needed for -- correct processing of the List and Page pragmas). The returned value ! -- is a copy of Pragma_Node, or Error if an error is found. Note that ! -- at the point where Prag is called, the right paren ending the pragma ! -- has been scanned out, and except in the case of pragma Style_Checks, ! -- so has the following semicolon. For Style_Checks, the caller delays ! -- the scanning of the semicolon so that it will be scanned using the ! -- settings from the Style_Checks pragma preceding it. ------------------------- -- Subsidiary Routines -- *************** begin *** 1054,1060 **** if Configuration_Pragmas then declare ! Ecount : constant Int := Errors_Detected; Pragmas : List_Id := Empty_List; P_Node : Node_Id; --- 1058,1064 ---- if Configuration_Pragmas then declare ! Ecount : constant Int := Total_Errors_Detected; Pragmas : List_Id := Empty_List; P_Node : Node_Id; *************** begin *** 1070,1076 **** else P_Node := P_Pragma; ! if Errors_Detected > Ecount then return Error_List; end if; --- 1074,1080 ---- else P_Node := P_Pragma; ! if Total_Errors_Detected > Ecount then return Error_List; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/par.ads gcc-3.3/gcc/ada/par.ads *** gcc-3.2.3/gcc/ada/par.ads 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/par.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch10.adb gcc-3.3/gcc/ada/par-ch10.adb *** gcc-3.2.3/gcc/ada/par-ch10.adb 2002-05-04 03:28:23.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch10.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch11.adb gcc-3.3/gcc/ada/par-ch11.adb *** gcc-3.2.3/gcc/ada/par-ch11.adb 2002-05-04 03:28:23.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch11.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch12.adb gcc-3.3/gcc/ada/par-ch12.adb *** gcc-3.2.3/gcc/ada/par-ch12.adb 2002-05-04 03:28:23.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch12.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch13.adb gcc-3.3/gcc/ada/par-ch13.adb *** gcc-3.2.3/gcc/ada/par-ch13.adb 2002-05-04 03:28:23.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch13.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch2.adb gcc-3.3/gcc/ada/par-ch2.adb *** gcc-3.2.3/gcc/ada/par-ch2.adb 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch2.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Ch2 is *** 223,228 **** --- 222,247 ---- Semicolon_Loc : Source_Ptr; Ident_Node : Node_Id; Assoc_Node : Node_Id; + Result : Node_Id; + + procedure Skip_Pragma_Semicolon; + -- Skip past semicolon at end of pragma + + --------------------------- + -- Skip_Pragma_Semicolon -- + --------------------------- + + procedure Skip_Pragma_Semicolon is + begin + if Token /= Tok_Semicolon then + T_Semicolon; + Resync_Past_Semicolon; + else + Scan; -- past semicolon + end if; + end Skip_Pragma_Semicolon; + + -- Start of processing for P_Pragma begin Pragma_Node := New_Node (N_Pragma, Token_Ptr); *************** package body Ch2 is *** 285,304 **** Semicolon_Loc := Token_Ptr; ! if Token /= Tok_Semicolon then ! T_Semicolon; ! Resync_Past_Semicolon; ! else ! Scan; -- past semicolon ! end if; ! if Is_Pragma_Name (Chars (Pragma_Node)) then ! return Par.Prag (Pragma_Node, Semicolon_Loc); else ! -- Unrecognized pragma, warning generated in Sem_Prag ! ! return Pragma_Node; end if; exception --- 304,329 ---- Semicolon_Loc := Token_Ptr; ! -- Now we have two tasks left, we need to scan out the semicolon ! -- following the pragma, and we have to call Par.Prag to process ! -- the pragma. Normally we do them in this order, however, there ! -- is one exception namely pragma Style_Checks where we like to ! -- skip the semicolon after processing the pragma, since that way ! -- the style checks for the scanning of the semicolon follow the ! -- settings of the pragma. ! -- You might think we could just unconditionally do things in ! -- the opposite order, but there are other pragmas, notably the ! -- case of pragma Source_File_Name, which assume the semicolon ! -- is already scanned out. + if Chars (Pragma_Node) = Name_Style_Checks then + Result := Par.Prag (Pragma_Node, Semicolon_Loc); + Skip_Pragma_Semicolon; + return Result; else ! Skip_Pragma_Semicolon; ! return Par.Prag (Pragma_Node, Semicolon_Loc); end if; exception diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch3.adb gcc-3.3/gcc/ada/par-ch3.adb *** gcc-3.2.3/gcc/ada/par-ch3.adb 2002-05-04 03:28:24.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch3.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Ch3 is *** 415,420 **** --- 414,426 ---- when Tok_Left_Paren => Typedef_Node := P_Enumeration_Type_Definition; + + End_Labl := + Make_Identifier (Token_Ptr, + Chars => Chars (Ident_Node)); + Set_Comes_From_Source (End_Labl, False); + + Set_End_Label (Typedef_Node, End_Labl); TF_Semicolon; exit; *************** package body Ch3 is *** 473,478 **** --- 479,491 ---- Typedef_Node := P_Record_Definition; Set_Tagged_Present (Typedef_Node, True); Set_Limited_Present (Typedef_Node, True); + + End_Labl := + Make_Identifier (Token_Ptr, + Chars => Chars (Ident_Node)); + Set_Comes_From_Source (End_Labl, False); + + Set_End_Label (Typedef_Node, End_Labl); end if; else *************** package body Ch3 is *** 489,494 **** --- 502,514 ---- else Typedef_Node := P_Record_Definition; Set_Tagged_Present (Typedef_Node, True); + + End_Labl := + Make_Identifier (Token_Ptr, + Chars => Chars (Ident_Node)); + Set_Comes_From_Source (End_Labl, False); + + Set_End_Label (Typedef_Node, End_Labl); end if; end if; *************** package body Ch3 is *** 2976,2982 **** end if; if Token = Tok_Comma then ! Error_Msg_SC (""","" should be ""|"""); else exit when Token /= Tok_Vertical_Bar; end if; --- 2996,3002 ---- end if; if Token = Tok_Comma then ! Error_Msg_SC (""","" should be ""'|"""); else exit when Token /= Tok_Vertical_Bar; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch4.adb gcc-3.3/gcc/ada/par-ch4.adb *** gcc-3.2.3/gcc/ada/par-ch4.adb 2002-05-04 03:28:24.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch4.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch5.adb gcc-3.3/gcc/ada/par-ch5.adb *** gcc-3.2.3/gcc/ada/par-ch5.adb 2002-05-04 03:28:25.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch5.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Ch5 is *** 595,601 **** Scan; -- past semicolon Statement_Required := False; ! -- Else we have a missing semicolon else TF_Semicolon; --- 594,613 ---- Scan; -- past semicolon Statement_Required := False; ! -- A slash following an identifier or a selected ! -- component in this situation is most likely a ! -- period (have a look at the keyboard :-) ! ! elsif Token = Tok_Slash ! and then (Nkind (Name_Node) = N_Identifier ! or else ! Nkind (Name_Node) = N_Selected_Component) ! then ! Error_Msg_SC ("""/"" should be ""."""); ! Statement_Required := False; ! raise Error_Resync; ! ! -- Else we have a missing semicolon else TF_Semicolon; diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch6.adb gcc-3.3/gcc/ada/par-ch6.adb *** gcc-3.2.3/gcc/ada/par-ch6.adb 2002-05-04 03:28:26.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch6.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch7.adb gcc-3.3/gcc/ada/par-ch7.adb *** gcc-3.2.3/gcc/ada/par-ch7.adb 2002-05-04 03:28:26.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch7.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch8.adb gcc-3.3/gcc/ada/par-ch8.adb *** gcc-3.2.3/gcc/ada/par-ch8.adb 2002-05-04 03:28:26.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch8.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-ch9.adb gcc-3.3/gcc/ada/par-ch9.adb *** gcc-3.2.3/gcc/ada/par-ch9.adb 2002-05-04 03:28:27.000000000 +0000 --- gcc-3.3/gcc/ada/par-ch9.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-endh.adb gcc-3.3/gcc/ada/par-endh.adb *** gcc-3.2.3/gcc/ada/par-endh.adb 2002-05-04 03:28:27.000000000 +0000 --- gcc-3.3/gcc/ada/par-endh.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-labl.adb gcc-3.3/gcc/ada/par-labl.adb *** gcc-3.2.3/gcc/ada/par-labl.adb 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/par-labl.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-load.adb gcc-3.3/gcc/ada/par-load.adb *** gcc-3.2.3/gcc/ada/par-load.adb 2002-05-04 03:28:28.000000000 +0000 --- gcc-3.3/gcc/ada/par-load.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-prag.adb gcc-3.3/gcc/ada/par-prag.adb *** gcc-3.2.3/gcc/ada/par-prag.adb 2002-05-04 03:28:28.000000000 +0000 --- gcc-3.3/gcc/ada/par-prag.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** function Prag (Pragma_Node : Node_Id; Se *** 54,60 **** function Arg1 return Node_Id; function Arg2 return Node_Id; function Arg3 return Node_Id; - function Arg4 return Node_Id; -- Obtain specified Pragma_Argument_Association. It is allowable to call -- the routine for the argument one past the last present argument, but -- that is the only case in which a non-present argument can be referenced. --- 53,58 ---- *************** function Prag (Pragma_Node : Node_Id; Se *** 113,127 **** return Next (Arg2); end Arg3; - ---------- - -- Arg4 -- - ---------- - - function Arg4 return Node_Id is - begin - return Next (Arg3); - end Arg4; - --------------------- -- Check_Arg_Count -- --------------------- --- 111,116 ---- *************** function Prag (Pragma_Node : Node_Id; Se *** 215,220 **** --- 204,217 ---- begin Error_Msg_Name_1 := Pragma_Name; + -- Ignore unrecognized pragma. We let Sem post the warning for this, since + -- it is a semantic error, not a syntactic one (we have already checked + -- the syntax for the unrecognized pragma as required by (RM 2.8(11)). + + if not Is_Pragma_Name (Chars (Pragma_Node)) then + return Pragma_Node; + end if; + -- Count number of arguments. This loop also checks if any of the arguments -- are Error, indicating a syntax error as they were parsed. If so, we -- simply return, because we get into trouble with cascaded errors if we *************** begin *** 527,532 **** --- 524,537 ---- and then Nkind (Selector_Name (Expr1)) = N_Identifier) then + if Nkind (Expr1) = N_Identifier + and then Chars (Expr1) = Name_System + then + Error_Msg_N + ("pragma Source_File_Name may not be used for System", Arg1); + return Error; + end if; + Check_Arg_Count (2); Check_Optional_Identifier (Arg1, Name_Unit_Name); *************** begin *** 830,835 **** --- 835,841 ---- Pragma_Atomic | Pragma_Atomic_Components | Pragma_Attach_Handler | + Pragma_Convention_Identifier | Pragma_CPP_Class | Pragma_CPP_Constructor | Pragma_CPP_Virtual | *************** begin *** 927,932 **** --- 933,940 ---- Pragma_Title | Pragma_Unchecked_Union | Pragma_Unimplemented_Unit | + Pragma_Universal_Data | + Pragma_Unreferenced | Pragma_Unreserve_All_Interrupts | Pragma_Unsuppress | Pragma_Use_VADS_Size | diff -Nrc3pad gcc-3.2.3/gcc/ada/par-sync.adb gcc-3.3/gcc/ada/par-sync.adb *** gcc-3.2.3/gcc/ada/par-sync.adb 2002-05-04 03:28:28.000000000 +0000 --- gcc-3.3/gcc/ada/par-sync.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/par-tchk.adb gcc-3.3/gcc/ada/par-tchk.adb *** gcc-3.2.3/gcc/ada/par-tchk.adb 2002-05-04 03:28:28.000000000 +0000 --- gcc-3.3/gcc/ada/par-tchk.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Tchk is *** 427,439 **** -- place to suggest the possibility of a "C" confusion :-) elsif Token = Tok_Vertical_Bar then ! Error_Msg_SC ("unexpected occurrence of ""|"", did you mean OR'?"); Resync_Past_Semicolon; -- Otherwise we really do have a missing semicolon else ! Error_Msg_AP ("missing "";"""); return; end if; --- 426,438 ---- -- place to suggest the possibility of a "C" confusion :-) elsif Token = Tok_Vertical_Bar then ! Error_Msg_SC ("unexpected occurrence of ""'|"", did you mean OR'?"); Resync_Past_Semicolon; -- Otherwise we really do have a missing semicolon else ! Error_Msg_AP ("|missing "";"""); return; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/par-util.adb gcc-3.3/gcc/ada/par-util.adb *** gcc-3.2.3/gcc/ada/par-util.adb 2002-05-04 03:28:28.000000000 +0000 --- gcc-3.3/gcc/ada/par-util.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- --- 6,11 ---- *************** package body Util is *** 360,365 **** --- 359,366 ---- ----------------------- procedure Discard_Junk_List (L : List_Id) is + pragma Warnings (Off, L); + begin null; end Discard_Junk_List; *************** package body Util is *** 369,374 **** --- 370,377 ---- ----------------------- procedure Discard_Junk_Node (N : Node_Id) is + pragma Warnings (Off, N); + begin null; end Discard_Junk_Node; diff -Nrc3pad gcc-3.2.3/gcc/ada/prj.adb gcc-3.3/gcc/ada/prj.adb *** gcc-3.2.3/gcc/ada/prj.adb 2002-05-04 03:28:33.000000000 +0000 --- gcc-3.3/gcc/ada/prj.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.10.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Ada.Characters.Handling; use Ada.Ch *** 30,35 **** --- 29,35 ---- with Errout; use Errout; with GNAT.OS_Lib; use GNAT.OS_Lib; with Namet; use Namet; + with Osint; use Osint; with Prj.Attr; with Prj.Com; with Prj.Env; *************** with Snames; use Snames; *** 41,47 **** package body Prj is ! The_Empty_String : String_Id; subtype Known_Casing is Casing_Type range All_Upper_Case .. Mixed_Case; --- 41,49 ---- package body Prj is ! The_Empty_String : String_Id; ! ! Ada_Language : constant Name_Id := Name_Ada; subtype Known_Casing is Casing_Type range All_Upper_Case .. Mixed_Case; *************** package body Prj is *** 155,161 **** begin if not Projects.Table (Project).Seen then ! Projects.Table (Project).Seen := False; Action (Project, With_State); List := Projects.Table (Project).Imported_Projects; --- 157,163 ---- begin if not Projects.Table (Project).Seen then ! Projects.Table (Project).Seen := True; Action (Project, With_State); List := Projects.Table (Project).Imported_Projects; *************** package body Prj is *** 203,208 **** --- 205,214 ---- Std_Naming_Data.Current_Spec_Suffix := Default_Ada_Spec_Suffix; Std_Naming_Data.Current_Impl_Suffix := Default_Ada_Impl_Suffix; Std_Naming_Data.Separate_Suffix := Default_Ada_Impl_Suffix; + Register_Default_Naming_Scheme + (Language => Ada_Language, + Default_Spec_Suffix => Default_Ada_Spec_Suffix, + Default_Impl_Suffix => Default_Ada_Impl_Suffix); Prj.Env.Initialize; Prj.Attr.Initialize; Set_Name_Table_Byte (Name_Project, Token_Type'Pos (Tok_Project)); *************** package body Prj is *** 211,216 **** --- 217,315 ---- end if; end Initialize; + ------------------------------------ + -- Register_Default_Naming_Scheme -- + ------------------------------------ + + procedure Register_Default_Naming_Scheme + (Language : Name_Id; + Default_Spec_Suffix : Name_Id; + Default_Impl_Suffix : Name_Id) + is + Lang : Name_Id; + Suffix : Array_Element_Id; + Found : Boolean := False; + Element : Array_Element; + + Spec_Str : String_Id; + Impl_Str : String_Id; + + begin + -- The following code is completely uncommented ??? + + Get_Name_String (Language); + Name_Buffer (1 .. Name_Len) := To_Lower (Name_Buffer (1 .. Name_Len)); + Lang := Name_Find; + + Get_Name_String (Default_Spec_Suffix); + Start_String; + Store_String_Chars (Name_Buffer (1 .. Name_Len)); + Spec_Str := End_String; + + Get_Name_String (Default_Impl_Suffix); + Start_String; + Store_String_Chars (Name_Buffer (1 .. Name_Len)); + Impl_Str := End_String; + + Suffix := Std_Naming_Data.Specification_Suffix; + Found := False; + + while Suffix /= No_Array_Element and then not Found loop + Element := Array_Elements.Table (Suffix); + + if Element.Index = Lang then + Found := True; + Element.Value.Value := Spec_Str; + Array_Elements.Table (Suffix) := Element; + + else + Suffix := Element.Next; + end if; + end loop; + + if not Found then + Element := + (Index => Lang, + Value => (Kind => Single, + Location => No_Location, + Default => False, + Value => Spec_Str), + Next => Std_Naming_Data.Specification_Suffix); + Array_Elements.Increment_Last; + Array_Elements.Table (Array_Elements.Last) := Element; + Std_Naming_Data.Specification_Suffix := Array_Elements.Last; + end if; + + Suffix := Std_Naming_Data.Implementation_Suffix; + Found := False; + + while Suffix /= No_Array_Element and then not Found loop + Element := Array_Elements.Table (Suffix); + + if Element.Index = Lang then + Found := True; + Element.Value.Value := Impl_Str; + Array_Elements.Table (Suffix) := Element; + + else + Suffix := Element.Next; + end if; + end loop; + + if not Found then + Element := + (Index => Lang, + Value => (Kind => Single, + Location => No_Location, + Default => False, + Value => Impl_Str), + Next => Std_Naming_Data.Implementation_Suffix); + Array_Elements.Increment_Last; + Array_Elements.Table (Array_Elements.Last) := Element; + Std_Naming_Data.Implementation_Suffix := Array_Elements.Last; + end if; + end Register_Default_Naming_Scheme; + ------------ -- Reset -- ------------ *************** package body Prj is *** 285,288 **** --- 384,392 ---- raise Constraint_Error; end Value; + begin + -- Make sure that the standard project file extension is compatible + -- with canonical case file naming. + + Canonical_Case_File_Name (Project_File_Extension); end Prj; diff -Nrc3pad gcc-3.2.3/gcc/ada/prj.ads gcc-3.3/gcc/ada/prj.ads *** gcc-3.2.3/gcc/ada/prj.ads 2002-05-04 03:28:33.000000000 +0000 --- gcc-3.3/gcc/ada/prj.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.7.10.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** with Types; use Types; *** 40,45 **** --- 39,49 ---- package Prj is + Project_File_Extension : String := ".gpr"; + -- The standard project file name extension. + -- It is not a constant, because Canonical_Case_File_Name is called + -- on this variable in the body of Prj. + Default_Ada_Spec_Suffix : Name_Id; -- The Name_Id for the standard GNAT suffix for Ada spec source file -- name ".ads". Initialized by Prj.Initialize. *************** package Prj is *** 48,56 **** -- The Name_Id for the standard GNAT suffix for Ada body source file -- name ".adb". Initialized by Prj.Initialize. - type Put_Line_Access is access procedure (Line : String); - -- Use to customize error reporting in Prj.Proc and Prj.Nmsc. - type Verbosity is (Default, Medium, High); -- Verbosity when parsing GNAT Project Files -- Default is default (very quiet, if no errors). --- 52,57 ---- *************** package Prj is *** 396,423 **** Include_Path : String_Access := null; -- The cached value of ADA_INCLUDE_PATH for this project file. ! -- Set by gnatmake (prj.Env.Set_Ada_Paths). -- Do not use this field directly outside of the compiler, use -- Prj.Env.Ada_Source_Path instead. Objects_Path : String_Access := null; -- The cached value of ADA_OBJECTS_PATH for this project file. ! -- Set by gnatmake (prj.Env.Set_Ada_Paths). -- Do not use this field directly outside of the compiler, use ! -- Prj.Env.Ada_Source_Path instead. Config_File_Name : Name_Id := No_Name; -- The name of the configuration pragmas file, if any. ! -- Set by gnatmage (Prj.Env.Create_Config_Pragmas_File). Config_File_Temp : Boolean := False; -- An indication that the configuration pragmas file is -- a temporary file that must be deleted at the end. ! -- Set by gnatmage (Prj.Env.Create_Config_Pragmas_File). Config_Checked : Boolean := False; -- A flag to avoid checking repetitively the configuration pragmas file. ! -- Set by gnatmage (Prj.Env.Create_Config_Pragmas_File). Language_Independent_Checked : Boolean := False; -- A flag that indicates that the project file has been checked --- 397,424 ---- Include_Path : String_Access := null; -- The cached value of ADA_INCLUDE_PATH for this project file. ! -- Set by gnatmake (Prj.Env.Set_Ada_Paths). -- Do not use this field directly outside of the compiler, use -- Prj.Env.Ada_Source_Path instead. Objects_Path : String_Access := null; -- The cached value of ADA_OBJECTS_PATH for this project file. ! -- Set by gnatmake (Prj.Env.Set_Ada_Paths). -- Do not use this field directly outside of the compiler, use ! -- Prj.Env.Ada_Objects_Path instead. Config_File_Name : Name_Id := No_Name; -- The name of the configuration pragmas file, if any. ! -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File). Config_File_Temp : Boolean := False; -- An indication that the configuration pragmas file is -- a temporary file that must be deleted at the end. ! -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File). Config_Checked : Boolean := False; -- A flag to avoid checking repetitively the configuration pragmas file. ! -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File). Language_Independent_Checked : Boolean := False; -- A flag that indicates that the project file has been checked *************** package Prj is *** 453,458 **** --- 454,464 ---- Table_Name => "Prj.Projects"); -- The set of all project files. + type Put_Line_Access is access procedure + (Line : String; + Project : Project_Id); + -- Use to customize error reporting in Prj.Proc and Prj.Nmsc. + procedure Expect (The_Token : Token_Type; Token_Image : String); -- Check that the current token is The_Token. If it is not, then -- output an error message. *************** package Prj is *** 465,470 **** --- 471,487 ---- -- This procedure resets all the tables that are used when processing a -- project file tree. Initialize must be called before the call to Reset. + procedure Register_Default_Naming_Scheme + (Language : Name_Id; + Default_Spec_Suffix : Name_Id; + Default_Impl_Suffix : Name_Id); + -- Register the default suffixs for a given language. These extensions + -- will be ignored if the user has specified a new naming scheme in a + -- project file. + -- Otherwise, this information will be automatically added to Naming_Data + -- when a project is processed, in the lists Specification_Suffix and + -- Implementation_Suffix. + generic type State is limited private; with procedure Action diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-attr.adb gcc-3.3/gcc/ada/prj-attr.adb *** gcc-3.2.3/gcc/ada/prj-attr.adb 2002-05-04 03:28:28.000000000 +0000 --- gcc-3.3/gcc/ada/prj-attr.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.10.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** package body Prj.Attr is *** 127,132 **** --- 126,142 ---- "Pgnatstub#" & "LVswitches#" & + -- package Ide + + "Pide#" & + "SVremote_host#" & + "Sacompiler_command#" & + "SVdebugger_command#" & + "SVgnatlist#" & + "SVvcs_kind#" & + "SVvcs_file_check#" & + "SVvcs_log_check#" & + "#"; ---------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-attr.ads gcc-3.3/gcc/ada/prj-attr.ads *** gcc-3.2.3/gcc/ada/prj-attr.ads 2002-05-04 03:28:29.000000000 +0000 --- gcc-3.3/gcc/ada/prj-attr.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.12.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-com.adb gcc-3.3/gcc/ada/prj-com.adb *** gcc-3.2.3/gcc/ada/prj-com.adb 2002-05-04 03:28:29.000000000 +0000 --- gcc-3.3/gcc/ada/prj-com.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-com.ads gcc-3.3/gcc/ada/prj-com.ads *** gcc-3.2.3/gcc/ada/prj-com.ads 2002-05-07 08:22:20.000000000 +0000 --- gcc-3.3/gcc/ada/prj-com.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-dect.adb gcc-3.3/gcc/ada/prj-dect.adb *** gcc-3.2.3/gcc/ada/prj-dect.adb 2002-05-04 03:28:29.000000000 +0000 --- gcc-3.3/gcc/ada/prj-dect.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** *** 26,42 **** -- -- ------------------------------------------------------------------------------ ! with Errout; use Errout; ! with Prj.Strt; ! with Prj.Tree; use Prj.Tree; ! with Scans; use Scans; ! with Sinfo; use Sinfo; ! with Types; use Types; ! with Prj.Attr; use Prj.Attr; package body Prj.Dect is type Zone is (In_Project, In_Package, In_Case_Construction); procedure Parse_Attribute_Declaration (Attribute : out Project_Node_Id; --- 25,43 ---- -- -- ------------------------------------------------------------------------------ ! with Errout; use Errout; ! with Namet; use Namet; ! with Prj.Strt; use Prj.Strt; ! with Prj.Tree; use Prj.Tree; ! with Scans; use Scans; ! with Sinfo; use Sinfo; ! with Types; use Types; ! with Prj.Attr; use Prj.Attr; package body Prj.Dect is type Zone is (In_Project, In_Package, In_Case_Construction); + -- Needs a comment ??? procedure Parse_Attribute_Declaration (Attribute : out Project_Node_Id; *************** package body Prj.Dect is *** 67,82 **** -- Parse a package declaration procedure Parse_String_Type_Declaration ! (String_Type : out Project_Node_Id; ! Current_Project : Project_Node_Id; ! First_Attribute : Attribute_Node_Id); -- type is ( { , } ) ; procedure Parse_Variable_Declaration ! (Variable : out Project_Node_Id; ! First_Attribute : Attribute_Node_Id; ! Current_Project : Project_Node_Id; ! Current_Package : Project_Node_Id); -- Parse a variable assignment -- := ; OR -- : := ; --- 68,81 ---- -- Parse a package declaration procedure Parse_String_Type_Declaration ! (String_Type : out Project_Node_Id; ! Current_Project : Project_Node_Id); -- type is ( { , } ) ; procedure Parse_Variable_Declaration ! (Variable : out Project_Node_Id; ! Current_Project : Project_Node_Id; ! Current_Package : Project_Node_Id); -- Parse a variable assignment -- := ; OR -- : := ; *************** package body Prj.Dect is *** 96,101 **** --- 95,101 ---- Declarations := Default_Project_Node (Of_Kind => N_Project_Declaration); Set_Location_Of (Declarations, To => Token_Ptr); Set_Modified_Project_Of (Declarations, To => Extends); + Set_Project_Declaration_Of (Current_Project, Declarations); Parse_Declarative_Items (Declarations => First_Declarative_Item, In_Zone => In_Project, *************** package body Prj.Dect is *** 132,143 **** Set_Name_Of (Attribute, To => Token_Name); Set_Location_Of (Attribute, To => Token_Ptr); - if Attributes.Table (Current_Attribute).Kind_2 = - Case_Insensitive_Associative_Array - then - Set_Case_Insensitive (Attribute, To => True); - end if; - while Current_Attribute /= Empty_Attribute and then Attributes.Table (Current_Attribute).Name /= Token_Name --- 132,137 ---- *************** package body Prj.Dect is *** 146,152 **** end loop; if Current_Attribute = Empty_Attribute then ! Error_Msg ("undefined attribute", Token_Ptr); end if; Scan; --- 140,154 ---- end loop; if Current_Attribute = Empty_Attribute then ! Error_Msg ("undefined attribute """ & ! Get_Name_String (Name_Of (Attribute)) & ! """", ! Token_Ptr); ! ! elsif Attributes.Table (Current_Attribute).Kind_2 = ! Case_Insensitive_Associative_Array ! then ! Set_Case_Insensitive (Attribute, To => True); end if; Scan; *************** package body Prj.Dect is *** 156,162 **** if Current_Attribute /= Empty_Attribute and then Attributes.Table (Current_Attribute).Kind_2 = Single then ! Error_Msg ("this attribute cannot be an associative array", Location_Of (Attribute)); end if; --- 158,167 ---- if Current_Attribute /= Empty_Attribute and then Attributes.Table (Current_Attribute).Kind_2 = Single then ! Error_Msg ("the attribute """ & ! Get_Name_String ! (Attributes.Table (Current_Attribute).Name) & ! """ cannot be an associative array", Location_Of (Attribute)); end if; *************** package body Prj.Dect is *** 179,185 **** and then Attributes.Table (Current_Attribute).Kind_2 /= Single then ! Error_Msg ("this attribute need to be an associative array", Location_Of (Attribute)); end if; end if; --- 184,193 ---- and then Attributes.Table (Current_Attribute).Kind_2 /= Single then ! Error_Msg ("the attribute """ & ! Get_Name_String ! (Attributes.Table (Current_Attribute).Name) & ! """ needs to be an associative array", Location_Of (Attribute)); end if; end if; *************** package body Prj.Dect is *** 199,205 **** Expression : Project_Node_Id := Empty_Node; begin ! Prj.Strt.Parse_Expression (Expression => Expression, Current_Project => Current_Project, Current_Package => Current_Package); --- 207,213 ---- Expression : Project_Node_Id := Empty_Node; begin ! Parse_Expression (Expression => Expression, Current_Project => Current_Project, Current_Package => Current_Package); *************** package body Prj.Dect is *** 211,217 **** Expression_Kind_Of (Expression) then Error_Msg ! ("wrong expression kind for the attribute", Expression_Location); end if; end; --- 219,228 ---- Expression_Kind_Of (Expression) then Error_Msg ! ("wrong expression kind for attribute """ & ! Get_Name_String ! (Attributes.Table (Current_Attribute).Name) & ! """", Expression_Location); end if; end; *************** package body Prj.Dect is *** 229,247 **** Current_Project : Project_Node_Id; Current_Package : Project_Node_Id) is ! Current_Item : Project_Node_Id := Empty_Node; ! Next_Item : Project_Node_Id := Empty_Node; ! First_Case_Item : Boolean := True; Variable_Location : Source_Ptr := No_Location; ! String_Type : Project_Node_Id := Empty_Node; ! Case_Variable : Project_Node_Id := Empty_Node; First_Declarative_Item : Project_Node_Id := Empty_Node; ! First_Choice : Project_Node_Id := Empty_Node; begin Case_Construction := --- 240,258 ---- Current_Project : Project_Node_Id; Current_Package : Project_Node_Id) is ! Current_Item : Project_Node_Id := Empty_Node; ! Next_Item : Project_Node_Id := Empty_Node; ! First_Case_Item : Boolean := True; Variable_Location : Source_Ptr := No_Location; ! String_Type : Project_Node_Id := Empty_Node; ! Case_Variable : Project_Node_Id := Empty_Node; First_Declarative_Item : Project_Node_Id := Empty_Node; ! First_Choice : Project_Node_Id := Empty_Node; begin Case_Construction := *************** package body Prj.Dect is *** 258,264 **** if Token = Tok_Identifier then Variable_Location := Token_Ptr; ! Prj.Strt.Parse_Variable_Reference (Variable => Case_Variable, Current_Project => Current_Project, Current_Package => Current_Package); --- 269,275 ---- if Token = Tok_Identifier then Variable_Location := Token_Ptr; ! Parse_Variable_Reference (Variable => Case_Variable, Current_Project => Current_Project, Current_Package => Current_Package); *************** package body Prj.Dect is *** 275,281 **** String_Type := String_Type_Of (Case_Variable); if String_Type = Empty_Node then ! Error_Msg ("this variable is not typed", Variable_Location); end if; end if; --- 286,295 ---- String_Type := String_Type_Of (Case_Variable); if String_Type = Empty_Node then ! Error_Msg ("variable """ & ! Get_Name_String (Name_Of (Case_Variable)) & ! """ is not typed", ! Variable_Location); end if; end if; *************** package body Prj.Dect is *** 288,294 **** Scan; end if; ! Prj.Strt.Start_New_Case_Construction (String_Type); When_Loop : --- 302,308 ---- Scan; end if; ! Start_New_Case_Construction (String_Type); When_Loop : *************** package body Prj.Dect is *** 339,345 **** exit When_Loop; else ! Prj.Strt.Parse_Choice_List (First_Choice => First_Choice); Set_First_Choice_Of (Current_Item, To => First_Choice); Expect (Tok_Arrow, "=>"); --- 353,359 ---- exit When_Loop; else ! Parse_Choice_List (First_Choice => First_Choice); Set_First_Choice_Of (Current_Item, To => First_Choice); Expect (Tok_Arrow, "=>"); *************** package body Prj.Dect is *** 357,363 **** end if; end loop When_Loop; ! Prj.Strt.End_Case_Construction; Expect (Tok_End, "end case"); --- 371,377 ---- end if; end loop When_Loop; ! End_Case_Construction; Expect (Tok_End, "end case"); *************** package body Prj.Dect is *** 417,423 **** Parse_Variable_Declaration (Current_Declaration, - First_Attribute => First_Attribute, Current_Project => Current_Project, Current_Package => Current_Package); --- 431,436 ---- *************** package body Prj.Dect is *** 452,459 **** Parse_String_Type_Declaration (String_Type => Current_Declaration, ! Current_Project => Current_Project, ! First_Attribute => First_Attribute); when Tok_Case => --- 465,471 ---- Parse_String_Type_Declaration (String_Type => Current_Declaration, ! Current_Project => Current_Project); when Tok_Case => *************** package body Prj.Dect is *** 535,541 **** end loop; if Current_Package = Empty_Package then ! Error_Msg ("not an allowed package name", Token_Ptr); else Set_Package_Id_Of (Package_Declaration, To => Current_Package); --- 547,556 ---- end loop; if Current_Package = Empty_Package then ! Error_Msg ("""" & ! Get_Name_String (Name_Of (Package_Declaration)) & ! """ is not an allowed package name", ! Token_Ptr); else Set_Package_Id_Of (Package_Declaration, To => Current_Package); *************** package body Prj.Dect is *** 552,558 **** if Current /= Empty_Node then Error_Msg ! ("package declared twice in the same project", Token_Ptr); else -- Add the package to the project list --- 567,576 ---- if Current /= Empty_Node then Error_Msg ! ("package """ & ! Get_Name_String (Name_Of (Package_Declaration)) & ! """ is declared twice in the same project", ! Token_Ptr); else -- Add the package to the project list *************** package body Prj.Dect is *** 569,579 **** -- Scan past the package name Scan; - end if; if Token = Tok_Renames then -- Scan past "renames" Scan; Expect (Tok_Identifier, "identifier"); --- 587,598 ---- -- Scan past the package name Scan; end if; if Token = Tok_Renames then + -- Scan past "renames" + Scan; Expect (Tok_Identifier, "identifier"); *************** package body Prj.Dect is *** 593,599 **** end loop; if Clause = Empty_Node then ! Error_Msg ("not an imported project", Token_Ptr); else Set_Project_Of_Renamed_Package_Of (Package_Declaration, To => The_Project); --- 612,620 ---- end loop; if Clause = Empty_Node then ! Error_Msg ("""" & ! Get_Name_String (Project_Name) & ! """ is not an imported project", Token_Ptr); else Set_Project_Of_Renamed_Package_Of (Package_Declaration, To => The_Project); *************** package body Prj.Dect is *** 629,635 **** if Current = Empty_Node then Error_Msg ! ("not a package declared by the project", Token_Ptr); end if; end; --- 650,658 ---- if Current = Empty_Node then Error_Msg ! ("""" & ! Get_Name_String (Token_Name) & ! """ is not a package declared by the project", Token_Ptr); end if; end; *************** package body Prj.Dect is *** 696,703 **** procedure Parse_String_Type_Declaration (String_Type : out Project_Node_Id; ! Current_Project : Project_Node_Id; ! First_Attribute : Attribute_Node_Id) is Current : Project_Node_Id := Empty_Node; First_String : Project_Node_Id := Empty_Node; --- 719,725 ---- procedure Parse_String_Type_Declaration (String_Type : out Project_Node_Id; ! Current_Project : Project_Node_Id) is Current : Project_Node_Id := Empty_Node; First_String : Project_Node_Id := Empty_Node; *************** package body Prj.Dect is *** 726,732 **** end loop; if Current /= Empty_Node then ! Error_Msg ("duplicate string type name", Token_Ptr); else Current := First_Variable_Of (Current_Project); while Current /= Empty_Node --- 748,757 ---- end loop; if Current /= Empty_Node then ! Error_Msg ("duplicate string type name """ & ! Get_Name_String (Token_Name) & ! """", ! Token_Ptr); else Current := First_Variable_Of (Current_Project); while Current /= Empty_Node *************** package body Prj.Dect is *** 736,742 **** end loop; if Current /= Empty_Node then ! Error_Msg ("already a variable name", Token_Ptr); else Set_Next_String_Type (String_Type, To => First_String_Type_Of (Current_Project)); --- 761,769 ---- end loop; if Current /= Empty_Node then ! Error_Msg ("""" & ! Get_Name_String (Token_Name) & ! """ is already a variable name", Token_Ptr); else Set_Next_String_Type (String_Type, To => First_String_Type_Of (Current_Project)); *************** package body Prj.Dect is *** 761,767 **** Scan; end if; ! Prj.Strt.Parse_String_Type_List (First_String => First_String); Set_First_Literal_String (String_Type, To => First_String); Expect (Tok_Right_Paren, ")"); --- 788,794 ---- Scan; end if; ! Parse_String_Type_List (First_String => First_String); Set_First_Literal_String (String_Type, To => First_String); Expect (Tok_Right_Paren, ")"); *************** package body Prj.Dect is *** 778,784 **** procedure Parse_Variable_Declaration (Variable : out Project_Node_Id; - First_Attribute : Attribute_Node_Id; Current_Project : Project_Node_Id; Current_Package : Project_Node_Id) is --- 805,810 ---- *************** package body Prj.Dect is *** 850,856 **** if The_Project_Name_And_Node = Tree_Private_Part.No_Project_Name_And_Node then ! Error_Msg ("unknown project", Project_Location); Current := Empty_Node; else Current := --- 876,886 ---- if The_Project_Name_And_Node = Tree_Private_Part.No_Project_Name_And_Node then ! Error_Msg ("unknown project """ & ! Get_Name_String ! (Project_String_Type_Name) & ! """", ! Project_Location); Current := Empty_Node; else Current := *************** package body Prj.Dect is *** 867,873 **** end loop; if Current = Empty_Node then ! Error_Msg ("unknown string type", Type_Location); else Set_String_Type_Of (Variable, To => Current); --- 897,906 ---- end loop; if Current = Empty_Node then ! Error_Msg ("unknown string type """ & ! Get_Name_String (String_Type_Name) & ! """", ! Type_Location); else Set_String_Type_Of (Variable, To => Current); *************** package body Prj.Dect is *** 887,893 **** Expression_Location := Token_Ptr; ! Prj.Strt.Parse_Expression (Expression => Expression, Current_Project => Current_Project, Current_Package => Current_Package); --- 920,926 ---- Expression_Location := Token_Ptr; ! Parse_Expression (Expression => Expression, Current_Project => Current_Project, Current_Package => Current_Package); *************** package body Prj.Dect is *** 936,942 **** if Expression_Kind_Of (The_Variable) /= Expression_Kind_Of (Variable) then ! Error_Msg ("wrong expression kind for the variable", Expression_Location); end if; end if; --- 969,977 ---- if Expression_Kind_Of (The_Variable) /= Expression_Kind_Of (Variable) then ! Error_Msg ("wrong expression kind for variable """ & ! Get_Name_String (Name_Of (The_Variable)) & ! """", Expression_Location); end if; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-dect.ads gcc-3.3/gcc/ada/prj-dect.ads *** gcc-3.2.3/gcc/ada/prj-dect.ads 2002-05-04 03:28:29.000000000 +0000 --- gcc-3.3/gcc/ada/prj-dect.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.4.10.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-env.adb gcc-3.3/gcc/ada/prj-env.adb *** gcc-3.2.3/gcc/ada/prj-env.adb 2002-05-04 03:28:29.000000000 +0000 --- gcc-3.3/gcc/ada/prj-env.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.10.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** with Table; *** 40,46 **** package body Prj.Env is type Naming_Id is new Nat; - No_Naming : constant Naming_Id := 0; Ada_Path_Buffer : String_Access := new String (1 .. 1_000); -- A buffer where values for ADA_INCLUDE_PATH --- 39,44 ---- *************** package body Prj.Env is *** 62,67 **** --- 60,67 ---- Global_Configuration_Pragmas : Name_Id; Local_Configuration_Pragmas : Name_Id; + Fill_Mapping_File : Boolean := True; + ----------------------- -- Local Subprograms -- ----------------------- *************** package body Prj.Env is *** 74,79 **** --- 74,83 ---- -- Returns the path name of the spec of a unit. -- Compute it first, if necessary. + procedure Add_To_Path (Source_Dirs : String_List_Id); + -- Add to Ada_Path_Buffer all the source directories in string list + -- Source_Dirs, if any. Increment Ada_Path_Length. + procedure Add_To_Path (Path : String); -- Add Path to global variable Ada_Path_Buffer -- Increment Ada_Path_Length *************** package body Prj.Env is *** 85,96 **** function Ada_Include_Path (Project : Project_Id) return String_Access is procedure Add (Project : Project_Id); ! -- Add all the source directories of a project to the path, ! -- only if this project has not been visited. ! -- Call itself recursively for projects being modified, ! -- and imported projects. ! -- Add the project to the list Seen if this is the first time ! -- we call Add for this project. --------- -- Add -- --- 89,98 ---- function Ada_Include_Path (Project : Project_Id) return String_Access is procedure Add (Project : Project_Id); ! -- Add all the source directories of a project to the path only if ! -- this project has not been visited. Calls itself recursively for ! -- projects being modified, and imported projects. Adds the project ! -- to the list Seen if this is the call to Add for this project. --------- -- Add -- *************** package body Prj.Env is *** 98,105 **** procedure Add (Project : Project_Id) is begin ! -- If Seen is empty, then the project cannot have been ! -- visited. if not Projects.Table (Project).Seen then Projects.Table (Project).Seen := True; --- 100,106 ---- procedure Add (Project : Project_Id) is begin ! -- If Seen is empty, then the project cannot have been visited if not Projects.Table (Project).Seen then Projects.Table (Project).Seen := True; *************** package body Prj.Env is *** 108,136 **** Data : Project_Data := Projects.Table (Project); List : Project_List := Data.Imported_Projects; - Current : String_List_Id := Data.Source_Dirs; - Source_Dir : String_Element; - begin -- Add to path all source directories of this project ! while Current /= Nil_String loop ! if Ada_Path_Length > 0 then ! Add_To_Path (Path => (1 => Path_Separator)); ! end if; ! ! Source_Dir := String_Elements.Table (Current); ! String_To_Name_Buffer (Source_Dir.Value); ! ! declare ! New_Path : constant String := ! Name_Buffer (1 .. Name_Len); ! begin ! Add_To_Path (New_Path); ! end; ! ! Current := Source_Dir.Next; ! end loop; -- Call Add to the project being modified, if any --- 109,118 ---- Data : Project_Data := Projects.Table (Project); List : Project_List := Data.Imported_Projects; begin -- Add to path all source directories of this project ! Add_To_Path (Data.Source_Dirs); -- Call Add to the project being modified, if any *************** package body Prj.Env is *** 146,152 **** end loop; end; end if; - end Add; -- Start of processing for Ada_Include_Path --- 128,133 ---- *************** package body Prj.Env is *** 170,175 **** --- 151,171 ---- return Projects.Table (Project).Include_Path; end Ada_Include_Path; + function Ada_Include_Path + (Project : Project_Id; + Recursive : Boolean) + return String + is + begin + if Recursive then + return Ada_Include_Path (Project).all; + else + Ada_Path_Length := 0; + Add_To_Path (Projects.Table (Project).Source_Dirs); + return Ada_Path_Buffer (1 .. Ada_Path_Length); + end if; + end Ada_Include_Path; + ---------------------- -- Ada_Objects_Path -- ---------------------- *************** package body Prj.Env is *** 177,191 **** function Ada_Objects_Path (Project : Project_Id; Including_Libraries : Boolean := True) ! return String_Access is ! procedure Add (Project : Project_Id); ! -- Add all the object directory of a project to the path, ! -- only if this project has not been visited. ! -- Call itself recursively for projects being modified, ! -- and imported projects. ! -- Add the project to the list Seen if this is the first time ! -- we call Add for this project. --------- -- Add -- --- 173,185 ---- function Ada_Objects_Path (Project : Project_Id; Including_Libraries : Boolean := True) ! return String_Access ! is procedure Add (Project : Project_Id); ! -- Add all the object directories of a project to the path only if ! -- this project has not been visited. Calls itself recursively for ! -- projects being modified, and imported projects. Adds the project ! -- to the list Seen if this is the first call to Add for this project. --------- -- Add -- *************** package body Prj.Env is *** 193,199 **** procedure Add (Project : Project_Id) is begin - -- If this project has not been seen yet if not Projects.Table (Project).Seen then --- 187,192 ---- *************** package body Prj.Env is *** 281,286 **** --- 274,303 ---- -- Add_To_Path -- ----------------- + procedure Add_To_Path (Source_Dirs : String_List_Id) is + Current : String_List_Id := Source_Dirs; + Source_Dir : String_Element; + + begin + while Current /= Nil_String loop + if Ada_Path_Length > 0 then + Add_To_Path (Path => (1 => Path_Separator)); + end if; + + Source_Dir := String_Elements.Table (Current); + String_To_Name_Buffer (Source_Dir.Value); + + declare + New_Path : constant String := + Name_Buffer (1 .. Name_Len); + begin + Add_To_Path (New_Path); + end; + + Current := Source_Dir.Next; + end loop; + end Add_To_Path; + procedure Add_To_Path (Path : String) is begin -- If Ada_Path_Buffer is too small, double it *************** package body Prj.Env is *** 654,666 **** Last : Natural; begin ! -- Add an ASCII.LF to the string. As this gnat.adc ! -- is supposed to be used only by the compiler, we don't ! -- care about the characters for the end of line. ! -- The truth is we could have put a space, but it is ! -- more convenient to be able to read gnat.adc during ! -- development. And the development was done under UNIX. ! -- Hence the ASCII.LF. S0 (1 .. S'Length) := S; S0 (S0'Last) := ASCII.LF; --- 671,681 ---- Last : Natural; begin ! -- Add an ASCII.LF to the string. As this gnat.adc is supposed to ! -- be used only by the compiler, we don't care about the characters ! -- for the end of line. In fact we could have put a space, but ! -- it is more convenient to be able to read gnat.adc during ! -- development, for which the ASCII.LF is fine. S0 (1 .. S'Length) := S; S0 (S0'Last) := ASCII.LF; *************** package body Prj.Env is *** 678,684 **** -- Start of processing for Create_Config_Pragmas_File begin - if not Projects.Table (For_Project).Config_Checked then -- Remove any memory of processed naming schemes, if any --- 693,698 ---- *************** package body Prj.Env is *** 744,754 **** end if; if Global_Attribute_Present then - if File /= Invalid_FD or else Local_Attribute_Present then Copy_File (Global_Attribute.Value); else String_To_Name_Buffer (Global_Attribute.Value); Projects.Table (For_Project).Config_File_Name := Name_Find; --- 758,768 ---- end if; if Global_Attribute_Present then if File /= Invalid_FD or else Local_Attribute_Present then Copy_File (Global_Attribute.Value); + else String_To_Name_Buffer (Global_Attribute.Value); Projects.Table (For_Project).Config_File_Name := Name_Find; *************** package body Prj.Env is *** 756,762 **** end if; if Local_Attribute_Present then - if File /= Invalid_FD then Copy_File (Local_Attribute.Value); --- 770,775 ---- *************** package body Prj.Env is *** 764,770 **** String_To_Name_Buffer (Local_Attribute.Value); Projects.Table (For_Project).Config_File_Name := Name_Find; end if; - end if; if File /= Invalid_FD then --- 777,782 ---- *************** package body Prj.Env is *** 783,791 **** end if; Projects.Table (For_Project).Config_Checked := True; - end if; - end Create_Config_Pragmas_File; ------------------------- --- 795,801 ---- *************** package body Prj.Env is *** 797,804 **** The_Unit_Data : Unit_Data; Data : File_Name_Data; ! procedure Put (S : String); ! -- Put a line in the mapping file procedure Put_Data (Spec : Boolean); -- Put the mapping of the spec or body contained in Data in the file --- 807,814 ---- The_Unit_Data : Unit_Data; Data : File_Name_Data; ! procedure Put_Name_Buffer; ! -- Put the line contained in the Name_Buffer in the mapping file procedure Put_Data (Spec : Boolean); -- Put the mapping of the spec or body contained in Data in the file *************** package body Prj.Env is *** 808,823 **** -- Put -- --------- ! procedure Put (S : String) is Last : Natural; begin ! Last := Write (File, S'Address, S'Length); ! if Last /= S'Length then Osint.Fail ("Disk full"); end if; ! end Put; -------------- -- Put_Data -- --- 818,835 ---- -- Put -- --------- ! procedure Put_Name_Buffer is Last : Natural; begin ! Name_Len := Name_Len + 1; ! Name_Buffer (Name_Len) := ASCII.LF; ! Last := Write (File, Name_Buffer (1)'Address, Name_Len); ! if Last /= Name_Len then Osint.Fail ("Disk full"); end if; ! end Put_Name_Buffer; -------------- -- Put_Data -- *************** package body Prj.Env is *** 825,843 **** procedure Put_Data (Spec : Boolean) is begin ! Put (Get_Name_String (The_Unit_Data.Name)); if Spec then ! Put ("%s"); else ! Put ("%b"); end if; ! Put (S => (1 => ASCII.LF)); ! Put (Get_Name_String (Data.Name)); ! Put (S => (1 => ASCII.LF)); ! Put (Get_Name_String (Data.Path)); ! Put (S => (1 => ASCII.LF)); end Put_Data; -- Start of processing for Create_Mapping_File --- 837,867 ---- procedure Put_Data (Spec : Boolean) is begin ! -- Line with the unit name ! ! Get_Name_String (The_Unit_Data.Name); ! Name_Len := Name_Len + 1; ! Name_Buffer (Name_Len) := '%'; ! Name_Len := Name_Len + 1; if Spec then ! Name_Buffer (Name_Len) := 's'; else ! Name_Buffer (Name_Len) := 'b'; end if; ! Put_Name_Buffer; ! ! -- Line with the file nale ! ! Get_Name_String (Data.Name); ! Put_Name_Buffer; ! ! -- Line with the path name ! ! Get_Name_String (Data.Path); ! Put_Name_Buffer; ! end Put_Data; -- Start of processing for Create_Mapping_File *************** package body Prj.Env is *** 855,886 **** Write_Line (""""); end if; ! -- For all units in table Units ! for Unit in 1 .. Units.Last loop ! The_Unit_Data := Units.Table (Unit); ! -- If the unit has a valid name ! if The_Unit_Data.Name /= No_Name then ! Data := The_Unit_Data.File_Names (Specification); ! -- If there is a spec, put it mapping in the file ! if Data.Name /= No_Name then ! Put_Data (Spec => True); ! end if; ! Data := The_Unit_Data.File_Names (Body_Part); ! -- If there is a body (or subunit) put its mapping in the file ! if Data.Name /= No_Name then ! Put_Data (Spec => False); ! end if; ! end if; ! end loop; GNAT.OS_Lib.Close (File); --- 879,912 ---- Write_Line (""""); end if; ! if Fill_Mapping_File then ! -- For all units in table Units ! for Unit in 1 .. Units.Last loop ! The_Unit_Data := Units.Table (Unit); ! -- If the unit has a valid name ! if The_Unit_Data.Name /= No_Name then ! Data := The_Unit_Data.File_Names (Specification); ! -- If there is a spec, put it mapping in the file ! if Data.Name /= No_Name then ! Put_Data (Spec => True); ! end if; ! Data := The_Unit_Data.File_Names (Body_Part); ! -- If there is a body (or subunit) put its mapping in the file ! if Data.Name /= No_Name then ! Put_Data (Spec => False); ! end if; ! end if; ! end loop; ! end if; GNAT.OS_Lib.Close (File); *************** package body Prj.Env is *** 1045,1051 **** end if; end; end if; - end loop; -- We don't know this file name, return an empty string --- 1071,1076 ---- *************** package body Prj.Env is *** 1324,1329 **** --- 1349,1355 ---- procedure Initialize is Global : constant String := "global_configuration_pragmas"; Local : constant String := "local_configuration_pragmas"; + begin -- Put the standard GNAT naming scheme in the Namings table *************** package body Prj.Env is *** 1523,1528 **** --- 1549,1563 ---- Write_Line ("end of List of Sources."); end Print_Sources; + --------------------------------------------- + -- Set_Mapping_File_Initial_State_To_Empty -- + --------------------------------------------- + + procedure Set_Mapping_File_Initial_State_To_Empty is + begin + Fill_Mapping_File := False; + end Set_Mapping_File_Initial_State_To_Empty; + ----------------------- -- Spec_Path_Name_Of -- ----------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-env.ads gcc-3.3/gcc/ada/prj-env.ads *** gcc-3.2.3/gcc/ada/prj-env.ads 2002-05-04 03:28:30.000000000 +0000 --- gcc-3.3/gcc/ada/prj-env.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** package Prj.Env is *** 43,48 **** --- 42,51 ---- -- Create a temporary mapping file. For each unit, put the mapping of -- its spec and or body to its file name and path name in this file. + procedure Set_Mapping_File_Initial_State_To_Empty; + -- When creating a mapping file, create an empty map. This case occurs + -- when run time source files are found in the project files. + procedure Create_Config_Pragmas_File (For_Project : Project_Id; Main_Project : Project_Id); *************** package Prj.Env is *** 58,63 **** --- 61,76 ---- -- Get the ADA_INCLUDE_PATH of a Project file. For the first call, compute -- it and cache it. + function Ada_Include_Path + (Project : Project_Id; + Recursive : Boolean) + return String; + -- Get the ADA_INCLUDE_PATH of a Project file. If Recursive it True, + -- get all the source directories of the imported and modified project + -- files (recursively). If Recursive is False, just get the path for the + -- source directories of Project. Note: the resulting String may be empty + -- if there is no source directory in the project file. + function Ada_Objects_Path (Project : Project_Id; Including_Libraries : Boolean := True) diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-ext.adb gcc-3.3/gcc/ada/prj-ext.adb *** gcc-3.2.3/gcc/ada/prj-ext.adb 2002-05-04 03:28:30.000000000 +0000 --- gcc-3.3/gcc/ada/prj-ext.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-ext.ads gcc-3.3/gcc/ada/prj-ext.ads *** gcc-3.2.3/gcc/ada/prj-ext.ads 2002-05-04 03:28:30.000000000 +0000 --- gcc-3.3/gcc/ada/prj-ext.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-makr.adb gcc-3.3/gcc/ada/prj-makr.adb *** gcc-3.2.3/gcc/ada/prj-makr.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/prj-makr.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,1015 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- P R J . M A K R -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001-2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with Csets; + with Namet; use Namet; + with Opt; + with Output; + with Osint; use Osint; + with Prj; use Prj; + with Prj.Part; + with Prj.PP; + with Prj.Tree; use Prj.Tree; + with Snames; use Snames; + with Stringt; use Stringt; + with Table; use Table; + + with Ada.Characters.Handling; use Ada.Characters.Handling; + with GNAT.Directory_Operations; use GNAT.Directory_Operations; + with GNAT.Expect; use GNAT.Expect; + with GNAT.OS_Lib; use GNAT.OS_Lib; + with GNAT.Regexp; use GNAT.Regexp; + with GNAT.Regpat; use GNAT.Regpat; + + package body Prj.Makr is + + type Matched_Type is (True, False, Excluded); + + Naming_File_Suffix : constant String := "_naming"; + Source_List_File_Suffix : constant String := "_source_list.txt"; + + Output_FD : File_Descriptor; + -- To save the project file and its naming project file. + + procedure Write_Eol; + -- Output an empty line. + + procedure Write_A_Char (C : Character); + -- Write one character to Output_FD + + procedure Write_A_String (S : String); + -- Write a String to Output_FD + + ---------- + -- Make -- + ---------- + + procedure Make + (File_Path : String; + Project_File : Boolean; + Directories : Argument_List; + Name_Patterns : Argument_List; + Excluded_Patterns : Argument_List; + Very_Verbose : Boolean) + is + Path_Name : String (1 .. File_Path'Length + + Project_File_Extension'Length); + Path_Last : Natural := File_Path'Length; + + Directory_Last : Natural := 0; + + Output_Name : String (Path_Name'Range); + Output_Name_Last : Natural; + Output_Name_Id : Name_Id; + + Project_Node : Project_Node_Id := Empty_Node; + Project_Declaration : Project_Node_Id := Empty_Node; + Source_Dirs_List : Project_Node_Id := Empty_Node; + Current_Source_Dir : Project_Node_Id := Empty_Node; + + Project_Naming_Node : Project_Node_Id := Empty_Node; + Project_Naming_Decl : Project_Node_Id := Empty_Node; + Naming_Package : Project_Node_Id := Empty_Node; + + Project_Naming_File_Name : String (1 .. Output_Name'Length + + Naming_File_Suffix'Length); + + Project_Naming_Last : Natural; + Project_Naming_Id : Name_Id := No_Name; + + Excluded_Expressions : array (Excluded_Patterns'Range) of Regexp; + Regular_Expressions : array (Name_Patterns'Range) of Regexp; + + Source_List_Path : String (1 .. Output_Name'Length + + Source_List_File_Suffix'Length); + Source_List_Last : Natural; + + Source_List_FD : File_Descriptor; + + Str : String (1 .. 2_000); + Last : Natural; + Dir : Dir_Type; + + PD : Process_Descriptor; + Result : Expect_Match; + Matcher : constant Pattern_Matcher := + Compile (Expression => "expected|Unit.*\)|No such"); + + Args : Argument_List := + (1 => new String'("-c"), + 2 => new String'("-gnats"), + 3 => new String'("-gnatu"), + 4 => new String'("-x"), + 5 => new String'("ada"), + 6 => null); + + type SFN_Pragma is record + Unit : String_Access; + File : String_Access; + Spec : Boolean; + end record; + + package SFN_Pragmas is new Table.Table + (Table_Component_Type => SFN_Pragma, + Table_Index_Type => Natural, + Table_Low_Bound => 0, + Table_Initial => 50, + Table_Increment => 50, + Table_Name => "Prj.Makr.SFN_Pragmas"); + + begin + -- Do some needed initializations + + Csets.Initialize; + Namet.Initialize; + Snames.Initialize; + Prj.Initialize; + + SFN_Pragmas.Set_Last (0); + + -- Get the path and file names + + if File_Names_Case_Sensitive then + Path_Name (1 .. Path_Last) := File_Path; + else + Path_Name (1 .. Path_Last) := To_Lower (File_Path); + end if; + + Path_Name (Path_Last + 1 .. Path_Name'Last) := + Project_File_Extension; + + -- Get the end of directory information, if any + + for Index in reverse 1 .. Path_Last loop + if Path_Name (Index) = Directory_Separator then + Directory_Last := Index; + exit; + end if; + end loop; + + if Project_File then + if Path_Last < Project_File_Extension'Length + 1 + or else Path_Name + (Path_Last - Project_File_Extension'Length + 1 .. Path_Last) + /= Project_File_Extension + then + Path_Last := Path_Name'Last; + end if; + + Output_Name (1 .. Path_Last) := To_Lower (Path_Name (1 .. Path_Last)); + Output_Name_Last := Path_Last - Project_File_Extension'Length; + + if Directory_Last /= 0 then + Output_Name (1 .. Output_Name_Last - Directory_Last) := + Output_Name (Directory_Last + 1 .. Output_Name_Last); + Output_Name_Last := Output_Name_Last - Directory_Last; + end if; + + -- Get the project name id + + Name_Len := Output_Name_Last; + Name_Buffer (1 .. Name_Len) := Output_Name (1 .. Name_Len); + Output_Name_Id := Name_Find; + + -- Create the project naming file name + + Project_Naming_Last := Output_Name_Last; + Project_Naming_File_Name (1 .. Project_Naming_Last) := + Output_Name (1 .. Project_Naming_Last); + Project_Naming_File_Name + (Project_Naming_Last + 1 .. + Project_Naming_Last + Naming_File_Suffix'Length) := + Naming_File_Suffix; + Project_Naming_Last := + Project_Naming_Last + Naming_File_Suffix'Length; + + -- Get the project naming id + + Name_Len := Project_Naming_Last; + Name_Buffer (1 .. Name_Len) := + Project_Naming_File_Name (1 .. Name_Len); + Project_Naming_Id := Name_Find; + + Project_Naming_File_Name + (Project_Naming_Last + 1 .. + Project_Naming_Last + Project_File_Extension'Length) := + Project_File_Extension; + Project_Naming_Last := + Project_Naming_Last + Project_File_Extension'Length; + + -- Create the source list file name + + Source_List_Last := Output_Name_Last; + Source_List_Path (1 .. Source_List_Last) := + Output_Name (1 .. Source_List_Last); + Source_List_Path + (Source_List_Last + 1 .. + Source_List_Last + Source_List_File_Suffix'Length) := + Source_List_File_Suffix; + Source_List_Last := Source_List_Last + Source_List_File_Suffix'Length; + + -- Add the project file extension to the project name + + Output_Name + (Output_Name_Last + 1 .. + Output_Name_Last + Project_File_Extension'Length) := + Project_File_Extension; + Output_Name_Last := Output_Name_Last + Project_File_Extension'Length; + end if; + + -- Change the current directory to the directory of the project file, + -- if any directory information is specified. + + if Directory_Last /= 0 then + begin + Change_Dir (Path_Name (1 .. Directory_Last)); + exception + when Directory_Error => + Fail ("unknown directory """ & + Path_Name (1 .. Directory_Last) & '"'); + end; + end if; + + if Project_File then + + -- Delete the source list file, if it already exists + + declare + Discard : Boolean; + + begin + Delete_File + (Source_List_Path (1 .. Source_List_Last), + Success => Discard); + end; + + -- And create a new source list file. + -- Fail if file cannot be created. + + Source_List_FD := Create_New_File + (Name => Source_List_Path (1 .. Source_List_Last), + Fmode => Text); + + if Source_List_FD = Invalid_FD then + Fail ("cannot create file """ & + Source_List_Path (1 .. Source_List_Last) & '"'); + end if; + end if; + + -- Compile the regular expressions. Fails immediately if any of + -- the specified strings is in error. + + for Index in Excluded_Expressions'Range loop + begin + Excluded_Expressions (Index) := + Compile (Pattern => Excluded_Patterns (Index).all, Glob => True); + + exception + when Error_In_Regexp => + Fail ("invalid regular expression """ & + Excluded_Patterns (Index).all & '"'); + end; + end loop; + + for Index in Regular_Expressions'Range loop + begin + Regular_Expressions (Index) := + Compile (Pattern => Name_Patterns (Index).all, Glob => True); + + exception + when Error_In_Regexp => + Fail ("invalid regular expression """ & + Name_Patterns (Index).all & '"'); + end; + end loop; + + if Project_File then + if Opt.Verbose_Mode then + Output.Write_Str ("Naming project file name is """); + Output.Write_Str + (Project_Naming_File_Name (1 .. Project_Naming_Last)); + Output.Write_Line (""""); + end if; + + -- If there is already a project file with the specified name, + -- parse it to get the components that are not automatically + -- generated. + + if Is_Regular_File (Output_Name (1 .. Output_Name_Last)) then + if Opt.Verbose_Mode then + Output.Write_Str ("Parsing already existing project file """); + Output.Write_Str (Output_Name (1 .. Output_Name_Last)); + Output.Write_Line (""""); + end if; + + Part.Parse + (Project => Project_Node, + Project_File_Name => Output_Name (1 .. Output_Name_Last), + Always_Errout_Finalize => False); + + -- If parsing was successful, remove the components that are + -- automatically generated, if any, so that they will be + -- unconditionally added later. + + if Project_Node /= Empty_Node then + + -- Remove the with clause for the naming project file + + declare + With_Clause : Project_Node_Id := + First_With_Clause_Of (Project_Node); + Previous : Project_Node_Id := Empty_Node; + + begin + while With_Clause /= Empty_Node loop + if Tree.Name_Of (With_Clause) = Project_Naming_Id then + if Previous = Empty_Node then + Set_First_With_Clause_Of + (Project_Node, + To => Next_With_Clause_Of (With_Clause)); + else + Set_Next_With_Clause_Of + (Previous, + To => Next_With_Clause_Of (With_Clause)); + end if; + + exit; + end if; + + Previous := With_Clause; + With_Clause := Next_With_Clause_Of (With_Clause); + end loop; + end; + + -- Remove attribute declarations of Source_Files, + -- Source_List_File, Source_Dirs, and the declaration of + -- package Naming, if they exist. + + declare + Declaration : Project_Node_Id := + First_Declarative_Item_Of + (Project_Declaration_Of (Project_Node)); + Previous : Project_Node_Id := Empty_Node; + Current_Node : Project_Node_Id := Empty_Node; + + begin + while Declaration /= Empty_Node loop + Current_Node := Current_Item_Node (Declaration); + + if (Kind_Of (Current_Node) = N_Attribute_Declaration + and then + (Tree.Name_Of (Current_Node) = Name_Source_Files + or else Tree.Name_Of (Current_Node) = + Name_Source_List_File + or else Tree.Name_Of (Current_Node) = + Name_Source_Dirs)) + or else + (Kind_Of (Current_Node) = N_Package_Declaration + and then Tree.Name_Of (Current_Node) = Name_Naming) + then + if Previous = Empty_Node then + Set_First_Declarative_Item_Of + (Project_Declaration_Of (Project_Node), + To => Next_Declarative_Item (Declaration)); + + else + Set_Next_Declarative_Item + (Previous, + To => Next_Declarative_Item (Declaration)); + end if; + + else + Previous := Declaration; + end if; + + Declaration := Next_Declarative_Item (Declaration); + end loop; + end; + end if; + end if; + + -- If there were no already existing project file, or if the parsing + -- was unsuccessful, create an empty project node with the correct + -- name and its project declaration node. + + if Project_Node = Empty_Node then + Project_Node := Default_Project_Node (Of_Kind => N_Project); + Set_Name_Of (Project_Node, To => Output_Name_Id); + Set_Project_Declaration_Of + (Project_Node, + To => Default_Project_Node (Of_Kind => N_Project_Declaration)); + + end if; + + -- Create the naming project node, and add an attribute declaration + -- for Source_Files as an empty list, to indicate there are no + -- sources in the naming project. + + Project_Naming_Node := Default_Project_Node (Of_Kind => N_Project); + Set_Name_Of (Project_Naming_Node, To => Project_Naming_Id); + Project_Naming_Decl := + Default_Project_Node (Of_Kind => N_Project_Declaration); + Set_Project_Declaration_Of (Project_Naming_Node, Project_Naming_Decl); + Naming_Package := + Default_Project_Node (Of_Kind => N_Package_Declaration); + Set_Name_Of (Naming_Package, To => Name_Naming); + + declare + Decl_Item : constant Project_Node_Id := + Default_Project_Node (Of_Kind => N_Declarative_Item); + + Attribute : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Attribute_Declaration, + And_Expr_Kind => List); + + Expression : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Expression, + And_Expr_Kind => List); + + Term : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Term, + And_Expr_Kind => List); + + Empty_List : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Literal_String_List); + + begin + Set_First_Declarative_Item_Of + (Project_Naming_Decl, To => Decl_Item); + Set_Next_Declarative_Item (Decl_Item, Naming_Package); + Set_Current_Item_Node (Decl_Item, To => Attribute); + Set_Name_Of (Attribute, To => Name_Source_Files); + Set_Expression_Of (Attribute, To => Expression); + Set_First_Term (Expression, To => Term); + Set_Current_Term (Term, To => Empty_List); + end; + + -- Add a with clause on the naming project in the main project + + declare + With_Clause : constant Project_Node_Id := + Default_Project_Node (Of_Kind => N_With_Clause); + + begin + Set_Next_With_Clause_Of + (With_Clause, To => First_With_Clause_Of (Project_Node)); + Set_First_With_Clause_Of (Project_Node, To => With_Clause); + Set_Name_Of (With_Clause, To => Project_Naming_Id); + Start_String; + Store_String_Chars + (Project_Naming_File_Name (1 .. Project_Naming_Last)); + Set_String_Value_Of (With_Clause, To => End_String); + end; + + Project_Declaration := Project_Declaration_Of (Project_Node); + + -- Add a renaming declaration for package Naming in the main project + + declare + Decl_Item : constant Project_Node_Id := + Default_Project_Node (Of_Kind => N_Declarative_Item); + + Naming : constant Project_Node_Id := + Default_Project_Node (Of_Kind => N_Package_Declaration); + begin + Set_Next_Declarative_Item + (Decl_Item, + To => First_Declarative_Item_Of (Project_Declaration)); + Set_First_Declarative_Item_Of + (Project_Declaration, To => Decl_Item); + Set_Current_Item_Node (Decl_Item, To => Naming); + Set_Name_Of (Naming, To => Name_Naming); + Set_Project_Of_Renamed_Package_Of + (Naming, To => Project_Naming_Node); + end; + + -- Add an attribute declaration for Source_Dirs, initialized as an + -- empty list. Directories will be added as they are read from the + -- directory list file. + + declare + Decl_Item : constant Project_Node_Id := + Default_Project_Node (Of_Kind => N_Declarative_Item); + + Attribute : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Attribute_Declaration, + And_Expr_Kind => List); + + Expression : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Expression, + And_Expr_Kind => List); + + Term : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Term, And_Expr_Kind => List); + + begin + Set_Next_Declarative_Item + (Decl_Item, + To => First_Declarative_Item_Of (Project_Declaration)); + Set_First_Declarative_Item_Of + (Project_Declaration, To => Decl_Item); + Set_Current_Item_Node (Decl_Item, To => Attribute); + Set_Name_Of (Attribute, To => Name_Source_Dirs); + Set_Expression_Of (Attribute, To => Expression); + Set_First_Term (Expression, To => Term); + Source_Dirs_List := + Default_Project_Node (Of_Kind => N_Literal_String_List, + And_Expr_Kind => List); + Set_Current_Term (Term, To => Source_Dirs_List); + end; + + -- Add an attribute declaration for Source_List_File with the + -- source list file name that will be created. + + declare + Decl_Item : constant Project_Node_Id := + Default_Project_Node (Of_Kind => N_Declarative_Item); + + Attribute : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Attribute_Declaration, + And_Expr_Kind => Single); + + Expression : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Expression, + And_Expr_Kind => Single); + + Term : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Term, + And_Expr_Kind => Single); + + Value : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Literal_String, + And_Expr_Kind => Single); + + begin + Set_Next_Declarative_Item + (Decl_Item, + To => First_Declarative_Item_Of (Project_Declaration)); + Set_First_Declarative_Item_Of + (Project_Declaration, To => Decl_Item); + Set_Current_Item_Node (Decl_Item, To => Attribute); + Set_Name_Of (Attribute, To => Name_Source_List_File); + Set_Expression_Of (Attribute, To => Expression); + Set_First_Term (Expression, To => Term); + Set_Current_Term (Term, To => Value); + Start_String; + Store_String_Chars (Source_List_Path (1 .. Source_List_Last)); + Set_String_Value_Of (Value, To => End_String); + end; + end if; + + -- Process each directory + + for Index in Directories'Range loop + + declare + Dir_Name : constant String := Directories (Index).all; + Matched : Matched_Type := False; + + begin + if Opt.Verbose_Mode then + Output.Write_Str ("Processing directory """); + Output.Write_Str (Dir_Name); + Output.Write_Line (""""); + end if; + + if Project_File then + + -- Add the directory in the list for attribute Source_Dirs + + declare + Expression : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Expression, + And_Expr_Kind => Single); + + Term : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Term, + And_Expr_Kind => Single); + + Value : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Literal_String, + And_Expr_Kind => Single); + + begin + if Current_Source_Dir = Empty_Node then + Set_First_Expression_In_List + (Source_Dirs_List, To => Expression); + else + Set_Next_Expression_In_List + (Current_Source_Dir, To => Expression); + end if; + + Current_Source_Dir := Expression; + Set_First_Term (Expression, To => Term); + Set_Current_Term (Term, To => Value); + Start_String; + Store_String_Chars (S => Dir_Name); + Set_String_Value_Of (Value, To => End_String); + end; + end if; + + -- Get the source file names from the directory. + -- Fails if the directory does not exist. + + begin + Open (Dir, Dir_Name); + + exception + when Directory_Error => + Fail ("cannot open directory """ & Dir_Name & '"'); + end; + + -- Process each regular file in the directory + + loop + Read (Dir, Str, Last); + exit when Last = 0; + + if Is_Regular_File + (Dir_Name & Directory_Separator & Str (1 .. Last)) + then + Matched := True; + + -- First, check if the file name matches at least one of + -- the excluded expressions; + + for Index in Excluded_Expressions'Range loop + if + Match (Str (1 .. Last), Excluded_Expressions (Index)) + then + Matched := Excluded; + exit; + end if; + end loop; + + -- If it does not match any of the excluded expressions, + -- check if the file name matches at least one of the + -- regular expressions. + + if Matched = True then + Matched := False; + for Index in Regular_Expressions'Range loop + if + Match (Str (1 .. Last), Regular_Expressions (Index)) + then + Matched := True; + exit; + end if; + end loop; + end if; + + if Very_Verbose + or else (Matched = True and then Opt.Verbose_Mode) + then + Output.Write_Str (" Checking """); + Output.Write_Str (Str (1 .. Last)); + Output.Write_Str (""": "); + end if; + + -- If the file name matches one of the regular expressions, + -- parse it to get its unit name. + + if Matched = True then + Args (6) := new String' + (Dir_Name & + Directory_Separator & + Str (1 .. Last)); + + begin + Non_Blocking_Spawn + (PD, "gcc", Args, Err_To_Out => True); + Expect (PD, Result, Matcher); + + exception + when Process_Died => + if Opt.Verbose_Mode then + Output.Write_Str ("(process died) "); + end if; + + Result := Expect_Timeout; + end; + + if Result /= Expect_Timeout then + + -- If we got a unit name, this is a valid source file + + declare + S : constant String := Expect_Out_Match (PD); + + begin + if S'Length >= 13 + and then S (S'First .. S'First + 3) = "Unit" + then + if Opt.Verbose_Mode then + Output.Write_Str + (S (S'Last - 4 .. S'Last - 1)); + Output.Write_Str (" of "); + Output.Write_Line + (S (S'First + 5 .. S'Last - 7)); + end if; + + if Project_File then + + -- Add the corresponding attribute in the + -- Naming package of the naming project. + + declare + Decl_Item : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => + N_Declarative_Item); + + Attribute : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => + N_Attribute_Declaration); + + Expression : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Expression, + And_Expr_Kind => Single); + + Term : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Term, + And_Expr_Kind => Single); + + Value : constant Project_Node_Id := + Default_Project_Node + (Of_Kind => N_Literal_String, + And_Expr_Kind => Single); + + begin + Set_Next_Declarative_Item + (Decl_Item, + To => First_Declarative_Item_Of + (Naming_Package)); + Set_First_Declarative_Item_Of + (Naming_Package, To => Decl_Item); + Set_Current_Item_Node + (Decl_Item, To => Attribute); + + if S (S'Last - 5 .. S'Last) = "(spec)" then + Set_Name_Of + (Attribute, To => Name_Specification); + else + Set_Name_Of + (Attribute, + To => Name_Implementation); + end if; + + Start_String; + Store_String_Chars + (To_Lower + (S (S'First + 5 .. S'Last - 7))); + Set_Associative_Array_Index_Of + (Attribute, To => End_String); + + Set_Expression_Of + (Attribute, To => Expression); + Set_First_Term (Expression, To => Term); + Set_Current_Term (Term, To => Value); + + Start_String; + Store_String_Chars (Str (1 .. Last)); + Set_String_Value_Of + (Value, To => End_String); + end; + + -- Add source file name to source list file + + Last := Last + 1; + Str (Last) := ASCII.LF; + + if Write (Source_List_FD, + Str (1)'Address, + Last) /= Last + then + Fail ("disk full"); + end if; + else + -- Add an entry in the SFN_Pragmas table + + SFN_Pragmas.Increment_Last; + SFN_Pragmas.Table (SFN_Pragmas.Last) := + (Unit => new String' + (S (S'First + 5 .. S'Last - 7)), + File => new String'(Str (1 .. Last)), + Spec => S (S'Last - 5 .. S'Last) + = "(spec)"); + end if; + + else + if Opt.Verbose_Mode then + Output.Write_Line ("not a unit"); + end if; + end if; + end; + + else + if Opt.Verbose_Mode then + Output.Write_Line ("not a unit"); + end if; + end if; + + Close (PD); + + else + if Very_Verbose then + if Matched = False then + Output.Write_Line ("no match"); + + else + Output.Write_Line ("excluded"); + end if; + end if; + end if; + end if; + end loop; + + Close (Dir); + end; + end loop; + + if Project_File then + Close (Source_List_FD); + end if; + + declare + Discard : Boolean; + + begin + -- Delete the file if it already exists + + Delete_File + (Path_Name (Directory_Last + 1 .. Path_Last), + Success => Discard); + + -- Create a new one + + if Opt.Verbose_Mode then + Output.Write_Str ("Creating new file """); + Output.Write_Str (Path_Name (Directory_Last + 1 .. Path_Last)); + Output.Write_Line (""""); + end if; + + Output_FD := Create_New_File + (Path_Name (Directory_Last + 1 .. Path_Last), + Fmode => Text); + + -- Fails if project file cannot be created + + if Output_FD = Invalid_FD then + Fail ("cannot create new """ & Path_Name (1 .. Path_Last) & '"'); + end if; + + if Project_File then + + -- Output the project file + + Prj.PP.Pretty_Print + (Project_Node, + W_Char => Write_A_Char'Access, + W_Eol => Write_Eol'Access, + W_Str => Write_A_String'Access); + Close (Output_FD); + + -- Delete the naming project file if it already exists + + Delete_File + (Project_Naming_File_Name (1 .. Project_Naming_Last), + Success => Discard); + + -- Create a new one + + if Opt.Verbose_Mode then + Output.Write_Str ("Creating new naming project file """); + Output.Write_Str (Project_Naming_File_Name + (1 .. Project_Naming_Last)); + Output.Write_Line (""""); + end if; + + Output_FD := Create_New_File + (Project_Naming_File_Name (1 .. Project_Naming_Last), + Fmode => Text); + + -- Fails if naming project file cannot be created + + if Output_FD = Invalid_FD then + Fail ("cannot create new """ & + Project_Naming_File_Name (1 .. Project_Naming_Last) & + '"'); + end if; + + -- Output the naming project file + + Prj.PP.Pretty_Print + (Project_Naming_Node, + W_Char => Write_A_Char'Access, + W_Eol => Write_Eol'Access, + W_Str => Write_A_String'Access); + Close (Output_FD); + + else + -- Write to the output file each entry in the SFN_Pragmas table + -- as an pragma Source_File_Name. + + for Index in 1 .. SFN_Pragmas.Last loop + Write_A_String ("pragma Source_File_Name"); + Write_Eol; + Write_A_String (" ("); + Write_A_String (SFN_Pragmas.Table (Index).Unit.all); + Write_A_String (","); + Write_Eol; + + if SFN_Pragmas.Table (Index).Spec then + Write_A_String (" Spec_File_Name => """); + + else + Write_A_String (" Body_File_Name => """); + end if; + + Write_A_String (SFN_Pragmas.Table (Index).File.all); + Write_A_String (""");"); + Write_Eol; + end loop; + + Close (Output_FD); + end if; + end; + + end Make; + + ---------------- + -- Write_Char -- + ---------------- + procedure Write_A_Char (C : Character) is + begin + Write_A_String ((1 => C)); + end Write_A_Char; + + --------------- + -- Write_Eol -- + --------------- + + procedure Write_Eol is + begin + Write_A_String ((1 => ASCII.LF)); + end Write_Eol; + + -------------------- + -- Write_A_String -- + -------------------- + + procedure Write_A_String (S : String) is + Str : String (1 .. S'Length); + + begin + if S'Length > 0 then + Str := S; + + if Write (Output_FD, Str (1)'Address, Str'Length) /= Str'Length then + Fail ("disk full"); + end if; + end if; + end Write_A_String; + + end Prj.Makr; diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-makr.ads gcc-3.3/gcc/ada/prj-makr.ads *** gcc-3.2.3/gcc/ada/prj-makr.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/prj-makr.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,64 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- P R J . M A K R -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001-2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- Support for procedure Gnatname. + + -- For arbitrary naming schemes, create or update a project file, + -- or create a configuration pragmas file. + + with GNAT.OS_Lib; use GNAT.OS_Lib; + + package Prj.Makr is + + procedure Make + (File_Path : String; + Project_File : Boolean; + Directories : Argument_List; + Name_Patterns : Argument_List; + Excluded_Patterns : Argument_List; + Very_Verbose : Boolean); + -- Create a project file or a configuration pragmas file + -- + -- Project_File is the path name of the project file. If the project + -- file already exists parse it and keep all the elements that are not + -- automatically generated. + -- + -- Directory_List_File is the path name of a text file that + -- contains on each non empty line the path names of the source + -- directories for the project file. The source directories + -- are relative to the directory of the project file. + -- + -- File_Name_Patterns is a GNAT.Regexp string pattern such as + -- ".*\.ads|.*\.adb" or any other pattern. + -- + -- A project file (without any sources) is automatically generated + -- with the name _naming. It contains a package Naming with + -- all the specs and bodies for the project. + -- A file containing the source file names is automatically + -- generated and used as the Source_File_List for the project file. + + end Prj.Makr; diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-nmsc.adb gcc-3.3/gcc/ada/prj-nmsc.adb *** gcc-3.2.3/gcc/ada/prj-nmsc.adb 2002-05-04 03:28:30.000000000 +0000 --- gcc-3.3/gcc/ada/prj-nmsc.adb 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.7.10.1 $ -- -- ! -- Copyright (C) 2000-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2000-2002 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- -- *************** *** 26,54 **** -- -- ------------------------------------------------------------------------------ with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants; ! with Errout; use Errout; with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.OS_Lib; use GNAT.OS_Lib; - with MLib.Tgt; - with Namet; use Namet; - with Osint; use Osint; - with Output; use Output; - with Prj.Com; use Prj.Com; - with Prj.Util; use Prj.Util; - with Snames; use Snames; - with Stringt; use Stringt; - with Types; use Types; package body Prj.Nmsc is ! Dir_Sep : Character renames GNAT.OS_Lib.Directory_Separator; ! Error_Report : Put_Line_Access := null; procedure Check_Ada_Naming_Scheme (Naming : Naming_Data); -- Check that the package Naming is correct. --- 25,58 ---- -- -- ------------------------------------------------------------------------------ + with Errout; + with Hostparm; + with MLib.Tgt; + with Namet; use Namet; + with Osint; use Osint; + with Output; use Output; + with Prj.Com; use Prj.Com; + with Prj.Env; use Prj.Env; + with Prj.Util; use Prj.Util; + with Snames; use Snames; + with Stringt; use Stringt; + with Types; use Types; + with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants; ! with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.OS_Lib; use GNAT.OS_Lib; package body Prj.Nmsc is ! Dir_Sep : Character renames GNAT.OS_Lib.Directory_Separator; ! Error_Report : Put_Line_Access := null; ! Current_Project : Project_Id := No_Project; procedure Check_Ada_Naming_Scheme (Naming : Naming_Data); -- Check that the package Naming is correct. *************** package body Prj.Nmsc is *** 76,92 **** -- specific SFN pragma is needed. If the file name corresponds to no -- unit, then Unit_Name will be No_Name. ! function Is_Illegal_Append (This : String) return Boolean; ! -- Returns True if the string This cannot be used as ! -- a Specification_Append, a Body_Append or a Separate_Append. procedure Record_Source ! (File_Name : Name_Id; ! Path_Name : Name_Id; ! Project : Project_Id; ! Data : in out Project_Data; ! Location : Source_Ptr; ! Current_Source : in out String_List_Id); -- Put a unit in the list of units of a project, if the file name -- corresponds to a valid unit name. --- 80,99 ---- -- specific SFN pragma is needed. If the file name corresponds to no -- unit, then Unit_Name will be No_Name. ! function Is_Illegal_Suffix ! (Suffix : String; ! Dot_Replacement_Is_A_Single_Dot : Boolean) ! return Boolean; ! -- Returns True if the string Suffix cannot be used as ! -- a spec suffix, a body suffix or a separate suffix. procedure Record_Source ! (File_Name : Name_Id; ! Path_Name : Name_Id; ! Project : Project_Id; ! Data : in out Project_Data; ! Location : Source_Ptr; ! Current_Source : in out String_List_Id); -- Put a unit in the list of units of a project, if the file name -- corresponds to a valid unit name. *************** package body Prj.Nmsc is *** 107,119 **** -- Returns the path name of a (non project) file. -- Returns an empty string if file cannot be found. - function Path_Name_Of - (File_Name : String_Id; - Directory : String_Id) - return String; - -- Same as above except that Directory is a String_Id instead - -- of a Name_Id. - --------------- -- Ada_Check -- --------------- --- 114,119 ---- *************** package body Prj.Nmsc is *** 164,170 **** Check_Ada_Name (Element.Index, Unit_Name); if Unit_Name = No_Name then ! Error_Msg_Name_1 := Element.Index; Error_Msg ("{ is not a valid unit name.", Element.Value.Location); --- 164,170 ---- Check_Ada_Name (Element.Index, Unit_Name); if Unit_Name = No_Name then ! Errout.Error_Msg_Name_1 := Element.Index; Error_Msg ("{ is not a valid unit name.", Element.Value.Location); *************** package body Prj.Nmsc is *** 255,266 **** -- duplicate unit name. Record_Source ! (File_Name => File_Name, ! Path_Name => Path_Name, ! Project => Project, ! Data => Data, ! Location => No_Location, ! Current_Source => Current_Source); else if Current_Verbosity = High then --- 255,266 ---- -- duplicate unit name. Record_Source ! (File_Name => File_Name, ! Path_Name => Path_Name, ! Project => Project, ! Data => Data, ! Location => No_Location, ! Current_Source => Current_Source); else if Current_Verbosity = High then *************** package body Prj.Nmsc is *** 309,321 **** Source_Dir : String_List_Id := Data.Source_Dirs; Element : String_Element; Path_Name : GNAT.OS_Lib.String_Access; - Found : Boolean := False; File : Name_Id; begin if Current_Verbosity = High then Write_Str (" Checking """); ! Write_Str (File_Name); Write_Line ("""."); end if; --- 309,329 ---- Source_Dir : String_List_Id := Data.Source_Dirs; Element : String_Element; Path_Name : GNAT.OS_Lib.String_Access; File : Name_Id; + Path : Name_Id; + + Found : Boolean := False; + Fname : String := File_Name; begin + Canonical_Case_File_Name (Fname); + Name_Len := Fname'Length; + Name_Buffer (1 .. Name_Len) := Fname; + File := Name_Find; + if Current_Verbosity = High then Write_Str (" Checking """); ! Write_Str (Fname); Write_Line ("""."); end if; *************** package body Prj.Nmsc is *** 332,338 **** Path_Name := Locate_Regular_File ! (File_Name, Get_Name_String (Element.Value)); if Path_Name /= null then --- 340,346 ---- Path_Name := Locate_Regular_File ! (Fname, Get_Name_String (Element.Value)); if Path_Name /= null then *************** package body Prj.Nmsc is *** 340,361 **** Write_Line ("OK"); end if; - Name_Len := File_Name'Length; - Name_Buffer (1 .. Name_Len) := File_Name; - File := Name_Find; Name_Len := Path_Name'Length; Name_Buffer (1 .. Name_Len) := Path_Name.all; ! -- Register the source. Report an error if the file does not ! -- correspond to a source. Record_Source ! (File_Name => File, ! Path_Name => Name_Find, ! Project => Project, ! Data => Data, ! Location => Location, ! Current_Source => Current_Source); Found := True; exit; --- 348,366 ---- Write_Line ("OK"); end if; Name_Len := Path_Name'Length; Name_Buffer (1 .. Name_Len) := Path_Name.all; + Path := Name_Find; ! -- Register the source if it is an Ada compilation unit.. Record_Source ! (File_Name => File, ! Path_Name => Path, ! Project => Project, ! Data => Data, ! Location => Location, ! Current_Source => Current_Source); Found := True; exit; *************** package body Prj.Nmsc is *** 368,373 **** --- 373,386 ---- end if; end loop; + -- It is an error if a source file names in a source list or + -- in a source list file is not found. + + if not Found then + Errout.Error_Msg_Name_1 := File; + Error_Msg ("source file { cannot be found", Location); + end if; + end Get_Path_Name_And_Record_Source; --------------------------- *************** package body Prj.Nmsc is *** 383,390 **** Last : Natural; Current_Source : String_List_Id := Nil_String; - Nmb_Errors : constant Nat := Errors_Detected; - begin if Current_Verbosity = High then Write_Str ("Opening """); --- 396,401 ---- *************** package body Prj.Nmsc is *** 403,409 **** Prj.Util.Get_Line (File, Line, Last); -- If the line is not empty and does not start with "--", ! -- then it must contains a file name. if Last /= 0 and then (Last = 1 or else Line (1 .. 2) /= "--") --- 414,422 ---- Prj.Util.Get_Line (File, Line, Last); -- If the line is not empty and does not start with "--", ! -- then it should contain a file name. However, if the ! -- file name does not exist, it may be for another language ! -- and we don't fail. if Last /= 0 and then (Last = 1 or else Line (1 .. 2) /= "--") *************** package body Prj.Nmsc is *** 412,418 **** (File_Name => Line (1 .. Last), Location => Location, Current_Source => Current_Source); - exit when Nmb_Errors /= Errors_Detected; end if; end loop; --- 425,430 ---- *************** package body Prj.Nmsc is *** 433,439 **** begin Language_Independent_Check (Project, Report_Error); ! Error_Report := Report_Error; Data := Projects.Table (Project); Languages := Prj.Util.Value_Of (Name_Languages, Data.Decl.Attributes); --- 445,452 ---- begin Language_Independent_Check (Project, Report_Error); ! Error_Report := Report_Error; ! Current_Project := Project; Data := Projects.Table (Project); Languages := Prj.Util.Value_Of (Name_Languages, Data.Decl.Attributes); *************** package body Prj.Nmsc is *** 609,615 **** else Name_Len := Casing_Image'Length; Name_Buffer (1 .. Name_Len) := Casing_Image; ! Error_Msg_Name_1 := Name_Find; Error_Msg ("{ is not a correct Casing", Casing_String.Location); --- 622,628 ---- else Name_Len := Casing_Image'Length; Name_Buffer (1 .. Name_Len) := Casing_Image; ! Errout.Error_Msg_Name_1 := Name_Find; Error_Msg ("{ is not a correct Casing", Casing_String.Location); *************** package body Prj.Nmsc is *** 806,812 **** begin if Source_File_Path_Name'Length = 0 then String_To_Name_Buffer (Source_List_File.Value); ! Error_Msg_Name_1 := Name_Find; Error_Msg ("file with sources { does not exist", Source_List_File.Location); --- 819,825 ---- begin if Source_File_Path_Name'Length = 0 then String_To_Name_Buffer (Source_List_File.Value); ! Errout.Error_Msg_Name_1 := Name_Find; Error_Msg ("file with sources { does not exist", Source_List_File.Location); *************** package body Prj.Nmsc is *** 989,1013 **** -- - start with an alphanumeric -- - start with an '_' followed by an alphanumeric ! if Is_Illegal_Append (Specification_Suffix) then ! Error_Msg_Name_1 := Naming.Current_Spec_Suffix; Error_Msg ("{ is illegal for Specification_Suffix", Naming.Spec_Suffix_Loc); end if; ! if Is_Illegal_Append (Implementation_Suffix) then ! Error_Msg_Name_1 := Naming.Current_Impl_Suffix; Error_Msg ! ("% is illegal for Implementation_Suffix", Naming.Impl_Suffix_Loc); end if; if Implementation_Suffix /= Separate_Suffix then ! if Is_Illegal_Append (Separate_Suffix) then ! Error_Msg_Name_1 := Naming.Separate_Suffix; Error_Msg ! ("{ is illegal for Separate_Append", Naming.Sep_Suffix_Loc); end if; end if; --- 1002,1032 ---- -- - start with an alphanumeric -- - start with an '_' followed by an alphanumeric ! if Is_Illegal_Suffix ! (Specification_Suffix, Dot_Replacement = ".") ! then ! Errout.Error_Msg_Name_1 := Naming.Current_Spec_Suffix; Error_Msg ("{ is illegal for Specification_Suffix", Naming.Spec_Suffix_Loc); end if; ! if Is_Illegal_Suffix ! (Implementation_Suffix, Dot_Replacement = ".") ! then ! Errout.Error_Msg_Name_1 := Naming.Current_Impl_Suffix; Error_Msg ! ("{ is illegal for Implementation_Suffix", Naming.Impl_Suffix_Loc); end if; if Implementation_Suffix /= Separate_Suffix then ! if Is_Illegal_Suffix ! (Separate_Suffix, Dot_Replacement = ".") ! then ! Errout.Error_Msg_Name_1 := Naming.Separate_Suffix; Error_Msg ! ("{ is illegal for Separate_Suffix", Naming.Sep_Suffix_Loc); end if; end if; *************** package body Prj.Nmsc is *** 1124,1134 **** Add ('"'); case Msg_Name is ! when 1 => Add (Error_Msg_Name_1); ! ! when 2 => Add (Error_Msg_Name_2); ! ! when 3 => Add (Error_Msg_Name_3); when others => null; end case; --- 1143,1151 ---- Add ('"'); case Msg_Name is ! when 1 => Add (Errout.Error_Msg_Name_1); ! when 2 => Add (Errout.Error_Msg_Name_2); ! when 3 => Add (Errout.Error_Msg_Name_3); when others => null; end case; *************** package body Prj.Nmsc is *** 1141,1147 **** end loop; ! Error_Report (Error_Buffer (1 .. Error_Last)); end Error_Msg; --------------------- --- 1158,1164 ---- end loop; ! Error_Report (Error_Buffer (1 .. Error_Last), Current_Project); end Error_Msg; --------------------- *************** package body Prj.Nmsc is *** 1252,1257 **** --- 1269,1281 ---- First : Positive := File'First; Last : Natural := File'Last; + Standard_GNAT : Boolean := + Naming.Current_Spec_Suffix = + Default_Ada_Spec_Suffix + and then + Naming.Current_Impl_Suffix = + Default_Ada_Impl_Suffix; + begin -- Check if the end of the file name is Specification_Append *************** package body Prj.Nmsc is *** 1333,1338 **** --- 1357,1364 ---- end if; Get_Name_String (Naming.Dot_Replacement); + Standard_GNAT := + Standard_GNAT and then Name_Buffer (1 .. Name_Len) = "-"; if Name_Buffer (1 .. Name_Len) /= "." then *************** package body Prj.Nmsc is *** 1414,1419 **** --- 1440,1475 ---- (Source => Src, Mapping => Lower_Case_Map); + -- In the standard GNAT naming scheme, check for special cases: + -- children or separates of A, G, I or S, and run time sources. + + if Standard_GNAT and then Src'Length >= 3 then + declare + S1 : constant Character := Src (Src'First); + S2 : constant Character := Src (Src'First + 1); + + begin + if S1 = 'a' or else S1 = 'g' + or else S1 = 'i' or else S1 = 's' + then + -- Children or separates of packages A, G, I or S + + if (Hostparm.OpenVMS and then S2 = '$') + or else (not Hostparm.OpenVMS and then S2 = '~') + then + Src (Src'First + 1) := '.'; + + -- If it is potentially a run time source, disable + -- filling of the mapping file to avoid warnings. + + elsif S2 = '.' then + Set_Mapping_File_Initial_State_To_Empty; + end if; + + end if; + end; + end if; + if Current_Verbosity = High then Write_Str (" "); Write_Line (Src); *************** package body Prj.Nmsc is *** 1432,1449 **** end Get_Unit; ----------------------- ! -- Is_Illegal_Append -- ----------------------- ! function Is_Illegal_Append (This : String) return Boolean is begin ! return This'Length = 0 ! or else Is_Alphanumeric (This (This'First)) ! or else Index (This, ".") = 0 ! or else (This'Length >= 2 ! and then This (This'First) = '_' ! and then Is_Alphanumeric (This (This'First + 1))); ! end Is_Illegal_Append; -------------------------------- -- Language_Independent_Check -- --- 1488,1535 ---- end Get_Unit; ----------------------- ! -- Is_Illegal_Suffix -- ----------------------- ! function Is_Illegal_Suffix ! (Suffix : String; ! Dot_Replacement_Is_A_Single_Dot : Boolean) ! return Boolean ! is begin ! if Suffix'Length = 0 ! or else Is_Alphanumeric (Suffix (Suffix'First)) ! or else Index (Suffix, ".") = 0 ! or else (Suffix'Length >= 2 ! and then Suffix (Suffix'First) = '_' ! and then Is_Alphanumeric (Suffix (Suffix'First + 1))) ! then ! return True; ! end if; ! ! -- If dot replacement is a single dot, and first character of ! -- suffix is also a dot ! ! if Dot_Replacement_Is_A_Single_Dot ! and then Suffix (Suffix'First) = '.' ! then ! for Index in Suffix'First + 1 .. Suffix'Last loop ! ! -- If there is another dot ! ! if Suffix (Index) = '.' then ! ! -- It is illegal to have a letter following the initial dot ! ! return Is_Letter (Suffix (Suffix'First + 1)); ! end if; ! end loop; ! end if; ! ! -- Everything is OK ! ! return False; ! end Is_Illegal_Suffix; -------------------------------- -- Language_Independent_Check -- *************** package body Prj.Nmsc is *** 1496,1501 **** --- 1582,1589 ---- The_Path_Last := The_Path_Last - 1; end if; + Canonical_Case_File_Name (The_Path); + if Current_Verbosity = High then Write_Str (" "); Write_Line (The_Path (The_Path'First .. The_Path_Last)); *************** package body Prj.Nmsc is *** 1545,1555 **** -- Avoid . and .. declare ! Path_Name : constant String := The_Path (The_Path'First .. The_Path_Last) & Name (1 .. Last); begin if Is_Directory (Path_Name) then -- We have found a new subdirectory, --- 1633,1645 ---- -- Avoid . and .. declare ! Path_Name : String := The_Path (The_Path'First .. The_Path_Last) & Name (1 .. Last); begin + Canonical_Case_File_Name (Path_Name); + if Is_Directory (Path_Name) then -- We have found a new subdirectory, *************** package body Prj.Nmsc is *** 1578,1583 **** --- 1668,1674 ---- end if; String_To_Name_Buffer (From); + Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len)); Directory := Name_Buffer (1 .. Name_Len); Directory_Id := Name_Find; *************** package body Prj.Nmsc is *** 1622,1628 **** begin if Root = No_Name then ! Error_Msg_Name_1 := Base_Dir; if Location = No_Location then Error_Msg ("{ is not a valid directory.", Data.Location); else --- 1713,1719 ---- begin if Root = No_Name then ! Errout.Error_Msg_Name_1 := Base_Dir; if Location = No_Location then Error_Msg ("{ is not a valid directory.", Data.Location); else *************** package body Prj.Nmsc is *** 1656,1662 **** begin if Path_Name = No_Name then ! Error_Msg_Name_1 := Directory_Id; if Location = No_Location then Error_Msg ("{ is not a valid directory", Data.Location); else --- 1747,1753 ---- begin if Path_Name = No_Name then ! Errout.Error_Msg_Name_1 := Directory_Id; if Location = No_Location then Error_Msg ("{ is not a valid directory", Data.Location); else *************** package body Prj.Nmsc is *** 1747,1753 **** Locate_Directory (Dir_Id, Data.Directory); if Data.Object_Directory = No_Name then ! Error_Msg_Name_1 := Dir_Id; Error_Msg ("the object directory { cannot be found", Data.Location); --- 1838,1844 ---- Locate_Directory (Dir_Id, Data.Directory); if Data.Object_Directory = No_Name then ! Errout.Error_Msg_Name_1 := Dir_Id; Error_Msg ("the object directory { cannot be found", Data.Location); *************** package body Prj.Nmsc is *** 1803,1809 **** Locate_Directory (Dir_Id, Data.Directory); if Data.Exec_Directory = No_Name then ! Error_Msg_Name_1 := Dir_Id; Error_Msg ("the exec directory { cannot be found", Data.Location); --- 1894,1900 ---- Locate_Directory (Dir_Id, Data.Directory); if Data.Exec_Directory = No_Name then ! Errout.Error_Msg_Name_1 := Dir_Id; Error_Msg ("the exec directory { cannot be found", Data.Location); *************** package body Prj.Nmsc is *** 2104,2112 **** -- Check Specification_Suffix ! Data.Naming.Specification_Suffix := Util.Value_Of ! (Name_Specification_Suffix, ! Naming.Decl.Arrays); declare Current : Array_Element_Id := Data.Naming.Specification_Suffix; --- 2195,2249 ---- -- Check Specification_Suffix ! declare ! Spec_Suffixs : Array_Element_Id := ! Util.Value_Of ! (Name_Specification_Suffix, ! Naming.Decl.Arrays); ! Suffix : Array_Element_Id; ! Element : Array_Element; ! Suffix2 : Array_Element_Id; ! ! begin ! -- If some suffixs have been specified, we make sure that ! -- for each language for which a default suffix has been ! -- specified, there is a suffix specified, either the one ! -- in the project file or if there were noe, the default. ! ! if Spec_Suffixs /= No_Array_Element then ! Suffix := Data.Naming.Specification_Suffix; ! ! while Suffix /= No_Array_Element loop ! Element := Array_Elements.Table (Suffix); ! Suffix2 := Spec_Suffixs; ! ! while Suffix2 /= No_Array_Element loop ! exit when Array_Elements.Table (Suffix2).Index = ! Element.Index; ! Suffix2 := Array_Elements.Table (Suffix2).Next; ! end loop; ! ! -- There is a registered default suffix, but no ! -- suffix specified in the project file. ! -- Add the default to the array. ! ! if Suffix2 = No_Array_Element then ! Array_Elements.Increment_Last; ! Array_Elements.Table (Array_Elements.Last) := ! (Index => Element.Index, ! Value => Element.Value, ! Next => Spec_Suffixs); ! Spec_Suffixs := Array_Elements.Last; ! end if; ! ! Suffix := Element.Next; ! end loop; ! ! -- Put the resulting array as the specification suffixs ! ! Data.Naming.Specification_Suffix := Spec_Suffixs; ! end if; ! end; declare Current : Array_Element_Id := Data.Naming.Specification_Suffix; *************** package body Prj.Nmsc is *** 2130,2138 **** -- Check Implementation_Suffix ! Data.Naming.Implementation_Suffix := Util.Value_Of ! (Name_Implementation_Suffix, ! Naming.Decl.Arrays); declare Current : Array_Element_Id := Data.Naming.Implementation_Suffix; --- 2267,2320 ---- -- Check Implementation_Suffix ! declare ! Impl_Suffixs : Array_Element_Id := ! Util.Value_Of ! (Name_Implementation_Suffix, ! Naming.Decl.Arrays); ! Suffix : Array_Element_Id; ! Element : Array_Element; ! Suffix2 : Array_Element_Id; ! begin ! -- If some suffixs have been specified, we make sure that ! -- for each language for which a default suffix has been ! -- specified, there is a suffix specified, either the one ! -- in the project file or if there were noe, the default. ! ! if Impl_Suffixs /= No_Array_Element then ! Suffix := Data.Naming.Implementation_Suffix; ! ! while Suffix /= No_Array_Element loop ! Element := Array_Elements.Table (Suffix); ! Suffix2 := Impl_Suffixs; ! ! while Suffix2 /= No_Array_Element loop ! exit when Array_Elements.Table (Suffix2).Index = ! Element.Index; ! Suffix2 := Array_Elements.Table (Suffix2).Next; ! end loop; ! ! -- There is a registered default suffix, but no ! -- suffix specified in the project file. ! -- Add the default to the array. ! ! if Suffix2 = No_Array_Element then ! Array_Elements.Increment_Last; ! Array_Elements.Table (Array_Elements.Last) := ! (Index => Element.Index, ! Value => Element.Value, ! Next => Impl_Suffixs); ! Impl_Suffixs := Array_Elements.Last; ! end if; ! ! Suffix := Element.Next; ! end loop; ! ! -- Put the resulting array as the implementation suffixs ! ! Data.Naming.Implementation_Suffix := Impl_Suffixs; ! end if; ! end; declare Current : Array_Element_Id := Data.Naming.Implementation_Suffix; *************** package body Prj.Nmsc is *** 2154,2159 **** --- 2336,2352 ---- end loop; end; + -- Get the exceptions, if any + + Data.Naming.Specification_Exceptions := + Util.Value_Of + (Name_Specification_Exceptions, + In_Arrays => Naming.Decl.Arrays); + + Data.Naming.Implementation_Exceptions := + Util.Value_Of + (Name_Implementation_Exceptions, + In_Arrays => Naming.Decl.Arrays); end if; end; *************** package body Prj.Nmsc is *** 2221,2254 **** function Path_Name_Of (File_Name : String_Id; - Directory : String_Id) - return String - is - Result : String_Access; - - begin - String_To_Name_Buffer (File_Name); - - declare - The_File_Name : constant String := Name_Buffer (1 .. Name_Len); - - begin - String_To_Name_Buffer (Directory); - Result := Locate_Regular_File - (File_Name => The_File_Name, - Path => Name_Buffer (1 .. Name_Len)); - end; - - if Result = null then - return ""; - else - Canonical_Case_File_Name (Result.all); - return Result.all; - end if; - end Path_Name_Of; - - function Path_Name_Of - (File_Name : String_Id; Directory : Name_Id) return String is --- 2414,2419 ---- *************** package body Prj.Nmsc is *** 2274,2285 **** ------------------- procedure Record_Source ! (File_Name : Name_Id; ! Path_Name : Name_Id; ! Project : Project_Id; ! Data : in out Project_Data; ! Location : Source_Ptr; ! Current_Source : in out String_List_Id) is Unit_Name : Name_Id; Unit_Kind : Spec_Or_Body; --- 2439,2450 ---- ------------------- procedure Record_Source ! (File_Name : Name_Id; ! Path_Name : Name_Id; ! Project : Project_Id; ! Data : in out Project_Data; ! Location : Source_Ptr; ! Current_Source : in out String_List_Id) is Unit_Name : Name_Id; Unit_Kind : Spec_Or_Body; *************** package body Prj.Nmsc is *** 2367,2384 **** The_Location := Projects.Table (Project).Location; end if; ! Error_Msg_Name_1 := Unit_Name; Error_Msg ("duplicate source {", The_Location); ! Error_Msg_Name_1 := Projects.Table (The_Unit_Data.File_Names (Unit_Kind).Project).Name; ! Error_Msg_Name_2 := The_Unit_Data.File_Names (Unit_Kind).Path; Error_Msg ("\ project file {, {", The_Location); ! Error_Msg_Name_1 := Projects.Table (Project).Name; ! Error_Msg_Name_2 := Path_Name; Error_Msg ("\ project file {, {", The_Location); end if; --- 2532,2549 ---- The_Location := Projects.Table (Project).Location; end if; ! Errout.Error_Msg_Name_1 := Unit_Name; Error_Msg ("duplicate source {", The_Location); ! Errout.Error_Msg_Name_1 := Projects.Table (The_Unit_Data.File_Names (Unit_Kind).Project).Name; ! Errout.Error_Msg_Name_2 := The_Unit_Data.File_Names (Unit_Kind).Path; Error_Msg ("\ project file {, {", The_Location); ! Errout.Error_Msg_Name_1 := Projects.Table (Project).Name; ! Errout.Error_Msg_Name_2 := Path_Name; Error_Msg ("\ project file {, {", The_Location); end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-nmsc.ads gcc-3.3/gcc/ada/prj-nmsc.ads *** gcc-3.2.3/gcc/ada/prj-nmsc.ads 2002-05-04 03:28:30.000000000 +0000 --- gcc-3.3/gcc/ada/prj-nmsc.ads 2002-10-23 07:33:27.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 2000-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-pars.adb gcc-3.3/gcc/ada/prj-pars.adb *** gcc-3.2.3/gcc/ada/prj-pars.adb 2002-05-04 03:28:30.000000000 +0000 --- gcc-3.3/gcc/ada/prj-pars.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-pars.ads gcc-3.3/gcc/ada/prj-pars.ads *** gcc-3.2.3/gcc/ada/prj-pars.ads 2002-05-04 03:28:31.000000000 +0000 --- gcc-3.3/gcc/ada/prj-pars.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-part.adb gcc-3.3/gcc/ada/prj-part.adb *** gcc-3.2.3/gcc/ada/prj-part.adb 2002-05-04 03:28:31.000000000 +0000 --- gcc-3.3/gcc/ada/prj-part.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** package body Prj.Part is *** 51,58 **** Dir_Sep : Character renames GNAT.OS_Lib.Directory_Separator; - Project_File_Extension : String := ".gpr"; - Project_Path : String_Access; -- The project path; initialized during package elaboration. --- 50,55 ---- *************** package body Prj.Part is *** 88,100 **** -- Recursive procedure: it calls itself for imported and -- modified projects. - function Path_Name_Of - (File_Name : String; - Directory : String) - return String; - -- Returns the path name of a (non project) file. - -- Returns an empty string if file cannot be found. - function Project_Path_Name_Of (Project_File_Name : String; Directory : String) --- 85,90 ---- *************** package body Prj.Part is *** 166,183 **** declare Path_Name : constant String := ! Project_Path_Name_Of (Project_File_Name, ! Directory => Current_Directory); begin - -- Initialize the tables - - Tree_Private_Part.Project_Nodes.Set_Last (Empty_Node); - Tree_Private_Part.Projects_Htable.Reset; - Errout.Initialize; ! -- And parse the main project file if Path_Name = "" then Fail ("project file """ & Project_File_Name & """ not found"); --- 156,168 ---- declare Path_Name : constant String := ! Project_Path_Name_Of (Project_File_Name, ! Directory => Current_Directory); begin Errout.Initialize; ! -- Parse the main project file if Path_Name = "" then Fail ("project file """ & Project_File_Name & """ not found"); *************** package body Prj.Part is *** 188,194 **** Path_Name => Path_Name, Modified => False); ! if Errout.Errors_Detected > 0 then Project := Empty_Node; end if; --- 173,182 ---- Path_Name => Path_Name, Modified => False); ! -- If there were any kind of error during the parsing, serious ! -- or not, then the parsing fails. ! ! if Errout.Total_Errors_Detected > 0 then Project := Empty_Node; end if; *************** package body Prj.Part is *** 242,267 **** return; end if; ! -- New with clause ! ! if Current_With_Clause = Empty_Node then ! ! -- First with clause of the context clause ! ! Current_With_Clause := Default_Project_Node ! (Of_Kind => N_With_Clause); ! Context_Clause := Current_With_Clause; ! ! else ! Next_With_Clause := Default_Project_Node ! (Of_Kind => N_With_Clause); ! Set_Next_With_Clause_Of (Current_With_Clause, Next_With_Clause); ! Current_With_Clause := Next_With_Clause; ! end if; ! ! Set_String_Value_Of (Current_With_Clause, Strval (Token_Node)); ! Set_Location_Of (Current_With_Clause, Token_Ptr); ! String_To_Name_Buffer (String_Value_Of (Current_With_Clause)); declare Original_Path : constant String := --- 230,236 ---- return; end if; ! String_To_Name_Buffer (Strval (Token_Node)); declare Original_Path : constant String := *************** package body Prj.Part is *** 285,291 **** --- 254,294 ---- Error_Msg ("unknown project file: {", Token_Ptr); + -- If this is not imported by the main project file, + -- display the import path. + + if Project_Stack.Last > 1 then + for Index in reverse 1 .. Project_Stack.Last loop + Error_Msg_Name_1 := Project_Stack.Table (Index); + Error_Msg ("\imported by {", Token_Ptr); + end loop; + end if; + else + -- New with clause + + if Current_With_Clause = Empty_Node then + + -- First with clause of the context clause + + Current_With_Clause := Default_Project_Node + (Of_Kind => N_With_Clause); + Context_Clause := Current_With_Clause; + + else + Next_With_Clause := Default_Project_Node + (Of_Kind => N_With_Clause); + Set_Next_With_Clause_Of + (Current_With_Clause, Next_With_Clause); + Current_With_Clause := Next_With_Clause; + end if; + + Set_String_Value_Of + (Current_With_Clause, Strval (Token_Node)); + Set_Location_Of (Current_With_Clause, Token_Ptr); + String_To_Name_Buffer + (String_Value_Of (Current_With_Clause)); + -- Parse the imported project Parse_Single_Project *************** package body Prj.Part is *** 563,568 **** --- 566,585 ---- Error_Msg ("unknown project file: {", Token_Ptr); + -- If we are not in the main project file, display the + -- import path. + + if Project_Stack.Last > 1 then + Error_Msg_Name_1 := + Project_Stack.Table (Project_Stack.Last); + Error_Msg ("\extended by {", Token_Ptr); + + for Index in reverse 1 .. Project_Stack.Last - 1 loop + Error_Msg_Name_1 := Project_Stack.Table (Index); + Error_Msg ("\imported by {", Token_Ptr); + end loop; + end if; + else Parse_Single_Project (Project => Modified_Project, *************** package body Prj.Part is *** 626,655 **** Project_Stack.Decrement_Last; end Parse_Single_Project; - ------------------ - -- Path_Name_Of -- - ------------------ - - function Path_Name_Of - (File_Name : String; - Directory : String) - return String - is - Result : String_Access; - - begin - Result := Locate_Regular_File (File_Name => File_Name, - Path => Directory); - - if Result = null then - return ""; - - else - Canonical_Case_File_Name (Result.all); - return Result.all; - end if; - end Path_Name_Of; - ----------------------- -- Project_Name_From -- ----------------------- --- 643,648 ---- *************** package body Prj.Part is *** 850,857 **** end Simple_File_Name_Of; begin - Canonical_Case_File_Name (Project_File_Extension); - if Prj_Path.all = "" then Project_Path := new String'("."); --- 843,848 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-part.ads gcc-3.3/gcc/ada/prj-part.ads *** gcc-3.2.3/gcc/ada/prj-part.ads 2002-05-04 03:28:31.000000000 +0000 --- gcc-3.3/gcc/ada/prj-part.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-pp.adb gcc-3.3/gcc/ada/prj-pp.adb *** gcc-3.2.3/gcc/ada/prj-pp.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/prj-pp.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,646 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- P R J . P P -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001-2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with Ada.Characters.Handling; use Ada.Characters.Handling; + + with Hostparm; + with Namet; use Namet; + with Output; use Output; + with Stringt; use Stringt; + + package body Prj.PP is + + use Prj.Tree; + + Not_Tested : array (Project_Node_Kind) of Boolean := (others => True); + + Max_Line_Length : constant := Hostparm.Max_Line_Length - 5; + -- Maximum length of a line. + + Column : Natural := 0; + -- Column number of the last character in the line. Used to avoid + -- outputing lines longer than Max_Line_Length. + + procedure Indicate_Tested (Kind : Project_Node_Kind); + -- Set the corresponding component of array Not_Tested to False. + -- Only called by pragmas Debug. + -- + + --------------------- + -- Indicate_Tested -- + --------------------- + + procedure Indicate_Tested (Kind : Project_Node_Kind) is + begin + Not_Tested (Kind) := False; + end Indicate_Tested; + + ------------------ + -- Pretty_Print -- + ------------------ + + procedure Pretty_Print + (Project : Prj.Tree.Project_Node_Id; + Increment : Positive := 3; + Eliminate_Empty_Case_Constructions : Boolean := False; + Minimize_Empty_Lines : Boolean := False; + W_Char : Write_Char_Ap := null; + W_Eol : Write_Eol_Ap := null; + W_Str : Write_Str_Ap := null) is + + procedure Print (Node : Project_Node_Id; Indent : Natural); + -- A recursive procedure that traverses a project file tree + -- and outputs its source. + -- Current_Prj is the project that we are printing. This + -- is used when printing attributes, since in nested packages they need + -- to use a fully qualified name. + + procedure Output_Name (Name : Name_Id; Capitalize : Boolean := True); + -- Outputs a name + + procedure Start_Line (Indent : Natural); + -- Outputs the indentation at the beginning of the line. + + procedure Output_String (S : String_Id); + -- Outputs a string using the default output procedures + + procedure Write_Empty_Line (Always : Boolean := False); + -- Outputs an empty line, only if the previous line was not + -- empty already and either Always is True or Minimize_Empty_Lines + -- is False. + + procedure Write_Line (S : String); + -- Outputs S followed by a new line + + procedure Write_String (S : String); + -- Outputs S using Write_Str, starting a new line if line would + -- become too long. + + Write_Char : Write_Char_Ap := Output.Write_Char'Access; + Write_Eol : Write_Eol_Ap := Output.Write_Eol'Access; + Write_Str : Write_Str_Ap := Output.Write_Str'Access; + -- These two access to procedure values are used for the output. + + Last_Line_Is_Empty : Boolean := False; + -- Used to avoid two consecutive empty lines. + + ----------------- + -- Output_Name -- + ----------------- + + procedure Output_Name (Name : Name_Id; Capitalize : Boolean := True) is + Capital : Boolean := Capitalize; + + begin + Get_Name_String (Name); + + -- If line would become too long, create new line + + if Column + Name_Len > Max_Line_Length then + Write_Eol.all; + Column := 0; + end if; + + for J in 1 .. Name_Len loop + if Capital then + Write_Char (To_Upper (Name_Buffer (J))); + else + Write_Char (Name_Buffer (J)); + end if; + + if Capitalize then + Capital := + Name_Buffer (J) = '_' + or else Is_Digit (Name_Buffer (J)); + end if; + end loop; + end Output_Name; + + ------------------- + -- Output_String -- + ------------------- + + procedure Output_String (S : String_Id) is + begin + String_To_Name_Buffer (S); + + -- If line could become too long, create new line. + -- Note that the number of characters on the line could be + -- twice the number of character in the string (if every + -- character is a '"') plus two (the initial and final '"'). + + if Column + Name_Len + Name_Len + 2 > Max_Line_Length then + Write_Eol.all; + Column := 0; + end if; + + Write_Char ('"'); + Column := Column + 1; + String_To_Name_Buffer (S); + + for J in 1 .. Name_Len loop + if Name_Buffer (J) = '"' then + Write_Char ('"'); + Write_Char ('"'); + Column := Column + 2; + else + Write_Char (Name_Buffer (J)); + Column := Column + 1; + end if; + + -- If the string does not fit on one line, cut it in parts + -- and concatenate. + + if J < Name_Len and then Column >= Max_Line_Length then + Write_Str (""" &"); + Write_Eol.all; + Write_Char ('"'); + Column := 1; + end if; + end loop; + + Write_Char ('"'); + Column := Column + 1; + end Output_String; + + ---------------- + -- Start_Line -- + ---------------- + + procedure Start_Line (Indent : Natural) is + begin + if not Minimize_Empty_Lines then + Write_Str ((1 .. Indent => ' ')); + Column := Column + Indent; + end if; + end Start_Line; + + ---------------------- + -- Write_Empty_Line -- + ---------------------- + + procedure Write_Empty_Line (Always : Boolean := False) is + begin + if (Always or else not Minimize_Empty_Lines) + and then not Last_Line_Is_Empty then + Write_Eol.all; + Column := 0; + Last_Line_Is_Empty := True; + end if; + end Write_Empty_Line; + + ---------------- + -- Write_Line -- + ---------------- + + procedure Write_Line (S : String) is + begin + Write_String (S); + Last_Line_Is_Empty := False; + Write_Eol.all; + Column := 0; + end Write_Line; + + ------------------ + -- Write_String -- + ------------------ + + procedure Write_String (S : String) is + begin + -- If the string would not fit on the line, + -- start a new line. + + if Column + S'Length > Max_Line_Length then + Write_Eol.all; + Column := 0; + end if; + + Write_Str (S); + Column := Column + S'Length; + end Write_String; + + ----------- + -- Print -- + ----------- + + procedure Print (Node : Project_Node_Id; Indent : Natural) is + begin + if Node /= Empty_Node then + + case Kind_Of (Node) is + + when N_Project => + pragma Debug (Indicate_Tested (N_Project)); + if First_With_Clause_Of (Node) /= Empty_Node then + + -- with clause(s) + + Print (First_With_Clause_Of (Node), Indent); + Write_Empty_Line (Always => True); + end if; + + Start_Line (Indent); + Write_String ("project "); + Output_Name (Name_Of (Node)); + + -- Check if this project modifies another project + + if Modified_Project_Path_Of (Node) /= No_String then + Write_String (" extends "); + Output_String (Modified_Project_Path_Of (Node)); + end if; + + Write_Line (" is"); + Write_Empty_Line (Always => True); + + -- Output all of the declarations in the project + + Print (Project_Declaration_Of (Node), Indent); + Start_Line (Indent); + Write_String ("end "); + Output_Name (Name_Of (Node)); + Write_Line (";"); + + when N_With_Clause => + pragma Debug (Indicate_Tested (N_With_Clause)); + + if Name_Of (Node) /= No_Name then + Start_Line (Indent); + Write_String ("with "); + Output_String (String_Value_Of (Node)); + Write_Line (";"); + end if; + + Print (Next_With_Clause_Of (Node), Indent); + + when N_Project_Declaration => + pragma Debug (Indicate_Tested (N_Project_Declaration)); + + if First_Declarative_Item_Of (Node) /= Empty_Node then + Print + (First_Declarative_Item_Of (Node), Indent + Increment); + Write_Empty_Line (Always => True); + end if; + + when N_Declarative_Item => + pragma Debug (Indicate_Tested (N_Declarative_Item)); + Print (Current_Item_Node (Node), Indent); + Print (Next_Declarative_Item (Node), Indent); + + when N_Package_Declaration => + pragma Debug (Indicate_Tested (N_Package_Declaration)); + Write_Empty_Line (Always => True); + Start_Line (Indent); + Write_String ("package "); + Output_Name (Name_Of (Node)); + + if Project_Of_Renamed_Package_Of (Node) /= Empty_Node then + Write_String (" renames "); + Output_Name + (Name_Of (Project_Of_Renamed_Package_Of (Node))); + Write_String ("."); + Output_Name (Name_Of (Node)); + Write_Line (";"); + + else + Write_Line (" is"); + + if First_Declarative_Item_Of (Node) /= Empty_Node then + Print + (First_Declarative_Item_Of (Node), + Indent + Increment); + end if; + + Start_Line (Indent); + Write_String ("end "); + Output_Name (Name_Of (Node)); + Write_Line (";"); + Write_Empty_Line; + end if; + + when N_String_Type_Declaration => + pragma Debug (Indicate_Tested (N_String_Type_Declaration)); + Start_Line (Indent); + Write_String ("type "); + Output_Name (Name_Of (Node)); + Write_Line (" is"); + Start_Line (Indent + Increment); + Write_String ("("); + + declare + String_Node : Project_Node_Id := + First_Literal_String (Node); + + begin + while String_Node /= Empty_Node loop + Output_String (String_Value_Of (String_Node)); + String_Node := Next_Literal_String (String_Node); + + if String_Node /= Empty_Node then + Write_String (", "); + end if; + end loop; + end; + + Write_Line (");"); + + when N_Literal_String => + pragma Debug (Indicate_Tested (N_Literal_String)); + Output_String (String_Value_Of (Node)); + + when N_Attribute_Declaration => + pragma Debug (Indicate_Tested (N_Attribute_Declaration)); + Start_Line (Indent); + Write_String ("for "); + Output_Name (Name_Of (Node)); + + if Associative_Array_Index_Of (Node) /= No_String then + Write_String (" ("); + Output_String (Associative_Array_Index_Of (Node)); + Write_String (")"); + end if; + + Write_String (" use "); + Print (Expression_Of (Node), Indent); + Write_Line (";"); + + when N_Typed_Variable_Declaration => + pragma Debug + (Indicate_Tested (N_Typed_Variable_Declaration)); + Start_Line (Indent); + Output_Name (Name_Of (Node)); + Write_String (" : "); + Output_Name (Name_Of (String_Type_Of (Node))); + Write_String (" := "); + Print (Expression_Of (Node), Indent); + Write_Line (";"); + + when N_Variable_Declaration => + pragma Debug (Indicate_Tested (N_Variable_Declaration)); + Start_Line (Indent); + Output_Name (Name_Of (Node)); + Write_String (" := "); + Print (Expression_Of (Node), Indent); + Write_Line (";"); + + when N_Expression => + pragma Debug (Indicate_Tested (N_Expression)); + declare + Term : Project_Node_Id := First_Term (Node); + + begin + while Term /= Empty_Node loop + Print (Term, Indent); + Term := Next_Term (Term); + + if Term /= Empty_Node then + Write_String (" & "); + end if; + end loop; + end; + + when N_Term => + pragma Debug (Indicate_Tested (N_Term)); + Print (Current_Term (Node), Indent); + + when N_Literal_String_List => + pragma Debug (Indicate_Tested (N_Literal_String_List)); + Write_String ("("); + + declare + Expression : Project_Node_Id := + First_Expression_In_List (Node); + + begin + while Expression /= Empty_Node loop + Print (Expression, Indent); + Expression := Next_Expression_In_List (Expression); + + if Expression /= Empty_Node then + Write_String (", "); + end if; + end loop; + end; + + Write_String (")"); + + when N_Variable_Reference => + pragma Debug (Indicate_Tested (N_Variable_Reference)); + if Project_Node_Of (Node) /= Empty_Node then + Output_Name (Name_Of (Project_Node_Of (Node))); + Write_String ("."); + end if; + + if Package_Node_Of (Node) /= Empty_Node then + Output_Name (Name_Of (Package_Node_Of (Node))); + Write_String ("."); + end if; + + Output_Name (Name_Of (Node)); + + when N_External_Value => + pragma Debug (Indicate_Tested (N_External_Value)); + Write_String ("external ("); + Print (External_Reference_Of (Node), Indent); + + if External_Default_Of (Node) /= Empty_Node then + Write_String (", "); + Print (External_Default_Of (Node), Indent); + end if; + + Write_String (")"); + + when N_Attribute_Reference => + pragma Debug (Indicate_Tested (N_Attribute_Reference)); + + if Project_Node_Of (Node) /= Empty_Node + and then Project_Node_Of (Node) /= Project + then + Output_Name (Name_Of (Project_Node_Of (Node))); + + if Package_Node_Of (Node) /= Empty_Node then + Write_String ("."); + Output_Name (Name_Of (Package_Node_Of (Node))); + end if; + + elsif Package_Node_Of (Node) /= Empty_Node then + Output_Name (Name_Of (Package_Node_Of (Node))); + + else + Write_String ("project"); + end if; + + Write_String ("'"); + Output_Name (Name_Of (Node)); + + declare + Index : constant String_Id := + Associative_Array_Index_Of (Node); + + begin + if Index /= No_String then + Write_String (" ("); + Output_String (Index); + Write_String (")"); + end if; + end; + + when N_Case_Construction => + pragma Debug (Indicate_Tested (N_Case_Construction)); + + declare + Case_Item : Project_Node_Id := First_Case_Item_Of (Node); + Is_Non_Empty : Boolean := False; + begin + while Case_Item /= Empty_Node loop + if First_Declarative_Item_Of (Case_Item) /= Empty_Node + or else not Eliminate_Empty_Case_Constructions + then + Is_Non_Empty := True; + exit; + end if; + Case_Item := Next_Case_Item (Case_Item); + end loop; + + if Is_Non_Empty then + Write_Empty_Line; + Start_Line (Indent); + Write_String ("case "); + Print (Case_Variable_Reference_Of (Node), Indent); + Write_Line (" is"); + + declare + Case_Item : Project_Node_Id := + First_Case_Item_Of (Node); + + begin + while Case_Item /= Empty_Node loop + pragma Assert + (Kind_Of (Case_Item) = N_Case_Item); + Print (Case_Item, Indent + Increment); + Case_Item := Next_Case_Item (Case_Item); + end loop; + end; + + Start_Line (Indent); + Write_Line ("end case;"); + end if; + end; + + when N_Case_Item => + pragma Debug (Indicate_Tested (N_Case_Item)); + + if First_Declarative_Item_Of (Node) /= Empty_Node + or else not Eliminate_Empty_Case_Constructions + then + Write_Empty_Line; + Start_Line (Indent); + Write_String ("when "); + + if First_Choice_Of (Node) = Empty_Node then + Write_String ("others"); + + else + declare + Label : Project_Node_Id := First_Choice_Of (Node); + + begin + while Label /= Empty_Node loop + Print (Label, Indent); + Label := Next_Literal_String (Label); + + if Label /= Empty_Node then + Write_String (" | "); + end if; + end loop; + end; + end if; + + Write_Line (" =>"); + + declare + First : Project_Node_Id := + First_Declarative_Item_Of (Node); + + begin + if First = Empty_Node then + Write_Eol.all; + + else + Print (First, Indent + Increment); + end if; + end; + end if; + end case; + end if; + end Print; + + begin + if W_Char = null then + Write_Char := Output.Write_Char'Access; + else + Write_Char := W_Char; + end if; + + if W_Eol = null then + Write_Eol := Output.Write_Eol'Access; + else + Write_Eol := W_Eol; + end if; + + if W_Str = null then + Write_Str := Output.Write_Str'Access; + else + Write_Str := W_Str; + end if; + + Print (Project, 0); + + if W_Char = null or else W_Str = null then + Output.Write_Eol; + end if; + end Pretty_Print; + + ----------------------- + -- Output_Statistics -- + ----------------------- + + procedure Output_Statistics is + begin + Output.Write_Line ("Project_Node_Kinds not tested:"); + + for Kind in Project_Node_Kind loop + if Not_Tested (Kind) then + Output.Write_Str (" "); + Output.Write_Line (Project_Node_Kind'Image (Kind)); + end if; + end loop; + + Output.Write_Eol; + end Output_Statistics; + + end Prj.PP; diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-pp.ads gcc-3.3/gcc/ada/prj-pp.ads *** gcc-3.2.3/gcc/ada/prj-pp.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/prj-pp.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,79 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- P R J . P P -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + -- + -- This package is the Project File Pretty Printer. + -- It is used to output a project file from a project file tree. + -- It is used by gnatname to update or create project files. + -- It is also used GLIDE2 to display project file trees. + -- It can also be used for debugging purposes for tools that create project + -- file trees. + + with Prj.Tree; + + package Prj.PP is + + -- The following access to procedure types are used + -- to redirect output when calling Pretty_Print. + + type Write_Char_Ap is access procedure (C : Character); + + type Write_Eol_Ap is access procedure; + + type Write_Str_Ap is access procedure (S : String); + + procedure Pretty_Print + (Project : Prj.Tree.Project_Node_Id; + Increment : Positive := 3; + Eliminate_Empty_Case_Constructions : Boolean := False; + Minimize_Empty_Lines : Boolean := False; + W_Char : Write_Char_Ap := null; + W_Eol : Write_Eol_Ap := null; + W_Str : Write_Str_Ap := null); + -- Output a project file, using either the default output + -- routines, or the ones specified by W_Char, W_Eol and W_Str. + -- + -- Increment is the number of spaces for each indentation level. + -- + -- W_Char, W_Eol and W_Str can be used to change the default output + -- procedures. The default values force the output to Standard_Output. + -- + -- If Eliminate_Empty_Case_Constructions is True, then case constructions + -- and case items that do not include any declarations will not be output. + -- + -- If Minimize_Empty_Lines is True, empty lines will be output only + -- after the last with clause, after the line declaring the project name, + -- after the last declarative item of the project and before each + -- package declaration. Otherwise, more empty lines are output. + + private + + procedure Output_Statistics; + -- This procedure can be used after one or more calls to Pretty_Print + -- to display what Project_Node_Kinds have not been exercised by the + -- call(s) to Pretty_Print. It is used only for testing purposes. + + end Prj.PP; diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-proc.adb gcc-3.3/gcc/ada/prj-proc.adb *** gcc-3.2.3/gcc/ada/prj-proc.adb 2002-05-04 03:28:31.000000000 +0000 --- gcc-3.3/gcc/ada/prj-proc.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** with Prj.Ext; use Prj.Ext; *** 36,42 **** with Prj.Nmsc; use Prj.Nmsc; with Stringt; use Stringt; ! with GNAT.Case_Util; with GNAT.HTable; package body Prj.Proc is --- 35,41 ---- with Prj.Nmsc; use Prj.Nmsc; with Stringt; use Stringt; ! with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.HTable; package body Prj.Proc is *************** package body Prj.Proc is *** 76,88 **** (Project : Project_Id; With_Name : Name_Id) return Project_Id; ! -- Find an imported or modified project of Project whose name is With_Name. function Package_From (Project : Project_Id; With_Name : Name_Id) return Package_Id; ! -- Find the package of Project whose name is With_Name. procedure Process_Declarative_Items (Project : Project_Id; --- 75,87 ---- (Project : Project_Id; With_Name : Name_Id) return Project_Id; ! -- Find an imported or modified project of Project whose name is With_Name function Package_From (Project : Project_Id; With_Name : Name_Id) return Package_Id; ! -- Find the package of Project whose name is With_Name procedure Process_Declarative_Items (Project : Project_Id; *************** package body Prj.Proc is *** 105,119 **** -- Then process the declarative items of the project. procedure Check (Project : in out Project_Id); ! -- Set all projects to not checked, then call Recursive_Check for ! -- the main project Project. ! -- Project is set to No_Project if errors occurred. procedure Recursive_Check (Project : Project_Id); ! -- If Project is marked as not checked, mark it as checked, ! -- call Check_Naming_Scheme for the project, then call itself ! -- for a possible modified project and all the imported projects ! -- of Project. --------- -- Add -- --- 104,116 ---- -- Then process the declarative items of the project. procedure Check (Project : in out Project_Id); ! -- Set all projects to not checked, then call Recursive_Check for the ! -- main project Project. Project is set to No_Project if errors occurred. procedure Recursive_Check (Project : Project_Id); ! -- If Project is marked as not checked, mark it as checked, call ! -- Check_Naming_Scheme for the project, then call itself for a ! -- possible modified project and all the imported projects of Project. --------- -- Add -- *************** package body Prj.Proc is *** 204,210 **** procedure Check (Project : in out Project_Id) is begin ! -- Make sure that all projects are marked as not checked. for Index in 1 .. Projects.Last loop Projects.Table (Index).Checked := False; --- 201,207 ---- procedure Check (Project : in out Project_Id) is begin ! -- Make sure that all projects are marked as not checked for Index in 1 .. Projects.Last loop Projects.Table (Index).Checked := False; *************** package body Prj.Proc is *** 212,218 **** Recursive_Check (Project); ! if Errout.Errors_Detected > 0 then Project := No_Project; end if; --- 209,215 ---- Recursive_Check (Project); ! if Errout.Total_Errors_Detected > 0 then Project := No_Project; end if; *************** package body Prj.Proc is *** 376,386 **** The_Package : Package_Id := Pkg; The_Name : Name_Id := No_Name; The_Variable_Id : Variable_Id := No_Variable; ! The_Variable : Variable; Term_Project : constant Project_Node_Id := Project_Node_Of (The_Current_Term); Term_Package : constant Project_Node_Id := Package_Node_Of (The_Current_Term); begin if Term_Project /= Empty_Node and then --- 373,384 ---- The_Package : Package_Id := Pkg; The_Name : Name_Id := No_Name; The_Variable_Id : Variable_Id := No_Variable; ! The_Variable : Variable_Value; Term_Project : constant Project_Node_Id := Project_Node_Of (The_Current_Term); Term_Package : constant Project_Node_Id := Package_Node_Of (The_Current_Term); + Index : String_Id := No_String; begin if Term_Project /= Empty_Node and then *************** package body Prj.Proc is *** 416,473 **** The_Name := Name_Of (The_Current_Term); ! if The_Package /= No_Package then ! -- First, if there is a package, look into the package ! if Kind_Of (The_Current_Term) = N_Variable_Reference then ! The_Variable_Id := ! Packages.Table (The_Package).Decl.Variables; - else - The_Variable_Id := - Packages.Table (The_Package).Decl.Attributes; end if; ! while The_Variable_Id /= No_Variable ! and then ! Variable_Elements.Table (The_Variable_Id).Name /= ! The_Name ! loop ! The_Variable_Id := ! Variable_Elements.Table (The_Variable_Id).Next; ! end loop; ! end if; ! if The_Variable_Id = No_Variable then ! -- If we have not found it, look into the project ! if Kind_Of (The_Current_Term) = N_Variable_Reference then ! The_Variable_Id := ! Projects.Table (The_Project).Decl.Variables; - else - The_Variable_Id := - Projects.Table (The_Project).Decl.Attributes; end if; ! while The_Variable_Id /= No_Variable ! and then ! Variable_Elements.Table (The_Variable_Id).Name /= ! The_Name ! loop ! The_Variable_Id := ! Variable_Elements.Table (The_Variable_Id).Next; ! end loop; ! end if; ! pragma Assert (The_Variable_Id /= No_Variable, ! "variable or attribute not found"); ! The_Variable := Variable_Elements.Table (The_Variable_Id); case Kind is --- 414,559 ---- The_Name := Name_Of (The_Current_Term); ! if Kind_Of (The_Current_Term) = N_Attribute_Reference then ! Index := Associative_Array_Index_Of (The_Current_Term); ! end if; ! -- If it is not an associative array attribute ! if Index = No_String then ! ! -- It is not an associative array attribute ! ! if The_Package /= No_Package then ! ! -- First, if there is a package, look into the package ! ! if ! Kind_Of (The_Current_Term) = N_Variable_Reference ! then ! The_Variable_Id := ! Packages.Table (The_Package).Decl.Variables; ! ! else ! The_Variable_Id := ! Packages.Table (The_Package).Decl.Attributes; ! end if; ! ! while The_Variable_Id /= No_Variable ! and then ! Variable_Elements.Table (The_Variable_Id).Name /= ! The_Name ! loop ! The_Variable_Id := ! Variable_Elements.Table (The_Variable_Id).Next; ! end loop; end if; ! if The_Variable_Id = No_Variable then ! -- If we have not found it, look into the project ! if ! Kind_Of (The_Current_Term) = N_Variable_Reference ! then ! The_Variable_Id := ! Projects.Table (The_Project).Decl.Variables; ! else ! The_Variable_Id := ! Projects.Table (The_Project).Decl.Attributes; ! end if; ! while The_Variable_Id /= No_Variable ! and then ! Variable_Elements.Table (The_Variable_Id).Name /= ! The_Name ! loop ! The_Variable_Id := ! Variable_Elements.Table (The_Variable_Id).Next; ! end loop; end if; ! pragma Assert (The_Variable_Id /= No_Variable, ! "variable or attribute not found"); ! The_Variable := Variable_Elements.Table ! (The_Variable_Id).Value; ! else ! -- It is an associative array attribute ! ! declare ! The_Array : Array_Id := No_Array; ! The_Element : Array_Element_Id := No_Array_Element; ! Array_Index : Name_Id := No_Name; ! begin ! if The_Package /= No_Package then ! The_Array := ! Packages.Table (The_Package).Decl.Arrays; ! ! else ! The_Array := ! Projects.Table (The_Project).Decl.Arrays; ! end if; ! ! while The_Array /= No_Array ! and then Arrays.Table (The_Array).Name /= The_Name ! loop ! The_Array := Arrays.Table (The_Array).Next; ! end loop; ! ! if The_Array /= No_Array then ! The_Element := Arrays.Table (The_Array).Value; ! ! String_To_Name_Buffer (Index); ! ! if Case_Insensitive (The_Current_Term) then ! To_Lower (Name_Buffer (1 .. Name_Len)); ! end if; ! ! Array_Index := Name_Find; ! ! while The_Element /= No_Array_Element ! and then Array_Elements.Table (The_Element).Index ! /= Array_Index ! loop ! The_Element := ! Array_Elements.Table (The_Element).Next; ! end loop; ! ! end if; ! ! if The_Element /= No_Array_Element then ! The_Variable := ! Array_Elements.Table (The_Element).Value; ! ! else ! if ! Expression_Kind_Of (The_Current_Term) = List ! then ! The_Variable := ! (Kind => List, ! Location => No_Location, ! Default => True, ! Values => Nil_String); ! ! else ! The_Variable := ! (Kind => Single, ! Location => No_Location, ! Default => True, ! Value => Empty_String); ! end if; ! ! end if; ! ! end; ! ! end if; case Kind is *************** package body Prj.Proc is *** 480,492 **** when Single => ! case The_Variable.Value.Kind is when Undefined => null; when Single => ! Add (Result.Value, The_Variable.Value.Value); when List => --- 566,578 ---- when Single => ! case The_Variable.Kind is when Undefined => null; when Single => ! Add (Result.Value, The_Variable.Value); when List => *************** package body Prj.Proc is *** 501,507 **** end case; when List => ! case The_Variable.Value.Kind is when Undefined => null; --- 587,593 ---- end case; when List => ! case The_Variable.Kind is when Undefined => null; *************** package body Prj.Proc is *** 523,529 **** Last := String_Elements.Last; String_Elements.Table (Last) := ! (Value => The_Variable.Value.Value, Location => Location_Of (The_Current_Term), Next => Nil_String); --- 609,615 ---- Last := String_Elements.Last; String_Elements.Table (Last) := ! (Value => The_Variable.Value, Location => Location_Of (The_Current_Term), Next => Nil_String); *************** package body Prj.Proc is *** 531,537 **** declare The_List : String_List_Id := ! The_Variable.Value.Values; begin while The_List /= Nil_String loop --- 617,623 ---- declare The_List : String_List_Id := ! The_Variable.Values; begin while The_List /= Nil_String loop *************** package body Prj.Proc is *** 591,597 **** else Error_Report ("""" & Get_Name_String (Name) & ! """ is an undefined external reference"); end if; Value := Empty_String; --- 677,684 ---- else Error_Report ("""" & Get_Name_String (Name) & ! """ is an undefined external reference", ! Project); end if; Value := Empty_String; *************** package body Prj.Proc is *** 742,755 **** From_Project_Node => From_Project_Node, Modified_By => No_Project); ! if Errout.Errors_Detected > 0 then Project := No_Project; end if; if Project /= No_Project then Check (Project); end if; - end Process; ------------------------------- --- 829,841 ---- From_Project_Node => From_Project_Node, Modified_By => No_Project); ! if Errout.Total_Errors_Detected > 0 then Project := No_Project; end if; if Project /= No_Project then Check (Project); end if; end Process; ------------------------------- *************** package body Prj.Proc is *** 894,900 **** else Error_Report ("no value defined for " & ! Get_Name_String (Error_Msg_Name_1)); end if; else --- 980,987 ---- else Error_Report ("no value defined for " & ! Get_Name_String (Error_Msg_Name_1), ! Project); end if; else *************** package body Prj.Proc is *** 930,936 **** Get_Name_String (Error_Msg_Name_1) & """ is illegal for typed string """ & Get_Name_String (Error_Msg_Name_2) & ! """"); end if; end if; end; --- 1017,1024 ---- Get_Name_String (Error_Msg_Name_1) & """ is illegal for typed string """ & Get_Name_String (Error_Msg_Name_2) & ! """", ! Project); end if; end if; end; *************** package body Prj.Proc is *** 1301,1311 **** --- 1389,1402 ---- Projects.Increment_Last; Project := Projects.Last; Processed_Projects.Set (Name, Project); + Processed_Data.Name := Name; Processed_Data.Path_Name := Path_Name_Of (From_Project_Node); Processed_Data.Location := Location_Of (From_Project_Node); Processed_Data.Directory := Directory_Of (From_Project_Node); Processed_Data.Modified_By := Modified_By; + Processed_Data.Naming := Standard_Naming_Data; + Add_Attributes (Processed_Data.Decl, Attribute_First); With_Clause := First_With_Clause_Of (From_Project_Node); diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-proc.ads gcc-3.3/gcc/ada/prj-proc.ads *** gcc-3.2.3/gcc/ada/prj-proc.ads 2002-05-04 03:28:31.000000000 +0000 --- gcc-3.3/gcc/ada/prj-proc.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-strt.adb gcc-3.3/gcc/ada/prj-strt.adb *** gcc-3.2.3/gcc/ada/prj-strt.adb 2002-05-04 03:28:31.000000000 +0000 --- gcc-3.3/gcc/ada/prj-strt.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** *** 27,32 **** --- 26,32 ---- ------------------------------------------------------------------------------ with Errout; use Errout; + with Namet; use Namet; with Prj.Attr; use Prj.Attr; with Prj.Tree; use Prj.Tree; with Scans; use Scans; *************** with Types; use Types; *** 37,44 **** package body Prj.Strt is - Initial_Size : constant := 8; - type Name_Location is record Name : Name_Id := No_Name; Location : Source_Ptr := No_Location; --- 37,42 ---- *************** package body Prj.Strt is *** 73,83 **** First_Choice_Node_Id : constant Choice_Node_Id := Choice_Node_Low_Bound; - Empty_Choice : constant Choice_Node_Id := - Choice_Node_Low_Bound; - - First_Choice_Id : constant Choice_Node_Id := First_Choice_Node_Id + 1; - package Choices is new Table.Table (Table_Component_Type => Choice_String, Table_Index_Type => Choice_Node_Id, --- 71,76 ---- *************** package body Prj.Strt is *** 151,157 **** begin Reference := Default_Project_Node (Of_Kind => N_Attribute_Reference); Set_Location_Of (Reference, To => Token_Ptr); ! Scan; -- past apostrophe Expect (Tok_Identifier, "Identifier"); if Token = Tok_Identifier then --- 144,150 ---- begin Reference := Default_Project_Node (Of_Kind => N_Attribute_Reference); Set_Location_Of (Reference, To => Token_Ptr); ! Scan; -- past apostrophe Expect (Tok_Identifier, "Identifier"); if Token = Tok_Identifier then *************** package body Prj.Strt is *** 165,179 **** end loop; if Current_Attribute = Empty_Attribute then ! Error_Msg ("unknown attribute", Token_Ptr); ! Reference := Empty_Node; ! ! elsif ! Attributes.Table (Current_Attribute).Kind_2 = Associative_Array ! then ! Error_Msg ! ("associative array attribute cannot be referenced", ! Token_Ptr); Reference := Empty_Node; else --- 158,165 ---- end loop; if Current_Attribute = Empty_Attribute then ! Error_Msg_Name_1 := Token_Name; ! Error_Msg ("unknown attribute %", Token_Ptr); Reference := Empty_Node; else *************** package body Prj.Strt is *** 181,187 **** --- 167,196 ---- Set_Package_Node_Of (Reference, To => Current_Package); Set_Expression_Kind_Of (Reference, To => Attributes.Table (Current_Attribute).Kind_1); + Set_Case_Insensitive + (Reference, To => Attributes.Table (Current_Attribute).Kind_2 = + Case_Insensitive_Associative_Array); Scan; + + if Attributes.Table (Current_Attribute).Kind_2 /= Single then + Expect (Tok_Left_Paren, "("); + + if Token = Tok_Left_Paren then + Scan; + Expect (Tok_String_Literal, "literal string"); + + if Token = Tok_String_Literal then + Set_Associative_Array_Index_Of + (Reference, To => Strval (Token_Node)); + Scan; + Expect (Tok_Right_Paren, ")"); + + if Token = Tok_Right_Paren then + Scan; + end if; + end if; + end if; + end if; end if; end if; end Attribute_Reference; *************** package body Prj.Strt is *** 319,325 **** Found := True; if Choices.Table (Choice).Already_Used then ! Error_Msg ("duplicate case label", Token_Ptr); else Choices.Table (Choice).Already_Used := True; end if; --- 328,336 ---- Found := True; if Choices.Table (Choice).Already_Used then ! String_To_Name_Buffer (Choice_String); ! Error_Msg_Name_1 := Name_Find; ! Error_Msg ("duplicate case label {", Token_Ptr); else Choices.Table (Choice).Already_Used := True; end if; *************** package body Prj.Strt is *** 329,335 **** end loop; if not Found then ! Error_Msg ("illegal case label", Token_Ptr); end if; Scan; --- 340,348 ---- end loop; if not Found then ! String_To_Name_Buffer (Choice_String); ! Error_Msg_Name_1 := Name_Find; ! Error_Msg ("illegal case label {", Token_Ptr); end if; Scan; *************** package body Prj.Strt is *** 398,404 **** begin while Current /= Last_String loop if String_Equal (String_Value_Of (Current), String_Value) then ! Error_Msg ("duplicate value in type", Token_Ptr); exit; end if; --- 411,419 ---- begin while Current /= Last_String loop if String_Equal (String_Value_Of (Current), String_Value) then ! String_To_Name_Buffer (String_Value); ! Error_Msg_Name_1 := Name_Find; ! Error_Msg ("duplicate value { in type", Token_Ptr); exit; end if; *************** package body Prj.Strt is *** 494,500 **** end loop; if The_Package = Empty_Node then ! Error_Msg ("package not yet defined", The_Names (1).Location); end if; --- 509,516 ---- end loop; if The_Package = Empty_Node then ! Error_Msg_Name_1 := The_Names (1).Name; ! Error_Msg ("package % not yet defined", The_Names (1).Location); end if; *************** package body Prj.Strt is *** 514,520 **** if The_Project_Name_And_Node = Tree_Private_Part.No_Project_Name_And_Node then ! Error_Msg ("unknown project", The_Names (1).Location); else The_Project := The_Project_Name_And_Node.Node; --- 530,537 ---- if The_Project_Name_And_Node = Tree_Private_Part.No_Project_Name_And_Node then ! Error_Msg_Name_1 := The_Names (1).Name; ! Error_Msg ("unknown project %", The_Names (1).Location); else The_Project := The_Project_Name_And_Node.Node; *************** package body Prj.Strt is *** 535,541 **** end loop; if With_Clause = Empty_Node then ! Error_Msg ("unknown project", The_Names (1).Location); The_Project := Empty_Node; The_Package := Empty_Node; --- 552,559 ---- end loop; if With_Clause = Empty_Node then ! Error_Msg_Name_1 := The_Names (1).Name; ! Error_Msg ("unknown project %", The_Names (1).Location); The_Project := Empty_Node; The_Package := Empty_Node; *************** package body Prj.Strt is *** 551,557 **** end loop; if The_Package = Empty_Node then ! Error_Msg ("package not declared in project", The_Names (2).Location); First_Attribute := Attribute_First; --- 569,577 ---- end loop; if The_Package = Empty_Node then ! Error_Msg_Name_1 := The_Names (2).Name; ! Error_Msg_Name_2 := The_Names (1).Name; ! Error_Msg ("package % not declared in project %", The_Names (2).Location); First_Attribute := Attribute_First; *************** package body Prj.Strt is *** 637,643 **** end if; if The_Project = Empty_Node then ! Error_Msg ("unknown package or project", The_Names (1).Location); Look_For_Variable := False; else --- 657,664 ---- end if; if The_Project = Empty_Node then ! Error_Msg_Name_1 := The_Names (1).Name; ! Error_Msg ("unknown package or project %", The_Names (1).Location); Look_For_Variable := False; else *************** package body Prj.Strt is *** 675,681 **** end if; if The_Project = Empty_Node then ! Error_Msg ("unknown package or project", The_Names (1).Location); Look_For_Variable := False; --- 696,703 ---- end if; if The_Project = Empty_Node then ! Error_Msg_Name_1 := The_Names (1).Name; ! Error_Msg ("unknown package or project %", The_Names (1).Location); Look_For_Variable := False; *************** package body Prj.Strt is *** 690,696 **** end loop; if The_Package = Empty_Node then ! Error_Msg ("unknown package", The_Names (2).Location); Look_For_Variable := False; --- 712,719 ---- end loop; if The_Package = Empty_Node then ! Error_Msg_Name_1 := The_Names (2).Name; ! Error_Msg ("unknown package %", The_Names (2).Location); Look_For_Variable := False; *************** package body Prj.Strt is *** 732,738 **** end if; if Current_Variable = Empty_Node then ! Error_Msg ("unknown variable", The_Names (Last_Name).Location); end if; end if; --- 755,762 ---- end if; if Current_Variable = Empty_Node then ! Error_Msg_Name_1 := Variable_Name; ! Error_Msg ("unknown variable %", The_Names (Last_Name).Location); end if; end if; *************** package body Prj.Strt is *** 745,750 **** --- 769,789 ---- (Variable, To => String_Type_Of (Current_Variable)); end if; end if; + + if Token = Tok_Left_Paren then + Error_Msg ("\variables cannot be associative arrays", Token_Ptr); + Scan; + Expect (Tok_String_Literal, "literal string"); + + if Token = Tok_String_Literal then + Scan; + Expect (Tok_Right_Paren, ")"); + + if Token = Tok_Right_Paren then + Scan; + end if; + end if; + end if; end Parse_Variable_Reference; --------------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-strt.ads gcc-3.3/gcc/ada/prj-strt.ads *** gcc-3.2.3/gcc/ada/prj-strt.ads 2002-05-04 03:28:32.000000000 +0000 --- gcc-3.3/gcc/ada/prj-strt.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-tree.adb gcc-3.3/gcc/ada/prj-tree.adb *** gcc-3.2.3/gcc/ada/prj-tree.adb 2002-05-04 03:28:32.000000000 +0000 --- gcc-3.3/gcc/ada/prj-tree.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Prj.Tree is *** 44,50 **** pragma Assert (Node /= Empty_Node and then ! (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration)); return Project_Nodes.Table (Node).Value; end Associative_Array_Index_Of; --- 43,51 ---- pragma Assert (Node /= Empty_Node and then ! (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration ! or else ! Project_Nodes.Table (Node).Kind = N_Attribute_Reference)); return Project_Nodes.Table (Node).Value; end Associative_Array_Index_Of; *************** package body Prj.Tree is *** 57,63 **** pragma Assert (Node /= Empty_Node and then ! (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration)); return Project_Nodes.Table (Node).Case_Insensitive; end Case_Insensitive; --- 58,66 ---- pragma Assert (Node /= Empty_Node and then ! (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration ! or else ! Project_Nodes.Table (Node).Kind = N_Attribute_Reference)); return Project_Nodes.Table (Node).Case_Insensitive; end Case_Insensitive; *************** package body Prj.Tree is *** 733,739 **** pragma Assert (Node /= Empty_Node and then ! Project_Nodes.Table (Node).Kind = N_Attribute_Declaration); Project_Nodes.Table (Node).Value := To; end Set_Associative_Array_Index_Of; --- 736,744 ---- pragma Assert (Node /= Empty_Node and then ! (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration ! or else ! Project_Nodes.Table (Node).Kind = N_Attribute_Reference)); Project_Nodes.Table (Node).Value := To; end Set_Associative_Array_Index_Of; *************** package body Prj.Tree is *** 749,755 **** pragma Assert (Node /= Empty_Node and then ! Project_Nodes.Table (Node).Kind = N_Attribute_Declaration); Project_Nodes.Table (Node).Case_Insensitive := To; end Set_Case_Insensitive; --- 754,762 ---- pragma Assert (Node /= Empty_Node and then ! (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration ! or else ! Project_Nodes.Table (Node).Kind = N_Attribute_Reference)); Project_Nodes.Table (Node).Case_Insensitive := To; end Set_Case_Insensitive; diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-tree.ads gcc-3.3/gcc/ada/prj-tree.ads *** gcc-3.2.3/gcc/ada/prj-tree.ads 2002-05-04 03:28:32.000000000 +0000 --- gcc-3.3/gcc/ada/prj-tree.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.4.10.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Prj.Tree is *** 53,59 **** Empty_Node : constant Project_Node_Id := Project_Node_Low_Bound; -- Designates no node in table Project_Nodes ! First_Node_Id : constant Project_Node_Id := Project_Node_Low_Bound; subtype Variable_Node_Id is Project_Node_Id; -- Used to designate a node whose expected kind is one of --- 52,58 ---- Empty_Node : constant Project_Node_Id := Project_Node_Low_Bound; -- Designates no node in table Project_Nodes ! First_Node_Id : constant Project_Node_Id := Project_Node_Low_Bound + 1; subtype Variable_Node_Id is Project_Node_Id; -- Used to designate a node whose expected kind is one of *************** package Prj.Tree is *** 233,239 **** function Associative_Array_Index_Of (Node : Project_Node_Id) return String_Id; ! -- Only valid for N_Attribute_Declaration. -- Returns No_String for non associative array attributes. function Next_Variable --- 232,238 ---- function Associative_Array_Index_Of (Node : Project_Node_Id) return String_Id; ! -- Only valid for N_Attribute_Declaration and N_Attribute_Reference. -- Returns No_String for non associative array attributes. function Next_Variable *************** package Prj.Tree is *** 311,317 **** -- Only valid for N_Case_Item nodes function Case_Insensitive (Node : Project_Node_Id) return Boolean; ! -- Only valid for N_Attribute_Declaration nodes -------------------- -- Set Procedures -- --- 310,316 ---- -- Only valid for N_Case_Item nodes function Case_Insensitive (Node : Project_Node_Id) return Boolean; ! -- Only valid for N_Attribute_Declaration and N_Attribute_Reference nodes -------------------- -- Set Procedures -- *************** package Prj.Tree is *** 547,555 **** -- See below the meaning for each Project_Node_Kind Case_Insensitive : Boolean := False; ! -- Significant only for N_Attribute_Declaration ! -- Indicates, for an associative array attribute, that the ! -- index is case insensitive. end record; --- 546,554 ---- -- See below the meaning for each Project_Node_Kind Case_Insensitive : Boolean := False; ! -- This flag is significant only for N_Attribute_Declaration and ! -- N_Atribute_Reference. It indicates for an associative array ! -- attribute, that the index is case insensitive. end record; *************** package Prj.Tree is *** 705,711 **** -- -- Field1: project -- -- Field2: package (if attribute of a package) -- -- Field3: not used ! -- -- Value: not used -- N_Case_Construction, -- -- Name: not used --- 704,711 ---- -- -- Field1: project -- -- Field2: package (if attribute of a package) -- -- Field3: not used ! -- -- Value: associative array index ! -- -- (if an associative array element) -- N_Case_Construction, -- -- Name: not used diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-util.adb gcc-3.3/gcc/ada/prj-util.adb *** gcc-3.2.3/gcc/ada/prj-util.adb 2002-05-04 03:28:32.000000000 +0000 --- gcc-3.3/gcc/ada/prj-util.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.12.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/prj-util.ads gcc-3.3/gcc/ada/prj-util.ads *** gcc-3.2.3/gcc/ada/prj-util.ads 2002-05-04 03:28:33.000000000 +0000 --- gcc-3.3/gcc/ada/prj-util.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/raise.c gcc-3.3/gcc/ada/raise.c *** gcc-3.2.3/gcc/ada/raise.c 2002-05-04 03:28:33.000000000 +0000 --- gcc-3.3/gcc/ada/raise.c 2003-03-05 16:13:55.000000000 +0000 *************** *** 6,14 **** * * * C Implementation File * * * - * $Revision: 1.2.10.1 $ * * ! * Copyright (C) 1992-2001, 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- * --- 6,13 ---- * * * C Implementation File * * * * * ! * Copyright (C) 1992-2002, 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- * *************** *** 38,43 **** --- 37,45 ---- #include "tconfig.h" #include "tsystem.h" #include + typedef char bool; + # define true 1 + # define false 0 #else #include "config.h" #include "system.h" *************** __gnat_unhandled_terminate () *** 85,92 **** #endif } ! /* Below is the eh personality routine for Ada to be called when the GCC ! mechanism is used. ??? It is currently inspired from the one for C++, needs cleanups and additional comments. It also contains a big bunch of debugging code that --- 87,108 ---- #endif } ! /* Below is the code related to the integration of the GCC mechanism for ! exception handling. Still work in progress. */ ! ! #include "unwind.h" ! ! /* If the underlying GCC scheme for exception handling is SJLJ, the standard ! propagation routine (_Unwind_RaiseException) is actually renamed using a ! #define directive (see unwing-sjlj.c). We need a consistently named ! interface to import from a-except, so stubs are defined here, at the end ! of this file. */ ! ! _Unwind_Reason_Code ! __gnat_Unwind_RaiseException PARAMS ((struct _Unwind_Exception *)); ! ! ! /* Exception Handling personality routine for Ada. ??? It is currently inspired from the one for C++, needs cleanups and additional comments. It also contains a big bunch of debugging code that *************** __gnat_unhandled_terminate () *** 97,103 **** /* ??? Does it make any sense to leave this for the compiler ? */ #include "dwarf2.h" - #include "unwind.h" #include "unwind-dw2-fde.h" #include "unwind-pe.h" --- 113,118 ---- *************** struct lsda_header_info *** 118,128 **** typedef struct lsda_header_info lsda_header_info; - typedef enum {false = 0, true = 1} bool; - static const unsigned char * ! parse_lsda_header (_Unwind_Context *context, const unsigned char *p, ! lsda_header_info *info) { _Unwind_Ptr tmp; unsigned char lpstart_encoding; --- 133,143 ---- typedef struct lsda_header_info lsda_header_info; static const unsigned char * ! parse_lsda_header (context, p, info) ! _Unwind_Context *context; ! const unsigned char *p; ! lsda_header_info *info; { _Unwind_Ptr tmp; unsigned char lpstart_encoding; *************** parse_lsda_header (_Unwind_Context *cont *** 135,141 **** p = read_encoded_value (context, lpstart_encoding, p, &info->LPStart); else info->LPStart = info->Start; ! /* Find @TType, the base of the handler and exception spec type data. */ info->ttype_encoding = *p++; if (info->ttype_encoding != DW_EH_PE_omit) --- 150,156 ---- p = read_encoded_value (context, lpstart_encoding, p, &info->LPStart); else info->LPStart = info->Start; ! /* Find @TType, the base of the handler and exception spec type data. */ info->ttype_encoding = *p++; if (info->ttype_encoding != DW_EH_PE_omit) *************** parse_lsda_header (_Unwind_Context *cont *** 155,163 **** return p; } - static const _Unwind_Ptr ! get_ttype_entry (_Unwind_Context *context, lsda_header_info *info, long i) { _Unwind_Ptr ptr; --- 170,180 ---- return p; } static const _Unwind_Ptr ! get_ttype_entry (context, info, i) ! _Unwind_Context *context; ! lsda_header_info *info; ! long i; { _Unwind_Ptr ptr; *************** get_ttype_entry (_Unwind_Context *contex *** 171,181 **** library (a-except.adb). The layouts should exactly match, and the "common" header is mandated by the exception handling ABI. */ ! struct _GNAT_Exception { struct _Unwind_Exception common; - _Unwind_Ptr id; - char handled_by_others; char has_cleanup; char select_cleanups; --- 188,197 ---- library (a-except.adb). The layouts should exactly match, and the "common" header is mandated by the exception handling ABI. */ ! struct _GNAT_Exception ! { struct _Unwind_Exception common; _Unwind_Ptr id; char handled_by_others; char has_cleanup; char select_cleanups; *************** static int db_specs = 0; *** 216,235 **** #define END_DB(what) } \ } while (0); ! /* The "action" stuff below if also there for debugging purposes only. */ ! typedef struct { _Unwind_Action action; char * description; ! } action_description_t; ! action_description_t action_descriptions [] = { ! { _UA_SEARCH_PHASE, "SEARCH_PHASE" }, ! { _UA_CLEANUP_PHASE, "CLEANUP_PHASE" }, ! { _UA_HANDLER_FRAME, "HANDLER_FRAME" }, ! { _UA_FORCE_UNWIND, "FORCE_UNWIND" }, ! { -1, (char *)0 } ! }; static void decode_actions (actions) --- 232,251 ---- #define END_DB(what) } \ } while (0); ! /* The "action" stuff below is also there for debugging purposes only. */ ! typedef struct ! { _Unwind_Action action; char * description; ! } action_description_t; ! static action_description_t action_descriptions[] ! = {{ _UA_SEARCH_PHASE, "SEARCH_PHASE" }, ! { _UA_CLEANUP_PHASE, "CLEANUP_PHASE" }, ! { _UA_HANDLER_FRAME, "HANDLER_FRAME" }, ! { _UA_FORCE_UNWIND, "FORCE_UNWIND" }, ! { -1, 0}}; static void decode_actions (actions) *************** decode_actions (actions) *** 237,272 **** { int i; ! action_description_t * a = action_descriptions; printf ("\n"); ! while (a->description != (char *)0) ! { ! if (actions & a->action) ! { ! printf ("%s ", a->description); ! } ! ! a ++; ! } printf (" : "); } ! /* The following is defined from a-except.adb. It's purpose is to enable automatic backtraces upon exception raise, as provided through the GNAT.Traceback facilities. */ ! extern void ! __gnat_notify_handled_exception (void * handler, bool others, bool db_notify); /* Below is the eh personality routine per se. */ _Unwind_Reason_Code ! __gnat_eh_personality (int version, ! _Unwind_Action actions, ! _Unwind_Exception_Class exception_class, ! struct _Unwind_Exception *ue_header, ! struct _Unwind_Context *context) { enum found_handler_type { --- 253,282 ---- { int i; ! action_description_t *a = action_descriptions; printf ("\n"); ! for (; a->description != 0; a++) ! if (actions & a->action) ! printf ("%s ", a->description); printf (" : "); } ! /* The following is defined from a-except.adb. Its purpose is to enable automatic backtraces upon exception raise, as provided through the GNAT.Traceback facilities. */ ! extern void __gnat_notify_handled_exception PARAMS ((void *, bool, bool)); /* Below is the eh personality routine per se. */ _Unwind_Reason_Code ! __gnat_eh_personality (version, actions, exception_class, ue_header, context) ! int version; ! _Unwind_Action actions; ! _Unwind_Exception_Class exception_class; ! struct _Unwind_Exception *ue_header; ! struct _Unwind_Context *context; { enum found_handler_type { *************** __gnat_eh_personality (int version, *** 275,291 **** found_cleanup, found_handler } found_type; - lsda_header_info info; const unsigned char *language_specific_data; const unsigned char *action_record; const unsigned char *p; _Unwind_Ptr landing_pad, ip; int handler_switch_value; - bool hit_others_handler; ! ! struct _GNAT_Exception * gnat_exception; if (version != 1) return _URC_FATAL_PHASE1_ERROR; --- 285,298 ---- found_cleanup, found_handler } found_type; lsda_header_info info; const unsigned char *language_specific_data; const unsigned char *action_record; const unsigned char *p; _Unwind_Ptr landing_pad, ip; int handler_switch_value; bool hit_others_handler; ! struct _GNAT_Exception *gnat_exception; if (version != 1) return _URC_FATAL_PHASE1_ERROR; *************** __gnat_eh_personality (int version, *** 293,301 **** START_DB (DB_PHASES); decode_actions (actions); END_DB (DB_PHASES); ! ! if (strcmp ( ((char *)&exception_class), "GNU") != 0 ! || strcmp ( ((char *)&exception_class)+4, "Ada") != 0) { START_DB (DB_SEARCH); printf (" Exception Class doesn't match for ip = %p\n", ip); --- 300,308 ---- START_DB (DB_PHASES); decode_actions (actions); END_DB (DB_PHASES); ! ! if (strcmp ((char *) &exception_class, "GNU") != 0 ! || strcmp (((char *) &exception_class) + 4, "Ada") != 0) { START_DB (DB_SEARCH); printf (" Exception Class doesn't match for ip = %p\n", ip); *************** __gnat_eh_personality (int version, *** 310,326 **** START_DB (DB_PHASES); if (gnat_exception->select_cleanups) ! { ! printf ("(select_cleanups) :\n"); ! } else ! { ! printf (" :\n"); ! } END_DB (DB_PHASES); ! language_specific_data = (const unsigned char *) ! _Unwind_GetLanguageSpecificData (context); /* If no LSDA, then there are no handlers or cleanups. */ if (! language_specific_data) --- 317,329 ---- START_DB (DB_PHASES); if (gnat_exception->select_cleanups) ! printf ("(select_cleanups) :\n"); else ! printf (" :\n"); END_DB (DB_PHASES); ! language_specific_data ! = (const unsigned char *) _Unwind_GetLanguageSpecificData (context); /* If no LSDA, then there are no handlers or cleanups. */ if (! language_specific_data) *************** __gnat_eh_personality (int version, *** 335,341 **** END_DB (DB_FOUND); return _URC_CONTINUE_UNWIND; } ! /* Parse the LSDA header. */ p = parse_lsda_header (context, language_specific_data, &info); info.ttype_base = base_of_encoded_value (info.ttype_encoding, context); --- 338,344 ---- END_DB (DB_FOUND); return _URC_CONTINUE_UNWIND; } ! /* Parse the LSDA header. */ p = parse_lsda_header (context, language_specific_data, &info); info.ttype_base = base_of_encoded_value (info.ttype_encoding, context); *************** __gnat_eh_personality (int version, *** 347,353 **** /* Search the call-site table for the action associated with this IP. */ while (p < info.action_table) { ! _Unwind_Ptr cs_start, cs_len, cs_lp, cs_action; /* Note that all call-site encodings are "absolute" displacements. */ p = read_encoded_value (0, info.call_site_encoding, p, &cs_start); --- 350,357 ---- /* Search the call-site table for the action associated with this IP. */ while (p < info.action_table) { ! _Unwind_Ptr cs_start, cs_len, cs_lp; ! _Unwind_Word cs_action; /* Note that all call-site encodings are "absolute" displacements. */ p = read_encoded_value (0, info.call_site_encoding, p, &cs_start); *************** __gnat_eh_personality (int version, *** 375,394 **** /* If ip is not present in the table, call terminate. This is for a destructor inside a cleanup, or a library routine the compiler was not expecting to throw. ! found_type = (actions & _UA_FORCE_UNWIND ? found_nothing : found_terminate); ! ??? Does this have a mapping in Ada semantics ? */ found_type = found_nothing; - goto do_something; found_something: found_type = found_nothing; ! if (landing_pad == 0) { /* If ip is present, and has a null landing pad, there are --- 379,397 ---- /* If ip is not present in the table, call terminate. This is for a destructor inside a cleanup, or a library routine the compiler was not expecting to throw. ! found_type = (actions & _UA_FORCE_UNWIND ? found_nothing : found_terminate); ! ??? Does this have a mapping in Ada semantics ? */ found_type = found_nothing; goto do_something; found_something: found_type = found_nothing; ! if (landing_pad == 0) { /* If ip is present, and has a null landing pad, there are *************** __gnat_eh_personality (int version, *** 406,412 **** else { signed long ar_filter, ar_disp; - signed long cleanup_filter = 0; signed long handler_filter = 0; --- 409,414 ---- *************** __gnat_eh_personality (int version, *** 423,429 **** while (1) { ! _Unwind_Ptr tmp; p = action_record; p = read_sleb128 (p, &tmp); ar_filter = tmp; --- 425,431 ---- while (1) { ! _Unwind_Word tmp; p = action_record; p = read_sleb128 (p, &tmp); ar_filter = tmp; *************** __gnat_eh_personality (int version, *** 445,464 **** else if (ar_filter > 0) { _Unwind_Ptr lp_id = get_ttype_entry (context, &info, ar_filter); ! START_DB (DB_MATCH); printf ("catch_type "); ! switch (lp_id) { case GNAT_ALL_OTHERS_ID: printf ("GNAT_ALL_OTHERS_ID\n"); break; ! case GNAT_OTHERS_ID: printf ("GNAT_OTHERS_ID\n"); break; ! default: printf ("%p\n", lp_id); break; --- 447,466 ---- else if (ar_filter > 0) { _Unwind_Ptr lp_id = get_ttype_entry (context, &info, ar_filter); ! START_DB (DB_MATCH); printf ("catch_type "); ! switch (lp_id) { case GNAT_ALL_OTHERS_ID: printf ("GNAT_ALL_OTHERS_ID\n"); break; ! case GNAT_OTHERS_ID: printf ("GNAT_OTHERS_ID\n"); break; ! default: printf ("%p\n", lp_id); break; *************** __gnat_eh_personality (int version, *** 476,483 **** gnat_exception->has_cleanup = true; } ! hit_others_handler = ! (lp_id == GNAT_OTHERS_ID && gnat_exception->handled_by_others); if (hit_others_handler || lp_id == gnat_exception->id) { --- 478,486 ---- gnat_exception->has_cleanup = true; } ! hit_others_handler ! = (lp_id == GNAT_OTHERS_ID ! && gnat_exception->handled_by_others); if (hit_others_handler || lp_id == gnat_exception->id) { *************** __gnat_eh_personality (int version, *** 489,498 **** } } else ! { ! /* Negative filter values are for C++ exception specifications. ! Should not be there for Ada :/ */ ! } if (actions & _UA_SEARCH_PHASE) { --- 492,500 ---- } } else ! /* Negative filter values are for C++ exception specifications. ! Should not be there for Ada :/ */ ! ; if (actions & _UA_SEARCH_PHASE) { *************** __gnat_eh_personality (int version, *** 504,512 **** } if (cleanup_filter) ! { ! found_type = found_cleanup; ! } } if (actions & _UA_CLEANUP_PHASE) --- 506,512 ---- } if (cleanup_filter) ! found_type = found_cleanup; } if (actions & _UA_CLEANUP_PHASE) *************** __gnat_eh_personality (int version, *** 517,523 **** handler_switch_value = handler_filter; break; } ! if (cleanup_filter) { found_type = found_cleanup; --- 517,523 ---- handler_switch_value = handler_filter; break; } ! if (cleanup_filter) { found_type = found_cleanup; *************** __gnat_eh_personality (int version, *** 528,547 **** if (ar_disp == 0) break; action_record = p + ar_disp; } } do_something: ! if (found_type == found_nothing) { ! START_DB (DB_FOUND); ! printf (" => FOUND nothing\n"); ! END_DB (DB_FOUND); ! return _URC_CONTINUE_UNWIND; ! } ! if (actions & _UA_SEARCH_PHASE) { START_DB (DB_FOUND); printf (" => Computing return for SEARCH\n"); --- 528,549 ---- if (ar_disp == 0) break; + action_record = p + ar_disp; } } do_something: ! if (found_type == found_nothing) ! { ! START_DB (DB_FOUND); ! printf (" => FOUND nothing\n"); ! END_DB (DB_FOUND); ! return _URC_CONTINUE_UNWIND; ! } ! if (actions & _UA_SEARCH_PHASE) { START_DB (DB_FOUND); printf (" => Computing return for SEARCH\n"); *************** __gnat_eh_personality (int version, *** 565,571 **** } install_context: ! START_DB (DB_INSTALL); printf (" => INSTALLING context for filter %d\n", handler_switch_value); --- 567,573 ---- } install_context: ! START_DB (DB_INSTALL); printf (" => INSTALLING context for filter %d\n", handler_switch_value); *************** __gnat_eh_personality (int version, *** 579,598 **** END_DB (DB_INSTALL); } ! /* Signal that we are going to enter a handler, which will typically enable the debugger to take control and possibly output an automatic backtrace. Note that we are supposed to provide the handler's entry ! point here but we don't have it. ! */ ! __gnat_notify_handled_exception ! ((void *)landing_pad, hit_others_handler, true); ! /* The GNU-Ada exception handlers know how to find the exception occurrence without having to pass it as an argument so there is no need to feed any specific register with this information. ! This is why the two following lines are commented out. */ /* _Unwind_SetGR (context, __builtin_eh_return_data_regno (0), --- 581,598 ---- END_DB (DB_INSTALL); } ! /* Signal that we are going to enter a handler, which will typically enable the debugger to take control and possibly output an automatic backtrace. Note that we are supposed to provide the handler's entry ! point here but we don't have it. */ ! __gnat_notify_handled_exception ((void *)landing_pad, hit_others_handler, ! true); /* The GNU-Ada exception handlers know how to find the exception occurrence without having to pass it as an argument so there is no need to feed any specific register with this information. ! This is why the two following lines are commented out. */ /* _Unwind_SetGR (context, __builtin_eh_return_data_regno (0), *************** __gnat_eh_personality (int version, *** 607,610 **** } ! #endif /* IN_RTS - For eh personality routine */ --- 607,652 ---- } ! /* Stubs for the libgcc unwinding interface, to be imported by a-except. */ ! ! #ifdef __USING_SJLJ_EXCEPTIONS__ ! ! _Unwind_Reason_Code ! __gnat_Unwind_RaiseException (e) ! struct _Unwind_Exception *e; ! { ! return _Unwind_SjLj_RaiseException (e); ! } ! ! #else ! /* __USING_SJLJ_EXCEPTIONS__ not defined */ ! ! _Unwind_Reason_Code ! __gnat_Unwind_RaiseException (e) ! struct _Unwind_Exception *e; ! { ! return _Unwind_RaiseException (e); ! } ! ! #endif ! ! #else ! /* IN_RTS not defined */ ! ! /* The calls to the GCC runtime interface for exception raising are currently ! issued from a-except.adb, which is used by both the runtime library and ! the compiler. As the compiler binary is not linked against the GCC runtime ! library, we need a stub for this interface in the compiler case. */ ! ! /* Since we don't link the compiler with a host libgcc, we should not be ! using the GCC eh mechanism for the compiler and so expect this function ! never to be called. */ ! ! _Unwind_Reason_Code ! __gnat_Unwind_RaiseException (e) ! struct _Unwind_Exception *e ATTRIBUTE_UNUSED; ! { ! abort (); ! } ! ! #endif diff -Nrc3pad gcc-3.2.3/gcc/ada/raise.h gcc-3.3/gcc/ada/raise.h *** gcc-3.2.3/gcc/ada/raise.h 2002-05-04 03:28:33.000000000 +0000 --- gcc-3.3/gcc/ada/raise.h 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001, Free Software Foundation, Inc. * * * --- 6,11 ---- *************** struct Exception_Occurrence *** 48,54 **** int Max_Length; Exception_Id Id; int Msg_Length; ! char Msg [0]; }; typedef struct Exception_Occurrence *Exception_Occurrence_Access; --- 47,53 ---- int Max_Length; Exception_Id Id; int Msg_Length; ! char Msg[0]; }; typedef struct Exception_Occurrence *Exception_Occurrence_Access; *************** extern void __gnat_free PARAMS ((void *** 60,71 **** extern void *__gnat_realloc PARAMS ((void *, __SIZE_TYPE__)); extern void __gnat_finalize PARAMS ((void)); extern void set_gnat_exit_status PARAMS ((int)); ! extern void __gnat_set_globals PARAMS ((int, int, int, int, int, int, ! void (*) PARAMS ((void)), ! int, int)); extern void __gnat_initialize PARAMS ((void)); extern void __gnat_init_float PARAMS ((void)); extern void __gnat_install_handler PARAMS ((void)); extern int gnat_exit_status; - --- 59,69 ---- extern void *__gnat_realloc PARAMS ((void *, __SIZE_TYPE__)); extern void __gnat_finalize PARAMS ((void)); extern void set_gnat_exit_status PARAMS ((int)); ! extern void __gnat_set_globals PARAMS ((int, int, ! char, char, char, char, ! char *, int, int, int)); extern void __gnat_initialize PARAMS ((void)); extern void __gnat_init_float PARAMS ((void)); extern void __gnat_install_handler PARAMS ((void)); extern int gnat_exit_status; diff -Nrc3pad gcc-3.2.3/gcc/ada/repinfo.adb gcc-3.3/gcc/ada/repinfo.adb *** gcc-3.2.3/gcc/ada/repinfo.adb 2002-05-04 03:28:33.000000000 +0000 --- gcc-3.3/gcc/ada/repinfo.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1999-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1999-2002 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- -- *************** package body Repinfo is *** 140,145 **** --- 139,152 ---- -- Returns True if Val represents a variable value, and False if it -- represents a value that is fixed at compile time. + procedure Write_Info_Line (S : String); + -- Routine to write a line to Repinfo output file. This routine is + -- passed as a special output procedure to Output.Set_Special_Output. + -- Note that Write_Info_Line is called with an EOL character at the + -- end of each line, as per the Output spec, but the internal call + -- to the appropriate routine in Osint requires that the end of line + -- sequence be stripped off. + procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False); -- Given a representation value, write it out. No_Uint values or values -- dependent on discriminants are written as two question marks. If the *************** package body Repinfo is *** 286,293 **** if Present (Ent) then E := First_Entity (Ent); while Present (E) loop - if Comes_From_Source (E) or else Debug_Flag_AA then if Is_Record_Type (E) then List_Record_Info (E); --- 293,306 ---- if Present (Ent) then E := First_Entity (Ent); while Present (E) loop + -- We list entities that come from source (excluding private + -- types, where we will list the info for the full view). If + -- debug flag A is set, all entities are listed + + if (Comes_From_Source (E) and then not Is_Private_Type (E)) + or else Debug_Flag_AA + then if Is_Record_Type (E) then List_Record_Info (E); *************** package body Repinfo is *** 295,301 **** List_Array_Info (E); elsif List_Representation_Info >= 2 then - if Is_Type (E) then List_Type_Info (E); --- 308,313 ---- *************** package body Repinfo is *** 311,325 **** end if; end if; ! -- Recurse over nested package, but not if they are -- package renamings (in particular renamings of the -- enclosing package, as for some Java bindings and -- for generic instances). ! if (Ekind (E) = E_Package ! and then No (Renamed_Object (E))) ! or else ! Ekind (E) = E_Protected_Type or else Ekind (E) = E_Task_Type or else --- 323,341 ---- end if; end if; ! -- Recurse into nested package, but not if they are -- package renamings (in particular renamings of the -- enclosing package, as for some Java bindings and -- for generic instances). ! if Ekind (E) = E_Package then ! if No (Renamed_Object (E)) then ! List_Entities (E); ! end if; ! ! -- Recurse into bodies ! ! elsif Ekind (E) = E_Protected_Type or else Ekind (E) = E_Task_Type or else *************** package body Repinfo is *** 332,337 **** --- 348,358 ---- Ekind (E) = E_Protected_Body then List_Entities (E); + + -- Recurse into blocks + + elsif Ekind (E) = E_Block then + List_Entities (E); end if; end if; *************** package body Repinfo is *** 477,483 **** begin if U = No_Uint then ! Write_Line ("??"); else P (U); end if; --- 498,504 ---- begin if U = No_Uint then ! Write_Str ("??"); else P (U); end if; *************** package body Repinfo is *** 507,527 **** begin Write_Eol; ! if Known_Esize (Ent) then ! Write_Str ("for "); ! List_Name (Ent); ! Write_Str ("'Size use "); ! Write_Val (Esize (Ent)); ! Write_Line (";"); ! end if; ! if Known_Alignment (Ent) then ! Write_Str ("for "); ! List_Name (Ent); ! Write_Str ("'Alignment use "); ! Write_Val (Alignment (Ent)); ! Write_Line (";"); ! end if; end List_Object_Info; ---------------------- --- 528,544 ---- begin Write_Eol; ! Write_Str ("for "); ! List_Name (Ent); ! Write_Str ("'Size use "); ! Write_Val (Esize (Ent)); ! Write_Line (";"); ! Write_Str ("for "); ! List_Name (Ent); ! Write_Str ("'Alignment use "); ! Write_Val (Alignment (Ent)); ! Write_Line (";"); end List_Object_Info; ---------------------- *************** package body Repinfo is *** 574,580 **** UI_Image (Sunit); end if; ! if Unknown_Normalized_First_Bit (Comp) then Set_Normalized_First_Bit (Comp, Uint_0); end if; --- 591,603 ---- UI_Image (Sunit); end if; ! -- If the record is not packed, then we know that all ! -- fields whose position is not specified have a starting ! -- normalized bit position of zero ! ! if Unknown_Normalized_First_Bit (Comp) ! and then not Is_Packed (Ent) ! then Set_Normalized_First_Bit (Comp, Uint_0); end if; *************** package body Repinfo is *** 620,627 **** and then List_Representation_Info = 3 then Spaces (Max_Suni_Length - 2); Write_Val (Bofs, Paren => True); ! Write_Str (" / 8"); elsif Known_Normalized_Position (Comp) and then List_Representation_Info = 3 --- 643,654 ---- and then List_Representation_Info = 3 then Spaces (Max_Suni_Length - 2); + Write_Str ("bit offset"); Write_Val (Bofs, Paren => True); ! Write_Str (" size in bits = "); ! Write_Val (Esiz, Paren => True); ! Write_Eol; ! goto Continue; elsif Known_Normalized_Position (Comp) and then List_Representation_Info = 3 *************** package body Repinfo is *** 630,643 **** Write_Val (Npos); else ! Write_Str ("??"); end if; Write_Str (" range "); UI_Write (Fbit); Write_Str (" .. "); ! if not Is_Dynamic_SO_Ref (Esize (Comp)) then Lbit := Fbit + Esiz - 1; if Lbit < 10 then --- 657,689 ---- Write_Val (Npos); else ! -- For the packed case, we don't know the bit positions ! -- if we don't know the starting position! ! ! if Is_Packed (Ent) then ! Write_Line ("?? range ? .. ??;"); ! goto Continue; ! ! -- Otherwise we can continue ! ! else ! Write_Str ("??"); ! end if; end if; Write_Str (" range "); UI_Write (Fbit); Write_Str (" .. "); ! -- Allowing Uint_0 here is a kludge, really this should be ! -- a fine Esize value but currently it means unknown, except ! -- that we know after gigi has back annotated that a size of ! -- zero is real, since otherwise gigi back annotates using ! -- No_Uint as the value to indicate unknown). ! ! if (Esize (Comp) = Uint_0 or else Known_Static_Esize (Comp)) ! and then Known_Static_Normalized_First_Bit (Comp) ! then Lbit := Fbit + Esiz - 1; if Lbit < 10 then *************** package body Repinfo is *** 646,655 **** UI_Write (Lbit); ! elsif List_Representation_Info < 3 then Write_Str ("??"); ! else -- List_Representation >= 3 Write_Val (Esiz, Paren => True); --- 692,708 ---- UI_Write (Lbit); ! -- The test for Esize (Comp) not being Uint_0 here is a kludge. ! -- Officially a value of zero for Esize means unknown, but here ! -- we use the fact that we know that gigi annotates Esize with ! -- No_Uint, not Uint_0. Really everyone should use No_Uint??? ! ! elsif List_Representation_Info < 3 ! or else (Esize (Comp) /= Uint_0 and then Unknown_Esize (Comp)) ! then Write_Str ("??"); ! else -- List_Representation >= 3 and Known_Esize (Comp) Write_Val (Esiz, Paren => True); *************** package body Repinfo is *** 679,684 **** --- 732,738 ---- end; end if; + <> Comp := Next_Entity (Comp); end loop; *************** package body Repinfo is *** 695,717 **** begin for U in Main_Unit .. Last_Unit loop if In_Extended_Main_Source_Unit (Cunit_Entity (U)) then - Unit_Casing := Identifier_Casing (Source_Index (U)); - Write_Eol; - Write_Str ("Representation information for unit "); - Write_Unit_Name (Unit_Name (U)); - Col := Column; - Write_Eol; ! for J in 1 .. Col - 1 loop ! Write_Char ('-'); ! end loop; ! Write_Eol; ! List_Entities (Cunit_Entity (U)); end if; end loop; end List_Rep_Info; -------------------- -- List_Type_Info -- -------------------- --- 749,794 ---- begin for U in Main_Unit .. Last_Unit loop if In_Extended_Main_Source_Unit (Cunit_Entity (U)) then ! -- Normal case, list to standard output ! if not List_Representation_Info_To_File then ! Unit_Casing := Identifier_Casing (Source_Index (U)); ! Write_Eol; ! Write_Str ("Representation information for unit "); ! Write_Unit_Name (Unit_Name (U)); ! Col := Column; ! Write_Eol; ! ! for J in 1 .. Col - 1 loop ! Write_Char ('-'); ! end loop; ! ! Write_Eol; ! List_Entities (Cunit_Entity (U)); ! ! -- List representation information to file ! ! else ! Creat_Repinfo_File_Access.all (File_Name (Source_Index (U))); ! Set_Special_Output (Write_Info_Line'Access); ! List_Entities (Cunit_Entity (U)); ! Set_Special_Output (null); ! Close_Repinfo_File_Access.all; ! end if; end if; end loop; end List_Rep_Info; + --------------------- + -- Write_Info_Line -- + --------------------- + + procedure Write_Info_Line (S : String) is + begin + Write_Repinfo_Line_Access.all (S (S'First .. S'Last - 1)); + end Write_Info_Line; + -------------------- -- List_Type_Info -- -------------------- *************** package body Repinfo is *** 720,765 **** begin Write_Eol; ! -- If Esize and RM_Size are the same and known, list as Size. This ! -- is a common case, which we may as well list in simple form. ! if Esize (Ent) = RM_Size (Ent) then ! if Known_Esize (Ent) then Write_Str ("for "); List_Name (Ent); Write_Str ("'Size use "); Write_Val (Esize (Ent)); Write_Line (";"); - end if; ! -- For now, temporary case, to be removed when gigi properly back ! -- annotates RM_Size, if RM_Size is not set, then list Esize as ! -- Size. This avoids odd Object_Size output till we fix things??? ! elsif Unknown_RM_Size (Ent) then ! if Known_Esize (Ent) then Write_Str ("for "); List_Name (Ent); Write_Str ("'Size use "); Write_Val (Esize (Ent)); Write_Line (";"); - end if; ! -- Otherwise list size values separately if they are set ! else ! if Known_Esize (Ent) then Write_Str ("for "); List_Name (Ent); Write_Str ("'Object_Size use "); Write_Val (Esize (Ent)); Write_Line (";"); - end if; ! -- Note on following check: The RM_Size of a discrete type can ! -- legitimately be set to zero, so a special check is needed. - if Known_RM_Size (Ent) or else Is_Discrete_Type (Ent) then Write_Str ("for "); List_Name (Ent); Write_Str ("'Value_Size use "); --- 797,841 ---- begin Write_Eol; ! -- Do not list size info for unconstrained arrays, not meaningful ! if Is_Array_Type (Ent) and then not Is_Constrained (Ent) then ! null; ! ! else ! -- If Esize and RM_Size are the same and known, list as Size. This ! -- is a common case, which we may as well list in simple form. ! ! if Esize (Ent) = RM_Size (Ent) then Write_Str ("for "); List_Name (Ent); Write_Str ("'Size use "); Write_Val (Esize (Ent)); Write_Line (";"); ! -- For now, temporary case, to be removed when gigi properly back ! -- annotates RM_Size, if RM_Size is not set, then list Esize as ! -- Size. This avoids odd Object_Size output till we fix things??? ! elsif Unknown_RM_Size (Ent) then Write_Str ("for "); List_Name (Ent); Write_Str ("'Size use "); Write_Val (Esize (Ent)); Write_Line (";"); ! -- Otherwise list size values separately if they are set ! else Write_Str ("for "); List_Name (Ent); Write_Str ("'Object_Size use "); Write_Val (Esize (Ent)); Write_Line (";"); ! -- Note on following check: The RM_Size of a discrete type can ! -- legitimately be set to zero, so a special check is needed. Write_Str ("for "); List_Name (Ent); Write_Str ("'Value_Size use "); *************** package body Repinfo is *** 768,780 **** end if; end if; ! if Known_Alignment (Ent) then ! Write_Str ("for "); ! List_Name (Ent); ! Write_Str ("'Alignment use "); ! Write_Val (Alignment (Ent)); ! Write_Line (";"); ! end if; end List_Type_Info; ---------------------- --- 844,854 ---- end if; end if; ! Write_Str ("for "); ! List_Name (Ent); ! Write_Str ("'Alignment use "); ! Write_Val (Alignment (Ent)); ! Write_Line (";"); end List_Type_Info; ---------------------- *************** package body Repinfo is *** 1004,1018 **** procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False) is begin if Rep_Not_Constant (Val) then ! if List_Representation_Info < 3 then Write_Str ("??"); else if Back_End_Layout then Write_Char (' '); ! List_GCC_Expression (Val); Write_Char (' '); else ! Write_Name_Decoded (Chars (Get_Dynamic_SO_Entity (Val))); end if; end if; --- 1078,1108 ---- procedure Write_Val (Val : Node_Ref_Or_Val; Paren : Boolean := False) is begin if Rep_Not_Constant (Val) then ! if List_Representation_Info < 3 or else Val = No_Uint then Write_Str ("??"); + else if Back_End_Layout then Write_Char (' '); ! ! if Paren then ! Write_Char ('('); ! List_GCC_Expression (Val); ! Write_Char (')'); ! else ! List_GCC_Expression (Val); ! end if; ! Write_Char (' '); + else ! if Paren then ! Write_Char ('('); ! Write_Name_Decoded (Chars (Get_Dynamic_SO_Entity (Val))); ! Write_Char (')'); ! else ! Write_Name_Decoded (Chars (Get_Dynamic_SO_Entity (Val))); ! end if; end if; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/repinfo.ads gcc-3.3/gcc/ada/repinfo.ads *** gcc-3.2.3/gcc/ada/repinfo.ads 2002-05-04 03:28:33.000000000 +0000 --- gcc-3.3/gcc/ada/repinfo.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/repinfo.h gcc-3.3/gcc/ada/repinfo.h *** gcc-3.2.3/gcc/ada/repinfo.h 2002-05-04 03:28:34.000000000 +0000 --- gcc-3.3/gcc/ada/repinfo.h 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1999-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/restrict.adb gcc-3.3/gcc/ada/restrict.adb *** gcc-3.2.3/gcc/ada/restrict.adb 2002-05-04 03:28:34.000000000 +0000 --- gcc-3.3/gcc/ada/restrict.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.12.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Fname; use Fname; *** 34,43 **** with Fname.UF; use Fname.UF; with Lib; use Lib; with Namet; use Namet; - with Nmake; use Nmake; with Opt; use Opt; with Stand; use Stand; with Targparm; use Targparm; with Uname; use Uname; package body Restrict is --- 33,42 ---- with Fname.UF; use Fname.UF; with Lib; use Lib; with Namet; use Namet; with Opt; use Opt; with Stand; use Stand; with Targparm; use Targparm; + with Tbuild; use Tbuild; with Uname; use Uname; package body Restrict is *************** package body Restrict is *** 125,131 **** Error_Msg_Unit_1 := U; Error_Msg_N ! ("dependence on $ not allowed,", N); Name_Buffer (1 .. S'Last) := S; Name_Len := S'Length; --- 124,130 ---- Error_Msg_Unit_1 := U; Error_Msg_N ! ("|dependence on $ not allowed,", N); Name_Buffer (1 .. S'Last) := S; Name_Len := S'Length; *************** package body Restrict is *** 134,140 **** Error_Msg_Sloc := Restrictions_Loc (R_Id); Error_Msg_N ! ("\violates pragma Restriction (%) #", N); return; end; end if; --- 133,139 ---- Error_Msg_Sloc := Restrictions_Loc (R_Id); Error_Msg_N ! ("\|violates pragma Restriction (%) #", N); return; end; end if; *************** package body Restrict is *** 167,173 **** Set_Casing (All_Lower_Case); Error_Msg_Name_1 := Name_Enter; Error_Msg_Sloc := Restrictions_Loc (R); ! Error_Msg_N ("violation of restriction %#", N); end; end if; end Check_Restriction; --- 166,172 ---- Set_Casing (All_Lower_Case); Error_Msg_Name_1 := Name_Enter; Error_Msg_Sloc := Restrictions_Loc (R); ! Error_Msg_N ("|violation of restriction %#", N); end; end if; end Check_Restriction; *************** package body Restrict is *** 198,204 **** Error_Msg_N ("violation of restriction %?#!", N); Insert_Action (N, ! Make_Raise_Storage_Error (Loc)); end; end if; end Check_Restriction; --- 197,204 ---- Error_Msg_N ("violation of restriction %?#!", N); Insert_Action (N, ! Make_Raise_Storage_Error (Loc, ! Reason => SE_Restriction_Violation)); end; end if; end Check_Restriction; *************** package body Restrict is *** 224,230 **** Set_Casing (All_Lower_Case); Error_Msg_Name_1 := Name_Enter; Error_Msg_Sloc := Restriction_Parameters_Loc (R); ! Error_Msg_N ("maximum value exceeded for restriction %#", N); end; end if; end Check_Restriction; --- 224,230 ---- Set_Casing (All_Lower_Case); Error_Msg_Name_1 := Name_Enter; Error_Msg_Sloc := Restriction_Parameters_Loc (R); ! Error_Msg_N ("|maximum value exceeded for restriction %#", N); end; end if; end Check_Restriction; *************** package body Restrict is *** 269,278 **** if No_Run_Time then if High_Integrity_Mode_On_Target then Error_Msg_N ! ("this construct not allowed in high integrity mode", Enode); else Error_Msg_N ! ("this construct not allowed in No_Run_Time mode", Enode); end if; end if; end Disallow_In_No_Run_Time_Mode; --- 269,278 ---- if No_Run_Time then if High_Integrity_Mode_On_Target then Error_Msg_N ! ("|this construct not allowed in high integrity mode", Enode); else Error_Msg_N ! ("|this construct not allowed in No_Run_Time mode", Enode); end if; end if; end Disallow_In_No_Run_Time_Mode; *************** package body Restrict is *** 378,383 **** --- 378,384 ---- begin No_Run_Time := True; Restrictions (No_Exception_Handlers) := True; + Restrictions (No_Implicit_Dynamic_Code) := True; Opt.Global_Discard_Names := True; end Set_No_Run_Time_Mode; *************** package body Restrict is *** 434,440 **** function Suppress_Restriction_Message (N : Node_Id) return Boolean is begin ! -- If main unit is library unit, then we will output message if In_Extended_Main_Source_Unit (N) then return False; --- 435,441 ---- function Suppress_Restriction_Message (N : Node_Id) return Boolean is begin ! -- We only output messages for the extended main source unit if In_Extended_Main_Source_Unit (N) then return False; *************** package body Restrict is *** 447,454 **** -- Otherwise suppress message if internal file else ! return ! Is_Internal_File_Name (Unit_File_Name (Get_Source_Unit (N))); end if; end Suppress_Restriction_Message; --- 448,454 ---- -- Otherwise suppress message if internal file else ! return Is_Internal_File_Name (Unit_File_Name (Get_Source_Unit (N))); end if; end Suppress_Restriction_Message; *************** package body Restrict is *** 458,465 **** function Tasking_Allowed return Boolean is begin ! return ! Restriction_Parameters (Max_Tasks) /= 0; end Tasking_Allowed; end Restrict; --- 458,464 ---- function Tasking_Allowed return Boolean is begin ! return Restriction_Parameters (Max_Tasks) /= 0; end Tasking_Allowed; end Restrict; diff -Nrc3pad gcc-3.2.3/gcc/ada/restrict.ads gcc-3.3/gcc/ada/restrict.ads *** gcc-3.2.3/gcc/ada/restrict.ads 2002-05-04 03:28:34.000000000 +0000 --- gcc-3.3/gcc/ada/restrict.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Restrict is *** 37,44 **** type Restriction_Id is new Rident.Restriction_Id; -- The type Restriction_Id defines the set of restriction identifiers, -- which take no parameter (i.e. they are either present or not present). ! -- The actual definition is in the separate package Rident, so that it ! -- can easily be accessed by the binder without dragging in lots of stuff. subtype Partition_Restrictions is Restriction_Id range --- 36,50 ---- type Restriction_Id is new Rident.Restriction_Id; -- The type Restriction_Id defines the set of restriction identifiers, -- which take no parameter (i.e. they are either present or not present). ! -- The actual definition is in the separate package Rident, so that ! -- it can easily be accessed by the binder without dragging in lots of ! -- stuff. ! ! subtype All_Restrictions is ! Restriction_Id range ! Restriction_Id (Rident.All_Restrictions'First) .. ! Restriction_Id (Rident.All_Restrictions'Last); ! -- All restriction identifiers subtype Partition_Restrictions is Restriction_Id range *************** package Restrict is *** 69,75 **** -- be consistent at link time, and we might as well find the error -- at compile time. Clients must NOT use this array for checking to -- see if a restriction is violated, instead it is required that the ! -- Check_Restrictions subprograms be used for this purpose. The only -- legitimate direct use of this array is when the code is modified -- as a result of the restriction in some way. --- 75,81 ---- -- be consistent at link time, and we might as well find the error -- at compile time. Clients must NOT use this array for checking to -- see if a restriction is violated, instead it is required that the ! -- Check_Restriction subprograms be used for this purpose. The only -- legitimate direct use of this array is when the code is modified -- as a result of the restriction in some way. *************** package Restrict is *** 140,145 **** --- 146,185 ---- -- Type used for saving and restoring compilation unit restrictions. -- See Compilation_Unit_Restrictions_[Save|Restore] subprograms. + -- The following map has True for all GNAT pragmas. It is used to + -- implement pragma Restrictions (No_Implementation_Restrictions) + -- (which is why this restriction itself is excluded from the list). + + Implementation_Restriction : Restrictions_Flags := + (Boolean_Entry_Barriers => True, + No_Calendar => True, + No_Dynamic_Interrupts => True, + No_Enumeration_Maps => True, + No_Entry_Calls_In_Elaboration_Code => True, + No_Entry_Queue => True, + No_Exception_Handlers => True, + No_Implicit_Conditionals => True, + No_Implicit_Dynamic_Code => True, + No_Implicit_Loops => True, + No_Local_Protected_Objects => True, + No_Protected_Type_Allocators => True, + No_Relative_Delay => True, + No_Requeue => True, + No_Secondary_Stack => True, + No_Select_Statements => True, + No_Standard_Storage_Pools => True, + No_Streams => True, + No_Task_Attributes => True, + No_Task_Termination => True, + No_Tasking => True, + No_Wide_Characters => True, + Static_Priorities => True, + Static_Storage_Size => True, + No_Implementation_Attributes => True, + No_Implementation_Pragmas => True, + No_Elaboration_Code => True, + others => False); + ----------------- -- Subprograms -- ----------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/rident.ads gcc-3.3/gcc/ada/rident.ads *** gcc-3.2.3/gcc/ada/rident.ads 2002-05-04 03:28:34.000000000 +0000 --- gcc-3.3/gcc/ada/rident.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Rident is *** 36,42 **** -- identifiers not taking a parameter that are implemented in GNAT. -- To add a new restriction identifier, add an entry with the name -- to be used in the pragma, and add appropriate calls to the ! -- Check_Restriction routine. type Restriction_Id is ( --- 35,41 ---- -- identifiers not taking a parameter that are implemented in GNAT. -- To add a new restriction identifier, add an entry with the name -- to be used in the pragma, and add appropriate calls to the ! -- Restrict.Check_Restriction routine. type Restriction_Id is ( *************** package Rident is *** 46,52 **** No_Abort_Statements, -- (RM D.7(5), H.4(3)) No_Access_Subprograms, -- (RM H.4(17)) No_Allocators, -- (RM H.4(7)) ! No_Asynchronous_Control, -- (RM D.9(10)) No_Calendar, -- GNAT No_Delay, -- (RM H.4(21)) No_Dispatch, -- (RM H.4(19)) --- 45,51 ---- No_Abort_Statements, -- (RM D.7(5), H.4(3)) No_Access_Subprograms, -- (RM H.4(17)) No_Allocators, -- (RM H.4(7)) ! No_Asynchronous_Control, -- (RM D.7(10)) No_Calendar, -- GNAT No_Delay, -- (RM H.4(21)) No_Dispatch, -- (RM H.4(19)) *************** package Rident is *** 81,86 **** --- 80,86 ---- No_Task_Attributes, -- GNAT No_Task_Hierarchy, -- (RM D.7(3), H.4(3)) No_Task_Termination, -- GNAT + No_Tasking, -- GNAT No_Terminate_Alternatives, -- (RM D.7(6)) No_Unchecked_Access, -- (RM H.4(18)) No_Unchecked_Conversion, -- (RM H.4(16)) *************** package Rident is *** 99,104 **** --- 99,108 ---- Not_A_Restriction_Id); + subtype All_Restrictions is + Restriction_Id range Boolean_Entry_Barriers .. No_Elaboration_Code; + -- All restrictions except Not_A_Restriction_Id + -- The following range of Restriction identifiers is checked for -- consistency across a partition. The generated ali file is marked -- for each entry to show one of three possibilities: *************** package Rident is *** 111,118 **** Restriction_Id range Boolean_Entry_Barriers .. Static_Storage_Size; -- The following set of Restriction identifiers is not checked for ! -- consistency across a partition, and the generated ali files does ! -- not carry any indications with respect to such restrictions. subtype Compilation_Unit_Restrictions is Restriction_Id range Immediate_Reclamation .. No_Elaboration_Code; --- 115,123 ---- Restriction_Id range Boolean_Entry_Barriers .. Static_Storage_Size; -- The following set of Restriction identifiers is not checked for ! -- consistency across a partition. The generated ali file still ! -- contains indications of the above three possibilities for the ! -- purposes of listing applicable restrictions. subtype Compilation_Unit_Restrictions is Restriction_Id range Immediate_Reclamation .. No_Elaboration_Code; *************** package Rident is *** 121,127 **** -- parameter identifiers taking a parameter that are implemented in -- GNAT. To add a new restriction parameter identifier, add an entry -- with the name to be used in the pragma, and add appropriate ! -- calls to Check_Restriction. -- Note: the GNAT implementation currently only accomodates restriction -- parameter identifiers whose expression value is a non-negative --- 126,132 ---- -- parameter identifiers taking a parameter that are implemented in -- GNAT. To add a new restriction parameter identifier, add an entry -- with the name to be used in the pragma, and add appropriate ! -- calls to Restrict.Check_Restriction. -- Note: the GNAT implementation currently only accomodates restriction -- parameter identifiers whose expression value is a non-negative diff -Nrc3pad gcc-3.2.3/gcc/ada/rtsfind.adb gcc-3.3/gcc/ada/rtsfind.adb *** gcc-3.2.3/gcc/ada/rtsfind.adb 2002-05-04 03:28:34.000000000 +0000 --- gcc-3.3/gcc/ada/rtsfind.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Rtsfind is *** 577,589 **** U_Id : constant RTU_Id := RE_Unit_Table (E); U : RT_Unit_Table_Record renames RT_Unit_Table (U_Id); - Ent : Entity_Id; Lib_Unit : Node_Id; Pkg_Ent : Entity_Id; Ename : Name_Id; Ravenscar : constant Boolean := Restricted_Profile; procedure Check_RPC; -- Reject programs that make use of distribution features not supported -- on the current target. On such targets (VMS, Vxworks, others?) we --- 576,598 ---- U_Id : constant RTU_Id := RE_Unit_Table (E); U : RT_Unit_Table_Record renames RT_Unit_Table (U_Id); Lib_Unit : Node_Id; Pkg_Ent : Entity_Id; Ename : Name_Id; Ravenscar : constant Boolean := Restricted_Profile; + -- The following flag is used to disable front-end inlining when RTE + -- is invoked. This prevents the analysis of other runtime bodies when + -- a particular spec is loaded through Rtsfind. This is both efficient, + -- and it prevents spurious visibility conflicts between use-visible + -- user entities, and entities in run-time packages. + + -- In No_Run_Time mode, subprograms marked Inlined_Always must be + -- inlined, so in the case we retain the Front_End_Inlining mode. + + Save_Front_End_Inlining : Boolean; + procedure Check_RPC; -- Reject programs that make use of distribution features not supported -- on the current target. On such targets (VMS, Vxworks, others?) we *************** package body Rtsfind is *** 714,719 **** --- 723,729 ---- -- Start of processing for RTE begin + -- Check violation of no run time and ravenscar mode if No_Run_Time *************** package body Rtsfind is *** 745,750 **** --- 755,763 ---- return Find_Local_Entity (E); end if; + Save_Front_End_Inlining := Front_End_Inlining; + Front_End_Inlining := No_Run_Time; + -- Load unit if unit not previously loaded if No (RE_Table (E)) then *************** package body Rtsfind is *** 790,795 **** --- 803,809 ---- if No_Run_Time and then not OK_To_Use_In_No_Run_Time_Mode (U_Id) then + Front_End_Inlining := Save_Front_End_Inlining; return Empty; else *************** package body Rtsfind is *** 832,860 **** end; end if; ! -- We can now obtain the entity. Check that the no run time condition ! -- is not violated. Note that we do not signal the error if we detect ! -- it in a runtime unit. This can only arise if the user explicitly ! -- with'ed the runtime unit (or another runtime unit that uses it ! -- transitively), or if some acceptable (e.g. inlined) entity is ! -- fetched from a unit, some of whose other routines or entities ! -- violate the conditions. In the latter case, it does not matter, ! -- since we won't be using those entities. ! ! Ent := RE_Table (E); ! ! if Is_Subprogram (Ent) ! and then not Is_Inlined (Ent) ! and then Sloc (Current_Error_Node) /= Standard_Location ! and then not ! Is_Predefined_File_Name ! (Unit_File_Name (Get_Source_Unit (Current_Error_Node))) ! and then not Ravenscar ! then ! Disallow_In_No_Run_Time_Mode (Current_Error_Node); ! end if; ! ! return Ent; end RTE; -------------------- --- 846,853 ---- end; end if; ! Front_End_Inlining := Save_Front_End_Inlining; ! return RE_Table (E); end RTE; -------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/rtsfind.ads gcc-3.3/gcc/ada/rtsfind.ads *** gcc-3.2.3/gcc/ada/rtsfind.ads 2002-05-04 03:28:34.000000000 +0000 --- gcc-3.3/gcc/ada/rtsfind.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Rtsfind is *** 158,164 **** System_Checked_Pools, System_Exception_Table, System_Exceptions, - System_Delay_Operations, System_Exn_Flt, System_Exn_Int, System_Exn_LFlt, --- 157,162 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-addima.adb gcc-3.3/gcc/ada/s-addima.adb *** gcc-3.2.3/gcc/ada/s-addima.adb 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-addima.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-addima.ads gcc-3.3/gcc/ada/s-addima.ads *** gcc-3.2.3/gcc/ada/s-addima.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-addima.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-arit64.adb gcc-3.3/gcc/ada/s-arit64.adb *** gcc-3.2.3/gcc/ada/s-arit64.adb 2002-05-04 03:28:36.000000000 +0000 --- gcc-3.3/gcc/ada/s-arit64.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body System.Arith_64 is *** 63,71 **** -- Length doubling subtraction function "*" (A, B : Uns32) return Uns64; - function "*" (A : Uns64; B : Uns32) return Uns64; pragma Inline ("*"); ! -- Length doubling multiplications function "/" (A : Uns64; B : Uns32) return Uns64; pragma Inline ("/"); --- 62,69 ---- -- Length doubling subtraction function "*" (A, B : Uns32) return Uns64; pragma Inline ("*"); ! -- Length doubling multiplication function "/" (A : Uns64; B : Uns32) return Uns64; pragma Inline ("/"); *************** package body System.Arith_64 is *** 120,130 **** return Uns64 (A) * Uns64 (B); end "*"; - function "*" (A : Uns64; B : Uns32) return Uns64 is - begin - return A * Uns64 (B); - end "*"; - --------- -- "+" -- --------- --- 118,123 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-arit64.ads gcc-3.3/gcc/ada/s-arit64.ads *** gcc-3.2.3/gcc/ada/s-arit64.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-arit64.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-assert.adb gcc-3.3/gcc/ada/s-assert.adb *** gcc-3.2.3/gcc/ada/s-assert.adb 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-assert.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-assert.ads gcc-3.3/gcc/ada/s-assert.ads *** gcc-3.2.3/gcc/ada/s-assert.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-assert.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-asthan.adb gcc-3.3/gcc/ada/s-asthan.adb *** gcc-3.2.3/gcc/ada/s-asthan.adb 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-asthan.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1996-1998 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1996-2001 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- -- *************** with System.Aux_DEC; *** 41,46 **** --- 40,47 ---- package body System.AST_Handling is + pragma Warnings (Off); -- kill warnings on unreferenced formals + ------------------------ -- Create_AST_Handler -- ------------------------ diff -Nrc3pad gcc-3.2.3/gcc/ada/s-asthan.ads gcc-3.3/gcc/ada/s-asthan.ads *** gcc-3.2.3/gcc/ada/s-asthan.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-asthan.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-atacco.adb gcc-3.3/gcc/ada/s-atacco.adb *** gcc-3.2.3/gcc/ada/s-atacco.adb 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-atacco.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992,1993,1994 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-atacco.ads gcc-3.3/gcc/ada/s-atacco.ads *** gcc-3.2.3/gcc/ada/s-atacco.ads 2001-10-26 01:41:17.000000000 +0000 --- gcc-3.3/gcc/ada/s-atacco.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 2001 Ada Core Technologies, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** *** 33,39 **** -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- ! -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 32,38 ---- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- ! -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ diff -Nrc3pad gcc-3.2.3/gcc/ada/s-auxdec.adb gcc-3.3/gcc/ada/s-auxdec.adb *** gcc-3.2.3/gcc/ada/s-auxdec.adb 2002-05-04 03:28:36.000000000 +0000 --- gcc-3.3/gcc/ada/s-auxdec.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body System.Aux_DEC is *** 326,331 **** --- 325,332 ---- Retry_Count : in Natural; Success_Flag : out Boolean) is + pragma Warnings (Off, Retry_Count); + begin SSL.Lock_Task.all; Old_Value := Bit; *************** package body System.Aux_DEC is *** 355,360 **** --- 356,363 ---- Retry_Count : in Natural; Success_Flag : out Boolean) is + pragma Warnings (Off, Retry_Count); + begin SSL.Lock_Task.all; Old_Value := Bit; *************** package body System.Aux_DEC is *** 408,413 **** --- 411,418 ---- Old_Value : out Integer; Success_Flag : out Boolean) is + pragma Warnings (Off, Retry_Count); + begin SSL.Lock_Task.all; Old_Value := To.Value; *************** package body System.Aux_DEC is *** 433,438 **** --- 438,445 ---- Old_Value : out Long_Integer; Success_Flag : out Boolean) is + pragma Warnings (Off, Retry_Count); + begin SSL.Lock_Task.all; Old_Value := To.Value; *************** package body System.Aux_DEC is *** 471,476 **** --- 478,485 ---- Old_Value : out Integer; Success_Flag : out Boolean) is + pragma Warnings (Off, Retry_Count); + begin SSL.Lock_Task.all; Old_Value := To.Value; *************** package body System.Aux_DEC is *** 496,501 **** --- 505,512 ---- Old_Value : out Long_Integer; Success_Flag : out Boolean) is + pragma Warnings (Off, Retry_Count); + begin SSL.Lock_Task.all; Old_Value := To.Value; *************** package body System.Aux_DEC is *** 525,530 **** --- 536,543 ---- Old_Value : out Integer; Success_Flag : out Boolean) is + pragma Warnings (Off, Retry_Count); + begin SSL.Lock_Task.all; Old_Value := To.Value; *************** package body System.Aux_DEC is *** 550,555 **** --- 563,570 ---- Old_Value : out Long_Integer; Success_Flag : out Boolean) is + pragma Warnings (Off, Retry_Count); + begin SSL.Lock_Task.all; Old_Value := To.Value; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-auxdec.ads gcc-3.3/gcc/ada/s-auxdec.ads *** gcc-3.2.3/gcc/ada/s-auxdec.ads 2002-05-04 03:28:36.000000000 +0000 --- gcc-3.3/gcc/ada/s-auxdec.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-bitops.adb gcc-3.3/gcc/ada/s-bitops.adb *** gcc-3.2.3/gcc/ada/s-bitops.adb 2002-05-04 03:28:36.000000000 +0000 --- gcc-3.3/gcc/ada/s-bitops.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1996-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-bitops.ads gcc-3.3/gcc/ada/s-bitops.ads *** gcc-3.2.3/gcc/ada/s-bitops.ads 2002-05-04 03:28:37.000000000 +0000 --- gcc-3.3/gcc/ada/s-bitops.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/scans.adb gcc-3.3/gcc/ada/scans.adb *** gcc-3.2.3/gcc/ada/scans.adb 2002-05-04 03:28:52.000000000 +0000 --- gcc-3.3/gcc/ada/scans.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/scans.ads gcc-3.3/gcc/ada/scans.ads *** gcc-3.2.3/gcc/ada/scans.ads 2002-05-04 03:28:52.000000000 +0000 --- gcc-3.3/gcc/ada/scans.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.4.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-chepoo.ads gcc-3.3/gcc/ada/s-chepoo.ads *** gcc-3.2.3/gcc/ada/s-chepoo.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-chepoo.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/scn.adb gcc-3.3/gcc/ada/scn.adb *** gcc-3.2.3/gcc/ada/scn.adb 2002-05-04 03:28:53.000000000 +0000 --- gcc-3.3/gcc/ada/scn.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Scn is *** 1061,1067 **** -- Special check for || to give nice message if Source (Scan_Ptr + 1) = '|' then ! Error_Msg_S ("""||"" should be `OR ELSE`"); Scan_Ptr := Scan_Ptr + 2; Token := Tok_Or; return; --- 1060,1066 ---- -- Special check for || to give nice message if Source (Scan_Ptr + 1) = '|' then ! Error_Msg_S ("""'|'|"" should be `OR ELSE`"); Scan_Ptr := Scan_Ptr + 2; Token := Tok_Or; return; *************** package body Scn is *** 1163,1170 **** else -- Upper half characters may possibly be identifier letters ! -- but can never be digits, so Identifier_Character can be ! -- used to test for a valid start of identifier character. if Identifier_Char (Source (Scan_Ptr)) then Name_Len := 0; --- 1162,1169 ---- else -- Upper half characters may possibly be identifier letters ! -- but can never be digits, so Identifier_Char can be used ! -- to test for a valid start of identifier character. if Identifier_Char (Source (Scan_Ptr)) then Name_Len := 0; *************** package body Scn is *** 1357,1386 **** Sptr : constant Source_Ptr := Scan_Ptr; Code : Char_Code; Err : Boolean; begin Scan_Wide (Source, Scan_Ptr, Code, Err); ! Accumulate_Checksum (Code); if Err then Error_Illegal_Wide_Character; else Store_Encoded_Character (Code); - end if; ! -- Make sure we are allowing wide characters in identifiers. ! -- Note that we allow wide character notation for an OK ! -- identifier character. This in particular allows bracket ! -- or other notation to be used for upper half letters. ! if Identifier_Character_Set /= 'w' ! and then ! (not In_Character_Range (Code) ! or else ! not Identifier_Char (Get_Character (Code))) ! then ! Error_Msg ! ("wide character not allowed in identifier", Sptr); end if; end; --- 1356,1399 ---- Sptr : constant Source_Ptr := Scan_Ptr; Code : Char_Code; Err : Boolean; + Chr : Character; begin Scan_Wide (Source, Scan_Ptr, Code, Err); ! ! -- If error, signal error if Err then Error_Illegal_Wide_Character; + + -- If the character scanned is a normal identifier + -- character, then we treat it that way. + + elsif In_Character_Range (Code) + and then Identifier_Char (Get_Character (Code)) + then + Chr := Get_Character (Code); + Accumulate_Checksum (Chr); + Store_Encoded_Character + (Get_Char_Code (Fold_Lower (Chr))); + + -- Character is not normal identifier character, store + -- it in encoded form. + else + Accumulate_Checksum (Code); Store_Encoded_Character (Code); ! -- Make sure we are allowing wide characters in ! -- identifiers. Note that we allow wide character ! -- notation for an OK identifier character. This ! -- in particular allows bracket or other notation ! -- to be used for upper half letters. ! if Identifier_Character_Set /= 'w' then ! Error_Msg ! ("wide character not allowed in identifier", Sptr); ! end if; end if; end; diff -Nrc3pad gcc-3.2.3/gcc/ada/scn.ads gcc-3.3/gcc/ada/scn.ads *** gcc-3.2.3/gcc/ada/scn.ads 2002-05-04 03:28:53.000000000 +0000 --- gcc-3.3/gcc/ada/scn.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/scn-nlit.adb gcc-3.3/gcc/ada/scn-nlit.adb *** gcc-3.2.3/gcc/ada/scn-nlit.adb 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/scn-nlit.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** begin *** 356,362 **** -- This is especially useful when parsing garbled input. elsif Operating_Mode /= Check_Syntax ! and then (Errors_Detected = 0 or else Try_Semantics) then Set_Intval (Token_Node, UI_Num_Value * UI_Base ** UI_Scale); --- 355,361 ---- -- This is especially useful when parsing garbled input. elsif Operating_Mode /= Check_Syntax ! and then (Serious_Errors_Detected = 0 or else Try_Semantics) then Set_Intval (Token_Node, UI_Num_Value * UI_Base ** UI_Scale); diff -Nrc3pad gcc-3.2.3/gcc/ada/scn-slit.adb gcc-3.3/gcc/ada/scn-slit.adb *** gcc-3.2.3/gcc/ada/scn-slit.adb 2002-05-04 03:28:53.000000000 +0000 --- gcc-3.3/gcc/ada/scn-slit.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-crc32.adb gcc-3.3/gcc/ada/s-crc32.adb *** gcc-3.2.3/gcc/ada/s-crc32.adb 2001-10-11 23:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-crc32.adb 2002-03-14 10:59:42.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-crc32.ads gcc-3.3/gcc/ada/s-crc32.ads *** gcc-3.2.3/gcc/ada/s-crc32.ads 2001-10-11 23:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-crc32.ads 2002-03-14 10:59:42.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 2001 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/sdefault.ads gcc-3.3/gcc/ada/sdefault.ads *** gcc-3.2.3/gcc/ada/sdefault.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sdefault.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-direio.adb gcc-3.3/gcc/ada/s-direio.adb *** gcc-3.2.3/gcc/ada/s-direio.adb 2002-05-04 03:28:37.000000000 +0000 --- gcc-3.3/gcc/ada/s-direio.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-1999 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body System.Direct_IO is *** 60,65 **** --- 59,66 ---- ------------------- function AFCB_Allocate (Control_Block : Direct_AFCB) return FCB.AFCB_Ptr is + pragma Warnings (Off, Control_Block); + begin return new Direct_AFCB; end AFCB_Allocate; *************** package body System.Direct_IO is *** 71,76 **** --- 72,79 ---- -- No special processing required for Direct_IO close procedure AFCB_Close (File : access Direct_AFCB) is + pragma Warnings (Off, File); + begin null; end AFCB_Close; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-direio.ads gcc-3.3/gcc/ada/s-direio.ads *** gcc-3.2.3/gcc/ada/s-direio.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-direio.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem.adb gcc-3.3/gcc/ada/sem.adb *** gcc-3.2.3/gcc/ada/sem.adb 2002-05-04 03:28:53.000000000 +0000 --- gcc-3.3/gcc/ada/sem.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Sem is *** 552,558 **** -- a real internal error which we complain about. when N_Empty => ! pragma Assert (Errors_Detected /= 0); null; -- A call to analyze the error node is simply ignored, to avoid --- 551,557 ---- -- a real internal error which we complain about. when N_Empty => ! pragma Assert (Serious_Errors_Detected /= 0); null; -- A call to analyze the error node is simply ignored, to avoid diff -Nrc3pad gcc-3.2.3/gcc/ada/sem.ads gcc-3.3/gcc/ada/sem.ads *** gcc-3.2.3/gcc/ada/sem.ads 2002-05-04 03:28:53.000000000 +0000 --- gcc-3.3/gcc/ada/sem.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_aggr.adb gcc-3.3/gcc/ada/sem_aggr.adb *** gcc-3.2.3/gcc/ada/sem_aggr.adb 2002-05-04 03:28:54.000000000 +0000 --- gcc-3.3/gcc/ada/sem_aggr.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Sem_Aggr is *** 422,434 **** then if Is_Out_Of_Range (Exp, Base_Type (Check_Typ)) then Apply_Compile_Time_Constraint_Error ! (Exp, "value not in range of}?", Ent => Base_Type (Check_Typ), Typ => Base_Type (Check_Typ)); elsif Is_Out_Of_Range (Exp, Check_Typ) then Apply_Compile_Time_Constraint_Error ! (Exp, "value not in range of}?", Ent => Check_Typ, Typ => Check_Typ); --- 421,433 ---- then if Is_Out_Of_Range (Exp, Base_Type (Check_Typ)) then Apply_Compile_Time_Constraint_Error ! (Exp, "value not in range of}?", CE_Range_Check_Failed, Ent => Base_Type (Check_Typ), Typ => Base_Type (Check_Typ)); elsif Is_Out_Of_Range (Exp, Check_Typ) then Apply_Compile_Time_Constraint_Error ! (Exp, "value not in range of}?", CE_Range_Check_Failed, Ent => Check_Typ, Typ => Check_Typ); *************** package body Sem_Aggr is *** 630,636 **** Itype := Create_Itype (E_Array_Subtype, N); Set_First_Rep_Item (Itype, First_Rep_Item (Typ)); - Set_Component_Type (Itype, Component_Type (Typ)); Set_Convention (Itype, Convention (Typ)); Set_Depends_On_Private (Itype, Has_Private_Component (Typ)); Set_Etype (Itype, Base_Type (Typ)); --- 629,634 ---- *************** package body Sem_Aggr is *** 745,751 **** Ind : Entity_Id; begin ! if Has_Record_Rep_Clause (Base_Type (T)) then return; elsif Present (Next_Discriminant (Disc)) then --- 743,749 ---- Ind : Entity_Id; begin ! if Has_Record_Rep_Clause (T) then return; elsif Present (Next_Discriminant (Disc)) then *************** package body Sem_Aggr is *** 821,827 **** C_Node := Make_Character_Literal (P, Name_Find, C); Set_Etype (C_Node, Any_Character); - Set_Analyzed (C_Node); Append_To (Exprs, C_Node); P := P + 1; --- 819,824 ---- *************** package body Sem_Aggr is *** 995,1001 **** if Raises_Constraint_Error (N) then Aggr_Subtyp := Etype (N); ! Rewrite (N, Make_Raise_Constraint_Error (Sloc (N))); Set_Raises_Constraint_Error (N); Set_Etype (N, Aggr_Subtyp); Set_Analyzed (N); --- 992,1000 ---- if Raises_Constraint_Error (N) then Aggr_Subtyp := Etype (N); ! Rewrite (N, ! Make_Raise_Constraint_Error (Sloc (N), ! Reason => CE_Range_Check_Failed)); Set_Raises_Constraint_Error (N); Set_Etype (N, Aggr_Subtyp); Set_Analyzed (N); *************** package body Sem_Aggr is *** 1476,1481 **** --- 1475,1486 ---- return Failure; end if; + -- Protect against cascaded errors + + if Etype (Index_Typ) = Any_Type then + return Failure; + end if; + -- STEP 2: Process named components if No (Expressions (N)) then *************** package body Sem_Aggr is *** 2588,2594 **** -- If this is an extension aggregate, the component list must -- include all components that are not in the given ancestor -- type. Otherwise, the component list must include components ! -- of all ancestors. if Nkind (N) = N_Extension_Aggregate then Root_Typ := Base_Type (Etype (Ancestor_Part (N))); --- 2593,2599 ---- -- If this is an extension aggregate, the component list must -- include all components that are not in the given ancestor -- type. Otherwise, the component list must include components ! -- of all ancestors, starting with the root. if Nkind (N) = N_Extension_Aggregate then Root_Typ := Base_Type (Etype (Ancestor_Part (N))); *************** package body Sem_Aggr is *** 2609,2618 **** -- If we don't get a full declaration, then we have some -- error which will get signalled later so skip this part. if Nkind (Dnode) = N_Full_Type_Declaration then Record_Def := Type_Definition (Dnode); ! Gather_Components (Typ, Component_List (Record_Def), Governed_By => New_Assoc_List, Into => Components, --- 2614,2627 ---- -- If we don't get a full declaration, then we have some -- error which will get signalled later so skip this part. + -- Otherwise, gather components of root that apply to the + -- aggregate type. We use the base type in case there is an + -- applicable girder constraint that renames the discriminants + -- of the root. if Nkind (Dnode) = N_Full_Type_Declaration then Record_Def := Type_Definition (Dnode); ! Gather_Components (Base_Type (Typ), Component_List (Record_Def), Governed_By => New_Assoc_List, Into => Components, *************** package body Sem_Aggr is *** 2668,2674 **** if Null_Present (Record_Def) then null; else ! Gather_Components (Typ, Component_List (Record_Def), Governed_By => New_Assoc_List, Into => Components, --- 2677,2683 ---- if Null_Present (Record_Def) then null; else ! Gather_Components (Base_Type (Typ), Component_List (Record_Def), Governed_By => New_Assoc_List, Into => Components, diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_aggr.ads gcc-3.3/gcc/ada/sem_aggr.ads *** gcc-3.2.3/gcc/ada/sem_aggr.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_aggr.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_attr.adb gcc-3.3/gcc/ada/sem_attr.adb *** gcc-3.2.3/gcc/ada/sem_attr.adb 2002-05-04 03:28:54.000000000 +0000 --- gcc-3.3/gcc/ada/sem_attr.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.8.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with Sem; use Sem; *** 48,54 **** with Sem_Cat; use Sem_Cat; with Sem_Ch6; use Sem_Ch6; with Sem_Ch8; use Sem_Ch8; - with Sem_Ch13; use Sem_Ch13; with Sem_Dist; use Sem_Dist; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; --- 47,52 ---- *************** package body Sem_Attr is *** 232,240 **** -- as referenced, since the image function could possibly end up -- referencing any of the literals indirectly. - procedure Check_Enumeration_Type; - -- Verify that prefix of attribute N is an enumeration type - procedure Check_Fixed_Point_Type; -- Verify that prefix of attribute N is a fixed type --- 230,235 ---- *************** package body Sem_Attr is *** 444,449 **** --- 439,448 ---- elsif Is_Entity_Name (P) and then Is_Overloadable (Entity (P)) then + if not Is_Library_Level_Entity (Entity (P)) then + Check_Restriction (No_Implicit_Dynamic_Code, P); + end if; + Build_Access_Subprogram_Type (P); return; *************** package body Sem_Attr is *** 453,459 **** and then Is_Overloadable (Entity (Selector_Name (P)))) then if Ekind (Entity (Selector_Name (P))) = E_Entry then ! Error_Attr ("Prefix of % attribute must be subprogram", P); end if; Build_Access_Subprogram_Type (Selector_Name (P)); --- 452,458 ---- and then Is_Overloadable (Entity (Selector_Name (P)))) then if Ekind (Entity (Selector_Name (P))) = E_Entry then ! Error_Attr ("prefix of % attribute must be subprogram", P); end if; Build_Access_Subprogram_Type (Selector_Name (P)); *************** package body Sem_Attr is *** 942,960 **** end Check_Enum_Image; ---------------------------- - -- Check_Enumeration_Type -- - ---------------------------- - - procedure Check_Enumeration_Type is - begin - Check_Type; - - if not Is_Enumeration_Type (P_Type) then - Error_Attr ("prefix of % attribute must be enumeration type", P); - end if; - end Check_Enumeration_Type; - - ---------------------------- -- Check_Fixed_Point_Type -- ---------------------------- --- 941,946 ---- *************** package body Sem_Attr is *** 1342,1348 **** if not Is_Entity_Name (P) or else not Is_Type (Entity (P)) then ! Error_Attr (" prefix of % attribute must be generic type", N); elsif Is_Generic_Actual_Type (Entity (P)) or In_Instance --- 1328,1334 ---- if not Is_Entity_Name (P) or else not Is_Type (Entity (P)) then ! Error_Attr ("prefix of % attribute must be generic type", N); elsif Is_Generic_Actual_Type (Entity (P)) or In_Instance *************** package body Sem_Attr is *** 1352,1363 **** elsif Is_Generic_Type (Entity (P)) then if not Is_Indefinite_Subtype (Entity (P)) then Error_Attr ! (" prefix of % attribute must be indefinite generic type", N); end if; else Error_Attr ! (" prefix of % attribute must be indefinite generic type", N); end if; Set_Etype (N, Standard_Boolean); --- 1338,1349 ---- elsif Is_Generic_Type (Entity (P)) then if not Is_Indefinite_Subtype (Entity (P)) then Error_Attr ! ("prefix of % attribute must be indefinite generic type", N); end if; else Error_Attr ! ("prefix of % attribute must be indefinite generic type", N); end if; Set_Etype (N, Standard_Boolean); *************** package body Sem_Attr is *** 1549,1556 **** -- applies to other entity-denoting expressions. if (Is_Entity_Name (P)) then ! if Is_Subprogram (Entity (P)) ! or else Is_Object (Entity (P)) or else Ekind (Entity (P)) = E_Label then Set_Address_Taken (Entity (P)); --- 1535,1548 ---- -- applies to other entity-denoting expressions. if (Is_Entity_Name (P)) then ! if Is_Subprogram (Entity (P)) then ! if not Is_Library_Level_Entity (Entity (P)) then ! Check_Restriction (No_Implicit_Dynamic_Code, P); ! end if; ! ! Set_Address_Taken (Entity (P)); ! ! elsif Is_Object (Entity (P)) or else Ekind (Entity (P)) = E_Label then Set_Address_Taken (Entity (P)); *************** package body Sem_Attr is *** 2144,2156 **** end if; elsif Nkind (P) = N_Indexed_Component then ! Ent := Entity (Prefix (P)); ! if Ekind (Ent) /= E_Entry_Family then ! Error_Attr ("invalid entry family name", P); return; end if; else Error_Attr ("invalid entry name", N); return; --- 2136,2169 ---- end if; elsif Nkind (P) = N_Indexed_Component then ! if not Is_Entity_Name (Prefix (P)) ! or else No (Entity (Prefix (P))) ! or else Ekind (Entity (Prefix (P))) /= E_Entry_Family ! then ! if Nkind (Prefix (P)) = N_Selected_Component ! and then Present (Entity (Selector_Name (Prefix (P)))) ! and then Ekind (Entity (Selector_Name (Prefix (P)))) = ! E_Entry_Family ! then ! Error_Attr ! ("attribute % must apply to entry of current task", P); ! else ! Error_Attr ("invalid entry family name", P); ! end if; return; + + else + Ent := Entity (Prefix (P)); end if; + elsif Nkind (P) = N_Selected_Component + and then Present (Entity (Selector_Name (P))) + and then Ekind (Entity (Selector_Name (P))) = E_Entry + then + Error_Attr + ("attribute % must apply to entry of current task", P); + else Error_Attr ("invalid entry name", N); return; *************** package body Sem_Attr is *** 2175,2182 **** then null; else ! Error_Msg_N ! ("Count must apply to entry of current task", N); end if; end if; --- 2188,2195 ---- then null; else ! Error_Attr ! ("Attribute % must apply to entry of current task", N); end if; end if; *************** package body Sem_Attr is *** 2188,2194 **** and then Ekind (S) /= E_Entry and then Ekind (S) /= E_Entry_Family then ! Error_Attr ("Count cannot appear in inner unit", N); elsif Ekind (Scope (Ent)) = E_Protected_Type and then not Has_Completion (Scope (Ent)) --- 2201,2207 ---- and then Ekind (S) /= E_Entry and then Ekind (S) /= E_Entry_Family then ! Error_Attr ("Attribute % cannot appear in inner unit", N); elsif Ekind (Scope (Ent)) = E_Protected_Type and then not Has_Completion (Scope (Ent)) *************** package body Sem_Attr is *** 2666,2693 **** Resolve (E2, P_Base_Type); Set_Etype (N, P_Base_Type); - ---------------------------- - -- Max_Interrupt_Priority -- - ---------------------------- - - when Attribute_Max_Interrupt_Priority => - Standard_Attribute - (UI_To_Int - (Expr_Value - (Expression - (Parent (RTE (RE_Max_Interrupt_Priority)))))); - - ------------------ - -- Max_Priority -- - ------------------ - - when Attribute_Max_Priority => - Standard_Attribute - (UI_To_Int - (Expr_Value - (Expression - (Parent (RTE (RE_Max_Priority)))))); - ---------------------------------- -- Max_Size_In_Storage_Elements -- ---------------------------------- --- 2679,2684 ---- *************** package body Sem_Attr is *** 3314,3333 **** Set_Etype (N, Standard_Boolean); Check_Task_Prefix; - ---------- - -- Tick -- - ---------- - - when Attribute_Tick => - Check_Standard_Prefix; - Rewrite (N, - Make_Real_Literal (Loc, - UR_From_Components ( - Num => UI_From_Int (Ttypes.System_Tick_Nanoseconds), - Den => UI_From_Int (9), - Rbase => 10))); - Analyze (N); - ---------------- -- To_Address -- ---------------- --- 3305,3310 ---- *************** package body Sem_Attr is *** 3794,3800 **** elsif Is_Out_Of_Range (N, T) then Apply_Compile_Time_Constraint_Error ! (N, "value not in range of}?"); elsif not Range_Checks_Suppressed (T) then Enable_Range_Check (N); --- 3771,3777 ---- elsif Is_Out_Of_Range (N, T) then Apply_Compile_Time_Constraint_Error ! (N, "value not in range of}?", CE_Range_Check_Failed); elsif not Range_Checks_Suppressed (T) then Enable_Range_Check (N); *************** package body Sem_Attr is *** 4404,4410 **** if Raises_Constraint_Error (N) then CE_Node := ! Make_Raise_Constraint_Error (Sloc (N)); Set_Etype (CE_Node, Etype (N)); Set_Raises_Constraint_Error (CE_Node); Check_Expressions; --- 4381,4388 ---- if Raises_Constraint_Error (N) then CE_Node := ! Make_Raise_Constraint_Error (Sloc (N), ! Reason => CE_Range_Check_Failed); Set_Etype (CE_Node, Etype (N)); Set_Raises_Constraint_Error (CE_Node); Check_Expressions; *************** package body Sem_Attr is *** 5261,5267 **** Expr_Value (Type_Low_Bound (P_Base_Type)) then Apply_Compile_Time_Constraint_Error ! (N, "Pred of type''First"); Check_Expressions; return; end if; --- 5239,5245 ---- Expr_Value (Type_Low_Bound (P_Base_Type)) then Apply_Compile_Time_Constraint_Error ! (N, "Pred of type''First", CE_Overflow_Check_Failed); Check_Expressions; return; end if; *************** package body Sem_Attr is *** 5571,5577 **** Expr_Value (Type_High_Bound (P_Base_Type)) then Apply_Compile_Time_Constraint_Error ! (N, "Succ of type''Last"); Check_Expressions; return; else --- 5549,5555 ---- Expr_Value (Type_High_Bound (P_Base_Type)) then Apply_Compile_Time_Constraint_Error ! (N, "Succ of type''Last", CE_Overflow_Check_Failed); Check_Expressions; return; else *************** package body Sem_Attr is *** 5677,5683 **** Expr_Value (E1) > Expr_Value (Type_High_Bound (P_Base_Type)) then Apply_Compile_Time_Constraint_Error ! (N, "Val expression out of range"); Check_Expressions; return; else --- 5655,5661 ---- Expr_Value (E1) > Expr_Value (Type_High_Bound (P_Base_Type)) then Apply_Compile_Time_Constraint_Error ! (N, "Val expression out of range", CE_Range_Check_Failed); Check_Expressions; return; else *************** package body Sem_Attr is *** 5988,5995 **** Attribute_First_Bit | Attribute_Input | Attribute_Last_Bit | - Attribute_Max_Interrupt_Priority | - Attribute_Max_Priority | Attribute_Maximum_Alignment | Attribute_Output | Attribute_Partition_ID | --- 5966,5971 ---- *************** package body Sem_Attr is *** 6000,6006 **** Attribute_Storage_Unit | Attribute_Tag | Attribute_Terminated | - Attribute_Tick | Attribute_To_Address | Attribute_UET_Address | Attribute_Unchecked_Access | --- 5976,5981 ---- *************** package body Sem_Attr is *** 6262,6267 **** --- 6237,6243 ---- end if; Resolve (Prefix (P), Etype (Prefix (P))); + Generate_Reference (Entity (Selector_Name (P)), P); elsif Is_Overloaded (P) then *************** package body Sem_Attr is *** 6423,6429 **** ("?non-local pointer cannot point to local object", P); Error_Msg_N ("?Program_Error will be raised at run time", P); ! Rewrite (N, Make_Raise_Program_Error (Loc)); Set_Etype (N, Typ); return; --- 6399,6407 ---- ("?non-local pointer cannot point to local object", P); Error_Msg_N ("?Program_Error will be raised at run time", P); ! Rewrite (N, ! Make_Raise_Program_Error (Loc, ! Reason => PE_Accessibility_Check_Failed)); Set_Etype (N, Typ); return; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_attr.ads gcc-3.3/gcc/ada/sem_attr.ads *** gcc-3.2.3/gcc/ada/sem_attr.ads 2002-05-04 03:28:55.000000000 +0000 --- gcc-3.3/gcc/ada/sem_attr.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-1999, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package Sem_Attr is *** 209,215 **** -- value indicating whether or not the body of the designated library -- unit has been elaborated yet. - -------------- -- Enum_Rep -- -------------- --- 208,213 ---- *************** package Sem_Attr is *** 305,333 **** -- This attribute is identical to the Object_Size attribute. It is -- provided for compatibility with the DEC attribute of this name. - ---------------------------- - -- Max_Interrupt_Priority -- - ---------------------------- - - Attribute_Max_Interrupt_Priority => True, - -- - -- Standard'Max_Interrupt_Priority (Standard is the only permissible - -- prefix), provides the value System.Max_Interrupt_Priority, and is - -- intended primarily for constructing this definition in package - -- System (see note above in Default_Bit_Order description}. This - -- is a static attribute. - - ------------------ - -- Max_Priority -- - ------------------ - - Attribute_Max_Priority => True, - -- - -- Standard'Max_Priority (Standard is the only permissible prefix) - -- provides the value System.Max_Priority, and is intended primarily - -- for constructing this definition in package System (see note above - -- in Default_Bit_Order description). This is a static attribute. - ----------------------- -- Maximum_Alignment -- ----------------------- --- 303,308 ---- *************** package Sem_Attr is *** 431,447 **** -- for constructing this definition in package System (see note above -- in Default_Bit_Order description). The is a static attribute. - ---------- - -- Tick -- - ---------- - - Attribute_Tick => True, - -- - -- Standard'Tick (Standard is the only permissible prefix) provides - -- the value System.Tick, and is intended primarily for constructing - -- this definition in package System (see note above in description - -- of Default_Bit_Order). This is a static attribute. - ---------------- -- To_Address -- ---------------- --- 406,411 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_case.adb gcc-3.3/gcc/ada/sem_case.adb *** gcc-3.2.3/gcc/ada/sem_case.adb 2002-05-04 03:28:56.000000000 +0000 --- gcc-3.3/gcc/ada/sem_case.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1996-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1996-2002 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- -- *************** package body Sem_Case is *** 331,336 **** --- 330,337 ---- ----------- procedure No_OP (C : Node_Id) is + pragma Warnings (Off, C); + begin null; end No_OP; *************** package body Sem_Case is *** 577,588 **** else if Is_Out_Of_Range (L, E) then Apply_Compile_Time_Constraint_Error ! (L, "static value out of range"); end if; if Is_Out_Of_Range (H, E) then Apply_Compile_Time_Constraint_Error ! (H, "static value out of range"); end if; end if; end if; --- 578,591 ---- else if Is_Out_Of_Range (L, E) then Apply_Compile_Time_Constraint_Error ! (L, "static value out of range", ! CE_Range_Check_Failed); end if; if Is_Out_Of_Range (H, E) then Apply_Compile_Time_Constraint_Error ! (H, "static value out of range", ! CE_Range_Check_Failed); end if; end if; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_case.ads gcc-3.3/gcc/ada/sem_case.ads *** gcc-3.2.3/gcc/ada/sem_case.ads 2002-05-04 03:28:56.000000000 +0000 --- gcc-3.3/gcc/ada/sem_case.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.4.10.1 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_cat.adb gcc-3.3/gcc/ada/sem_cat.adb *** gcc-3.2.3/gcc/ada/sem_cat.adb 2002-05-04 03:28:56.000000000 +0000 --- gcc-3.3/gcc/ada/sem_cat.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_cat.ads gcc-3.3/gcc/ada/sem_cat.ads *** gcc-3.2.3/gcc/ada/sem_cat.ads 2002-05-04 03:28:56.000000000 +0000 --- gcc-3.3/gcc/ada/sem_cat.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch10.adb gcc-3.3/gcc/ada/sem_ch10.adb *** gcc-3.2.3/gcc/ada/sem_ch10.adb 2002-05-04 03:28:56.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch10.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Sem_Ch10 is *** 93,98 **** --- 92,104 ---- -- N is the compilation unit whose list of context items receives the -- implicit with_clauses. + function Get_Parent_Entity (Unit : Node_Id) return Entity_Id; + -- Get defining entity of parent unit of a child unit. In most cases this + -- is the defining entity of the unit, but for a child instance whose + -- parent needs a body for inlining, the instantiation node of the parent + -- has not yet been rewritten as a package declaration, and the entity has + -- to be retrieved from the Instance_Spec of the unit. + procedure Implicit_With_On_Parent (Child_Unit : Node_Id; N : Node_Id); -- If the main unit is a child unit, implicit withs are also added for -- all its ancestors. *************** package body Sem_Ch10 is *** 233,239 **** Semantics (Lib_Unit); if not Analyzed (Proper_Body (Unit_Node)) then ! if Errors_Detected > 0 then Error_Msg_N ("subunit not analyzed (errors in parent unit)", N); else Error_Msg_N ("missing stub for subunit", N); --- 239,245 ---- Semantics (Lib_Unit); if not Analyzed (Proper_Body (Unit_Node)) then ! if Serious_Errors_Detected > 0 then Error_Msg_N ("subunit not analyzed (errors in parent unit)", N); else Error_Msg_N ("missing stub for subunit", N); *************** package body Sem_Ch10 is *** 401,407 **** -- Set the entities of all parents in the program_unit_name. Generate_Parent_References ( ! Unit_Node, Defining_Entity (Unit (Parent_Spec (Unit_Node)))); end if; -- All components of the context: with-clauses, library unit, ancestors --- 407,413 ---- -- Set the entities of all parents in the program_unit_name. Generate_Parent_References ( ! Unit_Node, Get_Parent_Entity (Unit (Parent_Spec (Unit_Node)))); end if; -- All components of the context: with-clauses, library unit, ancestors *************** package body Sem_Ch10 is *** 1061,1067 **** Analyze_Subprogram_Body (N); ! if Errors_Detected = 0 then Analyze_Proper_Body (N, Empty); end if; --- 1067,1073 ---- Analyze_Subprogram_Body (N); ! if Serious_Errors_Detected = 0 then Analyze_Proper_Body (N, Empty); end if; *************** package body Sem_Ch10 is *** 1619,1625 **** Unum : Unit_Number_Type; Sel : Node_Id; ! procedure Decorate_Tagged_Type (T : Entity_Id; Kind : Entity_Kind); -- Set basic attributes of type, including its class_wide type. function In_Chain (E : Entity_Id) return Boolean; --- 1625,1631 ---- Unum : Unit_Number_Type; Sel : Node_Id; ! procedure Decorate_Tagged_Type (T : Entity_Id); -- Set basic attributes of type, including its class_wide type. function In_Chain (E : Entity_Id) return Boolean; *************** package body Sem_Ch10 is *** 1630,1636 **** -- Decorate_Tagged_Type -- -------------------------- ! procedure Decorate_Tagged_Type (T : Entity_Id; Kind : Entity_Kind) is CW : Entity_Id; begin --- 1636,1642 ---- -- Decorate_Tagged_Type -- -------------------------- ! procedure Decorate_Tagged_Type (T : Entity_Id) is CW : Entity_Id; begin *************** package body Sem_Ch10 is *** 1847,1853 **** -- to type and build its class-wide type. Init_Size_Align (Typ); ! Decorate_Tagged_Type (Typ, E_Record_Type); end if; else --- 1853,1859 ---- -- to type and build its class-wide type. Init_Size_Align (Typ); ! Decorate_Tagged_Type (Typ); end if; else *************** package body Sem_Ch10 is *** 1887,1893 **** Error_Msg_N ("type must be declared tagged", N); elsif not Analyzed (Decl) then ! Decorate_Tagged_Type (Typ, E_Private_Type); end if; Set_Entity (Sel, Typ); --- 1893,1899 ---- Error_Msg_N ("type must be declared tagged", N); elsif not Analyzed (Decl) then ! Decorate_Tagged_Type (Typ); end if; Set_Entity (Sel, Typ); *************** package body Sem_Ch10 is *** 2175,2180 **** --- 2181,2199 ---- New_Nodes_OK := New_Nodes_OK - 1; end Expand_With_Clause; + ----------------------- + -- Get_Parent_Entity -- + ----------------------- + + function Get_Parent_Entity (Unit : Node_Id) return Entity_Id is + begin + if Nkind (Unit) = N_Package_Instantiation then + return Defining_Entity (Specification (Instance_Spec (Unit))); + else + return Defining_Entity (Unit); + end if; + end Get_Parent_Entity; + ----------------------------- -- Implicit_With_On_Parent -- ----------------------------- *************** package body Sem_Ch10 is *** 2187,2193 **** P : constant Node_Id := Parent_Spec (Child_Unit); P_Unit : constant Node_Id := Unit (P); ! P_Name : Entity_Id := Defining_Entity (P_Unit); Withn : Node_Id; function Build_Ancestor_Name (P : Node_Id) return Node_Id; --- 2206,2212 ---- P : constant Node_Id := Parent_Spec (Child_Unit); P_Unit : constant Node_Id := Unit (P); ! P_Name : Entity_Id := Get_Parent_Entity (P_Unit); Withn : Node_Id; function Build_Ancestor_Name (P : Node_Id) return Node_Id; *************** package body Sem_Ch10 is *** 2518,2524 **** begin P := Unit (Parent_Spec (Lib_Unit)); ! P_Name := Defining_Entity (P); if Etype (P_Name) = Any_Type then return; --- 2537,2543 ---- begin P := Unit (Parent_Spec (Lib_Unit)); ! P_Name := Get_Parent_Entity (P); if Etype (P_Name) = Any_Type then return; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch10.ads gcc-3.3/gcc/ada/sem_ch10.ads *** gcc-3.2.3/gcc/ada/sem_ch10.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch10.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch11.adb gcc-3.3/gcc/ada/sem_ch11.adb *** gcc-3.2.3/gcc/ada/sem_ch11.adb 2002-05-04 03:28:56.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch11.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Sem_Ch11 is *** 324,333 **** if Is_Entity_Name (Exception_Id) then Exception_Name := Entity (Exception_Id); - - if Present (Renamed_Object (Exception_Name)) then - Set_Entity (Exception_Id, Renamed_Object (Exception_Name)); - end if; end if; if No (Exception_Name) --- 323,328 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch11.ads gcc-3.3/gcc/ada/sem_ch11.ads *** gcc-3.2.3/gcc/ada/sem_ch11.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch11.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1998 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch12.adb gcc-3.3/gcc/ada/sem_ch12.adb *** gcc-3.2.3/gcc/ada/sem_ch12.adb 2002-05-04 03:28:57.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch12.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.16.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Sem_Ch12 is *** 321,327 **** -- Verify that the actuals of the actual instance match the actuals of -- the template for a formal package that is not declared with a box. ! procedure Check_Forward_Instantiation (N : Node_Id; Decl : Node_Id); -- If the generic is a local entity and the corresponding body has not -- been seen yet, flag enclosing packages to indicate that it will be -- elaborated after the generic body. Subprograms declared in the same --- 320,326 ---- -- Verify that the actuals of the actual instance match the actuals of -- the template for a formal package that is not declared with a box. ! procedure Check_Forward_Instantiation (Decl : Node_Id); -- If the generic is a local entity and the corresponding body has not -- been seen yet, flag enclosing packages to indicate that it will be -- elaborated after the generic body. Subprograms declared in the same *************** package body Sem_Ch12 is *** 1228,1233 **** --- 1227,1233 ---- Set_Small_Value (T, Delta_Val); Set_Scalar_Range (T, Scalar_Range (Base)); + Check_Restriction (No_Fixed_Point, Def); end Analyze_Formal_Decimal_Fixed_Point_Type; --------------------------------- *************** package body Sem_Ch12 is *** 1365,1370 **** --- 1365,1372 ---- Set_Digits_Value (Base, Digits_Value (Standard_Float)); Set_Scalar_Range (Base, Scalar_Range (Standard_Float)); Set_Parent (Base, Parent (Def)); + + Check_Restriction (No_Floating_Point, Def); end Analyze_Formal_Floating_Type; --------------------------------- *************** package body Sem_Ch12 is *** 1512,1517 **** --- 1514,1521 ---- Set_Delta_Value (Base, Ureal_1); Set_Scalar_Range (Base, Scalar_Range (T)); Set_Parent (Base, Parent (Def)); + + Check_Restriction (No_Fixed_Point, Def); end Analyze_Formal_Ordinary_Fixed_Point_Type; ---------------------------- *************** package body Sem_Ch12 is *** 2083,2089 **** Formals := Parameter_Specifications (Spec); if Present (Formals) then ! Process_Formals (Id, Formals, Spec); end if; if Nkind (Spec) = N_Function_Specification then --- 2087,2093 ---- Formals := Parameter_Specifications (Spec); if Present (Formals) then ! Process_Formals (Formals, Spec); end if; if Nkind (Spec) = N_Function_Specification then *************** package body Sem_Ch12 is *** 2271,2283 **** ("& is hidden within declaration of instance ", Prefix (Gen_Id)); end if; ! -- If renaming, indicate this is an instantiation of renamed unit. if Present (Renamed_Object (Gen_Unit)) and then Ekind (Renamed_Object (Gen_Unit)) = E_Generic_Package then Gen_Unit := Renamed_Object (Gen_Unit); - Set_Entity (Gen_Id, Gen_Unit); end if; -- Verify that there are no circular instantiations. --- 2275,2288 ---- ("& is hidden within declaration of instance ", Prefix (Gen_Id)); end if; ! Set_Entity (Gen_Id, Gen_Unit); ! ! -- If generic is a renaming, get original generic unit. if Present (Renamed_Object (Gen_Unit)) and then Ekind (Renamed_Object (Gen_Unit)) = E_Generic_Package then Gen_Unit := Renamed_Object (Gen_Unit); end if; -- Verify that there are no circular instantiations. *************** package body Sem_Ch12 is *** 2460,2466 **** -- and that cleanup actions should be delayed until after the -- instance body is expanded. ! Check_Forward_Instantiation (N, Gen_Decl); if Nkind (N) = N_Package_Instantiation then declare Enclosing_Master : Entity_Id := Current_Scope; --- 2465,2471 ---- -- and that cleanup actions should be delayed until after the -- instance body is expanded. ! Check_Forward_Instantiation (Gen_Decl); if Nkind (N) = N_Package_Instantiation then declare Enclosing_Master : Entity_Id := Current_Scope; *************** package body Sem_Ch12 is *** 3075,3081 **** end if; else ! -- If renaming, indicate that this is instantiation of renamed unit if Present (Renamed_Object (Gen_Unit)) and then (Ekind (Renamed_Object (Gen_Unit)) = E_Generic_Procedure --- 3080,3088 ---- end if; else ! Set_Entity (Gen_Id, Gen_Unit); ! ! -- If renaming, get original unit. if Present (Renamed_Object (Gen_Unit)) and then (Ekind (Renamed_Object (Gen_Unit)) = E_Generic_Procedure *************** package body Sem_Ch12 is *** 3083,3089 **** Ekind (Renamed_Object (Gen_Unit)) = E_Generic_Function) then Gen_Unit := Renamed_Object (Gen_Unit); - Set_Entity (Gen_Id, Gen_Unit); end if; if Contains_Instance_Of (Gen_Unit, Current_Scope, Gen_Id) then --- 3090,3095 ---- *************** package body Sem_Ch12 is *** 3199,3205 **** Pending_Instantiations.Increment_Last; Pending_Instantiations.Table (Pending_Instantiations.Last) := (N, Act_Decl, Expander_Active, Current_Sem_Unit); ! Check_Forward_Instantiation (N, Gen_Decl); -- The wrapper package is always delayed, because it does -- not constitute a freeze point, but to insure that the --- 3205,3211 ---- Pending_Instantiations.Increment_Last; Pending_Instantiations.Table (Pending_Instantiations.Last) := (N, Act_Decl, Expander_Active, Current_Sem_Unit); ! Check_Forward_Instantiation (Gen_Decl); -- The wrapper package is always delayed, because it does -- not constitute a freeze point, but to insure that the *************** package body Sem_Ch12 is *** 3568,3574 **** -- Check_Forward_Instantiation -- --------------------------------- ! procedure Check_Forward_Instantiation (N : Node_Id; Decl : Node_Id) is S : Entity_Id; Gen_Comp : Entity_Id := Cunit_Entity (Get_Source_Unit (Decl)); --- 3574,3580 ---- -- Check_Forward_Instantiation -- --------------------------------- ! procedure Check_Forward_Instantiation (Decl : Node_Id) is S : Entity_Id; Gen_Comp : Entity_Id := Cunit_Entity (Get_Source_Unit (Decl)); *************** package body Sem_Ch12 is *** 4222,4227 **** --- 4228,4239 ---- return List_Id; -- Apply Copy_Node recursively to the members of a node list. + function In_Defining_Unit_Name (Nam : Node_Id) return Boolean; + -- True if an identifier is part of the defining program unit name + -- of a child unit. The entity of such an identifier must be kept + -- (for ASIS use) even though as the name of an enclosing generic + -- it would otherwise not be preserved in the generic tree. + ----------------------- -- Copy_Descendants -- ----------------------- *************** package body Sem_Ch12 is *** 4321,4326 **** --- 4333,4351 ---- end if; end Copy_Generic_List; + --------------------------- + -- In_Defining_Unit_Name -- + --------------------------- + + function In_Defining_Unit_Name (Nam : Node_Id) return Boolean is + begin + return Present (Parent (Nam)) + and then (Nkind (Parent (Nam)) = N_Defining_Program_Unit_Name + or else + (Nkind (Parent (Nam)) = N_Expanded_Name + and then In_Defining_Unit_Name (Parent (Nam)))); + end In_Defining_Unit_Name; + -- Start of processing for Copy_Generic_Node begin *************** package body Sem_Ch12 is *** 4384,4390 **** if No (Current_Instantiated_Parent.Gen_Id) then if No (Ent) or else Nkind (Ent) /= N_Defining_Identifier ! or else Nkind (Parent (N)) /= N_Defining_Program_Unit_Name then Set_Associated_Node (New_N, Empty); end if; --- 4409,4415 ---- if No (Current_Instantiated_Parent.Gen_Id) then if No (Ent) or else Nkind (Ent) /= N_Defining_Identifier ! or else not In_Defining_Unit_Name (N) then Set_Associated_Node (New_N, Empty); end if; *************** package body Sem_Ch12 is *** 4854,4860 **** Pack_Id : Entity_Id) is F_Node : Node_Id; ! Gen_Unit : constant Entity_Id := Entity (Name (Inst_Node)); Par : constant Entity_Id := Scope (Gen_Unit); Enc_G : Entity_Id; Enc_I : Node_Id; --- 4879,4885 ---- Pack_Id : Entity_Id) is F_Node : Node_Id; ! Gen_Unit : constant Entity_Id := Get_Generic_Entity (Inst_Node); Par : constant Entity_Id := Scope (Gen_Unit); Enc_G : Entity_Id; Enc_I : Node_Id; *************** package body Sem_Ch12 is *** 5148,5155 **** -- If the instantiation is a compilation unit that does not need a -- body then the instantiation node has been rewritten as a package -- declaration for the instance, and we return the original node. -- If it is a compilation unit and the instance node has not been ! -- rewritten, then it is still the unit of the compilation. -- Otherwise the instantiation node appears after the declaration. -- If the entity is a formal package, the declaration may have been -- rewritten as a generic declaration (in the case of a formal with a --- 5173,5185 ---- -- If the instantiation is a compilation unit that does not need a -- body then the instantiation node has been rewritten as a package -- declaration for the instance, and we return the original node. + -- If it is a compilation unit and the instance node has not been ! -- rewritten, then it is still the unit of the compilation. Finally, ! -- if a body is present, this is a parent of the main unit whose body ! -- has been compiled for inlining purposes, and the instantiation node ! -- has been rewritten with the instance body. ! -- Otherwise the instantiation node appears after the declaration. -- If the entity is a formal package, the declaration may have been -- rewritten as a generic declaration (in the case of a formal with a *************** package body Sem_Ch12 is *** 5157,5162 **** --- 5187,5198 ---- -- is found with a forward search. if Nkind (Parent (Decl)) = N_Compilation_Unit then + if Nkind (Decl) = N_Package_Declaration + and then Present (Corresponding_Body (Decl)) + then + Decl := Unit_Declaration_Node (Corresponding_Body (Decl)); + end if; + if Nkind (Original_Node (Decl)) = N_Package_Instantiation then return Original_Node (Decl); else *************** package body Sem_Ch12 is *** 6495,6501 **** Loc : constant Source_Ptr := Sloc (Inst_Node); Gen_Id : constant Node_Id := Name (Inst_Node); ! Gen_Unit : constant Entity_Id := Entity (Name (Inst_Node)); Gen_Decl : constant Node_Id := Unit_Declaration_Node (Gen_Unit); Act_Spec : constant Node_Id := Specification (Act_Decl); Act_Decl_Id : constant Entity_Id := Defining_Entity (Act_Spec); --- 6531,6537 ---- Loc : constant Source_Ptr := Sloc (Inst_Node); Gen_Id : constant Node_Id := Name (Inst_Node); ! Gen_Unit : constant Entity_Id := Get_Generic_Entity (Inst_Node); Gen_Decl : constant Node_Id := Unit_Declaration_Node (Gen_Unit); Act_Spec : constant Node_Id := Specification (Act_Decl); Act_Decl_Id : constant Entity_Id := Defining_Entity (Act_Spec); *************** package body Sem_Ch12 is *** 6649,6654 **** --- 6685,6697 ---- Inherit_Context (Gen_Body, Inst_Node); end if; + -- Remove the parent instances if they have been placed on the + -- scope stack to compile the body. + + if Parent_Installed then + Remove_Parent (In_Body => True); + end if; + Restore_Private_Views (Act_Decl_Id); Restore_Env; Style_Check := Save_Style_Check; *************** package body Sem_Ch12 is *** 6658,6664 **** -- (since a common reason for missing the body is that it had errors). elsif Unit_Requires_Body (Gen_Unit) then ! if Errors_Detected = 0 then Error_Msg_NE ("cannot find body of generic package &", Inst_Node, Gen_Unit); --- 6701,6707 ---- -- (since a common reason for missing the body is that it had errors). elsif Unit_Requires_Body (Gen_Unit) then ! if Serious_Errors_Detected = 0 then Error_Msg_NE ("cannot find body of generic package &", Inst_Node, Gen_Unit); *************** package body Sem_Ch12 is *** 6692,6704 **** end if; Expander_Mode_Restore; - - -- Remove the parent instances if they have been placed on the - -- scope stack to compile the body. - - if Parent_Installed then - Remove_Parent (In_Body => True); - end if; end Instantiate_Package_Body; --------------------------------- --- 6735,6740 ---- *************** package body Sem_Ch12 is *** 6714,6720 **** Decls : List_Id; Gen_Id : constant Node_Id := Name (Inst_Node); ! Gen_Unit : constant Entity_Id := Entity (Name (Inst_Node)); Gen_Decl : constant Node_Id := Unit_Declaration_Node (Gen_Unit); Anon_Id : constant Entity_Id := Defining_Unit_Name (Specification (Act_Decl)); --- 6750,6756 ---- Decls : List_Id; Gen_Id : constant Node_Id := Name (Inst_Node); ! Gen_Unit : constant Entity_Id := Get_Generic_Entity (Inst_Node); Gen_Decl : constant Node_Id := Unit_Declaration_Node (Gen_Unit); Anon_Id : constant Entity_Id := Defining_Unit_Name (Specification (Act_Decl)); *************** package body Sem_Ch12 is *** 6875,6881 **** -- raise program error if executed. We generate a subprogram body for -- this purpose. See DEC ac30vso. ! elsif Errors_Detected = 0 and then Nkind (Parent (Inst_Node)) /= N_Compilation_Unit then if Ekind (Anon_Id) = E_Procedure then --- 6911,6917 ---- -- raise program error if executed. We generate a subprogram body for -- this purpose. See DEC ac30vso. ! elsif Serious_Errors_Detected = 0 and then Nkind (Parent (Inst_Node)) /= N_Compilation_Unit then if Ekind (Anon_Id) = E_Procedure then *************** package body Sem_Ch12 is *** 6892,6898 **** Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => ! New_List (Make_Raise_Program_Error (Loc)))); else Act_Body := Make_Subprogram_Body (Loc, --- 6928,6938 ---- Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => ! New_List ( ! Make_Raise_Program_Error (Loc, ! Reason => ! PE_Access_Before_Elaboration)))); ! else Act_Body := Make_Subprogram_Body (Loc, *************** package body Sem_Ch12 is *** 6910,6916 **** Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Make_Return_Statement (Loc, ! Expression => Make_Raise_Program_Error (Loc))))); end if; Pack_Body := Make_Package_Body (Loc, --- 6950,6959 ---- Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Make_Return_Statement (Loc, ! Expression => ! Make_Raise_Program_Error (Loc, ! Reason => ! PE_Access_Before_Elaboration))))); end if; Pack_Body := Make_Package_Body (Loc, *************** package body Sem_Ch12 is *** 7467,7472 **** --- 7510,7525 ---- else Act_T := Entity (Actual); + -- Deal with fixed/floating restrictions + + if Is_Floating_Point_Type (Act_T) then + Check_Restriction (No_Floating_Point, Actual); + elsif Is_Fixed_Point_Type (Act_T) then + Check_Restriction (No_Fixed_Point, Actual); + end if; + + -- Deal with error of using incomplete type as generic actual + if Ekind (Act_T) = E_Incomplete_Type then if No (Underlying_Type (Act_T)) then Error_Msg_N ("premature use of incomplete type", Actual); *************** package body Sem_Ch12 is *** 7481,7486 **** --- 7534,7541 ---- end if; end if; + -- Deal with error of premature use of private type as generic actual + elsif Is_Private_Type (Act_T) and then Is_Private_Type (Base_Type (Act_T)) and then not Is_Generic_Type (Act_T) *************** package body Sem_Ch12 is *** 7901,7907 **** procedure Pre_Analyze_Actuals (N : Node_Id) is Assoc : Node_Id; Act : Node_Id; ! Errs : Int := Errors_Detected; begin Assoc := First (Generic_Associations (N)); --- 7956,7962 ---- procedure Pre_Analyze_Actuals (N : Node_Id) is Assoc : Node_Id; Act : Node_Id; ! Errs : Int := Serious_Errors_Detected; begin Assoc := First (Generic_Associations (N)); *************** package body Sem_Ch12 is *** 7929,7935 **** Analyze (Act); end if; ! if Errs /= Errors_Detected then Abandon_Instantiation (Act); end if; --- 7984,7990 ---- Analyze (Act); end if; ! if Errs /= Serious_Errors_Detected then Abandon_Instantiation (Act); end if; *************** package body Sem_Ch12 is *** 7967,7972 **** --- 8022,8036 ---- Next_Entity (E); end loop; + if Is_Generic_Instance (Current_Scope) + and then P /= Current_Scope + then + -- We are within an instance of some sibling. Retain + -- visibility of parent, for proper subsequent cleanup. + + Set_In_Private_Part (P); + end if; + elsif not In_Open_Scopes (Scope (P)) then Set_Is_Immediately_Visible (P, False); end if; *************** package body Sem_Ch12 is *** 8495,8501 **** Act1 : Node_Id; Act2 : Node_Id; Def : Node_Id; ! Gen_Id : Entity_Id := Entity (Name (N2)); Ndec : Node_Id; Subp : Entity_Id; Actual : Entity_Id; --- 8559,8565 ---- Act1 : Node_Id; Act2 : Node_Id; Def : Node_Id; ! Gen_Id : Entity_Id := Get_Generic_Entity (N2); Ndec : Node_Id; Subp : Entity_Id; Actual : Entity_Id; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch12.ads gcc-3.3/gcc/ada/sem_ch12.ads *** gcc-3.2.3/gcc/ada/sem_ch12.ads 2002-05-04 03:28:58.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch12.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch13.adb gcc-3.3/gcc/ada/sem_ch13.adb *** gcc-3.2.3/gcc/ada/sem_ch13.adb 2002-05-04 03:29:01.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch13.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with Sem_Eval; use Sem_Eval; *** 44,52 **** with Sem_Res; use Sem_Res; with Sem_Type; use Sem_Type; with Sem_Util; use Sem_Util; with Stand; use Stand; with Sinfo; use Sinfo; - with Snames; use Snames; with Table; with Ttypes; use Ttypes; with Tbuild; use Tbuild; --- 43,51 ---- with Sem_Res; use Sem_Res; with Sem_Type; use Sem_Type; with Sem_Util; use Sem_Util; + with Snames; use Snames; with Stand; use Stand; with Sinfo; use Sinfo; with Table; with Ttypes; use Ttypes; with Tbuild; use Tbuild; *************** package body Sem_Ch13 is *** 97,102 **** --- 96,107 ---- -- for limited types is a legality check, which is why this takes place -- here rather than in exp_ch13, where it was previously. + -- To avoid elaboration anomalies with freeze nodes, for untagged types + -- we generate both a subprogram declaration and a subprogram renaming + -- declaration, so that the attribute specification is handled as a + -- renaming_as_body. For tagged types, the specification is one of the + -- primitive specs. + procedure New_Stream_Procedure (N : Node_Id; Ent : Entity_Id; *************** package body Sem_Ch13 is *** 249,254 **** --- 254,262 ---- Error_Msg_N ("entity must be declared in this scope", Nam); return; + elsif No (U_Ent) then + U_Ent := Ent; + elsif Is_Type (U_Ent) and then not Is_First_Subtype (U_Ent) and then Id /= Attribute_Object_Size *************** package body Sem_Ch13 is *** 308,313 **** --- 316,330 ---- Check_Constant_Address_Clause (Expr, U_Ent); + if Is_Task_Type (Scope (U_Ent)) + and then Comes_From_Source (Scope (U_Ent)) + then + Error_Msg_N + ("?entry address declared for entry in task type", N); + Error_Msg_N + ("\?only one task can be declared of this type", N); + end if; + -- Case of address clause for an object elsif *************** package body Sem_Ch13 is *** 966,976 **** Set_RM_Size (U_Ent, Size); -- For scalar types, increase Object_Size to power of 2, ! -- but not less than 8 in any case, i.e. byte addressable. if Is_Scalar_Type (U_Ent) then ! if Size <= 8 then ! Init_Esize (U_Ent, 8); elsif Size <= 16 then Init_Esize (U_Ent, 16); elsif Size <= 32 then --- 983,994 ---- Set_RM_Size (U_Ent, Size); -- For scalar types, increase Object_Size to power of 2, ! -- but not less than a storage unit in any case (i.e., ! -- normally this means it will be byte addressable). if Is_Scalar_Type (U_Ent) then ! if Size <= System_Storage_Unit then ! Init_Esize (U_Ent, System_Storage_Unit); elsif Size <= 16 then Init_Esize (U_Ent, 16); elsif Size <= 32 then *************** package body Sem_Ch13 is *** 1886,1895 **** Ccount := Ccount + 1; end if; ! Set_Has_Record_Rep_Clause (Rectype); ! Set_Has_Specified_Layout (Rectype); ! ! -- A representation like this applies to the base type as well Set_Has_Record_Rep_Clause (Base_Type (Rectype)); Set_Has_Non_Standard_Rep (Base_Type (Rectype)); --- 1904,1910 ---- Ccount := Ccount + 1; end if; ! -- A representation like this applies to the base type Set_Has_Record_Rep_Clause (Base_Type (Rectype)); Set_Has_Non_Standard_Rep (Base_Type (Rectype)); *************** package body Sem_Ch13 is *** 2750,2825 **** end if; end Get_Alignment_Value; - ------------------------------------- - -- Get_Attribute_Definition_Clause -- - ------------------------------------- - - function Get_Attribute_Definition_Clause - (E : Entity_Id; - Id : Attribute_Id) - return Node_Id - is - N : Node_Id; - - begin - N := First_Rep_Item (E); - while Present (N) loop - if Nkind (N) = N_Attribute_Definition_Clause - and then Get_Attribute_Id (Chars (N)) = Id - then - return N; - else - Next_Rep_Item (N); - end if; - end loop; - - return Empty; - end Get_Attribute_Definition_Clause; - - -------------------- - -- Get_Rep_Pragma -- - -------------------- - - function Get_Rep_Pragma (E : Entity_Id; Nam : Name_Id) return Node_Id is - N : Node_Id; - Typ : Entity_Id; - - begin - N := First_Rep_Item (E); - - while Present (N) loop - if Nkind (N) = N_Pragma and then Chars (N) = Nam then - - if Nam = Name_Stream_Convert then - - -- For tagged types this pragma is not inherited, so we - -- must verify that it is defined for the given type and - -- not an ancestor. - - Typ := Entity (Expression - (First (Pragma_Argument_Associations (N)))); - - if not Is_Tagged_Type (E) - or else E = Typ - or else (Is_Private_Type (Typ) - and then E = Full_View (Typ)) - then - return N; - else - Next_Rep_Item (N); - end if; - - else - return N; - end if; - else - Next_Rep_Item (N); - end if; - end loop; - - return Empty; - end Get_Rep_Pragma; - ---------------- -- Initialize -- ---------------- --- 2765,2770 ---- *************** package body Sem_Ch13 is *** 2845,2851 **** return Id = Attribute_Input or else Id = Attribute_Output or else Id = Attribute_Read ! or else Id = Attribute_Write; end; end if; end Is_Operational_Item; --- 2790,2797 ---- return Id = Attribute_Input or else Id = Attribute_Output or else Id = Attribute_Read ! or else Id = Attribute_Write ! or else Id = Attribute_External_Tag; end; end if; end Is_Operational_Item; *************** package body Sem_Ch13 is *** 2868,2873 **** --- 2814,2820 ---- B : Uint; S : Nat; Ancest : Entity_Id; + R_Typ : constant Entity_Id := Root_Type (T); begin -- If bad type, return 0 *************** package body Sem_Ch13 is *** 2879,2885 **** -- need to know such a size, but this routine may be called with a -- generic type as part of normal processing. ! elsif Is_Generic_Type (Root_Type (T)) then return 0; -- Access types --- 2826,2834 ---- -- need to know such a size, but this routine may be called with a -- generic type as part of normal processing. ! elsif Is_Generic_Type (R_Typ) ! or else R_Typ = Any_Type ! then return 0; -- Access types *************** package body Sem_Ch13 is *** 2890,2896 **** -- Floating-point types elsif Is_Floating_Point_Type (T) then ! return UI_To_Int (Esize (Root_Type (T))); -- Discrete types --- 2839,2845 ---- -- Floating-point types elsif Is_Floating_Point_Type (T) then ! return UI_To_Int (Esize (R_Typ)); -- Discrete types *************** package body Sem_Ch13 is *** 3057,3092 **** Nam : Name_Id) is Loc : constant Source_Ptr := Sloc (N); ! Subp_Id : Entity_Id := Make_Defining_Identifier (Loc, Nam); Subp_Decl : Node_Id; F : Entity_Id; Etyp : Entity_Id; ! begin ! F := First_Formal (Subp); ! Etyp := Etype (Subp); ! Subp_Decl := ! Make_Subprogram_Renaming_Declaration (Loc, ! Specification => ! Make_Function_Specification (Loc, ! Defining_Unit_Name => Subp_Id, ! Parameter_Specifications => ! New_List ( ! Make_Parameter_Specification (Loc, ! Defining_Identifier => ! Make_Defining_Identifier (Loc, Name_S), ! Parameter_Type => ! Make_Access_Definition (Loc, ! Subtype_Mark => ! New_Reference_To ( ! Designated_Type (Etype (F)), Loc)))), ! Subtype_Mark => ! New_Reference_To (Etyp, Loc)), ! Name => New_Reference_To (Subp, Loc)); if Is_Tagged_Type (Ent) and then not Is_Limited_Type (Ent) then Set_TSS (Base_Type (Ent), Subp_Id); --- 3006,3063 ---- Nam : Name_Id) is Loc : constant Source_Ptr := Sloc (N); ! Subp_Id : Entity_Id; Subp_Decl : Node_Id; F : Entity_Id; Etyp : Entity_Id; ! function Build_Spec return Node_Id; ! -- Used for declaration and renaming declaration, so that this is ! -- treated as a renaming_as_body. ! ---------------- ! -- Build_Spec -- ! ---------------- ! function Build_Spec return Node_Id is ! begin ! Subp_Id := Make_Defining_Identifier (Loc, Nam); ! return ! Make_Function_Specification (Loc, ! Defining_Unit_Name => Subp_Id, ! Parameter_Specifications => ! New_List ( ! Make_Parameter_Specification (Loc, ! Defining_Identifier => ! Make_Defining_Identifier (Loc, Name_S), ! Parameter_Type => ! Make_Access_Definition (Loc, ! Subtype_Mark => ! New_Reference_To ( ! Designated_Type (Etype (F)), Loc)))), ! Subtype_Mark => ! New_Reference_To (Etyp, Loc)); ! end Build_Spec; ! ! -- Start of processing for New_Stream_Function ! ! begin ! F := First_Formal (Subp); ! Etyp := Etype (Subp); ! ! if not Is_Tagged_Type (Ent) then ! Subp_Decl := ! Make_Subprogram_Declaration (Loc, ! Specification => Build_Spec); ! Insert_Action (N, Subp_Decl); ! end if; ! ! Subp_Decl := ! Make_Subprogram_Renaming_Declaration (Loc, ! Specification => Build_Spec, ! Name => New_Reference_To (Subp, Loc)); if Is_Tagged_Type (Ent) and then not Is_Limited_Type (Ent) then Set_TSS (Base_Type (Ent), Subp_Id); *************** package body Sem_Ch13 is *** 3109,3147 **** Out_P : Boolean := False) is Loc : constant Source_Ptr := Sloc (N); ! Subp_Id : Entity_Id := Make_Defining_Identifier (Loc, Nam); Subp_Decl : Node_Id; F : Entity_Id; Etyp : Entity_Id; begin F := First_Formal (Subp); Etyp := Etype (Next_Formal (F)); Subp_Decl := Make_Subprogram_Renaming_Declaration (Loc, ! Specification => ! ! Make_Procedure_Specification (Loc, ! Defining_Unit_Name => Subp_Id, ! Parameter_Specifications => ! New_List ( ! Make_Parameter_Specification (Loc, ! Defining_Identifier => ! Make_Defining_Identifier (Loc, Name_S), ! Parameter_Type => ! Make_Access_Definition (Loc, ! Subtype_Mark => ! New_Reference_To ( ! Designated_Type (Etype (F)), Loc))), ! ! Make_Parameter_Specification (Loc, ! Defining_Identifier => ! Make_Defining_Identifier (Loc, Name_V), ! Out_Present => Out_P, ! Parameter_Type => ! New_Reference_To (Etyp, Loc)))), ! Name => New_Reference_To (Subp, Loc)); if Is_Tagged_Type (Ent) and then not Is_Limited_Type (Ent) then Set_TSS (Base_Type (Ent), Subp_Id); --- 3080,3137 ---- Out_P : Boolean := False) is Loc : constant Source_Ptr := Sloc (N); ! Subp_Id : Entity_Id; Subp_Decl : Node_Id; F : Entity_Id; Etyp : Entity_Id; + function Build_Spec return Node_Id; + -- Used for declaration and renaming declaration, so that this is + -- treated as a renaming_as_body. + + function Build_Spec return Node_Id is + begin + Subp_Id := Make_Defining_Identifier (Loc, Nam); + + return + Make_Procedure_Specification (Loc, + Defining_Unit_Name => Subp_Id, + Parameter_Specifications => + New_List ( + Make_Parameter_Specification (Loc, + Defining_Identifier => + Make_Defining_Identifier (Loc, Name_S), + Parameter_Type => + Make_Access_Definition (Loc, + Subtype_Mark => + New_Reference_To ( + Designated_Type (Etype (F)), Loc))), + + Make_Parameter_Specification (Loc, + Defining_Identifier => + Make_Defining_Identifier (Loc, Name_V), + Out_Present => Out_P, + Parameter_Type => + New_Reference_To (Etyp, Loc)))); + end Build_Spec; + + -- Start of processing for New_Stream_Function + begin F := First_Formal (Subp); Etyp := Etype (Next_Formal (F)); + if not Is_Tagged_Type (Ent) then + Subp_Decl := + Make_Subprogram_Declaration (Loc, + Specification => Build_Spec); + Insert_Action (N, Subp_Decl); + end if; + Subp_Decl := Make_Subprogram_Renaming_Declaration (Loc, ! Specification => Build_Spec, ! Name => New_Reference_To (Subp, Loc)); if Is_Tagged_Type (Ent) and then not Is_Limited_Type (Ent) then Set_TSS (Base_Type (Ent), Subp_Id); *************** package body Sem_Ch13 is *** 3172,3180 **** return Boolean is begin ! -- Cannot apply rep items to generic types ! if Is_Type (T) and then Is_Generic_Type (Root_Type (T)) then Error_Msg_N --- 3162,3174 ---- return Boolean is begin ! -- Cannot apply rep items that are not operational items ! -- to generic types ! if Is_Operational_Item (N) then ! return False; ! ! elsif Is_Type (T) and then Is_Generic_Type (Root_Type (T)) then Error_Msg_N *************** package body Sem_Ch13 is *** 3195,3201 **** -- illegal but stream attributes and Convention pragmas are correct. elsif Has_Private_Component (T) then ! if (Nkind (N) = N_Pragma or else Is_Operational_Item (N)) then return False; else Error_Msg_N --- 3189,3195 ---- -- illegal but stream attributes and Convention pragmas are correct. elsif Has_Private_Component (T) then ! if Nkind (N) = N_Pragma then return False; else Error_Msg_N *************** package body Sem_Ch13 is *** 3490,3496 **** if Lo < 0 then if Lo >= -Uint_2**07 and then Hi < Uint_2**07 then ! Sz := 8; elsif Lo >= -Uint_2**15 and then Hi < Uint_2**15 then Sz := 16; --- 3484,3490 ---- if Lo < 0 then if Lo >= -Uint_2**07 and then Hi < Uint_2**07 then ! Sz := Standard_Character_Size; -- May be > 8 on some targets elsif Lo >= -Uint_2**15 and then Hi < Uint_2**15 then Sz := 16; *************** package body Sem_Ch13 is *** 3504,3510 **** else if Hi < Uint_2**08 then ! Sz := 8; elsif Hi < Uint_2**16 then Sz := 16; --- 3498,3504 ---- else if Hi < Uint_2**08 then ! Sz := Standard_Character_Size; -- May be > 8 on some targets elsif Hi < Uint_2**16 then Sz := 16; *************** package body Sem_Ch13 is *** 3635,3641 **** -- use the official RM size instead of Esize. See description -- in Einfo "Handling of Type'Size Values" for details. ! if Errors_Detected = 0 and then Known_Static_RM_Size (Source) and then Known_Static_RM_Size (Target) then --- 3629,3635 ---- -- use the official RM size instead of Esize. See description -- in Einfo "Handling of Type'Size Values" for details. ! if Serious_Errors_Detected = 0 and then Known_Static_RM_Size (Source) and then Known_Static_RM_Size (Target) then *************** package body Sem_Ch13 is *** 3712,3718 **** -- If both types are access types, we need to check the alignment. -- If the alignment of both is specified, we can do it here. ! if Errors_Detected = 0 and then Ekind (Source) in Access_Kind and then Ekind (Target) in Access_Kind and then Target_Strict_Alignment --- 3706,3712 ---- -- If both types are access types, we need to check the alignment. -- If the alignment of both is specified, we can do it here. ! if Serious_Errors_Detected = 0 and then Ekind (Source) in Access_Kind and then Ekind (Target) in Access_Kind and then Target_Strict_Alignment diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch13.ads gcc-3.3/gcc/ada/sem_ch13.ads *** gcc-3.2.3/gcc/ada/sem_ch13.ads 2002-05-04 03:29:01.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch13.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** *** 26,32 **** -- -- ------------------------------------------------------------------------------ - with Snames; use Snames; with Types; use Types; with Uintp; use Uintp; --- 25,30 ---- *************** package Sem_Ch13 is *** 80,99 **** -- way to meet the requirement. If the type is currently biased, then -- this biased size is used in the initial check, and Biased is False. - function Get_Rep_Pragma (E : Entity_Id; Nam : Name_Id) return Node_Id; - -- Searches the Rep_Item chain for the given entity E, for an instance - -- of a representation pragma with the given name Nam. If found then - -- the value returned is the N_Pragma node, otherwise Empty is returned. - - function Get_Attribute_Definition_Clause - (E : Entity_Id; - Id : Attribute_Id) - return Node_Id; - -- Searches the Rep_Item chain for a given entity E, for an instance - -- of an attribute definition clause with the given attibute Id Id. If - -- found, the value returned is the N_Attribute_Definition_Clause node, - -- otherwise Empty is returned. - procedure Record_Rep_Item (T : Entity_Id; N : Node_Id); -- N is the node for either a representation pragma or an attribute -- definition clause that applies to type T. This procedure links --- 78,83 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch2.adb gcc-3.3/gcc/ada/sem_ch2.adb *** gcc-3.2.3/gcc/ada/sem_ch2.adb 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch2.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1999, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, 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- -- *************** *** 27,32 **** --- 26,32 ---- ------------------------------------------------------------------------------ with Atree; use Atree; + with Errout; use Errout; with Opt; use Opt; with Restrict; use Restrict; with Sem_Ch8; use Sem_Ch8; *************** package body Sem_Ch2 is *** 64,70 **** procedure Analyze_Identifier (N : Node_Id) is begin ! Find_Direct_Name (N); end Analyze_Identifier; ----------------------------- --- 64,80 ---- procedure Analyze_Identifier (N : Node_Id) is begin ! -- Ignore call if prior errors, and identifier has no name, since ! -- this is the result of some kind of previous error generating a ! -- junk identifier. ! ! if Chars (N) in Error_Name_Or_No_Name ! and then Total_Errors_Detected /= 0 ! then ! return; ! else ! Find_Direct_Name (N); ! end if; end Analyze_Identifier; ----------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch2.ads gcc-3.3/gcc/ada/sem_ch2.ads *** gcc-3.2.3/gcc/ada/sem_ch2.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch2.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch3.adb gcc-3.3/gcc/ada/sem_ch3.adb *** gcc-3.2.3/gcc/ada/sem_ch3.adb 2002-05-04 03:29:01.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch3.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.13.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Sem_Ch3 is *** 248,255 **** function Build_Scalar_Bound (Bound : Node_Id; Par_T : Entity_Id; ! Der_T : Entity_Id; ! Loc : Source_Ptr) return Node_Id; -- The bounds of a derived scalar type are conversions of the bounds of -- the parent type. Optimize the representation if the bounds are literals. --- 247,253 ---- function Build_Scalar_Bound (Bound : Node_Id; Par_T : Entity_Id; ! Der_T : Entity_Id) return Node_Id; -- The bounds of a derived scalar type are conversions of the bounds of -- the parent type. Optimize the representation if the bounds are literals. *************** package body Sem_Ch3 is *** 371,379 **** -- Empty for Def_Id indicates that an implicit type must be created, but -- creation is delayed (and must be done by this procedure) because other -- subsidiary implicit types must be created first (which is why Def_Id ! -- is an in/out parameter). Related_Nod gives the place where this type has ! -- to be inserted in the tree. The Related_Id and Suffix parameters are ! -- used to build the associated Implicit type name. procedure Constrain_Concurrent (Def_Id : in out Entity_Id; --- 369,379 ---- -- Empty for Def_Id indicates that an implicit type must be created, but -- creation is delayed (and must be done by this procedure) because other -- subsidiary implicit types must be created first (which is why Def_Id ! -- is an in/out parameter). The second parameter is a subtype indication ! -- node for the constrained array to be created (e.g. something of the ! -- form string (1 .. 10)). Related_Nod gives the place where this type ! -- has to be inserted in the tree. The Related_Id and Suffix parameters ! -- are used to build the associated Implicit type name. procedure Constrain_Concurrent (Def_Id : in out Entity_Id; *************** package body Sem_Ch3 is *** 407,416 **** -- When constraining a protected type or task type with discriminants, -- constrain the corresponding record with the same discriminant values. ! procedure Constrain_Decimal ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id); -- Constrain a decimal fixed point type with a digits constraint and/or a -- range constraint, and build E_Decimal_Fixed_Point_Subtype entity. --- 407,413 ---- -- When constraining a protected type or task type with discriminants, -- constrain the corresponding record with the same discriminant values. ! procedure Constrain_Decimal (Def_Id : Node_Id; S : Node_Id); -- Constrain a decimal fixed point type with a digits constraint and/or a -- range constraint, and build E_Decimal_Fixed_Point_Subtype entity. *************** package body Sem_Ch3 is *** 426,443 **** -- Constrain_Concurrent. See Build_Discrimated_Subtype for an explanation -- of For_Access. ! procedure Constrain_Enumeration ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id); -- Constrain an enumeration type with a range constraint. This is -- identical to Constrain_Integer, but for the Ekind of the -- resulting subtype. ! procedure Constrain_Float ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id); -- Constrain a floating point type with either a digits constraint -- and/or a range constraint, building a E_Floating_Point_Subtype. --- 423,434 ---- -- Constrain_Concurrent. See Build_Discrimated_Subtype for an explanation -- of For_Access. ! procedure Constrain_Enumeration (Def_Id : Node_Id; S : Node_Id); -- Constrain an enumeration type with a range constraint. This is -- identical to Constrain_Integer, but for the Ekind of the -- resulting subtype. ! procedure Constrain_Float (Def_Id : Node_Id; S : Node_Id); -- Constrain a floating point type with either a digits constraint -- and/or a range constraint, building a E_Floating_Point_Subtype. *************** package body Sem_Ch3 is *** 454,469 **** -- unconstrained array. The Related_Id and Suffix parameters are used to -- build the associated Implicit type name. ! procedure Constrain_Integer ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id); -- Build subtype of a signed or modular integer type. ! procedure Constrain_Ordinary_Fixed ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id); -- Constrain an ordinary fixed point type with a range constraint, and -- build an E_Ordinary_Fixed_Point_Subtype entity. --- 445,454 ---- -- unconstrained array. The Related_Id and Suffix parameters are used to -- build the associated Implicit type name. ! procedure Constrain_Integer (Def_Id : Node_Id; S : Node_Id); -- Build subtype of a signed or modular integer type. ! procedure Constrain_Ordinary_Fixed (Def_Id : Node_Id; S : Node_Id); -- Constrain an ordinary fixed point type with a range constraint, and -- build an E_Ordinary_Fixed_Point_Subtype entity. *************** package body Sem_Ch3 is *** 624,629 **** --- 609,623 ---- -- type. It is provided so that its Has_Task flag can be set if any of -- the component have Has_Task set. + procedure Replace_Components (Typ : Entity_Id; Decl : Node_Id); + -- Subsidiary to Build_Derived_Record_Type. For untagged records, we + -- build a copy of the declaration tree of the parent, and we create + -- independently the list of components for the derived type. Semantic + -- information uses the component entities, but record representation + -- clauses are validated on the declaration tree. This procedure replaces + -- discriminants and components in the declaration with those that have + -- been created by Inherit_Components. + procedure Set_Fixed_Range (E : Entity_Id; Loc : Source_Ptr; *************** package body Sem_Ch3 is *** 634,643 **** -- for the constructed range. See body for further details. procedure Set_Scalar_Range_For_Subtype ! (Def_Id : Entity_Id; ! R : Node_Id; ! Subt : Entity_Id; ! Related_Nod : Node_Id); -- This routine is used to set the scalar range field for a subtype -- given Def_Id, the entity for the subtype, and R, the range expression -- for the scalar range. Subt provides the parent subtype to be used --- 628,636 ---- -- for the constructed range. See body for further details. procedure Set_Scalar_Range_For_Subtype ! (Def_Id : Entity_Id; ! R : Node_Id; ! Subt : Entity_Id); -- This routine is used to set the scalar range field for a subtype -- given Def_Id, the entity for the subtype, and R, the range expression -- for the scalar range. Subt provides the parent subtype to be used *************** package body Sem_Ch3 is *** 723,729 **** if Present (Formals) then New_Scope (Desig_Type); ! Process_Formals (Desig_Type, Formals, Parent (T_Def)); -- A bit of a kludge here, End_Scope requires that the parent -- pointer be set to something reasonable, but Itypes don't --- 716,722 ---- if Present (Formals) then New_Scope (Desig_Type); ! Process_Formals (Formals, Parent (T_Def)); -- A bit of a kludge here, End_Scope requires that the parent -- pointer be set to something reasonable, but Itypes don't *************** package body Sem_Ch3 is *** 1351,1363 **** Constant_Redeclaration (Id, N, T); Generate_Reference (Prev_Entity, Id, 'c'); ! ! -- If in main unit, set as referenced, so we do not complain about ! -- the full declaration being an unreferenced entity. ! ! if In_Extended_Main_Source_Unit (Id) then ! Set_Referenced (Id); ! end if; if Error_Posted (N) then -- Type mismatch or illegal redeclaration, Do not analyze --- 1344,1350 ---- Constant_Redeclaration (Id, N, T); Generate_Reference (Prev_Entity, Id, 'c'); ! Set_Completion_Referenced (Id); if Error_Posted (N) then -- Type mismatch or illegal redeclaration, Do not analyze *************** package body Sem_Ch3 is *** 1389,1401 **** -- If deferred constant, make sure context is appropriate. We detect -- a deferred constant as a constant declaration with no expression. if Constant_Present (N) and then No (E) then ! if not Is_Package (Current_Scope) ! or else In_Private_Part (Current_Scope) ! then Error_Msg_N ("invalid context for deferred constant declaration", N); Set_Constant_Present (N, False); --- 1376,1388 ---- -- If deferred constant, make sure context is appropriate. We detect -- a deferred constant as a constant declaration with no expression. + -- A deferred constant can appear in a package body if its completion + -- is by means of an interface pragma. if Constant_Present (N) and then No (E) then ! if not Is_Package (Current_Scope) then Error_Msg_N ("invalid context for deferred constant declaration", N); Set_Constant_Present (N, False); *************** package body Sem_Ch3 is *** 1810,1815 **** --- 1797,1836 ---- Check_Restriction (No_Task_Hierarchy, N); Check_Potentially_Blocking_Operation (N); end if; + + -- A rather specialized test. If we see two tasks being declared + -- of the same type in the same object declaration, and the task + -- has an entry with an address clause, we know that program error + -- will be raised at run-time since we can't have two tasks with + -- entries at the same address. + + if Is_Task_Type (Etype (Id)) + and then More_Ids (N) + then + declare + E : Entity_Id; + + begin + E := First_Entity (Etype (Id)); + while Present (E) loop + if Ekind (E) = E_Entry + and then Present (Get_Attribute_Definition_Clause + (E, Attribute_Address)) + then + Error_Msg_N + ("?more than one task with same entry address", N); + Error_Msg_N + ("\?Program_Error will be raised at run time", N); + Insert_Action (N, + Make_Raise_Program_Error (Loc, + Reason => PE_Duplicated_Entry_Address)); + exit; + end if; + + Next_Entity (E); + end loop; + end; + end if; end if; -- Some simple constant-propagation: if the expression is a constant *************** package body Sem_Ch3 is *** 1879,1884 **** --- 1900,1907 ---- -- of the others choice will occur as part of the processing of the parent procedure Analyze_Others_Choice (N : Node_Id) is + pragma Warnings (Off, N); + begin null; end Analyze_Others_Choice; *************** package body Sem_Ch3 is *** 2179,2185 **** end if; when Concurrent_Kind => - Set_Ekind (Id, Subtype_Kind (Ekind (T))); Set_Corresponding_Record_Type (Id, Corresponding_Record_Type (T)); --- 2202,2207 ---- *************** package body Sem_Ch3 is *** 2504,2516 **** -- and the second parameter provides the reference location. Generate_Reference (T, T, 'c'); ! ! -- If in main unit, set as referenced, so we do not complain about ! -- the full declaration being an unreferenced entity. ! ! if In_Extended_Main_Source_Unit (Def_Id) then ! Set_Referenced (Def_Id); ! end if; -- For completion of incomplete type, process incomplete dependents -- and always mark the full type as referenced (it is the incomplete --- 2526,2532 ---- -- and the second parameter provides the reference location. Generate_Reference (T, T, 'c'); ! Set_Completion_Referenced (Def_Id); -- For completion of incomplete type, process incomplete dependents -- and always mark the full type as referenced (it is the incomplete *************** package body Sem_Ch3 is *** 2519,2531 **** elsif Ekind (Prev) = E_Incomplete_Type then Process_Incomplete_Dependents (N, T, Prev); Generate_Reference (Prev, Def_Id, 'c'); ! ! -- If in main unit, set as referenced, so we do not complain about ! -- the full declaration being an unreferenced entity. ! ! if In_Extended_Main_Source_Unit (Def_Id) then ! Set_Referenced (Def_Id); ! end if; -- If not private type or incomplete type completion, this is a real -- definition of a new entity, so record it. --- 2535,2541 ---- elsif Ekind (Prev) = E_Incomplete_Type then Process_Incomplete_Dependents (N, T, Prev); Generate_Reference (Prev, Def_Id, 'c'); ! Set_Completion_Referenced (Def_Id); -- If not private type or incomplete type completion, this is a real -- definition of a new entity, so record it. *************** package body Sem_Ch3 is *** 2706,2718 **** Set_First_Index (Implicit_Base, First_Index (T)); Set_Component_Type (Implicit_Base, Element_Type); ! Set_Has_Task (Implicit_Base, Has_Task (Element_Type)); Set_Component_Size (Implicit_Base, Uint_0); ! Set_Has_Controlled_Component (Implicit_Base, ! Has_Controlled_Component (Element_Type) ! or else Is_Controlled (Element_Type)); ! Set_Finalize_Storage_Only (Implicit_Base, ! Finalize_Storage_Only (Element_Type)); -- Unconstrained array case --- 2716,2731 ---- Set_First_Index (Implicit_Base, First_Index (T)); Set_Component_Type (Implicit_Base, Element_Type); ! Set_Has_Task (Implicit_Base, Has_Task (Element_Type)); Set_Component_Size (Implicit_Base, Uint_0); ! Set_Has_Controlled_Component ! (Implicit_Base, Has_Controlled_Component ! (Element_Type) ! or else ! Is_Controlled (Element_Type)); ! Set_Finalize_Storage_Only ! (Implicit_Base, Finalize_Storage_Only ! (Element_Type)); -- Unconstrained array case *************** package body Sem_Ch3 is *** 2725,2739 **** Set_Is_Constrained (T, False); Set_First_Index (T, First (Subtype_Marks (Def))); Set_Has_Delayed_Freeze (T, True); ! Set_Has_Task (T, Has_Task (Element_Type)); ! Set_Has_Controlled_Component (T, ! Has_Controlled_Component (Element_Type) ! or else Is_Controlled (Element_Type)); ! Set_Finalize_Storage_Only (T, ! Finalize_Storage_Only (Element_Type)); end if; ! Set_Component_Type (T, Element_Type); if Aliased_Present (Def) then Set_Has_Aliased_Components (Etype (T)); --- 2738,2753 ---- Set_Is_Constrained (T, False); Set_First_Index (T, First (Subtype_Marks (Def))); Set_Has_Delayed_Freeze (T, True); ! Set_Has_Task (T, Has_Task (Element_Type)); ! Set_Has_Controlled_Component (T, Has_Controlled_Component ! (Element_Type) ! or else ! Is_Controlled (Element_Type)); ! Set_Finalize_Storage_Only (T, Finalize_Storage_Only ! (Element_Type)); end if; ! Set_Component_Type (Base_Type (T), Element_Type); if Aliased_Present (Def) then Set_Has_Aliased_Components (Etype (T)); *************** package body Sem_Ch3 is *** 2742,2751 **** Priv := Private_Component (Element_Type); if Present (Priv) then ! -- Check for circular definitions. if Priv = Any_Type then - Set_Component_Type (T, Any_Type); Set_Component_Type (Etype (T), Any_Type); -- There is a gap in the visiblity of operations on the composite --- 2756,2765 ---- Priv := Private_Component (Element_Type); if Present (Priv) then ! ! -- Check for circular definitions if Priv = Any_Type then Set_Component_Type (Etype (T), Any_Type); -- There is a gap in the visiblity of operations on the composite *************** package body Sem_Ch3 is *** 2834,2845 **** begin Copy_Node (Pbase, Ibase); ! Set_Chars (Ibase, Svg_Chars); ! Set_Next_Entity (Ibase, Svg_Next_E); ! Set_Sloc (Ibase, Sloc (Derived_Type)); ! Set_Scope (Ibase, Scope (Derived_Type)); ! Set_Freeze_Node (Ibase, Empty); ! Set_Is_Frozen (Ibase, False); Set_Etype (Ibase, Pbase); Set_Etype (Derived_Type, Ibase); --- 2848,2861 ---- begin Copy_Node (Pbase, Ibase); ! Set_Chars (Ibase, Svg_Chars); ! Set_Next_Entity (Ibase, Svg_Next_E); ! Set_Sloc (Ibase, Sloc (Derived_Type)); ! Set_Scope (Ibase, Scope (Derived_Type)); ! Set_Freeze_Node (Ibase, Empty); ! Set_Is_Frozen (Ibase, False); ! Set_Comes_From_Source (Ibase, False); ! Set_Is_First_Subtype (Ibase, False); Set_Etype (Ibase, Pbase); Set_Etype (Derived_Type, Ibase); *************** package body Sem_Ch3 is *** 3293,3301 **** begin if Nkind (R) = N_Range then Hi := Build_Scalar_Bound ! (High_Bound (R), Parent_Type, Implicit_Base, Loc); Lo := Build_Scalar_Bound ! (Low_Bound (R), Parent_Type, Implicit_Base, Loc); else -- Constraint is a Range attribute. Replace with the --- 3309,3317 ---- begin if Nkind (R) = N_Range then Hi := Build_Scalar_Bound ! (High_Bound (R), Parent_Type, Implicit_Base); Lo := Build_Scalar_Bound ! (Low_Bound (R), Parent_Type, Implicit_Base); else -- Constraint is a Range attribute. Replace with the *************** package body Sem_Ch3 is *** 3324,3334 **** Hi := Build_Scalar_Bound (Type_High_Bound (Parent_Type), ! Parent_Type, Implicit_Base, Loc); Lo := Build_Scalar_Bound (Type_Low_Bound (Parent_Type), ! Parent_Type, Implicit_Base, Loc); end if; Rang_Expr := --- 3340,3350 ---- Hi := Build_Scalar_Bound (Type_High_Bound (Parent_Type), ! Parent_Type, Implicit_Base); Lo := Build_Scalar_Bound (Type_Low_Bound (Parent_Type), ! Parent_Type, Implicit_Base); end if; Rang_Expr := *************** package body Sem_Ch3 is *** 3560,3568 **** -------------------------------- procedure Build_Derived_Private_Type ! (N : Node_Id; ! Parent_Type : Entity_Id; ! Derived_Type : Entity_Id; Is_Completion : Boolean; Derive_Subps : Boolean := True) is --- 3576,3584 ---- -------------------------------- procedure Build_Derived_Private_Type ! (N : Node_Id; ! Parent_Type : Entity_Id; ! Derived_Type : Entity_Id; Is_Completion : Boolean; Derive_Subps : Boolean := True) is *************** package body Sem_Ch3 is *** 3579,3584 **** --- 3595,3604 ---- -- Copy derived type declaration, replace parent with its full view, -- and analyze new declaration. + -------------------- + -- Copy_And_Build -- + -------------------- + procedure Copy_And_Build is Full_N : Node_Id; *************** package body Sem_Ch3 is *** 3729,3746 **** return; end if; ! -- Inherit the discriminants of the full view, but ! -- keep the proper parent type. ! -- ??? this looks wrong, we are replacing (and thus, ! -- erasing) the partial view! -- In any case, the primitive operations are inherited from -- the parent type, not from the internal full view. - Build_Derived_Record_Type - (N, Full_View (Parent_Type), Derived_Type, - Derive_Subps => False); Set_Etype (Base_Type (Derived_Type), Base_Type (Parent_Type)); if Derive_Subps then --- 3749,3782 ---- return; end if; ! -- If full view of parent is a record type, Build full view as ! -- a derivation from the parent's full view. Partial view remains ! -- private. ! if not Is_Private_Type (Full_View (Parent_Type)) then ! Full_Der := Make_Defining_Identifier (Sloc (Derived_Type), ! Chars (Derived_Type)); ! Set_Is_Itype (Full_Der); ! Set_Has_Private_Declaration (Full_Der); ! Set_Has_Private_Declaration (Derived_Type); ! Set_Associated_Node_For_Itype (Full_Der, N); ! Set_Parent (Full_Der, Parent (Derived_Type)); ! Set_Full_View (Derived_Type, Full_Der); ! ! Full_P := Full_View (Parent_Type); ! Exchange_Declarations (Parent_Type); ! Copy_And_Build; ! Exchange_Declarations (Full_P); ! ! else ! Build_Derived_Record_Type ! (N, Full_View (Parent_Type), Derived_Type, ! Derive_Subps => False); ! end if; -- In any case, the primitive operations are inherited from -- the parent type, not from the internal full view. Set_Etype (Base_Type (Derived_Type), Base_Type (Parent_Type)); if Derive_Subps then *************** package body Sem_Ch3 is *** 3748,3755 **** end if; else ! ! -- Untagged type, No discriminants on either view. if Nkind (Subtype_Indication (Type_Definition (N))) = N_Subtype_Indication --- 3784,3790 ---- end if; else ! -- Untagged type, No discriminants on either view if Nkind (Subtype_Indication (Type_Definition (N))) = N_Subtype_Indication *************** package body Sem_Ch3 is *** 3767,3783 **** end if; Set_Girder_Constraint (Derived_Type, No_Elist); ! Set_Is_Constrained (Derived_Type, Is_Constrained (Parent_Type)); ! Set_Is_Controlled (Derived_Type, Is_Controlled (Parent_Type)); ! Set_Has_Controlled_Component (Derived_Type, ! Has_Controlled_Component (Parent_Type)); ! -- Direct controlled types do not inherit the Finalize_Storage_Only ! -- flag. if not Is_Controlled (Parent_Type) then ! Set_Finalize_Storage_Only (Derived_Type, ! Finalize_Storage_Only (Parent_Type)); end if; -- Construct the implicit full view by deriving from full --- 3802,3818 ---- end if; Set_Girder_Constraint (Derived_Type, No_Elist); ! Set_Is_Constrained (Derived_Type, Is_Constrained (Parent_Type)); ! Set_Is_Controlled (Derived_Type, Is_Controlled (Parent_Type)); ! Set_Has_Controlled_Component ! (Derived_Type, Has_Controlled_Component ! (Parent_Type)); ! -- Direct controlled types do not inherit Finalize_Storage_Only flag if not Is_Controlled (Parent_Type) then ! Set_Finalize_Storage_Only ! (Base_Type (Derived_Type), Finalize_Storage_Only (Parent_Type)); end if; -- Construct the implicit full view by deriving from full *************** package body Sem_Ch3 is *** 3912,3922 **** -- type T (...) is new R (...) [with ...]; -- The representation clauses of T can specify a completely different ! -- record layout from R's. Hence a same component can be placed in two very ! -- different positions in objects of type T and R. If R and T are tagged ! -- types, representation clauses for T can only specify the layout of non ! -- inherited components, thus components that are common in R and T have ! -- the same position in objects of type R or T. -- This has two implications. The first is that the entire tree for R's -- declaration needs to be copied for T in the untagged case, so that --- 3947,3957 ---- -- type T (...) is new R (...) [with ...]; -- The representation clauses of T can specify a completely different ! -- record layout from R's. Hence the same component can be placed in ! -- two very different positions in objects of type T and R. If R and T ! -- are tagged types, representation clauses for T can only specify the ! -- layout of non inherited components, thus components that are common ! -- in R and T have the same position in objects of type R and T. -- This has two implications. The first is that the entire tree for R's -- declaration needs to be copied for T in the untagged case, so that *************** package body Sem_Ch3 is *** 4364,4380 **** New_Indic : Node_Id; Is_Tagged : constant Boolean := Is_Tagged_Type (Parent_Type); ! Discriminant_Specs : constant Boolean ! := Present (Discriminant_Specifications (N)); ! Private_Extension : constant Boolean ! := (Nkind (N) = N_Private_Extension_Declaration); Constraint_Present : Boolean; Inherit_Discrims : Boolean := False; ! Save_Etype : Entity_Id; ! Save_Discr_Constr : Elist_Id; ! Save_Next_Entity : Entity_Id; begin if Ekind (Parent_Type) = E_Record_Type_With_Private --- 4399,4415 ---- New_Indic : Node_Id; Is_Tagged : constant Boolean := Is_Tagged_Type (Parent_Type); ! Discriminant_Specs : constant Boolean := ! Present (Discriminant_Specifications (N)); ! Private_Extension : constant Boolean := ! (Nkind (N) = N_Private_Extension_Declaration); Constraint_Present : Boolean; Inherit_Discrims : Boolean := False; ! Save_Etype : Entity_Id; ! Save_Discr_Constr : Elist_Id; ! Save_Next_Entity : Entity_Id; begin if Ekind (Parent_Type) = E_Record_Type_With_Private *************** package body Sem_Ch3 is *** 4827,4838 **** Set_Has_Primitive_Operations (Derived_Type, Has_Primitive_Operations (Parent_Base)); ! -- Direct controlled types do not inherit the Finalize_Storage_Only ! -- flag. if not Is_Controlled (Parent_Type) then ! Set_Finalize_Storage_Only (Derived_Type, ! Finalize_Storage_Only (Parent_Type)); end if; -- Set fields for private derived types. --- 4862,4872 ---- Set_Has_Primitive_Operations (Derived_Type, Has_Primitive_Operations (Parent_Base)); ! -- Direct controlled types do not inherit Finalize_Storage_Only flag if not Is_Controlled (Parent_Type) then ! Set_Finalize_Storage_Only ! (Derived_Type, Finalize_Storage_Only (Parent_Type)); end if; -- Set fields for private derived types. *************** package body Sem_Ch3 is *** 4953,4958 **** --- 4987,4993 ---- (Derived_Type, Save_Discr_Constr); Set_Girder_Constraint (Derived_Type, Expand_To_Girder_Constraint (Parent_Base, Discs)); + Replace_Components (Derived_Type, New_Decl); end if; -- Insert the new derived type declaration *************** package body Sem_Ch3 is *** 5447,5453 **** is Has_Discrs : constant Boolean := Has_Discriminants (T); Constrained : constant Boolean ! := (Has_Discrs and then not Is_Empty_Elmt_List (Elist)) or else Is_Constrained (T); begin --- 5482,5490 ---- is Has_Discrs : constant Boolean := Has_Discriminants (T); Constrained : constant Boolean ! := (Has_Discrs ! and then not Is_Empty_Elmt_List (Elist) ! and then not Is_Class_Wide_Type (T)) or else Is_Constrained (T); begin *************** package body Sem_Ch3 is *** 5544,5552 **** function Build_Scalar_Bound (Bound : Node_Id; Par_T : Entity_Id; ! Der_T : Entity_Id; ! Loc : Source_Ptr) ! return Node_Id is New_Bound : Entity_Id; --- 5581,5588 ---- function Build_Scalar_Bound (Bound : Node_Id; Par_T : Entity_Id; ! Der_T : Entity_Id) ! return Node_Id is New_Bound : Entity_Id; *************** package body Sem_Ch3 is *** 5816,5822 **** if not Comes_From_Source (E) then pragma Assert ! (Errors_Detected > 0 or else Subunits_Missing or else not Expander_Active); return; --- 5852,5858 ---- if not Comes_From_Source (E) then pragma Assert ! (Serious_Errors_Detected > 0 or else Subunits_Missing or else not Expander_Active); return; *************** package body Sem_Ch3 is *** 6274,6280 **** Set_Primitive_Operations (Full, Primitive_Operations (Full_Base)); elsif Is_Concurrent_Type (Full_Base) then - if Has_Discriminants (Full) and then Present (Corresponding_Record_Type (Full_Base)) then --- 6310,6315 ---- *************** package body Sem_Ch3 is *** 6304,6309 **** --- 6339,6382 ---- Obj_Def : constant Node_Id := Object_Definition (N); New_T : Entity_Id; + procedure Check_Recursive_Declaration (Typ : Entity_Id); + -- If deferred constant is an access type initialized with an + -- allocator, check whether there is an illegal recursion in the + -- definition, through a default value of some record subcomponent. + -- This is normally detected when generating init_procs, but requires + -- this additional mechanism when expansion is disabled. + + procedure Check_Recursive_Declaration (Typ : Entity_Id) is + Comp : Entity_Id; + + begin + if Is_Record_Type (Typ) then + Comp := First_Component (Typ); + + while Present (Comp) loop + if Comes_From_Source (Comp) then + if Present (Expression (Parent (Comp))) + and then Is_Entity_Name (Expression (Parent (Comp))) + and then Entity (Expression (Parent (Comp))) = Prev + then + Error_Msg_Sloc := Sloc (Parent (Comp)); + Error_Msg_NE + ("illegal circularity with declaration for&#", + N, Comp); + return; + + elsif Is_Record_Type (Etype (Comp)) then + Check_Recursive_Declaration (Etype (Comp)); + end if; + end if; + + Next_Component (Comp); + end loop; + end if; + end Check_Recursive_Declaration; + + -- Start of processing for Constant_Redeclaration + begin if Nkind (Parent (Prev)) = N_Object_Declaration then if Nkind (Object_Definition *************** package body Sem_Ch3 is *** 6345,6350 **** --- 6418,6424 ---- if Ekind (Prev) /= E_Constant or else Present (Expression (Parent (Prev))) + or else Present (Full_View (Prev)) then Enter_Name (Id); *************** package body Sem_Ch3 is *** 6373,6379 **** Error_Msg_N ("ALIASED required (see declaration#)", N); end if; ! -- Check that placement is in private part if Ekind (Current_Scope) = E_Package and then not In_Private_Part (Current_Scope) --- 6447,6454 ---- Error_Msg_N ("ALIASED required (see declaration#)", N); end if; ! -- Check that placement is in private part and that the incomplete ! -- declaration appeared in the visible part. if Ekind (Current_Scope) = E_Package and then not In_Private_Part (Current_Scope) *************** package body Sem_Ch3 is *** 6381,6386 **** --- 6456,6476 ---- Error_Msg_Sloc := Sloc (Prev); Error_Msg_N ("full constant for declaration#" & " must be in private part", N); + + elsif Ekind (Current_Scope) = E_Package + and then List_Containing (Parent (Prev)) + /= Visible_Declarations + (Specification (Unit_Declaration_Node (Current_Scope))) + then + Error_Msg_N + ("deferred constant must be declared in visible part", + Parent (Prev)); + end if; + + if Is_Access_Type (T) + and then Nkind (Expression (N)) = N_Allocator + then + Check_Recursive_Declaration (Designated_Type (T)); end if; end if; end Constant_Redeclaration; *************** package body Sem_Ch3 is *** 6431,6436 **** --- 6521,6577 ---- return; end if; + if Ekind (T) = E_General_Access_Type + and then Has_Private_Declaration (Desig_Type) + and then In_Open_Scopes (Scope (Desig_Type)) + then + -- Enforce rule that the constraint is illegal if there is + -- an unconstrained view of the designated type. This means + -- that the partial view (either a private type declaration or + -- a derivation from a private type) has no discriminants. + -- (Defect Report 8652/0008, Technical Corrigendum 1, checked + -- by ACATS B371001). + + declare + Pack : Node_Id := Unit_Declaration_Node (Scope (Desig_Type)); + Decls : List_Id; + Decl : Node_Id; + + begin + if Nkind (Pack) = N_Package_Declaration then + Decls := Visible_Declarations (Specification (Pack)); + Decl := First (Decls); + + while Present (Decl) loop + if (Nkind (Decl) = N_Private_Type_Declaration + and then + Chars (Defining_Identifier (Decl)) = + Chars (Desig_Type)) + + or else + (Nkind (Decl) = N_Full_Type_Declaration + and then + Chars (Defining_Identifier (Decl)) = + Chars (Desig_Type) + and then Is_Derived_Type (Desig_Type) + and then + Has_Private_Declaration (Etype (Desig_Type))) + then + if No (Discriminant_Specifications (Decl)) then + Error_Msg_N + ("cannot constrain general access type " & + "if designated type has unconstrained view", S); + end if; + + exit; + end if; + + Next (Decl); + end loop; + end if; + end; + end if; + Constrain_Discriminated_Type (Desig_Subtype, S, Related_Nod, For_Access => True); *************** package body Sem_Ch3 is *** 6560,6566 **** Set_First_Index (Def_Id, First (Constraints (C))); end if; - Set_Component_Type (Def_Id, Component_Type (T)); Set_Is_Constrained (Def_Id, True); Set_Is_Aliased (Def_Id, Is_Aliased (T)); Set_Depends_On_Private (Def_Id, Has_Private_Component (Def_Id)); --- 6701,6706 ---- *************** package body Sem_Ch3 is *** 6621,6627 **** function Is_Discriminant (Expr : Node_Id) return Boolean; -- Returns True if Expr is a discriminant. ! function Get_Value (Discrim : Entity_Id) return Node_Id; -- Find the value of discriminant Discrim in Constraint. ----------------------------------- --- 6761,6767 ---- function Is_Discriminant (Expr : Node_Id) return Boolean; -- Returns True if Expr is a discriminant. ! function Get_Discr_Value (Discrim : Entity_Id) return Node_Id; -- Find the value of discriminant Discrim in Constraint. ----------------------------------- *************** package body Sem_Ch3 is *** 6749,6759 **** Get_Index_Bounds (Old_Index, Lo_Expr, Hi_Expr); if Is_Discriminant (Lo_Expr) then ! Lo_Expr := Get_Value (Lo_Expr); end if; if Is_Discriminant (Hi_Expr) then ! Hi_Expr := Get_Value (Hi_Expr); end if; Range_Node := --- 6889,6899 ---- Get_Index_Bounds (Old_Index, Lo_Expr, Hi_Expr); if Is_Discriminant (Lo_Expr) then ! Lo_Expr := Get_Discr_Value (Lo_Expr); end if; if Is_Discriminant (Hi_Expr) then ! Hi_Expr := Get_Discr_Value (Hi_Expr); end if; Range_Node := *************** package body Sem_Ch3 is *** 6806,6812 **** Expr := Node (Old_Constraint); if Is_Discriminant (Expr) then ! Expr := Get_Value (Expr); end if; Append (New_Copy_Tree (Expr), To => Constr_List); --- 6946,6952 ---- Expr := Node (Old_Constraint); if Is_Discriminant (Expr) then ! Expr := Get_Discr_Value (Expr); end if; Append (New_Copy_Tree (Expr), To => Constr_List); *************** package body Sem_Ch3 is *** 6867,6887 **** return Def_Id; end Build_Subtype; ! --------------- ! -- Get_Value -- ! --------------- ! function Get_Value (Discrim : Entity_Id) return Node_Id is D : Entity_Id := First_Discriminant (Typ); E : Elmt_Id := First_Elmt (Constraints); begin ! while Present (D) loop ! ! -- If we are constraining the subtype of a derived tagged type, ! -- recover the discriminant of the parent, which appears in ! -- the constraint of an inherited component. if D = Entity (Discrim) or else Corresponding_Discriminant (D) = Entity (Discrim) then --- 7007,7030 ---- return Def_Id; end Build_Subtype; ! --------------------- ! -- Get_Discr_Value -- ! --------------------- ! function Get_Discr_Value (Discrim : Entity_Id) return Node_Id is D : Entity_Id := First_Discriminant (Typ); E : Elmt_Id := First_Elmt (Constraints); + G : Elmt_Id; begin ! -- The discriminant may be declared for the type, in which case we ! -- find it by iterating over the list of discriminants. If the ! -- discriminant is inherited from a parent type, it appears as the ! -- corresponding discriminant of the current type. This will be the ! -- case when constraining an inherited component whose constraint is ! -- given by a discriminant of the parent. + while Present (D) loop if D = Entity (Discrim) or else Corresponding_Discriminant (D) = Entity (Discrim) then *************** package body Sem_Ch3 is *** 6892,6901 **** Next_Elmt (E); end loop; -- Something is wrong if we did not find the value raise Program_Error; ! end Get_Value; --------------------- -- Is_Discriminant -- --- 7035,7069 ---- Next_Elmt (E); end loop; + -- The corresponding_Discriminant mechanism is incomplete, because + -- the correspondence between new and old discriminants is not one + -- to one: one new discriminant can constrain several old ones. + -- In that case, scan sequentially the girder_constraint, the list + -- of discriminants of the parents, and the constraints. + + if Is_Derived_Type (Typ) + and then Present (Girder_Constraint (Typ)) + and then Scope (Entity (Discrim)) = Etype (Typ) + then + D := First_Discriminant (Etype (Typ)); + E := First_Elmt (Constraints); + G := First_Elmt (Girder_Constraint (Typ)); + + while Present (D) loop + if D = Entity (Discrim) then + return Node (E); + end if; + + Next_Discriminant (D); + Next_Elmt (E); + Next_Elmt (G); + end loop; + end if; + -- Something is wrong if we did not find the value raise Program_Error; ! end Get_Discr_Value; --------------------- -- Is_Discriminant -- *************** package body Sem_Ch3 is *** 7052,7062 **** -- Constrain_Decimal -- ----------------------- ! procedure Constrain_Decimal ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id) ! is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : constant Node_Id := Constraint (S); Loc : constant Source_Ptr := Sloc (C); --- 7220,7226 ---- -- Constrain_Decimal -- ----------------------- ! procedure Constrain_Decimal (Def_Id : Node_Id; S : Node_Id) is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : constant Node_Id := Constraint (S); Loc : constant Source_Ptr := Sloc (C); *************** package body Sem_Ch3 is *** 7115,7121 **** end if; ! Set_Scalar_Range_For_Subtype (Def_Id, Range_Expr, T, Related_Nod); Set_Discrete_RM_Size (Def_Id); -- Unconditionally delay the freeze, since we cannot set size --- 7279,7285 ---- end if; ! Set_Scalar_Range_For_Subtype (Def_Id, Range_Expr, T); Set_Discrete_RM_Size (Def_Id); -- Unconditionally delay the freeze, since we cannot set size *************** package body Sem_Ch3 is *** 7134,7139 **** --- 7298,7304 ---- Related_Nod : Node_Id; For_Access : Boolean := False) is + E : constant Entity_Id := Entity (Subtype_Mark (S)); T : Entity_Id; C : Node_Id; Elist : Elist_Id := New_Elmt_List; *************** package body Sem_Ch3 is *** 7181,7187 **** Fixup_Bad_Constraint; return; ! elsif Is_Constrained (Entity (Subtype_Mark (S))) then Error_Msg_N ("type is already constrained", Subtype_Mark (S)); Fixup_Bad_Constraint; return; --- 7346,7355 ---- Fixup_Bad_Constraint; return; ! elsif Is_Constrained (E) ! or else (Ekind (E) = E_Class_Wide_Subtype ! and then Present (Discriminant_Constraint (E))) ! then Error_Msg_N ("type is already constrained", Subtype_Mark (S)); Fixup_Bad_Constraint; return; *************** package body Sem_Ch3 is *** 7210,7220 **** -- Constrain_Enumeration -- --------------------------- ! procedure Constrain_Enumeration ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id) ! is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : constant Node_Id := Constraint (S); --- 7378,7384 ---- -- Constrain_Enumeration -- --------------------------- ! procedure Constrain_Enumeration (Def_Id : Node_Id; S : Node_Id) is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : constant Node_Id := Constraint (S); *************** package body Sem_Ch3 is *** 7228,7235 **** Set_First_Rep_Item (Def_Id, First_Rep_Item (T)); Set_Is_Character_Type (Def_Id, Is_Character_Type (T)); ! Set_Scalar_Range_For_Subtype ! (Def_Id, Range_Expression (C), T, Related_Nod); Set_Discrete_RM_Size (Def_Id); --- 7392,7398 ---- Set_First_Rep_Item (Def_Id, First_Rep_Item (T)); Set_Is_Character_Type (Def_Id, Is_Character_Type (T)); ! Set_Scalar_Range_For_Subtype (Def_Id, Range_Expression (C), T); Set_Discrete_RM_Size (Def_Id); *************** package body Sem_Ch3 is *** 7239,7249 **** -- Constrain_Float -- ---------------------- ! procedure Constrain_Float ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id) ! is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : Node_Id; D : Node_Id; --- 7402,7408 ---- -- Constrain_Float -- ---------------------- ! procedure Constrain_Float (Def_Id : Node_Id; S : Node_Id) is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : Node_Id; D : Node_Id; *************** package body Sem_Ch3 is *** 7275,7281 **** if Digits_Value (Def_Id) > Digits_Value (T) then Error_Msg_Uint_1 := Digits_Value (T); Error_Msg_N ("?digits value is too large, maximum is ^", D); ! Rais := Make_Raise_Constraint_Error (Sloc (D)); Insert_Action (Declaration_Node (Def_Id), Rais); end if; --- 7434,7442 ---- if Digits_Value (Def_Id) > Digits_Value (T) then Error_Msg_Uint_1 := Digits_Value (T); Error_Msg_N ("?digits value is too large, maximum is ^", D); ! Rais := ! Make_Raise_Constraint_Error (Sloc (D), ! Reason => CE_Range_Check_Failed); Insert_Action (Declaration_Node (Def_Id), Rais); end if; *************** package body Sem_Ch3 is *** 7290,7297 **** -- Range constraint present if Nkind (C) = N_Range_Constraint then ! Set_Scalar_Range_For_Subtype ! (Def_Id, Range_Expression (C), T, Related_Nod); -- No range constraint present --- 7451,7457 ---- -- Range constraint present if Nkind (C) = N_Range_Constraint then ! Set_Scalar_Range_For_Subtype (Def_Id, Range_Expression (C), T); -- No range constraint present *************** package body Sem_Ch3 is *** 7344,7351 **** Checks_Off := True; end if; ! Process_Range_Expr_In_Decl ! (R, T, Related_Nod, Empty_List, Checks_Off); if not Error_Posted (S) and then --- 7504,7510 ---- Checks_Off := True; end if; ! Process_Range_Expr_In_Decl (R, T, Empty_List, Checks_Off); if not Error_Posted (S) and then *************** package body Sem_Ch3 is *** 7428,7444 **** -- Constrain_Integer -- ----------------------- ! procedure Constrain_Integer ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id) ! is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : constant Node_Id := Constraint (S); begin ! Set_Scalar_Range_For_Subtype ! (Def_Id, Range_Expression (C), T, Related_Nod); if Is_Modular_Integer_Type (T) then Set_Ekind (Def_Id, E_Modular_Integer_Subtype); --- 7587,7598 ---- -- Constrain_Integer -- ----------------------- ! procedure Constrain_Integer (Def_Id : Node_Id; S : Node_Id) is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : constant Node_Id := Constraint (S); begin ! Set_Scalar_Range_For_Subtype (Def_Id, Range_Expression (C), T); if Is_Modular_Integer_Type (T) then Set_Ekind (Def_Id, E_Modular_Integer_Subtype); *************** package body Sem_Ch3 is *** 7457,7467 **** -- Constrain_Ordinary_Fixed -- ------------------------------ ! procedure Constrain_Ordinary_Fixed ! (Def_Id : Node_Id; ! S : Node_Id; ! Related_Nod : Node_Id) ! is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : Node_Id; D : Node_Id; --- 7611,7617 ---- -- Constrain_Ordinary_Fixed -- ------------------------------ ! procedure Constrain_Ordinary_Fixed (Def_Id : Node_Id; S : Node_Id) is T : constant Entity_Id := Entity (Subtype_Mark (S)); C : Node_Id; D : Node_Id; *************** package body Sem_Ch3 is *** 7492,7498 **** if Delta_Value (Def_Id) < Delta_Value (T) then Error_Msg_N ("?delta value is too small", D); ! Rais := Make_Raise_Constraint_Error (Sloc (D)); Insert_Action (Declaration_Node (Def_Id), Rais); end if; --- 7642,7650 ---- if Delta_Value (Def_Id) < Delta_Value (T) then Error_Msg_N ("?delta value is too small", D); ! Rais := ! Make_Raise_Constraint_Error (Sloc (D), ! Reason => CE_Range_Check_Failed); Insert_Action (Declaration_Node (Def_Id), Rais); end if; *************** package body Sem_Ch3 is *** 7507,7514 **** -- Range constraint present if Nkind (C) = N_Range_Constraint then ! Set_Scalar_Range_For_Subtype ! (Def_Id, Range_Expression (C), T, Related_Nod); -- No range constraint present --- 7659,7665 ---- -- Range constraint present if Nkind (C) = N_Range_Constraint then ! Set_Scalar_Range_For_Subtype (Def_Id, Range_Expression (C), T); -- No range constraint present *************** package body Sem_Ch3 is *** 7545,7555 **** begin Lo := Build_Scalar_Bound (Type_Low_Bound (Derived_Type), ! Parent_Type, Implicit_Base, Loc); Hi := Build_Scalar_Bound (Type_High_Bound (Derived_Type), ! Parent_Type, Implicit_Base, Loc); Rng := Make_Range (Loc, --- 7696,7706 ---- begin Lo := Build_Scalar_Bound (Type_Low_Bound (Derived_Type), ! Parent_Type, Implicit_Base); Hi := Build_Scalar_Bound (Type_High_Bound (Derived_Type), ! Parent_Type, Implicit_Base); Rng := Make_Range (Loc, *************** package body Sem_Ch3 is *** 8609,8614 **** --- 8760,8766 ---- if Is_Tagged_Type (T) then Set_Primitive_Operations (T, New_Elmt_List); end if; + return; elsif Is_Unchecked_Union (Parent_Type) then *************** package body Sem_Ch3 is *** 8818,8823 **** --- 8970,8981 ---- then Set_Discard_Names (T); end if; + + -- Process end label if there is one + + if Present (Def) then + Process_End_Label (Def, 'e', T); + end if; end Enumeration_Type_Declaration; -------------------------- *************** package body Sem_Ch3 is *** 9174,9182 **** end if; Copy_And_Swap (Prev, Id); - Set_Full_View (Id, Prev); Set_Has_Private_Declaration (Prev); Set_Has_Private_Declaration (Id); New_Id := Prev; end if; --- 9332,9353 ---- end if; Copy_And_Swap (Prev, Id); Set_Has_Private_Declaration (Prev); Set_Has_Private_Declaration (Id); + + -- If no error, propagate freeze_node from private to full view. + -- It may have been generated for an early operational item. + + if Present (Freeze_Node (Id)) + and then Serious_Errors_Detected = 0 + and then No (Full_View (Id)) + then + Set_Freeze_Node (Prev, Freeze_Node (Id)); + Set_Freeze_Node (Id, Empty); + Set_First_Rep_Item (Prev, First_Rep_Item (Id)); + end if; + + Set_Full_View (Id, Prev); New_Id := Prev; end if; *************** package body Sem_Ch3 is *** 10190,10206 **** Set_Has_Delayed_Freeze (CW_Type); -- Customize the class-wide type: It has no prim. op., it cannot be ! -- abstract and its Etype points back to the root type Set_Ekind (CW_Type, E_Class_Wide_Type); Set_Is_Tagged_Type (CW_Type, True); Set_Primitive_Operations (CW_Type, New_Elmt_List); Set_Is_Abstract (CW_Type, False); - Set_Etype (CW_Type, T); Set_Is_Constrained (CW_Type, False); Set_Is_First_Subtype (CW_Type, Is_First_Subtype (T)); Init_Size_Align (CW_Type); -- If this is the class_wide type of a constrained subtype, it does -- not have discriminants. --- 10361,10382 ---- Set_Has_Delayed_Freeze (CW_Type); -- Customize the class-wide type: It has no prim. op., it cannot be ! -- abstract and its Etype points back to the specific root type. Set_Ekind (CW_Type, E_Class_Wide_Type); Set_Is_Tagged_Type (CW_Type, True); Set_Primitive_Operations (CW_Type, New_Elmt_List); Set_Is_Abstract (CW_Type, False); Set_Is_Constrained (CW_Type, False); Set_Is_First_Subtype (CW_Type, Is_First_Subtype (T)); Init_Size_Align (CW_Type); + if Ekind (T) = E_Class_Wide_Subtype then + Set_Etype (CW_Type, Etype (Base_Type (T))); + else + Set_Etype (CW_Type, T); + end if; + -- If this is the class_wide type of a constrained subtype, it does -- not have discriminants. *************** package body Sem_Ch3 is *** 10317,10323 **** end if; R := I; ! Process_Range_Expr_In_Decl (R, T, Related_Nod); elsif Nkind (I) = N_Subtype_Indication then --- 10493,10499 ---- end if; R := I; ! Process_Range_Expr_In_Decl (R, T); elsif Nkind (I) = N_Subtype_Indication then *************** package body Sem_Ch3 is *** 10334,10341 **** R := Range_Expression (Constraint (I)); Resolve (R, T); ! Process_Range_Expr_In_Decl (R, ! Entity (Subtype_Mark (I)), Related_Nod); elsif Nkind (I) = N_Attribute_Reference then --- 10510,10516 ---- R := Range_Expression (Constraint (I)); Resolve (R, T); ! Process_Range_Expr_In_Decl (R, Entity (Subtype_Mark (I))); elsif Nkind (I) = N_Attribute_Reference then *************** package body Sem_Ch3 is *** 11369,11375 **** procedure Process_Range_Expr_In_Decl (R : Node_Id; T : Entity_Id; - Related_Nod : Node_Id; Check_List : List_Id := Empty_List; R_Check_Off : Boolean := False) is --- 11544,11549 ---- *************** package body Sem_Ch3 is *** 11693,11711 **** Constrain_Array (Def_Id, S, Related_Nod, Related_Id, Suffix); when Decimal_Fixed_Point_Kind => ! Constrain_Decimal (Def_Id, S, N_Dynamic_Ityp); when Enumeration_Kind => ! Constrain_Enumeration (Def_Id, S, N_Dynamic_Ityp); when Ordinary_Fixed_Point_Kind => ! Constrain_Ordinary_Fixed (Def_Id, S, N_Dynamic_Ityp); when Float_Kind => ! Constrain_Float (Def_Id, S, N_Dynamic_Ityp); when Integer_Kind => ! Constrain_Integer (Def_Id, S, N_Dynamic_Ityp); when E_Record_Type | E_Record_Subtype | --- 11867,11885 ---- Constrain_Array (Def_Id, S, Related_Nod, Related_Id, Suffix); when Decimal_Fixed_Point_Kind => ! Constrain_Decimal (Def_Id, S); when Enumeration_Kind => ! Constrain_Enumeration (Def_Id, S); when Ordinary_Fixed_Point_Kind => ! Constrain_Ordinary_Fixed (Def_Id, S); when Float_Kind => ! Constrain_Float (Def_Id, S); when Integer_Kind => ! Constrain_Integer (Def_Id, S); when E_Record_Type | E_Record_Subtype | *************** package body Sem_Ch3 is *** 11787,11793 **** -- private tagged types where the full view omits the word tagged. Is_Tagged := Tagged_Present (Def) ! or else (Errors_Detected > 0 and then Is_Tagged_Type (T)); -- Records constitute a scope for the component declarations within. -- The scope is created prior to the processing of these declarations. --- 11961,11967 ---- -- private tagged types where the full view omits the word tagged. Is_Tagged := Tagged_Present (Def) ! or else (Serious_Errors_Detected > 0 and then Is_Tagged_Type (T)); -- Records constitute a scope for the component declarations within. -- The scope is created prior to the processing of these declarations. *************** package body Sem_Ch3 is *** 11943,11952 **** end if; if Present (Def) then ! Process_End_Label (Def, 'e'); end if; end Record_Type_Definition; --------------------- -- Set_Fixed_Range -- --------------------- --- 12117,12191 ---- end if; if Present (Def) then ! Process_End_Label (Def, 'e', T); end if; end Record_Type_Definition; + ------------------------ + -- Replace_Components -- + ------------------------ + + procedure Replace_Components (Typ : Entity_Id; Decl : Node_Id) is + function Process (N : Node_Id) return Traverse_Result; + + ------------- + -- Process -- + ------------- + + function Process (N : Node_Id) return Traverse_Result is + Comp : Entity_Id; + + begin + if Nkind (N) = N_Discriminant_Specification then + Comp := First_Discriminant (Typ); + + while Present (Comp) loop + if Chars (Comp) = Chars (Defining_Identifier (N)) then + Set_Defining_Identifier (N, Comp); + exit; + end if; + + Next_Discriminant (Comp); + end loop; + + elsif Nkind (N) = N_Component_Declaration then + Comp := First_Component (Typ); + + while Present (Comp) loop + if Chars (Comp) = Chars (Defining_Identifier (N)) then + Set_Defining_Identifier (N, Comp); + exit; + end if; + + Next_Component (Comp); + end loop; + end if; + + return OK; + end Process; + + procedure Replace is new Traverse_Proc (Process); + + -- Start of processing for Replace_Components + + begin + Replace (Decl); + end Replace_Components; + + ------------------------------- + -- Set_Completion_Referenced -- + ------------------------------- + + procedure Set_Completion_Referenced (E : Entity_Id) is + begin + -- If in main unit, mark entity that is a completion as referenced, + -- warnings go on the partial view when needed. + + if In_Extended_Main_Source_Unit (E) then + Set_Referenced (E); + end if; + end Set_Completion_Referenced; + --------------------- -- Set_Fixed_Range -- --------------------- *************** package body Sem_Ch3 is *** 12021,12030 **** ---------------------------------- procedure Set_Scalar_Range_For_Subtype ! (Def_Id : Entity_Id; ! R : Node_Id; ! Subt : Entity_Id; ! Related_Nod : Node_Id) is Kind : constant Entity_Kind := Ekind (Def_Id); begin --- 12260,12268 ---- ---------------------------------- procedure Set_Scalar_Range_For_Subtype ! (Def_Id : Entity_Id; ! R : Node_Id; ! Subt : Entity_Id) is Kind : constant Entity_Kind := Ekind (Def_Id); begin *************** package body Sem_Ch3 is *** 12044,12050 **** -- catch possible premature use in the bounds themselves. Set_Ekind (Def_Id, E_Void); ! Process_Range_Expr_In_Decl (R, Subt, Related_Nod); Set_Ekind (Def_Id, Kind); end Set_Scalar_Range_For_Subtype; --- 12282,12288 ---- -- catch possible premature use in the bounds themselves. Set_Ekind (Def_Id, E_Void); ! Process_Range_Expr_In_Decl (R, Subt); Set_Ekind (Def_Id, Kind); end Set_Scalar_Range_For_Subtype; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch3.ads gcc-3.3/gcc/ada/sem_ch3.ads *** gcc-3.2.3/gcc/ada/sem_ch3.ads 2002-05-04 03:29:03.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch3.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Sem_Ch3 is *** 186,192 **** procedure Process_Range_Expr_In_Decl (R : Node_Id; T : Entity_Id; - Related_Nod : Node_Id; Check_List : List_Id := Empty_List; R_Check_Off : Boolean := False); -- Process a range expression that appears in a declaration context. The --- 185,190 ---- *************** package Sem_Ch3 is *** 216,221 **** --- 214,225 ---- -- Process the discriminants contained in an N_Full_Type_Declaration or -- N_Incomplete_Type_Decl node N. + procedure Set_Completion_Referenced (E : Entity_Id); + -- If E is the completion of a private or incomplete type declaration, + -- or the completion of a deferred constant declaration, mark the entity + -- as referenced. Warnings on unused entities, if needed, go on the + -- partial view. + procedure Set_Girder_Constraint_From_Discriminant_Constraint (E : Entity_Id); -- E is some record type. This routine computes E's Girder_Constraint diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch4.adb gcc-3.3/gcc/ada/sem_ch4.adb *** gcc-3.2.3/gcc/ada/sem_ch4.adb 2002-05-04 03:29:06.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch4.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Sem_Ch4 is *** 341,347 **** procedure Analyze_Allocator (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); ! Sav_Errs : constant Nat := Errors_Detected; E : Node_Id := Expression (N); Acc_Type : Entity_Id; Type_Id : Entity_Id; --- 340,346 ---- procedure Analyze_Allocator (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); ! Sav_Errs : constant Nat := Serious_Errors_Detected; E : Node_Id := Expression (N); Acc_Type : Entity_Id; Type_Id : Entity_Id; *************** package body Sem_Ch4 is *** 441,447 **** Defining_Identifier => Def_Id, Subtype_Indication => Relocate_Node (E))); ! if Sav_Errs /= Errors_Detected and then Nkind (Constraint (E)) = N_Index_Or_Discriminant_Constraint then --- 440,446 ---- Defining_Identifier => Def_Id, Subtype_Indication => Relocate_Node (E))); ! if Sav_Errs /= Serious_Errors_Detected and then Nkind (Constraint (E)) = N_Index_Or_Discriminant_Constraint then *************** package body Sem_Ch4 is *** 467,473 **** -- are probably cascaded errors if Is_Indefinite_Subtype (Type_Id) ! and then Errors_Detected = Sav_Errs then if Is_Class_Wide_Type (Type_Id) then Error_Msg_N --- 466,472 ---- -- are probably cascaded errors if Is_Indefinite_Subtype (Type_Id) ! and then Serious_Errors_Detected = Sav_Errs then if Is_Class_Wide_Type (Type_Id) then Error_Msg_N *************** package body Sem_Ch4 is *** 494,500 **** Check_Restriction (No_Local_Allocators, N); end if; ! if Errors_Detected > Sav_Errs then Set_Error_Posted (N); Set_Etype (N, Any_Type); end if; --- 493,499 ---- Check_Restriction (No_Local_Allocators, N); end if; ! if Serious_Errors_Detected > Sav_Errs then Set_Error_Posted (N); Set_Etype (N, Any_Type); end if; *************** package body Sem_Ch4 is *** 1335,1340 **** --- 1334,1343 ---- if Is_Access_Type (Array_Type) then Array_Type := Designated_Type (Array_Type); + + if Warn_On_Dereference then + Error_Msg_N ("?implicit dereference", N); + end if; end if; if Is_Array_Type (Array_Type) then *************** package body Sem_Ch4 is *** 1498,1503 **** --- 1501,1510 ---- if Is_Access_Type (Typ) then Typ := Designated_Type (Typ); + + if Warn_On_Dereference then + Error_Msg_N ("?implicit dereference", N); + end if; end if; if Is_Array_Type (Typ) then *************** package body Sem_Ch4 is *** 2169,2174 **** --- 2176,2186 ---- while Present (It.Typ) loop if Is_Access_Type (It.Typ) then T := Designated_Type (It.Typ); + + if Warn_On_Dereference then + Error_Msg_N ("?implicit dereference", N); + end if; + else T := It.Typ; end if; *************** package body Sem_Ch4 is *** 2219,2224 **** --- 2231,2240 ---- if Is_Access_Type (Etype (Nam)) then Insert_Explicit_Dereference (Nam); + + if Warn_On_Dereference then + Error_Msg_N ("?implicit dereference", N); + end if; end if; end if; *************** package body Sem_Ch4 is *** 2226,2232 **** end loop; Set_Is_Overloaded (N, Is_Overloaded (Sel)); - end if; Get_Next_Interp (I, It); --- 2242,2247 ---- *************** package body Sem_Ch4 is *** 2414,2431 **** end if; if Is_Access_Type (Prefix_Type) then if Is_Remote_Access_To_Class_Wide_Type (Prefix_Type) and then Comes_From_Source (N) then - -- A RACW object can never be used as prefix of a selected - -- component since that means it is dereferenced without - -- being a controlling operand of a dispatching operation - -- (RM E.2.2(15)). - Error_Msg_N ("invalid dereference of a remote access to class-wide value", N); end if; Prefix_Type := Designated_Type (Prefix_Type); end if; --- 2429,2455 ---- end if; if Is_Access_Type (Prefix_Type) then + + -- A RACW object can never be used as prefix of a selected + -- component since that means it is dereferenced without + -- being a controlling operand of a dispatching operation + -- (RM E.2.2(15)). + if Is_Remote_Access_To_Class_Wide_Type (Prefix_Type) and then Comes_From_Source (N) then Error_Msg_N ("invalid dereference of a remote access to class-wide value", N); + + -- Normal case of selected component applied to access type + + else + if Warn_On_Dereference then + Error_Msg_N ("?implicit dereference", N); + end if; end if; + Prefix_Type := Designated_Type (Prefix_Type); end if; *************** package body Sem_Ch4 is *** 2466,2471 **** --- 2490,2499 ---- if Is_Access_Type (Etype (Name)) then Insert_Explicit_Dereference (Name); + + if Warn_On_Dereference then + Error_Msg_N ("?implicit dereference", N); + end if; end if; elsif Is_Record_Type (Prefix_Type) then *************** package body Sem_Ch4 is *** 2656,2661 **** --- 2684,2693 ---- if Is_Access_Type (Etype (Name)) then Insert_Explicit_Dereference (Name); + + if Warn_On_Dereference then + Error_Msg_N ("?implicit dereference", N); + end if; end if; end if; *************** package body Sem_Ch4 is *** 2693,2698 **** --- 2725,2731 ---- elsif Is_Generic_Type (Prefix_Type) and then Ekind (Prefix_Type) = E_Record_Type_With_Private + and then Prefix_Type /= Etype (Prefix_Type) and then Is_Record_Type (Etype (Prefix_Type)) then -- If this is a derived formal type, the parent may have a *************** package body Sem_Ch4 is *** 2730,2735 **** --- 2763,2769 ---- Apply_Compile_Time_Constraint_Error (N, "component not present in }?", + CE_Discriminant_Check_Failed, Ent => Prefix_Type, Rep => False); Set_Raises_Constraint_Error (N); return; *************** package body Sem_Ch4 is *** 2831,2836 **** --- 2865,2874 ---- if Is_Access_Type (Typ) then Typ := Designated_Type (Typ); + + if Warn_On_Dereference then + Error_Msg_N ("?implicit dereference", N); + end if; end if; if Is_Array_Type (Typ) *************** package body Sem_Ch4 is *** 2868,2873 **** --- 2906,2915 ---- if Is_Access_Type (Array_Type) then Array_Type := Designated_Type (Array_Type); + + if Warn_On_Dereference then + Error_Msg_N ("?implicit dereference", N); + end if; end if; if not Is_Array_Type (Array_Type) then diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch4.ads gcc-3.3/gcc/ada/sem_ch4.ads *** gcc-3.2.3/gcc/ada/sem_ch4.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch4.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch5.adb gcc-3.3/gcc/ada/sem_ch5.adb *** gcc-3.2.3/gcc/ada/sem_ch5.adb 2002-05-04 03:29:08.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch5.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Sem_Ch5 is *** 436,442 **** end if; Analyze (Handled_Statement_Sequence (N)); ! Process_End_Label (Handled_Statement_Sequence (N), 'e'); -- Analyze exception handlers if present. Note that the test for -- HSS being present is an error defence against previous errors. --- 435,441 ---- end if; Analyze (Handled_Statement_Sequence (N)); ! Process_End_Label (Handled_Statement_Sequence (N), 'e', Ent); -- Analyze exception handlers if present. Note that the test for -- HSS being present is an error defence against previous errors. *************** package body Sem_Ch5 is *** 1093,1099 **** New_Scope (Ent); Analyze_Iteration_Scheme (Iteration_Scheme (N)); Analyze_Statements (Statements (N)); ! Process_End_Label (N, 'e'); End_Scope; end Analyze_Loop_Statement; --- 1092,1098 ---- New_Scope (Ent); Analyze_Iteration_Scheme (Iteration_Scheme (N)); Analyze_Statements (Statements (N)); ! Process_End_Label (N, 'e', Ent); End_Scope; end Analyze_Loop_Statement; *************** package body Sem_Ch5 is *** 1105,1110 **** --- 1104,1111 ---- -- null statement, too bad everything isn't as simple as this! procedure Analyze_Null_Statement (N : Node_Id) is + pragma Warnings (Off, N); + begin null; end Analyze_Null_Statement; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch5.ads gcc-3.3/gcc/ada/sem_ch5.ads *** gcc-3.2.3/gcc/ada/sem_ch5.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch5.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch6.adb gcc-3.3/gcc/ada/sem_ch6.adb *** gcc-3.2.3/gcc/ada/sem_ch6.adb 2002-05-04 03:29:08.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch6.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with Elists; use Elists; *** 34,40 **** with Errout; use Errout; with Expander; use Expander; with Exp_Ch7; use Exp_Ch7; - with Fname; use Fname; with Freeze; use Freeze; with Lib.Xref; use Lib.Xref; with Namet; use Namet; --- 33,38 ---- *************** package body Sem_Ch6 is *** 96,101 **** --- 94,101 ---- type Conformance_Type is (Type_Conformant, Mode_Conformant, Subtype_Conformant, Fully_Conformant); + -- Conformance type used for following call, meaning matches the + -- RM definitions of the corresponding terms. procedure Check_Conformance (New_Id : Entity_Id; *************** package body Sem_Ch6 is *** 707,713 **** and then Object_Access_Level (Expr) > Subprogram_Access_Level (Scope_Id) then ! Rewrite (N, Make_Raise_Program_Error (Loc)); Analyze (N); Error_Msg_N --- 707,715 ---- and then Object_Access_Level (Expr) > Subprogram_Access_Level (Scope_Id) then ! Rewrite (N, ! Make_Raise_Program_Error (Loc, ! Reason => PE_Accessibility_Check_Failed)); Analyze (N); Error_Msg_N *************** package body Sem_Ch6 is *** 785,791 **** if Present (Formals) then Set_Scope (Designator, Current_Scope); New_Scope (Designator); ! Process_Formals (Designator, Formals, N); End_Scope; end if; --- 787,793 ---- if Present (Formals) then Set_Scope (Designator, Current_Scope); New_Scope (Designator); ! Process_Formals (Formals, N); End_Scope; end if; *************** package body Sem_Ch6 is *** 829,834 **** --- 831,837 ---- Conformant : Boolean; Missing_Ret : Boolean; Body_Deleted : Boolean := False; + P_Ent : Entity_Id; begin if Debug_Flag_C then *************** package body Sem_Ch6 is *** 916,929 **** end if; end if; if No (Spec_Id) and then Comes_From_Source (N) and then Is_Protected_Type (Current_Scope) then - -- Fully private operation in the body of the protected type. We - -- must create a declaration for the subprogram, in order to attach - -- the protected subprogram that will be used in internal calls. - declare Decl : Node_Id; Plist : List_Id; --- 919,964 ---- end if; end if; + -- Do not inline any subprogram that contains nested subprograms, + -- since the backend inlining circuit seems to generate uninitialized + -- references in this case. We know this happens in the case of front + -- end ZCX support, but it also appears it can happen in other cases + -- as well. The backend often rejects attempts to inline in the case + -- of nested procedures anyway, so little if anything is lost by this. + + -- Do not do this test if errors have been detected, because in some + -- error cases, this code blows up, and we don't need it anyway if + -- there have been errors, since we won't get to the linker anyway. + + if Serious_Errors_Detected = 0 then + P_Ent := Body_Id; + loop + P_Ent := Scope (P_Ent); + exit when No (P_Ent) or else P_Ent = Standard_Standard; + + if Is_Subprogram (P_Ent) and then Is_Inlined (P_Ent) then + Set_Is_Inlined (P_Ent, False); + + if Comes_From_Source (P_Ent) + and then Ineffective_Inline_Warnings + and then Has_Pragma_Inline (P_Ent) + then + Error_Msg_NE + ("?pragma Inline for & ignored (has nested subprogram)", + Get_Rep_Pragma (P_Ent, Name_Inline), P_Ent); + end if; + end if; + end loop; + end if; + + -- Case of fully private operation in the body of the protected type. + -- We must create a declaration for the subprogram, in order to attach + -- the protected subprogram that will be used in internal calls. + if No (Spec_Id) and then Comes_From_Source (N) and then Is_Protected_Type (Current_Scope) then declare Decl : Node_Id; Plist : List_Id; *************** package body Sem_Ch6 is *** 998,1004 **** -- is a spec, the visible entity remains that of the spec. if Present (Spec_Id) then ! Generate_Reference (Spec_Id, Body_Id, 'b'); Style.Check_Identifier (Body_Id, Spec_Id); Set_Is_Compilation_Unit (Body_Id, Is_Compilation_Unit (Spec_Id)); --- 1033,1039 ---- -- is a spec, the visible entity remains that of the spec. if Present (Spec_Id) then ! Generate_Reference (Spec_Id, Body_Id, 'b', Set_Ref => False); Style.Check_Identifier (Body_Id, Spec_Id); Set_Is_Compilation_Unit (Body_Id, Is_Compilation_Unit (Spec_Id)); *************** package body Sem_Ch6 is *** 1050,1056 **** end if; -- Generate references from body formals to spec formals ! -- and also set the Spec_Entity fields for all formals if Spec_Id /= Body_Id then declare --- 1085,1093 ---- end if; -- Generate references from body formals to spec formals ! -- and also set the Spec_Entity fields for all formals. We ! -- do not set this reference count as a reference for the ! -- purposes of identifying unreferenced formals however. if Spec_Id /= Body_Id then declare *************** package body Sem_Ch6 is *** 1064,1069 **** --- 1101,1107 ---- Generate_Reference (Fs, Fb, 'b'); Style.Check_Identifier (Fb, Fs); Set_Spec_Entity (Fb, Fs); + Set_Referenced (Fs, False); Next_Formal (Fs); Next_Formal (Fb); end loop; *************** package body Sem_Ch6 is *** 1150,1198 **** elsif Present (Spec_Id) and then Expander_Active ! and then Has_Pragma_Inline (Spec_Id) ! and then (Front_End_Inlining ! or else ! (No_Run_Time and then Is_Always_Inlined (Spec_Id))) then if Build_Body_To_Inline (N, Spec_Id, Copy_Separate_Tree (N)) then null; end if; end if; - -- Here we have a real body, not a stub. First step is to null out - -- the subprogram body if we have the special case of no run time - -- mode with a predefined unit, and the subprogram is not marked - -- as Inline_Always. The reason is that we should never call such - -- a routine in no run time mode, and it may in general have some - -- statements that we cannot handle in no run time mode. - - -- ASIS note: we do a replace here, because we are really NOT going - -- to analyze the original body and declarations at all, so it is - -- useless to keep them around, we really are obliterating the body, - -- basically creating a specialized no run time version on the fly - -- in which the bodies *are* null. - - if No_Run_Time - and then Present (Spec_Id) - and then Is_Predefined_File_Name - (Unit_File_Name (Get_Source_Unit (Loc))) - and then not Is_Always_Inlined (Spec_Id) - then - Replace (N, - Make_Subprogram_Body (Loc, - Specification => Specification (N), - Declarations => Empty_List, - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => New_List ( - Make_Null_Statement (Loc)), - End_Label => - End_Label (Handled_Statement_Sequence (N))))); - Set_Corresponding_Spec (N, Spec_Id); - Body_Deleted := True; - end if; - -- Now we can go on to analyze the body HSS := Handled_Statement_Sequence (N); --- 1188,1203 ---- elsif Present (Spec_Id) and then Expander_Active ! and then (Is_Always_Inlined (Spec_Id) ! or else (Has_Pragma_Inline (Spec_Id) ! and then ! (Front_End_Inlining or else No_Run_Time))) then if Build_Body_To_Inline (N, Spec_Id, Copy_Separate_Tree (N)) then null; end if; end if; -- Now we can go on to analyze the body HSS := Handled_Statement_Sequence (N); *************** package body Sem_Ch6 is *** 1200,1206 **** Analyze_Declarations (Declarations (N)); Check_Completion; Analyze (HSS); ! Process_End_Label (HSS, 't'); End_Scope; Check_Subprogram_Order (N); --- 1205,1211 ---- Analyze_Declarations (Declarations (N)); Check_Completion; Analyze (HSS); ! Process_End_Label (HSS, 't', Current_Scope); End_Scope; Check_Subprogram_Order (N); *************** package body Sem_Ch6 is *** 2707,2713 **** Type_2 : Entity_Id := T2; function Base_Types_Match (T1, T2 : Entity_Id) return Boolean; ! -- If neither T1 nor T2 are generic actual types, then verify -- that the base types are equal. Otherwise T1 and T2 must be -- on the same subtype chain. The whole purpose of this procedure -- is to prevent spurious ambiguities in an instantiation that may --- 2712,2719 ---- Type_2 : Entity_Id := T2; function Base_Types_Match (T1, T2 : Entity_Id) return Boolean; ! -- If neither T1 nor T2 are generic actual types, or if they are ! -- in different scopes (e.g. parent and child instances), then verify -- that the base types are equal. Otherwise T1 and T2 must be -- on the same subtype chain. The whole purpose of this procedure -- is to prevent spurious ambiguities in an instantiation that may *************** package body Sem_Ch6 is *** 2730,2736 **** -- other ???. return not Is_Generic_Actual_Type (T1) ! or else not Is_Generic_Actual_Type (T2); else return False; --- 2736,2743 ---- -- other ???. return not Is_Generic_Actual_Type (T1) ! or else not Is_Generic_Actual_Type (T2) ! or else Scope (T1) /= Scope (T2); else return False; *************** package body Sem_Ch6 is *** 3137,3143 **** and then not In_Instance then Error_Msg_Sloc := Sloc (E); ! Error_Msg_NE ("duplicate body for & declared#", N, E); end if; elsif Is_Child_Unit (E) --- 3144,3156 ---- and then not In_Instance then Error_Msg_Sloc := Sloc (E); ! if Is_Imported (E) then ! Error_Msg_NE ! ("body not allowed for imported subprogram & declared#", ! N, E); ! else ! Error_Msg_NE ("duplicate body for & declared#", N, E); ! end if; end if; elsif Is_Child_Unit (E) *************** package body Sem_Ch6 is *** 3958,3963 **** --- 3971,3977 ---- procedure Maybe_Primitive_Operation (Overriding : Boolean := False) is Formal : Entity_Id; F_Typ : Entity_Id; + B_Typ : Entity_Id; function Visible_Part_Type (T : Entity_Id) return Boolean; -- Returns true if T is declared in the visible part of *************** package body Sem_Ch6 is *** 4010,4017 **** ----------------------- function Visible_Part_Type (T : Entity_Id) return Boolean is ! P : Node_Id := Unit_Declaration_Node (Scope (T)); ! N : Node_Id := First (Visible_Declarations (Specification (P))); begin -- If the entity is a private type, then it must be --- 4024,4031 ---- ----------------------- function Visible_Part_Type (T : Entity_Id) return Boolean is ! P : constant Node_Id := Unit_Declaration_Node (Scope (T)); ! N : Node_Id; begin -- If the entity is a private type, then it must be *************** package body Sem_Ch6 is *** 4027,4032 **** --- 4041,4047 ---- -- private type is the one in the full view, which does not -- indicate that it is the completion of something visible. + N := First (Visible_Declarations (Specification (P))); while Present (N) loop if Nkind (N) = N_Full_Type_Declaration and then Present (Defining_Identifier (N)) *************** package body Sem_Ch6 is *** 4059,4074 **** and then not In_Package_Body (Current_Scope)) or else Overriding then ! if Ekind (S) = E_Function ! and then Scope (Base_Type (Etype (S))) = Current_Scope ! then ! Set_Has_Primitive_Operations (Base_Type (Etype (S))); ! Check_Private_Overriding (Base_Type (Etype (S))); end if; ! Formal := First_Formal (S); while Present (Formal) loop if Ekind (Etype (Formal)) = E_Anonymous_Access_Type then F_Typ := Designated_Type (Etype (Formal)); --- 4074,4093 ---- and then not In_Package_Body (Current_Scope)) or else Overriding then + -- For function, check return type ! if Ekind (S) = E_Function then ! B_Typ := Base_Type (Etype (S)); ! ! if Scope (B_Typ) = Current_Scope then ! Set_Has_Primitive_Operations (B_Typ); ! Check_Private_Overriding (B_Typ); ! end if; end if; ! -- For all subprograms, check formals + Formal := First_Formal (S); while Present (Formal) loop if Ekind (Etype (Formal)) = E_Anonymous_Access_Type then F_Typ := Designated_Type (Etype (Formal)); *************** package body Sem_Ch6 is *** 4076,4089 **** F_Typ := Etype (Formal); end if; ! if Scope (Base_Type (F_Typ)) = Current_Scope then ! Set_Has_Primitive_Operations (Base_Type (F_Typ)); ! Check_Private_Overriding (Base_Type (F_Typ)); end if; Next_Formal (Formal); end loop; - end if; end Maybe_Primitive_Operation; --- 4095,4109 ---- F_Typ := Etype (Formal); end if; ! B_Typ := Base_Type (F_Typ); ! ! if Scope (B_Typ) = Current_Scope then ! Set_Has_Primitive_Operations (B_Typ); ! Check_Private_Overriding (B_Typ); end if; Next_Formal (Formal); end loop; end if; end Maybe_Primitive_Operation; *************** package body Sem_Ch6 is *** 4446,4453 **** --------------------- procedure Process_Formals ! (S : Entity_Id; ! T : List_Id; Related_Nod : Node_Id) is Param_Spec : Node_Id; --- 4466,4472 ---- --------------------- procedure Process_Formals ! (T : List_Id; Related_Nod : Node_Id) is Param_Spec : Node_Id; *************** package body Sem_Ch6 is *** 4456,4461 **** --- 4475,4499 ---- Default : Node_Id; Ptype : Entity_Id; + function Is_Class_Wide_Default (D : Node_Id) return Boolean; + -- Check whether the default has a class-wide type. After analysis + -- the default has the type of the formal, so we must also check + -- explicitly for an access attribute. + + --------------------------- + -- Is_Class_Wide_Default -- + --------------------------- + + function Is_Class_Wide_Default (D : Node_Id) return Boolean is + begin + return Is_Class_Wide_Type (Designated_Type (Etype (D))) + or else (Nkind (D) = N_Attribute_Reference + and then Attribute_Name (D) = Name_Access + and then Is_Class_Wide_Type (Etype (Prefix (D)))); + end Is_Class_Wide_Default; + + -- Start of processing for Process_Formals + begin -- In order to prevent premature use of the formals in the same formal -- part, the Ekind is left undefined until all default expressions are *************** package body Sem_Ch6 is *** 4524,4533 **** -- designated type is also class-wide. if Ekind (Formal_Type) = E_Anonymous_Access_Type ! and then Is_Class_Wide_Type (Designated_Type (Etype (Default))) and then not Is_Class_Wide_Type (Designated_Type (Formal_Type)) then ! Wrong_Type (Default, Formal_Type); end if; end if; --- 4562,4572 ---- -- designated type is also class-wide. if Ekind (Formal_Type) = E_Anonymous_Access_Type ! and then Is_Class_Wide_Default (Default) and then not Is_Class_Wide_Type (Designated_Type (Formal_Type)) then ! Error_Msg_N ! ("access to class-wide expression not allowed here", Default); end if; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch6.ads gcc-3.3/gcc/ada/sem_ch6.ads *** gcc-3.2.3/gcc/ada/sem_ch6.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch6.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992,1993,1994,1995,1996 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package Sem_Ch6 is *** 136,145 **** -- If Derived_Type is not Empty, then it indicates that this -- is subprogram derived for that type. ! procedure Process_Formals ( ! S : Entity_Id; ! T : List_Id; ! Related_Nod : Node_Id); -- Enter the formals in the scope of the subprogram or entry, and -- analyze default expressions if any. The implicit types created for -- access parameter are attached to the Related_Nod which comes from the --- 135,141 ---- -- If Derived_Type is not Empty, then it indicates that this -- is subprogram derived for that type. ! procedure Process_Formals (T : List_Id; Related_Nod : Node_Id); -- Enter the formals in the scope of the subprogram or entry, and -- analyze default expressions if any. The implicit types created for -- access parameter are attached to the Related_Nod which comes from the diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch7.adb gcc-3.3/gcc/ada/sem_ch7.adb *** gcc-3.2.3/gcc/ada/sem_ch7.adb 2002-05-04 03:29:09.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch7.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Sem_Ch7 is *** 300,306 **** HSS := Handled_Statement_Sequence (N); if Present (HSS) then ! Process_End_Label (HSS, 't'); Analyze (HSS); -- Check that elaboration code in a preelaborable package body is --- 299,305 ---- HSS := Handled_Statement_Sequence (N); if Present (HSS) then ! Process_End_Label (HSS, 't', Spec_Id); Analyze (HSS); -- Check that elaboration code in a preelaborable package body is *************** package body Sem_Ch7 is *** 316,322 **** -- because the call will use In_Extended_Main_Source_Unit as a check, -- and we want to make sure that Corresponding_Stub links are set ! Generate_Reference (Spec_Id, Body_Id, 'b'); -- For a generic package, collect global references and mark -- them on the original body so that they are not resolved --- 315,321 ---- -- because the call will use In_Extended_Main_Source_Unit as a check, -- and we want to make sure that Corresponding_Stub links are set ! Generate_Reference (Spec_Id, Body_Id, 'b', Set_Ref => False); -- For a generic package, collect global references and mark -- them on the original body so that they are not resolved *************** package body Sem_Ch7 is *** 816,822 **** end; end if; ! Process_End_Label (N, 'e'); end Analyze_Package_Specification; -------------------------------------- --- 815,821 ---- end; end if; ! Process_End_Label (N, 'e', Id); end Analyze_Package_Specification; -------------------------------------- *************** package body Sem_Ch7 is *** 851,856 **** --- 850,895 ---- procedure Declare_Inherited_Private_Subprograms (Id : Entity_Id) is E : Entity_Id; + Op_List : Elist_Id; + Op_Elmt : Elmt_Id; + Op_Elmt_2 : Elmt_Id; + Prim_Op : Entity_Id; + New_Op : Entity_Id; + Parent_Subp : Entity_Id; + Found_Explicit : Boolean; + Decl_Privates : Boolean; + + function Is_Primitive_Of (T : Entity_Id; S : Entity_Id) return Boolean; + -- Check whether an inherited subprogram is an operation of an + -- untagged derived type. + + --------------------- + -- Is_Primitive_Of -- + --------------------- + + function Is_Primitive_Of (T : Entity_Id; S : Entity_Id) return Boolean is + Formal : Entity_Id; + + begin + if Etype (S) = T then + return True; + + else + Formal := First_Formal (S); + + while Present (Formal) loop + if Etype (Formal) = T then + return True; + end if; + + Next_Formal (Formal); + end loop; + + return False; + end if; + end Is_Primitive_Of; + + -- Start of processing for Declare_Inherited_Private_Subprograms begin E := First_Entity (Id); *************** package body Sem_Ch7 is *** 862,887 **** -- inherited operations that now need to be made visible. -- Ditto if the entity is a formal derived type in a child unit. ! if Is_Tagged_Type (E) ! and then ! ((Is_Derived_Type (E) and then not Is_Private_Type (E)) or else (Nkind (Parent (E)) = N_Private_Extension_Declaration and then Is_Generic_Type (E))) and then In_Open_Scopes (Scope (Etype (E))) and then E = Base_Type (E) then ! declare ! Op_List : constant Elist_Id := Primitive_Operations (E); ! Op_Elmt : Elmt_Id := First_Elmt (Op_List); ! Op_Elmt_2 : Elmt_Id; ! Prim_Op : Entity_Id; ! New_Op : Entity_Id := Empty; ! Parent_Subp : Entity_Id; ! Found_Explicit : Boolean; ! Decl_Privates : Boolean := False; - begin while Present (Op_Elmt) loop Prim_Op := Node (Op_Elmt); --- 901,919 ---- -- inherited operations that now need to be made visible. -- Ditto if the entity is a formal derived type in a child unit. ! if ((Is_Derived_Type (E) and then not Is_Private_Type (E)) or else (Nkind (Parent (E)) = N_Private_Extension_Declaration and then Is_Generic_Type (E))) and then In_Open_Scopes (Scope (Etype (E))) and then E = Base_Type (E) then ! if Is_Tagged_Type (E) then ! Op_List := Primitive_Operations (E); ! Op_Elmt := First_Elmt (Op_List); ! New_Op := Empty; ! Decl_Privates := False; while Present (Op_Elmt) loop Prim_Op := Node (Op_Elmt); *************** package body Sem_Ch7 is *** 963,969 **** then Set_All_DT_Position (E); end if; ! end; end if; Next_Entity (E); --- 995,1021 ---- then Set_All_DT_Position (E); end if; ! ! else ! -- Non-tagged type, scan forward to locate ! -- inherited hidden operations. ! ! Prim_Op := Next_Entity (E); ! ! while Present (Prim_Op) loop ! if Is_Subprogram (Prim_Op) ! and then Present (Alias (Prim_Op)) ! and then not Comes_From_Source (Prim_Op) ! and then Is_Internal_Name (Chars (Prim_Op)) ! and then not Is_Internal_Name (Chars (Alias (Prim_Op))) ! and then Is_Primitive_Of (E, Prim_Op) ! then ! Derive_Subprogram (New_Op, Alias (Prim_Op), E, Etype (E)); ! end if; ! ! Next_Entity (Prim_Op); ! end loop; ! end if; end if; Next_Entity (E); *************** package body Sem_Ch7 is *** 1355,1363 **** if Priv_Is_Base_Type then Set_Is_Controlled (Priv, Is_Controlled (Base_Type (Full))); - Set_Has_Task (Priv, Has_Task (Base_Type (Full))); Set_Finalize_Storage_Only (Priv, Finalize_Storage_Only (Base_Type (Full))); Set_Has_Controlled_Component (Priv, Has_Controlled_Component (Base_Type (Full))); end if; --- 1407,1415 ---- if Priv_Is_Base_Type then Set_Is_Controlled (Priv, Is_Controlled (Base_Type (Full))); Set_Finalize_Storage_Only (Priv, Finalize_Storage_Only (Base_Type (Full))); + Set_Has_Task (Priv, Has_Task (Base_Type (Full))); Set_Has_Controlled_Component (Priv, Has_Controlled_Component (Base_Type (Full))); end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch7.ads gcc-3.3/gcc/ada/sem_ch7.ads *** gcc-3.2.3/gcc/ada/sem_ch7.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch7.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch8.adb gcc-3.3/gcc/ada/sem_ch8.adb *** gcc-3.2.3/gcc/ada/sem_ch8.adb 2002-05-04 03:29:10.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch8.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.10.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Sem_Ch8 is *** 1032,1037 **** --- 1031,1090 ---- Inst_Node : Node_Id := Empty; Save_83 : Boolean := Ada_83; + function Original_Subprogram (Subp : Entity_Id) return Entity_Id; + -- Find renamed entity when the declaration is a renaming_as_body + -- and the renamed entity may itself be a renaming_as_body. Used to + -- enforce rule that a renaming_as_body is illegal if the declaration + -- occurs before the subprogram it completes is frozen, and renaming + -- indirectly renames the subprogram itself.(Defect Report 8652/0027). + + ------------------------- + -- Original_Subprogram -- + ------------------------- + + function Original_Subprogram (Subp : Entity_Id) return Entity_Id is + Orig_Decl : Node_Id; + Orig_Subp : Entity_Id; + + begin + -- First case: renamed entity is itself a renaming + + if Present (Alias (Subp)) then + return Alias (Subp); + + elsif + Nkind (Unit_Declaration_Node (Subp)) = N_Subprogram_Declaration + and then Present + (Corresponding_Body (Unit_Declaration_Node (Subp))) + then + -- Check if renamed entity is a renaming_as_body + + Orig_Decl := + Unit_Declaration_Node + (Corresponding_Body (Unit_Declaration_Node (Subp))); + + if Nkind (Orig_Decl) = N_Subprogram_Renaming_Declaration then + Orig_Subp := Entity (Name (Orig_Decl)); + + if Orig_Subp = Rename_Spec then + + -- Circularity detected. + + return Orig_Subp; + + else + return (Original_Subprogram (Orig_Subp)); + end if; + else + return Subp; + end if; + else + return Subp; + end if; + end Original_Subprogram; + + -- Start of procesing for Analyze_Subprogram_Renaming + begin -- We must test for the attribute renaming case before the Analyze -- call because otherwise Sem_Attr will complain that the attribute *************** package body Sem_Ch8 is *** 1225,1238 **** Generate_Reference (Rename_Spec, Defining_Entity (Spec), 'b'); Style.Check_Identifier (Defining_Entity (Spec), Rename_Spec); ! if not Is_Frozen (Rename_Spec) ! and then not Has_Convention_Pragma (Rename_Spec) ! then ! Set_Convention (New_S, Convention (Old_S)); end if; Check_Frozen_Renaming (N, Rename_Spec); - Check_Subtype_Conformant (New_S, Old_S, Spec); elsif Ekind (Old_S) /= E_Operator then Check_Mode_Conformant (New_S, Old_S); --- 1278,1300 ---- Generate_Reference (Rename_Spec, Defining_Entity (Spec), 'b'); Style.Check_Identifier (Defining_Entity (Spec), Rename_Spec); ! if not Is_Frozen (Rename_Spec) then ! if not Has_Convention_Pragma (Rename_Spec) then ! Set_Convention (New_S, Convention (Old_S)); ! end if; ! ! if Ekind (Old_S) /= E_Operator then ! Check_Mode_Conformant (New_S, Old_S, Spec); ! end if; ! ! if Original_Subprogram (Old_S) = Rename_Spec then ! Error_Msg_N ("unfrozen subprogram cannot rename itself ", N); ! end if; ! else ! Check_Subtype_Conformant (New_S, Old_S, Spec); end if; Check_Frozen_Renaming (N, Rename_Spec); elsif Ekind (Old_S) /= E_Operator then Check_Mode_Conformant (New_S, Old_S); *************** package body Sem_Ch8 is *** 1382,1388 **** Pack_Name : Node_Id; Pack : Entity_Id; ! function In_Previous_With_Clause (P : Entity_Id) return Boolean; -- For use clauses in a context clause, the indicated package may -- be visible and yet illegal, if it did not appear in a previous -- with clause. --- 1444,1450 ---- Pack_Name : Node_Id; Pack : Entity_Id; ! function In_Previous_With_Clause return Boolean; -- For use clauses in a context clause, the indicated package may -- be visible and yet illegal, if it did not appear in a previous -- with clause. *************** package body Sem_Ch8 is *** 1391,1397 **** -- In_Previous_With_Clause -- ----------------------------- ! function In_Previous_With_Clause (P : Entity_Id) return Boolean is Item : Node_Id; begin --- 1453,1459 ---- -- In_Previous_With_Clause -- ----------------------------- ! function In_Previous_With_Clause return Boolean is Item : Node_Id; begin *************** package body Sem_Ch8 is *** 1488,1494 **** elsif Nkind (Parent (N)) = N_Compilation_Unit and then Nkind (Pack_Name) /= N_Expanded_Name ! and then not In_Previous_With_Clause (Pack) then Error_Msg_N ("package is not directly visible", Pack_Name); --- 1550,1556 ---- elsif Nkind (Parent (N)) = N_Compilation_Unit and then Nkind (Pack_Name) /= N_Expanded_Name ! and then not In_Previous_With_Clause then Error_Msg_N ("package is not directly visible", Pack_Name); *************** package body Sem_Ch8 is *** 1524,1530 **** Find_Type (Id); if Entity (Id) /= Any_Type then ! Use_One_Type (Id, N); end if; Next (Id); --- 1586,1592 ---- Find_Type (Id); if Entity (Id) /= Any_Type then ! Use_One_Type (Id); end if; Next (Id); *************** package body Sem_Ch8 is *** 2356,2361 **** --- 2418,2432 ---- else Error_Msg_N ("non-visible declaration#!", N); end if; + + -- Set entity and its containing package as referenced. We + -- can't be sure of this, but this seems a better choice + -- to avoid unused entity messages. + + if Comes_From_Source (Ent) then + Set_Referenced (Ent); + Set_Referenced (Cunit_Entity (Get_Source_Unit (Ent))); + end if; end if; <> *************** package body Sem_Ch8 is *** 2883,2890 **** -- the scope of its declaration. procedure Find_Expanded_Name (N : Node_Id) is ! Candidate : Entity_Id := Empty; ! Selector : constant Node_Id := Selector_Name (N); P_Name : Entity_Id; O_Name : Entity_Id; Id : Entity_Id; --- 2954,2961 ---- -- the scope of its declaration. procedure Find_Expanded_Name (N : Node_Id) is ! Selector : constant Node_Id := Selector_Name (N); ! Candidate : Entity_Id := Empty; P_Name : Entity_Id; O_Name : Entity_Id; Id : Entity_Id; *************** package body Sem_Ch8 is *** 3158,3165 **** end if; Change_Selected_Component_To_Expanded_Name (N); ! Set_Entity_With_Style_Check (N, Id); ! Generate_Reference (Id, N); if Is_Type (Id) then Set_Etype (N, Id); --- 3229,3245 ---- end if; Change_Selected_Component_To_Expanded_Name (N); ! ! -- Do style check and generate reference, but skip both steps if this ! -- entity has homonyms, since we may not have the right homonym set ! -- yet. The proper homonym will be set during the resolve phase. ! ! if Has_Homonym (Id) then ! Set_Entity (N, Id); ! else ! Set_Entity_With_Style_Check (N, Id); ! Generate_Reference (Id, N); ! end if; if Is_Type (Id) then Set_Etype (N, Id); *************** package body Sem_Ch8 is *** 3952,3958 **** end if; end if; ! if Present (Etype (N)) then if Is_Fixed_Point_Type (Etype (N)) then Check_Restriction (No_Fixed_Point, N); elsif Is_Floating_Point_Type (Etype (N)) then --- 4032,4038 ---- end if; end if; ! if Present (Etype (N)) and then Comes_From_Source (N) then if Is_Fixed_Point_Type (Etype (N)) then Check_Restriction (No_Fixed_Point, N); elsif Is_Floating_Point_Type (Etype (N)) then *************** package body Sem_Ch8 is *** 4340,4346 **** while Present (P) loop if Entity (P) /= Any_Type then ! Use_One_Type (P, U); end if; Next (P); --- 4420,4426 ---- while Present (P) loop if Entity (P) /= Any_Type then ! Use_One_Type (P); end if; Next (P); *************** package body Sem_Ch8 is *** 4962,4968 **** while Present (Id) loop if Entity (Id) /= Any_Type then ! Use_One_Type (Id, Decl); end if; Next (Id); --- 5042,5048 ---- while Present (Id) loop if Entity (Id) /= Any_Type then ! Use_One_Type (Id); end if; Next (Id); *************** package body Sem_Ch8 is *** 5137,5143 **** -- Use_One_Type -- ------------------ ! procedure Use_One_Type (Id : Node_Id; N : Node_Id) is T : Entity_Id; Op_List : Elist_Id; Elmt : Elmt_Id; --- 5217,5223 ---- -- Use_One_Type -- ------------------ ! procedure Use_One_Type (Id : Node_Id) is T : Entity_Id; Op_List : Elist_Id; Elmt : Elmt_Id; *************** package body Sem_Ch8 is *** 5173,5179 **** Next_Elmt (Elmt); end loop; end if; - end Use_One_Type; ---------------- --- 5253,5258 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch8.ads gcc-3.3/gcc/ada/sem_ch8.ads *** gcc-3.2.3/gcc/ada/sem_ch8.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch8.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Sem_Ch8 is *** 177,186 **** -- re-installing use clauses of parent units. N is the use_clause that -- names P (and possibly other packages). ! procedure Use_One_Type (Id : Node_Id; N : Node_Id); -- Id is the subtype mark from a use type clause. This procedure makes -- the primitive operators of the type potentially use-visible. - -- N is the Use_Type_Clause that names Id. procedure Set_Use (L : List_Id); -- Find use clauses that are declarative items in a package declaration --- 176,184 ---- -- re-installing use clauses of parent units. N is the use_clause that -- names P (and possibly other packages). ! procedure Use_One_Type (Id : Node_Id); -- Id is the subtype mark from a use type clause. This procedure makes -- the primitive operators of the type potentially use-visible. procedure Set_Use (L : List_Id); -- Find use clauses that are declarative items in a package declaration diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch9.adb gcc-3.3/gcc/ada/sem_ch9.adb *** gcc-3.2.3/gcc/ada/sem_ch9.adb 2002-05-04 03:29:11.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch9.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Sem_Ch9 is *** 245,251 **** if Present (Formals) then New_Scope (Ityp); ! Process_Formals (Ityp, Formals, N); Create_Extra_Formals (Ityp); End_Scope; end if; --- 244,250 ---- if Present (Formals) then New_Scope (Ityp); ! Process_Formals (Formals, N); Create_Extra_Formals (Ityp); End_Scope; end if; *************** package body Sem_Ch9 is *** 275,281 **** return; else Set_Entity (Nam, Entry_Nam); ! Generate_Reference (Entry_Nam, Nam, 'b'); Style.Check_Identifier (Nam, Entry_Nam); end if; --- 274,280 ---- return; else Set_Entity (Nam, Entry_Nam); ! Generate_Reference (Entry_Nam, Nam, 'b', Set_Ref => False); Style.Check_Identifier (Nam, Entry_Nam); end if; *************** package body Sem_Ch9 is *** 399,405 **** Set_Actual_Subtypes (N, Current_Scope); Analyze (Stats); ! Process_End_Label (Handled_Statement_Sequence (N), 't'); End_Scope; end if; --- 398,404 ---- Set_Actual_Subtypes (N, Current_Scope); Analyze (Stats); ! Process_End_Label (Handled_Statement_Sequence (N), 't', Entry_Nam); End_Scope; end if; *************** package body Sem_Ch9 is *** 408,414 **** Check_Potentially_Blocking_Operation (N); Check_References (Entry_Nam, N); Set_Entry_Accepted (Entry_Nam); - end Analyze_Accept_Statement; --------------------------------- --- 407,412 ---- *************** package body Sem_Ch9 is *** 577,583 **** else Set_Has_Completion (Entry_Name); ! Generate_Reference (Entry_Name, Id, 'b'); Style.Check_Identifier (Id, Entry_Name); end if; --- 575,581 ---- else Set_Has_Completion (Entry_Name); ! Generate_Reference (Entry_Name, Id, 'b', Set_Ref => False); Style.Check_Identifier (Id, Entry_Name); end if; *************** package body Sem_Ch9 is *** 607,613 **** end if; Check_References (Entry_Name); ! Process_End_Label (Handled_Statement_Sequence (N), 't'); End_Scope; -- If this is an entry family, remove the loop created to provide --- 605,611 ---- end if; Check_References (Entry_Name); ! Process_End_Label (Handled_Statement_Sequence (N), 't', Entry_Name); End_Scope; -- If this is an entry family, remove the loop created to provide *************** package body Sem_Ch9 is *** 640,646 **** if Present (Formals) then Set_Scope (Id, Current_Scope); New_Scope (Id); ! Process_Formals (Id, Formals, Parent (N)); End_Scope; end if; --- 638,644 ---- if Present (Formals) then Set_Scope (Id, Current_Scope); New_Scope (Id); ! Process_Formals (Formals, Parent (N)); End_Scope; end if; *************** package body Sem_Ch9 is *** 694,700 **** if Present (Formals) then Set_Scope (Id, Current_Scope); New_Scope (Id); ! Process_Formals (Id, Formals, N); Create_Extra_Formals (Id); End_Scope; end if; --- 692,698 ---- if Present (Formals) then Set_Scope (Id, Current_Scope); New_Scope (Id); ! Process_Formals (Formals, N); Create_Extra_Formals (Id); End_Scope; end if; *************** package body Sem_Ch9 is *** 744,752 **** procedure Analyze_Protected_Body (N : Node_Id) is Body_Id : constant Entity_Id := Defining_Identifier (N); - Spec_Id : Entity_Id; Last_E : Entity_Id; begin Tasking_Used := True; Set_Ekind (Body_Id, E_Protected_Body); --- 742,761 ---- procedure Analyze_Protected_Body (N : Node_Id) is Body_Id : constant Entity_Id := Defining_Identifier (N); Last_E : Entity_Id; + Spec_Id : Entity_Id; + -- This is initially the entity of the protected object or protected + -- type involved, but is replaced by the protected type always in the + -- case of a single protected declaration, since this is the proper + -- scope to be used. + + Ref_Id : Entity_Id; + -- This is the entity of the protected object or protected type + -- involved, and is the entity used for cross-reference purposes + -- (it differs from Spec_Id in the case of a single protected + -- object, since Spec_Id is set to the protected type in this case). + begin Tasking_Used := True; Set_Ekind (Body_Id, E_Protected_Body); *************** package body Sem_Ch9 is *** 768,774 **** return; end if; ! Generate_Reference (Spec_Id, Body_Id, 'b'); Style.Check_Identifier (Body_Id, Spec_Id); -- The declarations are always attached to the type --- 777,784 ---- return; end if; ! Ref_Id := Spec_Id; ! Generate_Reference (Ref_Id, Body_Id, 'b', Set_Ref => False); Style.Check_Identifier (Body_Id, Spec_Id); -- The declarations are always attached to the type *************** package body Sem_Ch9 is *** 803,809 **** Check_Completion (Body_Id); Check_References (Spec_Id); ! Process_End_Label (N, 't'); End_Scope; end Analyze_Protected_Body; --- 813,819 ---- Check_Completion (Body_Id); Check_References (Spec_Id); ! Process_End_Label (N, 't', Ref_Id); End_Scope; end Analyze_Protected_Body; *************** package body Sem_Ch9 is *** 843,849 **** then Set_Convention (E, Convention_Protected); ! elsif Is_Task_Type (Etype (E)) then Set_Has_Task (Current_Scope); end if; --- 853,861 ---- then Set_Convention (E, Convention_Protected); ! elsif Is_Task_Type (Etype (E)) ! or else Has_Task (Etype (E)) ! then Set_Has_Task (Current_Scope); end if; *************** package body Sem_Ch9 is *** 851,857 **** end loop; Check_Max_Entries (N, Max_Protected_Entries); ! Process_End_Label (N, 'e'); end Analyze_Protected_Definition; ---------------------------- --- 863,869 ---- end loop; Check_Max_Entries (N, Max_Protected_Entries); ! Process_End_Label (N, 'e', Current_Scope); end Analyze_Protected_Definition; ---------------------------- *************** package body Sem_Ch9 is *** 871,876 **** --- 883,889 ---- if Ekind (T) = E_Incomplete_Type then T := Full_View (T); + Set_Completion_Referenced (T); end if; Set_Ekind (T, E_Protected_Type); *************** package body Sem_Ch9 is *** 1361,1369 **** procedure Analyze_Task_Body (N : Node_Id) is Body_Id : constant Entity_Id := Defining_Identifier (N); - Spec_Id : Entity_Id; Last_E : Entity_Id; begin Tasking_Used := True; Set_Ekind (Body_Id, E_Task_Body); --- 1374,1391 ---- procedure Analyze_Task_Body (N : Node_Id) is Body_Id : constant Entity_Id := Defining_Identifier (N); Last_E : Entity_Id; + Spec_Id : Entity_Id; + -- This is initially the entity of the task or task type involved, + -- but is replaced by the task type always in the case of a single + -- task declaration, since this is the proper scope to be used. + + Ref_Id : Entity_Id; + -- This is the entity of the task or task type, and is the entity + -- used for cross-reference purposes (it differs from Spec_Id in + -- the case of a single task, since Spec_Id is set to the task type) + begin Tasking_Used := True; Set_Ekind (Body_Id, E_Task_Body); *************** package body Sem_Ch9 is *** 1389,1395 **** return; end if; ! Generate_Reference (Spec_Id, Body_Id, 'b'); Style.Check_Identifier (Body_Id, Spec_Id); -- Deal with case of body of single task (anonymous type was created) --- 1411,1418 ---- return; end if; ! Ref_Id := Spec_Id; ! Generate_Reference (Ref_Id, Body_Id, 'b', Set_Ref => False); Style.Check_Identifier (Body_Id, Spec_Id); -- Deal with case of body of single task (anonymous type was created) *************** package body Sem_Ch9 is *** 1443,1449 **** end loop; end; ! Process_End_Label (Handled_Statement_Sequence (N), 't'); End_Scope; end Analyze_Task_Body; --- 1466,1472 ---- end loop; end; ! Process_End_Label (Handled_Statement_Sequence (N), 't', Ref_Id); End_Scope; end Analyze_Task_Body; *************** package body Sem_Ch9 is *** 1475,1481 **** end if; Check_Max_Entries (N, Max_Task_Entries); ! Process_End_Label (N, 'e'); end Analyze_Task_Definition; ----------------------- --- 1498,1504 ---- end if; Check_Max_Entries (N, Max_Task_Entries); ! Process_End_Label (N, 'e', Current_Scope); end Analyze_Task_Definition; ----------------------- *************** package body Sem_Ch9 is *** 1489,1499 **** --- 1512,1524 ---- begin Tasking_Used := True; Check_Restriction (Max_Tasks, N); + Check_Restriction (No_Tasking, N); T := Find_Type_Name (N); Generate_Definition (T); if Ekind (T) = E_Incomplete_Type then T := Full_View (T); + Set_Completion_Referenced (T); end if; Set_Ekind (T, E_Task_Type); diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_ch9.ads gcc-3.3/gcc/ada/sem_ch9.ads *** gcc-3.2.3/gcc/ada/sem_ch9.ads 2002-05-04 03:29:11.000000000 +0000 --- gcc-3.3/gcc/ada/sem_ch9.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_disp.adb gcc-3.3/gcc/ada/sem_disp.adb *** gcc-3.2.3/gcc/ada/sem_disp.adb 2002-05-04 03:29:11.000000000 +0000 --- gcc-3.3/gcc/ada/sem_disp.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Debug; use Debug; *** 31,43 **** --- 30,47 ---- with Elists; use Elists; with Einfo; use Einfo; with Exp_Disp; use Exp_Disp; + with Exp_Ch7; use Exp_Ch7; + with Exp_Tss; use Exp_Tss; with Errout; use Errout; with Hostparm; use Hostparm; with Nlists; use Nlists; + with Opt; use Opt; with Output; use Output; + with Sem; use Sem; with Sem_Ch6; use Sem_Ch6; with Sem_Eval; use Sem_Eval; with Sem_Util; use Sem_Util; + with Snames; use Snames; with Sinfo; use Sinfo; with Uintp; use Uintp; *************** package body Sem_Disp is *** 267,295 **** if Is_Abstract (Func) and then No (Controlling_Argument (N)) then ! Par := Parent (N); ! while Present (Par) loop ! if Nkind (Par) = N_Function_Call or else ! Nkind (Par) = N_Procedure_Call_Statement or else ! Nkind (Par) = N_Assignment_Statement or else ! Nkind (Par) = N_Op_Eq or else ! Nkind (Par) = N_Op_Ne ! then ! return; ! elsif Nkind (Par) = N_Qualified_Expression ! or else Nkind (Par) = N_Unchecked_Type_Conversion ! then ! Par := Parent (Par); ! else ! Error_Msg_N ! ("call to abstract function must be dispatching", N); ! return; ! end if; ! end loop; end if; end Check_Dispatching_Context; --- 271,312 ---- if Is_Abstract (Func) and then No (Controlling_Argument (N)) then ! if Present (Alias (Func)) ! and then not Is_Abstract (Alias (Func)) ! and then No (DTC_Entity (Func)) ! then ! -- private overriding of inherited abstract operation, ! -- call is legal ! Set_Entity (Name (N), Alias (Func)); ! return; ! else ! Par := Parent (N); ! while Present (Par) loop ! if (Nkind (Par) = N_Function_Call or else ! Nkind (Par) = N_Procedure_Call_Statement or else ! Nkind (Par) = N_Assignment_Statement or else ! Nkind (Par) = N_Op_Eq or else ! Nkind (Par) = N_Op_Ne) ! and then Is_Tagged_Type (Etype (Func)) ! then ! return; ! ! elsif Nkind (Par) = N_Qualified_Expression ! or else Nkind (Par) = N_Unchecked_Type_Conversion ! then ! Par := Parent (Par); ! ! else ! Error_Msg_N ! ("call to abstract function must be dispatching", N); ! return; ! end if; ! end loop; ! end if; end if; end Check_Dispatching_Context; *************** package body Sem_Disp is *** 403,409 **** --------------------------------- procedure Check_Dispatching_Operation (Subp, Old_Subp : Entity_Id) is ! Tagged_Seen : Entity_Id; Has_Dispatching_Parent : Boolean := False; Body_Is_Last_Primitive : Boolean := False; --- 420,426 ---- --------------------------------- procedure Check_Dispatching_Operation (Subp, Old_Subp : Entity_Id) is ! Tagged_Type : Entity_Id; Has_Dispatching_Parent : Boolean := False; Body_Is_Last_Primitive : Boolean := False; *************** package body Sem_Disp is *** 413,419 **** end if; Set_Is_Dispatching_Operation (Subp, False); ! Tagged_Seen := Find_Dispatching_Type (Subp); -- If Subp is derived from a dispatching operation then it should -- always be treated as dispatching. In this case various checks --- 430,436 ---- end if; Set_Is_Dispatching_Operation (Subp, False); ! Tagged_Type := Find_Dispatching_Type (Subp); -- If Subp is derived from a dispatching operation then it should -- always be treated as dispatching. In this case various checks *************** package body Sem_Disp is *** 424,436 **** Has_Dispatching_Parent := Present (Alias (Subp)) and then Is_Dispatching_Operation (Alias (Subp)); ! if No (Tagged_Seen) then return; -- The subprograms build internally after the freezing point (such as -- the Init procedure) are not primitives ! elsif Is_Frozen (Tagged_Seen) and then not Comes_From_Source (Subp) and then not Has_Dispatching_Parent then --- 441,453 ---- Has_Dispatching_Parent := Present (Alias (Subp)) and then Is_Dispatching_Operation (Alias (Subp)); ! if No (Tagged_Type) then return; -- The subprograms build internally after the freezing point (such as -- the Init procedure) are not primitives ! elsif Is_Frozen (Tagged_Type) and then not Comes_From_Source (Subp) and then not Has_Dispatching_Parent then *************** package body Sem_Disp is *** 451,457 **** and then not Has_Dispatching_Parent then if not Comes_From_Source (Subp) ! or else (Present (Old_Subp) and then not Is_Frozen (Tagged_Seen)) then null; --- 468,474 ---- and then not Has_Dispatching_Parent then if not Comes_From_Source (Subp) ! or else (Present (Old_Subp) and then not Is_Frozen (Tagged_Type)) then null; *************** package body Sem_Disp is *** 471,477 **** then declare Subp_Body : constant Node_Id := Unit_Declaration_Node (Subp); ! Decl_Item : Node_Id := Next (Parent (Tagged_Seen)); begin -- ??? The checks here for whether the type has been --- 488,494 ---- then declare Subp_Body : constant Node_Id := Unit_Declaration_Node (Subp); ! Decl_Item : Node_Id := Next (Parent (Tagged_Type)); begin -- ??? The checks here for whether the type has been *************** package body Sem_Disp is *** 548,554 **** -- case it looks suspiciously like an attempt to define a primitive -- operation. ! elsif not Is_Frozen (Tagged_Seen) then Error_Msg_N ("?not dispatching (must be defined in a package spec)", Subp); return; --- 565,571 ---- -- case it looks suspiciously like an attempt to define a primitive -- operation. ! elsif not Is_Frozen (Tagged_Type) then Error_Msg_N ("?not dispatching (must be defined in a package spec)", Subp); return; *************** package body Sem_Disp is *** 563,595 **** -- Now, we are sure that the scope is a package spec. If the subprogram -- is declared after the freezing point ot the type that's an error ! elsif Is_Frozen (Tagged_Seen) and then not Has_Dispatching_Parent then Error_Msg_N ("this primitive operation is declared too late", Subp); Error_Msg_NE ("?no primitive operations for& after this line", ! Freeze_Node (Tagged_Seen), ! Tagged_Seen); return; end if; ! Check_Controlling_Formals (Tagged_Seen, Subp); -- Now it should be a correct primitive operation, put it in the list if Present (Old_Subp) then Check_Subtype_Conformant (Subp, Old_Subp); ! Override_Dispatching_Operation (Tagged_Seen, Old_Subp, Subp); else ! Add_Dispatching_Operation (Tagged_Seen, Subp); end if; Set_Is_Dispatching_Operation (Subp, True); if not Body_Is_Last_Primitive then Set_DT_Position (Subp, No_Uint); - end if; end Check_Dispatching_Operation; ------------------------------------------ --- 580,684 ---- -- Now, we are sure that the scope is a package spec. If the subprogram -- is declared after the freezing point ot the type that's an error ! elsif Is_Frozen (Tagged_Type) and then not Has_Dispatching_Parent then Error_Msg_N ("this primitive operation is declared too late", Subp); Error_Msg_NE ("?no primitive operations for& after this line", ! Freeze_Node (Tagged_Type), ! Tagged_Type); return; end if; ! Check_Controlling_Formals (Tagged_Type, Subp); -- Now it should be a correct primitive operation, put it in the list if Present (Old_Subp) then Check_Subtype_Conformant (Subp, Old_Subp); ! Override_Dispatching_Operation (Tagged_Type, Old_Subp, Subp); else ! Add_Dispatching_Operation (Tagged_Type, Subp); end if; Set_Is_Dispatching_Operation (Subp, True); if not Body_Is_Last_Primitive then Set_DT_Position (Subp, No_Uint); + elsif Has_Controlled_Component (Tagged_Type) + and then + (Chars (Subp) = Name_Initialize + or else Chars (Subp) = Name_Adjust + or else Chars (Subp) = Name_Finalize) + then + declare + F_Node : Node_Id := Freeze_Node (Tagged_Type); + Decl : Node_Id; + Old_P : Entity_Id; + Old_Bod : Node_Id; + Old_Spec : Entity_Id; + + C_Names : constant array (1 .. 3) of Name_Id := + (Name_Initialize, + Name_Adjust, + Name_Finalize); + + D_Names : constant array (1 .. 3) of Name_Id := + (Name_uDeep_Initialize, + Name_uDeep_Adjust, + Name_uDeep_Finalize); + + begin + -- Remove previous controlled function, which was constructed + -- and analyzed when the type was frozen. This requires + -- removing the body of the redefined primitive, as well as its + -- specification if needed (there is no spec created for + -- Deep_Initialize, see exp_ch3.adb). We must also dismantle + -- the exception information that may have been generated for it + -- when zero-cost is enabled. + + for J in D_Names'Range loop + Old_P := TSS (Tagged_Type, D_Names (J)); + + if Present (Old_P) + and then Chars (Subp) = C_Names (J) + then + Old_Bod := Unit_Declaration_Node (Old_P); + Remove (Old_Bod); + Set_Is_Eliminated (Old_P); + Set_Scope (Old_P, Scope (Current_Scope)); + + if Nkind (Old_Bod) = N_Subprogram_Body + and then Present (Corresponding_Spec (Old_Bod)) + then + Old_Spec := Corresponding_Spec (Old_Bod); + Set_Has_Completion (Old_Spec, False); + + if Exception_Mechanism = Front_End_ZCX then + Set_Has_Subprogram_Descriptor (Old_Spec, False); + Set_Handler_Records (Old_Spec, No_List); + Set_Is_Eliminated (Old_Spec); + end if; + end if; + + end if; + end loop; + + Build_Late_Proc (Tagged_Type, Chars (Subp)); + + -- The new operation is added to the actions of the freeze + -- node for the type, but this node has already been analyzed, + -- so we must retrieve and analyze explicitly the one new body, + + if Present (F_Node) + and then Present (Actions (F_Node)) + then + Decl := Last (Actions (F_Node)); + Analyze (Decl); + end if; + end; + end if; end Check_Dispatching_Operation; ------------------------------------------ *************** package body Sem_Disp is *** 777,782 **** --- 866,881 ---- if Nkind (N) = N_Attribute_Reference then Typ := Etype (Prefix (N)); + + -- An allocator is dispatching if the type of qualified + -- expression is class_wide, in which case this is the + -- controlling type. + + elsif Nkind (Orig_Node) = N_Allocator + and then Nkind (Expression (Orig_Node)) = N_Qualified_Expression + then + Typ := Etype (Expression (Orig_Node)); + else Typ := Designated_Type (Typ); end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_disp.ads gcc-3.3/gcc/ada/sem_disp.ads *** gcc-3.2.3/gcc/ada/sem_disp.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/sem_disp.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_dist.adb gcc-3.3/gcc/ada/sem_dist.adb *** gcc-3.2.3/gcc/ada/sem_dist.adb 2002-05-04 03:29:12.000000000 +0000 --- gcc-3.3/gcc/ada/sem_dist.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Sem_Dist is *** 658,664 **** elsif Ekind (Typ) = E_Record_Type and then Present (Corresponding_Remote_Type (Typ)) then - -- This is a record type representing a RAS type, this must be -- expanded. --- 657,662 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_dist.ads gcc-3.3/gcc/ada/sem_dist.ads *** gcc-3.2.3/gcc/ada/sem_dist.ads 2002-05-04 03:29:12.000000000 +0000 --- gcc-3.3/gcc/ada/sem_dist.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_elab.adb gcc-3.3/gcc/ada/sem_elab.adb *** gcc-3.2.3/gcc/ada/sem_elab.adb 2002-05-04 03:29:12.000000000 +0000 --- gcc-3.3/gcc/ada/sem_elab.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.4.12.1 $ -- -- ! -- Copyright (C) 1997-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2002 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- -- *************** package body Sem_Elab is *** 179,185 **** -- Outer_Scope is the outer level scope for the original call. -- Inter_Unit_Only is set if the call is only to be checked in the -- case where it is to another unit (and skipped if within a unit). ! -- Generate_Warnings is set to True to suppress warning messages -- about missing pragma Elaborate_All's. These messages are not -- wanted for inner calls in the dynamic model. --- 178,184 ---- -- Outer_Scope is the outer level scope for the original call. -- Inter_Unit_Only is set if the call is only to be checked in the -- case where it is to another unit (and skipped if within a unit). ! -- Generate_Warnings is set to False to suppress warning messages -- about missing pragma Elaborate_All's. These messages are not -- wanted for inner calls in the dynamic model. *************** package body Sem_Elab is *** 279,284 **** --- 278,289 ---- -- Given two scopes E1 and E2, returns True if E1 is equal to E2, or -- is one of its contained scopes, False otherwise. + function Within_Elaborate_All (E : Entity_Id) return Boolean; + -- Before emitting a warning on a scope E for a missing elaborate_all, + -- check whether E may be in the context of a directly visible unit + -- U to which the pragma applies. This prevents spurious warnings when + -- the called entity is renamed within U. + ------------------ -- Check_A_Call -- ------------------ *************** package body Sem_Elab is *** 521,527 **** if Unit_Caller /= No_Unit and then Unit_Callee /= Unit_Caller - and then Unit_Callee /= No_Unit and then not Dynamic_Elaboration_Checks then E_Scope := Spec_Entity (Cunit_Entity (Unit_Caller)); --- 526,531 ---- *************** package body Sem_Elab is *** 539,545 **** E_Scope := Scope (E_Scope); end loop; ! -- For the case of not in an instance, or call within instance -- We recompute E_Scope for the error message, since we -- do NOT want to go to the unit which has the ultimate -- declaration in the case of renaming and derivation and --- 543,549 ---- E_Scope := Scope (E_Scope); end loop; ! -- For the case N is not an instance, or a call within instance -- We recompute E_Scope for the error message, since we -- do NOT want to go to the unit which has the ultimate -- declaration in the case of renaming and derivation and *************** package body Sem_Elab is *** 573,578 **** --- 577,586 ---- end loop; end if; + if Within_Elaborate_All (E_Scope) then + return; + end if; + if not Suppress_Elaboration_Warnings (Ent) and then not Suppress_Elaboration_Warnings (E_Scope) and then Elab_Warnings *************** package body Sem_Elab is *** 586,591 **** --- 594,613 ---- else Error_Msg_NE ("call to & may raise Program_Error?", N, Ent); + + if Unit_Callee = No_Unit + and then E_Scope = Current_Scope + then + -- The missing pragma cannot be on the current unit, so + -- place it on the compilation unit that contains the + -- called entity, which is more likely to be right. + + E_Scope := Ent; + + while not Is_Compilation_Unit (E_Scope) loop + E_Scope := Scope (E_Scope); + end loop; + end if; end if; Error_Msg_Qual_Level := Nat'Last; *************** package body Sem_Elab is *** 663,671 **** if Nkind (N) not in N_Generic_Instantiation then return; ! -- Nothing to do if errors already detected (avoid cascaded errors) ! elsif Errors_Detected /= 0 then return; -- Nothing to do if not in full analysis mode --- 685,693 ---- if Nkind (N) not in N_Generic_Instantiation then return; ! -- Nothing to do if serious errors detected (avoid cascaded errors) ! elsif Serious_Errors_Detected /= 0 then return; -- Nothing to do if not in full analysis mode *************** package body Sem_Elab is *** 693,699 **** end if; Nam := Name (N); ! Ent := Entity (Nam); -- The case we are interested in is when the generic spec is in the -- current declarative part --- 715,721 ---- end if; Nam := Name (N); ! Ent := Get_Generic_Entity (N); -- The case we are interested in is when the generic spec is in the -- current declarative part *************** package body Sem_Elab is *** 861,866 **** --- 883,889 ---- if Comes_From_Source (N) and then In_Preelaborated_Unit + and then not In_Inlined_Body then Error_Msg_N ("non-static call not allowed in preelaborated unit", N); *************** package body Sem_Elab is *** 1070,1076 **** -- Skip delayed calls if we had any errors ! if Errors_Detected = 0 then Delaying_Elab_Checks := False; Expander_Mode_Save_And_Set (True); --- 1093,1099 ---- -- Skip delayed calls if we had any errors ! if Serious_Errors_Detected = 0 then Delaying_Elab_Checks := False; Expander_Mode_Save_And_Set (True); *************** package body Sem_Elab is *** 1129,1135 **** end if; Nam := Name (N); ! Ent := Entity (Nam); From_Elab_Code := not In_Subprogram_Or_Concurrent_Unit; -- See if we need to analyze this instantiation. We analyze it if --- 1152,1158 ---- end if; Nam := Name (N); ! Ent := Get_Generic_Entity (N); From_Elab_Code := not In_Subprogram_Or_Concurrent_Unit; -- See if we need to analyze this instantiation. We analyze it if *************** package body Sem_Elab is *** 1214,1220 **** -- Nothing to do if errors already detected (avoid cascaded errors) ! elsif Errors_Detected /= 0 then return; -- Nothing to do if not in full analysis mode --- 1237,1243 ---- -- Nothing to do if errors already detected (avoid cascaded errors) ! elsif Serious_Errors_Detected /= 0 then return; -- Nothing to do if not in full analysis mode *************** package body Sem_Elab is *** 1584,1589 **** --- 1607,1619 ---- -- will have been elaborated already. We keep separate lists for -- each kind of task. + -- Skip this test if errors have occurred, since in this case + -- we can get false indications. + + if Total_Errors_Detected /= 0 then + return; + end if; + if Present (Proc) then if Outer_Unit (Scope (Proc)) = Enclosing then *************** package body Sem_Elab is *** 1768,1774 **** ---------------------- function Has_Generic_Body (N : Node_Id) return Boolean is ! Ent : constant Entity_Id := Entity (Name (N)); Decl : constant Node_Id := Unit_Declaration_Node (Ent); Scop : Entity_Id; --- 1798,1804 ---- ---------------------- function Has_Generic_Body (N : Node_Id) return Boolean is ! Ent : constant Entity_Id := Get_Generic_Entity (N); Decl : constant Node_Id := Unit_Declaration_Node (Ent); Scop : Entity_Id; *************** package body Sem_Elab is *** 2025,2033 **** begin if No (C) then ! R := Make_Raise_Program_Error (Loc); else ! R := Make_Raise_Program_Error (Loc, Make_Op_Not (Loc, C)); end if; if No (Declarations (ADN)) then --- 2055,2068 ---- begin if No (C) then ! R := ! Make_Raise_Program_Error (Loc, ! Reason => PE_Access_Before_Elaboration); else ! R := ! Make_Raise_Program_Error (Loc, ! Condition => Make_Op_Not (Loc, C), ! Reason => PE_Access_Before_Elaboration); end if; if No (Declarations (ADN)) then *************** package body Sem_Elab is *** 2056,2064 **** then declare Typ : constant Entity_Id := Etype (N); - R : constant Node_Id := Make_Raise_Program_Error (Loc); Chk : constant Boolean := Do_Range_Check (N); begin Set_Etype (R, Typ); --- 2091,2102 ---- then declare Typ : constant Entity_Id := Etype (N); Chk : constant Boolean := Do_Range_Check (N); + R : constant Node_Id := + Make_Raise_Program_Error (Loc, + Reason => PE_Access_Before_Elaboration); + begin Set_Etype (R, Typ); *************** package body Sem_Elab is *** 2086,2098 **** else if No (C) then Insert_Action (Nod, ! Make_Raise_Program_Error (Loc)); else Insert_Action (Nod, Make_Raise_Program_Error (Loc, Condition => Make_Op_Not (Loc, ! Right_Opnd => C))); end if; end if; end if; --- 2124,2138 ---- else if No (C) then Insert_Action (Nod, ! Make_Raise_Program_Error (Loc, ! Reason => PE_Access_Before_Elaboration)); else Insert_Action (Nod, Make_Raise_Program_Error (Loc, Condition => Make_Op_Not (Loc, ! Right_Opnd => C), ! Reason => PE_Access_Before_Elaboration)); end if; end if; end if; *************** package body Sem_Elab is *** 2284,2287 **** --- 2324,2367 ---- raise Program_Error; end Within; + -------------------------- + -- Within_Elaborate_All -- + -------------------------- + + function Within_Elaborate_All (E : Entity_Id) return Boolean is + Item : Node_Id; + Item2 : Node_Id; + Elab_Id : Entity_Id; + Par : Node_Id; + + begin + Item := First (Context_Items (Cunit (Current_Sem_Unit))); + + while Present (Item) loop + if Nkind (Item) = N_Pragma + and then Get_Pragma_Id (Chars (Item)) = Pragma_Elaborate_All + then + Elab_Id := + Entity ( + Expression (First (Pragma_Argument_Associations (Item)))); + Par := Parent (Unit_Declaration_Node (Elab_Id)); + Item2 := First (Context_Items (Par)); + + while Present (Item2) loop + if Nkind (Item2) = N_With_Clause + and then Entity (Name (Item2)) = E + then + return True; + end if; + + Next (Item2); + end loop; + end if; + + Next (Item); + end loop; + + return False; + end Within_Elaborate_All; + end Sem_Elab; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_elab.ads gcc-3.3/gcc/ada/sem_elab.ads *** gcc-3.2.3/gcc/ada/sem_elab.ads 2002-05-04 03:29:12.000000000 +0000 --- gcc-3.3/gcc/ada/sem_elab.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_elim.adb gcc-3.3/gcc/ada/sem_elim.adb *** gcc-3.2.3/gcc/ada/sem_elim.adb 2002-05-04 03:29:13.000000000 +0000 --- gcc-3.3/gcc/ada/sem_elim.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Sinfo; use Sinfo; *** 35,40 **** --- 34,40 ---- with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; + with Uintp; use Uintp; with GNAT.HTable; use GNAT.HTable; package body Sem_Elim is *************** package body Sem_Elim is *** 83,88 **** --- 83,91 ---- Result_Type : Name_Id; -- Result type name if Result_Types parameter present, No_Name if not + Homonym_Number : Uint; + -- Homonyn number if Homonym_Number parameter present, No_Uint if not. + Hash_Link : Access_Elim_Data; -- Link for hash table use *************** package body Sem_Elim is *** 197,202 **** --- 200,207 ---- Elmt : Access_Elim_Data; Scop : Entity_Id; Form : Entity_Id; + Ctr : Nat; + Ent : Entity_Id; begin if No_Elimination then *************** package body Sem_Elim is *** 280,307 **** elsif Ekind (E) = E_Function or else Ekind (E) = E_Procedure then ! -- Two parameter case always matches ! if Elmt.Result_Type = No_Name ! and then Elmt.Parameter_Types = null ! then ! Set_Is_Eliminated (E); ! return; ! -- Here we have a profile, so see if it matches ! else ! if Ekind (E) = E_Function then ! if Chars (Etype (E)) /= Elmt.Result_Type then ! goto Continue; ! end if; end if; Form := First_Formal (E); if No (Form) and then Elmt.Parameter_Types = null then ! Set_Is_Eliminated (E); ! return; elsif Elmt.Parameter_Types = null then goto Continue; --- 285,326 ---- elsif Ekind (E) = E_Function or else Ekind (E) = E_Procedure then ! -- If Homonym_Number present, then see if it matches ! if Elmt.Homonym_Number /= No_Uint then ! Ctr := 1; ! Ent := E; ! while Present (Homonym (Ent)) ! and then Scope (Ent) = Scope (Homonym (Ent)) ! loop ! Ctr := Ctr + 1; ! Ent := Homonym (Ent); ! end loop; ! if Ctr /= Elmt.Homonym_Number then ! goto Continue; end if; + end if; + -- If we have a Result_Type, then we must have a function + -- with the proper result type + + if Elmt.Result_Type /= No_Name then + if Ekind (E) /= E_Function + or else Chars (Etype (E)) /= Elmt.Result_Type + then + goto Continue; + end if; + end if; + + -- If we have Parameter_Types, they must match + + if Elmt.Parameter_Types /= null then Form := First_Formal (E); if No (Form) and then Elmt.Parameter_Types = null then ! null; elsif Elmt.Parameter_Types = null then goto Continue; *************** package body Sem_Elim is *** 319,330 **** if Present (Form) then goto Continue; - else - Set_Is_Eliminated (E); - return; end if; end if; end if; end if; <> Elmt := Elmt.Homonym; --- 338,351 ---- if Present (Form) then goto Continue; end if; end if; end if; + + -- If we fall through, this is match + + Set_Is_Eliminated (E); + return; end if; <> Elmt := Elmt.Homonym; *************** package body Sem_Elim is *** 351,363 **** (Arg_Unit_Name : Node_Id; Arg_Entity : Node_Id; Arg_Parameter_Types : Node_Id; ! Arg_Result_Type : Node_Id) is - Argx_Unit_Name : Node_Id; - Argx_Entity : Node_Id; - Argx_Parameter_Types : Node_Id; - Argx_Result_Type : Node_Id; - Data : constant Access_Elim_Data := new Elim_Data; -- Build result data here --- 372,380 ---- (Arg_Unit_Name : Node_Id; Arg_Entity : Node_Id; Arg_Parameter_Types : Node_Id; ! Arg_Result_Type : Node_Id; ! Arg_Homonym_Number : Node_Id) is Data : constant Access_Elim_Data := new Elim_Data; -- Build result data here *************** package body Sem_Elim is *** 366,372 **** Num_Names : Nat := 0; -- Number of names in unit name ! Lit : Node_Id; function OK_Selected_Component (N : Node_Id) return Boolean; -- Test if N is a selected component with all identifiers, or a --- 383,391 ---- Num_Names : Nat := 0; -- Number of names in unit name ! Lit : Node_Id; ! Arg_Ent : Entity_Id; ! Arg_Uname : Node_Id; function OK_Selected_Component (N : Node_Id) return Boolean; -- Test if N is a selected component with all identifiers, or a *************** package body Sem_Elim is *** 402,465 **** -- Process Unit_Name argument ! Argx_Unit_Name := Expression (Arg_Unit_Name); ! ! if Nkind (Argx_Unit_Name) = N_Identifier then ! Data.Unit_Name := new Names'(1 => Chars (Argx_Unit_Name)); Num_Names := 1; ! elsif OK_Selected_Component (Argx_Unit_Name) then Data.Unit_Name := new Names (1 .. Num_Names); for J in reverse 2 .. Num_Names loop ! Data.Unit_Name (J) := Chars (Selector_Name (Argx_Unit_Name)); ! Argx_Unit_Name := Prefix (Argx_Unit_Name); end loop; ! Data.Unit_Name (1) := Chars (Argx_Unit_Name); else Error_Msg_N ! ("wrong form for Unit_Name parameter of pragma%", ! Argx_Unit_Name); return; end if; -- Process Entity argument if Present (Arg_Entity) then - Argx_Entity := Expression (Arg_Entity); Num_Names := 0; ! if Nkind (Argx_Entity) = N_Identifier ! or else Nkind (Argx_Entity) = N_Operator_Symbol then ! Data.Entity_Name := Chars (Argx_Entity); ! Data.Entity_Node := Argx_Entity; Data.Entity_Scope := null; ! elsif OK_Selected_Component (Argx_Entity) then Data.Entity_Scope := new Names (1 .. Num_Names - 1); ! Data.Entity_Name := Chars (Selector_Name (Argx_Entity)); ! Data.Entity_Node := Argx_Entity; ! Argx_Entity := Prefix (Argx_Entity); for J in reverse 2 .. Num_Names - 1 loop ! Data.Entity_Scope (J) := Chars (Selector_Name (Argx_Entity)); ! Argx_Entity := Prefix (Argx_Entity); end loop; ! Data.Entity_Scope (1) := Chars (Argx_Entity); ! elsif Nkind (Argx_Entity) = N_String_Literal then ! String_To_Name_Buffer (Strval (Argx_Entity)); Data.Entity_Name := Name_Find; ! Data.Entity_Node := Argx_Entity; else Error_Msg_N ("wrong form for Entity_Argument parameter of pragma%", ! Argx_Unit_Name); return; end if; else --- 421,481 ---- -- Process Unit_Name argument ! if Nkind (Arg_Unit_Name) = N_Identifier then ! Data.Unit_Name := new Names'(1 => Chars (Arg_Unit_Name)); Num_Names := 1; ! elsif OK_Selected_Component (Arg_Unit_Name) then Data.Unit_Name := new Names (1 .. Num_Names); + Arg_Uname := Arg_Unit_Name; for J in reverse 2 .. Num_Names loop ! Data.Unit_Name (J) := Chars (Selector_Name (Arg_Uname)); ! Arg_Uname := Prefix (Arg_Uname); end loop; ! Data.Unit_Name (1) := Chars (Arg_Uname); else Error_Msg_N ! ("wrong form for Unit_Name parameter of pragma%", Arg_Unit_Name); return; end if; -- Process Entity argument if Present (Arg_Entity) then Num_Names := 0; ! if Nkind (Arg_Entity) = N_Identifier ! or else Nkind (Arg_Entity) = N_Operator_Symbol then ! Data.Entity_Name := Chars (Arg_Entity); ! Data.Entity_Node := Arg_Entity; Data.Entity_Scope := null; ! elsif OK_Selected_Component (Arg_Entity) then Data.Entity_Scope := new Names (1 .. Num_Names - 1); ! Data.Entity_Name := Chars (Selector_Name (Arg_Entity)); ! Data.Entity_Node := Arg_Entity; ! Arg_Ent := Prefix (Arg_Entity); for J in reverse 2 .. Num_Names - 1 loop ! Data.Entity_Scope (J) := Chars (Selector_Name (Arg_Ent)); ! Arg_Ent := Prefix (Arg_Ent); end loop; ! Data.Entity_Scope (1) := Chars (Arg_Ent); ! elsif Nkind (Arg_Entity) = N_String_Literal then ! String_To_Name_Buffer (Strval (Arg_Entity)); Data.Entity_Name := Name_Find; ! Data.Entity_Node := Arg_Entity; else Error_Msg_N ("wrong form for Entity_Argument parameter of pragma%", ! Arg_Unit_Name); return; end if; else *************** package body Sem_Elim is *** 470,495 **** -- Process Parameter_Types argument if Present (Arg_Parameter_Types) then - Argx_Parameter_Types := Expression (Arg_Parameter_Types); -- Case of one name, which looks like a parenthesized literal -- rather than an aggregate. ! if Nkind (Argx_Parameter_Types) = N_String_Literal ! and then Paren_Count (Argx_Parameter_Types) = 1 then ! String_To_Name_Buffer (Strval (Argx_Parameter_Types)); Data.Parameter_Types := new Names'(1 => Name_Find); -- Otherwise must be an aggregate ! elsif Nkind (Argx_Parameter_Types) /= N_Aggregate ! or else Present (Component_Associations (Argx_Parameter_Types)) ! or else No (Expressions (Argx_Parameter_Types)) then Error_Msg_N ("Parameter_Types for pragma% must be list of string literals", ! Argx_Parameter_Types); return; -- Here for aggregate case --- 486,510 ---- -- Process Parameter_Types argument if Present (Arg_Parameter_Types) then -- Case of one name, which looks like a parenthesized literal -- rather than an aggregate. ! if Nkind (Arg_Parameter_Types) = N_String_Literal ! and then Paren_Count (Arg_Parameter_Types) = 1 then ! String_To_Name_Buffer (Strval (Arg_Parameter_Types)); Data.Parameter_Types := new Names'(1 => Name_Find); -- Otherwise must be an aggregate ! elsif Nkind (Arg_Parameter_Types) /= N_Aggregate ! or else Present (Component_Associations (Arg_Parameter_Types)) ! or else No (Expressions (Arg_Parameter_Types)) then Error_Msg_N ("Parameter_Types for pragma% must be list of string literals", ! Arg_Parameter_Types); return; -- Here for aggregate case *************** package body Sem_Elim is *** 497,505 **** else Data.Parameter_Types := new Names ! (1 .. List_Length (Expressions (Argx_Parameter_Types))); ! Lit := First (Expressions (Argx_Parameter_Types)); for J in Data.Parameter_Types'Range loop if Nkind (Lit) /= N_String_Literal then Error_Msg_N --- 512,520 ---- else Data.Parameter_Types := new Names ! (1 .. List_Length (Expressions (Arg_Parameter_Types))); ! Lit := First (Expressions (Arg_Parameter_Types)); for J in Data.Parameter_Types'Range loop if Nkind (Lit) /= N_String_Literal then Error_Msg_N *************** package body Sem_Elim is *** 518,539 **** -- Process Result_Types argument if Present (Arg_Result_Type) then - Argx_Result_Type := Expression (Arg_Result_Type); ! if Nkind (Argx_Result_Type) /= N_String_Literal then Error_Msg_N ("Result_Type argument for pragma% must be string literal", ! Argx_Result_Type); return; end if; ! String_To_Name_Buffer (Strval (Argx_Result_Type)); Data.Result_Type := Name_Find; else Data.Result_Type := No_Name; end if; -- Now link this new entry into the hash table Elmt := Elim_Hash_Table.Get (Hash_Subprograms.Get_Key (Data)); --- 533,570 ---- -- Process Result_Types argument if Present (Arg_Result_Type) then ! if Nkind (Arg_Result_Type) /= N_String_Literal then Error_Msg_N ("Result_Type argument for pragma% must be string literal", ! Arg_Result_Type); return; end if; ! String_To_Name_Buffer (Strval (Arg_Result_Type)); Data.Result_Type := Name_Find; else Data.Result_Type := No_Name; end if; + -- Process Homonym_Number argument + + if Present (Arg_Homonym_Number) then + + if Nkind (Arg_Homonym_Number) /= N_Integer_Literal then + Error_Msg_N + ("Homonym_Number argument for pragma% must be integer literal", + Arg_Homonym_Number); + return; + end if; + + Data.Homonym_Number := Intval (Arg_Homonym_Number); + + else + Data.Homonym_Number := No_Uint; + end if; + -- Now link this new entry into the hash table Elmt := Elim_Hash_Table.Get (Hash_Subprograms.Get_Key (Data)); diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_elim.ads gcc-3.3/gcc/ada/sem_elim.ads *** gcc-3.2.3/gcc/ada/sem_elim.ads 2002-05-07 08:22:32.000000000 +0000 --- gcc-3.3/gcc/ada/sem_elim.ads 2002-10-23 07:33:32.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1997 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1997-2001 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- -- *************** package Sem_Elim is *** 39,51 **** (Arg_Unit_Name : Node_Id; Arg_Entity : Node_Id; Arg_Parameter_Types : Node_Id; ! Arg_Result_Type : Node_Id); -- Process eliminate pragma. The number of arguments has been checked, -- as well as possible optional identifiers, but no other checks have -- been made. This subprogram completes the checking, and then if the -- pragma is well formed, makes appropriate entries in the internal ! -- tables used to keep track of Eliminate pragmas. The four arguments ! -- are the possible pragma arguments (set to Empty if not present). procedure Check_Eliminated (E : Entity_Id); -- Checks if entity E is eliminated, and if so sets the Is_Eliminated --- 38,52 ---- (Arg_Unit_Name : Node_Id; Arg_Entity : Node_Id; Arg_Parameter_Types : Node_Id; ! Arg_Result_Type : Node_Id; ! Arg_Homonym_Number : Node_Id); -- Process eliminate pragma. The number of arguments has been checked, -- as well as possible optional identifiers, but no other checks have -- been made. This subprogram completes the checking, and then if the -- pragma is well formed, makes appropriate entries in the internal ! -- tables used to keep track of Eliminate pragmas. The five arguments ! -- are expressions (not pragma argument associations) for the possible ! -- pragma arguments. A parameter that is not present is set to Empty. procedure Check_Eliminated (E : Entity_Id); -- Checks if entity E is eliminated, and if so sets the Is_Eliminated diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_eval.adb gcc-3.3/gcc/ada/sem_eval.adb *** gcc-3.2.3/gcc/ada/sem_eval.adb 2002-05-04 03:29:13.000000000 +0000 --- gcc-3.3/gcc/ada/sem_eval.adb 2002-10-23 07:33:32.000000000 +0000 *************** *** 1,4 **** ! ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- --- 1,4 ---- ! --------------------- -- -- -- GNAT COMPILER COMPONENTS -- -- -- *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Einfo; use Einfo; *** 33,38 **** --- 32,38 ---- with Elists; use Elists; with Errout; use Errout; with Eval_Fat; use Eval_Fat; + with Exp_Util; use Exp_Util; with Nmake; use Nmake; with Nlists; use Nlists; with Opt; use Opt; *************** with Sinfo; use Sinfo; *** 47,52 **** --- 47,53 ---- with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; + with Tbuild; use Tbuild; package body Sem_Eval is *************** package body Sem_Eval is *** 96,113 **** type Bits is array (Nat range <>) of Boolean; -- Used to convert unsigned (modular) values for folding logical ops ----------------------- -- Local Subprograms -- ----------------------- - function OK_Bits (N : Node_Id; Bits : Uint) return Boolean; - -- Bits represents the number of bits in an integer value to be computed - -- (but the value has not been computed yet). If this value in Bits is - -- reasonable, a result of True is returned, with the implication that - -- the caller should go ahead and complete the calculation. If the value - -- in Bits is unreasonably large, then an error is posted on node N, and - -- False is returned (and the caller skips the proposed calculation). - function From_Bits (B : Bits; T : Entity_Id) return Uint; -- Converts a bit string of length B'Length to a Uint value to be used -- for a target of type T, which is a modular type. This procedure --- 97,133 ---- type Bits is array (Nat range <>) of Boolean; -- Used to convert unsigned (modular) values for folding logical ops + -- The following definitions are used to maintain a cache of nodes that + -- have compile time known values. The cache is maintained only for + -- discrete types (the most common case), and is populated by calls to + -- Compile_Time_Known_Value and Expr_Value, but only used by Expr_Value + -- since it is possible for the status to change (in particular it is + -- possible for a node to get replaced by a constraint error node). + + CV_Bits : constant := 5; + -- Number of low order bits of Node_Id value used to reference entries + -- in the cache table. + + CV_Cache_Size : constant Nat := 2 ** CV_Bits; + -- Size of cache for compile time values + + subtype CV_Range is Nat range 0 .. CV_Cache_Size; + + type CV_Entry is record + N : Node_Id; + V : Uint; + end record; + + type CV_Cache_Array is array (CV_Range) of CV_Entry; + + CV_Cache : CV_Cache_Array := (others => (Node_High_Bound, Uint_0)); + -- This is the actual cache, with entries consisting of node/value pairs, + -- and the impossible value Node_High_Bound used for unset entries. + ----------------------- -- Local Subprograms -- ----------------------- function From_Bits (B : Bits; T : Entity_Id) return Uint; -- Converts a bit string of length B'Length to a Uint value to be used -- for a target of type T, which is a modular type. This procedure *************** package body Sem_Eval is *** 121,126 **** --- 141,154 ---- -- two must be available, or the operand would not have been marked -- as foldable in the earlier analysis of the operation). + function OK_Bits (N : Node_Id; Bits : Uint) return Boolean; + -- Bits represents the number of bits in an integer value to be computed + -- (but the value has not been computed yet). If this value in Bits is + -- reasonable, a result of True is returned, with the implication that + -- the caller should go ahead and complete the calculation. If the value + -- in Bits is unreasonably large, then an error is posted on node N, and + -- False is returned (and the caller skips the proposed calculation). + procedure Out_Of_Range (N : Node_Id); -- This procedure is called if it is determined that node N, which -- appears in a non-static context, is a compile time known value *************** package body Sem_Eval is *** 218,228 **** and then not Is_Machine_Number (N) and then not Is_Generic_Type (Etype (N)) and then Etype (N) /= Universal_Real - and then not Debug_Flag_S - and then (not Debug_Flag_T - or else - (Nkind (Parent (N)) = N_Object_Declaration - and then Constant_Present (Parent (N)))) then -- Check that value is in bounds before converting to machine -- number, so as not to lose case where value overflows in the --- 246,251 ---- *************** package body Sem_Eval is *** 282,288 **** Intval (N) > Expr_Value (Type_High_Bound (Universal_Integer))) then Apply_Compile_Time_Constraint_Error ! (N, "non-static universal integer value out of range?"); -- Check out of range of base type --- 305,312 ---- Intval (N) > Expr_Value (Type_High_Bound (Universal_Integer))) then Apply_Compile_Time_Constraint_Error ! (N, "non-static universal integer value out of range?", ! CE_Range_Check_Failed); -- Check out of range of base type *************** package body Sem_Eval is *** 302,308 **** elsif Is_Out_Of_Range (N, T) then Apply_Compile_Time_Constraint_Error ! (N, "value not in range of}?"); elsif Checks_On then Enable_Range_Check (N); --- 326,332 ---- elsif Is_Out_Of_Range (N, T) then Apply_Compile_Time_Constraint_Error ! (N, "value not in range of}?", CE_Range_Check_Failed); elsif Checks_On then Enable_Range_Check (N); *************** package body Sem_Eval is *** 327,332 **** --- 351,357 ---- then Apply_Compile_Time_Constraint_Error (N, "string length wrong for}?", + CE_Length_Check_Failed, Ent => Ttype, Typ => Ttype); end if; *************** package body Sem_Eval is *** 541,546 **** --- 566,583 ---- -- Start of processing for Compile_Time_Compare begin + -- If either operand could raise constraint error, then we cannot + -- know the result at compile time (since CE may be raised!) + + if not (Cannot_Raise_Constraint_Error (L) + and then + Cannot_Raise_Constraint_Error (R)) + then + return Unknown; + end if; + + -- Identical operands are most certainly equal + if L = R then return EQ; *************** package body Sem_Eval is *** 684,690 **** ------------------------------ function Compile_Time_Known_Value (Op : Node_Id) return Boolean is ! K : constant Node_Kind := Nkind (Op); begin -- Never known at compile time if bad type or raises constraint error --- 721,728 ---- ------------------------------ function Compile_Time_Known_Value (Op : Node_Id) return Boolean is ! K : constant Node_Kind := Nkind (Op); ! CV_Ent : CV_Entry renames CV_Cache (Nat (Op) mod CV_Cache_Size); begin -- Never known at compile time if bad type or raises constraint error *************** package body Sem_Eval is *** 719,728 **** if Ekind (E) = E_Enumeration_Literal then return True; ! elsif Ekind (E) /= E_Constant then ! return False; ! ! else V := Constant_Value (E); return Present (V) and then Compile_Time_Known_Value (V); end if; --- 757,763 ---- if Ekind (E) = E_Enumeration_Literal then return True; ! elsif Ekind (E) = E_Constant then V := Constant_Value (E); return Present (V) and then Compile_Time_Known_Value (V); end if; *************** package body Sem_Eval is *** 731,740 **** -- We have a value, see if it is compile time known else ! -- Literals and NULL are known at compile time ! if K = N_Integer_Literal ! or else K = N_Character_Literal or else K = N_Real_Literal --- 766,781 ---- -- We have a value, see if it is compile time known else ! -- Integer literals are worth storing in the cache ! if K = N_Integer_Literal then ! CV_Ent.N := Op; ! CV_Ent.V := Intval (Op); ! return True; ! ! -- Other literals and NULL are known at compile time ! ! elsif K = N_Character_Literal or else K = N_Real_Literal *************** package body Sem_Eval is *** 751,764 **** elsif K = N_Attribute_Reference then return Attribute_Name (Op) = Name_Null_Parameter; ! -- All other types of values are not known at compile time ! else ! return False; ! end if; ! end if; end Compile_Time_Known_Value; -------------------------------------- --- 792,810 ---- elsif K = N_Attribute_Reference then return Attribute_Name (Op) = Name_Null_Parameter; + end if; + end if; ! -- If we fall through, not known at compile time ! return False; ! -- If we get an exception while trying to do this test, then some error ! -- has occurred, and we simply say that the value is not known after all ! ! exception ! when others => ! return False; end Compile_Time_Known_Value; -------------------------------------- *************** package body Sem_Eval is *** 931,937 **** if Right_Int = 0 then Apply_Compile_Time_Constraint_Error ! (N, "division by zero"); return; else Result := Left_Int / Right_Int; --- 977,983 ---- if Right_Int = 0 then Apply_Compile_Time_Constraint_Error ! (N, "division by zero", CE_Divide_By_Zero); return; else Result := Left_Int / Right_Int; *************** package body Sem_Eval is *** 944,950 **** if Right_Int = 0 then Apply_Compile_Time_Constraint_Error ! (N, "mod with zero divisor"); return; else Result := Left_Int mod Right_Int; --- 990,996 ---- if Right_Int = 0 then Apply_Compile_Time_Constraint_Error ! (N, "mod with zero divisor", CE_Divide_By_Zero); return; else Result := Left_Int mod Right_Int; *************** package body Sem_Eval is *** 957,963 **** if Right_Int = 0 then Apply_Compile_Time_Constraint_Error ! (N, "rem with zero divisor"); return; else Result := Left_Int rem Right_Int; --- 1003,1009 ---- if Right_Int = 0 then Apply_Compile_Time_Constraint_Error ! (N, "rem with zero divisor", CE_Divide_By_Zero); return; else Result := Left_Int rem Right_Int; *************** package body Sem_Eval is *** 1011,1017 **** else pragma Assert (Nkind (N) = N_Op_Divide); if UR_Is_Zero (Right_Real) then Apply_Compile_Time_Constraint_Error ! (N, "division by zero"); return; end if; --- 1057,1063 ---- else pragma Assert (Nkind (N) = N_Op_Divide); if UR_Is_Zero (Right_Real) then Apply_Compile_Time_Constraint_Error ! (N, "division by zero", CE_Divide_By_Zero); return; end if; *************** package body Sem_Eval is *** 1023,1029 **** end if; Set_Is_Static_Expression (N, Stat); - end Eval_Arithmetic_Op; ---------------------------- --- 1069,1074 ---- *************** package body Sem_Eval is *** 1033,1038 **** --- 1078,1085 ---- -- Nothing to be done! procedure Eval_Character_Literal (N : Node_Id) is + pragma Warnings (Off, N); + begin null; end Eval_Character_Literal; *************** package body Sem_Eval is *** 1225,1232 **** -- Eval_Indexed_Component -- ---------------------------- ! -- Indexed components are never static, so the only required processing ! -- is to perform the check for non-static context on the index values. procedure Eval_Indexed_Component (N : Node_Id) is Expr : Node_Id; --- 1272,1280 ---- -- Eval_Indexed_Component -- ---------------------------- ! -- Indexed components are never static, so we need to perform the check ! -- for non-static context on the index values. Then, we check if the ! -- value can be obtained at compile time, even though it is non-static. procedure Eval_Indexed_Component (N : Node_Id) is Expr : Node_Id; *************** package body Sem_Eval is *** 1238,1243 **** --- 1286,1359 ---- Next (Expr); end loop; + -- See if this is a constant array reference + + if List_Length (Expressions (N)) = 1 + and then Is_Entity_Name (Prefix (N)) + and then Ekind (Entity (Prefix (N))) = E_Constant + and then Present (Constant_Value (Entity (Prefix (N)))) + then + declare + Loc : constant Source_Ptr := Sloc (N); + Arr : constant Node_Id := Constant_Value (Entity (Prefix (N))); + Sub : constant Node_Id := First (Expressions (N)); + + Atyp : Entity_Id; + -- Type of array + + Lin : Nat; + -- Linear one's origin subscript value for array reference + + Lbd : Node_Id; + -- Lower bound of the first array index + + Elm : Node_Id; + -- Value from constant array + + begin + Atyp := Etype (Arr); + + if Is_Access_Type (Atyp) then + Atyp := Designated_Type (Atyp); + end if; + + -- If we have an array type (we should have but perhaps there + -- are error cases where this is not the case), then see if we + -- can do a constant evaluation of the array reference. + + if Is_Array_Type (Atyp) then + if Ekind (Atyp) = E_String_Literal_Subtype then + Lbd := String_Literal_Low_Bound (Atyp); + else + Lbd := Type_Low_Bound (Etype (First_Index (Atyp))); + end if; + + if Compile_Time_Known_Value (Sub) + and then Nkind (Arr) = N_Aggregate + and then Compile_Time_Known_Value (Lbd) + and then Is_Discrete_Type (Component_Type (Atyp)) + then + Lin := UI_To_Int (Expr_Value (Sub) - Expr_Value (Lbd)) + 1; + + if List_Length (Expressions (Arr)) >= Lin then + Elm := Pick (Expressions (Arr), Lin); + + -- If the resulting expression is compile time known, + -- then we can rewrite the indexed component with this + -- value, being sure to mark the result as non-static. + -- We also reset the Sloc, in case this generates an + -- error later on (e.g. 136'Access). + + if Compile_Time_Known_Value (Elm) then + Rewrite (N, Duplicate_Subexpr_No_Checks (Elm)); + Set_Is_Static_Expression (N, False); + Set_Sloc (N, Loc); + end if; + end if; + end if; + end if; + end; + end if; end Eval_Indexed_Component; -------------------------- *************** package body Sem_Eval is *** 1552,1558 **** if Right_Int < 0 then Apply_Compile_Time_Constraint_Error ! (N, "integer exponent negative"); return; else --- 1668,1674 ---- if Right_Int < 0 then Apply_Compile_Time_Constraint_Error ! (N, "integer exponent negative", CE_Range_Check_Failed); return; else *************** package body Sem_Eval is *** 1583,1589 **** if Right_Int < 0 then Apply_Compile_Time_Constraint_Error ! (N, "zero ** negative integer"); return; else Fold_Ureal (N, Ureal_0); --- 1699,1705 ---- if Right_Int < 0 then Apply_Compile_Time_Constraint_Error ! (N, "zero ** negative integer", CE_Range_Check_Failed); return; else Fold_Ureal (N, Ureal_0); *************** package body Sem_Eval is *** 1655,1662 **** Operand : constant Node_Id := Expression (N); Target_Type : constant Entity_Id := Entity (Subtype_Mark (N)); ! Stat : Boolean; ! Fold : Boolean; begin -- Can only fold if target is string or scalar and subtype is static --- 1771,1779 ---- Operand : constant Node_Id := Expression (N); Target_Type : constant Entity_Id := Entity (Subtype_Mark (N)); ! Stat : Boolean; ! Fold : Boolean; ! Hex : Boolean; begin -- Can only fold if target is string or scalar and subtype is static *************** package body Sem_Eval is *** 1687,1698 **** --- 1804,1826 ---- return; end if; + -- Here we will fold, save Print_In_Hex indication + + Hex := Nkind (Operand) = N_Integer_Literal + and then Print_In_Hex (Operand); + -- Fold the result of qualification if Is_Discrete_Type (Target_Type) then Fold_Uint (N, Expr_Value (Operand)); Set_Is_Static_Expression (N, Stat); + -- Preserve Print_In_Hex indication + + if Hex and then Nkind (N) = N_Integer_Literal then + Set_Print_In_Hex (N); + end if; + elsif Is_Real_Type (Target_Type) then Fold_Ureal (N, Expr_Value_R (Operand)); Set_Is_Static_Expression (N, Stat); *************** package body Sem_Eval is *** 2072,2078 **** if String_Literal_Length (T) > String_Type_Len (B) then Apply_Compile_Time_Constraint_Error ! (N, "string literal too long for}", Ent => B, Typ => First_Subtype (B)); --- 2200,2206 ---- if String_Literal_Length (T) > String_Type_Len (B) then Apply_Compile_Time_Constraint_Error ! (N, "string literal too long for}", CE_Length_Check_Failed, Ent => B, Typ => First_Subtype (B)); *************** package body Sem_Eval is *** 2083,2088 **** --- 2211,2217 ---- then Apply_Compile_Time_Constraint_Error (N, "null string literal not allowed for}", + CE_Length_Check_Failed, Ent => B, Typ => First_Subtype (B)); end if; *************** package body Sem_Eval is *** 2331,2338 **** -------------------- function Expr_Rep_Value (N : Node_Id) return Uint is ! Kind : constant Node_Kind := Nkind (N); ! Ent : Entity_Id; begin if Is_Entity_Name (N) then --- 2460,2467 ---- -------------------- function Expr_Rep_Value (N : Node_Id) return Uint is ! Kind : constant Node_Kind := Nkind (N); ! Ent : Entity_Id; begin if Is_Entity_Name (N) then *************** package body Sem_Eval is *** 2363,2376 **** -- obtain the desired value from Corresponding_Integer_Value. elsif Kind = N_Real_Literal then - - -- Apply the assertion to the Underlying_Type of the literal for - -- the benefit of calls to this function in the JGNAT back end, - -- where literal types can reflect private views. - pragma Assert (Is_Fixed_Point_Type (Underlying_Type (Etype (N)))); return Corresponding_Integer_Value (N); else pragma Assert (Kind = N_Character_Literal); Ent := Entity (N); --- 2492,2509 ---- -- obtain the desired value from Corresponding_Integer_Value. elsif Kind = N_Real_Literal then pragma Assert (Is_Fixed_Point_Type (Underlying_Type (Etype (N)))); return Corresponding_Integer_Value (N); + -- Peculiar VMS case, if we have xxx'Null_Parameter, return zero + + elsif Kind = N_Attribute_Reference + and then Attribute_Name (N) = Name_Null_Parameter + then + return Uint_0; + + -- Otherwise must be character literal + else pragma Assert (Kind = N_Character_Literal); Ent := Entity (N); *************** package body Sem_Eval is *** 2394,2403 **** ---------------- function Expr_Value (N : Node_Id) return Uint is ! Kind : constant Node_Kind := Nkind (N); ! Ent : Entity_Id; begin if Is_Entity_Name (N) then Ent := Entity (N); --- 2527,2548 ---- ---------------- function Expr_Value (N : Node_Id) return Uint is ! Kind : constant Node_Kind := Nkind (N); ! CV_Ent : CV_Entry renames CV_Cache (Nat (N) mod CV_Cache_Size); ! Ent : Entity_Id; ! Val : Uint; begin + -- If already in cache, then we know it's compile time known and + -- we can return the value that was previously stored in the cache + -- since compile time known values cannot change :-) + + if CV_Ent.N = N then + return CV_Ent.V; + end if; + + -- Otherwise proceed to test value + if Is_Entity_Name (N) then Ent := Entity (N); *************** package body Sem_Eval is *** 2405,2424 **** -- created as a result of static evaluation. if Ekind (Ent) = E_Enumeration_Literal then ! return Enumeration_Pos (Ent); -- A user defined static constant else pragma Assert (Ekind (Ent) = E_Constant); ! return Expr_Value (Constant_Value (Ent)); end if; -- An integer literal that was either in the source or created -- as a result of static evaluation. elsif Kind = N_Integer_Literal then ! return Intval (N); -- A real literal for a fixed-point type. This must be the fixed-point -- case, either the literal is of a fixed-point type, or it is a bound --- 2550,2569 ---- -- created as a result of static evaluation. if Ekind (Ent) = E_Enumeration_Literal then ! Val := Enumeration_Pos (Ent); -- A user defined static constant else pragma Assert (Ekind (Ent) = E_Constant); ! Val := Expr_Value (Constant_Value (Ent)); end if; -- An integer literal that was either in the source or created -- as a result of static evaluation. elsif Kind = N_Integer_Literal then ! Val := Intval (N); -- A real literal for a fixed-point type. This must be the fixed-point -- case, either the literal is of a fixed-point type, or it is a bound *************** package body Sem_Eval is *** 2427,2445 **** elsif Kind = N_Real_Literal then - -- Apply the assertion to the Underlying_Type of the literal for - -- the benefit of calls to this function in the JGNAT back end, - -- where literal types can reflect private views. - pragma Assert (Is_Fixed_Point_Type (Underlying_Type (Etype (N)))); ! return Corresponding_Integer_Value (N); -- Peculiar VMS case, if we have xxx'Null_Parameter, return zero elsif Kind = N_Attribute_Reference and then Attribute_Name (N) = Name_Null_Parameter then ! return Uint_0; -- Otherwise must be character literal --- 2572,2586 ---- elsif Kind = N_Real_Literal then pragma Assert (Is_Fixed_Point_Type (Underlying_Type (Etype (N)))); ! Val := Corresponding_Integer_Value (N); -- Peculiar VMS case, if we have xxx'Null_Parameter, return zero elsif Kind = N_Attribute_Reference and then Attribute_Name (N) = Name_Null_Parameter then ! Val := Uint_0; -- Otherwise must be character literal *************** package body Sem_Eval is *** 2454,2465 **** -- their Pos value as usual. if No (Ent) then ! return UI_From_Int (Int (Char_Literal_Value (N))); else ! return Enumeration_Pos (Ent); end if; end if; end Expr_Value; ------------------ --- 2595,2611 ---- -- their Pos value as usual. if No (Ent) then ! Val := UI_From_Int (Int (Char_Literal_Value (N))); else ! Val := Enumeration_Pos (Ent); end if; end if; + -- Come here with Val set to value to be returned, set cache + + CV_Ent.N := N; + CV_Ent.V := Val; + return Val; end Expr_Value; ------------------ *************** package body Sem_Eval is *** 3161,3167 **** else Apply_Compile_Time_Constraint_Error ! (N, "value not in range of}"); end if; -- Here we generate a warning for the Ada 83 case, or when we are --- 3307,3313 ---- else Apply_Compile_Time_Constraint_Error ! (N, "value not in range of}", CE_Range_Check_Failed); end if; -- Here we generate a warning for the Ada 83 case, or when we are *************** package body Sem_Eval is *** 3170,3176 **** else Warn_On_Instance := True; Apply_Compile_Time_Constraint_Error ! (N, "value not in range of}?"); Warn_On_Instance := False; end if; end Out_Of_Range; --- 3316,3322 ---- else Warn_On_Instance := True; Apply_Compile_Time_Constraint_Error ! (N, "value not in range of}?", CE_Range_Check_Failed); Warn_On_Instance := False; end if; end Out_Of_Range; *************** package body Sem_Eval is *** 3201,3207 **** -- We have to build an explicit raise_ce node else ! Rewrite (N, Make_Raise_Constraint_Error (Sloc (Exp))); Set_Raises_Constraint_Error (N); Set_Etype (N, Typ); end if; --- 3347,3355 ---- -- We have to build an explicit raise_ce node else ! Rewrite (N, ! Make_Raise_Constraint_Error (Sloc (Exp), ! Reason => CE_Range_Check_Failed)); Set_Raises_Constraint_Error (N); Set_Etype (N, Typ); end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_eval.ads gcc-3.3/gcc/ada/sem_eval.ads *** gcc-3.2.3/gcc/ada/sem_eval.ads 2002-05-04 03:29:13.000000000 +0000 --- gcc-3.3/gcc/ada/sem_eval.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_intr.adb gcc-3.3/gcc/ada/sem_intr.adb *** gcc-3.2.3/gcc/ada/sem_intr.adb 2002-05-04 03:29:13.000000000 +0000 --- gcc-3.3/gcc/ada/sem_intr.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Sem_Intr is *** 145,167 **** ------------------------------ procedure Check_Intrinsic_Operator (E : Entity_Id; N : Node_Id) is ! Nam : Name_Id := Chars (E); T1 : Entity_Id; T2 : Entity_Id; - Ret : constant Entity_Id := Etype (E); begin if Nam = Name_Op_Add ! or else Nam = Name_Op_Subtract ! or else Nam = Name_Op_Multiply ! or else Nam = Name_Op_Divide then T1 := Etype (First_Formal (E)); if No (Next_Formal (First_Formal (E))) then ! -- previous error in declaration. ! return; else T2 := Etype (Next_Formal (First_Formal (E))); --- 144,188 ---- ------------------------------ procedure Check_Intrinsic_Operator (E : Entity_Id; N : Node_Id) is ! Ret : constant Entity_Id := Etype (E); ! Nam : constant Name_Id := Chars (E); T1 : Entity_Id; T2 : Entity_Id; begin + -- Aritnmetic operators + if Nam = Name_Op_Add ! or else ! Nam = Name_Op_Subtract ! or else ! Nam = Name_Op_Multiply ! or else ! Nam = Name_Op_Divide ! or else ! Nam = Name_Op_Rem ! or else ! Nam = Name_Op_Mod ! or else ! Nam = Name_Op_Abs then T1 := Etype (First_Formal (E)); if No (Next_Formal (First_Formal (E))) then ! if Nam = Name_Op_Add ! or else ! Nam = Name_Op_Subtract ! or else ! Nam = Name_Op_Abs ! then ! T2 := T1; ! ! else ! -- Previous error in declaration ! ! return; ! end if; else T2 := Etype (Next_Formal (First_Formal (E))); *************** package body Sem_Intr is *** 170,186 **** if Root_Type (T1) /= Root_Type (T2) or else Root_Type (T1) /= Root_Type (Ret) then ! Errint ( ! "types of intrinsic operator must have the same size", E, N); ! elsif not Is_Numeric_Type (T1) then ! Errint ( ! " intrinsic operator can only apply to numeric types", E, N); end if; else Errint ("incorrect context for ""Intrinsic"" convention", E, N); end if; end Check_Intrinsic_Operator; -------------------------------- --- 191,271 ---- if Root_Type (T1) /= Root_Type (T2) or else Root_Type (T1) /= Root_Type (Ret) then ! Errint ! ("types of intrinsic operator must have the same size", E, N); ! end if; ! -- Comparison operators ! ! elsif Nam = Name_Op_Eq ! or else ! Nam = Name_Op_Ge ! or else ! Nam = Name_Op_Gt ! or else ! Nam = Name_Op_Le ! or else ! Nam = Name_Op_Lt ! or else ! Nam = Name_Op_Ne ! then ! T1 := Etype (First_Formal (E)); ! ! if No (Next_Formal (First_Formal (E))) then ! ! -- Previous error in declaration ! ! return; ! ! else ! T2 := Etype (Next_Formal (First_Formal (E))); ! end if; ! ! if Root_Type (T1) /= Root_Type (T2) then ! Errint ! ("types of intrinsic operator must have the same size", E, N); ! end if; ! ! if Root_Type (Ret) /= Standard_Boolean then ! Errint ! ("result type of intrinsic comparison must be boolean", E, N); end if; + -- Exponentiation + + elsif Nam = Name_Op_Expon then + T1 := Etype (First_Formal (E)); + + if No (Next_Formal (First_Formal (E))) then + + -- Previous error in declaration + + return; + + else + T2 := Etype (Next_Formal (First_Formal (E))); + end if; + + if not (Is_Integer_Type (T1) + or else + Is_Floating_Point_Type (T1)) + or else Root_Type (T1) /= Root_Type (Ret) + or else Root_Type (T2) /= Root_Type (Standard_Integer) + then + Errint ("incorrect operands for intrinsic operator", N, E); + end if; + + -- All other operators (are there any?) are not handled + else Errint ("incorrect context for ""Intrinsic"" convention", E, N); + return; + end if; + + if not Is_Numeric_Type (T1) then + Errint ("intrinsic operator can only apply to numeric types", E, N); end if; + end Check_Intrinsic_Operator; -------------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_intr.ads gcc-3.3/gcc/ada/sem_intr.ads *** gcc-3.2.3/gcc/ada/sem_intr.ads 2002-05-07 08:22:32.000000000 +0000 --- gcc-3.3/gcc/ada/sem_intr.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_maps.adb gcc-3.3/gcc/ada/sem_maps.adb *** gcc-3.2.3/gcc/ada/sem_maps.adb 2002-05-07 08:22:32.000000000 +0000 --- gcc-3.3/gcc/ada/sem_maps.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_maps.ads gcc-3.3/gcc/ada/sem_maps.ads *** gcc-3.2.3/gcc/ada/sem_maps.ads 2002-05-04 03:29:14.000000000 +0000 --- gcc-3.3/gcc/ada/sem_maps.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_mech.adb gcc-3.3/gcc/ada/sem_mech.adb *** gcc-3.2.3/gcc/ada/sem_mech.adb 2002-05-04 03:29:14.000000000 +0000 --- gcc-3.3/gcc/ada/sem_mech.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1996-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1996-2002 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- -- *************** package body Sem_Mech is *** 384,391 **** when Convention_Fortran => -- In OpenVMS, pass a character of array of character ! -- value using Descriptor(S). Should this also test ! -- Debug_Flag_M ??? if OpenVMS_On_Target and then (Root_Type (Typ) = Standard_Character --- 383,389 ---- when Convention_Fortran => -- In OpenVMS, pass a character of array of character ! -- value using Descriptor(S). if OpenVMS_On_Target and then (Root_Type (Typ) = Standard_Character *************** package body Sem_Mech is *** 407,413 **** -- It is not clear that this is right in the long run, -- but it seems to correspond to what gnu f77 wants. - else Set_Mechanism (Formal, By_Reference); end if; --- 405,410 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_mech.ads gcc-3.3/gcc/ada/sem_mech.ads *** gcc-3.2.3/gcc/ada/sem_mech.ads 2002-05-07 08:22:32.000000000 +0000 --- gcc-3.3/gcc/ada/sem_mech.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_prag.adb gcc-3.3/gcc/ada/sem_prag.adb *** gcc-3.2.3/gcc/ada/sem_prag.adb 2002-05-04 03:29:14.000000000 +0000 --- gcc-3.3/gcc/ada/sem_prag.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with Uintp; use Uintp; *** 77,82 **** --- 76,83 ---- with Urealp; use Urealp; with Validsw; use Validsw; + with GNAT.Spelling_Checker; use GNAT.Spelling_Checker; + package body Sem_Prag is ---------------------------------------------- *************** package body Sem_Prag is *** 337,346 **** -- If any argument has an identifier, then an error message is issued, -- and Pragma_Exit is raised. - procedure Check_Non_Overloaded_Function (Arg : Node_Id); - -- Check that the given argument is the name of a local function of - -- one argument that is not overloaded in the current local scope. - procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id); -- Checks if the given argument has an identifier, and if so, requires -- it to match the given identifier name. If there is a non-matching --- 338,343 ---- *************** package body Sem_Prag is *** 576,583 **** procedure Check_Ada_83_Warning is begin - GNAT_Pragma; - if Ada_83 and then Comes_From_Source (N) then Error_Msg_N ("(Ada 83) pragma& is non-standard?", N); end if; --- 573,578 ---- *************** package body Sem_Prag is *** 1049,1081 **** end if; end Check_No_Identifiers; - ----------------------------------- - -- Check_Non_Overloaded_Function -- - ----------------------------------- - - procedure Check_Non_Overloaded_Function (Arg : Node_Id) is - Ent : Entity_Id; - - begin - Check_Arg_Is_Local_Name (Arg); - Ent := Entity (Expression (Arg)); - - if Present (Homonym (Ent)) - and then Scope (Homonym (Ent)) = Current_Scope - then - Error_Pragma_Arg - ("argument for pragma% may not be overloaded", Arg); - end if; - - if Ekind (Ent) /= E_Function - or else No (First_Formal (Ent)) - or else Present (Next_Formal (First_Formal (Ent))) - then - Error_Pragma_Arg - ("argument for pragma% must be function of one argument", Arg); - end if; - end Check_Non_Overloaded_Function; - ------------------------------- -- Check_Optional_Identifier -- ------------------------------- --- 1044,1049 ---- *************** package body Sem_Prag is *** 1481,1488 **** end if; if Index = Names'Last then ! Error_Pragma_Arg_Ident ! ("pragma% does not allow & argument", Arg); end if; end loop; end if; --- 1449,1471 ---- end if; if Index = Names'Last then ! Error_Msg_Name_1 := Chars (N); ! Error_Msg_N ("pragma% does not allow & argument", Arg); ! ! -- Check for possible misspelling ! ! for Index1 in Names'Range loop ! if Is_Bad_Spelling_Of ! (Get_Name_String (Chars (Arg)), ! Get_Name_String (Names (Index1))) ! then ! Error_Msg_Name_1 := Names (Index1); ! Error_Msg_N ("\possible misspelling of%", Arg); ! exit; ! end if; ! end loop; ! ! raise Pragma_Exit; end if; end loop; end if; *************** package body Sem_Prag is *** 1603,1611 **** E : Entity_Id; D : Node_Id; K : Node_Kind; begin - GNAT_Pragma; Check_Ada_83_Warning; Check_No_Identifiers; Check_Arg_Count (1); --- 1586,1594 ---- E : Entity_Id; D : Node_Id; K : Node_Kind; + Utyp : Entity_Id; begin Check_Ada_83_Warning; Check_No_Identifiers; Check_Arg_Count (1); *************** package body Sem_Prag is *** 1648,1653 **** --- 1631,1655 ---- if Prag_Id /= Pragma_Volatile then Set_Is_Atomic (E); + + -- An interesting improvement here. If an object of type X + -- is declared atomic, and the type X is not atomic, that's + -- a pity, since it may not have appropraite alignment etc. + -- We can rescue this in the special case where the object + -- and type are in the same unit by just setting the type + -- as atomic, so that the back end will process it as atomic. + + Utyp := Underlying_Type (Etype (E)); + + if Present (Utyp) + and then Sloc (E) > No_Location + and then Sloc (Utyp) > No_Location + and then + Get_Source_File_Index (Sloc (E)) = + Get_Source_File_Index (Sloc (Underlying_Type (Etype (E)))) + then + Set_Is_Atomic (Underlying_Type (Etype (E))); + end if; end if; Set_Is_Volatile (E); *************** package body Sem_Prag is *** 1923,1928 **** --- 1925,1931 ---- Code_Val : Uint; begin + GNAT_Pragma; Process_Extended_Import_Export_Internal_Arg (Arg_Internal); Def_Id := Entity (Arg_Internal); *************** package body Sem_Prag is *** 2506,2512 **** Next_Formal (Formal); end loop; end if; - end Process_Extended_Import_Export_Subprogram_Pragma; -------------------------- --- 2509,2514 ---- *************** package body Sem_Prag is *** 3941,3947 **** K : Node_Kind; begin - GNAT_Pragma; Check_Ada_83_Warning; Check_No_Identifiers; Check_Arg_Count (1); --- 3943,3948 ---- *************** package body Sem_Prag is *** 4212,4218 **** Set_Component_Alignment (Base_Type (Typ), Atype); end if; end if; - end Component_AlignmentP; ---------------- --- 4213,4218 ---- *************** package body Sem_Prag is *** 4256,4261 **** --- 4256,4291 ---- Process_Convention (C, E); end Convention; + --------------------------- + -- Convention_Identifier -- + --------------------------- + + -- pragma Convention_Identifier ([Name =>] IDENTIFIER, + -- [Convention =>] convention_IDENTIFIER); + + when Pragma_Convention_Identifier => Convention_Identifier : declare + Idnam : Name_Id; + Cname : Name_Id; + + begin + GNAT_Pragma; + Check_Arg_Count (2); + Check_Optional_Identifier (Arg1, Name_Name); + Check_Optional_Identifier (Arg2, Name_Convention); + Check_Arg_Is_Identifier (Arg1); + Check_Arg_Is_Identifier (Arg1); + Idnam := Chars (Expression (Arg1)); + Cname := Chars (Expression (Arg2)); + + if Is_Convention_Name (Cname) then + Record_Convention_Identifier + (Idnam, Get_Convention_Id (Cname)); + else + Error_Pragma_Arg + ("second arg for % pragma must be convention", Arg2); + end if; + end Convention_Identifier; + --------------- -- CPP_Class -- --------------- *************** package body Sem_Prag is *** 4683,4689 **** E : Entity_Id; begin - GNAT_Pragma; Check_Ada_83_Warning; -- Deal with configuration pragma case --- 4713,4718 ---- *************** package body Sem_Prag is *** 4973,5005 **** -- SELECTED_COMPONENT | -- STRING_LITERAL] -- [,[Parameter_Types =>] PARAMETER_TYPES] ! -- [,[Result_Type =>] result_SUBTYPE_MARK]); ! -- PARAMETER_TYPES ::= ! -- null ! -- (SUBTYPE_MARK, SUBTYPE_MARK, ...) ! when Pragma_Eliminate => Eliminate : begin GNAT_Pragma; - Check_Ada_83_Warning; Check_Valid_Configuration_Pragma; ! Check_At_Least_N_Arguments (1); ! Check_At_Most_N_Arguments (4); ! if Arg_Count = 3 ! and then Chars (Arg3) = Name_Result_Type ! then ! Arg4 := Arg3; ! Arg3 := Empty; ! else ! Check_Optional_Identifier (Arg1, "unit_name"); ! Check_Optional_Identifier (Arg2, Name_Entity); ! Check_Optional_Identifier (Arg3, Name_Parameter_Types); ! Check_Optional_Identifier (Arg4, Name_Result_Type); end if; ! Process_Eliminate_Pragma (Arg1, Arg2, Arg3, Arg4); end Eliminate; ------------ --- 5002,5053 ---- -- SELECTED_COMPONENT | -- STRING_LITERAL] -- [,[Parameter_Types =>] PARAMETER_TYPES] ! -- [,[Result_Type =>] result_SUBTYPE_NAME] ! -- [,[Homonym_Number =>] INTEGER_LITERAL]); ! -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME}) ! -- SUBTYPE_NAME ::= STRING_LITERAL ! when Pragma_Eliminate => Eliminate : declare ! Args : Args_List (1 .. 5); ! Names : Name_List (1 .. 5) := ( ! Name_Unit_Name, ! Name_Entity, ! Name_Parameter_Types, ! Name_Result_Type, ! Name_Homonym_Number); ! ! Unit_Name : Node_Id renames Args (1); ! Entity : Node_Id renames Args (2); ! Parameter_Types : Node_Id renames Args (3); ! Result_Type : Node_Id renames Args (4); ! Homonym_Number : Node_Id renames Args (5); ! ! begin GNAT_Pragma; Check_Valid_Configuration_Pragma; ! Gather_Associations (Names, Args); ! if No (Unit_Name) then ! Error_Pragma ("missing Unit_Name argument for pragma%"); ! end if; ! if No (Entity) ! and then (Present (Parameter_Types) ! or else ! Present (Result_Type) ! or else ! Present (Homonym_Number)) ! then ! Error_Pragma ("missing Entity argument for pragma%"); end if; ! Process_Eliminate_Pragma ! (Unit_Name, ! Entity, ! Parameter_Types, ! Result_Type, ! Homonym_Number); end Eliminate; ------------ *************** package body Sem_Prag is *** 5054,5061 **** Code : Node_Id renames Args (4); begin - GNAT_Pragma; - if Inside_A_Generic then Error_Pragma ("pragma% cannot be used for generic entities"); end if; --- 5102,5107 ---- *************** package body Sem_Prag is *** 5333,5339 **** when others => null; end case; - end External_Name_Casing; --------------------------- --- 5379,5384 ---- *************** package body Sem_Prag is *** 5373,5379 **** Error_Pragma ("duplicate pragma%, only one allowed"); elsif not Rep_Item_Too_Late (Typ, N) then ! Set_Finalize_Storage_Only (Typ, True); end if; end Finalize_Storage; --- 5418,5424 ---- Error_Pragma ("duplicate pragma%, only one allowed"); elsif not Rep_Item_Too_Late (Typ, N) then ! Set_Finalize_Storage_Only (Base_Type (Typ), True); end if; end Finalize_Storage; *************** package body Sem_Prag is *** 5476,5482 **** end case; end if; end if; - end Float_Representation; ----------- --- 5521,5526 ---- *************** package body Sem_Prag is *** 5637,5643 **** Code : Node_Id renames Args (4); begin - GNAT_Pragma; Gather_Associations (Names, Args); if Present (External) and then Present (Code) then --- 5681,5686 ---- *************** package body Sem_Prag is *** 5654,5660 **** if not Is_VMS_Exception (Entity (Internal)) then Set_Imported (Entity (Internal)); end if; - end Import_Exception; --------------------- --- 5697,5702 ---- *************** package body Sem_Prag is *** 6237,6245 **** while Present (Arg) loop Check_Arg_Is_Static_Expression (Arg, Standard_String); ! -- Store argument, converting sequences of spaces to ! -- a single null character (this is the difference in ! -- processing between Link_With, and Linker_Options). declare C : constant Char_Code := Get_Char_Code (' '); --- 6279,6288 ---- while Present (Arg) loop Check_Arg_Is_Static_Expression (Arg, Standard_String); ! -- Store argument, converting sequences of spaces ! -- to a single null character (this is one of the ! -- differences in processing between Link_With ! -- and Linker_Options). declare C : constant Char_Code := Get_Char_Code (' '); *************** package body Sem_Prag is *** 6323,6341 **** -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION}); - -- Note: the use of multiple arguments is a GNAT extension - when Pragma_Linker_Options => Linker_Options : declare Arg : Node_Id; begin if Operating_Mode = Generate_Code and then In_Extended_Main_Source_Unit (N) then - Check_Ada_83_Warning; - Check_At_Least_N_Arguments (1); - Check_No_Identifiers; - Check_Is_In_Decl_Part_Or_Package_Spec; Check_Arg_Is_Static_Expression (Arg1, Standard_String); Start_String (Strval (Expr_Value_S (Expression (Arg1)))); --- 6366,6383 ---- -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION}); when Pragma_Linker_Options => Linker_Options : declare Arg : Node_Id; begin + Check_Ada_83_Warning; + Check_No_Identifiers; + Check_Arg_Count (1); + Check_Is_In_Decl_Part_Or_Package_Spec; + if Operating_Mode = Generate_Code and then In_Extended_Main_Source_Unit (N) then Check_Arg_Is_Static_Expression (Arg1, Standard_String); Start_String (Strval (Expr_Value_S (Expression (Arg1)))); *************** package body Sem_Prag is *** 6598,6604 **** Next (Nod); end loop; - end Main_Storage; ----------------- --- 6640,6645 ---- *************** package body Sem_Prag is *** 6946,6952 **** -- exp_ch9 should use this ??? end if; end if; - end Priority; -------------------------- --- 6987,6992 ---- *************** package body Sem_Prag is *** 6997,7002 **** --- 7037,7046 ---- -- than 31 characters, or a string literal with more than -- 31 characters, and we are operating under VMS + -------------------- + -- Check_Too_Long -- + -------------------- + procedure Check_Too_Long (Arg : Node_Id) is X : Node_Id := Original_Node (Arg); *************** package body Sem_Prag is *** 7207,7213 **** (Sloc => Sloc (R_External), Strval => Str)))); Analyze (MA); - end Psect_Object; ---------- --- 7251,7256 ---- *************** package body Sem_Prag is *** 7438,7443 **** --- 7481,7491 ---- -- Restriction is active else + if Implementation_Restriction (R_Id) then + Check_Restriction + (No_Implementation_Restrictions, Arg); + end if; + Restrictions (R_Id) := True; Restrictions_Loc (R_Id) := Sloc (N); *************** package body Sem_Prag is *** 7530,7535 **** --- 7578,7584 ---- -- pragma Shared (LOCAL_NAME); when Pragma_Shared => + GNAT_Pragma; Process_Atomic_Shared_Volatile; -------------------- *************** package body Sem_Prag is *** 7666,7680 **** -- [Read =>] function_NAME, -- [Write =>] function NAME); ! when Pragma_Stream_Convert => Stream_Convert : begin GNAT_Pragma; Check_Arg_Count (3); Check_Optional_Identifier (Arg1, Name_Entity); Check_Optional_Identifier (Arg2, Name_Read); Check_Optional_Identifier (Arg3, Name_Write); Check_Arg_Is_Local_Name (Arg1); ! Check_Non_Overloaded_Function (Arg2); ! Check_Non_Overloaded_Function (Arg3); declare Typ : constant Entity_Id := --- 7715,7765 ---- -- [Read =>] function_NAME, -- [Write =>] function NAME); ! when Pragma_Stream_Convert => Stream_Convert : declare ! ! procedure Check_OK_Stream_Convert_Function (Arg : Node_Id); ! -- Check that the given argument is the name of a local ! -- function of one argument that is not overloaded earlier ! -- in the current local scope. A check is also made that the ! -- argument is a function with one parameter. ! ! -------------------------------------- ! -- Check_OK_Stream_Convert_Function -- ! -------------------------------------- ! ! procedure Check_OK_Stream_Convert_Function (Arg : Node_Id) is ! Ent : Entity_Id; ! ! begin ! Check_Arg_Is_Local_Name (Arg); ! Ent := Entity (Expression (Arg)); ! ! if Has_Homonym (Ent) then ! Error_Pragma_Arg ! ("argument for pragma% may not be overloaded", Arg); ! end if; ! ! if Ekind (Ent) /= E_Function ! or else No (First_Formal (Ent)) ! or else Present (Next_Formal (First_Formal (Ent))) ! then ! Error_Pragma_Arg ! ("argument for pragma% must be" & ! " function of one argument", Arg); ! end if; ! end Check_OK_Stream_Convert_Function; ! ! -- Start of procecessing for Stream_Convert ! ! begin GNAT_Pragma; Check_Arg_Count (3); Check_Optional_Identifier (Arg1, Name_Entity); Check_Optional_Identifier (Arg2, Name_Read); Check_Optional_Identifier (Arg3, Name_Write); Check_Arg_Is_Local_Name (Arg1); ! Check_OK_Stream_Convert_Function (Arg2); ! Check_OK_Stream_Convert_Function (Arg3); declare Typ : constant Entity_Id := *************** package body Sem_Prag is *** 7993,7999 **** else Set_Has_Task_Info_Pragma (P, True); end if; - end Task_Info; --------------- --- 8078,8083 ---- *************** package body Sem_Prag is *** 8025,8031 **** Set_Has_Task_Name_Pragma (P, True); Record_Rep_Item (Defining_Identifier (Parent (P)), N); end if; - end Task_Name; ------------------ --- 8109,8114 ---- *************** package body Sem_Prag is *** 8071,8077 **** if Rep_Item_Too_Late (Ent, N) then raise Pragma_Exit; end if; - end Task_Storage; ---------------- --- 8154,8159 ---- *************** package body Sem_Prag is *** 8339,8344 **** --- 8421,8479 ---- end if; end Unimplemented_Unit; + -------------------- + -- Universal_Data -- + -------------------- + + -- pragma Universal_Data; + + when Pragma_Universal_Data => + GNAT_Pragma; + Check_Arg_Count (0); + Check_Valid_Library_Unit_Pragma; + + if not AAMP_On_Target then + Error_Pragma ("?pragma% ignored (applies only to AAMP)"); + end if; + + ------------------ + -- Unreferenced -- + ------------------ + + -- pragma Unreferenced (local_Name {, local_Name}); + + when Pragma_Unreferenced => Unreferenced : declare + Arg_Node : Node_Id; + Arg_Expr : Node_Id; + + begin + GNAT_Pragma; + Check_At_Least_N_Arguments (1); + + Arg_Node := Arg1; + + while Present (Arg_Node) loop + Check_No_Identifier (Arg_Node); + + -- Note that the analyze call done by Check_Arg_Is_Local_Name + -- will in fact generate a reference, so that the entity will + -- have a reference, which will inhibit any warnings about it + -- not being referenced, and also properly show up in the ali + -- file as a reference. But this reference is recorded before + -- the Has_Pragma_Unreferenced flag is set, so that no warning + -- is generated for this reference. + + Check_Arg_Is_Local_Name (Arg_Node); + Arg_Expr := Get_Pragma_Arg (Arg_Node); + + if Is_Entity_Name (Arg_Expr) then + Set_Has_Pragma_Unreferenced (Entity (Arg_Expr)); + end if; + + Next (Arg_Node); + end loop; + end Unreferenced; + ------------------------------ -- Unreserve_All_Interrupts -- ------------------------------ *************** package body Sem_Prag is *** 8648,8654 **** else return False; end if; - end Is_Pragma_String_Literal; -------------------------------------- --- 8783,8788 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_prag.ads gcc-3.3/gcc/ada/sem_prag.ads *** gcc-3.2.3/gcc/ada/sem_prag.ads 2002-05-07 08:22:32.000000000 +0000 --- gcc-3.3/gcc/ada/sem_prag.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_res.adb gcc-3.3/gcc/ada/sem_res.adb *** gcc-3.2.3/gcc/ada/sem_res.adb 2002-05-04 03:29:15.000000000 +0000 --- gcc-3.3/gcc/ada/sem_res.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.6.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Sem_Res is *** 195,209 **** procedure Set_String_Literal_Subtype (N : Node_Id; Typ : Entity_Id); -- The String_Literal_Subtype is built for all strings that are not ! -- operands of a static concatenation operation. If the argument is not ! -- a String the function is a no-op. procedure Set_Slice_Subtype (N : Node_Id); -- Build subtype of array type, with the range specified by the slice. function Unique_Fixed_Point_Type (N : Node_Id) return Entity_Id; ! -- A universal_fixed expression in an universal context is unambiguous if ! -- there is only one applicable fixed point type. Determining whether -- there is only one requires a search over all visible entities, and -- happens only in very pathological cases (see 6115-006). --- 194,208 ---- procedure Set_String_Literal_Subtype (N : Node_Id; Typ : Entity_Id); -- The String_Literal_Subtype is built for all strings that are not ! -- operands of a static concatenation operation. If the argument is ! -- not a N_String_Literal node, then the call has no effect. procedure Set_Slice_Subtype (N : Node_Id); -- Build subtype of array type, with the range specified by the slice. function Unique_Fixed_Point_Type (N : Node_Id) return Entity_Id; ! -- A universal_fixed expression in an universal context is unambiguous ! -- if there is only one applicable fixed point type. Determining whether -- there is only one requires a search over all visible entities, and -- happens only in very pathological cases (see 6115-006). *************** package body Sem_Res is *** 589,594 **** --- 588,632 ---- P : Node_Id; C : Node_Id; + function Same_Argument_List return Boolean; + -- Check whether list of actuals is identical to list of formals + -- of called function (which is also the enclosing scope). + + ------------------------ + -- Same_Argument_List -- + ------------------------ + + function Same_Argument_List return Boolean is + A : Node_Id; + F : Entity_Id; + Subp : Entity_Id; + + begin + if not Is_Entity_Name (Name (N)) then + return False; + else + Subp := Entity (Name (N)); + end if; + + F := First_Formal (Subp); + A := First_Actual (N); + + while Present (F) and then Present (A) loop + if not Is_Entity_Name (A) + or else Entity (A) /= F + then + return False; + end if; + + Next_Actual (A); + Next_Formal (F); + end loop; + + return True; + end Same_Argument_List; + + -- Start of processing for Check_Infinite_Recursion + begin -- Loop moving up tree, quitting if something tells us we are -- definitely not in an infinite recursion situation. *************** package body Sem_Res is *** 608,613 **** --- 646,677 ---- elsif Nkind (P) = N_Handled_Sequence_Of_Statements and then C /= First (Statements (P)) then + -- If the call is the expression of a return statement and + -- the actuals are identical to the formals, it's worth a + -- warning. However, we skip this if there is an immediately + -- preceding raise statement, since the call is never executed. + + -- Furthermore, this corresponds to a common idiom: + + -- function F (L : Thing) return Boolean is + -- begin + -- raise Program_Error; + -- return F (L); + -- end F; + + -- for generating a stub function + + if Nkind (Parent (N)) = N_Return_Statement + and then Same_Argument_List + then + exit when not Is_List_Member (Parent (N)) + or else (Nkind (Prev (Parent (N))) /= N_Raise_Statement + and then + (Nkind (Prev (Parent (N))) not in N_Raise_xxx_Error + or else + Present (Condition (Prev (Parent (N)))))); + end if; + return False; else *************** package body Sem_Res is *** 631,646 **** Typ : Entity_Id := Etype (First_Formal (Nam)); function Uses_SS (T : Entity_Id) return Boolean; function Uses_SS (T : Entity_Id) return Boolean is Comp : Entity_Id; Expr : Node_Id; begin ! if Is_Controlled (T) ! or else Has_Controlled_Component (T) ! or else Functions_Return_By_DSP_On_Target ! then return False; elsif Is_Array_Type (T) then --- 695,716 ---- Typ : Entity_Id := Etype (First_Formal (Nam)); function Uses_SS (T : Entity_Id) return Boolean; + -- Check whether the creation of an object of the type will involve + -- use of the secondary stack. If T is a record type, this is true + -- if the expression for some component uses the secondary stack, eg. + -- through a call to a function that returns an unconstrained value. + -- False if T is controlled, because cleanups occur elsewhere. + + ------------- + -- Uses_SS -- + ------------- function Uses_SS (T : Entity_Id) return Boolean is Comp : Entity_Id; Expr : Node_Id; begin ! if Is_Controlled (T) then return False; elsif Is_Array_Type (T) then *************** package body Sem_Res is *** 676,683 **** end if; end Uses_SS; begin ! if Uses_SS (Typ) then Establish_Transient_Scope (First_Actual (N), Sec_Stack => True); end if; end Check_Initialization_Call; --- 746,763 ---- end if; end Uses_SS; + -- Start of processing for Check_Initialization_Call + begin ! -- Nothing to do if functions do not use the secondary stack for ! -- returns (i.e. they use a depressed stack pointer instead). ! ! if Functions_Return_By_DSP_On_Target then ! return; ! ! -- Otherwise establish a transient scope if the type needs it ! ! elsif Uses_SS (Typ) then Establish_Transient_Scope (First_Actual (N), Sec_Stack => True); end if; end Check_Initialization_Call; *************** package body Sem_Res is *** 690,697 **** Nam : Node_Id; begin ! if Nkind (N) in N_Has_Etype and then Etype (N) = Any_Type then ! return; end if; -- Rewrite as call if overloadable entity that is (or could be, in --- 770,785 ---- Nam : Node_Id; begin ! -- Defend against junk stuff if errors already detected ! ! if Total_Errors_Detected /= 0 then ! if Nkind (N) in N_Has_Etype and then Etype (N) = Any_Type then ! return; ! elsif Nkind (N) in N_Has_Chars ! and then Chars (N) in Error_Name_Or_No_Name ! then ! return; ! end if; end if; -- Rewrite as call if overloadable entity that is (or could be, in *************** package body Sem_Res is *** 1425,1438 **** Debug_A_Entry ("resolving ", N); ! if Is_Fixed_Point_Type (Typ) then ! Check_Restriction (No_Fixed_Point, N); ! elsif Is_Floating_Point_Type (Typ) ! and then Typ /= Universal_Real ! and then Typ /= Any_Real ! then ! Check_Restriction (No_Floating_Point, N); end if; -- Return if already analyzed --- 1513,1528 ---- Debug_A_Entry ("resolving ", N); ! if Comes_From_Source (N) then ! if Is_Fixed_Point_Type (Typ) then ! Check_Restriction (No_Fixed_Point, N); ! elsif Is_Floating_Point_Type (Typ) ! and then Typ /= Universal_Real ! and then Typ /= Any_Real ! then ! Check_Restriction (No_Floating_Point, N); ! end if; end if; -- Return if already analyzed *************** package body Sem_Res is *** 2142,2148 **** if Raises_Constraint_Error (Actval) then Rewrite (Actval, ! Make_Raise_Constraint_Error (Loc)); Set_Raises_Constraint_Error (Actval); Set_Etype (Actval, Etype (F)); end if; --- 2232,2239 ---- if Raises_Constraint_Error (Actval) then Rewrite (Actval, ! Make_Raise_Constraint_Error (Loc, ! Reason => CE_Range_Check_Failed)); Set_Raises_Constraint_Error (Actval); Set_Etype (Actval, Etype (F)); end if; *************** package body Sem_Res is *** 2194,2199 **** --- 2285,2301 ---- while Present (F) loop + -- If we have an error in any actual or formal, indicated by + -- a type of Any_Type, then abandon resolution attempt, and + -- set result type to Any_Type. + + if (No (A) or else Etype (A) = Any_Type or else Etype (F) = Any_Type) + and then Total_Errors_Detected /= 0 + then + Set_Etype (N, Any_Type); + return; + end if; + if Present (A) and then (Nkind (Parent (A)) /= N_Parameter_Association or else *************** package body Sem_Res is *** 2213,2218 **** --- 2315,2330 ---- and then Nkind (A) = N_Type_Conversion and then not Is_Class_Wide_Type (Etype (Expression (A))) then + if Ekind (F) = E_In_Out_Parameter + and then Is_Array_Type (Etype (F)) + and then Has_Aliased_Components (Etype (Expression (A))) + /= Has_Aliased_Components (Etype (F)) + then + Error_Msg_N + ("both component types in a view conversion must be" + & " aliased, or neither", A); + end if; + if Conversion_OK (A) or else Valid_Conversion (A, Etype (A), Expression (A)) then *************** package body Sem_Res is *** 2246,2251 **** --- 2358,2368 ---- end if; end if; + if Etype (A) = Any_Type then + Set_Etype (N, Any_Type); + return; + end if; + if Ekind (F) /= E_Out_Parameter then Check_Unset_Reference (A); *************** package body Sem_Res is *** 2376,2382 **** and then not Is_Controlling_Formal (F) then Error_Msg_N ("class-wide argument not allowed here!", A); ! if Is_Subprogram (Nam) then Error_Msg_Node_2 := F_Typ; Error_Msg_NE ("& is not a primitive operation of &!", A, Nam); --- 2493,2502 ---- and then not Is_Controlling_Formal (F) then Error_Msg_N ("class-wide argument not allowed here!", A); ! ! if Is_Subprogram (Nam) ! and then Comes_From_Source (Nam) ! then Error_Msg_Node_2 := F_Typ; Error_Msg_NE ("& is not a primitive operation of &!", A, Nam); *************** package body Sem_Res is *** 2386,2399 **** and then Is_Access_Type (F_Typ) and then Ekind (F_Typ) /= E_Access_Subprogram_Type and then (Is_Class_Wide_Type (Designated_Type (A_Typ)) ! or else (Nkind (A) = N_Attribute_Reference ! and then Is_Class_Wide_Type (Etype (Prefix (A))))) and then not Is_Class_Wide_Type (Designated_Type (F_Typ)) and then not Is_Controlling_Formal (F) then Error_Msg_N ("access to class-wide argument not allowed here!", A); ! if Is_Subprogram (Nam) then Error_Msg_Node_2 := Designated_Type (F_Typ); Error_Msg_NE ("& is not a primitive operation of &!", A, Nam); --- 2506,2523 ---- and then Is_Access_Type (F_Typ) and then Ekind (F_Typ) /= E_Access_Subprogram_Type and then (Is_Class_Wide_Type (Designated_Type (A_Typ)) ! or else (Nkind (A) = N_Attribute_Reference ! and then ! Is_Class_Wide_Type (Etype (Prefix (A))))) and then not Is_Class_Wide_Type (Designated_Type (F_Typ)) and then not Is_Controlling_Formal (F) then Error_Msg_N ("access to class-wide argument not allowed here!", A); ! ! if Is_Subprogram (Nam) ! and then Comes_From_Source (Nam) ! then Error_Msg_Node_2 := Designated_Type (F_Typ); Error_Msg_NE ("& is not a primitive operation of &!", A, Nam); *************** package body Sem_Res is *** 2435,2440 **** --- 2559,2585 ---- Constr : Node_Id; Disc_Exp : Node_Id; + function In_Dispatching_Context return Boolean; + -- If the allocator is an actual in a call, it is allowed to be + -- class-wide when the context is not because it is a controlling + -- actual. + + ---------------------------- + -- In_Dispatching_Context -- + ---------------------------- + + function In_Dispatching_Context return Boolean is + Par : constant Node_Id := Parent (N); + + begin + return (Nkind (Par) = N_Function_Call + or else Nkind (Par) = N_Procedure_Call_Statement) + and then Is_Entity_Name (Name (Par)) + and then Is_Dispatching_Operation (Entity (Name (Par))); + end In_Dispatching_Context; + + -- Start of processing for Resolve_Allocator + begin -- Replace general access with specific type *************** package body Sem_Res is *** 2452,2457 **** --- 2597,2603 ---- if Nkind (E) = N_Qualified_Expression then if Is_Class_Wide_Type (Etype (E)) and then not Is_Class_Wide_Type (Designated_Type (Typ)) + and then not In_Dispatching_Context then Error_Msg_N ("class-wide allocator not allowed for this access type", N); *************** package body Sem_Res is *** 2545,2551 **** Error_Msg_N ("?allocation from empty storage pool!", N); Error_Msg_N ("?Storage_Error will be raised at run time!", N); Insert_Action (N, ! Make_Raise_Storage_Error (Loc)); end; end if; end Resolve_Allocator; --- 2691,2698 ---- Error_Msg_N ("?allocation from empty storage pool!", N); Error_Msg_N ("?Storage_Error will be raised at run time!", N); Insert_Action (N, ! Make_Raise_Storage_Error (Loc, ! Reason => SE_Empty_Storage_Pool)); end; end if; end Resolve_Allocator; *************** package body Sem_Res is *** 3312,3329 **** then Check_Dispatching_Call (N); - -- If the subprogram is abstract, check that the call has a - -- controlling argument (i.e. is dispatching) or is disptaching on - -- result - - if Is_Abstract (Nam) - and then No (Controlling_Argument (N)) - and then not Is_Class_Wide_Type (Typ) - and then not Is_Tag_Indeterminate (N) - then - Error_Msg_N ("call to abstract subprogram must be dispatching", N); - end if; - elsif Is_Abstract (Nam) and then not In_Instance then --- 3459,3464 ---- *************** package body Sem_Res is *** 3592,3597 **** --- 3727,3739 ---- E : constant Entity_Id := Entity (N); begin + -- If garbage from errors, set to Any_Type and return + + if No (E) and then Total_Errors_Detected /= 0 then + Set_Etype (N, Any_Type); + return; + end if; + -- Replace named numbers by corresponding literals. Note that this is -- the one case where Resolve_Entity_Name must reset the Etype, since -- it is currently marked as universal. *************** package body Sem_Res is *** 4465,4470 **** --- 4607,4617 ---- ("no modular type available in this context", N); Set_Etype (N, Any_Type); return; + elsif Is_Modular_Integer_Type (Typ) + and then Etype (Left_Opnd (N)) = Universal_Integer + and then Etype (Right_Opnd (N)) = Universal_Integer + then + Check_For_Visible_Operator (N, B_Typ); end if; Resolve (Left_Opnd (N), B_Typ); *************** package body Sem_Res is *** 4487,4492 **** --- 4634,4641 ---- -- rule for universal types applies. procedure Resolve_Membership_Op (N : Node_Id; Typ : Entity_Id) is + pragma Warnings (Off, Typ); + L : constant Node_Id := Left_Opnd (N); R : constant Node_Id := Right_Opnd (N); T : Entity_Id; *************** package body Sem_Res is *** 4860,4865 **** --- 5009,5017 ---- -- Nothing to be done, all resolved already procedure Resolve_Operator_Symbol (N : Node_Id; Typ : Entity_Id) is + pragma Warnings (Off, N); + pragma Warnings (Off, Typ); + begin null; end Resolve_Operator_Symbol; *************** package body Sem_Res is *** 4869,4874 **** --- 5021,5028 ---- ---------------------------------- procedure Resolve_Qualified_Expression (N : Node_Id; Typ : Entity_Id) is + pragma Warnings (Off, Typ); + Target_Typ : constant Entity_Id := Entity (Subtype_Mark (N)); Expr : constant Node_Id := Expression (N); *************** package body Sem_Res is *** 5486,5492 **** or else Char_Val > Expr_Value (Comp_Typ_Hi) then Apply_Compile_Time_Constraint_Error ! (N, "character out of range?", Loc => Source_Ptr (Int (Loc) + J)); end if; end loop; --- 5640,5646 ---- or else Char_Val > Expr_Value (Comp_Typ_Hi) then Apply_Compile_Time_Constraint_Error ! (N, "character out of range?", CE_Range_Check_Failed, Loc => Source_Ptr (Int (Loc) + J)); end if; end loop; *************** package body Sem_Res is *** 5716,5721 **** --- 5870,5877 ---- (N : Node_Id; Typ : Entity_Id) is + pragma Warnings (Off, Typ); + Operand : constant Node_Id := Expression (N); Opnd_Type : constant Entity_Id := Etype (Operand); *************** package body Sem_Res is *** 5837,5843 **** Set_Etype (Index, Index_Subtype); Append (Index, Index_List); - Set_Component_Type (Slice_Subtype, Component_Type (Etype (N))); Set_First_Index (Slice_Subtype, Index); Set_Etype (Slice_Subtype, Base_Type (Etype (N))); Set_Is_Constrained (Slice_Subtype, True); --- 5993,5998 ---- *************** package body Sem_Res is *** 5872,5883 **** begin if Nkind (N) /= N_String_Literal then return; - else Subtype_Id := Create_Itype (E_String_Literal_Subtype, N); end if; - Set_Component_Type (Subtype_Id, Component_Type (Typ)); Set_String_Literal_Length (Subtype_Id, UI_From_Int (String_Length (Strval (N)))); Set_Etype (Subtype_Id, Base_Type (Typ)); --- 6027,6036 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_res.ads gcc-3.3/gcc/ada/sem_res.ads *** gcc-3.2.3/gcc/ada/sem_res.ads 2002-05-04 03:29:16.000000000 +0000 --- gcc-3.3/gcc/ada/sem_res.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_smem.adb gcc-3.3/gcc/ada/sem_smem.adb *** gcc-3.2.3/gcc/ada/sem_smem.adb 2002-05-04 03:29:17.000000000 +0000 --- gcc-3.3/gcc/ada/sem_smem.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_smem.ads gcc-3.3/gcc/ada/sem_smem.ads *** gcc-3.2.3/gcc/ada/sem_smem.ads 2002-05-07 08:22:32.000000000 +0000 --- gcc-3.3/gcc/ada/sem_smem.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1998-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_type.adb gcc-3.3/gcc/ada/sem_type.adb *** gcc-3.2.3/gcc/ada/sem_type.adb 2002-05-04 03:29:17.000000000 +0000 --- gcc-3.3/gcc/ada/sem_type.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Sem_Type is *** 525,531 **** function Covers (T1, T2 : Entity_Id) return Boolean is begin ! pragma Assert (Present (T1) and Present (T2)); -- Simplest case: same types are compatible, and types that have the -- same base type and are not generic actuals are compatible. Generic --- 524,540 ---- function Covers (T1, T2 : Entity_Id) return Boolean is begin ! -- If either operand missing, then this is an error, but ignore ! -- it (and pretend we have a cover) if errors already detected, ! -- since this may simply mean we have malformed trees. ! ! if No (T1) or else No (T2) then ! if Total_Errors_Detected /= 0 then ! return True; ! else ! raise Program_Error; ! end if; ! end if; -- Simplest case: same types are compatible, and types that have the -- same base type and are not generic actuals are compatible. Generic *************** package body Sem_Type is *** 869,875 **** Get_Next_Interp (I, It); end loop; ! if Errors_Detected > 0 then -- After some error, a formal may have Any_Type and yield -- a spurious match. To avoid cascaded errors if possible, --- 878,884 ---- Get_Next_Interp (I, It); end loop; ! if Serious_Errors_Detected > 0 then -- After some error, a formal may have Any_Type and yield -- a spurious match. To avoid cascaded errors if possible, diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_type.ads gcc-3.3/gcc/ada/sem_type.ads *** gcc-3.2.3/gcc/ada/sem_type.ads 2002-05-04 03:29:17.000000000 +0000 --- gcc-3.3/gcc/ada/sem_type.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_util.adb gcc-3.3/gcc/ada/sem_util.adb *** gcc-3.2.3/gcc/ada/sem_util.adb 2002-05-04 03:29:17.000000000 +0000 --- gcc-3.3/gcc/ada/sem_util.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 1,4 **** ! ----------------------------------------------------------------------------- -- -- -- GNAT COMPILER COMPONENTS -- -- -- --- 1,4 ---- ! ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.7.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Sem_Util is *** 106,117 **** ----------------------------------------- procedure Apply_Compile_Time_Constraint_Error ! (N : Node_Id; ! Msg : String; ! Ent : Entity_Id := Empty; ! Typ : Entity_Id := Empty; ! Loc : Source_Ptr := No_Location; ! Rep : Boolean := True) is Stat : constant Boolean := Is_Static_Expression (N); Rtyp : Entity_Id; --- 105,117 ---- ----------------------------------------- procedure Apply_Compile_Time_Constraint_Error ! (N : Node_Id; ! Msg : String; ! Reason : RT_Exception_Code; ! Ent : Entity_Id := Empty; ! Typ : Entity_Id := Empty; ! Loc : Source_Ptr := No_Location; ! Rep : Boolean := True) is Stat : constant Boolean := Is_Static_Expression (N); Rtyp : Entity_Id; *************** package body Sem_Util is *** 132,138 **** -- Now we replace the node by an N_Raise_Constraint_Error node -- This does not need reanalyzing, so set it as analyzed now. ! Rewrite (N, Make_Raise_Constraint_Error (Sloc (N))); Set_Analyzed (N, True); Set_Etype (N, Rtyp); Set_Raises_Constraint_Error (N); --- 132,140 ---- -- Now we replace the node by an N_Raise_Constraint_Error node -- This does not need reanalyzing, so set it as analyzed now. ! Rewrite (N, ! Make_Raise_Constraint_Error (Sloc (N), ! Reason => Reason)); Set_Analyzed (N, True); Set_Etype (N, Rtyp); Set_Raises_Constraint_Error (N); *************** package body Sem_Util is *** 185,198 **** Lo := Make_Attribute_Reference (Loc, ! Prefix => Duplicate_Subexpr (Obj, Name_Req => True), Attribute_Name => Name_First, Expressions => New_List ( Make_Integer_Literal (Loc, J))); Hi := Make_Attribute_Reference (Loc, ! Prefix => Duplicate_Subexpr (Obj, Name_Req => True), Attribute_Name => Name_Last, Expressions => New_List ( Make_Integer_Literal (Loc, J))); --- 187,202 ---- Lo := Make_Attribute_Reference (Loc, ! Prefix => ! Duplicate_Subexpr_No_Checks (Obj, Name_Req => True), Attribute_Name => Name_First, Expressions => New_List ( Make_Integer_Literal (Loc, J))); Hi := Make_Attribute_Reference (Loc, ! Prefix => ! Duplicate_Subexpr_No_Checks (Obj, Name_Req => True), Attribute_Name => Name_Last, Expressions => New_List ( Make_Integer_Literal (Loc, J))); *************** package body Sem_Util is *** 224,230 **** while Present (Discr) loop Append_To (Constraints, Make_Selected_Component (Loc, ! Prefix => Duplicate_Subexpr (Obj), Selector_Name => New_Occurrence_Of (Discr, Loc))); Next_Discriminant (Discr); end loop; --- 228,235 ---- while Present (Discr) loop Append_To (Constraints, Make_Selected_Component (Loc, ! Prefix => ! Duplicate_Subexpr_No_Checks (Obj), Selector_Name => New_Occurrence_Of (Discr, Loc))); Next_Discriminant (Discr); end loop; *************** package body Sem_Util is *** 677,682 **** --- 682,811 ---- Set_Has_Fully_Qualified_Name (Elab_Ent); end Build_Elaboration_Entity; + ----------------------------------- + -- Cannot_Raise_Constraint_Error -- + ----------------------------------- + + function Cannot_Raise_Constraint_Error (Expr : Node_Id) return Boolean is + begin + if Compile_Time_Known_Value (Expr) then + return True; + + elsif Do_Range_Check (Expr) then + return False; + + elsif Raises_Constraint_Error (Expr) then + return False; + + else + case Nkind (Expr) is + when N_Identifier => + return True; + + when N_Expanded_Name => + return True; + + when N_Selected_Component => + return not Do_Discriminant_Check (Expr); + + when N_Attribute_Reference => + if Do_Overflow_Check (Expr) + or else Do_Access_Check (Expr) + then + return False; + + elsif No (Expressions (Expr)) then + return True; + + else + declare + N : Node_Id := First (Expressions (Expr)); + + begin + while Present (N) loop + if Cannot_Raise_Constraint_Error (N) then + Next (N); + else + return False; + end if; + end loop; + + return True; + end; + end if; + + when N_Type_Conversion => + if Do_Overflow_Check (Expr) + or else Do_Length_Check (Expr) + or else Do_Tag_Check (Expr) + then + return False; + else + return + Cannot_Raise_Constraint_Error (Expression (Expr)); + end if; + + when N_Unchecked_Type_Conversion => + return Cannot_Raise_Constraint_Error (Expression (Expr)); + + when N_Unary_Op => + if Do_Overflow_Check (Expr) then + return False; + else + return + Cannot_Raise_Constraint_Error (Right_Opnd (Expr)); + end if; + + when N_Op_Divide | + N_Op_Mod | + N_Op_Rem + => + if Do_Division_Check (Expr) + or else Do_Overflow_Check (Expr) + then + return False; + else + return + Cannot_Raise_Constraint_Error (Left_Opnd (Expr)) + and then + Cannot_Raise_Constraint_Error (Right_Opnd (Expr)); + end if; + + when N_Op_Add | + N_Op_And | + N_Op_Concat | + N_Op_Eq | + N_Op_Expon | + N_Op_Ge | + N_Op_Gt | + N_Op_Le | + N_Op_Lt | + N_Op_Multiply | + N_Op_Ne | + N_Op_Or | + N_Op_Rotate_Left | + N_Op_Rotate_Right | + N_Op_Shift_Left | + N_Op_Shift_Right | + N_Op_Shift_Right_Arithmetic | + N_Op_Subtract | + N_Op_Xor + => + if Do_Overflow_Check (Expr) then + return False; + else + return + Cannot_Raise_Constraint_Error (Left_Opnd (Expr)) + and then + Cannot_Raise_Constraint_Error (Right_Opnd (Expr)); + end if; + + when others => + return False; + end case; + end if; + end Cannot_Raise_Constraint_Error; + -------------------------- -- Check_Fully_Declared -- -------------------------- *************** package body Sem_Util is *** 720,726 **** if Is_Protected_Type (S) then if Restricted_Profile then Insert_Before (N, ! Make_Raise_Program_Error (Loc)); Error_Msg_N ("potentially blocking operation, " & " Program Error will be raised at run time?", N); --- 849,856 ---- if Is_Protected_Type (S) then if Restricted_Profile then Insert_Before (N, ! Make_Raise_Program_Error (Loc, ! Reason => PE_Potentially_Blocking_Operation)); Error_Msg_N ("potentially blocking operation, " & " Program Error will be raised at run time?", N); *************** package body Sem_Util is *** 901,906 **** --- 1031,1037 ---- Warn : Boolean; P : Node_Id; Msgs : Boolean; + Eloc : Source_Ptr; begin -- A static constraint error in an instance body is not a fatal error. *************** package body Sem_Util is *** 911,916 **** --- 1042,1052 ---- -- No messages are generated if we already posted an error on this node if not Error_Posted (N) then + if Loc /= No_Location then + Eloc := Loc; + else + Eloc := Sloc (N); + end if; -- Make all such messages unconditional *************** package body Sem_Util is *** 978,1002 **** if Msgs then if Present (Ent) then ! Error_Msg_NE (Msgc (1 .. Msgl), N, Ent); else ! Error_Msg_NE (Msgc (1 .. Msgl), N, Etype (N)); end if; if Warn then if Inside_Init_Proc then ! Error_Msg_NE ("\& will be raised for objects of this type!?", ! N, Standard_Constraint_Error); else ! Error_Msg_NE ("\& will be raised at run time!?", ! N, Standard_Constraint_Error); end if; else ! Error_Msg_NE ("\static expression raises&!", ! N, Standard_Constraint_Error); end if; end if; end if; --- 1114,1138 ---- if Msgs then if Present (Ent) then ! Error_Msg_NEL (Msgc (1 .. Msgl), N, Ent, Eloc); else ! Error_Msg_NEL (Msgc (1 .. Msgl), N, Etype (N), Eloc); end if; if Warn then if Inside_Init_Proc then ! Error_Msg_NEL ("\& will be raised for objects of this type!?", ! N, Standard_Constraint_Error, Eloc); else ! Error_Msg_NEL ("\& will be raised at run time!?", ! N, Standard_Constraint_Error, Eloc); end if; else ! Error_Msg_NEL ("\static expression raises&!", ! N, Standard_Constraint_Error, Eloc); end if; end if; end if; *************** package body Sem_Util is *** 1923,1929 **** Make_Component_Association (Sloc (Typ), New_List (New_Occurrence_Of (D, Sloc (Typ))), ! Duplicate_Subexpr (Node (C))); exit Find_Constraint; end if; --- 2059,2065 ---- Make_Component_Association (Sloc (Typ), New_List (New_Occurrence_Of (D, Sloc (Typ))), ! Duplicate_Subexpr_No_Checks (Node (C))); exit Find_Constraint; end if; *************** package body Sem_Util is *** 2188,2193 **** --- 2324,2344 ---- end if; end Get_Enum_Lit_From_Pos; + ------------------------ + -- Get_Generic_Entity -- + ------------------------ + + function Get_Generic_Entity (N : Node_Id) return Entity_Id is + Ent : constant Entity_Id := Entity (Name (N)); + + begin + if Present (Renamed_Object (Ent)) then + return Renamed_Object (Ent); + else + return Ent; + end if; + end Get_Generic_Entity; + ---------------------- -- Get_Index_Bounds -- ---------------------- *************** package body Sem_Util is *** 2827,2834 **** Comp := Original_Record_Component (Entity (Selector_Name (Object))); if not Is_Constrained (Prefix_Type) ! and then not Is_Indefinite_Subtype (Prefix_Type) and then (Is_Declared_Within_Variant (Comp) or else Has_Dependent_Constraint (Comp)) and then not P_Aliased --- 2978,2993 ---- Comp := Original_Record_Component (Entity (Selector_Name (Object))); + -- As per AI-0017, the renaming is illegal in a generic body, + -- even if the subtype is indefinite. + if not Is_Constrained (Prefix_Type) ! and then (not Is_Indefinite_Subtype (Prefix_Type) ! or else ! (Is_Generic_Type (Prefix_Type) ! and then Ekind (Current_Scope) = E_Generic_Package ! and then In_Package_Body (Current_Scope))) ! and then (Is_Declared_Within_Variant (Comp) or else Has_Dependent_Constraint (Comp)) and then not P_Aliased *************** package body Sem_Util is *** 2944,2949 **** --- 3103,3110 ---- end; end if; + -- If no null indexes, then type is not fully initialized + return False; elsif Is_Record_Type (Typ) then *************** package body Sem_Util is *** 2966,2971 **** --- 3127,3135 ---- end loop; end; + -- No uninitialized components, so type is fully initialized. + -- Note that this catches the case of no components as well. + return True; elsif Is_Concurrent_Type (Typ) then *************** package body Sem_Util is *** 3060,3065 **** --- 3224,3234 ---- when N_Function_Call => return True; + -- A reference to the stream attribute Input is a function call. + + when N_Attribute_Reference => + return Attribute_Name (N) = Name_Input; + when N_Selected_Component => return Is_Object_Reference (Selector_Name (N)); *************** package body Sem_Util is *** 3159,3164 **** --- 3328,3453 ---- end if; end Is_OK_Variable_For_Out_Formal; + ----------------------------------- + -- Is_Partially_Initialized_Type -- + ----------------------------------- + + function Is_Partially_Initialized_Type (Typ : Entity_Id) return Boolean is + begin + if Is_Scalar_Type (Typ) then + return False; + + elsif Is_Access_Type (Typ) then + return True; + + elsif Is_Array_Type (Typ) then + + -- If component type is partially initialized, so is array type + + if Is_Partially_Initialized_Type (Component_Type (Typ)) then + return True; + + -- Otherwise we are only partially initialized if we are fully + -- initialized (this is the empty array case, no point in us + -- duplicating that code here). + + else + return Is_Fully_Initialized_Type (Typ); + end if; + + elsif Is_Record_Type (Typ) then + + -- A discriminated type is always partially initialized + + if Has_Discriminants (Typ) then + return True; + + -- A tagged type is always partially initialized + + elsif Is_Tagged_Type (Typ) then + return True; + + -- Case of non-discriminated record + + else + declare + Ent : Entity_Id; + + Component_Present : Boolean := False; + -- Set True if at least one component is present. If no + -- components are present, then record type is fully + -- initialized (another odd case, like the null array). + + begin + -- Loop through components + + Ent := First_Entity (Typ); + while Present (Ent) loop + if Ekind (Ent) = E_Component then + Component_Present := True; + + -- If a component has an initialization expression then + -- the enclosing record type is partially initialized + + if Present (Parent (Ent)) + and then Present (Expression (Parent (Ent))) + then + return True; + + -- If a component is of a type which is itself partially + -- initialized, then the enclosing record type is also. + + elsif Is_Partially_Initialized_Type (Etype (Ent)) then + return True; + end if; + end if; + + Next_Entity (Ent); + end loop; + + -- No initialized components found. If we found any components + -- they were all uninitialized so the result is false. + + if Component_Present then + return False; + + -- But if we found no components, then all the components are + -- initialized so we consider the type to be initialized. + + else + return True; + end if; + end; + end if; + + -- Concurrent types are always fully initialized + + elsif Is_Concurrent_Type (Typ) then + return True; + + -- For a private type, go to underlying type. If there is no underlying + -- type then just assume this partially initialized. Not clear if this + -- can happen in a non-error case, but no harm in testing for this. + + elsif Is_Private_Type (Typ) then + declare + U : constant Entity_Id := Underlying_Type (Typ); + + begin + if No (U) then + return True; + else + return Is_Partially_Initialized_Type (U); + end if; + end; + + -- For any other type (are there any?) assume partially initialized + + else + return True; + end if; + end Is_Partially_Initialized_Type; + ----------------------------- -- Is_RCI_Pkg_Spec_Or_Body -- ----------------------------- *************** package body Sem_Util is *** 4225,4234 **** -- Process_End_Label -- ----------------------- ! procedure Process_End_Label (N : Node_Id; Typ : Character) is Loc : Source_Ptr; Nam : Node_Id; - Ctyp : Entity_Id; Label_Ref : Boolean; -- Set True if reference to end label itself is required --- 4514,4526 ---- -- Process_End_Label -- ----------------------- ! procedure Process_End_Label ! (N : Node_Id; ! Typ : Character; ! Ent : Entity_Id) ! is Loc : Source_Ptr; Nam : Node_Id; Label_Ref : Boolean; -- Set True if reference to end label itself is required *************** package body Sem_Util is *** 4238,4251 **** -- the entity Ent. For the child unit case, this is the identifier -- from the designator. For other cases, this is simply Endl. - Ent : Entity_Id; - -- This is the entity for the construct to which the End_Label applies - procedure Generate_Parent_Ref (N : Node_Id); -- N is an identifier node that appears as a parent unit reference -- in the case where Ent is a child unit. This procedure generates -- an appropriate cross-reference entry. procedure Generate_Parent_Ref (N : Node_Id) is Parent_Ent : Entity_Id; --- 4530,4544 ---- -- the entity Ent. For the child unit case, this is the identifier -- from the designator. For other cases, this is simply Endl. procedure Generate_Parent_Ref (N : Node_Id); -- N is an identifier node that appears as a parent unit reference -- in the case where Ent is a child unit. This procedure generates -- an appropriate cross-reference entry. + ------------------------- + -- Generate_Parent_Ref -- + ------------------------- + procedure Generate_Parent_Ref (N : Node_Id) is Parent_Ent : Entity_Id; *************** package body Sem_Util is *** 4353,4393 **** end if; end if; ! -- Locate the entity to which the end label applies. Most of the ! -- time this is simply the current scope containing the construct. ! ! Ent := Current_Scope; ! ! if Chars (Ent) = Chars (Endl) then ! null; ! ! -- But in the case of single tasks and single protected objects, ! -- the current scope is the anonymous task or protected type and ! -- what we want is the object. There is no direct link so what we ! -- do is search ahead in the entity chain for the object with the ! -- matching type and name. In practice it is almost certain to be ! -- the very next entity on the chain, so this is not inefficient. ! ! else ! Ctyp := Etype (Ent); ! loop ! Next_Entity (Ent); ! ! -- If we don't find the entry we are looking for, that's ! -- odd, perhaps results from some error condition? Anyway ! -- the appropriate thing is just to abandon the attempt. ! ! if No (Ent) then ! return; ! ! -- Exit if we find the entity we are looking for ! elsif Etype (Ent) = Ctyp ! and then Chars (Ent) = Chars (Endl) ! then ! exit; ! end if; ! end loop; end if; -- If label was really there, then generate a normal reference --- 4646,4658 ---- end if; end if; ! -- If the end label is not for the given entity, then either we have ! -- some previous error, or this is a generic instantiation for which ! -- we do not need to make a cross-reference in this case anyway. In ! -- either case we simply ignore the call. ! if Chars (Ent) /= Chars (Endl) then ! return; end if; -- If label was really there, then generate a normal reference *************** package body Sem_Util is *** 4399,4409 **** if Comes_From_Source (Endl) then -- If a label reference is required, then do the style check ! -- and generate a normal cross-reference entry for the label if Label_Ref then Style.Check_Identifier (Endl, Ent); ! Generate_Reference (Ent, Endl, 'r', Set_Ref => False); end if; -- Set the location to point past the label (normally this will --- 4664,4674 ---- if Comes_From_Source (Endl) then -- If a label reference is required, then do the style check ! -- and generate an l-type cross-reference entry for the label if Label_Ref then Style.Check_Identifier (Endl, Ent); ! Generate_Reference (Ent, Endl, 'l', Set_Ref => False); end if; -- Set the location to point past the label (normally this will diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_util.ads gcc-3.3/gcc/ada/sem_util.ads *** gcc-3.2.3/gcc/ada/sem_util.ads 2002-05-04 03:29:17.000000000 +0000 --- gcc-3.3/gcc/ada/sem_util.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package Sem_Util is *** 46,71 **** -- entity is not yet known to the compiler. procedure Apply_Compile_Time_Constraint_Error ! (N : Node_Id; ! Msg : String; ! Ent : Entity_Id := Empty; ! Typ : Entity_Id := Empty; ! Loc : Source_Ptr := No_Location; ! Rep : Boolean := True); -- N is a subexpression which will raise constraint error when evaluated -- at runtime. Msg is a message that explains the reason for raising the ! -- exception. The last character is ? if the message is always a ! -- warning, even in Ada 95, and is not a ? if the message represents an ! -- illegality (because of violation of static expression rules) in Ada 95 ! -- (but not in Ada 83). Typically this routine posts all messages at ! -- the Sloc of node N. However, if Loc /= No_Location, Loc is the Sloc ! -- used to output the message. After posting the appropriate message, ! -- and if the flag Rep is set, this routine replaces the expression ! -- with an N_Raise_Constraint_Error node. This node is then marked as ! -- being static if the original node is static, but sets the flag ! -- Raises_Constraint_Error, preventing further evaluation. ! -- The error message may contain a } or & insertion character. ! -- This normally references Etype (N), unless the Ent argument is given -- explicitly, in which case it is used instead. The type of the raise -- node that is built is normally Etype (N), but if the Typ parameter -- is present, this is used instead. --- 45,71 ---- -- entity is not yet known to the compiler. procedure Apply_Compile_Time_Constraint_Error ! (N : Node_Id; ! Msg : String; ! Reason : RT_Exception_Code; ! Ent : Entity_Id := Empty; ! Typ : Entity_Id := Empty; ! Loc : Source_Ptr := No_Location; ! Rep : Boolean := True); -- N is a subexpression which will raise constraint error when evaluated -- at runtime. Msg is a message that explains the reason for raising the ! -- exception. The last character is ? if the message is always a warning, ! -- even in Ada 95, and is not a ? if the message represents an illegality ! -- (because of violation of static expression rules) in Ada 95 (but not ! -- in Ada 83). Typically this routine posts all messages at the Sloc of ! -- node N. However, if Loc /= No_Location, Loc is the Sloc used to output ! -- the message. After posting the appropriate message, and if the flag ! -- Rep is set, this routine replaces the expression with an appropriate ! -- N_Raise_Constraint_Error node using the given Reason code. This node ! -- is then marked as being static if the original node is static, but ! -- sets the flag Raises_Constraint_Error, preventing further evaluation. ! -- The error message may contain a } or & insertion character. This ! -- normally references Etype (N), unless the Ent argument is given -- explicitly, in which case it is used instead. The type of the raise -- node that is built is normally Etype (N), but if the Typ parameter -- is present, this is used instead. *************** package Sem_Util is *** 97,102 **** --- 97,108 ---- -- the compilation unit, and install it in the Elaboration_Entity field -- of Spec_Id, the entity for the compilation unit. + function Cannot_Raise_Constraint_Error (Expr : Node_Id) return Boolean; + -- Returns True if the expression cannot possibly raise Constraint_Error. + -- The response is conservative in the sense that a result of False does + -- not necessarily mean that CE could be raised, but a response of True + -- means that for sure CE cannot be raised. + procedure Check_Fully_Declared (T : Entity_Id; N : Node_Id); -- Verify that the full declaration of type T has been seen. If not, -- place error message on node N. Used in object declarations, type *************** package Sem_Util is *** 293,298 **** --- 299,309 ---- -- an identifier provided as the external name. Letters in the name are -- according to the setting of Opt.External_Name_Default_Casing. + function Get_Generic_Entity (N : Node_Id) return Entity_Id; + -- Returns the true generic entity in an instantiation. If the name in + -- the instantiation is a renaming, the function returns the renamed + -- generic. + procedure Get_Index_Bounds (N : Node_Id; L, H : out Node_Id); -- This procedure assigns to L and H respectively the values of the -- low and high bounds of node N, which must be a range, subtype *************** package Sem_Util is *** 439,444 **** --- 450,462 ---- -- is a variable (in the Is_Variable sense) with a non-tagged type -- target are considered view conversions and hence variables. + function Is_Partially_Initialized_Type (Typ : Entity_Id) return Boolean; + -- Typ is a type entity. This function returns true if this type is + -- partly initialized, meaning that an object of the type is at least + -- partly initialized (in particular in the record case, that at least + -- one field has an initialization expression). Note that initialization + -- resulting from the use of pragma Normalized_Scalars does not count. + function Is_RCI_Pkg_Spec_Or_Body (Cunit : Node_Id) return Boolean; -- Return True if a compilation unit is the specification or the -- body of a remote call interface package. *************** package Sem_Util is *** 563,574 **** -- record type there may be several such components, we just return -- the first one. ! procedure Process_End_Label (N : Node_Id; Typ : Character); -- N is a node whose End_Label is to be processed, generating all -- appropriate cross-reference entries, and performing style checks -- for any identifier references in the end label. Typ is either -- 'e' or 't indicating the type of the cross-reference entity ! -- (e for spec, t for body, see Lib.Xref spec for details). function Real_Convert (S : String) return Node_Id; -- S is a possibly signed syntactically valid real literal. The result --- 581,597 ---- -- record type there may be several such components, we just return -- the first one. ! procedure Process_End_Label ! (N : Node_Id; ! Typ : Character; ! Ent : Entity_Id); -- N is a node whose End_Label is to be processed, generating all -- appropriate cross-reference entries, and performing style checks -- for any identifier references in the end label. Typ is either -- 'e' or 't indicating the type of the cross-reference entity ! -- (e for spec, t for body, see Lib.Xref spec for details). The ! -- parameter Ent gives the entity to which the End_Label refers, ! -- and to which cross-references are to be generated. function Real_Convert (S : String) return Node_Id; -- S is a possibly signed syntactically valid real literal. The result diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_vfpt.adb gcc-3.3/gcc/ada/sem_vfpt.adb *** gcc-3.2.3/gcc/ada/sem_vfpt.adb 2002-05-04 03:29:18.000000000 +0000 --- gcc-3.3/gcc/ada/sem_vfpt.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1997-2000, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2002, 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- -- *************** with Opt; use Opt; *** 32,46 **** with Stand; use Stand; with Targparm; use Targparm; with Ttypef; use Ttypef; - with Uintp; use Uintp; - - pragma Elaborate_All (Uintp); package body Sem_VFpt is - T_Digits : constant Uint := UI_From_Int (IEEEL_Digits); - -- Digits for IEEE formats - ----------------- -- Set_D_Float -- ----------------- --- 31,39 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_vfpt.ads gcc-3.3/gcc/ada/sem_vfpt.ads *** gcc-3.2.3/gcc/ada/sem_vfpt.ads 2002-05-07 08:22:32.000000000 +0000 --- gcc-3.3/gcc/ada/sem_vfpt.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_warn.adb gcc-3.3/gcc/ada/sem_warn.adb *** gcc-3.2.3/gcc/ada/sem_warn.adb 2002-05-04 03:29:18.000000000 +0000 --- gcc-3.3/gcc/ada/sem_warn.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.10.1 $ -- -- ! -- Copyright (C) 1999-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1999-2002 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- -- *************** package body Sem_Warn is *** 120,130 **** Table_Increment => Alloc.Conditional_Stack_Increment, Table_Name => "Conditional_Stack"); ! Current_Entity_List : Elist_Id := No_Elist; ! -- This is a copy of the Defs list of the current branch of the current ! -- conditional. It could be accessed by taking the top element of the ! -- Conditional_Stack, and going to te Current_Branch entry of this ! -- conditional, but we keep it precomputed for rapid access. ---------------------- -- Check_References -- --- 119,129 ---- Table_Increment => Alloc.Conditional_Stack_Increment, Table_Name => "Conditional_Stack"); ! function Operand_Has_Warnings_Suppressed (N : Node_Id) return Boolean; ! -- This function traverses the expression tree represented by the node ! -- N and determines if any sub-operand is a reference to an entity for ! -- which the Warnings_Off flag is set. True is returned if such an ! -- entity is encountered, and False otherwise. ---------------------- -- Check_References -- *************** package body Sem_Warn is *** 142,149 **** function Publicly_Referenceable (Ent : Entity_Id) return Boolean; -- This is true if the entity in question is potentially referenceable -- from another unit. This is true for entities in packages that are ! -- at the library level, or for entities in tasks or protected objects ! -- that are themselves publicly visible. ---------------------------- -- Output_Reference_Error -- --- 141,147 ---- function Publicly_Referenceable (Ent : Entity_Id) return Boolean; -- This is true if the entity in question is potentially referenceable -- from another unit. This is true for entities in packages that are ! -- at the library level. ---------------------------- -- Output_Reference_Error -- *************** package body Sem_Warn is *** 192,223 **** ---------------------------- function Publicly_Referenceable (Ent : Entity_Id) return Boolean is ! S : Entity_Id; begin ! -- Any entity in a generic package is considered to be publicly ! -- referenceable, since it could be referenced in an instantiation ! if Ekind (E) = E_Generic_Package then ! return True; ! end if; ! -- Otherwise look up the scope stack ! S := Scope (Ent); ! loop ! if Is_Package (S) then ! return Is_Library_Level_Entity (S); ! elsif Ekind (S) = E_Task_Type ! or else Ekind (S) = E_Protected_Type ! or else Ekind (S) = E_Entry ! then ! S := Scope (S); ! else ! return False; ! end if; end loop; end Publicly_Referenceable; --- 190,236 ---- ---------------------------- function Publicly_Referenceable (Ent : Entity_Id) return Boolean is ! P : Node_Id; begin ! -- Examine parents to look for a library level package spec ! -- But if we find a body or block or other similar construct ! -- along the way, we cannot be referenced. ! P := Parent (Ent); ! loop ! case Nkind (P) is ! -- If we get to top of tree, then publicly referencable ! when N_Empty => ! return True; ! -- If we reach a generic package declaration, then always ! -- consider this referenceable, since any instantiation will ! -- have access to the entities in the generic package. Note ! -- that the package itself may not be instantiated, but then ! -- we will get a warning for the package entity ! when N_Generic_Package_Declaration => ! return True; ! ! -- If we reach any body, then definitely not referenceable ! ! when N_Package_Body | ! N_Subprogram_Body | ! N_Task_Body | ! N_Entry_Body | ! N_Protected_Body | ! N_Block_Statement | ! N_Subunit => ! return False; ! ! -- For all other cases, keep looking up tree ! ! when others => ! P := Parent (P); ! end case; end loop; end Publicly_Referenceable; *************** package body Sem_Warn is *** 233,239 **** -- necessary to suppress the warnings in this case). if Warning_Mode = Suppress ! or else Errors_Detected /= 0 or else Unloaded_Subunits then return; --- 246,252 ---- -- necessary to suppress the warnings in this case). if Warning_Mode = Suppress ! or else Serious_Errors_Detected /= 0 or else Unloaded_Subunits then return; *************** package body Sem_Warn is *** 340,352 **** -- Then check for unreferenced variables ! if Check_Unreferenced ! -- Check entity is flagged as not referenced and that ! -- warnings are not suppressed for this entity ! and then not Referenced (E1) ! and then not Warnings_Off (E1) -- Warnings are placed on objects, types, subprograms, -- labels, and enumeration literals. --- 353,365 ---- -- Then check for unreferenced variables ! if not Referenced (E1) ! -- Check that warnings on unreferenced entities are enabled ! and then ((Check_Unreferenced and then not Is_Formal (E1)) ! or else ! (Check_Unreferenced_Formals and then Is_Formal (E1))) -- Warnings are placed on objects, types, subprograms, -- labels, and enumeration literals. *************** package body Sem_Warn is *** 363,369 **** or else Is_Overloadable (E1)) ! -- We only place warnings for the main unit and then In_Extended_Main_Source_Unit (E1) --- 376,382 ---- or else Is_Overloadable (E1)) ! -- We only place warnings for the extended main unit and then In_Extended_Main_Source_Unit (E1) *************** package body Sem_Warn is *** 372,387 **** and then Instantiation_Location (Sloc (E1)) = No_Location ! -- Exclude formal parameters from bodies (in the case ! -- where there is a separate spec, it is the spec formals ! -- that are of interest). ! and then (not Is_Formal (E1) ! or else ! Ekind (Scope (E1)) /= E_Subprogram_Body) ! -- Consider private type referenced if full view is ! -- referenced. and then not (Is_Private_Type (E1) and then --- 385,403 ---- and then Instantiation_Location (Sloc (E1)) = No_Location ! -- Exclude formal parameters from bodies if the corresponding ! -- spec entity has been referenced in the case where there is ! -- a separate spec. ! and then not (Is_Formal (E1) ! and then ! Ekind (Scope (E1)) = E_Subprogram_Body ! and then ! Present (Spec_Entity (E1)) ! and then ! Referenced (Spec_Entity (E1))) ! -- Consider private type referenced if full view is referenced and then not (Is_Private_Type (E1) and then *************** package body Sem_Warn is *** 417,422 **** --- 433,445 ---- and then Ekind (E1) /= E_Constant and then Ekind (E1) /= E_Component) or else not Is_Task_Type (Etype (E1))) + + -- For subunits, only place warnings on the main unit + -- itself, since parent units are not completely compiled + + and then (Nkind (Unit (Cunit (Main_Unit))) /= N_Subunit + or else + Get_Source_Unit (E1) = Main_Unit) then -- Suppress warnings in internal units if not in -gnatg -- mode (these would be junk warnings for an applications *************** package body Sem_Warn is *** 891,896 **** --- 914,966 ---- end if; end Check_Unused_Withs; + ------------------------------------- + -- Operand_Has_Warnings_Suppressed -- + ------------------------------------- + + function Operand_Has_Warnings_Suppressed (N : Node_Id) return Boolean is + + function Check_For_Warnings (N : Node_Id) return Traverse_Result; + -- Function used to check one node to see if it is or was originally + -- a reference to an entity for which Warnings are off. If so, Abandon + -- is returned, otherwise OK_Orig is returned to continue the traversal + -- of the original expression. + + function Traverse is new Traverse_Func (Check_For_Warnings); + -- Function used to traverse tree looking for warnings + + ------------------------ + -- Check_For_Warnings -- + ------------------------ + + function Check_For_Warnings (N : Node_Id) return Traverse_Result is + R : constant Node_Id := Original_Node (N); + + begin + if Nkind (R) in N_Has_Entity + and then Present (Entity (R)) + and then Warnings_Off (Entity (R)) + then + return Abandon; + else + return OK_Orig; + end if; + end Check_For_Warnings; + + -- Start of processing for Operand_Has_Warnings_Suppressed + + begin + return Traverse (N) = Abandon; + + -- If any exception occurs, then something has gone wrong, and this is + -- only a minor aesthetic issue anyway, so just say we did not find what + -- we are looking for, rather than blow up. + + exception + when others => + return False; + end Operand_Has_Warnings_Suppressed; + ---------------------------------- -- Output_Unreferenced_Messages -- ---------------------------------- *************** package body Sem_Warn is *** 1017,1026 **** P := Parent (P); end loop; ! if Entity (C) = Standard_True then ! Error_Msg_N ("condition is always True?", C); ! else ! Error_Msg_N ("condition is always False?", C); end if; end if; end Warn_On_Known_Condition; --- 1087,1101 ---- P := Parent (P); end loop; ! -- Here we issue the warning unless some sub-operand has warnings ! -- set off, in which case we suppress the warning for the node. ! ! if not Operand_Has_Warnings_Suppressed (C) then ! if Entity (C) = Standard_True then ! Error_Msg_N ("condition is always True?", C); ! else ! Error_Msg_N ("condition is always False?", C); ! end if; end if; end if; end Warn_On_Known_Condition; diff -Nrc3pad gcc-3.2.3/gcc/ada/sem_warn.ads gcc-3.3/gcc/ada/sem_warn.ads *** gcc-3.2.3/gcc/ada/sem_warn.ads 2002-05-04 03:29:18.000000000 +0000 --- gcc-3.3/gcc/ada/sem_warn.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sequenio.ads gcc-3.3/gcc/ada/sequenio.ads *** gcc-3.2.3/gcc/ada/sequenio.ads 2002-05-07 08:22:32.000000000 +0000 --- gcc-3.3/gcc/ada/sequenio.ads 2002-03-14 11:00:15.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-errrep.adb gcc-3.3/gcc/ada/s-errrep.adb *** gcc-3.2.3/gcc/ada/s-errrep.adb 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-errrep.adb 2002-03-14 10:59:42.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-2000 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-errrep.ads gcc-3.3/gcc/ada/s-errrep.ads *** gcc-3.2.3/gcc/ada/s-errrep.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-errrep.ads 2002-03-14 10:59:43.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1991-1998 Florida State University -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-except.ads gcc-3.3/gcc/ada/s-except.ads *** gcc-3.2.3/gcc/ada/s-except.ads 2002-05-04 03:28:37.000000000 +0000 --- gcc-3.3/gcc/ada/s-except.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exctab.adb gcc-3.3/gcc/ada/s-exctab.adb *** gcc-3.2.3/gcc/ada/s-exctab.adb 2002-05-04 03:28:37.000000000 +0000 --- gcc-3.3/gcc/ada/s-exctab.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1996-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exctab.ads gcc-3.3/gcc/ada/s-exctab.ads *** gcc-3.2.3/gcc/ada/s-exctab.ads 2002-05-04 03:28:37.000000000 +0000 --- gcc-3.3/gcc/ada/s-exctab.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1996-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exnflt.ads gcc-3.3/gcc/ada/s-exnflt.ads *** gcc-3.2.3/gcc/ada/s-exnflt.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exnflt.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exngen.adb gcc-3.3/gcc/ada/s-exngen.adb *** gcc-3.2.3/gcc/ada/s-exngen.adb 2002-05-04 03:28:37.000000000 +0000 --- gcc-3.3/gcc/ada/s-exngen.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exngen.ads gcc-3.3/gcc/ada/s-exngen.ads *** gcc-3.2.3/gcc/ada/s-exngen.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exngen.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exnint.ads gcc-3.3/gcc/ada/s-exnint.ads *** gcc-3.2.3/gcc/ada/s-exnint.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exnint.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exnlfl.ads gcc-3.3/gcc/ada/s-exnlfl.ads *** gcc-3.2.3/gcc/ada/s-exnlfl.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exnlfl.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exnlin.ads gcc-3.3/gcc/ada/s-exnlin.ads *** gcc-3.2.3/gcc/ada/s-exnlin.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exnlin.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exnllf.ads gcc-3.3/gcc/ada/s-exnllf.ads *** gcc-3.2.3/gcc/ada/s-exnllf.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exnllf.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exnlli.ads gcc-3.3/gcc/ada/s-exnlli.ads *** gcc-3.2.3/gcc/ada/s-exnlli.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exnlli.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exnsfl.ads gcc-3.3/gcc/ada/s-exnsfl.ads *** gcc-3.2.3/gcc/ada/s-exnsfl.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exnsfl.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exnsin.ads gcc-3.3/gcc/ada/s-exnsin.ads *** gcc-3.2.3/gcc/ada/s-exnsin.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exnsin.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-exnssi.ads gcc-3.3/gcc/ada/s-exnssi.ads *** gcc-3.2.3/gcc/ada/s-exnssi.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-exnssi.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expflt.ads gcc-3.3/gcc/ada/s-expflt.ads *** gcc-3.2.3/gcc/ada/s-expflt.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-expflt.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expgen.adb gcc-3.3/gcc/ada/s-expgen.adb *** gcc-3.2.3/gcc/ada/s-expgen.adb 2002-05-04 03:28:38.000000000 +0000 --- gcc-3.3/gcc/ada/s-expgen.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expgen.ads gcc-3.3/gcc/ada/s-expgen.ads *** gcc-3.2.3/gcc/ada/s-expgen.ads 2002-05-07 08:22:21.000000000 +0000 --- gcc-3.3/gcc/ada/s-expgen.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expint.ads gcc-3.3/gcc/ada/s-expint.ads *** gcc-3.2.3/gcc/ada/s-expint.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expint.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-explfl.ads gcc-3.3/gcc/ada/s-explfl.ads *** gcc-3.2.3/gcc/ada/s-explfl.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-explfl.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-explin.ads gcc-3.3/gcc/ada/s-explin.ads *** gcc-3.2.3/gcc/ada/s-explin.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-explin.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expllf.ads gcc-3.3/gcc/ada/s-expllf.ads *** gcc-3.2.3/gcc/ada/s-expllf.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expllf.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-explli.ads gcc-3.3/gcc/ada/s-explli.ads *** gcc-3.2.3/gcc/ada/s-explli.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-explli.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expllu.adb gcc-3.3/gcc/ada/s-expllu.adb *** gcc-3.2.3/gcc/ada/s-expllu.adb 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expllu.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expllu.ads gcc-3.3/gcc/ada/s-expllu.ads *** gcc-3.2.3/gcc/ada/s-expllu.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expllu.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expmod.adb gcc-3.3/gcc/ada/s-expmod.adb *** gcc-3.2.3/gcc/ada/s-expmod.adb 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expmod.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expmod.ads gcc-3.3/gcc/ada/s-expmod.ads *** gcc-3.2.3/gcc/ada/s-expmod.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expmod.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expsfl.ads gcc-3.3/gcc/ada/s-expsfl.ads *** gcc-3.2.3/gcc/ada/s-expsfl.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expsfl.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expsin.ads gcc-3.3/gcc/ada/s-expsin.ads *** gcc-3.2.3/gcc/ada/s-expsin.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expsin.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expssi.ads gcc-3.3/gcc/ada/s-expssi.ads *** gcc-3.2.3/gcc/ada/s-expssi.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expssi.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expuns.adb gcc-3.3/gcc/ada/s-expuns.adb *** gcc-3.2.3/gcc/ada/s-expuns.adb 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expuns.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-expuns.ads gcc-3.3/gcc/ada/s-expuns.ads *** gcc-3.2.3/gcc/ada/s-expuns.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-expuns.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fatflt.ads gcc-3.3/gcc/ada/s-fatflt.ads *** gcc-3.2.3/gcc/ada/s-fatflt.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-fatflt.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fatgen.adb gcc-3.3/gcc/ada/s-fatgen.adb *** gcc-3.2.3/gcc/ada/s-fatgen.adb 2002-05-04 03:28:39.000000000 +0000 --- gcc-3.3/gcc/ada/s-fatgen.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 40,46 **** -- specialized appropriately, or better still, its generic instantiations -- should be replaced by efficient machine-specific code. ! with Ada.Unchecked_Conversion; use Ada; with System; package body System.Fat_Gen is --- 39,45 ---- -- specialized appropriately, or better still, its generic instantiations -- should be replaced by efficient machine-specific code. ! with Ada.Unchecked_Conversion; with System; package body System.Fat_Gen is *************** package body System.Fat_Gen is *** 784,794 **** -- This assumes that the range IEEE_Emin - 1 .. IEEE_Emax + 1 -- contains 2**N values, for some N in Natural. ! function To_Float is new Unchecked_Conversion (Float_Rep, T); type Float_Access is access all T; function To_Address is ! new Unchecked_Conversion (Float_Access, System.Address); XA : constant System.Address := To_Address (Float_Access (X)); --- 783,793 ---- -- This assumes that the range IEEE_Emin - 1 .. IEEE_Emax + 1 -- contains 2**N values, for some N in Natural. ! function To_Float is new Ada.Unchecked_Conversion (Float_Rep, T); type Float_Access is access all T; function To_Address is ! new Ada.Unchecked_Conversion (Float_Access, System.Address); XA : constant System.Address := To_Address (Float_Access (X)); diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fatgen.ads gcc-3.3/gcc/ada/s-fatgen.ads *** gcc-3.2.3/gcc/ada/s-fatgen.ads 2002-05-04 03:28:39.000000000 +0000 --- gcc-3.3/gcc/ada/s-fatgen.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fatlfl.ads gcc-3.3/gcc/ada/s-fatlfl.ads *** gcc-3.2.3/gcc/ada/s-fatlfl.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-fatlfl.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fatllf.ads gcc-3.3/gcc/ada/s-fatllf.ads *** gcc-3.2.3/gcc/ada/s-fatllf.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-fatllf.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fatsfl.ads gcc-3.3/gcc/ada/s-fatsfl.ads *** gcc-3.2.3/gcc/ada/s-fatsfl.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-fatsfl.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-ficobl.ads gcc-3.3/gcc/ada/s-ficobl.ads *** gcc-3.2.3/gcc/ada/s-ficobl.ads 2002-05-04 03:28:39.000000000 +0000 --- gcc-3.3/gcc/ada/s-ficobl.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fileio.adb gcc-3.3/gcc/ada/s-fileio.adb *** gcc-3.2.3/gcc/ada/s-fileio.adb 2002-05-04 03:28:39.000000000 +0000 --- gcc-3.3/gcc/ada/s-fileio.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body System.File_IO is *** 79,84 **** --- 78,84 ---- -- This is the finalize operation that is used to do the cleanup. File_IO_Clean_Up_Object : File_IO_Clean_Up_Type; + pragma Warnings (Off, File_IO_Clean_Up_Object); -- This is the single object of the type that triggers the finalization -- call. Since it is at the library level, this happens just before the -- environment task is finalized. *************** package body System.File_IO is *** 331,336 **** --- 331,338 ---- -- task just before terminating execution. procedure Finalize (V : in out File_IO_Clean_Up_Type) is + pragma Warnings (Off, V); + Discard : int; Fptr1 : AFCB_Ptr; Fptr2 : AFCB_Ptr; *************** package body System.File_IO is *** 795,805 **** raise Use_Error; end if; ! for J in Fullname'Range loop ! if Fullname (J) = ASCII.NUL then ! Full_Name_Len := J; ! exit; ! end if; end loop; -- If Shared=None or Shared=Yes, then check for the existence --- 797,807 ---- raise Use_Error; end if; ! Full_Name_Len := 1; ! while Full_Name_Len < Fullname'Last ! and then Fullname (Full_Name_Len) /= ASCII.NUL ! loop ! Full_Name_Len := Full_Name_Len + 1; end loop; -- If Shared=None or Shared=Yes, then check for the existence diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fileio.ads gcc-3.3/gcc/ada/s-fileio.ads *** gcc-3.2.3/gcc/ada/s-fileio.ads 2002-05-04 03:28:39.000000000 +0000 --- gcc-3.3/gcc/ada/s-fileio.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-finimp.adb gcc-3.3/gcc/ada/s-finimp.adb *** gcc-3.2.3/gcc/ada/s-finimp.adb 2002-05-04 03:28:39.000000000 +0000 --- gcc-3.3/gcc/ada/s-finimp.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body System.Finalization_Impleme *** 290,295 **** --- 289,296 ---- A : System.Address; B : Boolean) is + pragma Warnings (Off, L); + V : constant SFR.Finalizable_Ptr := To_Finalizable_Ptr (A); Offset : constant SSE.Storage_Offset := RC_Offset (V'Tag); *************** package body System.Finalization_Impleme *** 515,520 **** --- 516,523 ---- ---------------- procedure Initialize (Object : in out Limited_Record_Controller) is + pragma Warnings (Off, Object); + begin null; end Initialize; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-finimp.ads gcc-3.3/gcc/ada/s-finimp.ads *** gcc-3.2.3/gcc/ada/s-finimp.ads 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-finimp.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-finroo.adb gcc-3.3/gcc/ada/s-finroo.adb *** gcc-3.2.3/gcc/ada/s-finroo.adb 2002-05-04 03:28:39.000000000 +0000 --- gcc-3.3/gcc/ada/s-finroo.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-finroo.ads gcc-3.3/gcc/ada/s-finroo.ads *** gcc-3.2.3/gcc/ada/s-finroo.ads 2002-05-04 03:28:39.000000000 +0000 --- gcc-3.3/gcc/ada/s-finroo.ads 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sfn_scan.adb gcc-3.3/gcc/ada/sfn_scan.adb *** gcc-3.2.3/gcc/ada/sfn_scan.adb 2002-05-04 03:29:18.000000000 +0000 --- gcc-3.3/gcc/ada/sfn_scan.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sfn_scan.ads gcc-3.3/gcc/ada/sfn_scan.ads *** gcc-3.2.3/gcc/ada/sfn_scan.ads 2002-05-04 03:29:18.000000000 +0000 --- gcc-3.3/gcc/ada/sfn_scan.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fore.adb gcc-3.3/gcc/ada/s-fore.adb *** gcc-3.2.3/gcc/ada/s-fore.adb 2002-05-07 08:22:22.000000000 +0000 --- gcc-3.3/gcc/ada/s-fore.adb 2002-10-23 07:33:28.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-fore.ads gcc-3.3/gcc/ada/s-fore.ads *** gcc-3.2.3/gcc/ada/s-fore.ads 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-fore.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-gloloc.adb gcc-3.3/gcc/ada/s-gloloc.adb *** gcc-3.2.3/gcc/ada/s-gloloc.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-gloloc.adb 2002-03-14 10:59:45.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1999-2001 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- -- *************** package body System.Global_Locks is *** 43,53 **** Dir_Separator : Character; pragma Import (C, Dir_Separator, "__gnat_dir_separator"); ! type Lock_File_Entry is ! record ! Dir : String_Access; ! File : String_Access; ! end record; Last_Lock : Lock_Type := Null_Lock; Lock_Table : array (Lock_Type range 1 .. 15) of Lock_File_Entry; --- 42,51 ---- Dir_Separator : Character; pragma Import (C, Dir_Separator, "__gnat_dir_separator"); ! type Lock_File_Entry is record ! Dir : String_Access; ! File : String_Access; ! end record; Last_Lock : Lock_Type := Null_Lock; Lock_Table : array (Lock_Type range 1 .. 15) of Lock_File_Entry; *************** package body System.Global_Locks is *** 68,75 **** ------------------ procedure Acquire_Lock ! (Lock : in out Lock_Type) ! is begin Lock_File (Lock_Table (Lock).Dir.all, --- 66,72 ---- ------------------ procedure Acquire_Lock ! (Lock : in out Lock_Type) is begin Lock_File (Lock_Table (Lock).Dir.all, diff -Nrc3pad gcc-3.2.3/gcc/ada/s-gloloc.ads gcc-3.3/gcc/ada/s-gloloc.ads *** gcc-3.2.3/gcc/ada/s-gloloc.ads 2001-10-02 14:30:13.000000000 +0000 --- gcc-3.3/gcc/ada/s-gloloc.ads 2002-03-14 10:59:45.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1999-2001 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgbiu.adb gcc-3.3/gcc/ada/s-imgbiu.adb *** gcc-3.2.3/gcc/ada/s-imgbiu.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgbiu.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgbiu.ads gcc-3.3/gcc/ada/s-imgbiu.ads *** gcc-3.2.3/gcc/ada/s-imgbiu.ads 2002-05-04 03:28:39.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgbiu.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgboo.adb gcc-3.3/gcc/ada/s-imgboo.adb *** gcc-3.2.3/gcc/ada/s-imgboo.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgboo.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgboo.ads gcc-3.3/gcc/ada/s-imgboo.ads *** gcc-3.2.3/gcc/ada/s-imgboo.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgboo.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgcha.adb gcc-3.3/gcc/ada/s-imgcha.adb *** gcc-3.2.3/gcc/ada/s-imgcha.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgcha.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgcha.ads gcc-3.3/gcc/ada/s-imgcha.ads *** gcc-3.2.3/gcc/ada/s-imgcha.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgcha.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgdec.adb gcc-3.3/gcc/ada/s-imgdec.adb *** gcc-3.2.3/gcc/ada/s-imgdec.adb 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgdec.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgdec.ads gcc-3.3/gcc/ada/s-imgdec.ads *** gcc-3.2.3/gcc/ada/s-imgdec.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgdec.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgenu.adb gcc-3.3/gcc/ada/s-imgenu.adb *** gcc-3.2.3/gcc/ada/s-imgenu.adb 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgenu.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgenu.ads gcc-3.3/gcc/ada/s-imgenu.ads *** gcc-3.2.3/gcc/ada/s-imgenu.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgenu.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgint.adb gcc-3.3/gcc/ada/s-imgint.adb *** gcc-3.2.3/gcc/ada/s-imgint.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgint.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgint.ads gcc-3.3/gcc/ada/s-imgint.ads *** gcc-3.2.3/gcc/ada/s-imgint.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgint.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgllb.adb gcc-3.3/gcc/ada/s-imgllb.adb *** gcc-3.2.3/gcc/ada/s-imgllb.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgllb.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgllb.ads gcc-3.3/gcc/ada/s-imgllb.ads *** gcc-3.2.3/gcc/ada/s-imgllb.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgllb.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imglld.adb gcc-3.3/gcc/ada/s-imglld.adb *** gcc-3.2.3/gcc/ada/s-imglld.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imglld.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imglld.ads gcc-3.3/gcc/ada/s-imglld.ads *** gcc-3.2.3/gcc/ada/s-imglld.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imglld.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imglli.adb gcc-3.3/gcc/ada/s-imglli.adb *** gcc-3.2.3/gcc/ada/s-imglli.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imglli.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imglli.ads gcc-3.3/gcc/ada/s-imglli.ads *** gcc-3.2.3/gcc/ada/s-imglli.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imglli.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgllu.adb gcc-3.3/gcc/ada/s-imgllu.adb *** gcc-3.2.3/gcc/ada/s-imgllu.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgllu.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgllu.ads gcc-3.3/gcc/ada/s-imgllu.ads *** gcc-3.2.3/gcc/ada/s-imgllu.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgllu.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgllw.adb gcc-3.3/gcc/ada/s-imgllw.adb *** gcc-3.2.3/gcc/ada/s-imgllw.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgllw.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgllw.ads gcc-3.3/gcc/ada/s-imgllw.ads *** gcc-3.2.3/gcc/ada/s-imgllw.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgllw.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgrea.adb gcc-3.3/gcc/ada/s-imgrea.adb *** gcc-3.2.3/gcc/ada/s-imgrea.adb 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgrea.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgrea.ads gcc-3.3/gcc/ada/s-imgrea.ads *** gcc-3.2.3/gcc/ada/s-imgrea.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgrea.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imguns.adb gcc-3.3/gcc/ada/s-imguns.adb *** gcc-3.2.3/gcc/ada/s-imguns.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imguns.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imguns.ads gcc-3.3/gcc/ada/s-imguns.ads *** gcc-3.2.3/gcc/ada/s-imguns.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imguns.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgwch.adb gcc-3.3/gcc/ada/s-imgwch.adb *** gcc-3.2.3/gcc/ada/s-imgwch.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgwch.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgwch.ads gcc-3.3/gcc/ada/s-imgwch.ads *** gcc-3.2.3/gcc/ada/s-imgwch.ads 2002-05-04 03:28:40.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgwch.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgwiu.adb gcc-3.3/gcc/ada/s-imgwiu.adb *** gcc-3.2.3/gcc/ada/s-imgwiu.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgwiu.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-imgwiu.ads gcc-3.3/gcc/ada/s-imgwiu.ads *** gcc-3.2.3/gcc/ada/s-imgwiu.ads 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-imgwiu.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sinfo.adb gcc-3.3/gcc/ada/sinfo.adb *** gcc-3.2.3/gcc/ada/sinfo.adb 2002-05-04 03:29:18.000000000 +0000 --- gcc-3.3/gcc/ada/sinfo.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Sinfo is *** 898,903 **** --- 897,903 ---- (N : Node_Id) return Node_Id is begin pragma Assert (False + or else NT (N).Nkind = N_Enumeration_Type_Definition or else NT (N).Nkind = N_Handled_Sequence_Of_Statements or else NT (N).Nkind = N_Loop_Statement or else NT (N).Nkind = N_Package_Specification *************** package body Sinfo is *** 1619,1624 **** --- 1619,1632 ---- return Flag5 (N); end More_Ids; + function Must_Be_Byte_Aligned + (N : Node_Id) return Boolean is + begin + pragma Assert (False + or else NT (N).Nkind = N_Attribute_Reference); + return Flag14 (N); + end Must_Be_Byte_Aligned; + function Must_Not_Freeze (N : Node_Id) return Boolean is begin *************** package body Sinfo is *** 2032,2037 **** --- 2040,2055 ---- return Ureal3 (N); end Realval; + function Reason + (N : Node_Id) return Uint is + begin + pragma Assert (False + or else NT (N).Nkind = N_Raise_Constraint_Error + or else NT (N).Nkind = N_Raise_Program_Error + or else NT (N).Nkind = N_Raise_Storage_Error); + return Uint3 (N); + end Reason; + function Record_Extension_Part (N : Node_Id) return Node_Id is begin *************** package body Sinfo is *** 3253,3258 **** --- 3271,3277 ---- (N : Node_Id; Val : Node_Id) is begin pragma Assert (False + or else NT (N).Nkind = N_Enumeration_Type_Definition or else NT (N).Nkind = N_Handled_Sequence_Of_Statements or else NT (N).Nkind = N_Loop_Statement or else NT (N).Nkind = N_Package_Specification *************** package body Sinfo is *** 3974,3979 **** --- 3993,4006 ---- Set_Flag5 (N, Val); end Set_More_Ids; + procedure Set_Must_Be_Byte_Aligned + (N : Node_Id; Val : Boolean := True) is + begin + pragma Assert (False + or else NT (N).Nkind = N_Attribute_Reference); + Set_Flag14 (N, Val); + end Set_Must_Be_Byte_Aligned; + procedure Set_Must_Not_Freeze (N : Node_Id; Val : Boolean := True) is begin *************** package body Sinfo is *** 4387,4392 **** --- 4414,4429 ---- Set_Ureal3 (N, Val); end Set_Realval; + procedure Set_Reason + (N : Node_Id; Val : Uint) is + begin + pragma Assert (False + or else NT (N).Nkind = N_Raise_Constraint_Error + or else NT (N).Nkind = N_Raise_Program_Error + or else NT (N).Nkind = N_Raise_Storage_Error); + Set_Uint3 (N, Val); + end Set_Reason; + procedure Set_Record_Extension_Part (N : Node_Id; Val : Node_Id) is begin diff -Nrc3pad gcc-3.2.3/gcc/ada/sinfo.ads gcc-3.3/gcc/ada/sinfo.ads *** gcc-3.2.3/gcc/ada/sinfo.ads 2002-05-04 03:29:18.000000000 +0000 --- gcc-3.3/gcc/ada/sinfo.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.6.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package Sinfo is *** 386,392 **** -- In the following node definitions, all fields, both syntactic and -- semantic, are documented. The one exception is in the case of entities ! -- (defining identifiers, character literals and operator symbols), -- where the usage of the fields depends on the entity kind. Entity -- fields are fully documented in the separate package Einfo. --- 385,391 ---- -- In the following node definitions, all fields, both syntactic and -- semantic, are documented. The one exception is in the case of entities ! -- (defining indentifiers, character literals and operator symbols), -- where the usage of the fields depends on the entity kind. Entity -- fields are fully documented in the separate package Einfo. *************** package Sinfo is *** 551,559 **** -- All_Others (Flag11-Sem) -- Present in an N_Others_Choice node. This flag is set in the case ! -- of an others exception where all exceptions, even those that are ! -- not normally handled (in particular the tasking abort signal) by ! -- others. This is used for translation of the at end handler into -- a normal exception handler. -- Assignment_OK (Flag15-Sem) --- 550,558 ---- -- All_Others (Flag11-Sem) -- Present in an N_Others_Choice node. This flag is set in the case ! -- of an others exception where all exceptions are to be caught, even ! -- those that are not normally handled (in particular the tasking abort ! -- signal). This is used for translation of the at end handler into -- a normal exception handler. -- Assignment_OK (Flag15-Sem) *************** package Sinfo is *** 1180,1185 **** --- 1179,1194 ---- -- Used to collect actions that must be executed within the loop because -- they may need to be evaluated anew each time through. + -- Must_Be_Byte_Aligned (Flag14-Sem) + -- This flag is present in N_Attribute_Reference nodes. It can be set + -- only for the Address and Unrestricted_Access attributes. If set it + -- means that the object for which the address/access is given must be + -- on a byte (more accurately a storage unit) boundary. If necessary, + -- a copy of the object is to be made before taking the address (this + -- copy is in the current scope on the stack frame). This is used for + -- certainly cases of code generated by the expander that passes + -- parameters by address. + -- Must_Not_Freeze (Flag8-Sem) -- A flag present in all expression nodes. Normally expressions cause -- freezing as described in the RM. If this flag is set, then this *************** package Sinfo is *** 1475,1480 **** --- 1484,1490 ---- -- Case Statement end case; -- Record Definition end record; + -- Enumeration Definition ); -- The End_Label and End_Span fields are used to mark the locations -- of these lines, and also keep track of the label in the case where *************** package Sinfo is *** 1506,1511 **** --- 1516,1524 ---- -- entry for the end of a record, since it represents a scope for -- name declaration purposes. + -- The enumeration definition case is handled in an exactly similar + -- manner, building a dummy identifier to get a cross-reference. + -- Note: the reason we store the difference as a Uint, instead of -- storing the Source_Ptr value directly, is that Source_Ptr values -- cannot be distinguished from other types of values, and we count *************** package Sinfo is *** 2007,2012 **** --- 2020,2026 ---- -- N_Enumeration_Type_Definition -- Sloc points to left parenthesis -- Literals (List1) (Empty for CHARACTER or WIDE_CHARACTER) + -- End_Label (Node4) (set to Empty if internally generated record) ---------------------------------------------- -- 3.5.1 Enumeration Literal Specification -- *************** package Sinfo is *** 2802,2807 **** --- 2816,2830 ---- -- a non-standard enumeration type or a nonzero/zero semantics -- boolean type, so the value is simply the stored representation. + -- Note: In generated code, the Address and Unrestricted_Access + -- attributes can be applied to any expression, and the meaning is + -- to create an object containing the value (the object is in the + -- current stack frame), and pass the address of this value. If the + -- Must_Be_Byte_Aligned flag is set, then the object whose address + -- is taken must be on a byte (storage unit) boundary, and if it is + -- not (or may not be), then the generated code must create a copy + -- that is byte aligned, and pass the address of this copy. + -- N_Attribute_Reference -- Sloc points to apostrophe -- Prefix (Node3) *************** package Sinfo is *** 2813,2818 **** --- 2836,2842 ---- -- Do_Overflow_Check (Flag17-Sem) -- Redundant_Use (Flag13-Sem) -- OK_For_Stream (Flag4-Sem) + -- Must_Be_Byte_Aligned (Flag14) -- plus fields for expression --------------------------------- *************** package Sinfo is *** 3456,3462 **** -- 5.1 Statement Identifier -- ------------------------------- ! -- STATEMENT_IDENTIFIER ::= DIRECT_NAME -- The IDENTIFIER of a STATEMENT_IDENTIFIER shall be an identifier -- (not an OPERATOR_SYMBOL) --- 3480,3486 ---- -- 5.1 Statement Identifier -- ------------------------------- ! -- STATEMENT_INDENTIFIER ::= DIRECT_NAME -- The IDENTIFIER of a STATEMENT_IDENTIFIER shall be an identifier -- (not an OPERATOR_SYMBOL) *************** package Sinfo is *** 6063,6095 **** -- circuit form whose left argument is static and decisively -- eliminates elaboration of the raise operation. -- Gigi restriction: This expander ensures that the type of the -- Condition field is always Standard.Boolean, even if the type -- in the source is some non-standard boolean type. ! -- Sprint syntax: [xxx_error] ! -- or: [xxx_error when condition] -- N_Raise_Constraint_Error -- Sloc references related construct -- Condition (Node1) (set to Empty if no condition) ! -- Sloc is copied from the expression generating the exception -- plus fields for expression -- N_Raise_Program_Error -- Sloc references related construct -- Condition (Node1) (set to Empty if no condition) ! -- Sloc is copied from the construct generating the exception -- plus fields for expression -- N_Raise_Storage_Error -- Sloc references related construct -- Condition (Node1) (set to Empty if no condition) ! -- Sloc is copied from the construct generating the exception -- plus fields for expression ! -- Note: in the case where a debug source file is generated, the Sloc ! -- for this node points to the left bracket in the Sprint file output. --------------- -- Reference -- --- 6087,6128 ---- -- circuit form whose left argument is static and decisively -- eliminates elaboration of the raise operation. + -- The exception is generated with a message that contains the + -- file name and line number, and then appended text. The Reason + -- code shows the text to be added. The Reason code is an element + -- of the type Types.RT_Exception_Code, and indicates both the + -- message to be added, and the exception to be raised (which must + -- match the node type). The value is stored by storing a Uint which + -- is the Pos value of the enumeration element in this type. + -- Gigi restriction: This expander ensures that the type of the -- Condition field is always Standard.Boolean, even if the type -- in the source is some non-standard boolean type. ! -- Sprint syntax: [xxx_error "msg"] ! -- or: [xxx_error when condition "msg"] -- N_Raise_Constraint_Error -- Sloc references related construct -- Condition (Node1) (set to Empty if no condition) ! -- Reason (Uint3) -- plus fields for expression -- N_Raise_Program_Error -- Sloc references related construct -- Condition (Node1) (set to Empty if no condition) ! -- Reason (Uint3) -- plus fields for expression -- N_Raise_Storage_Error -- Sloc references related construct -- Condition (Node1) (set to Empty if no condition) ! -- Reason (Uint3) -- plus fields for expression ! -- Note: Sloc is copied from the expression generating the exception. ! -- In the case where a debug source file is generated, the Sloc for ! -- this node points to the left bracket in the Sprint file output. --------------- -- Reference -- *************** package Sinfo is *** 7205,7210 **** --- 7238,7246 ---- function More_Ids (N : Node_Id) return Boolean; -- Flag5 + function Must_Be_Byte_Aligned + (N : Node_Id) return Boolean; -- Flag14 + function Must_Not_Freeze (N : Node_Id) return Boolean; -- Flag8 *************** package Sinfo is *** 7328,7333 **** --- 7364,7372 ---- function Realval (N : Node_Id) return Ureal; -- Ureal3 + function Reason + (N : Node_Id) return Uint; -- Uint3 + function Record_Extension_Part (N : Node_Id) return Node_Id; -- Node3 *************** package Sinfo is *** 7955,7960 **** --- 7994,8002 ---- procedure Set_More_Ids (N : Node_Id; Val : Boolean := True); -- Flag5 + procedure Set_Must_Be_Byte_Aligned + (N : Node_Id; Val : Boolean := True); -- Flag14 + procedure Set_Must_Not_Freeze (N : Node_Id; Val : Boolean := True); -- Flag8 *************** package Sinfo is *** 8078,8083 **** --- 8120,8128 ---- procedure Set_Realval (N : Node_Id; Val : Ureal); -- Ureal3 + procedure Set_Reason + (N : Node_Id; Val : Uint); -- Uint3 + procedure Set_Record_Extension_Part (N : Node_Id; Val : Node_Id); -- Node3 *************** package Sinfo is *** 8391,8396 **** --- 8436,8442 ---- pragma Inline (Low_Bound); pragma Inline (Mod_Clause); pragma Inline (More_Ids); + pragma Inline (Must_Be_Byte_Aligned); pragma Inline (Must_Not_Freeze); pragma Inline (Name); pragma Inline (Names); *************** package Sinfo is *** 8430,8437 **** pragma Inline (Raises_Constraint_Error); pragma Inline (Range_Constraint); pragma Inline (Range_Expression); - pragma Inline (Realval); pragma Inline (Real_Range_Specification); pragma Inline (Record_Extension_Part); pragma Inline (Redundant_Use); pragma Inline (Return_Type); --- 8476,8484 ---- pragma Inline (Raises_Constraint_Error); pragma Inline (Range_Constraint); pragma Inline (Range_Expression); pragma Inline (Real_Range_Specification); + pragma Inline (Realval); + pragma Inline (Reason); pragma Inline (Record_Extension_Part); pragma Inline (Redundant_Use); pragma Inline (Return_Type); *************** package Sinfo is *** 8638,8643 **** --- 8685,8691 ---- pragma Inline (Set_Low_Bound); pragma Inline (Set_Mod_Clause); pragma Inline (Set_More_Ids); + pragma Inline (Set_Must_Be_Byte_Aligned); pragma Inline (Set_Must_Not_Freeze); pragma Inline (Set_Name); pragma Inline (Set_Names); *************** package Sinfo is *** 8676,8683 **** pragma Inline (Set_Raises_Constraint_Error); pragma Inline (Set_Range_Constraint); pragma Inline (Set_Range_Expression); - pragma Inline (Set_Realval); pragma Inline (Set_Real_Range_Specification); pragma Inline (Set_Record_Extension_Part); pragma Inline (Set_Redundant_Use); pragma Inline (Set_Return_Type); --- 8724,8732 ---- pragma Inline (Set_Raises_Constraint_Error); pragma Inline (Set_Range_Constraint); pragma Inline (Set_Range_Expression); pragma Inline (Set_Real_Range_Specification); + pragma Inline (Set_Realval); + pragma Inline (Set_Reason); pragma Inline (Set_Record_Extension_Part); pragma Inline (Set_Redundant_Use); pragma Inline (Set_Return_Type); diff -Nrc3pad gcc-3.2.3/gcc/ada/sinfo-cn.adb gcc-3.3/gcc/ada/sinfo-cn.adb *** gcc-3.2.3/gcc/ada/sinfo-cn.adb 2002-05-04 03:29:18.000000000 +0000 --- gcc-3.3/gcc/ada/sinfo-cn.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sinfo-cn.ads gcc-3.3/gcc/ada/sinfo-cn.ads *** gcc-3.2.3/gcc/ada/sinfo-cn.ads 2002-05-04 03:29:18.000000000 +0000 --- gcc-3.3/gcc/ada/sinfo-cn.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sinfo.h gcc-3.3/gcc/ada/sinfo.h *** gcc-3.2.3/gcc/ada/sinfo.h 2003-04-22 06:56:18.000000000 +0000 --- gcc-3.3/gcc/ada/sinfo.h 2003-05-14 00:18:14.000000000 +0000 *************** *** 6,15 **** /* */ /* C Header File */ /* */ ! /* Generated by xsinfo revision 1.1 using */ ! /* sinfo.ads revision 1.6 */ /* */ ! /* Copyright (C) 1992-2001, 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- */ --- 6,15 ---- /* */ /* C Header File */ /* */ ! /* Generated by xsinfo revision using */ ! /* sinfo.ads revision 1.439 */ /* */ ! /* Copyright (C) 1992-2002, 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- */ *************** *** 661,666 **** --- 661,668 ---- { return Node2 (N); } INLINE Boolean More_Ids (Node_Id N) { return Flag5 (N); } + INLINE Boolean Must_Be_Byte_Aligned (Node_Id N) + { return Flag14 (N); } INLINE Boolean Must_Not_Freeze (Node_Id N) { return Flag8 (N); } INLINE Node_Id Name (Node_Id N) *************** *** 743,748 **** --- 745,752 ---- { return Node4 (N); } INLINE Ureal Realval (Node_Id N) { return Ureal3 (N); } + INLINE Uint Reason (Node_Id N) + { return Uint3 (N); } INLINE Node_Id Record_Extension_Part (Node_Id N) { return Node3 (N); } INLINE Boolean Redundant_Use (Node_Id N) diff -Nrc3pad gcc-3.2.3/gcc/ada/s-inmaop.ads gcc-3.3/gcc/ada/s-inmaop.ads *** gcc-3.2.3/gcc/ada/s-inmaop.ads 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-inmaop.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 7,13 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sinput.adb gcc-3.3/gcc/ada/sinput.adb *** gcc-3.2.3/gcc/ada/sinput.adb 2002-05-04 03:29:20.000000000 +0000 --- gcc-3.3/gcc/ada/sinput.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Output; use Output; *** 43,48 **** --- 42,49 ---- with Tree_IO; use Tree_IO; with System; use System; + with System.Memory; + with Unchecked_Conversion; with Unchecked_Deallocation; *************** package body Sinput is *** 53,58 **** --- 54,74 ---- First_Time_Around : Boolean := True; + -- Routines to support conversion between types Lines_Table_Ptr, + -- Logical_Lines_Table_Ptr and System.Address. + + function To_Address is + new Unchecked_Conversion (Lines_Table_Ptr, Address); + + function To_Address is + new Unchecked_Conversion (Logical_Lines_Table_Ptr, Address); + + function To_Pointer is + new Unchecked_Conversion (Address, Lines_Table_Ptr); + + function To_Pointer is + new Unchecked_Conversion (Address, Logical_Lines_Table_Ptr); + --------------------------- -- Add_Line_Tables_Entry -- --------------------------- *************** package body Sinput is *** 111,137 **** (S : in out Source_File_Record; New_Max : Nat) is ! function realloc ! (memblock : Lines_Table_Ptr; ! size : size_t) ! return Lines_Table_Ptr; ! pragma Import (C, realloc, "realloc"); ! ! function reallocl ! (memblock : Logical_Lines_Table_Ptr; ! size : size_t) ! return Logical_Lines_Table_Ptr; ! pragma Import (C, reallocl, "realloc"); ! ! function malloc ! (size : size_t) ! return Lines_Table_Ptr; ! pragma Import (C, malloc, "malloc"); ! ! function mallocl ! (size : size_t) ! return Logical_Lines_Table_Ptr; ! pragma Import (C, mallocl, "malloc"); New_Table : Lines_Table_Ptr; --- 127,133 ---- (S : in out Source_File_Record; New_Max : Nat) is ! subtype size_t is Memory.size_t; New_Table : Lines_Table_Ptr; *************** package body Sinput is *** 143,153 **** begin if S.Lines_Table = null then ! New_Table := malloc (New_Size); else New_Table := ! realloc (memblock => S.Lines_Table, size => New_Size); end if; if New_Table = null then --- 139,149 ---- begin if S.Lines_Table = null then ! New_Table := To_Pointer (Memory.Alloc (New_Size)); else New_Table := ! To_Pointer (Memory.Realloc (To_Address (S.Lines_Table), New_Size)); end if; if New_Table = null then *************** package body Sinput is *** 159,168 **** if S.Num_SRef_Pragmas /= 0 then if S.Logical_Lines_Table = null then ! New_Logical_Table := mallocl (New_Size); else ! New_Logical_Table := ! reallocl (memblock => S.Logical_Lines_Table, size => New_Size); end if; if New_Logical_Table = null then --- 155,164 ---- if S.Num_SRef_Pragmas /= 0 then if S.Logical_Lines_Table = null then ! New_Logical_Table := To_Pointer (Memory.Alloc (New_Size)); else ! New_Logical_Table := To_Pointer ! (Memory.Realloc (To_Address (S.Logical_Lines_Table), New_Size)); end if; if New_Logical_Table = null then *************** package body Sinput is *** 570,581 **** Mapped_Line : Nat; Line_After_Pragma : Physical_Line_Number) is ! SFR : Source_File_Record renames Source_File.Table (Current_Source_File); ! function malloc ! (size : size_t) ! return Logical_Lines_Table_Ptr; ! pragma Import (C, malloc); ML : Logical_Line_Number; --- 566,574 ---- Mapped_Line : Nat; Line_After_Pragma : Physical_Line_Number) is ! subtype size_t is Memory.size_t; ! SFR : Source_File_Record renames Source_File.Table (Current_Source_File); ML : Logical_Line_Number; *************** package body Sinput is *** 596,606 **** end if; if SFR.Logical_Lines_Table = null then ! SFR.Logical_Lines_Table := ! malloc (size_t (SFR.Lines_Table_Max * Logical_Lines_Table_Type'Component_Size / ! Storage_Unit)); end if; SFR.Logical_Lines_Table (Line_After_Pragma - 1) := No_Line_Number; --- 589,599 ---- end if; if SFR.Logical_Lines_Table = null then ! SFR.Logical_Lines_Table := To_Pointer ! (Memory.Alloc (size_t (SFR.Lines_Table_Max * Logical_Lines_Table_Type'Component_Size / ! Storage_Unit))); end if; SFR.Logical_Lines_Table (Line_After_Pragma - 1) := No_Line_Number; *************** package body Sinput is *** 738,753 **** procedure Free_Ptr is new Unchecked_Deallocation (Big_Source_Buffer, Source_Buffer_Ptr); - -- Note: we are using free here, because we used malloc - -- or realloc directly to allocate the tables. That is - -- because we were playing the big array trick. - - procedure free (X : Lines_Table_Ptr); - pragma Import (C, free, "free"); - - procedure freel (X : Logical_Lines_Table_Ptr); - pragma Import (C, freel, "free"); - function To_Source_Buffer_Ptr is new Unchecked_Conversion (Address, Source_Buffer_Ptr); --- 731,736 ---- *************** package body Sinput is *** 766,778 **** (S.Source_Text (S.Source_First)'Address); Free_Ptr (Tmp1); if S.Lines_Table /= null then ! free (S.Lines_Table); S.Lines_Table := null; end if; if S.Logical_Lines_Table /= null then ! freel (S.Logical_Lines_Table); S.Logical_Lines_Table := null; end if; end if; --- 749,765 ---- (S.Source_Text (S.Source_First)'Address); Free_Ptr (Tmp1); + -- Note: we are using free here, because we used malloc + -- or realloc directly to allocate the tables. That is + -- because we were playing the big array trick. + if S.Lines_Table /= null then ! Memory.Free (To_Address (S.Lines_Table)); S.Lines_Table := null; end if; if S.Logical_Lines_Table /= null then ! Memory.Free (To_Address (S.Logical_Lines_Table)); S.Logical_Lines_Table := null; end if; end if; *************** package body Sinput is *** 1119,1124 **** --- 1106,1129 ---- Source_File.Table (S).License := L; end Set_License; + ---------------------- + -- Trim_Lines_Table -- + ---------------------- + + procedure Trim_Lines_Table (S : Source_File_Index) is + Max : constant Nat := Nat (Source_File.Table (S).Last_Source_Line); + + begin + -- Release allocated storage that is no longer needed + + Source_File.Table (S).Lines_Table := To_Pointer + (Memory.Realloc + (To_Address (Source_File.Table (S).Lines_Table), + Memory.size_t + (Max * (Lines_Table_Type'Component_Size / System.Storage_Unit)))); + Source_File.Table (S).Lines_Table_Max := Physical_Line_Number (Max); + end Trim_Lines_Table; + -------- -- wl -- -------- diff -Nrc3pad gcc-3.2.3/gcc/ada/sinput.ads gcc-3.3/gcc/ada/sinput.ads *** gcc-3.2.3/gcc/ada/sinput.ads 2002-05-04 03:29:20.000000000 +0000 --- gcc-3.3/gcc/ada/sinput.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.12.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Sinput is *** 489,494 **** --- 488,494 ---- -- is why the somewhat cryptic use of brackets is acceptable). procedure wl (P : Source_Ptr); + pragma Export (Ada, wl); -- Equivalent to Write_Location (P); Write_Eol; for calls from GDB procedure Write_Time_Stamp (S : Source_File_Index); *************** private *** 631,634 **** --- 631,639 ---- -- present, also increments logical lines table size by one, and -- sets new entry. + procedure Trim_Lines_Table (S : Source_File_Index); + -- Set lines table size for entry S in the source file table to + -- correspond to the current value of Num_Source_Lines, releasing + -- any unused storage. This is used by Sinput.L and Sinput.D. + end Sinput; diff -Nrc3pad gcc-3.2.3/gcc/ada/sinput-d.adb gcc-3.3/gcc/ada/sinput-d.adb *** gcc-3.2.3/gcc/ada/sinput-d.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/sinput-d.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,112 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S I N P U T . D -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001, 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with Osint; use Osint; + with Osint.C; use Osint.C; + + package body Sinput.D is + + Dfile : Source_File_Index; + -- Index of currently active debug source file + + ------------------------ + -- Close_Debug_Source -- + ------------------------ + + procedure Close_Debug_Source is + S : Source_File_Record renames Source_File.Table (Dfile); + Src : Source_Buffer_Ptr; + + begin + Trim_Lines_Table (Dfile); + Close_Debug_File; + + -- Now we need to read the file that we wrote and store it + -- in memory for subsequent access. + + Read_Source_File + (S.Debug_Source_Name, S.Source_First, S.Source_Last, Src); + S.Source_Text := Src; + end Close_Debug_Source; + + ------------------------- + -- Create_Debug_Source -- + ------------------------- + + procedure Create_Debug_Source + (Source : Source_File_Index; + Loc : out Source_Ptr) + is + begin + Loc := Source_File.Table (Source_File.Last).Source_Last + 1; + Source_File.Increment_Last; + Dfile := Source_File.Last; + + declare + S : Source_File_Record renames Source_File.Table (Dfile); + + begin + S := Source_File.Table (Source); + S.Debug_Source_Name := Create_Debug_File (S.File_Name); + S.Source_First := Loc; + S.Source_Last := Loc; + S.Lines_Table := null; + S.Last_Source_Line := 1; + + -- Allocate lines table, guess that it needs to be three times + -- bigger than the original source (in number of lines). + + Alloc_Line_Tables + (S, Int (Source_File.Table (Source).Last_Source_Line * 3)); + S.Lines_Table (1) := Loc; + end; + end Create_Debug_Source; + + ---------------------- + -- Write_Debug_Line -- + ---------------------- + + procedure Write_Debug_Line (Str : String; Loc : in out Source_Ptr) is + S : Source_File_Record renames Source_File.Table (Dfile); + + begin + -- Ignore write request if null line at start of file + + if Str'Length = 0 and then Loc = S.Source_First then + return; + + -- Here we write the line, and update the source record entry + + else + Write_Debug_Info (Str (Str'First .. Str'Last - 1)); + Add_Line_Tables_Entry (S, Loc); + Loc := Loc - 1 + Source_Ptr (Str'Length + Debug_File_Eol_Length); + S.Source_Last := Loc; + end if; + end Write_Debug_Line; + + end Sinput.D; diff -Nrc3pad gcc-3.2.3/gcc/ada/sinput-d.ads gcc-3.3/gcc/ada/sinput-d.ads *** gcc-3.2.3/gcc/ada/sinput-d.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/sinput-d.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,62 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S I N P U T . D -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001, 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This child package contains the routines used to write debug source + -- files. These routines are not in Sinput.L, because they are used only + -- by the compiler, while Sinput.L is also used by gnatmake. + + package Sinput.D is + + ------------------------------------------------ + -- Subprograms for Writing Debug Source Files -- + ------------------------------------------------ + + procedure Create_Debug_Source + (Source : Source_File_Index; + Loc : out Source_Ptr); + -- Given a source file, creates a new source file table entry to be used + -- for the debug source file output (Debug_Generated_Code switch set). + -- Loc is set to the initial Sloc value for the first line. This call + -- also creates the debug source output file (using Create_Debug_File). + + procedure Write_Debug_Line (Str : String; Loc : in out Source_Ptr); + -- This procedure is called to write a line to the debug source file + -- previously created by Create_Debug_Source using Write_Debug_Info. + -- Str is the source line to be written to the file (it does not include + -- an end of line character). On entry Loc is the Sloc value previously + -- returned by Create_Debug_Source or Write_Debug_Line, and on exit, + -- Sloc is updated to point to the start of the next line to be written, + -- taking into account the length of the ternminator that was written by + -- Write_Debug_Info. + + procedure Close_Debug_Source; + -- This procedure completes the source table entry for the debug file + -- previously created by Create_Debug_Source, and written using the + -- Write_Debug_Line procedure. It then calls Close_Debug_File to + -- complete the writing of the file itself. + + end Sinput.D; diff -Nrc3pad gcc-3.2.3/gcc/ada/sinput-l.adb gcc-3.3/gcc/ada/sinput-l.adb *** gcc-3.2.3/gcc/ada/sinput-l.adb 2002-05-04 03:29:19.000000000 +0000 --- gcc-3.3/gcc/ada/sinput-l.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** *** 27,60 **** ------------------------------------------------------------------------------ with Alloc; ! with Atree; use Atree; ! with Debug; use Debug; ! with Einfo; use Einfo; ! with Namet; use Namet; with Opt; ! with Osint; use Osint; ! with Output; use Output; ! with Scans; use Scans; ! with Scn; use Scn; ! with Sinfo; use Sinfo; ! with System; use System; with Unchecked_Conversion; package body Sinput.L is ! Dfile : Source_File_Index; ! -- Index of currently active debug source file ----------------- -- Subprograms -- ----------------- - procedure Trim_Lines_Table (S : Source_File_Index); - -- Set lines table size for entry S in the source file table to - -- correspond to the current value of Num_Source_Lines, releasing - -- any unused storage. - function Load_File (N : File_Name_Type; T : File_Type) --- 26,54 ---- ------------------------------------------------------------------------------ with Alloc; ! with Atree; use Atree; ! with Debug; use Debug; ! with Einfo; use Einfo; ! with Namet; use Namet; with Opt; ! with Osint; use Osint; ! with Output; use Output; ! with Scans; use Scans; ! with Scn; use Scn; ! with Sinfo; use Sinfo; ! with System; use System; with Unchecked_Conversion; package body Sinput.L is ! -- Routines to support conversion between types Lines_Table_Ptr ! -- and System.Address. ----------------- -- Subprograms -- ----------------- function Load_File (N : File_Name_Type; T : File_Type) *************** package body Sinput.L is *** 79,104 **** end if; end Adjust_Instantiation_Sloc; - ------------------------ - -- Close_Debug_Source -- - ------------------------ - - procedure Close_Debug_Source is - S : Source_File_Record renames Source_File.Table (Dfile); - Src : Source_Buffer_Ptr; - - begin - Trim_Lines_Table (Dfile); - Close_Debug_File; - - -- Now we need to read the file that we wrote and store it - -- in memory for subsequent access. - - Read_Source_File - (S.Debug_Source_Name, S.Source_First, S.Source_Last, Src); - S.Source_Text := Src; - end Close_Debug_Source; - -------------------------------- -- Complete_Source_File_Entry -- -------------------------------- --- 73,78 ---- *************** package body Sinput.L is *** 111,159 **** Source_File.Table (CSF).Source_Checksum := Checksum; end Complete_Source_File_Entry; - ------------------------- - -- Create_Debug_Source -- - ------------------------- - - procedure Create_Debug_Source - (Source : Source_File_Index; - Loc : out Source_Ptr) - is - begin - Loc := Source_File.Table (Source_File.Last).Source_Last + 1; - Source_File.Increment_Last; - Dfile := Source_File.Last; - - declare - S : Source_File_Record renames Source_File.Table (Dfile); - - begin - S := Source_File.Table (Source); - S.Debug_Source_Name := Create_Debug_File (S.File_Name); - S.Source_First := Loc; - S.Source_Last := Loc; - S.Lines_Table := null; - S.Last_Source_Line := 1; - - -- Allocate lines table, guess that it needs to be three times - -- bigger than the original source (in number of lines). - - Alloc_Line_Tables - (S, Int (Source_File.Table (Source).Last_Source_Line * 3)); - S.Lines_Table (1) := Loc; - end; - - if Debug_Flag_GG then - Write_Str ("---> Create_Debug_Source (Source => "); - Write_Int (Int (Source)); - Write_Str (", Loc => "); - Write_Int (Int (Loc)); - Write_Str (");"); - Write_Eol; - end if; - - end Create_Debug_Source; - --------------------------------- -- Create_Instantiation_Source -- --------------------------------- --- 85,90 ---- *************** package body Sinput.L is *** 468,533 **** return Token = Tok_Separate; end Source_File_Is_Subunit; - ---------------------- - -- Trim_Lines_Table -- - ---------------------- - - procedure Trim_Lines_Table (S : Source_File_Index) is - - function realloc - (P : Lines_Table_Ptr; - New_Size : Int) - return Lines_Table_Ptr; - pragma Import (C, realloc); - - Max : constant Nat := Nat (Source_File.Table (S).Last_Source_Line); - - begin - -- Release allocated storage that is no longer needed - - Source_File.Table (S).Lines_Table := - realloc - (Source_File.Table (S).Lines_Table, - Max * (Lines_Table_Type'Component_Size / System.Storage_Unit)); - Source_File.Table (S).Lines_Table_Max := Physical_Line_Number (Max); - end Trim_Lines_Table; - - ---------------------- - -- Write_Debug_Line -- - ---------------------- - - procedure Write_Debug_Line (Str : String; Loc : in out Source_Ptr) is - S : Source_File_Record renames Source_File.Table (Dfile); - - begin - -- Ignore write request if null line at start of file - - if Str'Length = 0 and then Loc = S.Source_First then - return; - - -- Here we write the line, and update the source record entry - - else - Write_Debug_Info (Str); - Add_Line_Tables_Entry (S, Loc); - Loc := Loc + Source_Ptr (Str'Length + Debug_File_Eol_Length); - S.Source_Last := Loc; - - if Debug_Flag_GG then - declare - Lin : constant String := Str; - - begin - Column := 1; - Write_Str ("---> Write_Debug_Line (Str => """); - Write_Str (Lin); - Write_Str (""", Loc => "); - Write_Int (Int (Loc)); - Write_Str (");"); - Write_Eol; - end; - end if; - end if; - end Write_Debug_Line; - end Sinput.L; --- 399,402 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sinput-l.ads gcc-3.3/gcc/ada/sinput-l.ads *** gcc-3.2.3/gcc/ada/sinput-l.ads 2002-05-07 08:22:33.000000000 +0000 --- gcc-3.3/gcc/ada/sinput-l.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Sinput.L is *** 90,123 **** -- Adjust_Instantiation_Sloc to each copied node to adjust the Sloc -- to reference the source entry for the instantiation. - ------------------------------------------------ - -- Subprograms for Writing Debug Source Files -- - ------------------------------------------------ - - procedure Create_Debug_Source - (Source : Source_File_Index; - Loc : out Source_Ptr); - -- Given a source file, creates a new source file table entry to be used - -- for the debug source file output (Debug_Generated_Code switch set). - -- Loc is set to the initial Sloc value for the first line. This call - -- also creates the debug source output file (using Create_Debug_File). - - procedure Write_Debug_Line (Str : String; Loc : in out Source_Ptr); - -- This procedure is called to write a line to the debug source file - -- previously created by Create_Debug_Source using Write_Debug_Info. - -- Str is the source line to be written to the file (it does not include - -- an end of line character). On entry Loc is the Sloc value previously - -- returned by Create_Debug_Source or Write_Debug_Line, and on exit, - -- Sloc is updated to point to the start of the next line to be written, - -- taking into account the length of the ternminator that was written by - -- Write_Debug_Info. - - procedure Close_Debug_Source; - -- This procedure completes the source table entry for the debug file - -- previously created by Create_Debug_Source, and written using the - -- Write_Debug_Line procedure. It then calls Close_Debug_File to - -- complete the writing of the file itself. - private type Sloc_Adjustment is record --- 89,94 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sinput-p.adb gcc-3.3/gcc/ada/sinput-p.adb *** gcc-3.2.3/gcc/ada/sinput-p.adb 2002-05-04 03:29:20.000000000 +0000 --- gcc-3.3/gcc/ada/sinput-p.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sinput-p.ads gcc-3.3/gcc/ada/sinput-p.ads *** gcc-3.2.3/gcc/ada/sinput-p.ads 2002-05-04 03:29:20.000000000 +0000 --- gcc-3.3/gcc/ada/sinput-p.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-interr.adb gcc-3.3/gcc/ada/s-interr.adb *** gcc-3.2.3/gcc/ada/s-interr.adb 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-interr.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 56,68 **** -- There is no more than one interrupt per Server_Task and no more than -- one Server_Task per interrupt. - -- Within this package, the lock L is used to protect the various status - -- tables. If there is a Server_Task associated with an interrupt, we use - -- the per-task lock of the Server_Task instead so that we protect the - -- status between Interrupt_Manager and Server_Task. Protection among - -- service requests are done using User Request to Interrupt_Manager - -- rendezvous. - with Ada.Task_Identification; -- used for Task_ID type --- 55,60 ---- *************** with System.Interrupt_Management.Operati *** 99,107 **** -- All_Tasks_Mask pragma Elaborate_All (System.Interrupt_Management.Operations); - with System.Error_Reporting; - -- used for Shutdown - with System.Task_Primitives.Operations; -- used for Write_Lock -- Unlock --- 91,96 ---- *************** with System.Tasking.Initialization; *** 136,147 **** -- used for Defer_Abort -- Undefer_Abort with Unchecked_Conversion; package body System.Interrupts is use Tasking; - use System.Error_Reporting; use Ada.Exceptions; package PRI renames System.Task_Primitives; --- 125,139 ---- -- used for Defer_Abort -- Undefer_Abort + with System.Parameters; + -- used for Single_Lock + with Unchecked_Conversion; package body System.Interrupts is + use Parameters; use Tasking; use Ada.Exceptions; package PRI renames System.Task_Primitives; *************** package body System.Interrupts is *** 157,167 **** -- Local Tasks -- ----------------- ! -- WARNING: System.Tasking.Utilities performs calls to this task -- with low-level constructs. Do not change this spec without synchro- -- nizing it. task Interrupt_Manager is entry Initialize (Mask : IMNG.Interrupt_Mask); entry Attach_Handler --- 149,161 ---- -- Local Tasks -- ----------------- ! -- WARNING: System.Tasking.Stages performs calls to this task -- with low-level constructs. Do not change this spec without synchro- -- nizing it. task Interrupt_Manager is + entry Detach_Interrupt_Entries (T : Task_ID); + entry Initialize (Mask : IMNG.Interrupt_Mask); entry Attach_Handler *************** package body System.Interrupts is *** 185,192 **** E : Task_Entry_Index; Interrupt : Interrupt_ID); - entry Detach_Interrupt_Entries (T : Task_ID); - entry Block_Interrupt (Interrupt : Interrupt_ID); entry Unblock_Interrupt (Interrupt : Interrupt_ID); --- 179,184 ---- *************** package body System.Interrupts is *** 204,212 **** type Server_Task_Access is access Server_Task; ! -------------------------------- ! -- Local Types and Variables -- ! -------------------------------- type Entry_Assoc is record T : Task_ID; --- 196,204 ---- type Server_Task_Access is access Server_Task; ! ------------------------------- ! -- Local Types and Variables -- ! ------------------------------- type Entry_Assoc is record T : Task_ID; *************** package body System.Interrupts is *** 271,313 **** Access_Hold : Server_Task_Access; -- variable used to allocate Server_Task using "new". - L : aliased PRI.RTS_Lock; - -- L protects contents in tables above corresponding to interrupts - -- for which Server_ID (T) = null. - -- - -- If Server_ID (T) /= null then protection is via - -- per-task (TCB) lock of Server_ID (T). - -- - -- For deadlock prevention, L should not be locked after - -- any other lock is held, hence we use PO_Level which is the highest - -- lock level for error checking. - - Task_Lock : array (Interrupt_ID'Range) of Boolean := (others => False); - -- Boolean flags to give matching Locking and Unlocking. See the comments - -- in Lock_Interrupt. - ----------------------- -- Local Subprograms -- ----------------------- - procedure Lock_Interrupt - (Self_ID : Task_ID; - Interrupt : Interrupt_ID); - -- protect the tables using L or per-task lock. Set the Boolean - -- value Task_Lock if the lock is made using per-task lock. - -- This information is needed so that Unlock_Interrupt - -- performs unlocking on the same lock. The situation we are preventing - -- is, for example, when Attach_Handler is called for the first time - -- we lock L and create an Server_Task. For a matching unlocking, if we - -- rely on the fact that there is a Server_Task, we will unlock the - -- per-task lock. - - procedure Unlock_Interrupt - (Self_ID : Task_ID; - Interrupt : Interrupt_ID); - function Is_Registered (Handler : Parameterless_Handler) return Boolean; ! -- ??? spec needs comments -------------------- -- Attach_Handler -- --- 263,275 ---- Access_Hold : Server_Task_Access; -- variable used to allocate Server_Task using "new". ----------------------- -- Local Subprograms -- ----------------------- function Is_Registered (Handler : Parameterless_Handler) return Boolean; ! -- See if the Handler has been "pragma"ed using Interrupt_Handler. ! -- Always consider a null handler as registered. -------------------- -- Attach_Handler -- *************** package body System.Interrupts is *** 602,610 **** -- Is_Registered -- ------------------- - -- See if the Handler has been "pragma"ed using Interrupt_Handler. - -- Always consider a null handler as registered. - function Is_Registered (Handler : Parameterless_Handler) return Boolean is type Fat_Ptr is record --- 564,569 ---- *************** package body System.Interrupts is *** 648,698 **** return IMNG.Reserve (IMNG.Interrupt_ID (Interrupt)); end Is_Reserved; - -------------------- - -- Lock_Interrupt -- - -------------------- - - -- ????? - - -- This package has been modified several times. - -- Do we still need this fancy locking scheme, now that more operations - -- are entries of the interrupt manager task? - - -- ????? - - -- More likely, we will need to convert one or more entry calls to - -- protected operations, because presently we are violating locking order - -- rules by calling a task entry from within the runtime system. - - procedure Lock_Interrupt - (Self_ID : Task_ID; - Interrupt : Interrupt_ID) - is - begin - Initialization.Defer_Abort (Self_ID); - - POP.Write_Lock (L'Access); - - if Task_Lock (Interrupt) then - - -- We need to use per-task lock. - - POP.Unlock (L'Access); - POP.Write_Lock (Server_ID (Interrupt)); - - -- Rely on the fact that once Server_ID is set to a non-null - -- value it will never be set back to null. - - elsif Server_ID (Interrupt) /= Null_Task then - - -- We need to use per-task lock. - - Task_Lock (Interrupt) := True; - POP.Unlock (L'Access); - POP.Write_Lock (Server_ID (Interrupt)); - end if; - end Lock_Interrupt; - --------------- -- Reference -- --------------- --- 607,612 ---- *************** package body System.Interrupts is *** 786,809 **** Interrupt_Manager.Unignore_Interrupt (Interrupt); end Unignore_Interrupt; - ---------------------- - -- Unlock_Interrupt -- - ---------------------- - - procedure Unlock_Interrupt - (Self_ID : Task_ID; - Interrupt : Interrupt_ID) - is - begin - if Task_Lock (Interrupt) then - POP.Unlock (Server_ID (Interrupt)); - else - POP.Unlock (L'Access); - end if; - - Initialization.Undefer_Abort (Self_ID); - end Unlock_Interrupt; - ----------------------- -- Interrupt_Manager -- ----------------------- --- 700,705 ---- *************** package body System.Interrupts is *** 818,823 **** --- 714,720 ---- Ret_Interrupt : Interrupt_ID; Old_Mask : aliased IMNG.Interrupt_Mask; Self_ID : Task_ID := POP.Self; + Old_Handler : Parameterless_Handler; --------------------- -- Local Routines -- *************** package body System.Interrupts is *** 833,841 **** -- Otherwise, we have to interrupt Server_Task for status change -- through abort interrupt. - -- Following two procedure are named Unprotected... in order to - -- indicate that Lock/Unlock_Interrupt operations are needed around. - procedure Unprotected_Exchange_Handler (Old_Handler : out Parameterless_Handler; New_Handler : in Parameterless_Handler; --- 730,735 ---- *************** package body System.Interrupts is *** 924,930 **** -- In case we have an Interrupt Entry installed. -- raise a program error. (propagate it to the caller). - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "An interrupt entry is already installed"); end if; --- 818,823 ---- *************** package body System.Interrupts is *** 934,944 **** -- status of the current_Handler. if not Static and then User_Handler (Interrupt).Static then - -- Tries to detach a static Interrupt Handler. -- raise a program error. - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "Trying to detach a static Interrupt Handler"); end if; --- 827,835 ---- *************** package body System.Interrupts is *** 970,984 **** New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID; Static : in Boolean; ! Restoration : in Boolean := False) ! is begin if User_Entry (Interrupt).T /= Null_Task then - -- In case we have an Interrupt Entry already installed. -- raise a program error. (propagate it to the caller). - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "An interrupt is already installed"); end if; --- 861,872 ---- New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID; Static : in Boolean; ! Restoration : in Boolean := False) is begin if User_Entry (Interrupt).T /= Null_Task then -- In case we have an Interrupt Entry already installed. -- raise a program error. (propagate it to the caller). Raise_Exception (Program_Error'Identity, "An interrupt is already installed"); end if; *************** package body System.Interrupts is *** 1002,1008 **** or else not Is_Registered (New_Handler)) then - Unlock_Interrupt (Self_ID, Interrupt); Raise_Exception (Program_Error'Identity, "Trying to overwrite a static Interrupt Handler with a " & "dynamic Handler"); --- 890,895 ---- *************** package body System.Interrupts is *** 1069,1075 **** System.Tasking.Utilities.Make_Independent; ! -- Environmen task gets its own interrupt mask, saves it, -- and then masks all interrupts except the Keep_Unmasked set. -- During rendezvous, the Interrupt_Manager receives the old --- 956,962 ---- System.Tasking.Utilities.Make_Independent; ! -- Environment task gets its own interrupt mask, saves it, -- and then masks all interrupts except the Keep_Unmasked set. -- During rendezvous, the Interrupt_Manager receives the old *************** package body System.Interrupts is *** 1124,1370 **** loop -- A block is needed to absorb Program_Error exception - declare - Old_Handler : Parameterless_Handler; - begin select ! accept Attach_Handler ! (New_Handler : in Parameterless_Handler; ! Interrupt : in Interrupt_ID; ! Static : in Boolean; ! Restoration : in Boolean := False) ! do ! Lock_Interrupt (Self_ID, Interrupt); ! Unprotected_Exchange_Handler ! (Old_Handler, New_Handler, Interrupt, Static, Restoration); ! Unlock_Interrupt (Self_ID, Interrupt); ! end Attach_Handler; ! ! or accept Exchange_Handler ! (Old_Handler : out Parameterless_Handler; ! New_Handler : in Parameterless_Handler; ! Interrupt : in Interrupt_ID; ! Static : in Boolean) ! do ! Lock_Interrupt (Self_ID, Interrupt); ! Unprotected_Exchange_Handler ! (Old_Handler, New_Handler, Interrupt, Static); ! Unlock_Interrupt (Self_ID, Interrupt); ! end Exchange_Handler; ! ! or accept Detach_Handler ! (Interrupt : in Interrupt_ID; ! Static : in Boolean) ! do ! Lock_Interrupt (Self_ID, Interrupt); ! Unprotected_Detach_Handler (Interrupt, Static); ! Unlock_Interrupt (Self_ID, Interrupt); ! end Detach_Handler; ! ! or accept Bind_Interrupt_To_Entry ! (T : Task_ID; ! E : Task_Entry_Index; ! Interrupt : Interrupt_ID) ! do ! Lock_Interrupt (Self_ID, Interrupt); ! ! -- if there is a binding already (either a procedure or an ! -- entry), raise Program_Error (propagate it to the caller). ! ! if User_Handler (Interrupt).H /= null ! or else User_Entry (Interrupt).T /= Null_Task ! then ! Unlock_Interrupt (Self_ID, Interrupt); ! Raise_Exception (Program_Error'Identity, ! "A binding for this interrupt is already present"); ! end if; ! ! -- The interrupt should no longer be ingnored if ! -- it was ever ignored. ! ! Ignored (Interrupt) := False; ! User_Entry (Interrupt) := Entry_Assoc' (T => T, E => E); ! ! -- Indicate the attachment of Interrupt Entry in ATCB. ! -- This is need so that when an Interrupt Entry task terminates ! -- the binding can be cleaned. The call to unbinding must be ! -- make by the task before it terminates. ! ! T.Interrupt_Entry := True; ! -- Invoke a corresponding Server_Task if not yet created. ! -- Place Task_ID info in Server_ID array. ! if Server_ID (Interrupt) = Null_Task then ! -- When a new Server_Task is created, it should have its ! -- signal mask set to the All_Tasks_Mask. ! IMOP.Set_Interrupt_Mask ! (IMOP.All_Tasks_Mask'Access, Old_Mask'Access); ! Access_Hold := new Server_Task (Interrupt); ! IMOP.Set_Interrupt_Mask (Old_Mask'Access); ! Server_ID (Interrupt) := ! To_System (Access_Hold.all'Identity); ! end if; ! Bind_Handler (Interrupt); ! Unlock_Interrupt (Self_ID, Interrupt); ! end Bind_Interrupt_To_Entry; ! or accept Detach_Interrupt_Entries (T : Task_ID) ! do ! for I in Interrupt_ID'Range loop ! if not Is_Reserved (I) then ! Lock_Interrupt (Self_ID, I); ! if User_Entry (I).T = T then ! -- The interrupt should no longer be ingnored if ! -- it was ever ignored. ! Ignored (I) := False; ! User_Entry (I) := Entry_Assoc' ! (T => Null_Task, E => Null_Task_Entry); ! Unbind_Handler (I); ! end if; ! Unlock_Interrupt (Self_ID, I); end if; - end loop; ! -- Indicate in ATCB that no Interrupt Entries are attached. ! ! T.Interrupt_Entry := False; ! end Detach_Interrupt_Entries; ! ! or accept Block_Interrupt (Interrupt : Interrupt_ID) do ! Lock_Interrupt (Self_ID, Interrupt); ! ! if Blocked (Interrupt) then ! Unlock_Interrupt (Self_ID, Interrupt); ! return; ! end if; ! Blocked (Interrupt) := True; ! Last_Unblocker (Interrupt) := Null_Task; ! -- Mask this task for the given Interrupt so that all tasks ! -- are masked for the Interrupt. ! IMOP.Thread_Block_Interrupt (IMNG.Interrupt_ID (Interrupt)); ! if User_Handler (Interrupt).H /= null ! or else User_Entry (Interrupt).T /= Null_Task ! then ! -- This is the case where the Server_Task is waiting on ! -- "sigwait." Wake it up by sending an Abort_Task_Interrupt ! -- so that the Server_Task waits on Cond. ! POP.Abort_Task (Server_ID (Interrupt)); ! -- Make sure corresponding Server_Task is out of its own ! -- sigwait state. ! Ret_Interrupt := ! Interrupt_ID (IMOP.Interrupt_Wait (Intwait_Mask'Access)); ! pragma Assert ! (Ret_Interrupt = Interrupt_ID (IMNG.Abort_Task_Interrupt)); ! end if; ! Unlock_Interrupt (Self_ID, Interrupt); ! end Block_Interrupt; ! or accept Unblock_Interrupt (Interrupt : Interrupt_ID) do ! Lock_Interrupt (Self_ID, Interrupt); ! if not Blocked (Interrupt) then ! Unlock_Interrupt (Self_ID, Interrupt); ! return; ! end if; ! Blocked (Interrupt) := False; ! Last_Unblocker (Interrupt) := ! To_System (Unblock_Interrupt'Caller); ! if User_Handler (Interrupt).H = null ! and then User_Entry (Interrupt).T = Null_Task ! then ! -- No handler is attached. Unmask the Interrupt so that ! -- the default action can be carried out. ! IMOP.Thread_Unblock_Interrupt ! (IMNG.Interrupt_ID (Interrupt)); ! else ! -- The Server_Task must be waiting on the Cond variable ! -- since it was being blocked and an Interrupt Hander or ! -- an Entry was there. Wake it up and let it change ! -- it place of waiting according to its new state. ! POP.Wakeup (Server_ID (Interrupt), ! Interrupt_Server_Blocked_Interrupt_Sleep); ! end if; ! Unlock_Interrupt (Self_ID, Interrupt); ! end Unblock_Interrupt; ! or accept Ignore_Interrupt (Interrupt : Interrupt_ID) do ! Lock_Interrupt (Self_ID, Interrupt); ! if Ignored (Interrupt) then ! Unlock_Interrupt (Self_ID, Interrupt); ! return; ! end if; ! Ignored (Interrupt) := True; ! -- If there is a handler associated with the Interrupt, ! -- detach it first. In this way we make sure that the ! -- Server_Task is not on sigwait. This is legal since ! -- Unignore_Interrupt is to install the default action. ! if User_Handler (Interrupt).H /= null then ! Unprotected_Detach_Handler ! (Interrupt => Interrupt, Static => True); ! elsif User_Entry (Interrupt).T /= Null_Task then ! User_Entry (Interrupt) := Entry_Assoc' ! (T => Null_Task, E => Null_Task_Entry); ! Unbind_Handler (Interrupt); ! end if; ! IMOP.Install_Ignore_Action (IMNG.Interrupt_ID (Interrupt)); ! Unlock_Interrupt (Self_ID, Interrupt); ! end Ignore_Interrupt; ! or accept Unignore_Interrupt (Interrupt : Interrupt_ID) do ! Lock_Interrupt (Self_ID, Interrupt); ! Ignored (Interrupt) := False; ! -- If there is a handler associated with the Interrupt, ! -- detach it first. In this way we make sure that the ! -- Server_Task is not on sigwait. This is legal since ! -- Unignore_Interrupt is to install the default action. ! if User_Handler (Interrupt).H /= null then ! Unprotected_Detach_Handler ! (Interrupt => Interrupt, Static => True); ! elsif User_Entry (Interrupt).T /= Null_Task then ! User_Entry (Interrupt) := Entry_Assoc' ! (T => Null_Task, E => Null_Task_Entry); ! Unbind_Handler (Interrupt); ! end if; ! IMOP.Install_Default_Action (IMNG.Interrupt_ID (Interrupt)); ! Unlock_Interrupt (Self_ID, Interrupt); ! end Unignore_Interrupt; end select; exception - -- If there is a program error we just want to propagate it to -- the caller and do not want to stop this task. --- 1011,1228 ---- loop -- A block is needed to absorb Program_Error exception begin select + accept Attach_Handler + (New_Handler : in Parameterless_Handler; + Interrupt : in Interrupt_ID; + Static : in Boolean; + Restoration : in Boolean := False) + do + Unprotected_Exchange_Handler + (Old_Handler, New_Handler, Interrupt, Static, Restoration); + end Attach_Handler; ! or ! accept Exchange_Handler ! (Old_Handler : out Parameterless_Handler; ! New_Handler : in Parameterless_Handler; ! Interrupt : in Interrupt_ID; ! Static : in Boolean) ! do ! Unprotected_Exchange_Handler ! (Old_Handler, New_Handler, Interrupt, Static); ! end Exchange_Handler; ! or ! accept Detach_Handler ! (Interrupt : in Interrupt_ID; ! Static : in Boolean) ! do ! Unprotected_Detach_Handler (Interrupt, Static); ! end Detach_Handler; ! or ! accept Bind_Interrupt_To_Entry ! (T : Task_ID; ! E : Task_Entry_Index; ! Interrupt : Interrupt_ID) ! do ! -- if there is a binding already (either a procedure or an ! -- entry), raise Program_Error (propagate it to the caller). ! if User_Handler (Interrupt).H /= null ! or else User_Entry (Interrupt).T /= Null_Task ! then ! Raise_Exception (Program_Error'Identity, ! "A binding for this interrupt is already present"); ! end if; ! -- The interrupt should no longer be ingnored if ! -- it was ever ignored. ! Ignored (Interrupt) := False; ! User_Entry (Interrupt) := Entry_Assoc' (T => T, E => E); ! -- Indicate the attachment of Interrupt Entry in ATCB. ! -- This is need so that when an Interrupt Entry task ! -- terminates the binding can be cleaned. The call to ! -- unbinding must be made by the task before it terminates. ! T.Interrupt_Entry := True; ! -- Invoke a corresponding Server_Task if not yet created. ! -- Place Task_ID info in Server_ID array. ! if Server_ID (Interrupt) = Null_Task then ! -- When a new Server_Task is created, it should have its ! -- signal mask set to the All_Tasks_Mask. ! IMOP.Set_Interrupt_Mask ! (IMOP.All_Tasks_Mask'Access, Old_Mask'Access); ! Access_Hold := new Server_Task (Interrupt); ! IMOP.Set_Interrupt_Mask (Old_Mask'Access); ! Server_ID (Interrupt) := ! To_System (Access_Hold.all'Identity); end if; ! Bind_Handler (Interrupt); ! end Bind_Interrupt_To_Entry; ! or ! accept Detach_Interrupt_Entries (T : Task_ID) do ! for J in Interrupt_ID'Range loop ! if not Is_Reserved (J) then ! if User_Entry (J).T = T then ! -- The interrupt should no longer be ingnored if ! -- it was ever ignored. ! Ignored (J) := False; ! User_Entry (J) := Entry_Assoc' ! (T => Null_Task, E => Null_Task_Entry); ! Unbind_Handler (J); ! end if; ! end if; ! end loop; ! -- Indicate in ATCB that no Interrupt Entries are attached. ! T.Interrupt_Entry := False; ! end Detach_Interrupt_Entries; ! or ! accept Block_Interrupt (Interrupt : Interrupt_ID) do ! if Blocked (Interrupt) then ! return; ! end if; ! Blocked (Interrupt) := True; ! Last_Unblocker (Interrupt) := Null_Task; ! -- Mask this task for the given Interrupt so that all tasks ! -- are masked for the Interrupt. ! IMOP.Thread_Block_Interrupt (IMNG.Interrupt_ID (Interrupt)); ! if User_Handler (Interrupt).H /= null ! or else User_Entry (Interrupt).T /= Null_Task ! then ! -- This is the case where the Server_Task is waiting on ! -- "sigwait." Wake it up by sending an ! -- Abort_Task_Interrupt so that the Server_Task waits on ! -- Cond. ! POP.Abort_Task (Server_ID (Interrupt)); ! -- Make sure corresponding Server_Task is out of its own ! -- sigwait state. ! Ret_Interrupt := Interrupt_ID ! (IMOP.Interrupt_Wait (Intwait_Mask'Access)); ! pragma Assert ! (Ret_Interrupt = ! Interrupt_ID (IMNG.Abort_Task_Interrupt)); ! end if; ! end Block_Interrupt; ! or ! accept Unblock_Interrupt (Interrupt : Interrupt_ID) do ! if not Blocked (Interrupt) then ! return; ! end if; ! Blocked (Interrupt) := False; ! Last_Unblocker (Interrupt) := ! To_System (Unblock_Interrupt'Caller); ! if User_Handler (Interrupt).H = null ! and then User_Entry (Interrupt).T = Null_Task ! then ! -- No handler is attached. Unmask the Interrupt so that ! -- the default action can be carried out. ! IMOP.Thread_Unblock_Interrupt ! (IMNG.Interrupt_ID (Interrupt)); ! else ! -- The Server_Task must be waiting on the Cond variable ! -- since it was being blocked and an Interrupt Hander or ! -- an Entry was there. Wake it up and let it change ! -- it place of waiting according to its new state. ! POP.Wakeup (Server_ID (Interrupt), ! Interrupt_Server_Blocked_Interrupt_Sleep); ! end if; ! end Unblock_Interrupt; ! or ! accept Ignore_Interrupt (Interrupt : Interrupt_ID) do ! if Ignored (Interrupt) then ! return; ! end if; ! Ignored (Interrupt) := True; ! -- If there is a handler associated with the Interrupt, ! -- detach it first. In this way we make sure that the ! -- Server_Task is not on sigwait. This is legal since ! -- Unignore_Interrupt is to install the default action. ! if User_Handler (Interrupt).H /= null then ! Unprotected_Detach_Handler ! (Interrupt => Interrupt, Static => True); ! elsif User_Entry (Interrupt).T /= Null_Task then ! User_Entry (Interrupt) := Entry_Assoc' ! (T => Null_Task, E => Null_Task_Entry); ! Unbind_Handler (Interrupt); ! end if; ! IMOP.Install_Ignore_Action (IMNG.Interrupt_ID (Interrupt)); ! end Ignore_Interrupt; ! or ! accept Unignore_Interrupt (Interrupt : Interrupt_ID) do ! Ignored (Interrupt) := False; ! -- If there is a handler associated with the Interrupt, ! -- detach it first. In this way we make sure that the ! -- Server_Task is not on sigwait. This is legal since ! -- Unignore_Interrupt is to install the default action. ! if User_Handler (Interrupt).H /= null then ! Unprotected_Detach_Handler ! (Interrupt => Interrupt, Static => True); ! elsif User_Entry (Interrupt).T /= Null_Task then ! User_Entry (Interrupt) := Entry_Assoc' ! (T => Null_Task, E => Null_Task_Entry); ! Unbind_Handler (Interrupt); ! end if; + IMOP.Install_Default_Action (IMNG.Interrupt_ID (Interrupt)); + end Unignore_Interrupt; end select; exception -- If there is a program error we just want to propagate it to -- the caller and do not want to stop this task. *************** package body System.Interrupts is *** 1372,1386 **** null; when others => ! pragma Assert ! (Shutdown ("Interrupt_Manager---exception not expected")); null; end; - end loop; - - pragma Assert (Shutdown ("Interrupt_Manager---should not get here")); - end Interrupt_Manager; ----------------- --- 1230,1239 ---- null; when others => ! pragma Assert (False); null; end; end loop; end Interrupt_Manager; ----------------- *************** package body System.Interrupts is *** 1438,1443 **** --- 1291,1301 ---- loop System.Tasking.Initialization.Defer_Abort (Self_ID); + + if Single_Lock then + POP.Lock_RTS; + end if; + POP.Write_Lock (Self_ID); if User_Handler (Interrupt).H = null *************** package body System.Interrupts is *** 1472,1477 **** --- 1330,1339 ---- POP.Unlock (Self_ID); + if Single_Lock then + POP.Unlock_RTS; + end if; + Ret_Interrupt := Interrupt_ID (IMOP.Interrupt_Wait (Intwait_Mask'Access)); *************** package body System.Interrupts is *** 1480,1490 **** --- 1342,1361 ---- -- Inform the Interrupt_Manager of wakeup from above sigwait. POP.Abort_Task (Interrupt_Manager_ID); + + if Single_Lock then + POP.Lock_RTS; + end if; + POP.Write_Lock (Self_ID); else pragma Assert (Ret_Interrupt = Interrupt); + if Single_Lock then + POP.Lock_RTS; + end if; + POP.Write_Lock (Self_ID); -- Even though we have received an Interrupt the status may *************** package body System.Interrupts is *** 1501,1507 **** --- 1372,1387 ---- POP.Unlock (Self_ID); + if Single_Lock then + POP.Unlock_RTS; + end if; + Tmp_Handler.all; + + if Single_Lock then + POP.Lock_RTS; + end if; + POP.Write_Lock (Self_ID); elsif User_Entry (Interrupt).T /= Null_Task then *************** package body System.Interrupts is *** 1510,1521 **** --- 1390,1410 ---- -- RTS calls should not be made with self being locked. + if Single_Lock then + POP.Unlock_RTS; + end if; + POP.Unlock (Self_ID); System.Tasking.Rendezvous.Call_Simple (Tmp_ID, Tmp_Entry_Index, System.Null_Address); POP.Write_Lock (Self_ID); + + if Single_Lock then + POP.Lock_RTS; + end if; + else -- This is a situation that this task wake up -- receiving an Interrupt and before it get the lock *************** package body System.Interrupts is *** 1526,1542 **** IMOP.Interrupt_Self_Process (IMNG.Interrupt_ID (Interrupt)); end if; end if; - end if; POP.Unlock (Self_ID); System.Tasking.Initialization.Undefer_Abort (Self_ID); -- Undefer abort here to allow a window for this task -- to be aborted at the time of system shutdown. end loop; - - pragma Assert (Shutdown ("Server_Task---should not get here")); end Server_Task; -- Elaboration code for package System.Interrupts --- 1415,1433 ---- IMOP.Interrupt_Self_Process (IMNG.Interrupt_ID (Interrupt)); end if; end if; end if; POP.Unlock (Self_ID); + + if Single_Lock then + POP.Unlock_RTS; + end if; + System.Tasking.Initialization.Undefer_Abort (Self_ID); -- Undefer abort here to allow a window for this task -- to be aborted at the time of system shutdown. end loop; end Server_Task; -- Elaboration code for package System.Interrupts *************** begin *** 1547,1558 **** Interrupt_Manager_ID := To_System (Interrupt_Manager'Identity); - -- Initialize the lock L. - - Initialization.Defer_Abort (Self); - POP.Initialize_Lock (L'Access, POP.PO_Level); - Initialization.Undefer_Abort (Self); - -- During the elaboration of this package body we want RTS to -- inherit the interrupt mask from the Environment Task. --- 1438,1443 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-interr.ads gcc-3.3/gcc/ada/s-interr.ads *** gcc-3.2.3/gcc/ada/s-interr.ads 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-interr.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-intman.ads gcc-3.3/gcc/ada/s-intman.ads *** gcc-3.2.3/gcc/ada/s-intman.ads 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-intman.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1991-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-io.adb gcc-3.3/gcc/ada/s-io.adb *** gcc-3.2.3/gcc/ada/s-io.adb 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-io.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-io.ads gcc-3.3/gcc/ada/s-io.ads *** gcc-3.2.3/gcc/ada/s-io.ads 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-io.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-maccod.ads gcc-3.3/gcc/ada/s-maccod.ads *** gcc-3.2.3/gcc/ada/s-maccod.ads 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-maccod.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-mantis.adb gcc-3.3/gcc/ada/s-mantis.adb *** gcc-3.2.3/gcc/ada/s-mantis.adb 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-mantis.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-mantis.ads gcc-3.3/gcc/ada/s-mantis.ads *** gcc-3.2.3/gcc/ada/s-mantis.ads 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-mantis.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-mastop.adb gcc-3.3/gcc/ada/s-mastop.adb *** gcc-3.2.3/gcc/ada/s-mastop.adb 2001-10-02 14:30:14.000000000 +0000 --- gcc-3.3/gcc/ada/s-mastop.adb 2002-03-14 10:59:49.000000000 +0000 *************** *** 7,15 **** -- B o d y -- -- (Dummy version) -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 7,14 ---- -- B o d y -- -- (Dummy version) -- -- -- -- -- ! -- Copyright (C) 1999-2001 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- -- *************** *** 39,44 **** --- 38,47 ---- package body System.Machine_State_Operations is + -- Turn off warnings since many unused parameters + + pragma Warnings (Off); + use System.Exceptions; ---------------------------- *************** package body System.Machine_State_Operat *** 122,128 **** procedure Set_Signal_Machine_State (M : Machine_State; ! Context : System.Address) is begin null; end Set_Signal_Machine_State; --- 125,132 ---- procedure Set_Signal_Machine_State (M : Machine_State; ! Context : System.Address) ! is begin null; end Set_Signal_Machine_State; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-mastop.ads gcc-3.3/gcc/ada/s-mastop.ads *** gcc-3.2.3/gcc/ada/s-mastop.ads 2001-10-02 14:30:14.000000000 +0000 --- gcc-3.3/gcc/ada/s-mastop.ads 2002-03-14 10:59:49.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1999-2001 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-memory.adb gcc-3.3/gcc/ada/s-memory.adb *** gcc-3.2.3/gcc/ada/s-memory.adb 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-memory.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 2001-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** *** 51,56 **** --- 50,56 ---- with Ada.Exceptions; with System.Soft_Links; + with System.Parameters; package body System.Memory is *************** package body System.Memory is *** 89,97 **** Actual_Size := 1; end if; ! Abort_Defer.all; ! Result := c_malloc (Actual_Size); ! Abort_Undefer.all; if Result = System.Null_Address then Raise_Exception (Storage_Error'Identity, "heap exhausted"); --- 89,101 ---- Actual_Size := 1; end if; ! if Parameters.No_Abort then ! Result := c_malloc (Actual_Size); ! else ! Abort_Defer.all; ! Result := c_malloc (Actual_Size); ! Abort_Undefer.all; ! end if; if Result = System.Null_Address then Raise_Exception (Storage_Error'Identity, "heap exhausted"); *************** package body System.Memory is *** 106,114 **** procedure Free (Ptr : System.Address) is begin ! Abort_Defer.all; ! c_free (Ptr); ! Abort_Undefer.all; end Free; ------------- --- 110,122 ---- procedure Free (Ptr : System.Address) is begin ! if Parameters.No_Abort then ! c_free (Ptr); ! else ! Abort_Defer.all; ! c_free (Ptr); ! Abort_Undefer.all; ! end if; end Free; ------------- *************** package body System.Memory is *** 128,136 **** Raise_Exception (Storage_Error'Identity, "object too large"); end if; ! Abort_Defer.all; ! Result := c_realloc (Ptr, Actual_Size); ! Abort_Undefer.all; if Result = System.Null_Address then Raise_Exception (Storage_Error'Identity, "heap exhausted"); --- 136,148 ---- Raise_Exception (Storage_Error'Identity, "object too large"); end if; ! if Parameters.No_Abort then ! Result := c_realloc (Ptr, Actual_Size); ! else ! Abort_Defer.all; ! Result := c_realloc (Ptr, Actual_Size); ! Abort_Undefer.all; ! end if; if Result = System.Null_Address then Raise_Exception (Storage_Error'Identity, "heap exhausted"); diff -Nrc3pad gcc-3.2.3/gcc/ada/s-memory.ads gcc-3.3/gcc/ada/s-memory.ads *** gcc-3.2.3/gcc/ada/s-memory.ads 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-memory.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/snames.adb gcc-3.3/gcc/ada/snames.adb *** gcc-3.2.3/gcc/ada/snames.adb 2002-05-07 08:22:34.000000000 +0000 --- gcc-3.3/gcc/ada/snames.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.6.10.2 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** *** 34,42 **** --- 33,57 ---- ------------------------------------------------------------------------------ with Namet; use Namet; + with Table; package body Snames is + -- Table used to record convention identifiers + + type Convention_Id_Entry is record + Name : Name_Id; + Convention : Convention_Id; + end record; + + package Convention_Identifiers is new Table.Table ( + Table_Component_Type => Convention_Id_Entry, + Table_Index_Type => Int, + Table_Low_Bound => 1, + Table_Initial => 50, + Table_Increment => 200, + Table_Name => "Name_Convention_Identifiers"); + -- Table of names to be set by Initialize. Each name is terminated by a -- single #, and the end of the list is marked by a null entry, i.e. by -- two # marks in succession. Note that the table does not include the *************** package body Snames is *** 149,154 **** --- 164,170 ---- "ada_95#" & "c_pass_by_copy#" & "component_alignment#" & + "convention_identifier#" & "discard_names#" & "elaboration_checks#" & "eliminate#" & *************** package body Snames is *** 261,281 **** "title#" & "unchecked_union#" & "unimplemented_unit#" & "unreserve_all_interrupts#" & "volatile#" & "volatile_components#" & "weak_external#" & "ada#" & - "asm#" & "assembler#" & "cobol#" & "cpp#" & - "dll#" & "fortran#" & "intrinsic#" & "java#" & "stdcall#" & "stubbed#" & "win32#" & "as_is#" & "body_file_name#" & --- 277,301 ---- "title#" & "unchecked_union#" & "unimplemented_unit#" & + "universal_data#" & + "unreferenced#" & "unreserve_all_interrupts#" & "volatile#" & "volatile_components#" & "weak_external#" & "ada#" & "assembler#" & "cobol#" & "cpp#" & "fortran#" & "intrinsic#" & "java#" & "stdcall#" & "stubbed#" & + "asm#" & + "assembly#" & + "default#" & + "dll#" & "win32#" & "as_is#" & "body_file_name#" & *************** package body Snames is *** 286,292 **** "copy#" & "d_float#" & "descriptor#" & - "default#" & "dot_replacement#" & "dynamic#" & "entity#" & --- 306,311 ---- *************** package body Snames is *** 298,303 **** --- 317,323 ---- "gnat#" & "gpl#" & "ieee_float#" & + "homonym_number#" & "internal#" & "link_name#" & "lowercase#" & *************** package body Snames is *** 387,394 **** "machine_rounds#" & "machine_size#" & "mantissa#" & - "max_interrupt_priority#" & - "max_priority#" & "max_size_in_storage_elements#" & "maximum_alignment#" & "mechanism_code#" & --- 407,412 ---- *************** package body Snames is *** 420,426 **** "storage_unit#" & "tag#" & "terminated#" & - "tick#" & "to_address#" & "type_class#" & "uet_address#" & --- 438,443 ---- *************** package body Snames is *** 641,647 **** -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3) ! -- (list not yet complete ???) ---------------------- -- Get_Attribute_Id -- --- 658,664 ---- -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3) ! -- (Note: this list is not complete or accurate ???) ---------------------- -- Get_Attribute_Id -- *************** package body Snames is *** 669,687 **** begin case N is when Name_Ada => return Convention_Ada; - when Name_Asm => return Convention_Assembler; when Name_Assembler => return Convention_Assembler; when Name_C => return Convention_C; when Name_COBOL => return Convention_COBOL; when Name_CPP => return Convention_CPP; - when Name_DLL => return Convention_Stdcall; when Name_Fortran => return Convention_Fortran; when Name_Intrinsic => return Convention_Intrinsic; when Name_Java => return Convention_Java; when Name_Stdcall => return Convention_Stdcall; when Name_Stubbed => return Convention_Stubbed; ! when Name_Win32 => return Convention_Stdcall; when others => raise Program_Error; end case; end Get_Convention_Id; --- 686,708 ---- begin case N is when Name_Ada => return Convention_Ada; when Name_Assembler => return Convention_Assembler; when Name_C => return Convention_C; when Name_COBOL => return Convention_COBOL; when Name_CPP => return Convention_CPP; when Name_Fortran => return Convention_Fortran; when Name_Intrinsic => return Convention_Intrinsic; when Name_Java => return Convention_Java; when Name_Stdcall => return Convention_Stdcall; when Name_Stubbed => return Convention_Stubbed; ! when others => + for J in 1 .. Convention_Identifiers.Last loop + if N = Convention_Identifiers.Table (J).Name then + return Convention_Identifiers.Table (J).Convention; + end if; + end loop; + raise Program_Error; end case; end Get_Convention_Id; *************** package body Snames is *** 767,772 **** --- 788,807 ---- -- properly matching version of the body. pragma Assert (Discard_Name = Last_Predefined_Name); + + -- Initialize the convention identifiers table with the standard + -- set of synonyms that we recognize for conventions. + + Convention_Identifiers.Init; + + Convention_Identifiers.Append ((Name_Asm, Convention_Assembler)); + Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler)); + + Convention_Identifiers.Append ((Name_Default, Convention_C)); + Convention_Identifiers.Append ((Name_External, Convention_C)); + + Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall)); + Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall)); end Initialize; ----------------------- *************** package body Snames is *** 793,800 **** function Is_Convention_Name (N : Name_Id) return Boolean is begin ! return N in First_Convention_Name .. Last_Convention_Name ! or else N = Name_C; end Is_Convention_Name; ------------------------------ --- 828,847 ---- function Is_Convention_Name (N : Name_Id) return Boolean is begin ! if N in First_Convention_Name .. Last_Convention_Name ! or else N = Name_C ! then ! return True; ! ! else ! for J in 1 .. Convention_Identifiers.Last loop ! if N = Convention_Identifiers.Table (J).Name then ! return True; ! end if; ! end loop; ! ! return False; ! end if; end Is_Convention_Name; ------------------------------ *************** package body Snames is *** 884,887 **** --- 931,946 ---- return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name; end Is_Type_Attribute_Name; + ---------------------------------- + -- Record_Convention_Identifier -- + ---------------------------------- + + procedure Record_Convention_Identifier + (Id : Name_Id; + Convention : Convention_Id) + is + begin + Convention_Identifiers.Append ((Id, Convention)); + end Record_Convention_Identifier; + end Snames; diff -Nrc3pad gcc-3.2.3/gcc/ada/snames.ads gcc-3.3/gcc/ada/snames.ads *** gcc-3.2.3/gcc/ada/snames.ads 2002-05-04 03:29:20.000000000 +0000 --- gcc-3.3/gcc/ada/snames.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.7.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package Snames is *** 42,48 **** -- the definitions of some enumeration types whose definitions are tied to -- the order of these preset names. ! -- WARNING: There is a C file, a-snames-h which duplicates some of the -- definitions in this file and must be kept properly synchronized. ------------------ --- 41,47 ---- -- the definitions of some enumeration types whose definitions are tied to -- the order of these preset names. ! -- WARNING: There is a C file, a-snames.h which duplicates some of the -- definitions in this file and must be kept properly synchronized. ------------------ *************** package Snames is *** 62,70 **** -- everything is simpler if no such duplications occur! -- First we have the one character names used to optimize the lookup ! -- process for one character identifiers (avoid the hashing in this case) ! -- There are a full 256 of these, but only the entries for lower case ! -- and upper case letters have identifiers -- The lower case letter entries are used for one character identifiers -- appearing in the source, for example in pragma Interface (C). --- 61,69 ---- -- everything is simpler if no such duplications occur! -- First we have the one character names used to optimize the lookup ! -- process for one character identifiers (to avoid the hashing in this ! -- case) There are a full 256 of these, but only the entries for lower ! -- case and upper case letters have identifiers -- The lower case letter entries are used for one character identifiers -- appearing in the source, for example in pragma Interface (C). *************** package Snames is *** 300,305 **** --- 299,308 ---- -- only in OpenVMS versions of GNAT. They are ignored in other versions -- with an appropriate warning. + -- The entries marked AAMP are AAMP specific pragmas that are recognized + -- only in GNAT for the AAMP. They are ignored in other versions with + -- appropriate warnings. + First_Pragma_Name : constant Name_Id := N + 102; -- Configuration pragmas are grouped at start *************** package Snames is *** 308,348 **** Name_Ada_95 : constant Name_Id := N + 103; -- GNAT Name_C_Pass_By_Copy : constant Name_Id := N + 104; -- GNAT Name_Component_Alignment : constant Name_Id := N + 105; -- GNAT ! Name_Discard_Names : constant Name_Id := N + 106; ! Name_Elaboration_Checks : constant Name_Id := N + 107; -- GNAT ! Name_Eliminate : constant Name_Id := N + 108; -- GNAT ! Name_Extend_System : constant Name_Id := N + 109; -- GNAT ! Name_Extensions_Allowed : constant Name_Id := N + 110; -- GNAT ! Name_External_Name_Casing : constant Name_Id := N + 111; -- GNAT ! Name_Float_Representation : constant Name_Id := N + 112; -- GNAT ! Name_Initialize_Scalars : constant Name_Id := N + 113; -- GNAT ! Name_License : constant Name_Id := N + 114; -- GNAT ! Name_Locking_Policy : constant Name_Id := N + 115; ! Name_Long_Float : constant Name_Id := N + 116; -- VMS ! Name_No_Run_Time : constant Name_Id := N + 117; -- GNAT ! Name_Normalize_Scalars : constant Name_Id := N + 118; ! Name_Polling : constant Name_Id := N + 119; -- GNAT ! Name_Propagate_Exceptions : constant Name_Id := N + 120; -- GNAT ! Name_Queuing_Policy : constant Name_Id := N + 121; ! Name_Ravenscar : constant Name_Id := N + 122; ! Name_Restricted_Run_Time : constant Name_Id := N + 123; ! Name_Restrictions : constant Name_Id := N + 124; ! Name_Reviewable : constant Name_Id := N + 125; ! Name_Source_File_Name : constant Name_Id := N + 126; -- GNAT ! Name_Style_Checks : constant Name_Id := N + 127; -- GNAT ! Name_Suppress : constant Name_Id := N + 128; ! Name_Task_Dispatching_Policy : constant Name_Id := N + 129; ! Name_Unsuppress : constant Name_Id := N + 130; -- GNAT ! Name_Use_VADS_Size : constant Name_Id := N + 131; -- GNAT ! Name_Warnings : constant Name_Id := N + 132; -- GNAT ! Name_Validity_Checks : constant Name_Id := N + 133; -- GNAT ! Last_Configuration_Pragma_Name : constant Name_Id := N + 133; -- Remaining pragma names ! Name_Abort_Defer : constant Name_Id := N + 134; -- GNAT ! Name_All_Calls_Remote : constant Name_Id := N + 135; ! Name_Annotate : constant Name_Id := N + 136; -- GNAT -- Note: AST_Entry is not in this list because its name matches the -- name of the corresponding attribute. However, it is included in the --- 311,352 ---- Name_Ada_95 : constant Name_Id := N + 103; -- GNAT Name_C_Pass_By_Copy : constant Name_Id := N + 104; -- GNAT Name_Component_Alignment : constant Name_Id := N + 105; -- GNAT ! Name_Convention_Identifier : constant Name_Id := N + 106; -- GNAT ! Name_Discard_Names : constant Name_Id := N + 107; ! Name_Elaboration_Checks : constant Name_Id := N + 108; -- GNAT ! Name_Eliminate : constant Name_Id := N + 109; -- GNAT ! Name_Extend_System : constant Name_Id := N + 110; -- GNAT ! Name_Extensions_Allowed : constant Name_Id := N + 111; -- GNAT ! Name_External_Name_Casing : constant Name_Id := N + 112; -- GNAT ! Name_Float_Representation : constant Name_Id := N + 113; -- GNAT ! Name_Initialize_Scalars : constant Name_Id := N + 114; -- GNAT ! Name_License : constant Name_Id := N + 115; -- GNAT ! Name_Locking_Policy : constant Name_Id := N + 116; ! Name_Long_Float : constant Name_Id := N + 117; -- VMS ! Name_No_Run_Time : constant Name_Id := N + 118; -- GNAT ! Name_Normalize_Scalars : constant Name_Id := N + 119; ! Name_Polling : constant Name_Id := N + 120; -- GNAT ! Name_Propagate_Exceptions : constant Name_Id := N + 121; -- GNAT ! Name_Queuing_Policy : constant Name_Id := N + 122; ! Name_Ravenscar : constant Name_Id := N + 123; ! Name_Restricted_Run_Time : constant Name_Id := N + 124; ! Name_Restrictions : constant Name_Id := N + 125; ! Name_Reviewable : constant Name_Id := N + 126; ! Name_Source_File_Name : constant Name_Id := N + 127; -- GNAT ! Name_Style_Checks : constant Name_Id := N + 128; -- GNAT ! Name_Suppress : constant Name_Id := N + 129; ! Name_Task_Dispatching_Policy : constant Name_Id := N + 130; ! Name_Unsuppress : constant Name_Id := N + 131; -- GNAT ! Name_Use_VADS_Size : constant Name_Id := N + 132; -- GNAT ! Name_Warnings : constant Name_Id := N + 133; -- GNAT ! Name_Validity_Checks : constant Name_Id := N + 134; -- GNAT ! Last_Configuration_Pragma_Name : constant Name_Id := N + 134; -- Remaining pragma names ! Name_Abort_Defer : constant Name_Id := N + 135; -- GNAT ! Name_All_Calls_Remote : constant Name_Id := N + 136; ! Name_Annotate : constant Name_Id := N + 137; -- GNAT -- Note: AST_Entry is not in this list because its name matches the -- name of the corresponding attribute. However, it is included in the *************** package Snames is *** 350,422 **** -- and Check_Pragma_Id correctly recognize and process Name_AST_Entry. -- AST_Entry is a VMS specific pragma. ! Name_Assert : constant Name_Id := N + 137; -- GNAT ! Name_Asynchronous : constant Name_Id := N + 138; ! Name_Atomic : constant Name_Id := N + 139; ! Name_Atomic_Components : constant Name_Id := N + 140; ! Name_Attach_Handler : constant Name_Id := N + 141; ! Name_Comment : constant Name_Id := N + 142; -- GNAT ! Name_Common_Object : constant Name_Id := N + 143; -- GNAT ! Name_Complex_Representation : constant Name_Id := N + 144; -- GNAT ! Name_Controlled : constant Name_Id := N + 145; ! Name_Convention : constant Name_Id := N + 146; ! Name_CPP_Class : constant Name_Id := N + 147; -- GNAT ! Name_CPP_Constructor : constant Name_Id := N + 148; -- GNAT ! Name_CPP_Virtual : constant Name_Id := N + 149; -- GNAT ! Name_CPP_Vtable : constant Name_Id := N + 150; -- GNAT ! Name_Debug : constant Name_Id := N + 151; -- GNAT ! Name_Elaborate : constant Name_Id := N + 152; -- Ada 83 ! Name_Elaborate_All : constant Name_Id := N + 153; ! Name_Elaborate_Body : constant Name_Id := N + 154; ! Name_Export : constant Name_Id := N + 155; ! Name_Export_Exception : constant Name_Id := N + 156; -- VMS ! Name_Export_Function : constant Name_Id := N + 157; -- GNAT ! Name_Export_Object : constant Name_Id := N + 158; -- GNAT ! Name_Export_Procedure : constant Name_Id := N + 159; -- GNAT ! Name_Export_Valued_Procedure : constant Name_Id := N + 160; -- GNAT ! Name_External : constant Name_Id := N + 161; -- GNAT ! Name_Finalize_Storage_Only : constant Name_Id := N + 162; -- GNAT ! Name_Ident : constant Name_Id := N + 163; -- VMS ! Name_Import : constant Name_Id := N + 164; ! Name_Import_Exception : constant Name_Id := N + 165; -- VMS ! Name_Import_Function : constant Name_Id := N + 166; -- GNAT ! Name_Import_Object : constant Name_Id := N + 167; -- GNAT ! Name_Import_Procedure : constant Name_Id := N + 168; -- GNAT ! Name_Import_Valued_Procedure : constant Name_Id := N + 169; -- GNAT ! Name_Inline : constant Name_Id := N + 170; ! Name_Inline_Always : constant Name_Id := N + 171; -- GNAT ! Name_Inline_Generic : constant Name_Id := N + 172; -- GNAT ! Name_Inspection_Point : constant Name_Id := N + 173; ! Name_Interface : constant Name_Id := N + 174; -- Ada 83 ! Name_Interface_Name : constant Name_Id := N + 175; -- GNAT ! Name_Interrupt_Handler : constant Name_Id := N + 176; ! Name_Interrupt_Priority : constant Name_Id := N + 177; ! Name_Java_Constructor : constant Name_Id := N + 178; -- GNAT ! Name_Java_Interface : constant Name_Id := N + 179; -- GNAT ! Name_Link_With : constant Name_Id := N + 180; -- GNAT ! Name_Linker_Alias : constant Name_Id := N + 181; -- GNAT ! Name_Linker_Options : constant Name_Id := N + 182; ! Name_Linker_Section : constant Name_Id := N + 183; -- GNAT ! Name_List : constant Name_Id := N + 184; ! Name_Machine_Attribute : constant Name_Id := N + 185; -- GNAT ! Name_Main : constant Name_Id := N + 186; -- GNAT ! Name_Main_Storage : constant Name_Id := N + 187; -- GNAT ! Name_Memory_Size : constant Name_Id := N + 188; -- Ada 83 ! Name_No_Return : constant Name_Id := N + 189; -- GNAT ! Name_Optimize : constant Name_Id := N + 190; ! Name_Pack : constant Name_Id := N + 191; ! Name_Page : constant Name_Id := N + 192; ! Name_Passive : constant Name_Id := N + 193; -- GNAT ! Name_Preelaborate : constant Name_Id := N + 194; ! Name_Priority : constant Name_Id := N + 195; ! Name_Psect_Object : constant Name_Id := N + 196; -- VMS ! Name_Pure : constant Name_Id := N + 197; ! Name_Pure_Function : constant Name_Id := N + 198; -- GNAT ! Name_Remote_Call_Interface : constant Name_Id := N + 199; ! Name_Remote_Types : constant Name_Id := N + 200; ! Name_Share_Generic : constant Name_Id := N + 201; -- GNAT ! Name_Shared : constant Name_Id := N + 202; -- Ada 83 ! Name_Shared_Passive : constant Name_Id := N + 203; -- Note: Storage_Size is not in this list because its name matches the -- name of the corresponding attribute. However, it is included in the --- 354,426 ---- -- and Check_Pragma_Id correctly recognize and process Name_AST_Entry. -- AST_Entry is a VMS specific pragma. ! Name_Assert : constant Name_Id := N + 138; -- GNAT ! Name_Asynchronous : constant Name_Id := N + 139; ! Name_Atomic : constant Name_Id := N + 140; ! Name_Atomic_Components : constant Name_Id := N + 141; ! Name_Attach_Handler : constant Name_Id := N + 142; ! Name_Comment : constant Name_Id := N + 143; -- GNAT ! Name_Common_Object : constant Name_Id := N + 144; -- GNAT ! Name_Complex_Representation : constant Name_Id := N + 145; -- GNAT ! Name_Controlled : constant Name_Id := N + 146; ! Name_Convention : constant Name_Id := N + 147; ! Name_CPP_Class : constant Name_Id := N + 148; -- GNAT ! Name_CPP_Constructor : constant Name_Id := N + 149; -- GNAT ! Name_CPP_Virtual : constant Name_Id := N + 150; -- GNAT ! Name_CPP_Vtable : constant Name_Id := N + 151; -- GNAT ! Name_Debug : constant Name_Id := N + 152; -- GNAT ! Name_Elaborate : constant Name_Id := N + 153; -- Ada 83 ! Name_Elaborate_All : constant Name_Id := N + 154; ! Name_Elaborate_Body : constant Name_Id := N + 155; ! Name_Export : constant Name_Id := N + 156; ! Name_Export_Exception : constant Name_Id := N + 157; -- VMS ! Name_Export_Function : constant Name_Id := N + 158; -- GNAT ! Name_Export_Object : constant Name_Id := N + 159; -- GNAT ! Name_Export_Procedure : constant Name_Id := N + 160; -- GNAT ! Name_Export_Valued_Procedure : constant Name_Id := N + 161; -- GNAT ! Name_External : constant Name_Id := N + 162; -- GNAT ! Name_Finalize_Storage_Only : constant Name_Id := N + 163; -- GNAT ! Name_Ident : constant Name_Id := N + 164; -- VMS ! Name_Import : constant Name_Id := N + 165; ! Name_Import_Exception : constant Name_Id := N + 166; -- VMS ! Name_Import_Function : constant Name_Id := N + 167; -- GNAT ! Name_Import_Object : constant Name_Id := N + 168; -- GNAT ! Name_Import_Procedure : constant Name_Id := N + 169; -- GNAT ! Name_Import_Valued_Procedure : constant Name_Id := N + 170; -- GNAT ! Name_Inline : constant Name_Id := N + 171; ! Name_Inline_Always : constant Name_Id := N + 172; -- GNAT ! Name_Inline_Generic : constant Name_Id := N + 173; -- GNAT ! Name_Inspection_Point : constant Name_Id := N + 174; ! Name_Interface : constant Name_Id := N + 175; -- Ada 83 ! Name_Interface_Name : constant Name_Id := N + 176; -- GNAT ! Name_Interrupt_Handler : constant Name_Id := N + 177; ! Name_Interrupt_Priority : constant Name_Id := N + 178; ! Name_Java_Constructor : constant Name_Id := N + 179; -- GNAT ! Name_Java_Interface : constant Name_Id := N + 180; -- GNAT ! Name_Link_With : constant Name_Id := N + 181; -- GNAT ! Name_Linker_Alias : constant Name_Id := N + 182; -- GNAT ! Name_Linker_Options : constant Name_Id := N + 183; ! Name_Linker_Section : constant Name_Id := N + 184; -- GNAT ! Name_List : constant Name_Id := N + 185; ! Name_Machine_Attribute : constant Name_Id := N + 186; -- GNAT ! Name_Main : constant Name_Id := N + 187; -- GNAT ! Name_Main_Storage : constant Name_Id := N + 188; -- GNAT ! Name_Memory_Size : constant Name_Id := N + 189; -- Ada 83 ! Name_No_Return : constant Name_Id := N + 190; -- GNAT ! Name_Optimize : constant Name_Id := N + 191; ! Name_Pack : constant Name_Id := N + 192; ! Name_Page : constant Name_Id := N + 193; ! Name_Passive : constant Name_Id := N + 194; -- GNAT ! Name_Preelaborate : constant Name_Id := N + 195; ! Name_Priority : constant Name_Id := N + 196; ! Name_Psect_Object : constant Name_Id := N + 197; -- VMS ! Name_Pure : constant Name_Id := N + 198; ! Name_Pure_Function : constant Name_Id := N + 199; -- GNAT ! Name_Remote_Call_Interface : constant Name_Id := N + 200; ! Name_Remote_Types : constant Name_Id := N + 201; ! Name_Share_Generic : constant Name_Id := N + 202; -- GNAT ! Name_Shared : constant Name_Id := N + 203; -- Ada 83 ! Name_Shared_Passive : constant Name_Id := N + 204; -- Note: Storage_Size is not in this list because its name matches the -- name of the corresponding attribute. However, it is included in the *************** package Snames is *** 426,450 **** -- Note: Storage_Unit is also omitted from the list because of a clash -- with an attribute name, and is treated similarly. ! Name_Source_Reference : constant Name_Id := N + 204; -- GNAT ! Name_Stream_Convert : constant Name_Id := N + 205; -- GNAT ! Name_Subtitle : constant Name_Id := N + 206; -- GNAT ! Name_Suppress_All : constant Name_Id := N + 207; -- GNAT ! Name_Suppress_Debug_Info : constant Name_Id := N + 208; -- GNAT ! Name_Suppress_Initialization : constant Name_Id := N + 209; -- GNAT ! Name_System_Name : constant Name_Id := N + 210; -- Ada 83 ! Name_Task_Info : constant Name_Id := N + 211; -- GNAT ! Name_Task_Name : constant Name_Id := N + 212; -- GNAT ! Name_Task_Storage : constant Name_Id := N + 213; -- VMS ! Name_Time_Slice : constant Name_Id := N + 214; -- GNAT ! Name_Title : constant Name_Id := N + 215; -- GNAT ! Name_Unchecked_Union : constant Name_Id := N + 216; -- GNAT ! Name_Unimplemented_Unit : constant Name_Id := N + 217; -- GNAT ! Name_Unreserve_All_Interrupts : constant Name_Id := N + 218; -- GNAT ! Name_Volatile : constant Name_Id := N + 219; ! Name_Volatile_Components : constant Name_Id := N + 220; ! Name_Weak_External : constant Name_Id := N + 221; -- GNAT ! Last_Pragma_Name : constant Name_Id := N + 221; -- Language convention names for pragma Convention/Export/Import/Interface -- Note that Name_C is not included in this list, since it was already --- 430,456 ---- -- Note: Storage_Unit is also omitted from the list because of a clash -- with an attribute name, and is treated similarly. ! Name_Source_Reference : constant Name_Id := N + 205; -- GNAT ! Name_Stream_Convert : constant Name_Id := N + 206; -- GNAT ! Name_Subtitle : constant Name_Id := N + 207; -- GNAT ! Name_Suppress_All : constant Name_Id := N + 208; -- GNAT ! Name_Suppress_Debug_Info : constant Name_Id := N + 209; -- GNAT ! Name_Suppress_Initialization : constant Name_Id := N + 210; -- GNAT ! Name_System_Name : constant Name_Id := N + 211; -- Ada 83 ! Name_Task_Info : constant Name_Id := N + 212; -- GNAT ! Name_Task_Name : constant Name_Id := N + 213; -- GNAT ! Name_Task_Storage : constant Name_Id := N + 214; -- VMS ! Name_Time_Slice : constant Name_Id := N + 215; -- GNAT ! Name_Title : constant Name_Id := N + 216; -- GNAT ! Name_Unchecked_Union : constant Name_Id := N + 217; -- GNAT ! Name_Unimplemented_Unit : constant Name_Id := N + 218; -- GNAT ! Name_Universal_Data : constant Name_Id := N + 219; -- AAMP ! Name_Unreferenced : constant Name_Id := N + 220; -- GNAT ! Name_Unreserve_All_Interrupts : constant Name_Id := N + 221; -- GNAT ! Name_Volatile : constant Name_Id := N + 222; ! Name_Volatile_Components : constant Name_Id := N + 223; ! Name_Weak_External : constant Name_Id := N + 224; -- GNAT ! Last_Pragma_Name : constant Name_Id := N + 224; -- Language convention names for pragma Convention/Export/Import/Interface -- Note that Name_C is not included in this list, since it was already *************** package Snames is *** 455,540 **** -- Entry and Protected, this is because these conventions cannot be -- specified by a pragma. ! -- Note: The convention name C_Pass_By_Copy is treated as entirely ! -- equivalent to C except when it is specified on a record type. In ! -- this case the convention of the record type is set to C, but in ! -- addition the flag C_Pass_By_Copy is set on the record type. ! ! First_Convention_Name : constant Name_Id := N + 222; ! Name_Ada : constant Name_Id := N + 222; ! Name_Asm : constant Name_Id := N + 223; ! Name_Assembler : constant Name_Id := N + 224; ! Name_COBOL : constant Name_Id := N + 225; ! Name_CPP : constant Name_Id := N + 226; ! Name_DLL : constant Name_Id := N + 227; ! Name_Fortran : constant Name_Id := N + 228; ! Name_Intrinsic : constant Name_Id := N + 229; ! Name_Java : constant Name_Id := N + 230; ! Name_Stdcall : constant Name_Id := N + 231; ! Name_Stubbed : constant Name_Id := N + 232; ! Name_Win32 : constant Name_Id := N + 233; Last_Convention_Name : constant Name_Id := N + 233; -- Other special names used in processing pragma arguments ! Name_As_Is : constant Name_Id := N + 234; ! Name_Body_File_Name : constant Name_Id := N + 235; ! Name_Casing : constant Name_Id := N + 236; ! Name_Code : constant Name_Id := N + 237; ! Name_Component : constant Name_Id := N + 238; ! Name_Component_Size_4 : constant Name_Id := N + 239; ! Name_Copy : constant Name_Id := N + 240; ! Name_D_Float : constant Name_Id := N + 241; ! Name_Descriptor : constant Name_Id := N + 242; ! Name_Default : constant Name_Id := N + 243; ! Name_Dot_Replacement : constant Name_Id := N + 244; ! Name_Dynamic : constant Name_Id := N + 245; ! Name_Entity : constant Name_Id := N + 246; ! Name_External_Name : constant Name_Id := N + 247; ! Name_First_Optional_Parameter : constant Name_Id := N + 248; ! Name_Form : constant Name_Id := N + 249; ! Name_G_Float : constant Name_Id := N + 250; ! Name_Gcc : constant Name_Id := N + 251; ! Name_Gnat : constant Name_Id := N + 252; ! Name_GPL : constant Name_Id := N + 253; ! Name_IEEE_Float : constant Name_Id := N + 254; ! Name_Internal : constant Name_Id := N + 255; ! Name_Link_Name : constant Name_Id := N + 256; ! Name_Lowercase : constant Name_Id := N + 257; ! Name_Max_Size : constant Name_Id := N + 258; ! Name_Mechanism : constant Name_Id := N + 259; ! Name_Mixedcase : constant Name_Id := N + 260; ! Name_Modified_GPL : constant Name_Id := N + 261; ! Name_Name : constant Name_Id := N + 262; ! Name_NCA : constant Name_Id := N + 263; ! Name_No : constant Name_Id := N + 264; ! Name_On : constant Name_Id := N + 265; ! Name_Parameter_Types : constant Name_Id := N + 266; ! Name_Reference : constant Name_Id := N + 267; ! Name_Restricted : constant Name_Id := N + 268; ! Name_Result_Mechanism : constant Name_Id := N + 269; ! Name_Result_Type : constant Name_Id := N + 270; ! Name_SB : constant Name_Id := N + 271; ! Name_Section : constant Name_Id := N + 272; ! Name_Semaphore : constant Name_Id := N + 273; ! Name_Spec_File_Name : constant Name_Id := N + 274; ! Name_Static : constant Name_Id := N + 275; ! Name_Stack_Size : constant Name_Id := N + 276; ! Name_Subunit_File_Name : constant Name_Id := N + 277; ! Name_Task_Stack_Size_Default : constant Name_Id := N + 278; ! Name_Task_Type : constant Name_Id := N + 279; ! Name_Time_Slicing_Enabled : constant Name_Id := N + 280; ! Name_Top_Guard : constant Name_Id := N + 281; ! Name_UBA : constant Name_Id := N + 282; ! Name_UBS : constant Name_Id := N + 283; ! Name_UBSB : constant Name_Id := N + 284; ! Name_Unit_Name : constant Name_Id := N + 285; ! Name_Unknown : constant Name_Id := N + 286; ! Name_Unrestricted : constant Name_Id := N + 287; ! Name_Uppercase : constant Name_Id := N + 288; ! Name_VAX_Float : constant Name_Id := N + 289; ! Name_VMS : constant Name_Id := N + 290; ! Name_Working_Storage : constant Name_Id := N + 291; -- Names of recognized attributes. The entries with the comment "Ada 83" -- are attributes that are defined in Ada 83, but not in Ada 95. These --- 461,553 ---- -- Entry and Protected, this is because these conventions cannot be -- specified by a pragma. ! First_Convention_Name : constant Name_Id := N + 225; ! Name_Ada : constant Name_Id := N + 225; ! Name_Assembler : constant Name_Id := N + 226; ! Name_COBOL : constant Name_Id := N + 227; ! Name_CPP : constant Name_Id := N + 228; ! Name_Fortran : constant Name_Id := N + 229; ! Name_Intrinsic : constant Name_Id := N + 230; ! Name_Java : constant Name_Id := N + 231; ! Name_Stdcall : constant Name_Id := N + 232; ! Name_Stubbed : constant Name_Id := N + 233; Last_Convention_Name : constant Name_Id := N + 233; + -- The following names are preset as synonyms for Assembler + + Name_Asm : constant Name_Id := N + 234; + Name_Assembly : constant Name_Id := N + 235; + + -- The following names are preset as synonyms for C + + Name_Default : constant Name_Id := N + 236; + -- Name_Exernal (previously defined as pragma) + + -- The following names are present as synonyms for Stdcall + + Name_DLL : constant Name_Id := N + 237; + Name_Win32 : constant Name_Id := N + 238; + -- Other special names used in processing pragma arguments ! Name_As_Is : constant Name_Id := N + 239; ! Name_Body_File_Name : constant Name_Id := N + 240; ! Name_Casing : constant Name_Id := N + 241; ! Name_Code : constant Name_Id := N + 242; ! Name_Component : constant Name_Id := N + 243; ! Name_Component_Size_4 : constant Name_Id := N + 244; ! Name_Copy : constant Name_Id := N + 245; ! Name_D_Float : constant Name_Id := N + 246; ! Name_Descriptor : constant Name_Id := N + 247; ! Name_Dot_Replacement : constant Name_Id := N + 248; ! Name_Dynamic : constant Name_Id := N + 249; ! Name_Entity : constant Name_Id := N + 250; ! Name_External_Name : constant Name_Id := N + 251; ! Name_First_Optional_Parameter : constant Name_Id := N + 252; ! Name_Form : constant Name_Id := N + 253; ! Name_G_Float : constant Name_Id := N + 254; ! Name_Gcc : constant Name_Id := N + 255; ! Name_Gnat : constant Name_Id := N + 256; ! Name_GPL : constant Name_Id := N + 257; ! Name_IEEE_Float : constant Name_Id := N + 258; ! Name_Homonym_Number : constant Name_Id := N + 259; ! Name_Internal : constant Name_Id := N + 260; ! Name_Link_Name : constant Name_Id := N + 261; ! Name_Lowercase : constant Name_Id := N + 262; ! Name_Max_Size : constant Name_Id := N + 263; ! Name_Mechanism : constant Name_Id := N + 264; ! Name_Mixedcase : constant Name_Id := N + 265; ! Name_Modified_GPL : constant Name_Id := N + 266; ! Name_Name : constant Name_Id := N + 267; ! Name_NCA : constant Name_Id := N + 268; ! Name_No : constant Name_Id := N + 269; ! Name_On : constant Name_Id := N + 270; ! Name_Parameter_Types : constant Name_Id := N + 271; ! Name_Reference : constant Name_Id := N + 272; ! Name_Restricted : constant Name_Id := N + 273; ! Name_Result_Mechanism : constant Name_Id := N + 274; ! Name_Result_Type : constant Name_Id := N + 275; ! Name_SB : constant Name_Id := N + 276; ! Name_Section : constant Name_Id := N + 277; ! Name_Semaphore : constant Name_Id := N + 278; ! Name_Spec_File_Name : constant Name_Id := N + 279; ! Name_Static : constant Name_Id := N + 280; ! Name_Stack_Size : constant Name_Id := N + 281; ! Name_Subunit_File_Name : constant Name_Id := N + 282; ! Name_Task_Stack_Size_Default : constant Name_Id := N + 283; ! Name_Task_Type : constant Name_Id := N + 284; ! Name_Time_Slicing_Enabled : constant Name_Id := N + 285; ! Name_Top_Guard : constant Name_Id := N + 286; ! Name_UBA : constant Name_Id := N + 287; ! Name_UBS : constant Name_Id := N + 288; ! Name_UBSB : constant Name_Id := N + 289; ! Name_Unit_Name : constant Name_Id := N + 290; ! Name_Unknown : constant Name_Id := N + 291; ! Name_Unrestricted : constant Name_Id := N + 292; ! Name_Uppercase : constant Name_Id := N + 293; ! Name_VAX_Float : constant Name_Id := N + 294; ! Name_VMS : constant Name_Id := N + 295; ! Name_Working_Storage : constant Name_Id := N + 296; -- Names of recognized attributes. The entries with the comment "Ada 83" -- are attributes that are defined in Ada 83, but not in Ada 95. These *************** package Snames is *** 548,705 **** -- The entries marked VMS are recognized only in OpenVMS implementations -- of GNAT, and are treated as illegal in all other contexts. ! First_Attribute_Name : constant Name_Id := N + 292; ! Name_Abort_Signal : constant Name_Id := N + 292; -- GNAT ! Name_Access : constant Name_Id := N + 293; ! Name_Address : constant Name_Id := N + 294; ! Name_Address_Size : constant Name_Id := N + 295; -- GNAT ! Name_Aft : constant Name_Id := N + 296; ! Name_Alignment : constant Name_Id := N + 297; ! Name_Asm_Input : constant Name_Id := N + 298; -- GNAT ! Name_Asm_Output : constant Name_Id := N + 299; -- GNAT ! Name_AST_Entry : constant Name_Id := N + 300; -- VMS ! Name_Bit : constant Name_Id := N + 301; -- GNAT ! Name_Bit_Order : constant Name_Id := N + 302; ! Name_Bit_Position : constant Name_Id := N + 303; -- GNAT ! Name_Body_Version : constant Name_Id := N + 304; ! Name_Callable : constant Name_Id := N + 305; ! Name_Caller : constant Name_Id := N + 306; ! Name_Code_Address : constant Name_Id := N + 307; -- GNAT ! Name_Component_Size : constant Name_Id := N + 308; ! Name_Compose : constant Name_Id := N + 309; ! Name_Constrained : constant Name_Id := N + 310; ! Name_Count : constant Name_Id := N + 311; ! Name_Default_Bit_Order : constant Name_Id := N + 312; -- GNAT ! Name_Definite : constant Name_Id := N + 313; ! Name_Delta : constant Name_Id := N + 314; ! Name_Denorm : constant Name_Id := N + 315; ! Name_Digits : constant Name_Id := N + 316; ! Name_Elaborated : constant Name_Id := N + 317; -- GNAT ! Name_Emax : constant Name_Id := N + 318; -- Ada 83 ! Name_Enum_Rep : constant Name_Id := N + 319; -- GNAT ! Name_Epsilon : constant Name_Id := N + 320; -- Ada 83 ! Name_Exponent : constant Name_Id := N + 321; ! Name_External_Tag : constant Name_Id := N + 322; ! Name_First : constant Name_Id := N + 323; ! Name_First_Bit : constant Name_Id := N + 324; ! Name_Fixed_Value : constant Name_Id := N + 325; -- GNAT ! Name_Fore : constant Name_Id := N + 326; ! Name_Has_Discriminants : constant Name_Id := N + 327; -- GNAT ! Name_Identity : constant Name_Id := N + 328; ! Name_Img : constant Name_Id := N + 329; -- GNAT ! Name_Integer_Value : constant Name_Id := N + 330; -- GNAT ! Name_Large : constant Name_Id := N + 331; -- Ada 83 ! Name_Last : constant Name_Id := N + 332; ! Name_Last_Bit : constant Name_Id := N + 333; ! Name_Leading_Part : constant Name_Id := N + 334; ! Name_Length : constant Name_Id := N + 335; ! Name_Machine_Emax : constant Name_Id := N + 336; ! Name_Machine_Emin : constant Name_Id := N + 337; ! Name_Machine_Mantissa : constant Name_Id := N + 338; ! Name_Machine_Overflows : constant Name_Id := N + 339; ! Name_Machine_Radix : constant Name_Id := N + 340; ! Name_Machine_Rounds : constant Name_Id := N + 341; ! Name_Machine_Size : constant Name_Id := N + 342; -- GNAT ! Name_Mantissa : constant Name_Id := N + 343; -- Ada 83 ! Name_Max_Interrupt_Priority : constant Name_Id := N + 344; -- GNAT ! Name_Max_Priority : constant Name_Id := N + 345; -- GNAT ! Name_Max_Size_In_Storage_Elements : constant Name_Id := N + 346; ! Name_Maximum_Alignment : constant Name_Id := N + 347; -- GNAT ! Name_Mechanism_Code : constant Name_Id := N + 348; -- GNAT ! Name_Model_Emin : constant Name_Id := N + 349; ! Name_Model_Epsilon : constant Name_Id := N + 350; ! Name_Model_Mantissa : constant Name_Id := N + 351; ! Name_Model_Small : constant Name_Id := N + 352; ! Name_Modulus : constant Name_Id := N + 353; ! Name_Null_Parameter : constant Name_Id := N + 354; -- GNAT ! Name_Object_Size : constant Name_Id := N + 355; -- GNAT ! Name_Partition_ID : constant Name_Id := N + 356; ! Name_Passed_By_Reference : constant Name_Id := N + 357; -- GNAT ! Name_Pos : constant Name_Id := N + 358; ! Name_Position : constant Name_Id := N + 359; ! Name_Range : constant Name_Id := N + 360; ! Name_Range_Length : constant Name_Id := N + 361; -- GNAT ! Name_Round : constant Name_Id := N + 362; ! Name_Safe_Emax : constant Name_Id := N + 363; -- Ada 83 ! Name_Safe_First : constant Name_Id := N + 364; ! Name_Safe_Large : constant Name_Id := N + 365; -- Ada 83 ! Name_Safe_Last : constant Name_Id := N + 366; ! Name_Safe_Small : constant Name_Id := N + 367; -- Ada 83 ! Name_Scale : constant Name_Id := N + 368; ! Name_Scaling : constant Name_Id := N + 369; ! Name_Signed_Zeros : constant Name_Id := N + 370; ! Name_Size : constant Name_Id := N + 371; ! Name_Small : constant Name_Id := N + 372; ! Name_Storage_Size : constant Name_Id := N + 373; ! Name_Storage_Unit : constant Name_Id := N + 374; -- GNAT ! Name_Tag : constant Name_Id := N + 375; ! Name_Terminated : constant Name_Id := N + 376; ! Name_Tick : constant Name_Id := N + 377; -- GNAT ! Name_To_Address : constant Name_Id := N + 378; -- GNAT ! Name_Type_Class : constant Name_Id := N + 379; -- GNAT ! Name_UET_Address : constant Name_Id := N + 380; -- GNAT ! Name_Unbiased_Rounding : constant Name_Id := N + 381; ! Name_Unchecked_Access : constant Name_Id := N + 382; ! Name_Universal_Literal_String : constant Name_Id := N + 383; -- GNAT ! Name_Unrestricted_Access : constant Name_Id := N + 384; -- GNAT ! Name_VADS_Size : constant Name_Id := N + 385; -- GNAT ! Name_Val : constant Name_Id := N + 386; ! Name_Valid : constant Name_Id := N + 387; ! Name_Value_Size : constant Name_Id := N + 388; -- GNAT ! Name_Version : constant Name_Id := N + 389; ! Name_Wchar_T_Size : constant Name_Id := N + 390; -- GNAT ! Name_Wide_Width : constant Name_Id := N + 391; ! Name_Width : constant Name_Id := N + 392; ! Name_Word_Size : constant Name_Id := N + 393; -- GNAT -- Attributes that designate attributes returning renamable functions, -- i.e. functions that return other than a universal value. ! First_Renamable_Function_Attribute : constant Name_Id := N + 394; ! Name_Adjacent : constant Name_Id := N + 394; ! Name_Ceiling : constant Name_Id := N + 395; ! Name_Copy_Sign : constant Name_Id := N + 396; ! Name_Floor : constant Name_Id := N + 397; ! Name_Fraction : constant Name_Id := N + 398; ! Name_Image : constant Name_Id := N + 399; ! Name_Input : constant Name_Id := N + 400; ! Name_Machine : constant Name_Id := N + 401; ! Name_Max : constant Name_Id := N + 402; ! Name_Min : constant Name_Id := N + 403; ! Name_Model : constant Name_Id := N + 404; ! Name_Pred : constant Name_Id := N + 405; ! Name_Remainder : constant Name_Id := N + 406; ! Name_Rounding : constant Name_Id := N + 407; ! Name_Succ : constant Name_Id := N + 408; ! Name_Truncation : constant Name_Id := N + 409; ! Name_Value : constant Name_Id := N + 410; ! Name_Wide_Image : constant Name_Id := N + 411; ! Name_Wide_Value : constant Name_Id := N + 412; ! Last_Renamable_Function_Attribute : constant Name_Id := N + 412; -- Attributes that designate procedures ! First_Procedure_Attribute : constant Name_Id := N + 413; ! Name_Output : constant Name_Id := N + 413; ! Name_Read : constant Name_Id := N + 414; ! Name_Write : constant Name_Id := N + 415; ! Last_Procedure_Attribute : constant Name_Id := N + 415; -- Remaining attributes are ones that return entities ! First_Entity_Attribute_Name : constant Name_Id := N + 416; ! Name_Elab_Body : constant Name_Id := N + 416; -- GNAT ! Name_Elab_Spec : constant Name_Id := N + 417; -- GNAT ! Name_Storage_Pool : constant Name_Id := N + 418; -- These attributes are the ones that return types ! First_Type_Attribute_Name : constant Name_Id := N + 419; ! Name_Base : constant Name_Id := N + 419; ! Name_Class : constant Name_Id := N + 420; ! Last_Type_Attribute_Name : constant Name_Id := N + 420; ! Last_Entity_Attribute_Name : constant Name_Id := N + 420; ! Last_Attribute_Name : constant Name_Id := N + 420; -- Names of recognized locking policy identifiers --- 561,715 ---- -- The entries marked VMS are recognized only in OpenVMS implementations -- of GNAT, and are treated as illegal in all other contexts. ! First_Attribute_Name : constant Name_Id := N + 297; ! Name_Abort_Signal : constant Name_Id := N + 297; -- GNAT ! Name_Access : constant Name_Id := N + 298; ! Name_Address : constant Name_Id := N + 299; ! Name_Address_Size : constant Name_Id := N + 300; -- GNAT ! Name_Aft : constant Name_Id := N + 301; ! Name_Alignment : constant Name_Id := N + 302; ! Name_Asm_Input : constant Name_Id := N + 303; -- GNAT ! Name_Asm_Output : constant Name_Id := N + 304; -- GNAT ! Name_AST_Entry : constant Name_Id := N + 305; -- VMS ! Name_Bit : constant Name_Id := N + 306; -- GNAT ! Name_Bit_Order : constant Name_Id := N + 307; ! Name_Bit_Position : constant Name_Id := N + 308; -- GNAT ! Name_Body_Version : constant Name_Id := N + 309; ! Name_Callable : constant Name_Id := N + 310; ! Name_Caller : constant Name_Id := N + 311; ! Name_Code_Address : constant Name_Id := N + 312; -- GNAT ! Name_Component_Size : constant Name_Id := N + 313; ! Name_Compose : constant Name_Id := N + 314; ! Name_Constrained : constant Name_Id := N + 315; ! Name_Count : constant Name_Id := N + 316; ! Name_Default_Bit_Order : constant Name_Id := N + 317; -- GNAT ! Name_Definite : constant Name_Id := N + 318; ! Name_Delta : constant Name_Id := N + 319; ! Name_Denorm : constant Name_Id := N + 320; ! Name_Digits : constant Name_Id := N + 321; ! Name_Elaborated : constant Name_Id := N + 322; -- GNAT ! Name_Emax : constant Name_Id := N + 323; -- Ada 83 ! Name_Enum_Rep : constant Name_Id := N + 324; -- GNAT ! Name_Epsilon : constant Name_Id := N + 325; -- Ada 83 ! Name_Exponent : constant Name_Id := N + 326; ! Name_External_Tag : constant Name_Id := N + 327; ! Name_First : constant Name_Id := N + 328; ! Name_First_Bit : constant Name_Id := N + 329; ! Name_Fixed_Value : constant Name_Id := N + 330; -- GNAT ! Name_Fore : constant Name_Id := N + 331; ! Name_Has_Discriminants : constant Name_Id := N + 332; -- GNAT ! Name_Identity : constant Name_Id := N + 333; ! Name_Img : constant Name_Id := N + 334; -- GNAT ! Name_Integer_Value : constant Name_Id := N + 335; -- GNAT ! Name_Large : constant Name_Id := N + 336; -- Ada 83 ! Name_Last : constant Name_Id := N + 337; ! Name_Last_Bit : constant Name_Id := N + 338; ! Name_Leading_Part : constant Name_Id := N + 339; ! Name_Length : constant Name_Id := N + 340; ! Name_Machine_Emax : constant Name_Id := N + 341; ! Name_Machine_Emin : constant Name_Id := N + 342; ! Name_Machine_Mantissa : constant Name_Id := N + 343; ! Name_Machine_Overflows : constant Name_Id := N + 344; ! Name_Machine_Radix : constant Name_Id := N + 345; ! Name_Machine_Rounds : constant Name_Id := N + 346; ! Name_Machine_Size : constant Name_Id := N + 347; -- GNAT ! Name_Mantissa : constant Name_Id := N + 348; -- Ada 83 ! Name_Max_Size_In_Storage_Elements : constant Name_Id := N + 349; ! Name_Maximum_Alignment : constant Name_Id := N + 350; -- GNAT ! Name_Mechanism_Code : constant Name_Id := N + 351; -- GNAT ! Name_Model_Emin : constant Name_Id := N + 352; ! Name_Model_Epsilon : constant Name_Id := N + 353; ! Name_Model_Mantissa : constant Name_Id := N + 354; ! Name_Model_Small : constant Name_Id := N + 355; ! Name_Modulus : constant Name_Id := N + 356; ! Name_Null_Parameter : constant Name_Id := N + 357; -- GNAT ! Name_Object_Size : constant Name_Id := N + 358; -- GNAT ! Name_Partition_ID : constant Name_Id := N + 359; ! Name_Passed_By_Reference : constant Name_Id := N + 360; -- GNAT ! Name_Pos : constant Name_Id := N + 361; ! Name_Position : constant Name_Id := N + 362; ! Name_Range : constant Name_Id := N + 363; ! Name_Range_Length : constant Name_Id := N + 364; -- GNAT ! Name_Round : constant Name_Id := N + 365; ! Name_Safe_Emax : constant Name_Id := N + 366; -- Ada 83 ! Name_Safe_First : constant Name_Id := N + 367; ! Name_Safe_Large : constant Name_Id := N + 368; -- Ada 83 ! Name_Safe_Last : constant Name_Id := N + 369; ! Name_Safe_Small : constant Name_Id := N + 370; -- Ada 83 ! Name_Scale : constant Name_Id := N + 371; ! Name_Scaling : constant Name_Id := N + 372; ! Name_Signed_Zeros : constant Name_Id := N + 373; ! Name_Size : constant Name_Id := N + 374; ! Name_Small : constant Name_Id := N + 375; ! Name_Storage_Size : constant Name_Id := N + 376; ! Name_Storage_Unit : constant Name_Id := N + 377; -- GNAT ! Name_Tag : constant Name_Id := N + 378; ! Name_Terminated : constant Name_Id := N + 379; ! Name_To_Address : constant Name_Id := N + 380; -- GNAT ! Name_Type_Class : constant Name_Id := N + 381; -- GNAT ! Name_UET_Address : constant Name_Id := N + 382; -- GNAT ! Name_Unbiased_Rounding : constant Name_Id := N + 383; ! Name_Unchecked_Access : constant Name_Id := N + 384; ! Name_Universal_Literal_String : constant Name_Id := N + 385; -- GNAT ! Name_Unrestricted_Access : constant Name_Id := N + 386; -- GNAT ! Name_VADS_Size : constant Name_Id := N + 387; -- GNAT ! Name_Val : constant Name_Id := N + 388; ! Name_Valid : constant Name_Id := N + 389; ! Name_Value_Size : constant Name_Id := N + 390; -- GNAT ! Name_Version : constant Name_Id := N + 391; ! Name_Wchar_T_Size : constant Name_Id := N + 392; -- GNAT ! Name_Wide_Width : constant Name_Id := N + 393; ! Name_Width : constant Name_Id := N + 394; ! Name_Word_Size : constant Name_Id := N + 395; -- GNAT -- Attributes that designate attributes returning renamable functions, -- i.e. functions that return other than a universal value. ! First_Renamable_Function_Attribute : constant Name_Id := N + 396; ! Name_Adjacent : constant Name_Id := N + 396; ! Name_Ceiling : constant Name_Id := N + 397; ! Name_Copy_Sign : constant Name_Id := N + 398; ! Name_Floor : constant Name_Id := N + 399; ! Name_Fraction : constant Name_Id := N + 400; ! Name_Image : constant Name_Id := N + 401; ! Name_Input : constant Name_Id := N + 402; ! Name_Machine : constant Name_Id := N + 403; ! Name_Max : constant Name_Id := N + 404; ! Name_Min : constant Name_Id := N + 405; ! Name_Model : constant Name_Id := N + 406; ! Name_Pred : constant Name_Id := N + 407; ! Name_Remainder : constant Name_Id := N + 408; ! Name_Rounding : constant Name_Id := N + 409; ! Name_Succ : constant Name_Id := N + 410; ! Name_Truncation : constant Name_Id := N + 411; ! Name_Value : constant Name_Id := N + 412; ! Name_Wide_Image : constant Name_Id := N + 413; ! Name_Wide_Value : constant Name_Id := N + 414; ! Last_Renamable_Function_Attribute : constant Name_Id := N + 414; -- Attributes that designate procedures ! First_Procedure_Attribute : constant Name_Id := N + 415; ! Name_Output : constant Name_Id := N + 415; ! Name_Read : constant Name_Id := N + 416; ! Name_Write : constant Name_Id := N + 417; ! Last_Procedure_Attribute : constant Name_Id := N + 417; -- Remaining attributes are ones that return entities ! First_Entity_Attribute_Name : constant Name_Id := N + 418; ! Name_Elab_Body : constant Name_Id := N + 418; -- GNAT ! Name_Elab_Spec : constant Name_Id := N + 419; -- GNAT ! Name_Storage_Pool : constant Name_Id := N + 420; -- These attributes are the ones that return types ! First_Type_Attribute_Name : constant Name_Id := N + 421; ! Name_Base : constant Name_Id := N + 421; ! Name_Class : constant Name_Id := N + 422; ! Last_Type_Attribute_Name : constant Name_Id := N + 422; ! Last_Entity_Attribute_Name : constant Name_Id := N + 422; ! Last_Attribute_Name : constant Name_Id := N + 422; -- Names of recognized locking policy identifiers *************** package Snames is *** 707,716 **** -- name (e.g. C for Ceiling_Locking). If new policy names are added, -- the first character must be distinct. ! First_Locking_Policy_Name : constant Name_Id := N + 421; ! Name_Ceiling_Locking : constant Name_Id := N + 421; ! Name_Inheritance_Locking : constant Name_Id := N + 422; ! Last_Locking_Policy_Name : constant Name_Id := N + 422; -- Names of recognized queuing policy identifiers. --- 717,726 ---- -- name (e.g. C for Ceiling_Locking). If new policy names are added, -- the first character must be distinct. ! First_Locking_Policy_Name : constant Name_Id := N + 423; ! Name_Ceiling_Locking : constant Name_Id := N + 423; ! Name_Inheritance_Locking : constant Name_Id := N + 424; ! Last_Locking_Policy_Name : constant Name_Id := N + 424; -- Names of recognized queuing policy identifiers. *************** package Snames is *** 718,727 **** -- name (e.g. F for FIFO_Queuing). If new policy names are added, -- the first character must be distinct. ! First_Queuing_Policy_Name : constant Name_Id := N + 423; ! Name_FIFO_Queuing : constant Name_Id := N + 423; ! Name_Priority_Queuing : constant Name_Id := N + 424; ! Last_Queuing_Policy_Name : constant Name_Id := N + 424; -- Names of recognized task dispatching policy identifiers --- 728,737 ---- -- name (e.g. F for FIFO_Queuing). If new policy names are added, -- the first character must be distinct. ! First_Queuing_Policy_Name : constant Name_Id := N + 425; ! Name_FIFO_Queuing : constant Name_Id := N + 425; ! Name_Priority_Queuing : constant Name_Id := N + 426; ! Last_Queuing_Policy_Name : constant Name_Id := N + 426; -- Names of recognized task dispatching policy identifiers *************** package Snames is *** 729,900 **** -- name (e.g. F for FIFO_WIthinn_Priorities). If new policy names -- are added, the first character must be distinct. ! First_Task_Dispatching_Policy_Name : constant Name_Id := N + 425; ! Name_Fifo_Within_Priorities : constant Name_Id := N + 425; ! Last_Task_Dispatching_Policy_Name : constant Name_Id := N + 425; -- Names of recognized checks for pragma Suppress ! First_Check_Name : constant Name_Id := N + 426; ! Name_Access_Check : constant Name_Id := N + 426; ! Name_Accessibility_Check : constant Name_Id := N + 427; ! Name_Discriminant_Check : constant Name_Id := N + 428; ! Name_Division_Check : constant Name_Id := N + 429; ! Name_Elaboration_Check : constant Name_Id := N + 430; ! Name_Index_Check : constant Name_Id := N + 431; ! Name_Length_Check : constant Name_Id := N + 432; ! Name_Overflow_Check : constant Name_Id := N + 433; ! Name_Range_Check : constant Name_Id := N + 434; ! Name_Storage_Check : constant Name_Id := N + 435; ! Name_Tag_Check : constant Name_Id := N + 436; ! Name_All_Checks : constant Name_Id := N + 437; ! Last_Check_Name : constant Name_Id := N + 437; -- Names corresponding to reserved keywords, excluding those already -- declared in the attribute list (Access, Delta, Digits, Range). ! Name_Abort : constant Name_Id := N + 438; ! Name_Abs : constant Name_Id := N + 439; ! Name_Accept : constant Name_Id := N + 440; ! Name_And : constant Name_Id := N + 441; ! Name_All : constant Name_Id := N + 442; ! Name_Array : constant Name_Id := N + 443; ! Name_At : constant Name_Id := N + 444; ! Name_Begin : constant Name_Id := N + 445; ! Name_Body : constant Name_Id := N + 446; ! Name_Case : constant Name_Id := N + 447; ! Name_Constant : constant Name_Id := N + 448; ! Name_Declare : constant Name_Id := N + 449; ! Name_Delay : constant Name_Id := N + 450; ! Name_Do : constant Name_Id := N + 451; ! Name_Else : constant Name_Id := N + 452; ! Name_Elsif : constant Name_Id := N + 453; ! Name_End : constant Name_Id := N + 454; ! Name_Entry : constant Name_Id := N + 455; ! Name_Exception : constant Name_Id := N + 456; ! Name_Exit : constant Name_Id := N + 457; ! Name_For : constant Name_Id := N + 458; ! Name_Function : constant Name_Id := N + 459; ! Name_Generic : constant Name_Id := N + 460; ! Name_Goto : constant Name_Id := N + 461; ! Name_If : constant Name_Id := N + 462; ! Name_In : constant Name_Id := N + 463; ! Name_Is : constant Name_Id := N + 464; ! Name_Limited : constant Name_Id := N + 465; ! Name_Loop : constant Name_Id := N + 466; ! Name_Mod : constant Name_Id := N + 467; ! Name_New : constant Name_Id := N + 468; ! Name_Not : constant Name_Id := N + 469; ! Name_Null : constant Name_Id := N + 470; ! Name_Of : constant Name_Id := N + 471; ! Name_Or : constant Name_Id := N + 472; ! Name_Others : constant Name_Id := N + 473; ! Name_Out : constant Name_Id := N + 474; ! Name_Package : constant Name_Id := N + 475; ! Name_Pragma : constant Name_Id := N + 476; ! Name_Private : constant Name_Id := N + 477; ! Name_Procedure : constant Name_Id := N + 478; ! Name_Raise : constant Name_Id := N + 479; ! Name_Record : constant Name_Id := N + 480; ! Name_Rem : constant Name_Id := N + 481; ! Name_Renames : constant Name_Id := N + 482; ! Name_Return : constant Name_Id := N + 483; ! Name_Reverse : constant Name_Id := N + 484; ! Name_Select : constant Name_Id := N + 485; ! Name_Separate : constant Name_Id := N + 486; ! Name_Subtype : constant Name_Id := N + 487; ! Name_Task : constant Name_Id := N + 488; ! Name_Terminate : constant Name_Id := N + 489; ! Name_Then : constant Name_Id := N + 490; ! Name_Type : constant Name_Id := N + 491; ! Name_Use : constant Name_Id := N + 492; ! Name_When : constant Name_Id := N + 493; ! Name_While : constant Name_Id := N + 494; ! Name_With : constant Name_Id := N + 495; ! Name_Xor : constant Name_Id := N + 496; -- Names of intrinsic subprograms -- Note: Asm is missing from this list, since Asm is a legitimate -- convention name. ! First_Intrinsic_Name : constant Name_Id := N + 497; ! Name_Divide : constant Name_Id := N + 497; ! Name_Enclosing_Entity : constant Name_Id := N + 498; ! Name_Exception_Information : constant Name_Id := N + 499; ! Name_Exception_Message : constant Name_Id := N + 500; ! Name_Exception_Name : constant Name_Id := N + 501; ! Name_File : constant Name_Id := N + 502; ! Name_Import_Address : constant Name_Id := N + 503; ! Name_Import_Largest_Value : constant Name_Id := N + 504; ! Name_Import_Value : constant Name_Id := N + 505; ! Name_Is_Negative : constant Name_Id := N + 506; ! Name_Line : constant Name_Id := N + 507; ! Name_Rotate_Left : constant Name_Id := N + 508; ! Name_Rotate_Right : constant Name_Id := N + 509; ! Name_Shift_Left : constant Name_Id := N + 510; ! Name_Shift_Right : constant Name_Id := N + 511; ! Name_Shift_Right_Arithmetic : constant Name_Id := N + 512; ! Name_Source_Location : constant Name_Id := N + 513; ! Name_Unchecked_Conversion : constant Name_Id := N + 514; ! Name_Unchecked_Deallocation : constant Name_Id := N + 515; ! Last_Intrinsic_Name : constant Name_Id := N + 515; -- Reserved words used only in Ada 95 ! First_95_Reserved_Word : constant Name_Id := N + 516; ! Name_Abstract : constant Name_Id := N + 516; ! Name_Aliased : constant Name_Id := N + 517; ! Name_Protected : constant Name_Id := N + 518; ! Name_Until : constant Name_Id := N + 519; ! Name_Requeue : constant Name_Id := N + 520; ! Name_Tagged : constant Name_Id := N + 521; ! Last_95_Reserved_Word : constant Name_Id := N + 521; subtype Ada_95_Reserved_Words is Name_Id range First_95_Reserved_Word .. Last_95_Reserved_Word; -- Miscellaneous names used in semantic checking ! Name_Raise_Exception : constant Name_Id := N + 522; -- Additional reserved words in GNAT Project Files -- Note that Name_External is already previously declared ! Name_Binder : constant Name_Id := N + 523; ! Name_Builder : constant Name_Id := N + 524; ! Name_Compiler : constant Name_Id := N + 525; ! Name_Cross_Reference : constant Name_Id := N + 526; ! Name_Default_Switches : constant Name_Id := N + 527; ! Name_Exec_Dir : constant Name_Id := N + 528; ! Name_Extends : constant Name_Id := N + 529; ! Name_Finder : constant Name_Id := N + 530; ! Name_Gnatls : constant Name_Id := N + 531; ! Name_Gnatstub : constant Name_Id := N + 532; ! Name_Implementation : constant Name_Id := N + 533; ! Name_Implementation_Exceptions : constant Name_Id := N + 534; ! Name_Implementation_Suffix : constant Name_Id := N + 535; ! Name_Languages : constant Name_Id := N + 536; ! Name_Library_Dir : constant Name_Id := N + 537; ! Name_Library_Elaboration : constant Name_Id := N + 538; ! Name_Library_Kind : constant Name_Id := N + 539; ! Name_Library_Name : constant Name_Id := N + 540; ! Name_Library_Version : constant Name_Id := N + 541; ! Name_Linker : constant Name_Id := N + 542; ! Name_Naming : constant Name_Id := N + 543; ! Name_Object_Dir : constant Name_Id := N + 544; ! Name_Project : constant Name_Id := N + 545; ! Name_Separate_Suffix : constant Name_Id := N + 546; ! Name_Source_Dirs : constant Name_Id := N + 547; ! Name_Source_Files : constant Name_Id := N + 548; ! Name_Source_List_File : constant Name_Id := N + 549; ! Name_Specification : constant Name_Id := N + 550; ! Name_Specification_Exceptions : constant Name_Id := N + 551; ! Name_Specification_Suffix : constant Name_Id := N + 552; ! Name_Switches : constant Name_Id := N + 553; -- Mark last defined name for consistency check in Snames body ! Last_Predefined_Name : constant Name_Id := N + 553; subtype Any_Operator_Name is Name_Id range First_Operator_Name .. Last_Operator_Name; --- 739,910 ---- -- name (e.g. F for FIFO_WIthinn_Priorities). If new policy names -- are added, the first character must be distinct. ! First_Task_Dispatching_Policy_Name : constant Name_Id := N + 427; ! Name_Fifo_Within_Priorities : constant Name_Id := N + 427; ! Last_Task_Dispatching_Policy_Name : constant Name_Id := N + 427; -- Names of recognized checks for pragma Suppress ! First_Check_Name : constant Name_Id := N + 428; ! Name_Access_Check : constant Name_Id := N + 428; ! Name_Accessibility_Check : constant Name_Id := N + 429; ! Name_Discriminant_Check : constant Name_Id := N + 430; ! Name_Division_Check : constant Name_Id := N + 431; ! Name_Elaboration_Check : constant Name_Id := N + 432; ! Name_Index_Check : constant Name_Id := N + 433; ! Name_Length_Check : constant Name_Id := N + 434; ! Name_Overflow_Check : constant Name_Id := N + 435; ! Name_Range_Check : constant Name_Id := N + 436; ! Name_Storage_Check : constant Name_Id := N + 437; ! Name_Tag_Check : constant Name_Id := N + 438; ! Name_All_Checks : constant Name_Id := N + 439; ! Last_Check_Name : constant Name_Id := N + 439; -- Names corresponding to reserved keywords, excluding those already -- declared in the attribute list (Access, Delta, Digits, Range). ! Name_Abort : constant Name_Id := N + 440; ! Name_Abs : constant Name_Id := N + 441; ! Name_Accept : constant Name_Id := N + 442; ! Name_And : constant Name_Id := N + 443; ! Name_All : constant Name_Id := N + 444; ! Name_Array : constant Name_Id := N + 445; ! Name_At : constant Name_Id := N + 446; ! Name_Begin : constant Name_Id := N + 447; ! Name_Body : constant Name_Id := N + 448; ! Name_Case : constant Name_Id := N + 449; ! Name_Constant : constant Name_Id := N + 450; ! Name_Declare : constant Name_Id := N + 451; ! Name_Delay : constant Name_Id := N + 452; ! Name_Do : constant Name_Id := N + 453; ! Name_Else : constant Name_Id := N + 454; ! Name_Elsif : constant Name_Id := N + 455; ! Name_End : constant Name_Id := N + 456; ! Name_Entry : constant Name_Id := N + 457; ! Name_Exception : constant Name_Id := N + 458; ! Name_Exit : constant Name_Id := N + 459; ! Name_For : constant Name_Id := N + 460; ! Name_Function : constant Name_Id := N + 461; ! Name_Generic : constant Name_Id := N + 462; ! Name_Goto : constant Name_Id := N + 463; ! Name_If : constant Name_Id := N + 464; ! Name_In : constant Name_Id := N + 465; ! Name_Is : constant Name_Id := N + 466; ! Name_Limited : constant Name_Id := N + 467; ! Name_Loop : constant Name_Id := N + 468; ! Name_Mod : constant Name_Id := N + 469; ! Name_New : constant Name_Id := N + 470; ! Name_Not : constant Name_Id := N + 471; ! Name_Null : constant Name_Id := N + 472; ! Name_Of : constant Name_Id := N + 473; ! Name_Or : constant Name_Id := N + 474; ! Name_Others : constant Name_Id := N + 475; ! Name_Out : constant Name_Id := N + 476; ! Name_Package : constant Name_Id := N + 477; ! Name_Pragma : constant Name_Id := N + 478; ! Name_Private : constant Name_Id := N + 479; ! Name_Procedure : constant Name_Id := N + 480; ! Name_Raise : constant Name_Id := N + 481; ! Name_Record : constant Name_Id := N + 482; ! Name_Rem : constant Name_Id := N + 483; ! Name_Renames : constant Name_Id := N + 484; ! Name_Return : constant Name_Id := N + 485; ! Name_Reverse : constant Name_Id := N + 486; ! Name_Select : constant Name_Id := N + 487; ! Name_Separate : constant Name_Id := N + 488; ! Name_Subtype : constant Name_Id := N + 489; ! Name_Task : constant Name_Id := N + 490; ! Name_Terminate : constant Name_Id := N + 491; ! Name_Then : constant Name_Id := N + 492; ! Name_Type : constant Name_Id := N + 493; ! Name_Use : constant Name_Id := N + 494; ! Name_When : constant Name_Id := N + 495; ! Name_While : constant Name_Id := N + 496; ! Name_With : constant Name_Id := N + 497; ! Name_Xor : constant Name_Id := N + 498; -- Names of intrinsic subprograms -- Note: Asm is missing from this list, since Asm is a legitimate -- convention name. ! First_Intrinsic_Name : constant Name_Id := N + 499; ! Name_Divide : constant Name_Id := N + 499; ! Name_Enclosing_Entity : constant Name_Id := N + 500; ! Name_Exception_Information : constant Name_Id := N + 501; ! Name_Exception_Message : constant Name_Id := N + 502; ! Name_Exception_Name : constant Name_Id := N + 503; ! Name_File : constant Name_Id := N + 504; ! Name_Import_Address : constant Name_Id := N + 505; ! Name_Import_Largest_Value : constant Name_Id := N + 506; ! Name_Import_Value : constant Name_Id := N + 507; ! Name_Is_Negative : constant Name_Id := N + 508; ! Name_Line : constant Name_Id := N + 509; ! Name_Rotate_Left : constant Name_Id := N + 510; ! Name_Rotate_Right : constant Name_Id := N + 511; ! Name_Shift_Left : constant Name_Id := N + 512; ! Name_Shift_Right : constant Name_Id := N + 513; ! Name_Shift_Right_Arithmetic : constant Name_Id := N + 514; ! Name_Source_Location : constant Name_Id := N + 515; ! Name_Unchecked_Conversion : constant Name_Id := N + 516; ! Name_Unchecked_Deallocation : constant Name_Id := N + 517; ! Last_Intrinsic_Name : constant Name_Id := N + 517; -- Reserved words used only in Ada 95 ! First_95_Reserved_Word : constant Name_Id := N + 518; ! Name_Abstract : constant Name_Id := N + 518; ! Name_Aliased : constant Name_Id := N + 519; ! Name_Protected : constant Name_Id := N + 520; ! Name_Until : constant Name_Id := N + 521; ! Name_Requeue : constant Name_Id := N + 522; ! Name_Tagged : constant Name_Id := N + 523; ! Last_95_Reserved_Word : constant Name_Id := N + 523; subtype Ada_95_Reserved_Words is Name_Id range First_95_Reserved_Word .. Last_95_Reserved_Word; -- Miscellaneous names used in semantic checking ! Name_Raise_Exception : constant Name_Id := N + 524; -- Additional reserved words in GNAT Project Files -- Note that Name_External is already previously declared ! Name_Binder : constant Name_Id := N + 525; ! Name_Builder : constant Name_Id := N + 526; ! Name_Compiler : constant Name_Id := N + 527; ! Name_Cross_Reference : constant Name_Id := N + 528; ! Name_Default_Switches : constant Name_Id := N + 529; ! Name_Exec_Dir : constant Name_Id := N + 530; ! Name_Extends : constant Name_Id := N + 531; ! Name_Finder : constant Name_Id := N + 532; ! Name_Gnatls : constant Name_Id := N + 533; ! Name_Gnatstub : constant Name_Id := N + 534; ! Name_Implementation : constant Name_Id := N + 535; ! Name_Implementation_Exceptions : constant Name_Id := N + 536; ! Name_Implementation_Suffix : constant Name_Id := N + 537; ! Name_Languages : constant Name_Id := N + 538; ! Name_Library_Dir : constant Name_Id := N + 539; ! Name_Library_Elaboration : constant Name_Id := N + 540; ! Name_Library_Kind : constant Name_Id := N + 541; ! Name_Library_Name : constant Name_Id := N + 542; ! Name_Library_Version : constant Name_Id := N + 543; ! Name_Linker : constant Name_Id := N + 544; ! Name_Naming : constant Name_Id := N + 545; ! Name_Object_Dir : constant Name_Id := N + 546; ! Name_Project : constant Name_Id := N + 547; ! Name_Separate_Suffix : constant Name_Id := N + 548; ! Name_Source_Dirs : constant Name_Id := N + 549; ! Name_Source_Files : constant Name_Id := N + 550; ! Name_Source_List_File : constant Name_Id := N + 551; ! Name_Specification : constant Name_Id := N + 552; ! Name_Specification_Exceptions : constant Name_Id := N + 553; ! Name_Specification_Suffix : constant Name_Id := N + 554; ! Name_Switches : constant Name_Id := N + 555; -- Mark last defined name for consistency check in Snames body ! Last_Predefined_Name : constant Name_Id := N + 555; subtype Any_Operator_Name is Name_Id range First_Operator_Name .. Last_Operator_Name; *************** package Snames is *** 956,963 **** Attribute_Machine_Rounds, Attribute_Machine_Size, Attribute_Mantissa, - Attribute_Max_Interrupt_Priority, - Attribute_Max_Priority, Attribute_Max_Size_In_Storage_Elements, Attribute_Maximum_Alignment, Attribute_Mechanism_Code, --- 966,971 ---- *************** package Snames is *** 989,995 **** Attribute_Storage_Unit, Attribute_Tag, Attribute_Terminated, - Attribute_Tick, Attribute_To_Address, Attribute_Type_Class, Attribute_UET_Address, --- 997,1002 ---- *************** package Snames is *** 1079,1102 **** -- The remaining conventions are foreign language conventions ! Convention_Assembler, ! Convention_C, Convention_COBOL, Convention_CPP, Convention_Fortran, Convention_Java, ! Convention_Stdcall, Convention_Stubbed); ! -- Note: Conventions C_Pass_By_Copy, External, and Default are all ! -- treated as synonyms for convention C (with an appropriate flag ! -- being set in a record type in the case of C_Pass_By_Copy). See ! -- processing in Sem_Prag for details. ! ! -- Note: convention Win32 has the same effect as convention Stdcall ! -- and as a special exception to normal rules is considered to be ! -- conformant with convention Stdcall. Therefore if the convention ! -- Win32 is encountered, it is translated into Convention_Stdcall. for Convention_Id'Size use 8; -- Plenty of space for expansion --- 1086,1104 ---- -- The remaining conventions are foreign language conventions ! Convention_Assembler, -- also Asm, Assembly ! Convention_C, -- also Default, External Convention_COBOL, Convention_CPP, Convention_Fortran, Convention_Java, ! Convention_Stdcall, -- also DLL, Win32 Convention_Stubbed); ! -- Note: Convention C_Pass_By_Copy is allowed only for record ! -- types (where it is treated like C except that the appropriate ! -- flag is set in the record type). Recognizion of this convention ! -- is specially handled in Sem_Prag. for Convention_Id'Size use 8; -- Plenty of space for expansion *************** package Snames is *** 1124,1129 **** --- 1126,1132 ---- Pragma_Ada_95, Pragma_C_Pass_By_Copy, Pragma_Component_Alignment, + Pragma_Convention_Identifier, Pragma_Discard_Names, Pragma_Elaboration_Checks, Pragma_Eliminate, *************** package Snames is *** 1239,1244 **** --- 1242,1249 ---- Pragma_Title, Pragma_Unchecked_Union, Pragma_Unimplemented_Unit, + Pragma_Universal_Data, + Pragma_Unreferenced, Pragma_Unreserve_All_Interrupts, Pragma_Volatile, Pragma_Volatile_Components, *************** package Snames is *** 1330,1336 **** function Get_Convention_Id (N : Name_Id) return Convention_Id; -- Returns Id of language convention corresponding to given name. It is an ! -- to call this function with a name that is not the name of a check. function Get_Check_Id (N : Name_Id) return Check_Id; -- Returns Id of suppress check corresponding to given name. It is an error --- 1335,1342 ---- function Get_Convention_Id (N : Name_Id) return Convention_Id; -- Returns Id of language convention corresponding to given name. It is an ! -- to call this function with a name that is not the name of a convention, ! -- or one previously given in a call to Record_Convention_Identifier. function Get_Check_Id (N : Name_Id) return Check_Id; -- Returns Id of suppress check corresponding to given name. It is an error *************** package Snames is *** 1354,1362 **** function Get_Task_Dispatching_Policy_Id (N : Name_Id) return Task_Dispatching_Policy_Id; ! -- Returns Id of task dispatching policy corresponding to given name. It ! -- is an error to call this function with a name that is not the name ! -- of a check. private pragma Inline (Is_Attribute_Name); --- 1360,1375 ---- function Get_Task_Dispatching_Policy_Id (N : Name_Id) return Task_Dispatching_Policy_Id; ! -- Returns Id of task dispatching policy corresponding to given name. ! -- It is an error to call this function with a name that is not the ! -- name of a check. ! ! procedure Record_Convention_Identifier ! (Id : Name_Id; ! Convention : Convention_Id); ! -- A call to this procedure, resulting from an occurrence of a pragma ! -- Convention_Identifier, records that from now on an occurrence of ! -- Id will be recognized as a name for the specified convention. private pragma Inline (Is_Attribute_Name); diff -Nrc3pad gcc-3.2.3/gcc/ada/snames.h gcc-3.3/gcc/ada/snames.h *** gcc-3.2.3/gcc/ada/snames.h 2002-05-04 03:29:20.000000000 +0000 --- gcc-3.3/gcc/ada/snames.h 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** * * * C Header File * * * - * $Revision: 1.2.12.1 $ * * ! * Copyright (C) 1992-2001 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- * --- 6,13 ---- * * * C Header File * * * * * ! * Copyright (C) 1992-2002 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- * *************** extern char Get_Attribute_Id PARAMS ((in *** 101,187 **** #define Attr_Machine_Rounds 49 #define Attr_Machine_Size 50 #define Attr_Mantissa 51 ! #define Attr_Max_Interrupt_Priority 52 ! #define Attr_Max_Priority 53 ! #define Attr_Max_Size_In_Storage_Elements 54 ! #define Attr_Maximum_Alignment 55 ! #define Attr_Mechanism_Code 56 ! #define Attr_Model_Emin 57 ! #define Attr_Model_Epsilon 58 ! #define Attr_Model_Mantissa 59 ! #define Attr_Model_Small 60 ! #define Attr_Modulus 61 ! #define Attr_Null_Parameter 62 ! #define Attr_Object_Size 63 ! #define Attr_Partition_ID 64 ! #define Attr_Passed_By_Reference 65 ! #define Attr_Pos 66 ! #define Attr_Position 67 ! #define Attr_Range 68 ! #define Attr_Range_Length 69 ! #define Attr_Round 70 ! #define Attr_Safe_Emax 71 ! #define Attr_Safe_First 72 ! #define Attr_Safe_Large 73 ! #define Attr_Safe_Last 74 ! #define Attr_Safe_Small 75 ! #define Attr_Scale 76 ! #define Attr_Scaling 77 ! #define Attr_Signed_Zeros 78 ! #define Attr_Size 79 ! #define Attr_Small 80 ! #define Attr_Storage_Size 81 ! #define Attr_Storage_Unit 82 ! #define Attr_Tag 83 ! #define Attr_Terminated 84 ! #define Attr_Tick 85 ! #define Attr_To_Address 86 ! #define Attr_Type_Class 87 ! #define Attr_UET_Address 88 ! #define Attr_Unbiased_Rounding 89 ! #define Attr_Unchecked_Access 90 ! #define Attr_Universal_Literal_String 91 ! #define Attr_Unrestricted_Access 92 ! #define Attr_VADS_Size 93 ! #define Attr_Val 94 ! #define Attr_Valid 95 ! #define Attr_Value_Size 96 ! #define Attr_Version 97 ! #define Attr_Wide_Character_Size 98 ! #define Attr_Wide_Width 99 ! #define Attr_Width 100 ! #define Attr_Word_Size 101 ! #define Attr_Adjacent 102 ! #define Attr_Ceiling 103 ! #define Attr_Copy_Sign 104 ! #define Attr_Floor 105 ! #define Attr_Fraction 106 ! #define Attr_Image 107 ! #define Attr_Input 108 ! #define Attr_Machine 109 ! #define Attr_Max 110 ! #define Attr_Min 111 ! #define Attr_Model 112 ! #define Attr_Pred 113 ! #define Attr_Remainder 114 ! #define Attr_Rounding 115 ! #define Attr_Succ 116 ! #define Attr_Truncation 117 ! #define Attr_Value 118 ! #define Attr_Wide_Image 119 ! #define Attr_Wide_Value 120 ! #define Attr_Output 121 ! #define Attr_Read 122 ! #define Attr_Write 123 ! #define Attr_Elab_Body 124 ! #define Attr_Elab_Spec 125 ! #define Attr_Storage_Pool 126 ! #define Attr_Base 127 ! #define Attr_Class 128 /* Define the function to check if a Name_Id value is a valid pragma */ --- 100,183 ---- #define Attr_Machine_Rounds 49 #define Attr_Machine_Size 50 #define Attr_Mantissa 51 ! #define Attr_Max_Size_In_Storage_Elements 52 ! #define Attr_Maximum_Alignment 53 ! #define Attr_Mechanism_Code 54 ! #define Attr_Model_Emin 55 ! #define Attr_Model_Epsilon 56 ! #define Attr_Model_Mantissa 57 ! #define Attr_Model_Small 58 ! #define Attr_Modulus 59 ! #define Attr_Null_Parameter 60 ! #define Attr_Object_Size 61 ! #define Attr_Partition_ID 62 ! #define Attr_Passed_By_Reference 63 ! #define Attr_Pos 64 ! #define Attr_Position 65 ! #define Attr_Range 66 ! #define Attr_Range_Length 67 ! #define Attr_Round 68 ! #define Attr_Safe_Emax 69 ! #define Attr_Safe_First 70 ! #define Attr_Safe_Large 71 ! #define Attr_Safe_Last 72 ! #define Attr_Safe_Small 73 ! #define Attr_Scale 74 ! #define Attr_Scaling 75 ! #define Attr_Signed_Zeros 76 ! #define Attr_Size 77 ! #define Attr_Small 78 ! #define Attr_Storage_Size 79 ! #define Attr_Storage_Unit 80 ! #define Attr_Tag 81 ! #define Attr_Terminated 82 ! #define Attr_To_Address 83 ! #define Attr_Type_Class 84 ! #define Attr_UET_Address 85 ! #define Attr_Unbiased_Rounding 86 ! #define Attr_Unchecked_Access 87 ! #define Attr_Universal_Literal_String 88 ! #define Attr_Unrestricted_Access 89 ! #define Attr_VADS_Size 90 ! #define Attr_Val 91 ! #define Attr_Valid 92 ! #define Attr_Value_Size 93 ! #define Attr_Version 94 ! #define Attr_Wide_Character_Size 95 ! #define Attr_Wide_Width 96 ! #define Attr_Width 97 ! #define Attr_Word_Size 98 ! #define Attr_Adjacent 99 ! #define Attr_Ceiling 100 ! #define Attr_Copy_Sign 101 ! #define Attr_Floor 102 ! #define Attr_Fraction 103 ! #define Attr_Image 104 ! #define Attr_Input 105 ! #define Attr_Machine 106 ! #define Attr_Max 107 ! #define Attr_Min 108 ! #define Attr_Model 109 ! #define Attr_Pred 110 ! #define Attr_Remainder 111 ! #define Attr_Rounding 112 ! #define Attr_Succ 113 ! #define Attr_Truncation 114 ! #define Attr_Value 115 ! #define Attr_Wide_Image 116 ! #define Attr_Wide_Value 117 ! #define Attr_Output 118 ! #define Attr_Read 119 ! #define Attr_Write 120 ! #define Attr_Elab_Body 121 ! #define Attr_Elab_Spec 122 ! #define Attr_Storage_Pool 123 ! #define Attr_Base 124 ! #define Attr_Class 125 /* Define the function to check if a Name_Id value is a valid pragma */ *************** extern char Get_Pragma_Id PARAMS ((int)) *** 204,334 **** #define Pragma_Ada_95 1 #define Pragma_C_Pass_By_Copy 2 #define Pragma_Component_Alignment 3 ! #define Pragma_Discard_Names 4 ! #define Pragma_Elaboration_Checking 5 ! #define Pragma_Eliminate 6 ! #define Pragma_Extend_System 7 ! #define Pragma_Extensions_Allowed 8 ! #define Pragma_External_Name_Casing 9 ! #define Pragma_Float_Representation 10 ! #define Pragma_Initialize 11 ! #define Pragma_License 12 ! #define Pragma_Locking_Policy 13 ! #define Pragma_Long_Float 14 ! #define Pragma_No_Run_Time 15 ! #define Pragma_Normalize_Scalars 16 ! #define Pragma_Polling 17 ! #define Pragma_Propagate_Exceptions 18 ! #define Pragma_Queuing_Policy 19 ! #define Pragma_Ravenscar 20 ! #define Pragma_Restricted_Run_Time 21 ! #define Pragma_Restrictions 22 ! #define Pragma_Reviewable 23 ! #define Pragma_Source_File_Name 24 ! #define Pragma_Style_Checks 25 ! #define Pragma_Suppress 26 ! #define Pragma_Task_Dispatching_Policy 27 ! #define Pragma_Unsuppress 28 ! #define Pragma_Use_VADS_Size 29 ! #define Pragma_Validity_Checks 30 ! #define Pragma_Warnings 31 /* Remaining pragmas */ ! #define Pragma_Abort_Defer 32 ! #define Pragma_All_Calls_Remote 33 ! #define Pragma_Annotate 34 ! #define Pragma_Assert 35 ! #define Pragma_Asynchronous 36 ! #define Pragma_Atomic 37 ! #define Pragma_Atomic_Components 38 ! #define Pragma_Attach_Handler 39 ! #define Pragma_Comment 40 ! #define Pragma_Common_Object 41 ! #define Pragma_Complex_Representation 42 ! #define Pragma_Controlled 43 ! #define Pragma_Convention 44 ! #define Pragma_CPP_Class 45 ! #define Pragma_CPP_Constructor 46 ! #define Pragma_CPP_Virtual 47 ! #define Pragma_CPP_Vtable 48 ! #define Pragma_Debug 49 ! #define Pragma_Elaborate 50 ! #define Pragma_Elaborate_All 51 ! #define Pragma_Elaborate_Body 52 ! #define Pragma_Export 53 ! #define Pragma_Export_Exception 54 ! #define Pragma_Export_Function 55 ! #define Pragma_Export_Object 56 ! #define Pragma_Export_Procedure 57 ! #define Pragma_Export_Valued_Procedure 58 ! #define Pragma_External 59 ! #define Pragma_Finalize_Storage_Only 60 ! #define Pragma_Ident 61 ! #define Pragma_Import 62 ! #define Pragma_Import_Exception 63 ! #define Pragma_Import_Function 64 ! #define Pragma_Import_Object 65 ! #define Pragma_Import_Procedure 66 ! #define Pragma_Import_Valued_Procedure 67 ! #define Pragma_Inline 68 ! #define Pragma_Inline_Always 69 ! #define Pragma_Inline_Generic 70 ! #define Pragma_Inspection_Point 71 ! #define Pragma_Interface 72 ! #define Pragma_Interface_Name 73 ! #define Pragma_Interrupt_Handler 74 ! #define Pragma_Interrupt_Priority 75 ! #define Pragma_Java_Constructor 76 ! #define Pragma_Java_Interface 77 ! #define Pragma_Link_With 78 ! #define Pragma_Linker_Alias 79 ! #define Pragma_Linker_Options 80 ! #define Pragma_Linker_Section 81 ! #define Pragma_List 82 ! #define Pragma_Machine_Attribute 83 ! #define Pragma_Main 84 ! #define Pragma_Main_Storage 85 ! #define Pragma_Memory_Size 86 ! #define Pragma_No_Return 87 ! #define Pragma_Optimize 88 ! #define Pragma_Pack 89 ! #define Pragma_Page 90 ! #define Pragma_Passive 91 ! #define Pragma_Preelaborate 92 ! #define Pragma_Priority 93 ! #define Pragma_Psect_Object 94 ! #define Pragma_Pure 95 ! #define Pragma_Pure_Function 96 ! #define Pragma_Remote_Call_Interface 97 ! #define Pragma_Remote_Types 98 ! #define Pragma_Share_Generic 99 ! #define Pragma_Shared 100 ! #define Pragma_Shared_Passive 101 ! #define Pragma_Source_Reference 102 ! #define Pragma_Stream_Convert 103 ! #define Pragma_Subtitle 104 ! #define Pragma_Suppress_All 105 ! #define Pragma_Suppress_Debug_Info 106 ! #define Pragma_Suppress_Initialization 107 ! #define Pragma_System_Name 108 ! #define Pragma_Task_Info 109 ! #define Pragma_Task_Name 110 ! #define Pragma_Task_Storage 111 ! #define Pragma_Time_Slice 112 ! #define Pragma_Title 113 ! #define Pragma_Unchecked_Union 114 ! #define Pragma_Unimplemented_Unit 115 ! #define Pragma_Unreserve_All_Interrupts 116 ! #define Pragma_Volatile 117 ! #define Pragma_Volatile_Components 118 ! #define Pragma_Weak_External 119 /* The following are deliberately out of alphabetical order, see Snames */ ! #define Pragma_AST_Entry 120 ! #define Pragma_Storage_Size 121 ! #define Pragma_Storage_Unit 122 /* Define the numeric values for the conventions. */ --- 200,333 ---- #define Pragma_Ada_95 1 #define Pragma_C_Pass_By_Copy 2 #define Pragma_Component_Alignment 3 ! #define Pragma_Convention_Identifier 4 ! #define Pragma_Discard_Names 5 ! #define Pragma_Elaboration_Checking 6 ! #define Pragma_Eliminate 7 ! #define Pragma_Extend_System 8 ! #define Pragma_Extensions_Allowed 9 ! #define Pragma_External_Name_Casing 10 ! #define Pragma_Float_Representation 11 ! #define Pragma_Initialize 12 ! #define Pragma_License 13 ! #define Pragma_Locking_Policy 14 ! #define Pragma_Long_Float 15 ! #define Pragma_No_Run_Time 16 ! #define Pragma_Normalize_Scalars 17 ! #define Pragma_Polling 18 ! #define Pragma_Propagate_Exceptions 19 ! #define Pragma_Queuing_Policy 20 ! #define Pragma_Ravenscar 21 ! #define Pragma_Restricted_Run_Time 22 ! #define Pragma_Restrictions 23 ! #define Pragma_Reviewable 24 ! #define Pragma_Source_File_Name 25 ! #define Pragma_Style_Checks 26 ! #define Pragma_Suppress 27 ! #define Pragma_Task_Dispatching_Policy 28 ! #define Pragma_Unsuppress 29 ! #define Pragma_Use_VADS_Size 30 ! #define Pragma_Validity_Checks 31 ! #define Pragma_Warnings 32 /* Remaining pragmas */ ! #define Pragma_Abort_Defer 33 ! #define Pragma_All_Calls_Remote 34 ! #define Pragma_Annotate 35 ! #define Pragma_Assert 36 ! #define Pragma_Asynchronous 37 ! #define Pragma_Atomic 38 ! #define Pragma_Atomic_Components 39 ! #define Pragma_Attach_Handler 40 ! #define Pragma_Comment 41 ! #define Pragma_Common_Object 42 ! #define Pragma_Complex_Representation 43 ! #define Pragma_Controlled 44 ! #define Pragma_Convention 45 ! #define Pragma_CPP_Class 46 ! #define Pragma_CPP_Constructor 47 ! #define Pragma_CPP_Virtual 48 ! #define Pragma_CPP_Vtable 49 ! #define Pragma_Debug 50 ! #define Pragma_Elaborate 51 ! #define Pragma_Elaborate_All 52 ! #define Pragma_Elaborate_Body 53 ! #define Pragma_Export 54 ! #define Pragma_Export_Exception 55 ! #define Pragma_Export_Function 56 ! #define Pragma_Export_Object 57 ! #define Pragma_Export_Procedure 58 ! #define Pragma_Export_Valued_Procedure 59 ! #define Pragma_External 60 ! #define Pragma_Finalize_Storage_Only 61 ! #define Pragma_Ident 62 ! #define Pragma_Import 63 ! #define Pragma_Import_Exception 64 ! #define Pragma_Import_Function 65 ! #define Pragma_Import_Object 66 ! #define Pragma_Import_Procedure 67 ! #define Pragma_Import_Valued_Procedure 68 ! #define Pragma_Inline 69 ! #define Pragma_Inline_Always 70 ! #define Pragma_Inline_Generic 71 ! #define Pragma_Inspection_Point 72 ! #define Pragma_Interface 73 ! #define Pragma_Interface_Name 74 ! #define Pragma_Interrupt_Handler 75 ! #define Pragma_Interrupt_Priority 76 ! #define Pragma_Java_Constructor 77 ! #define Pragma_Java_Interface 78 ! #define Pragma_Link_With 79 ! #define Pragma_Linker_Alias 80 ! #define Pragma_Linker_Options 81 ! #define Pragma_Linker_Section 82 ! #define Pragma_List 83 ! #define Pragma_Machine_Attribute 84 ! #define Pragma_Main 85 ! #define Pragma_Main_Storage 86 ! #define Pragma_Memory_Size 87 ! #define Pragma_No_Return 88 ! #define Pragma_Optimize 89 ! #define Pragma_Pack 90 ! #define Pragma_Page 91 ! #define Pragma_Passive 92 ! #define Pragma_Preelaborate 93 ! #define Pragma_Priority 94 ! #define Pragma_Psect_Object 95 ! #define Pragma_Pure 96 ! #define Pragma_Pure_Function 97 ! #define Pragma_Remote_Call_Interface 98 ! #define Pragma_Remote_Types 99 ! #define Pragma_Share_Generic 100 ! #define Pragma_Shared 101 ! #define Pragma_Shared_Passive 102 ! #define Pragma_Source_Reference 103 ! #define Pragma_Stream_Convert 104 ! #define Pragma_Subtitle 105 ! #define Pragma_Suppress_All 106 ! #define Pragma_Suppress_Debug_Info 107 ! #define Pragma_Suppress_Initialization 108 ! #define Pragma_System_Name 109 ! #define Pragma_Task_Info 110 ! #define Pragma_Task_Name 111 ! #define Pragma_Task_Storage 112 ! #define Pragma_Time_Slice 113 ! #define Pragma_Title 114 ! #define Pragma_Unchecked_Union 115 ! #define Pragma_Unimplemented_Unit 116 ! #define Pragma_Universal_Data 117 ! #define Pragma_Unreferenced 118 ! #define Pragma_Unreserve_All_Interrupts 119 ! #define Pragma_Volatile 120 ! #define Pragma_Volatile_Components 121 ! #define Pragma_Weak_External 122 /* The following are deliberately out of alphabetical order, see Snames */ ! #define Pragma_AST_Entry 123 ! #define Pragma_Storage_Size 124 ! #define Pragma_Storage_Unit 125 /* Define the numeric values for the conventions. */ diff -Nrc3pad gcc-3.2.3/gcc/ada/s-osprim.ads gcc-3.3/gcc/ada/s-osprim.ads *** gcc-3.2.3/gcc/ada/s-osprim.ads 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-osprim.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack03.adb gcc-3.3/gcc/ada/s-pack03.adb *** gcc-3.2.3/gcc/ada/s-pack03.adb 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack03.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack03.ads gcc-3.3/gcc/ada/s-pack03.ads *** gcc-3.2.3/gcc/ada/s-pack03.ads 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack03.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack05.adb gcc-3.3/gcc/ada/s-pack05.adb *** gcc-3.2.3/gcc/ada/s-pack05.adb 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack05.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack05.ads gcc-3.3/gcc/ada/s-pack05.ads *** gcc-3.2.3/gcc/ada/s-pack05.ads 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack05.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack06.adb gcc-3.3/gcc/ada/s-pack06.adb *** gcc-3.2.3/gcc/ada/s-pack06.adb 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack06.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack06.ads gcc-3.3/gcc/ada/s-pack06.ads *** gcc-3.2.3/gcc/ada/s-pack06.ads 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack06.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack07.adb gcc-3.3/gcc/ada/s-pack07.adb *** gcc-3.2.3/gcc/ada/s-pack07.adb 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack07.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack07.ads gcc-3.3/gcc/ada/s-pack07.ads *** gcc-3.2.3/gcc/ada/s-pack07.ads 2002-05-07 08:22:23.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack07.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack09.adb gcc-3.3/gcc/ada/s-pack09.adb *** gcc-3.2.3/gcc/ada/s-pack09.adb 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack09.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack09.ads gcc-3.3/gcc/ada/s-pack09.ads *** gcc-3.2.3/gcc/ada/s-pack09.ads 2002-05-07 08:22:24.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack09.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack10.adb gcc-3.3/gcc/ada/s-pack10.adb *** gcc-3.2.3/gcc/ada/s-pack10.adb 2002-05-04 03:28:41.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack10.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack10.ads gcc-3.3/gcc/ada/s-pack10.ads *** gcc-3.2.3/gcc/ada/s-pack10.ads 2002-05-04 03:28:42.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack10.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack11.adb gcc-3.3/gcc/ada/s-pack11.adb *** gcc-3.2.3/gcc/ada/s-pack11.adb 2002-05-04 03:28:42.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack11.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack11.ads gcc-3.3/gcc/ada/s-pack11.ads *** gcc-3.2.3/gcc/ada/s-pack11.ads 2002-05-07 08:22:24.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack11.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack12.adb gcc-3.3/gcc/ada/s-pack12.adb *** gcc-3.2.3/gcc/ada/s-pack12.adb 2002-05-04 03:28:42.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack12.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack12.ads gcc-3.3/gcc/ada/s-pack12.ads *** gcc-3.2.3/gcc/ada/s-pack12.ads 2002-05-04 03:28:42.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack12.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack13.adb gcc-3.3/gcc/ada/s-pack13.adb *** gcc-3.2.3/gcc/ada/s-pack13.adb 2002-05-04 03:28:42.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack13.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack13.ads gcc-3.3/gcc/ada/s-pack13.ads *** gcc-3.2.3/gcc/ada/s-pack13.ads 2002-05-07 08:22:24.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack13.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack14.adb gcc-3.3/gcc/ada/s-pack14.adb *** gcc-3.2.3/gcc/ada/s-pack14.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack14.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack14.ads gcc-3.3/gcc/ada/s-pack14.ads *** gcc-3.2.3/gcc/ada/s-pack14.ads 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack14.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack15.adb gcc-3.3/gcc/ada/s-pack15.adb *** gcc-3.2.3/gcc/ada/s-pack15.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack15.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack15.ads gcc-3.3/gcc/ada/s-pack15.ads *** gcc-3.2.3/gcc/ada/s-pack15.ads 2002-05-07 08:22:24.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack15.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack17.adb gcc-3.3/gcc/ada/s-pack17.adb *** gcc-3.2.3/gcc/ada/s-pack17.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack17.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack17.ads gcc-3.3/gcc/ada/s-pack17.ads *** gcc-3.2.3/gcc/ada/s-pack17.ads 2002-05-07 08:22:24.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack17.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack18.adb gcc-3.3/gcc/ada/s-pack18.adb *** gcc-3.2.3/gcc/ada/s-pack18.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack18.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack18.ads gcc-3.3/gcc/ada/s-pack18.ads *** gcc-3.2.3/gcc/ada/s-pack18.ads 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack18.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack19.adb gcc-3.3/gcc/ada/s-pack19.adb *** gcc-3.2.3/gcc/ada/s-pack19.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack19.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack19.ads gcc-3.3/gcc/ada/s-pack19.ads *** gcc-3.2.3/gcc/ada/s-pack19.ads 2002-05-07 08:22:25.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack19.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack20.adb gcc-3.3/gcc/ada/s-pack20.adb *** gcc-3.2.3/gcc/ada/s-pack20.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack20.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack20.ads gcc-3.3/gcc/ada/s-pack20.ads *** gcc-3.2.3/gcc/ada/s-pack20.ads 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack20.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack21.adb gcc-3.3/gcc/ada/s-pack21.adb *** gcc-3.2.3/gcc/ada/s-pack21.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack21.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack21.ads gcc-3.3/gcc/ada/s-pack21.ads *** gcc-3.2.3/gcc/ada/s-pack21.ads 2002-05-07 08:22:26.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack21.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack22.adb gcc-3.3/gcc/ada/s-pack22.adb *** gcc-3.2.3/gcc/ada/s-pack22.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack22.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack22.ads gcc-3.3/gcc/ada/s-pack22.ads *** gcc-3.2.3/gcc/ada/s-pack22.ads 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack22.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack23.adb gcc-3.3/gcc/ada/s-pack23.adb *** gcc-3.2.3/gcc/ada/s-pack23.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack23.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack23.ads gcc-3.3/gcc/ada/s-pack23.ads *** gcc-3.2.3/gcc/ada/s-pack23.ads 2002-05-07 08:22:26.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack23.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack24.adb gcc-3.3/gcc/ada/s-pack24.adb *** gcc-3.2.3/gcc/ada/s-pack24.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack24.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack24.ads gcc-3.3/gcc/ada/s-pack24.ads *** gcc-3.2.3/gcc/ada/s-pack24.ads 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack24.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack25.adb gcc-3.3/gcc/ada/s-pack25.adb *** gcc-3.2.3/gcc/ada/s-pack25.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack25.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack25.ads gcc-3.3/gcc/ada/s-pack25.ads *** gcc-3.2.3/gcc/ada/s-pack25.ads 2002-05-07 08:22:26.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack25.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack26.adb gcc-3.3/gcc/ada/s-pack26.adb *** gcc-3.2.3/gcc/ada/s-pack26.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack26.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack26.ads gcc-3.3/gcc/ada/s-pack26.ads *** gcc-3.2.3/gcc/ada/s-pack26.ads 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack26.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack27.adb gcc-3.3/gcc/ada/s-pack27.adb *** gcc-3.2.3/gcc/ada/s-pack27.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack27.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack27.ads gcc-3.3/gcc/ada/s-pack27.ads *** gcc-3.2.3/gcc/ada/s-pack27.ads 2002-05-07 08:22:26.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack27.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack28.adb gcc-3.3/gcc/ada/s-pack28.adb *** gcc-3.2.3/gcc/ada/s-pack28.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack28.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack28.ads gcc-3.3/gcc/ada/s-pack28.ads *** gcc-3.2.3/gcc/ada/s-pack28.ads 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack28.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack29.adb gcc-3.3/gcc/ada/s-pack29.adb *** gcc-3.2.3/gcc/ada/s-pack29.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack29.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack29.ads gcc-3.3/gcc/ada/s-pack29.ads *** gcc-3.2.3/gcc/ada/s-pack29.ads 2002-05-07 08:22:26.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack29.ads 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack30.adb gcc-3.3/gcc/ada/s-pack30.adb *** gcc-3.2.3/gcc/ada/s-pack30.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack30.adb 2002-10-23 07:33:29.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack30.ads gcc-3.3/gcc/ada/s-pack30.ads *** gcc-3.2.3/gcc/ada/s-pack30.ads 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack30.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack31.adb gcc-3.3/gcc/ada/s-pack31.adb *** gcc-3.2.3/gcc/ada/s-pack31.adb 2002-05-04 03:28:43.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack31.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack31.ads gcc-3.3/gcc/ada/s-pack31.ads *** gcc-3.2.3/gcc/ada/s-pack31.ads 2002-05-07 08:22:26.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack31.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack33.adb gcc-3.3/gcc/ada/s-pack33.adb *** gcc-3.2.3/gcc/ada/s-pack33.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack33.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack33.ads gcc-3.3/gcc/ada/s-pack33.ads *** gcc-3.2.3/gcc/ada/s-pack33.ads 2002-05-07 08:22:26.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack33.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack34.adb gcc-3.3/gcc/ada/s-pack34.adb *** gcc-3.2.3/gcc/ada/s-pack34.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack34.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack34.ads gcc-3.3/gcc/ada/s-pack34.ads *** gcc-3.2.3/gcc/ada/s-pack34.ads 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack34.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack35.adb gcc-3.3/gcc/ada/s-pack35.adb *** gcc-3.2.3/gcc/ada/s-pack35.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack35.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack35.ads gcc-3.3/gcc/ada/s-pack35.ads *** gcc-3.2.3/gcc/ada/s-pack35.ads 2002-05-07 08:22:26.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack35.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack36.adb gcc-3.3/gcc/ada/s-pack36.adb *** gcc-3.2.3/gcc/ada/s-pack36.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack36.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack36.ads gcc-3.3/gcc/ada/s-pack36.ads *** gcc-3.2.3/gcc/ada/s-pack36.ads 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack36.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack37.adb gcc-3.3/gcc/ada/s-pack37.adb *** gcc-3.2.3/gcc/ada/s-pack37.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack37.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack37.ads gcc-3.3/gcc/ada/s-pack37.ads *** gcc-3.2.3/gcc/ada/s-pack37.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack37.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack38.adb gcc-3.3/gcc/ada/s-pack38.adb *** gcc-3.2.3/gcc/ada/s-pack38.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack38.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack38.ads gcc-3.3/gcc/ada/s-pack38.ads *** gcc-3.2.3/gcc/ada/s-pack38.ads 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack38.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack39.adb gcc-3.3/gcc/ada/s-pack39.adb *** gcc-3.2.3/gcc/ada/s-pack39.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack39.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack39.ads gcc-3.3/gcc/ada/s-pack39.ads *** gcc-3.2.3/gcc/ada/s-pack39.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack39.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack40.adb gcc-3.3/gcc/ada/s-pack40.adb *** gcc-3.2.3/gcc/ada/s-pack40.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack40.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack40.ads gcc-3.3/gcc/ada/s-pack40.ads *** gcc-3.2.3/gcc/ada/s-pack40.ads 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack40.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack41.adb gcc-3.3/gcc/ada/s-pack41.adb *** gcc-3.2.3/gcc/ada/s-pack41.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack41.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack41.ads gcc-3.3/gcc/ada/s-pack41.ads *** gcc-3.2.3/gcc/ada/s-pack41.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack41.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack42.adb gcc-3.3/gcc/ada/s-pack42.adb *** gcc-3.2.3/gcc/ada/s-pack42.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack42.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack42.ads gcc-3.3/gcc/ada/s-pack42.ads *** gcc-3.2.3/gcc/ada/s-pack42.ads 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack42.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack43.adb gcc-3.3/gcc/ada/s-pack43.adb *** gcc-3.2.3/gcc/ada/s-pack43.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack43.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack43.ads gcc-3.3/gcc/ada/s-pack43.ads *** gcc-3.2.3/gcc/ada/s-pack43.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack43.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack44.adb gcc-3.3/gcc/ada/s-pack44.adb *** gcc-3.2.3/gcc/ada/s-pack44.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack44.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack44.ads gcc-3.3/gcc/ada/s-pack44.ads *** gcc-3.2.3/gcc/ada/s-pack44.ads 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack44.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack45.adb gcc-3.3/gcc/ada/s-pack45.adb *** gcc-3.2.3/gcc/ada/s-pack45.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack45.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack45.ads gcc-3.3/gcc/ada/s-pack45.ads *** gcc-3.2.3/gcc/ada/s-pack45.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack45.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack46.adb gcc-3.3/gcc/ada/s-pack46.adb *** gcc-3.2.3/gcc/ada/s-pack46.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack46.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack46.ads gcc-3.3/gcc/ada/s-pack46.ads *** gcc-3.2.3/gcc/ada/s-pack46.ads 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack46.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack47.adb gcc-3.3/gcc/ada/s-pack47.adb *** gcc-3.2.3/gcc/ada/s-pack47.adb 2002-05-04 03:28:44.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack47.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack47.ads gcc-3.3/gcc/ada/s-pack47.ads *** gcc-3.2.3/gcc/ada/s-pack47.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack47.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack48.adb gcc-3.3/gcc/ada/s-pack48.adb *** gcc-3.2.3/gcc/ada/s-pack48.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack48.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack48.ads gcc-3.3/gcc/ada/s-pack48.ads *** gcc-3.2.3/gcc/ada/s-pack48.ads 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack48.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack49.adb gcc-3.3/gcc/ada/s-pack49.adb *** gcc-3.2.3/gcc/ada/s-pack49.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack49.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack49.ads gcc-3.3/gcc/ada/s-pack49.ads *** gcc-3.2.3/gcc/ada/s-pack49.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack49.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack50.adb gcc-3.3/gcc/ada/s-pack50.adb *** gcc-3.2.3/gcc/ada/s-pack50.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack50.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack50.ads gcc-3.3/gcc/ada/s-pack50.ads *** gcc-3.2.3/gcc/ada/s-pack50.ads 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack50.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack51.adb gcc-3.3/gcc/ada/s-pack51.adb *** gcc-3.2.3/gcc/ada/s-pack51.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack51.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack51.ads gcc-3.3/gcc/ada/s-pack51.ads *** gcc-3.2.3/gcc/ada/s-pack51.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack51.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack52.adb gcc-3.3/gcc/ada/s-pack52.adb *** gcc-3.2.3/gcc/ada/s-pack52.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack52.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack52.ads gcc-3.3/gcc/ada/s-pack52.ads *** gcc-3.2.3/gcc/ada/s-pack52.ads 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack52.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack53.adb gcc-3.3/gcc/ada/s-pack53.adb *** gcc-3.2.3/gcc/ada/s-pack53.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack53.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack53.ads gcc-3.3/gcc/ada/s-pack53.ads *** gcc-3.2.3/gcc/ada/s-pack53.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack53.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack54.adb gcc-3.3/gcc/ada/s-pack54.adb *** gcc-3.2.3/gcc/ada/s-pack54.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack54.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack54.ads gcc-3.3/gcc/ada/s-pack54.ads *** gcc-3.2.3/gcc/ada/s-pack54.ads 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack54.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack55.adb gcc-3.3/gcc/ada/s-pack55.adb *** gcc-3.2.3/gcc/ada/s-pack55.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack55.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack55.ads gcc-3.3/gcc/ada/s-pack55.ads *** gcc-3.2.3/gcc/ada/s-pack55.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack55.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack56.adb gcc-3.3/gcc/ada/s-pack56.adb *** gcc-3.2.3/gcc/ada/s-pack56.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack56.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack56.ads gcc-3.3/gcc/ada/s-pack56.ads *** gcc-3.2.3/gcc/ada/s-pack56.ads 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack56.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack57.adb gcc-3.3/gcc/ada/s-pack57.adb *** gcc-3.2.3/gcc/ada/s-pack57.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack57.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack57.ads gcc-3.3/gcc/ada/s-pack57.ads *** gcc-3.2.3/gcc/ada/s-pack57.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack57.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack58.adb gcc-3.3/gcc/ada/s-pack58.adb *** gcc-3.2.3/gcc/ada/s-pack58.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack58.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack58.ads gcc-3.3/gcc/ada/s-pack58.ads *** gcc-3.2.3/gcc/ada/s-pack58.ads 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack58.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack59.adb gcc-3.3/gcc/ada/s-pack59.adb *** gcc-3.2.3/gcc/ada/s-pack59.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack59.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack59.ads gcc-3.3/gcc/ada/s-pack59.ads *** gcc-3.2.3/gcc/ada/s-pack59.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack59.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack60.adb gcc-3.3/gcc/ada/s-pack60.adb *** gcc-3.2.3/gcc/ada/s-pack60.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack60.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack60.ads gcc-3.3/gcc/ada/s-pack60.ads *** gcc-3.2.3/gcc/ada/s-pack60.ads 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack60.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack61.adb gcc-3.3/gcc/ada/s-pack61.adb *** gcc-3.2.3/gcc/ada/s-pack61.adb 2002-05-04 03:28:45.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack61.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack61.ads gcc-3.3/gcc/ada/s-pack61.ads *** gcc-3.2.3/gcc/ada/s-pack61.ads 2002-05-07 08:22:27.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack61.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack62.adb gcc-3.3/gcc/ada/s-pack62.adb *** gcc-3.2.3/gcc/ada/s-pack62.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack62.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack62.ads gcc-3.3/gcc/ada/s-pack62.ads *** gcc-3.2.3/gcc/ada/s-pack62.ads 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack62.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack63.adb gcc-3.3/gcc/ada/s-pack63.adb *** gcc-3.2.3/gcc/ada/s-pack63.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack63.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pack63.ads gcc-3.3/gcc/ada/s-pack63.ads *** gcc-3.2.3/gcc/ada/s-pack63.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-pack63.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-parame.adb gcc-3.3/gcc/ada/s-parame.adb *** gcc-3.2.3/gcc/ada/s-parame.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-parame.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1995-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-parame.ads gcc-3.3/gcc/ada/s-parame.ads *** gcc-3.2.3/gcc/ada/s-parame.ads 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-parame.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** pragma Pure (Parameters); *** 133,136 **** --- 132,190 ---- Garbage_Collected : constant Boolean := False; -- The storage mode for this system (release on program exit) + --------------------- + -- Tasking Profile -- + --------------------- + + -- In the following sections, constant parameters are defined to + -- allow some optimizations within the tasking run time based on + -- restrictions on the tasking features. + + ---------------------- + -- Locking Strategy -- + ---------------------- + + Single_Lock : constant Boolean := False; + -- Indicates whether a single lock should be used within the tasking + -- run-time to protect internal structures. If True, a single lock + -- will be used, meaning less locking/unlocking operations, but also + -- more global contention. In general, Single_Lock should be set to + -- True on single processor machines, and to False to multi-processor + -- systems, but this can vary from application to application and also + -- depends on the scheduling policy. + + ------------------- + -- Task Abortion -- + ------------------- + + No_Abort : constant Boolean := False; + -- This constant indicates whether abort statements and asynchronous + -- transfer of control (ATC) are disallowed. If set to True, it is + -- assumed that neither construct is used, and the run time does not + -- need to defer/undefer abort and check for pending actions at + -- completion points. A value of True for No_Abort corresponds to: + -- pragma Restrictions (No_Abort_Statements); + -- pragma Restrictions (Max_Asynchronous_Select_Nesting => 0); + + ---------------------- + -- Dynamic Priority -- + ---------------------- + + Dynamic_Priority_Support : constant Boolean := True; + -- This constant indicates whether dynamic changes of task priorities + -- are allowed (True means normal RM mode in which such changes are + -- allowed). In particular, if this is False, then we do not need to + -- poll for pending base priority changes at every abort completion + -- point. A value of False for Dynamic_Priority_Support corresponds + -- to pragma Restrictions (No_Dynamic_Priorities); + + -------------------- + -- Runtime Traces -- + -------------------- + + Runtime_Traces : constant Boolean := False; + -- This constant indicates whether the runtime outputs traces to a + -- predefined output or not (True means that traces are output). + -- See System.Traces for more details. + end System.Parameters; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-parint.adb gcc-3.3/gcc/ada/s-parint.adb *** gcc-3.2.3/gcc/ada/s-parint.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-parint.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 7,15 **** -- B o d y -- -- (Dummy body for non-distributed case) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1995-2000 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 7,14 ---- -- B o d y -- -- (Dummy body for non-distributed case) -- -- -- -- -- ! -- Copyright (C) 1995-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 36,41 **** --- 35,42 ---- package body System.Partition_Interface is + pragma Warnings (Off); -- supress warnings for unreferenced formals + M : constant := 7; type String_Access is access String; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-parint.ads gcc-3.3/gcc/ada/s-parint.ads *** gcc-3.2.3/gcc/ada/s-parint.ads 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-parint.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1995-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pooglo.adb gcc-3.3/gcc/ada/s-pooglo.adb *** gcc-3.2.3/gcc/ada/s-pooglo.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-pooglo.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body System.Pool_Global is *** 51,57 **** --- 50,60 ---- Storage_Size : SSE.Storage_Count; Alignment : SSE.Storage_Count) is + pragma Warnings (Off, Pool); + pragma Warnings (Off, Alignment); + Allocated : System.Address; + begin Allocated := Memory.Alloc (Memory.size_t (Storage_Size)); *************** package body System.Pool_Global is *** 74,80 **** (Pool : in out Unbounded_No_Reclaim_Pool; Address : System.Address; Storage_Size : SSE.Storage_Count; ! Alignment : SSE.Storage_Count) is begin Memory.Free (Address); end Deallocate; --- 77,88 ---- (Pool : in out Unbounded_No_Reclaim_Pool; Address : System.Address; Storage_Size : SSE.Storage_Count; ! Alignment : SSE.Storage_Count) ! is ! pragma Warnings (Off, Pool); ! pragma Warnings (Off, Storage_Size); ! pragma Warnings (Off, Alignment); ! begin Memory.Free (Address); end Deallocate; *************** package body System.Pool_Global is *** 87,92 **** --- 95,102 ---- (Pool : Unbounded_No_Reclaim_Pool) return SSE.Storage_Count is + pragma Warnings (Off, Pool); + begin -- Intuitively, should return System.Memory_Size. But on Sun/Alsys, -- System.Memory_Size > System.Max_Int, which means all you can do with diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pooglo.ads gcc-3.3/gcc/ada/s-pooglo.ads *** gcc-3.2.3/gcc/ada/s-pooglo.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-pooglo.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pooloc.adb gcc-3.3/gcc/ada/s-pooloc.adb *** gcc-3.2.3/gcc/ada/s-pooloc.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-pooloc.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body System.Pool_Local is *** 68,75 **** Storage_Size : SSE.Storage_Count; Alignment : SSE.Storage_Count) is Allocated : constant System.Address := ! Memory.Alloc (Memory.size_t (Storage_Size + Pointers_Size)); begin -- The call to Alloc returns an address whose alignment is compatible --- 67,77 ---- Storage_Size : SSE.Storage_Count; Alignment : SSE.Storage_Count) is + pragma Warnings (Off, Alignment); + Allocated : constant System.Address := ! Memory.Alloc ! (Memory.size_t (Storage_Size + Pointers_Size)); begin -- The call to Alloc returns an address whose alignment is compatible *************** package body System.Pool_Local is *** 101,107 **** --- 103,113 ---- Storage_Size : SSE.Storage_Count; Alignment : SSE.Storage_Count) is + pragma Warnings (Off, Storage_Size); + pragma Warnings (Off, Alignment); + Allocated : constant System.Address := Address - Pointers_Size; + begin if Prev (Allocated).all = Null_Address then Pool.First := Next (Allocated).all; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-pooloc.ads gcc-3.3/gcc/ada/s-pooloc.ads *** gcc-3.2.3/gcc/ada/s-pooloc.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-pooloc.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-poosiz.adb gcc-3.3/gcc/ada/s-poosiz.adb *** gcc-3.2.3/gcc/ada/s-poosiz.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-poosiz.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-poosiz.ads gcc-3.3/gcc/ada/s-poosiz.ads *** gcc-3.2.3/gcc/ada/s-poosiz.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-poosiz.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-powtab.ads gcc-3.3/gcc/ada/s-powtab.ads *** gcc-3.2.3/gcc/ada/s-powtab.ads 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-powtab.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sprint.adb gcc-3.3/gcc/ada/sprint.adb *** gcc-3.2.3/gcc/ada/sprint.adb 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/sprint.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** *** 28,33 **** --- 27,33 ---- with Atree; use Atree; with Casing; use Casing; + with Csets; use Csets; with Debug; use Debug; with Einfo; use Einfo; with Lib; use Lib; *************** with Output; use Output; *** 38,44 **** with Rtsfind; use Rtsfind; with Sinfo; use Sinfo; with Sinput; use Sinput; ! with Sinput.L; use Sinput.L; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; --- 38,44 ---- with Rtsfind; use Rtsfind; with Sinfo; use Sinfo; with Sinput; use Sinput; ! with Sinput.D; use Sinput.D; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; *************** package body Sprint is *** 81,86 **** --- 81,135 ---- -- Keep track of freeze indent level (controls blank lines before -- procedures within expression freeze actions) + ------------------------------- + -- Operator Precedence Table -- + ------------------------------- + + -- This table is used to decide whether a subexpression needs to be + -- parenthesized. The rule is that if an operand of an operator (which + -- for this purpose includes AND THEN and OR ELSE) is itself an operator + -- with a lower precedence than the operator (or equal precedence if + -- appearing as the right operand), then parentheses are required. + + Op_Prec : array (N_Subexpr) of Short_Short_Integer := + (N_Op_And => 1, + N_Op_Or => 1, + N_Op_Xor => 1, + N_And_Then => 1, + N_Or_Else => 1, + + N_In => 2, + N_Not_In => 2, + N_Op_Eq => 2, + N_Op_Ge => 2, + N_Op_Gt => 2, + N_Op_Le => 2, + N_Op_Lt => 2, + N_Op_Ne => 2, + + N_Op_Add => 3, + N_Op_Concat => 3, + N_Op_Subtract => 3, + N_Op_Plus => 3, + N_Op_Minus => 3, + + N_Op_Divide => 4, + N_Op_Mod => 4, + N_Op_Rem => 4, + N_Op_Multiply => 4, + + N_Op_Expon => 5, + N_Op_Abs => 5, + N_Op_Not => 5, + + others => 6); + + procedure Sprint_Left_Opnd (N : Node_Id); + -- Print left operand of operator, parenthesizing if necessary + + procedure Sprint_Right_Opnd (N : Node_Id); + -- Print right operand of operator, parenthesizing if necessary + ----------------------- -- Local Subprograms -- ----------------------- *************** package body Sprint is *** 102,109 **** procedure Indent_End; -- Decrease indentation level ! procedure Print_Eol; ! -- Terminate current line in line buffer procedure Process_TFAI_RR_Flags (Nod : Node_Id); -- Given a divide, multiplication or division node, check the flags --- 151,159 ---- procedure Indent_End; -- Decrease indentation level ! procedure Print_Debug_Line (S : String); ! -- Used to print output lines in Debug_Generated_Code mode (this is used ! -- as the argument for a call to Set_Special_Output in package Output). procedure Process_TFAI_RR_Flags (Nod : Node_Id); -- Given a divide, multiplication or division node, check the flags *************** package body Sprint is *** 133,138 **** --- 183,191 ---- -- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is -- called to ensure that the current node has a proper Sloc set. + procedure Write_Condition_And_Reason (Node : Node_Id); + -- Write Condition and Reason codes of Raise_xxx_Error node + procedure Write_Discr_Specs (N : Node_Id); -- Output discriminant specification for node, which is any of the type -- declarations that can have discriminants. *************** package body Sprint is *** 269,318 **** end Indent_End; -------- ! -- PG -- -------- ! procedure PG (Node : Node_Id) is begin Dump_Generated_Only := True; Dump_Original_Only := False; Sprint_Node (Node); ! Print_Eol; ! end PG; -------- ! -- PO -- -------- ! procedure PO (Node : Node_Id) is begin Dump_Generated_Only := False; Dump_Original_Only := True; Sprint_Node (Node); ! Print_Eol; ! end PO; ! --------------- ! -- Print_Eol -- ! --------------- ! procedure Print_Eol is begin ! -- If we are writing a debug source file, then grab it from the ! -- Output buffer, and reset the column counter (the routines in ! -- Output never actually write any output for us in this mode, ! -- they just build line images in Buffer). ! ! if Debug_Generated_Code then ! Write_Debug_Line (Buffer (1 .. Natural (Column) - 1), Debug_Sloc); ! Column := 1; ! ! -- In normal mode, we call Write_Eol to write the line normally ! ! else ! Write_Eol; ! end if; ! end Print_Eol; --------------------------- -- Process_TFAI_RR_Flags -- --- 322,358 ---- end Indent_End; -------- ! -- pg -- -------- ! procedure pg (Node : Node_Id) is begin Dump_Generated_Only := True; Dump_Original_Only := False; Sprint_Node (Node); ! Write_Eol; ! end pg; -------- ! -- po -- -------- ! procedure po (Node : Node_Id) is begin Dump_Generated_Only := False; Dump_Original_Only := True; Sprint_Node (Node); ! Write_Eol; ! end po; ! ---------------------- ! -- Print_Debug_Line -- ! ---------------------- ! procedure Print_Debug_Line (S : String) is begin ! Write_Debug_Line (S, Debug_Sloc); ! end Print_Debug_Line; --------------------------- -- Process_TFAI_RR_Flags -- *************** package body Sprint is *** 330,345 **** end Process_TFAI_RR_Flags; -------- ! -- PS -- -------- ! procedure PS (Node : Node_Id) is begin Dump_Generated_Only := False; Dump_Original_Only := False; Sprint_Node (Node); ! Print_Eol; ! end PS; -------------------- -- Set_Debug_Sloc -- --- 370,385 ---- end Process_TFAI_RR_Flags; -------- ! -- ps -- -------- ! procedure ps (Node : Node_Id) is begin Dump_Generated_Only := False; Dump_Original_Only := False; Sprint_Node (Node); ! Write_Eol; ! end ps; -------------------- -- Set_Debug_Sloc -- *************** package body Sprint is *** 366,378 **** Col : constant Int := Column; begin ! Print_Eol; while Col > Column loop Write_Char ('-'); end loop; ! Print_Eol; end Underline; -- Start of processing for Tree_Dump. --- 406,418 ---- Col : constant Int := Column; begin ! Write_Eol; while Col > Column loop Write_Char ('-'); end loop; ! Write_Eol; end Underline; -- Start of processing for Tree_Dump. *************** package body Sprint is *** 391,403 **** if Debug_Flag_Z then Debug_Flag_Z := False; ! Print_Eol; ! Print_Eol; Write_Str ("Source recreated from tree of Standard (spec)"); Underline; Sprint_Node (Standard_Package_Node); ! Print_Eol; ! Print_Eol; end if; if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then --- 431,443 ---- if Debug_Flag_Z then Debug_Flag_Z := False; ! Write_Eol; ! Write_Eol; Write_Str ("Source recreated from tree of Standard (spec)"); Underline; Sprint_Node (Standard_Package_Node); ! Write_Eol; ! Write_Eol; end if; if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then *************** package body Sprint is *** 418,427 **** -- If we are generating debug files, setup to write them if Debug_Generated_Code then Create_Debug_Source (Source_Index (U), Debug_Sloc); Sprint_Node (Cunit (U)); ! Print_Eol; Close_Debug_Source; -- Normal output to standard output file --- 458,469 ---- -- If we are generating debug files, setup to write them if Debug_Generated_Code then + Set_Special_Output (Print_Debug_Line'Access); Create_Debug_Source (Source_Index (U), Debug_Sloc); Sprint_Node (Cunit (U)); ! Write_Eol; Close_Debug_Source; + Set_Special_Output (null); -- Normal output to standard output file *************** package body Sprint is *** 495,500 **** --- 537,562 ---- Indent_End; end Sprint_Indented_List; + --------------------- + -- Sprint_Left_Opnd -- + --------------------- + + procedure Sprint_Left_Opnd (N : Node_Id) is + Opnd : constant Node_Id := Left_Opnd (N); + + begin + if Paren_Count (Opnd) /= 0 + or else Op_Prec (Nkind (Opnd)) >= Op_Prec (Nkind (N)) + then + Sprint_Node (Opnd); + + else + Write_Char ('('); + Sprint_Node (Opnd); + Write_Char (')'); + end if; + end Sprint_Left_Opnd; + ----------------- -- Sprint_Node -- ----------------- *************** package body Sprint is *** 722,730 **** end if; when N_And_Then => ! Sprint_Node (Left_Opnd (Node)); Write_Str_Sloc (" and then "); ! Sprint_Node (Right_Opnd (Node)); when N_At_Clause => Write_Indent_Str_Sloc ("for "); --- 784,792 ---- end if; when N_And_Then => ! Sprint_Left_Opnd (Node); Write_Str_Sloc (" and then "); ! Sprint_Right_Opnd (Node); when N_At_Clause => Write_Indent_Str_Sloc ("for "); *************** package body Sprint is *** 1466,1474 **** end if; when N_In => ! Sprint_Node (Left_Opnd (Node)); Write_Str_Sloc (" in "); ! Sprint_Node (Right_Opnd (Node)); when N_Incomplete_Type_Declaration => Write_Indent_Str_Sloc ("type "); --- 1528,1536 ---- end if; when N_In => ! Sprint_Left_Opnd (Node); Write_Str_Sloc (" in "); ! Sprint_Right_Opnd (Node); when N_Incomplete_Type_Declaration => Write_Indent_Str_Sloc ("type "); *************** package body Sprint is *** 1565,1573 **** Sprint_Node (Expression (Node)); when N_Not_In => ! Sprint_Node (Left_Opnd (Node)); Write_Str_Sloc (" not in "); ! Sprint_Node (Right_Opnd (Node)); when N_Null => Write_Str_With_Col_Check_Sloc ("null"); --- 1627,1635 ---- Sprint_Node (Expression (Node)); when N_Not_In => ! Sprint_Left_Opnd (Node); Write_Str_Sloc (" not in "); ! Sprint_Right_Opnd (Node); when N_Null => Write_Str_With_Col_Check_Sloc ("null"); *************** package body Sprint is *** 1648,1755 **** when N_Op_Abs => Write_Operator (Node, "abs "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Add => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " + "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_And => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " and "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Concat => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " & "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Divide => ! Sprint_Node (Left_Opnd (Node)); Write_Char (' '); Process_TFAI_RR_Flags (Node); Write_Operator (Node, "/ "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Eq => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " = "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Expon => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " ** "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Ge => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " >= "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Gt => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " > "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Le => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " <= "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Lt => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " < "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Minus => Write_Operator (Node, "-"); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Mod => ! Sprint_Node (Left_Opnd (Node)); if Treat_Fixed_As_Integer (Node) then Write_Str (" #"); end if; Write_Operator (Node, " mod "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Multiply => ! Sprint_Node (Left_Opnd (Node)); Write_Char (' '); Process_TFAI_RR_Flags (Node); Write_Operator (Node, "* "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Ne => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " /= "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Not => Write_Operator (Node, "not "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Or => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " or "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Plus => Write_Operator (Node, "+"); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Rem => ! Sprint_Node (Left_Opnd (Node)); if Treat_Fixed_As_Integer (Node) then Write_Str (" #"); end if; Write_Operator (Node, " rem "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Shift => Set_Debug_Sloc; --- 1710,1817 ---- when N_Op_Abs => Write_Operator (Node, "abs "); ! Sprint_Right_Opnd (Node); when N_Op_Add => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " + "); ! Sprint_Right_Opnd (Node); when N_Op_And => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " and "); ! Sprint_Right_Opnd (Node); when N_Op_Concat => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " & "); ! Sprint_Right_Opnd (Node); when N_Op_Divide => ! Sprint_Left_Opnd (Node); Write_Char (' '); Process_TFAI_RR_Flags (Node); Write_Operator (Node, "/ "); ! Sprint_Right_Opnd (Node); when N_Op_Eq => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " = "); ! Sprint_Right_Opnd (Node); when N_Op_Expon => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " ** "); ! Sprint_Right_Opnd (Node); when N_Op_Ge => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " >= "); ! Sprint_Right_Opnd (Node); when N_Op_Gt => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " > "); ! Sprint_Right_Opnd (Node); when N_Op_Le => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " <= "); ! Sprint_Right_Opnd (Node); when N_Op_Lt => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " < "); ! Sprint_Right_Opnd (Node); when N_Op_Minus => Write_Operator (Node, "-"); ! Sprint_Right_Opnd (Node); when N_Op_Mod => ! Sprint_Left_Opnd (Node); if Treat_Fixed_As_Integer (Node) then Write_Str (" #"); end if; Write_Operator (Node, " mod "); ! Sprint_Right_Opnd (Node); when N_Op_Multiply => ! Sprint_Left_Opnd (Node); Write_Char (' '); Process_TFAI_RR_Flags (Node); Write_Operator (Node, "* "); ! Sprint_Right_Opnd (Node); when N_Op_Ne => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " /= "); ! Sprint_Right_Opnd (Node); when N_Op_Not => Write_Operator (Node, "not "); ! Sprint_Right_Opnd (Node); when N_Op_Or => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " or "); ! Sprint_Right_Opnd (Node); when N_Op_Plus => Write_Operator (Node, "+"); ! Sprint_Right_Opnd (Node); when N_Op_Rem => ! Sprint_Left_Opnd (Node); if Treat_Fixed_As_Integer (Node) then Write_Str (" #"); end if; Write_Operator (Node, " rem "); ! Sprint_Right_Opnd (Node); when N_Op_Shift => Set_Debug_Sloc; *************** package body Sprint is *** 1762,1775 **** Write_Char (')'); when N_Op_Subtract => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " - "); ! Sprint_Node (Right_Opnd (Node)); when N_Op_Xor => ! Sprint_Node (Left_Opnd (Node)); Write_Operator (Node, " xor "); ! Sprint_Node (Right_Opnd (Node)); when N_Operator_Symbol => Write_Name_With_Col_Check_Sloc (Chars (Node)); --- 1824,1837 ---- Write_Char (')'); when N_Op_Subtract => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " - "); ! Sprint_Right_Opnd (Node); when N_Op_Xor => ! Sprint_Left_Opnd (Node); Write_Operator (Node, " xor "); ! Sprint_Right_Opnd (Node); when N_Operator_Symbol => Write_Name_With_Col_Check_Sloc (Chars (Node)); *************** package body Sprint is *** 1780,1788 **** Sprint_Opt_Node (Real_Range_Specification (Node)); when N_Or_Else => ! Sprint_Node (Left_Opnd (Node)); Write_Str_Sloc (" or else "); ! Sprint_Node (Right_Opnd (Node)); when N_Others_Choice => if All_Others (Node) then --- 1842,1850 ---- Sprint_Opt_Node (Real_Range_Specification (Node)); when N_Or_Else => ! Sprint_Left_Opnd (Node); Write_Str_Sloc (" or else "); ! Sprint_Right_Opnd (Node); when N_Others_Choice => if All_Others (Node) then *************** package body Sprint is *** 1991,1997 **** when N_Qualified_Expression => Sprint_Node (Subtype_Mark (Node)); Write_Char_Sloc ('''); ! Sprint_Node (Expression (Node)); when N_Raise_Constraint_Error => --- 2053,2072 ---- when N_Qualified_Expression => Sprint_Node (Subtype_Mark (Node)); Write_Char_Sloc ('''); ! ! -- Print expression, make sure we have at least one level of ! -- parentheses around the expression. For cases of qualified ! -- expressions in the source, this is always the case, but ! -- for generated qualifications, there may be no explicit ! -- parentheses present. ! ! if Paren_Count (Expression (Node)) /= 0 then ! Sprint_Node (Expression (Node)); ! else ! Write_Char ('('); ! Sprint_Node (Expression (Node)); ! Write_Char (')'); ! end if; when N_Raise_Constraint_Error => *************** package body Sprint is *** 2006,2040 **** end if; Write_Str_With_Col_Check_Sloc ("[constraint_error"); ! ! if Present (Condition (Node)) then ! Write_Str_With_Col_Check (" when "); ! Sprint_Node (Condition (Node)); ! end if; ! ! Write_Char (']'); when N_Raise_Program_Error => - Write_Indent; - Write_Str_With_Col_Check_Sloc ("[program_error"); ! if Present (Condition (Node)) then ! Write_Str_With_Col_Check (" when "); ! Sprint_Node (Condition (Node)); end if; ! Write_Char (']'); when N_Raise_Storage_Error => - Write_Indent; - Write_Str_With_Col_Check_Sloc ("[storage_error"); ! if Present (Condition (Node)) then ! Write_Str_With_Col_Check (" when "); ! Sprint_Node (Condition (Node)); end if; ! Write_Char (']'); when N_Raise_Statement => Write_Indent_Str_Sloc ("raise "); --- 2081,2117 ---- end if; Write_Str_With_Col_Check_Sloc ("[constraint_error"); ! Write_Condition_And_Reason (Node); when N_Raise_Program_Error => ! -- This node can be used either as a subexpression or as a ! -- statement form. The following test is a reasonably reliable ! -- way to distinguish the two cases. ! ! if Is_List_Member (Node) ! and then Nkind (Parent (Node)) not in N_Subexpr ! then ! Write_Indent; end if; ! Write_Str_With_Col_Check_Sloc ("[program_error"); ! Write_Condition_And_Reason (Node); when N_Raise_Storage_Error => ! -- This node can be used either as a subexpression or as a ! -- statement form. The following test is a reasonably reliable ! -- way to distinguish the two cases. ! ! if Is_List_Member (Node) ! and then Nkind (Parent (Node)) not in N_Subexpr ! then ! Write_Indent; end if; ! Write_Str_With_Col_Check_Sloc ("[storage_error"); ! Write_Condition_And_Reason (Node); when N_Raise_Statement => Write_Indent_Str_Sloc ("raise "); *************** package body Sprint is *** 2248,2254 **** Write_Indent_Str_Sloc ("separate ("); Sprint_Node (Name (Node)); Write_Char (')'); ! Print_Eol; Sprint_Node (Proper_Body (Node)); when N_Task_Body => --- 2325,2331 ---- Write_Indent_Str_Sloc ("separate ("); Sprint_Node (Name (Node)); Write_Char (')'); ! Write_Eol; Sprint_Node (Proper_Body (Node)); when N_Task_Body => *************** package body Sprint is *** 2381,2387 **** when N_Unused_At_Start | N_Unused_At_End => Write_Indent_Str ("***** Error, unused node encountered *****"); ! Print_Eol; when N_Use_Package_Clause => Write_Indent_Str_Sloc ("use "); --- 2458,2464 ---- when N_Unused_At_Start | N_Unused_At_End => Write_Indent_Str ("***** Error, unused node encountered *****"); ! Write_Eol; when N_Use_Package_Clause => Write_Indent_Str_Sloc ("use "); *************** package body Sprint is *** 2573,2578 **** --- 2650,2675 ---- end if; end Sprint_Paren_Comma_List; + ---------------------- + -- Sprint_Right_Opnd -- + ---------------------- + + procedure Sprint_Right_Opnd (N : Node_Id) is + Opnd : constant Node_Id := Right_Opnd (N); + + begin + if Paren_Count (Opnd) /= 0 + or else Op_Prec (Nkind (Opnd)) > Op_Prec (Nkind (N)) + then + Sprint_Node (Opnd); + + else + Write_Char ('('); + Sprint_Node (Opnd); + Write_Char (')'); + end if; + end Sprint_Right_Opnd; + --------------------- -- Write_Char_Sloc -- --------------------- *************** package body Sprint is *** 2586,2591 **** --- 2683,2716 ---- Write_Char (C); end Write_Char_Sloc; + -------------------------------- + -- Write_Condition_And_Reason -- + -------------------------------- + + procedure Write_Condition_And_Reason (Node : Node_Id) is + Image : constant String := RT_Exception_Code'Image + (RT_Exception_Code'Val + (UI_To_Int (Reason (Node)))); + + begin + if Present (Condition (Node)) then + Write_Str_With_Col_Check (" when "); + Sprint_Node (Condition (Node)); + end if; + + Write_Str (" """); + + for J in 4 .. Image'Last loop + if Image (J) = '_' then + Write_Char (' '); + else + Write_Char (Fold_Lower (Image (J))); + end if; + end loop; + + Write_Str ("""]"); + end Write_Condition_And_Reason; + ------------------------ -- Write_Discr_Specs -- ------------------------ *************** package body Sprint is *** 2756,2762 **** if Indent_Annull_Flag then Indent_Annull_Flag := False; else ! Print_Eol; for J in 1 .. Indent loop Write_Char (' '); end loop; --- 2881,2888 ---- if Indent_Annull_Flag then Indent_Annull_Flag := False; else ! Write_Eol; ! for J in 1 .. Indent loop Write_Char (' '); end loop; *************** package body Sprint is *** 2909,2933 **** T : Natural := S'Last; begin ! if S (F) = ' ' then ! Write_Char (' '); ! F := F + 1; ! end if; ! if S (T) = ' ' then ! T := T - 1; ! end if; - if Do_Overflow_Check (N) then Write_Char ('{'); Write_Str_Sloc (S (F .. T)); Write_Char ('}'); - else - Write_Str_Sloc (S); - end if; ! if S (S'Last) = ' ' then ! Write_Char (' '); end if; end Write_Operator; --- 3035,3065 ---- T : Natural := S'Last; begin ! -- If no overflow check, just write string out, and we are done ! if not Do_Overflow_Check (N) then ! Write_Str_Sloc (S); ! ! -- If overflow check, we want to surround the operator with curly ! -- brackets, but not include spaces within the brackets. ! ! else ! if S (F) = ' ' then ! Write_Char (' '); ! F := F + 1; ! end if; ! ! if S (T) = ' ' then ! T := T - 1; ! end if; Write_Char ('{'); Write_Str_Sloc (S (F .. T)); Write_Char ('}'); ! if S (S'Last) = ' ' then ! Write_Char (' '); ! end if; end if; end Write_Operator; diff -Nrc3pad gcc-3.2.3/gcc/ada/sprint.ads gcc-3.3/gcc/ada/sprint.ads *** gcc-3.2.3/gcc/ada/sprint.ads 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/sprint.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-1999, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package Sprint is *** 67,73 **** -- Multiply wi Treat_Fixed_As_Integer x #* y -- Multiply wi Rounded_Result x @* y -- Others choice for cleanup when all others ! -- Raise xxx error [xxx_error [when condition]] -- Rational literal See UR_Write for details -- Rem wi Treat_Fixed_As_Integer x #rem y -- Reference expression'reference --- 66,73 ---- -- Multiply wi Treat_Fixed_As_Integer x #* y -- Multiply wi Rounded_Result x @* y -- Others choice for cleanup when all others ! -- Raise xxx error [xxx_error [when cond]] ! -- Raise xxx error with msg [xxx_error [when cond], "msg"] -- Rational literal See UR_Write for details -- Rem wi Treat_Fixed_As_Integer x #rem y -- Reference expression'reference *************** package Sprint is *** 133,147 **** -- Same as normal Sprint_Node procedure, except that one leading -- blank is output before the node if it is non-empty. ! procedure PG (Node : Node_Id); -- Print generated source for node N (like -gnatdg output). This is -- intended only for use from gdb for debugging purposes. ! procedure PO (Node : Node_Id); -- Print original source for node N (like -gnatdo output). This is -- intended only for use from gdb for debugging purposes. ! procedure PS (Node : Node_Id); -- Print generated and original source for node N (like -gnatds output). -- This is intended only for use from gdb for debugging purposes. --- 133,150 ---- -- Same as normal Sprint_Node procedure, except that one leading -- blank is output before the node if it is non-empty. ! procedure pg (Node : Node_Id); ! pragma Export (Ada, pg); -- Print generated source for node N (like -gnatdg output). This is -- intended only for use from gdb for debugging purposes. ! procedure po (Node : Node_Id); ! pragma Export (Ada, po); -- Print original source for node N (like -gnatdo output). This is -- intended only for use from gdb for debugging purposes. ! procedure ps (Node : Node_Id); ! pragma Export (Ada, ps); -- Print generated and original source for node N (like -gnatds output). -- This is intended only for use from gdb for debugging purposes. diff -Nrc3pad gcc-3.2.3/gcc/ada/s-proinf.adb gcc-3.3/gcc/ada/s-proinf.adb *** gcc-3.2.3/gcc/ada/s-proinf.adb 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-proinf.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-proinf.ads gcc-3.3/gcc/ada/s-proinf.ads *** gcc-3.2.3/gcc/ada/s-proinf.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-proinf.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-rpc.adb gcc-3.3/gcc/ada/s-rpc.adb *** gcc-3.2.3/gcc/ada/s-rpc.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-rpc.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** with Ada.Exceptions; use Ada.Exceptions; *** 46,51 **** --- 45,51 ---- package body System.RPC is GNAT : constant Boolean := True; + pragma Unreferenced (GNAT); -- This dummy entity allows the compiler to recognize that this is the -- version of this package that is supplied by GNAT, not by the user. -- This is used to cause a compile time error if an attempt is made to *************** package body System.RPC is *** 85,91 **** Raise_Exception (Program_Error'Identity, Msg); end Write; - ------------ -- Do_RPC -- ------------ --- 85,90 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-rpc.ads gcc-3.3/gcc/ada/s-rpc.ads *** gcc-3.2.3/gcc/ada/s-rpc.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-rpc.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-scaval.ads gcc-3.3/gcc/ada/s-scaval.ads *** gcc-3.2.3/gcc/ada/s-scaval.ads 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-scaval.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 5,11 **** -- S Y S T E M . S C A L A R _ V A L U E S -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 5,10 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-secsta.adb gcc-3.3/gcc/ada/s-secsta.adb *** gcc-3.2.3/gcc/ada/s-secsta.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-secsta.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body System.Secondary_Stack is *** 109,115 **** function From_Addr is new Unchecked_Conversion (Address, Stack_Ptr); function To_Addr is new Unchecked_Conversion (Stack_Ptr, System.Address); - function To_Stack is new Unchecked_Conversion (Fixed_Stack_Ptr, Stack_Ptr); function To_Fixed is new Unchecked_Conversion (Stack_Ptr, Fixed_Stack_Ptr); procedure Free is new Unchecked_Deallocation (Chunk_Id, Chunk_Ptr); --- 108,113 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-secsta.ads gcc-3.3/gcc/ada/s-secsta.ads *** gcc-3.2.3/gcc/ada/s-secsta.ads 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-secsta.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-sequio.adb gcc-3.3/gcc/ada/s-sequio.adb *** gcc-3.2.3/gcc/ada/s-sequio.adb 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-sequio.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1998 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body System.Sequential_IO is *** 50,55 **** --- 49,56 ---- (Control_Block : Sequential_AFCB) return FCB.AFCB_Ptr is + pragma Warnings (Off, Control_Block); + begin return new Sequential_AFCB; end AFCB_Allocate; *************** package body System.Sequential_IO is *** 61,66 **** --- 62,69 ---- -- No special processing required for Sequential_IO close procedure AFCB_Close (File : access Sequential_AFCB) is + pragma Warnings (Off, File); + begin null; end AFCB_Close; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-sequio.ads gcc-3.3/gcc/ada/s-sequio.ads *** gcc-3.2.3/gcc/ada/s-sequio.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-sequio.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-shasto.adb gcc-3.3/gcc/ada/s-shasto.adb *** gcc-3.2.3/gcc/ada/s-shasto.adb 2002-05-04 03:28:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-shasto.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body System.Shared_Storage is *** 78,87 **** Shared_Var_Files_Open : Natural := 0; -- Number of shared variable access files currently open ! type File_Stream_Type is new AS.Root_Stream_Type with ! record ! File : SIO.File_Type; ! end record; type File_Stream_Access is access all File_Stream_Type'Class; procedure Read --- 77,85 ---- Shared_Var_Files_Open : Natural := 0; -- Number of shared variable access files currently open ! type File_Stream_Type is new AS.Root_Stream_Type with record ! File : SIO.File_Type; ! end record; type File_Stream_Access is access all File_Stream_Type'Class; procedure Read *************** package body System.Shared_Storage is *** 315,320 **** --- 313,319 ---- ---------------------- procedure Shared_Var_Close (Var : in SIO.Stream_Access) is + pragma Warnings (Off, Var); begin TSL.Unlock; end Shared_Var_Close; *************** package body System.Shared_Storage is *** 324,329 **** --- 323,330 ---- --------------------- procedure Shared_Var_Lock (Var : in String) is + pragma Warnings (Off, Var); + begin TSL.Lock; Initialize; *************** package body System.Shared_Storage is *** 409,414 **** --- 410,417 ---- ----------------------- procedure Shared_Var_Unlock (Var : in String) is + pragma Warnings (Off, Var); + begin TSL.Lock; Initialize; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-shasto.ads gcc-3.3/gcc/ada/s-shasto.ads *** gcc-3.2.3/gcc/ada/s-shasto.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-shasto.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-soflin.adb gcc-3.3/gcc/ada/s-soflin.adb *** gcc-3.2.3/gcc/ada/s-soflin.adb 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-soflin.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body System.Soft_Links is *** 112,119 **** SS_Ratio_Dynamic : constant Boolean := Parameters.Sec_Stack_Ratio = Parameters.Dynamic; - begin if SS_Ratio_Dynamic then SST.SS_Init (New_TSD.Sec_Stack_Addr, SST.Default_Secondary_Stack_Size); --- 111,118 ---- SS_Ratio_Dynamic : constant Boolean := Parameters.Sec_Stack_Ratio = Parameters.Dynamic; + begin if SS_Ratio_Dynamic then SST.SS_Init (New_TSD.Sec_Stack_Addr, SST.Default_Secondary_Stack_Size); *************** package body System.Soft_Links is *** 266,271 **** --- 265,272 ---- --------------------------- procedure Set_Exc_Stack_Addr_NT (Self_ID : Address; Addr : Address) is + pragma Warnings (Off, Self_ID); + begin NT_TSD.Exc_Stack_Addr := Addr; end Set_Exc_Stack_Addr_NT; *************** package body System.Soft_Links is *** 356,361 **** --- 357,371 ---- Ada.Exceptions.Save_Occurrence (NT_TSD.Current_Excep, X); end Update_Exception_NT; + ------------------ + -- Task_Name_NT -- + ------------------- + + function Task_Name_NT return String is + begin + return "main_task"; + end Task_Name_NT; + ------------------------- -- Package Elaboration -- ------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-soflin.ads gcc-3.3/gcc/ada/s-soflin.ads *** gcc-3.2.3/gcc/ada/s-soflin.ads 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-soflin.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package System.Soft_Links is *** 84,89 **** --- 83,91 ---- type Get_Stack_Access_Call is access function return Stack_Checking.Stack_Access; + type Task_Name_Call is access + function return String; + -- Suppress checks on all these types, since we know corrresponding -- values can never be null (the soft links are always initialized). *************** package System.Soft_Links is *** 98,103 **** --- 100,106 ---- pragma Suppress (Access_Check, Set_EOA_Call); pragma Suppress (Access_Check, Timed_Delay_Call); pragma Suppress (Access_Check, Get_Stack_Access_Call); + pragma Suppress (Access_Check, Task_Name_Call); -- The following one is not related to tasking/no-tasking but to the -- traceback decorators for exceptions. *************** package System.Soft_Links is *** 258,263 **** --- 261,274 ---- Timed_Delay : Timed_Delay_Call; + -------------------------- + -- Task Name Soft-Links -- + -------------------------- + + function Task_Name_NT return String; + + Task_Name : Task_Name_Call := Task_Name_NT'Access; + ------------------------------------- -- Exception Tracebacks Soft-Links -- ------------------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-sopco3.adb gcc-3.3/gcc/ada/s-sopco3.adb *** gcc-3.2.3/gcc/ada/s-sopco3.adb 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-sopco3.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-sopco3.ads gcc-3.3/gcc/ada/s-sopco3.ads *** gcc-3.2.3/gcc/ada/s-sopco3.ads 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-sopco3.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-sopco4.adb gcc-3.3/gcc/ada/s-sopco4.adb *** gcc-3.2.3/gcc/ada/s-sopco4.adb 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-sopco4.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-sopco4.ads gcc-3.3/gcc/ada/s-sopco4.ads *** gcc-3.2.3/gcc/ada/s-sopco4.ads 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-sopco4.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-sopco5.adb gcc-3.3/gcc/ada/s-sopco5.adb *** gcc-3.2.3/gcc/ada/s-sopco5.adb 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-sopco5.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-sopco5.ads gcc-3.3/gcc/ada/s-sopco5.ads *** gcc-3.2.3/gcc/ada/s-sopco5.ads 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-sopco5.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-stache.adb gcc-3.3/gcc/ada/s-stache.adb *** gcc-3.2.3/gcc/ada/s-stache.adb 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-stache.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body System.Stack_Checking is *** 80,85 **** --- 79,86 ---- ---------------------------- procedure Invalidate_Stack_Cache (Any_Stack : Stack_Access) is + pragma Warnings (Off, Any_Stack); + begin Cache := Null_Stack; end Invalidate_Stack_Cache; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-stache.ads gcc-3.3/gcc/ada/s-stache.ads *** gcc-3.2.3/gcc/ada/s-stache.ads 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-stache.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-stalib.adb gcc-3.3/gcc/ada/s-stalib.adb *** gcc-3.2.3/gcc/ada/s-stalib.adb 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-stalib.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1995-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-stalib.ads gcc-3.3/gcc/ada/s-stalib.ads *** gcc-3.2.3/gcc/ada/s-stalib.ads 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-stalib.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-stoele.adb gcc-3.3/gcc/ada/s-stoele.adb *** gcc-3.2.3/gcc/ada/s-stoele.adb 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-stoele.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-stoele.ads gcc-3.3/gcc/ada/s-stoele.ads *** gcc-3.2.3/gcc/ada/s-stoele.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-stoele.ads 2002-03-14 10:59:58.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-stopoo.ads gcc-3.3/gcc/ada/s-stopoo.ads *** gcc-3.2.3/gcc/ada/s-stopoo.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-stopoo.ads 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-stratt.adb gcc-3.3/gcc/ada/s-stratt.adb *** gcc-3.2.3/gcc/ada/s-stratt.adb 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-stratt.adb 2002-10-23 07:33:30.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-stratt.ads gcc-3.3/gcc/ada/s-stratt.ads *** gcc-3.2.3/gcc/ada/s-stratt.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-stratt.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-strops.adb gcc-3.3/gcc/ada/s-strops.adb *** gcc-3.2.3/gcc/ada/s-strops.adb 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-strops.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-strops.ads gcc-3.3/gcc/ada/s-strops.ads *** gcc-3.2.3/gcc/ada/s-strops.ads 2002-05-04 03:28:47.000000000 +0000 --- gcc-3.3/gcc/ada/s-strops.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-taasde.adb gcc-3.3/gcc/ada/s-taasde.adb *** gcc-3.2.3/gcc/ada/s-taasde.adb 2001-10-02 14:30:17.000000000 +0000 --- gcc-3.3/gcc/ada/s-taasde.adb 2002-03-14 10:59:58.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1998-2001 Ada Core Technologies, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** with System.OS_Primitives; *** 67,72 **** --- 65,77 ---- with Ada.Task_Identification; -- used for Task_ID type + with System.Parameters; + -- used for Single_Lock + -- Runtime_Traces + + with System.Traces.Tasking; + -- used for Send_Trace_Info + with Unchecked_Conversion; package body System.Tasking.Async_Delays is *************** package body System.Tasking.Async_Delays *** 77,82 **** --- 82,91 ---- package STI renames System.Tasking.Initialization; package OSP renames System.OS_Primitives; + use Parameters; + use System.Traces; + use System.Traces.Tasking; + function To_System is new Unchecked_Conversion (Ada.Task_Identification.Task_Id, Task_ID); *************** package body System.Tasking.Async_Delays *** 127,132 **** --- 136,146 ---- -- remove self from timer queue STI.Defer_Abort_Nestable (D.Self_Id); + + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Timer_Server_ID); Dpred := D.Pred; Dsucc := D.Succ; *************** package body System.Tasking.Async_Delays *** 145,150 **** --- 159,169 ---- STPO.Write_Lock (D.Self_Id); STU.Exit_One_ATC_Level (D.Self_Id); STPO.Unlock (D.Self_Id); + + if Single_Lock then + STPO.Unlock_RTS; + end if; + STI.Undefer_Abort_Nestable (D.Self_Id); end Cancel_Async_Delay; *************** package body System.Tasking.Async_Delays *** 164,169 **** --- 183,191 ---- return False; else + -- The corresponding call to Undefer_Abort is performed by the + -- expanded code (see exp_ch9). + STI.Defer_Abort (STPO.Self); Time_Enqueue (STPO.Monotonic_Clock *************** package body System.Tasking.Async_Delays *** 219,225 **** D.Self_Id := Self_Id; D.Resume_Time := T; ! STI.Defer_Abort (Self_Id); STPO.Write_Lock (Timer_Server_ID); -- Previously, there was code here to dynamically create --- 241,250 ---- D.Self_Id := Self_Id; D.Resume_Time := T; ! if Single_Lock then ! STPO.Lock_RTS; ! end if; ! STPO.Write_Lock (Timer_Server_ID); -- Previously, there was code here to dynamically create *************** package body System.Tasking.Async_Delays *** 256,262 **** end if; STPO.Unlock (Timer_Server_ID); ! STI.Undefer_Abort (Self_Id); end Time_Enqueue; --------------- --- 281,290 ---- end if; STPO.Unlock (Timer_Server_ID); ! ! if Single_Lock then ! STPO.Unlock_RTS; ! end if; end Time_Enqueue; --------------- *************** package body System.Tasking.Async_Delays *** 273,279 **** ------------------ task body Timer_Server is ! Next_Wakeup_Time : Duration := Duration'Last; Timedout : Boolean; Yielded : Boolean; Now : Duration; --- 301,321 ---- ------------------ task body Timer_Server is ! function Get_Next_Wakeup_Time return Duration; ! -- Used to initialize Next_Wakeup_Time, but also to ensure that ! -- Make_Independent is called during the elaboration of this task ! ! -------------------------- ! -- Get_Next_Wakeup_Time -- ! -------------------------- ! ! function Get_Next_Wakeup_Time return Duration is ! begin ! STU.Make_Independent; ! return Duration'Last; ! end Get_Next_Wakeup_Time; ! ! Next_Wakeup_Time : Duration := Get_Next_Wakeup_Time; Timedout : Boolean; Yielded : Boolean; Now : Duration; *************** package body System.Tasking.Async_Delays *** 282,299 **** Tsucc : Delay_Block_Access; Dequeued_Task : Task_ID; - -- Initialize_Timer_Queue returns null, but has critical side-effects - -- of initializing the timer queue. - begin Timer_Server_ID := STPO.Self; - STU.Make_Independent; -- Initialize the timer queue to empty, and make the wakeup time of the -- header node be larger than any real wakeup time we will ever use. loop STI.Defer_Abort (Timer_Server_ID); STPO.Write_Lock (Timer_Server_ID); -- The timer server needs to catch pending aborts after finalization --- 324,342 ---- Tsucc : Delay_Block_Access; Dequeued_Task : Task_ID; begin Timer_Server_ID := STPO.Self; -- Initialize the timer queue to empty, and make the wakeup time of the -- header node be larger than any real wakeup time we will ever use. loop STI.Defer_Abort (Timer_Server_ID); + + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Timer_Server_ID); -- The timer server needs to catch pending aborts after finalization *************** package body System.Tasking.Async_Delays *** 350,355 **** --- 393,402 ---- -- the timer queue, but that is OK because we always restart the -- next iteration at the head of the queue. + if Parameters.Runtime_Traces then + Send_Trace_Info (E_Kill, Dequeued.Self_Id); + end if; + STPO.Unlock (Timer_Server_ID); STPO.Write_Lock (Dequeued.Self_Id); Dequeued_Task := Dequeued.Self_Id; *************** package body System.Tasking.Async_Delays *** 368,373 **** --- 415,425 ---- -- an actual delay in this server. STPO.Unlock (Timer_Server_ID); + + if Single_Lock then + STPO.Unlock_RTS; + end if; + STI.Undefer_Abort (Timer_Server_ID); end loop; end Timer_Server; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-taasde.ads gcc-3.3/gcc/ada/s-taasde.ads *** gcc-3.2.3/gcc/ada/s-taasde.ads 2001-10-02 14:30:17.000000000 +0000 --- gcc-3.3/gcc/ada/s-taasde.ads 2002-03-14 10:59:58.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1998-1999 Ada Core Technologies, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 34,41 **** -- -- ------------------------------------------------------------------------------ ! -- This package contains the procedures to implements timeouts (delays) on ! -- asynchronous select statements. -- Note: the compiler generates direct calls to this interface, via Rtsfind. -- Any changes to this interface may require corresponding compiler changes. --- 33,40 ---- -- -- ------------------------------------------------------------------------------ ! -- This package contains the procedures to implements timeouts (delays) ! -- for asynchronous select statements. -- Note: the compiler generates direct calls to this interface, via Rtsfind. -- Any changes to this interface may require corresponding compiler changes. diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tadeca.adb gcc-3.3/gcc/ada/s-tadeca.adb *** gcc-3.2.3/gcc/ada/s-tadeca.adb 2001-10-02 14:30:17.000000000 +0000 --- gcc-3.3/gcc/ada/s-tadeca.adb 2002-03-14 10:59:58.000000000 +0000 *************** *** 2,15 **** -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K I N G . A S Y N C _ D E L A Y S . -- ! -- E N Q U E U E _ C A L E N D A R -- -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1998-1999 Ada Core Technologies, Inc. -- -- -- -- GNARL 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- -- --- 2,13 ---- -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASKING.ASYNC_DELAYS.ENQUEUE_CALENDAR -- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** with System.Task_Primitives.Operations; *** 40,47 **** with System.Tasking.Initialization; function System.Tasking.Async_Delays.Enqueue_Calendar ! (T : in Ada.Calendar.Time; ! D : Delay_Block_Access) return Boolean is use type Ada.Calendar.Time; begin --- 38,46 ---- with System.Tasking.Initialization; function System.Tasking.Async_Delays.Enqueue_Calendar ! (T : Ada.Calendar.Time; ! D : Delay_Block_Access) ! return Boolean is use type Ada.Calendar.Time; begin diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tadeca.ads gcc-3.3/gcc/ada/s-tadeca.ads *** gcc-3.2.3/gcc/ada/s-tadeca.ads 2001-10-02 14:30:17.000000000 +0000 --- gcc-3.3/gcc/ada/s-tadeca.ads 2002-03-14 10:59:58.000000000 +0000 *************** *** 2,15 **** -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K I N G . A S Y N C _ D E L A Y S . -- ! -- E N Q U E U E _ C A L E N D A R -- -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1998-1999 Ada Core Technologies, Inc. -- -- -- -- GNARL 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- -- --- 2,13 ---- -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASKING.ASYNC_DELAYS.ENQUEUE_CALENDAR -- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 42,46 **** with Ada.Calendar; function System.Tasking.Async_Delays.Enqueue_Calendar ! (T : in Ada.Calendar.Time; ! D : Delay_Block_Access) return Boolean; --- 40,45 ---- with Ada.Calendar; function System.Tasking.Async_Delays.Enqueue_Calendar ! (T : Ada.Calendar.Time; ! D : Delay_Block_Access) ! return Boolean; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tadert.adb gcc-3.3/gcc/ada/s-tadert.adb *** gcc-3.2.3/gcc/ada/s-tadert.adb 2001-10-02 14:30:17.000000000 +0000 --- gcc-3.3/gcc/ada/s-tadert.adb 2002-03-14 10:59:58.000000000 +0000 *************** *** 2,15 **** -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K I N G . A S Y N C _ D E L A Y S . -- ! -- E N Q U E U E _ R T -- -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1998-1999 Ada Core Technologies, Inc. -- -- -- -- GNARL 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- -- --- 2,13 ---- -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASKING.ASYNC_DELAYS.ENQUEUE_RT -- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tadert.ads gcc-3.3/gcc/ada/s-tadert.ads *** gcc-3.2.3/gcc/ada/s-tadert.ads 2001-10-02 14:30:17.000000000 +0000 --- gcc-3.3/gcc/ada/s-tadert.ads 2002-03-14 10:59:58.000000000 +0000 *************** *** 2,15 **** -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K I N G . A S Y N C _ D E L A Y S . -- ! -- E N Q U E U E _ R T -- -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1998-1999 Ada Core Technologies, Inc. -- -- -- -- GNARL 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- -- --- 2,13 ---- -- -- -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASKING.ASYNC_DELAYS.ENQUEUE_RT -- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 42,46 **** with Ada.Real_Time; function System.Tasking.Async_Delays.Enqueue_RT ! (T : in Ada.Real_Time.Time; ! D : Delay_Block_Access) return Boolean; --- 40,45 ---- with Ada.Real_Time; function System.Tasking.Async_Delays.Enqueue_RT ! (T : Ada.Real_Time.Time; ! D : Delay_Block_Access) ! return Boolean; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-taenca.adb gcc-3.3/gcc/ada/s-taenca.adb *** gcc-3.2.3/gcc/ada/s-taenca.adb 2001-10-02 14:30:17.000000000 +0000 --- gcc-3.3/gcc/ada/s-taenca.adb 2002-03-14 10:59:58.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,45 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ - -- This package provides internal RTS calls implementing operations - -- that apply to general entry calls, that is, calls to either - -- protected or task entries. - - -- These declarations are not part of the GNARL interface - with System.Task_Primitives.Operations; -- used for STPO.Write_Lock -- Unlock --- 28,37 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ with System.Task_Primitives.Operations; -- used for STPO.Write_Lock -- Unlock *************** with System.Tasking.Queuing; *** 67,83 **** with System.Tasking.Utilities; -- used for Exit_One_ATC_Level package body System.Tasking.Entry_Calls is package STPO renames System.Task_Primitives.Operations; ! use System.Task_Primitives; ! use System.Tasking.Protected_Objects.Entries; ! use System.Tasking.Protected_Objects.Operations; -- DO NOT use Protected_Objects.Lock or Protected_Objects.Unlock -- internally. Those operations will raise Program_Error, which ! -- we do are not prepared to handle inside the RTS. Instead, use -- System.Task_Primitives lock operations directly on Protection.L. ----------------------- --- 59,84 ---- with System.Tasking.Utilities; -- used for Exit_One_ATC_Level + with System.Parameters; + -- used for Single_Lock + -- Runtime_Traces + + with System.Traces; + -- used for Send_Trace_Info + package body System.Tasking.Entry_Calls is package STPO renames System.Task_Primitives.Operations; ! use Parameters; ! use Task_Primitives; ! use Protected_Objects.Entries; ! use Protected_Objects.Operations; ! use System.Traces; -- DO NOT use Protected_Objects.Lock or Protected_Objects.Unlock -- internally. Those operations will raise Program_Error, which ! -- we are not prepared to handle inside the RTS. Instead, use -- System.Task_Primitives lock operations directly on Protection.L. ----------------------- *************** package body System.Tasking.Entry_Calls *** 101,123 **** -- hold an ATCB lock, something which is not permitted. Since -- the server cannot be obtained reliably, it must be obtained unreliably -- and then checked again once it has been locked. procedure Unlock_Server (Entry_Call : Entry_Call_Link); -- STPO.Unlock the server targeted by Entry_Call. The server must -- be locked before calling this. procedure Unlock_And_Update_Server (Self_ID : Task_ID; Entry_Call : Entry_Call_Link); -- Similar to Unlock_Server, but services entry calls if the -- server is a protected object. procedure Check_Pending_Actions_For_Entry_Call (Self_ID : Task_ID; Entry_Call : Entry_Call_Link); - pragma Inline (Check_Pending_Actions_For_Entry_Call); -- This procedure performs priority change of a queued call and ! -- dequeuing of an entry call when an the call is cancelled. -- If the call is dequeued the state should be set to Cancelled. procedure Poll_Base_Priority_Change_At_Entry_Call --- 102,129 ---- -- hold an ATCB lock, something which is not permitted. Since -- the server cannot be obtained reliably, it must be obtained unreliably -- and then checked again once it has been locked. + -- + -- If Single_Lock and server is a PO, release RTS_Lock. procedure Unlock_Server (Entry_Call : Entry_Call_Link); -- STPO.Unlock the server targeted by Entry_Call. The server must -- be locked before calling this. + -- + -- If Single_Lock and server is a PO, take RTS_Lock on exit. procedure Unlock_And_Update_Server (Self_ID : Task_ID; Entry_Call : Entry_Call_Link); -- Similar to Unlock_Server, but services entry calls if the -- server is a protected object. + -- + -- If Single_Lock and server is a PO, take RTS_Lock on exit. procedure Check_Pending_Actions_For_Entry_Call (Self_ID : Task_ID; Entry_Call : Entry_Call_Link); -- This procedure performs priority change of a queued call and ! -- dequeuing of an entry call when the call is cancelled. -- If the call is dequeued the state should be set to Cancelled. procedure Poll_Base_Priority_Change_At_Entry_Call *************** package body System.Tasking.Entry_Calls *** 147,152 **** --- 153,160 ---- (Self_ID : Task_ID; Entry_Call : Entry_Call_Link) is + pragma Warnings (Off, Self_ID); + use type Ada.Exceptions.Exception_Id; procedure Internal_Raise (X : Ada.Exceptions.Exception_Id); *************** package body System.Tasking.Entry_Calls *** 177,184 **** procedure Check_Pending_Actions_For_Entry_Call (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link) ! is begin pragma Assert (Self_ID = Entry_Call.Self); --- 185,191 ---- procedure Check_Pending_Actions_For_Entry_Call (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link) is begin pragma Assert (Self_ID = Entry_Call.Self); *************** package body System.Tasking.Entry_Calls *** 240,248 **** -- We had very bad luck, interleaving with TWO different -- requeue operations. Go around the loop and try again. ! STPO.Yield; else Lock_Entries (Test_PO, Ceiling_Violation); -- ???? --- 247,265 ---- -- We had very bad luck, interleaving with TWO different -- requeue operations. Go around the loop and try again. ! if Single_Lock then ! STPO.Unlock_RTS; ! STPO.Yield; ! STPO.Lock_RTS; ! else ! STPO.Yield; ! end if; else + if Single_Lock then + STPO.Unlock_RTS; + end if; + Lock_Entries (Test_PO, Ceiling_Violation); -- ???? *************** package body System.Tasking.Entry_Calls *** 250,256 **** -- when cancelling a call, to allow for the possibility -- that the priority of the caller has been raised -- beyond that of the protected entry call by ! -- Ada.Dynamic_Priorities.STPO.Set_Priority. -- If the current task has a higher priority than the ceiling -- of the protected object, temporarily lower it. It will --- 267,273 ---- -- when cancelling a call, to allow for the possibility -- that the priority of the caller has been raised -- beyond that of the protected entry call by ! -- Ada.Dynamic_Priorities.Set_Priority. -- If the current task has a higher priority than the ceiling -- of the protected object, temporarily lower it. It will *************** package body System.Tasking.Entry_Calls *** 262,267 **** --- 279,288 ---- Old_Base_Priority : System.Any_Priority; begin + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Current_Task); Old_Base_Priority := Current_Task.Common.Base_Priority; Current_Task.New_Base_Priority := Test_PO.Ceiling; *************** package body System.Tasking.Entry_Calls *** 269,274 **** --- 290,299 ---- (Current_Task); STPO.Unlock (Current_Task); + if Single_Lock then + STPO.Unlock_RTS; + end if; + -- Following lock should not fail Lock_Entries (Test_PO); *************** package body System.Tasking.Entry_Calls *** 280,285 **** --- 305,314 ---- exit when To_Address (Test_PO) = Entry_Call.Called_PO; Unlock_Entries (Test_PO); + + if Single_Lock then + STPO.Lock_RTS; + end if; end if; else *************** package body System.Tasking.Entry_Calls *** 303,326 **** procedure Poll_Base_Priority_Change_At_Entry_Call (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link) ! is begin ! if Initialization.Dynamic_Priority_Support ! and then Self_ID.Pending_Priority_Change ! then -- Check for ceiling violations ??? Self_ID.Pending_Priority_Change := False; if Self_ID.Common.Base_Priority = Self_ID.New_Base_Priority then ! STPO.Unlock (Self_ID); ! STPO.Yield; ! STPO.Write_Lock (Self_ID); else if Self_ID.Common.Base_Priority < Self_ID.New_Base_Priority then - -- Raising priority Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; --- 332,357 ---- procedure Poll_Base_Priority_Change_At_Entry_Call (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link) is begin ! if Dynamic_Priority_Support and then Self_ID.Pending_Priority_Change then -- Check for ceiling violations ??? Self_ID.Pending_Priority_Change := False; if Self_ID.Common.Base_Priority = Self_ID.New_Base_Priority then ! if Single_Lock then ! STPO.Unlock_RTS; ! STPO.Yield; ! STPO.Lock_RTS; ! else ! STPO.Unlock (Self_ID); ! STPO.Yield; ! STPO.Write_Lock (Self_ID); ! end if; else if Self_ID.Common.Base_Priority < Self_ID.New_Base_Priority then -- Raising priority Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; *************** package body System.Tasking.Entry_Calls *** 331,339 **** Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; STPO.Set_Priority (Self_ID, Self_ID.Common.Base_Priority); ! STPO.Unlock (Self_ID); ! STPO.Yield; ! STPO.Write_Lock (Self_ID); end if; end if; --- 362,377 ---- Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; STPO.Set_Priority (Self_ID, Self_ID.Common.Base_Priority); ! ! if Single_Lock then ! STPO.Unlock_RTS; ! STPO.Yield; ! STPO.Lock_RTS; ! else ! STPO.Unlock (Self_ID); ! STPO.Yield; ! STPO.Write_Lock (Self_ID); ! end if; end if; end if; *************** package body System.Tasking.Entry_Calls *** 354,389 **** -- Reset_Priority -- -------------------- - -- Reset the priority of a task completing an accept statement to - -- the value it had before the call. - procedure Reset_Priority ! (Acceptor_Prev_Priority : Rendezvous_Priority; ! Acceptor : Task_ID) is begin if Acceptor_Prev_Priority /= Priority_Not_Boosted then STPO.Set_Priority (Acceptor, Acceptor_Prev_Priority, Loss_Of_Inheritance => True); end if; end Reset_Priority; - -- ??? - -- Check why we don't need any kind of lock to do this. - -- Do we limit this kind of "active" priority change to be done - -- by the task for itself only? - ------------------------------ -- Try_To_Cancel_Entry_Call -- ------------------------------ - -- This is used to implement the Cancel_Task_Entry_Call and - -- Cancel_Protected_Entry_Call. - -- Try to cancel async. entry call. - -- Effect includes Abort_To_Level and Wait_For_Completion. - -- Cancelled = True iff the cancelation was successful, i.e., - -- the call was not Done before this call. - -- On return, the call is off-queue and the ATC level is reduced by one. - procedure Try_To_Cancel_Entry_Call (Succeeded : out Boolean) is Entry_Call : Entry_Call_Link; Self_ID : constant Task_ID := STPO.Self; --- 392,416 ---- -- Reset_Priority -- -------------------- procedure Reset_Priority ! (Acceptor : Task_ID; ! Acceptor_Prev_Priority : Rendezvous_Priority) is begin + pragma Assert (Acceptor = STPO.Self); + + -- Since we limit this kind of "active" priority change to be done + -- by the task for itself, we don't need to lock Acceptor. + if Acceptor_Prev_Priority /= Priority_Not_Boosted then STPO.Set_Priority (Acceptor, Acceptor_Prev_Priority, Loss_Of_Inheritance => True); end if; end Reset_Priority; ------------------------------ -- Try_To_Cancel_Entry_Call -- ------------------------------ procedure Try_To_Cancel_Entry_Call (Succeeded : out Boolean) is Entry_Call : Entry_Call_Link; Self_ID : constant Task_ID := STPO.Self; *************** package body System.Tasking.Entry_Calls *** 394,406 **** Entry_Call := Self_ID.Entry_Calls (Self_ID.ATC_Nesting_Level)'Access; -- Experimentation has shown that abort is sometimes (but not ! -- always) already deferred when Cancel_X_Entry_Call is called. -- That may indicate an error. Find out what is going on. ??? pragma Assert (Entry_Call.Mode = Asynchronous_Call); - pragma Assert (Self_ID = Self); - Initialization.Defer_Abort_Nestable (Self_ID); STPO.Write_Lock (Self_ID); Entry_Call.Cancellation_Attempted := True; --- 421,436 ---- Entry_Call := Self_ID.Entry_Calls (Self_ID.ATC_Nesting_Level)'Access; -- Experimentation has shown that abort is sometimes (but not ! -- always) already deferred when Cancel_xxx_Entry_Call is called. -- That may indicate an error. Find out what is going on. ??? pragma Assert (Entry_Call.Mode = Asynchronous_Call); Initialization.Defer_Abort_Nestable (Self_ID); + + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Self_ID); Entry_Call.Cancellation_Attempted := True; *************** package body System.Tasking.Entry_Calls *** 408,421 **** Self_ID.Pending_ATC_Level := Entry_Call.Level - 1; end if; ! Entry_Calls.Wait_For_Completion (Self_ID, Entry_Call); STPO.Unlock (Self_ID); Succeeded := Entry_Call.State = Cancelled; if Succeeded then Initialization.Undefer_Abort_Nestable (Self_ID); else ! -- ???? Initialization.Undefer_Abort_Nestable (Self_ID); --- 438,456 ---- Self_ID.Pending_ATC_Level := Entry_Call.Level - 1; end if; ! Entry_Calls.Wait_For_Completion (Entry_Call); STPO.Unlock (Self_ID); + + if Single_Lock then + STPO.Unlock_RTS; + end if; + Succeeded := Entry_Call.State = Cancelled; if Succeeded then Initialization.Undefer_Abort_Nestable (Self_ID); else ! -- ??? Initialization.Undefer_Abort_Nestable (Self_ID); *************** package body System.Tasking.Entry_Calls *** 456,468 **** --- 491,516 ---- if Called_PO.Pending_Action then Called_PO.Pending_Action := False; Caller := STPO.Self; + + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Caller); Caller.New_Base_Priority := Called_PO.Old_Base_Priority; Initialization.Change_Base_Priority (Caller); STPO.Unlock (Caller); + + if Single_Lock then + STPO.Unlock_RTS; + end if; end if; Unlock_Entries (Called_PO); + + if Single_Lock then + STPO.Lock_RTS; + end if; end if; end Unlock_And_Update_Server; *************** package body System.Tasking.Entry_Calls *** 483,588 **** if Called_PO.Pending_Action then Called_PO.Pending_Action := False; Caller := STPO.Self; STPO.Write_Lock (Caller); Caller.New_Base_Priority := Called_PO.Old_Base_Priority; Initialization.Change_Base_Priority (Caller); STPO.Unlock (Caller); end if; Unlock_Entries (Called_PO); end if; end Unlock_Server; ------------------------- ! -- Wait_For_Completion-- ------------------------- ! -- Call this only when holding Self_ID locked ! ! -- If this is a conditional call, it should be cancelled when it ! -- becomes abortable. This is checked in the loop below. ! ! -- We do the same thing for Asynchronous_Call. Executing the following ! -- loop will clear the Pending_Action field if there is no ! -- Pending_Action. We want the call made from Cancel_Task_Entry_Call ! -- to check the abortion level so that we make sure that the Cancelled ! -- field reflect the status of an Asynchronous_Call properly. ! -- This problem came up when the triggered statement and the abortable ! -- part depend on entries of the same task. When a cancellation is ! -- delivered, Undefer_Abort in the call made from abortable part ! -- sets the Pending_Action bit to false. However, the call is actually ! -- made to cancel the Asynchronous Call so that we need to check its ! -- status here again. Otherwise we may end up waiting for a cancelled ! -- call forever. ! -- ????? ......... ! -- Recheck the logic of the above old comment. It may be stale. ! procedure Wait_For_Completion ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link) ! is ! begin ! pragma Assert (Self_ID = Entry_Call.Self); ! Self_ID.Common.State := Entry_Caller_Sleep; loop ! Check_Pending_Actions_For_Entry_Call (Self_ID, Entry_Call); exit when Entry_Call.State >= Done; ! STPO.Sleep (Self_ID, Entry_Caller_Sleep); end loop; ! Self_ID.Common.State := Runnable; ! Utilities.Exit_One_ATC_Level (Self_ID); end Wait_For_Completion; -------------------------------------- -- Wait_For_Completion_With_Timeout -- -------------------------------------- - -- This routine will lock Self_ID. - - -- This procedure waits for the entry call to - -- be served, with a timeout. It tries to cancel the - -- call if the timeout expires before the call is served. - - -- If we wake up from the timed sleep operation here, - -- it may be for several possible reasons: - - -- 1) The entry call is done being served. - -- 2) There is an abort or priority change to be served. - -- 3) The timeout has expired (Timedout = True) - -- 4) There has been a spurious wakeup. - - -- Once the timeout has expired we may need to continue to wait if - -- the call is already being serviced. In that case, we want to go - -- back to sleep, but without any timeout. The variable Timedout is - -- used to control this. If the Timedout flag is set, we do not need - -- to STPO.Sleep with a timeout. We just sleep until we get a wakeup for - -- some status change. - - -- The original call may have become abortable after waking up. - -- We want to check Check_Pending_Actions_For_Entry_Call again - -- in any case. - procedure Wait_For_Completion_With_Timeout ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link; Wakeup_Time : Duration; ! Mode : Delay_Modes) is Timedout : Boolean := False; - Yielded : Boolean := False; use type Ada.Exceptions.Exception_Id; begin ! Initialization.Defer_Abort_Nestable (Self_ID); ! STPO.Write_Lock (Self_ID); - pragma Assert (Entry_Call.Self = Self_ID); pragma Assert (Entry_Call.Mode = Timed_Call); ! Self_ID.Common.State := Entry_Caller_Sleep; -- Looping is necessary in case the task wakes up early from the -- timed sleep, due to a "spurious wakeup". Spurious wakeups are --- 531,631 ---- if Called_PO.Pending_Action then Called_PO.Pending_Action := False; Caller := STPO.Self; + + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Caller); Caller.New_Base_Priority := Called_PO.Old_Base_Priority; Initialization.Change_Base_Priority (Caller); STPO.Unlock (Caller); + + if Single_Lock then + STPO.Unlock_RTS; + end if; end if; Unlock_Entries (Called_PO); + + if Single_Lock then + STPO.Lock_RTS; + end if; end if; end Unlock_Server; ------------------------- ! -- Wait_For_Completion -- ------------------------- ! procedure Wait_For_Completion (Entry_Call : Entry_Call_Link) is ! Self_Id : constant Task_ID := Entry_Call.Self; ! begin ! -- If this is a conditional call, it should be cancelled when it ! -- becomes abortable. This is checked in the loop below. ! if Parameters.Runtime_Traces then ! Send_Trace_Info (W_Completion); ! end if; ! Self_Id.Common.State := Entry_Caller_Sleep; loop ! Check_Pending_Actions_For_Entry_Call (Self_Id, Entry_Call); exit when Entry_Call.State >= Done; ! STPO.Sleep (Self_Id, Entry_Caller_Sleep); end loop; ! Self_Id.Common.State := Runnable; ! Utilities.Exit_One_ATC_Level (Self_Id); ! ! if Parameters.Runtime_Traces then ! Send_Trace_Info (M_Call_Complete); ! end if; end Wait_For_Completion; -------------------------------------- -- Wait_For_Completion_With_Timeout -- -------------------------------------- procedure Wait_For_Completion_With_Timeout ! (Entry_Call : Entry_Call_Link; Wakeup_Time : Duration; ! Mode : Delay_Modes; ! Yielded : out Boolean) is + Self_Id : constant Task_ID := Entry_Call.Self; Timedout : Boolean := False; use type Ada.Exceptions.Exception_Id; begin ! -- This procedure waits for the entry call to be served, with a timeout. ! -- It tries to cancel the call if the timeout expires before the call is ! -- served. ! ! -- If we wake up from the timed sleep operation here, it may be for ! -- several possible reasons: ! ! -- 1) The entry call is done being served. ! -- 2) There is an abort or priority change to be served. ! -- 3) The timeout has expired (Timedout = True) ! -- 4) There has been a spurious wakeup. ! ! -- Once the timeout has expired we may need to continue to wait if the ! -- call is already being serviced. In that case, we want to go back to ! -- sleep, but without any timeout. The variable Timedout is used to ! -- control this. If the Timedout flag is set, we do not need to ! -- STPO.Sleep with a timeout. We just sleep until we get a wakeup for ! -- some status change. ! ! -- The original call may have become abortable after waking up. We want ! -- to check Check_Pending_Actions_For_Entry_Call again in any case. pragma Assert (Entry_Call.Mode = Timed_Call); ! ! Yielded := False; ! Self_Id.Common.State := Entry_Caller_Sleep; -- Looping is necessary in case the task wakes up early from the -- timed sleep, due to a "spurious wakeup". Spurious wakeups are *************** package body System.Tasking.Entry_Calls *** 591,612 **** -- when the condition is signaled. See the same loop in the -- ordinary Wait_For_Completion, above. loop ! Check_Pending_Actions_For_Entry_Call (Self_ID, Entry_Call); exit when Entry_Call.State >= Done; ! STPO.Timed_Sleep (Self_ID, Wakeup_Time, Mode, Entry_Caller_Sleep, Timedout, Yielded); if Timedout then -- Try to cancel the call (see Try_To_Cancel_Entry_Call for -- corresponding code in the ATC case). Entry_Call.Cancellation_Attempted := True; ! if Self_ID.Pending_ATC_Level >= Entry_Call.Level then ! Self_ID.Pending_ATC_Level := Entry_Call.Level - 1; end if; -- The following loop is the same as the loop and exit code --- 634,662 ---- -- when the condition is signaled. See the same loop in the -- ordinary Wait_For_Completion, above. + if Parameters.Runtime_Traces then + Send_Trace_Info (WT_Completion, Wakeup_Time); + end if; + loop ! Check_Pending_Actions_For_Entry_Call (Self_Id, Entry_Call); exit when Entry_Call.State >= Done; ! STPO.Timed_Sleep (Self_Id, Wakeup_Time, Mode, Entry_Caller_Sleep, Timedout, Yielded); if Timedout then + if Parameters.Runtime_Traces then + Send_Trace_Info (E_Timeout); + end if; -- Try to cancel the call (see Try_To_Cancel_Entry_Call for -- corresponding code in the ATC case). Entry_Call.Cancellation_Attempted := True; ! if Self_Id.Pending_ATC_Level >= Entry_Call.Level then ! Self_Id.Pending_ATC_Level := Entry_Call.Level - 1; end if; -- The following loop is the same as the loop and exit code *************** package body System.Tasking.Entry_Calls *** 615,653 **** -- has actually completed or been cancelled successfully. loop ! Check_Pending_Actions_For_Entry_Call (Self_ID, Entry_Call); exit when Entry_Call.State >= Done; ! STPO.Sleep (Self_ID, Entry_Caller_Sleep); end loop; ! Self_ID.Common.State := Runnable; ! Utilities.Exit_One_ATC_Level (Self_ID); ! ! STPO.Unlock (Self_ID); ! ! if Entry_Call.State = Cancelled then ! Initialization.Undefer_Abort_Nestable (Self_ID); ! else ! -- ???? ! ! Initialization.Undefer_Abort_Nestable (Self_ID); ! ! -- Ideally, abort should no longer be deferred at this ! -- point, so we should be able to call Check_Exception. ! -- The loop below should be considered temporary, ! -- to work around the possiblility that abort may be ! -- deferred more than one level deep. ! ! if Entry_Call.Exception_To_Raise /= ! Ada.Exceptions.Null_Id then ! ! while Self_ID.Deferral_Level > 0 loop ! Initialization.Undefer_Abort_Nestable (Self_ID); ! end loop; ! ! Entry_Calls.Check_Exception (Self_ID, Entry_Call); ! end if; ! end if; return; end if; --- 665,677 ---- -- has actually completed or been cancelled successfully. loop ! Check_Pending_Actions_For_Entry_Call (Self_Id, Entry_Call); exit when Entry_Call.State >= Done; ! STPO.Sleep (Self_Id, Entry_Caller_Sleep); end loop; ! Self_Id.Common.State := Runnable; ! Utilities.Exit_One_ATC_Level (Self_Id); return; end if; *************** package body System.Tasking.Entry_Calls *** 656,687 **** -- This last part is the same as ordinary Wait_For_Completion, -- and is only executed if the call completed without timing out. ! Self_ID.Common.State := Runnable; ! Utilities.Exit_One_ATC_Level (Self_ID); ! STPO.Unlock (Self_ID); ! ! Initialization.Undefer_Abort_Nestable (Self_ID); ! ! if not Yielded then ! STPO.Yield; end if; end Wait_For_Completion_With_Timeout; -------------------------- -- Wait_Until_Abortable -- -------------------------- - -- Wait to start the abortable part of an async. select statement - -- until the trigger entry call becomes abortable. - procedure Wait_Until_Abortable ! (Self_ID : Task_ID; ! Call : Entry_Call_Link) ! is begin pragma Assert (Self_ID.ATC_Nesting_Level > 0); pragma Assert (Call.Mode = Asynchronous_Call); STPO.Write_Lock (Self_ID); Self_ID.Common.State := Entry_Caller_Sleep; --- 680,708 ---- -- This last part is the same as ordinary Wait_For_Completion, -- and is only executed if the call completed without timing out. ! if Parameters.Runtime_Traces then ! Send_Trace_Info (M_Call_Complete); end if; + + Self_Id.Common.State := Runnable; + Utilities.Exit_One_ATC_Level (Self_Id); end Wait_For_Completion_With_Timeout; -------------------------- -- Wait_Until_Abortable -- -------------------------- procedure Wait_Until_Abortable ! (Self_ID : Task_ID; ! Call : Entry_Call_Link) is begin pragma Assert (Self_ID.ATC_Nesting_Level > 0); pragma Assert (Call.Mode = Asynchronous_Call); + if Parameters.Runtime_Traces then + Send_Trace_Info (W_Completion); + end if; + STPO.Write_Lock (Self_ID); Self_ID.Common.State := Entry_Caller_Sleep; *************** package body System.Tasking.Entry_Calls *** 693,713 **** Self_ID.Common.State := Runnable; STPO.Unlock (Self_ID); - end Wait_Until_Abortable; - - -- It might seem that we should be holding the server's lock when - -- we test Call.State above. ! -- In an earlier version, the code above temporarily unlocked the ! -- caller and locked the server just for checking Call.State. ! -- The unlocking of the caller risked missing a wakeup ! -- (an error) and locking the server had no apparent value. ! -- We should not need the server's lock, since once Call.State ! -- is set to Was_Abortable or beyond, it never goes back below ! -- Was_Abortable until this task starts another entry call. ! ! -- ???? ! -- It seems that other calls to Lock_Server may also risk missing ! -- wakeups. We need to check that they do not have this problem. end System.Tasking.Entry_Calls; --- 714,723 ---- Self_ID.Common.State := Runnable; STPO.Unlock (Self_ID); ! if Parameters.Runtime_Traces then ! Send_Trace_Info (M_Call_Complete); ! end if; ! end Wait_Until_Abortable; end System.Tasking.Entry_Calls; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-taenca.ads gcc-3.3/gcc/ada/s-taenca.ads *** gcc-3.2.3/gcc/ada/s-taenca.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-taenca.ads 2002-03-14 10:59:58.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-1998, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,67 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ package System.Tasking.Entry_Calls is ! procedure Wait_For_Completion ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link); -- This procedure suspends the calling task until the specified entry -- call has either been completed or cancelled. It performs other -- operations required of suspended tasks, such as performing -- dynamic priority changes. On exit, the call will not be queued. -- This waits for calls on task or protected entries. -- Abortion must be deferred when calling this procedure. ! -- Call this only when holding Self_ID locked. procedure Wait_For_Completion_With_Timeout ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link; Wakeup_Time : Duration; ! Mode : Delay_Modes); ! -- Same as Wait_For_Completion but it wait for a timeout with the value -- specified in Wakeup_Time as well. ! -- Self_ID will be locked by this procedure. procedure Wait_Until_Abortable (Self_ID : Task_ID; ! Call : Entry_Call_Link); -- This procedure suspends the calling task until the specified entry -- call is queued abortably or completes. ! -- Abortion must be deferred when calling this procedure. procedure Try_To_Cancel_Entry_Call (Succeeded : out Boolean); pragma Inline (Try_To_Cancel_Entry_Call); --- 28,71 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ + -- This package provides internal RTS calls implementing operations + -- that apply to general entry calls, that is, calls to either + -- protected or task entries. + + -- These declarations are not part of the GNARL Interface + package System.Tasking.Entry_Calls is ! procedure Wait_For_Completion (Entry_Call : Entry_Call_Link); -- This procedure suspends the calling task until the specified entry -- call has either been completed or cancelled. It performs other -- operations required of suspended tasks, such as performing -- dynamic priority changes. On exit, the call will not be queued. -- This waits for calls on task or protected entries. -- Abortion must be deferred when calling this procedure. ! -- Call this only when holding Self (= Entry_Call.Self) or global RTS lock. procedure Wait_For_Completion_With_Timeout ! (Entry_Call : Entry_Call_Link; Wakeup_Time : Duration; ! Mode : Delay_Modes; ! Yielded : out Boolean); ! -- Same as Wait_For_Completion but wait for a timeout with the value -- specified in Wakeup_Time as well. ! -- On return, Yielded indicates whether the wait has performed a yield. ! -- Check_Exception must be called after calling this procedure. procedure Wait_Until_Abortable (Self_ID : Task_ID; ! Call : Entry_Call_Link); -- This procedure suspends the calling task until the specified entry -- call is queued abortably or completes. ! -- Abortion must be deferred when calling this procedure, and the global ! -- RTS lock taken when Single_Lock. procedure Try_To_Cancel_Entry_Call (Succeeded : out Boolean); pragma Inline (Try_To_Cancel_Entry_Call); *************** package System.Tasking.Entry_Calls is *** 72,94 **** -- On return, the call is off-queue and the ATC level is reduced by one. procedure Reset_Priority ! (Acceptor_Prev_Priority : Rendezvous_Priority; ! Acceptor : Task_ID); pragma Inline (Reset_Priority); -- Reset the priority of a task completing an accept statement to -- the value it had before the call. procedure Check_Exception ! (Self_ID : Task_ID; Entry_Call : Entry_Call_Link); pragma Inline (Check_Exception); -- Raise any pending exception from the Entry_Call. ! -- This should be called at the end of every compiler interface ! -- procedure that implements an entry call. ! -- In principle, the caller should not be abort-deferred (unless ! -- the application program violates the Ada language rules by doing ! -- entry calls from within protected operations -- an erroneous practice ! -- apparently followed with success by some adventurous GNAT users). -- Absolutely, the caller should not be holding any locks, or there -- will be deadlock. --- 76,99 ---- -- On return, the call is off-queue and the ATC level is reduced by one. procedure Reset_Priority ! (Acceptor : Task_ID; ! Acceptor_Prev_Priority : Rendezvous_Priority); pragma Inline (Reset_Priority); -- Reset the priority of a task completing an accept statement to -- the value it had before the call. + -- Acceptor should always be equal to Self. procedure Check_Exception ! (Self_ID : Task_ID; Entry_Call : Entry_Call_Link); pragma Inline (Check_Exception); -- Raise any pending exception from the Entry_Call. ! -- This should be called at the end of every compiler interface procedure ! -- that implements an entry call. ! -- In principle, the caller should not be abort-deferred (unless the ! -- application program violates the Ada language rules by doing entry calls ! -- from within protected operations -- an erroneous practice apparently ! -- followed with success by some adventurous GNAT users). -- Absolutely, the caller should not be holding any locks, or there -- will be deadlock. diff -Nrc3pad gcc-3.2.3/gcc/ada/stand.adb gcc-3.3/gcc/ada/stand.adb *** gcc-3.2.3/gcc/ada/stand.adb 2002-05-07 08:22:34.000000000 +0000 --- gcc-3.3/gcc/ada/stand.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/stand.ads gcc-3.3/gcc/ada/stand.ads *** gcc-3.2.3/gcc/ada/stand.ads 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/stand.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-taprob.adb gcc-3.3/gcc/ada/s-taprob.adb *** gcc-3.2.3/gcc/ada/s-taprob.adb 2001-12-20 06:22:42.000000000 +0000 --- gcc-3.3/gcc/ada/s-taprob.adb 2002-03-14 10:59:58.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- *************** with System.Task_Primitives.Operations; *** 42,50 **** --- 41,56 ---- -- used for Write_Lock -- Unlock + with System.Parameters; + -- used for Runtime_Traces + + with System.Traces; + -- used for Send_Trace_Info + package body System.Tasking.Protected_Objects is use System.Task_Primitives.Operations; + use System.Traces; ------------------------- -- Finalize_Protection -- *************** package body System.Tasking.Protected_Ob *** 92,97 **** --- 98,107 ---- Write_Lock (Object.L'Access, Ceiling_Violation); + if Parameters.Runtime_Traces then + Send_Trace_Info (PO_Lock); + end if; + if Ceiling_Violation then raise Program_Error; end if; *************** package body System.Tasking.Protected_Ob *** 106,111 **** --- 116,125 ---- begin Read_Lock (Object.L'Access, Ceiling_Violation); + if Parameters.Runtime_Traces then + Send_Trace_Info (PO_Lock); + end if; + if Ceiling_Violation then raise Program_Error; end if; *************** package body System.Tasking.Protected_Ob *** 118,123 **** --- 132,141 ---- procedure Unlock (Object : Protection_Access) is begin Unlock (Object.L'Access); + + if Parameters.Runtime_Traces then + Send_Trace_Info (PO_Unlock); + end if; end Unlock; end System.Tasking.Protected_Objects; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-taprob.ads gcc-3.3/gcc/ada/s-taprob.ads *** gcc-3.2.3/gcc/ada/s-taprob.ads 2002-05-04 03:28:48.000000000 +0000 --- gcc-3.3/gcc/ada/s-taprob.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-taprop.ads gcc-3.3/gcc/ada/s-taprop.ads *** gcc-3.2.3/gcc/ada/s-taprop.ads 2002-05-04 03:28:48.000000000 +0000 --- gcc-3.3/gcc/ada/s-taprop.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package System.Task_Primitives.Operation *** 137,145 **** type Lock_Level is (PO_Level, Global_Task_Level, ! All_Attrs_Level, ! All_Tasks_Level, ! Interrupts_Level, ATCB_Level); -- Type used to describe kind of lock for second form of Initialize_Lock -- call specified below. --- 136,142 ---- type Lock_Level is (PO_Level, Global_Task_Level, ! RTS_Lock_Level, ATCB_Level); -- Type used to describe kind of lock for second form of Initialize_Lock -- call specified below. *************** package System.Task_Primitives.Operation *** 175,181 **** -- corresponding Initialize_Lock operation. procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean); ! procedure Write_Lock (L : access RTS_Lock); procedure Write_Lock (T : ST.Task_ID); pragma Inline (Write_Lock); -- Lock a lock object for write access. After this operation returns, --- 172,178 ---- -- corresponding Initialize_Lock operation. procedure Write_Lock (L : access Lock; Ceiling_Violation : out Boolean); ! procedure Write_Lock (L : access RTS_Lock; Global_Lock : Boolean := False); procedure Write_Lock (T : ST.Task_ID); pragma Inline (Write_Lock); -- Lock a lock object for write access. After this operation returns, *************** package System.Task_Primitives.Operation *** 189,194 **** --- 186,194 ---- -- operation failed, which will happen if there is a priority ceiling -- violation. -- + -- For the operation on RTS_Lock, Global_Lock should be set to True + -- if L is a global lock (Single_RTS_Lock, Global_Task_Lock). + -- -- For the operation on ST.Task_ID, the lock is the special lock object -- associated with that task's ATCB. This lock has effective ceiling -- priority high enough that it is safe to call by a task with any *************** package System.Task_Primitives.Operation *** 220,226 **** -- locking that make a reader-writer distinction have higher overhead. procedure Unlock (L : access Lock); ! procedure Unlock (L : access RTS_Lock); procedure Unlock (T : ST.Task_ID); pragma Inline (Unlock); -- Unlock a locked lock object. --- 220,226 ---- -- locking that make a reader-writer distinction have higher overhead. procedure Unlock (L : access Lock); ! procedure Unlock (L : access RTS_Lock; Global_Lock : Boolean := False); procedure Unlock (T : ST.Task_ID); pragma Inline (Unlock); -- Unlock a locked lock object. *************** package System.Task_Primitives.Operation *** 231,239 **** -- read or write permission. (That is, matching pairs of Lock and Unlock -- operations on each lock object must be properly nested.) -- Note that Write_Lock for RTS_Lock does not have an out-parameter. -- RTS_Locks are used in situations where we have not made provision ! -- for recovery from ceiling violations. We do not expect them to -- occur inside the runtime system, because all RTS locks have ceiling -- Priority'Last. --- 231,242 ---- -- read or write permission. (That is, matching pairs of Lock and Unlock -- operations on each lock object must be properly nested.) + -- For the operation on RTS_Lock, Global_Lock should be set to True + -- if L is a global lock (Single_RTS_Lock, Global_Task_Lock). + -- -- Note that Write_Lock for RTS_Lock does not have an out-parameter. -- RTS_Locks are used in situations where we have not made provision ! -- for recovery from ceiling violations. We do not expect them to -- occur inside the runtime system, because all RTS locks have ceiling -- Priority'Last. *************** package System.Task_Primitives.Operation *** 242,248 **** -- executing in the Interrupt_Priority range. -- It is not clear what to do about ceiling violations due ! -- to RTS calls done at interrupt priority. In general, it -- is not acceptable to give all RTS locks interrupt priority, -- since that whould give terrible performance on systems where -- this has the effect of masking hardware interrupts, though we --- 245,251 ---- -- executing in the Interrupt_Priority range. -- It is not clear what to do about ceiling violations due ! -- to RTS calls done at interrupt priority. In general, it -- is not acceptable to give all RTS locks interrupt priority, -- since that whould give terrible performance on systems where -- this has the effect of masking hardware interrupts, though we *************** package System.Task_Primitives.Operation *** 254,260 **** -- penalties. -- For POSIX systems, we considered just skipping setting a ! -- priority ceiling on RTS locks. This would mean there is no -- ceiling violation, but we would end up with priority inversions -- inside the runtime system, resulting in failure to satisfy the -- Ada priority rules, and possible missed validation tests. --- 257,263 ---- -- penalties. -- For POSIX systems, we considered just skipping setting a ! -- priority ceiling on RTS locks. This would mean there is no -- ceiling violation, but we would end up with priority inversions -- inside the runtime system, resulting in failure to satisfy the -- Ada priority rules, and possible missed validation tests. *************** package System.Task_Primitives.Operation *** 266,274 **** -- This issue should be reconsidered whenever we get around to -- checking for calls to potentially blocking operations from ! -- within protected operations. If we check for such calls and -- catch them on entry to the OS, it may be that we can eliminate ! -- the possibility of ceiling violations inside the RTS. For this -- to work, we would have to forbid explicitly setting the priority -- of a task to anything in the Interrupt_Priority range, at least. -- We would also have to check that there are no RTS-lock operations --- 269,277 ---- -- This issue should be reconsidered whenever we get around to -- checking for calls to potentially blocking operations from ! -- within protected operations. If we check for such calls and -- catch them on entry to the OS, it may be that we can eliminate ! -- the possibility of ceiling violations inside the RTS. For this -- to work, we would have to forbid explicitly setting the priority -- of a task to anything in the Interrupt_Priority range, at least. -- We would also have to check that there are no RTS-lock operations *************** package System.Task_Primitives.Operation *** 277,283 **** -- The latter approach seems to be the best, i.e. to check on entry -- to RTS calls that may need to use locks that the priority is not ! -- in the interrupt range. If there are RTS operations that NEED to -- be called from interrupt handlers, those few RTS locks should then -- be converted to PO-type locks, with ceiling Interrupt_Priority'Last. --- 280,286 ---- -- The latter approach seems to be the best, i.e. to check on entry -- to RTS calls that may need to use locks that the priority is not ! -- in the interrupt range. If there are RTS operations that NEED to -- be called from interrupt handlers, those few RTS locks should then -- be converted to PO-type locks, with ceiling Interrupt_Priority'Last. *************** package System.Task_Primitives.Operation *** 324,332 **** -- Returns the resolution of the underlying clock used to implement -- RT_Clock. ! ------------------ ! -- Extensions -- ! ------------------ -- Whoever calls either of the Sleep routines is responsible -- for checking for pending aborts before the call. --- 327,335 ---- -- Returns the resolution of the underlying clock used to implement -- RT_Clock. ! ---------------- ! -- Extensions -- ! ---------------- -- Whoever calls either of the Sleep routines is responsible -- for checking for pending aborts before the call. *************** package System.Task_Primitives.Operation *** 388,393 **** --- 391,416 ---- function Get_Thread_Id (T : ST.Task_ID) return OSI.Thread_Id; -- returns the thread id of the specified task. + ----------------------- + -- RTS Entrance/Exit -- + ----------------------- + + -- Following two routines are used for possible operations needed + -- to be setup/cleared upon entrance/exit of RTS while maintaining + -- a single thread of control in the RTS. Since we intend these + -- routines to be used for implementing the Single_Lock RTS, + -- Lock_RTS should follow the first Defer_Abortion operation + -- entering RTS. In the same fashion Unlock_RTS should preceed + -- the last Undefer_Abortion exiting RTS. + -- + -- These routines also replace the functions Lock/Unlock_All_Tasks_List + + procedure Lock_RTS; + -- Take the global RTS lock. + + procedure Unlock_RTS; + -- Release the global RTS lock. + -------------------- -- Stack Checking -- -------------------- *************** package System.Task_Primitives.Operation *** 464,475 **** -- Such functionality is needed by gdb on some targets (e.g VxWorks) -- Return True is the operation is successful - procedure Lock_All_Tasks_List; - procedure Unlock_All_Tasks_List; - -- Lock/Unlock the All_Tasks_L lock which protects - -- System.Initialization.All_Tasks_List and Known_Tasks - -- ??? These routines were previousely in System.Tasking.Initialization - -- but were moved here to avoid dependency problems. That would be - -- nice to look at it some day and put it back in Initialization. - end System.Task_Primitives.Operations; --- 487,490 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tarest.adb gcc-3.3/gcc/ada/s-tarest.adb *** gcc-3.2.3/gcc/ada/s-tarest.adb 2001-12-18 00:03:38.000000000 +0000 --- gcc-3.3/gcc/ada/s-tarest.adb 2002-03-14 10:59:59.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1999-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** pragma Polling (Off); *** 50,55 **** --- 48,54 ---- with System.Parameters; -- used for Size_Type + -- Single_Lock with System.Task_Info; -- used for Task_Info_Type *************** package body System.Tasking.Restricted.S *** 83,91 **** package SSE renames System.Storage_Elements; package SST renames System.Secondary_Stack; ! use System.Task_Primitives; ! use System.Task_Primitives.Operations; ! use System.Task_Info; Global_Task_Lock : aliased System.Task_Primitives.RTS_Lock; -- This is a global lock; it is used to execute in mutual exclusion --- 82,90 ---- package SSE renames System.Storage_Elements; package SST renames System.Secondary_Stack; ! use Parameters; ! use Task_Primitives.Operations; ! use Task_Info; Global_Task_Lock : aliased System.Task_Primitives.RTS_Lock; -- This is a global lock; it is used to execute in mutual exclusion *************** package body System.Tasking.Restricted.S *** 147,153 **** procedure Task_Lock is begin ! STPO.Write_Lock (Global_Task_Lock'Access); end Task_Lock; ----------------- --- 146,152 ---- procedure Task_Lock is begin ! STPO.Write_Lock (Global_Task_Lock'Access, Global_Lock => True); end Task_Lock; ----------------- *************** package body System.Tasking.Restricted.S *** 156,162 **** procedure Task_Unlock is begin ! STPO.Unlock (Global_Task_Lock'Access); end Task_Unlock; ---------------------- --- 155,161 ---- procedure Task_Unlock is begin ! STPO.Unlock (Global_Task_Lock'Access, Global_Lock => True); end Task_Unlock; ---------------------- *************** package body System.Tasking.Restricted.S *** 294,299 **** --- 293,302 ---- pragma Assert (Self_ID = Environment_Task); pragma Assert (Self_ID.Common.Wait_Count = 0); + if Single_Lock then + Lock_RTS; + end if; + -- Lock self, to prevent activated tasks -- from racing ahead before we finish activating the chain. *************** package body System.Tasking.Restricted.S *** 351,356 **** --- 354,363 ---- Self_ID.Common.State := Runnable; Unlock (Self_ID); + if Single_Lock then + Unlock_RTS; + end if; + -- Remove the tasks from the chain. Chain_Access.T_ID := null; *************** package body System.Tasking.Restricted.S *** 370,375 **** --- 377,386 ---- Activator : constant Task_ID := Self_ID.Common.Activator; begin + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Activator); Write_Lock (Self_ID); *************** package body System.Tasking.Restricted.S *** 393,398 **** --- 404,413 ---- Unlock (Self_ID); Unlock (Activator); + if Single_Lock then + Unlock_RTS; + end if; + -- After the activation, active priority should be the same -- as base priority. We must unlock the Activator first, -- though, since it should not wait if we have lower priority. *************** package body System.Tasking.Restricted.S *** 439,444 **** --- 454,464 ---- end if; T := New_ATCB (0); + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); -- With no task hierarchy, the parent of all non-Environment tasks that *************** package body System.Tasking.Restricted.S *** 454,459 **** --- 474,484 ---- if not Success then Unlock (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + raise Program_Error; end if; *************** package body System.Tasking.Restricted.S *** 461,466 **** --- 486,495 ---- T.Common.Task_Image := Task_Image; Unlock (Self_ID); + if Single_Lock then + Unlock_RTS; + end if; + -- Create TSD as early as possible in the creation of a task, since it -- may be used by the operation of Ada code within the task. *************** package body System.Tasking.Restricted.S *** 483,492 **** --- 512,529 ---- begin pragma Assert (Self_ID = STPO.Environment_Task); + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); Sleep (Self_ID, Master_Completion_Sleep); Unlock (Self_ID); + if Single_Lock then + Unlock_RTS; + end if; + -- Should never return from Master Completion Sleep raise Program_Error; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tarest.ads gcc-3.3/gcc/ada/s-tarest.ads *** gcc-3.2.3/gcc/ada/s-tarest.ads 2002-05-04 03:28:48.000000000 +0000 --- gcc-3.3/gcc/ada/s-tarest.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-1999, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasdeb.adb gcc-3.3/gcc/ada/s-tasdeb.adb *** gcc-3.2.3/gcc/ada/s-tasdeb.adb 2002-05-04 03:28:48.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasdeb.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- ! -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1997-2002 Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 39,45 **** -- Note : This file *must* be compiled with debugging information -- Do not add any dependency to GNARL packages since this package is used ! -- in both normal and resticted (ravenscar) environments. with System.Task_Info, System.Task_Primitives.Operations, --- 38,44 ---- -- Note : This file *must* be compiled with debugging information -- Do not add any dependency to GNARL packages since this package is used ! -- in both normal and restricted (ravenscar) environments. with System.Task_Info, System.Task_Primitives.Operations, *************** package body System.Tasking.Debug is *** 52,69 **** package STPO renames System.Task_Primitives.Operations; type Integer_Address is mod 2 ** Standard'Address_Size; - type Integer_Address_Ptr is access all Integer_Address; - - function "+" is new - Unchecked_Conversion (System.Address, Integer_Address_Ptr); function "+" is new Unchecked_Conversion (Task_ID, Integer_Address); Hex_Address_Width : constant := (Standard'Address_Size / 4); - Zero_Pos : constant := Character'Pos ('0'); - Hex_Digits : constant array (0 .. Integer_Address'(15)) of Character := "0123456789abcdef"; --- 51,62 ---- *************** package body System.Tasking.Debug is *** 498,504 **** R : Boolean; begin ! STPO.Lock_All_Tasks_List; C := All_Tasks_List; while C /= null loop --- 491,497 ---- R : Boolean; begin ! STPO.Lock_RTS; C := All_Tasks_List; while C /= null loop *************** package body System.Tasking.Debug is *** 506,512 **** C := C.Common.All_Tasks_Link; end loop; ! STPO.Unlock_All_Tasks_List; end Resume_All_Tasks; ---------- --- 499,505 ---- C := C.Common.All_Tasks_Link; end loop; ! STPO.Unlock_RTS; end Resume_All_Tasks; ---------- *************** package body System.Tasking.Debug is *** 579,585 **** R : Boolean; begin ! STPO.Lock_All_Tasks_List; C := All_Tasks_List; while C /= null loop --- 572,578 ---- R : Boolean; begin ! STPO.Lock_RTS; C := All_Tasks_List; while C /= null loop *************** package body System.Tasking.Debug is *** 587,593 **** C := C.Common.All_Tasks_Link; end loop; ! STPO.Unlock_All_Tasks_List; end Suspend_All_Tasks; ------------------------ --- 580,586 ---- C := C.Common.All_Tasks_Link; end loop; ! STPO.Unlock_RTS; end Suspend_All_Tasks; ------------------------ *************** package body System.Tasking.Debug is *** 681,686 **** --- 674,681 ---- Other_ID : ST.Task_ID; Flag : Character) is + pragma Warnings (Off, Other_ID); + Self_ID : constant ST.Task_ID := STPO.Self; begin diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasdeb.ads gcc-3.3/gcc/ada/s-tasdeb.ads *** gcc-3.2.3/gcc/ada/s-tasdeb.ads 2002-05-04 03:28:48.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasdeb.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1997-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasinf.adb gcc-3.3/gcc/ada/s-tasinf.adb *** gcc-3.2.3/gcc/ada/s-tasinf.adb 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasinf.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (Compiler Interface) -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1998 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasinf.ads gcc-3.3/gcc/ada/s-tasinf.ads *** gcc-3.2.3/gcc/ada/s-tasinf.ads 2002-05-04 03:28:49.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasinf.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 7,13 **** -- S p e c -- -- (Compiler Interface) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasini.adb gcc-3.3/gcc/ada/s-tasini.adb *** gcc-3.2.3/gcc/ada/s-tasini.adb 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasini.adb 2002-03-14 10:59:59.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** pragma Polling (Off); *** 43,53 **** -- of the routines in this package, and more to the point, if we try -- to poll it can cause infinite loops. - -- This package provides overall initialization of the tasking portion - -- of the RTS. This package must be elaborated before any tasking - -- features are used. It also contains initialization for - -- Ada Task Control Block (ATCB) records. - with Ada.Exceptions; -- used for Exception_Occurrence_Access. --- 41,46 ---- *************** with System.Soft_Links; *** 71,92 **** with System.Tasking.Debug; -- used for Trace - with System.Tasking.Task_Attributes; - -- used for All_Attrs_L - with System.Stack_Checking; package body System.Tasking.Initialization is package STPO renames System.Task_Primitives.Operations; package SSL renames System.Soft_Links; package AE renames Ada.Exceptions; ! use System.Task_Primitives.Operations; Global_Task_Lock : aliased System.Task_Primitives.RTS_Lock; -- This is a global lock; it is used to execute in mutual exclusion ! -- from all other tasks. It is only used by Task_Lock, -- Task_Unlock, and Final_Task_Unlock. function Current_Target_Exception return AE.Exception_Occurrence; --- 64,86 ---- with System.Tasking.Debug; -- used for Trace with System.Stack_Checking; + with System.Parameters; + -- used for Single_Lock + package body System.Tasking.Initialization is package STPO renames System.Task_Primitives.Operations; package SSL renames System.Soft_Links; package AE renames Ada.Exceptions; ! use Parameters; ! use Task_Primitives.Operations; Global_Task_Lock : aliased System.Task_Primitives.RTS_Lock; -- This is a global lock; it is used to execute in mutual exclusion ! -- from all other tasks. It is only used by Task_Lock, -- Task_Unlock, and Final_Task_Unlock. function Current_Target_Exception return AE.Exception_Occurrence; *************** package body System.Tasking.Initializati *** 143,148 **** --- 137,145 ---- (X : AE.Exception_Occurrence := Current_Target_Exception); -- Handle exception setting and check for pending actions + function Task_Name return String; + -- Returns current task's name + ------------------------ -- Local Subprograms -- ------------------------ *************** package body System.Tasking.Initializati *** 181,188 **** ------------------------ function Check_Abort_Status return Integer is ! Self_ID : Task_ID := Self; ! begin if Self_ID /= null and then Self_ID.Deferral_Level = 0 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level --- 178,184 ---- ------------------------ function Check_Abort_Status return Integer is ! Self_ID : constant Task_ID := Self; begin if Self_ID /= null and then Self_ID.Deferral_Level = 0 and then Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level *************** package body System.Tasking.Initializati *** 199,234 **** procedure Defer_Abort (Self_ID : Task_ID) is begin pragma Assert (Self_ID.Deferral_Level = 0); ! -- pragma Assert ! -- (Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level); ! -- The above check has been useful in detecting mismatched ! -- defer/undefer pairs. You may uncomment it when testing on ! -- systems that support preemptive abort. ! -- If the OS supports preemptive abort (e.g. pthread_kill), ! -- it should have happened already. A problem is with systems ! -- that do not support preemptive abort, and so rely on polling. ! -- On such systems we may get false failures of the assertion, ! -- since polling for pending abort does no occur until the abort ! -- undefer operation. ! -- Even on systems that only poll for abort, the assertion may ! -- be useful for catching missed abort completion polling points. ! -- The operations that undefer abort poll for pending aborts. ! -- This covers most of the places where the core Ada semantics ! -- require abort to be caught, without any special attention. ! -- However, this generally happens on exit from runtime system ! -- call, which means a pending abort will not be noticed on the ! -- way into the runtime system. We considered adding a check ! -- for pending aborts at this point, but chose not to, because ! -- of the overhead. Instead, we searched for RTS calls that ! -- where abort completion is required and a task could go ! -- farther than Ada allows before undeferring abort; we then ! -- modified the code to ensure the abort would be detected. Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1; end Defer_Abort; --- 195,231 ---- procedure Defer_Abort (Self_ID : Task_ID) is begin + if No_Abort and then not Dynamic_Priority_Support then + return; + end if; pragma Assert (Self_ID.Deferral_Level = 0); ! -- pragma Assert ! -- (Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level); ! -- The above check has been useful in detecting mismatched defer/undefer ! -- pairs. You may uncomment it when testing on systems that support ! -- preemptive abort. ! -- If the OS supports preemptive abort (e.g. pthread_kill), it should ! -- have happened already. A problem is with systems that do not support ! -- preemptive abort, and so rely on polling. On such systems we may get ! -- false failures of the assertion, since polling for pending abort does ! -- no occur until the abort undefer operation. ! -- Even on systems that only poll for abort, the assertion may be useful ! -- for catching missed abort completion polling points. The operations ! -- that undefer abort poll for pending aborts. This covers most of the ! -- places where the core Ada semantics require abort to be caught, ! -- without any special attention. However, this generally happens on ! -- exit from runtime system call, which means a pending abort will not ! -- be noticed on the way into the runtime system. We considered adding a ! -- check for pending aborts at this point, but chose not to, because of ! -- the overhead. Instead, we searched for RTS calls where abort ! -- completion is required and a task could go farther than Ada allows ! -- before undeferring abort; we then modified the code to ensure the ! -- abort would be detected. Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1; end Defer_Abort; *************** package body System.Tasking.Initializati *** 239,251 **** procedure Defer_Abort_Nestable (Self_ID : Task_ID) is begin ! -- pragma Assert ! -- ((Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level or else ! -- Self_ID.Deferral_Level > 0)); ! -- See comment in Defer_Abort on the situations in which it may ! -- be useful to uncomment the above assertion. Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1; end Defer_Abort_Nestable; --- 236,251 ---- procedure Defer_Abort_Nestable (Self_ID : Task_ID) is begin + if No_Abort and then not Dynamic_Priority_Support then + return; + end if; ! -- pragma Assert ! -- ((Self_ID.Pending_ATC_Level >= Self_ID.ATC_Nesting_Level or else ! -- Self_ID.Deferral_Level > 0)); ! -- See comment in Defer_Abort on the situations in which it may be ! -- useful to uncomment the above assertion. Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1; end Defer_Abort_Nestable; *************** package body System.Tasking.Initializati *** 254,267 **** -- Defer_Abortion -- -------------------- - -- ?????? - -- Phase out Defer_Abortion without Self_ID - -- to reduce overhead due to multiple calls to Self - procedure Defer_Abortion is ! Self_ID : constant Task_ID := STPO.Self; begin Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1; end Defer_Abortion; --- 254,268 ---- -- Defer_Abortion -- -------------------- procedure Defer_Abortion is ! Self_ID : Task_ID; begin + if No_Abort and then not Dynamic_Priority_Support then + return; + end if; + + Self_ID := STPO.Self; Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1; end Defer_Abortion; *************** package body System.Tasking.Initializati *** 285,295 **** --- 286,304 ---- Self_ID.Deferral_Level := Self_ID.Deferral_Level + 1; + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_ID); Self_ID.Pending_Action := False; Poll_Base_Priority_Change (Self_ID); Unlock (Self_ID); + if Single_Lock then + Unlock_RTS; + end if; + -- Restore the original Deferral value. Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1; *************** package body System.Tasking.Initializati *** 341,347 **** procedure Final_Task_Unlock (Self_ID : Task_ID) is begin pragma Assert (Self_ID.Global_Task_Lock_Nesting = 1); ! Unlock (Global_Task_Lock'Access); end Final_Task_Unlock; -------------- --- 350,356 ---- procedure Final_Task_Unlock (Self_ID : Task_ID) is begin pragma Assert (Self_ID.Global_Task_Lock_Nesting = 1); ! Unlock (Global_Task_Lock'Access, Global_Lock => True); end Final_Task_Unlock; -------------- *************** package body System.Tasking.Initializati *** 350,355 **** --- 359,365 ---- procedure Init_RTS is Self_Id : Task_ID; + begin -- Terminate run time (regular vs restricted) specific initialization -- of the environment task. *************** package body System.Tasking.Initializati *** 380,396 **** Initialize_Lock (Global_Task_Lock'Access, STPO.Global_Task_Level); - -- Initialize lock used to implement mutual exclusion in the package - -- System.Task_Attributes. - - Initialize_Lock (System.Tasking.Task_Attributes.All_Attrs_L'Access, - All_Attrs_Level); - -- Notify that the tasking run time has been elaborated so that -- the tasking version of the soft links can be used. ! SSL.Abort_Defer := Defer_Abortion'Access; ! SSL.Abort_Undefer := Undefer_Abortion'Access; SSL.Update_Exception := Update_Exception'Access; SSL.Lock_Task := Task_Lock'Access; SSL.Unlock_Task := Task_Unlock'Access; --- 390,403 ---- Initialize_Lock (Global_Task_Lock'Access, STPO.Global_Task_Level); -- Notify that the tasking run time has been elaborated so that -- the tasking version of the soft links can be used. ! if not No_Abort or else Dynamic_Priority_Support then ! SSL.Abort_Defer := Defer_Abortion'Access; ! SSL.Abort_Undefer := Undefer_Abortion'Access; ! end if; ! SSL.Update_Exception := Update_Exception'Access; SSL.Lock_Task := Task_Lock'Access; SSL.Unlock_Task := Task_Unlock'Access; *************** package body System.Tasking.Initializati *** 406,411 **** --- 413,419 ---- SSL.Timed_Delay := Timed_Delay_T'Access; SSL.Check_Abort_Status := Check_Abort_Status'Access; SSL.Get_Stack_Info := Get_Stack_Info'Access; + SSL.Task_Name := Task_Name'Access; -- No need to create a new Secondary Stack, since we will use the -- default one created in s-secsta.adb *************** package body System.Tasking.Initializati *** 574,590 **** procedure Poll_Base_Priority_Change (Self_ID : Task_ID) is begin ! if Dynamic_Priority_Support ! and then Self_ID.Pending_Priority_Change ! then -- Check for ceiling violations ??? Self_ID.Pending_Priority_Change := False; if Self_ID.Common.Base_Priority = Self_ID.New_Base_Priority then ! Unlock (Self_ID); ! Yield; ! Write_Lock (Self_ID); elsif Self_ID.Common.Base_Priority < Self_ID.New_Base_Priority then Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; --- 582,602 ---- procedure Poll_Base_Priority_Change (Self_ID : Task_ID) is begin ! if Dynamic_Priority_Support and then Self_ID.Pending_Priority_Change then -- Check for ceiling violations ??? Self_ID.Pending_Priority_Change := False; if Self_ID.Common.Base_Priority = Self_ID.New_Base_Priority then ! if Single_Lock then ! Unlock_RTS; ! Yield; ! Lock_RTS; ! else ! Unlock (Self_ID); ! Yield; ! Write_Lock (Self_ID); ! end if; elsif Self_ID.Common.Base_Priority < Self_ID.New_Base_Priority then Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; *************** package body System.Tasking.Initializati *** 595,603 **** Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; Set_Priority (Self_ID, Self_ID.Common.Base_Priority); ! Unlock (Self_ID); ! Yield; ! Write_Lock (Self_ID); end if; end if; end Poll_Base_Priority_Change; --- 607,622 ---- Self_ID.Common.Base_Priority := Self_ID.New_Base_Priority; Set_Priority (Self_ID, Self_ID.Common.Base_Priority); ! ! if Single_Lock then ! Unlock_RTS; ! Yield; ! Lock_RTS; ! else ! Unlock (Self_ID); ! Yield; ! Write_Lock (Self_ID); ! end if; end if; end if; end Poll_Base_Priority_Change; *************** package body System.Tasking.Initializati *** 614,623 **** pragma Debug (Debug.Trace ("Remove_From_All_Tasks_List", 'C')); - Lock_All_Tasks_List; - Previous := Null_Task; C := All_Tasks_List; while C /= Null_Task loop if C = T then if Previous = Null_Task then --- 633,641 ---- pragma Debug (Debug.Trace ("Remove_From_All_Tasks_List", 'C')); Previous := Null_Task; C := All_Tasks_List; + while C /= Null_Task loop if C = T then if Previous = Null_Task then *************** package body System.Tasking.Initializati *** 627,633 **** Previous.Common.All_Tasks_Link := C.Common.All_Tasks_Link; end if; - Unlock_All_Tasks_List; return; end if; --- 645,650 ---- *************** package body System.Tasking.Initializati *** 642,697 **** -- Task_Lock -- --------------- - procedure Task_Lock is - T : Task_ID := STPO.Self; - - begin - T.Global_Task_Lock_Nesting := T.Global_Task_Lock_Nesting + 1; - - if T.Global_Task_Lock_Nesting = 1 then - Defer_Abort_Nestable (T); - Write_Lock (Global_Task_Lock'Access); - end if; - end Task_Lock; - procedure Task_Lock (Self_ID : Task_ID) is begin Self_ID.Global_Task_Lock_Nesting := Self_ID.Global_Task_Lock_Nesting + 1; if Self_ID.Global_Task_Lock_Nesting = 1 then Defer_Abort_Nestable (Self_ID); ! Write_Lock (Global_Task_Lock'Access); end if; end Task_Lock; ! ----------------- ! -- Task_Unlock -- ! ----------------- ! ! procedure Task_Unlock is ! T : Task_ID := STPO.Self; ! begin ! pragma Assert (T.Global_Task_Lock_Nesting > 0); ! T.Global_Task_Lock_Nesting := T.Global_Task_Lock_Nesting - 1; ! if T.Global_Task_Lock_Nesting = 0 then ! Unlock (Global_Task_Lock'Access); ! Undefer_Abort_Nestable (T); end if; ! end Task_Unlock; procedure Task_Unlock (Self_ID : Task_ID) is begin Self_ID.Global_Task_Lock_Nesting := Self_ID.Global_Task_Lock_Nesting - 1; if Self_ID.Global_Task_Lock_Nesting = 0 then ! Unlock (Global_Task_Lock'Access); Undefer_Abort_Nestable (Self_ID); end if; end Task_Unlock; ------------------- -- Undefer_Abort -- ------------------- --- 659,714 ---- -- Task_Lock -- --------------- procedure Task_Lock (Self_ID : Task_ID) is begin Self_ID.Global_Task_Lock_Nesting := Self_ID.Global_Task_Lock_Nesting + 1; if Self_ID.Global_Task_Lock_Nesting = 1 then Defer_Abort_Nestable (Self_ID); ! Write_Lock (Global_Task_Lock'Access, Global_Lock => True); end if; end Task_Lock; ! procedure Task_Lock is begin ! Task_Lock (STPO.Self); ! end Task_Lock; ! --------------- ! -- Task_Name -- ! --------------- ! function Task_Name return String is ! use System.Task_Info; ! ! begin ! if STPO.Self.Common.Task_Image /= null then ! return STPO.Self.Common.Task_Image.all; ! else ! return ""; end if; ! end Task_Name; ! ! ----------------- ! -- Task_Unlock -- ! ----------------- procedure Task_Unlock (Self_ID : Task_ID) is begin + pragma Assert (Self_ID.Global_Task_Lock_Nesting > 0); Self_ID.Global_Task_Lock_Nesting := Self_ID.Global_Task_Lock_Nesting - 1; if Self_ID.Global_Task_Lock_Nesting = 0 then ! Unlock (Global_Task_Lock'Access, Global_Lock => True); Undefer_Abort_Nestable (Self_ID); end if; end Task_Unlock; + procedure Task_Unlock is + begin + Task_Unlock (STPO.Self); + end Task_Unlock; + ------------------- -- Undefer_Abort -- ------------------- *************** package body System.Tasking.Initializati *** 700,713 **** -- Undefer_Abort is called on any abortion completion point (aka. -- synchronization point). It performs the following actions if they ! -- are pending: (1) change the base priority, (2) abort the task, ! -- (3) raise a pending exception. -- The priority change has to occur before abortion. Otherwise, it would -- take effect no earlier than the next abortion completion point. procedure Undefer_Abort (Self_ID : Task_ID) is begin pragma Assert (Self_ID.Deferral_Level = 1); Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1; --- 717,733 ---- -- Undefer_Abort is called on any abortion completion point (aka. -- synchronization point). It performs the following actions if they ! -- are pending: (1) change the base priority, (2) abort the task. -- The priority change has to occur before abortion. Otherwise, it would -- take effect no earlier than the next abortion completion point. procedure Undefer_Abort (Self_ID : Task_ID) is begin + if No_Abort and then not Dynamic_Priority_Support then + return; + end if; + pragma Assert (Self_ID.Deferral_Level = 1); Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1; *************** package body System.Tasking.Initializati *** 725,747 **** -- Undefer_Abort_Nestable -- ---------------------------- ! -- An earlier version would re-defer abort if an abort is ! -- in progress. Then, we modified the effect of the raise ! -- statement so that it defers abort until control reaches a ! -- handler. That was done to prevent "skipping over" a ! -- handler if another asynchronous abort occurs during the ! -- propagation of the abort to the handler. ! -- There has been talk of reversing that decision, based on ! -- a newer implementation of exception propagation. Care must ! -- be taken to evaluate how such a change would interact with ! -- the above code and all the places where abort-deferral is ! -- used to bridge over critical transitions, such as entry to ! -- the scope of a region with a finalizer and entry into the -- body of an accept-procedure. procedure Undefer_Abort_Nestable (Self_ID : Task_ID) is begin pragma Assert (Self_ID.Deferral_Level > 0); Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1; --- 745,769 ---- -- Undefer_Abort_Nestable -- ---------------------------- ! -- An earlier version would re-defer abort if an abort is in progress. ! -- Then, we modified the effect of the raise statement so that it defers ! -- abort until control reaches a handler. That was done to prevent ! -- "skipping over" a handler if another asynchronous abort occurs during ! -- the propagation of the abort to the handler. ! -- There has been talk of reversing that decision, based on a newer ! -- implementation of exception propagation. Care must be taken to evaluate ! -- how such a change would interact with the above code and all the places ! -- where abort-deferral is used to bridge over critical transitions, such ! -- as entry to the scope of a region with a finalizer and entry into the -- body of an accept-procedure. procedure Undefer_Abort_Nestable (Self_ID : Task_ID) is begin + if No_Abort and then not Dynamic_Priority_Support then + return; + end if; + pragma Assert (Self_ID.Deferral_Level > 0); Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1; *************** package body System.Tasking.Initializati *** 764,772 **** -- to reduce overhead due to multiple calls to Self. procedure Undefer_Abortion is ! Self_ID : constant Task_ID := STPO.Self; ! begin pragma Assert (Self_ID.Deferral_Level > 0); Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1; --- 786,798 ---- -- to reduce overhead due to multiple calls to Self. procedure Undefer_Abortion is ! Self_ID : Task_ID; begin + if No_Abort and then not Dynamic_Priority_Support then + return; + end if; + + Self_ID := STPO.Self; pragma Assert (Self_ID.Deferral_Level > 0); Self_ID.Deferral_Level := Self_ID.Deferral_Level - 1; *************** package body System.Tasking.Initializati *** 799,808 **** --- 825,844 ---- if Self_Id.Pending_Action then Self_Id.Pending_Action := False; Self_Id.Deferral_Level := Self_Id.Deferral_Level + 1; + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (Self_Id); Self_Id.Pending_Action := False; Poll_Base_Priority_Change (Self_Id); Unlock (Self_Id); + + if Single_Lock then + Unlock_RTS; + end if; + Self_Id.Deferral_Level := Self_Id.Deferral_Level - 1; if Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level then *************** package body System.Tasking.Initializati *** 846,852 **** New_State : Entry_Call_State) is Caller : constant Task_ID := Entry_Call.Self; - begin pragma Debug (Debug.Trace (Self_ID, "Wakeup_Entry_Caller", Caller, 'E')); --- 882,887 ---- *************** package body System.Tasking.Initializati *** 878,926 **** function Get_Current_Excep return SSL.EOA is Me : constant Task_ID := STPO.Self; - begin return Me.Common.Compiler_Data.Current_Excep'Access; end Get_Current_Excep; function Get_Exc_Stack_Addr return Address is Me : constant Task_ID := STPO.Self; - begin return Me.Common.Compiler_Data.Exc_Stack_Addr; end Get_Exc_Stack_Addr; function Get_Jmpbuf_Address return Address is Me : constant Task_ID := STPO.Self; - begin return Me.Common.Compiler_Data.Jmpbuf_Address; end Get_Jmpbuf_Address; function Get_Machine_State_Addr return Address is Me : constant Task_ID := STPO.Self; - begin return Me.Common.Compiler_Data.Machine_State_Addr; end Get_Machine_State_Addr; function Get_Sec_Stack_Addr return Address is Me : constant Task_ID := STPO.Self; - begin return Me.Common.Compiler_Data.Sec_Stack_Addr; end Get_Sec_Stack_Addr; function Get_Stack_Info return Stack_Checking.Stack_Access is Me : constant Task_ID := STPO.Self; - begin return Me.Common.Compiler_Data.Pri_Stack_Info'Access; end Get_Stack_Info; procedure Set_Exc_Stack_Addr (Self_ID : Address; Addr : Address) is Me : Task_ID := To_Task_Id (Self_ID); - begin if Me = Null_Task then Me := STPO.Self; --- 913,954 ---- *************** package body System.Tasking.Initializati *** 931,977 **** procedure Set_Jmpbuf_Address (Addr : Address) is Me : Task_ID := STPO.Self; - begin Me.Common.Compiler_Data.Jmpbuf_Address := Addr; end Set_Jmpbuf_Address; procedure Set_Machine_State_Addr (Addr : Address) is Me : Task_ID := STPO.Self; - begin Me.Common.Compiler_Data.Machine_State_Addr := Addr; end Set_Machine_State_Addr; procedure Set_Sec_Stack_Addr (Addr : Address) is Me : Task_ID := STPO.Self; - begin Me.Common.Compiler_Data.Sec_Stack_Addr := Addr; end Set_Sec_Stack_Addr; procedure Timed_Delay_T (Time : Duration; Mode : Integer) is - Self_ID : constant Task_ID := Self; - begin ! STPO.Timed_Delay (Self_ID, Time, Mode); end Timed_Delay_T; ! ------------------------ ! -- Soft-Link Dummies -- ! ------------------------ -- These are dummies for subprograms that are only needed by certain ! -- optional run-time system packages. If they are needed, the soft -- links will be redirected to the real subprogram by elaboration of -- the subprogram body where the real subprogram is declared. procedure Finalize_Attributes (T : Task_ID) is begin null; end Finalize_Attributes; procedure Initialize_Attributes (T : Task_ID) is begin null; end Initialize_Attributes; --- 959,1002 ---- procedure Set_Jmpbuf_Address (Addr : Address) is Me : Task_ID := STPO.Self; begin Me.Common.Compiler_Data.Jmpbuf_Address := Addr; end Set_Jmpbuf_Address; procedure Set_Machine_State_Addr (Addr : Address) is Me : Task_ID := STPO.Self; begin Me.Common.Compiler_Data.Machine_State_Addr := Addr; end Set_Machine_State_Addr; procedure Set_Sec_Stack_Addr (Addr : Address) is Me : Task_ID := STPO.Self; begin Me.Common.Compiler_Data.Sec_Stack_Addr := Addr; end Set_Sec_Stack_Addr; procedure Timed_Delay_T (Time : Duration; Mode : Integer) is begin ! STPO.Timed_Delay (STPO.Self, Time, Mode); end Timed_Delay_T; ! ----------------------- ! -- Soft-Link Dummies -- ! ----------------------- -- These are dummies for subprograms that are only needed by certain ! -- optional run-time system packages. If they are needed, the soft -- links will be redirected to the real subprogram by elaboration of -- the subprogram body where the real subprogram is declared. procedure Finalize_Attributes (T : Task_ID) is + pragma Warnings (Off, T); begin null; end Finalize_Attributes; procedure Initialize_Attributes (T : Task_ID) is + pragma Warnings (Off, T); begin null; end Initialize_Attributes; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasini.ads gcc-3.3/gcc/ada/s-tasini.ads *** gcc-3.2.3/gcc/ada/s-tasini.ads 2002-05-04 03:28:49.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasini.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-1999, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 35,59 **** -- This package provides overall initialization of the tasking portion of the -- RTS. This package must be elaborated before any tasking features are used. - -- It also contains initialization for Ada Task Control Block (ATCB) records. package System.Tasking.Initialization is procedure Remove_From_All_Tasks_List (T : Task_ID); -- Remove T from All_Tasks_List. ! ! ------------------------------------------------ ! -- Static (Compile-Time) Configuration Flags -- ! ------------------------------------------------ ! ! -- ????? ! -- Maybe this does not belong here? Where else? ! -- For now, it is here because so is Change_Base_Priority, ! -- and the two are used together. ! ! Dynamic_Priority_Support : constant Boolean := True; ! -- Should we poll for pending base priority changes at every ! -- abort completion point? --------------------------------- -- Tasking-Specific Soft Links -- --- 34,45 ---- -- This package provides overall initialization of the tasking portion of the -- RTS. This package must be elaborated before any tasking features are used. package System.Tasking.Initialization is procedure Remove_From_All_Tasks_List (T : Task_ID); -- Remove T from All_Tasks_List. ! -- Call this function with RTS_Lock taken. --------------------------------- -- Tasking-Specific Soft Links -- *************** package System.Tasking.Initialization is *** 88,96 **** -- 1) base priority changes ! -- 2) exceptions that need to be raised ! ! -- 3) abort/ATC -- Abort deferral MAY be nested (Self_ID.Deferral_Level is a count), -- but to avoid waste and undetected errors, it generally SHOULD NOT --- 74,80 ---- -- 1) base priority changes ! -- 2) abort/ATC -- Abort deferral MAY be nested (Self_ID.Deferral_Level is a count), -- but to avoid waste and undetected errors, it generally SHOULD NOT *************** package System.Tasking.Initialization is *** 118,127 **** -- deferred, and do not modify the deferral level. -- There is also a set of non-linable defer/undefer routines, ! -- for direct call from the compiler. These are not in-lineable -- because they may need to be called via pointers ("soft links"). -- For the sake of efficiency, the version with Self_ID as parameter ! -- should used wherever possible. These are all nestable. -- Non-nestable inline versions -- --- 102,111 ---- -- deferred, and do not modify the deferral level. -- There is also a set of non-linable defer/undefer routines, ! -- for direct call from the compiler. These are not in-lineable -- because they may need to be called via pointers ("soft links"). -- For the sake of efficiency, the version with Self_ID as parameter ! -- should used wherever possible. These are all nestable. -- Non-nestable inline versions -- *************** package System.Tasking.Initialization is *** 140,146 **** pragma Inline (Undefer_Abort_Nestable); -- NON-INLINE versions without Self_ID for code generated by the ! -- expander and for hard links procedure Defer_Abortion; procedure Undefer_Abortion; --- 124,130 ---- pragma Inline (Undefer_Abort_Nestable); -- NON-INLINE versions without Self_ID for code generated by the ! -- expander and for soft links procedure Defer_Abortion; procedure Undefer_Abortion; *************** package System.Tasking.Initialization is *** 171,177 **** --- 155,164 ---- ---------------------- procedure Task_Lock (Self_ID : Task_ID); + pragma Inline (Task_Lock); + procedure Task_Unlock (Self_ID : Task_ID); + pragma Inline (Task_Unlock); -- These are versions of Lock_Task and Unlock_Task created for use -- within the GNARL. diff -Nrc3pad gcc-3.2.3/gcc/ada/s-taskin.adb gcc-3.3/gcc/ada/s-taskin.adb *** gcc-3.2.3/gcc/ada/s-taskin.adb 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-taskin.adb 2002-03-14 11:00:00.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- -- Copyright (C) 1991-2001 Florida State University -- -- -- --- 6,11 ---- *************** package body System.Tasking is *** 67,74 **** -- Initialize_ATCB -- --------------------- - -- Call this only with abort deferred and holding All_Tasks_L. - procedure Initialize_ATCB (Self_ID : Task_ID; Task_Entry_Point : Task_Procedure_Access; --- 66,71 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-taskin.ads gcc-3.3/gcc/ada/s-taskin.ads *** gcc-3.2.3/gcc/ada/s-taskin.ads 2002-05-04 03:28:49.000000000 +0000 --- gcc-3.3/gcc/ada/s-taskin.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** with System.Soft_Links; *** 52,58 **** with System.Task_Primitives; -- used for Private_Data - -- Lock (in System.Tasking.Protected_Objects) with Unchecked_Conversion; --- 51,56 ---- *************** package System.Tasking is *** 82,96 **** -- Unlock (Y); -- -- Locks with lower (smaller) level number cannot be locked ! -- while holding a lock with a higher level number. (The level -- number is the number at the left.) -- -- 1. System.Tasking.PO_Simple.Protection.L (any PO lock) -- 2. System.Tasking.Initialization.Global_Task_Lock (in body) ! -- 3. System.Tasking.Task_Attributes.All_Attrs_L ! -- 4. System.Task_Primitives.Operations.All_Tasks_L ! -- 5. System.Interrupts.L (in body) ! -- 6. System.Tasking.Ada_Task_Control_Block.LL.L (any TCB lock) -- -- Clearly, there can be no circular chain of hold-and-wait -- relationships involving locks in different ordering levels. --- 80,92 ---- -- Unlock (Y); -- -- Locks with lower (smaller) level number cannot be locked ! -- while holding a lock with a higher level number. (The level -- number is the number at the left.) -- -- 1. System.Tasking.PO_Simple.Protection.L (any PO lock) -- 2. System.Tasking.Initialization.Global_Task_Lock (in body) ! -- 3. System.Task_Primitives.Operations.Single_RTS_Lock ! -- 4. System.Tasking.Ada_Task_Control_Block.LL.L (any TCB lock) -- -- Clearly, there can be no circular chain of hold-and-wait -- relationships involving locks in different ordering levels. *************** package System.Tasking is *** 99,105 **** -- clearly wrong since there can be calls to "new" inside protected -- operations. The new ordering prevents these failures. -- ! -- Sometime we need to hold two ATCB locks at the same time. To allow -- us to order the locking, each ATCB is given a unique serial -- number. If one needs to hold locks on several ATCBs at once, -- the locks with lower serial numbers must be locked first. --- 95,101 ---- -- clearly wrong since there can be calls to "new" inside protected -- operations. The new ordering prevents these failures. -- ! -- Sometimes we need to hold two ATCB locks at the same time. To allow -- us to order the locking, each ATCB is given a unique serial -- number. If one needs to hold locks on several ATCBs at once, -- the locks with lower serial numbers must be locked first. *************** package System.Tasking is *** 112,120 **** -- . The environment task has a lower serial number than any other task. -- . If the activator of a task is different from the task's parent, -- the parent always has a lower serial number than the activator. - -- - -- For interrupt-handler state, we have a special locking rule. - -- See System.Interrupts (spec) for explanation. --------------------------------- -- Task_ID related definitions -- --- 108,113 ---- *************** package System.Tasking is *** 468,474 **** All_Tasks_Link : Task_ID; -- Used to link this task to the list of all tasks in the system. ! -- Protection: All_Tasks.L. Activation_Link : Task_ID; -- Used to link this task to a list of tasks to be activated. --- 461,467 ---- All_Tasks_Link : Task_ID; -- Used to link this task to the list of all tasks in the system. ! -- Protection: RTS_Lock. Activation_Link : Task_ID; -- Used to link this task to a list of tasks to be activated. *************** package System.Tasking is *** 933,943 **** -- is, in user terms Direct_Attributes : Direct_Attribute_Array; ! -- for task attributes that have same size as Address Is_Defined : Direct_Index_Vector := 0; ! -- bit I is 1 iff Direct_Attributes (I) is defined Indirect_Attributes : Access_Address; ! -- a pointer to chain of records for other attributes that -- are not address-sized, including all tagged types. Entry_Queues : Task_Entry_Queue_Array (1 .. Entry_Num); --- 926,938 ---- -- is, in user terms Direct_Attributes : Direct_Attribute_Array; ! -- For task attributes that have same size as Address ! Is_Defined : Direct_Index_Vector := 0; ! -- Bit I is 1 iff Direct_Attributes (I) is defined ! Indirect_Attributes : Access_Address; ! -- A pointer to chain of records for other attributes that -- are not address-sized, including all tagged types. Entry_Queues : Task_Entry_Queue_Array (1 .. Entry_Num); *************** package System.Tasking is *** 963,969 **** T : in out Task_ID; Success : out Boolean); -- Initialize fields of a TCB and link into global TCB structures ! -- Call this only with abort deferred and holding All_Tasks_L. private --- 958,964 ---- T : in out Task_ID; Success : out Boolean); -- Initialize fields of a TCB and link into global TCB structures ! -- Call this only with abort deferred and holding RTS_Lock. private diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasque.adb gcc-3.3/gcc/ada/s-tasque.adb *** gcc-3.2.3/gcc/ada/s-tasque.adb 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasque.adb 2002-03-14 11:00:00.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** with System.Task_Primitives.Operations; *** 45,61 **** with System.Tasking.Initialization; -- used for Wakeup_Entry_Caller ! package body System.Tasking.Queuing is ! use System.Task_Primitives.Operations; ! use System.Tasking.Protected_Objects; ! use System.Tasking.Protected_Objects.Entries; ! procedure Wakeup_Entry_Caller ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link; ! New_State : Entry_Call_State) ! renames Initialization.Wakeup_Entry_Caller; -- Entry Queues implemented as doubly linked list. --- 43,57 ---- with System.Tasking.Initialization; -- used for Wakeup_Entry_Caller ! with System.Parameters; ! -- used for Single_Lock ! package body System.Tasking.Queuing is ! use Parameters; ! use Task_Primitives.Operations; ! use Protected_Objects; ! use Protected_Objects.Entries; -- Entry Queues implemented as doubly linked list. *************** package body System.Tasking.Queuing is *** 81,91 **** procedure Broadcast_Program_Error (Self_ID : Task_ID; Object : Protection_Entries_Access; ! Pending_Call : Entry_Call_Link) is ! Entry_Call : Entry_Call_Link; ! begin if Pending_Call /= null then Send_Program_Error (Self_ID, Pending_Call); end if; --- 77,91 ---- procedure Broadcast_Program_Error (Self_ID : Task_ID; Object : Protection_Entries_Access; ! Pending_Call : Entry_Call_Link; ! RTS_Locked : Boolean := False) is ! Entry_Call : Entry_Call_Link; begin + if Single_Lock and then not RTS_Locked then + Lock_RTS; + end if; + if Pending_Call /= null then Send_Program_Error (Self_ID, Pending_Call); end if; *************** package body System.Tasking.Queuing is *** 100,105 **** --- 100,109 ---- Dequeue_Head (Object.Entry_Queues (E), Entry_Call); end loop; end loop; + + if Single_Lock and then not RTS_Locked then + Unlock_RTS; + end if; end Broadcast_Program_Error; ----------------- *************** package body System.Tasking.Queuing is *** 472,478 **** is Entry_Call : Entry_Call_Link; Temp_Call : Entry_Call_Link; ! Entry_Index : Protected_Entry_Index; begin Entry_Call := null; --- 476,484 ---- is Entry_Call : Entry_Call_Link; Temp_Call : Entry_Call_Link; ! Entry_Index : Protected_Entry_Index := Null_Entry; -- stop warning ! ! -- ??? should add comment as to why Entry_Index is always initialized begin Entry_Call := null; *************** package body System.Tasking.Queuing is *** 485,494 **** for J in Object.Entry_Queues'Range loop Temp_Call := Head (Object.Entry_Queues (J)); ! if Temp_Call /= null and then ! Object.Entry_Bodies ( ! Object.Find_Body_Index (Object.Compiler_Info, J)). ! Barrier (Object.Compiler_Info, J) then if (Entry_Call = null or else Entry_Call.Prio < Temp_Call.Prio) --- 491,502 ---- for J in Object.Entry_Queues'Range loop Temp_Call := Head (Object.Entry_Queues (J)); ! if Temp_Call /= null ! and then ! Object.Entry_Bodies ! (Object.Find_Body_Index ! (Object.Compiler_Info, J)). ! Barrier (Object.Compiler_Info, J) then if (Entry_Call = null or else Entry_Call.Prio < Temp_Call.Prio) *************** package body System.Tasking.Queuing is *** 505,514 **** for J in Object.Entry_Queues'Range loop Temp_Call := Head (Object.Entry_Queues (J)); ! if Temp_Call /= null and then ! Object.Entry_Bodies ( ! Object.Find_Body_Index (Object.Compiler_Info, J)). ! Barrier (Object.Compiler_Info, J) then Entry_Call := Temp_Call; Entry_Index := J; --- 513,524 ---- for J in Object.Entry_Queues'Range loop Temp_Call := Head (Object.Entry_Queues (J)); ! if Temp_Call /= null ! and then ! Object.Entry_Bodies ! (Object.Find_Body_Index ! (Object.Compiler_Info, J)). ! Barrier (Object.Compiler_Info, J) then Entry_Call := Temp_Call; Entry_Index := J; *************** package body System.Tasking.Queuing is *** 549,564 **** is Entry_Call : Entry_Call_Link; Temp_Call : Entry_Call_Link; ! Entry_Index : Task_Entry_Index; Temp_Entry : Task_Entry_Index; begin Open_Alternative := False; ! Entry_Call := null; if Priority_Queuing then ! ! -- Priority Queuing for J in Open_Accepts'Range loop Temp_Entry := Open_Accepts (J).S; --- 559,574 ---- is Entry_Call : Entry_Call_Link; Temp_Call : Entry_Call_Link; ! Entry_Index : Task_Entry_Index := Task_Entry_Index'First; Temp_Entry : Task_Entry_Index; begin Open_Alternative := False; ! Entry_Call := null; ! Selection := No_Rendezvous; if Priority_Queuing then ! -- Priority queueing case for J in Open_Accepts'Range loop Temp_Entry := Open_Accepts (J).S; *************** package body System.Tasking.Queuing is *** 567,578 **** Open_Alternative := True; Temp_Call := Head (Acceptor.Entry_Queues (Temp_Entry)); ! if Temp_Call /= null and then ! (Entry_Call = null or else ! Entry_Call.Prio < Temp_Call.Prio) ! then ! Entry_Call := Head (Acceptor.Entry_Queues (Temp_Entry)); Entry_Index := Temp_Entry; Selection := J; end if; --- 577,587 ---- Open_Alternative := True; Temp_Call := Head (Acceptor.Entry_Queues (Temp_Entry)); ! if Temp_Call /= null ! and then (Entry_Call = null ! or else Entry_Call.Prio < Temp_Call.Prio) then ! Entry_Call := Head (Acceptor.Entry_Queues (Temp_Entry)); Entry_Index := Temp_Entry; Selection := J; end if; *************** package body System.Tasking.Queuing is *** 580,586 **** end loop; else ! -- FIFO Queuing for J in Open_Accepts'Range loop Temp_Entry := Open_Accepts (J).S; --- 589,595 ---- end loop; else ! -- FIFO Queuing case for J in Open_Accepts'Range loop Temp_Entry := Open_Accepts (J).S; *************** package body System.Tasking.Queuing is *** 599,608 **** end loop; end if; ! if Entry_Call = null then ! Selection := No_Rendezvous; ! ! else Dequeue_Head (Acceptor.Entry_Queues (Entry_Index), Entry_Call); -- Guard is open --- 608,614 ---- end loop; end if; ! if Entry_Call /= null then Dequeue_Head (Acceptor.Entry_Queues (Entry_Index), Entry_Call); -- Guard is open *************** package body System.Tasking.Queuing is *** 620,631 **** Entry_Call : Entry_Call_Link) is Caller : Task_ID; - begin Caller := Entry_Call.Self; Entry_Call.Exception_To_Raise := Program_Error'Identity; Write_Lock (Caller); ! Wakeup_Entry_Caller (Self_ID, Entry_Call, Done); Unlock (Caller); end Send_Program_Error; --- 626,636 ---- Entry_Call : Entry_Call_Link) is Caller : Task_ID; begin Caller := Entry_Call.Self; Entry_Call.Exception_To_Raise := Program_Error'Identity; Write_Lock (Caller); ! Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done); Unlock (Caller); end Send_Program_Error; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasque.ads gcc-3.3/gcc/ada/s-tasque.ads *** gcc-3.2.3/gcc/ada/s-tasque.ads 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasque.ads 2002-03-14 11:00:00.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-1998 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** package System.Tasking.Queuing is *** 43,53 **** procedure Broadcast_Program_Error (Self_ID : Task_ID; Object : POE.Protection_Entries_Access; ! Pending_Call : Entry_Call_Link); ! -- Raise Program_Error in all tasks calling the protected entries ! -- of Object. The exception will not be raised immediately for ! -- the calling task; it will be deferred until it calls ! -- Raise_Pending_Exception. procedure Enqueue (E : in out Entry_Queue; Call : Entry_Call_Link); -- Enqueue Call at the end of entry_queue E --- 41,53 ---- procedure Broadcast_Program_Error (Self_ID : Task_ID; Object : POE.Protection_Entries_Access; ! Pending_Call : Entry_Call_Link; ! RTS_Locked : Boolean := False); ! -- Raise Program_Error in all tasks calling the protected entries of Object ! -- The exception will not be raised immediately for the calling task; it ! -- will be deferred until it calls Check_Exception. ! -- RTS_Locked indicates whether the global RTS lock is taken (only ! -- relevant if Single_Lock is True). procedure Enqueue (E : in out Entry_Queue; Call : Entry_Call_Link); -- Enqueue Call at the end of entry_queue E diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasren.adb gcc-3.3/gcc/ada/s-tasren.adb *** gcc-3.2.3/gcc/ada/s-tasren.adb 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasren.adb 2002-03-14 11:00:00.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** with System.Tasking.Protected_Objects.Op *** 79,92 **** with System.Tasking.Debug; -- used for Trace package body System.Tasking.Rendezvous is package STPO renames System.Task_Primitives.Operations; ! package POO renames System.Tasking.Protected_Objects.Operations; ! package POE renames System.Tasking.Protected_Objects.Entries; ! use System.Task_Primitives; ! use System.Task_Primitives.Operations; type Select_Treatment is ( Accept_Alternative_Selected, -- alternative with non-null body --- 77,99 ---- with System.Tasking.Debug; -- used for Trace + with System.Parameters; + -- used for Single_Lock + -- Runtime_Traces + + with System.Traces.Tasking; + -- used for Send_Trace_Info + package body System.Tasking.Rendezvous is package STPO renames System.Task_Primitives.Operations; ! package POO renames Protected_Objects.Operations; ! package POE renames Protected_Objects.Entries; ! use Parameters; ! use Task_Primitives.Operations; ! use System.Traces; ! use System.Traces.Tasking; type Select_Treatment is ( Accept_Alternative_Selected, -- alternative with non-null body *************** package body System.Tasking.Rendezvous i *** 138,149 **** -- means either the user is trying to do a potentially blocking -- operation from within a protected object, or there is a -- runtime system/compiler error that has failed to undefer ! -- an earlier abort deferral. Thus, for debugging it may be -- wise to modify the above renamings to the non-nestable forms. ! procedure Boost_Priority ! (Call : Entry_Call_Link; ! Acceptor : Task_ID); pragma Inline (Boost_Priority); -- Call this only with abort deferred and holding lock of Acceptor. --- 145,154 ---- -- means either the user is trying to do a potentially blocking -- operation from within a protected object, or there is a -- runtime system/compiler error that has failed to undefer ! -- an earlier abort deferral. Thus, for debugging it may be -- wise to modify the above renamings to the non-nestable forms. ! procedure Boost_Priority (Call : Entry_Call_Link; Acceptor : Task_ID); pragma Inline (Boost_Priority); -- Call this only with abort deferred and holding lock of Acceptor. *************** package body System.Tasking.Rendezvous i *** 174,209 **** pragma Inline (Wait_For_Call); -- Call this only with abort deferred and holding lock of Self_Id. -- An accepting task goes into Sleep by calling this routine ! -- waiting for a call from the caller or waiting for an abortion. -- Make sure Self_Id is locked before calling this routine. ----------------- -- Accept_Call -- ----------------- - -- Compiler interface only. Do not call from within the RTS. - - -- source: - -- accept E do ...A... end E; - -- expansion: - -- A27b : address; - -- L26b : label - -- begin - -- accept_call (1, A27b); - -- ...A... - -- complete_rendezvous; - -- <> - -- exception - -- when all others => - -- exceptional_complete_rendezvous (get_gnat_exception); - -- end; - - -- The handler for Abort_Signal (*all* others) is to handle the case when - -- the acceptor is aborted between Accept_Call and the corresponding - -- Complete_Rendezvous call. We need to wake up the caller in this case. - - -- See also Selective_Wait - procedure Accept_Call (E : Task_Entry_Index; Uninterpreted_Data : out System.Address) --- 179,191 ---- pragma Inline (Wait_For_Call); -- Call this only with abort deferred and holding lock of Self_Id. -- An accepting task goes into Sleep by calling this routine ! -- waiting for a call from the caller or waiting for an abort. -- Make sure Self_Id is locked before calling this routine. ----------------- -- Accept_Call -- ----------------- procedure Accept_Call (E : Task_Entry_Index; Uninterpreted_Data : out System.Address) *************** package body System.Tasking.Rendezvous i *** 216,221 **** --- 198,207 ---- begin Initialization.Defer_Abort (Self_Id); + if Single_Lock then + Lock_RTS; + end if; + STPO.Write_Lock (Self_Id); if not Self_Id.Callable then *************** package body System.Tasking.Rendezvous i *** 224,229 **** --- 210,220 ---- pragma Assert (Self_Id.Pending_Action); STPO.Unlock (Self_Id); + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort (Self_Id); -- Should never get here ??? *************** package body System.Tasking.Rendezvous i *** 232,248 **** raise Standard'Abort_Signal; end if; - -- If someone completed this task, this task should not try to - -- access its pending entry calls or queues in this case, as they - -- are being emptied. Wait for abortion to kill us. - -- ????? - -- Recheck the correctness of the above, now that we have made - -- changes. The logic above seems to be based on the assumption - -- that one task can safely clean up another's in-service accepts. - -- ????? - -- Why do we need to block here in this case? - -- Why not just return and let Undefer_Abort do its work? - Queuing.Dequeue_Head (Self_Id.Entry_Queues (E), Entry_Call); if Entry_Call /= null then --- 223,228 ---- *************** package body System.Tasking.Rendezvous i *** 259,318 **** -- Wait for normal call pragma Debug (Debug.Trace (Self_Id, "Accept_Call: wait", 'R')); Wait_For_Call (Self_Id); pragma Assert (Self_Id.Open_Accepts = null); ! if Self_Id.Pending_ATC_Level >= Self_Id.ATC_Nesting_Level then Caller := Self_Id.Common.Call.Self; Uninterpreted_Data := Caller.Entry_Calls (Caller.ATC_Nesting_Level).Uninterpreted_Data; ! end if; ! ! -- If this task has been aborted, skip the Uninterpreted_Data load ! -- (Caller will not be reliable) and fall through to ! -- Undefer_Abort which will allow the task to be killed. ! -- ????? ! -- Perhaps we could do the code anyway, if it has no harm, in order ! -- to get better performance for the normal case. end if; -- Self_Id.Common.Call should already be updated by the Caller -- On return, we will start the rendezvous. STPO.Unlock (Self_Id); Initialization.Undefer_Abort (Self_Id); end Accept_Call; -------------------- -- Accept_Trivial -- -------------------- - -- Compiler interface only. Do not call from within the RTS. - -- This should only be called when there is no accept body, - -- or the except body is empty. - - -- source: - -- accept E; - -- expansion: - -- accept_trivial (1); - - -- The compiler is also able to recognize the following and - -- translate it the same way. - - -- accept E do null; end E; - procedure Accept_Trivial (E : Task_Entry_Index) is ! Self_Id : constant Task_ID := STPO.Self; ! Caller : Task_ID := null; ! Open_Accepts : aliased Accept_List (1 .. 1); ! Entry_Call : Entry_Call_Link; begin Initialization.Defer_Abort_Nestable (Self_Id); STPO.Write_Lock (Self_Id); if not Self_Id.Callable then --- 239,298 ---- -- Wait for normal call + if Parameters.Runtime_Traces then + Send_Trace_Info (W_Accept, Self_Id, Integer (Open_Accepts'Length)); + end if; + pragma Debug (Debug.Trace (Self_Id, "Accept_Call: wait", 'R')); Wait_For_Call (Self_Id); pragma Assert (Self_Id.Open_Accepts = null); ! if Self_Id.Common.Call /= null then Caller := Self_Id.Common.Call.Self; Uninterpreted_Data := Caller.Entry_Calls (Caller.ATC_Nesting_Level).Uninterpreted_Data; ! else ! -- Case of an aborted task. + Uninterpreted_Data := System.Null_Address; + end if; end if; -- Self_Id.Common.Call should already be updated by the Caller -- On return, we will start the rendezvous. STPO.Unlock (Self_Id); + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort (Self_Id); + + if Parameters.Runtime_Traces then + Send_Trace_Info (M_Accept_Complete, Caller, Entry_Index (E)); + end if; end Accept_Call; -------------------- -- Accept_Trivial -- -------------------- procedure Accept_Trivial (E : Task_Entry_Index) is ! Self_Id : constant Task_ID := STPO.Self; ! Caller : Task_ID := null; ! Open_Accepts : aliased Accept_List (1 .. 1); ! Entry_Call : Entry_Call_Link; begin Initialization.Defer_Abort_Nestable (Self_Id); + + if Single_Lock then + Lock_RTS; + end if; + STPO.Write_Lock (Self_Id); if not Self_Id.Callable then *************** package body System.Tasking.Rendezvous i *** 321,326 **** --- 301,311 ---- pragma Assert (Self_Id.Pending_Action); STPO.Unlock (Self_Id); + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort_Nestable (Self_Id); -- Should never get here ??? *************** package body System.Tasking.Rendezvous i *** 329,351 **** raise Standard'Abort_Signal; end if; - -- If someone completed this task, this task should not try to - -- access its pending entry calls or queues in this case, as they - -- are being emptied. Wait for abortion to kill us. - -- ????? - -- Recheck the correctness of the above, now that we have made - -- changes. - Queuing.Dequeue_Head (Self_Id.Entry_Queues (E), Entry_Call); if Entry_Call = null then - -- Need to wait for entry call Open_Accepts (1).Null_Body := True; Open_Accepts (1).S := E; Self_Id.Open_Accepts := Open_Accepts'Unrestricted_Access; pragma Debug (Debug.Trace (Self_Id, "Accept_Trivial: wait", 'R')); --- 314,332 ---- raise Standard'Abort_Signal; end if; Queuing.Dequeue_Head (Self_Id.Entry_Queues (E), Entry_Call); if Entry_Call = null then -- Need to wait for entry call Open_Accepts (1).Null_Body := True; Open_Accepts (1).S := E; Self_Id.Open_Accepts := Open_Accepts'Unrestricted_Access; + if Parameters.Runtime_Traces then + Send_Trace_Info (W_Accept, Self_Id, Integer (Open_Accepts'Length)); + end if; + pragma Debug (Debug.Trace (Self_Id, "Accept_Trivial: wait", 'R')); *************** package body System.Tasking.Rendezvous i *** 359,365 **** STPO.Unlock (Self_Id); else -- found caller already waiting - pragma Assert (Entry_Call.State < Done); STPO.Unlock (Self_Id); --- 340,345 ---- *************** package body System.Tasking.Rendezvous i *** 370,375 **** --- 350,368 ---- STPO.Unlock (Caller); end if; + if Parameters.Runtime_Traces then + Send_Trace_Info (M_Accept_Complete); + + -- Fake one, since there is (???) no way + -- to know that the rendezvous is over + + Send_Trace_Info (M_RDV_Complete); + end if; + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort_Nestable (Self_Id); end Accept_Trivial; *************** package body System.Tasking.Rendezvous i *** 377,386 **** -- Boost_Priority -- -------------------- - -- Call this only with abort deferred and holding lock of Acceptor. - procedure Boost_Priority (Call : Entry_Call_Link; Acceptor : Task_ID) is ! Caller : Task_ID := Call.Self; Caller_Prio : System.Any_Priority := Get_Priority (Caller); Acceptor_Prio : System.Any_Priority := Get_Priority (Acceptor); --- 370,377 ---- -- Boost_Priority -- -------------------- procedure Boost_Priority (Call : Entry_Call_Link; Acceptor : Task_ID) is ! Caller : constant Task_ID := Call.Self; Caller_Prio : System.Any_Priority := Get_Priority (Caller); Acceptor_Prio : System.Any_Priority := Get_Priority (Acceptor); *************** package body System.Tasking.Rendezvous i *** 398,405 **** -- Call_Simple -- ----------------- - -- Compiler interface only. Do not call from within the RTS. - procedure Call_Simple (Acceptor : Task_ID; E : Task_Entry_Index; --- 389,394 ---- *************** package body System.Tasking.Rendezvous i *** 415,422 **** -- Call_Synchronous -- ---------------------- ! -- Compiler interface. ! -- Also called from inside Call_Simple and Task_Entry_Call. procedure Call_Synchronous (Acceptor : Task_ID; --- 404,410 ---- -- Call_Synchronous -- ---------------------- ! -- Called from Call_Simple and Task_Entry_Call. procedure Call_Synchronous (Acceptor : Task_ID; *************** package body System.Tasking.Rendezvous i *** 443,448 **** --- 431,440 ---- Entry_Call.Mode := Mode; Entry_Call.Cancellation_Attempted := False; + if Parameters.Runtime_Traces then + Send_Trace_Info (W_Call, Acceptor, Entry_Index (E)); + end if; + -- If this is a call made inside of an abort deferred region, -- the call should be never abortable. *************** package body System.Tasking.Rendezvous i *** 458,469 **** Entry_Call.Called_Task := Acceptor; Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id; ! -- Note: the caller will undefer abortion on return (see WARNING above) if not Task_Do_Or_Queue (Self_Id, Entry_Call, With_Abort => True) then Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level - 1; Initialization.Undefer_Abort (Self_Id); pragma Debug (Debug.Trace (Self_Id, "CS: exited to ATC level: " & --- 450,474 ---- Entry_Call.Called_Task := Acceptor; Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id; ! -- Note: the caller will undefer abort on return (see WARNING above) ! ! if Single_Lock then ! Lock_RTS; ! end if; if not Task_Do_Or_Queue (Self_Id, Entry_Call, With_Abort => True) then Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level - 1; + + if Single_Lock then + Unlock_RTS; + end if; + + if Parameters.Runtime_Traces then + Send_Trace_Info (E_Missed, Acceptor); + end if; + Initialization.Undefer_Abort (Self_Id); pragma Debug (Debug.Trace (Self_Id, "CS: exited to ATC level: " & *************** package body System.Tasking.Rendezvous i *** 474,484 **** STPO.Write_Lock (Self_Id); pragma Debug (Debug.Trace (Self_Id, "Call_Synchronous: wait", 'R')); ! Entry_Calls.Wait_For_Completion (Self_Id, Entry_Call); pragma Debug (Debug.Trace (Self_Id, "Call_Synchronous: done waiting", 'R')); Rendezvous_Successful := Entry_Call.State = Done; STPO.Unlock (Self_Id); Local_Undefer_Abort (Self_Id); Entry_Calls.Check_Exception (Self_Id, Entry_Call); end Call_Synchronous; --- 479,494 ---- STPO.Write_Lock (Self_Id); pragma Debug (Debug.Trace (Self_Id, "Call_Synchronous: wait", 'R')); ! Entry_Calls.Wait_For_Completion (Entry_Call); pragma Debug (Debug.Trace (Self_Id, "Call_Synchronous: done waiting", 'R')); Rendezvous_Successful := Entry_Call.State = Done; STPO.Unlock (Self_Id); + + if Single_Lock then + Unlock_RTS; + end if; + Local_Undefer_Abort (Self_Id); Entry_Calls.Check_Exception (Self_Id, Entry_Call); end Call_Synchronous; *************** package body System.Tasking.Rendezvous i *** 487,505 **** -- Callable -- -------------- - -- Compiler interface. - -- Do not call from within the RTS, - -- except for body of Ada.Task_Identification. - function Callable (T : Task_ID) return Boolean is Result : Boolean; Self_Id : constant Task_ID := STPO.Self; begin Initialization.Defer_Abort (Self_Id); STPO.Write_Lock (T); Result := T.Callable; STPO.Unlock (T); Initialization.Undefer_Abort (Self_Id); return Result; end Callable; --- 497,521 ---- -- Callable -- -------------- function Callable (T : Task_ID) return Boolean is Result : Boolean; Self_Id : constant Task_ID := STPO.Self; begin Initialization.Defer_Abort (Self_Id); + + if Single_Lock then + Lock_RTS; + end if; + STPO.Write_Lock (T); Result := T.Callable; STPO.Unlock (T); + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort (Self_Id); return Result; end Callable; *************** package body System.Tasking.Rendezvous i *** 508,516 **** -- Cancel_Task_Entry_Call -- ---------------------------- - -- Compiler interface only. Do not call from within the RTS. - -- Call only with abort deferred. - procedure Cancel_Task_Entry_Call (Cancelled : out Boolean) is begin Entry_Calls.Try_To_Cancel_Entry_Call (Cancelled); --- 524,529 ---- *************** package body System.Tasking.Rendezvous i *** 520,527 **** -- Complete_Rendezvous -- ------------------------- - -- See comments for Exceptional_Complete_Rendezvous. - procedure Complete_Rendezvous is begin Exceptional_Complete_Rendezvous (Ada.Exceptions.Null_Id); --- 533,538 ---- *************** package body System.Tasking.Rendezvous i *** 531,552 **** -- Exceptional_Complete_Rendezvous -- ------------------------------------- - -- Compiler interface. - -- Also called from Complete_Rendezvous. - -- ????? - -- Consider phasing out Complete_Rendezvous in favor - -- of direct call to this with Ada.Exceptions.Null_ID. - -- See code expansion examples for Accept_Call and Selective_Wait. - -- ????? - -- If we don't change the interface, consider instead - -- putting an explicit re-raise after this call, in - -- the generated code. That way we could eliminate the - -- code here that reraises the exception. - - -- The deferral level is critical here, - -- since we want to raise an exception or allow abort to take - -- place, if there is an exception or abort pending. - procedure Exceptional_Complete_Rendezvous (Ex : Ada.Exceptions.Exception_Id) is --- 542,547 ---- *************** package body System.Tasking.Rendezvous i *** 565,576 **** --- 560,587 ---- use type STPE.Protection_Entries_Access; begin + -- Consider phasing out Complete_Rendezvous in favor + -- of direct call to this with Ada.Exceptions.Null_ID. + -- See code expansion examples for Accept_Call and Selective_Wait. + -- Also consider putting an explicit re-raise after this call, in + -- the generated code. That way we could eliminate the + -- code here that reraises the exception. + + -- The deferral level is critical here, + -- since we want to raise an exception or allow abort to take + -- place, if there is an exception or abort pending. + pragma Debug (Debug.Trace (Self_Id, "Exceptional_Complete_Rendezvous", 'R')); if Ex = Ada.Exceptions.Null_Id then -- The call came from normal end-of-rendezvous, -- so abort is not yet deferred. + + if Parameters.Runtime_Traces then + Send_Trace_Info (M_RDV_Complete, Entry_Call.Self); + end if; + Initialization.Defer_Abort_Nestable (Self_Id); end if; *************** package body System.Tasking.Rendezvous i *** 578,583 **** --- 589,598 ---- -- been serving when it was aborted. if Ex = Standard'Abort_Signal'Identity then + if Single_Lock then + Lock_RTS; + end if; + while Entry_Call /= null loop Entry_Call.Exception_To_Raise := Tasking_Error'Identity; *************** package body System.Tasking.Rendezvous i *** 593,604 **** -- Complete the call abnormally, with exception. STPO.Write_Lock (Caller); - Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); Entry_Call := Entry_Call.Acceptor_Prev_Call; end loop; else Caller := Entry_Call.Self; --- 608,622 ---- -- Complete the call abnormally, with exception. STPO.Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); Entry_Call := Entry_Call.Acceptor_Prev_Call; end loop; + if Single_Lock then + Unlock_RTS; + end if; + else Caller := Entry_Call.Self; *************** package body System.Tasking.Rendezvous i *** 612,624 **** --- 630,654 ---- if Entry_Call.Called_Task /= null then -- Requeue to another task entry + if Single_Lock then + Lock_RTS; + end if; + if not Task_Do_Or_Queue (Self_Id, Entry_Call, Entry_Call.Requeue_With_Abort) then + if Single_Lock then + Lock_RTS; + end if; + Initialization.Undefer_Abort (Self_Id); raise Tasking_Error; end if; + if Single_Lock then + Unlock_RTS; + end if; + else -- Requeue to a protected entry *************** package body System.Tasking.Rendezvous i *** 630,640 **** --- 660,679 ---- Exception_To_Raise := Program_Error'Identity; Entry_Call.Exception_To_Raise := Exception_To_Raise; + + if Single_Lock then + Lock_RTS; + end if; + STPO.Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); + if Single_Lock then + Unlock_RTS; + end if; + else POO.PO_Do_Or_Queue (Self_Id, Called_PO, Entry_Call, *************** package body System.Tasking.Rendezvous i *** 644,657 **** end if; end if; ! Entry_Calls.Reset_Priority (Entry_Call.Acceptor_Prev_Priority, ! Self_Id); else -- The call does not need to be requeued. Self_Id.Common.Call := Entry_Call.Acceptor_Prev_Call; Entry_Call.Exception_To_Raise := Ex; STPO.Write_Lock (Caller); -- Done with Caller locked to make sure that Wakeup is not lost. --- 683,701 ---- end if; end if; ! Entry_Calls.Reset_Priority ! (Self_Id, Entry_Call.Acceptor_Prev_Priority); else -- The call does not need to be requeued. Self_Id.Common.Call := Entry_Call.Acceptor_Prev_Call; Entry_Call.Exception_To_Raise := Ex; + + if Single_Lock then + Lock_RTS; + end if; + STPO.Write_Lock (Caller); -- Done with Caller locked to make sure that Wakeup is not lost. *************** package body System.Tasking.Rendezvous i *** 664,671 **** Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); ! Entry_Calls.Reset_Priority (Entry_Call.Acceptor_Prev_Priority, ! Self_Id); end if; end if; --- 708,720 ---- Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); ! ! if Single_Lock then ! Unlock_RTS; ! end if; ! ! Entry_Calls.Reset_Priority ! (Self_Id, Entry_Call.Acceptor_Prev_Priority); end if; end if; *************** package body System.Tasking.Rendezvous i *** 675,684 **** Internal_Reraise; end if; ! -- ????? ! -- Do we need to ! -- give precedence to Program_Error that might be raised ! -- due to failure of finalization, over Tasking_Error from -- failure of requeue? end Exceptional_Complete_Rendezvous; --- 724,731 ---- Internal_Reraise; end if; ! -- ??? Do we need to give precedence to Program_Error that might be ! -- raised due to failure of finalization, over Tasking_Error from -- failure of requeue? end Exceptional_Complete_Rendezvous; *************** package body System.Tasking.Rendezvous i *** 710,752 **** -- Requeue_Protected_To_Task_Entry -- ------------------------------------- - -- Compiler interface only. Do not call from within the RTS. - - -- entry e2 when b is - -- begin - -- b := false; - -- ...A... - -- requeue t.e2; - -- end e2; - - -- procedure rPT__E14b (O : address; P : address; E : - -- protected_entry_index) is - -- type rTVP is access rTV; - -- freeze rTVP [] - -- _object : rTVP := rTVP!(O); - -- begin - -- declare - -- rR : protection renames _object._object; - -- vP : integer renames _object.v; - -- bP : boolean renames _object.b; - -- begin - -- b := false; - -- ...A... - -- requeue_protected_to_task_entry (rR'unchecked_access, tTV!(t). - -- _task_id, 2, false); - -- return; - -- end; - -- complete_entry_body (_object._object'unchecked_access, objectF => - -- 0); - -- return; - -- exception - -- when others => - -- abort_undefer.all; - -- exceptional_complete_entry_body (_object._object' - -- unchecked_access, current_exception, objectF => 0); - -- return; - -- end rPT__E14b; - procedure Requeue_Protected_To_Task_Entry (Object : STPE.Protection_Entries_Access; Acceptor : Task_ID; --- 757,762 ---- *************** package body System.Tasking.Rendezvous i *** 768,808 **** -- Requeue_Task_Entry -- ------------------------ - -- Compiler interface only. Do not call from within the RTS. - -- The code generation for task entry requeues is different from that - -- for protected entry requeues. There is a "goto" that skips around - -- the call to Complete_Rendezous, so that Requeue_Task_Entry must also - -- do the work of Complete_Rendezvous. The difference is that it does - -- not report that the call's State = Done. - - -- accept e1 do - -- ...A... - -- requeue e2; - -- ...B... - -- end e1; - - -- A62b : address; - -- L61b : label - -- begin - -- accept_call (1, A62b); - -- ...A... - -- requeue_task_entry (tTV!(t)._task_id, 2, false); - -- goto L61b; - -- ...B... - -- complete_rendezvous; - -- <> - -- exception - -- when others => - -- exceptional_complete_rendezvous (current_exception); - -- end; - procedure Requeue_Task_Entry (Acceptor : Task_ID; E : Task_Entry_Index; With_Abort : Boolean) is ! Self_Id : constant Task_ID := STPO.Self; ! Entry_Call : constant Entry_Call_Link := Self_Id.Common.Call; begin Initialization.Defer_Abort (Self_Id); --- 778,790 ---- -- Requeue_Task_Entry -- ------------------------ procedure Requeue_Task_Entry (Acceptor : Task_ID; E : Task_Entry_Index; With_Abort : Boolean) is ! Self_Id : constant Task_ID := STPO.Self; ! Entry_Call : constant Entry_Call_Link := Self_Id.Common.Call; begin Initialization.Defer_Abort (Self_Id); *************** package body System.Tasking.Rendezvous i *** 817,887 **** -- Selective_Wait -- -------------------- - -- Compiler interface only. Do not call from within the RTS. - -- See comments on Accept_Call. - - -- source code: - - -- select accept e1 do - -- ...A... - -- end e1; - -- ...B... - -- or accept e2; - -- ...C... - -- end select; - - -- expansion: - - -- A32b : address; - -- declare - -- null; - -- if accept_alternative'size * 2 >= 16#8000_0000# then - -- raise storage_error; - -- end if; - -- A37b : T36b; - -- A37b (1) := (null_body => false, s => 1); - -- A37b (2) := (null_body => true, s => 2); - -- if accept_alternative'size * 2 >= 16#8000_0000# then - -- raise storage_error; - -- end if; - -- S0 : aliased T36b := accept_list'A37b; - -- J1 : select_index := 0; - -- L3 : label - -- L1 : label - -- L2 : label - -- procedure e1A is - -- begin - -- abort_undefer.all; - -- L31b : label - -- ...A... - -- <> - -- complete_rendezvous; - -- exception - -- when all others => - -- exceptional_complete_rendezvous (get_gnat_exception); - -- end e1A; - -- begin - -- selective_wait (S0'unchecked_access, simple_mode, A32b, J1); - -- case J1 is - -- when 0 => - -- goto L3; - -- when 1 => - -- e1A; - -- goto L1; - -- when 2 => - -- goto L2; - -- when others => - -- goto L3; - -- end case; - -- <> - -- ...B... - -- goto L3; - -- <> - -- ...C... - -- goto L3; - -- <> - -- end; - procedure Selective_Wait (Open_Accepts : Accept_List_Access; Select_Mode : Select_Modes; --- 799,804 ---- *************** package body System.Tasking.Rendezvous i *** 897,902 **** --- 814,824 ---- begin Initialization.Defer_Abort (Self_Id); + + if Single_Lock then + Lock_RTS; + end if; + STPO.Write_Lock (Self_Id); if not Self_Id.Callable then *************** package body System.Tasking.Rendezvous i *** 906,913 **** STPO.Unlock (Self_Id); ! -- ??? In some cases abort is deferred more than once. Need to figure ! -- out why. Self_Id.Deferral_Level := 1; --- 828,839 ---- STPO.Unlock (Self_Id); ! if Single_Lock then ! Unlock_RTS; ! end if; ! ! -- ??? In some cases abort is deferred more than once. Need to ! -- figure out why this happens. Self_Id.Deferral_Level := 1; *************** package body System.Tasking.Rendezvous i *** 919,933 **** raise Standard'Abort_Signal; end if; - -- If someone completed this task, this task should not try to - -- access its pending entry calls or queues in this case, as they - -- are being emptied. Wait for abortion to kill us. - -- ????? - -- Recheck the correctness of the above, now that we have made - -- changes. - pragma Assert (Open_Accepts /= null); Queuing.Select_Task_Entry_Call (Self_Id, Open_Accepts, Entry_Call, Selection, Open_Alternative); --- 845,854 ---- raise Standard'Abort_Signal; end if; pragma Assert (Open_Accepts /= null); + Uninterpreted_Data := Null_Address; + Queuing.Select_Task_Entry_Call (Self_Id, Open_Accepts, Entry_Call, Selection, Open_Alternative); *************** package body System.Tasking.Rendezvous i *** 940,946 **** if Entry_Call /= null then if Open_Accepts (Selection).Null_Body then Treatment := Accept_Alternative_Completed; - else Setup_For_Rendezvous_With_Body (Entry_Call, Self_Id); Treatment := Accept_Alternative_Selected; --- 861,866 ---- *************** package body System.Tasking.Rendezvous i *** 953,1147 **** end if; end if; - -- ?????? - -- Recheck the logic above against the ARM. - -- Handle the select according to the disposition selected above. case Treatment is ! when Accept_Alternative_Selected => ! ! -- Ready to rendezvous ! ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! ! -- In this case the accept body is not Null_Body. Defer abortion ! -- until it gets into the accept body. ! ! pragma Assert (Self_Id.Deferral_Level = 1); ! ! Initialization.Defer_Abort_Nestable (Self_Id); ! STPO.Unlock (Self_Id); ! when Accept_Alternative_Completed => ! -- Accept body is null, so rendezvous is over immediately. ! STPO.Unlock (Self_Id); ! Caller := Entry_Call.Self; ! STPO.Write_Lock (Caller); ! Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); ! STPO.Unlock (Caller); ! when Accept_Alternative_Open => ! -- Wait for caller. ! Self_Id.Open_Accepts := Open_Accepts; ! pragma Debug ! (Debug.Trace (Self_Id, "Selective_Wait: wait", 'R')); ! Wait_For_Call (Self_Id); ! pragma Assert (Self_Id.Open_Accepts = null); ! -- Self_Id.Common.Call should already be updated by the Caller if ! -- not aborted. It might also be ready to do rendezvous even if ! -- this wakes up due to an abortion. ! -- Therefore, if the call is not empty we need to do the rendezvous ! -- if the accept body is not Null_Body. ! -- ????? ! -- aren't the first two conditions below redundant? ! if Self_Id.Chosen_Index /= No_Rendezvous and then ! Self_Id.Common.Call /= null and then ! not Open_Accepts (Self_Id.Chosen_Index).Null_Body ! then ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! pragma Assert (Self_Id.Deferral_Level = 1); ! Initialization.Defer_Abort_Nestable (Self_Id); ! -- Leave abort deferred until the accept body ! end if; ! STPO.Unlock (Self_Id); ! when Else_Selected => ! pragma Assert (Self_Id.Open_Accepts = null); ! STPO.Unlock (Self_Id); ! when Terminate_Selected => ! -- Terminate alternative is open ! Self_Id.Open_Accepts := Open_Accepts; ! Self_Id.Common.State := Acceptor_Sleep; ! STPO.Unlock (Self_Id); ! -- ????? ! -- We need to check if a signal is pending on an open interrupt ! -- entry. Otherwise this task would become potentially terminatable ! -- and, if none of the siblings are active ! -- any more, the task could not wake up any more, even though a ! -- signal might be pending on an open interrupt entry. ! -- ------------- ! -- This comment paragraph does not make sense. Is it obsolete? ! -- There was no code here to check for pending signals. ! -- Notify ancestors that this task is on a terminate alternative. ! Utilities.Make_Passive (Self_Id, Task_Completed => False); ! -- Wait for normal entry call or termination ! pragma Assert (Self_Id.ATC_Nesting_Level = 1); ! STPO.Write_Lock (Self_Id); ! loop ! Initialization.Poll_Base_Priority_Change (Self_Id); ! exit when Self_Id.Open_Accepts = null; ! Sleep (Self_Id, Acceptor_Sleep); ! end loop; ! Self_Id.Common.State := Runnable; ! pragma Assert (Self_Id.Open_Accepts = null); ! if Self_Id.Terminate_Alternative then ! -- An entry call should have reset this to False, ! -- so we must be aborted. ! -- We cannot be in an async. select, since that ! -- is not legal, so the abort must be of the entire ! -- task. Therefore, we do not need to cancel the ! -- terminate alternative. The cleanup will be done ! -- in Complete_Master. ! pragma Assert (Self_Id.Pending_ATC_Level = 0); ! pragma Assert (Self_Id.Awake_Count = 0); ! -- Trust that it is OK to fall through. ! null; ! else ! -- Self_Id.Common.Call and Self_Id.Chosen_Index ! -- should already be updated by the Caller. ! if Self_Id.Chosen_Index /= No_Rendezvous ! and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body ! then ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! pragma Assert (Self_Id.Deferral_Level = 1); ! -- We need an extra defer here, to keep abort ! -- deferred until we get into the accept body ! Initialization.Defer_Abort_Nestable (Self_Id); end if; - end if; ! STPO.Unlock (Self_Id); ! when No_Alternative_Open => ! -- In this case, Index will be No_Rendezvous on return, which ! -- should cause a Program_Error if it is not a Delay_Mode. ! -- If delay alternative exists (Delay_Mode) we should suspend ! -- until the delay expires. ! Self_Id.Open_Accepts := null; ! if Select_Mode = Delay_Mode then ! Self_Id.Common.State := Delay_Sleep; ! loop ! Initialization.Poll_Base_Priority_Change (Self_Id); ! exit when Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level; ! Sleep (Self_Id, Delay_Sleep); ! end loop; ! Self_Id.Common.State := Runnable; ! STPO.Unlock (Self_Id); ! else ! STPO.Unlock (Self_Id); ! Initialization.Undefer_Abort (Self_Id); ! Ada.Exceptions.Raise_Exception (Program_Error'Identity, ! "Entry call not a delay mode"); ! end if; end case; -- Caller has been chosen. -- Self_Id.Common.Call should already be updated by the Caller. -- Self_Id.Chosen_Index should either be updated by the Caller -- or by Test_Selective_Wait. -- On return, we sill start rendezvous unless the accept body is ! -- null. In the latter case, we will have already completed the RV. Index := Self_Id.Chosen_Index; Initialization.Undefer_Abort_Nestable (Self_Id); - end Selective_Wait; ------------------------------------ --- 873,1066 ---- end if; end if; -- Handle the select according to the disposition selected above. case Treatment is + when Accept_Alternative_Selected => + -- Ready to rendezvous ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! -- In this case the accept body is not Null_Body. Defer abort ! -- until it gets into the accept body. ! pragma Assert (Self_Id.Deferral_Level = 1); ! Initialization.Defer_Abort_Nestable (Self_Id); ! STPO.Unlock (Self_Id); ! when Accept_Alternative_Completed => ! -- Accept body is null, so rendezvous is over immediately. ! if Parameters.Runtime_Traces then ! Send_Trace_Info (M_RDV_Complete, Entry_Call.Self); ! end if; ! STPO.Unlock (Self_Id); ! Caller := Entry_Call.Self; ! STPO.Write_Lock (Caller); ! Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); ! STPO.Unlock (Caller); ! when Accept_Alternative_Open => ! -- Wait for caller. ! Self_Id.Open_Accepts := Open_Accepts; ! pragma Debug ! (Debug.Trace (Self_Id, "Selective_Wait: wait", 'R')); ! if Parameters.Runtime_Traces then ! Send_Trace_Info (W_Select, Self_Id, ! Integer (Open_Accepts'Length)); ! end if; ! Wait_For_Call (Self_Id); ! pragma Assert (Self_Id.Open_Accepts = null); ! -- Self_Id.Common.Call should already be updated by the Caller if ! -- not aborted. It might also be ready to do rendezvous even if ! -- this wakes up due to an abortion. ! -- Therefore, if the call is not empty we need to do the ! -- rendezvous if the accept body is not Null_Body. ! -- Aren't the first two conditions below redundant??? ! if Self_Id.Chosen_Index /= No_Rendezvous ! and then Self_Id.Common.Call /= null ! and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body ! then ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! pragma Assert (Self_Id.Deferral_Level = 1); ! Initialization.Defer_Abort_Nestable (Self_Id); ! -- Leave abort deferred until the accept body ! end if; ! STPO.Unlock (Self_Id); ! when Else_Selected => ! pragma Assert (Self_Id.Open_Accepts = null); ! if Parameters.Runtime_Traces then ! Send_Trace_Info (M_Select_Else); ! end if; ! STPO.Unlock (Self_Id); ! when Terminate_Selected => ! -- Terminate alternative is open ! Self_Id.Open_Accepts := Open_Accepts; ! Self_Id.Common.State := Acceptor_Sleep; ! STPO.Unlock (Self_Id); ! -- Notify ancestors that this task is on a terminate alternative. ! Utilities.Make_Passive (Self_Id, Task_Completed => False); ! -- Wait for normal entry call or termination ! pragma Assert (Self_Id.ATC_Nesting_Level = 1); ! STPO.Write_Lock (Self_Id); ! loop ! Initialization.Poll_Base_Priority_Change (Self_Id); ! exit when Self_Id.Open_Accepts = null; ! Sleep (Self_Id, Acceptor_Sleep); ! end loop; ! Self_Id.Common.State := Runnable; ! pragma Assert (Self_Id.Open_Accepts = null); ! if Self_Id.Terminate_Alternative then ! -- An entry call should have reset this to False, ! -- so we must be aborted. ! -- We cannot be in an async. select, since that ! -- is not legal, so the abort must be of the entire ! -- task. Therefore, we do not need to cancel the ! -- terminate alternative. The cleanup will be done ! -- in Complete_Master. ! pragma Assert (Self_Id.Pending_ATC_Level = 0); ! pragma Assert (Self_Id.Awake_Count = 0); ! -- Trust that it is OK to fall through. ! null; ! else ! -- Self_Id.Common.Call and Self_Id.Chosen_Index ! -- should already be updated by the Caller. ! if Self_Id.Chosen_Index /= No_Rendezvous ! and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body ! then ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! pragma Assert (Self_Id.Deferral_Level = 1); ! -- We need an extra defer here, to keep abort ! -- deferred until we get into the accept body ! Initialization.Defer_Abort_Nestable (Self_Id); ! end if; end if; ! STPO.Unlock (Self_Id); ! when No_Alternative_Open => ! -- In this case, Index will be No_Rendezvous on return, which ! -- should cause a Program_Error if it is not a Delay_Mode. ! -- If delay alternative exists (Delay_Mode) we should suspend ! -- until the delay expires. ! Self_Id.Open_Accepts := null; ! if Select_Mode = Delay_Mode then ! Self_Id.Common.State := Delay_Sleep; ! loop ! Initialization.Poll_Base_Priority_Change (Self_Id); ! exit when ! Self_Id.Pending_ATC_Level < Self_Id.ATC_Nesting_Level; ! Sleep (Self_Id, Delay_Sleep); ! end loop; ! Self_Id.Common.State := Runnable; ! STPO.Unlock (Self_Id); ! else ! STPO.Unlock (Self_Id); ! if Single_Lock then ! Unlock_RTS; ! end if; + Initialization.Undefer_Abort (Self_Id); + Ada.Exceptions.Raise_Exception + (Program_Error'Identity, "Entry call not a delay mode"); + end if; end case; + if Single_Lock then + Unlock_RTS; + end if; + -- Caller has been chosen. -- Self_Id.Common.Call should already be updated by the Caller. -- Self_Id.Chosen_Index should either be updated by the Caller -- or by Test_Selective_Wait. -- On return, we sill start rendezvous unless the accept body is ! -- null. In the latter case, we will have already completed the RV. Index := Self_Id.Chosen_Index; Initialization.Undefer_Abort_Nestable (Self_Id); end Selective_Wait; ------------------------------------ *************** package body System.Tasking.Rendezvous i *** 1152,1159 **** procedure Setup_For_Rendezvous_With_Body (Entry_Call : Entry_Call_Link; ! Acceptor : Task_ID) ! is begin Entry_Call.Acceptor_Prev_Call := Acceptor.Common.Call; Acceptor.Common.Call := Entry_Call; --- 1071,1077 ---- procedure Setup_For_Rendezvous_With_Body (Entry_Call : Entry_Call_Link; ! Acceptor : Task_ID) is begin Entry_Call.Acceptor_Prev_Call := Acceptor.Common.Call; Acceptor.Common.Call := Entry_Call; *************** package body System.Tasking.Rendezvous i *** 1169,1185 **** -- Task_Count -- ---------------- - -- Compiler interface only. Do not call from within the RTS. - function Task_Count (E : Task_Entry_Index) return Natural is Self_Id : constant Task_ID := STPO.Self; Return_Count : Natural; begin Initialization.Defer_Abort (Self_Id); STPO.Write_Lock (Self_Id); Return_Count := Queuing.Count_Waiting (Self_Id.Entry_Queues (E)); STPO.Unlock (Self_Id); Initialization.Undefer_Abort (Self_Id); return Return_Count; end Task_Count; --- 1087,1111 ---- -- Task_Count -- ---------------- function Task_Count (E : Task_Entry_Index) return Natural is Self_Id : constant Task_ID := STPO.Self; Return_Count : Natural; begin Initialization.Defer_Abort (Self_Id); + + if Single_Lock then + Lock_RTS; + end if; + STPO.Write_Lock (Self_Id); Return_Count := Queuing.Count_Waiting (Self_Id.Entry_Queues (E)); STPO.Unlock (Self_Id); + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort (Self_Id); return Return_Count; end Task_Count; *************** package body System.Tasking.Rendezvous i *** 1188,1243 **** -- Task_Do_Or_Queue -- ---------------------- - -- Call this only with abort deferred and holding no locks. - -- May propagate an exception, including Abort_Signal & Tasking_Error. - -- ????? - -- See Check_Callable. Check all call contexts to verify - -- it is OK to raise an exception. - - -- Find out whether Entry_Call can be accepted immediately. - -- If the Acceptor is not callable, raise Tasking_Error. - -- If the rendezvous can start, initiate it. - -- If the accept-body is trivial, also complete the rendezvous. - -- If the acceptor is not ready, enqueue the call. - - -- ????? - -- This should have a special case for Accept_Call and - -- Accept_Trivial, so that - -- we don't have the loop setup overhead, below. - - -- ????? - -- The call state Done is used here and elsewhere to include - -- both the case of normal successful completion, and the case - -- of an exception being raised. The difference is that if an - -- exception is raised no one will pay attention to the fact - -- that State = Done. Instead the exception will be raised in - -- Undefer_Abort, and control will skip past the place where - -- we normally would resume from an entry call. - function Task_Do_Or_Queue (Self_ID : Task_ID; Entry_Call : Entry_Call_Link; With_Abort : Boolean) return Boolean is ! E : constant Task_Entry_Index := Task_Entry_Index (Entry_Call.E); ! Old_State : constant Entry_Call_State := Entry_Call.State; ! Acceptor : constant Task_ID := Entry_Call.Called_Task; ! Parent : constant Task_ID := Acceptor.Common.Parent; Parent_Locked : Boolean := False; ! Null_Body : Boolean; begin pragma Assert (not Queuing.Onqueue (Entry_Call)); ! -- We rely that the call is off-queue for protection, ! -- that the caller will not exit the Entry_Caller_Sleep, ! -- and so will not reuse the call record for another call. -- We rely on the Caller's lock for call State mod's. -- We can't lock Acceptor.Parent while holding Acceptor, -- so lock it in advance if we expect to need to lock it. - -- ????? - -- Is there some better solution? if Acceptor.Terminate_Alternative then STPO.Write_Lock (Parent); --- 1114,1158 ---- -- Task_Do_Or_Queue -- ---------------------- function Task_Do_Or_Queue (Self_ID : Task_ID; Entry_Call : Entry_Call_Link; With_Abort : Boolean) return Boolean is ! E : constant Task_Entry_Index := ! Task_Entry_Index (Entry_Call.E); ! Old_State : constant Entry_Call_State := Entry_Call.State; ! Acceptor : constant Task_ID := Entry_Call.Called_Task; ! Parent : constant Task_ID := Acceptor.Common.Parent; Parent_Locked : Boolean := False; ! Null_Body : Boolean; begin + -- Find out whether Entry_Call can be accepted immediately. + -- If the Acceptor is not callable, return False. + -- If the rendezvous can start, initiate it. + -- If the accept-body is trivial, also complete the rendezvous. + -- If the acceptor is not ready, enqueue the call. + + -- This should have a special case for Accept_Call and Accept_Trivial, + -- so that we don't have the loop setup overhead, below. + + -- The call state Done is used here and elsewhere to include both the + -- case of normal successful completion, and the case of an exception + -- being raised. The difference is that if an exception is raised no one + -- will pay attention to the fact that State = Done. Instead the + -- exception will be raised in Undefer_Abort, and control will skip past + -- the place where we normally would resume from an entry call. + pragma Assert (not Queuing.Onqueue (Entry_Call)); ! -- We rely that the call is off-queue for protection, that the caller ! -- will not exit the Entry_Caller_Sleep, and so will not reuse the call ! -- record for another call. -- We rely on the Caller's lock for call State mod's. -- We can't lock Acceptor.Parent while holding Acceptor, -- so lock it in advance if we expect to need to lock it. if Acceptor.Terminate_Alternative then STPO.Write_Lock (Parent); *************** package body System.Tasking.Rendezvous i *** 1246,1263 **** STPO.Write_Lock (Acceptor); ! -- If the acceptor is not callable, abort the call ! -- and raise Tasking_Error. The call is not aborted ! -- for an asynchronous call, since Cancel_Task_Entry_Call ! -- will do the cancelation in that case. ! -- ????? ..... ! -- Does the above still make sense? if not Acceptor.Callable then STPO.Unlock (Acceptor); if Parent_Locked then ! STPO.Unlock (Acceptor.Common.Parent); end if; pragma Assert (Entry_Call.State < Done); --- 1161,1173 ---- STPO.Write_Lock (Acceptor); ! -- If the acceptor is not callable, abort the call and return False. if not Acceptor.Callable then STPO.Unlock (Acceptor); if Parent_Locked then ! STPO.Unlock (Parent); end if; pragma Assert (Entry_Call.State < Done); *************** package body System.Tasking.Rendezvous i *** 1269,1274 **** --- 1179,1185 ---- Entry_Call.Exception_To_Raise := Tasking_Error'Identity; Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done); STPO.Unlock (Entry_Call.Self); + return False; end if; *************** package body System.Tasking.Rendezvous i *** 1291,1297 **** end if; if Acceptor.Terminate_Alternative then - -- Cancel terminate alternative. -- See matching code in Selective_Wait and -- Vulnerable_Complete_Master. --- 1202,1207 ---- *************** package body System.Tasking.Rendezvous i *** 1307,1314 **** Parent.Awake_Count := Parent.Awake_Count + 1; ! if Parent.Common.State = Master_Completion_Sleep and then ! Acceptor.Master_of_Task = Parent.Master_Within then Parent.Common.Wait_Count := Parent.Common.Wait_Count + 1; --- 1217,1224 ---- Parent.Awake_Count := Parent.Awake_Count + 1; ! if Parent.Common.State = Master_Completion_Sleep ! and then Acceptor.Master_of_Task = Parent.Master_Within then Parent.Common.Wait_Count := Parent.Common.Wait_Count + 1; *************** package body System.Tasking.Rendezvous i *** 1317,1323 **** end if; if Null_Body then - -- Rendezvous is over immediately. STPO.Wakeup (Acceptor, Acceptor_Sleep); --- 1227,1232 ---- *************** package body System.Tasking.Rendezvous i *** 1379,1391 **** STPO.Unlock (Parent); end if; ! if Old_State /= Entry_Call.State and then ! Entry_Call.State = Now_Abortable and then ! Entry_Call.Mode > Simple_Call and then ! ! -- Asynchronous_Call or Conditional_Call ! Entry_Call.Self /= Self_ID then -- Because of ATCB lock ordering rule --- 1288,1299 ---- STPO.Unlock (Parent); end if; ! if Old_State /= Entry_Call.State ! and then Entry_Call.State = Now_Abortable ! and then Entry_Call.Mode > Simple_Call ! and then Entry_Call.Self /= Self_ID ! -- Asynchronous_Call or Conditional_Call then -- Because of ATCB lock ordering rule *************** package body System.Tasking.Rendezvous i *** 1437,1442 **** --- 1345,1354 ---- Entry_Call : Entry_Call_Link; begin + if Parameters.Runtime_Traces then + Send_Trace_Info (W_Call, Acceptor, Entry_Index (E)); + end if; + if Mode = Simple_Call or else Mode = Conditional_Call then Call_Synchronous (Acceptor, E, Uninterpreted_Data, Mode, Rendezvous_Successful); *************** package body System.Tasking.Rendezvous i *** 1466,1471 **** --- 1378,1387 ---- Entry_Call.Called_PO := Null_Address; Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id; + if Single_Lock then + Lock_RTS; + end if; + if not Task_Do_Or_Queue (Self_Id, Entry_Call, With_Abort => True) then *************** package body System.Tasking.Rendezvous i *** 1473,1479 **** --- 1389,1405 ---- pragma Debug (Debug.Trace (Self_Id, "TEC: exited to ATC level: " & ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A')); + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort (Self_Id); + + if Parameters.Runtime_Traces then + Send_Trace_Info (E_Missed, Acceptor); + end if; + raise Tasking_Error; end if; *************** package body System.Tasking.Rendezvous i *** 1488,1493 **** --- 1414,1423 ---- Entry_Calls.Wait_Until_Abortable (Self_Id, Entry_Call); end if; + if Single_Lock then + Unlock_RTS; + end if; + -- Note: following assignment needs to be atomic. Rendezvous_Successful := Entry_Call.State = Done; *************** package body System.Tasking.Rendezvous i *** 1498,1511 **** -- Task_Entry_Caller -- ----------------------- - -- Compiler interface only. - function Task_Entry_Caller (D : Task_Entry_Nesting_Depth) return Task_ID is Self_Id : constant Task_ID := STPO.Self; Entry_Call : Entry_Call_Link; begin Entry_Call := Self_Id.Common.Call; for Depth in 1 .. D loop Entry_Call := Entry_Call.Acceptor_Prev_Call; pragma Assert (Entry_Call /= null); --- 1428,1440 ---- -- Task_Entry_Caller -- ----------------------- function Task_Entry_Caller (D : Task_Entry_Nesting_Depth) return Task_ID is Self_Id : constant Task_ID := STPO.Self; Entry_Call : Entry_Call_Link; begin Entry_Call := Self_Id.Common.Call; + for Depth in 1 .. D loop Entry_Call := Entry_Call.Acceptor_Prev_Call; pragma Assert (Entry_Call /= null); *************** package body System.Tasking.Rendezvous i *** 1518,1525 **** -- Timed_Selective_Wait -- -------------------------- - -- Compiler interface only. Do not call from within the RTS. - procedure Timed_Selective_Wait (Open_Accepts : Accept_List_Access; Select_Mode : Select_Modes; --- 1447,1452 ---- *************** package body System.Tasking.Rendezvous i *** 1535,1541 **** Selection : Select_Index; Open_Alternative : Boolean; Timedout : Boolean := False; ! Yielded : Boolean := False; begin pragma Assert (Select_Mode = Delay_Mode); --- 1462,1469 ---- Selection : Select_Index; Open_Alternative : Boolean; Timedout : Boolean := False; ! Yielded : Boolean := True; ! begin pragma Assert (Select_Mode = Delay_Mode); *************** package body System.Tasking.Rendezvous i *** 1543,1548 **** --- 1471,1480 ---- -- If we are aborted here, the effect will be pending + if Single_Lock then + Lock_RTS; + end if; + STPO.Write_Lock (Self_Id); if not Self_Id.Callable then *************** package body System.Tasking.Rendezvous i *** 1551,1556 **** --- 1483,1493 ---- pragma Assert (Self_Id.Pending_Action); STPO.Unlock (Self_Id); + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort (Self_Id); -- Should never get here ??? *************** package body System.Tasking.Rendezvous i *** 1559,1570 **** raise Standard'Abort_Signal; end if; ! -- If someone completed this task, this task should not try to ! -- access its pending entry calls or queues in this case, as they ! -- are being emptied. Wait for abortion to kill us. ! -- ????? ! -- Recheck the correctness of the above, now that we have made ! -- changes. pragma Assert (Open_Accepts /= null); --- 1496,1502 ---- raise Standard'Abort_Signal; end if; ! Uninterpreted_Data := Null_Address; pragma Assert (Open_Accepts /= null); *************** package body System.Tasking.Rendezvous i *** 1596,1710 **** -- Handle the select according to the disposition selected above. case Treatment is ! when Accept_Alternative_Selected => ! ! -- Ready to rendezvous ! -- In this case the accept body is not Null_Body. Defer abortion ! -- until it gets into the accept body. ! ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! Initialization.Defer_Abort (Self_Id); ! STPO.Unlock (Self_Id); ! ! when Accept_Alternative_Completed => ! -- Rendezvous is over ! STPO.Unlock (Self_Id); ! Caller := Entry_Call.Self; ! STPO.Write_Lock (Caller); ! Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); ! STPO.Unlock (Caller); ! when Accept_Alternative_Open => ! -- Wait for caller. ! Self_Id.Open_Accepts := Open_Accepts; ! -- Wait for a normal call and a pending action until the ! -- Wakeup_Time is reached. ! Self_Id.Common.State := Acceptor_Sleep; ! loop ! Initialization.Poll_Base_Priority_Change (Self_Id); ! exit when Self_Id.Open_Accepts = null; ! if Timedout then ! Sleep (Self_Id, Acceptor_Sleep); ! else ! STPO.Timed_Sleep (Self_Id, Timeout, Mode, ! Acceptor_Sleep, Timedout, Yielded); ! end if; ! if Timedout then ! Self_Id.Open_Accepts := null; ! end if; ! end loop; ! Self_Id.Common.State := Runnable; ! -- Self_Id.Common.Call should already be updated by the Caller if ! -- not aborted. It might also be ready to do rendezvous even if ! -- this wakes up due to an abortion. ! -- Therefore, if the call is not empty we need to do the rendezvous ! -- if the accept body is not Null_Body. ! if Self_Id.Chosen_Index /= No_Rendezvous and then ! Self_Id.Common.Call /= null and then ! not Open_Accepts (Self_Id.Chosen_Index).Null_Body ! then ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! pragma Assert (Self_Id.Deferral_Level = 1); ! Initialization.Defer_Abort_Nestable (Self_Id); ! -- Leave abort deferred until the accept body ! end if; ! STPO.Unlock (Self_Id); ! if not Yielded then ! Yield; ! end if; ! when No_Alternative_Open => ! -- In this case, Index will be No_Rendezvous on return. We sleep ! -- for the time we need to. ! -- Wait for a signal or timeout. A wakeup can be made ! -- for several reasons: ! -- 1) Delay is expired ! -- 2) Pending_Action needs to be checked ! -- (Abortion, Priority change) ! -- 3) Spurious wakeup ! Self_Id.Open_Accepts := null; ! Self_Id.Common.State := Acceptor_Sleep; ! Initialization.Poll_Base_Priority_Change (Self_Id); ! STPO.Timed_Sleep (Self_Id, Timeout, Mode, Acceptor_Sleep, ! Timedout, Yielded); ! Self_Id.Common.State := Runnable; ! STPO.Unlock (Self_Id); ! if not Yielded then ! Yield; ! end if; ! when others => ! -- Should never get here ??? ! pragma Assert (False); ! null; ! end case; -- Caller has been chosen --- 1528,1651 ---- -- Handle the select according to the disposition selected above. case Treatment is + when Accept_Alternative_Selected => + -- Ready to rendezvous + -- In this case the accept body is not Null_Body. Defer abort + -- until it gets into the accept body. ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! Initialization.Defer_Abort (Self_Id); ! STPO.Unlock (Self_Id); ! when Accept_Alternative_Completed => ! -- Rendezvous is over ! if Parameters.Runtime_Traces then ! Send_Trace_Info (M_RDV_Complete, Entry_Call.Self); ! end if; ! STPO.Unlock (Self_Id); ! Caller := Entry_Call.Self; ! STPO.Write_Lock (Caller); ! Initialization.Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); ! STPO.Unlock (Caller); ! when Accept_Alternative_Open => ! -- Wait for caller. ! Self_Id.Open_Accepts := Open_Accepts; ! -- Wait for a normal call and a pending action until the ! -- Wakeup_Time is reached. ! Self_Id.Common.State := Acceptor_Sleep; ! loop ! Initialization.Poll_Base_Priority_Change (Self_Id); ! exit when Self_Id.Open_Accepts = null; ! if Timedout then ! Sleep (Self_Id, Acceptor_Sleep); ! else ! if Parameters.Runtime_Traces then ! Send_Trace_Info (WT_Select, ! Self_Id, ! Integer (Open_Accepts'Length), ! Timeout); ! end if; ! STPO.Timed_Sleep (Self_Id, Timeout, Mode, ! Acceptor_Sleep, Timedout, Yielded); ! end if; ! if Timedout then ! Self_Id.Open_Accepts := null; ! if Parameters.Runtime_Traces then ! Send_Trace_Info (E_Timeout); ! end if; ! end if; ! end loop; ! Self_Id.Common.State := Runnable; ! -- Self_Id.Common.Call should already be updated by the Caller if ! -- not aborted. It might also be ready to do rendezvous even if ! -- this wakes up due to an abortion. ! -- Therefore, if the call is not empty we need to do the ! -- rendezvous if the accept body is not Null_Body. ! if Self_Id.Chosen_Index /= No_Rendezvous ! and then Self_Id.Common.Call /= null ! and then not Open_Accepts (Self_Id.Chosen_Index).Null_Body ! then ! Uninterpreted_Data := Self_Id.Common.Call.Uninterpreted_Data; ! pragma Assert (Self_Id.Deferral_Level = 1); ! Initialization.Defer_Abort_Nestable (Self_Id); ! -- Leave abort deferred until the accept body ! end if; ! STPO.Unlock (Self_Id); ! when No_Alternative_Open => ! -- In this case, Index will be No_Rendezvous on return. We sleep ! -- for the time we need to. ! -- Wait for a signal or timeout. A wakeup can be made ! -- for several reasons: ! -- 1) Delay is expired ! -- 2) Pending_Action needs to be checked ! -- (Abortion, Priority change) ! -- 3) Spurious wakeup ! Self_Id.Open_Accepts := null; ! Self_Id.Common.State := Acceptor_Sleep; ! Initialization.Poll_Base_Priority_Change (Self_Id); ! STPO.Timed_Sleep (Self_Id, Timeout, Mode, Acceptor_Sleep, ! Timedout, Yielded); ! Self_Id.Common.State := Runnable; ! STPO.Unlock (Self_Id); ! when others => ! -- Should never get here ! pragma Assert (False); ! null; ! end case; ! if Single_Lock then ! Unlock_RTS; ! end if; ! if not Yielded then ! Yield; ! end if; -- Caller has been chosen *************** package body System.Tasking.Rendezvous i *** 1717,1731 **** Initialization.Undefer_Abort_Nestable (Self_Id); -- Start rendezvous, if not already completed - end Timed_Selective_Wait; --------------------------- -- Timed_Task_Entry_Call -- --------------------------- - -- Compiler interface only. Do not call from within the RTS. - procedure Timed_Task_Entry_Call (Acceptor : Task_ID; E : Task_Entry_Index; --- 1658,1669 ---- *************** package body System.Tasking.Rendezvous i *** 1737,1742 **** --- 1675,1681 ---- Self_Id : constant Task_ID := STPO.Self; Level : ATC_Level; Entry_Call : Entry_Call_Link; + Yielded : Boolean; begin Initialization.Defer_Abort (Self_Id); *************** package body System.Tasking.Rendezvous i *** 1746,1751 **** --- 1685,1695 ---- (Debug.Trace (Self_Id, "TTEC: entered ATC level: " & ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A')); + if Parameters.Runtime_Traces then + Send_Trace_Info (WT_Call, Acceptor, + Entry_Index (E), Timeout); + end if; + Level := Self_Id.ATC_Nesting_Level; Entry_Call := Self_Id.Entry_Calls (Level)'Access; Entry_Call.Next := null; *************** package body System.Tasking.Rendezvous i *** 1770,1775 **** --- 1714,1723 ---- -- Note: the caller will undefer abortion on return (see WARNING above) + if Single_Lock then + Lock_RTS; + end if; + if not Task_Do_Or_Queue (Self_Id, Entry_Call, With_Abort => True) then *************** package body System.Tasking.Rendezvous i *** 1779,1790 **** (Debug.Trace (Self_Id, "TTEC: exited to ATC level: " & ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A')); Initialization.Undefer_Abort (Self_Id); raise Tasking_Error; end if; Entry_Calls.Wait_For_Completion_With_Timeout ! (Self_Id, Entry_Call, Timeout, Mode); Rendezvous_Successful := Entry_Call.State = Done; Initialization.Undefer_Abort (Self_Id); Entry_Calls.Check_Exception (Self_Id, Entry_Call); --- 1727,1755 ---- (Debug.Trace (Self_Id, "TTEC: exited to ATC level: " & ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A')); + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort (Self_Id); + + if Parameters.Runtime_Traces then + Send_Trace_Info (E_Missed, Acceptor); + end if; raise Tasking_Error; end if; + Write_Lock (Self_Id); Entry_Calls.Wait_For_Completion_With_Timeout ! (Entry_Call, Timeout, Mode, Yielded); ! Unlock (Self_Id); ! ! if Single_Lock then ! Unlock_RTS; ! end if; ! ! -- ??? Do we need to yield in case Yielded is False ! Rendezvous_Successful := Entry_Call.State = Done; Initialization.Undefer_Abort (Self_Id); Entry_Calls.Check_Exception (Self_Id, Entry_Call); diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasren.ads gcc-3.3/gcc/ada/s-tasren.ads *** gcc-3.2.3/gcc/ada/s-tasren.ads 2002-05-07 08:22:28.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasren.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** with System.Tasking.Protected_Objects.En *** 43,50 **** -- used for Protection_Entries package System.Tasking.Rendezvous is - -- This interface is described in the document - -- Gnu Ada Runtime Library Interface (GNARLI). package STPE renames System.Tasking.Protected_Objects.Entries; --- 42,47 ---- *************** package System.Tasking.Rendezvous is *** 54,60 **** Uninterpreted_Data : System.Address; Mode : Call_Modes; Rendezvous_Successful : out Boolean); ! -- General entry call procedure Timed_Task_Entry_Call (Acceptor : Task_ID; --- 51,65 ---- Uninterpreted_Data : System.Address; Mode : Call_Modes; Rendezvous_Successful : out Boolean); ! -- General entry call used to implement ATC or conditional entry calls. ! -- Compiler interface only. Do not call from within the RTS. ! -- Acceptor is the ID of the acceptor task. ! -- E is the entry index requested. ! -- Uninterpreted_Data represents the parameters of the entry. It is ! -- constructed by the compiler for the caller and the callee; therefore, ! -- the run time never needs to decode this data. ! -- Mode can be either Asynchronous_Call (ATC) or Conditional_Call. ! -- Rendezvous_Successful is set to True on return if the call was serviced. procedure Timed_Task_Entry_Call (Acceptor : Task_ID; *************** package System.Tasking.Rendezvous is *** 64,96 **** Mode : Delay_Modes; Rendezvous_Successful : out Boolean); -- Timed entry call without using ATC. procedure Call_Simple (Acceptor : Task_ID; E : Task_Entry_Index; Uninterpreted_Data : System.Address); ! -- Simple entry call procedure Cancel_Task_Entry_Call (Cancelled : out Boolean); ! -- Cancel pending task entry call procedure Requeue_Task_Entry (Acceptor : Task_ID; E : Task_Entry_Index; With_Abort : Boolean); procedure Requeue_Protected_To_Task_Entry (Object : STPE.Protection_Entries_Access; Acceptor : Task_ID; E : Task_Entry_Index; With_Abort : Boolean); procedure Selective_Wait (Open_Accepts : Accept_List_Access; Select_Mode : Select_Modes; Uninterpreted_Data : out System.Address; Index : out Select_Index); ! -- Selective wait procedure Timed_Selective_Wait (Open_Accepts : Accept_List_Access; --- 69,242 ---- Mode : Delay_Modes; Rendezvous_Successful : out Boolean); -- Timed entry call without using ATC. + -- Compiler interface only. Do not call from within the RTS. + -- See Task_Entry_Call for details on Acceptor, E and Uninterpreted_Data. + -- Timeout is the value of the time out. + -- Mode determines whether the delay is relative or absolute. procedure Call_Simple (Acceptor : Task_ID; E : Task_Entry_Index; Uninterpreted_Data : System.Address); ! -- Simple entry call. ! -- Compiler interface only. Do not call from within the RTS. ! -- ! -- source: ! -- T.E1 (Params); ! -- ! -- expansion: ! -- declare ! -- P : parms := (parm1, parm2, parm3); ! -- X : Task_Entry_Index := 1; ! -- begin ! -- Call_Simple (t._task_id, X, P'Address); ! -- parm1 := P.param1; ! -- parm2 := P.param2; ! -- ... ! -- end; procedure Cancel_Task_Entry_Call (Cancelled : out Boolean); ! -- Cancel pending asynchronous task entry call. ! -- Compiler interface only. Do not call from within the RTS. ! -- See Exp_Ch9.Expand_N_Asynchronous_Select for code expansion. procedure Requeue_Task_Entry (Acceptor : Task_ID; E : Task_Entry_Index; With_Abort : Boolean); + -- Requeue from a task entry to a task entry. + -- Compiler interface only. Do not call from within the RTS. + -- The code generation for task entry requeues is different from that for + -- protected entry requeues. There is a "goto" that skips around the call + -- to Complete_Rendezvous, so that Requeue_Task_Entry must also do the work + -- of Complete_Rendezvous. The difference is that it does not report that + -- the call's State = Done. + -- + -- source: + -- accept e1 do + -- ...A... + -- requeue e2; + -- ...B... + -- end e1; + -- + -- expansion: + -- A62b : address; + -- L61b : label + -- begin + -- accept_call (1, A62b); + -- ...A... + -- requeue_task_entry (tTV!(t)._task_id, 2, false); + -- goto L61b; + -- ...B... + -- complete_rendezvous; + -- <> + -- exception + -- when others => + -- exceptional_complete_rendezvous (current_exception); + -- end; procedure Requeue_Protected_To_Task_Entry (Object : STPE.Protection_Entries_Access; Acceptor : Task_ID; E : Task_Entry_Index; With_Abort : Boolean); + -- Requeue from a protected entry to a task entry. + -- Compiler interface only. Do not call from within the RTS. + -- + -- source: + -- entry e2 when b is + -- begin + -- b := false; + -- ...A... + -- requeue t.e2; + -- end e2; + -- + -- expansion: + -- procedure rPT__E14b (O : address; P : address; E : + -- protected_entry_index) is + -- type rTVP is access rTV; + -- freeze rTVP [] + -- _object : rTVP := rTVP!(O); + -- begin + -- declare + -- rR : protection renames _object._object; + -- vP : integer renames _object.v; + -- bP : boolean renames _object.b; + -- begin + -- b := false; + -- ...A... + -- requeue_protected_to_task_entry (rR'unchecked_access, tTV!(t). + -- _task_id, 2, false); + -- return; + -- end; + -- complete_entry_body (_object._object'unchecked_access, objectF => + -- 0); + -- return; + -- exception + -- when others => + -- abort_undefer.all; + -- exceptional_complete_entry_body (_object._object' + -- unchecked_access, current_exception, objectF => 0); + -- return; + -- end rPT__E14b; procedure Selective_Wait (Open_Accepts : Accept_List_Access; Select_Mode : Select_Modes; Uninterpreted_Data : out System.Address; Index : out Select_Index); ! -- Implement select statement. ! -- Compiler interface only. Do not call from within the RTS. ! -- See comments on Accept_Call. ! -- ! -- source: ! -- select accept e1 do ! -- ...A... ! -- end e1; ! -- ...B... ! -- or accept e2; ! -- ...C... ! -- end select; ! -- ! -- expansion: ! -- A32b : address; ! -- declare ! -- A37b : T36b; ! -- A37b (1) := (null_body => false, s => 1); ! -- A37b (2) := (null_body => true, s => 2); ! -- S0 : aliased T36b := accept_list'A37b; ! -- J1 : select_index := 0; ! -- procedure e1A is ! -- begin ! -- abort_undefer.all; ! -- ...A... ! -- <> ! -- complete_rendezvous; ! -- exception ! -- when all others => ! -- exceptional_complete_rendezvous (get_gnat_exception); ! -- end e1A; ! -- begin ! -- selective_wait (S0'unchecked_access, simple_mode, A32b, J1); ! -- case J1 is ! -- when 0 => ! -- goto L3; ! -- when 1 => ! -- e1A; ! -- goto L1; ! -- when 2 => ! -- goto L2; ! -- when others => ! -- goto L3; ! -- end case; ! -- <> ! -- ...B... ! -- goto L3; ! -- <> ! -- ...C... ! -- goto L3; ! -- <> ! -- end; procedure Timed_Selective_Wait (Open_Accepts : Accept_List_Access; *************** package System.Tasking.Rendezvous is *** 100,127 **** Mode : Delay_Modes; Index : out Select_Index); -- Selective wait with timeout without using ATC. procedure Accept_Call (E : Task_Entry_Index; Uninterpreted_Data : out System.Address); ! -- Accept an entry call procedure Accept_Trivial (E : Task_Entry_Index); ! -- Accept an entry call that has no parameters and no body function Task_Count (E : Task_Entry_Index) return Natural; -- Return number of tasks waiting on the entry E (of current task) function Callable (T : Task_ID) return Boolean; ! -- Return T'CALLABLE type Task_Entry_Nesting_Depth is new Task_Entry_Index range 0 .. Max_Task_Entry; function Task_Entry_Caller (D : Task_Entry_Nesting_Depth) return Task_ID; ! -- Return E'Caller. This will only work if called from within an ! -- accept statement that is handling E, as required by the ! -- LRM (C.7.1(14)). procedure Complete_Rendezvous; -- Called by acceptor to wake up caller --- 246,312 ---- Mode : Delay_Modes; Index : out Select_Index); -- Selective wait with timeout without using ATC. + -- Compiler interface only. Do not call from within the RTS. procedure Accept_Call (E : Task_Entry_Index; Uninterpreted_Data : out System.Address); ! -- Accept an entry call. ! -- Compiler interface only. Do not call from within the RTS. ! -- ! -- source: ! -- accept E do ...A... end E; ! -- expansion: ! -- A27b : address; ! -- L26b : label ! -- begin ! -- accept_call (1, A27b); ! -- ...A... ! -- complete_rendezvous; ! -- <> ! -- exception ! -- when all others => ! -- exceptional_complete_rendezvous (get_gnat_exception); ! -- end; ! -- ! -- The handler for Abort_Signal (*all* others) is to handle the case when ! -- the acceptor is aborted between Accept_Call and the corresponding ! -- Complete_Rendezvous call. We need to wake up the caller in this case. ! -- ! -- See also Selective_Wait procedure Accept_Trivial (E : Task_Entry_Index); ! -- Accept an entry call that has no parameters and no body. ! -- Compiler interface only. Do not call from within the RTS. ! -- This should only be called when there is no accept body, or the accept ! -- body is empty. ! -- ! -- source: ! -- accept E; ! -- expansion: ! -- accept_trivial (1); ! -- ! -- The compiler is also able to recognize the following and ! -- translate it the same way. ! -- ! -- accept E do null; end E; function Task_Count (E : Task_Entry_Index) return Natural; -- Return number of tasks waiting on the entry E (of current task) + -- Compiler interface only. Do not call from within the RTS. function Callable (T : Task_ID) return Boolean; ! -- Return T'Callable ! -- Compiler interface. Do not call from within the RTS, except for body of ! -- Ada.Task_Identification. type Task_Entry_Nesting_Depth is new Task_Entry_Index range 0 .. Max_Task_Entry; function Task_Entry_Caller (D : Task_Entry_Nesting_Depth) return Task_ID; ! -- Return E'Caller. This will only work if called from within an ! -- accept statement that is handling E, as required by the LRM (C.7.1(14)). ! -- Compiler interface only. Do not call from within the RTS. procedure Complete_Rendezvous; -- Called by acceptor to wake up caller *************** package System.Tasking.Rendezvous is *** 137,149 **** (Self_ID : Task_ID; Entry_Call : Entry_Call_Link; With_Abort : Boolean) return Boolean; ! -- Call this only with abort deferred and holding lock of Acceptor. -- Returns False iff the call cannot be served or queued, as is the -- case if the caller is not callable; i.e., a False return value -- indicates that Tasking_Error should be raised. -- Either initiate the entry call, such that the accepting task is -- free to execute the rendezvous, queue the call on the acceptor's ! -- queue, or cancel the call. Conditional calls that cannot be -- accepted immediately are cancelled. end System.Tasking.Rendezvous; --- 322,335 ---- (Self_ID : Task_ID; Entry_Call : Entry_Call_Link; With_Abort : Boolean) return Boolean; ! -- Call this only with abort deferred and holding no locks, except ! -- the global RTS lock when Single_Lock is True which must be owned. -- Returns False iff the call cannot be served or queued, as is the -- case if the caller is not callable; i.e., a False return value -- indicates that Tasking_Error should be raised. -- Either initiate the entry call, such that the accepting task is -- free to execute the rendezvous, queue the call on the acceptor's ! -- queue, or cancel the call. Conditional calls that cannot be -- accepted immediately are cancelled. end System.Tasking.Rendezvous; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasres.ads gcc-3.3/gcc/ada/s-tasres.ads *** gcc-3.2.3/gcc/ada/s-tasres.ads 2002-05-04 03:28:49.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasres.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-1999, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tassta.adb gcc-3.3/gcc/ada/s-tassta.adb *** gcc-3.2.3/gcc/ada/s-tassta.adb 2001-12-16 01:13:46.000000000 +0000 --- gcc-3.3/gcc/ada/s-tassta.adb 2002-03-14 11:00:00.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** with System.Address_Image; *** 50,55 **** --- 48,55 ---- with System.Parameters; -- used for Size_Type + -- Single_Lock + -- Runtime_Traces with System.Task_Info; -- used for Task_Info_Type *************** with System.Task_Primitives.Operations; *** 63,69 **** -- Sleep -- Wakeup -- Get_Priority ! -- Lock/Unlock_All_Tasks_List -- New_ATCB with System.Soft_Links; --- 63,69 ---- -- Sleep -- Wakeup -- Get_Priority ! -- Lock/Unlock_RTS -- New_ATCB with System.Soft_Links; *************** with System.Storage_Elements; *** 112,117 **** --- 112,120 ---- with System.Standard_Library; -- used for Exception_Trace + with System.Traces.Tasking; + -- used for Send_Trace_Info + package body System.Tasking.Stages is package STPO renames System.Task_Primitives.Operations; *************** package body System.Tasking.Stages is *** 121,143 **** use Ada.Exceptions; ! use System.Task_Primitives; ! use System.Task_Primitives.Operations; ! use System.Task_Info; ! ! procedure Wakeup_Entry_Caller ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link; ! New_State : Entry_Call_State) ! renames Initialization.Wakeup_Entry_Caller; ! ! procedure Cancel_Queued_Entry_Calls (T : Task_ID) ! renames Utilities.Cancel_Queued_Entry_Calls; ! procedure Abort_One_Task ! (Self_ID : Task_ID; ! T : Task_ID) ! renames Utilities.Abort_One_Task; ----------------------- -- Local Subprograms -- --- 124,136 ---- use Ada.Exceptions; ! use Parameters; ! use Task_Primitives; ! use Task_Primitives.Operations; ! use Task_Info; ! use System.Traces; ! use System.Traces.Tasking; ----------------------- -- Local Subprograms -- *************** package body System.Tasking.Stages is *** 171,181 **** -- Signal to Self_ID's activator that Self_ID has -- completed activation. -- ! -- Does not defer abortion (unlike Complete_Activation). procedure Abort_Dependents (Self_ID : Task_ID); ! -- Abort all the dependents of Self at our current master ! -- nesting level. procedure Vulnerable_Free_Task (T : Task_ID); -- Recover all runtime system storage associated with the task T. --- 164,175 ---- -- Signal to Self_ID's activator that Self_ID has -- completed activation. -- ! -- Call this procedure with abort deferred. procedure Abort_Dependents (Self_ID : Task_ID); ! -- Abort all the direct dependents of Self at its current master ! -- nesting level, plus all of their dependents, transitively. ! -- RTS_Lock should be locked by the caller. procedure Vulnerable_Free_Task (T : Task_ID); -- Recover all runtime system storage associated with the task T. *************** package body System.Tasking.Stages is *** 199,227 **** -- Abort_Dependents -- ---------------------- - -- Abort all the direct dependents of Self at its current master - -- nesting level, plus all of their dependents, transitively. - -- No locks should be held when this routine is called. - procedure Abort_Dependents (Self_ID : Task_ID) is C : Task_ID; P : Task_ID; begin - Lock_All_Tasks_List; - C := All_Tasks_List; while C /= null loop P := C.Common.Parent; while P /= null loop if P = Self_ID then - -- ??? C is supposed to take care of its own dependents, so ! -- there should be no need to take worry about them. Need to ! -- double check this. if C.Master_of_Task = Self_ID.Master_Within then ! Abort_One_Task (Self_ID, C); C.Dependents_Aborted := True; end if; --- 193,216 ---- -- Abort_Dependents -- ---------------------- procedure Abort_Dependents (Self_ID : Task_ID) is C : Task_ID; P : Task_ID; begin C := All_Tasks_List; + while C /= null loop P := C.Common.Parent; + while P /= null loop if P = Self_ID then -- ??? C is supposed to take care of its own dependents, so ! -- there should be no need to worry about them. Need to double ! -- check this. if C.Master_of_Task = Self_ID.Master_Within then ! Utilities.Abort_One_Task (Self_ID, C); C.Dependents_Aborted := True; end if; *************** package body System.Tasking.Stages is *** 235,241 **** end loop; Self_ID.Dependents_Aborted := True; - Unlock_All_Tasks_List; end Abort_Dependents; ----------------- --- 224,229 ---- *************** package body System.Tasking.Stages is *** 258,264 **** -- task. That satisfies our in-order-of-creation ATCB locking policy. -- At one point, we may also lock the parent, if the parent is ! -- different from the activator. That is also consistent with the -- lock ordering policy, since the activator cannot be created -- before the parent. --- 246,252 ---- -- task. That satisfies our in-order-of-creation ATCB locking policy. -- At one point, we may also lock the parent, if the parent is ! -- different from the activator. That is also consistent with the -- lock ordering policy, since the activator cannot be created -- before the parent. *************** package body System.Tasking.Stages is *** 268,282 **** -- the counts until we see that the thread creation is successful. -- If the thread creation fails, we do need to close the entries ! -- of the task. The first phase, of dequeuing calls, only requires -- locking the acceptor's ATCB, but the waking up of the callers ! -- requires locking the caller's ATCB. We cannot safely do this ! -- while we are holding other locks. Therefore, the queue-clearing -- operation is done in a separate pass over the activation chain. ! procedure Activate_Tasks ! (Chain_Access : Activation_Chain_Access) ! is Self_ID : constant Task_ID := STPO.Self; P : Task_ID; C : Task_ID; --- 256,268 ---- -- the counts until we see that the thread creation is successful. -- If the thread creation fails, we do need to close the entries ! -- of the task. The first phase, of dequeuing calls, only requires -- locking the acceptor's ATCB, but the waking up of the callers ! -- requires locking the caller's ATCB. We cannot safely do this ! -- while we are holding other locks. Therefore, the queue-clearing -- operation is done in a separate pass over the activation chain. ! procedure Activate_Tasks (Chain_Access : Activation_Chain_Access) is Self_ID : constant Task_ID := STPO.Self; P : Task_ID; C : Task_ID; *************** package body System.Tasking.Stages is *** 293,313 **** pragma Assert (Self_ID.Common.Wait_Count = 0); ! -- Lock All_Tasks_L, to prevent activated tasks -- from racing ahead before we finish activating the chain. ! -- ????? ! -- Is there some less heavy-handed way? ! -- In an earlier version, we used the activator's lock here, ! -- but that violated the locking order rule when we had ! -- to lock the parent later. ! ! Lock_All_Tasks_List; -- Check that all task bodies have been elaborated. C := Chain_Access.T_ID; Last_C := null; while C /= null loop if C.Common.Elaborated /= null and then not C.Common.Elaborated.all --- 279,294 ---- pragma Assert (Self_ID.Common.Wait_Count = 0); ! -- Lock RTS_Lock, to prevent activated tasks -- from racing ahead before we finish activating the chain. ! Lock_RTS; -- Check that all task bodies have been elaborated. C := Chain_Access.T_ID; Last_C := null; + while C /= null loop if C.Common.Elaborated /= null and then not C.Common.Elaborated.all *************** package body System.Tasking.Stages is *** 327,333 **** Chain_Access.T_ID := Last_C; if not All_Elaborated then ! Unlock_All_Tasks_List; Initialization.Undefer_Abort_Nestable (Self_ID); Raise_Exception (Program_Error'Identity, "Some tasks have not been elaborated"); --- 308,314 ---- Chain_Access.T_ID := Last_C; if not All_Elaborated then ! Unlock_RTS; Initialization.Undefer_Abort_Nestable (Self_ID); Raise_Exception (Program_Error'Identity, "Some tasks have not been elaborated"); *************** package body System.Tasking.Stages is *** 338,343 **** --- 319,325 ---- -- activation. So create it now. C := Chain_Access.T_ID; + while C /= null loop if C.Common.State /= Terminated then pragma Assert (C.Common.State = Unactivated); *************** package body System.Tasking.Stages is *** 360,366 **** -- There would be a race between the created task and -- the creator to do the following initialization, ! -- if we did not have a Lock/Unlock_All_Tasks_List pair -- in the task wrapper, to prevent it from racing ahead. if Success then --- 342,348 ---- -- There would be a race between the created task and -- the creator to do the following initialization, ! -- if we did not have a Lock/Unlock_RTS pair -- in the task wrapper, to prevent it from racing ahead. if Success then *************** package body System.Tasking.Stages is *** 393,399 **** C := C.Common.Activation_Link; end loop; ! Unlock_All_Tasks_List; -- Close the entries of any tasks that failed thread creation, -- and count those that have not finished activation. --- 375,383 ---- C := C.Common.Activation_Link; end loop; ! if not Single_Lock then ! Unlock_RTS; ! end if; -- Close the entries of any tasks that failed thread creation, -- and count those that have not finished activation. *************** package body System.Tasking.Stages is *** 409,415 **** C.Common.Activator := null; C.Common.State := Terminated; C.Callable := False; ! Cancel_Queued_Entry_Calls (C); elsif C.Common.Activator /= null then Self_ID.Common.Wait_Count := Self_ID.Common.Wait_Count + 1; --- 393,399 ---- C.Common.Activator := null; C.Common.State := Terminated; C.Callable := False; ! Utilities.Cancel_Queued_Entry_Calls (C); elsif C.Common.Activator /= null then Self_ID.Common.Wait_Count := Self_ID.Common.Wait_Count + 1; *************** package body System.Tasking.Stages is *** 434,439 **** --- 418,427 ---- Self_ID.Common.State := Runnable; Unlock (Self_ID); + if Single_Lock then + Unlock_RTS; + end if; + -- Remove the tasks from the chain. Chain_Access.T_ID := null; *************** package body System.Tasking.Stages is *** 452,466 **** procedure Complete_Activation is Self_ID : constant Task_ID := STPO.Self; - begin Initialization.Defer_Abort_Nestable (Self_ID); Vulnerable_Complete_Activation (Self_ID); Initialization.Undefer_Abort_Nestable (Self_ID); ! -- ????? -- Why do we need to allow for nested deferral here? end Complete_Activation; --------------------- --- 440,466 ---- procedure Complete_Activation is Self_ID : constant Task_ID := STPO.Self; begin Initialization.Defer_Abort_Nestable (Self_ID); + + if Single_Lock then + Lock_RTS; + end if; + Vulnerable_Complete_Activation (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort_Nestable (Self_ID); ! -- ??? -- Why do we need to allow for nested deferral here? + if Runtime_Traces then + Send_Trace_Info (T_Activate); + end if; end Complete_Activation; --------------------- *************** package body System.Tasking.Stages is *** 484,490 **** procedure Complete_Task is Self_ID : constant Task_ID := STPO.Self; - begin pragma Assert (Self_ID.Deferral_Level > 0); --- 484,489 ---- *************** package body System.Tasking.Stages is *** 492,498 **** -- All of our dependents have terminated. -- Never undefer abort again! - end Complete_Task; ----------------- --- 491,496 ---- *************** package body System.Tasking.Stages is *** 552,562 **** Raise_Exception (Storage_Error'Identity, "Cannot allocate task"); end; ! -- All_Tasks_L is used by Abort_Dependents and Abort_Tasks. -- Up to this point, it is possible that we may be part of -- a family of tasks that is being aborted. ! Lock_All_Tasks_List; Write_Lock (Self_ID); -- Now, we must check that we have not been aborted. --- 550,560 ---- Raise_Exception (Storage_Error'Identity, "Cannot allocate task"); end; ! -- RTS_Lock is used by Abort_Dependents and Abort_Tasks. -- Up to this point, it is possible that we may be part of -- a family of tasks that is being aborted. ! Lock_RTS; Write_Lock (Self_ID); -- Now, we must check that we have not been aborted. *************** package body System.Tasking.Stages is *** 570,576 **** or else Chain.T_ID.Common.State = Unactivated); Unlock (Self_ID); ! Unlock_All_Tasks_List; Initialization.Undefer_Abort_Nestable (Self_ID); -- ??? Should never get here --- 568,574 ---- or else Chain.T_ID.Common.State = Unactivated); Unlock (Self_ID); ! Unlock_RTS; Initialization.Undefer_Abort_Nestable (Self_ID); -- ??? Should never get here *************** package body System.Tasking.Stages is *** 584,590 **** if not Success then Unlock (Self_ID); ! Unlock_All_Tasks_List; Initialization.Undefer_Abort_Nestable (Self_ID); Raise_Exception (Storage_Error'Identity, "Failed to initialize task"); --- 582,588 ---- if not Success then Unlock (Self_ID); ! Unlock_RTS; Initialization.Undefer_Abort_Nestable (Self_ID); Raise_Exception (Storage_Error'Identity, "Failed to initialize task"); *************** package body System.Tasking.Stages is *** 600,606 **** T.Common.Task_Image := Task_Image; Unlock (Self_ID); ! Unlock_All_Tasks_List; -- Create TSD as early as possible in the creation of a task, since it -- may be used by the operation of Ada code within the task. --- 598,604 ---- T.Common.Task_Image := Task_Image; Unlock (Self_ID); ! Unlock_RTS; -- Create TSD as early as possible in the creation of a task, since it -- may be used by the operation of Ada code within the task. *************** package body System.Tasking.Stages is *** 611,616 **** --- 609,618 ---- Initialization.Initialize_Attributes_Link.all (T); Created_Task := T; Initialization.Undefer_Abort_Nestable (Self_ID); + + if Runtime_Traces then + Send_Trace_Info (T_Create, T); + end if; end Create_Task; -------------------- *************** package body System.Tasking.Stages is *** 618,627 **** -------------------- function Current_Master return Master_Level is - Self_ID : constant Task_ID := STPO.Self; - begin ! return Self_ID.Master_Within; end Current_Master; ------------------ --- 620,627 ---- -------------------- function Current_Master return Master_Level is begin ! return STPO.Self.Master_Within; end Current_Master; ------------------ *************** package body System.Tasking.Stages is *** 653,662 **** Initialization.Defer_Abort_Nestable (Self_ID); ! -- ???? -- Experimentation has shown that abort is sometimes (but not -- always) already deferred when this is called. ! -- That may indicate an error. Find out what is going on. C := Chain.T_ID; --- 653,662 ---- Initialization.Defer_Abort_Nestable (Self_ID); ! -- ??? -- Experimentation has shown that abort is sometimes (but not -- always) already deferred when this is called. ! -- That may indicate an error. Find out what is going on. C := Chain.T_ID; *************** package body System.Tasking.Stages is *** 666,671 **** --- 666,672 ---- Temp := C.Common.Activation_Link; if C.Common.State = Unactivated then + Lock_RTS; Write_Lock (C); for J in 1 .. C.Entry_Num loop *************** package body System.Tasking.Stages is *** 674,680 **** --- 675,684 ---- end loop; Unlock (C); + Initialization.Remove_From_All_Tasks_List (C); + Unlock_RTS; + Vulnerable_Free_Task (C); C := Temp; end if; *************** package body System.Tasking.Stages is *** 688,694 **** -- Finalize_Global_Tasks -- --------------------------- ! -- ???? -- We have a potential problem here if finalization of global -- objects does anything with signals or the timer server, since -- by that time those servers have terminated. --- 692,698 ---- -- Finalize_Global_Tasks -- --------------------------- ! -- ??? -- We have a potential problem here if finalization of global -- objects does anything with signals or the timer server, since -- by that time those servers have terminated. *************** package body System.Tasking.Stages is *** 699,711 **** -- using the global finalization chain. procedure Finalize_Global_Tasks is ! Self_ID : constant Task_ID := STPO.Self; ! Zero_Independent : Boolean; begin if Self_ID.Deferral_Level = 0 then ! ! -- ?????? -- In principle, we should be able to predict whether -- abort is already deferred here (and it should not be deferred -- yet but in practice it seems Finalize_Global_Tasks is being --- 703,714 ---- -- using the global finalization chain. procedure Finalize_Global_Tasks is ! Self_ID : constant Task_ID := STPO.Self; ! Ignore : Boolean; begin if Self_ID.Deferral_Level = 0 then ! -- ??? -- In principle, we should be able to predict whether -- abort is already deferred here (and it should not be deferred -- yet but in practice it seems Finalize_Global_Tasks is being *************** package body System.Tasking.Stages is *** 715,721 **** Initialization.Defer_Abort_Nestable (Self_ID); -- Never undefer again!!! - end if; -- This code is only executed by the environment task --- 718,723 ---- *************** package body System.Tasking.Stages is *** 733,762 **** -- Force termination of "independent" library-level server tasks. Abort_Dependents (Self_ID); -- We need to explicitly wait for the task to be -- terminated here because on true concurrent system, we -- may end this procedure before the tasks are really -- terminated. loop ! Write_Lock (Self_ID); ! Zero_Independent := Utilities.Independent_Task_Count = 0; ! Unlock (Self_ID); -- We used to yield here, but this did not take into account -- low priority tasks that would cause dead lock in some cases. -- See 8126-020. ! Timed_Delay (Self_ID, 0.01, System.OS_Primitives.Relative); ! exit when Zero_Independent; end loop; -- ??? On multi-processor environments, it seems that the above loop -- isn't sufficient, so we need to add an additional delay. ! Timed_Delay (Self_ID, 0.1, System.OS_Primitives.Relative); -- Complete the environment task. --- 735,779 ---- -- Force termination of "independent" library-level server tasks. + Lock_RTS; + Abort_Dependents (Self_ID); + if not Single_Lock then + Unlock_RTS; + end if; + -- We need to explicitly wait for the task to be -- terminated here because on true concurrent system, we -- may end this procedure before the tasks are really -- terminated. + Write_Lock (Self_ID); + loop ! exit when Utilities.Independent_Task_Count = 0; -- We used to yield here, but this did not take into account -- low priority tasks that would cause dead lock in some cases. -- See 8126-020. ! Timed_Sleep ! (Self_ID, 0.01, System.OS_Primitives.Relative, ! Self_ID.Common.State, Ignore, Ignore); end loop; -- ??? On multi-processor environments, it seems that the above loop -- isn't sufficient, so we need to add an additional delay. ! Timed_Sleep ! (Self_ID, 0.01, System.OS_Primitives.Relative, ! Self_ID.Common.State, Ignore, Ignore); ! ! Unlock (Self_ID); ! ! if Single_Lock then ! Unlock_RTS; ! end if; -- Complete the environment task. *************** package body System.Tasking.Stages is *** 778,784 **** SSL.Get_Stack_Info := SSL.Get_Stack_Info_NT'Access; -- Don't bother trying to finalize Initialization.Global_Task_Lock ! -- and System.Task_Primitives.All_Tasks_L. end Finalize_Global_Tasks; --------------- --- 795,802 ---- SSL.Get_Stack_Info := SSL.Get_Stack_Info_NT'Access; -- Don't bother trying to finalize Initialization.Global_Task_Lock ! -- and System.Task_Primitives.RTS_Lock. ! end Finalize_Global_Tasks; --------------- *************** package body System.Tasking.Stages is *** 790,796 **** begin if T.Common.State = Terminated then - -- It is not safe to call Abort_Defer or Write_Lock at this stage Initialization.Task_Lock (Self_Id); --- 808,813 ---- *************** package body System.Tasking.Stages is *** 799,805 **** --- 816,825 ---- Free_Task_Image (T.Common.Task_Image); end if; + Lock_RTS; Initialization.Remove_From_All_Tasks_List (T); + Unlock_RTS; + Initialization.Task_Unlock (Self_Id); System.Task_Primitives.Operations.Finalize_TCB (T); *************** package body System.Tasking.Stages is *** 914,927 **** Enter_Task (Self_ID); ! -- We lock All_Tasks_L to wait for activator to finish activating -- the rest of the chain, so that everyone in the chain comes out -- in priority order. -- This also protects the value of -- Self_ID.Common.Activator.Common.Wait_Count. ! Lock_All_Tasks_List; ! Unlock_All_Tasks_List; begin -- We are separating the following portion of the code in order to --- 934,947 ---- Enter_Task (Self_ID); ! -- We lock RTS_Lock to wait for activator to finish activating -- the rest of the chain, so that everyone in the chain comes out -- in priority order. -- This also protects the value of -- Self_ID.Common.Activator.Common.Wait_Count. ! Lock_RTS; ! Unlock_RTS; begin -- We are separating the following portion of the code in order to *************** package body System.Tasking.Stages is *** 939,945 **** -- allowed. Self_ID.Common.Task_Entry_Point (Self_ID.Common.Task_Arg); - Terminate_Task (Self_ID); exception --- 959,964 ---- *************** package body System.Tasking.Stages is *** 983,998 **** -- calls to Task_Lock and Task_Unlock. That was not really a solution, -- since the operation Task_Unlock continued to access the ATCB after -- unlocking, after which the parent was observed to race ahead, ! -- deallocate the ATCB, and then reallocate it to another task. The -- call to Undefer_Abortion in Task_Unlock by the "terminated" task was ! -- overwriting the data of the new task that reused the ATCB! To solve -- this problem, we introduced the new operation Final_Task_Unlock. procedure Terminate_Task (Self_ID : Task_ID) is Environment_Task : constant Task_ID := STPO.Environment_Task; begin ! pragma Assert (Self_ID.Common.Activator = null); -- Since GCC cannot allocate stack chunks efficiently without reordering -- some of the allocations, we have to handle this unexpected situation --- 1002,1019 ---- -- calls to Task_Lock and Task_Unlock. That was not really a solution, -- since the operation Task_Unlock continued to access the ATCB after -- unlocking, after which the parent was observed to race ahead, ! -- deallocate the ATCB, and then reallocate it to another task. The -- call to Undefer_Abortion in Task_Unlock by the "terminated" task was ! -- overwriting the data of the new task that reused the ATCB! To solve -- this problem, we introduced the new operation Final_Task_Unlock. procedure Terminate_Task (Self_ID : Task_ID) is Environment_Task : constant Task_ID := STPO.Environment_Task; begin ! if Runtime_Traces then ! Send_Trace_Info (T_Terminate); ! end if; -- Since GCC cannot allocate stack chunks efficiently without reordering -- some of the allocations, we have to handle this unexpected situation *************** package body System.Tasking.Stages is *** 1003,1025 **** Vulnerable_Complete_Task (Self_ID); end if; -- Check if the current task is an independent task -- If so, decrement the Independent_Task_Count value. if Self_ID.Master_of_Task = 2 then ! Write_Lock (Environment_Task); ! Utilities.Independent_Task_Count := ! Utilities.Independent_Task_Count - 1; ! Unlock (Environment_Task); end if; -- Unprotect the guard page if needed. Stack_Guard (Self_ID, False); - Initialization.Task_Lock (Self_ID); Utilities.Make_Passive (Self_ID, Task_Completed => True); pragma Assert (Check_Exit (Self_ID)); SSL.Destroy_TSD (Self_ID.Common.Compiler_Data); --- 1024,1061 ---- Vulnerable_Complete_Task (Self_ID); end if; + Initialization.Task_Lock (Self_ID); + + if Single_Lock then + Lock_RTS; + end if; + -- Check if the current task is an independent task -- If so, decrement the Independent_Task_Count value. if Self_ID.Master_of_Task = 2 then ! if Single_Lock then ! Utilities.Independent_Task_Count := ! Utilities.Independent_Task_Count - 1; ! ! else ! Write_Lock (Environment_Task); ! Utilities.Independent_Task_Count := ! Utilities.Independent_Task_Count - 1; ! Unlock (Environment_Task); ! end if; end if; -- Unprotect the guard page if needed. Stack_Guard (Self_ID, False); Utilities.Make_Passive (Self_ID, Task_Completed => True); + if Single_Lock then + Unlock_RTS; + end if; + pragma Assert (Check_Exit (Self_ID)); SSL.Destroy_TSD (Self_ID.Common.Compiler_Data); *************** package body System.Tasking.Stages is *** 1042,1050 **** --- 1078,1096 ---- begin Initialization.Defer_Abort_Nestable (Self_ID); + + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (T); Result := T.Common.State = Terminated; Unlock (T); + + if Single_Lock then + Unlock_RTS; + end if; + Initialization.Undefer_Abort_Nestable (Self_ID); return Result; end Terminated; *************** package body System.Tasking.Stages is *** 1053,1071 **** -- Vulnerable_Complete_Activation -- ------------------------------------ - -- Only call this procedure with abortion deferred. - -- As in several other places, the locks of the activator and activated ! -- task are both locked here. This follows our deadlock prevention lock -- ordering policy, since the activated task must be created after the -- activator. procedure Vulnerable_Complete_Activation (Self_ID : Task_ID) is ! Activator : Task_ID := Self_ID.Common.Activator; begin ! pragma Debug ! (Debug.Trace (Self_ID, "V_Complete_Activation", 'C')); Write_Lock (Activator); Write_Lock (Self_ID); --- 1099,1114 ---- -- Vulnerable_Complete_Activation -- ------------------------------------ -- As in several other places, the locks of the activator and activated ! -- task are both locked here. This follows our deadlock prevention lock -- ordering policy, since the activated task must be created after the -- activator. procedure Vulnerable_Complete_Activation (Self_ID : Task_ID) is ! Activator : constant Task_ID := Self_ID.Common.Activator; begin ! pragma Debug (Debug.Trace (Self_ID, "V_Complete_Activation", 'C')); Write_Lock (Activator); Write_Lock (Self_ID); *************** package body System.Tasking.Stages is *** 1102,1108 **** Unlock (Activator); -- After the activation, active priority should be the same ! -- as base priority. We must unlock the Activator first, -- though, since it should not wait if we have lower priority. if Get_Priority (Self_ID) /= Self_ID.Common.Base_Priority then --- 1145,1151 ---- Unlock (Activator); -- After the activation, active priority should be the same ! -- as base priority. We must unlock the Activator first, -- though, since it should not wait if we have lower priority. if Get_Priority (Self_ID) /= Self_ID.Common.Base_Priority then *************** package body System.Tasking.Stages is *** 1124,1130 **** To_Be_Freed : Task_ID; -- This is a list of ATCBs to be freed, after we have released ! -- all RTS locks. This is necessary because of the locking order -- rules, since the storage manager uses Global_Task_Lock. pragma Warnings (Off); --- 1167,1173 ---- To_Be_Freed : Task_ID; -- This is a list of ATCBs to be freed, after we have released ! -- all RTS locks. This is necessary because of the locking order -- rules, since the storage manager uses Global_Task_Lock. pragma Warnings (Off); *************** package body System.Tasking.Stages is *** 1133,1141 **** -- Temporary error-checking code below. This is part of the checks -- added in the new run time. Call it only inside a pragma Assert. function Check_Unactivated_Tasks return Boolean is begin ! Lock_All_Tasks_List; Write_Lock (Self_ID); C := All_Tasks_List; --- 1176,1191 ---- -- Temporary error-checking code below. This is part of the checks -- added in the new run time. Call it only inside a pragma Assert. + ----------------------------- + -- Check_Unactivated_Tasks -- + ----------------------------- + function Check_Unactivated_Tasks return Boolean is begin ! if not Single_Lock then ! Lock_RTS; ! end if; ! Write_Lock (Self_ID); C := All_Tasks_List; *************** package body System.Tasking.Stages is *** 1158,1171 **** end loop; Unlock (Self_ID); ! Unlock_All_Tasks_List; return True; end Check_Unactivated_Tasks; -- Start of processing for Vulnerable_Complete_Master begin - pragma Debug (Debug.Trace (Self_ID, "V_Complete_Master", 'C')); --- 1208,1224 ---- end loop; Unlock (Self_ID); ! ! if not Single_Lock then ! Unlock_RTS; ! end if; ! return True; end Check_Unactivated_Tasks; -- Start of processing for Vulnerable_Complete_Master begin pragma Debug (Debug.Trace (Self_ID, "V_Complete_Master", 'C')); *************** package body System.Tasking.Stages is *** 1179,1185 **** -- zero for new tasks, and the task should not exit the -- sleep-loops that use this count until the count reaches zero. ! Lock_All_Tasks_List; Write_Lock (Self_ID); C := All_Tasks_List; --- 1232,1238 ---- -- zero for new tasks, and the task should not exit the -- sleep-loops that use this count until the count reaches zero. ! Lock_RTS; Write_Lock (Self_ID); C := All_Tasks_List; *************** package body System.Tasking.Stages is *** 1191,1197 **** C.Common.Activator := null; C.Common.State := Terminated; C.Callable := False; ! Cancel_Queued_Entry_Calls (C); Unlock (C); end if; --- 1244,1250 ---- C.Common.Activator := null; C.Common.State := Terminated; C.Callable := False; ! Utilities.Cancel_Queued_Entry_Calls (C); Unlock (C); end if; *************** package body System.Tasking.Stages is *** 1210,1216 **** Self_ID.Common.State := Master_Completion_Sleep; Unlock (Self_ID); ! Unlock_All_Tasks_List; -- Wait until dependent tasks are all terminated or ready to terminate. -- While waiting, the task may be awakened if the task's priority needs --- 1263,1272 ---- Self_ID.Common.State := Master_Completion_Sleep; Unlock (Self_ID); ! ! if not Single_Lock then ! Unlock_RTS; ! end if; -- Wait until dependent tasks are all terminated or ready to terminate. -- While waiting, the task may be awakened if the task's priority needs *************** package body System.Tasking.Stages is *** 1219,1224 **** --- 1275,1281 ---- -- to zero. Write_Lock (Self_ID); + loop Initialization.Poll_Base_Priority_Change (Self_ID); exit when Self_ID.Common.Wait_Count = 0; *************** package body System.Tasking.Stages is *** 1228,1237 **** if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level and then not Self_ID.Dependents_Aborted then ! Unlock (Self_ID); ! Abort_Dependents (Self_ID); ! Write_Lock (Self_ID); ! else Sleep (Self_ID, Master_Completion_Sleep); end if; --- 1285,1299 ---- if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level and then not Self_ID.Dependents_Aborted then ! if Single_Lock then ! Abort_Dependents (Self_ID); ! else ! Unlock (Self_ID); ! Lock_RTS; ! Abort_Dependents (Self_ID); ! Unlock_RTS; ! Write_Lock (Self_ID); ! end if; else Sleep (Self_ID, Master_Completion_Sleep); end if; *************** package body System.Tasking.Stages is *** 1247,1287 **** pragma Assert (Check_Unactivated_Tasks); if Self_ID.Alive_Count > 1 then ! ! -- ????? ! -- Consider finding a way to skip the following extra steps if ! -- there are no dependents with terminate alternatives. This ! -- could be done by adding another count to the ATCB, similar to ! -- Awake_Count, but keeping track of count of tasks that are on ! -- terminate alternatives. pragma Assert (Self_ID.Common.Wait_Count = 0); -- Force any remaining dependents to terminate, by aborting them. Abort_Dependents (Self_ID); -- Above, when we "abort" the dependents we are simply using this -- operation for convenience. We are not required to support the full -- abort-statement semantics; in particular, we are not required to ! -- immediately cancel any queued or in-service entry calls. That is -- good, because if we tried to cancel a call we would need to lock ! -- the caller, in order to wake the caller up. Our anti-deadlock -- rules prevent us from doing that without releasing the locks on C ! -- and Self_ID. Releasing and retaking those locks would be ! -- wasteful, at best, and should not be considered further without ! -- more detailed analysis of potential concurrent accesses to the -- ATCBs of C and Self_ID. -- Count how many "alive" dependent tasks this master currently ! -- has, and record this in Wait_Count. ! -- This count should start at zero, since it is initialized to ! -- zero for new tasks, and the task should not exit the ! -- sleep-loops that use this count until the count reaches zero. pragma Assert (Self_ID.Common.Wait_Count = 0); - Lock_All_Tasks_List; Write_Lock (Self_ID); C := All_Tasks_List; --- 1309,1350 ---- pragma Assert (Check_Unactivated_Tasks); if Self_ID.Alive_Count > 1 then ! -- ??? ! -- Consider finding a way to skip the following extra steps if there ! -- are no dependents with terminate alternatives. This could be done ! -- by adding another count to the ATCB, similar to Awake_Count, but ! -- keeping track of tasks that are on terminate alternatives. pragma Assert (Self_ID.Common.Wait_Count = 0); -- Force any remaining dependents to terminate, by aborting them. + if not Single_Lock then + Lock_RTS; + end if; + Abort_Dependents (Self_ID); -- Above, when we "abort" the dependents we are simply using this -- operation for convenience. We are not required to support the full -- abort-statement semantics; in particular, we are not required to ! -- immediately cancel any queued or in-service entry calls. That is -- good, because if we tried to cancel a call we would need to lock ! -- the caller, in order to wake the caller up. Our anti-deadlock -- rules prevent us from doing that without releasing the locks on C ! -- and Self_ID. Releasing and retaking those locks would be wasteful ! -- at best, and should not be considered further without more ! -- detailed analysis of potential concurrent accesses to the -- ATCBs of C and Self_ID. -- Count how many "alive" dependent tasks this master currently ! -- has, and record this in Wait_Count. This count should start at ! -- zero, since it is initialized to zero for new tasks, and the ! -- task should not exit the sleep-loops that use this count until ! -- the count reaches zero. pragma Assert (Self_ID.Common.Wait_Count = 0); Write_Lock (Self_ID); C := All_Tasks_List; *************** package body System.Tasking.Stages is *** 1304,1310 **** Self_ID.Common.State := Master_Phase_2_Sleep; Unlock (Self_ID); ! Unlock_All_Tasks_List; -- Wait for all counted tasks to finish terminating themselves. --- 1367,1376 ---- Self_ID.Common.State := Master_Phase_2_Sleep; Unlock (Self_ID); ! ! if not Single_Lock then ! Unlock_RTS; ! end if; -- Wait for all counted tasks to finish terminating themselves. *************** package body System.Tasking.Stages is *** 1322,1330 **** -- We don't wake up for abortion here. We are already terminating -- just as fast as we can, so there is no point. - -- ???? - -- Consider whether we want to bother checking for priority - -- changes in the loop above, though. -- Remove terminated tasks from the list of Self_ID's dependents, but -- don't free their ATCBs yet, because of lock order restrictions, --- 1388,1393 ---- *************** package body System.Tasking.Stages is *** 1332,1338 **** -- other locks. Instead, we put those ATCBs to be freed onto a -- temporary list, called To_Be_Freed. ! Lock_All_Tasks_List; C := All_Tasks_List; P := null; --- 1395,1404 ---- -- other locks. Instead, we put those ATCBs to be freed onto a -- temporary list, called To_Be_Freed. ! if not Single_Lock then ! Lock_RTS; ! end if; ! C := All_Tasks_List; P := null; *************** package body System.Tasking.Stages is *** 1355,1361 **** end if; end loop; ! Unlock_All_Tasks_List; -- Free all the ATCBs on the list To_Be_Freed. --- 1421,1427 ---- end if; end loop; ! Unlock_RTS; -- Free all the ATCBs on the list To_Be_Freed. *************** package body System.Tasking.Stages is *** 1377,1383 **** -- otherwise occur during finalization of library-level objects. -- A better solution might be to hook task objects into the -- finalization chain and deallocate the ATCB when the task ! -- object is deallocated. However, this change is not likely -- to gain anything significant, since all this storage should -- be recovered en-masse when the process exits. --- 1443,1449 ---- -- otherwise occur during finalization of library-level objects. -- A better solution might be to hook task objects into the -- finalization chain and deallocate the ATCB when the task ! -- object is deallocated. However, this change is not likely -- to gain anything significant, since all this storage should -- be recovered en-masse when the process exits. *************** package body System.Tasking.Stages is *** 1390,1403 **** if T.Interrupt_Entry and Interrupt_Manager_ID /= null then declare ! Detach_Interrupt_Entries_Index : Task_Entry_Index := 6; -- Corresponds to the entry index of System.Interrupts. -- Interrupt_Manager.Detach_Interrupt_Entries. -- Be sure to update this value when changing -- Interrupt_Manager specs. type Param_Type is access all Task_ID; Param : aliased Param_Type := T'Access; begin System.Tasking.Rendezvous.Call_Simple (Interrupt_Manager_ID, Detach_Interrupt_Entries_Index, --- 1456,1471 ---- if T.Interrupt_Entry and Interrupt_Manager_ID /= null then declare ! Detach_Interrupt_Entries_Index : Task_Entry_Index := 1; -- Corresponds to the entry index of System.Interrupts. -- Interrupt_Manager.Detach_Interrupt_Entries. -- Be sure to update this value when changing -- Interrupt_Manager specs. type Param_Type is access all Task_ID; + Param : aliased Param_Type := T'Access; + begin System.Tasking.Rendezvous.Call_Simple (Interrupt_Manager_ID, Detach_Interrupt_Entries_Index, *************** package body System.Tasking.Stages is *** 1423,1447 **** end if; end loop; ! -- It might seem nice to let the terminated task deallocate ! -- its own ATCB. That would not cover the case of unactivated ! -- tasks. It also would force us to keep the underlying thread ! -- around past termination, since references to the ATCB are ! -- possible past termination. Currently, we get rid of the ! -- thread as soon as the task terminates, and let the parent ! -- recover the ATCB later. - -- ???? -- Some day, if we want to recover the ATCB earlier, at task ! -- termination, we could consider using "fat task IDs", that ! -- include the serial number with the ATCB pointer, to catch ! -- references to tasks that no longer have ATCBs. It is not ! -- clear how much this would gain, since the user-level task ! -- object would still be occupying storage. -- Make next master level up active. ! -- We don't need to lock the ATCB, since the value is only ! -- updated by each task for itself. Self_ID.Master_Within := CM - 1; end Vulnerable_Complete_Master; --- 1491,1512 ---- end if; end loop; ! -- It might seem nice to let the terminated task deallocate its own ! -- ATCB. That would not cover the case of unactivated tasks. It also ! -- would force us to keep the underlying thread around past termination, ! -- since references to the ATCB are possible past termination. ! -- Currently, we get rid of the thread as soon as the task terminates, ! -- and let the parent recover the ATCB later. -- Some day, if we want to recover the ATCB earlier, at task ! -- termination, we could consider using "fat task IDs", that include the ! -- serial number with the ATCB pointer, to catch references to tasks ! -- that no longer have ATCBs. It is not clear how much this would gain, ! -- since the user-level task object would still be occupying storage. -- Make next master level up active. ! -- We don't need to lock the ATCB, since the value is only updated by ! -- each task for itself. Self_ID.Master_Within := CM - 1; end Vulnerable_Complete_Master; *************** package body System.Tasking.Stages is *** 1450,1460 **** -- Vulnerable_Complete_Task -- ------------------------------ ! -- Complete the calling task. -- This procedure must be called with abort deferred. (That's why the -- name has "Vulnerable" in it.) It should only be called by Complete_Task ! -- and Finalizate_Global_Tasks (for the environment task). -- The effect is similar to that of Complete_Master. Differences include -- the closing of entries here, and computation of the number of active --- 1515,1525 ---- -- Vulnerable_Complete_Task -- ------------------------------ ! -- Complete the calling task -- This procedure must be called with abort deferred. (That's why the -- name has "Vulnerable" in it.) It should only be called by Complete_Task ! -- and Finalize_Global_Tasks (for the environment task). -- The effect is similar to that of Complete_Master. Differences include -- the closing of entries here, and computation of the number of active *************** package body System.Tasking.Stages is *** 1476,1499 **** pragma Assert (Self_ID.Open_Accepts = null); pragma Assert (Self_ID.ATC_Nesting_Level = 1); ! pragma Debug ! (Debug.Trace (Self_ID, "V_Complete_Task", 'C')); Write_Lock (Self_ID); Self_ID.Callable := False; ! -- In theory, Self should have no pending entry calls ! -- left on its call-stack. Each async. select statement should ! -- clean its own call, and blocking entry calls should ! -- defer abort until the calls are cancelled, then clean up. ! Cancel_Queued_Entry_Calls (Self_ID); Unlock (Self_ID); if Self_ID.Common.Activator /= null then Vulnerable_Complete_Activation (Self_ID); end if; -- If Self_ID.Master_Within = Self_ID.Master_of_Task + 2 -- we may have dependent tasks for which we need to wait. -- Otherwise, we can just exit. --- 1541,1571 ---- pragma Assert (Self_ID.Open_Accepts = null); pragma Assert (Self_ID.ATC_Nesting_Level = 1); ! pragma Debug (Debug.Trace (Self_ID, "V_Complete_Task", 'C')); ! ! if Single_Lock then ! Lock_RTS; ! end if; Write_Lock (Self_ID); Self_ID.Callable := False; ! -- In theory, Self should have no pending entry calls left on its ! -- call-stack. Each async. select statement should clean its own call, ! -- and blocking entry calls should defer abort until the calls are ! -- cancelled, then clean up. ! Utilities.Cancel_Queued_Entry_Calls (Self_ID); Unlock (Self_ID); if Self_ID.Common.Activator /= null then Vulnerable_Complete_Activation (Self_ID); end if; + if Single_Lock then + Unlock_RTS; + end if; + -- If Self_ID.Master_Within = Self_ID.Master_of_Task + 2 -- we may have dependent tasks for which we need to wait. -- Otherwise, we can just exit. *************** package body System.Tasking.Stages is *** 1501,1507 **** if Self_ID.Master_Within = Self_ID.Master_of_Task + 2 then Vulnerable_Complete_Master (Self_ID); end if; - end Vulnerable_Complete_Task; -------------------------- --- 1573,1578 ---- *************** package body System.Tasking.Stages is *** 1511,1518 **** --- 1582,1591 ---- -- Recover all runtime system storage associated with the task T. -- This should only be called after T has terminated and will no -- longer be referenced. + -- For tasks created by an allocator that fails, due to an exception, -- it is called from Expunge_Unactivated_Tasks. + -- For tasks created by elaboration of task object declarations it -- is called from the finalization code of the Task_Wrapper procedure. -- It is also called from Unchecked_Deallocation, for objects that *************** package body System.Tasking.Stages is *** 1523,1534 **** --- 1596,1617 ---- pragma Debug (Debug.Trace ("Vulnerable_Free_Task", T, 'C')); + if Single_Lock then + Lock_RTS; + end if; + Write_Lock (T); Initialization.Finalize_Attributes_Link.all (T); Unlock (T); + + if Single_Lock then + Unlock_RTS; + end if; + if T.Common.Task_Image /= null then Free_Task_Image (T.Common.Task_Image); end if; + System.Task_Primitives.Operations.Finalize_TCB (T); end Vulnerable_Free_Task; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tassta.ads gcc-3.3/gcc/ada/s-tassta.ads *** gcc-3.2.3/gcc/ada/s-tassta.ads 2002-05-04 03:28:49.000000000 +0000 --- gcc-3.3/gcc/ada/s-tassta.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-1999, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasuti.adb gcc-3.3/gcc/ada/s-tasuti.adb *** gcc-3.2.3/gcc/ada/s-tasuti.adb 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasuti.adb 2002-03-14 11:00:00.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** with System.Task_Primitives.Operations; *** 51,57 **** -- Unlock -- Sleep -- Abort_Task ! -- Lock/Unlock_All_Tasks_List with System.Tasking.Initialization; -- Used for Defer_Abort --- 49,55 ---- -- Unlock -- Sleep -- Abort_Task ! -- Lock/Unlock_RTS with System.Tasking.Initialization; -- Used for Defer_Abort *************** with System.Tasking.Queuing; *** 65,120 **** with System.Tasking.Debug; -- used for Trace with Unchecked_Conversion; package body System.Tasking.Utilities is package STPO renames System.Task_Primitives.Operations; ! use System.Tasking.Debug; ! use System.Task_Primitives; ! use System.Task_Primitives.Operations; ! ! procedure Locked_Abort_To_Level ! (Self_Id : Task_ID; ! T : Task_ID; ! L : ATC_Level) ! renames ! Initialization.Locked_Abort_To_Level; ! ! procedure Defer_Abort (Self_Id : Task_ID) renames ! System.Tasking.Initialization.Defer_Abort; ! ! procedure Defer_Abort_Nestable (Self_Id : Task_ID) renames ! System.Tasking.Initialization.Defer_Abort_Nestable; ! ! procedure Undefer_Abort (Self_Id : Task_ID) renames ! System.Tasking.Initialization.Undefer_Abort; ! ! procedure Undefer_Abort_Nestable (Self_Id : Task_ID) renames ! System.Tasking.Initialization.Undefer_Abort_Nestable; ! procedure Wakeup_Entry_Caller ! (Self_Id : Task_ID; ! Entry_Call : Entry_Call_Link; ! New_State : Entry_Call_State) ! renames ! Initialization.Wakeup_Entry_Caller; ! ---------------- ! -- Abort_Task -- ! ---------------- -- Similar to Locked_Abort_To_Level (Self_ID, T, 0), but: ! -- (1) caller should be holding no locks -- (2) may be called for tasks that have not yet been activated -- (3) always aborts whole task ! procedure Abort_One_Task ! (Self_ID : Task_ID; ! T : Task_ID) ! is begin Write_Lock (T); if T.Common.State = Unactivated then --- 63,104 ---- with System.Tasking.Debug; -- used for Trace + with System.Parameters; + -- used for Single_Lock + -- Runtime_Traces + + with System.Traces.Tasking; + -- used for Send_Trace_Info + with Unchecked_Conversion; package body System.Tasking.Utilities is package STPO renames System.Task_Primitives.Operations; ! use Parameters; ! use Tasking.Debug; ! use Task_Primitives; ! use Task_Primitives.Operations; ! use System.Traces; ! use System.Traces.Tasking; ! -------------------- ! -- Abort_One_Task -- ! -------------------- -- Similar to Locked_Abort_To_Level (Self_ID, T, 0), but: ! -- (1) caller should be holding no locks except RTS_Lock when Single_Lock -- (2) may be called for tasks that have not yet been activated -- (3) always aborts whole task ! procedure Abort_One_Task (Self_ID : Task_ID; T : Task_ID) is begin + if Parameters.Runtime_Traces then + Send_Trace_Info (T_Abort, Self_ID, T); + end if; + Write_Lock (T); if T.Common.State = Unactivated then *************** package body System.Tasking.Utilities is *** 124,130 **** Cancel_Queued_Entry_Calls (T); elsif T.Common.State /= Terminated then ! Locked_Abort_To_Level (Self_ID, T, 0); end if; Unlock (T); --- 108,114 ---- Cancel_Queued_Entry_Calls (T); elsif T.Common.State /= Terminated then ! Initialization.Locked_Abort_To_Level (Self_ID, T, 0); end if; Unlock (T); *************** package body System.Tasking.Utilities is *** 148,174 **** P : Task_ID; begin ! -- ???? ! -- Since this is a "potentially blocking operation", we should ! -- add a separate check here that we are not inside a protected ! -- operation. ! ! Defer_Abort_Nestable (Self_Id); -- ????? -- Really should not be nested deferral here. -- Patch for code generation error that defers abort before -- evaluating parameters of an entry call (at least, timed entry -- calls), and so may propagate an exception that causes abort ! -- to remain undeferred indefinitely. See C97404B. When all -- such bugs are fixed, this patch can be removed. for J in Tasks'Range loop C := Tasks (J); Abort_One_Task (Self_Id, C); end loop; - Lock_All_Tasks_List; C := All_Tasks_List; while C /= null loop --- 132,154 ---- P : Task_ID; begin ! Initialization.Defer_Abort_Nestable (Self_Id); -- ????? -- Really should not be nested deferral here. -- Patch for code generation error that defers abort before -- evaluating parameters of an entry call (at least, timed entry -- calls), and so may propagate an exception that causes abort ! -- to remain undeferred indefinitely. See C97404B. When all -- such bugs are fixed, this patch can be removed. + Lock_RTS; + for J in Tasks'Range loop C := Tasks (J); Abort_One_Task (Self_Id, C); end loop; C := All_Tasks_List; while C /= null loop *************** package body System.Tasking.Utilities is *** 188,204 **** C := C.Common.All_Tasks_Link; end loop; ! Unlock_All_Tasks_List; ! Undefer_Abort_Nestable (Self_Id); end Abort_Tasks; ------------------------------- -- Cancel_Queued_Entry_Calls -- ------------------------------- ! -- Cancel any entry calls queued on target task. Call this only while ! -- holding T locked, and nothing more. This should only be called by T, ! -- unless T is a terminated previously unactivated task. procedure Cancel_Queued_Entry_Calls (T : Task_ID) is Next_Entry_Call : Entry_Call_Link; --- 168,183 ---- C := C.Common.All_Tasks_Link; end loop; ! Unlock_RTS; ! Initialization.Undefer_Abort_Nestable (Self_Id); end Abort_Tasks; ------------------------------- -- Cancel_Queued_Entry_Calls -- ------------------------------- ! -- This should only be called by T, unless T is a terminated previously ! -- unactivated task. procedure Cancel_Queued_Entry_Calls (T : Task_ID) is Next_Entry_Call : Entry_Call_Link; *************** package body System.Tasking.Utilities is *** 214,220 **** Queuing.Dequeue_Head (T.Entry_Queues (J), Entry_Call); while Entry_Call /= null loop - -- Leave Entry_Call.Done = False, since this is cancelled Caller := Entry_Call.Self; --- 193,198 ---- *************** package body System.Tasking.Utilities is *** 223,229 **** Level := Entry_Call.Level - 1; Unlock (T); Write_Lock (Entry_Call.Self); ! Wakeup_Entry_Caller (Self_Id, Entry_Call, Cancelled); Unlock (Entry_Call.Self); Write_Lock (T); Entry_Call.State := Done; --- 201,208 ---- Level := Entry_Call.Level - 1; Unlock (T); Write_Lock (Entry_Call.Self); ! Initialization.Wakeup_Entry_Caller ! (Self_Id, Entry_Call, Cancelled); Unlock (Entry_Call.Self); Write_Lock (T); Entry_Call.State := Done; *************** package body System.Tasking.Utilities is *** 277,303 **** -- Make_Independent -- ---------------------- - -- Move the current task to the outermost level (level 2) of the master - -- hierarchy of the environment task. That is one level further out - -- than normal tasks defined in library-level packages (level 3). The - -- environment task will wait for level 3 tasks to terminate normally, - -- then it will abort all the level 2 tasks. See Finalize_Global_Tasks - -- procedure for more information. - - -- This is a dangerous operation, and should only be used on nested tasks - -- or tasks that depend on any objects that might be finalized earlier than - -- the termination of the environment task. It is for internal use by the - -- GNARL, to prevent such internal server tasks from preventing a partition - -- from terminating. - - -- Also note that the run time assumes that the parent of an independent - -- task is the environment task. If this is not the case, Make_Independent - -- will change the task's parent. This assumption is particularly - -- important for master level completion and for the computation of - -- Independent_Task_Count. - - -- See procedures Init_RTS and Finalize_Global_Tasks for related code. - procedure Make_Independent is Self_Id : constant Task_ID := STPO.Self; Environment_Task : constant Task_ID := STPO.Environment_Task; --- 256,261 ---- *************** package body System.Tasking.Utilities is *** 309,315 **** Known_Tasks (Self_Id.Known_Tasks_Index) := null; end if; ! Defer_Abort (Self_Id); Write_Lock (Environment_Task); Write_Lock (Self_Id); --- 267,278 ---- Known_Tasks (Self_Id.Known_Tasks_Index) := null; end if; ! Initialization.Defer_Abort (Self_Id); ! ! if Single_Lock then ! Lock_RTS; ! end if; ! Write_Lock (Environment_Task); Write_Lock (Self_Id); *************** package body System.Tasking.Utilities is *** 352,371 **** end if; Unlock (Environment_Task); ! Undefer_Abort (Self_Id); end Make_Independent; ------------------ -- Make_Passive -- ------------------ ! -- Update counts to indicate current task is either terminated ! -- or accepting on a terminate alternative. Call holding no locks. ! ! procedure Make_Passive ! (Self_ID : Task_ID; ! Task_Completed : Boolean) ! is C : Task_ID := Self_ID; P : Task_ID := C.Common.Parent; --- 315,333 ---- end if; Unlock (Environment_Task); ! ! if Single_Lock then ! Unlock_RTS; ! end if; ! ! Initialization.Undefer_Abort (Self_Id); end Make_Independent; ------------------ -- Make_Passive -- ------------------ ! procedure Make_Passive (Self_ID : Task_ID; Task_Completed : Boolean) is C : Task_ID := Self_ID; P : Task_ID := C.Common.Parent; *************** package body System.Tasking.Utilities is *** 433,440 **** -- is waiting (with zero Awake_Count) in Phase 2 of -- Complete_Master. ! pragma Debug ! (Debug.Trace (Self_ID, "Make_Passive: Phase 2", 'M')); pragma Assert (P /= null); --- 395,401 ---- -- is waiting (with zero Awake_Count) in Phase 2 of -- Complete_Master. ! pragma Debug (Debug.Trace (Self_ID, "Make_Passive: Phase 2", 'M')); pragma Assert (P /= null); *************** package body System.Tasking.Utilities is *** 474,480 **** if P.Common.State = Master_Phase_2_Sleep and then C.Master_of_Task = P.Master_Within - then pragma Assert (P.Common.Wait_Count > 0); P.Common.Wait_Count := P.Common.Wait_Count - 1; --- 435,440 ---- *************** package body System.Tasking.Utilities is *** 538,545 **** -- P has non-passive dependents. ! if P.Common.State = Master_Completion_Sleep and then ! C.Master_of_Task = P.Master_Within then pragma Debug (Debug.Trace --- 498,505 ---- -- P has non-passive dependents. ! if P.Common.State = Master_Completion_Sleep ! and then C.Master_of_Task = P.Master_Within then pragma Debug (Debug.Trace diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tasuti.ads gcc-3.3/gcc/ada/s-tasuti.ads *** gcc-3.2.3/gcc/ada/s-tasuti.ads 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-tasuti.ads 2002-03-14 11:00:00.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1991-1998 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** package System.Tasking.Utilities is *** 49,66 **** --------------------------------- procedure Make_Independent; ! -- Move the current task to the outermost level (level 1) of the master ! -- master hierarchy of the environment task. This is one level further ! -- out than normal tasks defined in library-level packages (level 2). ! -- The environment task will wait for level 2 tasks to terminate normally, ! -- then it will abort all the level 1 tasks. See Finalize_Global_Tasks -- procedure for more information. -- -- This is a dangerous operation, and should only be used on nested tasks -- or tasks that depend on any objects that might be finalized earlier than ! -- the termination of the environment task. It is for internal use by ! -- GNARL, to prevent such internal server tasks from preventing a ! -- partition from terminating. Independent_Task_Count : Natural := 0; -- Number of independent task. This counter is incremented each time --- 47,70 ---- --------------------------------- procedure Make_Independent; ! -- Move the current task to the outermost level (level 2) of the master ! -- hierarchy of the environment task. That is one level further out ! -- than normal tasks defined in library-level packages (level 3). The ! -- environment task will wait for level 3 tasks to terminate normally, ! -- then it will abort all the level 2 tasks. See Finalize_Global_Tasks -- procedure for more information. -- -- This is a dangerous operation, and should only be used on nested tasks -- or tasks that depend on any objects that might be finalized earlier than ! -- the termination of the environment task. It is for internal use by the ! -- GNARL, to prevent such internal server tasks from preventing a partition ! -- from terminating. ! -- ! -- Also note that the run time assumes that the parent of an independent ! -- task is the environment task. If this is not the case, Make_Independent ! -- will change the task's parent. This assumption is particularly ! -- important for master level completion and for the computation of ! -- Independent_Task_Count. Independent_Task_Count : Natural := 0; -- Number of independent task. This counter is incremented each time *************** package System.Tasking.Utilities is *** 75,81 **** procedure Cancel_Queued_Entry_Calls (T : Task_ID); -- Cancel any entry calls queued on target task. ! -- Do not call this while holding any locks. procedure Exit_One_ATC_Level (Self_ID : Task_ID); pragma Inline (Exit_One_ATC_Level); --- 79,85 ---- procedure Cancel_Queued_Entry_Calls (T : Task_ID); -- Cancel any entry calls queued on target task. ! -- Call this while holding T's lock (or RTS_Lock in Single_Lock mode). procedure Exit_One_ATC_Level (Self_ID : Task_ID); pragma Inline (Exit_One_ATC_Level); *************** package System.Tasking.Utilities is *** 83,91 **** -- This is a bit of common code for all entry calls. -- The effect is to exit one level of ATC nesting. ! procedure Abort_One_Task ! (Self_ID : Task_ID; ! T : Task_ID); -- Similar to Locked_Abort_To_Level (Self_ID, T, 0), but: -- (1) caller should be holding no locks -- (2) may be called for tasks that have not yet been activated --- 87,93 ---- -- This is a bit of common code for all entry calls. -- The effect is to exit one level of ATC nesting. ! procedure Abort_One_Task (Self_ID : Task_ID; T : Task_ID); -- Similar to Locked_Abort_To_Level (Self_ID, T, 0), but: -- (1) caller should be holding no locks -- (2) may be called for tasks that have not yet been activated *************** package System.Tasking.Utilities is *** 95,104 **** -- Abort_Tasks is called to initiate abortion, however, the actual -- abortion is done by abortee by means of Abort_Handler ! procedure Make_Passive ! (Self_ID : Task_ID; ! Task_Completed : Boolean); -- Update counts to indicate current task is either terminated ! -- or accepting on a terminate alternative. Call holding no locks. end System.Tasking.Utilities; --- 97,106 ---- -- Abort_Tasks is called to initiate abortion, however, the actual -- abortion is done by abortee by means of Abort_Handler ! procedure Make_Passive (Self_ID : Task_ID; Task_Completed : Boolean); -- Update counts to indicate current task is either terminated ! -- or accepting on a terminate alternative. ! -- Call holding no locks except Global_Task_Lock when calling from ! -- Terminate_Task, and RTS_Lock when Single_Lock is True. end System.Tasking.Utilities; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tataat.adb gcc-3.3/gcc/ada/s-tataat.adb *** gcc-3.2.3/gcc/ada/s-tataat.adb 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tataat.adb 2002-03-14 11:00:00.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1995-1999 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1995-2001 Florida State University -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** with System.Storage_Elements; *** 40,46 **** with System.Task_Primitives.Operations; -- used for Write_Lock -- Unlock ! -- Lock/Unlock_All_Tasks_List with System.Tasking.Initialization; -- used for Defer_Abort --- 38,44 ---- with System.Task_Primitives.Operations; -- used for Write_Lock -- Unlock ! -- Lock/Unlock_RTS with System.Tasking.Initialization; -- used for Defer_Abort *************** with Unchecked_Conversion; *** 50,57 **** package body System.Tasking.Task_Attributes is ! use Task_Primitives.Operations, ! System.Tasking.Initialization; function To_Access_Node is new Unchecked_Conversion (Access_Address, Access_Node); --- 48,55 ---- package body System.Tasking.Task_Attributes is ! use Task_Primitives.Operations; ! use Tasking.Initialization; function To_Access_Node is new Unchecked_Conversion (Access_Address, Access_Node); *************** package body System.Tasking.Task_Attribu *** 70,76 **** begin Defer_Abortion; ! Write_Lock (All_Attrs_L'Access); -- Remove this instantiation from the list of all instantiations. --- 68,74 ---- begin Defer_Abortion; ! Lock_RTS; -- Remove this instantiation from the list of all instantiations. *************** package body System.Tasking.Task_Attribu *** 93,99 **** end; if X.Index /= 0 then - -- Free location of this attribute, for reuse. In_Use := In_Use and not (2**Natural (X.Index)); --- 91,96 ---- *************** package body System.Tasking.Task_Attribu *** 106,113 **** -- all tasks, and deallocate the nodes. -- Deallocation does finalization, if necessary. - Lock_All_Tasks_List; - declare C : System.Tasking.Task_ID := All_Tasks_List; P : Access_Node; --- 103,108 ---- *************** package body System.Tasking.Task_Attribu *** 131,138 **** P.Next := Q.Next; end if; ! -- Can't Deallocate now since we are holding the All_Tasks_L ! -- lock. Q.Next := To_Be_Freed; To_Be_Freed := Q; --- 126,132 ---- P.Next := Q.Next; end if; ! -- Can't Deallocate now since we are holding RTS_Lock. Q.Next := To_Be_Freed; To_Be_Freed := Q; *************** package body System.Tasking.Task_Attribu *** 142,152 **** C := C.Common.All_Tasks_Link; end loop; end; - - Unlock_All_Tasks_List; end if; ! Unlock (All_Attrs_L'Access); while To_Be_Freed /= null loop Q := To_Be_Freed; --- 136,144 ---- C := C.Common.All_Tasks_Link; end loop; end; end if; ! Unlock_RTS; while To_Be_Freed /= null loop Q := To_Be_Freed; *************** package body System.Tasking.Task_Attribu *** 193,211 **** -- Initialize Attributes -- --------------------------- ! -- This is to be called by System.Task_Stages.Create_Task. -- It relies on their being no concurrent access to this TCB, ! -- so it does not defer abortion or lock T.L. procedure Initialize_Attributes (T : Task_ID) is P : Access_Instance; - begin ! Write_Lock (All_Attrs_L'Access); -- Initialize all the direct-access attributes of this task. P := All_Attributes; while P /= null loop if P.Index /= 0 then T.Direct_Attributes (P.Index) := --- 185,203 ---- -- Initialize Attributes -- --------------------------- ! -- This is to be called by System.Tasking.Stages.Create_Task. -- It relies on their being no concurrent access to this TCB, ! -- so it does not defer abortion nor lock T.L. procedure Initialize_Attributes (T : Task_ID) is P : Access_Instance; begin ! Lock_RTS; -- Initialize all the direct-access attributes of this task. P := All_Attributes; + while P /= null loop if P.Index /= 0 then T.Direct_Attributes (P.Index) := *************** package body System.Tasking.Task_Attribu *** 215,221 **** P := P.Next; end loop; ! Unlock (All_Attrs_L'Access); exception when others => null; --- 207,213 ---- P := P.Next; end loop; ! Unlock_RTS; exception when others => null; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tataat.ads gcc-3.3/gcc/ada/s-tataat.ads *** gcc-3.2.3/gcc/ada/s-tataat.ads 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tataat.ads 2002-03-14 11:00:00.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1995-2000 Florida State University -- -- -- -- GNARL 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1995-2002 Florida State University -- -- -- -- GNARL 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- -- *************** *** 29,36 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** package System.Tasking.Task_Attributes i *** 50,57 **** --- 48,61 ---- type Node; type Access_Node is access all Node; + -- This needs comments ??? + type Dummy_Wrapper; type Access_Dummy_Wrapper is access all Dummy_Wrapper; + for Access_Dummy_Wrapper'Storage_Size use 0; + -- This is a stand-in for the generic type Wrapper defined in + -- Ada.Task_Attributes. The real objects allocated are always + -- of type Wrapper, no Dummy_Wrapper objects are ever created. type Deallocator is access procedure (P : in out Access_Node); -- Called to deallocate an Wrapper. P is a pointer to a Node within. *************** package System.Tasking.Task_Attributes i *** 98,110 **** -- A linked list of all indirectly access attributes, -- which includes all those that require finalization. - All_Attrs_L : aliased System.Task_Primitives.RTS_Lock; - -- Protects In_Use, Next_Indirect_Index, and All_Attributes. - -- Deadlock prevention order of locking: - -- 1) All_Attrs_L - -- 2) All_Tasks_L - -- 3) any TCB.L - procedure Initialize_Attributes (T : Task_ID); -- Initialize all attributes created via Ada.Task_Attributes for T. -- This must be called by the creator of the task, inside Create_Task, --- 102,107 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tpinop.adb gcc-3.3/gcc/ada/s-tpinop.adb *** gcc-3.2.3/gcc/ada/s-tpinop.adb 2002-05-04 03:28:49.000000000 +0000 --- gcc-3.3/gcc/ada/s-tpinop.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 7,13 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tpinop.ads gcc-3.3/gcc/ada/s-tpinop.ads *** gcc-3.2.3/gcc/ada/s-tpinop.ads 2002-05-04 03:28:50.000000000 +0000 --- gcc-3.3/gcc/ada/s-tpinop.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1998-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tpoben.adb gcc-3.3/gcc/ada/s-tpoben.adb *** gcc-3.2.3/gcc/ada/s-tpoben.adb 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tpoben.adb 2002-03-14 11:00:00.000000000 +0000 *************** *** 1,15 **** ------------------------------------------------------------------------------ -- -- ! -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . -- ! -- E N T R I E S -- -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 1,13 ---- ------------------------------------------------------------------------------ -- -- ! -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASKING.PROTECTED_OBJECTS.ENTRIES -- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 30,37 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** pragma Elaborate_All (System.Tasking.Ini *** 65,76 **** -- this insures that tasking is initialized if any protected objects are -- created. package body System.Tasking.Protected_Objects.Entries is package STPO renames System.Task_Primitives.Operations; use Ada.Exceptions; - use STPO; Locking_Policy : Character; pragma Import (C, Locking_Policy, "__gl_locking_policy"); --- 62,77 ---- -- this insures that tasking is initialized if any protected objects are -- created. + with System.Parameters; + -- used for Single_Lock + package body System.Tasking.Protected_Objects.Entries is package STPO renames System.Task_Primitives.Operations; + use Parameters; + use Task_Primitives.Operations; use Ada.Exceptions; Locking_Policy : Character; pragma Import (C, Locking_Policy, "__gl_locking_policy"); *************** package body System.Tasking.Protected_Ob *** 93,100 **** STPO.Write_Lock (Object.L'Unrestricted_Access, Ceiling_Violation); ! if Ceiling_Violation then -- Dip our own priority down to ceiling of lock. -- See similar code in Tasking.Entry_Calls.Lock_Server. --- 94,104 ---- STPO.Write_Lock (Object.L'Unrestricted_Access, Ceiling_Violation); ! if Single_Lock then ! Lock_RTS; ! end if; + if Ceiling_Violation then -- Dip our own priority down to ceiling of lock. -- See similar code in Tasking.Entry_Calls.Lock_Server. *************** package body System.Tasking.Protected_Ob *** 103,114 **** --- 107,127 ---- Self_ID.New_Base_Priority := Object.Ceiling; Initialization.Change_Base_Priority (Self_ID); STPO.Unlock (Self_ID); + + if Single_Lock then + Unlock_RTS; + end if; + STPO.Write_Lock (Object.L'Unrestricted_Access, Ceiling_Violation); if Ceiling_Violation then Raise_Exception (Program_Error'Identity, "Ceiling Violation"); end if; + if Single_Lock then + Lock_RTS; + end if; + Object.Old_Base_Priority := Old_Base_Priority; Object.Pending_Action := True; end if; *************** package body System.Tasking.Protected_Ob *** 121,136 **** --- 134,157 ---- while Entry_Call /= null loop Caller := Entry_Call.Self; Entry_Call.Exception_To_Raise := Program_Error'Identity; + STPO.Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done); STPO.Unlock (Caller); + exit when Entry_Call = Object.Entry_Queues (E).Tail; Entry_Call := Entry_Call.Next; end loop; end loop; Object.Finalized := True; + + if Single_Lock then + Unlock_RTS; + end if; + STPO.Unlock (Object.L'Unrestricted_Access); + STPO.Finalize_Lock (Object.L'Unrestricted_Access); end Finalize; *************** package body System.Tasking.Protected_Ob *** 142,147 **** --- 163,169 ---- (Object : Protection_Entries_Access) return Boolean is + pragma Warnings (Off, Object); begin return False; end Has_Interrupt_Or_Attach_Handler; *************** package body System.Tasking.Protected_Ob *** 197,202 **** --- 219,229 ---- procedure Lock_Entries (Object : Protection_Entries_Access; Ceiling_Violation : out Boolean) is begin + if Object.Finalized then + Raise_Exception + (Program_Error'Identity, "Protected Object is finalized"); + end if; + -- The lock is made without defering abortion. -- Therefore the abortion has to be deferred before calling this *************** package body System.Tasking.Protected_Ob *** 214,219 **** --- 241,251 ---- procedure Lock_Entries (Object : Protection_Entries_Access) is Ceiling_Violation : Boolean; begin + if Object.Finalized then + Raise_Exception + (Program_Error'Identity, "Protected Object is finalized"); + end if; + pragma Assert (STPO.Self.Deferral_Level > 0); Write_Lock (Object.L'Access, Ceiling_Violation); *************** package body System.Tasking.Protected_Ob *** 229,234 **** --- 261,271 ---- procedure Lock_Read_Only_Entries (Object : Protection_Entries_Access) is Ceiling_Violation : Boolean; begin + if Object.Finalized then + Raise_Exception + (Program_Error'Identity, "Protected Object is finalized"); + end if; + Read_Lock (Object.L'Access, Ceiling_Violation); if Ceiling_Violation then diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tpoben.ads gcc-3.3/gcc/ada/s-tpoben.ads *** gcc-3.2.3/gcc/ada/s-tpoben.ads 2002-05-04 03:28:50.000000000 +0000 --- gcc-3.3/gcc/ada/s-tpoben.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 1,13 **** ------------------------------------------------------------------------------ -- -- ! -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . -- ! -- E N T R I E S -- -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 1,11 ---- ------------------------------------------------------------------------------ -- -- ! -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASKING.PROTECTED_OBJECTS.ENTRIES -- -- -- -- S p e c -- -- -- -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tpobop.adb gcc-3.3/gcc/ada/s-tpobop.adb *** gcc-3.2.3/gcc/ada/s-tpobop.adb 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tpobop.adb 2002-03-14 11:00:01.000000000 +0000 *************** *** 7,15 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-2001, Florida State University -- -- -- -- GNARL 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- -- --- 7,14 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2001, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 30,37 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 29,35 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** with System.Task_Primitives.Operations; *** 63,68 **** --- 61,67 ---- with System.Tasking.Entry_Calls; -- used for Wait_For_Completion -- Wait_Until_Abortable + -- Wait_For_Completion_With_Timeout with System.Tasking.Initialization; -- Used for Defer_Abort, *************** with System.Tasking.Rendezvous; *** 86,100 **** with System.Tasking.Debug; -- used for Trace package body System.Tasking.Protected_Objects.Operations is package STPO renames System.Task_Primitives.Operations; use Task_Primitives; - use Tasking; use Ada.Exceptions; use Entries; ----------------------- -- Local Subprograms -- ----------------------- --- 85,109 ---- with System.Tasking.Debug; -- used for Trace + with System.Parameters; + -- used for Single_Lock + -- Runtime_Traces + + with System.Traces.Tasking; + -- used for Send_Trace_Info + package body System.Tasking.Protected_Objects.Operations is package STPO renames System.Task_Primitives.Operations; + use Parameters; use Task_Primitives; use Ada.Exceptions; use Entries; + use System.Traces; + use System.Traces.Tasking; + ----------------------- -- Local Subprograms -- ----------------------- *************** package body System.Tasking.Protected_Ob *** 183,189 **** -- has been "cancelled". -- Enqueued should be true if there is any chance that the call ! -- is still on a queue. It seems to be safe to make it True if -- the call was Onqueue at some point before return from -- Protected_Entry_Call. --- 192,198 ---- -- has been "cancelled". -- Enqueued should be true if there is any chance that the call ! -- is still on a queue. It seems to be safe to make it True if -- the call was Onqueue at some point before return from -- Protected_Entry_Call. *************** package body System.Tasking.Protected_Ob *** 192,203 **** -- ????? -- The need for Enqueued is less obvious. ! -- The "if enqueued()" tests are not necessary, since both -- Cancel_Protected_Entry_Call and Protected_Entry_Call must ! -- do the same test internally, with locking. The one that -- makes cancellation conditional may be a useful heuristic -- since at least 1/2 the time the call should be off-queue ! -- by that point. The other one seems totally useless, since -- Protected_Entry_Call must do the same check and then -- possibly wait for the call to be abortable, internally. --- 201,212 ---- -- ????? -- The need for Enqueued is less obvious. ! -- The "if enqueued ()" tests are not necessary, since both -- Cancel_Protected_Entry_Call and Protected_Entry_Call must ! -- do the same test internally, with locking. The one that -- makes cancellation conditional may be a useful heuristic -- since at least 1/2 the time the call should be off-queue ! -- by that point. The other one seems totally useless, since -- Protected_Entry_Call must do the same check and then -- possibly wait for the call to be abortable, internally. *************** package body System.Tasking.Protected_Ob *** 206,213 **** -- No other task can access the call record at this point. procedure Cancel_Protected_Entry_Call ! (Block : in out Communication_Block) ! is begin Entry_Calls.Try_To_Cancel_Entry_Call (Block.Cancelled); end Cancel_Protected_Entry_Call; --- 215,221 ---- -- No other task can access the call record at this point. procedure Cancel_Protected_Entry_Call ! (Block : in out Communication_Block) is begin Entry_Calls.Try_To_Cancel_Entry_Call (Block.Cancelled); end Cancel_Protected_Entry_Call; *************** package body System.Tasking.Protected_Ob *** 248,254 **** Ex : Ada.Exceptions.Exception_Id) is Entry_Call : constant Entry_Call_Link := Object.Call_In_Progress; - begin pragma Debug (Debug.Trace (STPO.Self, "Exceptional_Complete_Entry_Body", 'P')); --- 256,261 ---- *************** package body System.Tasking.Protected_Ob *** 257,274 **** -- a protected operation. if Entry_Call /= null then - -- The call was not requeued. Entry_Call.Exception_To_Raise := Ex; ! -- ????? ! -- The caller should do the following, after return from this ! -- procedure, if Call_In_Progress /= null ! -- Write_Lock (Entry_Call.Self); ! -- Initialization.Wakeup_Entry_Caller (STPO.Self, Entry_Call, Done); ! -- Unlock (Entry_Call.Self); end if; end Exceptional_Complete_Entry_Body; --- 264,279 ---- -- a protected operation. if Entry_Call /= null then -- The call was not requeued. Entry_Call.Exception_To_Raise := Ex; ! -- Wakeup_Entry_Caller will be called from PO_Do_Or_Queue or ! -- PO_Service_Entries on return. ! end if; + if Runtime_Traces then + Send_Trace_Info (PO_Done, Entry_Call.Self); end if; end Exceptional_Complete_Entry_Body; *************** package body System.Tasking.Protected_Ob *** 286,291 **** --- 291,297 ---- New_Object : Protection_Entries_Access; Ceiling_Violation : Boolean; Barrier_Value : Boolean; + Result : Boolean; begin -- When the Action procedure for an entry body returns, it is either *************** package body System.Tasking.Protected_Ob *** 318,324 **** --- 324,341 ---- -- Body of current entry served call to completion Object.Call_In_Progress := null; + + if Single_Lock then + STPO.Lock_RTS; + end if; + + STPO.Write_Lock (Entry_Call.Self); Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done); + STPO.Unlock (Entry_Call.Self); + + if Single_Lock then + STPO.Unlock_RTS; + end if; else -- Body of current entry requeued the call *************** package body System.Tasking.Protected_Ob *** 328,340 **** -- Call was requeued to a task ! if not Rendezvous.Task_Do_Or_Queue (Self_ID, Entry_Call, ! With_Abort => Entry_Call.Requeue_With_Abort) ! then Queuing.Broadcast_Program_Error ! (Self_ID, Object, Entry_Call); end if; return; end if; --- 345,367 ---- -- Call was requeued to a task ! if Single_Lock then ! STPO.Lock_RTS; ! end if; ! ! Result := Rendezvous.Task_Do_Or_Queue (Self_ID, Entry_Call, ! With_Abort => Entry_Call.Requeue_With_Abort); ! ! if not Result then Queuing.Broadcast_Program_Error ! (Self_ID, Object, Entry_Call, RTS_Locked => True); ! end if; ! ! if Single_Lock then ! STPO.Unlock_RTS; end if; + return; end if; *************** package body System.Tasking.Protected_Ob *** 392,401 **** --- 419,436 ---- else -- Conditional_Call and With_Abort + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Entry_Call.Self); pragma Assert (Entry_Call.State >= Was_Abortable); Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Cancelled); STPO.Unlock (Entry_Call.Self); + + if Single_Lock then + STPO.Unlock_RTS; + end if; end if; exception *************** package body System.Tasking.Protected_Ob *** 416,421 **** --- 451,457 ---- Caller : Task_ID; New_Object : Protection_Entries_Access; Ceiling_Violation : Boolean; + Result : Boolean; begin loop *************** package body System.Tasking.Protected_Ob *** 433,438 **** --- 469,479 ---- Object.Call_In_Progress := Entry_Call; begin + if Runtime_Traces then + Send_Trace_Info (PO_Run, Self_ID, + Entry_Call.Self, Entry_Index (E)); + end if; + pragma Debug (Debug.Trace (Self_ID, "POSE: start entry body", 'P')); Object.Entry_Bodies ( *************** package body System.Tasking.Protected_Ob *** 447,456 **** --- 488,506 ---- if Object.Call_In_Progress /= null then Object.Call_In_Progress := null; Caller := Entry_Call.Self; + + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done); STPO.Unlock (Caller); + if Single_Lock then + STPO.Unlock_RTS; + end if; + else -- Call needs to be requeued *************** package body System.Tasking.Protected_Ob *** 460,471 **** -- Call is to be requeued to a task entry ! if not Rendezvous.Task_Do_Or_Queue (Self_ID, Entry_Call, ! With_Abort => Entry_Call.Requeue_With_Abort) ! then Queuing.Broadcast_Program_Error ! (Self_ID, Object, Entry_Call); end if; else --- 510,530 ---- -- Call is to be requeued to a task entry ! if Single_Lock then ! STPO.Lock_RTS; ! end if; ! ! Result := Rendezvous.Task_Do_Or_Queue (Self_ID, Entry_Call, ! With_Abort => Entry_Call.Requeue_With_Abort); ! ! if not Result then Queuing.Broadcast_Program_Error ! (Self_ID, Object, Entry_Call, RTS_Locked => True); ! end if; ! ! if Single_Lock then ! STPO.Unlock_RTS; end if; else *************** package body System.Tasking.Protected_Ob *** 569,597 **** -- end if; -- end; ! -- See also Cancel_Protected_Entry_Call for code expansion of ! -- asynchronous entry call. ! -- The initial part of this procedure does not need to lock the ! -- the calling task's ATCB, up to the point where the call record ! -- first may be queued (PO_Do_Or_Queue), since before that no ! -- other task will have access to the record. ! -- If this is a call made inside of an abort deferred region, ! -- the call should be never abortable. ! -- If the call was not queued abortably, we need to wait ! -- until it is before proceeding with the abortable part. ! -- There are some heuristics here, just to save time for ! -- frequently occurring cases. For example, we check ! -- Initially_Abortable to try to avoid calling the procedure ! -- Wait_Until_Abortable, since the normal case for async. ! -- entry calls is to be queued abortably. ! -- Another heuristic uses the Block.Enqueued to try to avoid ! -- calling Cancel_Protected_Entry_Call if the call can be ! -- served immediately. procedure Protected_Entry_Call (Object : Protection_Entries_Access; --- 628,654 ---- -- end if; -- end; ! -- See also Cancel_Protected_Entry_Call for code expansion of asynchronous ! -- entry call. ! -- The initial part of this procedure does not need to lock the the calling ! -- task's ATCB, up to the point where the call record first may be queued ! -- (PO_Do_Or_Queue), since before that no other task will have access to ! -- the record. ! -- If this is a call made inside of an abort deferred region, the call ! -- should be never abortable. ! -- If the call was not queued abortably, we need to wait until it is before ! -- proceeding with the abortable part. ! -- There are some heuristics here, just to save time for frequently ! -- occurring cases. For example, we check Initially_Abortable to try to ! -- avoid calling the procedure Wait_Until_Abortable, since the normal case ! -- for async. entry calls is to be queued abortably. ! -- Another heuristic uses the Block.Enqueued to try to avoid calling ! -- Cancel_Protected_Entry_Call if the call can be served immediately. procedure Protected_Entry_Call (Object : Protection_Entries_Access; *************** package body System.Tasking.Protected_Ob *** 609,617 **** pragma Debug (Debug.Trace (Self_ID, "Protected_Entry_Call", 'P')); if Self_ID.ATC_Nesting_Level = ATC_Level'Last then ! Raise_Exception (Storage_Error'Identity, ! "not enough ATC nesting levels"); end if; Initialization.Defer_Abort (Self_ID); --- 666,678 ---- pragma Debug (Debug.Trace (Self_ID, "Protected_Entry_Call", 'P')); + if Runtime_Traces then + Send_Trace_Info (PO_Call, Entry_Index (E)); + end if; + if Self_ID.ATC_Nesting_Level = ATC_Level'Last then ! Raise_Exception ! (Storage_Error'Identity, "not enough ATC nesting levels"); end if; Initialization.Defer_Abort (Self_ID); *************** package body System.Tasking.Protected_Ob *** 685,700 **** -- Try to avoid an expensive call. if not Initially_Abortable then ! Entry_Calls.Wait_Until_Abortable (Self_ID, Entry_Call); end if; elsif Mode < Asynchronous_Call then -- Simple_Call or Conditional_Call ! STPO.Write_Lock (Self_ID); ! Entry_Calls.Wait_For_Completion (Self_ID, Entry_Call); ! STPO.Unlock (Self_ID); Block.Cancelled := Entry_Call.State = Cancelled; else --- 746,774 ---- -- Try to avoid an expensive call. if not Initially_Abortable then ! if Single_Lock then ! STPO.Lock_RTS; ! Entry_Calls.Wait_Until_Abortable (Self_ID, Entry_Call); ! STPO.Unlock_RTS; ! else ! Entry_Calls.Wait_Until_Abortable (Self_ID, Entry_Call); ! end if; end if; elsif Mode < Asynchronous_Call then -- Simple_Call or Conditional_Call ! if Single_Lock then ! STPO.Lock_RTS; ! Entry_Calls.Wait_For_Completion (Entry_Call); ! STPO.Unlock_RTS; ! else ! STPO.Write_Lock (Self_ID); ! Entry_Calls.Wait_For_Completion (Entry_Call); ! STPO.Unlock (Self_ID); ! end if; ! Block.Cancelled := Entry_Call.State = Cancelled; else *************** package body System.Tasking.Protected_Ob *** 704,718 **** Initialization.Undefer_Abort (Self_ID); Entry_Calls.Check_Exception (Self_ID, Entry_Call); - end Protected_Entry_Call; ---------------------------- -- Protected_Entry_Caller -- ---------------------------- ! function Protected_Entry_Caller (Object : Protection_Entries'Class) ! return Task_ID is begin return Object.Call_In_Progress.Self; end Protected_Entry_Caller; --- 778,791 ---- Initialization.Undefer_Abort (Self_ID); Entry_Calls.Check_Exception (Self_ID, Entry_Call); end Protected_Entry_Call; ---------------------------- -- Protected_Entry_Caller -- ---------------------------- ! function Protected_Entry_Caller ! (Object : Protection_Entries'Class) return Task_ID is begin return Object.Call_In_Progress.Self; end Protected_Entry_Caller; *************** package body System.Tasking.Protected_Ob *** 810,836 **** E : Protected_Entry_Index; With_Abort : Boolean) is ! Self_ID : constant Task_ID := STPO.Self; ! Entry_Call : constant Entry_Call_Link := Self_ID.Common.Call; begin Initialization.Defer_Abort (Self_ID); ! STPO.Write_Lock (Self_ID); Entry_Call.Needs_Requeue := True; Entry_Call.Requeue_With_Abort := With_Abort; Entry_Call.Called_PO := To_Address (New_Object); Entry_Call.Called_Task := null; - STPO.Unlock (Self_ID); Entry_Call.E := Entry_Index (E); Initialization.Undefer_Abort (Self_ID); end Requeue_Task_To_Protected_Entry; - -- ?????? - -- Do we really need to lock Self_ID above? - -- Might the caller be trying to cancel? - -- If so, it should fail, since the call state should not be - -- abortable while the call is in service. - --------------------- -- Service_Entries -- --------------------- --- 883,905 ---- E : Protected_Entry_Index; With_Abort : Boolean) is ! Self_ID : constant Task_ID := STPO.Self; ! Entry_Call : constant Entry_Call_Link := Self_ID.Common.Call; begin Initialization.Defer_Abort (Self_ID); ! ! -- We do not need to lock Self_ID here since the call is not abortable ! -- at this point, and therefore, the caller cannot cancel the call. ! Entry_Call.Needs_Requeue := True; Entry_Call.Requeue_With_Abort := With_Abort; Entry_Call.Called_PO := To_Address (New_Object); Entry_Call.Called_Task := null; Entry_Call.E := Entry_Index (E); Initialization.Undefer_Abort (Self_ID); end Requeue_Task_To_Protected_Entry; --------------------- -- Service_Entries -- --------------------- *************** package body System.Tasking.Protected_Ob *** 855,924 **** Mode : Delay_Modes; Entry_Call_Successful : out Boolean) is ! Self_ID : Task_ID := STPO.Self; Entry_Call : Entry_Call_Link; Ceiling_Violation : Boolean; begin ! if Self_ID.ATC_Nesting_Level = ATC_Level'Last then Raise_Exception (Storage_Error'Identity, "not enough ATC nesting levels"); end if; ! Initialization.Defer_Abort (Self_ID); Lock_Entries (Object, Ceiling_Violation); if Ceiling_Violation then ! Initialization.Undefer_Abort (Self_ID); raise Program_Error; end if; ! Self_ID.ATC_Nesting_Level := Self_ID.ATC_Nesting_Level + 1; pragma Debug ! (Debug.Trace (Self_ID, "TPEC: exited to ATC level: " & ! ATC_Level'Image (Self_ID.ATC_Nesting_Level), 'A')); Entry_Call := ! Self_ID.Entry_Calls (Self_ID.ATC_Nesting_Level)'Access; Entry_Call.Next := null; Entry_Call.Mode := Timed_Call; Entry_Call.Cancellation_Attempted := False; ! if Self_ID.Deferral_Level > 1 then Entry_Call.State := Never_Abortable; else Entry_Call.State := Now_Abortable; end if; Entry_Call.E := Entry_Index (E); ! Entry_Call.Prio := STPO.Get_Priority (Self_ID); Entry_Call.Uninterpreted_Data := Uninterpreted_Data; Entry_Call.Called_PO := To_Address (Object); Entry_Call.Called_Task := null; Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id; ! PO_Do_Or_Queue (Self_ID, Object, Entry_Call, With_Abort => True); ! PO_Service_Entries (Self_ID, Object); Unlock_Entries (Object); -- Try to avoid waiting for completed or cancelled calls. if Entry_Call.State >= Done then ! Self_ID.ATC_Nesting_Level := Self_ID.ATC_Nesting_Level - 1; pragma Debug ! (Debug.Trace (Self_ID, "TPEC: exited to ATC level: " & ! ATC_Level'Image (Self_ID.ATC_Nesting_Level), 'A')); Entry_Call_Successful := Entry_Call.State = Done; ! Initialization.Undefer_Abort (Self_ID); ! Entry_Calls.Check_Exception (Self_ID, Entry_Call); return; end if; Entry_Calls.Wait_For_Completion_With_Timeout ! (Self_ID, Entry_Call, Timeout, Mode); ! Initialization.Undefer_Abort (Self_ID); Entry_Call_Successful := Entry_Call.State = Done; ! Entry_Calls.Check_Exception (Self_ID, Entry_Call); end Timed_Protected_Entry_Call; ---------------------------- --- 924,1013 ---- Mode : Delay_Modes; Entry_Call_Successful : out Boolean) is ! Self_Id : constant Task_ID := STPO.Self; Entry_Call : Entry_Call_Link; Ceiling_Violation : Boolean; + Yielded : Boolean; begin ! if Self_Id.ATC_Nesting_Level = ATC_Level'Last then Raise_Exception (Storage_Error'Identity, "not enough ATC nesting levels"); end if; ! if Runtime_Traces then ! Send_Trace_Info (POT_Call, Entry_Index (E), Timeout); ! end if; ! ! Initialization.Defer_Abort (Self_Id); Lock_Entries (Object, Ceiling_Violation); if Ceiling_Violation then ! Initialization.Undefer_Abort (Self_Id); raise Program_Error; end if; ! Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level + 1; pragma Debug ! (Debug.Trace (Self_Id, "TPEC: exited to ATC level: " & ! ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A')); Entry_Call := ! Self_Id.Entry_Calls (Self_Id.ATC_Nesting_Level)'Access; Entry_Call.Next := null; Entry_Call.Mode := Timed_Call; Entry_Call.Cancellation_Attempted := False; ! if Self_Id.Deferral_Level > 1 then Entry_Call.State := Never_Abortable; else Entry_Call.State := Now_Abortable; end if; Entry_Call.E := Entry_Index (E); ! Entry_Call.Prio := STPO.Get_Priority (Self_Id); Entry_Call.Uninterpreted_Data := Uninterpreted_Data; Entry_Call.Called_PO := To_Address (Object); Entry_Call.Called_Task := null; Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id; ! PO_Do_Or_Queue (Self_Id, Object, Entry_Call, With_Abort => True); ! PO_Service_Entries (Self_Id, Object); Unlock_Entries (Object); -- Try to avoid waiting for completed or cancelled calls. if Entry_Call.State >= Done then ! Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level - 1; pragma Debug ! (Debug.Trace (Self_Id, "TPEC: exited to ATC level: " & ! ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A')); Entry_Call_Successful := Entry_Call.State = Done; ! Initialization.Undefer_Abort (Self_Id); ! Entry_Calls.Check_Exception (Self_Id, Entry_Call); return; end if; + if Single_Lock then + STPO.Lock_RTS; + else + STPO.Write_Lock (Self_Id); + end if; + Entry_Calls.Wait_For_Completion_With_Timeout ! (Entry_Call, Timeout, Mode, Yielded); ! ! if Single_Lock then ! STPO.Unlock_RTS; ! else ! STPO.Unlock (Self_Id); ! end if; ! ! -- ??? Do we need to yield in case Yielded is False ! ! Initialization.Undefer_Abort (Self_Id); Entry_Call_Successful := Entry_Call.State = Done; ! Entry_Calls.Check_Exception (Self_Id, Entry_Call); end Timed_Protected_Entry_Call; ---------------------------- *************** package body System.Tasking.Protected_Ob *** 953,959 **** With_Abort : Boolean) is Old : Entry_Call_State := Entry_Call.State; - begin pragma Assert (Old < Done); --- 1042,1047 ---- *************** package body System.Tasking.Protected_Ob *** 963,968 **** --- 1051,1060 ---- if Old < Was_Abortable and then Entry_Call.State = Now_Abortable then + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Entry_Call.Self); if Entry_Call.Self.Common.State = Async_Select_Sleep then *************** package body System.Tasking.Protected_Ob *** 970,975 **** --- 1062,1072 ---- end if; STPO.Unlock (Entry_Call.Self); + + if Single_Lock then + STPO.Unlock_RTS; + end if; + end if; elsif Entry_Call.Mode = Conditional_Call then diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tpobop.ads gcc-3.3/gcc/ada/s-tpobop.ads *** gcc-3.2.3/gcc/ada/s-tpobop.ads 2002-05-04 03:28:50.000000000 +0000 --- gcc-3.3/gcc/ada/s-tpobop.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 7,13 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 7,12 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tposen.adb gcc-3.3/gcc/ada/s-tposen.adb *** gcc-3.2.3/gcc/ada/s-tposen.adb 2001-12-18 00:03:37.000000000 +0000 --- gcc-3.3/gcc/ada/s-tposen.adb 2002-03-14 11:00:01.000000000 +0000 *************** *** 1,15 **** ------------------------------------------------------------------------------ -- -- ! -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . -- ! -- S I N G L E _ E N T R Y -- -- -- -- B o d y -- -- -- - -- $Revision: 1.2 $ -- -- ! -- Copyright (C) 1998-2001 Ada Core Technologies -- -- -- -- GNARL 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- -- --- 1,13 ---- ------------------------------------------------------------------------------ -- -- ! -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASKING.PROTECTED_OBJECTS.SINGLE_ENTRY -- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2002, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- *************** *** 30,37 **** -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies Inc. in cooperation with Florida -- ! -- State University (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. It is -- ! -- now maintained by Ada Core Technologies, Inc. (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ *************** with System.Task_Primitives.Operations; *** 73,86 **** with Ada.Exceptions; -- used for Exception_Id; ! with Unchecked_Conversion; package body System.Tasking.Protected_Objects.Single_Entry is package STPO renames System.Task_Primitives.Operations; ! function To_Address is new ! Unchecked_Conversion (Protection_Entry_Access, System.Address); ----------------------- -- Local Subprograms -- --- 70,83 ---- with Ada.Exceptions; -- used for Exception_Id; ! with System.Parameters; ! -- used for Single_Lock package body System.Tasking.Protected_Objects.Single_Entry is package STPO renames System.Task_Primitives.Operations; ! use Parameters; ----------------------- -- Local Subprograms -- *************** package body System.Tasking.Protected_Ob *** 110,118 **** -- The caller is waiting on Entry_Caller_Sleep, in -- Wait_For_Completion, or Wait_For_Completion_With_Timeout. ! procedure Wait_For_Completion ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link); pragma Inline (Wait_For_Completion); -- This procedure suspends the calling task until the specified entry call -- has either been completed or cancelled. On exit, the call will not be --- 107,113 ---- -- The caller is waiting on Entry_Caller_Sleep, in -- Wait_For_Completion, or Wait_For_Completion_With_Timeout. ! procedure Wait_For_Completion (Entry_Call : Entry_Call_Link); pragma Inline (Wait_For_Completion); -- This procedure suspends the calling task until the specified entry call -- has either been completed or cancelled. On exit, the call will not be *************** package body System.Tasking.Protected_Ob *** 120,132 **** -- Call this only when holding Self_ID locked. procedure Wait_For_Completion_With_Timeout ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link; Wakeup_Time : Duration; Mode : Delay_Modes); -- Same as Wait_For_Completion but it waits for a timeout with the value -- specified in Wakeup_Time as well. - -- Self_ID will be locked by this procedure. procedure Check_Exception (Self_ID : Task_ID; --- 115,125 ---- -- Call this only when holding Self_ID locked. procedure Wait_For_Completion_With_Timeout ! (Entry_Call : Entry_Call_Link; Wakeup_Time : Duration; Mode : Delay_Modes); -- Same as Wait_For_Completion but it waits for a timeout with the value -- specified in Wakeup_Time as well. procedure Check_Exception (Self_ID : Task_ID; *************** package body System.Tasking.Protected_Ob *** 153,158 **** --- 146,153 ---- (Self_ID : Task_ID; Entry_Call : Entry_Call_Link) is + pragma Warnings (Off, Self_ID); + procedure Internal_Raise (X : Ada.Exceptions.Exception_Id); pragma Import (C, Internal_Raise, "__gnat_raise_with_msg"); *************** package body System.Tasking.Protected_Ob *** 178,249 **** Caller : constant Task_ID := Entry_Call.Self; begin Entry_Call.Exception_To_Raise := Program_Error'Identity; STPO.Write_Lock (Caller); Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); end Send_Program_Error; ------------------------- -- Wait_For_Completion -- ------------------------- ! -- Call this only when holding Self_ID locked ! ! procedure Wait_For_Completion ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link) is begin ! pragma Assert (Self_ID = Entry_Call.Self); ! Self_ID.Common.State := Entry_Caller_Sleep; ! ! STPO.Sleep (Self_ID, Entry_Caller_Sleep); ! ! Self_ID.Common.State := Runnable; end Wait_For_Completion; -------------------------------------- -- Wait_For_Completion_With_Timeout -- -------------------------------------- - -- This routine will lock Self_ID. - - -- This procedure waits for the entry call to - -- be served, with a timeout. It tries to cancel the - -- call if the timeout expires before the call is served. - - -- If we wake up from the timed sleep operation here, - -- it may be for the following possible reasons: - - -- 1) The entry call is done being served. - -- 2) The timeout has expired (Timedout = True) - - -- Once the timeout has expired we may need to continue to wait if - -- the call is already being serviced. In that case, we want to go - -- back to sleep, but without any timeout. The variable Timedout is - -- used to control this. If the Timedout flag is set, we do not need - -- to Sleep with a timeout. We just sleep until we get a wakeup for - -- some status change. - procedure Wait_For_Completion_With_Timeout ! (Self_ID : Task_ID; ! Entry_Call : Entry_Call_Link; Wakeup_Time : Duration; Mode : Delay_Modes) is Timedout : Boolean; Yielded : Boolean; use type Ada.Exceptions.Exception_Id; begin ! STPO.Write_Lock (Self_ID); - pragma Assert (Entry_Call.Self = Self_ID); pragma Assert (Entry_Call.Mode = Timed_Call); ! Self_ID.Common.State := Entry_Caller_Sleep; STPO.Timed_Sleep ! (Self_ID, Wakeup_Time, Mode, Entry_Caller_Sleep, Timedout, Yielded); if Timedout then Entry_Call.State := Cancelled; --- 173,242 ---- Caller : constant Task_ID := Entry_Call.Self; begin Entry_Call.Exception_To_Raise := Program_Error'Identity; + + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Caller); Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); + + if Single_Lock then + STPO.Unlock_RTS; + end if; end Send_Program_Error; ------------------------- -- Wait_For_Completion -- ------------------------- ! procedure Wait_For_Completion (Entry_Call : Entry_Call_Link) is ! Self_Id : constant Task_ID := Entry_Call.Self; begin ! Self_Id.Common.State := Entry_Caller_Sleep; ! STPO.Sleep (Self_Id, Entry_Caller_Sleep); ! Self_Id.Common.State := Runnable; end Wait_For_Completion; -------------------------------------- -- Wait_For_Completion_With_Timeout -- -------------------------------------- procedure Wait_For_Completion_With_Timeout ! (Entry_Call : Entry_Call_Link; Wakeup_Time : Duration; Mode : Delay_Modes) is + Self_Id : constant Task_ID := Entry_Call.Self; Timedout : Boolean; Yielded : Boolean; use type Ada.Exceptions.Exception_Id; begin ! -- This procedure waits for the entry call to be served, with a timeout. ! -- It tries to cancel the call if the timeout expires before the call is ! -- served. ! ! -- If we wake up from the timed sleep operation here, it may be for the ! -- following possible reasons: ! ! -- 1) The entry call is done being served. ! -- 2) The timeout has expired (Timedout = True) ! ! -- Once the timeout has expired we may need to continue to wait if the ! -- call is already being serviced. In that case, we want to go back to ! -- sleep, but without any timeout. The variable Timedout is used to ! -- control this. If the Timedout flag is set, we do not need to Sleep ! -- with a timeout. We just sleep until we get a wakeup for some status ! -- change. pragma Assert (Entry_Call.Mode = Timed_Call); ! Self_Id.Common.State := Entry_Caller_Sleep; STPO.Timed_Sleep ! (Self_Id, Wakeup_Time, Mode, Entry_Caller_Sleep, Timedout, Yielded); if Timedout then Entry_Call.State := Cancelled; *************** package body System.Tasking.Protected_Ob *** 251,258 **** Entry_Call.State := Done; end if; ! Self_ID.Common.State := Runnable; ! STPO.Unlock (Self_ID); end Wait_For_Completion_With_Timeout; ------------------------- --- 244,250 ---- Entry_Call.State := Done; end if; ! Self_Id.Common.State := Runnable; end Wait_For_Completion_With_Timeout; ------------------------- *************** package body System.Tasking.Protected_Ob *** 280,286 **** --- 272,281 ---- Entry_Call : Entry_Call_Link; New_State : Entry_Call_State) is + pragma Warnings (Off, Self_ID); + Caller : constant Task_ID := Entry_Call.Self; + begin pragma Assert (New_State = Done or else New_State = Cancelled); pragma Assert *************** package body System.Tasking.Protected_Ob *** 300,309 **** -------------------------------- procedure Complete_Single_Entry_Body (Object : Protection_Entry_Access) is begin ! -- Nothing needs to be done since ! -- Object.Call_In_Progress.Exception_To_Raise has already been set to ! -- Null_Id null; end Complete_Single_Entry_Body; --- 295,306 ---- -------------------------------- procedure Complete_Single_Entry_Body (Object : Protection_Entry_Access) is + pragma Warnings (Off, Object); + begin ! -- Nothing needs to do (Object.Call_In_Progress.Exception_To_Raise ! -- has already been set to Null_Id). ! null; end Complete_Single_Entry_Body; *************** package body System.Tasking.Protected_Ob *** 328,335 **** Compiler_Info : System.Address; Entry_Body : Entry_Body_Access) is ! Init_Priority : Integer := Ceiling_Priority; ! begin if Init_Priority = Unspecified_Priority then Init_Priority := System.Priority'Last; --- 325,331 ---- Compiler_Info : System.Address; Entry_Body : Entry_Body_Access) is ! Init_Priority : Integer := Ceiling_Priority; begin if Init_Priority = Unspecified_Priority then Init_Priority := System.Priority'Last; *************** package body System.Tasking.Protected_Ob *** 406,421 **** --- 402,436 ---- Object.Entry_Body.Action (Object.Compiler_Info, Entry_Call.Uninterpreted_Data, 1); Object.Call_In_Progress := null; + + if Single_Lock then + STPO.Lock_RTS; + end if; + + STPO.Write_Lock (Entry_Call.Self); Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); + STPO.Unlock (Entry_Call.Self); + + if Single_Lock then + STPO.Unlock_RTS; + end if; elsif Entry_Call.Mode /= Conditional_Call then Object.Entry_Queue := Entry_Call; else -- Conditional_Call + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Entry_Call.Self); Wakeup_Entry_Caller (Self_Id, Entry_Call, Cancelled); STPO.Unlock (Entry_Call.Self); + + if Single_Lock then + STPO.Unlock_RTS; + end if; end if; exception *************** package body System.Tasking.Protected_Ob *** 471,479 **** pragma Assert (Entry_Call.State /= Cancelled); if Entry_Call.State /= Done then STPO.Write_Lock (Self_Id); ! Wait_For_Completion (Self_Id, Entry_Call'Access); STPO.Unlock (Self_Id); end if; Check_Exception (Self_Id, Entry_Call'Access); --- 486,502 ---- pragma Assert (Entry_Call.State /= Cancelled); if Entry_Call.State /= Done then + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Self_Id); ! Wait_For_Completion (Entry_Call'Access); STPO.Unlock (Self_Id); + + if Single_Lock then + STPO.Unlock_RTS; + end if; end if; Check_Exception (Self_Id, Entry_Call'Access); *************** package body System.Tasking.Protected_Ob *** 517,525 **** --- 540,557 ---- (Object.Compiler_Info, Entry_Call.Uninterpreted_Data, 1); Object.Call_In_Progress := null; Caller := Entry_Call.Self; + + if Single_Lock then + STPO.Lock_RTS; + end if; + STPO.Write_Lock (Caller); Wakeup_Entry_Caller (Self_Id, Entry_Call, Done); STPO.Unlock (Caller); + + if Single_Lock then + STPO.Unlock_RTS; + end if; end if; end if; *************** package body System.Tasking.Protected_Ob *** 572,579 **** return; end if; ! Wait_For_Completion_With_Timeout ! (Self_Id, Entry_Call'Access, Timeout, Mode); pragma Assert (Entry_Call.State >= Done); --- 604,622 ---- return; end if; ! if Single_Lock then ! STPO.Lock_RTS; ! else ! STPO.Write_Lock (Self_Id); ! end if; ! ! Wait_For_Completion_With_Timeout (Entry_Call'Access, Timeout, Mode); ! ! if Single_Lock then ! STPO.Unlock_RTS; ! else ! STPO.Unlock (Self_Id); ! end if; pragma Assert (Entry_Call.State >= Done); diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tposen.ads gcc-3.3/gcc/ada/s-tposen.ads *** gcc-3.2.3/gcc/ada/s-tposen.ads 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-tposen.ads 2002-03-14 11:00:01.000000000 +0000 *************** *** 1,15 **** ------------------------------------------------------------------------------ -- -- ! -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . -- ! -- S I N G L E _ E N T R Y -- -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1991-1999 Florida State University -- -- -- -- GNARL 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- -- --- 1,13 ---- ------------------------------------------------------------------------------ -- -- ! -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- ! -- SYSTEM.TASKING.PROTECTED_OBJECTS.SINGLE_ENTRY -- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1991-2001 Florida State University -- -- -- -- GNARL 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- -- *************** package System.Tasking.Protected_Objects *** 264,270 **** procedure Exceptional_Complete_Single_Entry_Body (Object : Protection_Entry_Access; Ex : Ada.Exceptions.Exception_Id); ! -- Perform all of the functions of Complete_Entry_Body. In addition, -- report in Ex the exception whose propagation terminated the entry -- body to the runtime system. --- 262,268 ---- procedure Exceptional_Complete_Single_Entry_Body (Object : Protection_Entry_Access; Ex : Ada.Exceptions.Exception_Id); ! -- Perform all of the functions of Complete_Entry_Body. In addition, -- report in Ex the exception whose propagation terminated the entry -- body to the runtime system. diff -Nrc3pad gcc-3.2.3/gcc/ada/s-traceb.adb gcc-3.3/gcc/ada/s-traceb.adb *** gcc-3.2.3/gcc/ada/s-traceb.adb 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-traceb.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1999-2001 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- -- *************** *** 29,35 **** -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- ! -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- ! -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ diff -Nrc3pad gcc-3.2.3/gcc/ada/s-traceb.ads gcc-3.3/gcc/ada/s-traceb.ads *** gcc-3.2.3/gcc/ada/s-traceb.ads 2001-10-02 14:30:18.000000000 +0000 --- gcc-3.3/gcc/ada/s-traceb.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1 $ -- -- ! -- Copyright (C) 1999-2001 Ada Core Technologies, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1999-2001 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- -- *************** *** 29,35 **** -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- ! -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ --- 28,34 ---- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- ! -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ diff -Nrc3pad gcc-3.2.3/gcc/ada/s-traces.adb gcc-3.3/gcc/ada/s-traces.adb *** gcc-3.2.3/gcc/ada/s-traces.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/s-traces.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,57 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- + -- -- + -- S Y S T E M . T R A C E S -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001 Free Software Foundation, Inc. -- + -- -- + -- GNARL 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- -- + -- sion. GNARL 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 GNARL; see file COPYING. If not, write -- + -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + package body System.Traces is + + pragma Warnings (Off); -- kill warnings on unreferenced formals + + --------------------- + -- Send_Trace_Info -- + --------------------- + + procedure Send_Trace_Info (Id : Trace_T) is + begin + null; + end Send_Trace_Info; + + --------------------- + -- Send_Trace_Info -- + --------------------- + + procedure Send_Trace_Info (Id : Trace_T; Timeout : Duration) is + begin + null; + end Send_Trace_Info; + + end System.Traces; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-traces.ads gcc-3.3/gcc/ada/s-traces.ads *** gcc-3.2.3/gcc/ada/s-traces.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/s-traces.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,116 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- + -- -- + -- S Y S T E M . T R A C E S -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 Free Software Foundation, Inc. -- + -- -- + -- GNARL 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- -- + -- sion. GNARL 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 GNARL; see file COPYING. If not, write -- + -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package implements functions for traces when tasking is not involved + + -- Warning : NO dependencies to tasking should be created here + + -- This package, and all its children are used to implement debug + -- informations + + -- A new primitive, Send_Trace_Info (Id : Trace_T; 'data') is introduced. + -- Trace_T is an event identifier, 'data' are the informations to pass + -- with the event. Thid procedure is used from within the Runtime to send + -- debug informations. + + -- This primitive is overloaded in System.Traces.Tasking and this package. + + -- Send_Trace_Info calls Send_Trace, in System.Traces.Send, which is trarget + -- dependent, to send the debug informations to a debugger, stream .. + + -- To add a new event, just add them to the Trace_T type, and write the + -- corresponding Send_Trace_Info procedure. It may be required for some + -- target to modify Send_Trace (eg. VxWorks). + + -- To add a new target, just adapt System.Traces.Send to your own purpose. + + package System.Traces is + + type Trace_T is + ( + -- Events handled. + + -- Messages + -- + M_Accept_Complete, + M_Select_Else, + M_RDV_Complete, + M_Call_Complete, + M_Delay, + + -- Errors + -- + E_Missed, + E_Timeout, + E_Kill, + + -- Waiting events + -- + W_Call, + W_Accept, + W_Select, + W_Completion, + W_Delay, + WU_Delay, + + WT_Call, + WT_Select, + WT_Completion, + + -- Protected objects events + -- + PO_Call, + POT_Call, + PO_Run, + PO_Lock, + PO_Unlock, + PO_Done, + + -- Task handling events + -- + T_Create, + T_Activate, + T_Abort, + T_Terminate); + + -- Send_Trace_Info procedures + + -- They are overloaded, depending on the parameters passed with + -- the event, e.g. Time information, Task name, Accept name ... + + procedure Send_Trace_Info (Id : Trace_T); + + procedure Send_Trace_Info (Id : Trace_T; Timeout : Duration); + + end System.Traces; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tratas.adb gcc-3.3/gcc/ada/s-tratas.adb *** gcc-3.2.3/gcc/ada/s-tratas.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/s-tratas.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,122 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- + -- -- + -- S Y S T E M . T R A C E S . T A S K I N G -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001 Free Software Foundation, Inc. -- + -- -- + -- GNARL 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- -- + -- sion. GNARL 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 GNARL; see file COPYING. If not, write -- + -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + package body System.Traces.Tasking is + + pragma Warnings (Off); -- kill warnings on unreferenced formals + + --------------------- + -- Send_Trace_Info -- + --------------------- + + procedure Send_Trace_Info (Id : Trace_T; Task_Name2 : ST.Task_ID) is + begin + null; + end Send_Trace_Info; + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name2 : ST.Task_ID; + Entry_Number : ST.Entry_Index) + is + begin + null; + end Send_Trace_Info; + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name : ST.Task_ID; + Task_Name2 : ST.Task_ID; + Entry_Number : ST.Entry_Index) + is + begin + null; + end Send_Trace_Info; + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name : ST.Task_ID; + Task_Name2 : ST.Task_ID) + is + begin + null; + end Send_Trace_Info; + + procedure Send_Trace_Info + (Id : Trace_T; + Entry_Number : ST.Entry_Index) + is + begin + null; + end Send_Trace_Info; + + procedure Send_Trace_Info + (Id : Trace_T; + Acceptor : ST.Task_ID; + Entry_Number : ST.Entry_Index; + Timeout : Duration) + is + begin + null; + end Send_Trace_Info; + + procedure Send_Trace_Info + (Id : Trace_T; + Entry_Number : ST.Entry_Index; + Timeout : Duration) + is + begin + null; + end Send_Trace_Info; + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name : ST.Task_ID; + Number : Integer) + is + begin + null; + end Send_Trace_Info; + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name : ST.Task_ID; + Number : Integer; + Timeout : Duration) + is + begin + null; + end Send_Trace_Info; + + end System.Traces.Tasking; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-tratas.ads gcc-3.3/gcc/ada/s-tratas.ads *** gcc-3.2.3/gcc/ada/s-tratas.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/s-tratas.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,97 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS -- + -- -- + -- S Y S T E M . T R A C E S . T A S K I N G -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 Free Software Foundation, Inc. -- + -- -- + -- GNARL 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- -- + -- sion. GNARL 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 GNARL; see file COPYING. If not, write -- + -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- 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. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package provides all procedures used to implement debug traces + -- in the case tasking is involved. + + -- See System.Traces for an overview of the various files involved in Tracing + + -- If tasking is not involved, refer to System.Traces.General + + with System.Tasking; + + package System.Traces.Tasking is + + package ST renames System.Tasking; + + -- Send_Trace_Info procedures + + -- They are overloaded, depending on the parameters passed with the event + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name2 : ST.Task_ID); + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name2 : ST.Task_ID; + Entry_Number : ST.Entry_Index); + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name : ST.Task_ID; + Task_Name2 : ST.Task_ID; + Entry_Number : ST.Entry_Index); + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name : ST.Task_ID; + Task_Name2 : ST.Task_ID); + + procedure Send_Trace_Info + (Id : Trace_T; + Entry_Number : ST.Entry_Index); + + procedure Send_Trace_Info + (Id : Trace_T; + Acceptor : ST.Task_ID; + Entry_Number : ST.Entry_Index; + Timeout : Duration); + + procedure Send_Trace_Info + (Id : Trace_T; + Entry_Number : ST.Entry_Index; + Timeout : Duration); + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name : ST.Task_ID; + Number : Integer); + + procedure Send_Trace_Info + (Id : Trace_T; + Task_Name : ST.Task_ID; + Number : Integer; + Timeout : Duration); + end System.Traces.Tasking; diff -Nrc3pad gcc-3.2.3/gcc/ada/stringt.adb gcc-3.3/gcc/ada/stringt.adb *** gcc-3.2.3/gcc/ada/stringt.adb 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/stringt.adb 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Stringt is *** 80,85 **** --- 79,85 ---- procedure Add_String_To_Name_Buffer (S : String_Id) is Len : constant Natural := Natural (String_Length (S)); + begin for J in 1 .. Len loop Name_Buffer (Name_Len + J) := diff -Nrc3pad gcc-3.2.3/gcc/ada/stringt.ads gcc-3.3/gcc/ada/stringt.ads *** gcc-3.2.3/gcc/ada/stringt.ads 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/stringt.ads 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Stringt is *** 108,117 **** -- Determines if two string literals represent the same string procedure String_To_Name_Buffer (S : String_Id); ! -- Place characters of given string in Name_Buffer, setting Name_Len procedure Add_String_To_Name_Buffer (S : String_Id); ! -- Append characters of given string to Name_Buffer, updating Name_Len function String_Chars_Address return System.Address; -- Return address of String_Chars table (used by Back_End call to Gigi) --- 107,120 ---- -- Determines if two string literals represent the same string procedure String_To_Name_Buffer (S : String_Id); ! -- Place characters of given string in Name_Buffer, setting Name_Len. ! -- Error if any characters are out of Character range. Does not attempt ! -- to do any encoding of any characters. procedure Add_String_To_Name_Buffer (S : String_Id); ! -- Append characters of given string to Name_Buffer, updating Name_Len. ! -- Error if any characters are out of Character range. Does not attempt ! -- to do any encoding of any characters. function String_Chars_Address return System.Address; -- Return address of String_Chars table (used by Back_End call to Gigi) *************** package Stringt is *** 140,157 **** -- the code is output as ["hh"] where hh is the two digit hex value for -- the code. Codes greater than 16#FF# are output as ["hhhh"] where hhhh -- is the four digit hex representation of the code value (high order ! -- byte first). Hex letters are always in upper case. procedure Write_String_Table_Entry (Id : String_Id); -- Writes a string value with enclosing quotes to the current file using -- routines in package Output. Does not write an end of line character. -- This procedure is used for debug output purposes, and also for output -- of strings specified by pragma Linker Option to the ali file. 7-bit ! -- ASCII graphics (except for double quote and left brace) are output ! -- literally. The double quote appears as two successive double quotes. -- All other codes, are output as described for Write_Char_Code. For -- example, the string created by folding "A" & ASCII.LF & "Hello" will ! -- print as "A{0A}Hello". A No_String value prints simply as "no string" -- without surrounding quote marks. private --- 143,160 ---- -- the code is output as ["hh"] where hh is the two digit hex value for -- the code. Codes greater than 16#FF# are output as ["hhhh"] where hhhh -- is the four digit hex representation of the code value (high order ! -- byte first). Hex letters are always in lower case. procedure Write_String_Table_Entry (Id : String_Id); -- Writes a string value with enclosing quotes to the current file using -- routines in package Output. Does not write an end of line character. -- This procedure is used for debug output purposes, and also for output -- of strings specified by pragma Linker Option to the ali file. 7-bit ! -- ASCII graphics (except for double quote) are output literally. ! -- The double quote appears as two successive double quotes. -- All other codes, are output as described for Write_Char_Code. For -- example, the string created by folding "A" & ASCII.LF & "Hello" will ! -- print as "A["0a"]Hello". A No_String value prints simply as "no string" -- without surrounding quote marks. private diff -Nrc3pad gcc-3.2.3/gcc/ada/stringt.h gcc-3.3/gcc/ada/stringt.h *** gcc-3.2.3/gcc/ada/stringt.h 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/stringt.h 2002-10-23 07:33:33.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- *************** struct String_Entry *** 56,64 **** }; /* Pointer to string entry vector. This pointer is passed to the tree ! transformer and stored in a global location for access from here after ! subtracting String_First_Entry, so that String_Id values can be used as ! subscripts into the vector. */ extern struct String_Entry *Strings_Ptr; /* Pointer to name characters table. This pointer is passed to the tree --- 55,61 ---- }; /* Pointer to string entry vector. This pointer is passed to the tree ! transformer and stored in a global location. */ extern struct String_Entry *Strings_Ptr; /* Pointer to name characters table. This pointer is passed to the tree *************** INLINE Int *** 74,80 **** String_Length (Id) String_Id Id; { ! return Strings_Ptr [Id].Length; } --- 71,77 ---- String_Length (Id) String_Id Id; { ! return Strings_Ptr[Id - First_String_Id].Length; } *************** Get_String_Char (Id, Index) *** 88,92 **** String_Id Id; Int Index; { ! return String_Chars_Ptr [Strings_Ptr [Id].String_Index + Index - 1]; } --- 85,91 ---- String_Id Id; Int Index; { ! return ! String_Chars_Ptr ! [Strings_Ptr[Id - First_String_Id].String_Index + Index - 1]; } diff -Nrc3pad gcc-3.2.3/gcc/ada/style.adb gcc-3.3/gcc/ada/style.adb *** gcc-3.2.3/gcc/ada/style.adb 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/style.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Style is *** 136,141 **** --- 135,142 ---- -- lower case, except after an underline character. procedure Check_Attribute_Name (Reserved : Boolean) is + pragma Warnings (Off, Reserved); + begin if Style_Check_Attribute_Casing then if Determine_Token_Casing /= Mixed_Case then diff -Nrc3pad gcc-3.2.3/gcc/ada/style.ads gcc-3.3/gcc/ada/style.ads *** gcc-3.2.3/gcc/ada/style.ads 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/style.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/stylesw.adb gcc-3.3/gcc/ada/stylesw.adb *** gcc-3.2.3/gcc/ada/stylesw.adb 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/stylesw.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/stylesw.ads gcc-3.3/gcc/ada/stylesw.ads *** gcc-3.2.3/gcc/ada/stylesw.ads 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/stylesw.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-unstyp.ads gcc-3.3/gcc/ada/s-unstyp.ads *** gcc-3.2.3/gcc/ada/s-unstyp.ads 2002-05-04 03:28:50.000000000 +0000 --- gcc-3.3/gcc/ada/s-unstyp.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 37,43 **** -- correspond in size to the standard signed types declared in Standard. -- and (unlike the types in Interfaces have corresponding names). It -- also contains some related definitions for other specialized types ! -- used only by the expander. package System.Unsigned_Types is pragma Pure (Unsigned_Types); --- 36,42 ---- -- correspond in size to the standard signed types declared in Standard. -- and (unlike the types in Interfaces have corresponding names). It -- also contains some related definitions for other specialized types ! -- used by the compiler in connection with packed array types. package System.Unsigned_Types is pragma Pure (Unsigned_Types); diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vaflop.adb gcc-3.3/gcc/ada/s-vaflop.adb *** gcc-3.2.3/gcc/ada/s-vaflop.adb 2002-05-04 03:28:50.000000000 +0000 --- gcc-3.3/gcc/ada/s-vaflop.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vaflop.ads gcc-3.3/gcc/ada/s-vaflop.ads *** gcc-3.2.3/gcc/ada/s-vaflop.ads 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-vaflop.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.2 $ -- -- -- Copyright (C) 1997-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valboo.adb gcc-3.3/gcc/ada/s-valboo.adb *** gcc-3.2.3/gcc/ada/s-valboo.adb 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-valboo.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valboo.ads gcc-3.3/gcc/ada/s-valboo.ads *** gcc-3.2.3/gcc/ada/s-valboo.ads 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-valboo.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valcha.adb gcc-3.3/gcc/ada/s-valcha.adb *** gcc-3.2.3/gcc/ada/s-valcha.adb 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-valcha.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valcha.ads gcc-3.3/gcc/ada/s-valcha.ads *** gcc-3.2.3/gcc/ada/s-valcha.ads 2002-05-04 03:28:50.000000000 +0000 --- gcc-3.3/gcc/ada/s-valcha.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valdec.adb gcc-3.3/gcc/ada/s-valdec.adb *** gcc-3.2.3/gcc/ada/s-valdec.adb 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-valdec.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valdec.ads gcc-3.3/gcc/ada/s-valdec.ads *** gcc-3.2.3/gcc/ada/s-valdec.ads 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-valdec.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valenu.adb gcc-3.3/gcc/ada/s-valenu.adb *** gcc-3.2.3/gcc/ada/s-valenu.adb 2002-05-04 03:28:50.000000000 +0000 --- gcc-3.3/gcc/ada/s-valenu.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valenu.ads gcc-3.3/gcc/ada/s-valenu.ads *** gcc-3.2.3/gcc/ada/s-valenu.ads 2002-05-04 03:28:50.000000000 +0000 --- gcc-3.3/gcc/ada/s-valenu.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valint.adb gcc-3.3/gcc/ada/s-valint.adb *** gcc-3.2.3/gcc/ada/s-valint.adb 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-valint.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valint.ads gcc-3.3/gcc/ada/s-valint.ads *** gcc-3.2.3/gcc/ada/s-valint.ads 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-valint.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vallld.adb gcc-3.3/gcc/ada/s-vallld.adb *** gcc-3.2.3/gcc/ada/s-vallld.adb 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-vallld.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vallld.ads gcc-3.3/gcc/ada/s-vallld.ads *** gcc-3.2.3/gcc/ada/s-vallld.ads 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-vallld.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vallli.adb gcc-3.3/gcc/ada/s-vallli.adb *** gcc-3.2.3/gcc/ada/s-vallli.adb 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-vallli.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vallli.ads gcc-3.3/gcc/ada/s-vallli.ads *** gcc-3.2.3/gcc/ada/s-vallli.ads 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-vallli.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valllu.adb gcc-3.3/gcc/ada/s-valllu.adb *** gcc-3.2.3/gcc/ada/s-valllu.adb 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-valllu.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valllu.ads gcc-3.3/gcc/ada/s-valllu.ads *** gcc-3.2.3/gcc/ada/s-valllu.ads 2002-05-07 08:22:29.000000000 +0000 --- gcc-3.3/gcc/ada/s-valllu.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valrea.adb gcc-3.3/gcc/ada/s-valrea.adb *** gcc-3.2.3/gcc/ada/s-valrea.adb 2002-05-04 03:28:50.000000000 +0000 --- gcc-3.3/gcc/ada/s-valrea.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valrea.ads gcc-3.3/gcc/ada/s-valrea.ads *** gcc-3.2.3/gcc/ada/s-valrea.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-valrea.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valuns.adb gcc-3.3/gcc/ada/s-valuns.adb *** gcc-3.2.3/gcc/ada/s-valuns.adb 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-valuns.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valuns.ads gcc-3.3/gcc/ada/s-valuns.ads *** gcc-3.2.3/gcc/ada/s-valuns.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-valuns.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valuti.adb gcc-3.3/gcc/ada/s-valuti.adb *** gcc-3.2.3/gcc/ada/s-valuti.adb 2002-05-04 03:28:51.000000000 +0000 --- gcc-3.3/gcc/ada/s-valuti.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valuti.ads gcc-3.3/gcc/ada/s-valuti.ads *** gcc-3.2.3/gcc/ada/s-valuti.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-valuti.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valwch.adb gcc-3.3/gcc/ada/s-valwch.adb *** gcc-3.2.3/gcc/ada/s-valwch.adb 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-valwch.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-valwch.ads gcc-3.3/gcc/ada/s-valwch.ads *** gcc-3.2.3/gcc/ada/s-valwch.ads 2002-05-04 03:28:51.000000000 +0000 --- gcc-3.3/gcc/ada/s-valwch.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vercon.adb gcc-3.3/gcc/ada/s-vercon.adb *** gcc-3.2.3/gcc/ada/s-vercon.adb 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-vercon.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vercon.ads gcc-3.3/gcc/ada/s-vercon.ads *** gcc-3.2.3/gcc/ada/s-vercon.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-vercon.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vmexta.adb gcc-3.3/gcc/ada/s-vmexta.adb *** gcc-3.2.3/gcc/ada/s-vmexta.adb 2002-05-04 03:28:51.000000000 +0000 --- gcc-3.3/gcc/ada/s-vmexta.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1997-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-vmexta.ads gcc-3.3/gcc/ada/s-vmexta.ads *** gcc-3.2.3/gcc/ada/s-vmexta.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-vmexta.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wchcnv.adb gcc-3.3/gcc/ada/s-wchcnv.adb *** gcc-3.2.3/gcc/ada/s-wchcnv.adb 2002-05-04 03:28:51.000000000 +0000 --- gcc-3.3/gcc/ada/s-wchcnv.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wchcnv.ads gcc-3.3/gcc/ada/s-wchcnv.ads *** gcc-3.2.3/gcc/ada/s-wchcnv.ads 2002-05-04 03:28:51.000000000 +0000 --- gcc-3.3/gcc/ada/s-wchcnv.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wchcon.ads gcc-3.3/gcc/ada/s-wchcon.ads *** gcc-3.2.3/gcc/ada/s-wchcon.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-wchcon.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wchjis.adb gcc-3.3/gcc/ada/s-wchjis.adb *** gcc-3.2.3/gcc/ada/s-wchjis.adb 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-wchjis.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wchjis.ads gcc-3.3/gcc/ada/s-wchjis.ads *** gcc-3.2.3/gcc/ada/s-wchjis.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-wchjis.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wchstw.adb gcc-3.3/gcc/ada/s-wchstw.adb *** gcc-3.2.3/gcc/ada/s-wchstw.adb 2002-05-04 03:28:52.000000000 +0000 --- gcc-3.3/gcc/ada/s-wchstw.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wchstw.ads gcc-3.3/gcc/ada/s-wchstw.ads *** gcc-3.2.3/gcc/ada/s-wchstw.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-wchstw.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wchwts.adb gcc-3.3/gcc/ada/s-wchwts.adb *** gcc-3.2.3/gcc/ada/s-wchwts.adb 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-wchwts.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wchwts.ads gcc-3.3/gcc/ada/s-wchwts.ads *** gcc-3.2.3/gcc/ada/s-wchwts.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-wchwts.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widboo.adb gcc-3.3/gcc/ada/s-widboo.adb *** gcc-3.2.3/gcc/ada/s-widboo.adb 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-widboo.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widboo.ads gcc-3.3/gcc/ada/s-widboo.ads *** gcc-3.2.3/gcc/ada/s-widboo.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-widboo.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widcha.adb gcc-3.3/gcc/ada/s-widcha.adb *** gcc-3.2.3/gcc/ada/s-widcha.adb 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-widcha.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widcha.ads gcc-3.3/gcc/ada/s-widcha.ads *** gcc-3.2.3/gcc/ada/s-widcha.ads 2002-05-07 08:22:30.000000000 +0000 --- gcc-3.3/gcc/ada/s-widcha.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widenu.adb gcc-3.3/gcc/ada/s-widenu.adb *** gcc-3.2.3/gcc/ada/s-widenu.adb 2002-05-04 03:28:52.000000000 +0000 --- gcc-3.3/gcc/ada/s-widenu.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2000 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001 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- -- *************** package body System.Wid_Enum is *** 47,52 **** --- 46,53 ---- Lo, Hi : Natural) return Natural is + pragma Warnings (Off, Names); + W : Natural; type Natural_8 is range 0 .. 2 ** 7 - 1; *************** package body System.Wid_Enum is *** 78,83 **** --- 79,86 ---- Lo, Hi : Natural) return Natural is + pragma Warnings (Off, Names); + W : Natural; type Natural_16 is range 0 .. 2 ** 15 - 1; *************** package body System.Wid_Enum is *** 109,114 **** --- 112,119 ---- Lo, Hi : Natural) return Natural is + pragma Warnings (Off, Names); + W : Natural; type Natural_32 is range 0 .. 2 ** 31 - 1; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widenu.ads gcc-3.3/gcc/ada/s-widenu.ads *** gcc-3.2.3/gcc/ada/s-widenu.ads 2002-05-04 03:28:52.000000000 +0000 --- gcc-3.3/gcc/ada/s-widenu.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widlli.adb gcc-3.3/gcc/ada/s-widlli.adb *** gcc-3.2.3/gcc/ada/s-widlli.adb 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/s-widlli.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widlli.ads gcc-3.3/gcc/ada/s-widlli.ads *** gcc-3.2.3/gcc/ada/s-widlli.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/s-widlli.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widllu.adb gcc-3.3/gcc/ada/s-widllu.adb *** gcc-3.2.3/gcc/ada/s-widllu.adb 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/s-widllu.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widllu.ads gcc-3.3/gcc/ada/s-widllu.ads *** gcc-3.2.3/gcc/ada/s-widllu.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/s-widllu.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widwch.adb gcc-3.3/gcc/ada/s-widwch.adb *** gcc-3.2.3/gcc/ada/s-widwch.adb 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/s-widwch.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-widwch.ads gcc-3.3/gcc/ada/s-widwch.ads *** gcc-3.2.3/gcc/ada/s-widwch.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/s-widwch.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/switch.adb gcc-3.3/gcc/ada/switch.adb *** gcc-3.2.3/gcc/ada/switch.adb 2002-05-04 03:29:21.000000000 +0000 --- gcc-3.3/gcc/ada/switch.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.6.10.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 26,92 **** -- -- ------------------------------------------------------------------------------ - -- Option switch scanning for both the compiler and the binder - - -- Note: this version of the package should be usable in both Unix and DOS - - with Debug; use Debug; - with Osint; use Osint; - with Opt; use Opt; - with Validsw; use Validsw; - with Stylesw; use Stylesw; - with Types; use Types; - - with System.WCh_Con; use System.WCh_Con; - package body Switch is - Bad_Switch : exception; - -- Exception raised if bad switch encountered - - Bad_Switch_Value : exception; - -- Exception raised if bad switch value encountered - - Missing_Switch_Value : exception; - -- Exception raised if no switch value encountered - - Too_Many_Output_Files : exception; - -- Exception raised if the -o switch is encountered more than once - - Switch_Max_Value : constant := 999; - -- Maximum value permitted in switches that take a value - - procedure Scan_Nat - (Switch_Chars : String; - Max : Integer; - Ptr : in out Integer; - Result : out Nat); - -- Scan natural integer parameter for switch. On entry, Ptr points - -- just past the switch character, on exit it points past the last - -- digit of the integer value. - - procedure Scan_Pos - (Switch_Chars : String; - Max : Integer; - Ptr : in out Integer; - Result : out Pos); - -- Scan positive integer parameter for switch. On entry, Ptr points - -- just past the switch character, on exit it points past the last - -- digit of the integer value. - ------------------------- -- Is_Front_End_Switch -- ------------------------- function Is_Front_End_Switch (Switch_Chars : String) return Boolean is ! Ptr : constant Positive := Switch_Chars'First; begin return Is_Switch (Switch_Chars) and then ! (Switch_Chars (Ptr + 1) = 'I' ! or else ! (Switch_Chars'Length >= 5 ! and then Switch_Chars (Ptr + 1 .. Ptr + 4) = "gnat")); end Is_Front_End_Switch; --------------- --- 25,47 ---- -- -- ------------------------------------------------------------------------------ package body Switch is ------------------------- -- Is_Front_End_Switch -- ------------------------- function Is_Front_End_Switch (Switch_Chars : String) return Boolean is ! Ptr : constant Positive := Switch_Chars'First; ! begin return Is_Switch (Switch_Chars) and then ! (Switch_Chars (Ptr + 1) = 'I' ! or else (Switch_Chars'Length >= 5 ! and then Switch_Chars (Ptr + 1 .. Ptr + 4) = "gnat") ! or else (Switch_Chars'Length >= 5 ! and then Switch_Chars (Ptr + 1 .. Ptr + 4) = "fRTS")); end Is_Front_End_Switch; --------------- *************** package body Switch is *** 96,1347 **** function Is_Switch (Switch_Chars : String) return Boolean is begin return Switch_Chars'Length > 1 ! and then (Switch_Chars (Switch_Chars'First) = '-' ! or ! Switch_Chars (Switch_Chars'First) = Switch_Character); end Is_Switch; - -------------------------- - -- Scan_Binder_Switches -- - -------------------------- - - procedure Scan_Binder_Switches (Switch_Chars : String) is - Ptr : Integer := Switch_Chars'First; - Max : Integer := Switch_Chars'Last; - C : Character := ' '; - - begin - -- Skip past the initial character (must be the switch character) - - if Ptr = Max then - raise Bad_Switch; - else - Ptr := Ptr + 1; - end if; - - -- A little check, "gnat" at the start of a switch is not allowed - -- except for the compiler - - if Switch_Chars'Last >= Ptr + 3 - and then Switch_Chars (Ptr .. Ptr + 3) = "gnat" - then - Osint.Fail ("invalid switch: """, Switch_Chars, """" - & " (gnat not needed here)"); - - end if; - - -- Loop to scan through switches given in switch string - - while Ptr <= Max loop - C := Switch_Chars (Ptr); - - case C is - - -- Processing for A switch - - when 'A' => - Ptr := Ptr + 1; - - Ada_Bind_File := True; - - -- Processing for b switch - - when 'b' => - Ptr := Ptr + 1; - Brief_Output := True; - - -- Processing for c switch - - when 'c' => - Ptr := Ptr + 1; - - Check_Only := True; - - -- Processing for C switch - - when 'C' => - Ptr := Ptr + 1; - - Ada_Bind_File := False; - - -- Processing for d switch - - when 'd' => - - -- Note: for the debug switch, the remaining characters in this - -- switch field must all be debug flags, since all valid switch - -- characters are also valid debug characters. - - -- Loop to scan out debug flags - - while Ptr < Max loop - Ptr := Ptr + 1; - C := Switch_Chars (Ptr); - exit when C = ASCII.NUL or else C = '/' or else C = '-'; - - if C in '1' .. '9' or else - C in 'a' .. 'z' or else - C in 'A' .. 'Z' - then - Set_Debug_Flag (C); - else - raise Bad_Switch; - end if; - end loop; - - -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This - -- is for backwards compatibility with old versions and usage. - - if Debug_Flag_XX then - Zero_Cost_Exceptions_Set := True; - Zero_Cost_Exceptions_Val := True; - end if; - - return; - - -- Processing for e switch - - when 'e' => - Ptr := Ptr + 1; - Elab_Dependency_Output := True; - - -- Processing for E switch - - when 'E' => - Ptr := Ptr + 1; - Exception_Tracebacks := True; - - -- Processing for f switch - - when 'f' => - Ptr := Ptr + 1; - Force_RM_Elaboration_Order := True; - - -- Processing for g switch - - when 'g' => - Ptr := Ptr + 1; - - if Ptr <= Max then - C := Switch_Chars (Ptr); - - if C in '0' .. '3' then - Debugger_Level := - Character'Pos - (Switch_Chars (Ptr)) - Character'Pos ('0'); - Ptr := Ptr + 1; - end if; - - else - Debugger_Level := 2; - end if; - - -- Processing for G switch - - when 'G' => - Ptr := Ptr + 1; - Print_Generated_Code := True; - - -- Processing for h switch - - when 'h' => - Ptr := Ptr + 1; - Usage_Requested := True; - - -- Processing for i switch - - when 'i' => - if Ptr = Max then - raise Bad_Switch; - end if; - - Ptr := Ptr + 1; - C := Switch_Chars (Ptr); - - if C in '1' .. '5' - or else C = '8' - or else C = 'p' - or else C = 'f' - or else C = 'n' - or else C = 'w' - then - Identifier_Character_Set := C; - Ptr := Ptr + 1; - else - raise Bad_Switch; - end if; - - -- Processing for K switch - - when 'K' => - Ptr := Ptr + 1; - - if Program = Binder then - Output_Linker_Option_List := True; - else - raise Bad_Switch; - end if; - - -- Processing for l switch - - when 'l' => - Ptr := Ptr + 1; - Elab_Order_Output := True; - - -- Processing for m switch - - when 'm' => - Ptr := Ptr + 1; - Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors); - - -- Processing for n switch - - when 'n' => - Ptr := Ptr + 1; - Bind_Main_Program := False; - - -- Note: The -L option of the binder also implies -n, so - -- any change here must also be reflected in the processing - -- for -L that is found in Gnatbind.Scan_Bind_Arg. - - -- Processing for o switch - - when 'o' => - Ptr := Ptr + 1; - - if Output_File_Name_Present then - raise Too_Many_Output_Files; - - else - Output_File_Name_Present := True; - end if; - - -- Processing for O switch - - when 'O' => - Ptr := Ptr + 1; - Output_Object_List := True; - - -- Processing for p switch - - when 'p' => - Ptr := Ptr + 1; - Pessimistic_Elab_Order := True; - - -- Processing for q switch - - when 'q' => - Ptr := Ptr + 1; - Quiet_Output := True; - - -- Processing for s switch - - when 's' => - Ptr := Ptr + 1; - All_Sources := True; - Check_Source_Files := True; - - -- Processing for t switch - - when 't' => - Ptr := Ptr + 1; - Tolerate_Consistency_Errors := True; - - -- Processing for T switch - - when 'T' => - Ptr := Ptr + 1; - Time_Slice_Set := True; - Scan_Nat (Switch_Chars, Max, Ptr, Time_Slice_Value); - - -- Processing for v switch - - when 'v' => - Ptr := Ptr + 1; - Verbose_Mode := True; - - -- Processing for w switch - - when 'w' => - - -- For the binder we only allow suppress/error cases - - Ptr := Ptr + 1; - - case Switch_Chars (Ptr) is - - when 'e' => - Warning_Mode := Treat_As_Error; - - when 's' => - Warning_Mode := Suppress; - - when others => - raise Bad_Switch; - end case; - - Ptr := Ptr + 1; - - -- Processing for W switch - - when 'W' => - Ptr := Ptr + 1; - - for J in WC_Encoding_Method loop - if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then - Wide_Character_Encoding_Method := J; - exit; - - elsif J = WC_Encoding_Method'Last then - raise Bad_Switch; - end if; - end loop; - - Upper_Half_Encoding := - Wide_Character_Encoding_Method in - WC_Upper_Half_Encoding_Method; - - Ptr := Ptr + 1; - - -- Processing for x switch - - when 'x' => - Ptr := Ptr + 1; - All_Sources := False; - Check_Source_Files := False; - - -- Processing for z switch - - when 'z' => - Ptr := Ptr + 1; - No_Main_Subprogram := True; - - -- Ignore extra switch character - - when '/' | '-' => - Ptr := Ptr + 1; - - -- Anything else is an error (illegal switch character) - - when others => - raise Bad_Switch; - end case; - end loop; - - exception - when Bad_Switch => - Osint.Fail ("invalid switch: ", (1 => C)); - - when Bad_Switch_Value => - Osint.Fail ("numeric value too big for switch: ", (1 => C)); - - when Missing_Switch_Value => - Osint.Fail ("missing numeric value for switch: ", (1 => C)); - - when Too_Many_Output_Files => - Osint.Fail ("duplicate -o switch"); - end Scan_Binder_Switches; - - ----------------------------- - -- Scan_Front_End_Switches -- - ----------------------------- - - procedure Scan_Front_End_Switches (Switch_Chars : String) is - Switch_Starts_With_Gnat : Boolean; - Ptr : Integer := Switch_Chars'First; - Max : constant Integer := Switch_Chars'Last; - C : Character := ' '; - - begin - -- Skip past the initial character (must be the switch character) - - if Ptr = Max then - raise Bad_Switch; - - else - Ptr := Ptr + 1; - end if; - - -- A little check, "gnat" at the start of a switch is not allowed - -- except for the compiler (where it was already removed) - - Switch_Starts_With_Gnat := - Ptr + 3 <= Max and then Switch_Chars (Ptr .. Ptr + 3) = "gnat"; - - if Switch_Starts_With_Gnat then - Ptr := Ptr + 4; - end if; - - -- Loop to scan through switches given in switch string - - while Ptr <= Max loop - C := Switch_Chars (Ptr); - - -- Processing for a switch - - case Switch_Starts_With_Gnat is - - when False => - -- There is only one front-end switch that - -- does not start with -gnat, namely -I - - case C is - - when 'I' => - Ptr := Ptr + 1; - - if Ptr > Max then - raise Bad_Switch; - end if; - - -- Find out whether this is a -I- or regular -Ixxx switch - - if Ptr = Max and then Switch_Chars (Ptr) = '-' then - Look_In_Primary_Dir := False; - - else - Add_Src_Search_Dir (Switch_Chars (Ptr .. Max)); - end if; - - Ptr := Max + 1; - - when others => - -- Should not happen, as Scan_Switches is supposed - -- to be called for front-end switches only. - -- Still, it is safest to raise Bad_Switch error. - - raise Bad_Switch; - end case; - - when True => - -- Process -gnat* options - - case C is - - when 'a' => - Ptr := Ptr + 1; - Assertions_Enabled := True; - - -- Processing for A switch - - when 'A' => - Ptr := Ptr + 1; - Config_File := False; - - -- Processing for b switch - - when 'b' => - Ptr := Ptr + 1; - Brief_Output := True; - - -- Processing for c switch - - when 'c' => - Ptr := Ptr + 1; - Operating_Mode := Check_Semantics; - - -- Processing for C switch - - when 'C' => - Ptr := Ptr + 1; - Compress_Debug_Names := True; - - -- Processing for d switch - - when 'd' => - - -- Note: for the debug switch, the remaining characters in this - -- switch field must all be debug flags, since all valid switch - -- characters are also valid debug characters. - - -- Loop to scan out debug flags - - while Ptr < Max loop - Ptr := Ptr + 1; - C := Switch_Chars (Ptr); - exit when C = ASCII.NUL or else C = '/' or else C = '-'; - - if C in '1' .. '9' or else - C in 'a' .. 'z' or else - C in 'A' .. 'Z' - then - Set_Debug_Flag (C); - - else - raise Bad_Switch; - end if; - end loop; - - -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This - -- is for backwards compatibility with old versions and usage. - - if Debug_Flag_XX then - Zero_Cost_Exceptions_Set := True; - Zero_Cost_Exceptions_Val := True; - end if; - - return; - - -- Processing for D switch - - when 'D' => - Ptr := Ptr + 1; - - -- Note: -gnatD also sets -gnatx (to turn off cross-reference - -- generation in the ali file) since otherwise this generation - -- gets confused by the "wrong" Sloc values put in the tree. - - Debug_Generated_Code := True; - Xref_Active := False; - Set_Debug_Flag ('g'); - - -- Processing for e switch - - when 'e' => - Ptr := Ptr + 1; - - if Ptr > Max then - raise Bad_Switch; - end if; - - case Switch_Chars (Ptr) is - - -- Configuration pragmas - - when 'c' => - Ptr := Ptr + 1; - - if Ptr > Max then - raise Bad_Switch; - end if; - - Config_File_Name := - new String'(Switch_Chars (Ptr .. Max)); - - return; - - -- Mapping file - - when 'm' => - Ptr := Ptr + 1; - - if Ptr > Max then - raise Bad_Switch; - end if; - - Mapping_File_Name := - new String'(Switch_Chars (Ptr .. Max)); - return; - - when others => - raise Bad_Switch; - end case; - - -- Processing for E switch - - when 'E' => - Ptr := Ptr + 1; - Dynamic_Elaboration_Checks := True; - - -- Processing for f switch - - when 'f' => - Ptr := Ptr + 1; - All_Errors_Mode := True; - - -- Processing for F switch - - when 'F' => - Ptr := Ptr + 1; - External_Name_Exp_Casing := Uppercase; - External_Name_Imp_Casing := Uppercase; - - -- Processing for g switch - - when 'g' => - Ptr := Ptr + 1; - GNAT_Mode := True; - Identifier_Character_Set := 'n'; - Warning_Mode := Treat_As_Error; - Check_Unreferenced := True; - Check_Withs := True; - - Set_Default_Style_Check_Options; - - -- Processing for G switch - - when 'G' => - Ptr := Ptr + 1; - Print_Generated_Code := True; - - -- Processing for h switch - - when 'h' => - Ptr := Ptr + 1; - Usage_Requested := True; - - -- Processing for H switch - - when 'H' => - Ptr := Ptr + 1; - HLO_Active := True; - - -- Processing for i switch - - when 'i' => - if Ptr = Max then - raise Bad_Switch; - end if; - - Ptr := Ptr + 1; - C := Switch_Chars (Ptr); - - if C in '1' .. '5' - or else C = '8' - or else C = 'p' - or else C = 'f' - or else C = 'n' - or else C = 'w' - then - Identifier_Character_Set := C; - Ptr := Ptr + 1; - - else - raise Bad_Switch; - end if; - - -- Processing for k switch - - when 'k' => - Ptr := Ptr + 1; - Scan_Pos (Switch_Chars, Max, Ptr, Maximum_File_Name_Length); - - -- Processing for l switch - - when 'l' => - Ptr := Ptr + 1; - Full_List := True; - - -- Processing for L switch - - when 'L' => - Ptr := Ptr + 1; - Zero_Cost_Exceptions_Set := True; - Zero_Cost_Exceptions_Val := False; - - -- Processing for m switch - - when 'm' => - Ptr := Ptr + 1; - Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors); - - -- Processing for n switch - - when 'n' => - Ptr := Ptr + 1; - Inline_Active := True; - - -- Processing for N switch - - when 'N' => - Ptr := Ptr + 1; - Inline_Active := True; - Front_End_Inlining := True; - - -- Processing for o switch - - when 'o' => - Ptr := Ptr + 1; - Suppress_Options.Overflow_Checks := False; - - -- Processing for O switch - - when 'O' => - Ptr := Ptr + 1; - Output_File_Name_Present := True; - - -- Processing for p switch - - when 'p' => - Ptr := Ptr + 1; - Suppress_Options.Access_Checks := True; - Suppress_Options.Accessibility_Checks := True; - Suppress_Options.Discriminant_Checks := True; - Suppress_Options.Division_Checks := True; - Suppress_Options.Elaboration_Checks := True; - Suppress_Options.Index_Checks := True; - Suppress_Options.Length_Checks := True; - Suppress_Options.Overflow_Checks := True; - Suppress_Options.Range_Checks := True; - Suppress_Options.Division_Checks := True; - Suppress_Options.Length_Checks := True; - Suppress_Options.Range_Checks := True; - Suppress_Options.Storage_Checks := True; - Suppress_Options.Tag_Checks := True; - - Validity_Checks_On := False; - - -- Processing for P switch - - when 'P' => - Ptr := Ptr + 1; - Polling_Required := True; - - -- Processing for q switch - - when 'q' => - Ptr := Ptr + 1; - Try_Semantics := True; - - -- Processing for q switch - - when 'Q' => - Ptr := Ptr + 1; - Force_ALI_Tree_File := True; - Try_Semantics := True; - - -- Processing for r switch - - when 'r' => - Ptr := Ptr + 1; - - -- Temporarily allow -gnatr to mean -gnatyl (use RM layout) - -- for compatibility with pre 3.12 versions of GNAT, - -- to be removed for 3.13 ??? - - Set_Style_Check_Options ("l"); - - -- Processing for R switch - - when 'R' => - Ptr := Ptr + 1; - Back_Annotate_Rep_Info := True; - - if Ptr <= Max - and then Switch_Chars (Ptr) in '0' .. '9' - then - C := Switch_Chars (Ptr); - - if C in '4' .. '9' then - raise Bad_Switch; - else - List_Representation_Info := - Character'Pos (C) - Character'Pos ('0'); - Ptr := Ptr + 1; - end if; - - else - List_Representation_Info := 1; - end if; - - -- Processing for s switch - - when 's' => - Ptr := Ptr + 1; - Operating_Mode := Check_Syntax; - - -- Processing for t switch - - when 't' => - Ptr := Ptr + 1; - Tree_Output := True; - Back_Annotate_Rep_Info := True; - - -- Processing for T switch - - when 'T' => - Ptr := Ptr + 1; - Time_Slice_Set := True; - Scan_Nat (Switch_Chars, Max, Ptr, Time_Slice_Value); - - -- Processing for u switch - - when 'u' => - Ptr := Ptr + 1; - List_Units := True; - - -- Processing for U switch - - when 'U' => - Ptr := Ptr + 1; - Unique_Error_Tag := True; - - -- Processing for v switch - - when 'v' => - Ptr := Ptr + 1; - Verbose_Mode := True; - - -- Processing for V switch - - when 'V' => - Ptr := Ptr + 1; - - if Ptr > Max then - raise Bad_Switch; - - else - declare - OK : Boolean; - - begin - Set_Validity_Check_Options - (Switch_Chars (Ptr .. Max), OK, Ptr); - - if not OK then - raise Bad_Switch; - end if; - end; - end if; - - -- Processing for w switch - - when 'w' => - Ptr := Ptr + 1; - - if Ptr > Max then - raise Bad_Switch; - end if; - - while Ptr <= Max loop - C := Switch_Chars (Ptr); - - case C is - - when 'a' => - Constant_Condition_Warnings := True; - Elab_Warnings := True; - Check_Unreferenced := True; - Check_Withs := True; - Implementation_Unit_Warnings := True; - Ineffective_Inline_Warnings := True; - Warn_On_Redundant_Constructs := True; - - when 'A' => - Constant_Condition_Warnings := False; - Elab_Warnings := False; - Check_Unreferenced := False; - Check_Withs := False; - Implementation_Unit_Warnings := False; - Warn_On_Biased_Rounding := False; - Warn_On_Hiding := False; - Warn_On_Redundant_Constructs := False; - Ineffective_Inline_Warnings := False; - - when 'c' => - Constant_Condition_Warnings := True; - - when 'C' => - Constant_Condition_Warnings := False; - - when 'b' => - Warn_On_Biased_Rounding := True; - - when 'B' => - Warn_On_Biased_Rounding := False; - - when 'e' => - Warning_Mode := Treat_As_Error; - - when 'h' => - Warn_On_Hiding := True; - - when 'H' => - Warn_On_Hiding := False; - - when 'i' => - Implementation_Unit_Warnings := True; - - when 'I' => - Implementation_Unit_Warnings := False; - - when 'l' => - Elab_Warnings := True; - - when 'L' => - Elab_Warnings := False; - - when 'o' => - Address_Clause_Overlay_Warnings := True; - - when 'O' => - Address_Clause_Overlay_Warnings := False; - - when 'p' => - Ineffective_Inline_Warnings := True; - - when 'P' => - Ineffective_Inline_Warnings := False; - - when 'r' => - Warn_On_Redundant_Constructs := True; - - when 'R' => - Warn_On_Redundant_Constructs := False; - - when 's' => - Warning_Mode := Suppress; - - when 'u' => - Check_Unreferenced := True; - Check_Withs := True; - - when 'U' => - Check_Unreferenced := False; - Check_Withs := False; - - -- Allow and ignore 'w' so that the old - -- format (e.g. -gnatwuwl) will work. - - when 'w' => - null; - - when others => - raise Bad_Switch; - end case; - - Ptr := Ptr + 1; - end loop; - - return; - - -- Processing for W switch - - when 'W' => - Ptr := Ptr + 1; - - for J in WC_Encoding_Method loop - if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then - Wide_Character_Encoding_Method := J; - exit; - - elsif J = WC_Encoding_Method'Last then - raise Bad_Switch; - end if; - end loop; - - Upper_Half_Encoding := - Wide_Character_Encoding_Method in - WC_Upper_Half_Encoding_Method; - - Ptr := Ptr + 1; - - -- Processing for x switch - - when 'x' => - Ptr := Ptr + 1; - Xref_Active := False; - - -- Processing for X switch - - when 'X' => - Ptr := Ptr + 1; - Extensions_Allowed := True; - - -- Processing for y switch - - when 'y' => - Ptr := Ptr + 1; - - if Ptr > Max then - Set_Default_Style_Check_Options; - - else - declare - OK : Boolean; - - begin - Set_Style_Check_Options - (Switch_Chars (Ptr .. Max), OK, Ptr); - - if not OK then - raise Bad_Switch; - end if; - end; - end if; - - -- Processing for z switch - - when 'z' => - Ptr := Ptr + 1; - - -- Allowed for compiler, only if this is the only - -- -z switch, we do not allow multiple occurrences - - if Distribution_Stub_Mode = No_Stubs then - case Switch_Chars (Ptr) is - when 'r' => - Distribution_Stub_Mode := Generate_Receiver_Stub_Body; - - when 'c' => - Distribution_Stub_Mode := Generate_Caller_Stub_Body; - - when others => - raise Bad_Switch; - end case; - - Ptr := Ptr + 1; - - end if; - - -- Processing for Z switch - - when 'Z' => - Ptr := Ptr + 1; - Zero_Cost_Exceptions_Set := True; - Zero_Cost_Exceptions_Val := True; - - -- Processing for 83 switch - - when '8' => - - if Ptr = Max then - raise Bad_Switch; - end if; - - Ptr := Ptr + 1; - - if Switch_Chars (Ptr) /= '3' then - raise Bad_Switch; - else - Ptr := Ptr + 1; - Ada_95 := False; - Ada_83 := True; - end if; - - -- Ignore extra switch character - - when '/' | '-' => - Ptr := Ptr + 1; - - -- Anything else is an error (illegal switch character) - - when others => - raise Bad_Switch; - end case; - end case; - end loop; - - exception - when Bad_Switch => - Osint.Fail ("invalid switch: ", (1 => C)); - - when Bad_Switch_Value => - Osint.Fail ("numeric value too big for switch: ", (1 => C)); - - when Missing_Switch_Value => - Osint.Fail ("missing numeric value for switch: ", (1 => C)); - - end Scan_Front_End_Switches; - ------------------------ - -- Scan_Make_Switches -- - ------------------------ - - procedure Scan_Make_Switches (Switch_Chars : String) is - Ptr : Integer := Switch_Chars'First; - Max : Integer := Switch_Chars'Last; - C : Character := ' '; - - begin - -- Skip past the initial character (must be the switch character) - - if Ptr = Max then - raise Bad_Switch; - - else - Ptr := Ptr + 1; - end if; - - -- A little check, "gnat" at the start of a switch is not allowed - -- except for the compiler (where it was already removed) - - if Switch_Chars'Length >= Ptr + 3 - and then Switch_Chars (Ptr .. Ptr + 3) = "gnat" - then - Osint.Fail - ("invalid switch: """, Switch_Chars, """ (gnat not needed here)"); - end if; - - -- Loop to scan through switches given in switch string - - while Ptr <= Max loop - C := Switch_Chars (Ptr); - - -- Processing for a switch - - case C is - - when 'a' => - Ptr := Ptr + 1; - Check_Readonly_Files := True; - - -- Processing for b switch - - when 'b' => - Ptr := Ptr + 1; - Bind_Only := True; - - -- Processing for c switch - - when 'c' => - Ptr := Ptr + 1; - Compile_Only := True; - - when 'd' => - - -- Note: for the debug switch, the remaining characters in this - -- switch field must all be debug flags, since all valid switch - -- characters are also valid debug characters. - - -- Loop to scan out debug flags - - while Ptr < Max loop - Ptr := Ptr + 1; - C := Switch_Chars (Ptr); - exit when C = ASCII.NUL or else C = '/' or else C = '-'; - - if C in '1' .. '9' or else - C in 'a' .. 'z' or else - C in 'A' .. 'Z' - then - Set_Debug_Flag (C); - else - raise Bad_Switch; - end if; - end loop; - - -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This - -- is for backwards compatibility with old versions and usage. - - if Debug_Flag_XX then - Zero_Cost_Exceptions_Set := True; - Zero_Cost_Exceptions_Val := True; - end if; - - return; - - -- Processing for f switch - - when 'f' => - Ptr := Ptr + 1; - Force_Compilations := True; - - -- Processing for G switch - - when 'G' => - Ptr := Ptr + 1; - Print_Generated_Code := True; - - -- Processing for h switch - - when 'h' => - Ptr := Ptr + 1; - Usage_Requested := True; - - -- Processing for i switch - - when 'i' => - Ptr := Ptr + 1; - In_Place_Mode := True; - - -- Processing for j switch - - when 'j' => - Ptr := Ptr + 1; - - declare - Max_Proc : Pos; - begin - Scan_Pos (Switch_Chars, Max, Ptr, Max_Proc); - Maximum_Processes := Positive (Max_Proc); - end; - - -- Processing for k switch - - when 'k' => - Ptr := Ptr + 1; - Keep_Going := True; - - -- Processing for l switch - - when 'l' => - Ptr := Ptr + 1; - Link_Only := True; - - when 'M' => - Ptr := Ptr + 1; - List_Dependencies := True; - - -- Processing for n switch - - when 'n' => - Ptr := Ptr + 1; - Do_Not_Execute := True; - - -- Processing for o switch - - when 'o' => - Ptr := Ptr + 1; - - if Output_File_Name_Present then - raise Too_Many_Output_Files; - else - Output_File_Name_Present := True; - end if; - - -- Processing for q switch - - when 'q' => - Ptr := Ptr + 1; - Quiet_Output := True; - - -- Processing for s switch - - when 's' => - Ptr := Ptr + 1; - Check_Switches := True; - - -- Processing for v switch - - when 'v' => - Ptr := Ptr + 1; - Verbose_Mode := True; - - -- Processing for z switch - - when 'z' => - Ptr := Ptr + 1; - No_Main_Subprogram := True; - - -- Ignore extra switch character - - when '/' | '-' => - Ptr := Ptr + 1; - - -- Anything else is an error (illegal switch character) - - when others => - raise Bad_Switch; - - end case; - end loop; - - exception - when Bad_Switch => - Osint.Fail ("invalid switch: ", (1 => C)); - - when Bad_Switch_Value => - Osint.Fail ("numeric value too big for switch: ", (1 => C)); - - when Missing_Switch_Value => - Osint.Fail ("missing numeric value for switch: ", (1 => C)); - - when Too_Many_Output_Files => - Osint.Fail ("duplicate -o switch"); - - end Scan_Make_Switches; - -------------- -- Scan_Nat -- -------------- --- 51,60 ---- function Is_Switch (Switch_Chars : String) return Boolean is begin return Switch_Chars'Length > 1 ! and then Switch_Chars (Switch_Chars'First) = '-'; end Is_Switch; ------------------------ -------------- -- Scan_Nat -- -------------- *************** package body Switch is *** 1350,1358 **** (Switch_Chars : String; Max : Integer; Ptr : in out Integer; ! Result : out Nat) is begin Result := 0; if Ptr > Max or else Switch_Chars (Ptr) not in '0' .. '9' then raise Missing_Switch_Value; end if; --- 63,73 ---- (Switch_Chars : String; Max : Integer; Ptr : in out Integer; ! Result : out Nat) ! is begin Result := 0; + if Ptr > Max or else Switch_Chars (Ptr) not in '0' .. '9' then raise Missing_Switch_Value; end if; *************** package body Switch is *** 1380,1385 **** --- 95,101 ---- begin Scan_Nat (Switch_Chars, Max, Ptr, Result); + if Result = 0 then raise Bad_Switch_Value; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/switch.ads gcc-3.3/gcc/ada/switch.ads *** gcc-3.2.3/gcc/ada/switch.ads 2002-05-07 08:22:35.000000000 +0000 --- gcc-3.3/gcc/ada/switch.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 26,37 **** -- -- ------------------------------------------------------------------------------ ! -- This package scans switches. Note that the body of Usage must be ! -- coordinated with the switches that are recognized by this package. ! -- The Usage package also acts as the official documentation for the -- switches that are recognized. In addition, package Debug documents -- the otherwise undocumented debug switches that are also recognized. package Switch is -- Note: The default switch character is indicated by Switch_Character, --- 25,39 ---- -- -- ------------------------------------------------------------------------------ ! -- This package together with a child package appropriate to the client ! -- tool scans switches. Note that the body of the appropraite Usage package ! -- must be coordinated with the switches that are recognized by this package. ! -- These Usage packages also act as the official documentation for the -- switches that are recognized. In addition, package Debug documents -- the otherwise undocumented debug switches that are also recognized. + with Types; use Types; + package Switch is -- Note: The default switch character is indicated by Switch_Character, *************** package Switch is *** 55,69 **** -- Returns True iff Switch_Chars represents a front-end switch, -- ie. it starts with -I or -gnat. ! procedure Scan_Front_End_Switches (Switch_Chars : String); ! procedure Scan_Binder_Switches (Switch_Chars : String); ! procedure Scan_Make_Switches (Switch_Chars : String); ! -- Procedures to scan out switches stored in the given string. The first ! -- character is known to be a valid switch character, and there are no ! -- blanks or other switch terminator characters in the string, so the ! -- entire string should consist of valid switch characters, except that ! -- an optional terminating NUL character is allowed. A bad switch causes ! -- a fatal error exit and control does not return. The call also sets ! -- Usage_Requested to True if a ? switch is encountered. end Switch; --- 57,99 ---- -- Returns True iff Switch_Chars represents a front-end switch, -- ie. it starts with -I or -gnat. ! private ! ! -- This section contains some common routines used by the tool dependent ! -- child packages (there is one such child package for each tool that ! -- uses Switches to scan switches - Compiler/gnatbind/gnatmake/. ! ! Bad_Switch : exception; ! -- Exception raised if bad switch encountered ! ! Bad_Switch_Value : exception; ! -- Exception raised if bad switch value encountered ! ! Missing_Switch_Value : exception; ! -- Exception raised if no switch value encountered ! ! Too_Many_Output_Files : exception; ! -- Exception raised if the -o switch is encountered more than once ! ! Switch_Max_Value : constant := 999; ! -- Maximum value permitted in switches that take a value ! ! procedure Scan_Nat ! (Switch_Chars : String; ! Max : Integer; ! Ptr : in out Integer; ! Result : out Nat); ! -- Scan natural integer parameter for switch. On entry, Ptr points ! -- just past the switch character, on exit it points past the last ! -- digit of the integer value. ! ! procedure Scan_Pos ! (Switch_Chars : String; ! Max : Integer; ! Ptr : in out Integer; ! Result : out Pos); ! -- Scan positive integer parameter for switch. On entry, Ptr points ! -- just past the switch character, on exit it points past the last ! -- digit of the integer value. end Switch; diff -Nrc3pad gcc-3.2.3/gcc/ada/switch-b.adb gcc-3.3/gcc/ada/switch-b.adb *** gcc-3.2.3/gcc/ada/switch-b.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/switch-b.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,427 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S W I T C H - B -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001-2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with Debug; use Debug; + with Osint; use Osint; + with Opt; use Opt; + + with System.WCh_Con; use System.WCh_Con; + + package body Switch.B is + + -------------------------- + -- Scan_Binder_Switches -- + -------------------------- + + procedure Scan_Binder_Switches (Switch_Chars : String) is + Ptr : Integer := Switch_Chars'First; + Max : Integer := Switch_Chars'Last; + C : Character := ' '; + + begin + -- Skip past the initial character (must be the switch character) + + if Ptr = Max then + raise Bad_Switch; + else + Ptr := Ptr + 1; + end if; + + -- A little check, "gnat" at the start of a switch is not allowed + -- except for the compiler + + if Switch_Chars'Last >= Ptr + 3 + and then Switch_Chars (Ptr .. Ptr + 3) = "gnat" + then + Osint.Fail ("invalid switch: """, Switch_Chars, """" + & " (gnat not needed here)"); + + end if; + + -- Loop to scan through switches given in switch string + + while Ptr <= Max loop + C := Switch_Chars (Ptr); + + case C is + + -- Processing for A switch + + when 'A' => + Ptr := Ptr + 1; + + Ada_Bind_File := True; + + -- Processing for b switch + + when 'b' => + Ptr := Ptr + 1; + Brief_Output := True; + + -- Processing for c switch + + when 'c' => + Ptr := Ptr + 1; + + Check_Only := True; + + -- Processing for C switch + + when 'C' => + Ptr := Ptr + 1; + + Ada_Bind_File := False; + + -- Processing for d switch + + when 'd' => + + -- Note: for the debug switch, the remaining characters in this + -- switch field must all be debug flags, since all valid switch + -- characters are also valid debug characters. This switch is not + -- documented on purpose because it is only used by the + -- implementors. + + -- Loop to scan out debug flags + + while Ptr < Max loop + Ptr := Ptr + 1; + C := Switch_Chars (Ptr); + exit when C = ASCII.NUL or else C = '/' or else C = '-'; + + if C in '1' .. '9' or else + C in 'a' .. 'z' or else + C in 'A' .. 'Z' + then + Set_Debug_Flag (C); + else + raise Bad_Switch; + end if; + end loop; + + -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This + -- is for backwards compatibility with old versions and usage. + + if Debug_Flag_XX then + Zero_Cost_Exceptions_Set := True; + Zero_Cost_Exceptions_Val := True; + end if; + + return; + + -- Processing for e switch + + when 'e' => + Ptr := Ptr + 1; + Elab_Dependency_Output := True; + + -- Processing for E switch + + when 'E' => + Ptr := Ptr + 1; + Exception_Tracebacks := True; + + -- Processing for f switch + + when 'f' => + Ptr := Ptr + 1; + Force_RM_Elaboration_Order := True; + + -- Processing for g switch + + when 'g' => + Ptr := Ptr + 1; + + if Ptr <= Max then + C := Switch_Chars (Ptr); + + if C in '0' .. '3' then + Debugger_Level := + Character'Pos + (Switch_Chars (Ptr)) - Character'Pos ('0'); + Ptr := Ptr + 1; + end if; + + else + Debugger_Level := 2; + end if; + + -- Processing for h switch + + when 'h' => + Ptr := Ptr + 1; + Usage_Requested := True; + + -- Processing for i switch + + when 'i' => + if Ptr = Max then + raise Bad_Switch; + end if; + + Ptr := Ptr + 1; + C := Switch_Chars (Ptr); + + if C in '1' .. '5' + or else C = '8' + or else C = 'p' + or else C = 'f' + or else C = 'n' + or else C = 'w' + then + Identifier_Character_Set := C; + Ptr := Ptr + 1; + else + raise Bad_Switch; + end if; + + -- Processing for K switch + + when 'K' => + Ptr := Ptr + 1; + Output_Linker_Option_List := True; + + -- Processing for l switch + + when 'l' => + Ptr := Ptr + 1; + Elab_Order_Output := True; + + -- Processing for m switch + + when 'm' => + Ptr := Ptr + 1; + Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors); + + -- Processing for n switch + + when 'n' => + Ptr := Ptr + 1; + Bind_Main_Program := False; + + -- Note: The -L option of the binder also implies -n, so + -- any change here must also be reflected in the processing + -- for -L that is found in Gnatbind.Scan_Bind_Arg. + + -- Processing for o switch + + when 'o' => + Ptr := Ptr + 1; + + if Output_File_Name_Present then + raise Too_Many_Output_Files; + + else + Output_File_Name_Present := True; + end if; + + -- Processing for O switch + + when 'O' => + Ptr := Ptr + 1; + Output_Object_List := True; + + -- Processing for p switch + + when 'p' => + Ptr := Ptr + 1; + Pessimistic_Elab_Order := True; + + -- Processing for q switch + + when 'q' => + Ptr := Ptr + 1; + Quiet_Output := True; + + -- Processing for r switch + + when 'r' => + Ptr := Ptr + 1; + List_Restrictions := True; + + -- Processing for s switch + + when 's' => + Ptr := Ptr + 1; + All_Sources := True; + Check_Source_Files := True; + + -- Processing for t switch + + when 't' => + Ptr := Ptr + 1; + Tolerate_Consistency_Errors := True; + + -- Processing for T switch + + when 'T' => + Ptr := Ptr + 1; + Time_Slice_Set := True; + Scan_Nat (Switch_Chars, Max, Ptr, Time_Slice_Value); + + -- Processing for v switch + + when 'v' => + Ptr := Ptr + 1; + Verbose_Mode := True; + + -- Processing for w switch + + when 'w' => + + -- For the binder we only allow suppress/error cases + + Ptr := Ptr + 1; + + case Switch_Chars (Ptr) is + + when 'e' => + Warning_Mode := Treat_As_Error; + + when 's' => + Warning_Mode := Suppress; + + when others => + raise Bad_Switch; + end case; + + Ptr := Ptr + 1; + + -- Processing for W switch + + when 'W' => + Ptr := Ptr + 1; + + for J in WC_Encoding_Method loop + if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then + Wide_Character_Encoding_Method := J; + exit; + + elsif J = WC_Encoding_Method'Last then + raise Bad_Switch; + end if; + end loop; + + Upper_Half_Encoding := + Wide_Character_Encoding_Method in + WC_Upper_Half_Encoding_Method; + + Ptr := Ptr + 1; + + -- Processing for x switch + + when 'x' => + Ptr := Ptr + 1; + All_Sources := False; + Check_Source_Files := False; + + -- Processing for z switch + + when 'z' => + Ptr := Ptr + 1; + No_Main_Subprogram := True; + + -- Ignore extra switch character + + when '/' => + Ptr := Ptr + 1; + + -- Ignore '-' extra switch caracter, only if it isn't followed by + -- 'RTS'. If it is, then we must process the 'RTS' switch + + when '-' => + + if Ptr + 3 <= Max and then + Switch_Chars (Ptr + 1 .. Ptr + 3) = "RTS" + then + Ptr := Ptr + 1; + + if Switch_Chars (Ptr + 3) /= '=' or else + (Switch_Chars (Ptr + 3) = '=' + and then Ptr + 4 > Max) + then + Osint.Fail ("missing path for --RTS"); + else + + -- valid --RTS switch + Opt.No_Stdinc := True; + Opt.RTS_Switch := True; + + declare + Src_Path_Name : String_Ptr := Get_RTS_Search_Dir + (Switch_Chars (Ptr + 4 .. Switch_Chars'Last), Include); + Lib_Path_Name : String_Ptr := Get_RTS_Search_Dir + (Switch_Chars (Ptr + 4 .. Switch_Chars'Last), Objects); + begin + if Src_Path_Name /= null and then + Lib_Path_Name /= null + then + Add_Search_Dirs (Src_Path_Name, Include); + Add_Search_Dirs (Lib_Path_Name, Objects); + -- we can exit as there can not be another switch + -- after --RTS + exit; + elsif Src_Path_Name = null + and Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude and adalib directories"); + elsif Src_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude directory"); + elsif Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adalib directory"); + end if; + end; + end if; + + else + Ptr := Ptr + 1; + end if; + + -- Anything else is an error (illegal switch character) + + when others => + raise Bad_Switch; + end case; + end loop; + + exception + when Bad_Switch => + Osint.Fail ("invalid switch: ", (1 => C)); + + when Bad_Switch_Value => + Osint.Fail ("numeric value too big for switch: ", (1 => C)); + + when Missing_Switch_Value => + Osint.Fail ("missing numeric value for switch: ", (1 => C)); + + when Too_Many_Output_Files => + Osint.Fail ("duplicate -o switch"); + end Scan_Binder_Switches; + + end Switch.B; diff -Nrc3pad gcc-3.2.3/gcc/ada/switch-b.ads gcc-3.3/gcc/ada/switch-b.ads *** gcc-3.2.3/gcc/ada/switch-b.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/switch-b.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,45 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S W I T C H - B -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package scans binder switches. Note that the body of Usage must be + -- coordinated with the switches that are recognized by this package. + -- The Usage package also acts as the official documentation for the + -- switches that are recognized. In addition, package Debug documents + -- the otherwise undocumented debug switches that are also recognized. + + package Switch.B is + + procedure Scan_Binder_Switches (Switch_Chars : String); + -- Procedures to scan out binder switches stored in the given string. + -- The first character is known to be a valid switch character, and there + -- are no blanks or other switch terminator characters in the string, so + -- the entire string should consist of valid switch characters, except that + -- an optional terminating NUL character is allowed. A bad switch causes + -- a fatal error exit and control does not return. The call also sets + -- Usage_Requested to True if a ? switch is encountered. + + end Switch.B; diff -Nrc3pad gcc-3.2.3/gcc/ada/switch-c.adb gcc-3.3/gcc/ada/switch-c.adb *** gcc-3.2.3/gcc/ada/switch-c.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/switch-c.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,869 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S W I T C H - C -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001-2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with Debug; use Debug; + with Lib; use Lib; + with Osint; use Osint; + with Opt; use Opt; + with Types; use Types; + with Validsw; use Validsw; + with Stylesw; use Stylesw; + + with System.WCh_Con; use System.WCh_Con; + + package body Switch.C is + + ----------------------------- + -- Scan_Front_End_Switches -- + ----------------------------- + + procedure Scan_Front_End_Switches (Switch_Chars : String) is + Switch_Starts_With_Gnat : Boolean; + -- True if first four switch characters are "gnat" + + First_Switch : Boolean := True; + -- False for all but first switch + + Ptr : Integer := Switch_Chars'First; + Max : constant Integer := Switch_Chars'Last; + C : Character := ' '; + + Store_Switch : Boolean := True; + First_Char : Integer := Ptr; + Storing : String := Switch_Chars; + First_Stored : Positive := Ptr + 1; + -- The above need comments ??? + + begin + -- Skip past the initial character (must be the switch character) + + if Ptr = Max then + raise Bad_Switch; + else + Ptr := Ptr + 1; + end if; + + -- Remove "gnat" from the switch, if present + + Switch_Starts_With_Gnat := + Ptr + 3 <= Max and then Switch_Chars (Ptr .. Ptr + 3) = "gnat"; + + if Switch_Starts_With_Gnat then + Ptr := Ptr + 4; + First_Stored := Ptr; + end if; + + -- Loop to scan through switches given in switch string + + while Ptr <= Max loop + Store_Switch := True; + First_Char := Ptr; + C := Switch_Chars (Ptr); + + -- Processing for a switch + + case Switch_Starts_With_Gnat is + + when False => + -- There are only two front-end switches that + -- do not start with -gnat, namely -I and --RTS + + if Switch_Chars (Ptr) = 'I' then + Store_Switch := False; + + Ptr := Ptr + 1; + + if Ptr > Max then + raise Bad_Switch; + end if; + + -- Find out whether this is a -I- or regular -Ixxx switch + + if Ptr = Max and then Switch_Chars (Ptr) = '-' then + Look_In_Primary_Dir := False; + + else + Add_Src_Search_Dir (Switch_Chars (Ptr .. Max)); + end if; + + Ptr := Max + 1; + + -- Processing of the --RTS switch. --RTS has been modified by + -- gcc and is now of the form -fRTS + elsif Ptr + 3 <= Max and then + Switch_Chars (Ptr .. Ptr + 3) = "fRTS" + then + Ptr := Ptr + 1; + + if Ptr + 4 > Max or else Switch_Chars (Ptr + 3) /= '=' then + Osint.Fail ("missing path for --RTS"); + else + + -- valid --RTS switch + Opt.No_Stdinc := True; + Opt.RTS_Switch := True; + + declare + Src_Path_Name : String_Ptr := Get_RTS_Search_Dir + (Switch_Chars (Ptr + 4 .. Max), Include); + Lib_Path_Name : String_Ptr := Get_RTS_Search_Dir + (Switch_Chars (Ptr + 4 .. Max), Objects); + begin + if Src_Path_Name /= null and then + Lib_Path_Name /= null + then + Add_Search_Dirs (Src_Path_Name, Include); + Add_Search_Dirs (Lib_Path_Name, Objects); + Ptr := Max + 1; + elsif Src_Path_Name = null + and Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude and adalib directories"); + elsif Src_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adainclude directory"); + elsif Lib_Path_Name = null then + Osint.Fail ("RTS path not valid: missing " & + "adalib directory"); + end if; + end; + end if; + else + raise Bad_Switch; + end if; + + when True => + -- Process -gnat* options + + case C is + + when 'a' => + Ptr := Ptr + 1; + Assertions_Enabled := True; + + -- Processing for A switch + + when 'A' => + Ptr := Ptr + 1; + Config_File := False; + + -- Processing for b switch + + when 'b' => + Ptr := Ptr + 1; + Brief_Output := True; + + -- Processing for c switch + + when 'c' => + if not First_Switch then + Osint.Fail + ("-gnatc myust be first if combined with other switches"); + end if; + + Ptr := Ptr + 1; + Operating_Mode := Check_Semantics; + + -- Processing for C switch + + when 'C' => + Ptr := Ptr + 1; + Compress_Debug_Names := True; + + -- Processing for d switch + + when 'd' => + Store_Switch := False; + Storing (First_Stored) := 'd'; + -- Note: for the debug switch, the remaining characters in this + -- switch field must all be debug flags, since all valid switch + -- characters are also valid debug characters. + + -- Loop to scan out debug flags + + while Ptr < Max loop + Ptr := Ptr + 1; + C := Switch_Chars (Ptr); + exit when C = ASCII.NUL or else C = '/' or else C = '-'; + + if C in '1' .. '9' or else + C in 'a' .. 'z' or else + C in 'A' .. 'Z' + then + Set_Debug_Flag (C); + Storing (First_Stored + 1) := C; + Store_Compilation_Switch + (Storing (Storing'First .. First_Stored + 1)); + + else + raise Bad_Switch; + end if; + end loop; + + -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This + -- is for backwards compatibility with old versions and usage. + + if Debug_Flag_XX then + Zero_Cost_Exceptions_Set := True; + Zero_Cost_Exceptions_Val := True; + end if; + + return; + + -- Processing for D switch + + when 'D' => + Ptr := Ptr + 1; + + -- Note: -gnatD also sets -gnatx (to turn off cross-reference + -- generation in the ali file) since otherwise this generation + -- gets confused by the "wrong" Sloc values put in the tree. + + Debug_Generated_Code := True; + Xref_Active := False; + Set_Debug_Flag ('g'); + + -- Processing for e switch + + when 'e' => + Ptr := Ptr + 1; + + if Ptr > Max then + raise Bad_Switch; + end if; + + case Switch_Chars (Ptr) is + + -- Configuration pragmas + + when 'c' => + Store_Switch := False; + Ptr := Ptr + 1; + + if Ptr > Max then + raise Bad_Switch; + end if; + + Config_File_Name := + new String'(Switch_Chars (Ptr .. Max)); + + return; + + -- Mapping file + + when 'm' => + Store_Switch := False; + Ptr := Ptr + 1; + + if Ptr > Max then + raise Bad_Switch; + end if; + + Mapping_File_Name := + new String'(Switch_Chars (Ptr .. Max)); + return; + + when others => + raise Bad_Switch; + end case; + + -- Processing for E switch + + when 'E' => + Ptr := Ptr + 1; + Dynamic_Elaboration_Checks := True; + + -- Processing for f switch + + when 'f' => + Ptr := Ptr + 1; + All_Errors_Mode := True; + + -- Processing for F switch + + when 'F' => + Ptr := Ptr + 1; + External_Name_Exp_Casing := Uppercase; + External_Name_Imp_Casing := Uppercase; + + -- Processing for g switch + + when 'g' => + Ptr := Ptr + 1; + GNAT_Mode := True; + Identifier_Character_Set := 'n'; + Warning_Mode := Treat_As_Error; + Check_Unreferenced := True; + Check_Withs := True; + + Set_Default_Style_Check_Options; + + -- Processing for G switch + + when 'G' => + Ptr := Ptr + 1; + Print_Generated_Code := True; + + -- Processing for h switch + + when 'h' => + Ptr := Ptr + 1; + Usage_Requested := True; + + -- Processing for H switch + + when 'H' => + Ptr := Ptr + 1; + HLO_Active := True; + + -- Processing for i switch + + when 'i' => + if Ptr = Max then + raise Bad_Switch; + end if; + + Ptr := Ptr + 1; + C := Switch_Chars (Ptr); + + if C in '1' .. '5' + or else C = '8' + or else C = '9' + or else C = 'p' + or else C = 'f' + or else C = 'n' + or else C = 'w' + then + Identifier_Character_Set := C; + Ptr := Ptr + 1; + + else + raise Bad_Switch; + end if; + + -- Processing for k switch + + when 'k' => + Ptr := Ptr + 1; + Scan_Pos (Switch_Chars, Max, Ptr, Maximum_File_Name_Length); + + -- Processing for l switch + + when 'l' => + Ptr := Ptr + 1; + Full_List := True; + + -- Processing for L switch + + when 'L' => + Ptr := Ptr + 1; + Zero_Cost_Exceptions_Set := True; + Zero_Cost_Exceptions_Val := False; + + -- Processing for m switch + + when 'm' => + Ptr := Ptr + 1; + Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors); + + -- Processing for n switch + + when 'n' => + Ptr := Ptr + 1; + Inline_Active := True; + + -- Processing for N switch + + when 'N' => + Ptr := Ptr + 1; + Inline_Active := True; + Front_End_Inlining := True; + + -- Processing for o switch + + when 'o' => + Ptr := Ptr + 1; + Suppress_Options.Overflow_Checks := False; + Opt.Enable_Overflow_Checks := True; + + -- Processing for O switch + + when 'O' => + Ptr := Ptr + 1; + Output_File_Name_Present := True; + + -- Processing for p switch + + when 'p' => + Ptr := Ptr + 1; + Suppress_Options.Access_Checks := True; + Suppress_Options.Accessibility_Checks := True; + Suppress_Options.Discriminant_Checks := True; + Suppress_Options.Division_Checks := True; + Suppress_Options.Elaboration_Checks := True; + Suppress_Options.Index_Checks := True; + Suppress_Options.Length_Checks := True; + Suppress_Options.Overflow_Checks := True; + Suppress_Options.Range_Checks := True; + Suppress_Options.Storage_Checks := True; + Suppress_Options.Tag_Checks := True; + + Validity_Checks_On := False; + Opt.Suppress_Checks := True; + Opt.Enable_Overflow_Checks := False; + + -- Processing for P switch + + when 'P' => + Ptr := Ptr + 1; + Polling_Required := True; + + -- Processing for q switch + + when 'q' => + Ptr := Ptr + 1; + Try_Semantics := True; + + -- Processing for q switch + + when 'Q' => + Ptr := Ptr + 1; + Force_ALI_Tree_File := True; + Try_Semantics := True; + + -- Processing for R switch + + when 'R' => + Ptr := Ptr + 1; + Back_Annotate_Rep_Info := True; + + if Ptr <= Max + and then Switch_Chars (Ptr) in '0' .. '9' + then + C := Switch_Chars (Ptr); + + if C in '4' .. '9' then + raise Bad_Switch; + else + List_Representation_Info := + Character'Pos (C) - Character'Pos ('0'); + Ptr := Ptr + 1; + end if; + + if Ptr <= Max and then Switch_Chars (Ptr) = 's' then + Ptr := Ptr + 1; + + if List_Representation_Info /= 0 then + List_Representation_Info_To_File := True; + end if; + end if; + + else + List_Representation_Info := 1; + end if; + + -- Processing for s switch + + when 's' => + if not First_Switch then + Osint.Fail + ("-gnats myust be first if combined with other switches"); + end if; + + Ptr := Ptr + 1; + Operating_Mode := Check_Syntax; + + -- Processing for t switch + + when 't' => + Ptr := Ptr + 1; + Tree_Output := True; + Back_Annotate_Rep_Info := True; + + -- Processing for T switch + + when 'T' => + Ptr := Ptr + 1; + Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor); + + -- Processing for u switch + + when 'u' => + Ptr := Ptr + 1; + List_Units := True; + + -- Processing for U switch + + when 'U' => + Ptr := Ptr + 1; + Unique_Error_Tag := True; + + -- Processing for v switch + + when 'v' => + Ptr := Ptr + 1; + Verbose_Mode := True; + + -- Processing for V switch + + when 'V' => + Store_Switch := False; + Storing (First_Stored) := 'V'; + Ptr := Ptr + 1; + + if Ptr > Max then + raise Bad_Switch; + + else + declare + OK : Boolean; + + begin + Set_Validity_Check_Options + (Switch_Chars (Ptr .. Max), OK, Ptr); + + if not OK then + raise Bad_Switch; + end if; + + for Index in First_Char + 1 .. Max loop + Storing (First_Stored + 1) := + Switch_Chars (Index); + Store_Compilation_Switch + (Storing (Storing'First .. First_Stored + 1)); + end loop; + end; + end if; + + Ptr := Max + 1; + + -- Processing for w switch + + when 'w' => + Store_Switch := False; + Storing (First_Stored) := 'w'; + Ptr := Ptr + 1; + + if Ptr > Max then + raise Bad_Switch; + end if; + + while Ptr <= Max loop + C := Switch_Chars (Ptr); + + case C is + + when 'a' => + Constant_Condition_Warnings := True; + Elab_Warnings := True; + Check_Unreferenced := True; + Check_Withs := True; + Check_Unreferenced_Formals := True; + Implementation_Unit_Warnings := True; + Ineffective_Inline_Warnings := True; + Warn_On_Redundant_Constructs := True; + + when 'A' => + Constant_Condition_Warnings := False; + Elab_Warnings := False; + Check_Unreferenced := False; + Check_Withs := False; + Check_Unreferenced_Formals := False; + Implementation_Unit_Warnings := False; + Warn_On_Biased_Rounding := False; + Warn_On_Dereference := False; + Warn_On_Hiding := False; + Warn_On_Redundant_Constructs := False; + Ineffective_Inline_Warnings := False; + + when 'b' => + Warn_On_Biased_Rounding := True; + + when 'B' => + Warn_On_Biased_Rounding := False; + + when 'c' => + Constant_Condition_Warnings := True; + + when 'C' => + Constant_Condition_Warnings := False; + + when 'd' => + Warn_On_Dereference := True; + + when 'D' => + Warn_On_Dereference := False; + + when 'e' => + Warning_Mode := Treat_As_Error; + + when 'f' => + Check_Unreferenced_Formals := True; + + when 'F' => + Check_Unreferenced_Formals := False; + + when 'h' => + Warn_On_Hiding := True; + + when 'H' => + Warn_On_Hiding := False; + + when 'i' => + Implementation_Unit_Warnings := True; + + when 'I' => + Implementation_Unit_Warnings := False; + + when 'l' => + Elab_Warnings := True; + + when 'L' => + Elab_Warnings := False; + + when 'o' => + Address_Clause_Overlay_Warnings := True; + + when 'O' => + Address_Clause_Overlay_Warnings := False; + + when 'p' => + Ineffective_Inline_Warnings := True; + + when 'P' => + Ineffective_Inline_Warnings := False; + + when 'r' => + Warn_On_Redundant_Constructs := True; + + when 'R' => + Warn_On_Redundant_Constructs := False; + + when 's' => + Warning_Mode := Suppress; + + when 'u' => + Check_Unreferenced := True; + Check_Withs := True; + Check_Unreferenced_Formals := True; + + when 'U' => + Check_Unreferenced := False; + Check_Withs := False; + Check_Unreferenced_Formals := False; + + -- Allow and ignore 'w' so that the old + -- format (e.g. -gnatwuwl) will work. + + when 'w' => + null; + + when others => + raise Bad_Switch; + end case; + + if C /= 'w' then + Storing (First_Stored + 1) := C; + Store_Compilation_Switch + (Storing (Storing'First .. First_Stored + 1)); + end if; + + Ptr := Ptr + 1; + end loop; + + return; + + -- Processing for W switch + + when 'W' => + Ptr := Ptr + 1; + + if Ptr > Max then + raise Bad_Switch; + end if; + + for J in WC_Encoding_Method loop + if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then + Wide_Character_Encoding_Method := J; + exit; + + elsif J = WC_Encoding_Method'Last then + raise Bad_Switch; + end if; + end loop; + + Upper_Half_Encoding := + Wide_Character_Encoding_Method in + WC_Upper_Half_Encoding_Method; + + Ptr := Ptr + 1; + + -- Processing for x switch + + when 'x' => + Ptr := Ptr + 1; + Xref_Active := False; + + -- Processing for X switch + + when 'X' => + Ptr := Ptr + 1; + Extensions_Allowed := True; + + -- Processing for y switch + + when 'y' => + Ptr := Ptr + 1; + + if Ptr > Max then + Set_Default_Style_Check_Options; + + else + Store_Switch := False; + Storing (First_Stored) := 'y'; + + declare + OK : Boolean; + Last_Stored : Integer; + + begin + Set_Style_Check_Options + (Switch_Chars (Ptr .. Max), OK, Ptr); + + if not OK then + raise Bad_Switch; + end if; + + Ptr := First_Char + 1; + + while Ptr <= Max loop + Last_Stored := First_Stored + 1; + Storing (Last_Stored) := Switch_Chars (Ptr); + + if Switch_Chars (Ptr) = 'M' then + loop + Ptr := Ptr + 1; + exit when Ptr > Max + or else Switch_Chars (Ptr) not in '0' .. '9'; + Last_Stored := Last_Stored + 1; + Storing (Last_Stored) := Switch_Chars (Ptr); + end loop; + + else + Ptr := Ptr + 1; + end if; + + Store_Compilation_Switch + (Storing (Storing'First .. Last_Stored)); + end loop; + end; + end if; + + -- Processing for z switch + + when 'z' => + Ptr := Ptr + 1; + + -- Allowed for compiler, only if this is the only + -- -z switch, we do not allow multiple occurrences + + if Distribution_Stub_Mode = No_Stubs then + case Switch_Chars (Ptr) is + when 'r' => + Distribution_Stub_Mode := Generate_Receiver_Stub_Body; + + when 'c' => + Distribution_Stub_Mode := Generate_Caller_Stub_Body; + + when others => + raise Bad_Switch; + end case; + + Ptr := Ptr + 1; + + end if; + + -- Processing for Z switch + + when 'Z' => + Ptr := Ptr + 1; + Zero_Cost_Exceptions_Set := True; + Zero_Cost_Exceptions_Val := True; + + -- Processing for 83 switch + + when '8' => + + if Ptr = Max then + raise Bad_Switch; + end if; + + Ptr := Ptr + 1; + + if Switch_Chars (Ptr) /= '3' then + raise Bad_Switch; + else + Ptr := Ptr + 1; + Ada_95 := False; + Ada_83 := True; + end if; + + -- Ignore extra switch character + + when '/' | '-' => + Ptr := Ptr + 1; + + -- Anything else is an error (illegal switch character) + + when others => + raise Bad_Switch; + end case; + end case; + + if Store_Switch then + Storing (First_Stored .. First_Stored + Ptr - First_Char - 1) := + Switch_Chars (First_Char .. Ptr - 1); + Store_Compilation_Switch + (Storing (Storing'First .. First_Stored + Ptr - First_Char - 1)); + end if; + + First_Switch := False; + end loop; + + exception + when Bad_Switch => + Osint.Fail ("invalid switch: ", (1 => C)); + + when Bad_Switch_Value => + Osint.Fail ("numeric value too big for switch: ", (1 => C)); + + when Missing_Switch_Value => + Osint.Fail ("missing numeric value for switch: ", (1 => C)); + + end Scan_Front_End_Switches; + + end Switch.C; diff -Nrc3pad gcc-3.2.3/gcc/ada/switch-c.ads gcc-3.3/gcc/ada/switch-c.ads *** gcc-3.2.3/gcc/ada/switch-c.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/switch-c.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,45 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S W I T C H - C -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package scans front end switches. Note that the body of Usage must be + -- coordinated with the switches that are recognized by this package. + -- The Usage package also acts as the official documentation for the + -- switches that are recognized. In addition, package Debug documents + -- the otherwise undocumented debug switches that are also recognized. + + package Switch.C is + + procedure Scan_Front_End_Switches (Switch_Chars : String); + -- Procedures to scan out front end switches stored in the given string. + -- The first character is known to be a valid switch character, and there + -- are no blanks or other switch terminator characters in the string, so + -- the entire string should consist of valid switch characters, except that + -- an optional terminating NUL character is allowed. A bad switch causes + -- a fatal error exit and control does not return. The call also sets + -- Usage_Requested to True if a ? switch is encountered. + + end Switch.C; diff -Nrc3pad gcc-3.2.3/gcc/ada/switch-m.adb gcc-3.3/gcc/ada/switch-m.adb *** gcc-3.2.3/gcc/ada/switch-m.adb 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/switch-m.adb 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,590 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S W I T C H - M -- + -- -- + -- B o d y -- + -- -- + -- -- + -- Copyright (C) 2001-2002 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + with Debug; use Debug; + with Osint; use Osint; + with Opt; use Opt; + with Table; + + package body Switch.M is + + package Normalized_Switches is new Table.Table + (Table_Component_Type => String_Access, + Table_Index_Type => Integer, + Table_Low_Bound => 1, + Table_Initial => 20, + Table_Increment => 100, + Table_Name => "Switch.C.Normalized_Switches"); + -- This table is used to keep the normalized switches, so that they may be + -- reused for subsequent invocations of Normalize_Compiler_Switches with + -- similar switches. + + Initial_Number_Of_Switches : constant := 10; + + Global_Switches : Argument_List_Access := null; + -- Used by function Normalize_Compiler_Switches + + --------------------------------- + -- Normalize_Compiler_Switches -- + --------------------------------- + + procedure Normalize_Compiler_Switches + (Switch_Chars : String; + Switches : in out Argument_List_Access; + Last : out Natural) + is + Switch_Starts_With_Gnat : Boolean; + + Ptr : Integer := Switch_Chars'First; + Max : constant Integer := Switch_Chars'Last; + C : Character := ' '; + + First_Char : Integer := Ptr; + Storing : String := Switch_Chars; + First_Stored : Positive := Ptr + 1; + Last_Stored : Positive := First_Stored; + + procedure Add_Switch_Component (S : String); + -- Add a new String_Access component in Switches. If a string equal + -- to S is already stored in the table Normalized_Switches, use it. + -- Other wise add a new component to the table. + + -------------------------- + -- Add_Switch_Component -- + -------------------------- + + procedure Add_Switch_Component (S : String) is + begin + -- If Switches is null, allocate a new array + + if Switches = null then + Switches := new Argument_List (1 .. Initial_Number_Of_Switches); + + -- otherwise, if Switches is full, extend it + + elsif Last = Switches'Last then + declare + New_Switches : Argument_List_Access := new Argument_List + (1 .. Switches'Length + Switches'Length); + begin + New_Switches (1 .. Switches'Length) := Switches.all; + Last := Switches'Length; + Switches := New_Switches; + end; + end if; + + -- If this is the first switch, Last designates the first component + if Last = 0 then + Last := Switches'First; + + else + Last := Last + 1; + end if; + + -- Look into the table Normalized_Switches for a similar string. + -- If one is found, put it at the added component, and return. + + for Index in 1 .. Normalized_Switches.Last loop + if S = Normalized_Switches.Table (Index).all then + Switches (Last) := Normalized_Switches.Table (Index); + return; + end if; + end loop; + + -- No string equal to S was found in the table Normalized_Switches. + -- Add a new component in the table. + + Switches (Last) := new String'(S); + Normalized_Switches.Increment_Last; + Normalized_Switches.Table (Normalized_Switches.Last) := + Switches (Last); + end Add_Switch_Component; + + -- Start of processing for Normalize_Compiler_Switches + + begin + Last := 0; + + if Ptr = Max or else Switch_Chars (Ptr) /= '-' then + return; + end if; + + Ptr := Ptr + 1; + + Switch_Starts_With_Gnat := + Ptr + 3 <= Max and then Switch_Chars (Ptr .. Ptr + 3) = "gnat"; + + if Switch_Starts_With_Gnat then + Ptr := Ptr + 4; + First_Stored := Ptr; + end if; + + while Ptr <= Max loop + First_Char := Ptr; + C := Switch_Chars (Ptr); + + -- Processing for a switch + + case Switch_Starts_With_Gnat is + + when False => + -- All switches that don't start with -gnat stay as is + + Add_Switch_Component (Switch_Chars); + return; + + when True => + + case C is + + -- One-letter switches + + when 'a' | 'A' | 'b' | 'c' | 'C' | 'D' | 'E' | 'f' | + 'F' | 'g' | 'h' | 'H' | 'k' | 'l' | 'L' | 'n' | 'N' | + 'o' | 'O' | 'p' | 'P' | 'q' | 'Q' | 'r' | 's' | 't' | + 'u' | 'U' | 'v' | 'x' | 'X' | 'Z' => + Storing (First_Stored) := C; + Add_Switch_Component + (Storing (Storing'First .. First_Stored)); + Ptr := Ptr + 1; + + -- One-letter switches followed by a positive number + + when 'm' | 'T' => + Storing (First_Stored) := C; + Last_Stored := First_Stored; + + loop + Ptr := Ptr + 1; + exit when Ptr > Max + or else Switch_Chars (Ptr) not in '0' .. '9'; + Last_Stored := Last_Stored + 1; + Storing (Last_Stored) := Switch_Chars (Ptr); + end loop; + + Add_Switch_Component + (Storing (Storing'First .. Last_Stored)); + + when 'd' => + Storing (First_Stored) := 'd'; + + while Ptr < Max loop + Ptr := Ptr + 1; + C := Switch_Chars (Ptr); + exit when C = ASCII.NUL or else C = '/' + or else C = '-'; + + if C in '1' .. '9' or else + C in 'a' .. 'z' or else + C in 'A' .. 'Z' + then + Storing (First_Stored + 1) := C; + Add_Switch_Component + (Storing (Storing'First .. First_Stored + 1)); + + else + Last := 0; + return; + end if; + end loop; + + return; + + when 'e' => + -- None of the -gnate switches (-gnatec and -gnatem) + -- need to be store in an ALI file. + + return; + + when 'i' => + Storing (First_Stored) := 'i'; + + Ptr := Ptr + 1; + + if Ptr > Max then + Last := 0; + return; + end if; + + C := Switch_Chars (Ptr); + + if C in '1' .. '5' + or else C = '8' + or else C = 'p' + or else C = 'f' + or else C = 'n' + or else C = 'w' + then + Storing (First_Stored + 1) := C; + Add_Switch_Component + (Storing (Storing'First .. First_Stored + 1)); + Ptr := Ptr + 1; + + else + Last := 0; + return; + end if; + + -- -gnatR may be followed by '0', '1', '2' or '3', + -- then by 's' + + when 'R' => + Last_Stored := First_Stored; + Storing (Last_Stored) := 'R'; + Ptr := Ptr + 1; + + if Ptr <= Max + and then Switch_Chars (Ptr) in '0' .. '9' + then + C := Switch_Chars (Ptr); + + if C in '4' .. '9' then + Last := 0; + return; + + else + Last_Stored := Last_Stored + 1; + Storing (Last_Stored) := C; + Ptr := Ptr + 1; + + if Ptr <= Max + and then Switch_Chars (Ptr) = 's' then + Last_Stored := Last_Stored + 1; + Storing (Last_Stored) := 's'; + Ptr := Ptr + 1; + end if; + end if; + end if; + + Add_Switch_Component + (Storing (Storing'First .. Last_Stored)); + + -- Multiple switches + + when 'V' | 'w' | 'y' => + Storing (First_Stored) := C; + Ptr := Ptr + 1; + + if Ptr > Max then + if C = 'y' then + Add_Switch_Component + (Storing (Storing'First .. First_Stored)); + + else + Last := 0; + return; + end if; + end if; + + while Ptr <= Max loop + C := Switch_Chars (Ptr); + Ptr := Ptr + 1; + + -- 'w' should be skipped in -gnatw + + if C /= 'w' or else Storing (First_Stored) /= 'w' then + + -- -gnatyMxxx + + if C = 'M' + and then Storing (First_Stored) = 'y' then + Last_Stored := First_Stored + 1; + Storing (Last_Stored) := 'M'; + + while Ptr <= Max loop + C := Switch_Chars (Ptr); + exit when C not in '0' .. '9'; + Last_Stored := Last_Stored + 1; + Storing (Last_Stored) := C; + Ptr := Ptr + 1; + end loop; + + -- If there is no digit after -gnatyM, + -- the switch is invalid. + + if Last_Stored = First_Stored + 1 then + Last := 0; + return; + + else + Add_Switch_Component + (Storing (Storing'First .. Last_Stored)); + end if; + + -- All other switches are -gnatxx + + else + Storing (First_Stored + 1) := C; + Add_Switch_Component + (Storing (Storing'First .. First_Stored + 1)); + end if; + end if; + end loop; + + -- Not a valid switch + + when others => + Last := 0; + return; + + end case; + + end case; + end loop; + end Normalize_Compiler_Switches; + + function Normalize_Compiler_Switches + (Switch_Chars : String) + return Argument_List + is + Last : Natural; + + begin + Normalize_Compiler_Switches (Switch_Chars, Global_Switches, Last); + + if Last = 0 then + return (1 .. 0 => null); + + else + return Global_Switches (Global_Switches'First .. Last); + end if; + + end Normalize_Compiler_Switches; + + ------------------------ + -- Scan_Make_Switches -- + ------------------------ + + procedure Scan_Make_Switches (Switch_Chars : String) is + Ptr : Integer := Switch_Chars'First; + Max : Integer := Switch_Chars'Last; + C : Character := ' '; + + begin + -- Skip past the initial character (must be the switch character) + + if Ptr = Max then + raise Bad_Switch; + + else + Ptr := Ptr + 1; + end if; + + -- A little check, "gnat" at the start of a switch is not allowed + -- except for the compiler (where it was already removed) + + if Switch_Chars'Length >= Ptr + 3 + and then Switch_Chars (Ptr .. Ptr + 3) = "gnat" + then + Osint.Fail + ("invalid switch: """, Switch_Chars, """ (gnat not needed here)"); + end if; + + -- Loop to scan through switches given in switch string + + while Ptr <= Max loop + C := Switch_Chars (Ptr); + + -- Processing for a switch + + case C is + + when 'a' => + Ptr := Ptr + 1; + Check_Readonly_Files := True; + + -- Processing for b switch + + when 'b' => + Ptr := Ptr + 1; + Bind_Only := True; + + -- Processing for c switch + + when 'c' => + Ptr := Ptr + 1; + Compile_Only := True; + + -- Processing for C switch + + when 'C' => + Ptr := Ptr + 1; + Create_Mapping_File := True; + + -- Processing for d switch + + when 'd' => + + -- Note: for the debug switch, the remaining characters in this + -- switch field must all be debug flags, since all valid switch + -- characters are also valid debug characters. This switch is not + -- documented on purpose because it is only used by the + -- implementors. + + -- Loop to scan out debug flags + + while Ptr < Max loop + Ptr := Ptr + 1; + C := Switch_Chars (Ptr); + exit when C = ASCII.NUL or else C = '/' or else C = '-'; + + if C in '1' .. '9' or else + C in 'a' .. 'z' or else + C in 'A' .. 'Z' + then + Set_Debug_Flag (C); + else + raise Bad_Switch; + end if; + end loop; + + -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This + -- is for backwards compatibility with old versions and usage. + + if Debug_Flag_XX then + Zero_Cost_Exceptions_Set := True; + Zero_Cost_Exceptions_Val := True; + end if; + + return; + + -- Processing for f switch + + when 'f' => + Ptr := Ptr + 1; + Force_Compilations := True; + + -- Processing for h switch + + when 'h' => + Ptr := Ptr + 1; + Usage_Requested := True; + + -- Processing for i switch + + when 'i' => + Ptr := Ptr + 1; + In_Place_Mode := True; + + -- Processing for j switch + + when 'j' => + Ptr := Ptr + 1; + + declare + Max_Proc : Pos; + begin + Scan_Pos (Switch_Chars, Max, Ptr, Max_Proc); + Maximum_Processes := Positive (Max_Proc); + end; + + -- Processing for k switch + + when 'k' => + Ptr := Ptr + 1; + Keep_Going := True; + + -- Processing for l switch + + when 'l' => + Ptr := Ptr + 1; + Link_Only := True; + + when 'M' => + Ptr := Ptr + 1; + List_Dependencies := True; + + -- Processing for n switch + + when 'n' => + Ptr := Ptr + 1; + Do_Not_Execute := True; + + -- Processing for o switch + + when 'o' => + Ptr := Ptr + 1; + + if Output_File_Name_Present then + raise Too_Many_Output_Files; + else + Output_File_Name_Present := True; + end if; + + -- Processing for q switch + + when 'q' => + Ptr := Ptr + 1; + Quiet_Output := True; + + -- Processing for s switch + + when 's' => + Ptr := Ptr + 1; + Check_Switches := True; + + -- Processing for v switch + + when 'v' => + Ptr := Ptr + 1; + Verbose_Mode := True; + + -- Processing for z switch + + when 'z' => + Ptr := Ptr + 1; + No_Main_Subprogram := True; + + -- Ignore extra switch character + + when '/' | '-' => + Ptr := Ptr + 1; + + -- Anything else is an error (illegal switch character) + + when others => + raise Bad_Switch; + + end case; + end loop; + + exception + when Bad_Switch => + Osint.Fail ("invalid switch: ", (1 => C)); + + when Bad_Switch_Value => + Osint.Fail ("numeric value too big for switch: ", (1 => C)); + + when Missing_Switch_Value => + Osint.Fail ("missing numeric value for switch: ", (1 => C)); + + when Too_Many_Output_Files => + Osint.Fail ("duplicate -o switch"); + + end Scan_Make_Switches; + + end Switch.M; diff -Nrc3pad gcc-3.2.3/gcc/ada/switch-m.ads gcc-3.3/gcc/ada/switch-m.ads *** gcc-3.2.3/gcc/ada/switch-m.ads 1970-01-01 00:00:00.000000000 +0000 --- gcc-3.3/gcc/ada/switch-m.ads 2002-10-23 08:04:17.000000000 +0000 *************** *** 0 **** --- 1,75 ---- + ------------------------------------------------------------------------------ + -- -- + -- GNAT COMPILER COMPONENTS -- + -- -- + -- S W I T C H - M -- + -- -- + -- S p e c -- + -- -- + -- -- + -- Copyright (C) 2001 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- -- + -- 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, 59 Temple Place - Suite 330, Boston, -- + -- MA 02111-1307, USA. -- + -- -- + -- GNAT was originally developed by the GNAT team at New York University. -- + -- Extensive contributions were provided by Ada Core Technologies Inc. -- + -- -- + ------------------------------------------------------------------------------ + + -- This package scans make switches. Note that the body of Usage must be + -- coordinated with the switches that are recognized by this package. + -- The Usage package also acts as the official documentation for the + -- switches that are recognized. In addition, package Debug documents + -- the otherwise undocumented debug switches that are also recognized. + + with GNAT.OS_Lib; use GNAT.OS_Lib; + + package Switch.M is + + procedure Scan_Make_Switches (Switch_Chars : String); + -- Procedures to scan out binder switches stored in the given string. + -- The first character is known to be a valid switch character, and there + -- are no blanks or other switch terminator characters in the string, so + -- the entire string should consist of valid switch characters, except that + -- an optional terminating NUL character is allowed. A bad switch causes + -- a fatal error exit and control does not return. The call also sets + -- Usage_Requested to True if a ? switch is encountered. + + procedure Normalize_Compiler_Switches + (Switch_Chars : String; + Switches : in out Argument_List_Access; + Last : out Natural); + -- Takes a compiler switch which potentially is equivalent to more + -- that one simple switches and returns the equivalent list of simple + -- switches that are stored in an ALI file. Switches will be extended + -- if initially null or too short. Last indicates the index in Switches + -- of the last simple switch. Last is equal to zero, if it has been + -- determined that Switch_Chars is ill-formed or does not contain any + -- switch that should be stored in an ALI file. Otherwise, the list of + -- simple switches is Switches (Switches'First .. Last). + -- + -- Example: if Switch_Chars is equal to "-gnatAwue", then the list of + -- simple switches will have 3 components: -gnatA, -gnatwu, -gnatwe. + -- + -- The String_Access components of Switches should not be deallocated: + -- they are shallow copies of components in a table in the body. + + function Normalize_Compiler_Switches + (Switch_Chars : String) + return Argument_List; + -- Similar to the previous procedure. The return value is the list of + -- simple switches. It may be an empty array if it has been determined + -- that Switch_Chars is ill-formed or does not contain any switch that + -- should be stored in an ALI file. The String_Access components of the + -- returned value should not be deallocated. + + end Switch.M; diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wwdcha.adb gcc-3.3/gcc/ada/s-wwdcha.adb *** gcc-3.2.3/gcc/ada/s-wwdcha.adb 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/s-wwdcha.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wwdcha.ads gcc-3.3/gcc/ada/s-wwdcha.ads *** gcc-3.2.3/gcc/ada/s-wwdcha.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/s-wwdcha.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wwdenu.adb gcc-3.3/gcc/ada/s-wwdenu.adb *** gcc-3.2.3/gcc/ada/s-wwdenu.adb 2002-05-04 03:28:52.000000000 +0000 --- gcc-3.3/gcc/ada/s-wwdenu.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wwdenu.ads gcc-3.3/gcc/ada/s-wwdenu.ads *** gcc-3.2.3/gcc/ada/s-wwdenu.ads 2002-05-04 03:28:52.000000000 +0000 --- gcc-3.3/gcc/ada/s-wwdenu.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wwdwch.adb gcc-3.3/gcc/ada/s-wwdwch.adb *** gcc-3.2.3/gcc/ada/s-wwdwch.adb 2002-05-04 03:28:52.000000000 +0000 --- gcc-3.3/gcc/ada/s-wwdwch.adb 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/s-wwdwch.ads gcc-3.3/gcc/ada/s-wwdwch.ads *** gcc-3.2.3/gcc/ada/s-wwdwch.ads 2002-05-07 08:22:31.000000000 +0000 --- gcc-3.3/gcc/ada/s-wwdwch.ads 2002-10-23 07:33:31.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/sysdep.c gcc-3.3/gcc/ada/sysdep.c *** gcc-3.2.3/gcc/ada/sysdep.c 2002-08-26 07:11:39.000000000 +0000 --- gcc-3.3/gcc/ada/sysdep.c 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** * * * C Implementation File * * * - * $Revision: 1.5.10.1.4.1 $ * * ! * Copyright (C) 1992-2001 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- * --- 6,13 ---- * * * C Implementation File * * * * * ! * Copyright (C) 1992-2002 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- * *************** *** 36,41 **** --- 35,42 ---- GNAT Run Time Library */ #ifdef __vxworks + #include "ioLib.h" + #include "selectLib.h" #include "vxWorks.h" #endif #ifdef IN_RTS *************** *** 142,159 **** */ #if defined(WINNT) || defined (MSDOS) || defined (__EMX__) ! const char *mode_read_text = "rt"; ! const char *mode_write_text = "wt"; ! const char *mode_append_text = "at"; ! const char *mode_read_binary = "rb"; ! const char *mode_write_binary = "wb"; ! const char *mode_append_binary = "ab"; ! const char *mode_read_text_plus = "r+t"; ! const char *mode_write_text_plus = "w+t"; ! const char *mode_append_text_plus = "a+t"; ! const char *mode_read_binary_plus = "r+b"; ! const char *mode_write_binary_plus = "w+b"; ! const char *mode_append_binary_plus = "a+b"; const char __gnat_text_translation_required = 1; void --- 143,160 ---- */ #if defined(WINNT) || defined (MSDOS) || defined (__EMX__) ! static const char *mode_read_text = "rt"; ! static const char *mode_write_text = "wt"; ! static const char *mode_append_text = "at"; ! static const char *mode_read_binary = "rb"; ! static const char *mode_write_binary = "wb"; ! static const char *mode_append_binary = "ab"; ! static const char *mode_read_text_plus = "r+t"; ! static const char *mode_write_text_plus = "w+t"; ! static const char *mode_append_text_plus = "a+t"; ! static const char *mode_read_binary_plus = "r+b"; ! static const char *mode_write_binary_plus = "w+b"; ! static const char *mode_append_binary_plus = "a+b"; const char __gnat_text_translation_required = 1; void *************** static void winflush_nt () *** 247,264 **** #else ! const char *mode_read_text = "r"; ! const char *mode_write_text = "w"; ! const char *mode_append_text = "a"; ! const char *mode_read_binary = "r"; ! const char *mode_write_binary = "w"; ! const char *mode_append_binary = "a"; ! const char *mode_read_text_plus = "r+"; ! const char *mode_write_text_plus = "w+"; ! const char *mode_append_text_plus = "a+"; ! const char *mode_read_binary_plus = "r+"; ! const char *mode_write_binary_plus = "w+"; ! const char *mode_append_binary_plus = "a+"; const char __gnat_text_translation_required = 0; /* These functions do nothing in non-DOS systems. */ --- 248,265 ---- #else ! static const char *mode_read_text = "r"; ! static const char *mode_write_text = "w"; ! static const char *mode_append_text = "a"; ! static const char *mode_read_binary = "r"; ! static const char *mode_write_binary = "w"; ! static const char *mode_append_binary = "a"; ! static const char *mode_read_text_plus = "r+"; ! static const char *mode_write_text_plus = "w+"; ! static const char *mode_append_text_plus = "a+"; ! static const char *mode_read_binary_plus = "r+"; ! static const char *mode_write_binary_plus = "w+"; ! static const char *mode_append_binary_plus = "a+"; const char __gnat_text_translation_required = 0; /* These functions do nothing in non-DOS systems. */ *************** __gnat_ttyname (filedes) *** 292,298 **** #if defined (linux) || defined (sun) || defined (sgi) || defined (__EMX__) \ || (defined (__osf__) && ! defined (__alpha_vxworks)) || defined (WINNT) \ ! || defined (__MACHTEN__) || defined (__CYGWIN__) #include #else --- 293,301 ---- #if defined (linux) || defined (sun) || defined (sgi) || defined (__EMX__) \ || (defined (__osf__) && ! defined (__alpha_vxworks)) || defined (WINNT) \ ! || defined (__MACHTEN__) || defined (hpux) || defined (_AIX) \ ! || (defined (__svr4__) && defined (i386)) || defined (__Lynx__) \ ! || defined (__CYGWIN__) #include #else *************** getc_immediate_common (stream, ch, end_o *** 347,353 **** { #if defined (linux) || defined (sun) || defined (sgi) || defined (__EMX__) \ || (defined (__osf__) && ! defined (__alpha_vxworks)) \ ! || defined (__CYGWIN__) || defined (__MACHTEN__) char c; int nread; int good_one = 0; --- 350,358 ---- { #if defined (linux) || defined (sun) || defined (sgi) || defined (__EMX__) \ || (defined (__osf__) && ! defined (__alpha_vxworks)) \ ! || defined (__CYGWIN__) || defined (__MACHTEN__) || defined (hpux) \ ! || defined (_AIX) || (defined (__svr4__) && defined (i386)) \ ! || defined (__Lynx__) char c; int nread; int good_one = 0; *************** getc_immediate_common (stream, ch, end_o *** 359,392 **** { tcgetattr (fd, &termios_rec); memcpy (&otermios_rec, &termios_rec, sizeof (struct termios)); - while (! good_one) - { - /* Set RAW mode */ - termios_rec.c_lflag = termios_rec.c_lflag & ~ICANON; - #if defined(sgi) || defined (sun) || defined (__EMX__) || defined (__osf__) \ - || defined (linux) || defined (__MACHTEN__) - eof_ch = termios_rec.c_cc[VEOF]; ! /* If waiting (i.e. Get_Immediate (Char)), set MIN = 1 and wait for ! a character forever. This doesn't seem to effect Ctrl-Z or ! Ctrl-C processing except on OS/2 where Ctrl-C won't work right ! unless we do a read loop. Luckily we can delay a bit between ! iterations. If not waiting (i.e. Get_Immediate (Char, Available)), ! don't wait for anything but timeout immediately. */ #ifdef __EMX__ ! termios_rec.c_cc[VMIN] = 0; ! termios_rec.c_cc[VTIME] = waiting; #else ! termios_rec.c_cc[VMIN] = waiting; ! termios_rec.c_cc[VTIME] = 0; #endif #endif ! tcsetattr (fd, TCSANOW, &termios_rec); ! /* Read() is used here instead of fread(), because fread() doesn't work on Solaris5 and Sunos4 in this situation. Maybe because we are mixing calls that use file descriptors and streams. */ - nread = read (fd, &c, 1); if (nread > 0) { --- 364,400 ---- { tcgetattr (fd, &termios_rec); memcpy (&otermios_rec, &termios_rec, sizeof (struct termios)); ! /* Set RAW mode, with no echo */ ! termios_rec.c_lflag = termios_rec.c_lflag & ~ICANON & ~ECHO; ! ! #if defined(linux) || defined (sun) || defined (sgi) || defined (__EMX__) \ ! || defined (__osf__) || defined (__MACHTEN__) || defined (hpux) \ ! || defined (_AIX) || (defined (__svr4__) && defined (i386)) \ ! || defined (__Lynx__) ! eof_ch = termios_rec.c_cc[VEOF]; ! ! /* If waiting (i.e. Get_Immediate (Char)), set MIN = 1 and wait for ! a character forever. This doesn't seem to effect Ctrl-Z or ! Ctrl-C processing except on OS/2 where Ctrl-C won't work right ! unless we do a read loop. Luckily we can delay a bit between ! iterations. If not waiting (i.e. Get_Immediate (Char, Available)), ! don't wait for anything but timeout immediately. */ #ifdef __EMX__ ! termios_rec.c_cc[VMIN] = 0; ! termios_rec.c_cc[VTIME] = waiting; #else ! termios_rec.c_cc[VMIN] = waiting; ! termios_rec.c_cc[VTIME] = 0; #endif #endif ! tcsetattr (fd, TCSANOW, &termios_rec); ! while (! good_one) ! { ! /* Read is used here instead of fread, because fread doesn't work on Solaris5 and Sunos4 in this situation. Maybe because we are mixing calls that use file descriptors and streams. */ nread = read (fd, &c, 1); if (nread > 0) { *************** getc_immediate_common (stream, ch, end_o *** 414,422 **** good_one = 1; } else ! { ! good_one = 0; ! } } tcsetattr (fd, TCSANOW, &otermios_rec); --- 422,428 ---- good_one = 1; } else ! good_one = 0; } tcsetattr (fd, TCSANOW, &otermios_rec); *************** getc_immediate_common (stream, ch, end_o *** 424,431 **** } else ! #else ! #if defined (VMS) int fd = fileno (stream); if (isatty (fd)) --- 430,436 ---- } else ! #elif defined (VMS) int fd = fileno (stream); if (isatty (fd)) *************** getc_immediate_common (stream, ch, end_o *** 435,440 **** --- 440,446 ---- decc$bsd_initscr (); initted = 1; } + decc$bsd_cbreak (); *ch = decc$bsd_wgetch (decc$ga_stdscr); *************** getc_immediate_common (stream, ch, end_o *** 447,454 **** decc$bsd_nocbreak (); } else ! #else ! #if defined (__MINGW32__) int fd = fileno (stream); int char_waiting; int eot_ch = 4; /* Ctrl-D */ --- 453,459 ---- decc$bsd_nocbreak (); } else ! #elif defined (__MINGW32__) int fd = fileno (stream); int char_waiting; int eot_ch = 4; /* Ctrl-D */ *************** getc_immediate_common (stream, ch, end_o *** 457,464 **** { if (waiting) { ! *ch = getch(); ! (*winflush_function)(); if (*ch == eot_ch) *end_of_file = 1; --- 462,469 ---- { if (waiting) { ! *ch = getch (); ! (*winflush_function) (); if (*ch == eot_ch) *end_of_file = 1; *************** getc_immediate_common (stream, ch, end_o *** 474,481 **** if (char_waiting == 1) { *avail = 1; ! *ch = getch(); ! (*winflush_function)(); if (*ch == eot_ch) *end_of_file = 1; --- 479,486 ---- if (char_waiting == 1) { *avail = 1; ! *ch = getch (); ! (*winflush_function) (); if (*ch == eot_ch) *end_of_file = 1; *************** getc_immediate_common (stream, ch, end_o *** 490,502 **** } } else ! #endif ! #endif #endif { /* If we're not on a terminal, then we don't need any fancy processing. Also this is the only thing that's left if we're not on one of the ! supported systems. */ *ch = fgetc (stream); if (feof (stream)) { --- 495,588 ---- } } else ! #elif defined (__vxworks) ! /* Bit masks of file descriptors to read from. */ ! struct fd_set readFds; ! /* Timeout before select returns if nothing can be read. */ ! struct timeval timeOut; ! char c; ! int fd = fileno (stream); ! int nread; ! int option; ! int readable; ! int status; ! int width; ! ! if (isatty (fd)) ! { ! /* If we do not want to wait, we have to set up fd in RAW mode. This ! should be done outside this function as setting fd in RAW mode under ! vxWorks flushes the buffer of fd. If the RAW mode was set here, the ! buffer would be empty and we would always return that no character ! is available */ ! if (! waiting) ! { ! /* Initialization of timeOut for its use with select. */ ! timeOut.tv_sec = 0; ! timeOut.tv_usec = 0; ! ! /* Initialization of readFds for its use with select; ! FD is the only file descriptor to be monitored */ ! FD_ZERO (&readFds); ! FD_SET (fd, &readFds); ! width = 2; ! ! /* We do all this processing to emulate a non blocking read. */ ! readable = select (width, &readFds, NULL, NULL, &timeOut); ! if (readable == ERROR) ! *avail = -1, *end_of_file = -1; ! /* No character available in input. */ ! else if (readable == 0) ! *avail = 0, *end_of_file = 0; ! else ! { ! nread = read (fd, &c, 1); ! if (nread > 0) ! *avail = 1, *end_of_file = 0; ! /* End Of File. */ ! else if (nread == 0) ! *avail = 0, *end_of_file = 1; ! /* Error. */ ! else ! *avail = -1, *end_of_file = -1; ! } ! } ! ! /* We have to wait until we get a character */ ! else ! { ! *avail = -1; ! *end_of_file = -1; ! ! /* Save the current mode of FD. */ ! option = ioctl (fd, FIOGETOPTIONS, 0); ! ! /* Set FD in RAW mode. */ ! status = ioctl (fd, FIOSETOPTIONS, OPT_RAW); ! if (status != -1) ! { ! nread = read (fd, &c, 1); ! if (nread > 0) ! *avail = 1, *end_of_file = 0; ! /* End of file. */ ! else if (nread == 0) ! *avail = 0, *end_of_file = 1; ! /* Else there is an ERROR. */ ! } ! ! /* Revert FD to its previous mode. */ ! status = ioctl (fd, FIOSETOPTIONS, option); ! } ! ! *ch = c; ! } ! else #endif { /* If we're not on a terminal, then we don't need any fancy processing. Also this is the only thing that's left if we're not on one of the ! supported systems; which means that for non supported systems, ! get_immediate may wait for a carriage return on terminals. */ *ch = fgetc (stream); if (feof (stream)) { *************** extern void (*Unlock_Task) PARAMS ((void *** 584,590 **** provide localtime_r, but in the library libc_r which doesn't get included systematically, so we can't use it. */ ! exrern void struct tm *__gnat_localtime_r PARAMS ((const time_t *, struct tm *)); struct tm * --- 670,676 ---- provide localtime_r, but in the library libc_r which doesn't get included systematically, so we can't use it. */ ! extern void struct tm *__gnat_localtime_r PARAMS ((const time_t *, struct tm *)); struct tm * diff -Nrc3pad gcc-3.2.3/gcc/ada/system.ads gcc-3.3/gcc/ada/system.ads *** gcc-3.2.3/gcc/ada/system.ads 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/system.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 7,15 **** -- S p e c -- -- (Compiler Version) -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- --- 7,14 ---- -- S p e c -- -- (Compiler Version) -- -- -- -- -- ! -- Copyright (C) 1992-2002 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- *************** *** 38,43 **** --- 37,47 ---- -- -- ------------------------------------------------------------------------------ + -- This version of System is a generic version that is used in building + -- the compiler. Right now, we have a host/target problem if we try to + -- use the "proper" System, and since the compiler itself does not care + -- about most System parameters, this generic version works fine. + package System is pragma Pure (System); -- Note that we take advantage of the implementation permission to *************** pragma Pure (System); *** 60,66 **** Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := Standard'Tick; -- Storage-related Declarations --- 64,70 ---- Max_Mantissa : constant := 63; Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ! Tick : constant := 1.0; -- Storage-related Declarations *************** pragma Pure (System); *** 93,119 **** -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; ! Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer ! range 0 .. Standard'Max_Interrupt_Priority; ! ! subtype Priority is Any_Priority ! range 0 .. Standard'Max_Priority; ! ! -- Functional notation is needed in the following to avoid visibility ! -- problems when this package is compiled through rtsfind in the middle ! -- of another compilation. ! ! subtype Interrupt_Priority is Any_Priority ! range ! Standard."+" (Standard'Max_Priority, 1) .. ! Standard'Max_Interrupt_Priority; ! Default_Priority : constant Priority := ! Standard."/" (Standard."+" (Priority'First, Priority'Last), 2); private --- 97,110 ---- -- Priority-related Declarations (RM D.1) ! Max_Priority : constant Positive := 30; Max_Interrupt_Priority : constant Positive := 31; ! subtype Any_Priority is Integer range 0 .. 31; ! subtype Priority is Any_Priority range 0 .. 30; ! subtype Interrupt_Priority is Any_Priority range 31 .. 31; ! Default_Priority : constant Priority := 15; private *************** private *** 138,145 **** --- 129,139 ---- -- do not use floating-point anyway in the compiler). AAMP : constant Boolean := False; + Backend_Divide_Checks : constant Boolean := False; + Backend_Overflow_Checks : constant Boolean := False; Command_Line_Args : constant Boolean := True; Denorm : constant Boolean := True; + Fractional_Fixed_Ops : constant Boolean := False; Frontend_Layout : constant Boolean := False; Functions_Return_By_DSP : constant Boolean := False; Long_Shifts_Inlined : constant Boolean := True; diff -Nrc3pad gcc-3.2.3/gcc/ada/table.adb gcc-3.3/gcc/ada/table.adb *** gcc-3.2.3/gcc/ada/table.adb 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/table.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** *** 35,43 **** with Debug; use Debug; with Opt; ! with Output; use Output; ! with System; use System; ! with Tree_IO; use Tree_IO; package body Table is package body Table is --- 34,45 ---- with Debug; use Debug; with Opt; ! with Output; use Output; ! pragma Elaborate_All (Output); ! with System; use System; ! with Tree_IO; use Tree_IO; ! with System.Memory; use System.Memory; ! with System.Address_To_Access_Conversions; package body Table is package body Table is *************** package body Table is *** 49,57 **** -- Number of entries in currently allocated table. The value of zero -- ensures that we initially allocate the table. - procedure free (T : Table_Ptr); - pragma Import (C, free); - ----------------------- -- Local Subprograms -- ----------------------- --- 51,56 ---- *************** package body Table is *** 65,70 **** --- 64,81 ---- -- Return Null_Address if the table length is zero, -- Table (First)'Address if not. + package Table_Conversions is + new System.Address_To_Access_Conversions (Big_Table_Type); + -- Address and Access conversions for a Table object. + + function To_Address (Table : Table_Ptr) return Address; + pragma Inline (To_Address); + -- Returns the Address for the Table object. + + function To_Pointer (Table : Address) return Table_Ptr; + pragma Inline (To_Pointer); + -- Returns the Access pointer for the Table object. + ------------ -- Append -- ------------ *************** package body Table is *** 90,96 **** procedure Free is begin ! free (Table); Table := null; Length := 0; end Free; --- 101,107 ---- procedure Free is begin ! Free (To_Address (Table)); Table := null; Length := 0; end Free; *************** package body Table is *** 151,169 **** ---------------- procedure Reallocate is ! ! function realloc ! (memblock : Table_Ptr; ! size : size_t) ! return Table_Ptr; ! pragma Import (C, realloc); ! ! function malloc ! (size : size_t) ! return Table_Ptr; ! pragma Import (C, malloc); ! ! New_Size : size_t; begin if Max < Last_Val then --- 162,168 ---- ---------------- procedure Reallocate is ! New_Size : Memory.size_t; begin if Max < Last_Val then *************** package body Table is *** 191,207 **** end if; New_Size := ! size_t ((Max - Min + 1) * ! (Table_Type'Component_Size / Storage_Unit)); if Table = null then ! Table := malloc (New_Size); elsif New_Size > 0 then Table := ! realloc ! (memblock => Table, ! size => New_Size); end if; if Length /= 0 and then Table = null then --- 190,205 ---- end if; New_Size := ! Memory.size_t ((Max - Min + 1) * ! (Table_Type'Component_Size / Storage_Unit)); if Table = null then ! Table := To_Pointer (Alloc (New_Size)); elsif New_Size > 0 then Table := ! To_Pointer (Realloc (Ptr => To_Address (Table), ! Size => New_Size)); end if; if Length /= 0 and then Table = null then *************** package body Table is *** 231,237 **** procedure Restore (T : Saved_Table) is begin ! free (Table); Last_Val := T.Last_Val; Max := T.Max; Table := T.Table; --- 229,235 ---- procedure Restore (T : Saved_Table) is begin ! Free (To_Address (Table)); Last_Val := T.Last_Val; Max := T.Max; Table := T.Table; *************** package body Table is *** 289,294 **** --- 287,311 ---- end if; end Set_Last; + ---------------- + -- To_Address -- + ---------------- + + function To_Address (Table : Table_Ptr) return Address is + begin + return Table_Conversions.To_Address + (Table_Conversions.Object_Pointer (Table)); + end To_Address; + + ---------------- + -- To_Pointer -- + ---------------- + + function To_Pointer (Table : Address) return Table_Ptr is + begin + return Table_Ptr (Table_Conversions.To_Pointer (Table)); + end To_Pointer; + ---------------------------- -- Tree_Get_Table_Address -- ---------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/table.ads gcc-3.3/gcc/ada/table.ads *** gcc-3.2.3/gcc/ada/table.ads 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/table.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/targparm.adb gcc-3.3/gcc/ada/targparm.adb *** gcc-3.2.3/gcc/ada/targparm.adb 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/targparm.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** with Namet; use Namet; *** 30,52 **** with Output; use Output; with Sinput; use Sinput; with Sinput.L; use Sinput.L; - with Fname.UF; use Fname.UF; with Types; use Types; package body Targparm is type Targparm_Tags is ! (AAM, CLA, DEN, DSP, FEL, HIM, LSI, MOV, ! MRN, SCD, SCP, SNZ, UAM, VMS, ZCD, ZCG, ZCF); Targparm_Flags : array (Targparm_Tags) of Boolean := (others => False); -- Flag is set True if corresponding parameter is scanned AAM_Str : aliased constant Source_Buffer := "AAMP"; CLA_Str : aliased constant Source_Buffer := "Command_Line_Args"; DEN_Str : aliased constant Source_Buffer := "Denorm"; DSP_Str : aliased constant Source_Buffer := "Functions_Return_By_DSP"; FEL_Str : aliased constant Source_Buffer := "Frontend_Layout"; HIM_Str : aliased constant Source_Buffer := "High_Integrity_Mode"; LSI_Str : aliased constant Source_Buffer := "Long_Shifts_Inlined"; MOV_Str : aliased constant Source_Buffer := "Machine_Overflows"; --- 29,71 ---- with Output; use Output; with Sinput; use Sinput; with Sinput.L; use Sinput.L; with Types; use Types; package body Targparm is type Targparm_Tags is ! (AAM, -- AAMP; ! BDC, -- Backend_Divide_Checks; ! BOC, -- Backend_Overflow_Checks; ! CLA, -- Command_Line_Args; ! DEN, -- Denorm; ! DSP, -- Functions_Return_By_DSP; ! FEL, -- Frontend_Layout; ! FFO, -- Fractional_Fixed_Ops ! HIM, -- High_Integrity_Mode; ! LSI, -- Long_Shifts_Inlined; ! MOV, -- Machine_Overflows; ! MRN, -- Machine_Rounds; ! SCD, -- Stack_Check_Default; ! SCP, -- Stack_Check_Probes; ! SNZ, -- Signed_Zeros; ! UAM, -- Use_Ada_Main_Program_Name; ! VMS, -- OpenVMS; ! ZCD, -- ZCX_By_Default; ! ZCG, -- GCC_ZCX_Support; ! ZCF); -- Front_End_ZCX_Support; Targparm_Flags : array (Targparm_Tags) of Boolean := (others => False); -- Flag is set True if corresponding parameter is scanned AAM_Str : aliased constant Source_Buffer := "AAMP"; + BDC_Str : aliased constant Source_Buffer := "Backend_Divide_Checks"; + BOC_Str : aliased constant Source_Buffer := "Backend_Overflow_Checks"; CLA_Str : aliased constant Source_Buffer := "Command_Line_Args"; DEN_Str : aliased constant Source_Buffer := "Denorm"; DSP_Str : aliased constant Source_Buffer := "Functions_Return_By_DSP"; FEL_Str : aliased constant Source_Buffer := "Frontend_Layout"; + FFO_Str : aliased constant Source_Buffer := "Fractional_Fixed_Ops"; HIM_Str : aliased constant Source_Buffer := "High_Integrity_Mode"; LSI_Str : aliased constant Source_Buffer := "Long_Shifts_Inlined"; MOV_Str : aliased constant Source_Buffer := "Machine_Overflows"; *************** package body Targparm is *** 63,72 **** --- 82,94 ---- type Buffer_Ptr is access constant Source_Buffer; Targparm_Str : array (Targparm_Tags) of Buffer_Ptr := (AAM_Str'Access, + BDC_Str'Access, + BOC_Str'Access, CLA_Str'Access, DEN_Str'Access, DSP_Str'Access, FEL_Str'Access, + FFO_Str'Access, HIM_Str'Access, LSI_Str'Access, MOV_Str'Access, *************** package body Targparm is *** 100,108 **** -- Records boolean from system line begin ! Name_Buffer (1 .. 6) := "system"; ! Name_Len := 6; ! N := File_Name_Of_Spec (Name_Find); S := Load_Source_File (N); if S = No_Source_File then --- 122,130 ---- -- Records boolean from system line begin ! Name_Buffer (1 .. 10) := "system.ads"; ! Name_Len := 10; ! N := Name_Find; S := Load_Source_File (N); if S = No_Source_File then *************** package body Targparm is *** 163,172 **** --- 185,197 ---- case K is when AAM => AAMP_On_Target := Result; + when BDC => Backend_Divide_Checks_On_Target := Result; + when BOC => Backend_Overflow_Checks_On_Target := Result; when CLA => Command_Line_Args_On_Target := Result; when DEN => Denorm_On_Target := Result; when DSP => Functions_Return_By_DSP_On_Target := Result; when FEL => Frontend_Layout_On_Target := Result; + when FFO => Fractional_Fixed_Ops_On_Target := Result; when HIM => High_Integrity_Mode_On_Target := Result; when LSI => Long_Shifts_Inlined_On_Target := Result; when MOV => Machine_Overflows_On_Target := Result; diff -Nrc3pad gcc-3.2.3/gcc/ada/targparm.ads gcc-3.3/gcc/ada/targparm.ads *** gcc-3.2.3/gcc/ada/targparm.ads 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/targparm.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1999-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package Targparm is *** 49,55 **** -- The following parameters correspond to the variables defined in the -- private part of System (without the terminating _On_Target). Note ! -- that it is required that all parameters be specified in system.ads. ----------------------------------- -- Control of Exception Handling -- --- 48,79 ---- -- The following parameters correspond to the variables defined in the -- private part of System (without the terminating _On_Target). Note ! -- that it is required that all parameters defined here be specified ! -- in the target specific version of system.ads (there are no defaults). ! ! -- All these parameters should be regarded as read only by all clients ! -- of the package. The only way they get modified is by calling the ! -- Get_Target_Parameters routine which reads the values from System. ! ! ------------------------------- ! -- Backend Arithmetic Checks -- ! ------------------------------- ! ! -- Divide and overflow checks are either done in the front end or ! -- back end. The front end will generate checks when required unless ! -- the corresponding parameter here is set to indicate that the back ! -- end will generate the required checks (or that the checks are ! -- automatically performed by the hardware in an appropriate form). ! ! Backend_Divide_Checks_On_Target : Boolean; ! -- Set True if the back end generates divide checks, or if the hardware ! -- checks automatically. Set False if the front end must generate the ! -- required tests using explicit expanded code. ! ! Backend_Overflow_Checks_On_Target : Boolean; ! -- Set True if the back end generates arithmetic overflow checks, or if ! -- the hardware checks automatically. Set False if the front end must ! -- generate the required tests using explicit expanded code. ----------------------------------- -- Control of Exception Handling -- *************** package Targparm is *** 75,82 **** -- available. ZCX_By_Default_On_Target : Boolean; ! -- Indicates if zero cost exceptions are active by default. Can be modified ! -- by the use of -gnatZ and -gnatL switches. GCC_ZCX_Support_On_Target : Boolean; -- Indicates that when ZCX is active the mechanism to be used is the --- 99,105 ---- -- available. ZCX_By_Default_On_Target : Boolean; ! -- Indicates if zero cost exceptions are active by default. GCC_ZCX_Support_On_Target : Boolean; -- Indicates that when ZCX is active the mechanism to be used is the *************** package Targparm is *** 225,230 **** --- 248,263 ---- OpenVMS_On_Target : Boolean; -- Set to True if target is OpenVMS. + ------------------------------------------- + -- Boolean-Valued Fixed-Point Attributes -- + ------------------------------------------- + + Fractional_Fixed_Ops_On_Target : Boolean; + -- Set to True for targets that support fixed-by-fixed multiplication + -- and division for fixed-point types with a small value equal to + -- 2 ** (-(T'Object_Size - 1)) and whose values have an absolute + -- value less than 1.0. + -------------------------------------------------------------- -- Handling of Unconstrained Values Returned from Functions -- -------------------------------------------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/targtyps.c gcc-3.3/gcc/ada/targtyps.c *** gcc-3.2.3/gcc/ada/targtyps.c 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/targtyps.c 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** * * * Body * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- *************** *** 55,98 **** #include "ada-tree.h" #include "gigi.h" ! #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) ! ! /* Standard data type sizes. Most of these are not used. */ ! ! #ifndef CHAR_TYPE_SIZE ! #define CHAR_TYPE_SIZE BITS_PER_UNIT ! #endif ! ! #ifndef SHORT_TYPE_SIZE ! #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2)) ! #endif ! ! #ifndef INT_TYPE_SIZE ! #define INT_TYPE_SIZE BITS_PER_WORD ! #endif ! ! #ifdef OPEN_VMS /* A target macro defined in vms.h */ ! #define LONG_TYPE_SIZE 64 ! #else ! #ifndef LONG_TYPE_SIZE ! #define LONG_TYPE_SIZE BITS_PER_WORD ! #endif ! #endif ! ! #ifndef LONG_LONG_TYPE_SIZE ! #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2) ! #endif ! ! #ifndef FLOAT_TYPE_SIZE ! #define FLOAT_TYPE_SIZE BITS_PER_WORD ! #endif ! ! #ifndef DOUBLE_TYPE_SIZE ! #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) ! #endif ! ! #ifndef LONG_DOUBLE_TYPE_SIZE ! #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) #endif #ifndef WIDEST_HARDWARE_FP_SIZE --- 54,63 ---- #include "ada-tree.h" #include "gigi.h" ! /* If we don't have a specific size for Ada's equivalent of `long', use that ! of C. */ ! #ifndef ADA_LONG_TYPE_SIZE ! #define ADA_LONG_TYPE_SIZE LONG_TYPE_SIZE #endif #ifndef WIDEST_HARDWARE_FP_SIZE *************** get_target_int_size () *** 142,148 **** Pos get_target_long_size () { ! return LONG_TYPE_SIZE; } Pos --- 107,113 ---- Pos get_target_long_size () { ! return ADA_LONG_TYPE_SIZE; } Pos diff -Nrc3pad gcc-3.2.3/gcc/ada/tbuild.adb gcc-3.3/gcc/ada/tbuild.adb *** gcc-3.2.3/gcc/ada/tbuild.adb 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/tbuild.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** package body Tbuild is *** 108,113 **** --- 107,135 ---- end if; end Convert_To; + ------------------------------------------- + -- Make_Byte_Aligned_Attribute_Reference -- + ------------------------------------------- + + function Make_Byte_Aligned_Attribute_Reference + (Sloc : Source_Ptr; + Prefix : Node_Id; + Attribute_Name : Name_Id) + return Node_Id + is + N : constant Node_Id := + Make_Attribute_Reference (Sloc, + Prefix => Prefix, + Attribute_Name => Attribute_Name); + + begin + pragma Assert (Attribute_Name = Name_Address + or else + Attribute_Name = Name_Unrestricted_Access); + Set_Must_Be_Byte_Aligned (N, True); + return N; + end Make_Byte_Aligned_Attribute_Reference; + -------------------- -- Make_DT_Access -- -------------------- *************** package body Tbuild is *** 244,249 **** --- 266,328 ---- return Make_Integer_Literal (Loc, UI_From_Int (Intval)); end Make_Integer_Literal; + --------------------------------- + -- Make_Raise_Constraint_Error -- + --------------------------------- + + function Make_Raise_Constraint_Error + (Sloc : Source_Ptr; + Condition : Node_Id := Empty; + Reason : RT_Exception_Code) + return Node_Id + is + begin + pragma Assert (Reason in RT_CE_Exceptions); + return + Make_Raise_Constraint_Error (Sloc, + Condition => Condition, + Reason => + UI_From_Int (RT_Exception_Code'Pos (Reason))); + end Make_Raise_Constraint_Error; + + ------------------------------ + -- Make_Raise_Program_Error -- + ------------------------------ + + function Make_Raise_Program_Error + (Sloc : Source_Ptr; + Condition : Node_Id := Empty; + Reason : RT_Exception_Code) + return Node_Id + is + begin + pragma Assert (Reason in RT_PE_Exceptions); + return + Make_Raise_Program_Error (Sloc, + Condition => Condition, + Reason => + UI_From_Int (RT_Exception_Code'Pos (Reason))); + end Make_Raise_Program_Error; + + ------------------------------ + -- Make_Raise_Storage_Error -- + ------------------------------ + + function Make_Raise_Storage_Error + (Sloc : Source_Ptr; + Condition : Node_Id := Empty; + Reason : RT_Exception_Code) + return Node_Id + is + begin + pragma Assert (Reason in RT_SE_Exceptions); + return + Make_Raise_Storage_Error (Sloc, + Condition => Condition, + Reason => + UI_From_Int (RT_Exception_Code'Pos (Reason))); + end Make_Raise_Storage_Error; + --------------------------- -- Make_Unsuppress_Block -- --------------------------- diff -Nrc3pad gcc-3.2.3/gcc/ada/tbuild.ads gcc-3.3/gcc/ada/tbuild.ads *** gcc-3.2.3/gcc/ada/tbuild.ads 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/tbuild.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.2.10.1 $ -- -- ! -- Copyright (C) 1992-2000, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with Types; use Types; *** 33,38 **** --- 32,62 ---- package Tbuild is + function Checks_Off (N : Node_Id) return Node_Id; + pragma Inline (Checks_Off); + -- Returns an N_Unchecked_Expression node whose expression is the given + -- argument. The results is a subexpression identical to the argument, + -- except that it will be analyzed and resolved with checks off. + + function Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id; + -- Returns an expression that represents the result of a checked convert + -- of expression Exp to type T. If the base type of Exp is T, then no + -- conversion is required, and Exp is returned unchanged. Otherwise an + -- N_Type_Conversion node is constructed to convert the expression. + -- If an N_Type_Conversion node is required, Relocate_Node is used on + -- Exp. This means that it is safe to replace a node by a Convert_To + -- of itself to some other type. + + function Make_Byte_Aligned_Attribute_Reference + (Sloc : Source_Ptr; + Prefix : Node_Id; + Attribute_Name : Name_Id) + return Node_Id; + pragma Inline (Make_Byte_Aligned_Attribute_Reference); + -- Like the standard Make_Attribute_Reference but the special flag + -- Must_Be_Byte_Aligned is set in the attribute reference node. The + -- Attribute_Name must be Name_Address or Name_Unrestricted_Access. + function Make_DT_Component (Loc : Source_Ptr; Typ : Entity_Id; *************** package Tbuild is *** 101,106 **** --- 125,157 ---- pragma Inline (Make_Integer_Literal); -- A convenient form of Make_Integer_Literal taking Int instead of Uint + function Make_Raise_Constraint_Error + (Sloc : Source_Ptr; + Condition : Node_Id := Empty; + Reason : RT_Exception_Code) + return Node_Id; + pragma Inline (Make_Raise_Constraint_Error); + -- A convenient form of Make_Raise_Constraint_Error where the Reason + -- is given simply as an enumeration value, rather than a Uint code. + + function Make_Raise_Program_Error + (Sloc : Source_Ptr; + Condition : Node_Id := Empty; + Reason : RT_Exception_Code) + return Node_Id; + pragma Inline (Make_Raise_Program_Error); + -- A convenient form of Make_Raise_Program_Error where the Reason + -- is given simply as an enumeration value, rather than a Uint code. + + function Make_Raise_Storage_Error + (Sloc : Source_Ptr; + Condition : Node_Id := Empty; + Reason : RT_Exception_Code) + return Node_Id; + pragma Inline (Make_Raise_Storage_Error); + -- A convenient form of Make_Raise_Storage_Error where the Reason + -- is given simply as an enumeration value, rather than a Uint code. + function Make_Unsuppress_Block (Loc : Source_Ptr; Check : Name_Id; *************** package Tbuild is *** 183,198 **** -- of sources, the numbers will be consistent. This means that it is fine -- to use these as public symbols. - function New_Suffixed_Name - (Related_Id : Name_Id; - Suffix : String) - return Name_Id; - -- This function is used to create special suffixed names used by the - -- debugger. Suffix is a string of upper case letters, used to construct - -- the required name. For instance, the special type used to record the - -- fixed-point small is called typ_SMALL where typ is the name of the - -- fixed-point type (as passed in Related_Id), and Suffix is "SMALL". - function New_Occurrence_Of (Def_Id : Entity_Id; Loc : Source_Ptr) --- 234,239 ---- *************** package Tbuild is *** 212,231 **** -- It is used from the expander, where Etype fields are generally not set, -- since they are set when the expanded tree is reanalyzed. ! function Checks_Off (N : Node_Id) return Node_Id; ! pragma Inline (Checks_Off); ! -- Returns an N_Unchecked_Expression node whose expression is the given ! -- argument. The results is a subexpression identical to the argument, ! -- except that it will be analyzed and resolved with checks off. ! ! function Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id; ! -- Returns an expression that represents the result of a checked convert ! -- of expression Exp to type T. If the base type of Exp is T, then no ! -- conversion is required, and Exp is returned unchanged. Otherwise an ! -- N_Type_Conversion node is constructed to convert the expression. ! -- If an N_Type_Conversion node is required, Relocate_Node is used on ! -- Exp. This means that it is safe to replace a node by a Convert_To ! -- of itself to some other type. function OK_Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id; -- Like Convert_To, except that a conversion node is always generated, --- 253,267 ---- -- It is used from the expander, where Etype fields are generally not set, -- since they are set when the expanded tree is reanalyzed. ! function New_Suffixed_Name ! (Related_Id : Name_Id; ! Suffix : String) ! return Name_Id; ! -- This function is used to create special suffixed names used by the ! -- debugger. Suffix is a string of upper case letters, used to construct ! -- the required name. For instance, the special type used to record the ! -- fixed-point small is called typ_SMALL where typ is the name of the ! -- fixed-point type (as passed in Related_Id), and Suffix is "SMALL". function OK_Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id; -- Like Convert_To, except that a conversion node is always generated, diff -Nrc3pad gcc-3.2.3/gcc/ada/text_io.ads gcc-3.3/gcc/ada/text_io.ads *** gcc-3.2.3/gcc/ada/text_io.ads 2002-05-07 08:22:35.000000000 +0000 --- gcc-3.3/gcc/ada/text_io.ads 2002-03-14 11:00:19.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/tracebak.c gcc-3.3/gcc/ada/tracebak.c *** gcc-3.2.3/gcc/ada/tracebak.c 2001-11-17 11:35:08.000000000 +0000 --- gcc-3.3/gcc/ada/tracebak.c 2002-03-14 11:00:20.000000000 +0000 *************** *** 6,12 **** * * * C Implementation File * * * - * $Revision: 1.3 $ * * * Copyright (C) 2000-2001 Ada Core Technologies, Inc. * * * --- 6,11 ---- *************** struct layout *** 144,157 **** void *return_address; }; #define FRAME_LEVEL 0 #define FRAME_OFFSET 0 #define SKIP_FRAME 1 #define PC_ADJUST -2 #define STOP_FRAME(CURRENT, TOP_STACK) \ ! ((CURRENT)->return_address == 0|| (CURRENT)->next == 0 \ || (void *) (CURRENT) < (TOP_STACK)) #elif defined (__alpha_vxworks) #define SKIP_FRAME 1 --- 143,185 ---- void *return_address; }; + #ifdef _WIN32 + /* _image_base__ is the image starting address, no stack addresses should be + under this value */ + extern unsigned int _image_base__; + #define LOWEST_ADDR ((unsigned int) (&_image_base__)) + #else + #define LOWEST_ADDR 0 + #endif + #define FRAME_LEVEL 0 #define FRAME_OFFSET 0 #define SKIP_FRAME 1 #define PC_ADJUST -2 #define STOP_FRAME(CURRENT, TOP_STACK) \ ! ((unsigned int)(CURRENT)->return_address < LOWEST_ADDR \ ! || (CURRENT)->return_address == 0|| (CURRENT)->next == 0 \ || (void *) (CURRENT) < (TOP_STACK)) + /* On i386 architecture we check that at the call point we really have a call + insn. Possible call instructions are: + + call addr16 E8 xx xx xx xx + call reg FF Dx + call off(reg) FF xx xx + lcall addr seg 9A xx xx xx xx xx xx + + This check will not catch all cases but it will increase the backtrace + reliability on this architecture. + */ + + #define VALID_STACK_FRAME(ptr) \ + (((*((ptr) - 3) & 0xff) == 0xe8) \ + || ((*((ptr) - 4) & 0xff) == 0x9a) \ + || ((*((ptr) - 2) & 0xff) == 0xff) \ + || (((*((ptr) - 1) & 0xff00) == 0xff00) \ + && ((*((ptr) - 1) & 0xf0) == 0xd0))) + #elif defined (__alpha_vxworks) #define SKIP_FRAME 1 *************** segv_handler (ignored) *** 192,197 **** --- 220,229 ---- } #endif + #ifndef VALID_STACK_FRAME + #define VALID_STACK_FRAME(ptr) 1 + #endif + int __gnat_backtrace (array, size, exclude_min, exclude_max) void **array; *************** __gnat_backtrace (array, size, exclude_m *** 236,242 **** cnt = 0; while (cnt < size) { ! if (STOP_FRAME (current, top_stack)) break; if (current->return_address < exclude_min --- 268,275 ---- cnt = 0; while (cnt < size) { ! if (STOP_FRAME (current, top_stack) || ! !VALID_STACK_FRAME((char *)(current->return_address + PC_ADJUST))) break; if (current->return_address < exclude_min diff -Nrc3pad gcc-3.2.3/gcc/ada/trans.c gcc-3.3/gcc/ada/trans.c *** gcc-3.2.3/gcc/ada/trans.c 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/trans.c 2002-11-05 00:49:44.000000000 +0000 *************** *** 6,14 **** * * * C Implementation File * * * - * $Revision: 1.11.2.2 $ * * ! * Copyright (C) 1992-2001, 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- * --- 6,13 ---- * * * C Implementation File * * * * * ! * Copyright (C) 1992-2002, 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- * *************** *** 35,40 **** --- 34,40 ---- #include "expr.h" #include "ggc.h" #include "function.h" + #include "except.h" #include "debug.h" #include "output.h" #include "ada.h" *************** tree gnu_block_stack; *** 85,92 **** /* List of TREE_LIST nodes representing a stack of exception pointer variables. TREE_VALUE is the VAR_DECL that stores the address of the raised exception. Nonzero means we are in an exception ! handler. Set to error_mark_node in the zero-cost case. */ ! static tree gnu_except_ptr_stack; /* Map GNAT tree codes to GCC tree codes for simple expressions. */ static enum tree_code gnu_codes[Number_Node_Kinds]; --- 85,96 ---- /* List of TREE_LIST nodes representing a stack of exception pointer variables. TREE_VALUE is the VAR_DECL that stores the address of the raised exception. Nonzero means we are in an exception ! handler. Not used in the zero-cost case. */ ! static GTY(()) tree gnu_except_ptr_stack; ! ! /* List of TREE_LIST nodes containing pending elaborations lists. ! used to prevent the elaborations being reclaimed by GC. */ ! static GTY(()) tree gnu_pending_elaboration_lists; /* Map GNAT tree codes to GCC tree codes for simple expressions. */ static enum tree_code gnu_codes[Number_Node_Kinds]; *************** Node_Id error_gnat_node; *** 96,102 **** /* Variable that stores a list of labels to be used as a goto target instead of a return in some functions. See processing for N_Subprogram_Body. */ ! static tree gnu_return_label_stack; static tree tree_transform PARAMS((Node_Id)); static void elaborate_all_entities PARAMS((Node_Id)); --- 100,106 ---- /* Variable that stores a list of labels to be used as a goto target instead of a return in some functions. See processing for N_Subprogram_Body. */ ! static GTY(()) tree gnu_return_label_stack; static tree tree_transform PARAMS((Node_Id)); static void elaborate_all_entities PARAMS((Node_Id)); *************** static tree emit_access_check PARAMS((t *** 108,114 **** static tree emit_discriminant_check PARAMS((tree, Node_Id)); static tree emit_range_check PARAMS((tree, Node_Id)); static tree emit_index_check PARAMS((tree, tree, tree, tree)); ! static tree emit_check PARAMS((tree, tree)); static tree convert_with_check PARAMS((Entity_Id, tree, int, int, int)); static int addressable_p PARAMS((tree)); --- 112,118 ---- static tree emit_discriminant_check PARAMS((tree, Node_Id)); static tree emit_range_check PARAMS((tree, Node_Id)); static tree emit_index_check PARAMS((tree, tree, tree, tree)); ! static tree emit_check PARAMS((tree, tree, int)); static tree convert_with_check PARAMS((Entity_Id, tree, int, int, int)); static int addressable_p PARAMS((tree)); *************** static REAL_VALUE_TYPE dconstmp5; *** 127,143 **** structures and then generates code. */ void ! gigi (gnat_root, max_gnat_node, number_name, ! nodes_ptr, next_node_ptr, prev_node_ptr, elists_ptr, elmts_ptr, ! strings_ptr, string_chars_ptr, list_headers_ptr, ! number_units, file_info_ptr, ! standard_integer, standard_long_long_float, standard_exception_type, ! gigi_operating_mode) ! Node_Id gnat_root; int max_gnat_node; int number_name; - struct Node *nodes_ptr; Node_Id *next_node_ptr; Node_Id *prev_node_ptr; --- 131,143 ---- structures and then generates code. */ void ! gigi (gnat_root, max_gnat_node, number_name, nodes_ptr, next_node_ptr, ! prev_node_ptr, elists_ptr, elmts_ptr, strings_ptr, string_chars_ptr, ! list_headers_ptr, number_units, file_info_ptr, standard_integer, ! standard_long_long_float, standard_exception_type, gigi_operating_mode) Node_Id gnat_root; int max_gnat_node; int number_name; struct Node *nodes_ptr; Node_Id *next_node_ptr; Node_Id *prev_node_ptr; *************** gigi (gnat_root, max_gnat_node, number_n *** 148,158 **** struct List_Header *list_headers_ptr; Int number_units ATTRIBUTE_UNUSED; char *file_info_ptr ATTRIBUTE_UNUSED; - Entity_Id standard_integer; Entity_Id standard_long_long_float; Entity_Id standard_exception_type; - Int gigi_operating_mode; { tree gnu_standard_long_long_float; --- 148,156 ---- *************** gigi (gnat_root, max_gnat_node, number_n *** 160,173 **** max_gnat_nodes = max_gnat_node; number_names = number_name; ! Nodes_Ptr = nodes_ptr - First_Node_Id; ! Next_Node_Ptr = next_node_ptr - First_Node_Id; ! Prev_Node_Ptr = prev_node_ptr - First_Node_Id; ! Elists_Ptr = elists_ptr - First_Elist_Id; ! Elmts_Ptr = elmts_ptr - First_Elmt_Id; ! Strings_Ptr = strings_ptr - First_String_Id; String_Chars_Ptr = string_chars_ptr; ! List_Headers_Ptr = list_headers_ptr - First_List_Id; type_annotate_only = (gigi_operating_mode == 1); --- 158,171 ---- max_gnat_nodes = max_gnat_node; number_names = number_name; ! Nodes_Ptr = nodes_ptr; ! Next_Node_Ptr = next_node_ptr; ! Prev_Node_Ptr = prev_node_ptr; ! Elists_Ptr = elists_ptr; ! Elmts_Ptr = elmts_ptr; ! Strings_Ptr = strings_ptr; String_Chars_Ptr = string_chars_ptr; ! List_Headers_Ptr = list_headers_ptr; type_annotate_only = (gigi_operating_mode == 1); *************** gigi (gnat_root, max_gnat_node, number_n *** 194,202 **** save_gnu_tree (Base_Type (standard_integer), TYPE_NAME (integer_type_node), 0); - ggc_add_tree_root (&gnu_block_stack, 1); - ggc_add_tree_root (&gnu_except_ptr_stack, 1); - ggc_add_tree_root (&gnu_return_label_stack, 1); gnu_except_ptr_stack = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); dconstp5 = REAL_VALUE_ATOF ("0.5", DFmode); --- 192,197 ---- *************** gigi (gnat_root, max_gnat_node, number_n *** 209,225 **** init_gigi_decls (gnu_standard_long_long_float, gnu_standard_exception_type); ! /* Emit global symbols containing context list info for the SGI Workshop ! debugger */ ! ! #ifdef MIPS_DEBUGGING_INFO ! if (Spec_Context_List != 0) ! emit_unit_label (Spec_Context_List, Spec_Filename); ! ! if (Body_Context_List != 0) ! emit_unit_label (Body_Context_List, Body_Filename); ! #endif ! #ifdef ASM_OUTPUT_IDENT if (Present (Ident_String (Main_Unit))) ASM_OUTPUT_IDENT --- 204,210 ---- init_gigi_decls (gnu_standard_long_long_float, gnu_standard_exception_type); ! /* Process any Pragma Ident for the main unit. */ #ifdef ASM_OUTPUT_IDENT if (Present (Ident_String (Main_Unit))) ASM_OUTPUT_IDENT *************** gigi (gnat_root, max_gnat_node, number_n *** 227,232 **** --- 212,221 ---- TREE_STRING_POINTER (gnat_to_gnu (Ident_String (Main_Unit)))); #endif + /* If we are using the GCC exception mechanism, let GCC know. */ + if (Exception_Mechanism == GCC_ZCX) + gnat_init_gcc_eh (); + gnat_to_code (gnat_root); } *************** tree_transform (gnat_node) *** 336,342 **** return error_mark_node; else return build1 (NULL_EXPR, gnu_result_type, ! build_call_raise (raise_constraint_error_decl)); } switch (Nkind (gnat_node)) --- 325,331 ---- return error_mark_node; else return build1 (NULL_EXPR, gnu_result_type, ! build_call_raise (CE_Range_Check_Failed)); } switch (Nkind (gnat_node)) *************** tree_transform (gnat_node) *** 433,439 **** right now. */ if (TREE_VALUE (gnu_except_ptr_stack) != 0) { ! mark_addressable (gnu_result); flush_addressof (gnu_result); } --- 422,428 ---- right now. */ if (TREE_VALUE (gnu_except_ptr_stack) != 0) { ! gnat_mark_addressable (gnu_result); flush_addressof (gnu_result); } *************** tree_transform (gnat_node) *** 505,533 **** gnu_type = TREE_TYPE (TYPE_FIELDS (gnu_type)); gnu_result = UI_To_gnu (Intval (gnat_node), gnu_type); - /* Get the type of the result, looking inside any padding and - left-justified modular types. Then get the value in that type. */ - gnu_type = gnu_result_type = get_unpadded_type (Etype (gnat_node)); - - if (TREE_CODE (gnu_type) == RECORD_TYPE - && TYPE_LEFT_JUSTIFIED_MODULAR_P (gnu_type)) - gnu_type = TREE_TYPE (TYPE_FIELDS (gnu_type)); - - gnu_result = UI_To_gnu (Intval (gnat_node), gnu_type); ! /* If the result overflows (meaning it doesn't fit in its base type) ! or is outside of the range of the subtype, we have an illegal tree ! entry, so abort. Note that the test for of types with biased ! representation is harder, so we don't test in that case. */ ! if (TREE_CONSTANT_OVERFLOW (gnu_result) ! || (TREE_CODE (TYPE_MIN_VALUE (gnu_result_type)) == INTEGER_CST ! && ! TYPE_BIASED_REPRESENTATION_P (gnu_result_type) ! && tree_int_cst_lt (gnu_result, ! TYPE_MIN_VALUE (gnu_result_type))) ! || (TREE_CODE (TYPE_MAX_VALUE (gnu_result_type)) == INTEGER_CST ! && ! TYPE_BIASED_REPRESENTATION_P (gnu_result_type) ! && tree_int_cst_lt (TYPE_MAX_VALUE (gnu_result_type), ! gnu_result))) gigi_abort (305); } break; --- 494,506 ---- gnu_type = TREE_TYPE (TYPE_FIELDS (gnu_type)); gnu_result = UI_To_gnu (Intval (gnat_node), gnu_type); ! /* If the result overflows (meaning it doesn't fit in its base type), ! abort. We would like to check that the value is within the range ! of the subtype, but that causes problems with subtypes whose usage ! will raise Constraint_Error and with biased representation, so ! we don't. */ ! if (TREE_CONSTANT_OVERFLOW (gnu_result)) gigi_abort (305); } break; *************** tree_transform (gnat_node) *** 607,617 **** gigi_abort (336); else ! gnu_result ! = build_real (gnu_result_type, ! REAL_VALUE_LDEXP ! (TREE_REAL_CST (gnu_result), ! - UI_To_Int (Denominator (ur_realval)))); } /* Now see if we need to negate the result. Do it this way to --- 580,592 ---- gigi_abort (336); else ! { ! REAL_VALUE_TYPE tmp; ! ! real_ldexp (&tmp, &TREE_REAL_CST (gnu_result), ! - UI_To_Int (Denominator (ur_realval))); ! gnu_result = build_real (gnu_result_type, tmp); ! } } /* Now see if we need to negate the result. Do it this way to *************** tree_transform (gnat_node) *** 800,813 **** gnat_temp = Defining_Entity (gnat_node); ! /* Don't do anything if this renaming handled by the front end. ! or if we are just annotating types and this object has an ! unconstrained or task type, don't elaborate it. */ if (! Is_Renaming_Of_Object (gnat_temp) && ! (type_annotate_only ! && (((Is_Array_Type (Etype (gnat_temp)) ! || Is_Record_Type (Etype (gnat_temp))) ! && ! Is_Constrained (Etype (gnat_temp))) || Is_Concurrent_Type (Etype (gnat_temp))))) { gnu_expr = gnat_to_gnu (Renamed_Object (gnat_temp)); --- 775,787 ---- gnat_temp = Defining_Entity (gnat_node); ! /* Don't do anything if this renaming is handled by the front end. ! or if we are just annotating types and this object has a ! composite or task type, don't elaborate it. */ if (! Is_Renaming_Of_Object (gnat_temp) && ! (type_annotate_only ! && (Is_Array_Type (Etype (gnat_temp)) ! || Is_Record_Type (Etype (gnat_temp)) || Is_Concurrent_Type (Etype (gnat_temp))))) { gnu_expr = gnat_to_gnu (Renamed_Object (gnat_temp)); *************** tree_transform (gnat_node) *** 1028,1040 **** /* If there are discriminants, the prefix might be evaluated more than once, which is a problem if it has side-effects. */ - if (Has_Discriminants (Is_Access_Type (Etype (Prefix (gnat_node))) ? Designated_Type (Etype (Prefix (gnat_node))) ! : Etype (Prefix (gnat_node))) ! && TREE_SIDE_EFFECTS (gnu_prefix)) ! gnu_prefix = make_save_expr (gnu_prefix); /* Emit discriminant check if necessary. */ if (Do_Discriminant_Check (gnat_node)) --- 1002,1012 ---- /* If there are discriminants, the prefix might be evaluated more than once, which is a problem if it has side-effects. */ if (Has_Discriminants (Is_Access_Type (Etype (Prefix (gnat_node))) ? Designated_Type (Etype (Prefix (gnat_node))) ! : Etype (Prefix (gnat_node)))) ! gnu_prefix = gnat_stabilize_reference (gnu_prefix, 0); /* Emit discriminant check if necessary. */ if (Do_Discriminant_Check (gnat_node)) *************** tree_transform (gnat_node) *** 1109,1115 **** if (Do_Range_Check (First (Expressions (gnat_node)))) { ! gnu_expr = make_save_expr (gnu_expr); gnu_expr = emit_check (build_binary_op (EQ_EXPR, integer_type_node, --- 1081,1087 ---- if (Do_Range_Check (First (Expressions (gnat_node)))) { ! gnu_expr = protect_multiple_eval (gnu_expr); gnu_expr = emit_check (build_binary_op (EQ_EXPR, integer_type_node, *************** tree_transform (gnat_node) *** 1117,1123 **** attribute == Attr_Pred ? TYPE_MIN_VALUE (gnu_result_type) : TYPE_MAX_VALUE (gnu_result_type)), ! gnu_expr); } gnu_result --- 1089,1095 ---- attribute == Attr_Pred ? TYPE_MIN_VALUE (gnu_result_type) : TYPE_MAX_VALUE (gnu_result_type)), ! gnu_expr, CE_Range_Check_Failed); } gnu_result *************** tree_transform (gnat_node) *** 1132,1138 **** /* Conversions don't change something's address but can cause us to miss the COMPONENT_REF case below, so strip them off. */ ! gnu_prefix = remove_conversions (gnu_prefix); /* If we are taking 'Address of an unconstrained object, this is the pointer to the underlying array. */ --- 1104,1112 ---- /* Conversions don't change something's address but can cause us to miss the COMPONENT_REF case below, so strip them off. */ ! gnu_prefix ! = remove_conversions (gnu_prefix, ! ! Must_Be_Byte_Aligned (gnat_node)); /* If we are taking 'Address of an unconstrained object, this is the pointer to the underlying array. */ *************** tree_transform (gnat_node) *** 1146,1153 **** gnu_result_type = get_unpadded_type (Etype (gnat_node)); gnu_result ! = build_unary_op (attribute == Attr_Address ! || attribute == Attr_Unrestricted_Access ? ATTR_ADDR_EXPR : ADDR_EXPR, gnu_result_type, gnu_prefix); --- 1120,1128 ---- gnu_result_type = get_unpadded_type (Etype (gnat_node)); gnu_result ! = build_unary_op (((attribute == Attr_Address ! || attribute == Attr_Unrestricted_Access) ! && ! Must_Be_Byte_Aligned (gnat_node)) ? ATTR_ADDR_EXPR : ADDR_EXPR, gnu_result_type, gnu_prefix); *************** tree_transform (gnat_node) *** 1180,1186 **** while (TREE_CODE (gnu_expr) == NOP_EXPR) gnu_expr = TREE_OPERAND (gnu_expr, 0); ! gnu_prefix = remove_conversions (gnu_prefix); prefix_unused = 1; gnu_type = TREE_TYPE (gnu_prefix); --- 1155,1161 ---- while (TREE_CODE (gnu_expr) == NOP_EXPR) gnu_expr = TREE_OPERAND (gnu_expr, 0); ! gnu_prefix = remove_conversions (gnu_prefix, 1); prefix_unused = 1; gnu_type = TREE_TYPE (gnu_prefix); *************** tree_transform (gnat_node) *** 1376,1382 **** /* 'Length or 'Range_Length. */ { tree gnu_compute_type ! = signed_or_unsigned_type (0, get_base_type (gnu_result_type)); gnu_result --- 1351,1357 ---- /* 'Length or 'Range_Length. */ { tree gnu_compute_type ! = gnat_signed_or_unsigned_type (0, get_base_type (gnu_result_type)); gnu_result *************** tree_transform (gnat_node) *** 1423,1429 **** int unsignedp, volatilep; gnu_result_type = get_unpadded_type (Etype (gnat_node)); ! gnu_prefix = remove_conversions (gnu_prefix); prefix_unused = 1; /* We can have 'Bit on any object, but if it isn't a --- 1398,1404 ---- int unsignedp, volatilep; gnu_result_type = get_unpadded_type (Etype (gnat_node)); ! gnu_prefix = remove_conversions (gnu_prefix, 1); prefix_unused = 1; /* We can have 'Bit on any object, but if it isn't a *************** tree_transform (gnat_node) *** 1445,1451 **** get_inner_reference (gnu_prefix, &bitsize, &bitpos, &gnu_offset, &mode, &unsignedp, &volatilep); - if (TREE_CODE (gnu_prefix) == COMPONENT_REF) { gnu_field_bitpos --- 1420,1425 ---- *************** tree_transform (gnat_node) *** 1485,1497 **** gnu_result = gnu_field_offset; break; - case Attr_First_Bit: case Attr_Bit: gnu_result = size_int (bitpos % BITS_PER_UNIT); break; - case Attr_Last_Bit: gnu_result = bitsize_int (bitpos % BITS_PER_UNIT); gnu_result --- 1459,1469 ---- *************** tree_transform (gnat_node) *** 1611,1618 **** } /* If this is an attribute where the prefix was unused, ! force a use of it if it has a side-effect. */ ! if (prefix_unused && TREE_SIDE_EFFECTS (gnu_prefix)) gnu_result = fold (build (COMPOUND_EXPR, TREE_TYPE (gnu_result), gnu_prefix, gnu_result)); } --- 1583,1594 ---- } /* If this is an attribute where the prefix was unused, ! force a use of it if it has a side-effect. But don't do it if ! the prefix is just an entity name. However, if an access check ! is needed, we must do it. See second example in AARM 11.6(5.e). */ ! if (prefix_unused && TREE_SIDE_EFFECTS (gnu_prefix) ! && (! Is_Entity_Name (Prefix (gnat_node)) ! || Do_Access_Check (gnat_node))) gnu_result = fold (build (COMPOUND_EXPR, TREE_TYPE (gnu_result), gnu_prefix, gnu_result)); } *************** tree_transform (gnat_node) *** 1717,1723 **** = TREE_CODE (gnu_obj_type) == FUNCTION_TYPE ? FUNCTION_BOUNDARY : TYPE_ALIGN (gnu_obj_type); ! if (align != 0 && align < oalign && ! TYPE_ALIGN_OK_P (gnu_obj_type)) post_error_ne_tree_2 ("?source alignment (^) < alignment of & (^)", gnat_node, Designated_Type (Etype (gnat_node)), --- 1693,1699 ---- = TREE_CODE (gnu_obj_type) == FUNCTION_TYPE ? FUNCTION_BOUNDARY : TYPE_ALIGN (gnu_obj_type); ! if (align != 0 && align < oalign && ! TYPE_ALIGN_OK (gnu_obj_type)) post_error_ne_tree_2 ("?source alignment (^) < alignment of & (^)", gnat_node, Designated_Type (Etype (gnat_node)), *************** tree_transform (gnat_node) *** 1763,1769 **** gnu_object, gnu_low); else { ! gnu_object = make_save_expr (gnu_object); gnu_result = build_binary_op (TRUTH_ANDIF_EXPR, gnu_result_type, build_binary_op (GE_EXPR, gnu_result_type, --- 1739,1745 ---- gnu_object, gnu_low); else { ! gnu_object = protect_multiple_eval (gnu_object); gnu_result = build_binary_op (TRUTH_ANDIF_EXPR, gnu_result_type, build_binary_op (GE_EXPR, gnu_result_type, *************** tree_transform (gnat_node) *** 1894,1903 **** so we may need to choose a different type. */ if (Nkind (gnat_node) == N_Op_Shift_Right && ! TREE_UNSIGNED (gnu_type)) ! gnu_type = unsigned_type (gnu_type); else if (Nkind (gnat_node) == N_Op_Shift_Right_Arithmetic && TREE_UNSIGNED (gnu_type)) ! gnu_type = signed_type (gnu_type); if (gnu_type != gnu_result_type) { --- 1870,1879 ---- so we may need to choose a different type. */ if (Nkind (gnat_node) == N_Op_Shift_Right && ! TREE_UNSIGNED (gnu_type)) ! gnu_type = gnat_unsigned_type (gnu_type); else if (Nkind (gnat_node) == N_Op_Shift_Right_Arithmetic && TREE_UNSIGNED (gnu_type)) ! gnu_type = gnat_signed_type (gnu_type); if (gnu_type != gnu_result_type) { *************** tree_transform (gnat_node) *** 1934,1940 **** gnu_result_type = get_unpadded_type (Etype (gnat_node)); gnu_result = build_cond_expr (gnu_result_type, ! truthvalue_conversion (gnu_cond), gnu_true, gnu_false); } break; --- 1910,1916 ---- gnu_result_type = get_unpadded_type (Etype (gnat_node)); gnu_result = build_cond_expr (gnu_result_type, ! gnat_truthvalue_conversion (gnu_cond), gnu_true, gnu_false); } break; *************** tree_transform (gnat_node) *** 2071,2077 **** && TREE_OVERFLOW (TYPE_SIZE (TREE_TYPE (gnu_lhs)))) || (TREE_CODE (TYPE_SIZE (TREE_TYPE (gnu_rhs))) == INTEGER_CST && TREE_OVERFLOW (TYPE_SIZE (TREE_TYPE (gnu_rhs))))) ! expand_expr_stmt (build_call_raise (raise_storage_error_decl)); else expand_expr_stmt (build_binary_op (MODIFY_EXPR, NULL_TREE, gnu_lhs, gnu_rhs)); --- 2047,2053 ---- && TREE_OVERFLOW (TYPE_SIZE (TREE_TYPE (gnu_lhs)))) || (TREE_CODE (TYPE_SIZE (TREE_TYPE (gnu_rhs))) == INTEGER_CST && TREE_OVERFLOW (TYPE_SIZE (TREE_TYPE (gnu_rhs))))) ! expand_expr_stmt (build_call_raise (SE_Object_Too_Large)); else expand_expr_stmt (build_binary_op (MODIFY_EXPR, NULL_TREE, gnu_lhs, gnu_rhs)); *************** tree_transform (gnat_node) *** 2220,2226 **** /* After compiling the choices attached to the WHEN compile the body of statements that have to be executed, should the ! "WHEN ... =>" be taken. */ for (gnat_statement = First (Statements (gnat_when)); Present (gnat_statement); gnat_statement = Next (gnat_statement)) --- 2196,2207 ---- /* After compiling the choices attached to the WHEN compile the body of statements that have to be executed, should the ! "WHEN ... =>" be taken. Push a binding level here in case ! variables are declared since we want them to be local to this ! set of statements instead of the block containing the Case ! statement. */ ! pushlevel (0); ! expand_start_bindings (0); for (gnat_statement = First (Statements (gnat_when)); Present (gnat_statement); gnat_statement = Next (gnat_statement)) *************** tree_transform (gnat_node) *** 2229,2234 **** --- 2210,2217 ---- /* Communicate to GCC that we are done with the current WHEN, i.e. insert a "break" statement. */ expand_exit_something (); + expand_end_bindings (getdecls (), kept_level_p (), 0); + poplevel (kept_level_p (), 1, 0); } expand_end_case (gnu_expr); *************** tree_transform (gnat_node) *** 2338,2344 **** { tree gnu_loop_id = make_node (GNAT_LOOP_ID); ! TREE_LOOP_ID (gnu_loop_id) = (rtx) loop_id; save_gnu_tree (Entity (Identifier (gnat_node)), gnu_loop_id, 1); } --- 2321,2327 ---- { tree gnu_loop_id = make_node (GNAT_LOOP_ID); ! TREE_LOOP_ID (gnu_loop_id) = loop_id; save_gnu_tree (Entity (Identifier (gnat_node)), gnu_loop_id, 1); } *************** tree_transform (gnat_node) *** 2427,2439 **** if (Present (Name (gnat_node))) loop_id ! = (struct nesting *) ! TREE_LOOP_ID (get_gnu_tree (Entity (Name (gnat_node)))); if (Present (Condition (gnat_node))) ! gnu_cond ! = invert_truthvalue ! (truthvalue_conversion (gnat_to_gnu (Condition (gnat_node)))); set_lineno (gnat_node, 1); expand_exit_loop_if_false (loop_id, gnu_cond); --- 2410,2420 ---- if (Present (Name (gnat_node))) loop_id ! = TREE_LOOP_ID (get_gnu_tree (Entity (Name (gnat_node)))); if (Present (Condition (gnat_node))) ! gnu_cond = invert_truthvalue (gnat_truthvalue_conversion ! (gnat_to_gnu (Condition (gnat_node)))); set_lineno (gnat_node, 1); expand_exit_loop_if_false (loop_id, gnu_cond); *************** tree_transform (gnat_node) *** 2582,2588 **** { /* Save debug output mode in case it is reset. */ enum debug_info_type save_write_symbols = write_symbols; ! struct gcc_debug_hooks *save_debug_hooks = debug_hooks; /* Definining identifier of a parameter to the subprogram. */ Entity_Id gnat_param; /* The defining identifier for the subprogram body. Note that if a --- 2563,2569 ---- { /* Save debug output mode in case it is reset. */ enum debug_info_type save_write_symbols = write_symbols; ! const struct gcc_debug_hooks *const save_debug_hooks = debug_hooks; /* Definining identifier of a parameter to the subprogram. */ Entity_Id gnat_param; /* The defining identifier for the subprogram body. Note that if a *************** tree_transform (gnat_node) *** 2798,2807 **** gnu_result_type = TREE_TYPE (gnu_subprog_type); gnu_result = build1 (NULL_EXPR, gnu_result_type, ! build_call_raise (raise_program_error_decl)); } else ! expand_expr_stmt (build_call_raise (raise_program_error_decl)); break; } --- 2779,2789 ---- gnu_result_type = TREE_TYPE (gnu_subprog_type); gnu_result = build1 (NULL_EXPR, gnu_result_type, ! build_call_raise (PE_Stubbed_Subprogram_Called)); } else ! expand_expr_stmt ! (build_call_raise (PE_Stubbed_Subprogram_Called)); break; } *************** tree_transform (gnat_node) *** 3013,3019 **** gnu_actual = unchecked_convert (DECL_ARG_TYPE (get_gnu_tree (gnat_formal)), ! convert (type_for_size (tree_low_cst (gnu_actual_size, 1), 1), integer_zero_node)); else --- 2995,3001 ---- gnu_actual = unchecked_convert (DECL_ARG_TYPE (get_gnu_tree (gnat_formal)), ! convert (gnat_type_for_size (tree_low_cst (gnu_actual_size, 1), 1), integer_zero_node)); else *************** tree_transform (gnat_node) *** 3062,3068 **** { tree gnu_name; ! gnu_subprog_call = make_save_expr (gnu_subprog_call); /* If any of the names had side-effects, ensure they are all evaluated before the call. */ --- 3044,3050 ---- { tree gnu_name; ! gnu_subprog_call = protect_multiple_eval (gnu_subprog_call); /* If any of the names had side-effects, ensure they are all evaluated before the call. */ *************** tree_transform (gnat_node) *** 3299,3304 **** --- 3281,3317 ---- /***************************/ case N_Handled_Sequence_Of_Statements: + + /* The GCC exception handling mechanism can handle both ZCX and SJLJ + schemes and we have our own SJLJ mechanism. To call the GCC + mechanism, we first call expand_eh_region_start if there is at least + one handler associated with the region. We then generate code for + the region and call expand_start_all_catch to announce that the + associated handlers are going to be generated. + + For each handler we call expand_start_catch, generate code for the + handler, and then call expand_end_catch. + + After all the handlers, we call expand_end_all_catch. + + Here we deal with the region level calls and the + N_Exception_Handler branch deals with the handler level calls + (start_catch/end_catch). + + ??? The region level calls down there have been specifically put in + place for a ZCX context and currently the order in which things are + emitted (region/handlers) is different from the SJLJ case. Instead of + putting other calls with different conditions at other places for the + SJLJ case, it seems cleaner to reorder things for the SJLJ case and + generalize the condition to make it not ZCX specific. */ + + /* Tell the back-end we are starting a new exception region if + necessary. */ + if (! type_annotate_only + && Exception_Mechanism == GCC_ZCX + && Present (Exception_Handlers (gnat_node))) + expand_eh_region_start (); + /* If there are exception handlers, start a new binding level that we can exit (since each exception handler will do so). Then declare a variable to save the old __gnat_jmpbuf value and a *************** tree_transform (gnat_node) *** 3315,3321 **** pushlevel (0); expand_start_bindings (1); ! if (! Zero_Cost_Handling (gnat_node)) { gnu_jmpsave_decl = create_var_decl (get_identifier ("JMPBUF_SAVE"), NULL_TREE, --- 3328,3334 ---- pushlevel (0); expand_start_bindings (1); ! if (Exception_Mechanism == Setjmp_Longjmp) { gnu_jmpsave_decl = create_var_decl (get_identifier ("JMPBUF_SAVE"), NULL_TREE, *************** tree_transform (gnat_node) *** 3344,3350 **** expand_decl_cleanup (gnu_cleanup_decl, gnu_cleanup_call); } ! if (! Zero_Cost_Handling (gnat_node)) { /* When we exit this block, restore the saved value. */ expand_decl_cleanup (gnu_jmpsave_decl, --- 3357,3363 ---- expand_decl_cleanup (gnu_cleanup_decl, gnu_cleanup_call); } ! if (Exception_Mechanism == Setjmp_Longjmp) { /* When we exit this block, restore the saved value. */ expand_decl_cleanup (gnu_jmpsave_decl, *************** tree_transform (gnat_node) *** 3412,3420 **** /* If there are no exception handlers, we must not have an at end cleanup identifier, since the cleanup identifier should always ! generate a corresponding exception handler. */ else if (! type_annotate_only && Present (At_End_Proc (gnat_node))) ! gigi_abort (335); /* Generate code and declarations for the prefix of this block, if any. */ --- 3425,3453 ---- /* If there are no exception handlers, we must not have an at end cleanup identifier, since the cleanup identifier should always ! generate a corresponding exception handler, except in the case ! of the No_Exception_Handlers restriction, where the front-end ! does not generate exception handlers. */ else if (! type_annotate_only && Present (At_End_Proc (gnat_node))) ! { ! if (No_Exception_Handlers_Set ()) ! { ! tree gnu_cleanup_call = 0; ! tree gnu_cleanup_decl; ! ! gnu_cleanup_call ! = build_call_0_expr (gnat_to_gnu (At_End_Proc (gnat_node))); ! ! gnu_cleanup_decl ! = create_var_decl (get_identifier ("CLEANUP"), NULL_TREE, ! integer_type_node, NULL_TREE, 0, 0, 0, 0, ! 0); ! ! expand_decl_cleanup (gnu_cleanup_decl, gnu_cleanup_call); ! } ! else ! gigi_abort (335); ! } /* Generate code and declarations for the prefix of this block, if any. */ *************** tree_transform (gnat_node) *** 3429,3451 **** Present (gnat_temp); gnat_temp = Next (gnat_temp)) gnat_to_code (gnat_temp); /* For zero-cost exceptions, exit the block and then compile the handlers. */ ! if (! type_annotate_only && Zero_Cost_Handling (gnat_node) && Present (Exception_Handlers (gnat_node))) { expand_exit_something (); - gnu_except_ptr_stack - = tree_cons (NULL_TREE, error_mark_node, gnu_except_ptr_stack); - for (gnat_temp = First_Non_Pragma (Exception_Handlers (gnat_node)); Present (gnat_temp); gnat_temp = Next_Non_Pragma (gnat_temp)) gnat_to_code (gnat_temp); ! gnu_except_ptr_stack = TREE_CHAIN (gnu_except_ptr_stack); } /* If we have handlers, close the block we made. */ if (! type_annotate_only && Present (Exception_Handlers (gnat_node))) { --- 3462,3505 ---- Present (gnat_temp); gnat_temp = Next (gnat_temp)) gnat_to_code (gnat_temp); + /* Tell the back-end we are ending the new exception region and + starting the associated handlers. */ + if (! type_annotate_only + && Exception_Mechanism == GCC_ZCX + && Present (Exception_Handlers (gnat_node))) + expand_start_all_catch (); + /* For zero-cost exceptions, exit the block and then compile the handlers. */ ! if (! type_annotate_only ! && Exception_Mechanism == GCC_ZCX && Present (Exception_Handlers (gnat_node))) { expand_exit_something (); for (gnat_temp = First_Non_Pragma (Exception_Handlers (gnat_node)); Present (gnat_temp); gnat_temp = Next_Non_Pragma (gnat_temp)) gnat_to_code (gnat_temp); + } ! /* We don't support Front_End_ZCX in GNAT 5.0, but we don't want to ! crash if -gnatdX is specified. */ ! if (! type_annotate_only ! && Exception_Mechanism == Front_End_ZCX ! && Present (Exception_Handlers (gnat_node))) ! { ! for (gnat_temp = First_Non_Pragma (Exception_Handlers (gnat_node)); ! Present (gnat_temp); ! gnat_temp = Next_Non_Pragma (gnat_temp)) ! gnat_to_code (gnat_temp); } + /* Tell the backend when we are done with the handlers. */ + if (! type_annotate_only + && Exception_Mechanism == GCC_ZCX + && Present (Exception_Handlers (gnat_node))) + expand_end_all_catch (); + /* If we have handlers, close the block we made. */ if (! type_annotate_only && Present (Exception_Handlers (gnat_node))) { *************** tree_transform (gnat_node) *** 3456,3462 **** break; case N_Exception_Handler: ! if (! Zero_Cost_Handling (gnat_node)) { /* Unless this is "Others" or the special "Non-Ada" exception for Ada, make an "if" statement to select the proper --- 3510,3516 ---- break; case N_Exception_Handler: ! if (Exception_Mechanism == Setjmp_Longjmp) { /* Unless this is "Others" or the special "Non-Ada" exception for Ada, make an "if" statement to select the proper *************** tree_transform (gnat_node) *** 3552,3557 **** --- 3606,3677 ---- expand_start_cond (gnu_choice, 0); } + /* Tell the back end that we start an exception handler if necessary. */ + if (Exception_Mechanism == GCC_ZCX) + { + /* We build a TREE_LIST of nodes representing what exception + types this handler is able to catch, with special cases + for others and all others cases. + + Each exception type is actually identified by a pointer to the + exception id, with special value zero for "others" and one for + "all others". Beware that these special values are known and used + by the personality routine to identify the corresponding specific + kinds of handlers. + + ??? For initial time frame reasons, the others and all_others + cases have been handled using specific type trees, but this + somehow hides information to the back-end, which expects NULL to + be passed for catch all and end_cleanup to be used for cleanups. + + Care should be taken to ensure that the control flow impact of + such clauses is rendered in some way. lang_eh_type_covers is + doing the trick currently. + + ??? Should investigate the possible usage of the end_cleanup + interface in this context. */ + + tree gnu_expr, gnu_etype; + tree gnu_etypes_list = NULL_TREE; + + for (gnat_temp = First (Exception_Choices (gnat_node)); + gnat_temp; gnat_temp = Next (gnat_temp)) + { + if (Nkind (gnat_temp) == N_Others_Choice) + gnu_etype + = All_Others (gnat_temp) ? integer_one_node + : integer_zero_node; + else if (Nkind (gnat_temp) == N_Identifier + || Nkind (gnat_temp) == N_Expanded_Name) + { + gnu_expr = gnat_to_gnu_entity (Entity (gnat_temp), + NULL_TREE, 0); + gnu_etype = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_expr); + } + else + gigi_abort (337); + + gnu_etypes_list + = tree_cons (NULL_TREE, gnu_etype, gnu_etypes_list); + + /* The GCC interface expects NULL to be passed for catch all + handlers, so the approach below is quite tempting : + + if (gnu_etype == integer_zero_node) + gnu_etypes_list = NULL; + + It would not work, however, because GCC's notion + of "catch all" is stronger than our notion of "others". + + Until we correctly use the cleanup interface as well, the + two lines above will prevent the "all others" handlers from + beeing seen, because nothing can be caught beyond a catch + all from GCC's point of view. */ + } + + expand_start_catch (gnu_etypes_list); + } + for (gnat_temp = First (Statements (gnat_node)); gnat_temp; gnat_temp = Next (gnat_temp)) gnat_to_code (gnat_temp); *************** tree_transform (gnat_node) *** 3560,3566 **** in N_Handled_Sequence_Of_Statements. */ expand_exit_something (); ! if (! Zero_Cost_Handling (gnat_node)) expand_end_cond (); break; --- 3680,3689 ---- in N_Handled_Sequence_Of_Statements. */ expand_exit_something (); ! /* Tell the back end that we're done with the current handler. */ ! if (Exception_Mechanism == GCC_ZCX) ! expand_end_catch (); ! else if (Exception_Mechanism == Setjmp_Longjmp) expand_end_cond (); break; *************** tree_transform (gnat_node) *** 3581,3587 **** to be done with them. */ break; - /***************************************************/ /* Chapter 13: Representation Clauses and */ /* Implementation-Dependent Features: */ --- 3704,3709 ---- *************** tree_transform (gnat_node) *** 3651,3659 **** build_string (strlen (clobber) + 1, clobber), gnu_clobber_list); ! expand_asm_operands (gnu_template, nreverse (gnu_output_list), ! nreverse (gnu_input_list), gnu_clobber_list, ! Is_Asm_Volatile (gnat_node), input_filename, lineno); /* Copy all the intermediate outputs into the specified outputs. */ --- 3773,3783 ---- build_string (strlen (clobber) + 1, clobber), gnu_clobber_list); ! gnu_input_list = nreverse (gnu_input_list); ! gnu_output_list = nreverse (gnu_output_list); ! gnu_orig_out_list = nreverse (gnu_orig_out_list); ! expand_asm_operands (gnu_template, gnu_output_list, gnu_input_list, ! gnu_clobber_list, Is_Asm_Volatile (gnat_node), input_filename, lineno); /* Copy all the intermediate outputs into the specified outputs. */ *************** tree_transform (gnat_node) *** 3738,3749 **** break; gnu_result_type = get_unpadded_type (Etype (gnat_node)); ! gnu_result ! = build_call_raise ! (Nkind (gnat_node) == N_Raise_Constraint_Error ! ? raise_constraint_error_decl ! : Nkind (gnat_node) == N_Raise_Program_Error ! ? raise_program_error_decl : raise_storage_error_decl); /* If the type is VOID, this is a statement, so we need to generate the code for the call. Handle a Condition, if there --- 3862,3868 ---- break; gnu_result_type = get_unpadded_type (Etype (gnat_node)); ! gnu_result = build_call_raise (UI_To_Int (Reason (gnat_node))); /* If the type is VOID, this is a statement, so we need to generate the code for the call. Handle a Condition, if there *************** tree_transform (gnat_node) *** 3788,3794 **** gnu_result = build1 (NULL_EXPR, gnu_result_type, ! build_call_raise (raise_constraint_error_decl)); } /* If our result has side-effects and is of an unconstrained type, --- 3907,3913 ---- gnu_result = build1 (NULL_EXPR, gnu_result_type, ! build_call_raise (CE_Overflow_Check_Failed)); } /* If our result has side-effects and is of an unconstrained type, *************** process_freeze_entity (gnat_node) *** 4062,4076 **** gnu_new = gnat_to_gnu_entity (gnat_entity, gnu_init, 1); /* If we've made any pointers to the old version of this type, we ! have to update them. Also copy the name of the old object to ! the new one. */ ! if (gnu_old != 0) ! { ! DECL_NAME (gnu_new) = DECL_NAME (gnu_old); ! update_pointer_to (TYPE_MAIN_VARIANT (TREE_TYPE (gnu_old)), ! TREE_TYPE (gnu_new)); ! } } /* Process the list of inlined subprograms of GNAT_NODE, which is an --- 4181,4190 ---- gnu_new = gnat_to_gnu_entity (gnat_entity, gnu_init, 1); /* If we've made any pointers to the old version of this type, we ! have to update them. */ if (gnu_old != 0) ! update_pointer_to (TYPE_MAIN_VARIANT (TREE_TYPE (gnu_old)), ! TREE_TYPE (gnu_new)); } /* Process the list of inlined subprograms of GNAT_NODE, which is an *************** static tree *** 4252,4271 **** emit_access_check (gnu_expr) tree gnu_expr; { ! tree gnu_type = TREE_TYPE (gnu_expr); ! ! /* This only makes sense if GNU_TYPE is a pointer of some sort. */ ! if (! POINTER_TYPE_P (gnu_type) && ! TYPE_FAT_POINTER_P (gnu_type)) ! gigi_abort (322); /* Checked expressions must be evaluated only once. */ ! gnu_expr = make_save_expr (gnu_expr); return emit_check (build_binary_op (EQ_EXPR, integer_type_node, ! gnu_expr, ! convert (TREE_TYPE (gnu_expr), integer_zero_node)), ! gnu_expr); } /* Emits a discriminant check. GNU_EXPR is the expression to be checked and --- 4366,4392 ---- emit_access_check (gnu_expr) tree gnu_expr; { ! tree gnu_check_expr; /* Checked expressions must be evaluated only once. */ ! gnu_check_expr = gnu_expr = protect_multiple_eval (gnu_expr); ! ! /* Technically, we check a fat pointer against two words of zero. However, ! that's wasteful and really doesn't protect against null accesses. It ! makes more sense to check oly the array pointer. */ ! if (TYPE_FAT_POINTER_P (TREE_TYPE (gnu_expr))) ! gnu_check_expr ! = build_component_ref (gnu_expr, get_identifier ("P_ARRAY"), NULL_TREE); ! ! if (! POINTER_TYPE_P (TREE_TYPE (gnu_check_expr))) ! gigi_abort (322); return emit_check (build_binary_op (EQ_EXPR, integer_type_node, ! gnu_check_expr, ! convert (TREE_TYPE (gnu_check_expr), integer_zero_node)), ! gnu_expr, ! CE_Access_Check_Failed); } /* Emits a discriminant check. GNU_EXPR is the expression to be checked and *************** emit_discriminant_check (gnu_expr, gnat_ *** 4289,4295 **** if (Is_Tagged_Type (Scope (orig_comp))) gnat_pref_type = Scope (orig_comp); else ! gnat_pref_type = Etype (Prefix (gnat_node)); if (! Present (gnat_discr_fct)) return gnu_expr; --- 4410,4426 ---- if (Is_Tagged_Type (Scope (orig_comp))) gnat_pref_type = Scope (orig_comp); else ! { ! gnat_pref_type = Etype (Prefix (gnat_node)); ! ! /* For an untagged derived type, use the discriminants of the parent, ! which have been renamed in the derivation, possibly by a one-to-many ! constraint. */ ! if (Is_Derived_Type (gnat_pref_type) ! && (Number_Discriminants (gnat_pref_type) ! != Number_Discriminants (Etype (Base_Type (gnat_pref_type))))) ! gnat_pref_type = Etype (Base_Type (gnat_pref_type)); ! } if (! Present (gnat_discr_fct)) return gnu_expr; *************** emit_discriminant_check (gnu_expr, gnat_ *** 4297,4303 **** gnu_discr_fct = gnat_to_gnu (gnat_discr_fct); /* Checked expressions must be evaluated only once. */ ! gnu_expr = make_save_expr (gnu_expr); /* Create the list of the actual parameters as GCC expects it. This list is the list of the discriminant fields of the --- 4428,4434 ---- gnu_discr_fct = gnat_to_gnu (gnat_discr_fct); /* Checked expressions must be evaluated only once. */ ! gnu_expr = protect_multiple_eval (gnu_expr); /* Create the list of the actual parameters as GCC expects it. This list is the list of the discriminant fields of the *************** emit_discriminant_check (gnu_expr, gnat_ *** 4347,4353 **** emit_check (gnu_cond, build_unary_op (ADDR_EXPR, build_reference_type (TREE_TYPE (gnu_expr)), ! gnu_expr))); } /* Emit code for a range check. GNU_EXPR is the expression to be checked, --- 4478,4485 ---- emit_check (gnu_cond, build_unary_op (ADDR_EXPR, build_reference_type (TREE_TYPE (gnu_expr)), ! gnu_expr), ! CE_Discriminant_Check_Failed)); } /* Emit code for a range check. GNU_EXPR is the expression to be checked, *************** emit_range_check (gnu_expr, gnat_range_t *** 4373,4379 **** return gnu_expr; /* Checked expressions must be evaluated only once. */ ! gnu_expr = make_save_expr (gnu_expr); /* There's no good type to use here, so we might as well use integer_type_node. Note that the form of the check is --- 4505,4511 ---- return gnu_expr; /* Checked expressions must be evaluated only once. */ ! gnu_expr = protect_multiple_eval (gnu_expr); /* There's no good type to use here, so we might as well use integer_type_node. Note that the form of the check is *************** emit_range_check (gnu_expr, gnat_range_t *** 4391,4397 **** convert (gnu_compare_type, gnu_expr), convert (gnu_compare_type, gnu_high)))), ! gnu_expr); } /* Emit code for an index check. GNU_ARRAY_OBJECT is the array object --- 4523,4529 ---- convert (gnu_compare_type, gnu_expr), convert (gnu_compare_type, gnu_high)))), ! gnu_expr, CE_Range_Check_Failed); } /* Emit code for an index check. GNU_ARRAY_OBJECT is the array object *************** emit_index_check (gnu_array_object, gnu_ *** 4416,4422 **** tree gnu_expr_check; /* Checked expressions must be evaluated only once. */ ! gnu_expr = make_save_expr (gnu_expr); /* Must do this computation in the base type in case the expression's type is an unsigned subtypes. */ --- 4548,4554 ---- tree gnu_expr_check; /* Checked expressions must be evaluated only once. */ ! gnu_expr = protect_multiple_eval (gnu_expr); /* Must do this computation in the base type in case the expression's type is an unsigned subtypes. */ *************** emit_index_check (gnu_array_object, gnu_ *** 4444,4478 **** gnu_expr_check, convert (TREE_TYPE (gnu_expr_check), gnu_high))), ! gnu_expr); } /* Given GNU_COND which contains the condition corresponding to an access, discriminant or range check, of value GNU_EXPR, build a COND_EXPR that returns GNU_EXPR if GNU_COND is false and raises a ! CONSTRAINT_ERROR if GNU_COND is true. */ static tree ! emit_check (gnu_cond, gnu_expr) tree gnu_cond; tree gnu_expr; { tree gnu_call; ! gnu_call = build_call_raise (raise_constraint_error_decl); ! /* Use an outer COMPOUND_EXPR to make sure that GNU_EXPR will ! get evaluated in front of the comparison in case it ends ! up being a SAVE_EXPR. Put the whole thing inside its own ! SAVE_EXPR do the inner SAVE_EXPR doesn't leak out. */ ! return make_save_expr (build (COMPOUND_EXPR, TREE_TYPE (gnu_expr), gnu_expr, ! fold (build (COND_EXPR, TREE_TYPE (gnu_expr), ! gnu_cond, ! build (COMPOUND_EXPR, ! TREE_TYPE (gnu_expr), ! gnu_call, gnu_expr), ! gnu_expr)))); } /* Return an expression that converts GNU_EXPR to GNAT_TYPE, doing --- 4576,4623 ---- gnu_expr_check, convert (TREE_TYPE (gnu_expr_check), gnu_high))), ! gnu_expr, CE_Index_Check_Failed); } /* Given GNU_COND which contains the condition corresponding to an access, discriminant or range check, of value GNU_EXPR, build a COND_EXPR that returns GNU_EXPR if GNU_COND is false and raises a ! CONSTRAINT_ERROR if GNU_COND is true. REASON is the code that says ! why the exception was raised. */ static tree ! emit_check (gnu_cond, gnu_expr, reason) tree gnu_cond; tree gnu_expr; + int reason; { tree gnu_call; + tree gnu_result; ! gnu_call = build_call_raise (reason); ! /* Use an outer COMPOUND_EXPR to make sure that GNU_EXPR will get evaluated ! in front of the comparison in case it ends up being a SAVE_EXPR. Put the ! whole thing inside its own SAVE_EXPR so the inner SAVE_EXPR doesn't leak ! out. */ ! gnu_result = fold (build (COND_EXPR, TREE_TYPE (gnu_expr), gnu_cond, ! build (COMPOUND_EXPR, TREE_TYPE (gnu_expr), ! gnu_call, gnu_expr), ! gnu_expr)); ! /* If GNU_EXPR has side effects, make the outer COMPOUND_EXPR and ! protect it. Otherwise, show GNU_RESULT has no side effects: we ! don't need to evaluate it just for the check. */ ! if (TREE_SIDE_EFFECTS (gnu_expr)) ! gnu_result ! = build (COMPOUND_EXPR, TREE_TYPE (gnu_expr), gnu_expr, gnu_result); ! else ! TREE_SIDE_EFFECTS (gnu_result) = 0; ! ! /* ??? Unfortunately, if we don't put a SAVE_EXPR around this whole thing, ! we will repeatedly do the test. It would be nice if GCC was able ! to optimize this and only do it once. */ ! return save_expr (gnu_result); } /* Return an expression that converts GNU_EXPR to GNAT_TYPE, doing *************** convert_with_check (gnat_type, gnu_expr, *** 4523,4546 **** && ! (FLOAT_TYPE_P (gnu_base_type) && INTEGRAL_TYPE_P (gnu_in_basetype))) { /* Ensure GNU_EXPR only gets evaluated once. */ ! tree gnu_input = make_save_expr (gnu_result); tree gnu_cond = integer_zero_node; /* Convert the lower bounds to signed types, so we're sure we're comparing them properly. Likewise, convert the upper bounds to unsigned types. */ if (INTEGRAL_TYPE_P (gnu_in_basetype) && TREE_UNSIGNED (gnu_in_basetype)) ! gnu_in_lb = convert (signed_type (gnu_in_basetype), gnu_in_lb); if (INTEGRAL_TYPE_P (gnu_in_basetype) && ! TREE_UNSIGNED (gnu_in_basetype)) ! gnu_in_ub = convert (unsigned_type (gnu_in_basetype), gnu_in_ub); if (INTEGRAL_TYPE_P (gnu_base_type) && TREE_UNSIGNED (gnu_base_type)) ! gnu_out_lb = convert (signed_type (gnu_base_type), gnu_out_lb); if (INTEGRAL_TYPE_P (gnu_base_type) && ! TREE_UNSIGNED (gnu_base_type)) ! gnu_out_ub = convert (unsigned_type (gnu_base_type), gnu_out_ub); /* Check each bound separately and only if the result bound is tighter than the bound on the input type. Note that all the --- 4668,4691 ---- && ! (FLOAT_TYPE_P (gnu_base_type) && INTEGRAL_TYPE_P (gnu_in_basetype))) { /* Ensure GNU_EXPR only gets evaluated once. */ ! tree gnu_input = protect_multiple_eval (gnu_result); tree gnu_cond = integer_zero_node; /* Convert the lower bounds to signed types, so we're sure we're comparing them properly. Likewise, convert the upper bounds to unsigned types. */ if (INTEGRAL_TYPE_P (gnu_in_basetype) && TREE_UNSIGNED (gnu_in_basetype)) ! gnu_in_lb = convert (gnat_signed_type (gnu_in_basetype), gnu_in_lb); if (INTEGRAL_TYPE_P (gnu_in_basetype) && ! TREE_UNSIGNED (gnu_in_basetype)) ! gnu_in_ub = convert (gnat_unsigned_type (gnu_in_basetype), gnu_in_ub); if (INTEGRAL_TYPE_P (gnu_base_type) && TREE_UNSIGNED (gnu_base_type)) ! gnu_out_lb = convert (gnat_signed_type (gnu_base_type), gnu_out_lb); if (INTEGRAL_TYPE_P (gnu_base_type) && ! TREE_UNSIGNED (gnu_base_type)) ! gnu_out_ub = convert (gnat_unsigned_type (gnu_base_type), gnu_out_ub); /* Check each bound separately and only if the result bound is tighter than the bound on the input type. Note that all the *************** convert_with_check (gnat_type, gnu_expr, *** 4579,4585 **** gnu_out_ub)))); if (! integer_zerop (gnu_cond)) ! gnu_result = emit_check (gnu_cond, gnu_input); } /* Now convert to the result base type. If this is a non-truncating --- 4724,4731 ---- gnu_out_ub)))); if (! integer_zerop (gnu_cond)) ! gnu_result = emit_check (gnu_cond, gnu_input, ! CE_Overflow_Check_Failed); } /* Now convert to the result base type. If this is a non-truncating *************** convert_with_check (gnat_type, gnu_expr, *** 4619,4627 **** return convert (gnu_type, gnu_result); } ! /* Return 1 if GNU_EXPR can be directly addressed. This is the case unless ! it is an expression involving computation or if it involves a bitfield ! reference. This returns the same as mark_addressable in most cases. */ static int addressable_p (gnu_expr) --- 4765,4774 ---- return convert (gnu_type, gnu_result); } ! /* Return 1 if GNU_EXPR can be directly addressed. This is the case ! unless it is an expression involving computation or if it involves ! a bitfield reference. This returns the same as ! gnat_mark_addressable in most cases. */ static int addressable_p (gnu_expr) *************** addressable_p (gnu_expr) *** 4652,4674 **** return (AGGREGATE_TYPE_P (TREE_TYPE (gnu_expr)) && addressable_p (TREE_OPERAND (gnu_expr, 0))); ! case UNCHECKED_CONVERT_EXPR: { ! /* This is addressable if the code in gnat_expand_expr can do ! it by either just taking the operand or by pointer punning. */ ! tree inner = TREE_OPERAND (gnu_expr, 0); tree type = TREE_TYPE (gnu_expr); ! tree inner_type = TREE_TYPE (inner); ! return ((TYPE_MODE (type) == TYPE_MODE (inner_type) ! && (TYPE_ALIGN (type) <= TYPE_ALIGN (inner_type) ! || TYPE_ALIGN (inner_type) >= BIGGEST_ALIGNMENT)) ! || ((TYPE_MODE (type) == BLKmode ! || TYPE_MODE (inner_type) == BLKmode) ! && (TYPE_ALIGN (type) <= TYPE_ALIGN (inner_type) ! || TYPE_ALIGN (inner_type) >= BIGGEST_ALIGNMENT ! || TYPE_ALIGN_OK_P (type) ! || TYPE_ALIGN_OK_P (inner_type)))); } default: --- 4799,4820 ---- return (AGGREGATE_TYPE_P (TREE_TYPE (gnu_expr)) && addressable_p (TREE_OPERAND (gnu_expr, 0))); ! case VIEW_CONVERT_EXPR: { ! /* This is addressable if we can avoid a copy. */ tree type = TREE_TYPE (gnu_expr); ! tree inner_type = TREE_TYPE (TREE_OPERAND (gnu_expr, 0)); ! return (((TYPE_MODE (type) == TYPE_MODE (inner_type) ! && (TYPE_ALIGN (type) <= TYPE_ALIGN (inner_type) ! || TYPE_ALIGN (inner_type) >= BIGGEST_ALIGNMENT)) ! || ((TYPE_MODE (type) == BLKmode ! || TYPE_MODE (inner_type) == BLKmode) ! && (TYPE_ALIGN (type) <= TYPE_ALIGN (inner_type) ! || TYPE_ALIGN (inner_type) >= BIGGEST_ALIGNMENT ! || TYPE_ALIGN_OK (type) ! || TYPE_ALIGN_OK (inner_type)))) ! && addressable_p (TREE_OPERAND (gnu_expr, 0))); } default: *************** maybe_implicit_deref (exp) *** 4937,4977 **** return exp; } ! /* Surround EXP with a SAVE_EXPR, but handle unconstrained objects specially ! since it doesn't make any sense to put them in a SAVE_EXPR. */ tree ! make_save_expr (exp) tree exp; { tree type = TREE_TYPE (exp); ! /* If this is an unchecked conversion, save the input since we may need to ! handle this expression separately if it's the operand of a component ! reference. */ ! if (TREE_CODE (exp) == UNCHECKED_CONVERT_EXPR) ! return build1 (UNCHECKED_CONVERT_EXPR, type, ! make_save_expr (TREE_OPERAND (exp, 0))); ! /* If this is an aggregate type, we may be doing a dereference of it in ! the LHS side of an assignment. In that case, we need to evaluate ! it , take its address, make a SAVE_EXPR of that, then do the indirect ! reference. Note that for an unconstrained array, the effect will be ! to make a SAVE_EXPR of the fat pointer. ! ??? This is an efficiency problem in the case of a type that can be ! placed into memory, but until we can deal with the LHS issue, ! we have to take that hit. This really should test for BLKmode. */ ! else if (TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE ! || (AGGREGATE_TYPE_P (type) && ! TYPE_FAT_POINTER_P (type))) return build_unary_op (INDIRECT_REF, type, save_expr (build_unary_op (ADDR_EXPR, build_reference_type (type), exp))); - - /* Otherwise, just do the usual thing. */ - return save_expr (exp); } /* This is equivalent to stabilize_reference in GCC's tree.c, but we know --- 5083,5124 ---- return exp; } ! /* Protect EXP from multiple evaluation. This may make a SAVE_EXPR. */ tree ! protect_multiple_eval (exp) tree exp; { tree type = TREE_TYPE (exp); ! /* If this has no side effects, we don't need to do anything. */ ! if (! TREE_SIDE_EFFECTS (exp)) ! return exp; ! /* If it is a conversion, protect what's inside the conversion. ! Similarly, if we're indirectly referencing something, we only ! actually need to protect the address since the data itself can't ! change in these situations. */ ! else if (TREE_CODE (exp) == NON_LVALUE_EXPR ! || TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR ! || TREE_CODE (exp) == VIEW_CONVERT_EXPR ! || TREE_CODE (exp) == INDIRECT_REF ! || TREE_CODE (exp) == UNCONSTRAINED_ARRAY_REF) ! return build1 (TREE_CODE (exp), type, ! protect_multiple_eval (TREE_OPERAND (exp, 0))); ! /* If EXP is a fat pointer or something that can be placed into a register, ! just make a SAVE_EXPR. */ ! if (TYPE_FAT_POINTER_P (type) || TYPE_MODE (type) != BLKmode) ! return save_expr (exp); ! ! /* Otherwise, dereference, protect the address, and re-reference. */ ! else return build_unary_op (INDIRECT_REF, type, save_expr (build_unary_op (ADDR_EXPR, build_reference_type (type), exp))); } /* This is equivalent to stabilize_reference in GCC's tree.c, but we know *************** gnat_stabilize_reference (ref, force) *** 5002,5008 **** case FIX_FLOOR_EXPR: case FIX_ROUND_EXPR: case FIX_CEIL_EXPR: ! case UNCHECKED_CONVERT_EXPR: case ADDR_EXPR: result = build1 (code, type, --- 5149,5155 ---- case FIX_FLOOR_EXPR: case FIX_ROUND_EXPR: case FIX_CEIL_EXPR: ! case VIEW_CONVERT_EXPR: case ADDR_EXPR: result = build1 (code, type, *************** gnat_stabilize_reference_1 (e, force) *** 5113,5126 **** return e; case '2': - /* Division is slow and tends to be compiled with jumps, - especially the division by powers of 2 that is often - found inside of an array reference. So do it just once. */ - if (code == TRUNC_DIV_EXPR || code == TRUNC_MOD_EXPR - || code == FLOOR_DIV_EXPR || code == FLOOR_MOD_EXPR - || code == CEIL_DIV_EXPR || code == CEIL_MOD_EXPR - || code == ROUND_DIV_EXPR || code == ROUND_MOD_EXPR) - return save_expr (e); /* Recursively stabilize each operand. */ result = build (code, type, gnat_stabilize_reference_1 (TREE_OPERAND (e, 0), force), --- 5260,5265 ---- *************** build_unit_elab (gnat_unit, body_p, gnu_ *** 5163,5168 **** --- 5302,5311 ---- if (gnu_elab_list == 0) return 1; + /* Prevent the elaboration list from being reclaimed by the GC. */ + gnu_pending_elaboration_lists = chainon (gnu_pending_elaboration_lists, + gnu_elab_list); + /* Set our file and line number to that of the object and set up the elaboration routine. */ gnu_decl = create_subprog_decl (create_concat_name (gnat_unit, *************** build_unit_elab (gnat_unit, body_p, gnu_ *** 5223,5228 **** --- 5366,5374 ---- gnu_block_stack = TREE_CHAIN (gnu_block_stack); end_subprog_body (); + /* We are finished with the elaboration list it can now be discarded. */ + gnu_pending_elaboration_lists = TREE_CHAIN (gnu_pending_elaboration_lists); + /* If there were no insns, we don't need an elab routine. It would be nice to not output this one, but there's no good way to do that. */ return result; *************** init_code_table () *** 5452,5454 **** --- 5598,5602 ---- gnu_codes[N_Op_Shift_Right] = RSHIFT_EXPR; gnu_codes[N_Op_Shift_Right_Arithmetic] = RSHIFT_EXPR; } + + #include "gt-ada-trans.h" diff -Nrc3pad gcc-3.2.3/gcc/ada/tree_gen.adb gcc-3.3/gcc/ada/tree_gen.adb *** gcc-3.2.3/gcc/ada/tree_gen.adb 2002-05-04 03:29:22.000000000 +0000 --- gcc-3.3/gcc/ada/tree_gen.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-1999, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2001, 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- -- *************** with Lib; *** 33,39 **** with Namet; with Nlists; with Opt; ! with Osint; with Repinfo; with Sinput; with Stand; --- 32,38 ---- with Namet; with Nlists; with Opt; ! with Osint.C; with Repinfo; with Sinput; with Stand; *************** with Urealp; *** 44,50 **** procedure Tree_Gen is begin if Opt.Tree_Output then ! Osint.Tree_Create; Opt.Tree_Write; Atree.Tree_Write; Elists.Tree_Write; --- 43,49 ---- procedure Tree_Gen is begin if Opt.Tree_Output then ! Osint.C.Tree_Create; Opt.Tree_Write; Atree.Tree_Write; Elists.Tree_Write; *************** begin *** 58,63 **** Uintp.Tree_Write; Urealp.Tree_Write; Repinfo.Tree_Write; ! Osint.Tree_Close; end if; end Tree_Gen; --- 57,62 ---- Uintp.Tree_Write; Urealp.Tree_Write; Repinfo.Tree_Write; ! Osint.C.Tree_Close; end if; end Tree_Gen; diff -Nrc3pad gcc-3.2.3/gcc/ada/tree_gen.ads gcc-3.3/gcc/ada/tree_gen.ads *** gcc-3.2.3/gcc/ada/tree_gen.ads 2002-05-07 08:22:36.000000000 +0000 --- gcc-3.3/gcc/ada/tree_gen.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/tree_in.adb gcc-3.3/gcc/ada/tree_in.adb *** gcc-3.2.3/gcc/ada/tree_in.adb 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/tree_in.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-1999, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/tree_in.ads gcc-3.3/gcc/ada/tree_in.ads *** gcc-3.2.3/gcc/ada/tree_in.ads 2002-05-07 08:22:36.000000000 +0000 --- gcc-3.3/gcc/ada/tree_in.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994,1995 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/tree_io.adb gcc-3.3/gcc/ada/tree_io.adb *** gcc-3.2.3/gcc/ada/tree_io.adb 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/tree_io.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Tree_IO is *** 72,80 **** Max_Count : constant := 63; -- Maximum data length for one compression sequence - Max_Comp : constant := Max_Count + 1; - -- Maximum length of one compression sequence - -- The above compression scheme applies only to data written with the -- Tree_Write routine and read with Tree_Read. Data written using the -- Tree_Write_Char or Tree_Write_Int routines and read using the --- 71,76 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/tree_io.ads gcc-3.3/gcc/ada/tree_io.ads *** gcc-3.2.3/gcc/ada/tree_io.ads 2002-05-07 08:22:36.000000000 +0000 --- gcc-3.3/gcc/ada/tree_io.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1999 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/treepr.adb gcc-3.3/gcc/ada/treepr.adb *** gcc-3.2.3/gcc/ada/treepr.adb 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/treepr.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package body Treepr is *** 214,244 **** -- printed lines. -------- ! -- PE -- -------- ! procedure PE (E : Elist_Id) is begin Print_Tree_Elist (E); ! end PE; -------- ! -- PL -- -------- ! procedure PL (L : List_Id) is begin Print_Tree_List (L); ! end PL; -------- ! -- PN -- -------- ! procedure PN (N : Node_Id) is begin Print_Tree_Node (N); ! end PN; ---------------- -- Print_Char -- --- 213,243 ---- -- printed lines. -------- ! -- pe -- -------- ! procedure pe (E : Elist_Id) is begin Print_Tree_Elist (E); ! end pe; -------- ! -- pl -- -------- ! procedure pl (L : List_Id) is begin Print_Tree_List (L); ! end pl; -------- ! -- pn -- -------- ! procedure pn (N : Node_Id) is begin Print_Tree_Node (N); ! end pn; ---------------- -- Print_Char -- *************** package body Treepr is *** 1342,1354 **** end Print_Tree_Node; -------- ! -- PT -- -------- ! procedure PT (N : Node_Id) is begin Print_Node_Subtree (N); ! end PT; ------------------- -- Serial_Number -- --- 1341,1353 ---- end Print_Tree_Node; -------- ! -- pt -- -------- ! procedure pt (N : Node_Id) is begin Print_Node_Subtree (N); ! end pt; ------------------- -- Serial_Number -- diff -Nrc3pad gcc-3.2.3/gcc/ada/treepr.ads gcc-3.3/gcc/ada/treepr.ads *** gcc-3.2.3/gcc/ada/treepr.ads 2002-05-07 08:22:36.000000000 +0000 --- gcc-3.3/gcc/ada/treepr.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992,1993,1994,1995 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Treepr is *** 60,78 **** -- Prints the subtree consisting of the given element list and all its -- referenced descendants. ! procedure PE (E : Elist_Id); -- Debugging procedure (to be called within gdb) -- same as Print_Tree_Elist ! procedure PL (L : List_Id); -- Debugging procedure (to be called within gdb) -- same as Print_Tree_List ! procedure PN (N : Node_Id); -- Debugging procedure (to be called within gdb) -- same as Print_Tree_Node with Label = "" ! procedure PT (N : Node_Id); -- Debugging procedure (to be called within gdb) -- same as Print_Node_Subtree --- 59,81 ---- -- Prints the subtree consisting of the given element list and all its -- referenced descendants. ! procedure pe (E : Elist_Id); ! pragma Export (Ada, pe); -- Debugging procedure (to be called within gdb) -- same as Print_Tree_Elist ! procedure pl (L : List_Id); ! pragma Export (Ada, pl); -- Debugging procedure (to be called within gdb) -- same as Print_Tree_List ! procedure pn (N : Node_Id); ! pragma Export (Ada, pn); -- Debugging procedure (to be called within gdb) -- same as Print_Tree_Node with Label = "" ! procedure pt (N : Node_Id); ! pragma Export (Ada, pt); -- Debugging procedure (to be called within gdb) -- same as Print_Node_Subtree diff -Nrc3pad gcc-3.2.3/gcc/ada/treeprs.ads gcc-3.3/gcc/ada/treeprs.ads *** gcc-3.2.3/gcc/ada/treeprs.ads 2003-04-22 06:56:18.000000000 +0000 --- gcc-3.3/gcc/ada/treeprs.ads 2003-05-14 00:18:14.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- ! -- Generated by xtreeprs revision 1.1 using -- ! -- sinfo.ads revision 1.6 -- ! -- treeprs.adt revision 1.1 -- -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,14 ---- -- -- -- S p e c -- -- -- ! -- Generated by xtreeprs revision using -- ! -- sinfo.ads revision 1.439 -- ! -- treeprs.adt revision 1.17 -- -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- *************** package Treeprs is *** 195,201 **** "" & -- Attribute_Reference "%Prefix$Attribute_Name#Expressions&Entity&Associated_Node2Do_Access_C" & ! "heck8Do_Overflow_Check4Redundant_Use+OK_For_Stream" & -- And_Then "#Actions" & -- Conditional_Expression --- 195,202 ---- "" & -- Attribute_Reference "%Prefix$Attribute_Name#Expressions&Entity&Associated_Node2Do_Access_C" & ! "heck8Do_Overflow_Check4Redundant_Use+OK_For_Stream5Must_Be_Byte_Al" & ! "igned" & -- And_Then "#Actions" & -- Conditional_Expression *************** package Treeprs is *** 223,233 **** -- Qualified_Expression "&Subtype_Mark%Expression" & -- Raise_Constraint_Error ! "#Condition" & -- Raise_Program_Error ! "#Condition" & -- Raise_Storage_Error ! "#Condition" & -- Aggregate "#Expressions$Component_Associations8Null_Record_Present%Aggregate_Bou" & "nds&Associated_Node+Static_Processing_OK9Compile_Time_Known_Aggreg" & --- 224,234 ---- -- Qualified_Expression "&Subtype_Mark%Expression" & -- Raise_Constraint_Error ! "#Condition%Reason" & -- Raise_Program_Error ! "#Condition%Reason" & -- Raise_Storage_Error ! "#Condition%Reason" & -- Aggregate "#Expressions$Component_Associations8Null_Record_Present%Aggregate_Bou" & "nds&Associated_Node+Static_Processing_OK9Compile_Time_Known_Aggreg" & *************** package Treeprs is *** 483,489 **** -- Discriminant_Specification "#Defining_Identifier'Discriminant_Type%Expression,More_Ids-Prev_Ids" & -- Enumeration_Type_Definition ! "#Literals" & -- Entry_Body "#Defining_Identifier'Entry_Body_Formal_Part$Declarations&Handled_Stat" & "ement_Sequence%Activation_Chain_Entity" & --- 484,490 ---- -- Discriminant_Specification "#Defining_Identifier'Discriminant_Type%Expression,More_Ids-Prev_Ids" & -- Enumeration_Type_Definition ! "#Literals&End_Label" & -- Entry_Body "#Defining_Identifier'Entry_Body_Formal_Part$Declarations&Handled_Stat" & "ement_Sequence%Activation_Chain_Entity" & *************** package Treeprs is *** 630,798 **** N_Op_Not => 980, N_Op_Plus => 980, N_Attribute_Reference => 980, ! N_And_Then => 1099, ! N_Conditional_Expression => 1107, ! N_Explicit_Dereference => 1145, ! N_Function_Call => 1168, ! N_In => 1289, ! N_Indexed_Component => 1289, ! N_Integer_Literal => 1324, ! N_Not_In => 1344, ! N_Null => 1344, ! N_Or_Else => 1344, ! N_Procedure_Call_Statement => 1352, ! N_Qualified_Expression => 1473, ! N_Raise_Constraint_Error => 1497, ! N_Raise_Program_Error => 1507, ! N_Raise_Storage_Error => 1517, ! N_Aggregate => 1527, ! N_Allocator => 1683, ! N_Extension_Aggregate => 1760, ! N_Range => 1863, ! N_Real_Literal => 1904, ! N_Reference => 1958, ! N_Selected_Component => 1965, ! N_Slice => 2040, ! N_String_Literal => 2078, ! N_Subprogram_Info => 2104, ! N_Type_Conversion => 2115, ! N_Unchecked_Expression => 2230, ! N_Unchecked_Type_Conversion => 2241, ! N_Subtype_Indication => 2282, ! N_Component_Declaration => 2322, ! N_Entry_Declaration => 2406, ! N_Formal_Object_Declaration => 2479, ! N_Formal_Type_Declaration => 2564, ! N_Full_Type_Declaration => 2665, ! N_Incomplete_Type_Declaration => 2753, ! N_Loop_Parameter_Specification => 2831, ! N_Object_Declaration => 2895, ! N_Protected_Type_Declaration => 3142, ! N_Private_Extension_Declaration => 3230, ! N_Private_Type_Declaration => 3344, ! N_Subtype_Declaration => 3470, ! N_Function_Specification => 3544, ! N_Procedure_Specification => 3636, ! N_Entry_Index_Specification => 3715, ! N_Freeze_Entity => 3763, ! N_Access_Function_Definition => 3831, ! N_Access_Procedure_Definition => 3887, ! N_Task_Type_Declaration => 3930, ! N_Package_Body_Stub => 4033, ! N_Protected_Body_Stub => 4085, ! N_Subprogram_Body_Stub => 4137, ! N_Task_Body_Stub => 4183, ! N_Function_Instantiation => 4235, ! N_Package_Instantiation => 4321, ! N_Procedure_Instantiation => 4407, ! N_Package_Body => 4493, ! N_Subprogram_Body => 4591, ! N_Protected_Body => 4818, ! N_Task_Body => 4900, ! N_Implicit_Label_Declaration => 5038, ! N_Package_Declaration => 5074, ! N_Single_Task_Declaration => 5143, ! N_Subprogram_Declaration => 5179, ! N_Use_Package_Clause => 5239, ! N_Generic_Package_Declaration => 5282, ! N_Generic_Subprogram_Declaration => 5379, ! N_Constrained_Array_Definition => 5452, ! N_Unconstrained_Array_Definition => 5516, ! N_Exception_Renaming_Declaration => 5565, ! N_Object_Renaming_Declaration => 5590, ! N_Package_Renaming_Declaration => 5662, ! N_Subprogram_Renaming_Declaration => 5698, ! N_Generic_Function_Renaming_Declaration => 5748, ! N_Generic_Package_Renaming_Declaration => 5784, ! N_Generic_Procedure_Renaming_Declaration => 5820, ! N_Abort_Statement => 5856, ! N_Accept_Statement => 5862, ! N_Assignment_Statement => 5957, ! N_Asynchronous_Select => 6043, ! N_Block_Statement => 6081, ! N_Case_Statement => 6246, ! N_Code_Statement => 6279, ! N_Conditional_Entry_Call => 6290, ! N_Delay_Relative_Statement => 6329, ! N_Delay_Until_Statement => 6340, ! N_Entry_Call_Statement => 6351, ! N_Free_Statement => 6398, ! N_Goto_Statement => 6440, ! N_Loop_Statement => 6460, ! N_Null_Statement => 6532, ! N_Raise_Statement => 6532, ! N_Requeue_Statement => 6537, ! N_Return_Statement => 6556, ! N_Selective_Accept => 6630, ! N_Timed_Entry_Call => 6666, ! N_Exit_Statement => 6707, ! N_If_Statement => 6722, ! N_Accept_Alternative => 6785, ! N_Delay_Alternative => 6861, ! N_Elsif_Part => 6913, ! N_Entry_Body_Formal_Part => 6957, ! N_Iteration_Scheme => 7018, ! N_Terminate_Alternative => 7075, ! N_Abortable_Part => 7114, ! N_Abstract_Subprogram_Declaration => 7125, ! N_Access_Definition => 7139, ! N_Access_To_Object_Definition => 7152, ! N_Case_Statement_Alternative => 7200, ! N_Compilation_Unit => 7228, ! N_Compilation_Unit_Aux => 7367, ! N_Component_Association => 7402, ! N_Component_List => 7434, ! N_Derived_Type_Definition => 7476, ! N_Decimal_Fixed_Point_Definition => 7534, ! N_Defining_Program_Unit_Name => 7594, ! N_Delta_Constraint => 7619, ! N_Designator => 7653, ! N_Digits_Constraint => 7669, ! N_Discriminant_Association => 7704, ! N_Discriminant_Specification => 7730, ! N_Enumeration_Type_Definition => 7797, ! N_Entry_Body => 7806, ! N_Entry_Call_Alternative => 7913, ! N_Exception_Declaration => 7960, ! N_Exception_Handler => 8009, ! N_Floating_Point_Definition => 8074, ! N_Formal_Decimal_Fixed_Point_Definition => 8117, ! N_Formal_Derived_Type_Definition => 8117, ! N_Formal_Discrete_Type_Definition => 8163, ! N_Formal_Floating_Point_Definition => 8163, ! N_Formal_Modular_Type_Definition => 8163, ! N_Formal_Ordinary_Fixed_Point_Definition => 8163, ! N_Formal_Package_Declaration => 8163, ! N_Formal_Private_Type_Definition => 8250, ! N_Formal_Signed_Integer_Type_Definition => 8298, ! N_Formal_Subprogram_Declaration => 8298, ! N_Generic_Association => 8337, ! N_Handled_Sequence_Of_Statements => 8385, ! N_Index_Or_Discriminant_Constraint => 8477, ! N_Itype_Reference => 8489, ! N_Label => 8495, ! N_Modular_Type_Definition => 8521, ! N_Number_Declaration => 8532, ! N_Ordinary_Fixed_Point_Definition => 8581, ! N_Others_Choice => 8623, ! N_Package_Specification => 8658, ! N_Parameter_Association => 8744, ! N_Parameter_Specification => 8802, ! N_Protected_Definition => 8931, ! N_Range_Constraint => 9003, ! N_Real_Range_Specification => 9020, ! N_Record_Definition => 9041, ! N_Signed_Integer_Type_Definition => 9127, ! N_Single_Protected_Declaration => 9148, ! N_Subunit => 9189, ! N_Task_Definition => 9225, ! N_Triggering_Alternative => 9363, ! N_Use_Type_Clause => 9410, ! N_Validate_Unchecked_Conversion => 9461, ! N_Variant => 9485, ! N_Variant_Part => 9564, ! N_With_Clause => 9578, ! N_With_Type_Clause => 9753, ! N_Unused_At_End => 9773); end Treeprs; --- 631,799 ---- N_Op_Not => 980, N_Op_Plus => 980, N_Attribute_Reference => 980, ! N_And_Then => 1120, ! N_Conditional_Expression => 1128, ! N_Explicit_Dereference => 1166, ! N_Function_Call => 1189, ! N_In => 1310, ! N_Indexed_Component => 1310, ! N_Integer_Literal => 1345, ! N_Not_In => 1365, ! N_Null => 1365, ! N_Or_Else => 1365, ! N_Procedure_Call_Statement => 1373, ! N_Qualified_Expression => 1494, ! N_Raise_Constraint_Error => 1518, ! N_Raise_Program_Error => 1535, ! N_Raise_Storage_Error => 1552, ! N_Aggregate => 1569, ! N_Allocator => 1725, ! N_Extension_Aggregate => 1802, ! N_Range => 1905, ! N_Real_Literal => 1946, ! N_Reference => 2000, ! N_Selected_Component => 2007, ! N_Slice => 2082, ! N_String_Literal => 2120, ! N_Subprogram_Info => 2146, ! N_Type_Conversion => 2157, ! N_Unchecked_Expression => 2272, ! N_Unchecked_Type_Conversion => 2283, ! N_Subtype_Indication => 2324, ! N_Component_Declaration => 2364, ! N_Entry_Declaration => 2448, ! N_Formal_Object_Declaration => 2521, ! N_Formal_Type_Declaration => 2606, ! N_Full_Type_Declaration => 2707, ! N_Incomplete_Type_Declaration => 2795, ! N_Loop_Parameter_Specification => 2873, ! N_Object_Declaration => 2937, ! N_Protected_Type_Declaration => 3184, ! N_Private_Extension_Declaration => 3272, ! N_Private_Type_Declaration => 3386, ! N_Subtype_Declaration => 3512, ! N_Function_Specification => 3586, ! N_Procedure_Specification => 3678, ! N_Entry_Index_Specification => 3757, ! N_Freeze_Entity => 3805, ! N_Access_Function_Definition => 3873, ! N_Access_Procedure_Definition => 3929, ! N_Task_Type_Declaration => 3972, ! N_Package_Body_Stub => 4075, ! N_Protected_Body_Stub => 4127, ! N_Subprogram_Body_Stub => 4179, ! N_Task_Body_Stub => 4225, ! N_Function_Instantiation => 4277, ! N_Package_Instantiation => 4363, ! N_Procedure_Instantiation => 4449, ! N_Package_Body => 4535, ! N_Subprogram_Body => 4633, ! N_Protected_Body => 4860, ! N_Task_Body => 4942, ! N_Implicit_Label_Declaration => 5080, ! N_Package_Declaration => 5116, ! N_Single_Task_Declaration => 5185, ! N_Subprogram_Declaration => 5221, ! N_Use_Package_Clause => 5281, ! N_Generic_Package_Declaration => 5324, ! N_Generic_Subprogram_Declaration => 5421, ! N_Constrained_Array_Definition => 5494, ! N_Unconstrained_Array_Definition => 5558, ! N_Exception_Renaming_Declaration => 5607, ! N_Object_Renaming_Declaration => 5632, ! N_Package_Renaming_Declaration => 5704, ! N_Subprogram_Renaming_Declaration => 5740, ! N_Generic_Function_Renaming_Declaration => 5790, ! N_Generic_Package_Renaming_Declaration => 5826, ! N_Generic_Procedure_Renaming_Declaration => 5862, ! N_Abort_Statement => 5898, ! N_Accept_Statement => 5904, ! N_Assignment_Statement => 5999, ! N_Asynchronous_Select => 6085, ! N_Block_Statement => 6123, ! N_Case_Statement => 6288, ! N_Code_Statement => 6321, ! N_Conditional_Entry_Call => 6332, ! N_Delay_Relative_Statement => 6371, ! N_Delay_Until_Statement => 6382, ! N_Entry_Call_Statement => 6393, ! N_Free_Statement => 6440, ! N_Goto_Statement => 6482, ! N_Loop_Statement => 6502, ! N_Null_Statement => 6574, ! N_Raise_Statement => 6574, ! N_Requeue_Statement => 6579, ! N_Return_Statement => 6598, ! N_Selective_Accept => 6672, ! N_Timed_Entry_Call => 6708, ! N_Exit_Statement => 6749, ! N_If_Statement => 6764, ! N_Accept_Alternative => 6827, ! N_Delay_Alternative => 6903, ! N_Elsif_Part => 6955, ! N_Entry_Body_Formal_Part => 6999, ! N_Iteration_Scheme => 7060, ! N_Terminate_Alternative => 7117, ! N_Abortable_Part => 7156, ! N_Abstract_Subprogram_Declaration => 7167, ! N_Access_Definition => 7181, ! N_Access_To_Object_Definition => 7194, ! N_Case_Statement_Alternative => 7242, ! N_Compilation_Unit => 7270, ! N_Compilation_Unit_Aux => 7409, ! N_Component_Association => 7444, ! N_Component_List => 7476, ! N_Derived_Type_Definition => 7518, ! N_Decimal_Fixed_Point_Definition => 7576, ! N_Defining_Program_Unit_Name => 7636, ! N_Delta_Constraint => 7661, ! N_Designator => 7695, ! N_Digits_Constraint => 7711, ! N_Discriminant_Association => 7746, ! N_Discriminant_Specification => 7772, ! N_Enumeration_Type_Definition => 7839, ! N_Entry_Body => 7858, ! N_Entry_Call_Alternative => 7965, ! N_Exception_Declaration => 8012, ! N_Exception_Handler => 8061, ! N_Floating_Point_Definition => 8126, ! N_Formal_Decimal_Fixed_Point_Definition => 8169, ! N_Formal_Derived_Type_Definition => 8169, ! N_Formal_Discrete_Type_Definition => 8215, ! N_Formal_Floating_Point_Definition => 8215, ! N_Formal_Modular_Type_Definition => 8215, ! N_Formal_Ordinary_Fixed_Point_Definition => 8215, ! N_Formal_Package_Declaration => 8215, ! N_Formal_Private_Type_Definition => 8302, ! N_Formal_Signed_Integer_Type_Definition => 8350, ! N_Formal_Subprogram_Declaration => 8350, ! N_Generic_Association => 8389, ! N_Handled_Sequence_Of_Statements => 8437, ! N_Index_Or_Discriminant_Constraint => 8529, ! N_Itype_Reference => 8541, ! N_Label => 8547, ! N_Modular_Type_Definition => 8573, ! N_Number_Declaration => 8584, ! N_Ordinary_Fixed_Point_Definition => 8633, ! N_Others_Choice => 8675, ! N_Package_Specification => 8710, ! N_Parameter_Association => 8796, ! N_Parameter_Specification => 8854, ! N_Protected_Definition => 8983, ! N_Range_Constraint => 9055, ! N_Real_Range_Specification => 9072, ! N_Record_Definition => 9093, ! N_Signed_Integer_Type_Definition => 9179, ! N_Single_Protected_Declaration => 9200, ! N_Subunit => 9241, ! N_Task_Definition => 9277, ! N_Triggering_Alternative => 9415, ! N_Use_Type_Clause => 9462, ! N_Validate_Unchecked_Conversion => 9513, ! N_Variant => 9537, ! N_Variant_Part => 9616, ! N_With_Clause => 9630, ! N_With_Type_Clause => 9805, ! N_Unused_At_End => 9825); end Treeprs; diff -Nrc3pad gcc-3.2.3/gcc/ada/treeprs.adt gcc-3.3/gcc/ada/treeprs.adt *** gcc-3.2.3/gcc/ada/treeprs.adt 2002-05-07 08:22:36.000000000 +0000 --- gcc-3.3/gcc/ada/treeprs.adt 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- T e m p l a t e -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1997 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/ttypef.ads gcc-3.3/gcc/ada/ttypef.ads *** gcc-3.2.3/gcc/ada/ttypef.ads 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/ttypef.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/ttypes.ads gcc-3.3/gcc/ada/ttypes.ads *** gcc-3.2.3/gcc/ada/ttypes.ads 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/ttypes.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Ttypes is *** 143,149 **** Standard_Character_Size : constant Pos := Get_Char_Size; ! Standard_Wide_Character_Size : constant Pos := 2 * Get_Char_Size; -- The Standard.Wide_Character type is special in the sense that -- it is not defined in terms of its corresponding C type (wchar_t). -- Unfortunately this makes the representation of Wide_Character --- 142,148 ---- Standard_Character_Size : constant Pos := Get_Char_Size; ! Standard_Wide_Character_Size : constant Pos := 16; -- The Standard.Wide_Character type is special in the sense that -- it is not defined in terms of its corresponding C type (wchar_t). -- Unfortunately this makes the representation of Wide_Character diff -Nrc3pad gcc-3.2.3/gcc/ada/types.adb gcc-3.3/gcc/ada/types.adb *** gcc-3.2.3/gcc/ada/types.adb 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/types.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** package body Types is *** 128,137 **** -- Get_Character -- ------------------- - -- Note: raises Constraint_Error if checks on and C out of range - function Get_Character (C : Char_Code) return Character is begin return Character'Val (C); end Get_Character; --- 127,135 ---- -- Get_Character -- ------------------- function Get_Character (C : Char_Code) return Character is begin + pragma Assert (C <= 255); return Character'Val (C); end Get_Character; diff -Nrc3pad gcc-3.2.3/gcc/ada/types.ads gcc-3.3/gcc/ada/types.ads *** gcc-3.2.3/gcc/ada/types.ads 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/types.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.5.10.1 $ -- -- ! -- Copyright (C) 1992-2001 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** pragma Preelaborate (Types); *** 380,385 **** --- 379,387 ---- -- indicate that some kind of error was encountered in scanning out -- the relevant name, so it does not have a representable label. + subtype Error_Name_Or_No_Name is Name_Id range No_Name .. Error_Name; + -- Used to test for either error name or no name + First_Name_Id : constant Name_Id := Names_Low_Bound + 2; -- Subscript of first entry in names table *************** pragma Preelaborate (Types); *** 721,724 **** --- 723,802 ---- -- than a type to avoid some annoying processing problems with certain -- routines in Einfo (processing them to create the corresponding C). + ------------------------------ + -- Run-Time Exception Codes -- + ------------------------------ + + -- When the code generator generates a run-time exception, it provides + -- a reason code which is one of the following. This reason code is used + -- to select the appropriate run-time routine to be called, determining + -- both the exception to be raised, and the message text to be added. + + -- The prefix CE/PE/SE indicates the exception to be raised + -- CE = Constraint_Error + -- PE = Program_Error + -- SE = Storage_Error + + -- The remaining part of the name indicates the message text to be added, + -- where all letters are lower case, and underscores are converted to + -- spaces (for example CE_Invalid_Data adds the text "invalid data"). + + -- To add a new code, you need to do the following: + + -- 1. Modify the type and subtype declarations below appropriately, + -- keeping things in alphabetical order. + + -- 2. Modify the corresponding definitions in a-types.h, including + -- the definition of last_reason_code. + + -- 3. Add a new routine in Ada.Exceptions with the appropriate call + -- and static string constant + + -- 4. Initialize the new entry in raise_decls + + type RT_Exception_Code is ( + CE_Access_Check_Failed, + CE_Access_Parameter_Is_Null, + CE_Discriminant_Check_Failed, + CE_Divide_By_Zero, + CE_Explicit_Raise, + CE_Index_Check_Failed, + CE_Invalid_Data, + CE_Length_Check_Failed, + CE_Overflow_Check_Failed, + CE_Partition_Check_Failed, + CE_Range_Check_Failed, + CE_Tag_Check_Failed, + + PE_Access_Before_Elaboration, + PE_Accessibility_Check_Failed, + PE_All_Guards_Closed, + PE_Duplicated_Entry_Address, + PE_Explicit_Raise, + PE_Finalize_Raised_Exception, + PE_Invalid_Data, + PE_Misaligned_Address_Value, + PE_Missing_Return, + PE_Potentially_Blocking_Operation, + PE_Stubbed_Subprogram_Called, + PE_Unchecked_Union_Restriction, + + SE_Empty_Storage_Pool, + SE_Explicit_Raise, + SE_Infinite_Recursion, + SE_Object_Too_Large, + SE_Restriction_Violation); + + subtype RT_CE_Exceptions is RT_Exception_Code range + CE_Access_Check_Failed .. + CE_Tag_Check_Failed; + + subtype RT_PE_Exceptions is RT_Exception_Code range + PE_Access_Before_Elaboration .. + PE_Unchecked_Union_Restriction; + + subtype RT_SE_Exceptions is RT_Exception_Code range + SE_Empty_Storage_Pool .. + SE_Restriction_Violation; + end Types; diff -Nrc3pad gcc-3.2.3/gcc/ada/types.h gcc-3.3/gcc/ada/types.h *** gcc-3.2.3/gcc/ada/types.h 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/types.h 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * ! * Copyright (C) 1992-2001, 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- * --- 6,13 ---- * * * C Header File * * * * * ! * Copyright (C) 1992-2002, 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- * *************** typedef Int Mechanism_Type; *** 333,335 **** --- 332,367 ---- #define By_Descriptor_SB (-8) #define By_Descriptor_A (-9) #define By_Descriptor_NCA (-10) + + /* Definitions of Reason codes for Raise_xxx_Error nodes */ + #define CE_Access_Check_Failed 0 + #define CE_Access_Parameter_Is_Null 1 + #define CE_Discriminant_Check_Failed 2 + #define CE_Divide_By_Zero 3 + #define CE_Explicit_Raise 4 + #define CE_Index_Check_Failed 5 + #define CE_Invalid_Data 6 + #define CE_Length_Check_Failed 7 + #define CE_Overflow_Check_Failed 8 + #define CE_Partition_Check_Failed 9 + #define CE_Range_Check_Failed 10 + #define CE_Tag_Check_Failed 11 + #define PE_Access_Before_Elaboration 12 + #define PE_Accessibility_Check_Failed 13 + #define PE_All_Guards_Closed 14 + #define PE_Duplicated_Entry_Address 15 + #define PE_Explicit_Raise 16 + #define PE_Finalize_Raised_Exception 17 + #define PE_Invalid_Data 18 + #define PE_Misaligned_Address_Value 19 + #define PE_Missing_Return 20 + #define PE_Potentially_Blocking_Operation 21 + #define PE_Stubbed_Subprogram_Called 22 + #define PE_Unchecked_Union_Restriction 23 + #define SE_Empty_Storage_Pool 24 + #define SE_Explicit_Raise 25 + #define SE_Infinite_Recursion 26 + #define SE_Object_Too_Large 27 + #define SE_Restriction_Violation 28 + + #define LAST_REASON_CODE 28 diff -Nrc3pad gcc-3.2.3/gcc/ada/uintp.adb gcc-3.3/gcc/ada/uintp.adb *** gcc-3.2.3/gcc/ada/uintp.adb 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/uintp.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/uintp.ads gcc-3.3/gcc/ada/uintp.ads *** gcc-3.2.3/gcc/ada/uintp.ads 2002-05-04 03:29:23.000000000 +0000 --- gcc-3.3/gcc/ada/uintp.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** *** 40,45 **** --- 39,45 ---- with Alloc; with Table; + pragma Elaborate_All (Table); with Types; use Types; package Uintp is *************** package Uintp is *** 265,274 **** --- 265,276 ---- -- will be more convenient to read. procedure pid (Input : Uint); + pragma Export (Ada, pid); -- Writes representation of Uint in decimal with a terminating line -- return. This is intended for use from the debugger. procedure pih (Input : Uint); + pragma Export (Ada, pih); -- Writes representation of Uint in hex with a terminating line return. -- This is intended for use from the debugger. diff -Nrc3pad gcc-3.2.3/gcc/ada/uintp.h gcc-3.3/gcc/ada/uintp.h *** gcc-3.2.3/gcc/ada/uintp.h 2002-05-04 03:29:24.000000000 +0000 --- gcc-3.3/gcc/ada/uintp.h 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.1.16.1 $ * * * Copyright (C) 1992-2001, Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/uname.adb gcc-3.3/gcc/ada/uname.adb *** gcc-3.2.3/gcc/ada/uname.adb 2002-05-04 03:29:24.000000000 +0000 --- gcc-3.3/gcc/ada/uname.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/uname.ads gcc-3.3/gcc/ada/uname.ads *** gcc-3.2.3/gcc/ada/uname.ads 2002-05-07 08:22:36.000000000 +0000 --- gcc-3.3/gcc/ada/uname.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998, Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/unchconv.ads gcc-3.3/gcc/ada/unchconv.ads *** gcc-3.2.3/gcc/ada/unchconv.ads 2002-05-07 08:22:37.000000000 +0000 --- gcc-3.3/gcc/ada/unchconv.ads 2002-03-14 11:00:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/unchdeal.ads gcc-3.3/gcc/ada/unchdeal.ads *** gcc-3.2.3/gcc/ada/unchdeal.ads 2002-05-07 08:22:37.000000000 +0000 --- gcc-3.3/gcc/ada/unchdeal.ads 2002-03-14 11:00:21.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- This specification is adapted from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/urealp.adb gcc-3.3/gcc/ada/urealp.adb *** gcc-3.2.3/gcc/ada/urealp.adb 2002-05-04 03:29:24.000000000 +0000 --- gcc-3.3/gcc/ada/urealp.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/urealp.ads gcc-3.3/gcc/ada/urealp.ads *** gcc-3.2.3/gcc/ada/urealp.ads 2002-05-07 08:22:37.000000000 +0000 --- gcc-3.3/gcc/ada/urealp.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- ! -- Copyright (C) 1992-1998 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1992-2002 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- -- *************** package Urealp is *** 265,270 **** --- 264,270 ---- -- output is of the form [numerator/denominator]. procedure pr (Real : Ureal); + pragma Export (Ada, pr); -- Writes value of Real to standard output with a terminating line return, -- using UR_Write as described above. This is for use from the debugger. diff -Nrc3pad gcc-3.2.3/gcc/ada/urealp.h gcc-3.3/gcc/ada/urealp.h *** gcc-3.2.3/gcc/ada/urealp.h 2002-05-04 03:29:24.000000000 +0000 --- gcc-3.3/gcc/ada/urealp.h 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** * * * C Header File * * * - * $Revision: 1.2.10.1 $ * * * Copyright (C) 1992-2001 Free Software Foundation, Inc. * * * --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/usage.adb gcc-3.3/gcc/ada/usage.adb *** gcc-3.2.3/gcc/ada/usage.adb 2002-05-04 03:29:24.000000000 +0000 --- gcc-3.3/gcc/ada/usage.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.5.10.1 $ -- -- ! -- Copyright (C) 1992-2001, 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1992-2002, 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- -- *************** with System.WCh_Con; use System.WCh_Con; *** 35,41 **** procedure Usage is procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat"); ! -- Output two spaces followed by default switch character followed -- Prefix, followed by the string given as the argument, and then -- enough blanks to tab to column 13, i.e. assuming Sw is not longer -- than 5 characters, the maximum allowed, Write_Switch_Char will --- 34,40 ---- procedure Usage is procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat"); ! -- Output two spaces followed by the switch character minus followed -- Prefix, followed by the string given as the argument, and then -- enough blanks to tab to column 13, i.e. assuming Sw is not longer -- than 5 characters, the maximum allowed, Write_Switch_Char will *************** procedure Usage is *** 43,50 **** procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat") is begin ! Write_Str (" "); ! Write_Char (Switch_Character); Write_Str (Prefix); Write_Str (Sw); --- 42,48 ---- procedure Write_Switch_Char (Sw : String; Prefix : String := "gnat") is begin ! Write_Str (" -"); Write_Str (Prefix); Write_Str (Sw); *************** begin *** 193,199 **** -- Line for -gnati switch Write_Switch_Char ("i?"); ! Write_Line ("Identifier char set (?=1/2/3/4/5/8/p/f/n/w)"); -- Line for -gnatk switch --- 191,197 ---- -- Line for -gnati switch Write_Switch_Char ("i?"); ! Write_Line ("Identifier char set (?=1/2/3/4/5/8/9/p/f/n/w)"); -- Line for -gnatk switch *************** begin *** 296,328 **** Write_Line ("Enable selected validity checking mode, xx = list of parameters:"); Write_Line (" a turn on all validity checking options"); ! Write_Line (" c turn on validity checking for copies"); ! Write_Line (" C turn off validity checking for copies"); ! Write_Line (" f turn on validity checking for floating-point"); ! Write_Line (" F turn off validity checking for floating-point"); ! Write_Line (" i turn on validity checking for in params"); ! Write_Line (" I turn off validity checking for in params"); ! Write_Line (" m turn on validity checking for in out params"); ! Write_Line (" M turn off validity checking for in out params"); ! Write_Line (" r turn on validity checking for returns"); ! Write_Line (" R turn off validity checking for returns"); ! Write_Line (" s turn on validity checking for subscripts"); ! Write_Line (" S turn off validity checking for subscripts"); ! Write_Line (" t turn on validity checking for tests"); ! Write_Line (" T turn off validity checking for tests"); Write_Line (" n turn off all validity checks (including RM)"); -- Lines for -gnatw switch Write_Switch_Char ("wxx"); Write_Line ("Enable selected warning modes, xx = list of parameters:"); ! Write_Line (" a turn on all optional warnings (except b,h)"); Write_Line (" A turn off all optional warnings"); Write_Line (" b turn on biased rounding warnings"); Write_Line (" B turn off biased rounding warnings"); Write_Line (" c turn on constant conditional warnings"); Write_Line (" C* turn off constant conditional warnings"); Write_Line (" e treat all warnings as errors"); Write_Line (" h turn on warnings for hiding variables"); Write_Line (" H* turn off warnings for hiding variables"); Write_Line (" i* turn on warnings for implementation units"); --- 294,334 ---- Write_Line ("Enable selected validity checking mode, xx = list of parameters:"); Write_Line (" a turn on all validity checking options"); ! Write_Line (" c turn on checking for copies"); ! Write_Line (" C turn off checking for copies"); ! Write_Line (" d turn on default (RM) checking"); ! Write_Line (" D turn off default (RM) checking"); ! Write_Line (" f turn on checking for floating-point"); ! Write_Line (" F turn off checking for floating-point"); ! Write_Line (" i turn on checking for in params"); ! Write_Line (" I turn off checking for in params"); ! Write_Line (" m turn on checking for in out params"); ! Write_Line (" M turn off checking for in out params"); ! Write_Line (" o turn on checking for operators/attributes"); ! Write_Line (" O turn off checking for operators/attributes"); ! Write_Line (" r turn on checking for returns"); ! Write_Line (" R turn off checking for returns"); ! Write_Line (" s turn on checking for subscripts"); ! Write_Line (" S turn off checking for subscripts"); ! Write_Line (" t turn on checking for tests"); ! Write_Line (" T turn off checking for tests"); Write_Line (" n turn off all validity checks (including RM)"); -- Lines for -gnatw switch Write_Switch_Char ("wxx"); Write_Line ("Enable selected warning modes, xx = list of parameters:"); ! Write_Line (" a turn on all optional warnings (except b,d,h)"); Write_Line (" A turn off all optional warnings"); Write_Line (" b turn on biased rounding warnings"); Write_Line (" B turn off biased rounding warnings"); Write_Line (" c turn on constant conditional warnings"); Write_Line (" C* turn off constant conditional warnings"); + Write_Line (" d turn on implicit dereference warnings"); + Write_Line (" D* turn off implicit dereference warnings"); Write_Line (" e treat all warnings as errors"); + Write_Line (" f turn on unreferenced formal warnings"); + Write_Line (" F* turn off unreferenced formal warnings"); Write_Line (" h turn on warnings for hiding variables"); Write_Line (" H* turn off warnings for hiding variables"); Write_Line (" i* turn on warnings for implementation units"); diff -Nrc3pad gcc-3.2.3/gcc/ada/usage.ads gcc-3.3/gcc/ada/usage.ads *** gcc-3.2.3/gcc/ada/usage.ads 2002-05-07 08:22:37.000000000 +0000 --- gcc-3.3/gcc/ada/usage.ads 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992,1993,1994 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/utils2.c gcc-3.3/gcc/ada/utils2.c *** gcc-3.2.3/gcc/ada/utils2.c 2002-05-04 03:29:24.000000000 +0000 --- gcc-3.3/gcc/ada/utils2.c 2003-03-24 07:44:47.000000000 +0000 *************** *** 6,14 **** * * * C Implementation File * * * - * $Revision: 1.4.10.1 $ * * ! * Copyright (C) 1992-2001, 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- * --- 6,13 ---- * * * C Implementation File * * * * * ! * Copyright (C) 1992-2002, 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- * *************** static tree build_simple_component_ref P *** 67,73 **** the only possible operands will be things of Boolean type. */ tree ! truthvalue_conversion (expr) tree expr; { tree type = TREE_TYPE (expr); --- 66,72 ---- the only possible operands will be things of Boolean type. */ tree ! gnat_truthvalue_conversion (expr) tree expr; { tree type = TREE_TYPE (expr); *************** truthvalue_conversion (expr) *** 86,98 **** case COND_EXPR: /* Distribute the conversion into the arms of a COND_EXPR. */ ! return fold (build (COND_EXPR, type, TREE_OPERAND (expr, 0), ! truthvalue_conversion (TREE_OPERAND (expr, 1)), ! truthvalue_conversion (TREE_OPERAND (expr, 2)))); case WITH_RECORD_EXPR: return build (WITH_RECORD_EXPR, type, ! truthvalue_conversion (TREE_OPERAND (expr, 0)), TREE_OPERAND (expr, 1)); default: --- 85,98 ---- case COND_EXPR: /* Distribute the conversion into the arms of a COND_EXPR. */ ! return fold ! (build (COND_EXPR, type, TREE_OPERAND (expr, 0), ! gnat_truthvalue_conversion (TREE_OPERAND (expr, 1)), ! gnat_truthvalue_conversion (TREE_OPERAND (expr, 2)))); case WITH_RECORD_EXPR: return build (WITH_RECORD_EXPR, type, ! gnat_truthvalue_conversion (TREE_OPERAND (expr, 0)), TREE_OPERAND (expr, 1)); default: *************** contains_save_expr_p (exp) *** 233,239 **** case ADDR_EXPR: case INDIRECT_REF: case COMPONENT_REF: ! case NOP_EXPR: case CONVERT_EXPR: case UNCHECKED_CONVERT_EXPR: return contains_save_expr_p (TREE_OPERAND (exp, 0)); case CONSTRUCTOR: --- 233,239 ---- case ADDR_EXPR: case INDIRECT_REF: case COMPONENT_REF: ! case NOP_EXPR: case CONVERT_EXPR: case VIEW_CONVERT_EXPR: return contains_save_expr_p (TREE_OPERAND (exp, 0)); case CONSTRUCTOR: *************** compare_arrays (result_type, a1, a2) *** 446,452 **** result = build_binary_op (TRUTH_ANDIF_EXPR, result_type, result, ! build (EQ_EXPR, result_type, a1, a2)); } --- 446,452 ---- result = build_binary_op (TRUTH_ANDIF_EXPR, result_type, result, ! fold (build (EQ_EXPR, result_type, a1, a2))); } *************** nonbinary_modular_operation (op_code, ty *** 512,520 **** || TREE_UNSIGNED (op_type) != unsignedp) { /* Copy the node so we ensure it can be modified to make it modular. */ ! op_type = copy_node (type_for_size (precision, unsignedp)); modulus = convert (op_type, modulus); ! TYPE_MODULUS (op_type) = modulus; TYPE_MODULAR_P (op_type) = 1; lhs = convert (op_type, lhs); rhs = convert (op_type, rhs); --- 512,520 ---- || TREE_UNSIGNED (op_type) != unsignedp) { /* Copy the node so we ensure it can be modified to make it modular. */ ! op_type = copy_node (gnat_type_for_size (precision, unsignedp)); modulus = convert (op_type, modulus); ! SET_TYPE_MODULUS (op_type, modulus); TYPE_MODULAR_P (op_type) = 1; lhs = convert (op_type, lhs); rhs = convert (op_type, rhs); *************** nonbinary_modular_operation (op_code, ty *** 528,536 **** possible size. */ if (op_code == MULT_EXPR) { ! tree div_type = copy_node (type_for_size (needed_precision, 1)); modulus = convert (div_type, modulus); ! TYPE_MODULUS (div_type) = modulus; TYPE_MODULAR_P (div_type) = 1; result = convert (op_type, fold (build (TRUNC_MOD_EXPR, div_type, --- 528,536 ---- possible size. */ if (op_code == MULT_EXPR) { ! tree div_type = copy_node (gnat_type_for_size (needed_precision, 1)); modulus = convert (div_type, modulus); ! SET_TYPE_MODULUS (div_type, modulus); TYPE_MODULAR_P (div_type) = 1; result = convert (op_type, fold (build (TRUNC_MOD_EXPR, div_type, *************** build_binary_op (op_code, result_type, l *** 647,653 **** unless we are not changing the mode. */ while ((TREE_CODE (left_operand) == CONVERT_EXPR || TREE_CODE (left_operand) == NOP_EXPR ! || TREE_CODE (left_operand) == UNCHECKED_CONVERT_EXPR) && (((INTEGRAL_TYPE_P (left_type) || POINTER_TYPE_P (left_type)) && (INTEGRAL_TYPE_P (TREE_TYPE --- 647,653 ---- unless we are not changing the mode. */ while ((TREE_CODE (left_operand) == CONVERT_EXPR || TREE_CODE (left_operand) == NOP_EXPR ! || TREE_CODE (left_operand) == VIEW_CONVERT_EXPR) && (((INTEGRAL_TYPE_P (left_type) || POINTER_TYPE_P (left_type)) && (INTEGRAL_TYPE_P (TREE_TYPE *************** build_binary_op (op_code, result_type, l *** 680,699 **** /* If the RHS has a conversion between record and array types and an inner type is no worse, use it. Note we cannot do this for ! modular types or types with TYPE_ALIGN_OK_P, since the latter might indicate a conversion between a root type and a class-wide type, which we must not remove. */ ! while (TREE_CODE (right_operand) == UNCHECKED_CONVERT_EXPR && ((TREE_CODE (right_type) == RECORD_TYPE && ! TYPE_LEFT_JUSTIFIED_MODULAR_P (right_type) ! && ! TYPE_ALIGN_OK_P (right_type) && ! TYPE_IS_FAT_POINTER_P (right_type)) || TREE_CODE (right_type) == ARRAY_TYPE) && (((TREE_CODE (TREE_TYPE (TREE_OPERAND (right_operand, 0))) == RECORD_TYPE) && ! (TYPE_LEFT_JUSTIFIED_MODULAR_P (TREE_TYPE (TREE_OPERAND (right_operand, 0)))) ! && ! (TYPE_ALIGN_OK_P (TREE_TYPE (TREE_OPERAND (right_operand, 0)))) && ! (TYPE_IS_FAT_POINTER_P (TREE_TYPE (TREE_OPERAND (right_operand, 0))))) --- 680,699 ---- /* If the RHS has a conversion between record and array types and an inner type is no worse, use it. Note we cannot do this for ! modular types or types with TYPE_ALIGN_OK, since the latter might indicate a conversion between a root type and a class-wide type, which we must not remove. */ ! while (TREE_CODE (right_operand) == VIEW_CONVERT_EXPR && ((TREE_CODE (right_type) == RECORD_TYPE && ! TYPE_LEFT_JUSTIFIED_MODULAR_P (right_type) ! && ! TYPE_ALIGN_OK (right_type) && ! TYPE_IS_FAT_POINTER_P (right_type)) || TREE_CODE (right_type) == ARRAY_TYPE) && (((TREE_CODE (TREE_TYPE (TREE_OPERAND (right_operand, 0))) == RECORD_TYPE) && ! (TYPE_LEFT_JUSTIFIED_MODULAR_P (TREE_TYPE (TREE_OPERAND (right_operand, 0)))) ! && ! (TYPE_ALIGN_OK (TREE_TYPE (TREE_OPERAND (right_operand, 0)))) && ! (TYPE_IS_FAT_POINTER_P (TREE_TYPE (TREE_OPERAND (right_operand, 0))))) *************** build_binary_op (op_code, result_type, l *** 719,750 **** operation_type = best_type; /* If a class-wide type may be involved, force use of the RHS type. */ ! if (TREE_CODE (right_type) == RECORD_TYPE ! && TYPE_ALIGN_OK_P (right_type)) operation_type = right_type; ! /* After we strip off any COMPONENT_REF, ARRAY_REF, or ARRAY_RANGE_REF ! from the lhs, we must have either an INDIRECT_REF or a decl. Allow ! UNCHECKED_CONVERT_EXPRs, but set TREE_ADDRESSABLE to show they are ! in an LHS. Finally, allow NOP_EXPR if both types are the same tree ! code and mode because we know these will be nops. */ ! for (result = left_operand; ! TREE_CODE (result) == COMPONENT_REF ! || TREE_CODE (result) == ARRAY_REF ! || TREE_CODE (result) == ARRAY_RANGE_REF ! || TREE_CODE (result) == REALPART_EXPR ! || TREE_CODE (result) == IMAGPART_EXPR ! || TREE_CODE (result) == WITH_RECORD_EXPR ! || TREE_CODE (result) == UNCHECKED_CONVERT_EXPR ! || ((TREE_CODE (result) == NOP_EXPR ! || TREE_CODE (result) == CONVERT_EXPR) ! && (TREE_CODE (TREE_TYPE (result)) ! == TREE_CODE (TREE_TYPE (TREE_OPERAND (result, 0)))) ! && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (result, 0))) ! == TYPE_MODE (TREE_TYPE (result)))); ! result = TREE_OPERAND (result, 0)) ! if (TREE_CODE (result) == UNCHECKED_CONVERT_EXPR) ! TREE_ADDRESSABLE (result) = 1; if (TREE_CODE (result) != INDIRECT_REF && TREE_CODE (result) != NULL_EXPR && ! DECL_P (result)) --- 719,763 ---- operation_type = best_type; /* If a class-wide type may be involved, force use of the RHS type. */ ! if (TREE_CODE (right_type) == RECORD_TYPE && TYPE_ALIGN_OK (right_type)) operation_type = right_type; ! /* Ensure everything on the LHS is valid. If we have a field reference, ! strip anything that get_inner_reference can handle. Then remove any ! conversions with type types having the same code and mode. Mark ! VIEW_CONVERT_EXPRs with TREE_ADDRESSABLE. When done, we must have ! either an INDIRECT_REF or a decl. */ ! result = left_operand; ! while (1) ! { ! tree restype = TREE_TYPE (result); ! ! if (TREE_CODE (result) == COMPONENT_REF ! || TREE_CODE (result) == ARRAY_REF ! || TREE_CODE (result) == ARRAY_RANGE_REF) ! while (handled_component_p (result)) ! result = TREE_OPERAND (result, 0); ! else if (TREE_CODE (result) == REALPART_EXPR ! || TREE_CODE (result) == IMAGPART_EXPR ! || TREE_CODE (result) == WITH_RECORD_EXPR ! || ((TREE_CODE (result) == NOP_EXPR ! || TREE_CODE (result) == CONVERT_EXPR) ! && (((TREE_CODE (restype) ! == TREE_CODE (TREE_TYPE ! (TREE_OPERAND (result, 0)))) ! && (TYPE_MODE (TREE_TYPE ! (TREE_OPERAND (result, 0))) ! == TYPE_MODE (restype))) ! || TYPE_ALIGN_OK (restype)))) ! result = TREE_OPERAND (result, 0); ! else if (TREE_CODE (result) == VIEW_CONVERT_EXPR) ! { ! TREE_ADDRESSABLE (result) = 1; ! result = TREE_OPERAND (result, 0); ! } ! else ! break; ! } if (TREE_CODE (result) != INDIRECT_REF && TREE_CODE (result) != NULL_EXPR && ! DECL_P (result)) *************** build_binary_op (op_code, result_type, l *** 805,822 **** if (! TREE_CONSTANT (right_operand) || ! TREE_CONSTANT (TYPE_MIN_VALUE (right_type)) || op_code == ARRAY_RANGE_REF) ! mark_addressable (left_operand); ! ! /* If the array is an UNCHECKED_CONVERT_EXPR from and to BLKmode ! types, convert it to a normal conversion since GCC can deal ! with any mis-alignment as part of the handling of compponent ! references. */ ! ! if (TREE_CODE (left_operand) == UNCHECKED_CONVERT_EXPR ! && TYPE_MODE (TREE_TYPE (left_operand)) == BLKmode ! && TYPE_MODE (TREE_TYPE (TREE_OPERAND (left_operand, 0))) == BLKmode) ! left_operand = build1 (CONVERT_EXPR, TREE_TYPE (left_operand), ! TREE_OPERAND (left_operand, 0)); modulus = 0; break; --- 818,824 ---- if (! TREE_CONSTANT (right_operand) || ! TREE_CONSTANT (TYPE_MIN_VALUE (right_type)) || op_code == ARRAY_RANGE_REF) ! gnat_mark_addressable (left_operand); modulus = 0; break; *************** build_binary_op (op_code, result_type, l *** 865,884 **** right_base_type = get_base_type (right_type); } - /* If either object if an UNCHECKED_CONVERT_EXPR between two BLKmode - objects, change it to a CONVERT_EXPR. */ - if (TREE_CODE (left_operand) == UNCHECKED_CONVERT_EXPR - && TYPE_MODE (left_type) == BLKmode - && TYPE_MODE (TREE_TYPE (TREE_OPERAND (left_operand, 0))) == BLKmode) - left_operand = build1 (CONVERT_EXPR, left_type, - TREE_OPERAND (left_operand, 0)); - if (TREE_CODE (right_operand) == UNCHECKED_CONVERT_EXPR - && TYPE_MODE (right_type) == BLKmode - && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (right_operand, 0))) - == BLKmode)) - right_operand = build1 (CONVERT_EXPR, right_type, - TREE_OPERAND (right_operand, 0)); - /* If both objects are arrays, compare them specially. */ if ((TREE_CODE (left_type) == ARRAY_TYPE || (TREE_CODE (left_type) == INTEGER_TYPE --- 867,872 ---- *************** build_binary_op (op_code, result_type, l *** 996,1003 **** case TRUTH_AND_EXPR: case TRUTH_OR_EXPR: case TRUTH_XOR_EXPR: ! left_operand = truthvalue_conversion (left_operand); ! right_operand = truthvalue_conversion (right_operand); goto common; case BIT_AND_EXPR: --- 984,991 ---- case TRUTH_AND_EXPR: case TRUTH_OR_EXPR: case TRUTH_XOR_EXPR: ! left_operand = gnat_truthvalue_conversion (left_operand); ! right_operand = gnat_truthvalue_conversion (right_operand); goto common; case BIT_AND_EXPR: *************** build_binary_op (op_code, result_type, l *** 1058,1065 **** TREE_SIDE_EFFECTS (result) |= has_side_effects; TREE_CONSTANT (result) ! = (TREE_CONSTANT (left_operand) & TREE_CONSTANT (right_operand) ! && op_code != ARRAY_REF && op_code != ARRAY_RANGE_REF); if ((op_code == ARRAY_REF || op_code == ARRAY_RANGE_REF) && TYPE_VOLATILE (operation_type)) --- 1046,1053 ---- TREE_SIDE_EFFECTS (result) |= has_side_effects; TREE_CONSTANT (result) ! |= (TREE_CONSTANT (left_operand) & TREE_CONSTANT (right_operand) ! && op_code != ARRAY_REF && op_code != ARRAY_RANGE_REF); if ((op_code == ARRAY_REF || op_code == ARRAY_RANGE_REF) && TYPE_VOLATILE (operation_type)) *************** build_unary_op (op_code, result_type, op *** 1128,1134 **** if (result_type != base_type) gigi_abort (508); ! result = invert_truthvalue (truthvalue_conversion (operand)); break; case ATTR_ADDR_EXPR: --- 1116,1122 ---- if (result_type != base_type) gigi_abort (508); ! result = invert_truthvalue (gnat_truthvalue_conversion (operand)); break; case ATTR_ADDR_EXPR: *************** build_unary_op (op_code, result_type, op *** 1183,1188 **** --- 1171,1181 ---- if (offset == 0) offset = size_zero_node; + if (bitpos % BITS_PER_UNIT != 0) + post_error + ("taking address of object not aligned on storage unit?", + error_gnat_node); + offset = size_binop (PLUS_EXPR, offset, size_int (bitpos / BITS_PER_UNIT)); *************** build_unary_op (op_code, result_type, op *** 1246,1252 **** if (type != error_mark_node) operation_type = build_pointer_type (type); ! mark_addressable (operand); result = fold (build1 (ADDR_EXPR, operation_type, operand)); } --- 1239,1245 ---- if (type != error_mark_node) operation_type = build_pointer_type (type); ! gnat_mark_addressable (operand); result = fold (build1 (ADDR_EXPR, operation_type, operand)); } *************** build_cond_expr (result_type, condition_ *** 1415,1421 **** result = fold (build (COND_EXPR, result_type, condition_operand, true_operand, false_operand)); ! if (addr_p) result = build_unary_op (INDIRECT_REF, NULL_TREE, result); return result; --- 1408,1432 ---- result = fold (build (COND_EXPR, result_type, condition_operand, true_operand, false_operand)); ! ! /* If either operand is a SAVE_EXPR (possibly surrounded by ! arithmetic, make sure it gets done. */ ! while (TREE_CODE_CLASS (TREE_CODE (true_operand)) == '1' ! || (TREE_CODE_CLASS (TREE_CODE (true_operand)) == '2' ! && TREE_CONSTANT (TREE_OPERAND (true_operand, 1)))) ! true_operand = TREE_OPERAND (true_operand, 0); ! ! while (TREE_CODE_CLASS (TREE_CODE (false_operand)) == '1' ! || (TREE_CODE_CLASS (TREE_CODE (false_operand)) == '2' ! && TREE_CONSTANT (TREE_OPERAND (false_operand, 1)))) ! false_operand = TREE_OPERAND (false_operand, 0); ! ! if (TREE_CODE (true_operand) == SAVE_EXPR) ! result = build (COMPOUND_EXPR, result_type, true_operand, result); ! if (TREE_CODE (false_operand) == SAVE_EXPR) ! result = build (COMPOUND_EXPR, result_type, false_operand, result); ! ! if (addr_p) result = build_unary_op (INDIRECT_REF, NULL_TREE, result); return result; *************** build_call_0_expr (fundecl) *** 1475,1487 **** return call; } ! /* Call a function FCN that raises an exception and pass the line ! number and file name, if requested. */ tree ! build_call_raise (fndecl) ! tree fndecl; { const char *str = discard_file_names ? "" : ref_filename; int len = strlen (str) + 1; tree filename = build_string (len, str); --- 1486,1499 ---- return call; } ! /* Call a function that raises an exception and pass the line number and file ! name, if requested. MSG says which exception function to call. */ tree ! build_call_raise (msg) ! int msg; { + tree fndecl = gnat_raise_decls[msg]; const char *str = discard_file_names ? "" : ref_filename; int len = strlen (str) + 1; tree filename = build_string (len, str); *************** build_simple_component_ref (record_varia *** 1641,1655 **** if (field == 0) return 0; - /* If the record variable is an UNCHECKED_CONVERT_EXPR from and to BLKmode - types, convert it to a normal conversion since GCC can deal with any - mis-alignment as part of the handling of compponent references. */ - if (TREE_CODE (record_variable) == UNCHECKED_CONVERT_EXPR - && TYPE_MODE (TREE_TYPE (record_variable)) == BLKmode - && TYPE_MODE (TREE_TYPE (TREE_OPERAND (record_variable, 0))) == BLKmode) - record_variable = build1 (CONVERT_EXPR, TREE_TYPE (record_variable), - TREE_OPERAND (record_variable, 0)); - /* It would be nice to call "fold" here, but that can lose a type we need to tag a PLACEHOLDER_EXPR with, so we can't do it. */ ref = build (COMPONENT_REF, TREE_TYPE (field), record_variable, field); --- 1653,1658 ---- *************** build_component_ref (record_variable, co *** 1683,1689 **** else if (field != 0) return build1 (NULL_EXPR, TREE_TYPE (field), ! build_call_raise (raise_constraint_error_decl)); else gigi_abort (512); } --- 1686,1692 ---- else if (field != 0) return build1 (NULL_EXPR, TREE_TYPE (field), ! build_call_raise (CE_Discriminant_Check_Failed)); else gigi_abort (512); } *************** build_allocator (type, init, result_type *** 1861,1867 **** storage = build_call_alloc_dealloc (NULL_TREE, size, TYPE_ALIGN (storage_type), gnat_proc, gnat_pool); ! storage = convert (storage_ptr_type, make_save_expr (storage)); if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) { --- 1864,1870 ---- storage = build_call_alloc_dealloc (NULL_TREE, size, TYPE_ALIGN (storage_type), gnat_proc, gnat_pool); ! storage = convert (storage_ptr_type, protect_multiple_eval (storage)); if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) { *************** fill_vms_descriptor (expr, gnat_formal) *** 1989,1995 **** tree const_list = 0; expr = maybe_unconstrained_array (expr); ! mark_addressable (expr); for (field = TYPE_FIELDS (record_type); field; field = TREE_CHAIN (field)) { --- 1992,1998 ---- tree const_list = 0; expr = maybe_unconstrained_array (expr); ! gnat_mark_addressable (expr); for (field = TYPE_FIELDS (record_type); field; field = TREE_CHAIN (field)) { *************** fill_vms_descriptor (expr, gnat_formal) *** 2007,2016 **** } /* Indicate that we need to make the address of EXPR_NODE and it therefore ! should not be allocated in a register. Return 1 if successful. */ ! int ! mark_addressable (expr_node) tree expr_node; { while (1) --- 2010,2019 ---- } /* Indicate that we need to make the address of EXPR_NODE and it therefore ! should not be allocated in a register. Returns true if successful. */ ! bool ! gnat_mark_addressable (expr_node) tree expr_node; { while (1) *************** mark_addressable (expr_node) *** 2028,2051 **** case CONSTRUCTOR: TREE_ADDRESSABLE (expr_node) = 1; ! return 1; case VAR_DECL: case PARM_DECL: case RESULT_DECL: ! put_var_into_stack (expr_node); TREE_ADDRESSABLE (expr_node) = 1; ! return 1; case FUNCTION_DECL: TREE_ADDRESSABLE (expr_node) = 1; ! return 1; case CONST_DECL: return (DECL_CONST_CORRESPONDING_VAR (expr_node) != 0 ! && (mark_addressable (DECL_CONST_CORRESPONDING_VAR (expr_node)))); default: ! return 1; } } --- 2031,2054 ---- case CONSTRUCTOR: TREE_ADDRESSABLE (expr_node) = 1; ! return true; case VAR_DECL: case PARM_DECL: case RESULT_DECL: ! put_var_into_stack (expr_node, /*rescan=*/true); TREE_ADDRESSABLE (expr_node) = 1; ! return true; case FUNCTION_DECL: TREE_ADDRESSABLE (expr_node) = 1; ! return true; case CONST_DECL: return (DECL_CONST_CORRESPONDING_VAR (expr_node) != 0 ! && (gnat_mark_addressable (DECL_CONST_CORRESPONDING_VAR (expr_node)))); default: ! return true; } } diff -Nrc3pad gcc-3.2.3/gcc/ada/utils.c gcc-3.3/gcc/ada/utils.c *** gcc-3.2.3/gcc/ada/utils.c 2002-05-04 03:29:24.000000000 +0000 --- gcc-3.3/gcc/ada/utils.c 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** * * * C Implementation File * * * - * $Revision: 1.8.8.1 $ * * ! * Copyright (C) 1992-2001, 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- * --- 6,13 ---- * * * C Implementation File * * * * * ! * Copyright (C) 1992-2002, 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- * *************** *** 34,39 **** --- 33,39 ---- #include "toplev.h" #include "output.h" #include "ggc.h" + #include "debug.h" #include "convert.h" #include "ada.h" *************** *** 61,84 **** /* If nonzero, pretend we are allocating at global level. */ int force_global; ! /* Global Variables for the various types we create. */ tree gnat_std_decls[(int) ADT_LAST]; /* Associates a GNAT tree node to a GCC tree node. It is used in `save_gnu_tree', `get_gnu_tree' and `present_gnu_tree'. See documentation of `save_gnu_tree' for more info. */ ! static tree *associate_gnat_to_gnu; /* This listhead is used to record any global objects that need elaboration. TREE_PURPOSE is the variable to be elaborated and TREE_VALUE is the initial value to assign. */ ! static tree pending_elaborations; /* This stack allows us to momentarily switch to generating elaboration lists for an inner context. */ ! static struct e_stack {struct e_stack *next; tree elab_list; } *elist_stack; /* This variable keeps a table for types for each precision so that we only allocate each of them once. Signed and unsigned types are kept separate. --- 61,91 ---- /* If nonzero, pretend we are allocating at global level. */ int force_global; ! /* Tree nodes for the various types and decls we create. */ tree gnat_std_decls[(int) ADT_LAST]; + /* Functions to call for each of the possible raise reasons. */ + tree gnat_raise_decls[(int) LAST_REASON_CODE + 1]; + /* Associates a GNAT tree node to a GCC tree node. It is used in `save_gnu_tree', `get_gnu_tree' and `present_gnu_tree'. See documentation of `save_gnu_tree' for more info. */ ! static GTY((length ("max_gnat_nodes"))) tree *associate_gnat_to_gnu; /* This listhead is used to record any global objects that need elaboration. TREE_PURPOSE is the variable to be elaborated and TREE_VALUE is the initial value to assign. */ ! static GTY(()) tree pending_elaborations; /* This stack allows us to momentarily switch to generating elaboration lists for an inner context. */ ! struct e_stack GTY(()) { ! struct e_stack *next; ! tree elab_list; ! }; ! static GTY(()) struct e_stack *elist_stack; /* This variable keeps a table for types for each precision so that we only allocate each of them once. Signed and unsigned types are kept separate. *************** static struct e_stack {struct e_stack *n *** 86,95 **** Note that these types are only used when fold-const requests something special. Perhaps we should NOT share these types; we'll see how it goes later. */ ! static tree signed_and_unsigned_types[2 * MAX_BITS_PER_WORD + 1][2]; /* Likewise for float types, but record these by mode. */ ! static tree float_types[NUM_MACHINE_MODES]; /* For each binding contour we allocate a binding_level structure which records the entities defined or declared in that contour. Contours include: --- 93,102 ---- Note that these types are only used when fold-const requests something special. Perhaps we should NOT share these types; we'll see how it goes later. */ ! static GTY(()) tree signed_and_unsigned_types[2 * MAX_BITS_PER_WORD + 1][2]; /* Likewise for float types, but record these by mode. */ ! static GTY(()) tree float_types[NUM_MACHINE_MODES]; /* For each binding contour we allocate a binding_level structure which records the entities defined or declared in that contour. Contours include: *************** static tree float_types[NUM_MACHINE_MODE *** 100,106 **** Binding contours are used to create GCC tree BLOCK nodes. */ ! struct binding_level { /* A chain of ..._DECL nodes for all variables, constants, functions, parameters and type declarations. These ..._DECL nodes are chained --- 107,113 ---- Binding contours are used to create GCC tree BLOCK nodes. */ ! struct binding_level GTY(()) { /* A chain of ..._DECL nodes for all variables, constants, functions, parameters and type declarations. These ..._DECL nodes are chained *************** struct binding_level *** 119,128 **** }; /* The binding level currently in effect. */ ! static struct binding_level *current_binding_level = NULL; /* A chain of binding_level structures awaiting reuse. */ ! static struct binding_level *free_binding_level = NULL; /* The outermost binding level. This binding level is created when the compiler is started and it will exist through the entire compilation. */ --- 126,135 ---- }; /* The binding level currently in effect. */ ! static GTY(()) struct binding_level *current_binding_level; /* A chain of binding_level structures awaiting reuse. */ ! static GTY((deletable (""))) struct binding_level *free_binding_level; /* The outermost binding level. This binding level is created when the compiler is started and it will exist through the entire compilation. */ *************** static struct binding_level *global_bind *** 131,136 **** --- 138,147 ---- /* Binding level structures are initialized by copying this one. */ static struct binding_level clear_binding_level = {NULL, NULL, NULL, NULL}; + struct language_function GTY(()) + { + int unused; + }; static tree merge_sizes PARAMS ((tree, tree, tree, int, int)); static tree compute_related_constant PARAMS ((tree, tree)); *************** static tree convert_to_fat_pointer PARAM *** 141,148 **** static tree convert_to_thin_pointer PARAMS ((tree, tree)); static tree make_descriptor_field PARAMS ((const char *,tree, tree, tree)); - static void mark_binding_level PARAMS((PTR)); - static void mark_e_stack PARAMS((PTR)); /* Initialize the association of GNAT nodes to GCC trees. */ --- 152,157 ---- *************** init_gnat_to_gnu () *** 151,174 **** { Node_Id gnat_node; ! associate_gnat_to_gnu = (tree *) xmalloc (max_gnat_nodes * sizeof (tree)); ! ggc_add_tree_root (associate_gnat_to_gnu, max_gnat_nodes); for (gnat_node = 0; gnat_node < max_gnat_nodes; gnat_node++) ! associate_gnat_to_gnu [gnat_node] = NULL_TREE; ! ! associate_gnat_to_gnu -= First_Node_Id; pending_elaborations = build_tree_list (NULL_TREE, NULL_TREE); - ggc_add_tree_root (&pending_elaborations, 1); - ggc_add_root ((PTR) &elist_stack, 1, sizeof (struct e_stack), mark_e_stack); - ggc_add_tree_root (&signed_and_unsigned_types[0][0], - (sizeof signed_and_unsigned_types - / sizeof signed_and_unsigned_types[0][0])); - ggc_add_tree_root (float_types, sizeof float_types / sizeof float_types[0]); - - ggc_add_root (¤t_binding_level, 1, sizeof current_binding_level, - mark_binding_level); } /* GNAT_ENTITY is a GNAT tree node for an entity. GNU_DECL is the GCC tree --- 160,171 ---- { Node_Id gnat_node; ! associate_gnat_to_gnu = (tree *) ggc_alloc (max_gnat_nodes * sizeof (tree)); for (gnat_node = 0; gnat_node < max_gnat_nodes; gnat_node++) ! associate_gnat_to_gnu[gnat_node] = NULL_TREE; pending_elaborations = build_tree_list (NULL_TREE, NULL_TREE); } /* GNAT_ENTITY is a GNAT tree node for an entity. GNU_DECL is the GCC tree *************** save_gnu_tree (gnat_entity, gnu_decl, no *** 184,194 **** int no_check; { if (gnu_decl ! && (associate_gnat_to_gnu [gnat_entity] || (! no_check && ! DECL_P (gnu_decl)))) gigi_abort (401); ! associate_gnat_to_gnu [gnat_entity] = gnu_decl; } /* GNAT_ENTITY is a GNAT tree node for a defining identifier. --- 181,191 ---- int no_check; { if (gnu_decl ! && (associate_gnat_to_gnu[gnat_entity - First_Node_Id] || (! no_check && ! DECL_P (gnu_decl)))) gigi_abort (401); ! associate_gnat_to_gnu[gnat_entity - First_Node_Id] = gnu_decl; } /* GNAT_ENTITY is a GNAT tree node for a defining identifier. *************** tree *** 202,211 **** get_gnu_tree (gnat_entity) Entity_Id gnat_entity; { ! if (! associate_gnat_to_gnu [gnat_entity]) gigi_abort (402); ! return associate_gnat_to_gnu [gnat_entity]; } /* Return nonzero if a GCC tree has been associated with GNAT_ENTITY. */ --- 199,208 ---- get_gnu_tree (gnat_entity) Entity_Id gnat_entity; { ! if (! associate_gnat_to_gnu[gnat_entity - First_Node_Id]) gigi_abort (402); ! return associate_gnat_to_gnu[gnat_entity - First_Node_Id]; } /* Return nonzero if a GCC tree has been associated with GNAT_ENTITY. */ *************** int *** 214,220 **** present_gnu_tree (gnat_entity) Entity_Id gnat_entity; { ! return (associate_gnat_to_gnu [gnat_entity] != NULL_TREE); } --- 211,217 ---- present_gnu_tree (gnat_entity) Entity_Id gnat_entity; { ! return (associate_gnat_to_gnu[gnat_entity - First_Node_Id] != NULL_TREE); } *************** pushlevel (ignore) *** 261,267 **** } else newlevel ! = (struct binding_level *) xmalloc (sizeof (struct binding_level)); *newlevel = clear_binding_level; --- 258,264 ---- } else newlevel ! = (struct binding_level *) ggc_alloc (sizeof (struct binding_level)); *newlevel = clear_binding_level; *************** gnat_init_decl_processing () *** 482,493 **** { lineno = 0; - /* incomplete_decl_finalize_hook is defined in toplev.c. It needs to be set - by each front end to the appropriate routine that handles incomplete - VAR_DECL nodes. This routine will be invoked by compile_file when a - VAR_DECL node of DECL_SIZE zero is encountered. */ - incomplete_decl_finalize_hook = finish_incomplete_decl; - /* Make the binding_level structure for global names. */ current_function_decl = 0; current_binding_level = 0; --- 479,484 ---- *************** gnat_init_decl_processing () *** 500,506 **** /* In Ada, we use a signed type for SIZETYPE. Use the signed type corresponding to the size of ptr_mode. Make this here since we need this before we can expand the GNAT types. */ ! set_sizetype (type_for_size (GET_MODE_BITSIZE (ptr_mode), 0)); build_common_tree_nodes_2 (0); pushdecl (build_decl (TYPE_DECL, get_identifier (SIZE_TYPE), sizetype)); --- 491,497 ---- /* In Ada, we use a signed type for SIZETYPE. Use the signed type corresponding to the size of ptr_mode. Make this here since we need this before we can expand the GNAT types. */ ! set_sizetype (gnat_type_for_size (GET_MODE_BITSIZE (ptr_mode), 0)); build_common_tree_nodes_2 (0); pushdecl (build_decl (TYPE_DECL, get_identifier (SIZE_TYPE), sizetype)); *************** void *** 523,529 **** init_gigi_decls (long_long_float_type, exception_type) tree long_long_float_type, exception_type; { ! tree endlink; /* Set the types that GCC and Gigi use from the front end. We would like to do this for char_type_node, but it needs to correspond to the C --- 514,521 ---- init_gigi_decls (long_long_float_type, exception_type) tree long_long_float_type, exception_type; { ! tree endlink, decl; ! unsigned int i; /* Set the types that GCC and Gigi use from the front end. We would like to do this for char_type_node, but it needs to correspond to the C *************** init_gigi_decls (long_long_float_type, e *** 543,549 **** except_type_node = TREE_TYPE (exception_type); ! unsigned_type_node = type_for_size (INT_TYPE_SIZE, 1); pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"), unsigned_type_node)); --- 535,541 ---- except_type_node = TREE_TYPE (exception_type); ! unsigned_type_node = gnat_type_for_size (INT_TYPE_SIZE, 1); pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"), unsigned_type_node)); *************** init_gigi_decls (long_long_float_type, e *** 579,585 **** /* Make the types and functions used for exception processing. */ jmpbuf_type ! = build_array_type (type_for_mode (Pmode, 0), build_index_type (build_int_2 (5, 0))); pushdecl (build_decl (TYPE_DECL, get_identifier ("JMPBUF_T"), jmpbuf_type)); jmpbuf_ptr_type = build_pointer_type (jmpbuf_type); --- 571,577 ---- /* Make the types and functions used for exception processing. */ jmpbuf_type ! = build_array_type (gnat_type_for_mode (Pmode, 0), build_index_type (build_int_2 (5, 0))); pushdecl (build_decl (TYPE_DECL, get_identifier ("JMPBUF_T"), jmpbuf_type)); jmpbuf_ptr_type = build_pointer_type (jmpbuf_type); *************** init_gigi_decls (long_long_float_type, e *** 607,613 **** build_function_type (build_pointer_type (except_type_node), NULL_TREE), NULL_TREE, 0, 1, 1, 0); ! /* Function that raise exceptions. */ raise_nodefer_decl = create_subprog_decl (get_identifier ("__gnat_raise_nodefer_with_msg"), NULL_TREE, --- 599,605 ---- build_function_type (build_pointer_type (except_type_node), NULL_TREE), NULL_TREE, 0, 1, 1, 0); ! /* Functions that raise exceptions. */ raise_nodefer_decl = create_subprog_decl (get_identifier ("__gnat_raise_nodefer_with_msg"), NULL_TREE, *************** init_gigi_decls (long_long_float_type, e *** 617,684 **** endlink)), NULL_TREE, 0, 1, 1, 0); ! /* __gnat_raise_constraint_error takes a string, an integer and never ! returns. */ ! raise_constraint_error_decl ! = create_subprog_decl ! (get_identifier ("__gnat_raise_constraint_error"), NULL_TREE, ! build_function_type (void_type_node, ! tree_cons (NULL_TREE, ! build_pointer_type (char_type_node), ! tree_cons (NULL_TREE, ! integer_type_node, ! endlink))), ! NULL_TREE, 0, 1, 1, 0); ! ! /* Likewise for __gnat_raise_program_error. */ ! raise_program_error_decl ! = create_subprog_decl ! (get_identifier ("__gnat_raise_program_error"), NULL_TREE, ! build_function_type (void_type_node, ! tree_cons (NULL_TREE, ! build_pointer_type (char_type_node), ! tree_cons (NULL_TREE, ! integer_type_node, ! endlink))), ! NULL_TREE, 0, 1, 1, 0); ! /* Likewise for __gnat_raise_storage_error. */ ! raise_storage_error_decl ! = create_subprog_decl ! (get_identifier ("__gnat_raise_storage_error"), NULL_TREE, ! build_function_type (void_type_node, ! tree_cons (NULL_TREE, ! build_pointer_type (char_type_node), ! tree_cons (NULL_TREE, ! integer_type_node, ! endlink))), ! NULL_TREE, 0, 1, 1, 0); /* Indicate that these never return. */ - TREE_THIS_VOLATILE (raise_nodefer_decl) = 1; - TREE_THIS_VOLATILE (raise_constraint_error_decl) = 1; - TREE_THIS_VOLATILE (raise_program_error_decl) = 1; - TREE_THIS_VOLATILE (raise_storage_error_decl) = 1; - TREE_SIDE_EFFECTS (raise_nodefer_decl) = 1; - TREE_SIDE_EFFECTS (raise_constraint_error_decl) = 1; - TREE_SIDE_EFFECTS (raise_program_error_decl) = 1; - TREE_SIDE_EFFECTS (raise_storage_error_decl) = 1; - TREE_TYPE (raise_nodefer_decl) = build_qualified_type (TREE_TYPE (raise_nodefer_decl), TYPE_QUAL_VOLATILE); ! TREE_TYPE (raise_constraint_error_decl) ! = build_qualified_type (TREE_TYPE (raise_constraint_error_decl), ! TYPE_QUAL_VOLATILE); ! TREE_TYPE (raise_program_error_decl) ! = build_qualified_type (TREE_TYPE (raise_program_error_decl), ! TYPE_QUAL_VOLATILE); ! TREE_TYPE (raise_storage_error_decl) ! = build_qualified_type (TREE_TYPE (raise_storage_error_decl), ! TYPE_QUAL_VOLATILE); /* setjmp returns an integer and has one operand, which is a pointer to a jmpbuf. */ --- 609,668 ---- endlink)), NULL_TREE, 0, 1, 1, 0); + /* If in no exception handlers mode, all raise statements are redirected to + __gnat_last_chance_handler. No need to redefine raise_nodefer_decl, since + this procedure will never be called in this mode. */ + if (No_Exception_Handlers_Set ()) + { + decl + = create_subprog_decl + (get_identifier ("__gnat_last_chance_handler"), NULL_TREE, + build_function_type (void_type_node, + tree_cons (NULL_TREE, + build_pointer_type (char_type_node), + tree_cons (NULL_TREE, + integer_type_node, + endlink))), + NULL_TREE, 0, 1, 1, 0); ! for (i = 0; i < ARRAY_SIZE (gnat_raise_decls); i++) ! gnat_raise_decls[i] = decl; ! } ! else ! /* Otherwise, make one decl for each exception reason. */ ! for (i = 0; i < ARRAY_SIZE (gnat_raise_decls); i++) ! { ! char name[17]; ! sprintf (name, "__gnat_rcheck_%.2d", i); ! gnat_raise_decls[i] ! = create_subprog_decl ! (get_identifier (name), NULL_TREE, ! build_function_type (void_type_node, ! tree_cons (NULL_TREE, ! build_pointer_type ! (char_type_node), ! tree_cons (NULL_TREE, ! integer_type_node, ! endlink))), ! NULL_TREE, 0, 1, 1, 0); ! } /* Indicate that these never return. */ TREE_THIS_VOLATILE (raise_nodefer_decl) = 1; TREE_SIDE_EFFECTS (raise_nodefer_decl) = 1; TREE_TYPE (raise_nodefer_decl) = build_qualified_type (TREE_TYPE (raise_nodefer_decl), TYPE_QUAL_VOLATILE); ! ! for (i = 0; i < ARRAY_SIZE (gnat_raise_decls); i++) ! { ! TREE_THIS_VOLATILE (gnat_raise_decls[i]) = 1; ! TREE_SIDE_EFFECTS (gnat_raise_decls[i]) = 1; ! TREE_TYPE (gnat_raise_decls[i]) ! = build_qualified_type (TREE_TYPE (gnat_raise_decls[i]), ! TYPE_QUAL_VOLATILE); ! } /* setjmp returns an integer and has one operand, which is a pointer to a jmpbuf. */ *************** init_gigi_decls (long_long_float_type, e *** 692,712 **** DECL_BUILT_IN_CLASS (setjmp_decl) = BUILT_IN_NORMAL; DECL_FUNCTION_CODE (setjmp_decl) = BUILT_IN_SETJMP; ! ggc_add_tree_root (gnat_std_decls, ! sizeof gnat_std_decls / sizeof gnat_std_decls[0]); } - /* This routine is called in tree.c to print an error message for invalid use - of an incomplete type. */ - - void - incomplete_type_error (dont_care_1, dont_care_2) - tree dont_care_1 ATTRIBUTE_UNUSED; - tree dont_care_2 ATTRIBUTE_UNUSED; - { - gigi_abort (404); - } - /* This function is called indirectly from toplev.c to handle incomplete declarations, i.e. VAR_DECL nodes whose DECL_SIZE is zero. To be precise, compile_file in toplev.c makes an indirect call through the function pointer --- 676,684 ---- DECL_BUILT_IN_CLASS (setjmp_decl) = BUILT_IN_NORMAL; DECL_FUNCTION_CODE (setjmp_decl) = BUILT_IN_SETJMP; ! main_identifier_node = get_identifier ("main"); } /* This function is called indirectly from toplev.c to handle incomplete declarations, i.e. VAR_DECL nodes whose DECL_SIZE is zero. To be precise, compile_file in toplev.c makes an indirect call through the function pointer *************** incomplete_type_error (dont_care_1, dont *** 714,720 **** init_decl_processing. */ void ! finish_incomplete_decl (dont_care) tree dont_care ATTRIBUTE_UNUSED; { gigi_abort (405); --- 686,692 ---- init_decl_processing. */ void ! gnat_finish_incomplete_decl (dont_care) tree dont_care ATTRIBUTE_UNUSED; { gigi_abort (405); *************** finish_record_type (record_type, fieldli *** 738,743 **** --- 710,716 ---- tree ada_size = bitsize_zero_node; tree size = bitsize_zero_node; tree size_unit = size_zero_node; + int var_size = 0; tree field; TYPE_FIELDS (record_type) = fieldlist; *************** finish_record_type (record_type, fieldli *** 793,798 **** --- 766,780 ---- tree this_size_unit = DECL_SIZE_UNIT (field); tree this_ada_size = DECL_SIZE (field); + /* We need to make an XVE/XVU record if any field has variable size, + whether or not the record does. For example, if we have an union, + it may be that all fields, rounded up to the alignment, have the + same size, in which case we'll use that size. But the debug + output routines (except Dwarf2) won't be able to output the fields, + so we need to make the special record. */ + if (TREE_CODE (this_size) != INTEGER_CST) + var_size = 1; + if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == QUAL_UNION_TYPE) && ! TYPE_IS_FAT_POINTER_P (type) *************** finish_record_type (record_type, fieldli *** 861,871 **** /* Now set any of the values we've just computed that apply. */ if (! TYPE_IS_FAT_POINTER_P (record_type) && ! TYPE_CONTAINS_TEMPLATE_P (record_type)) ! TYPE_ADA_SIZE (record_type) = ada_size; #ifdef ROUND_TYPE_SIZE size = ROUND_TYPE_SIZE (record_type, size, TYPE_ALIGN (record_type)); ! size_unit = ROUND_TYPE_SIZE_UNIT (record_size, size_unit, TYPE_ALIGN (record_type) / BITS_PER_UNIT); #else size = round_up (size, TYPE_ALIGN (record_type)); --- 843,853 ---- /* Now set any of the values we've just computed that apply. */ if (! TYPE_IS_FAT_POINTER_P (record_type) && ! TYPE_CONTAINS_TEMPLATE_P (record_type)) ! SET_TYPE_ADA_SIZE (record_type, ada_size); #ifdef ROUND_TYPE_SIZE size = ROUND_TYPE_SIZE (record_type, size, TYPE_ALIGN (record_type)); ! size_unit = ROUND_TYPE_SIZE_UNIT (record_type, size_unit, TYPE_ALIGN (record_type) / BITS_PER_UNIT); #else size = round_up (size, TYPE_ALIGN (record_type)); *************** finish_record_type (record_type, fieldli *** 891,897 **** debugger knows it is and make a new, parallel, record that tells the debugger how the record is laid out. See exp_dbug.ads. */ ! if (TREE_CODE (TYPE_SIZE (record_type)) != INTEGER_CST) { tree new_record_type = make_node (TREE_CODE (record_type) == QUAL_UNION_TYPE --- 873,879 ---- debugger knows it is and make a new, parallel, record that tells the debugger how the record is laid out. See exp_dbug.ads. */ ! if (var_size) { tree new_record_type = make_node (TREE_CODE (record_type) == QUAL_UNION_TYPE *************** finish_record_type (record_type, fieldli *** 973,979 **** /* See if this type is variable-size and make a new type and indicate the indirection if so. */ ! if (TREE_CODE (TYPE_SIZE (field_type)) != INTEGER_CST) { field_type = build_pointer_type (field_type); var = 1; --- 955,961 ---- /* See if this type is variable-size and make a new type and indicate the indirection if so. */ ! if (TREE_CODE (DECL_SIZE (old_field)) != INTEGER_CST) { field_type = build_pointer_type (field_type); var = 1; *************** finish_record_type (record_type, fieldli *** 995,1001 **** new_field = create_field_decl (field_name, field_type, new_record_type, 0, ! TYPE_SIZE (field_type), pos, 0); TREE_CHAIN (new_field) = TYPE_FIELDS (new_record_type); TYPE_FIELDS (new_record_type) = new_field; --- 977,983 ---- new_field = create_field_decl (field_name, field_type, new_record_type, 0, ! DECL_SIZE (old_field), pos, 0); TREE_CHAIN (new_field) = TYPE_FIELDS (new_record_type); TYPE_FIELDS (new_record_type) = new_field; *************** finish_record_type (record_type, fieldli *** 1008,1014 **** (TREE_CODE (TREE_TYPE (old_field)) == QUAL_UNION_TYPE) ? bitsize_zero_node ! : TYPE_SIZE (TREE_TYPE (old_field))); } TYPE_FIELDS (new_record_type) --- 990,996 ---- (TREE_CODE (TREE_TYPE (old_field)) == QUAL_UNION_TYPE) ? bitsize_zero_node ! : DECL_SIZE (old_field)); } TYPE_FIELDS (new_record_type) *************** create_subprog_type (return_type, param_ *** 1171,1177 **** || TYPE_RETURNS_BY_REF_P (type) != returns_by_ref) type = copy_type (type); ! TYPE_CI_CO_LIST (type) = cico_list; TYPE_RETURNS_UNCONSTRAINED_P (type) = returns_unconstrained; TYPE_RETURNS_STACK_DEPRESSED (type) = returns_with_dsp; TYPE_RETURNS_BY_REF_P (type) = returns_by_ref; --- 1153,1159 ---- || TYPE_RETURNS_BY_REF_P (type) != returns_by_ref) type = copy_type (type); ! SET_TYPE_CI_CO_LIST (type, cico_list); TYPE_RETURNS_UNCONSTRAINED_P (type) = returns_unconstrained; TYPE_RETURNS_STACK_DEPRESSED (type) = returns_with_dsp; TYPE_RETURNS_BY_REF_P (type) = returns_by_ref; *************** create_index_type (min, max, index) *** 1219,1225 **** else if (TYPE_INDEX_TYPE (type) != 0) type = copy_type (type); ! TYPE_INDEX_TYPE (type) = index; return type; } --- 1201,1207 ---- else if (TYPE_INDEX_TYPE (type) != 0) type = copy_type (type); ! SET_TYPE_INDEX_TYPE (type, index); return type; } *************** create_var_decl (var_name, asm_name, typ *** 1362,1368 **** /* If this is volatile, force it into memory. */ if (TREE_SIDE_EFFECTS (var_decl)) ! mark_addressable (var_decl); if (TREE_CODE (var_decl) != CONST_DECL) rest_of_decl_compilation (var_decl, 0, global_bindings_p (), 0); --- 1344,1350 ---- /* If this is volatile, force it into memory. */ if (TREE_SIDE_EFFECTS (var_decl)) ! gnat_mark_addressable (var_decl); if (TREE_CODE (var_decl) != CONST_DECL) rest_of_decl_compilation (var_decl, 0, global_bindings_p (), 0); *************** create_field_decl (field_name, field_typ *** 1485,1498 **** known_align = TYPE_ALIGN (record_type); layout_decl (field_decl, known_align); ! SET_DECL_OFFSET_ALIGN (field_decl, BIGGEST_ALIGNMENT); pos_from_bit (&DECL_FIELD_OFFSET (field_decl), &DECL_FIELD_BIT_OFFSET (field_decl), ! BIGGEST_ALIGNMENT, pos); DECL_HAS_REP_P (field_decl) = 1; } /* Mark the decl as nonaddressable if it either is indicated so semantically or if it is a bit field. */ DECL_NONADDRESSABLE_P (field_decl) --- 1467,1487 ---- known_align = TYPE_ALIGN (record_type); layout_decl (field_decl, known_align); ! SET_DECL_OFFSET_ALIGN (field_decl, ! host_integerp (pos, 1) ? BIGGEST_ALIGNMENT ! : BITS_PER_UNIT); pos_from_bit (&DECL_FIELD_OFFSET (field_decl), &DECL_FIELD_BIT_OFFSET (field_decl), ! DECL_OFFSET_ALIGN (field_decl), pos); DECL_HAS_REP_P (field_decl) = 1; } + /* If the field type is passed by reference, we will have pointers to the + field, so it is addressable. */ + if (must_pass_by_ref (field_type) || default_pass_by_ref (field_type)) + addressable = 1; + /* Mark the decl as nonaddressable if it either is indicated so semantically or if it is a bit field. */ DECL_NONADDRESSABLE_P (field_decl) *************** get_pending_elaborations () *** 1603,1639 **** return result; } - /* Mark the binding level stack. */ - - static void - mark_binding_level (arg) - PTR arg; - { - struct binding_level *level = *(struct binding_level **) arg; - - for (; level != 0; level = level->level_chain) - { - ggc_mark_tree (level->names); - ggc_mark_tree (level->blocks); - ggc_mark_tree (level->this_block); - } - } - - /* Mark the pending elaboration list. */ - - static void - mark_e_stack (data) - PTR data; - { - struct e_stack *p = *((struct e_stack **) data); - - if (p != 0) - { - ggc_mark_tree (p->elab_list); - mark_e_stack (&p->next); - } - } - /* Return nonzero if there are pending elaborations. */ int --- 1592,1597 ---- *************** pending_elaborations_p () *** 1648,1654 **** void push_pending_elaborations () { ! struct e_stack *p = (struct e_stack *) xmalloc (sizeof (struct e_stack)); p->next = elist_stack; p->elab_list = pending_elaborations; --- 1606,1612 ---- void push_pending_elaborations () { ! struct e_stack *p = (struct e_stack *) ggc_alloc (sizeof (struct e_stack)); p->next = elist_stack; p->elab_list = pending_elaborations; *************** pop_pending_elaborations () *** 1665,1671 **** pending_elaborations = p->elab_list; elist_stack = p->next; - free (p); } /* Return the current position in pending_elaborations so we can insert --- 1623,1628 ---- *************** create_label_decl (label_name) *** 1715,1722 **** node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of PARM_DECL nodes chained through the TREE_CHAIN field). ! INLINE_FLAG, PUBLIC_FLAG, and EXTERN_FLAG are used to set the appropriate ! fields in the FUNCTION_DECL. */ tree create_subprog_decl (subprog_name, asm_name, subprog_type, param_decl_list, --- 1672,1679 ---- node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of PARM_DECL nodes chained through the TREE_CHAIN field). ! INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, and ATTR_LIST are used to set the ! appropriate fields in the FUNCTION_DECL. */ tree create_subprog_decl (subprog_name, asm_name, subprog_type, param_decl_list, *************** create_subprog_decl (subprog_name, asm_n *** 1750,1756 **** DECL_RESULT (subprog_decl) = build_decl (RESULT_DECL, 0, return_type); if (asm_name != 0) ! DECL_ASSEMBLER_NAME (subprog_decl) = asm_name; process_attributes (subprog_decl, attr_list); --- 1707,1713 ---- DECL_RESULT (subprog_decl) = build_decl (RESULT_DECL, 0, return_type); if (asm_name != 0) ! SET_DECL_ASSEMBLER_NAME (subprog_decl, asm_name); process_attributes (subprog_decl, attr_list); *************** begin_subprog_body (subprog_decl) *** 1822,1831 **** /* Store back the PARM_DECL nodes. They appear in the right order. */ DECL_ARGUMENTS (subprog_decl) = getdecls (); ! init_function_start (subprog_decl, input_filename, lineno); expand_function_start (subprog_decl, 0); - } /* Finish the definition of the current subprogram and compile it all the way to assembler language output. */ --- 1779,1794 ---- /* Store back the PARM_DECL nodes. They appear in the right order. */ DECL_ARGUMENTS (subprog_decl) = getdecls (); ! init_function_start (subprog_decl, input_filename, lineno); expand_function_start (subprog_decl, 0); + /* If this function is `main', emit a call to `__main' + to run global initializers, etc. */ + if (DECL_ASSEMBLER_NAME (subprog_decl) != 0 + && MAIN_NAME_P (DECL_ASSEMBLER_NAME (subprog_decl)) + && DECL_CONTEXT (subprog_decl) == NULL_TREE) + expand_main_function (); + } /* Finish the definition of the current subprogram and compile it all the way to assembler language output. */ *************** end_subprog_body () *** 1908,1933 **** See tree.h for its possible values. If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME, ! the name to be called if we can't opencode the function. */ tree ! builtin_function (name, type, function_code, class, library_name) const char *name; tree type; int function_code; enum built_in_class class; const char *library_name; { tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type); DECL_EXTERNAL (decl) = 1; TREE_PUBLIC (decl) = 1; if (library_name) ! DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name); pushdecl (decl); DECL_BUILT_IN_CLASS (decl) = class; DECL_FUNCTION_CODE (decl) = function_code; return decl; } --- 1871,1900 ---- See tree.h for its possible values. If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME, ! the name to be called if we can't opencode the function. If ! ATTRS is nonzero, use that for the function attribute list. */ tree ! builtin_function (name, type, function_code, class, library_name, attrs) const char *name; tree type; int function_code; enum built_in_class class; const char *library_name; + tree attrs; { tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type); DECL_EXTERNAL (decl) = 1; TREE_PUBLIC (decl) = 1; if (library_name) ! SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name)); pushdecl (decl); DECL_BUILT_IN_CLASS (decl) = class; DECL_FUNCTION_CODE (decl) = function_code; + if (attrs) + decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN); return decl; } *************** builtin_function (name, type, function_c *** 1936,1942 **** it is a signed type. */ tree ! type_for_size (precision, unsignedp) unsigned precision; int unsignedp; { --- 1903,1909 ---- it is a signed type. */ tree ! gnat_type_for_size (precision, unsignedp) unsigned precision; int unsignedp; { *************** float_type_for_size (precision, mode) *** 1997,2019 **** an unsigned type; otherwise a signed type is returned. */ tree ! type_for_mode (mode, unsignedp) enum machine_mode mode; int unsignedp; { if (GET_MODE_CLASS (mode) == MODE_FLOAT) return float_type_for_size (GET_MODE_BITSIZE (mode), mode); else ! return type_for_size (GET_MODE_BITSIZE (mode), unsignedp); } /* Return the unsigned version of a TYPE_NODE, a scalar type. */ tree ! unsigned_type (type_node) tree type_node; { ! tree type = type_for_size (TYPE_PRECISION (type_node), 1); if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node)) { --- 1964,1986 ---- an unsigned type; otherwise a signed type is returned. */ tree ! gnat_type_for_mode (mode, unsignedp) enum machine_mode mode; int unsignedp; { if (GET_MODE_CLASS (mode) == MODE_FLOAT) return float_type_for_size (GET_MODE_BITSIZE (mode), mode); else ! return gnat_type_for_size (GET_MODE_BITSIZE (mode), unsignedp); } /* Return the unsigned version of a TYPE_NODE, a scalar type. */ tree ! gnat_unsigned_type (type_node) tree type_node; { ! tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 1); if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node)) { *************** unsigned_type (type_node) *** 2034,2043 **** /* Return the signed version of a TYPE_NODE, a scalar type. */ tree ! signed_type (type_node) tree type_node; { ! tree type = type_for_size (TYPE_PRECISION (type_node), 0); if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node)) { --- 2001,2010 ---- /* Return the signed version of a TYPE_NODE, a scalar type. */ tree ! gnat_signed_type (type_node) tree type_node; { ! tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 0); if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node)) { *************** signed_type (type_node) *** 2059,2072 **** UNSIGNEDP. */ tree ! signed_or_unsigned_type (unsignedp, type) int unsignedp; tree type; { if (! INTEGRAL_TYPE_P (type) || TREE_UNSIGNED (type) == unsignedp) return type; else ! return type_for_size (TYPE_PRECISION (type), unsignedp); } /* EXP is an expression for the size of an object. If this size contains --- 2026,2039 ---- UNSIGNEDP. */ tree ! gnat_signed_or_unsigned_type (unsignedp, type) int unsignedp; tree type; { if (! INTEGRAL_TYPE_P (type) || TREE_UNSIGNED (type) == unsignedp) return type; else ! return gnat_type_for_size (TYPE_PRECISION (type), unsignedp); } /* EXP is an expression for the size of an object. If this size contains *************** build_vms_descriptor (type, mech, gnat_e *** 2383,2396 **** field_list = chainon (field_list, make_descriptor_field ! ("LENGTH", type_for_size (16, 1), record_type, size_in_bytes (mech == By_Descriptor_A ? inner_type : type))); field_list = chainon (field_list, ! make_descriptor_field ("DTYPE", type_for_size (8, 1), record_type, size_int (dtype))); field_list = chainon (field_list, ! make_descriptor_field ("CLASS", type_for_size (8, 1), record_type, size_int (class))); field_list --- 2350,2365 ---- field_list = chainon (field_list, make_descriptor_field ! ("LENGTH", gnat_type_for_size (16, 1), record_type, size_in_bytes (mech == By_Descriptor_A ? inner_type : type))); field_list = chainon (field_list, ! make_descriptor_field ("DTYPE", ! gnat_type_for_size (8, 1), record_type, size_int (dtype))); field_list = chainon (field_list, ! make_descriptor_field ("CLASS", ! gnat_type_for_size (8, 1), record_type, size_int (class))); field_list *************** build_vms_descriptor (type, mech, gnat_e *** 2413,2425 **** field_list = chainon (field_list, make_descriptor_field ! ("SB_L1", type_for_size (32, 1), record_type, TREE_CODE (type) == ARRAY_TYPE ? TYPE_MIN_VALUE (TYPE_DOMAIN (type)) : size_zero_node)); field_list = chainon (field_list, make_descriptor_field ! ("SB_L2", type_for_size (32, 1), record_type, TREE_CODE (type) == ARRAY_TYPE ? TYPE_MAX_VALUE (TYPE_DOMAIN (type)) : size_zero_node)); break; --- 2382,2394 ---- field_list = chainon (field_list, make_descriptor_field ! ("SB_L1", gnat_type_for_size (32, 1), record_type, TREE_CODE (type) == ARRAY_TYPE ? TYPE_MIN_VALUE (TYPE_DOMAIN (type)) : size_zero_node)); field_list = chainon (field_list, make_descriptor_field ! ("SB_L2", gnat_type_for_size (32, 1), record_type, TREE_CODE (type) == ARRAY_TYPE ? TYPE_MAX_VALUE (TYPE_DOMAIN (type)) : size_zero_node)); break; *************** build_vms_descriptor (type, mech, gnat_e *** 2428,2447 **** case By_Descriptor_NCA: field_list = chainon (field_list, make_descriptor_field ("SCALE", ! type_for_size (8, 1), record_type, size_zero_node)); field_list = chainon (field_list, make_descriptor_field ("DIGITS", ! type_for_size (8, 1), record_type, size_zero_node)); field_list = chainon (field_list, make_descriptor_field ! ("AFLAGS", type_for_size (8, 1), record_type, size_int (mech == By_Descriptor_NCA ? 0 /* Set FL_COLUMN, FL_COEFF, and FL_BOUNDS. */ --- 2397,2416 ---- case By_Descriptor_NCA: field_list = chainon (field_list, make_descriptor_field ("SCALE", ! gnat_type_for_size (8, 1), record_type, size_zero_node)); field_list = chainon (field_list, make_descriptor_field ("DIGITS", ! gnat_type_for_size (8, 1), record_type, size_zero_node)); field_list = chainon (field_list, make_descriptor_field ! ("AFLAGS", gnat_type_for_size (8, 1), record_type, size_int (mech == By_Descriptor_NCA ? 0 /* Set FL_COLUMN, FL_COEFF, and FL_BOUNDS. */ *************** build_vms_descriptor (type, mech, gnat_e *** 2451,2463 **** field_list = chainon (field_list, make_descriptor_field ("DIMCT", ! type_for_size (8, 1), record_type, size_int (ndim))); field_list = chainon (field_list, make_descriptor_field ("ARSIZE", ! type_for_size (32, 1), record_type, size_in_bytes (type))); --- 2420,2432 ---- field_list = chainon (field_list, make_descriptor_field ("DIMCT", ! gnat_type_for_size (8, 1), record_type, size_int (ndim))); field_list = chainon (field_list, make_descriptor_field ("ARSIZE", ! gnat_type_for_size (32, 1), record_type, size_in_bytes (type))); *************** build_vms_descriptor (type, mech, gnat_e *** 2489,2499 **** fname[0] = (mech == By_Descriptor_NCA ? 'S' : 'M'); fname[1] = '0' + i, fname[2] = 0; ! field_list = chainon (field_list, ! make_descriptor_field (fname, ! type_for_size (32, 1), ! record_type, ! idx_length)); if (mech == By_Descriptor_NCA) tem = idx_length; --- 2458,2468 ---- fname[0] = (mech == By_Descriptor_NCA ? 'S' : 'M'); fname[1] = '0' + i, fname[2] = 0; ! field_list ! = chainon (field_list, ! make_descriptor_field (fname, ! gnat_type_for_size (32, 1), ! record_type, idx_length)); if (mech == By_Descriptor_NCA) tem = idx_length; *************** build_vms_descriptor (type, mech, gnat_e *** 2508,2521 **** field_list = chainon (field_list, make_descriptor_field ! (fname, type_for_size (32, 1), record_type, TYPE_MIN_VALUE (idx_arr[i]))); fname[0] = 'U'; field_list = chainon (field_list, make_descriptor_field ! (fname, type_for_size (32, 1), record_type, TYPE_MAX_VALUE (idx_arr[i]))); } break; --- 2477,2490 ---- field_list = chainon (field_list, make_descriptor_field ! (fname, gnat_type_for_size (32, 1), record_type, TYPE_MIN_VALUE (idx_arr[i]))); fname[0] = 'U'; field_list = chainon (field_list, make_descriptor_field ! (fname, gnat_type_for_size (32, 1), record_type, TYPE_MAX_VALUE (idx_arr[i]))); } break; *************** update_pointer_to (old_type, new_type) *** 2663,2669 **** TREE_CHAIN (TYPE_FIELDS (ptr)), new_ref)); for (var = TYPE_MAIN_VARIANT (ptr); var; var = TYPE_NEXT_VARIANT (var)) ! TYPE_UNCONSTRAINED_ARRAY (var) = new_type; TYPE_POINTER_TO (new_type) = TYPE_REFERENCE_TO (new_type) = TREE_TYPE (new_type) = ptr; --- 2632,2638 ---- TREE_CHAIN (TYPE_FIELDS (ptr)), new_ref)); for (var = TYPE_MAIN_VARIANT (ptr); var; var = TYPE_NEXT_VARIANT (var)) ! SET_TYPE_UNCONSTRAINED_ARRAY (var, new_type); TYPE_POINTER_TO (new_type) = TYPE_REFERENCE_TO (new_type) = TREE_TYPE (new_type) = ptr; *************** convert (type, expr) *** 2824,2830 **** /* If we previously converted from another type and our type is of variable size, remove the conversion to avoid the need for variable-size temporaries. */ ! if (TREE_CODE (expr) == UNCHECKED_CONVERT_EXPR && ! TREE_CONSTANT (TYPE_SIZE (type))) expr = TREE_OPERAND (expr, 0); --- 2793,2799 ---- /* If we previously converted from another type and our type is of variable size, remove the conversion to avoid the need for variable-size temporaries. */ ! if (TREE_CODE (expr) == VIEW_CONVERT_EXPR && ! TREE_CONSTANT (TYPE_SIZE (type))) expr = TREE_OPERAND (expr, 0); *************** convert (type, expr) *** 2947,2953 **** ecode = TREE_CODE (etype); break; ! case UNCHECKED_CONVERT_EXPR: if (AGGREGATE_TYPE_P (type) && AGGREGATE_TYPE_P (etype) && ! TYPE_FAT_POINTER_P (type) && ! TYPE_FAT_POINTER_P (etype)) return convert (type, TREE_OPERAND (expr, 0)); --- 2916,2922 ---- ecode = TREE_CODE (etype); break; ! case VIEW_CONVERT_EXPR: if (AGGREGATE_TYPE_P (type) && AGGREGATE_TYPE_P (etype) && ! TYPE_FAT_POINTER_P (type) && ! TYPE_FAT_POINTER_P (etype)) return convert (type, TREE_OPERAND (expr, 0)); *************** convert (type, expr) *** 3105,3133 **** } /* Remove all conversions that are done in EXP. This includes converting ! from a padded type or converting to a left-justified modular type. */ tree ! remove_conversions (exp) tree exp; { switch (TREE_CODE (exp)) { case CONSTRUCTOR: ! if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE && TYPE_LEFT_JUSTIFIED_MODULAR_P (TREE_TYPE (exp))) ! return remove_conversions (TREE_VALUE (CONSTRUCTOR_ELTS (exp))); break; case COMPONENT_REF: if (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == RECORD_TYPE && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (exp, 0)))) ! return remove_conversions (TREE_OPERAND (exp, 0)); break; ! case UNCHECKED_CONVERT_EXPR: ! case NOP_EXPR: case CONVERT_EXPR: ! return remove_conversions (TREE_OPERAND (exp, 0)); default: break; --- 3074,3106 ---- } /* Remove all conversions that are done in EXP. This includes converting ! from a padded type or to a left-justified modular type. If TRUE_ADDRESS ! is nonzero, always return the address of the containing object even if ! the address is not bit-aligned. */ tree ! remove_conversions (exp, true_address) tree exp; + int true_address; { switch (TREE_CODE (exp)) { case CONSTRUCTOR: ! if (true_address ! && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE && TYPE_LEFT_JUSTIFIED_MODULAR_P (TREE_TYPE (exp))) ! return remove_conversions (TREE_VALUE (CONSTRUCTOR_ELTS (exp)), 1); break; case COMPONENT_REF: if (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == RECORD_TYPE && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (exp, 0)))) ! return remove_conversions (TREE_OPERAND (exp, 0), true_address); break; ! case VIEW_CONVERT_EXPR: case NON_LVALUE_EXPR: ! case NOP_EXPR: case CONVERT_EXPR: case GNAT_NOP_EXPR: ! return remove_conversions (TREE_OPERAND (exp, 0), true_address); default: break; *************** unchecked_convert (type, expr) *** 3298,3323 **** else if (TREE_CODE (etype) == UNCONSTRAINED_ARRAY_TYPE && TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) expr = build_unary_op (INDIRECT_REF, NULL_TREE, ! build1 (UNCHECKED_CONVERT_EXPR, TREE_TYPE (type), build_unary_op (ADDR_EXPR, NULL_TREE, expr))); - - /* If both types are aggregates with the same mode and alignment (except - if the result is a UNION_TYPE), we can do this as a normal conversion. */ - else if (AGGREGATE_TYPE_P (type) && AGGREGATE_TYPE_P (etype) - && TREE_CODE (type) != UNION_TYPE - && TYPE_ALIGN (type) == TYPE_ALIGN (etype) - && TYPE_MODE (type) == TYPE_MODE (etype)) - expr = build1 (CONVERT_EXPR, type, expr); - else { expr = maybe_unconstrained_array (expr); etype = TREE_TYPE (expr); ! expr = build1 (UNCHECKED_CONVERT_EXPR, type, expr); } - /* If the result is an integral type whose size is not equal to the size of the underlying machine type, sign- or zero-extend the result. We need not do this in the case where the input is --- 3271,3286 ---- else if (TREE_CODE (etype) == UNCONSTRAINED_ARRAY_TYPE && TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) expr = build_unary_op (INDIRECT_REF, NULL_TREE, ! build1 (VIEW_CONVERT_EXPR, TREE_TYPE (type), build_unary_op (ADDR_EXPR, NULL_TREE, expr))); else { expr = maybe_unconstrained_array (expr); etype = TREE_TYPE (expr); ! expr = build1 (VIEW_CONVERT_EXPR, type, expr); } /* If the result is an integral type whose size is not equal to the size of the underlying machine type, sign- or zero-extend the result. We need not do this in the case where the input is *************** unchecked_convert (type, expr) *** 3336,3342 **** 0)) && ! (TREE_UNSIGNED (type) && TREE_UNSIGNED (etype))) { ! tree base_type = type_for_mode (TYPE_MODE (type), TREE_UNSIGNED (type)); tree shift_expr = convert (base_type, size_binop (MINUS_EXPR, --- 3299,3306 ---- 0)) && ! (TREE_UNSIGNED (type) && TREE_UNSIGNED (etype))) { ! tree base_type = gnat_type_for_mode (TYPE_MODE (type), ! TREE_UNSIGNED (type)); tree shift_expr = convert (base_type, size_binop (MINUS_EXPR, *************** unchecked_convert (type, expr) *** 3353,3370 **** } /* An unchecked conversion should never raise Constraint_Error. The code ! below assumes that GCC's conversion routines overflow the same ! way that the underlying hardware does. This is probably true. In ! the rare case when it isn't, we can rely on the fact that such ! conversions are erroneous anyway. */ if (TREE_CODE (expr) == INTEGER_CST) TREE_OVERFLOW (expr) = TREE_CONSTANT_OVERFLOW (expr) = 0; ! /* If the sizes of the types differ and this is an UNCHECKED_CONVERT_EXPR, show no longer constant. */ ! if (TREE_CODE (expr) == UNCHECKED_CONVERT_EXPR && ! operand_equal_p (TYPE_SIZE_UNIT (type), TYPE_SIZE_UNIT (etype), 1)) TREE_CONSTANT (expr) = 0; return expr; } --- 3317,3337 ---- } /* An unchecked conversion should never raise Constraint_Error. The code ! below assumes that GCC's conversion routines overflow the same way that ! the underlying hardware does. This is probably true. In the rare case ! when it is false, we can rely on the fact that such conversions are ! erroneous anyway. */ if (TREE_CODE (expr) == INTEGER_CST) TREE_OVERFLOW (expr) = TREE_CONSTANT_OVERFLOW (expr) = 0; ! /* If the sizes of the types differ and this is an VIEW_CONVERT_EXPR, show no longer constant. */ ! if (TREE_CODE (expr) == VIEW_CONVERT_EXPR && ! operand_equal_p (TYPE_SIZE_UNIT (type), TYPE_SIZE_UNIT (etype), 1)) TREE_CONSTANT (expr) = 0; return expr; } + + #include "gt-ada-utils.h" + #include "gtype-ada.h" diff -Nrc3pad gcc-3.2.3/gcc/ada/validsw.adb gcc-3.3/gcc/ada/validsw.adb *** gcc-3.2.3/gcc/ada/validsw.adb 2002-05-04 03:29:25.000000000 +0000 --- gcc-3.3/gcc/ada/validsw.adb 2002-10-23 07:33:34.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.1 $ -- -- ! -- Copyright (C) 2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 2001-2002 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- -- *************** package body Validsw is *** 128,134 **** --- 127,138 ---- C := Options (J); J := J + 1; + -- Turn on validity checking (gets turned off by Vn) + + Validity_Checks_On := True; + case C is + when 'c' => Validity_Check_Copies := True; *************** package body Validsw is *** 204,209 **** --- 208,214 ---- Validity_Check_Returns := False; Validity_Check_Subscripts := False; Validity_Check_Tests := False; + Validity_Checks_On := False; when ' ' => null; *************** package body Validsw is *** 215,221 **** end case; end loop; - Validity_Checks_On := True; OK := True; Err_Col := Options'Last + 1; end Set_Validity_Check_Options; --- 220,225 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/validsw.ads gcc-3.3/gcc/ada/validsw.ads *** gcc-3.2.3/gcc/ada/validsw.ads 2002-05-04 03:29:25.000000000 +0000 --- gcc-3.3/gcc/ada/validsw.ads 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/widechar.adb gcc-3.3/gcc/ada/widechar.adb *** gcc-3.2.3/gcc/ada/widechar.adb 2002-05-04 03:29:25.000000000 +0000 --- gcc-3.3/gcc/ada/widechar.adb 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/widechar.ads gcc-3.3/gcc/ada/widechar.ads *** gcc-3.2.3/gcc/ada/widechar.ads 2002-05-07 08:22:37.000000000 +0000 --- gcc-3.3/gcc/ada/widechar.ads 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,12 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/xeinfo.adb gcc-3.3/gcc/ada/xeinfo.adb *** gcc-3.2.3/gcc/ada/xeinfo.adb 2002-05-04 03:29:25.000000000 +0000 --- gcc-3.3/gcc/ada/xeinfo.adb 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.3.10.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** procedure XEinfo is *** 69,76 **** A : VString := Nul; B : VString := Nul; C : VString := Nul; - Einfobrev : VString := Nul; - Einfosrev : VString := Nul; Expr : VString := Nul; Filler : VString := Nul; Fline : VString := Nul; --- 68,73 ---- *************** procedure XEinfo is *** 89,98 **** OldS : VString := Nul; Rtn : VString := Nul; Term : VString := Nul; - XEinforev : VString := Nul; - - InB : File_Type; - -- Used to read initial header from body InF : File_Type; -- Used to read full text of both spec and body --- 86,91 ---- *************** procedure XEinfo is *** 101,110 **** -- Used to write output file wsp : Pattern := NSpan (' ' & ASCII.HT); - Get_BRev : Pattern := BreakX ('$') & "$Rev" & "ision: " - & Break (' ') * Einfobrev; - Get_SRev : Pattern := BreakX ('$') & "$Rev" & "ision: " - & Break (' ') * Einfosrev; Comment : Pattern := wsp & "--"; For_Rep : Pattern := wsp & "for"; Get_Func : Pattern := wsp * A & "function" & wsp & Break (' ') * Name; --- 94,99 ---- *************** procedure XEinfo is *** 249,307 **** begin Anchored_Mode := True; - Match ("$Revision: 1.3.10.1 $", "$Rev" & "ision: " & Break (' ') * XEinforev); - if Argument_Count > 0 then Create (Ofile, Out_File, Argument (1)); else Create (Ofile, Out_File, "a-einfo.h"); end if; - Open (InB, In_File, "einfo.adb"); Open (InF, In_File, "einfo.ads"); Lineno := 0; ! -- Get einfo revs and write header to output file ! ! loop ! Line := Get_Line (InB); ! ! if Line = "" then ! raise Err; ! end if; ! ! exit when Match (Line, Get_BRev); ! end loop; loop Line := Get_Line (InF); Lineno := Lineno + 1; exit when Line = ""; ! if Match (Line, Get_SRev) then ! Put_Line ! (Ofile, ! "/* Generated by xeinfo revision " & XEinforev & ! " using */"); ! Put_Line ! (Ofile, ! "/* einfo.ads revision " & Einfosrev & ! " */"); ! Put_Line ! (Ofile, ! "/* einfo.adb revision " & Einfobrev & ! " */"); ! else ! Match (Line, ! "-- S p e c ", ! "-- C Header File "); ! Match (Line, "--", "/*"); ! Match (Line, Rtab (2) * A & "--", M); ! Replace (M, A & "*/"); ! Put_Line (Ofile, Line); ! end if; end loop; Put_Line (Ofile, ""); --- 238,268 ---- begin Anchored_Mode := True; if Argument_Count > 0 then Create (Ofile, Out_File, Argument (1)); else Create (Ofile, Out_File, "a-einfo.h"); end if; Open (InF, In_File, "einfo.ads"); Lineno := 0; ! -- Write header to output file loop Line := Get_Line (InF); Lineno := Lineno + 1; exit when Line = ""; ! Match (Line, ! "-- S p e c ", ! "-- C Header File "); ! Match (Line, "--", "/*"); ! Match (Line, Rtab (2) * A & "--", M); ! Replace (M, A & "*/"); ! Put_Line (Ofile, Line); end loop; Put_Line (Ofile, ""); *************** begin *** 444,450 **** -- Read body to find inlined functions - Close (InB); Close (InF); Open (InF, In_File, "einfo.adb"); Lineno := 0; --- 405,410 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/xnmake.adb gcc-3.3/gcc/ada/xnmake.adb *** gcc-3.2.3/gcc/ada/xnmake.adb 2002-05-07 08:22:37.000000000 +0000 --- gcc-3.3/gcc/ada/xnmake.adb 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.2.12.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** procedure XNmake is *** 75,85 **** Node : VString := Nul; Op_Name : VString := Nul; Prevl : VString := Nul; - Sinfo_Rev : VString := Nul; Synonym : VString := Nul; - Temp_Rev : VString := Nul; X : VString := Nul; - XNmake_Rev : VString := Nul; Lineno : Natural; NWidth : Natural; --- 74,81 ---- *************** procedure XNmake is *** 99,110 **** -- Note: in following patterns, we break up the word revision to -- avoid RCS getting enthusiastic about updating the reference! - Get_SRev : Pattern := BreakX ('$') & "$Rev" & "ision: " & - Break (' ') * Sinfo_Rev; - - GetT_Rev : Pattern := BreakX ('$') & "$Rev" & "ision: " & - Break (' ') * Temp_Rev; - Body_Only : Pattern := BreakX (' ') * X & Span (' ') & "-- body only"; Spec_Only : Pattern := BreakX (' ') * X & Span (' ') & "-- spec only"; --- 95,100 ---- *************** procedure XNmake is *** 207,215 **** begin -- Capture our revision (following line updated by RCS) - Match ("$Revision: 1.2.12.2 $", - "$Rev" & "ision: " & Break (' ') * XNmake_Rev); - Lineno := 0; NWidth := 28; Anchored_Mode := True; --- 197,202 ---- *************** begin *** 272,335 **** Anchored_Mode := True; - -- Get Sinfo revision number - - loop - Line := Get_Line (InS); - exit when Match (Line, Get_SRev); - end loop; - -- Copy initial part of template to spec and body loop Line := Get_Line (InT); ! if Match (Line, GetT_Rev) then ! WriteBS ! ("-- Generated by xnmake revision " & ! XNmake_Rev & " using"); ! ! WriteBS ! ("-- sinfo.ads revision " & ! Sinfo_Rev); ! ! WriteBS ! ("-- nmake.adt revision " & ! Temp_Rev); ! ! else ! -- Skip lines describing the template ! ! if Match (Line, "-- This file is a template") then ! loop ! Line := Get_Line (InT); ! exit when Line = ""; ! end loop; ! end if; ! exit when Match (Line, "package"); ! if Match (Line, Body_Only, M) then ! Replace (M, X); ! WriteB (Line); ! elsif Match (Line, Spec_Only, M) then ! Replace (M, X); ! WriteS (Line); ! else ! if Match (Line, Templ, M) then ! Replace (M, A & " S p e c "); ! end if; ! WriteS (Line); ! if Match (Line, Spec, M) then ! Replace (M, A & "B o d y"); ! end if; ! WriteB (Line); end if; end if; end loop; --- 259,300 ---- Anchored_Mode := True; -- Copy initial part of template to spec and body loop Line := Get_Line (InT); ! -- Skip lines describing the template ! if Match (Line, "-- This file is a template") then ! loop ! Line := Get_Line (InT); ! exit when Line = ""; ! end loop; ! end if; ! exit when Match (Line, "package"); ! if Match (Line, Body_Only, M) then ! Replace (M, X); ! WriteB (Line); ! elsif Match (Line, Spec_Only, M) then ! Replace (M, X); ! WriteS (Line); ! else ! if Match (Line, Templ, M) then ! Replace (M, A & " S p e c "); ! end if; ! WriteS (Line); ! if Match (Line, Spec, M) then ! Replace (M, A & "B o d y"); end if; + + WriteB (Line); end if; end loop; diff -Nrc3pad gcc-3.2.3/gcc/ada/xref_lib.adb gcc-3.3/gcc/ada/xref_lib.adb *** gcc-3.2.3/gcc/ada/xref_lib.adb 2002-05-04 03:29:25.000000000 +0000 --- gcc-3.3/gcc/ada/xref_lib.adb 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1998-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2002 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- -- *************** *** 25,38 **** -- -- ------------------------------------------------------------------------------ - with Ada.Strings.Fixed; use Ada.Strings.Fixed; - with GNAT.Command_Line; use GNAT.Command_Line; - with GNAT.IO_Aux; use GNAT.IO_Aux; with Osint; with Output; use Output; with Types; use Types; with Unchecked_Deallocation; package body Xref_Lib is Type_Position : constant := 50; --- 24,39 ---- -- -- ------------------------------------------------------------------------------ with Osint; with Output; use Output; with Types; use Types; with Unchecked_Deallocation; + with Ada.Strings.Fixed; use Ada.Strings.Fixed; + + with GNAT.Command_Line; use GNAT.Command_Line; + with GNAT.IO_Aux; use GNAT.IO_Aux; + package body Xref_Lib is Type_Position : constant := 50; *************** package body Xref_Lib is *** 42,52 **** -- Local Variables -- --------------------- - D : constant Character := 'D'; - X : constant Character := 'X'; - W : constant Character := 'W'; - Dot : constant Character := '.'; - Pipe : constant Character := '|'; -- First character on xref lines in the .ali file --- 43,48 ---- *************** package body Xref_Lib is *** 60,68 **** subtype File_Offset is Natural; - function End_Of_Line_Index (File : ALI_File) return Integer; - -- Returns the index of the last character of the current_line - procedure Read_File (FD : File_Descriptor; Contents : out String_Access; --- 56,61 ---- *************** package body Xref_Lib is *** 259,299 **** end if; end if; ! Add_File (Entity (File_Start .. Line_Start - 1), File_Existed, File_Ref, Visited => True); Add_Line (File_Ref, Line_Num, Col_Num); ! Add_File (ALI_File_Name (Entity (File_Start .. Line_Start - 1)), File_Existed, File_Ref, Visited => False, Emit_Warning => True); end Add_Entity; ! -------------- ! -- Add_File -- ! -------------- ! procedure Add_File (File : String) is File_Ref : File_Reference := Empty_File; File_Existed : Boolean; Iterator : Expansion_Iterator; ! procedure Add_File_Internal (File : String); -- Do the actual addition of the file ! ----------------------- ! -- Add_File_Internal -- ! ----------------------- ! procedure Add_File_Internal (File : String) is begin -- Case where we have an ALI file, accept it even though this is -- not official usage, since the intention is obvious if Tail (File, 4) = ".ali" then ! Add_File (File, File_Existed, File_Ref, --- 252,292 ---- end if; end if; ! Add_To_Xref_File (Entity (File_Start .. Line_Start - 1), File_Existed, File_Ref, Visited => True); Add_Line (File_Ref, Line_Num, Col_Num); ! Add_To_Xref_File (ALI_File_Name (Entity (File_Start .. Line_Start - 1)), File_Existed, File_Ref, Visited => False, Emit_Warning => True); end Add_Entity; ! ------------------- ! -- Add_Xref_File -- ! ------------------- ! procedure Add_Xref_File (File : String) is File_Ref : File_Reference := Empty_File; File_Existed : Boolean; Iterator : Expansion_Iterator; ! procedure Add_Xref_File_Internal (File : String); -- Do the actual addition of the file ! ---------------------------- ! -- Add_Xref_File_Internal -- ! ---------------------------- ! procedure Add_Xref_File_Internal (File : String) is begin -- Case where we have an ALI file, accept it even though this is -- not official usage, since the intention is obvious if Tail (File, 4) = ".ali" then ! Add_To_Xref_File (File, File_Existed, File_Ref, *************** package body Xref_Lib is *** 303,324 **** -- Normal non-ali file case else ! Add_File (File, File_Existed, File_Ref, Visited => True); ! Add_File (ALI_File_Name (File), File_Existed, File_Ref, Visited => False, Emit_Warning => True); end if; ! end Add_File_Internal; ! -- Start of processing for Add_File begin -- Check if we need to do the expansion --- 296,317 ---- -- Normal non-ali file case else ! Add_To_Xref_File (File, File_Existed, File_Ref, Visited => True); ! Add_To_Xref_File (ALI_File_Name (File), File_Existed, File_Ref, Visited => False, Emit_Warning => True); end if; ! end Add_Xref_File_Internal; ! -- Start of processing for Add_Xref_File begin -- Check if we need to do the expansion *************** package body Xref_Lib is *** 334,347 **** begin exit when S'Length = 0; ! Add_File_Internal (S); end; end loop; else ! Add_File_Internal (File); end if; ! end Add_File; ----------------------- -- Current_Xref_File -- --- 327,340 ---- begin exit when S'Length = 0; ! Add_Xref_File_Internal (S); end; end loop; else ! Add_Xref_File_Internal (File); end if; ! end Add_Xref_File; ----------------------- -- Current_Xref_File -- *************** package body Xref_Lib is *** 387,408 **** when Directory_Error => return String'(1 .. 0 => ' '); end Default_Project_File; - ----------------------- - -- End_Of_Line_Index -- - ----------------------- - - function End_Of_Line_Index (File : ALI_File) return Integer is - Index : Integer := File.Current_Line; - begin - while Index <= File.Buffer'Last - and then File.Buffer (Index) /= ASCII.LF - loop - Index := Index + 1; - end loop; - - return Index; - end End_Of_Line_Index; - --------------- -- File_Name -- --------------- --- 380,385 ---- *************** package body Xref_Lib is *** 478,484 **** end if; elsif Last > 4 and then Dir_Ent (Last - 3 .. Last) = ".ali" then ! Add_File (Dir_Ent (1 .. Last), File_Existed, File_Ref, Visited => False); Set_Directory (File_Ref, Current_Obj_Dir); end if; --- 455,464 ---- end if; elsif Last > 4 and then Dir_Ent (Last - 3 .. Last) = ".ali" then ! Add_To_Xref_File ! (Dir_Ent (1 .. Last), ! File_Existed, ! File_Ref, Visited => False); Set_Directory (File_Ref, Current_Obj_Dir); end if; *************** package body Xref_Lib is *** 609,615 **** while Ali (Ptr) /= EOF loop ! if Ali (Ptr) = D then -- Found dependency information. Format looks like: -- D source-name time-stamp checksum [subunit-name] \ -- [line:file-name] --- 589,595 ---- while Ali (Ptr) /= EOF loop ! if Ali (Ptr) = 'D' then -- Found dependency information. Format looks like: -- D source-name time-stamp checksum [subunit-name] \ -- [line:file-name] *************** package body Xref_Lib is *** 645,658 **** Token := Gnatchop_Name + 1; end if; ! Add_File (Ali (File_Start .. File_End), File_Existed, File.Dep.Table (Num_Dependencies), Gnatchop_File => Ali (Token .. Ptr - 1), Gnatchop_Offset => Gnatchop_Offset); ! elsif Dependencies and then Ali (Ptr) = W then -- Found with-clause information. Format looks like: -- "W debug%s debug.adb debug.ali" --- 625,638 ---- Token := Gnatchop_Name + 1; end if; ! Add_To_Xref_File (Ali (File_Start .. File_End), File_Existed, File.Dep.Table (Num_Dependencies), Gnatchop_File => Ali (Token .. Ptr - 1), Gnatchop_Offset => Gnatchop_Offset); ! elsif Dependencies and then Ali (Ptr) = 'W' then -- Found with-clause information. Format looks like: -- "W debug%s debug.adb debug.ali" *************** package body Xref_Lib is *** 662,673 **** Parse_Token (Ali, Ptr, Token); Parse_Token (Ali, Ptr, Token); ! Add_File (Ali (Token .. Ptr - 1), ! File_Existed, File_Ref, Visited => False); ! elsif Ali (Ptr) = X then -- Found a cross-referencing line - stop processing File.Current_Line := Ptr; --- 642,654 ---- Parse_Token (Ali, Ptr, Token); Parse_Token (Ali, Ptr, Token); ! Add_To_Xref_File (Ali (Token .. Ptr - 1), ! File_Existed, ! File_Ref, Visited => False); ! elsif Ali (Ptr) = 'X' then -- Found a cross-referencing line - stop processing File.Current_Line := Ptr; *************** package body Xref_Lib is *** 852,858 **** Decl_Ref := Add_Declaration (File.X_File, Ali (E_Name .. Ptr - 1), E_Line, E_Col, E_Type); ! if Ali (Ptr) = '<' then -- Here we have a type derivation information. The format is -- <3|12I45> which means that the current entity is derived from the --- 833,842 ---- Decl_Ref := Add_Declaration (File.X_File, Ali (E_Name .. Ptr - 1), E_Line, E_Col, E_Type); ! if Ali (Ptr) = '<' ! or else Ali (Ptr) = '(' ! or else Ali (Ptr) = '{' ! then -- Here we have a type derivation information. The format is -- <3|12I45> which means that the current entity is derived from the *************** package body Xref_Lib is *** 860,974 **** -- unit number is optional. It is specified only if the parent type -- is not defined in the current unit. Ptr := Ptr + 1; ! Parse_Derived_Info : declare ! P_Line : Natural; -- parent entity line ! P_Column : Natural; -- parent entity column ! P_Type : Character; -- parent entity type ! P_Eun : Positive; -- parent entity file number ! begin ! Parse_Number (Ali, Ptr, P_Line); ! -- If we have a pipe then the first number was the unit number ! if Ali (Ptr) = '|' then ! P_Eun := P_Line; ! Ptr := Ptr + 1; ! -- Now we have the line number ! Parse_Number (Ali, Ptr, P_Line); ! else ! -- We don't have a unit number specified, so we set P_Eun to ! -- the current unit. ! for K in Dependencies_Tables.First .. Last (File.Dep) loop ! P_Eun := K; ! exit when File.Dep.Table (K) = File_Ref; ! end loop; ! end if; ! -- Then parse the type and column number ! P_Type := Ali (Ptr); ! Ptr := Ptr + 1; ! Parse_Number (Ali, Ptr, P_Column); ! -- Skip '>' ! Ptr := Ptr + 1; ! -- The derived info is needed only is the derived info mode is on ! -- or if we want to output the type hierarchy ! if Der_Info or else Type_Tree then ! Add_Parent ! (Decl_Ref, ! Get_Symbol_Name (P_Eun, P_Line, P_Column), ! P_Line, ! P_Column, ! File.Dep.Table (P_Eun)); ! end if; ! if Type_Tree then ! Search_Parent_Tree : declare ! Pattern : Search_Pattern; -- Parent type pattern ! File_Pos_Backup : Positive; ! begin ! Add_Entity ! (Pattern, ! Get_Symbol_Name (P_Eun, P_Line, P_Column) ! & ':' & Get_Gnatchop_File (File.Dep.Table (P_Eun)) ! & ':' & Get_Line (Get_Parent (Decl_Ref)) ! & ':' & Get_Column (Get_Parent (Decl_Ref)), False); ! -- No default match is needed to look for the parent type ! -- since we are using the fully qualified symbol name: ! -- symbol:file:line:column ! Set_Default_Match (False); ! -- The parent type is defined in the same unit as the ! -- derived type. So we want to revisit the unit. ! File_Pos_Backup := File.Current_Line; ! if File.Dep.Table (P_Eun) = File_Ref then ! -- set file pointer at the start of the xref lines ! File.Current_Line := File.Xref_Line; ! Revisit_ALI_File : declare ! File_Existed : Boolean; ! File_Ref : File_Reference; ! begin ! Add_File ! (ALI_File_Name (Get_File (File.Dep.Table (P_Eun))), ! File_Existed, ! File_Ref, ! Visited => False); ! Set_Unvisited (File_Ref); ! end Revisit_ALI_File; ! end if; ! Search (Pattern, ! Local_Symbols, False, False, Der_Info, Type_Tree); ! File.Current_Line := File_Pos_Backup; ! -- in this mode there is no need to parse the remaining of ! -- the lines. ! return; ! end Search_Parent_Tree; ! end if; ! end Parse_Derived_Info; end if; -- To find the body, we will have to parse the file too --- 844,980 ---- -- unit number is optional. It is specified only if the parent type -- is not defined in the current unit. + -- We could also have something like + -- 16I9*I + -- that indicates that I derives from the predefined type integer. + Ptr := Ptr + 1; ! if Ali (Ptr) in '0' .. '9' then ! Parse_Derived_Info : declare ! P_Line : Natural; -- parent entity line ! P_Column : Natural; -- parent entity column ! P_Type : Character; -- parent entity type ! P_Eun : Positive; -- parent entity file number ! begin ! Parse_Number (Ali, Ptr, P_Line); ! -- If we have a pipe then the first number was the unit number ! if Ali (Ptr) = '|' then ! P_Eun := P_Line; ! Ptr := Ptr + 1; ! -- Now we have the line number ! Parse_Number (Ali, Ptr, P_Line); ! else ! -- We don't have a unit number specified, so we set P_Eun to ! -- the current unit. ! for K in Dependencies_Tables.First .. Last (File.Dep) loop ! P_Eun := K; ! exit when File.Dep.Table (K) = File_Ref; ! end loop; ! end if; ! -- Then parse the type and column number ! P_Type := Ali (Ptr); ! Ptr := Ptr + 1; ! Parse_Number (Ali, Ptr, P_Column); ! -- Skip '>', or ')' or '>' ! Ptr := Ptr + 1; ! -- The derived info is needed only is the derived info mode is ! -- on or if we want to output the type hierarchy ! if Der_Info or else Type_Tree then ! Add_Parent ! (Decl_Ref, ! Get_Symbol_Name (P_Eun, P_Line, P_Column), ! P_Line, ! P_Column, ! File.Dep.Table (P_Eun)); ! end if; ! if Type_Tree then ! Search_Parent_Tree : declare ! Pattern : Search_Pattern; -- Parent type pattern ! File_Pos_Backup : Positive; ! begin ! Add_Entity ! (Pattern, ! Get_Symbol_Name (P_Eun, P_Line, P_Column) ! & ':' & Get_Gnatchop_File (File.Dep.Table (P_Eun)) ! & ':' & Get_Line (Get_Parent (Decl_Ref)) ! & ':' & Get_Column (Get_Parent (Decl_Ref)), False); ! -- No default match is needed to look for the parent type ! -- since we are using the fully qualified symbol name: ! -- symbol:file:line:column ! Set_Default_Match (False); ! -- The parent type is defined in the same unit as the ! -- derived type. So we want to revisit the unit. ! File_Pos_Backup := File.Current_Line; ! if File.Dep.Table (P_Eun) = File_Ref then ! -- set file pointer at the start of the xref lines ! File.Current_Line := File.Xref_Line; ! Revisit_ALI_File : declare ! File_Existed : Boolean; ! File_Ref : File_Reference; ! begin ! Add_To_Xref_File ! (ALI_File_Name ! (Get_File (File.Dep.Table (P_Eun))), ! File_Existed, ! File_Ref, ! Visited => False); ! Set_Unvisited (File_Ref); ! end Revisit_ALI_File; ! end if; ! Search (Pattern, ! Local_Symbols, False, False, Der_Info, Type_Tree); ! File.Current_Line := File_Pos_Backup; ! end Search_Parent_Tree; ! end if; ! end Parse_Derived_Info; ! else ! while Ali (Ptr) /= '>' ! and then Ali (Ptr) /= ')' ! and then Ali (Ptr) /= '}' ! loop ! Ptr := Ptr + 1; ! end loop; ! Ptr := Ptr + 1; ! end if; ! ! elsif Ali (Ptr) = '=' then ! declare ! P_Line, P_Column : Natural; ! begin ! Ptr := Ptr + 1; ! Parse_Number (Ali, Ptr, P_Line); ! Ptr := Ptr + 1; ! Parse_Number (Ali, Ptr, P_Column); ! end; end if; -- To find the body, we will have to parse the file too *************** package body Xref_Lib is *** 981,988 **** Get_Gnatchop_File (File.X_File); begin ! Add_File (ALI_File_Name (File_Name), ! File_Existed, File_Ref, False); end; end if; --- 987,994 ---- Get_Gnatchop_File (File.X_File); begin ! Add_To_Xref_File ! (ALI_File_Name (File_Name), File_Existed, File_Ref, False); end; end if; *************** package body Xref_Lib is *** 1017,1022 **** --- 1023,1046 ---- Add_Reference (Decl_Ref, File_Ref, R_Line, R_Col, R_Type); + -- Skip generic information, if any + + if Ali (Ptr) = '[' then + declare + Num_Nested : Integer := 1; + begin + Ptr := Ptr + 1; + while Num_Nested /= 0 loop + if Ali (Ptr) = ']' then + Num_Nested := Num_Nested - 1; + elsif Ali (Ptr) = '[' then + Num_Nested := Num_Nested + 1; + end if; + Ptr := Ptr + 1; + end loop; + end; + end if; + end loop; Parse_EOL (Ali, Ptr); *************** package body Xref_Lib is *** 1076,1083 **** while (In_Quotes or else not (Source (Ptr) = ' ' ! or else Source (Ptr) = ASCII.HT ! or else Source (Ptr) = '<')) and then Source (Ptr) >= ' ' loop if Source (Ptr) = '"' then --- 1100,1110 ---- while (In_Quotes or else not (Source (Ptr) = ' ' ! or else Source (Ptr) = ASCII.HT ! or else Source (Ptr) = '<' ! or else Source (Ptr) = '{' ! or else Source (Ptr) = '=' ! or else Source (Ptr) = '(')) and then Source (Ptr) >= ' ' loop if Source (Ptr) = '"' then *************** package body Xref_Lib is *** 1098,1104 **** File_Nr : Natural; begin ! while Ali (Ptr) = X loop -- The current line is the start of a new Xref file section, -- whose format looks like: --- 1125,1131 ---- File_Nr : Natural; begin ! while Ali (Ptr) = 'X' loop -- The current line is the start of a new Xref file section, -- whose format looks like: diff -Nrc3pad gcc-3.2.3/gcc/ada/xref_lib.ads gcc-3.3/gcc/ada/xref_lib.ads *** gcc-3.2.3/gcc/ada/xref_lib.ads 2002-05-04 03:29:26.000000000 +0000 --- gcc-3.3/gcc/ada/xref_lib.ads 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1998-1999 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2001 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- -- *************** package Xref_Lib is *** 68,77 **** -- this procedure. Glob indicates if we should use the 'globbing -- patterns' (True) or the full regular expressions (False) ! procedure Add_File (File : String); ! -- Add a new file in the list of files to search for references. ! -- File is considered to be a globbing regular expression, which is thus ! -- expanded Invalid_Argument : exception; -- Exception raised when there is a syntax error in the command line --- 67,75 ---- -- this procedure. Glob indicates if we should use the 'globbing -- patterns' (True) or the full regular expressions (False) ! procedure Add_Xref_File (File : String); ! -- Add a new file in the list of files to search for references. File ! -- is interpreted as a globbing regular expression, which is expanded. Invalid_Argument : exception; -- Exception raised when there is a syntax error in the command line *************** package Xref_Lib is *** 155,161 **** -- if Dependencies is True, the insert every library file 'with'ed in -- the files database (used for gnatxref) - private type Rec_DIR is limited record Dir : GNAT.Directory_Operations.Dir_Type; --- 153,158 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/xr_tabls.adb gcc-3.3/gcc/ada/xr_tabls.adb *** gcc-3.2.3/gcc/ada/xr_tabls.adb 2002-05-04 03:29:25.000000000 +0000 --- gcc-3.3/gcc/ada/xr_tabls.adb 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,14 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1998-2001 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- -- --- 6,13 ---- -- -- -- B o d y -- -- -- -- -- ! -- Copyright (C) 1998-2002 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- -- *************** *** 25,48 **** -- -- ------------------------------------------------------------------------------ with Ada.IO_Exceptions; with Ada.Strings.Fixed; with Ada.Strings; with Ada.Text_IO; ! with Hostparm; with GNAT.IO_Aux; - with Unchecked_Deallocation; with GNAT.OS_Lib; use GNAT.OS_Lib; with GNAT.Directory_Operations; use GNAT.Directory_Operations; - with Osint; - - with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package body Xr_Tabls is - subtype Line_String is String (1 .. Hostparm.Max_Line_Length); - subtype File_Name_String is String (1 .. Hostparm.Max_Name_Length); - function Base_File_Name (File : String) return String; -- Return the base file name for File (ie not including the directory) --- 24,44 ---- -- -- ------------------------------------------------------------------------------ + with Osint; + with Unchecked_Deallocation; + with Ada.IO_Exceptions; with Ada.Strings.Fixed; with Ada.Strings; with Ada.Text_IO; ! with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; ! with GNAT.IO_Aux; with GNAT.OS_Lib; use GNAT.OS_Lib; with GNAT.Directory_Operations; use GNAT.Directory_Operations; package body Xr_Tabls is function Base_File_Name (File : String) return String; -- Return the base file name for File (ie not including the directory) *************** package body Xr_Tabls is *** 94,121 **** -- Insert the Declaration in the table ! New_Decl := new Declaration_Record' ! (Symbol_Length => Symbol'Length, ! Symbol => Symbol, ! Decl => (File => File_Ref, ! Line => Line, ! Column => Column, ! Source_Line => Null_Unbounded_String, ! Next => null), ! Decl_Type => Decl_Type, ! Body_Ref => null, ! Ref_Ref => null, ! Modif_Ref => null, ! Match => Default_Match or else Match (File_Ref, Line, Column), ! Par_Symbol => null, ! Next => null); if Prev = null then ! New_Decl.Next := Entities.Table; Entities.Table := New_Decl; else ! New_Decl.Next := Prev.Next; ! Prev.Next := New_Decl; end if; if New_Decl.Match then --- 90,119 ---- -- Insert the Declaration in the table ! New_Decl := ! new Declaration_Record' ! (Symbol_Length => Symbol'Length, ! Symbol => Symbol, ! Decl => (File => File_Ref, ! Line => Line, ! Column => Column, ! Source_Line => Null_Unbounded_String, ! Next => null), ! Decl_Type => Decl_Type, ! Body_Ref => null, ! Ref_Ref => null, ! Modif_Ref => null, ! Match => Default_Match ! or else Match (File_Ref, Line, Column), ! Par_Symbol => null, ! Next => null); if Prev = null then ! New_Decl.Next := Entities.Table; Entities.Table := New_Decl; else ! New_Decl.Next := Prev.Next; ! Prev.Next := New_Decl; end if; if New_Decl.Match then *************** package body Xr_Tabls is *** 126,151 **** return New_Decl; end Add_Declaration; ! -------------- ! -- Add_File -- ! -------------- ! procedure Add_File ! (File_Name : String; ! File_Existed : out Boolean; ! Ref : out File_Reference; ! Visited : Boolean := True; ! Emit_Warning : Boolean := False; ! Gnatchop_File : String := ""; Gnatchop_Offset : Integer := 0) is ! The_Files : File_Reference := Files.Table; Base : constant String := Base_File_Name (File_Name); Dir : constant String := Xr_Tabls.Dir_Name (File_Name); ! Dir_Acc : String_Access := null; begin ! -- Do we have a directory name as well ? if Dir /= "" then Dir_Acc := new String' (Dir); end if; --- 124,150 ---- return New_Decl; end Add_Declaration; ! ---------------------- ! -- Add_To_Xref_File -- ! ---------------------- ! procedure Add_To_Xref_File ! (File_Name : String; ! File_Existed : out Boolean; ! Ref : out File_Reference; ! Visited : Boolean := True; ! Emit_Warning : Boolean := False; ! Gnatchop_File : String := ""; Gnatchop_Offset : Integer := 0) is ! The_Files : File_Reference := Files.Table; Base : constant String := Base_File_Name (File_Name); Dir : constant String := Xr_Tabls.Dir_Name (File_Name); ! Dir_Acc : String_Access := null; begin ! -- Do we have a directory name as well? ! if Dir /= "" then Dir_Acc := new String' (Dir); end if; *************** package body Xr_Tabls is *** 175,181 **** Next => Files.Table); Files.Table := Ref; File_Existed := False; ! end Add_File; -------------- -- Add_Line -- --- 174,180 ---- Next => Files.Table); Files.Table := Ref; File_Existed := False; ! end Add_To_Xref_File; -------------- -- Add_Line -- *************** package body Xr_Tabls is *** 247,256 **** begin case Ref_Type is ! when 'b' | 'c' => Ref := Declaration.Body_Ref; ! when 'r' | 'i' => Ref := Declaration.Ref_Ref; ! when 'm' => Ref := Declaration.Modif_Ref; ! when others => return; end case; -- Check if the reference already exists --- 246,266 ---- begin case Ref_Type is ! when 'b' | 'c' => ! Ref := Declaration.Body_Ref; ! ! when 'r' | 'i' | 'l' | ' ' | 'x' => ! Ref := Declaration.Ref_Ref; ! ! when 'm' => ! Ref := Declaration.Modif_Ref; ! ! when 'e' | 't' | 'p' => ! return; ! ! when others => ! Ada.Text_IO.Put_Line ("Unknown reference type: " & Ref_Type); ! return; end case; -- Check if the reference already exists *************** package body Xr_Tabls is *** 277,291 **** else case Ref_Type is when 'b' | 'c' => ! New_Ref.Next := Declaration.Body_Ref; ! Declaration.Body_Ref := New_Ref; ! when 'r' | 'i' => ! New_Ref.Next := Declaration.Ref_Ref; ! Declaration.Ref_Ref := New_Ref; when 'm' => ! New_Ref.Next := Declaration.Modif_Ref; Declaration.Modif_Ref := New_Ref; ! when others => null; end case; end if; --- 287,305 ---- else case Ref_Type is when 'b' | 'c' => ! New_Ref.Next := Declaration.Body_Ref; ! Declaration.Body_Ref := New_Ref; ! ! when 'r' | 'i' | 'l' | ' ' | 'x' => ! New_Ref.Next := Declaration.Ref_Ref; ! Declaration.Ref_Ref := New_Ref; ! when 'm' => ! New_Ref.Next := Declaration.Modif_Ref; Declaration.Modif_Ref := New_Ref; ! ! when others => ! null; end case; end if; *************** package body Xr_Tabls is *** 327,332 **** --- 341,347 ---- return File (J + 1 .. File'Last); end if; end loop; + return File; end Base_File_Name; *************** package body Xr_Tabls is *** 614,620 **** else declare Max_Path : Integer; ! pragma Import (C, Max_Path, "max_path_len"); Base2 : Dir_Name_Str (1 .. Max_Path); Last : Natural; --- 629,635 ---- else declare Max_Path : Integer; ! pragma Import (C, Max_Path, "__gnat_max_path_len"); Base2 : Dir_Name_Str (1 .. Max_Path); Last : Natural; *************** package body Xr_Tabls is *** 973,988 **** type Simple_Ref; type Simple_Ref_Access is access Simple_Ref; ! type Simple_Ref is ! record ! Ref : Reference; ! Next : Simple_Ref_Access; ! end record; List : Simple_Ref_Access := null; -- This structure is used to speed up the parsing of Ada sources: -- Every reference found by parsing the .ali files is inserted in this ! -- list, sorted by filename and line numbers. ! -- This allows use not to parse a same ada file multiple times procedure Free is new Unchecked_Deallocation (Simple_Ref, Simple_Ref_Access); --- 988,1002 ---- type Simple_Ref; type Simple_Ref_Access is access Simple_Ref; ! type Simple_Ref is record ! Ref : Reference; ! Next : Simple_Ref_Access; ! end record; List : Simple_Ref_Access := null; -- This structure is used to speed up the parsing of Ada sources: -- Every reference found by parsing the .ali files is inserted in this ! -- list, sorted by filename and line numbers. This allows avoiding ! -- parsing a same ada file multiple times procedure Free is new Unchecked_Deallocation (Simple_Ref, Simple_Ref_Access); *************** package body Xr_Tabls is *** 1121,1126 **** --- 1135,1141 ---- else Prev.Next := new Simple_Ref'(Ref, Iter); end if; + return; end if; diff -Nrc3pad gcc-3.2.3/gcc/ada/xr_tabls.ads gcc-3.3/gcc/ada/xr_tabls.ads *** gcc-3.2.3/gcc/ada/xr_tabls.ads 2002-05-04 03:29:25.000000000 +0000 --- gcc-3.3/gcc/ada/xr_tabls.ads 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,14 **** -- -- -- S p e c -- -- -- - -- $Revision: 1.1.16.1 $ -- -- ! -- Copyright (C) 1998-2000 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- -- --- 6,13 ---- -- -- -- S p e c -- -- -- -- -- ! -- Copyright (C) 1998-2002 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- -- *************** package Xr_Tabls is *** 112,136 **** -- The parent declaration (Symbol in file File_Ref at position Line and -- Column) information is added to Declaration. ! procedure Add_File ! (File_Name : String; ! File_Existed : out Boolean; ! Ref : out File_Reference; ! Visited : Boolean := True; ! Emit_Warning : Boolean := False; ! Gnatchop_File : String := ""; Gnatchop_Offset : Integer := 0); ! -- Add a new reference to a file in the table. Ref is used to return ! -- the index in the table where this file is stored On exit, ! -- File_Existed is True if the file was already in the table Visited is ! -- the value which will be used in the table (if True, the file will ! -- not be returned by Next_Unvisited_File). If Emit_Warning is True and ! -- the ali file does not exist or does not have cross-referencing ! -- informations, then a warning will be emitted. ! -- Gnatchop_File is the name of the file that File_Name was extracted from ! -- through a call to "gnatchop -r" (with pragma Source_Reference). ! -- Gnatchop_Offset should be the index of the first line of File_Name ! -- withing Gnatchop_File. procedure Add_Line (File : File_Reference; --- 111,134 ---- -- The parent declaration (Symbol in file File_Ref at position Line and -- Column) information is added to Declaration. ! procedure Add_To_Xref_File ! (File_Name : String; ! File_Existed : out Boolean; ! Ref : out File_Reference; ! Visited : Boolean := True; ! Emit_Warning : Boolean := False; ! Gnatchop_File : String := ""; Gnatchop_Offset : Integer := 0); ! -- Add a new reference to a file in the table. Ref is used to return the ! -- index in the table where this file is stored On exit, File_Existed is ! -- True if the file was already in the table Visited is the value which ! -- will be used in the table (if True, the file will not be returned by ! -- Next_Unvisited_File). If Emit_Warning is True and the ali file does ! -- not exist or does not have cross-referencing information, then a ! -- warning will be emitted. Gnatchop_File is the name of the file that ! -- File_Name was extracted from through a call to "gnatchop -r" (using ! -- pragma Source_Reference). Gnatchop_Offset should be the index of the ! -- first line of File_Name within the Gnatchop_File. procedure Add_Line (File : File_Reference; *************** package Xr_Tabls is *** 162,168 **** function First_Body (Decl : Declaration_Reference) return Reference; function First_Declaration return Declaration_Reference; ! function First_Modif (Decl : Declaration_Reference) return Reference; function First_Reference (Decl : Declaration_Reference) return Reference; -- Initialize the iterators --- 160,166 ---- function First_Body (Decl : Declaration_Reference) return Reference; function First_Declaration return Declaration_Reference; ! function First_Modif (Decl : Declaration_Reference) return Reference; function First_Reference (Decl : Declaration_Reference) return Reference; -- Initialize the iterators *************** package Xr_Tabls is *** 186,201 **** -- Returns the Emit_Warning field of the structure function Get_Gnatchop_File ! (File : File_Reference; With_Dir : Boolean := False) return String; function Get_Gnatchop_File ! (Ref : Reference; With_Dir : Boolean := False) return String; function Get_Gnatchop_File ! (Decl : Declaration_Reference; With_Dir : Boolean := False) return String; -- Return the name of the file that File was extracted from through a ! -- call to "gnatchop -r". ! -- The file name for File is returned if File wasn't extracted from such a ! -- file. The directory will be given only if With_Dir is True. ! function Get_File (Decl : Declaration_Reference; --- 184,204 ---- -- Returns the Emit_Warning field of the structure function Get_Gnatchop_File ! (File : File_Reference; ! With_Dir : Boolean := False) ! return String; function Get_Gnatchop_File ! (Ref : Reference; ! With_Dir : Boolean := False) ! return String; function Get_Gnatchop_File ! (Decl : Declaration_Reference; ! With_Dir : Boolean := False) ! return String; -- Return the name of the file that File was extracted from through a ! -- call to "gnatchop -r". The file name for File is returned if File ! -- was not extracted from such a file. The directory will be given only ! -- if With_Dir is True. function Get_File (Decl : Declaration_Reference; *************** package Xr_Tabls is *** 213,237 **** (File : File_Reference; With_Dir : Boolean := False; Strip : Natural := 0) ! return String; ! -- Returns the file name (and its directory if With_Dir is True or ! -- the user as used the -f switch on the command line. ! -- If Strip is not 0, then the last Strip-th "-..." substrings are ! -- removed first. For instance, with Strip=2, a file name ! -- "parent-child1-child2-child3.ali" would be returned as ! -- "parent-child1.ali". This is used when looking for the ALI file to use ! -- for a package, since for separates with have to use the parent's ALI. ! -- ! -- "" is returned if there is no such parent unit ! function Get_File_Ref (Ref : Reference) return File_Reference; ! function Get_Line (Decl : Declaration_Reference) return String; ! function Get_Line (Ref : Reference) return String; ! function Get_Symbol (Decl : Declaration_Reference) return String; ! function Get_Type (Decl : Declaration_Reference) return Character; -- Functions that return the content of a declaration ! function Get_Source_Line (Ref : Reference) return String; function Get_Source_Line (Decl : Declaration_Reference) return String; -- Return the source line associated with the reference --- 216,239 ---- (File : File_Reference; With_Dir : Boolean := False; Strip : Natural := 0) ! return String; ! -- Returns the file name (and its directory if With_Dir is True or the ! -- user has used the -f switch on the command line. If Strip is not 0, ! -- then the last Strip-th "-..." substrings are removed first. For ! -- instance, with Strip=2, a file name "parent-child1-child2-child3.ali" ! -- would be returned as "parent-child1.ali". This is used when looking ! -- for the ALI file to use for a package, since for separates with have ! -- to use the parent's ALI. The null string is returned if there is no ! -- such parent unit ! function Get_File_Ref (Ref : Reference) return File_Reference; ! function Get_Line (Decl : Declaration_Reference) return String; ! function Get_Line (Ref : Reference) return String; ! function Get_Symbol (Decl : Declaration_Reference) return String; ! function Get_Type (Decl : Declaration_Reference) return Character; -- Functions that return the content of a declaration ! function Get_Source_Line (Ref : Reference) return String; function Get_Source_Line (Decl : Declaration_Reference) return String; -- Return the source line associated with the reference *************** package Xr_Tabls is *** 256,262 **** -- by the user function Next (Decl : Declaration_Reference) return Declaration_Reference; ! function Next (Ref : Reference) return Reference; -- Returns the next declaration, or Empty_Declaration function Next_Unvisited_File return File_Reference; --- 258,264 ---- -- by the user function Next (Decl : Declaration_Reference) return Declaration_Reference; ! function Next (Ref : Reference) return Reference; -- Returns the next declaration, or Empty_Declaration function Next_Unvisited_File return File_Reference; *************** package Xr_Tabls is *** 276,282 **** procedure Set_Unvisited (File_Ref : in File_Reference); -- Set File_Ref as unvisited. So Next_Unvisited_File will return it. - private type Project_File (Src_Dir_Length, Obj_Dir_Length : Natural) is record Src_Dir : String (1 .. Src_Dir_Length); --- 278,283 ---- *************** private *** 308,330 **** Empty_File : constant File_Reference := null; type File_Record (File_Length : Natural) is record ! File : String (1 .. File_Length); ! Dir : String_Access := null; ! Lines : Ref_In_File_Ptr := null; ! Visited : Boolean := False; ! Emit_Warning : Boolean := False; ! Gnatchop_File : String_Access := null; ! Gnatchop_Offset : Integer := 0; ! Next : File_Reference := null; end record; -- Holds a reference to a source file, that was referenced in at least one ! -- ALI file. ! -- Gnatchop_File will contain the name of the file that File was extracted ! -- From. Gnatchop_Offset contains the index of the first line of File ! -- within Gnatchop_File. These two fields are used to properly support -- gnatchop files and pragma Source_Reference. - type Reference_Record; type Reference is access all Reference_Record; --- 309,329 ---- Empty_File : constant File_Reference := null; type File_Record (File_Length : Natural) is record ! File : String (1 .. File_Length); ! Dir : String_Access := null; ! Lines : Ref_In_File_Ptr := null; ! Visited : Boolean := False; ! Emit_Warning : Boolean := False; ! Gnatchop_File : String_Access := null; ! Gnatchop_Offset : Integer := 0; ! Next : File_Reference := null; end record; -- Holds a reference to a source file, that was referenced in at least one ! -- ALI file. Gnatchop_File will contain the name of the file that File was ! -- extracted From. Gnatchop_Offset contains the index of the first line of ! -- File within Gnatchop_File. These two fields are used to properly support -- gnatchop files and pragma Source_Reference. type Reference_Record; type Reference is access all Reference_Record; diff -Nrc3pad gcc-3.2.3/gcc/ada/xsinfo.adb gcc-3.3/gcc/ada/xsinfo.adb *** gcc-3.2.3/gcc/ada/xsinfo.adb 2002-05-04 03:29:26.000000000 +0000 --- gcc-3.3/gcc/ada/xsinfo.adb 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.1 $ -- -- -- Copyright (C) 1992-2000 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** procedure XSinfo is *** 66,81 **** N1, N2 : VString := Nul; Nam : VString := Nul; Rtn : VString := Nul; - Sinforev : VString := Nul; Term : VString := Nul; - XSinforev : VString := Nul; InS : File_Type; Ofile : File_Type; wsp : Pattern := Span (' ' & ASCII.HT); - Get_Vsn : Pattern := BreakX ('$') & "$Rev" & "ision: " - & Break (' ') * Sinforev; Wsp_For : Pattern := wsp & "for"; Is_Cmnt : Pattern := wsp & "--"; Typ_Nod : Pattern := wsp * A & "type Node_Kind is"; --- 65,76 ---- *************** procedure XSinfo is *** 120,126 **** begin Set_Exit_Status (1); Anchored_Mode := True; - Match ("$Revision: 1.1.16.1 $", "$Rev" & "ision: " & Break (' ') * XSinforev); if Argument_Count > 0 then Create (Ofile, Out_File, Argument (1)); --- 115,120 ---- *************** begin *** 130,160 **** Open (InS, In_File, "sinfo.ads"); ! -- Get Sinfo rev and write header to output file loop Line := Get_Line (InS); exit when Line = ""; ! if Match (Line, Get_Vsn) then ! Put_Line ! (Ofile, "/* Generated by xsinfo revision " ! & XSinforev & " using */"); ! Put_Line ! (Ofile, "/* sinfo.ads revision " ! & Sinforev & " */"); ! ! else ! Match ! (Line, ! "-- S p e c ", ! "-- C Header File "); ! Match (Line, "--", "/*"); ! Match (Line, Rtab (2) * A & "--", M); ! Replace (M, A & "*/"); ! Put_Line (Ofile, Line); ! end if; end loop; -- Skip to package line --- 124,144 ---- Open (InS, In_File, "sinfo.ads"); ! -- Write header to output file loop Line := Get_Line (InS); exit when Line = ""; ! Match ! (Line, ! "-- S p e c ", ! "-- C Header File "); ! Match (Line, "--", "/*"); ! Match (Line, Rtab (2) * A & "--", M); ! Replace (M, A & "*/"); ! Put_Line (Ofile, Line); end loop; -- Skip to package line diff -Nrc3pad gcc-3.2.3/gcc/ada/xsnames.adb gcc-3.3/gcc/ada/xsnames.adb *** gcc-3.2.3/gcc/ada/xsnames.adb 2002-05-04 03:29:26.000000000 +0000 --- gcc-3.3/gcc/ada/xsnames.adb 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.12.1 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- -- --- 6,11 ---- *************** procedure XSnames is *** 51,73 **** Line : VString := Nul; Name : VString := Nul; Name1 : VString := Nul; - Oldrev : VString := Nul; Oname : VString := Nul; Oval : VString := Nul; Restl : VString := Nul; - Specrev : VString := Nul; Tdigs : Pattern := Any (Decimal_Digit_Set) & Any (Decimal_Digit_Set) & Any (Decimal_Digit_Set); - Get_Srev : Pattern := BreakX ('$') & "$Rev" & "ision: " - & Break (' ') * Specrev; - - Get_Orev : Pattern := (BreakX ('$') & "$Rev" & "ision: " - & Break ('.') & '.') * A - & Break (' ') * Oldrev & ' '; - Name_Ref : Pattern := Span (' ') * A & Break (' ') * Name & Span (' ') * B & ": constant Name_Id := N + " & Tdigs --- 50,63 ---- *************** begin *** 96,113 **** Oname := Nul; Val := 0; - loop - Line := Get_Line (InS); - Put_Line (OutS, Line); - exit when not Match (Line, Get_Srev); - end loop; - - loop - Line := Get_Line (InB); - exit when Match (Line, Get_Orev); - Put_Line (OutB, Line); - end loop; - Line := A & (Natural'Value (S (Oldrev)) + 1) & " $"; Line := Rpad (Line, 76) & "--"; Put_Line (OutB, Line); --- 86,91 ---- diff -Nrc3pad gcc-3.2.3/gcc/ada/xtreeprs.adb gcc-3.3/gcc/ada/xtreeprs.adb *** gcc-3.2.3/gcc/ada/xtreeprs.adb 2002-05-07 08:22:37.000000000 +0000 --- gcc-3.3/gcc/ada/xtreeprs.adb 2002-10-23 07:33:35.000000000 +0000 *************** *** 6,12 **** -- -- -- B o d y -- -- -- - -- $Revision: 1.1.16.2 $ -- -- -- Copyright (C) 1992-2001 Free Software Foundation, Inc. -- -- --- 6,11 ---- *************** procedure XTreeprs is *** 73,84 **** Prefix : VString := Nul; S : VString := Nul; S1 : VString := Nul; - Sinforev : VString := Nul; Syn : VString := Nul; Synonym : VString := Nul; - Temprev : VString := Nul; Term : VString := Nul; - Treeprsrev : VString := Nul; OutS : File_Type; -- Output file --- 72,80 ---- *************** procedure XTreeprs is *** 128,137 **** wsp : Pattern := Span (' ' & ASCII.HT); - Get_SRev : Pattern := BreakX ('$') & "$Rev" & "ision: " - & Break (' ') * Sinforev; - Get_TRev : Pattern := BreakX ('$') & "$Rev" & "ision: " - & Break (' ') * Temprev; Is_Temp : Pattern := BreakX ('T') * A & "T e m p l a t e"; Get_Node : Pattern := wsp & "-- N_" & Rest * Node; Tst_Punc : Pattern := Break (" ,."); --- 124,129 ---- *************** procedure XTreeprs is *** 149,157 **** begin Anchored_Mode := True; - Match ("$Revision: 1.1.16.2 $", - "$Rev" & "ision: " & Break (' ') * Treeprsrev); - if Argument_Count > 0 then Create (OutS, Out_File, Argument (1)); else --- 141,146 ---- *************** begin *** 180,237 **** Set (Special, "Raises_Constraint_Error", True); Set (Special, "Right_Opnd", True); - -- Get sinfo revs and write header to output file - - loop - Line := Get_Line (InS); - Lineno := Lineno + 1; - - if Line = "" then - raise Err; - end if; - - exit when Match (Line, Get_SRev); - end loop; - -- Read template header and generate new header loop Line := Get_Line (InT); ! if Match (Line, Get_TRev) then ! Put_Line ! (OutS, ! "-- Generated by xtreeprs revision " & ! Treeprsrev & " using"); ! ! Put_Line ! (OutS, ! "-- sinfo.ads revision " & ! Sinforev); ! ! Put_Line ! (OutS, ! "-- treeprs.adt revision " ! & Temprev); ! ! else ! -- Skip lines describing the template ! ! if Match (Line, "-- This file is a template") then ! loop ! Line := Get_Line (InT); ! exit when Line = ""; ! end loop; ! end if; ! exit when Match (Line, "package"); ! if Match (Line, Is_Temp, M) then ! Replace (M, A & " S p e c "); ! end if; ! Put_Line (OutS, Line); end if; end loop; Put_Line (OutS, Line); --- 169,195 ---- Set (Special, "Raises_Constraint_Error", True); Set (Special, "Right_Opnd", True); -- Read template header and generate new header loop Line := Get_Line (InT); ! -- Skip lines describing the template ! if Match (Line, "-- This file is a template") then ! loop ! Line := Get_Line (InT); ! exit when Line = ""; ! end loop; ! end if; ! exit when Match (Line, "package"); ! if Match (Line, Is_Temp, M) then ! Replace (M, A & " S p e c "); end if; + + Put_Line (OutS, Line); end loop; Put_Line (OutS, Line);